summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/8_3_names.test197
-rw-r--r--test/aggerror.test78
-rw-r--r--test/alias.test140
-rw-r--r--test/all.test51
-rw-r--r--test/alter.test862
-rw-r--r--test/alter2.test468
-rw-r--r--test/alter3.test397
-rw-r--r--test/alter4.test332
-rw-r--r--test/altermalloc.test71
-rw-r--r--test/analyze.test364
-rw-r--r--test/analyze3.test615
-rw-r--r--test/analyze4.test111
-rw-r--r--test/analyze5.test231
-rw-r--r--test/analyze6.test122
-rw-r--r--test/analyze7.test113
-rw-r--r--test/analyze8.test103
-rw-r--r--test/async.test90
-rw-r--r--test/async2.test126
-rw-r--r--test/async3.test76
-rw-r--r--test/async4.test168
-rw-r--r--test/async5.test69
-rw-r--r--test/attach.test843
-rw-r--r--test/attach2.test394
-rw-r--r--test/attach3.test354
-rw-r--r--test/attach4.test118
-rw-r--r--test/attachmalloc.test77
-rw-r--r--test/auth.test2372
-rw-r--r--test/auth2.test170
-rw-r--r--test/auth3.test111
-rw-r--r--test/autoinc.test668
-rw-r--r--test/autoindex1.test261
-rw-r--r--test/autovacuum.test698
-rw-r--r--test/autovacuum_ioerr2.test132
-rw-r--r--test/avtrans.test926
-rw-r--r--test/backcompat.test445
-rw-r--r--test/backup.test972
-rw-r--r--test/backup2.test189
-rw-r--r--test/backup_ioerr.test286
-rw-r--r--test/backup_malloc.test87
-rw-r--r--test/badutf.test143
-rw-r--r--test/badutf2.test121
-rw-r--r--test/between.test113
-rw-r--r--test/bigfile.test200
-rw-r--r--test/bigrow.test223
-rw-r--r--test/bind.test758
-rw-r--r--test/bindxfer.test76
-rw-r--r--test/bitvec.test195
-rw-r--r--test/blob.test147
-rw-r--r--test/boundary1.tcl289
-rw-r--r--test/boundary1.test7645
-rw-r--r--test/boundary2.tcl445
-rw-r--r--test/boundary2.test15198
-rw-r--r--test/boundary3.tcl290
-rw-r--r--test/boundary3.test12456
-rw-r--r--test/boundary4.tcl340
-rw-r--r--test/boundary4.test343
-rw-r--r--test/busy.test61
-rw-r--r--test/cache.test140
-rw-r--r--test/capi2.test801
-rw-r--r--test/capi3.test1215
-rw-r--r--test/capi3b.test145
-rw-r--r--test/capi3c.test1363
-rw-r--r--test/capi3d.test116
-rw-r--r--test/capi3e.test122
-rw-r--r--test/cast.test346
-rw-r--r--test/check.test374
-rw-r--r--test/coalesce.test84
-rw-r--r--test/collate1.test307
-rw-r--r--test/collate2.test694
-rw-r--r--test/collate3.test428
-rw-r--r--test/collate4.test701
-rw-r--r--test/collate5.test292
-rw-r--r--test/collate6.test153
-rw-r--r--test/collate7.test72
-rw-r--r--test/collate8.test125
-rw-r--r--test/collate9.test178
-rw-r--r--test/collateA.test217
-rw-r--r--test/colmeta.test94
-rw-r--r--test/colname.test329
-rw-r--r--test/conflict.test814
-rw-r--r--test/corrupt.test344
-rw-r--r--test/corrupt2.test558
-rw-r--r--test/corrupt3.test114
-rw-r--r--test/corrupt4.test79
-rw-r--r--test/corrupt5.test45
-rw-r--r--test/corrupt6.test256
-rw-r--r--test/corrupt7.test130
-rw-r--r--test/corrupt8.test104
-rw-r--r--test/corrupt9.test136
-rw-r--r--test/corruptA.test79
-rw-r--r--test/corruptB.test189
-rw-r--r--test/corruptC.test407
-rw-r--r--test/corruptD.test140
-rw-r--r--test/corruptE.test175
-rw-r--r--test/count.test192
-rw-r--r--test/crash.test411
-rw-r--r--test/crash2.test133
-rw-r--r--test/crash3.test190
-rw-r--r--test/crash4.test102
-rw-r--r--test/crash5.test110
-rw-r--r--test/crash6.test118
-rw-r--r--test/crash7.test82
-rw-r--r--test/crash8.test402
-rw-r--r--test/crashtest1.c96
-rw-r--r--test/createtab.test146
-rw-r--r--test/crypto.test1148
-rw-r--r--test/cse.test160
-rw-r--r--test/ctime.test227
-rw-r--r--test/date.test531
-rw-r--r--test/dbstatus.test359
-rw-r--r--test/dbstatus2.test76
-rw-r--r--test/default.test67
-rw-r--r--test/delete.test394
-rw-r--r--test/delete2.test119
-rw-r--r--test/delete3.test57
-rw-r--r--test/descidx1.test364
-rw-r--r--test/descidx2.test185
-rw-r--r--test/descidx3.test154
-rw-r--r--test/diskfull.test115
-rw-r--r--test/distinct.test166
-rw-r--r--test/distinctagg.test62
-rw-r--r--test/e_createtable.test1930
-rw-r--r--test/e_delete.test470
-rw-r--r--test/e_droptrigger.test218
-rw-r--r--test/e_dropview.test192
-rw-r--r--test/e_expr.test1847
-rw-r--r--test/e_fkey.test3014
-rw-r--r--test/e_fts3.test706
-rw-r--r--test/e_insert.test406
-rw-r--r--test/e_reindex.test294
-rw-r--r--test/e_resolve.test135
-rw-r--r--test/e_select.test2162
-rw-r--r--test/e_select2.test580
-rw-r--r--test/e_update.test607
-rw-r--r--test/e_uri.test456
-rw-r--r--test/e_vacuum.test303
-rw-r--r--test/enc.test172
-rw-r--r--test/enc2.test555
-rw-r--r--test/enc3.test107
-rw-r--r--test/enc4.test137
-rw-r--r--test/eqp.test578
-rw-r--r--test/errmsg.test116
-rw-r--r--test/eval.test75
-rw-r--r--test/exclusive.test509
-rw-r--r--test/exclusive2.test317
-rw-r--r--test/exec.test37
-rw-r--r--test/exists.test198
-rw-r--r--test/expr.test943
-rw-r--r--test/fallocate.test146
-rw-r--r--test/filectrl.test41
-rw-r--r--test/filefmt.test216
-rw-r--r--test/fkey1.test121
-rw-r--r--test/fkey2.test1991
-rw-r--r--test/fkey3.test186
-rw-r--r--test/fkey4.test55
-rw-r--r--test/fkey_malloc.test132
-rw-r--r--test/format4.test65
-rw-r--r--test/fts-9fd058691.test59
-rw-r--r--test/fts1a.test186
-rw-r--r--test/fts1b.test147
-rw-r--r--test/fts1c.test1213
-rw-r--r--test/fts1d.test65
-rw-r--r--test/fts1e.test85
-rw-r--r--test/fts1f.test90
-rw-r--r--test/fts1i.test88
-rw-r--r--test/fts1j.test89
-rw-r--r--test/fts1k.test69
-rw-r--r--test/fts1l.test65
-rw-r--r--test/fts1m.test50
-rw-r--r--test/fts1n.test45
-rw-r--r--test/fts1o.test138
-rw-r--r--test/fts1porter.test23590
-rw-r--r--test/fts2.test67
-rw-r--r--test/fts2a.test202
-rw-r--r--test/fts2b.test147
-rw-r--r--test/fts2c.test1213
-rw-r--r--test/fts2d.test65
-rw-r--r--test/fts2e.test85
-rw-r--r--test/fts2f.test90
-rw-r--r--test/fts2g.test93
-rw-r--r--test/fts2h.test76
-rw-r--r--test/fts2i.test87
-rw-r--r--test/fts2j.test89
-rw-r--r--test/fts2k.test105
-rw-r--r--test/fts2l.test69
-rw-r--r--test/fts2m.test65
-rw-r--r--test/fts2n.test196
-rw-r--r--test/fts2o.test169
-rw-r--r--test/fts2p.test357
-rw-r--r--test/fts2q.test346
-rw-r--r--test/fts2r.test121
-rw-r--r--test/fts2token.test174
-rw-r--r--test/fts3.test19
-rw-r--r--test/fts3_common.tcl290
-rw-r--r--test/fts3aa.test227
-rw-r--r--test/fts3ab.test148
-rw-r--r--test/fts3ac.test1219
-rw-r--r--test/fts3ad.test106
-rw-r--r--test/fts3ae.test85
-rw-r--r--test/fts3af.test90
-rw-r--r--test/fts3ag.test94
-rw-r--r--test/fts3ah.test71
-rw-r--r--test/fts3ai.test87
-rw-r--r--test/fts3aj.test89
-rw-r--r--test/fts3ak.test105
-rw-r--r--test/fts3al.test73
-rw-r--r--test/fts3am.test65
-rw-r--r--test/fts3an.test218
-rw-r--r--test/fts3ao.test223
-rw-r--r--test/fts3atoken.test187
-rw-r--r--test/fts3auto.test704
-rw-r--r--test/fts3aux1.test462
-rw-r--r--test/fts3b.test230
-rw-r--r--test/fts3c.test255
-rw-r--r--test/fts3comp1.test115
-rw-r--r--test/fts3conf.test139
-rw-r--r--test/fts3corrupt.test169
-rw-r--r--test/fts3corrupt2.test110
-rw-r--r--test/fts3cov.test432
-rw-r--r--test/fts3d.test360
-rw-r--r--test/fts3defer.test493
-rw-r--r--test/fts3defer2.test153
-rw-r--r--test/fts3drop.test61
-rw-r--r--test/fts3e.test125
-rw-r--r--test/fts3expr.test499
-rw-r--r--test/fts3expr2.test166
-rw-r--r--test/fts3fault.test231
-rw-r--r--test/fts3fault2.test134
-rw-r--r--test/fts3first.test163
-rw-r--r--test/fts3malloc.test304
-rw-r--r--test/fts3matchinfo.test408
-rw-r--r--test/fts3near.test584
-rw-r--r--test/fts3prefix.test213
-rw-r--r--test/fts3query.test213
-rw-r--r--test/fts3rnd.test460
-rw-r--r--test/fts3shared.test72
-rw-r--r--test/fts3snippet.test463
-rw-r--r--test/fts3sort.test185
-rw-r--r--test/fts4aa.test1730
-rw-r--r--test/fts4content.test501
-rw-r--r--test/func.test1250
-rw-r--r--test/func2.test511
-rw-r--r--test/func3.test73
-rw-r--r--test/fuzz.test379
-rw-r--r--test/fuzz2.test108
-rw-r--r--test/fuzz3.test169
-rw-r--r--test/fuzz_common.tcl391
-rw-r--r--test/fuzz_malloc.test94
-rw-r--r--test/fuzzer1.test1382
-rw-r--r--test/hook.test392
-rw-r--r--test/icu.test136
-rw-r--r--test/in.test609
-rw-r--r--test/in2.test67
-rw-r--r--test/in3.test289
-rw-r--r--test/in4.test162
-rw-r--r--test/incrblob.test690
-rw-r--r--test/incrblob2.test418
-rw-r--r--test/incrblob3.test272
-rw-r--r--test/incrblob_err.test139
-rw-r--r--test/incrblobfault.test70
-rw-r--r--test/incrvacuum.test786
-rw-r--r--test/incrvacuum2.test211
-rw-r--r--test/incrvacuum_ioerr.test181
-rw-r--r--test/index.test720
-rw-r--r--test/index2.test74
-rw-r--r--test/index3.test56
-rw-r--r--test/index4.test126
-rw-r--r--test/indexedby.test277
-rw-r--r--test/indexfault.test342
-rw-r--r--test/init.test82
-rw-r--r--test/insert.test391
-rw-r--r--test/insert2.test278
-rw-r--r--test/insert3.test205
-rw-r--r--test/insert4.test389
-rw-r--r--test/insert5.test117
-rw-r--r--test/intarray.test109
-rw-r--r--test/interrupt.test183
-rw-r--r--test/intpkey.test605
-rw-r--r--test/io.test565
-rw-r--r--test/ioerr.test465
-rw-r--r--test/ioerr2.test170
-rw-r--r--test/ioerr3.test42
-rw-r--r--test/ioerr4.test100
-rw-r--r--test/ioerr5.test216
-rw-r--r--test/join.test644
-rw-r--r--test/join2.test75
-rw-r--r--test/join3.test62
-rw-r--r--test/join4.test98
-rw-r--r--test/join5.test110
-rw-r--r--test/join6.test158
-rw-r--r--test/journal1.test67
-rw-r--r--test/journal2.test234
-rw-r--r--test/journal3.test60
-rw-r--r--test/jrnlmode.test558
-rw-r--r--test/jrnlmode2.test123
-rw-r--r--test/jrnlmode3.test149
-rw-r--r--test/keyword1.test118
-rw-r--r--test/lastinsert.test366
-rw-r--r--test/laststmtchanges.test331
-rw-r--r--test/like.test876
-rw-r--r--test/like2.test1009
-rw-r--r--test/limit.test472
-rw-r--r--test/loadext.test274
-rw-r--r--test/loadext2.test144
-rw-r--r--test/lock.test426
-rw-r--r--test/lock2.test111
-rw-r--r--test/lock3.test79
-rw-r--r--test/lock4.test118
-rw-r--r--test/lock5.test195
-rw-r--r--test/lock6.test167
-rw-r--r--test/lock7.test61
-rw-r--r--test/lock_common.tcl174
-rw-r--r--test/lookaside.test132
-rw-r--r--test/main.test518
-rw-r--r--test/make-where7.tcl120
-rw-r--r--test/malloc.test890
-rw-r--r--test/malloc3.test664
-rw-r--r--test/malloc4.test194
-rw-r--r--test/malloc5.test393
-rw-r--r--test/malloc6.test55
-rw-r--r--test/malloc7.test48
-rw-r--r--test/malloc8.test95
-rw-r--r--test/malloc9.test51
-rw-r--r--test/mallocA.test78
-rw-r--r--test/mallocAll.test66
-rw-r--r--test/mallocB.test51
-rw-r--r--test/mallocC.test122
-rw-r--r--test/mallocD.test65
-rw-r--r--test/mallocE.test48
-rw-r--r--test/mallocF.test76
-rw-r--r--test/mallocG.test68
-rw-r--r--test/mallocH.test73
-rw-r--r--test/mallocI.test64
-rw-r--r--test/mallocJ.test73
-rw-r--r--test/mallocK.test72
-rw-r--r--test/malloc_common.tcl660
-rw-r--r--test/manydb.test102
-rw-r--r--test/mem5.test66
-rw-r--r--test/memdb.test432
-rw-r--r--test/memleak.test97
-rw-r--r--test/memsubsys1.test309
-rw-r--r--test/memsubsys2.test173
-rw-r--r--test/minmax.test542
-rw-r--r--test/minmax2.test387
-rw-r--r--test/minmax3.test288
-rw-r--r--test/misc1.test589
-rw-r--r--test/misc2.test441
-rw-r--r--test/misc3.test355
-rw-r--r--test/misc4.test211
-rw-r--r--test/misc5.test1874
-rw-r--r--test/misc6.test48
-rw-r--r--test/misc7.test489
-rw-r--r--test/misuse.test207
-rw-r--r--test/multiplex.test569
-rw-r--r--test/mutex1.test192
-rw-r--r--test/mutex2.test105
-rw-r--r--test/nan.test371
-rw-r--r--test/notify1.test500
-rw-r--r--test/notify2.test242
-rw-r--r--test/notify3.test153
-rw-r--r--test/notnull.test539
-rw-r--r--test/null.test283
-rw-r--r--test/openv2.test55
-rw-r--r--test/oserror.test125
-rw-r--r--test/pager1.test2467
-rw-r--r--test/pager2.test151
-rw-r--r--test/pager3.test33
-rw-r--r--test/pagerfault.test1250
-rw-r--r--test/pagerfault2.test99
-rw-r--r--test/pagerfault3.test64
-rw-r--r--test/pageropt.test199
-rw-r--r--test/pagesize.test219
-rw-r--r--test/pcache.test181
-rw-r--r--test/pcache2.test79
-rw-r--r--test/permutations.test869
-rw-r--r--test/pragma.test1492
-rw-r--r--test/pragma2.test119
-rw-r--r--test/printf.test3755
-rw-r--r--test/progress.test177
-rw-r--r--test/ptrchng.test223
-rw-r--r--test/quick.test15
-rw-r--r--test/quota.test516
-rw-r--r--test/quote.test89
-rw-r--r--test/randexpr1.tcl342
-rw-r--r--test/randexpr1.test7832
-rw-r--r--test/rdonly.test84
-rw-r--r--test/reindex.test171
-rw-r--r--test/releasetest.mk14
-rw-r--r--test/releasetest.tcl339
-rw-r--r--test/rollback.test150
-rw-r--r--test/rowhash.test59
-rw-r--r--test/rowid.test703
-rw-r--r--test/rtree.test18
-rw-r--r--test/savepoint.test1045
-rw-r--r--test/savepoint2.test154
-rw-r--r--test/savepoint3.test136
-rw-r--r--test/savepoint4.test169
-rw-r--r--test/savepoint5.test46
-rw-r--r--test/savepoint6.test281
-rw-r--r--test/schema.test391
-rw-r--r--test/schema2.test340
-rw-r--r--test/schema3.test97
-rw-r--r--test/schema4.test175
-rw-r--r--test/securedel.test73
-rw-r--r--test/select1.test1070
-rw-r--r--test/select2.test185
-rw-r--r--test/select3.test264
-rw-r--r--test/select4.test808
-rw-r--r--test/select5.test257
-rw-r--r--test/select6.test517
-rw-r--r--test/select7.test202
-rw-r--r--test/select8.test62
-rw-r--r--test/select9.test419
-rw-r--r--test/selectA.test1296
-rw-r--r--test/selectB.test381
-rw-r--r--test/selectC.test236
-rw-r--r--test/server1.test171
-rw-r--r--test/shared.test1062
-rw-r--r--test/shared2.test181
-rw-r--r--test/shared3.test107
-rw-r--r--test/shared4.test237
-rw-r--r--test/shared6.test255
-rw-r--r--test/shared7.test55
-rw-r--r--test/shared_err.test521
-rw-r--r--test/sharedlock.test55
-rw-r--r--test/shortread1.test52
-rw-r--r--test/sidedelete.test92
-rw-r--r--test/soak.test90
-rw-r--r--test/softheap1.test49
-rw-r--r--test/sort.test467
-rw-r--r--test/speed1.test298
-rw-r--r--test/speed1p.explain366
-rw-r--r--test/speed1p.test346
-rw-r--r--test/speed2.test339
-rw-r--r--test/speed3.test172
-rw-r--r--test/speed4.test231
-rw-r--r--test/speed4p.explain283
-rw-r--r--test/speed4p.test292
-rw-r--r--test/sqllimits1.test844
-rw-r--r--test/stat.test167
-rw-r--r--test/stmt.test97
-rw-r--r--test/subquery.test499
-rw-r--r--test/subquery2.test86
-rw-r--r--test/subselect.test210
-rw-r--r--test/substr.test159
-rw-r--r--test/superlock.test254
-rw-r--r--test/sync.test100
-rw-r--r--test/syscall.test276
-rw-r--r--test/sysfault.test247
-rw-r--r--test/table.test728
-rw-r--r--test/tableapi.test256
-rw-r--r--test/tclsqlite.test632
-rw-r--r--test/tempdb.test93
-rw-r--r--test/temptable.test441
-rw-r--r--test/temptrigger.test204
-rw-r--r--test/tester.tcl1561
-rw-r--r--test/thread001.test145
-rw-r--r--test/thread002.test105
-rw-r--r--test/thread003.test189
-rw-r--r--test/thread004.test79
-rw-r--r--test/thread005.test238
-rw-r--r--test/thread1.test173
-rw-r--r--test/thread2.test120
-rw-r--r--test/thread_common.tcl110
-rw-r--r--test/threadtest1.c289
-rw-r--r--test/threadtest2.c133
-rw-r--r--test/threadtest3.c1461
-rw-r--r--test/tkt-02a8e81d44.test31
-rw-r--r--test/tkt-26ff0c2d1e.test33
-rw-r--r--test/tkt-2d1a5c67d.test127
-rw-r--r--test/tkt-2ea2425d34.test31
-rw-r--r--test/tkt-31338dca7e.test178
-rw-r--r--test/tkt-313723c356.test57
-rw-r--r--test/tkt-38cb5df375.test321
-rw-r--r--test/tkt-3998683a16.test46
-rw-r--r--test/tkt-3fe897352e.test60
-rw-r--r--test/tkt-4a03edc4c8.test46
-rw-r--r--test/tkt-54844eea3f.test67
-rw-r--r--test/tkt-5d863f876e.test53
-rw-r--r--test/tkt-5e10420e8d.test50
-rw-r--r--test/tkt-5ee23731f.test42
-rw-r--r--test/tkt-752e1646fc.test30
-rw-r--r--test/tkt-78e04e52ea.test68
-rw-r--r--test/tkt-80ba201079.test191
-rw-r--r--test/tkt-80e031a00f.test206
-rw-r--r--test/tkt-8454a207b9.test67
-rw-r--r--test/tkt-91e2e8ba6f.test52
-rw-r--r--test/tkt-94c04eaadb.test73
-rw-r--r--test/tkt-9d68c883.test53
-rw-r--r--test/tkt-b1d3a2e531.test109
-rw-r--r--test/tkt-b351d95f9.test47
-rw-r--r--test/tkt-b72787b1.test77
-rw-r--r--test/tkt-bd484a090c.test38
-rw-r--r--test/tkt-c48d99d690.test26
-rw-r--r--test/tkt-cbd054fa6b.test87
-rw-r--r--test/tkt-d11f09d36e.test62
-rw-r--r--test/tkt-d635236375.test38
-rw-r--r--test/tkt-d82e3f3721.test80
-rw-r--r--test/tkt-f3e5abed55.test117
-rw-r--r--test/tkt-f777251dc7a.test99
-rw-r--r--test/tkt-f7b4edec.test74
-rw-r--r--test/tkt-f973c7ac31.test87
-rw-r--r--test/tkt-fa7bf5ec.test39
-rw-r--r--test/tkt-fc62af4523.test84
-rw-r--r--test/tkt1435.test111
-rw-r--r--test/tkt1443.test180
-rw-r--r--test/tkt1444.test56
-rw-r--r--test/tkt1449.test262
-rw-r--r--test/tkt1473.test728
-rw-r--r--test/tkt1501.test36
-rw-r--r--test/tkt1512.test54
-rw-r--r--test/tkt1514.test27
-rw-r--r--test/tkt1536.test38
-rw-r--r--test/tkt1537.test122
-rw-r--r--test/tkt1567.test51
-rw-r--r--test/tkt1644.test111
-rw-r--r--test/tkt1667.test83
-rw-r--r--test/tkt1873.test72
-rw-r--r--test/tkt2141.test61
-rw-r--r--test/tkt2192.test140
-rw-r--r--test/tkt2213.test29
-rw-r--r--test/tkt2251.test108
-rw-r--r--test/tkt2285.test56
-rw-r--r--test/tkt2332.test67
-rw-r--r--test/tkt2339.test100
-rw-r--r--test/tkt2391.test49
-rw-r--r--test/tkt2409.test229
-rw-r--r--test/tkt2450.test48
-rw-r--r--test/tkt2565.test92
-rw-r--r--test/tkt2640.test124
-rw-r--r--test/tkt2643.test39
-rw-r--r--test/tkt2686.test81
-rw-r--r--test/tkt2767.test90
-rw-r--r--test/tkt2817.test72
-rw-r--r--test/tkt2820.test94
-rw-r--r--test/tkt2822.test336
-rw-r--r--test/tkt2832.test67
-rw-r--r--test/tkt2854.test149
-rw-r--r--test/tkt2920.test78
-rw-r--r--test/tkt2927.test674
-rw-r--r--test/tkt2942.test62
-rw-r--r--test/tkt3080.test77
-rw-r--r--test/tkt3093.test86
-rw-r--r--test/tkt3121.test50
-rw-r--r--test/tkt3201.test105
-rw-r--r--test/tkt3292.test61
-rw-r--r--test/tkt3298.test80
-rw-r--r--test/tkt3334.test84
-rw-r--r--test/tkt3346.test67
-rw-r--r--test/tkt3357.test64
-rw-r--r--test/tkt3419.test73
-rw-r--r--test/tkt3424.test53
-rw-r--r--test/tkt3442.test72
-rw-r--r--test/tkt3457.test87
-rw-r--r--test/tkt3461.test67
-rw-r--r--test/tkt3493.test153
-rw-r--r--test/tkt3508.test38
-rw-r--r--test/tkt3522.test43
-rw-r--r--test/tkt3527.test118
-rw-r--r--test/tkt3541.test35
-rw-r--r--test/tkt3554.test67
-rw-r--r--test/tkt3581.test54
-rw-r--r--test/tkt35xx.test102
-rw-r--r--test/tkt3630.test47
-rw-r--r--test/tkt3718.test230
-rw-r--r--test/tkt3731.test56
-rw-r--r--test/tkt3757.test60
-rw-r--r--test/tkt3761.test40
-rw-r--r--test/tkt3762.test54
-rw-r--r--test/tkt3773.test38
-rw-r--r--test/tkt3791.test28
-rw-r--r--test/tkt3793.test121
-rw-r--r--test/tkt3810.test87
-rw-r--r--test/tkt3824.test99
-rw-r--r--test/tkt3832.test41
-rw-r--r--test/tkt3838.test41
-rw-r--r--test/tkt3841.test48
-rw-r--r--test/tkt3871.test53
-rw-r--r--test/tkt3879.test52
-rw-r--r--test/tkt3911.test58
-rw-r--r--test/tkt3918.test60
-rw-r--r--test/tkt3922.test89
-rw-r--r--test/tkt3929.test53
-rw-r--r--test/tkt3935.test57
-rw-r--r--test/tkt3992.test81
-rw-r--r--test/tkt3997.test73
-rw-r--r--test/tkt4018.test89
-rw-r--r--test/tokenize.test65
-rw-r--r--test/trace.test245
-rw-r--r--test/trace2.test152
-rw-r--r--test/trans.test956
-rw-r--r--test/trans2.test232
-rw-r--r--test/trans3.test77
-rw-r--r--test/trigger1.test702
-rw-r--r--test/trigger2.test759
-rw-r--r--test/trigger3.test194
-rw-r--r--test/trigger4.test200
-rw-r--r--test/trigger5.test43
-rw-r--r--test/trigger6.test82
-rw-r--r--test/trigger7.test119
-rw-r--r--test/trigger8.test53
-rw-r--r--test/trigger9.test223
-rw-r--r--test/triggerA.test230
-rw-r--r--test/triggerB.test153
-rw-r--r--test/triggerC.test954
-rw-r--r--test/triggerD.test219
-rw-r--r--test/tt3_checkpoint.c150
-rw-r--r--test/types.test325
-rw-r--r--test/types2.test340
-rw-r--r--test/types3.test99
-rw-r--r--test/unique.test253
-rw-r--r--test/unixexcl.test83
-rw-r--r--test/unordered.test70
-rw-r--r--test/update.test608
-rw-r--r--test/uri.test312
-rw-r--r--test/utf16align.test95
-rw-r--r--test/vacuum.test404
-rw-r--r--test/vacuum2.test231
-rw-r--r--test/vacuum3.test340
-rw-r--r--test/vacuum4.test67
-rw-r--r--test/varint.test32
-rw-r--r--test/veryquick.test19
-rw-r--r--test/view.test579
-rw-r--r--test/vtab1.test1197
-rw-r--r--test/vtab2.test136
-rw-r--r--test/vtab3.test140
-rw-r--r--test/vtab4.test193
-rw-r--r--test/vtab5.test154
-rw-r--r--test/vtab6.test573
-rw-r--r--test/vtab7.test207
-rw-r--r--test/vtab8.test78
-rw-r--r--test/vtab9.test70
-rw-r--r--test/vtabA.test153
-rw-r--r--test/vtabB.test79
-rw-r--r--test/vtabC.test116
-rw-r--r--test/vtabD.test71
-rw-r--r--test/vtabE.test48
-rw-r--r--test/vtabF.test45
-rw-r--r--test/vtab_alter.test103
-rw-r--r--test/vtab_err.test71
-rw-r--r--test/vtab_shared.test231
-rw-r--r--test/wal.test1563
-rw-r--r--test/wal2.test1298
-rw-r--r--test/wal3.test786
-rw-r--r--test/wal4.test64
-rw-r--r--test/wal5.test346
-rw-r--r--test/wal6.test81
-rw-r--r--test/wal7.test118
-rw-r--r--test/wal_common.tcl93
-rw-r--r--test/walbak.test357
-rw-r--r--test/walbig.test78
-rw-r--r--test/walcksum.test393
-rw-r--r--test/walcrash.test296
-rw-r--r--test/walcrash2.test99
-rw-r--r--test/walfault.test551
-rw-r--r--test/walhook.test109
-rw-r--r--test/walmode.test387
-rw-r--r--test/walnoshm.test184
-rw-r--r--test/walpersist.test73
-rw-r--r--test/walro.test168
-rw-r--r--test/walshared.test63
-rw-r--r--test/walslow.test73
-rw-r--r--test/walthread.test527
-rw-r--r--test/where.test1260
-rw-r--r--test/where2.test654
-rw-r--r--test/where3.test428
-rw-r--r--test/where4.test273
-rw-r--r--test/where5.test288
-rw-r--r--test/where6.test154
-rw-r--r--test/where7.test23348
-rw-r--r--test/where8.test719
-rw-r--r--test/where8m.test57
-rw-r--r--test/where9.test860
-rw-r--r--test/whereA.test156
-rw-r--r--test/whereB.test543
-rw-r--r--test/wherelimit.test284
-rw-r--r--test/win32lock.test133
-rw-r--r--test/zeroblob.test259
678 files changed, 277670 insertions, 0 deletions
diff --git a/test/8_3_names.test b/test/8_3_names.test
new file mode 100644
index 0000000..b53e28a
--- /dev/null
+++ b/test/8_3_names.test
@@ -0,0 +1,197 @@
+# 2011 May 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test cases for the SQLITE_ENABLE_8_3_NAMES feature that forces all
+# filename extensions to be limited to 3 characters. Some embedded
+# systems need this to work around microsoft FAT patents, but this
+# feature should be disabled on most deployments.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !8_3_names {
+ finish_test
+ return
+}
+
+db close
+sqlite3_shutdown
+sqlite3_config_uri 1
+
+do_test 8_3_names-1.0 {
+ forcedelete test.db test.nal test.db-journal
+ sqlite3 db test.db
+ db eval {
+ PRAGMA cache_size=10;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(20000));
+ BEGIN;
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(randomblob(15000));
+ }
+ file exists test.db-journal
+} 1
+do_test 8_3_names-1.1 {
+ file exists test.nal
+} 0
+do_test 8_3_names-1.2 {
+ db eval {
+ ROLLBACK;
+ SELECT length(x) FROM t1
+ }
+} 20000
+
+db close
+do_test 8_3_names-2.0 {
+ forcedelete test.db test.nal test.db-journal
+ sqlite3 db file:./test.db?8_3_names=1
+ db eval {
+ PRAGMA cache_size=10;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(20000));
+ BEGIN;
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(randomblob(15000));
+ }
+ file exists test.db-journal
+} 0
+do_test 8_3_names-2.1 {
+ file exists test.nal
+} 1
+forcedelete test2.db test2.nal test2.db-journal
+copy_file test.db test2.db
+copy_file test.nal test2.nal
+do_test 8_3_names-2.2 {
+ db eval {
+ COMMIT;
+ SELECT length(x) FROM t1
+ }
+} 15000
+do_test 8_3_names-2.3 {
+ sqlite3 db2 file:./test2.db?8_3_names=1
+ db2 eval {
+ PRAGMA integrity_check;
+ SELECT length(x) FROM t1;
+ }
+} {ok 20000}
+
+db close
+do_test 8_3_names-3.0 {
+ forcedelete test.db test.nal test.db-journal
+ sqlite3 db file:./test.db?8_3_names=0
+ db eval {
+ PRAGMA cache_size=10;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(20000));
+ BEGIN;
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(randomblob(15000));
+ }
+ file exists test.db-journal
+} 1
+do_test 8_3_names-3.1 {
+ file exists test.nal
+} 0
+forcedelete test2.db test2.nal test2.db-journal
+copy_file test.db test2.db
+copy_file test.db-journal test2.db-journal
+do_test 8_3_names-3.2 {
+ db eval {
+ COMMIT;
+ SELECT length(x) FROM t1
+ }
+} 15000
+do_test 8_3_names-3.3 {
+ sqlite3 db2 file:./test2.db?8_3_names=0
+ db2 eval {
+ PRAGMA integrity_check;
+ SELECT length(x) FROM t1;
+ }
+} {ok 20000}
+
+##########################################################################
+# Master journals.
+#
+db close
+forcedelete test.db test2.db
+do_test 8_3_names-4.0 {
+ sqlite3 db file:./test.db?8_3_names=1
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ ATTACH 'file:./test2.db?8_3_names=1' AS db2;
+ CREATE TABLE db2.t2(y);
+ INSERT INTO t2 VALUES(2);
+ BEGIN;
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t2 VALUES(4);
+ COMMIT;
+ SELECT * FROM t1, t2 ORDER BY x, y
+ }
+} {1 2 1 4 3 2 3 4}
+
+
+##########################################################################
+# WAL mode.
+#
+ifcapable !wal {
+ finish_test
+ return
+}
+db close
+forcedelete test.db
+do_test 8_3_names-5.0 {
+ sqlite3 db file:./test.db?8_3_names=1
+ register_wholenumber_module db
+ db eval {
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(x);
+ CREATE VIRTUAL TABLE nums USING wholenumber;
+ INSERT INTO t1 SELECT value FROM nums WHERE value BETWEEN 1 AND 1000;
+ BEGIN;
+ UPDATE t1 SET x=x*2;
+ }
+ sqlite3 db2 file:./test.db?8_3_names=1
+ register_wholenumber_module db2
+ db2 eval {
+ BEGIN;
+ SELECT sum(x) FROM t1;
+ }
+} {500500}
+
+do_test 8_3_names-5.1 {
+ file exists test.db-wal
+} 0
+do_test 8_3_names-5.2 {
+ file exists test.wal
+} 1
+do_test 8_3_names-5.3 {
+ file exists test.db-shm
+} 0
+do_test 8_3_names-5.4 {
+ file exists test.shm
+} 1
+
+
+do_test 8_3_names-5.5 {
+ db eval {
+ COMMIT;
+ SELECT sum(x) FROM t1;
+ }
+} {1001000}
+do_test 8_3_names-5.6 {
+ db2 eval {
+ SELECT sum(x) FROM t1;
+ }
+} {500500}
+
+
+finish_test
diff --git a/test/aggerror.test b/test/aggerror.test
new file mode 100644
index 0000000..f95d8b2
--- /dev/null
+++ b/test/aggerror.test
@@ -0,0 +1,78 @@
+# 2006 January 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for calling sqlite3_result_error()
+# from within an aggregate function implementation.
+#
+# $Id: aggerror.test,v 1.3 2006/05/03 23:34:06 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+# Add the x_count aggregate function to the database handle.
+# x_count will error out if its input is 40 or 41 or if its
+# final results is 42. Make sure that such errors are handled
+# appropriately.
+#
+do_test aggerror-1.1 {
+ set DB [sqlite3_connection_pointer db]
+ sqlite3_create_aggregate $DB
+ execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 SELECT a+2 FROM t1;
+ INSERT INTO t1 SELECT a+4 FROM t1;
+ INSERT INTO t1 SELECT a+8 FROM t1;
+ INSERT INTO t1 SELECT a+16 FROM t1;
+ INSERT INTO t1 SELECT a+32 FROM t1 ORDER BY a LIMIT 7;
+ SELECT x_count(*) FROM t1;
+ }
+} {39}
+do_test aggerror-1.2 {
+ execsql {
+ INSERT INTO t1 VALUES(40);
+ SELECT x_count(*) FROM t1;
+ }
+} {40}
+do_test aggerror-1.3 {
+ catchsql {
+ SELECT x_count(a) FROM t1;
+ }
+} {1 {value of 40 handed to x_count}}
+ifcapable utf16 {
+ do_test aggerror-1.4 {
+ execsql {
+ UPDATE t1 SET a=41 WHERE a=40
+ }
+ catchsql {
+ SELECT x_count(a) FROM t1;
+ }
+ } {1 abc}
+}
+do_test aggerror-1.5 {
+ execsql {
+ SELECT x_count(*) FROM t1
+ }
+} 40
+do_test aggerror-1.6 {
+ execsql {
+ INSERT INTO t1 VALUES(40);
+ INSERT INTO t1 VALUES(42);
+ }
+ catchsql {
+ SELECT x_count(*) FROM t1;
+ }
+} {1 {x_count totals to 42}}
+
+finish_test
diff --git a/test/alias.test b/test/alias.test
new file mode 100644
index 0000000..2907989
--- /dev/null
+++ b/test/alias.test
@@ -0,0 +1,140 @@
+# 2008 August 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. The
+# focus of this script is correct code generation of aliased result-set
+# values. See ticket #3343.
+#
+# $Id: alias.test,v 1.3 2009/04/23 13:22:44 drh Exp $
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Aliases are currently evaluated twice. We might try to change this
+# in the future. But not now.
+return
+
+# A procedure to return a sequence of increasing integers.
+#
+namespace eval ::seq {
+ variable counter 0
+ proc value {args} {
+ variable counter
+ incr counter
+ return $counter
+ }
+ proc reset {} {
+ variable counter
+ set counter 0
+ }
+}
+
+
+do_test alias-1.1 {
+ db function sequence ::seq::value
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(9);
+ INSERT INTO t1 VALUES(8);
+ INSERT INTO t1 VALUES(7);
+ SELECT x, sequence() FROM t1;
+ }
+} {9 1 8 2 7 3}
+do_test alias-1.2 {
+ ::seq::reset
+ db eval {
+ SELECT x, sequence() AS y FROM t1 WHERE y>0
+ }
+} {9 1 8 2 7 3}
+do_test alias-1.3 {
+ ::seq::reset
+ db eval {
+ SELECT x, sequence() AS y FROM t1 WHERE y>0 AND y<99
+ }
+} {9 1 8 2 7 3}
+do_test alias-1.4 {
+ ::seq::reset
+ db eval {
+ SELECT x, sequence() AS y FROM t1 WHERE y>0 AND y<99 AND y!=55
+ }
+} {9 1 8 2 7 3}
+do_test alias-1.5 {
+ ::seq::reset
+ db eval {
+ SELECT x, sequence() AS y FROM t1
+ WHERE y>0 AND y<99 AND y!=55 AND y NOT IN (56,57,58)
+ AND y NOT LIKE 'abc%' AND y%10==2
+ }
+} {8 2}
+do_test alias-1.6 {
+ ::seq::reset
+ db eval {
+ SELECT x, sequence() AS y FROM t1 WHERE y BETWEEN 0 AND 99
+ }
+} {9 1 8 2 7 3}
+#do_test alias-1.7 {
+# ::seq::reset
+# db eval {
+# SELECT x, sequence() AS y FROM t1 WHERE y IN (55,66,3)
+# }
+#} {7 3}
+do_test alias-1.8 {
+ ::seq::reset
+ db eval {
+ SELECT x, 1-sequence() AS y FROM t1 ORDER BY y
+ }
+} {7 -2 8 -1 9 0}
+do_test alias-1.9 {
+ ::seq::reset
+ db eval {
+ SELECT x, sequence() AS y FROM t1 ORDER BY -y
+ }
+} {7 3 8 2 9 1}
+do_test alias-1.10 {
+ ::seq::reset
+ db eval {
+ SELECT x, sequence() AS y FROM t1 ORDER BY x%2, y
+ }
+} {8 2 9 1 7 3}
+
+unset -nocomplain random_int_list
+set random_int_list [db eval {
+ SELECT random()&2147483647 AS r FROM t1, t1, t1, t1 ORDER BY r
+}]
+do_test alias-1.11 {
+ lsort -integer $::random_int_list
+} $random_int_list
+
+
+do_test alias-2.1 {
+ db eval {
+ SELECT 4 UNION SELECT 1 ORDER BY 1
+ }
+} {1 4}
+do_test alias-2.2 {
+ db eval {
+ SELECT 4 UNION SELECT 1 UNION SELECT 9 ORDER BY 1
+ }
+} {1 4 9}
+
+if 0 {
+ # Aliases in the GROUP BY clause cause the expression to be evaluated
+ # twice in the current implementation. This might change in the future.
+ #
+ do_test alias-3.1 {
+ ::seq::reset
+ db eval {
+ SELECT sequence(*) AS y, count(*) AS z FROM t1 GROUP BY y ORDER BY z, y
+ }
+ } {1 1 2 1 3 1}
+}
+
+finish_test
diff --git a/test/all.test b/test/all.test
new file mode 100644
index 0000000..54302d0
--- /dev/null
+++ b/test/all.test
@@ -0,0 +1,51 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file runs all tests.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/permutations.test
+
+run_test_suite full
+
+run_test_suite no_optimization
+run_test_suite memsubsys1
+run_test_suite memsubsys2
+run_test_suite singlethread
+run_test_suite multithread
+run_test_suite onefile
+run_test_suite utf16
+run_test_suite exclusive
+run_test_suite persistent_journal
+run_test_suite persistent_journal_error
+run_test_suite no_journal
+run_test_suite no_journal_error
+run_test_suite autovacuum_ioerr
+run_test_suite no_mutex_try
+run_test_suite fullmutex
+run_test_suite journaltest
+run_test_suite inmemory_journal
+run_test_suite pcache0
+run_test_suite pcache10
+run_test_suite pcache50
+run_test_suite pcache90
+run_test_suite pcache100
+run_test_suite prepare
+
+if {$::tcl_platform(platform)=="unix"} {
+ ifcapable !default_autovacuum {
+ run_test_suite autovacuum_crash
+ }
+}
+
+finish_test
+
+
diff --git a/test/alter.test b/test/alter.test
new file mode 100644
index 0000000..1481bc2
--- /dev/null
+++ b/test/alter.test
@@ -0,0 +1,862 @@
+# 2004 November 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the ALTER TABLE statement.
+#
+# $Id: alter.test,v 1.32 2009/03/24 15:08:10 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+#----------------------------------------------------------------------
+# Test organization:
+#
+# alter-1.1.* - alter-1.7.*: Basic tests of ALTER TABLE, including tables
+# with implicit and explicit indices. These tests came from an earlier
+# fork of SQLite that also supported ALTER TABLE.
+# alter-1.8.*: Tests for ALTER TABLE when the table resides in an
+# attached database.
+# alter-1.9.*: Tests for ALTER TABLE when their is whitespace between the
+# table name and left parenthesis token. i.e:
+# "CREATE TABLE abc (a, b, c);"
+# alter-2.*: Test error conditions and messages.
+# alter-3.*: Test ALTER TABLE on tables that have TRIGGERs attached to them.
+# alter-4.*: Test ALTER TABLE on tables that have AUTOINCREMENT fields.
+# ...
+# alter-12.*: Test ALTER TABLE on views.
+#
+
+# Create some tables to rename. Be sure to include some TEMP tables
+# and some tables with odd names.
+#
+do_test alter-1.1 {
+ ifcapable tempdb {
+ set ::temp TEMP
+ } else {
+ set ::temp {}
+ }
+ execsql [subst -nocommands {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ CREATE TABLE [t1'x1](c UNIQUE, b PRIMARY KEY);
+ INSERT INTO [t1'x1] VALUES(3,4);
+ CREATE INDEX t1i1 ON T1(B);
+ CREATE INDEX t1i2 ON t1(a,b);
+ CREATE INDEX i3 ON [t1'x1](b,c);
+ CREATE $::temp TABLE "temp table"(e,f,g UNIQUE);
+ CREATE INDEX i2 ON [temp table](f);
+ INSERT INTO [temp table] VALUES(5,6,7);
+ }]
+ execsql {
+ SELECT 't1', * FROM t1;
+ SELECT 't1''x1', * FROM "t1'x1";
+ SELECT * FROM [temp table];
+ }
+} {t1 1 2 t1'x1 3 4 5 6 7}
+do_test alter-1.2 {
+ execsql [subst {
+ CREATE $::temp TABLE objlist(type, name, tbl_name);
+ INSERT INTO objlist SELECT type, name, tbl_name
+ FROM sqlite_master WHERE NAME!='objlist';
+ }]
+ ifcapable tempdb {
+ execsql {
+ INSERT INTO objlist SELECT type, name, tbl_name
+ FROM sqlite_temp_master WHERE NAME!='objlist';
+ }
+ }
+
+ execsql {
+ SELECT type, name, tbl_name FROM objlist ORDER BY tbl_name, type desc, name;
+ }
+} [list \
+ table t1 t1 \
+ index t1i1 t1 \
+ index t1i2 t1 \
+ table t1'x1 t1'x1 \
+ index i3 t1'x1 \
+ index {sqlite_autoindex_t1'x1_1} t1'x1 \
+ index {sqlite_autoindex_t1'x1_2} t1'x1 \
+ table {temp table} {temp table} \
+ index i2 {temp table} \
+ index {sqlite_autoindex_temp table_1} {temp table} \
+ ]
+
+# Make some changes
+#
+integrity_check alter-1.3.0
+do_test alter-1.3 {
+ execsql {
+ ALTER TABLE [T1] RENAME to [-t1-];
+ ALTER TABLE "t1'x1" RENAME TO T2;
+ ALTER TABLE [temp table] RENAME to TempTab;
+ }
+} {}
+integrity_check alter-1.3.1
+do_test alter-1.4 {
+ execsql {
+ SELECT 't1', * FROM [-t1-];
+ SELECT 't2', * FROM t2;
+ SELECT * FROM temptab;
+ }
+} {t1 1 2 t2 3 4 5 6 7}
+do_test alter-1.5 {
+ execsql {
+ DELETE FROM objlist;
+ INSERT INTO objlist SELECT type, name, tbl_name
+ FROM sqlite_master WHERE NAME!='objlist';
+ }
+ catchsql {
+ INSERT INTO objlist SELECT type, name, tbl_name
+ FROM sqlite_temp_master WHERE NAME!='objlist';
+ }
+ execsql {
+ SELECT type, name, tbl_name FROM objlist ORDER BY tbl_name, type desc, name;
+ }
+} [list \
+ table -t1- -t1- \
+ index t1i1 -t1- \
+ index t1i2 -t1- \
+ table T2 T2 \
+ index i3 T2 \
+ index {sqlite_autoindex_T2_1} T2 \
+ index {sqlite_autoindex_T2_2} T2 \
+ table {TempTab} {TempTab} \
+ index i2 {TempTab} \
+ index {sqlite_autoindex_TempTab_1} {TempTab} \
+ ]
+
+# Make sure the changes persist after restarting the database.
+# (The TEMP table will not persist, of course.)
+#
+ifcapable tempdb {
+ do_test alter-1.6 {
+ db close
+ sqlite3 db test.db
+ set DB [sqlite3_connection_pointer db]
+ execsql {
+ CREATE TEMP TABLE objlist(type, name, tbl_name);
+ INSERT INTO objlist SELECT type, name, tbl_name FROM sqlite_master;
+ INSERT INTO objlist
+ SELECT type, name, tbl_name FROM sqlite_temp_master
+ WHERE NAME!='objlist';
+ SELECT type, name, tbl_name FROM objlist
+ ORDER BY tbl_name, type desc, name;
+ }
+ } [list \
+ table -t1- -t1- \
+ index t1i1 -t1- \
+ index t1i2 -t1- \
+ table T2 T2 \
+ index i3 T2 \
+ index {sqlite_autoindex_T2_1} T2 \
+ index {sqlite_autoindex_T2_2} T2 \
+ ]
+} else {
+ execsql {
+ DROP TABLE TempTab;
+ }
+}
+
+# Create bogus application-defined functions for functions used
+# internally by ALTER TABLE, to ensure that ALTER TABLE falls back
+# to the built-in functions.
+#
+proc failing_app_func {args} {error "bad function"}
+do_test alter-1.7-prep {
+ db func substr failing_app_func
+ db func like failing_app_func
+ db func sqlite_rename_table failing_app_func
+ db func sqlite_rename_trigger failing_app_func
+ db func sqlite_rename_parent failing_app_func
+ catchsql {SELECT substr(name,1,3) FROM sqlite_master}
+} {1 {bad function}}
+
+# Make sure the ALTER TABLE statements work with the
+# non-callback API
+#
+do_test alter-1.7 {
+ stepsql $DB {
+ ALTER TABLE [-t1-] RENAME to [*t1*];
+ ALTER TABLE T2 RENAME TO [<t2>];
+ }
+ execsql {
+ DELETE FROM objlist;
+ INSERT INTO objlist SELECT type, name, tbl_name
+ FROM sqlite_master WHERE NAME!='objlist';
+ }
+ catchsql {
+ INSERT INTO objlist SELECT type, name, tbl_name
+ FROM sqlite_temp_master WHERE NAME!='objlist';
+ }
+ execsql {
+ SELECT type, name, tbl_name FROM objlist ORDER BY tbl_name, type desc, name;
+ }
+} [list \
+ table *t1* *t1* \
+ index t1i1 *t1* \
+ index t1i2 *t1* \
+ table <t2> <t2> \
+ index i3 <t2> \
+ index {sqlite_autoindex_<t2>_1} <t2> \
+ index {sqlite_autoindex_<t2>_2} <t2> \
+ ]
+
+# Check that ALTER TABLE works on attached databases.
+#
+ifcapable attach {
+ do_test alter-1.8.1 {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ }
+ } {}
+ do_test alter-1.8.2 {
+ execsql {
+ CREATE TABLE t4(a PRIMARY KEY, b, c);
+ CREATE TABLE aux.t4(a PRIMARY KEY, b, c);
+ CREATE INDEX i4 ON t4(b);
+ CREATE INDEX aux.i4 ON t4(b);
+ }
+ } {}
+ do_test alter-1.8.3 {
+ execsql {
+ INSERT INTO t4 VALUES('main', 'main', 'main');
+ INSERT INTO aux.t4 VALUES('aux', 'aux', 'aux');
+ SELECT * FROM t4 WHERE a = 'main';
+ }
+ } {main main main}
+ do_test alter-1.8.4 {
+ execsql {
+ ALTER TABLE t4 RENAME TO t5;
+ SELECT * FROM t4 WHERE a = 'aux';
+ }
+ } {aux aux aux}
+ do_test alter-1.8.5 {
+ execsql {
+ SELECT * FROM t5;
+ }
+ } {main main main}
+ do_test alter-1.8.6 {
+ execsql {
+ SELECT * FROM t5 WHERE b = 'main';
+ }
+ } {main main main}
+ do_test alter-1.8.7 {
+ execsql {
+ ALTER TABLE aux.t4 RENAME TO t5;
+ SELECT * FROM aux.t5 WHERE b = 'aux';
+ }
+ } {aux aux aux}
+}
+
+do_test alter-1.9.1 {
+ execsql {
+ CREATE TABLE tbl1 (a, b, c);
+ INSERT INTO tbl1 VALUES(1, 2, 3);
+ }
+} {}
+do_test alter-1.9.2 {
+ execsql {
+ SELECT * FROM tbl1;
+ }
+} {1 2 3}
+do_test alter-1.9.3 {
+ execsql {
+ ALTER TABLE tbl1 RENAME TO tbl2;
+ SELECT * FROM tbl2;
+ }
+} {1 2 3}
+do_test alter-1.9.4 {
+ execsql {
+ DROP TABLE tbl2;
+ }
+} {}
+
+# Test error messages
+#
+do_test alter-2.1 {
+ catchsql {
+ ALTER TABLE none RENAME TO hi;
+ }
+} {1 {no such table: none}}
+do_test alter-2.2 {
+ execsql {
+ CREATE TABLE t3(p,q,r);
+ }
+ catchsql {
+ ALTER TABLE [<t2>] RENAME TO t3;
+ }
+} {1 {there is already another table or index with this name: t3}}
+do_test alter-2.3 {
+ catchsql {
+ ALTER TABLE [<t2>] RENAME TO i3;
+ }
+} {1 {there is already another table or index with this name: i3}}
+do_test alter-2.4 {
+ catchsql {
+ ALTER TABLE SqLiTe_master RENAME TO master;
+ }
+} {1 {table sqlite_master may not be altered}}
+do_test alter-2.5 {
+ catchsql {
+ ALTER TABLE t3 RENAME TO sqlite_t3;
+ }
+} {1 {object name reserved for internal use: sqlite_t3}}
+do_test alter-2.6 {
+ catchsql {
+ ALTER TABLE t3 ADD COLUMN (ALTER TABLE t3 ADD COLUMN);
+ }
+} {1 {near "(": syntax error}}
+
+# If this compilation does not include triggers, omit the alter-3.* tests.
+ifcapable trigger {
+
+#-----------------------------------------------------------------------
+# Tests alter-3.* test ALTER TABLE on tables that have triggers.
+#
+# alter-3.1.*: ALTER TABLE with triggers.
+# alter-3.2.*: Test that the ON keyword cannot be used as a database,
+# table or column name unquoted. This is done because part of the
+# ALTER TABLE code (specifically the implementation of SQL function
+# "sqlite_alter_trigger") will break in this case.
+# alter-3.3.*: ALTER TABLE with TEMP triggers (todo).
+#
+
+# An SQL user-function for triggers to fire, so that we know they
+# are working.
+proc trigfunc {args} {
+ set ::TRIGGER $args
+}
+db func trigfunc trigfunc
+
+do_test alter-3.1.0 {
+ execsql {
+ CREATE TABLE t6(a, b, c);
+ CREATE TRIGGER trig1 AFTER INSERT ON t6 BEGIN
+ SELECT trigfunc('trig1', new.a, new.b, new.c);
+ END;
+ }
+} {}
+do_test alter-3.1.1 {
+ execsql {
+ INSERT INTO t6 VALUES(1, 2, 3);
+ }
+ set ::TRIGGER
+} {trig1 1 2 3}
+do_test alter-3.1.2 {
+ execsql {
+ ALTER TABLE t6 RENAME TO t7;
+ INSERT INTO t7 VALUES(4, 5, 6);
+ }
+ set ::TRIGGER
+} {trig1 4 5 6}
+do_test alter-3.1.3 {
+ execsql {
+ DROP TRIGGER trig1;
+ }
+} {}
+do_test alter-3.1.4 {
+ execsql {
+ CREATE TRIGGER trig2 AFTER INSERT ON main.t7 BEGIN
+ SELECT trigfunc('trig2', new.a, new.b, new.c);
+ END;
+ INSERT INTO t7 VALUES(1, 2, 3);
+ }
+ set ::TRIGGER
+} {trig2 1 2 3}
+do_test alter-3.1.5 {
+ execsql {
+ ALTER TABLE t7 RENAME TO t8;
+ INSERT INTO t8 VALUES(4, 5, 6);
+ }
+ set ::TRIGGER
+} {trig2 4 5 6}
+do_test alter-3.1.6 {
+ execsql {
+ DROP TRIGGER trig2;
+ }
+} {}
+do_test alter-3.1.7 {
+ execsql {
+ CREATE TRIGGER trig3 AFTER INSERT ON main.'t8'BEGIN
+ SELECT trigfunc('trig3', new.a, new.b, new.c);
+ END;
+ INSERT INTO t8 VALUES(1, 2, 3);
+ }
+ set ::TRIGGER
+} {trig3 1 2 3}
+do_test alter-3.1.8 {
+ execsql {
+ ALTER TABLE t8 RENAME TO t9;
+ INSERT INTO t9 VALUES(4, 5, 6);
+ }
+ set ::TRIGGER
+} {trig3 4 5 6}
+
+# Make sure "ON" cannot be used as a database, table or column name without
+# quoting. Otherwise the sqlite_alter_trigger() function might not work.
+forcedelete test3.db
+forcedelete test3.db-journal
+ifcapable attach {
+ do_test alter-3.2.1 {
+ catchsql {
+ ATTACH 'test3.db' AS ON;
+ }
+ } {1 {near "ON": syntax error}}
+ do_test alter-3.2.2 {
+ catchsql {
+ ATTACH 'test3.db' AS 'ON';
+ }
+ } {0 {}}
+ do_test alter-3.2.3 {
+ catchsql {
+ CREATE TABLE ON.t1(a, b, c);
+ }
+ } {1 {near "ON": syntax error}}
+ do_test alter-3.2.4 {
+ catchsql {
+ CREATE TABLE 'ON'.t1(a, b, c);
+ }
+ } {0 {}}
+ do_test alter-3.2.4 {
+ catchsql {
+ CREATE TABLE 'ON'.ON(a, b, c);
+ }
+ } {1 {near "ON": syntax error}}
+ do_test alter-3.2.5 {
+ catchsql {
+ CREATE TABLE 'ON'.'ON'(a, b, c);
+ }
+ } {0 {}}
+}
+do_test alter-3.2.6 {
+ catchsql {
+ CREATE TABLE t10(a, ON, c);
+ }
+} {1 {near "ON": syntax error}}
+do_test alter-3.2.7 {
+ catchsql {
+ CREATE TABLE t10(a, 'ON', c);
+ }
+} {0 {}}
+do_test alter-3.2.8 {
+ catchsql {
+ CREATE TRIGGER trig4 AFTER INSERT ON ON BEGIN SELECT 1; END;
+ }
+} {1 {near "ON": syntax error}}
+ifcapable attach {
+ do_test alter-3.2.9 {
+ catchsql {
+ CREATE TRIGGER 'on'.trig4 AFTER INSERT ON 'ON' BEGIN SELECT 1; END;
+ }
+ } {0 {}}
+}
+do_test alter-3.2.10 {
+ execsql {
+ DROP TABLE t10;
+ }
+} {}
+
+do_test alter-3.3.1 {
+ execsql [subst {
+ CREATE TABLE tbl1(a, b, c);
+ CREATE $::temp TRIGGER trig1 AFTER INSERT ON tbl1 BEGIN
+ SELECT trigfunc('trig1', new.a, new.b, new.c);
+ END;
+ }]
+} {}
+do_test alter-3.3.2 {
+ execsql {
+ INSERT INTO tbl1 VALUES('a', 'b', 'c');
+ }
+ set ::TRIGGER
+} {trig1 a b c}
+do_test alter-3.3.3 {
+ execsql {
+ ALTER TABLE tbl1 RENAME TO tbl2;
+ INSERT INTO tbl2 VALUES('d', 'e', 'f');
+ }
+ set ::TRIGGER
+} {trig1 d e f}
+do_test alter-3.3.4 {
+ execsql [subst {
+ CREATE $::temp TRIGGER trig2 AFTER UPDATE ON tbl2 BEGIN
+ SELECT trigfunc('trig2', new.a, new.b, new.c);
+ END;
+ }]
+} {}
+do_test alter-3.3.5 {
+ execsql {
+ ALTER TABLE tbl2 RENAME TO tbl3;
+ INSERT INTO tbl3 VALUES('g', 'h', 'i');
+ }
+ set ::TRIGGER
+} {trig1 g h i}
+do_test alter-3.3.6 {
+ execsql {
+ UPDATE tbl3 SET a = 'G' where a = 'g';
+ }
+ set ::TRIGGER
+} {trig2 G h i}
+do_test alter-3.3.7 {
+ execsql {
+ DROP TABLE tbl3;
+ }
+} {}
+ifcapable tempdb {
+ do_test alter-3.3.8 {
+ execsql {
+ SELECT * FROM sqlite_temp_master WHERE type = 'trigger';
+ }
+ } {}
+}
+
+} ;# ifcapable trigger
+
+# If the build does not include AUTOINCREMENT fields, omit alter-4.*.
+ifcapable autoinc {
+
+do_test alter-4.1 {
+ execsql {
+ CREATE TABLE tbl1(a INTEGER PRIMARY KEY AUTOINCREMENT);
+ INSERT INTO tbl1 VALUES(10);
+ }
+} {}
+do_test alter-4.2 {
+ execsql {
+ INSERT INTO tbl1 VALUES(NULL);
+ SELECT a FROM tbl1;
+ }
+} {10 11}
+do_test alter-4.3 {
+ execsql {
+ ALTER TABLE tbl1 RENAME TO tbl2;
+ DELETE FROM tbl2;
+ INSERT INTO tbl2 VALUES(NULL);
+ SELECT a FROM tbl2;
+ }
+} {12}
+do_test alter-4.4 {
+ execsql {
+ DROP TABLE tbl2;
+ }
+} {}
+
+} ;# ifcapable autoinc
+
+# Test that it is Ok to execute an ALTER TABLE immediately after
+# opening a database.
+do_test alter-5.1 {
+ execsql {
+ CREATE TABLE tbl1(a, b, c);
+ INSERT INTO tbl1 VALUES('x', 'y', 'z');
+ }
+} {}
+do_test alter-5.2 {
+ sqlite3 db2 test.db
+ execsql {
+ ALTER TABLE tbl1 RENAME TO tbl2;
+ SELECT * FROM tbl2;
+ } db2
+} {x y z}
+do_test alter-5.3 {
+ db2 close
+} {}
+
+foreach tblname [execsql {
+ SELECT name FROM sqlite_master
+ WHERE type='table' AND name NOT GLOB 'sqlite*'
+}] {
+ execsql "DROP TABLE \"$tblname\""
+}
+
+set ::tbl_name "abc\uABCDdef"
+do_test alter-6.1 {
+ string length $::tbl_name
+} {7}
+do_test alter-6.2 {
+ execsql "
+ CREATE TABLE ${tbl_name}(a, b, c);
+ "
+ set ::oid [execsql {SELECT max(oid) FROM sqlite_master}]
+ execsql "
+ SELECT sql FROM sqlite_master WHERE oid = $::oid;
+ "
+} "{CREATE TABLE ${::tbl_name}(a, b, c)}"
+execsql "
+ SELECT * FROM ${::tbl_name}
+"
+set ::tbl_name2 "abcXdef"
+do_test alter-6.3 {
+ execsql "
+ ALTER TABLE $::tbl_name RENAME TO $::tbl_name2
+ "
+ execsql "
+ SELECT sql FROM sqlite_master WHERE oid = $::oid
+ "
+} "{CREATE TABLE \"${::tbl_name2}\"(a, b, c)}"
+do_test alter-6.4 {
+ execsql "
+ ALTER TABLE $::tbl_name2 RENAME TO $::tbl_name
+ "
+ execsql "
+ SELECT sql FROM sqlite_master WHERE oid = $::oid
+ "
+} "{CREATE TABLE \"${::tbl_name}\"(a, b, c)}"
+set ::col_name ghi\1234\jkl
+do_test alter-6.5 {
+ execsql "
+ ALTER TABLE $::tbl_name ADD COLUMN $::col_name VARCHAR
+ "
+ execsql "
+ SELECT sql FROM sqlite_master WHERE oid = $::oid
+ "
+} "{CREATE TABLE \"${::tbl_name}\"(a, b, c, $::col_name VARCHAR)}"
+set ::col_name2 B\3421\A
+do_test alter-6.6 {
+ db close
+ sqlite3 db test.db
+ execsql "
+ ALTER TABLE $::tbl_name ADD COLUMN $::col_name2
+ "
+ execsql "
+ SELECT sql FROM sqlite_master WHERE oid = $::oid
+ "
+} "{CREATE TABLE \"${::tbl_name}\"(a, b, c, $::col_name VARCHAR, $::col_name2)}"
+do_test alter-6.7 {
+ execsql "
+ INSERT INTO ${::tbl_name} VALUES(1, 2, 3, 4, 5);
+ SELECT $::col_name, $::col_name2 FROM $::tbl_name;
+ "
+} {4 5}
+
+# Ticket #1665: Make sure ALTER TABLE ADD COLUMN works on a table
+# that includes a COLLATE clause.
+#
+do_realnum_test alter-7.1 {
+ execsql {
+ CREATE TABLE t1(a TEXT COLLATE BINARY);
+ ALTER TABLE t1 ADD COLUMN b INTEGER COLLATE NOCASE;
+ INSERT INTO t1 VALUES(1,'-2');
+ INSERT INTO t1 VALUES(5.4e-08,'5.4e-08');
+ SELECT typeof(a), a, typeof(b), b FROM t1;
+ }
+} {text 1 integer -2 text 5.4e-08 real 5.4e-08}
+
+# Make sure that when a column is added by ALTER TABLE ADD COLUMN and has
+# a default value that the default value is used by aggregate functions.
+#
+do_test alter-8.1 {
+ execsql {
+ CREATE TABLE t2(a INTEGER);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ ALTER TABLE t2 ADD COLUMN b INTEGER DEFAULT 9;
+ SELECT sum(b) FROM t2;
+ }
+} {27}
+do_test alter-8.2 {
+ execsql {
+ SELECT a, sum(b) FROM t2 GROUP BY a;
+ }
+} {1 18 2 9}
+
+#--------------------------------------------------------------------------
+# alter-9.X - Special test: Make sure the sqlite_rename_trigger() and
+# rename_table() functions do not crash when handed bad input.
+#
+ifcapable trigger {
+ do_test alter-9.1 {
+ execsql {SELECT SQLITE_RENAME_TRIGGER(0,0)}
+ } {{}}
+}
+do_test alter-9.2 {
+ execsql {
+ SELECT SQLITE_RENAME_TABLE(0,0);
+ SELECT SQLITE_RENAME_TABLE(10,20);
+ SELECT SQLITE_RENAME_TABLE('foo', 'foo');
+ }
+} {{} {} {}}
+
+#------------------------------------------------------------------------
+# alter-10.X - Make sure ALTER TABLE works with multi-byte UTF-8 characters
+# in the names.
+#
+do_test alter-10.1 {
+ execsql "CREATE TABLE xyz(x UNIQUE)"
+ execsql "ALTER TABLE xyz RENAME TO xyz\u1234abc"
+ execsql {SELECT name FROM sqlite_master WHERE name GLOB 'xyz*'}
+} [list xyz\u1234abc]
+do_test alter-10.2 {
+ execsql {SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_autoindex*'}
+} [list sqlite_autoindex_xyz\u1234abc_1]
+do_test alter-10.3 {
+ execsql "ALTER TABLE xyz\u1234abc RENAME TO xyzabc"
+ execsql {SELECT name FROM sqlite_master WHERE name GLOB 'xyz*'}
+} [list xyzabc]
+do_test alter-10.4 {
+ execsql {SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_autoindex*'}
+} [list sqlite_autoindex_xyzabc_1]
+
+do_test alter-11.1 {
+ sqlite3_exec db {CREATE TABLE t11(%c6%c6)}
+ execsql {
+ ALTER TABLE t11 ADD COLUMN abc;
+ }
+ catchsql {
+ ALTER TABLE t11 ADD COLUMN abc;
+ }
+} {1 {duplicate column name: abc}}
+set isutf16 [regexp 16 [db one {PRAGMA encoding}]]
+if {!$isutf16} {
+ do_test alter-11.2 {
+ execsql {INSERT INTO t11 VALUES(1,2)}
+ sqlite3_exec db {SELECT %c6%c6 AS xyz, abc FROM t11}
+ } {0 {xyz abc 1 2}}
+}
+do_test alter-11.3 {
+ sqlite3_exec db {CREATE TABLE t11b("%81%82%83" text)}
+ execsql {
+ ALTER TABLE t11b ADD COLUMN abc;
+ }
+ catchsql {
+ ALTER TABLE t11b ADD COLUMN abc;
+ }
+} {1 {duplicate column name: abc}}
+if {!$isutf16} {
+ do_test alter-11.4 {
+ execsql {INSERT INTO t11b VALUES(3,4)}
+ sqlite3_exec db {SELECT %81%82%83 AS xyz, abc FROM t11b}
+ } {0 {xyz abc 3 4}}
+ do_test alter-11.5 {
+ sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11b}
+ } {0 {xyz abc 3 4}}
+ do_test alter-11.6 {
+ sqlite3_exec db {SELECT "%81%82%83" AS xyz, abc FROM t11b}
+ } {0 {xyz abc 3 4}}
+}
+do_test alter-11.7 {
+ sqlite3_exec db {CREATE TABLE t11c(%81%82%83 text)}
+ execsql {
+ ALTER TABLE t11c ADD COLUMN abc;
+ }
+ catchsql {
+ ALTER TABLE t11c ADD COLUMN abc;
+ }
+} {1 {duplicate column name: abc}}
+if {!$isutf16} {
+ do_test alter-11.8 {
+ execsql {INSERT INTO t11c VALUES(5,6)}
+ sqlite3_exec db {SELECT %81%82%83 AS xyz, abc FROM t11c}
+ } {0 {xyz abc 5 6}}
+ do_test alter-11.9 {
+ sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11c}
+ } {0 {xyz abc 5 6}}
+ do_test alter-11.10 {
+ sqlite3_exec db {SELECT "%81%82%83" AS xyz, abc FROM t11c}
+ } {0 {xyz abc 5 6}}
+}
+
+do_test alter-12.1 {
+ execsql {
+ CREATE TABLE t12(a, b, c);
+ CREATE VIEW v1 AS SELECT * FROM t12;
+ }
+} {}
+do_test alter-12.2 {
+ catchsql {
+ ALTER TABLE v1 RENAME TO v2;
+ }
+} {1 {view v1 may not be altered}}
+do_test alter-12.3 {
+ execsql { SELECT * FROM v1; }
+} {}
+do_test alter-12.4 {
+ db close
+ sqlite3 db test.db
+ execsql { SELECT * FROM v1; }
+} {}
+do_test alter-12.5 {
+ catchsql {
+ ALTER TABLE v1 ADD COLUMN new_column;
+ }
+} {1 {Cannot add a column to a view}}
+
+# Ticket #3102:
+# Verify that comments do not interfere with the table rename
+# algorithm.
+#
+do_test alter-13.1 {
+ execsql {
+ CREATE TABLE /* hi */ t3102a(x);
+ CREATE TABLE t3102b -- comment
+ (y);
+ CREATE INDEX t3102c ON t3102a(x);
+ SELECT name FROM sqlite_master WHERE name GLOB 't3102*' ORDER BY 1;
+ }
+} {t3102a t3102b t3102c}
+do_test alter-13.2 {
+ execsql {
+ ALTER TABLE t3102a RENAME TO t3102a_rename;
+ SELECT name FROM sqlite_master WHERE name GLOB 't3102*' ORDER BY 1;
+ }
+} {t3102a_rename t3102b t3102c}
+do_test alter-13.3 {
+ execsql {
+ ALTER TABLE t3102b RENAME TO t3102b_rename;
+ SELECT name FROM sqlite_master WHERE name GLOB 't3102*' ORDER BY 1;
+ }
+} {t3102a_rename t3102b_rename t3102c}
+
+# Ticket #3651
+do_test alter-14.1 {
+ catchsql {
+ CREATE TABLE t3651(a UNIQUE);
+ ALTER TABLE t3651 ADD COLUMN b UNIQUE;
+ }
+} {1 {Cannot add a UNIQUE column}}
+do_test alter-14.2 {
+ catchsql {
+ ALTER TABLE t3651 ADD COLUMN b PRIMARY KEY;
+ }
+} {1 {Cannot add a PRIMARY KEY column}}
+
+
+#-------------------------------------------------------------------------
+# Test that it is not possible to use ALTER TABLE on any system table.
+#
+set system_table_list {1 sqlite_master}
+catchsql ANALYZE
+ifcapable analyze { lappend system_table_list 2 sqlite_stat1 }
+ifcapable stat3 { lappend system_table_list 4 sqlite_stat3 }
+
+foreach {tn tbl} $system_table_list {
+ do_test alter-15.$tn.1 {
+ catchsql "ALTER TABLE $tbl RENAME TO xyz"
+ } [list 1 "table $tbl may not be altered"]
+
+ do_test alter-15.$tn.2 {
+ catchsql "ALTER TABLE $tbl ADD COLUMN xyz"
+ } [list 1 "table $tbl may not be altered"]
+}
+
+
+finish_test
diff --git a/test/alter2.test b/test/alter2.test
new file mode 100644
index 0000000..14be637
--- /dev/null
+++ b/test/alter2.test
@@ -0,0 +1,468 @@
+# 2005 February 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing that SQLite can handle a subtle
+# file format change that may be used in the future to implement
+# "ALTER TABLE ... ADD COLUMN".
+#
+# $Id: alter2.test,v 1.14 2009/04/07 14:14:22 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# We have to have pragmas in order to do this test
+ifcapable {!pragma} return
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts. See proc [set_file_format].
+#
+do_not_use_codec
+
+# The file format change affects the way row-records stored in tables (but
+# not indices) are interpreted. Before version 3.1.3, a row-record for a
+# table with N columns was guaranteed to contain exactly N fields. As
+# of version 3.1.3, the record may contain up to N fields. In this case
+# the M fields that are present are the values for the left-most M
+# columns. The (N-M) rightmost columns contain NULL.
+#
+# If any records in the database contain less fields than their table
+# has columns, then the file-format meta value should be set to (at least) 2.
+#
+
+# This procedure sets the value of the file-format in file 'test.db'
+# to $newval. Also, the schema cookie is incremented.
+#
+proc set_file_format {newval} {
+ hexio_write test.db 44 [hexio_render_int32 $newval]
+ set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
+ incr schemacookie
+ hexio_write test.db 40 [hexio_render_int32 $schemacookie]
+ return {}
+}
+
+# This procedure returns the value of the file-format in file 'test.db'.
+#
+proc get_file_format {{fname test.db}} {
+ return [hexio_get_int [hexio_read $fname 44 4]]
+}
+
+# This procedure sets the SQL statement stored for table $tbl in the
+# sqlite_master table of file 'test.db' to $sql. Also set the file format
+# to the supplied value. This is 2 if the added column has a default that is
+# NULL, or 3 otherwise.
+#
+proc alter_table {tbl sql {file_format 2}} {
+ sqlite3 dbat test.db
+ set s [string map {' ''} $sql]
+ set t [string map {' ''} $tbl]
+ dbat eval [subst {
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master SET sql = '$s' WHERE name = '$t' AND type = 'table';
+ PRAGMA writable_schema = 0;
+ }]
+ dbat close
+ set_file_format 2
+}
+
+# Create bogus application-defined functions for functions used
+# internally by ALTER TABLE, to ensure that ALTER TABLE falls back
+# to the built-in functions.
+#
+proc failing_app_func {args} {error "bad function"}
+do_test alter2-1.0 {
+ db func substr failing_app_func
+ db func like failing_app_func
+ db func sqlite_rename_table failing_app_func
+ db func sqlite_rename_trigger failing_app_func
+ db func sqlite_rename_parent failing_app_func
+ catchsql {SELECT substr('abcdefg',1,3)}
+} {1 {bad function}}
+
+
+#-----------------------------------------------------------------------
+# Some basic tests to make sure short rows are handled.
+#
+do_test alter2-1.1 {
+ execsql {
+ CREATE TABLE abc(a, b);
+ INSERT INTO abc VALUES(1, 2);
+ INSERT INTO abc VALUES(3, 4);
+ INSERT INTO abc VALUES(5, 6);
+ }
+} {}
+do_test alter2-1.2 {
+ # ALTER TABLE abc ADD COLUMN c;
+ alter_table abc {CREATE TABLE abc(a, b, c);}
+} {}
+do_test alter2-1.3 {
+ execsql {
+ SELECT * FROM abc;
+ }
+} {1 2 {} 3 4 {} 5 6 {}}
+do_test alter2-1.4 {
+ execsql {
+ UPDATE abc SET c = 10 WHERE a = 1;
+ SELECT * FROM abc;
+ }
+} {1 2 10 3 4 {} 5 6 {}}
+do_test alter2-1.5 {
+ execsql {
+ CREATE INDEX abc_i ON abc(c);
+ }
+} {}
+do_test alter2-1.6 {
+ execsql {
+ SELECT c FROM abc ORDER BY c;
+ }
+} {{} {} 10}
+do_test alter2-1.7 {
+ execsql {
+ SELECT * FROM abc WHERE c = 10;
+ }
+} {1 2 10}
+do_test alter2-1.8 {
+ execsql {
+ SELECT sum(a), c FROM abc GROUP BY c;
+ }
+} {8 {} 1 10}
+do_test alter2-1.9 {
+ # ALTER TABLE abc ADD COLUMN d;
+ alter_table abc {CREATE TABLE abc(a, b, c, d);}
+ if {[permutation] == "prepare"} { db cache flush }
+ execsql { SELECT * FROM abc; }
+ execsql {
+ UPDATE abc SET d = 11 WHERE c IS NULL AND a<4;
+ SELECT * FROM abc;
+ }
+} {1 2 10 {} 3 4 {} 11 5 6 {} {}}
+do_test alter2-1.10 {
+ execsql {
+ SELECT typeof(d) FROM abc;
+ }
+} {null integer null}
+do_test alter2-1.99 {
+ execsql {
+ DROP TABLE abc;
+ }
+} {}
+
+#-----------------------------------------------------------------------
+# Test that views work when the underlying table structure is changed.
+#
+ifcapable view {
+ do_test alter2-2.1 {
+ execsql {
+ CREATE TABLE abc2(a, b, c);
+ INSERT INTO abc2 VALUES(1, 2, 10);
+ INSERT INTO abc2 VALUES(3, 4, NULL);
+ INSERT INTO abc2 VALUES(5, 6, NULL);
+ CREATE VIEW abc2_v AS SELECT * FROM abc2;
+ SELECT * FROM abc2_v;
+ }
+ } {1 2 10 3 4 {} 5 6 {}}
+ do_test alter2-2.2 {
+ # ALTER TABLE abc ADD COLUMN d;
+ alter_table abc2 {CREATE TABLE abc2(a, b, c, d);}
+ execsql {
+ SELECT * FROM abc2_v;
+ }
+ } {1 2 10 {} 3 4 {} {} 5 6 {} {}}
+ do_test alter2-2.3 {
+ execsql {
+ DROP TABLE abc2;
+ DROP VIEW abc2_v;
+ }
+ } {}
+}
+
+#-----------------------------------------------------------------------
+# Test that triggers work when a short row is copied to the old.*
+# trigger pseudo-table.
+#
+ifcapable trigger {
+ do_test alter2-3.1 {
+ execsql {
+ CREATE TABLE abc3(a, b);
+ CREATE TABLE blog(o, n);
+ CREATE TRIGGER abc3_t AFTER UPDATE OF b ON abc3 BEGIN
+ INSERT INTO blog VALUES(old.b, new.b);
+ END;
+ }
+ } {}
+ do_test alter2-3.2 {
+ execsql {
+ INSERT INTO abc3 VALUES(1, 4);
+ UPDATE abc3 SET b = 2 WHERE b = 4;
+ SELECT * FROM blog;
+ }
+ } {4 2}
+ do_test alter2-3.3 {
+ execsql {
+ INSERT INTO abc3 VALUES(3, 4);
+ INSERT INTO abc3 VALUES(5, 6);
+ }
+ alter_table abc3 {CREATE TABLE abc3(a, b, c);}
+ execsql {
+ SELECT * FROM abc3;
+ }
+ } {1 2 {} 3 4 {} 5 6 {}}
+ do_test alter2-3.4 {
+ execsql {
+ UPDATE abc3 SET b = b*2 WHERE a<4;
+ SELECT * FROM abc3;
+ }
+ } {1 4 {} 3 8 {} 5 6 {}}
+ do_test alter2-3.5 {
+ execsql {
+ SELECT * FROM blog;
+ }
+ } {4 2 2 4 4 8}
+
+ do_test alter2-3.6 {
+ execsql {
+ CREATE TABLE clog(o, n);
+ CREATE TRIGGER abc3_t2 AFTER UPDATE OF c ON abc3 BEGIN
+ INSERT INTO clog VALUES(old.c, new.c);
+ END;
+ UPDATE abc3 SET c = a*2;
+ SELECT * FROM clog;
+ }
+ } {{} 2 {} 6 {} 10}
+} else {
+ execsql { CREATE TABLE abc3(a, b); }
+}
+
+#---------------------------------------------------------------------
+# Check that an error occurs if the database is upgraded to a file
+# format that SQLite does not support (in this case 5). Note: The
+# file format is checked each time the schema is read, so changing the
+# file format requires incrementing the schema cookie.
+#
+do_test alter2-4.1 {
+ db close
+ set_file_format 5
+ catch { sqlite3 db test.db }
+ set {} {}
+} {}
+do_test alter2-4.2 {
+ # We have to run two queries here because the Tcl interface uses
+ # sqlite3_prepare_v2(). In this case, the first query encounters an
+ # SQLITE_SCHEMA error. Then, when trying to recompile the statement, the
+ # "unsupported file format" error is encountered. So the error code
+ # returned is SQLITE_SCHEMA, not SQLITE_ERROR as required by the following
+ # test case.
+ #
+ # When the query is attempted a second time, the same error message is
+ # returned but the error code is SQLITE_ERROR, because the unsupported
+ # file format was detected during a call to sqlite3_prepare(), not
+ # sqlite3_step().
+ #
+ catchsql { SELECT * FROM sqlite_master; }
+ catchsql { SELECT * FROM sqlite_master; }
+} {1 {unsupported file format}}
+do_test alter2-4.3 {
+ sqlite3_errcode db
+} {SQLITE_ERROR}
+do_test alter2-4.4 {
+ set ::DB [sqlite3_connection_pointer db]
+ catchsql {
+ SELECT * FROM sqlite_master;
+ }
+} {1 {unsupported file format}}
+do_test alter2-4.5 {
+ sqlite3_errcode db
+} {SQLITE_ERROR}
+
+#---------------------------------------------------------------------
+# Check that executing VACUUM on a file with file-format version 2
+# resets the file format to 1.
+#
+set default_file_format [expr $SQLITE_DEFAULT_FILE_FORMAT==4 ? 4 : 1]
+ifcapable vacuum {
+ do_test alter2-5.1 {
+ set_file_format 2
+ db close
+ sqlite3 db test.db
+ execsql {SELECT 1 FROM sqlite_master LIMIT 1;}
+ get_file_format
+ } {2}
+ do_test alter2-5.2 {
+ execsql { VACUUM }
+ } {}
+ do_test alter2-5.3 {
+ get_file_format
+ } $default_file_format
+}
+
+#---------------------------------------------------------------------
+# Test that when a database with file-format 2 is opened, new
+# databases are still created with file-format 1.
+#
+do_test alter2-6.1 {
+ db close
+ set_file_format 2
+ sqlite3 db test.db
+ get_file_format
+} {2}
+ifcapable attach {
+ do_test alter2-6.2 {
+ forcedelete test2.db-journal
+ forcedelete test2.db
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ CREATE TABLE aux.t1(a, b);
+ }
+ get_file_format test2.db
+ } $default_file_format
+}
+do_test alter2-6.3 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ }
+ get_file_format
+} {2}
+
+#---------------------------------------------------------------------
+# Test that types and values for columns added with default values
+# other than NULL work with SELECT statements.
+#
+do_test alter2-7.1 {
+ execsql {
+ DROP TABLE t1;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ SELECT * FROM t1;
+ }
+} {1 2 3 4}
+do_test alter2-7.2 {
+ set sql {CREATE TABLE t1(a, b DEFAULT '123', c INTEGER DEFAULT '123')}
+ alter_table t1 $sql 3
+ execsql {
+ SELECT * FROM t1 LIMIT 1;
+ }
+} {1 123 123}
+do_test alter2-7.3 {
+ execsql {
+ SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;
+ }
+} {1 integer 123 text 123 integer}
+do_test alter2-7.4 {
+ execsql {
+ SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;
+ }
+} {1 integer 123 text 123 integer}
+do_test alter2-7.5 {
+ set sql {CREATE TABLE t1(a, b DEFAULT -123.0, c VARCHAR(10) default 5)}
+ alter_table t1 $sql 3
+ execsql {
+ SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;
+ }
+} {1 integer -123 integer 5 text}
+
+#-----------------------------------------------------------------------
+# Test that UPDATE trigger tables work with default values, and that when
+# a row is updated the default values are correctly transfered to the
+# new row.
+#
+ifcapable trigger {
+db function set_val {set ::val}
+ do_test alter2-8.1 {
+ execsql {
+ CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN
+ SELECT set_val(
+ old.b||' '||typeof(old.b)||' '||old.c||' '||typeof(old.c)||' '||
+ new.b||' '||typeof(new.b)||' '||new.c||' '||typeof(new.c)
+ );
+ END;
+ }
+ list
+ } {}
+}
+do_test alter2-8.2 {
+ execsql {
+ UPDATE t1 SET c = 10 WHERE a = 1;
+ SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;
+ }
+} {1 integer -123 integer 10 text}
+ifcapable trigger {
+ do_test alter2-8.3 {
+ set ::val
+ } {-123 integer 5 text -123 integer 10 text}
+}
+
+#-----------------------------------------------------------------------
+# Test that DELETE trigger tables work with default values, and that when
+# a row is updated the default values are correctly transfered to the
+# new row.
+#
+ifcapable trigger {
+ do_test alter2-9.1 {
+ execsql {
+ CREATE TRIGGER trig2 BEFORE DELETE ON t1 BEGIN
+ SELECT set_val(
+ old.b||' '||typeof(old.b)||' '||old.c||' '||typeof(old.c)
+ );
+ END;
+ }
+ list
+ } {}
+ do_test alter2-9.2 {
+ execsql {
+ DELETE FROM t1 WHERE a = 2;
+ }
+ set ::val
+ } {-123 integer 5 text}
+}
+
+#-----------------------------------------------------------------------
+# Test creating an index on a column added with a default value.
+#
+ifcapable bloblit {
+ do_test alter2-10.1 {
+ execsql {
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES('a');
+ INSERT INTO t2 VALUES('b');
+ INSERT INTO t2 VALUES('c');
+ INSERT INTO t2 VALUES('d');
+ }
+ alter_table t2 {CREATE TABLE t2(a, b DEFAULT X'ABCD', c DEFAULT NULL);} 3
+ catchsql {
+ SELECT * FROM sqlite_master;
+ }
+ execsql {
+ SELECT quote(a), quote(b), quote(c) FROM t2 LIMIT 1;
+ }
+ } {'a' X'ABCD' NULL}
+ do_test alter2-10.2 {
+ execsql {
+ CREATE INDEX i1 ON t2(b);
+ SELECT a FROM t2 WHERE b = X'ABCD';
+ }
+ } {a b c d}
+ do_test alter2-10.3 {
+ execsql {
+ DELETE FROM t2 WHERE a = 'c';
+ SELECT a FROM t2 WHERE b = X'ABCD';
+ }
+ } {a b d}
+ do_test alter2-10.4 {
+ execsql {
+ SELECT count(b) FROM t2 WHERE b = X'ABCD';
+ }
+ } {3}
+}
+
+finish_test
diff --git a/test/alter3.test b/test/alter3.test
new file mode 100644
index 0000000..28d293e
--- /dev/null
+++ b/test/alter3.test
@@ -0,0 +1,397 @@
+# 2005 February 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing that SQLite can handle a subtle
+# file format change that may be used in the future to implement
+# "ALTER TABLE ... ADD COLUMN".
+#
+# $Id: alter3.test,v 1.11 2008/03/19 00:21:31 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+
+source $testdir/tester.tcl
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+# Determine if there is a codec available on this test.
+#
+if {[catch {sqlite3 -has-codec} r] || $r} {
+ set has_codec 1
+} else {
+ set has_codec 0
+}
+
+
+# Test Organisation:
+# ------------------
+#
+# alter3-1.*: Test that ALTER TABLE correctly modifies the CREATE TABLE sql.
+# alter3-2.*: Test error messages.
+# alter3-3.*: Test adding columns with default value NULL.
+# alter3-4.*: Test adding columns with default values other than NULL.
+# alter3-5.*: Test adding columns to tables in ATTACHed databases.
+# alter3-6.*: Test that temp triggers are not accidentally dropped.
+# alter3-7.*: Test that VACUUM resets the file-format.
+#
+
+# This procedure returns the value of the file-format in file 'test.db'.
+#
+proc get_file_format {{fname test.db}} {
+ return [hexio_get_int [hexio_read $fname 44 4]]
+}
+
+do_test alter3-1.1 {
+ execsql {
+ PRAGMA legacy_file_format=ON;
+ CREATE TABLE abc(a, b, c);
+ SELECT sql FROM sqlite_master;
+ }
+} {{CREATE TABLE abc(a, b, c)}}
+do_test alter3-1.2 {
+ execsql {ALTER TABLE abc ADD d INTEGER;}
+ execsql {
+ SELECT sql FROM sqlite_master;
+ }
+} {{CREATE TABLE abc(a, b, c, d INTEGER)}}
+do_test alter3-1.3 {
+ execsql {ALTER TABLE abc ADD e}
+ execsql {
+ SELECT sql FROM sqlite_master;
+ }
+} {{CREATE TABLE abc(a, b, c, d INTEGER, e)}}
+do_test alter3-1.4 {
+ execsql {
+ CREATE TABLE main.t1(a, b);
+ ALTER TABLE t1 ADD c;
+ SELECT sql FROM sqlite_master WHERE tbl_name = 't1';
+ }
+} {{CREATE TABLE t1(a, b, c)}}
+do_test alter3-1.5 {
+ execsql {
+ ALTER TABLE t1 ADD d CHECK (a>d);
+ SELECT sql FROM sqlite_master WHERE tbl_name = 't1';
+ }
+} {{CREATE TABLE t1(a, b, c, d CHECK (a>d))}}
+ifcapable foreignkey {
+ do_test alter3-1.6 {
+ execsql {
+ CREATE TABLE t2(a, b, UNIQUE(a, b));
+ ALTER TABLE t2 ADD c REFERENCES t1(c) ;
+ SELECT sql FROM sqlite_master WHERE tbl_name = 't2' AND type = 'table';
+ }
+ } {{CREATE TABLE t2(a, b, c REFERENCES t1(c), UNIQUE(a, b))}}
+}
+do_test alter3-1.7 {
+ execsql {
+ CREATE TABLE t3(a, b, UNIQUE(a, b));
+ ALTER TABLE t3 ADD COLUMN c VARCHAR(10, 20);
+ SELECT sql FROM sqlite_master WHERE tbl_name = 't3' AND type = 'table';
+ }
+} {{CREATE TABLE t3(a, b, c VARCHAR(10, 20), UNIQUE(a, b))}}
+do_test alter3-1.99 {
+ catchsql {
+ # May not exist if foriegn-keys are omitted at compile time.
+ DROP TABLE t2;
+ }
+ execsql {
+ DROP TABLE abc;
+ DROP TABLE t1;
+ DROP TABLE t3;
+ }
+} {}
+
+do_test alter3-2.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ }
+ catchsql {
+ ALTER TABLE t1 ADD c PRIMARY KEY;
+ }
+} {1 {Cannot add a PRIMARY KEY column}}
+do_test alter3-2.2 {
+ catchsql {
+ ALTER TABLE t1 ADD c UNIQUE
+ }
+} {1 {Cannot add a UNIQUE column}}
+do_test alter3-2.3 {
+ catchsql {
+ ALTER TABLE t1 ADD b VARCHAR(10)
+ }
+} {1 {duplicate column name: b}}
+do_test alter3-2.3 {
+ catchsql {
+ ALTER TABLE t1 ADD c NOT NULL;
+ }
+} {1 {Cannot add a NOT NULL column with default value NULL}}
+do_test alter3-2.4 {
+ catchsql {
+ ALTER TABLE t1 ADD c NOT NULL DEFAULT 10;
+ }
+} {0 {}}
+ifcapable view {
+ do_test alter3-2.5 {
+ execsql {
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ }
+ catchsql {
+ alter table v1 add column d;
+ }
+ } {1 {Cannot add a column to a view}}
+}
+do_test alter3-2.6 {
+ catchsql {
+ alter table t1 add column d DEFAULT CURRENT_TIME;
+ }
+} {1 {Cannot add a column with non-constant default}}
+do_test alter3-2.99 {
+ execsql {
+ DROP TABLE t1;
+ }
+} {}
+
+do_test alter3-3.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 100);
+ INSERT INTO t1 VALUES(2, 300);
+ SELECT * FROM t1;
+ }
+} {1 100 2 300}
+do_test alter3-3.1 {
+ execsql {
+ PRAGMA schema_version = 10;
+ }
+} {}
+do_test alter3-3.2 {
+ execsql {
+ ALTER TABLE t1 ADD c;
+ SELECT * FROM t1;
+ }
+} {1 100 {} 2 300 {}}
+if {!$has_codec} {
+ do_test alter3-3.3 {
+ get_file_format
+ } {3}
+}
+ifcapable schema_version {
+ do_test alter3-3.4 {
+ execsql {
+ PRAGMA schema_version;
+ }
+ } {11}
+}
+
+do_test alter3-4.1 {
+ db close
+ forcedelete test.db
+ set ::DB [sqlite3 db test.db]
+ execsql {
+ PRAGMA legacy_file_format=ON;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 100);
+ INSERT INTO t1 VALUES(2, 300);
+ SELECT * FROM t1;
+ }
+} {1 100 2 300}
+do_test alter3-4.1 {
+ execsql {
+ PRAGMA schema_version = 20;
+ }
+} {}
+do_test alter3-4.2 {
+ execsql {
+ ALTER TABLE t1 ADD c DEFAULT 'hello world';
+ SELECT * FROM t1;
+ }
+} {1 100 {hello world} 2 300 {hello world}}
+if {!$has_codec} {
+ do_test alter3-4.3 {
+ get_file_format
+ } {3}
+}
+ifcapable schema_version {
+ do_test alter3-4.4 {
+ execsql {
+ PRAGMA schema_version;
+ }
+ } {21}
+}
+do_test alter3-4.99 {
+ execsql {
+ DROP TABLE t1;
+ }
+} {}
+
+ifcapable attach {
+ do_test alter3-5.1 {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ ATTACH 'test2.db' AS aux;
+ CREATE TABLE aux.t1 AS SELECT * FROM t1;
+ PRAGMA aux.schema_version = 30;
+ SELECT sql FROM aux.sqlite_master;
+ }
+ } {{CREATE TABLE t1(a,b)}}
+ do_test alter3-5.2 {
+ execsql {
+ ALTER TABLE aux.t1 ADD COLUMN c VARCHAR(128);
+ SELECT sql FROM aux.sqlite_master;
+ }
+ } {{CREATE TABLE t1(a,b, c VARCHAR(128))}}
+ do_test alter3-5.3 {
+ execsql {
+ SELECT * FROM aux.t1;
+ }
+ } {1 one {} 2 two {}}
+ ifcapable schema_version {
+ do_test alter3-5.4 {
+ execsql {
+ PRAGMA aux.schema_version;
+ }
+ } {31}
+ }
+ if {!$has_codec} {
+ do_test alter3-5.5 {
+ list [get_file_format test2.db] [get_file_format]
+ } {2 3}
+ }
+ do_test alter3-5.6 {
+ execsql {
+ ALTER TABLE aux.t1 ADD COLUMN d DEFAULT 1000;
+ SELECT sql FROM aux.sqlite_master;
+ }
+ } {{CREATE TABLE t1(a,b, c VARCHAR(128), d DEFAULT 1000)}}
+ do_test alter3-5.7 {
+ execsql {
+ SELECT * FROM aux.t1;
+ }
+ } {1 one {} 1000 2 two {} 1000}
+ ifcapable schema_version {
+ do_test alter3-5.8 {
+ execsql {
+ PRAGMA aux.schema_version;
+ }
+ } {32}
+ }
+ do_test alter3-5.9 {
+ execsql {
+ SELECT * FROM t1;
+ }
+ } {1 one 2 two}
+ do_test alter3-5.99 {
+ execsql {
+ DROP TABLE aux.t1;
+ DROP TABLE t1;
+ }
+ } {}
+}
+
+#----------------------------------------------------------------
+# Test that the table schema is correctly reloaded when a column
+# is added to a table.
+#
+ifcapable trigger&&tempdb {
+ do_test alter3-6.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE log(trig, a, b);
+
+ CREATE TRIGGER t1_a AFTER INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('a', new.a, new.b);
+ END;
+ CREATE TEMP TRIGGER t1_b AFTER INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('b', new.a, new.b);
+ END;
+
+ INSERT INTO t1 VALUES(1, 2);
+ SELECT * FROM log;
+ }
+ } {b 1 2 a 1 2}
+ do_test alter3-6.2 {
+ execsql {
+ ALTER TABLE t1 ADD COLUMN c DEFAULT 'c';
+ INSERT INTO t1(a, b) VALUES(3, 4);
+ SELECT * FROM log;
+ }
+ } {b 1 2 a 1 2 b 3 4 a 3 4}
+}
+
+if {!$has_codec} {
+ ifcapable vacuum {
+ do_test alter3-7.1 {
+ execsql {
+ VACUUM;
+ }
+ get_file_format
+ } {1}
+ do_test alter3-7.2 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ ALTER TABLE abc ADD d DEFAULT NULL;
+ }
+ get_file_format
+ } {2}
+ do_test alter3-7.3 {
+ execsql {
+ ALTER TABLE abc ADD e DEFAULT 10;
+ }
+ get_file_format
+ } {3}
+ do_test alter3-7.4 {
+ execsql {
+ ALTER TABLE abc ADD f DEFAULT NULL;
+ }
+ get_file_format
+ } {3}
+ do_test alter3-7.5 {
+ execsql {
+ VACUUM;
+ }
+ get_file_format
+ } {1}
+ }
+}
+
+# Ticket #1183 - Make sure adding columns to large tables does not cause
+# memory corruption (as was the case before this bug was fixed).
+do_test alter3-8.1 {
+ execsql {
+ CREATE TABLE t4(c1);
+ }
+} {}
+set ::sql ""
+do_test alter3-8.2 {
+ set cols c1
+ for {set i 2} {$i < 100} {incr i} {
+ execsql "
+ ALTER TABLE t4 ADD c$i
+ "
+ lappend cols c$i
+ }
+ set ::sql "CREATE TABLE t4([join $cols {, }])"
+ list
+} {}
+do_test alter3-8.2 {
+ execsql {
+ SELECT sql FROM sqlite_master WHERE name = 't4';
+ }
+} [list $::sql]
+
+finish_test
diff --git a/test/alter4.test b/test/alter4.test
new file mode 100644
index 0000000..cda4553
--- /dev/null
+++ b/test/alter4.test
@@ -0,0 +1,332 @@
+# 2009 February 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing that SQLite can handle a subtle
+# file format change that may be used in the future to implement
+# "ALTER TABLE ... ADD COLUMN".
+#
+# $Id: alter4.test,v 1.1 2009/02/02 18:03:22 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+
+source $testdir/tester.tcl
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+
+# Test Organisation:
+# ------------------
+#
+# alter4-1.*: Test that ALTER TABLE correctly modifies the CREATE TABLE sql.
+# alter4-2.*: Test error messages.
+# alter4-3.*: Test adding columns with default value NULL.
+# alter4-4.*: Test adding columns with default values other than NULL.
+# alter4-5.*: Test adding columns to tables in ATTACHed databases.
+# alter4-6.*: Test that temp triggers are not accidentally dropped.
+# alter4-7.*: Test that VACUUM resets the file-format.
+#
+
+do_test alter4-1.1 {
+ execsql {
+ CREATE TEMP TABLE abc(a, b, c);
+ SELECT sql FROM sqlite_temp_master;
+ }
+} {{CREATE TABLE abc(a, b, c)}}
+do_test alter4-1.2 {
+ execsql {ALTER TABLE abc ADD d INTEGER;}
+ execsql {
+ SELECT sql FROM sqlite_temp_master;
+ }
+} {{CREATE TABLE abc(a, b, c, d INTEGER)}}
+do_test alter4-1.3 {
+ execsql {ALTER TABLE abc ADD e}
+ execsql {
+ SELECT sql FROM sqlite_temp_master;
+ }
+} {{CREATE TABLE abc(a, b, c, d INTEGER, e)}}
+do_test alter4-1.4 {
+ execsql {
+ CREATE TABLE temp.t1(a, b);
+ ALTER TABLE t1 ADD c;
+ SELECT sql FROM sqlite_temp_master WHERE tbl_name = 't1';
+ }
+} {{CREATE TABLE t1(a, b, c)}}
+do_test alter4-1.5 {
+ execsql {
+ ALTER TABLE t1 ADD d CHECK (a>d);
+ SELECT sql FROM sqlite_temp_master WHERE tbl_name = 't1';
+ }
+} {{CREATE TABLE t1(a, b, c, d CHECK (a>d))}}
+ifcapable foreignkey {
+ do_test alter4-1.6 {
+ execsql {
+ CREATE TEMP TABLE t2(a, b, UNIQUE(a, b));
+ ALTER TABLE t2 ADD c REFERENCES t1(c) ;
+ SELECT sql FROM sqlite_temp_master
+ WHERE tbl_name = 't2' AND type = 'table';
+ }
+ } {{CREATE TABLE t2(a, b, c REFERENCES t1(c), UNIQUE(a, b))}}
+}
+do_test alter4-1.7 {
+ execsql {
+ CREATE TEMPORARY TABLE t3(a, b, UNIQUE(a, b));
+ ALTER TABLE t3 ADD COLUMN c VARCHAR(10, 20);
+ SELECT sql FROM sqlite_temp_master
+ WHERE tbl_name = 't3' AND type = 'table';
+ }
+} {{CREATE TABLE t3(a, b, c VARCHAR(10, 20), UNIQUE(a, b))}}
+do_test alter4-1.99 {
+ catchsql {
+ # May not exist if foriegn-keys are omitted at compile time.
+ DROP TABLE t2;
+ }
+ execsql {
+ DROP TABLE abc;
+ DROP TABLE t1;
+ DROP TABLE t3;
+ }
+} {}
+
+do_test alter4-2.1 {
+ execsql {
+ CREATE TABLE temp.t1(a, b);
+ }
+ catchsql {
+ ALTER TABLE t1 ADD c PRIMARY KEY;
+ }
+} {1 {Cannot add a PRIMARY KEY column}}
+do_test alter4-2.2 {
+ catchsql {
+ ALTER TABLE t1 ADD c UNIQUE
+ }
+} {1 {Cannot add a UNIQUE column}}
+do_test alter4-2.3 {
+ catchsql {
+ ALTER TABLE t1 ADD b VARCHAR(10)
+ }
+} {1 {duplicate column name: b}}
+do_test alter4-2.3 {
+ catchsql {
+ ALTER TABLE t1 ADD c NOT NULL;
+ }
+} {1 {Cannot add a NOT NULL column with default value NULL}}
+do_test alter4-2.4 {
+ catchsql {
+ ALTER TABLE t1 ADD c NOT NULL DEFAULT 10;
+ }
+} {0 {}}
+ifcapable view {
+ do_test alter4-2.5 {
+ execsql {
+ CREATE TEMPORARY VIEW v1 AS SELECT * FROM t1;
+ }
+ catchsql {
+ alter table v1 add column d;
+ }
+ } {1 {Cannot add a column to a view}}
+}
+do_test alter4-2.6 {
+ catchsql {
+ alter table t1 add column d DEFAULT CURRENT_TIME;
+ }
+} {1 {Cannot add a column with non-constant default}}
+do_test alter4-2.99 {
+ execsql {
+ DROP TABLE t1;
+ }
+} {}
+
+do_test alter4-3.1 {
+ execsql {
+ CREATE TEMP TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 100);
+ INSERT INTO t1 VALUES(2, 300);
+ SELECT * FROM t1;
+ }
+} {1 100 2 300}
+do_test alter4-3.1 {
+ execsql {
+ PRAGMA schema_version = 10;
+ }
+} {}
+do_test alter4-3.2 {
+ execsql {
+ ALTER TABLE t1 ADD c;
+ SELECT * FROM t1;
+ }
+} {1 100 {} 2 300 {}}
+ifcapable schema_version {
+ do_test alter4-3.4 {
+ execsql {
+ PRAGMA schema_version;
+ }
+ } {10}
+}
+
+do_test alter4-4.1 {
+ db close
+ forcedelete test.db
+ set ::DB [sqlite3 db test.db]
+ execsql {
+ CREATE TEMP TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 100);
+ INSERT INTO t1 VALUES(2, 300);
+ SELECT * FROM t1;
+ }
+} {1 100 2 300}
+do_test alter4-4.1 {
+ execsql {
+ PRAGMA schema_version = 20;
+ }
+} {}
+do_test alter4-4.2 {
+ execsql {
+ ALTER TABLE t1 ADD c DEFAULT 'hello world';
+ SELECT * FROM t1;
+ }
+} {1 100 {hello world} 2 300 {hello world}}
+ifcapable schema_version {
+ do_test alter4-4.4 {
+ execsql {
+ PRAGMA schema_version;
+ }
+ } {20}
+}
+do_test alter4-4.99 {
+ execsql {
+ DROP TABLE t1;
+ }
+} {}
+
+ifcapable attach {
+ do_test alter4-5.1 {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ execsql {
+ CREATE TEMP TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ ATTACH 'test2.db' AS aux;
+ CREATE TABLE aux.t1 AS SELECT * FROM t1;
+ PRAGMA aux.schema_version = 30;
+ SELECT sql FROM aux.sqlite_master;
+ }
+ } {{CREATE TABLE t1(a,b)}}
+ do_test alter4-5.2 {
+ execsql {
+ ALTER TABLE aux.t1 ADD COLUMN c VARCHAR(128);
+ SELECT sql FROM aux.sqlite_master;
+ }
+ } {{CREATE TABLE t1(a,b, c VARCHAR(128))}}
+ do_test alter4-5.3 {
+ execsql {
+ SELECT * FROM aux.t1;
+ }
+ } {1 one {} 2 two {}}
+ ifcapable schema_version {
+ do_test alter4-5.4 {
+ execsql {
+ PRAGMA aux.schema_version;
+ }
+ } {31}
+ }
+ do_test alter4-5.6 {
+ execsql {
+ ALTER TABLE aux.t1 ADD COLUMN d DEFAULT 1000;
+ SELECT sql FROM aux.sqlite_master;
+ }
+ } {{CREATE TABLE t1(a,b, c VARCHAR(128), d DEFAULT 1000)}}
+ do_test alter4-5.7 {
+ execsql {
+ SELECT * FROM aux.t1;
+ }
+ } {1 one {} 1000 2 two {} 1000}
+ ifcapable schema_version {
+ do_test alter4-5.8 {
+ execsql {
+ PRAGMA aux.schema_version;
+ }
+ } {32}
+ }
+ do_test alter4-5.9 {
+ execsql {
+ SELECT * FROM t1;
+ }
+ } {1 one 2 two}
+ do_test alter4-5.99 {
+ execsql {
+ DROP TABLE aux.t1;
+ DROP TABLE t1;
+ }
+ } {}
+}
+
+#----------------------------------------------------------------
+# Test that the table schema is correctly reloaded when a column
+# is added to a table.
+#
+ifcapable trigger&&tempdb {
+ do_test alter4-6.1 {
+ execsql {
+ CREATE TEMP TABLE t1(a, b);
+ CREATE TEMP TABLE log(trig, a, b);
+
+ CREATE TRIGGER t1_a AFTER INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('a', new.a, new.b);
+ END;
+ CREATE TEMP TRIGGER t1_b AFTER INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('b', new.a, new.b);
+ END;
+
+ INSERT INTO t1 VALUES(1, 2);
+ SELECT * FROM log;
+ }
+ } {b 1 2 a 1 2}
+ do_test alter4-6.2 {
+ execsql {
+ ALTER TABLE t1 ADD COLUMN c DEFAULT 'c';
+ INSERT INTO t1(a, b) VALUES(3, 4);
+ SELECT * FROM log;
+ }
+ } {b 1 2 a 1 2 b 3 4 a 3 4}
+}
+
+# Ticket #1183 - Make sure adding columns to large tables does not cause
+# memory corruption (as was the case before this bug was fixed).
+do_test alter4-8.1 {
+ execsql {
+ CREATE TEMP TABLE t4(c1);
+ }
+} {}
+set ::sql ""
+do_test alter4-8.2 {
+ set cols c1
+ for {set i 2} {$i < 100} {incr i} {
+ execsql "
+ ALTER TABLE t4 ADD c$i
+ "
+ lappend cols c$i
+ }
+ set ::sql "CREATE TABLE t4([join $cols {, }])"
+ list
+} {}
+do_test alter4-8.2 {
+ execsql {
+ SELECT sql FROM sqlite_temp_master WHERE name = 't4';
+ }
+} [list $::sql]
+
+finish_test
diff --git a/test/altermalloc.test b/test/altermalloc.test
new file mode 100644
index 0000000..a35e7d5
--- /dev/null
+++ b/test/altermalloc.test
@@ -0,0 +1,71 @@
+# 2005 September 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the ALTER TABLE statement and
+# specifically out-of-memory conditions within that command.
+#
+# $Id: altermalloc.test,v 1.10 2008/10/30 17:21:13 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable||!memdebug {
+ finish_test
+ return
+}
+
+source $testdir/malloc_common.tcl
+
+do_malloc_test altermalloc-1 -tclprep {
+ db close
+} -tclbody {
+ if {[catch {sqlite3 db test.db}]} {
+ error "out of memory"
+ }
+ sqlite3_db_config_lookaside db 0 0 0
+ sqlite3_extended_result_codes db 1
+} -sqlbody {
+ CREATE TABLE t1(a int);
+ ALTER TABLE t1 ADD COLUMN b INTEGER DEFAULT NULL;
+ ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT 'default-text';
+ ALTER TABLE t1 RENAME TO t2;
+ ALTER TABLE t2 ADD COLUMN d BLOB DEFAULT X'ABCD';
+}
+
+# Test malloc() failure on an ALTER TABLE on a virtual table.
+#
+ifcapable vtab {
+ do_malloc_test altermalloc-vtab -tclprep {
+ sqlite3 db2 test.db
+ sqlite3_db_config_lookaside db2 0 0 0
+ sqlite3_extended_result_codes db2 1
+ register_echo_module [sqlite3_connection_pointer db2]
+ db2 eval {
+ CREATE TABLE t1(a, b VARCHAR, c INTEGER);
+ CREATE VIRTUAL TABLE t1echo USING echo(t1);
+ }
+ db2 close
+
+ register_echo_module [sqlite3_connection_pointer db]
+ } -tclbody {
+ set rc [catch {db eval { ALTER TABLE t1echo RENAME TO t1_echo }} msg]
+ if {$msg eq "vtable constructor failed: t1echo"} {
+ set msg "out of memory"
+ }
+ if {$rc} {
+ error $msg
+ }
+ }
+}
+
+finish_test
diff --git a/test/analyze.test b/test/analyze.test
new file mode 100644
index 0000000..362702a
--- /dev/null
+++ b/test/analyze.test
@@ -0,0 +1,364 @@
+# 2005 July 22
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+# This file implements tests for the ANALYZE command.
+#
+# $Id: analyze.test,v 1.9 2008/08/11 18:44:58 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# There is nothing to test if ANALYZE is disable for this build.
+#
+ifcapable {!analyze} {
+ finish_test
+ return
+}
+
+# Basic sanity checks.
+#
+do_test analyze-1.1 {
+ catchsql {
+ ANALYZE no_such_table
+ }
+} {1 {no such table: no_such_table}}
+do_test analyze-1.2 {
+ execsql {
+ SELECT count(*) FROM sqlite_master WHERE name='sqlite_stat1'
+ }
+} {0}
+do_test analyze-1.3 {
+ catchsql {
+ ANALYZE no_such_db.no_such_table
+ }
+} {1 {unknown database no_such_db}}
+do_test analyze-1.4 {
+ execsql {
+ SELECT count(*) FROM sqlite_master WHERE name='sqlite_stat1'
+ }
+} {0}
+do_test analyze-1.5.1 {
+ catchsql {
+ ANALYZE
+ }
+} {0 {}}
+do_test analyze-1.5.2 {
+ catchsql {
+ PRAGMA empty_result_callbacks=1;
+ ANALYZE
+ }
+} {0 {}}
+do_test analyze-1.6 {
+ execsql {
+ SELECT count(*) FROM sqlite_master WHERE name='sqlite_stat1'
+ }
+} {1}
+do_test analyze-1.6.2 {
+ catchsql {
+ CREATE INDEX stat1idx ON sqlite_stat1(idx);
+ }
+} {1 {table sqlite_stat1 may not be indexed}}
+do_test analyze-1.6.3 {
+ catchsql {
+ CREATE INDEX main.stat1idx ON SQLite_stat1(idx);
+ }
+} {1 {table sqlite_stat1 may not be indexed}}
+do_test analyze-1.7 {
+ execsql {
+ SELECT * FROM sqlite_stat1 WHERE idx NOT NULL
+ }
+} {}
+do_test analyze-1.8 {
+ catchsql {
+ ANALYZE main
+ }
+} {0 {}}
+do_test analyze-1.9 {
+ execsql {
+ SELECT * FROM sqlite_stat1 WHERE idx NOT NULL
+ }
+} {}
+do_test analyze-1.10 {
+ catchsql {
+ CREATE TABLE t1(a,b);
+ ANALYZE main.t1;
+ }
+} {0 {}}
+do_test analyze-1.11 {
+ execsql {
+ SELECT * FROM sqlite_stat1
+ }
+} {}
+do_test analyze-1.12 {
+ catchsql {
+ ANALYZE t1;
+ }
+} {0 {}}
+do_test analyze-1.13 {
+ execsql {
+ SELECT * FROM sqlite_stat1
+ }
+} {}
+
+# Create some indices that can be analyzed. But do not yet add
+# data. Without data in the tables, no analysis is done.
+#
+do_test analyze-2.1 {
+ execsql {
+ CREATE INDEX t1i1 ON t1(a);
+ ANALYZE main.t1;
+ SELECT * FROM sqlite_stat1 ORDER BY idx;
+ }
+} {}
+do_test analyze-2.2 {
+ execsql {
+ CREATE INDEX t1i2 ON t1(b);
+ ANALYZE t1;
+ SELECT * FROM sqlite_stat1 ORDER BY idx;
+ }
+} {}
+do_test analyze-2.3 {
+ execsql {
+ CREATE INDEX t1i3 ON t1(a,b);
+ ANALYZE main;
+ SELECT * FROM sqlite_stat1 ORDER BY idx;
+ }
+} {}
+
+# Start adding data to the table. Verify that the analysis
+# is done correctly.
+#
+do_test analyze-3.1 {
+ execsql {
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(1,3);
+ ANALYZE main.t1;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {t1i1 {2 2} t1i2 {2 1} t1i3 {2 2 1}}
+do_test analyze-3.2 {
+ execsql {
+ INSERT INTO t1 VALUES(1,4);
+ INSERT INTO t1 VALUES(1,5);
+ ANALYZE t1;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {t1i1 {4 4} t1i2 {4 1} t1i3 {4 4 1}}
+do_test analyze-3.3 {
+ execsql {
+ INSERT INTO t1 VALUES(2,5);
+ ANALYZE main;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1}}
+do_test analyze-3.4 {
+ execsql {
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ CREATE INDEX t2i1 ON t2(a);
+ CREATE INDEX t2i2 ON t2(b);
+ CREATE INDEX t2i3 ON t2(a,b);
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1} t2i1 {5 3} t2i2 {5 2} t2i3 {5 3 1}}
+do_test analyze-3.5 {
+ execsql {
+ DROP INDEX t2i3;
+ ANALYZE t1;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1} t2i1 {5 3} t2i2 {5 2}}
+do_test analyze-3.6 {
+ execsql {
+ ANALYZE t2;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1} t2i1 {5 3} t2i2 {5 2}}
+do_test analyze-3.7 {
+ execsql {
+ DROP INDEX t2i2;
+ ANALYZE t2;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1} t2i1 {5 3}}
+do_test analyze-3.8 {
+ execsql {
+ CREATE TABLE t3 AS SELECT a, b, rowid AS c, 'hi' AS d FROM t1;
+ CREATE INDEX t3i1 ON t3(a);
+ CREATE INDEX t3i2 ON t3(a,b,c,d);
+ CREATE INDEX t3i3 ON t3(d,b,c,a);
+ DROP TABLE t1;
+ DROP TABLE t2;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {}
+do_test analyze-3.9 {
+ execsql {
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}
+
+do_test analyze-3.10 {
+ execsql {
+ CREATE TABLE [silly " name](a, b, c);
+ CREATE INDEX 'foolish '' name' ON [silly " name](a, b);
+ CREATE INDEX 'another foolish '' name' ON [silly " name](c);
+ INSERT INTO [silly " name] VALUES(1, 2, 3);
+ INSERT INTO [silly " name] VALUES(4, 5, 6);
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {{another foolish ' name} {2 1} {foolish ' name} {2 1 1} t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}
+do_test analyze-3.11 {
+ execsql {
+ DROP INDEX "foolish ' name";
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {{another foolish ' name} {2 1} t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}
+do_test analyze-3.11 {
+ execsql {
+ DROP TABLE "silly "" name";
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}
+
+# Try corrupting the sqlite_stat1 table and make sure the
+# database is still able to function.
+#
+do_test analyze-4.0 {
+ sqlite3 db2 test.db
+ db2 eval {
+ CREATE TABLE t4(x,y,z);
+ CREATE INDEX t4i1 ON t4(x);
+ CREATE INDEX t4i2 ON t4(y);
+ INSERT INTO t4 SELECT a,b,c FROM t3;
+ }
+ db2 close
+ db close
+ sqlite3 db test.db
+ execsql {
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ }
+} {t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1} t4i1 {5 3} t4i2 {5 2}}
+do_test analyze-4.1 {
+ execsql {
+ PRAGMA writable_schema=on;
+ INSERT INTO sqlite_stat1 VALUES(null,null,null);
+ PRAGMA writable_schema=off;
+ }
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM t4 WHERE x=1234;
+ }
+} {}
+do_test analyze-4.2 {
+ execsql {
+ PRAGMA writable_schema=on;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1 VALUES('t4','t4i1','nonsense');
+ INSERT INTO sqlite_stat1 VALUES('t4','t4i2','120897349817238741092873198273409187234918720394817209384710928374109827172901827349871928741910');
+ PRAGMA writable_schema=off;
+ }
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM t4 WHERE x=1234;
+ }
+} {}
+do_test analyze-4.3 {
+ execsql {
+ INSERT INTO sqlite_stat1 VALUES('t4','xyzzy','0 1 2 3');
+ }
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM t4 WHERE x=1234;
+ }
+} {}
+
+# Verify that DROP TABLE and DROP INDEX remove entries from the
+# sqlite_stat1 and sqlite_stat3 tables.
+#
+do_test analyze-5.0 {
+ execsql {
+ DELETE FROM t3;
+ DELETE FROM t4;
+ INSERT INTO t3 VALUES(1,2,3,4);
+ INSERT INTO t3 VALUES(5,6,7,8);
+ INSERT INTO t3 SELECT a+8, b+8, c+8, d+8 FROM t3;
+ INSERT INTO t3 SELECT a+16, b+16, c+16, d+16 FROM t3;
+ INSERT INTO t3 SELECT a+32, b+32, c+32, d+32 FROM t3;
+ INSERT INTO t3 SELECT a+64, b+64, c+64, d+64 FROM t3;
+ INSERT INTO t4 SELECT a, b, c FROM t3;
+ ANALYZE;
+ SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1;
+ SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1;
+ }
+} {t3i1 t3i2 t3i3 t4i1 t4i2 t3 t4}
+ifcapable stat3 {
+ do_test analyze-5.1 {
+ execsql {
+ SELECT DISTINCT idx FROM sqlite_stat3 ORDER BY 1;
+ SELECT DISTINCT tbl FROM sqlite_stat3 ORDER BY 1;
+ }
+ } {t3i1 t3i2 t3i3 t4i1 t4i2 t3 t4}
+}
+do_test analyze-5.2 {
+ execsql {
+ DROP INDEX t3i2;
+ SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1;
+ SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1;
+ }
+} {t3i1 t3i3 t4i1 t4i2 t3 t4}
+ifcapable stat3 {
+ do_test analyze-5.3 {
+ execsql {
+ SELECT DISTINCT idx FROM sqlite_stat3 ORDER BY 1;
+ SELECT DISTINCT tbl FROM sqlite_stat3 ORDER BY 1;
+ }
+ } {t3i1 t3i3 t4i1 t4i2 t3 t4}
+}
+do_test analyze-5.4 {
+ execsql {
+ DROP TABLE t3;
+ SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1;
+ SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1;
+ }
+} {t4i1 t4i2 t4}
+ifcapable stat3 {
+ do_test analyze-5.5 {
+ execsql {
+ SELECT DISTINCT idx FROM sqlite_stat3 ORDER BY 1;
+ SELECT DISTINCT tbl FROM sqlite_stat3 ORDER BY 1;
+ }
+ } {t4i1 t4i2 t4}
+}
+
+# This test corrupts the database file so it must be the last test
+# in the series.
+#
+do_test analyze-99.1 {
+ execsql {
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET sql='nonsense' WHERE name='sqlite_stat1';
+ }
+ db close
+ catch { sqlite3 db test.db }
+ catchsql {
+ ANALYZE
+ }
+} {1 {malformed database schema (sqlite_stat1) - near "nonsense": syntax error}}
+
+
+finish_test
diff --git a/test/analyze3.test b/test/analyze3.test
new file mode 100644
index 0000000..f705bc6
--- /dev/null
+++ b/test/analyze3.test
@@ -0,0 +1,615 @@
+# 2009 August 06
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. This file
+# implements tests for range and LIKE constraints that use bound variables
+# instead of literal constant arguments.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !stat3 {
+ finish_test
+ return
+}
+
+#----------------------------------------------------------------------
+# Test Organization:
+#
+# analyze3-1.*: Test that the values of bound parameters are considered
+# in the same way as constants when planning queries that
+# use range constraints.
+#
+# analyze3-2.*: Test that the values of bound parameters are considered
+# in the same way as constants when planning queries that
+# use LIKE expressions in the WHERE clause.
+#
+# analyze3-3.*: Test that binding to a variable does not invalidate the
+# query plan when there is no way in which replanning the
+# query may produce a superior outcome.
+#
+# analyze3-4.*: Test that SQL or authorization callback errors occuring
+# within sqlite3Reprepare() are handled correctly.
+#
+# analyze3-5.*: Check that the query plans of applicable statements are
+# invalidated if the values of SQL parameter are modified
+# using the clear_bindings() or transfer_bindings() APIs.
+#
+
+proc getvar {varname} { uplevel #0 set $varname }
+db function var getvar
+
+proc eqp {sql {db db}} {
+ uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db
+}
+
+proc sf_execsql {sql {db db}} {
+ set ::sqlite_search_count 0
+ set r [uplevel [list execsql $sql $db]]
+
+ concat $::sqlite_search_count [$db status step] $r
+}
+
+#-------------------------------------------------------------------------
+#
+# analyze3-1.1.1:
+# Create a table with two columns. Populate the first column (affinity
+# INTEGER) with integer values from 100 to 1100. Create an index on this
+# column. ANALYZE the table.
+#
+# analyze3-1.1.2 - 3.1.3
+# Show that there are two possible plans for querying the table with
+# a range constraint on the indexed column - "full table scan" or "use
+# the index". When the range is specified using literal values, SQLite
+# is able to pick the best plan based on the samples in sqlite_stat3.
+#
+# analyze3-1.1.4 - 3.1.9
+# Show that using SQL variables produces the same results as using
+# literal values to constrain the range scan.
+#
+# These tests also check that the compiler code considers column
+# affinities when estimating the number of rows scanned by the "use
+# index strategy".
+#
+do_test analyze3-1.1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(x INTEGER, y);
+ CREATE INDEX i1 ON t1(x);
+ }
+ for {set i 0} {$i < 1000} {incr i} {
+ execsql { INSERT INTO t1 VALUES($i+100, $i) }
+ }
+ execsql {
+ COMMIT;
+ ANALYZE;
+ }
+} {}
+
+do_eqp_test analyze3-1.1.2 {
+ SELECT sum(y) FROM t1 WHERE x>200 AND x<300
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x<?) (~179 rows)}}
+do_eqp_test analyze3-1.1.3 {
+ SELECT sum(y) FROM t1 WHERE x>0 AND x<1100
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x<?) (~959 rows)}}
+
+do_test analyze3-1.1.4 {
+ sf_execsql { SELECT sum(y) FROM t1 WHERE x>200 AND x<300 }
+} {199 0 14850}
+do_test analyze3-1.1.5 {
+ set l [string range "200" 0 end]
+ set u [string range "300" 0 end]
+ sf_execsql { SELECT sum(y) FROM t1 WHERE x>$l AND x<$u }
+} {199 0 14850}
+do_test analyze3-1.1.6 {
+ set l [expr int(200)]
+ set u [expr int(300)]
+ sf_execsql { SELECT sum(y) FROM t1 WHERE x>$l AND x<$u }
+} {199 0 14850}
+do_test analyze3-1.1.7 {
+ sf_execsql { SELECT sum(y) FROM t1 WHERE x>0 AND x<1100 }
+} {2000 0 499500}
+do_test analyze3-1.1.8 {
+ set l [string range "0" 0 end]
+ set u [string range "1100" 0 end]
+ sf_execsql { SELECT sum(y) FROM t1 WHERE x>$l AND x<$u }
+} {2000 0 499500}
+do_test analyze3-1.1.9 {
+ set l [expr int(0)]
+ set u [expr int(1100)]
+ sf_execsql { SELECT sum(y) FROM t1 WHERE x>$l AND x<$u }
+} {2000 0 499500}
+
+
+# The following tests are similar to the block above. The difference is
+# that the indexed column has TEXT affinity in this case. In the tests
+# above the affinity is INTEGER.
+#
+do_test analyze3-1.2.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t2(x TEXT, y);
+ INSERT INTO t2 SELECT * FROM t1;
+ CREATE INDEX i2 ON t2(x);
+ COMMIT;
+ ANALYZE;
+ }
+} {}
+do_eqp_test analyze3-1.2.2 {
+ SELECT sum(y) FROM t2 WHERE x>1 AND x<2
+} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?) (~196 rows)}}
+do_eqp_test analyze3-1.2.3 {
+ SELECT sum(y) FROM t2 WHERE x>0 AND x<99
+} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?) (~968 rows)}}
+do_test analyze3-1.2.4 {
+ sf_execsql { SELECT sum(y) FROM t2 WHERE x>12 AND x<20 }
+} {161 0 4760}
+do_test analyze3-1.2.5 {
+ set l [string range "12" 0 end]
+ set u [string range "20" 0 end]
+ sf_execsql {SELECT typeof($l), typeof($u), sum(y) FROM t2 WHERE x>$l AND x<$u}
+} {161 0 text text 4760}
+do_test analyze3-1.2.6 {
+ set l [expr int(12)]
+ set u [expr int(20)]
+ sf_execsql {SELECT typeof($l), typeof($u), sum(y) FROM t2 WHERE x>$l AND x<$u}
+} {161 0 integer integer 4760}
+do_test analyze3-1.2.7 {
+ sf_execsql { SELECT sum(y) FROM t2 WHERE x>0 AND x<99 }
+} {1981 0 490555}
+do_test analyze3-1.2.8 {
+ set l [string range "0" 0 end]
+ set u [string range "99" 0 end]
+ sf_execsql {SELECT typeof($l), typeof($u), sum(y) FROM t2 WHERE x>$l AND x<$u}
+} {1981 0 text text 490555}
+do_test analyze3-1.2.9 {
+ set l [expr int(0)]
+ set u [expr int(99)]
+ sf_execsql {SELECT typeof($l), typeof($u), sum(y) FROM t2 WHERE x>$l AND x<$u}
+} {1981 0 integer integer 490555}
+
+# Same tests a third time. This time, column x has INTEGER affinity and
+# is not the leftmost column of the table. This triggered a bug causing
+# SQLite to use sub-optimal query plans in 3.6.18 and earlier.
+#
+do_test analyze3-1.3.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(y TEXT, x INTEGER);
+ INSERT INTO t3 SELECT y, x FROM t1;
+ CREATE INDEX i3 ON t3(x);
+ COMMIT;
+ ANALYZE;
+ }
+} {}
+do_eqp_test analyze3-1.3.2 {
+ SELECT sum(y) FROM t3 WHERE x>200 AND x<300
+} {0 0 0 {SEARCH TABLE t3 USING INDEX i3 (x>? AND x<?) (~156 rows)}}
+do_eqp_test analyze3-1.3.3 {
+ SELECT sum(y) FROM t3 WHERE x>0 AND x<1100
+} {0 0 0 {SEARCH TABLE t3 USING INDEX i3 (x>? AND x<?) (~989 rows)}}
+
+do_test analyze3-1.3.4 {
+ sf_execsql { SELECT sum(y) FROM t3 WHERE x>200 AND x<300 }
+} {199 0 14850}
+do_test analyze3-1.3.5 {
+ set l [string range "200" 0 end]
+ set u [string range "300" 0 end]
+ sf_execsql { SELECT sum(y) FROM t3 WHERE x>$l AND x<$u }
+} {199 0 14850}
+do_test analyze3-1.3.6 {
+ set l [expr int(200)]
+ set u [expr int(300)]
+ sf_execsql { SELECT sum(y) FROM t3 WHERE x>$l AND x<$u }
+} {199 0 14850}
+do_test analyze3-1.3.7 {
+ sf_execsql { SELECT sum(y) FROM t3 WHERE x>0 AND x<1100 }
+} {2000 0 499500}
+do_test analyze3-1.3.8 {
+ set l [string range "0" 0 end]
+ set u [string range "1100" 0 end]
+ sf_execsql { SELECT sum(y) FROM t3 WHERE x>$l AND x<$u }
+} {2000 0 499500}
+do_test analyze3-1.3.9 {
+ set l [expr int(0)]
+ set u [expr int(1100)]
+ sf_execsql { SELECT sum(y) FROM t3 WHERE x>$l AND x<$u }
+} {2000 0 499500}
+
+#-------------------------------------------------------------------------
+# Test that the values of bound SQL variables may be used for the LIKE
+# optimization.
+#
+drop_all_tables
+do_test analyze3-2.1 {
+ execsql {
+ PRAGMA case_sensitive_like=off;
+ BEGIN;
+ CREATE TABLE t1(a, b TEXT COLLATE nocase);
+ CREATE INDEX i1 ON t1(b);
+ }
+ for {set i 0} {$i < 1000} {incr i} {
+ set t ""
+ append t [lindex {a b c d e f g h i j} [expr $i/100]]
+ append t [lindex {a b c d e f g h i j} [expr ($i/10)%10]]
+ append t [lindex {a b c d e f g h i j} [expr ($i%10)]]
+ execsql { INSERT INTO t1 VALUES($i, $t) }
+ }
+ execsql COMMIT
+} {}
+do_eqp_test analyze3-2.2 {
+ SELECT count(a) FROM t1 WHERE b LIKE 'a%'
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (b>? AND b<?) (~31250 rows)}}
+do_eqp_test analyze3-2.3 {
+ SELECT count(a) FROM t1 WHERE b LIKE '%a'
+} {0 0 0 {SCAN TABLE t1 (~500000 rows)}}
+
+do_test analyze3-2.4 {
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE 'a%' }
+} {101 0 100}
+do_test analyze3-2.5 {
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE '%a' }
+} {999 999 100}
+
+do_test analyze3-2.4 {
+ set like "a%"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} {101 0 100}
+do_test analyze3-2.5 {
+ set like "%a"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} {999 999 100}
+do_test analyze3-2.6 {
+ set like "a"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} {101 0 0}
+do_test analyze3-2.7 {
+ set like "ab"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} {11 0 0}
+do_test analyze3-2.8 {
+ set like "abc"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} {2 0 1}
+do_test analyze3-2.9 {
+ set like "a_c"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} {101 0 10}
+
+
+#-------------------------------------------------------------------------
+# This block of tests checks that statements are correctly marked as
+# expired when the values bound to any parameters that may affect the
+# query plan are modified.
+#
+drop_all_tables
+db auth auth
+proc auth {args} {
+ set ::auth 1
+ return SQLITE_OK
+}
+
+do_test analyze3-3.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(b);
+ }
+ for {set i 0} {$i < 100} {incr i} {
+ execsql { INSERT INTO t1 VALUES($i, $i, $i) }
+ }
+ execsql COMMIT
+ execsql ANALYZE
+} {}
+
+do_test analyze3-3.2.1 {
+ set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE b>?" -1 dummy]
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.2.2 {
+ sqlite3_bind_text $S 1 "abc" 3
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.2.4 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+do_test analyze3-3.2.5 {
+ set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE b=?" -1 dummy]
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.2.6 {
+ sqlite3_bind_text $S 1 "abc" 3
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.2.7 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+do_test analyze3-3.4.1 {
+ set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy]
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.4.2 {
+ sqlite3_bind_text $S 1 "abc" 3
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.4.3 {
+ sqlite3_bind_text $S 2 "def" 3
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.4.4 {
+ sqlite3_bind_text $S 2 "ghi" 3
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.4.5 {
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.4.6 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+do_test analyze3-3.5.1 {
+ set S [sqlite3_prepare_v2 db {
+ SELECT * FROM t1 WHERE a IN (
+ ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10,
+ ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20,
+ ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31
+ ) AND b>?32;
+ } -1 dummy]
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.5.2 {
+ sqlite3_bind_text $S 31 "abc" 3
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.5.3 {
+ sqlite3_bind_text $S 32 "def" 3
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.5.5 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+do_test analyze3-3.6.1 {
+ set S [sqlite3_prepare_v2 db {
+ SELECT * FROM t1 WHERE a IN (
+ ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10,
+ ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20,
+ ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32
+ ) AND b>?33;
+ } -1 dummy]
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.6.2 {
+ sqlite3_bind_text $S 32 "abc" 3
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.6.3 {
+ sqlite3_bind_text $S 33 "def" 3
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.6.5 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+do_test analyze3-3.7.1 {
+ set S [sqlite3_prepare_v2 db {
+ SELECT * FROM t1 WHERE a IN (
+ ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?33,
+ ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20,
+ ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32
+ ) AND b>?10;
+ } -1 dummy]
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.7.2 {
+ sqlite3_bind_text $S 32 "abc" 3
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.7.3 {
+ sqlite3_bind_text $S 33 "def" 3
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.7.4 {
+ sqlite3_bind_text $S 10 "def" 3
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.7.6 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+do_test analyze3-3.8.1 {
+ execsql {
+ CREATE TABLE t4(x, y TEXT COLLATE NOCASE);
+ CREATE INDEX i4 ON t4(y);
+ }
+} {}
+do_test analyze3-3.8.2 {
+ set S [sqlite3_prepare_v2 db {
+ SELECT * FROM t4 WHERE x != ? AND y LIKE ?
+ } -1 dummy]
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.8.3 {
+ sqlite3_bind_text $S 1 "abc" 3
+ sqlite3_expired $S
+} {0}
+do_test analyze3-3.8.4 {
+ sqlite3_bind_text $S 2 "def" 3
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.8.7 {
+ sqlite3_bind_text $S 2 "ghi%" 4
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.8.8 {
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.8.9 {
+ sqlite3_bind_text $S 2 "ghi%def" 7
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.8.10 {
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.8.11 {
+ sqlite3_bind_text $S 2 "%ab" 3
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.8.12 {
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.8.12 {
+ sqlite3_bind_text $S 2 "%de" 3
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.8.13 {
+ sqlite3_expired $S
+} {1}
+do_test analyze3-3.8.14 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+#-------------------------------------------------------------------------
+# These tests check that errors encountered while repreparing an SQL
+# statement within sqlite3Reprepare() are handled correctly.
+#
+
+# Check a schema error.
+#
+do_test analyze3-4.1.1 {
+ set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy]
+ sqlite3_step $S
+} {SQLITE_DONE}
+do_test analyze3-4.1.2 {
+ sqlite3_reset $S
+ sqlite3_bind_text $S 2 "abc" 3
+ execsql { DROP TABLE t1 }
+ sqlite3_step $S
+} {SQLITE_ERROR}
+do_test analyze3-4.1.3 {
+ sqlite3_finalize $S
+} {SQLITE_ERROR}
+
+# Check an authorization error.
+#
+do_test analyze3-4.2.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(b);
+ }
+ for {set i 0} {$i < 100} {incr i} {
+ execsql { INSERT INTO t1 VALUES($i, $i, $i) }
+ }
+ execsql COMMIT
+ execsql ANALYZE
+ set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy]
+ sqlite3_step $S
+} {SQLITE_DONE}
+db auth auth
+proc auth {args} {
+ if {[lindex $args 0] == "SQLITE_READ"} {return SQLITE_DENY}
+ return SQLITE_OK
+}
+do_test analyze3-4.2.2 {
+ sqlite3_reset $S
+ sqlite3_bind_text $S 2 "abc" 3
+ sqlite3_step $S
+} {SQLITE_AUTH}
+do_test analyze3-4.2.4 {
+ sqlite3_finalize $S
+} {SQLITE_AUTH}
+
+# Check the effect of an authorization error that occurs in a re-prepare
+# performed by sqlite3_step() is the same as one that occurs within
+# sqlite3Reprepare().
+#
+do_test analyze3-4.3.1 {
+ db auth {}
+ set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy]
+ execsql { CREATE TABLE t2(d, e, f) }
+ db auth auth
+ sqlite3_step $S
+} {SQLITE_AUTH}
+do_test analyze3-4.3.2 {
+ sqlite3_finalize $S
+} {SQLITE_AUTH}
+db auth {}
+
+#-------------------------------------------------------------------------
+# Test that modifying bound variables using the clear_bindings() or
+# transfer_bindings() APIs works.
+#
+# analyze3-5.1.*: sqlite3_clear_bindings()
+# analyze3-5.2.*: sqlite3_transfer_bindings()
+#
+do_test analyze3-5.1.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE t1(x TEXT COLLATE NOCASE);
+ CREATE INDEX i1 ON t1(x);
+ INSERT INTO t1 VALUES('aaa');
+ INSERT INTO t1 VALUES('abb');
+ INSERT INTO t1 VALUES('acc');
+ INSERT INTO t1 VALUES('baa');
+ INSERT INTO t1 VALUES('bbb');
+ INSERT INTO t1 VALUES('bcc');
+ }
+
+ set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE x LIKE ?" -1 dummy]
+ sqlite3_bind_text $S 1 "a%" 2
+ set R [list]
+ while { "SQLITE_ROW" == [sqlite3_step $S] } {
+ lappend R [sqlite3_column_text $S 0]
+ }
+ concat [sqlite3_reset $S] $R
+} {SQLITE_OK aaa abb acc}
+do_test analyze3-5.1.2 {
+ sqlite3_clear_bindings $S
+ set R [list]
+ while { "SQLITE_ROW" == [sqlite3_step $S] } {
+ lappend R [sqlite3_column_text $S 0]
+ }
+ concat [sqlite3_reset $S] $R
+} {SQLITE_OK}
+do_test analyze3-5.1.3 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+do_test analyze3-5.1.1 {
+ set S1 [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE x LIKE ?" -1 dummy]
+ sqlite3_bind_text $S1 1 "b%" 2
+ set R [list]
+ while { "SQLITE_ROW" == [sqlite3_step $S1] } {
+ lappend R [sqlite3_column_text $S1 0]
+ }
+ concat [sqlite3_reset $S1] $R
+} {SQLITE_OK baa bbb bcc}
+
+do_test analyze3-5.1.2 {
+ set S2 [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE x = ?" -1 dummy]
+ sqlite3_bind_text $S2 1 "a%" 2
+ sqlite3_transfer_bindings $S2 $S1
+ set R [list]
+ while { "SQLITE_ROW" == [sqlite3_step $S1] } {
+ lappend R [sqlite3_column_text $S1 0]
+ }
+ concat [sqlite3_reset $S1] $R
+} {SQLITE_OK aaa abb acc}
+do_test analyze3-5.1.3 {
+ sqlite3_finalize $S2
+ sqlite3_finalize $S1
+} {SQLITE_OK}
+
+finish_test
diff --git a/test/analyze4.test b/test/analyze4.test
new file mode 100644
index 0000000..1fed564
--- /dev/null
+++ b/test/analyze4.test
@@ -0,0 +1,111 @@
+# 2011 January 04
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. This file
+# implements tests for ANALYZE to verify that multiple rows containing
+# a NULL value count as distinct rows for the purposes of analyze
+# statistics.
+#
+# Also include test cases for collating sequences on indices.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test analyze4-1.0 {
+ db eval {
+ CREATE TABLE t1(a,b);
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ INSERT INTO t1 VALUES(1,NULL);
+ INSERT INTO t1 SELECT a+1, b FROM t1;
+ INSERT INTO t1 SELECT a+2, b FROM t1;
+ INSERT INTO t1 SELECT a+4, b FROM t1;
+ INSERT INTO t1 SELECT a+8, b FROM t1;
+ INSERT INTO t1 SELECT a+16, b FROM t1;
+ INSERT INTO t1 SELECT a+32, b FROM t1;
+ INSERT INTO t1 SELECT a+64, b FROM t1;
+ ANALYZE;
+ }
+
+ # Should choose the t1a index since it is more specific than t1b.
+ db eval {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=5 AND b IS NULL}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
+
+# Verify that the t1b index shows that it does not narrow down the
+# search any at all.
+#
+do_test analyze4-1.1 {
+ db eval {
+ SELECT idx, stat FROM sqlite_stat1 WHERE tbl='t1' ORDER BY idx;
+ }
+} {t1a {128 1} t1b {128 128}}
+
+# Change half of the b values from NULL to a constant. Verify
+# that the number of rows selected in stat1 is half the total
+# number of rows.
+#
+do_test analyze4-1.2 {
+ db eval {
+ UPDATE t1 SET b='x' WHERE a%2;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 WHERE tbl='t1' ORDER BY idx;
+ }
+} {t1a {128 1} t1b {128 64}}
+
+# Change the t1.b values all back to NULL. Add columns t1.c and t1.d.
+# Create a multi-column indices using t1.b and verify that ANALYZE
+# processes them correctly.
+#
+do_test analyze4-1.3 {
+ db eval {
+ UPDATE t1 SET b=NULL;
+ ALTER TABLE t1 ADD COLUMN c;
+ ALTER TABLE t1 ADD COLUMN d;
+ UPDATE t1 SET c=a/4, d=a/2;
+ CREATE INDEX t1bcd ON t1(b,c,d);
+ CREATE INDEX t1cdb ON t1(c,d,b);
+ CREATE INDEX t1cbd ON t1(c,b,d);
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 WHERE tbl='t1' ORDER BY idx;
+ }
+} {t1a {128 1} t1b {128 128} t1bcd {128 128 4 2} t1cbd {128 4 4 2} t1cdb {128 4 2 2}}
+
+# Verify that collating sequences are taken into account when computing
+# ANALYZE statistics.
+#
+do_test analyze4-2.0 {
+ db eval {
+ CREATE TABLE t2(
+ x INTEGER PRIMARY KEY,
+ a TEXT COLLATE nocase,
+ b TEXT COLLATE rtrim,
+ c TEXT COLLATE binary
+ );
+ CREATE INDEX t2a ON t2(a);
+ CREATE INDEX t2b ON t2(b);
+ CREATE INDEX t2c ON t2(c);
+ CREATE INDEX t2c2 ON t2(c COLLATE nocase);
+ CREATE INDEX t2c3 ON t2(c COLLATE rtrim);
+ INSERT INTO t2 VALUES(1, 'abc', 'abc', 'abc');
+ INSERT INTO t2 VALUES(2, 'abC', 'abC', 'abC');
+ INSERT INTO t2 VALUES(3, 'abc ', 'abc ', 'abc ');
+ INSERT INTO t2 VALUES(4, 'abC ', 'abC ', 'abC ');
+ INSERT INTO t2 VALUES(5, 'aBc', 'aBc', 'aBc');
+ INSERT INTO t2 VALUES(6, 'aBC', 'aBC', 'aBC');
+ INSERT INTO t2 VALUES(7, 'aBc ', 'aBc ', 'aBc ');
+ INSERT INTO t2 VALUES(8, 'aBC ', 'aBC ', 'aBC ');
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 WHERE tbl='t2' ORDER BY idx;
+ }
+} {t2a {8 4} t2b {8 2} t2c {8 1} t2c2 {8 4} t2c3 {8 2}}
+
+finish_test
diff --git a/test/analyze5.test b/test/analyze5.test
new file mode 100644
index 0000000..1041d70
--- /dev/null
+++ b/test/analyze5.test
@@ -0,0 +1,231 @@
+# 2011 January 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests for SQLite library. The focus of the tests
+# in this file is the use of the sqlite_stat3 histogram data on tables
+# with many repeated values and only a few distinct values.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !stat3 {
+ finish_test
+ return
+}
+
+set testprefix analyze5
+
+proc eqp {sql {db db}} {
+ uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db
+}
+
+unset -nocomplain i t u v w x y z
+do_test analyze5-1.0 {
+ db eval {CREATE TABLE t1(t,u,v TEXT COLLATE nocase,w,x,y,z)}
+ for {set i 0} {$i < 1000} {incr i} {
+ set y [expr {$i>=25 && $i<=50}]
+ set z [expr {($i>=400) + ($i>=700) + ($i>=875)}]
+ set x $z
+ set w $z
+ set t [expr {$z+0.5}]
+ switch $z {
+ 0 {set u "alpha"; unset x}
+ 1 {set u "bravo"}
+ 2 {set u "charlie"}
+ 3 {set u "delta"; unset w}
+ }
+ if {$i%2} {set v $u} {set v [string toupper $u]}
+ db eval {INSERT INTO t1 VALUES($t,$u,$v,$w,$x,$y,$z)}
+ }
+ db eval {
+ CREATE INDEX t1t ON t1(t); -- 0.5, 1.5, 2.5, and 3.5
+ CREATE INDEX t1u ON t1(u); -- text
+ CREATE INDEX t1v ON t1(v); -- mixed case text
+ CREATE INDEX t1w ON t1(w); -- integers 0, 1, 2 and a few NULLs
+ CREATE INDEX t1x ON t1(x); -- integers 1, 2, 3 and many NULLs
+ CREATE INDEX t1y ON t1(y); -- integers 0 and very few 1s
+ CREATE INDEX t1z ON t1(z); -- integers 0, 1, 2, and 3
+ ANALYZE;
+ SELECT sample FROM sqlite_stat3 WHERE idx='t1u' ORDER BY nlt;
+ }
+} {alpha bravo charlie delta}
+
+do_test analyze5-1.1 {
+ db eval {SELECT DISTINCT lower(sample) FROM sqlite_stat3 WHERE idx='t1v'
+ ORDER BY 1}
+} {alpha bravo charlie delta}
+do_test analyze5-1.2 {
+ db eval {SELECT idx, count(*) FROM sqlite_stat3 GROUP BY 1 ORDER BY 1}
+} {t1t 4 t1u 4 t1v 4 t1w 4 t1x 4 t1y 2 t1z 4}
+
+# Verify that range queries generate the correct row count estimates
+#
+foreach {testid where index rows} {
+ 1 {z>=0 AND z<=0} t1z 400
+ 2 {z>=1 AND z<=1} t1z 300
+ 3 {z>=2 AND z<=2} t1z 175
+ 4 {z>=3 AND z<=3} t1z 125
+ 5 {z>=4 AND z<=4} t1z 1
+ 6 {z>=-1 AND z<=-1} t1z 1
+ 7 {z>1 AND z<3} t1z 175
+ 8 {z>0 AND z<100} t1z 600
+ 9 {z>=1 AND z<100} t1z 600
+ 10 {z>1 AND z<100} t1z 300
+ 11 {z>=2 AND z<100} t1z 300
+ 12 {z>2 AND z<100} t1z 125
+ 13 {z>=3 AND z<100} t1z 125
+ 14 {z>3 AND z<100} t1z 1
+ 15 {z>=4 AND z<100} t1z 1
+ 16 {z>=-100 AND z<=-1} t1z 1
+ 17 {z>=-100 AND z<=0} t1z 400
+ 18 {z>=-100 AND z<0} t1z 1
+ 19 {z>=-100 AND z<=1} t1z 700
+ 20 {z>=-100 AND z<2} t1z 700
+ 21 {z>=-100 AND z<=2} t1z 875
+ 22 {z>=-100 AND z<3} t1z 875
+
+ 31 {z>=0.0 AND z<=0.0} t1z 400
+ 32 {z>=1.0 AND z<=1.0} t1z 300
+ 33 {z>=2.0 AND z<=2.0} t1z 175
+ 34 {z>=3.0 AND z<=3.0} t1z 125
+ 35 {z>=4.0 AND z<=4.0} t1z 1
+ 36 {z>=-1.0 AND z<=-1.0} t1z 1
+ 37 {z>1.5 AND z<3.0} t1z 174
+ 38 {z>0.5 AND z<100} t1z 599
+ 39 {z>=1.0 AND z<100} t1z 600
+ 40 {z>1.5 AND z<100} t1z 299
+ 41 {z>=2.0 AND z<100} t1z 300
+ 42 {z>2.1 AND z<100} t1z 124
+ 43 {z>=3.0 AND z<100} t1z 125
+ 44 {z>3.2 AND z<100} t1z 1
+ 45 {z>=4.0 AND z<100} t1z 1
+ 46 {z>=-100 AND z<=-1.0} t1z 1
+ 47 {z>=-100 AND z<=0.0} t1z 400
+ 48 {z>=-100 AND z<0.0} t1z 1
+ 49 {z>=-100 AND z<=1.0} t1z 700
+ 50 {z>=-100 AND z<2.0} t1z 700
+ 51 {z>=-100 AND z<=2.0} t1z 875
+ 52 {z>=-100 AND z<3.0} t1z 875
+
+ 101 {z=-1} t1z 1
+ 102 {z=0} t1z 400
+ 103 {z=1} t1z 300
+ 104 {z=2} t1z 175
+ 105 {z=3} t1z 125
+ 106 {z=4} t1z 1
+ 107 {z=-10.0} t1z 1
+ 108 {z=0.0} t1z 400
+ 109 {z=1.0} t1z 300
+ 110 {z=2.0} t1z 175
+ 111 {z=3.0} t1z 125
+ 112 {z=4.0} t1z 1
+ 113 {z=1.5} t1z 1
+ 114 {z=2.5} t1z 1
+
+ 201 {z IN (-1)} t1z 1
+ 202 {z IN (0)} t1z 400
+ 203 {z IN (1)} t1z 300
+ 204 {z IN (2)} t1z 175
+ 205 {z IN (3)} t1z 125
+ 206 {z IN (4)} t1z 1
+ 207 {z IN (0.5)} t1z 1
+ 208 {z IN (0,1)} t1z 700
+ 209 {z IN (0,1,2)} t1z 875
+ 210 {z IN (0,1,2,3)} {} 100
+ 211 {z IN (0,1,2,3,4,5)} {} 100
+ 212 {z IN (1,2)} t1z 475
+ 213 {z IN (2,3)} t1z 300
+ 214 {z=3 OR z=2} t1z 300
+ 215 {z IN (-1,3)} t1z 126
+ 216 {z=-1 OR z=3} t1z 126
+
+ 300 {y=0} t1y 974
+ 301 {y=1} t1y 26
+ 302 {y=0.1} t1y 1
+
+ 400 {x IS NULL} t1x 400
+
+} {
+ # Verify that the expected index is used with the expected row count
+ do_test analyze5-1.${testid}a {
+ set x [lindex [eqp "SELECT * FROM t1 WHERE $where"] 3]
+ set idx {}
+ regexp {INDEX (t1.) } $x all idx
+ regexp {~([0-9]+) rows} $x all nrow
+ list $idx $nrow
+ } [list $index $rows]
+
+ # Verify that the same result is achieved regardless of whether or not
+ # the index is used
+ do_test analyze5-1.${testid}b {
+ set w2 [string map {y +y z +z} $where]
+ set a1 [db eval "SELECT rowid FROM t1 NOT INDEXED WHERE $w2\
+ ORDER BY +rowid"]
+ set a2 [db eval "SELECT rowid FROM t1 WHERE $where ORDER BY +rowid"]
+ if {$a1==$a2} {
+ set res ok
+ } else {
+ set res "a1=\[$a1\] a2=\[$a2\]"
+ }
+ set res
+ } {ok}
+}
+
+# Increase the number of NULLs in column x
+#
+db eval {
+ UPDATE t1 SET x=NULL;
+ UPDATE t1 SET x=rowid
+ WHERE rowid IN (SELECT rowid FROM t1 ORDER BY random() LIMIT 5);
+ ANALYZE;
+}
+
+# Verify that range queries generate the correct row count estimates
+#
+foreach {testid where index rows} {
+ 500 {x IS NULL AND u='charlie'} t1u 17
+ 501 {x=1 AND u='charlie'} t1x 1
+ 502 {x IS NULL} t1x 995
+ 503 {x=1} t1x 1
+ 504 {x IS NOT NULL} t1x 2
+ 505 {+x IS NOT NULL} {} 500
+ 506 {upper(x) IS NOT NULL} {} 500
+
+} {
+ # Verify that the expected index is used with the expected row count
+if {$testid==50299} {breakpoint; set sqlite_where_trace 1}
+ do_test analyze5-1.${testid}a {
+ set x [lindex [eqp "SELECT * FROM t1 WHERE $where"] 3]
+ set idx {}
+ regexp {INDEX (t1.) } $x all idx
+ regexp {~([0-9]+) rows} $x all nrow
+ list $idx $nrow
+ } [list $index $rows]
+if {$testid==50299} exit
+
+ # Verify that the same result is achieved regardless of whether or not
+ # the index is used
+ do_test analyze5-1.${testid}b {
+ set w2 [string map {y +y z +z} $where]
+ set a1 [db eval "SELECT rowid FROM t1 NOT INDEXED WHERE $w2\
+ ORDER BY +rowid"]
+ set a2 [db eval "SELECT rowid FROM t1 WHERE $where ORDER BY +rowid"]
+ if {$a1==$a2} {
+ set res ok
+ } else {
+ set res "a1=\[$a1\] a2=\[$a2\]"
+ }
+ set res
+ } {ok}
+}
+
+finish_test
diff --git a/test/analyze6.test b/test/analyze6.test
new file mode 100644
index 0000000..74b7ec7
--- /dev/null
+++ b/test/analyze6.test
@@ -0,0 +1,122 @@
+# 2011 March 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests for SQLite library. The focus of the tests
+# in this file a corner-case query planner optimization involving the
+# join order of two tables of different sizes.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !stat3 {
+ finish_test
+ return
+}
+
+set testprefix analyze6
+
+proc eqp {sql {db db}} {
+ uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db
+}
+
+do_test analyze6-1.0 {
+ db eval {
+ CREATE TABLE cat(x INT);
+ CREATE UNIQUE INDEX catx ON cat(x);
+ /* Give cat 16 unique integers */
+ INSERT INTO cat VALUES(1);
+ INSERT INTO cat VALUES(2);
+ INSERT INTO cat SELECT x+2 FROM cat;
+ INSERT INTO cat SELECT x+4 FROM cat;
+ INSERT INTO cat SELECT x+8 FROM cat;
+
+ CREATE TABLE ev(y INT);
+ CREATE INDEX evy ON ev(y);
+ /* ev will hold 32 copies of 16 integers found in cat */
+ INSERT INTO ev SELECT x FROM cat;
+ INSERT INTO ev SELECT x FROM cat;
+ INSERT INTO ev SELECT y FROM ev;
+ INSERT INTO ev SELECT y FROM ev;
+ INSERT INTO ev SELECT y FROM ev;
+ INSERT INTO ev SELECT y FROM ev;
+ ANALYZE;
+ SELECT count(*) FROM cat;
+ SELECT count(*) FROM ev;
+ }
+} {16 512}
+
+# The lowest cost plan is to scan CAT and for each integer there, do a single
+# lookup of the first corresponding entry in EV then read off the equal values
+# in EV. (Prior to the 2011-03-04 enhancement to where.c, this query would
+# have used EV for the outer loop instead of CAT - which was about 3x slower.)
+#
+do_test analyze6-1.1 {
+ eqp {SELECT count(*) FROM ev, cat WHERE x=y}
+} {0 0 1 {SCAN TABLE cat (~16 rows)} 0 1 0 {SEARCH TABLE ev USING COVERING INDEX evy (y=?) (~32 rows)}}
+
+# The same plan is chosen regardless of the order of the tables in the
+# FROM clause.
+#
+do_test analyze6-1.2 {
+ eqp {SELECT count(*) FROM cat, ev WHERE x=y}
+} {0 0 0 {SCAN TABLE cat (~16 rows)} 0 1 1 {SEARCH TABLE ev USING COVERING INDEX evy (y=?) (~32 rows)}}
+
+
+# Ticket [83ea97620bd3101645138b7b0e71c12c5498fe3d] 2011-03-30
+# If ANALYZE is run on an empty table, make sure indices are used
+# on the table.
+#
+do_test analyze6-2.1 {
+ execsql {
+ CREATE TABLE t201(x INTEGER PRIMARY KEY, y UNIQUE, z);
+ CREATE INDEX t201z ON t201(z);
+ ANALYZE;
+ }
+ eqp {SELECT * FROM t201 WHERE z=5}
+} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?) (~10 rows)}}
+do_test analyze6-2.2 {
+ eqp {SELECT * FROM t201 WHERE y=5}
+} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?) (~1 rows)}}
+do_test analyze6-2.3 {
+ eqp {SELECT * FROM t201 WHERE x=5}
+} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
+do_test analyze6-2.4 {
+ execsql {
+ INSERT INTO t201 VALUES(1,2,3);
+ ANALYZE t201;
+ }
+ eqp {SELECT * FROM t201 WHERE z=5}
+} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?) (~10 rows)}}
+do_test analyze6-2.5 {
+ eqp {SELECT * FROM t201 WHERE y=5}
+} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?) (~1 rows)}}
+do_test analyze6-2.6 {
+ eqp {SELECT * FROM t201 WHERE x=5}
+} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
+do_test analyze6-2.7 {
+ execsql {
+ INSERT INTO t201 VALUES(4,5,7);
+ INSERT INTO t201 SELECT x+100, y+100, z+100 FROM t201;
+ INSERT INTO t201 SELECT x+200, y+200, z+200 FROM t201;
+ INSERT INTO t201 SELECT x+400, y+400, z+400 FROM t201;
+ ANALYZE t201;
+ }
+ eqp {SELECT * FROM t201 WHERE z=5}
+} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?) (~10 rows)}}
+do_test analyze6-2.8 {
+ eqp {SELECT * FROM t201 WHERE y=5}
+} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?) (~1 rows)}}
+do_test analyze6-2.9 {
+ eqp {SELECT * FROM t201 WHERE x=5}
+} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
+
+finish_test
diff --git a/test/analyze7.test b/test/analyze7.test
new file mode 100644
index 0000000..5bdb04d
--- /dev/null
+++ b/test/analyze7.test
@@ -0,0 +1,113 @@
+# 2011 April 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+# This file implements tests for the ANALYZE command when an idnex
+# name is given as the argument.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# There is nothing to test if ANALYZE is disable for this build.
+#
+ifcapable {!analyze||!vtab} {
+ finish_test
+ return
+}
+
+# Generate some test data
+#
+do_test analyze7-1.0 {
+ register_wholenumber_module db
+ execsql {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ CREATE INDEX t1cd ON t1(c,d);
+ CREATE VIRTUAL TABLE nums USING wholenumber;
+ INSERT INTO t1 SELECT value, value, value/100, value FROM nums
+ WHERE value BETWEEN 1 AND 256;
+ EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123;
+ }
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~10 rows)}}
+do_test analyze7-1.1 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~10 rows)}}
+do_test analyze7-1.2 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~10 rows)}}
+
+# Run an analyze on one of the three indices. Verify that this
+# effects the row-count estimate on the one query that uses that
+# one index.
+#
+do_test analyze7-2.0 {
+ execsql {ANALYZE t1a;}
+ db cache flush
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123;}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
+do_test analyze7-2.1 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~10 rows)}}
+do_test analyze7-2.2 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~10 rows)}}
+
+# Verify that since the query planner now things that t1a is more
+# selective than t1b, it prefers to use t1a.
+#
+do_test analyze7-2.3 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND b=123}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
+
+# Run an analysis on another of the three indices. Verify that this
+# new analysis works and does not disrupt the previous analysis.
+#
+do_test analyze7-3.0 {
+ execsql {ANALYZE t1cd;}
+ db cache flush;
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123;}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
+do_test analyze7-3.1 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~10 rows)}}
+do_test analyze7-3.2.1 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=?;}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~86 rows)}}
+ifcapable stat3 {
+ # If ENABLE_STAT3 is defined, SQLite comes up with a different estimated
+ # row count for (c=2) than it does for (c=?).
+ do_test analyze7-3.2.2 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}
+ } {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~57 rows)}}
+} else {
+ # If ENABLE_STAT3 is not defined, the expected row count for (c=2) is the
+ # same as that for (c=?).
+ do_test analyze7-3.2.3 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}
+ } {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~86 rows)}}
+}
+do_test analyze7-3.3 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND b=123}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
+ifcapable {!stat3} {
+ do_test analyze7-3.4 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=123 AND b=123}
+ } {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~2 rows)}}
+ do_test analyze7-3.5 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND c=123}
+ } {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
+}
+do_test analyze7-3.6 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=123 AND d=123 AND b=123}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=? AND d=?) (~1 rows)}}
+
+finish_test
diff --git a/test/analyze8.test b/test/analyze8.test
new file mode 100644
index 0000000..f3e2710
--- /dev/null
+++ b/test/analyze8.test
@@ -0,0 +1,103 @@
+# 2011 August 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests for SQLite library. The focus of the tests
+# in this file is testing the capabilities of sqlite_stat3.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !stat3 {
+ finish_test
+ return
+}
+
+set testprefix analyze8
+
+proc eqp {sql {db db}} {
+ uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db
+}
+
+# Scenario:
+#
+# Two indices. One has mostly singleton entries, but for a few
+# values there are hundreds of entries. The other has 10-20
+# entries per value.
+#
+# Verify that the query planner chooses the first index for the singleton
+# entries and the second index for the others.
+#
+do_test 1.0 {
+ db eval {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ CREATE INDEX t1c ON t1(c);
+ }
+ for {set i 0} {$i<1000} {incr i} {
+ if {$i%2==0} {set a $i} {set a [expr {($i%8)*100}]}
+ set b [expr {$i/10}]
+ set c [expr {$i/8}]
+ set c [expr {$c*$c*$c}]
+ db eval {INSERT INTO t1 VALUES($a,$b,$c,$i)}
+ }
+ db eval {ANALYZE}
+} {}
+
+# The a==100 comparison is expensive because there are many rows
+# with a==100. And so for those cases, choose the t1b index.
+#
+# Buf ro a==99 and a==101, there are far fewer rows so choose
+# the t1a index.
+#
+do_test 1.1 {
+ eqp {SELECT * FROM t1 WHERE a=100 AND b=55}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~2 rows)}}
+do_test 1.2 {
+ eqp {SELECT * FROM t1 WHERE a=99 AND b=55}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
+do_test 1.3 {
+ eqp {SELECT * FROM t1 WHERE a=101 AND b=55}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
+do_test 1.4 {
+ eqp {SELECT * FROM t1 WHERE a=100 AND b=56}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~2 rows)}}
+do_test 1.5 {
+ eqp {SELECT * FROM t1 WHERE a=99 AND b=56}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
+do_test 1.6 {
+ eqp {SELECT * FROM t1 WHERE a=101 AND b=56}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
+do_test 2.1 {
+ eqp {SELECT * FROM t1 WHERE a=100 AND b BETWEEN 50 AND 54}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?) (~2 rows)}}
+
+# There are many more values of c between 0 and 100000 than there are
+# between 800000 and 900000. So t1c is more selective for the latter
+# range.
+#
+do_test 3.1 {
+ eqp {SELECT * FROM t1 WHERE b BETWEEN 50 AND 54 AND c BETWEEN 0 AND 100000}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?) (~6 rows)}}
+do_test 3.2 {
+ eqp {SELECT * FROM t1
+ WHERE b BETWEEN 50 AND 54 AND c BETWEEN 800000 AND 900000}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?) (~4 rows)}}
+do_test 3.3 {
+ eqp {SELECT * FROM t1 WHERE a=100 AND c BETWEEN 0 AND 100000}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~63 rows)}}
+do_test 3.4 {
+ eqp {SELECT * FROM t1
+ WHERE a=100 AND c BETWEEN 800000 AND 900000}
+} {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?) (~2 rows)}}
+
+finish_test
diff --git a/test/async.test b/test/async.test
new file mode 100644
index 0000000..e1bc086
--- /dev/null
+++ b/test/async.test
@@ -0,0 +1,90 @@
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file runs all tests.
+#
+# $Id: async.test,v 1.21 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {[info commands sqlite3async_initialize] eq ""} {
+ # The async logic is not built into this system
+ finish_test
+ return
+}
+
+rename finish_test async_really_finish_test
+proc finish_test {} {
+ catch {db close}
+ catch {db2 close}
+ catch {db3 close}
+}
+if {[info exists G(isquick)]} { set ASYNC_SAVE_ISQUICK $G(isquick) }
+set G(isquick) 1
+
+set ASYNC_INCLUDE {
+ insert.test
+ insert2.test
+ insert3.test
+ lock.test
+ lock2.test
+ lock3.test
+ select1.test
+ select2.test
+ select3.test
+ select4.test
+ trans.test
+}
+
+# Enable asynchronous IO.
+sqlite3async_initialize "" 1
+
+# This proc flushes the contents of the async-IO queue through to the
+# underlying VFS. A couple of the test scripts identified in $ASYNC_INCLUDE
+# above contain lines like "catch flush_async_queue" in places where
+# this is required for the tests to work in async mode.
+#
+proc flush_async_queue {} {
+ sqlite3async_control halt idle
+ sqlite3async_start
+ sqlite3async_wait
+ sqlite3async_control halt never
+}
+
+rename do_test async_really_do_test
+proc do_test {name args} {
+ uplevel async_really_do_test async_io-$name $args
+ flush_async_queue
+}
+
+foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
+ set tail [file tail $testfile]
+ if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue
+ source $testfile
+
+ # Make sure everything is flushed through. This is because [source]ing
+ # the next test file will delete the database file on disk (using
+ # [delete_file]). If the asynchronous backend still has the file
+ # open, it will become confused.
+ #
+ flush_async_queue
+}
+
+# Flush the write-queue and disable asynchronous IO. This should ensure
+# all allocated memory is cleaned up.
+set sqlite3async_trace 1
+flush_async_queue
+sqlite3async_shutdown
+set sqlite3async_trace 0
+
+rename do_test {}
+rename async_really_do_test do_test
+rename finish_test {}
+rename async_really_finish_test finish_test
+
+if {[info exists ASYNC_SAVE_ISQUICK]} { set G(isquick) $ASYNC_SAVE_ISQUICK }
+finish_test
diff --git a/test/async2.test b/test/async2.test
new file mode 100644
index 0000000..7994a72
--- /dev/null
+++ b/test/async2.test
@@ -0,0 +1,126 @@
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: async2.test,v 1.12 2009/04/25 08:39:15 danielk1977 Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {
+ [info commands sqlite3async_initialize]=="" ||
+ [info command sqlite3_memdebug_fail]==""
+} {
+ # The async logic is not built into this system
+ puts "Skipping async2 tests: not compiled with required features"
+ finish_test
+ return
+}
+
+# Enable asynchronous IO.
+
+set setup_script {
+ CREATE TABLE counter(c);
+ INSERT INTO counter(c) VALUES (1);
+}
+
+set sql_script {
+ BEGIN;
+ UPDATE counter SET c = 2;
+ CREATE TABLE t1(a PRIMARY KEY, b, c);
+ CREATE TABLE t2(a PRIMARY KEY, b, c);
+ COMMIT;
+
+ BEGIN;
+ UPDATE counter SET c = 3;
+ INSERT INTO t1 VALUES('abcdefghij', 'four', 'score');
+ INSERT INTO t2 VALUES('klmnopqrst', 'and', 'seven');
+ COMMIT;
+
+ UPDATE counter SET c = 'FIN';
+}
+
+db close
+
+foreach err [list ioerr malloc-transient malloc-persistent] {
+ set ::go 10
+ for {set n 1} {$::go} {incr n} {
+ set ::sqlite_io_error_pending 0
+ sqlite3_memdebug_fail -1
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql $::setup_script
+ db close
+
+ sqlite3async_initialize "" 1
+ sqlite3 db test.db
+ sqlite3_db_config_lookaside db 0 0 0
+
+ switch -- $err {
+ ioerr { set ::sqlite_io_error_pending $n }
+ malloc-persistent { sqlite3_memdebug_fail $n -repeat 1 }
+ malloc-transient { sqlite3_memdebug_fail $n -repeat 0 }
+ }
+
+ catchsql $::sql_script
+ db close
+
+ sqlite3async_control halt idle
+ sqlite3async_start
+ sqlite3async_wait
+ sqlite3async_control halt never
+ sqlite3async_shutdown
+
+ set ::sqlite_io_error_pending 0
+ sqlite3_memdebug_fail -1
+
+ sqlite3 db test.db
+ set c [db one {SELECT c FROM counter LIMIT 1}]
+ switch -- $c {
+ 1 {
+ do_test async-$err-1.1.$n {
+ execsql {
+ SELECT name FROM sqlite_master;
+ }
+ } {counter}
+ }
+ 2 {
+ do_test async-$err-1.2.$n.1 {
+ execsql {
+ SELECT * FROM t1;
+ }
+ } {}
+ do_test async-$err-1.2.$n.2 {
+ execsql {
+ SELECT * FROM t2;
+ }
+ } {}
+ }
+ 3 {
+ do_test async-$err-1.3.$n.1 {
+ execsql {
+ SELECT * FROM t1;
+ }
+ } {abcdefghij four score}
+ do_test async-$err-1.3.$n.2 {
+ execsql {
+ SELECT * FROM t2;
+ }
+ } {klmnopqrst and seven}
+ }
+ FIN {
+ incr ::go -1
+ }
+ }
+
+ db close
+ }
+}
+
+catch {db close}
+
+finish_test
diff --git a/test/async3.test b/test/async3.test
new file mode 100644
index 0000000..9336b66
--- /dev/null
+++ b/test/async3.test
@@ -0,0 +1,76 @@
+# 2007 September 5
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# The focus of this file is testing the code in test_async.c.
+# Specifically, it tests that the xFullPathname() method of
+# of the asynchronous vfs works correctly.
+#
+# $Id: async3.test,v 1.5 2009/04/25 08:39:15 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if { [info commands sqlite3async_initialize]=="" } {
+ # The async logic is not built into this system
+ puts "Skipping async3 tests: not compiled with required features"
+ finish_test
+ return
+}
+
+db close
+sqlite3async_initialize "" 1
+#set sqlite3async_trace 1
+sqlite3async_start
+
+set paths {
+ chocolate/banana/vanilla/file.db
+ chocolate//banana/vanilla/file.db
+ chocolate/./banana//vanilla/file.db
+ chocolate/banana/./vanilla/file.db
+ chocolate/banana/../banana/vanilla/file.db
+ chocolate/banana/./vanilla/extra_bit/../file.db
+}
+
+do_test async3-1.0 {
+ file mkdir [file join chocolate banana vanilla]
+ forcedelete chocolate/banana/vanilla/file.db
+ forcedelete chocolate/banana/vanilla/file.db-journal
+} {}
+
+do_test async3-1.1 {
+ sqlite3 db chocolate/banana/vanilla/file.db
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ BEGIN;
+ INSERT INTO abc VALUES(1, 2, 3);
+ }
+} {}
+
+set N 2
+foreach p $paths {
+ sqlite3 db2 $p
+ do_test async3-1.$N.1 {
+ execsql {SELECT * FROM abc} db2
+ } {}
+ do_test async3-1.$N.2 {
+ catchsql {INSERT INTO abc VALUES(4, 5, 6)} db2
+ } {1 {database is locked}}
+ db2 close
+ incr N
+}
+
+db close
+
+sqlite3async_control halt idle
+sqlite3async_wait
+sqlite3async_control halt never
+sqlite3async_shutdown
+finish_test
diff --git a/test/async4.test b/test/async4.test
new file mode 100644
index 0000000..92a8201
--- /dev/null
+++ b/test/async4.test
@@ -0,0 +1,168 @@
+# 2009 April 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: async4.test,v 1.4 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# These tests only work for Tcl version 8.5 and later on Windows (for now)
+#
+if {$tcl_platform(platform)=="windows"} {
+ scan $::tcl_version %f vx
+ if {$vx<8.5} {
+ finish_test
+ return
+ }
+}
+
+if {[info commands sqlite3async_initialize] eq ""} {
+ # The async logic is not built into this system
+ finish_test
+ return
+}
+db close
+
+# Test layout:
+#
+# async4.1.*: Test the lockfiles parameter.
+# async4.2.*: Test the delay parameter.
+
+do_test async4.1.1 {
+ sqlite3async_initialize {} 0
+ sqlite3async_control lockfiles
+} {1}
+do_test async4.1.2 {
+ sqlite3async_control lockfiles false
+} {0}
+do_test async4.1.3 {
+ sqlite3async_control lockfiles
+} {0}
+do_test async4.1.4 {
+ sqlite3async_control lockfiles true
+} {1}
+
+do_test async4.1.5 {
+ sqlite3 db test.db -vfs sqlite3async
+ execsql { CREATE TABLE t1(a, b, c) }
+} {}
+do_test async4.1.6 {
+ list [file exists test.db] [file size test.db]
+} {1 0}
+do_test async4.1.7 {
+ sqlite3 db2 test.db
+ catchsql { CREATE TABLE t2(a, b, c) } db2
+} {1 {database is locked}}
+do_test async4.1.8 {
+ sqlite3async_control halt idle
+ sqlite3async_start
+ sqlite3async_wait
+} {}
+do_test async4.1.9 {
+ catchsql { CREATE TABLE t2(a, b, c) } db2
+} {0 {}}
+do_test async4.1.10 {
+ list [catch {sqlite3async_control lockfiles false} msg] $msg
+} {1 SQLITE_MISUSE}
+do_test async4.1.11 {
+ db close
+ list [catch {sqlite3async_control lockfiles false} msg] $msg
+} {1 SQLITE_MISUSE}
+do_test async4.1.12 {
+ sqlite3async_start
+ sqlite3async_wait
+ sqlite3async_control lockfiles false
+} {0}
+do_test async4.1.13 {
+ sqlite3 db test.db -vfs sqlite3async
+ execsql { CREATE TABLE t3(a, b, c) } db
+} {}
+do_test async4.1.14 {
+ execsql {
+ CREATE INDEX i1 ON t2(a);
+ CREATE INDEX i2 ON t1(a);
+ } db2
+} {}
+do_test async4.1.15 {
+ sqlite3async_start
+ sqlite3async_wait
+ hexio_write test.db 28 00000000
+ execsql { pragma integrity_check } db2
+} {{*** in database main ***
+Page 5 is never used}}
+do_test async4.1.16 {
+ db close
+ db2 close
+ sqlite3async_start
+ sqlite3async_wait
+} {}
+do_test async4.1.17 {
+ sqlite3async_control lockfiles true
+} {1}
+
+do_test async4.2.1 {
+ sqlite3async_control delay
+} {0}
+do_test async4.2.2 {
+ sqlite3async_control delay 23
+} {23}
+do_test async4.2.3 {
+ sqlite3async_control delay
+} {23}
+do_test async4.2.4 {
+ sqlite3async_control delay 0
+} {0}
+do_test async4.2.5 {
+ sqlite3 db test.db -vfs sqlite3async
+
+ execsql { CREATE TABLE t4(a, b) }
+ set T1 [lindex [time {
+ sqlite3async_start
+ sqlite3async_wait
+ }] 0]
+
+ sqlite3async_control delay 100
+ execsql { CREATE TABLE t5(a, b) }
+ set T2 [lindex [time {
+ sqlite3async_start
+ sqlite3async_wait
+ }] 0]
+
+ expr {($T1+1000000) < $T2}
+} {1}
+
+do_test async4.2.6 {
+ sqlite3async_control delay 0
+ execsql { CREATE TABLE t6(a, b) }
+ set T1 [lindex [time {
+ sqlite3async_start
+ sqlite3async_wait
+ }] 0]
+
+ expr {($T1+1000000) < $T2}
+} {1}
+
+do_test async4.2.7 {
+ list [catch { sqlite3async_control delay -1 } msg] $msg
+} {1 SQLITE_MISUSE}
+
+do_test async4.2.8 {
+ db close
+ sqlite3async_start
+ sqlite3async_wait
+} {}
+
+finish_test
diff --git a/test/async5.test b/test/async5.test
new file mode 100644
index 0000000..aa484fc
--- /dev/null
+++ b/test/async5.test
@@ -0,0 +1,69 @@
+# 2009 July 19
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file tests that asynchronous IO is compatible with multi-file
+# transactions.
+#
+# $Id: async5.test,v 1.1 2009/07/18 11:52:04 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {[info commands sqlite3async_initialize] eq ""} {
+ # The async logic is not built into this system
+ finish_test
+ return
+}
+
+db close
+forcedelete test2.db
+sqlite3async_initialize "" 1
+sqlite3async_control halt never
+sqlite3 db test.db
+
+do_test async5-1.1 {
+ execsql {
+ ATTACH 'test2.db' AS next;
+ CREATE TABLE main.t1(a, b);
+ CREATE TABLE next.t2(a, b);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ COMMIT;
+ }
+} {}
+do_test async5-1.2 {
+ execsql { SELECT * FROM t1 }
+} {1 2}
+do_test async5-1.3 {
+ execsql { SELECT * FROM t2 }
+} {3 4}
+do_test async5-1.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('a', 'b');
+ INSERT INTO t2 VALUES('c', 'd');
+ COMMIT;
+ }
+} {}
+do_test async5-1.5 {
+ execsql { SELECT * FROM t1 }
+} {1 2 a b}
+do_test async5-1.6 {
+ execsql { SELECT * FROM t2 }
+} {3 4 c d}
+
+db close
+
+sqlite3async_control halt idle
+sqlite3async_start
+sqlite3async_wait
+sqlite3async_control halt never
+sqlite3async_shutdown
+set sqlite3async_trace 0
+finish_test
+
diff --git a/test/attach.test b/test/attach.test
new file mode 100644
index 0000000..d57f5bf
--- /dev/null
+++ b/test/attach.test
@@ -0,0 +1,843 @@
+# 2003 April 4
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the ATTACH and DETACH commands
+# and related functionality.
+#
+# $Id: attach.test,v 1.52 2009/05/29 14:39:08 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !attach {
+ finish_test
+ return
+}
+
+for {set i 2} {$i<=15} {incr i} {
+ forcedelete test$i.db
+ forcedelete test$i.db-journal
+}
+
+do_test attach-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ SELECT * FROM t1;
+ }
+} {1 2 3 4}
+do_test attach-1.2 {
+ sqlite3 db2 test2.db
+ execsql {
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(1,'x');
+ INSERT INTO t2 VALUES(2,'y');
+ SELECT * FROM t2;
+ } db2
+} {1 x 2 y}
+do_test attach-1.3 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS two;
+ SELECT * FROM two.t2;
+ }
+} {1 x 2 y}
+do_test attach-1.4 {
+ execsql {
+ SELECT * FROM t2;
+ }
+} {1 x 2 y}
+do_test attach-1.5 {
+ execsql {
+ DETACH DATABASE two;
+ SELECT * FROM t1;
+ }
+} {1 2 3 4}
+do_test attach-1.6 {
+ catchsql {
+ SELECT * FROM t2;
+ }
+} {1 {no such table: t2}}
+do_test attach-1.7 {
+ catchsql {
+ SELECT * FROM two.t2;
+ }
+} {1 {no such table: two.t2}}
+do_test attach-1.8 {
+ catchsql {
+ ATTACH DATABASE 'test3.db' AS three;
+ }
+} {0 {}}
+do_test attach-1.9 {
+ catchsql {
+ SELECT * FROM three.sqlite_master;
+ }
+} {0 {}}
+do_test attach-1.10 {
+ catchsql {
+ DETACH DATABASE [three];
+ }
+} {0 {}}
+do_test attach-1.11 {
+ execsql {
+ ATTACH 'test.db' AS db2;
+ ATTACH 'test.db' AS db3;
+ ATTACH 'test.db' AS db4;
+ ATTACH 'test.db' AS db5;
+ ATTACH 'test.db' AS db6;
+ ATTACH 'test.db' AS db7;
+ ATTACH 'test.db' AS db8;
+ ATTACH 'test.db' AS db9;
+ }
+} {}
+proc db_list {db} {
+ set list {}
+ foreach {idx name file} [execsql {PRAGMA database_list} $db] {
+ lappend list $idx $name
+ }
+ return $list
+}
+ifcapable schema_pragmas {
+do_test attach-1.11b {
+ db_list db
+} {0 main 2 db2 3 db3 4 db4 5 db5 6 db6 7 db7 8 db8 9 db9}
+} ;# ifcapable schema_pragmas
+do_test attach-1.12 {
+ catchsql {
+ ATTACH 'test.db' as db2;
+ }
+} {1 {database db2 is already in use}}
+do_test attach-1.12.2 {
+ db errorcode
+} {1}
+do_test attach-1.13 {
+ catchsql {
+ ATTACH 'test.db' as db5;
+ }
+} {1 {database db5 is already in use}}
+do_test attach-1.14 {
+ catchsql {
+ ATTACH 'test.db' as db9;
+ }
+} {1 {database db9 is already in use}}
+do_test attach-1.15 {
+ catchsql {
+ ATTACH 'test.db' as main;
+ }
+} {1 {database main is already in use}}
+ifcapable tempdb {
+ do_test attach-1.16 {
+ catchsql {
+ ATTACH 'test.db' as temp;
+ }
+ } {1 {database temp is already in use}}
+}
+do_test attach-1.17 {
+ catchsql {
+ ATTACH 'test.db' as MAIN;
+ }
+} {1 {database MAIN is already in use}}
+do_test attach-1.18 {
+ catchsql {
+ ATTACH 'test.db' as db10;
+ ATTACH 'test.db' as db11;
+ }
+} {0 {}}
+if {$SQLITE_MAX_ATTACHED==10} {
+ do_test attach-1.19 {
+ catchsql {
+ ATTACH 'test.db' as db12;
+ }
+ } {1 {too many attached databases - max 10}}
+ do_test attach-1.19.1 {
+ db errorcode
+ } {1}
+}
+do_test attach-1.20.1 {
+ execsql {
+ DETACH db5;
+ }
+} {}
+ifcapable schema_pragmas {
+do_test attach-1.20.2 {
+ db_list db
+} {0 main 2 db2 3 db3 4 db4 5 db6 6 db7 7 db8 8 db9 9 db10 10 db11}
+} ;# ifcapable schema_pragmas
+integrity_check attach-1.20.3
+ifcapable tempdb {
+ execsql {select * from sqlite_temp_master}
+}
+do_test attach-1.21 {
+ catchsql {
+ ATTACH 'test.db' as db12;
+ }
+} {0 {}}
+if {$SQLITE_MAX_ATTACHED==10} {
+ do_test attach-1.22 {
+ catchsql {
+ ATTACH 'test.db' as db13;
+ }
+ } {1 {too many attached databases - max 10}}
+ do_test attach-1.22.1 {
+ db errorcode
+ } {1}
+}
+do_test attach-1.23 {
+ catchsql {
+ DETACH "db14";
+ }
+} {1 {no such database: db14}}
+do_test attach-1.24 {
+ catchsql {
+ DETACH db12;
+ }
+} {0 {}}
+do_test attach-1.25 {
+ catchsql {
+ DETACH db12;
+ }
+} {1 {no such database: db12}}
+do_test attach-1.26 {
+ catchsql {
+ DETACH main;
+ }
+} {1 {cannot detach database main}}
+
+ifcapable tempdb {
+ do_test attach-1.27 {
+ catchsql {
+ DETACH Temp;
+ }
+ } {1 {cannot detach database Temp}}
+} else {
+ do_test attach-1.27 {
+ catchsql {
+ DETACH Temp;
+ }
+ } {1 {no such database: Temp}}
+}
+
+do_test attach-1.28 {
+ catchsql {
+ DETACH db11;
+ DETACH db10;
+ DETACH db9;
+ DETACH db8;
+ DETACH db7;
+ DETACH db6;
+ DETACH db4;
+ DETACH db3;
+ DETACH db2;
+ }
+} {0 {}}
+ifcapable schema_pragmas {
+ ifcapable tempdb {
+ do_test attach-1.29 {
+ db_list db
+ } {0 main 1 temp}
+ } else {
+ do_test attach-1.29 {
+ db_list db
+ } {0 main}
+ }
+} ;# ifcapable schema_pragmas
+
+ifcapable {trigger} { # Only do the following tests if triggers are enabled
+do_test attach-2.1 {
+ execsql {
+ CREATE TABLE tx(x1,x2,y1,y2);
+ CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN
+ INSERT INTO tx(x1,x2,y1,y2) VALUES(OLD.x,NEW.x,OLD.y,NEW.y);
+ END;
+ SELECT * FROM tx;
+ } db2;
+} {}
+do_test attach-2.2 {
+ execsql {
+ UPDATE t2 SET x=x+10;
+ SELECT * FROM tx;
+ } db2;
+} {1 11 x x 2 12 y y}
+do_test attach-2.3 {
+ execsql {
+ CREATE TABLE tx(x1,x2,y1,y2);
+ SELECT * FROM tx;
+ }
+} {}
+do_test attach-2.4 {
+ execsql {
+ ATTACH 'test2.db' AS db2;
+ }
+} {}
+do_test attach-2.5 {
+ execsql {
+ UPDATE db2.t2 SET x=x+10;
+ SELECT * FROM db2.tx;
+ }
+} {1 11 x x 2 12 y y 11 21 x x 12 22 y y}
+do_test attach-2.6 {
+ execsql {
+ SELECT * FROM main.tx;
+ }
+} {}
+do_test attach-2.7 {
+ execsql {
+ SELECT type, name, tbl_name FROM db2.sqlite_master;
+ }
+} {table t2 t2 table tx tx trigger r1 t2}
+
+ifcapable schema_pragmas&&tempdb {
+ do_test attach-2.8 {
+ db_list db
+ } {0 main 1 temp 2 db2}
+} ;# ifcapable schema_pragmas&&tempdb
+ifcapable schema_pragmas&&!tempdb {
+ do_test attach-2.8 {
+ db_list db
+ } {0 main 2 db2}
+} ;# ifcapable schema_pragmas&&!tempdb
+
+do_test attach-2.9 {
+ execsql {
+ CREATE INDEX i2 ON t2(x);
+ SELECT * FROM t2 WHERE x>5;
+ } db2
+} {21 x 22 y}
+do_test attach-2.10 {
+ execsql {
+ SELECT type, name, tbl_name FROM sqlite_master;
+ } db2
+} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}
+#do_test attach-2.11 {
+# catchsql {
+# SELECT * FROM t2 WHERE x>5;
+# }
+#} {1 {database schema has changed}}
+ifcapable schema_pragmas {
+ ifcapable tempdb {
+ do_test attach-2.12 {
+ db_list db
+ } {0 main 1 temp 2 db2}
+ } else {
+ do_test attach-2.12 {
+ db_list db
+ } {0 main 2 db2}
+ }
+} ;# ifcapable schema_pragmas
+do_test attach-2.13 {
+ catchsql {
+ SELECT * FROM t2 WHERE x>5;
+ }
+} {0 {21 x 22 y}}
+do_test attach-2.14 {
+ execsql {
+ SELECT type, name, tbl_name FROM sqlite_master;
+ }
+} {table t1 t1 table tx tx}
+do_test attach-2.15 {
+ execsql {
+ SELECT type, name, tbl_name FROM db2.sqlite_master;
+ }
+} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}
+do_test attach-2.16 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ ATTACH 'test2.db' AS db2;
+ SELECT type, name, tbl_name FROM db2.sqlite_master;
+ }
+} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}
+} ;# End of ifcapable {trigger}
+
+do_test attach-3.1 {
+ db close
+ db2 close
+ sqlite3 db test.db
+ sqlite3 db2 test2.db
+ execsql {
+ SELECT * FROM t1
+ }
+} {1 2 3 4}
+
+# If we are testing a version of the code that lacks trigger support,
+# adjust the database contents so that they are the same if triggers
+# had been enabled.
+ifcapable {!trigger} {
+ db2 eval {
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES(21, 'x');
+ INSERT INTO t2 VALUES(22, 'y');
+ CREATE TABLE tx(x1,x2,y1,y2);
+ INSERT INTO tx VALUES(1, 11, 'x', 'x');
+ INSERT INTO tx VALUES(2, 12, 'y', 'y');
+ INSERT INTO tx VALUES(11, 21, 'x', 'x');
+ INSERT INTO tx VALUES(12, 22, 'y', 'y');
+ CREATE INDEX i2 ON t2(x);
+ }
+}
+
+do_test attach-3.2 {
+ catchsql {
+ SELECT * FROM t2
+ }
+} {1 {no such table: t2}}
+do_test attach-3.3 {
+ catchsql {
+ ATTACH DATABASE 'test2.db' AS db2;
+ SELECT * FROM t2
+ }
+} {0 {21 x 22 y}}
+
+# Even though 'db' has started a transaction, it should not yet have
+# a lock on test2.db so 'db2' should be readable.
+do_test attach-3.4 {
+ execsql BEGIN
+ catchsql {
+ SELECT * FROM t2;
+ } db2;
+} {0 {21 x 22 y}}
+
+# Reading from test2.db from db within a transaction should not
+# prevent test2.db from being read by db2.
+do_test attach-3.5 {
+ execsql {SELECT * FROM t2}
+ catchsql {
+ SELECT * FROM t2;
+ } db2;
+} {0 {21 x 22 y}}
+
+# Making a change to test2.db through db causes test2.db to get
+# a reserved lock. It should still be accessible through db2.
+do_test attach-3.6 {
+ execsql {
+ UPDATE t2 SET x=x+1 WHERE x=50;
+ }
+ catchsql {
+ SELECT * FROM t2;
+ } db2;
+} {0 {21 x 22 y}}
+
+do_test attach-3.7 {
+ execsql ROLLBACK
+ execsql {SELECT * FROM t2} db2
+} {21 x 22 y}
+
+# Start transactions on both db and db2. Once again, just because
+# we make a change to test2.db using db2, only a RESERVED lock is
+# obtained, so test2.db should still be readable using db.
+#
+do_test attach-3.8 {
+ execsql BEGIN
+ execsql BEGIN db2
+ execsql {UPDATE t2 SET x=0 WHERE 0} db2
+ catchsql {SELECT * FROM t2}
+} {0 {21 x 22 y}}
+
+# It is also still accessible from db2.
+do_test attach-3.9 {
+ catchsql {SELECT * FROM t2} db2
+} {0 {21 x 22 y}}
+
+do_test attach-3.10 {
+ execsql {SELECT * FROM t1}
+} {1 2 3 4}
+
+do_test attach-3.11 {
+ catchsql {UPDATE t1 SET a=a+1}
+} {0 {}}
+do_test attach-3.12 {
+ execsql {SELECT * FROM t1}
+} {2 2 4 4}
+
+# db2 has a RESERVED lock on test2.db, so db cannot write to any tables
+# in test2.db.
+do_test attach-3.13 {
+ catchsql {UPDATE t2 SET x=x+1 WHERE x=50}
+} {1 {database is locked}}
+
+# Change for version 3. Transaction is no longer rolled back
+# for a locked database.
+execsql {ROLLBACK}
+
+# db is able to reread its schema because db2 still only holds a
+# reserved lock.
+do_test attach-3.14 {
+ catchsql {SELECT * FROM t1}
+} {0 {1 2 3 4}}
+do_test attach-3.15 {
+ execsql COMMIT db2
+ execsql {SELECT * FROM t1}
+} {1 2 3 4}
+
+# Ticket #323
+do_test attach-4.1 {
+ execsql {DETACH db2}
+ db2 close
+ sqlite3 db2 test2.db
+ execsql {
+ CREATE TABLE t3(x,y);
+ CREATE UNIQUE INDEX t3i1 ON t3(x);
+ INSERT INTO t3 VALUES(1,2);
+ SELECT * FROM t3;
+ } db2;
+} {1 2}
+do_test attach-4.2 {
+ execsql {
+ CREATE TABLE t3(a,b);
+ CREATE UNIQUE INDEX t3i1b ON t3(a);
+ INSERT INTO t3 VALUES(9,10);
+ SELECT * FROM t3;
+ }
+} {9 10}
+do_test attach-4.3 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS db2;
+ SELECT * FROM db2.t3;
+ }
+} {1 2}
+do_test attach-4.4 {
+ execsql {
+ SELECT * FROM main.t3;
+ }
+} {9 10}
+do_test attach-4.5 {
+ execsql {
+ INSERT INTO db2.t3 VALUES(9,10);
+ SELECT * FROM db2.t3;
+ }
+} {1 2 9 10}
+execsql {
+ DETACH db2;
+}
+ifcapable {trigger} {
+ do_test attach-4.6 {
+ execsql {
+ CREATE TABLE t4(x);
+ CREATE TRIGGER t3r3 AFTER INSERT ON t3 BEGIN
+ INSERT INTO t4 VALUES('db2.' || NEW.x);
+ END;
+ INSERT INTO t3 VALUES(6,7);
+ SELECT * FROM t4;
+ } db2
+ } {db2.6}
+ do_test attach-4.7 {
+ execsql {
+ CREATE TABLE t4(y);
+ CREATE TRIGGER t3r3 AFTER INSERT ON t3 BEGIN
+ INSERT INTO t4 VALUES('main.' || NEW.a);
+ END;
+ INSERT INTO main.t3 VALUES(11,12);
+ SELECT * FROM main.t4;
+ }
+ } {main.11}
+}
+ifcapable {!trigger} {
+ # When we do not have trigger support, set up the table like they
+ # would have been had triggers been there. The tests that follow need
+ # this setup.
+ execsql {
+ CREATE TABLE t4(x);
+ INSERT INTO t3 VALUES(6,7);
+ INSERT INTO t4 VALUES('db2.6');
+ INSERT INTO t4 VALUES('db2.13');
+ } db2
+ execsql {
+ CREATE TABLE t4(y);
+ INSERT INTO main.t3 VALUES(11,12);
+ INSERT INTO t4 VALUES('main.11');
+ }
+}
+
+
+# This one is tricky. On the UNION ALL select, we have to make sure
+# the schema for both main and db2 is valid before starting to execute
+# the first query of the UNION ALL. If we wait to test the validity of
+# the schema for main until after the first query has run, that test will
+# fail and the query will abort but we will have already output some
+# results. When the query is retried, the results will be repeated.
+#
+ifcapable compound {
+do_test attach-4.8 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS db2;
+ INSERT INTO db2.t3 VALUES(13,14);
+ SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4;
+ }
+} {db2.6 db2.13 main.11}
+
+do_test attach-4.9 {
+ ifcapable {!trigger} {execsql {INSERT INTO main.t4 VALUES('main.15')}}
+ execsql {
+ INSERT INTO main.t3 VALUES(15,16);
+ SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4;
+ }
+} {db2.6 db2.13 main.11 main.15}
+} ;# ifcapable compound
+
+ifcapable !compound {
+ ifcapable {!trigger} {execsql {INSERT INTO main.t4 VALUES('main.15')}}
+ execsql {
+ ATTACH DATABASE 'test2.db' AS db2;
+ INSERT INTO db2.t3 VALUES(13,14);
+ INSERT INTO main.t3 VALUES(15,16);
+ }
+} ;# ifcapable !compound
+
+ifcapable view {
+do_test attach-4.10 {
+ execsql {
+ DETACH DATABASE db2;
+ }
+ execsql {
+ CREATE VIEW v3 AS SELECT x*100+y FROM t3;
+ SELECT * FROM v3;
+ } db2
+} {102 910 607 1314}
+do_test attach-4.11 {
+ execsql {
+ CREATE VIEW v3 AS SELECT a*100+b FROM t3;
+ SELECT * FROM v3;
+ }
+} {910 1112 1516}
+do_test attach-4.12 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS db2;
+ SELECT * FROM db2.v3;
+ }
+} {102 910 607 1314}
+do_test attach-4.13 {
+ execsql {
+ SELECT * FROM main.v3;
+ }
+} {910 1112 1516}
+} ;# ifcapable view
+
+# Tests for the sqliteFix...() routines in attach.c
+#
+ifcapable {trigger} {
+do_test attach-5.1 {
+ db close
+ sqlite3 db test.db
+ db2 close
+ forcedelete test2.db
+ sqlite3 db2 test2.db
+ catchsql {
+ ATTACH DATABASE 'test.db' AS orig;
+ CREATE TRIGGER r1 AFTER INSERT ON orig.t1 BEGIN
+ SELECT 'no-op';
+ END;
+ } db2
+} {1 {trigger r1 cannot reference objects in database orig}}
+do_test attach-5.2 {
+ catchsql {
+ CREATE TABLE t5(x,y);
+ CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
+ SELECT 'no-op';
+ END;
+ } db2
+} {0 {}}
+do_test attach-5.3 {
+ catchsql {
+ DROP TRIGGER r5;
+ CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
+ SELECT 'no-op' FROM orig.t1;
+ END;
+ } db2
+} {1 {trigger r5 cannot reference objects in database orig}}
+ifcapable tempdb {
+ do_test attach-5.4 {
+ catchsql {
+ CREATE TEMP TABLE t6(p,q,r);
+ CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
+ SELECT 'no-op' FROM temp.t6;
+ END;
+ } db2
+ } {1 {trigger r5 cannot reference objects in database temp}}
+}
+ifcapable subquery {
+ do_test attach-5.5 {
+ catchsql {
+ CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
+ SELECT 'no-op' || (SELECT * FROM temp.t6);
+ END;
+ } db2
+ } {1 {trigger r5 cannot reference objects in database temp}}
+ do_test attach-5.6 {
+ catchsql {
+ CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
+ SELECT 'no-op' FROM t1 WHERE x<(SELECT min(x) FROM temp.t6);
+ END;
+ } db2
+ } {1 {trigger r5 cannot reference objects in database temp}}
+ do_test attach-5.7 {
+ catchsql {
+ CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
+ SELECT 'no-op' FROM t1 GROUP BY 1 HAVING x<(SELECT min(x) FROM temp.t6);
+ END;
+ } db2
+ } {1 {trigger r5 cannot reference objects in database temp}}
+ do_test attach-5.7 {
+ catchsql {
+ CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
+ SELECT max(1,x,(SELECT min(x) FROM temp.t6)) FROM t1;
+ END;
+ } db2
+ } {1 {trigger r5 cannot reference objects in database temp}}
+ do_test attach-5.8 {
+ catchsql {
+ CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
+ INSERT INTO t1 VALUES((SELECT min(x) FROM temp.t6),5);
+ END;
+ } db2
+ } {1 {trigger r5 cannot reference objects in database temp}}
+ do_test attach-5.9 {
+ catchsql {
+ CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
+ DELETE FROM t1 WHERE x<(SELECT min(x) FROM temp.t6);
+ END;
+ } db2
+ } {1 {trigger r5 cannot reference objects in database temp}}
+} ;# endif subquery
+} ;# endif trigger
+
+# Check to make sure we get a sensible error if unable to open
+# the file that we are trying to attach.
+#
+do_test attach-6.1 {
+ catchsql {
+ ATTACH DATABASE 'no-such-file' AS nosuch;
+ }
+} {0 {}}
+if {$tcl_platform(platform)=="unix"} {
+ do_test attach-6.2 {
+ sqlite3 dbx cannot-read
+ dbx eval {CREATE TABLE t1(a,b,c)}
+ dbx close
+ file attributes cannot-read -permission 0000
+ if {[file writable cannot-read]} {
+ puts "\n**** Tests do not work when run as root ****"
+ forcedelete cannot-read
+ exit 1
+ }
+ catchsql {
+ ATTACH DATABASE 'cannot-read' AS noread;
+ }
+ } {1 {unable to open database: cannot-read}}
+ do_test attach-6.2.2 {
+ db errorcode
+ } {14}
+ forcedelete cannot-read
+}
+
+# Check the error message if we try to access a database that has
+# not been attached.
+do_test attach-6.3 {
+ catchsql {
+ CREATE TABLE no_such_db.t1(a, b, c);
+ }
+} {1 {unknown database no_such_db}}
+for {set i 2} {$i<=15} {incr i} {
+ catch {db$i close}
+}
+db close
+forcedelete test2.db
+forcedelete no-such-file
+
+ifcapable subquery {
+ do_test attach-7.1 {
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ catchsql {
+ DETACH RAISE ( IGNORE ) IN ( SELECT "AAAAAA" . * ORDER BY
+ REGISTER LIMIT "AAAAAA" . "AAAAAA" OFFSET RAISE ( IGNORE ) NOT NULL )
+ }
+ } {1 {no such table: AAAAAA}}
+}
+
+# Create a malformed file (a file that is not a valid database)
+# and try to attach it
+#
+do_test attach-8.1 {
+ set fd [open test2.db w]
+ puts $fd "This file is not a valid SQLite database"
+ close $fd
+ catchsql {
+ ATTACH 'test2.db' AS t2;
+ }
+} {1 {file is encrypted or is not a database}}
+do_test attach-8.2 {
+ db errorcode
+} {26}
+forcedelete test2.db
+do_test attach-8.3 {
+ sqlite3 db2 test2.db
+ db2 eval {CREATE TABLE t1(x); BEGIN EXCLUSIVE}
+ catchsql {
+ ATTACH 'test2.db' AS t2;
+ }
+} {1 {database is locked}}
+do_test attach-8.4 {
+ db errorcode
+} {5}
+db2 close
+forcedelete test2.db
+
+# Test that it is possible to attach the same database more than
+# once when not in shared-cache mode. That this is not possible in
+# shared-cache mode is tested in shared7.test.
+do_test attach-9.1 {
+ forcedelete test4.db
+ execsql {
+ ATTACH 'test4.db' AS aux1;
+ CREATE TABLE aux1.t1(a, b);
+ INSERT INTO aux1.t1 VALUES(1, 2);
+ ATTACH 'test4.db' AS aux2;
+ SELECT * FROM aux2.t1;
+ }
+} {1 2}
+do_test attach-9.2 {
+ catchsql {
+ BEGIN;
+ INSERT INTO aux1.t1 VALUES(3, 4);
+ INSERT INTO aux2.t1 VALUES(5, 6);
+ }
+} {1 {database is locked}}
+do_test attach-9.3 {
+ execsql {
+ COMMIT;
+ SELECT * FROM aux2.t1;
+ }
+} {1 2 3 4}
+
+# Ticket [abe728bbc311d81334dae9762f0db87c07a98f79].
+# Multi-database commit on an attached TEMP database.
+#
+do_test attach-10.1 {
+ execsql {
+ ATTACH '' AS noname;
+ ATTACH ':memory:' AS inmem;
+ BEGIN;
+ CREATE TABLE noname.noname(x);
+ CREATE TABLE inmem.inmem(y);
+ CREATE TABLE main.main(z);
+ COMMIT;
+ SELECT name FROM noname.sqlite_master;
+ SELECT name FROM inmem.sqlite_master;
+ }
+} {noname inmem}
+do_test attach-10.2 {
+ lrange [execsql {
+ PRAGMA database_list;
+ }] 9 end
+} {4 noname {} 5 inmem {}}
+
+finish_test
diff --git a/test/attach2.test b/test/attach2.test
new file mode 100644
index 0000000..db23072
--- /dev/null
+++ b/test/attach2.test
@@ -0,0 +1,394 @@
+# 2003 July 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the ATTACH and DETACH commands
+# and related functionality.
+#
+# $Id: attach2.test,v 1.38 2007/12/13 21:54:11 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !attach {
+ finish_test
+ return
+}
+
+# Ticket #354
+#
+# Databases test.db and test2.db contain identical schemas. Make
+# sure we can attach test2.db from test.db.
+#
+do_test attach2-1.1 {
+ db eval {
+ CREATE TABLE t1(a,b);
+ CREATE INDEX x1 ON t1(a);
+ }
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ sqlite3 db2 test2.db
+ db2 eval {
+ CREATE TABLE t1(a,b);
+ CREATE INDEX x1 ON t1(a);
+ }
+ catchsql {
+ ATTACH 'test2.db' AS t2;
+ }
+} {0 {}}
+
+# Ticket #514
+#
+proc db_list {db} {
+ set list {}
+ foreach {idx name file} [execsql {PRAGMA database_list} $db] {
+ lappend list $idx $name
+ }
+ return $list
+}
+db eval {DETACH t2}
+do_test attach2-2.1 {
+ # lock test2.db then try to attach it. This is no longer an error because
+ # db2 just RESERVES the database. It does not obtain a write-lock until
+ # we COMMIT.
+ db2 eval {BEGIN}
+ db2 eval {UPDATE t1 SET a = 0 WHERE 0}
+ catchsql {
+ ATTACH 'test2.db' AS t2;
+ }
+} {0 {}}
+ifcapable schema_pragmas {
+do_test attach2-2.2 {
+ # make sure test2.db did get attached.
+ db_list db
+} {0 main 2 t2}
+} ;# ifcapable schema_pragmas
+db2 eval {COMMIT}
+
+do_test attach2-2.5 {
+ # Make sure we can read test2.db from db
+ catchsql {
+ SELECT name FROM t2.sqlite_master;
+ }
+} {0 {t1 x1}}
+do_test attach2-2.6 {
+ # lock test2.db and try to read from it. This should still work because
+ # the lock is only a RESERVED lock which does not prevent reading.
+ #
+ db2 eval BEGIN
+ db2 eval {UPDATE t1 SET a = 0 WHERE 0}
+ catchsql {
+ SELECT name FROM t2.sqlite_master;
+ }
+} {0 {t1 x1}}
+do_test attach2-2.7 {
+ # but we can still read from test1.db even though test2.db is locked.
+ catchsql {
+ SELECT name FROM main.sqlite_master;
+ }
+} {0 {t1 x1}}
+do_test attach2-2.8 {
+ # start a transaction on test.db even though test2.db is locked.
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(8,9);
+ }
+} {0 {}}
+do_test attach2-2.9 {
+ execsql {
+ SELECT * FROM t1
+ }
+} {8 9}
+do_test attach2-2.10 {
+ # now try to write to test2.db. the write should fail
+ catchsql {
+ INSERT INTO t2.t1 VALUES(1,2);
+ }
+} {1 {database is locked}}
+do_test attach2-2.11 {
+ # when the write failed in the previous test, the transaction should
+ # have rolled back.
+ #
+ # Update for version 3: A transaction is no longer rolled back if a
+ # database is found to be busy.
+ execsql {rollback}
+ db2 eval ROLLBACK
+ execsql {
+ SELECT * FROM t1
+ }
+} {}
+do_test attach2-2.12 {
+ catchsql {
+ COMMIT
+ }
+} {1 {cannot commit - no transaction is active}}
+
+# Ticket #574: Make sure it works using the non-callback API
+#
+do_test attach2-3.1 {
+ set DB [sqlite3_connection_pointer db]
+ set rc [catch {sqlite3_prepare $DB "ATTACH 'test2.db' AS t2" -1 TAIL} VM]
+ if {$rc} {lappend rc $VM}
+ sqlite3_step $VM
+ sqlite3_finalize $VM
+ set rc
+} {0}
+do_test attach2-3.2 {
+ set rc [catch {sqlite3_prepare $DB "DETACH t2" -1 TAIL} VM]
+ if {$rc} {lappend rc $VM}
+ sqlite3_step $VM
+ sqlite3_finalize $VM
+ set rc
+} {0}
+
+db close
+for {set i 2} {$i<=15} {incr i} {
+ catch {db$i close}
+}
+
+# A procedure to verify the status of locks on a database.
+#
+proc lock_status {testnum db expected_result} {
+ # If the database was compiled with OMIT_TEMPDB set, then
+ # the lock_status list will not contain an entry for the temp
+ # db. But the test code doesn't know this, so its easiest
+ # to filter it out of the $expected_result list here.
+ ifcapable !tempdb {
+ set expected_result [concat \
+ [lrange $expected_result 0 1] \
+ [lrange $expected_result 4 end] \
+ ]
+ }
+ do_test attach2-$testnum [subst {
+ $db cache flush ;# The lock_status pragma should not be cached
+ execsql {PRAGMA lock_status} $db
+ }] $expected_result
+}
+set sqlite_os_trace 0
+
+# Tests attach2-4.* test that read-locks work correctly with attached
+# databases.
+do_test attach2-4.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql {ATTACH 'test2.db' as file2}
+ execsql {ATTACH 'test2.db' as file2} db2
+} {}
+
+lock_status 4.1.1 db {main unlocked temp closed file2 unlocked}
+lock_status 4.1.2 db2 {main unlocked temp closed file2 unlocked}
+
+do_test attach2-4.2 {
+ # Handle 'db' read-locks test.db
+ execsql {BEGIN}
+ execsql {SELECT * FROM t1}
+ # Lock status:
+ # db - shared(main)
+ # db2 -
+} {}
+
+lock_status 4.2.1 db {main shared temp closed file2 unlocked}
+lock_status 4.2.2 db2 {main unlocked temp closed file2 unlocked}
+
+do_test attach2-4.3 {
+ # The read lock held by db does not prevent db2 from reading test.db
+ execsql {SELECT * FROM t1} db2
+} {}
+
+lock_status 4.3.1 db {main shared temp closed file2 unlocked}
+lock_status 4.3.2 db2 {main unlocked temp closed file2 unlocked}
+
+do_test attach2-4.4 {
+ # db is holding a read lock on test.db, so we should not be able
+ # to commit a write to test.db from db2
+ catchsql {
+ INSERT INTO t1 VALUES(1, 2)
+ } db2
+} {1 {database is locked}}
+
+lock_status 4.4.1 db {main shared temp closed file2 unlocked}
+lock_status 4.4.2 db2 {main unlocked temp closed file2 unlocked}
+
+# We have to make sure that the cache_size and the soft_heap_limit
+# are large enough to hold the entire change in memory. If either
+# is set too small, then changes will spill to the database, forcing
+# a reserved lock to promote to exclusive. That will mess up our
+# test results.
+
+set soft_limit [sqlite3_soft_heap_limit 0]
+
+
+do_test attach2-4.5 {
+ # Handle 'db2' reserves file2.
+ execsql {BEGIN} db2
+ execsql {INSERT INTO file2.t1 VALUES(1, 2)} db2
+ # Lock status:
+ # db - shared(main)
+ # db2 - reserved(file2)
+} {}
+
+lock_status 4.5.1 db {main shared temp closed file2 unlocked}
+lock_status 4.5.2 db2 {main unlocked temp closed file2 reserved}
+
+do_test attach2-4.6.1 {
+ # Reads are allowed against a reserved database.
+ catchsql {
+ SELECT * FROM file2.t1;
+ }
+ # Lock status:
+ # db - shared(main), shared(file2)
+ # db2 - reserved(file2)
+} {0 {}}
+
+lock_status 4.6.1.1 db {main shared temp closed file2 shared}
+lock_status 4.6.1.2 db2 {main unlocked temp closed file2 reserved}
+
+do_test attach2-4.6.2 {
+ # Writes against a reserved database are not allowed.
+ catchsql {
+ UPDATE file2.t1 SET a=0;
+ }
+} {1 {database is locked}}
+
+lock_status 4.6.2.1 db {main shared temp closed file2 shared}
+lock_status 4.6.2.2 db2 {main unlocked temp closed file2 reserved}
+
+do_test attach2-4.7 {
+ # Ensure handle 'db' retains the lock on the main file after
+ # failing to obtain a write-lock on file2.
+ catchsql {
+ INSERT INTO t1 VALUES(1, 2)
+ } db2
+} {0 {}}
+
+lock_status 4.7.1 db {main shared temp closed file2 shared}
+lock_status 4.7.2 db2 {main reserved temp closed file2 reserved}
+
+do_test attach2-4.8 {
+ # We should still be able to read test.db from db2
+ execsql {SELECT * FROM t1} db2
+} {1 2}
+
+lock_status 4.8.1 db {main shared temp closed file2 shared}
+lock_status 4.8.2 db2 {main reserved temp closed file2 reserved}
+
+do_test attach2-4.9 {
+ # Try to upgrade the handle 'db' lock.
+ catchsql {
+ INSERT INTO t1 VALUES(1, 2)
+ }
+} {1 {database is locked}}
+
+lock_status 4.9.1 db {main shared temp closed file2 shared}
+lock_status 4.9.2 db2 {main reserved temp closed file2 reserved}
+
+do_test attach2-4.10 {
+ # We cannot commit db2 while db is holding a read-lock
+ catchsql {COMMIT} db2
+} {1 {database is locked}}
+
+lock_status 4.10.1 db {main shared temp closed file2 shared}
+lock_status 4.10.2 db2 {main pending temp closed file2 reserved}
+
+set sqlite_os_trace 0
+do_test attach2-4.11 {
+ # db is able to commit.
+ catchsql {COMMIT}
+} {0 {}}
+
+lock_status 4.11.1 db {main unlocked temp closed file2 unlocked}
+lock_status 4.11.2 db2 {main pending temp closed file2 reserved}
+
+do_test attach2-4.12 {
+ # Now we can commit db2
+ catchsql {COMMIT} db2
+} {0 {}}
+
+lock_status 4.12.1 db {main unlocked temp closed file2 unlocked}
+lock_status 4.12.2 db2 {main unlocked temp closed file2 unlocked}
+
+do_test attach2-4.13 {
+ execsql {SELECT * FROM file2.t1}
+} {1 2}
+do_test attach2-4.14 {
+ execsql {INSERT INTO t1 VALUES(1, 2)}
+} {}
+do_test attach2-4.15 {
+ execsql {SELECT * FROM t1} db2
+} {1 2 1 2}
+
+db close
+db2 close
+forcedelete test2.db
+sqlite3_soft_heap_limit $soft_limit
+
+# These tests - attach2-5.* - check that the master journal file is deleted
+# correctly when a multi-file transaction is committed or rolled back.
+#
+# Update: It's not actually created if a rollback occurs, so that test
+# doesn't really prove too much.
+foreach f [glob test.db*] {forcedelete $f}
+do_test attach2-5.1 {
+ sqlite3 db test.db
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ }
+} {}
+do_test attach2-5.2 {
+ execsql {
+ BEGIN;
+ CREATE TABLE tbl(a, b, c);
+ CREATE TABLE aux.tbl(a, b, c);
+ COMMIT;
+ }
+} {}
+do_test attach2-5.3 {
+ lsort [glob test.db*]
+} {test.db test.db2}
+do_test attach2-5.4 {
+ execsql {
+ BEGIN;
+ DROP TABLE aux.tbl;
+ DROP TABLE tbl;
+ ROLLBACK;
+ }
+} {}
+do_test attach2-5.5 {
+ lsort [glob test.db*]
+} {test.db test.db2}
+
+# Check that a database cannot be ATTACHed or DETACHed during a transaction.
+do_test attach2-6.1 {
+ execsql {
+ BEGIN;
+ }
+} {}
+do_test attach2-6.2 {
+ catchsql {
+ ATTACH 'test3.db' as aux2;
+ }
+} {1 {cannot ATTACH database within transaction}}
+
+do_test attach2-6.3 {
+ catchsql {
+ DETACH aux;
+ }
+} {1 {cannot DETACH database within transaction}}
+do_test attach2-6.4 {
+ execsql {
+ COMMIT;
+ DETACH aux;
+ }
+} {}
+
+db close
+
+finish_test
diff --git a/test/attach3.test b/test/attach3.test
new file mode 100644
index 0000000..f861425
--- /dev/null
+++ b/test/attach3.test
@@ -0,0 +1,354 @@
+# 2003 July 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the ATTACH and DETACH commands
+# and schema changes to attached databases.
+#
+# $Id: attach3.test,v 1.18 2007/10/09 08:29:32 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !attach {
+ finish_test
+ return
+}
+
+# The tests in this file were written before SQLite supported recursive
+# trigger invocation, and some tests depend on that to pass. So disable
+# recursive triggers for this file.
+catchsql { pragma recursive_triggers = off }
+
+# Create tables t1 and t2 in the main database
+execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+}
+
+# Create tables t1 and t2 in database file test2.db
+forcedelete test2.db
+forcedelete test2.db-journal
+sqlite3 db2 test2.db
+execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+} db2
+db2 close
+
+# Create a table in the auxilary database.
+do_test attach3-1.1 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ }
+} {}
+do_test attach3-1.2 {
+ execsql {
+ CREATE TABLE aux.t3(e, f);
+ }
+} {}
+do_test attach3-1.3 {
+ execsql {
+ SELECT * FROM sqlite_master WHERE name = 't3';
+ }
+} {}
+do_test attach3-1.4 {
+ execsql {
+ SELECT * FROM aux.sqlite_master WHERE name = 't3';
+ }
+} "table t3 t3 [expr $AUTOVACUUM?5:4] {CREATE TABLE t3(e, f)}"
+do_test attach3-1.5 {
+ execsql {
+ INSERT INTO t3 VALUES(1, 2);
+ SELECT * FROM t3;
+ }
+} {1 2}
+
+# Create an index on the auxilary database table.
+do_test attach3-2.1 {
+ execsql {
+ CREATE INDEX aux.i1 on t3(e);
+ }
+} {}
+do_test attach3-2.2 {
+ execsql {
+ SELECT * FROM sqlite_master WHERE name = 'i1';
+ }
+} {}
+do_test attach3-2.3 {
+ execsql {
+ SELECT * FROM aux.sqlite_master WHERE name = 'i1';
+ }
+} "index i1 t3 [expr $AUTOVACUUM?6:5] {CREATE INDEX i1 on t3(e)}"
+
+# Drop the index on the aux database table.
+do_test attach3-3.1 {
+ execsql {
+ DROP INDEX aux.i1;
+ SELECT * FROM aux.sqlite_master WHERE name = 'i1';
+ }
+} {}
+do_test attach3-3.2 {
+ execsql {
+ CREATE INDEX aux.i1 on t3(e);
+ SELECT * FROM aux.sqlite_master WHERE name = 'i1';
+ }
+} "index i1 t3 [expr $AUTOVACUUM?6:5] {CREATE INDEX i1 on t3(e)}"
+do_test attach3-3.3 {
+ execsql {
+ DROP INDEX i1;
+ SELECT * FROM aux.sqlite_master WHERE name = 'i1';
+ }
+} {}
+
+# Drop tables t1 and t2 in the auxilary database.
+do_test attach3-4.1 {
+ execsql {
+ DROP TABLE aux.t1;
+ SELECT name FROM aux.sqlite_master;
+ }
+} {t2 t3}
+do_test attach3-4.2 {
+ # This will drop main.t2
+ execsql {
+ DROP TABLE t2;
+ SELECT name FROM aux.sqlite_master;
+ }
+} {t2 t3}
+do_test attach3-4.3 {
+ execsql {
+ DROP TABLE t2;
+ SELECT name FROM aux.sqlite_master;
+ }
+} {t3}
+
+# Create a view in the auxilary database.
+ifcapable view {
+do_test attach3-5.1 {
+ execsql {
+ CREATE VIEW aux.v1 AS SELECT * FROM t3;
+ }
+} {}
+do_test attach3-5.2 {
+ execsql {
+ SELECT * FROM aux.sqlite_master WHERE name = 'v1';
+ }
+} {view v1 v1 0 {CREATE VIEW v1 AS SELECT * FROM t3}}
+do_test attach3-5.3 {
+ execsql {
+ INSERT INTO aux.t3 VALUES('hello', 'world');
+ SELECT * FROM v1;
+ }
+} {1 2 hello world}
+
+# Drop the view
+do_test attach3-6.1 {
+ execsql {
+ DROP VIEW aux.v1;
+ }
+} {}
+do_test attach3-6.2 {
+ execsql {
+ SELECT * FROM aux.sqlite_master WHERE name = 'v1';
+ }
+} {}
+} ;# ifcapable view
+
+ifcapable {trigger} {
+# Create a trigger in the auxilary database.
+do_test attach3-7.1 {
+ execsql {
+ CREATE TRIGGER aux.tr1 AFTER INSERT ON t3 BEGIN
+ INSERT INTO t3 VALUES(new.e*2, new.f*2);
+ END;
+ }
+} {}
+do_test attach3-7.2 {
+ execsql {
+ DELETE FROM t3;
+ INSERT INTO t3 VALUES(10, 20);
+ SELECT * FROM t3;
+ }
+} {10 20 20 40}
+do_test attach3-5.3 {
+ execsql {
+ SELECT * FROM aux.sqlite_master WHERE name = 'tr1';
+ }
+} {trigger tr1 t3 0 {CREATE TRIGGER tr1 AFTER INSERT ON t3 BEGIN
+ INSERT INTO t3 VALUES(new.e*2, new.f*2);
+ END}}
+
+# Drop the trigger
+do_test attach3-8.1 {
+ execsql {
+ DROP TRIGGER aux.tr1;
+ }
+} {}
+do_test attach3-8.2 {
+ execsql {
+ SELECT * FROM aux.sqlite_master WHERE name = 'tr1';
+ }
+} {}
+
+ifcapable tempdb {
+ # Try to trick SQLite into dropping the wrong temp trigger.
+ do_test attach3-9.0 {
+ execsql {
+ CREATE TABLE main.t4(a, b, c);
+ CREATE TABLE aux.t4(a, b, c);
+ CREATE TEMP TRIGGER tst_trigger BEFORE INSERT ON aux.t4 BEGIN
+ SELECT 'hello world';
+ END;
+ SELECT count(*) FROM sqlite_temp_master;
+ }
+ } {1}
+ do_test attach3-9.1 {
+ execsql {
+ DROP TABLE main.t4;
+ SELECT count(*) FROM sqlite_temp_master;
+ }
+ } {1}
+ do_test attach3-9.2 {
+ execsql {
+ DROP TABLE aux.t4;
+ SELECT count(*) FROM sqlite_temp_master;
+ }
+ } {0}
+}
+} ;# endif trigger
+
+# Make sure the aux.sqlite_master table is read-only
+do_test attach3-10.0 {
+ catchsql {
+ INSERT INTO aux.sqlite_master VALUES(1, 2, 3, 4, 5);
+ }
+} {1 {table sqlite_master may not be modified}}
+
+# Failure to attach leaves us in a workable state.
+# Ticket #811
+#
+do_test attach3-11.0 {
+ catchsql {
+ ATTACH DATABASE '/nodir/nofile.x' AS notadb;
+ }
+} {1 {unable to open database: /nodir/nofile.x}}
+do_test attach3-11.1 {
+ catchsql {
+ ATTACH DATABASE ':memory:' AS notadb;
+ }
+} {0 {}}
+do_test attach3-11.2 {
+ catchsql {
+ DETACH DATABASE notadb;
+ }
+} {0 {}}
+
+# Return a list of attached databases
+#
+proc db_list {} {
+ set x [execsql {
+ PRAGMA database_list;
+ }]
+ set y {}
+ foreach {n id file} $x {lappend y $id}
+ return $y
+}
+
+ifcapable schema_pragmas&&tempdb {
+
+ifcapable !trigger {
+ execsql {create temp table dummy(dummy)}
+}
+
+# Ticket #1825
+#
+do_test attach3-12.1 {
+ db_list
+} {main temp aux}
+do_test attach3-12.2 {
+ execsql {
+ ATTACH DATABASE ? AS ?
+ }
+ db_list
+} {main temp aux {}}
+do_test attach3-12.3 {
+ execsql {
+ DETACH aux
+ }
+ db_list
+} {main temp {}}
+do_test attach3-12.4 {
+ execsql {
+ DETACH ?
+ }
+ db_list
+} {main temp}
+do_test attach3-12.5 {
+ execsql {
+ ATTACH DATABASE '' AS ''
+ }
+ db_list
+} {main temp {}}
+do_test attach3-12.6 {
+ execsql {
+ DETACH ''
+ }
+ db_list
+} {main temp}
+do_test attach3-12.7 {
+ execsql {
+ ATTACH DATABASE '' AS ?
+ }
+ db_list
+} {main temp {}}
+do_test attach3-12.8 {
+ execsql {
+ DETACH ''
+ }
+ db_list
+} {main temp}
+do_test attach3-12.9 {
+ execsql {
+ ATTACH DATABASE '' AS NULL
+ }
+ db_list
+} {main temp {}}
+do_test attach3-12.10 {
+breakpoint
+ execsql {
+ DETACH ?
+ }
+ db_list
+} {main temp}
+do_test attach3-12.11 {
+ catchsql {
+ DETACH NULL
+ }
+} {1 {no such database: }}
+do_test attach3-12.12 {
+ catchsql {
+ ATTACH null AS null;
+ ATTACH '' AS '';
+ }
+} {1 {database is already in use}}
+do_test attach3-12.13 {
+ db_list
+} {main temp {}}
+do_test attach3-12.14 {
+ execsql {
+ DETACH '';
+ }
+ db_list
+} {main temp}
+
+} ;# ifcapable pragma
+
+finish_test
diff --git a/test/attach4.test b/test/attach4.test
new file mode 100644
index 0000000..77dd7e4
--- /dev/null
+++ b/test/attach4.test
@@ -0,0 +1,118 @@
+# 200 July 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is attaching many database files to a single
+# connection.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix attach4
+
+ifcapable !attach {
+ finish_test
+ return
+}
+
+puts "Testing with SQLITE_MAX_ATTACHED=$SQLITE_MAX_ATTACHED"
+
+set files {main test.db}
+for {set ii 0} {$ii < $SQLITE_MAX_ATTACHED} {incr ii} {
+ lappend files aux$ii "test.db$ii"
+}
+
+do_test 1.1 {
+ sqlite3_limit db SQLITE_LIMIT_ATTACHED -1
+} $SQLITE_MAX_ATTACHED
+
+do_test 1.2.1 {
+ db close
+ foreach {name f} $files { forcedelete $f }
+ sqlite3 db test.db
+
+ foreach {name f} $files {
+ if {$name == "main"} continue
+ execsql "ATTACH '$f' AS $name"
+ }
+
+ db eval {PRAGMA database_list} {
+ lappend L $name [file tail $file]
+ }
+ set L
+} $files
+
+do_catchsql_test 1.2.2 {
+ ATTACH 'x.db' AS next;
+} [list 1 "too many attached databases - max $SQLITE_MAX_ATTACHED"]
+
+do_test 1.3 {
+ execsql BEGIN;
+ foreach {name f} $files {
+ execsql "CREATE TABLE $name.tbl(x)"
+ execsql "INSERT INTO $name.tbl VALUES('$f')"
+ }
+ execsql COMMIT;
+} {}
+
+do_test 1.4 {
+ set L [list]
+ foreach {name f} $files {
+ lappend L $name [execsql "SELECT x FROM $name.tbl"]
+ }
+ set L
+} $files
+
+set L [list]
+set S ""
+foreach {name f} $files {
+ if {[permutation] == "journaltest"} {
+ set mode delete
+ } else {
+ set mode wal
+ }
+ ifcapable !wal { set mode delete }
+ lappend L $mode
+ append S "
+ PRAGMA $name.journal_mode = WAL;
+ UPDATE $name.tbl SET x = '$name';
+ "
+}
+do_execsql_test 1.5 $S $L
+
+do_test 1.6 {
+ set L [list]
+ foreach {name f} $files {
+ lappend L [execsql "SELECT x FROM $name.tbl"] $f
+ }
+ set L
+} $files
+
+do_test 1.7 {
+ execsql BEGIN;
+ foreach {name f} $files {
+ execsql "UPDATE $name.tbl SET x = '$f'"
+ }
+ execsql COMMIT;
+} {}
+
+do_test 1.8 {
+ set L [list]
+ foreach {name f} $files {
+ lappend L $name [execsql "SELECT x FROM $name.tbl"]
+ }
+ set L
+} $files
+
+db close
+foreach {name f} $files { forcedelete $f }
+
+finish_test
diff --git a/test/attachmalloc.test b/test/attachmalloc.test
new file mode 100644
index 0000000..7fee1e1
--- /dev/null
+++ b/test/attachmalloc.test
@@ -0,0 +1,77 @@
+# 2005 September 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the ATTACH statement and
+# specifically out-of-memory conditions within that command.
+#
+# $Id: attachmalloc.test,v 1.10 2008/10/22 10:45:38 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !memdebug||!attach {
+ finish_test
+ return
+}
+
+source $testdir/malloc_common.tcl
+
+do_malloc_test attachmalloc-1 -tclprep {
+ catch { db close }
+ for {set i 2} {$i<=4} {incr i} {
+ catch { db$i close }
+ forcedelete test$i.db
+ forcedelete test$i.db-journal
+ }
+} -tclbody {
+ if {[catch {sqlite3 db test.db}]} {
+ error "out of memory"
+ }
+ sqlite3_db_config_lookaside db 0 0 0
+ sqlite3_extended_result_codes db 1
+} -sqlbody {
+ ATTACH 'test2.db' AS two;
+ CREATE TABLE two.t1(x);
+ ATTACH 'test3.db' AS three;
+ CREATE TABLE three.t1(x);
+ ATTACH 'test4.db' AS four;
+ CREATE TABLE four.t1(x);
+}
+
+do_malloc_test attachmalloc-2 -tclprep {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ sqlite3 db2 test2.db
+ db2 eval {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(a, b);
+ }
+ db2 close
+} -sqlbody {
+ CREATE TABLE t1(d, e, f);
+ ATTACH 'test2.db' AS db1;
+}
+
+set enable_shared_cache [sqlite3_enable_shared_cache 1]
+sqlite3 dbaux test3.db
+dbaux eval {SELECT * FROM sqlite_master}
+do_malloc_test attachmalloc-3 -sqlbody {
+ SELECT * FROM sqlite_master;
+ ATTACH 'test3.db' AS three;
+} -cleanup {
+ db eval { DETACH three }
+}
+dbaux close
+sqlite3_enable_shared_cache $enable_shared_cache
+
+
+finish_test
diff --git a/test/auth.test b/test/auth.test
new file mode 100644
index 0000000..211ae7e
--- /dev/null
+++ b/test/auth.test
@@ -0,0 +1,2372 @@
+# 2003 April 4
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the sqlite3_set_authorizer() API
+# and related functionality.
+#
+# $Id: auth.test,v 1.46 2009/07/02 18:40:35 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# disable this test if the SQLITE_OMIT_AUTHORIZATION macro is
+# defined during compilation.
+if {[catch {db auth {}} msg]} {
+ finish_test
+ return
+}
+
+rename proc proc_real
+proc_real proc {name arguments script} {
+ proc_real $name $arguments $script
+ if {$name=="auth"} {
+ db authorizer ::auth
+ }
+}
+
+do_test auth-1.1.1 {
+ db close
+ set ::DB [sqlite3 db test.db]
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ db authorizer ::auth
+ catchsql {CREATE TABLE t1(a,b,c)}
+} {1 {not authorized}}
+do_test auth-1.1.2 {
+ db errorcode
+} {23}
+do_test auth-1.1.3 {
+ db authorizer
+} {::auth}
+do_test auth-1.1.4 {
+ # Ticket #896.
+ catchsql {
+ SELECT x;
+ }
+} {1 {no such column: x}}
+do_test auth-1.2 {
+ execsql {SELECT name FROM sqlite_master}
+} {}
+do_test auth-1.3.1 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TABLE t1(a,b,c)}
+} {1 {not authorized}}
+do_test auth-1.3.2 {
+ db errorcode
+} {23}
+do_test auth-1.3.3 {
+ set ::authargs
+} {t1 {} main {}}
+do_test auth-1.4 {
+ execsql {SELECT name FROM sqlite_master}
+} {}
+
+ifcapable tempdb {
+ do_test auth-1.5 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TEMP TABLE t1(a,b,c)}
+ } {1 {not authorized}}
+ do_test auth-1.6 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {}
+ do_test auth-1.7.1 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TEMP TABLE t1(a,b,c)}
+ } {1 {not authorized}}
+ do_test auth-1.7.2 {
+ set ::authargs
+ } {t1 {} temp {}}
+ do_test auth-1.8 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {}
+}
+
+do_test auth-1.9 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TABLE t1(a,b,c)}
+} {0 {}}
+do_test auth-1.10 {
+ execsql {SELECT name FROM sqlite_master}
+} {}
+do_test auth-1.11 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TABLE t1(a,b,c)}
+} {0 {}}
+do_test auth-1.12 {
+ execsql {SELECT name FROM sqlite_master}
+} {}
+
+ifcapable tempdb {
+ do_test auth-1.13 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TEMP TABLE t1(a,b,c)}
+ } {0 {}}
+ do_test auth-1.14 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {}
+ do_test auth-1.15 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TEMP TABLE t1(a,b,c)}
+ } {0 {}}
+ do_test auth-1.16 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {}
+
+ do_test auth-1.17 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TEMP TABLE t1(a,b,c)}
+ } {0 {}}
+ do_test auth-1.18 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+}
+
+do_test auth-1.19.1 {
+ set ::authargs {}
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TABLE t2(a,b,c)}
+} {0 {}}
+do_test auth-1.19.2 {
+ set ::authargs
+} {}
+do_test auth-1.20 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+
+do_test auth-1.21.1 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t2}
+} {1 {not authorized}}
+do_test auth-1.21.2 {
+ set ::authargs
+} {t2 {} main {}}
+do_test auth-1.22 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.23.1 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t2}
+} {0 {}}
+do_test auth-1.23.2 {
+ set ::authargs
+} {t2 {} main {}}
+do_test auth-1.24 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+
+ifcapable tempdb {
+ do_test auth-1.25 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t1}
+ } {1 {not authorized}}
+ do_test auth-1.26 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+ do_test auth-1.27 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t1}
+ } {0 {}}
+ do_test auth-1.28 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+}
+
+do_test auth-1.29 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="t2"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {INSERT INTO t2 VALUES(1,2,3)}
+} {1 {not authorized}}
+do_test auth-1.30 {
+ execsql {SELECT * FROM t2}
+} {}
+do_test auth-1.31 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="t2"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {INSERT INTO t2 VALUES(1,2,3)}
+} {0 {}}
+do_test auth-1.32 {
+ execsql {SELECT * FROM t2}
+} {}
+do_test auth-1.33 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="t1"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {INSERT INTO t2 VALUES(1,2,3)}
+} {0 {}}
+do_test auth-1.34 {
+ execsql {SELECT * FROM t2}
+} {1 2 3}
+
+do_test auth-1.35.1 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t2}
+} {1 {access to t2.b is prohibited}}
+ifcapable attach {
+ do_test auth-1.35.2 {
+ execsql {ATTACH DATABASE 'test.db' AS two}
+ catchsql {SELECT * FROM two.t2}
+ } {1 {access to two.t2.b is prohibited}}
+ execsql {DETACH DATABASE two}
+}
+do_test auth-1.36 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t2}
+} {0 {1 {} 3}}
+do_test auth-1.37 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t2 WHERE b=2}
+} {0 {}}
+do_test auth-1.38 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="a"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t2 WHERE b=2}
+} {0 {{} 2 3}}
+do_test auth-1.39 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t2 WHERE b IS NULL}
+} {0 {1 {} 3}}
+do_test auth-1.40 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT a,c FROM t2 WHERE b IS NULL}
+} {1 {access to t2.b is prohibited}}
+
+do_test auth-1.41 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_UPDATE" && $arg1=="t2" && $arg2=="b"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {UPDATE t2 SET a=11}
+} {0 {}}
+do_test auth-1.42 {
+ execsql {SELECT * FROM t2}
+} {11 2 3}
+do_test auth-1.43 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_UPDATE" && $arg1=="t2" && $arg2=="b"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {UPDATE t2 SET b=22, c=33}
+} {1 {not authorized}}
+do_test auth-1.44 {
+ execsql {SELECT * FROM t2}
+} {11 2 3}
+do_test auth-1.45 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_UPDATE" && $arg1=="t2" && $arg2=="b"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {UPDATE t2 SET b=22, c=33}
+} {0 {}}
+do_test auth-1.46 {
+ execsql {SELECT * FROM t2}
+} {11 2 33}
+
+do_test auth-1.47 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="t2"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DELETE FROM t2 WHERE a=11}
+} {1 {not authorized}}
+do_test auth-1.48 {
+ execsql {SELECT * FROM t2}
+} {11 2 33}
+do_test auth-1.49 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="t2"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DELETE FROM t2 WHERE a=11}
+} {0 {}}
+do_test auth-1.50 {
+ execsql {SELECT * FROM t2}
+} {}
+do_test auth-1.50.2 {
+ execsql {INSERT INTO t2 VALUES(11, 2, 33)}
+} {}
+
+do_test auth-1.51 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_SELECT"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t2}
+} {1 {not authorized}}
+do_test auth-1.52 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_SELECT"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t2}
+} {0 {}}
+do_test auth-1.53 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_SELECT"} {
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t2}
+} {0 {11 2 33}}
+
+# Update for version 3: There used to be a handful of test here that
+# tested the authorisation callback with the COPY command. The following
+# test makes the same database modifications as they used to.
+do_test auth-1.54 {
+ execsql {INSERT INTO t2 VALUES(7, 8, 9);}
+} {}
+do_test auth-1.55 {
+ execsql {SELECT * FROM t2}
+} {11 2 33 7 8 9}
+
+do_test auth-1.63 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t2}
+} {1 {not authorized}}
+do_test auth-1.64 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.65 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="t2"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t2}
+} {1 {not authorized}}
+do_test auth-1.66 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+
+ifcapable tempdb {
+ do_test auth-1.67 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t1}
+ } {1 {not authorized}}
+ do_test auth-1.68 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+ do_test auth-1.69 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="t1"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t1}
+ } {1 {not authorized}}
+ do_test auth-1.70 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+}
+
+do_test auth-1.71 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t2}
+} {0 {}}
+do_test auth-1.72 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.73 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="t2"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t2}
+} {0 {}}
+do_test auth-1.74 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+
+ifcapable tempdb {
+ do_test auth-1.75 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t1}
+ } {0 {}}
+ do_test auth-1.76 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+ do_test auth-1.77 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="t1"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TABLE t1}
+ } {0 {}}
+ do_test auth-1.78 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+}
+
+# Test cases auth-1.79 to auth-1.124 test creating and dropping views.
+# Omit these if the library was compiled with views omitted.
+ifcapable view {
+do_test auth-1.79 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_VIEW"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2}
+} {1 {not authorized}}
+do_test auth-1.80 {
+ set ::authargs
+} {v1 {} main {}}
+do_test auth-1.81 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.82 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_VIEW"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2}
+} {0 {}}
+do_test auth-1.83 {
+ set ::authargs
+} {v1 {} main {}}
+do_test auth-1.84 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+
+ifcapable tempdb {
+ do_test auth-1.85 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_VIEW"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2}
+ } {1 {not authorized}}
+ do_test auth-1.86 {
+ set ::authargs
+ } {v1 {} temp {}}
+ do_test auth-1.87 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+ do_test auth-1.88 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_VIEW"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2}
+ } {0 {}}
+ do_test auth-1.89 {
+ set ::authargs
+ } {v1 {} temp {}}
+ do_test auth-1.90 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+}
+
+do_test auth-1.91 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2}
+} {1 {not authorized}}
+do_test auth-1.92 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.93 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2}
+} {0 {}}
+do_test auth-1.94 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+
+ifcapable tempdb {
+ do_test auth-1.95 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2}
+ } {1 {not authorized}}
+ do_test auth-1.96 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+ do_test auth-1.97 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2}
+ } {0 {}}
+ do_test auth-1.98 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+}
+
+do_test auth-1.99 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE VIEW v2 AS SELECT a+1,b+1 FROM t2;
+ DROP VIEW v2
+ }
+} {1 {not authorized}}
+do_test auth-1.100 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 v2}
+do_test auth-1.101 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_VIEW"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP VIEW v2}
+} {1 {not authorized}}
+do_test auth-1.102 {
+ set ::authargs
+} {v2 {} main {}}
+do_test auth-1.103 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 v2}
+do_test auth-1.104 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP VIEW v2}
+} {0 {}}
+do_test auth-1.105 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 v2}
+do_test auth-1.106 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_VIEW"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP VIEW v2}
+} {0 {}}
+do_test auth-1.107 {
+ set ::authargs
+} {v2 {} main {}}
+do_test auth-1.108 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 v2}
+do_test auth-1.109 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_VIEW"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP VIEW v2}
+} {0 {}}
+do_test auth-1.110 {
+ set ::authargs
+} {v2 {} main {}}
+do_test auth-1.111 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+
+
+ifcapable tempdb {
+ do_test auth-1.112 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TEMP VIEW v1 AS SELECT a+1,b+1 FROM t1;
+ DROP VIEW v1
+ }
+ } {1 {not authorized}}
+ do_test auth-1.113 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1 v1}
+ do_test auth-1.114 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_VIEW"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP VIEW v1}
+ } {1 {not authorized}}
+ do_test auth-1.115 {
+ set ::authargs
+ } {v1 {} temp {}}
+ do_test auth-1.116 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1 v1}
+ do_test auth-1.117 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP VIEW v1}
+ } {0 {}}
+ do_test auth-1.118 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1 v1}
+ do_test auth-1.119 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_VIEW"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP VIEW v1}
+ } {0 {}}
+ do_test auth-1.120 {
+ set ::authargs
+ } {v1 {} temp {}}
+ do_test auth-1.121 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1 v1}
+ do_test auth-1.122 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_VIEW"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP VIEW v1}
+ } {0 {}}
+ do_test auth-1.123 {
+ set ::authargs
+ } {v1 {} temp {}}
+ do_test auth-1.124 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+}
+} ;# ifcapable view
+
+# Test cases auth-1.125 to auth-1.176 test creating and dropping triggers.
+# Omit these if the library was compiled with triggers omitted.
+#
+ifcapable trigger&&tempdb {
+do_test auth-1.125 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TRIGGER r2 DELETE on t2 BEGIN
+ SELECT NULL;
+ END;
+ }
+} {1 {not authorized}}
+do_test auth-1.126 {
+ set ::authargs
+} {r2 t2 main {}}
+do_test auth-1.127 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.128 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TRIGGER r2 DELETE on t2 BEGIN
+ SELECT NULL;
+ END;
+ }
+} {1 {not authorized}}
+do_test auth-1.129 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.130 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TRIGGER r2 DELETE on t2 BEGIN
+ SELECT NULL;
+ END;
+ }
+} {0 {}}
+do_test auth-1.131 {
+ set ::authargs
+} {r2 t2 main {}}
+do_test auth-1.132 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.133 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TRIGGER r2 DELETE on t2 BEGIN
+ SELECT NULL;
+ END;
+ }
+} {0 {}}
+do_test auth-1.134 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.135 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TABLE tx(id);
+ CREATE TRIGGER r2 AFTER INSERT ON t2 BEGIN
+ INSERT INTO tx VALUES(NEW.rowid);
+ END;
+ }
+} {0 {}}
+do_test auth-1.136.1 {
+ set ::authargs
+} {r2 t2 main {}}
+do_test auth-1.136.2 {
+ execsql {
+ SELECT name FROM sqlite_master WHERE type='trigger'
+ }
+} {r2}
+do_test auth-1.136.3 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ lappend ::authargs $code $arg1 $arg2 $arg3 $arg4
+ return SQLITE_OK
+ }
+ set ::authargs {}
+ execsql {
+ INSERT INTO t2 VALUES(1,2,3);
+ }
+ set ::authargs
+} {SQLITE_INSERT t2 {} main {} SQLITE_INSERT tx {} main r2 SQLITE_READ t2 ROWID main r2}
+do_test auth-1.136.4 {
+ execsql {
+ SELECT * FROM tx;
+ }
+} {3}
+do_test auth-1.137 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 tx r2}
+do_test auth-1.138 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TRIGGER r1 DELETE on t1 BEGIN
+ SELECT NULL;
+ END;
+ }
+} {1 {not authorized}}
+do_test auth-1.139 {
+ set ::authargs
+} {r1 t1 temp {}}
+do_test auth-1.140 {
+ execsql {SELECT name FROM sqlite_temp_master}
+} {t1}
+do_test auth-1.141 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TRIGGER r1 DELETE on t1 BEGIN
+ SELECT NULL;
+ END;
+ }
+} {1 {not authorized}}
+do_test auth-1.142 {
+ execsql {SELECT name FROM sqlite_temp_master}
+} {t1}
+do_test auth-1.143 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TRIGGER r1 DELETE on t1 BEGIN
+ SELECT NULL;
+ END;
+ }
+} {0 {}}
+do_test auth-1.144 {
+ set ::authargs
+} {r1 t1 temp {}}
+do_test auth-1.145 {
+ execsql {SELECT name FROM sqlite_temp_master}
+} {t1}
+do_test auth-1.146 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TRIGGER r1 DELETE on t1 BEGIN
+ SELECT NULL;
+ END;
+ }
+} {0 {}}
+do_test auth-1.147 {
+ execsql {SELECT name FROM sqlite_temp_master}
+} {t1}
+do_test auth-1.148 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ CREATE TRIGGER r1 DELETE on t1 BEGIN
+ SELECT NULL;
+ END;
+ }
+} {0 {}}
+do_test auth-1.149 {
+ set ::authargs
+} {r1 t1 temp {}}
+do_test auth-1.150 {
+ execsql {SELECT name FROM sqlite_temp_master}
+} {t1 r1}
+
+do_test auth-1.151 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TRIGGER r2}
+} {1 {not authorized}}
+do_test auth-1.152 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 tx r2}
+do_test auth-1.153 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TRIGGER r2}
+} {1 {not authorized}}
+do_test auth-1.154 {
+ set ::authargs
+} {r2 t2 main {}}
+do_test auth-1.155 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 tx r2}
+do_test auth-1.156 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TRIGGER r2}
+} {0 {}}
+do_test auth-1.157 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 tx r2}
+do_test auth-1.158 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TRIGGER r2}
+} {0 {}}
+do_test auth-1.159 {
+ set ::authargs
+} {r2 t2 main {}}
+do_test auth-1.160 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 tx r2}
+do_test auth-1.161 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TRIGGER r2}
+} {0 {}}
+do_test auth-1.162 {
+ set ::authargs
+} {r2 t2 main {}}
+do_test auth-1.163 {
+ execsql {
+ DROP TABLE tx;
+ DELETE FROM t2 WHERE a=1 AND b=2 AND c=3;
+ SELECT name FROM sqlite_master;
+ }
+} {t2}
+
+do_test auth-1.164 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TRIGGER r1}
+} {1 {not authorized}}
+do_test auth-1.165 {
+ execsql {SELECT name FROM sqlite_temp_master}
+} {t1 r1}
+do_test auth-1.166 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TRIGGER r1}
+} {1 {not authorized}}
+do_test auth-1.167 {
+ set ::authargs
+} {r1 t1 temp {}}
+do_test auth-1.168 {
+ execsql {SELECT name FROM sqlite_temp_master}
+} {t1 r1}
+do_test auth-1.169 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TRIGGER r1}
+} {0 {}}
+do_test auth-1.170 {
+ execsql {SELECT name FROM sqlite_temp_master}
+} {t1 r1}
+do_test auth-1.171 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TRIGGER r1}
+} {0 {}}
+do_test auth-1.172 {
+ set ::authargs
+} {r1 t1 temp {}}
+do_test auth-1.173 {
+ execsql {SELECT name FROM sqlite_temp_master}
+} {t1 r1}
+do_test auth-1.174 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_TRIGGER"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP TRIGGER r1}
+} {0 {}}
+do_test auth-1.175 {
+ set ::authargs
+} {r1 t1 temp {}}
+do_test auth-1.176 {
+ execsql {SELECT name FROM sqlite_temp_master}
+} {t1}
+} ;# ifcapable trigger
+
+do_test auth-1.177 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE INDEX i2 ON t2(a)}
+} {1 {not authorized}}
+do_test auth-1.178 {
+ set ::authargs
+} {i2 t2 main {}}
+do_test auth-1.179 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.180 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE INDEX i2 ON t2(a)}
+} {1 {not authorized}}
+do_test auth-1.181 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.182 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE INDEX i2 ON t2(b)}
+} {0 {}}
+do_test auth-1.183 {
+ set ::authargs
+} {i2 t2 main {}}
+do_test auth-1.184 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.185 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE INDEX i2 ON t2(b)}
+} {0 {}}
+do_test auth-1.186 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+do_test auth-1.187 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE INDEX i2 ON t2(a)}
+} {0 {}}
+do_test auth-1.188 {
+ set ::authargs
+} {i2 t2 main {}}
+do_test auth-1.189 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 i2}
+
+ifcapable tempdb {
+ do_test auth-1.190 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE INDEX i1 ON t1(a)}
+ } {1 {not authorized}}
+ do_test auth-1.191 {
+ set ::authargs
+ } {i1 t1 temp {}}
+ do_test auth-1.192 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+ do_test auth-1.193 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE INDEX i1 ON t1(b)}
+ } {1 {not authorized}}
+ do_test auth-1.194 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+ do_test auth-1.195 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE INDEX i1 ON t1(b)}
+ } {0 {}}
+ do_test auth-1.196 {
+ set ::authargs
+ } {i1 t1 temp {}}
+ do_test auth-1.197 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+ do_test auth-1.198 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE INDEX i1 ON t1(c)}
+ } {0 {}}
+ do_test auth-1.199 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+ do_test auth-1.200 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_CREATE_TEMP_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {CREATE INDEX i1 ON t1(a)}
+ } {0 {}}
+ do_test auth-1.201 {
+ set ::authargs
+ } {i1 t1 temp {}}
+ do_test auth-1.202 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1 i1}
+}
+
+do_test auth-1.203 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP INDEX i2}
+} {1 {not authorized}}
+do_test auth-1.204 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 i2}
+do_test auth-1.205 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP INDEX i2}
+} {1 {not authorized}}
+do_test auth-1.206 {
+ set ::authargs
+} {i2 t2 main {}}
+do_test auth-1.207 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 i2}
+do_test auth-1.208 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP INDEX i2}
+} {0 {}}
+do_test auth-1.209 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 i2}
+do_test auth-1.210 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP INDEX i2}
+} {0 {}}
+do_test auth-1.211 {
+ set ::authargs
+} {i2 t2 main {}}
+do_test auth-1.212 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2 i2}
+do_test auth-1.213 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP INDEX i2}
+} {0 {}}
+do_test auth-1.214 {
+ set ::authargs
+} {i2 t2 main {}}
+do_test auth-1.215 {
+ execsql {SELECT name FROM sqlite_master}
+} {t2}
+
+ifcapable tempdb {
+ do_test auth-1.216 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP INDEX i1}
+ } {1 {not authorized}}
+ do_test auth-1.217 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1 i1}
+ do_test auth-1.218 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP INDEX i1}
+ } {1 {not authorized}}
+ do_test auth-1.219 {
+ set ::authargs
+ } {i1 t1 temp {}}
+ do_test auth-1.220 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1 i1}
+ do_test auth-1.221 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP INDEX i1}
+ } {0 {}}
+ do_test auth-1.222 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1 i1}
+ do_test auth-1.223 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP INDEX i1}
+ } {0 {}}
+ do_test auth-1.224 {
+ set ::authargs
+ } {i1 t1 temp {}}
+ do_test auth-1.225 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1 i1}
+ do_test auth-1.226 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DROP_TEMP_INDEX"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {DROP INDEX i1}
+ } {0 {}}
+ do_test auth-1.227 {
+ set ::authargs
+ } {i1 t1 temp {}}
+ do_test auth-1.228 {
+ execsql {SELECT name FROM sqlite_temp_master}
+ } {t1}
+}
+
+do_test auth-1.229 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_PRAGMA"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {PRAGMA full_column_names=on}
+} {1 {not authorized}}
+do_test auth-1.230 {
+ set ::authargs
+} {full_column_names on {} {}}
+do_test auth-1.231 {
+ execsql2 {SELECT a FROM t2}
+} {a 11 a 7}
+do_test auth-1.232 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_PRAGMA"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {PRAGMA full_column_names=on}
+} {0 {}}
+do_test auth-1.233 {
+ set ::authargs
+} {full_column_names on {} {}}
+do_test auth-1.234 {
+ execsql2 {SELECT a FROM t2}
+} {a 11 a 7}
+do_test auth-1.235 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_PRAGMA"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {PRAGMA full_column_names=on}
+} {0 {}}
+do_test auth-1.236 {
+ execsql2 {SELECT a FROM t2}
+} {t2.a 11 t2.a 7}
+do_test auth-1.237 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_PRAGMA"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {PRAGMA full_column_names=OFF}
+} {0 {}}
+do_test auth-1.238 {
+ set ::authargs
+} {full_column_names OFF {} {}}
+do_test auth-1.239 {
+ execsql2 {SELECT a FROM t2}
+} {a 11 a 7}
+
+do_test auth-1.240 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_TRANSACTION"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {BEGIN}
+} {1 {not authorized}}
+do_test auth-1.241 {
+ set ::authargs
+} {BEGIN {} {} {}}
+do_test auth-1.242 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_TRANSACTION" && $arg1!="BEGIN"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {BEGIN; INSERT INTO t2 VALUES(44,55,66); COMMIT}
+} {1 {not authorized}}
+do_test auth-1.243 {
+ set ::authargs
+} {COMMIT {} {} {}}
+do_test auth-1.244 {
+ execsql {SELECT * FROM t2}
+} {11 2 33 7 8 9 44 55 66}
+do_test auth-1.245 {
+ catchsql {ROLLBACK}
+} {1 {not authorized}}
+do_test auth-1.246 {
+ set ::authargs
+} {ROLLBACK {} {} {}}
+do_test auth-1.247 {
+ catchsql {END TRANSACTION}
+} {1 {not authorized}}
+do_test auth-1.248 {
+ set ::authargs
+} {COMMIT {} {} {}}
+do_test auth-1.249 {
+ db authorizer {}
+ catchsql {ROLLBACK}
+} {0 {}}
+do_test auth-1.250 {
+ execsql {SELECT * FROM t2}
+} {11 2 33 7 8 9}
+
+# ticket #340 - authorization for ATTACH and DETACH.
+#
+ifcapable attach {
+ do_test auth-1.251 {
+ db authorizer ::auth
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ATTACH"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ATTACH DATABASE ':memory:' AS test1
+ }
+ } {0 {}}
+ do_test auth-1.252a {
+ set ::authargs
+ } {:memory: {} {} {}}
+ do_test auth-1.252b {
+ db eval {DETACH test1}
+ set ::attachfilename :memory:
+ db eval {ATTACH $::attachfilename AS test1}
+ set ::authargs
+ } {{} {} {} {}}
+ do_test auth-1.252c {
+ db eval {DETACH test1}
+ db eval {ATTACH ':mem' || 'ory:' AS test1}
+ set ::authargs
+ } {{} {} {} {}}
+ do_test auth-1.253 {
+ catchsql {DETACH DATABASE test1}
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ATTACH"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ATTACH DATABASE ':memory:' AS test1;
+ }
+ } {1 {not authorized}}
+ do_test auth-1.254 {
+ lindex [execsql {PRAGMA database_list}] 7
+ } {}
+ do_test auth-1.255 {
+ catchsql {DETACH DATABASE test1}
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ATTACH"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ATTACH DATABASE ':memory:' AS test1;
+ }
+ } {0 {}}
+ do_test auth-1.256 {
+ lindex [execsql {PRAGMA database_list}] 7
+ } {}
+ do_test auth-1.257 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DETACH"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ execsql {ATTACH DATABASE ':memory:' AS test1}
+ catchsql {
+ DETACH DATABASE test1;
+ }
+ } {0 {}}
+ do_test auth-1.258 {
+ lindex [execsql {PRAGMA database_list}] 7
+ } {}
+ do_test auth-1.259 {
+ execsql {ATTACH DATABASE ':memory:' AS test1}
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DETACH"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ DETACH DATABASE test1;
+ }
+ } {0 {}}
+ ifcapable tempdb {
+ ifcapable schema_pragmas {
+ do_test auth-1.260 {
+ lindex [execsql {PRAGMA database_list}] 7
+ } {test1}
+ } ;# ifcapable schema_pragmas
+ do_test auth-1.261 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DETACH"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ DETACH DATABASE test1;
+ }
+ } {1 {not authorized}}
+ ifcapable schema_pragmas {
+ do_test auth-1.262 {
+ lindex [execsql {PRAGMA database_list}] 7
+ } {test1}
+ } ;# ifcapable schema_pragmas
+ db authorizer {}
+ execsql {DETACH DATABASE test1}
+ db authorizer ::auth
+
+ # Authorization for ALTER TABLE. These tests are omitted if the library
+ # was built without ALTER TABLE support.
+ ifcapable altertable {
+
+ do_test auth-1.263 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t1 RENAME TO t1x
+ }
+ } {0 {}}
+ do_test auth-1.264 {
+ execsql {SELECT name FROM sqlite_temp_master WHERE type='table'}
+ } {t1x}
+ do_test auth-1.265 {
+ set authargs
+ } {temp t1 {} {}}
+ do_test auth-1.266 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t1x RENAME TO t1
+ }
+ } {0 {}}
+ do_test auth-1.267 {
+ execsql {SELECT name FROM sqlite_temp_master WHERE type='table'}
+ } {t1x}
+ do_test auth-1.268 {
+ set authargs
+ } {temp t1x {} {}}
+ do_test auth-1.269 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t1x RENAME TO t1
+ }
+ } {1 {not authorized}}
+ do_test auth-1.270 {
+ execsql {SELECT name FROM sqlite_temp_master WHERE type='table'}
+ } {t1x}
+
+ do_test auth-1.271 {
+ set authargs
+ } {temp t1x {} {}}
+ } ;# ifcapable altertable
+
+ } else {
+ db authorizer {}
+ db eval {
+ DETACH DATABASE test1;
+ }
+ }
+}
+
+ifcapable altertable {
+db authorizer {}
+catchsql {ALTER TABLE t1x RENAME TO t1}
+db authorizer ::auth
+do_test auth-1.272 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t2 RENAME TO t2x
+ }
+} {0 {}}
+do_test auth-1.273 {
+ execsql {SELECT name FROM sqlite_master WHERE type='table'}
+} {t2x}
+do_test auth-1.274 {
+ set authargs
+} {main t2 {} {}}
+do_test auth-1.275 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t2x RENAME TO t2
+ }
+} {0 {}}
+do_test auth-1.276 {
+ execsql {SELECT name FROM sqlite_master WHERE type='table'}
+} {t2x}
+do_test auth-1.277 {
+ set authargs
+} {main t2x {} {}}
+do_test auth-1.278 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t2x RENAME TO t2
+ }
+} {1 {not authorized}}
+do_test auth-1.279 {
+ execsql {SELECT name FROM sqlite_master WHERE type='table'}
+} {t2x}
+do_test auth-1.280 {
+ set authargs
+} {main t2x {} {}}
+db authorizer {}
+catchsql {ALTER TABLE t2x RENAME TO t2}
+
+} ;# ifcapable altertable
+
+# Test the authorization callbacks for the REINDEX command.
+ifcapable reindex {
+
+proc auth {code args} {
+ if {$code=="SQLITE_REINDEX"} {
+ set ::authargs [concat $::authargs $args]
+ }
+ return SQLITE_OK
+}
+db authorizer auth
+do_test auth-1.281 {
+ execsql {
+ CREATE TABLE t3(a PRIMARY KEY, b, c);
+ CREATE INDEX t3_idx1 ON t3(c COLLATE BINARY);
+ CREATE INDEX t3_idx2 ON t3(b COLLATE NOCASE);
+ }
+} {}
+do_test auth-1.282 {
+ set ::authargs {}
+ execsql {
+ REINDEX t3_idx1;
+ }
+ set ::authargs
+} {t3_idx1 {} main {}}
+do_test auth-1.283 {
+ set ::authargs {}
+ execsql {
+ REINDEX BINARY;
+ }
+ set ::authargs
+} {t3_idx1 {} main {} sqlite_autoindex_t3_1 {} main {}}
+do_test auth-1.284 {
+ set ::authargs {}
+ execsql {
+ REINDEX NOCASE;
+ }
+ set ::authargs
+} {t3_idx2 {} main {}}
+do_test auth-1.285 {
+ set ::authargs {}
+ execsql {
+ REINDEX t3;
+ }
+ set ::authargs
+} {t3_idx2 {} main {} t3_idx1 {} main {} sqlite_autoindex_t3_1 {} main {}}
+do_test auth-1.286 {
+ execsql {
+ DROP TABLE t3;
+ }
+} {}
+ifcapable tempdb {
+ do_test auth-1.287 {
+ execsql {
+ CREATE TEMP TABLE t3(a PRIMARY KEY, b, c);
+ CREATE INDEX t3_idx1 ON t3(c COLLATE BINARY);
+ CREATE INDEX t3_idx2 ON t3(b COLLATE NOCASE);
+ }
+ } {}
+ do_test auth-1.288 {
+ set ::authargs {}
+ execsql {
+ REINDEX temp.t3_idx1;
+ }
+ set ::authargs
+ } {t3_idx1 {} temp {}}
+ do_test auth-1.289 {
+ set ::authargs {}
+ execsql {
+ REINDEX BINARY;
+ }
+ set ::authargs
+ } {t3_idx1 {} temp {} sqlite_autoindex_t3_1 {} temp {}}
+ do_test auth-1.290 {
+ set ::authargs {}
+ execsql {
+ REINDEX NOCASE;
+ }
+ set ::authargs
+ } {t3_idx2 {} temp {}}
+ do_test auth-1.291 {
+ set ::authargs {}
+ execsql {
+ REINDEX temp.t3;
+ }
+ set ::authargs
+ } {t3_idx2 {} temp {} t3_idx1 {} temp {} sqlite_autoindex_t3_1 {} temp {}}
+ proc auth {code args} {
+ if {$code=="SQLITE_REINDEX"} {
+ set ::authargs [concat $::authargs $args]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ do_test auth-1.292 {
+ set ::authargs {}
+ catchsql {
+ REINDEX temp.t3;
+ }
+ } {1 {not authorized}}
+ do_test auth-1.293 {
+ execsql {
+ DROP TABLE t3;
+ }
+ } {}
+}
+
+} ;# ifcapable reindex
+
+ifcapable analyze {
+ proc auth {code args} {
+ if {$code=="SQLITE_ANALYZE"} {
+ set ::authargs [concat $::authargs $args]
+ }
+ return SQLITE_OK
+ }
+ do_test auth-1.294 {
+ set ::authargs {}
+ execsql {
+ CREATE TABLE t4(a,b,c);
+ CREATE INDEX t4i1 ON t4(a);
+ CREATE INDEX t4i2 ON t4(b,a,c);
+ INSERT INTO t4 VALUES(1,2,3);
+ ANALYZE;
+ }
+ set ::authargs
+ } {t4 {} main {} t2 {} main {}}
+ do_test auth-1.295 {
+ execsql {
+ SELECT count(*) FROM sqlite_stat1;
+ }
+ } 3
+ proc auth {code args} {
+ if {$code=="SQLITE_ANALYZE"} {
+ set ::authargs [concat $::authargs $args]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ do_test auth-1.296 {
+ set ::authargs {}
+ catchsql {
+ ANALYZE;
+ }
+ } {1 {not authorized}}
+ do_test auth-1.297 {
+ execsql {
+ SELECT count(*) FROM sqlite_stat1;
+ }
+ } 3
+} ;# ifcapable analyze
+
+
+# Authorization for ALTER TABLE ADD COLUMN.
+# These tests are omitted if the library
+# was built without ALTER TABLE support.
+ifcapable {altertable} {
+ do_test auth-1.300 {
+ execsql {CREATE TABLE t5(x)}
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t5 ADD COLUMN new_col_1;
+ }
+ } {0 {}}
+ do_test auth-1.301 {
+ set x [execsql {SELECT sql FROM sqlite_master WHERE name='t5'}]
+ regexp new_col_1 $x
+ } {1}
+ do_test auth-1.302 {
+ set authargs
+ } {main t5 {} {}}
+ do_test auth-1.303 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t5 ADD COLUMN new_col_2;
+ }
+ } {0 {}}
+ do_test auth-1.304 {
+ set x [execsql {SELECT sql FROM sqlite_master WHERE name='t5'}]
+ regexp new_col_2 $x
+ } {0}
+ do_test auth-1.305 {
+ set authargs
+ } {main t5 {} {}}
+ do_test auth-1.306 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t5 ADD COLUMN new_col_3
+ }
+ } {1 {not authorized}}
+ do_test auth-1.307 {
+ set x [execsql {SELECT sql FROM sqlite_temp_master WHERE type='t5'}]
+ regexp new_col_3 $x
+ } {0}
+
+ do_test auth-1.308 {
+ set authargs
+ } {main t5 {} {}}
+ execsql {DROP TABLE t5}
+} ;# ifcapable altertable
+
+do_test auth-2.1 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t3" && $arg2=="x"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ db authorizer ::auth
+ execsql {CREATE TABLE t3(x INTEGER PRIMARY KEY, y, z)}
+ catchsql {SELECT * FROM t3}
+} {1 {access to t3.x is prohibited}}
+do_test auth-2.1 {
+ catchsql {SELECT y,z FROM t3}
+} {0 {}}
+do_test auth-2.2 {
+ catchsql {SELECT ROWID,y,z FROM t3}
+} {1 {access to t3.x is prohibited}}
+do_test auth-2.3 {
+ catchsql {SELECT OID,y,z FROM t3}
+} {1 {access to t3.x is prohibited}}
+do_test auth-2.4 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t3" && $arg2=="x"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ execsql {INSERT INTO t3 VALUES(44,55,66)}
+ catchsql {SELECT * FROM t3}
+} {0 {{} 55 66}}
+do_test auth-2.5 {
+ catchsql {SELECT rowid,y,z FROM t3}
+} {0 {{} 55 66}}
+do_test auth-2.6 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t3" && $arg2=="ROWID"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t3}
+} {0 {44 55 66}}
+do_test auth-2.7 {
+ catchsql {SELECT ROWID,y,z FROM t3}
+} {0 {44 55 66}}
+do_test auth-2.8 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="ROWID"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT ROWID,b,c FROM t2}
+} {0 {{} 2 33 {} 8 9}}
+do_test auth-2.9.1 {
+ # We have to flush the cache here in case the Tcl interface tries to
+ # reuse a statement compiled with sqlite3_prepare_v2(). In this case,
+ # the first error encountered is an SQLITE_SCHEMA error. Then, when
+ # trying to recompile the statement, the authorization error is encountered.
+ # If we do not flush the cache, the correct error message is returned, but
+ # the error code is SQLITE_SCHEMA, not SQLITE_ERROR as required by the test
+ # case after this one.
+ #
+ db cache flush
+
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="ROWID"} {
+ return bogus
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT ROWID,b,c FROM t2}
+} {1 {authorizer malfunction}}
+do_test auth-2.9.2 {
+ db errorcode
+} {1}
+do_test auth-2.10 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_SELECT"} {
+ return bogus
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT ROWID,b,c FROM t2}
+} {1 {authorizer malfunction}}
+do_test auth-2.11.1 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg2=="a"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t2, t3}
+} {0 {{} 2 33 44 55 66 {} 8 9 44 55 66}}
+do_test auth-2.11.2 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg2=="x"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {SELECT * FROM t2, t3}
+} {0 {11 2 33 {} 55 66 7 8 9 {} 55 66}}
+
+# Make sure the OLD and NEW pseudo-tables of a trigger get authorized.
+#
+ifcapable trigger {
+ do_test auth-3.1 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ return SQLITE_OK
+ }
+ execsql {
+ CREATE TABLE tx(a1,a2,b1,b2,c1,c2);
+ CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN
+ INSERT INTO tx VALUES(OLD.a,NEW.a,OLD.b,NEW.b,OLD.c,NEW.c);
+ END;
+ UPDATE t2 SET a=a+1;
+ SELECT * FROM tx;
+ }
+ } {11 12 2 2 33 33 7 8 8 8 9 9}
+ do_test auth-3.2 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="c"} {
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ execsql {
+ DELETE FROM tx;
+ UPDATE t2 SET a=a+100;
+ SELECT * FROM tx;
+ }
+ } {12 112 2 2 {} {} 8 108 8 8 {} {}}
+} ;# ifcapable trigger
+
+# Make sure the names of views and triggers are passed on on arg4.
+#
+ifcapable trigger {
+do_test auth-4.1 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ lappend ::authargs $code $arg1 $arg2 $arg3 $arg4
+ return SQLITE_OK
+ }
+ set authargs {}
+ execsql {
+ UPDATE t2 SET a=a+1;
+ }
+ set authargs
+} [list \
+ SQLITE_READ t2 a main {} \
+ SQLITE_UPDATE t2 a main {} \
+ SQLITE_INSERT tx {} main r1 \
+ SQLITE_READ t2 a main r1 \
+ SQLITE_READ t2 a main r1 \
+ SQLITE_READ t2 b main r1 \
+ SQLITE_READ t2 b main r1 \
+ SQLITE_READ t2 c main r1 \
+ SQLITE_READ t2 c main r1]
+}
+
+ifcapable {view && trigger} {
+do_test auth-4.2 {
+ execsql {
+ CREATE VIEW v1 AS SELECT a+b AS x FROM t2;
+ CREATE TABLE v1chng(x1,x2);
+ CREATE TRIGGER r2 INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO v1chng VALUES(OLD.x,NEW.x);
+ END;
+ SELECT * FROM v1;
+ }
+} {115 117}
+do_test auth-4.3 {
+ set authargs {}
+ execsql {
+ UPDATE v1 SET x=1 WHERE x=117
+ }
+ set authargs
+} [list \
+ SQLITE_UPDATE v1 x main {} \
+ SQLITE_SELECT {} {} {} v1 \
+ SQLITE_READ t2 a main v1 \
+ SQLITE_READ t2 b main v1 \
+ SQLITE_SELECT {} {} {} {} \
+ SQLITE_READ v1 x main v1 \
+ SQLITE_INSERT v1chng {} main r2 \
+ SQLITE_READ v1 x main r2 \
+ SQLITE_READ v1 x main r2 \
+]
+
+do_test auth-4.4 {
+ execsql {
+ CREATE TRIGGER r3 INSTEAD OF DELETE ON v1 BEGIN
+ INSERT INTO v1chng VALUES(OLD.x,NULL);
+ END;
+ SELECT * FROM v1;
+ }
+} {115 117}
+do_test auth-4.5 {
+ set authargs {}
+ execsql {
+ DELETE FROM v1 WHERE x=117
+ }
+ set authargs
+} [list \
+ SQLITE_DELETE v1 {} main {} \
+ SQLITE_SELECT {} {} {} v1 \
+ SQLITE_READ t2 a main v1 \
+ SQLITE_READ t2 b main v1 \
+ SQLITE_SELECT {} {} {} {} \
+ SQLITE_READ v1 x main v1 \
+ SQLITE_INSERT v1chng {} main r3 \
+ SQLITE_READ v1 x main r3 \
+]
+
+} ;# ifcapable view && trigger
+
+# Ticket #1338: Make sure authentication works in the presence of an AS
+# clause.
+#
+do_test auth-5.1 {
+ proc auth {code arg1 arg2 arg3 arg4} {
+ return SQLITE_OK
+ }
+ execsql {
+ SELECT count(a) AS cnt FROM t4 ORDER BY cnt
+ }
+} {1}
+
+# Ticket #1607
+#
+ifcapable compound&&subquery {
+ ifcapable trigger {
+ execsql {
+ DROP TABLE tx;
+ }
+ ifcapable view {
+ execsql {
+ DROP TABLE v1chng;
+ }
+ }
+ }
+ ifcapable stat3 {
+ set stat3 "sqlite_stat3 "
+ } else {
+ set stat3 ""
+ }
+ do_test auth-5.2 {
+ execsql {
+ SELECT name FROM (
+ SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master)
+ WHERE type='table'
+ ORDER BY name
+ }
+ } "sqlite_stat1 ${stat3}t1 t2 t3 t4"
+}
+
+# Ticket #3944
+#
+ifcapable trigger {
+ do_test auth-5.3.1 {
+ execsql {
+ CREATE TABLE t5 ( x );
+ CREATE TRIGGER t5_tr1 AFTER INSERT ON t5 BEGIN
+ UPDATE t5 SET x = 1 WHERE NEW.x = 0;
+ END;
+ }
+ } {}
+ set ::authargs [list]
+ proc auth {args} {
+ eval lappend ::authargs $args
+ return SQLITE_OK
+ }
+ do_test auth-5.3.2 {
+ execsql { INSERT INTO t5 (x) values(0) }
+ set ::authargs
+ } [list SQLITE_INSERT t5 {} main {} \
+ SQLITE_UPDATE t5 x main t5_tr1 \
+ SQLITE_READ t5 x main t5_tr1 \
+ ]
+ do_test auth-5.3.2 {
+ execsql { SELECT * FROM t5 }
+ } {1}
+}
+
+
+rename proc {}
+rename proc_real proc
+
+
+finish_test
diff --git a/test/auth2.test b/test/auth2.test
new file mode 100644
index 0000000..f5dba14
--- /dev/null
+++ b/test/auth2.test
@@ -0,0 +1,170 @@
+# 2006 Aug 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the sqlite3_set_authorizer() API
+# and related functionality.
+#
+# $Id: auth2.test,v 1.3 2008/07/02 13:13:53 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# disable this test if the SQLITE_OMIT_AUTHORIZATION macro is
+# defined during compilation.
+if {[catch {db auth {}} msg]} {
+ finish_test
+ return
+}
+
+do_test auth2-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ }
+ set ::flist {}
+ proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_FUNCTION"} {
+ lappend ::flist $arg2
+ if {$arg2=="max"} {
+ return SQLITE_DENY
+ } elseif {$arg2=="min"} {
+ return SQLITE_IGNORE
+ } else {
+ return SQLITE_OK
+ }
+ }
+ return SQLITE_OK
+ }
+ db authorizer ::auth
+ catchsql {SELECT max(a,b,c) FROM t1}
+} {1 {not authorized to use function: max}}
+do_test auth2-1.2 {
+ set ::flist
+} max
+do_test auth2-1.3 {
+ set ::flist {}
+ catchsql {SELECT min(a,b,c) FROM t1}
+} {0 {{}}}
+do_test auth2-1.4 {
+ set ::flist
+} min
+do_test auth2-1.5 {
+ set ::flist {}
+ catchsql {SELECT coalesce(min(a,b,c),999) FROM t1}
+} {0 999}
+do_test auth2-1.6 {
+ set ::flist
+} {coalesce min}
+do_test auth2-1.7 {
+ set ::flist {}
+ catchsql {SELECT coalesce(a,b,c) FROM t1}
+} {0 1}
+do_test auth2-1.8 {
+ set ::flist
+} coalesce
+
+# Make sure the authorizer is not called when parsing the schema
+# and when computing the result set of a view.
+#
+db close
+sqlite3 db test.db
+sqlite3 db2 test.db
+proc auth {args} {
+ global authargs
+ append authargs $args\n
+ return SQLITE_OK
+}
+db auth auth
+do_test auth2-2.1 {
+ set ::authargs {}
+ db eval {
+ CREATE TABLE t2(x,y,z);
+ }
+ set ::authargs
+} {SQLITE_INSERT sqlite_master {} main {}
+SQLITE_CREATE_TABLE t2 {} main {}
+SQLITE_UPDATE sqlite_master type main {}
+SQLITE_UPDATE sqlite_master name main {}
+SQLITE_UPDATE sqlite_master tbl_name main {}
+SQLITE_UPDATE sqlite_master rootpage main {}
+SQLITE_UPDATE sqlite_master sql main {}
+SQLITE_READ sqlite_master ROWID main {}
+SQLITE_READ sqlite_master name main {}
+SQLITE_READ sqlite_master rootpage main {}
+SQLITE_READ sqlite_master sql main {}
+SQLITE_READ sqlite_master tbl_name main {}
+SQLITE_READ sqlite_master ROWID main {}
+}
+do_test auth2-2.2 {
+ set ::authargs {}
+ db eval {
+ CREATE VIEW v2 AS SELECT x+y AS a, y+z AS b from t2;
+ }
+ set ::authargs
+} {SQLITE_INSERT sqlite_master {} main {}
+SQLITE_CREATE_VIEW v2 {} main {}
+SQLITE_UPDATE sqlite_master type main {}
+SQLITE_UPDATE sqlite_master name main {}
+SQLITE_UPDATE sqlite_master tbl_name main {}
+SQLITE_UPDATE sqlite_master rootpage main {}
+SQLITE_UPDATE sqlite_master sql main {}
+SQLITE_READ sqlite_master ROWID main {}
+SQLITE_READ sqlite_master name main {}
+SQLITE_READ sqlite_master rootpage main {}
+SQLITE_READ sqlite_master sql main {}
+SQLITE_READ sqlite_master tbl_name main {}
+SQLITE_READ sqlite_master ROWID main {}
+}
+do_test auth2-2.3 {
+ set ::authargs {}
+ db eval {
+ SELECT a, b FROM v2;
+ }
+ set ::authargs
+} {SQLITE_SELECT {} {} {} {}
+SQLITE_READ v2 a main {}
+SQLITE_READ v2 b main {}
+SQLITE_READ t2 x main v2
+SQLITE_READ t2 y main v2
+SQLITE_READ t2 y main v2
+SQLITE_READ t2 z main v2
+SQLITE_SELECT {} {} {} v2
+}
+do_test auth2-2.4 {
+ db2 eval {
+ CREATE TABLE t3(p,q,r);
+ }
+ set ::authargs {}
+ db eval {
+ SELECT b, a FROM v2;
+ }
+ set ::authargs
+} {SQLITE_SELECT {} {} {} {}
+SQLITE_READ v2 b main {}
+SQLITE_READ v2 a main {}
+SQLITE_READ t2 x main v2
+SQLITE_READ t2 y main v2
+SQLITE_READ t2 y main v2
+SQLITE_READ t2 z main v2
+SQLITE_SELECT {} {} {} v2
+SQLITE_SELECT {} {} {} {}
+SQLITE_READ v2 b main {}
+SQLITE_READ v2 a main {}
+SQLITE_READ t2 x main v2
+SQLITE_READ t2 y main v2
+SQLITE_READ t2 y main v2
+SQLITE_READ t2 z main v2
+SQLITE_SELECT {} {} {} v2
+}
+db2 close
+
+finish_test
diff --git a/test/auth3.test b/test/auth3.test
new file mode 100644
index 0000000..21e2b3b
--- /dev/null
+++ b/test/auth3.test
@@ -0,0 +1,111 @@
+# 2008 October 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test that the truncate optimization is disabled if the SQLITE_DELETE
+# authorization callback returns SQLITE_IGNORE.
+#
+# $Id: auth3.test,v 1.2 2009/05/04 01:58:31 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# disable this test if the SQLITE_OMIT_AUTHORIZATION macro is
+# defined during compilation.
+if {[catch {db auth {}} msg]} {
+ finish_test
+ return
+}
+
+# Disable the statement cache for these tests.
+#
+db cache size 0
+
+db authorizer ::auth
+proc auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_DELETE"} {
+ return $::authcode
+ }
+ return SQLITE_OK
+}
+
+#--------------------------------------------------------------------------
+# The following tests - auth3-1.* - test that return values of SQLITE_DENY,
+# SQLITE_IGNORE, SQLITE_OK and <invalid> are correctly handled when returned
+# by an SQLITE_DELETE authorization callback triggered by a
+# "DELETE FROM <table-name>" statement.
+#
+do_test auth3-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ }
+} {}
+do_test auth3.1.2 {
+ set ::authcode SQLITE_DENY
+ catchsql { DELETE FROM t1 }
+} {1 {not authorized}}
+do_test auth3.1.3 {
+ set ::authcode SQLITE_INVALID
+ catchsql { DELETE FROM t1 }
+} {1 {authorizer malfunction}}
+do_test auth3.1.4 {
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4 5 6}
+do_test auth3-1.5 {
+ set ::authcode SQLITE_IGNORE
+ execsql {
+ DELETE FROM t1;
+ SELECT * FROM t1;
+ }
+} {}
+do_test auth3-1.6 {
+ set ::authcode SQLITE_OK
+ execsql {
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ DELETE FROM t1;
+ SELECT * FROM t1;
+ }
+} {}
+
+#--------------------------------------------------------------------------
+# These tests - auth3-2.* - test that returning SQLITE_IGNORE really does
+# disable the truncate optimization.
+#
+do_test auth3-2.1 {
+ set ::authcode SQLITE_OK
+ execsql {
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ }
+ set sqlite_search_count 0
+ execsql {
+ DELETE FROM t1;
+ }
+ set sqlite_search_count
+} {0}
+
+do_test auth3-2.2 {
+ set ::authcode SQLITE_IGNORE
+ execsql {
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ }
+ set sqlite_search_count 0
+ execsql {
+ DELETE FROM t1;
+ }
+ set sqlite_search_count
+} {1}
+
+finish_test
diff --git a/test/autoinc.test b/test/autoinc.test
new file mode 100644
index 0000000..98f6919
--- /dev/null
+++ b/test/autoinc.test
@@ -0,0 +1,668 @@
+# 2004 November 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the AUTOINCREMENT features.
+#
+# $Id: autoinc.test,v 1.14 2009/06/23 20:28:54 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If the library is not compiled with autoincrement support then
+# skip all tests in this file.
+#
+ifcapable {!autoinc} {
+ finish_test
+ return
+}
+
+sqlite3_db_config_lookaside db 0 0 0
+
+# The database is initially empty.
+#
+do_test autoinc-1.1 {
+ execsql {
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {}
+
+# Add a table with the AUTOINCREMENT feature. Verify that the
+# SQLITE_SEQUENCE table gets created.
+#
+do_test autoinc-1.2 {
+ execsql {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {t1 sqlite_sequence}
+
+# The SQLITE_SEQUENCE table is initially empty
+#
+do_test autoinc-1.3 {
+ execsql {
+ SELECT * FROM sqlite_sequence;
+ }
+} {}
+do_test autoinc-1.3.1 {
+ catchsql {
+ CREATE INDEX seqidx ON sqlite_sequence(name)
+ }
+} {1 {table sqlite_sequence may not be indexed}}
+
+# Close and reopen the database. Verify that everything is still there.
+#
+do_test autoinc-1.4 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM sqlite_sequence;
+ }
+} {}
+
+# We are not allowed to drop the sqlite_sequence table.
+#
+do_test autoinc-1.5 {
+ catchsql {DROP TABLE sqlite_sequence}
+} {1 {table sqlite_sequence may not be dropped}}
+do_test autoinc-1.6 {
+ execsql {SELECT name FROM sqlite_master WHERE type='table'}
+} {t1 sqlite_sequence}
+
+# Insert an entries into the t1 table and make sure the largest key
+# is always recorded in the sqlite_sequence table.
+#
+do_test autoinc-2.1 {
+ execsql {
+ SELECT * FROM sqlite_sequence
+ }
+} {}
+do_test autoinc-2.2 {
+ execsql {
+ INSERT INTO t1 VALUES(12,34);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 12}
+do_test autoinc-2.3 {
+ execsql {
+ INSERT INTO t1 VALUES(1,23);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 12}
+do_test autoinc-2.4 {
+ execsql {
+ INSERT INTO t1 VALUES(123,456);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 123}
+do_test autoinc-2.5 {
+ execsql {
+ INSERT INTO t1 VALUES(NULL,567);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 124}
+do_test autoinc-2.6 {
+ execsql {
+ DELETE FROM t1 WHERE y=567;
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 124}
+do_test autoinc-2.7 {
+ execsql {
+ INSERT INTO t1 VALUES(NULL,567);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 125}
+do_test autoinc-2.8 {
+ execsql {
+ DELETE FROM t1;
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 125}
+do_test autoinc-2.9 {
+ execsql {
+ INSERT INTO t1 VALUES(12,34);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 125}
+do_test autoinc-2.10 {
+ execsql {
+ INSERT INTO t1 VALUES(125,456);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 125}
+do_test autoinc-2.11 {
+ execsql {
+ INSERT INTO t1 VALUES(-1234567,-1);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 125}
+do_test autoinc-2.12 {
+ execsql {
+ INSERT INTO t1 VALUES(234,5678);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 234}
+do_test autoinc-2.13 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(NULL,1);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 235}
+do_test autoinc-2.14 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {235 1}
+
+# Manually change the autoincrement values in sqlite_sequence.
+#
+do_test autoinc-2.20 {
+ execsql {
+ UPDATE sqlite_sequence SET seq=1234 WHERE name='t1';
+ INSERT INTO t1 VALUES(NULL,2);
+ SELECT * FROM t1;
+ }
+} {235 1 1235 2}
+do_test autoinc-2.21 {
+ execsql {
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 1235}
+do_test autoinc-2.22 {
+ execsql {
+ UPDATE sqlite_sequence SET seq=NULL WHERE name='t1';
+ INSERT INTO t1 VALUES(NULL,3);
+ SELECT * FROM t1;
+ }
+} {235 1 1235 2 1236 3}
+do_test autoinc-2.23 {
+ execsql {
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 1236}
+do_test autoinc-2.24 {
+ execsql {
+ UPDATE sqlite_sequence SET seq='a-string' WHERE name='t1';
+ INSERT INTO t1 VALUES(NULL,4);
+ SELECT * FROM t1;
+ }
+} {235 1 1235 2 1236 3 1237 4}
+do_test autoinc-2.25 {
+ execsql {
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 1237}
+do_test autoinc-2.26 {
+ execsql {
+ DELETE FROM sqlite_sequence WHERE name='t1';
+ INSERT INTO t1 VALUES(NULL,5);
+ SELECT * FROM t1;
+ }
+} {235 1 1235 2 1236 3 1237 4 1238 5}
+do_test autoinc-2.27 {
+ execsql {
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 1238}
+do_test autoinc-2.28 {
+ execsql {
+ UPDATE sqlite_sequence SET seq='12345678901234567890'
+ WHERE name='t1';
+ INSERT INTO t1 VALUES(NULL,6);
+ SELECT * FROM t1;
+ }
+} {235 1 1235 2 1236 3 1237 4 1238 5 1239 6}
+do_test autoinc-2.29 {
+ execsql {
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 1239}
+
+# Test multi-row inserts
+#
+do_test autoinc-2.50 {
+ execsql {
+ DELETE FROM t1 WHERE y>=3;
+ INSERT INTO t1 SELECT NULL, y+2 FROM t1;
+ SELECT * FROM t1;
+ }
+} {235 1 1235 2 1240 3 1241 4}
+do_test autoinc-2.51 {
+ execsql {
+ SELECT * FROM sqlite_sequence
+ }
+} {t1 1241}
+
+ifcapable tempdb {
+ do_test autoinc-2.52 {
+ execsql {
+ CREATE TEMP TABLE t2 AS SELECT y FROM t1;
+ }
+ execsql {
+ INSERT INTO t1 SELECT NULL, y+4 FROM t2;
+ SELECT * FROM t1;
+ }
+ } {235 1 1235 2 1240 3 1241 4 1242 5 1243 6 1244 7 1245 8}
+ do_test autoinc-2.53 {
+ execsql {
+ SELECT * FROM sqlite_sequence
+ }
+ } {t1 1245}
+ do_test autoinc-2.54 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 SELECT NULL, y FROM t2;
+ SELECT * FROM t1;
+ }
+ } {1246 1 1247 2 1248 3 1249 4}
+ do_test autoinc-2.55 {
+ execsql {
+ SELECT * FROM sqlite_sequence
+ }
+ } {t1 1249}
+}
+
+# Create multiple AUTOINCREMENT tables. Make sure all sequences are
+# tracked separately and do not interfere with one another.
+#
+do_test autoinc-2.70 {
+ catchsql {
+ DROP TABLE t2;
+ }
+ execsql {
+ CREATE TABLE t2(d, e INTEGER PRIMARY KEY AUTOINCREMENT, f);
+ INSERT INTO t2(d) VALUES(1);
+ SELECT * FROM sqlite_sequence;
+ }
+} [ifcapable tempdb {list t1 1249 t2 1} else {list t1 1241 t2 1}]
+do_test autoinc-2.71 {
+ execsql {
+ INSERT INTO t2(d) VALUES(2);
+ SELECT * FROM sqlite_sequence;
+ }
+} [ifcapable tempdb {list t1 1249 t2 2} else {list t1 1241 t2 2}]
+do_test autoinc-2.72 {
+ execsql {
+ INSERT INTO t1(x) VALUES(10000);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 10000 t2 2}
+do_test autoinc-2.73 {
+ execsql {
+ CREATE TABLE t3(g INTEGER PRIMARY KEY AUTOINCREMENT, h);
+ INSERT INTO t3(h) VALUES(1);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 10000 t2 2 t3 1}
+do_test autoinc-2.74 {
+ execsql {
+ INSERT INTO t2(d,e) VALUES(3,100);
+ SELECT * FROM sqlite_sequence;
+ }
+} {t1 10000 t2 100 t3 1}
+
+
+# When a table with an AUTOINCREMENT is deleted, the corresponding entry
+# in the SQLITE_SEQUENCE table should also be deleted. But the SQLITE_SEQUENCE
+# table itself should remain behind.
+#
+do_test autoinc-3.1 {
+ execsql {SELECT name FROM sqlite_sequence}
+} {t1 t2 t3}
+do_test autoinc-3.2 {
+ execsql {
+ DROP TABLE t1;
+ SELECT name FROM sqlite_sequence;
+ }
+} {t2 t3}
+do_test autoinc-3.3 {
+ execsql {
+ DROP TABLE t3;
+ SELECT name FROM sqlite_sequence;
+ }
+} {t2}
+do_test autoinc-3.4 {
+ execsql {
+ DROP TABLE t2;
+ SELECT name FROM sqlite_sequence;
+ }
+} {}
+
+# AUTOINCREMENT on TEMP tables.
+#
+ifcapable tempdb {
+ do_test autoinc-4.1 {
+ execsql {
+ SELECT 1, name FROM sqlite_master WHERE type='table';
+ SELECT 2, name FROM sqlite_temp_master WHERE type='table';
+ }
+ } {1 sqlite_sequence}
+ do_test autoinc-4.2 {
+ execsql {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
+ CREATE TEMP TABLE t3(a INTEGER PRIMARY KEY AUTOINCREMENT, b);
+ SELECT 1, name FROM sqlite_master WHERE type='table';
+ SELECT 2, name FROM sqlite_temp_master WHERE type='table';
+ }
+ } {1 sqlite_sequence 1 t1 2 t3 2 sqlite_sequence}
+ do_test autoinc-4.3 {
+ execsql {
+ SELECT 1, * FROM main.sqlite_sequence;
+ SELECT 2, * FROM temp.sqlite_sequence;
+ }
+ } {}
+ do_test autoinc-4.4 {
+ execsql {
+ INSERT INTO t1 VALUES(10,1);
+ INSERT INTO t3 VALUES(20,2);
+ INSERT INTO t1 VALUES(NULL,3);
+ INSERT INTO t3 VALUES(NULL,4);
+ }
+ } {}
+
+ ifcapable compound {
+ do_test autoinc-4.4.1 {
+ execsql {
+ SELECT * FROM t1 UNION ALL SELECT * FROM t3;
+ }
+ } {10 1 11 3 20 2 21 4}
+ } ;# ifcapable compound
+
+ do_test autoinc-4.5 {
+ execsql {
+ SELECT 1, * FROM main.sqlite_sequence;
+ SELECT 2, * FROM temp.sqlite_sequence;
+ }
+ } {1 t1 11 2 t3 21}
+ do_test autoinc-4.6 {
+ execsql {
+ INSERT INTO t1 SELECT * FROM t3;
+ SELECT 1, * FROM main.sqlite_sequence;
+ SELECT 2, * FROM temp.sqlite_sequence;
+ }
+ } {1 t1 21 2 t3 21}
+ do_test autoinc-4.7 {
+ execsql {
+ INSERT INTO t3 SELECT x+100, y FROM t1;
+ SELECT 1, * FROM main.sqlite_sequence;
+ SELECT 2, * FROM temp.sqlite_sequence;
+ }
+ } {1 t1 21 2 t3 121}
+ do_test autoinc-4.8 {
+ execsql {
+ DROP TABLE t3;
+ SELECT 1, * FROM main.sqlite_sequence;
+ SELECT 2, * FROM temp.sqlite_sequence;
+ }
+ } {1 t1 21}
+ do_test autoinc-4.9 {
+ execsql {
+ CREATE TEMP TABLE t2(p INTEGER PRIMARY KEY AUTOINCREMENT, q);
+ INSERT INTO t2 SELECT * FROM t1;
+ DROP TABLE t1;
+ SELECT 1, * FROM main.sqlite_sequence;
+ SELECT 2, * FROM temp.sqlite_sequence;
+ }
+ } {2 t2 21}
+ do_test autoinc-4.10 {
+ execsql {
+ DROP TABLE t2;
+ SELECT 1, * FROM main.sqlite_sequence;
+ SELECT 2, * FROM temp.sqlite_sequence;
+ }
+ } {}
+}
+
+# Make sure AUTOINCREMENT works on ATTACH-ed tables.
+#
+ifcapable tempdb&&attach {
+ do_test autoinc-5.1 {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ sqlite3 db2 test2.db
+ execsql {
+ CREATE TABLE t4(m INTEGER PRIMARY KEY AUTOINCREMENT, n);
+ CREATE TABLE t5(o, p INTEGER PRIMARY KEY AUTOINCREMENT);
+ } db2;
+ execsql {
+ ATTACH 'test2.db' as aux;
+ SELECT 1, * FROM main.sqlite_sequence;
+ SELECT 2, * FROM temp.sqlite_sequence;
+ SELECT 3, * FROM aux.sqlite_sequence;
+ }
+ } {}
+ do_test autoinc-5.2 {
+ execsql {
+ INSERT INTO t4 VALUES(NULL,1);
+ SELECT 1, * FROM main.sqlite_sequence;
+ SELECT 2, * FROM temp.sqlite_sequence;
+ SELECT 3, * FROM aux.sqlite_sequence;
+ }
+ } {3 t4 1}
+ do_test autoinc-5.3 {
+ execsql {
+ INSERT INTO t5 VALUES(100,200);
+ SELECT * FROM sqlite_sequence
+ } db2
+ } {t4 1 t5 200}
+ do_test autoinc-5.4 {
+ execsql {
+ SELECT 1, * FROM main.sqlite_sequence;
+ SELECT 2, * FROM temp.sqlite_sequence;
+ SELECT 3, * FROM aux.sqlite_sequence;
+ }
+ } {3 t4 1 3 t5 200}
+}
+
+# Requirement REQ00310: Make sure an insert fails if the sequence is
+# already at its maximum value.
+#
+ifcapable {rowid32} {
+ do_test autoinc-6.1 {
+ execsql {
+ CREATE TABLE t6(v INTEGER PRIMARY KEY AUTOINCREMENT, w);
+ INSERT INTO t6 VALUES(2147483647,1);
+ SELECT seq FROM main.sqlite_sequence WHERE name='t6';
+ }
+ } 2147483647
+}
+ifcapable {!rowid32} {
+ do_test autoinc-6.1 {
+ execsql {
+ CREATE TABLE t6(v INTEGER PRIMARY KEY AUTOINCREMENT, w);
+ INSERT INTO t6 VALUES(9223372036854775807,1);
+ SELECT seq FROM main.sqlite_sequence WHERE name='t6';
+ }
+ } 9223372036854775807
+}
+do_test autoinc-6.2 {
+ catchsql {
+ INSERT INTO t6 VALUES(NULL,1);
+ }
+} {1 {database or disk is full}}
+
+# Allow the AUTOINCREMENT keyword inside the parentheses
+# on a separate PRIMARY KEY designation.
+#
+do_test autoinc-7.1 {
+ execsql {
+ CREATE TABLE t7(x INTEGER, y REAL, PRIMARY KEY(x AUTOINCREMENT));
+ INSERT INTO t7(y) VALUES(123);
+ INSERT INTO t7(y) VALUES(234);
+ DELETE FROM t7;
+ INSERT INTO t7(y) VALUES(345);
+ SELECT * FROM t7;
+ }
+} {3 345.0}
+
+# Test that if the AUTOINCREMENT is applied to a non integer primary key
+# the error message is sensible.
+do_test autoinc-7.2 {
+ catchsql {
+ CREATE TABLE t8(x TEXT PRIMARY KEY AUTOINCREMENT);
+ }
+} {1 {AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY}}
+
+
+# Ticket #1283. Make sure that preparing but never running a statement
+# that creates the sqlite_sequence table does not mess up the database.
+#
+do_test autoinc-8.1 {
+ catch {db2 close}
+ catch {db close}
+ forcedelete test.db
+ sqlite3 db test.db
+ set DB [sqlite3_connection_pointer db]
+ set STMT [sqlite3_prepare $DB {
+ CREATE TABLE t1(
+ x INTEGER PRIMARY KEY AUTOINCREMENT
+ )
+ } -1 TAIL]
+ sqlite3_finalize $STMT
+ set STMT [sqlite3_prepare $DB {
+ CREATE TABLE t1(
+ x INTEGER PRIMARY KEY AUTOINCREMENT
+ )
+ } -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {
+ INSERT INTO t1 VALUES(NULL);
+ SELECT * FROM t1;
+ }
+} {1}
+
+# Ticket #3148
+# Make sure the sqlite_sequence table is not damaged when doing
+# an empty insert - an INSERT INTO ... SELECT ... where the SELECT
+# clause returns an empty set.
+#
+do_test autoinc-9.1 {
+ db eval {
+ CREATE TABLE t2(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
+ INSERT INTO t2 VALUES(NULL, 1);
+ CREATE TABLE t3(a INTEGER PRIMARY KEY AUTOINCREMENT, b);
+ INSERT INTO t3 SELECT * FROM t2 WHERE y>1;
+
+ SELECT * FROM sqlite_sequence WHERE name='t3';
+ }
+} {t3 0}
+
+ifcapable trigger {
+ catchsql { pragma recursive_triggers = off }
+
+ # Ticket #3928. Make sure that triggers to not make extra slots in
+ # the SQLITE_SEQUENCE table.
+ #
+ do_test autoinc-3928.1 {
+ db eval {
+ CREATE TABLE t3928(a INTEGER PRIMARY KEY AUTOINCREMENT, b);
+ CREATE TRIGGER t3928r1 BEFORE INSERT ON t3928 BEGIN
+ INSERT INTO t3928(b) VALUES('before1');
+ INSERT INTO t3928(b) VALUES('before2');
+ END;
+ CREATE TRIGGER t3928r2 AFTER INSERT ON t3928 BEGIN
+ INSERT INTO t3928(b) VALUES('after1');
+ INSERT INTO t3928(b) VALUES('after2');
+ END;
+ INSERT INTO t3928(b) VALUES('test');
+ SELECT * FROM t3928 ORDER BY a;
+ }
+ } {1 before1 2 after1 3 after2 4 before2 5 after1 6 after2 7 test 8 before1 9 before2 10 after1 11 before1 12 before2 13 after2}
+ do_test autoinc-3928.2 {
+ db eval {
+ SELECT * FROM sqlite_sequence WHERE name='t3928'
+ }
+ } {t3928 13}
+
+ do_test autoinc-3928.3 {
+ db eval {
+ DROP TRIGGER t3928r1;
+ DROP TRIGGER t3928r2;
+ CREATE TRIGGER t3928r3 BEFORE UPDATE ON t3928
+ WHEN typeof(new.b)=='integer' BEGIN
+ INSERT INTO t3928(b) VALUES('before-int-' || new.b);
+ END;
+ CREATE TRIGGER t3928r4 AFTER UPDATE ON t3928
+ WHEN typeof(new.b)=='integer' BEGIN
+ INSERT INTO t3928(b) VALUES('after-int-' || new.b);
+ END;
+ DELETE FROM t3928 WHERE a!=1;
+ UPDATE t3928 SET b=456 WHERE a=1;
+ SELECT * FROM t3928 ORDER BY a;
+ }
+ } {1 456 14 before-int-456 15 after-int-456}
+ do_test autoinc-3928.4 {
+ db eval {
+ SELECT * FROM sqlite_sequence WHERE name='t3928'
+ }
+ } {t3928 15}
+
+ do_test autoinc-3928.5 {
+ db eval {
+ CREATE TABLE t3928b(x);
+ INSERT INTO t3928b VALUES(100);
+ INSERT INTO t3928b VALUES(200);
+ INSERT INTO t3928b VALUES(300);
+ DELETE FROM t3928;
+ CREATE TABLE t3928c(y INTEGER PRIMARY KEY AUTOINCREMENT, z);
+ CREATE TRIGGER t3928br1 BEFORE DELETE ON t3928b BEGIN
+ INSERT INTO t3928(b) VALUES('before-del-'||old.x);
+ INSERT INTO t3928c(z) VALUES('before-del-'||old.x);
+ END;
+ CREATE TRIGGER t3928br2 AFTER DELETE ON t3928b BEGIN
+ INSERT INTO t3928(b) VALUES('after-del-'||old.x);
+ INSERT INTO t3928c(z) VALUES('after-del-'||old.x);
+ END;
+ DELETE FROM t3928b;
+ SELECT * FROM t3928 ORDER BY a;
+ }
+ } {16 before-del-100 17 after-del-100 18 before-del-200 19 after-del-200 20 before-del-300 21 after-del-300}
+ do_test autoinc-3928.6 {
+ db eval {
+ SELECT * FROM t3928c ORDER BY y;
+ }
+ } {1 before-del-100 2 after-del-100 3 before-del-200 4 after-del-200 5 before-del-300 6 after-del-300}
+ do_test autoinc-3928.7 {
+ db eval {
+ SELECT * FROM sqlite_sequence WHERE name LIKE 't3928%' ORDER BY name;
+ }
+ } {t3928 21 t3928c 6}
+
+ # Ticket [a696379c1f0886615541a48b35bd8181a80e88f8]
+ do_test autoinc-a69637.1 {
+ db eval {
+ CREATE TABLE ta69637_1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
+ CREATE TABLE ta69637_2(z);
+ CREATE TRIGGER ra69637_1 AFTER INSERT ON ta69637_2 BEGIN
+ INSERT INTO ta69637_1(y) VALUES(new.z+1);
+ END;
+ INSERT INTO ta69637_2 VALUES(123);
+ SELECT * FROM ta69637_1;
+ }
+ } {1 124}
+ do_test autoinc-a69637.2 {
+ db eval {
+ CREATE VIEW va69637_2 AS SELECT * FROM ta69637_2;
+ CREATE TRIGGER ra69637_2 INSTEAD OF INSERT ON va69637_2 BEGIN
+ INSERT INTO ta69637_1(y) VALUES(new.z+10000);
+ END;
+ INSERT INTO va69637_2 VALUES(123);
+ SELECT * FROM ta69637_1;
+ }
+ } {1 124 2 10123}
+}
+
+
+
+finish_test
diff --git a/test/autoindex1.test b/test/autoindex1.test
new file mode 100644
index 0000000..6c8d54d
--- /dev/null
+++ b/test/autoindex1.test
@@ -0,0 +1,261 @@
+# 2010 April 07
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing automatic index creation logic.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If the library is not compiled with automatic index support then
+# skip all tests in this file.
+#
+ifcapable {!autoindex} {
+ finish_test
+ return
+}
+
+# With automatic index turned off, we do a full scan of the T2 table
+do_test autoindex1-100 {
+ db eval {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,11);
+ INSERT INTO t1 VALUES(2,22);
+ INSERT INTO t1 SELECT a+2, b+22 FROM t1;
+ INSERT INTO t1 SELECT a+4, b+44 FROM t1;
+ CREATE TABLE t2(c,d);
+ INSERT INTO t2 SELECT a, 900+b FROM t1;
+ }
+ db eval {
+ PRAGMA automatic_index=OFF;
+ SELECT b, d FROM t1 JOIN t2 ON a=c ORDER BY b;
+ }
+} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}
+do_test autoindex1-101 {
+ db status step
+} {63}
+do_test autoindex1-102 {
+ db status autoindex
+} {0}
+
+# With autoindex turned on, we build an index once and then use that index
+# to find T2 values.
+do_test autoindex1-110 {
+ db eval {
+ PRAGMA automatic_index=ON;
+ SELECT b, d FROM t1 JOIN t2 ON a=c ORDER BY b;
+ }
+} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}
+do_test autoindex1-111 {
+ db status step
+} {7}
+do_test autoindex1-112 {
+ db status autoindex
+} {7}
+
+# The same test as above, but this time the T2 query is a subquery rather
+# than a join.
+do_test autoindex1-200 {
+ db eval {
+ PRAGMA automatic_index=OFF;
+ SELECT b, (SELECT d FROM t2 WHERE c=a) FROM t1;
+ }
+} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}
+do_test autoindex1-201 {
+ db status step
+} {35}
+do_test autoindex1-202 {
+ db status autoindex
+} {0}
+do_test autoindex1-210 {
+ db eval {
+ PRAGMA automatic_index=ON;
+ SELECT b, (SELECT d FROM t2 WHERE c=a) FROM t1;
+ }
+} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}
+do_test autoindex1-211 {
+ db status step
+} {7}
+do_test autoindex1-212 {
+ db status autoindex
+} {7}
+
+
+# Modify the second table of the join while the join is in progress
+#
+do_test autoindex1-300 {
+ set r {}
+ db eval {SELECT b, d FROM t1 JOIN t2 ON (c=a)} {
+ lappend r $b $d
+ db eval {UPDATE t2 SET d=d+1}
+ }
+ set r
+} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}
+do_test autoindex1-310 {
+ db eval {SELECT d FROM t2 ORDER BY d}
+} {919 930 941 952 963 974 985 996}
+
+# The next test does a 10-way join on unindexed tables. Without
+# automatic indices, the join will take a long time to complete.
+# With automatic indices, it should only take about a second.
+#
+do_test autoindex1-400 {
+ db eval {
+ CREATE TABLE t4(a, b);
+ INSERT INTO t4 VALUES(1,2);
+ INSERT INTO t4 VALUES(2,3);
+ }
+ for {set n 2} {$n<4096} {set n [expr {$n+$n}]} {
+ db eval {INSERT INTO t4 SELECT a+$n, b+$n FROM t4}
+ }
+ db eval {
+ SELECT count(*) FROM t4;
+ }
+} {4096}
+do_test autoindex1-401 {
+ db eval {
+ SELECT count(*)
+ FROM t4 AS x1
+ JOIN t4 AS x2 ON x2.a=x1.b
+ JOIN t4 AS x3 ON x3.a=x2.b
+ JOIN t4 AS x4 ON x4.a=x3.b
+ JOIN t4 AS x5 ON x5.a=x4.b
+ JOIN t4 AS x6 ON x6.a=x5.b
+ JOIN t4 AS x7 ON x7.a=x6.b
+ JOIN t4 AS x8 ON x8.a=x7.b
+ JOIN t4 AS x9 ON x9.a=x8.b
+ JOIN t4 AS x10 ON x10.a=x9.b;
+ }
+} {4087}
+
+# Ticket [8011086c85c6c404014c947fcf3eb9f42b184a0d] from 2010-07-08
+# Make sure automatic indices are not created for the RHS of an IN expression
+# that is not a correlated subquery.
+#
+do_execsql_test autoindex1-500 {
+ CREATE TABLE t501(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t502(x INTEGER PRIMARY KEY, y);
+ EXPLAIN QUERY PLAN
+ SELECT b FROM t501
+ WHERE t501.a IN (SELECT x FROM t502 WHERE y=?);
+} {
+ 0 0 0 {SEARCH TABLE t501 USING INTEGER PRIMARY KEY (rowid=?) (~25 rows)}
+ 0 0 0 {EXECUTE LIST SUBQUERY 1}
+ 1 0 0 {SCAN TABLE t502 (~100000 rows)}
+}
+do_execsql_test autoindex1-501 {
+ EXPLAIN QUERY PLAN
+ SELECT b FROM t501
+ WHERE t501.a IN (SELECT x FROM t502 WHERE y=t501.b);
+} {
+ 0 0 0 {SCAN TABLE t501 (~500000 rows)}
+ 0 0 0 {EXECUTE CORRELATED LIST SUBQUERY 1}
+ 1 0 0 {SEARCH TABLE t502 USING AUTOMATIC COVERING INDEX (y=?) (~7 rows)}
+}
+do_execsql_test autoindex1-502 {
+ EXPLAIN QUERY PLAN
+ SELECT b FROM t501
+ WHERE t501.a=123
+ AND t501.a IN (SELECT x FROM t502 WHERE y=t501.b);
+} {
+ 0 0 0 {SEARCH TABLE t501 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+ 0 0 0 {EXECUTE CORRELATED LIST SUBQUERY 1}
+ 1 0 0 {SCAN TABLE t502 (~100000 rows)}
+}
+
+
+# The following code checks a performance regression reported on the
+# mailing list on 2010-10-19. The problem is that the nRowEst field
+# of ephermeral tables was not being initialized correctly and so no
+# automatic index was being created for the emphemeral table when it was
+# used as part of a join.
+#
+do_execsql_test autoindex1-600 {
+ CREATE TABLE flock_owner(
+ owner_rec_id INTEGER CONSTRAINT flock_owner_key PRIMARY KEY,
+ flock_no VARCHAR(6) NOT NULL REFERENCES flock (flock_no),
+ owner_person_id INTEGER NOT NULL REFERENCES person (person_id),
+ owner_change_date TEXT, last_changed TEXT NOT NULL,
+ CONSTRAINT fo_owner_date UNIQUE (flock_no, owner_change_date)
+ );
+ CREATE TABLE sheep (
+ Sheep_No char(7) NOT NULL,
+ Date_of_Birth char(8),
+ Sort_DoB text,
+ Flock_Book_Vol char(2),
+ Breeder_No char(6),
+ Breeder_Person integer,
+ Originating_Flock char(6),
+ Registering_Flock char(6),
+ Tag_Prefix char(9),
+ Tag_No char(15),
+ Sort_Tag_No integer,
+ Breeders_Temp_Tag char(15),
+ Sex char(1),
+ Sheep_Name char(32),
+ Sire_No char(7),
+ Dam_No char(7),
+ Register_Code char(1),
+ Colour char(48),
+ Colour_Code char(2),
+ Pattern_Code char(8),
+ Horns char(1),
+ Litter_Size char(1),
+ Coeff_of_Inbreeding real,
+ Date_of_Registration text,
+ Date_Last_Changed text,
+ UNIQUE(Sheep_No));
+ CREATE INDEX fo_flock_no_index
+ ON flock_owner (flock_no);
+ CREATE INDEX fo_owner_change_date_index
+ ON flock_owner (owner_change_date);
+ CREATE INDEX fo_owner_person_id_index
+ ON flock_owner (owner_person_id);
+ CREATE INDEX sheep_org_flock_index
+ ON sheep (originating_flock);
+ CREATE INDEX sheep_reg_flock_index
+ ON sheep (registering_flock);
+ EXPLAIN QUERY PLAN
+ SELECT x.sheep_no, x.registering_flock, x.date_of_registration
+ FROM sheep x LEFT JOIN
+ (SELECT s.sheep_no, prev.flock_no, prev.owner_person_id,
+ s.date_of_registration, prev.owner_change_date
+ FROM sheep s JOIN flock_owner prev ON s.registering_flock =
+ prev.flock_no
+ AND (prev.owner_change_date <= s.date_of_registration || ' 00:00:00')
+ WHERE NOT EXISTS
+ (SELECT 'x' FROM flock_owner later
+ WHERE prev.flock_no = later.flock_no
+ AND later.owner_change_date > prev.owner_change_date
+ AND later.owner_change_date <= s.date_of_registration||' 00:00:00')
+ ) y ON x.sheep_no = y.sheep_no
+ WHERE y.sheep_no IS NULL
+ ORDER BY x.registering_flock;
+} {
+ 1 0 0 {SCAN TABLE sheep AS s (~1000000 rows)}
+ 1 1 1 {SEARCH TABLE flock_owner AS prev USING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date<?) (~2 rows)}
+ 1 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 2}
+ 2 0 0 {SEARCH TABLE flock_owner AS later USING COVERING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date>? AND owner_change_date<?) (~1 rows)}
+ 0 0 0 {SCAN TABLE sheep AS x USING INDEX sheep_reg_flock_index (~1000000 rows)}
+ 0 1 1 {SEARCH SUBQUERY 1 AS y USING AUTOMATIC COVERING INDEX (sheep_no=?) (~8 rows)}
+}
+
+
+do_execsql_test autoindex1-700 {
+ CREATE TABLE t5(a, b, c);
+ EXPLAIN QUERY PLAN SELECT a FROM t5 WHERE b=10 ORDER BY c;
+} {
+ 0 0 0 {SCAN TABLE t5 (~100000 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+
+
+finish_test
diff --git a/test/autovacuum.test b/test/autovacuum.test
new file mode 100644
index 0000000..1aef18f
--- /dev/null
+++ b/test/autovacuum.test
@@ -0,0 +1,698 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the SELECT statement.
+#
+# $Id: autovacuum.test,v 1.29 2009/04/06 17:50:03 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build of the library does not support auto-vacuum, omit this
+# whole file.
+ifcapable {!autovacuum || !pragma} {
+ finish_test
+ return
+}
+
+# Return a string $len characters long. The returned string is $char repeated
+# over and over. For example, [make_str abc 8] returns "abcabcab".
+proc make_str {char len} {
+ set str [string repeat $char. $len]
+ return [string range $str 0 [expr $len-1]]
+}
+
+# Return the number of pages in the file test.db by looking at the file system.
+proc file_pages {} {
+ return [expr [file size test.db] / 1024]
+}
+
+#-------------------------------------------------------------------------
+# Test cases autovacuum-1.* work as follows:
+#
+# 1. A table with a single indexed field is created.
+# 2. Approximately 20 rows are inserted into the table. Each row is long
+# enough such that it uses at least 2 overflow pages for both the table
+# and index entry.
+# 3. The rows are deleted in a psuedo-random order. Sometimes only one row
+# is deleted per transaction, sometimes more than one.
+# 4. After each transaction the table data is checked to ensure it is correct
+# and a "PRAGMA integrity_check" is executed.
+# 5. Once all the rows are deleted the file is checked to make sure it
+# consists of exactly 4 pages.
+#
+# Steps 2-5 are repeated for a few different psuedo-random delete patterns
+# (defined by the $delete_orders list).
+set delete_orders [list]
+lappend delete_orders {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
+lappend delete_orders {20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+lappend delete_orders {8 18 2 4 14 11 13 3 10 7 9 5 12 17 19 15 20 6 16 1}
+lappend delete_orders {10 3 11 17 19 20 7 4 13 6 1 14 16 12 9 18 8 15 5 2}
+lappend delete_orders {{1 2 3 4 5 6 7 8 9 10} {11 12 13 14 15 16 17 18 19 20}}
+lappend delete_orders {{19 8 17 15} {16 11 9 14} {18 5 3 1} {13 20 7 2} {6 12}}
+
+# The length of each table entry.
+# set ENTRY_LEN 3500
+set ENTRY_LEN 3500
+
+do_test autovacuum-1.1 {
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE av1(a);
+ CREATE INDEX av1_idx ON av1(a);
+ }
+} {}
+
+set tn 0
+foreach delete_order $delete_orders {
+ incr tn
+
+ # Set up the table.
+ set ::tbl_data [list]
+ foreach i [lsort -integer [eval concat $delete_order]] {
+ execsql "INSERT INTO av1 (oid, a) VALUES($i, '[make_str $i $ENTRY_LEN]')"
+ lappend ::tbl_data [make_str $i $ENTRY_LEN]
+ }
+
+ # Make sure the integrity check passes with the initial data.
+ ifcapable {integrityck} {
+ do_test autovacuum-1.$tn.1 {
+ execsql {
+ pragma integrity_check
+ }
+ } {ok}
+ }
+
+ foreach delete $delete_order {
+ # Delete one set of rows from the table.
+ do_test autovacuum-1.$tn.($delete).1 {
+ execsql "
+ DELETE FROM av1 WHERE oid = [join $delete " OR oid = "]
+ "
+ } {}
+
+ # Do the integrity check.
+ ifcapable {integrityck} {
+ do_test autovacuum-1.$tn.($delete).2 {
+ execsql {
+ pragma integrity_check
+ }
+ } {ok}
+ }
+ # Ensure the data remaining in the table is what was expected.
+ foreach d $delete {
+ set idx [lsearch $::tbl_data [make_str $d $ENTRY_LEN]]
+ set ::tbl_data [lreplace $::tbl_data $idx $idx]
+ }
+ do_test autovacuum-1.$tn.($delete).3 {
+ execsql {
+ select a from av1
+ }
+ } $::tbl_data
+ }
+
+ # All rows have been deleted. Ensure the file has shrunk to 4 pages.
+ do_test autovacuum-1.$tn.3 {
+ file_pages
+ } {4}
+}
+
+#---------------------------------------------------------------------------
+# Tests cases autovacuum-2.* test that root pages are allocated
+# and deallocated correctly at the start of the file. Operation is roughly as
+# follows:
+#
+# autovacuum-2.1.*: Drop the tables that currently exist in the database.
+# autovacuum-2.2.*: Create some tables. Ensure that data pages can be
+# moved correctly to make space for new root-pages.
+# autovacuum-2.3.*: Drop one of the tables just created (not the last one),
+# and check that one of the other tables is moved to
+# the free root-page location.
+# autovacuum-2.4.*: Check that a table can be created correctly when the
+# root-page it requires is on the free-list.
+# autovacuum-2.5.*: Check that a table with indices can be dropped. This
+# is slightly tricky because dropping one of the
+# indices/table btrees could move the root-page of another.
+# The code-generation layer of SQLite overcomes this problem
+# by dropping the btrees in descending order of root-pages.
+# This test ensures that this actually happens.
+#
+do_test autovacuum-2.1.1 {
+ execsql {
+ DROP TABLE av1;
+ }
+} {}
+do_test autovacuum-2.1.2 {
+ file_pages
+} {1}
+
+# Create a table and put some data in it.
+do_test autovacuum-2.2.1 {
+ execsql {
+ CREATE TABLE av1(x);
+ SELECT rootpage FROM sqlite_master ORDER BY rootpage;
+ }
+} {3}
+do_test autovacuum-2.2.2 {
+ execsql "
+ INSERT INTO av1 VALUES('[make_str abc 3000]');
+ INSERT INTO av1 VALUES('[make_str def 3000]');
+ INSERT INTO av1 VALUES('[make_str ghi 3000]');
+ INSERT INTO av1 VALUES('[make_str jkl 3000]');
+ "
+ set ::av1_data [db eval {select * from av1}]
+ file_pages
+} {15}
+
+# Create another table. Check it is located immediately after the first.
+# This test case moves the second page in an over-flow chain.
+do_test autovacuum-2.2.3 {
+ execsql {
+ CREATE TABLE av2(x);
+ SELECT rootpage FROM sqlite_master ORDER BY rootpage;
+ }
+} {3 4}
+do_test autovacuum-2.2.4 {
+ file_pages
+} {16}
+
+# Create another table. Check it is located immediately after the second.
+# This test case moves the first page in an over-flow chain.
+do_test autovacuum-2.2.5 {
+ execsql {
+ CREATE TABLE av3(x);
+ SELECT rootpage FROM sqlite_master ORDER BY rootpage;
+ }
+} {3 4 5}
+do_test autovacuum-2.2.6 {
+ file_pages
+} {17}
+
+# Create another table. Check it is located immediately after the second.
+# This test case moves a btree leaf page.
+do_test autovacuum-2.2.7 {
+ execsql {
+ CREATE TABLE av4(x);
+ SELECT rootpage FROM sqlite_master ORDER BY rootpage;
+ }
+} {3 4 5 6}
+do_test autovacuum-2.2.8 {
+ file_pages
+} {18}
+do_test autovacuum-2.2.9 {
+ execsql {
+ select * from av1
+ }
+} $av1_data
+
+do_test autovacuum-2.3.1 {
+ execsql {
+ INSERT INTO av2 SELECT 'av1' || x FROM av1;
+ INSERT INTO av3 SELECT 'av2' || x FROM av1;
+ INSERT INTO av4 SELECT 'av3' || x FROM av1;
+ }
+ set ::av2_data [execsql {select x from av2}]
+ set ::av3_data [execsql {select x from av3}]
+ set ::av4_data [execsql {select x from av4}]
+ file_pages
+} {54}
+do_test autovacuum-2.3.2 {
+ execsql {
+ DROP TABLE av2;
+ SELECT rootpage FROM sqlite_master ORDER BY rootpage;
+ }
+} {3 4 5}
+do_test autovacuum-2.3.3 {
+ file_pages
+} {41}
+do_test autovacuum-2.3.4 {
+ execsql {
+ SELECT x FROM av3;
+ }
+} $::av3_data
+do_test autovacuum-2.3.5 {
+ execsql {
+ SELECT x FROM av4;
+ }
+} $::av4_data
+
+# Drop all the tables in the file. This puts all pages except the first 2
+# (the sqlite_master root-page and the first pointer map page) on the
+# free-list.
+do_test autovacuum-2.4.1 {
+ execsql {
+ DROP TABLE av1;
+ DROP TABLE av3;
+ BEGIN;
+ DROP TABLE av4;
+ }
+ file_pages
+} {15}
+do_test autovacuum-2.4.2 {
+ for {set i 3} {$i<=10} {incr i} {
+ execsql "CREATE TABLE av$i (x)"
+ }
+ file_pages
+} {15}
+do_test autovacuum-2.4.3 {
+ execsql {
+ SELECT rootpage FROM sqlite_master ORDER by rootpage
+ }
+} {3 4 5 6 7 8 9 10}
+
+# Right now there are 5 free pages in the database. Consume and then free
+# a 520 pages. Then create 520 tables. This ensures that at least some of the
+# desired root-pages reside on the second free-list trunk page, and that the
+# trunk itself is required at some point.
+do_test autovacuum-2.4.4 {
+ execsql "
+ INSERT INTO av3 VALUES ('[make_str abcde [expr 1020*520 + 500]]');
+ DELETE FROM av3;
+ "
+} {}
+set root_page_list [list]
+set pending_byte_page [expr ($::sqlite_pending_byte / 1024) + 1]
+for {set i 3} {$i<=532} {incr i} {
+ # 207 and 412 are pointer-map pages.
+ if { $i!=207 && $i!=412 && $i != $pending_byte_page} {
+ lappend root_page_list $i
+ }
+}
+if {$i >= $pending_byte_page} {
+ lappend root_page_list $i
+}
+do_test autovacuum-2.4.5 {
+ for {set i 11} {$i<=530} {incr i} {
+ execsql "CREATE TABLE av$i (x)"
+ }
+ execsql {
+ SELECT rootpage FROM sqlite_master ORDER by rootpage
+ }
+} $root_page_list
+
+# Just for fun, delete all those tables and see if the database is 1 page.
+do_test autovacuum-2.4.6 {
+ execsql COMMIT;
+ file_pages
+} [expr 561 + (($i >= $pending_byte_page)?1:0)]
+integrity_check autovacuum-2.4.6
+do_test autovacuum-2.4.7 {
+ execsql BEGIN
+ for {set i 3} {$i<=530} {incr i} {
+ execsql "DROP TABLE av$i"
+ }
+ execsql COMMIT
+ file_pages
+} 1
+
+# Create some tables with indices to drop.
+do_test autovacuum-2.5.1 {
+ execsql {
+ CREATE TABLE av1(a PRIMARY KEY, b, c);
+ INSERT INTO av1 VALUES('av1 a', 'av1 b', 'av1 c');
+
+ CREATE TABLE av2(a PRIMARY KEY, b, c);
+ CREATE INDEX av2_i1 ON av2(b);
+ CREATE INDEX av2_i2 ON av2(c);
+ INSERT INTO av2 VALUES('av2 a', 'av2 b', 'av2 c');
+
+ CREATE TABLE av3(a PRIMARY KEY, b, c);
+ CREATE INDEX av3_i1 ON av3(b);
+ INSERT INTO av3 VALUES('av3 a', 'av3 b', 'av3 c');
+
+ CREATE TABLE av4(a, b, c);
+ CREATE INDEX av4_i1 ON av4(a);
+ CREATE INDEX av4_i2 ON av4(b);
+ CREATE INDEX av4_i3 ON av4(c);
+ CREATE INDEX av4_i4 ON av4(a, b, c);
+ INSERT INTO av4 VALUES('av4 a', 'av4 b', 'av4 c');
+ }
+} {}
+
+do_test autovacuum-2.5.2 {
+ execsql {
+ SELECT name, rootpage FROM sqlite_master;
+ }
+} [list av1 3 sqlite_autoindex_av1_1 4 \
+ av2 5 sqlite_autoindex_av2_1 6 av2_i1 7 av2_i2 8 \
+ av3 9 sqlite_autoindex_av3_1 10 av3_i1 11 \
+ av4 12 av4_i1 13 av4_i2 14 av4_i3 15 av4_i4 16 \
+]
+
+# The following 4 tests are SELECT queries that use the indices created.
+# If the root-pages in the internal schema are not updated correctly when
+# a table or indice is moved, these queries will fail. They are repeated
+# after each table is dropped (i.e. as test cases 2.5.*.[1..4]).
+do_test autovacuum-2.5.2.1 {
+ execsql {
+ SELECT * FROM av1 WHERE a = 'av1 a';
+ }
+} {{av1 a} {av1 b} {av1 c}}
+do_test autovacuum-2.5.2.2 {
+ execsql {
+ SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'
+ }
+} {{av2 a} {av2 b} {av2 c}}
+do_test autovacuum-2.5.2.3 {
+ execsql {
+ SELECT * FROM av3 WHERE a = 'av3 a' AND b = 'av3 b';
+ }
+} {{av3 a} {av3 b} {av3 c}}
+do_test autovacuum-2.5.2.4 {
+ execsql {
+ SELECT * FROM av4 WHERE a = 'av4 a' AND b = 'av4 b' AND c = 'av4 c';
+ }
+} {{av4 a} {av4 b} {av4 c}}
+
+# Drop table av3. Indices av4_i2, av4_i3 and av4_i4 are moved to fill the two
+# root pages vacated. The operation proceeds as:
+# Step 1: Delete av3_i1 (root-page 11). Move root-page of av4_i4 to page 11.
+# Step 2: Delete av3 (root-page 10). Move root-page of av4_i3 to page 10.
+# Step 3: Delete sqlite_autoindex_av1_3 (root-page 9). Move av4_i2 to page 9.
+do_test autovacuum-2.5.3 {
+ execsql {
+ DROP TABLE av3;
+ SELECT name, rootpage FROM sqlite_master;
+ }
+} [list av1 3 sqlite_autoindex_av1_1 4 \
+ av2 5 sqlite_autoindex_av2_1 6 av2_i1 7 av2_i2 8 \
+ av4 12 av4_i1 13 av4_i2 9 av4_i3 10 av4_i4 11 \
+]
+do_test autovacuum-2.5.3.1 {
+ execsql {
+ SELECT * FROM av1 WHERE a = 'av1 a';
+ }
+} {{av1 a} {av1 b} {av1 c}}
+do_test autovacuum-2.5.3.2 {
+ execsql {
+ SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'
+ }
+} {{av2 a} {av2 b} {av2 c}}
+do_test autovacuum-2.5.3.3 {
+ execsql {
+ SELECT * FROM av4 WHERE a = 'av4 a' AND b = 'av4 b' AND c = 'av4 c';
+ }
+} {{av4 a} {av4 b} {av4 c}}
+
+# Drop table av1:
+# Step 1: Delete av1 (root page 4). Root-page of av4_i1 fills the gap.
+# Step 2: Delete sqlite_autoindex_av1_1 (root page 3). Move av4 to the gap.
+do_test autovacuum-2.5.4 {
+ execsql {
+ DROP TABLE av1;
+ SELECT name, rootpage FROM sqlite_master;
+ }
+} [list av2 5 sqlite_autoindex_av2_1 6 av2_i1 7 av2_i2 8 \
+ av4 3 av4_i1 4 av4_i2 9 av4_i3 10 av4_i4 11 \
+]
+do_test autovacuum-2.5.4.2 {
+ execsql {
+ SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'
+ }
+} {{av2 a} {av2 b} {av2 c}}
+do_test autovacuum-2.5.4.4 {
+ execsql {
+ SELECT * FROM av4 WHERE a = 'av4 a' AND b = 'av4 b' AND c = 'av4 c';
+ }
+} {{av4 a} {av4 b} {av4 c}}
+
+# Drop table av4:
+# Step 1: Delete av4_i4.
+# Step 2: Delete av4_i3.
+# Step 3: Delete av4_i2.
+# Step 4: Delete av4_i1. av2_i2 replaces it.
+# Step 5: Delete av4. av2_i1 replaces it.
+do_test autovacuum-2.5.5 {
+ execsql {
+ DROP TABLE av4;
+ SELECT name, rootpage FROM sqlite_master;
+ }
+} [list av2 5 sqlite_autoindex_av2_1 6 av2_i1 3 av2_i2 4]
+do_test autovacuum-2.5.5.2 {
+ execsql {
+ SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'
+ }
+} {{av2 a} {av2 b} {av2 c}}
+
+#--------------------------------------------------------------------------
+# Test cases autovacuum-3.* test the operation of the "PRAGMA auto_vacuum"
+# command.
+#
+do_test autovacuum-3.1 {
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+} {1}
+do_test autovacuum-3.2 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+} {1}
+do_test autovacuum-3.3 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA auto_vacuum;
+ }
+} {1}
+
+do_test autovacuum-3.4 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+} $AUTOVACUUM
+do_test autovacuum-3.5 {
+ execsql {
+ CREATE TABLE av1(x);
+ PRAGMA auto_vacuum;
+ }
+} $AUTOVACUUM
+do_test autovacuum-3.6 {
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA auto_vacuum;
+ }
+} [expr $AUTOVACUUM ? 1 : 0]
+do_test autovacuum-3.7 {
+ execsql {
+ DROP TABLE av1;
+ }
+ file_pages
+} [expr $AUTOVACUUM?1:2]
+
+
+#-----------------------------------------------------------------------
+# Test that if a statement transaction around a CREATE INDEX statement is
+# rolled back no corruption occurs.
+#
+do_test autovacuum-4.0 {
+ # The last round of tests may have left the db in non-autovacuum mode.
+ # Reset everything just in case.
+ #
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA auto_vacuum;
+ }
+} {1}
+do_test autovacuum-4.1 {
+ execsql {
+ CREATE TABLE av1(a, b);
+ BEGIN;
+ }
+ for {set i 0} {$i<100} {incr i} {
+ execsql "INSERT INTO av1 VALUES($i, '[string repeat X 200]');"
+ }
+ execsql "INSERT INTO av1 VALUES(99, '[string repeat X 200]');"
+ execsql {
+ SELECT sum(a) FROM av1;
+ }
+} {5049}
+do_test autovacuum-4.2 {
+ catchsql {
+ CREATE UNIQUE INDEX av1_i ON av1(a);
+ }
+} {1 {indexed columns are not unique}}
+do_test autovacuum-4.3 {
+ execsql {
+ SELECT sum(a) FROM av1;
+ }
+} {5049}
+do_test autovacuum-4.4 {
+ execsql {
+ COMMIT;
+ }
+} {}
+
+ifcapable integrityck {
+
+# Ticket #1727
+do_test autovacuum-5.1 {
+ db close
+ sqlite3 db :memory:
+ db eval {
+ PRAGMA auto_vacuum=1;
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(a);
+ DROP TABLE t1;
+ PRAGMA integrity_check;
+ }
+} ok
+
+}
+
+# Ticket #1728.
+#
+# In autovacuum mode, when tables or indices are deleted, the rootpage
+# values in the symbol table have to be updated. There was a bug in this
+# logic so that if an index/table was moved twice, the second move might
+# not occur. This would leave the internal symbol table in an inconsistent
+# state causing subsequent statements to fail.
+#
+# The problem is difficult to reproduce. The sequence of statements in
+# the following test are carefully designed make it occur and thus to
+# verify that this very obscure bug has been resolved.
+#
+ifcapable integrityck&&memorydb {
+
+do_test autovacuum-6.1 {
+ db close
+ sqlite3 db :memory:
+ db eval {
+ PRAGMA auto_vacuum=1;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ CREATE TABLE t2(a);
+ CREATE INDEX i2 ON t2(a);
+ CREATE TABLE t3(a);
+ CREATE INDEX i3 ON t2(a);
+ CREATE INDEX x ON t1(b);
+ DROP TABLE t3;
+ PRAGMA integrity_check;
+ DROP TABLE t2;
+ PRAGMA integrity_check;
+ DROP TABLE t1;
+ PRAGMA integrity_check;
+ }
+} {ok ok ok}
+
+}
+
+#---------------------------------------------------------------------
+# Test cases autovacuum-7.X test the case where a page must be moved
+# and the destination location collides with at least one other
+# entry in the page hash-table (internal to the pager.c module.
+#
+do_test autovacuum-7.1 {
+ db close
+ forcedelete test.db
+ forcedelete test.db-journal
+ sqlite3 db test.db
+
+ execsql {
+ PRAGMA auto_vacuum=1;
+ CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
+ INSERT INTO t1 VALUES(randstr(400,400),randstr(400,400));
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 4
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 8
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 16
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 32
+ }
+
+ expr {[file size test.db] / 1024}
+} {73}
+
+do_test autovacuum-7.2 {
+ execsql {
+ CREATE TABLE t2(a, b, PRIMARY KEY(a, b));
+ INSERT INTO t2 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2
+ CREATE TABLE t3(a, b, PRIMARY KEY(a, b));
+ INSERT INTO t3 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2
+ CREATE TABLE t4(a, b, PRIMARY KEY(a, b));
+ INSERT INTO t4 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2
+ CREATE TABLE t5(a, b, PRIMARY KEY(a, b));
+ INSERT INTO t5 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2
+ }
+ expr {[file size test.db] / 1024}
+} {354}
+
+do_test autovacuum-7.3 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ BEGIN;
+ DELETE FROM t4;
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+ expr {[file size test.db] / 1024}
+} {286}
+
+#------------------------------------------------------------------------
+# Additional tests.
+#
+# Try to determine the autovacuum setting for a database that is locked.
+#
+do_test autovacuum-8.1 {
+ db close
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ db eval {PRAGMA auto_vacuum}
+} {1}
+if {[permutation] == ""} {
+ do_test autovacuum-8.2 {
+ db eval {BEGIN EXCLUSIVE}
+ catchsql {PRAGMA auto_vacuum} db2
+ } {1 {database is locked}}
+ catch {db2 close}
+ catch {db eval {COMMIT}}
+}
+
+do_test autovacuum-9.1 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ DROP TABLE t3;
+ DROP TABLE t4;
+ DROP TABLE t5;
+ PRAGMA page_count;
+ }
+} {1}
+do_test autovacuum-9.2 {
+ file size test.db
+} 1024
+do_test autovacuum-9.3 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(NULL, randstr(50,50));
+ }
+ for {set ii 0} {$ii < 10} {incr ii} {
+ db eval { INSERT INTO t1 SELECT NULL, randstr(50,50) FROM t1 }
+ }
+ file size test.db
+} $::sqlite_pending_byte
+do_test autovacuum-9.4 {
+ execsql { INSERT INTO t1 SELECT NULL, randstr(50,50) FROM t1 }
+} {}
+do_test autovacuum-9.5 {
+ execsql { DELETE FROM t1 WHERE rowid > (SELECT max(a)/2 FROM t1) }
+ file size test.db
+} $::sqlite_pending_byte
+
+
+finish_test
diff --git a/test/autovacuum_ioerr2.test b/test/autovacuum_ioerr2.test
new file mode 100644
index 0000000..891d00e
--- /dev/null
+++ b/test/autovacuum_ioerr2.test
@@ -0,0 +1,132 @@
+# 2001 October 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing for correct handling of I/O errors
+# such as writes failing because the disk is full.
+#
+# The tests in this file use special facilities that are only
+# available in the SQLite test fixture.
+#
+# $Id: autovacuum_ioerr2.test,v 1.7 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build of the library does not support auto-vacuum, omit this
+# whole file.
+ifcapable {!autovacuum} {
+ finish_test
+ return
+}
+
+do_ioerr_test autovacuum-ioerr2-1 -sqlprep {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE abc(a);
+ INSERT INTO abc VALUES(randstr(1500,1500));
+} -sqlbody {
+ CREATE TABLE abc2(a);
+ BEGIN;
+ DELETE FROM abc;
+ INSERT INTO abc VALUES(randstr(1500,1500));
+ CREATE TABLE abc3(a);
+ COMMIT;
+}
+
+do_ioerr_test autovacuum-ioerr2-2 -tclprep {
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE abc(a);
+ INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 4 is overflow
+ INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 5 is overflow
+ }
+ for {set i 0} {$i<150} {incr i} {
+ execsql {
+ INSERT INTO abc VALUES(randstr(100,100));
+ }
+ }
+ execsql COMMIT
+} -sqlbody {
+ BEGIN;
+ DELETE FROM abc WHERE length(a)>100;
+ UPDATE abc SET a = randstr(90,90);
+ CREATE TABLE abc3(a);
+ COMMIT;
+}
+
+do_ioerr_test autovacuum-ioerr2-3 -sqlprep {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE abc(a);
+ CREATE TABLE abc2(b);
+} -sqlbody {
+ BEGIN;
+ INSERT INTO abc2 VALUES(10);
+ DROP TABLE abc;
+ COMMIT;
+ DROP TABLE abc2;
+}
+
+forcedelete backup.db
+ifcapable subquery {
+ do_ioerr_test autovacuum-ioerr2-4 -tclprep {
+ if {![file exists backup.db]} {
+ sqlite3 dbb backup.db
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ BEGIN;
+ CREATE TABLE abc(a);
+ INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 4 is overflow
+ INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 5 is overflow
+ } dbb
+ for {set i 0} {$i<2500} {incr i} {
+ execsql {
+ INSERT INTO abc VALUES(randstr(100,100));
+ } dbb
+ }
+ execsql {
+ COMMIT;
+ PRAGMA cache_size = 10;
+ } dbb
+ dbb close
+ }
+ db close
+ forcedelete test.db
+ forcedelete test.db-journal
+ forcecopy backup.db test.db
+ set ::DB [sqlite3 db test.db]
+ execsql {
+ PRAGMA cache_size = 10;
+ }
+ } -sqlbody {
+ BEGIN;
+ DELETE FROM abc WHERE oid < 3;
+ UPDATE abc SET a = randstr(100,100) WHERE oid > 2300;
+ UPDATE abc SET a = randstr(1100,1100) WHERE oid =
+ (select max(oid) from abc);
+ COMMIT;
+ }
+}
+
+do_ioerr_test autovacuum-ioerr2-1 -sqlprep {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE abc(a);
+ INSERT INTO abc VALUES(randstr(1500,1500));
+} -sqlbody {
+ CREATE TABLE abc2(a);
+ BEGIN;
+ DELETE FROM abc;
+ INSERT INTO abc VALUES(randstr(1500,1500));
+ CREATE TABLE abc3(a);
+ COMMIT;
+}
+
+finish_test
diff --git a/test/avtrans.test b/test/avtrans.test
new file mode 100644
index 0000000..17a2860
--- /dev/null
+++ b/test/avtrans.test
@@ -0,0 +1,926 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. This
+# file is a copy of "trans.test" modified to run under autovacuum mode.
+# the point is to stress the autovacuum logic and try to get it to fail.
+#
+# $Id: avtrans.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+# Create several tables to work with.
+#
+do_test avtrans-1.0 {
+ execsql { PRAGMA auto_vacuum=ON }
+ wal_set_journal_mode
+ execsql {
+ CREATE TABLE one(a int PRIMARY KEY, b text);
+ INSERT INTO one VALUES(1,'one');
+ INSERT INTO one VALUES(2,'two');
+ INSERT INTO one VALUES(3,'three');
+ SELECT b FROM one ORDER BY a;
+ }
+} {one two three}
+do_test avtrans-1.1 {
+ execsql {
+ CREATE TABLE two(a int PRIMARY KEY, b text);
+ INSERT INTO two VALUES(1,'I');
+ INSERT INTO two VALUES(5,'V');
+ INSERT INTO two VALUES(10,'X');
+ SELECT b FROM two ORDER BY a;
+ }
+} {I V X}
+do_test avtrans-1.9 {
+ sqlite3 altdb test.db
+ execsql {SELECT b FROM one ORDER BY a} altdb
+} {one two three}
+do_test avtrans-1.10 {
+ execsql {SELECT b FROM two ORDER BY a} altdb
+} {I V X}
+integrity_check avtrans-1.11
+wal_check_journal_mode avtrans-1.12
+
+# Basic transactions
+#
+do_test avtrans-2.1 {
+ set v [catch {execsql {BEGIN}} msg]
+ lappend v $msg
+} {0 {}}
+do_test avtrans-2.2 {
+ set v [catch {execsql {END}} msg]
+ lappend v $msg
+} {0 {}}
+do_test avtrans-2.3 {
+ set v [catch {execsql {BEGIN TRANSACTION}} msg]
+ lappend v $msg
+} {0 {}}
+do_test avtrans-2.4 {
+ set v [catch {execsql {COMMIT TRANSACTION}} msg]
+ lappend v $msg
+} {0 {}}
+do_test avtrans-2.5 {
+ set v [catch {execsql {BEGIN TRANSACTION 'foo'}} msg]
+ lappend v $msg
+} {0 {}}
+do_test avtrans-2.6 {
+ set v [catch {execsql {ROLLBACK TRANSACTION 'foo'}} msg]
+ lappend v $msg
+} {0 {}}
+do_test avtrans-2.10 {
+ execsql {
+ BEGIN;
+ SELECT a FROM one ORDER BY a;
+ SELECT a FROM two ORDER BY a;
+ END;
+ }
+} {1 2 3 1 5 10}
+integrity_check avtrans-2.11
+wal_check_journal_mode avtrans-2.12
+
+# Check the locking behavior
+#
+sqlite3_soft_heap_limit 0
+do_test avtrans-3.1 {
+ execsql {
+ BEGIN;
+ UPDATE one SET a = 0 WHERE 0;
+ SELECT a FROM one ORDER BY a;
+ }
+} {1 2 3}
+do_test avtrans-3.2 {
+ catchsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb
+} {0 {1 5 10}}
+do_test avtrans-3.3 {
+ catchsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb
+} {0 {1 2 3}}
+do_test avtrans-3.4 {
+ catchsql {
+ INSERT INTO one VALUES(4,'four');
+ }
+} {0 {}}
+do_test avtrans-3.5 {
+ catchsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb
+} {0 {1 5 10}}
+do_test avtrans-3.6 {
+ catchsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb
+} {0 {1 2 3}}
+do_test avtrans-3.7 {
+ catchsql {
+ INSERT INTO two VALUES(4,'IV');
+ }
+} {0 {}}
+do_test avtrans-3.8 {
+ catchsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb
+} {0 {1 5 10}}
+do_test avtrans-3.9 {
+ catchsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb
+} {0 {1 2 3}}
+do_test avtrans-3.10 {
+ execsql {END TRANSACTION}
+} {}
+do_test avtrans-3.11 {
+ set v [catch {execsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb} msg]
+ lappend v $msg
+} {0 {1 4 5 10}}
+do_test avtrans-3.12 {
+ set v [catch {execsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb} msg]
+ lappend v $msg
+} {0 {1 2 3 4}}
+do_test avtrans-3.13 {
+ set v [catch {execsql {
+ SELECT a FROM two ORDER BY a;
+ } db} msg]
+ lappend v $msg
+} {0 {1 4 5 10}}
+do_test avtrans-3.14 {
+ set v [catch {execsql {
+ SELECT a FROM one ORDER BY a;
+ } db} msg]
+ lappend v $msg
+} {0 {1 2 3 4}}
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+integrity_check avtrans-3.15
+
+do_test avtrans-4.1 {
+ set v [catch {execsql {
+ COMMIT;
+ } db} msg]
+ lappend v $msg
+} {1 {cannot commit - no transaction is active}}
+do_test avtrans-4.2 {
+ set v [catch {execsql {
+ ROLLBACK;
+ } db} msg]
+ lappend v $msg
+} {1 {cannot rollback - no transaction is active}}
+do_test avtrans-4.3 {
+ catchsql {
+ BEGIN TRANSACTION;
+ UPDATE two SET a = 0 WHERE 0;
+ SELECT a FROM two ORDER BY a;
+ } db
+} {0 {1 4 5 10}}
+do_test avtrans-4.4 {
+ catchsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb
+} {0 {1 4 5 10}}
+do_test avtrans-4.5 {
+ catchsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb
+} {0 {1 2 3 4}}
+do_test avtrans-4.6 {
+ catchsql {
+ BEGIN TRANSACTION;
+ SELECT a FROM one ORDER BY a;
+ } db
+} {1 {cannot start a transaction within a transaction}}
+do_test avtrans-4.7 {
+ catchsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb
+} {0 {1 4 5 10}}
+do_test avtrans-4.8 {
+ catchsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb
+} {0 {1 2 3 4}}
+do_test avtrans-4.9 {
+ set v [catch {execsql {
+ END TRANSACTION;
+ SELECT a FROM two ORDER BY a;
+ } db} msg]
+ lappend v $msg
+} {0 {1 4 5 10}}
+do_test avtrans-4.10 {
+ set v [catch {execsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb} msg]
+ lappend v $msg
+} {0 {1 4 5 10}}
+do_test avtrans-4.11 {
+ set v [catch {execsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb} msg]
+ lappend v $msg
+} {0 {1 2 3 4}}
+integrity_check avtrans-4.12
+do_test avtrans-4.98 {
+ altdb close
+ execsql {
+ DROP TABLE one;
+ DROP TABLE two;
+ }
+} {}
+integrity_check avtrans-4.99
+
+# Check out the commit/rollback behavior of the database
+#
+do_test avtrans-5.1 {
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
+} {}
+do_test avtrans-5.2 {
+ execsql {BEGIN TRANSACTION}
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
+} {}
+do_test avtrans-5.3 {
+ execsql {CREATE TABLE one(a text, b int)}
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
+} {one}
+do_test avtrans-5.4 {
+ execsql {SELECT a,b FROM one ORDER BY b}
+} {}
+do_test avtrans-5.5 {
+ execsql {INSERT INTO one(a,b) VALUES('hello', 1)}
+ execsql {SELECT a,b FROM one ORDER BY b}
+} {hello 1}
+do_test avtrans-5.6 {
+ execsql {ROLLBACK}
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
+} {}
+do_test avtrans-5.7 {
+ set v [catch {
+ execsql {SELECT a,b FROM one ORDER BY b}
+ } msg]
+ lappend v $msg
+} {1 {no such table: one}}
+
+# Test commits and rollbacks of table CREATE TABLEs, CREATE INDEXs
+# DROP TABLEs and DROP INDEXs
+#
+do_test avtrans-5.8 {
+ execsql {
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name
+ }
+} {}
+do_test avtrans-5.9 {
+ execsql {
+ BEGIN TRANSACTION;
+ CREATE TABLE t1(a int, b int, c int);
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {t1}
+do_test avtrans-5.10 {
+ execsql {
+ CREATE INDEX i1 ON t1(a);
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i1 t1}
+do_test avtrans-5.11 {
+ execsql {
+ COMMIT;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i1 t1}
+do_test avtrans-5.12 {
+ execsql {
+ BEGIN TRANSACTION;
+ CREATE TABLE t2(a int, b int, c int);
+ CREATE INDEX i2a ON t2(a);
+ CREATE INDEX i2b ON t2(b);
+ DROP TABLE t1;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i2a i2b t2}
+do_test avtrans-5.13 {
+ execsql {
+ ROLLBACK;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i1 t1}
+do_test avtrans-5.14 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {t1}
+do_test avtrans-5.15 {
+ execsql {
+ ROLLBACK;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i1 t1}
+do_test avtrans-5.16 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ CREATE TABLE t2(x int, y int, z int);
+ CREATE INDEX i2x ON t2(x);
+ CREATE INDEX i2y ON t2(y);
+ INSERT INTO t2 VALUES(1,2,3);
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i2x i2y t1 t2}
+do_test avtrans-5.17 {
+ execsql {
+ COMMIT;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i2x i2y t1 t2}
+do_test avtrans-5.18 {
+ execsql {
+ SELECT * FROM t2;
+ }
+} {1 2 3}
+do_test avtrans-5.19 {
+ execsql {
+ SELECT x FROM t2 WHERE y=2;
+ }
+} {1}
+do_test avtrans-5.20 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ DROP TABLE t2;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {}
+do_test avtrans-5.21 {
+ set r [catch {execsql {
+ SELECT * FROM t2
+ }} msg]
+ lappend r $msg
+} {1 {no such table: t2}}
+do_test avtrans-5.22 {
+ execsql {
+ ROLLBACK;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i2x i2y t1 t2}
+do_test avtrans-5.23 {
+ execsql {
+ SELECT * FROM t2;
+ }
+} {1 2 3}
+integrity_check avtrans-5.23
+
+
+# Try to DROP and CREATE tables and indices with the same name
+# within a transaction. Make sure ROLLBACK works.
+#
+do_test avtrans-6.1 {
+ execsql2 {
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(p,q,r);
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {a 1 b 2 c 3}
+do_test avtrans-6.2 {
+ execsql2 {
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(p,q,r);
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {}
+do_test avtrans-6.3 {
+ execsql2 {
+ INSERT INTO t1 VALUES(1,2,3);
+ SELECT * FROM t1;
+ }
+} {p 1 q 2 r 3}
+do_test avtrans-6.4 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(4,5,6);
+ SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+} {a 4 b 5 c 6}
+do_test avtrans-6.5 {
+ execsql2 {
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {p 1 q 2 r 3}
+do_test avtrans-6.6 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(4,5,6);
+ SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+} {a 4 b 5 c 6}
+do_test avtrans-6.7 {
+ catchsql {
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {1 {no such table: t1}}
+
+# Repeat on a table with an automatically generated index.
+#
+do_test avtrans-6.10 {
+ execsql2 {
+ CREATE TABLE t1(a unique,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(p unique,q,r);
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {a 1 b 2 c 3}
+do_test avtrans-6.11 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(p unique,q,r);
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {}
+do_test avtrans-6.12 {
+ execsql2 {
+ INSERT INTO t1 VALUES(1,2,3);
+ SELECT * FROM t1;
+ }
+} {p 1 q 2 r 3}
+do_test avtrans-6.13 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a unique,b,c);
+ INSERT INTO t1 VALUES(4,5,6);
+ SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+} {a 4 b 5 c 6}
+do_test avtrans-6.14 {
+ execsql2 {
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {p 1 q 2 r 3}
+do_test avtrans-6.15 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a unique,b,c);
+ INSERT INTO t1 VALUES(4,5,6);
+ SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+} {a 4 b 5 c 6}
+do_test avtrans-6.16 {
+ catchsql {
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {1 {no such table: t1}}
+
+do_test avtrans-6.20 {
+ execsql {
+ CREATE TABLE t1(a integer primary key,b,c);
+ INSERT INTO t1 VALUES(1,-2,-3);
+ INSERT INTO t1 VALUES(4,-5,-6);
+ SELECT * FROM t1;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test avtrans-6.21 {
+ execsql {
+ CREATE INDEX i1 ON t1(b);
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test avtrans-6.22 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ SELECT * FROM t1 WHERE b<1;
+ ROLLBACK;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test avtrans-6.23 {
+ execsql {
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test avtrans-6.24 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ ROLLBACK;
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+
+do_test avtrans-6.25 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ CREATE INDEX i1 ON t1(c);
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test avtrans-6.26 {
+ execsql {
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test avtrans-6.27 {
+ execsql {
+ ROLLBACK;
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test avtrans-6.28 {
+ execsql {
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {1 -2 -3 4 -5 -6}
+
+# The following repeats steps 6.20 through 6.28, but puts a "unique"
+# constraint the first field of the table in order to generate an
+# automatic index.
+#
+do_test avtrans-6.30 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a int unique,b,c);
+ COMMIT;
+ INSERT INTO t1 VALUES(1,-2,-3);
+ INSERT INTO t1 VALUES(4,-5,-6);
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test avtrans-6.31 {
+ execsql {
+ CREATE INDEX i1 ON t1(b);
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test avtrans-6.32 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ SELECT * FROM t1 WHERE b<1;
+ ROLLBACK;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test avtrans-6.33 {
+ execsql {
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test avtrans-6.34 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ ROLLBACK;
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+
+do_test avtrans-6.35 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ CREATE INDEX i1 ON t1(c);
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test avtrans-6.36 {
+ execsql {
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test avtrans-6.37 {
+ execsql {
+ DROP INDEX i1;
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test avtrans-6.38 {
+ execsql {
+ ROLLBACK;
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test avtrans-6.39 {
+ execsql {
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {1 -2 -3 4 -5 -6}
+integrity_check avtrans-6.40
+
+ifcapable !floatingpoint {
+ finish_test
+ return
+}
+
+# Test to make sure rollback restores the database back to its original
+# state.
+#
+do_test avtrans-7.1 {
+ execsql {BEGIN}
+ for {set i 0} {$i<1000} {incr i} {
+ set r1 [expr {rand()}]
+ set r2 [expr {rand()}]
+ set r3 [expr {rand()}]
+ execsql "INSERT INTO t2 VALUES($r1,$r2,$r3)"
+ }
+ execsql {COMMIT}
+ set ::checksum [execsql {SELECT md5sum(x,y,z) FROM t2}]
+ set ::checksum2 [
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+ ]
+ execsql {SELECT count(*) FROM t2}
+} {1001}
+do_test avtrans-7.2 {
+ execsql {SELECT md5sum(x,y,z) FROM t2}
+} $checksum
+do_test avtrans-7.2.1 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+do_test avtrans-7.3 {
+ execsql {
+ BEGIN;
+ DELETE FROM t2;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+} $checksum
+do_test avtrans-7.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO t2 SELECT * FROM t2;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+} $checksum
+do_test avtrans-7.5 {
+ execsql {
+ BEGIN;
+ DELETE FROM t2;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+} $checksum
+do_test avtrans-7.6 {
+ execsql {
+ BEGIN;
+ INSERT INTO t2 SELECT * FROM t2;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+} $checksum
+do_test avtrans-7.7 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t3 AS SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t3;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+} $checksum
+do_test avtrans-7.8 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+ifcapable tempdb {
+ do_test avtrans-7.9 {
+ execsql {
+ BEGIN;
+ CREATE TEMP TABLE t3 AS SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t3;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+ } $checksum
+}
+do_test avtrans-7.10 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+ifcapable tempdb {
+ do_test avtrans-7.11 {
+ execsql {
+ BEGIN;
+ CREATE TEMP TABLE t3 AS SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t3;
+ DROP INDEX i2x;
+ DROP INDEX i2y;
+ CREATE INDEX i3a ON t3(x);
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+ } $checksum
+}
+do_test avtrans-7.12 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+ifcapable tempdb {
+ do_test avtrans-7.13 {
+ execsql {
+ BEGIN;
+ DROP TABLE t2;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+ } $checksum
+}
+do_test avtrans-7.14 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+integrity_check avtrans-7.15
+
+# Arrange for another process to begin modifying the database but abort
+# and die in the middle of the modification. Then have this process read
+# the database. This process should detect the journal file and roll it
+# back. Verify that this happens correctly.
+#
+set fd [open test.tcl w]
+puts $fd {
+ sqlite3 db test.db
+ db eval {
+ PRAGMA default_cache_size=20;
+ BEGIN;
+ CREATE TABLE t3 AS SELECT * FROM t2;
+ DELETE FROM t2;
+ }
+ sqlite_abort
+}
+close $fd
+do_test avtrans-8.1 {
+ catch {exec [info nameofexec] test.tcl}
+ execsql {SELECT md5sum(x,y,z) FROM t2}
+} $checksum
+do_test avtrans-8.2 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+integrity_check avtrans-8.3
+
+# In the following sequence of tests, compute the MD5 sum of the content
+# of a table, make lots of modifications to that table, then do a rollback.
+# Verify that after the rollback, the MD5 checksum is unchanged.
+#
+do_test avtrans-9.1 {
+ execsql {
+ PRAGMA default_cache_size=10;
+ }
+ db close
+ sqlite3 db test.db
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(x TEXT);
+ INSERT INTO t3 VALUES(randstr(10,400));
+ INSERT INTO t3 VALUES(randstr(10,400));
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ COMMIT;
+ SELECT count(*) FROM t3;
+ }
+} {1024}
+
+# The following procedure computes a "signature" for table "t3". If
+# T3 changes in any way, the signature should change.
+#
+# This is used to test ROLLBACK. We gather a signature for t3, then
+# make lots of changes to t3, then rollback and take another signature.
+# The two signatures should be the same.
+#
+proc signature {} {
+ return [db eval {SELECT count(*), md5sum(x) FROM t3}]
+}
+
+# Repeat the following group of tests 20 times for quick testing and
+# 40 times for full testing. Each iteration of the test makes table
+# t3 a little larger, and thus takes a little longer, so doing 40 tests
+# is more than 2.0 times slower than doing 20 tests. Considerably more.
+#
+if {[info exists G(isquick)]} {
+ set limit 20
+} else {
+ set limit 40
+}
+
+# Do rollbacks. Make sure the signature does not change.
+#
+for {set i 2} {$i<=$limit} {incr i} {
+ set ::sig [signature]
+ set cnt [lindex $::sig 0]
+ if {$i%2==0} {
+ execsql {PRAGMA fullfsync=ON}
+ } else {
+ execsql {PRAGMA fullfsync=OFF}
+ }
+ set sqlite_sync_count 0
+ set sqlite_fullsync_count 0
+ do_test avtrans-9.$i.1-$cnt {
+ execsql {
+ BEGIN;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ ROLLBACK;
+ }
+ signature
+ } $sig
+ do_test avtrans-9.$i.2-$cnt {
+ execsql {
+ BEGIN;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ ROLLBACK;
+ }
+ signature
+ } $sig
+ if {$i<$limit} {
+ do_test avtrans-9.$i.3-$cnt {
+ execsql {
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE random()%10==0;
+ }
+ } {}
+ if {$tcl_platform(platform)=="unix"} {
+ do_test avtrans-9.$i.4-$cnt {
+ expr {$sqlite_sync_count>0}
+ } 1
+ ifcapable pager_pragmas {
+ do_test avtrans-9.$i.5-$cnt {
+ expr {$sqlite_fullsync_count>0}
+ } [expr {$i%2==0}]
+ } else {
+ do_test avtrans-9.$i.5-$cnt {
+ expr {$sqlite_fullsync_count==0}
+ } {1}
+ }
+ }
+ wal_check_journal_mode avtrans-9.$i-6.$cnt
+ }
+ set ::pager_old_format 0
+}
+integrity_check avtrans-10.1
+wal_check_journal_mode avtrans-10.2
+
+finish_test
diff --git a/test/backcompat.test b/test/backcompat.test
new file mode 100644
index 0000000..e8e2f61
--- /dev/null
+++ b/test/backcompat.test
@@ -0,0 +1,445 @@
+# 2010 August 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that the current version of SQLite
+# is capable of reading and writing databases created by previous
+# versions, and vice-versa.
+#
+# To use this test, old versions of the testfixture process should be
+# copied into the working directory alongside the new version. The old
+# versions should be named "testfixtureXXX" (or testfixtureXXX.exe on
+# windows), where XXX can be any string.
+#
+# This test file uses the tcl code for controlling a second testfixture
+# process located in lock_common.tcl. See the commments in lock_common.tcl
+# for documentation of the available commands.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+db close
+
+# Search for binaries to test against. Any executable files that match
+# our naming convention are assumed to be testfixture binaries to test
+# against.
+#
+set binaries [list]
+set pattern "[file tail [info nameofexec]]?*"
+if {$tcl_platform(platform)=="windows"} {
+ set pattern [string map {\.exe {}} $pattern]
+}
+foreach file [glob -nocomplain $pattern] {
+ if {[file executable $file] && [file isfile $file]} {lappend binaries $file}
+}
+if {[llength $binaries]==0} {
+ puts "WARNING: No historical binaries to test against."
+ puts "WARNING: No backwards-compatibility tests have been run."
+ finish_test
+ return
+}
+proc get_version {binary} {
+ set chan [launch_testfixture $binary]
+ set v [testfixture $chan { sqlite3 -version }]
+ close $chan
+ set v
+}
+foreach bin $binaries {
+ puts -nonewline "Testing against $bin - "
+ flush stdout
+ puts "version [get_version $bin]"
+}
+
+proc do_backcompat_test {rv bin1 bin2 script} {
+
+ forcedelete test.db
+
+ if {$bin1 != ""} { set ::bc_chan1 [launch_testfixture $bin1] }
+ set ::bc_chan2 [launch_testfixture $bin2]
+
+ if { $rv } {
+ proc code2 {tcl} { uplevel #0 $tcl }
+ if {$bin1 != ""} { proc code2 {tcl} { testfixture $::bc_chan1 $tcl } }
+ proc code1 {tcl} { testfixture $::bc_chan2 $tcl }
+ } else {
+ proc code1 {tcl} { uplevel #0 $tcl }
+ if {$bin1 != ""} { proc code1 {tcl} { testfixture $::bc_chan1 $tcl } }
+ proc code2 {tcl} { testfixture $::bc_chan2 $tcl }
+ }
+
+ proc sql1 sql { code1 [list db eval $sql] }
+ proc sql2 sql { code2 [list db eval $sql] }
+
+ code1 { sqlite3 db test.db }
+ code2 { sqlite3 db test.db }
+
+ uplevel $script
+
+ catch { code1 { db close } }
+ catch { code2 { db close } }
+ catch { close $::bc_chan2 }
+ catch { close $::bc_chan1 }
+}
+
+array set ::incompatible [list]
+proc do_allbackcompat_test {script} {
+
+ foreach bin $::binaries {
+ set nErr [set_test_counter errors]
+ foreach dir {0 1} {
+
+ set bintag [string map {testfixture {}} $bin]
+ set bintag [string map {\.exe {}} $bintag]
+ if {$bintag == ""} {set bintag self}
+ set ::bcname ".$bintag.$dir."
+
+ rename do_test _do_test
+ proc do_test {nm sql res} {
+ set nm [regsub {\.} $nm $::bcname]
+ uplevel [list _do_test $nm $sql $res]
+ }
+
+ do_backcompat_test $dir {} $bin $script
+
+ rename do_test {}
+ rename _do_test do_test
+ }
+ if { $nErr < [set_test_counter errors] } {
+ set ::incompatible([get_version $bin]) 1
+ }
+ }
+}
+
+proc read_file {zFile} {
+ set zData {}
+ if {[file exists $zFile]} {
+ set fd [open $zFile]
+ fconfigure $fd -translation binary -encoding binary
+
+ if {[file size $zFile]<=$::sqlite_pending_byte || $zFile != "test.db"} {
+ set zData [read $fd]
+ } else {
+ set zData [read $fd $::sqlite_pending_byte]
+ append zData [string repeat x 512]
+ seek $fd [expr $::sqlite_pending_byte+512] start
+ append zData [read $fd]
+ }
+
+ close $fd
+ }
+ return $zData
+}
+proc write_file {zFile zData} {
+ set fd [open $zFile w]
+ fconfigure $fd -translation binary -encoding binary
+ puts -nonewline $fd $zData
+ close $fd
+}
+proc read_file_system {} {
+ set ret [list]
+ foreach f {test.db test.db-journal test.db-wal} { lappend ret [read_file $f] }
+ set ret
+}
+proc write_file_system {data} {
+ foreach f {test.db test.db-journal test.db-wal} d $data {
+ if {[string length $d] == 0} {
+ forcedelete $f
+ } else {
+ write_file $f $d
+ }
+ }
+}
+
+#-------------------------------------------------------------------------
+# Actual tests begin here.
+#
+# This first block of tests checks to see that the same database and
+# journal files can be used by old and new versions. WAL and wal-index
+# files are tested separately below.
+#
+do_allbackcompat_test {
+
+ # Test that database files are backwards compatible.
+ #
+ do_test backcompat-1.1.1 { sql1 {
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 VALUES('abc', 'def');
+ } } {}
+ do_test backcompat-1.1.2 { sql2 { SELECT * FROM t1; } } {abc def}
+ do_test backcompat-1.1.3 { sql2 { INSERT INTO t1 VALUES('ghi', 'jkl'); } } {}
+ do_test backcompat-1.1.4 { sql1 { SELECT * FROM t1; } } {abc def ghi jkl}
+ do_test backcompat-1.1.5 { sql1 { PRAGMA integrity_check } } {ok}
+ do_test backcompat-1.1.6 { sql2 { PRAGMA integrity_check } } {ok}
+
+ # Test that one version can roll back a hot-journal file left in the
+ # file-system by the other version.
+ #
+ # Each test case is named "backcompat-1.X...", where X is either 0 or
+ # 1. If it is 0, then the current version creates a journal file that
+ # the old versions try to read. Otherwise, if X is 1, then the old version
+ # creates the journal file and we try to read it with the current version.
+ #
+ do_test backcompat-1.2.1 { sql1 {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(400), randomblob(400));
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
+ COMMIT;
+ } } {}
+ set cksum1 [sql1 {SELECT md5sum(a), md5sum(b) FROM t1}]
+ set cksum2 [sql2 {SELECT md5sum(a), md5sum(b) FROM t1}]
+ do_test backcompat-1.2.2 [list string compare $cksum1 $cksum2] 0
+
+ do_test backcompat-1.2.3 { sql1 {
+ BEGIN;
+ UPDATE t1 SET a = randomblob(500);
+ } } {}
+ set data [read_file_system]
+
+ do_test backcompat-1.2.4 { sql1 { COMMIT } } {}
+
+ set same [expr {[sql2 {SELECT md5sum(a), md5sum(b) FROM t1}] == $cksum2}]
+ do_test backcompat-1.2.5 [list set {} $same] 0
+
+ code1 { db close }
+ code2 { db close }
+ write_file_system $data
+ code1 { sqlite3 db test.db }
+ code2 { sqlite3 db test.db }
+
+ set same [expr {[sql2 {SELECT md5sum(a), md5sum(b) FROM t1}] == $cksum2}]
+ do_test backcompat-1.2.6 [list set {} $same] 1
+
+ do_test backcompat-1.2.7 { sql1 { PRAGMA integrity_check } } {ok}
+ do_test backcompat-1.2.8 { sql2 { PRAGMA integrity_check } } {ok}
+}
+foreach k [lsort [array names ::incompatible]] {
+ puts "ERROR: Detected journal incompatibility with version $k"
+}
+unset ::incompatible
+
+
+#-------------------------------------------------------------------------
+# Test that WAL and wal-index files may be shared between different
+# SQLite versions.
+#
+do_allbackcompat_test {
+ if {[code1 {sqlite3 -version}] >= "3.7.0"
+ && [code2 {sqlite3 -version}] >= "3.7.0"
+ } {
+
+ do_test backcompat-2.1.1 { sql1 {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 VALUES('I', 1);
+ INSERT INTO t1 VALUES('II', 2);
+ INSERT INTO t1 VALUES('III', 3);
+ SELECT * FROM t1;
+ } } {wal I 1 II 2 III 3}
+ do_test backcompat-2.1.2 { sql2 {
+ SELECT * FROM t1;
+ } } {I 1 II 2 III 3}
+
+ set data [read_file_system]
+ code1 {db close}
+ code2 {db close}
+ write_file_system $data
+ code1 {sqlite3 db test.db}
+ code2 {sqlite3 db test.db}
+
+ # The WAL file now in the file-system was created by the [code1]
+ # process. Check that the [code2] process can recover the log.
+ #
+ do_test backcompat-2.1.3 { sql2 {
+ SELECT * FROM t1;
+ } } {I 1 II 2 III 3}
+ do_test backcompat-2.1.4 { sql1 {
+ SELECT * FROM t1;
+ } } {I 1 II 2 III 3}
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test that FTS3 tables may be read/written by different versions of
+# SQLite.
+#
+set contents {
+ CREATE VIRTUAL TABLE t1 USING fts3(a, b);
+}
+foreach {num doc} {
+ one "jk zm jk eczkjblu urvysbnykk sk gnl jk ttvgf hmjf"
+ two "jk bnhc jjrxpjkb mjpavjuhw fibokdry igju jk zm zm xh"
+ three "wxe ogttbykvt uhzq xr iaf zf urvysbnykk aayxpmve oacaxgjoo mjpavjuhw"
+ four "gazrt jk ephknonq myjp uenvbm wuvajhwqz jk zm xnxhf nvfasfh"
+ five "zm aayxpmve csjqxhgj xnxhf xr jk aayxpmve xnxhf zm zm"
+ six "sokcyf zm ogyavjvv jk zm fibokdry zm jk igju igju"
+ seven "vgsld bvgimjik xuprtlyle jk akmikrqyt jk aayxpmve hkfoudzftq ddjj"
+ eight "zm uhzq ovkyevlgv zk uenvbm csjqxhgj jk vgsld pgybs jk"
+ nine "zm agmckuiu zexh fibokdry jk uhzq bu tugflixoex xnxhf sk"
+} {
+ append contents "INSERT INTO t1 VALUES('$num', '$doc');"
+}
+do_allbackcompat_test {
+ if {[code1 {set ::sqlite_options(fts3)}]
+ && [code2 {set ::sqlite_options(fts3)}]
+ } {
+
+ do_test backcompat-3.1 { sql1 $contents } {}
+
+ foreach {n q} {
+ 1 "SELECT * FROM t1 ORDER BY a, b"
+ 2 "SELECT rowid FROM t1 WHERE a MATCH 'five'"
+ 3 "SELECT * FROM t1 WHERE a MATCH 'five'"
+ 4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'"
+ 5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'"
+ } {
+ do_test backcompat-3.2 [list sql1 $q] [sql2 $q]
+ }
+
+ do_test backcompat-3.3 { sql1 {
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ } } {}
+
+ foreach {n q} {
+ 1 "SELECT * FROM t1 ORDER BY a, b"
+ 2 "SELECT rowid FROM t1 WHERE a MATCH 'five'"
+ 3 "SELECT * FROM t1 WHERE a MATCH 'five'"
+ 4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'"
+ 5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'"
+ } {
+ do_test backcompat-3.4 [list sql1 $q] [sql2 $q]
+ }
+
+ set alphabet "a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4"
+ for {set i 0} {$i < 900} {incr i} {
+ set term "[lindex $alphabet [expr $i/30]][lindex $alphabet [expr $i%30]] "
+ sql1 "INSERT INTO t1 VALUES($i, '[string repeat $term 14]')"
+ }
+
+ foreach {n q} {
+ 1 "SELECT * FROM t1 ORDER BY a, b"
+ 2 "SELECT rowid FROM t1 WHERE a MATCH 'five'"
+ 3 "SELECT * FROM t1 WHERE a MATCH 'five'"
+ 4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'"
+ 5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'"
+
+ 6 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'aa'"
+ 7 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH '44'"
+ 8 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'a*'"
+ } {
+ do_test backcompat-3.5 [list sql1 $q] [sql2 $q]
+ }
+
+ do_test backcompat-3.6 {
+ sql1 "SELECT optimize(t1) FROM t1 LIMIT 1"
+ } {{Index optimized}}
+
+ foreach {n q} {
+ 1 "SELECT * FROM t1 ORDER BY a, b"
+ 2 "SELECT rowid FROM t1 WHERE a MATCH 'five'"
+ 3 "SELECT * FROM t1 WHERE a MATCH 'five'"
+ 4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'"
+ 5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'"
+
+ 6 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'aa'"
+ 7 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH '44'"
+ 8 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'a*'"
+ } {
+ do_test backcompat-3.7 [list sql1 $q] [sql2 $q]
+ }
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test that Rtree tables may be read/written by different versions of
+# SQLite.
+#
+set contents {
+ CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2, y1, y2);
+}
+foreach {id x1 x2 y1 y2} {
+ 1 -47.64 43.87 33.86 34.42 2 -21.51 17.32 2.05 31.04
+ 3 -43.67 -38.33 -19.79 3.43 4 32.41 35.16 9.12 19.82
+ 5 33.28 34.87 14.78 28.26 6 49.31 116.59 -9.87 75.09
+ 7 -14.93 34.51 -17.64 64.09 8 -43.05 23.43 -1.19 69.44
+ 9 44.79 133.56 28.09 80.30 10 -2.66 81.47 -41.38 -10.46
+ 11 -42.89 -3.54 15.76 71.63 12 -3.50 84.96 -11.64 64.95
+ 13 -45.69 26.25 11.14 55.06 14 -44.09 11.23 17.52 44.45
+ 15 36.23 133.49 -19.38 53.67 16 -17.89 81.54 14.64 50.61
+ 17 -41.97 -24.04 -39.43 28.95 18 -5.85 7.76 -6.38 47.02
+ 19 18.82 27.10 42.82 100.09 20 39.17 113.45 26.14 73.47
+ 21 22.31 103.17 49.92 106.05 22 -43.06 40.38 -1.75 76.08
+ 23 2.43 57.27 -14.19 -3.83 24 -47.57 -4.35 8.93 100.06
+ 25 -37.47 49.14 -29.11 8.81 26 -7.86 75.72 49.34 107.42
+ 27 1.53 45.49 20.36 49.74 28 -48.48 32.54 28.81 54.45
+ 29 2.67 39.77 -4.05 13.67 30 4.11 62.88 -47.44 -5.72
+ 31 -21.47 51.75 37.25 116.09 32 45.59 111.37 -6.43 43.64
+ 33 35.23 48.29 23.54 113.33 34 16.61 68.35 -14.69 65.97
+ 35 13.98 16.60 48.66 102.87 36 19.74 23.84 31.15 77.27
+ 37 -27.61 24.43 7.96 94.91 38 -34.77 12.05 -22.60 -6.29
+ 39 -25.83 8.71 -13.48 -12.53 40 -17.11 -1.01 18.06 67.89
+ 41 14.13 71.72 -3.78 39.25 42 23.75 76.00 -16.30 8.23
+ 43 -39.15 28.63 38.12 125.88 44 48.62 86.09 36.49 102.95
+ 45 -31.39 -21.98 2.52 89.78 46 5.65 56.04 15.94 89.10
+ 47 18.28 95.81 46.46 143.08 48 30.93 102.82 -20.08 37.36
+ 49 -20.78 -3.48 -5.58 35.46 50 49.85 90.58 -24.48 46.29
+} {
+if {$x1 >= $x2 || $y1 >= $y2} { error "$x1 $x2 $y1 $y2" }
+ append contents "INSERT INTO t1 VALUES($id, $x1, $x2, $y1, $y2);"
+}
+set queries {
+ 1 "SELECT id FROM t1 WHERE x1>10 AND x2<44"
+ 2 "SELECT id FROM t1 WHERE y1<100"
+ 3 "SELECT id FROM t1 WHERE y1<100 AND x1>0"
+ 4 "SELECT id FROM t1 WHERE y1>10 AND x1>0 AND x2<50 AND y2<550"
+}
+do_allbackcompat_test {
+ if {[code1 {set ::sqlite_options(fts3)}]
+ && [code2 {set ::sqlite_options(fts3)}]
+ } {
+
+ do_test backcompat-4.1 { sql1 $contents } {}
+
+ foreach {n q} $::queries {
+ do_test backcompat-4.2.$n [list sql1 $q] [sql2 $q]
+ }
+
+ do_test backcompat-4.3 { sql1 {
+ INSERT INTO t1 SELECT id+100, x1+10.0, x2+10.0, y1-10.0, y2-10.0 FROM t1;
+ } } {}
+
+ foreach {n q} $::queries {
+ do_test backcompat-4.4.$n [list sql1 $q] [sql2 $q]
+ }
+
+ do_test backcompat-4.5 { sql2 {
+ INSERT INTO t1 SELECT id+200, x1+20.0, x2+20.0, y1-20.0, y2-20.0 FROM t1;
+ } } {}
+
+ foreach {n q} $::queries {
+ do_test backcompat-4.6.$n [list sql1 $q] [sql2 $q]
+ }
+
+ }
+}
+
+finish_test
diff --git a/test/backup.test b/test/backup.test
new file mode 100644
index 0000000..6269885
--- /dev/null
+++ b/test/backup.test
@@ -0,0 +1,972 @@
+# 2009 January 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the sqlite3_backup_XXX API.
+#
+# $Id: backup.test,v 1.11 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_not_use_codec
+
+#---------------------------------------------------------------------
+# Test organization:
+#
+# backup-1.*: Warm-body tests.
+#
+# backup-2.*: Test backup under various conditions. To and from in-memory
+# databases. To and from empty/populated databases. etc.
+#
+# backup-3.*: Verify that the locking-page (pending byte page) is handled.
+#
+# backup-4.*: Test various error conditions.
+#
+# backup-5.*: Test the source database being modified during a backup.
+#
+# backup-6.*: Test the backup_remaining() and backup_pagecount() APIs.
+#
+# backup-7.*: Test SQLITE_BUSY and SQLITE_LOCKED errors.
+#
+# backup-8.*: Test multiple simultaneous backup operations.
+#
+# backup-9.*: Test that passing a negative argument to backup_step() is
+# interpreted as "copy the whole file".
+#
+# backup-10.*: Test writing the source database mid backup.
+#
+
+proc data_checksum {db file} { $db one "SELECT md5sum(a, b) FROM ${file}.t1" }
+proc test_contents {name db1 file1 db2 file2} {
+ $db2 eval {select * from sqlite_master}
+ $db1 eval {select * from sqlite_master}
+ set checksum [data_checksum $db2 $file2]
+ uplevel [list do_test $name [list data_checksum $db1 $file1] $checksum]
+}
+
+do_test backup-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, randstr(1000,1000));
+ INSERT INTO t1 VALUES(3, randstr(1000,1000));
+ INSERT INTO t1 VALUES(4, randstr(1000,1000));
+ INSERT INTO t1 VALUES(5, randstr(1000,1000));
+ COMMIT;
+ }
+} {}
+
+# Sanity check to verify that the [test_contents] proc works.
+#
+test_contents backup-1.2 db main db main
+
+# Check that it is possible to create and finish backup operations.
+#
+do_test backup-1.3.1 {
+ delete_file test2.db
+ sqlite3 db2 test2.db
+ sqlite3_backup B db2 main db main
+} {B}
+do_test backup-1.3.2 {
+ B finish
+} {SQLITE_OK}
+do_test backup-1.3.3 {
+ info commands B
+} {}
+
+# Simplest backup operation. Backup test.db to test2.db. test2.db is
+# initially empty. test.db uses the default page size.
+#
+do_test backup-1.4.1 {
+ sqlite3_backup B db2 main db main
+} {B}
+do_test backup-1.4.2 {
+ B step 200
+} {SQLITE_DONE}
+do_test backup-1.4.3 {
+ B finish
+} {SQLITE_OK}
+do_test backup-1.4.4 {
+ info commands B
+} {}
+test_contents backup-1.4.5 db2 main db main
+db close
+db2 close
+#
+# End of backup-1.* tests.
+#---------------------------------------------------------------------
+
+
+#---------------------------------------------------------------------
+# The following tests, backup-2.*, are based on the following procedure:
+#
+# 1) Populate the source database.
+# 2) Populate the destination database.
+# 3) Run the backup to completion. (backup-2.*.1)
+# 4) Integrity check the destination db. (backup-2.*.2)
+# 5) Check that the contents of the destination db is the same as that
+# of the source db. (backup-2.*.3)
+#
+# The test is run with all possible combinations of the following
+# input parameters, except that if the destination is an in-memory
+# database, the only page size tested is 1024 bytes (the same as the
+# source page-size).
+#
+# * Source database is an in-memory database, OR
+# * Source database is a file-backed database.
+#
+# * Target database is an in-memory database, OR
+# * Target database is a file-backed database.
+#
+# * Destination database is a main file, OR
+# * Destination database is an attached file, OR
+# * Destination database is a temp database.
+#
+# * Target database is empty (zero bytes), OR
+# * Target database is larger than the source, OR
+# * Target database is smaller than the source.
+#
+# * Target database page-size is the same as the source, OR
+# * Target database page-size is larger than the source, OR
+# * Target database page-size is smaller than the source.
+#
+# * Each call to step copies a single page, OR
+# * A single call to step copies the entire source database.
+#
+set iTest 1
+foreach zSrcFile {test.db :memory:} {
+foreach zDestFile {test2.db :memory:} {
+foreach zOpenScript [list {
+ sqlite3 db $zSrcFile
+ sqlite3 db2 $zSrcFile
+ db2 eval "ATTACH '$zDestFile' AS bak"
+ set db_dest db2
+ set file_dest bak
+} {
+ sqlite3 db $zSrcFile
+ sqlite3 db2 $zDestFile
+ set db_dest db2
+ set file_dest main
+} {
+ sqlite3 db $zSrcFile
+ sqlite3 db2 $zDestFile
+ set db_dest db2
+ set file_dest temp
+}] {
+foreach rows_dest {0 3 10} {
+foreach pgsz_dest {512 1024 2048} {
+foreach nPagePerStep {1 200} {
+
+ # Open the databases.
+ catch { delete_file test.db }
+ catch { delete_file test2.db }
+ eval $zOpenScript
+
+ # Set to true if copying to an in-memory destination. Copying to an
+ # in-memory destination is only possible if the initial destination
+ # page size is the same as the source page size (in this case 1024 bytes).
+ #
+ set isMemDest [expr {
+ $zDestFile eq ":memory:" || $file_dest eq "temp" && $TEMP_STORE>=2
+ }]
+
+ if { $isMemDest==0 || $pgsz_dest == 1024 } {
+ if 0 {
+ puts -nonewline "Test $iTest: src=$zSrcFile dest=$zDestFile"
+ puts -nonewline " (as $db_dest.$file_dest)"
+ puts -nonewline " rows_dest=$rows_dest pgsz_dest=$pgsz_dest"
+ puts ""
+ }
+
+ # Set up the content of the source database.
+ execsql {
+ PRAGMA page_size = 1024;
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, randstr(1000,1000));
+ INSERT INTO t1 VALUES(3, randstr(1000,1000));
+ INSERT INTO t1 VALUES(4, randstr(1000,1000));
+ INSERT INTO t1 VALUES(5, randstr(1000,1000));
+ COMMIT;
+ }
+
+
+
+ # Set up the content of the target database.
+ execsql "PRAGMA ${file_dest}.page_size = ${pgsz_dest}" $db_dest
+ if {$rows_dest != 0} {
+ execsql "
+ BEGIN;
+ CREATE TABLE ${file_dest}.t1(a, b);
+ CREATE INDEX ${file_dest}.i1 ON t1(a, b);
+ " $db_dest
+ for {set ii 0} {$ii < $rows_dest} {incr ii} {
+ execsql "
+ INSERT INTO ${file_dest}.t1 VALUES(1, randstr(1000,1000))
+ " $db_dest
+ }
+ }
+
+ # Backup the source database.
+ do_test backup-2.$iTest.1 {
+ sqlite3_backup B $db_dest $file_dest db main
+ while {[B step $nPagePerStep]=="SQLITE_OK"} {}
+ B finish
+ } {SQLITE_OK}
+
+ # Run integrity check on the backup.
+ do_test backup-2.$iTest.2 {
+ execsql "PRAGMA ${file_dest}.integrity_check" $db_dest
+ } {ok}
+
+ test_contents backup-2.$iTest.3 db main $db_dest $file_dest
+
+ }
+
+ db close
+ catch {db2 close}
+ incr iTest
+
+} } } } } }
+#
+# End of backup-2.* tests.
+#---------------------------------------------------------------------
+
+#---------------------------------------------------------------------
+# These tests, backup-3.*, ensure that nothing goes wrong if either
+# the source or destination database are large enough to include the
+# the locking-page (the page that contains the range of bytes that
+# the locks are applied to). These tests assume that the pending
+# byte is at offset 0x00010000 (64KB offset), as set by tester.tcl,
+# not at the 1GB offset as it usually is.
+#
+# The test procedure is as follows (same procedure as used for
+# the backup-2.* tests):
+#
+# 1) Populate the source database.
+# 2) Populate the destination database.
+# 3) Run the backup to completion. (backup-3.*.1)
+# 4) Integrity check the destination db. (backup-3.*.2)
+# 5) Check that the contents of the destination db is the same as that
+# of the source db. (backup-3.*.3)
+#
+# The test procedure is run with the following parameters varied:
+#
+# * Source database includes pending-byte page.
+# * Source database does not include pending-byte page.
+#
+# * Target database includes pending-byte page.
+# * Target database does not include pending-byte page.
+#
+# * Target database page-size is the same as the source, OR
+# * Target database page-size is larger than the source, OR
+# * Target database page-size is smaller than the source.
+#
+set iTest 1
+foreach nSrcPg {10 64 65 66 100} {
+foreach nDestRow {10 100} {
+foreach nDestPgsz {512 1024 2048 4096} {
+
+ catch { delete_file test.db }
+ catch { delete_file test2.db }
+ sqlite3 db test.db
+ sqlite3 db2 test2.db
+
+ # Set up the content of the two databases.
+ #
+ execsql { PRAGMA page_size = 1024 }
+ execsql "PRAGMA page_size = $nDestPgsz" db2
+ foreach db {db db2} {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ COMMIT;
+ } $db
+ }
+ while {[file size test.db]/1024 < $nSrcPg} {
+ execsql { INSERT INTO t1 VALUES($ii, randstr(200,200)) }
+ }
+
+ for {set ii 0} {$ii < $nDestRow} {incr ii} {
+ execsql { INSERT INTO t1 VALUES($ii, randstr(1000,1000)) } db2
+ }
+
+ # Backup the source database.
+ do_test backup-3.$iTest.1 {
+ sqlite3_backup B db main db2 main
+ while {[B step 10]=="SQLITE_OK"} {}
+ B finish
+ } {SQLITE_OK}
+
+ # Run integrity check on the backup.
+ do_test backup-3.$iTest.2 {
+ execsql "PRAGMA integrity_check" db2
+ } {ok}
+
+ test_contents backup-3.$iTest.3 db main db2 main
+
+ db close
+ db2 close
+ incr iTest
+}
+}
+}
+
+#--------------------------------------------------------------------
+do_test backup-3.$iTest.1 {
+ catch { forcedelete test.db }
+ catch { forcedelete test2.db }
+ sqlite3 db test.db
+ set iTab 1
+
+ db eval { PRAGMA page_size = 512 }
+ while {[file size test.db] <= $::sqlite_pending_byte} {
+ db eval "CREATE TABLE t${iTab}(a, b, c)"
+ incr iTab
+ }
+
+ sqlite3 db2 test2.db
+ db2 eval { PRAGMA page_size = 4096 }
+ while {[file size test2.db] < $::sqlite_pending_byte} {
+ db2 eval "CREATE TABLE t${iTab}(a, b, c)"
+ incr iTab
+ }
+
+ sqlite3_backup B db2 main db main
+ B step -1
+} {SQLITE_DONE}
+
+do_test backup-3.$iTest.2 {
+ B finish
+} {SQLITE_OK}
+
+#
+# End of backup-3.* tests.
+#---------------------------------------------------------------------
+
+
+#---------------------------------------------------------------------
+# The following tests, backup-4.*, test various error conditions:
+#
+# backup-4.1.*: Test invalid database names.
+#
+# backup-4.2.*: Test that the source database cannot be detached while
+# a backup is in progress.
+#
+# backup-4.3.*: Test that the source database handle cannot be closed
+# while a backup is in progress.
+#
+# backup-4.4.*: Test an attempt to specify the same handle for the
+# source and destination databases.
+#
+# backup-4.5.*: Test that an in-memory destination with a different
+# page-size to the source database is an error.
+#
+sqlite3 db test.db
+sqlite3 db2 test2.db
+
+do_test backup-4.1.1 {
+ catch { sqlite3_backup B db aux db2 main }
+} {1}
+do_test backup-4.1.2 {
+ sqlite3_errmsg db
+} {unknown database aux}
+do_test backup-4.1.3 {
+ catch { sqlite3_backup B db main db2 aux }
+} {1}
+do_test backup-4.1.4 {
+ sqlite3_errmsg db
+} {unknown database aux}
+
+do_test backup-4.2.1 {
+ catch { forcedelete test3.db }
+ catch { forcedelete test4.db }
+ execsql {
+ ATTACH 'test3.db' AS aux1;
+ CREATE TABLE aux1.t1(a, b);
+ }
+ execsql {
+ ATTACH 'test4.db' AS aux2;
+ CREATE TABLE aux2.t2(a, b);
+ } db2
+ sqlite3_backup B db aux1 db2 aux2
+} {B}
+do_test backup-4.2.2 {
+ catchsql { DETACH aux2 } db2
+} {1 {database aux2 is locked}}
+do_test backup-4.2.3 {
+ B step 50
+} {SQLITE_DONE}
+do_test backup-4.2.4 {
+ B finish
+} {SQLITE_OK}
+
+do_test backup-4.3.1 {
+ sqlite3_backup B db aux1 db2 aux2
+} {B}
+do_test backup-4.3.2 {
+ db2 cache flush
+ sqlite3_close db2
+} {SQLITE_BUSY}
+do_test backup-4.3.3 {
+ sqlite3_errmsg db2
+} {unable to close due to unfinished backup operation}
+do_test backup-4.3.4 {
+ B step 50
+} {SQLITE_DONE}
+do_test backup-4.3.5 {
+ B finish
+} {SQLITE_OK}
+
+do_test backup-4.4.1 {
+ set rc [catch {sqlite3_backup B db main db aux1}]
+ list $rc [sqlite3_errcode db] [sqlite3_errmsg db]
+} {1 SQLITE_ERROR {source and destination must be distinct}}
+db close
+db2 close
+
+do_test backup-4.5.1 {
+ catch { forcedelete test.db }
+ sqlite3 db test.db
+ sqlite3 db2 :memory:
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ execsql {
+ PRAGMA page_size = 4096;
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES(3, 4);
+ } db2
+ sqlite3_backup B db2 main db main
+} {B}
+do_test backup-4.5.2 {
+ B step 5000
+} {SQLITE_READONLY}
+do_test backup-4.5.3 {
+ B finish
+} {SQLITE_READONLY}
+
+db close
+db2 close
+#
+# End of backup-5.* tests.
+#---------------------------------------------------------------------
+
+#---------------------------------------------------------------------
+# The following tests, backup-5.*, test that the backup works properly
+# when the source database is modified during the backup. Test cases
+# are organized as follows:
+#
+# backup-5.x.1.*: Nothing special. Modify the database mid-backup.
+#
+# backup-5.x.2.*: Modify the database mid-backup so that one or more
+# pages are written out due to cache stress. Then
+# rollback the transaction.
+#
+# backup-5.x.3.*: Database is vacuumed.
+#
+# backup-5.x.4.*: Database is vacuumed and the page-size modified.
+#
+# backup-5.x.5.*: Database is shrunk via incr-vacuum.
+#
+# Each test is run three times, in the following configurations:
+#
+# 1) Backing up file-to-file. The writer writes via an external pager.
+# 2) Backing up file-to-file. The writer writes via the same pager as
+# is used by the backup operation.
+# 3) Backing up memory-to-file.
+#
+set iTest 0
+forcedelete bak.db-wal
+foreach {writer file} {db test.db db3 test.db db :memory:} {
+ incr iTest
+ catch { delete_file bak.db }
+ sqlite3 db2 bak.db
+ catch { delete_file $file }
+ sqlite3 db $file
+ sqlite3 db3 $file
+
+ do_test backup-5.$iTest.1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, randstr(1000,1000));
+ INSERT INTO t1 VALUES(3, randstr(1000,1000));
+ INSERT INTO t1 VALUES(4, randstr(1000,1000));
+ INSERT INTO t1 VALUES(5, randstr(1000,1000));
+ COMMIT;
+ }
+ expr {[execsql {PRAGMA page_count}] > 10}
+ } {1}
+ do_test backup-5.$iTest.1.2 {
+ sqlite3_backup B db2 main db main
+ B step 5
+ } {SQLITE_OK}
+ do_test backup-5.$iTest.1.3 {
+ execsql { UPDATE t1 SET a = a + 1 } $writer
+ B step 50
+ } {SQLITE_DONE}
+ do_test backup-5.$iTest.1.4 {
+ B finish
+ } {SQLITE_OK}
+ integrity_check backup-5.$iTest.1.5 db2
+ test_contents backup-5.$iTest.1.6 db main db2 main
+
+ do_test backup-5.$iTest.2.1 {
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ INSERT INTO t1 SELECT '', randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT '', randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT '', randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT '', randstr(1000,1000) FROM t1;
+ COMMIT;
+ }
+ } {}
+ do_test backup-5.$iTest.2.2 {
+ sqlite3_backup B db2 main db main
+ B step 50
+ } {SQLITE_OK}
+ do_test backup-5.$iTest.2.3 {
+ execsql {
+ BEGIN;
+ UPDATE t1 SET a = a + 1;
+ ROLLBACK;
+ } $writer
+ B step 5000
+ } {SQLITE_DONE}
+ do_test backup-5.$iTest.2.4 {
+ B finish
+ } {SQLITE_OK}
+ integrity_check backup-5.$iTest.2.5 db2
+ test_contents backup-5.$iTest.2.6 db main db2 main
+
+ do_test backup-5.$iTest.3.1 {
+ execsql { UPDATE t1 SET b = randstr(1000,1000) }
+ } {}
+ do_test backup-5.$iTest.3.2 {
+ sqlite3_backup B db2 main db main
+ B step 50
+ } {SQLITE_OK}
+ do_test backup-5.$iTest.3.3 {
+ execsql { VACUUM } $writer
+ B step 5000
+ } {SQLITE_DONE}
+ do_test backup-5.$iTest.3.4 {
+ B finish
+ } {SQLITE_OK}
+ integrity_check backup-5.$iTest.3.5 db2
+ test_contents backup-5.$iTest.3.6 db main db2 main
+
+ do_test backup-5.$iTest.4.1 {
+ execsql { UPDATE t1 SET b = randstr(1000,1000) }
+ } {}
+ do_test backup-5.$iTest.4.2 {
+ sqlite3_backup B db2 main db main
+ B step 50
+ } {SQLITE_OK}
+ do_test backup-5.$iTest.4.3 {
+ execsql {
+ PRAGMA page_size = 2048;
+ VACUUM;
+ } $writer
+ B step 5000
+ } {SQLITE_DONE}
+ do_test backup-5.$iTest.4.4 {
+ B finish
+ } {SQLITE_OK}
+ integrity_check backup-5.$iTest.4.5 db2
+ test_contents backup-5.$iTest.4.6 db main db2 main
+
+ catch {db close}
+ catch {db2 close}
+ catch {db3 close}
+ catch { delete_file bak.db }
+ sqlite3 db2 bak.db
+ catch { delete_file $file }
+ sqlite3 db $file
+ sqlite3 db3 $file
+ do_test backup-5.$iTest.5.1 {
+ execsql {
+ PRAGMA auto_vacuum = incremental;
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, randstr(1000,1000));
+ INSERT INTO t1 VALUES(3, randstr(1000,1000));
+ INSERT INTO t1 VALUES(4, randstr(1000,1000));
+ INSERT INTO t1 VALUES(5, randstr(1000,1000));
+ COMMIT;
+ }
+ } {}
+ do_test backup-5.$iTest.5.2 {
+ sqlite3_backup B db2 main db main
+ B step 8
+ } {SQLITE_OK}
+ do_test backup-5.$iTest.5.3 {
+ execsql {
+ DELETE FROM t1;
+ PRAGMA incremental_vacuum;
+ } $writer
+ B step 50
+ } {SQLITE_DONE}
+ do_test backup-5.$iTest.5.4 {
+ B finish
+ } {SQLITE_OK}
+ integrity_check backup-5.$iTest.5.5 db2
+ test_contents backup-5.$iTest.5.6 db main db2 main
+ catch {db close}
+ catch {db2 close}
+ catch {db3 close}
+}
+#
+# End of backup-5.* tests.
+#---------------------------------------------------------------------
+
+#---------------------------------------------------------------------
+# Test the sqlite3_backup_remaining() and backup_pagecount() APIs.
+#
+do_test backup-6.1 {
+ catch { forcedelete test.db }
+ catch { forcedelete test2.db }
+ sqlite3 db test.db
+ sqlite3 db2 test2.db
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, randstr(1000,1000));
+ INSERT INTO t1 VALUES(3, randstr(1000,1000));
+ INSERT INTO t1 VALUES(4, randstr(1000,1000));
+ INSERT INTO t1 VALUES(5, randstr(1000,1000));
+ COMMIT;
+ }
+} {}
+do_test backup-6.2 {
+ set nTotal [expr {[file size test.db]/1024}]
+ sqlite3_backup B db2 main db main
+ B step 1
+} {SQLITE_OK}
+do_test backup-6.3 {
+ B pagecount
+} $nTotal
+do_test backup-6.4 {
+ B remaining
+} [expr $nTotal-1]
+do_test backup-6.5 {
+ B step 5
+ list [B remaining] [B pagecount]
+} [list [expr $nTotal-6] $nTotal]
+do_test backup-6.6 {
+ execsql { CREATE TABLE t2(a PRIMARY KEY, b) }
+ B step 1
+ list [B remaining] [B pagecount]
+} [list [expr $nTotal-5] [expr $nTotal+2]]
+
+do_test backup-6.X {
+ B finish
+} {SQLITE_OK}
+
+catch {db close}
+catch {db2 close}
+
+#---------------------------------------------------------------------
+# Test cases backup-7.* test that SQLITE_BUSY and SQLITE_LOCKED errors
+# are returned correctly:
+#
+# backup-7.1.*: Source database is externally locked (return SQLITE_BUSY).
+#
+# backup-7.2.*: Attempt to step the backup process while a
+# write-transaction is underway on the source pager (return
+# SQLITE_LOCKED).
+#
+# backup-7.3.*: Destination database is externally locked (return SQLITE_BUSY).
+#
+do_test backup-7.0 {
+ catch { forcedelete test.db }
+ catch { forcedelete test2.db }
+ sqlite3 db2 test2.db
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+ 2, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+ 4, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+ 8, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+16, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+32, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+64, randstr(1000,1000) FROM t1;
+ }
+} {}
+
+do_test backup-7.1.1 {
+ sqlite3_backup B db2 main db main
+ B step 5
+} {SQLITE_OK}
+do_test backup-7.1.2 {
+ sqlite3 db3 test.db
+ execsql { BEGIN EXCLUSIVE } db3
+ B step 5
+} {SQLITE_BUSY}
+do_test backup-7.1.3 {
+ execsql { ROLLBACK } db3
+ B step 5
+} {SQLITE_OK}
+do_test backup-7.2.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 4);
+ }
+} {}
+do_test backup-7.2.2 {
+ B step 5000
+} {SQLITE_BUSY}
+do_test backup-7.2.3 {
+ execsql { ROLLBACK }
+ B step 5000
+} {SQLITE_DONE}
+do_test backup-7.2.4 {
+ B finish
+} {SQLITE_OK}
+test_contents backup-7.2.5 db main db2 main
+integrity_check backup-7.3.6 db2
+
+do_test backup-7.3.1 {
+ db2 close
+ db3 close
+ forcedelete test2.db
+ sqlite3 db2 test2.db
+ sqlite3 db3 test2.db
+
+ sqlite3_backup B db2 main db main
+ execsql { BEGIN ; CREATE TABLE t2(a, b); } db3
+
+ B step 5
+} {SQLITE_BUSY}
+do_test backup-7.3.2 {
+ execsql { COMMIT } db3
+ B step 5000
+} {SQLITE_DONE}
+do_test backup-7.3.3 {
+ B finish
+} {SQLITE_OK}
+test_contents backup-7.3.4 db main db2 main
+integrity_check backup-7.3.5 db2
+catch { db2 close }
+catch { db3 close }
+
+#-----------------------------------------------------------------------
+# The following tests, backup-8.*, test attaching multiple backup
+# processes to the same source database. Also, reading from the source
+# database while a read transaction is active.
+#
+# These tests reuse the database "test.db" left over from backup-7.*.
+#
+do_test backup-8.1 {
+ catch { forcedelete test2.db }
+ catch { forcedelete test3.db }
+ sqlite3 db2 test2.db
+ sqlite3 db3 test3.db
+
+ sqlite3_backup B2 db2 main db main
+ sqlite3_backup B3 db3 main db main
+ list [B2 finish] [B3 finish]
+} {SQLITE_OK SQLITE_OK}
+do_test backup-8.2 {
+ sqlite3_backup B3 db3 main db main
+ sqlite3_backup B2 db2 main db main
+ list [B2 finish] [B3 finish]
+} {SQLITE_OK SQLITE_OK}
+do_test backup-8.3 {
+ sqlite3_backup B2 db2 main db main
+ sqlite3_backup B3 db3 main db main
+ B2 step 5
+} {SQLITE_OK}
+do_test backup-8.4 {
+ execsql {
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ }
+ B3 step 5
+} {SQLITE_OK}
+do_test backup-8.5 {
+ list [B3 step 5000] [B3 finish]
+} {SQLITE_DONE SQLITE_OK}
+do_test backup-8.6 {
+ list [B2 step 5000] [B2 finish]
+} {SQLITE_DONE SQLITE_OK}
+test_contents backup-8.7 db main db2 main
+test_contents backup-8.8 db main db3 main
+do_test backup-8.9 {
+ execsql { PRAGMA lock_status }
+} {main shared temp closed}
+do_test backup-8.10 {
+ execsql COMMIT
+} {}
+catch { db2 close }
+catch { db3 close }
+
+#-----------------------------------------------------------------------
+# The following tests, backup-9.*, test that:
+#
+# * Passing 0 as an argument to sqlite3_backup_step() means no pages
+# are backed up (backup-9.1.*), and
+# * Passing a negative value as an argument to sqlite3_backup_step() means
+# all pages are backed up (backup-9.2.*).
+#
+# These tests reuse the database "test.db" left over from backup-7.*.
+#
+do_test backup-9.1.1 {
+ sqlite3 db2 test2.db
+ sqlite3_backup B db2 main db main
+ B step 1
+} {SQLITE_OK}
+do_test backup-9.1.2 {
+ set nRemaining [B remaining]
+ expr {$nRemaining>100}
+} {1}
+do_test backup-9.1.3 {
+ B step 0
+} {SQLITE_OK}
+do_test backup-9.1.4 {
+ B remaining
+} $nRemaining
+
+do_test backup-9.2.1 {
+ B step -1
+} {SQLITE_DONE}
+do_test backup-9.2.2 {
+ B remaining
+} {0}
+do_test backup-9.2.3 {
+ B finish
+} {SQLITE_OK}
+catch {db2 close}
+
+ifcapable memorymanage {
+ db close
+ forcedelete test.db
+ forcedelete bak.db
+
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ sqlite3 db3 bak.db
+
+ do_test backup-10.1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, randstr(1000,1000));
+ INSERT INTO t1 VALUES(3, randstr(1000,1000));
+ INSERT INTO t1 VALUES(4, randstr(1000,1000));
+ INSERT INTO t1 VALUES(5, randstr(1000,1000));
+ CREATE INDEX i1 ON t1(a, b);
+ COMMIT;
+ }
+ } {}
+ do_test backup-10.1.2 {
+ sqlite3_backup B db3 main db2 main
+ B step 5
+ } {SQLITE_OK}
+ do_test backup-10.1.3 {
+ execsql {
+ UPDATE t1 SET b = randstr(500,500);
+ }
+ } {}
+ sqlite3_release_memory [expr 1024*1024]
+ do_test backup-10.1.3 {
+ B step 50
+ } {SQLITE_DONE}
+ do_test backup-10.1.4 {
+ B finish
+ } {SQLITE_OK}
+ do_test backup-10.1.5 {
+ execsql { PRAGMA integrity_check } db3
+ } {ok}
+
+ db2 close
+ db3 close
+}
+
+
+#-----------------------------------------------------------------------
+# Test that if the database is written to via the same database handle being
+# used as the source by a backup operation:
+#
+# 10.1.*: If the db is in-memory, the backup is restarted.
+# 10.2.*: If the db is a file, the backup is not restarted.
+#
+db close
+forcedelete test.db test.db-journal
+foreach {tn file rc} {
+ 1 test.db SQLITE_DONE
+ 2 :memory: SQLITE_OK
+} {
+ do_test backup-10.$tn.1 {
+ sqlite3 db $file
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);
+ BEGIN;
+ INSERT INTO t1 VALUES(NULL, randomblob(200));
+ INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+ } {256}
+
+ do_test backup-10.$tn.2 {
+ set pgs [execsql {pragma page_count}]
+ expr {$pgs > 50 && $pgs < 75}
+ } {1}
+
+ do_test backup-10.$tn.3 {
+ forcedelete bak.db bak.db-journal
+ sqlite3 db2 bak.db
+ sqlite3_backup B db2 main db main
+ B step 50
+ } {SQLITE_OK}
+
+ do_test backup-10.$tn.4 {
+ execsql { UPDATE t1 SET b = randomblob(200) WHERE a IN (1, 250) }
+ } {}
+
+ do_test backup-10.$tn.5 {
+ B step 50
+ } $rc
+
+ do_test backup-10.$tn.6 {
+ B finish
+ } {SQLITE_OK}
+
+ db2 close
+}
+
+finish_test
diff --git a/test/backup2.test b/test/backup2.test
new file mode 100644
index 0000000..34924b0
--- /dev/null
+++ b/test/backup2.test
@@ -0,0 +1,189 @@
+# 2009 February 4
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the "backup" and "restore" methods
+# of the TCL interface - methods which are based on the
+# sqlite3_backup_XXX API.
+#
+# $Id: backup2.test,v 1.4 2009/04/07 14:14:23 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_not_use_codec
+
+ifcapable !trigger||!view { finish_test ; return }
+
+# Fill a database with test data.
+#
+do_test backup2-1 {
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randstr(8000,8000));
+ INSERT INTO t1 VALUES(randstr(8000,8000));
+ INSERT INTO t1 VALUES(randstr(8000,8000));
+ INSERT INTO t1 VALUES(randstr(8000,8000));
+ INSERT INTO t1 VALUES(randstr(8000,8000));
+ CREATE VIEW v1 AS SELECT substr(x,10,10) FROM t1;
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2 VALUES(1,2);
+ INSERT INTO t2 VALUES(2,4);
+ INSERT INTO t2 SELECT a+2, (a+2)*2 FROM t2;
+ INSERT INTO t2 SELECT a+4, (a+4)*2 FROM t2;
+ INSERT INTO t2 SELECT a+8, (a+8)*2 FROM t2;
+ INSERT INTO t2 SELECT a+16, (a+16)*2 FROM t2;
+ INSERT INTO t2 SELECT a+32, (a+32)*2 FROM t2;
+ INSERT INTO t2 SELECT a+64, (a+64)*2 FROM t2;
+ INSERT INTO t2 SELECT a+128, (a+128)*2 FROM t2;
+ CREATE INDEX t2i1 ON t2(a,b);
+ CREATE TRIGGER r1 AFTER INSERT ON t2 BEGIN
+ SELECT 'hello';
+ END;
+ ANALYZE;
+ PRAGMA integrity_check;
+ }
+} {ok}
+
+# Remember a check-sum on the database file.
+#
+unset -nocomplain cksum
+set cksum [dbcksum db main]
+
+# Make a backup of the test data. Verify that the backup copy
+# is identical to the original.
+#
+do_test backup2-2 {
+ forcedelete bu1.db
+ db backup bu1.db
+ sqlite3 db2 bu1.db
+ dbcksum db2 main
+} $cksum
+
+# Delete the original. Restore from backup. Verify the content is
+# unchanged.
+#
+do_test backup2-3.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ db2 eval {BEGIN EXCLUSIVE}
+ set rc [catch {db restore bu1.db} res]
+ lappend rc $res
+ db2 eval {ROLLBACK}
+ set rc
+} {1 {restore failed: source database busy}}
+do_test backup2-3.2 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ db restore bu1.db
+ dbcksum db main
+} $cksum
+
+# Use alternative databases - other than "main".
+#
+do_test backup2-4 {
+ db restore temp bu1.db
+ dbcksum db temp
+} $cksum
+do_test backup2-5 {
+ db2 close
+ forcedelete bu1.db bu2.db
+ db backup temp bu2.db
+ sqlite3 db2 bu2.db
+ dbcksum db2 main
+} $cksum
+
+# Try to backup to a readonly file.
+#
+do_test backup2-6 {
+ db2 close
+ catch {file attributes bu2.db -permissions r--------}
+ catch {file attributes bu2.db -readonly 1}
+ set rc [catch {db backup temp bu2.db} res]
+ lappend rc $res
+} {1 {backup failed: attempt to write a readonly database}}
+
+# Try to backup to something that is not a database file.
+#
+do_test backup2-7 {
+ catch {file attributes bu2.db -readonly 0}
+ catch {file attributes bu2.db -permissions rw-------}
+ set out [open bu2.db w]
+ puts $out "This is not a valid database file"
+ close $out
+ set rc [catch {db backup temp bu2.db} res]
+ lappend rc $res
+} {1 {backup failed: file is encrypted or is not a database}}
+
+# Try to backup database that does not exist
+#
+do_test backup2-8 {
+ forcedelete bu1.db
+ set rc [catch {db backup aux1 bu1.db} res]
+ lappend rc $res
+} {1 {backup failed: unknown database aux1}}
+
+# Invalid syntax on the backup method
+#
+do_test backup2-9 {
+ set rc [catch {db backup} res]
+ lappend rc $res
+} {1 {wrong # args: should be "db backup ?DATABASE? FILENAME"}}
+
+# Try to restore from an unreadable file.
+#
+if {$tcl_platform(platform)=="windows"} {
+ do_test backup2-10 {
+ forcedelete bu3.db
+ file mkdir bu3.db
+ set rc [catch {db restore temp bu3.db} res]
+ lappend rc $res
+ } {1 {cannot open source database: unable to open database file}}
+}
+if {$tcl_platform(platform)!="windows"} {
+ do_test backup2-10 {
+ forcedelete bu3.db
+ file mkdir bu3.db
+ set rc [catch {db restore temp bu3.db} res]
+ lappend rc $res
+ } {1 {cannot open source database: disk I/O error}}
+}
+
+# Try to restore from something that is not a database file.
+#
+do_test backup2-11 {
+ set rc [catch {db restore temp bu2.db} res]
+ lappend rc $res
+} {1 {restore failed: file is encrypted or is not a database}}
+
+# Try to restore a database that does not exist
+#
+do_test backup2-12 {
+ set rc [catch {db restore aux1 bu2.db} res]
+ lappend rc $res
+} {1 {restore failed: unknown database aux1}}
+do_test backup2-13 {
+ forcedelete bu4.db
+ set rc [catch {db restore bu4.db} res]
+ lappend rc $res
+} {1 {cannot open source database: unable to open database file}}
+
+# Invalid syntax on the restore method
+#
+do_test backup2-14 {
+ set rc [catch {db restore} res]
+ lappend rc $res
+} {1 {wrong # args: should be "db restore ?DATABASE? FILENAME"}}
+
+forcedelete bu1.db bu2.db bu3.db bu4.db
+
+finish_test
diff --git a/test/backup_ioerr.test b/test/backup_ioerr.test
new file mode 100644
index 0000000..313cff3
--- /dev/null
+++ b/test/backup_ioerr.test
@@ -0,0 +1,286 @@
+# 2009 January 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the handling of IO errors by the
+# sqlite3_backup_XXX APIs.
+#
+# $Id: backup_ioerr.test,v 1.3 2009/04/10 18:41:01 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc data_checksum {db file} {
+ $db one "SELECT md5sum(a, b) FROM ${file}.t1"
+}
+proc test_contents {name db1 file1 db2 file2} {
+ $db2 eval {select * from sqlite_master}
+ $db1 eval {select * from sqlite_master}
+ set checksum [data_checksum $db2 $file2]
+ uplevel [list do_test $name [list data_checksum $db1 $file1] $checksum]
+}
+
+#--------------------------------------------------------------------
+# This proc creates a database of approximately 290 pages. Depending
+# on whether or not auto-vacuum is configured. Test cases backup_ioerr-1.*
+# verify nothing more than this assumption.
+#
+proc populate_database {db {xtra_large 0}} {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+ 2, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+ 4, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+ 8, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+16, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+32, randstr(1000,1000) FROM t1;
+ CREATE INDEX i1 ON t1(b);
+ COMMIT;
+ } $db
+ if {$xtra_large} {
+ execsql { INSERT INTO t1 SELECT a+64, randstr(1000,1000) FROM t1 } $db
+ }
+}
+do_test backup_ioerr-1.1 {
+ populate_database db
+ set nPage [expr {[file size test.db] / 1024}]
+ expr {$nPage>130 && $nPage<160}
+} {1}
+do_test backup_ioerr-1.2 {
+ expr {[file size test.db] > $sqlite_pending_byte}
+} {1}
+do_test backup_ioerr-1.3 {
+ db close
+ forcedelete test.db
+} {}
+
+# Turn off IO error simulation.
+#
+proc clear_ioerr_simulation {} {
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_hardhit 0
+ set ::sqlite_io_error_pending 0
+ set ::sqlite_io_error_persist 0
+}
+
+#--------------------------------------------------------------------
+# The following procedure runs with SQLite's IO error simulation
+# enabled.
+#
+# 1) Start with a reasonably sized database. One that includes the
+# pending-byte (locking) page.
+#
+# 2) Open a backup process. Set the cache-size for the destination
+# database to 10 pages only.
+#
+# 3) Step the backup process N times to partially backup the database
+# file. If an IO error is reported, then the backup process is
+# concluded with a call to backup_finish().
+#
+# If an IO error occurs, verify that:
+#
+# * the call to backup_step() returns an SQLITE_IOERR_XXX error code.
+#
+# * after the failed call to backup_step() but before the call to
+# backup_finish() the destination database handle error code and
+# error message remain unchanged.
+#
+# * the call to backup_finish() returns an SQLITE_IOERR_XXX error code.
+#
+# * following the call to backup_finish(), the destination database
+# handle has been populated with an error code and error message.
+#
+# 4) Write to the database via the source database connection. Check
+# that:
+#
+# * If an IO error occurs while writing the source database, the
+# write operation should report an IO error. The backup should
+# proceed as normal.
+#
+# * If an IO error occurs while updating the backup, the write
+# operation should proceed normally. The error should be reported
+# from the next call to backup_step() (in step 5 of this test
+# procedure).
+#
+# 5) Step the backup process to finish the backup. If an IO error is
+# reported, then the backup process is concluded with a call to
+# backup_finish().
+#
+# Test that if an IO error occurs, or if one occured while updating
+# the backup database during step 4, then the conditions listed
+# under step 3 are all true.
+#
+# 6) Finish the backup process.
+#
+# * If the backup succeeds (backup_finish() returns SQLITE_OK), then
+# the contents of the backup database should match that of the
+# source database.
+#
+# * If the backup fails (backup_finish() returns other than SQLITE_OK),
+# then the contents of the backup database should be as they were
+# before the operation was started.
+#
+# The following factors are varied:
+#
+# * Destination database is initially larger than the source database, OR
+# * Destination database is initially smaller than the source database.
+#
+# * IO errors are transient, OR
+# * IO errors are persistent.
+#
+# * Destination page-size is smaller than the source.
+# * Destination page-size is the same as the source.
+# * Destination page-size is larger than the source.
+#
+
+set iTest 1
+foreach bPersist {0 1} {
+foreach iDestPagesize {512 1024 4096} {
+foreach zSetupBak [list "" {populate_database ddb 1}] {
+
+ incr iTest
+ set bStop 0
+for {set iError 1} {$bStop == 0} {incr iError} {
+ # Disable IO error simulation.
+ clear_ioerr_simulation
+
+ catch { ddb close }
+ catch { sdb close }
+ catch { forcedelete test.db }
+ catch { forcedelete bak.db }
+
+ # Open the source and destination databases.
+ sqlite3 sdb test.db
+ sqlite3 ddb bak.db
+
+ # Step 1: Populate the source and destination databases.
+ populate_database sdb
+ ddb eval "PRAGMA page_size = $iDestPagesize"
+ ddb eval "PRAGMA cache_size = 10"
+ eval $zSetupBak
+
+ # Step 2: Open the backup process.
+ sqlite3_backup B ddb main sdb main
+
+ # Enable IO error simulation.
+ set ::sqlite_io_error_pending $iError
+ set ::sqlite_io_error_persist $bPersist
+
+ # Step 3: Partially backup the database. If an IO error occurs, check
+ # a few things then skip to the next iteration of the loop.
+ #
+ set rc [B step 100]
+ if {$::sqlite_io_error_hardhit} {
+
+ do_test backup_ioerr-$iTest.$iError.1 {
+ string match SQLITE_IOERR* $rc
+ } {1}
+ do_test backup_ioerr-$iTest.$iError.2 {
+ list [sqlite3_errcode ddb] [sqlite3_errmsg ddb]
+ } {SQLITE_OK {not an error}}
+
+ set rc [B finish]
+ do_test backup_ioerr-$iTest.$iError.3 {
+ string match SQLITE_IOERR* $rc
+ } {1}
+
+ do_test backup_ioerr-$iTest.$iError.4 {
+ sqlite3_errmsg ddb
+ } {disk I/O error}
+
+ clear_ioerr_simulation
+ sqlite3 ddb bak.db
+ integrity_check backup_ioerr-$iTest.$iError.5 ddb
+
+ continue
+ }
+
+ # No IO error was encountered during step 3. Check that backup_step()
+ # returned SQLITE_OK before proceding.
+ do_test backup_ioerr-$iTest.$iError.6 {
+ expr {$rc eq "SQLITE_OK"}
+ } {1}
+
+ # Step 4: Write to the source database.
+ set rc [catchsql { UPDATE t1 SET b = randstr(1000,1000) WHERE a < 50 } sdb]
+
+ if {[lindex $rc 0] && $::sqlite_io_error_persist==0} {
+ # The IO error occured while updating the source database. In this
+ # case the backup should be able to continue.
+ set rc [B step 5000]
+ if { $rc != "SQLITE_IOERR_UNLOCK" } {
+ do_test backup_ioerr-$iTest.$iError.7 {
+ list [B step 5000] [B finish]
+ } {SQLITE_DONE SQLITE_OK}
+
+ clear_ioerr_simulation
+ test_contents backup_ioerr-$iTest.$iError.8 ddb main sdb main
+ integrity_check backup_ioerr-$iTest.$iError.9 ddb
+ } else {
+ do_test backup_ioerr-$iTest.$iError.10 {
+ B finish
+ } {SQLITE_IOERR_UNLOCK}
+ }
+
+ clear_ioerr_simulation
+ sqlite3 ddb bak.db
+ integrity_check backup_ioerr-$iTest.$iError.11 ddb
+
+ continue
+ }
+
+ # Step 5: Finish the backup operation. If an IO error occurs, check that
+ # it is reported correctly and skip to the next iteration of the loop.
+ #
+ set rc [B step 5000]
+ if {$rc != "SQLITE_DONE"} {
+ do_test backup_ioerr-$iTest.$iError.12 {
+ string match SQLITE_IOERR* $rc
+ } {1}
+ do_test backup_ioerr-$iTest.$iError.13 {
+ list [sqlite3_errcode ddb] [sqlite3_errmsg ddb]
+ } {SQLITE_OK {not an error}}
+
+ set rc [B finish]
+ do_test backup_ioerr-$iTest.$iError.14 {
+ string match SQLITE_IOERR* $rc
+ } {1}
+ do_test backup_ioerr-$iTest.$iError.15 {
+ sqlite3_errmsg ddb
+ } {disk I/O error}
+
+ clear_ioerr_simulation
+ sqlite3 ddb bak.db
+ integrity_check backup_ioerr-$iTest.$iError.16 ddb
+
+ continue
+ }
+
+ # The backup was successfully completed.
+ #
+ do_test backup_ioerr-$iTest.$iError.17 {
+ list [set rc] [B finish]
+ } {SQLITE_DONE SQLITE_OK}
+
+ clear_ioerr_simulation
+ sqlite3 sdb test.db
+ sqlite3 ddb bak.db
+
+ test_contents backup_ioerr-$iTest.$iError.18 ddb main sdb main
+ integrity_check backup_ioerr-$iTest.$iError.19 ddb
+
+ set bStop [expr $::sqlite_io_error_pending<=0]
+}}}}
+
+catch { sdb close }
+catch { ddb close }
+finish_test
diff --git a/test/backup_malloc.test b/test/backup_malloc.test
new file mode 100644
index 0000000..f556861
--- /dev/null
+++ b/test/backup_malloc.test
@@ -0,0 +1,87 @@
+# 2009 January 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the handling of OOM errors by the
+# sqlite3_backup_XXX APIs.
+#
+# $Id: backup_malloc.test,v 1.2 2009/02/04 22:46:47 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+source $testdir/malloc_common.tcl
+
+do_malloc_test backup_malloc-1 -tclprep {
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+ 2, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+ 4, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+ 8, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+16, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+32, randstr(1000,1000) FROM t1;
+ INSERT INTO t1 SELECT a+64, randstr(1000,1000) FROM t1;
+ CREATE INDEX i1 ON t1(b);
+ COMMIT;
+ }
+ sqlite3 db2 test2.db
+ execsql { PRAGMA cache_size = 10 } db2
+} -tclbody {
+
+ # Create a backup object.
+ #
+ set rc [catch {sqlite3_backup B db2 main db main}]
+ if {$rc && [sqlite3_errcode db2] == "SQLITE_NOMEM"} {
+ error "out of memory"
+ }
+
+ # Run the backup process some.
+ #
+ set rc [B step 50]
+ if {$rc == "SQLITE_NOMEM" || $rc == "SQLITE_IOERR_NOMEM"} {
+ error "out of memory"
+ }
+
+ # Update the database.
+ #
+ execsql { UPDATE t1 SET a = a + 1 }
+
+ # Finish doing the backup.
+ #
+ set rc [B step 5000]
+ if {$rc == "SQLITE_NOMEM" || $rc == "SQLITE_IOERR_NOMEM"} {
+ error "out of memory"
+ }
+
+ # Finalize the backup.
+ B finish
+} -cleanup {
+ catch { B finish }
+ catch { db2 close }
+}
+
+do_malloc_test backup_malloc-2 -tclprep {
+ sqlite3 db2 test2.db
+} -tclbody {
+ set rc [catch {sqlite3_backup B db2 temp db main}]
+ set errcode [sqlite3_errcode db2]
+ if {$rc && ($errcode == "SQLITE_NOMEM" || $errcode == "SQLITE_IOERR_NOMEM")} {
+ error "out of memory"
+ }
+} -cleanup {
+ catch { B finish }
+ db2 close
+}
+
+finish_test
diff --git a/test/badutf.test b/test/badutf.test
new file mode 100644
index 0000000..d09c933
--- /dev/null
+++ b/test/badutf.test
@@ -0,0 +1,143 @@
+# 2007 May 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file checks to make sure SQLite is able to gracefully
+# handle malformed UTF-8.
+#
+# $Id: badutf.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test badutf-1.1 {
+ db eval {PRAGMA encoding=UTF8}
+ sqlite3_exec db {SELECT hex('%80') AS x}
+} {0 {x 80}}
+do_test badutf-1.2 {
+ sqlite3_exec db {SELECT hex('%81') AS x}
+} {0 {x 81}}
+do_test badutf-1.3 {
+ sqlite3_exec db {SELECT hex('%bf') AS x}
+} {0 {x BF}}
+do_test badutf-1.4 {
+ sqlite3_exec db {SELECT hex('%c0') AS x}
+} {0 {x C0}}
+do_test badutf-1.5 {
+ sqlite3_exec db {SELECT hex('%e0') AS x}
+} {0 {x E0}}
+do_test badutf-1.6 {
+ sqlite3_exec db {SELECT hex('%f0') AS x}
+} {0 {x F0}}
+do_test badutf-1.7 {
+ sqlite3_exec db {SELECT hex('%ff') AS x}
+} {0 {x FF}}
+
+sqlite3 db2 {}
+ifcapable utf16 {
+ do_test badutf-1.10 {
+ db2 eval {PRAGMA encoding=UTF16be}
+ sqlite3_exec db2 {SELECT hex('%80') AS x}
+ } {0 {x 0080}}
+ do_test badutf-1.11 {
+ sqlite3_exec db2 {SELECT hex('%81') AS x}
+ } {0 {x 0081}}
+ do_test badutf-1.12 {
+ sqlite3_exec db2 {SELECT hex('%bf') AS x}
+ } {0 {x 00BF}}
+ do_test badutf-1.13 {
+ sqlite3_exec db2 {SELECT hex('%c0') AS x}
+ } {0 {x FFFD}}
+ do_test badutf-1.14 {
+ sqlite3_exec db2 {SELECT hex('%c1') AS x}
+ } {0 {x FFFD}}
+ do_test badutf-1.15 {
+ sqlite3_exec db2 {SELECT hex('%c0%bf') AS x}
+ } {0 {x FFFD}}
+ do_test badutf-1.16 {
+ sqlite3_exec db2 {SELECT hex('%c1%bf') AS x}
+ } {0 {x FFFD}}
+ do_test badutf-1.17 {
+ sqlite3_exec db2 {SELECT hex('%c3%bf') AS x}
+ } {0 {x 00FF}}
+ do_test badutf-1.18 {
+ sqlite3_exec db2 {SELECT hex('%e0') AS x}
+ } {0 {x FFFD}}
+ do_test badutf-1.19 {
+ sqlite3_exec db2 {SELECT hex('%f0') AS x}
+ } {0 {x FFFD}}
+ do_test badutf-1.20 {
+ sqlite3_exec db2 {SELECT hex('%ff') AS x}
+ } {0 {x FFFD}}
+}
+
+
+ifcapable bloblit {
+ do_test badutf-2.1 {
+ sqlite3_exec db {SELECT '%80'=CAST(x'80' AS text) AS x}
+ } {0 {x 1}}
+ do_test badutf-2.2 {
+ sqlite3_exec db {SELECT CAST('%80' AS blob)=x'80' AS x}
+ } {0 {x 1}}
+}
+
+do_test badutf-3.1 {
+ sqlite3_exec db {SELECT length('%80') AS x}
+} {0 {x 1}}
+do_test badutf-3.2 {
+ sqlite3_exec db {SELECT length('%61%62%63') AS x}
+} {0 {x 3}}
+do_test badutf-3.3 {
+ sqlite3_exec db {SELECT length('%7f%80%81') AS x}
+} {0 {x 3}}
+do_test badutf-3.4 {
+ sqlite3_exec db {SELECT length('%61%c0') AS x}
+} {0 {x 2}}
+do_test badutf-3.5 {
+ sqlite3_exec db {SELECT length('%61%c0%80%80%80%80%80%80%80%80%80%80') AS x}
+} {0 {x 2}}
+do_test badutf-3.6 {
+ sqlite3_exec db {SELECT length('%c0%80%80%80%80%80%80%80%80%80%80') AS x}
+} {0 {x 1}}
+do_test badutf-3.7 {
+ sqlite3_exec db {SELECT length('%80%80%80%80%80%80%80%80%80%80') AS x}
+} {0 {x 10}}
+do_test badutf-3.8 {
+ sqlite3_exec db {SELECT length('%80%80%80%80%80%f0%80%80%80%80') AS x}
+} {0 {x 6}}
+do_test badutf-3.9 {
+ sqlite3_exec db {SELECT length('%80%80%80%80%80%f0%80%80%80%ff') AS x}
+} {0 {x 7}}
+
+do_test badutf-4.1 {
+ sqlite3_exec db {SELECT hex(trim('%80%80%80%f0%80%80%80%ff','%80%ff')) AS x}
+} {0 {x F0}}
+do_test badutf-4.2 {
+ sqlite3_exec db {SELECT hex(ltrim('%80%80%80%f0%80%80%80%ff','%80%ff')) AS x}
+} {0 {x F0808080FF}}
+do_test badutf-4.3 {
+ sqlite3_exec db {SELECT hex(rtrim('%80%80%80%f0%80%80%80%ff','%80%ff')) AS x}
+} {0 {x 808080F0}}
+do_test badutf-4.4 {
+ sqlite3_exec db {SELECT hex(trim('%80%80%80%f0%80%80%80%ff','%ff%80')) AS x}
+} {0 {x 808080F0808080FF}}
+do_test badutf-4.5 {
+ sqlite3_exec db {SELECT hex(trim('%ff%80%80%f0%80%80%80%ff','%ff%80')) AS x}
+} {0 {x 80F0808080FF}}
+do_test badutf-4.6 {
+ sqlite3_exec db {SELECT hex(trim('%ff%80%f0%80%80%80%ff','%ff%80')) AS x}
+} {0 {x F0808080FF}}
+do_test badutf-4.7 {
+ sqlite3_exec db {SELECT hex(trim('%ff%80%f0%80%80%80%ff','%ff%80%80')) AS x}
+} {0 {x FF80F0808080FF}}
+
+db2 close
+finish_test
diff --git a/test/badutf2.test b/test/badutf2.test
new file mode 100644
index 0000000..36b40fb
--- /dev/null
+++ b/test/badutf2.test
@@ -0,0 +1,121 @@
+# 2011 March 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file checks to make sure SQLite is able to gracEFully
+# handle malformed UTF-8.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc utf8_to_ustr2 {s} {
+ set r ""
+ foreach i [split $s ""] {
+ scan $i %c c
+ append r [format \\u%04.4X $c]
+ }
+ set r
+}
+
+proc utf8_to_hstr {in} {
+ regsub -all -- {(..)} $in {%[format "%s" \1]} out
+ subst $out
+}
+
+proc utf8_to_xstr {in} {
+ regsub -all -- {(..)} $in {\\\\x[format "%s" \1]} out
+ subst $out
+}
+
+proc utf8_to_ustr {in} {
+ regsub -all -- {(..)} $in {\\\\u[format "%04.4X" 0x\1]} out
+ subst $out
+}
+
+do_test badutf2-1.0 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval "PRAGMA encoding = 'UTF-8'"
+} {}
+
+do_test badutf2-4.0 {
+ set S [sqlite3_prepare_v2 db "SELECT ?" -1 dummy]
+ sqlite3_expired $S
+} {0}
+
+foreach { i len uval xstr ustr u2u } {
+1 1 00 \x00 {} {}
+2 1 01 \x01 "\\u0001" 01
+3 1 3F \x3F "\\u003F" 3F
+4 1 7F \x7F "\\u007F" 7F
+5 1 80 \x80 "\\u0080" C280
+6 1 C3BF \xFF "\\u00FF" C3BF
+7 3 EFBFBD \xEF\xBF\xBD "\\uFFFD" {}
+} {
+
+ set hstr [ utf8_to_hstr $uval ]
+
+ ifcapable bloblit {
+ if {$hstr != "%00"} {
+ do_test badutf2-2.1.$i {
+ set sql "SELECT '$hstr'=CAST(x'$uval' AS text) AS x;"
+ set res [ sqlite3_exec db $sql ]
+ lindex [ lindex $res 1] 1
+ } {1}
+ do_test badutf2-2.2.$i {
+ set sql "SELECT CAST('$hstr' AS blob)=x'$uval' AS x;"
+ set res [ sqlite3_exec db $sql ]
+ lindex [ lindex $res 1] 1
+ } {1}
+ }
+ do_test badutf2-2.3.$i {
+ set sql "SELECT hex(CAST(x'$uval' AS text)) AS x;"
+ set res [ sqlite3_exec db $sql ]
+ lindex [ lindex $res 1] 1
+ } $uval
+ do_test badutf2-2.4.$i {
+ set sql "SELECT hex(CAST(x'$uval' AS text)) AS x;"
+ set res [ sqlite3_exec db $sql ]
+ lindex [ lindex $res 1] 1
+ } $uval
+ }
+
+ if {$hstr != "%00"} {
+ do_test badutf2-3.1.$i {
+ set sql "SELECT hex('$hstr') AS x;"
+ set res [ sqlite3_exec db $sql ]
+ lindex [ lindex $res 1] 1
+ } $uval
+ }
+
+ do_test badutf2-4.1.$i {
+ sqlite3_reset $S
+ sqlite3_bind_text $S 1 $xstr $len
+ sqlite3_step $S
+ utf8_to_ustr2 [ sqlite3_column_text $S 0 ]
+ } $ustr
+
+ ifcapable debug {
+ do_test badutf2-5.1.$i {
+ utf8_to_utf8 $uval
+ } $u2u
+ }
+
+}
+
+do_test badutf2-4.2 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+
+finish_test
diff --git a/test/between.test b/test/between.test
new file mode 100644
index 0000000..4543675
--- /dev/null
+++ b/test/between.test
@@ -0,0 +1,113 @@
+# 2005 July 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the use of indices in WHERE clauses
+# when the WHERE clause contains the BETWEEN operator.
+#
+# $Id: between.test,v 1.2 2006/01/17 09:35:02 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+do_test between-1.0 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(w int, x int, y int, z int);
+ }
+ for {set i 1} {$i<=100} {incr i} {
+ set w $i
+ set x [expr {int(log($i)/log(2))}]
+ set y [expr {$i*$i + 2*$i + 1}]
+ set z [expr {$x+$y}]
+ ifcapable tclvar {
+ # Random unplanned test of the $varname variable syntax.
+ execsql {INSERT INTO t1 VALUES($::w,$::x,$::y,$::z)}
+ } else {
+ # If the $varname syntax is not available, use the regular variable
+ # declaration syntax.
+ execsql {INSERT INTO t1 VALUES(:w,:x,:y,:z)}
+ }
+ }
+ execsql {
+ CREATE UNIQUE INDEX i1w ON t1(w);
+ CREATE INDEX i1xy ON t1(x,y);
+ CREATE INDEX i1zyx ON t1(z,y,x);
+ COMMIT;
+ }
+} {}
+
+# This procedure executes the SQL. Then it appends to the result the
+# "sort" or "nosort" keyword depending on whether or not any sorting
+# is done. Then it appends the ::sqlite_query_plan variable.
+#
+proc queryplan {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ if {$::sqlite_sort_count} {set x sort} {set x nosort}
+ lappend data $x
+ return [concat $data $::sqlite_query_plan]
+}
+
+do_test between-1.1.1 {
+ queryplan {
+ SELECT * FROM t1 WHERE w BETWEEN 5 AND 6 ORDER BY +w
+ }
+} {5 2 36 38 6 2 49 51 sort t1 i1w}
+do_test between-1.1.2 {
+ queryplan {
+ SELECT * FROM t1 WHERE +w BETWEEN 5 AND 6 ORDER BY +w
+ }
+} {5 2 36 38 6 2 49 51 sort t1 {}}
+do_test between-1.2.1 {
+ queryplan {
+ SELECT * FROM t1 WHERE w BETWEEN 5 AND 65-y ORDER BY +w
+ }
+} {5 2 36 38 6 2 49 51 sort t1 i1w}
+do_test between-1.2.2 {
+ queryplan {
+ SELECT * FROM t1 WHERE +w BETWEEN 5 AND 65-y ORDER BY +w
+ }
+} {5 2 36 38 6 2 49 51 sort t1 {}}
+do_test between-1.3.1 {
+ queryplan {
+ SELECT * FROM t1 WHERE w BETWEEN 41-y AND 6 ORDER BY +w
+ }
+} {5 2 36 38 6 2 49 51 sort t1 i1w}
+do_test between-1.3.2 {
+ queryplan {
+ SELECT * FROM t1 WHERE +w BETWEEN 41-y AND 6 ORDER BY +w
+ }
+} {5 2 36 38 6 2 49 51 sort t1 {}}
+do_test between-1.4 {
+ queryplan {
+ SELECT * FROM t1 WHERE w BETWEEN 41-y AND 65-y ORDER BY +w
+ }
+} {5 2 36 38 6 2 49 51 sort t1 {}}
+do_test between-1.5.1 {
+ queryplan {
+ SELECT * FROM t1 WHERE 26 BETWEEN y AND z ORDER BY +w
+ }
+} {4 2 25 27 sort t1 i1zyx}
+do_test between-1.5.2 {
+ queryplan {
+ SELECT * FROM t1 WHERE 26 BETWEEN +y AND z ORDER BY +w
+ }
+} {4 2 25 27 sort t1 i1zyx}
+do_test between-1.5.3 {
+ queryplan {
+ SELECT * FROM t1 WHERE 26 BETWEEN y AND +z ORDER BY +w
+ }
+} {4 2 25 27 sort t1 {}}
+
+
+finish_test
diff --git a/test/bigfile.test b/test/bigfile.test
new file mode 100644
index 0000000..52d74ed
--- /dev/null
+++ b/test/bigfile.test
@@ -0,0 +1,200 @@
+# 2002 November 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script testing the ability of SQLite to handle database
+# files larger than 4GB.
+#
+# $Id: bigfile.test,v 1.12 2009/03/05 04:27:08 shane Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for this file, as the database is manipulated using
+# external methods (the [fake_big_file] and [hexio_write] commands).
+#
+do_not_use_codec
+
+# If SQLITE_DISABLE_LFS is defined, omit this file.
+ifcapable !lfs {
+ finish_test
+ return
+}
+
+# These tests only work for Tcl version 8.4 and later. Prior to 8.4,
+# Tcl was unable to handle large files.
+#
+scan $::tcl_version %f vx
+if {$vx<8.4} return
+
+# Mac OS X does not handle large files efficiently. So skip this test
+# on that platform.
+if {$tcl_platform(os)=="Darwin"} return
+
+# This is the md5 checksum of all the data in table t1 as created
+# by the first test. We will use this number to make sure that data
+# never changes.
+#
+set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf}
+
+do_test bigfile-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz');
+ INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
+ INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
+ INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
+ INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
+ INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
+ INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
+ INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
+ COMMIT;
+ }
+ execsql {
+ SELECT md5sum(x) FROM t1;
+ }
+} $::MAGIC_SUM
+
+# Try to create a large file - a file that is larger than 2^32 bytes.
+# If this fails, it means that the system being tested does not support
+# large files. So skip all of the remaining tests in this file.
+#
+db close
+if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} {
+ puts "**** Unable to create a file larger than 4096 MB. *****"
+ finish_test
+ return
+}
+hexio_write test.db 28 00000000
+
+do_test bigfile-1.2 {
+ sqlite3 db test.db
+ execsql {
+ SELECT md5sum(x) FROM t1;
+ }
+} $::MAGIC_SUM
+
+# The previous test may fail on some systems because they are unable
+# to handle large files. If that is so, then skip all of the following
+# tests. We will know the above test failed because the "db" command
+# does not exist.
+#
+if {[llength [info command db]]<=0} {
+ puts "**** Large file support appears to be broken. *****"
+ finish_test
+ return
+}
+
+do_test bigfile-1.3 {
+ execsql {
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ SELECT md5sum(x) FROM t2;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.4 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT md5sum(x) FROM t1;
+ }
+} $::MAGIC_SUM
+
+db close
+if {[catch {fake_big_file 8192 [pwd]/test.db}]} {
+ puts "**** Unable to create a file larger than 8192 MB. *****"
+ finish_test
+ return
+}
+hexio_write test.db 28 00000000
+
+do_test bigfile-1.5 {
+ sqlite3 db test.db
+ execsql {
+ SELECT md5sum(x) FROM t1;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.6 {
+ sqlite3 db test.db
+ execsql {
+ SELECT md5sum(x) FROM t2;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.7 {
+ execsql {
+ CREATE TABLE t3 AS SELECT * FROM t1;
+ SELECT md5sum(x) FROM t3;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.8 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT md5sum(x) FROM t1;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.9 {
+ execsql {
+ SELECT md5sum(x) FROM t2;
+ }
+} $::MAGIC_SUM
+
+db close
+if {[catch {fake_big_file 16384 [pwd]/test.db}]} {
+ puts "**** Unable to create a file larger than 16384 MB. *****"
+ finish_test
+ return
+}
+hexio_write test.db 28 00000000
+
+do_test bigfile-1.10 {
+ sqlite3 db test.db
+ execsql {
+ SELECT md5sum(x) FROM t1;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.11 {
+ sqlite3 db test.db
+ execsql {
+ SELECT md5sum(x) FROM t2;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.12 {
+ sqlite3 db test.db
+ execsql {
+ SELECT md5sum(x) FROM t3;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.13 {
+ execsql {
+ CREATE TABLE t4 AS SELECT * FROM t1;
+ SELECT md5sum(x) FROM t4;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.14 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT md5sum(x) FROM t1;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.15 {
+ execsql {
+ SELECT md5sum(x) FROM t2;
+ }
+} $::MAGIC_SUM
+do_test bigfile-1.16 {
+ execsql {
+ SELECT md5sum(x) FROM t3;
+ }
+} $::MAGIC_SUM
+
+finish_test
diff --git a/test/bigrow.test b/test/bigrow.test
new file mode 100644
index 0000000..fa59c36
--- /dev/null
+++ b/test/bigrow.test
@@ -0,0 +1,223 @@
+# 2001 September 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is stressing the library by putting large amounts
+# of data in a single row of a table.
+#
+# $Id: bigrow.test,v 1.5 2004/08/07 23:54:48 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Make a big string that we can use for test data
+#
+do_test bigrow-1.0 {
+ set ::bigstr {}
+ for {set i 1} {$i<=9999} {incr i} {
+ set sep [string index "abcdefghijklmnopqrstuvwxyz" [expr {$i%26}]]
+ append ::bigstr "$sep [format %04d $i] "
+ }
+ string length $::bigstr
+} {69993}
+
+# Make a table into which we can insert some but records.
+#
+do_test bigrow-1.1 {
+ execsql {
+ CREATE TABLE t1(a text, b text, c text);
+ SELECT name FROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name
+ }
+} {t1}
+
+do_test bigrow-1.2 {
+ set ::big1 [string range $::bigstr 0 65519]
+ set sql "INSERT INTO t1 VALUES('abc',"
+ append sql "'$::big1', 'xyz');"
+ execsql $sql
+ execsql {SELECT a, c FROM t1}
+} {abc xyz}
+do_test bigrow-1.3 {
+ execsql {SELECT b FROM t1}
+} [list $::big1]
+do_test bigrow-1.4 {
+ set ::big2 [string range $::bigstr 0 65520]
+ set sql "INSERT INTO t1 VALUES('abc2',"
+ append sql "'$::big2', 'xyz2');"
+ set r [catch {execsql $sql} msg]
+ lappend r $msg
+} {0 {}}
+do_test bigrow-1.4.1 {
+ execsql {SELECT b FROM t1 ORDER BY c}
+} [list $::big1 $::big2]
+do_test bigrow-1.4.2 {
+ execsql {SELECT c FROM t1 ORDER BY c}
+} {xyz xyz2}
+do_test bigrow-1.4.3 {
+ execsql {DELETE FROM t1 WHERE a='abc2'}
+ execsql {SELECT c FROM t1}
+} {xyz}
+
+do_test bigrow-1.5 {
+ execsql {
+ UPDATE t1 SET a=b, b=a;
+ SELECT b,c FROM t1
+ }
+} {abc xyz}
+do_test bigrow-1.6 {
+ execsql {
+ SELECT * FROM t1
+ }
+} [list $::big1 abc xyz]
+do_test bigrow-1.7 {
+ execsql {
+ INSERT INTO t1 VALUES('1','2','3');
+ INSERT INTO t1 VALUES('A','B','C');
+ SELECT b FROM t1 WHERE a=='1';
+ }
+} {2}
+do_test bigrow-1.8 {
+ execsql "SELECT b FROM t1 WHERE a=='$::big1'"
+} {abc}
+do_test bigrow-1.9 {
+ execsql "SELECT b FROM t1 WHERE a!='$::big1' ORDER BY a"
+} {2 B}
+
+# Try doing some indexing on big columns
+#
+do_test bigrow-2.1 {
+ execsql {
+ CREATE INDEX i1 ON t1(a)
+ }
+ execsql "SELECT b FROM t1 WHERE a=='$::big1'"
+} {abc}
+do_test bigrow-2.2 {
+ execsql {
+ UPDATE t1 SET a=b, b=a
+ }
+ execsql "SELECT b FROM t1 WHERE a=='abc'"
+} [list $::big1]
+do_test bigrow-2.3 {
+ execsql {
+ UPDATE t1 SET a=b, b=a
+ }
+ execsql "SELECT b FROM t1 WHERE a=='$::big1'"
+} {abc}
+catch {unset ::bigstr}
+catch {unset ::big1}
+catch {unset ::big2}
+
+# Mosts of the tests above were created back when rows were limited in
+# size to 64K. Now rows can be much bigger. Test that logic. Also
+# make sure things work correctly at the transition boundries between
+# row sizes of 256 to 257 bytes and from 65536 to 65537 bytes.
+#
+# We begin by testing the 256..257 transition.
+#
+do_test bigrow-3.1 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');
+ }
+ execsql {SELECT a,length(b),c FROM t1}
+} {one 30 hi}
+do_test bigrow-3.2 {
+ execsql {
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ }
+ execsql {SELECT a,length(b),c FROM t1}
+} {one 240 hi}
+for {set i 1} {$i<10} {incr i} {
+ do_test bigrow-3.3.$i {
+ execsql "UPDATE t1 SET b=b||'$i'"
+ execsql {SELECT a,length(b),c FROM t1}
+ } "one [expr {240+$i}] hi"
+}
+
+# Now test the 65536..65537 row-size transition.
+#
+do_test bigrow-4.1 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');
+ }
+ execsql {SELECT a,length(b),c FROM t1}
+} {one 30 hi}
+do_test bigrow-4.2 {
+ execsql {
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ }
+ execsql {SELECT a,length(b),c FROM t1}
+} {one 122880 hi}
+do_test bigrow-4.3 {
+ execsql {
+ UPDATE t1 SET b=substr(b,1,65515)
+ }
+ execsql {SELECT a,length(b),c FROM t1}
+} {one 65515 hi}
+for {set i 1} {$i<10} {incr i} {
+ do_test bigrow-4.4.$i {
+ execsql "UPDATE t1 SET b=b||'$i'"
+ execsql {SELECT a,length(b),c FROM t1}
+ } "one [expr {65515+$i}] hi"
+}
+
+# Check to make sure the library recovers safely if a row contains
+# too much data.
+#
+do_test bigrow-5.1 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');
+ }
+ execsql {SELECT a,length(b),c FROM t1}
+} {one 30 hi}
+set i 1
+for {set sz 60} {$sz<1048560} {incr sz $sz} {
+ do_test bigrow-5.2.$i {
+ execsql {
+ UPDATE t1 SET b=b||b;
+ SELECT a,length(b),c FROM t1;
+ }
+ } "one $sz hi"
+ incr i
+}
+do_test bigrow-5.3 {
+ catchsql {UPDATE t1 SET b=b||b}
+} {0 {}}
+do_test bigrow-5.4 {
+ execsql {SELECT length(b) FROM t1}
+} 1966080
+do_test bigrow-5.5 {
+ catchsql {UPDATE t1 SET b=b||b}
+} {0 {}}
+do_test bigrow-5.6 {
+ execsql {SELECT length(b) FROM t1}
+} 3932160
+do_test bigrow-5.99 {
+ execsql {DROP TABLE t1}
+} {}
+
+finish_test
diff --git a/test/bind.test b/test/bind.test
new file mode 100644
index 0000000..34f3155
--- /dev/null
+++ b/test/bind.test
@@ -0,0 +1,758 @@
+# 2003 September 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script testing the sqlite_bind API.
+#
+# $Id: bind.test,v 1.48 2009/07/22 07:27:57 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc sqlite_step {stmt N VALS COLS} {
+ upvar VALS vals
+ upvar COLS cols
+ set vals [list]
+ set cols [list]
+
+ set rc [sqlite3_step $stmt]
+ for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {
+ lappend cols [sqlite3_column_name $stmt $i]
+ }
+ for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} {
+ lappend vals [sqlite3_column_text $stmt $i]
+ }
+
+ return $rc
+}
+
+do_test bind-1.1 {
+ set DB [sqlite3_connection_pointer db]
+ execsql {CREATE TABLE t1(a,b,c);}
+ set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:1,?,:abc)} -1 TAIL]
+ set TAIL
+} {}
+do_test bind-1.1.1 {
+ sqlite3_bind_parameter_count $VM
+} 3
+do_test bind-1.1.2 {
+ sqlite3_bind_parameter_name $VM 1
+} {:1}
+do_test bind-1.1.3 {
+ sqlite3_bind_parameter_name $VM 2
+} {}
+do_test bind-1.1.4 {
+ sqlite3_bind_parameter_name $VM 3
+} {:abc}
+do_test bind-1.2 {
+ sqlite_step $VM N VALUES COLNAMES
+} {SQLITE_DONE}
+do_test bind-1.3 {
+ execsql {SELECT rowid, * FROM t1}
+} {1 {} {} {}}
+do_test bind-1.4 {
+ sqlite3_reset $VM
+ sqlite_bind $VM 1 {test value 1} normal
+ sqlite_step $VM N VALUES COLNAMES
+} SQLITE_DONE
+do_test bind-1.5 {
+ execsql {SELECT rowid, * FROM t1}
+} {1 {} {} {} 2 {test value 1} {} {}}
+do_test bind-1.6 {
+ sqlite3_reset $VM
+ sqlite_bind $VM 3 {'test value 2'} normal
+ sqlite_step $VM N VALUES COLNAMES
+} SQLITE_DONE
+do_test bind-1.7 {
+ execsql {SELECT rowid, * FROM t1}
+} {1 {} {} {} 2 {test value 1} {} {} 3 {test value 1} {} {'test value 2'}}
+do_test bind-1.8 {
+ sqlite3_reset $VM
+ set sqlite_static_bind_value 123
+ sqlite_bind $VM 1 {} static
+ sqlite_bind $VM 2 {abcdefg} normal
+ sqlite_bind $VM 3 {} null
+ execsql {DELETE FROM t1}
+ sqlite_step $VM N VALUES COLNAMES
+ execsql {SELECT rowid, * FROM t1}
+} {1 123 abcdefg {}}
+do_test bind-1.9 {
+ sqlite3_reset $VM
+ sqlite_bind $VM 1 {456} normal
+ sqlite_step $VM N VALUES COLNAMES
+ execsql {SELECT rowid, * FROM t1}
+} {1 123 abcdefg {} 2 456 abcdefg {}}
+
+do_test bind-1.10 {
+ set rc [catch {
+ sqlite3_prepare db {INSERT INTO t1 VALUES($abc:123,?,:abc)} -1 TAIL
+ } msg]
+ lappend rc $msg
+} {1 {(1) near ":123": syntax error}}
+do_test bind-1.11 {
+ set rc [catch {
+ sqlite3_prepare db {INSERT INTO t1 VALUES(@abc:xyz,?,:abc)} -1 TAIL
+ } msg]
+ lappend rc $msg
+} {1 {(1) near ":xyz": syntax error}}
+
+do_test bind-1.99 {
+ sqlite3_finalize $VM
+} SQLITE_OK
+
+# Prepare the statement in different ways depending on whether or not
+# the $var processing is compiled into the library.
+#
+ifcapable {tclvar} {
+ do_test bind-2.1 {
+ execsql {
+ DELETE FROM t1;
+ }
+ set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES($one,$::two,$x(-z-))}\
+ -1 TX]
+ set TX
+ } {}
+ set v1 {$one}
+ set v2 {$::two}
+ set v3 {$x(-z-)}
+}
+ifcapable {!tclvar} {
+ do_test bind-2.1 {
+ execsql {
+ DELETE FROM t1;
+ }
+ set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:one,:two,:_)} -1 TX]
+ set TX
+ } {}
+ set v1 {:one}
+ set v2 {:two}
+ set v3 {:_}
+}
+
+do_test bind-2.1.1 {
+ sqlite3_bind_parameter_count $VM
+} 3
+do_test bind-2.1.2 {
+ sqlite3_bind_parameter_name $VM 1
+} $v1
+do_test bind-2.1.3 {
+ sqlite3_bind_parameter_name $VM 2
+} $v2
+do_test bind-2.1.4 {
+ sqlite3_bind_parameter_name $VM 3
+} $v3
+do_test bind-2.1.5 {
+ sqlite3_bind_parameter_index $VM $v1
+} 1
+do_test bind-2.1.6 {
+ sqlite3_bind_parameter_index $VM $v2
+} 2
+do_test bind-2.1.7 {
+ sqlite3_bind_parameter_index $VM $v3
+} 3
+do_test bind-2.1.8 {
+ sqlite3_bind_parameter_index $VM {:hi}
+} 0
+
+# 32 bit Integers
+do_test bind-2.2 {
+ sqlite3_bind_int $VM 1 123
+ sqlite3_bind_int $VM 2 456
+ sqlite3_bind_int $VM 3 789
+ sqlite_step $VM N VALUES COLNAMES
+ sqlite3_reset $VM
+ execsql {SELECT rowid, * FROM t1}
+} {1 123 456 789}
+do_test bind-2.3 {
+ sqlite3_bind_int $VM 2 -2000000000
+ sqlite3_bind_int $VM 3 2000000000
+ sqlite_step $VM N VALUES COLNAMES
+ sqlite3_reset $VM
+ execsql {SELECT rowid, * FROM t1}
+} {1 123 456 789 2 123 -2000000000 2000000000}
+do_test bind-2.4 {
+ execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
+} {integer integer integer integer integer integer}
+do_test bind-2.5 {
+ execsql {
+ DELETE FROM t1;
+ }
+} {}
+
+# 64 bit Integers
+do_test bind-3.1 {
+ sqlite3_bind_int64 $VM 1 32
+ sqlite3_bind_int64 $VM 2 -2000000000000
+ sqlite3_bind_int64 $VM 3 2000000000000
+ sqlite_step $VM N VALUES COLNAMES
+ sqlite3_reset $VM
+ execsql {SELECT rowid, * FROM t1}
+} {1 32 -2000000000000 2000000000000}
+do_test bind-3.2 {
+ execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
+} {integer integer integer}
+do_test bind-3.3 {
+ execsql {
+ DELETE FROM t1;
+ }
+} {}
+
+# Doubles
+do_test bind-4.1 {
+ sqlite3_bind_double $VM 1 1234.1234
+ sqlite3_bind_double $VM 2 0.00001
+ sqlite3_bind_double $VM 3 123456789
+ sqlite_step $VM N VALUES COLNAMES
+ sqlite3_reset $VM
+ set x [execsql {SELECT rowid, * FROM t1}]
+ regsub {1e-005} $x {1e-05} y
+ set y
+} {1 1234.1234 1e-05 123456789.0}
+do_test bind-4.2 {
+ execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
+} {real real real}
+do_test bind-4.3 {
+ execsql {
+ DELETE FROM t1;
+ }
+} {}
+do_test bind-4.4 {
+ sqlite3_bind_double $VM 1 NaN
+ sqlite3_bind_double $VM 2 1e300
+ sqlite3_bind_double $VM 3 -1e-300
+ sqlite_step $VM N VALUES COLNAMES
+ sqlite3_reset $VM
+ set x [execsql {SELECT rowid, * FROM t1}]
+ regsub {1e-005} $x {1e-05} y
+ set y
+} {1 {} 1e+300 -1e-300}
+do_test bind-4.5 {
+ execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
+} {null real real}
+do_test bind-4.6 {
+ execsql {
+ DELETE FROM t1;
+ }
+} {}
+
+# NULL
+do_test bind-5.1 {
+ sqlite3_bind_null $VM 1
+ sqlite3_bind_null $VM 2
+ sqlite3_bind_null $VM 3
+ sqlite_step $VM N VALUES COLNAMES
+ sqlite3_reset $VM
+ execsql {SELECT rowid, * FROM t1}
+} {1 {} {} {}}
+do_test bind-5.2 {
+ execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
+} {null null null}
+do_test bind-5.3 {
+ execsql {
+ DELETE FROM t1;
+ }
+} {}
+
+# UTF-8 text
+do_test bind-6.1 {
+ sqlite3_bind_text $VM 1 hellothere 5
+ sqlite3_bind_text $VM 2 ".." 1
+ sqlite3_bind_text $VM 3 world\000 -1
+ sqlite_step $VM N VALUES COLNAMES
+ sqlite3_reset $VM
+ execsql {SELECT rowid, * FROM t1}
+} {1 hello . world}
+do_test bind-6.2 {
+ execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
+} {text text text}
+do_test bind-6.3 {
+ execsql {
+ DELETE FROM t1;
+ }
+} {}
+
+# Make sure zeros in a string work.
+#
+do_test bind-6.4 {
+ db eval {DELETE FROM t1}
+ sqlite3_bind_text $VM 1 hello\000there\000 12
+ sqlite3_bind_text $VM 2 hello\000there\000 11
+ sqlite3_bind_text $VM 3 hello\000there\000 -1
+ sqlite_step $VM N VALUES COLNAMES
+ sqlite3_reset $VM
+ execsql {SELECT * FROM t1}
+} {hello hello hello}
+set enc [db eval {PRAGMA encoding}]
+if {$enc=="UTF-8" || $enc==""} {
+ do_test bind-6.5 {
+ execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
+ } {68656C6C6F00746865726500 68656C6C6F007468657265 68656C6C6F}
+} elseif {$enc=="UTF-16le"} {
+ do_test bind-6.5 {
+ execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
+ } {680065006C006C006F000000740068006500720065000000 680065006C006C006F00000074006800650072006500 680065006C006C006F00}
+} elseif {$enc=="UTF-16be"} {
+ do_test bind-6.5 {
+ execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
+ } {00680065006C006C006F0000007400680065007200650000 00680065006C006C006F000000740068006500720065 00680065006C006C006F}
+} else {
+ do_test bind-6.5 {
+ set "Unknown database encoding: $::enc"
+ } {}
+}
+do_test bind-6.6 {
+ execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
+} {text text text}
+do_test bind-6.7 {
+ execsql {
+ DELETE FROM t1;
+ }
+} {}
+
+# UTF-16 text
+ifcapable {utf16} {
+ do_test bind-7.1 {
+ sqlite3_bind_text16 $VM 1 [encoding convertto unicode hellothere] 10
+ sqlite3_bind_text16 $VM 2 [encoding convertto unicode ""] 0
+ sqlite3_bind_text16 $VM 3 [encoding convertto unicode world] 10
+ sqlite_step $VM N VALUES COLNAMES
+ sqlite3_reset $VM
+ execsql {SELECT rowid, * FROM t1}
+ } {1 hello {} world}
+ do_test bind-7.2 {
+ execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
+ } {text text text}
+ do_test bind-7.3 {
+ db eval {DELETE FROM t1}
+ sqlite3_bind_text16 $VM 1 [encoding convertto unicode hi\000yall\000] 16
+ sqlite3_bind_text16 $VM 2 [encoding convertto unicode hi\000yall\000] 14
+ sqlite3_bind_text16 $VM 3 [encoding convertto unicode hi\000yall\000] -1
+ sqlite_step $VM N VALUES COLNAMES
+ sqlite3_reset $VM
+ execsql {SELECT * FROM t1}
+ } {hi hi hi}
+ if {$enc=="UTF-8"} {
+ do_test bind-7.4 {
+ execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
+ } {68690079616C6C00 68690079616C6C 6869}
+ } elseif {$enc=="UTF-16le"} {
+ do_test bind-7.4 {
+ execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
+ } {680069000000790061006C006C000000 680069000000790061006C006C00 68006900}
+ } elseif {$enc=="UTF-16be"} {
+ do_test bind-7.4 {
+ execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
+ } {00680069000000790061006C006C0000 00680069000000790061006C006C 00680069}
+ }
+ do_test bind-7.5 {
+ execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
+ } {text text text}
+}
+do_test bind-7.99 {
+ execsql {DELETE FROM t1;}
+} {}
+
+# Test that the 'out of range' error works.
+do_test bind-8.1 {
+ catch { sqlite3_bind_null $VM 0 }
+} {1}
+do_test bind-8.2 {
+ sqlite3_errmsg $DB
+} {bind or column index out of range}
+ifcapable {utf16} {
+ do_test bind-8.3 {
+ encoding convertfrom unicode [sqlite3_errmsg16 $DB]
+ } {bind or column index out of range}
+}
+do_test bind-8.4 {
+ sqlite3_bind_null $VM 1
+ sqlite3_errmsg $DB
+} {not an error}
+do_test bind-8.5 {
+ catch { sqlite3_bind_null $VM 4 }
+} {1}
+do_test bind-8.6 {
+ sqlite3_errmsg $DB
+} {bind or column index out of range}
+ifcapable {utf16} {
+ do_test bind-8.7 {
+ encoding convertfrom unicode [sqlite3_errmsg16 $DB]
+ } {bind or column index out of range}
+}
+
+do_test bind-8.8 {
+ catch { sqlite3_bind_blob $VM 0 "abc" 3 }
+} {1}
+do_test bind-8.9 {
+ catch { sqlite3_bind_blob $VM 4 "abc" 3 }
+} {1}
+do_test bind-8.10 {
+ catch { sqlite3_bind_text $VM 0 "abc" 3 }
+} {1}
+ifcapable {utf16} {
+ do_test bind-8.11 {
+ catch { sqlite3_bind_text16 $VM 4 "abc" 2 }
+ } {1}
+}
+do_test bind-8.12 {
+ catch { sqlite3_bind_int $VM 0 5 }
+} {1}
+do_test bind-8.13 {
+ catch { sqlite3_bind_int $VM 4 5 }
+} {1}
+do_test bind-8.14 {
+ catch { sqlite3_bind_double $VM 0 5.0 }
+} {1}
+do_test bind-8.15 {
+ catch { sqlite3_bind_double $VM 4 6.0 }
+} {1}
+
+do_test bind-8.99 {
+ sqlite3_finalize $VM
+} SQLITE_OK
+
+set iMaxVar $SQLITE_MAX_VARIABLE_NUMBER
+set zError "(1) variable number must be between ?1 and ?$iMaxVar"
+do_test bind-9.1 {
+ execsql {
+ CREATE TABLE t2(a,b,c,d,e,f);
+ }
+ set rc [catch {
+ sqlite3_prepare $DB {
+ INSERT INTO t2(a) VALUES(?0)
+ } -1 TAIL
+ } msg]
+ lappend rc $msg
+} [list 1 $zError]
+do_test bind-9.2 {
+ set rc [catch {
+ sqlite3_prepare $DB "INSERT INTO t2(a) VALUES(?[expr $iMaxVar+1])" -1 TAIL
+ } msg]
+ lappend rc $msg
+} [list 1 $zError]
+do_test bind-9.3.1 {
+ set VM [
+ sqlite3_prepare $DB "
+ INSERT INTO t2(a,b) VALUES(?1,?$iMaxVar)
+ " -1 TAIL
+ ]
+ sqlite3_bind_parameter_count $VM
+} $iMaxVar
+catch {sqlite3_finalize $VM}
+do_test bind-9.3.2 {
+ set VM [
+ sqlite3_prepare $DB "
+ INSERT INTO t2(a,b) VALUES(?2,?[expr $iMaxVar - 1])
+ " -1 TAIL
+ ]
+ sqlite3_bind_parameter_count $VM
+} [expr {$iMaxVar - 1}]
+catch {sqlite3_finalize $VM}
+do_test bind-9.4 {
+ set VM [
+ sqlite3_prepare $DB "
+ INSERT INTO t2(a,b,c,d) VALUES(?1,?[expr $iMaxVar - 2],?,?)
+ " -1 TAIL
+ ]
+ sqlite3_bind_parameter_count $VM
+} $iMaxVar
+do_test bind-9.5 {
+ sqlite3_bind_int $VM 1 1
+ sqlite3_bind_int $VM [expr $iMaxVar - 2] 999
+ sqlite3_bind_int $VM [expr $iMaxVar - 1] 1000
+ sqlite3_bind_int $VM $iMaxVar 1001
+ sqlite3_step $VM
+} SQLITE_DONE
+do_test bind-9.6 {
+ sqlite3_finalize $VM
+} SQLITE_OK
+do_test bind-9.7 {
+ execsql {SELECT * FROM t2}
+} {1 999 1000 1001 {} {}}
+
+ifcapable {tclvar} {
+ do_test bind-10.1 {
+ set VM [
+ sqlite3_prepare $DB {
+ INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,$abc,:abc,$ab,$abc,:abc)
+ } -1 TAIL
+ ]
+ sqlite3_bind_parameter_count $VM
+ } 3
+ set v1 {$abc}
+ set v2 {$ab}
+}
+ifcapable {!tclvar} {
+ do_test bind-10.1 {
+ set VM [
+ sqlite3_prepare $DB {
+ INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,:xyz,:abc,:xy,:xyz,:abc)
+ } -1 TAIL
+ ]
+ sqlite3_bind_parameter_count $VM
+ } 3
+ set v1 {:xyz}
+ set v2 {:xy}
+}
+do_test bind-10.2 {
+ sqlite3_bind_parameter_index $VM :abc
+} 1
+do_test bind-10.3 {
+ sqlite3_bind_parameter_index $VM $v1
+} 2
+do_test bind-10.4 {
+ sqlite3_bind_parameter_index $VM $v2
+} 3
+do_test bind-10.5 {
+ sqlite3_bind_parameter_name $VM 1
+} :abc
+do_test bind-10.6 {
+ sqlite3_bind_parameter_name $VM 2
+} $v1
+do_test bind-10.7 {
+ sqlite3_bind_parameter_name $VM 3
+} $v2
+do_test bind-10.7.1 {
+ sqlite3_bind_parameter_name 0 1 ;# Ignore if VM is NULL
+} {}
+do_test bind-10.7.2 {
+ sqlite3_bind_parameter_name $VM 0 ;# Ignore if index too small
+} {}
+do_test bind-10.7.3 {
+ sqlite3_bind_parameter_name $VM 4 ;# Ignore if index is too big
+} {}
+do_test bind-10.8 {
+ sqlite3_bind_int $VM 1 1
+ sqlite3_bind_int $VM 2 2
+ sqlite3_bind_int $VM 3 3
+ sqlite3_step $VM
+} SQLITE_DONE
+do_test bind-10.8.1 {
+ # Binding attempts after program start should fail
+ set rc [catch {
+ sqlite3_bind_int $VM 1 1
+ } msg]
+ lappend rc $msg
+} {1 {}}
+do_test bind-10.9 {
+ sqlite3_finalize $VM
+} SQLITE_OK
+do_test bind-10.10 {
+ execsql {SELECT * FROM t2}
+} {1 999 1000 1001 {} {} 1 2 1 3 2 1}
+
+# Ticket #918
+#
+do_test bind-10.11 {
+ # catch {sqlite3_finalize $VM}
+ set VM [
+ sqlite3_prepare $DB {
+ INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,?,?4,:pqr,:abc,?4)
+ } -1 TAIL
+ ]
+ sqlite3_bind_parameter_count $VM
+} 5
+do_test bind-10.11.1 {
+ sqlite3_bind_parameter_index 0 :xyz ;# ignore NULL VM arguments
+} 0
+do_test bind-10.12 {
+ sqlite3_bind_parameter_index $VM :xyz
+} 0
+do_test bind-10.13 {
+ sqlite3_bind_parameter_index $VM {}
+} 0
+do_test bind-10.14 {
+ sqlite3_bind_parameter_index $VM :pqr
+} 5
+do_test bind-10.15 {
+ sqlite3_bind_parameter_index $VM ?4
+} 4
+do_test bind-10.16 {
+ sqlite3_bind_parameter_name $VM 1
+} :abc
+do_test bind-10.17 {
+ sqlite3_bind_parameter_name $VM 2
+} {}
+do_test bind-10.18 {
+ sqlite3_bind_parameter_name $VM 3
+} {}
+do_test bind-10.19 {
+ sqlite3_bind_parameter_name $VM 4
+} {?4}
+do_test bind-10.20 {
+ sqlite3_bind_parameter_name $VM 5
+} :pqr
+catch {sqlite3_finalize $VM}
+
+# Make sure we catch an unterminated "(" in a Tcl-style variable name
+#
+ifcapable tclvar {
+ do_test bind-11.1 {
+ catchsql {SELECT * FROM sqlite_master WHERE name=$abc(123 and sql NOT NULL;}
+ } {1 {unrecognized token: "$abc(123"}}
+}
+
+if {[execsql {pragma encoding}]=="UTF-8"} {
+ # Test the ability to bind text that contains embedded '\000' characters.
+ # Make sure we can recover the entire input string.
+ #
+ do_test bind-12.1 {
+ execsql {
+ CREATE TABLE t3(x BLOB);
+ }
+ set VM [sqlite3_prepare $DB {INSERT INTO t3 VALUES(?)} -1 TAIL]
+ sqlite_bind $VM 1 not-used blob10
+ sqlite3_step $VM
+ sqlite3_finalize $VM
+ execsql {
+ SELECT typeof(x), length(x), quote(x),
+ length(cast(x AS BLOB)), quote(cast(x AS BLOB)) FROM t3
+ }
+ } {text 3 'abc' 10 X'6162630078797A007071'}
+ do_test bind-12.2 {
+ sqlite3_create_function $DB
+ execsql {
+ SELECT quote(cast(x_coalesce(x) AS blob)) FROM t3
+ }
+ } {X'6162630078797A007071'}
+}
+
+# Test the operation of sqlite3_clear_bindings
+#
+do_test bind-13.1 {
+ set VM [sqlite3_prepare $DB {SELECT ?,?,?} -1 TAIL]
+ sqlite3_step $VM
+ list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \
+ [sqlite3_column_type $VM 2]
+} {NULL NULL NULL}
+do_test bind-13.2 {
+ sqlite3_reset $VM
+ sqlite3_bind_int $VM 1 1
+ sqlite3_bind_int $VM 2 2
+ sqlite3_bind_int $VM 3 3
+ sqlite3_step $VM
+ list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \
+ [sqlite3_column_type $VM 2]
+} {INTEGER INTEGER INTEGER}
+do_test bind-13.3 {
+ sqlite3_reset $VM
+ sqlite3_step $VM
+ list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \
+ [sqlite3_column_type $VM 2]
+} {INTEGER INTEGER INTEGER}
+do_test bind-13.4 {
+ sqlite3_reset $VM
+ sqlite3_clear_bindings $VM
+ sqlite3_step $VM
+ list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \
+ [sqlite3_column_type $VM 2]
+} {NULL NULL NULL}
+sqlite3_finalize $VM
+
+#--------------------------------------------------------------------
+# These tests attempt to reproduce bug #3463.
+#
+proc param_names {db zSql} {
+ set ret [list]
+ set VM [sqlite3_prepare db $zSql -1 TAIL]
+ for {set ii 1} {$ii <= [sqlite3_bind_parameter_count $VM]} {incr ii} {
+ lappend ret [sqlite3_bind_parameter_name $VM $ii]
+ }
+ sqlite3_finalize $VM
+ set ret
+}
+
+do_test bind-14.1 {
+ param_names db { SELECT @a, @b }
+} {@a @b}
+do_test bind-14.2 {
+ param_names db { SELECT NULL FROM (SELECT NULL) WHERE @a = @b }
+} {@a @b}
+do_test bind-14.3 {
+ param_names db { SELECT @a FROM (SELECT NULL) WHERE 1 = @b }
+} {@a @b}
+do_test bind-14.4 {
+ param_names db { SELECT @a, @b FROM (SELECT NULL) }
+} {@a @b}
+
+#--------------------------------------------------------------------------
+# Tests of the OP_Variable opcode where P3>1
+#
+do_test bind-15.1 {
+ db eval {CREATE TABLE t4(a,b,c,d,e,f,g,h);}
+ set VM [sqlite3_prepare db {
+ INSERT INTO t4(a,b,c,d,f,g,h,e) VALUES(?,?,?,?,?,?,?,?)
+ } -1 TAIL]
+ sqlite3_bind_int $VM 1 1
+ sqlite3_bind_int $VM 2 2
+ sqlite3_bind_int $VM 3 3
+ sqlite3_bind_int $VM 4 4
+ sqlite3_bind_int $VM 5 5
+ sqlite3_bind_int $VM 6 6
+ sqlite3_bind_int $VM 7 7
+ sqlite3_bind_int $VM 8 8
+ sqlite3_step $VM
+ sqlite3_finalize $VM
+ db eval {SELECT * FROM t4}
+} {1 2 3 4 8 5 6 7}
+do_test bind-15.2 {
+ db eval {DELETE FROM t4}
+ set VM [sqlite3_prepare db {
+ INSERT INTO t4(a,b,c,d,e,f,g,h) VALUES(?,?,?,?,?,?,?,?)
+ } -1 TAIL]
+ sqlite3_bind_int $VM 1 1
+ sqlite3_bind_int $VM 2 2
+ sqlite3_bind_int $VM 3 3
+ sqlite3_bind_int $VM 4 4
+ sqlite3_bind_int $VM 5 5
+ sqlite3_bind_int $VM 6 6
+ sqlite3_bind_int $VM 7 7
+ sqlite3_bind_int $VM 8 8
+ sqlite3_step $VM
+ sqlite3_finalize $VM
+ db eval {SELECT * FROM t4}
+} {1 2 3 4 5 6 7 8}
+do_test bind-15.3 {
+ db eval {DELETE FROM t4}
+ set VM [sqlite3_prepare db {
+ INSERT INTO t4(h,g,f,e,d,c,b,a) VALUES(?,?,?,?,?,?,?,?)
+ } -1 TAIL]
+ sqlite3_bind_int $VM 1 1
+ sqlite3_bind_int $VM 2 2
+ sqlite3_bind_int $VM 3 3
+ sqlite3_bind_int $VM 4 4
+ sqlite3_bind_int $VM 5 5
+ sqlite3_bind_int $VM 6 6
+ sqlite3_bind_int $VM 7 7
+ sqlite3_bind_int $VM 8 8
+ sqlite3_step $VM
+ sqlite3_finalize $VM
+ db eval {SELECT * FROM t4}
+} {8 7 6 5 4 3 2 1}
+do_test bind-15.4 {
+ db eval {DELETE FROM t4}
+ set VM [sqlite3_prepare db {
+ INSERT INTO t4(a,b,c,d,e,f,g,h) VALUES(?,?,?,?4,?,?6,?,?)
+ } -1 TAIL]
+ sqlite3_bind_int $VM 1 1
+ sqlite3_bind_int $VM 2 2
+ sqlite3_bind_int $VM 3 3
+ sqlite3_bind_int $VM 4 4
+ sqlite3_bind_int $VM 5 5
+ sqlite3_bind_int $VM 6 6
+ sqlite3_bind_int $VM 7 7
+ sqlite3_bind_int $VM 8 8
+ sqlite3_step $VM
+ sqlite3_finalize $VM
+ db eval {SELECT * FROM t4}
+} {1 2 3 4 5 6 7 8}
+
+finish_test
diff --git a/test/bindxfer.test b/test/bindxfer.test
new file mode 100644
index 0000000..393aab9
--- /dev/null
+++ b/test/bindxfer.test
@@ -0,0 +1,76 @@
+# 2005 April 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script testing the sqlite_transfer_bindings() API.
+#
+# $Id: bindxfer.test,v 1.9 2009/04/17 11:56:28 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc sqlite_step {stmt VALS COLS} {
+ upvar #0 $VALS vals
+ upvar #0 $COLS cols
+ set vals [list]
+ set cols [list]
+
+ set rc [sqlite3_step $stmt]
+ for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {
+ lappend cols [sqlite3_column_name $stmt $i]
+ }
+ for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} {
+ lappend vals [sqlite3_column_text $stmt $i]
+ }
+
+ return $rc
+}
+
+do_test bindxfer-1.1 {
+ set DB [sqlite3_connection_pointer db]
+ execsql {CREATE TABLE t1(a,b,c);}
+ set VM1 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL]
+ set TAIL
+} {}
+do_test bindxfer-1.2 {
+ sqlite3_bind_parameter_count $VM1
+} 3
+do_test bindxfer-1.3 {
+ set VM2 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL]
+ set TAIL
+} {}
+do_test bindxfer-1.4 {
+ sqlite3_bind_parameter_count $VM2
+} 3
+ifcapable deprecated {
+ do_test bindxfer-1.5 {
+ sqlite_bind $VM1 1 one normal
+ set sqlite_static_bind_value two
+ sqlite_bind $VM1 2 {} static
+ sqlite_bind $VM1 3 {} null
+ sqlite3_transfer_bindings $VM1 $VM2
+ sqlite_step $VM1 VALUES COLNAMES
+ } SQLITE_ROW
+ do_test bindxfer-1.6 {
+ set VALUES
+ } {{} {} {}}
+ do_test bindxfer-1.7 {
+ sqlite_step $VM2 VALUES COLNAMES
+ } SQLITE_ROW
+ do_test bindxfer-1.8 {
+ set VALUES
+ } {one two {}}
+}
+catch {sqlite3_finalize $VM1}
+catch {sqlite3_finalize $VM2}
+
+
+finish_test
diff --git a/test/bitvec.test b/test/bitvec.test
new file mode 100644
index 0000000..d27f927
--- /dev/null
+++ b/test/bitvec.test
@@ -0,0 +1,195 @@
+# 2008 February 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Unit testing of the Bitvec object.
+#
+# $Id: bitvec.test,v 1.4 2009/04/01 23:49:04 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# The built-in test logic must be operational in order for
+# this test to work.
+ifcapable !builtin_test {
+ finish_test
+ return
+}
+
+# Test that sqlite3BitvecBuiltinTest correctly reports errors
+# that are deliberately introduced.
+#
+do_test bitvec-1.0.1 {
+ sqlite3BitvecBuiltinTest 400 {5 1 1 1 0}
+} 1
+do_test bitvec-1.0.2 {
+ sqlite3BitvecBuiltinTest 400 {5 1 234 1 0}
+} 234
+
+# Run test cases that set every bit in vectors of various sizes.
+# for larger cases, this should cycle the bit vector representation
+# from hashing into subbitmaps. The subbitmaps should start as
+# hashes then change to either subbitmaps or linear maps, depending
+# on their size.
+#
+do_test bitvec-1.1 {
+ sqlite3BitvecBuiltinTest 400 {1 400 1 1 0}
+} 0
+do_test bitvec-1.2 {
+ sqlite3BitvecBuiltinTest 4000 {1 4000 1 1 0}
+} 0
+do_test bitvec-1.3 {
+ sqlite3BitvecBuiltinTest 40000 {1 40000 1 1 0}
+} 0
+do_test bitvec-1.4 {
+ sqlite3BitvecBuiltinTest 400000 {1 400000 1 1 0}
+} 0
+
+# By specifying a larger increments, we spread the load around.
+#
+do_test bitvec-1.5 {
+ sqlite3BitvecBuiltinTest 400 {1 400 1 7 0}
+} 0
+do_test bitvec-1.6 {
+ sqlite3BitvecBuiltinTest 4000 {1 4000 1 7 0}
+} 0
+do_test bitvec-1.7 {
+ sqlite3BitvecBuiltinTest 40000 {1 40000 1 7 0}
+} 0
+do_test bitvec-1.8 {
+ sqlite3BitvecBuiltinTest 400000 {1 400000 1 7 0}
+} 0
+
+# First fill up the bitmap with ones, then go through and
+# clear all the bits. This will stress the clearing mechanism.
+#
+do_test bitvec-1.9 {
+ sqlite3BitvecBuiltinTest 400 {1 400 1 1 2 400 1 1 0}
+} 0
+do_test bitvec-1.10 {
+ sqlite3BitvecBuiltinTest 4000 {1 4000 1 1 2 4000 1 1 0}
+} 0
+do_test bitvec-1.11 {
+ sqlite3BitvecBuiltinTest 40000 {1 40000 1 1 2 40000 1 1 0}
+} 0
+do_test bitvec-1.12 {
+ sqlite3BitvecBuiltinTest 400000 {1 400000 1 1 2 400000 1 1 0}
+} 0
+
+do_test bitvec-1.13 {
+ sqlite3BitvecBuiltinTest 400 {1 400 1 1 2 400 1 7 0}
+} 0
+do_test bitvec-1.15 {
+ sqlite3BitvecBuiltinTest 4000 {1 4000 1 1 2 4000 1 7 0}
+} 0
+do_test bitvec-1.16 {
+ sqlite3BitvecBuiltinTest 40000 {1 40000 1 1 2 40000 1 77 0}
+} 0
+do_test bitvec-1.17 {
+ sqlite3BitvecBuiltinTest 400000 {1 400000 1 1 2 400000 1 777 0}
+} 0
+
+do_test bitvec-1.18 {
+ sqlite3BitvecBuiltinTest 400000 {1 5000 100000 1 2 400000 1 37 0}
+} 0
+
+# Attempt to induce hash collisions.
+#
+unset -nocomplain start
+unset -nocomplain incr
+foreach start {1 2 3 4 5 6 7 8} {
+ foreach incr {124 125} {
+ do_test bitvec-1.20.$start.$incr {
+ set prog [list 1 60 $::start $::incr 2 5000 1 1 0]
+ sqlite3BitvecBuiltinTest 5000 $prog
+ } 0
+ }
+}
+
+do_test bitvec-1.30.big_and_slow {
+ sqlite3BitvecBuiltinTest 17000000 {1 17000000 1 1 2 17000000 1 1 0}
+} 0
+
+
+# Test setting and clearing a random subset of bits.
+#
+do_test bitvec-2.1 {
+ sqlite3BitvecBuiltinTest 4000 {3 2000 4 2000 0}
+} 0
+do_test bitvec-2.2 {
+ sqlite3BitvecBuiltinTest 4000 {3 1000 4 1000 3 1000 4 1000 3 1000 4 1000
+ 3 1000 4 1000 3 1000 4 1000 3 1000 4 1000 0}
+} 0
+do_test bitvec-2.3 {
+ sqlite3BitvecBuiltinTest 400000 {3 10 0}
+} 0
+do_test bitvec-2.4 {
+ sqlite3BitvecBuiltinTest 4000 {3 10 2 4000 1 1 0}
+} 0
+do_test bitvec-2.5 {
+ sqlite3BitvecBuiltinTest 5000 {3 20 2 5000 1 1 0}
+} 0
+do_test bitvec-2.6 {
+ sqlite3BitvecBuiltinTest 50000 {3 60 2 50000 1 1 0}
+} 0
+do_test bitvec-2.7 {
+ sqlite3BitvecBuiltinTest 5000 {
+ 1 25 121 125
+ 1 50 121 125
+ 2 25 121 125
+ 0
+ }
+} 0
+
+# This procedure runs sqlite3BitvecBuiltinTest with argments "n" and
+# "program". But it also causes a malloc error to occur after the
+# "failcnt"-th malloc. The result should be "0" if no malloc failure
+# occurs or "-1" if there is a malloc failure.
+#
+proc bitvec_malloc_test {label failcnt n program} {
+ do_test $label [subst {
+ sqlite3_memdebug_fail $failcnt
+ set x \[sqlite3BitvecBuiltinTest $n [list $program]\]
+ set nFail \[sqlite3_memdebug_fail -1\]
+ if {\$nFail==0} {
+ set ::go 0
+ set x -1
+ }
+ set x
+ }] -1
+}
+
+# Make sure malloc failures are handled sanily.
+#
+unset -nocomplain n
+unset -nocomplain go
+set go 1
+save_prng_state
+for {set n 0} {$go} {incr n} {
+ restore_prng_state
+ bitvec_malloc_test bitvec-3.1.$n $n 5000 {
+ 3 60 2 5000 1 1 3 60 2 5000 1 1 3 60 2 5000 1 1 0
+ }
+}
+set go 1
+for {set n 0} {$go} {incr n} {
+ restore_prng_state
+ bitvec_malloc_test bitvec-3.2.$n $n 5000 {
+ 3 600 2 5000 1 1 3 600 2 5000 1 1 3 600 2 5000 1 1 0
+ }
+}
+set go 1
+for {set n 1} {$go} {incr n} {
+ bitvec_malloc_test bitvec-3.3.$n $n 50000 {1 50000 1 1 0}
+}
+
+finish_test
+return
diff --git a/test/blob.test b/test/blob.test
new file mode 100644
index 0000000..b1aae38
--- /dev/null
+++ b/test/blob.test
@@ -0,0 +1,147 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# $Id: blob.test,v 1.8 2009/04/28 18:00:27 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!bloblit} {
+ finish_test
+ return
+}
+
+proc bin_to_hex {blob} {
+ set bytes {}
+ binary scan $blob \c* bytes
+ set bytes2 [list]
+ foreach b $bytes {lappend bytes2 [format %02X [expr $b & 0xFF]]}
+ join $bytes2 {}
+}
+
+# Simplest possible case. Specify a blob literal
+do_test blob-1.0 {
+ set blob [execsql {SELECT X'01020304';}]
+ bin_to_hex [lindex $blob 0]
+} {01020304}
+do_test blob-1.1 {
+ set blob [execsql {SELECT x'ABCDEF';}]
+ bin_to_hex [lindex $blob 0]
+} {ABCDEF}
+do_test blob-1.2 {
+ set blob [execsql {SELECT x'';}]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test blob-1.3 {
+ set blob [execsql {SELECT x'abcdEF12';}]
+ bin_to_hex [lindex $blob 0]
+} {ABCDEF12}
+do_test blob-1.3.2 {
+ set blob [execsql {SELECT x'0123456789abcdefABCDEF';}]
+ bin_to_hex [lindex $blob 0]
+} {0123456789ABCDEFABCDEF}
+
+# Try some syntax errors in blob literals.
+do_test blob-1.4 {
+ catchsql {SELECT X'01020k304', 100}
+} {1 {unrecognized token: "X'01020k304'"}}
+do_test blob-1.5 {
+ catchsql {SELECT X'01020, 100}
+} {1 {unrecognized token: "X'01020, 100"}}
+do_test blob-1.6 {
+ catchsql {SELECT X'01020 100'}
+} {1 {unrecognized token: "X'01020 100'"}}
+do_test blob-1.7 {
+ catchsql {SELECT X'01001'}
+} {1 {unrecognized token: "X'01001'"}}
+do_test blob-1.8 {
+ catchsql {SELECT x'012/45'}
+} {1 {unrecognized token: "x'012/45'"}}
+do_test blob-1.9 {
+ catchsql {SELECT x'012:45'}
+} {1 {unrecognized token: "x'012:45'"}}
+do_test blob-1.10 {
+ catchsql {SELECT x'012@45'}
+} {1 {unrecognized token: "x'012@45'"}}
+do_test blob-1.11 {
+ catchsql {SELECT x'012G45'}
+} {1 {unrecognized token: "x'012G45'"}}
+do_test blob-1.12 {
+ catchsql {SELECT x'012`45'}
+} {1 {unrecognized token: "x'012`45'"}}
+do_test blob-1.13 {
+ catchsql {SELECT x'012g45'}
+} {1 {unrecognized token: "x'012g45'"}}
+
+
+# Insert a blob into a table and retrieve it.
+do_test blob-2.0 {
+ execsql {
+ CREATE TABLE t1(a BLOB, b BLOB);
+ INSERT INTO t1 VALUES(X'123456', x'7890ab');
+ INSERT INTO t1 VALUES(X'CDEF12', x'345678');
+ }
+ set blobs [execsql {SELECT * FROM t1}]
+ set blobs2 [list]
+ foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
+ set blobs2
+} {123456 7890AB CDEF12 345678}
+
+# An index on a blob column
+do_test blob-2.1 {
+ execsql {
+ CREATE INDEX i1 ON t1(a);
+ }
+ set blobs [execsql {SELECT * FROM t1}]
+ set blobs2 [list]
+ foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
+ set blobs2
+} {123456 7890AB CDEF12 345678}
+do_test blob-2.2 {
+ set blobs [execsql {SELECT * FROM t1 where a = X'123456'}]
+ set blobs2 [list]
+ foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
+ set blobs2
+} {123456 7890AB}
+do_test blob-2.3 {
+ set blobs [execsql {SELECT * FROM t1 where a = X'CDEF12'}]
+ set blobs2 [list]
+ foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
+ set blobs2
+} {CDEF12 345678}
+do_test blob-2.4 {
+ set blobs [execsql {SELECT * FROM t1 where a = X'CD12'}]
+ set blobs2 [list]
+ foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
+ set blobs2
+} {}
+
+# Try to bind a blob value to a prepared statement.
+do_test blob-3.0 {
+ sqlite3 db2 test.db
+ set DB [sqlite3_connection_pointer db2]
+ set STMT [sqlite3_prepare $DB "DELETE FROM t1 WHERE a = ?" -1 DUMMY]
+ sqlite3_bind_blob $STMT 1 "\x12\x34\x56" 3
+ sqlite3_step $STMT
+} {SQLITE_DONE}
+do_test blob-3.1 {
+ sqlite3_finalize $STMT
+ db2 close
+} {}
+do_test blob-3.2 {
+ set blobs [execsql {SELECT * FROM t1}]
+ set blobs2 [list]
+ foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
+ set blobs2
+} {CDEF12 345678}
+
+finish_test
diff --git a/test/boundary1.tcl b/test/boundary1.tcl
new file mode 100644
index 0000000..3896b50
--- /dev/null
+++ b/test/boundary1.tcl
@@ -0,0 +1,289 @@
+puts {# 2008 December 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is automatically generated from a separate TCL script.
+# This file seeks to exercise integer boundary values.
+#
+# $Id: boundary1.tcl,v 1.3 2009/01/02 15:45:48 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Many of the boundary tests depend on a working 64-bit implementation.
+if {![working_64bit_int]} { finish_test; return }
+}
+
+expr srand(0)
+
+# Generate interesting boundary numbers
+#
+foreach x {
+ 0
+ 1
+ 0x7f
+ 0x7fff
+ 0x7fffff
+ 0x7fffffff
+ 0x7fffffffff
+ 0x7fffffffffff
+ 0x7fffffffffffff
+ 0x7fffffffffffffff
+} {
+ set x [expr {wide($x)}]
+ set boundarynum($x) 1
+ set boundarynum([expr {$x+1}]) 1
+ set boundarynum([expr {-($x+1)}]) 1
+ set boundarynum([expr {-($x+2)}]) 1
+ set boundarynum([expr {$x+$x+1}]) 1
+ set boundarynum([expr {$x+$x+2}]) 1
+}
+set x [expr {wide(127)}]
+for {set i 1} {$i<=9} {incr i} {
+ set boundarynum($x) 1
+ set boundarynum([expr {$x+1}]) 1
+ set x [expr {wide($x*128 + 127)}]
+}
+
+# Scramble the $inlist into a random order.
+#
+proc scramble {inlist} {
+ set y {}
+ foreach x $inlist {
+ lappend y [list [expr {rand()}] $x]
+ }
+ set y [lsort $y]
+ set outlist {}
+ foreach x $y {
+ lappend outlist [lindex $x 1]
+ }
+ return $outlist
+}
+
+# A simple selection sort. Not trying to be efficient.
+#
+proc sort {inlist} {
+ set outlist {}
+ set mn [lindex $inlist 0]
+ foreach x $inlist {
+ if {$x<$mn} {set mn $x}
+ }
+ set outlist $mn
+ set mx $mn
+ while {1} {
+ set valid 0
+ foreach x $inlist {
+ if {$x>$mx && (!$valid || $mn>$x)} {
+ set mn $x
+ set valid 1
+ }
+ }
+ if {!$valid} break
+ lappend outlist $mn
+ set mx $mn
+ }
+ return $outlist
+}
+
+# Reverse the order of a list
+#
+proc reverse {inlist} {
+ set i [llength $inlist]
+ set outlist {}
+ for {incr i -1} {$i>=0} {incr i -1} {
+ lappend outlist [lindex $inlist $i]
+ }
+ return $outlist
+}
+
+set nums1 [scramble [array names boundarynum]]
+set nums2 [scramble [array names boundarynum]]
+
+set tname boundary1
+puts "do_test $tname-1.1 \173"
+puts " db eval \173"
+puts " CREATE TABLE t1(a,x);"
+set a 0
+foreach r $nums1 {
+ incr a
+ set t1ra($r) $a
+ set t1ar($a) $r
+ set x [format %08x%08x [expr {wide($r)>>32}] $r]
+ set t1rx($r) $x
+ set t1xr($x) $r
+ puts " INSERT INTO t1(oid,a,x) VALUES($r,$a,'$x');"
+}
+puts " CREATE INDEX t1i1 ON t1(a);"
+puts " CREATE INDEX t1i2 ON t1(x);"
+puts " \175"
+puts "\175 {}"
+
+puts "do_test $tname-1.2 \173"
+puts " db eval \173"
+puts " SELECT count(*) FROM t1"
+puts " \175"
+puts "\175 {64}"
+
+set nums3 $nums2
+lappend nums3 9.22337303685477580800e+18
+lappend nums3 -9.22337303685477580800e+18
+
+set i 0
+foreach r $nums3 {
+ incr i
+
+ if {abs($r)<9.22337203685477580800e+18} {
+ set x $t1rx($r)
+ set a $t1ra($r)
+ set r5 $r.5
+ set r0 $r.0
+ puts "do_test $tname-2.$i.1 \173"
+ puts " db eval \173"
+ puts " SELECT * FROM t1 WHERE rowid=$r"
+ puts " \175"
+ puts "\175 {$a $x}"
+ puts "do_test $tname-2.$i.2 \173"
+ puts " db eval \173"
+ puts " SELECT rowid, a FROM t1 WHERE x='$x'"
+ puts " \175"
+ puts "\175 {$r $a}"
+ puts "do_test $tname-2.$i.3 \173"
+ puts " db eval \173"
+ puts " SELECT rowid, x FROM t1 WHERE a=$a"
+ puts " \175"
+ puts "\175 {$r $x}"
+ }
+
+ foreach op {> >= < <=} subno {gt ge lt le} {
+
+ ################################################################ 2.x.y.1
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r" {
+ lappend rset $rx
+ lappend aset $t1ra($rx)
+ }
+ }
+ puts "do_test $tname-2.$i.$subno.1 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE rowid $op $r ORDER BY a"
+ puts " \175"
+ puts "\175 {[sort $aset]}"
+
+ ################################################################ 2.x.y.2
+ puts "do_test $tname-2.$i.$subno.2 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE rowid $op $r ORDER BY a DESC"
+ puts " \175"
+ puts "\175 {[reverse [sort $aset]]}"
+
+ ################################################################ 2.x.y.3
+ set aset {}
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.3 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE rowid $op $r ORDER BY rowid"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.4
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.4 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE rowid $op $r ORDER BY rowid DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.5
+ set aset {}
+ set xset {}
+ foreach rx $rset {
+ lappend xset $t1rx($rx)
+ }
+ foreach x [sort $xset] {
+ set rx $t1xr($x)
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.5 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE rowid $op $r ORDER BY x"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.10
+ if {abs($r)>9223372036854775808 || [string length $r5]>15} continue
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r0" {
+ lappend rset $rx
+ }
+ }
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.10 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE rowid $op $r0 ORDER BY rowid"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.11
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.11 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE rowid $op $r0 ORDER BY rowid DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+
+
+ ################################################################ 2.x.y.12
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r5" {
+ lappend rset $rx
+ }
+ }
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.12 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE rowid $op $r5 ORDER BY rowid"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.13
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.13 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE rowid $op $r5 ORDER BY rowid DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+ }
+
+}
+
+
+puts {finish_test}
diff --git a/test/boundary1.test b/test/boundary1.test
new file mode 100644
index 0000000..0e2458c
--- /dev/null
+++ b/test/boundary1.test
@@ -0,0 +1,7645 @@
+# 2008 December 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is automatically generated from a separate TCL script.
+# This file seeks to exercise integer boundary values.
+#
+# $Id: boundary1.test,v 1.2 2009/01/02 15:45:48 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Many of the boundary tests depend on a working 64-bit implementation.
+if {![working_64bit_int]} { finish_test; return }
+
+do_test boundary1-1.1 {
+ db eval {
+ CREATE TABLE t1(a,x);
+ INSERT INTO t1(oid,a,x) VALUES(-8388609,1,'ffffffffff7fffff');
+ INSERT INTO t1(oid,a,x) VALUES(-36028797018963969,2,'ff7fffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(9223372036854775807,3,'7fffffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(127,4,'000000000000007f');
+ INSERT INTO t1(oid,a,x) VALUES(3,5,'0000000000000003');
+ INSERT INTO t1(oid,a,x) VALUES(16777216,6,'0000000001000000');
+ INSERT INTO t1(oid,a,x) VALUES(4398046511103,7,'000003ffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(16383,8,'0000000000003fff');
+ INSERT INTO t1(oid,a,x) VALUES(16777215,9,'0000000000ffffff');
+ INSERT INTO t1(oid,a,x) VALUES(281474976710655,10,'0000ffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-2147483648,11,'ffffffff80000000');
+ INSERT INTO t1(oid,a,x) VALUES(268435455,12,'000000000fffffff');
+ INSERT INTO t1(oid,a,x) VALUES(562949953421311,13,'0001ffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(4294967295,14,'00000000ffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(2097151,15,'00000000001fffff');
+ INSERT INTO t1(oid,a,x) VALUES(16384,16,'0000000000004000');
+ INSERT INTO t1(oid,a,x) VALUES(72057594037927935,17,'00ffffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(8388607,18,'00000000007fffff');
+ INSERT INTO t1(oid,a,x) VALUES(1099511627776,19,'0000010000000000');
+ INSERT INTO t1(oid,a,x) VALUES(2147483647,20,'000000007fffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-140737488355329,21,'ffff7fffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(34359738368,22,'0000000800000000');
+ INSERT INTO t1(oid,a,x) VALUES(32767,23,'0000000000007fff');
+ INSERT INTO t1(oid,a,x) VALUES(8388608,24,'0000000000800000');
+ INSERT INTO t1(oid,a,x) VALUES(140737488355327,25,'00007fffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(281474976710656,26,'0001000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(36028797018963967,27,'007fffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(72057594037927936,28,'0100000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-32769,29,'ffffffffffff7fff');
+ INSERT INTO t1(oid,a,x) VALUES(255,30,'00000000000000ff');
+ INSERT INTO t1(oid,a,x) VALUES(4,31,'0000000000000004');
+ INSERT INTO t1(oid,a,x) VALUES(-32768,32,'ffffffffffff8000');
+ INSERT INTO t1(oid,a,x) VALUES(-2,33,'fffffffffffffffe');
+ INSERT INTO t1(oid,a,x) VALUES(140737488355328,34,'0000800000000000');
+ INSERT INTO t1(oid,a,x) VALUES(549755813888,35,'0000008000000000');
+ INSERT INTO t1(oid,a,x) VALUES(4294967296,36,'0000000100000000');
+ INSERT INTO t1(oid,a,x) VALUES(-8388608,37,'ffffffffff800000');
+ INSERT INTO t1(oid,a,x) VALUES(-1,38,'ffffffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(34359738367,39,'00000007ffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(268435456,40,'0000000010000000');
+ INSERT INTO t1(oid,a,x) VALUES(2,41,'0000000000000002');
+ INSERT INTO t1(oid,a,x) VALUES(2097152,42,'0000000000200000');
+ INSERT INTO t1(oid,a,x) VALUES(562949953421312,43,'0002000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-140737488355328,44,'ffff800000000000');
+ INSERT INTO t1(oid,a,x) VALUES(36028797018963968,45,'0080000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(549755813887,46,'0000007fffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-2147483649,47,'ffffffff7fffffff');
+ INSERT INTO t1(oid,a,x) VALUES(65535,48,'000000000000ffff');
+ INSERT INTO t1(oid,a,x) VALUES(128,49,'0000000000000080');
+ INSERT INTO t1(oid,a,x) VALUES(32768,50,'0000000000008000');
+ INSERT INTO t1(oid,a,x) VALUES(2147483648,51,'0000000080000000');
+ INSERT INTO t1(oid,a,x) VALUES(-3,52,'fffffffffffffffd');
+ INSERT INTO t1(oid,a,x) VALUES(-128,53,'ffffffffffffff80');
+ INSERT INTO t1(oid,a,x) VALUES(-129,54,'ffffffffffffff7f');
+ INSERT INTO t1(oid,a,x) VALUES(-9223372036854775808,55,'8000000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(4398046511104,56,'0000040000000000');
+ INSERT INTO t1(oid,a,x) VALUES(1099511627775,57,'000000ffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-549755813889,58,'ffffff7fffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(0,59,'0000000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(1,60,'0000000000000001');
+ INSERT INTO t1(oid,a,x) VALUES(256,61,'0000000000000100');
+ INSERT INTO t1(oid,a,x) VALUES(65536,62,'0000000000010000');
+ INSERT INTO t1(oid,a,x) VALUES(-549755813888,63,'ffffff8000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-36028797018963968,64,'ff80000000000000');
+ CREATE INDEX t1i1 ON t1(a);
+ CREATE INDEX t1i2 ON t1(x);
+ }
+} {}
+do_test boundary1-1.2 {
+ db eval {
+ SELECT count(*) FROM t1
+ }
+} {64}
+do_test boundary1-2.1.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=72057594037927935
+ }
+} {17 00ffffffffffffff}
+do_test boundary1-2.1.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='00ffffffffffffff'
+ }
+} {72057594037927935 17}
+do_test boundary1-2.1.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=17
+ }
+} {72057594037927935 00ffffffffffffff}
+do_test boundary1-2.1.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 72057594037927935 ORDER BY a
+ }
+} {3 28}
+do_test boundary1-2.1.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 72057594037927935 ORDER BY a DESC
+ }
+} {28 3}
+do_test boundary1-2.1.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 72057594037927935 ORDER BY rowid
+ }
+} {28 3}
+do_test boundary1-2.1.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 72057594037927935 ORDER BY rowid DESC
+ }
+} {3 28}
+do_test boundary1-2.1.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 72057594037927935 ORDER BY x
+ }
+} {28 3}
+do_test boundary1-2.1.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 72057594037927935 ORDER BY a
+ }
+} {3 17 28}
+do_test boundary1-2.1.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 72057594037927935 ORDER BY a DESC
+ }
+} {28 17 3}
+do_test boundary1-2.1.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 72057594037927935 ORDER BY rowid
+ }
+} {17 28 3}
+do_test boundary1-2.1.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 72057594037927935 ORDER BY rowid DESC
+ }
+} {3 28 17}
+do_test boundary1-2.1.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 72057594037927935 ORDER BY x
+ }
+} {17 28 3}
+do_test boundary1-2.1.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 72057594037927935 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.1.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 72057594037927935 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.1.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 72057594037927935 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}
+do_test boundary1-2.1.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 72057594037927935 ORDER BY rowid DESC
+ }
+} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.1.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 72057594037927935 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.1.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 72057594037927935 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.1.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 72057594037927935 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.1.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 72057594037927935 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}
+do_test boundary1-2.1.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 72057594037927935 ORDER BY rowid DESC
+ }
+} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.1.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 72057594037927935 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.2.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=16384
+ }
+} {16 0000000000004000}
+do_test boundary1-2.2.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000004000'
+ }
+} {16384 16}
+do_test boundary1-2.2.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=16
+ }
+} {16384 0000000000004000}
+do_test boundary1-2.2.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16384 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary1-2.2.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16384 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.2.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16384 ORDER BY rowid
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.2.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16384 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}
+do_test boundary1-2.2.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16384 ORDER BY x
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.2.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16384 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary1-2.2.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16384 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.2.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16384 ORDER BY rowid
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.2.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16384 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}
+do_test boundary1-2.2.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16384 ORDER BY x
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.2.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16384 ORDER BY a
+ }
+} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.2.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16384 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}
+do_test boundary1-2.2.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16384 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}
+do_test boundary1-2.2.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16384 ORDER BY rowid DESC
+ }
+} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.2.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16384 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.2.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16384 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.2.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16384 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}
+do_test boundary1-2.2.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16384 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}
+do_test boundary1-2.2.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16384 ORDER BY rowid DESC
+ }
+} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.2.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16384 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.3.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=4294967296
+ }
+} {36 0000000100000000}
+do_test boundary1-2.3.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000100000000'
+ }
+} {4294967296 36}
+do_test boundary1-2.3.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=36
+ }
+} {4294967296 0000000100000000}
+do_test boundary1-2.3.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4294967296 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}
+do_test boundary1-2.3.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4294967296 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary1-2.3.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4294967296 ORDER BY rowid
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.3.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4294967296 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}
+do_test boundary1-2.3.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4294967296 ORDER BY x
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.3.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4294967296 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary1-2.3.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4294967296 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary1-2.3.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4294967296 ORDER BY rowid
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.3.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4294967296 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}
+do_test boundary1-2.3.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4294967296 ORDER BY x
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.3.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4294967296 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.3.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4294967296 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.3.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4294967296 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}
+do_test boundary1-2.3.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4294967296 ORDER BY rowid DESC
+ }
+} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.3.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4294967296 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.3.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4294967296 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.3.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4294967296 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.3.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4294967296 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}
+do_test boundary1-2.3.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4294967296 ORDER BY rowid DESC
+ }
+} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.3.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4294967296 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.4.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=16777216
+ }
+} {6 0000000001000000}
+do_test boundary1-2.4.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000001000000'
+ }
+} {16777216 6}
+do_test boundary1-2.4.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=6
+ }
+} {16777216 0000000001000000}
+do_test boundary1-2.4.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16777216 ORDER BY a
+ }
+} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.4.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16777216 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}
+do_test boundary1-2.4.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16777216 ORDER BY rowid
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.4.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16777216 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}
+do_test boundary1-2.4.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16777216 ORDER BY x
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.4.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16777216 ORDER BY a
+ }
+} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.4.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16777216 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}
+do_test boundary1-2.4.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16777216 ORDER BY rowid
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.4.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16777216 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}
+do_test boundary1-2.4.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16777216 ORDER BY x
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.4.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16777216 ORDER BY a
+ }
+} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.4.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16777216 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}
+do_test boundary1-2.4.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16777216 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}
+do_test boundary1-2.4.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16777216 ORDER BY rowid DESC
+ }
+} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.4.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16777216 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.4.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16777216 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.4.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16777216 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}
+do_test boundary1-2.4.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16777216 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}
+do_test boundary1-2.4.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16777216 ORDER BY rowid DESC
+ }
+} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.4.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16777216 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.5.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-32769
+ }
+} {29 ffffffffffff7fff}
+do_test boundary1-2.5.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffffffffff7fff'
+ }
+} {-32769 29}
+do_test boundary1-2.5.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=29
+ }
+} {-32769 ffffffffffff7fff}
+do_test boundary1-2.5.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -32769 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.5.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -32769 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.5.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -32769 ORDER BY rowid
+ }
+} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.5.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -32769 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}
+do_test boundary1-2.5.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -32769 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}
+do_test boundary1-2.5.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -32769 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.5.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -32769 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.5.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -32769 ORDER BY rowid
+ }
+} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.5.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -32769 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}
+do_test boundary1-2.5.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -32769 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}
+do_test boundary1-2.5.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -32769 ORDER BY a
+ }
+} {1 2 11 21 37 44 47 55 58 63 64}
+do_test boundary1-2.5.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -32769 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 21 11 2 1}
+do_test boundary1-2.5.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -32769 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary1-2.5.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -32769 ORDER BY rowid DESC
+ }
+} {37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.5.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -32769 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary1-2.5.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -32769 ORDER BY a
+ }
+} {1 2 11 21 29 37 44 47 55 58 63 64}
+do_test boundary1-2.5.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -32769 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 29 21 11 2 1}
+do_test boundary1-2.5.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -32769 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary1-2.5.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -32769 ORDER BY rowid DESC
+ }
+} {29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.5.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -32769 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary1-2.6.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-140737488355329
+ }
+} {21 ffff7fffffffffff}
+do_test boundary1-2.6.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffff7fffffffffff'
+ }
+} {-140737488355329 21}
+do_test boundary1-2.6.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=21
+ }
+} {-140737488355329 ffff7fffffffffff}
+do_test boundary1-2.6.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -140737488355329 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary1-2.6.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -140737488355329 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.6.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -140737488355329 ORDER BY rowid
+ }
+} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.6.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -140737488355329 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}
+do_test boundary1-2.6.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -140737488355329 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.6.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -140737488355329 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary1-2.6.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -140737488355329 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.6.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -140737488355329 ORDER BY rowid
+ }
+} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.6.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -140737488355329 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}
+do_test boundary1-2.6.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -140737488355329 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.6.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -140737488355329 ORDER BY a
+ }
+} {2 55 64}
+do_test boundary1-2.6.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -140737488355329 ORDER BY a DESC
+ }
+} {64 55 2}
+do_test boundary1-2.6.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -140737488355329 ORDER BY rowid
+ }
+} {55 2 64}
+do_test boundary1-2.6.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -140737488355329 ORDER BY rowid DESC
+ }
+} {64 2 55}
+do_test boundary1-2.6.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -140737488355329 ORDER BY x
+ }
+} {55 2 64}
+do_test boundary1-2.6.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -140737488355329 ORDER BY a
+ }
+} {2 21 55 64}
+do_test boundary1-2.6.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -140737488355329 ORDER BY a DESC
+ }
+} {64 55 21 2}
+do_test boundary1-2.6.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -140737488355329 ORDER BY rowid
+ }
+} {55 2 64 21}
+do_test boundary1-2.6.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -140737488355329 ORDER BY rowid DESC
+ }
+} {21 64 2 55}
+do_test boundary1-2.6.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -140737488355329 ORDER BY x
+ }
+} {55 2 64 21}
+do_test boundary1-2.7.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=2
+ }
+} {41 0000000000000002}
+do_test boundary1-2.7.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000000002'
+ }
+} {2 41}
+do_test boundary1-2.7.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=41
+ }
+} {2 0000000000000002}
+do_test boundary1-2.7.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary1-2.7.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.7.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2 ORDER BY rowid
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.7.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}
+do_test boundary1-2.7.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2 ORDER BY x
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.7.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary1-2.7.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.7.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2 ORDER BY rowid
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.7.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}
+do_test boundary1-2.7.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2 ORDER BY x
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.7.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.7.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary1-2.7.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}
+do_test boundary1-2.7.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2 ORDER BY rowid DESC
+ }
+} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.7.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2 ORDER BY x
+ }
+} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.7.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.7.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}
+do_test boundary1-2.7.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}
+do_test boundary1-2.7.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2 ORDER BY rowid DESC
+ }
+} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.7.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2 ORDER BY x
+ }
+} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.8.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=4
+ }
+} {31 0000000000000004}
+do_test boundary1-2.8.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000000004'
+ }
+} {4 31}
+do_test boundary1-2.8.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=31
+ }
+} {4 0000000000000004}
+do_test boundary1-2.8.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary1-2.8.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary1-2.8.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4 ORDER BY rowid
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.8.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}
+do_test boundary1-2.8.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4 ORDER BY x
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.8.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary1-2.8.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary1-2.8.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4 ORDER BY rowid
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.8.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}
+do_test boundary1-2.8.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4 ORDER BY x
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.8.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4 ORDER BY a
+ }
+} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.8.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}
+do_test boundary1-2.8.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}
+do_test boundary1-2.8.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4 ORDER BY rowid DESC
+ }
+} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.8.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4 ORDER BY x
+ }
+} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.8.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4 ORDER BY a
+ }
+} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.8.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}
+do_test boundary1-2.8.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}
+do_test boundary1-2.8.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4 ORDER BY rowid DESC
+ }
+} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.8.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4 ORDER BY x
+ }
+} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.9.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=562949953421311
+ }
+} {13 0001ffffffffffff}
+do_test boundary1-2.9.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0001ffffffffffff'
+ }
+} {562949953421311 13}
+do_test boundary1-2.9.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=13
+ }
+} {562949953421311 0001ffffffffffff}
+do_test boundary1-2.9.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 562949953421311 ORDER BY a
+ }
+} {3 17 27 28 43 45}
+do_test boundary1-2.9.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 562949953421311 ORDER BY a DESC
+ }
+} {45 43 28 27 17 3}
+do_test boundary1-2.9.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 562949953421311 ORDER BY rowid
+ }
+} {43 27 45 17 28 3}
+do_test boundary1-2.9.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 562949953421311 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43}
+do_test boundary1-2.9.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 562949953421311 ORDER BY x
+ }
+} {43 27 45 17 28 3}
+do_test boundary1-2.9.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 562949953421311 ORDER BY a
+ }
+} {3 13 17 27 28 43 45}
+do_test boundary1-2.9.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 562949953421311 ORDER BY a DESC
+ }
+} {45 43 28 27 17 13 3}
+do_test boundary1-2.9.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 562949953421311 ORDER BY rowid
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary1-2.9.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 562949953421311 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13}
+do_test boundary1-2.9.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 562949953421311 ORDER BY x
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary1-2.9.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 562949953421311 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.9.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 562949953421311 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.9.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 562949953421311 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}
+do_test boundary1-2.9.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 562949953421311 ORDER BY rowid DESC
+ }
+} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.9.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 562949953421311 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.9.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 562949953421311 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.9.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 562949953421311 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.9.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 562949953421311 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}
+do_test boundary1-2.9.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 562949953421311 ORDER BY rowid DESC
+ }
+} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.9.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 562949953421311 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.10.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=256
+ }
+} {61 0000000000000100}
+do_test boundary1-2.10.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000000100'
+ }
+} {256 61}
+do_test boundary1-2.10.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=61
+ }
+} {256 0000000000000100}
+do_test boundary1-2.10.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 256 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary1-2.10.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 256 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary1-2.10.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 256 ORDER BY rowid
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.10.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 256 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}
+do_test boundary1-2.10.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 256 ORDER BY x
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.10.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 256 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary1-2.10.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 256 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary1-2.10.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 256 ORDER BY rowid
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.10.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 256 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}
+do_test boundary1-2.10.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 256 ORDER BY x
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.10.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 256 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.10.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 256 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary1-2.10.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 256 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}
+do_test boundary1-2.10.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 256 ORDER BY rowid DESC
+ }
+} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.10.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 256 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.10.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 256 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.10.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 256 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary1-2.10.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 256 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}
+do_test boundary1-2.10.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 256 ORDER BY rowid DESC
+ }
+} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.10.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 256 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.11.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=34359738368
+ }
+} {22 0000000800000000}
+do_test boundary1-2.11.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000800000000'
+ }
+} {34359738368 22}
+do_test boundary1-2.11.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=22
+ }
+} {34359738368 0000000800000000}
+do_test boundary1-2.11.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 34359738368 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary1-2.11.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 34359738368 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary1-2.11.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 34359738368 ORDER BY rowid
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.11.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 34359738368 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}
+do_test boundary1-2.11.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 34359738368 ORDER BY x
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.11.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 34359738368 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary1-2.11.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 34359738368 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary1-2.11.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 34359738368 ORDER BY rowid
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.11.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 34359738368 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}
+do_test boundary1-2.11.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 34359738368 ORDER BY x
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.11.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 34359738368 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.11.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 34359738368 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.11.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 34359738368 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}
+do_test boundary1-2.11.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 34359738368 ORDER BY rowid DESC
+ }
+} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.11.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 34359738368 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.11.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 34359738368 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.11.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 34359738368 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.11.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 34359738368 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}
+do_test boundary1-2.11.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 34359738368 ORDER BY rowid DESC
+ }
+} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.11.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 34359738368 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.12.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=65536
+ }
+} {62 0000000000010000}
+do_test boundary1-2.12.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000010000'
+ }
+} {65536 62}
+do_test boundary1-2.12.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=62
+ }
+} {65536 0000000000010000}
+do_test boundary1-2.12.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 65536 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary1-2.12.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 65536 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.12.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 65536 ORDER BY rowid
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.12.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 65536 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}
+do_test boundary1-2.12.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 65536 ORDER BY x
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.12.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 65536 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}
+do_test boundary1-2.12.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 65536 ORDER BY a DESC
+ }
+} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.12.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 65536 ORDER BY rowid
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.12.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 65536 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}
+do_test boundary1-2.12.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 65536 ORDER BY x
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.12.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 65536 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.12.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 65536 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary1-2.12.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 65536 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}
+do_test boundary1-2.12.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 65536 ORDER BY rowid DESC
+ }
+} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.12.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 65536 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.12.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 65536 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.12.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 65536 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary1-2.12.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 65536 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}
+do_test boundary1-2.12.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 65536 ORDER BY rowid DESC
+ }
+} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.12.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 65536 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.13.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=268435456
+ }
+} {40 0000000010000000}
+do_test boundary1-2.13.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000010000000'
+ }
+} {268435456 40}
+do_test boundary1-2.13.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=40
+ }
+} {268435456 0000000010000000}
+do_test boundary1-2.13.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 268435456 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary1-2.13.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 268435456 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary1-2.13.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 268435456 ORDER BY rowid
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.13.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 268435456 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}
+do_test boundary1-2.13.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 268435456 ORDER BY x
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.13.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 268435456 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.13.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 268435456 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary1-2.13.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 268435456 ORDER BY rowid
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.13.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 268435456 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}
+do_test boundary1-2.13.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 268435456 ORDER BY x
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.13.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 268435456 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.13.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 268435456 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.13.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 268435456 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}
+do_test boundary1-2.13.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 268435456 ORDER BY rowid DESC
+ }
+} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.13.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 268435456 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.13.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 268435456 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.13.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 268435456 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.13.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 268435456 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}
+do_test boundary1-2.13.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 268435456 ORDER BY rowid DESC
+ }
+} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.13.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 268435456 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.14.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-140737488355328
+ }
+} {44 ffff800000000000}
+do_test boundary1-2.14.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffff800000000000'
+ }
+} {-140737488355328 44}
+do_test boundary1-2.14.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=44
+ }
+} {-140737488355328 ffff800000000000}
+do_test boundary1-2.14.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -140737488355328 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary1-2.14.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -140737488355328 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.14.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -140737488355328 ORDER BY rowid
+ }
+} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.14.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -140737488355328 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}
+do_test boundary1-2.14.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.14.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -140737488355328 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary1-2.14.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -140737488355328 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.14.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -140737488355328 ORDER BY rowid
+ }
+} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.14.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -140737488355328 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}
+do_test boundary1-2.14.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.14.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -140737488355328 ORDER BY a
+ }
+} {2 21 55 64}
+do_test boundary1-2.14.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -140737488355328 ORDER BY a DESC
+ }
+} {64 55 21 2}
+do_test boundary1-2.14.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -140737488355328 ORDER BY rowid
+ }
+} {55 2 64 21}
+do_test boundary1-2.14.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -140737488355328 ORDER BY rowid DESC
+ }
+} {21 64 2 55}
+do_test boundary1-2.14.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -140737488355328 ORDER BY x
+ }
+} {55 2 64 21}
+do_test boundary1-2.14.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -140737488355328 ORDER BY a
+ }
+} {2 21 44 55 64}
+do_test boundary1-2.14.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -140737488355328 ORDER BY a DESC
+ }
+} {64 55 44 21 2}
+do_test boundary1-2.14.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -140737488355328 ORDER BY rowid
+ }
+} {55 2 64 21 44}
+do_test boundary1-2.14.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -140737488355328 ORDER BY rowid DESC
+ }
+} {44 21 64 2 55}
+do_test boundary1-2.14.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -140737488355328 ORDER BY x
+ }
+} {55 2 64 21 44}
+do_test boundary1-2.15.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=1099511627776
+ }
+} {19 0000010000000000}
+do_test boundary1-2.15.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000010000000000'
+ }
+} {1099511627776 19}
+do_test boundary1-2.15.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=19
+ }
+} {1099511627776 0000010000000000}
+do_test boundary1-2.15.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1099511627776 ORDER BY a
+ }
+} {3 7 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary1-2.15.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1099511627776 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 7 3}
+do_test boundary1-2.15.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1099511627776 ORDER BY rowid
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.15.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1099511627776 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7}
+do_test boundary1-2.15.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1099511627776 ORDER BY x
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.15.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1099511627776 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}
+do_test boundary1-2.15.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1099511627776 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary1-2.15.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1099511627776 ORDER BY rowid
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.15.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1099511627776 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}
+do_test boundary1-2.15.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1099511627776 ORDER BY x
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.15.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1099511627776 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary1-2.15.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1099511627776 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.15.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1099511627776 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}
+do_test boundary1-2.15.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1099511627776 ORDER BY rowid DESC
+ }
+} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.15.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1099511627776 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.15.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1099511627776 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary1-2.15.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1099511627776 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.15.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1099511627776 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}
+do_test boundary1-2.15.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1099511627776 ORDER BY rowid DESC
+ }
+} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.15.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1099511627776 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.16.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 9223372036854775807 ORDER BY a
+ }
+} {}
+do_test boundary1-2.16.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 9223372036854775807 ORDER BY a DESC
+ }
+} {}
+do_test boundary1-2.16.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 9223372036854775807 ORDER BY rowid
+ }
+} {}
+do_test boundary1-2.16.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 9223372036854775807 ORDER BY rowid DESC
+ }
+} {}
+do_test boundary1-2.16.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 9223372036854775807 ORDER BY x
+ }
+} {}
+do_test boundary1-2.16.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 9223372036854775807 ORDER BY a
+ }
+} {3}
+do_test boundary1-2.16.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 9223372036854775807 ORDER BY a DESC
+ }
+} {3}
+do_test boundary1-2.16.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 9223372036854775807 ORDER BY rowid
+ }
+} {3}
+do_test boundary1-2.16.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 9223372036854775807 ORDER BY rowid DESC
+ }
+} {3}
+do_test boundary1-2.16.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 9223372036854775807 ORDER BY x
+ }
+} {3}
+do_test boundary1-2.16.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.16.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.16.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}
+do_test boundary1-2.16.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY rowid DESC
+ }
+} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.16.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.16.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 9223372036854775807 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.16.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 9223372036854775807 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary1-2.16.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 9223372036854775807 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.16.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 9223372036854775807 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.16.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 9223372036854775807 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.17.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=32768
+ }
+} {50 0000000000008000}
+do_test boundary1-2.17.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000008000'
+ }
+} {32768 50}
+do_test boundary1-2.17.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=50
+ }
+} {32768 0000000000008000}
+do_test boundary1-2.17.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 32768 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}
+do_test boundary1-2.17.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 32768 ORDER BY a DESC
+ }
+} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.17.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 32768 ORDER BY rowid
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.17.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 32768 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}
+do_test boundary1-2.17.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 32768 ORDER BY x
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.17.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 32768 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary1-2.17.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 32768 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.17.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 32768 ORDER BY rowid
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.17.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 32768 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}
+do_test boundary1-2.17.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 32768 ORDER BY x
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.17.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 32768 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.17.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 32768 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary1-2.17.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 32768 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}
+do_test boundary1-2.17.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 32768 ORDER BY rowid DESC
+ }
+} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.17.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.17.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 32768 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.17.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 32768 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary1-2.17.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 32768 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}
+do_test boundary1-2.17.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 32768 ORDER BY rowid DESC
+ }
+} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.17.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.18.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-36028797018963968
+ }
+} {64 ff80000000000000}
+do_test boundary1-2.18.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ff80000000000000'
+ }
+} {-36028797018963968 64}
+do_test boundary1-2.18.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=64
+ }
+} {-36028797018963968 ff80000000000000}
+do_test boundary1-2.18.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -36028797018963968 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary1-2.18.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -36028797018963968 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.18.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -36028797018963968 ORDER BY rowid
+ }
+} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.18.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -36028797018963968 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}
+do_test boundary1-2.18.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.18.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -36028797018963968 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.18.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -36028797018963968 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.18.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -36028797018963968 ORDER BY rowid
+ }
+} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.18.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -36028797018963968 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}
+do_test boundary1-2.18.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.18.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -36028797018963968 ORDER BY a
+ }
+} {2 55}
+do_test boundary1-2.18.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -36028797018963968 ORDER BY a DESC
+ }
+} {55 2}
+do_test boundary1-2.18.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -36028797018963968 ORDER BY rowid
+ }
+} {55 2}
+do_test boundary1-2.18.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -36028797018963968 ORDER BY rowid DESC
+ }
+} {2 55}
+do_test boundary1-2.18.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -36028797018963968 ORDER BY x
+ }
+} {55 2}
+do_test boundary1-2.18.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -36028797018963968 ORDER BY a
+ }
+} {2 55 64}
+do_test boundary1-2.18.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -36028797018963968 ORDER BY a DESC
+ }
+} {64 55 2}
+do_test boundary1-2.18.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -36028797018963968 ORDER BY rowid
+ }
+} {55 2 64}
+do_test boundary1-2.18.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -36028797018963968 ORDER BY rowid DESC
+ }
+} {64 2 55}
+do_test boundary1-2.18.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -36028797018963968 ORDER BY x
+ }
+} {55 2 64}
+do_test boundary1-2.19.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=65535
+ }
+} {48 000000000000ffff}
+do_test boundary1-2.19.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='000000000000ffff'
+ }
+} {65535 48}
+do_test boundary1-2.19.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=48
+ }
+} {65535 000000000000ffff}
+do_test boundary1-2.19.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 65535 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}
+do_test boundary1-2.19.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 65535 ORDER BY a DESC
+ }
+} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.19.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 65535 ORDER BY rowid
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.19.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 65535 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}
+do_test boundary1-2.19.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 65535 ORDER BY x
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.19.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 65535 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}
+do_test boundary1-2.19.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 65535 ORDER BY a DESC
+ }
+} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.19.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 65535 ORDER BY rowid
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.19.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 65535 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}
+do_test boundary1-2.19.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 65535 ORDER BY x
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.19.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 65535 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.19.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 65535 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary1-2.19.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 65535 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}
+do_test boundary1-2.19.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 65535 ORDER BY rowid DESC
+ }
+} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.19.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 65535 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.19.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 65535 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.19.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 65535 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary1-2.19.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 65535 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}
+do_test boundary1-2.19.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 65535 ORDER BY rowid DESC
+ }
+} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.19.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 65535 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.20.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=4294967295
+ }
+} {14 00000000ffffffff}
+do_test boundary1-2.20.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='00000000ffffffff'
+ }
+} {4294967295 14}
+do_test boundary1-2.20.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=14
+ }
+} {4294967295 00000000ffffffff}
+do_test boundary1-2.20.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4294967295 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary1-2.20.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4294967295 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary1-2.20.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4294967295 ORDER BY rowid
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.20.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4294967295 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}
+do_test boundary1-2.20.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4294967295 ORDER BY x
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.20.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4294967295 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary1-2.20.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4294967295 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary1-2.20.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4294967295 ORDER BY rowid
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.20.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4294967295 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}
+do_test boundary1-2.20.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4294967295 ORDER BY x
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.20.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4294967295 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.20.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4294967295 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.20.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4294967295 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}
+do_test boundary1-2.20.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4294967295 ORDER BY rowid DESC
+ }
+} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.20.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4294967295 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.20.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4294967295 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.20.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4294967295 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.20.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4294967295 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}
+do_test boundary1-2.20.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4294967295 ORDER BY rowid DESC
+ }
+} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.20.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4294967295 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.21.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=1099511627775
+ }
+} {57 000000ffffffffff}
+do_test boundary1-2.21.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='000000ffffffffff'
+ }
+} {1099511627775 57}
+do_test boundary1-2.21.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=57
+ }
+} {1099511627775 000000ffffffffff}
+do_test boundary1-2.21.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1099511627775 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}
+do_test boundary1-2.21.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1099511627775 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary1-2.21.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1099511627775 ORDER BY rowid
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.21.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1099511627775 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}
+do_test boundary1-2.21.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1099511627775 ORDER BY x
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.21.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1099511627775 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}
+do_test boundary1-2.21.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1099511627775 ORDER BY a DESC
+ }
+} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary1-2.21.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1099511627775 ORDER BY rowid
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.21.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1099511627775 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}
+do_test boundary1-2.21.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1099511627775 ORDER BY x
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.21.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1099511627775 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.21.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1099511627775 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.21.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1099511627775 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}
+do_test boundary1-2.21.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1099511627775 ORDER BY rowid DESC
+ }
+} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.21.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1099511627775 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.21.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1099511627775 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary1-2.21.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1099511627775 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.21.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1099511627775 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}
+do_test boundary1-2.21.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1099511627775 ORDER BY rowid DESC
+ }
+} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.21.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1099511627775 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.22.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-8388608
+ }
+} {37 ffffffffff800000}
+do_test boundary1-2.22.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffffffff800000'
+ }
+} {-8388608 37}
+do_test boundary1-2.22.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=37
+ }
+} {-8388608 ffffffffff800000}
+do_test boundary1-2.22.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -8388608 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.22.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -8388608 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.22.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -8388608 ORDER BY rowid
+ }
+} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.22.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -8388608 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}
+do_test boundary1-2.22.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}
+do_test boundary1-2.22.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -8388608 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.22.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -8388608 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.22.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -8388608 ORDER BY rowid
+ }
+} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.22.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -8388608 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}
+do_test boundary1-2.22.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}
+do_test boundary1-2.22.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -8388608 ORDER BY a
+ }
+} {1 2 11 21 44 47 55 58 63 64}
+do_test boundary1-2.22.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -8388608 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2 1}
+do_test boundary1-2.22.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -8388608 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary1-2.22.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -8388608 ORDER BY rowid DESC
+ }
+} {1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.22.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -8388608 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary1-2.22.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -8388608 ORDER BY a
+ }
+} {1 2 11 21 37 44 47 55 58 63 64}
+do_test boundary1-2.22.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -8388608 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 21 11 2 1}
+do_test boundary1-2.22.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -8388608 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary1-2.22.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -8388608 ORDER BY rowid DESC
+ }
+} {37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.22.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -8388608 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary1-2.23.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=549755813888
+ }
+} {35 0000008000000000}
+do_test boundary1-2.23.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000008000000000'
+ }
+} {549755813888 35}
+do_test boundary1-2.23.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=35
+ }
+} {549755813888 0000008000000000}
+do_test boundary1-2.23.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 549755813888 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}
+do_test boundary1-2.23.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 549755813888 ORDER BY a DESC
+ }
+} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary1-2.23.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 549755813888 ORDER BY rowid
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.23.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 549755813888 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}
+do_test boundary1-2.23.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 549755813888 ORDER BY x
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.23.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 549755813888 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}
+do_test boundary1-2.23.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 549755813888 ORDER BY a DESC
+ }
+} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary1-2.23.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 549755813888 ORDER BY rowid
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.23.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 549755813888 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}
+do_test boundary1-2.23.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 549755813888 ORDER BY x
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.23.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 549755813888 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.23.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 549755813888 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.23.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 549755813888 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}
+do_test boundary1-2.23.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 549755813888 ORDER BY rowid DESC
+ }
+} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.23.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.23.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 549755813888 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.23.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 549755813888 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.23.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 549755813888 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}
+do_test boundary1-2.23.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 549755813888 ORDER BY rowid DESC
+ }
+} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.23.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.24.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=8388607
+ }
+} {18 00000000007fffff}
+do_test boundary1-2.24.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='00000000007fffff'
+ }
+} {8388607 18}
+do_test boundary1-2.24.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=18
+ }
+} {8388607 00000000007fffff}
+do_test boundary1-2.24.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 8388607 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.24.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 8388607 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary1-2.24.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 8388607 ORDER BY rowid
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.24.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 8388607 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}
+do_test boundary1-2.24.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 8388607 ORDER BY x
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.24.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 8388607 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.24.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 8388607 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary1-2.24.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 8388607 ORDER BY rowid
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.24.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 8388607 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}
+do_test boundary1-2.24.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 8388607 ORDER BY x
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.24.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 8388607 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.24.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 8388607 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary1-2.24.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 8388607 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}
+do_test boundary1-2.24.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 8388607 ORDER BY rowid DESC
+ }
+} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.24.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 8388607 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.24.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 8388607 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.24.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 8388607 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary1-2.24.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 8388607 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}
+do_test boundary1-2.24.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 8388607 ORDER BY rowid DESC
+ }
+} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.24.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 8388607 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.25.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-3
+ }
+} {52 fffffffffffffffd}
+do_test boundary1-2.25.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='fffffffffffffffd'
+ }
+} {-3 52}
+do_test boundary1-2.25.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=52
+ }
+} {-3 fffffffffffffffd}
+do_test boundary1-2.25.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -3 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary1-2.25.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -3 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.25.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -3 ORDER BY rowid
+ }
+} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.25.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -3 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}
+do_test boundary1-2.25.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -3 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}
+do_test boundary1-2.25.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -3 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}
+do_test boundary1-2.25.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -3 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.25.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -3 ORDER BY rowid
+ }
+} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.25.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -3 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}
+do_test boundary1-2.25.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -3 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}
+do_test boundary1-2.25.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -3 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}
+do_test boundary1-2.25.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -3 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}
+do_test boundary1-2.25.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -3 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary1-2.25.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -3 ORDER BY rowid DESC
+ }
+} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.25.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -3 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary1-2.25.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -3 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}
+do_test boundary1-2.25.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -3 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}
+do_test boundary1-2.25.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -3 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary1-2.25.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -3 ORDER BY rowid DESC
+ }
+} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.25.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -3 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary1-2.26.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=0
+ }
+} {59 0000000000000000}
+do_test boundary1-2.26.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000000000'
+ }
+} {0 59}
+do_test boundary1-2.26.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=59
+ }
+} {0 0000000000000000}
+do_test boundary1-2.26.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 0 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}
+do_test boundary1-2.26.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 0 ORDER BY a DESC
+ }
+} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.26.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 0 ORDER BY rowid
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.26.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 0 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}
+do_test boundary1-2.26.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 0 ORDER BY x
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.26.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 0 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary1-2.26.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 0 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.26.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 0 ORDER BY rowid
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.26.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 0 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}
+do_test boundary1-2.26.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 0 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.26.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 0 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}
+do_test boundary1-2.26.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 0 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary1-2.26.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 0 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.26.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 0 ORDER BY rowid DESC
+ }
+} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.26.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 0 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.26.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 0 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}
+do_test boundary1-2.26.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 0 ORDER BY a DESC
+ }
+} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary1-2.26.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 0 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}
+do_test boundary1-2.26.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 0 ORDER BY rowid DESC
+ }
+} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.26.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 0 ORDER BY x
+ }
+} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.27.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-1
+ }
+} {38 ffffffffffffffff}
+do_test boundary1-2.27.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffffffffffffff'
+ }
+} {-1 38}
+do_test boundary1-2.27.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=38
+ }
+} {-1 ffffffffffffffff}
+do_test boundary1-2.27.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary1-2.27.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -1 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.27.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -1 ORDER BY rowid
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.27.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -1 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}
+do_test boundary1-2.27.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -1 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.27.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary1-2.27.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -1 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.27.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -1 ORDER BY rowid
+ }
+} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.27.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -1 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}
+do_test boundary1-2.27.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -1 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}
+do_test boundary1-2.27.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}
+do_test boundary1-2.27.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -1 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}
+do_test boundary1-2.27.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -1 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary1-2.27.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -1 ORDER BY rowid DESC
+ }
+} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.27.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -1 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary1-2.27.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}
+do_test boundary1-2.27.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -1 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary1-2.27.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -1 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.27.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -1 ORDER BY rowid DESC
+ }
+} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.27.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -1 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.28.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-2
+ }
+} {33 fffffffffffffffe}
+do_test boundary1-2.28.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='fffffffffffffffe'
+ }
+} {-2 33}
+do_test boundary1-2.28.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=33
+ }
+} {-2 fffffffffffffffe}
+do_test boundary1-2.28.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary1-2.28.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.28.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2 ORDER BY rowid
+ }
+} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.28.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}
+do_test boundary1-2.28.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}
+do_test boundary1-2.28.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary1-2.28.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.28.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2 ORDER BY rowid
+ }
+} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.28.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}
+do_test boundary1-2.28.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}
+do_test boundary1-2.28.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}
+do_test boundary1-2.28.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}
+do_test boundary1-2.28.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary1-2.28.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2 ORDER BY rowid DESC
+ }
+} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.28.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary1-2.28.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}
+do_test boundary1-2.28.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}
+do_test boundary1-2.28.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary1-2.28.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2 ORDER BY rowid DESC
+ }
+} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.28.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary1-2.29.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=2097152
+ }
+} {42 0000000000200000}
+do_test boundary1-2.29.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000200000'
+ }
+} {2097152 42}
+do_test boundary1-2.29.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=42
+ }
+} {2097152 0000000000200000}
+do_test boundary1-2.29.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2097152 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.29.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2097152 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary1-2.29.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2097152 ORDER BY rowid
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.29.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2097152 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}
+do_test boundary1-2.29.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2097152 ORDER BY x
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.29.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2097152 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary1-2.29.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2097152 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary1-2.29.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2097152 ORDER BY rowid
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.29.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2097152 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}
+do_test boundary1-2.29.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2097152 ORDER BY x
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.29.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2097152 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.29.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2097152 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary1-2.29.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2097152 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}
+do_test boundary1-2.29.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2097152 ORDER BY rowid DESC
+ }
+} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.29.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2097152 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.29.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2097152 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.29.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2097152 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary1-2.29.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2097152 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}
+do_test boundary1-2.29.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2097152 ORDER BY rowid DESC
+ }
+} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.29.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2097152 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.30.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=128
+ }
+} {49 0000000000000080}
+do_test boundary1-2.30.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000000080'
+ }
+} {128 49}
+do_test boundary1-2.30.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=49
+ }
+} {128 0000000000000080}
+do_test boundary1-2.30.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 128 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary1-2.30.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 128 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary1-2.30.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 128 ORDER BY rowid
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.30.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 128 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}
+do_test boundary1-2.30.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 128 ORDER BY x
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.30.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 128 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary1-2.30.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 128 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary1-2.30.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 128 ORDER BY rowid
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.30.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 128 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}
+do_test boundary1-2.30.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 128 ORDER BY x
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.30.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 128 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.30.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 128 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary1-2.30.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 128 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}
+do_test boundary1-2.30.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 128 ORDER BY rowid DESC
+ }
+} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.30.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 128 ORDER BY x
+ }
+} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.30.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 128 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.30.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 128 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary1-2.30.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 128 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}
+do_test boundary1-2.30.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 128 ORDER BY rowid DESC
+ }
+} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.30.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 128 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.31.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=255
+ }
+} {30 00000000000000ff}
+do_test boundary1-2.31.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='00000000000000ff'
+ }
+} {255 30}
+do_test boundary1-2.31.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=30
+ }
+} {255 00000000000000ff}
+do_test boundary1-2.31.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 255 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary1-2.31.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 255 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary1-2.31.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 255 ORDER BY rowid
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.31.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 255 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}
+do_test boundary1-2.31.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 255 ORDER BY x
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.31.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 255 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary1-2.31.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 255 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary1-2.31.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 255 ORDER BY rowid
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.31.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 255 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}
+do_test boundary1-2.31.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 255 ORDER BY x
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.31.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 255 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.31.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 255 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary1-2.31.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 255 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}
+do_test boundary1-2.31.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 255 ORDER BY rowid DESC
+ }
+} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.31.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 255 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.31.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 255 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.31.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 255 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary1-2.31.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 255 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}
+do_test boundary1-2.31.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 255 ORDER BY rowid DESC
+ }
+} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.31.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 255 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.32.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-2147483648
+ }
+} {11 ffffffff80000000}
+do_test boundary1-2.32.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffffff80000000'
+ }
+} {-2147483648 11}
+do_test boundary1-2.32.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=11
+ }
+} {-2147483648 ffffffff80000000}
+do_test boundary1-2.32.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2147483648 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.32.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2147483648 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.32.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2147483648 ORDER BY rowid
+ }
+} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.32.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2147483648 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}
+do_test boundary1-2.32.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.32.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2147483648 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.32.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2147483648 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.32.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2147483648 ORDER BY rowid
+ }
+} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.32.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2147483648 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}
+do_test boundary1-2.32.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.32.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2147483648 ORDER BY a
+ }
+} {2 21 44 47 55 58 63 64}
+do_test boundary1-2.32.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2147483648 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 2}
+do_test boundary1-2.32.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2147483648 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary1-2.32.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2147483648 ORDER BY rowid DESC
+ }
+} {47 63 58 44 21 64 2 55}
+do_test boundary1-2.32.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2147483648 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary1-2.32.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2147483648 ORDER BY a
+ }
+} {2 11 21 44 47 55 58 63 64}
+do_test boundary1-2.32.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2147483648 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2}
+do_test boundary1-2.32.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2147483648 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary1-2.32.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2147483648 ORDER BY rowid DESC
+ }
+} {11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.32.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2147483648 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary1-2.33.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=34359738367
+ }
+} {39 00000007ffffffff}
+do_test boundary1-2.33.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='00000007ffffffff'
+ }
+} {34359738367 39}
+do_test boundary1-2.33.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=39
+ }
+} {34359738367 00000007ffffffff}
+do_test boundary1-2.33.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 34359738367 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary1-2.33.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 34359738367 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary1-2.33.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 34359738367 ORDER BY rowid
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.33.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 34359738367 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}
+do_test boundary1-2.33.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 34359738367 ORDER BY x
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.33.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 34359738367 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}
+do_test boundary1-2.33.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 34359738367 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary1-2.33.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 34359738367 ORDER BY rowid
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.33.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 34359738367 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}
+do_test boundary1-2.33.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 34359738367 ORDER BY x
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.33.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 34359738367 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.33.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 34359738367 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.33.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 34359738367 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}
+do_test boundary1-2.33.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 34359738367 ORDER BY rowid DESC
+ }
+} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.33.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 34359738367 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.33.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 34359738367 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.33.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 34359738367 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.33.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 34359738367 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}
+do_test boundary1-2.33.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 34359738367 ORDER BY rowid DESC
+ }
+} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.33.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 34359738367 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.34.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-549755813889
+ }
+} {58 ffffff7fffffffff}
+do_test boundary1-2.34.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffff7fffffffff'
+ }
+} {-549755813889 58}
+do_test boundary1-2.34.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=58
+ }
+} {-549755813889 ffffff7fffffffff}
+do_test boundary1-2.34.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -549755813889 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}
+do_test boundary1-2.34.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -549755813889 ORDER BY a DESC
+ }
+} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.34.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -549755813889 ORDER BY rowid
+ }
+} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.34.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -549755813889 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}
+do_test boundary1-2.34.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -549755813889 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.34.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -549755813889 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary1-2.34.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -549755813889 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.34.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -549755813889 ORDER BY rowid
+ }
+} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.34.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -549755813889 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}
+do_test boundary1-2.34.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -549755813889 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.34.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -549755813889 ORDER BY a
+ }
+} {2 21 44 55 64}
+do_test boundary1-2.34.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -549755813889 ORDER BY a DESC
+ }
+} {64 55 44 21 2}
+do_test boundary1-2.34.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -549755813889 ORDER BY rowid
+ }
+} {55 2 64 21 44}
+do_test boundary1-2.34.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -549755813889 ORDER BY rowid DESC
+ }
+} {44 21 64 2 55}
+do_test boundary1-2.34.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -549755813889 ORDER BY x
+ }
+} {55 2 64 21 44}
+do_test boundary1-2.34.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -549755813889 ORDER BY a
+ }
+} {2 21 44 55 58 64}
+do_test boundary1-2.34.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -549755813889 ORDER BY a DESC
+ }
+} {64 58 55 44 21 2}
+do_test boundary1-2.34.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -549755813889 ORDER BY rowid
+ }
+} {55 2 64 21 44 58}
+do_test boundary1-2.34.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -549755813889 ORDER BY rowid DESC
+ }
+} {58 44 21 64 2 55}
+do_test boundary1-2.34.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -549755813889 ORDER BY x
+ }
+} {55 2 64 21 44 58}
+do_test boundary1-2.35.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-32768
+ }
+} {32 ffffffffffff8000}
+do_test boundary1-2.35.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffffffffff8000'
+ }
+} {-32768 32}
+do_test boundary1-2.35.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=32
+ }
+} {-32768 ffffffffffff8000}
+do_test boundary1-2.35.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -32768 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.35.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -32768 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.35.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -32768 ORDER BY rowid
+ }
+} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.35.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -32768 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}
+do_test boundary1-2.35.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}
+do_test boundary1-2.35.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -32768 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.35.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -32768 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.35.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -32768 ORDER BY rowid
+ }
+} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.35.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -32768 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}
+do_test boundary1-2.35.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}
+do_test boundary1-2.35.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -32768 ORDER BY a
+ }
+} {1 2 11 21 29 37 44 47 55 58 63 64}
+do_test boundary1-2.35.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -32768 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 29 21 11 2 1}
+do_test boundary1-2.35.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -32768 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary1-2.35.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -32768 ORDER BY rowid DESC
+ }
+} {29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.35.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -32768 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary1-2.35.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -32768 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 55 58 63 64}
+do_test boundary1-2.35.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -32768 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 32 29 21 11 2 1}
+do_test boundary1-2.35.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -32768 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary1-2.35.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -32768 ORDER BY rowid DESC
+ }
+} {32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.35.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -32768 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary1-2.36.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=2147483647
+ }
+} {20 000000007fffffff}
+do_test boundary1-2.36.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='000000007fffffff'
+ }
+} {2147483647 20}
+do_test boundary1-2.36.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=20
+ }
+} {2147483647 000000007fffffff}
+do_test boundary1-2.36.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2147483647 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary1-2.36.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2147483647 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary1-2.36.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2147483647 ORDER BY rowid
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.36.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2147483647 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}
+do_test boundary1-2.36.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2147483647 ORDER BY x
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.36.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2147483647 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary1-2.36.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2147483647 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary1-2.36.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2147483647 ORDER BY rowid
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.36.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2147483647 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}
+do_test boundary1-2.36.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2147483647 ORDER BY x
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.36.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2147483647 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.36.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2147483647 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.36.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2147483647 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}
+do_test boundary1-2.36.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2147483647 ORDER BY rowid DESC
+ }
+} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.36.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2147483647 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.36.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2147483647 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.36.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2147483647 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.36.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2147483647 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}
+do_test boundary1-2.36.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2147483647 ORDER BY rowid DESC
+ }
+} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.36.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2147483647 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.37.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-129
+ }
+} {54 ffffffffffffff7f}
+do_test boundary1-2.37.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffffffffffff7f'
+ }
+} {-129 54}
+do_test boundary1-2.37.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=54
+ }
+} {-129 ffffffffffffff7f}
+do_test boundary1-2.37.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -129 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}
+do_test boundary1-2.37.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -129 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.37.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -129 ORDER BY rowid
+ }
+} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.37.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -129 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}
+do_test boundary1-2.37.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -129 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}
+do_test boundary1-2.37.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -129 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.37.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -129 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.37.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -129 ORDER BY rowid
+ }
+} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.37.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -129 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}
+do_test boundary1-2.37.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -129 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}
+do_test boundary1-2.37.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -129 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 55 58 63 64}
+do_test boundary1-2.37.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -129 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 32 29 21 11 2 1}
+do_test boundary1-2.37.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -129 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary1-2.37.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -129 ORDER BY rowid DESC
+ }
+} {32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.37.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -129 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary1-2.37.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -129 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}
+do_test boundary1-2.37.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -129 ORDER BY a DESC
+ }
+} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}
+do_test boundary1-2.37.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -129 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary1-2.37.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -129 ORDER BY rowid DESC
+ }
+} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.37.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -129 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary1-2.38.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-128
+ }
+} {53 ffffffffffffff80}
+do_test boundary1-2.38.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffffffffffff80'
+ }
+} {-128 53}
+do_test boundary1-2.38.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=53
+ }
+} {-128 ffffffffffffff80}
+do_test boundary1-2.38.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -128 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}
+do_test boundary1-2.38.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -128 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.38.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -128 ORDER BY rowid
+ }
+} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.38.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -128 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}
+do_test boundary1-2.38.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -128 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}
+do_test boundary1-2.38.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -128 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}
+do_test boundary1-2.38.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -128 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.38.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -128 ORDER BY rowid
+ }
+} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.38.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -128 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}
+do_test boundary1-2.38.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -128 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}
+do_test boundary1-2.38.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -128 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}
+do_test boundary1-2.38.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -128 ORDER BY a DESC
+ }
+} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}
+do_test boundary1-2.38.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -128 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary1-2.38.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -128 ORDER BY rowid DESC
+ }
+} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.38.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -128 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary1-2.38.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -128 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}
+do_test boundary1-2.38.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -128 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}
+do_test boundary1-2.38.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -128 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary1-2.38.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -128 ORDER BY rowid DESC
+ }
+} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.38.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -128 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary1-2.39.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=72057594037927936
+ }
+} {28 0100000000000000}
+do_test boundary1-2.39.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0100000000000000'
+ }
+} {72057594037927936 28}
+do_test boundary1-2.39.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=28
+ }
+} {72057594037927936 0100000000000000}
+do_test boundary1-2.39.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 72057594037927936 ORDER BY a
+ }
+} {3}
+do_test boundary1-2.39.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 72057594037927936 ORDER BY a DESC
+ }
+} {3}
+do_test boundary1-2.39.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 72057594037927936 ORDER BY rowid
+ }
+} {3}
+do_test boundary1-2.39.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 72057594037927936 ORDER BY rowid DESC
+ }
+} {3}
+do_test boundary1-2.39.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 72057594037927936 ORDER BY x
+ }
+} {3}
+do_test boundary1-2.39.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 72057594037927936 ORDER BY a
+ }
+} {3 28}
+do_test boundary1-2.39.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 72057594037927936 ORDER BY a DESC
+ }
+} {28 3}
+do_test boundary1-2.39.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 72057594037927936 ORDER BY rowid
+ }
+} {28 3}
+do_test boundary1-2.39.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 72057594037927936 ORDER BY rowid DESC
+ }
+} {3 28}
+do_test boundary1-2.39.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 72057594037927936 ORDER BY x
+ }
+} {28 3}
+do_test boundary1-2.39.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 72057594037927936 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.39.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 72057594037927936 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.39.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 72057594037927936 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}
+do_test boundary1-2.39.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 72057594037927936 ORDER BY rowid DESC
+ }
+} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.39.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 72057594037927936 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.39.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 72057594037927936 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.39.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 72057594037927936 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.39.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 72057594037927936 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}
+do_test boundary1-2.39.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 72057594037927936 ORDER BY rowid DESC
+ }
+} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.39.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 72057594037927936 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.40.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=2147483648
+ }
+} {51 0000000080000000}
+do_test boundary1-2.40.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000080000000'
+ }
+} {2147483648 51}
+do_test boundary1-2.40.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=51
+ }
+} {2147483648 0000000080000000}
+do_test boundary1-2.40.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2147483648 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary1-2.40.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2147483648 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary1-2.40.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2147483648 ORDER BY rowid
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.40.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2147483648 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}
+do_test boundary1-2.40.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2147483648 ORDER BY x
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.40.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2147483648 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary1-2.40.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2147483648 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary1-2.40.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2147483648 ORDER BY rowid
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.40.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2147483648 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}
+do_test boundary1-2.40.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2147483648 ORDER BY x
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.40.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2147483648 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.40.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2147483648 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.40.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2147483648 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}
+do_test boundary1-2.40.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2147483648 ORDER BY rowid DESC
+ }
+} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.40.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.40.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2147483648 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.40.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2147483648 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.40.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2147483648 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}
+do_test boundary1-2.40.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2147483648 ORDER BY rowid DESC
+ }
+} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.40.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.41.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=549755813887
+ }
+} {46 0000007fffffffff}
+do_test boundary1-2.41.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000007fffffffff'
+ }
+} {549755813887 46}
+do_test boundary1-2.41.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=46
+ }
+} {549755813887 0000007fffffffff}
+do_test boundary1-2.41.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 549755813887 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}
+do_test boundary1-2.41.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 549755813887 ORDER BY a DESC
+ }
+} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary1-2.41.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 549755813887 ORDER BY rowid
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.41.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 549755813887 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}
+do_test boundary1-2.41.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 549755813887 ORDER BY x
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.41.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 549755813887 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary1-2.41.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 549755813887 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary1-2.41.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 549755813887 ORDER BY rowid
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.41.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 549755813887 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}
+do_test boundary1-2.41.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 549755813887 ORDER BY x
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.41.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 549755813887 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.41.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 549755813887 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.41.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 549755813887 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}
+do_test boundary1-2.41.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 549755813887 ORDER BY rowid DESC
+ }
+} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.41.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 549755813887 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.41.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 549755813887 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.41.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 549755813887 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.41.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 549755813887 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}
+do_test boundary1-2.41.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 549755813887 ORDER BY rowid DESC
+ }
+} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.41.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 549755813887 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.42.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-549755813888
+ }
+} {63 ffffff8000000000}
+do_test boundary1-2.42.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffff8000000000'
+ }
+} {-549755813888 63}
+do_test boundary1-2.42.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=63
+ }
+} {-549755813888 ffffff8000000000}
+do_test boundary1-2.42.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -549755813888 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.42.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -549755813888 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.42.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -549755813888 ORDER BY rowid
+ }
+} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.42.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -549755813888 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}
+do_test boundary1-2.42.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.42.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -549755813888 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}
+do_test boundary1-2.42.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -549755813888 ORDER BY a DESC
+ }
+} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.42.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -549755813888 ORDER BY rowid
+ }
+} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.42.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -549755813888 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}
+do_test boundary1-2.42.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.42.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -549755813888 ORDER BY a
+ }
+} {2 21 44 55 58 64}
+do_test boundary1-2.42.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -549755813888 ORDER BY a DESC
+ }
+} {64 58 55 44 21 2}
+do_test boundary1-2.42.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -549755813888 ORDER BY rowid
+ }
+} {55 2 64 21 44 58}
+do_test boundary1-2.42.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -549755813888 ORDER BY rowid DESC
+ }
+} {58 44 21 64 2 55}
+do_test boundary1-2.42.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -549755813888 ORDER BY x
+ }
+} {55 2 64 21 44 58}
+do_test boundary1-2.42.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -549755813888 ORDER BY a
+ }
+} {2 21 44 55 58 63 64}
+do_test boundary1-2.42.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -549755813888 ORDER BY a DESC
+ }
+} {64 63 58 55 44 21 2}
+do_test boundary1-2.42.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -549755813888 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary1-2.42.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -549755813888 ORDER BY rowid DESC
+ }
+} {63 58 44 21 64 2 55}
+do_test boundary1-2.42.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -549755813888 ORDER BY x
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary1-2.43.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=281474976710655
+ }
+} {10 0000ffffffffffff}
+do_test boundary1-2.43.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000ffffffffffff'
+ }
+} {281474976710655 10}
+do_test boundary1-2.43.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=10
+ }
+} {281474976710655 0000ffffffffffff}
+do_test boundary1-2.43.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 281474976710655 ORDER BY a
+ }
+} {3 13 17 26 27 28 43 45}
+do_test boundary1-2.43.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 281474976710655 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 3}
+do_test boundary1-2.43.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 281474976710655 ORDER BY rowid
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary1-2.43.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 281474976710655 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26}
+do_test boundary1-2.43.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 281474976710655 ORDER BY x
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary1-2.43.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 281474976710655 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 43 45}
+do_test boundary1-2.43.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 281474976710655 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 10 3}
+do_test boundary1-2.43.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 281474976710655 ORDER BY rowid
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.43.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 281474976710655 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10}
+do_test boundary1-2.43.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 281474976710655 ORDER BY x
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.43.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 281474976710655 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.43.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 281474976710655 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary1-2.43.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 281474976710655 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}
+do_test boundary1-2.43.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 281474976710655 ORDER BY rowid DESC
+ }
+} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.43.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 281474976710655 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.43.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 281474976710655 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.43.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 281474976710655 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.43.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 281474976710655 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}
+do_test boundary1-2.43.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 281474976710655 ORDER BY rowid DESC
+ }
+} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.43.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 281474976710655 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.44.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=4398046511103
+ }
+} {7 000003ffffffffff}
+do_test boundary1-2.44.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='000003ffffffffff'
+ }
+} {4398046511103 7}
+do_test boundary1-2.44.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=7
+ }
+} {4398046511103 000003ffffffffff}
+do_test boundary1-2.44.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4398046511103 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary1-2.44.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4398046511103 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary1-2.44.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4398046511103 ORDER BY rowid
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.44.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4398046511103 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56}
+do_test boundary1-2.44.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4398046511103 ORDER BY x
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.44.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4398046511103 ORDER BY a
+ }
+} {3 7 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary1-2.44.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4398046511103 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 7 3}
+do_test boundary1-2.44.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4398046511103 ORDER BY rowid
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.44.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4398046511103 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7}
+do_test boundary1-2.44.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4398046511103 ORDER BY x
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.44.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4398046511103 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary1-2.44.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4398046511103 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.44.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4398046511103 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}
+do_test boundary1-2.44.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4398046511103 ORDER BY rowid DESC
+ }
+} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.44.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4398046511103 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.44.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4398046511103 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary1-2.44.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4398046511103 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary1-2.44.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4398046511103 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}
+do_test boundary1-2.44.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4398046511103 ORDER BY rowid DESC
+ }
+} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.44.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4398046511103 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.45.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=268435455
+ }
+} {12 000000000fffffff}
+do_test boundary1-2.45.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='000000000fffffff'
+ }
+} {268435455 12}
+do_test boundary1-2.45.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=12
+ }
+} {268435455 000000000fffffff}
+do_test boundary1-2.45.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 268435455 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.45.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 268435455 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary1-2.45.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 268435455 ORDER BY rowid
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.45.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 268435455 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}
+do_test boundary1-2.45.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 268435455 ORDER BY x
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.45.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 268435455 ORDER BY a
+ }
+} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.45.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 268435455 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}
+do_test boundary1-2.45.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 268435455 ORDER BY rowid
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.45.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 268435455 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}
+do_test boundary1-2.45.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 268435455 ORDER BY x
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.45.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 268435455 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.45.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 268435455 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}
+do_test boundary1-2.45.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 268435455 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}
+do_test boundary1-2.45.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 268435455 ORDER BY rowid DESC
+ }
+} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.45.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 268435455 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.45.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 268435455 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.45.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 268435455 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary1-2.45.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 268435455 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}
+do_test boundary1-2.45.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 268435455 ORDER BY rowid DESC
+ }
+} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.45.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 268435455 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.46.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-9223372036854775808
+ }
+} {55 8000000000000000}
+do_test boundary1-2.46.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='8000000000000000'
+ }
+} {-9223372036854775808 55}
+do_test boundary1-2.46.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=55
+ }
+} {-9223372036854775808 8000000000000000}
+do_test boundary1-2.46.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -9223372036854775808 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.46.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -9223372036854775808 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary1-2.46.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -9223372036854775808 ORDER BY rowid
+ }
+} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.46.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -9223372036854775808 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}
+do_test boundary1-2.46.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -9223372036854775808 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.46.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -9223372036854775808 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.46.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -9223372036854775808 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary1-2.46.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -9223372036854775808 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.46.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -9223372036854775808 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.46.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -9223372036854775808 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.46.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -9223372036854775808 ORDER BY a
+ }
+} {}
+do_test boundary1-2.46.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -9223372036854775808 ORDER BY a DESC
+ }
+} {}
+do_test boundary1-2.46.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -9223372036854775808 ORDER BY rowid
+ }
+} {}
+do_test boundary1-2.46.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -9223372036854775808 ORDER BY rowid DESC
+ }
+} {}
+do_test boundary1-2.46.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -9223372036854775808 ORDER BY x
+ }
+} {}
+do_test boundary1-2.46.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -9223372036854775808 ORDER BY a
+ }
+} {55}
+do_test boundary1-2.46.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -9223372036854775808 ORDER BY a DESC
+ }
+} {55}
+do_test boundary1-2.46.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -9223372036854775808 ORDER BY rowid
+ }
+} {55}
+do_test boundary1-2.46.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -9223372036854775808 ORDER BY rowid DESC
+ }
+} {55}
+do_test boundary1-2.46.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -9223372036854775808 ORDER BY x
+ }
+} {55}
+do_test boundary1-2.47.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=562949953421312
+ }
+} {43 0002000000000000}
+do_test boundary1-2.47.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0002000000000000'
+ }
+} {562949953421312 43}
+do_test boundary1-2.47.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=43
+ }
+} {562949953421312 0002000000000000}
+do_test boundary1-2.47.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 562949953421312 ORDER BY a
+ }
+} {3 17 27 28 45}
+do_test boundary1-2.47.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 562949953421312 ORDER BY a DESC
+ }
+} {45 28 27 17 3}
+do_test boundary1-2.47.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 562949953421312 ORDER BY rowid
+ }
+} {27 45 17 28 3}
+do_test boundary1-2.47.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 562949953421312 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27}
+do_test boundary1-2.47.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 562949953421312 ORDER BY x
+ }
+} {27 45 17 28 3}
+do_test boundary1-2.47.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 562949953421312 ORDER BY a
+ }
+} {3 17 27 28 43 45}
+do_test boundary1-2.47.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 562949953421312 ORDER BY a DESC
+ }
+} {45 43 28 27 17 3}
+do_test boundary1-2.47.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 562949953421312 ORDER BY rowid
+ }
+} {43 27 45 17 28 3}
+do_test boundary1-2.47.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 562949953421312 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43}
+do_test boundary1-2.47.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 562949953421312 ORDER BY x
+ }
+} {43 27 45 17 28 3}
+do_test boundary1-2.47.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 562949953421312 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.47.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 562949953421312 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.47.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 562949953421312 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}
+do_test boundary1-2.47.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 562949953421312 ORDER BY rowid DESC
+ }
+} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.47.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 562949953421312 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.47.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 562949953421312 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.47.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 562949953421312 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.47.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 562949953421312 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}
+do_test boundary1-2.47.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 562949953421312 ORDER BY rowid DESC
+ }
+} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.47.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 562949953421312 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.48.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-8388609
+ }
+} {1 ffffffffff7fffff}
+do_test boundary1-2.48.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffffffff7fffff'
+ }
+} {-8388609 1}
+do_test boundary1-2.48.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=1
+ }
+} {-8388609 ffffffffff7fffff}
+do_test boundary1-2.48.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -8388609 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.48.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -8388609 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.48.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -8388609 ORDER BY rowid
+ }
+} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.48.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -8388609 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}
+do_test boundary1-2.48.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -8388609 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}
+do_test boundary1-2.48.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -8388609 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.48.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -8388609 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.48.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -8388609 ORDER BY rowid
+ }
+} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.48.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -8388609 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}
+do_test boundary1-2.48.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -8388609 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.48.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -8388609 ORDER BY a
+ }
+} {2 11 21 44 47 55 58 63 64}
+do_test boundary1-2.48.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -8388609 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2}
+do_test boundary1-2.48.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -8388609 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary1-2.48.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -8388609 ORDER BY rowid DESC
+ }
+} {11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.48.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -8388609 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary1-2.48.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -8388609 ORDER BY a
+ }
+} {1 2 11 21 44 47 55 58 63 64}
+do_test boundary1-2.48.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -8388609 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2 1}
+do_test boundary1-2.48.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -8388609 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary1-2.48.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -8388609 ORDER BY rowid DESC
+ }
+} {1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.48.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -8388609 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary1-2.49.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=16777215
+ }
+} {9 0000000000ffffff}
+do_test boundary1-2.49.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000ffffff'
+ }
+} {16777215 9}
+do_test boundary1-2.49.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=9
+ }
+} {16777215 0000000000ffffff}
+do_test boundary1-2.49.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16777215 ORDER BY a
+ }
+} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.49.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16777215 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}
+do_test boundary1-2.49.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16777215 ORDER BY rowid
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.49.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16777215 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}
+do_test boundary1-2.49.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16777215 ORDER BY x
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.49.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16777215 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.49.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16777215 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary1-2.49.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16777215 ORDER BY rowid
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.49.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16777215 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}
+do_test boundary1-2.49.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16777215 ORDER BY x
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.49.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16777215 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.49.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16777215 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary1-2.49.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16777215 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}
+do_test boundary1-2.49.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16777215 ORDER BY rowid DESC
+ }
+} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.49.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16777215 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.49.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16777215 ORDER BY a
+ }
+} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.49.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16777215 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}
+do_test boundary1-2.49.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16777215 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}
+do_test boundary1-2.49.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16777215 ORDER BY rowid DESC
+ }
+} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.49.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16777215 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.50.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=8388608
+ }
+} {24 0000000000800000}
+do_test boundary1-2.50.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000800000'
+ }
+} {8388608 24}
+do_test boundary1-2.50.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=24
+ }
+} {8388608 0000000000800000}
+do_test boundary1-2.50.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 8388608 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.50.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 8388608 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary1-2.50.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 8388608 ORDER BY rowid
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.50.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 8388608 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}
+do_test boundary1-2.50.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 8388608 ORDER BY x
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.50.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 8388608 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary1-2.50.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 8388608 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary1-2.50.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 8388608 ORDER BY rowid
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.50.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 8388608 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}
+do_test boundary1-2.50.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 8388608 ORDER BY x
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.50.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 8388608 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.50.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 8388608 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary1-2.50.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 8388608 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}
+do_test boundary1-2.50.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 8388608 ORDER BY rowid DESC
+ }
+} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.50.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.50.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 8388608 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.50.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 8388608 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary1-2.50.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 8388608 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}
+do_test boundary1-2.50.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 8388608 ORDER BY rowid DESC
+ }
+} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.50.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.51.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=16383
+ }
+} {8 0000000000003fff}
+do_test boundary1-2.51.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000003fff'
+ }
+} {16383 8}
+do_test boundary1-2.51.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=8
+ }
+} {16383 0000000000003fff}
+do_test boundary1-2.51.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16383 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary1-2.51.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16383 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.51.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16383 ORDER BY rowid
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.51.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16383 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}
+do_test boundary1-2.51.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 16383 ORDER BY x
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.51.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16383 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary1-2.51.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16383 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary1-2.51.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16383 ORDER BY rowid
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.51.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16383 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}
+do_test boundary1-2.51.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 16383 ORDER BY x
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.51.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16383 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.51.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16383 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary1-2.51.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16383 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}
+do_test boundary1-2.51.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16383 ORDER BY rowid DESC
+ }
+} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.51.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 16383 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.51.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16383 ORDER BY a
+ }
+} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.51.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16383 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}
+do_test boundary1-2.51.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16383 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}
+do_test boundary1-2.51.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16383 ORDER BY rowid DESC
+ }
+} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.51.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 16383 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.52.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=140737488355328
+ }
+} {34 0000800000000000}
+do_test boundary1-2.52.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000800000000000'
+ }
+} {140737488355328 34}
+do_test boundary1-2.52.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=34
+ }
+} {140737488355328 0000800000000000}
+do_test boundary1-2.52.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 140737488355328 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 43 45}
+do_test boundary1-2.52.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 140737488355328 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 10 3}
+do_test boundary1-2.52.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 140737488355328 ORDER BY rowid
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.52.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 140737488355328 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10}
+do_test boundary1-2.52.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 140737488355328 ORDER BY x
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.52.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 140737488355328 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 34 43 45}
+do_test boundary1-2.52.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 140737488355328 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 17 13 10 3}
+do_test boundary1-2.52.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 140737488355328 ORDER BY rowid
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.52.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 140737488355328 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34}
+do_test boundary1-2.52.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 140737488355328 ORDER BY x
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.52.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 140737488355328 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.52.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 140737488355328 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary1-2.52.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 140737488355328 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}
+do_test boundary1-2.52.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 140737488355328 ORDER BY rowid DESC
+ }
+} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.52.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.52.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 140737488355328 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.52.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 140737488355328 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary1-2.52.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 140737488355328 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}
+do_test boundary1-2.52.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 140737488355328 ORDER BY rowid DESC
+ }
+} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.52.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.53.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=2097151
+ }
+} {15 00000000001fffff}
+do_test boundary1-2.53.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='00000000001fffff'
+ }
+} {2097151 15}
+do_test boundary1-2.53.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=15
+ }
+} {2097151 00000000001fffff}
+do_test boundary1-2.53.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2097151 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary1-2.53.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2097151 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary1-2.53.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2097151 ORDER BY rowid
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.53.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2097151 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}
+do_test boundary1-2.53.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 2097151 ORDER BY x
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.53.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2097151 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary1-2.53.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2097151 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.53.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2097151 ORDER BY rowid
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.53.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2097151 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}
+do_test boundary1-2.53.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 2097151 ORDER BY x
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.53.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2097151 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.53.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2097151 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary1-2.53.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2097151 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}
+do_test boundary1-2.53.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2097151 ORDER BY rowid DESC
+ }
+} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.53.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 2097151 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.53.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2097151 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary1-2.53.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2097151 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary1-2.53.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2097151 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}
+do_test boundary1-2.53.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2097151 ORDER BY rowid DESC
+ }
+} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.53.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 2097151 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.54.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=140737488355327
+ }
+} {25 00007fffffffffff}
+do_test boundary1-2.54.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='00007fffffffffff'
+ }
+} {140737488355327 25}
+do_test boundary1-2.54.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=25
+ }
+} {140737488355327 00007fffffffffff}
+do_test boundary1-2.54.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 140737488355327 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 34 43 45}
+do_test boundary1-2.54.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 140737488355327 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 17 13 10 3}
+do_test boundary1-2.54.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 140737488355327 ORDER BY rowid
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.54.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 140737488355327 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34}
+do_test boundary1-2.54.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 140737488355327 ORDER BY x
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.54.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 140737488355327 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45}
+do_test boundary1-2.54.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 140737488355327 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary1-2.54.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 140737488355327 ORDER BY rowid
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.54.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 140737488355327 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25}
+do_test boundary1-2.54.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 140737488355327 ORDER BY x
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.54.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 140737488355327 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.54.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 140737488355327 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary1-2.54.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 140737488355327 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}
+do_test boundary1-2.54.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 140737488355327 ORDER BY rowid DESC
+ }
+} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.54.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 140737488355327 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.54.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 140737488355327 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.54.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 140737488355327 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary1-2.54.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 140737488355327 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}
+do_test boundary1-2.54.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 140737488355327 ORDER BY rowid DESC
+ }
+} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.54.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 140737488355327 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.55.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=281474976710656
+ }
+} {26 0001000000000000}
+do_test boundary1-2.55.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0001000000000000'
+ }
+} {281474976710656 26}
+do_test boundary1-2.55.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=26
+ }
+} {281474976710656 0001000000000000}
+do_test boundary1-2.55.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 281474976710656 ORDER BY a
+ }
+} {3 13 17 27 28 43 45}
+do_test boundary1-2.55.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 281474976710656 ORDER BY a DESC
+ }
+} {45 43 28 27 17 13 3}
+do_test boundary1-2.55.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 281474976710656 ORDER BY rowid
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary1-2.55.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 281474976710656 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13}
+do_test boundary1-2.55.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 281474976710656 ORDER BY x
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary1-2.55.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 281474976710656 ORDER BY a
+ }
+} {3 13 17 26 27 28 43 45}
+do_test boundary1-2.55.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 281474976710656 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 3}
+do_test boundary1-2.55.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 281474976710656 ORDER BY rowid
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary1-2.55.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 281474976710656 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26}
+do_test boundary1-2.55.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 281474976710656 ORDER BY x
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary1-2.55.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 281474976710656 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.55.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 281474976710656 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.55.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 281474976710656 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}
+do_test boundary1-2.55.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 281474976710656 ORDER BY rowid DESC
+ }
+} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.55.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 281474976710656 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.55.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 281474976710656 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.55.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 281474976710656 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.55.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 281474976710656 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}
+do_test boundary1-2.55.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 281474976710656 ORDER BY rowid DESC
+ }
+} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.55.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 281474976710656 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.56.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=32767
+ }
+} {23 0000000000007fff}
+do_test boundary1-2.56.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000007fff'
+ }
+} {32767 23}
+do_test boundary1-2.56.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=23
+ }
+} {32767 0000000000007fff}
+do_test boundary1-2.56.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 32767 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary1-2.56.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 32767 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.56.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 32767 ORDER BY rowid
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.56.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 32767 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}
+do_test boundary1-2.56.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 32767 ORDER BY x
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.56.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 32767 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary1-2.56.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 32767 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary1-2.56.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 32767 ORDER BY rowid
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.56.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 32767 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}
+do_test boundary1-2.56.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 32767 ORDER BY x
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.56.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 32767 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.56.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 32767 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}
+do_test boundary1-2.56.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 32767 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}
+do_test boundary1-2.56.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 32767 ORDER BY rowid DESC
+ }
+} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.56.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 32767 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.56.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 32767 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary1-2.56.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 32767 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary1-2.56.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 32767 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}
+do_test boundary1-2.56.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 32767 ORDER BY rowid DESC
+ }
+} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.56.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 32767 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.57.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=127
+ }
+} {4 000000000000007f}
+do_test boundary1-2.57.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='000000000000007f'
+ }
+} {127 4}
+do_test boundary1-2.57.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=4
+ }
+} {127 000000000000007f}
+do_test boundary1-2.57.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 127 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary1-2.57.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 127 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary1-2.57.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 127 ORDER BY rowid
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.57.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 127 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}
+do_test boundary1-2.57.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 127 ORDER BY x
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.57.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 127 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary1-2.57.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 127 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary1-2.57.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 127 ORDER BY rowid
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.57.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 127 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}
+do_test boundary1-2.57.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 127 ORDER BY x
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.57.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 127 ORDER BY a
+ }
+} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.57.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 127 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}
+do_test boundary1-2.57.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 127 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}
+do_test boundary1-2.57.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 127 ORDER BY rowid DESC
+ }
+} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.57.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 127 ORDER BY x
+ }
+} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.57.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 127 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.57.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 127 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary1-2.57.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 127 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}
+do_test boundary1-2.57.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 127 ORDER BY rowid DESC
+ }
+} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.57.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 127 ORDER BY x
+ }
+} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.58.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=36028797018963967
+ }
+} {27 007fffffffffffff}
+do_test boundary1-2.58.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='007fffffffffffff'
+ }
+} {36028797018963967 27}
+do_test boundary1-2.58.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=27
+ }
+} {36028797018963967 007fffffffffffff}
+do_test boundary1-2.58.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 36028797018963967 ORDER BY a
+ }
+} {3 17 28 45}
+do_test boundary1-2.58.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 36028797018963967 ORDER BY a DESC
+ }
+} {45 28 17 3}
+do_test boundary1-2.58.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 36028797018963967 ORDER BY rowid
+ }
+} {45 17 28 3}
+do_test boundary1-2.58.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 36028797018963967 ORDER BY rowid DESC
+ }
+} {3 28 17 45}
+do_test boundary1-2.58.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 36028797018963967 ORDER BY x
+ }
+} {45 17 28 3}
+do_test boundary1-2.58.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 36028797018963967 ORDER BY a
+ }
+} {3 17 27 28 45}
+do_test boundary1-2.58.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 36028797018963967 ORDER BY a DESC
+ }
+} {45 28 27 17 3}
+do_test boundary1-2.58.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 36028797018963967 ORDER BY rowid
+ }
+} {27 45 17 28 3}
+do_test boundary1-2.58.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 36028797018963967 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27}
+do_test boundary1-2.58.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 36028797018963967 ORDER BY x
+ }
+} {27 45 17 28 3}
+do_test boundary1-2.58.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 36028797018963967 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.58.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 36028797018963967 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.58.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 36028797018963967 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}
+do_test boundary1-2.58.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 36028797018963967 ORDER BY rowid DESC
+ }
+} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.58.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 36028797018963967 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.58.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 36028797018963967 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.58.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 36028797018963967 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.58.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 36028797018963967 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}
+do_test boundary1-2.58.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 36028797018963967 ORDER BY rowid DESC
+ }
+} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.58.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 36028797018963967 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.59.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=4398046511104
+ }
+} {56 0000040000000000}
+do_test boundary1-2.59.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000040000000000'
+ }
+} {4398046511104 56}
+do_test boundary1-2.59.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=56
+ }
+} {4398046511104 0000040000000000}
+do_test boundary1-2.59.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4398046511104 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45}
+do_test boundary1-2.59.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4398046511104 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary1-2.59.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4398046511104 ORDER BY rowid
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.59.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4398046511104 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25}
+do_test boundary1-2.59.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 4398046511104 ORDER BY x
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.59.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4398046511104 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary1-2.59.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4398046511104 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary1-2.59.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4398046511104 ORDER BY rowid
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.59.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4398046511104 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56}
+do_test boundary1-2.59.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 4398046511104 ORDER BY x
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.59.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4398046511104 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary1-2.59.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4398046511104 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary1-2.59.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4398046511104 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}
+do_test boundary1-2.59.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4398046511104 ORDER BY rowid DESC
+ }
+} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.59.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 4398046511104 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.59.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4398046511104 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.59.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4398046511104 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary1-2.59.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4398046511104 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}
+do_test boundary1-2.59.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4398046511104 ORDER BY rowid DESC
+ }
+} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.59.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 4398046511104 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.60.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=1
+ }
+} {60 0000000000000001}
+do_test boundary1-2.60.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000000001'
+ }
+} {1 60}
+do_test boundary1-2.60.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=60
+ }
+} {1 0000000000000001}
+do_test boundary1-2.60.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary1-2.60.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.60.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1 ORDER BY rowid
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.60.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}
+do_test boundary1-2.60.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 1 ORDER BY x
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.60.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}
+do_test boundary1-2.60.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1 ORDER BY a DESC
+ }
+} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.60.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1 ORDER BY rowid
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.60.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}
+do_test boundary1-2.60.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 1 ORDER BY x
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.60.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}
+do_test boundary1-2.60.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1 ORDER BY a DESC
+ }
+} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary1-2.60.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}
+do_test boundary1-2.60.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1 ORDER BY rowid DESC
+ }
+} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.60.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 1 ORDER BY x
+ }
+} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.60.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.60.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary1-2.60.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}
+do_test boundary1-2.60.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1 ORDER BY rowid DESC
+ }
+} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.60.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 1 ORDER BY x
+ }
+} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.61.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=36028797018963968
+ }
+} {45 0080000000000000}
+do_test boundary1-2.61.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0080000000000000'
+ }
+} {36028797018963968 45}
+do_test boundary1-2.61.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=45
+ }
+} {36028797018963968 0080000000000000}
+do_test boundary1-2.61.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 36028797018963968 ORDER BY a
+ }
+} {3 17 28}
+do_test boundary1-2.61.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 36028797018963968 ORDER BY a DESC
+ }
+} {28 17 3}
+do_test boundary1-2.61.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 36028797018963968 ORDER BY rowid
+ }
+} {17 28 3}
+do_test boundary1-2.61.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 36028797018963968 ORDER BY rowid DESC
+ }
+} {3 28 17}
+do_test boundary1-2.61.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 36028797018963968 ORDER BY x
+ }
+} {17 28 3}
+do_test boundary1-2.61.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 36028797018963968 ORDER BY a
+ }
+} {3 17 28 45}
+do_test boundary1-2.61.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 36028797018963968 ORDER BY a DESC
+ }
+} {45 28 17 3}
+do_test boundary1-2.61.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 36028797018963968 ORDER BY rowid
+ }
+} {45 17 28 3}
+do_test boundary1-2.61.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 36028797018963968 ORDER BY rowid DESC
+ }
+} {3 28 17 45}
+do_test boundary1-2.61.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 36028797018963968 ORDER BY x
+ }
+} {45 17 28 3}
+do_test boundary1-2.61.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 36028797018963968 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.61.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 36028797018963968 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.61.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 36028797018963968 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}
+do_test boundary1-2.61.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 36028797018963968 ORDER BY rowid DESC
+ }
+} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.61.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.61.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 36028797018963968 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.61.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 36028797018963968 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary1-2.61.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 36028797018963968 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}
+do_test boundary1-2.61.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 36028797018963968 ORDER BY rowid DESC
+ }
+} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.61.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.62.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-2147483649
+ }
+} {47 ffffffff7fffffff}
+do_test boundary1-2.62.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ffffffff7fffffff'
+ }
+} {-2147483649 47}
+do_test boundary1-2.62.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=47
+ }
+} {-2147483649 ffffffff7fffffff}
+do_test boundary1-2.62.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2147483649 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.62.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2147483649 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.62.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2147483649 ORDER BY rowid
+ }
+} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.62.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2147483649 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}
+do_test boundary1-2.62.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -2147483649 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.62.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2147483649 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary1-2.62.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2147483649 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.62.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2147483649 ORDER BY rowid
+ }
+} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.62.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2147483649 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}
+do_test boundary1-2.62.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -2147483649 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.62.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2147483649 ORDER BY a
+ }
+} {2 21 44 55 58 63 64}
+do_test boundary1-2.62.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2147483649 ORDER BY a DESC
+ }
+} {64 63 58 55 44 21 2}
+do_test boundary1-2.62.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2147483649 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary1-2.62.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2147483649 ORDER BY rowid DESC
+ }
+} {63 58 44 21 64 2 55}
+do_test boundary1-2.62.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -2147483649 ORDER BY x
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary1-2.62.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2147483649 ORDER BY a
+ }
+} {2 21 44 47 55 58 63 64}
+do_test boundary1-2.62.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2147483649 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 2}
+do_test boundary1-2.62.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2147483649 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary1-2.62.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2147483649 ORDER BY rowid DESC
+ }
+} {47 63 58 44 21 64 2 55}
+do_test boundary1-2.62.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -2147483649 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary1-2.63.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=-36028797018963969
+ }
+} {2 ff7fffffffffffff}
+do_test boundary1-2.63.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='ff7fffffffffffff'
+ }
+} {-36028797018963969 2}
+do_test boundary1-2.63.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=2
+ }
+} {-36028797018963969 ff7fffffffffffff}
+do_test boundary1-2.63.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -36028797018963969 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.63.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -36028797018963969 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary1-2.63.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -36028797018963969 ORDER BY rowid
+ }
+} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.63.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -36028797018963969 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}
+do_test boundary1-2.63.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -36028797018963969 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.63.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -36028797018963969 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.63.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -36028797018963969 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary1-2.63.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -36028797018963969 ORDER BY rowid
+ }
+} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.63.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -36028797018963969 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}
+do_test boundary1-2.63.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -36028797018963969 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.63.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -36028797018963969 ORDER BY a
+ }
+} {55}
+do_test boundary1-2.63.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -36028797018963969 ORDER BY a DESC
+ }
+} {55}
+do_test boundary1-2.63.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -36028797018963969 ORDER BY rowid
+ }
+} {55}
+do_test boundary1-2.63.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -36028797018963969 ORDER BY rowid DESC
+ }
+} {55}
+do_test boundary1-2.63.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -36028797018963969 ORDER BY x
+ }
+} {55}
+do_test boundary1-2.63.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -36028797018963969 ORDER BY a
+ }
+} {2 55}
+do_test boundary1-2.63.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -36028797018963969 ORDER BY a DESC
+ }
+} {55 2}
+do_test boundary1-2.63.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -36028797018963969 ORDER BY rowid
+ }
+} {55 2}
+do_test boundary1-2.63.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -36028797018963969 ORDER BY rowid DESC
+ }
+} {2 55}
+do_test boundary1-2.63.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -36028797018963969 ORDER BY x
+ }
+} {55 2}
+do_test boundary1-2.64.1 {
+ db eval {
+ SELECT * FROM t1 WHERE rowid=3
+ }
+} {5 0000000000000003}
+do_test boundary1-2.64.2 {
+ db eval {
+ SELECT rowid, a FROM t1 WHERE x='0000000000000003'
+ }
+} {3 5}
+do_test boundary1-2.64.3 {
+ db eval {
+ SELECT rowid, x FROM t1 WHERE a=5
+ }
+} {3 0000000000000003}
+do_test boundary1-2.64.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 3 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary1-2.64.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 3 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary1-2.64.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 3 ORDER BY rowid
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.64.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 3 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}
+do_test boundary1-2.64.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 3 ORDER BY x
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.64.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 3 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary1-2.64.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 3 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary1-2.64.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 3 ORDER BY rowid
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.64.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 3 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}
+do_test boundary1-2.64.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 3 ORDER BY x
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.64.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 3 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.64.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 3 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}
+do_test boundary1-2.64.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 3 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}
+do_test boundary1-2.64.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 3 ORDER BY rowid DESC
+ }
+} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.64.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 3 ORDER BY x
+ }
+} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.64.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 3 ORDER BY a
+ }
+} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary1-2.64.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 3 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}
+do_test boundary1-2.64.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 3 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}
+do_test boundary1-2.64.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 3 ORDER BY rowid DESC
+ }
+} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.64.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 3 ORDER BY x
+ }
+} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.65.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary1-2.65.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary1-2.65.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 9.22337303685477580800e+18 ORDER BY rowid
+ }
+} {}
+do_test boundary1-2.65.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 9.22337303685477580800e+18 ORDER BY rowid DESC
+ }
+} {}
+do_test boundary1-2.65.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > 9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+do_test boundary1-2.65.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary1-2.65.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary1-2.65.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 9.22337303685477580800e+18 ORDER BY rowid
+ }
+} {}
+do_test boundary1-2.65.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 9.22337303685477580800e+18 ORDER BY rowid DESC
+ }
+} {}
+do_test boundary1-2.65.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= 9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+do_test boundary1-2.65.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.65.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary1-2.65.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 9.22337303685477580800e+18 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.65.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 9.22337303685477580800e+18 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.65.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < 9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.65.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.65.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary1-2.65.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 9.22337303685477580800e+18 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.65.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 9.22337303685477580800e+18 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.65.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= 9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.66.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.66.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary1-2.66.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -9.22337303685477580800e+18 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.66.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -9.22337303685477580800e+18 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.66.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid > -9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.66.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary1-2.66.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary1-2.66.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -9.22337303685477580800e+18 ORDER BY rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary1-2.66.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -9.22337303685477580800e+18 ORDER BY rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary1-2.66.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid >= -9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary1-2.66.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary1-2.66.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary1-2.66.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -9.22337303685477580800e+18 ORDER BY rowid
+ }
+} {}
+do_test boundary1-2.66.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -9.22337303685477580800e+18 ORDER BY rowid DESC
+ }
+} {}
+do_test boundary1-2.66.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid < -9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+do_test boundary1-2.66.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary1-2.66.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary1-2.66.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -9.22337303685477580800e+18 ORDER BY rowid
+ }
+} {}
+do_test boundary1-2.66.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -9.22337303685477580800e+18 ORDER BY rowid DESC
+ }
+} {}
+do_test boundary1-2.66.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE rowid <= -9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+finish_test
diff --git a/test/boundary2.tcl b/test/boundary2.tcl
new file mode 100644
index 0000000..b141166
--- /dev/null
+++ b/test/boundary2.tcl
@@ -0,0 +1,445 @@
+puts {# 2008 December 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is automatically generated from a separate TCL script.
+# This file seeks to exercise integer boundary values.
+#
+# $Id: boundary2.tcl,v 1.3 2009/01/02 15:45:48 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Many of the boundary tests depend on a working 64-bit implementation.
+if {![working_64bit_int]} { finish_test; return }
+}
+
+expr srand(0)
+
+# Generate interesting boundary numbers
+#
+foreach x {
+ 0
+ 1
+ 0x7f
+ 0x7fff
+ 0x7fffff
+ 0x7fffffff
+ 0x7fffffffff
+ 0x7fffffffffff
+ 0x7fffffffffffff
+ 0x7fffffffffffffff
+} {
+ set x [expr {wide($x)}]
+ set boundarynum($x) 1
+ set boundarynum([expr {$x+1}]) 1
+ set boundarynum([expr {-($x+1)}]) 1
+ set boundarynum([expr {-($x+2)}]) 1
+ set boundarynum([expr {$x+$x+1}]) 1
+ set boundarynum([expr {$x+$x+2}]) 1
+}
+set x [expr {wide(127)}]
+for {set i 1} {$i<=9} {incr i} {
+ set boundarynum($x) 1
+ set boundarynum([expr {$x+1}]) 1
+ set x [expr {wide($x*128 + 127)}]
+}
+
+# Scramble the $inlist into a random order.
+#
+proc scramble {inlist} {
+ set y {}
+ foreach x $inlist {
+ lappend y [list [expr {rand()}] $x]
+ }
+ set y [lsort $y]
+ set outlist {}
+ foreach x $y {
+ lappend outlist [lindex $x 1]
+ }
+ return $outlist
+}
+
+# A simple selection sort. Not trying to be efficient.
+#
+proc sort {inlist} {
+ set outlist {}
+ set mn [lindex $inlist 0]
+ foreach x $inlist {
+ if {$x<$mn} {set mn $x}
+ }
+ set outlist $mn
+ set mx $mn
+ while {1} {
+ set valid 0
+ foreach x $inlist {
+ if {$x>$mx && (!$valid || $mn>$x)} {
+ set mn $x
+ set valid 1
+ }
+ }
+ if {!$valid} break
+ lappend outlist $mn
+ set mx $mn
+ }
+ return $outlist
+}
+
+# Reverse the order of a list
+#
+proc reverse {inlist} {
+ set i [llength $inlist]
+ set outlist {}
+ for {incr i -1} {$i>=0} {incr i -1} {
+ lappend outlist [lindex $inlist $i]
+ }
+ return $outlist
+}
+
+set nums1 [scramble [array names boundarynum]]
+set nums2 [scramble [array names boundarynum]]
+
+set tname boundary2
+puts "do_test $tname-1.1 \173"
+puts " db eval \173"
+puts " CREATE TABLE t1(r INTEGER, a INTEGER, x TEXT);"
+set a 0
+foreach r $nums1 {
+ incr a
+ set t1ra($r) $a
+ set t1ar($a) $r
+ set x [format %08x%08x [expr {wide($r)>>32}] $r]
+ set t1rx($r) $x
+ set t1xr($x) $r
+ puts " INSERT INTO t1 VALUES($r,$a,'$x');"
+}
+puts " CREATE INDEX t1i1 ON t1(r);"
+puts " CREATE INDEX t1i2 ON t1(a);"
+puts " CREATE INDEX t1i3 ON t1(x);"
+puts " \175"
+puts "\175 {}"
+
+puts "do_test $tname-1.2 \173"
+puts " db eval \173"
+puts " SELECT count(*) FROM t1"
+puts " \175"
+puts "\175 {64}"
+
+set nums3 $nums2
+lappend nums3 9.22337303685477580800e+18
+lappend nums3 -9.22337303685477580800e+18
+
+set i 0
+foreach r $nums3 {
+ incr i
+
+ if {abs($r)<9.22337203685477580800e+18} {
+ set x $t1rx($r)
+ set a $t1ra($r)
+ set r5 $r.5
+ set r0 $r.0
+ puts "do_test $tname-2.$i.1 \173"
+ puts " db eval \173"
+ puts " SELECT * FROM t1 WHERE r=$r"
+ puts " \175"
+ puts "\175 {$r $a $x}"
+ puts "do_test $tname-2.$i.2 \173"
+ puts " db eval \173"
+ puts " SELECT r, a FROM t1 WHERE x='$x'"
+ puts " \175"
+ puts "\175 {$r $a}"
+ puts "do_test $tname-2.$i.3 \173"
+ puts " db eval \173"
+ puts " SELECT r, x FROM t1 WHERE a=$a"
+ puts " \175"
+ puts "\175 {$r $x}"
+ }
+
+ foreach op {> >= < <=} subno {gt ge lt le} {
+
+ ################################################################ 2.x.y.1
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r" {
+ lappend rset $rx
+ lappend aset $t1ra($rx)
+ }
+ }
+ puts "do_test $tname-2.$i.$subno.1 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r ORDER BY a"
+ puts " \175"
+ puts "\175 {[sort $aset]}"
+
+ ################################################################ 2.x.y.2
+ puts "do_test $tname-2.$i.$subno.2 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r ORDER BY a DESC"
+ puts " \175"
+ puts "\175 {[reverse [sort $aset]]}"
+
+ ################################################################ 2.x.y.3
+ set aset {}
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.3 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r ORDER BY r"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.4
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.4 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r ORDER BY r DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.5
+ set aset {}
+ set xset {}
+ foreach rx $rset {
+ lappend xset $t1rx($rx)
+ }
+ foreach x [sort $xset] {
+ set rx $t1xr($x)
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.5 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r ORDER BY x"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.10
+ if {abs($r)>9223372036854775808 || [string length $r5]>15} continue
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r0" {
+ lappend rset $rx
+ }
+ }
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.10 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r0 ORDER BY r"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.11
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.11 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r0 ORDER BY r DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+
+
+ ################################################################ 2.x.y.12
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r5" {
+ lappend rset $rx
+ }
+ }
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.12 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r5 ORDER BY r"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.13
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.13 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r5 ORDER BY r DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+ }
+}
+
+puts "do_test $tname-3.1 \173"
+puts " db eval \173"
+puts " DROP INDEX t1i1;"
+puts " DROP INDEX t1i2;"
+puts " DROP INDEX t1i3;"
+puts " \175"
+puts "\175 {}"
+
+set i 0
+foreach r $nums3 {
+ incr i
+
+ if {abs($r)<9.22337203685477580800e+18} {
+ set x $t1rx($r)
+ set a $t1ra($r)
+ set r5 $r.5
+ set r0 $r.0
+ puts "do_test $tname-4.$i.1 \173"
+ puts " db eval \173"
+ puts " SELECT * FROM t1 WHERE r=$r"
+ puts " \175"
+ puts "\175 {$r $a $x}"
+ puts "do_test $tname-4.$i.2 \173"
+ puts " db eval \173"
+ puts " SELECT r, a FROM t1 WHERE x='$x'"
+ puts " \175"
+ puts "\175 {$r $a}"
+ puts "do_test $tname-4.$i.3 \173"
+ puts " db eval \173"
+ puts " SELECT r, x FROM t1 WHERE a=$a"
+ puts " \175"
+ puts "\175 {$r $x}"
+ }
+
+ foreach op {> >= < <=} subno {gt ge lt le} {
+
+ ################################################################ 2.x.y.1
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r" {
+ lappend rset $rx
+ lappend aset $t1ra($rx)
+ }
+ }
+ puts "do_test $tname-4.$i.$subno.1 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r ORDER BY a"
+ puts " \175"
+ puts "\175 {[sort $aset]}"
+
+ ################################################################ 2.x.y.2
+ puts "do_test $tname-4.$i.$subno.2 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r ORDER BY a DESC"
+ puts " \175"
+ puts "\175 {[reverse [sort $aset]]}"
+
+ ################################################################ 2.x.y.3
+ set aset {}
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-4.$i.$subno.3 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r ORDER BY r"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.4
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-4.$i.$subno.4 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r ORDER BY r DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.5
+ set aset {}
+ set xset {}
+ foreach rx $rset {
+ lappend xset $t1rx($rx)
+ }
+ foreach x [sort $xset] {
+ set rx $t1xr($x)
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-4.$i.$subno.5 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r ORDER BY x"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.10
+ if {abs($r)>9223372036854775808 || [string length $r5]>15} continue
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r0" {
+ lappend rset $rx
+ }
+ }
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-4.$i.$subno.10 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r0 ORDER BY r"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.11
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-4.$i.$subno.11 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r0 ORDER BY r DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+
+
+ ################################################################ 2.x.y.12
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r5" {
+ lappend rset $rx
+ }
+ }
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-4.$i.$subno.12 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r5 ORDER BY r"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.13
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-4.$i.$subno.13 \173"
+ puts " db eval \173"
+ puts " SELECT a FROM t1 WHERE r $op $r5 ORDER BY r DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+ }
+}
+
+
+puts {finish_test}
diff --git a/test/boundary2.test b/test/boundary2.test
new file mode 100644
index 0000000..15a824d
--- /dev/null
+++ b/test/boundary2.test
@@ -0,0 +1,15198 @@
+# 2008 December 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is automatically generated from a separate TCL script.
+# This file seeks to exercise integer boundary values.
+#
+# $Id: boundary2.test,v 1.2 2009/01/02 15:45:48 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Many of the boundary tests depend on a working 64-bit implementation.
+if {![working_64bit_int]} { finish_test; return }
+
+do_test boundary2-1.1 {
+ db eval {
+ CREATE TABLE t1(r INTEGER, a INTEGER, x TEXT);
+ INSERT INTO t1 VALUES(-8388609,1,'ffffffffff7fffff');
+ INSERT INTO t1 VALUES(-36028797018963969,2,'ff7fffffffffffff');
+ INSERT INTO t1 VALUES(9223372036854775807,3,'7fffffffffffffff');
+ INSERT INTO t1 VALUES(127,4,'000000000000007f');
+ INSERT INTO t1 VALUES(3,5,'0000000000000003');
+ INSERT INTO t1 VALUES(16777216,6,'0000000001000000');
+ INSERT INTO t1 VALUES(4398046511103,7,'000003ffffffffff');
+ INSERT INTO t1 VALUES(16383,8,'0000000000003fff');
+ INSERT INTO t1 VALUES(16777215,9,'0000000000ffffff');
+ INSERT INTO t1 VALUES(281474976710655,10,'0000ffffffffffff');
+ INSERT INTO t1 VALUES(-2147483648,11,'ffffffff80000000');
+ INSERT INTO t1 VALUES(268435455,12,'000000000fffffff');
+ INSERT INTO t1 VALUES(562949953421311,13,'0001ffffffffffff');
+ INSERT INTO t1 VALUES(4294967295,14,'00000000ffffffff');
+ INSERT INTO t1 VALUES(2097151,15,'00000000001fffff');
+ INSERT INTO t1 VALUES(16384,16,'0000000000004000');
+ INSERT INTO t1 VALUES(72057594037927935,17,'00ffffffffffffff');
+ INSERT INTO t1 VALUES(8388607,18,'00000000007fffff');
+ INSERT INTO t1 VALUES(1099511627776,19,'0000010000000000');
+ INSERT INTO t1 VALUES(2147483647,20,'000000007fffffff');
+ INSERT INTO t1 VALUES(-140737488355329,21,'ffff7fffffffffff');
+ INSERT INTO t1 VALUES(34359738368,22,'0000000800000000');
+ INSERT INTO t1 VALUES(32767,23,'0000000000007fff');
+ INSERT INTO t1 VALUES(8388608,24,'0000000000800000');
+ INSERT INTO t1 VALUES(140737488355327,25,'00007fffffffffff');
+ INSERT INTO t1 VALUES(281474976710656,26,'0001000000000000');
+ INSERT INTO t1 VALUES(36028797018963967,27,'007fffffffffffff');
+ INSERT INTO t1 VALUES(72057594037927936,28,'0100000000000000');
+ INSERT INTO t1 VALUES(-32769,29,'ffffffffffff7fff');
+ INSERT INTO t1 VALUES(255,30,'00000000000000ff');
+ INSERT INTO t1 VALUES(4,31,'0000000000000004');
+ INSERT INTO t1 VALUES(-32768,32,'ffffffffffff8000');
+ INSERT INTO t1 VALUES(-2,33,'fffffffffffffffe');
+ INSERT INTO t1 VALUES(140737488355328,34,'0000800000000000');
+ INSERT INTO t1 VALUES(549755813888,35,'0000008000000000');
+ INSERT INTO t1 VALUES(4294967296,36,'0000000100000000');
+ INSERT INTO t1 VALUES(-8388608,37,'ffffffffff800000');
+ INSERT INTO t1 VALUES(-1,38,'ffffffffffffffff');
+ INSERT INTO t1 VALUES(34359738367,39,'00000007ffffffff');
+ INSERT INTO t1 VALUES(268435456,40,'0000000010000000');
+ INSERT INTO t1 VALUES(2,41,'0000000000000002');
+ INSERT INTO t1 VALUES(2097152,42,'0000000000200000');
+ INSERT INTO t1 VALUES(562949953421312,43,'0002000000000000');
+ INSERT INTO t1 VALUES(-140737488355328,44,'ffff800000000000');
+ INSERT INTO t1 VALUES(36028797018963968,45,'0080000000000000');
+ INSERT INTO t1 VALUES(549755813887,46,'0000007fffffffff');
+ INSERT INTO t1 VALUES(-2147483649,47,'ffffffff7fffffff');
+ INSERT INTO t1 VALUES(65535,48,'000000000000ffff');
+ INSERT INTO t1 VALUES(128,49,'0000000000000080');
+ INSERT INTO t1 VALUES(32768,50,'0000000000008000');
+ INSERT INTO t1 VALUES(2147483648,51,'0000000080000000');
+ INSERT INTO t1 VALUES(-3,52,'fffffffffffffffd');
+ INSERT INTO t1 VALUES(-128,53,'ffffffffffffff80');
+ INSERT INTO t1 VALUES(-129,54,'ffffffffffffff7f');
+ INSERT INTO t1 VALUES(-9223372036854775808,55,'8000000000000000');
+ INSERT INTO t1 VALUES(4398046511104,56,'0000040000000000');
+ INSERT INTO t1 VALUES(1099511627775,57,'000000ffffffffff');
+ INSERT INTO t1 VALUES(-549755813889,58,'ffffff7fffffffff');
+ INSERT INTO t1 VALUES(0,59,'0000000000000000');
+ INSERT INTO t1 VALUES(1,60,'0000000000000001');
+ INSERT INTO t1 VALUES(256,61,'0000000000000100');
+ INSERT INTO t1 VALUES(65536,62,'0000000000010000');
+ INSERT INTO t1 VALUES(-549755813888,63,'ffffff8000000000');
+ INSERT INTO t1 VALUES(-36028797018963968,64,'ff80000000000000');
+ CREATE INDEX t1i1 ON t1(r);
+ CREATE INDEX t1i2 ON t1(a);
+ CREATE INDEX t1i3 ON t1(x);
+ }
+} {}
+do_test boundary2-1.2 {
+ db eval {
+ SELECT count(*) FROM t1
+ }
+} {64}
+do_test boundary2-2.1.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=72057594037927935
+ }
+} {72057594037927935 17 00ffffffffffffff}
+do_test boundary2-2.1.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00ffffffffffffff'
+ }
+} {72057594037927935 17}
+do_test boundary2-2.1.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=17
+ }
+} {72057594037927935 00ffffffffffffff}
+do_test boundary2-2.1.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY a
+ }
+} {3 28}
+do_test boundary2-2.1.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY a DESC
+ }
+} {28 3}
+do_test boundary2-2.1.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY r
+ }
+} {28 3}
+do_test boundary2-2.1.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY r DESC
+ }
+} {3 28}
+do_test boundary2-2.1.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY x
+ }
+} {28 3}
+do_test boundary2-2.1.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY a
+ }
+} {3 17 28}
+do_test boundary2-2.1.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY a DESC
+ }
+} {28 17 3}
+do_test boundary2-2.1.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY r
+ }
+} {17 28 3}
+do_test boundary2-2.1.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY r DESC
+ }
+} {3 28 17}
+do_test boundary2-2.1.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY x
+ }
+} {17 28 3}
+do_test boundary2-2.1.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.1.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.1.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}
+do_test boundary2-2.1.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY r DESC
+ }
+} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.1.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.1.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.1.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.1.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}
+do_test boundary2-2.1.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY r DESC
+ }
+} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.1.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.2.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=16384
+ }
+} {16384 16 0000000000004000}
+do_test boundary2-2.2.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000004000'
+ }
+} {16384 16}
+do_test boundary2-2.2.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=16
+ }
+} {16384 0000000000004000}
+do_test boundary2-2.2.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16384 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-2.2.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16384 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.2.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16384 ORDER BY r
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.2.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16384 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}
+do_test boundary2-2.2.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16384 ORDER BY x
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.2.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16384 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-2.2.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16384 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.2.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16384 ORDER BY r
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.2.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16384 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}
+do_test boundary2-2.2.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16384 ORDER BY x
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.2.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16384 ORDER BY a
+ }
+} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.2.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16384 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}
+do_test boundary2-2.2.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16384 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}
+do_test boundary2-2.2.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16384 ORDER BY r DESC
+ }
+} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.2.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16384 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.2.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16384 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.2.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16384 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}
+do_test boundary2-2.2.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16384 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}
+do_test boundary2-2.2.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16384 ORDER BY r DESC
+ }
+} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.2.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16384 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.3.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=4294967296
+ }
+} {4294967296 36 0000000100000000}
+do_test boundary2-2.3.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000100000000'
+ }
+} {4294967296 36}
+do_test boundary2-2.3.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=36
+ }
+} {4294967296 0000000100000000}
+do_test boundary2-2.3.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967296 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}
+do_test boundary2-2.3.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967296 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-2.3.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967296 ORDER BY r
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.3.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967296 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}
+do_test boundary2-2.3.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967296 ORDER BY x
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.3.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary2-2.3.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-2.3.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY r
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.3.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}
+do_test boundary2-2.3.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY x
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.3.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967296 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.3.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967296 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.3.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967296 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}
+do_test boundary2-2.3.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967296 ORDER BY r DESC
+ }
+} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.3.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967296 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.3.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.3.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.3.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}
+do_test boundary2-2.3.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY r DESC
+ }
+} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.3.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.4.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=16777216
+ }
+} {16777216 6 0000000001000000}
+do_test boundary2-2.4.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000001000000'
+ }
+} {16777216 6}
+do_test boundary2-2.4.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=6
+ }
+} {16777216 0000000001000000}
+do_test boundary2-2.4.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777216 ORDER BY a
+ }
+} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.4.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777216 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}
+do_test boundary2-2.4.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777216 ORDER BY r
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.4.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777216 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}
+do_test boundary2-2.4.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777216 ORDER BY x
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.4.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777216 ORDER BY a
+ }
+} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.4.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777216 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}
+do_test boundary2-2.4.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777216 ORDER BY r
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.4.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777216 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}
+do_test boundary2-2.4.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777216 ORDER BY x
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.4.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777216 ORDER BY a
+ }
+} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.4.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777216 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}
+do_test boundary2-2.4.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777216 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}
+do_test boundary2-2.4.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777216 ORDER BY r DESC
+ }
+} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.4.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777216 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.4.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777216 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.4.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777216 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}
+do_test boundary2-2.4.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777216 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}
+do_test boundary2-2.4.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777216 ORDER BY r DESC
+ }
+} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.4.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777216 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.5.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-32769
+ }
+} {-32769 29 ffffffffffff7fff}
+do_test boundary2-2.5.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffffff7fff'
+ }
+} {-32769 29}
+do_test boundary2-2.5.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=29
+ }
+} {-32769 ffffffffffff7fff}
+do_test boundary2-2.5.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32769 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.5.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32769 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.5.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32769 ORDER BY r
+ }
+} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.5.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32769 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}
+do_test boundary2-2.5.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32769 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}
+do_test boundary2-2.5.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32769 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.5.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32769 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.5.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32769 ORDER BY r
+ }
+} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.5.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32769 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}
+do_test boundary2-2.5.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32769 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}
+do_test boundary2-2.5.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32769 ORDER BY a
+ }
+} {1 2 11 21 37 44 47 55 58 63 64}
+do_test boundary2-2.5.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32769 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 21 11 2 1}
+do_test boundary2-2.5.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32769 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary2-2.5.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32769 ORDER BY r DESC
+ }
+} {37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.5.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32769 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary2-2.5.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32769 ORDER BY a
+ }
+} {1 2 11 21 29 37 44 47 55 58 63 64}
+do_test boundary2-2.5.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32769 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 29 21 11 2 1}
+do_test boundary2-2.5.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32769 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary2-2.5.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32769 ORDER BY r DESC
+ }
+} {29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.5.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32769 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary2-2.6.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-140737488355329
+ }
+} {-140737488355329 21 ffff7fffffffffff}
+do_test boundary2-2.6.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffff7fffffffffff'
+ }
+} {-140737488355329 21}
+do_test boundary2-2.6.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=21
+ }
+} {-140737488355329 ffff7fffffffffff}
+do_test boundary2-2.6.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-2.6.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.6.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY r
+ }
+} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.6.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}
+do_test boundary2-2.6.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.6.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-2.6.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.6.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY r
+ }
+} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.6.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}
+do_test boundary2-2.6.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.6.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY a
+ }
+} {2 55 64}
+do_test boundary2-2.6.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY a DESC
+ }
+} {64 55 2}
+do_test boundary2-2.6.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY r
+ }
+} {55 2 64}
+do_test boundary2-2.6.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY r DESC
+ }
+} {64 2 55}
+do_test boundary2-2.6.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY x
+ }
+} {55 2 64}
+do_test boundary2-2.6.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY a
+ }
+} {2 21 55 64}
+do_test boundary2-2.6.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY a DESC
+ }
+} {64 55 21 2}
+do_test boundary2-2.6.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY r
+ }
+} {55 2 64 21}
+do_test boundary2-2.6.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY r DESC
+ }
+} {21 64 2 55}
+do_test boundary2-2.6.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY x
+ }
+} {55 2 64 21}
+do_test boundary2-2.7.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=2
+ }
+} {2 41 0000000000000002}
+do_test boundary2-2.7.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000002'
+ }
+} {2 41}
+do_test boundary2-2.7.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=41
+ }
+} {2 0000000000000002}
+do_test boundary2-2.7.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-2.7.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.7.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2 ORDER BY r
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.7.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}
+do_test boundary2-2.7.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2 ORDER BY x
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.7.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-2.7.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.7.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2 ORDER BY r
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.7.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}
+do_test boundary2-2.7.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2 ORDER BY x
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.7.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.7.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-2.7.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}
+do_test boundary2-2.7.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2 ORDER BY r DESC
+ }
+} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.7.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2 ORDER BY x
+ }
+} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.7.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.7.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}
+do_test boundary2-2.7.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}
+do_test boundary2-2.7.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2 ORDER BY r DESC
+ }
+} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.7.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2 ORDER BY x
+ }
+} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.8.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=4
+ }
+} {4 31 0000000000000004}
+do_test boundary2-2.8.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000004'
+ }
+} {4 31}
+do_test boundary2-2.8.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=31
+ }
+} {4 0000000000000004}
+do_test boundary2-2.8.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-2.8.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary2-2.8.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4 ORDER BY r
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.8.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}
+do_test boundary2-2.8.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4 ORDER BY x
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.8.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-2.8.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary2-2.8.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4 ORDER BY r
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.8.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}
+do_test boundary2-2.8.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4 ORDER BY x
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.8.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4 ORDER BY a
+ }
+} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.8.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}
+do_test boundary2-2.8.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}
+do_test boundary2-2.8.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4 ORDER BY r DESC
+ }
+} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.8.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4 ORDER BY x
+ }
+} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.8.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4 ORDER BY a
+ }
+} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.8.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}
+do_test boundary2-2.8.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}
+do_test boundary2-2.8.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4 ORDER BY r DESC
+ }
+} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.8.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4 ORDER BY x
+ }
+} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.9.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=562949953421311
+ }
+} {562949953421311 13 0001ffffffffffff}
+do_test boundary2-2.9.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0001ffffffffffff'
+ }
+} {562949953421311 13}
+do_test boundary2-2.9.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=13
+ }
+} {562949953421311 0001ffffffffffff}
+do_test boundary2-2.9.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY a
+ }
+} {3 17 27 28 43 45}
+do_test boundary2-2.9.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY a DESC
+ }
+} {45 43 28 27 17 3}
+do_test boundary2-2.9.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY r
+ }
+} {43 27 45 17 28 3}
+do_test boundary2-2.9.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43}
+do_test boundary2-2.9.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY x
+ }
+} {43 27 45 17 28 3}
+do_test boundary2-2.9.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY a
+ }
+} {3 13 17 27 28 43 45}
+do_test boundary2-2.9.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY a DESC
+ }
+} {45 43 28 27 17 13 3}
+do_test boundary2-2.9.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY r
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary2-2.9.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13}
+do_test boundary2-2.9.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY x
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary2-2.9.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.9.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.9.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}
+do_test boundary2-2.9.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY r DESC
+ }
+} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.9.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.9.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.9.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.9.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}
+do_test boundary2-2.9.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY r DESC
+ }
+} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.9.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.10.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=256
+ }
+} {256 61 0000000000000100}
+do_test boundary2-2.10.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000100'
+ }
+} {256 61}
+do_test boundary2-2.10.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=61
+ }
+} {256 0000000000000100}
+do_test boundary2-2.10.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 256 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-2.10.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 256 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-2.10.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 256 ORDER BY r
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.10.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 256 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}
+do_test boundary2-2.10.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 256 ORDER BY x
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.10.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 256 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary2-2.10.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 256 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-2.10.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 256 ORDER BY r
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.10.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 256 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}
+do_test boundary2-2.10.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 256 ORDER BY x
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.10.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 256 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.10.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 256 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary2-2.10.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 256 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}
+do_test boundary2-2.10.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 256 ORDER BY r DESC
+ }
+} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.10.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 256 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.10.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 256 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.10.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 256 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary2-2.10.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 256 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}
+do_test boundary2-2.10.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 256 ORDER BY r DESC
+ }
+} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.10.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 256 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.11.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=34359738368
+ }
+} {34359738368 22 0000000800000000}
+do_test boundary2-2.11.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000800000000'
+ }
+} {34359738368 22}
+do_test boundary2-2.11.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=22
+ }
+} {34359738368 0000000800000000}
+do_test boundary2-2.11.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738368 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary2-2.11.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738368 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-2.11.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738368 ORDER BY r
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.11.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738368 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}
+do_test boundary2-2.11.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738368 ORDER BY x
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.11.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary2-2.11.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-2.11.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY r
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.11.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}
+do_test boundary2-2.11.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY x
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.11.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738368 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.11.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738368 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.11.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738368 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}
+do_test boundary2-2.11.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738368 ORDER BY r DESC
+ }
+} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.11.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738368 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.11.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.11.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.11.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}
+do_test boundary2-2.11.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY r DESC
+ }
+} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.11.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.12.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=65536
+ }
+} {65536 62 0000000000010000}
+do_test boundary2-2.12.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000010000'
+ }
+} {65536 62}
+do_test boundary2-2.12.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=62
+ }
+} {65536 0000000000010000}
+do_test boundary2-2.12.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65536 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary2-2.12.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65536 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.12.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65536 ORDER BY r
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.12.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65536 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}
+do_test boundary2-2.12.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65536 ORDER BY x
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.12.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65536 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}
+do_test boundary2-2.12.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65536 ORDER BY a DESC
+ }
+} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.12.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65536 ORDER BY r
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.12.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65536 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}
+do_test boundary2-2.12.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65536 ORDER BY x
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.12.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65536 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.12.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65536 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-2.12.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65536 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}
+do_test boundary2-2.12.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65536 ORDER BY r DESC
+ }
+} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.12.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65536 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.12.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65536 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.12.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65536 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-2.12.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65536 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}
+do_test boundary2-2.12.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65536 ORDER BY r DESC
+ }
+} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.12.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65536 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.13.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=268435456
+ }
+} {268435456 40 0000000010000000}
+do_test boundary2-2.13.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000010000000'
+ }
+} {268435456 40}
+do_test boundary2-2.13.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=40
+ }
+} {268435456 0000000010000000}
+do_test boundary2-2.13.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435456 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary2-2.13.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435456 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary2-2.13.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435456 ORDER BY r
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.13.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435456 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}
+do_test boundary2-2.13.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435456 ORDER BY x
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.13.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435456 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.13.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435456 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary2-2.13.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435456 ORDER BY r
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.13.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435456 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}
+do_test boundary2-2.13.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435456 ORDER BY x
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.13.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435456 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.13.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435456 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.13.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435456 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}
+do_test boundary2-2.13.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435456 ORDER BY r DESC
+ }
+} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.13.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435456 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.13.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435456 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.13.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435456 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.13.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435456 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}
+do_test boundary2-2.13.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435456 ORDER BY r DESC
+ }
+} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.13.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435456 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.14.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-140737488355328
+ }
+} {-140737488355328 44 ffff800000000000}
+do_test boundary2-2.14.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffff800000000000'
+ }
+} {-140737488355328 44}
+do_test boundary2-2.14.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=44
+ }
+} {-140737488355328 ffff800000000000}
+do_test boundary2-2.14.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-2.14.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.14.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY r
+ }
+} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.14.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}
+do_test boundary2-2.14.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.14.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-2.14.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.14.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY r
+ }
+} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.14.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}
+do_test boundary2-2.14.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.14.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY a
+ }
+} {2 21 55 64}
+do_test boundary2-2.14.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY a DESC
+ }
+} {64 55 21 2}
+do_test boundary2-2.14.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY r
+ }
+} {55 2 64 21}
+do_test boundary2-2.14.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY r DESC
+ }
+} {21 64 2 55}
+do_test boundary2-2.14.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY x
+ }
+} {55 2 64 21}
+do_test boundary2-2.14.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY a
+ }
+} {2 21 44 55 64}
+do_test boundary2-2.14.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY a DESC
+ }
+} {64 55 44 21 2}
+do_test boundary2-2.14.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY r
+ }
+} {55 2 64 21 44}
+do_test boundary2-2.14.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY r DESC
+ }
+} {44 21 64 2 55}
+do_test boundary2-2.14.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY x
+ }
+} {55 2 64 21 44}
+do_test boundary2-2.15.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=1099511627776
+ }
+} {1099511627776 19 0000010000000000}
+do_test boundary2-2.15.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000010000000000'
+ }
+} {1099511627776 19}
+do_test boundary2-2.15.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=19
+ }
+} {1099511627776 0000010000000000}
+do_test boundary2-2.15.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY a
+ }
+} {3 7 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary2-2.15.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 7 3}
+do_test boundary2-2.15.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY r
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.15.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7}
+do_test boundary2-2.15.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY x
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.15.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}
+do_test boundary2-2.15.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-2.15.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY r
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.15.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}
+do_test boundary2-2.15.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY x
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.15.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-2.15.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.15.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}
+do_test boundary2-2.15.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY r DESC
+ }
+} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.15.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.15.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-2.15.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.15.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}
+do_test boundary2-2.15.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY r DESC
+ }
+} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.15.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.16.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY a
+ }
+} {}
+do_test boundary2-2.16.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-2.16.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY r
+ }
+} {}
+do_test boundary2-2.16.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-2.16.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY x
+ }
+} {}
+do_test boundary2-2.16.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY a
+ }
+} {3}
+do_test boundary2-2.16.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY a DESC
+ }
+} {3}
+do_test boundary2-2.16.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY r
+ }
+} {3}
+do_test boundary2-2.16.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY r DESC
+ }
+} {3}
+do_test boundary2-2.16.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY x
+ }
+} {3}
+do_test boundary2-2.16.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.16.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.16.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}
+do_test boundary2-2.16.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY r DESC
+ }
+} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.16.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.16.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.16.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-2.16.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.16.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.16.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.17.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=32768
+ }
+} {32768 50 0000000000008000}
+do_test boundary2-2.17.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000008000'
+ }
+} {32768 50}
+do_test boundary2-2.17.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=50
+ }
+} {32768 0000000000008000}
+do_test boundary2-2.17.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32768 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}
+do_test boundary2-2.17.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32768 ORDER BY a DESC
+ }
+} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.17.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32768 ORDER BY r
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.17.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32768 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}
+do_test boundary2-2.17.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32768 ORDER BY x
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.17.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32768 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-2.17.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32768 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.17.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32768 ORDER BY r
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.17.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32768 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}
+do_test boundary2-2.17.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32768 ORDER BY x
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.17.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32768 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.17.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32768 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-2.17.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32768 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}
+do_test boundary2-2.17.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32768 ORDER BY r DESC
+ }
+} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.17.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.17.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32768 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.17.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32768 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-2.17.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32768 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}
+do_test boundary2-2.17.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32768 ORDER BY r DESC
+ }
+} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.17.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.18.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-36028797018963968
+ }
+} {-36028797018963968 64 ff80000000000000}
+do_test boundary2-2.18.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ff80000000000000'
+ }
+} {-36028797018963968 64}
+do_test boundary2-2.18.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=64
+ }
+} {-36028797018963968 ff80000000000000}
+do_test boundary2-2.18.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-2.18.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.18.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY r
+ }
+} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.18.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}
+do_test boundary2-2.18.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.18.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.18.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.18.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY r
+ }
+} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.18.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}
+do_test boundary2-2.18.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.18.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY a
+ }
+} {2 55}
+do_test boundary2-2.18.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY a DESC
+ }
+} {55 2}
+do_test boundary2-2.18.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY r
+ }
+} {55 2}
+do_test boundary2-2.18.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY r DESC
+ }
+} {2 55}
+do_test boundary2-2.18.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY x
+ }
+} {55 2}
+do_test boundary2-2.18.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY a
+ }
+} {2 55 64}
+do_test boundary2-2.18.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY a DESC
+ }
+} {64 55 2}
+do_test boundary2-2.18.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY r
+ }
+} {55 2 64}
+do_test boundary2-2.18.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY r DESC
+ }
+} {64 2 55}
+do_test boundary2-2.18.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY x
+ }
+} {55 2 64}
+do_test boundary2-2.19.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=65535
+ }
+} {65535 48 000000000000ffff}
+do_test boundary2-2.19.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000000000000ffff'
+ }
+} {65535 48}
+do_test boundary2-2.19.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=48
+ }
+} {65535 000000000000ffff}
+do_test boundary2-2.19.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65535 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}
+do_test boundary2-2.19.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65535 ORDER BY a DESC
+ }
+} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.19.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65535 ORDER BY r
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.19.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65535 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}
+do_test boundary2-2.19.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65535 ORDER BY x
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.19.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65535 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}
+do_test boundary2-2.19.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65535 ORDER BY a DESC
+ }
+} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.19.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65535 ORDER BY r
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.19.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65535 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}
+do_test boundary2-2.19.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65535 ORDER BY x
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.19.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65535 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.19.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65535 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-2.19.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65535 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}
+do_test boundary2-2.19.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65535 ORDER BY r DESC
+ }
+} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.19.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65535 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.19.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65535 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.19.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65535 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-2.19.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65535 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}
+do_test boundary2-2.19.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65535 ORDER BY r DESC
+ }
+} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.19.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65535 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.20.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=4294967295
+ }
+} {4294967295 14 00000000ffffffff}
+do_test boundary2-2.20.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00000000ffffffff'
+ }
+} {4294967295 14}
+do_test boundary2-2.20.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=14
+ }
+} {4294967295 00000000ffffffff}
+do_test boundary2-2.20.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967295 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary2-2.20.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967295 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-2.20.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967295 ORDER BY r
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.20.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967295 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}
+do_test boundary2-2.20.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967295 ORDER BY x
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.20.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary2-2.20.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary2-2.20.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY r
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.20.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}
+do_test boundary2-2.20.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY x
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.20.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967295 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.20.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967295 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.20.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967295 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}
+do_test boundary2-2.20.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967295 ORDER BY r DESC
+ }
+} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.20.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967295 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.20.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.20.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.20.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}
+do_test boundary2-2.20.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY r DESC
+ }
+} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.20.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.21.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=1099511627775
+ }
+} {1099511627775 57 000000ffffffffff}
+do_test boundary2-2.21.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000000ffffffffff'
+ }
+} {1099511627775 57}
+do_test boundary2-2.21.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=57
+ }
+} {1099511627775 000000ffffffffff}
+do_test boundary2-2.21.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}
+do_test boundary2-2.21.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-2.21.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY r
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.21.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}
+do_test boundary2-2.21.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY x
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.21.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}
+do_test boundary2-2.21.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY a DESC
+ }
+} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-2.21.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY r
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.21.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}
+do_test boundary2-2.21.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY x
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.21.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.21.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.21.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}
+do_test boundary2-2.21.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY r DESC
+ }
+} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.21.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.21.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-2.21.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.21.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}
+do_test boundary2-2.21.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY r DESC
+ }
+} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.21.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.22.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-8388608
+ }
+} {-8388608 37 ffffffffff800000}
+do_test boundary2-2.22.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffff800000'
+ }
+} {-8388608 37}
+do_test boundary2-2.22.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=37
+ }
+} {-8388608 ffffffffff800000}
+do_test boundary2-2.22.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388608 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.22.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388608 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.22.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388608 ORDER BY r
+ }
+} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.22.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388608 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}
+do_test boundary2-2.22.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}
+do_test boundary2-2.22.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388608 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.22.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388608 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.22.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388608 ORDER BY r
+ }
+} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.22.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388608 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}
+do_test boundary2-2.22.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}
+do_test boundary2-2.22.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388608 ORDER BY a
+ }
+} {1 2 11 21 44 47 55 58 63 64}
+do_test boundary2-2.22.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388608 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2 1}
+do_test boundary2-2.22.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388608 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary2-2.22.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388608 ORDER BY r DESC
+ }
+} {1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.22.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388608 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary2-2.22.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388608 ORDER BY a
+ }
+} {1 2 11 21 37 44 47 55 58 63 64}
+do_test boundary2-2.22.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388608 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 21 11 2 1}
+do_test boundary2-2.22.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388608 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary2-2.22.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388608 ORDER BY r DESC
+ }
+} {37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.22.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388608 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary2-2.23.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=549755813888
+ }
+} {549755813888 35 0000008000000000}
+do_test boundary2-2.23.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000008000000000'
+ }
+} {549755813888 35}
+do_test boundary2-2.23.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=35
+ }
+} {549755813888 0000008000000000}
+do_test boundary2-2.23.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813888 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}
+do_test boundary2-2.23.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813888 ORDER BY a DESC
+ }
+} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-2.23.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813888 ORDER BY r
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.23.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813888 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}
+do_test boundary2-2.23.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813888 ORDER BY x
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.23.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}
+do_test boundary2-2.23.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY a DESC
+ }
+} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-2.23.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY r
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.23.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}
+do_test boundary2-2.23.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY x
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.23.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813888 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.23.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813888 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.23.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813888 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}
+do_test boundary2-2.23.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813888 ORDER BY r DESC
+ }
+} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.23.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.23.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.23.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.23.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}
+do_test boundary2-2.23.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY r DESC
+ }
+} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.23.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.24.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=8388607
+ }
+} {8388607 18 00000000007fffff}
+do_test boundary2-2.24.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00000000007fffff'
+ }
+} {8388607 18}
+do_test boundary2-2.24.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=18
+ }
+} {8388607 00000000007fffff}
+do_test boundary2-2.24.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388607 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.24.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388607 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary2-2.24.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388607 ORDER BY r
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.24.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388607 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}
+do_test boundary2-2.24.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388607 ORDER BY x
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.24.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388607 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.24.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388607 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary2-2.24.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388607 ORDER BY r
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.24.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388607 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}
+do_test boundary2-2.24.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388607 ORDER BY x
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.24.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388607 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.24.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388607 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary2-2.24.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388607 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}
+do_test boundary2-2.24.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388607 ORDER BY r DESC
+ }
+} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.24.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388607 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.24.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388607 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.24.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388607 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary2-2.24.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388607 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}
+do_test boundary2-2.24.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388607 ORDER BY r DESC
+ }
+} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.24.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388607 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.25.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-3
+ }
+} {-3 52 fffffffffffffffd}
+do_test boundary2-2.25.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='fffffffffffffffd'
+ }
+} {-3 52}
+do_test boundary2-2.25.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=52
+ }
+} {-3 fffffffffffffffd}
+do_test boundary2-2.25.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -3 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-2.25.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -3 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.25.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -3 ORDER BY r
+ }
+} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.25.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -3 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}
+do_test boundary2-2.25.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -3 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}
+do_test boundary2-2.25.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -3 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}
+do_test boundary2-2.25.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -3 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.25.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -3 ORDER BY r
+ }
+} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.25.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -3 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}
+do_test boundary2-2.25.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -3 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}
+do_test boundary2-2.25.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -3 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}
+do_test boundary2-2.25.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -3 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}
+do_test boundary2-2.25.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -3 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary2-2.25.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -3 ORDER BY r DESC
+ }
+} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.25.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -3 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary2-2.25.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -3 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}
+do_test boundary2-2.25.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -3 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}
+do_test boundary2-2.25.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -3 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary2-2.25.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -3 ORDER BY r DESC
+ }
+} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.25.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -3 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary2-2.26.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=0
+ }
+} {0 59 0000000000000000}
+do_test boundary2-2.26.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000000'
+ }
+} {0 59}
+do_test boundary2-2.26.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=59
+ }
+} {0 0000000000000000}
+do_test boundary2-2.26.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 0 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}
+do_test boundary2-2.26.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 0 ORDER BY a DESC
+ }
+} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.26.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 0 ORDER BY r
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.26.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 0 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}
+do_test boundary2-2.26.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 0 ORDER BY x
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.26.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 0 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-2.26.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 0 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.26.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 0 ORDER BY r
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.26.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 0 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}
+do_test boundary2-2.26.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 0 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.26.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 0 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}
+do_test boundary2-2.26.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 0 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-2.26.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 0 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.26.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 0 ORDER BY r DESC
+ }
+} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.26.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 0 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.26.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 0 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}
+do_test boundary2-2.26.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 0 ORDER BY a DESC
+ }
+} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-2.26.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 0 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}
+do_test boundary2-2.26.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 0 ORDER BY r DESC
+ }
+} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.26.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 0 ORDER BY x
+ }
+} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.27.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-1
+ }
+} {-1 38 ffffffffffffffff}
+do_test boundary2-2.27.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffffffffff'
+ }
+} {-1 38}
+do_test boundary2-2.27.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=38
+ }
+} {-1 ffffffffffffffff}
+do_test boundary2-2.27.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-2.27.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -1 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.27.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -1 ORDER BY r
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.27.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -1 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}
+do_test boundary2-2.27.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -1 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.27.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-2.27.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -1 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.27.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -1 ORDER BY r
+ }
+} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.27.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -1 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}
+do_test boundary2-2.27.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -1 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}
+do_test boundary2-2.27.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}
+do_test boundary2-2.27.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -1 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}
+do_test boundary2-2.27.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -1 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary2-2.27.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -1 ORDER BY r DESC
+ }
+} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.27.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -1 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary2-2.27.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}
+do_test boundary2-2.27.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -1 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-2.27.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -1 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.27.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -1 ORDER BY r DESC
+ }
+} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.27.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -1 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.28.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-2
+ }
+} {-2 33 fffffffffffffffe}
+do_test boundary2-2.28.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='fffffffffffffffe'
+ }
+} {-2 33}
+do_test boundary2-2.28.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=33
+ }
+} {-2 fffffffffffffffe}
+do_test boundary2-2.28.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-2.28.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.28.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2 ORDER BY r
+ }
+} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.28.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}
+do_test boundary2-2.28.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}
+do_test boundary2-2.28.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-2.28.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.28.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2 ORDER BY r
+ }
+} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.28.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}
+do_test boundary2-2.28.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}
+do_test boundary2-2.28.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}
+do_test boundary2-2.28.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}
+do_test boundary2-2.28.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary2-2.28.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2 ORDER BY r DESC
+ }
+} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.28.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary2-2.28.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}
+do_test boundary2-2.28.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}
+do_test boundary2-2.28.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary2-2.28.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2 ORDER BY r DESC
+ }
+} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.28.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary2-2.29.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=2097152
+ }
+} {2097152 42 0000000000200000}
+do_test boundary2-2.29.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000200000'
+ }
+} {2097152 42}
+do_test boundary2-2.29.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=42
+ }
+} {2097152 0000000000200000}
+do_test boundary2-2.29.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097152 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.29.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097152 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary2-2.29.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097152 ORDER BY r
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.29.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097152 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}
+do_test boundary2-2.29.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097152 ORDER BY x
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.29.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097152 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary2-2.29.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097152 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary2-2.29.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097152 ORDER BY r
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.29.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097152 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}
+do_test boundary2-2.29.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097152 ORDER BY x
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.29.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097152 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.29.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097152 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary2-2.29.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097152 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}
+do_test boundary2-2.29.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097152 ORDER BY r DESC
+ }
+} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.29.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097152 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.29.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097152 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.29.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097152 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary2-2.29.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097152 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}
+do_test boundary2-2.29.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097152 ORDER BY r DESC
+ }
+} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.29.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097152 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.30.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=128
+ }
+} {128 49 0000000000000080}
+do_test boundary2-2.30.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000080'
+ }
+} {128 49}
+do_test boundary2-2.30.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=49
+ }
+} {128 0000000000000080}
+do_test boundary2-2.30.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 128 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary2-2.30.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 128 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-2.30.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 128 ORDER BY r
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.30.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 128 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}
+do_test boundary2-2.30.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 128 ORDER BY x
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.30.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 128 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-2.30.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 128 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-2.30.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 128 ORDER BY r
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.30.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 128 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}
+do_test boundary2-2.30.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 128 ORDER BY x
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.30.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 128 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.30.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 128 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary2-2.30.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 128 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}
+do_test boundary2-2.30.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 128 ORDER BY r DESC
+ }
+} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.30.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 128 ORDER BY x
+ }
+} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.30.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 128 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.30.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 128 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary2-2.30.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 128 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}
+do_test boundary2-2.30.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 128 ORDER BY r DESC
+ }
+} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.30.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 128 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.31.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=255
+ }
+} {255 30 00000000000000ff}
+do_test boundary2-2.31.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00000000000000ff'
+ }
+} {255 30}
+do_test boundary2-2.31.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=30
+ }
+} {255 00000000000000ff}
+do_test boundary2-2.31.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 255 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary2-2.31.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 255 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-2.31.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 255 ORDER BY r
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.31.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 255 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}
+do_test boundary2-2.31.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 255 ORDER BY x
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.31.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 255 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary2-2.31.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 255 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-2.31.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 255 ORDER BY r
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.31.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 255 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}
+do_test boundary2-2.31.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 255 ORDER BY x
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.31.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 255 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.31.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 255 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary2-2.31.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 255 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}
+do_test boundary2-2.31.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 255 ORDER BY r DESC
+ }
+} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.31.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 255 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.31.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 255 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.31.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 255 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary2-2.31.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 255 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}
+do_test boundary2-2.31.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 255 ORDER BY r DESC
+ }
+} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.31.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 255 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.32.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-2147483648
+ }
+} {-2147483648 11 ffffffff80000000}
+do_test boundary2-2.32.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffff80000000'
+ }
+} {-2147483648 11}
+do_test boundary2-2.32.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=11
+ }
+} {-2147483648 ffffffff80000000}
+do_test boundary2-2.32.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483648 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.32.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483648 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.32.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483648 ORDER BY r
+ }
+} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.32.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483648 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}
+do_test boundary2-2.32.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.32.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.32.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.32.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY r
+ }
+} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.32.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}
+do_test boundary2-2.32.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.32.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483648 ORDER BY a
+ }
+} {2 21 44 47 55 58 63 64}
+do_test boundary2-2.32.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483648 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 2}
+do_test boundary2-2.32.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483648 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary2-2.32.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483648 ORDER BY r DESC
+ }
+} {47 63 58 44 21 64 2 55}
+do_test boundary2-2.32.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483648 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary2-2.32.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY a
+ }
+} {2 11 21 44 47 55 58 63 64}
+do_test boundary2-2.32.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2}
+do_test boundary2-2.32.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary2-2.32.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY r DESC
+ }
+} {11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.32.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary2-2.33.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=34359738367
+ }
+} {34359738367 39 00000007ffffffff}
+do_test boundary2-2.33.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00000007ffffffff'
+ }
+} {34359738367 39}
+do_test boundary2-2.33.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=39
+ }
+} {34359738367 00000007ffffffff}
+do_test boundary2-2.33.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738367 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary2-2.33.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738367 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-2.33.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738367 ORDER BY r
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.33.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738367 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}
+do_test boundary2-2.33.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738367 ORDER BY x
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.33.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}
+do_test boundary2-2.33.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-2.33.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY r
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.33.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}
+do_test boundary2-2.33.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY x
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.33.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738367 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.33.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738367 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.33.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738367 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}
+do_test boundary2-2.33.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738367 ORDER BY r DESC
+ }
+} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.33.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738367 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.33.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.33.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.33.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}
+do_test boundary2-2.33.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY r DESC
+ }
+} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.33.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.34.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-549755813889
+ }
+} {-549755813889 58 ffffff7fffffffff}
+do_test boundary2-2.34.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffff7fffffffff'
+ }
+} {-549755813889 58}
+do_test boundary2-2.34.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=58
+ }
+} {-549755813889 ffffff7fffffffff}
+do_test boundary2-2.34.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813889 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}
+do_test boundary2-2.34.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813889 ORDER BY a DESC
+ }
+} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.34.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813889 ORDER BY r
+ }
+} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.34.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813889 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}
+do_test boundary2-2.34.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813889 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.34.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-2.34.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.34.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY r
+ }
+} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.34.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}
+do_test boundary2-2.34.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.34.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813889 ORDER BY a
+ }
+} {2 21 44 55 64}
+do_test boundary2-2.34.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813889 ORDER BY a DESC
+ }
+} {64 55 44 21 2}
+do_test boundary2-2.34.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813889 ORDER BY r
+ }
+} {55 2 64 21 44}
+do_test boundary2-2.34.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813889 ORDER BY r DESC
+ }
+} {44 21 64 2 55}
+do_test boundary2-2.34.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813889 ORDER BY x
+ }
+} {55 2 64 21 44}
+do_test boundary2-2.34.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY a
+ }
+} {2 21 44 55 58 64}
+do_test boundary2-2.34.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY a DESC
+ }
+} {64 58 55 44 21 2}
+do_test boundary2-2.34.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY r
+ }
+} {55 2 64 21 44 58}
+do_test boundary2-2.34.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY r DESC
+ }
+} {58 44 21 64 2 55}
+do_test boundary2-2.34.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY x
+ }
+} {55 2 64 21 44 58}
+do_test boundary2-2.35.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-32768
+ }
+} {-32768 32 ffffffffffff8000}
+do_test boundary2-2.35.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffffff8000'
+ }
+} {-32768 32}
+do_test boundary2-2.35.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=32
+ }
+} {-32768 ffffffffffff8000}
+do_test boundary2-2.35.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32768 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.35.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32768 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.35.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32768 ORDER BY r
+ }
+} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.35.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32768 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}
+do_test boundary2-2.35.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}
+do_test boundary2-2.35.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32768 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.35.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32768 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.35.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32768 ORDER BY r
+ }
+} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.35.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32768 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}
+do_test boundary2-2.35.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}
+do_test boundary2-2.35.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32768 ORDER BY a
+ }
+} {1 2 11 21 29 37 44 47 55 58 63 64}
+do_test boundary2-2.35.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32768 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 29 21 11 2 1}
+do_test boundary2-2.35.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32768 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary2-2.35.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32768 ORDER BY r DESC
+ }
+} {29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.35.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32768 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary2-2.35.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32768 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 55 58 63 64}
+do_test boundary2-2.35.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32768 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 32 29 21 11 2 1}
+do_test boundary2-2.35.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32768 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary2-2.35.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32768 ORDER BY r DESC
+ }
+} {32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.35.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32768 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary2-2.36.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=2147483647
+ }
+} {2147483647 20 000000007fffffff}
+do_test boundary2-2.36.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000000007fffffff'
+ }
+} {2147483647 20}
+do_test boundary2-2.36.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=20
+ }
+} {2147483647 000000007fffffff}
+do_test boundary2-2.36.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483647 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary2-2.36.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483647 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary2-2.36.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483647 ORDER BY r
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.36.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483647 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}
+do_test boundary2-2.36.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483647 ORDER BY x
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.36.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary2-2.36.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary2-2.36.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY r
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.36.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}
+do_test boundary2-2.36.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY x
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.36.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483647 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.36.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483647 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.36.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483647 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}
+do_test boundary2-2.36.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483647 ORDER BY r DESC
+ }
+} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.36.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483647 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.36.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.36.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.36.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}
+do_test boundary2-2.36.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY r DESC
+ }
+} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.36.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.37.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-129
+ }
+} {-129 54 ffffffffffffff7f}
+do_test boundary2-2.37.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffffffff7f'
+ }
+} {-129 54}
+do_test boundary2-2.37.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=54
+ }
+} {-129 ffffffffffffff7f}
+do_test boundary2-2.37.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -129 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}
+do_test boundary2-2.37.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -129 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.37.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -129 ORDER BY r
+ }
+} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.37.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -129 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}
+do_test boundary2-2.37.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -129 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}
+do_test boundary2-2.37.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -129 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.37.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -129 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.37.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -129 ORDER BY r
+ }
+} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.37.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -129 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}
+do_test boundary2-2.37.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -129 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}
+do_test boundary2-2.37.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -129 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 55 58 63 64}
+do_test boundary2-2.37.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -129 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 32 29 21 11 2 1}
+do_test boundary2-2.37.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -129 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary2-2.37.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -129 ORDER BY r DESC
+ }
+} {32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.37.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -129 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary2-2.37.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -129 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}
+do_test boundary2-2.37.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -129 ORDER BY a DESC
+ }
+} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}
+do_test boundary2-2.37.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -129 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary2-2.37.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -129 ORDER BY r DESC
+ }
+} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.37.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -129 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary2-2.38.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-128
+ }
+} {-128 53 ffffffffffffff80}
+do_test boundary2-2.38.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffffffff80'
+ }
+} {-128 53}
+do_test boundary2-2.38.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=53
+ }
+} {-128 ffffffffffffff80}
+do_test boundary2-2.38.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -128 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}
+do_test boundary2-2.38.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -128 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.38.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -128 ORDER BY r
+ }
+} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.38.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -128 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}
+do_test boundary2-2.38.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -128 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}
+do_test boundary2-2.38.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -128 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}
+do_test boundary2-2.38.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -128 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.38.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -128 ORDER BY r
+ }
+} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.38.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -128 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}
+do_test boundary2-2.38.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -128 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}
+do_test boundary2-2.38.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -128 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}
+do_test boundary2-2.38.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -128 ORDER BY a DESC
+ }
+} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}
+do_test boundary2-2.38.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -128 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary2-2.38.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -128 ORDER BY r DESC
+ }
+} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.38.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -128 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary2-2.38.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -128 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}
+do_test boundary2-2.38.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -128 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}
+do_test boundary2-2.38.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -128 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary2-2.38.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -128 ORDER BY r DESC
+ }
+} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.38.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -128 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary2-2.39.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=72057594037927936
+ }
+} {72057594037927936 28 0100000000000000}
+do_test boundary2-2.39.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0100000000000000'
+ }
+} {72057594037927936 28}
+do_test boundary2-2.39.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=28
+ }
+} {72057594037927936 0100000000000000}
+do_test boundary2-2.39.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY a
+ }
+} {3}
+do_test boundary2-2.39.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY a DESC
+ }
+} {3}
+do_test boundary2-2.39.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY r
+ }
+} {3}
+do_test boundary2-2.39.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY r DESC
+ }
+} {3}
+do_test boundary2-2.39.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY x
+ }
+} {3}
+do_test boundary2-2.39.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY a
+ }
+} {3 28}
+do_test boundary2-2.39.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY a DESC
+ }
+} {28 3}
+do_test boundary2-2.39.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY r
+ }
+} {28 3}
+do_test boundary2-2.39.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY r DESC
+ }
+} {3 28}
+do_test boundary2-2.39.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY x
+ }
+} {28 3}
+do_test boundary2-2.39.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.39.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.39.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}
+do_test boundary2-2.39.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY r DESC
+ }
+} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.39.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.39.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.39.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.39.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}
+do_test boundary2-2.39.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY r DESC
+ }
+} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.39.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.40.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=2147483648
+ }
+} {2147483648 51 0000000080000000}
+do_test boundary2-2.40.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000080000000'
+ }
+} {2147483648 51}
+do_test boundary2-2.40.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=51
+ }
+} {2147483648 0000000080000000}
+do_test boundary2-2.40.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483648 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary2-2.40.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483648 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary2-2.40.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483648 ORDER BY r
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.40.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483648 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}
+do_test boundary2-2.40.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483648 ORDER BY x
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.40.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary2-2.40.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary2-2.40.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY r
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.40.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}
+do_test boundary2-2.40.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY x
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.40.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483648 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.40.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483648 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.40.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483648 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}
+do_test boundary2-2.40.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483648 ORDER BY r DESC
+ }
+} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.40.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.40.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.40.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.40.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}
+do_test boundary2-2.40.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY r DESC
+ }
+} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.40.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.41.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=549755813887
+ }
+} {549755813887 46 0000007fffffffff}
+do_test boundary2-2.41.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000007fffffffff'
+ }
+} {549755813887 46}
+do_test boundary2-2.41.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=46
+ }
+} {549755813887 0000007fffffffff}
+do_test boundary2-2.41.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813887 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}
+do_test boundary2-2.41.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813887 ORDER BY a DESC
+ }
+} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-2.41.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813887 ORDER BY r
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.41.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813887 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}
+do_test boundary2-2.41.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813887 ORDER BY x
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.41.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary2-2.41.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-2.41.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY r
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.41.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}
+do_test boundary2-2.41.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY x
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.41.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813887 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.41.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813887 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.41.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813887 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}
+do_test boundary2-2.41.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813887 ORDER BY r DESC
+ }
+} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.41.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813887 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.41.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.41.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.41.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}
+do_test boundary2-2.41.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY r DESC
+ }
+} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.41.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.42.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-549755813888
+ }
+} {-549755813888 63 ffffff8000000000}
+do_test boundary2-2.42.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffff8000000000'
+ }
+} {-549755813888 63}
+do_test boundary2-2.42.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=63
+ }
+} {-549755813888 ffffff8000000000}
+do_test boundary2-2.42.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813888 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.42.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813888 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.42.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813888 ORDER BY r
+ }
+} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.42.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813888 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}
+do_test boundary2-2.42.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.42.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}
+do_test boundary2-2.42.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY a DESC
+ }
+} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.42.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY r
+ }
+} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.42.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}
+do_test boundary2-2.42.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.42.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813888 ORDER BY a
+ }
+} {2 21 44 55 58 64}
+do_test boundary2-2.42.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813888 ORDER BY a DESC
+ }
+} {64 58 55 44 21 2}
+do_test boundary2-2.42.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813888 ORDER BY r
+ }
+} {55 2 64 21 44 58}
+do_test boundary2-2.42.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813888 ORDER BY r DESC
+ }
+} {58 44 21 64 2 55}
+do_test boundary2-2.42.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813888 ORDER BY x
+ }
+} {55 2 64 21 44 58}
+do_test boundary2-2.42.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY a
+ }
+} {2 21 44 55 58 63 64}
+do_test boundary2-2.42.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY a DESC
+ }
+} {64 63 58 55 44 21 2}
+do_test boundary2-2.42.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY r
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary2-2.42.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY r DESC
+ }
+} {63 58 44 21 64 2 55}
+do_test boundary2-2.42.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY x
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary2-2.43.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=281474976710655
+ }
+} {281474976710655 10 0000ffffffffffff}
+do_test boundary2-2.43.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000ffffffffffff'
+ }
+} {281474976710655 10}
+do_test boundary2-2.43.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=10
+ }
+} {281474976710655 0000ffffffffffff}
+do_test boundary2-2.43.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY a
+ }
+} {3 13 17 26 27 28 43 45}
+do_test boundary2-2.43.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 3}
+do_test boundary2-2.43.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY r
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary2-2.43.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26}
+do_test boundary2-2.43.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY x
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary2-2.43.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 43 45}
+do_test boundary2-2.43.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 10 3}
+do_test boundary2-2.43.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY r
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.43.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10}
+do_test boundary2-2.43.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY x
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.43.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.43.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-2.43.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}
+do_test boundary2-2.43.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY r DESC
+ }
+} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.43.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.43.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.43.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.43.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}
+do_test boundary2-2.43.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY r DESC
+ }
+} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.43.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.44.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=4398046511103
+ }
+} {4398046511103 7 000003ffffffffff}
+do_test boundary2-2.44.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000003ffffffffff'
+ }
+} {4398046511103 7}
+do_test boundary2-2.44.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=7
+ }
+} {4398046511103 000003ffffffffff}
+do_test boundary2-2.44.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary2-2.44.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary2-2.44.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY r
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.44.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56}
+do_test boundary2-2.44.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY x
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.44.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY a
+ }
+} {3 7 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary2-2.44.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 7 3}
+do_test boundary2-2.44.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY r
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.44.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7}
+do_test boundary2-2.44.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY x
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.44.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-2.44.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.44.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}
+do_test boundary2-2.44.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY r DESC
+ }
+} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.44.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.44.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-2.44.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-2.44.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}
+do_test boundary2-2.44.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY r DESC
+ }
+} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.44.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.45.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=268435455
+ }
+} {268435455 12 000000000fffffff}
+do_test boundary2-2.45.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000000000fffffff'
+ }
+} {268435455 12}
+do_test boundary2-2.45.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=12
+ }
+} {268435455 000000000fffffff}
+do_test boundary2-2.45.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435455 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.45.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435455 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary2-2.45.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435455 ORDER BY r
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.45.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435455 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}
+do_test boundary2-2.45.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435455 ORDER BY x
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.45.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435455 ORDER BY a
+ }
+} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.45.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435455 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}
+do_test boundary2-2.45.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435455 ORDER BY r
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.45.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435455 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}
+do_test boundary2-2.45.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435455 ORDER BY x
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.45.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435455 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.45.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435455 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}
+do_test boundary2-2.45.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435455 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}
+do_test boundary2-2.45.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435455 ORDER BY r DESC
+ }
+} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.45.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435455 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.45.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435455 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.45.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435455 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-2.45.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435455 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}
+do_test boundary2-2.45.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435455 ORDER BY r DESC
+ }
+} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.45.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435455 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.46.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-9223372036854775808
+ }
+} {-9223372036854775808 55 8000000000000000}
+do_test boundary2-2.46.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='8000000000000000'
+ }
+} {-9223372036854775808 55}
+do_test boundary2-2.46.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=55
+ }
+} {-9223372036854775808 8000000000000000}
+do_test boundary2-2.46.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.46.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-2.46.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY r
+ }
+} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.46.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}
+do_test boundary2-2.46.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.46.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.46.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-2.46.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.46.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.46.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.46.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY a
+ }
+} {}
+do_test boundary2-2.46.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-2.46.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY r
+ }
+} {}
+do_test boundary2-2.46.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-2.46.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY x
+ }
+} {}
+do_test boundary2-2.46.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY a
+ }
+} {55}
+do_test boundary2-2.46.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY a DESC
+ }
+} {55}
+do_test boundary2-2.46.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY r
+ }
+} {55}
+do_test boundary2-2.46.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY r DESC
+ }
+} {55}
+do_test boundary2-2.46.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY x
+ }
+} {55}
+do_test boundary2-2.47.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=562949953421312
+ }
+} {562949953421312 43 0002000000000000}
+do_test boundary2-2.47.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0002000000000000'
+ }
+} {562949953421312 43}
+do_test boundary2-2.47.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=43
+ }
+} {562949953421312 0002000000000000}
+do_test boundary2-2.47.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY a
+ }
+} {3 17 27 28 45}
+do_test boundary2-2.47.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY a DESC
+ }
+} {45 28 27 17 3}
+do_test boundary2-2.47.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY r
+ }
+} {27 45 17 28 3}
+do_test boundary2-2.47.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY r DESC
+ }
+} {3 28 17 45 27}
+do_test boundary2-2.47.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY x
+ }
+} {27 45 17 28 3}
+do_test boundary2-2.47.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY a
+ }
+} {3 17 27 28 43 45}
+do_test boundary2-2.47.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY a DESC
+ }
+} {45 43 28 27 17 3}
+do_test boundary2-2.47.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY r
+ }
+} {43 27 45 17 28 3}
+do_test boundary2-2.47.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43}
+do_test boundary2-2.47.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY x
+ }
+} {43 27 45 17 28 3}
+do_test boundary2-2.47.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.47.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.47.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}
+do_test boundary2-2.47.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY r DESC
+ }
+} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.47.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.47.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.47.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.47.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}
+do_test boundary2-2.47.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY r DESC
+ }
+} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.47.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.48.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-8388609
+ }
+} {-8388609 1 ffffffffff7fffff}
+do_test boundary2-2.48.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffff7fffff'
+ }
+} {-8388609 1}
+do_test boundary2-2.48.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=1
+ }
+} {-8388609 ffffffffff7fffff}
+do_test boundary2-2.48.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388609 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.48.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388609 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.48.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388609 ORDER BY r
+ }
+} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.48.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388609 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}
+do_test boundary2-2.48.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388609 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}
+do_test boundary2-2.48.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388609 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.48.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388609 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.48.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388609 ORDER BY r
+ }
+} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.48.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388609 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}
+do_test boundary2-2.48.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388609 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.48.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388609 ORDER BY a
+ }
+} {2 11 21 44 47 55 58 63 64}
+do_test boundary2-2.48.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388609 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2}
+do_test boundary2-2.48.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388609 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary2-2.48.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388609 ORDER BY r DESC
+ }
+} {11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.48.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388609 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary2-2.48.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388609 ORDER BY a
+ }
+} {1 2 11 21 44 47 55 58 63 64}
+do_test boundary2-2.48.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388609 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2 1}
+do_test boundary2-2.48.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388609 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary2-2.48.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388609 ORDER BY r DESC
+ }
+} {1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.48.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388609 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary2-2.49.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=16777215
+ }
+} {16777215 9 0000000000ffffff}
+do_test boundary2-2.49.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000ffffff'
+ }
+} {16777215 9}
+do_test boundary2-2.49.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=9
+ }
+} {16777215 0000000000ffffff}
+do_test boundary2-2.49.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777215 ORDER BY a
+ }
+} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.49.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777215 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}
+do_test boundary2-2.49.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777215 ORDER BY r
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.49.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777215 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}
+do_test boundary2-2.49.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777215 ORDER BY x
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.49.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777215 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.49.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777215 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary2-2.49.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777215 ORDER BY r
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.49.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777215 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}
+do_test boundary2-2.49.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777215 ORDER BY x
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.49.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777215 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.49.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777215 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary2-2.49.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777215 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}
+do_test boundary2-2.49.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777215 ORDER BY r DESC
+ }
+} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.49.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777215 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.49.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777215 ORDER BY a
+ }
+} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.49.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777215 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}
+do_test boundary2-2.49.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777215 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}
+do_test boundary2-2.49.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777215 ORDER BY r DESC
+ }
+} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.49.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777215 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.50.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=8388608
+ }
+} {8388608 24 0000000000800000}
+do_test boundary2-2.50.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000800000'
+ }
+} {8388608 24}
+do_test boundary2-2.50.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=24
+ }
+} {8388608 0000000000800000}
+do_test boundary2-2.50.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388608 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.50.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388608 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary2-2.50.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388608 ORDER BY r
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.50.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388608 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}
+do_test boundary2-2.50.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388608 ORDER BY x
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.50.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388608 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-2.50.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388608 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary2-2.50.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388608 ORDER BY r
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.50.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388608 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}
+do_test boundary2-2.50.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388608 ORDER BY x
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.50.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388608 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.50.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388608 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary2-2.50.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388608 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}
+do_test boundary2-2.50.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388608 ORDER BY r DESC
+ }
+} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.50.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.50.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388608 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.50.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388608 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary2-2.50.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388608 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}
+do_test boundary2-2.50.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388608 ORDER BY r DESC
+ }
+} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.50.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.51.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=16383
+ }
+} {16383 8 0000000000003fff}
+do_test boundary2-2.51.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000003fff'
+ }
+} {16383 8}
+do_test boundary2-2.51.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=8
+ }
+} {16383 0000000000003fff}
+do_test boundary2-2.51.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16383 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-2.51.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16383 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.51.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16383 ORDER BY r
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.51.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16383 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}
+do_test boundary2-2.51.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16383 ORDER BY x
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.51.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16383 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-2.51.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16383 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-2.51.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16383 ORDER BY r
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.51.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16383 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}
+do_test boundary2-2.51.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16383 ORDER BY x
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.51.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16383 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.51.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16383 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary2-2.51.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16383 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}
+do_test boundary2-2.51.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16383 ORDER BY r DESC
+ }
+} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.51.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16383 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.51.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16383 ORDER BY a
+ }
+} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.51.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16383 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}
+do_test boundary2-2.51.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16383 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}
+do_test boundary2-2.51.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16383 ORDER BY r DESC
+ }
+} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.51.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16383 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.52.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=140737488355328
+ }
+} {140737488355328 34 0000800000000000}
+do_test boundary2-2.52.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000800000000000'
+ }
+} {140737488355328 34}
+do_test boundary2-2.52.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=34
+ }
+} {140737488355328 0000800000000000}
+do_test boundary2-2.52.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 43 45}
+do_test boundary2-2.52.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 10 3}
+do_test boundary2-2.52.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY r
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.52.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10}
+do_test boundary2-2.52.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY x
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.52.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 34 43 45}
+do_test boundary2-2.52.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 17 13 10 3}
+do_test boundary2-2.52.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY r
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.52.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34}
+do_test boundary2-2.52.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY x
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.52.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.52.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-2.52.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}
+do_test boundary2-2.52.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY r DESC
+ }
+} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.52.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.52.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.52.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-2.52.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}
+do_test boundary2-2.52.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY r DESC
+ }
+} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.52.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.53.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=2097151
+ }
+} {2097151 15 00000000001fffff}
+do_test boundary2-2.53.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00000000001fffff'
+ }
+} {2097151 15}
+do_test boundary2-2.53.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=15
+ }
+} {2097151 00000000001fffff}
+do_test boundary2-2.53.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097151 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary2-2.53.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097151 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary2-2.53.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097151 ORDER BY r
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.53.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097151 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}
+do_test boundary2-2.53.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097151 ORDER BY x
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.53.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097151 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary2-2.53.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097151 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.53.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097151 ORDER BY r
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.53.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097151 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}
+do_test boundary2-2.53.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097151 ORDER BY x
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.53.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097151 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.53.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097151 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-2.53.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097151 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}
+do_test boundary2-2.53.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097151 ORDER BY r DESC
+ }
+} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.53.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097151 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.53.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097151 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-2.53.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097151 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary2-2.53.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097151 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}
+do_test boundary2-2.53.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097151 ORDER BY r DESC
+ }
+} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.53.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097151 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.54.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=140737488355327
+ }
+} {140737488355327 25 00007fffffffffff}
+do_test boundary2-2.54.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00007fffffffffff'
+ }
+} {140737488355327 25}
+do_test boundary2-2.54.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=25
+ }
+} {140737488355327 00007fffffffffff}
+do_test boundary2-2.54.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 34 43 45}
+do_test boundary2-2.54.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 17 13 10 3}
+do_test boundary2-2.54.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY r
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.54.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34}
+do_test boundary2-2.54.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY x
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.54.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45}
+do_test boundary2-2.54.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary2-2.54.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY r
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.54.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25}
+do_test boundary2-2.54.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY x
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.54.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.54.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-2.54.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}
+do_test boundary2-2.54.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY r DESC
+ }
+} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.54.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.54.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.54.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-2.54.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}
+do_test boundary2-2.54.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY r DESC
+ }
+} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.54.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.55.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=281474976710656
+ }
+} {281474976710656 26 0001000000000000}
+do_test boundary2-2.55.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0001000000000000'
+ }
+} {281474976710656 26}
+do_test boundary2-2.55.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=26
+ }
+} {281474976710656 0001000000000000}
+do_test boundary2-2.55.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY a
+ }
+} {3 13 17 27 28 43 45}
+do_test boundary2-2.55.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY a DESC
+ }
+} {45 43 28 27 17 13 3}
+do_test boundary2-2.55.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY r
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary2-2.55.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13}
+do_test boundary2-2.55.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY x
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary2-2.55.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY a
+ }
+} {3 13 17 26 27 28 43 45}
+do_test boundary2-2.55.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 3}
+do_test boundary2-2.55.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY r
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary2-2.55.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26}
+do_test boundary2-2.55.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY x
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary2-2.55.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.55.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.55.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}
+do_test boundary2-2.55.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY r DESC
+ }
+} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.55.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.55.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.55.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.55.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}
+do_test boundary2-2.55.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY r DESC
+ }
+} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.55.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.56.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=32767
+ }
+} {32767 23 0000000000007fff}
+do_test boundary2-2.56.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000007fff'
+ }
+} {32767 23}
+do_test boundary2-2.56.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=23
+ }
+} {32767 0000000000007fff}
+do_test boundary2-2.56.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32767 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-2.56.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32767 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.56.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32767 ORDER BY r
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.56.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32767 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}
+do_test boundary2-2.56.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32767 ORDER BY x
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.56.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32767 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-2.56.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32767 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-2.56.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32767 ORDER BY r
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.56.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32767 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}
+do_test boundary2-2.56.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32767 ORDER BY x
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.56.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32767 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.56.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32767 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}
+do_test boundary2-2.56.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32767 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}
+do_test boundary2-2.56.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32767 ORDER BY r DESC
+ }
+} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.56.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32767 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.56.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32767 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-2.56.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32767 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-2.56.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32767 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}
+do_test boundary2-2.56.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32767 ORDER BY r DESC
+ }
+} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.56.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32767 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.57.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=127
+ }
+} {127 4 000000000000007f}
+do_test boundary2-2.57.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000000000000007f'
+ }
+} {127 4}
+do_test boundary2-2.57.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=4
+ }
+} {127 000000000000007f}
+do_test boundary2-2.57.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 127 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-2.57.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 127 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-2.57.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 127 ORDER BY r
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.57.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 127 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}
+do_test boundary2-2.57.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 127 ORDER BY x
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.57.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 127 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-2.57.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 127 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary2-2.57.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 127 ORDER BY r
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.57.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 127 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}
+do_test boundary2-2.57.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 127 ORDER BY x
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.57.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 127 ORDER BY a
+ }
+} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.57.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 127 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}
+do_test boundary2-2.57.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 127 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}
+do_test boundary2-2.57.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 127 ORDER BY r DESC
+ }
+} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.57.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 127 ORDER BY x
+ }
+} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.57.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 127 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.57.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 127 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary2-2.57.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 127 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}
+do_test boundary2-2.57.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 127 ORDER BY r DESC
+ }
+} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.57.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 127 ORDER BY x
+ }
+} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.58.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=36028797018963967
+ }
+} {36028797018963967 27 007fffffffffffff}
+do_test boundary2-2.58.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='007fffffffffffff'
+ }
+} {36028797018963967 27}
+do_test boundary2-2.58.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=27
+ }
+} {36028797018963967 007fffffffffffff}
+do_test boundary2-2.58.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY a
+ }
+} {3 17 28 45}
+do_test boundary2-2.58.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY a DESC
+ }
+} {45 28 17 3}
+do_test boundary2-2.58.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY r
+ }
+} {45 17 28 3}
+do_test boundary2-2.58.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY r DESC
+ }
+} {3 28 17 45}
+do_test boundary2-2.58.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY x
+ }
+} {45 17 28 3}
+do_test boundary2-2.58.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY a
+ }
+} {3 17 27 28 45}
+do_test boundary2-2.58.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY a DESC
+ }
+} {45 28 27 17 3}
+do_test boundary2-2.58.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY r
+ }
+} {27 45 17 28 3}
+do_test boundary2-2.58.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY r DESC
+ }
+} {3 28 17 45 27}
+do_test boundary2-2.58.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY x
+ }
+} {27 45 17 28 3}
+do_test boundary2-2.58.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.58.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.58.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}
+do_test boundary2-2.58.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY r DESC
+ }
+} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.58.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.58.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.58.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.58.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}
+do_test boundary2-2.58.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY r DESC
+ }
+} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.58.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.59.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=4398046511104
+ }
+} {4398046511104 56 0000040000000000}
+do_test boundary2-2.59.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000040000000000'
+ }
+} {4398046511104 56}
+do_test boundary2-2.59.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=56
+ }
+} {4398046511104 0000040000000000}
+do_test boundary2-2.59.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45}
+do_test boundary2-2.59.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary2-2.59.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY r
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.59.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25}
+do_test boundary2-2.59.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY x
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.59.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary2-2.59.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary2-2.59.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY r
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.59.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56}
+do_test boundary2-2.59.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY x
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.59.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-2.59.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-2.59.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}
+do_test boundary2-2.59.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY r DESC
+ }
+} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.59.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.59.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.59.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-2.59.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}
+do_test boundary2-2.59.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY r DESC
+ }
+} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.59.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.60.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=1
+ }
+} {1 60 0000000000000001}
+do_test boundary2-2.60.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000001'
+ }
+} {1 60}
+do_test boundary2-2.60.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=60
+ }
+} {1 0000000000000001}
+do_test boundary2-2.60.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-2.60.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.60.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1 ORDER BY r
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.60.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}
+do_test boundary2-2.60.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1 ORDER BY x
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.60.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}
+do_test boundary2-2.60.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1 ORDER BY a DESC
+ }
+} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.60.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1 ORDER BY r
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.60.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}
+do_test boundary2-2.60.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1 ORDER BY x
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.60.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}
+do_test boundary2-2.60.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1 ORDER BY a DESC
+ }
+} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-2.60.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}
+do_test boundary2-2.60.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1 ORDER BY r DESC
+ }
+} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.60.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1 ORDER BY x
+ }
+} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.60.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.60.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-2.60.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}
+do_test boundary2-2.60.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1 ORDER BY r DESC
+ }
+} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.60.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1 ORDER BY x
+ }
+} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.61.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=36028797018963968
+ }
+} {36028797018963968 45 0080000000000000}
+do_test boundary2-2.61.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0080000000000000'
+ }
+} {36028797018963968 45}
+do_test boundary2-2.61.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=45
+ }
+} {36028797018963968 0080000000000000}
+do_test boundary2-2.61.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY a
+ }
+} {3 17 28}
+do_test boundary2-2.61.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY a DESC
+ }
+} {28 17 3}
+do_test boundary2-2.61.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY r
+ }
+} {17 28 3}
+do_test boundary2-2.61.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY r DESC
+ }
+} {3 28 17}
+do_test boundary2-2.61.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY x
+ }
+} {17 28 3}
+do_test boundary2-2.61.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY a
+ }
+} {3 17 28 45}
+do_test boundary2-2.61.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY a DESC
+ }
+} {45 28 17 3}
+do_test boundary2-2.61.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY r
+ }
+} {45 17 28 3}
+do_test boundary2-2.61.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY r DESC
+ }
+} {3 28 17 45}
+do_test boundary2-2.61.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY x
+ }
+} {45 17 28 3}
+do_test boundary2-2.61.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.61.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.61.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}
+do_test boundary2-2.61.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY r DESC
+ }
+} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.61.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.61.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.61.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-2.61.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}
+do_test boundary2-2.61.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY r DESC
+ }
+} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.61.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.62.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-2147483649
+ }
+} {-2147483649 47 ffffffff7fffffff}
+do_test boundary2-2.62.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffff7fffffff'
+ }
+} {-2147483649 47}
+do_test boundary2-2.62.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=47
+ }
+} {-2147483649 ffffffff7fffffff}
+do_test boundary2-2.62.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483649 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.62.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483649 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.62.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483649 ORDER BY r
+ }
+} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.62.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483649 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}
+do_test boundary2-2.62.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483649 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.62.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-2.62.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.62.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY r
+ }
+} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.62.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}
+do_test boundary2-2.62.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.62.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483649 ORDER BY a
+ }
+} {2 21 44 55 58 63 64}
+do_test boundary2-2.62.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483649 ORDER BY a DESC
+ }
+} {64 63 58 55 44 21 2}
+do_test boundary2-2.62.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483649 ORDER BY r
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary2-2.62.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483649 ORDER BY r DESC
+ }
+} {63 58 44 21 64 2 55}
+do_test boundary2-2.62.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483649 ORDER BY x
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary2-2.62.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY a
+ }
+} {2 21 44 47 55 58 63 64}
+do_test boundary2-2.62.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 2}
+do_test boundary2-2.62.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary2-2.62.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY r DESC
+ }
+} {47 63 58 44 21 64 2 55}
+do_test boundary2-2.62.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary2-2.63.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-36028797018963969
+ }
+} {-36028797018963969 2 ff7fffffffffffff}
+do_test boundary2-2.63.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ff7fffffffffffff'
+ }
+} {-36028797018963969 2}
+do_test boundary2-2.63.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=2
+ }
+} {-36028797018963969 ff7fffffffffffff}
+do_test boundary2-2.63.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.63.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-2.63.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY r
+ }
+} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.63.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}
+do_test boundary2-2.63.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.63.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.63.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-2.63.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY r
+ }
+} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.63.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}
+do_test boundary2-2.63.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.63.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY a
+ }
+} {55}
+do_test boundary2-2.63.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY a DESC
+ }
+} {55}
+do_test boundary2-2.63.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY r
+ }
+} {55}
+do_test boundary2-2.63.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY r DESC
+ }
+} {55}
+do_test boundary2-2.63.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY x
+ }
+} {55}
+do_test boundary2-2.63.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY a
+ }
+} {2 55}
+do_test boundary2-2.63.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY a DESC
+ }
+} {55 2}
+do_test boundary2-2.63.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY r
+ }
+} {55 2}
+do_test boundary2-2.63.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY r DESC
+ }
+} {2 55}
+do_test boundary2-2.63.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY x
+ }
+} {55 2}
+do_test boundary2-2.64.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=3
+ }
+} {3 5 0000000000000003}
+do_test boundary2-2.64.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000003'
+ }
+} {3 5}
+do_test boundary2-2.64.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=5
+ }
+} {3 0000000000000003}
+do_test boundary2-2.64.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 3 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-2.64.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 3 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary2-2.64.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 3 ORDER BY r
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.64.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 3 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}
+do_test boundary2-2.64.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 3 ORDER BY x
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.64.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 3 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-2.64.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 3 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-2.64.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 3 ORDER BY r
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.64.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 3 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}
+do_test boundary2-2.64.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 3 ORDER BY x
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.64.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 3 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.64.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 3 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}
+do_test boundary2-2.64.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 3 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}
+do_test boundary2-2.64.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 3 ORDER BY r DESC
+ }
+} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.64.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 3 ORDER BY x
+ }
+} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.64.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 3 ORDER BY a
+ }
+} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-2.64.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 3 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}
+do_test boundary2-2.64.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 3 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}
+do_test boundary2-2.64.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 3 ORDER BY r DESC
+ }
+} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.64.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 3 ORDER BY x
+ }
+} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.65.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary2-2.65.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-2.65.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY r
+ }
+} {}
+do_test boundary2-2.65.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-2.65.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+do_test boundary2-2.65.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary2-2.65.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-2.65.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY r
+ }
+} {}
+do_test boundary2-2.65.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-2.65.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+do_test boundary2-2.65.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.65.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-2.65.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.65.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.65.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.65.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.65.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-2.65.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.65.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.65.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.66.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.66.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-2.66.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.66.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.66.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.66.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-2.66.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-2.66.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-2.66.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-2.66.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-2.66.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary2-2.66.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-2.66.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY r
+ }
+} {}
+do_test boundary2-2.66.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-2.66.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+do_test boundary2-2.66.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary2-2.66.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-2.66.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY r
+ }
+} {}
+do_test boundary2-2.66.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-2.66.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+do_test boundary2-3.1 {
+ db eval {
+ DROP INDEX t1i1;
+ DROP INDEX t1i2;
+ DROP INDEX t1i3;
+ }
+} {}
+do_test boundary2-4.1.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=72057594037927935
+ }
+} {72057594037927935 17 00ffffffffffffff}
+do_test boundary2-4.1.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00ffffffffffffff'
+ }
+} {72057594037927935 17}
+do_test boundary2-4.1.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=17
+ }
+} {72057594037927935 00ffffffffffffff}
+do_test boundary2-4.1.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY a
+ }
+} {3 28}
+do_test boundary2-4.1.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY a DESC
+ }
+} {28 3}
+do_test boundary2-4.1.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY r
+ }
+} {28 3}
+do_test boundary2-4.1.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY r DESC
+ }
+} {3 28}
+do_test boundary2-4.1.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY x
+ }
+} {28 3}
+do_test boundary2-4.1.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY a
+ }
+} {3 17 28}
+do_test boundary2-4.1.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY a DESC
+ }
+} {28 17 3}
+do_test boundary2-4.1.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY r
+ }
+} {17 28 3}
+do_test boundary2-4.1.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY r DESC
+ }
+} {3 28 17}
+do_test boundary2-4.1.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY x
+ }
+} {17 28 3}
+do_test boundary2-4.1.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.1.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.1.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}
+do_test boundary2-4.1.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY r DESC
+ }
+} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.1.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.1.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.1.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.1.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}
+do_test boundary2-4.1.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY r DESC
+ }
+} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.1.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.2.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=16384
+ }
+} {16384 16 0000000000004000}
+do_test boundary2-4.2.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000004000'
+ }
+} {16384 16}
+do_test boundary2-4.2.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=16
+ }
+} {16384 0000000000004000}
+do_test boundary2-4.2.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16384 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-4.2.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16384 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.2.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16384 ORDER BY r
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.2.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16384 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}
+do_test boundary2-4.2.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16384 ORDER BY x
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.2.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16384 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-4.2.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16384 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.2.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16384 ORDER BY r
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.2.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16384 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}
+do_test boundary2-4.2.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16384 ORDER BY x
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.2.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16384 ORDER BY a
+ }
+} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.2.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16384 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}
+do_test boundary2-4.2.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16384 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}
+do_test boundary2-4.2.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16384 ORDER BY r DESC
+ }
+} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.2.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16384 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.2.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16384 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.2.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16384 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}
+do_test boundary2-4.2.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16384 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}
+do_test boundary2-4.2.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16384 ORDER BY r DESC
+ }
+} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.2.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16384 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.3.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=4294967296
+ }
+} {4294967296 36 0000000100000000}
+do_test boundary2-4.3.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000100000000'
+ }
+} {4294967296 36}
+do_test boundary2-4.3.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=36
+ }
+} {4294967296 0000000100000000}
+do_test boundary2-4.3.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967296 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}
+do_test boundary2-4.3.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967296 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-4.3.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967296 ORDER BY r
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.3.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967296 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}
+do_test boundary2-4.3.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967296 ORDER BY x
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.3.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary2-4.3.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-4.3.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY r
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.3.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}
+do_test boundary2-4.3.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY x
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.3.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967296 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.3.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967296 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.3.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967296 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}
+do_test boundary2-4.3.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967296 ORDER BY r DESC
+ }
+} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.3.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967296 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.3.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.3.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.3.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}
+do_test boundary2-4.3.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY r DESC
+ }
+} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.3.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.4.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=16777216
+ }
+} {16777216 6 0000000001000000}
+do_test boundary2-4.4.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000001000000'
+ }
+} {16777216 6}
+do_test boundary2-4.4.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=6
+ }
+} {16777216 0000000001000000}
+do_test boundary2-4.4.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777216 ORDER BY a
+ }
+} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.4.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777216 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}
+do_test boundary2-4.4.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777216 ORDER BY r
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.4.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777216 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}
+do_test boundary2-4.4.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777216 ORDER BY x
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.4.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777216 ORDER BY a
+ }
+} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.4.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777216 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}
+do_test boundary2-4.4.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777216 ORDER BY r
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.4.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777216 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}
+do_test boundary2-4.4.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777216 ORDER BY x
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.4.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777216 ORDER BY a
+ }
+} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.4.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777216 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}
+do_test boundary2-4.4.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777216 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}
+do_test boundary2-4.4.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777216 ORDER BY r DESC
+ }
+} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.4.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777216 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.4.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777216 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.4.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777216 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}
+do_test boundary2-4.4.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777216 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}
+do_test boundary2-4.4.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777216 ORDER BY r DESC
+ }
+} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.4.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777216 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.5.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-32769
+ }
+} {-32769 29 ffffffffffff7fff}
+do_test boundary2-4.5.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffffff7fff'
+ }
+} {-32769 29}
+do_test boundary2-4.5.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=29
+ }
+} {-32769 ffffffffffff7fff}
+do_test boundary2-4.5.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32769 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.5.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32769 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.5.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32769 ORDER BY r
+ }
+} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.5.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32769 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}
+do_test boundary2-4.5.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32769 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}
+do_test boundary2-4.5.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32769 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.5.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32769 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.5.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32769 ORDER BY r
+ }
+} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.5.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32769 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}
+do_test boundary2-4.5.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32769 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}
+do_test boundary2-4.5.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32769 ORDER BY a
+ }
+} {1 2 11 21 37 44 47 55 58 63 64}
+do_test boundary2-4.5.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32769 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 21 11 2 1}
+do_test boundary2-4.5.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32769 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary2-4.5.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32769 ORDER BY r DESC
+ }
+} {37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.5.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32769 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary2-4.5.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32769 ORDER BY a
+ }
+} {1 2 11 21 29 37 44 47 55 58 63 64}
+do_test boundary2-4.5.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32769 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 29 21 11 2 1}
+do_test boundary2-4.5.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32769 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary2-4.5.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32769 ORDER BY r DESC
+ }
+} {29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.5.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32769 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary2-4.6.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-140737488355329
+ }
+} {-140737488355329 21 ffff7fffffffffff}
+do_test boundary2-4.6.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffff7fffffffffff'
+ }
+} {-140737488355329 21}
+do_test boundary2-4.6.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=21
+ }
+} {-140737488355329 ffff7fffffffffff}
+do_test boundary2-4.6.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-4.6.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.6.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY r
+ }
+} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.6.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}
+do_test boundary2-4.6.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.6.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-4.6.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.6.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY r
+ }
+} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.6.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}
+do_test boundary2-4.6.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.6.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY a
+ }
+} {2 55 64}
+do_test boundary2-4.6.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY a DESC
+ }
+} {64 55 2}
+do_test boundary2-4.6.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY r
+ }
+} {55 2 64}
+do_test boundary2-4.6.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY r DESC
+ }
+} {64 2 55}
+do_test boundary2-4.6.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY x
+ }
+} {55 2 64}
+do_test boundary2-4.6.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY a
+ }
+} {2 21 55 64}
+do_test boundary2-4.6.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY a DESC
+ }
+} {64 55 21 2}
+do_test boundary2-4.6.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY r
+ }
+} {55 2 64 21}
+do_test boundary2-4.6.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY r DESC
+ }
+} {21 64 2 55}
+do_test boundary2-4.6.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY x
+ }
+} {55 2 64 21}
+do_test boundary2-4.7.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=2
+ }
+} {2 41 0000000000000002}
+do_test boundary2-4.7.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000002'
+ }
+} {2 41}
+do_test boundary2-4.7.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=41
+ }
+} {2 0000000000000002}
+do_test boundary2-4.7.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-4.7.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.7.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2 ORDER BY r
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.7.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}
+do_test boundary2-4.7.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2 ORDER BY x
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.7.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-4.7.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.7.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2 ORDER BY r
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.7.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}
+do_test boundary2-4.7.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2 ORDER BY x
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.7.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.7.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-4.7.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}
+do_test boundary2-4.7.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2 ORDER BY r DESC
+ }
+} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.7.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2 ORDER BY x
+ }
+} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.7.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.7.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}
+do_test boundary2-4.7.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}
+do_test boundary2-4.7.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2 ORDER BY r DESC
+ }
+} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.7.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2 ORDER BY x
+ }
+} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.8.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=4
+ }
+} {4 31 0000000000000004}
+do_test boundary2-4.8.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000004'
+ }
+} {4 31}
+do_test boundary2-4.8.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=31
+ }
+} {4 0000000000000004}
+do_test boundary2-4.8.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-4.8.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary2-4.8.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4 ORDER BY r
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.8.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}
+do_test boundary2-4.8.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4 ORDER BY x
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.8.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-4.8.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary2-4.8.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4 ORDER BY r
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.8.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}
+do_test boundary2-4.8.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4 ORDER BY x
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.8.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4 ORDER BY a
+ }
+} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.8.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}
+do_test boundary2-4.8.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}
+do_test boundary2-4.8.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4 ORDER BY r DESC
+ }
+} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.8.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4 ORDER BY x
+ }
+} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.8.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4 ORDER BY a
+ }
+} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.8.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}
+do_test boundary2-4.8.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}
+do_test boundary2-4.8.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4 ORDER BY r DESC
+ }
+} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.8.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4 ORDER BY x
+ }
+} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.9.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=562949953421311
+ }
+} {562949953421311 13 0001ffffffffffff}
+do_test boundary2-4.9.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0001ffffffffffff'
+ }
+} {562949953421311 13}
+do_test boundary2-4.9.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=13
+ }
+} {562949953421311 0001ffffffffffff}
+do_test boundary2-4.9.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY a
+ }
+} {3 17 27 28 43 45}
+do_test boundary2-4.9.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY a DESC
+ }
+} {45 43 28 27 17 3}
+do_test boundary2-4.9.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY r
+ }
+} {43 27 45 17 28 3}
+do_test boundary2-4.9.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43}
+do_test boundary2-4.9.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY x
+ }
+} {43 27 45 17 28 3}
+do_test boundary2-4.9.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY a
+ }
+} {3 13 17 27 28 43 45}
+do_test boundary2-4.9.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY a DESC
+ }
+} {45 43 28 27 17 13 3}
+do_test boundary2-4.9.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY r
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary2-4.9.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13}
+do_test boundary2-4.9.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY x
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary2-4.9.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.9.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.9.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}
+do_test boundary2-4.9.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY r DESC
+ }
+} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.9.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.9.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.9.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.9.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}
+do_test boundary2-4.9.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY r DESC
+ }
+} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.9.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.10.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=256
+ }
+} {256 61 0000000000000100}
+do_test boundary2-4.10.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000100'
+ }
+} {256 61}
+do_test boundary2-4.10.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=61
+ }
+} {256 0000000000000100}
+do_test boundary2-4.10.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 256 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-4.10.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 256 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-4.10.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 256 ORDER BY r
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.10.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 256 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}
+do_test boundary2-4.10.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 256 ORDER BY x
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.10.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 256 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary2-4.10.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 256 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-4.10.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 256 ORDER BY r
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.10.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 256 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}
+do_test boundary2-4.10.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 256 ORDER BY x
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.10.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 256 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.10.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 256 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary2-4.10.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 256 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}
+do_test boundary2-4.10.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 256 ORDER BY r DESC
+ }
+} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.10.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 256 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.10.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 256 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.10.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 256 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary2-4.10.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 256 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}
+do_test boundary2-4.10.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 256 ORDER BY r DESC
+ }
+} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.10.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 256 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.11.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=34359738368
+ }
+} {34359738368 22 0000000800000000}
+do_test boundary2-4.11.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000800000000'
+ }
+} {34359738368 22}
+do_test boundary2-4.11.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=22
+ }
+} {34359738368 0000000800000000}
+do_test boundary2-4.11.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738368 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary2-4.11.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738368 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-4.11.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738368 ORDER BY r
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.11.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738368 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}
+do_test boundary2-4.11.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738368 ORDER BY x
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.11.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary2-4.11.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-4.11.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY r
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.11.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}
+do_test boundary2-4.11.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY x
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.11.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738368 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.11.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738368 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.11.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738368 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}
+do_test boundary2-4.11.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738368 ORDER BY r DESC
+ }
+} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.11.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738368 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.11.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.11.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.11.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}
+do_test boundary2-4.11.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY r DESC
+ }
+} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.11.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.12.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=65536
+ }
+} {65536 62 0000000000010000}
+do_test boundary2-4.12.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000010000'
+ }
+} {65536 62}
+do_test boundary2-4.12.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=62
+ }
+} {65536 0000000000010000}
+do_test boundary2-4.12.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65536 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary2-4.12.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65536 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.12.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65536 ORDER BY r
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.12.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65536 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}
+do_test boundary2-4.12.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65536 ORDER BY x
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.12.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65536 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}
+do_test boundary2-4.12.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65536 ORDER BY a DESC
+ }
+} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.12.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65536 ORDER BY r
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.12.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65536 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}
+do_test boundary2-4.12.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65536 ORDER BY x
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.12.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65536 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.12.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65536 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-4.12.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65536 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}
+do_test boundary2-4.12.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65536 ORDER BY r DESC
+ }
+} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.12.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65536 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.12.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65536 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.12.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65536 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-4.12.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65536 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}
+do_test boundary2-4.12.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65536 ORDER BY r DESC
+ }
+} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.12.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65536 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.13.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=268435456
+ }
+} {268435456 40 0000000010000000}
+do_test boundary2-4.13.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000010000000'
+ }
+} {268435456 40}
+do_test boundary2-4.13.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=40
+ }
+} {268435456 0000000010000000}
+do_test boundary2-4.13.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435456 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary2-4.13.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435456 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary2-4.13.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435456 ORDER BY r
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.13.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435456 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}
+do_test boundary2-4.13.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435456 ORDER BY x
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.13.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435456 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.13.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435456 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary2-4.13.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435456 ORDER BY r
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.13.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435456 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}
+do_test boundary2-4.13.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435456 ORDER BY x
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.13.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435456 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.13.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435456 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.13.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435456 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}
+do_test boundary2-4.13.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435456 ORDER BY r DESC
+ }
+} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.13.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435456 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.13.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435456 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.13.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435456 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.13.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435456 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}
+do_test boundary2-4.13.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435456 ORDER BY r DESC
+ }
+} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.13.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435456 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.14.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-140737488355328
+ }
+} {-140737488355328 44 ffff800000000000}
+do_test boundary2-4.14.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffff800000000000'
+ }
+} {-140737488355328 44}
+do_test boundary2-4.14.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=44
+ }
+} {-140737488355328 ffff800000000000}
+do_test boundary2-4.14.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-4.14.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.14.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY r
+ }
+} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.14.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}
+do_test boundary2-4.14.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.14.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-4.14.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.14.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY r
+ }
+} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.14.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}
+do_test boundary2-4.14.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.14.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY a
+ }
+} {2 21 55 64}
+do_test boundary2-4.14.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY a DESC
+ }
+} {64 55 21 2}
+do_test boundary2-4.14.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY r
+ }
+} {55 2 64 21}
+do_test boundary2-4.14.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY r DESC
+ }
+} {21 64 2 55}
+do_test boundary2-4.14.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY x
+ }
+} {55 2 64 21}
+do_test boundary2-4.14.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY a
+ }
+} {2 21 44 55 64}
+do_test boundary2-4.14.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY a DESC
+ }
+} {64 55 44 21 2}
+do_test boundary2-4.14.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY r
+ }
+} {55 2 64 21 44}
+do_test boundary2-4.14.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY r DESC
+ }
+} {44 21 64 2 55}
+do_test boundary2-4.14.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY x
+ }
+} {55 2 64 21 44}
+do_test boundary2-4.15.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=1099511627776
+ }
+} {1099511627776 19 0000010000000000}
+do_test boundary2-4.15.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000010000000000'
+ }
+} {1099511627776 19}
+do_test boundary2-4.15.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=19
+ }
+} {1099511627776 0000010000000000}
+do_test boundary2-4.15.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY a
+ }
+} {3 7 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary2-4.15.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 7 3}
+do_test boundary2-4.15.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY r
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.15.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7}
+do_test boundary2-4.15.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY x
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.15.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}
+do_test boundary2-4.15.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-4.15.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY r
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.15.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}
+do_test boundary2-4.15.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY x
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.15.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-4.15.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.15.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}
+do_test boundary2-4.15.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY r DESC
+ }
+} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.15.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.15.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-4.15.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.15.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}
+do_test boundary2-4.15.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY r DESC
+ }
+} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.15.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.16.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY a
+ }
+} {}
+do_test boundary2-4.16.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-4.16.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY r
+ }
+} {}
+do_test boundary2-4.16.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-4.16.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY x
+ }
+} {}
+do_test boundary2-4.16.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY a
+ }
+} {3}
+do_test boundary2-4.16.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY a DESC
+ }
+} {3}
+do_test boundary2-4.16.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY r
+ }
+} {3}
+do_test boundary2-4.16.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY r DESC
+ }
+} {3}
+do_test boundary2-4.16.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY x
+ }
+} {3}
+do_test boundary2-4.16.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.16.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.16.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}
+do_test boundary2-4.16.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY r DESC
+ }
+} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.16.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.16.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.16.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-4.16.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.16.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.16.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.17.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=32768
+ }
+} {32768 50 0000000000008000}
+do_test boundary2-4.17.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000008000'
+ }
+} {32768 50}
+do_test boundary2-4.17.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=50
+ }
+} {32768 0000000000008000}
+do_test boundary2-4.17.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32768 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}
+do_test boundary2-4.17.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32768 ORDER BY a DESC
+ }
+} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.17.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32768 ORDER BY r
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.17.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32768 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}
+do_test boundary2-4.17.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32768 ORDER BY x
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.17.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32768 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-4.17.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32768 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.17.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32768 ORDER BY r
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.17.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32768 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}
+do_test boundary2-4.17.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32768 ORDER BY x
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.17.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32768 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.17.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32768 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-4.17.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32768 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}
+do_test boundary2-4.17.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32768 ORDER BY r DESC
+ }
+} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.17.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.17.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32768 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.17.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32768 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-4.17.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32768 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}
+do_test boundary2-4.17.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32768 ORDER BY r DESC
+ }
+} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.17.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.18.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-36028797018963968
+ }
+} {-36028797018963968 64 ff80000000000000}
+do_test boundary2-4.18.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ff80000000000000'
+ }
+} {-36028797018963968 64}
+do_test boundary2-4.18.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=64
+ }
+} {-36028797018963968 ff80000000000000}
+do_test boundary2-4.18.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-4.18.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.18.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY r
+ }
+} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.18.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}
+do_test boundary2-4.18.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.18.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.18.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.18.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY r
+ }
+} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.18.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}
+do_test boundary2-4.18.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.18.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY a
+ }
+} {2 55}
+do_test boundary2-4.18.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY a DESC
+ }
+} {55 2}
+do_test boundary2-4.18.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY r
+ }
+} {55 2}
+do_test boundary2-4.18.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY r DESC
+ }
+} {2 55}
+do_test boundary2-4.18.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY x
+ }
+} {55 2}
+do_test boundary2-4.18.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY a
+ }
+} {2 55 64}
+do_test boundary2-4.18.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY a DESC
+ }
+} {64 55 2}
+do_test boundary2-4.18.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY r
+ }
+} {55 2 64}
+do_test boundary2-4.18.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY r DESC
+ }
+} {64 2 55}
+do_test boundary2-4.18.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY x
+ }
+} {55 2 64}
+do_test boundary2-4.19.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=65535
+ }
+} {65535 48 000000000000ffff}
+do_test boundary2-4.19.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000000000000ffff'
+ }
+} {65535 48}
+do_test boundary2-4.19.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=48
+ }
+} {65535 000000000000ffff}
+do_test boundary2-4.19.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65535 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}
+do_test boundary2-4.19.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65535 ORDER BY a DESC
+ }
+} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.19.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65535 ORDER BY r
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.19.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65535 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}
+do_test boundary2-4.19.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 65535 ORDER BY x
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.19.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65535 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}
+do_test boundary2-4.19.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65535 ORDER BY a DESC
+ }
+} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.19.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65535 ORDER BY r
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.19.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65535 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}
+do_test boundary2-4.19.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 65535 ORDER BY x
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.19.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65535 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.19.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65535 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-4.19.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65535 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}
+do_test boundary2-4.19.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65535 ORDER BY r DESC
+ }
+} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.19.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 65535 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.19.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65535 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.19.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65535 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-4.19.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65535 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}
+do_test boundary2-4.19.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65535 ORDER BY r DESC
+ }
+} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.19.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 65535 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.20.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=4294967295
+ }
+} {4294967295 14 00000000ffffffff}
+do_test boundary2-4.20.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00000000ffffffff'
+ }
+} {4294967295 14}
+do_test boundary2-4.20.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=14
+ }
+} {4294967295 00000000ffffffff}
+do_test boundary2-4.20.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967295 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary2-4.20.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967295 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-4.20.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967295 ORDER BY r
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.20.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967295 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}
+do_test boundary2-4.20.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4294967295 ORDER BY x
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.20.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary2-4.20.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary2-4.20.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY r
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.20.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}
+do_test boundary2-4.20.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY x
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.20.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967295 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.20.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967295 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.20.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967295 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}
+do_test boundary2-4.20.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967295 ORDER BY r DESC
+ }
+} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.20.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4294967295 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.20.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.20.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.20.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}
+do_test boundary2-4.20.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY r DESC
+ }
+} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.20.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.21.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=1099511627775
+ }
+} {1099511627775 57 000000ffffffffff}
+do_test boundary2-4.21.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000000ffffffffff'
+ }
+} {1099511627775 57}
+do_test boundary2-4.21.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=57
+ }
+} {1099511627775 000000ffffffffff}
+do_test boundary2-4.21.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}
+do_test boundary2-4.21.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-4.21.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY r
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.21.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}
+do_test boundary2-4.21.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY x
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.21.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}
+do_test boundary2-4.21.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY a DESC
+ }
+} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-4.21.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY r
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.21.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}
+do_test boundary2-4.21.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY x
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.21.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.21.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.21.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}
+do_test boundary2-4.21.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY r DESC
+ }
+} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.21.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.21.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-4.21.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.21.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}
+do_test boundary2-4.21.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY r DESC
+ }
+} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.21.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.22.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-8388608
+ }
+} {-8388608 37 ffffffffff800000}
+do_test boundary2-4.22.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffff800000'
+ }
+} {-8388608 37}
+do_test boundary2-4.22.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=37
+ }
+} {-8388608 ffffffffff800000}
+do_test boundary2-4.22.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388608 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.22.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388608 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.22.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388608 ORDER BY r
+ }
+} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.22.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388608 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}
+do_test boundary2-4.22.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}
+do_test boundary2-4.22.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388608 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.22.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388608 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.22.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388608 ORDER BY r
+ }
+} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.22.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388608 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}
+do_test boundary2-4.22.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}
+do_test boundary2-4.22.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388608 ORDER BY a
+ }
+} {1 2 11 21 44 47 55 58 63 64}
+do_test boundary2-4.22.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388608 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2 1}
+do_test boundary2-4.22.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388608 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary2-4.22.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388608 ORDER BY r DESC
+ }
+} {1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.22.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388608 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary2-4.22.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388608 ORDER BY a
+ }
+} {1 2 11 21 37 44 47 55 58 63 64}
+do_test boundary2-4.22.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388608 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 21 11 2 1}
+do_test boundary2-4.22.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388608 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary2-4.22.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388608 ORDER BY r DESC
+ }
+} {37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.22.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388608 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary2-4.23.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=549755813888
+ }
+} {549755813888 35 0000008000000000}
+do_test boundary2-4.23.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000008000000000'
+ }
+} {549755813888 35}
+do_test boundary2-4.23.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=35
+ }
+} {549755813888 0000008000000000}
+do_test boundary2-4.23.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813888 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}
+do_test boundary2-4.23.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813888 ORDER BY a DESC
+ }
+} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-4.23.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813888 ORDER BY r
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.23.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813888 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}
+do_test boundary2-4.23.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813888 ORDER BY x
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.23.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}
+do_test boundary2-4.23.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY a DESC
+ }
+} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-4.23.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY r
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.23.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}
+do_test boundary2-4.23.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY x
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.23.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813888 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.23.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813888 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.23.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813888 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}
+do_test boundary2-4.23.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813888 ORDER BY r DESC
+ }
+} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.23.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.23.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.23.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.23.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}
+do_test boundary2-4.23.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY r DESC
+ }
+} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.23.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.24.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=8388607
+ }
+} {8388607 18 00000000007fffff}
+do_test boundary2-4.24.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00000000007fffff'
+ }
+} {8388607 18}
+do_test boundary2-4.24.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=18
+ }
+} {8388607 00000000007fffff}
+do_test boundary2-4.24.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388607 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.24.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388607 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary2-4.24.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388607 ORDER BY r
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.24.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388607 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}
+do_test boundary2-4.24.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388607 ORDER BY x
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.24.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388607 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.24.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388607 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary2-4.24.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388607 ORDER BY r
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.24.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388607 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}
+do_test boundary2-4.24.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388607 ORDER BY x
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.24.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388607 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.24.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388607 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary2-4.24.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388607 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}
+do_test boundary2-4.24.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388607 ORDER BY r DESC
+ }
+} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.24.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388607 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.24.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388607 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.24.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388607 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary2-4.24.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388607 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}
+do_test boundary2-4.24.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388607 ORDER BY r DESC
+ }
+} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.24.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388607 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.25.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-3
+ }
+} {-3 52 fffffffffffffffd}
+do_test boundary2-4.25.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='fffffffffffffffd'
+ }
+} {-3 52}
+do_test boundary2-4.25.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=52
+ }
+} {-3 fffffffffffffffd}
+do_test boundary2-4.25.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -3 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-4.25.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -3 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.25.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -3 ORDER BY r
+ }
+} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.25.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -3 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}
+do_test boundary2-4.25.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -3 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}
+do_test boundary2-4.25.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -3 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}
+do_test boundary2-4.25.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -3 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.25.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -3 ORDER BY r
+ }
+} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.25.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -3 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}
+do_test boundary2-4.25.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -3 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}
+do_test boundary2-4.25.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -3 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}
+do_test boundary2-4.25.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -3 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}
+do_test boundary2-4.25.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -3 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary2-4.25.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -3 ORDER BY r DESC
+ }
+} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.25.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -3 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary2-4.25.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -3 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}
+do_test boundary2-4.25.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -3 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}
+do_test boundary2-4.25.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -3 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary2-4.25.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -3 ORDER BY r DESC
+ }
+} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.25.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -3 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary2-4.26.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=0
+ }
+} {0 59 0000000000000000}
+do_test boundary2-4.26.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000000'
+ }
+} {0 59}
+do_test boundary2-4.26.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=59
+ }
+} {0 0000000000000000}
+do_test boundary2-4.26.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 0 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}
+do_test boundary2-4.26.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 0 ORDER BY a DESC
+ }
+} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.26.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 0 ORDER BY r
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.26.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 0 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}
+do_test boundary2-4.26.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 0 ORDER BY x
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.26.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 0 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-4.26.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 0 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.26.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 0 ORDER BY r
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.26.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 0 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}
+do_test boundary2-4.26.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 0 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.26.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 0 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}
+do_test boundary2-4.26.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 0 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-4.26.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 0 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.26.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 0 ORDER BY r DESC
+ }
+} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.26.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 0 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.26.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 0 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}
+do_test boundary2-4.26.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 0 ORDER BY a DESC
+ }
+} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-4.26.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 0 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}
+do_test boundary2-4.26.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 0 ORDER BY r DESC
+ }
+} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.26.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 0 ORDER BY x
+ }
+} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.27.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-1
+ }
+} {-1 38 ffffffffffffffff}
+do_test boundary2-4.27.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffffffffff'
+ }
+} {-1 38}
+do_test boundary2-4.27.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=38
+ }
+} {-1 ffffffffffffffff}
+do_test boundary2-4.27.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-4.27.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -1 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.27.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -1 ORDER BY r
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.27.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -1 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}
+do_test boundary2-4.27.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -1 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.27.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-4.27.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -1 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.27.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -1 ORDER BY r
+ }
+} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.27.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -1 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}
+do_test boundary2-4.27.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -1 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}
+do_test boundary2-4.27.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}
+do_test boundary2-4.27.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -1 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}
+do_test boundary2-4.27.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -1 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary2-4.27.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -1 ORDER BY r DESC
+ }
+} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.27.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -1 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary2-4.27.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}
+do_test boundary2-4.27.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -1 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-4.27.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -1 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.27.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -1 ORDER BY r DESC
+ }
+} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.27.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -1 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.28.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-2
+ }
+} {-2 33 fffffffffffffffe}
+do_test boundary2-4.28.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='fffffffffffffffe'
+ }
+} {-2 33}
+do_test boundary2-4.28.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=33
+ }
+} {-2 fffffffffffffffe}
+do_test boundary2-4.28.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-4.28.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.28.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2 ORDER BY r
+ }
+} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.28.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}
+do_test boundary2-4.28.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}
+do_test boundary2-4.28.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary2-4.28.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.28.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2 ORDER BY r
+ }
+} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.28.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}
+do_test boundary2-4.28.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}
+do_test boundary2-4.28.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}
+do_test boundary2-4.28.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}
+do_test boundary2-4.28.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary2-4.28.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2 ORDER BY r DESC
+ }
+} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.28.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary2-4.28.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}
+do_test boundary2-4.28.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}
+do_test boundary2-4.28.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary2-4.28.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2 ORDER BY r DESC
+ }
+} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.28.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary2-4.29.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=2097152
+ }
+} {2097152 42 0000000000200000}
+do_test boundary2-4.29.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000200000'
+ }
+} {2097152 42}
+do_test boundary2-4.29.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=42
+ }
+} {2097152 0000000000200000}
+do_test boundary2-4.29.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097152 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.29.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097152 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary2-4.29.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097152 ORDER BY r
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.29.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097152 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}
+do_test boundary2-4.29.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097152 ORDER BY x
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.29.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097152 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary2-4.29.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097152 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary2-4.29.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097152 ORDER BY r
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.29.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097152 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}
+do_test boundary2-4.29.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097152 ORDER BY x
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.29.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097152 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.29.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097152 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary2-4.29.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097152 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}
+do_test boundary2-4.29.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097152 ORDER BY r DESC
+ }
+} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.29.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097152 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.29.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097152 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.29.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097152 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary2-4.29.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097152 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}
+do_test boundary2-4.29.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097152 ORDER BY r DESC
+ }
+} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.29.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097152 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.30.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=128
+ }
+} {128 49 0000000000000080}
+do_test boundary2-4.30.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000080'
+ }
+} {128 49}
+do_test boundary2-4.30.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=49
+ }
+} {128 0000000000000080}
+do_test boundary2-4.30.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 128 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary2-4.30.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 128 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-4.30.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 128 ORDER BY r
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.30.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 128 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}
+do_test boundary2-4.30.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 128 ORDER BY x
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.30.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 128 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-4.30.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 128 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-4.30.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 128 ORDER BY r
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.30.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 128 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}
+do_test boundary2-4.30.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 128 ORDER BY x
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.30.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 128 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.30.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 128 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary2-4.30.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 128 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}
+do_test boundary2-4.30.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 128 ORDER BY r DESC
+ }
+} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.30.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 128 ORDER BY x
+ }
+} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.30.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 128 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.30.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 128 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary2-4.30.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 128 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}
+do_test boundary2-4.30.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 128 ORDER BY r DESC
+ }
+} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.30.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 128 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.31.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=255
+ }
+} {255 30 00000000000000ff}
+do_test boundary2-4.31.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00000000000000ff'
+ }
+} {255 30}
+do_test boundary2-4.31.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=30
+ }
+} {255 00000000000000ff}
+do_test boundary2-4.31.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 255 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary2-4.31.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 255 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-4.31.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 255 ORDER BY r
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.31.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 255 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}
+do_test boundary2-4.31.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 255 ORDER BY x
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.31.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 255 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary2-4.31.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 255 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-4.31.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 255 ORDER BY r
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.31.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 255 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}
+do_test boundary2-4.31.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 255 ORDER BY x
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.31.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 255 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.31.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 255 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary2-4.31.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 255 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}
+do_test boundary2-4.31.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 255 ORDER BY r DESC
+ }
+} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.31.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 255 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.31.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 255 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.31.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 255 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary2-4.31.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 255 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}
+do_test boundary2-4.31.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 255 ORDER BY r DESC
+ }
+} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.31.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 255 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.32.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-2147483648
+ }
+} {-2147483648 11 ffffffff80000000}
+do_test boundary2-4.32.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffff80000000'
+ }
+} {-2147483648 11}
+do_test boundary2-4.32.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=11
+ }
+} {-2147483648 ffffffff80000000}
+do_test boundary2-4.32.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483648 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.32.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483648 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.32.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483648 ORDER BY r
+ }
+} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.32.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483648 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}
+do_test boundary2-4.32.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.32.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.32.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.32.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY r
+ }
+} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.32.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}
+do_test boundary2-4.32.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.32.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483648 ORDER BY a
+ }
+} {2 21 44 47 55 58 63 64}
+do_test boundary2-4.32.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483648 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 2}
+do_test boundary2-4.32.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483648 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary2-4.32.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483648 ORDER BY r DESC
+ }
+} {47 63 58 44 21 64 2 55}
+do_test boundary2-4.32.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483648 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary2-4.32.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY a
+ }
+} {2 11 21 44 47 55 58 63 64}
+do_test boundary2-4.32.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2}
+do_test boundary2-4.32.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary2-4.32.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY r DESC
+ }
+} {11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.32.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary2-4.33.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=34359738367
+ }
+} {34359738367 39 00000007ffffffff}
+do_test boundary2-4.33.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00000007ffffffff'
+ }
+} {34359738367 39}
+do_test boundary2-4.33.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=39
+ }
+} {34359738367 00000007ffffffff}
+do_test boundary2-4.33.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738367 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary2-4.33.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738367 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-4.33.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738367 ORDER BY r
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.33.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738367 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}
+do_test boundary2-4.33.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 34359738367 ORDER BY x
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.33.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}
+do_test boundary2-4.33.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary2-4.33.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY r
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.33.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}
+do_test boundary2-4.33.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY x
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.33.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738367 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.33.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738367 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.33.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738367 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}
+do_test boundary2-4.33.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738367 ORDER BY r DESC
+ }
+} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.33.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 34359738367 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.33.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.33.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.33.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}
+do_test boundary2-4.33.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY r DESC
+ }
+} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.33.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.34.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-549755813889
+ }
+} {-549755813889 58 ffffff7fffffffff}
+do_test boundary2-4.34.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffff7fffffffff'
+ }
+} {-549755813889 58}
+do_test boundary2-4.34.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=58
+ }
+} {-549755813889 ffffff7fffffffff}
+do_test boundary2-4.34.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813889 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}
+do_test boundary2-4.34.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813889 ORDER BY a DESC
+ }
+} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.34.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813889 ORDER BY r
+ }
+} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.34.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813889 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}
+do_test boundary2-4.34.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813889 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.34.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary2-4.34.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.34.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY r
+ }
+} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.34.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}
+do_test boundary2-4.34.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.34.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813889 ORDER BY a
+ }
+} {2 21 44 55 64}
+do_test boundary2-4.34.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813889 ORDER BY a DESC
+ }
+} {64 55 44 21 2}
+do_test boundary2-4.34.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813889 ORDER BY r
+ }
+} {55 2 64 21 44}
+do_test boundary2-4.34.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813889 ORDER BY r DESC
+ }
+} {44 21 64 2 55}
+do_test boundary2-4.34.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813889 ORDER BY x
+ }
+} {55 2 64 21 44}
+do_test boundary2-4.34.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY a
+ }
+} {2 21 44 55 58 64}
+do_test boundary2-4.34.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY a DESC
+ }
+} {64 58 55 44 21 2}
+do_test boundary2-4.34.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY r
+ }
+} {55 2 64 21 44 58}
+do_test boundary2-4.34.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY r DESC
+ }
+} {58 44 21 64 2 55}
+do_test boundary2-4.34.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY x
+ }
+} {55 2 64 21 44 58}
+do_test boundary2-4.35.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-32768
+ }
+} {-32768 32 ffffffffffff8000}
+do_test boundary2-4.35.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffffff8000'
+ }
+} {-32768 32}
+do_test boundary2-4.35.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=32
+ }
+} {-32768 ffffffffffff8000}
+do_test boundary2-4.35.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32768 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.35.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32768 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.35.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32768 ORDER BY r
+ }
+} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.35.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32768 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}
+do_test boundary2-4.35.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}
+do_test boundary2-4.35.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32768 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.35.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32768 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.35.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32768 ORDER BY r
+ }
+} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.35.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32768 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}
+do_test boundary2-4.35.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -32768 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}
+do_test boundary2-4.35.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32768 ORDER BY a
+ }
+} {1 2 11 21 29 37 44 47 55 58 63 64}
+do_test boundary2-4.35.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32768 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 29 21 11 2 1}
+do_test boundary2-4.35.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32768 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary2-4.35.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32768 ORDER BY r DESC
+ }
+} {29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.35.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -32768 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary2-4.35.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32768 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 55 58 63 64}
+do_test boundary2-4.35.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32768 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 32 29 21 11 2 1}
+do_test boundary2-4.35.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32768 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary2-4.35.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32768 ORDER BY r DESC
+ }
+} {32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.35.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -32768 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary2-4.36.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=2147483647
+ }
+} {2147483647 20 000000007fffffff}
+do_test boundary2-4.36.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000000007fffffff'
+ }
+} {2147483647 20}
+do_test boundary2-4.36.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=20
+ }
+} {2147483647 000000007fffffff}
+do_test boundary2-4.36.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483647 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary2-4.36.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483647 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary2-4.36.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483647 ORDER BY r
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.36.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483647 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}
+do_test boundary2-4.36.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483647 ORDER BY x
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.36.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary2-4.36.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary2-4.36.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY r
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.36.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}
+do_test boundary2-4.36.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY x
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.36.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483647 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.36.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483647 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.36.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483647 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}
+do_test boundary2-4.36.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483647 ORDER BY r DESC
+ }
+} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.36.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483647 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.36.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.36.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.36.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}
+do_test boundary2-4.36.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY r DESC
+ }
+} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.36.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.37.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-129
+ }
+} {-129 54 ffffffffffffff7f}
+do_test boundary2-4.37.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffffffff7f'
+ }
+} {-129 54}
+do_test boundary2-4.37.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=54
+ }
+} {-129 ffffffffffffff7f}
+do_test boundary2-4.37.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -129 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}
+do_test boundary2-4.37.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -129 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.37.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -129 ORDER BY r
+ }
+} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.37.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -129 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}
+do_test boundary2-4.37.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -129 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}
+do_test boundary2-4.37.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -129 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.37.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -129 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.37.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -129 ORDER BY r
+ }
+} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.37.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -129 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}
+do_test boundary2-4.37.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -129 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}
+do_test boundary2-4.37.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -129 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 55 58 63 64}
+do_test boundary2-4.37.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -129 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 37 32 29 21 11 2 1}
+do_test boundary2-4.37.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -129 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary2-4.37.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -129 ORDER BY r DESC
+ }
+} {32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.37.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -129 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary2-4.37.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -129 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}
+do_test boundary2-4.37.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -129 ORDER BY a DESC
+ }
+} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}
+do_test boundary2-4.37.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -129 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary2-4.37.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -129 ORDER BY r DESC
+ }
+} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.37.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -129 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary2-4.38.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-128
+ }
+} {-128 53 ffffffffffffff80}
+do_test boundary2-4.38.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffffffff80'
+ }
+} {-128 53}
+do_test boundary2-4.38.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=53
+ }
+} {-128 ffffffffffffff80}
+do_test boundary2-4.38.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -128 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}
+do_test boundary2-4.38.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -128 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.38.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -128 ORDER BY r
+ }
+} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.38.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -128 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}
+do_test boundary2-4.38.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -128 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}
+do_test boundary2-4.38.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -128 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}
+do_test boundary2-4.38.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -128 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.38.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -128 ORDER BY r
+ }
+} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.38.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -128 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}
+do_test boundary2-4.38.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -128 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}
+do_test boundary2-4.38.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -128 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}
+do_test boundary2-4.38.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -128 ORDER BY a DESC
+ }
+} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}
+do_test boundary2-4.38.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -128 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary2-4.38.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -128 ORDER BY r DESC
+ }
+} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.38.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -128 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary2-4.38.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -128 ORDER BY a
+ }
+} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}
+do_test boundary2-4.38.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -128 ORDER BY a DESC
+ }
+} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}
+do_test boundary2-4.38.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -128 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary2-4.38.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -128 ORDER BY r DESC
+ }
+} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.38.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -128 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary2-4.39.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=72057594037927936
+ }
+} {72057594037927936 28 0100000000000000}
+do_test boundary2-4.39.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0100000000000000'
+ }
+} {72057594037927936 28}
+do_test boundary2-4.39.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=28
+ }
+} {72057594037927936 0100000000000000}
+do_test boundary2-4.39.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY a
+ }
+} {3}
+do_test boundary2-4.39.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY a DESC
+ }
+} {3}
+do_test boundary2-4.39.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY r
+ }
+} {3}
+do_test boundary2-4.39.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY r DESC
+ }
+} {3}
+do_test boundary2-4.39.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY x
+ }
+} {3}
+do_test boundary2-4.39.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY a
+ }
+} {3 28}
+do_test boundary2-4.39.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY a DESC
+ }
+} {28 3}
+do_test boundary2-4.39.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY r
+ }
+} {28 3}
+do_test boundary2-4.39.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY r DESC
+ }
+} {3 28}
+do_test boundary2-4.39.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY x
+ }
+} {28 3}
+do_test boundary2-4.39.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.39.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.39.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}
+do_test boundary2-4.39.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY r DESC
+ }
+} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.39.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.39.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.39.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.39.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}
+do_test boundary2-4.39.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY r DESC
+ }
+} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.39.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.40.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=2147483648
+ }
+} {2147483648 51 0000000080000000}
+do_test boundary2-4.40.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000080000000'
+ }
+} {2147483648 51}
+do_test boundary2-4.40.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=51
+ }
+} {2147483648 0000000080000000}
+do_test boundary2-4.40.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483648 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary2-4.40.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483648 ORDER BY a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary2-4.40.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483648 ORDER BY r
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.40.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483648 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}
+do_test boundary2-4.40.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2147483648 ORDER BY x
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.40.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary2-4.40.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary2-4.40.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY r
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.40.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}
+do_test boundary2-4.40.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY x
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.40.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483648 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.40.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483648 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.40.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483648 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}
+do_test boundary2-4.40.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483648 ORDER BY r DESC
+ }
+} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.40.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.40.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.40.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.40.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}
+do_test boundary2-4.40.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY r DESC
+ }
+} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.40.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.41.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=549755813887
+ }
+} {549755813887 46 0000007fffffffff}
+do_test boundary2-4.41.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000007fffffffff'
+ }
+} {549755813887 46}
+do_test boundary2-4.41.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=46
+ }
+} {549755813887 0000007fffffffff}
+do_test boundary2-4.41.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813887 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}
+do_test boundary2-4.41.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813887 ORDER BY a DESC
+ }
+} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-4.41.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813887 ORDER BY r
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.41.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813887 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}
+do_test boundary2-4.41.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 549755813887 ORDER BY x
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.41.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary2-4.41.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary2-4.41.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY r
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.41.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}
+do_test boundary2-4.41.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY x
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.41.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813887 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.41.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813887 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.41.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813887 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}
+do_test boundary2-4.41.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813887 ORDER BY r DESC
+ }
+} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.41.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 549755813887 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.41.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.41.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.41.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}
+do_test boundary2-4.41.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY r DESC
+ }
+} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.41.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.42.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-549755813888
+ }
+} {-549755813888 63 ffffff8000000000}
+do_test boundary2-4.42.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffff8000000000'
+ }
+} {-549755813888 63}
+do_test boundary2-4.42.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=63
+ }
+} {-549755813888 ffffff8000000000}
+do_test boundary2-4.42.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813888 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.42.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813888 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.42.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813888 ORDER BY r
+ }
+} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.42.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813888 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}
+do_test boundary2-4.42.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.42.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}
+do_test boundary2-4.42.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY a DESC
+ }
+} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.42.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY r
+ }
+} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.42.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}
+do_test boundary2-4.42.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.42.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813888 ORDER BY a
+ }
+} {2 21 44 55 58 64}
+do_test boundary2-4.42.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813888 ORDER BY a DESC
+ }
+} {64 58 55 44 21 2}
+do_test boundary2-4.42.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813888 ORDER BY r
+ }
+} {55 2 64 21 44 58}
+do_test boundary2-4.42.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813888 ORDER BY r DESC
+ }
+} {58 44 21 64 2 55}
+do_test boundary2-4.42.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -549755813888 ORDER BY x
+ }
+} {55 2 64 21 44 58}
+do_test boundary2-4.42.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY a
+ }
+} {2 21 44 55 58 63 64}
+do_test boundary2-4.42.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY a DESC
+ }
+} {64 63 58 55 44 21 2}
+do_test boundary2-4.42.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY r
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary2-4.42.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY r DESC
+ }
+} {63 58 44 21 64 2 55}
+do_test boundary2-4.42.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY x
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary2-4.43.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=281474976710655
+ }
+} {281474976710655 10 0000ffffffffffff}
+do_test boundary2-4.43.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000ffffffffffff'
+ }
+} {281474976710655 10}
+do_test boundary2-4.43.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=10
+ }
+} {281474976710655 0000ffffffffffff}
+do_test boundary2-4.43.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY a
+ }
+} {3 13 17 26 27 28 43 45}
+do_test boundary2-4.43.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 3}
+do_test boundary2-4.43.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY r
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary2-4.43.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26}
+do_test boundary2-4.43.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY x
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary2-4.43.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 43 45}
+do_test boundary2-4.43.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 10 3}
+do_test boundary2-4.43.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY r
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.43.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10}
+do_test boundary2-4.43.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY x
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.43.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.43.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-4.43.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}
+do_test boundary2-4.43.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY r DESC
+ }
+} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.43.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.43.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.43.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.43.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}
+do_test boundary2-4.43.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY r DESC
+ }
+} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.43.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.44.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=4398046511103
+ }
+} {4398046511103 7 000003ffffffffff}
+do_test boundary2-4.44.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000003ffffffffff'
+ }
+} {4398046511103 7}
+do_test boundary2-4.44.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=7
+ }
+} {4398046511103 000003ffffffffff}
+do_test boundary2-4.44.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary2-4.44.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary2-4.44.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY r
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.44.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56}
+do_test boundary2-4.44.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY x
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.44.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY a
+ }
+} {3 7 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary2-4.44.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 7 3}
+do_test boundary2-4.44.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY r
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.44.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7}
+do_test boundary2-4.44.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY x
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.44.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-4.44.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.44.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}
+do_test boundary2-4.44.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY r DESC
+ }
+} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.44.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.44.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-4.44.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-4.44.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}
+do_test boundary2-4.44.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY r DESC
+ }
+} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.44.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.45.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=268435455
+ }
+} {268435455 12 000000000fffffff}
+do_test boundary2-4.45.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000000000fffffff'
+ }
+} {268435455 12}
+do_test boundary2-4.45.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=12
+ }
+} {268435455 000000000fffffff}
+do_test boundary2-4.45.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435455 ORDER BY a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.45.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435455 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary2-4.45.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435455 ORDER BY r
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.45.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435455 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}
+do_test boundary2-4.45.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 268435455 ORDER BY x
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.45.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435455 ORDER BY a
+ }
+} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.45.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435455 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}
+do_test boundary2-4.45.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435455 ORDER BY r
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.45.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435455 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}
+do_test boundary2-4.45.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 268435455 ORDER BY x
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.45.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435455 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.45.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435455 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}
+do_test boundary2-4.45.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435455 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}
+do_test boundary2-4.45.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435455 ORDER BY r DESC
+ }
+} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.45.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 268435455 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.45.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435455 ORDER BY a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.45.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435455 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary2-4.45.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435455 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}
+do_test boundary2-4.45.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435455 ORDER BY r DESC
+ }
+} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.45.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 268435455 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.46.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-9223372036854775808
+ }
+} {-9223372036854775808 55 8000000000000000}
+do_test boundary2-4.46.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='8000000000000000'
+ }
+} {-9223372036854775808 55}
+do_test boundary2-4.46.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=55
+ }
+} {-9223372036854775808 8000000000000000}
+do_test boundary2-4.46.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.46.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-4.46.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY r
+ }
+} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.46.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}
+do_test boundary2-4.46.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.46.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.46.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-4.46.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.46.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.46.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.46.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY a
+ }
+} {}
+do_test boundary2-4.46.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-4.46.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY r
+ }
+} {}
+do_test boundary2-4.46.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-4.46.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY x
+ }
+} {}
+do_test boundary2-4.46.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY a
+ }
+} {55}
+do_test boundary2-4.46.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY a DESC
+ }
+} {55}
+do_test boundary2-4.46.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY r
+ }
+} {55}
+do_test boundary2-4.46.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY r DESC
+ }
+} {55}
+do_test boundary2-4.46.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY x
+ }
+} {55}
+do_test boundary2-4.47.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=562949953421312
+ }
+} {562949953421312 43 0002000000000000}
+do_test boundary2-4.47.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0002000000000000'
+ }
+} {562949953421312 43}
+do_test boundary2-4.47.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=43
+ }
+} {562949953421312 0002000000000000}
+do_test boundary2-4.47.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY a
+ }
+} {3 17 27 28 45}
+do_test boundary2-4.47.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY a DESC
+ }
+} {45 28 27 17 3}
+do_test boundary2-4.47.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY r
+ }
+} {27 45 17 28 3}
+do_test boundary2-4.47.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY r DESC
+ }
+} {3 28 17 45 27}
+do_test boundary2-4.47.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY x
+ }
+} {27 45 17 28 3}
+do_test boundary2-4.47.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY a
+ }
+} {3 17 27 28 43 45}
+do_test boundary2-4.47.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY a DESC
+ }
+} {45 43 28 27 17 3}
+do_test boundary2-4.47.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY r
+ }
+} {43 27 45 17 28 3}
+do_test boundary2-4.47.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43}
+do_test boundary2-4.47.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY x
+ }
+} {43 27 45 17 28 3}
+do_test boundary2-4.47.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.47.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.47.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}
+do_test boundary2-4.47.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY r DESC
+ }
+} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.47.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.47.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.47.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.47.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}
+do_test boundary2-4.47.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY r DESC
+ }
+} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.47.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.48.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-8388609
+ }
+} {-8388609 1 ffffffffff7fffff}
+do_test boundary2-4.48.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffffff7fffff'
+ }
+} {-8388609 1}
+do_test boundary2-4.48.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=1
+ }
+} {-8388609 ffffffffff7fffff}
+do_test boundary2-4.48.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388609 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.48.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388609 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.48.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388609 ORDER BY r
+ }
+} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.48.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388609 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}
+do_test boundary2-4.48.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -8388609 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}
+do_test boundary2-4.48.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388609 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.48.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388609 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.48.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388609 ORDER BY r
+ }
+} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.48.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388609 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}
+do_test boundary2-4.48.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -8388609 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.48.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388609 ORDER BY a
+ }
+} {2 11 21 44 47 55 58 63 64}
+do_test boundary2-4.48.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388609 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2}
+do_test boundary2-4.48.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388609 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary2-4.48.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388609 ORDER BY r DESC
+ }
+} {11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.48.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -8388609 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary2-4.48.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388609 ORDER BY a
+ }
+} {1 2 11 21 44 47 55 58 63 64}
+do_test boundary2-4.48.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388609 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 11 2 1}
+do_test boundary2-4.48.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388609 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary2-4.48.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388609 ORDER BY r DESC
+ }
+} {1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.48.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -8388609 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary2-4.49.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=16777215
+ }
+} {16777215 9 0000000000ffffff}
+do_test boundary2-4.49.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000ffffff'
+ }
+} {16777215 9}
+do_test boundary2-4.49.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=9
+ }
+} {16777215 0000000000ffffff}
+do_test boundary2-4.49.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777215 ORDER BY a
+ }
+} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.49.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777215 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}
+do_test boundary2-4.49.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777215 ORDER BY r
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.49.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777215 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}
+do_test boundary2-4.49.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16777215 ORDER BY x
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.49.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777215 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.49.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777215 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary2-4.49.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777215 ORDER BY r
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.49.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777215 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}
+do_test boundary2-4.49.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16777215 ORDER BY x
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.49.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777215 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.49.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777215 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary2-4.49.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777215 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}
+do_test boundary2-4.49.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777215 ORDER BY r DESC
+ }
+} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.49.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16777215 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.49.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777215 ORDER BY a
+ }
+} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.49.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777215 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}
+do_test boundary2-4.49.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777215 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}
+do_test boundary2-4.49.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777215 ORDER BY r DESC
+ }
+} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.49.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16777215 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.50.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=8388608
+ }
+} {8388608 24 0000000000800000}
+do_test boundary2-4.50.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000800000'
+ }
+} {8388608 24}
+do_test boundary2-4.50.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=24
+ }
+} {8388608 0000000000800000}
+do_test boundary2-4.50.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388608 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.50.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388608 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary2-4.50.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388608 ORDER BY r
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.50.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388608 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}
+do_test boundary2-4.50.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 8388608 ORDER BY x
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.50.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388608 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary2-4.50.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388608 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary2-4.50.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388608 ORDER BY r
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.50.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388608 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}
+do_test boundary2-4.50.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 8388608 ORDER BY x
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.50.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388608 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.50.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388608 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary2-4.50.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388608 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}
+do_test boundary2-4.50.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388608 ORDER BY r DESC
+ }
+} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.50.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.50.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388608 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.50.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388608 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary2-4.50.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388608 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}
+do_test boundary2-4.50.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388608 ORDER BY r DESC
+ }
+} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.50.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 8388608 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.51.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=16383
+ }
+} {16383 8 0000000000003fff}
+do_test boundary2-4.51.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000003fff'
+ }
+} {16383 8}
+do_test boundary2-4.51.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=8
+ }
+} {16383 0000000000003fff}
+do_test boundary2-4.51.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16383 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-4.51.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16383 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.51.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16383 ORDER BY r
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.51.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16383 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}
+do_test boundary2-4.51.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 16383 ORDER BY x
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.51.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16383 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-4.51.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16383 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-4.51.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16383 ORDER BY r
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.51.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16383 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}
+do_test boundary2-4.51.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 16383 ORDER BY x
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.51.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16383 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.51.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16383 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary2-4.51.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16383 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}
+do_test boundary2-4.51.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16383 ORDER BY r DESC
+ }
+} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.51.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 16383 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.51.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16383 ORDER BY a
+ }
+} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.51.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16383 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}
+do_test boundary2-4.51.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16383 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}
+do_test boundary2-4.51.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16383 ORDER BY r DESC
+ }
+} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.51.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 16383 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.52.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=140737488355328
+ }
+} {140737488355328 34 0000800000000000}
+do_test boundary2-4.52.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000800000000000'
+ }
+} {140737488355328 34}
+do_test boundary2-4.52.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=34
+ }
+} {140737488355328 0000800000000000}
+do_test boundary2-4.52.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 43 45}
+do_test boundary2-4.52.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 10 3}
+do_test boundary2-4.52.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY r
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.52.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10}
+do_test boundary2-4.52.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY x
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.52.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 34 43 45}
+do_test boundary2-4.52.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 17 13 10 3}
+do_test boundary2-4.52.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY r
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.52.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34}
+do_test boundary2-4.52.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY x
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.52.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.52.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-4.52.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}
+do_test boundary2-4.52.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY r DESC
+ }
+} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.52.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.52.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.52.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-4.52.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}
+do_test boundary2-4.52.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY r DESC
+ }
+} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.52.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.53.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=2097151
+ }
+} {2097151 15 00000000001fffff}
+do_test boundary2-4.53.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00000000001fffff'
+ }
+} {2097151 15}
+do_test boundary2-4.53.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=15
+ }
+} {2097151 00000000001fffff}
+do_test boundary2-4.53.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097151 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary2-4.53.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097151 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary2-4.53.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097151 ORDER BY r
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.53.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097151 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}
+do_test boundary2-4.53.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 2097151 ORDER BY x
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.53.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097151 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary2-4.53.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097151 ORDER BY a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.53.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097151 ORDER BY r
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.53.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097151 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}
+do_test boundary2-4.53.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 2097151 ORDER BY x
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.53.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097151 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.53.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097151 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-4.53.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097151 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}
+do_test boundary2-4.53.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097151 ORDER BY r DESC
+ }
+} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.53.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 2097151 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.53.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097151 ORDER BY a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary2-4.53.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097151 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary2-4.53.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097151 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}
+do_test boundary2-4.53.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097151 ORDER BY r DESC
+ }
+} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.53.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 2097151 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.54.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=140737488355327
+ }
+} {140737488355327 25 00007fffffffffff}
+do_test boundary2-4.54.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='00007fffffffffff'
+ }
+} {140737488355327 25}
+do_test boundary2-4.54.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=25
+ }
+} {140737488355327 00007fffffffffff}
+do_test boundary2-4.54.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY a
+ }
+} {3 10 13 17 26 27 28 34 43 45}
+do_test boundary2-4.54.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 17 13 10 3}
+do_test boundary2-4.54.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY r
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.54.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34}
+do_test boundary2-4.54.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY x
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.54.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45}
+do_test boundary2-4.54.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary2-4.54.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY r
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.54.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25}
+do_test boundary2-4.54.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY x
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.54.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.54.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-4.54.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}
+do_test boundary2-4.54.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY r DESC
+ }
+} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.54.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.54.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.54.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-4.54.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}
+do_test boundary2-4.54.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY r DESC
+ }
+} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.54.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.55.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=281474976710656
+ }
+} {281474976710656 26 0001000000000000}
+do_test boundary2-4.55.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0001000000000000'
+ }
+} {281474976710656 26}
+do_test boundary2-4.55.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=26
+ }
+} {281474976710656 0001000000000000}
+do_test boundary2-4.55.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY a
+ }
+} {3 13 17 27 28 43 45}
+do_test boundary2-4.55.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY a DESC
+ }
+} {45 43 28 27 17 13 3}
+do_test boundary2-4.55.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY r
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary2-4.55.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13}
+do_test boundary2-4.55.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY x
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary2-4.55.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY a
+ }
+} {3 13 17 26 27 28 43 45}
+do_test boundary2-4.55.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY a DESC
+ }
+} {45 43 28 27 26 17 13 3}
+do_test boundary2-4.55.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY r
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary2-4.55.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26}
+do_test boundary2-4.55.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY x
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary2-4.55.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.55.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.55.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}
+do_test boundary2-4.55.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY r DESC
+ }
+} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.55.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.55.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.55.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.55.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}
+do_test boundary2-4.55.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY r DESC
+ }
+} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.55.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.56.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=32767
+ }
+} {32767 23 0000000000007fff}
+do_test boundary2-4.56.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000007fff'
+ }
+} {32767 23}
+do_test boundary2-4.56.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=23
+ }
+} {32767 0000000000007fff}
+do_test boundary2-4.56.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32767 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-4.56.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32767 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.56.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32767 ORDER BY r
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.56.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32767 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}
+do_test boundary2-4.56.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 32767 ORDER BY x
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.56.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32767 ORDER BY a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary2-4.56.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32767 ORDER BY a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary2-4.56.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32767 ORDER BY r
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.56.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32767 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}
+do_test boundary2-4.56.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 32767 ORDER BY x
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.56.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32767 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.56.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32767 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}
+do_test boundary2-4.56.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32767 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}
+do_test boundary2-4.56.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32767 ORDER BY r DESC
+ }
+} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.56.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 32767 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.56.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32767 ORDER BY a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary2-4.56.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32767 ORDER BY a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary2-4.56.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32767 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}
+do_test boundary2-4.56.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32767 ORDER BY r DESC
+ }
+} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.56.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 32767 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.57.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=127
+ }
+} {127 4 000000000000007f}
+do_test boundary2-4.57.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='000000000000007f'
+ }
+} {127 4}
+do_test boundary2-4.57.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=4
+ }
+} {127 000000000000007f}
+do_test boundary2-4.57.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 127 ORDER BY a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-4.57.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 127 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary2-4.57.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 127 ORDER BY r
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.57.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 127 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}
+do_test boundary2-4.57.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 127 ORDER BY x
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.57.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 127 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-4.57.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 127 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary2-4.57.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 127 ORDER BY r
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.57.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 127 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}
+do_test boundary2-4.57.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 127 ORDER BY x
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.57.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 127 ORDER BY a
+ }
+} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.57.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 127 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}
+do_test boundary2-4.57.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 127 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}
+do_test boundary2-4.57.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 127 ORDER BY r DESC
+ }
+} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.57.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 127 ORDER BY x
+ }
+} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.57.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 127 ORDER BY a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.57.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 127 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary2-4.57.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 127 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}
+do_test boundary2-4.57.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 127 ORDER BY r DESC
+ }
+} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.57.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 127 ORDER BY x
+ }
+} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.58.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=36028797018963967
+ }
+} {36028797018963967 27 007fffffffffffff}
+do_test boundary2-4.58.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='007fffffffffffff'
+ }
+} {36028797018963967 27}
+do_test boundary2-4.58.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=27
+ }
+} {36028797018963967 007fffffffffffff}
+do_test boundary2-4.58.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY a
+ }
+} {3 17 28 45}
+do_test boundary2-4.58.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY a DESC
+ }
+} {45 28 17 3}
+do_test boundary2-4.58.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY r
+ }
+} {45 17 28 3}
+do_test boundary2-4.58.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY r DESC
+ }
+} {3 28 17 45}
+do_test boundary2-4.58.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY x
+ }
+} {45 17 28 3}
+do_test boundary2-4.58.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY a
+ }
+} {3 17 27 28 45}
+do_test boundary2-4.58.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY a DESC
+ }
+} {45 28 27 17 3}
+do_test boundary2-4.58.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY r
+ }
+} {27 45 17 28 3}
+do_test boundary2-4.58.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY r DESC
+ }
+} {3 28 17 45 27}
+do_test boundary2-4.58.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY x
+ }
+} {27 45 17 28 3}
+do_test boundary2-4.58.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.58.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.58.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}
+do_test boundary2-4.58.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY r DESC
+ }
+} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.58.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.58.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.58.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.58.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}
+do_test boundary2-4.58.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY r DESC
+ }
+} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.58.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.59.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=4398046511104
+ }
+} {4398046511104 56 0000040000000000}
+do_test boundary2-4.59.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000040000000000'
+ }
+} {4398046511104 56}
+do_test boundary2-4.59.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=56
+ }
+} {4398046511104 0000040000000000}
+do_test boundary2-4.59.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45}
+do_test boundary2-4.59.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY a DESC
+ }
+} {45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary2-4.59.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY r
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.59.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25}
+do_test boundary2-4.59.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY x
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.59.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary2-4.59.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary2-4.59.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY r
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.59.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56}
+do_test boundary2-4.59.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY x
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.59.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary2-4.59.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-4.59.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}
+do_test boundary2-4.59.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY r DESC
+ }
+} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.59.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.59.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.59.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary2-4.59.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}
+do_test boundary2-4.59.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY r DESC
+ }
+} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.59.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.60.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=1
+ }
+} {1 60 0000000000000001}
+do_test boundary2-4.60.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000001'
+ }
+} {1 60}
+do_test boundary2-4.60.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=60
+ }
+} {1 0000000000000001}
+do_test boundary2-4.60.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-4.60.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.60.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1 ORDER BY r
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.60.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}
+do_test boundary2-4.60.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 1 ORDER BY x
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.60.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}
+do_test boundary2-4.60.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1 ORDER BY a DESC
+ }
+} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.60.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1 ORDER BY r
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.60.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}
+do_test boundary2-4.60.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 1 ORDER BY x
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.60.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}
+do_test boundary2-4.60.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1 ORDER BY a DESC
+ }
+} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-4.60.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}
+do_test boundary2-4.60.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1 ORDER BY r DESC
+ }
+} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.60.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 1 ORDER BY x
+ }
+} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.60.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.60.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary2-4.60.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}
+do_test boundary2-4.60.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1 ORDER BY r DESC
+ }
+} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.60.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 1 ORDER BY x
+ }
+} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.61.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=36028797018963968
+ }
+} {36028797018963968 45 0080000000000000}
+do_test boundary2-4.61.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0080000000000000'
+ }
+} {36028797018963968 45}
+do_test boundary2-4.61.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=45
+ }
+} {36028797018963968 0080000000000000}
+do_test boundary2-4.61.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY a
+ }
+} {3 17 28}
+do_test boundary2-4.61.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY a DESC
+ }
+} {28 17 3}
+do_test boundary2-4.61.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY r
+ }
+} {17 28 3}
+do_test boundary2-4.61.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY r DESC
+ }
+} {3 28 17}
+do_test boundary2-4.61.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY x
+ }
+} {17 28 3}
+do_test boundary2-4.61.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY a
+ }
+} {3 17 28 45}
+do_test boundary2-4.61.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY a DESC
+ }
+} {45 28 17 3}
+do_test boundary2-4.61.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY r
+ }
+} {45 17 28 3}
+do_test boundary2-4.61.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY r DESC
+ }
+} {3 28 17 45}
+do_test boundary2-4.61.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY x
+ }
+} {45 17 28 3}
+do_test boundary2-4.61.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.61.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.61.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}
+do_test boundary2-4.61.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY r DESC
+ }
+} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.61.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.61.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.61.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary2-4.61.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}
+do_test boundary2-4.61.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY r DESC
+ }
+} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.61.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.62.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-2147483649
+ }
+} {-2147483649 47 ffffffff7fffffff}
+do_test boundary2-4.62.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ffffffff7fffffff'
+ }
+} {-2147483649 47}
+do_test boundary2-4.62.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=47
+ }
+} {-2147483649 ffffffff7fffffff}
+do_test boundary2-4.62.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483649 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.62.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483649 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.62.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483649 ORDER BY r
+ }
+} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.62.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483649 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}
+do_test boundary2-4.62.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -2147483649 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.62.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary2-4.62.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.62.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY r
+ }
+} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.62.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}
+do_test boundary2-4.62.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.62.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483649 ORDER BY a
+ }
+} {2 21 44 55 58 63 64}
+do_test boundary2-4.62.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483649 ORDER BY a DESC
+ }
+} {64 63 58 55 44 21 2}
+do_test boundary2-4.62.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483649 ORDER BY r
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary2-4.62.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483649 ORDER BY r DESC
+ }
+} {63 58 44 21 64 2 55}
+do_test boundary2-4.62.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -2147483649 ORDER BY x
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary2-4.62.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY a
+ }
+} {2 21 44 47 55 58 63 64}
+do_test boundary2-4.62.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY a DESC
+ }
+} {64 63 58 55 47 44 21 2}
+do_test boundary2-4.62.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary2-4.62.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY r DESC
+ }
+} {47 63 58 44 21 64 2 55}
+do_test boundary2-4.62.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary2-4.63.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=-36028797018963969
+ }
+} {-36028797018963969 2 ff7fffffffffffff}
+do_test boundary2-4.63.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='ff7fffffffffffff'
+ }
+} {-36028797018963969 2}
+do_test boundary2-4.63.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=2
+ }
+} {-36028797018963969 ff7fffffffffffff}
+do_test boundary2-4.63.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.63.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary2-4.63.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY r
+ }
+} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.63.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}
+do_test boundary2-4.63.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.63.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.63.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-4.63.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY r
+ }
+} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.63.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}
+do_test boundary2-4.63.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.63.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY a
+ }
+} {55}
+do_test boundary2-4.63.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY a DESC
+ }
+} {55}
+do_test boundary2-4.63.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY r
+ }
+} {55}
+do_test boundary2-4.63.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY r DESC
+ }
+} {55}
+do_test boundary2-4.63.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY x
+ }
+} {55}
+do_test boundary2-4.63.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY a
+ }
+} {2 55}
+do_test boundary2-4.63.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY a DESC
+ }
+} {55 2}
+do_test boundary2-4.63.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY r
+ }
+} {55 2}
+do_test boundary2-4.63.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY r DESC
+ }
+} {2 55}
+do_test boundary2-4.63.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY x
+ }
+} {55 2}
+do_test boundary2-4.64.1 {
+ db eval {
+ SELECT * FROM t1 WHERE r=3
+ }
+} {3 5 0000000000000003}
+do_test boundary2-4.64.2 {
+ db eval {
+ SELECT r, a FROM t1 WHERE x='0000000000000003'
+ }
+} {3 5}
+do_test boundary2-4.64.3 {
+ db eval {
+ SELECT r, x FROM t1 WHERE a=5
+ }
+} {3 0000000000000003}
+do_test boundary2-4.64.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 3 ORDER BY a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-4.64.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 3 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary2-4.64.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 3 ORDER BY r
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.64.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 3 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}
+do_test boundary2-4.64.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 3 ORDER BY x
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.64.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 3 ORDER BY a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary2-4.64.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 3 ORDER BY a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary2-4.64.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 3 ORDER BY r
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.64.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 3 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}
+do_test boundary2-4.64.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 3 ORDER BY x
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.64.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 3 ORDER BY a
+ }
+} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.64.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 3 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}
+do_test boundary2-4.64.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 3 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}
+do_test boundary2-4.64.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 3 ORDER BY r DESC
+ }
+} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.64.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 3 ORDER BY x
+ }
+} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.64.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 3 ORDER BY a
+ }
+} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary2-4.64.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 3 ORDER BY a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}
+do_test boundary2-4.64.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 3 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}
+do_test boundary2-4.64.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 3 ORDER BY r DESC
+ }
+} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.64.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 3 ORDER BY x
+ }
+} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.65.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary2-4.65.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-4.65.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY r
+ }
+} {}
+do_test boundary2-4.65.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-4.65.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+do_test boundary2-4.65.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary2-4.65.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-4.65.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY r
+ }
+} {}
+do_test boundary2-4.65.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-4.65.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+do_test boundary2-4.65.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.65.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-4.65.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.65.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.65.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.65.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.65.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-4.65.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.65.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.65.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.66.gt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.66.gt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-4.66.gt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.66.gt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.66.gt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.66.ge.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary2-4.66.ge.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary2-4.66.ge.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY r
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary2-4.66.ge.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary2-4.66.ge.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary2-4.66.lt.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary2-4.66.lt.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-4.66.lt.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY r
+ }
+} {}
+do_test boundary2-4.66.lt.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-4.66.lt.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+do_test boundary2-4.66.le.1 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY a
+ }
+} {}
+do_test boundary2-4.66.le.2 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY a DESC
+ }
+} {}
+do_test boundary2-4.66.le.3 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY r
+ }
+} {}
+do_test boundary2-4.66.le.4 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY r DESC
+ }
+} {}
+do_test boundary2-4.66.le.5 {
+ db eval {
+ SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY x
+ }
+} {}
+finish_test
diff --git a/test/boundary3.tcl b/test/boundary3.tcl
new file mode 100644
index 0000000..ac3bf0a
--- /dev/null
+++ b/test/boundary3.tcl
@@ -0,0 +1,290 @@
+puts {# 2008 December 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is automatically generated from a separate TCL script.
+# This file seeks to exercise integer boundary values.
+#
+# $Id: boundary3.tcl,v 1.3 2009/01/02 15:45:48 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Many of the boundary tests depend on a working 64-bit implementation.
+if {![working_64bit_int]} { finish_test; return }
+}
+
+expr srand(0)
+
+# Generate interesting boundary numbers
+#
+foreach x {
+ 0
+ 1
+ 0x7f
+ 0x7fff
+ 0x7fffff
+ 0x7fffffff
+ 0x7fffffffff
+ 0x7fffffffffff
+ 0x7fffffffffffff
+ 0x7fffffffffffffff
+} {
+ set x [expr {wide($x)}]
+ set boundarynum($x) 1
+ set boundarynum([expr {$x+1}]) 1
+ set boundarynum([expr {-($x+1)}]) 1
+ set boundarynum([expr {-($x+2)}]) 1
+ set boundarynum([expr {$x+$x+1}]) 1
+ set boundarynum([expr {$x+$x+2}]) 1
+}
+set x [expr {wide(127)}]
+for {set i 1} {$i<=9} {incr i} {
+ set boundarynum($x) 1
+ set boundarynum([expr {$x+1}]) 1
+ set x [expr {wide($x*128 + 127)}]
+}
+
+# Scramble the $inlist into a random order.
+#
+proc scramble {inlist} {
+ set y {}
+ foreach x $inlist {
+ lappend y [list [expr {rand()}] $x]
+ }
+ set y [lsort $y]
+ set outlist {}
+ foreach x $y {
+ lappend outlist [lindex $x 1]
+ }
+ return $outlist
+}
+
+# A simple selection sort. Not trying to be efficient.
+#
+proc sort {inlist} {
+ set outlist {}
+ set mn [lindex $inlist 0]
+ foreach x $inlist {
+ if {$x<$mn} {set mn $x}
+ }
+ set outlist $mn
+ set mx $mn
+ while {1} {
+ set valid 0
+ foreach x $inlist {
+ if {$x>$mx && (!$valid || $mn>$x)} {
+ set mn $x
+ set valid 1
+ }
+ }
+ if {!$valid} break
+ lappend outlist $mn
+ set mx $mn
+ }
+ return $outlist
+}
+
+# Reverse the order of a list
+#
+proc reverse {inlist} {
+ set i [llength $inlist]
+ set outlist {}
+ for {incr i -1} {$i>=0} {incr i -1} {
+ lappend outlist [lindex $inlist $i]
+ }
+ return $outlist
+}
+
+set nums1 [scramble [array names boundarynum]]
+set nums2 [scramble [array names boundarynum]]
+
+set tname boundary3
+puts "do_test $tname-1.1 \173"
+puts " db eval \173"
+puts " CREATE TABLE t1(a,x);"
+set a 0
+foreach r $nums1 {
+ incr a
+ set t1ra($r) $a
+ set t1ar($a) $r
+ set x [format %08x%08x [expr {wide($r)>>32}] $r]
+ set t1rx($r) $x
+ set t1xr($x) $r
+ puts " INSERT INTO t1(oid,a,x) VALUES($r,$a,'$x');"
+}
+puts " CREATE INDEX t1i1 ON t1(a);"
+puts " CREATE INDEX t1i2 ON t1(x);"
+puts " \175"
+puts "\175 {}"
+
+puts "do_test $tname-1.2 \173"
+puts " db eval \173"
+puts " SELECT count(*) FROM t1"
+puts " \175"
+puts "\175 {64}"
+
+puts "do_test $tname-1.3 \173"
+puts " db eval \173"
+puts " CREATE TABLE t2(r,a);"
+puts " INSERT INTO t2 SELECT rowid, a FROM t1;"
+puts " CREATE INDEX t2i1 ON t2(r);"
+puts " CREATE INDEX t2i2 ON t2(a);"
+puts " INSERT INTO t2 VALUES(9.22337303685477580800e+18,65);"
+set t1ra(9.22337303685477580800e+18) 65
+set t1ar(65) 9.22337303685477580800e+18)
+puts " INSERT INTO t2 VALUES(-9.22337303685477580800e+18,66);"
+set t1ra(-9.22337303685477580800e+18) 66
+set t1ar(66) -9.22337303685477580800e+18)
+puts " SELECT count(*) FROM t2;"
+puts " \175"
+puts "\175 {66}"
+
+set nums3 $nums2
+lappend nums3 9.22337303685477580800e+18
+lappend nums3 -9.22337303685477580800e+18
+
+set i 0
+foreach r $nums3 {
+ incr i
+
+ set r5 $r.5
+ set r0 $r.0
+ if {abs($r)<9.22337203685477580800e+18} {
+ set x $t1rx($r)
+ set a $t1ra($r)
+ puts "do_test $tname-2.$i.1 \173"
+ puts " db eval \173"
+ puts " SELECT t1.* FROM t1, t2 WHERE t1.rowid=$r AND t2.a=t1.a"
+ puts " \175"
+ puts "\175 {$a $x}"
+ puts "do_test $tname-2.$i.2 \173"
+ puts " db eval \173"
+ puts " SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='$x'"
+ puts " \175"
+ puts "\175 {$r $a}"
+ puts "do_test $tname-2.$i.3 \173"
+ puts " db eval \173"
+ puts " SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=$a"
+ puts " \175"
+ puts "\175 {$r $x}"
+ }
+
+ foreach op {> >= < <=} subno {gt ge lt le} {
+
+ ################################################################ 2.x.y.1
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r" {
+ lappend rset $rx
+ lappend aset $t1ra($rx)
+ }
+ }
+ puts "do_test $tname-2.$i.$subno.1 \173"
+ puts " db eval \173"
+ puts " SELECT t2.a FROM t1 JOIN t2 USING(a)"
+ puts " WHERE t1.rowid $op $r ORDER BY t2.a"
+ puts " \175"
+ puts "\175 {[sort $aset]}"
+
+ ################################################################ 2.x.y.2
+ puts "do_test $tname-2.$i.$subno.2 \173"
+ puts " db eval \173"
+ puts " SELECT t2.a FROM t2 NATURAL JOIN t1"
+ puts " WHERE t1.rowid $op $r ORDER BY t1.a DESC"
+ puts " \175"
+ puts "\175 {[reverse [sort $aset]]}"
+
+
+ ################################################################ 2.x.y.3
+ set ax $t1ra($r)
+ set aset {}
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.3 \173"
+ puts " db eval \173"
+ puts " SELECT t1.a FROM t1 JOIN t2 ON t1.rowid $op t2.r"
+ puts " WHERE t2.a=$ax"
+ puts " ORDER BY t1.rowid"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.4
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.4 \173"
+ puts " db eval \173"
+ puts " SELECT t1.a FROM t1 JOIN t2 ON t1.rowid $op t2.r"
+ puts " WHERE t2.a=$ax"
+ puts " ORDER BY t1.rowid DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.5
+ set aset {}
+ set xset {}
+ foreach rx $rset {
+ lappend xset $t1rx($rx)
+ }
+ foreach x [sort $xset] {
+ set rx $t1xr($x)
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.5 \173"
+ puts " db eval \173"
+ puts " SELECT t1.a FROM t1 JOIN t2 ON t1.rowid $op t2.r"
+ puts " WHERE t2.a=$ax"
+ puts " ORDER BY x"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.10
+ if {[string length $r5]>15} continue
+ set rset {}
+ set aset {}
+ foreach rx $nums2 {
+ if "\$rx $op \$r0" {
+ lappend rset $rx
+ }
+ }
+ foreach rx [sort $rset] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.10 \173"
+ puts " db eval \173"
+ puts " SELECT t1.a FROM t1 JOIN t2 ON t1.rowid $op CAST(t2.r AS real)"
+ puts " WHERE t2.a=$ax"
+ puts " ORDER BY t1.rowid"
+ puts " \175"
+ puts "\175 {$aset}"
+
+ ################################################################ 2.x.y.11
+ set aset {}
+ foreach rx [reverse [sort $rset]] {
+ lappend aset $t1ra($rx)
+ }
+ puts "do_test $tname-2.$i.$subno.11 \173"
+ puts " db eval \173"
+ puts " SELECT t1.a FROM t1 JOIN t2 ON t1.rowid $op CAST(t2.r AS real)"
+ puts " WHERE t2.a=$ax"
+ puts " ORDER BY t1.rowid DESC"
+ puts " \175"
+ puts "\175 {$aset}"
+ }
+
+}
+
+
+puts {finish_test}
diff --git a/test/boundary3.test b/test/boundary3.test
new file mode 100644
index 0000000..dbe9abf
--- /dev/null
+++ b/test/boundary3.test
@@ -0,0 +1,12456 @@
+# 2008 December 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is automatically generated from a separate TCL script.
+# This file seeks to exercise integer boundary values.
+#
+# $Id: boundary3.test,v 1.2 2009/01/02 15:45:48 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Many of the boundary tests depend on a working 64-bit implementation.
+if {![working_64bit_int]} { finish_test; return }
+
+do_test boundary3-1.1 {
+ db eval {
+ CREATE TABLE t1(a,x);
+ INSERT INTO t1(oid,a,x) VALUES(-8388609,1,'ffffffffff7fffff');
+ INSERT INTO t1(oid,a,x) VALUES(-36028797018963969,2,'ff7fffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(9223372036854775807,3,'7fffffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(127,4,'000000000000007f');
+ INSERT INTO t1(oid,a,x) VALUES(3,5,'0000000000000003');
+ INSERT INTO t1(oid,a,x) VALUES(16777216,6,'0000000001000000');
+ INSERT INTO t1(oid,a,x) VALUES(4398046511103,7,'000003ffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(16383,8,'0000000000003fff');
+ INSERT INTO t1(oid,a,x) VALUES(16777215,9,'0000000000ffffff');
+ INSERT INTO t1(oid,a,x) VALUES(281474976710655,10,'0000ffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-2147483648,11,'ffffffff80000000');
+ INSERT INTO t1(oid,a,x) VALUES(268435455,12,'000000000fffffff');
+ INSERT INTO t1(oid,a,x) VALUES(562949953421311,13,'0001ffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(4294967295,14,'00000000ffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(2097151,15,'00000000001fffff');
+ INSERT INTO t1(oid,a,x) VALUES(16384,16,'0000000000004000');
+ INSERT INTO t1(oid,a,x) VALUES(72057594037927935,17,'00ffffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(8388607,18,'00000000007fffff');
+ INSERT INTO t1(oid,a,x) VALUES(1099511627776,19,'0000010000000000');
+ INSERT INTO t1(oid,a,x) VALUES(2147483647,20,'000000007fffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-140737488355329,21,'ffff7fffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(34359738368,22,'0000000800000000');
+ INSERT INTO t1(oid,a,x) VALUES(32767,23,'0000000000007fff');
+ INSERT INTO t1(oid,a,x) VALUES(8388608,24,'0000000000800000');
+ INSERT INTO t1(oid,a,x) VALUES(140737488355327,25,'00007fffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(281474976710656,26,'0001000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(36028797018963967,27,'007fffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(72057594037927936,28,'0100000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-32769,29,'ffffffffffff7fff');
+ INSERT INTO t1(oid,a,x) VALUES(255,30,'00000000000000ff');
+ INSERT INTO t1(oid,a,x) VALUES(4,31,'0000000000000004');
+ INSERT INTO t1(oid,a,x) VALUES(-32768,32,'ffffffffffff8000');
+ INSERT INTO t1(oid,a,x) VALUES(-2,33,'fffffffffffffffe');
+ INSERT INTO t1(oid,a,x) VALUES(140737488355328,34,'0000800000000000');
+ INSERT INTO t1(oid,a,x) VALUES(549755813888,35,'0000008000000000');
+ INSERT INTO t1(oid,a,x) VALUES(4294967296,36,'0000000100000000');
+ INSERT INTO t1(oid,a,x) VALUES(-8388608,37,'ffffffffff800000');
+ INSERT INTO t1(oid,a,x) VALUES(-1,38,'ffffffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(34359738367,39,'00000007ffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(268435456,40,'0000000010000000');
+ INSERT INTO t1(oid,a,x) VALUES(2,41,'0000000000000002');
+ INSERT INTO t1(oid,a,x) VALUES(2097152,42,'0000000000200000');
+ INSERT INTO t1(oid,a,x) VALUES(562949953421312,43,'0002000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-140737488355328,44,'ffff800000000000');
+ INSERT INTO t1(oid,a,x) VALUES(36028797018963968,45,'0080000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(549755813887,46,'0000007fffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-2147483649,47,'ffffffff7fffffff');
+ INSERT INTO t1(oid,a,x) VALUES(65535,48,'000000000000ffff');
+ INSERT INTO t1(oid,a,x) VALUES(128,49,'0000000000000080');
+ INSERT INTO t1(oid,a,x) VALUES(32768,50,'0000000000008000');
+ INSERT INTO t1(oid,a,x) VALUES(2147483648,51,'0000000080000000');
+ INSERT INTO t1(oid,a,x) VALUES(-3,52,'fffffffffffffffd');
+ INSERT INTO t1(oid,a,x) VALUES(-128,53,'ffffffffffffff80');
+ INSERT INTO t1(oid,a,x) VALUES(-129,54,'ffffffffffffff7f');
+ INSERT INTO t1(oid,a,x) VALUES(-9223372036854775808,55,'8000000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(4398046511104,56,'0000040000000000');
+ INSERT INTO t1(oid,a,x) VALUES(1099511627775,57,'000000ffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-549755813889,58,'ffffff7fffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(0,59,'0000000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(1,60,'0000000000000001');
+ INSERT INTO t1(oid,a,x) VALUES(256,61,'0000000000000100');
+ INSERT INTO t1(oid,a,x) VALUES(65536,62,'0000000000010000');
+ INSERT INTO t1(oid,a,x) VALUES(-549755813888,63,'ffffff8000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-36028797018963968,64,'ff80000000000000');
+ CREATE INDEX t1i1 ON t1(a);
+ CREATE INDEX t1i2 ON t1(x);
+ }
+} {}
+do_test boundary3-1.2 {
+ db eval {
+ SELECT count(*) FROM t1
+ }
+} {64}
+do_test boundary3-1.3 {
+ db eval {
+ CREATE TABLE t2(r,a);
+ INSERT INTO t2 SELECT rowid, a FROM t1;
+ CREATE INDEX t2i1 ON t2(r);
+ CREATE INDEX t2i2 ON t2(a);
+ INSERT INTO t2 VALUES(9.22337303685477580800e+18,65);
+ INSERT INTO t2 VALUES(-9.22337303685477580800e+18,66);
+ SELECT count(*) FROM t2;
+ }
+} {66}
+do_test boundary3-2.1.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=72057594037927935 AND t2.a=t1.a
+ }
+} {17 00ffffffffffffff}
+do_test boundary3-2.1.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00ffffffffffffff'
+ }
+} {72057594037927935 17}
+do_test boundary3-2.1.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=17
+ }
+} {72057594037927935 00ffffffffffffff}
+do_test boundary3-2.1.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 72057594037927935 ORDER BY t2.a
+ }
+} {3 28}
+do_test boundary3-2.1.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 72057594037927935 ORDER BY t1.a DESC
+ }
+} {28 3}
+do_test boundary3-2.1.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=17
+ ORDER BY t1.rowid
+ }
+} {28 3}
+do_test boundary3-2.1.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=17
+ ORDER BY t1.rowid DESC
+ }
+} {3 28}
+do_test boundary3-2.1.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=17
+ ORDER BY x
+ }
+} {28 3}
+do_test boundary3-2.1.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 72057594037927935 ORDER BY t2.a
+ }
+} {3 17 28}
+do_test boundary3-2.1.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 72057594037927935 ORDER BY t1.a DESC
+ }
+} {28 17 3}
+do_test boundary3-2.1.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=17
+ ORDER BY t1.rowid
+ }
+} {17 28 3}
+do_test boundary3-2.1.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=17
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17}
+do_test boundary3-2.1.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=17
+ ORDER BY x
+ }
+} {17 28 3}
+do_test boundary3-2.1.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 72057594037927935 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.1.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 72057594037927935 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.1.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=17
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}
+do_test boundary3-2.1.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=17
+ ORDER BY t1.rowid DESC
+ }
+} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.1.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=17
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.1.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 72057594037927935 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.1.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 72057594037927935 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.1.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=17
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}
+do_test boundary3-2.1.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=17
+ ORDER BY t1.rowid DESC
+ }
+} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.1.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=17
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.2.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=16384 AND t2.a=t1.a
+ }
+} {16 0000000000004000}
+do_test boundary3-2.2.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000004000'
+ }
+} {16384 16}
+do_test boundary3-2.2.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=16
+ }
+} {16384 0000000000004000}
+do_test boundary3-2.2.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 16384 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary3-2.2.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 16384 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.2.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=16
+ ORDER BY t1.rowid
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.2.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=16
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}
+do_test boundary3-2.2.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=16
+ ORDER BY x
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.2.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=16
+ ORDER BY t1.rowid
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.2.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=16
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}
+do_test boundary3-2.2.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 16384 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary3-2.2.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 16384 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.2.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=16
+ ORDER BY t1.rowid
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.2.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=16
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}
+do_test boundary3-2.2.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=16
+ ORDER BY x
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.2.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=16
+ ORDER BY t1.rowid
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.2.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=16
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}
+do_test boundary3-2.2.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 16384 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.2.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 16384 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}
+do_test boundary3-2.2.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=16
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}
+do_test boundary3-2.2.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=16
+ ORDER BY t1.rowid DESC
+ }
+} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.2.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=16
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.2.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=16
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}
+do_test boundary3-2.2.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=16
+ ORDER BY t1.rowid DESC
+ }
+} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.2.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 16384 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.2.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 16384 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}
+do_test boundary3-2.2.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=16
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}
+do_test boundary3-2.2.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=16
+ ORDER BY t1.rowid DESC
+ }
+} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.2.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=16
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.2.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=16
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}
+do_test boundary3-2.2.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=16
+ ORDER BY t1.rowid DESC
+ }
+} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.3.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=4294967296 AND t2.a=t1.a
+ }
+} {36 0000000100000000}
+do_test boundary3-2.3.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000100000000'
+ }
+} {4294967296 36}
+do_test boundary3-2.3.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=36
+ }
+} {4294967296 0000000100000000}
+do_test boundary3-2.3.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 4294967296 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}
+do_test boundary3-2.3.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 4294967296 ORDER BY t1.a DESC
+ }
+} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary3-2.3.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=36
+ ORDER BY t1.rowid
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.3.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=36
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}
+do_test boundary3-2.3.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=36
+ ORDER BY x
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.3.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=36
+ ORDER BY t1.rowid
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.3.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=36
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}
+do_test boundary3-2.3.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 4294967296 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary3-2.3.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 4294967296 ORDER BY t1.a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary3-2.3.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=36
+ ORDER BY t1.rowid
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.3.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=36
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}
+do_test boundary3-2.3.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=36
+ ORDER BY x
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.3.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=36
+ ORDER BY t1.rowid
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.3.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=36
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}
+do_test boundary3-2.3.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 4294967296 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.3.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 4294967296 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.3.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=36
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}
+do_test boundary3-2.3.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=36
+ ORDER BY t1.rowid DESC
+ }
+} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.3.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=36
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.3.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=36
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}
+do_test boundary3-2.3.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=36
+ ORDER BY t1.rowid DESC
+ }
+} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.3.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 4294967296 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.3.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 4294967296 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.3.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=36
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}
+do_test boundary3-2.3.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=36
+ ORDER BY t1.rowid DESC
+ }
+} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.3.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=36
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.3.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=36
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}
+do_test boundary3-2.3.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=36
+ ORDER BY t1.rowid DESC
+ }
+} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.4.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=16777216 AND t2.a=t1.a
+ }
+} {6 0000000001000000}
+do_test boundary3-2.4.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000001000000'
+ }
+} {16777216 6}
+do_test boundary3-2.4.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=6
+ }
+} {16777216 0000000001000000}
+do_test boundary3-2.4.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 16777216 ORDER BY t2.a
+ }
+} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.4.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 16777216 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}
+do_test boundary3-2.4.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=6
+ ORDER BY t1.rowid
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.4.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=6
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}
+do_test boundary3-2.4.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=6
+ ORDER BY x
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.4.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=6
+ ORDER BY t1.rowid
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.4.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=6
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}
+do_test boundary3-2.4.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 16777216 ORDER BY t2.a
+ }
+} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.4.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 16777216 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}
+do_test boundary3-2.4.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=6
+ ORDER BY t1.rowid
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.4.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=6
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}
+do_test boundary3-2.4.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=6
+ ORDER BY x
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.4.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=6
+ ORDER BY t1.rowid
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.4.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=6
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}
+do_test boundary3-2.4.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 16777216 ORDER BY t2.a
+ }
+} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.4.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 16777216 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}
+do_test boundary3-2.4.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=6
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}
+do_test boundary3-2.4.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=6
+ ORDER BY t1.rowid DESC
+ }
+} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.4.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=6
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.4.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=6
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}
+do_test boundary3-2.4.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=6
+ ORDER BY t1.rowid DESC
+ }
+} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.4.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 16777216 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.4.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 16777216 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}
+do_test boundary3-2.4.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=6
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}
+do_test boundary3-2.4.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=6
+ ORDER BY t1.rowid DESC
+ }
+} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.4.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=6
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.4.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=6
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}
+do_test boundary3-2.4.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=6
+ ORDER BY t1.rowid DESC
+ }
+} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.5.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-32769 AND t2.a=t1.a
+ }
+} {29 ffffffffffff7fff}
+do_test boundary3-2.5.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffffff7fff'
+ }
+} {-32769 29}
+do_test boundary3-2.5.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=29
+ }
+} {-32769 ffffffffffff7fff}
+do_test boundary3-2.5.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -32769 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.5.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -32769 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.5.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=29
+ ORDER BY t1.rowid
+ }
+} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.5.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=29
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}
+do_test boundary3-2.5.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=29
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}
+do_test boundary3-2.5.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=29
+ ORDER BY t1.rowid
+ }
+} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.5.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=29
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}
+do_test boundary3-2.5.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -32769 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.5.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -32769 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.5.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=29
+ ORDER BY t1.rowid
+ }
+} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.5.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=29
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}
+do_test boundary3-2.5.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=29
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}
+do_test boundary3-2.5.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=29
+ ORDER BY t1.rowid
+ }
+} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.5.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=29
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}
+do_test boundary3-2.5.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -32769 ORDER BY t2.a
+ }
+} {1 2 11 21 37 44 47 55 58 63 64}
+do_test boundary3-2.5.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -32769 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 37 21 11 2 1}
+do_test boundary3-2.5.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=29
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary3-2.5.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=29
+ ORDER BY t1.rowid DESC
+ }
+} {37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.5.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=29
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary3-2.5.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=29
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary3-2.5.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=29
+ ORDER BY t1.rowid DESC
+ }
+} {37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.5.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -32769 ORDER BY t2.a
+ }
+} {1 2 11 21 29 37 44 47 55 58 63 64}
+do_test boundary3-2.5.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -32769 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 37 29 21 11 2 1}
+do_test boundary3-2.5.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=29
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary3-2.5.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=29
+ ORDER BY t1.rowid DESC
+ }
+} {29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.5.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=29
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary3-2.5.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=29
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary3-2.5.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=29
+ ORDER BY t1.rowid DESC
+ }
+} {29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.6.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-140737488355329 AND t2.a=t1.a
+ }
+} {21 ffff7fffffffffff}
+do_test boundary3-2.6.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffff7fffffffffff'
+ }
+} {-140737488355329 21}
+do_test boundary3-2.6.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=21
+ }
+} {-140737488355329 ffff7fffffffffff}
+do_test boundary3-2.6.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -140737488355329 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary3-2.6.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -140737488355329 ORDER BY t1.a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.6.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=21
+ ORDER BY t1.rowid
+ }
+} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.6.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=21
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}
+do_test boundary3-2.6.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=21
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.6.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -140737488355329 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary3-2.6.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -140737488355329 ORDER BY t1.a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.6.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=21
+ ORDER BY t1.rowid
+ }
+} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.6.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=21
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}
+do_test boundary3-2.6.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=21
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.6.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -140737488355329 ORDER BY t2.a
+ }
+} {2 55 64}
+do_test boundary3-2.6.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -140737488355329 ORDER BY t1.a DESC
+ }
+} {64 55 2}
+do_test boundary3-2.6.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=21
+ ORDER BY t1.rowid
+ }
+} {55 2 64}
+do_test boundary3-2.6.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=21
+ ORDER BY t1.rowid DESC
+ }
+} {64 2 55}
+do_test boundary3-2.6.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=21
+ ORDER BY x
+ }
+} {55 2 64}
+do_test boundary3-2.6.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -140737488355329 ORDER BY t2.a
+ }
+} {2 21 55 64}
+do_test boundary3-2.6.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -140737488355329 ORDER BY t1.a DESC
+ }
+} {64 55 21 2}
+do_test boundary3-2.6.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=21
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21}
+do_test boundary3-2.6.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=21
+ ORDER BY t1.rowid DESC
+ }
+} {21 64 2 55}
+do_test boundary3-2.6.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=21
+ ORDER BY x
+ }
+} {55 2 64 21}
+do_test boundary3-2.7.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=2 AND t2.a=t1.a
+ }
+} {41 0000000000000002}
+do_test boundary3-2.7.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000002'
+ }
+} {2 41}
+do_test boundary3-2.7.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=41
+ }
+} {2 0000000000000002}
+do_test boundary3-2.7.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 2 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary3-2.7.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 2 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.7.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=41
+ ORDER BY t1.rowid
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.7.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=41
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}
+do_test boundary3-2.7.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=41
+ ORDER BY x
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.7.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=41
+ ORDER BY t1.rowid
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.7.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=41
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}
+do_test boundary3-2.7.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 2 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary3-2.7.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 2 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.7.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=41
+ ORDER BY t1.rowid
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.7.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=41
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}
+do_test boundary3-2.7.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=41
+ ORDER BY x
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.7.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=41
+ ORDER BY t1.rowid
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.7.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=41
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}
+do_test boundary3-2.7.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 2 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.7.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 2 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary3-2.7.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=41
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}
+do_test boundary3-2.7.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=41
+ ORDER BY t1.rowid DESC
+ }
+} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.7.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=41
+ ORDER BY x
+ }
+} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.7.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=41
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}
+do_test boundary3-2.7.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=41
+ ORDER BY t1.rowid DESC
+ }
+} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.7.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 2 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.7.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 2 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}
+do_test boundary3-2.7.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=41
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}
+do_test boundary3-2.7.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=41
+ ORDER BY t1.rowid DESC
+ }
+} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.7.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=41
+ ORDER BY x
+ }
+} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.7.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=41
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}
+do_test boundary3-2.7.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=41
+ ORDER BY t1.rowid DESC
+ }
+} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.8.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=4 AND t2.a=t1.a
+ }
+} {31 0000000000000004}
+do_test boundary3-2.8.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000004'
+ }
+} {4 31}
+do_test boundary3-2.8.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=31
+ }
+} {4 0000000000000004}
+do_test boundary3-2.8.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 4 ORDER BY t2.a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary3-2.8.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 4 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary3-2.8.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=31
+ ORDER BY t1.rowid
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.8.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=31
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}
+do_test boundary3-2.8.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=31
+ ORDER BY x
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.8.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=31
+ ORDER BY t1.rowid
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.8.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=31
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}
+do_test boundary3-2.8.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 4 ORDER BY t2.a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary3-2.8.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 4 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary3-2.8.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=31
+ ORDER BY t1.rowid
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.8.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=31
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}
+do_test boundary3-2.8.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=31
+ ORDER BY x
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.8.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=31
+ ORDER BY t1.rowid
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.8.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=31
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}
+do_test boundary3-2.8.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 4 ORDER BY t2.a
+ }
+} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.8.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 4 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}
+do_test boundary3-2.8.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=31
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}
+do_test boundary3-2.8.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=31
+ ORDER BY t1.rowid DESC
+ }
+} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.8.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=31
+ ORDER BY x
+ }
+} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.8.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=31
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}
+do_test boundary3-2.8.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=31
+ ORDER BY t1.rowid DESC
+ }
+} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.8.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 4 ORDER BY t2.a
+ }
+} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.8.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 4 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}
+do_test boundary3-2.8.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=31
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}
+do_test boundary3-2.8.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=31
+ ORDER BY t1.rowid DESC
+ }
+} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.8.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=31
+ ORDER BY x
+ }
+} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.8.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=31
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}
+do_test boundary3-2.8.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=31
+ ORDER BY t1.rowid DESC
+ }
+} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.9.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=562949953421311 AND t2.a=t1.a
+ }
+} {13 0001ffffffffffff}
+do_test boundary3-2.9.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0001ffffffffffff'
+ }
+} {562949953421311 13}
+do_test boundary3-2.9.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=13
+ }
+} {562949953421311 0001ffffffffffff}
+do_test boundary3-2.9.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 562949953421311 ORDER BY t2.a
+ }
+} {3 17 27 28 43 45}
+do_test boundary3-2.9.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 562949953421311 ORDER BY t1.a DESC
+ }
+} {45 43 28 27 17 3}
+do_test boundary3-2.9.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=13
+ ORDER BY t1.rowid
+ }
+} {43 27 45 17 28 3}
+do_test boundary3-2.9.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=13
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43}
+do_test boundary3-2.9.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=13
+ ORDER BY x
+ }
+} {43 27 45 17 28 3}
+do_test boundary3-2.9.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 562949953421311 ORDER BY t2.a
+ }
+} {3 13 17 27 28 43 45}
+do_test boundary3-2.9.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 562949953421311 ORDER BY t1.a DESC
+ }
+} {45 43 28 27 17 13 3}
+do_test boundary3-2.9.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=13
+ ORDER BY t1.rowid
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary3-2.9.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=13
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13}
+do_test boundary3-2.9.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=13
+ ORDER BY x
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary3-2.9.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 562949953421311 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.9.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 562949953421311 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.9.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=13
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}
+do_test boundary3-2.9.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=13
+ ORDER BY t1.rowid DESC
+ }
+} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.9.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=13
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.9.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 562949953421311 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.9.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 562949953421311 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.9.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=13
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}
+do_test boundary3-2.9.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=13
+ ORDER BY t1.rowid DESC
+ }
+} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.9.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=13
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.10.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=256 AND t2.a=t1.a
+ }
+} {61 0000000000000100}
+do_test boundary3-2.10.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000100'
+ }
+} {256 61}
+do_test boundary3-2.10.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=61
+ }
+} {256 0000000000000100}
+do_test boundary3-2.10.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 256 ORDER BY t2.a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary3-2.10.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 256 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary3-2.10.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=61
+ ORDER BY t1.rowid
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.10.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=61
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}
+do_test boundary3-2.10.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=61
+ ORDER BY x
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.10.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=61
+ ORDER BY t1.rowid
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.10.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=61
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}
+do_test boundary3-2.10.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 256 ORDER BY t2.a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary3-2.10.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 256 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary3-2.10.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=61
+ ORDER BY t1.rowid
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.10.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=61
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}
+do_test boundary3-2.10.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=61
+ ORDER BY x
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.10.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=61
+ ORDER BY t1.rowid
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.10.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=61
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}
+do_test boundary3-2.10.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 256 ORDER BY t2.a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.10.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 256 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary3-2.10.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=61
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}
+do_test boundary3-2.10.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=61
+ ORDER BY t1.rowid DESC
+ }
+} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.10.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=61
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.10.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=61
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}
+do_test boundary3-2.10.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=61
+ ORDER BY t1.rowid DESC
+ }
+} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.10.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 256 ORDER BY t2.a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.10.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 256 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary3-2.10.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=61
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}
+do_test boundary3-2.10.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=61
+ ORDER BY t1.rowid DESC
+ }
+} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.10.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=61
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.10.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=61
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}
+do_test boundary3-2.10.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=61
+ ORDER BY t1.rowid DESC
+ }
+} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.11.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=34359738368 AND t2.a=t1.a
+ }
+} {22 0000000800000000}
+do_test boundary3-2.11.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000800000000'
+ }
+} {34359738368 22}
+do_test boundary3-2.11.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=22
+ }
+} {34359738368 0000000800000000}
+do_test boundary3-2.11.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 34359738368 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary3-2.11.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 34359738368 ORDER BY t1.a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary3-2.11.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=22
+ ORDER BY t1.rowid
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.11.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=22
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}
+do_test boundary3-2.11.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=22
+ ORDER BY x
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.11.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=22
+ ORDER BY t1.rowid
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.11.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=22
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}
+do_test boundary3-2.11.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 34359738368 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary3-2.11.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 34359738368 ORDER BY t1.a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary3-2.11.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=22
+ ORDER BY t1.rowid
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.11.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=22
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}
+do_test boundary3-2.11.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=22
+ ORDER BY x
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.11.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=22
+ ORDER BY t1.rowid
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.11.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=22
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}
+do_test boundary3-2.11.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 34359738368 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.11.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 34359738368 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.11.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=22
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}
+do_test boundary3-2.11.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=22
+ ORDER BY t1.rowid DESC
+ }
+} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.11.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=22
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.11.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=22
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}
+do_test boundary3-2.11.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=22
+ ORDER BY t1.rowid DESC
+ }
+} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.11.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 34359738368 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.11.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 34359738368 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.11.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=22
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}
+do_test boundary3-2.11.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=22
+ ORDER BY t1.rowid DESC
+ }
+} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.11.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=22
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.11.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=22
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}
+do_test boundary3-2.11.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=22
+ ORDER BY t1.rowid DESC
+ }
+} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.12.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=65536 AND t2.a=t1.a
+ }
+} {62 0000000000010000}
+do_test boundary3-2.12.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000010000'
+ }
+} {65536 62}
+do_test boundary3-2.12.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=62
+ }
+} {65536 0000000000010000}
+do_test boundary3-2.12.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 65536 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary3-2.12.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 65536 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.12.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=62
+ ORDER BY t1.rowid
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.12.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=62
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}
+do_test boundary3-2.12.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=62
+ ORDER BY x
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.12.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=62
+ ORDER BY t1.rowid
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.12.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=62
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}
+do_test boundary3-2.12.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 65536 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}
+do_test boundary3-2.12.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 65536 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.12.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=62
+ ORDER BY t1.rowid
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.12.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=62
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}
+do_test boundary3-2.12.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=62
+ ORDER BY x
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.12.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=62
+ ORDER BY t1.rowid
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.12.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=62
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}
+do_test boundary3-2.12.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 65536 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.12.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 65536 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary3-2.12.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=62
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}
+do_test boundary3-2.12.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=62
+ ORDER BY t1.rowid DESC
+ }
+} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.12.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=62
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.12.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=62
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}
+do_test boundary3-2.12.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=62
+ ORDER BY t1.rowid DESC
+ }
+} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.12.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 65536 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.12.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 65536 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary3-2.12.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=62
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}
+do_test boundary3-2.12.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=62
+ ORDER BY t1.rowid DESC
+ }
+} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.12.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=62
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.12.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=62
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}
+do_test boundary3-2.12.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=62
+ ORDER BY t1.rowid DESC
+ }
+} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.13.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=268435456 AND t2.a=t1.a
+ }
+} {40 0000000010000000}
+do_test boundary3-2.13.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000010000000'
+ }
+} {268435456 40}
+do_test boundary3-2.13.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=40
+ }
+} {268435456 0000000010000000}
+do_test boundary3-2.13.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 268435456 ORDER BY t2.a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary3-2.13.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 268435456 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary3-2.13.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=40
+ ORDER BY t1.rowid
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.13.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=40
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}
+do_test boundary3-2.13.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=40
+ ORDER BY x
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.13.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=40
+ ORDER BY t1.rowid
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.13.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=40
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}
+do_test boundary3-2.13.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 268435456 ORDER BY t2.a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.13.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 268435456 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary3-2.13.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=40
+ ORDER BY t1.rowid
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.13.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=40
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}
+do_test boundary3-2.13.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=40
+ ORDER BY x
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.13.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=40
+ ORDER BY t1.rowid
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.13.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=40
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}
+do_test boundary3-2.13.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 268435456 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.13.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 268435456 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.13.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=40
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}
+do_test boundary3-2.13.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=40
+ ORDER BY t1.rowid DESC
+ }
+} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.13.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=40
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.13.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=40
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}
+do_test boundary3-2.13.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=40
+ ORDER BY t1.rowid DESC
+ }
+} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.13.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 268435456 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.13.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 268435456 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.13.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=40
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}
+do_test boundary3-2.13.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=40
+ ORDER BY t1.rowid DESC
+ }
+} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.13.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=40
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.13.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=40
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}
+do_test boundary3-2.13.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=40
+ ORDER BY t1.rowid DESC
+ }
+} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.14.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-140737488355328 AND t2.a=t1.a
+ }
+} {44 ffff800000000000}
+do_test boundary3-2.14.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffff800000000000'
+ }
+} {-140737488355328 44}
+do_test boundary3-2.14.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=44
+ }
+} {-140737488355328 ffff800000000000}
+do_test boundary3-2.14.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -140737488355328 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary3-2.14.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -140737488355328 ORDER BY t1.a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.14.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=44
+ ORDER BY t1.rowid
+ }
+} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.14.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=44
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}
+do_test boundary3-2.14.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=44
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.14.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -140737488355328 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary3-2.14.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -140737488355328 ORDER BY t1.a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.14.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=44
+ ORDER BY t1.rowid
+ }
+} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.14.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=44
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}
+do_test boundary3-2.14.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=44
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.14.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -140737488355328 ORDER BY t2.a
+ }
+} {2 21 55 64}
+do_test boundary3-2.14.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -140737488355328 ORDER BY t1.a DESC
+ }
+} {64 55 21 2}
+do_test boundary3-2.14.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=44
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21}
+do_test boundary3-2.14.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=44
+ ORDER BY t1.rowid DESC
+ }
+} {21 64 2 55}
+do_test boundary3-2.14.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=44
+ ORDER BY x
+ }
+} {55 2 64 21}
+do_test boundary3-2.14.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -140737488355328 ORDER BY t2.a
+ }
+} {2 21 44 55 64}
+do_test boundary3-2.14.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -140737488355328 ORDER BY t1.a DESC
+ }
+} {64 55 44 21 2}
+do_test boundary3-2.14.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=44
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44}
+do_test boundary3-2.14.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=44
+ ORDER BY t1.rowid DESC
+ }
+} {44 21 64 2 55}
+do_test boundary3-2.14.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=44
+ ORDER BY x
+ }
+} {55 2 64 21 44}
+do_test boundary3-2.15.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=1099511627776 AND t2.a=t1.a
+ }
+} {19 0000010000000000}
+do_test boundary3-2.15.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000010000000000'
+ }
+} {1099511627776 19}
+do_test boundary3-2.15.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=19
+ }
+} {1099511627776 0000010000000000}
+do_test boundary3-2.15.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 1099511627776 ORDER BY t2.a
+ }
+} {3 7 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary3-2.15.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 1099511627776 ORDER BY t1.a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 7 3}
+do_test boundary3-2.15.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=19
+ ORDER BY t1.rowid
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.15.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=19
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7}
+do_test boundary3-2.15.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=19
+ ORDER BY x
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.15.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=19
+ ORDER BY t1.rowid
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.15.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=19
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7}
+do_test boundary3-2.15.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 1099511627776 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}
+do_test boundary3-2.15.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 1099511627776 ORDER BY t1.a DESC
+ }
+} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary3-2.15.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=19
+ ORDER BY t1.rowid
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.15.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=19
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}
+do_test boundary3-2.15.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=19
+ ORDER BY x
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.15.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=19
+ ORDER BY t1.rowid
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.15.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=19
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}
+do_test boundary3-2.15.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 1099511627776 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary3-2.15.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 1099511627776 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.15.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=19
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}
+do_test boundary3-2.15.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=19
+ ORDER BY t1.rowid DESC
+ }
+} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.15.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=19
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.15.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=19
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}
+do_test boundary3-2.15.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=19
+ ORDER BY t1.rowid DESC
+ }
+} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.15.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 1099511627776 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary3-2.15.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 1099511627776 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.15.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=19
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}
+do_test boundary3-2.15.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=19
+ ORDER BY t1.rowid DESC
+ }
+} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.15.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=19
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.15.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=19
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}
+do_test boundary3-2.15.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=19
+ ORDER BY t1.rowid DESC
+ }
+} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.16.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 9223372036854775807 ORDER BY t2.a
+ }
+} {}
+do_test boundary3-2.16.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 9223372036854775807 ORDER BY t1.a DESC
+ }
+} {}
+do_test boundary3-2.16.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=3
+ ORDER BY t1.rowid
+ }
+} {}
+do_test boundary3-2.16.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=3
+ ORDER BY t1.rowid DESC
+ }
+} {}
+do_test boundary3-2.16.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=3
+ ORDER BY x
+ }
+} {}
+do_test boundary3-2.16.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 9223372036854775807 ORDER BY t2.a
+ }
+} {3}
+do_test boundary3-2.16.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 9223372036854775807 ORDER BY t1.a DESC
+ }
+} {3}
+do_test boundary3-2.16.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=3
+ ORDER BY t1.rowid
+ }
+} {3}
+do_test boundary3-2.16.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=3
+ ORDER BY t1.rowid DESC
+ }
+} {3}
+do_test boundary3-2.16.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=3
+ ORDER BY x
+ }
+} {3}
+do_test boundary3-2.16.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 9223372036854775807 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.16.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 9223372036854775807 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.16.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=3
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}
+do_test boundary3-2.16.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=3
+ ORDER BY t1.rowid DESC
+ }
+} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.16.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=3
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.16.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 9223372036854775807 ORDER BY t2.a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.16.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 9223372036854775807 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary3-2.16.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=3
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.16.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=3
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.16.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=3
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.17.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=32768 AND t2.a=t1.a
+ }
+} {50 0000000000008000}
+do_test boundary3-2.17.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000008000'
+ }
+} {32768 50}
+do_test boundary3-2.17.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=50
+ }
+} {32768 0000000000008000}
+do_test boundary3-2.17.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 32768 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}
+do_test boundary3-2.17.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 32768 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.17.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=50
+ ORDER BY t1.rowid
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.17.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=50
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}
+do_test boundary3-2.17.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=50
+ ORDER BY x
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.17.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=50
+ ORDER BY t1.rowid
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.17.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=50
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}
+do_test boundary3-2.17.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 32768 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary3-2.17.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 32768 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.17.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=50
+ ORDER BY t1.rowid
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.17.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=50
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}
+do_test boundary3-2.17.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=50
+ ORDER BY x
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.17.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=50
+ ORDER BY t1.rowid
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.17.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=50
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}
+do_test boundary3-2.17.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 32768 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.17.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 32768 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary3-2.17.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=50
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}
+do_test boundary3-2.17.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=50
+ ORDER BY t1.rowid DESC
+ }
+} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.17.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=50
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.17.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=50
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}
+do_test boundary3-2.17.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=50
+ ORDER BY t1.rowid DESC
+ }
+} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.17.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 32768 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.17.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 32768 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary3-2.17.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=50
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}
+do_test boundary3-2.17.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=50
+ ORDER BY t1.rowid DESC
+ }
+} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.17.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=50
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.17.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=50
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}
+do_test boundary3-2.17.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=50
+ ORDER BY t1.rowid DESC
+ }
+} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.18.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-36028797018963968 AND t2.a=t1.a
+ }
+} {64 ff80000000000000}
+do_test boundary3-2.18.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ff80000000000000'
+ }
+} {-36028797018963968 64}
+do_test boundary3-2.18.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=64
+ }
+} {-36028797018963968 ff80000000000000}
+do_test boundary3-2.18.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -36028797018963968 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary3-2.18.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -36028797018963968 ORDER BY t1.a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.18.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=64
+ ORDER BY t1.rowid
+ }
+} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.18.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=64
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}
+do_test boundary3-2.18.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=64
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.18.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -36028797018963968 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.18.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -36028797018963968 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.18.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=64
+ ORDER BY t1.rowid
+ }
+} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.18.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=64
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}
+do_test boundary3-2.18.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=64
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.18.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -36028797018963968 ORDER BY t2.a
+ }
+} {2 55}
+do_test boundary3-2.18.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -36028797018963968 ORDER BY t1.a DESC
+ }
+} {55 2}
+do_test boundary3-2.18.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=64
+ ORDER BY t1.rowid
+ }
+} {55 2}
+do_test boundary3-2.18.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=64
+ ORDER BY t1.rowid DESC
+ }
+} {2 55}
+do_test boundary3-2.18.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=64
+ ORDER BY x
+ }
+} {55 2}
+do_test boundary3-2.18.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -36028797018963968 ORDER BY t2.a
+ }
+} {2 55 64}
+do_test boundary3-2.18.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -36028797018963968 ORDER BY t1.a DESC
+ }
+} {64 55 2}
+do_test boundary3-2.18.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=64
+ ORDER BY t1.rowid
+ }
+} {55 2 64}
+do_test boundary3-2.18.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=64
+ ORDER BY t1.rowid DESC
+ }
+} {64 2 55}
+do_test boundary3-2.18.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=64
+ ORDER BY x
+ }
+} {55 2 64}
+do_test boundary3-2.19.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=65535 AND t2.a=t1.a
+ }
+} {48 000000000000ffff}
+do_test boundary3-2.19.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000000000000ffff'
+ }
+} {65535 48}
+do_test boundary3-2.19.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=48
+ }
+} {65535 000000000000ffff}
+do_test boundary3-2.19.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 65535 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}
+do_test boundary3-2.19.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 65535 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.19.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=48
+ ORDER BY t1.rowid
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.19.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=48
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}
+do_test boundary3-2.19.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=48
+ ORDER BY x
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.19.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=48
+ ORDER BY t1.rowid
+ }
+} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.19.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=48
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}
+do_test boundary3-2.19.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 65535 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}
+do_test boundary3-2.19.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 65535 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.19.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=48
+ ORDER BY t1.rowid
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.19.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=48
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}
+do_test boundary3-2.19.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=48
+ ORDER BY x
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.19.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=48
+ ORDER BY t1.rowid
+ }
+} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.19.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=48
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}
+do_test boundary3-2.19.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 65535 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.19.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 65535 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary3-2.19.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=48
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}
+do_test boundary3-2.19.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=48
+ ORDER BY t1.rowid DESC
+ }
+} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.19.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=48
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.19.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=48
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}
+do_test boundary3-2.19.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=48
+ ORDER BY t1.rowid DESC
+ }
+} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.19.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 65535 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.19.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 65535 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary3-2.19.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=48
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}
+do_test boundary3-2.19.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=48
+ ORDER BY t1.rowid DESC
+ }
+} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.19.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=48
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.19.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=48
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}
+do_test boundary3-2.19.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=48
+ ORDER BY t1.rowid DESC
+ }
+} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.20.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=4294967295 AND t2.a=t1.a
+ }
+} {14 00000000ffffffff}
+do_test boundary3-2.20.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00000000ffffffff'
+ }
+} {4294967295 14}
+do_test boundary3-2.20.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=14
+ }
+} {4294967295 00000000ffffffff}
+do_test boundary3-2.20.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 4294967295 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary3-2.20.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 4294967295 ORDER BY t1.a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary3-2.20.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=14
+ ORDER BY t1.rowid
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.20.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=14
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}
+do_test boundary3-2.20.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=14
+ ORDER BY x
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.20.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=14
+ ORDER BY t1.rowid
+ }
+} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.20.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=14
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}
+do_test boundary3-2.20.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 4294967295 ORDER BY t2.a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary3-2.20.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 4294967295 ORDER BY t1.a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary3-2.20.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=14
+ ORDER BY t1.rowid
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.20.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=14
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}
+do_test boundary3-2.20.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=14
+ ORDER BY x
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.20.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=14
+ ORDER BY t1.rowid
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.20.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=14
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}
+do_test boundary3-2.20.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 4294967295 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.20.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 4294967295 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.20.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=14
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}
+do_test boundary3-2.20.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=14
+ ORDER BY t1.rowid DESC
+ }
+} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.20.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=14
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.20.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=14
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}
+do_test boundary3-2.20.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=14
+ ORDER BY t1.rowid DESC
+ }
+} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.20.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 4294967295 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.20.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 4294967295 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.20.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=14
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}
+do_test boundary3-2.20.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=14
+ ORDER BY t1.rowid DESC
+ }
+} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.20.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=14
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.20.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=14
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}
+do_test boundary3-2.20.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=14
+ ORDER BY t1.rowid DESC
+ }
+} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.21.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=1099511627775 AND t2.a=t1.a
+ }
+} {57 000000ffffffffff}
+do_test boundary3-2.21.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000000ffffffffff'
+ }
+} {1099511627775 57}
+do_test boundary3-2.21.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=57
+ }
+} {1099511627775 000000ffffffffff}
+do_test boundary3-2.21.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 1099511627775 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}
+do_test boundary3-2.21.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 1099511627775 ORDER BY t1.a DESC
+ }
+} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary3-2.21.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=57
+ ORDER BY t1.rowid
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.21.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=57
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}
+do_test boundary3-2.21.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=57
+ ORDER BY x
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.21.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=57
+ ORDER BY t1.rowid
+ }
+} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.21.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=57
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}
+do_test boundary3-2.21.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 1099511627775 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}
+do_test boundary3-2.21.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 1099511627775 ORDER BY t1.a DESC
+ }
+} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary3-2.21.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=57
+ ORDER BY t1.rowid
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.21.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=57
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}
+do_test boundary3-2.21.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=57
+ ORDER BY x
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.21.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=57
+ ORDER BY t1.rowid
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.21.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=57
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}
+do_test boundary3-2.21.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 1099511627775 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.21.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 1099511627775 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.21.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=57
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}
+do_test boundary3-2.21.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=57
+ ORDER BY t1.rowid DESC
+ }
+} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.21.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=57
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.21.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=57
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}
+do_test boundary3-2.21.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=57
+ ORDER BY t1.rowid DESC
+ }
+} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.21.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 1099511627775 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary3-2.21.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 1099511627775 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.21.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=57
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}
+do_test boundary3-2.21.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=57
+ ORDER BY t1.rowid DESC
+ }
+} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.21.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=57
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.21.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=57
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}
+do_test boundary3-2.21.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=57
+ ORDER BY t1.rowid DESC
+ }
+} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.22.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-8388608 AND t2.a=t1.a
+ }
+} {37 ffffffffff800000}
+do_test boundary3-2.22.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffff800000'
+ }
+} {-8388608 37}
+do_test boundary3-2.22.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=37
+ }
+} {-8388608 ffffffffff800000}
+do_test boundary3-2.22.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -8388608 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.22.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -8388608 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.22.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=37
+ ORDER BY t1.rowid
+ }
+} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.22.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=37
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}
+do_test boundary3-2.22.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=37
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}
+do_test boundary3-2.22.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=37
+ ORDER BY t1.rowid
+ }
+} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.22.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=37
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}
+do_test boundary3-2.22.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -8388608 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.22.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -8388608 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.22.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=37
+ ORDER BY t1.rowid
+ }
+} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.22.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=37
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}
+do_test boundary3-2.22.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=37
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}
+do_test boundary3-2.22.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=37
+ ORDER BY t1.rowid
+ }
+} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.22.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=37
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}
+do_test boundary3-2.22.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -8388608 ORDER BY t2.a
+ }
+} {1 2 11 21 44 47 55 58 63 64}
+do_test boundary3-2.22.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -8388608 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 21 11 2 1}
+do_test boundary3-2.22.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=37
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary3-2.22.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=37
+ ORDER BY t1.rowid DESC
+ }
+} {1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.22.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=37
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary3-2.22.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=37
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary3-2.22.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=37
+ ORDER BY t1.rowid DESC
+ }
+} {1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.22.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -8388608 ORDER BY t2.a
+ }
+} {1 2 11 21 37 44 47 55 58 63 64}
+do_test boundary3-2.22.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -8388608 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 37 21 11 2 1}
+do_test boundary3-2.22.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=37
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary3-2.22.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=37
+ ORDER BY t1.rowid DESC
+ }
+} {37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.22.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=37
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary3-2.22.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=37
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37}
+do_test boundary3-2.22.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=37
+ ORDER BY t1.rowid DESC
+ }
+} {37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.23.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=549755813888 AND t2.a=t1.a
+ }
+} {35 0000008000000000}
+do_test boundary3-2.23.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000008000000000'
+ }
+} {549755813888 35}
+do_test boundary3-2.23.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=35
+ }
+} {549755813888 0000008000000000}
+do_test boundary3-2.23.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 549755813888 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}
+do_test boundary3-2.23.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 549755813888 ORDER BY t1.a DESC
+ }
+} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary3-2.23.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=35
+ ORDER BY t1.rowid
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.23.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=35
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}
+do_test boundary3-2.23.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=35
+ ORDER BY x
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.23.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=35
+ ORDER BY t1.rowid
+ }
+} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.23.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=35
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}
+do_test boundary3-2.23.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 549755813888 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}
+do_test boundary3-2.23.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 549755813888 ORDER BY t1.a DESC
+ }
+} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary3-2.23.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=35
+ ORDER BY t1.rowid
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.23.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=35
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}
+do_test boundary3-2.23.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=35
+ ORDER BY x
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.23.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=35
+ ORDER BY t1.rowid
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.23.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=35
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}
+do_test boundary3-2.23.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 549755813888 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.23.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 549755813888 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.23.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=35
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}
+do_test boundary3-2.23.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=35
+ ORDER BY t1.rowid DESC
+ }
+} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.23.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=35
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.23.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=35
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}
+do_test boundary3-2.23.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=35
+ ORDER BY t1.rowid DESC
+ }
+} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.23.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 549755813888 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.23.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 549755813888 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.23.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=35
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}
+do_test boundary3-2.23.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=35
+ ORDER BY t1.rowid DESC
+ }
+} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.23.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=35
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.23.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=35
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}
+do_test boundary3-2.23.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=35
+ ORDER BY t1.rowid DESC
+ }
+} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.24.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=8388607 AND t2.a=t1.a
+ }
+} {18 00000000007fffff}
+do_test boundary3-2.24.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00000000007fffff'
+ }
+} {8388607 18}
+do_test boundary3-2.24.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=18
+ }
+} {8388607 00000000007fffff}
+do_test boundary3-2.24.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 8388607 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.24.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 8388607 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary3-2.24.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=18
+ ORDER BY t1.rowid
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.24.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=18
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}
+do_test boundary3-2.24.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=18
+ ORDER BY x
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.24.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=18
+ ORDER BY t1.rowid
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.24.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=18
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}
+do_test boundary3-2.24.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 8388607 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.24.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 8388607 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary3-2.24.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=18
+ ORDER BY t1.rowid
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.24.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=18
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}
+do_test boundary3-2.24.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=18
+ ORDER BY x
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.24.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=18
+ ORDER BY t1.rowid
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.24.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=18
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}
+do_test boundary3-2.24.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 8388607 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.24.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 8388607 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary3-2.24.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=18
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}
+do_test boundary3-2.24.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=18
+ ORDER BY t1.rowid DESC
+ }
+} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.24.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=18
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.24.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=18
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}
+do_test boundary3-2.24.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=18
+ ORDER BY t1.rowid DESC
+ }
+} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.24.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 8388607 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.24.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 8388607 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary3-2.24.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=18
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}
+do_test boundary3-2.24.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=18
+ ORDER BY t1.rowid DESC
+ }
+} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.24.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=18
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.24.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=18
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}
+do_test boundary3-2.24.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=18
+ ORDER BY t1.rowid DESC
+ }
+} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.25.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-3 AND t2.a=t1.a
+ }
+} {52 fffffffffffffffd}
+do_test boundary3-2.25.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='fffffffffffffffd'
+ }
+} {-3 52}
+do_test boundary3-2.25.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=52
+ }
+} {-3 fffffffffffffffd}
+do_test boundary3-2.25.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -3 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary3-2.25.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -3 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.25.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=52
+ ORDER BY t1.rowid
+ }
+} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.25.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=52
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}
+do_test boundary3-2.25.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=52
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}
+do_test boundary3-2.25.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=52
+ ORDER BY t1.rowid
+ }
+} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.25.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=52
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}
+do_test boundary3-2.25.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -3 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}
+do_test boundary3-2.25.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -3 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.25.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=52
+ ORDER BY t1.rowid
+ }
+} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.25.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=52
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}
+do_test boundary3-2.25.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=52
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}
+do_test boundary3-2.25.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=52
+ ORDER BY t1.rowid
+ }
+} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.25.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=52
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}
+do_test boundary3-2.25.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -3 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}
+do_test boundary3-2.25.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -3 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}
+do_test boundary3-2.25.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=52
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary3-2.25.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=52
+ ORDER BY t1.rowid DESC
+ }
+} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.25.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=52
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary3-2.25.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=52
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary3-2.25.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=52
+ ORDER BY t1.rowid DESC
+ }
+} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.25.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -3 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}
+do_test boundary3-2.25.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -3 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}
+do_test boundary3-2.25.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=52
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary3-2.25.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=52
+ ORDER BY t1.rowid DESC
+ }
+} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.25.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=52
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary3-2.25.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=52
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary3-2.25.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=52
+ ORDER BY t1.rowid DESC
+ }
+} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.26.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=0 AND t2.a=t1.a
+ }
+} {59 0000000000000000}
+do_test boundary3-2.26.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000000'
+ }
+} {0 59}
+do_test boundary3-2.26.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=59
+ }
+} {0 0000000000000000}
+do_test boundary3-2.26.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 0 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}
+do_test boundary3-2.26.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 0 ORDER BY t1.a DESC
+ }
+} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.26.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=59
+ ORDER BY t1.rowid
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.26.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=59
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}
+do_test boundary3-2.26.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=59
+ ORDER BY x
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.26.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=59
+ ORDER BY t1.rowid
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.26.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=59
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}
+do_test boundary3-2.26.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 0 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary3-2.26.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 0 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.26.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=59
+ ORDER BY t1.rowid
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.26.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=59
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}
+do_test boundary3-2.26.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=59
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.26.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=59
+ ORDER BY t1.rowid
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.26.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=59
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}
+do_test boundary3-2.26.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 0 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}
+do_test boundary3-2.26.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 0 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary3-2.26.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=59
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.26.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=59
+ ORDER BY t1.rowid DESC
+ }
+} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.26.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=59
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.26.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=59
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.26.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=59
+ ORDER BY t1.rowid DESC
+ }
+} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.26.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 0 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}
+do_test boundary3-2.26.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 0 ORDER BY t1.a DESC
+ }
+} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary3-2.26.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=59
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}
+do_test boundary3-2.26.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=59
+ ORDER BY t1.rowid DESC
+ }
+} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.26.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=59
+ ORDER BY x
+ }
+} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.26.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=59
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}
+do_test boundary3-2.26.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=59
+ ORDER BY t1.rowid DESC
+ }
+} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.27.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-1 AND t2.a=t1.a
+ }
+} {38 ffffffffffffffff}
+do_test boundary3-2.27.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffffffffff'
+ }
+} {-1 38}
+do_test boundary3-2.27.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=38
+ }
+} {-1 ffffffffffffffff}
+do_test boundary3-2.27.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -1 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary3-2.27.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -1 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.27.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=38
+ ORDER BY t1.rowid
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.27.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=38
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}
+do_test boundary3-2.27.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=38
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.27.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=38
+ ORDER BY t1.rowid
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.27.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=38
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}
+do_test boundary3-2.27.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -1 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary3-2.27.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -1 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.27.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=38
+ ORDER BY t1.rowid
+ }
+} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.27.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=38
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}
+do_test boundary3-2.27.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=38
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}
+do_test boundary3-2.27.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=38
+ ORDER BY t1.rowid
+ }
+} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.27.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=38
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}
+do_test boundary3-2.27.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -1 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}
+do_test boundary3-2.27.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -1 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}
+do_test boundary3-2.27.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=38
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary3-2.27.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=38
+ ORDER BY t1.rowid DESC
+ }
+} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.27.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=38
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary3-2.27.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=38
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary3-2.27.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=38
+ ORDER BY t1.rowid DESC
+ }
+} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.27.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -1 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}
+do_test boundary3-2.27.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -1 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary3-2.27.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=38
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.27.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=38
+ ORDER BY t1.rowid DESC
+ }
+} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.27.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=38
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.27.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=38
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.27.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=38
+ ORDER BY t1.rowid DESC
+ }
+} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.28.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-2 AND t2.a=t1.a
+ }
+} {33 fffffffffffffffe}
+do_test boundary3-2.28.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='fffffffffffffffe'
+ }
+} {-2 33}
+do_test boundary3-2.28.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=33
+ }
+} {-2 fffffffffffffffe}
+do_test boundary3-2.28.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -2 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary3-2.28.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -2 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.28.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=33
+ ORDER BY t1.rowid
+ }
+} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.28.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=33
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}
+do_test boundary3-2.28.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=33
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}
+do_test boundary3-2.28.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=33
+ ORDER BY t1.rowid
+ }
+} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.28.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=33
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}
+do_test boundary3-2.28.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -2 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}
+do_test boundary3-2.28.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -2 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.28.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=33
+ ORDER BY t1.rowid
+ }
+} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.28.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=33
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}
+do_test boundary3-2.28.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=33
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}
+do_test boundary3-2.28.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=33
+ ORDER BY t1.rowid
+ }
+} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.28.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=33
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}
+do_test boundary3-2.28.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -2 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}
+do_test boundary3-2.28.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -2 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}
+do_test boundary3-2.28.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=33
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary3-2.28.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=33
+ ORDER BY t1.rowid DESC
+ }
+} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.28.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=33
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary3-2.28.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=33
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}
+do_test boundary3-2.28.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=33
+ ORDER BY t1.rowid DESC
+ }
+} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.28.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -2 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}
+do_test boundary3-2.28.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -2 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}
+do_test boundary3-2.28.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=33
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary3-2.28.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=33
+ ORDER BY t1.rowid DESC
+ }
+} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.28.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=33
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary3-2.28.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=33
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}
+do_test boundary3-2.28.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=33
+ ORDER BY t1.rowid DESC
+ }
+} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.29.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=2097152 AND t2.a=t1.a
+ }
+} {42 0000000000200000}
+do_test boundary3-2.29.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000200000'
+ }
+} {2097152 42}
+do_test boundary3-2.29.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=42
+ }
+} {2097152 0000000000200000}
+do_test boundary3-2.29.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 2097152 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.29.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 2097152 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary3-2.29.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=42
+ ORDER BY t1.rowid
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.29.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=42
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}
+do_test boundary3-2.29.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=42
+ ORDER BY x
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.29.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=42
+ ORDER BY t1.rowid
+ }
+} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.29.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=42
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}
+do_test boundary3-2.29.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 2097152 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary3-2.29.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 2097152 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary3-2.29.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=42
+ ORDER BY t1.rowid
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.29.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=42
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}
+do_test boundary3-2.29.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=42
+ ORDER BY x
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.29.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=42
+ ORDER BY t1.rowid
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.29.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=42
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}
+do_test boundary3-2.29.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 2097152 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.29.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 2097152 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary3-2.29.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=42
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}
+do_test boundary3-2.29.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=42
+ ORDER BY t1.rowid DESC
+ }
+} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.29.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=42
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.29.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=42
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}
+do_test boundary3-2.29.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=42
+ ORDER BY t1.rowid DESC
+ }
+} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.29.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 2097152 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.29.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 2097152 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary3-2.29.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=42
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}
+do_test boundary3-2.29.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=42
+ ORDER BY t1.rowid DESC
+ }
+} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.29.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=42
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.29.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=42
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}
+do_test boundary3-2.29.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=42
+ ORDER BY t1.rowid DESC
+ }
+} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.30.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=128 AND t2.a=t1.a
+ }
+} {49 0000000000000080}
+do_test boundary3-2.30.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000080'
+ }
+} {128 49}
+do_test boundary3-2.30.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=49
+ }
+} {128 0000000000000080}
+do_test boundary3-2.30.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 128 ORDER BY t2.a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary3-2.30.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 128 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary3-2.30.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=49
+ ORDER BY t1.rowid
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.30.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=49
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}
+do_test boundary3-2.30.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=49
+ ORDER BY x
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.30.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=49
+ ORDER BY t1.rowid
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.30.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=49
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}
+do_test boundary3-2.30.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 128 ORDER BY t2.a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary3-2.30.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 128 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary3-2.30.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=49
+ ORDER BY t1.rowid
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.30.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=49
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}
+do_test boundary3-2.30.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=49
+ ORDER BY x
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.30.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=49
+ ORDER BY t1.rowid
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.30.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=49
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}
+do_test boundary3-2.30.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 128 ORDER BY t2.a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.30.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 128 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary3-2.30.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=49
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}
+do_test boundary3-2.30.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=49
+ ORDER BY t1.rowid DESC
+ }
+} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.30.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=49
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.30.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=49
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}
+do_test boundary3-2.30.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=49
+ ORDER BY t1.rowid DESC
+ }
+} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.30.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 128 ORDER BY t2.a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.30.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 128 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary3-2.30.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=49
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}
+do_test boundary3-2.30.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=49
+ ORDER BY t1.rowid DESC
+ }
+} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.30.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=49
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.30.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=49
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}
+do_test boundary3-2.30.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=49
+ ORDER BY t1.rowid DESC
+ }
+} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.31.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=255 AND t2.a=t1.a
+ }
+} {30 00000000000000ff}
+do_test boundary3-2.31.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00000000000000ff'
+ }
+} {255 30}
+do_test boundary3-2.31.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=30
+ }
+} {255 00000000000000ff}
+do_test boundary3-2.31.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 255 ORDER BY t2.a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary3-2.31.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 255 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary3-2.31.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=30
+ ORDER BY t1.rowid
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.31.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=30
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}
+do_test boundary3-2.31.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=30
+ ORDER BY x
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.31.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=30
+ ORDER BY t1.rowid
+ }
+} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.31.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=30
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}
+do_test boundary3-2.31.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 255 ORDER BY t2.a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}
+do_test boundary3-2.31.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 255 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary3-2.31.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=30
+ ORDER BY t1.rowid
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.31.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=30
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}
+do_test boundary3-2.31.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=30
+ ORDER BY x
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.31.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=30
+ ORDER BY t1.rowid
+ }
+} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.31.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=30
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}
+do_test boundary3-2.31.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 255 ORDER BY t2.a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.31.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 255 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary3-2.31.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=30
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}
+do_test boundary3-2.31.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=30
+ ORDER BY t1.rowid DESC
+ }
+} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.31.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=30
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.31.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=30
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}
+do_test boundary3-2.31.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=30
+ ORDER BY t1.rowid DESC
+ }
+} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.31.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 255 ORDER BY t2.a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.31.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 255 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary3-2.31.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=30
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}
+do_test boundary3-2.31.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=30
+ ORDER BY t1.rowid DESC
+ }
+} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.31.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=30
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.31.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=30
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}
+do_test boundary3-2.31.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=30
+ ORDER BY t1.rowid DESC
+ }
+} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.32.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-2147483648 AND t2.a=t1.a
+ }
+} {11 ffffffff80000000}
+do_test boundary3-2.32.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffff80000000'
+ }
+} {-2147483648 11}
+do_test boundary3-2.32.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=11
+ }
+} {-2147483648 ffffffff80000000}
+do_test boundary3-2.32.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -2147483648 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.32.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -2147483648 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.32.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=11
+ ORDER BY t1.rowid
+ }
+} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.32.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=11
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}
+do_test boundary3-2.32.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=11
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.32.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=11
+ ORDER BY t1.rowid
+ }
+} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.32.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=11
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}
+do_test boundary3-2.32.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -2147483648 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.32.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -2147483648 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.32.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=11
+ ORDER BY t1.rowid
+ }
+} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.32.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=11
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}
+do_test boundary3-2.32.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=11
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.32.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=11
+ ORDER BY t1.rowid
+ }
+} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.32.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=11
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}
+do_test boundary3-2.32.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -2147483648 ORDER BY t2.a
+ }
+} {2 21 44 47 55 58 63 64}
+do_test boundary3-2.32.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -2147483648 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 21 2}
+do_test boundary3-2.32.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=11
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary3-2.32.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=11
+ ORDER BY t1.rowid DESC
+ }
+} {47 63 58 44 21 64 2 55}
+do_test boundary3-2.32.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=11
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary3-2.32.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=11
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary3-2.32.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=11
+ ORDER BY t1.rowid DESC
+ }
+} {47 63 58 44 21 64 2 55}
+do_test boundary3-2.32.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -2147483648 ORDER BY t2.a
+ }
+} {2 11 21 44 47 55 58 63 64}
+do_test boundary3-2.32.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -2147483648 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 21 11 2}
+do_test boundary3-2.32.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=11
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary3-2.32.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=11
+ ORDER BY t1.rowid DESC
+ }
+} {11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.32.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=11
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary3-2.32.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=11
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary3-2.32.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=11
+ ORDER BY t1.rowid DESC
+ }
+} {11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.33.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=34359738367 AND t2.a=t1.a
+ }
+} {39 00000007ffffffff}
+do_test boundary3-2.33.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00000007ffffffff'
+ }
+} {34359738367 39}
+do_test boundary3-2.33.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=39
+ }
+} {34359738367 00000007ffffffff}
+do_test boundary3-2.33.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 34359738367 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary3-2.33.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 34359738367 ORDER BY t1.a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary3-2.33.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=39
+ ORDER BY t1.rowid
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.33.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=39
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}
+do_test boundary3-2.33.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=39
+ ORDER BY x
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.33.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=39
+ ORDER BY t1.rowid
+ }
+} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.33.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=39
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}
+do_test boundary3-2.33.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 34359738367 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}
+do_test boundary3-2.33.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 34359738367 ORDER BY t1.a DESC
+ }
+} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}
+do_test boundary3-2.33.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=39
+ ORDER BY t1.rowid
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.33.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=39
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}
+do_test boundary3-2.33.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=39
+ ORDER BY x
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.33.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=39
+ ORDER BY t1.rowid
+ }
+} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.33.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=39
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}
+do_test boundary3-2.33.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 34359738367 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.33.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 34359738367 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.33.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=39
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}
+do_test boundary3-2.33.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=39
+ ORDER BY t1.rowid DESC
+ }
+} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.33.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=39
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.33.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=39
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}
+do_test boundary3-2.33.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=39
+ ORDER BY t1.rowid DESC
+ }
+} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.33.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 34359738367 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.33.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 34359738367 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.33.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=39
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}
+do_test boundary3-2.33.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=39
+ ORDER BY t1.rowid DESC
+ }
+} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.33.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=39
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.33.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=39
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}
+do_test boundary3-2.33.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=39
+ ORDER BY t1.rowid DESC
+ }
+} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.34.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-549755813889 AND t2.a=t1.a
+ }
+} {58 ffffff7fffffffff}
+do_test boundary3-2.34.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffff7fffffffff'
+ }
+} {-549755813889 58}
+do_test boundary3-2.34.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=58
+ }
+} {-549755813889 ffffff7fffffffff}
+do_test boundary3-2.34.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -549755813889 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}
+do_test boundary3-2.34.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -549755813889 ORDER BY t1.a DESC
+ }
+} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.34.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=58
+ ORDER BY t1.rowid
+ }
+} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.34.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=58
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}
+do_test boundary3-2.34.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=58
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.34.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=58
+ ORDER BY t1.rowid
+ }
+} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.34.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=58
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}
+do_test boundary3-2.34.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -549755813889 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}
+do_test boundary3-2.34.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -549755813889 ORDER BY t1.a DESC
+ }
+} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.34.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=58
+ ORDER BY t1.rowid
+ }
+} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.34.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=58
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}
+do_test boundary3-2.34.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=58
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.34.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=58
+ ORDER BY t1.rowid
+ }
+} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.34.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=58
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}
+do_test boundary3-2.34.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -549755813889 ORDER BY t2.a
+ }
+} {2 21 44 55 64}
+do_test boundary3-2.34.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -549755813889 ORDER BY t1.a DESC
+ }
+} {64 55 44 21 2}
+do_test boundary3-2.34.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=58
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44}
+do_test boundary3-2.34.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=58
+ ORDER BY t1.rowid DESC
+ }
+} {44 21 64 2 55}
+do_test boundary3-2.34.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=58
+ ORDER BY x
+ }
+} {55 2 64 21 44}
+do_test boundary3-2.34.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=58
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44}
+do_test boundary3-2.34.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=58
+ ORDER BY t1.rowid DESC
+ }
+} {44 21 64 2 55}
+do_test boundary3-2.34.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -549755813889 ORDER BY t2.a
+ }
+} {2 21 44 55 58 64}
+do_test boundary3-2.34.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -549755813889 ORDER BY t1.a DESC
+ }
+} {64 58 55 44 21 2}
+do_test boundary3-2.34.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=58
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58}
+do_test boundary3-2.34.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=58
+ ORDER BY t1.rowid DESC
+ }
+} {58 44 21 64 2 55}
+do_test boundary3-2.34.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=58
+ ORDER BY x
+ }
+} {55 2 64 21 44 58}
+do_test boundary3-2.34.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=58
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58}
+do_test boundary3-2.34.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=58
+ ORDER BY t1.rowid DESC
+ }
+} {58 44 21 64 2 55}
+do_test boundary3-2.35.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-32768 AND t2.a=t1.a
+ }
+} {32 ffffffffffff8000}
+do_test boundary3-2.35.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffffff8000'
+ }
+} {-32768 32}
+do_test boundary3-2.35.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=32
+ }
+} {-32768 ffffffffffff8000}
+do_test boundary3-2.35.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -32768 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.35.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -32768 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.35.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=32
+ ORDER BY t1.rowid
+ }
+} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.35.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=32
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}
+do_test boundary3-2.35.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=32
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}
+do_test boundary3-2.35.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=32
+ ORDER BY t1.rowid
+ }
+} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.35.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=32
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}
+do_test boundary3-2.35.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -32768 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.35.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -32768 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.35.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=32
+ ORDER BY t1.rowid
+ }
+} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.35.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=32
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}
+do_test boundary3-2.35.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=32
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}
+do_test boundary3-2.35.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=32
+ ORDER BY t1.rowid
+ }
+} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.35.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=32
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}
+do_test boundary3-2.35.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -32768 ORDER BY t2.a
+ }
+} {1 2 11 21 29 37 44 47 55 58 63 64}
+do_test boundary3-2.35.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -32768 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 37 29 21 11 2 1}
+do_test boundary3-2.35.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=32
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary3-2.35.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=32
+ ORDER BY t1.rowid DESC
+ }
+} {29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.35.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=32
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary3-2.35.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=32
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29}
+do_test boundary3-2.35.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=32
+ ORDER BY t1.rowid DESC
+ }
+} {29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.35.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -32768 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 37 44 47 55 58 63 64}
+do_test boundary3-2.35.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -32768 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 37 32 29 21 11 2 1}
+do_test boundary3-2.35.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=32
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary3-2.35.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=32
+ ORDER BY t1.rowid DESC
+ }
+} {32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.35.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=32
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary3-2.35.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=32
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary3-2.35.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=32
+ ORDER BY t1.rowid DESC
+ }
+} {32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.36.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=2147483647 AND t2.a=t1.a
+ }
+} {20 000000007fffffff}
+do_test boundary3-2.36.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000000007fffffff'
+ }
+} {2147483647 20}
+do_test boundary3-2.36.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=20
+ }
+} {2147483647 000000007fffffff}
+do_test boundary3-2.36.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 2147483647 ORDER BY t2.a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary3-2.36.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 2147483647 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary3-2.36.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=20
+ ORDER BY t1.rowid
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.36.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=20
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}
+do_test boundary3-2.36.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=20
+ ORDER BY x
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.36.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=20
+ ORDER BY t1.rowid
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.36.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=20
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}
+do_test boundary3-2.36.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 2147483647 ORDER BY t2.a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary3-2.36.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 2147483647 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary3-2.36.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=20
+ ORDER BY t1.rowid
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.36.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=20
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}
+do_test boundary3-2.36.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=20
+ ORDER BY x
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.36.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=20
+ ORDER BY t1.rowid
+ }
+} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.36.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=20
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}
+do_test boundary3-2.36.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 2147483647 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.36.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 2147483647 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.36.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=20
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}
+do_test boundary3-2.36.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=20
+ ORDER BY t1.rowid DESC
+ }
+} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.36.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=20
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.36.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=20
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}
+do_test boundary3-2.36.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=20
+ ORDER BY t1.rowid DESC
+ }
+} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.36.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 2147483647 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.36.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 2147483647 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.36.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=20
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}
+do_test boundary3-2.36.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=20
+ ORDER BY t1.rowid DESC
+ }
+} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.36.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=20
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.36.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=20
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}
+do_test boundary3-2.36.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=20
+ ORDER BY t1.rowid DESC
+ }
+} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.37.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-129 AND t2.a=t1.a
+ }
+} {54 ffffffffffffff7f}
+do_test boundary3-2.37.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffffffff7f'
+ }
+} {-129 54}
+do_test boundary3-2.37.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=54
+ }
+} {-129 ffffffffffffff7f}
+do_test boundary3-2.37.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -129 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}
+do_test boundary3-2.37.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -129 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.37.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=54
+ ORDER BY t1.rowid
+ }
+} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.37.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=54
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}
+do_test boundary3-2.37.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=54
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}
+do_test boundary3-2.37.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=54
+ ORDER BY t1.rowid
+ }
+} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.37.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=54
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}
+do_test boundary3-2.37.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -129 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.37.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -129 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.37.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=54
+ ORDER BY t1.rowid
+ }
+} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.37.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=54
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}
+do_test boundary3-2.37.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=54
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}
+do_test boundary3-2.37.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=54
+ ORDER BY t1.rowid
+ }
+} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.37.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=54
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}
+do_test boundary3-2.37.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -129 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 37 44 47 55 58 63 64}
+do_test boundary3-2.37.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -129 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 37 32 29 21 11 2 1}
+do_test boundary3-2.37.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=54
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary3-2.37.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=54
+ ORDER BY t1.rowid DESC
+ }
+} {32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.37.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=54
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary3-2.37.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=54
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32}
+do_test boundary3-2.37.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=54
+ ORDER BY t1.rowid DESC
+ }
+} {32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.37.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -129 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}
+do_test boundary3-2.37.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -129 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}
+do_test boundary3-2.37.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=54
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary3-2.37.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=54
+ ORDER BY t1.rowid DESC
+ }
+} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.37.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=54
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary3-2.37.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=54
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary3-2.37.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=54
+ ORDER BY t1.rowid DESC
+ }
+} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.38.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-128 AND t2.a=t1.a
+ }
+} {53 ffffffffffffff80}
+do_test boundary3-2.38.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffffffff80'
+ }
+} {-128 53}
+do_test boundary3-2.38.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=53
+ }
+} {-128 ffffffffffffff80}
+do_test boundary3-2.38.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -128 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}
+do_test boundary3-2.38.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -128 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.38.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=53
+ ORDER BY t1.rowid
+ }
+} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.38.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=53
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}
+do_test boundary3-2.38.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=53
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}
+do_test boundary3-2.38.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=53
+ ORDER BY t1.rowid
+ }
+} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.38.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=53
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}
+do_test boundary3-2.38.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -128 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}
+do_test boundary3-2.38.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -128 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.38.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=53
+ ORDER BY t1.rowid
+ }
+} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.38.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=53
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}
+do_test boundary3-2.38.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=53
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}
+do_test boundary3-2.38.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=53
+ ORDER BY t1.rowid
+ }
+} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.38.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=53
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}
+do_test boundary3-2.38.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -128 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}
+do_test boundary3-2.38.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -128 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}
+do_test boundary3-2.38.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=53
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary3-2.38.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=53
+ ORDER BY t1.rowid DESC
+ }
+} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.38.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=53
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary3-2.38.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=53
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}
+do_test boundary3-2.38.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=53
+ ORDER BY t1.rowid DESC
+ }
+} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.38.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -128 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}
+do_test boundary3-2.38.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -128 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}
+do_test boundary3-2.38.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=53
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary3-2.38.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=53
+ ORDER BY t1.rowid DESC
+ }
+} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.38.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=53
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary3-2.38.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=53
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}
+do_test boundary3-2.38.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=53
+ ORDER BY t1.rowid DESC
+ }
+} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.39.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=72057594037927936 AND t2.a=t1.a
+ }
+} {28 0100000000000000}
+do_test boundary3-2.39.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0100000000000000'
+ }
+} {72057594037927936 28}
+do_test boundary3-2.39.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=28
+ }
+} {72057594037927936 0100000000000000}
+do_test boundary3-2.39.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 72057594037927936 ORDER BY t2.a
+ }
+} {3}
+do_test boundary3-2.39.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 72057594037927936 ORDER BY t1.a DESC
+ }
+} {3}
+do_test boundary3-2.39.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=28
+ ORDER BY t1.rowid
+ }
+} {3}
+do_test boundary3-2.39.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=28
+ ORDER BY t1.rowid DESC
+ }
+} {3}
+do_test boundary3-2.39.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=28
+ ORDER BY x
+ }
+} {3}
+do_test boundary3-2.39.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 72057594037927936 ORDER BY t2.a
+ }
+} {3 28}
+do_test boundary3-2.39.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 72057594037927936 ORDER BY t1.a DESC
+ }
+} {28 3}
+do_test boundary3-2.39.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=28
+ ORDER BY t1.rowid
+ }
+} {28 3}
+do_test boundary3-2.39.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=28
+ ORDER BY t1.rowid DESC
+ }
+} {3 28}
+do_test boundary3-2.39.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=28
+ ORDER BY x
+ }
+} {28 3}
+do_test boundary3-2.39.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 72057594037927936 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.39.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 72057594037927936 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.39.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=28
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}
+do_test boundary3-2.39.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=28
+ ORDER BY t1.rowid DESC
+ }
+} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.39.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=28
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.39.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 72057594037927936 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.39.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 72057594037927936 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.39.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=28
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}
+do_test boundary3-2.39.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=28
+ ORDER BY t1.rowid DESC
+ }
+} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.39.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=28
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.40.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=2147483648 AND t2.a=t1.a
+ }
+} {51 0000000080000000}
+do_test boundary3-2.40.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000080000000'
+ }
+} {2147483648 51}
+do_test boundary3-2.40.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=51
+ }
+} {2147483648 0000000080000000}
+do_test boundary3-2.40.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 2147483648 ORDER BY t2.a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}
+do_test boundary3-2.40.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 2147483648 ORDER BY t1.a DESC
+ }
+} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary3-2.40.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=51
+ ORDER BY t1.rowid
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.40.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=51
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}
+do_test boundary3-2.40.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=51
+ ORDER BY x
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.40.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=51
+ ORDER BY t1.rowid
+ }
+} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.40.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=51
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}
+do_test boundary3-2.40.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 2147483648 ORDER BY t2.a
+ }
+} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}
+do_test boundary3-2.40.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 2147483648 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}
+do_test boundary3-2.40.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=51
+ ORDER BY t1.rowid
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.40.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=51
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}
+do_test boundary3-2.40.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=51
+ ORDER BY x
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.40.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=51
+ ORDER BY t1.rowid
+ }
+} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.40.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=51
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}
+do_test boundary3-2.40.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 2147483648 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.40.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 2147483648 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.40.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=51
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}
+do_test boundary3-2.40.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=51
+ ORDER BY t1.rowid DESC
+ }
+} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.40.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=51
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.40.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=51
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}
+do_test boundary3-2.40.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=51
+ ORDER BY t1.rowid DESC
+ }
+} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.40.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 2147483648 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.40.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 2147483648 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.40.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=51
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}
+do_test boundary3-2.40.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=51
+ ORDER BY t1.rowid DESC
+ }
+} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.40.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=51
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.40.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=51
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}
+do_test boundary3-2.40.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=51
+ ORDER BY t1.rowid DESC
+ }
+} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.41.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=549755813887 AND t2.a=t1.a
+ }
+} {46 0000007fffffffff}
+do_test boundary3-2.41.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000007fffffffff'
+ }
+} {549755813887 46}
+do_test boundary3-2.41.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=46
+ }
+} {549755813887 0000007fffffffff}
+do_test boundary3-2.41.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 549755813887 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}
+do_test boundary3-2.41.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 549755813887 ORDER BY t1.a DESC
+ }
+} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary3-2.41.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=46
+ ORDER BY t1.rowid
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.41.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=46
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}
+do_test boundary3-2.41.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=46
+ ORDER BY x
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.41.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=46
+ ORDER BY t1.rowid
+ }
+} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.41.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=46
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}
+do_test boundary3-2.41.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 549755813887 ORDER BY t2.a
+ }
+} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}
+do_test boundary3-2.41.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 549755813887 ORDER BY t1.a DESC
+ }
+} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}
+do_test boundary3-2.41.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=46
+ ORDER BY t1.rowid
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.41.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=46
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}
+do_test boundary3-2.41.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=46
+ ORDER BY x
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.41.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=46
+ ORDER BY t1.rowid
+ }
+} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.41.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=46
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}
+do_test boundary3-2.41.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 549755813887 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.41.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 549755813887 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.41.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=46
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}
+do_test boundary3-2.41.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=46
+ ORDER BY t1.rowid DESC
+ }
+} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.41.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=46
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.41.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=46
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}
+do_test boundary3-2.41.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=46
+ ORDER BY t1.rowid DESC
+ }
+} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.41.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 549755813887 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.41.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 549755813887 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.41.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=46
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}
+do_test boundary3-2.41.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=46
+ ORDER BY t1.rowid DESC
+ }
+} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.41.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=46
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.41.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=46
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}
+do_test boundary3-2.41.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=46
+ ORDER BY t1.rowid DESC
+ }
+} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.42.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-549755813888 AND t2.a=t1.a
+ }
+} {63 ffffff8000000000}
+do_test boundary3-2.42.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffff8000000000'
+ }
+} {-549755813888 63}
+do_test boundary3-2.42.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=63
+ }
+} {-549755813888 ffffff8000000000}
+do_test boundary3-2.42.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -549755813888 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.42.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -549755813888 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.42.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=63
+ ORDER BY t1.rowid
+ }
+} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.42.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=63
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}
+do_test boundary3-2.42.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=63
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.42.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=63
+ ORDER BY t1.rowid
+ }
+} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.42.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=63
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}
+do_test boundary3-2.42.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -549755813888 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}
+do_test boundary3-2.42.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -549755813888 ORDER BY t1.a DESC
+ }
+} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.42.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=63
+ ORDER BY t1.rowid
+ }
+} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.42.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=63
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}
+do_test boundary3-2.42.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=63
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.42.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=63
+ ORDER BY t1.rowid
+ }
+} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.42.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=63
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}
+do_test boundary3-2.42.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -549755813888 ORDER BY t2.a
+ }
+} {2 21 44 55 58 64}
+do_test boundary3-2.42.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -549755813888 ORDER BY t1.a DESC
+ }
+} {64 58 55 44 21 2}
+do_test boundary3-2.42.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=63
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58}
+do_test boundary3-2.42.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=63
+ ORDER BY t1.rowid DESC
+ }
+} {58 44 21 64 2 55}
+do_test boundary3-2.42.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=63
+ ORDER BY x
+ }
+} {55 2 64 21 44 58}
+do_test boundary3-2.42.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=63
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58}
+do_test boundary3-2.42.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=63
+ ORDER BY t1.rowid DESC
+ }
+} {58 44 21 64 2 55}
+do_test boundary3-2.42.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -549755813888 ORDER BY t2.a
+ }
+} {2 21 44 55 58 63 64}
+do_test boundary3-2.42.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -549755813888 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 44 21 2}
+do_test boundary3-2.42.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=63
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary3-2.42.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=63
+ ORDER BY t1.rowid DESC
+ }
+} {63 58 44 21 64 2 55}
+do_test boundary3-2.42.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=63
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary3-2.42.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=63
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary3-2.42.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=63
+ ORDER BY t1.rowid DESC
+ }
+} {63 58 44 21 64 2 55}
+do_test boundary3-2.43.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=281474976710655 AND t2.a=t1.a
+ }
+} {10 0000ffffffffffff}
+do_test boundary3-2.43.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000ffffffffffff'
+ }
+} {281474976710655 10}
+do_test boundary3-2.43.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=10
+ }
+} {281474976710655 0000ffffffffffff}
+do_test boundary3-2.43.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 281474976710655 ORDER BY t2.a
+ }
+} {3 13 17 26 27 28 43 45}
+do_test boundary3-2.43.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 281474976710655 ORDER BY t1.a DESC
+ }
+} {45 43 28 27 26 17 13 3}
+do_test boundary3-2.43.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=10
+ ORDER BY t1.rowid
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary3-2.43.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=10
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26}
+do_test boundary3-2.43.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=10
+ ORDER BY x
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary3-2.43.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 281474976710655 ORDER BY t2.a
+ }
+} {3 10 13 17 26 27 28 43 45}
+do_test boundary3-2.43.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 281474976710655 ORDER BY t1.a DESC
+ }
+} {45 43 28 27 26 17 13 10 3}
+do_test boundary3-2.43.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=10
+ ORDER BY t1.rowid
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.43.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=10
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10}
+do_test boundary3-2.43.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=10
+ ORDER BY x
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.43.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 281474976710655 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.43.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 281474976710655 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary3-2.43.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=10
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}
+do_test boundary3-2.43.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=10
+ ORDER BY t1.rowid DESC
+ }
+} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.43.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=10
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.43.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 281474976710655 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.43.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 281474976710655 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.43.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=10
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}
+do_test boundary3-2.43.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=10
+ ORDER BY t1.rowid DESC
+ }
+} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.43.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=10
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.44.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=4398046511103 AND t2.a=t1.a
+ }
+} {7 000003ffffffffff}
+do_test boundary3-2.44.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000003ffffffffff'
+ }
+} {4398046511103 7}
+do_test boundary3-2.44.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=7
+ }
+} {4398046511103 000003ffffffffff}
+do_test boundary3-2.44.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 4398046511103 ORDER BY t2.a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary3-2.44.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 4398046511103 ORDER BY t1.a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary3-2.44.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=7
+ ORDER BY t1.rowid
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.44.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=7
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56}
+do_test boundary3-2.44.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=7
+ ORDER BY x
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.44.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=7
+ ORDER BY t1.rowid
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.44.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=7
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56}
+do_test boundary3-2.44.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 4398046511103 ORDER BY t2.a
+ }
+} {3 7 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary3-2.44.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 4398046511103 ORDER BY t1.a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 7 3}
+do_test boundary3-2.44.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=7
+ ORDER BY t1.rowid
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.44.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=7
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7}
+do_test boundary3-2.44.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=7
+ ORDER BY x
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.44.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=7
+ ORDER BY t1.rowid
+ }
+} {7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.44.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=7
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7}
+do_test boundary3-2.44.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 4398046511103 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary3-2.44.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 4398046511103 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.44.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=7
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}
+do_test boundary3-2.44.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=7
+ ORDER BY t1.rowid DESC
+ }
+} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.44.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=7
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.44.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=7
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}
+do_test boundary3-2.44.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=7
+ ORDER BY t1.rowid DESC
+ }
+} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.44.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 4398046511103 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary3-2.44.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 4398046511103 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary3-2.44.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=7
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}
+do_test boundary3-2.44.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=7
+ ORDER BY t1.rowid DESC
+ }
+} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.44.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=7
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.44.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=7
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}
+do_test boundary3-2.44.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=7
+ ORDER BY t1.rowid DESC
+ }
+} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.45.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=268435455 AND t2.a=t1.a
+ }
+} {12 000000000fffffff}
+do_test boundary3-2.45.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000000000fffffff'
+ }
+} {268435455 12}
+do_test boundary3-2.45.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=12
+ }
+} {268435455 000000000fffffff}
+do_test boundary3-2.45.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 268435455 ORDER BY t2.a
+ }
+} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.45.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 268435455 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}
+do_test boundary3-2.45.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=12
+ ORDER BY t1.rowid
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.45.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=12
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}
+do_test boundary3-2.45.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=12
+ ORDER BY x
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.45.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=12
+ ORDER BY t1.rowid
+ }
+} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.45.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=12
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}
+do_test boundary3-2.45.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 268435455 ORDER BY t2.a
+ }
+} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.45.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 268435455 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}
+do_test boundary3-2.45.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=12
+ ORDER BY t1.rowid
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.45.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=12
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}
+do_test boundary3-2.45.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=12
+ ORDER BY x
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.45.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=12
+ ORDER BY t1.rowid
+ }
+} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.45.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=12
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}
+do_test boundary3-2.45.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 268435455 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.45.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 268435455 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}
+do_test boundary3-2.45.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=12
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}
+do_test boundary3-2.45.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=12
+ ORDER BY t1.rowid DESC
+ }
+} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.45.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=12
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.45.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=12
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}
+do_test boundary3-2.45.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=12
+ ORDER BY t1.rowid DESC
+ }
+} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.45.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 268435455 ORDER BY t2.a
+ }
+} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.45.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 268435455 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}
+do_test boundary3-2.45.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=12
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}
+do_test boundary3-2.45.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=12
+ ORDER BY t1.rowid DESC
+ }
+} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.45.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=12
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.45.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=12
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}
+do_test boundary3-2.45.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=12
+ ORDER BY t1.rowid DESC
+ }
+} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.46.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-9223372036854775808 AND t2.a=t1.a
+ }
+} {55 8000000000000000}
+do_test boundary3-2.46.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='8000000000000000'
+ }
+} {-9223372036854775808 55}
+do_test boundary3-2.46.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=55
+ }
+} {-9223372036854775808 8000000000000000}
+do_test boundary3-2.46.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -9223372036854775808 ORDER BY t2.a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.46.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -9223372036854775808 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary3-2.46.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=55
+ ORDER BY t1.rowid
+ }
+} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.46.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=55
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}
+do_test boundary3-2.46.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=55
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.46.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -9223372036854775808 ORDER BY t2.a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.46.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -9223372036854775808 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary3-2.46.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=55
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.46.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=55
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.46.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=55
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.46.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -9223372036854775808 ORDER BY t2.a
+ }
+} {}
+do_test boundary3-2.46.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -9223372036854775808 ORDER BY t1.a DESC
+ }
+} {}
+do_test boundary3-2.46.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=55
+ ORDER BY t1.rowid
+ }
+} {}
+do_test boundary3-2.46.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=55
+ ORDER BY t1.rowid DESC
+ }
+} {}
+do_test boundary3-2.46.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=55
+ ORDER BY x
+ }
+} {}
+do_test boundary3-2.46.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -9223372036854775808 ORDER BY t2.a
+ }
+} {55}
+do_test boundary3-2.46.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -9223372036854775808 ORDER BY t1.a DESC
+ }
+} {55}
+do_test boundary3-2.46.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=55
+ ORDER BY t1.rowid
+ }
+} {55}
+do_test boundary3-2.46.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=55
+ ORDER BY t1.rowid DESC
+ }
+} {55}
+do_test boundary3-2.46.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=55
+ ORDER BY x
+ }
+} {55}
+do_test boundary3-2.47.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=562949953421312 AND t2.a=t1.a
+ }
+} {43 0002000000000000}
+do_test boundary3-2.47.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0002000000000000'
+ }
+} {562949953421312 43}
+do_test boundary3-2.47.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=43
+ }
+} {562949953421312 0002000000000000}
+do_test boundary3-2.47.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 562949953421312 ORDER BY t2.a
+ }
+} {3 17 27 28 45}
+do_test boundary3-2.47.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 562949953421312 ORDER BY t1.a DESC
+ }
+} {45 28 27 17 3}
+do_test boundary3-2.47.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=43
+ ORDER BY t1.rowid
+ }
+} {27 45 17 28 3}
+do_test boundary3-2.47.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=43
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27}
+do_test boundary3-2.47.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=43
+ ORDER BY x
+ }
+} {27 45 17 28 3}
+do_test boundary3-2.47.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 562949953421312 ORDER BY t2.a
+ }
+} {3 17 27 28 43 45}
+do_test boundary3-2.47.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 562949953421312 ORDER BY t1.a DESC
+ }
+} {45 43 28 27 17 3}
+do_test boundary3-2.47.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=43
+ ORDER BY t1.rowid
+ }
+} {43 27 45 17 28 3}
+do_test boundary3-2.47.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=43
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43}
+do_test boundary3-2.47.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=43
+ ORDER BY x
+ }
+} {43 27 45 17 28 3}
+do_test boundary3-2.47.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 562949953421312 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.47.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 562949953421312 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.47.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=43
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}
+do_test boundary3-2.47.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=43
+ ORDER BY t1.rowid DESC
+ }
+} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.47.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=43
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.47.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 562949953421312 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.47.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 562949953421312 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.47.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=43
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}
+do_test boundary3-2.47.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=43
+ ORDER BY t1.rowid DESC
+ }
+} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.47.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=43
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.48.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-8388609 AND t2.a=t1.a
+ }
+} {1 ffffffffff7fffff}
+do_test boundary3-2.48.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffff7fffff'
+ }
+} {-8388609 1}
+do_test boundary3-2.48.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=1
+ }
+} {-8388609 ffffffffff7fffff}
+do_test boundary3-2.48.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -8388609 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.48.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -8388609 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.48.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=1
+ ORDER BY t1.rowid
+ }
+} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.48.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=1
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}
+do_test boundary3-2.48.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=1
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}
+do_test boundary3-2.48.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=1
+ ORDER BY t1.rowid
+ }
+} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.48.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=1
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}
+do_test boundary3-2.48.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -8388609 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.48.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -8388609 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.48.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=1
+ ORDER BY t1.rowid
+ }
+} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.48.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=1
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}
+do_test boundary3-2.48.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=1
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.48.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=1
+ ORDER BY t1.rowid
+ }
+} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.48.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=1
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}
+do_test boundary3-2.48.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -8388609 ORDER BY t2.a
+ }
+} {2 11 21 44 47 55 58 63 64}
+do_test boundary3-2.48.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -8388609 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 21 11 2}
+do_test boundary3-2.48.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=1
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary3-2.48.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=1
+ ORDER BY t1.rowid DESC
+ }
+} {11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.48.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=1
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary3-2.48.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=1
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11}
+do_test boundary3-2.48.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=1
+ ORDER BY t1.rowid DESC
+ }
+} {11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.48.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -8388609 ORDER BY t2.a
+ }
+} {1 2 11 21 44 47 55 58 63 64}
+do_test boundary3-2.48.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -8388609 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 21 11 2 1}
+do_test boundary3-2.48.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=1
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary3-2.48.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=1
+ ORDER BY t1.rowid DESC
+ }
+} {1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.48.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=1
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary3-2.48.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=1
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1}
+do_test boundary3-2.48.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=1
+ ORDER BY t1.rowid DESC
+ }
+} {1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.49.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=16777215 AND t2.a=t1.a
+ }
+} {9 0000000000ffffff}
+do_test boundary3-2.49.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000ffffff'
+ }
+} {16777215 9}
+do_test boundary3-2.49.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=9
+ }
+} {16777215 0000000000ffffff}
+do_test boundary3-2.49.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 16777215 ORDER BY t2.a
+ }
+} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.49.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 16777215 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}
+do_test boundary3-2.49.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=9
+ ORDER BY t1.rowid
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.49.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=9
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}
+do_test boundary3-2.49.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=9
+ ORDER BY x
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.49.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=9
+ ORDER BY t1.rowid
+ }
+} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.49.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=9
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}
+do_test boundary3-2.49.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 16777215 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.49.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 16777215 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary3-2.49.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=9
+ ORDER BY t1.rowid
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.49.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=9
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}
+do_test boundary3-2.49.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=9
+ ORDER BY x
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.49.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=9
+ ORDER BY t1.rowid
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.49.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=9
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}
+do_test boundary3-2.49.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 16777215 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.49.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 16777215 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary3-2.49.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=9
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}
+do_test boundary3-2.49.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=9
+ ORDER BY t1.rowid DESC
+ }
+} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.49.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=9
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.49.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=9
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}
+do_test boundary3-2.49.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=9
+ ORDER BY t1.rowid DESC
+ }
+} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.49.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 16777215 ORDER BY t2.a
+ }
+} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.49.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 16777215 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}
+do_test boundary3-2.49.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=9
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}
+do_test boundary3-2.49.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=9
+ ORDER BY t1.rowid DESC
+ }
+} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.49.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=9
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.49.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=9
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}
+do_test boundary3-2.49.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=9
+ ORDER BY t1.rowid DESC
+ }
+} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.50.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=8388608 AND t2.a=t1.a
+ }
+} {24 0000000000800000}
+do_test boundary3-2.50.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000800000'
+ }
+} {8388608 24}
+do_test boundary3-2.50.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=24
+ }
+} {8388608 0000000000800000}
+do_test boundary3-2.50.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 8388608 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.50.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 8388608 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary3-2.50.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=24
+ ORDER BY t1.rowid
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.50.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=24
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}
+do_test boundary3-2.50.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=24
+ ORDER BY x
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.50.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=24
+ ORDER BY t1.rowid
+ }
+} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.50.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=24
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}
+do_test boundary3-2.50.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 8388608 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}
+do_test boundary3-2.50.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 8388608 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}
+do_test boundary3-2.50.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=24
+ ORDER BY t1.rowid
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.50.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=24
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}
+do_test boundary3-2.50.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=24
+ ORDER BY x
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.50.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=24
+ ORDER BY t1.rowid
+ }
+} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.50.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=24
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}
+do_test boundary3-2.50.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 8388608 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.50.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 8388608 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary3-2.50.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=24
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}
+do_test boundary3-2.50.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=24
+ ORDER BY t1.rowid DESC
+ }
+} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.50.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=24
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.50.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=24
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}
+do_test boundary3-2.50.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=24
+ ORDER BY t1.rowid DESC
+ }
+} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.50.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 8388608 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.50.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 8388608 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}
+do_test boundary3-2.50.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=24
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}
+do_test boundary3-2.50.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=24
+ ORDER BY t1.rowid DESC
+ }
+} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.50.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=24
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.50.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=24
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}
+do_test boundary3-2.50.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=24
+ ORDER BY t1.rowid DESC
+ }
+} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.51.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=16383 AND t2.a=t1.a
+ }
+} {8 0000000000003fff}
+do_test boundary3-2.51.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000003fff'
+ }
+} {16383 8}
+do_test boundary3-2.51.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=8
+ }
+} {16383 0000000000003fff}
+do_test boundary3-2.51.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 16383 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary3-2.51.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 16383 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.51.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=8
+ ORDER BY t1.rowid
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.51.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=8
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}
+do_test boundary3-2.51.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=8
+ ORDER BY x
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.51.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=8
+ ORDER BY t1.rowid
+ }
+} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.51.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=8
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}
+do_test boundary3-2.51.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 16383 ORDER BY t2.a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary3-2.51.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 16383 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary3-2.51.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=8
+ ORDER BY t1.rowid
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.51.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=8
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}
+do_test boundary3-2.51.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=8
+ ORDER BY x
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.51.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=8
+ ORDER BY t1.rowid
+ }
+} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.51.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=8
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}
+do_test boundary3-2.51.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 16383 ORDER BY t2.a
+ }
+} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.51.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 16383 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}
+do_test boundary3-2.51.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=8
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}
+do_test boundary3-2.51.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=8
+ ORDER BY t1.rowid DESC
+ }
+} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.51.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=8
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.51.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=8
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}
+do_test boundary3-2.51.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=8
+ ORDER BY t1.rowid DESC
+ }
+} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.51.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 16383 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.51.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 16383 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}
+do_test boundary3-2.51.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=8
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}
+do_test boundary3-2.51.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=8
+ ORDER BY t1.rowid DESC
+ }
+} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.51.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=8
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.51.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=8
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}
+do_test boundary3-2.51.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=8
+ ORDER BY t1.rowid DESC
+ }
+} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.52.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=140737488355328 AND t2.a=t1.a
+ }
+} {34 0000800000000000}
+do_test boundary3-2.52.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000800000000000'
+ }
+} {140737488355328 34}
+do_test boundary3-2.52.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=34
+ }
+} {140737488355328 0000800000000000}
+do_test boundary3-2.52.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 140737488355328 ORDER BY t2.a
+ }
+} {3 10 13 17 26 27 28 43 45}
+do_test boundary3-2.52.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 140737488355328 ORDER BY t1.a DESC
+ }
+} {45 43 28 27 26 17 13 10 3}
+do_test boundary3-2.52.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=34
+ ORDER BY t1.rowid
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.52.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=34
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10}
+do_test boundary3-2.52.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=34
+ ORDER BY x
+ }
+} {10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.52.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 140737488355328 ORDER BY t2.a
+ }
+} {3 10 13 17 26 27 28 34 43 45}
+do_test boundary3-2.52.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 140737488355328 ORDER BY t1.a DESC
+ }
+} {45 43 34 28 27 26 17 13 10 3}
+do_test boundary3-2.52.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=34
+ ORDER BY t1.rowid
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.52.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=34
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34}
+do_test boundary3-2.52.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=34
+ ORDER BY x
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.52.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 140737488355328 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.52.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 140737488355328 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary3-2.52.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=34
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}
+do_test boundary3-2.52.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=34
+ ORDER BY t1.rowid DESC
+ }
+} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.52.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=34
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.52.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 140737488355328 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.52.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 140737488355328 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary3-2.52.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=34
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}
+do_test boundary3-2.52.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=34
+ ORDER BY t1.rowid DESC
+ }
+} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.52.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=34
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.53.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=2097151 AND t2.a=t1.a
+ }
+} {15 00000000001fffff}
+do_test boundary3-2.53.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00000000001fffff'
+ }
+} {2097151 15}
+do_test boundary3-2.53.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=15
+ }
+} {2097151 00000000001fffff}
+do_test boundary3-2.53.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 2097151 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary3-2.53.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 2097151 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}
+do_test boundary3-2.53.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=15
+ ORDER BY t1.rowid
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.53.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=15
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}
+do_test boundary3-2.53.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=15
+ ORDER BY x
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.53.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=15
+ ORDER BY t1.rowid
+ }
+} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.53.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=15
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}
+do_test boundary3-2.53.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 2097151 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}
+do_test boundary3-2.53.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 2097151 ORDER BY t1.a DESC
+ }
+} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.53.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=15
+ ORDER BY t1.rowid
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.53.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=15
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}
+do_test boundary3-2.53.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=15
+ ORDER BY x
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.53.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=15
+ ORDER BY t1.rowid
+ }
+} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.53.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=15
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}
+do_test boundary3-2.53.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 2097151 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.53.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 2097151 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary3-2.53.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=15
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}
+do_test boundary3-2.53.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=15
+ ORDER BY t1.rowid DESC
+ }
+} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.53.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=15
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.53.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=15
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}
+do_test boundary3-2.53.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=15
+ ORDER BY t1.rowid DESC
+ }
+} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.53.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 2097151 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}
+do_test boundary3-2.53.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 2097151 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}
+do_test boundary3-2.53.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=15
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}
+do_test boundary3-2.53.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=15
+ ORDER BY t1.rowid DESC
+ }
+} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.53.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=15
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.53.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=15
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}
+do_test boundary3-2.53.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=15
+ ORDER BY t1.rowid DESC
+ }
+} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.54.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=140737488355327 AND t2.a=t1.a
+ }
+} {25 00007fffffffffff}
+do_test boundary3-2.54.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00007fffffffffff'
+ }
+} {140737488355327 25}
+do_test boundary3-2.54.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=25
+ }
+} {140737488355327 00007fffffffffff}
+do_test boundary3-2.54.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 140737488355327 ORDER BY t2.a
+ }
+} {3 10 13 17 26 27 28 34 43 45}
+do_test boundary3-2.54.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 140737488355327 ORDER BY t1.a DESC
+ }
+} {45 43 34 28 27 26 17 13 10 3}
+do_test boundary3-2.54.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=25
+ ORDER BY t1.rowid
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.54.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=25
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34}
+do_test boundary3-2.54.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=25
+ ORDER BY x
+ }
+} {34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.54.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 140737488355327 ORDER BY t2.a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45}
+do_test boundary3-2.54.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 140737488355327 ORDER BY t1.a DESC
+ }
+} {45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary3-2.54.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=25
+ ORDER BY t1.rowid
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.54.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=25
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25}
+do_test boundary3-2.54.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=25
+ ORDER BY x
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.54.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 140737488355327 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.54.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 140737488355327 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary3-2.54.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=25
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}
+do_test boundary3-2.54.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=25
+ ORDER BY t1.rowid DESC
+ }
+} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.54.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=25
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.54.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 140737488355327 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.54.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 140737488355327 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary3-2.54.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=25
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}
+do_test boundary3-2.54.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=25
+ ORDER BY t1.rowid DESC
+ }
+} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.54.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=25
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.55.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=281474976710656 AND t2.a=t1.a
+ }
+} {26 0001000000000000}
+do_test boundary3-2.55.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0001000000000000'
+ }
+} {281474976710656 26}
+do_test boundary3-2.55.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=26
+ }
+} {281474976710656 0001000000000000}
+do_test boundary3-2.55.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 281474976710656 ORDER BY t2.a
+ }
+} {3 13 17 27 28 43 45}
+do_test boundary3-2.55.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 281474976710656 ORDER BY t1.a DESC
+ }
+} {45 43 28 27 17 13 3}
+do_test boundary3-2.55.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=26
+ ORDER BY t1.rowid
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary3-2.55.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=26
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13}
+do_test boundary3-2.55.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=26
+ ORDER BY x
+ }
+} {13 43 27 45 17 28 3}
+do_test boundary3-2.55.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 281474976710656 ORDER BY t2.a
+ }
+} {3 13 17 26 27 28 43 45}
+do_test boundary3-2.55.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 281474976710656 ORDER BY t1.a DESC
+ }
+} {45 43 28 27 26 17 13 3}
+do_test boundary3-2.55.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=26
+ ORDER BY t1.rowid
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary3-2.55.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=26
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26}
+do_test boundary3-2.55.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=26
+ ORDER BY x
+ }
+} {26 13 43 27 45 17 28 3}
+do_test boundary3-2.55.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 281474976710656 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.55.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 281474976710656 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.55.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=26
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}
+do_test boundary3-2.55.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=26
+ ORDER BY t1.rowid DESC
+ }
+} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.55.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=26
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.55.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 281474976710656 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.55.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 281474976710656 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.55.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=26
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}
+do_test boundary3-2.55.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=26
+ ORDER BY t1.rowid DESC
+ }
+} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.55.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=26
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.56.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=32767 AND t2.a=t1.a
+ }
+} {23 0000000000007fff}
+do_test boundary3-2.56.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000007fff'
+ }
+} {32767 23}
+do_test boundary3-2.56.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=23
+ }
+} {32767 0000000000007fff}
+do_test boundary3-2.56.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 32767 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary3-2.56.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 32767 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.56.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=23
+ ORDER BY t1.rowid
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.56.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=23
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}
+do_test boundary3-2.56.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=23
+ ORDER BY x
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.56.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=23
+ ORDER BY t1.rowid
+ }
+} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.56.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=23
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}
+do_test boundary3-2.56.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 32767 ORDER BY t2.a
+ }
+} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}
+do_test boundary3-2.56.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 32767 ORDER BY t1.a DESC
+ }
+} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}
+do_test boundary3-2.56.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=23
+ ORDER BY t1.rowid
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.56.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=23
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}
+do_test boundary3-2.56.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=23
+ ORDER BY x
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.56.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=23
+ ORDER BY t1.rowid
+ }
+} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.56.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=23
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}
+do_test boundary3-2.56.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 32767 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.56.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 32767 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}
+do_test boundary3-2.56.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=23
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}
+do_test boundary3-2.56.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=23
+ ORDER BY t1.rowid DESC
+ }
+} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.56.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=23
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.56.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=23
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}
+do_test boundary3-2.56.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=23
+ ORDER BY t1.rowid DESC
+ }
+} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.56.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 32767 ORDER BY t2.a
+ }
+} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}
+do_test boundary3-2.56.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 32767 ORDER BY t1.a DESC
+ }
+} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}
+do_test boundary3-2.56.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=23
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}
+do_test boundary3-2.56.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=23
+ ORDER BY t1.rowid DESC
+ }
+} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.56.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=23
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.56.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=23
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}
+do_test boundary3-2.56.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=23
+ ORDER BY t1.rowid DESC
+ }
+} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.57.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=127 AND t2.a=t1.a
+ }
+} {4 000000000000007f}
+do_test boundary3-2.57.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000000000000007f'
+ }
+} {127 4}
+do_test boundary3-2.57.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=4
+ }
+} {127 000000000000007f}
+do_test boundary3-2.57.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 127 ORDER BY t2.a
+ }
+} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary3-2.57.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 127 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}
+do_test boundary3-2.57.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=4
+ ORDER BY t1.rowid
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.57.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=4
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}
+do_test boundary3-2.57.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=4
+ ORDER BY x
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.57.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=4
+ ORDER BY t1.rowid
+ }
+} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.57.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=4
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}
+do_test boundary3-2.57.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 127 ORDER BY t2.a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary3-2.57.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 127 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary3-2.57.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=4
+ ORDER BY t1.rowid
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.57.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=4
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}
+do_test boundary3-2.57.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=4
+ ORDER BY x
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.57.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=4
+ ORDER BY t1.rowid
+ }
+} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.57.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=4
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}
+do_test boundary3-2.57.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 127 ORDER BY t2.a
+ }
+} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.57.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 127 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}
+do_test boundary3-2.57.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=4
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}
+do_test boundary3-2.57.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=4
+ ORDER BY t1.rowid DESC
+ }
+} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.57.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=4
+ ORDER BY x
+ }
+} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.57.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=4
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}
+do_test boundary3-2.57.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=4
+ ORDER BY t1.rowid DESC
+ }
+} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.57.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 127 ORDER BY t2.a
+ }
+} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.57.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 127 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}
+do_test boundary3-2.57.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=4
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}
+do_test boundary3-2.57.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=4
+ ORDER BY t1.rowid DESC
+ }
+} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.57.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=4
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.57.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=4
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}
+do_test boundary3-2.57.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=4
+ ORDER BY t1.rowid DESC
+ }
+} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.58.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=36028797018963967 AND t2.a=t1.a
+ }
+} {27 007fffffffffffff}
+do_test boundary3-2.58.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='007fffffffffffff'
+ }
+} {36028797018963967 27}
+do_test boundary3-2.58.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=27
+ }
+} {36028797018963967 007fffffffffffff}
+do_test boundary3-2.58.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 36028797018963967 ORDER BY t2.a
+ }
+} {3 17 28 45}
+do_test boundary3-2.58.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 36028797018963967 ORDER BY t1.a DESC
+ }
+} {45 28 17 3}
+do_test boundary3-2.58.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=27
+ ORDER BY t1.rowid
+ }
+} {45 17 28 3}
+do_test boundary3-2.58.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=27
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45}
+do_test boundary3-2.58.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=27
+ ORDER BY x
+ }
+} {45 17 28 3}
+do_test boundary3-2.58.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 36028797018963967 ORDER BY t2.a
+ }
+} {3 17 27 28 45}
+do_test boundary3-2.58.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 36028797018963967 ORDER BY t1.a DESC
+ }
+} {45 28 27 17 3}
+do_test boundary3-2.58.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=27
+ ORDER BY t1.rowid
+ }
+} {27 45 17 28 3}
+do_test boundary3-2.58.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=27
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27}
+do_test boundary3-2.58.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=27
+ ORDER BY x
+ }
+} {27 45 17 28 3}
+do_test boundary3-2.58.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 36028797018963967 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.58.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 36028797018963967 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.58.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=27
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}
+do_test boundary3-2.58.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=27
+ ORDER BY t1.rowid DESC
+ }
+} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.58.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=27
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.58.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 36028797018963967 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.58.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 36028797018963967 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.58.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=27
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}
+do_test boundary3-2.58.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=27
+ ORDER BY t1.rowid DESC
+ }
+} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.58.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=27
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.59.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=4398046511104 AND t2.a=t1.a
+ }
+} {56 0000040000000000}
+do_test boundary3-2.59.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000040000000000'
+ }
+} {4398046511104 56}
+do_test boundary3-2.59.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=56
+ }
+} {4398046511104 0000040000000000}
+do_test boundary3-2.59.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 4398046511104 ORDER BY t2.a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45}
+do_test boundary3-2.59.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 4398046511104 ORDER BY t1.a DESC
+ }
+} {45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary3-2.59.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=56
+ ORDER BY t1.rowid
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.59.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=56
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25}
+do_test boundary3-2.59.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=56
+ ORDER BY x
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.59.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=56
+ ORDER BY t1.rowid
+ }
+} {25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.59.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=56
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25}
+do_test boundary3-2.59.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 4398046511104 ORDER BY t2.a
+ }
+} {3 10 13 17 25 26 27 28 34 43 45 56}
+do_test boundary3-2.59.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 4398046511104 ORDER BY t1.a DESC
+ }
+} {56 45 43 34 28 27 26 25 17 13 10 3}
+do_test boundary3-2.59.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=56
+ ORDER BY t1.rowid
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.59.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=56
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56}
+do_test boundary3-2.59.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=56
+ ORDER BY x
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.59.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=56
+ ORDER BY t1.rowid
+ }
+} {56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.59.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=56
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56}
+do_test boundary3-2.59.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 4398046511104 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}
+do_test boundary3-2.59.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 4398046511104 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary3-2.59.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=56
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}
+do_test boundary3-2.59.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=56
+ ORDER BY t1.rowid DESC
+ }
+} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.59.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=56
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.59.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=56
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}
+do_test boundary3-2.59.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=56
+ ORDER BY t1.rowid DESC
+ }
+} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.59.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 4398046511104 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.59.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 4398046511104 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}
+do_test boundary3-2.59.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=56
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}
+do_test boundary3-2.59.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=56
+ ORDER BY t1.rowid DESC
+ }
+} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.59.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=56
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.59.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=56
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}
+do_test boundary3-2.59.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=56
+ ORDER BY t1.rowid DESC
+ }
+} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.60.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=1 AND t2.a=t1.a
+ }
+} {60 0000000000000001}
+do_test boundary3-2.60.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000001'
+ }
+} {1 60}
+do_test boundary3-2.60.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=60
+ }
+} {1 0000000000000001}
+do_test boundary3-2.60.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 1 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary3-2.60.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 1 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.60.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=60
+ ORDER BY t1.rowid
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.60.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=60
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}
+do_test boundary3-2.60.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=60
+ ORDER BY x
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.60.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=60
+ ORDER BY t1.rowid
+ }
+} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.60.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=60
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}
+do_test boundary3-2.60.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 1 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}
+do_test boundary3-2.60.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 1 ORDER BY t1.a DESC
+ }
+} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.60.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=60
+ ORDER BY t1.rowid
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.60.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=60
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}
+do_test boundary3-2.60.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=60
+ ORDER BY x
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.60.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=60
+ ORDER BY t1.rowid
+ }
+} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.60.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=60
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}
+do_test boundary3-2.60.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 1 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}
+do_test boundary3-2.60.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 1 ORDER BY t1.a DESC
+ }
+} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary3-2.60.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=60
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}
+do_test boundary3-2.60.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=60
+ ORDER BY t1.rowid DESC
+ }
+} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.60.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=60
+ ORDER BY x
+ }
+} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.60.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=60
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}
+do_test boundary3-2.60.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=60
+ ORDER BY t1.rowid DESC
+ }
+} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.60.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 1 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.60.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 1 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}
+do_test boundary3-2.60.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=60
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}
+do_test boundary3-2.60.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=60
+ ORDER BY t1.rowid DESC
+ }
+} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.60.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=60
+ ORDER BY x
+ }
+} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.60.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=60
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}
+do_test boundary3-2.60.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=60
+ ORDER BY t1.rowid DESC
+ }
+} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.61.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=36028797018963968 AND t2.a=t1.a
+ }
+} {45 0080000000000000}
+do_test boundary3-2.61.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0080000000000000'
+ }
+} {36028797018963968 45}
+do_test boundary3-2.61.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=45
+ }
+} {36028797018963968 0080000000000000}
+do_test boundary3-2.61.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 36028797018963968 ORDER BY t2.a
+ }
+} {3 17 28}
+do_test boundary3-2.61.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 36028797018963968 ORDER BY t1.a DESC
+ }
+} {28 17 3}
+do_test boundary3-2.61.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=45
+ ORDER BY t1.rowid
+ }
+} {17 28 3}
+do_test boundary3-2.61.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=45
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17}
+do_test boundary3-2.61.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=45
+ ORDER BY x
+ }
+} {17 28 3}
+do_test boundary3-2.61.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 36028797018963968 ORDER BY t2.a
+ }
+} {3 17 28 45}
+do_test boundary3-2.61.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 36028797018963968 ORDER BY t1.a DESC
+ }
+} {45 28 17 3}
+do_test boundary3-2.61.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=45
+ ORDER BY t1.rowid
+ }
+} {45 17 28 3}
+do_test boundary3-2.61.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=45
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45}
+do_test boundary3-2.61.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=45
+ ORDER BY x
+ }
+} {45 17 28 3}
+do_test boundary3-2.61.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 36028797018963968 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.61.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 36028797018963968 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.61.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=45
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}
+do_test boundary3-2.61.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=45
+ ORDER BY t1.rowid DESC
+ }
+} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.61.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=45
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.61.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 36028797018963968 ORDER BY t2.a
+ }
+} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.61.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 36028797018963968 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}
+do_test boundary3-2.61.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=45
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}
+do_test boundary3-2.61.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=45
+ ORDER BY t1.rowid DESC
+ }
+} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.61.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=45
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.62.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-2147483649 AND t2.a=t1.a
+ }
+} {47 ffffffff7fffffff}
+do_test boundary3-2.62.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffff7fffffff'
+ }
+} {-2147483649 47}
+do_test boundary3-2.62.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=47
+ }
+} {-2147483649 ffffffff7fffffff}
+do_test boundary3-2.62.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -2147483649 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.62.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -2147483649 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.62.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=47
+ ORDER BY t1.rowid
+ }
+} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.62.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=47
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}
+do_test boundary3-2.62.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=47
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.62.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=47
+ ORDER BY t1.rowid
+ }
+} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.62.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=47
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}
+do_test boundary3-2.62.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -2147483649 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}
+do_test boundary3-2.62.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -2147483649 ORDER BY t1.a DESC
+ }
+} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.62.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=47
+ ORDER BY t1.rowid
+ }
+} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.62.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=47
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}
+do_test boundary3-2.62.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=47
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.62.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=47
+ ORDER BY t1.rowid
+ }
+} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.62.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=47
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}
+do_test boundary3-2.62.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -2147483649 ORDER BY t2.a
+ }
+} {2 21 44 55 58 63 64}
+do_test boundary3-2.62.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -2147483649 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 44 21 2}
+do_test boundary3-2.62.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=47
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary3-2.62.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=47
+ ORDER BY t1.rowid DESC
+ }
+} {63 58 44 21 64 2 55}
+do_test boundary3-2.62.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=47
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary3-2.62.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=47
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63}
+do_test boundary3-2.62.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=47
+ ORDER BY t1.rowid DESC
+ }
+} {63 58 44 21 64 2 55}
+do_test boundary3-2.62.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -2147483649 ORDER BY t2.a
+ }
+} {2 21 44 47 55 58 63 64}
+do_test boundary3-2.62.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -2147483649 ORDER BY t1.a DESC
+ }
+} {64 63 58 55 47 44 21 2}
+do_test boundary3-2.62.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=47
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary3-2.62.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=47
+ ORDER BY t1.rowid DESC
+ }
+} {47 63 58 44 21 64 2 55}
+do_test boundary3-2.62.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=47
+ ORDER BY x
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary3-2.62.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=47
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47}
+do_test boundary3-2.62.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=47
+ ORDER BY t1.rowid DESC
+ }
+} {47 63 58 44 21 64 2 55}
+do_test boundary3-2.63.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=-36028797018963969 AND t2.a=t1.a
+ }
+} {2 ff7fffffffffffff}
+do_test boundary3-2.63.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ff7fffffffffffff'
+ }
+} {-36028797018963969 2}
+do_test boundary3-2.63.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=2
+ }
+} {-36028797018963969 ff7fffffffffffff}
+do_test boundary3-2.63.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -36028797018963969 ORDER BY t2.a
+ }
+} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.63.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -36028797018963969 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}
+do_test boundary3-2.63.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=2
+ ORDER BY t1.rowid
+ }
+} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.63.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=2
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}
+do_test boundary3-2.63.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=2
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.63.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -36028797018963969 ORDER BY t2.a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.63.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -36028797018963969 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary3-2.63.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=2
+ ORDER BY t1.rowid
+ }
+} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.63.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=2
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}
+do_test boundary3-2.63.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=2
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.63.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -36028797018963969 ORDER BY t2.a
+ }
+} {55}
+do_test boundary3-2.63.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -36028797018963969 ORDER BY t1.a DESC
+ }
+} {55}
+do_test boundary3-2.63.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=2
+ ORDER BY t1.rowid
+ }
+} {55}
+do_test boundary3-2.63.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=2
+ ORDER BY t1.rowid DESC
+ }
+} {55}
+do_test boundary3-2.63.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=2
+ ORDER BY x
+ }
+} {55}
+do_test boundary3-2.63.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -36028797018963969 ORDER BY t2.a
+ }
+} {2 55}
+do_test boundary3-2.63.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -36028797018963969 ORDER BY t1.a DESC
+ }
+} {55 2}
+do_test boundary3-2.63.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=2
+ ORDER BY t1.rowid
+ }
+} {55 2}
+do_test boundary3-2.63.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=2
+ ORDER BY t1.rowid DESC
+ }
+} {2 55}
+do_test boundary3-2.63.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=2
+ ORDER BY x
+ }
+} {55 2}
+do_test boundary3-2.64.1 {
+ db eval {
+ SELECT t1.* FROM t1, t2 WHERE t1.rowid=3 AND t2.a=t1.a
+ }
+} {5 0000000000000003}
+do_test boundary3-2.64.2 {
+ db eval {
+ SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000003'
+ }
+} {3 5}
+do_test boundary3-2.64.3 {
+ db eval {
+ SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=5
+ }
+} {3 0000000000000003}
+do_test boundary3-2.64.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 3 ORDER BY t2.a
+ }
+} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary3-2.64.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 3 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}
+do_test boundary3-2.64.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=5
+ ORDER BY t1.rowid
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.64.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=5
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}
+do_test boundary3-2.64.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=5
+ ORDER BY x
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.64.gt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=5
+ ORDER BY t1.rowid
+ }
+} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.64.gt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)
+ WHERE t2.a=5
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}
+do_test boundary3-2.64.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 3 ORDER BY t2.a
+ }
+} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}
+do_test boundary3-2.64.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 3 ORDER BY t1.a DESC
+ }
+} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}
+do_test boundary3-2.64.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=5
+ ORDER BY t1.rowid
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.64.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=5
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}
+do_test boundary3-2.64.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=5
+ ORDER BY x
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.64.ge.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=5
+ ORDER BY t1.rowid
+ }
+} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.64.ge.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)
+ WHERE t2.a=5
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}
+do_test boundary3-2.64.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 3 ORDER BY t2.a
+ }
+} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.64.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 3 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}
+do_test boundary3-2.64.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=5
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}
+do_test boundary3-2.64.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=5
+ ORDER BY t1.rowid DESC
+ }
+} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.64.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=5
+ ORDER BY x
+ }
+} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.64.lt.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=5
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}
+do_test boundary3-2.64.lt.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)
+ WHERE t2.a=5
+ ORDER BY t1.rowid DESC
+ }
+} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.64.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 3 ORDER BY t2.a
+ }
+} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}
+do_test boundary3-2.64.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 3 ORDER BY t1.a DESC
+ }
+} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}
+do_test boundary3-2.64.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=5
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}
+do_test boundary3-2.64.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=5
+ ORDER BY t1.rowid DESC
+ }
+} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.64.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=5
+ ORDER BY x
+ }
+} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.64.le.10 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=5
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}
+do_test boundary3-2.64.le.11 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)
+ WHERE t2.a=5
+ ORDER BY t1.rowid DESC
+ }
+} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.65.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > 9.22337303685477580800e+18 ORDER BY t2.a
+ }
+} {}
+do_test boundary3-2.65.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > 9.22337303685477580800e+18 ORDER BY t1.a DESC
+ }
+} {}
+do_test boundary3-2.65.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=65
+ ORDER BY t1.rowid
+ }
+} {}
+do_test boundary3-2.65.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=65
+ ORDER BY t1.rowid DESC
+ }
+} {}
+do_test boundary3-2.65.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=65
+ ORDER BY x
+ }
+} {}
+do_test boundary3-2.65.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= 9.22337303685477580800e+18 ORDER BY t2.a
+ }
+} {}
+do_test boundary3-2.65.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= 9.22337303685477580800e+18 ORDER BY t1.a DESC
+ }
+} {}
+do_test boundary3-2.65.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=65
+ ORDER BY t1.rowid
+ }
+} {}
+do_test boundary3-2.65.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=65
+ ORDER BY t1.rowid DESC
+ }
+} {}
+do_test boundary3-2.65.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=65
+ ORDER BY x
+ }
+} {}
+do_test boundary3-2.65.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < 9.22337303685477580800e+18 ORDER BY t2.a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.65.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < 9.22337303685477580800e+18 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary3-2.65.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=65
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.65.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=65
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.65.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=65
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.65.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= 9.22337303685477580800e+18 ORDER BY t2.a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.65.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= 9.22337303685477580800e+18 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary3-2.65.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=65
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.65.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=65
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.65.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=65
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.66.gt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid > -9.22337303685477580800e+18 ORDER BY t2.a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.66.gt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid > -9.22337303685477580800e+18 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary3-2.66.gt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=66
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.66.gt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=66
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.66.gt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r
+ WHERE t2.a=66
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.66.ge.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid >= -9.22337303685477580800e+18 ORDER BY t2.a
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}
+do_test boundary3-2.66.ge.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid >= -9.22337303685477580800e+18 ORDER BY t1.a DESC
+ }
+} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
+do_test boundary3-2.66.ge.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=66
+ ORDER BY t1.rowid
+ }
+} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}
+do_test boundary3-2.66.ge.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=66
+ ORDER BY t1.rowid DESC
+ }
+} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}
+do_test boundary3-2.66.ge.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r
+ WHERE t2.a=66
+ ORDER BY x
+ }
+} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}
+do_test boundary3-2.66.lt.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid < -9.22337303685477580800e+18 ORDER BY t2.a
+ }
+} {}
+do_test boundary3-2.66.lt.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid < -9.22337303685477580800e+18 ORDER BY t1.a DESC
+ }
+} {}
+do_test boundary3-2.66.lt.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=66
+ ORDER BY t1.rowid
+ }
+} {}
+do_test boundary3-2.66.lt.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=66
+ ORDER BY t1.rowid DESC
+ }
+} {}
+do_test boundary3-2.66.lt.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r
+ WHERE t2.a=66
+ ORDER BY x
+ }
+} {}
+do_test boundary3-2.66.le.1 {
+ db eval {
+ SELECT t2.a FROM t1 JOIN t2 USING(a)
+ WHERE t1.rowid <= -9.22337303685477580800e+18 ORDER BY t2.a
+ }
+} {}
+do_test boundary3-2.66.le.2 {
+ db eval {
+ SELECT t2.a FROM t2 NATURAL JOIN t1
+ WHERE t1.rowid <= -9.22337303685477580800e+18 ORDER BY t1.a DESC
+ }
+} {}
+do_test boundary3-2.66.le.3 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=66
+ ORDER BY t1.rowid
+ }
+} {}
+do_test boundary3-2.66.le.4 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=66
+ ORDER BY t1.rowid DESC
+ }
+} {}
+do_test boundary3-2.66.le.5 {
+ db eval {
+ SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r
+ WHERE t2.a=66
+ ORDER BY x
+ }
+} {}
+finish_test
diff --git a/test/boundary4.tcl b/test/boundary4.tcl
new file mode 100644
index 0000000..20f5c96
--- /dev/null
+++ b/test/boundary4.tcl
@@ -0,0 +1,340 @@
+puts {# 2008 December 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is automatically generated from a separate TCL script.
+# This file seeks to exercise integer boundary values.
+#
+# $Id: boundary4.tcl,v 1.3 2009/01/02 15:45:48 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Many of the boundary tests depend on a working 64-bit implementation.
+if {![working_64bit_int]} { finish_test; return }
+ifcapable !altertable { finish_test; return }
+}
+
+expr srand(0)
+
+# Generate interesting boundary numbers
+#
+foreach x {
+ 0x7f
+ 0x7fff
+ 0x7fffff
+ 0x7fffffff
+ 0x7fffffffff
+ 0x7fffffffffff
+ 0x7fffffffffffff
+ 0x7fffffffffffffff
+} {
+ set x [expr {wide($x)}]
+ set boundarynum($x) 1
+ set boundarynum([expr {$x+1}]) 1
+ set boundarynum([expr {-($x+1)}]) 1
+ set boundarynum([expr {-($x+2)}]) 1
+ set boundarynum([expr {$x+$x+1}]) 1
+ set boundarynum([expr {$x+$x+2}]) 1
+}
+set x [expr {wide(127)}]
+for {set i 127} {$i<=9} {incr i} {
+ set boundarynum($x) 1
+ set boundarynum([expr {$x+1}]) 1
+ set x [expr {wide($x*128 + 127)}]
+}
+
+# Scramble the $inlist into a random order.
+#
+proc scramble {inlist} {
+ set y {}
+ foreach x $inlist {
+ lappend y [list [expr {rand()}] $x]
+ }
+ set y [lsort $y]
+ set outlist {}
+ foreach x $y {
+ lappend outlist [lindex $x 1]
+ }
+ return $outlist
+}
+
+# A simple selection sort. Not trying to be efficient.
+#
+proc sort {inlist} {
+ set outlist {}
+ set mn [lindex $inlist 0]
+ foreach x $inlist {
+ if {$x<$mn} {set mn $x}
+ }
+ set outlist $mn
+ set mx $mn
+ while {1} {
+ set valid 0
+ foreach x $inlist {
+ if {$x>$mx && (!$valid || $mn>$x)} {
+ set mn $x
+ set valid 1
+ }
+ }
+ if {!$valid} break
+ lappend outlist $mn
+ set mx $mn
+ }
+ return $outlist
+}
+
+# Reverse the order of a list
+#
+proc reverse {inlist} {
+ set i [llength $inlist]
+ set outlist {}
+ for {incr i -1} {$i>=0} {incr i -1} {
+ lappend outlist [lindex $inlist $i]
+ }
+ return $outlist
+}
+
+set nums1 [scramble [array names boundarynum]]
+set nums2 [scramble [array names boundarynum]]
+
+set tname boundary4
+puts "do_test $tname-1.1 \173"
+puts " db eval \173"
+puts " CREATE TABLE t1(a,x);"
+set a 0
+set all_rowid {}
+set all_a {}
+set all_x {}
+foreach r $nums1 {
+ incr a
+ set t1ra($r) $a
+ set t1ar($a) $r
+ set x [format %08x%08x [expr {wide($r)>>32}] $r]
+ set t1rx($r) $x
+ set t1xr($x) $r
+ puts " INSERT INTO t1(oid,a,x) VALUES($r,$a,'$x');"
+ lappend all_rowid $r
+ lappend all_a $a
+ lappend all_x $x
+}
+puts " CREATE INDEX t1i1 ON t1(a);"
+puts " CREATE INDEX t1i2 ON t1(x);"
+puts " \175"
+puts "\175 {}"
+
+puts "do_test $tname-1.2 \173"
+puts " db eval \173"
+puts " SELECT count(*) FROM t1"
+puts " \175"
+puts "\175 {[llength $nums1]}"
+
+proc maketest {tnum sql answer} {
+ puts "do_test $::tname-$tnum \173"
+ puts " db eval \173"
+ puts " $sql"
+ puts " \175"
+ puts "\175 {$answer}"
+}
+
+set ans {}
+foreach r [sort $all_rowid] {
+ lappend ans $r $t1ra($r) $t1rx($r)
+}
+maketest 1.3 {SELECT rowid, a, x FROM t1 ORDER BY +rowid} $ans
+maketest 1.4 {SELECT rowid, a, x FROM t1 ORDER BY rowid} $ans
+
+set ans {}
+foreach r [reverse [sort $all_rowid]] {
+ lappend ans $r $t1ra($r) $t1rx($r)
+}
+maketest 1.5 {SELECT rowid, a, x FROM t1 ORDER BY +rowid DESC} $ans
+maketest 1.6 {SELECT rowid, a, x FROM t1 ORDER BY rowid DESC} $ans
+
+set ans {}
+foreach a [sort $all_a] {
+ set r $t1ar($a)
+ lappend ans $r $a $t1rx($r)
+}
+maketest 1.7 {SELECT rowid, a, x FROM t1 ORDER BY +a} $ans
+maketest 1.8 {SELECT rowid, a, x FROM t1 ORDER BY a} $ans
+
+set ans {}
+foreach a [reverse [sort $all_a]] {
+ set r $t1ar($a)
+ lappend ans $r $a $t1rx($r)
+}
+maketest 1.9 {SELECT rowid, a, x FROM t1 ORDER BY +a DESC} $ans
+maketest 1.10 {SELECT rowid, a, x FROM t1 ORDER BY a DESC} $ans
+
+set ans {}
+foreach x [sort $all_x] {
+ set r $t1xr($x)
+ lappend ans $r $t1ra($r) $x
+}
+maketest 1.11 {SELECT rowid, a, x FROM t1 ORDER BY +x} $ans
+maketest 1.12 {SELECT rowid, a, x FROM t1 ORDER BY x} $ans
+
+set ans {}
+foreach x [reverse [sort $all_x]] {
+ set r $t1xr($x)
+ lappend ans $r $t1ra($r) $x
+}
+maketest 1.13 {SELECT rowid, a, x FROM t1 ORDER BY +x DESC} $ans
+maketest 1.14 {SELECT rowid, a, x FROM t1 ORDER BY x DESC} $ans
+
+maketest 2.1 {UPDATE t1 SET rowid=a, a=rowid} {}
+
+set ans {}
+foreach r [sort $all_rowid] {
+ lappend ans $r $t1ra($r) $t1rx($r)
+}
+maketest 2.3 {SELECT a, rowid, x FROM t1 ORDER BY +a} $ans
+maketest 2.4 {SELECT a, rowid, x FROM t1 ORDER BY a} $ans
+
+set ans {}
+foreach r [reverse [sort $all_rowid]] {
+ lappend ans $r $t1ra($r) $t1rx($r)
+}
+maketest 2.5 {SELECT a, rowid, x FROM t1 ORDER BY +a DESC} $ans
+maketest 2.6 {SELECT a, rowid, x FROM t1 ORDER BY a DESC} $ans
+
+set ans {}
+foreach a [sort $all_a] {
+ set r $t1ar($a)
+ lappend ans $r $a $t1rx($r)
+}
+maketest 2.7 {SELECT a, rowid, x FROM t1 ORDER BY +rowid} $ans
+maketest 2.8 {SELECT a, rowid, x FROM t1 ORDER BY rowid} $ans
+
+set ans {}
+foreach a [reverse [sort $all_a]] {
+ set r $t1ar($a)
+ lappend ans $r $a $t1rx($r)
+}
+maketest 2.9 {SELECT a, rowid, x FROM t1 ORDER BY +rowid DESC} $ans
+maketest 2.10 {SELECT a, rowid, x FROM t1 ORDER BY rowid DESC} $ans
+
+set ans {}
+foreach x [sort $all_x] {
+ set r $t1xr($x)
+ lappend ans $r $t1ra($r) $x
+}
+maketest 2.11 {SELECT a, rowid, x FROM t1 ORDER BY +x} $ans
+maketest 2.12 {SELECT a, rowid, x FROM t1 ORDER BY x} $ans
+
+set ans {}
+foreach x [reverse [sort $all_x]] {
+ set r $t1xr($x)
+ lappend ans $r $t1ra($r) $x
+}
+maketest 2.13 {SELECT a, rowid, x FROM t1 ORDER BY +x DESC} $ans
+maketest 2.14 {SELECT a, rowid, x FROM t1 ORDER BY x DESC} $ans
+
+maketest 3.1 {UPDATE t1 SET rowid=a, a=rowid} {}
+maketest 3.2 {ALTER TABLE t1 ADD COLUMN z; UPDATE t1 SET z=zeroblob(600)} {}
+
+set ans {}
+foreach r [sort $all_rowid] {
+ lappend ans $r $t1ra($r) $t1rx($r)
+}
+maketest 3.3 {SELECT rowid, a, x FROM t1 ORDER BY +rowid} $ans
+maketest 3.4 {SELECT rowid, a, x FROM t1 ORDER BY rowid} $ans
+
+set ans {}
+foreach r [reverse [sort $all_rowid]] {
+ lappend ans $r $t1ra($r) $t1rx($r)
+}
+maketest 3.5 {SELECT rowid, a, x FROM t1 ORDER BY +rowid DESC} $ans
+maketest 3.6 {SELECT rowid, a, x FROM t1 ORDER BY rowid DESC} $ans
+
+set ans {}
+foreach a [sort $all_a] {
+ set r $t1ar($a)
+ lappend ans $r $a $t1rx($r)
+}
+maketest 3.7 {SELECT rowid, a, x FROM t1 ORDER BY +a} $ans
+maketest 3.8 {SELECT rowid, a, x FROM t1 ORDER BY a} $ans
+
+set ans {}
+foreach a [reverse [sort $all_a]] {
+ set r $t1ar($a)
+ lappend ans $r $a $t1rx($r)
+}
+maketest 3.9 {SELECT rowid, a, x FROM t1 ORDER BY +a DESC} $ans
+maketest 3.10 {SELECT rowid, a, x FROM t1 ORDER BY a DESC} $ans
+
+set ans {}
+foreach x [sort $all_x] {
+ set r $t1xr($x)
+ lappend ans $r $t1ra($r) $x
+}
+maketest 3.11 {SELECT rowid, a, x FROM t1 ORDER BY +x} $ans
+maketest 3.12 {SELECT rowid, a, x FROM t1 ORDER BY x} $ans
+
+set ans {}
+foreach x [reverse [sort $all_x]] {
+ set r $t1xr($x)
+ lappend ans $r $t1ra($r) $x
+}
+maketest 3.13 {SELECT rowid, a, x FROM t1 ORDER BY +x DESC} $ans
+maketest 3.14 {SELECT rowid, a, x FROM t1 ORDER BY x DESC} $ans
+
+
+maketest 4.1 {UPDATE t1 SET rowid=a, a=rowid, x=z, z=x} {}
+
+set ans {}
+foreach r [sort $all_rowid] {
+ lappend ans $r $t1ra($r) $t1rx($r)
+}
+maketest 4.3 {SELECT a, rowid, z FROM t1 ORDER BY +a} $ans
+maketest 4.4 {SELECT a, rowid, z FROM t1 ORDER BY a} $ans
+
+set ans {}
+foreach r [reverse [sort $all_rowid]] {
+ lappend ans $r $t1ra($r) $t1rx($r)
+}
+maketest 4.5 {SELECT a, rowid, z FROM t1 ORDER BY +a DESC} $ans
+maketest 4.6 {SELECT a, rowid, z FROM t1 ORDER BY a DESC} $ans
+
+set ans {}
+foreach a [sort $all_a] {
+ set r $t1ar($a)
+ lappend ans $r $a $t1rx($r)
+}
+maketest 4.7 {SELECT a, rowid, z FROM t1 ORDER BY +rowid} $ans
+maketest 4.8 {SELECT a, rowid, z FROM t1 ORDER BY rowid} $ans
+
+set ans {}
+foreach a [reverse [sort $all_a]] {
+ set r $t1ar($a)
+ lappend ans $r $a $t1rx($r)
+}
+maketest 4.9 {SELECT a, rowid, z FROM t1 ORDER BY +rowid DESC} $ans
+maketest 4.10 {SELECT a, rowid, z FROM t1 ORDER BY rowid DESC} $ans
+
+set ans {}
+foreach x [sort $all_x] {
+ set r $t1xr($x)
+ lappend ans $r $t1ra($r) $x
+}
+maketest 4.11 {SELECT a, rowid, z FROM t1 ORDER BY +z} $ans
+maketest 4.12 {SELECT a, rowid, z FROM t1 ORDER BY z} $ans
+
+set ans {}
+foreach x [reverse [sort $all_x]] {
+ set r $t1xr($x)
+ lappend ans $r $t1ra($r) $x
+}
+maketest 4.13 {SELECT a, rowid, z FROM t1 ORDER BY +z DESC} $ans
+maketest 4.14 {SELECT a, rowid, z FROM t1 ORDER BY z DESC} $ans
+
+puts {finish_test}
diff --git a/test/boundary4.test b/test/boundary4.test
new file mode 100644
index 0000000..b77ac3a
--- /dev/null
+++ b/test/boundary4.test
@@ -0,0 +1,343 @@
+# 2008 December 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is automatically generated from a separate TCL script.
+# This file seeks to exercise integer boundary values.
+#
+# $Id: boundary4.test,v 1.2 2009/01/02 15:45:48 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Many of the boundary tests depend on a working 64-bit implementation.
+if {![working_64bit_int]} { finish_test; return }
+ifcapable !altertable { finish_test; return }
+
+do_test boundary4-1.1 {
+ db eval {
+ CREATE TABLE t1(a,x);
+ INSERT INTO t1(oid,a,x) VALUES(549755813887,1,'0000007fffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-8388608,2,'ffffffffff800000');
+ INSERT INTO t1(oid,a,x) VALUES(0,3,'0000000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-129,4,'ffffffffffffff7f');
+ INSERT INTO t1(oid,a,x) VALUES(8388608,5,'0000000000800000');
+ INSERT INTO t1(oid,a,x) VALUES(65535,6,'000000000000ffff');
+ INSERT INTO t1(oid,a,x) VALUES(8388607,7,'00000000007fffff');
+ INSERT INTO t1(oid,a,x) VALUES(1099511627776,8,'0000010000000000');
+ INSERT INTO t1(oid,a,x) VALUES(16777215,9,'0000000000ffffff');
+ INSERT INTO t1(oid,a,x) VALUES(32767,10,'0000000000007fff');
+ INSERT INTO t1(oid,a,x) VALUES(4294967296,11,'0000000100000000');
+ INSERT INTO t1(oid,a,x) VALUES(-549755813888,12,'ffffff8000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-140737488355328,13,'ffff800000000000');
+ INSERT INTO t1(oid,a,x) VALUES(256,14,'0000000000000100');
+ INSERT INTO t1(oid,a,x) VALUES(16777216,15,'0000000001000000');
+ INSERT INTO t1(oid,a,x) VALUES(72057594037927936,16,'0100000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-1,17,'ffffffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(9223372036854775807,18,'7fffffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(281474976710655,19,'0000ffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(1099511627775,20,'000000ffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-8388609,21,'ffffffffff7fffff');
+ INSERT INTO t1(oid,a,x) VALUES(32768,22,'0000000000008000');
+ INSERT INTO t1(oid,a,x) VALUES(36028797018963968,23,'0080000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-32769,24,'ffffffffffff7fff');
+ INSERT INTO t1(oid,a,x) VALUES(127,25,'000000000000007f');
+ INSERT INTO t1(oid,a,x) VALUES(-9223372036854775808,26,'8000000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(72057594037927935,27,'00ffffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-549755813889,28,'ffffff7fffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(255,29,'00000000000000ff');
+ INSERT INTO t1(oid,a,x) VALUES(-36028797018963969,30,'ff7fffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-2147483648,31,'ffffffff80000000');
+ INSERT INTO t1(oid,a,x) VALUES(281474976710656,32,'0001000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(65536,33,'0000000000010000');
+ INSERT INTO t1(oid,a,x) VALUES(140737488355328,34,'0000800000000000');
+ INSERT INTO t1(oid,a,x) VALUES(549755813888,35,'0000008000000000');
+ INSERT INTO t1(oid,a,x) VALUES(2147483648,36,'0000000080000000');
+ INSERT INTO t1(oid,a,x) VALUES(4294967295,37,'00000000ffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(140737488355327,38,'00007fffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-2147483649,39,'ffffffff7fffffff');
+ INSERT INTO t1(oid,a,x) VALUES(36028797018963967,40,'007fffffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(128,41,'0000000000000080');
+ INSERT INTO t1(oid,a,x) VALUES(-32768,42,'ffffffffffff8000');
+ INSERT INTO t1(oid,a,x) VALUES(-36028797018963968,43,'ff80000000000000');
+ INSERT INTO t1(oid,a,x) VALUES(-140737488355329,44,'ffff7fffffffffff');
+ INSERT INTO t1(oid,a,x) VALUES(-128,45,'ffffffffffffff80');
+ INSERT INTO t1(oid,a,x) VALUES(2147483647,46,'000000007fffffff');
+ CREATE INDEX t1i1 ON t1(a);
+ CREATE INDEX t1i2 ON t1(x);
+ }
+} {}
+do_test boundary4-1.2 {
+ db eval {
+ SELECT count(*) FROM t1
+ }
+} {46}
+do_test boundary4-1.3 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +rowid
+ }
+} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}
+do_test boundary4-1.4 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY rowid
+ }
+} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}
+do_test boundary4-1.5 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +rowid DESC
+ }
+} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}
+do_test boundary4-1.6 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY rowid DESC
+ }
+} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}
+do_test boundary4-1.7 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +a
+ }
+} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}
+do_test boundary4-1.8 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY a
+ }
+} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}
+do_test boundary4-1.9 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +a DESC
+ }
+} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}
+do_test boundary4-1.10 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY a DESC
+ }
+} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}
+do_test boundary4-1.11 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +x
+ }
+} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}
+do_test boundary4-1.12 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY x
+ }
+} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}
+do_test boundary4-1.13 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +x DESC
+ }
+} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}
+do_test boundary4-1.14 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY x DESC
+ }
+} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}
+do_test boundary4-2.1 {
+ db eval {
+ UPDATE t1 SET rowid=a, a=rowid
+ }
+} {}
+do_test boundary4-2.3 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY +a
+ }
+} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}
+do_test boundary4-2.4 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY a
+ }
+} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}
+do_test boundary4-2.5 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY +a DESC
+ }
+} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}
+do_test boundary4-2.6 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY a DESC
+ }
+} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}
+do_test boundary4-2.7 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY +rowid
+ }
+} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}
+do_test boundary4-2.8 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY rowid
+ }
+} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}
+do_test boundary4-2.9 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY +rowid DESC
+ }
+} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}
+do_test boundary4-2.10 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY rowid DESC
+ }
+} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}
+do_test boundary4-2.11 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY +x
+ }
+} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}
+do_test boundary4-2.12 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY x
+ }
+} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}
+do_test boundary4-2.13 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY +x DESC
+ }
+} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}
+do_test boundary4-2.14 {
+ db eval {
+ SELECT a, rowid, x FROM t1 ORDER BY x DESC
+ }
+} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}
+do_test boundary4-3.1 {
+ db eval {
+ UPDATE t1 SET rowid=a, a=rowid
+ }
+} {}
+do_test boundary4-3.2 {
+ db eval {
+ ALTER TABLE t1 ADD COLUMN z; UPDATE t1 SET z=zeroblob(600)
+ }
+} {}
+do_test boundary4-3.3 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +rowid
+ }
+} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}
+do_test boundary4-3.4 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY rowid
+ }
+} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}
+do_test boundary4-3.5 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +rowid DESC
+ }
+} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}
+do_test boundary4-3.6 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY rowid DESC
+ }
+} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}
+do_test boundary4-3.7 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +a
+ }
+} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}
+do_test boundary4-3.8 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY a
+ }
+} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}
+do_test boundary4-3.9 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +a DESC
+ }
+} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}
+do_test boundary4-3.10 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY a DESC
+ }
+} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}
+do_test boundary4-3.11 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +x
+ }
+} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}
+do_test boundary4-3.12 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY x
+ }
+} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}
+do_test boundary4-3.13 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY +x DESC
+ }
+} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}
+do_test boundary4-3.14 {
+ db eval {
+ SELECT rowid, a, x FROM t1 ORDER BY x DESC
+ }
+} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}
+do_test boundary4-4.1 {
+ db eval {
+ UPDATE t1 SET rowid=a, a=rowid, x=z, z=x
+ }
+} {}
+do_test boundary4-4.3 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY +a
+ }
+} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}
+do_test boundary4-4.4 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY a
+ }
+} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}
+do_test boundary4-4.5 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY +a DESC
+ }
+} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}
+do_test boundary4-4.6 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY a DESC
+ }
+} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}
+do_test boundary4-4.7 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY +rowid
+ }
+} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}
+do_test boundary4-4.8 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY rowid
+ }
+} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}
+do_test boundary4-4.9 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY +rowid DESC
+ }
+} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}
+do_test boundary4-4.10 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY rowid DESC
+ }
+} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}
+do_test boundary4-4.11 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY +z
+ }
+} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}
+do_test boundary4-4.12 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY z
+ }
+} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}
+do_test boundary4-4.13 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY +z DESC
+ }
+} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}
+do_test boundary4-4.14 {
+ db eval {
+ SELECT a, rowid, z FROM t1 ORDER BY z DESC
+ }
+} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}
+finish_test
diff --git a/test/busy.test b/test/busy.test
new file mode 100644
index 0000000..585f764
--- /dev/null
+++ b/test/busy.test
@@ -0,0 +1,61 @@
+# 2005 july 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file test the busy handler
+#
+# $Id: busy.test,v 1.3 2008/03/15 02:09:22 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test busy-1.1 {
+ sqlite3 db2 test.db
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ SELECT * FROM t1
+ }
+} 1
+proc busy x {
+ lappend ::busyargs $x
+ if {$x>2} {return 1}
+ return 0
+}
+set busyargs {}
+do_test busy-1.2 {
+ db busy busy
+ db2 eval {BEGIN EXCLUSIVE}
+ catchsql {BEGIN IMMEDIATE}
+} {1 {database is locked}}
+do_test busy-1.3 {
+ set busyargs
+} {0 1 2 3}
+do_test busy-1.4 {
+ set busyargs {}
+ catchsql {BEGIN IMMEDIATE}
+ set busyargs
+} {0 1 2 3}
+
+do_test busy-2.1 {
+ db2 eval {COMMIT}
+ db eval {BEGIN; INSERT INTO t1 VALUES(5)}
+ db2 eval {BEGIN; SELECT * FROM t1}
+ set busyargs {}
+ catchsql COMMIT
+} {1 {database is locked}}
+do_test busy-2.2 {
+ set busyargs
+} {0 1 2 3}
+
+
+db2 close
+
+finish_test
diff --git a/test/cache.test b/test/cache.test
new file mode 100644
index 0000000..8d801f0
--- /dev/null
+++ b/test/cache.test
@@ -0,0 +1,140 @@
+# 2007 March 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: cache.test,v 1.4 2007/08/22 02:56:44 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!pager_pragmas} {
+ finish_test
+ return
+}
+sqlite3_soft_heap_limit 0
+
+proc pager_cache_size {db} {
+ set bt [btree_from_db $db]
+ db_enter $db
+ array set stats [btree_pager_stats $bt]
+ db_leave $db
+ return $stats(page)
+}
+
+if {[permutation] == ""} {
+ do_test cache-1.1 { pager_cache_size db } {0}
+}
+
+do_test cache-1.2 {
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ }
+ pager_cache_size db
+} {2}
+
+# At one point, repeatedly locking and unlocking the cache was causing
+# a resource leak of one page per repetition. The page wasn't actually
+# leaked, but would not be reused until the pager-cache was full (i.e.
+# 2000 pages by default).
+#
+# This tests that once the pager-cache is initialised, it can be locked
+# and unlocked repeatedly without internally allocating any new pages.
+#
+set cache_size [pager_cache_size db]
+for {set ii 0} {$ii < 10} {incr ii} {
+ do_test cache-1.3.$ii {
+ execsql {SELECT * FROM abc}
+ pager_cache_size db
+ } $::cache_size
+}
+
+#-------------------------------------------------------------------------
+# This block of tests checks that it is possible to set the cache_size of a
+# database to a small (< 10) value. More specifically:
+#
+# cache-2.1.*: Test that "PRAGMA cache_size" appears to work with small
+# values.
+# cache-2.2.*: Test that "PRAGMA main.cache_size" appears to work with
+# small values.
+# cache-2.3.*: Test cache_size=1 correctly spills/flushes the cache.
+# cache-2.4.*: Test cache_size=0 correctly spills/flushes the cache.
+#
+#
+db_delete_and_reopen
+do_execsql_test cache-2.0 {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA journal_mode=DELETE;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ INSERT INTO t1 VALUES('x', 'y');
+ INSERT INTO t2 VALUES('i', 'j');
+} {delete}
+
+for {set i 0} {$i < 20} {incr i} {
+ do_execsql_test cache-2.1.$i.1 "PRAGMA cache_size = $i"
+ do_execsql_test cache-2.1.$i.2 "PRAGMA cache_size" $i
+ do_execsql_test cache-2.1.$i.3 "SELECT * FROM t1" {x y}
+ do_execsql_test cache-2.1.$i.4 "PRAGMA cache_size" $i
+}
+for {set i 0} {$i < 20} {incr i} {
+ do_execsql_test cache-2.2.$i.1 "PRAGMA main.cache_size = $i"
+ do_execsql_test cache-2.2.$i.2 "PRAGMA main.cache_size" $i
+ do_execsql_test cache-2.2.$i.3 "SELECT * FROM t1" {x y}
+ do_execsql_test cache-2.2.$i.4 "PRAGMA main.cache_size" $i
+}
+
+# Tests for cache_size = 1.
+#
+do_execsql_test cache-2.3.1 {
+ PRAGMA cache_size = 1;
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ PRAGMA lock_status;
+} {main reserved temp closed}
+do_test cache-2.3.2 { pager_cache_size db } 2
+do_execsql_test cache-2.3.3 {
+ INSERT INTO t2 VALUES(1, 2);
+ PRAGMA lock_status;
+} {main exclusive temp closed}
+do_test cache-2.3.4 { pager_cache_size db } 2
+do_execsql_test cache-2.3.5 COMMIT
+do_test cache-2.3.6 { pager_cache_size db } 1
+
+do_execsql_test cache-2.3.7 {
+ SELECT * FROM t1 UNION SELECT * FROM t2;
+} {1 2 i j x y}
+do_test cache-2.3.8 { pager_cache_size db } 1
+
+# Tests for cache_size = 0.
+#
+do_execsql_test cache-2.4.1 {
+ PRAGMA cache_size = 0;
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ PRAGMA lock_status;
+} {main reserved temp closed}
+do_test cache-2.4.2 { pager_cache_size db } 2
+do_execsql_test cache-2.4.3 {
+ INSERT INTO t2 VALUES(1, 2);
+ PRAGMA lock_status;
+} {main exclusive temp closed}
+do_test cache-2.4.4 { pager_cache_size db } 2
+do_execsql_test cache-2.4.5 COMMIT
+
+do_test cache-2.4.6 { pager_cache_size db } 0
+do_execsql_test cache-2.4.7 {
+ SELECT * FROM t1 UNION SELECT * FROM t2;
+} {1 2 i j x y}
+do_test cache-2.4.8 { pager_cache_size db } 0
+
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+finish_test
diff --git a/test/capi2.test b/test/capi2.test
new file mode 100644
index 0000000..8b36ac6
--- /dev/null
+++ b/test/capi2.test
@@ -0,0 +1,801 @@
+# 2003 January 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script testing the callback-free C/C++ API.
+#
+# $Id: capi2.test,v 1.37 2008/12/30 17:55:00 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Return the text values from the current row pointed at by STMT as a list.
+proc get_row_values {STMT} {
+ set VALUES [list]
+ for {set i 0} {$i < [sqlite3_data_count $STMT]} {incr i} {
+ lappend VALUES [sqlite3_column_text $STMT $i]
+ }
+ return $VALUES
+}
+
+# Return the column names followed by declaration types for the result set
+# of the SQL statement STMT.
+#
+# i.e. for:
+# CREATE TABLE abc(a text, b integer);
+# SELECT * FROM abc;
+#
+# The result is {a b text integer}
+proc get_column_names {STMT} {
+ set VALUES [list]
+ for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {
+ lappend VALUES [sqlite3_column_name $STMT $i]
+ }
+ for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {
+ lappend VALUES [sqlite3_column_decltype $STMT $i]
+ }
+ return $VALUES
+}
+
+# Check basic functionality
+#
+do_test capi2-1.1 {
+ set DB [sqlite3_connection_pointer db]
+ execsql {CREATE TABLE t1(a,b,c)}
+ set VM [sqlite3_prepare $DB {SELECT name, rowid FROM sqlite_master} -1 TAIL]
+ set TAIL
+} {}
+do_test capi2-1.2 {
+ sqlite3_step $VM
+} {SQLITE_ROW}
+do_test capi2-1.3 {
+ sqlite3_data_count $VM
+} {2}
+do_test capi2-1.4 {
+ get_row_values $VM
+} {t1 1}
+do_test capi2-1.5 {
+ get_column_names $VM
+} {name rowid text INTEGER}
+do_test capi2-1.6 {
+ sqlite3_step $VM
+} {SQLITE_DONE}
+do_test capi2-1.7 {
+ list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM]
+} {2 {} {name rowid text INTEGER}}
+
+# This used to be SQLITE_MISUSE. But now we automatically reset prepared
+# statements.
+ifcapable autoreset {
+ do_test capi2-1.8 {
+ sqlite3_step $VM
+ } {SQLITE_ROW}
+} else {
+ do_test capi2-1.8 {
+ sqlite3_step $VM
+ } {SQLITE_MISUSE}
+}
+
+# Update: In v2, once SQLITE_MISUSE is returned the statement handle cannot
+# be interrogated for more information. However in v3, since the column
+# count, names and types are determined at compile time, these are still
+# accessible after an SQLITE_MISUSE error.
+do_test capi2-1.9 {
+ sqlite3_reset $VM
+ list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM]
+} {2 {} {name rowid text INTEGER}}
+do_test capi2-1.10 {
+ sqlite3_data_count $VM
+} {0}
+
+do_test capi2-1.11 {
+ sqlite3_finalize $VM
+} {SQLITE_OK}
+
+# Check to make sure that the "tail" of a multi-statement SQL script
+# is returned by sqlite3_prepare.
+#
+do_test capi2-2.1 {
+ set SQL {
+ SELECT name, rowid FROM sqlite_master;
+ SELECT name, rowid FROM sqlite_master WHERE 0;
+ -- A comment at the end
+ }
+ set VM [sqlite3_prepare $DB $SQL -1 SQL]
+ set SQL
+} {
+ SELECT name, rowid FROM sqlite_master WHERE 0;
+ -- A comment at the end
+ }
+do_test capi2-2.2 {
+ set r [sqlite3_step $VM]
+ lappend r [sqlite3_column_count $VM] \
+ [get_row_values $VM] \
+ [get_column_names $VM]
+} {SQLITE_ROW 2 {t1 1} {name rowid text INTEGER}}
+do_test capi2-2.3 {
+ set r [sqlite3_step $VM]
+ lappend r [sqlite3_column_count $VM] \
+ [get_row_values $VM] \
+ [get_column_names $VM]
+} {SQLITE_DONE 2 {} {name rowid text INTEGER}}
+do_test capi2-2.4 {
+ sqlite3_finalize $VM
+} {SQLITE_OK}
+do_test capi2-2.5 {
+ set VM [sqlite3_prepare $DB $SQL -1 SQL]
+ set SQL
+} {
+ -- A comment at the end
+ }
+do_test capi2-2.6 {
+ set r [sqlite3_step $VM]
+ lappend r [sqlite3_column_count $VM] \
+ [get_row_values $VM] \
+ [get_column_names $VM]
+} {SQLITE_DONE 2 {} {name rowid text INTEGER}}
+do_test capi2-2.7 {
+ sqlite3_finalize $VM
+} {SQLITE_OK}
+do_test capi2-2.8 {
+ set VM [sqlite3_prepare $DB $SQL -1 SQL]
+ list $SQL $VM
+} {{} {}}
+
+# Check the error handling.
+#
+do_test capi2-3.1 {
+ set rc [catch {
+ sqlite3_prepare $DB {select bogus from sqlite_master} -1 TAIL
+ } msg]
+ lappend rc $msg $TAIL
+} {1 {(1) no such column: bogus} {}}
+do_test capi2-3.2 {
+ set rc [catch {
+ sqlite3_prepare $DB {select bogus from } -1 TAIL
+ } msg]
+ lappend rc $msg $TAIL
+} {1 {(1) near " ": syntax error} {}}
+do_test capi2-3.3 {
+ set rc [catch {
+ sqlite3_prepare $DB {;;;;select bogus from sqlite_master} -1 TAIL
+ } msg]
+ lappend rc $msg $TAIL
+} {1 {(1) no such column: bogus} {}}
+do_test capi2-3.4 {
+ set rc [catch {
+ sqlite3_prepare $DB {select bogus from sqlite_master;x;} -1 TAIL
+ } msg]
+ lappend rc $msg $TAIL
+} {1 {(1) no such column: bogus} {x;}}
+do_test capi2-3.5 {
+ set rc [catch {
+ sqlite3_prepare $DB {select bogus from sqlite_master;;;x;} -1 TAIL
+ } msg]
+ lappend rc $msg $TAIL
+} {1 {(1) no such column: bogus} {;;x;}}
+do_test capi2-3.6 {
+ set rc [catch {
+ sqlite3_prepare $DB {select 5/0} -1 TAIL
+ } VM]
+ lappend rc $TAIL
+} {0 {}}
+do_test capi2-3.7 {
+ list [sqlite3_step $VM] \
+ [sqlite3_column_count $VM] \
+ [get_row_values $VM] \
+ [get_column_names $VM]
+} {SQLITE_ROW 1 {{}} {5/0 {}}}
+do_test capi2-3.8 {
+ sqlite3_finalize $VM
+} {SQLITE_OK}
+do_test capi2-3.9 {
+ execsql {CREATE UNIQUE INDEX i1 ON t1(a)}
+ set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(1,2,3)} -1 TAIL]
+ set TAIL
+} {}
+do_test capi2-3.9b {db changes} {0}
+do_test capi2-3.10 {
+ list [sqlite3_step $VM] \
+ [sqlite3_column_count $VM] \
+ [get_row_values $VM] \
+ [get_column_names $VM]
+} {SQLITE_DONE 0 {} {}}
+
+# Update for v3 - the change has not actually happened until the query is
+# finalized. Is this going to cause trouble for anyone? Lee Nelson maybe?
+# (Later:) The change now happens just before SQLITE_DONE is returned.
+do_test capi2-3.10b {db changes} {1}
+do_test capi2-3.11 {
+ sqlite3_finalize $VM
+} {SQLITE_OK}
+do_test capi2-3.11b {db changes} {1}
+#do_test capi2-3.12-misuse {
+# sqlite3_finalize $VM
+#} {SQLITE_MISUSE}
+do_test capi2-3.13 {
+ set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(1,3,4)} -1 TAIL]
+ list [sqlite3_step $VM] \
+ [sqlite3_column_count $VM] \
+ [get_row_values $VM] \
+ [get_column_names $VM]
+} {SQLITE_ERROR 0 {} {}}
+
+# Update for v3: Preparing a statement does not affect the change counter.
+# (Test result changes from 0 to 1). (Later:) change counter updates occur
+# when sqlite3_step returns, not at finalize time.
+do_test capi2-3.13b {db changes} {0}
+
+do_test capi2-3.14 {
+ list [sqlite3_finalize $VM] [sqlite3_errmsg $DB]
+} {SQLITE_CONSTRAINT {column a is not unique}}
+do_test capi2-3.15 {
+ set VM [sqlite3_prepare $DB {CREATE TABLE t2(a NOT NULL, b)} -1 TAIL]
+ set TAIL
+} {}
+do_test capi2-3.16 {
+ list [sqlite3_step $VM] \
+ [sqlite3_column_count $VM] \
+ [get_row_values $VM] \
+ [get_column_names $VM]
+} {SQLITE_DONE 0 {} {}}
+do_test capi2-3.17 {
+ list [sqlite3_finalize $VM] [sqlite3_errmsg $DB]
+} {SQLITE_OK {not an error}}
+do_test capi2-3.18 {
+ set VM [sqlite3_prepare $DB {INSERT INTO t2 VALUES(NULL,2)} -1 TAIL]
+ list [sqlite3_step $VM] \
+ [sqlite3_column_count $VM] \
+ [get_row_values $VM] \
+ [get_column_names $VM]
+} {SQLITE_ERROR 0 {} {}}
+do_test capi2-3.19 {
+ list [sqlite3_finalize $VM] [sqlite3_errmsg $DB]
+} {SQLITE_CONSTRAINT {t2.a may not be NULL}}
+
+do_test capi2-3.20 {
+ execsql {
+ CREATE TABLE a1(message_id, name , UNIQUE(message_id, name) );
+ INSERT INTO a1 VALUES(1, 1);
+ }
+} {}
+do_test capi2-3.21 {
+ set VM [sqlite3_prepare $DB {INSERT INTO a1 VALUES(1, 1)} -1 TAIL]
+ sqlite3_step $VM
+} {SQLITE_ERROR}
+do_test capi2-3.22 {
+ sqlite3_errcode $DB
+} {SQLITE_ERROR}
+do_test capi2-3.23 {
+ sqlite3_finalize $VM
+} {SQLITE_CONSTRAINT}
+do_test capi2-3.24 {
+ sqlite3_errcode $DB
+} {SQLITE_CONSTRAINT}
+
+# Two or more virtual machines exists at the same time.
+#
+do_test capi2-4.1 {
+ set VM1 [sqlite3_prepare $DB {INSERT INTO t2 VALUES(1,2)} -1 TAIL]
+ set TAIL
+} {}
+do_test capi2-4.2 {
+ set VM2 [sqlite3_prepare $DB {INSERT INTO t2 VALUES(2,3)} -1 TAIL]
+ set TAIL
+} {}
+do_test capi2-4.3 {
+ set VM3 [sqlite3_prepare $DB {INSERT INTO t2 VALUES(3,4)} -1 TAIL]
+ set TAIL
+} {}
+do_test capi2-4.4 {
+ list [sqlite3_step $VM2] \
+ [sqlite3_column_count $VM2] \
+ [get_row_values $VM2] \
+ [get_column_names $VM2]
+} {SQLITE_DONE 0 {} {}}
+do_test capi2-4.5 {
+ execsql {SELECT * FROM t2 ORDER BY a}
+} {2 3}
+do_test capi2-4.6 {
+ sqlite3_finalize $VM2
+} {SQLITE_OK}
+do_test capi2-4.7 {
+ list [sqlite3_step $VM3] \
+ [sqlite3_column_count $VM3] \
+ [get_row_values $VM3] \
+ [get_column_names $VM3]
+} {SQLITE_DONE 0 {} {}}
+do_test capi2-4.8 {
+ execsql {SELECT * FROM t2 ORDER BY a}
+} {2 3 3 4}
+do_test capi2-4.9 {
+ sqlite3_finalize $VM3
+} {SQLITE_OK}
+do_test capi2-4.10 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_DONE 0 {} {}}
+do_test capi2-4.11 {
+ execsql {SELECT * FROM t2 ORDER BY a}
+} {1 2 2 3 3 4}
+do_test capi2-4.12 {
+ sqlite3_finalize $VM1
+} {SQLITE_OK}
+
+# Interleaved SELECTs
+#
+do_test capi2-5.1 {
+ set VM1 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]
+ set VM2 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]
+ set VM3 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 2 {2 3} {a b {} {}}}
+do_test capi2-5.2 {
+ list [sqlite3_step $VM2] \
+ [sqlite3_column_count $VM2] \
+ [get_row_values $VM2] \
+ [get_column_names $VM2]
+} {SQLITE_ROW 2 {2 3} {a b {} {}}}
+do_test capi2-5.3 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 2 {3 4} {a b {} {}}}
+do_test capi2-5.4 {
+ list [sqlite3_step $VM3] \
+ [sqlite3_column_count $VM3] \
+ [get_row_values $VM3] \
+ [get_column_names $VM3]
+} {SQLITE_ROW 2 {2 3} {a b {} {}}}
+do_test capi2-5.5 {
+ list [sqlite3_step $VM3] \
+ [sqlite3_column_count $VM3] \
+ [get_row_values $VM3] \
+ [get_column_names $VM3]
+} {SQLITE_ROW 2 {3 4} {a b {} {}}}
+do_test capi2-5.6 {
+ list [sqlite3_step $VM3] \
+ [sqlite3_column_count $VM3] \
+ [get_row_values $VM3] \
+ [get_column_names $VM3]
+} {SQLITE_ROW 2 {1 2} {a b {} {}}}
+do_test capi2-5.7 {
+ list [sqlite3_step $VM3] \
+ [sqlite3_column_count $VM3] \
+ [get_row_values $VM3] \
+ [get_column_names $VM3]
+} {SQLITE_DONE 2 {} {a b {} {}}}
+do_test capi2-5.8 {
+ sqlite3_finalize $VM3
+} {SQLITE_OK}
+do_test capi2-5.9 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 2 {1 2} {a b {} {}}}
+do_test capi2-5.10 {
+ sqlite3_finalize $VM1
+} {SQLITE_OK}
+do_test capi2-5.11 {
+ list [sqlite3_step $VM2] \
+ [sqlite3_column_count $VM2] \
+ [get_row_values $VM2] \
+ [get_column_names $VM2]
+} {SQLITE_ROW 2 {3 4} {a b {} {}}}
+do_test capi2-5.12 {
+ list [sqlite3_step $VM2] \
+ [sqlite3_column_count $VM2] \
+ [get_row_values $VM2] \
+ [get_column_names $VM2]
+} {SQLITE_ROW 2 {1 2} {a b {} {}}}
+do_test capi2-5.11 {
+ sqlite3_finalize $VM2
+} {SQLITE_OK}
+
+# Check for proper SQLITE_BUSY returns.
+#
+do_test capi2-6.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(x counter);
+ INSERT INTO t3 VALUES(1);
+ INSERT INTO t3 VALUES(2);
+ INSERT INTO t3 SELECT x+2 FROM t3;
+ INSERT INTO t3 SELECT x+4 FROM t3;
+ INSERT INTO t3 SELECT x+8 FROM t3;
+ COMMIT;
+ }
+ set VM1 [sqlite3_prepare $DB {SELECT * FROM t3} -1 TAIL]
+ sqlite3 db2 test.db
+ execsql {BEGIN} db2
+} {}
+# Update for v3: BEGIN doesn't write-lock the database. It is quite
+# difficult to get v3 to write-lock the database, which causes a few
+# problems for test scripts.
+#
+# do_test capi2-6.2 {
+# list [sqlite3_step $VM1] \
+# [sqlite3_column_count $VM1] \
+# [get_row_values $VM1] \
+# [get_column_names $VM1]
+# } {SQLITE_BUSY 0 {} {}}
+do_test capi2-6.3 {
+ execsql {COMMIT} db2
+} {}
+do_test capi2-6.4 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 1 {x counter}}
+do_test capi2-6.5 {
+ catchsql {INSERT INTO t3 VALUES(10);} db2
+} {1 {database is locked}}
+do_test capi2-6.6 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 2 {x counter}}
+do_test capi2-6.7 {
+ execsql {SELECT * FROM t2} db2
+} {2 3 3 4 1 2}
+do_test capi2-6.8 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 3 {x counter}}
+do_test capi2-6.9 {
+ execsql {SELECT * FROM t2}
+} {2 3 3 4 1 2}
+do_test capi2-6.10 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 4 {x counter}}
+do_test capi2-6.11 {
+ execsql {BEGIN}
+} {}
+do_test capi2-6.12 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 5 {x counter}}
+
+# A read no longer blocks a write in the same connection.
+#do_test capi2-6.13 {
+# catchsql {UPDATE t3 SET x=x+1}
+#} {1 {database table is locked}}
+
+do_test capi2-6.14 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 6 {x counter}}
+do_test capi2-6.15 {
+ execsql {SELECT * FROM t1}
+} {1 2 3}
+do_test capi2-6.16 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 7 {x counter}}
+do_test capi2-6.17 {
+ catchsql {UPDATE t1 SET b=b+1}
+} {0 {}}
+do_test capi2-6.18 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 8 {x counter}}
+do_test capi2-6.19 {
+ execsql {SELECT * FROM t1}
+} {1 3 3}
+do_test capi2-6.20 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 9 {x counter}}
+#do_test capi2-6.21 {
+# execsql {ROLLBACK; SELECT * FROM t1}
+#} {1 2 3}
+do_test capi2-6.22 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 10 {x counter}}
+#do_test capi2-6.23 {
+# execsql {BEGIN TRANSACTION;}
+#} {}
+do_test capi2-6.24 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 11 {x counter}}
+do_test capi2-6.25 {
+ execsql {
+ INSERT INTO t1 VALUES(2,3,4);
+ SELECT * FROM t1;
+ }
+} {1 3 3 2 3 4}
+do_test capi2-6.26 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 12 {x counter}}
+do_test capi2-6.27 {
+ catchsql {
+ INSERT INTO t1 VALUES(2,4,5);
+ SELECT * FROM t1;
+ }
+} {1 {column a is not unique}}
+do_test capi2-6.28 {
+ list [sqlite3_step $VM1] \
+ [sqlite3_column_count $VM1] \
+ [get_row_values $VM1] \
+ [get_column_names $VM1]
+} {SQLITE_ROW 1 13 {x counter}}
+do_test capi2-6.99 {
+ sqlite3_finalize $VM1
+} {SQLITE_OK}
+catchsql {ROLLBACK}
+
+do_test capi2-7.1 {
+ stepsql $DB {
+ SELECT * FROM t1
+ }
+} {0 1 2 3}
+do_test capi2-7.2 {
+ stepsql $DB {
+ PRAGMA count_changes=on
+ }
+} {0}
+do_test capi2-7.3 {
+ stepsql $DB {
+ UPDATE t1 SET a=a+10;
+ }
+} {0 1}
+do_test capi2-7.4 {
+ stepsql $DB {
+ INSERT INTO t1 SELECT a+1,b+1,c+1 FROM t1;
+ }
+} {0 1}
+do_test capi2-7.4b {sqlite3_changes $DB} {1}
+do_test capi2-7.5 {
+ stepsql $DB {
+ UPDATE t1 SET a=a+10;
+ }
+} {0 2}
+do_test capi2-7.5b {sqlite3_changes $DB} {2}
+do_test capi2-7.6 {
+ stepsql $DB {
+ SELECT * FROM t1;
+ }
+} {0 21 2 3 22 3 4}
+do_test capi2-7.7 {
+ stepsql $DB {
+ INSERT INTO t1 SELECT a+2,b+2,c+2 FROM t1;
+ }
+} {0 2}
+do_test capi2-7.8 {
+ sqlite3_changes $DB
+} {2}
+do_test capi2-7.9 {
+ stepsql $DB {
+ SELECT * FROM t1;
+ }
+} {0 21 2 3 22 3 4 23 4 5 24 5 6}
+do_test capi2-7.10 {
+ stepsql $DB {
+ UPDATE t1 SET a=a-20;
+ SELECT * FROM t1;
+ }
+} {0 4 1 2 3 2 3 4 3 4 5 4 5 6}
+
+# Update for version 3: A SELECT statement no longer resets the change
+# counter (Test result changes from 0 to 4).
+do_test capi2-7.11 {
+ sqlite3_changes $DB
+} {4}
+do_test capi2-7.11a {
+ execsql {SELECT count(*) FROM t1}
+} {4}
+
+ifcapable {explain} {
+ do_test capi2-7.12 {
+ set x [stepsql $DB {EXPLAIN SELECT * FROM t1}]
+ lindex $x 0
+ } {0}
+}
+
+# Ticket #261 - make sure we can finalize before the end of a query.
+#
+do_test capi2-8.1 {
+ set VM1 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]
+ sqlite3_finalize $VM1
+} {SQLITE_OK}
+
+# Tickets #384 and #385 - make sure the TAIL argument to sqlite3_prepare
+# and all of the return pointers in sqlite_step can be null.
+#
+do_test capi2-9.1 {
+ set VM1 [sqlite3_prepare $DB {SELECT * FROM t2} -1 DUMMY]
+ sqlite3_step $VM1
+ sqlite3_finalize $VM1
+} {SQLITE_OK}
+
+# Test that passing a NULL pointer to sqlite3_finalize() or sqlite3_reset
+# does not cause an error.
+do_test capi2-10.1 {
+ sqlite3_finalize 0
+} {SQLITE_OK}
+do_test capi2-10.2 {
+ sqlite3_reset 0
+} {SQLITE_OK}
+
+#---------------------------------------------------------------------------
+# The following tests - capi2-11.* - test the "column origin" APIs.
+#
+# sqlite3_column_origin_name()
+# sqlite3_column_database_name()
+# sqlite3_column_table_name()
+#
+
+ifcapable columnmetadata {
+
+# This proc uses the database handle $::DB to compile the SQL statement passed
+# as a parameter. The return value of this procedure is a list with one
+# element for each column returned by the compiled statement. Each element of
+# this list is itself a list of length three, consisting of the origin
+# database, table and column for the corresponding returned column.
+proc check_origins {sql} {
+ set ret [list]
+ set ::STMT [sqlite3_prepare $::DB $sql -1 dummy]
+ for {set i 0} {$i < [sqlite3_column_count $::STMT]} {incr i} {
+ lappend ret [list \
+ [sqlite3_column_database_name $::STMT $i] \
+ [sqlite3_column_table_name $::STMT $i] \
+ [sqlite3_column_origin_name $::STMT $i] \
+ ]
+ }
+ sqlite3_finalize $::STMT
+ return $ret
+}
+do_test capi2-11.1 {
+ execsql {
+ CREATE TABLE tab1(col1, col2);
+ }
+} {}
+do_test capi2-11.2 {
+ check_origins {SELECT col2, col1 FROM tab1}
+} [list {main tab1 col2} {main tab1 col1}]
+do_test capi2-11.3 {
+ check_origins {SELECT col2 AS hello, col1 AS world FROM tab1}
+} [list {main tab1 col2} {main tab1 col1}]
+
+ifcapable subquery {
+ do_test capi2-11.4 {
+ check_origins {SELECT b, a FROM (SELECT col1 AS a, col2 AS b FROM tab1)}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-11.5 {
+ check_origins {SELECT (SELECT col2 FROM tab1), (SELECT col1 FROM tab1)}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-11.6 {
+ check_origins {SELECT (SELECT col2), (SELECT col1) FROM tab1}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-11.7 {
+ check_origins {SELECT * FROM tab1}
+ } [list {main tab1 col1} {main tab1 col2}]
+ do_test capi2-11.8 {
+ check_origins {SELECT * FROM (SELECT * FROM tab1)}
+ } [list {main tab1 col1} {main tab1 col2}]
+}
+
+ifcapable view&&subquery {
+ do_test capi2-12.1 {
+ execsql {
+ CREATE VIEW view1 AS SELECT * FROM tab1;
+ }
+ } {}
+ do_test capi2-12.2 {
+ check_origins {SELECT col2, col1 FROM view1}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-12.3 {
+ check_origins {SELECT col2 AS hello, col1 AS world FROM view1}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-12.4 {
+ check_origins {SELECT b, a FROM (SELECT col1 AS a, col2 AS b FROM view1)}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-12.5 {
+ check_origins {SELECT (SELECT col2 FROM view1), (SELECT col1 FROM view1)}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-12.6 {
+ check_origins {SELECT (SELECT col2), (SELECT col1) FROM view1}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-12.7 {
+ check_origins {SELECT * FROM view1}
+ } [list {main tab1 col1} {main tab1 col2}]
+ do_test capi2-12.8 {
+ check_origins {select * from (select * from view1)}
+ } [list {main tab1 col1} {main tab1 col2}]
+ do_test capi2-12.9 {
+ check_origins {select * from (select * from (select * from view1))}
+ } [list {main tab1 col1} {main tab1 col2}]
+ do_test capi2-12.10 {
+ db close
+ sqlite3 db test.db
+ set ::DB [sqlite3_connection_pointer db]
+ check_origins {select * from (select * from (select * from view1))}
+ } [list {main tab1 col1} {main tab1 col2}]
+
+ # This view will thwart the flattening optimization.
+ do_test capi2-13.1 {
+ execsql {
+ CREATE VIEW view2 AS SELECT * FROM tab1 limit 10 offset 10;
+ }
+ } {}
+ do_test capi2-13.2 {
+ check_origins {SELECT col2, col1 FROM view2}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-13.3 {
+ check_origins {SELECT col2 AS hello, col1 AS world FROM view2}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-13.4 {
+ check_origins {SELECT b, a FROM (SELECT col1 AS a, col2 AS b FROM view2)}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-13.5 {
+ check_origins {SELECT (SELECT col2 FROM view2), (SELECT col1 FROM view2)}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-13.6 {
+ check_origins {SELECT (SELECT col2), (SELECT col1) FROM view2}
+ } [list {main tab1 col2} {main tab1 col1}]
+ do_test capi2-13.7 {
+ check_origins {SELECT * FROM view2}
+ } [list {main tab1 col1} {main tab1 col2}]
+ do_test capi2-13.8 {
+ check_origins {select * from (select * from view2)}
+ } [list {main tab1 col1} {main tab1 col2}]
+ do_test capi2-13.9 {
+ check_origins {select * from (select * from (select * from view2))}
+ } [list {main tab1 col1} {main tab1 col2}]
+ do_test capi2-13.10 {
+ db close
+ sqlite3 db test.db
+ set ::DB [sqlite3_connection_pointer db]
+ check_origins {select * from (select * from (select * from view2))}
+ } [list {main tab1 col1} {main tab1 col2}]
+ do_test capi2-13.11 {
+ check_origins {select * from (select * from tab1 limit 10 offset 10)}
+ } [list {main tab1 col1} {main tab1 col2}]
+}
+
+
+} ;# ifcapable columnmetadata
+
+db2 close
+finish_test
diff --git a/test/capi3.test b/test/capi3.test
new file mode 100644
index 0000000..cbba04c
--- /dev/null
+++ b/test/capi3.test
@@ -0,0 +1,1215 @@
+# 2003 January 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script testing the callback-free C/C++ API.
+#
+# $Id: capi3.test,v 1.70 2009/01/09 02:49:32 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Return the UTF-16 representation of the supplied UTF-8 string $str.
+# If $nt is true, append two 0x00 bytes as a nul terminator.
+proc utf16 {str {nt 1}} {
+ set r [encoding convertto unicode $str]
+ if {$nt} {
+ append r "\x00\x00"
+ }
+ return $r
+}
+
+# Return the UTF-8 representation of the supplied UTF-16 string $str.
+proc utf8 {str} {
+ # If $str ends in two 0x00 0x00 bytes, knock these off before
+ # converting to UTF-8 using TCL.
+ binary scan $str \c* vals
+ if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {
+ set str [binary format \c* [lrange $vals 0 end-2]]
+ }
+
+ set r [encoding convertfrom unicode $str]
+ return $r
+}
+
+# These tests complement those in capi2.test. They are organized
+# as follows:
+#
+# capi3-1.*: Test sqlite3_prepare
+# capi3-2.*: Test sqlite3_prepare16
+# capi3-3.*: Test sqlite3_open
+# capi3-4.*: Test sqlite3_open16
+# capi3-5.*: Test the various sqlite3_result_* APIs
+# capi3-6.*: Test that sqlite3_close fails if there are outstanding VMs.
+#
+
+set DB [sqlite3_connection_pointer db]
+
+do_test capi3-1.0 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3-1.1 {
+ set STMT [sqlite3_prepare $DB {SELECT name FROM sqlite_master} -1 TAIL]
+ sqlite3_finalize $STMT
+ set TAIL
+} {}
+do_test capi3-1.2.1 {
+ sqlite3_errcode $DB
+} {SQLITE_OK}
+do_test capi3-1.2.2 {
+ sqlite3_extended_errcode $DB
+} {SQLITE_OK}
+do_test capi3-1.3 {
+ sqlite3_errmsg $DB
+} {not an error}
+do_test capi3-1.4 {
+ set sql {SELECT name FROM sqlite_master;SELECT 10}
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_finalize $STMT
+ set TAIL
+} {SELECT 10}
+do_test capi3-1.5 {
+ set sql {SELECT name FROM sqlite_master;SELECT 10}
+ set STMT [sqlite3_prepare $DB $sql [string length $sql] TAIL]
+ sqlite3_finalize $STMT
+ set TAIL
+} {SELECT 10}
+do_test capi3-1.6 {
+ set sql {SELECT name FROM sqlite_master;SELECT 10}
+ set STMT [sqlite3_prepare $DB $sql [expr [string length $sql]+1] TAIL]
+ sqlite3_finalize $STMT
+ set TAIL
+} {SELECT 10}
+
+do_test capi3-1.7 {
+ set sql {SELECT namex FROM sqlite_master}
+ catch {
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ }
+} {1}
+do_test capi3-1.8.1 {
+ sqlite3_errcode $DB
+} {SQLITE_ERROR}
+do_test capi3-1.8.2 {
+ sqlite3_extended_errcode $DB
+} {SQLITE_ERROR}
+do_test capi3-1.9 {
+ sqlite3_errmsg $DB
+} {no such column: namex}
+
+ifcapable {utf16} {
+ do_test capi3-2.1 {
+ set sql16 [utf16 {SELECT name FROM sqlite_master}]
+ set STMT [sqlite3_prepare16 $DB $sql16 -1 ::TAIL]
+ sqlite3_finalize $STMT
+ utf8 $::TAIL
+ } {}
+ do_test capi3-2.2 {
+ set sql [utf16 {SELECT name FROM sqlite_master;SELECT 10}]
+ set STMT [sqlite3_prepare16 $DB $sql -1 TAIL]
+ sqlite3_finalize $STMT
+ utf8 $TAIL
+ } {SELECT 10}
+ do_test capi3-2.3 {
+ set sql [utf16 {SELECT namex FROM sqlite_master}]
+ catch {
+ set STMT [sqlite3_prepare16 $DB $sql -1]
+ }
+ } {1}
+ do_test capi3-2.4.1 {
+ sqlite3_errcode $DB
+ } {SQLITE_ERROR}
+ do_test capi3-2.4.2 {
+ sqlite3_extended_errcode $DB
+ } {SQLITE_ERROR}
+ do_test capi3-2.5 {
+ sqlite3_errmsg $DB
+ } {no such column: namex}
+
+ ifcapable schema_pragmas {
+ do_test capi3-2.6 {
+ execsql {CREATE TABLE tablename(x)}
+ set sql16 [utf16 {PRAGMA table_info("TableName"); --excess text}]
+ set STMT [sqlite3_prepare16 $DB $sql16 -1]
+ sqlite3_step $STMT
+ } SQLITE_ROW
+ do_test capi3-2.7 {
+ sqlite3_step $STMT
+ } SQLITE_DONE
+ do_test capi3-2.8 {
+ sqlite3_finalize $STMT
+ } SQLITE_OK
+ }
+
+} ;# endif utf16
+
+# rename sqlite3_open sqlite3_open_old
+# proc sqlite3_open {fname options} {sqlite3_open_new $fname $options}
+
+do_test capi3-3.1 {
+ set db2 [sqlite3_open test.db {}]
+ sqlite3_errcode $db2
+} {SQLITE_OK}
+# FIX ME: Should test the db handle works.
+do_test capi3-3.2 {
+ sqlite3_close $db2
+} {SQLITE_OK}
+do_test capi3-3.3 {
+ catch {
+ set db2 [sqlite3_open /bogus/path/test.db {}]
+ }
+ sqlite3_extended_errcode $db2
+} {SQLITE_CANTOPEN}
+do_test capi3-3.4 {
+ sqlite3_errmsg $db2
+} {unable to open database file}
+do_test capi3-3.5 {
+ sqlite3_close $db2
+} {SQLITE_OK}
+do_test capi3-3.6.1-misuse {
+ sqlite3_close $db2
+} {SQLITE_MISUSE}
+do_test capi3-3.6.2-misuse {
+ sqlite3_errmsg $db2
+} {library routine called out of sequence}
+ifcapable {utf16} {
+ do_test capi3-3.6.3-misuse {
+ utf8 [sqlite3_errmsg16 $db2]
+ } {library routine called out of sequence}
+}
+
+do_test capi3-3.7 {
+ set db2 [sqlite3_open]
+ sqlite3_errcode $db2
+} {SQLITE_OK}
+do_test capi3-3.8 {
+ sqlite3_close $db2
+} {SQLITE_OK}
+
+# rename sqlite3_open ""
+# rename sqlite3_open_old sqlite3_open
+
+ifcapable {utf16} {
+do_test capi3-4.1 {
+ set db2 [sqlite3_open16 [utf16 test.db] {}]
+ sqlite3_errcode $db2
+} {SQLITE_OK}
+# FIX ME: Should test the db handle works.
+do_test capi3-4.2 {
+ sqlite3_close $db2
+} {SQLITE_OK}
+do_test capi3-4.3 {
+ catch {
+ set db2 [sqlite3_open16 [utf16 /bogus/path/test.db] {}]
+ }
+ sqlite3_errcode $db2
+} {SQLITE_CANTOPEN}
+do_test capi3-4.4 {
+ utf8 [sqlite3_errmsg16 $db2]
+} {unable to open database file}
+do_test capi3-4.5 {
+ sqlite3_close $db2
+} {SQLITE_OK}
+} ;# utf16
+
+# This proc is used to test the following API calls:
+#
+# sqlite3_column_count
+# sqlite3_column_name
+# sqlite3_column_name16
+# sqlite3_column_decltype
+# sqlite3_column_decltype16
+#
+# $STMT is a compiled SQL statement. $test is a prefix
+# to use for test names within this proc. $names is a list
+# of the column names that should be returned by $STMT.
+# $decltypes is a list of column declaration types for $STMT.
+#
+# Example:
+#
+# set STMT [sqlite3_prepare "SELECT 1, 2, 2;" -1 DUMMY]
+# check_header test1.1 {1 2 3} {"" "" ""}
+#
+proc check_header {STMT test names decltypes} {
+
+ # Use the return value of sqlite3_column_count() to build
+ # a list of column indexes. i.e. If sqlite3_column_count
+ # is 3, build the list {0 1 2}.
+ set ::idxlist [list]
+ set ::numcols [sqlite3_column_count $STMT]
+ for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}
+
+ # Column names in UTF-8
+ do_test $test.1 {
+ set cnamelist [list]
+ foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]}
+ set cnamelist
+ } $names
+
+ # Column names in UTF-16
+ ifcapable {utf16} {
+ do_test $test.2 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]
+ }
+ set cnamelist
+ } $names
+ }
+
+ # Column names in UTF-8
+ do_test $test.3 {
+ set cnamelist [list]
+ foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]}
+ set cnamelist
+ } $names
+
+ # Column names in UTF-16
+ ifcapable {utf16} {
+ do_test $test.4 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]
+ }
+ set cnamelist
+ } $names
+ }
+
+ # Column names in UTF-8
+ do_test $test.5 {
+ set cnamelist [list]
+ foreach i $idxlist {lappend cnamelist [sqlite3_column_decltype $STMT $i]}
+ set cnamelist
+ } $decltypes
+
+ # Column declaration types in UTF-16
+ ifcapable {utf16} {
+ do_test $test.6 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_decltype16 $STMT $i]]
+ }
+ set cnamelist
+ } $decltypes
+ }
+
+
+ # Test some out of range conditions:
+ ifcapable {utf16} {
+ do_test $test.7 {
+ list \
+ [sqlite3_column_name $STMT -1] \
+ [sqlite3_column_name16 $STMT -1] \
+ [sqlite3_column_decltype $STMT -1] \
+ [sqlite3_column_decltype16 $STMT -1] \
+ [sqlite3_column_name $STMT $numcols] \
+ [sqlite3_column_name16 $STMT $numcols] \
+ [sqlite3_column_decltype $STMT $numcols] \
+ [sqlite3_column_decltype16 $STMT $numcols]
+ } {{} {} {} {} {} {} {} {}}
+ }
+}
+
+# This proc is used to test the following API calls:
+#
+# sqlite3_column_origin_name
+# sqlite3_column_origin_name16
+# sqlite3_column_table_name
+# sqlite3_column_table_name16
+# sqlite3_column_database_name
+# sqlite3_column_database_name16
+#
+# $STMT is a compiled SQL statement. $test is a prefix
+# to use for test names within this proc. $names is a list
+# of the column names that should be returned by $STMT.
+# $decltypes is a list of column declaration types for $STMT.
+#
+# Example:
+#
+# set STMT [sqlite3_prepare "SELECT 1, 2, 2;" -1 DUMMY]
+# check_header test1.1 {1 2 3} {"" "" ""}
+#
+proc check_origin_header {STMT test dbs tables cols} {
+ # If sqlite3_column_origin_name() and friends are not compiled into
+ # this build, this proc is a no-op.
+ ifcapable columnmetadata {
+ # Use the return value of sqlite3_column_count() to build
+ # a list of column indexes. i.e. If sqlite3_column_count
+ # is 3, build the list {0 1 2}.
+ set ::idxlist [list]
+ set ::numcols [sqlite3_column_count $STMT]
+ for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}
+
+ # Database names in UTF-8
+ do_test $test.8 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [sqlite3_column_database_name $STMT $i]
+ }
+ set cnamelist
+ } $dbs
+
+ # Database names in UTF-16
+ ifcapable {utf16} {
+ do_test $test.9 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_database_name16 $STMT $i]]
+ }
+ set cnamelist
+ } $dbs
+ }
+
+ # Table names in UTF-8
+ do_test $test.10 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [sqlite3_column_table_name $STMT $i]
+ }
+ set cnamelist
+ } $tables
+
+ # Table names in UTF-16
+ ifcapable {utf16} {
+ do_test $test.11 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_table_name16 $STMT $i]]
+ }
+ set cnamelist
+ } $tables
+ }
+
+ # Origin names in UTF-8
+ do_test $test.12 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [sqlite3_column_origin_name $STMT $i]
+ }
+ set cnamelist
+ } $cols
+
+ # Origin declaration types in UTF-16
+ ifcapable {utf16} {
+ do_test $test.13 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_origin_name16 $STMT $i]]
+ }
+ set cnamelist
+ } $cols
+ }
+ }
+}
+
+# This proc is used to test the following APIs:
+#
+# sqlite3_data_count
+# sqlite3_column_type
+# sqlite3_column_int
+# sqlite3_column_text
+# sqlite3_column_text16
+# sqlite3_column_double
+#
+# $STMT is a compiled SQL statement for which the previous call
+# to sqlite3_step returned SQLITE_ROW. $test is a prefix to use
+# for test names within this proc. $types is a list of the
+# manifest types for the current row. $ints, $doubles and $strings
+# are lists of the integer, real and string representations of
+# the values in the current row.
+#
+# Example:
+#
+# set STMT [sqlite3_prepare "SELECT 'hello', 1.1, NULL" -1 DUMMY]
+# sqlite3_step $STMT
+# check_data test1.2 {TEXT REAL NULL} {0 1 0} {0 1.1 0} {hello 1.1 {}}
+#
+proc check_data {STMT test types ints doubles strings} {
+
+ # Use the return value of sqlite3_column_count() to build
+ # a list of column indexes. i.e. If sqlite3_column_count
+ # is 3, build the list {0 1 2}.
+ set ::idxlist [list]
+ set numcols [sqlite3_data_count $STMT]
+ for {set i 0} {$i < $numcols} {incr i} {lappend ::idxlist $i}
+
+# types
+do_test $test.1 {
+ set types [list]
+ foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}
+ set types
+} $types
+
+# Integers
+do_test $test.2 {
+ set ints [list]
+ foreach i $idxlist {lappend ints [sqlite3_column_int64 $STMT $i]}
+ set ints
+} $ints
+
+# bytes
+set lens [list]
+foreach i $::idxlist {
+ lappend lens [string length [lindex $strings $i]]
+}
+do_test $test.3 {
+ set bytes [list]
+ set lens [list]
+ foreach i $idxlist {
+ lappend bytes [sqlite3_column_bytes $STMT $i]
+ }
+ set bytes
+} $lens
+
+# bytes16
+ifcapable {utf16} {
+ set lens [list]
+ foreach i $::idxlist {
+ lappend lens [expr 2 * [string length [lindex $strings $i]]]
+ }
+ do_test $test.4 {
+ set bytes [list]
+ set lens [list]
+ foreach i $idxlist {
+ lappend bytes [sqlite3_column_bytes16 $STMT $i]
+ }
+ set bytes
+ } $lens
+}
+
+# Blob
+do_test $test.5 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [sqlite3_column_blob $STMT $i]}
+ set utf8
+} $strings
+
+# UTF-8
+do_test $test.6 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}
+ set utf8
+} $strings
+
+# Floats
+do_test $test.7 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}
+ set utf8
+} $doubles
+
+# UTF-16
+ifcapable {utf16} {
+ do_test $test.8 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]}
+ set utf8
+ } $strings
+}
+
+# Integers
+do_test $test.9 {
+ set ints [list]
+ foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}
+ set ints
+} $ints
+
+# Floats
+do_test $test.10 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}
+ set utf8
+} $doubles
+
+# UTF-8
+do_test $test.11 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}
+ set utf8
+} $strings
+
+# Types
+do_test $test.12 {
+ set types [list]
+ foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}
+ set types
+} $types
+
+# Test that an out of range request returns the equivalent of NULL
+do_test $test.13 {
+ sqlite3_column_int $STMT -1
+} {0}
+do_test $test.13 {
+ sqlite3_column_text $STMT -1
+} {}
+
+}
+
+ifcapable !floatingpoint {
+ finish_test
+ return
+}
+
+do_test capi3-5.0 {
+ execsql {
+ CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16));
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES('one', 'two', NULL);
+ INSERT INTO t1 VALUES(1.2, 1.3, 1.4);
+ }
+ set sql "SELECT * FROM t1"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_column_count $STMT
+} 3
+
+check_header $STMT capi3-5.1 {a b c} {VARINT BLOB VARCHAR(16)}
+check_origin_header $STMT capi3-5.1 {main main main} {t1 t1 t1} {a b c}
+do_test capi3-5.2 {
+ sqlite3_step $STMT
+} SQLITE_ROW
+
+check_header $STMT capi3-5.3 {a b c} {VARINT BLOB VARCHAR(16)}
+check_origin_header $STMT capi3-5.3 {main main main} {t1 t1 t1} {a b c}
+check_data $STMT capi3-5.4 {INTEGER INTEGER TEXT} {1 2 3} {1.0 2.0 3.0} {1 2 3}
+
+do_test capi3-5.5 {
+ sqlite3_step $STMT
+} SQLITE_ROW
+
+check_header $STMT capi3-5.6 {a b c} {VARINT BLOB VARCHAR(16)}
+check_origin_header $STMT capi3-5.6 {main main main} {t1 t1 t1} {a b c}
+check_data $STMT capi3-5.7 {TEXT TEXT NULL} {0 0 0} {0.0 0.0 0.0} {one two {}}
+
+do_test capi3-5.8 {
+ sqlite3_step $STMT
+} SQLITE_ROW
+
+check_header $STMT capi3-5.9 {a b c} {VARINT BLOB VARCHAR(16)}
+check_origin_header $STMT capi3-5.9 {main main main} {t1 t1 t1} {a b c}
+check_data $STMT capi3-5.10 {FLOAT FLOAT TEXT} {1 1 1} {1.2 1.3 1.4} {1.2 1.3 1.4}
+
+do_test capi3-5.11 {
+ sqlite3_step $STMT
+} SQLITE_DONE
+
+do_test capi3-5.12 {
+ sqlite3_finalize $STMT
+} SQLITE_OK
+
+do_test capi3-5.20 {
+ set sql "SELECT a, sum(b), max(c) FROM t1 GROUP BY a"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_column_count $STMT
+} 3
+
+check_header $STMT capi3-5.21 {a sum(b) max(c)} {VARINT {} {}}
+check_origin_header $STMT capi3-5.22 {main {} {}} {t1 {} {}} {a {} {}}
+do_test capi3-5.23 {
+ sqlite3_finalize $STMT
+} SQLITE_OK
+
+do_test capi3-5.30 {
+ set sql "SELECT a AS x, sum(b) AS y, max(c) AS z FROM t1 AS m GROUP BY x"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_column_count $STMT
+} 3
+
+check_header $STMT capi3-5.31 {x y z} {VARINT {} {}}
+check_origin_header $STMT capi3-5.32 {main {} {}} {t1 {} {}} {a {} {}}
+do_test capi3-5.33 {
+ sqlite3_finalize $STMT
+} SQLITE_OK
+
+
+set ::ENC [execsql {pragma encoding}]
+db close
+
+do_test capi3-6.0 {
+ sqlite3 db test.db
+ set DB [sqlite3_connection_pointer db]
+ if {[sqlite3 -has-codec]==0} { sqlite3_key $DB xyzzy }
+ set sql {SELECT a FROM t1 order by rowid}
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ expr 0
+} {0}
+do_test capi3-6.1 {
+ db cache flush
+ sqlite3_close $DB
+} {SQLITE_BUSY}
+do_test capi3-6.2 {
+ sqlite3_step $STMT
+} {SQLITE_ERROR}
+#check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1}
+do_test capi3-6.3 {
+ sqlite3_finalize $STMT
+} {SQLITE_SCHEMA}
+do_test capi3-6.4-misuse {
+ db cache flush
+ sqlite3_close $DB
+} {SQLITE_OK}
+db close
+
+# This procedure sets the value of the file-format in file 'test.db'
+# to $newval. Also, the schema cookie is incremented.
+#
+proc set_file_format {newval} {
+ hexio_write test.db 44 [hexio_render_int32 $newval]
+ set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
+ incr schemacookie
+ hexio_write test.db 40 [hexio_render_int32 $schemacookie]
+ return {}
+}
+
+# This procedure returns the value of the file-format in file 'test.db'.
+#
+proc get_file_format {{fname test.db}} {
+ return [hexio_get_int [hexio_read $fname 44 4]]
+}
+
+if {![sqlite3 -has-codec]} {
+ # Test what happens when the library encounters a newer file format.
+ do_test capi3-7.1 {
+ set_file_format 5
+ } {}
+ do_test capi3-7.2 {
+ catch { sqlite3 db test.db }
+ catchsql {
+ SELECT * FROM sqlite_master;
+ }
+ } {1 {unsupported file format}}
+ db close
+}
+
+if {![sqlite3 -has-codec]} {
+ # Now test that the library correctly handles bogus entries in the
+ # sqlite_master table (schema corruption).
+ do_test capi3-8.1 {
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(a);
+ }
+ db close
+ } {}
+ do_test capi3-8.2 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA writable_schema=ON;
+ INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL);
+ }
+ db close
+ } {}
+ do_test capi3-8.3 {
+ catch { sqlite3 db test.db }
+ catchsql {
+ SELECT * FROM sqlite_master;
+ }
+ } {1 {malformed database schema (?)}}
+ do_test capi3-8.4 {
+ # Build a 5-field row record. The first field is a string 'table', and
+ # subsequent fields are all NULL.
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(a);
+ PRAGMA writable_schema=ON;
+ INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL);
+ }
+ db close
+ } {};
+ do_test capi3-8.5 {
+ catch { sqlite3 db test.db }
+ catchsql {
+ SELECT * FROM sqlite_master;
+ }
+ } {1 {malformed database schema (?)}}
+ db close
+}
+forcedelete test.db
+forcedelete test.db-journal
+
+
+# Test the english language string equivalents for sqlite error codes
+set code2english [list \
+SQLITE_OK {not an error} \
+SQLITE_ERROR {SQL logic error or missing database} \
+SQLITE_PERM {access permission denied} \
+SQLITE_ABORT {callback requested query abort} \
+SQLITE_BUSY {database is locked} \
+SQLITE_LOCKED {database table is locked} \
+SQLITE_NOMEM {out of memory} \
+SQLITE_READONLY {attempt to write a readonly database} \
+SQLITE_INTERRUPT {interrupted} \
+SQLITE_IOERR {disk I/O error} \
+SQLITE_CORRUPT {database disk image is malformed} \
+SQLITE_FULL {database or disk is full} \
+SQLITE_CANTOPEN {unable to open database file} \
+SQLITE_EMPTY {table contains no data} \
+SQLITE_SCHEMA {database schema has changed} \
+SQLITE_CONSTRAINT {constraint failed} \
+SQLITE_MISMATCH {datatype mismatch} \
+SQLITE_MISUSE {library routine called out of sequence} \
+SQLITE_NOLFS {large file support is disabled} \
+SQLITE_AUTH {authorization denied} \
+SQLITE_FORMAT {auxiliary database format error} \
+SQLITE_RANGE {bind or column index out of range} \
+SQLITE_NOTADB {file is encrypted or is not a database} \
+unknownerror {unknown error} \
+]
+
+set test_number 1
+foreach {code english} $code2english {
+ do_test capi3-9.$test_number "sqlite3_test_errstr $code" $english
+ incr test_number
+}
+
+# Test the error message when a "real" out of memory occurs.
+ifcapable memdebug {
+ do_test capi3-10-1 {
+ sqlite3 db test.db
+ set DB [sqlite3_connection_pointer db]
+ sqlite3_memdebug_fail 1
+ catchsql {
+ select * from sqlite_master;
+ }
+ } {1 {out of memory}}
+ do_test capi3-10-2 {
+ sqlite3_errmsg $::DB
+ } {out of memory}
+ ifcapable {utf16} {
+ do_test capi3-10-3 {
+ utf8 [sqlite3_errmsg16 $::DB]
+ } {out of memory}
+ }
+ db close
+ sqlite3_memdebug_fail -1
+ do_test capi3-10-4 {
+ sqlite3 db test.db
+ set DB [sqlite3_connection_pointer db]
+ sqlite3_memdebug_fail 1
+ catchsql {
+ select * from sqlite_master where rowid>5;
+ }
+ } {1 {out of memory}}
+ do_test capi3-10-5 {
+ sqlite3_errmsg $::DB
+ } {out of memory}
+ ifcapable {utf16} {
+ do_test capi3-10-6 {
+ utf8 [sqlite3_errmsg16 $::DB]
+ } {out of memory}
+ }
+ db close
+ sqlite3_memdebug_fail -1
+}
+
+# The following tests - capi3-11.* - test that a COMMIT or ROLLBACK
+# statement issued while there are still outstanding VMs that are part of
+# the transaction fails.
+sqlite3 db test.db
+set DB [sqlite3_connection_pointer db]
+sqlite_register_test_function $DB func
+do_test capi3-11.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'int');
+ INSERT INTO t1 VALUES(2, 'notatype');
+ }
+} {}
+do_test capi3-11.1.1 {
+ sqlite3_get_autocommit $DB
+} 0
+do_test capi3-11.2 {
+ set STMT [sqlite3_prepare $DB "SELECT func(b, a) FROM t1" -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+
+# As of 3.6.5 a COMMIT is OK during while a query is still running -
+# as long as it is a read-only query and not an incremental BLOB write.
+#
+do_test capi3-11.3.1 {
+ catchsql {
+ COMMIT;
+ }
+} {0 {}}
+do_test capi3-11.3.2 {
+ sqlite3_extended_errcode $DB
+} {SQLITE_OK}
+do_test capi3-11.3.3 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3-11.3.4 {
+ db eval {PRAGMA lock_status}
+} {main shared temp closed}
+
+do_test capi3-11.4 {
+ sqlite3_step $STMT
+} {SQLITE_ERROR}
+do_test capi3-11.5 {
+ sqlite3_finalize $STMT
+} {SQLITE_ERROR}
+do_test capi3-11.6 {
+ catchsql {
+ SELECT * FROM t1;
+ }
+} {0 {1 int 2 notatype}}
+do_test capi3-11.7 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3-11.8 {
+ execsql {
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ BEGIN;
+ INSERT INTO t2 VALUES(3);
+ }
+} {}
+do_test capi3-11.8.1 {
+ sqlite3_get_autocommit $DB
+} 0
+do_test capi3-11.9 {
+ set STMT [sqlite3_prepare $DB "SELECT a FROM t2" -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3-11.9.1 {
+ sqlite3_get_autocommit $DB
+} 0
+do_test capi3-11.9.2 {
+ catchsql {
+ ROLLBACK;
+ }
+} {1 {cannot rollback transaction - SQL statements in progress}}
+do_test capi3-11.9.3 {
+ sqlite3_get_autocommit $DB
+} 0
+do_test capi3-11.10 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3-11.11 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3-11.12 {
+ sqlite3_step $STMT
+} {SQLITE_DONE}
+do_test capi3-11.13 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+do_test capi3-11.14 {
+ execsql {
+ SELECT a FROM t2;
+ }
+} {1 2 3}
+do_test capi3-11.14.1 {
+ sqlite3_get_autocommit $DB
+} 0
+do_test capi3-11.15 {
+ catchsql {
+ ROLLBACK;
+ }
+} {0 {}}
+do_test capi3-11.15.1 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3-11.16 {
+ execsql {
+ SELECT a FROM t2;
+ }
+} {1 2}
+
+# Sanity check on the definition of 'outstanding VM'. This means any VM
+# that has had sqlite3_step() called more recently than sqlite3_finalize() or
+# sqlite3_reset(). So a VM that has just been prepared or reset does not
+# count as an active VM.
+do_test capi3-11.17 {
+ execsql {
+ BEGIN;
+ }
+} {}
+do_test capi3-11.18 {
+ set STMT [sqlite3_prepare $DB "SELECT a FROM t1" -1 TAIL]
+ catchsql {
+ COMMIT;
+ }
+} {0 {}}
+do_test capi3-11.19 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3-11.20 {
+ catchsql {
+ BEGIN;
+ COMMIT;
+ }
+} {0 {}}
+do_test capi3-11.20 {
+ sqlite3_reset $STMT
+ catchsql {
+ COMMIT;
+ }
+} {1 {cannot commit - no transaction is active}}
+do_test capi3-11.21 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+# The following tests - capi3-12.* - check that its Ok to start a
+# transaction while other VMs are active, and that its Ok to execute
+# atomic updates in the same situation
+#
+do_test capi3-12.1 {
+ set STMT [sqlite3_prepare $DB "SELECT a FROM t2" -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3-12.2 {
+ catchsql {
+ INSERT INTO t1 VALUES(3, NULL);
+ }
+} {0 {}}
+do_test capi3-12.3 {
+ catchsql {
+ INSERT INTO t2 VALUES(4);
+ }
+} {0 {}}
+do_test capi3-12.4 {
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(4, NULL);
+ }
+} {0 {}}
+do_test capi3-12.5 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3-12.5.1 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3-12.6 {
+ sqlite3_step $STMT
+} {SQLITE_DONE}
+do_test capi3-12.7 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+do_test capi3-12.8 {
+ execsql {
+ COMMIT;
+ SELECT a FROM t1;
+ }
+} {1 2 3 4}
+
+# Test cases capi3-13.* test the sqlite3_clear_bindings() and
+# sqlite3_sleep APIs.
+#
+if {[llength [info commands sqlite3_clear_bindings]]>0} {
+ do_test capi3-13.1 {
+ execsql {
+ DELETE FROM t1;
+ }
+ set STMT [sqlite3_prepare $DB "INSERT INTO t1 VALUES(?, ?)" -1 TAIL]
+ sqlite3_step $STMT
+ } {SQLITE_DONE}
+ do_test capi3-13.2 {
+ sqlite3_reset $STMT
+ sqlite3_bind_text $STMT 1 hello 5
+ sqlite3_bind_text $STMT 2 world 5
+ sqlite3_step $STMT
+ } {SQLITE_DONE}
+ do_test capi3-13.3 {
+ sqlite3_reset $STMT
+ sqlite3_clear_bindings $STMT
+ sqlite3_step $STMT
+ } {SQLITE_DONE}
+ do_test capi3-13-4 {
+ sqlite3_finalize $STMT
+ execsql {
+ SELECT * FROM t1;
+ }
+ } {{} {} hello world {} {}}
+}
+if {[llength [info commands sqlite3_sleep]]>0} {
+ do_test capi3-13-5 {
+ set ms [sqlite3_sleep 80]
+ expr {$ms==80 || $ms==1000}
+ } {1}
+}
+
+# Ticket #1219: Make sure binding APIs can handle a NULL pointer.
+#
+do_test capi3-14.1-misuse {
+ set rc [catch {sqlite3_bind_text 0 1 hello 5} msg]
+ lappend rc $msg
+} {1 SQLITE_MISUSE}
+
+# Ticket #1650: Honor the nBytes parameter to sqlite3_prepare.
+#
+do_test capi3-15.1 {
+ set sql {SELECT * FROM t2}
+ set nbytes [string length $sql]
+ append sql { WHERE a==1}
+ set STMT [sqlite3_prepare $DB $sql $nbytes TAIL]
+ sqlite3_step $STMT
+ sqlite3_column_int $STMT 0
+} {1}
+do_test capi3-15.2 {
+ sqlite3_step $STMT
+ sqlite3_column_int $STMT 0
+} {2}
+do_test capi3-15.3 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+do_test capi3-15.4 {
+ # 123456789 1234567
+ set sql {SELECT 1234567890}
+ set STMT [sqlite3_prepare $DB $sql 8 TAIL]
+ sqlite3_step $STMT
+ set v1 [sqlite3_column_int $STMT 0]
+ sqlite3_finalize $STMT
+ set v1
+} {1}
+do_test capi3-15.5 {
+ # 123456789 1234567
+ set sql {SELECT 1234567890}
+ set STMT [sqlite3_prepare $DB $sql 9 TAIL]
+ sqlite3_step $STMT
+ set v1 [sqlite3_column_int $STMT 0]
+ sqlite3_finalize $STMT
+ set v1
+} {12}
+do_test capi3-15.6 {
+ # 123456789 1234567
+ set sql {SELECT 1234567890}
+ set STMT [sqlite3_prepare $DB $sql 12 TAIL]
+ sqlite3_step $STMT
+ set v1 [sqlite3_column_int $STMT 0]
+ sqlite3_finalize $STMT
+ set v1
+} {12345}
+do_test capi3-15.7 {
+ # 123456789 1234567
+ set sql {SELECT 12.34567890}
+ set STMT [sqlite3_prepare $DB $sql 12 TAIL]
+ sqlite3_step $STMT
+ set v1 [sqlite3_column_double $STMT 0]
+ sqlite3_finalize $STMT
+ set v1
+} {12.34}
+do_test capi3-15.8 {
+ # 123456789 1234567
+ set sql {SELECT 12.34567890}
+ set STMT [sqlite3_prepare $DB $sql 14 TAIL]
+ sqlite3_step $STMT
+ set v1 [sqlite3_column_double $STMT 0]
+ sqlite3_finalize $STMT
+ set v1
+} {12.3456}
+
+# Make sure code is always generated even if an IF EXISTS or
+# IF NOT EXISTS clause is present that the table does not or
+# does exists. That way we will always have a prepared statement
+# to expire when the schema changes.
+#
+do_test capi3-16.1 {
+ set sql {DROP TABLE IF EXISTS t3}
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_finalize $STMT
+ expr {$STMT!=""}
+} {1}
+do_test capi3-16.2 {
+ set sql {CREATE TABLE IF NOT EXISTS t1(x,y)}
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_finalize $STMT
+ expr {$STMT!=""}
+} {1}
+
+# But still we do not generate code if there is no SQL
+#
+do_test capi3-16.3 {
+ set STMT [sqlite3_prepare $DB {} -1 TAIL]
+ sqlite3_finalize $STMT
+ expr {$STMT==""}
+} {1}
+do_test capi3-16.4 {
+ set STMT [sqlite3_prepare $DB {;} -1 TAIL]
+ sqlite3_finalize $STMT
+ expr {$STMT==""}
+} {1}
+
+# Ticket #2426: Misuse of sqlite3_column_* by calling it after
+# a sqlite3_reset should be harmless.
+#
+do_test capi3-17.1 {
+ set STMT [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_column_int $STMT 0
+} {1}
+do_test capi3-17.2 {
+ sqlite3_reset $STMT
+ sqlite3_column_int $STMT 0
+} {0}
+do_test capi3-17.3 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+# Verify that sqlite3_step() fails with an SQLITE_SCHEMA error
+# when the statement is prepared with sqlite3_prepare() (not
+# sqlite3_prepare_v2()) and the schema has changed.
+#
+do_test capi3-18.1 {
+ set STMT [sqlite3_prepare db {SELECT * FROM t2} -1 TAIL]
+ sqlite3 db2 test.db
+ db2 eval {CREATE TABLE t3(x)}
+ db2 close
+ sqlite3_step $STMT
+} {SQLITE_ERROR}
+do_test capi3-18.2 {
+ sqlite3_reset $STMT
+ sqlite3_errcode db
+} {SQLITE_SCHEMA}
+do_test capi3-18.3 {
+ sqlite3_errmsg db
+} {database schema has changed}
+# The error persist on retry when sqlite3_prepare() has been used.
+do_test capi3-18.4 {
+ sqlite3_step $STMT
+} {SQLITE_ERROR}
+do_test capi3-18.5 {
+ sqlite3_reset $STMT
+ sqlite3_errcode db
+} {SQLITE_SCHEMA}
+do_test capi3-18.6 {
+ sqlite3_errmsg db
+} {database schema has changed}
+sqlite3_finalize $STMT
+
+# Ticket #3134. Prepare a statement with an nBytes parameter of 0.
+# Make sure this works correctly and does not reference memory out of
+# range.
+#
+do_test capi3-19.1 {
+ sqlite3_prepare_tkt3134 db
+} {}
+
+# Tests of the interface when no VFS is registered.
+#
+if {![info exists tester_do_binarylog]} {
+ db close
+ vfs_unregister_all
+ do_test capi3-20.1 {
+ sqlite3_sleep 100
+ } {0}
+ vfs_reregister_all
+}
+
+finish_test
diff --git a/test/capi3b.test b/test/capi3b.test
new file mode 100644
index 0000000..72bbbaf
--- /dev/null
+++ b/test/capi3b.test
@@ -0,0 +1,145 @@
+# 2004 September 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script testing the callback-free C/C++ API and in
+# particular the behavior of sqlite3_step() when trying to commit
+# with lock contention.
+#
+# $Id: capi3b.test,v 1.4 2007/08/10 19:46:14 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+# These tests depend on the pager holding changes in cache
+# until it is time to commit. But that won't happen if the
+# soft-heap-limit is set too low. So disable the soft heap limit
+# for the duration of this test.
+#
+sqlite3_soft_heap_limit 0
+
+
+set DB [sqlite3_connection_pointer db]
+sqlite3 db2 test.db
+set DB2 [sqlite3_connection_pointer db2]
+
+# Create some data in the database
+#
+do_test capi3b-1.1 {
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ SELECT * FROM t1
+ }
+} {1 2}
+
+# Make sure the second database connection can see the data
+#
+do_test capi3b-1.2 {
+ execsql {
+ SELECT * FROM t1
+ } db2
+} {1 2}
+
+# First database connection acquires a shared lock
+#
+do_test capi3b-1.3 {
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+} {1 2}
+
+# Second database connection tries to write. The sqlite3_step()
+# function returns SQLITE_BUSY because it cannot commit.
+#
+do_test capi3b-1.4 {
+ set VM [sqlite3_prepare $DB2 {INSERT INTO t1 VALUES(3)} -1 TAIL]
+ sqlite3_step $VM
+} SQLITE_BUSY
+
+# The sqlite3_step call can be repeated multiple times.
+#
+do_test capi3b-1.5.1 {
+ sqlite3_step $VM
+} SQLITE_BUSY
+do_test capi3b-1.5.2 {
+ sqlite3_step $VM
+} SQLITE_BUSY
+
+# The first connection closes its transaction. This allows the second
+# connections sqlite3_step to succeed.
+#
+do_test capi3b-1.6 {
+ execsql COMMIT
+ sqlite3_step $VM
+} SQLITE_DONE
+do_test capi3b-1.7 {
+ sqlite3_finalize $VM
+} SQLITE_OK
+do_test capi3b-1.8 {
+ execsql {SELECT * FROM t1} db2
+} {1 2 3}
+do_test capi3b-1.9 {
+ execsql {SELECT * FROM t1}
+} {1 2 3}
+
+# Start doing a SELECT with one connection. This gets a SHARED lock.
+# Then do an INSERT with the other connection. The INSERT should
+# not be able to complete until the SELECT finishes.
+#
+do_test capi3b-2.1 {
+ set VM1 [sqlite3_prepare $DB {SELECT * FROM t1} -1 TAIL]
+ sqlite3_step $VM1
+} SQLITE_ROW
+do_test capi3b-2.2 {
+ sqlite3_column_text $VM1 0
+} 1
+do_test capi3b-2.3 {
+ set VM2 [sqlite3_prepare $DB2 {INSERT INTO t1 VALUES(4)} -1 TAIL]
+ sqlite3_step $VM2
+} SQLITE_BUSY
+do_test capi3b-2.4 {
+ sqlite3_step $VM1
+} SQLITE_ROW
+do_test capi3b-2.5 {
+ sqlite3_column_text $VM1 0
+} 2
+do_test capi3b-2.6 {
+ sqlite3_step $VM2
+} SQLITE_BUSY
+do_test capi3b-2.7 {
+ sqlite3_step $VM1
+} SQLITE_ROW
+do_test capi3b-2.8 {
+ sqlite3_column_text $VM1 0
+} 3
+do_test capi3b-2.9 {
+ sqlite3_step $VM2
+} SQLITE_BUSY
+do_test capi3b-2.10 {
+ sqlite3_step $VM1
+} SQLITE_DONE
+do_test capi3b-2.11 {
+ sqlite3_step $VM2
+} SQLITE_DONE
+do_test capi3b-2.12 {
+ sqlite3_finalize $VM1
+ sqlite3_finalize $VM2
+ execsql {SELECT * FROM t1}
+} {1 2 3 4}
+
+catch {db2 close}
+
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+finish_test
diff --git a/test/capi3c.test b/test/capi3c.test
new file mode 100644
index 0000000..c1d5510
--- /dev/null
+++ b/test/capi3c.test
@@ -0,0 +1,1363 @@
+# 2006 November 08
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This is a copy of the capi3.test file that has been adapted to
+# test the new sqlite3_prepare_v2 interface.
+#
+# $Id: capi3c.test,v 1.23 2009/07/22 07:27:57 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Return the UTF-16 representation of the supplied UTF-8 string $str.
+# If $nt is true, append two 0x00 bytes as a nul terminator.
+proc utf16 {str {nt 1}} {
+ set r [encoding convertto unicode $str]
+ if {$nt} {
+ append r "\x00\x00"
+ }
+ return $r
+}
+
+# Return the UTF-8 representation of the supplied UTF-16 string $str.
+proc utf8 {str} {
+ # If $str ends in two 0x00 0x00 bytes, knock these off before
+ # converting to UTF-8 using TCL.
+ binary scan $str \c* vals
+ if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {
+ set str [binary format \c* [lrange $vals 0 end-2]]
+ }
+
+ set r [encoding convertfrom unicode $str]
+ return $r
+}
+
+# These tests complement those in capi2.test. They are organized
+# as follows:
+#
+# capi3c-1.*: Test sqlite3_prepare_v2
+# capi3c-2.*: Test sqlite3_prepare16_v2
+# capi3c-3.*: Test sqlite3_open
+# capi3c-4.*: Test sqlite3_open16
+# capi3c-5.*: Test the various sqlite3_result_* APIs
+# capi3c-6.*: Test that sqlite3_close fails if there are outstanding VMs.
+#
+
+set DB [sqlite3_connection_pointer db]
+
+do_test capi3c-1.0 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3c-1.1 {
+ set STMT [sqlite3_prepare_v2 $DB {SELECT name FROM sqlite_master} -1 TAIL]
+ sqlite3_finalize $STMT
+ set TAIL
+} {}
+do_test capi3c-1.2.1 {
+ sqlite3_errcode $DB
+} {SQLITE_OK}
+do_test capi3c-1.2.2 {
+ sqlite3_extended_errcode $DB
+} {SQLITE_OK}
+do_test capi3c-1.3 {
+ sqlite3_errmsg $DB
+} {not an error}
+do_test capi3c-1.4 {
+ set sql {SELECT name FROM sqlite_master;SELECT 10}
+ set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]
+ sqlite3_finalize $STMT
+ set TAIL
+} {SELECT 10}
+do_test capi3c-1.5 {
+ set sql {SELECT namex FROM sqlite_master}
+ catch {
+ set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]
+ }
+} {1}
+do_test capi3c-1.6.1 {
+ sqlite3_errcode $DB
+} {SQLITE_ERROR}
+do_test capi3c-1.6.2 {
+ sqlite3_extended_errcode $DB
+} {SQLITE_ERROR}
+do_test capi3c-1.7 {
+ sqlite3_errmsg $DB
+} {no such column: namex}
+
+
+ifcapable {utf16} {
+ do_test capi3c-2.1 {
+ set sql16 [utf16 {SELECT name FROM sqlite_master}]
+ set STMT [sqlite3_prepare16_v2 $DB $sql16 -1 ::TAIL]
+ sqlite3_finalize $STMT
+ utf8 $::TAIL
+ } {}
+ do_test capi3c-2.2 {
+ set sql [utf16 {SELECT name FROM sqlite_master;SELECT 10}]
+ set STMT [sqlite3_prepare16_v2 $DB $sql -1 TAIL]
+ sqlite3_finalize $STMT
+ utf8 $TAIL
+ } {SELECT 10}
+ do_test capi3c-2.3 {
+ set sql [utf16 {SELECT namex FROM sqlite_master}]
+ catch {
+ set STMT [sqlite3_prepare16_v2 $DB $sql -1 TAIL]
+ }
+ } {1}
+ do_test capi3c-2.4.1 {
+ sqlite3_errcode $DB
+ } {SQLITE_ERROR}
+ do_test capi3c-2.4.2 {
+ sqlite3_extended_errcode $DB
+ } {SQLITE_ERROR}
+ do_test capi3c-2.5 {
+ sqlite3_errmsg $DB
+ } {no such column: namex}
+
+ ifcapable schema_pragmas {
+ do_test capi3c-2.6 {
+ execsql {CREATE TABLE tablename(x)}
+ set sql16 [utf16 {PRAGMA table_info("TableName")}]
+ set STMT [sqlite3_prepare16_v2 $DB $sql16 -1 TAIL]
+ sqlite3_step $STMT
+ } SQLITE_ROW
+ do_test capi3c-2.7 {
+ sqlite3_step $STMT
+ } SQLITE_DONE
+ do_test capi3c-2.8 {
+ sqlite3_finalize $STMT
+ } SQLITE_OK
+ }
+
+} ;# endif utf16
+
+# rename sqlite3_open sqlite3_open_old
+# proc sqlite3_open {fname options} {sqlite3_open_new $fname $options}
+
+do_test capi3c-3.1 {
+ set db2 [sqlite3_open test.db {}]
+ sqlite3_errcode $db2
+} {SQLITE_OK}
+# FIX ME: Should test the db handle works.
+do_test capi3c-3.2 {
+ sqlite3_close $db2
+} {SQLITE_OK}
+do_test capi3c-3.3 {
+ catch {
+ set db2 [sqlite3_open /bogus/path/test.db {}]
+ }
+ sqlite3_errcode $db2
+} {SQLITE_CANTOPEN}
+do_test capi3c-3.4 {
+ sqlite3_errmsg $db2
+} {unable to open database file}
+do_test capi3c-3.5 {
+ sqlite3_close $db2
+} {SQLITE_OK}
+do_test capi3c-3.6.1-misuse {
+ sqlite3_close $db2
+} {SQLITE_MISUSE}
+do_test capi3c-3.6.2-misuse {
+ sqlite3_errmsg $db2
+} {library routine called out of sequence}
+ifcapable {utf16} {
+ do_test capi3c-3.6.3-misuse {
+ utf8 [sqlite3_errmsg16 $db2]
+ } {library routine called out of sequence}
+}
+
+# rename sqlite3_open ""
+# rename sqlite3_open_old sqlite3_open
+
+ifcapable {utf16} {
+do_test capi3c-4.1 {
+ set db2 [sqlite3_open16 [utf16 test.db] {}]
+ sqlite3_errcode $db2
+} {SQLITE_OK}
+# FIX ME: Should test the db handle works.
+do_test capi3c-4.2 {
+ sqlite3_close $db2
+} {SQLITE_OK}
+do_test capi3c-4.3 {
+ catch {
+ set db2 [sqlite3_open16 [utf16 /bogus/path/test.db] {}]
+ }
+ sqlite3_errcode $db2
+} {SQLITE_CANTOPEN}
+do_test capi3c-4.4 {
+ utf8 [sqlite3_errmsg16 $db2]
+} {unable to open database file}
+do_test capi3c-4.5 {
+ sqlite3_close $db2
+} {SQLITE_OK}
+} ;# utf16
+
+# This proc is used to test the following API calls:
+#
+# sqlite3_column_count
+# sqlite3_column_name
+# sqlite3_column_name16
+# sqlite3_column_decltype
+# sqlite3_column_decltype16
+#
+# $STMT is a compiled SQL statement. $test is a prefix
+# to use for test names within this proc. $names is a list
+# of the column names that should be returned by $STMT.
+# $decltypes is a list of column declaration types for $STMT.
+#
+# Example:
+#
+# set STMT [sqlite3_prepare_v2 "SELECT 1, 2, 2;" -1 DUMMY]
+# check_header test1.1 {1 2 3} {"" "" ""}
+#
+proc check_header {STMT test names decltypes} {
+
+ # Use the return value of sqlite3_column_count() to build
+ # a list of column indexes. i.e. If sqlite3_column_count
+ # is 3, build the list {0 1 2}.
+ set ::idxlist [list]
+ set ::numcols [sqlite3_column_count $STMT]
+ for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}
+
+ # Column names in UTF-8
+ do_test $test.1 {
+ set cnamelist [list]
+ foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]}
+ set cnamelist
+ } $names
+
+ # Column names in UTF-16
+ ifcapable {utf16} {
+ do_test $test.2 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]
+ }
+ set cnamelist
+ } $names
+ }
+
+ # Column names in UTF-8
+ do_test $test.3 {
+ set cnamelist [list]
+ foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]}
+ set cnamelist
+ } $names
+
+ # Column names in UTF-16
+ ifcapable {utf16} {
+ do_test $test.4 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]
+ }
+ set cnamelist
+ } $names
+ }
+
+ # Column names in UTF-8
+ do_test $test.5 {
+ set cnamelist [list]
+ foreach i $idxlist {lappend cnamelist [sqlite3_column_decltype $STMT $i]}
+ set cnamelist
+ } $decltypes
+
+ # Column declaration types in UTF-16
+ ifcapable {utf16} {
+ do_test $test.6 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_decltype16 $STMT $i]]
+ }
+ set cnamelist
+ } $decltypes
+ }
+
+
+ # Test some out of range conditions:
+ ifcapable {utf16} {
+ do_test $test.7 {
+ list \
+ [sqlite3_column_name $STMT -1] \
+ [sqlite3_column_name16 $STMT -1] \
+ [sqlite3_column_decltype $STMT -1] \
+ [sqlite3_column_decltype16 $STMT -1] \
+ [sqlite3_column_name $STMT $numcols] \
+ [sqlite3_column_name16 $STMT $numcols] \
+ [sqlite3_column_decltype $STMT $numcols] \
+ [sqlite3_column_decltype16 $STMT $numcols]
+ } {{} {} {} {} {} {} {} {}}
+ }
+}
+
+# This proc is used to test the following API calls:
+#
+# sqlite3_column_origin_name
+# sqlite3_column_origin_name16
+# sqlite3_column_table_name
+# sqlite3_column_table_name16
+# sqlite3_column_database_name
+# sqlite3_column_database_name16
+#
+# $STMT is a compiled SQL statement. $test is a prefix
+# to use for test names within this proc. $names is a list
+# of the column names that should be returned by $STMT.
+# $decltypes is a list of column declaration types for $STMT.
+#
+# Example:
+#
+# set STMT [sqlite3_prepare_v2 "SELECT 1, 2, 2;" -1 DUMMY]
+# check_header test1.1 {1 2 3} {"" "" ""}
+#
+proc check_origin_header {STMT test dbs tables cols} {
+ # If sqlite3_column_origin_name() and friends are not compiled into
+ # this build, this proc is a no-op.
+ifcapable columnmetadata {
+
+ # Use the return value of sqlite3_column_count() to build
+ # a list of column indexes. i.e. If sqlite3_column_count
+ # is 3, build the list {0 1 2}.
+ set ::idxlist [list]
+ set ::numcols [sqlite3_column_count $STMT]
+ for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}
+
+ # Database names in UTF-8
+ do_test $test.8 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [sqlite3_column_database_name $STMT $i]
+ }
+ set cnamelist
+ } $dbs
+
+ # Database names in UTF-16
+ ifcapable {utf16} {
+ do_test $test.9 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_database_name16 $STMT $i]]
+ }
+ set cnamelist
+ } $dbs
+ }
+
+ # Table names in UTF-8
+ do_test $test.10 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [sqlite3_column_table_name $STMT $i]
+ }
+ set cnamelist
+ } $tables
+
+ # Table names in UTF-16
+ ifcapable {utf16} {
+ do_test $test.11 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_table_name16 $STMT $i]]
+ }
+ set cnamelist
+ } $tables
+ }
+
+ # Origin names in UTF-8
+ do_test $test.12 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [sqlite3_column_origin_name $STMT $i]
+ }
+ set cnamelist
+ } $cols
+
+ # Origin declaration types in UTF-16
+ ifcapable {utf16} {
+ do_test $test.13 {
+ set cnamelist [list]
+ foreach i $idxlist {
+ lappend cnamelist [utf8 [sqlite3_column_origin_name16 $STMT $i]]
+ }
+ set cnamelist
+ } $cols
+ }
+ }
+}
+
+# This proc is used to test the following APIs:
+#
+# sqlite3_data_count
+# sqlite3_column_type
+# sqlite3_column_int
+# sqlite3_column_text
+# sqlite3_column_text16
+# sqlite3_column_double
+#
+# $STMT is a compiled SQL statement for which the previous call
+# to sqlite3_step returned SQLITE_ROW. $test is a prefix to use
+# for test names within this proc. $types is a list of the
+# manifest types for the current row. $ints, $doubles and $strings
+# are lists of the integer, real and string representations of
+# the values in the current row.
+#
+# Example:
+#
+# set STMT [sqlite3_prepare_v2 "SELECT 'hello', 1.1, NULL" -1 DUMMY]
+# sqlite3_step $STMT
+# check_data test1.2 {TEXT REAL NULL} {0 1 0} {0 1.1 0} {hello 1.1 {}}
+#
+proc check_data {STMT test types ints doubles strings} {
+
+ # Use the return value of sqlite3_column_count() to build
+ # a list of column indexes. i.e. If sqlite3_column_count
+ # is 3, build the list {0 1 2}.
+ set ::idxlist [list]
+ set numcols [sqlite3_data_count $STMT]
+ for {set i 0} {$i < $numcols} {incr i} {lappend ::idxlist $i}
+
+# types
+do_test $test.1 {
+ set types [list]
+ foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}
+ set types
+} $types
+
+# Integers
+do_test $test.2 {
+ set ints [list]
+ foreach i $idxlist {lappend ints [sqlite3_column_int64 $STMT $i]}
+ set ints
+} $ints
+
+# bytes
+set lens [list]
+foreach i $::idxlist {
+ lappend lens [string length [lindex $strings $i]]
+}
+do_test $test.3 {
+ set bytes [list]
+ set lens [list]
+ foreach i $idxlist {
+ lappend bytes [sqlite3_column_bytes $STMT $i]
+ }
+ set bytes
+} $lens
+
+# bytes16
+ifcapable {utf16} {
+ set lens [list]
+ foreach i $::idxlist {
+ lappend lens [expr 2 * [string length [lindex $strings $i]]]
+ }
+ do_test $test.4 {
+ set bytes [list]
+ set lens [list]
+ foreach i $idxlist {
+ lappend bytes [sqlite3_column_bytes16 $STMT $i]
+ }
+ set bytes
+ } $lens
+}
+
+# Blob
+do_test $test.5 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [sqlite3_column_blob $STMT $i]}
+ set utf8
+} $strings
+
+# UTF-8
+do_test $test.6 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}
+ set utf8
+} $strings
+
+# Floats
+do_test $test.7 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}
+ set utf8
+} $doubles
+
+# UTF-16
+ifcapable {utf16} {
+ do_test $test.8 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]}
+ set utf8
+ } $strings
+}
+
+# Integers
+do_test $test.9 {
+ set ints [list]
+ foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}
+ set ints
+} $ints
+
+# Floats
+do_test $test.10 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}
+ set utf8
+} $doubles
+
+# UTF-8
+do_test $test.11 {
+ set utf8 [list]
+ foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}
+ set utf8
+} $strings
+
+# Types
+do_test $test.12 {
+ set types [list]
+ foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}
+ set types
+} $types
+
+# Test that an out of range request returns the equivalent of NULL
+do_test $test.13 {
+ sqlite3_column_int $STMT -1
+} {0}
+do_test $test.13 {
+ sqlite3_column_text $STMT -1
+} {}
+
+}
+
+ifcapable !floatingpoint {
+ finish_test
+ return
+}
+
+do_test capi3c-5.0 {
+ execsql {
+ CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16));
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES('one', 'two', NULL);
+ INSERT INTO t1 VALUES(1.2, 1.3, 1.4);
+ }
+ set sql "SELECT * FROM t1"
+ set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]
+ sqlite3_column_count $STMT
+} 3
+
+check_header $STMT capi3c-5.1 {a b c} {VARINT BLOB VARCHAR(16)}
+check_origin_header $STMT capi3c-5.1 {main main main} {t1 t1 t1} {a b c}
+do_test capi3c-5.2 {
+ sqlite3_step $STMT
+} SQLITE_ROW
+
+check_header $STMT capi3c-5.3 {a b c} {VARINT BLOB VARCHAR(16)}
+check_origin_header $STMT capi3c-5.3 {main main main} {t1 t1 t1} {a b c}
+check_data $STMT capi3c-5.4 {INTEGER INTEGER TEXT} {1 2 3} {1.0 2.0 3.0} {1 2 3}
+
+do_test capi3c-5.5 {
+ sqlite3_step $STMT
+} SQLITE_ROW
+
+check_header $STMT capi3c-5.6 {a b c} {VARINT BLOB VARCHAR(16)}
+check_origin_header $STMT capi3c-5.6 {main main main} {t1 t1 t1} {a b c}
+check_data $STMT capi3c-5.7 {TEXT TEXT NULL} {0 0 0} {0.0 0.0 0.0} {one two {}}
+
+do_test capi3c-5.8 {
+ sqlite3_step $STMT
+} SQLITE_ROW
+
+check_header $STMT capi3c-5.9 {a b c} {VARINT BLOB VARCHAR(16)}
+check_origin_header $STMT capi3c-5.9 {main main main} {t1 t1 t1} {a b c}
+check_data $STMT capi3c-5.10 {FLOAT FLOAT TEXT} {1 1 1} {1.2 1.3 1.4} {1.2 1.3 1.4}
+
+do_test capi3c-5.11 {
+ sqlite3_step $STMT
+} SQLITE_DONE
+
+do_test capi3c-5.12 {
+ sqlite3_finalize $STMT
+} SQLITE_OK
+
+do_test capi3c-5.20 {
+ set sql "SELECT a, sum(b), max(c) FROM t1 GROUP BY a"
+ set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]
+ sqlite3_column_count $STMT
+} 3
+
+check_header $STMT capi3c-5.21 {a sum(b) max(c)} {VARINT {} {}}
+check_origin_header $STMT capi3c-5.22 {main {} {}} {t1 {} {}} {a {} {}}
+do_test capi3c-5.23 {
+ sqlite3_finalize $STMT
+} SQLITE_OK
+
+
+set ::ENC [execsql {pragma encoding}]
+db close
+
+do_test capi3c-6.0 {
+ sqlite3 db test.db
+ set DB [sqlite3_connection_pointer db]
+ if {[sqlite3 -has-codec]==0} { sqlite3_key $DB xyzzy }
+ set sql {SELECT a FROM t1 order by rowid}
+ set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]
+ expr 0
+} {0}
+do_test capi3c-6.1 {
+ db cache flush
+ sqlite3_close $DB
+} {SQLITE_BUSY}
+do_test capi3c-6.2 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+check_data $STMT capi3c-6.3 {INTEGER} {1} {1.0} {1}
+do_test capi3c-6.3 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+do_test capi3c-6.4 {
+ db cache flush
+ sqlite3_close $DB
+} {SQLITE_OK}
+do_test capi3c-6.99-misuse {
+ db close
+} {}
+
+# This procedure sets the value of the file-format in file 'test.db'
+# to $newval. Also, the schema cookie is incremented.
+#
+proc set_file_format {newval} {
+ hexio_write test.db 44 [hexio_render_int32 $newval]
+ set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
+ incr schemacookie
+ hexio_write test.db 40 [hexio_render_int32 $schemacookie]
+ return {}
+}
+
+# This procedure returns the value of the file-format in file 'test.db'.
+#
+proc get_file_format {{fname test.db}} {
+ return [hexio_get_int [hexio_read $fname 44 4]]
+}
+
+if {![sqlite3 -has-codec]} {
+ # Test what happens when the library encounters a newer file format.
+ do_test capi3c-7.1 {
+ set_file_format 5
+ } {}
+ do_test capi3c-7.2 {
+ catch { sqlite3 db test.db }
+ catchsql {
+ SELECT * FROM sqlite_master;
+ }
+ } {1 {unsupported file format}}
+ db close
+}
+
+if {![sqlite3 -has-codec]} {
+ # Now test that the library correctly handles bogus entries in the
+ # sqlite_master table (schema corruption).
+ do_test capi3c-8.1 {
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(a);
+ }
+ db close
+ } {}
+ do_test capi3c-8.2 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA writable_schema=ON;
+ INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL);
+ }
+ db close
+ } {}
+ do_test capi3c-8.3 {
+ catch { sqlite3 db test.db }
+ catchsql {
+ SELECT * FROM sqlite_master;
+ }
+ } {1 {malformed database schema (?)}}
+ do_test capi3c-8.4 {
+ # Build a 5-field row record. The first field is a string 'table', and
+ # subsequent fields are all NULL.
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(a);
+ PRAGMA writable_schema=ON;
+ INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL);
+ }
+ db close
+ } {};
+ do_test capi3c-8.5 {
+ catch { sqlite3 db test.db }
+ catchsql {
+ SELECT * FROM sqlite_master;
+ }
+ } {1 {malformed database schema (?)}}
+ db close
+}
+forcedelete test.db
+forcedelete test.db-journal
+
+
+# Test the english language string equivalents for sqlite error codes
+set code2english [list \
+SQLITE_OK {not an error} \
+SQLITE_ERROR {SQL logic error or missing database} \
+SQLITE_PERM {access permission denied} \
+SQLITE_ABORT {callback requested query abort} \
+SQLITE_BUSY {database is locked} \
+SQLITE_LOCKED {database table is locked} \
+SQLITE_NOMEM {out of memory} \
+SQLITE_READONLY {attempt to write a readonly database} \
+SQLITE_INTERRUPT {interrupted} \
+SQLITE_IOERR {disk I/O error} \
+SQLITE_CORRUPT {database disk image is malformed} \
+SQLITE_FULL {database or disk is full} \
+SQLITE_CANTOPEN {unable to open database file} \
+SQLITE_EMPTY {table contains no data} \
+SQLITE_SCHEMA {database schema has changed} \
+SQLITE_CONSTRAINT {constraint failed} \
+SQLITE_MISMATCH {datatype mismatch} \
+SQLITE_MISUSE {library routine called out of sequence} \
+SQLITE_NOLFS {large file support is disabled} \
+SQLITE_AUTH {authorization denied} \
+SQLITE_FORMAT {auxiliary database format error} \
+SQLITE_RANGE {bind or column index out of range} \
+SQLITE_NOTADB {file is encrypted or is not a database} \
+unknownerror {unknown error} \
+]
+
+set test_number 1
+foreach {code english} $code2english {
+ do_test capi3c-9.$test_number "sqlite3_test_errstr $code" $english
+ incr test_number
+}
+
+# Test the error message when a "real" out of memory occurs.
+ifcapable memdebug {
+ do_test capi3c-10-1 {
+ sqlite3 db test.db
+ set DB [sqlite3_connection_pointer db]
+ sqlite3_memdebug_fail 0
+ catchsql {
+ select * from sqlite_master;
+ }
+ } {1 {out of memory}}
+ do_test capi3c-10-2 {
+ sqlite3_errmsg $::DB
+ } {out of memory}
+ ifcapable {utf16} {
+ do_test capi3c-10-3 {
+ utf8 [sqlite3_errmsg16 $::DB]
+ } {out of memory}
+ }
+ db close
+ sqlite3_memdebug_fail -1
+}
+
+# The following tests - capi3c-11.* - test that a COMMIT or ROLLBACK
+# statement issued while there are still outstanding VMs that are part of
+# the transaction fails.
+sqlite3 db test.db
+set DB [sqlite3_connection_pointer db]
+sqlite_register_test_function $DB func
+do_test capi3c-11.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'int');
+ INSERT INTO t1 VALUES(2, 'notatype');
+ }
+} {}
+do_test capi3c-11.1.1 {
+ sqlite3_get_autocommit $DB
+} 0
+do_test capi3c-11.2 {
+ set STMT [sqlite3_prepare_v2 $DB "SELECT func(b, a) FROM t1" -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+
+# As of 3.6.5 a COMMIT is OK during while a query is still running -
+# as long as it is a read-only query and not an incremental BLOB write.
+#
+do_test capi3-11.3.1 {
+ catchsql {
+ COMMIT;
+ }
+} {0 {}}
+do_test capi3-11.3.2 {
+ sqlite3_extended_errcode $DB
+} {SQLITE_OK}
+do_test capi3-11.3.3 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3-11.3.4 {
+ db eval {PRAGMA lock_status}
+} {main shared temp closed}
+
+do_test capi3c-11.4 {
+ sqlite3_step $STMT
+} {SQLITE_ERROR}
+do_test capi3c-11.5 {
+ sqlite3_finalize $STMT
+} {SQLITE_ERROR}
+do_test capi3c-11.6 {
+ catchsql {
+ SELECT * FROM t1;
+ }
+} {0 {1 int 2 notatype}}
+do_test capi3c-11.7 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3c-11.8 {
+ execsql {
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ BEGIN;
+ INSERT INTO t2 VALUES(3);
+ }
+} {}
+do_test capi3c-11.8.1 {
+ sqlite3_get_autocommit $DB
+} 0
+do_test capi3c-11.9 {
+ set STMT [sqlite3_prepare_v2 $DB "SELECT a FROM t2" -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3c-11.9.1 {
+ sqlite3_get_autocommit $DB
+} 0
+do_test capi3c-11.9.2 {
+ catchsql {
+ ROLLBACK;
+ }
+} {1 {cannot rollback transaction - SQL statements in progress}}
+do_test capi3c-11.9.3 {
+ sqlite3_get_autocommit $DB
+} 0
+do_test capi3c-11.10 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3c-11.11 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3c-11.12 {
+ sqlite3_step $STMT
+} {SQLITE_DONE}
+do_test capi3c-11.13 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+do_test capi3c-11.14 {
+ execsql {
+ SELECT a FROM t2;
+ }
+} {1 2 3}
+do_test capi3c-11.14.1 {
+ sqlite3_get_autocommit $DB
+} 0
+do_test capi3c-11.15 {
+ catchsql {
+ ROLLBACK;
+ }
+} {0 {}}
+do_test capi3c-11.15.1 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3c-11.16 {
+ execsql {
+ SELECT a FROM t2;
+ }
+} {1 2}
+
+# Sanity check on the definition of 'outstanding VM'. This means any VM
+# that has had sqlite3_step() called more recently than sqlite3_finalize() or
+# sqlite3_reset(). So a VM that has just been prepared or reset does not
+# count as an active VM.
+do_test capi3c-11.17 {
+ execsql {
+ BEGIN;
+ }
+} {}
+do_test capi3c-11.18 {
+ set STMT [sqlite3_prepare_v2 $DB "SELECT a FROM t1" -1 TAIL]
+ catchsql {
+ COMMIT;
+ }
+} {0 {}}
+do_test capi3c-11.19 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3c-11.20 {
+ catchsql {
+ BEGIN;
+ COMMIT;
+ }
+} {0 {}}
+do_test capi3c-11.20 {
+ sqlite3_reset $STMT
+ catchsql {
+ COMMIT;
+ }
+} {1 {cannot commit - no transaction is active}}
+do_test capi3c-11.21 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+# The following tests - capi3c-12.* - check that its Ok to start a
+# transaction while other VMs are active, and that its Ok to execute
+# atomic updates in the same situation
+#
+do_test capi3c-12.1 {
+ set STMT [sqlite3_prepare_v2 $DB "SELECT a FROM t2" -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3c-12.2 {
+ catchsql {
+ INSERT INTO t1 VALUES(3, NULL);
+ }
+} {0 {}}
+do_test capi3c-12.3 {
+ catchsql {
+ INSERT INTO t2 VALUES(4);
+ }
+} {0 {}}
+do_test capi3c-12.4 {
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(4, NULL);
+ }
+} {0 {}}
+do_test capi3c-12.5 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3c-12.5.1 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3c-12.6 {
+ sqlite3_step $STMT
+} {SQLITE_DONE}
+do_test capi3c-12.7 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+do_test capi3c-12.8 {
+ execsql {
+ COMMIT;
+ SELECT a FROM t1;
+ }
+} {1 2 3 4}
+
+# Test cases capi3c-13.* test the sqlite3_clear_bindings() and
+# sqlite3_sleep APIs.
+#
+if {[llength [info commands sqlite3_clear_bindings]]>0} {
+ do_test capi3c-13.1 {
+ execsql {
+ DELETE FROM t1;
+ }
+ set STMT [sqlite3_prepare_v2 $DB "INSERT INTO t1 VALUES(?, ?)" -1 TAIL]
+ sqlite3_step $STMT
+ } {SQLITE_DONE}
+ do_test capi3c-13.2 {
+ sqlite3_reset $STMT
+ sqlite3_bind_text $STMT 1 hello 5
+ sqlite3_bind_text $STMT 2 world 5
+ sqlite3_step $STMT
+ } {SQLITE_DONE}
+ do_test capi3c-13.3 {
+ sqlite3_reset $STMT
+ sqlite3_clear_bindings $STMT
+ sqlite3_step $STMT
+ } {SQLITE_DONE}
+ do_test capi3c-13-4 {
+ sqlite3_finalize $STMT
+ execsql {
+ SELECT * FROM t1;
+ }
+ } {{} {} hello world {} {}}
+}
+if {[llength [info commands sqlite3_sleep]]>0} {
+ do_test capi3c-13-5 {
+ set ms [sqlite3_sleep 80]
+ expr {$ms==80 || $ms==1000}
+ } {1}
+}
+
+# Ticket #1219: Make sure binding APIs can handle a NULL pointer.
+#
+do_test capi3c-14.1 {
+ set rc [catch {sqlite3_bind_text 0 1 hello 5} msg]
+ lappend rc $msg
+} {1 SQLITE_MISUSE}
+
+# Ticket #1650: Honor the nBytes parameter to sqlite3_prepare.
+#
+do_test capi3c-15.1 {
+ set sql {SELECT * FROM t2}
+ set nbytes [string length $sql]
+ append sql { WHERE a==1}
+ set STMT [sqlite3_prepare_v2 $DB $sql $nbytes TAIL]
+ sqlite3_step $STMT
+ sqlite3_column_int $STMT 0
+} {1}
+do_test capi3c-15.2 {
+ sqlite3_step $STMT
+ sqlite3_column_int $STMT 0
+} {2}
+do_test capi3c-15.3 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+# Make sure code is always generated even if an IF EXISTS or
+# IF NOT EXISTS clause is present that the table does not or
+# does exists. That way we will always have a prepared statement
+# to expire when the schema changes.
+#
+do_test capi3c-16.1 {
+ set sql {DROP TABLE IF EXISTS t3}
+ set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]
+ sqlite3_finalize $STMT
+ expr {$STMT!=""}
+} {1}
+do_test capi3c-16.2 {
+ set sql {CREATE TABLE IF NOT EXISTS t1(x,y)}
+ set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]
+ sqlite3_finalize $STMT
+ expr {$STMT!=""}
+} {1}
+
+# But still we do not generate code if there is no SQL
+#
+do_test capi3c-16.3 {
+ set STMT [sqlite3_prepare_v2 $DB {} -1 TAIL]
+ sqlite3_finalize $STMT
+ expr {$STMT==""}
+} {1}
+do_test capi3c-16.4 {
+ set STMT [sqlite3_prepare_v2 $DB {;} -1 TAIL]
+ sqlite3_finalize $STMT
+ expr {$STMT==""}
+} {1}
+
+# Ticket #2154.
+#
+do_test capi3c-17.1 {
+ set STMT [sqlite3_prepare_v2 $DB {SELECT max(a) FROM t2} -1 TAIL]
+ sqlite3_step $STMT
+} SQLITE_ROW
+do_test capi3c-17.2 {
+ sqlite3_column_int $STMT 0
+} 4
+do_test capi3c-17.3 {
+ sqlite3_step $STMT
+} SQLITE_DONE
+do_test capi3c-17.4 {
+ sqlite3_reset $STMT
+ db eval {CREATE INDEX i2 ON t2(a)}
+ sqlite3_step $STMT
+} SQLITE_ROW
+do_test capi3c-17.5 {
+ sqlite3_column_int $STMT 0
+} 4
+do_test capi3c-17.6 {
+ sqlite3_step $STMT
+} SQLITE_DONE
+do_test capi3c-17.7 {
+ sqlite3_reset $STMT
+ db eval {DROP INDEX i2}
+ sqlite3_step $STMT
+} SQLITE_ROW
+do_test capi3c-17.8 {
+ sqlite3_column_int $STMT 0
+} 4
+do_test capi3c-17.9 {
+ sqlite3_step $STMT
+} SQLITE_DONE
+do_test capi3c-17.10 {
+ sqlite3_finalize $STMT
+ set STMT [sqlite3_prepare_v2 $DB {SELECT b FROM t1 WHERE a=?} -1 TAIL]
+ sqlite3_bind_int $STMT 1 2
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,'one');
+ INSERT INTO t1 VALUES(2,'two');
+ INSERT INTO t1 VALUES(3,'three');
+ INSERT INTO t1 VALUES(4,'four');
+ }
+ sqlite3_step $STMT
+} SQLITE_ROW
+do_test capi3c-17.11 {
+ sqlite3_column_text $STMT 0
+} two
+do_test capi3c-17.12 {
+ sqlite3_step $STMT
+} SQLITE_DONE
+do_test capi3c-17.13 {
+ sqlite3_reset $STMT
+ db eval {CREATE INDEX i1 ON t1(a)}
+ sqlite3_step $STMT
+} SQLITE_ROW
+do_test capi3c-17.14 {
+ sqlite3_column_text $STMT 0
+} two
+do_test capi3c-17.15 {
+ sqlite3_step $STMT
+} SQLITE_DONE
+do_test capi3c-17.16 {
+ sqlite3_reset $STMT
+ db eval {DROP INDEX i1}
+ sqlite3_step $STMT
+} SQLITE_ROW
+do_test capi3c-17.17 {
+ sqlite3_column_text $STMT 0
+} two
+do_test capi3c-17.18 {
+ sqlite3_step $STMT
+} SQLITE_DONE
+do_test capi3c-17.99 {
+ sqlite3_finalize $STMT
+} SQLITE_OK
+
+# On the mailing list it has been reported that finalizing after
+# an SQLITE_BUSY return leads to a segfault. Here we test that case.
+#
+do_test capi3c-18.1 {
+ sqlite3 db2 test.db
+ set STMT [sqlite3_prepare_v2 $DB {SELECT max(a) FROM t1} -1 TAIL]
+ sqlite3_step $STMT
+} SQLITE_ROW
+do_test capi3c-18.2 {
+ sqlite3_column_int $STMT 0
+} 4
+do_test capi3c-18.3 {
+ sqlite3_reset $STMT
+ db2 eval {BEGIN EXCLUSIVE}
+ sqlite3_step $STMT
+} SQLITE_BUSY
+do_test capi3c-18.4 {
+ sqlite3_finalize $STMT
+} SQLITE_BUSY
+do_test capi3c-18.5 {
+ db2 eval {COMMIT}
+ db2 close
+} {}
+
+# Ticket #2158. The sqlite3_step() will still return SQLITE_SCHEMA
+# if the database schema changes in a way that makes the statement
+# no longer valid.
+#
+do_test capi3c-19.1 {
+ db eval {
+ CREATE TABLE t3(x,y);
+ INSERT INTO t3 VALUES(1,2);
+ }
+ set STMT [sqlite3_prepare_v2 $DB {SELECT * FROM t3} -1 TAIL]
+ sqlite3_step $STMT
+} SQLITE_ROW
+do_test capi3c-19.2 {
+ sqlite3_column_int $STMT 0
+} 1
+do_test capi3c-19.3 {
+ sqlite3_step $STMT
+} SQLITE_DONE
+do_test capi3c-19.4 {
+ sqlite3_reset $STMT
+ db eval {DROP TABLE t3}
+ sqlite3_step $STMT
+} SQLITE_ERROR
+do_test capi3c-19.4.1 {
+ sqlite3_errmsg $DB
+} {no such table: t3}
+ifcapable deprecated {
+ do_test capi3c-19.4.2 {
+ sqlite3_expired $STMT
+ } 1
+}
+do_test capi3c-19.4.3 {
+ sqlite3_errmsg $DB
+} {no such table: t3}
+ifcapable deprecated {
+ do_test capi3c-19.4.4 {
+ sqlite3_expired 0
+ } 1
+}
+do_test capi3c-19.5 {
+ sqlite3_reset $STMT
+ db eval {
+ CREATE TABLE t3(x,y);
+ INSERT INTO t3 VALUES(1,2);
+ }
+ sqlite3_step $STMT
+} SQLITE_ROW
+ifcapable deprecated {
+ do_test capi3c-19.5.2 {
+ sqlite3_expired $STMT
+ } 0
+}
+do_test capi3c-19.6 {
+ sqlite3_column_int $STMT 1
+} 2
+do_test capi3c-19.99 {
+ sqlite3_finalize $STMT
+} SQLITE_OK
+
+# Make sure a change in a separate database connection does not
+# cause an SQLITE_SCHEMA return.
+#
+do_test capi3c-20.1 {
+ set STMT [sqlite3_prepare_v2 $DB {SELECT * FROM t3} -1 TAIL]
+ sqlite3 db2 test.db
+ db2 eval {CREATE TABLE t4(x)}
+ sqlite3_step $STMT
+} SQLITE_ROW
+do_test capi3c-20.2 {
+ sqlite3_column_int $STMT 1
+} 2
+do_test capi3c-20.3 {
+ sqlite3_step $STMT
+} SQLITE_DONE
+do_test capi3c-20.4 {
+ db2 close
+ sqlite3_finalize $STMT
+} SQLITE_OK
+
+# Test that sqlite3_step() sets the database error code correctly.
+# See ticket #2497.
+#
+ifcapable progress {
+ do_test capi3c-21.1 {
+ set STMT [sqlite3_prepare_v2 $DB {SELECT * FROM t3} -1 TAIL]
+ db progress 5 "expr 1"
+ sqlite3_step $STMT
+ } {SQLITE_INTERRUPT}
+ do_test capi3c-21.2 {
+ sqlite3_extended_errcode $DB
+ } {SQLITE_INTERRUPT}
+ do_test capi3c-21.3 {
+ sqlite3_finalize $STMT
+ } {SQLITE_INTERRUPT}
+ do_test capi3c-21.4 {
+ set STMT [sqlite3_prepare $DB {SELECT * FROM t3} -1 TAIL]
+ db progress 5 "expr 1"
+ sqlite3_step $STMT
+ } {SQLITE_ERROR}
+ do_test capi3c-21.5 {
+ sqlite3_errcode $DB
+ } {SQLITE_ERROR}
+ do_test capi3c-21.6 {
+ sqlite3_finalize $STMT
+ } {SQLITE_INTERRUPT}
+ do_test capi3c-21.7 {
+ sqlite3_errcode $DB
+ } {SQLITE_INTERRUPT}
+ do_test capi3c-21.8 {
+ sqlite3_extended_errcode $DB
+ } {SQLITE_INTERRUPT}
+}
+
+# Make sure sqlite3_result_error_code() returns the correct error code.
+# See ticket #2940
+#
+do_test capi3c-22.1 {
+ db progress 0 {}
+ set STMT [sqlite3_prepare_v2 db {SELECT test_error('the message',3)} -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_PERM}
+sqlite3_finalize $STMT
+do_test capi3c-22.2 {
+ set STMT [sqlite3_prepare_v2 db {SELECT test_error('the message',4)} -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_ABORT}
+sqlite3_finalize $STMT
+do_test capi3c-22.3 {
+ set STMT [sqlite3_prepare_v2 db {SELECT test_error('the message',16)} -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_EMPTY}
+sqlite3_finalize $STMT
+
+# For a multi-column result set where the same table column is repeated
+# in multiple columns of the output, verify that doing a UTF-8 to UTF-16
+# conversion (or vice versa) on one column does not change the value of
+# the second.
+#
+ifcapable utf16 {
+ do_test capi3c-23.1 {
+ set STMT [sqlite3_prepare_v2 db {SELECT b,b,b,b FROM t1} -1 TAIL]
+ sqlite3_step $STMT
+ } {SQLITE_ROW}
+ do_test capi3c-23.2 {
+ sqlite3_column_text16 $STMT 0
+ sqlite3_column_text $STMT 1
+ } {one}
+ do_test capi3c-23.3 {
+ sqlite3_column_text16 $STMT 2
+ sqlite3_column_text $STMT 3
+ } {one}
+ sqlite3_finalize $STMT
+ do_test capi3c-23.4 {
+ set STMT [sqlite3_prepare_v2 db {SELECT b||'x',b,b,b FROM t1} -1 TAIL]
+ sqlite3_step $STMT
+ } {SQLITE_ROW}
+ do_test capi3c-23.5 {
+ sqlite3_column_text16 $STMT 0
+ sqlite3_column_text $STMT 1
+ } {one}
+ do_test capi3c-23.6 {
+ sqlite3_column_text16 $STMT 2
+ sqlite3_column_text $STMT 3
+ } {one}
+ sqlite3_finalize $STMT
+}
+
+# Test decltype on some SELECT statements that contain sub-selects.
+#
+proc decltype {zSql} {
+ set ret [list]
+ set STMT [sqlite3_prepare_v2 db $zSql -1 TAIL]
+ for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {
+ lappend ret [sqlite3_column_decltype $STMT $i]
+ }
+ sqlite3_finalize $STMT
+ return $ret
+}
+do_test capi3c-24.1 {
+ execsql { CREATE TABLE t5(a INTEGER, b STRING, c DATETIME) }
+ decltype {SELECT * FROM t5}
+} {INTEGER STRING DATETIME}
+do_test capi3c-24.2 {
+ decltype {SELECT (SELECT c) FROM t5}
+} {DATETIME}
+do_test capi3c-24.3 {
+ decltype {SELECT (SELECT * FROM (SELECT c)) FROM t5}
+} {DATETIME}
+do_test capi3c-24.4 {
+ decltype {SELECT * FROM (SELECT * FROM t5 ORDER BY c LIMIT 1) ORDER BY b}
+} {INTEGER STRING DATETIME}
+do_test capi3c-24.5 {
+ decltype {
+ SELECT (SELECT x FROM (SELECT c AS x))
+ FROM (SELECT * FROM t5 ORDER BY c LIMIT 1) ORDER BY b
+ }
+} {DATETIME}
+do_test capi3c-24.3 {
+ decltype {SELECT (SELECT x FROM (SELECT t5.a AS x)) FROM t5}
+} {INTEGER}
+
+finish_test
diff --git a/test/capi3d.test b/test/capi3d.test
new file mode 100644
index 0000000..49e6447
--- /dev/null
+++ b/test/capi3d.test
@@ -0,0 +1,116 @@
+# 2008 June 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is devoted to testing the sqlite3_next_stmt and
+# sqlite3_stmt_readonly interfaces.
+#
+# $Id: capi3d.test,v 1.2 2008/07/14 15:11:20 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create N prepared statements against database connection db
+# and return a list of all the generated prepared statements.
+#
+proc make_prepared_statements {N} {
+ set plist {}
+ for {set i 0} {$i<$N} {incr i} {
+ set sql "SELECT $i FROM sqlite_master WHERE name LIKE '%$i%'"
+ if {rand()<0.33} {
+ set s [sqlite3_prepare_v2 db $sql -1 notused]
+ } else {
+ ifcapable utf16 {
+ if {rand()<0.5} {
+ set sql [encoding convertto unicode $sql]\x00\x00
+ set s [sqlite3_prepare16 db $sql -1 notused]
+ } else {
+ set s [sqlite3_prepare db $sql -1 notused]
+ }
+ }
+ ifcapable !utf16 {
+ set s [sqlite3_prepare db $sql -1 notused]
+ }
+ }
+ lappend plist $s
+ }
+ return $plist
+}
+
+
+# Scramble the $inlist into a random order.
+#
+proc scramble {inlist} {
+ set y {}
+ foreach x $inlist {
+ lappend y [list [expr {rand()}] $x]
+ }
+ set y [lsort $y]
+ set outlist {}
+ foreach x $y {
+ lappend outlist [lindex $x 1]
+ }
+ return $outlist
+}
+
+# Database initially has no prepared statements.
+#
+do_test capi3d-1.1 {
+ db cache flush
+ sqlite3_next_stmt db 0
+} {}
+
+# Run the following tests for between 1 and 100 prepared statements.
+#
+for {set i 1} {$i<=100} {incr i} {
+ set stmtlist [make_prepared_statements $i]
+ do_test capi3d-1.2.$i.1 {
+ set p [sqlite3_next_stmt db 0]
+ set x {}
+ while {$p!=""} {
+ lappend x $p
+ set p [sqlite3_next_stmt db $p]
+ }
+ lsort $x
+ } [lsort $stmtlist]
+ do_test capi3-1.2.$i.2 {
+ foreach p [scramble $::stmtlist] {
+ sqlite3_finalize $p
+ }
+ sqlite3_next_stmt db 0
+ } {}
+}
+
+# Tests for the is-read-only interface.
+#
+proc test_is_readonly {testname sql truth} {
+ do_test $testname [format {
+ set DB [sqlite3_connection_pointer db]
+ set STMT [sqlite3_prepare $DB {%s} -1 TAIL]
+ set rc [sqlite3_stmt_readonly $STMT]
+ sqlite3_finalize $STMT
+ set rc
+ } $sql] $truth
+}
+
+test_is_readonly capi3d-2.1 {SELECT * FROM sqlite_master} 1
+test_is_readonly capi3d-2.2 {CREATE TABLE t1(x)} 0
+db eval {CREATE TABLE t1(x)}
+test_is_readonly capi3d-2.3 {INSERT INTO t1 VALUES(5)} 0
+test_is_readonly capi3d-2.4 {UPDATE t1 SET x=x+1 WHERE x<0} 0
+test_is_readonly capi3d-2.5 {SELECT * FROM t1} 1
+do_test capi3-2.99 {
+ sqlite3_stmt_readonly 0
+} 1
+
+
+finish_test
diff --git a/test/capi3e.test b/test/capi3e.test
new file mode 100644
index 0000000..21304cb
--- /dev/null
+++ b/test/capi3e.test
@@ -0,0 +1,122 @@
+# 2010 Novemeber 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script testing the callback-free C/C++ API.
+#
+# $Id: capi3e.test,v 1.70 2009/01/09 02:49:32 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Make sure the system encoding is utf-8. Otherwise, if the system encoding
+# is other than utf-8, [file isfile $x] may not refer to the same file
+# as [sqlite3 db $x].
+encoding system utf-8
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Return the UTF-16 representation of the supplied UTF-8 string $str.
+# If $nt is true, append two 0x00 bytes as a nul terminator.
+proc utf16 {str {nt 1}} {
+ set r [encoding convertto unicode $str]
+ if {$nt} {
+ append r "\x00\x00"
+ }
+ return $r
+}
+
+# Return the UTF-8 representation of the supplied UTF-16 string $str.
+proc utf8 {str} {
+ # If $str ends in two 0x00 0x00 bytes, knock these off before
+ # converting to UTF-8 using TCL.
+ binary scan $str \c* vals
+ if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {
+ set str [binary format \c* [lrange $vals 0 end-2]]
+ }
+
+ set r [encoding convertfrom unicode $str]
+ return $r
+}
+
+# These tests complement those in capi2.test. They are organized
+# as follows:
+#
+# capi3e-1.*: Test sqlite3_open with various UTF8 filenames
+# capi3e-2.*: Test sqlite3_open16 with various UTF8 filenames
+# capi3e-3.*: Test ATTACH with various UTF8 filenames
+
+db close
+
+# here's the list of file names we're testing
+set names {t 1 t. 1. t.d 1.d t-1 1-1 t.db ä.db ë.db ö.db ü.db ÿ.db}
+
+set i 0
+foreach name $names {
+ incr i
+ do_test capi3e-1.1.$i {
+ set db2 [sqlite3_open $name {}]
+ sqlite3_errcode $db2
+ } {SQLITE_OK}
+ do_test capi3e-1.2.$i {
+ sqlite3_close $db2
+ } {SQLITE_OK}
+ do_test capi3e-1.3.$i {
+ file isfile $name
+ } {1}
+}
+
+ifcapable {utf16} {
+ set i 0
+ foreach name $names {
+ incr i
+ do_test capi3e-2.1.$i {
+ set db2 [sqlite3_open16 [utf16 $name] {}]
+ sqlite3_errcode $db2
+ } {SQLITE_OK}
+ do_test capi3e-2.2.$i {
+ sqlite3_close $db2
+ } {SQLITE_OK}
+ do_test capi3e-2.3.$i {
+ file isfile $name
+ } {1}
+ }
+}
+
+ifcapable attach {
+ do_test capi3e-3.1 {
+ sqlite3 db2 base.db
+ } {}
+ set i 0
+ foreach name $names {
+ incr i
+ do_test capi3e-3.2.$i {
+ db2 eval "ATTACH DATABASE '$name' AS db$i;"
+ } {}
+ do_test capi3e-3.3.$i {
+ db2 eval "DETACH DATABASE db$i;"
+ } {}
+ }
+ do_test capi3e-3.4 {
+ db2 close
+ } {}
+}
+
+# clean up
+forcedelete base.db
+foreach name $names {
+ forcedelete $name
+}
+
+finish_test
diff --git a/test/cast.test b/test/cast.test
new file mode 100644
index 0000000..f47f4bb
--- /dev/null
+++ b/test/cast.test
@@ -0,0 +1,346 @@
+# 2005 June 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the CAST operator.
+#
+# $Id: cast.test,v 1.10 2008/11/06 15:33:04 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Only run these tests if the build includes the CAST operator
+ifcapable !cast {
+ finish_test
+ return
+}
+
+# Tests for the CAST( AS blob), CAST( AS text) and CAST( AS numeric) built-ins
+#
+ifcapable bloblit {
+ do_test cast-1.1 {
+ execsql {SELECT x'616263'}
+ } abc
+ do_test cast-1.2 {
+ execsql {SELECT typeof(x'616263')}
+ } blob
+ do_test cast-1.3 {
+ execsql {SELECT CAST(x'616263' AS text)}
+ } abc
+ do_test cast-1.4 {
+ execsql {SELECT typeof(CAST(x'616263' AS text))}
+ } text
+ do_test cast-1.5 {
+ execsql {SELECT CAST(x'616263' AS numeric)}
+ } 0
+ do_test cast-1.6 {
+ execsql {SELECT typeof(CAST(x'616263' AS numeric))}
+ } integer
+ do_test cast-1.7 {
+ execsql {SELECT CAST(x'616263' AS blob)}
+ } abc
+ do_test cast-1.8 {
+ execsql {SELECT typeof(CAST(x'616263' AS blob))}
+ } blob
+ do_test cast-1.9 {
+ execsql {SELECT CAST(x'616263' AS integer)}
+ } 0
+ do_test cast-1.10 {
+ execsql {SELECT typeof(CAST(x'616263' AS integer))}
+ } integer
+}
+do_test cast-1.11 {
+ execsql {SELECT null}
+} {{}}
+do_test cast-1.12 {
+ execsql {SELECT typeof(NULL)}
+} null
+do_test cast-1.13 {
+ execsql {SELECT CAST(NULL AS text)}
+} {{}}
+do_test cast-1.14 {
+ execsql {SELECT typeof(CAST(NULL AS text))}
+} null
+do_test cast-1.15 {
+ execsql {SELECT CAST(NULL AS numeric)}
+} {{}}
+do_test cast-1.16 {
+ execsql {SELECT typeof(CAST(NULL AS numeric))}
+} null
+do_test cast-1.17 {
+ execsql {SELECT CAST(NULL AS blob)}
+} {{}}
+do_test cast-1.18 {
+ execsql {SELECT typeof(CAST(NULL AS blob))}
+} null
+do_test cast-1.19 {
+ execsql {SELECT CAST(NULL AS integer)}
+} {{}}
+do_test cast-1.20 {
+ execsql {SELECT typeof(CAST(NULL AS integer))}
+} null
+do_test cast-1.21 {
+ execsql {SELECT 123}
+} {123}
+do_test cast-1.22 {
+ execsql {SELECT typeof(123)}
+} integer
+do_test cast-1.23 {
+ execsql {SELECT CAST(123 AS text)}
+} {123}
+do_test cast-1.24 {
+ execsql {SELECT typeof(CAST(123 AS text))}
+} text
+do_test cast-1.25 {
+ execsql {SELECT CAST(123 AS numeric)}
+} 123
+do_test cast-1.26 {
+ execsql {SELECT typeof(CAST(123 AS numeric))}
+} integer
+do_test cast-1.27 {
+ execsql {SELECT CAST(123 AS blob)}
+} {123}
+do_test cast-1.28 {
+ execsql {SELECT typeof(CAST(123 AS blob))}
+} blob
+do_test cast-1.29 {
+ execsql {SELECT CAST(123 AS integer)}
+} {123}
+do_test cast-1.30 {
+ execsql {SELECT typeof(CAST(123 AS integer))}
+} integer
+do_test cast-1.31 {
+ execsql {SELECT 123.456}
+} {123.456}
+do_test cast-1.32 {
+ execsql {SELECT typeof(123.456)}
+} real
+do_test cast-1.33 {
+ execsql {SELECT CAST(123.456 AS text)}
+} {123.456}
+do_test cast-1.34 {
+ execsql {SELECT typeof(CAST(123.456 AS text))}
+} text
+do_test cast-1.35 {
+ execsql {SELECT CAST(123.456 AS numeric)}
+} 123.456
+do_test cast-1.36 {
+ execsql {SELECT typeof(CAST(123.456 AS numeric))}
+} real
+do_test cast-1.37 {
+ execsql {SELECT CAST(123.456 AS blob)}
+} {123.456}
+do_test cast-1.38 {
+ execsql {SELECT typeof(CAST(123.456 AS blob))}
+} blob
+do_test cast-1.39 {
+ execsql {SELECT CAST(123.456 AS integer)}
+} {123}
+do_test cast-1.38 {
+ execsql {SELECT typeof(CAST(123.456 AS integer))}
+} integer
+do_test cast-1.41 {
+ execsql {SELECT '123abc'}
+} {123abc}
+do_test cast-1.42 {
+ execsql {SELECT typeof('123abc')}
+} text
+do_test cast-1.43 {
+ execsql {SELECT CAST('123abc' AS text)}
+} {123abc}
+do_test cast-1.44 {
+ execsql {SELECT typeof(CAST('123abc' AS text))}
+} text
+do_test cast-1.45 {
+ execsql {SELECT CAST('123abc' AS numeric)}
+} 123
+do_test cast-1.46 {
+ execsql {SELECT typeof(CAST('123abc' AS numeric))}
+} integer
+do_test cast-1.47 {
+ execsql {SELECT CAST('123abc' AS blob)}
+} {123abc}
+do_test cast-1.48 {
+ execsql {SELECT typeof(CAST('123abc' AS blob))}
+} blob
+do_test cast-1.49 {
+ execsql {SELECT CAST('123abc' AS integer)}
+} 123
+do_test cast-1.50 {
+ execsql {SELECT typeof(CAST('123abc' AS integer))}
+} integer
+do_test cast-1.51 {
+ execsql {SELECT CAST('123.5abc' AS numeric)}
+} 123.5
+do_test cast-1.53 {
+ execsql {SELECT CAST('123.5abc' AS integer)}
+} 123
+
+do_test case-1.60 {
+ execsql {SELECT CAST(null AS REAL)}
+} {{}}
+do_test case-1.61 {
+ execsql {SELECT typeof(CAST(null AS REAL))}
+} {null}
+do_test case-1.62 {
+ execsql {SELECT CAST(1 AS REAL)}
+} {1.0}
+do_test case-1.63 {
+ execsql {SELECT typeof(CAST(1 AS REAL))}
+} {real}
+do_test case-1.64 {
+ execsql {SELECT CAST('1' AS REAL)}
+} {1.0}
+do_test case-1.65 {
+ execsql {SELECT typeof(CAST('1' AS REAL))}
+} {real}
+do_test case-1.66 {
+ execsql {SELECT CAST('abc' AS REAL)}
+} {0.0}
+do_test case-1.67 {
+ execsql {SELECT typeof(CAST('abc' AS REAL))}
+} {real}
+do_test case-1.68 {
+ execsql {SELECT CAST(x'31' AS REAL)}
+} {1.0}
+do_test case-1.69 {
+ execsql {SELECT typeof(CAST(x'31' AS REAL))}
+} {real}
+
+
+# Ticket #1662. Ignore leading spaces in numbers when casting.
+#
+do_test cast-2.1 {
+ execsql {SELECT CAST(' 123' AS integer)}
+} 123
+do_test cast-2.2 {
+ execsql {SELECT CAST(' -123.456' AS real)}
+} -123.456
+
+# ticket #2364. Use full percision integers if possible when casting
+# to numeric. Do not fallback to real (and the corresponding 48-bit
+# mantissa) unless absolutely necessary.
+#
+do_test cast-3.1 {
+ execsql {SELECT CAST(9223372036854774800 AS integer)}
+} 9223372036854774800
+do_test cast-3.2 {
+ execsql {SELECT CAST(9223372036854774800 AS numeric)}
+} 9223372036854774800
+do_realnum_test cast-3.3 {
+ execsql {SELECT CAST(9223372036854774800 AS real)}
+} 9.22337203685477e+18
+do_test cast-3.4 {
+ execsql {SELECT CAST(CAST(9223372036854774800 AS real) AS integer)}
+} 9223372036854774784
+do_test cast-3.5 {
+ execsql {SELECT CAST(-9223372036854774800 AS integer)}
+} -9223372036854774800
+do_test cast-3.6 {
+ execsql {SELECT CAST(-9223372036854774800 AS numeric)}
+} -9223372036854774800
+do_realnum_test cast-3.7 {
+ execsql {SELECT CAST(-9223372036854774800 AS real)}
+} -9.22337203685477e+18
+do_test cast-3.8 {
+ execsql {SELECT CAST(CAST(-9223372036854774800 AS real) AS integer)}
+} -9223372036854774784
+do_test cast-3.11 {
+ execsql {SELECT CAST('9223372036854774800' AS integer)}
+} 9223372036854774800
+do_test cast-3.12 {
+ execsql {SELECT CAST('9223372036854774800' AS numeric)}
+} 9223372036854774800
+do_realnum_test cast-3.13 {
+ execsql {SELECT CAST('9223372036854774800' AS real)}
+} 9.22337203685477e+18
+ifcapable long_double {
+ do_test cast-3.14 {
+ execsql {SELECT CAST(CAST('9223372036854774800' AS real) AS integer)}
+ } 9223372036854774784
+}
+do_test cast-3.15 {
+ execsql {SELECT CAST('-9223372036854774800' AS integer)}
+} -9223372036854774800
+do_test cast-3.16 {
+ execsql {SELECT CAST('-9223372036854774800' AS numeric)}
+} -9223372036854774800
+do_realnum_test cast-3.17 {
+ execsql {SELECT CAST('-9223372036854774800' AS real)}
+} -9.22337203685477e+18
+ifcapable long_double {
+ do_test cast-3.18 {
+ execsql {SELECT CAST(CAST('-9223372036854774800' AS real) AS integer)}
+ } -9223372036854774784
+}
+if {[db eval {PRAGMA encoding}]=="UTF-8"} {
+ do_test cast-3.21 {
+ execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS integer)}
+ } 9223372036854774800
+ do_test cast-3.22 {
+ execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS numeric)}
+ } 9223372036854774800
+ do_realnum_test cast-3.23 {
+ execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS real)}
+ } 9.22337203685477e+18
+ ifcapable long_double {
+ do_test cast-3.24 {
+ execsql {
+ SELECT CAST(CAST(x'39323233333732303336383534373734383030' AS real)
+ AS integer)
+ }
+ } 9223372036854774784
+ }
+}
+do_test case-3.31 {
+ execsql {SELECT CAST(NULL AS numeric)}
+} {{}}
+
+# Test to see if it is possible to trick SQLite into reading past
+# the end of a blob when converting it to a number.
+do_test cast-3.32.1 {
+ set blob "1234567890"
+ set DB [sqlite3_connection_pointer db]
+ set ::STMT [sqlite3_prepare $DB {SELECT CAST(? AS real)} -1 TAIL]
+ sqlite3_bind_blob -static $::STMT 1 $blob 5
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test cast-3.32.2 {
+ sqlite3_column_int $::STMT 0
+} {12345}
+do_test cast-3.32.3 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+
+
+do_test cast-4.1 {
+ db eval {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES('abc');
+ SELECT a, CAST(a AS integer) FROM t1;
+ }
+} {abc 0}
+do_test cast-4.2 {
+ db eval {
+ SELECT CAST(a AS integer), a FROM t1;
+ }
+} {0 abc}
+do_test cast-4.3 {
+ db eval {
+ SELECT a, CAST(a AS integer), a FROM t1;
+ }
+} {abc 0 abc}
+do_test cast-4.4 {
+ db eval {
+ SELECT CAST(a AS integer), a, CAST(a AS real), a FROM t1;
+ }
+} {0 abc 0.0 abc}
+
+finish_test
diff --git a/test/check.test b/test/check.test
new file mode 100644
index 0000000..d2867a0
--- /dev/null
+++ b/test/check.test
@@ -0,0 +1,374 @@
+# 2005 November 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing CHECK constraints
+#
+# $Id: check.test,v 1.13 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Only run these tests if the build includes support for CHECK constraints
+ifcapable !check {
+ finish_test
+ return
+}
+
+do_test check-1.1 {
+ execsql {
+ CREATE TABLE t1(
+ x INTEGER CHECK( x<5 ),
+ y REAL CHECK( y>x )
+ );
+ }
+} {}
+do_test check-1.2 {
+ execsql {
+ INSERT INTO t1 VALUES(3,4);
+ SELECT * FROM t1;
+ }
+} {3 4.0}
+do_test check-1.3 {
+ catchsql {
+ INSERT INTO t1 VALUES(6,7);
+ }
+} {1 {constraint failed}}
+do_test check-1.4 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {3 4.0}
+do_test check-1.5 {
+ catchsql {
+ INSERT INTO t1 VALUES(4,3);
+ }
+} {1 {constraint failed}}
+do_test check-1.6 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {3 4.0}
+do_test check-1.7 {
+ catchsql {
+ INSERT INTO t1 VALUES(NULL,6);
+ }
+} {0 {}}
+do_test check-1.8 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {3 4.0 {} 6.0}
+do_test check-1.9 {
+ catchsql {
+ INSERT INTO t1 VALUES(2,NULL);
+ }
+} {0 {}}
+do_test check-1.10 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {3 4.0 {} 6.0 2 {}}
+do_test check-1.11 {
+ execsql {
+ DELETE FROM t1 WHERE x IS NULL OR x!=3;
+ UPDATE t1 SET x=2 WHERE x==3;
+ SELECT * FROM t1;
+ }
+} {2 4.0}
+do_test check-1.12 {
+ catchsql {
+ UPDATE t1 SET x=7 WHERE x==2
+ }
+} {1 {constraint failed}}
+do_test check-1.13 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {2 4.0}
+do_test check-1.14 {
+ catchsql {
+ UPDATE t1 SET x=5 WHERE x==2
+ }
+} {1 {constraint failed}}
+do_test check-1.15 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {2 4.0}
+do_test check-1.16 {
+ catchsql {
+ UPDATE t1 SET x=4, y=11 WHERE x==2
+ }
+} {0 {}}
+do_test check-1.17 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {4 11.0}
+
+do_test check-2.1 {
+ execsql {
+ CREATE TABLE t2(
+ x INTEGER CHECK( typeof(coalesce(x,0))=="integer" ),
+ y REAL CHECK( typeof(coalesce(y,0.1))=='real' ),
+ z TEXT CHECK( typeof(coalesce(z,''))=='text' )
+ );
+ }
+} {}
+do_test check-2.2 {
+ execsql {
+ INSERT INTO t2 VALUES(1,2.2,'three');
+ SELECT * FROM t2;
+ }
+} {1 2.2 three}
+db close
+sqlite3 db test.db
+do_test check-2.3 {
+ execsql {
+ INSERT INTO t2 VALUES(NULL, NULL, NULL);
+ SELECT * FROM t2;
+ }
+} {1 2.2 three {} {} {}}
+do_test check-2.4 {
+ catchsql {
+ INSERT INTO t2 VALUES(1.1, NULL, NULL);
+ }
+} {1 {constraint failed}}
+do_test check-2.5 {
+ catchsql {
+ INSERT INTO t2 VALUES(NULL, 5, NULL);
+ }
+} {1 {constraint failed}}
+do_test check-2.6 {
+ catchsql {
+ INSERT INTO t2 VALUES(NULL, NULL, 3.14159);
+ }
+} {1 {constraint failed}}
+
+ifcapable subquery {
+ do_test check-3.1 {
+ catchsql {
+ CREATE TABLE t3(
+ x, y, z,
+ CHECK( x<(SELECT min(x) FROM t1) )
+ );
+ }
+ } {1 {subqueries prohibited in CHECK constraints}}
+}
+
+do_test check-3.2 {
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY name
+ }
+} {t1 t2}
+do_test check-3.3 {
+ catchsql {
+ CREATE TABLE t3(
+ x, y, z,
+ CHECK( q<x )
+ );
+ }
+} {1 {no such column: q}}
+do_test check-3.4 {
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY name
+ }
+} {t1 t2}
+do_test check-3.5 {
+ catchsql {
+ CREATE TABLE t3(
+ x, y, z,
+ CHECK( t2.x<x )
+ );
+ }
+} {1 {no such column: t2.x}}
+do_test check-3.6 {
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY name
+ }
+} {t1 t2}
+do_test check-3.7 {
+ catchsql {
+ CREATE TABLE t3(
+ x, y, z,
+ CHECK( t3.x<25 )
+ );
+ }
+} {0 {}}
+do_test check-3.8 {
+ execsql {
+ INSERT INTO t3 VALUES(1,2,3);
+ SELECT * FROM t3;
+ }
+} {1 2 3}
+do_test check-3.9 {
+ catchsql {
+ INSERT INTO t3 VALUES(111,222,333);
+ }
+} {1 {constraint failed}}
+
+do_test check-4.1 {
+ execsql {
+ CREATE TABLE t4(x, y,
+ CHECK (
+ x+y==11
+ OR x*y==12
+ OR x/y BETWEEN 5 AND 8
+ OR -x==y+10
+ )
+ );
+ }
+} {}
+do_test check-4.2 {
+ execsql {
+ INSERT INTO t4 VALUES(1,10);
+ SELECT * FROM t4
+ }
+} {1 10}
+do_test check-4.3 {
+ execsql {
+ UPDATE t4 SET x=4, y=3;
+ SELECT * FROM t4
+ }
+} {4 3}
+do_test check-4.4 {
+ execsql {
+ UPDATE t4 SET x=12, y=2;
+ SELECT * FROM t4
+ }
+} {12 2}
+do_test check-4.5 {
+ execsql {
+ UPDATE t4 SET x=12, y=-22;
+ SELECT * FROM t4
+ }
+} {12 -22}
+do_test check-4.6 {
+ catchsql {
+ UPDATE t4 SET x=0, y=1;
+ }
+} {1 {constraint failed}}
+do_test check-4.7 {
+ execsql {
+ SELECT * FROM t4;
+ }
+} {12 -22}
+do_test check-4.8 {
+ execsql {
+ PRAGMA ignore_check_constraints=ON;
+ UPDATE t4 SET x=0, y=1;
+ SELECT * FROM t4;
+ }
+} {0 1}
+do_test check-4.9 {
+ catchsql {
+ PRAGMA ignore_check_constraints=OFF;
+ UPDATE t4 SET x=0, y=2;
+ }
+} {1 {constraint failed}}
+ifcapable vacuum {
+ do_test check_4.10 {
+ catchsql {
+ VACUUM
+ }
+ } {0 {}}
+}
+
+do_test check-5.1 {
+ catchsql {
+ CREATE TABLE t5(x, y,
+ CHECK( x*y<:abc )
+ );
+ }
+} {1 {parameters prohibited in CHECK constraints}}
+do_test check-5.2 {
+ catchsql {
+ CREATE TABLE t5(x, y,
+ CHECK( x*y<? )
+ );
+ }
+} {1 {parameters prohibited in CHECK constraints}}
+
+ifcapable conflict {
+
+do_test check-6.1 {
+ execsql {SELECT * FROM t1}
+} {4 11.0}
+do_test check-6.2 {
+ execsql {
+ UPDATE OR IGNORE t1 SET x=5;
+ SELECT * FROM t1;
+ }
+} {4 11.0}
+do_test check-6.3 {
+ execsql {
+ INSERT OR IGNORE INTO t1 VALUES(5,4.0);
+ SELECT * FROM t1;
+ }
+} {4 11.0}
+do_test check-6.4 {
+ execsql {
+ INSERT OR IGNORE INTO t1 VALUES(2,20.0);
+ SELECT * FROM t1;
+ }
+} {4 11.0 2 20.0}
+do_test check-6.5 {
+ catchsql {
+ UPDATE OR FAIL t1 SET x=7-x, y=y+1;
+ }
+} {1 {constraint failed}}
+do_test check-6.6 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {3 12.0 2 20.0}
+do_test check-6.7 {
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1,30.0);
+ INSERT OR ROLLBACK INTO t1 VALUES(8,40.0);
+ }
+} {1 {constraint failed}}
+do_test check-6.8 {
+ catchsql {
+ COMMIT;
+ }
+} {1 {cannot commit - no transaction is active}}
+do_test check-6.9 {
+ execsql {
+ SELECT * FROM t1
+ }
+} {3 12.0 2 20.0}
+
+do_test check-6.11 {
+ execsql {SELECT * FROM t1}
+} {3 12.0 2 20.0}
+do_test check-6.12 {
+ catchsql {
+ REPLACE INTO t1 VALUES(6,7);
+ }
+} {1 {constraint failed}}
+do_test check-6.13 {
+ execsql {SELECT * FROM t1}
+} {3 12.0 2 20.0}
+do_test check-6.14 {
+ catchsql {
+ INSERT OR IGNORE INTO t1 VALUES(6,7);
+ }
+} {0 {}}
+do_test check-6.15 {
+ execsql {SELECT * FROM t1}
+} {3 12.0 2 20.0}
+
+
+}
+
+finish_test
diff --git a/test/coalesce.test b/test/coalesce.test
new file mode 100644
index 0000000..af4ea8d
--- /dev/null
+++ b/test/coalesce.test
@@ -0,0 +1,84 @@
+# 2009 November 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# Additional test cases for the COALESCE() and IFNULL() functions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+do_test coalesce-1.0 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);
+ INSERT INTO t1 VALUES(1, null, null, null);
+ INSERT INTO t1 VALUES(2, 2, 99, 99);
+ INSERT INTO t1 VALUES(3, null, 3, 99);
+ INSERT INTO t1 VALUES(4, null, null, 4);
+ INSERT INTO t1 VALUES(5, null, null, null);
+ INSERT INTO t1 VALUES(6, 22, 99, 99);
+ INSERT INTO t1 VALUES(7, null, 33, 99);
+ INSERT INTO t1 VALUES(8, null, null, 44);
+
+ SELECT coalesce(b,c,d) FROM t1 ORDER BY a;
+ }
+} {{} 2 3 4 {} 22 33 44}
+do_test coalesce-1.1 {
+ db eval {
+ SELECT coalesce(d+c+b,d+c,d) FROM t1 ORDER BY a;
+ }
+} {{} 200 102 4 {} 220 132 44}
+do_test coalesce-1.2 {
+ db eval {
+ SELECT ifnull(d+c+b,ifnull(d+c,d)) FROM t1 ORDER BY a;
+ }
+} {{} 200 102 4 {} 220 132 44}
+do_test coalesce-1.3 {
+ db eval {
+ SELECT ifnull(ifnull(d+c+b,d+c),d) FROM t1 ORDER BY a;
+ }
+} {{} 200 102 4 {} 220 132 44}
+do_test coalesce-1.4 {
+ db eval {
+ SELECT ifnull(ifnull(b,c),d) FROM t1 ORDER BY a;
+ }
+} {{} 2 3 4 {} 22 33 44}
+do_test coalesce-1.5 {
+ db eval {
+ SELECT ifnull(b,ifnull(c,d)) FROM t1 ORDER BY a;
+ }
+} {{} 2 3 4 {} 22 33 44}
+do_test coalesce-1.6 {
+ db eval {
+ SELECT coalesce(b,NOT b,-b,abs(b),lower(b),length(b),min(b,5),b*123,c)
+ FROM t1 ORDER BY a;
+ }
+} {{} 2 3 {} {} 22 33 {}}
+do_test coalesce-1.7 {
+ db eval {
+ SELECT ifnull(nullif(a,4),99)
+ FROM t1 ORDER BY a;
+ }
+} {1 2 3 99 5 6 7 8}
+do_test coalesce-1.8 {
+ db eval {
+pragma vdbe_listing=on;
+ SELECT coalesce(
+ CASE WHEN b=2 THEN 123 END,
+ CASE WHEN b=3 THEN 234 END,
+ CASE WHEN c=3 THEN 345 WHEN c=33 THEN 456 END,
+ d
+ )
+ FROM t1 ORDER BY a;
+ }
+} {{} 123 345 4 {} 99 456 44}
+
+
+finish_test
diff --git a/test/collate1.test b/test/collate1.test
new file mode 100644
index 0000000..ac2c75b
--- /dev/null
+++ b/test/collate1.test
@@ -0,0 +1,307 @@
+#
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is page cache subsystem.
+#
+# $Id: collate1.test,v 1.5 2007/02/01 23:02:46 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+#
+# Tests are roughly organised as follows:
+#
+# collate1-1.* - Single-field ORDER BY with an explicit COLLATE clause.
+# collate1-2.* - Multi-field ORDER BY with an explicit COLLATE clause.
+# collate1-3.* - ORDER BY using a default collation type. Also that an
+# explict collate type overrides a default collate type.
+# collate1-4.* - ORDER BY using a data type.
+#
+
+#
+# Collation type 'HEX'. If an argument can be interpreted as a hexadecimal
+# number, then it is converted to one before the comparison is performed.
+# Numbers are less than other strings. If neither argument is a number,
+# [string compare] is used.
+#
+db collate HEX hex_collate
+proc hex_collate {lhs rhs} {
+ set lhs_ishex [regexp {^(0x|)[1234567890abcdefABCDEF]+$} $lhs]
+ set rhs_ishex [regexp {^(0x|)[1234567890abcdefABCDEF]+$} $rhs]
+ if {$lhs_ishex && $rhs_ishex} {
+ set lhsx [scan $lhs %x]
+ set rhsx [scan $rhs %x]
+ if {$lhs < $rhs} {return -1}
+ if {$lhs == $rhs} {return 0}
+ if {$lhs > $rhs} {return 1}
+ }
+ if {$lhs_ishex} {
+ return -1;
+ }
+ if {$rhs_ishex} {
+ return 1;
+ }
+ return [string compare $lhs $rhs]
+}
+db function hex {format 0x%X}
+
+# Mimic the SQLite 2 collation type NUMERIC.
+db collate numeric numeric_collate
+proc numeric_collate {lhs rhs} {
+ if {$lhs == $rhs} {return 0}
+ return [expr ($lhs>$rhs)?1:-1]
+}
+
+do_test collate1-1.0 {
+ execsql {
+ CREATE TABLE collate1t1(c1, c2);
+ INSERT INTO collate1t1 VALUES(45, hex(45));
+ INSERT INTO collate1t1 VALUES(NULL, NULL);
+ INSERT INTO collate1t1 VALUES(281, hex(281));
+ }
+} {}
+do_test collate1-1.1 {
+ execsql {
+ SELECT c2 FROM collate1t1 ORDER BY 1;
+ }
+} {{} 0x119 0x2D}
+do_test collate1-1.2 {
+ execsql {
+ SELECT c2 FROM collate1t1 ORDER BY 1 COLLATE hex;
+ }
+} {{} 0x2D 0x119}
+do_test collate1-1.3 {
+ execsql {
+ SELECT c2 FROM collate1t1 ORDER BY 1 COLLATE hex DESC;
+ }
+} {0x119 0x2D {}}
+do_test collate1-1.4 {
+ execsql {
+ SELECT c2 FROM collate1t1 ORDER BY 1 COLLATE hex ASC;
+ }
+} {{} 0x2D 0x119}
+do_test collate1-1.5 {
+ execsql {
+ SELECT c2 COLLATE hex FROM collate1t1 ORDER BY 1
+ }
+} {{} 0x2D 0x119}
+do_test collate1-1.6 {
+ execsql {
+ SELECT c2 COLLATE hex FROM collate1t1 ORDER BY 1 ASC
+ }
+} {{} 0x2D 0x119}
+do_test collate1-1.7 {
+ execsql {
+ SELECT c2 COLLATE hex FROM collate1t1 ORDER BY 1 DESC
+ }
+} {0x119 0x2D {}}
+do_test collate1-1.99 {
+ execsql {
+ DROP TABLE collate1t1;
+ }
+} {}
+
+do_test collate1-2.0 {
+ execsql {
+ CREATE TABLE collate1t1(c1, c2);
+ INSERT INTO collate1t1 VALUES('5', '0x11');
+ INSERT INTO collate1t1 VALUES('5', '0xA');
+ INSERT INTO collate1t1 VALUES(NULL, NULL);
+ INSERT INTO collate1t1 VALUES('7', '0xA');
+ INSERT INTO collate1t1 VALUES('11', '0x11');
+ INSERT INTO collate1t1 VALUES('11', '0x101');
+ }
+} {}
+do_test collate1-2.2 {
+ execsql {
+ SELECT c1, c2 FROM collate1t1 ORDER BY 1 COLLATE numeric, 2 COLLATE hex;
+ }
+} {{} {} 5 0xA 5 0x11 7 0xA 11 0x11 11 0x101}
+do_test collate1-2.3 {
+ execsql {
+ SELECT c1, c2 FROM collate1t1 ORDER BY 1 COLLATE binary, 2 COLLATE hex;
+ }
+} {{} {} 11 0x11 11 0x101 5 0xA 5 0x11 7 0xA}
+do_test collate1-2.4 {
+ execsql {
+ SELECT c1, c2 FROM collate1t1 ORDER BY 1 COLLATE binary DESC, 2 COLLATE hex;
+ }
+} {7 0xA 5 0xA 5 0x11 11 0x11 11 0x101 {} {}}
+do_test collate1-2.5 {
+ execsql {
+ SELECT c1, c2 FROM collate1t1
+ ORDER BY 1 COLLATE binary DESC, 2 COLLATE hex DESC;
+ }
+} {7 0xA 5 0x11 5 0xA 11 0x101 11 0x11 {} {}}
+do_test collate1-2.6 {
+ execsql {
+ SELECT c1, c2 FROM collate1t1
+ ORDER BY 1 COLLATE binary ASC, 2 COLLATE hex ASC;
+ }
+} {{} {} 11 0x11 11 0x101 5 0xA 5 0x11 7 0xA}
+do_test collate1-2.12.1 {
+ execsql {
+ SELECT c1 COLLATE numeric, c2 FROM collate1t1
+ ORDER BY 1, 2 COLLATE hex;
+ }
+} {{} {} 5 0xA 5 0x11 7 0xA 11 0x11 11 0x101}
+do_test collate1-2.12.2 {
+ execsql {
+ SELECT c1 COLLATE hex, c2 FROM collate1t1
+ ORDER BY 1 COLLATE numeric, 2 COLLATE hex;
+ }
+} {{} {} 5 0xA 5 0x11 7 0xA 11 0x11 11 0x101}
+do_test collate1-2.12.3 {
+ execsql {
+ SELECT c1, c2 COLLATE hex FROM collate1t1
+ ORDER BY 1 COLLATE numeric, 2;
+ }
+} {{} {} 5 0xA 5 0x11 7 0xA 11 0x11 11 0x101}
+do_test collate1-2.12.4 {
+ execsql {
+ SELECT c1 COLLATE numeric, c2 COLLATE hex
+ FROM collate1t1
+ ORDER BY 1, 2;
+ }
+} {{} {} 5 0xA 5 0x11 7 0xA 11 0x11 11 0x101}
+do_test collate1-2.13 {
+ execsql {
+ SELECT c1 COLLATE binary, c2 COLLATE hex
+ FROM collate1t1
+ ORDER BY 1, 2;
+ }
+} {{} {} 11 0x11 11 0x101 5 0xA 5 0x11 7 0xA}
+do_test collate1-2.14 {
+ execsql {
+ SELECT c1, c2
+ FROM collate1t1 ORDER BY 1 COLLATE binary DESC, 2 COLLATE hex;
+ }
+} {7 0xA 5 0xA 5 0x11 11 0x11 11 0x101 {} {}}
+do_test collate1-2.15 {
+ execsql {
+ SELECT c1 COLLATE binary, c2 COLLATE hex
+ FROM collate1t1
+ ORDER BY 1 DESC, 2 DESC;
+ }
+} {7 0xA 5 0x11 5 0xA 11 0x101 11 0x11 {} {}}
+do_test collate1-2.16 {
+ execsql {
+ SELECT c1 COLLATE hex, c2 COLLATE binary
+ FROM collate1t1
+ ORDER BY 1 COLLATE binary ASC, 2 COLLATE hex ASC;
+ }
+} {{} {} 11 0x11 11 0x101 5 0xA 5 0x11 7 0xA}
+do_test collate1-2.99 {
+ execsql {
+ DROP TABLE collate1t1;
+ }
+} {}
+
+#
+# These tests ensure that the default collation type for a column is used
+# by an ORDER BY clause correctly. The focus is all the different ways
+# the column can be referenced. i.e. a, collate2t1.a, main.collate2t1.a etc.
+#
+do_test collate1-3.0 {
+ execsql {
+ CREATE TABLE collate1t1(a COLLATE hex, b);
+ INSERT INTO collate1t1 VALUES( '0x5', 5 );
+ INSERT INTO collate1t1 VALUES( '1', 1 );
+ INSERT INTO collate1t1 VALUES( '0x45', 69 );
+ INSERT INTO collate1t1 VALUES( NULL, NULL );
+ SELECT * FROM collate1t1 ORDER BY a;
+ }
+} {{} {} 1 1 0x5 5 0x45 69}
+
+do_test collate1-3.1 {
+ execsql {
+ SELECT * FROM collate1t1 ORDER BY 1;
+ }
+} {{} {} 1 1 0x5 5 0x45 69}
+do_test collate1-3.2 {
+ execsql {
+ SELECT * FROM collate1t1 ORDER BY collate1t1.a;
+ }
+} {{} {} 1 1 0x5 5 0x45 69}
+do_test collate1-3.3 {
+ execsql {
+ SELECT * FROM collate1t1 ORDER BY main.collate1t1.a;
+ }
+} {{} {} 1 1 0x5 5 0x45 69}
+do_test collate1-3.4 {
+ execsql {
+ SELECT a as c1, b as c2 FROM collate1t1 ORDER BY c1;
+ }
+} {{} {} 1 1 0x5 5 0x45 69}
+do_test collate1-3.5 {
+ execsql {
+ SELECT a as c1, b as c2 FROM collate1t1 ORDER BY c1 COLLATE binary;
+ }
+} {{} {} 0x45 69 0x5 5 1 1}
+do_test collate1-3.5.1 {
+ execsql {
+ SELECT a COLLATE binary as c1, b as c2
+ FROM collate1t1 ORDER BY c1;
+ }
+} {{} {} 0x45 69 0x5 5 1 1}
+do_test collate1-3.6 {
+ execsql {
+ DROP TABLE collate1t1;
+ }
+} {}
+
+# Update for SQLite version 3. The collate1-4.* test cases were written
+# before manifest types were introduced. The following test cases still
+# work, due to the 'affinity' mechanism, but they don't prove anything
+# about collation sequences.
+#
+do_test collate1-4.0 {
+ execsql {
+ CREATE TABLE collate1t1(c1 numeric, c2 text);
+ INSERT INTO collate1t1 VALUES(1, 1);
+ INSERT INTO collate1t1 VALUES(12, 12);
+ INSERT INTO collate1t1 VALUES(NULL, NULL);
+ INSERT INTO collate1t1 VALUES(101, 101);
+ }
+} {}
+do_test collate1-4.1 {
+ execsql {
+ SELECT c1 FROM collate1t1 ORDER BY 1;
+ }
+} {{} 1 12 101}
+do_test collate1-4.2 {
+ execsql {
+ SELECT c2 FROM collate1t1 ORDER BY 1;
+ }
+} {{} 1 101 12}
+do_test collate1-4.3 {
+ execsql {
+ SELECT c2+0 FROM collate1t1 ORDER BY 1;
+ }
+} {{} 1 12 101}
+do_test collate1-4.4 {
+ execsql {
+ SELECT c1||'' FROM collate1t1 ORDER BY 1;
+ }
+} {{} 1 101 12}
+do_test collate1-4.4.1 {
+ execsql {
+ SELECT (c1||'') COLLATE numeric FROM collate1t1 ORDER BY 1;
+ }
+} {{} 1 12 101}
+do_test collate1-4.5 {
+ execsql {
+ DROP TABLE collate1t1;
+ }
+} {}
+
+finish_test
diff --git a/test/collate2.test b/test/collate2.test
new file mode 100644
index 0000000..bf61923
--- /dev/null
+++ b/test/collate2.test
@@ -0,0 +1,694 @@
+#
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is page cache subsystem.
+#
+# $Id: collate2.test,v 1.6 2008/08/20 16:35:10 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+#
+# Tests are organised as follows:
+#
+# collate2-1.* WHERE <expr> expressions (sqliteExprIfTrue).
+# collate2-2.* WHERE NOT <expr> expressions (sqliteExprIfFalse).
+# collate2-3.* SELECT <expr> expressions (sqliteExprCode).
+# collate2-4.* Precedence of collation/data types in binary comparisons
+# collate2-5.* JOIN syntax.
+#
+
+# Create a collation type BACKWARDS for use in testing. This collation type
+# is similar to the built-in TEXT collation type except the order of
+# characters in each string is reversed before the comparison is performed.
+db collate BACKWARDS backwards_collate
+proc backwards_collate {a b} {
+ set ra {};
+ set rb {}
+ foreach c [split $a {}] { set ra $c$ra }
+ foreach c [split $b {}] { set rb $c$rb }
+ return [string compare $ra $rb]
+}
+
+# The following values are used in these tests:
+# NULL aa ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB
+#
+# The collation orders for each of the tested collation types are:
+#
+# BINARY: NULL AA AB Aa Ab BA BB Ba Bb aA aB aa ab bA bB ba bb
+# NOCASE: NULL aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB
+# BACKWARDS: NULL AA BA aA bA AB BB aB bB Aa Ba aa ba Ab Bb ab bb
+#
+# These tests verify that the default collation type for a column is used
+# for comparison operators (<, >, <=, >=, =) involving that column and
+# an expression that is not a column with a default collation type.
+#
+# The collation sequences BINARY and NOCASE are built-in, the BACKWARDS
+# collation sequence is implemented by the TCL proc backwards_collate
+# above.
+#
+do_test collate2-1.0 {
+ execsql {
+ CREATE TABLE collate2t1(
+ a COLLATE BINARY,
+ b COLLATE NOCASE,
+ c COLLATE BACKWARDS
+ );
+ INSERT INTO collate2t1 VALUES( NULL, NULL, NULL );
+
+ INSERT INTO collate2t1 VALUES( 'aa', 'aa', 'aa' );
+ INSERT INTO collate2t1 VALUES( 'ab', 'ab', 'ab' );
+ INSERT INTO collate2t1 VALUES( 'ba', 'ba', 'ba' );
+ INSERT INTO collate2t1 VALUES( 'bb', 'bb', 'bb' );
+
+ INSERT INTO collate2t1 VALUES( 'aA', 'aA', 'aA' );
+ INSERT INTO collate2t1 VALUES( 'aB', 'aB', 'aB' );
+ INSERT INTO collate2t1 VALUES( 'bA', 'bA', 'bA' );
+ INSERT INTO collate2t1 VALUES( 'bB', 'bB', 'bB' );
+
+ INSERT INTO collate2t1 VALUES( 'Aa', 'Aa', 'Aa' );
+ INSERT INTO collate2t1 VALUES( 'Ab', 'Ab', 'Ab' );
+ INSERT INTO collate2t1 VALUES( 'Ba', 'Ba', 'Ba' );
+ INSERT INTO collate2t1 VALUES( 'Bb', 'Bb', 'Bb' );
+
+ INSERT INTO collate2t1 VALUES( 'AA', 'AA', 'AA' );
+ INSERT INTO collate2t1 VALUES( 'AB', 'AB', 'AB' );
+ INSERT INTO collate2t1 VALUES( 'BA', 'BA', 'BA' );
+ INSERT INTO collate2t1 VALUES( 'BB', 'BB', 'BB' );
+ }
+ if {[info exists collate_test_use_index]} {
+ execsql {
+ CREATE INDEX collate2t1_i1 ON collate2t1(a);
+ CREATE INDEX collate2t1_i2 ON collate2t1(b);
+ CREATE INDEX collate2t1_i3 ON collate2t1(c);
+ }
+ }
+} {}
+do_test collate2-1.1 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE a > 'aa' ORDER BY 1;
+ }
+} {ab bA bB ba bb}
+do_test collate2-1.1.1 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE a COLLATE binary > 'aa' ORDER BY 1;
+ }
+} {ab bA bB ba bb}
+do_test collate2-1.1.2 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE b COLLATE binary > 'aa' ORDER BY 1;
+ }
+} {ab bA bB ba bb}
+do_test collate2-1.1.3 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE c COLLATE binary > 'aa' ORDER BY 1;
+ }
+} {ab bA bB ba bb}
+do_test collate2-1.2 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b > 'aa' ORDER BY 1, oid;
+ }
+} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.2.1 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE a COLLATE nocase > 'aa'
+ ORDER BY 1, oid;
+ }
+} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.2.2 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b COLLATE nocase > 'aa'
+ ORDER BY 1, oid;
+ }
+} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.2.3 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE c COLLATE nocase > 'aa'
+ ORDER BY 1, oid;
+ }
+} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.2.4 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b > 'aa' ORDER BY +b;
+ }
+} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.2.5 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE a COLLATE nocase > 'aa' ORDER BY +b;
+ }
+} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.2.6 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b COLLATE nocase > 'aa' ORDER BY +b;
+ }
+} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.2.7 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE c COLLATE nocase > 'aa' ORDER BY +b;
+ }
+} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.3 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE c > 'aa' ORDER BY 1;
+ }
+} {ba Ab Bb ab bb}
+do_test collate2-1.3.1 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE a COLLATE backwards > 'aa'
+ ORDER BY 1;
+ }
+} {ba Ab Bb ab bb}
+do_test collate2-1.3.2 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE b COLLATE backwards > 'aa'
+ ORDER BY 1;
+ }
+} {ba Ab Bb ab bb}
+do_test collate2-1.3.3 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE c COLLATE backwards > 'aa'
+ ORDER BY 1;
+ }
+} {ba Ab Bb ab bb}
+do_test collate2-1.4 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE a < 'aa' ORDER BY 1;
+ }
+} {AA AB Aa Ab BA BB Ba Bb aA aB}
+do_test collate2-1.5 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b < 'aa' ORDER BY 1, oid;
+ }
+} {}
+do_test collate2-1.5.1 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b < 'aa' ORDER BY +b;
+ }
+} {}
+do_test collate2-1.6 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE c < 'aa' ORDER BY 1;
+ }
+} {AA BA aA bA AB BB aB bB Aa Ba}
+do_test collate2-1.7 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE a = 'aa';
+ }
+} {aa}
+do_test collate2-1.8 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b = 'aa' ORDER BY oid;
+ }
+} {aa aA Aa AA}
+do_test collate2-1.9 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE c = 'aa';
+ }
+} {aa}
+do_test collate2-1.10 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE a >= 'aa' ORDER BY 1;
+ }
+} {aa ab bA bB ba bb}
+do_test collate2-1.11 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b >= 'aa' ORDER BY 1, oid;
+ }
+} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.12 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE c >= 'aa' ORDER BY 1;
+ }
+} {aa ba Ab Bb ab bb}
+do_test collate2-1.13 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE a <= 'aa' ORDER BY 1;
+ }
+} {AA AB Aa Ab BA BB Ba Bb aA aB aa}
+do_test collate2-1.14 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b <= 'aa' ORDER BY 1, oid;
+ }
+} {aa aA Aa AA}
+do_test collate2-1.15 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE c <= 'aa' ORDER BY 1;
+ }
+} {AA BA aA bA AB BB aB bB Aa Ba aa}
+do_test collate2-1.16 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE a BETWEEN 'Aa' AND 'Bb' ORDER BY 1;
+ }
+} {Aa Ab BA BB Ba Bb}
+do_test collate2-1.17 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b BETWEEN 'Aa' AND 'Bb' ORDER BY 1, oid;
+ }
+} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.17.1 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b BETWEEN 'Aa' AND 'Bb' ORDER BY +b;
+ }
+} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-1.18 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE c BETWEEN 'Aa' AND 'Bb' ORDER BY 1;
+ }
+} {Aa Ba aa ba Ab Bb}
+do_test collate2-1.19 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE
+ CASE a WHEN 'aa' THEN 1 ELSE 0 END
+ ORDER BY 1, oid;
+ }
+} {aa}
+do_test collate2-1.20 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE
+ CASE b WHEN 'aa' THEN 1 ELSE 0 END
+ ORDER BY 1, oid;
+ }
+} {aa aA Aa AA}
+do_test collate2-1.21 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE
+ CASE c WHEN 'aa' THEN 1 ELSE 0 END
+ ORDER BY 1, oid;
+ }
+} {aa}
+
+ifcapable subquery {
+ do_test collate2-1.22 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb') ORDER BY 1, oid;
+ }
+ } {aa bb}
+ do_test collate2-1.23 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b IN ('aa', 'bb') ORDER BY 1, oid;
+ }
+ } {aa aA Aa AA bb bB Bb BB}
+ do_test collate2-1.24 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE c IN ('aa', 'bb') ORDER BY 1, oid;
+ }
+ } {aa bb}
+ do_test collate2-1.25 {
+ execsql {
+ SELECT a FROM collate2t1
+ WHERE a IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
+ }
+ } {aa bb}
+ do_test collate2-1.26 {
+ execsql {
+ SELECT b FROM collate2t1
+ WHERE b IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
+ }
+ } {aa bb aA bB Aa Bb AA BB}
+ do_test collate2-1.27 {
+ execsql {
+ SELECT c FROM collate2t1
+ WHERE c IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
+ }
+ } {aa bb}
+} ;# ifcapable subquery
+
+do_test collate2-2.1 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE NOT a > 'aa' ORDER BY 1;
+ }
+} {AA AB Aa Ab BA BB Ba Bb aA aB aa}
+do_test collate2-2.2 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE NOT b > 'aa' ORDER BY 1, oid;
+ }
+} {aa aA Aa AA}
+do_test collate2-2.3 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE NOT c > 'aa' ORDER BY 1;
+ }
+} {AA BA aA bA AB BB aB bB Aa Ba aa}
+do_test collate2-2.4 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE NOT a < 'aa' ORDER BY 1;
+ }
+} {aa ab bA bB ba bb}
+do_test collate2-2.5 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE NOT b < 'aa' ORDER BY 1, oid;
+ }
+} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-2.6 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE NOT c < 'aa' ORDER BY 1;
+ }
+} {aa ba Ab Bb ab bb}
+do_test collate2-2.7 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE NOT a = 'aa';
+ }
+} {ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
+do_test collate2-2.8 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE NOT b = 'aa';
+ }
+} {ab ba bb aB bA bB Ab Ba Bb AB BA BB}
+do_test collate2-2.9 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE NOT c = 'aa';
+ }
+} {ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
+do_test collate2-2.10 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE NOT a >= 'aa' ORDER BY 1;
+ }
+} {AA AB Aa Ab BA BB Ba Bb aA aB}
+do_test collate2-2.11 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE NOT b >= 'aa' ORDER BY 1, oid;
+ }
+} {}
+do_test collate2-2.12 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE NOT c >= 'aa' ORDER BY 1;
+ }
+} {AA BA aA bA AB BB aB bB Aa Ba}
+do_test collate2-2.13 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE NOT a <= 'aa' ORDER BY 1;
+ }
+} {ab bA bB ba bb}
+do_test collate2-2.14 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE NOT b <= 'aa' ORDER BY 1, oid;
+ }
+} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
+do_test collate2-2.15 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE NOT c <= 'aa' ORDER BY 1;
+ }
+} {ba Ab Bb ab bb}
+do_test collate2-2.16 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE a NOT BETWEEN 'Aa' AND 'Bb' ORDER BY 1;
+ }
+} {AA AB aA aB aa ab bA bB ba bb}
+do_test collate2-2.17 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE b NOT BETWEEN 'Aa' AND 'Bb' ORDER BY 1, oid;
+ }
+} {}
+do_test collate2-2.18 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE c NOT BETWEEN 'Aa' AND 'Bb' ORDER BY 1;
+ }
+} {AA BA aA bA AB BB aB bB ab bb}
+do_test collate2-2.19 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE NOT CASE a WHEN 'aa' THEN 1 ELSE 0 END;
+ }
+} {{} ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
+do_test collate2-2.20 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE NOT CASE b WHEN 'aa' THEN 1 ELSE 0 END;
+ }
+} {{} ab ba bb aB bA bB Ab Ba Bb AB BA BB}
+do_test collate2-2.21 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE NOT CASE c WHEN 'aa' THEN 1 ELSE 0 END;
+ }
+} {{} ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
+
+ifcapable subquery {
+ do_test collate2-2.22 {
+ execsql {
+ SELECT a FROM collate2t1 WHERE NOT a IN ('aa', 'bb');
+ }
+ } {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
+ do_test collate2-2.23 {
+ execsql {
+ SELECT b FROM collate2t1 WHERE NOT b IN ('aa', 'bb');
+ }
+ } {ab ba aB bA Ab Ba AB BA}
+ do_test collate2-2.24 {
+ execsql {
+ SELECT c FROM collate2t1 WHERE NOT c IN ('aa', 'bb');
+ }
+ } {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
+ do_test collate2-2.25 {
+ execsql {
+ SELECT a FROM collate2t1
+ WHERE NOT a IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
+ }
+ } {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
+ do_test collate2-2.26 {
+ execsql {
+ SELECT b FROM collate2t1
+ WHERE NOT b IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
+ }
+ } {ab ba aB bA Ab Ba AB BA}
+ do_test collate2-2.27 {
+ execsql {
+ SELECT c FROM collate2t1
+ WHERE NOT c IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
+ }
+ } {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
+}
+
+do_test collate2-3.1 {
+ execsql {
+ SELECT a > 'aa' FROM collate2t1;
+ }
+} {{} 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0}
+do_test collate2-3.2 {
+ execsql {
+ SELECT b > 'aa' FROM collate2t1;
+ }
+} {{} 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1}
+do_test collate2-3.3 {
+ execsql {
+ SELECT c > 'aa' FROM collate2t1;
+ }
+} {{} 0 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0}
+do_test collate2-3.4 {
+ execsql {
+ SELECT a < 'aa' FROM collate2t1;
+ }
+} {{} 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1}
+do_test collate2-3.5 {
+ execsql {
+ SELECT b < 'aa' FROM collate2t1;
+ }
+} {{} 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}
+do_test collate2-3.6 {
+ execsql {
+ SELECT c < 'aa' FROM collate2t1;
+ }
+} {{} 0 0 0 0 1 1 1 1 1 0 1 0 1 1 1 1}
+do_test collate2-3.7 {
+ execsql {
+ SELECT a = 'aa' FROM collate2t1;
+ }
+} {{} 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}
+do_test collate2-3.8 {
+ execsql {
+ SELECT b = 'aa' FROM collate2t1;
+ }
+} {{} 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0}
+do_test collate2-3.9 {
+ execsql {
+ SELECT c = 'aa' FROM collate2t1;
+ }
+} {{} 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}
+do_test collate2-3.10 {
+ execsql {
+ SELECT a <= 'aa' FROM collate2t1;
+ }
+} {{} 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1}
+do_test collate2-3.11 {
+ execsql {
+ SELECT b <= 'aa' FROM collate2t1;
+ }
+} {{} 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0}
+do_test collate2-3.12 {
+ execsql {
+ SELECT c <= 'aa' FROM collate2t1;
+ }
+} {{} 1 0 0 0 1 1 1 1 1 0 1 0 1 1 1 1}
+do_test collate2-3.13 {
+ execsql {
+ SELECT a >= 'aa' FROM collate2t1;
+ }
+} {{} 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0}
+do_test collate2-3.14 {
+ execsql {
+ SELECT b >= 'aa' FROM collate2t1;
+ }
+} {{} 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1}
+do_test collate2-3.15 {
+ execsql {
+ SELECT c >= 'aa' FROM collate2t1;
+ }
+} {{} 1 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0}
+do_test collate2-3.16 {
+ execsql {
+ SELECT a BETWEEN 'Aa' AND 'Bb' FROM collate2t1;
+ }
+} {{} 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1}
+do_test collate2-3.17 {
+ execsql {
+ SELECT b BETWEEN 'Aa' AND 'Bb' FROM collate2t1;
+ }
+} {{} 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1}
+do_test collate2-3.18 {
+ execsql {
+ SELECT c BETWEEN 'Aa' AND 'Bb' FROM collate2t1;
+ }
+} {{} 1 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0}
+do_test collate2-3.19 {
+ execsql {
+ SELECT CASE a WHEN 'aa' THEN 1 ELSE 0 END FROM collate2t1;
+ }
+} {0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}
+do_test collate2-3.20 {
+ execsql {
+ SELECT CASE b WHEN 'aa' THEN 1 ELSE 0 END FROM collate2t1;
+ }
+} {0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0}
+do_test collate2-3.21 {
+ execsql {
+ SELECT CASE c WHEN 'aa' THEN 1 ELSE 0 END FROM collate2t1;
+ }
+} {0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}
+
+ifcapable subquery {
+ do_test collate2-3.22 {
+ execsql {
+ SELECT a IN ('aa', 'bb') FROM collate2t1;
+ }
+ } {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}
+ do_test collate2-3.23 {
+ execsql {
+ SELECT b IN ('aa', 'bb') FROM collate2t1;
+ }
+ } {{} 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1}
+ do_test collate2-3.24 {
+ execsql {
+ SELECT c IN ('aa', 'bb') FROM collate2t1;
+ }
+ } {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}
+ do_test collate2-3.25 {
+ execsql {
+ SELECT a IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'))
+ FROM collate2t1;
+ }
+ } {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}
+ do_test collate2-3.26 {
+ execsql {
+ SELECT b IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'))
+ FROM collate2t1;
+ }
+ } {{} 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1}
+ do_test collate2-3.27 {
+ execsql {
+ SELECT c IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'))
+ FROM collate2t1;
+ }
+ } {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}
+}
+
+do_test collate2-4.0 {
+ execsql {
+ CREATE TABLE collate2t2(b COLLATE binary);
+ CREATE TABLE collate2t3(b text);
+ INSERT INTO collate2t2 VALUES('aa');
+ INSERT INTO collate2t3 VALUES('aa');
+ }
+} {}
+
+# Test that when both sides of a binary comparison operator have
+# default collation types, the collate type for the leftmost term
+# is used.
+do_test collate2-4.1 {
+ execsql {
+ SELECT collate2t1.a FROM collate2t1, collate2t2
+ WHERE collate2t1.b = collate2t2.b;
+ }
+} {aa aA Aa AA}
+do_test collate2-4.2 {
+ execsql {
+ SELECT collate2t1.a FROM collate2t1, collate2t2
+ WHERE collate2t2.b = collate2t1.b;
+ }
+} {aa}
+
+# Test that when one side has a default collation type and the other
+# does not, the collation type is used.
+do_test collate2-4.3 {
+ execsql {
+ SELECT collate2t1.a FROM collate2t1, collate2t3
+ WHERE collate2t1.b = collate2t3.b||'';
+ }
+} {aa aA Aa AA}
+do_test collate2-4.4 {
+ execsql {
+ SELECT collate2t1.a FROM collate2t1, collate2t3
+ WHERE collate2t3.b||'' = collate2t1.b;
+ }
+} {aa aA Aa AA}
+
+do_test collate2-4.5 {
+ execsql {
+ DROP TABLE collate2t3;
+ }
+} {}
+
+#
+# Test that the default collation types are used when the JOIN syntax
+# is used in place of a WHERE clause.
+#
+# SQLite transforms the JOIN syntax into a WHERE clause internally, so
+# the focus of these tests is to ensure that the table on the left-hand-side
+# of the join determines the collation type used.
+#
+do_test collate2-5.0 {
+ execsql {
+ SELECT collate2t1.b FROM collate2t1 JOIN collate2t2 USING (b);
+ }
+} {aa aA Aa AA}
+do_test collate2-5.1 {
+ execsql {
+ SELECT collate2t1.b FROM collate2t2 JOIN collate2t1 USING (b);
+ }
+} {aa}
+do_test collate2-5.2 {
+ execsql {
+ SELECT collate2t1.b FROM collate2t1 NATURAL JOIN collate2t2;
+ }
+} {aa aA Aa AA}
+do_test collate2-5.3 {
+ execsql {
+ SELECT collate2t1.b FROM collate2t2 NATURAL JOIN collate2t1;
+ }
+} {aa}
+do_test collate2-5.4 {
+ execsql {
+ SELECT collate2t2.b FROM collate2t1 LEFT OUTER JOIN collate2t2 USING (b) order by collate2t1.oid;
+ }
+} {{} aa {} {} {} aa {} {} {} aa {} {} {} aa {} {} {}}
+do_test collate2-5.5 {
+ execsql {
+ SELECT collate2t1.b, collate2t2.b FROM collate2t2 LEFT OUTER JOIN collate2t1 USING (b);
+ }
+} {aa aa}
+
+finish_test
diff --git a/test/collate3.test b/test/collate3.test
new file mode 100644
index 0000000..c4dbfbe
--- /dev/null
+++ b/test/collate3.test
@@ -0,0 +1,428 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is page cache subsystem.
+#
+# $Id: collate3.test,v 1.13 2008/08/20 16:35:10 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+#
+# Tests are organised as follows:
+#
+# collate3.1.* - Errors related to unknown collation sequences.
+# collate3.2.* - Errors related to undefined collation sequences.
+# collate3.3.* - Writing to a table that has an index with an undefined c.s.
+# collate3.4.* - Misc errors.
+# collate3.5.* - Collation factory.
+#
+
+#
+# These tests ensure that when a user executes a statement with an
+# unknown collation sequence an error is returned.
+#
+do_test collate3-1.0 {
+ execsql {
+ CREATE TABLE collate3t1(c1);
+ }
+} {}
+do_test collate3-1.1 {
+ catchsql {
+ SELECT * FROM collate3t1 ORDER BY 1 collate garbage;
+ }
+} {1 {no such collation sequence: garbage}}
+do_test collate3-1.2 {
+ catchsql {
+ CREATE TABLE collate3t2(c1 collate garbage);
+ }
+} {1 {no such collation sequence: garbage}}
+do_test collate3-1.3 {
+ catchsql {
+ CREATE INDEX collate3i1 ON collate3t1(c1 COLLATE garbage);
+ }
+} {1 {no such collation sequence: garbage}}
+
+execsql {
+ DROP TABLE collate3t1;
+}
+
+#
+# Create a table with a default collation sequence, then close
+# and re-open the database without re-registering the collation
+# sequence. Then make sure the library stops us from using
+# the collation sequence in:
+# * an explicitly collated ORDER BY
+# * an ORDER BY that uses the default collation sequence
+# * an expression (=)
+# * a CREATE TABLE statement
+# * a CREATE INDEX statement that uses a default collation sequence
+# * a GROUP BY that uses the default collation sequence
+# * a SELECT DISTINCT that uses the default collation sequence
+# * Compound SELECTs that uses the default collation sequence
+# * An ORDER BY on a compound SELECT with an explicit ORDER BY.
+#
+do_test collate3-2.0 {
+ db collate string_compare {string compare}
+ execsql {
+ CREATE TABLE collate3t1(c1 COLLATE string_compare, c2);
+ }
+ db close
+ sqlite3 db test.db
+ expr 0
+} 0
+do_test collate3-2.1 {
+ catchsql {
+ SELECT * FROM collate3t1 ORDER BY 1 COLLATE string_compare;
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-2.2 {
+ catchsql {
+ SELECT * FROM collate3t1 ORDER BY c1;
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-2.3 {
+ catchsql {
+ SELECT * FROM collate3t1 WHERE c1 = 'xxx';
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-2.4 {
+ catchsql {
+ CREATE TABLE collate3t2(c1 COLLATE string_compare);
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-2.5 {
+ catchsql {
+ CREATE INDEX collate3t1_i1 ON collate3t1(c1);
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-2.6 {
+ catchsql {
+ SELECT * FROM collate3t1;
+ }
+} {0 {}}
+do_test collate3-2.7.1 {
+ catchsql {
+ SELECT count(*) FROM collate3t1 GROUP BY c1;
+ }
+} {1 {no such collation sequence: string_compare}}
+# do_test collate3-2.7.2 {
+# catchsql {
+# SELECT * FROM collate3t1 GROUP BY c1;
+# }
+# } {1 {GROUP BY may only be used on aggregate queries}}
+do_test collate3-2.7.2 {
+ catchsql {
+ SELECT * FROM collate3t1 GROUP BY c1;
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-2.8 {
+ catchsql {
+ SELECT DISTINCT c1 FROM collate3t1;
+ }
+} {1 {no such collation sequence: string_compare}}
+
+ifcapable compound {
+ do_test collate3-2.9 {
+ catchsql {
+ SELECT c1 FROM collate3t1 UNION SELECT c1 FROM collate3t1;
+ }
+ } {1 {no such collation sequence: string_compare}}
+ do_test collate3-2.10 {
+ catchsql {
+ SELECT c1 FROM collate3t1 EXCEPT SELECT c1 FROM collate3t1;
+ }
+ } {1 {no such collation sequence: string_compare}}
+ do_test collate3-2.11 {
+ catchsql {
+ SELECT c1 FROM collate3t1 INTERSECT SELECT c1 FROM collate3t1;
+ }
+ } {1 {no such collation sequence: string_compare}}
+ do_test collate3-2.12 {
+ catchsql {
+ SELECT c1 FROM collate3t1 UNION ALL SELECT c1 FROM collate3t1;
+ }
+ } {0 {}}
+ do_test collate3-2.13 {
+ catchsql {
+ SELECT 10 UNION ALL SELECT 20 ORDER BY 1 COLLATE string_compare;
+ }
+ } {1 {no such collation sequence: string_compare}}
+ do_test collate3-2.14 {
+ catchsql {
+ SELECT 10 INTERSECT SELECT 20 ORDER BY 1 COLLATE string_compare;
+ }
+ } {1 {no such collation sequence: string_compare}}
+ do_test collate3-2.15 {
+ catchsql {
+ SELECT 10 EXCEPT SELECT 20 ORDER BY 1 COLLATE string_compare;
+ }
+ } {1 {no such collation sequence: string_compare}}
+ do_test collate3-2.16 {
+ catchsql {
+ SELECT 10 UNION SELECT 20 ORDER BY 1 COLLATE string_compare;
+ }
+ } {1 {no such collation sequence: string_compare}}
+ do_test collate3-2.17 {
+ catchsql {
+ SELECT c1 FROM collate3t1 UNION ALL SELECT c1 FROM collate3t1 ORDER BY 1;
+ }
+ } {1 {no such collation sequence: string_compare}}
+} ;# ifcapable compound
+
+#
+# Create an index that uses a collation sequence then close and
+# re-open the database without re-registering the collation
+# sequence. Then check that for the table with the index
+# * An INSERT fails,
+# * An UPDATE on the column with the index fails,
+# * An UPDATE on a different column succeeds.
+# * A DELETE with a WHERE clause fails
+# * A DELETE without a WHERE clause succeeds
+#
+# Also, ensure that the restrictions tested by collate3-2.* still
+# apply after the index has been created.
+#
+do_test collate3-3.0 {
+ db collate string_compare {string compare}
+ execsql {
+ CREATE INDEX collate3t1_i1 ON collate3t1(c1);
+ INSERT INTO collate3t1 VALUES('xxx', 'yyy');
+ }
+ db close
+ sqlite3 db test.db
+ expr 0
+} 0
+db eval {select * from collate3t1}
+do_test collate3-3.1 {
+ catchsql {
+ INSERT INTO collate3t1 VALUES('xxx', 0);
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-3.2 {
+ catchsql {
+ UPDATE collate3t1 SET c1 = 'xxx';
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-3.3 {
+ catchsql {
+ UPDATE collate3t1 SET c2 = 'xxx';
+ }
+} {0 {}}
+do_test collate3-3.4 {
+ catchsql {
+ DELETE FROM collate3t1 WHERE 1;
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-3.5 {
+ catchsql {
+ SELECT * FROM collate3t1;
+ }
+} {0 {xxx xxx}}
+do_test collate3-3.6 {
+ catchsql {
+ DELETE FROM collate3t1;
+ }
+} {0 {}}
+ifcapable {integrityck} {
+ do_test collate3-3.8 {
+ catchsql {
+ PRAGMA integrity_check
+ }
+ } {1 {no such collation sequence: string_compare}}
+}
+do_test collate3-3.9 {
+ catchsql {
+ SELECT * FROM collate3t1;
+ }
+} {0 {}}
+do_test collate3-3.10 {
+ catchsql {
+ SELECT * FROM collate3t1 ORDER BY 1 COLLATE string_compare;
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-3.11 {
+ catchsql {
+ SELECT * FROM collate3t1 ORDER BY c1;
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-3.12 {
+ catchsql {
+ SELECT * FROM collate3t1 WHERE c1 = 'xxx';
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-3.13 {
+ catchsql {
+ CREATE TABLE collate3t2(c1 COLLATE string_compare);
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-3.14 {
+ catchsql {
+ CREATE INDEX collate3t1_i2 ON collate3t1(c1);
+ }
+} {1 {no such collation sequence: string_compare}}
+do_test collate3-3.15 {
+ execsql {
+ DROP TABLE collate3t1;
+ }
+} {}
+
+# Check we can create an index that uses an explicit collation
+# sequence and then close and re-open the database.
+do_test collate3-4.6 {
+ db collate user_defined "string compare"
+ execsql {
+ CREATE TABLE collate3t1(a, b);
+ INSERT INTO collate3t1 VALUES('hello', NULL);
+ CREATE INDEX collate3i1 ON collate3t1(a COLLATE user_defined);
+ }
+} {}
+do_test collate3-4.7 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT * FROM collate3t1 ORDER BY a COLLATE user_defined;
+ }
+} {1 {no such collation sequence: user_defined}}
+do_test collate3-4.8.1 {
+ db collate user_defined "string compare"
+ catchsql {
+ SELECT * FROM collate3t1 ORDER BY a COLLATE user_defined;
+ }
+} {0 {hello {}}}
+do_test collate3-4.8.2 {
+ db close
+ lindex [catch {
+ sqlite3 db test.db
+ }] 0
+} {0}
+do_test collate3-4.8.3 {
+ execsql {
+ DROP TABLE collate3t1;
+ }
+} {}
+
+# Compare strings as numbers.
+proc numeric_compare {lhs rhs} {
+ if {$rhs > $lhs} {
+ set res -1
+ } else {
+ set res [expr ($lhs > $rhs)?1:0]
+ }
+ return $res
+}
+
+# Check we can create a view that uses an explicit collation
+# sequence and then close and re-open the database.
+ifcapable view {
+do_test collate3-4.9 {
+ db collate user_defined numeric_compare
+ execsql {
+ CREATE TABLE collate3t1(a, b);
+ INSERT INTO collate3t1 VALUES('2', NULL);
+ INSERT INTO collate3t1 VALUES('101', NULL);
+ INSERT INTO collate3t1 VALUES('12', NULL);
+ CREATE VIEW collate3v1 AS SELECT * FROM collate3t1
+ ORDER BY 1 COLLATE user_defined;
+ SELECT * FROM collate3v1;
+ }
+} {2 {} 12 {} 101 {}}
+do_test collate3-4.10 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT * FROM collate3v1;
+ }
+} {1 {no such collation sequence: user_defined}}
+do_test collate3-4.11 {
+ db collate user_defined numeric_compare
+ catchsql {
+ SELECT * FROM collate3v1;
+ }
+} {0 {2 {} 12 {} 101 {}}}
+do_test collate3-4.12 {
+ execsql {
+ DROP TABLE collate3t1;
+ }
+} {}
+} ;# ifcapable view
+
+#
+# Test the collation factory. In the code, the "no such collation sequence"
+# message is only generated in two places. So these tests just test that
+# the collation factory can be called once from each of those points.
+#
+do_test collate3-5.0 {
+ catchsql {
+ CREATE TABLE collate3t1(a);
+ INSERT INTO collate3t1 VALUES(10);
+ SELECT a FROM collate3t1 ORDER BY 1 COLLATE unk;
+ }
+} {1 {no such collation sequence: unk}}
+do_test collate3-5.1 {
+ set ::cfact_cnt 0
+ proc cfact {nm} {
+ db collate $nm {string compare}
+ incr ::cfact_cnt
+ }
+ db collation_needed cfact
+} {}
+do_test collate3-5.2 {
+ catchsql {
+ SELECT a FROM collate3t1 ORDER BY 1 COLLATE unk;
+ }
+} {0 10}
+do_test collate3-5.3 {
+ set ::cfact_cnt
+} {1}
+do_test collate3-5.4 {
+ catchsql {
+ SELECT a FROM collate3t1 ORDER BY 1 COLLATE unk;
+ }
+} {0 10}
+do_test collate3-5.5 {
+ set ::cfact_cnt
+} {1}
+do_test collate3-5.6 {
+ catchsql {
+ SELECT a FROM collate3t1 ORDER BY 1 COLLATE unk;
+ }
+} {0 10}
+do_test collate3-5.7 {
+ execsql {
+ DROP TABLE collate3t1;
+ CREATE TABLE collate3t1(a COLLATE unk);
+ }
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT a FROM collate3t1 ORDER BY 1;
+ }
+} {1 {no such collation sequence: unk}}
+do_test collate3-5.8 {
+ set ::cfact_cnt 0
+ proc cfact {nm} {
+ db collate $nm {string compare}
+ incr ::cfact_cnt
+ }
+ db collation_needed cfact
+ catchsql {
+ SELECT a FROM collate3t1 ORDER BY 1;
+ }
+} {0 {}}
+
+do_test collate3-5.9 {
+ execsql {
+ DROP TABLE collate3t1;
+ }
+} {}
+
+finish_test
diff --git a/test/collate4.test b/test/collate4.test
new file mode 100644
index 0000000..12bc16e
--- /dev/null
+++ b/test/collate4.test
@@ -0,0 +1,701 @@
+#
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is page cache subsystem.
+#
+# $Id: collate4.test,v 1.9 2008/01/05 17:39:30 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+db collate TEXT text_collate
+proc text_collate {a b} {
+ return [string compare $a $b]
+}
+
+# Do an SQL statement. Append the search count to the end of the result.
+#
+proc count sql {
+ set ::sqlite_search_count 0
+ return [concat [execsql $sql] $::sqlite_search_count]
+}
+
+# This procedure executes the SQL. Then it checks the generated program
+# for the SQL and appends a "nosort" to the result if the program contains the
+# SortCallback opcode. If the program does not contain the SortCallback
+# opcode it appends "sort"
+#
+proc cksort {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ if {$::sqlite_sort_count} {set x sort} {set x nosort}
+ lappend data $x
+ return $data
+}
+
+#
+# Test cases are organized roughly as follows:
+#
+# collate4-1.* ORDER BY.
+# collate4-2.* WHERE clauses.
+# collate4-3.* constraints (primary key, unique).
+# collate4-4.* simple min() or max() queries.
+# collate4-5.* REINDEX command
+# collate4-6.* INTEGER PRIMARY KEY indices.
+#
+
+#
+# These tests - collate4-1.* - check that indices are correctly
+# selected or not selected to implement ORDER BY clauses when
+# user defined collation sequences are involved.
+#
+# Because these tests also exercise all the different ways indices
+# can be created, they also serve to verify that indices are correctly
+# initialised with user-defined collation sequences when they are
+# created.
+#
+# Tests named collate4-1.1.* use indices with a single column. Tests
+# collate4-1.2.* use indices with two columns.
+#
+do_test collate4-1.1.0 {
+ execsql {
+ CREATE TABLE collate4t1(a COLLATE NOCASE, b COLLATE TEXT);
+ INSERT INTO collate4t1 VALUES( 'a', 'a' );
+ INSERT INTO collate4t1 VALUES( 'b', 'b' );
+ INSERT INTO collate4t1 VALUES( NULL, NULL );
+ INSERT INTO collate4t1 VALUES( 'B', 'B' );
+ INSERT INTO collate4t1 VALUES( 'A', 'A' );
+ CREATE INDEX collate4i1 ON collate4t1(a);
+ CREATE INDEX collate4i2 ON collate4t1(b);
+ }
+} {}
+do_test collate4-1.1.1 {
+ cksort {SELECT a FROM collate4t1 ORDER BY a}
+} {{} a A b B nosort}
+do_test collate4-1.1.2 {
+ cksort {SELECT a FROM collate4t1 ORDER BY a COLLATE NOCASE}
+} {{} a A b B nosort}
+do_test collate4-1.1.3 {
+ cksort {SELECT a FROM collate4t1 ORDER BY a COLLATE TEXT}
+} {{} A B a b sort}
+do_test collate4-1.1.4 {
+ cksort {SELECT b FROM collate4t1 ORDER BY b}
+} {{} A B a b nosort}
+do_test collate4-1.1.5 {
+ cksort {SELECT b FROM collate4t1 ORDER BY b COLLATE TEXT}
+} {{} A B a b nosort}
+do_test collate4-1.1.6 {
+ cksort {SELECT b FROM collate4t1 ORDER BY b COLLATE NOCASE}
+} {{} a A b B sort}
+
+do_test collate4-1.1.7 {
+ execsql {
+ CREATE TABLE collate4t2(
+ a PRIMARY KEY COLLATE NOCASE,
+ b UNIQUE COLLATE TEXT
+ );
+ INSERT INTO collate4t2 VALUES( 'a', 'a' );
+ INSERT INTO collate4t2 VALUES( NULL, NULL );
+ INSERT INTO collate4t2 VALUES( 'B', 'B' );
+ }
+} {}
+do_test collate4-1.1.8 {
+ cksort {SELECT a FROM collate4t2 ORDER BY a}
+} {{} a B nosort}
+do_test collate4-1.1.9 {
+ cksort {SELECT a FROM collate4t2 ORDER BY a COLLATE NOCASE}
+} {{} a B nosort}
+do_test collate4-1.1.10 {
+ cksort {SELECT a FROM collate4t2 ORDER BY a COLLATE TEXT}
+} {{} B a sort}
+do_test collate4-1.1.11 {
+ cksort {SELECT b FROM collate4t2 ORDER BY b}
+} {{} B a nosort}
+do_test collate4-1.1.12 {
+ cksort {SELECT b FROM collate4t2 ORDER BY b COLLATE TEXT}
+} {{} B a nosort}
+do_test collate4-1.1.13 {
+ cksort {SELECT b FROM collate4t2 ORDER BY b COLLATE NOCASE}
+} {{} a B sort}
+
+do_test collate4-1.1.14 {
+ execsql {
+ CREATE TABLE collate4t3(
+ b COLLATE TEXT,
+ a COLLATE NOCASE,
+ UNIQUE(a), PRIMARY KEY(b)
+ );
+ INSERT INTO collate4t3 VALUES( 'a', 'a' );
+ INSERT INTO collate4t3 VALUES( NULL, NULL );
+ INSERT INTO collate4t3 VALUES( 'B', 'B' );
+ }
+} {}
+do_test collate4-1.1.15 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a}
+} {{} a B nosort}
+do_test collate4-1.1.16 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE NOCASE}
+} {{} a B nosort}
+do_test collate4-1.1.17 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE TEXT}
+} {{} B a sort}
+do_test collate4-1.1.18 {
+ cksort {SELECT b FROM collate4t3 ORDER BY b}
+} {{} B a nosort}
+do_test collate4-1.1.19 {
+ cksort {SELECT b FROM collate4t3 ORDER BY b COLLATE TEXT}
+} {{} B a nosort}
+do_test collate4-1.1.20 {
+ cksort {SELECT b FROM collate4t3 ORDER BY b COLLATE NOCASE}
+} {{} a B sort}
+
+do_test collate4-1.1.21 {
+ execsql {
+ CREATE TABLE collate4t4(a COLLATE NOCASE, b COLLATE TEXT);
+ INSERT INTO collate4t4 VALUES( 'a', 'a' );
+ INSERT INTO collate4t4 VALUES( 'b', 'b' );
+ INSERT INTO collate4t4 VALUES( NULL, NULL );
+ INSERT INTO collate4t4 VALUES( 'B', 'B' );
+ INSERT INTO collate4t4 VALUES( 'A', 'A' );
+ CREATE INDEX collate4i3 ON collate4t4(a COLLATE TEXT);
+ CREATE INDEX collate4i4 ON collate4t4(b COLLATE NOCASE);
+ }
+} {}
+do_test collate4-1.1.22 {
+ cksort {SELECT a FROM collate4t4 ORDER BY a}
+} {{} a A b B sort}
+do_test collate4-1.1.23 {
+ cksort {SELECT a FROM collate4t4 ORDER BY a COLLATE NOCASE}
+} {{} a A b B sort}
+do_test collate4-1.1.24 {
+ cksort {SELECT a FROM collate4t4 ORDER BY a COLLATE TEXT}
+} {{} A B a b nosort}
+do_test collate4-1.1.25 {
+ cksort {SELECT b FROM collate4t4 ORDER BY b}
+} {{} A B a b sort}
+do_test collate4-1.1.26 {
+ cksort {SELECT b FROM collate4t4 ORDER BY b COLLATE TEXT}
+} {{} A B a b sort}
+do_test collate4-1.1.27 {
+ cksort {SELECT b FROM collate4t4 ORDER BY b COLLATE NOCASE}
+} {{} a A b B nosort}
+
+do_test collate4-1.1.30 {
+ execsql {
+ DROP TABLE collate4t1;
+ DROP TABLE collate4t2;
+ DROP TABLE collate4t3;
+ DROP TABLE collate4t4;
+ }
+} {}
+
+do_test collate4-1.2.0 {
+ execsql {
+ CREATE TABLE collate4t1(a COLLATE NOCASE, b COLLATE TEXT);
+ INSERT INTO collate4t1 VALUES( 'a', 'a' );
+ INSERT INTO collate4t1 VALUES( 'b', 'b' );
+ INSERT INTO collate4t1 VALUES( NULL, NULL );
+ INSERT INTO collate4t1 VALUES( 'B', 'B' );
+ INSERT INTO collate4t1 VALUES( 'A', 'A' );
+ CREATE INDEX collate4i1 ON collate4t1(a, b);
+ }
+} {}
+do_test collate4-1.2.1 {
+ cksort {SELECT a FROM collate4t1 ORDER BY a}
+} {{} A a B b nosort}
+do_test collate4-1.2.2 {
+ cksort {SELECT a FROM collate4t1 ORDER BY a COLLATE nocase}
+} {{} A a B b nosort}
+do_test collate4-1.2.3 {
+ cksort {SELECT a FROM collate4t1 ORDER BY a COLLATE text}
+} {{} A B a b sort}
+do_test collate4-1.2.4 {
+ cksort {SELECT a FROM collate4t1 ORDER BY a, b}
+} {{} A a B b nosort}
+do_test collate4-1.2.5 {
+ cksort {SELECT a FROM collate4t1 ORDER BY a, b COLLATE nocase}
+} {{} a A b B sort}
+do_test collate4-1.2.6 {
+ cksort {SELECT a FROM collate4t1 ORDER BY a, b COLLATE text}
+} {{} A a B b nosort}
+
+do_test collate4-1.2.7 {
+ execsql {
+ CREATE TABLE collate4t2(
+ a COLLATE NOCASE,
+ b COLLATE TEXT,
+ PRIMARY KEY(a, b)
+ );
+ INSERT INTO collate4t2 VALUES( 'a', 'a' );
+ INSERT INTO collate4t2 VALUES( NULL, NULL );
+ INSERT INTO collate4t2 VALUES( 'B', 'B' );
+ }
+} {}
+do_test collate4-1.2.8 {
+ cksort {SELECT a FROM collate4t2 ORDER BY a}
+} {{} a B nosort}
+do_test collate4-1.2.9 {
+ cksort {SELECT a FROM collate4t2 ORDER BY a COLLATE nocase}
+} {{} a B nosort}
+do_test collate4-1.2.10 {
+ cksort {SELECT a FROM collate4t2 ORDER BY a COLLATE text}
+} {{} B a sort}
+do_test collate4-1.2.11 {
+ cksort {SELECT a FROM collate4t2 ORDER BY a, b}
+} {{} a B nosort}
+do_test collate4-1.2.12 {
+ cksort {SELECT a FROM collate4t2 ORDER BY a, b COLLATE nocase}
+} {{} a B sort}
+do_test collate4-1.2.13 {
+ cksort {SELECT a FROM collate4t2 ORDER BY a, b COLLATE text}
+} {{} a B nosort}
+
+do_test collate4-1.2.14 {
+ execsql {
+ CREATE TABLE collate4t3(a COLLATE NOCASE, b COLLATE TEXT);
+ INSERT INTO collate4t3 VALUES( 'a', 'a' );
+ INSERT INTO collate4t3 VALUES( 'b', 'b' );
+ INSERT INTO collate4t3 VALUES( NULL, NULL );
+ INSERT INTO collate4t3 VALUES( 'B', 'B' );
+ INSERT INTO collate4t3 VALUES( 'A', 'A' );
+ CREATE INDEX collate4i2 ON collate4t3(a COLLATE TEXT, b COLLATE NOCASE);
+ }
+} {}
+do_test collate4-1.2.15 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a}
+} {{} a A b B sort}
+do_test collate4-1.2.16 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE nocase}
+} {{} a A b B sort}
+do_test collate4-1.2.17 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text}
+} {{} A B a b nosort}
+do_test collate4-1.2.18 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text, b}
+} {{} A B a b sort}
+do_test collate4-1.2.19 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text, b COLLATE nocase}
+} {{} A B a b nosort}
+do_test collate4-1.2.20 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text, b COLLATE text}
+} {{} A B a b sort}
+do_test collate4-1.2.21 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text DESC}
+} {b a B A {} nosort}
+do_test collate4-1.2.22 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text DESC, b}
+} {b a B A {} sort}
+do_test collate4-1.2.23 {
+ cksort {SELECT a FROM collate4t3
+ ORDER BY a COLLATE text DESC, b COLLATE nocase}
+} {b a B A {} sort}
+do_test collate4-1.2.24 {
+ cksort {SELECT a FROM collate4t3
+ ORDER BY a COLLATE text DESC, b COLLATE nocase DESC}
+} {b a B A {} nosort}
+
+do_test collate4-1.2.25 {
+ execsql {
+ DROP TABLE collate4t1;
+ DROP TABLE collate4t2;
+ DROP TABLE collate4t3;
+ }
+} {}
+
+#
+# These tests - collate4-2.* - check that indices are correctly
+# selected or not selected to implement WHERE clauses when user
+# defined collation sequences are involved.
+#
+# Indices may optimise WHERE clauses using <, >, <=, >=, = or IN
+# operators.
+#
+do_test collate4-2.1.0 {
+ execsql {
+ PRAGMA automatic_index=OFF;
+ CREATE TABLE collate4t1(a COLLATE NOCASE);
+ CREATE TABLE collate4t2(b COLLATE TEXT);
+
+ INSERT INTO collate4t1 VALUES('a');
+ INSERT INTO collate4t1 VALUES('A');
+ INSERT INTO collate4t1 VALUES('b');
+ INSERT INTO collate4t1 VALUES('B');
+ INSERT INTO collate4t1 VALUES('c');
+ INSERT INTO collate4t1 VALUES('C');
+ INSERT INTO collate4t1 VALUES('d');
+ INSERT INTO collate4t1 VALUES('D');
+ INSERT INTO collate4t1 VALUES('e');
+ INSERT INTO collate4t1 VALUES('D');
+
+ INSERT INTO collate4t2 VALUES('A');
+ INSERT INTO collate4t2 VALUES('Z');
+ }
+} {}
+do_test collate4-2.1.1 {
+ count {
+ SELECT * FROM collate4t2, collate4t1 WHERE a = b;
+ }
+} {A a A A 19}
+do_test collate4-2.1.2 {
+ execsql {
+ CREATE INDEX collate4i1 ON collate4t1(a);
+ }
+ count {
+ SELECT * FROM collate4t2, collate4t1 WHERE a = b;
+ }
+} {A a A A 5}
+do_test collate4-2.1.3 {
+ count {
+ SELECT * FROM collate4t2, collate4t1 WHERE b = a;
+ }
+} {A A 19}
+do_test collate4-2.1.4 {
+ execsql {
+ DROP INDEX collate4i1;
+ CREATE INDEX collate4i1 ON collate4t1(a COLLATE TEXT);
+ }
+ count {
+ SELECT * FROM collate4t2, collate4t1 WHERE a = b;
+ }
+} {A a A A 19}
+do_test collate4-2.1.5 {
+ count {
+ SELECT * FROM collate4t2, collate4t1 WHERE b = a;
+ }
+} {A A 4}
+ifcapable subquery {
+ do_test collate4-2.1.6 {
+ count {
+ SELECT a FROM collate4t1 WHERE a IN (SELECT * FROM collate4t2);
+ }
+ } {a A 10}
+ do_test collate4-2.1.7 {
+ execsql {
+ DROP INDEX collate4i1;
+ CREATE INDEX collate4i1 ON collate4t1(a);
+ }
+ count {
+ SELECT a FROM collate4t1 WHERE a IN (SELECT * FROM collate4t2);
+ }
+ } {a A 6}
+ do_test collate4-2.1.8 {
+ count {
+ SELECT a FROM collate4t1 WHERE a IN ('z', 'a');
+ }
+ } {a A 5}
+ do_test collate4-2.1.9 {
+ execsql {
+ DROP INDEX collate4i1;
+ CREATE INDEX collate4i1 ON collate4t1(a COLLATE TEXT);
+ }
+ count {
+ SELECT a FROM collate4t1 WHERE a IN ('z', 'a');
+ }
+ } {a A 9}
+}
+do_test collate4-2.1.10 {
+ execsql {
+ DROP TABLE collate4t1;
+ DROP TABLE collate4t2;
+ }
+} {}
+
+do_test collate4-2.2.0 {
+ execsql {
+ CREATE TABLE collate4t1(a COLLATE nocase, b COLLATE text, c);
+ CREATE TABLE collate4t2(a COLLATE nocase, b COLLATE text, c COLLATE TEXT);
+
+ INSERT INTO collate4t1 VALUES('0', '0', '0');
+ INSERT INTO collate4t1 VALUES('0', '0', '1');
+ INSERT INTO collate4t1 VALUES('0', '1', '0');
+ INSERT INTO collate4t1 VALUES('0', '1', '1');
+ INSERT INTO collate4t1 VALUES('1', '0', '0');
+ INSERT INTO collate4t1 VALUES('1', '0', '1');
+ INSERT INTO collate4t1 VALUES('1', '1', '0');
+ INSERT INTO collate4t1 VALUES('1', '1', '1');
+ insert into collate4t2 SELECT * FROM collate4t1;
+ }
+} {}
+do_test collate4-2.2.1 {
+ count {
+ SELECT * FROM collate4t2 NOT INDEXED NATURAL JOIN collate4t1 NOT INDEXED;
+ }
+} {0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 63}
+do_test collate4-2.2.1b {
+ execsql {
+ CREATE INDEX collate4i1 ON collate4t1(a, b, c);
+ }
+ count {
+ SELECT * FROM collate4t2 NATURAL JOIN collate4t1;
+ }
+} {0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 29}
+do_test collate4-2.2.2 {
+ execsql {
+ DROP INDEX collate4i1;
+ CREATE INDEX collate4i1 ON collate4t1(a, b, c COLLATE text);
+ }
+ count {
+ SELECT * FROM collate4t2 NATURAL JOIN collate4t1;
+ }
+} {0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 22}
+
+do_test collate4-2.2.10 {
+ execsql {
+ DROP TABLE collate4t1;
+ DROP TABLE collate4t2;
+ }
+} {}
+
+#
+# These tests - collate4-3.* verify that indices that implement
+# UNIQUE and PRIMARY KEY constraints operate correctly with user
+# defined collation sequences.
+#
+do_test collate4-3.0 {
+ execsql {
+ CREATE TABLE collate4t1(a PRIMARY KEY COLLATE NOCASE);
+ }
+} {}
+do_test collate4-3.1 {
+ catchsql {
+ INSERT INTO collate4t1 VALUES('abc');
+ INSERT INTO collate4t1 VALUES('ABC');
+ }
+} {1 {column a is not unique}}
+do_test collate4-3.2 {
+ execsql {
+ SELECT * FROM collate4t1;
+ }
+} {abc}
+do_test collate4-3.3 {
+ catchsql {
+ INSERT INTO collate4t1 SELECT upper(a) FROM collate4t1;
+ }
+} {1 {column a is not unique}}
+do_test collate4-3.4 {
+ catchsql {
+ INSERT INTO collate4t1 VALUES(1);
+ UPDATE collate4t1 SET a = 'abc';
+ }
+} {1 {column a is not unique}}
+do_test collate4-3.5 {
+ execsql {
+ DROP TABLE collate4t1;
+ CREATE TABLE collate4t1(a COLLATE NOCASE UNIQUE);
+ }
+} {}
+do_test collate4-3.6 {
+ catchsql {
+ INSERT INTO collate4t1 VALUES('abc');
+ INSERT INTO collate4t1 VALUES('ABC');
+ }
+} {1 {column a is not unique}}
+do_test collate4-3.7 {
+ execsql {
+ SELECT * FROM collate4t1;
+ }
+} {abc}
+do_test collate4-3.8 {
+ catchsql {
+ INSERT INTO collate4t1 SELECT upper(a) FROM collate4t1;
+ }
+} {1 {column a is not unique}}
+do_test collate4-3.9 {
+ catchsql {
+ INSERT INTO collate4t1 VALUES(1);
+ UPDATE collate4t1 SET a = 'abc';
+ }
+} {1 {column a is not unique}}
+do_test collate4-3.10 {
+ execsql {
+ DROP TABLE collate4t1;
+ CREATE TABLE collate4t1(a);
+ CREATE UNIQUE INDEX collate4i1 ON collate4t1(a COLLATE NOCASE);
+ }
+} {}
+do_test collate4-3.11 {
+ catchsql {
+ INSERT INTO collate4t1 VALUES('abc');
+ INSERT INTO collate4t1 VALUES('ABC');
+ }
+} {1 {column a is not unique}}
+do_test collate4-3.12 {
+ execsql {
+ SELECT * FROM collate4t1;
+ }
+} {abc}
+do_test collate4-3.13 {
+ catchsql {
+ INSERT INTO collate4t1 SELECT upper(a) FROM collate4t1;
+ }
+} {1 {column a is not unique}}
+do_test collate4-3.14 {
+ catchsql {
+ INSERT INTO collate4t1 VALUES(1);
+ UPDATE collate4t1 SET a = 'abc';
+ }
+} {1 {column a is not unique}}
+
+do_test collate4-3.15 {
+ execsql {
+ DROP TABLE collate4t1;
+ }
+} {}
+
+# Mimic the SQLite 2 collation type NUMERIC.
+db collate numeric numeric_collate
+proc numeric_collate {lhs rhs} {
+ if {$lhs == $rhs} {return 0}
+ return [expr ($lhs>$rhs)?1:-1]
+}
+
+#
+# These tests - collate4-4.* check that min() and max() only ever
+# use indices constructed with built-in collation type numeric.
+#
+# CHANGED: min() and max() now use the collation type. If there
+# is an indice that can be used, it is used.
+#
+do_test collate4-4.0 {
+ execsql {
+ CREATE TABLE collate4t1(a COLLATE TEXT);
+ INSERT INTO collate4t1 VALUES('2');
+ INSERT INTO collate4t1 VALUES('10');
+ INSERT INTO collate4t1 VALUES('20');
+ INSERT INTO collate4t1 VALUES('104');
+ }
+} {}
+do_test collate4-4.1 {
+ count {
+ SELECT max(a) FROM collate4t1
+ }
+} {20 3}
+do_test collate4-4.2 {
+ count {
+ SELECT min(a) FROM collate4t1
+ }
+} {10 3}
+do_test collate4-4.3 {
+ # Test that the index with collation type TEXT is used.
+ execsql {
+ CREATE INDEX collate4i1 ON collate4t1(a);
+ }
+ count {
+ SELECT min(a) FROM collate4t1;
+ }
+} {10 1}
+do_test collate4-4.4 {
+ count {
+ SELECT max(a) FROM collate4t1;
+ }
+} {20 0}
+do_test collate4-4.5 {
+ # Test that the index with collation type NUMERIC is not used.
+ execsql {
+ DROP INDEX collate4i1;
+ CREATE INDEX collate4i1 ON collate4t1(a COLLATE NUMERIC);
+ }
+ count {
+ SELECT min(a) FROM collate4t1;
+ }
+} {10 3}
+do_test collate4-4.6 {
+ count {
+ SELECT max(a) FROM collate4t1;
+ }
+} {20 3}
+do_test collate4-4.7 {
+ execsql {
+ DROP TABLE collate4t1;
+ }
+} {}
+
+# Also test the scalar min() and max() functions.
+#
+do_test collate4-4.8 {
+ execsql {
+ CREATE TABLE collate4t1(a COLLATE TEXT, b COLLATE NUMERIC);
+ INSERT INTO collate4t1 VALUES('11', '101');
+ INSERT INTO collate4t1 VALUES('101', '11')
+ }
+} {}
+do_test collate4-4.9 {
+ execsql {
+ SELECT max(a, b) FROM collate4t1;
+ }
+} {11 11}
+do_test collate4-4.10 {
+ execsql {
+ SELECT max(b, a) FROM collate4t1;
+ }
+} {101 101}
+do_test collate4-4.11 {
+ execsql {
+ SELECT max(a, '101') FROM collate4t1;
+ }
+} {11 101}
+do_test collate4-4.12 {
+ execsql {
+ SELECT max('101', a) FROM collate4t1;
+ }
+} {11 101}
+do_test collate4-4.13 {
+ execsql {
+ SELECT max(b, '101') FROM collate4t1;
+ }
+} {101 101}
+do_test collate4-4.14 {
+ execsql {
+ SELECT max('101', b) FROM collate4t1;
+ }
+} {101 101}
+
+do_test collate4-4.15 {
+ execsql {
+ DROP TABLE collate4t1;
+ }
+} {}
+
+#
+# These tests - collate4.6.* - ensure that implict INTEGER PRIMARY KEY
+# indices do not confuse collation sequences.
+#
+# These indices are never used for sorting in SQLite. And you can't
+# create another index on an INTEGER PRIMARY KEY column, so we don't have
+# to test that.
+# (Revised 2004-Nov-22): The ROWID can be used for sorting now.
+#
+do_test collate4-6.0 {
+ execsql {
+ CREATE TABLE collate4t1(a INTEGER PRIMARY KEY);
+ INSERT INTO collate4t1 VALUES(101);
+ INSERT INTO collate4t1 VALUES(10);
+ INSERT INTO collate4t1 VALUES(15);
+ }
+} {}
+do_test collate4-6.1 {
+ cksort {
+ SELECT * FROM collate4t1 ORDER BY 1;
+ }
+} {10 15 101 nosort}
+do_test collate4-6.2 {
+ cksort {
+ SELECT * FROM collate4t1 ORDER BY oid;
+ }
+} {10 15 101 nosort}
+do_test collate4-6.3 {
+ cksort {
+ SELECT * FROM collate4t1 ORDER BY oid||'' COLLATE TEXT;
+ }
+} {10 101 15 sort}
+
+finish_test
diff --git a/test/collate5.test b/test/collate5.test
new file mode 100644
index 0000000..e5bea7a
--- /dev/null
+++ b/test/collate5.test
@@ -0,0 +1,292 @@
+#
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing DISTINCT, UNION, INTERSECT and EXCEPT
+# SELECT statements that use user-defined collation sequences. Also
+# GROUP BY clauses that use user-defined collation sequences.
+#
+# $Id: collate5.test,v 1.7 2008/09/16 11:58:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+#
+# Tests are organised as follows:
+# collate5-1.* - DISTINCT
+# collate5-2.* - Compound SELECT
+# collate5-3.* - ORDER BY on compound SELECT
+# collate5-4.* - GROUP BY
+
+# Create the collation sequence 'TEXT', purely for asthetic reasons. The
+# test cases in this script could just as easily use BINARY.
+db collate TEXT [list string compare]
+
+# Mimic the SQLite 2 collation type NUMERIC.
+db collate numeric numeric_collate
+proc numeric_collate {lhs rhs} {
+ if {$lhs == $rhs} {return 0}
+ return [expr ($lhs>$rhs)?1:-1]
+}
+
+#
+# These tests - collate5-1.* - focus on the DISTINCT keyword.
+#
+do_test collate5-1.0 {
+ execsql {
+ CREATE TABLE collate5t1(a COLLATE nocase, b COLLATE text);
+
+ INSERT INTO collate5t1 VALUES('a', 'apple');
+ INSERT INTO collate5t1 VALUES('A', 'Apple');
+ INSERT INTO collate5t1 VALUES('b', 'banana');
+ INSERT INTO collate5t1 VALUES('B', 'banana');
+ INSERT INTO collate5t1 VALUES('n', NULL);
+ INSERT INTO collate5t1 VALUES('N', NULL);
+ }
+} {}
+do_test collate5-1.1 {
+ execsql {
+ SELECT DISTINCT a FROM collate5t1;
+ }
+} {a b n}
+do_test collate5-1.2 {
+ execsql {
+ SELECT DISTINCT b FROM collate5t1;
+ }
+} {apple Apple banana {}}
+do_test collate5-1.3 {
+ execsql {
+ SELECT DISTINCT a, b FROM collate5t1;
+ }
+} {a apple A Apple b banana n {}}
+
+# Ticket #3376
+#
+do_test collate5-1.11 {
+ execsql {
+ CREATE TABLE tkt3376(a COLLATE nocase PRIMARY KEY);
+ INSERT INTO tkt3376 VALUES('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz');
+ INSERT INTO tkt3376 VALUES('ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789');
+ SELECT DISTINCT a FROM tkt3376;
+ }
+} {abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789}
+do_test collate5-1.12 {
+ sqlite3 db2 :memory:
+ db2 eval {
+ PRAGMA encoding=UTF16le;
+ CREATE TABLE tkt3376(a COLLATE nocase PRIMARY KEY);
+ INSERT INTO tkt3376 VALUES('abc');
+ INSERT INTO tkt3376 VALUES('ABX');
+ SELECT DISTINCT a FROM tkt3376;
+ }
+} {abc ABX}
+catch {db2 close}
+
+# The remainder of this file tests compound SELECT statements.
+# Omit it if the library is compiled such that they are omitted.
+#
+ifcapable !compound {
+ finish_test
+ return
+}
+
+#
+# Tests named collate5-2.* focus on UNION, EXCEPT and INTERSECT
+# queries that use user-defined collation sequences.
+#
+# collate5-2.1.* - UNION
+# collate5-2.2.* - INTERSECT
+# collate5-2.3.* - EXCEPT
+#
+do_test collate5-2.0 {
+ execsql {
+ CREATE TABLE collate5t2(a COLLATE text, b COLLATE nocase);
+
+ INSERT INTO collate5t2 VALUES('a', 'apple');
+ INSERT INTO collate5t2 VALUES('A', 'apple');
+ INSERT INTO collate5t2 VALUES('b', 'banana');
+ INSERT INTO collate5t2 VALUES('B', 'Banana');
+ }
+} {}
+
+do_test collate5-2.1.1 {
+ execsql {
+ SELECT a FROM collate5t1 UNION select a FROM collate5t2;
+ }
+} {A B N}
+do_test collate5-2.1.2 {
+ execsql {
+ SELECT a FROM collate5t2 UNION select a FROM collate5t1;
+ }
+} {A B N a b n}
+do_test collate5-2.1.3 {
+ execsql {
+ SELECT a, b FROM collate5t1 UNION select a, b FROM collate5t2;
+ }
+} {A Apple A apple B Banana b banana N {}}
+do_test collate5-2.1.4 {
+ execsql {
+ SELECT a, b FROM collate5t2 UNION select a, b FROM collate5t1;
+ }
+} {A Apple B banana N {} a apple b banana n {}}
+
+do_test collate5-2.2.1 {
+ execsql {
+ SELECT a FROM collate5t1 EXCEPT select a FROM collate5t2;
+ }
+} {N}
+do_test collate5-2.2.2 {
+ execsql {
+ SELECT a FROM collate5t2 EXCEPT select a FROM collate5t1 WHERE a != 'a';
+ }
+} {A a}
+do_test collate5-2.2.3 {
+ execsql {
+ SELECT a, b FROM collate5t1 EXCEPT select a, b FROM collate5t2;
+ }
+} {A Apple N {}}
+do_test collate5-2.2.4 {
+ execsql {
+ SELECT a, b FROM collate5t2 EXCEPT select a, b FROM collate5t1
+ where a != 'a';
+ }
+} {A apple a apple}
+
+do_test collate5-2.3.1 {
+ execsql {
+ SELECT a FROM collate5t1 INTERSECT select a FROM collate5t2;
+ }
+} {A B}
+do_test collate5-2.3.2 {
+ execsql {
+ SELECT a FROM collate5t2 INTERSECT select a FROM collate5t1 WHERE a != 'a';
+ }
+} {B b}
+do_test collate5-2.3.3 {
+ execsql {
+ SELECT a, b FROM collate5t1 INTERSECT select a, b FROM collate5t2;
+ }
+} {a apple B banana}
+do_test collate5-2.3.4 {
+ execsql {
+ SELECT a, b FROM collate5t2 INTERSECT select a, b FROM collate5t1;
+ }
+} {A apple B Banana a apple b banana}
+
+#
+# This test ensures performs a UNION operation with a bunch of different
+# length records. The goal is to test that the logic that compares records
+# for the compound SELECT operators works with record lengths that lie
+# either side of the troublesome 256 and 65536 byte marks.
+#
+set ::lens [list \
+ 0 1 2 3 4 5 6 7 8 9 \
+ 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 \
+ 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 \
+ 65520 65521 65522 65523 65524 65525 65526 65527 65528 65529 65530 \
+ 65531 65532 65533 65534 65535 65536 65537 65538 65539 65540 65541 \
+ 65542 65543 65544 65545 65546 65547 65548 65549 65550 65551 ]
+do_test collate5-2.4.0 {
+ execsql {
+ BEGIN;
+ CREATE TABLE collate5t3(a, b);
+ }
+ foreach ii $::lens {
+ execsql "INSERT INTO collate5t3 VALUES($ii, '[string repeat a $ii]');"
+ }
+ expr [llength [execsql {
+ COMMIT;
+ SELECT * FROM collate5t3 UNION SELECT * FROM collate5t3;
+ }]] / 2
+} [llength $::lens]
+do_test collate5-2.4.1 {
+ execsql {DROP TABLE collate5t3;}
+} {}
+unset ::lens
+
+#
+# These tests - collate5-3.* - focus on compound SELECT queries that
+# feature ORDER BY clauses.
+#
+do_test collate5-3.0 {
+ execsql {
+ SELECT a FROM collate5t1 UNION ALL SELECT a FROM collate5t2 ORDER BY 1;
+ }
+} {a A a A b B b B n N}
+do_test collate5-3.1 {
+ execsql {
+ SELECT a FROM collate5t2 UNION ALL SELECT a FROM collate5t1 ORDER BY 1;
+ }
+} {A A B B N a a b b n}
+do_test collate5-3.2 {
+ execsql {
+ SELECT a FROM collate5t1 UNION ALL SELECT a FROM collate5t2
+ ORDER BY 1 COLLATE TEXT;
+ }
+} {A A B B N a a b b n}
+
+do_test collate5-3.3 {
+ execsql {
+ CREATE TABLE collate5t_cn(a COLLATE NUMERIC);
+ CREATE TABLE collate5t_ct(a COLLATE TEXT);
+ INSERT INTO collate5t_cn VALUES('1');
+ INSERT INTO collate5t_cn VALUES('11');
+ INSERT INTO collate5t_cn VALUES('101');
+ INSERT INTO collate5t_ct SELECT * FROM collate5t_cn;
+ }
+} {}
+do_test collate5-3.4 {
+ execsql {
+ SELECT a FROM collate5t_cn INTERSECT SELECT a FROM collate5t_ct ORDER BY 1;
+ }
+} {1 11 101}
+do_test collate5-3.5 {
+ execsql {
+ SELECT a FROM collate5t_ct INTERSECT SELECT a FROM collate5t_cn ORDER BY 1;
+ }
+} {1 101 11}
+
+do_test collate5-3.20 {
+ execsql {
+ DROP TABLE collate5t_cn;
+ DROP TABLE collate5t_ct;
+ DROP TABLE collate5t1;
+ DROP TABLE collate5t2;
+ }
+} {}
+
+do_test collate5-4.0 {
+ execsql {
+ CREATE TABLE collate5t1(a COLLATE NOCASE, b COLLATE NUMERIC);
+ INSERT INTO collate5t1 VALUES('a', '1');
+ INSERT INTO collate5t1 VALUES('A', '1.0');
+ INSERT INTO collate5t1 VALUES('b', '2');
+ INSERT INTO collate5t1 VALUES('B', '3');
+ }
+} {}
+do_test collate5-4.1 {
+ string tolower [execsql {
+ SELECT a, count(*) FROM collate5t1 GROUP BY a;
+ }]
+} {a 2 b 2}
+do_test collate5-4.2 {
+ execsql {
+ SELECT a, b, count(*) FROM collate5t1 GROUP BY a, b ORDER BY a, b;
+ }
+} {A 1.0 2 b 2 1 B 3 1}
+do_test collate5-4.3 {
+ execsql {
+ DROP TABLE collate5t1;
+ }
+} {}
+
+finish_test
diff --git a/test/collate6.test b/test/collate6.test
new file mode 100644
index 0000000..d238639
--- /dev/null
+++ b/test/collate6.test
@@ -0,0 +1,153 @@
+#
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is collation sequences in concert with triggers.
+#
+# $Id: collate6.test,v 1.4 2007/07/30 14:40:48 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# There are no tests in this file that will work without
+# trigger support.
+#
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# Create a case-insensitive collation type NOCASE for use in testing.
+# Normally, capital letters are less than their lower-case counterparts.
+db collate NOCASE nocase_collate
+proc nocase_collate {a b} {
+ return [string compare -nocase $a $b]
+}
+
+#
+# Tests are organized as follows:
+# collate6-1.* - triggers.
+#
+
+do_test collate6-1.0 {
+ execsql {
+ CREATE TABLE collate6log(a, b);
+ CREATE TABLE collate6tab(a COLLATE NOCASE, b COLLATE BINARY);
+ }
+} {}
+
+# Test that the default collation sequence applies to new.* references
+# in WHEN clauses.
+do_test collate6-1.1 {
+ execsql {
+ CREATE TRIGGER collate6trig BEFORE INSERT ON collate6tab
+ WHEN new.a = 'a' BEGIN
+ INSERT INTO collate6log VALUES(new.a, new.b);
+ END;
+ }
+} {}
+do_test collate6-1.2 {
+ execsql {
+ INSERT INTO collate6tab VALUES('a', 'b');
+ SELECT * FROM collate6log;
+ }
+} {a b}
+do_test collate6-1.3 {
+ execsql {
+ INSERT INTO collate6tab VALUES('A', 'B');
+ SELECT * FROM collate6log;
+ }
+} {a b A B}
+do_test collate6-1.4 {
+ execsql {
+ DROP TRIGGER collate6trig;
+ DELETE FROM collate6log;
+ }
+} {}
+
+# Test that the default collation sequence applies to new.* references
+# in the body of triggers.
+do_test collate6-1.5 {
+ execsql {
+ CREATE TRIGGER collate6trig BEFORE INSERT ON collate6tab BEGIN
+ INSERT INTO collate6log VALUES(new.a='a', new.b='b');
+ END;
+ }
+} {}
+do_test collate6-1.6 {
+ execsql {
+ INSERT INTO collate6tab VALUES('a', 'b');
+ SELECT * FROM collate6log;
+ }
+} {1 1}
+do_test collate6-1.7 {
+ execsql {
+ INSERT INTO collate6tab VALUES('A', 'B');
+ SELECT * FROM collate6log;
+ }
+} {1 1 1 0}
+do_test collate6-1.8 {
+ execsql {
+ DROP TRIGGER collate6trig;
+ DELETE FROM collate6log;
+ }
+} {}
+
+do_test collate6-1.9 {
+ execsql {
+ DROP TABLE collate6tab;
+ }
+} {}
+
+# Test that an explicit collation sequence overrides an implicit
+# one attached to a 'new' reference.
+#
+do_test collate6-2.1 {
+ execsql {
+ CREATE TABLE abc(a COLLATE binary, b, c);
+ CREATE TABLE def(a, b, c);
+ CREATE TRIGGER abc_t1 AFTER INSERT ON abc BEGIN
+ INSERT INTO def SELECT * FROM abc WHERE a < new.a COLLATE nocase;
+ END
+ }
+} {}
+do_test collate6-2.2 {
+ execsql {
+ INSERT INTO abc VALUES('One', 'Two', 'Three');
+ INSERT INTO abc VALUES('one', 'two', 'three');
+ SELECT * FROM def;
+ }
+} {}
+do_test collate6-2.3 {
+ execsql {
+ UPDATE abc SET a = 'four' WHERE a = 'one';
+ CREATE TRIGGER abc_t2 AFTER UPDATE ON abc BEGIN
+ INSERT INTO def SELECT * FROM abc WHERE a < new.a COLLATE nocase;
+ END;
+ SELECT * FROM def;
+ }
+} {}
+
+# At one point the 6-3.2 (but not 6-3.1) was causing an assert() to fail.
+#
+do_test collate6-3.1 {
+ execsql {
+ SELECT 1 FROM sqlite_master WHERE name COLLATE nocase = 'hello';
+ }
+} {}
+do_test collate6-3.2 {
+ execsql {
+ SELECT 1 FROM sqlite_master WHERE 'hello' = name COLLATE nocase;
+ }
+} {}
+
+
+finish_test
diff --git a/test/collate7.test b/test/collate7.test
new file mode 100644
index 0000000..da97491
--- /dev/null
+++ b/test/collate7.test
@@ -0,0 +1,72 @@
+#
+# 2007 May 7
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is the experimental sqlite3_create_collation_v2()
+# API.
+#
+# $Id: collate7.test,v 1.2 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set ::caseless_del 0
+proc caseless_cmp {zLeft zRight} {
+ string compare -nocase $zLeft $zRight
+}
+
+do_test collate7-1.1 {
+ set cmd [list incr ::caseless_del]
+ sqlite3_create_collation_v2 db CASELESS caseless_cmp $cmd
+ set ::caseless_del
+} {0}
+do_test collate7-1.2 {
+ sqlite_delete_collation db CASELESS
+ set ::caseless_del
+} {1}
+do_test collate7-1.3 {
+ catchsql {
+ CREATE TABLE abc(a COLLATE CASELESS, b, c);
+ }
+} {1 {no such collation sequence: CASELESS}}
+do_test collate7-1.4 {
+ sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del}
+ db close
+ set ::caseless_del
+} {2}
+
+do_test collate7-2.1 {
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del}
+ execsql {
+ PRAGMA encoding='utf-16';
+ CREATE TABLE abc16(a COLLATE CASELESS, b, c);
+ } db
+ set ::caseless_del
+} {2}
+do_test collate7-2.2 {
+ execsql {
+ SELECT * FROM abc16 WHERE a < 'abc';
+ }
+ set ::caseless_del
+} {2}
+do_test collate7-2.3 {
+ sqlite_delete_collation db CASELESS
+ set ::caseless_del
+} {3}
+do_test collate7-2.4 {
+ catchsql {
+ SELECT * FROM abc16 WHERE a < 'abc';
+ }
+} {1 {no such collation sequence: CASELESS}}
+
+finish_test
diff --git a/test/collate8.test b/test/collate8.test
new file mode 100644
index 0000000..60a8916
--- /dev/null
+++ b/test/collate8.test
@@ -0,0 +1,125 @@
+#
+# 2007 June 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is making sure collations pass through the
+# unary + operator.
+#
+# $Id: collate8.test,v 1.2 2008/08/25 12:14:09 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test collate8-1.1 {
+ execsql {
+ CREATE TABLE t1(a TEXT COLLATE nocase);
+ INSERT INTO t1 VALUES('aaa');
+ INSERT INTO t1 VALUES('BBB');
+ INSERT INTO t1 VALUES('ccc');
+ INSERT INTO t1 VALUES('DDD');
+ SELECT a FROM t1 ORDER BY a;
+ }
+} {aaa BBB ccc DDD}
+do_test collate8-1.2 {
+ execsql {
+ SELECT rowid FROM t1 WHERE a<'ccc' ORDER BY 1
+ }
+} {1 2}
+do_test collate8-1.3 {
+ execsql {
+ SELECT rowid FROM t1 WHERE a<'ccc' COLLATE binary ORDER BY 1
+ }
+} {1 2 4}
+do_test collate8-1.4 {
+ execsql {
+ SELECT rowid FROM t1 WHERE +a<'ccc' ORDER BY 1
+ }
+} {1 2}
+do_test collate8-1.5 {
+ execsql {
+ SELECT a FROM t1 ORDER BY +a
+ }
+} {aaa BBB ccc DDD}
+do_test collate8-1.11 {
+ execsql {
+ SELECT a AS x FROM t1 ORDER BY "x";
+ }
+} {aaa BBB ccc DDD}
+do_test collate8-1.12 {
+ execsql {
+ SELECT a AS x FROM t1 WHERE x<'ccc' ORDER BY 1
+ }
+} {aaa BBB}
+do_test collate8-1.13 {
+ execsql {
+ SELECT a AS x FROM t1 WHERE x<'ccc' COLLATE binary ORDER BY [x]
+ }
+} {aaa BBB DDD}
+do_test collate8-1.14 {
+ execsql {
+ SELECT a AS x FROM t1 WHERE +x<'ccc' ORDER BY 1
+ }
+} {aaa BBB}
+do_test collate8-1.15 {
+ execsql {
+ SELECT a AS x FROM t1 ORDER BY +x
+ }
+} {aaa BBB ccc DDD}
+
+
+# When a result-set column is aliased into a WHERE clause, make sure the
+# collating sequence logic works correctly.
+#
+do_test collate8-2.1 {
+ execsql {
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES('abc');
+ INSERT INTO t2 VALUES('ABC');
+ SELECT a AS x FROM t2 WHERE x='abc';
+ }
+} {abc}
+do_test collate8-2.2 {
+ execsql {
+ SELECT a AS x FROM t2 WHERE x='abc' COLLATE nocase;
+ }
+} {abc ABC}
+do_test collate8-2.3 {
+ execsql {
+ SELECT a AS x FROM t2 WHERE (x COLLATE nocase)='abc';
+ }
+} {abc ABC}
+do_test collate8-2.4 {
+ execsql {
+ SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc';
+ }
+} {abc ABC}
+do_test collate8-2.5 {
+ execsql {
+ SELECT a COLLATE nocase AS x FROM t2 WHERE (x COLLATE binary)='abc';
+ }
+} {abc}
+do_test collate8-2.6 {
+ execsql {
+ SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc' COLLATE binary;
+ }
+} {abc ABC}
+do_test collate8-2.7 {
+ execsql {
+ SELECT * FROM t2 WHERE (a COLLATE nocase)='abc' COLLATE binary;
+ }
+} {abc ABC}
+do_test collate8-2.8 {
+ execsql {
+ SELECT a COLLATE nocase AS x FROM t2 WHERE 'abc'=x COLLATE binary;
+ }
+} {abc}
+
+finish_test
diff --git a/test/collate9.test b/test/collate9.test
new file mode 100644
index 0000000..5a07773
--- /dev/null
+++ b/test/collate9.test
@@ -0,0 +1,178 @@
+#
+# 2007 November 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is making sure that the names of collation
+# sequences may be quoted using double quotes in SQL statements.
+#
+# $Id: collate9.test,v 1.2 2008/07/10 00:32:42 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc reverse_sort {lhs rhs} {
+ return [string compare $rhs $lhs]
+}
+db collate "reverse sort" reverse_sort
+
+# This procedure executes the SQL. Then it checks to see if the OP_Sort
+# opcode was executed. If an OP_Sort did occur, then "sort" is appended
+# to the result. If no OP_Sort happened, then "nosort" is appended.
+#
+# This procedure is used to check to make sure sorting is or is not
+# occurring as expected.
+#
+proc cksort {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ if {$::sqlite_sort_count} {set x sort} {set x nosort}
+ lappend data $x
+ return $data
+}
+
+# Test plan:
+#
+# collate9-1.* - Test collation sequences attached to table columns
+# collate9-2.* - Test collation sequences attached to expressions
+# collate9-3.* - Test collation sequences attached to an index
+# collate9-4.* - Test collation sequences as an argument to REINDEX
+#
+
+do_test collate9-1.1 {
+ execsql {
+ CREATE TABLE xy(x COLLATE "reverse sort", y COLLATE binary);
+ INSERT INTO xy VALUES('one', 'one');
+ INSERT INTO xy VALUES('two', 'two');
+ INSERT INTO xy VALUES('three', 'three');
+ }
+} {}
+do_test collate9-1.2 {
+ execsql {
+ SELECT x FROM xy ORDER BY x
+ }
+} {two three one}
+do_test collate9-1.3 {
+ execsql {
+ SELECT y FROM xy ORDER BY y
+ }
+} {one three two}
+do_test collate9-1.4 {
+ cksort {
+ SELECT x FROM xy ORDER BY x
+ }
+} {two three one sort}
+do_test collate9-1.5 {
+ execsql {
+ CREATE INDEX xy_i ON xy(x)
+ }
+} {}
+do_test collate9-1.6 {
+ cksort {
+ SELECT x FROM xy ORDER BY x
+ }
+} {two three one nosort}
+
+do_test collate9-2.1 {
+ execsql {
+ SELECT x, x < 'seven' FROM xy ORDER BY x
+ }
+} {two 1 three 1 one 0}
+do_test collate9-2.2 {
+ execsql {
+ SELECT y, y < 'seven' FROM xy ORDER BY x
+ }
+} {two 0 three 0 one 1}
+do_test collate9-2.3 {
+ execsql {
+ SELECT y, y COLLATE "reverse sort" < 'seven' FROM xy ORDER BY x
+ }
+} {two 1 three 1 one 0}
+do_test collate9-2.4 {
+ execsql {
+ SELECT y FROM xy ORDER BY y
+ }
+} {one three two}
+do_test collate9-2.5 {
+ execsql {
+ SELECT y FROM xy ORDER BY y COLLATE "reverse sort"
+ }
+} {two three one}
+do_test collate9-2.6 {
+ execsql {
+ SELECT y COLLATE "reverse sort" AS aaa FROM xy ORDER BY aaa
+ }
+} {two three one}
+
+do_test collate9-3.1 {
+ execsql {
+ CREATE INDEX xy_i2 ON xy(y COLLATE "reverse sort");
+ }
+} {}
+do_test collate9-3.2 {
+ cksort {
+ SELECT y FROM xy ORDER BY y
+ }
+} {one three two sort}
+do_test collate9-3.3 {
+ cksort {
+ SELECT y FROM xy ORDER BY y COLLATE "reverse sort"
+ }
+} {two three one nosort}
+do_test collate9-3.4 {
+ cksort {
+ SELECT y AS aaa FROM xy ORDER BY aaa
+ }
+} {one three two sort}
+do_test collate9-3.5 {
+ cksort {
+ SELECT y COLLATE "reverse sort" AS aaa FROM xy ORDER BY aaa
+ }
+} {two three one nosort}
+
+ifcapable reindex {
+ do_test collate9-4.1 {
+ execsql {
+ REINDEX "reverse sort"
+ }
+ } {}
+
+ # Modify the "reverse sort" collation so that it now sorts in the same
+ # order as binary.
+ proc reverse_sort {lhs rhs} {
+ return [string compare $lhs $rhs]
+ }
+
+ # The integrity check should now fail because the indexes created using
+ # "reverse sort" are no longer in sync with the collation sequence
+ # implementation.
+ do_test collate9-4.2 {
+ expr {"ok" eq [execsql { PRAGMA integrity_check }]}
+ } {0}
+
+ do_test collate9-4.3 {
+ execsql {
+ REINDEX "reverse sort"
+ }
+ } {}
+
+ # Integrity check should now pass.
+ do_test collate9-4.4 {
+ expr {"ok" eq [execsql { PRAGMA integrity_check }]}
+ } {1}
+
+ do_test collate9-4.5 {
+ cksort {
+ SELECT x FROM xy ORDER BY x COLLATE "reverse sort"
+ }
+ } {one three two nosort}
+}
+
+finish_test
diff --git a/test/collateA.test b/test/collateA.test
new file mode 100644
index 0000000..3f7ebd9
--- /dev/null
+++ b/test/collateA.test
@@ -0,0 +1,217 @@
+#
+# 2008 January 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is the built-in RTRIM collating
+# API.
+#
+# $Id: collateA.test,v 1.3 2008/04/15 04:02:41 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test collateA-1.1 {
+ execsql {
+ CREATE TABLE t1(
+ a INTEGER PRIMARY KEY,
+ b TEXT COLLATE BINARY,
+ c TEXT COLLATE RTRIM
+ );
+ INSERT INTO t1 VALUES(1, 'abcde','abcde');
+ INSERT INTO t1 VALUES(2, 'xyzzy ','xyzzy ');
+ INSERT INTO t1 VALUES(3, 'xyzzy ','xyzzy ');
+ INSERT INTO t1 VALUES(4, 'xyzzy ','xyzzy ');
+ INSERT INTO t1 VALUES(5, ' ', ' ');
+ INSERT INTO t1 VALUES(6, '', '');
+ SELECT count(*) FROM t1;
+ }
+} {6}
+do_test collateA-1.2 {
+ execsql {SELECT a FROM t1 WHERE b='abcde '}
+} {}
+do_test collateA-1.3 {
+ execsql {SELECT a FROM t1 WHERE c='abcde '}
+} {1}
+do_test collateA-1.4 {
+ execsql {SELECT a FROM t1 WHERE b='xyzzy'}
+} {}
+do_test collateA-1.5 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy'}
+} {2 3 4}
+do_test collateA-1.6 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-1.7 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-1.8 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-1.9 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-1.10 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-1.11 {
+ execsql {SELECT 'abc123'='abc123 ' COLLATE RTRIM;}
+} {1}
+do_test collateA-1.12 {
+ execsql {SELECT 'abc123 '='abc123' COLLATE RTRIM;}
+} {1}
+do_test collateA-1.13 {
+ execsql {SELECT ' '='' COLLATE RTRIM, ' '='' COLLATE BINARY, ' '=''}
+} {1 0 0}
+do_test collateA-1.14 {
+ execsql {SELECT ''=' ' COLLATE RTRIM, ''=' ' COLLATE BINARY, ''=' '}
+} {1 0 0}
+do_test collateA-1.15 {
+ execsql {SELECT ' '=' ' COLLATE RTRIM, ' '=' '}
+} {1 0}
+do_test collateA-1.16 {
+ execsql {SELECT ''<>' ' COLLATE RTRIM, ''<>' ' COLLATE BINARY, ''<>' '}
+} {0 1 1}
+do_test collateA-1.17 {
+ execsql {SELECT a FROM t1 WHERE c='xyzz'}
+} {}
+do_test collateA-1.18 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzyy '}
+} {}
+do_test collateA-1.19 {
+ execsql {SELECT a FROM t1 WHERE c='xyzz '}
+} {}
+do_test collateA-1.20 {
+ execsql {SELECT a FROM t1 WHERE c='abcd '}
+} {}
+do_test collateA-1.21 {
+ execsql {SELECT a FROM t1 WHERE c='abcd'}
+} {}
+do_test collateA-1.22 {
+ execsql {SELECT a FROM t1 WHERE c='abc'}
+} {}
+do_test collateA-1.23 {
+ execsql {SELECT a FROM t1 WHERE c='abcdef '}
+} {}
+do_test collateA-1.24 {
+ execsql {SELECT a FROM t1 WHERE c=''}
+} {5 6}
+do_test collateA-1.25 {
+ execsql {SELECT a FROM t1 WHERE c=' '}
+} {5 6}
+do_test collateA-1.26 {
+ execsql {SELECT a FROM t1 WHERE c=' '}
+} {5 6}
+
+
+do_test collateA-2.1 {
+ execsql {
+ CREATE INDEX i1b ON t1(b);
+ CREATE INDEX i1c ON t1(c);
+ PRAGMA integrity_check;
+ }
+} {ok}
+do_test collateA-2.2 {
+ execsql {SELECT a FROM t1 WHERE b='abcde '}
+} {}
+do_test collateA-2.3 {
+ execsql {SELECT a FROM t1 WHERE c='abcde '}
+} {1}
+do_test collateA-2.4 {
+ execsql {SELECT a FROM t1 WHERE b='xyzzy'}
+} {}
+do_test collateA-2.5 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy'}
+} {2 3 4}
+do_test collateA-2.6 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-2.7 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-2.8 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-2.9 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-2.10 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-2.17 {
+ execsql {SELECT a FROM t1 WHERE c='xyzz'}
+} {}
+do_test collateA-2.18 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzyy '}
+} {}
+do_test collateA-2.19 {
+ execsql {SELECT a FROM t1 WHERE c='xyzz '}
+} {}
+do_test collateA-2.20 {
+ execsql {SELECT a FROM t1 WHERE c='abcd '}
+} {}
+do_test collateA-2.21 {
+ execsql {SELECT a FROM t1 WHERE c='abcd'}
+} {}
+do_test collateA-2.22 {
+ execsql {SELECT a FROM t1 WHERE c='abc'}
+} {}
+do_test collateA-2.23 {
+ execsql {SELECT a FROM t1 WHERE c='abcdef '}
+} {}
+do_test collateA-2.24 {
+ execsql {SELECT a FROM t1 WHERE c=''}
+} {5 6}
+do_test collateA-2.25 {
+ execsql {SELECT a FROM t1 WHERE c=' '}
+} {5 6}
+do_test collateA-2.26 {
+ execsql {SELECT a FROM t1 WHERE c=' '}
+} {5 6}
+
+
+do_test collateA-3.1 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ REINDEX;
+ PRAGMA integrity_check;
+ }
+} {ok}
+do_test collateA-3.2 {
+ execsql {SELECT a FROM t1 WHERE b='abcde '}
+} {}
+do_test collateA-3.3 {
+ execsql {SELECT a FROM t1 WHERE c='abcde '}
+} {1}
+do_test collateA-3.4 {
+ execsql {SELECT a FROM t1 WHERE b='xyzzy'}
+} {}
+do_test collateA-3.5 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy'}
+} {2 3 4}
+do_test collateA-3.6 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-3.7 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-3.8 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-3.9 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+do_test collateA-3.10 {
+ execsql {SELECT a FROM t1 WHERE c='xyzzy '}
+} {2 3 4}
+
+
+finish_test
diff --git a/test/colmeta.test b/test/colmeta.test
new file mode 100644
index 0000000..3939f82
--- /dev/null
+++ b/test/colmeta.test
@@ -0,0 +1,94 @@
+#
+# 2006 February 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is the sqlite3_table_column_metadata() API.
+#
+# $Id: colmeta.test,v 1.4 2008/01/23 12:52:41 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !columnmetadata {
+ finish_test
+ return
+}
+
+# Set up a schema in the main and temp test databases.
+do_test colmeta-0 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ CREATE TABLE abc2(a PRIMARY KEY COLLATE NOCASE, b VARCHAR(32), c);
+ CREATE TABLE abc3(a NOT NULL, b INTEGER PRIMARY KEY, c);
+ }
+ ifcapable autoinc {
+ execsql {
+ CREATE TABLE abc4(a, b INTEGER PRIMARY KEY AUTOINCREMENT, c);
+ }
+ }
+ ifcapable view {
+ execsql {
+ CREATE VIEW v1 AS SELECT * FROM abc2;
+ }
+ }
+} {}
+
+
+# Return values are of the form:
+#
+# {<decl-type> <collation> <not null> <primary key> <auto increment>}
+#
+set tests {
+ 1 {main abc a} {0 {{} BINARY 0 0 0}}
+ 2 {{} abc a} {0 {{} BINARY 0 0 0}}
+ 3 {{} abc2 b} {0 {VARCHAR(32) BINARY 0 0 0}}
+ 4 {main abc2 b} {0 {VARCHAR(32) BINARY 0 0 0}}
+ 5 {{} abc2 a} {0 {{} NOCASE 0 1 0}}
+ 6 {{} abc3 a} {0 {{} BINARY 1 0 0}}
+ 7 {{} abc3 b} {0 {INTEGER BINARY 0 1 0}}
+ 13 {main abc rowid} {0 {INTEGER BINARY 0 1 0}}
+ 14 {main abc3 rowid} {0 {INTEGER BINARY 0 1 0}}
+ 16 {main abc d} {1 {no such table column: abc.d}}
+}
+ifcapable view {
+ set tests [concat $tests {
+ 8 {{} abc4 b} {0 {INTEGER BINARY 0 1 1}}
+ 15 {main abc4 rowid} {0 {INTEGER BINARY 0 1 1}}
+ }]
+}
+ifcapable view {
+ set tests [concat $tests {
+ 9 {{} v1 a} {1 {no such table column: v1.a}}
+ 10 {main v1 b} {1 {no such table column: v1.b}}
+ 11 {main v1 badname} {1 {no such table column: v1.badname}}
+ 12 {main v1 rowid} {1 {no such table column: v1.rowid}}
+ }]
+}
+
+foreach {tn params results} $tests {
+ set ::DB [sqlite3_connection_pointer db]
+
+ set tstbody [concat sqlite3_table_column_metadata $::DB $params]
+ do_test colmeta-$tn.1 {
+ list [catch $tstbody msg] [set msg]
+ } $results
+
+ db close
+ sqlite3 db test.db
+
+ set ::DB [sqlite3_connection_pointer db]
+ set tstbody [concat sqlite3_table_column_metadata $::DB $params]
+ do_test colmeta-$tn.2 {
+ list [catch $tstbody msg] [set msg]
+ } $results
+}
+
+finish_test
diff --git a/test/colname.test b/test/colname.test
new file mode 100644
index 0000000..e16304d
--- /dev/null
+++ b/test/colname.test
@@ -0,0 +1,329 @@
+# 2008 July 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# The focus of this file is testing how SQLite generates the names
+# of columns in a result set.
+#
+# $Id: colname.test,v 1.7 2009/06/02 15:47:38 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Rules (applied in order):
+#
+# (1) If there is an AS clause, use it.
+#
+# (2) A non-trival expression (not a table column name) then the name is
+# a copy of the expression text.
+#
+# (3) If short_column_names=ON, then just the abbreviated column name without
+# the table name.
+#
+# (4) When short_column_names=OFF and full_column_names=OFF then
+# use case (2) for simple queries and case (5) for joins.
+#
+# (5) When short_column_names=OFF and full_column_names=ON then
+# use the form: TABLE.COLUMN
+#
+
+
+# Verify the default settings for short_column_name and full_column_name
+#
+do_test colname-1.1 {
+ db eval {PRAGMA short_column_names}
+} {1}
+do_test colname-1.2 {
+ db eval {PRAGMA full_column_names}
+} {0}
+
+# Tests for then short=ON and full=any
+#
+do_test colname-2.1 {
+ db eval {
+ CREATE TABLE tabc(a,b,c);
+ INSERT INTO tabc VALUES(1,2,3);
+ CREATE TABLE txyz(x,y,z);
+ INSERT INTO txyz VALUES(4,5,6);
+ CREATE TABLE tboth(a,b,c,x,y,z);
+ INSERT INTO tboth VALUES(11,12,13,14,15,16);
+ CREATE VIEW v1 AS SELECT tabC.a, txyZ.x, *
+ FROM tabc, txyz ORDER BY 1 LIMIT 1;
+ CREATE VIEW v2 AS SELECT tabC.a, txyZ.x, tboTh.a, tbotH.x, *
+ FROM tabc, txyz, tboth ORDER BY 1 LIMIT 1;
+ }
+ execsql2 {
+ SELECT * FROM tabc;
+ }
+} {a 1 b 2 c 3}
+do_test colname-2.2 {
+ execsql2 {
+ SELECT Tabc.a, tAbc.b, taBc.c, * FROM tabc
+ }
+} {a 1 b 2 c 3 a 1 b 2 c 3}
+do_test colname-2.3 {
+ execsql2 {
+ SELECT +tabc.a, -tabc.b, tabc.c, * FROM tabc
+ }
+} {+tabc.a 1 -tabc.b -2 c 3 a 1 b 2 c 3}
+do_test colname-2.4 {
+ execsql2 {
+ SELECT +tabc.a AS AAA, -tabc.b AS BBB, tabc.c CCC, * FROM tabc
+ }
+} {AAA 1 BBB -2 CCC 3 a 1 b 2 c 3}
+do_test colname-2.5 {
+ execsql2 {
+ SELECT tabc.a, txyz.x, * FROM tabc, txyz;
+ }
+} {a 1 x 4 a 1 b 2 c 3 x 4 y 5 z 6}
+do_test colname-2.6 {
+ execsql2 {
+ SELECT tabc.a, txyz.x, tabc.*, txyz.* FROM tabc, txyz;
+ }
+} {a 1 x 4 a 1 b 2 c 3 x 4 y 5 z 6}
+do_test colname-2.7 {
+ execsql2 {
+ SELECT tabc.a, txyz.x, tboth.a, tboth.x, * FROM tabc, txyz, tboth;
+ }
+} {a 11 x 14 a 11 x 14 a 11 b 12 c 13 x 14 y 15 z 16 a 11 b 12 c 13 x 14 y 15 z 16}
+do_test colname-2.8 {
+ execsql2 {
+ SELECT * FROM v1 ORDER BY 2;
+ }
+} {a 1 x 4 a:1 1 b 2 c 3 x:1 4 y 5 z 6}
+do_test colname-2.9 {
+ execsql2 {
+ SELECT * FROM v2 ORDER BY 2;
+ }
+} {a 1 x 4 a:1 11 x:1 14 a:2 1 b 2 c 3 x:2 4 y 5 z 6 a:3 11 b:1 12 c:1 13 x:3 14 y:1 15 z:1 16}
+
+
+# Tests for short=OFF and full=OFF
+#
+do_test colname-3.1 {
+ db eval {
+ PRAGMA short_column_names=OFF;
+ PRAGMA full_column_names=OFF;
+ CREATE VIEW v3 AS SELECT tabC.a, txyZ.x, *
+ FROM tabc, txyz ORDER BY 1 LIMIT 1;
+ CREATE VIEW v4 AS SELECT tabC.a, txyZ.x, tboTh.a, tbotH.x, *
+ FROM tabc, txyz, tboth ORDER BY 1 LIMIT 1;
+ }
+ execsql2 {
+ SELECT * FROM tabc;
+ }
+} {a 1 b 2 c 3}
+do_test colname-3.2 {
+ execsql2 {
+ SELECT Tabc.a, tAbc.b, taBc.c FROM tabc
+ }
+} {Tabc.a 1 tAbc.b 2 taBc.c 3}
+do_test colname-3.3 {
+ execsql2 {
+ SELECT +tabc.a, -tabc.b, tabc.c FROM tabc
+ }
+} {+tabc.a 1 -tabc.b -2 tabc.c 3}
+do_test colname-3.4 {
+ execsql2 {
+ SELECT +tabc.a AS AAA, -tabc.b AS BBB, tabc.c CCC FROM tabc
+ }
+} {AAA 1 BBB -2 CCC 3}
+do_test colname-3.5 {
+ execsql2 {
+ SELECT Tabc.a, Txyz.x, * FROM tabc, txyz;
+ }
+} {Tabc.a 1 Txyz.x 4 a 1 b 2 c 3 x 4 y 5 z 6}
+do_test colname-3.6 {
+ execsql2 {
+ SELECT tabc.*, txyz.* FROM tabc, txyz;
+ }
+} {a 1 b 2 c 3 x 4 y 5 z 6}
+do_test colname-3.7 {
+ execsql2 {
+ SELECT * FROM tabc, txyz, tboth;
+ }
+} {a 11 b 12 c 13 x 14 y 15 z 16 a 11 b 12 c 13 x 14 y 15 z 16}
+do_test colname-3.8 {
+ execsql2 {
+ SELECT v1.a, * FROM v1 ORDER BY 2;
+ }
+} {v1.a 1 a 1 x 4 a:1 1 b 2 c 3 x:1 4 y 5 z 6}
+do_test colname-3.9 {
+ execsql2 {
+ SELECT * FROM v2 ORDER BY 2;
+ }
+} {a 1 x 4 a:1 11 x:1 14 a:2 1 b 2 c 3 x:2 4 y 5 z 6 a:3 11 b:1 12 c:1 13 x:3 14 y:1 15 z:1 16}
+do_test colname-3.10 {
+ execsql2 {
+ SELECT * FROM v3 ORDER BY 2;
+ }
+} {a 1 x 4 a:1 1 b 2 c 3 x:1 4 y 5 z 6}
+do_test colname-3.11 {
+ execsql2 {
+ SELECT * FROM v4 ORDER BY 2;
+ }
+} {a 1 x 4 a:1 11 x:1 14 a:2 1 b 2 c 3 x:2 4 y 5 z 6 a:3 11 b:1 12 c:1 13 x:3 14 y:1 15 z:1 16}
+
+# Test for short=OFF and full=ON
+#
+do_test colname-4.1 {
+ db eval {
+ PRAGMA short_column_names=OFF;
+ PRAGMA full_column_names=ON;
+ CREATE VIEW v5 AS SELECT tabC.a, txyZ.x, *
+ FROM tabc, txyz ORDER BY 1 LIMIT 1;
+ CREATE VIEW v6 AS SELECT tabC.a, txyZ.x, tboTh.a, tbotH.x, *
+ FROM tabc, txyz, tboth ORDER BY 1 LIMIT 1;
+ }
+ execsql2 {
+ SELECT * FROM tabc;
+ }
+} {tabc.a 1 tabc.b 2 tabc.c 3}
+do_test colname-4.2 {
+ execsql2 {
+ SELECT Tabc.a, tAbc.b, taBc.c FROM tabc
+ }
+} {tabc.a 1 tabc.b 2 tabc.c 3}
+do_test colname-4.3 {
+ execsql2 {
+ SELECT +tabc.a, -tabc.b, tabc.c FROM tabc
+ }
+} {+tabc.a 1 -tabc.b -2 tabc.c 3}
+do_test colname-4.4 {
+ execsql2 {
+ SELECT +tabc.a AS AAA, -tabc.b AS BBB, tabc.c CCC FROM tabc
+ }
+} {AAA 1 BBB -2 CCC 3}
+do_test colname-4.5 {
+ execsql2 {
+ SELECT Tabc.a, Txyz.x, * FROM tabc, txyz;
+ }
+} {tabc.a 1 txyz.x 4 tabc.a 1 tabc.b 2 tabc.c 3 txyz.x 4 txyz.y 5 txyz.z 6}
+do_test colname-4.6 {
+ execsql2 {
+ SELECT tabc.*, txyz.* FROM tabc, txyz;
+ }
+} {tabc.a 1 tabc.b 2 tabc.c 3 txyz.x 4 txyz.y 5 txyz.z 6}
+do_test colname-4.7 {
+ execsql2 {
+ SELECT * FROM tabc, txyz, tboth;
+ }
+} {tabc.a 1 tabc.b 2 tabc.c 3 txyz.x 4 txyz.y 5 txyz.z 6 tboth.a 11 tboth.b 12 tboth.c 13 tboth.x 14 tboth.y 15 tboth.z 16}
+do_test colname-4.8 {
+ execsql2 {
+ SELECT * FROM v1 ORDER BY 2;
+ }
+} {v1.a 1 v1.x 4 v1.a:1 1 v1.b 2 v1.c 3 v1.x:1 4 v1.y 5 v1.z 6}
+do_test colname-4.9 {
+ execsql2 {
+ SELECT * FROM v2 ORDER BY 2;
+ }
+} {v2.a 1 v2.x 4 v2.a:1 11 v2.x:1 14 v2.a:2 1 v2.b 2 v2.c 3 v2.x:2 4 v2.y 5 v2.z 6 v2.a:3 11 v2.b:1 12 v2.c:1 13 v2.x:3 14 v2.y:1 15 v2.z:1 16}
+do_test colname-4.10 {
+ execsql2 {
+ SELECT * FROM v3 ORDER BY 2;
+ }
+} {v3.a 1 v3.x 4 v3.a:1 1 v3.b 2 v3.c 3 v3.x:1 4 v3.y 5 v3.z 6}
+do_test colname-4.11 {
+ execsql2 {
+ SELECT * FROM v4 ORDER BY 2;
+ }
+} {v4.a 1 v4.x 4 v4.a:1 11 v4.x:1 14 v4.a:2 1 v4.b 2 v4.c 3 v4.x:2 4 v4.y 5 v4.z 6 v4.a:3 11 v4.b:1 12 v4.c:1 13 v4.x:3 14 v4.y:1 15 v4.z:1 16}
+do_test colname-4.12 {
+ execsql2 {
+ SELECT * FROM v5 ORDER BY 2;
+ }
+} {v5.a 1 v5.x 4 v5.a:1 1 v5.b 2 v5.c 3 v5.x:1 4 v5.y 5 v5.z 6}
+do_test colname-4.13 {
+ execsql2 {
+ SELECT * FROM v6 ORDER BY 2;
+ }
+} {v6.a 1 v6.x 4 v6.a:1 11 v6.x:1 14 v6.a:2 1 v6.b 2 v6.c 3 v6.x:2 4 v6.y 5 v6.z 6 v6.a:3 11 v6.b:1 12 v6.c:1 13 v6.x:3 14 v6.y:1 15 v6.z:1 16}
+
+# ticket #3229
+do_test colname-5.1 {
+ lreplace [db eval {
+ SELECT x.* FROM sqlite_master X LIMIT 1;
+ }] 3 3 x
+} {table tabc tabc x {CREATE TABLE tabc(a,b,c)}}
+
+# ticket #3370, #3371, #3372
+#
+do_test colname-6.1 {
+ db close
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t6(a, ['a'], ["a"], "[a]", [`a`]);
+ INSERT INTO t6 VALUES(1,2,3,4,5);
+ }
+ execsql2 {SELECT * FROM t6}
+} {a 1 'a' 2 {"a"} 3 {[a]} 4 `a` 5}
+do_test colname-6.2 {
+ execsql2 {SELECT ['a'], [`a`], "[a]", [a], ["a"] FROM t6}
+} {'a' 2 `a` 5 {[a]} 4 a 1 {"a"} 3}
+do_test colname-6.3 {
+ execsql2 {SELECT "'a'", "`a`", "[a]", "a", """a""" FROM t6}
+} {'a' 2 `a` 5 {[a]} 4 a 1 {"a"} 3}
+do_test colname-6.4 {
+ execsql2 {SELECT `'a'`, ```a```, `[a]`, `a`, `"a"` FROM t6}
+} {'a' 2 `a` 5 {[a]} 4 a 1 {"a"} 3}
+do_test colname-6.11 {
+ execsql2 {SELECT a, max(a) AS m FROM t6}
+} {a 1 m 1}
+do_test colname-6.12 {
+ execsql2 {SELECT `a`, max(a) AS m FROM t6}
+} {a 1 m 1}
+do_test colname-6.13 {
+ execsql2 {SELECT "a", max(a) AS m FROM t6}
+} {a 1 m 1}
+do_test colname-6.14 {
+ execsql2 {SELECT [a], max(a) AS m FROM t6}
+} {a 1 m 1}
+do_test colname-6.15 {
+ execsql2 {SELECT t6.a, max(a) AS m FROM t6}
+} {a 1 m 1}
+do_test colname-6.16 {
+ execsql2 {SELECT ['a'], max(['a']) AS m FROM t6}
+} {'a' 2 m 2}
+do_test colname-6.17 {
+ execsql2 {SELECT ["a"], max(["a"]) AS m FROM t6}
+} {{"a"} 3 m 3}
+do_test colname-6.18 {
+ execsql2 {SELECT "[a]", max("[a]") AS m FROM t6}
+} {{[a]} 4 m 4}
+do_test colname-6.19 {
+ execsql2 {SELECT "`a`", max([`a`]) AS m FROM t6}
+} {`a` 5 m 5}
+
+
+# Ticket #3429
+# We cannot find anything wrong, but it never hurts to add another
+# test case.
+#
+do_test colname-7.1 {
+ db eval {
+ CREATE TABLE t7(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t7 VALUES(1,2);
+ }
+ execsql2 {SELECT rowid, * FROM t7}
+} {x 1 x 1 y 2}
+
+# Tickets #3893 and #3984. (Same problem; independently reported)
+#
+do_test colname-8.1 {
+ db eval {
+ CREATE TABLE "t3893"("x");
+ INSERT INTO t3893 VALUES(123);
+ SELECT "y"."x" FROM (SELECT "x" FROM "t3893") AS "y";
+ }
+} {123}
+
+finish_test
diff --git a/test/conflict.test b/test/conflict.test
new file mode 100644
index 0000000..17c7263
--- /dev/null
+++ b/test/conflict.test
@@ -0,0 +1,814 @@
+# 2002 January 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the conflict resolution extension
+# to SQLite.
+#
+# $Id: conflict.test,v 1.32 2009/04/30 09:10:38 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !conflict {
+ finish_test
+ return
+}
+
+# Create tables for the first group of tests.
+#
+do_test conflict-1.0 {
+ execsql {
+ CREATE TABLE t1(a, b, c, UNIQUE(a,b));
+ CREATE TABLE t2(x);
+ SELECT c FROM t1 ORDER BY c;
+ }
+} {}
+
+# Six columns of configuration data as follows:
+#
+# i The reference number of the test
+# cmd An INSERT or REPLACE command to execute against table t1
+# t0 True if there is an error from $cmd
+# t1 Content of "c" column of t1 assuming no error in $cmd
+# t2 Content of "x" column of t2
+# t3 Number of temporary files created by this test
+#
+foreach {i cmd t0 t1 t2 t3} {
+ 1 INSERT 1 {} 1 0
+ 2 {INSERT OR IGNORE} 0 3 1 0
+ 3 {INSERT OR REPLACE} 0 4 1 0
+ 4 REPLACE 0 4 1 0
+ 5 {INSERT OR FAIL} 1 {} 1 0
+ 6 {INSERT OR ABORT} 1 {} 1 0
+ 7 {INSERT OR ROLLBACK} 1 {} {} 0
+} {
+ do_test conflict-1.$i {
+ set ::sqlite_opentemp_count 0
+ set r0 [catch {execsql [subst {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN;
+ INSERT INTO t2 VALUES(1);
+ $cmd INTO t1 VALUES(1,2,4);
+ }]} r1]
+ catch {execsql {COMMIT}}
+ if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
+ set r2 [execsql {SELECT x FROM t2}]
+ set r3 $::sqlite_opentemp_count
+ list $r0 $r1 $r2 $r3
+ } [list $t0 $t1 $t2 $t3]
+}
+
+# Create tables for the first group of tests.
+#
+do_test conflict-2.0 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(a,b));
+ CREATE TABLE t2(x);
+ SELECT c FROM t1 ORDER BY c;
+ }
+} {}
+
+# Six columns of configuration data as follows:
+#
+# i The reference number of the test
+# cmd An INSERT or REPLACE command to execute against table t1
+# t0 True if there is an error from $cmd
+# t1 Content of "c" column of t1 assuming no error in $cmd
+# t2 Content of "x" column of t2
+#
+foreach {i cmd t0 t1 t2} {
+ 1 INSERT 1 {} 1
+ 2 {INSERT OR IGNORE} 0 3 1
+ 3 {INSERT OR REPLACE} 0 4 1
+ 4 REPLACE 0 4 1
+ 5 {INSERT OR FAIL} 1 {} 1
+ 6 {INSERT OR ABORT} 1 {} 1
+ 7 {INSERT OR ROLLBACK} 1 {} {}
+} {
+ do_test conflict-2.$i {
+ set r0 [catch {execsql [subst {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN;
+ INSERT INTO t2 VALUES(1);
+ $cmd INTO t1 VALUES(1,2,4);
+ }]} r1]
+ catch {execsql {COMMIT}}
+ if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
+ set r2 [execsql {SELECT x FROM t2}]
+ list $r0 $r1 $r2
+ } [list $t0 $t1 $t2]
+}
+
+# Create tables for the first group of tests.
+#
+do_test conflict-3.0 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(a, b, c INTEGER, PRIMARY KEY(c), UNIQUE(a,b));
+ CREATE TABLE t2(x);
+ SELECT c FROM t1 ORDER BY c;
+ }
+} {}
+
+# Six columns of configuration data as follows:
+#
+# i The reference number of the test
+# cmd An INSERT or REPLACE command to execute against table t1
+# t0 True if there is an error from $cmd
+# t1 Content of "c" column of t1 assuming no error in $cmd
+# t2 Content of "x" column of t2
+#
+foreach {i cmd t0 t1 t2} {
+ 1 INSERT 1 {} 1
+ 2 {INSERT OR IGNORE} 0 3 1
+ 3 {INSERT OR REPLACE} 0 4 1
+ 4 REPLACE 0 4 1
+ 5 {INSERT OR FAIL} 1 {} 1
+ 6 {INSERT OR ABORT} 1 {} 1
+ 7 {INSERT OR ROLLBACK} 1 {} {}
+} {
+ do_test conflict-3.$i {
+ set r0 [catch {execsql [subst {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN;
+ INSERT INTO t2 VALUES(1);
+ $cmd INTO t1 VALUES(1,2,4);
+ }]} r1]
+ catch {execsql {COMMIT}}
+ if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
+ set r2 [execsql {SELECT x FROM t2}]
+ list $r0 $r1 $r2
+ } [list $t0 $t1 $t2]
+}
+
+do_test conflict-4.0 {
+ execsql {
+ DROP TABLE t2;
+ CREATE TABLE t2(x);
+ SELECT x FROM t2;
+ }
+} {}
+
+# Six columns of configuration data as follows:
+#
+# i The reference number of the test
+# conf1 The conflict resolution algorithm on the UNIQUE constraint
+# cmd An INSERT or REPLACE command to execute against table t1
+# t0 True if there is an error from $cmd
+# t1 Content of "c" column of t1 assuming no error in $cmd
+# t2 Content of "x" column of t2
+#
+foreach {i conf1 cmd t0 t1 t2} {
+ 1 {} INSERT 1 {} 1
+ 2 REPLACE INSERT 0 4 1
+ 3 IGNORE INSERT 0 3 1
+ 4 FAIL INSERT 1 {} 1
+ 5 ABORT INSERT 1 {} 1
+ 6 ROLLBACK INSERT 1 {} {}
+ 7 REPLACE {INSERT OR IGNORE} 0 3 1
+ 8 IGNORE {INSERT OR REPLACE} 0 4 1
+ 9 FAIL {INSERT OR IGNORE} 0 3 1
+ 10 ABORT {INSERT OR REPLACE} 0 4 1
+ 11 ROLLBACK {INSERT OR IGNORE } 0 3 1
+} {
+ do_test conflict-4.$i {
+ if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
+ set r0 [catch {execsql [subst {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,UNIQUE(a,b) $conf1);
+ DELETE FROM t2;
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN;
+ INSERT INTO t2 VALUES(1);
+ $cmd INTO t1 VALUES(1,2,4);
+ }]} r1]
+ catch {execsql {COMMIT}}
+ if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
+ set r2 [execsql {SELECT x FROM t2}]
+ list $r0 $r1 $r2
+ } [list $t0 $t1 $t2]
+}
+
+do_test conflict-5.0 {
+ execsql {
+ DROP TABLE t2;
+ CREATE TABLE t2(x);
+ SELECT x FROM t2;
+ }
+} {}
+
+# Six columns of configuration data as follows:
+#
+# i The reference number of the test
+# conf1 The conflict resolution algorithm on the NOT NULL constraint
+# cmd An INSERT or REPLACE command to execute against table t1
+# t0 True if there is an error from $cmd
+# t1 Content of "c" column of t1 assuming no error in $cmd
+# t2 Content of "x" column of t2
+#
+foreach {i conf1 cmd t0 t1 t2} {
+ 1 {} INSERT 1 {} 1
+ 2 REPLACE INSERT 0 5 1
+ 3 IGNORE INSERT 0 {} 1
+ 4 FAIL INSERT 1 {} 1
+ 5 ABORT INSERT 1 {} 1
+ 6 ROLLBACK INSERT 1 {} {}
+ 7 REPLACE {INSERT OR IGNORE} 0 {} 1
+ 8 IGNORE {INSERT OR REPLACE} 0 5 1
+ 9 FAIL {INSERT OR IGNORE} 0 {} 1
+ 10 ABORT {INSERT OR REPLACE} 0 5 1
+ 11 ROLLBACK {INSERT OR IGNORE} 0 {} 1
+ 12 {} {INSERT OR IGNORE} 0 {} 1
+ 13 {} {INSERT OR REPLACE} 0 5 1
+ 14 {} {INSERT OR FAIL} 1 {} 1
+ 15 {} {INSERT OR ABORT} 1 {} 1
+ 16 {} {INSERT OR ROLLBACK} 1 {} {}
+} {
+ if {$t0} {set t1 {t1.c may not be NULL}}
+ do_test conflict-5.$i {
+ if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
+ set r0 [catch {execsql [subst {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5);
+ DELETE FROM t2;
+ BEGIN;
+ INSERT INTO t2 VALUES(1);
+ $cmd INTO t1 VALUES(1,2,NULL);
+ }]} r1]
+ catch {execsql {COMMIT}}
+ if {!$r0} {set r1 [execsql {SELECT c FROM t1}]}
+ set r2 [execsql {SELECT x FROM t2}]
+ list $r0 $r1 $r2
+ } [list $t0 $t1 $t2]
+}
+
+do_test conflict-6.0 {
+ execsql {
+ DROP TABLE t2;
+ CREATE TABLE t2(a,b,c);
+ INSERT INTO t2 VALUES(1,2,1);
+ INSERT INTO t2 VALUES(2,3,2);
+ INSERT INTO t2 VALUES(3,4,1);
+ INSERT INTO t2 VALUES(4,5,4);
+ SELECT c FROM t2 ORDER BY b;
+ CREATE TABLE t3(x);
+ INSERT INTO t3 VALUES(1);
+ }
+} {1 2 1 4}
+
+# Six columns of configuration data as follows:
+#
+# i The reference number of the test
+# conf1 The conflict resolution algorithm on the UNIQUE constraint
+# cmd An UPDATE command to execute against table t1
+# t0 True if there is an error from $cmd
+# t1 Content of "b" column of t1 assuming no error in $cmd
+# t2 Content of "x" column of t3
+# t3 Number of temporary files for tables
+# t4 Number of temporary files for statement journals
+#
+# Update: Since temporary table files are now opened lazily, and none
+# of the following tests use large quantities of data, t3 is always 0.
+#
+foreach {i conf1 cmd t0 t1 t2 t3 t4} {
+ 1 {} UPDATE 1 {6 7 8 9} 1 0 1
+ 2 REPLACE UPDATE 0 {7 6 9} 1 0 0
+ 3 IGNORE UPDATE 0 {6 7 3 9} 1 0 0
+ 4 FAIL UPDATE 1 {6 7 3 4} 1 0 0
+ 5 ABORT UPDATE 1 {1 2 3 4} 1 0 1
+ 6 ROLLBACK UPDATE 1 {1 2 3 4} 0 0 0
+ 7 REPLACE {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0
+ 8 IGNORE {UPDATE OR REPLACE} 0 {7 6 9} 1 0 0
+ 9 FAIL {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0
+ 10 ABORT {UPDATE OR REPLACE} 0 {7 6 9} 1 0 0
+ 11 ROLLBACK {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0
+ 12 {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0
+ 13 {} {UPDATE OR REPLACE} 0 {7 6 9} 1 0 0
+ 14 {} {UPDATE OR FAIL} 1 {6 7 3 4} 1 0 0
+ 15 {} {UPDATE OR ABORT} 1 {1 2 3 4} 1 0 1
+ 16 {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0 0 0
+} {
+ if {$t0} {set t1 {column a is not unique}}
+ if {[info exists TEMP_STORE] && $TEMP_STORE==3} {
+ set t3 0
+ } else {
+ set t3 [expr {$t3+$t4}]
+ }
+ do_test conflict-6.$i {
+ db close
+ sqlite3 db test.db
+ if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
+ execsql {pragma temp_store=file}
+ set ::sqlite_opentemp_count 0
+ set r0 [catch {execsql [subst {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1);
+ INSERT INTO t1 SELECT * FROM t2;
+ UPDATE t3 SET x=0;
+ BEGIN;
+ $cmd t3 SET x=1;
+ $cmd t1 SET b=b*2;
+ $cmd t1 SET a=c+5;
+ }]} r1]
+ catch {execsql {COMMIT}}
+ if {!$r0} {set r1 [execsql {SELECT a FROM t1 ORDER BY b}]}
+ set r2 [execsql {SELECT x FROM t3}]
+ list $r0 $r1 $r2 $::sqlite_opentemp_count
+ } [list $t0 $t1 $t2 $t3]
+}
+
+# Test to make sure a lot of IGNOREs don't cause a stack overflow
+#
+do_test conflict-7.1 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ DROP TABLE t3;
+ CREATE TABLE t1(a unique, b);
+ }
+ for {set i 1} {$i<=50} {incr i} {
+ execsql "INSERT into t1 values($i,[expr {$i+1}]);"
+ }
+ execsql {
+ SELECT count(*), min(a), max(b) FROM t1;
+ }
+} {50 1 51}
+do_test conflict-7.2 {
+ execsql {
+ PRAGMA count_changes=on;
+ UPDATE OR IGNORE t1 SET a=1000;
+ }
+} {1}
+do_test conflict-7.2.1 {
+ db changes
+} {1}
+do_test conflict-7.3 {
+ execsql {
+ SELECT b FROM t1 WHERE a=1000;
+ }
+} {2}
+do_test conflict-7.4 {
+ execsql {
+ SELECT count(*) FROM t1;
+ }
+} {50}
+do_test conflict-7.5 {
+ execsql {
+ PRAGMA count_changes=on;
+ UPDATE OR REPLACE t1 SET a=1001;
+ }
+} {50}
+do_test conflict-7.5.1 {
+ db changes
+} {50}
+do_test conflict-7.6 {
+ execsql {
+ SELECT b FROM t1 WHERE a=1001;
+ }
+} {51}
+do_test conflict-7.7 {
+ execsql {
+ SELECT count(*) FROM t1;
+ }
+} {1}
+
+# Update for version 3: A SELECT statement no longer resets the change
+# counter (Test result changes from 0 to 50).
+do_test conflict-7.7.1 {
+ db changes
+} {50}
+
+# Make sure the row count is right for rows that are ignored on
+# an insert.
+#
+do_test conflict-8.1 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2);
+ }
+ execsql {
+ INSERT OR IGNORE INTO t1 VALUES(2,3);
+ }
+} {1}
+do_test conflict-8.1.1 {
+ db changes
+} {1}
+do_test conflict-8.2 {
+ execsql {
+ INSERT OR IGNORE INTO t1 VALUES(2,4);
+ }
+} {0}
+do_test conflict-8.2.1 {
+ db changes
+} {0}
+do_test conflict-8.3 {
+ execsql {
+ INSERT OR REPLACE INTO t1 VALUES(2,4);
+ }
+} {1}
+do_test conflict-8.3.1 {
+ db changes
+} {1}
+do_test conflict-8.4 {
+ execsql {
+ INSERT OR IGNORE INTO t1 SELECT * FROM t1;
+ }
+} {0}
+do_test conflict-8.4.1 {
+ db changes
+} {0}
+do_test conflict-8.5 {
+ execsql {
+ INSERT OR IGNORE INTO t1 SELECT a+2,b+2 FROM t1;
+ }
+} {2}
+do_test conflict-8.5.1 {
+ db changes
+} {2}
+do_test conflict-8.6 {
+ execsql {
+ INSERT OR IGNORE INTO t1 SELECT a+3,b+3 FROM t1;
+ }
+} {3}
+do_test conflict-8.6.1 {
+ db changes
+} {3}
+
+integrity_check conflict-8.99
+
+do_test conflict-9.1 {
+ execsql {
+ PRAGMA count_changes=0;
+ CREATE TABLE t2(
+ a INTEGER UNIQUE ON CONFLICT IGNORE,
+ b INTEGER UNIQUE ON CONFLICT FAIL,
+ c INTEGER UNIQUE ON CONFLICT REPLACE,
+ d INTEGER UNIQUE ON CONFLICT ABORT,
+ e INTEGER UNIQUE ON CONFLICT ROLLBACK
+ );
+ CREATE TABLE t3(x);
+ INSERT INTO t3 VALUES(1);
+ SELECT * FROM t3;
+ }
+} {1}
+do_test conflict-9.2 {
+ catchsql {
+ INSERT INTO t2 VALUES(1,1,1,1,1);
+ INSERT INTO t2 VALUES(2,2,2,2,2);
+ SELECT * FROM t2;
+ }
+} {0 {1 1 1 1 1 2 2 2 2 2}}
+do_test conflict-9.3 {
+ catchsql {
+ INSERT INTO t2 VALUES(1,3,3,3,3);
+ SELECT * FROM t2;
+ }
+} {0 {1 1 1 1 1 2 2 2 2 2}}
+do_test conflict-9.4 {
+ catchsql {
+ UPDATE t2 SET a=a+1 WHERE a=1;
+ SELECT * FROM t2;
+ }
+} {0 {1 1 1 1 1 2 2 2 2 2}}
+do_test conflict-9.5 {
+ catchsql {
+ INSERT INTO t2 VALUES(3,1,3,3,3);
+ SELECT * FROM t2;
+ }
+} {1 {column b is not unique}}
+do_test conflict-9.6 {
+ catchsql {
+ UPDATE t2 SET b=b+1 WHERE b=1;
+ SELECT * FROM t2;
+ }
+} {1 {column b is not unique}}
+do_test conflict-9.7 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ INSERT INTO t2 VALUES(3,1,3,3,3);
+ SELECT * FROM t2;
+ }
+} {1 {column b is not unique}}
+do_test conflict-9.8 {
+ execsql {COMMIT}
+ execsql {SELECT * FROM t3}
+} {2}
+do_test conflict-9.9 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ UPDATE t2 SET b=b+1 WHERE b=1;
+ SELECT * FROM t2;
+ }
+} {1 {column b is not unique}}
+do_test conflict-9.10 {
+ execsql {COMMIT}
+ execsql {SELECT * FROM t3}
+} {3}
+do_test conflict-9.11 {
+ catchsql {
+ INSERT INTO t2 VALUES(3,3,3,1,3);
+ SELECT * FROM t2;
+ }
+} {1 {column d is not unique}}
+do_test conflict-9.12 {
+ catchsql {
+ UPDATE t2 SET d=d+1 WHERE d=1;
+ SELECT * FROM t2;
+ }
+} {1 {column d is not unique}}
+do_test conflict-9.13 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ INSERT INTO t2 VALUES(3,3,3,1,3);
+ SELECT * FROM t2;
+ }
+} {1 {column d is not unique}}
+do_test conflict-9.14 {
+ execsql {COMMIT}
+ execsql {SELECT * FROM t3}
+} {4}
+do_test conflict-9.15 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ UPDATE t2 SET d=d+1 WHERE d=1;
+ SELECT * FROM t2;
+ }
+} {1 {column d is not unique}}
+do_test conflict-9.16 {
+ execsql {COMMIT}
+ execsql {SELECT * FROM t3}
+} {5}
+do_test conflict-9.17 {
+ catchsql {
+ INSERT INTO t2 VALUES(3,3,3,3,1);
+ SELECT * FROM t2;
+ }
+} {1 {column e is not unique}}
+do_test conflict-9.18 {
+ catchsql {
+ UPDATE t2 SET e=e+1 WHERE e=1;
+ SELECT * FROM t2;
+ }
+} {1 {column e is not unique}}
+do_test conflict-9.19 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ INSERT INTO t2 VALUES(3,3,3,3,1);
+ SELECT * FROM t2;
+ }
+} {1 {column e is not unique}}
+do_test conflict-9.20 {
+ catch {execsql {COMMIT}}
+ execsql {SELECT * FROM t3}
+} {5}
+do_test conflict-9.21 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ UPDATE t2 SET e=e+1 WHERE e=1;
+ SELECT * FROM t2;
+ }
+} {1 {column e is not unique}}
+do_test conflict-9.22 {
+ catch {execsql {COMMIT}}
+ execsql {SELECT * FROM t3}
+} {5}
+do_test conflict-9.23 {
+ catchsql {
+ INSERT INTO t2 VALUES(3,3,1,3,3);
+ SELECT * FROM t2;
+ }
+} {0 {2 2 2 2 2 3 3 1 3 3}}
+do_test conflict-9.24 {
+ catchsql {
+ UPDATE t2 SET c=c-1 WHERE c=2;
+ SELECT * FROM t2;
+ }
+} {0 {2 2 1 2 2}}
+do_test conflict-9.25 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ INSERT INTO t2 VALUES(3,3,1,3,3);
+ SELECT * FROM t2;
+ }
+} {0 {3 3 1 3 3}}
+do_test conflict-9.26 {
+ catch {execsql {COMMIT}}
+ execsql {SELECT * FROM t3}
+} {6}
+
+do_test conflict-10.1 {
+ catchsql {
+ DELETE FROM t1;
+ BEGIN;
+ INSERT OR ROLLBACK INTO t1 VALUES(1,2);
+ INSERT OR ROLLBACK INTO t1 VALUES(1,3);
+ COMMIT;
+ }
+ execsql {SELECT * FROM t1}
+} {}
+do_test conflict-10.2 {
+ catchsql {
+ CREATE TABLE t4(x);
+ CREATE UNIQUE INDEX t4x ON t4(x);
+ BEGIN;
+ INSERT OR ROLLBACK INTO t4 VALUES(1);
+ INSERT OR ROLLBACK INTO t4 VALUES(1);
+ COMMIT;
+ }
+ execsql {SELECT * FROM t4}
+} {}
+
+# Ticket #1171. Make sure statement rollbacks do not
+# damage the database.
+#
+do_test conflict-11.1 {
+ execsql {
+ -- Create a database object (pages 2, 3 of the file)
+ BEGIN;
+ CREATE TABLE abc(a UNIQUE, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(4, 5, 6);
+ INSERT INTO abc VALUES(7, 8, 9);
+ COMMIT;
+ }
+
+
+ # Set a small cache size so that changes will spill into
+ # the database file.
+ execsql {
+ PRAGMA cache_size = 10;
+ }
+
+ # Make lots of changes. Because of the small cache, some
+ # (most?) of these changes will spill into the disk file.
+ # In other words, some of the changes will not be held in
+ # cache.
+ #
+ execsql {
+ BEGIN;
+ -- Make sure the pager is in EXCLUSIVE state.
+ CREATE TABLE def(d, e, f);
+ INSERT INTO def VALUES
+ ('xxxxxxxxxxxxxxx', 'yyyyyyyyyyyyyyyy', 'zzzzzzzzzzzzzzzz');
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ DELETE FROM abc WHERE a = 4;
+ }
+
+ # Execute a statement that does a statement rollback due to
+ # a constraint failure.
+ #
+ catchsql {
+ INSERT INTO abc SELECT 10, 20, 30 FROM def;
+ }
+
+ # Rollback the database. Verify that the state of the ABC table
+ # is unchanged from the beginning of the transaction. In other words,
+ # make sure the DELETE on table ABC that occurred within the transaction
+ # had no effect.
+ #
+ execsql {
+ ROLLBACK;
+ SELECT * FROM abc;
+ }
+} {1 2 3 4 5 6 7 8 9}
+integrity_check conflict-11.2
+
+# Repeat test conflict-11.1 but this time commit.
+#
+do_test conflict-11.3 {
+ execsql {
+ BEGIN;
+ -- Make sure the pager is in EXCLUSIVE state.
+ UPDATE abc SET a=a+1;
+ CREATE TABLE def(d, e, f);
+ INSERT INTO def VALUES
+ ('xxxxxxxxxxxxxxx', 'yyyyyyyyyyyyyyyy', 'zzzzzzzzzzzzzzzz');
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ DELETE FROM abc WHERE a = 4;
+ }
+ catchsql {
+ INSERT INTO abc SELECT 10, 20, 30 FROM def;
+ }
+ execsql {
+ ROLLBACK;
+ SELECT * FROM abc;
+ }
+} {1 2 3 4 5 6 7 8 9}
+# Repeat test conflict-11.1 but this time commit.
+#
+do_test conflict-11.5 {
+ execsql {
+ BEGIN;
+ -- Make sure the pager is in EXCLUSIVE state.
+ CREATE TABLE def(d, e, f);
+ INSERT INTO def VALUES
+ ('xxxxxxxxxxxxxxx', 'yyyyyyyyyyyyyyyy', 'zzzzzzzzzzzzzzzz');
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ INSERT INTO def SELECT * FROM def;
+ DELETE FROM abc WHERE a = 4;
+ }
+ catchsql {
+ INSERT INTO abc SELECT 10, 20, 30 FROM def;
+ }
+ execsql {
+ COMMIT;
+ SELECT * FROM abc;
+ }
+} {1 2 3 7 8 9}
+integrity_check conflict-11.6
+
+# Make sure UPDATE OR REPLACE works on tables that have only
+# an INTEGER PRIMARY KEY.
+#
+do_test conflict-12.1 {
+ execsql {
+ CREATE TABLE t5(a INTEGER PRIMARY KEY, b text);
+ INSERT INTO t5 VALUES(1,'one');
+ INSERT INTO t5 VALUES(2,'two');
+ SELECT * FROM t5
+ }
+} {1 one 2 two}
+do_test conflict-12.2 {
+ execsql {
+ UPDATE OR IGNORE t5 SET a=a+1 WHERE a=1;
+ SELECT * FROM t5;
+ }
+} {1 one 2 two}
+do_test conflict-12.3 {
+ catchsql {
+ UPDATE t5 SET a=a+1 WHERE a=1;
+ }
+} {1 {PRIMARY KEY must be unique}}
+do_test conflict-12.4 {
+ execsql {
+ UPDATE OR REPLACE t5 SET a=a+1 WHERE a=1;
+ SELECT * FROM t5;
+ }
+} {2 one}
+
+
+# Ticket [c38baa3d969eab7946dc50ba9d9b4f0057a19437]
+# REPLACE works like ABORT on a CHECK constraint.
+#
+do_test conflict-13.1 {
+ execsql {
+ CREATE TABLE t13(a CHECK(a!=2));
+ BEGIN;
+ REPLACE INTO t13 VALUES(1);
+ }
+ catchsql {
+ REPLACE INTO t13 VALUES(2);
+ }
+} {1 {constraint failed}}
+do_test conflict-13.2 {
+ execsql {
+ REPLACE INTO t13 VALUES(3);
+ COMMIT;
+ SELECT * FROM t13;
+ }
+} {1 3}
+
+
+finish_test
diff --git a/test/corrupt.test b/test/corrupt.test
new file mode 100644
index 0000000..09f3c5b
--- /dev/null
+++ b/test/corrupt.test
@@ -0,0 +1,344 @@
+# 2004 August 30 {}
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file.
+#
+# $Id: corrupt.test,v 1.12 2009/07/13 09:41:45 danielk1977 Exp $
+
+catch {forcedelete test.db test.db-journal test.bu}
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Construct a large database for testing.
+#
+do_test corrupt-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randstr(100,100));
+ INSERT INTO t1 VALUES(randstr(90,90));
+ INSERT INTO t1 VALUES(randstr(80,80));
+ INSERT INTO t1 SELECT x || randstr(5,5) FROM t1;
+ INSERT INTO t1 SELECT x || randstr(6,6) FROM t1;
+ INSERT INTO t1 SELECT x || randstr(7,7) FROM t1;
+ INSERT INTO t1 SELECT x || randstr(8,8) FROM t1;
+ INSERT INTO t1 VALUES(randstr(3000,3000));
+ INSERT INTO t1 SELECT x || randstr(9,9) FROM t1;
+ INSERT INTO t1 SELECT x || randstr(10,10) FROM t1;
+ INSERT INTO t1 SELECT x || randstr(11,11) FROM t1;
+ INSERT INTO t1 SELECT x || randstr(12,12) FROM t1;
+ CREATE INDEX t1i1 ON t1(x);
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ DELETE FROM t2 WHERE rowid%5!=0;
+ COMMIT;
+ }
+} {}
+integrity_check corrupt-1.2
+
+# Setup for the tests. Make a backup copy of the good database in test.bu.
+# Create a string of garbage data that is 256 bytes long.
+#
+forcecopy test.db test.bu
+set fsize [file size test.db]
+set junk "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+while {[string length $junk]<256} {append junk $junk}
+set junk [string range $junk 0 255]
+
+# Go through the database and write garbage data into each 256 segment
+# of the file. Then do various operations on the file to make sure that
+# the database engine can recover gracefully from the corruption.
+#
+for {set i [expr {1*256}]} {$i<$fsize-256} {incr i 256} {
+ set tn [expr {$i/256}]
+ db close
+ forcecopy test.bu test.db
+ set fd [open test.db r+]
+ fconfigure $fd -translation binary
+ seek $fd $i
+ puts -nonewline $fd $junk
+ close $fd
+ do_test corrupt-2.$tn.1 {
+ sqlite3 db test.db
+ catchsql {SELECT count(*) FROM sqlite_master}
+ set x {}
+ } {}
+ do_test corrupt-2.$tn.2 {
+ catchsql {SELECT count(*) FROM t1}
+ set x {}
+ } {}
+ do_test corrupt-2.$tn.3 {
+ catchsql {SELECT count(*) FROM t1 WHERE x>'abcdef'}
+ set x {}
+ } {}
+ do_test corrupt-2.$tn.4 {
+ catchsql {SELECT count(*) FROM t2}
+ set x {}
+ } {}
+ do_test corrupt-2.$tn.5 {
+ catchsql {CREATE TABLE t3 AS SELECT * FROM t1}
+ set x {}
+ } {}
+ do_test corrupt-2.$tn.6 {
+ catchsql {DROP TABLE t1}
+ set x {}
+ } {}
+ do_test corrupt-2.$tn.7 {
+ catchsql {PRAGMA integrity_check}
+ set x {}
+ } {}
+
+ # Check that no page references were leaked.
+ do_test corrupt-2.$tn.8 {
+ set bt [btree_from_db db]
+ db_enter db
+ array set stats [btree_pager_stats $bt]
+ db_leave db
+ set stats(ref)
+ } {0}
+}
+
+#------------------------------------------------------------------------
+# For these tests, swap the rootpage entries of t1 (a table) and t1i1 (an
+# index on t1) in sqlite_master. Then perform a few different queries
+# and make sure this is detected as corruption.
+#
+do_test corrupt-3.1 {
+ db close
+ forcecopy test.bu test.db
+ sqlite3 db test.db
+ list
+} {}
+do_test corrupt-3.2 {
+ set t1_r [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't1i1'}]
+ set t1i1_r [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't1'}]
+ set cookie [expr [execsql {PRAGMA schema_version}] + 1]
+ execsql "
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master SET rootpage = $t1_r WHERE name = 't1';
+ UPDATE sqlite_master SET rootpage = $t1i1_r WHERE name = 't1i1';
+ PRAGMA writable_schema = 0;
+ PRAGMA schema_version = $cookie;
+ "
+} {}
+
+# This one tests the case caught by code in checkin [2313].
+do_test corrupt-3.3 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ INSERT INTO t1 VALUES('abc');
+ }
+} {1 {database disk image is malformed}}
+do_test corrupt-3.4 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT * FROM t1;
+ }
+} {1 {database disk image is malformed}}
+do_test corrupt-3.5 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT * FROM t1 WHERE oid = 10;
+ }
+} {1 {database disk image is malformed}}
+do_test corrupt-3.6 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT * FROM t1 WHERE x = 'abcde';
+ }
+} {1 {database disk image is malformed}}
+
+do_test corrupt-4.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
+ }
+ for {set i 0} {$i < 10} {incr i} {
+ set text [string repeat $i 220]
+ execsql { INSERT INTO t1 VALUES($i, $text) }
+ }
+ execsql { CREATE INDEX i1 ON t1(b) }
+} {}
+do_test corrupt-4.2 {
+ set iRoot [db one {SELECT rootpage FROM sqlite_master WHERE name = 'i1'}]
+ set iOffset [hexio_get_int [hexio_read test.db [expr 12+($iRoot-1)*1024] 2]]
+ set data [hexio_render_int32 [expr $iRoot - 1]]
+ hexio_write test.db [expr ($iRoot-1)*1024 + $iOffset] $data
+ db close
+ sqlite3 db test.db
+
+ # The following DELETE statement attempts to delete a cell stored on the
+ # root page of index i1. After this cell is deleted it must be replaced
+ # by a cell retrieved from the child page (a leaf) of the deleted cell.
+ # This will fail, as the block modified the database image so that the
+ # child page of the deleted cell is from a table (intkey) b-tree, not an
+ # index b-tree as expected. At one point this was causing an assert()
+ # to fail.
+ catchsql { DELETE FROM t1 WHERE rowid = 3 }
+} {1 {database disk image is malformed}}
+
+do_test corrupt-5.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+
+ execsql { PRAGMA page_size = 1024 }
+ set ct "CREATE TABLE t1(c0 "
+ set i 0
+ while {[string length $ct] < 950} { append ct ", c[incr i]" }
+ append ct ")"
+ execsql $ct
+} {}
+
+do_test corrupt-5.2 {
+ db close
+ hexio_write test.db 108 00000000
+ sqlite3 db test.db
+ catchsql { SELECT * FROM sqlite_master }
+} {1 {database disk image is malformed}}
+
+# At one point, the specific corruption caused by this test case was
+# causing a buffer overwrite. Although a crash was never demonstrated,
+# running this testcase under valgrind revealed the problem.
+do_test corrupt-6.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024; CREATE TABLE t1(x);
+ }
+
+ # The root page of t1 is 1024 bytes in size. The header is 8 bytes, and
+ # each of the cells inserted by the following INSERT statements consume
+ # 16 bytes (including the 2 byte cell-offset array entry). So the page
+ # can contain up to 63 cells.
+ for {set i 0} {$i < 63} {incr i} {
+ execsql { INSERT INTO t1 VALUES( randomblob(10) ) }
+ }
+
+ # Free the cell stored right at the end of the page (at offset pgsz-14).
+ execsql { DELETE FROM t1 WHERE rowid=1 }
+ set rootpage [db one {SELECT rootpage FROM sqlite_master WHERE name = 't1'}]
+ db close
+
+ set offset [expr ($rootpage * 1024)-14+2]
+ hexio_write test.db $offset 00FF
+ sqlite3 db test.db
+
+ catchsql { INSERT INTO t1 VALUES( randomblob(10) ) }
+} {1 {database disk image is malformed}}
+
+ifcapable oversize_cell_check {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024; CREATE TABLE t1(x);
+ }
+
+ do_test corrupt-7.1 {
+ for {set i 0} {$i < 39} {incr i} {
+ execsql {
+ INSERT INTO t1 VALUES(X'000100020003000400050006000700080009000A');
+ }
+ }
+ } {}
+ db close
+
+ # Corrupt the root page of table t1 so that the first offset in the
+ # cell-offset array points to the data for the SQL blob associated with
+ # record (rowid=10). The root page still passes the checks in btreeInitPage(),
+ # because the start of said blob looks like the start of a legitimate
+ # page cell.
+ #
+ # Test case cc-2 overwrites the blob so that it no longer looks like a
+ # real cell. But, by the time it is overwritten, btreeInitPage() has already
+ # initialized the root page, so no corruption is detected.
+ #
+ # Test case cc-3 inserts an extra record into t1, forcing balance-deeper
+ # to run. After copying the contents of the root page to the new child,
+ # btreeInitPage() is called on the child. This time, it detects corruption
+ # (because the start of the blob associated with the (rowid=10) record
+ # no longer looks like a real cell). At one point the code assumed that
+ # detecting corruption was not possible at that point, and an assert() failed.
+ #
+ set fd [open test.db r+]
+ fconfigure $fd -translation binary -encoding binary
+ seek $fd [expr 1024+8]
+ puts -nonewline $fd "\x03\x14"
+ close $fd
+
+ sqlite3 db test.db
+ do_test corrupt-7.2 {
+ execsql {
+ UPDATE t1 SET x = X'870400020003000400050006000700080009000A'
+ WHERE rowid = 10;
+ }
+ } {}
+ do_test corrupt-7.3 {
+ catchsql {
+ INSERT INTO t1 VALUES(X'000100020003000400050006000700080009000A');
+ }
+ } {1 {database disk image is malformed}}
+}
+
+db close
+forcedelete test.db test.db-journal
+do_test corrupt-8.1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA secure_delete = on;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(5, randomblob(1900));
+ }
+
+ hexio_write test.db 2044 [hexio_render_int32 2]
+ hexio_write test.db 24 [hexio_render_int32 45]
+
+ catchsql { INSERT OR REPLACE INTO t1 VALUES(5, randomblob(1900)) }
+} {1 {database disk image is malformed}}
+
+db close
+forcedelete test.db test.db-journal
+do_test corrupt-8.2 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA secure_delete = on;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(5, randomblob(900));
+ INSERT INTO t1 VALUES(6, randomblob(900));
+ }
+
+ hexio_write test.db 2047 FF
+ hexio_write test.db 24 [hexio_render_int32 45]
+
+ catchsql { INSERT INTO t1 VALUES(4, randomblob(1900)) }
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/corrupt2.test b/test/corrupt2.test
new file mode 100644
index 0000000..744a76e
--- /dev/null
+++ b/test/corrupt2.test
@@ -0,0 +1,558 @@
+# 2004 August 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file.
+#
+# $Id: corrupt2.test,v 1.20 2009/04/06 17:50:03 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+set presql ""
+catch { set presql "$::G(perm:presql);" }
+unset -nocomplain ::G(perm:presql)
+
+# The following tests - corrupt2-1.* - create some databases corrupted in
+# specific ways and ensure that SQLite detects them as corrupt.
+#
+do_test corrupt2-1.1 {
+ execsql {
+ PRAGMA auto_vacuum=0;
+ PRAGMA page_size=1024;
+ CREATE TABLE abc(a, b, c);
+ }
+} {}
+
+do_test corrupt2-1.2 {
+
+ # Corrupt the 16 byte magic string at the start of the file
+ forcedelete corrupt.db
+ forcedelete corrupt.db-journal
+ forcecopy test.db corrupt.db
+ set f [open corrupt.db RDWR]
+ seek $f 8 start
+ puts $f blah
+ close $f
+
+ sqlite3 db2 corrupt.db
+ catchsql "
+ $::presql
+ SELECT * FROM sqlite_master;
+ " db2
+} {1 {file is encrypted or is not a database}}
+
+do_test corrupt2-1.3 {
+ db2 close
+
+ # Corrupt the page-size (bytes 16 and 17 of page 1).
+ forcedelete corrupt.db
+ forcedelete corrupt.db-journal
+ forcecopy test.db corrupt.db
+ set f [open corrupt.db RDWR]
+ fconfigure $f -encoding binary
+ seek $f 16 start
+ puts -nonewline $f "\x00\xFF"
+ close $f
+
+ sqlite3 db2 corrupt.db
+ catchsql "
+ $::presql
+ SELECT * FROM sqlite_master;
+ " db2
+} {1 {file is encrypted or is not a database}}
+
+do_test corrupt2-1.4 {
+ db2 close
+
+ # Corrupt the free-block list on page 1.
+ forcedelete corrupt.db
+ forcedelete corrupt.db-journal
+ forcecopy test.db corrupt.db
+ set f [open corrupt.db RDWR]
+ fconfigure $f -encoding binary
+ seek $f 101 start
+ puts -nonewline $f "\xFF\xFF"
+ close $f
+
+ sqlite3 db2 corrupt.db
+ catchsql "
+ $::presql
+ SELECT * FROM sqlite_master;
+ " db2
+} {1 {database disk image is malformed}}
+
+do_test corrupt2-1.5 {
+ db2 close
+
+ # Corrupt the free-block list on page 1.
+ forcedelete corrupt.db
+ forcedelete corrupt.db-journal
+ forcecopy test.db corrupt.db
+ set f [open corrupt.db RDWR]
+ fconfigure $f -encoding binary
+ seek $f 101 start
+ puts -nonewline $f "\x00\xC8"
+ seek $f 200 start
+ puts -nonewline $f "\x00\x00"
+ puts -nonewline $f "\x10\x00"
+ close $f
+
+ sqlite3 db2 corrupt.db
+ catchsql "
+ $::presql
+ SELECT * FROM sqlite_master;
+ " db2
+} {1 {database disk image is malformed}}
+db2 close
+
+# Corrupt a database by having 2 indices of the same name:
+do_test corrupt2-2.1 {
+
+ forcedelete corrupt.db
+ forcedelete corrupt.db-journal
+ forcecopy test.db corrupt.db
+
+ sqlite3 db2 corrupt.db
+ execsql "
+ $::presql
+ CREATE INDEX a1 ON abc(a);
+ CREATE INDEX a2 ON abc(b);
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master
+ SET name = 'a3', sql = 'CREATE INDEX a3' || substr(sql, 16, 10000)
+ WHERE type = 'index';
+ PRAGMA writable_schema = 0;
+ " db2
+
+ db2 close
+ sqlite3 db2 corrupt.db
+ catchsql "
+ $::presql
+ SELECT * FROM sqlite_master;
+ " db2
+} {1 {malformed database schema (a3) - index a3 already exists}}
+
+db2 close
+
+do_test corrupt2-3.1 {
+ forcedelete corrupt.db
+ forcedelete corrupt.db-journal
+ sqlite3 db2 corrupt.db
+
+ execsql "
+ $::presql
+ PRAGMA auto_vacuum = 1;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+ INSERT INTO t2 VALUES(randomblob(100), randomblob(100), randomblob(100));
+ INSERT INTO t2 SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t2;
+ " db2
+
+ db2 close
+
+ # On the root page of table t2 (page 4), set one of the child page-numbers
+ # to 0. This corruption will be detected when SQLite attempts to update
+ # the pointer-map after moving the content of page 4 to page 3 as part
+ # of the DROP TABLE operation below.
+ #
+ set fd [open corrupt.db r+]
+ fconfigure $fd -encoding binary -translation binary
+ seek $fd [expr 1024*3 + 12]
+ set zCelloffset [read $fd 2]
+ binary scan $zCelloffset S iCelloffset
+ seek $fd [expr 1024*3 + $iCelloffset]
+ puts -nonewline $fd "\00\00\00\00"
+ close $fd
+
+ sqlite3 db2 corrupt.db
+ catchsql "
+ $::presql
+ DROP TABLE t1;
+ " db2
+} {1 {database disk image is malformed}}
+
+do_test corrupt2-4.1 {
+ catchsql {
+ SELECT * FROM t2;
+ } db2
+} {1 {database disk image is malformed}}
+
+db2 close
+
+unset -nocomplain result
+do_test corrupt2-5.1 {
+ forcedelete corrupt.db
+ forcedelete corrupt.db-journal
+ sqlite3 db2 corrupt.db
+
+ execsql "
+ $::presql
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+ INSERT INTO t2 VALUES(randomblob(100), randomblob(100), randomblob(100));
+ INSERT INTO t2 SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t2;
+ INSERT INTO t1 SELECT * FROM t2;
+ " db2
+
+ db2 close
+
+ # This block links a page from table t2 into the t1 table structure.
+ #
+ set fd [open corrupt.db r+]
+ fconfigure $fd -encoding binary -translation binary
+ seek $fd [expr 1024 + 12]
+ set zCelloffset [read $fd 2]
+ binary scan $zCelloffset S iCelloffset
+ seek $fd [expr 1024 + $iCelloffset]
+ set zChildPage [read $fd 4]
+ seek $fd [expr 2*1024 + 12]
+ set zCelloffset [read $fd 2]
+ binary scan $zCelloffset S iCelloffset
+ seek $fd [expr 2*1024 + $iCelloffset]
+ puts -nonewline $fd $zChildPage
+ close $fd
+
+ sqlite3 db2 corrupt.db
+ db2 eval $::presql
+ db2 eval {SELECT rowid FROM t1} {
+ set result [db2 eval {pragma integrity_check}]
+ break
+ }
+ set result
+} {{*** in database main ***
+On tree page 2 cell 0: 2nd reference to page 10
+On tree page 2 cell 1: Child page depth differs
+Page 4 is never used}}
+
+db2 close
+
+proc corruption_test {args} {
+ set A(-corrupt) {}
+ set A(-sqlprep) {}
+ set A(-tclprep) {}
+ array set A $args
+
+ catch {db close}
+ forcedelete corrupt.db
+ forcedelete corrupt.db-journal
+
+ sqlite3 db corrupt.db
+ db eval $::presql
+ eval $A(-tclprep)
+ db eval $A(-sqlprep)
+ db close
+
+ eval $A(-corrupt)
+
+ sqlite3 db corrupt.db
+ eval $A(-test)
+}
+
+ifcapable autovacuum {
+ # The tests within this block - corrupt2-6.* - aim to test corruption
+ # detection within an incremental-vacuum. When an incremental-vacuum
+ # step is executed, the last non-free page of the database file is
+ # moved into a free space in the body of the file. After doing so,
+ # the page reference in the parent page must be updated to refer
+ # to the new location. These tests test the outcome of corrupting
+ # that page reference before performing the incremental vacuum.
+ #
+
+ # The last page in the database page is the second page
+ # in an overflow chain.
+ #
+ corruption_test -sqlprep {
+ PRAGMA auto_vacuum = incremental;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, randomblob(2500));
+ INSERT INTO t1 VALUES(2, randomblob(2500));
+ DELETE FROM t1 WHERE a = 1;
+ } -corrupt {
+ hexio_write corrupt.db [expr 1024*5] 00000008
+ } -test {
+ do_test corrupt2-6.1 {
+ catchsql " $::presql pragma incremental_vacuum = 1 "
+ } {1 {database disk image is malformed}}
+ }
+
+ # The last page in the database page is a non-root b-tree page.
+ #
+ corruption_test -sqlprep {
+ PRAGMA auto_vacuum = incremental;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, randomblob(2500));
+ INSERT INTO t1 VALUES(2, randomblob(50));
+ INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
+ DELETE FROM t1 WHERE a = 1;
+ } -corrupt {
+ hexio_write corrupt.db [expr 1024*2 + 8] 00000009
+ } -test {
+ do_test corrupt2-6.2 {
+ catchsql " $::presql pragma incremental_vacuum = 1 "
+ } {1 {database disk image is malformed}}
+ }
+
+ # Set up a pointer-map entry so that the last page of the database
+ # file appears to be a b-tree root page. This should be detected
+ # as corruption.
+ #
+ corruption_test -sqlprep {
+ PRAGMA auto_vacuum = incremental;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, randomblob(2500));
+ INSERT INTO t1 VALUES(2, randomblob(2500));
+ INSERT INTO t1 VALUES(3, randomblob(2500));
+ DELETE FROM t1 WHERE a = 1;
+ } -corrupt {
+ set nPage [expr [file size corrupt.db] / 1024]
+ hexio_write corrupt.db [expr 1024 + ($nPage-3)*5] 010000000
+ } -test {
+ do_test corrupt2-6.3 {
+ catchsql " $::presql pragma incremental_vacuum = 1 "
+ } {1 {database disk image is malformed}}
+ }
+
+ corruption_test -sqlprep {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, randomblob(2500));
+ DELETE FROM t1 WHERE a = 1;
+ } -corrupt {
+ set nAppend [expr 1024*207 - [file size corrupt.db]]
+ set fd [open corrupt.db r+]
+ seek $fd 0 end
+ puts -nonewline $fd [string repeat x $nAppend]
+ close $fd
+ hexio_write corrupt.db 28 00000000
+ } -test {
+ do_test corrupt2-6.4 {
+ catchsql "
+ $::presql
+ BEGIN EXCLUSIVE;
+ COMMIT;
+ "
+ } {1 {database disk image is malformed}}
+ }
+}
+
+
+set sqlprep {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE INDEX i1 ON t1(b);
+ INSERT INTO t1 VALUES(1, randomblob(50));
+ INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
+ INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
+}
+
+corruption_test -sqlprep $sqlprep -corrupt {
+ # Set the page-flags of one of the leaf pages of the index B-Tree to
+ # 0x0D (interpreted by SQLite as "leaf page of a table B-Tree").
+ #
+ set fd [open corrupt.db r+]
+ fconfigure $fd -translation binary -encoding binary
+ seek $fd [expr 1024*2 + 8]
+ set zRightChild [read $fd 4]
+ binary scan $zRightChild I iRightChild
+ seek $fd [expr 1024*($iRightChild-1)]
+ puts -nonewline $fd "\x0D"
+ close $fd
+} -test {
+ do_test corrupt2-7.1 {
+ catchsql " $::presql SELECT b FROM t1 ORDER BY b ASC "
+ } {1 {database disk image is malformed}}
+}
+
+corruption_test -sqlprep $sqlprep -corrupt {
+ # Mess up the page-header of one of the leaf pages of the index B-Tree.
+ # The corruption is detected as part of an OP_Prev opcode.
+ #
+ set fd [open corrupt.db r+]
+ fconfigure $fd -translation binary -encoding binary
+ seek $fd [expr 1024*2 + 12]
+ set zCellOffset [read $fd 2]
+ binary scan $zCellOffset S iCellOffset
+ seek $fd [expr 1024*2 + $iCellOffset]
+ set zChild [read $fd 4]
+ binary scan $zChild I iChild
+ seek $fd [expr 1024*($iChild-1)+3]
+ puts -nonewline $fd "\xFFFF"
+ close $fd
+} -test {
+ do_test corrupt2-7.1 {
+ catchsql " $::presql SELECT b FROM t1 ORDER BY b DESC "
+ } {1 {database disk image is malformed}}
+}
+
+corruption_test -sqlprep $sqlprep -corrupt {
+ # Set the page-flags of one of the leaf pages of the table B-Tree to
+ # 0x0A (interpreted by SQLite as "leaf page of an index B-Tree").
+ #
+ set fd [open corrupt.db r+]
+ fconfigure $fd -translation binary -encoding binary
+ seek $fd [expr 1024*1 + 8]
+ set zRightChild [read $fd 4]
+ binary scan $zRightChild I iRightChild
+ seek $fd [expr 1024*($iRightChild-1)]
+ puts -nonewline $fd "\x0A"
+ close $fd
+} -test {
+ do_test corrupt2-8.1 {
+ catchsql " $::presql SELECT * FROM t1 WHERE rowid=1000 "
+ } {1 {database disk image is malformed}}
+}
+
+corruption_test -sqlprep {
+ CREATE TABLE t1(a, b, c); CREATE TABLE t8(a, b, c); CREATE TABLE tE(a, b, c);
+ CREATE TABLE t2(a, b, c); CREATE TABLE t9(a, b, c); CREATE TABLE tF(a, b, c);
+ CREATE TABLE t3(a, b, c); CREATE TABLE tA(a, b, c); CREATE TABLE tG(a, b, c);
+ CREATE TABLE t4(a, b, c); CREATE TABLE tB(a, b, c); CREATE TABLE tH(a, b, c);
+ CREATE TABLE t5(a, b, c); CREATE TABLE tC(a, b, c); CREATE TABLE tI(a, b, c);
+ CREATE TABLE t6(a, b, c); CREATE TABLE tD(a, b, c); CREATE TABLE tJ(a, b, c);
+ CREATE TABLE x1(a, b, c); CREATE TABLE x8(a, b, c); CREATE TABLE xE(a, b, c);
+ CREATE TABLE x2(a, b, c); CREATE TABLE x9(a, b, c); CREATE TABLE xF(a, b, c);
+ CREATE TABLE x3(a, b, c); CREATE TABLE xA(a, b, c); CREATE TABLE xG(a, b, c);
+ CREATE TABLE x4(a, b, c); CREATE TABLE xB(a, b, c); CREATE TABLE xH(a, b, c);
+ CREATE TABLE x5(a, b, c); CREATE TABLE xC(a, b, c); CREATE TABLE xI(a, b, c);
+ CREATE TABLE x6(a, b, c); CREATE TABLE xD(a, b, c); CREATE TABLE xJ(a, b, c);
+} -corrupt {
+ set fd [open corrupt.db r+]
+ fconfigure $fd -translation binary -encoding binary
+ seek $fd 108
+ set zRightChild [read $fd 4]
+ binary scan $zRightChild I iRightChild
+ seek $fd [expr 1024*($iRightChild-1)+3]
+ puts -nonewline $fd "\x00\x00"
+ close $fd
+} -test {
+ do_test corrupt2-9.1 {
+ catchsql " $::presql SELECT sql FROM sqlite_master "
+ } {1 {database disk image is malformed}}
+}
+
+corruption_test -sqlprep {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master SET rootpage = NULL WHERE name = 't2';
+} -test {
+ do_test corrupt2-10.1 {
+ catchsql " $::presql SELECT * FROM t2 "
+ } {1 {malformed database schema (t2)}}
+ do_test corrupt2-10.2 {
+ sqlite3_errcode db
+ } {SQLITE_CORRUPT}
+}
+
+corruption_test -sqlprep {
+ PRAGMA auto_vacuum = incremental;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, randstr(100,100));
+ INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;
+ INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;
+ INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;
+ INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;
+ INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;
+ INSERT INTO t2 SELECT * FROM t1;
+ DELETE FROM t1;
+} -corrupt {
+ set offset [expr [file size corrupt.db] - 1024]
+ hexio_write corrupt.db $offset FF
+ hexio_write corrupt.db 24 12345678
+} -test {
+ do_test corrupt2-11.1 {
+ catchsql " $::presql PRAGMA incremental_vacuum "
+ } {1 {database disk image is malformed}}
+}
+corruption_test -sqlprep {
+ PRAGMA auto_vacuum = incremental;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, randstr(100,100));
+ INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;
+ INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;
+ INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;
+ INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;
+ INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;
+ INSERT INTO t2 SELECT * FROM t1;
+ DELETE FROM t1;
+} -corrupt {
+ set pgno [expr [file size corrupt.db] / 1024]
+ hexio_write corrupt.db [expr 1024+5*($pgno-3)] 03
+ hexio_write corrupt.db 24 12345678
+} -test {
+ do_test corrupt2-12.1 {
+ catchsql " $::presql PRAGMA incremental_vacuum "
+ } {1 {database disk image is malformed}}
+}
+
+ifcapable autovacuum {
+ # It is not possible for the last page in a database file to be the
+ # pending-byte page (AKA the locking page). This test verifies that if
+ # an attempt is made to commit a transaction to such an auto-vacuum
+ # database SQLITE_CORRUPT is returned.
+ #
+ corruption_test -tclprep {
+ db eval {
+ PRAGMA auto_vacuum = full;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(NULL, randstr(50,50));
+ }
+ for {set ii 0} {$ii < 10} {incr ii} {
+ db eval " $::presql INSERT INTO t1 SELECT NULL, randstr(50,50) FROM t1 "
+ }
+ } -corrupt {
+ do_test corrupt2-13.1 {
+ file size corrupt.db
+ } $::sqlite_pending_byte
+ hexio_write corrupt.db [expr $::sqlite_pending_byte+1023] 00
+ hexio_write corrupt.db 28 00000000
+ } -test {
+ do_test corrupt2-13.2 {
+ file size corrupt.db
+ } [expr $::sqlite_pending_byte + 1024]
+ do_test corrupt2-13.3 {
+ catchsql { DELETE FROM t1 WHERE rowid < 30; }
+ } {1 {database disk image is malformed}}
+ }
+}
+
+finish_test
diff --git a/test/corrupt3.test b/test/corrupt3.test
new file mode 100644
index 0000000..a382722
--- /dev/null
+++ b/test/corrupt3.test
@@ -0,0 +1,114 @@
+# 2007 April 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file.
+#
+# $Id: corrupt3.test,v 1.2 2007/04/06 21:42:22 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# We must have the page_size pragma for these tests to work.
+#
+ifcapable !pager_pragmas||direct_read {
+ finish_test
+ return
+}
+
+# Create a database with an overflow page.
+#
+do_test corrupt3-1.1 {
+ set bigstring [string repeat 0123456789 200]
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES($bigstring);
+ }
+ file size test.db
+} [expr {1024*3}]
+
+# Verify that the file format is as we expect. The page size
+# should be 1024 bytes. The only record should have a single
+# overflow page. The overflow page is page 3. The pointer to
+# the overflow page is on the last 4 bytes of page 2.
+#
+do_test corrupt3-1.2 {
+ hexio_get_int [hexio_read test.db 16 2]
+} 1024 ;# The page size is 1024
+do_test corrupt3-1.3 {
+ hexio_get_int [hexio_read test.db 20 1]
+} 0 ;# Unused bytes per page is 0
+do_test corrupt3-1.4 {
+ hexio_get_int [hexio_read test.db 2044 4]
+} 3 ;# Overflow page is 3
+do_test corrupt3-1.5 {
+ hexio_get_int [hexio_read test.db 2048 4]
+} 0 ;# First chained overflow is 0
+
+integrity_check corrupt3-1.6
+
+# Make the overflow chain loop back on itself. See if the
+# corruption is detected. (Actually, the last pointer in
+# an overflow chain is ignored, so this is not an error.)
+#
+do_test corrupt3-1.7 {
+ db close
+ hexio_write test.db 2048 [hexio_render_int32 3]
+ sqlite3 db test.db
+ catchsql {
+ SELECT x FROM t1
+ }
+} [list 0 $bigstring]
+integrity_check corrupt3-1.8
+
+# Change the pointer for the first page of the overflow
+# change to be a non-existant page.
+#
+do_test corrupt3-1.9 {
+ db close
+ hexio_write test.db 2044 [hexio_render_int32 4]
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,10) FROM t1
+ }
+} [list 0 0123456789]
+do_test corrupt3-1.10 {
+ catchsql {
+ PRAGMA integrity_check
+ }
+} {0 {{*** in database main ***
+On tree page 2 cell 0: invalid page number 4
+Page 3 is never used}}}
+do_test corrupt3-1.11 {
+ db close
+ hexio_write test.db 2044 [hexio_render_int32 0]
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,10) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+do_test corrupt3-1.12 {
+ catchsql {
+ PRAGMA integrity_check
+ }
+} {0 {{*** in database main ***
+On tree page 2 cell 0: 1 of 1 pages missing from overflow list starting at 0
+Page 3 is never used}}}
+
+finish_test
diff --git a/test/corrupt4.test b/test/corrupt4.test
new file mode 100644
index 0000000..1906113
--- /dev/null
+++ b/test/corrupt4.test
@@ -0,0 +1,79 @@
+# 2007 Sept 7
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file.
+#
+# $Id: corrupt4.test,v 1.1 2007/09/07 14:32:07 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# We must have the page_size pragma for these tests to work.
+#
+ifcapable !pager_pragmas {
+ finish_test
+ return
+}
+
+# Create a database with a freelist containing at least two pages.
+#
+do_test corrupt4-1.1 {
+ set bigstring [string repeat 0123456789 200]
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES($bigstring);
+ CREATE TABLE t2(y);
+ INSERT INTO t2 VALUES(1);
+ DROP TABLE t1;
+ }
+ file size test.db
+} [expr {1024*4}]
+
+# Verify that there are two pages on the freelist.
+#
+do_test corrupt4-1.2 {
+ execsql {PRAGMA freelist_count}
+} {2}
+
+# Get the page number for the trunk of the freelist.
+#
+set trunkpgno [hexio_get_int [hexio_read test.db 32 4]]
+set baseaddr [expr {($trunkpgno-1)*1024}]
+
+# Verify that the trunk of the freelist has exactly one
+# leaf.
+#
+do_test corrupt4-1.3 {
+ hexio_get_int [hexio_read test.db [expr {$::baseaddr+4}] 4]
+} {1}
+
+# Insert a negative number as the number of leaves on the trunk.
+# Then try to add a new element to the freelist.
+#
+do_test corrupt4-1.4 {
+ hexio_write test.db [expr {$::baseaddr+4}] [hexio_render_int32 -100000000]
+ db close
+ sqlite3 db test.db
+ catchsql {
+ DROP TABLE t2
+ }
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/corrupt5.test b/test/corrupt5.test
new file mode 100644
index 0000000..dca06e5
--- /dev/null
+++ b/test/corrupt5.test
@@ -0,0 +1,45 @@
+# 2008 Jan 22
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file. Checks for
+# malformed schema.
+#
+# $Id: corrupt5.test,v 1.3 2009/06/04 02:47:04 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# We must have the page_size pragma for these tests to work.
+#
+ifcapable !pager_pragmas {
+ finish_test
+ return
+}
+
+# Create a database with a freelist containing at least two pages.
+#
+do_test corrupt5-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX i1 ON t1(a,b);
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_master SET name=NULL, sql=NULL WHERE name='i1';
+ }
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT * FROM t1
+ }
+} {1 {malformed database schema (?)}}
+
+finish_test
diff --git a/test/corrupt6.test b/test/corrupt6.test
new file mode 100644
index 0000000..c0dcedf
--- /dev/null
+++ b/test/corrupt6.test
@@ -0,0 +1,256 @@
+# 2008 May 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file. It specifically focuses
+# on corrupt SerialTypeLen values.
+#
+# $Id: corrupt6.test,v 1.2 2008/05/19 15:37:10 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# We must have the page_size pragma for these tests to work.
+#
+ifcapable !pager_pragmas {
+ finish_test
+ return
+}
+
+# Create a simple, small database.
+#
+do_test corrupt6-1.1 {
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES('varint32-01234567890123456789012345678901234567890123456789');
+ INSERT INTO t1(x) VALUES('varint32-01234567890123456789012345678901234567890123456789');
+ }
+ file size test.db
+} [expr {1024*2}]
+
+# Verify that the file format is as we expect. The page size
+# should be 1024 bytes.
+#
+do_test corrupt6-1.2 {
+ hexio_get_int [hexio_read test.db 16 2]
+} 1024 ;# The page size is 1024
+do_test corrupt6-1.3 {
+ hexio_get_int [hexio_read test.db 20 1]
+} 0 ;# Unused bytes per page is 0
+
+integrity_check corrupt6-1.4
+
+# Verify SerialTypeLen for first field of two records as we expect.
+# SerialTypeLen = (len*2+12) = 60*2+12 = 132
+do_test corrupt6-1.5.1 {
+ hexio_read test.db 1923 2
+} 8103 ;# First text field size is 81 03 == 131
+do_test corrupt6-1.5.2 {
+ hexio_read test.db 1987 2
+} 8103 ;# Second text field size is 81 03 == 131
+
+# Verify simple query results as expected.
+do_test corrupt6-1.6 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 0 {varint32 varint32} ]
+integrity_check corrupt6-1.7
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Increase SerialTypeLen by 2.
+do_test corrupt6-1.8.1 {
+ db close
+ hexio_write test.db 1923 8105
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Decrease SerialTypeLen by 2.
+do_test corrupt6-1.8.2 {
+ db close
+ hexio_write test.db 1923 8101
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Put value of record 1 / field 1 SerialTypeLen back.
+do_test corrupt6-1.8.3 {
+ db close
+ hexio_write test.db 1923 8103
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 0 {varint32 varint32} ]
+integrity_check corrupt6-1.8.4
+
+# Adjust value of record 2 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Increase SerialTypeLen by 2.
+do_test corrupt6-1.9.1 {
+ db close
+ hexio_write test.db 1987 8105
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Adjust value of record 2 / field 2 SerialTypeLen and see if the
+# corruption is detected.
+# Decrease SerialTypeLen by 2.
+do_test corrupt6-1.9.2 {
+ db close
+ hexio_write test.db 1987 8101
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Put value of record 1 / field 2 SerialTypeLen back.
+do_test corrupt6-1.9.3 {
+ db close
+ hexio_write test.db 1987 8103
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 0 {varint32 varint32} ]
+integrity_check corrupt6-1.9.4
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Set SerialTypeLen to FF 7F (2 bytes)
+do_test corrupt6-1.10.1 {
+ db close
+ hexio_write test.db 1923 FF7F
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Set SerialTypeLen to FF FF 7F (3 bytes)
+do_test corrupt6-1.10.2 {
+ db close
+ hexio_write test.db 1923 FFFF7F
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Set SerialTypeLen to FF FF FF 7F (4 bytes)
+do_test corrupt6-1.10.3 {
+ db close
+ hexio_write test.db 1923 FFFFFF7F
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Set SerialTypeLen to FF FF FF FF 7F (5 bytes)
+do_test corrupt6-1.10.4 {
+ db close
+ hexio_write test.db 1923 FFFFFFFF7F
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Set SerialTypeLen to FF FF FF FF FF 7F (6 bytes, and overflows).
+do_test corrupt6-1.10.5 {
+ db close
+ hexio_write test.db 1923 FFFFFFFFFF7F
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Set SerialTypeLen to FF FF FF FF FF FF 7F (7 bytes, and overflows).
+do_test corrupt6-1.10.6 {
+ db close
+ hexio_write test.db 1923 FFFFFFFFFFFF7F
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Set SerialTypeLen to FF FF FF FF FF FF FF 7F (8 bytes, and overflows).
+do_test corrupt6-1.10.7 {
+ db close
+ hexio_write test.db 1923 FFFFFFFFFFFFFF7F
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Set SerialTypeLen to FF FF FF FF FF FF FF FF 7F (9 bytes, and overflows).
+do_test corrupt6-1.10.8 {
+ db close
+ hexio_write test.db 1923 FFFFFFFFFFFFFFFF7F
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+# Adjust value of record 1 / field 1 SerialTypeLen and see if the
+# corruption is detected.
+# Set SerialTypeLen to FFFF FF FF FF FF FF FF FF 7F (10 bytes, and overflows).
+do_test corrupt6-1.10.9 {
+ db close
+ hexio_write test.db 1923 FFFFFFFFFFFFFFFFFF7F
+ sqlite3 db test.db
+ catchsql {
+ SELECT substr(x,1,8) FROM t1
+ }
+} [list 1 {database disk image is malformed}]
+
+finish_test
diff --git a/test/corrupt7.test b/test/corrupt7.test
new file mode 100644
index 0000000..ad56656
--- /dev/null
+++ b/test/corrupt7.test
@@ -0,0 +1,130 @@
+# 2008 June 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file. It specifically focuses
+# on corrupt cell offsets in a btree page.
+#
+# $Id: corrupt7.test,v 1.8 2009/08/10 10:18:08 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# We must have the page_size pragma for these tests to work.
+#
+ifcapable !pager_pragmas {
+ finish_test
+ return
+}
+
+# Create a simple, small database.
+#
+do_test corrupt7-1.1 {
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(1);
+ INSERT INTO t1(x) VALUES(2);
+ INSERT INTO t1(x) SELECT x+2 FROM t1;
+ INSERT INTO t1(x) SELECT x+4 FROM t1;
+ INSERT INTO t1(x) SELECT x+8 FROM t1;
+ }
+ file size test.db
+} [expr {1024*2}]
+
+# Verify that the file format is as we expect. The page size
+# should be 1024 bytes.
+#
+do_test corrupt7-1.2 {
+ hexio_get_int [hexio_read test.db 16 2]
+} 1024 ;# The page size is 1024
+do_test corrupt7-1.3 {
+ hexio_get_int [hexio_read test.db 20 1]
+} 0 ;# Unused bytes per page is 0
+
+integrity_check corrupt7-1.4
+
+# Deliberately corrupt some of the cell offsets in the btree page
+# on page 2 of the database.
+#
+# The error message is different depending on whether or not the
+# SQLITE_ENABLE_OVERSIZE_CELL_CHECK compile-time option is engaged.
+#
+ifcapable oversize_cell_check {
+ do_test corrupt7-2.1 {
+ db close
+ hexio_write test.db 1062 FF
+ sqlite3 db test.db
+ db eval {PRAGMA integrity_check(1)}
+ } {{*** in database main ***
+Page 2: btreeInitPage() returns error code 11}}
+ do_test corrupt7-2.2 {
+ db close
+ hexio_write test.db 1062 04
+ sqlite3 db test.db
+ db eval {PRAGMA integrity_check(1)}
+ } {{*** in database main ***
+Page 2: btreeInitPage() returns error code 11}}
+} else {
+ do_test corrupt7-2.1 {
+ db close
+ hexio_write test.db 1062 FF
+ sqlite3 db test.db
+ db eval {PRAGMA integrity_check(1)}
+ } {{*** in database main ***
+Corruption detected in cell 15 on page 2}}
+ do_test corrupt7-2.2 {
+ db close
+ hexio_write test.db 1062 04
+ sqlite3 db test.db
+ db eval {PRAGMA integrity_check(1)}
+ } {{*** in database main ***
+On tree page 2 cell 15: Rowid 0 out of order (previous was 15)}}
+}
+
+# The code path that was causing the buffer overrun that this test
+# case was checking for was removed.
+#
+#do_test corrupt7-3.1 {
+# execsql {
+# DROP TABLE t1;
+# CREATE TABLE t1(a, b);
+# INSERT INTO t1 VALUES(1, 'one');
+# INSERT INTO t1 VALUES(100, 'one hundred');
+# INSERT INTO t1 VALUES(100000, 'one hundred thousand');
+# CREATE INDEX i1 ON t1(b);
+# }
+# db close
+#
+# # Locate the 3rd cell in the index.
+# set cell_offset [hexio_get_int [hexio_read test.db [expr 1024*2 + 12] 2]]
+# incr cell_offset [expr 1024*2]
+# incr cell_offset 1
+#
+# # This write corrupts the "header-size" field of the database record
+# # stored in the index cell. At one point this was causing sqlite to
+# # reference invalid memory.
+# hexio_write test.db $cell_offset FFFF7F
+#
+# sqlite3 db test.db
+# catchsql {
+# SELECT b FROM t1 WHERE b > 'o' AND b < 'p';
+# }
+#} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/corrupt8.test b/test/corrupt8.test
new file mode 100644
index 0000000..012beb5
--- /dev/null
+++ b/test/corrupt8.test
@@ -0,0 +1,104 @@
+# 2008 July 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file. It specifically focuses
+# on corrupt pointer map pages.
+#
+# $Id: corrupt8.test,v 1.2 2008/07/11 03:34:10 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# We must have the page_size pragma for these tests to work.
+#
+ifcapable !pager_pragmas||!autovacuum {
+ finish_test
+ return
+}
+
+# Create a database to work with.
+#
+do_test corrupt8-1.1 {
+ execsql {
+ PRAGMA auto_vacuum=1;
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(1);
+ INSERT INTO t1(x) VALUES(2);
+ INSERT INTO t1(x) SELECT x+2 FROM t1;
+ INSERT INTO t1(x) SELECT x+4 FROM t1;
+ INSERT INTO t1(x) SELECT x+8 FROM t1;
+ INSERT INTO t1(x) SELECT x+16 FROM t1;
+ INSERT INTO t1(x) SELECT x+32 FROM t1;
+ INSERT INTO t1(x) SELECT x+64 FROM t1;
+ INSERT INTO t1(x) SELECT x+128 FROM t1;
+ INSERT INTO t1(x) SELECT x+256 FROM t1;
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2 SELECT x, x*x FROM t1;
+ }
+ expr {[file size test.db]>1024*12}
+} {1}
+integrity_check corrupt8-1.2
+
+# Loop through each ptrmap entry. Corrupt the entry and make sure the
+# corruption is detected by the integrity_check.
+#
+for {set i 1024} {$i<2048} {incr i 5} {
+ set oldval [hexio_read test.db $i 1]
+ if {$oldval==0} break
+ hexio_write test.db $i 00
+ do_test corrupt8-2.$i.0 {
+ db close
+ sqlite3 db test.db
+ set x [db eval {PRAGMA integrity_check}]
+ expr {$x!="ok"}
+ } {1}
+ for {set k 1} {$k<=5} {incr k} {
+ if {$k==$oldval} continue
+ hexio_write test.db $i 0$k
+ do_test corrupt8-2.$i.$k {
+ db close
+ sqlite3 db test.db
+ set x [db eval {PRAGMA integrity_check}]
+ expr {$x!="ok"}
+ } {1}
+ }
+ hexio_write test.db $i 06
+ do_test corrupt8-2.$i.6 {
+ db close
+ sqlite3 db test.db
+ set x [db eval {PRAGMA integrity_check}]
+ expr {$x!="ok"}
+ } {1}
+ hexio_write test.db $i $oldval
+ if {$oldval>2} {
+ set i2 [expr {$i+1+$i%4}]
+ set oldval [hexio_read test.db $i2 1]
+ hexio_write test.db $i2 [format %02x [expr {($oldval+1)&0xff}]]
+ do_test corrupt8-2.$i.7 {
+ db close
+ sqlite3 db test.db
+ set x [db eval {PRAGMA integrity_check}]
+ expr {$x!="ok"}
+ } {1}
+ hexio_write test.db $i2 $oldval
+ }
+}
+
+
+finish_test
diff --git a/test/corrupt9.test b/test/corrupt9.test
new file mode 100644
index 0000000..f199452
--- /dev/null
+++ b/test/corrupt9.test
@@ -0,0 +1,136 @@
+# 2008 July 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file. It specifically focuses
+# on corruption in the form of duplicate entries on the freelist.
+#
+# $Id: corrupt9.test,v 1.3 2009/06/04 02:47:04 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# We must have the page_size pragma for these tests to work.
+#
+ifcapable !pager_pragmas {
+ finish_test
+ return
+}
+
+# Return the offset to the first (trunk) page of the freelist. Return
+# zero of the freelist is empty.
+#
+proc freelist_trunk_offset {filename} {
+ if {[hexio_read $filename 36 4]==0} {return 0}
+ set pgno [hexio_get_int [hexio_read $filename 32 4]]
+ return [expr {($pgno-1)*[hexio_get_int [hexio_read $filename 16 2]]}]
+}
+
+# This procedure looks at the first trunk page of the freelist and
+# corrupts that page by overwriting up to N entries with duplicates
+# of the first entry.
+#
+proc corrupt_freelist {filename N} {
+ set offset [freelist_trunk_offset $filename]
+ if {$offset==0} {error "Freelist is empty"}
+ set cnt [hexio_get_int [hexio_read $filename [expr {$offset+4}] 4]]
+ set pgno [hexio_read $filename [expr {$offset+8}] 4]
+ for {set i 12} {$N>0 && $i<8+4*$cnt} {incr i 4; incr N -1} {
+ hexio_write $filename [expr {$offset+$i}] $pgno
+ }
+}
+
+# Create a database to work with. Make sure there are plenty of
+# entries on the freelist.
+#
+do_test corrupt9-1.1 {
+ execsql {
+ PRAGMA auto_vacuum=NONE;
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(1);
+ INSERT INTO t1(x) VALUES(2);
+ INSERT INTO t1(x) SELECT x+2 FROM t1;
+ INSERT INTO t1(x) SELECT x+4 FROM t1;
+ INSERT INTO t1(x) SELECT x+8 FROM t1;
+ INSERT INTO t1(x) SELECT x+16 FROM t1;
+ INSERT INTO t1(x) SELECT x+32 FROM t1;
+ INSERT INTO t1(x) SELECT x+64 FROM t1;
+ INSERT INTO t1(x) SELECT x+128 FROM t1;
+ INSERT INTO t1(x) SELECT x+256 FROM t1;
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2 SELECT x, x*x FROM t1;
+ CREATE INDEX i1 ON t1(x);
+ CREATE INDEX i2 ON t2(b,a);
+ DROP INDEX i2;
+ }
+ expr {[file size test.db]>1024*24}
+} {1}
+integrity_check corrupt9-1.2
+
+# Corrupt the freelist by adding duplicate entries to the freelist.
+# Make sure the corruption is detected.
+#
+db close
+forcecopy test.db test.db-template
+
+corrupt_freelist test.db 1
+sqlite3 db test.db
+do_test corrupt9-2.1 {
+ set x [db eval {PRAGMA integrity_check}]
+ expr {$x!="ok"}
+} {1}
+do_test corrupt9-2.2 {
+ catchsql {
+ CREATE INDEX i2 ON t2(b,a);
+ REINDEX;
+ }
+} {1 {database disk image is malformed}}
+
+
+db close
+forcecopy test.db-template test.db
+corrupt_freelist test.db 2
+sqlite3 db test.db
+do_test corrupt9-3.1 {
+ set x [db eval {PRAGMA integrity_check}]
+ expr {$x!="ok"}
+} {1}
+do_test corrupt9-3.2 {
+ catchsql {
+ CREATE INDEX i2 ON t2(b,a);
+ REINDEX;
+ }
+} {1 {database disk image is malformed}}
+
+db close
+forcecopy test.db-template test.db
+corrupt_freelist test.db 3
+sqlite3 db test.db
+do_test corrupt9-4.1 {
+ set x [db eval {PRAGMA integrity_check}]
+ expr {$x!="ok"}
+} {1}
+do_test corrupt9-4.2 {
+ catchsql {
+ CREATE INDEX i2 ON t2(b,a);
+ REINDEX;
+ }
+} {1 {database disk image is malformed}}
+
+
+finish_test
diff --git a/test/corruptA.test b/test/corruptA.test
new file mode 100644
index 0000000..8b76d3a
--- /dev/null
+++ b/test/corruptA.test
@@ -0,0 +1,79 @@
+# 2008 July 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file. It specifically focuses
+# on corrupt database headers.
+#
+# $Id: corruptA.test,v 1.1 2008/07/11 16:39:23 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+
+# Create a database to work with.
+#
+do_test corruptA-1.1 {
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(1);
+ }
+ expr {[file size test.db]>=1024}
+} {1}
+integrity_check corruptA-1.2
+
+# Corrupt the file header in various ways and make sure the corruption
+# is detected when opening the database file.
+#
+db close
+forcecopy test.db test.db-template
+
+set unreadable_version 02
+ifcapable wal { set unreadable_version 03 }
+do_test corruptA-2.1 {
+ forcecopy test.db-template test.db
+ hexio_write test.db 19 $unreadable_version ;# the read format number
+ sqlite3 db test.db
+ catchsql {SELECT * FROM t1}
+} {1 {file is encrypted or is not a database}}
+
+do_test corruptA-2.2 {
+ db close
+ forcecopy test.db-template test.db
+ hexio_write test.db 21 41 ;# max embedded payload fraction
+ sqlite3 db test.db
+ catchsql {SELECT * FROM t1}
+} {1 {file is encrypted or is not a database}}
+
+do_test corruptA-2.3 {
+ db close
+ forcecopy test.db-template test.db
+ hexio_write test.db 22 1f ;# min embedded payload fraction
+ sqlite3 db test.db
+ catchsql {SELECT * FROM t1}
+} {1 {file is encrypted or is not a database}}
+
+do_test corruptA-2.4 {
+ db close
+ forcecopy test.db-template test.db
+ hexio_write test.db 23 21 ;# min leaf payload fraction
+ sqlite3 db test.db
+ catchsql {SELECT * FROM t1}
+} {1 {file is encrypted or is not a database}}
+
+
+finish_test
diff --git a/test/corruptB.test b/test/corruptB.test
new file mode 100644
index 0000000..0ff2d6e
--- /dev/null
+++ b/test/corruptB.test
@@ -0,0 +1,189 @@
+# 2008 Sep 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file. It specifically focuses
+# on loops in the B-Tree structure. A loop is formed in a B-Tree structure
+# when there exists a page that is both an a descendent or ancestor of
+# itself.
+#
+# Also test that an SQLITE_CORRUPT error is returned if a B-Tree page
+# contains a (corrupt) reference to a page greater than the configured
+# maximum page number.
+#
+# $Id: corruptB.test,v 1.4 2009/07/21 19:25:24 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+
+do_test corruptB-1.1 {
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(200));
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ }
+ expr {[file size test.db] > (1024*9)}
+} {1}
+integrity_check corruptB-1.2
+
+forcecopy test.db bak.db
+
+# Set the right-child of a B-Tree rootpage to refer to the root-page itself.
+#
+do_test corruptB-1.3.1 {
+ set ::root [execsql {SELECT rootpage FROM sqlite_master}]
+ set ::offset [expr {($::root-1)*1024}]
+ hexio_write test.db [expr $offset+8] [hexio_render_int32 $::root]
+} {4}
+do_test corruptB-1.3.2 {
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 }
+} {1 {database disk image is malformed}}
+
+# Set the left-child of a cell in a B-Tree rootpage to refer to the
+# root-page itself.
+#
+do_test corruptB-1.4.1 {
+ db close
+ forcecopy bak.db test.db
+ set cell_offset [hexio_get_int [hexio_read test.db [expr $offset+12] 2]]
+ hexio_write test.db [expr $offset+$cell_offset] [hexio_render_int32 $::root]
+} {4}
+do_test corruptB-1.4.2 {
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 }
+} {1 {database disk image is malformed}}
+
+# Now grow the table B-Tree so that it is more than 2 levels high.
+#
+do_test corruptB-1.5.1 {
+ db close
+ forcecopy bak.db test.db
+ sqlite3 db test.db
+ execsql {
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ }
+} {}
+
+forcecopy test.db bak.db
+
+# Set the right-child pointer of the right-child of the root page to point
+# back to the root page.
+#
+do_test corruptB-1.6.1 {
+ db close
+ set iRightChild [hexio_get_int [hexio_read test.db [expr $offset+8] 4]]
+ set c_offset [expr ($iRightChild-1)*1024]
+ hexio_write test.db [expr $c_offset+8] [hexio_render_int32 $::root]
+} {4}
+do_test corruptB-1.6.2 {
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 }
+} {1 {database disk image is malformed}}
+
+# Set the left-child pointer of a cell of the right-child of the root page to
+# point back to the root page.
+#
+do_test corruptB-1.7.1 {
+ db close
+ forcecopy bak.db test.db
+ set cell_offset [hexio_get_int [hexio_read test.db [expr $c_offset+12] 2]]
+ hexio_write test.db [expr $c_offset+$cell_offset] [hexio_render_int32 $::root]
+} {4}
+do_test corruptB-1.7.2 {
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 }
+} {1 {database disk image is malformed}}
+
+do_test corruptB-1.8.1 {
+ db close
+ set cell_offset [hexio_get_int [hexio_read test.db [expr $offset+12] 2]]
+ set iLeftChild [
+ hexio_get_int [hexio_read test.db [expr $offset+$cell_offset] 4]
+ ]
+ set c_offset [expr ($iLeftChild-1)*1024]
+ hexio_write test.db [expr $c_offset+8] [hexio_render_int32 $::root]
+} {4}
+do_test corruptB-1.8.2 {
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 }
+} {1 {database disk image is malformed}}
+
+# Set the left-child pointer of a cell of the right-child of the root page to
+# point back to the root page.
+#
+do_test corruptB-1.9.1 {
+ db close
+ forcecopy bak.db test.db
+ set cell_offset [hexio_get_int [hexio_read test.db [expr $c_offset+12] 2]]
+ hexio_write test.db [expr $c_offset+$cell_offset] [hexio_render_int32 $::root]
+} {4}
+do_test corruptB-1.9.2 {
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 }
+} {1 {database disk image is malformed}}
+
+#---------------------------------------------------------------------------
+
+do_test corruptB-2.1.1 {
+ db close
+ forcecopy bak.db test.db
+ hexio_write test.db [expr $offset+8] [hexio_render_int32 0x6FFFFFFF]
+} {4}
+do_test corruptB-2.1.2 {
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 }
+} {1 {database disk image is malformed}}
+
+#---------------------------------------------------------------------------
+
+# Corrupt the header-size field of a database record.
+#
+do_test corruptB-3.1.1 {
+ db close
+ forcecopy bak.db test.db
+ sqlite3 db test.db
+ set v [string repeat abcdefghij 200]
+ execsql {
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES($v);
+ }
+ set t2_root [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't2'}]
+ set iPage [expr ($t2_root-1)*1024]
+ set iCellarray [expr $iPage + 8]
+ set iRecord [hexio_get_int [hexio_read test.db $iCellarray 2]]
+ db close
+ hexio_write test.db [expr $iPage+$iRecord+3] FF00
+} {2}
+do_test corruptB-3.1.2 {
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t2 }
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/corruptC.test b/test/corruptC.test
new file mode 100644
index 0000000..34e81a1
--- /dev/null
+++ b/test/corruptC.test
@@ -0,0 +1,407 @@
+# 2004 August 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file. It creates a base
+# data base file, then tests that single byte corruptions in
+# increasingly larger quantities are handled gracefully.
+#
+# $Id: corruptC.test,v 1.14 2009/07/11 06:55:34 danielk1977 Exp $
+
+catch {forcedelete test.db test.db-journal test.bu}
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Construct a compact, dense database for testing.
+#
+do_test corruptC-1.1 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA legacy_file_format=1;
+ BEGIN;
+ CREATE TABLE t1(x,y);
+ INSERT INTO t1 VALUES(1,1);
+ INSERT OR IGNORE INTO t1 SELECT x*2,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*3,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*5,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*7,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*11,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*13,y FROM t1;
+ CREATE INDEX t1i1 ON t1(x);
+ CREATE TABLE t2 AS SELECT x,2 as y FROM t1 WHERE rowid%5!=0;
+ COMMIT;
+ }
+} {}
+
+ifcapable {integrityck} {
+ integrity_check corruptC-1.2
+}
+
+# Generate random integer
+#
+proc random {range} {
+ return [expr {round(rand()*$range)}]
+}
+
+# Setup for the tests. Make a backup copy of the good database in test.bu.
+#
+db close
+forcecopy test.db test.bu
+sqlite3 db test.db
+set fsize [file size test.db]
+
+# Set a quasi-random random seed.
+if {[info exists ::G(issoak)]} {
+ # If we are doing SOAK tests, we want a different
+ # random seed for each run. Ideally we would like
+ # to use [clock clicks] or something like that here.
+ set qseed [file mtime test.db]
+} else {
+ # If we are not doing soak tests,
+ # make it repeatable.
+ set qseed 0
+}
+expr srand($qseed)
+
+#
+# First test some specific corruption tests found from earlier runs
+# with specific seeds.
+#
+
+# test that a corrupt content offset size is handled (seed 5577)
+do_test corruptC-2.1 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 2053 [format %02x 0x04]
+
+ sqlite3 db test.db
+ catchsql {PRAGMA integrity_check}
+} {1 {database disk image is malformed}}
+
+# test that a corrupt content offset size is handled (seed 5649)
+do_test corruptC-2.2 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 27 [format %02x 0x08]
+ hexio_write test.db 233 [format %02x 0x6a]
+ hexio_write test.db 328 [format %02x 0x67]
+ hexio_write test.db 750 [format %02x 0x1f]
+ hexio_write test.db 1132 [format %02x 0x52]
+ hexio_write test.db 1133 [format %02x 0x84]
+ hexio_write test.db 1220 [format %02x 0x01]
+ hexio_write test.db 3688 [format %02x 0xc1]
+ hexio_write test.db 3714 [format %02x 0x58]
+ hexio_write test.db 3746 [format %02x 0x9a]
+
+ sqlite3 db test.db
+ catchsql {UPDATE t1 SET y=1}
+} {1 {database disk image is malformed}}
+
+# test that a corrupt free cell size is handled (seed 13329)
+do_test corruptC-2.3 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 1094 [format %02x 0x76]
+
+ sqlite3 db test.db
+ catchsql {UPDATE t1 SET y=1}
+} {1 {database disk image is malformed}}
+
+# test that a corrupt free cell size is handled (seed 169571)
+do_test corruptC-2.4 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 3119 [format %02x 0xdf]
+
+ sqlite3 db test.db
+ catchsql {UPDATE t2 SET y='abcdef-uvwxyz'}
+} {1 {database disk image is malformed}}
+
+# test that a corrupt free cell size is handled (seed 169571)
+do_test corruptC-2.5 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 3119 [format %02x 0xdf]
+ hexio_write test.db 4073 [format %02x 0xbf]
+
+ sqlite3 db test.db
+ catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}
+ catchsql {PRAGMA integrity_check}
+} {0 {{*** in database main ***
+Page 4: btreeInitPage() returns error code 11}}}
+
+# {0 {{*** in database main ***
+# Corruption detected in cell 710 on page 4
+# Multiple uses for byte 661 of page 4
+# Fragmented space is 249 byte reported as 21 on page 4}}}
+
+# test that a corrupt free cell size is handled (seed 169595)
+do_test corruptC-2.6 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 619 [format %02x 0xe2]
+ hexio_write test.db 3150 [format %02x 0xa8]
+
+ sqlite3 db test.db
+ catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}
+} {1 {database disk image is malformed}}
+
+# corruption (seed 178692)
+do_test corruptC-2.7 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 3074 [format %02x 0xa0]
+
+ sqlite3 db test.db
+ catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}
+} {1 {database disk image is malformed}}
+
+# corruption (seed 179069)
+do_test corruptC-2.8 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 1393 [format %02x 0x7d]
+ hexio_write test.db 84 [format %02x 0x19]
+ hexio_write test.db 3287 [format %02x 0x3b]
+ hexio_write test.db 2564 [format %02x 0xed]
+ hexio_write test.db 2139 [format %02x 0x55]
+
+ sqlite3 db test.db
+ catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;}
+} {1 {database disk image is malformed}}
+
+# corruption (seed 170434)
+do_test corruptC-2.9 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 2095 [format %02x 0xd6]
+
+ sqlite3 db test.db
+ catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;}
+} {1 {database disk image is malformed}}
+
+# corruption (seed 186504)
+do_test corruptC-2.10 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 3130 [format %02x 0x02]
+
+ sqlite3 db test.db
+ catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}
+} {1 {database disk image is malformed}}
+
+# corruption (seed 1589)
+do_test corruptC-2.11 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 55 [format %02x 0xa7]
+
+ sqlite3 db test.db
+ catchsql {BEGIN; CREATE TABLE t3 AS SELECT x,3 as y FROM t2 WHERE rowid%5!=0; ROLLBACK;}
+} {1 {database disk image is malformed}}
+
+# corruption (seed 14166)
+do_test corruptC-2.12 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 974 [format %02x 0x2e]
+
+ sqlite3 db test.db
+ catchsql {SELECT count(*) FROM sqlite_master;}
+} {1 {malformed database schema (t1i1) - corrupt database}}
+
+# corruption (seed 218803)
+do_test corruptC-2.13 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 102 [format %02x 0x12]
+
+ sqlite3 db test.db
+ catchsql {BEGIN; CREATE TABLE t3 AS SELECT x,3 as y FROM t2 WHERE rowid%5!=0; ROLLBACK;}
+} {1 {database disk image is malformed}}
+
+do_test corruptC-2.14 {
+ db close
+ forcecopy test.bu test.db
+
+ sqlite3 db test.db
+ set blob [string repeat abcdefghij 10000]
+ execsql { INSERT INTO t1 VALUES (1, $blob) }
+
+ sqlite3 db test.db
+ set filesize [file size test.db]
+ hexio_write test.db [expr $filesize-2048] 00000001
+ catchsql {DELETE FROM t1 WHERE rowid = (SELECT max(rowid) FROM t1)}
+} {1 {database disk image is malformed}}
+
+# At one point this particular corrupt database was causing a buffer
+# overread. Which caused a crash in a run of all.test once.
+#
+do_test corruptC-2.15 {
+ db close
+ forcecopy test.bu test.db
+ hexio_write test.db 986 b9
+ sqlite3 db test.db
+ catchsql {SELECT count(*) FROM sqlite_master;}
+} {1 {malformed database schema (t1i1) - no such table: main.t1}}
+
+#
+# Now test for a series of quasi-random seeds.
+# We loop over the entire file size and touch
+# each byte at least once.
+for {set tn 0} {$tn<$fsize} {incr tn 1} {
+
+ # setup for test
+ db close
+ forcecopy test.bu test.db
+ sqlite3 db test.db
+
+ # Seek to a random location in the file, and write a random single byte
+ # value. Then do various operations on the file to make sure that
+ # the database engine can handle the corruption gracefully.
+ #
+ set last 0
+ for {set i 1} {$i<=512 && !$last} {incr i 1} {
+
+ db close
+ if {$i==1} {
+ # on the first corrupt value, use location $tn
+ # this ensures that we touch each location in the
+ # file at least once.
+ set roffset $tn
+ } else {
+ # insert random byte at random location
+ set roffset [random $fsize]
+ }
+ set rbyte [format %02x [random 255]]
+
+ # You can uncomment the following to have it trace
+ # exactly how it's corrupting the file. This is
+ # useful for generating the "seed specific" tests
+ # above.
+ # set rline "$roffset $rbyte"
+ # puts stdout $rline
+
+ hexio_write test.db $roffset $rbyte
+ sqlite3 db test.db
+
+ # do a few random operations to make sure that if
+ # they error, they error gracefully instead of crashing.
+ do_test corruptC-3.$tn.($qseed).$i.1 {
+ catchsql {SELECT count(*) FROM sqlite_master}
+ set x {}
+ } {}
+ do_test corruptC-3.$tn.($qseed).$i.2 {
+ catchsql {SELECT count(*) FROM t1}
+ set x {}
+ } {}
+ do_test corruptC-3.$tn.($qseed).$i.3 {
+ catchsql {SELECT count(*) FROM t1 WHERE x>13}
+ set x {}
+ } {}
+ do_test corruptC-3.$tn.($qseed).$i.4 {
+ catchsql {SELECT count(*) FROM t2}
+ set x {}
+ } {}
+ do_test corruptC-3.$tn.($qseed).$i.5 {
+ catchsql {SELECT count(*) FROM t2 WHERE x<13}
+ set x {}
+ } {}
+ do_test corruptC-3.$tn.($qseed).$i.6 {
+ catchsql {BEGIN; UPDATE t1 SET y=1; ROLLBACK;}
+ set x {}
+ } {}
+ do_test corruptC-3.$tn.($qseed).$i.7 {
+ catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}
+ set x {}
+ } {}
+ do_test corruptC-3.$tn.($qseed).$i.8 {
+ catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;}
+ set x {}
+ } {}
+ do_test corruptC-3.$tn.($qseed).$i.9 {
+ catchsql {BEGIN; DELETE FROM t2 WHERE x<13; ROLLBACK;}
+ set x {}
+ } {}
+ do_test corruptC-3.$tn.($qseed).$i.10 {
+ catchsql {BEGIN; CREATE TABLE t3 AS SELECT x,3 as y FROM t2 WHERE rowid%5!=0; ROLLBACK;}
+ set x {}
+ } {}
+
+ # check the integrity of the database.
+ # once the corruption is detected, we can stop.
+ ifcapable {integrityck} {
+ set res [ catchsql {PRAGMA integrity_check} ]
+ set ans [lindex $res 1]
+ if { [ string compare $ans "ok" ] != 0 } {
+ set last -1
+ }
+ }
+ # if we are not capable of doing an integrity check,
+ # stop after corrupting 5 bytes.
+ ifcapable {!integrityck} {
+ if { $i > 5 } {
+ set last -1
+ }
+ }
+
+ # Check that no page references were leaked.
+ # TBD: need to figure out why this doesn't work
+ # work with ROLLBACKs...
+ if {0} {
+ do_test corruptC-3.$tn.($qseed).$i.11 {
+ set bt [btree_from_db db]
+ db_enter db
+ array set stats [btree_pager_stats $bt]
+ db_leave db
+ set stats(ref)
+ } {0}
+ }
+ }
+ # end for i
+
+}
+# end for tn
+
+finish_test
diff --git a/test/corruptD.test b/test/corruptD.test
new file mode 100644
index 0000000..393d41e
--- /dev/null
+++ b/test/corruptD.test
@@ -0,0 +1,140 @@
+# 2009 June 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: corruptD.test,v 1.2 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+#--------------------------------------------------------------------------
+# OVERVIEW
+#
+# This test file attempts to verify that SQLite does not read past the
+# end of any in-memory buffers as a result of corrupted database page
+# images. Usually this happens because a field within a database page
+# that contains an offset to some other structure within the same page
+# is set to too large a value. A database page contains the following
+# such fields:
+#
+# 1. The page header field that contains the offset to the first
+# free block of space.
+#
+# 2. The first two bytes of all but the last free block on the free-block
+# list (the offset to the next free block).
+#
+# 3. The page header field containing the number of cells on the page
+# (implicitly defines the offset to the final element in the cell offset
+# array, which could potentially be off the end of the page).
+#
+# 4. The page header field containing the offset to the start of the cell
+# content area.
+#
+# 5. The contents of the cell offset array.
+#
+# 6. The first few bytes of each cell determine the size of the cell
+# stored within the page, and hence the offset to the final byte of
+# the cell.
+#
+# If any of the above fields are set to too large a value, then a buffer
+# overread may occur. This test script creates and operates on various
+# strategically corrupted database files to attempt to provoke such buffer
+# overreads.
+#
+# Very often, a buffer overread passes unnoticed, particularly in workstation
+# environments. For this reason, this test script should be run using valgrind
+# (or similar) in order to verify that no overreads occur.
+#
+# TEST PLAN
+#
+# Test cases corruptD-1.* are white-box tests. They attempt to corrupt
+# one of the above fields, then exercise each part of the code in btree.c
+# that uses said field.
+#
+# Offset variables 1, 2, 3 and 4 are all checked to make sure they
+# will not result in buffer overruns as part of page initialization in
+# sqlite3BtreeInitPage(). Offsets 5 and 6 cannot be tested as part of
+# page initialization, as trying to do so causes a performance hit.
+#
+
+do_test corruptD-1.0 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ }
+ for {set ii 1} {$ii < 50} {incr ii} {
+ execsql { INSERT INTO t1 VALUES($ii, $ii * $ii) }
+ }
+ execsql {
+ DELETE FROM t1 WHERE a = 10;
+ DELETE FROM t1 WHERE a = 20;
+ DELETE FROM t1 WHERE a = 30;
+ DELETE FROM t1 WHERE a = 40;
+ }
+ forcecopy test.db test.bu
+} {}
+
+proc incr_change_counter {} {
+ hexio_write test.db 24 [
+ hexio_render_int32 [expr [hexio_get_int [hexio_read test.db 24 4]] + 1]
+ ]
+}
+
+proc restore_file {} {
+ db close
+ forcecopy test.bu test.db
+ sqlite3 db test.db
+}
+
+#-------------------------------------------------------------------------
+# The following tests, corruptD-1.1.*, focus on the page header field
+# containing the offset of the first free block in a page.
+#
+do_test corruptD-1.1.1 {
+ incr_change_counter
+ hexio_write test.db [expr 1024+1] FFFF
+ catchsql { SELECT * FROM t1 }
+} {1 {database disk image is malformed}}
+do_test corruptD-1.1.2 {
+ incr_change_counter
+ hexio_write test.db [expr 1024+1] [hexio_render_int32 1021]
+ catchsql { SELECT * FROM t1 }
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+# The following tests, corruptD-1.2.*, focus on the offsets contained
+# in the first 2 byte of each free-block on the free-list.
+#
+do_test corruptD-1.2.1 {
+ restore_file
+} {}
+do_test corruptD-1.2.2 {
+} {}
+
+#-------------------------------------------------------------------------
+# The following tests, corruptD-1.4.*, ...
+#
+
+
+#-------------------------------------------------------------------------
+# The following tests, corruptD-1.5.*, focus on the offsets contained
+# in the cell offset array.
+#
+# defragmentPage
+#
+
+finish_test
diff --git a/test/corruptE.test b/test/corruptE.test
new file mode 100644
index 0000000..507721d
--- /dev/null
+++ b/test/corruptE.test
@@ -0,0 +1,175 @@
+# 2010 February 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite does not crash or
+# segfault if it sees a corrupt database file. It specifcally
+# focuses on rowid order corruption.
+#
+# $Id: corruptE.test,v 1.14 2009/07/11 06:55:34 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Do not run the tests in this file if ENABLE_OVERSIZE_CELL_CHECK is on.
+#
+ifcapable oversize_cell_check {
+ finish_test
+ return
+}
+
+# Construct a compact, dense database for testing.
+#
+do_test corruptE-1.1 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA legacy_file_format=1;
+ BEGIN;
+ CREATE TABLE t1(x,y);
+ INSERT INTO t1 VALUES(1,1);
+ INSERT OR IGNORE INTO t1 SELECT x*2,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*3,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*5,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*7,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*11,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*13,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*17,y FROM t1;
+ INSERT OR IGNORE INTO t1 SELECT x*19,y FROM t1;
+ CREATE INDEX t1i1 ON t1(x);
+ CREATE TABLE t2 AS SELECT x,2 as y FROM t1 WHERE rowid%5!=0;
+ COMMIT;
+ }
+} {}
+
+ifcapable {integrityck} {
+ integrity_check corruptE-1.2
+}
+
+# Setup for the tests. Make a backup copy of the good database in test.bu.
+#
+db close
+forcecopy test.db test.bu
+sqlite3 db test.db
+set fsize [file size test.db]
+
+
+do_test corruptE-2.1 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 2041 [format %02x 0x2e]
+
+ sqlite3 db test.db
+
+ set res [ catchsql {PRAGMA integrity_check} ]
+ set ans [lindex $res 1]
+
+ list [regexp {out of order.*previous was} $ans] \
+ [regexp {out of order.*max larger than parent max} $ans]
+} {1 1}
+
+do_test corruptE-2.2 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 2047 [format %02x 0x84]
+
+ sqlite3 db test.db
+
+ set res [ catchsql {PRAGMA integrity_check} ]
+ set ans [lindex $res 1]
+
+ list [regexp {out of order.*previous was} $ans] \
+ [regexp {out of order.*min less than parent min} $ans]
+} {1 1}
+
+do_test corruptE-2.3 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 7420 [format %02x 0xa8]
+ hexio_write test.db 10459 [format %02x 0x8d]
+
+ sqlite3 db test.db
+
+ set res [ catchsql {PRAGMA integrity_check} ]
+ set ans [lindex $res 1]
+
+ list [regexp {out of order.*max larger than parent min} $ans]
+} {1}
+
+do_test corruptE-2.4 {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db 10233 [format %02x 0xd0]
+
+ sqlite3 db test.db
+
+ set res [ catchsql {PRAGMA integrity_check} ]
+ set ans [lindex $res 1]
+
+ list [regexp {out of order.*min less than parent max} $ans]
+} {1}
+
+
+set tests [list {10233 0xd0} \
+ {941 0x42} \
+ {1028 0x53} \
+ {2041 0xd0} \
+ {2042 0x1f} \
+ {2047 0xaa} \
+ {2263 0x29} \
+ {2274 0x75} \
+ {3267 0xf2} \
+ {4104 0x2c} \
+ {5113 0x36} \
+ {10233 0x84} \
+ {10234 0x74} \
+ {10239 0x41} \
+ {10453 0x11} \
+ {11273 0x28} \
+ {11455 0x11} \
+ {11461 0xe6} \
+ {12281 0x99} \
+ {12296 0x9e} \
+ {12297 0xd7} \
+ {13303 0x53} ]
+
+set tc 1
+foreach test $tests {
+ do_test corruptE-3.$tc {
+ db close
+ forcecopy test.bu test.db
+
+ # insert corrupt byte(s)
+ hexio_write test.db [lindex $test 0] [format %02x [lindex $test 1]]
+
+ sqlite3 db test.db
+
+ set res [ catchsql {PRAGMA integrity_check} ]
+ set ans [lindex $res 1]
+
+ list [regexp {out of order} $ans]
+ } {1}
+ incr tc 1
+}
+
+finish_test
diff --git a/test/count.test b/test/count.test
new file mode 100644
index 0000000..fbdd13b
--- /dev/null
+++ b/test/count.test
@@ -0,0 +1,192 @@
+# 2009 February 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing "SELECT count(*)" statements.
+#
+# $Id: count.test,v 1.6 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Test plan:
+#
+# count-0.*: Make sure count(*) works on an empty database. (Ticket #3774)
+#
+# count-1.*: Test that the OP_Count instruction appears to work on both
+# tables and indexes. Test both when they contain 0 entries,
+# when all entries are on the root page, and when the b-tree
+# forms a structure 2 and 3 levels deep.
+#
+# count-2.*: Test that
+#
+#
+
+do_test count-0.1 {
+ db eval {
+ SELECT count(*) FROM sqlite_master;
+ }
+} {0}
+
+set iTest 0
+foreach zIndex [list {
+ /* no-op */
+} {
+ CREATE INDEX i1 ON t1(a);
+}] {
+ incr iTest
+ do_test count-1.$iTest.1 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a, b);
+ }
+ execsql $zIndex
+ execsql { SELECT count(*) FROM t1 }
+ } {0}
+
+ do_test count-1.$iTest.2 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ SELECT count(*) FROM t1;
+ }
+ } {2}
+
+ do_test count-1.$iTest.3 {
+ execsql {
+ INSERT INTO t1 SELECT * FROM t1; -- 4
+ INSERT INTO t1 SELECT * FROM t1; -- 8
+ INSERT INTO t1 SELECT * FROM t1; -- 16
+ INSERT INTO t1 SELECT * FROM t1; -- 32
+ INSERT INTO t1 SELECT * FROM t1; -- 64
+ INSERT INTO t1 SELECT * FROM t1; -- 128
+ INSERT INTO t1 SELECT * FROM t1; -- 256
+ SELECT count(*) FROM t1;
+ }
+ } {256}
+
+ do_test count-1.$iTest.4 {
+ execsql {
+ INSERT INTO t1 SELECT * FROM t1; -- 512
+ INSERT INTO t1 SELECT * FROM t1; -- 1024
+ INSERT INTO t1 SELECT * FROM t1; -- 2048
+ INSERT INTO t1 SELECT * FROM t1; -- 4096
+ SELECT count(*) FROM t1;
+ }
+ } {4096}
+
+ do_test count-1.$iTest.5 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 SELECT * FROM t1; -- 8192
+ INSERT INTO t1 SELECT * FROM t1; -- 16384
+ INSERT INTO t1 SELECT * FROM t1; -- 32768
+ INSERT INTO t1 SELECT * FROM t1; -- 65536
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+ } {65536}
+}
+
+proc uses_op_count {sql} {
+ if {[lsearch [execsql "EXPLAIN $sql"] Count]>=0} {
+ return 1;
+ }
+ return 0
+}
+
+do_test count-2.1 {
+ execsql {
+ CREATE TABLE t2(a, b);
+ }
+ uses_op_count {SELECT count(*) FROM t2}
+} {1}
+do_test count-2.2 {
+ catchsql {SELECT count(DISTINCT *) FROM t2}
+} {1 {near "*": syntax error}}
+do_test count-2.3 {
+ uses_op_count {SELECT count(DISTINCT a) FROM t2}
+} {0}
+do_test count-2.4 {
+ uses_op_count {SELECT count(a) FROM t2}
+} {0}
+do_test count-2.5 {
+ uses_op_count {SELECT count() FROM t2}
+} {1}
+do_test count-2.6 {
+ catchsql {SELECT count(DISTINCT) FROM t2}
+} {1 {DISTINCT aggregates must have exactly one argument}}
+do_test count-2.7 {
+ uses_op_count {SELECT count(*)+1 FROM t2}
+} {0}
+do_test count-2.8 {
+ uses_op_count {SELECT count(*) FROM t2 WHERE a IS NOT NULL}
+} {0}
+do_test count-2.9 {
+ catchsql {SELECT count(*) FROM t2 HAVING count(*)>1}
+} {1 {a GROUP BY clause is required before HAVING}}
+do_test count-2.10 {
+ uses_op_count {SELECT count(*) FROM (SELECT 1)}
+} {0}
+do_test count-2.11 {
+ execsql { CREATE VIEW v1 AS SELECT 1 AS a }
+ uses_op_count {SELECT count(*) FROM v1}
+} {0}
+do_test count-2.12 {
+ uses_op_count {SELECT count(*), max(a) FROM t2}
+} {0}
+do_test count-2.13 {
+ uses_op_count {SELECT count(*) FROM t1, t2}
+} {0}
+
+ifcapable vtab {
+ register_echo_module [sqlite3_connection_pointer db]
+ do_test count-2.14 {
+ execsql { CREATE VIRTUAL TABLE techo USING echo(t1); }
+ uses_op_count {SELECT count(*) FROM techo}
+ } {0}
+}
+
+do_test count-3.1 {
+ execsql {
+ CREATE TABLE t3(a, b);
+ SELECT a FROM (SELECT count(*) AS a FROM t3) WHERE a==0;
+ }
+} {0}
+do_test count-3.2 {
+ execsql {
+ SELECT a FROM (SELECT count(*) AS a FROM t3) WHERE a==1;
+ }
+} {}
+
+do_test count-4.1 {
+ execsql {
+ CREATE TABLE t4(a, b);
+ INSERT INTO t4 VALUES('a', 'b');
+ CREATE INDEX t4i1 ON t4(b, a);
+ SELECT count(*) FROM t4;
+ }
+} {1}
+do_test count-4.2 {
+ execsql {
+ CREATE INDEX t4i2 ON t4(b);
+ SELECT count(*) FROM t4;
+ }
+} {1}
+do_test count-4.3 {
+ execsql {
+ DROP INDEX t4i1;
+ CREATE INDEX t4i1 ON t4(b, a);
+ SELECT count(*) FROM t4;
+ }
+} {1}
+
+
+finish_test
diff --git a/test/crash.test b/test/crash.test
new file mode 100644
index 0000000..f644dca
--- /dev/null
+++ b/test/crash.test
@@ -0,0 +1,411 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# The focus of this file is testing the ability of the database to
+# uses its rollback journal to recover intact (no database corruption)
+# from a power failure during the middle of a COMMIT. The OS interface
+# modules are overloaded using the modified I/O routines found in test6.c.
+# These routines allow us to simulate the kind of file damage that
+# occurs after a power failure.
+#
+# $Id: crash.test,v 1.27 2008/01/08 15:18:52 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !crashtest {
+ finish_test
+ return
+}
+
+set repeats 100
+#set repeats 10
+
+# The following procedure computes a "signature" for table "abc". If
+# abc changes in any way, the signature should change.
+proc signature {} {
+ return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
+}
+proc signature2 {} {
+ return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc2}]
+}
+
+#--------------------------------------------------------------------------
+# Simple crash test:
+#
+# crash-1.1: Create a database with a table with two rows.
+# crash-1.2: Run a 'DELETE FROM abc WHERE a = 1' that crashes during
+# the first journal-sync.
+# crash-1.3: Ensure the database is in the same state as after crash-1.1.
+# crash-1.4: Run a 'DELETE FROM abc WHERE a = 1' that crashes during
+# the first database-sync.
+# crash-1.5: Ensure the database is in the same state as after crash-1.1.
+# crash-1.6: Run a 'DELETE FROM abc WHERE a = 1' that crashes during
+# the second journal-sync.
+# crash-1.7: Ensure the database is in the same state as after crash-1.1.
+#
+# Tests 1.8 through 1.11 test for crashes on the third journal sync and
+# second database sync. Neither of these is required in such a small test
+# case, so these tests are just to verify that the test infrastructure
+# operates as expected.
+#
+do_test crash-1.1 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(4, 5, 6);
+ }
+ set ::sig [signature]
+ expr 0
+} {0}
+for {set i 0} {$i<10} {incr i} {
+ set seed [expr {int(abs(rand()*10000))}]
+ do_test crash-1.2.$i {
+ crashsql -delay 1 -file test.db-journal -seed $seed {
+ DELETE FROM abc WHERE a = 1;
+ }
+ } {1 {child process exited abnormally}}
+ do_test crash-1.3.$i {
+ signature
+ } $::sig
+}
+do_test crash-1.4 {
+ crashsql -delay 1 -file test.db {
+ DELETE FROM abc WHERE a = 1;
+ }
+} {1 {child process exited abnormally}}
+do_test crash-1.5 {
+ signature
+} $::sig
+do_test crash-1.6 {
+ crashsql -delay 2 -file test.db-journal {
+ DELETE FROM abc WHERE a = 1;
+ }
+} {1 {child process exited abnormally}}
+do_test crash-1.7 {
+ catchsql {
+ SELECT * FROM abc;
+ }
+} {0 {1 2 3 4 5 6}}
+
+do_test crash-1.8 {
+ crashsql -delay 3 -file test.db-journal {
+ DELETE FROM abc WHERE a = 1;
+ }
+} {0 {}}
+do_test crash-1.9 {
+ catchsql {
+ SELECT * FROM abc;
+ }
+} {0 {4 5 6}}
+do_test crash-1.10 {
+ crashsql -delay 2 -file test.db {
+ DELETE FROM abc WHERE a = 4;
+ }
+} {0 {}}
+do_test crash-1.11 {
+ catchsql {
+ SELECT * FROM abc;
+ }
+} {0 {}}
+
+#--------------------------------------------------------------------------
+# The following tests test recovery when both the database file and the the
+# journal file contain corrupt data. This can happen after pages are
+# written to the database file before a transaction is committed due to
+# cache-pressure.
+#
+# crash-2.1: Insert 18 pages of data into the database.
+# crash-2.2: Check the database file size looks ok.
+# crash-2.3: Delete 15 or so pages (with a 10 page page-cache), then crash.
+# crash-2.4: Ensure the database is in the same state as after crash-2.1.
+#
+# Test cases crash-2.5 and crash-2.6 check that the database is OK if the
+# crash occurs during the main database file sync. But this isn't really
+# different from the crash-1.* cases.
+#
+do_test crash-2.1 {
+ execsql { BEGIN }
+ for {set n 0} {$n < 1000} {incr n} {
+ execsql "INSERT INTO abc VALUES($n, [expr 2*$n], [expr 3*$n])"
+ }
+ execsql { COMMIT }
+ set ::sig [signature]
+ execsql { SELECT sum(a), sum(b), sum(c) from abc }
+} {499500 999000 1498500}
+do_test crash-2.2 {
+ expr ([file size test.db] / 1024)>16
+} {1}
+do_test crash-2.3 {
+ crashsql -delay 2 -file test.db-journal {
+ DELETE FROM abc WHERE a < 800;
+ }
+} {1 {child process exited abnormally}}
+do_test crash-2.4 {
+ signature
+} $sig
+do_test crash-2.5 {
+ crashsql -delay 1 -file test.db {
+ DELETE FROM abc WHERE a<800;
+ }
+} {1 {child process exited abnormally}}
+do_test crash-2.6 {
+ signature
+} $sig
+
+#--------------------------------------------------------------------------
+# The crash-3.* test cases are essentially the same test as test case
+# crash-2.*, but with a more complicated data set.
+#
+# The test is repeated a few times with different seeds for the random
+# number generator in the crashing executable. Because there is no way to
+# seed the random number generator directly, some SQL is added to the test
+# case to 'use up' a different quantity random numbers before the test SQL
+# is executed.
+#
+
+# Make sure the file is much bigger than the pager-cache (10 pages). This
+# ensures that cache-spills happen regularly.
+do_test crash-3.0 {
+ execsql {
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ }
+ expr ([file size test.db] / 1024) > 450
+} {1}
+for {set i 1} {$i < $repeats} {incr i} {
+ set sig [signature]
+ do_test crash-3.$i.1 {
+ set seed [expr {int(abs(rand()*10000))}]
+ crashsql -delay [expr $i%5 + 1] -file test.db-journal -seed $seed "
+ BEGIN;
+ SELECT random() FROM abc LIMIT $i;
+ INSERT INTO abc VALUES(randstr(10,10), 0, 0);
+ DELETE FROM abc WHERE random()%10!=0;
+ COMMIT;
+ "
+ } {1 {child process exited abnormally}}
+ do_test crash-3.$i.2 {
+ signature
+ } $sig
+}
+
+#--------------------------------------------------------------------------
+# The following test cases - crash-4.* - test the correct recovery of the
+# database when a crash occurs during a multi-file transaction.
+#
+# crash-4.1.*: Test recovery when crash occurs during sync() of the
+# main database journal file.
+# crash-4.2.*: Test recovery when crash occurs during sync() of an
+# attached database journal file.
+# crash-4.3.*: Test recovery when crash occurs during sync() of the master
+# journal file.
+#
+ifcapable attach {
+ do_test crash-4.0 {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ PRAGMA aux.default_cache_size = 10;
+ CREATE TABLE aux.abc2 AS SELECT 2*a as a, 2*b as b, 2*c as c FROM abc;
+ }
+ expr ([file size test2.db] / 1024) > 450
+ } {1}
+
+ set fin 0
+ for {set i 1} {$i<$repeats} {incr i} {
+ set seed [expr {int(abs(rand()*10000))}]
+ set sig [signature]
+ set sig2 [signature2]
+ do_test crash-4.1.$i.1 {
+ set c [crashsql -delay $i -file test.db-journal -seed $::seed "
+ ATTACH 'test2.db' AS aux;
+ BEGIN;
+ SELECT randstr($i,$i) FROM abc LIMIT $i;
+ INSERT INTO abc VALUES(randstr(10,10), 0, 0);
+ DELETE FROM abc WHERE random()%10!=0;
+ INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);
+ DELETE FROM abc2 WHERE random()%10!=0;
+ COMMIT;
+ "]
+ if { $c == {0 {}} } {
+ set ::fin 1
+ set c {1 {child process exited abnormally}}
+ }
+ set c
+ } {1 {child process exited abnormally}}
+ if {$::fin} break
+ do_test crash-4.1.$i.2 {
+ signature
+ } $sig
+ do_test crash-4.1.$i.3 {
+ signature2
+ } $sig2
+ }
+ set i 0
+ set fin 0
+ while {[incr i]} {
+ set seed [expr {int(abs(rand()*10000))}]
+ set sig [signature]
+ set sig2 [signature2]
+ set ::fin 0
+ do_test crash-4.2.$i.1 {
+ set c [crashsql -delay $i -file test2.db-journal -seed $::seed "
+ ATTACH 'test2.db' AS aux;
+ BEGIN;
+ SELECT randstr($i,$i) FROM abc LIMIT $i;
+ INSERT INTO abc VALUES(randstr(10,10), 0, 0);
+ DELETE FROM abc WHERE random()%10!=0;
+ INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);
+ DELETE FROM abc2 WHERE random()%10!=0;
+ COMMIT;
+ "]
+ if { $c == {0 {}} } {
+ set ::fin 1
+ set c {1 {child process exited abnormally}}
+ }
+ set c
+ } {1 {child process exited abnormally}}
+ if { $::fin } break
+ do_test crash-4.2.$i.2 {
+ signature
+ } $sig
+ do_test crash-4.2.$i.3 {
+ signature2
+ } $sig2
+ }
+ for {set i 1} {$i < 5} {incr i} {
+ set sig [signature]
+ set sig2 [signature2]
+ do_test crash-4.3.$i.1 {
+ crashsql -delay 1 -file test.db-mj* "
+ ATTACH 'test2.db' AS aux;
+ BEGIN;
+ SELECT random() FROM abc LIMIT $i;
+ INSERT INTO abc VALUES(randstr(10,10), 0, 0);
+ DELETE FROM abc WHERE random()%10!=0;
+ INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);
+ DELETE FROM abc2 WHERE random()%10!=0;
+ COMMIT;
+ "
+ } {1 {child process exited abnormally}}
+ do_test crash-4.3.$i.2 {
+ signature
+ } $sig
+ do_test crash-4.3.$i.3 {
+ signature2
+ } $sig2
+ }
+}
+
+#--------------------------------------------------------------------------
+# The following test cases - crash-5.* - exposes a bug that existed in the
+# sqlite3pager_movepage() API used by auto-vacuum databases.
+# database when a crash occurs during a multi-file transaction. See comments
+# in test crash-5.3 for details.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_test crash-5.1 {
+ execsql {
+ CREATE TABLE abc(a, b, c); -- Root page 3
+ INSERT INTO abc VALUES(randstr(1500,1500), 0, 0); -- Overflow page 4
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ }
+} {}
+do_test crash-5.2 {
+ expr [file size test.db] / 1024
+} [expr [string match [execsql {pragma auto_vacuum}] 1] ? 11 : 10]
+set sig [signature]
+do_test crash-5.3 {
+# The SQL below is used to expose a bug that existed in
+# sqlite3pager_movepage() during development of the auto-vacuum feature. It
+# functions as follows:
+#
+# 1: Begin a transaction.
+# 2: Put page 4 on the free-list (was the overflow page for the row deleted).
+# 3: Write data to page 4 (it becomes the overflow page for the row inserted).
+# The old page 4 data has been written to the journal file, but the
+# journal file has not been sync()hronized.
+# 4: Create a table, which calls sqlite3pager_movepage() to move page 4
+# to the end of the database (page 12) to make room for the new root-page.
+# 5: Put pressure on the pager-cache. This results in page 4 being written
+# to the database file to make space in the cache to load a new page. The
+# bug was that page 4 was written to the database file before the journal
+# is sync()hronized.
+# 6: Commit. A crash occurs during the sync of the journal file.
+#
+# End result: Before the bug was fixed, data has been written to page 4 of the
+# database file and the journal file does not contain trustworthy rollback
+# data for this page.
+#
+ crashsql -delay 1 -file test.db-journal {
+ BEGIN; -- 1
+ DELETE FROM abc WHERE oid = 1; -- 2
+ INSERT INTO abc VALUES(randstr(1500,1500), 0, 0); -- 3
+ CREATE TABLE abc2(a, b, c); -- 4
+ SELECT * FROM abc; -- 5
+ COMMIT; -- 6
+ }
+} {1 {child process exited abnormally}}
+integrity_check crash-5.4
+do_test crash-5.5 {
+ signature
+} $sig
+
+#--------------------------------------------------------------------------
+# The following test cases - crash-6.* - test that a DROP TABLE operation
+# is correctly rolled back in the event of a crash while the database file
+# is being written. This is mainly to test that all pages are written to the
+# journal file before truncation in an auto-vacuum database.
+#
+do_test crash-6.1 {
+ crashsql -delay 1 -file test.db {
+ DROP TABLE abc;
+ }
+} {1 {child process exited abnormally}}
+do_test crash-6.2 {
+ signature
+} $sig
+
+#--------------------------------------------------------------------------
+# These test cases test the case where the master journal file name is
+# corrupted slightly so that the corruption has to be detected by the
+# checksum.
+do_test crash-7.1 {
+ crashsql -delay 1 -file test.db {
+ ATTACH 'test2.db' AS aux;
+ BEGIN;
+ INSERT INTO abc VALUES(randstr(1500,1500), 0, 0);
+ INSERT INTO abc2 VALUES(randstr(1500,1500), 0, 0);
+ COMMIT;
+ }
+
+ # Change the checksum value for the master journal name.
+ set f [open test.db-journal a]
+ fconfigure $f -encoding binary
+ seek $f [expr [file size test.db-journal] - 12]
+ puts -nonewline $f "\00\00\00\00"
+ close $f
+} {}
+do_test crash-7.2 {
+ signature
+} $sig
+
+finish_test
diff --git a/test/crash2.test b/test/crash2.test
new file mode 100644
index 0000000..c74f6c2
--- /dev/null
+++ b/test/crash2.test
@@ -0,0 +1,133 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# The focus of this file is testing the ability of the database to
+# uses its rollback journal to recover intact (no database corruption)
+# from a power failure during the middle of a COMMIT. Even more
+# specifically, the tests in this file verify this functionality
+# for storage mediums with various sector sizes.
+#
+# $Id: crash2.test,v 1.6 2008/08/25 07:12:29 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !crashtest {
+ finish_test
+ return
+}
+
+db close
+
+# This test is designed to check that the crash-test infrastructure
+# can create files that do not consist of an integer number of
+# simulated disk blocks (i.e. 3KB file using 2KB disk blocks).
+#
+do_test crash2-1.1 {
+ crashsql -delay 500 -file test.db -blocksize 2048 {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=1024;
+ BEGIN;
+ CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;
+ CREATE TABLE def AS SELECT 1 AS d, 2 AS e, 3 AS f;
+ COMMIT;
+ }
+ file size test.db
+} {3072}
+
+for {set ii 0} {$ii < 5} {incr ii} {
+
+ # Simple test using the database created above: Create a new
+ # table so that page 1 and page 4 are modified. Using a
+ # block-size of 2048 and page-size of 1024, this means
+ # pages 2 and 3 must also be saved in the journal to avoid
+ # risking corruption.
+ #
+ # The loop is so that this test can be run with a couple
+ # of different seeds for the random number generator.
+ #
+ do_test crash2-1.2.$ii {
+ crashsql -file test.db -blocksize 2048 [subst {
+ [string repeat {SELECT random();} $ii]
+ CREATE TABLE hij(h, i, j);
+ }]
+ sqlite3 db test.db
+ db eval {PRAGMA integrity_check}
+ } {ok}
+}
+
+proc signature {} {
+ return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
+}
+
+# Test case for crashing during journal sync with simulated
+# sector-size values from 1024 to 8192.
+#
+do_test crash2-2.0 {
+ execsql BEGIN
+ for {set n 0} {$n < 1000} {incr n} {
+ execsql "INSERT INTO abc VALUES($n, [expr 2*$n], [expr 3*$n])"
+ }
+ execsql {
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ }
+ execsql COMMIT
+ expr ([file size test.db] / 1024) > 450
+} {1}
+for {set i 1} {$i < 30} {incr i} {
+ set sig [signature]
+ set sector [expr 1024 * 1<<($i%4)]
+ db close
+ do_test crash2-2.$i.1 {
+ crashsql -blocksize $sector -delay [expr $i%5 + 1] -file test.db-journal "
+ PRAGMA temp_store = memory;
+ BEGIN;
+ SELECT random() FROM abc LIMIT $i;
+ INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;
+ DELETE FROM abc WHERE random()%2!=0;
+ COMMIT;
+ "
+ } {1 {child process exited abnormally}}
+ do_test crash2-2.$i.2 {
+ sqlite3 db test.db
+ signature
+ } $sig
+}
+
+
+# Test case for crashing during database sync with simulated
+# sector-size values from 1024 to 8192.
+#
+for {set i 1} {$i < 10} {incr i} {
+ set sig [signature]
+ set sector [expr 1024 * 1<<($i%4)]
+ db close
+ do_test crash2-3.$i.1 {
+ crashsql -blocksize $sector -file test.db "
+ BEGIN;
+ SELECT random() FROM abc LIMIT $i;
+ INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;
+ DELETE FROM abc WHERE random()%2!=0;
+ COMMIT;
+ "
+ } {1 {child process exited abnormally}}
+ do_test crash2-3.$i.2 {
+ sqlite3 db test.db
+ signature
+ } $sig
+}
+
+finish_test
diff --git a/test/crash3.test b/test/crash3.test
new file mode 100644
index 0000000..7958af9
--- /dev/null
+++ b/test/crash3.test
@@ -0,0 +1,190 @@
+# 2007 August 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests that verify that SQLite can correctly rollback
+# databases after crashes when using the special IO modes triggered
+# by device IOCAP flags.
+#
+# $Id: crash3.test,v 1.4 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !crashtest {
+ finish_test
+ return
+}
+
+proc do_test2 {name tcl res1 res2} {
+ set script [subst -nocommands {
+ do_test $name {
+ set res1 {$res1}
+ set res2 {$res2}
+ set res [eval {$tcl}]
+ if {[set res] eq [set res1] || [set res] eq [set res2]} {
+ set res "{[set res1]} or {[set res2]}"
+ }
+ set res
+ } {{$res1} or {$res2}}
+ }]
+ uplevel $script
+}
+
+# This block tests crash-recovery when the IOCAP_ATOMIC flags is set.
+#
+# Each iteration of the following loop sets up the database to contain
+# the following schema and data:
+#
+# CREATE TABLE abc(a, b, c);
+# INSERT INTO abc VALUES(1, 2, 3);
+#
+# Then execute the SQL statement, scheduling a crash for part-way through
+# the first sync() of either the database file or the journal file (often
+# the journal file is not required - meaning no crash occurs).
+#
+# After the crash (or absence of a crash), open the database and
+# verify that:
+#
+# * The integrity check passes, and
+# * The contents of table abc is either {1 2 3} or the value specified
+# to the right of the SQL statement below.
+#
+# The procedure is repeated 10 times for each SQL statement. Five times
+# with the crash scheduled for midway through the first journal sync (if
+# any), and five times with the crash midway through the database sync.
+#
+set tn 1
+foreach {sql res2} [list \
+ {INSERT INTO abc VALUES(4, 5, 6)} {1 2 3 4 5 6} \
+ {DELETE FROM abc} {} \
+ {INSERT INTO abc SELECT * FROM abc} {1 2 3 1 2 3} \
+ {UPDATE abc SET a = 2} {2 2 3} \
+ {INSERT INTO abc VALUES(4, 5, randstr(1000,1000))} {n/a} \
+ {CREATE TABLE def(d, e, f)} {n/a} \
+] {
+ for {set ii 0} {$ii < 10} {incr ii} {
+
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ do_test crash3-1.$tn.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ COMMIT;
+ }
+ } {}
+ db close
+
+ set crashfile test.db
+ if {($ii%2)==0} { append crashfile -journal }
+ set rand "SELECT randstr($tn,$tn);"
+ do_test crash3-1.$tn.2 [subst {
+ crashsql -file $crashfile -char atomic {$rand $sql}
+ sqlite3 db test.db
+ execsql { PRAGMA integrity_check; }
+ }] {ok}
+
+ do_test2 crash3-1.$tn.3 {
+ execsql { SELECT * FROM abc }
+ } {1 2 3} $res2
+
+ incr tn
+ }
+}
+
+# This block tests both the IOCAP_SEQUENTIAL and IOCAP_SAFE_APPEND flags.
+#
+db close
+forcedelete test.db test.db-journal
+sqlite3 db test.db
+do_test crash3-2.0 {
+ execsql {
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY, b, c);
+ CREATE TABLE def(d PRIMARY KEY, e, f);
+ PRAGMA default_cache_size = 10;
+ INSERT INTO abc VALUES(randstr(10,1000),randstr(10,1000),randstr(10,1000));
+ INSERT INTO abc
+ SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;
+ COMMIT;
+ }
+} {}
+
+set tn 1
+foreach {::crashfile ::delay ::char} {
+ test.db 1 sequential
+ test.db 1 safe_append
+ test.db-journal 1 sequential
+ test.db-journal 1 safe_append
+ test.db-journal 2 safe_append
+ test.db-journal 2 sequential
+ test.db-journal 3 sequential
+ test.db-journal 3 safe_append
+} {
+ for {set ii 0} {$ii < 100} {incr ii} {
+ set ::SQL [subst {
+ SELECT randstr($ii,$ii+10);
+ BEGIN;
+ DELETE FROM abc WHERE random()%5;
+ INSERT INTO abc
+ SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000)
+ FROM abc
+ WHERE (random()%5)==0;
+ DELETE FROM def WHERE random()%5;
+ INSERT INTO def
+ SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000)
+ FROM def
+ WHERE (random()%5)==0;
+ COMMIT;
+ }]
+
+ do_test crash3-2.$tn.$ii {
+ crashsql -file $::crashfile -delay $::delay -char $::char $::SQL
+ db close
+ sqlite3 db test.db
+ execsql {PRAGMA integrity_check}
+ } {ok}
+ }
+ incr tn
+}
+
+# The following block tests an interaction between IOCAP_ATOMIC and
+# IOCAP_SEQUENTIAL. At one point, if both flags were set, small
+# journal files that contained only a single page, but were required
+# for some other reason (i.e. nTrunk) were not being written to
+# disk.
+#
+for {set ii 0} {$ii < 10} {incr ii} {
+ db close
+ forcedelete test.db test.db-journal
+ crashsql -file test.db -char {sequential atomic} {
+ CREATE TABLE abc(a, b, c);
+ }
+ sqlite3 db test.db
+ do_test crash3-3.$ii {
+ execsql {PRAGMA integrity_check}
+ } {ok}
+}
+
+finish_test
diff --git a/test/crash4.test b/test/crash4.test
new file mode 100644
index 0000000..f68caec
--- /dev/null
+++ b/test/crash4.test
@@ -0,0 +1,102 @@
+# 2008 January 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains additional tests to verify that SQLite database
+# file survive a power loss or OS crash.
+#
+# $Id: crash4.test,v 1.3 2008/01/16 17:46:38 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !crashtest {
+ finish_test
+ return
+}
+
+
+# A sequence of SQL commands:
+#
+set sql_cmd_list {
+ {CREATE TABLE a(id INTEGER, name CHAR(50))}
+ {INSERT INTO a(id,name) VALUES(1,'one')}
+ {INSERT INTO a(id,name) VALUES(2,'two')}
+ {INSERT INTO a(id,name) VALUES(3,'three')}
+ {INSERT INTO a(id,name) VALUES(4,'four')}
+ {INSERT INTO a(id,name) VALUES(5,'five')}
+ {INSERT INTO a(id,name) VALUES(6,'six')}
+ {INSERT INTO a(id,name) VALUES(7,'seven')}
+ {INSERT INTO a(id,name) VALUES(8,'eight')}
+ {INSERT INTO a(id,name) VALUES(9,'nine')}
+ {INSERT INTO a(id,name) VALUES(10,'ten')}
+ {UPDATE A SET name='new text for row 3' WHERE id=3}
+}
+
+# Assume that a database is created by evaluating the SQL statements
+# in $sql_cmd_list. Compute a set of checksums that capture the state
+# of the database after each statement. Also include a checksum for
+# the state of the database prior to any of these statements.
+#
+set crash4_cksum_set {}
+lappend crash4_cksum_set [allcksum db]
+foreach cmd $sql_cmd_list {
+ db eval $cmd
+ lappend crash4_cksum_set [allcksum db]
+}
+
+# Run the sequence of SQL statements shown above repeatedly.
+# Close and reopen the database right before the UPDATE statement.
+# On each repetition, introduce database corruption typical of
+# what might be seen in a power loss or OS crash.
+#
+# Slowly increase the delay before the crash, repeating the test
+# over and over. Stop testing when the entire sequence of SQL
+# statements runs to completing without hitting the crash.
+#
+for {set cnt 1; set fin 0} {!$fin} {incr cnt} {
+ db close
+ forcedelete test.db test.db-journal
+ do_test crash4-1.$cnt.1 {
+ set seed [expr {int(abs(rand()*10000))}]
+ set delay [expr {int($cnt/50)+1}]
+ set file [expr {($cnt&1)?"test.db":"test.db-journal"}]
+ set c [crashsql -delay $delay -file $file -seed $seed -tclbody {
+ db eval {CREATE TABLE a(id INTEGER, name CHAR(50))}
+ db eval {INSERT INTO a(id,name) VALUES(1,'one')}
+ db eval {INSERT INTO a(id,name) VALUES(2,'two')}
+ db eval {INSERT INTO a(id,name) VALUES(3,'three')}
+ db eval {INSERT INTO a(id,name) VALUES(4,'four')}
+ db eval {INSERT INTO a(id,name) VALUES(5,'five')}
+ db eval {INSERT INTO a(id,name) VALUES(6,'six')}
+ db eval {INSERT INTO a(id,name) VALUES(7,'seven')}
+ db eval {INSERT INTO a(id,name) VALUES(8,'eight')}
+ db eval {INSERT INTO a(id,name) VALUES(9,'nine')}
+ db eval {INSERT INTO a(id,name) VALUES(10,'ten')}
+ db close
+ sqlite3 db test.db
+ db eval {UPDATE A SET name='new text for row 3' WHERE id=3}
+ db close
+ } {}]
+ if {$c==[list 0 {}]} {
+ set ::fin 1
+ set c [list 1 {child process exited abnormally}]
+ }
+ set c
+ } {1 {child process exited abnormally}}
+ sqlite3 db test.db
+ integrity_check crash4-1.$cnt.2
+ do_test crash4-1.$cnt.3 {
+ set x [lsearch $::crash4_cksum_set [allcksum db]]
+ expr {$x>=0}
+ } {1}
+}
+
+finish_test
diff --git a/test/crash5.test b/test/crash5.test
new file mode 100644
index 0000000..42248d7
--- /dev/null
+++ b/test/crash5.test
@@ -0,0 +1,110 @@
+
+# 2007 Aug 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file tests aspects of recovery from a malloc() failure
+# in a CREATE INDEX statement.
+#
+# $Id: crash5.test,v 1.3 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+ifcapable !memdebug||!crashtest||!memorymanage {
+ puts "Skipping crash5 tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+db close
+
+for {set ii 0} {$ii < 10} {incr ii} {
+ for {set jj 50} {$jj < 100} {incr jj} {
+
+ # Set up the database so that it is an auto-vacuum database
+ # containing a single table (root page 3) with a single row.
+ # The row has an overflow page (page 4).
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ set c [string repeat 3 1500]
+ db eval {
+ pragma auto_vacuum = 1;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('1111111111', '2222222222', $c);
+ }
+ db close
+
+ do_test crash5-$ii.$jj.1 {
+ crashsql -delay 1 -file test.db-journal -seed $ii -tclbody [join [list \
+ [list set iFail $jj] {
+ sqlite3_crashparams 0 [file join [pwd] test.db-journal]
+
+ # Begin a transaction and evaluate a "CREATE INDEX" statement
+ # with the iFail'th malloc() set to fail. This operation will
+ # have to move the current contents of page 4 (the overflow
+ # page) to make room for the new root page. The bug is that
+ # if malloc() fails at a particular point in sqlite3PagerMovepage(),
+ # sqlite mistakenly thinks that the page being moved (page 4) has
+ # been safely synced into the journal. If the page is written
+ # to later in the transaction, it may be written out to the database
+ # before the relevant part of the journal has been synced.
+ #
+ db eval BEGIN
+ sqlite3_memdebug_fail $iFail -repeat 0
+ catch {db eval { CREATE UNIQUE INDEX i1 ON t1(a); }} msg
+ # puts "$n $msg ac=[sqlite3_get_autocommit db]"
+
+ # If the transaction is still active (it may not be if the malloc()
+ # failure occured in the OS layer), write to the database. Make sure
+ # page 4 is among those written.
+ #
+ if {![sqlite3_get_autocommit db]} {
+ db eval {
+ DELETE FROM t1; -- This will put page 4 on the free list.
+ INSERT INTO t1 VALUES('111111111', '2222222222', '33333333');
+ INSERT INTO t1 SELECT * FROM t1; -- 2
+ INSERT INTO t1 SELECT * FROM t1; -- 4
+ INSERT INTO t1 SELECT * FROM t1; -- 8
+ INSERT INTO t1 SELECT * FROM t1; -- 16
+ INSERT INTO t1 SELECT * FROM t1; -- 32
+ INSERT INTO t1 SELECT * FROM t1 WHERE rowid%2; -- 48
+ }
+ }
+
+ # If the right malloc() failed during the 'CREATE INDEX' above and
+ # the transaction was not rolled back, then the sqlite cache now
+ # has a dirty page 4 that it incorrectly believes is already safely
+ # in the synced part of the journal file. When
+ # sqlite3_release_memory() is called sqlite tries to free memory
+ # by writing page 4 out to the db file. If it crashes later on,
+ # before syncing the journal... Corruption!
+ #
+ sqlite3_crashparams 1 [file join [pwd] test.db-journal]
+ sqlite3_release_memory 8092
+ }]] {}
+ expr 1
+ } {1}
+
+ sqlite3 db test.db
+ do_test crash5-$ii.$jj.2 {
+ db eval {pragma integrity_check}
+ } {ok}
+ do_test crash5-$ii.$jj.3 {
+ db eval {SELECT * FROM t1}
+ } [list 1111111111 2222222222 $::c]
+ db close
+ }
+}
+
+
+finish_test
diff --git a/test/crash6.test b/test/crash6.test
new file mode 100644
index 0000000..69c1946
--- /dev/null
+++ b/test/crash6.test
@@ -0,0 +1,118 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file tests that rollback journals for databases that use a
+# page-size other than the default page-size can be rolled back Ok.
+#
+# $Id: crash6.test,v 1.2 2008/04/14 15:27:19 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !crashtest {
+ finish_test
+ return
+}
+
+for {set ii 0} {$ii < 10} {incr ii} {
+ catch {db close}
+ forcedelete test.db test.db-journal
+ crashsql -delay 2 -file test.db {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=4096;
+ BEGIN;
+ CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;
+ COMMIT;
+ BEGIN;
+ CREATE TABLE def AS SELECT 1 AS d, 2 AS e, 3 AS f;
+ COMMIT;
+ }
+ sqlite3 db test.db
+ integrity_check crash6-1.$ii
+}
+
+for {set ii 0} {$ii < 10} {incr ii} {
+ catch {db close}
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=2048;
+ BEGIN;
+ CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;
+ COMMIT;
+ }
+ db close
+ crashsql -delay 1 -file test.db {
+ INSERT INTO abc VALUES(5, 6, 7);
+ }
+ sqlite3 db test.db
+ integrity_check crash6-2.$ii
+}
+
+proc signature {} {
+ return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
+}
+
+# Test case for crashing during database sync with page-size values
+# from 1024 to 8192.
+#
+for {set ii 0} {$ii < 30} {incr ii} {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+
+ set pagesize [expr 1024 << ($ii % 4)]
+ if {$pagesize>$::SQLITE_MAX_PAGE_SIZE} {
+ set pagesize $::SQLITE_MAX_PAGE_SIZE
+ }
+ do_test crash6-3.$ii.0 {
+ execsql "pragma page_size = $pagesize"
+ execsql "pragma page_size"
+ } $pagesize
+
+ do_test crash6-3.$ii.1 {
+
+ execsql BEGIN
+ execsql {CREATE TABLE abc(a, b, c)}
+ for {set n 0} {$n < 1000} {incr n} {
+ execsql "INSERT INTO abc VALUES($n, [expr 2*$n], [expr 3*$n])"
+ }
+ execsql {
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ }
+ execsql COMMIT
+ expr ([file size test.db] / 1024) > 450
+ } {1}
+
+ set sig [signature]
+ db close
+
+ do_test crash6-3.$ii.2 {
+ crashsql -file test.db "
+ BEGIN;
+ SELECT random() FROM abc LIMIT $ii;
+ INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;
+ DELETE FROM abc WHERE random()%2!=0;
+ COMMIT;
+ "
+ } {1 {child process exited abnormally}}
+
+ do_test crash6-3.$ii.3 {
+ sqlite3 db test.db
+ signature
+ } $sig
+}
+
+finish_test
diff --git a/test/crash7.test b/test/crash7.test
new file mode 100644
index 0000000..4554a2a
--- /dev/null
+++ b/test/crash7.test
@@ -0,0 +1,82 @@
+# 2008 March 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: crash7.test,v 1.1 2008/04/03 14:36:26 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !crashtest {
+ finish_test
+ return
+}
+
+proc signature {} {
+ return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
+}
+
+foreach f [list test.db test.db-journal] {
+ for {set ii 1} {$ii < 64} {incr ii} {
+ db close
+ delete_file test.db
+ sqlite3 db test.db
+
+ set from_size [expr 1024 << ($ii&3)]
+ set to_size [expr 1024 << (($ii>>2)&3)]
+
+ execsql "
+ PRAGMA page_size = $from_size;
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY, b, c);
+ INSERT INTO abc VALUES(randomblob(100), randomblob(200), randomblob(1000));
+ INSERT INTO abc
+ SELECT randomblob(1000), randomblob(200), randomblob(100)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(100), randomblob(200), randomblob(1000)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(100), randomblob(200), randomblob(1000)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(100), randomblob(200), randomblob(1000)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(100), randomblob(200), randomblob(1000)
+ FROM abc WHERE [expr $ii&16];
+ INSERT INTO abc
+ SELECT randomblob(25), randomblob(45), randomblob(9456)
+ FROM abc WHERE [expr $ii&32];
+ INSERT INTO abc
+ SELECT randomblob(100), randomblob(200), randomblob(1000)
+ FROM abc WHERE [expr $ii&8];
+ INSERT INTO abc
+ SELECT randomblob(25), randomblob(45), randomblob(9456)
+ FROM abc WHERE [expr $ii&4];
+ COMMIT;
+ "
+
+ set sig [signature]
+ db close
+
+ do_test crash7-1.$ii.crash {
+ crashsql -file $f "
+ PRAGMA page_size = $to_size;
+ VACUUM;
+ "
+ } {1 {child process exited abnormally}}
+
+ sqlite3 db test.db
+ integrity_check crash7-1.$ii.integrity
+ }
+}
+
+finish_test
diff --git a/test/crash8.test b/test/crash8.test
new file mode 100644
index 0000000..8bc2586
--- /dev/null
+++ b/test/crash8.test
@@ -0,0 +1,402 @@
+# 2009 January 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test verifies a couple of specific potential data corruption
+# scenarios involving crashes or power failures.
+#
+# Later: Also, some other specific scenarios required for coverage
+# testing that do not lead to corruption.
+#
+# $Id: crash8.test,v 1.4 2009/01/11 00:44:48 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !crashtest {
+ finish_test
+ return
+}
+
+do_test crash8-1.1 {
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, randstr(1000,1000));
+ INSERT INTO t1 VALUES(3, randstr(1000,1000));
+ INSERT INTO t1 VALUES(4, randstr(1000,1000));
+ INSERT INTO t1 VALUES(5, randstr(1000,1000));
+ INSERT INTO t1 VALUES(6, randstr(1000,1000));
+ CREATE TABLE t2(a, b);
+ CREATE TABLE t3(a, b);
+ CREATE TABLE t4(a, b);
+ CREATE TABLE t5(a, b);
+ CREATE TABLE t6(a, b);
+ CREATE TABLE t7(a, b);
+ CREATE TABLE t8(a, b);
+ CREATE TABLE t9(a, b);
+ CREATE TABLE t10(a, b);
+ PRAGMA integrity_check
+ }
+} {ok}
+
+
+# Potential corruption scenario 1. A second process opens the database
+# and modifies a large portion of it. It then opens a second transaction
+# and modifies a small part of the database, but crashes before it commits
+# the transaction.
+#
+# When the first process accessed the database again, it was rolling back
+# the aborted transaction, but was not purging its in-memory cache (which
+# was loaded before the second process made its first, successful,
+# modification). Producing an inconsistent cache.
+#
+do_test crash8-1.2 {
+ crashsql -delay 2 -file test.db {
+ PRAGMA cache_size = 10;
+ UPDATE t1 SET b = randstr(1000,1000);
+ INSERT INTO t9 VALUES(1, 2);
+ }
+} {1 {child process exited abnormally}}
+do_test crash8-1.3 {
+ execsql {PRAGMA integrity_check}
+} {ok}
+
+# Potential corruption scenario 2. The second process, operating in
+# persistent-journal mode, makes a large change to the database file
+# with a small in-memory cache. Such that more than one journal-header
+# was written to the file. It then opens a second transaction and makes
+# a smaller change that requires only a single journal-header to be
+# written to the journal file. The second change is such that the
+# journal content written to the persistent journal file exactly overwrites
+# the first journal-header and set of subsequent records written by the
+# first, successful, change. The second process crashes before it can
+# commit its second change.
+#
+# When the first process accessed the database again, it was rolling back
+# the second aborted transaction, then continuing to rollback the second
+# and subsequent journal-headers written by the first, successful, change.
+# Database corruption.
+#
+do_test crash8.2.1 {
+ crashsql -delay 2 -file test.db {
+ PRAGMA journal_mode = persist;
+ PRAGMA cache_size = 10;
+ UPDATE t1 SET b = randstr(1000,1000);
+ PRAGMA cache_size = 100;
+ BEGIN;
+ INSERT INTO t2 VALUES('a', 'b');
+ INSERT INTO t3 VALUES('a', 'b');
+ INSERT INTO t4 VALUES('a', 'b');
+ INSERT INTO t5 VALUES('a', 'b');
+ INSERT INTO t6 VALUES('a', 'b');
+ INSERT INTO t7 VALUES('a', 'b');
+ INSERT INTO t8 VALUES('a', 'b');
+ INSERT INTO t9 VALUES('a', 'b');
+ INSERT INTO t10 VALUES('a', 'b');
+ COMMIT;
+ }
+} {1 {child process exited abnormally}}
+
+do_test crash8-2.3 {
+ execsql {PRAGMA integrity_check}
+} {ok}
+
+proc read_file {zFile} {
+ set fd [open $zFile]
+ fconfigure $fd -translation binary
+ set zData [read $fd]
+ close $fd
+ return $zData
+}
+proc write_file {zFile zData} {
+ set fd [open $zFile w]
+ fconfigure $fd -translation binary
+ puts -nonewline $fd $zData
+ close $fd
+}
+
+# The following tests check that SQLite will not roll back a hot-journal
+# file if the sector-size field in the first journal file header is
+# suspect. Definition of suspect:
+#
+# a) Not a power of 2, or (crash8-3.5)
+# b) Greater than 0x01000000 (16MB), or (crash8-3.6)
+# c) Less than 512. (crash8-3.7)
+#
+# Also test that SQLite will not rollback a hot-journal file with a
+# suspect page-size. In this case "suspect" means:
+#
+# a) Not a power of 2, or
+# b) Less than 512, or
+# c) Greater than SQLITE_MAX_PAGE_SIZE
+#
+do_test crash8-3.1 {
+ list [file exists test.db-joural] [file exists test.db]
+} {0 1}
+do_test crash8-3.2 {
+ execsql {
+ PRAGMA synchronous = off;
+ BEGIN;
+ DELETE FROM t1;
+ SELECT count(*) FROM t1;
+ }
+} {0}
+do_test crash8-3.3 {
+ set zJournal [read_file test.db-journal]
+ execsql {
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+} {0}
+do_test crash8-3.4 {
+ binary scan [string range $zJournal 20 23] I nSector
+ set nSector
+} {512}
+
+do_test crash8-3.5 {
+ set zJournal2 [string replace $zJournal 20 23 [binary format I 513]]
+ write_file test.db-journal $zJournal2
+
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check
+ }
+} {0 ok}
+do_test crash8-3.6 {
+ set zJournal2 [string replace $zJournal 20 23 [binary format I 0x2000000]]
+ write_file test.db-journal $zJournal2
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check
+ }
+} {0 ok}
+do_test crash8-3.7 {
+ set zJournal2 [string replace $zJournal 20 23 [binary format I 256]]
+ write_file test.db-journal $zJournal2
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check
+ }
+} {0 ok}
+
+do_test crash8-3.8 {
+ set zJournal2 [string replace $zJournal 24 27 [binary format I 513]]
+ write_file test.db-journal $zJournal2
+
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check
+ }
+} {0 ok}
+do_test crash8-3.9 {
+ set big [expr $SQLITE_MAX_PAGE_SIZE * 2]
+ set zJournal2 [string replace $zJournal 24 27 [binary format I $big]]
+ write_file test.db-journal $zJournal2
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check
+ }
+} {0 ok}
+do_test crash8-3.10 {
+ set zJournal2 [string replace $zJournal 24 27 [binary format I 256]]
+ write_file test.db-journal $zJournal2
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check
+ }
+} {0 ok}
+
+do_test crash8-3.11 {
+ set fd [open test.db-journal w]
+ fconfigure $fd -translation binary
+ puts -nonewline $fd $zJournal
+ close $fd
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check
+ }
+} {6 ok}
+
+
+# If a connection running in persistent-journal mode is part of a
+# multi-file transaction, it must ensure that the master-journal name
+# appended to the journal file contents during the commit is located
+# at the end of the physical journal file. If there was already a
+# large journal file allocated at the start of the transaction, this
+# may mean truncating the file so that the master journal name really
+# is at the physical end of the file.
+#
+# This block of tests test that SQLite correctly truncates such
+# journal files, and that the results behave correctly if a hot-journal
+# rollback occurs.
+#
+ifcapable pragma {
+ reset_db
+ forcedelete test2.db
+
+ do_test crash8-4.1 {
+ execsql {
+ PRAGMA journal_mode = persist;
+ CREATE TABLE ab(a, b);
+ INSERT INTO ab VALUES(0, 'abc');
+ INSERT INTO ab VALUES(1, NULL);
+ INSERT INTO ab VALUES(2, NULL);
+ INSERT INTO ab VALUES(3, NULL);
+ INSERT INTO ab VALUES(4, NULL);
+ INSERT INTO ab VALUES(5, NULL);
+ INSERT INTO ab VALUES(6, NULL);
+ UPDATE ab SET b = randstr(1000,1000);
+ ATTACH 'test2.db' AS aux;
+ PRAGMA aux.journal_mode = persist;
+ CREATE TABLE aux.ab(a, b);
+ INSERT INTO aux.ab SELECT * FROM main.ab;
+
+ UPDATE aux.ab SET b = randstr(1000,1000) WHERE a>=1;
+ UPDATE ab SET b = randstr(1000,1000) WHERE a>=1;
+ }
+ list [file exists test.db-journal] [file exists test2.db-journal]
+ } {1 1}
+
+ do_test crash8-4.2 {
+ execsql {
+ BEGIN;
+ UPDATE aux.ab SET b = 'def' WHERE a = 0;
+ UPDATE main.ab SET b = 'def' WHERE a = 0;
+ COMMIT;
+ }
+ } {}
+
+ do_test crash8-4.3 {
+ execsql {
+ UPDATE aux.ab SET b = randstr(1000,1000) WHERE a>=1;
+ UPDATE ab SET b = randstr(1000,1000) WHERE a>=1;
+ }
+ } {}
+
+ set contents_main [db eval {SELECT b FROM main.ab WHERE a = 1}]
+ set contents_aux [db eval {SELECT b FROM aux.ab WHERE a = 1}]
+
+ do_test crash8-4.4 {
+ crashsql -file test2.db -delay 1 {
+ ATTACH 'test2.db' AS aux;
+ BEGIN;
+ UPDATE aux.ab SET b = 'ghi' WHERE a = 0;
+ UPDATE main.ab SET b = 'ghi' WHERE a = 0;
+ COMMIT;
+ }
+ } {1 {child process exited abnormally}}
+
+ do_test crash8-4.5 {
+ list [file exists test.db-journal] [file exists test2.db-journal]
+ } {1 1}
+
+ do_test crash8-4.6 {
+ execsql {
+ SELECT b FROM main.ab WHERE a = 0;
+ SELECT b FROM aux.ab WHERE a = 0;
+ }
+ } {def def}
+
+ do_test crash8-4.7 {
+ crashsql -file test2.db -delay 1 {
+ ATTACH 'test2.db' AS aux;
+ BEGIN;
+ UPDATE aux.ab SET b = 'jkl' WHERE a = 0;
+ UPDATE main.ab SET b = 'jkl' WHERE a = 0;
+ COMMIT;
+ }
+ } {1 {child process exited abnormally}}
+
+ do_test crash8-4.8 {
+ set fd [open test.db-journal]
+ fconfigure $fd -translation binary
+ seek $fd -16 end
+ binary scan [read $fd 4] I len
+
+ seek $fd [expr {-1 * ($len + 16)}] end
+ set zMasterJournal [read $fd $len]
+ close $fd
+
+ file exists $zMasterJournal
+ } {1}
+
+ do_test crash8-4.9 {
+ execsql { SELECT b FROM aux.ab WHERE a = 0 }
+ } {def}
+
+ do_test crash8-4.10 {
+ delete_file $zMasterJournal
+ execsql { SELECT b FROM main.ab WHERE a = 0 }
+ } {jkl}
+}
+
+for {set i 1} {$i < 10} {incr i} {
+ catch { db close }
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ do_test crash8-5.$i.1 {
+ execsql {
+ CREATE TABLE t1(x PRIMARY KEY);
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 SELECT randomblob(900) FROM t1;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 rows */
+ }
+ crashsql -file test.db -delay [expr ($::i%2) + 1] {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ UPDATE t1 SET x = randomblob(900);
+ ROLLBACK;
+ INSERT INTO t1 VALUES(randomblob(900));
+ }
+ execsql { PRAGMA integrity_check }
+ } {ok}
+
+ catch { db close }
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ do_test crash8-5.$i.2 {
+ execsql {
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(x PRIMARY KEY);
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 SELECT randomblob(900) FROM t1;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 rows */
+ BEGIN;
+ UPDATE t1 SET x = randomblob(900);
+ }
+ forcedelete testX.db testX.db-journal testX.db-wal
+ forcecopy test.db testX.db
+ forcecopy test.db-journal testX.db-journal
+ db close
+
+ crashsql -file test.db -delay [expr ($::i%2) + 1] {
+ SELECT * FROM sqlite_master;
+ INSERT INTO t1 VALUES(randomblob(900));
+ }
+
+ sqlite3 db2 testX.db
+ execsql { PRAGMA integrity_check } db2
+ } {ok}
+}
+catch {db2 close}
+
+finish_test
diff --git a/test/crashtest1.c b/test/crashtest1.c
new file mode 100644
index 0000000..1f7035d
--- /dev/null
+++ b/test/crashtest1.c
@@ -0,0 +1,96 @@
+/*
+** This program tests the ability of SQLite database to recover from a crash.
+** This program runs under Unix only, but the results are applicable to all
+** systems.
+**
+** The main process first constructs a test database, then starts creating
+** subprocesses that write to that database. Each subprocess is killed off,
+** without a chance to clean up its database connection, after a random
+** delay. This killing of the subprocesses simulates a crash or power
+** failure. The next subprocess to open the database should rollback
+** whatever operation was in process at the time of the simulated crash.
+**
+** If any problems are encountered, an error is reported and the test stops.
+** If no problems are seen after a large number of tests, we assume that
+** the rollback mechanism is working.
+*/
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sched.h>
+#include "sqlite.h"
+
+static void do_some_sql(int parent){
+ char *zErr;
+ int rc = SQLITE_OK;
+ sqlite *db;
+ int cnt = 0;
+ static char zBig[] =
+ "-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ if( access("./test.db-journal",0)==0 ){
+ /*printf("pid %d: journal exists. rollback will be required\n",getpid());*/ unlink("test.db-saved");
+ system("cp test.db test.db-saved");
+ unlink("test.db-journal-saved");
+ system("cp test.db-journal test.db-journal-saved");
+ }
+ db = sqlite_open("./test.db", 0, &zErr);
+ if( db==0 ){
+ printf("ERROR: %s\n", zErr);
+ if( strcmp(zErr,"database disk image is malformed")==0 ){
+ kill(parent, SIGKILL);
+ }
+ exit(1);
+ }
+ srand(getpid());
+ while( rc==SQLITE_OK ){
+ cnt++;
+ rc = sqlite_exec_printf(db,
+ "INSERT INTO t1 VALUES(%d,'%d%s')", 0, 0, &zErr,
+ rand(), rand(), zBig);
+ }
+ if( rc!=SQLITE_OK ){
+ printf("ERROR #%d: %s\n", rc, zErr);
+ if( rc==SQLITE_CORRUPT ){
+ kill(parent, SIGKILL);
+ }
+ }
+ printf("pid %d: cnt=%d\n", getpid(), cnt);
+}
+
+
+int main(int argc, char **argv){
+ int i;
+ sqlite *db;
+ char *zErr;
+ int status;
+ int parent = getpid();
+
+ unlink("test.db");
+ unlink("test.db-journal");
+ db = sqlite_open("test.db", 0, &zErr);
+ if( db==0 ){
+ printf("Cannot initialize: %s\n", zErr);
+ return 1;
+ }
+ sqlite_exec(db, "CREATE TABLE t1(a,b)", 0, 0, 0);
+ sqlite_close(db);
+ for(i=0; i<10000; i++){
+ int pid = fork();
+ if( pid==0 ){
+ sched_yield();
+ do_some_sql(parent);
+ return 0;
+ }
+ printf("test %d, pid=%d\n", i, pid);
+ usleep(rand()%10000 + 1000);
+ kill(pid, SIGKILL);
+ waitpid(pid, &status, 0);
+ }
+ return 0;
+}
diff --git a/test/createtab.test b/test/createtab.test
new file mode 100644
index 0000000..01e0b61
--- /dev/null
+++ b/test/createtab.test
@@ -0,0 +1,146 @@
+# 2007 May 02
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that it is OK to create new tables
+# and indices while creating existing tables and indices.
+#
+# $Id: createtab.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable autovacuum {
+ set upperBound 2
+} else {
+ set upperBound 0
+}
+
+# Run these tests for all possible values of autovacuum.
+#
+for {set av 0} {$av<=$upperBound} {incr av} {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+
+ # Create a table that spans multiple pages. It is important
+ # that part of the database be in pages beyond the root page.
+ #
+ do_test createtab-$av.1 {
+ execsql "PRAGMA auto_vacuum=$av"
+ execsql {
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(1, hex(randomblob(200)));
+ INSERT INTO t1 VALUES(2, hex(randomblob(200)));
+ INSERT INTO t1 VALUES(3, hex(randomblob(200)));
+ INSERT INTO t1 VALUES(4, hex(randomblob(200)));
+ SELECT count(*) FROM t1;
+ }
+ } {4}
+
+ set isUtf16 0
+ ifcapable utf16 {
+ set isUtf16 [expr {[execsql {PRAGMA encoding}] != "UTF-8"}]
+ }
+
+ do_test createtab-$av.2 {
+ file size test.db
+ } [expr {1024*(4+($av!=0)+(${isUtf16}*2))}]
+
+ # Start reading the table
+ #
+ do_test createtab-$av.3 {
+ set STMT [sqlite3_prepare db {SELECT x FROM t1} -1 TAIL]
+ sqlite3_step $STMT
+ } {SQLITE_ROW}
+ do_test createtab-$av.4 {
+ sqlite3_column_int $STMT 0
+ } {1}
+
+ # While still reading the table, create a new table.
+ #
+ do_test createtab-$av.5 {
+ execsql {
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+ } {1 2}
+
+ # Continue reading the original table.
+ #
+ do_test createtab-$av.6 {
+ sqlite3_column_int $STMT 0
+ } {1}
+ do_test createtab-$av.7 {
+ sqlite3_step $STMT
+ } {SQLITE_ROW}
+ do_test createtab-$av.8 {
+ sqlite3_column_int $STMT 0
+ } {2}
+
+ # Do another cycle of creating a new database table while contining
+ # to read the original table.
+ #
+ do_test createtab-$av.11 {
+ execsql {
+ CREATE TABLE t3(a,b);
+ INSERT INTO t3 VALUES(4,5);
+ SELECT * FROM t3;
+ }
+ } {4 5}
+ do_test createtab-$av.12 {
+ sqlite3_column_int $STMT 0
+ } {2}
+ do_test createtab-$av.13 {
+ sqlite3_step $STMT
+ } {SQLITE_ROW}
+ do_test createtab-$av.14 {
+ sqlite3_column_int $STMT 0
+ } {3}
+
+ # One more cycle.
+ #
+ do_test createtab-$av.21 {
+ execsql {
+ CREATE TABLE t4(a,b);
+ INSERT INTO t4 VALUES('abc','xyz');
+ SELECT * FROM t4;
+ }
+ } {abc xyz}
+ do_test createtab-$av.22 {
+ sqlite3_column_int $STMT 0
+ } {3}
+ do_test createtab-$av.23 {
+ sqlite3_step $STMT
+ } {SQLITE_ROW}
+ do_test createtab-$av.24 {
+ sqlite3_column_int $STMT 0
+ } {4}
+
+ # Finish reading. Do an integrity check on the database.
+ #
+ do_test createtab-$av.30 {
+ sqlite3_step $STMT
+ } {SQLITE_DONE}
+ do_test createtab-$av.31 {
+ sqlite3_finalize $STMT
+ } {SQLITE_OK}
+ do_test createtab-$av.32 {
+ execsql {
+ SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1
+ }
+ } {t1 t2 t3 t4}
+ integrity_check createtab-$av.40
+
+}
+
+finish_test
diff --git a/test/crypto.test b/test/crypto.test
new file mode 100644
index 0000000..aabb481
--- /dev/null
+++ b/test/crypto.test
@@ -0,0 +1,1148 @@
+# SQLCipher
+# codec.test developed by Stephen Lombardo (Zetetic LLC)
+# sjlombardo at zetetic dot net
+# http://zetetic.net
+#
+# Copyright (c) 2009, ZETETIC LLC
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the ZETETIC LLC nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing code cipher features.
+#
+# NOTE: tester.tcl has overridden the definition of sqlite3 to
+# automatically pass in a key value. Thus tests in this file
+# should explicitly close and open db with sqlite_orig in order
+# to bypass default key assignment.
+
+
+file delete -force test.db
+file delete -force test2.db
+file delete -force test3.db
+file delete -force test4.db
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If the library is not compiled with has_codec support then
+# skip all tests in this file.
+if {![sqlite_orig -has-codec]} {
+ finish_test
+ return
+}
+
+proc setup {file key} {
+ sqlite_orig db $file
+ execsql "PRAGMA key=$key;"
+ execsql {
+ CREATE table t1(a,b);
+ INSERT INTO t1 VALUES ('test1', 'test2');
+ } db
+ db close
+}
+
+# The database is initially empty.
+# set an hex key create some basic data
+# create table and insert operations should work
+# close database, open it again with the same
+# hex key. verify that the table is readable
+# and the data just inserted is visible
+setup test.db "\"x'98483C6EB40B6C31A448C22A66DED3B5E5E8D5119CAC8327B655C8B5C4836481'\""
+do_test will-open-with-correct-raw-key {
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = "x'98483C6EB40B6C31A448C22A66DED3B5E5E8D5119CAC8327B655C8B5C4836481'";
+ SELECT name FROM sqlite_master WHERE type='table';
+ SELECT * from t1;
+ }
+} {t1 test1 test2}
+db close
+file delete -force test.db
+
+# set an encryption key (non-hex) and create some basic data
+# create table and insert operations should work
+# close database, open it again with the same
+# key. verify that the table is readable
+# and the data just inserted is visible
+setup test.db "'testkey'"
+do_test will-open-with-correct-derived-key {
+
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ SELECT name FROM sqlite_master WHERE type='table';
+ SELECT * from t1;
+ }
+} {t1 test1 test2}
+db close
+file delete -force test.db
+
+# open the database and try to read from it without
+# providing a passphrase. verify that the
+# an error is returned from the library
+setup test.db "'testkey'"
+do_test wont-open-without-key {
+ sqlite_orig db test.db
+ catchsql {
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {1 {file is encrypted or is not a database}}
+db close
+file delete -force test.db
+
+# open the database and try to set an invalid
+# passphrase. verify that an error is returned
+# and that data couldn't be read
+setup test.db "'testkey'"
+do_test wont-open-with-invalid-derived-key {
+ sqlite_orig db test.db
+ catchsql {
+ PRAGMA key = 'testkey2';
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {1 {file is encrypted or is not a database}}
+db close
+file delete -force test.db
+
+# open the database and try to set an invalid
+# hex key. verify that an error is returned
+# and that data couldn't be read
+setup test.db "'testkey'"
+do_test wont-open-with-invalid-raw-key {
+ sqlite_orig db test.db
+ catchsql {
+ PRAGMA key = "x'98483C6EB40B6C31A448C22A66DED3B5E5E8D5119CAC8327B655C8B5C4836480'";
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {1 {file is encrypted or is not a database}}
+db close
+file delete -force test.db
+
+# test a large number of inserts in a transaction to a memory database
+do_test memory-database {
+ sqlite_orig db :memory:
+ execsql {
+ PRAGMA key = 'testkey3';
+ BEGIN;
+ CREATE TABLE t2(a,b);
+ }
+ for {set i 1} {$i<=25000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t2 VALUES($i,$r);"
+ }
+ execsql {
+ COMMIT;
+ SELECT count(*) FROM t2;
+ DELETE FROM t2;
+ SELECT count(*) FROM t2;
+ }
+} {25000 0}
+db close
+
+# test a large number of inserts in a transaction for multiple pages
+do_test multi-page-database {
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ CREATE TABLE t2(a,b);
+ BEGIN;
+ }
+ for {set i 1} {$i<=25000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t2 VALUES($i,$r);"
+ }
+ execsql {
+ COMMIT;
+ SELECT count(*) FROM t2;
+ }
+} {25000}
+db close
+file delete -force test.db
+
+# test a rekey operation as the first op on a database
+# then test that now the new key opens the database
+# now close database re-open with new key
+setup test.db "'testkey'"
+do_test rekey-as-first-operation {
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA rekey = 'testkeynew';
+ }
+ db close
+
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkeynew';
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {t1}
+db close
+file delete -force test.db
+
+# attach an encrypted database
+# where both database have the same
+# key
+setup test.db "'testkey'"
+do_test attach-database-with-same-key {
+ sqlite_orig db2 test2.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2 VALUES ('test1', 'test2');
+ } db2
+
+ execsql {
+ SELECT count(*) FROM t2;
+ ATTACH 'test.db' AS db;
+ SELECT count(*) FROM db.t1;
+ } db2
+
+} {1 1}
+db2 close
+file delete -force test.db
+file delete -force test2.db
+
+# attach an encrypted database
+# where databases have different keys
+setup test.db "'testkey'"
+do_test attach-database-with-different-keys {
+ sqlite_orig db2 test2.db
+
+ execsql {
+ PRAGMA key = 'testkey2';
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2 VALUES ('test1', 'test2');
+ } db2
+
+ execsql {
+ ATTACH 'test.db' AS db KEY 'testkey';
+ SELECT count(*) FROM db.t1;
+ SELECT count(*) FROM t2;
+ } db2
+
+} {1 1}
+db2 close
+file delete -force test.db
+file delete -force test2.db
+
+# test locking across multiple handles
+setup test.db "'testkey'"
+do_test locking-across-multiple-handles-start {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ BEGIN EXCLUSIVE;
+ INSERT INTO t1 VALUES(1,2);
+ }
+
+ sqlite_orig dba test.db
+ catchsql {
+ PRAGMA key = 'testkey';
+ SELECT count(*) FROM t1;
+ } dba
+
+ } {1 {database is locked}}
+
+do_test locking-accross-multiple-handles-finish {
+ execsql {
+ COMMIT;
+ }
+
+ execsql {
+ SELECT count(*) FROM t1;
+ } dba
+} {2}
+db close
+dba close
+file delete -force test.db
+
+# alter schema
+setup test.db "'testkey'"
+do_test alter-schema {
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ ALTER TABLE t1 ADD COLUMN c;
+ INSERT INTO t1 VALUES (1,2,3);
+ INSERT INTO t1 VALUES (1,2,4);
+ CREATE TABLE t1a (a);
+ INSERT INTO t1a VALUES ('teststring');
+ }
+ db close
+
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ SELECT count(*) FROM t1 WHERE a IS NOT NULL;
+ SELECT count(*) FROM t1 WHERE c IS NOT NULL;
+ SELECT * FROM t1a;
+ }
+
+} {3 2 teststring}
+db close
+file delete -force test.db
+
+# test alterations of KDF iterations and ciphers
+# rekey then add
+setup test.db "'testkey'"
+do_test non-standard-kdf-and-ciphers {
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA rekey_kdf_iter = 1000;
+ PRAGMA rekey_cipher = 'aes-256-cfb';
+ PRAGMA rekey = 'testkey2';
+ INSERT INTO t1 VALUES (1,2);
+ }
+ db close
+
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey2';
+ PRAGMA kdf_iter = 1000;
+ PRAGMA cipher = 'aes-256-cfb';
+ SELECT count(*) FROM t1;
+ }
+
+} {2}
+db close
+file delete -force test.db
+
+# test alterations of CIPHER from CBC Mode requiring
+# IV to ECB mode that does not
+setup test.db "'testkey'"
+do_test rekey-from-cbc-to-ecb-no-iv {
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,$r);"
+ }
+
+ execsql {
+ COMMIT;
+ PRAGMA rekey_kdf_iter = 1000;
+ PRAGMA rekey_cipher = 'aes-128-ecb';
+ PRAGMA rekey = 'testkey';
+ }
+ db close
+
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA kdf_iter = 1000;
+ PRAGMA cipher = 'aes-128-ecb';
+ SELECT count(*) FROM t1;
+ }
+
+} {1001}
+db close
+file delete -force test.db
+
+# test alterations of CIPHER from ECB Mode (no IV) to CBC Mode
+do_test rekey-from-ecb-to-cbc-with-iv {
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA cipher = 'aes-256-ecb';
+ CREATE table t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,$r);"
+ }
+
+ execsql {
+ COMMIT;
+ PRAGMA rekey_cipher = 'aes-256-cbc';
+ PRAGMA rekey = 'testkey';
+ }
+ db close
+
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ SELECT count(*) FROM t1;
+ }
+
+} {1000}
+db close
+file delete -force test.db
+
+# create an unencrypted database, attach a new encrypted volume
+# copy data between, verify the encypted database is good afterwards
+do_test unencryped-attach {
+ sqlite_orig db test.db
+
+ execsql {
+ CREATE TABLE t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,$r);"
+ }
+
+ execsql {
+ COMMIT;
+ ATTACH DATABASE 'test2.db' AS db2 KEY 'testkey';
+ CREATE TABLE db2.t1(a,b);
+ INSERT INTO db2.t1 SELECT * FROM t1;
+ DETACH DATABASE db2;
+ }
+
+ sqlite_orig db2 test2.db
+ execsql {
+ PRAGMA key='testkey';
+ SELECT count(*) FROM t1;
+ } db2
+} {1000}
+db2 close
+file delete -force test.db
+file delete -force test2.db
+
+# create an unencrypted database, attach a new encrypted volume
+# using a raw key copy data between, verify the encypted
+# database is good afterwards
+do_test unencryped-attach-raw-key {
+ sqlite_orig db test.db
+
+ execsql {
+ CREATE TABLE t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,$r);"
+ }
+
+ execsql {
+ COMMIT;
+ ATTACH DATABASE 'test2.db' AS db2 KEY "x'10483C6EB40B6C31A448C22A66DED3B5E5E8D5119CAC8327B655C8B5C4836481'";
+ CREATE TABLE db2.t1(a,b);
+ INSERT INTO db2.t1 SELECT * FROM t1;
+ DETACH DATABASE db2;
+ }
+
+ sqlite_orig db2 test2.db
+ execsql {
+ PRAGMA key="x'10483C6EB40B6C31A448C22A66DED3B5E5E8D5119CAC8327B655C8B5C4836481'";
+ SELECT count(*) FROM t1;
+ } db2
+} {1000}
+db2 close
+file delete -force test.db
+file delete -force test2.db
+
+# create an encrypted database, attach an unencrypted volume
+# copy data between, verify the unencypted database is good afterwards
+do_test encryped-attach-unencrypted {
+ sqlite_orig db test.db
+
+ execsql {
+ CREATE TABLE t1(a,b);
+ }
+
+ sqlite_orig db2 test2.db
+ execsql {
+ PRAGMA key='testkey';
+ CREATE TABLE t1(a,b);
+ BEGIN;
+ } db2
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,$r);" db2
+ }
+
+ execsql {
+ COMMIT;
+ ATTACH DATABASE 'test.db' AS test KEY '';
+ INSERT INTO test.t1 SELECT * FROM t1;
+ DETACH DATABASE test;
+ } db2
+
+ execsql {
+ SELECT count(*) FROM t1;
+ }
+} {1000}
+db close
+db2 close
+file delete -force test.db
+file delete -force test2.db
+
+# create an unencrypted database, attach an unencrypted volume
+# copy data between, verify the unencypted database is good afterwards
+do_test unencryped-attach-unencrypted {
+ sqlite_orig db test.db
+
+ execsql {
+ CREATE TABLE t1(a,b);
+ }
+
+ sqlite_orig db2 test2.db
+ execsql {
+ CREATE TABLE t1(a,b);
+ BEGIN;
+ } db2
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,$r);" db2
+ }
+
+ execsql {
+ COMMIT;
+ ATTACH DATABASE 'test.db' AS test;
+ INSERT INTO test.t1 SELECT * FROM t1;
+ DETACH DATABASE test;
+ } db2
+
+ execsql {
+ SELECT count(*) FROM t1;
+ }
+} {1000}
+db close
+db2 close
+file delete -force test.db
+file delete -force test2.db
+
+# 1. create a database with a custom page size,
+# 2. create table and insert operations should work
+# 3. close database, open it again with the same
+# key and page size
+# 4. verify that the table is readable
+# and the data just inserted is visible
+do_test custom-pagesize {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA cipher_page_size = 4096;
+ CREATE table t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,'value $r');"
+ }
+
+ execsql {
+ COMMIT;
+ }
+
+ db close
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA cipher_page_size = 4096;
+ SELECT count(*) FROM t1;
+ }
+
+} {1000}
+db close
+
+# open the database with the default page size
+## and verfiy that it is not readable
+do_test custom-pagesize-must-match {
+ sqlite_orig db test.db
+ catchsql {
+ PRAGMA key = 'testkey';
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {1 {file is encrypted or is not a database}}
+db close
+file delete -force test.db
+
+# 1. create a database and insert a bunch of data, close the database
+# 2. seek to the middle of a database page and write some junk
+# 3. Open the database and verify that the database is no longer readable
+do_test hmac-tamper-resistence {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ CREATE table t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,'value $r');"
+ }
+
+ execsql {
+ COMMIT;
+ }
+
+ db close
+
+ # write some junk into the middle of the page
+ hexio_write test.db 2560 00
+
+ sqlite_orig db test.db
+
+ catchsql {
+ PRAGMA key = 'testkey';
+ SELECT count(*) FROM t1;
+ }
+
+} {1 {database disk image is malformed}}
+db close
+file delete -force test.db
+
+# 1. create a database and insert a bunch of data, close the database
+# 2. seek to the middle of a database page and write some junk
+# 3. Open the database and verify that the database is still readable
+do_test nohmac-not-tamper-resistent {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA cipher_use_hmac = OFF;
+ PRAGMA cipher_page_size = 1024;
+ CREATE table t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,'value $r');"
+ }
+
+ execsql {
+ COMMIT;
+ }
+
+ db close
+
+ # write some junk into the middle of the page
+ hexio_write test.db 2560 00
+
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA cipher_use_hmac = OFF;
+ PRAGMA cipher_page_size = 1024;
+ SELECT count(*) FROM t1;
+ }
+
+} {1000}
+db close
+file delete -force test.db
+
+# open a 1.1.8 database using the new code, HMAC disabled
+do_test open-1.1.8-database {
+ sqlite_orig db sqlcipher-1.1.8-testkey.db
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA cipher_use_hmac = OFF;
+ SELECT count(*) FROM t1;
+ SELECT * FROM t1;
+ }
+} {4 1 1 one one 1 2 one two}
+db close
+
+
+# open a 1.1.8 database without hmac, then copy the data
+do_test attach-and-copy-1.1.8 {
+ sqlite_orig db sqlcipher-1.1.8-testkey.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA cipher_use_hmac = OFF;
+ ATTACH DATABASE 'test.db' AS db2 KEY 'testkey-hmac';
+ CREATE TABLE db2.t1(a,b);
+ INSERT INTO db2.t1 SELECT * FROM main.t1;
+ DETACH DATABASE db2;
+ }
+ db close
+
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey-hmac';
+ SELECT count(*) FROM t1;
+ SELECT * FROM t1;
+ }
+} {4 1 1 one one 1 2 one two}
+db close
+file delete -force test.db
+
+# open a standard database, then attach a new
+# database with completely different options.
+# copy data between them, and verify that the
+# new database can be opened with the proper data
+do_test attached-database-pragmas {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ CREATE TABLE t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,'value $r');"
+ }
+
+ execsql {
+ COMMIT;
+ ATTACH DATABASE 'test2.db' AS db2 KEY 'testkey2';
+ PRAGMA db2.cipher_page_size = 4096;
+ PRAGMA db2.cipher = 'aes-128-cbc';
+ PRAGMA db2.kdf_iter = 1000;
+ PRAGMA db2.cipher_use_hmac = OFF;
+ CREATE TABLE db2.t1(a,b);
+ INSERT INTO db2.t1 SELECT * FROM main.t1;
+ DETACH DATABASE db2;
+ }
+ db close
+
+ sqlite_orig db test2.db
+ execsql {
+ PRAGMA key = 'testkey2';
+ PRAGMA cipher_page_size = 4096;
+ PRAGMA cipher = 'aes-128-cbc';
+ PRAGMA kdf_iter = 1000;
+ PRAGMA cipher_use_hmac = OFF;
+ SELECT count(*) FROM t1;
+ }
+} {1000}
+db close
+file delete -force test.db
+file delete -force test2.db
+
+# use the sqlcipher_export function
+# on a non-existent database. Verify
+# the error gets through.
+do_test export-error {
+ sqlite_orig db test.db
+
+ catchsql {
+ PRAGMA key = 'testkey';
+ CREATE TABLE t1(a,b);
+ SELECT sqlcipher_export('nodb');
+ }
+} {1 {unknown database nodb}}
+db close
+file delete -force test.db
+
+# use the sqlcipher_export function
+# to copy a complicated database.
+# tests autoincrement fields,
+# indexes, views, and triggers,
+# tables and virtual tables
+do_test export-database {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b, c);
+ CREATE UNIQUE INDEX b_idx ON t1(b);
+ CREATE INDEX c_idx ON t1(c);
+
+ CREATE TABLE t2(b,c);
+ CREATE TRIGGER t2_after_insert AFTER INSERT ON t2
+ BEGIN
+ INSERT INTO t1(b,c) VALUES (new.b, new.c);
+ END;
+
+ CREATE VIEW v1 AS
+ SELECT c FROM t1;
+
+ CREATE VIRTUAL TABLE fts USING fts3(a,b);
+
+ BEGIN;
+ -- start with one known value
+ INSERT INTO t2 VALUES(1000000,'value 1000000');
+ }
+
+ for {set i 1} {$i<=999} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t2 VALUES($i,'value $r');"
+ }
+
+ execsql {
+ INSERT INTO fts SELECT b,c FROM t1;
+ COMMIT;
+
+ ATTACH DATABASE 'test2.db' AS db2 KEY 'testkey2';
+ PRAGMA db2.cipher_page_size = 4096;
+
+ SELECT sqlcipher_export('db2');
+
+ DETACH DATABASE db2;
+ }
+ db close
+
+ sqlite_orig db test2.db
+ execsql {
+ PRAGMA key = 'testkey2';
+ PRAGMA cipher_page_size = 4096;
+ SELECT count(*) FROM t1;
+ SELECT count(*) FROM v1;
+ SELECT count(*) FROM sqlite_sequence;
+ SELECT seq FROM sqlite_sequence WHERE name = 't1';
+ INSERT INTO t2 VALUES(10001, 'value 938383');
+ SELECT count(*) FROM t1; -- verify the trigger worked
+ SELECT seq FROM sqlite_sequence WHERE name = 't1'; -- verify that autoincrement worked
+ SELECT a FROM fts WHERE b MATCH '1000000';
+ }
+} {1000 1000 1 1000 1001 1001 1000000}
+db close
+file copy -force test.db test-debug.db
+file copy -force test2.db test2-debug.db
+file delete -force test.db
+file delete -force test2.db
+
+# 1. create a database with WAL journal mode
+# 2. create table and insert operations should work
+# 3. close database, open it again
+# 4. verify that the table is present, readable, and that
+# the journal mode is WAL
+do_test journal-mode-wal {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA journal_mode = WAL;
+ CREATE table t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,'value $r');"
+ }
+
+ execsql {
+ COMMIT;
+ }
+
+ db close
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ SELECT count(*) FROM t1;
+ PRAGMA journal_mode;
+ }
+
+} {1000 wal}
+db close
+file delete -force test.db
+
+# Test rekey as first operation on an empty database. should be a no-op
+do_test rekey-as-first-op {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA rekey = 'testkey';
+ CREATE table t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=100} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,'value $r');"
+ }
+
+ execsql {
+ COMMIT;
+ }
+
+ db close
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA rekey = 'testkey';
+ SELECT count(*) FROM t1;
+ }
+
+} {100}
+db close
+file delete -force test.db
+
+# Test rekey as first operation follwed by key
+do_test rekey-then-key-as-first-ops {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA rekey = '1234';
+ PRAGMA key = 'testkey';
+ CREATE table t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=100} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,'value $r');"
+ }
+
+ execsql {
+ COMMIT;
+ }
+
+ db close
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA rekey = '4321';
+ PRAGMA key = 'testkey';
+ SELECT count(*) FROM t1;
+ }
+
+} {100}
+db close
+file delete -force test.db
+
+setup test.db "'testkey'"
+do_test multiple-key-calls-safe-1 {
+ sqlite_orig db test.db
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA cache_size = 0;
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {t1}
+
+do_test multiple-key-calls-safe-2 {
+ catchsql {
+ PRAGMA key = 'wrong key';
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {1 {file is encrypted or is not a database}}
+
+do_test multiple-key-calls-safe-3 {
+ execsql {
+ PRAGMA key = 'testkey';
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {t1}
+
+db close
+file delete -force test.db
+
+# 1. create a database with a custom hmac kdf iteration count,
+# 2. create table and insert operations should work
+# 3. close database, open it again with the same
+# key and hmac kdf iteration count
+# 4. verify that the table is readable
+# and the data just inserted is visible
+do_test custom-hmac-kdf-iter {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA fast_kdf_iter = 10;
+ CREATE table t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=1000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,'value $r');"
+ }
+
+ execsql {
+ COMMIT;
+ }
+
+ db close
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA fast_kdf_iter = 10;
+ SELECT count(*) FROM t1;
+ }
+
+} {1000}
+db close
+
+# open the database with the default hmac
+# kdf iteration count
+# to verify that it is not readable
+do_test custom-hmac-kdf-iter-must-match {
+ sqlite_orig db test.db
+ catchsql {
+ PRAGMA key = 'testkey';
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {1 {file is encrypted or is not a database}}
+db close
+file delete -force test.db
+
+# open the database and turn on auto_vacuum
+# then insert a bunch of data, delete it
+# and verify that the file has become smaller
+# but can still be opened with the proper
+# key
+do_test auto-vacuum {
+ sqlite_orig db test.db
+ set rc {}
+
+ execsql {
+ PRAGMA key = 'testkey';
+ PRAGMA auto_vacuum=FULL;
+ CREATE table t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=10000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,'value $r');"
+ }
+
+ lappend rc [execsql {
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }]
+
+ # grab current size of file
+ set sz [file size test.db]
+
+ # delete some records, and verify
+ # autovacuum removes them
+ execsql {
+ DELETE FROM t1 WHERE rowid > 5000;
+ }
+
+ db close
+
+ # grab new file size, post
+ # autovacuum
+ set sz2 [file size test.db]
+
+ # verify that the new size is
+ # smaller than the old size
+ if {$sz > $sz2} { lappend rc true }
+
+ sqlite_orig db test.db
+
+ lappend rc [execsql {
+ PRAGMA key = 'testkey';
+ SELECT count(*) FROM t1;
+ }]
+
+} {10000 true 5000}
+db close
+file delete -force test.db
+
+# open the database then insert a bunch of data.
+# then delete it and run a manual vacuum
+# verify that the file has become smaller
+# but can still be opened with the proper
+# key
+do_test vacuum {
+ sqlite_orig db test.db
+ set rc {}
+
+ execsql {
+ PRAGMA key = 'testkey';
+ CREATE table t1(a,b);
+ BEGIN;
+ }
+
+ for {set i 1} {$i<=10000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ execsql "INSERT INTO t1 VALUES($i,'value $r');"
+ }
+
+ lappend rc [execsql {
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }]
+
+ # grab current size of file
+ set sz [file size test.db]
+
+ execsql {
+ DELETE FROM t1 WHERE rowid > 5000;
+ VACUUM;
+ }
+ db close
+
+ # grab new file size, post
+ # autovacuum
+ set sz2 [file size test.db]
+
+ # verify that the new size is
+ # smaller than the old size
+ if {$sz > $sz2} { lappend rc true }
+
+ sqlite_orig db test.db
+ lappend rc [execsql {
+ PRAGMA key = 'testkey';
+ SELECT count(*) FROM t1;
+ }]
+
+} {10000 true 5000}
+db close
+file delete -force test.db
+
+# test kdf_iter and other pragmas
+# before a key is set. Verify that they
+# are no-ops
+do_test cipher-options-before-keys {
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA kdf_iter = 1000;
+ PRAGMA cipher_page_size = 4096;
+ PRAGMA cipher = 'aes-128-cbc';
+ PRAGMA cipher_use_hmac = OFF;
+ PRAGMA key = 'testkey';
+ CREATE table t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ }
+ db close
+
+ sqlite_orig db test.db
+
+ execsql {
+ PRAGMA key = 'testkey';
+ SELECT count(*) FROM t1;
+ }
+
+} {1}
+db close
+file delete -force test.db
+
+finish_test
diff --git a/test/cse.test b/test/cse.test
new file mode 100644
index 0000000..57cdef5
--- /dev/null
+++ b/test/cse.test
@@ -0,0 +1,160 @@
+# 2008 April 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test cases designed to exercise and verify the logic for
+# factoring constant expressions out of loops and for
+# common subexpression eliminations.
+#
+# $Id: cse.test,v 1.6 2008/08/04 03:51:24 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test cse-1.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d, e, f);
+ INSERT INTO t1 VALUES(1,11,12,13,14,15);
+ INSERT INTO t1 VALUES(2,21,22,23,24,25);
+ }
+ execsql {
+ SELECT b, -b, ~b, NOT b, NOT NOT b, b-b, b+b, b*b, b/b, b FROM t1
+ }
+} {11 -11 -12 0 1 0 22 121 1 11 21 -21 -22 0 1 0 42 441 1 21}
+do_test cse-1.2 {
+ execsql {
+ SELECT b, b%b, b==b, b!=b, b<b, b<=b, b IS NULL, b NOT NULL, b FROM t1
+ }
+} {11 0 1 0 0 1 0 1 11 21 0 1 0 0 1 0 1 21}
+do_test cse-1.3 {
+ execsql {
+ SELECT b, abs(b), coalesce(b,-b,NOT b,c,NOT c), c, -c FROM t1;
+ }
+} {11 11 11 12 -12 21 21 21 22 -22}
+do_test cse-1.4 {
+ execsql {
+ SELECT CASE WHEN a==1 THEN b ELSE c END, b, c FROM t1
+ }
+} {11 11 12 22 21 22}
+do_test cse-1.5 {
+ execsql {
+ SELECT CASE a WHEN 1 THEN b WHEN 2 THEN c ELSE d END, b, c, d FROM t1
+ }
+} {11 11 12 13 22 21 22 23}
+do_test cse-1.6.1 {
+ execsql {
+ SELECT CASE b WHEN 11 THEN -b WHEN 21 THEN -c ELSE -d END, b, c, d FROM t1
+ }
+} {-11 11 12 13 -22 21 22 23}
+do_test cse-1.6.2 {
+ execsql {
+ SELECT CASE b+1 WHEN c THEN d WHEN e THEN f ELSE 999 END, b, c, d FROM t1
+ }
+} {13 11 12 13 23 21 22 23}
+do_test cse-1.6.3 {
+ execsql {
+ SELECT CASE WHEN b THEN d WHEN e THEN f ELSE 999 END, b, c, d FROM t1
+ }
+} {13 11 12 13 23 21 22 23}
+do_test cse-1.6.4 {
+ execsql {
+ SELECT b, c, d, CASE WHEN b THEN d WHEN e THEN f ELSE 999 END FROM t1
+ }
+} {11 12 13 13 21 22 23 23}
+do_test cse-1.6.5 {
+ execsql {
+ SELECT b, c, d, CASE WHEN 0 THEN d WHEN e THEN f ELSE 999 END FROM t1
+ }
+} {11 12 13 15 21 22 23 25}
+do_test cse-1.7 {
+ execsql {
+ SELECT a, -a, ~a, NOT a, NOT NOT a, a-a, a+a, a*a, a/a, a FROM t1
+ }
+} {1 -1 -2 0 1 0 2 1 1 1 2 -2 -3 0 1 0 4 4 1 2}
+do_test cse-1.8 {
+ execsql {
+ SELECT a, a%a, a==a, a!=a, a<a, a<=a, a IS NULL, a NOT NULL, a FROM t1
+ }
+} {1 0 1 0 0 1 0 1 1 2 0 1 0 0 1 0 1 2}
+do_test cse-1.9 {
+ execsql {
+ SELECT NOT b, ~b, NOT NOT b, b FROM t1
+ }
+} {0 -12 1 11 0 -22 1 21}
+do_test cse-1.10 {
+ execsql {
+ SELECT CAST(b AS integer), typeof(b), CAST(b AS text), typeof(b) FROM t1
+ }
+} {11 integer 11 integer 21 integer 21 integer}
+ifcapable compound {
+ do_test cse-1.11 {
+ execsql {
+ SELECT *,* FROM t1 WHERE a=2
+ UNION ALL
+ SELECT *,* FROM t1 WHERE a=1
+ }
+ } {2 21 22 23 24 25 2 21 22 23 24 25 1 11 12 13 14 15 1 11 12 13 14 15}
+ do_test cse-1.12 {
+ execsql {
+ SELECT coalesce(b,c,d,e), a, b, c, d, e FROM t1 WHERE a=2
+ UNION ALL
+ SELECT coalesce(e,d,c,b), e, d, c, b, a FROM t1 WHERE a=1
+ }
+ } {21 2 21 22 23 24 14 14 13 12 11 1}
+}
+do_test cse-1.13 {
+ execsql {
+ SELECT upper(b), typeof(b), b FROM t1
+ }
+} {11 integer 11 21 integer 21}
+do_test cse-1.14 {
+ execsql {
+ SELECT b, typeof(b), upper(b), typeof(b), b FROM t1
+ }
+} {11 integer 11 integer 11 21 integer 21 integer 21}
+
+# Overflow the column cache. Create queries involving more and more
+# columns until the cache overflows. Verify correct operation throughout.
+#
+do_test cse-2.1 {
+ execsql {
+ CREATE TABLE t2(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,
+ a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,
+ a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,
+ a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,
+ a40,a41,a42,a43,a44,a45,a46,a47,a48,a49);
+ INSERT INTO t2 VALUES(0,1,2,3,4,5,6,7,8,9,
+ 10,11,12,13,14,15,16,17,18,19,
+ 20,21,22,23,24,25,26,27,28,29,
+ 30,31,32,33,34,35,36,37,38,39,
+ 40,41,42,43,44,45,46,47,48,49);
+ SELECT * FROM t2;
+ }
+} {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49}
+
+for {set i 1} {$i<100} {incr i} {
+ set n [expr {int(rand()*44)+5}]
+ set colset {}
+ set answer {}
+ for {set j 0} {$j<$n} {incr j} {
+ set r [expr {$j+int(rand()*5)}]
+ if {$r>49} {set r [expr {99-$r}]}
+ lappend colset a$j a$r
+ lappend answer $j $r
+ }
+ set sql "SELECT [join $colset ,] FROM t2"
+ do_test cse-2.2.$i {
+ # explain $::sql
+ execsql $::sql
+ } $answer
+}
+
+finish_test
diff --git a/test/ctime.test b/test/ctime.test
new file mode 100644
index 0000000..e4cb156
--- /dev/null
+++ b/test/ctime.test
@@ -0,0 +1,227 @@
+# 2009 February 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the compile time diagnostic
+# functions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Test organization:
+#
+# ctime-1.*: Test pragma support.
+# ctime-2.*: Test function support.
+#
+
+ifcapable !pragma||!compileoption_diags {
+ finish_test
+ return
+}
+
+#####################
+# ctime-1.*: Test pragma support.
+
+do_test ctime-1.1.1 {
+ catchsql {
+ PRAGMA compile_options();
+ }
+} {1 {near ")": syntax error}}
+do_test ctime-1.1.2 {
+ catchsql {
+ PRAGMA compile_options(NULL);
+ }
+} {1 {near "NULL": syntax error}}
+do_test ctime-1.1.3 {
+ catchsql {
+ PRAGMA compile_options *;
+ }
+} {1 {near "*": syntax error}}
+
+do_test ctime-1.2.1 {
+ set ans [ catchsql {
+ PRAGMA compile_options;
+ } ]
+ list [ lindex $ans 0 ]
+} {0}
+# the results should be in sorted order already
+do_test ctime-1.2.2 {
+ set ans [ catchsql {
+ PRAGMA compile_options;
+ } ]
+ list [ lindex $ans 0 ] [ expr { [lsort [lindex $ans 1]]==[lindex $ans 1] } ]
+} {0 1}
+
+# SQLITE_THREADSAFE should pretty much always be defined
+# one way or the other, and it must have a value of 0 or 1.
+do_test ctime-1.4.1 {
+ catchsql {
+ SELECT sqlite_compileoption_used('SQLITE_THREADSAFE');
+ }
+} {0 1}
+do_test ctime-1.4.2 {
+ catchsql {
+ SELECT sqlite_compileoption_used('THREADSAFE');
+ }
+} {0 1}
+do_test ctime-1.4.3 {
+ catchsql {
+ SELECT sqlite_compileoption_used("THREADSAFE");
+ }
+} {0 1}
+
+do_test ctime-1.5 {
+ set ans1 [ catchsql {
+ SELECT sqlite_compileoption_used('THREADSAFE=0');
+ } ]
+ set ans2 [ catchsql {
+ SELECT sqlite_compileoption_used('THREADSAFE=1');
+ } ]
+ set ans3 [ catchsql {
+ SELECT sqlite_compileoption_used('THREADSAFE=2');
+ } ]
+ lsort [ list $ans1 $ans2 $ans3 ]
+} {{0 0} {0 0} {0 1}}
+
+do_test ctime-1.6 {
+ execsql {
+ SELECT sqlite_compileoption_used('THREADSAFE=');
+ }
+} {0}
+
+do_test ctime-1.7.1 {
+ execsql {
+ SELECT sqlite_compileoption_used('SQLITE_OMIT_COMPILEOPTION_DIAGS');
+ }
+} {0}
+do_test ctime-1.7.2 {
+ execsql {
+ SELECT sqlite_compileoption_used('OMIT_COMPILEOPTION_DIAGS');
+ }
+} {0}
+
+#####################
+# ctime-2.*: Test function support.
+
+do_test ctime-2.1.1 {
+ catchsql {
+ SELECT sqlite_compileoption_used();
+ }
+} {1 {wrong number of arguments to function sqlite_compileoption_used()}}
+do_test ctime-2.1.2 {
+ catchsql {
+ SELECT sqlite_compileoption_used(NULL);
+ }
+} {0 {{}}}
+do_test ctime-2.1.3 {
+ catchsql {
+ SELECT sqlite_compileoption_used("");
+ }
+} {0 0}
+do_test ctime-2.1.4 {
+ catchsql {
+ SELECT sqlite_compileoption_used('');
+ }
+} {0 0}
+do_test ctime-2.1.5 {
+ catchsql {
+ SELECT sqlite_compileoption_used(foo);
+ }
+} {1 {no such column: foo}}
+do_test ctime-2.1.6 {
+ catchsql {
+ SELECT sqlite_compileoption_used('THREADSAFE', 0);
+ }
+} {1 {wrong number of arguments to function sqlite_compileoption_used()}}
+do_test ctime-2.1.7 {
+ catchsql {
+ SELECT sqlite_compileoption_used(0);
+ }
+} {0 0}
+do_test ctime-2.1.8 {
+ catchsql {
+ SELECT sqlite_compileoption_used('0');
+ }
+} {0 0}
+do_test ctime-2.1.9 {
+ catchsql {
+ SELECT sqlite_compileoption_used(1.0);
+ }
+} {0 0}
+
+do_test ctime-2.2.1 {
+ catchsql {
+ SELECT sqlite_compileoption_get();
+ }
+} {1 {wrong number of arguments to function sqlite_compileoption_get()}}
+do_test ctime-2.2.2 {
+ catchsql {
+ SELECT sqlite_compileoption_get(0, 0);
+ }
+} {1 {wrong number of arguments to function sqlite_compileoption_get()}}
+
+# This assumes there is at least 1 compile time option
+# (see SQLITE_THREADSAFE above).
+do_test ctime-2.3 {
+ catchsql {
+ SELECT sqlite_compileoption_used(sqlite_compileoption_get(0));
+ }
+} {0 1}
+
+# This assumes there is at least 1 compile time option
+# (see SQLITE_THREADSAFE above).
+do_test ctime-2.4 {
+ set ans [ catchsql {
+ SELECT sqlite_compileoption_get(0);
+ } ]
+ list [lindex $ans 0]
+} {0}
+
+# Get the list of defines using the pragma,
+# then try querying each one with the functions.
+set ans [ catchsql {
+ PRAGMA compile_options;
+} ]
+set opts [ lindex $ans 1 ]
+set tc 1
+foreach opt $opts {
+ do_test ctime-2.5.$tc {
+ set N [ expr {$tc-1} ]
+ set ans1 [ catchsql {
+ SELECT sqlite_compileoption_get($N);
+ } ]
+ set ans2 [ catchsql {
+ SELECT sqlite_compileoption_used($opt);
+ } ]
+ list [ lindex $ans1 0 ] [ expr { [lindex $ans1 1]==$opt } ] \
+ [ expr { $ans2 } ]
+ } {0 1 {0 1}}
+ incr tc 1
+}
+# test 1 past array bounds
+do_test ctime-2.5.$tc {
+ set N [ expr {$tc-1} ]
+ set ans [ catchsql {
+ SELECT sqlite_compileoption_get($N);
+ } ]
+} {0 {{}}}
+incr tc 1
+# test 1 before array bounds (N=-1)
+do_test ctime-2.5.$tc {
+ set N -1
+ set ans [ catchsql {
+ SELECT sqlite_compileoption_get($N);
+ } ]
+} {0 {{}}}
+
+
+finish_test
diff --git a/test/date.test b/test/date.test
new file mode 100644
index 0000000..9bfec12
--- /dev/null
+++ b/test/date.test
@@ -0,0 +1,531 @@
+# 2003 October 31
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing date and time functions.
+#
+# $Id: date.test,v 1.34 2009/04/16 12:58:03 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Skip this whole file if date and time functions are omitted
+# at compile-time
+#
+ifcapable {!datetime} {
+ finish_test
+ return
+}
+
+proc datetest {tnum expr result} {
+ do_test date-$tnum [subst {
+ execsql "SELECT coalesce($expr,'NULL')"
+ }] [list $result]
+}
+set tcl_precision 15
+datetest 1.1 julianday('2000-01-01') 2451544.5
+datetest 1.2 julianday('1970-01-01') 2440587.5
+datetest 1.3 julianday('1910-04-20') 2418781.5
+datetest 1.4 julianday('1986-02-09') 2446470.5
+datetest 1.5 julianday('12:00:00') 2451545.0
+datetest 1.6 {julianday('2000-01-01 12:00:00')} 2451545.0
+datetest 1.7 {julianday('2000-01-01 12:00')} 2451545.0
+datetest 1.8 julianday('bogus') NULL
+datetest 1.9 julianday('1999-12-31') 2451543.5
+datetest 1.10 julianday('1999-12-32') NULL
+datetest 1.11 julianday('1999-13-01') NULL
+datetest 1.12 julianday('2003-02-31') 2452701.5
+datetest 1.13 julianday('2003-03-03') 2452701.5
+datetest 1.14 julianday('+2000-01-01') NULL
+datetest 1.15 julianday('200-01-01') NULL
+datetest 1.16 julianday('2000-1-01') NULL
+datetest 1.17 julianday('2000-01-1') NULL
+datetest 1.18.1 {julianday('2000-01-01 12:00:00')} 2451545.0
+datetest 1.18.2 {julianday('2000-01-01T12:00:00')} 2451545.0
+datetest 1.18.3 {julianday('2000-01-01 T12:00:00')} 2451545.0
+datetest 1.18.4 {julianday('2000-01-01T 12:00:00')} 2451545.0
+datetest 1.18.4 {julianday('2000-01-01 T 12:00:00')} 2451545.0
+datetest 1.19 {julianday('2000-01-01 12:00:00.1')} 2451545.00000116
+datetest 1.20 {julianday('2000-01-01 12:00:00.01')} 2451545.00000012
+datetest 1.21 {julianday('2000-01-01 12:00:00.001')} 2451545.00000001
+datetest 1.22 {julianday('2000-01-01 12:00:00.')} NULL
+datetest 1.23 julianday(12345.6) 12345.6
+datetest 1.23b julianday('12345.6') 12345.6
+datetest 1.24 {julianday('2001-01-01 12:00:00 bogus')} NULL
+datetest 1.25 {julianday('2001-01-01 bogus')} NULL
+datetest 1.26 {julianday('2001-01-01 12:60:00')} NULL
+datetest 1.27 {julianday('2001-01-01 12:59:60')} NULL
+datetest 1.28 {julianday('2001-00-01')} NULL
+datetest 1.29 {julianday('2001-01-00')} NULL
+
+datetest 2.1 datetime(0,'unixepoch') {1970-01-01 00:00:00}
+datetest 2.1b datetime(0,'unixepoc') NULL
+datetest 2.1c datetime(0,'unixepochx') NULL
+datetest 2.1d datetime('2003-10-22','unixepoch') NULL
+datetest 2.2 datetime(946684800,'unixepoch') {2000-01-01 00:00:00}
+datetest 2.2b datetime('946684800','unixepoch') {2000-01-01 00:00:00}
+for {set i 0} {$i<1000} {incr i} {
+ set sql [format {strftime('%%H:%%M:%%f',1237962480.%03d,'unixepoch')} $i]
+ set res [format {06:28:00.%03d} $i]
+ datetest 2.2c-$i $sql $res
+}
+datetest 2.3 {date('2003-10-22','weekday 0')} 2003-10-26
+datetest 2.4 {date('2003-10-22','weekday 1')} 2003-10-27
+datetest 2.4a {date('2003-10-22','weekday 1')} 2003-10-27
+datetest 2.4b {date('2003-10-22','weekday 1x')} NULL
+datetest 2.4c {date('2003-10-22','weekday -1')} NULL
+datetest 2.4d {date('2003-10-22','weakday 1x')} NULL
+datetest 2.4e {date('2003-10-22','weekday ')} NULL
+datetest 2.5 {date('2003-10-22','weekday 2')} 2003-10-28
+datetest 2.6 {date('2003-10-22','weekday 3')} 2003-10-22
+datetest 2.7 {date('2003-10-22','weekday 4')} 2003-10-23
+datetest 2.8 {date('2003-10-22','weekday 5')} 2003-10-24
+datetest 2.9 {date('2003-10-22','weekday 6')} 2003-10-25
+datetest 2.10 {date('2003-10-22','weekday 7')} NULL
+datetest 2.11 {date('2003-10-22','weekday 5.5')} NULL
+datetest 2.12 {datetime('2003-10-22 12:34','weekday 0')} {2003-10-26 12:34:00}
+datetest 2.13 {datetime('2003-10-22 12:34','start of month')} \
+ {2003-10-01 00:00:00}
+datetest 2.14 {datetime('2003-10-22 12:34','start of year')} \
+ {2003-01-01 00:00:00}
+datetest 2.15 {datetime('2003-10-22 12:34','start of day')} \
+ {2003-10-22 00:00:00}
+datetest 2.15a {datetime('2003-10-22 12:34','start of')} NULL
+datetest 2.15b {datetime('2003-10-22 12:34','start of bogus')} NULL
+datetest 2.16 time('12:34:56.43') 12:34:56
+datetest 2.17 {datetime('2003-10-22 12:34','1 day')} {2003-10-23 12:34:00}
+datetest 2.18 {datetime('2003-10-22 12:34','+1 day')} {2003-10-23 12:34:00}
+datetest 2.19 {datetime('2003-10-22 12:34','+1.25 day')} {2003-10-23 18:34:00}
+datetest 2.20 {datetime('2003-10-22 12:34','-1.0 day')} {2003-10-21 12:34:00}
+datetest 2.21 {datetime('2003-10-22 12:34','1 month')} {2003-11-22 12:34:00}
+datetest 2.22 {datetime('2003-10-22 12:34','11 month')} {2004-09-22 12:34:00}
+datetest 2.23 {datetime('2003-10-22 12:34','-13 month')} {2002-09-22 12:34:00}
+datetest 2.24 {datetime('2003-10-22 12:34','1.5 months')} {2003-12-07 12:34:00}
+datetest 2.25 {datetime('2003-10-22 12:34','-5 years')} {1998-10-22 12:34:00}
+datetest 2.26 {datetime('2003-10-22 12:34','+10.5 minutes')} \
+ {2003-10-22 12:44:30}
+datetest 2.27 {datetime('2003-10-22 12:34','-1.25 hours')} \
+ {2003-10-22 11:19:00}
+datetest 2.28 {datetime('2003-10-22 12:34','11.25 seconds')} \
+ {2003-10-22 12:34:11}
+datetest 2.29 {datetime('2003-10-22 12:24','+5 bogus')} NULL
+datetest 2.30 {datetime('2003-10-22 12:24','+++')} NULL
+datetest 2.31 {datetime('2003-10-22 12:24','+12.3e4 femtoseconds')} NULL
+datetest 2.32 {datetime('2003-10-22 12:24','+12.3e4 uS')} NULL
+datetest 2.33 {datetime('2003-10-22 12:24','+1 abc')} NULL
+datetest 2.34 {datetime('2003-10-22 12:24','+1 abcd')} NULL
+datetest 2.35 {datetime('2003-10-22 12:24','+1 abcde')} NULL
+datetest 2.36 {datetime('2003-10-22 12:24','+1 abcdef')} NULL
+datetest 2.37 {datetime('2003-10-22 12:24','+1 abcdefg')} NULL
+datetest 2.38 {datetime('2003-10-22 12:24','+1 abcdefgh')} NULL
+datetest 2.39 {datetime('2003-10-22 12:24','+1 abcdefghi')} NULL
+set sqlite_current_time 1199243045
+datetest 2.40 {datetime()} {2008-01-02 03:04:05}
+set sqlite_current_time 0
+datetest 2.41 {datetime('2003-10-22 12:24','23 seconds')} {2003-10-22 12:24:23}
+datetest 2.42 {datetime('2003-10-22 12:24','345 second')} {2003-10-22 12:29:45}
+datetest 2.43 {datetime('2003-10-22 12:24','4 second')} {2003-10-22 12:24:04}
+datetest 2.44 {datetime('2003-10-22 12:24','56 second')} {2003-10-22 12:24:56}
+datetest 2.45 {datetime('2003-10-22 12:24','60 second')} {2003-10-22 12:25:00}
+datetest 2.46 {datetime('2003-10-22 12:24','70 second')} {2003-10-22 12:25:10}
+datetest 2.47 {datetime('2003-10-22 12:24','8.6 seconds')} {2003-10-22 12:24:08}
+datetest 2.48 {datetime('2003-10-22 12:24','9.4 second')} {2003-10-22 12:24:09}
+datetest 2.49 {datetime('2003-10-22 12:24','0000 second')} {2003-10-22 12:24:00}
+datetest 2.50 {datetime('2003-10-22 12:24','0001 second')} {2003-10-22 12:24:01}
+datetest 2.51 {datetime('2003-10-22 12:24','nonsense')} NULL
+
+datetest 3.1 {strftime('%d','2003-10-31 12:34:56.432')} 31
+datetest 3.2.1 {strftime('pre%fpost','2003-10-31 12:34:56.432')} pre56.432post
+datetest 3.2.2 {strftime('%f','2003-10-31 12:34:59.9999999')} 59.999
+datetest 3.3 {strftime('%H','2003-10-31 12:34:56.432')} 12
+datetest 3.4 {strftime('%j','2003-10-31 12:34:56.432')} 304
+datetest 3.5 {strftime('%J','2003-10-31 12:34:56.432')} 2452944.02426426
+datetest 3.6 {strftime('%m','2003-10-31 12:34:56.432')} 10
+datetest 3.7 {strftime('%M','2003-10-31 12:34:56.432')} 34
+datetest 3.8.1 {strftime('%s','2003-10-31 12:34:56.432')} 1067603696
+datetest 3.8.2 {strftime('%s','2038-01-19 03:14:07')} 2147483647
+datetest 3.8.3 {strftime('%s','2038-01-19 03:14:08')} 2147483648
+datetest 3.8.4 {strftime('%s','2201-04-09 12:00:00')} 7298164800
+datetest 3.8.5 {strftime('%s','9999-12-31 23:59:59')} 253402300799
+datetest 3.8.6 {strftime('%s','1969-12-31 23:59:59')} -1
+datetest 3.8.7 {strftime('%s','1901-12-13 20:45:52')} -2147483648
+datetest 3.8.8 {strftime('%s','1901-12-13 20:45:51')} -2147483649
+datetest 3.8.9 {strftime('%s','1776-07-04 00:00:00')} -6106060800
+datetest 3.9 {strftime('%S','2003-10-31 12:34:56.432')} 56
+datetest 3.10 {strftime('%w','2003-10-31 12:34:56.432')} 5
+datetest 3.11.1 {strftime('%W','2003-10-31 12:34:56.432')} 43
+datetest 3.11.2 {strftime('%W','2004-01-01')} 00
+datetest 3.11.3 {strftime('%W','2004-01-02')} 00
+datetest 3.11.4 {strftime('%W','2004-01-03')} 00
+datetest 3.11.5 {strftime('abc%Wxyz','2004-01-04')} abc00xyz
+datetest 3.11.6 {strftime('%W','2004-01-05')} 01
+datetest 3.11.7 {strftime('%W','2004-01-06')} 01
+datetest 3.11.8 {strftime('%W','2004-01-07')} 01
+datetest 3.11.9 {strftime('%W','2004-01-08')} 01
+datetest 3.11.10 {strftime('%W','2004-01-09')} 01
+datetest 3.11.11 {strftime('%W','2004-07-18')} 28
+datetest 3.11.12 {strftime('%W','2004-12-31')} 52
+datetest 3.11.13 {strftime('%W','2007-12-31')} 53
+datetest 3.11.14 {strftime('%W','2007-01-01')} 01
+datetest 3.11.15 {strftime('%W %j',2454109.04140970)} {02 008}
+datetest 3.11.16 {strftime('%W %j',2454109.04140971)} {02 008}
+datetest 3.11.17 {strftime('%W %j',2454109.04140972)} {02 008}
+datetest 3.11.18 {strftime('%W %j',2454109.04140973)} {02 008}
+datetest 3.11.19 {strftime('%W %j',2454109.04140974)} {02 008}
+datetest 3.11.20 {strftime('%W %j',2454109.04140975)} {02 008}
+datetest 3.11.21 {strftime('%W %j',2454109.04140976)} {02 008}
+datetest 3.11.22 {strftime('%W %j',2454109.04140977)} {02 008}
+datetest 3.11.23 {strftime('%W %j',2454109.04140978)} {02 008}
+datetest 3.11.24 {strftime('%W %j',2454109.04140979)} {02 008}
+datetest 3.11.25 {strftime('%W %j',2454109.04140980)} {02 008}
+datetest 3.11.99 {strftime('%W %j','2454109.04140970')} {02 008}
+datetest 3.12 {strftime('%Y','2003-10-31 12:34:56.432')} 2003
+datetest 3.13 {strftime('%%','2003-10-31 12:34:56.432')} %
+datetest 3.14 {strftime('%_','2003-10-31 12:34:56.432')} NULL
+datetest 3.15 {strftime('%Y-%m-%d','2003-10-31')} 2003-10-31
+proc repeat {n txt} {
+ set x {}
+ while {$n>0} {
+ append x $txt
+ incr n -1
+ }
+ return $x
+}
+datetest 3.16 "strftime('[repeat 200 %Y]','2003-10-31')" [repeat 200 2003]
+datetest 3.17 "strftime('[repeat 200 abc%m123]','2003-10-31')" \
+ [repeat 200 abc10123]
+
+foreach c {a b c e g h i k l n o p q r t v x y z
+ A B C D E F G I K L N O P Q R T U V Z
+ 0 1 2 3 4 5 6 6 7 9 _} {
+ datetest 3.18.$c "strftime('%$c','2003-10-31')" NULL
+}
+
+# Ticket #2276. Make sure leading zeros are inserted where appropriate.
+#
+datetest 3.20 \
+ {strftime('%d/%f/%H/%W/%j/%m/%M/%S/%Y','0421-01-02 03:04:05.006')} \
+ 02/05.006/03/00/002/01/04/05/0421
+
+set sqlite_current_time 1157124367
+datetest 4.1 {date('now')} {2006-09-01}
+set sqlite_current_time 0
+
+datetest 5.1 {datetime('1994-04-16 14:00:00 +05:00')} {1994-04-16 09:00:00}
+datetest 5.2 {datetime('1994-04-16 14:00:00 -05:15')} {1994-04-16 19:15:00}
+datetest 5.3 {datetime('1994-04-16 05:00:00 +08:30')} {1994-04-15 20:30:00}
+datetest 5.4 {datetime('1994-04-16 14:00:00 -11:55')} {1994-04-17 01:55:00}
+datetest 5.5 {datetime('1994-04-16 14:00:00 -11:60')} NULL
+datetest 5.6 {datetime('1994-04-16 14:00:00 -11:55 ')} {1994-04-17 01:55:00}
+datetest 5.7 {datetime('1994-04-16 14:00:00 -11:55 x')} NULL
+datetest 5.8 {datetime('1994-04-16T14:00:00Z')} {1994-04-16 14:00:00}
+datetest 5.9 {datetime('1994-04-16 14:00:00z')} {1994-04-16 14:00:00}
+datetest 5.10 {datetime('1994-04-16 14:00:00 Z')} {1994-04-16 14:00:00}
+datetest 5.11 {datetime('1994-04-16 14:00:00z ')} {1994-04-16 14:00:00}
+datetest 5.12 {datetime('1994-04-16 14:00:00 z ')} {1994-04-16 14:00:00}
+datetest 5.13 {datetime('1994-04-16 14:00:00Zulu')} NULL
+datetest 5.14 {datetime('1994-04-16 14:00:00Z +05:00')} NULL
+datetest 5.15 {datetime('1994-04-16 14:00:00 +05:00 Z')} NULL
+
+# localtime->utc and utc->localtime conversions. These tests only work
+# if the localtime is in the US Eastern Time (the time in Charlotte, NC
+# and in New York.)
+#
+# On non-Vista Windows platform, '2006-03-31' is treated incorrectly as being
+# in DST giving a 4 hour offset instead of 5. In 2007, DST was extended to
+# start three weeks earlier (second Sunday in March) and end one week
+# later (first Sunday in November). Older Windows systems apply this
+# new rule incorrectly to dates prior to 2007.
+#
+# It might be argued that this is masking a problem on non-Vista Windows
+# platform. A ticket has already been opened for this issue
+# (http://www.sqlite.org/cvstrac/tktview?tn=2322). This is just to prevent
+# more confusion/reports of the issue.
+#
+
+# $tzoffset_old should be 5 if DST is working correctly.
+set tzoffset_old [db one {
+ SELECT CAST(24*(julianday('2006-03-31') -
+ julianday('2006-03-31','localtime'))+0.5
+ AS INT)
+}]
+
+# $tzoffset_new should be 4 if DST is working correctly.
+set tzoffset_new [db one {
+ SELECT CAST(24*(julianday('2007-03-31') -
+ julianday('2007-03-31','localtime'))+0.5
+ AS INT)
+}]
+
+# Warn about possibly broken Windows DST implementations.
+if {$::tcl_platform(platform)=="windows" && $tzoffset_new==4 && $tzoffset_old==4} {
+ puts "******************************************************************"
+ puts "N.B.: The DST support provided by your current O/S seems to be"
+ puts "suspect in that it is reporting incorrect DST values for dates"
+ puts "prior to 2007. This is the known case for most (all?) non-Vista"
+ puts "Windows versions. Please see ticket #2322 for more information."
+ puts "******************************************************************"
+}
+
+if {$tzoffset_new==4} {
+ datetest 6.1 {datetime('2000-10-29 05:59:00','localtime')}\
+ {2000-10-29 01:59:00}
+ datetest 6.1.1 {datetime('2006-10-29 05:59:00','localtime')}\
+ {2006-10-29 01:59:00}
+ datetest 6.1.2 {datetime('2007-11-04 05:59:00','localtime')}\
+ {2007-11-04 01:59:00}
+
+ # If the new and old DST rules seem to be working correctly...
+ if {$tzoffset_new==4 && $tzoffset_old==5} {
+ datetest 6.2 {datetime('2000-10-29 06:00:00','localtime')}\
+ {2000-10-29 01:00:00}
+ datetest 6.2.1 {datetime('2006-10-29 06:00:00','localtime')}\
+ {2006-10-29 01:00:00}
+ }
+ datetest 6.2.2 {datetime('2007-11-04 06:00:00','localtime')}\
+ {2007-11-04 01:00:00}
+
+ # If the new and old DST rules seem to be working correctly...
+ if {$tzoffset_new==4 && $tzoffset_old==5} {
+ datetest 6.3 {datetime('2000-04-02 06:59:00','localtime')}\
+ {2000-04-02 01:59:00}
+ datetest 6.3.1 {datetime('2006-04-02 06:59:00','localtime')}\
+ {2006-04-02 01:59:00}
+ }
+ datetest 6.3.2 {datetime('2007-03-11 07:00:00','localtime')}\
+ {2007-03-11 03:00:00}
+
+ datetest 6.4 {datetime('2000-04-02 07:00:00','localtime')}\
+ {2000-04-02 03:00:00}
+ datetest 6.4.1 {datetime('2006-04-02 07:00:00','localtime')}\
+ {2006-04-02 03:00:00}
+ datetest 6.4.2 {datetime('2007-03-11 07:00:00','localtime')}\
+ {2007-03-11 03:00:00}
+
+ datetest 6.5 {datetime('2000-10-29 01:59:00','utc')} {2000-10-29 05:59:00}
+ datetest 6.5.1 {datetime('2006-10-29 01:59:00','utc')} {2006-10-29 05:59:00}
+ datetest 6.5.2 {datetime('2007-11-04 01:59:00','utc')} {2007-11-04 05:59:00}
+
+ # If the new and old DST rules seem to be working correctly...
+ if {$tzoffset_new==4 && $tzoffset_old==5} {
+ datetest 6.6 {datetime('2000-10-29 02:00:00','utc')} {2000-10-29 07:00:00}
+ datetest 6.6.1 {datetime('2006-10-29 02:00:00','utc')} {2006-10-29 07:00:00}
+ }
+ datetest 6.6.2 {datetime('2007-11-04 02:00:00','utc')} {2007-11-04 07:00:00}
+
+ # If the new and old DST rules seem to be working correctly...
+ if {$tzoffset_new==4 && $tzoffset_old==5} {
+ datetest 6.7 {datetime('2000-04-02 01:59:00','utc')} {2000-04-02 06:59:00}
+ datetest 6.7.1 {datetime('2006-04-02 01:59:00','utc')} {2006-04-02 06:59:00}
+ }
+ datetest 6.7.2 {datetime('2007-03-11 01:59:00','utc')} {2007-03-11 06:59:00}
+
+ datetest 6.8 {datetime('2000-04-02 02:00:00','utc')} {2000-04-02 06:00:00}
+ datetest 6.8.1 {datetime('2006-04-02 02:00:00','utc')} {2006-04-02 06:00:00}
+ datetest 6.8.2 {datetime('2007-03-11 02:00:00','utc')} {2007-03-11 06:00:00}
+
+ datetest 6.10 {datetime('2000-01-01 12:00:00','localtime')} \
+ {2000-01-01 07:00:00}
+ datetest 6.11 {datetime('1969-01-01 12:00:00','localtime')} \
+ {1969-01-01 07:00:00}
+ datetest 6.12 {datetime('2039-01-01 12:00:00','localtime')} \
+ {2039-01-01 07:00:00}
+ datetest 6.13 {datetime('2000-07-01 12:00:00','localtime')} \
+ {2000-07-01 08:00:00}
+ datetest 6.14 {datetime('1969-07-01 12:00:00','localtime')} \
+ {1969-07-01 07:00:00}
+ datetest 6.15 {datetime('2039-07-01 12:00:00','localtime')} \
+ {2039-07-01 07:00:00}
+ set sqlite_current_time \
+ [db eval {SELECT strftime('%s','2000-07-01 12:34:56')}]
+ datetest 6.16 {datetime('now','localtime')} {2000-07-01 08:34:56}
+ datetest 6.17 {datetime('now','localtimex')} NULL
+ datetest 6.18 {datetime('now','localtim')} NULL
+ set sqlite_current_time 0
+}
+
+# These two are a bit of a scam. They are added to ensure that 100% of
+# the date.c file is covered by testing, even when the time-zone
+# is not -0400 (the condition for running of the block of tests above).
+#
+datetest 6.19 {datetime('2039-07-01 12:00:00','localtime',null)} NULL
+datetest 6.20 {datetime('2039-07-01 12:00:00','utc',null)} NULL
+
+# Date-time functions that contain NULL arguments return a NULL
+# result.
+#
+datetest 7.1 {datetime(null)} NULL
+datetest 7.2 {datetime('now',null)} NULL
+datetest 7.3 {datetime('now','localtime',null)} NULL
+datetest 7.4 {time(null)} NULL
+datetest 7.5 {time('now',null)} NULL
+datetest 7.6 {time('now','localtime',null)} NULL
+datetest 7.7 {date(null)} NULL
+datetest 7.8 {date('now',null)} NULL
+datetest 7.9 {date('now','localtime',null)} NULL
+datetest 7.10 {julianday(null)} NULL
+datetest 7.11 {julianday('now',null)} NULL
+datetest 7.12 {julianday('now','localtime',null)} NULL
+datetest 7.13 {strftime(null,'now')} NULL
+datetest 7.14 {strftime('%s',null)} NULL
+datetest 7.15 {strftime('%s','now',null)} NULL
+datetest 7.16 {strftime('%s','now','localtime',null)} NULL
+
+# Test modifiers when the date begins as a julian day number - to
+# make sure the HH:MM:SS is preserved. Ticket #551.
+#
+set sqlite_current_time [db eval {SELECT strftime('%s','2003-10-22 12:34:00')}]
+datetest 8.1 {datetime('now','weekday 0')} {2003-10-26 12:34:00}
+datetest 8.2 {datetime('now','weekday 1')} {2003-10-27 12:34:00}
+datetest 8.3 {datetime('now','weekday 2')} {2003-10-28 12:34:00}
+datetest 8.4 {datetime('now','weekday 3')} {2003-10-22 12:34:00}
+datetest 8.5 {datetime('now','start of month')} {2003-10-01 00:00:00}
+datetest 8.6 {datetime('now','start of year')} {2003-01-01 00:00:00}
+datetest 8.7 {datetime('now','start of day')} {2003-10-22 00:00:00}
+datetest 8.8 {datetime('now','1 day')} {2003-10-23 12:34:00}
+datetest 8.9 {datetime('now','+1 day')} {2003-10-23 12:34:00}
+datetest 8.10 {datetime('now','+1.25 day')} {2003-10-23 18:34:00}
+datetest 8.11 {datetime('now','-1.0 day')} {2003-10-21 12:34:00}
+datetest 8.12 {datetime('now','1 month')} {2003-11-22 12:34:00}
+datetest 8.13 {datetime('now','11 month')} {2004-09-22 12:34:00}
+datetest 8.14 {datetime('now','-13 month')} {2002-09-22 12:34:00}
+datetest 8.15 {datetime('now','1.5 months')} {2003-12-07 12:34:00}
+datetest 8.16 {datetime('now','-5 years')} {1998-10-22 12:34:00}
+datetest 8.17 {datetime('now','+10.5 minutes')} {2003-10-22 12:44:30}
+datetest 8.18 {datetime('now','-1.25 hours')} {2003-10-22 11:19:00}
+datetest 8.19 {datetime('now','11.25 seconds')} {2003-10-22 12:34:11}
+datetest 8.90 {datetime('now','abcdefghijklmnopqrstuvwyxzABCDEFGHIJLMNOP')} NULL
+set sqlite_current_time 0
+
+# Negative years work. Example: '-4713-11-26' is JD 1.5.
+#
+datetest 9.1 {julianday('-4713-11-24 12:00:00')} {0.0}
+datetest 9.2 {julianday(datetime(5))} {5.0}
+datetest 9.3 {julianday(datetime(10))} {10.0}
+datetest 9.4 {julianday(datetime(100))} {100.0}
+datetest 9.5 {julianday(datetime(1000))} {1000.0}
+datetest 9.6 {julianday(datetime(10000))} {10000.0}
+datetest 9.7 {julianday(datetime(100000))} {100000.0}
+
+# datetime() with just an HH:MM:SS correctly inserts the date 2000-01-01.
+#
+datetest 10.1 {datetime('01:02:03')} {2000-01-01 01:02:03}
+datetest 10.2 {date('01:02:03')} {2000-01-01}
+datetest 10.3 {strftime('%Y-%m-%d %H:%M','01:02:03')} {2000-01-01 01:02}
+
+# Test the new HH:MM:SS modifier
+#
+datetest 11.1 {datetime('2004-02-28 20:00:00', '-01:20:30')} \
+ {2004-02-28 18:39:30}
+datetest 11.2 {datetime('2004-02-28 20:00:00', '+12:30:00')} \
+ {2004-02-29 08:30:00}
+datetest 11.3 {datetime('2004-02-28 20:00:00', '+12:30')} \
+ {2004-02-29 08:30:00}
+datetest 11.4 {datetime('2004-02-28 20:00:00', '12:30')} \
+ {2004-02-29 08:30:00}
+datetest 11.5 {datetime('2004-02-28 20:00:00', '-12:00')} \
+ {2004-02-28 08:00:00}
+datetest 11.6 {datetime('2004-02-28 20:00:00', '-12:01')} \
+ {2004-02-28 07:59:00}
+datetest 11.7 {datetime('2004-02-28 20:00:00', '-11:59')} \
+ {2004-02-28 08:01:00}
+datetest 11.8 {datetime('2004-02-28 20:00:00', '11:59')} \
+ {2004-02-29 07:59:00}
+datetest 11.9 {datetime('2004-02-28 20:00:00', '12:01')} \
+ {2004-02-29 08:01:00}
+datetest 11.10 {datetime('2004-02-28 20:00:00', '12:60')} NULL
+
+# Ticket #1964
+datetest 12.1 {datetime('2005-09-01')} {2005-09-01 00:00:00}
+datetest 12.2 {datetime('2005-09-01','+0 hours')} {2005-09-01 00:00:00}
+
+# Ticket #1991
+do_test date-13.1 {
+ execsql {
+ SELECT strftime('%Y-%m-%d %H:%M:%f', julianday('2006-09-24T10:50:26.047'))
+ }
+} {{2006-09-24 10:50:26.047}}
+
+# Ticket #2153
+datetest 13.2 {strftime('%Y-%m-%d %H:%M:%S', '2007-01-01 12:34:59.6')} \
+ {2007-01-01 12:34:59}
+datetest 13.3 {strftime('%Y-%m-%d %H:%M:%f', '2007-01-01 12:34:59.6')} \
+ {2007-01-01 12:34:59.600}
+datetest 13.4 {strftime('%Y-%m-%d %H:%M:%S', '2007-01-01 12:59:59.6')} \
+ {2007-01-01 12:59:59}
+datetest 13.5 {strftime('%Y-%m-%d %H:%M:%f', '2007-01-01 12:59:59.6')} \
+ {2007-01-01 12:59:59.600}
+datetest 13.6 {strftime('%Y-%m-%d %H:%M:%S', '2007-01-01 23:59:59.6')} \
+ {2007-01-01 23:59:59}
+datetest 13.7 {strftime('%Y-%m-%d %H:%M:%f', '2007-01-01 23:59:59.6')} \
+ {2007-01-01 23:59:59.600}
+
+# Ticket #3618
+datetest 13.11 {julianday(2454832.5,'-1 day')} {2454831.5}
+datetest 13.12 {julianday(2454832.5,'+1 day')} {2454833.5}
+datetest 13.13 {julianday(2454832.5,'-1.5 day')} {2454831.0}
+datetest 13.14 {julianday(2454832.5,'+1.5 day')} {2454834.0}
+datetest 13.15 {julianday(2454832.5,'-3 hours')} {2454832.375}
+datetest 13.16 {julianday(2454832.5,'+3 hours')} {2454832.625}
+datetest 13.17 {julianday(2454832.5,'-45 minutes')} {2454832.46875}
+datetest 13.18 {julianday(2454832.5,'+45 minutes')} {2454832.53125}
+datetest 13.19 {julianday(2454832.5,'-675 seconds')} {2454832.4921875}
+datetest 13.20 {julianday(2454832.5,'+675 seconds')} {2454832.5078125}
+datetest 13.21 {julianday(2454832.5,'-1.5 months')} {2454786.5}
+datetest 13.22 {julianday(2454832.5,'+1.5 months')} {2454878.5}
+datetest 13.23 {julianday(2454832.5,'-1.5 years')} {2454284.0}
+datetest 13.24 {julianday(2454832.5,'+1.5 years')} {2455380.0}
+
+datetest 13.30 {date('2000-01-01','+1.5 years')} {2001-07-02}
+datetest 13.31 {date('2001-01-01','+1.5 years')} {2002-07-02}
+datetest 13.32 {date('2002-01-01','+1.5 years')} {2003-07-02}
+datetest 13.33 {date('2002-01-01','-1.5 years')} {2000-07-02}
+datetest 13.34 {date('2001-01-01','-1.5 years')} {1999-07-02}
+
+# Test for issues reported by BareFeet (list.sql at tandb.com.au)
+# on mailing list on 2008-06-12.
+#
+# Put a floating point number in the database so that we can manipulate
+# raw bits using the hexio interface.
+#
+if {0==[sqlite3 -has-codec]} {
+ do_test date-14.1 {
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1.1);
+ }
+ db close
+ hexio_write test.db 2040 4142ba32bffffff9
+ sqlite3 db test.db
+ db eval {SELECT * FROM t1}
+ } {2454629.5}
+
+ # Changing the least significant byte of the floating point value between
+ # 00 and FF should always generate a time of either 23:59:59 or 00:00:00,
+ # never 24:00:00
+ #
+ for {set i 0} {$i<=255} {incr i} {
+ db close
+ hexio_write test.db 2047 [format %02x $i]
+ sqlite3 db test.db
+ do_test date-14.2.$i {
+ set date [db one {SELECT datetime(x) FROM t1}]
+ expr {$date eq "2008-06-12 00:00:00" || $date eq "2008-06-11 23:59:59"}
+ } {1}
+ }
+}
+finish_test
diff --git a/test/dbstatus.test b/test/dbstatus.test
new file mode 100644
index 0000000..e1c8f3e
--- /dev/null
+++ b/test/dbstatus.test
@@ -0,0 +1,359 @@
+# 2010 March 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests for the sqlite3_db_status() function
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Memory statistics must be enabled for this test.
+db close
+sqlite3_shutdown
+sqlite3_config_memstatus 1
+sqlite3_initialize
+sqlite3 db test.db
+
+
+# Make sure sqlite3_db_config() and sqlite3_db_status are working.
+#
+unset -nocomplain PAGESZ
+unset -nocomplain BASESZ
+do_test dbstatus-1.1 {
+ db close
+ sqlite3 db :memory:
+ db eval {
+ CREATE TABLE t1(x);
+ }
+ set sz1 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_CACHE_USED 0] 1]
+ db eval {
+ CREATE TABLE t2(y);
+ }
+ set sz2 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_CACHE_USED 0] 1]
+ set ::PAGESZ [expr {$sz2-$sz1}]
+ set ::BASESZ [expr {$sz1-$::PAGESZ}]
+ expr {$::PAGESZ>1024 && $::PAGESZ<1300}
+} {1}
+do_test dbstatus-1.2 {
+ db eval {
+ INSERT INTO t1 VALUES(zeroblob(9000));
+ }
+ lindex [sqlite3_db_status db SQLITE_DBSTATUS_CACHE_USED 0] 1
+} [expr {$BASESZ + 10*$PAGESZ}]
+
+
+proc lookaside {db} {
+ expr { $::lookaside_buffer_size *
+ [lindex [sqlite3_db_status $db SQLITE_DBSTATUS_LOOKASIDE_USED 0] 1]
+ }
+}
+
+ifcapable stat3 {
+ set STAT3 1
+} else {
+ set STAT3 0
+}
+
+#---------------------------------------------------------------------------
+# Run the dbstatus-2 and dbstatus-3 tests with several of different
+# lookaside buffer sizes.
+#
+foreach ::lookaside_buffer_size {0 64 120} {
+
+ # Do not run any of these tests if there is SQL configured to run
+ # as part of the [sqlite3] command. This prevents the script from
+ # configuring the size of the lookaside buffer after [sqlite3] has
+ # returned.
+ if {[presql] != ""} break
+
+ #-------------------------------------------------------------------------
+ # Tests for SQLITE_DBSTATUS_SCHEMA_USED.
+ #
+ # Each test in the following block works as follows. Each test uses a
+ # different database schema.
+ #
+ # 1. Open a connection to an empty database. Disable statement caching.
+ #
+ # 2. Execute the SQL to create the database schema. Measure the total
+ # heap and lookaside memory allocated by SQLite, and the memory
+ # allocated for the database schema according to sqlite3_db_status().
+ #
+ # 3. Drop all tables in the database schema. Measure the total memory
+ # and the schema memory again.
+ #
+ # 4. Repeat step 2.
+ #
+ # 5. Repeat step 3.
+ #
+ # Then test that:
+ #
+ # a) The difference in schema memory quantities in steps 2 and 3 is the
+ # same as the difference in total memory in steps 2 and 3.
+ #
+ # b) Step 4 reports the same amount of schema and total memory used as
+ # in step 2.
+ #
+ # c) Step 5 reports the same amount of schema and total memory used as
+ # in step 3.
+ #
+ foreach {tn schema} {
+ 1 { CREATE TABLE t1(a, b) }
+ 2 { CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1, c UNIQUE) }
+ 3 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ }
+ 4 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ CREATE TRIGGER AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(new.a, new.b);
+ SELECT * FROM t1, t2 WHERE a=c AND b=d GROUP BY b HAVING a>5 ORDER BY a;
+ END;
+ }
+ 5 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ CREATE VIEW v1 AS SELECT * FROM t1 UNION SELECT * FROM t2;
+ }
+ 6y {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(a,b);
+ CREATE INDEX i3 ON t1(b,b);
+ INSERT INTO t1 VALUES(randomblob(20), randomblob(25));
+ INSERT INTO t1 SELECT randomblob(20), randomblob(25) FROM t1;
+ INSERT INTO t1 SELECT randomblob(20), randomblob(25) FROM t1;
+ INSERT INTO t1 SELECT randomblob(20), randomblob(25) FROM t1;
+ ANALYZE;
+ }
+ 7 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ CREATE VIEW v1 AS
+ SELECT * FROM t1
+ UNION
+ SELECT * FROM t2
+ UNION ALL
+ SELECT c||b, d||a FROM t2 LEFT OUTER JOIN t1 GROUP BY c, d
+ ORDER BY 1, 2
+ ;
+ CREATE TRIGGER tr1 INSTEAD OF INSERT ON v1 BEGIN
+ SELECT * FROM v1;
+ UPDATE t1 SET a=5, b=(SELECT c FROM t2);
+ END;
+ SELECT * FROM v1;
+ }
+ 8x {
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ CREATE VIRTUAL TABLE t2 USING echo(t1);
+ }
+ } {
+ set tn "$::lookaside_buffer_size-$tn"
+
+ # Step 1.
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3_db_config_lookaside db 0 $::lookaside_buffer_size 500
+ db cache size 0
+
+ catch { register_echo_module db }
+ ifcapable !vtab { if {[string match *x $tn]} continue }
+
+ # Step 2.
+ execsql $schema
+ set nAlloc1 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
+ incr nAlloc1 [lookaside db]
+ set nSchema1 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_SCHEMA_USED 0] 1]
+
+ # Step 3.
+ drop_all_tables
+ set nAlloc2 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
+ incr nAlloc2 [lookaside db]
+ set nSchema2 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_SCHEMA_USED 0] 1]
+
+ # Step 4.
+ execsql $schema
+ set nAlloc3 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
+ incr nAlloc3 [lookaside db]
+ set nSchema3 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_SCHEMA_USED 0] 1]
+
+ # Step 5.
+ drop_all_tables
+ set nAlloc4 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
+ incr nAlloc4 [lookaside db]
+ set nSchema4 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_SCHEMA_USED 0] 1]
+ set nFree [expr {$nAlloc1-$nAlloc2}]
+
+ # Tests for which the test name ends in an "x" report slightly less
+ # memory than is actually freed when all schema items are finalized.
+ # This is because memory allocated by virtual table implementations
+ # for any reason is not counted as "schema memory".
+ #
+ # Additionally, in auto-vacuum mode, dropping tables and indexes causes
+ # the page-cache to shrink. So the amount of memory freed is always
+ # much greater than just that reported by DBSTATUS_SCHEMA_USED in this
+ # case.
+ #
+ # Some of the memory used for sqlite_stat3 is unaccounted for by
+ # dbstatus.
+ #
+ if {[string match *x $tn] || $AUTOVACUUM
+ || ([string match *y $tn] && $STAT3)} {
+ do_test dbstatus-2.$tn.ax { expr {($nSchema1-$nSchema2)<=$nFree} } 1
+ } else {
+ do_test dbstatus-2.$tn.a { expr {$nSchema1-$nSchema2} } $nFree
+ }
+
+ do_test dbstatus-2.$tn.b { list $nAlloc1 $nSchema1 } "$nAlloc3 $nSchema3"
+ do_test dbstatus-2.$tn.c { list $nAlloc2 $nSchema2 } "$nAlloc4 $nSchema4"
+ }
+
+ #-------------------------------------------------------------------------
+ # Tests for SQLITE_DBSTATUS_STMT_USED.
+ #
+ # Each test in the following block works as follows. Each test uses a
+ # different database schema.
+ #
+ # 1. Open a connection to an empty database. Initialized the database
+ # schema.
+ #
+ # 2. Prepare a bunch of SQL statements. Measure the total heap and
+ # lookaside memory allocated by SQLite, and the memory allocated
+ # for the prepared statements according to sqlite3_db_status().
+ #
+ # 3. Finalize all prepared statements Measure the total memory
+ # and the prepared statement memory again.
+ #
+ # 4. Repeat step 2.
+ #
+ # 5. Repeat step 3.
+ #
+ # Then test that:
+ #
+ # a) The difference in schema memory quantities in steps 2 and 3 is the
+ # same as the difference in total memory in steps 2 and 3.
+ #
+ # b) Step 4 reports the same amount of schema and total memory used as
+ # in step 2.
+ #
+ # c) Step 5 reports the same amount of schema and total memory used as
+ # in step 3.
+ #
+ foreach {tn schema statements} {
+ 1 { CREATE TABLE t1(a, b) } {
+ SELECT * FROM t1;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 SELECT * FROM t1;
+ UPDATE t1 SET a=5;
+ DELETE FROM t1;
+ }
+ 2 {
+ PRAGMA recursive_triggers = 1;
+ CREATE TABLE t1(a, b);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN (new.a>0) BEGIN
+ INSERT INTO t1 VALUES(new.a-1, new.b);
+ END;
+ } {
+ INSERT INTO t1 VALUES(5, 'x');
+ }
+ 3 {
+ PRAGMA recursive_triggers = 1;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN (new.a>0) BEGIN
+ INSERT INTO t2 VALUES(new.a-1, new.b);
+ END;
+ CREATE TRIGGER tr2 AFTER INSERT ON t1 WHEN (new.a>0) BEGIN
+ INSERT INTO t1 VALUES(new.a-1, new.b);
+ END;
+ } {
+ INSERT INTO t1 VALUES(10, 'x');
+ }
+ 4 {
+ CREATE TABLE t1(a, b);
+ } {
+ SELECT count(*) FROM t1 WHERE upper(a)='ABC';
+ }
+ 5x {
+ CREATE TABLE t1(a, b UNIQUE);
+ CREATE VIRTUAL TABLE t2 USING echo(t1);
+ } {
+ SELECT count(*) FROM t2;
+ SELECT * FROM t2 WHERE b>5;
+ SELECT * FROM t2 WHERE b='abcdefg';
+ }
+ } {
+ set tn "$::lookaside_buffer_size-$tn"
+
+ # Step 1.
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3_db_config_lookaside db 0 $::lookaside_buffer_size 500
+ db cache size 1000
+
+ catch { register_echo_module db }
+ ifcapable !vtab { if {[string match *x $tn]} continue }
+
+ execsql $schema
+ db cache flush
+
+ # Step 2.
+ execsql $statements
+ set nAlloc1 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
+ incr nAlloc1 [lookaside db]
+ set nStmt1 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_STMT_USED 0] 1]
+ execsql $statements
+
+ # Step 3.
+ db cache flush
+ set nAlloc2 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
+ incr nAlloc2 [lookaside db]
+ set nStmt2 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_STMT_USED 0] 1]
+
+ # Step 3.
+ execsql $statements
+ set nAlloc3 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
+ incr nAlloc3 [lookaside db]
+ set nStmt3 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_STMT_USED 0] 1]
+ execsql $statements
+
+ # Step 4.
+ db cache flush
+ set nAlloc4 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
+ incr nAlloc4 [lookaside db]
+ set nStmt4 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_STMT_USED 0] 1]
+
+ set nFree [expr {$nAlloc1-$nAlloc2}]
+
+ do_test dbstatus-3.$tn.a { expr $nStmt2 } {0}
+
+ # Tests for which the test name ends in an "x" report slightly less
+ # memory than is actually freed when all statements are finalized.
+ # This is because a small amount of memory allocated by a virtual table
+ # implementation using sqlite3_mprintf() is technically considered
+ # external and so is not counted as "statement memory".
+ #
+#puts "$nStmt1 $nFree"
+ if {[string match *x $tn]} {
+ do_test dbstatus-3.$tn.bx { expr $nStmt1<=$nFree } {1}
+ } else {
+ do_test dbstatus-3.$tn.b { expr $nStmt1==$nFree } {1}
+ }
+
+ do_test dbstatus-3.$tn.c { list $nAlloc1 $nStmt1 } [list $nAlloc3 $nStmt3]
+ do_test dbstatus-3.$tn.d { list $nAlloc2 $nStmt2 } [list $nAlloc4 $nStmt4]
+ }
+}
+
+finish_test
diff --git a/test/dbstatus2.test b/test/dbstatus2.test
new file mode 100644
index 0000000..4dfa9b8
--- /dev/null
+++ b/test/dbstatus2.test
@@ -0,0 +1,76 @@
+# 2011 September 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests for the sqlite3_stmt_status() function
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set ::testprefix dbstatus2
+
+do_execsql_test 1.0 {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, randomblob(600));
+ INSERT INTO t1 VALUES(2, randomblob(600));
+ INSERT INTO t1 VALUES(3, randomblob(600));
+}
+
+proc db_hit_miss {db {reset 0}} {
+ set nHit [sqlite3_db_status $db CACHE_HIT $reset]
+ set nMiss [sqlite3_db_status $db CACHE_MISS $reset]
+ list $nHit $nMiss
+}
+
+do_test 1.1 {
+ db close
+ sqlite3 db test.db
+ expr {[file size test.db] / 1024}
+} 6
+
+do_test 1.2 {
+ execsql { SELECT b FROM t1 WHERE a=2 }
+ db_hit_miss db
+} {{0 2 0} {0 4 0}}
+
+do_test 1.3 {
+ execsql { SELECT b FROM t1 WHERE a=2 }
+ db_hit_miss db
+} {{0 6 0} {0 4 0}}
+
+do_test 1.4 {
+ execsql { SELECT b FROM t1 WHERE a=2 }
+ db_hit_miss db
+} {{0 10 0} {0 4 0}}
+
+do_test 1.5 {
+ db_hit_miss db 1
+} {{0 10 0} {0 4 0}}
+
+do_test 1.6 {
+ db_hit_miss db 0
+} {{0 0 0} {0 0 0}}
+
+do_test 1.7 {
+ set fd [db incrblob main t1 b 1]
+ fconfigure $fd -translation binary
+ set len [string length [read $fd]]
+ close $fd
+ set len
+} 600
+do_test 1.8 { sqlite3_db_status db CACHE_HIT 0 } {0 2 0}
+do_test 1.9 { sqlite3_db_status db CACHE_MISS 0 } {0 1 0}
+
+
+finish_test
diff --git a/test/default.test b/test/default.test
new file mode 100644
index 0000000..95a4ee0
--- /dev/null
+++ b/test/default.test
@@ -0,0 +1,67 @@
+# 2005 August 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing corner cases of the DEFAULT syntax
+# on table definitions.
+#
+# $Id: default.test,v 1.3 2009/02/19 14:39:25 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable bloblit {
+ do_test default-1.1 {
+ execsql {
+ CREATE TABLE t1(
+ a INTEGER,
+ b BLOB DEFAULT x'6869'
+ );
+ INSERT INTO t1(a) VALUES(1);
+ SELECT * from t1;
+ }
+ } {1 hi}
+}
+do_test default-1.2 {
+ execsql {
+ CREATE TABLE t2(
+ x INTEGER,
+ y INTEGER DEFAULT NULL
+ );
+ INSERT INTO t2(x) VALUES(1);
+ SELECT * FROM t2;
+ }
+} {1 {}}
+do_test default-1.3 {
+ catchsql {
+ CREATE TABLE t3(
+ x INTEGER,
+ y INTEGER DEFAULT (max(x,5))
+ )
+ }
+} {1 {default value of column [y] is not constant}}
+
+ifcapable pragma {
+ do_test default-2.1 {
+ execsql {
+ CREATE TABLE t4(c DEFAULT 'abc');
+ PRAGMA table_info(t4);
+ }
+ } {0 c {} 0 'abc' 0}
+ do_test default-2.2 {
+ execsql {
+ INSERT INTO t4 DEFAULT VALUES;
+ PRAGMA table_info(t4);
+ }
+ } {0 c {} 0 'abc' 0}
+}
+
+finish_test
diff --git a/test/delete.test b/test/delete.test
new file mode 100644
index 0000000..47d3578
--- /dev/null
+++ b/test/delete.test
@@ -0,0 +1,394 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the DELETE FROM statement.
+#
+# $Id: delete.test,v 1.26 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Try to delete from a non-existant table.
+#
+do_test delete-1.1 {
+ set v [catch {execsql {DELETE FROM test1}} msg]
+ lappend v $msg
+} {1 {no such table: test1}}
+
+# Try to delete from sqlite_master
+#
+do_test delete-2.1 {
+ set v [catch {execsql {DELETE FROM sqlite_master}} msg]
+ lappend v $msg
+} {1 {table sqlite_master may not be modified}}
+
+# Delete selected entries from a table with and without an index.
+#
+do_test delete-3.1.1 {
+ execsql {CREATE TABLE table1(f1 int, f2 int)}
+ execsql {INSERT INTO table1 VALUES(1,2)}
+ execsql {INSERT INTO table1 VALUES(2,4)}
+ execsql {INSERT INTO table1 VALUES(3,8)}
+ execsql {INSERT INTO table1 VALUES(4,16)}
+ execsql {SELECT * FROM table1 ORDER BY f1}
+} {1 2 2 4 3 8 4 16}
+do_test delete-3.1.2 {
+ execsql {DELETE FROM table1 WHERE f1=3}
+} {}
+do_test delete-3.1.3 {
+ execsql {SELECT * FROM table1 ORDER BY f1}
+} {1 2 2 4 4 16}
+do_test delete-3.1.4 {
+ execsql {CREATE INDEX index1 ON table1(f1)}
+ execsql {PRAGMA count_changes=on}
+ ifcapable explain {
+ execsql {EXPLAIN DELETE FROM table1 WHERE f1=3}
+ }
+ execsql {DELETE FROM 'table1' WHERE f1=3}
+} {0}
+do_test delete-3.1.5 {
+ execsql {SELECT * FROM table1 ORDER BY f1}
+} {1 2 2 4 4 16}
+do_test delete-3.1.6.1 {
+ execsql {DELETE FROM table1 WHERE f1=2}
+} {1}
+do_test delete-3.1.6.2 {
+ db changes
+} 1
+do_test delete-3.1.7 {
+ execsql {SELECT * FROM table1 ORDER BY f1}
+} {1 2 4 16}
+integrity_check delete-3.2
+
+
+# Semantic errors in the WHERE clause
+#
+do_test delete-4.1 {
+ execsql {CREATE TABLE table2(f1 int, f2 int)}
+ set v [catch {execsql {DELETE FROM table2 WHERE f3=5}} msg]
+ lappend v $msg
+} {1 {no such column: f3}}
+
+do_test delete-4.2 {
+ set v [catch {execsql {DELETE FROM table2 WHERE xyzzy(f1+4)}} msg]
+ lappend v $msg
+} {1 {no such function: xyzzy}}
+integrity_check delete-4.3
+
+# Lots of deletes
+#
+do_test delete-5.1.1 {
+ execsql {DELETE FROM table1}
+} {2}
+do_test delete-5.1.2 {
+ execsql {SELECT count(*) FROM table1}
+} {0}
+do_test delete-5.2.1 {
+ execsql {BEGIN TRANSACTION}
+ for {set i 1} {$i<=200} {incr i} {
+ execsql "INSERT INTO table1 VALUES($i,[expr {$i*$i}])"
+ }
+ execsql {COMMIT}
+ execsql {SELECT count(*) FROM table1}
+} {200}
+do_test delete-5.2.2 {
+ execsql {DELETE FROM table1}
+} {200}
+do_test delete-5.2.3 {
+ execsql {BEGIN TRANSACTION}
+ for {set i 1} {$i<=200} {incr i} {
+ execsql "INSERT INTO table1 VALUES($i,[expr {$i*$i}])"
+ }
+ execsql {COMMIT}
+ execsql {SELECT count(*) FROM table1}
+} {200}
+do_test delete-5.2.4 {
+ execsql {PRAGMA count_changes=off}
+ execsql {DELETE FROM table1}
+} {}
+do_test delete-5.2.5 {
+ execsql {SELECT count(*) FROM table1}
+} {0}
+do_test delete-5.2.6 {
+ execsql {BEGIN TRANSACTION}
+ for {set i 1} {$i<=200} {incr i} {
+ execsql "INSERT INTO table1 VALUES($i,[expr {$i*$i}])"
+ }
+ execsql {COMMIT}
+ execsql {SELECT count(*) FROM table1}
+} {200}
+do_test delete-5.3 {
+ for {set i 1} {$i<=200} {incr i 4} {
+ execsql "DELETE FROM table1 WHERE f1==$i"
+ }
+ execsql {SELECT count(*) FROM table1}
+} {150}
+do_test delete-5.4.1 {
+ execsql "DELETE FROM table1 WHERE f1>50"
+ db changes
+} [db one {SELECT count(*) FROM table1 WHERE f1>50}]
+do_test delete-5.4.2 {
+ execsql {SELECT count(*) FROM table1}
+} {37}
+do_test delete-5.5 {
+ for {set i 1} {$i<=70} {incr i 3} {
+ execsql "DELETE FROM table1 WHERE f1==$i"
+ }
+ execsql {SELECT f1 FROM table1 ORDER BY f1}
+} {2 3 6 8 11 12 14 15 18 20 23 24 26 27 30 32 35 36 38 39 42 44 47 48 50}
+do_test delete-5.6 {
+ for {set i 1} {$i<40} {incr i} {
+ execsql "DELETE FROM table1 WHERE f1==$i"
+ }
+ execsql {SELECT f1 FROM table1 ORDER BY f1}
+} {42 44 47 48 50}
+do_test delete-5.7 {
+ execsql "DELETE FROM table1 WHERE f1!=48"
+ execsql {SELECT f1 FROM table1 ORDER BY f1}
+} {48}
+integrity_check delete-5.8
+
+
+# Delete large quantities of data. We want to test the List overflow
+# mechanism in the vdbe.
+#
+do_test delete-6.1 {
+ execsql {BEGIN; DELETE FROM table1}
+ for {set i 1} {$i<=3000} {incr i} {
+ execsql "INSERT INTO table1 VALUES($i,[expr {$i*$i}])"
+ }
+ execsql {DELETE FROM table2}
+ for {set i 1} {$i<=3000} {incr i} {
+ execsql "INSERT INTO table2 VALUES($i,[expr {$i*$i}])"
+ }
+ execsql {COMMIT}
+ execsql {SELECT count(*) FROM table1}
+} {3000}
+do_test delete-6.2 {
+ execsql {SELECT count(*) FROM table2}
+} {3000}
+do_test delete-6.3 {
+ execsql {SELECT f1 FROM table1 WHERE f1<10 ORDER BY f1}
+} {1 2 3 4 5 6 7 8 9}
+do_test delete-6.4 {
+ execsql {SELECT f1 FROM table2 WHERE f1<10 ORDER BY f1}
+} {1 2 3 4 5 6 7 8 9}
+do_test delete-6.5.1 {
+ execsql {DELETE FROM table1 WHERE f1>7}
+ db changes
+} {2993}
+do_test delete-6.5.2 {
+ execsql {SELECT f1 FROM table1 ORDER BY f1}
+} {1 2 3 4 5 6 7}
+do_test delete-6.6 {
+ execsql {DELETE FROM table2 WHERE f1>7}
+ execsql {SELECT f1 FROM table2 ORDER BY f1}
+} {1 2 3 4 5 6 7}
+do_test delete-6.7 {
+ execsql {DELETE FROM table1}
+ execsql {SELECT f1 FROM table1}
+} {}
+do_test delete-6.8 {
+ execsql {INSERT INTO table1 VALUES(2,3)}
+ execsql {SELECT f1 FROM table1}
+} {2}
+do_test delete-6.9 {
+ execsql {DELETE FROM table2}
+ execsql {SELECT f1 FROM table2}
+} {}
+do_test delete-6.10 {
+ execsql {INSERT INTO table2 VALUES(2,3)}
+ execsql {SELECT f1 FROM table2}
+} {2}
+integrity_check delete-6.11
+
+do_test delete-7.1 {
+ execsql {
+ CREATE TABLE t3(a);
+ INSERT INTO t3 VALUES(1);
+ INSERT INTO t3 SELECT a+1 FROM t3;
+ INSERT INTO t3 SELECT a+2 FROM t3;
+ SELECT * FROM t3;
+ }
+} {1 2 3 4}
+ifcapable {trigger} {
+ do_test delete-7.2 {
+ execsql {
+ CREATE TABLE cnt(del);
+ INSERT INTO cnt VALUES(0);
+ CREATE TRIGGER r1 AFTER DELETE ON t3 FOR EACH ROW BEGIN
+ UPDATE cnt SET del=del+1;
+ END;
+ DELETE FROM t3 WHERE a<2;
+ SELECT * FROM t3;
+ }
+ } {2 3 4}
+ do_test delete-7.3 {
+ execsql {
+ SELECT * FROM cnt;
+ }
+ } {1}
+ do_test delete-7.4 {
+ execsql {
+ DELETE FROM t3;
+ SELECT * FROM t3;
+ }
+ } {}
+ do_test delete-7.5 {
+ execsql {
+ SELECT * FROM cnt;
+ }
+ } {4}
+ do_test delete-7.6 {
+ execsql {
+ INSERT INTO t3 VALUES(1);
+ INSERT INTO t3 SELECT a+1 FROM t3;
+ INSERT INTO t3 SELECT a+2 FROM t3;
+ CREATE TABLE t4 AS SELECT * FROM t3;
+ PRAGMA count_changes=ON;
+ DELETE FROM t3;
+ DELETE FROM t4;
+ }
+ } {4 4}
+} ;# endif trigger
+ifcapable {!trigger} {
+ execsql {DELETE FROM t3}
+}
+integrity_check delete-7.7
+
+# Make sure error messages are consistent when attempting to delete
+# from a read-only database. Ticket #304.
+#
+do_test delete-8.0 {
+ execsql {
+ PRAGMA count_changes=OFF;
+ INSERT INTO t3 VALUES(123);
+ SELECT * FROM t3;
+ }
+} {123}
+db close
+catch {forcedelete test.db-journal}
+catch {file attributes test.db -permissions 0444}
+catch {file attributes test.db -readonly 1}
+sqlite3 db test.db
+set ::DB [sqlite3_connection_pointer db]
+do_test delete-8.1 {
+ catchsql {
+ DELETE FROM t3;
+ }
+} {1 {attempt to write a readonly database}}
+do_test delete-8.2 {
+ execsql {SELECT * FROM t3}
+} {123}
+do_test delete-8.3 {
+ catchsql {
+ DELETE FROM t3 WHERE 1;
+ }
+} {1 {attempt to write a readonly database}}
+do_test delete-8.4 {
+ execsql {SELECT * FROM t3}
+} {123}
+
+# Update for v3: In v2 the DELETE statement would succeed because no
+# database writes actually occur. Version 3 refuses to open a transaction
+# on a read-only file, so the statement fails.
+do_test delete-8.5 {
+ catchsql {
+ DELETE FROM t3 WHERE a<100;
+ }
+# v2 result: {0 {}}
+} {1 {attempt to write a readonly database}}
+do_test delete-8.6 {
+ execsql {SELECT * FROM t3}
+} {123}
+integrity_check delete-8.7
+
+# Need to do the following for tcl 8.5 on mac. On that configuration, the
+# -readonly flag is taken so seriously that a subsequent [forcedelete]
+# (required before the next test file can be executed) will fail.
+#
+catch {file attributes test.db -readonly 0}
+db close
+forcedelete test.db test.db-journal
+
+# The following tests verify that SQLite correctly handles the case
+# where an index B-Tree is being scanned, the rowid column being read
+# from each index entry and another statement deletes some rows from
+# the index B-Tree. At one point this (obscure) scenario was causing
+# SQLite to return spurious SQLITE_CORRUPT errors and arguably incorrect
+# query results.
+#
+do_test delete-9.1 {
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t5(a, b);
+ CREATE TABLE t6(c, d);
+ INSERT INTO t5 VALUES(1, 2);
+ INSERT INTO t5 VALUES(3, 4);
+ INSERT INTO t5 VALUES(5, 6);
+ INSERT INTO t6 VALUES('a', 'b');
+ INSERT INTO t6 VALUES('c', 'd');
+ CREATE INDEX i5 ON t5(a);
+ CREATE INDEX i6 ON t6(c);
+ }
+} {}
+do_test delete-9.2 {
+ set res [list]
+ db eval { SELECT t5.rowid AS r, c, d FROM t5, t6 ORDER BY a } {
+ if {$r==2} { db eval { DELETE FROM t5 } }
+ lappend res $r $c $d
+ }
+ set res
+} {1 a b 1 c d 2 a b {} c d}
+do_test delete-9.3 {
+ execsql {
+ INSERT INTO t5 VALUES(1, 2);
+ INSERT INTO t5 VALUES(3, 4);
+ INSERT INTO t5 VALUES(5, 6);
+ }
+ set res [list]
+ db eval { SELECT t5.rowid AS r, c, d FROM t5, t6 ORDER BY a } {
+ if {$r==2} { db eval { DELETE FROM t5 WHERE rowid = 2 } }
+ lappend res $r $c $d
+ }
+ set res
+} {1 a b 1 c d 2 a b {} c d 3 a b 3 c d}
+do_test delete-9.4 {
+ execsql {
+ DELETE FROM t5;
+ INSERT INTO t5 VALUES(1, 2);
+ INSERT INTO t5 VALUES(3, 4);
+ INSERT INTO t5 VALUES(5, 6);
+ }
+ set res [list]
+ db eval { SELECT t5.rowid AS r, c, d FROM t5, t6 ORDER BY a } {
+ if {$r==2} { db eval { DELETE FROM t5 WHERE rowid = 1 } }
+ lappend res $r $c $d
+ }
+ set res
+} {1 a b 1 c d 2 a b 2 c d 3 a b 3 c d}
+do_test delete-9.5 {
+ execsql {
+ DELETE FROM t5;
+ INSERT INTO t5 VALUES(1, 2);
+ INSERT INTO t5 VALUES(3, 4);
+ INSERT INTO t5 VALUES(5, 6);
+ }
+ set res [list]
+ db eval { SELECT t5.rowid AS r, c, d FROM t5, t6 ORDER BY a } {
+ if {$r==2} { db eval { DELETE FROM t5 WHERE rowid = 3 } }
+ lappend res $r $c $d
+ }
+ set res
+} {1 a b 1 c d 2 a b 2 c d}
+
+
+finish_test
diff --git a/test/delete2.test b/test/delete2.test
new file mode 100644
index 0000000..1668a3a
--- /dev/null
+++ b/test/delete2.test
@@ -0,0 +1,119 @@
+# 2003 September 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is a test to replicate the bug reported by
+# ticket #842.
+#
+# Ticket #842 was a database corruption problem caused by a DELETE that
+# removed an index entry by not the main table entry. To recreate the
+# problem do this:
+#
+# (1) Create a table with an index. Insert some data into that table.
+# (2) Start a query on the table but do not complete the query.
+# (3) Try to delete a single entry from the table.
+#
+# Step 3 will fail because there is still a read cursor on the table.
+# But the database is corrupted by the DELETE. It turns out that the
+# index entry was deleted first, before the table entry. And the index
+# delete worked. Thus an entry was deleted from the index but not from
+# the table.
+#
+# The solution to the problem was to detect that the table is locked
+# before the index entry is deleted.
+#
+# $Id: delete2.test,v 1.8 2008/07/08 15:59:52 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table that has an index.
+#
+do_test delete2-1.1 {
+ set DB [sqlite3_connection_pointer db]
+ execsql {
+ CREATE TABLE q(s string, id string, constraint pk_q primary key(id));
+ BEGIN;
+ INSERT INTO q(s,id) VALUES('hello','id.1');
+ INSERT INTO q(s,id) VALUES('goodbye','id.2');
+ INSERT INTO q(s,id) VALUES('again','id.3');
+ END;
+ SELECT * FROM q;
+ }
+} {hello id.1 goodbye id.2 again id.3}
+do_test delete2-1.2 {
+ execsql {
+ SELECT * FROM q WHERE id='id.1';
+ }
+} {hello id.1}
+integrity_check delete2-1.3
+
+# Start a query on the table. The query should not use the index.
+# Do not complete the query, thus leaving the table locked.
+#
+do_test delete2-1.4 {
+ set STMT [sqlite3_prepare $DB {SELECT * FROM q} -1 TAIL]
+ sqlite3_step $STMT
+} SQLITE_ROW
+integrity_check delete2-1.5
+
+# Try to delete a row from the table while a read is in process.
+# As of 2006-08-16, this is allowed. (It used to fail with SQLITE_LOCKED.)
+#
+do_test delete2-1.6 {
+ catchsql {
+ DELETE FROM q WHERE rowid=1
+ }
+} {0 {}}
+integrity_check delete2-1.7
+do_test delete2-1.8 {
+ execsql {
+ SELECT * FROM q;
+ }
+} {goodbye id.2 again id.3}
+
+# Finalize the query, thus clearing the lock on the table. Then
+# retry the delete. The delete should work this time.
+#
+do_test delete2-1.9 {
+ sqlite3_finalize $STMT
+ catchsql {
+ DELETE FROM q WHERE rowid=1
+ }
+} {0 {}}
+integrity_check delete2-1.10
+do_test delete2-1.11 {
+ execsql {
+ SELECT * FROM q;
+ }
+} {goodbye id.2 again id.3}
+
+do_test delete2-2.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ INSERT INTO t2 VALUES(5, 6);
+ }
+} {}
+do_test delete2-2.2 {
+ set res [list]
+ db eval {
+ SELECT CASE WHEN c = 5 THEN b ELSE NULL END AS b, c, d FROM t1, t2
+ } {
+ db eval {DELETE FROM t1}
+ lappend res $b $c $d
+ }
+ set res
+} {{} 3 4 {} 5 6}
+
+finish_test
diff --git a/test/delete3.test b/test/delete3.test
new file mode 100644
index 0000000..a31f6ec
--- /dev/null
+++ b/test/delete3.test
@@ -0,0 +1,57 @@
+# 2005 August 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is a test of the DELETE command where a
+# large number of rows are deleted.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table that contains a large number of rows.
+#
+do_test delete3-1.1 {
+ execsql {
+ CREATE TABLE t1(x integer primary key);
+ BEGIN;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 SELECT x+2 FROM t1;
+ INSERT INTO t1 SELECT x+4 FROM t1;
+ INSERT INTO t1 SELECT x+8 FROM t1;
+ INSERT INTO t1 SELECT x+16 FROM t1;
+ INSERT INTO t1 SELECT x+32 FROM t1;
+ INSERT INTO t1 SELECT x+64 FROM t1;
+ INSERT INTO t1 SELECT x+128 FROM t1;
+ INSERT INTO t1 SELECT x+256 FROM t1;
+ INSERT INTO t1 SELECT x+512 FROM t1;
+ INSERT INTO t1 SELECT x+1024 FROM t1;
+ INSERT INTO t1 SELECT x+2048 FROM t1;
+ INSERT INTO t1 SELECT x+4096 FROM t1;
+ INSERT INTO t1 SELECT x+8192 FROM t1;
+ INSERT INTO t1 SELECT x+16384 FROM t1;
+ INSERT INTO t1 SELECT x+32768 FROM t1;
+ INSERT INTO t1 SELECT x+65536 FROM t1;
+ INSERT INTO t1 SELECT x+131072 FROM t1;
+ INSERT INTO t1 SELECT x+262144 FROM t1;
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+} {524288}
+do_test delete3-1.2 {
+ execsql {
+ DELETE FROM t1 WHERE x%2==0;
+ SELECT count(*) FROM t1;
+ }
+} {262144}
+integrity_check delete3-1.3
+
+finish_test
diff --git a/test/descidx1.test b/test/descidx1.test
new file mode 100644
index 0000000..c7fab34
--- /dev/null
+++ b/test/descidx1.test
@@ -0,0 +1,364 @@
+# 2005 December 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is descending indices.
+#
+# $Id: descidx1.test,v 1.10 2008/03/19 00:21:31 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+db eval {PRAGMA legacy_file_format=OFF}
+
+# This procedure sets the value of the file-format in file 'test.db'
+# to $newval. Also, the schema cookie is incremented.
+#
+proc set_file_format {newval} {
+ hexio_write test.db 44 [hexio_render_int32 $newval]
+ set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
+ incr schemacookie
+ hexio_write test.db 40 [hexio_render_int32 $schemacookie]
+ return {}
+}
+
+# This procedure returns the value of the file-format in file 'test.db'.
+#
+proc get_file_format {{fname test.db}} {
+ return [hexio_get_int [hexio_read $fname 44 4]]
+}
+
+
+# Verify that the file format starts as 4.
+#
+do_test descidx1-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ CREATE INDEX i1 ON t1(b ASC);
+ }
+ get_file_format
+} {4}
+do_test descidx1-1.2 {
+ execsql {
+ CREATE INDEX i2 ON t1(a DESC);
+ }
+ get_file_format
+} {4}
+
+# Put some information in the table and verify that the descending
+# index actually works.
+#
+do_test descidx1-2.1 {
+ execsql {
+ INSERT INTO t1 VALUES(1,1);
+ INSERT INTO t1 VALUES(2,2);
+ INSERT INTO t1 SELECT a+2, a+2 FROM t1;
+ INSERT INTO t1 SELECT a+4, a+4 FROM t1;
+ SELECT b FROM t1 WHERE a>3 AND a<7;
+ }
+} {6 5 4}
+do_test descidx1-2.2 {
+ execsql {
+ SELECT a FROM t1 WHERE b>3 AND b<7;
+ }
+} {4 5 6}
+do_test descidx1-2.3 {
+ execsql {
+ SELECT b FROM t1 WHERE a>=3 AND a<7;
+ }
+} {6 5 4 3}
+do_test descidx1-2.4 {
+ execsql {
+ SELECT b FROM t1 WHERE a>3 AND a<=7;
+ }
+} {7 6 5 4}
+do_test descidx1-2.5 {
+ execsql {
+ SELECT b FROM t1 WHERE a>=3 AND a<=7;
+ }
+} {7 6 5 4 3}
+do_test descidx1-2.6 {
+ execsql {
+ SELECT a FROM t1 WHERE b>=3 AND b<=7;
+ }
+} {3 4 5 6 7}
+
+# This procedure executes the SQL. Then it checks to see if the OP_Sort
+# opcode was executed. If an OP_Sort did occur, then "sort" is appended
+# to the result. If no OP_Sort happened, then "nosort" is appended.
+#
+# This procedure is used to check to make sure sorting is or is not
+# occurring as expected.
+#
+proc cksort {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ if {$::sqlite_sort_count} {set x sort} {set x nosort}
+ lappend data $x
+ return $data
+}
+
+# Test sorting using a descending index.
+#
+do_test descidx1-3.1 {
+ cksort {SELECT a FROM t1 ORDER BY a}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx1-3.2 {
+ cksort {SELECT a FROM t1 ORDER BY a ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx1-3.3 {
+ cksort {SELECT a FROM t1 ORDER BY a DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+do_test descidx1-3.4 {
+ cksort {SELECT b FROM t1 ORDER BY a}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx1-3.5 {
+ cksort {SELECT b FROM t1 ORDER BY a ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx1-3.6 {
+ cksort {SELECT b FROM t1 ORDER BY a DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+do_test descidx1-3.7 {
+ cksort {SELECT a FROM t1 ORDER BY b}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx1-3.8 {
+ cksort {SELECT a FROM t1 ORDER BY b ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx1-3.9 {
+ cksort {SELECT a FROM t1 ORDER BY b DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+do_test descidx1-3.10 {
+ cksort {SELECT b FROM t1 ORDER BY b}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx1-3.11 {
+ cksort {SELECT b FROM t1 ORDER BY b ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx1-3.12 {
+ cksort {SELECT b FROM t1 ORDER BY b DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+
+do_test descidx1-3.21 {
+ cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a}
+} {4 5 6 7 nosort}
+do_test descidx1-3.22 {
+ cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a ASC}
+} {4 5 6 7 nosort}
+do_test descidx1-3.23 {
+ cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}
+} {7 6 5 4 nosort}
+do_test descidx1-3.24 {
+ cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a}
+} {4 5 6 7 nosort}
+do_test descidx1-3.25 {
+ cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a ASC}
+} {4 5 6 7 nosort}
+do_test descidx1-3.26 {
+ cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}
+} {7 6 5 4 nosort}
+
+# Create a table with indices that are descending on some terms and
+# ascending on others.
+#
+ifcapable bloblit {
+ do_test descidx1-4.1 {
+ execsql {
+ CREATE TABLE t2(a INT, b TEXT, c BLOB, d REAL);
+ CREATE INDEX i3 ON t2(a ASC, b DESC, c ASC);
+ CREATE INDEX i4 ON t2(b DESC, a ASC, d DESC);
+ INSERT INTO t2 VALUES(1,'one',x'31',1.0);
+ INSERT INTO t2 VALUES(2,'two',x'3232',2.0);
+ INSERT INTO t2 VALUES(3,'three',x'333333',3.0);
+ INSERT INTO t2 VALUES(4,'four',x'34343434',4.0);
+ INSERT INTO t2 VALUES(5,'five',x'3535353535',5.0);
+ INSERT INTO t2 VALUES(6,'six',x'363636363636',6.0);
+ INSERT INTO t2 VALUES(2,'two',x'323232',2.1);
+ INSERT INTO t2 VALUES(2,'zwei',x'3232',2.2);
+ INSERT INTO t2 VALUES(2,NULL,NULL,2.3);
+ SELECT count(*) FROM t2;
+ }
+ } {9}
+ do_test descidx1-4.2 {
+ execsql {
+ SELECT d FROM t2 ORDER BY a;
+ }
+ } {1.0 2.2 2.0 2.1 2.3 3.0 4.0 5.0 6.0}
+ do_test descidx1-4.3 {
+ execsql {
+ SELECT d FROM t2 WHERE a>=2;
+ }
+ } {2.2 2.0 2.1 2.3 3.0 4.0 5.0 6.0}
+ do_test descidx1-4.4 {
+ execsql {
+ SELECT d FROM t2 WHERE a>2;
+ }
+ } {3.0 4.0 5.0 6.0}
+ do_test descidx1-4.5 {
+ execsql {
+ SELECT d FROM t2 WHERE a=2 AND b>'two';
+ }
+ } {2.2}
+ do_test descidx1-4.6 {
+ execsql {
+ SELECT d FROM t2 WHERE a=2 AND b>='two';
+ }
+ } {2.2 2.0 2.1}
+ do_test descidx1-4.7 {
+ execsql {
+ SELECT d FROM t2 WHERE a=2 AND b<'two';
+ }
+ } {}
+ do_test descidx1-4.8 {
+ execsql {
+ SELECT d FROM t2 WHERE a=2 AND b<='two';
+ }
+ } {2.0 2.1}
+}
+
+do_test descidx1-5.1 {
+ execsql {
+ CREATE TABLE t3(a,b,c,d);
+ CREATE INDEX t3i1 ON t3(a DESC, b ASC, c DESC, d ASC);
+ INSERT INTO t3 VALUES(0,0,0,0);
+ INSERT INTO t3 VALUES(0,0,0,1);
+ INSERT INTO t3 VALUES(0,0,1,0);
+ INSERT INTO t3 VALUES(0,0,1,1);
+ INSERT INTO t3 VALUES(0,1,0,0);
+ INSERT INTO t3 VALUES(0,1,0,1);
+ INSERT INTO t3 VALUES(0,1,1,0);
+ INSERT INTO t3 VALUES(0,1,1,1);
+ INSERT INTO t3 VALUES(1,0,0,0);
+ INSERT INTO t3 VALUES(1,0,0,1);
+ INSERT INTO t3 VALUES(1,0,1,0);
+ INSERT INTO t3 VALUES(1,0,1,1);
+ INSERT INTO t3 VALUES(1,1,0,0);
+ INSERT INTO t3 VALUES(1,1,0,1);
+ INSERT INTO t3 VALUES(1,1,1,0);
+ INSERT INTO t3 VALUES(1,1,1,1);
+ SELECT count(*) FROM t3;
+ }
+} {16}
+do_test descidx1-5.2 {
+ cksort {
+ SELECT a||b||c||d FROM t3 ORDER BY a,b,c,d;
+ }
+} {0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 sort}
+do_test descidx1-5.3 {
+ cksort {
+ SELECT a||b||c||d FROM t3 ORDER BY a DESC, b ASC, c DESC, d ASC;
+ }
+} {1010 1011 1000 1001 1110 1111 1100 1101 0010 0011 0000 0001 0110 0111 0100 0101 nosort}
+do_test descidx1-5.4 {
+ cksort {
+ SELECT a||b||c||d FROM t3 ORDER BY a ASC, b DESC, c ASC, d DESC;
+ }
+} {0101 0100 0111 0110 0001 0000 0011 0010 1101 1100 1111 1110 1001 1000 1011 1010 nosort}
+do_test descidx1-5.5 {
+ cksort {
+ SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a DESC, b ASC, c DESC
+ }
+} {101 100 111 110 001 000 011 010 nosort}
+do_test descidx1-5.6 {
+ cksort {
+ SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a ASC, b DESC, c ASC
+ }
+} {010 011 000 001 110 111 100 101 nosort}
+do_test descidx1-5.7 {
+ cksort {
+ SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a ASC, b DESC, c DESC
+ }
+} {011 010 001 000 111 110 101 100 sort}
+do_test descidx1-5.8 {
+ cksort {
+ SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a ASC, b ASC, c ASC
+ }
+} {000 001 010 011 100 101 110 111 sort}
+do_test descidx1-5.9 {
+ cksort {
+ SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a DESC, b DESC, c ASC
+ }
+} {110 111 100 101 010 011 000 001 sort}
+
+# Test the legacy_file_format pragma here because we have access to
+# the get_file_format command.
+#
+ifcapable legacyformat {
+ do_test descidx1-6.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {PRAGMA legacy_file_format}
+ } {1}
+} else {
+ do_test descidx1-6.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {PRAGMA legacy_file_format}
+ } {0}
+}
+do_test descidx1-6.2 {
+ execsql {PRAGMA legacy_file_format=YES}
+ execsql {PRAGMA legacy_file_format}
+} {1}
+do_test descidx1-6.3 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ }
+ get_file_format
+} {1}
+ifcapable vacuum {
+ # Verify that the file format is preserved across a vacuum.
+ do_test descidx1-6.3.1 {
+ execsql {VACUUM}
+ get_file_format
+ } {1}
+}
+do_test descidx1-6.4 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {PRAGMA legacy_file_format=NO}
+ execsql {PRAGMA legacy_file_format}
+} {0}
+do_test descidx1-6.5 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX i1 ON t1(a ASC, b DESC, c ASC);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(1,1,0);
+ INSERT INTO t1 VALUES(1,2,1);
+ INSERT INTO t1 VALUES(1,3,4);
+ }
+ get_file_format
+} {4}
+ifcapable vacuum {
+ # Verify that the file format is preserved across a vacuum.
+ do_test descidx1-6.6 {
+ execsql {VACUUM}
+ get_file_format
+ } {4}
+ do_test descidx1-6.7 {
+ execsql {
+ PRAGMA legacy_file_format=ON;
+ VACUUM;
+ }
+ get_file_format
+ } {4}
+}
+
+
+
+finish_test
diff --git a/test/descidx2.test b/test/descidx2.test
new file mode 100644
index 0000000..fdc3eb0
--- /dev/null
+++ b/test/descidx2.test
@@ -0,0 +1,185 @@
+# 2005 December 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is descending indices.
+#
+# $Id: descidx2.test,v 1.5 2008/03/19 00:21:31 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+
+db eval {PRAGMA legacy_file_format=OFF}
+
+# This procedure sets the value of the file-format in file 'test.db'
+# to $newval. Also, the schema cookie is incremented.
+#
+proc set_file_format {newval} {
+ hexio_write test.db 44 [hexio_render_int32 $newval]
+ set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
+ incr schemacookie
+ hexio_write test.db 40 [hexio_render_int32 $schemacookie]
+ return {}
+}
+
+# This procedure returns the value of the file-format in file 'test.db'.
+#
+proc get_file_format {{fname test.db}} {
+ return [hexio_get_int [hexio_read $fname 44 4]]
+}
+
+
+# Verify that the file format starts as 4
+#
+do_test descidx2-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ CREATE INDEX i1 ON t1(b ASC);
+ }
+ get_file_format
+} {4}
+do_test descidx2-1.2 {
+ execsql {
+ CREATE INDEX i2 ON t1(a DESC);
+ }
+ get_file_format
+} {4}
+
+# Before adding any information to the database, set the file format
+# back to three. Then close and reopen the database. With the file
+# format set to three, SQLite should ignore the DESC argument on the
+# index.
+#
+do_test descidx2-2.0 {
+ set_file_format 3
+ db close
+ sqlite3 db test.db
+ get_file_format
+} {3}
+
+# Put some information in the table and verify that the DESC
+# on the index is ignored.
+#
+do_test descidx2-2.1 {
+ execsql {
+ INSERT INTO t1 VALUES(1,1);
+ INSERT INTO t1 VALUES(2,2);
+ INSERT INTO t1 SELECT a+2, a+2 FROM t1;
+ INSERT INTO t1 SELECT a+4, a+4 FROM t1;
+ SELECT b FROM t1 WHERE a>3 AND a<7;
+ }
+} {4 5 6}
+do_test descidx2-2.2 {
+ execsql {
+ SELECT a FROM t1 WHERE b>3 AND b<7;
+ }
+} {4 5 6}
+do_test descidx2-2.3 {
+ execsql {
+ SELECT b FROM t1 WHERE a>=3 AND a<7;
+ }
+} {3 4 5 6}
+do_test descidx2-2.4 {
+ execsql {
+ SELECT b FROM t1 WHERE a>3 AND a<=7;
+ }
+} {4 5 6 7}
+do_test descidx2-2.5 {
+ execsql {
+ SELECT b FROM t1 WHERE a>=3 AND a<=7;
+ }
+} {3 4 5 6 7}
+do_test descidx2-2.6 {
+ execsql {
+ SELECT a FROM t1 WHERE b>=3 AND b<=7;
+ }
+} {3 4 5 6 7}
+
+# This procedure executes the SQL. Then it checks to see if the OP_Sort
+# opcode was executed. If an OP_Sort did occur, then "sort" is appended
+# to the result. If no OP_Sort happened, then "nosort" is appended.
+#
+# This procedure is used to check to make sure sorting is or is not
+# occurring as expected.
+#
+proc cksort {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ if {$::sqlite_sort_count} {set x sort} {set x nosort}
+ lappend data $x
+ return $data
+}
+
+# Test sorting using a descending index.
+#
+do_test descidx2-3.1 {
+ cksort {SELECT a FROM t1 ORDER BY a}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.2 {
+ cksort {SELECT a FROM t1 ORDER BY a ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.3 {
+ cksort {SELECT a FROM t1 ORDER BY a DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+do_test descidx2-3.4 {
+ cksort {SELECT b FROM t1 ORDER BY a}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.5 {
+ cksort {SELECT b FROM t1 ORDER BY a ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.6 {
+ cksort {SELECT b FROM t1 ORDER BY a DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+do_test descidx2-3.7 {
+ cksort {SELECT a FROM t1 ORDER BY b}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.8 {
+ cksort {SELECT a FROM t1 ORDER BY b ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.9 {
+ cksort {SELECT a FROM t1 ORDER BY b DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+do_test descidx2-3.10 {
+ cksort {SELECT b FROM t1 ORDER BY b}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.11 {
+ cksort {SELECT b FROM t1 ORDER BY b ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.12 {
+ cksort {SELECT b FROM t1 ORDER BY b DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+
+do_test descidx2-3.21 {
+ cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a}
+} {4 5 6 7 nosort}
+do_test descidx2-3.22 {
+ cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a ASC}
+} {4 5 6 7 nosort}
+do_test descidx2-3.23 {
+ cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}
+} {7 6 5 4 nosort}
+do_test descidx2-3.24 {
+ cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a}
+} {4 5 6 7 nosort}
+do_test descidx2-3.25 {
+ cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a ASC}
+} {4 5 6 7 nosort}
+do_test descidx2-3.26 {
+ cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}
+} {7 6 5 4 nosort}
+
+finish_test
diff --git a/test/descidx3.test b/test/descidx3.test
new file mode 100644
index 0000000..3cc87af
--- /dev/null
+++ b/test/descidx3.test
@@ -0,0 +1,154 @@
+# 2006 January 02
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is descending indices.
+#
+# $Id: descidx3.test,v 1.6 2008/03/19 00:21:31 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+ifcapable !bloblit {
+ finish_test
+ return
+}
+db eval {PRAGMA legacy_file_format=OFF}
+
+# This procedure sets the value of the file-format in file 'test.db'
+# to $newval. Also, the schema cookie is incremented.
+#
+proc set_file_format {newval} {
+ hexio_write test.db 44 [hexio_render_int32 $newval]
+ set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
+ incr schemacookie
+ hexio_write test.db 40 [hexio_render_int32 $schemacookie]
+ return {}
+}
+
+# This procedure returns the value of the file-format in file 'test.db'.
+#
+proc get_file_format {{fname test.db}} {
+ return [hexio_get_int [hexio_read $fname 44 4]]
+}
+
+# Verify that the file format starts as 4.
+#
+do_test descidx3-1.1 {
+ execsql {
+ CREATE TABLE t1(i INTEGER PRIMARY KEY,a,b,c,d);
+ CREATE INDEX t1i1 ON t1(a DESC, b ASC, c DESC);
+ CREATE INDEX t1i2 ON t1(b DESC, c ASC, d DESC);
+ }
+ get_file_format
+} {4}
+
+# Put some information in the table and verify that the descending
+# index actually works.
+#
+do_test descidx3-2.1 {
+ execsql {
+ INSERT INTO t1 VALUES(1, NULL, NULL, NULL, NULL);
+ INSERT INTO t1 VALUES(2, 2, 2, 2, 2);
+ INSERT INTO t1 VALUES(3, 3, 3, 3, 3);
+ INSERT INTO t1 VALUES(4, 2.5, 2.5, 2.5, 2.5);
+ INSERT INTO t1 VALUES(5, -5, -5, -5, -5);
+ INSERT INTO t1 VALUES(6, 'six', 'six', 'six', 'six');
+ INSERT INTO t1 VALUES(7, x'77', x'77', x'77', x'77');
+ INSERT INTO t1 VALUES(8, 'eight', 'eight', 'eight', 'eight');
+ INSERT INTO t1 VALUES(9, x'7979', x'7979', x'7979', x'7979');
+ SELECT count(*) FROM t1;
+ }
+} 9
+do_test descidx3-2.2 {
+ execsql {
+ SELECT i FROM t1 ORDER BY a;
+ }
+} {1 5 2 4 3 8 6 7 9}
+do_test descidx3-2.3 {
+ execsql {
+ SELECT i FROM t1 ORDER BY a DESC;
+ }
+} {9 7 6 8 3 4 2 5 1}
+
+# The "natural" order for the index is decreasing
+do_test descidx3-2.4 {
+ execsql {
+ SELECT i FROM t1 WHERE a<=x'7979';
+ }
+} {9 7 6 8 3 4 2 5}
+do_test descidx3-2.5 {
+ execsql {
+ SELECT i FROM t1 WHERE a>-99;
+ }
+} {9 7 6 8 3 4 2 5}
+
+# Even when all values of t1.a are the same, sorting by A returns
+# the rows in reverse order because this the natural order of the
+# index.
+#
+do_test descidx3-3.1 {
+ execsql {
+ UPDATE t1 SET a=1;
+ SELECT i FROM t1 ORDER BY a;
+ }
+} {9 7 6 8 3 4 2 5 1}
+do_test descidx3-3.2 {
+ execsql {
+ SELECT i FROM t1 WHERE a=1 AND b>0 AND b<'zzz'
+ }
+} {2 4 3 8 6}
+do_test descidx3-3.3 {
+ execsql {
+ SELECT i FROM t1 WHERE b>0 AND b<'zzz'
+ }
+} {6 8 3 4 2}
+do_test descidx3-3.4 {
+ execsql {
+ SELECT i FROM t1 WHERE a=1 AND b>-9999 AND b<x'ffffffff'
+ }
+} {5 2 4 3 8 6 7 9}
+do_test descidx3-3.5 {
+ execsql {
+ SELECT i FROM t1 WHERE b>-9999 AND b<x'ffffffff'
+ }
+} {9 7 6 8 3 4 2 5}
+
+ifcapable subquery {
+ # If the subquery capability is not compiled in to the binary, then
+ # the IN(...) operator is not available. Hence these tests cannot be
+ # run.
+ do_test descidx3-4.1 {
+ execsql {
+ UPDATE t1 SET a=2 WHERE i<6;
+ SELECT i FROM t1 WHERE a IN (1,2) AND b>0 AND b<'zzz';
+ }
+ } {8 6 2 4 3}
+ do_test descidx3-4.2 {
+ execsql {
+ UPDATE t1 SET a=1;
+ SELECT i FROM t1 WHERE a IN (1,2) AND b>0 AND b<'zzz';
+ }
+ } {2 4 3 8 6}
+ do_test descidx3-4.3 {
+ execsql {
+ UPDATE t1 SET b=2;
+ SELECT i FROM t1 WHERE a IN (1,2) AND b>0 AND b<'zzz';
+ }
+ } {9 7 6 8 3 4 2 5 1}
+}
+
+finish_test
diff --git a/test/diskfull.test b/test/diskfull.test
new file mode 100644
index 0000000..391dfb4
--- /dev/null
+++ b/test/diskfull.test
@@ -0,0 +1,115 @@
+# 2001 October 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing for correct handling of disk full
+# errors.
+#
+# $Id: diskfull.test,v 1.8 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set sqlite_io_error_persist 0
+set sqlite_io_error_hit 0
+set sqlite_io_error_pending 0
+do_test diskfull-1.1 {
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randstr(1000,1000));
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ CREATE INDEX t1i1 ON t1(x);
+ CREATE TABLE t2 AS SELECT x AS a, x AS b FROM t1;
+ CREATE INDEX t2i1 ON t2(b);
+ }
+} {}
+set sqlite_diskfull_pending 0
+integrity_check diskfull-1.2
+do_test diskfull-1.3 {
+ set sqlite_diskfull_pending 1
+ catchsql {
+ INSERT INTO t1 SELECT * FROM t1;
+ }
+} {1 {database or disk is full}}
+set sqlite_diskfull_pending 0
+integrity_check diskfull-1.4
+do_test diskfull-1.5 {
+ set sqlite_diskfull_pending 1
+ catchsql {
+ DELETE FROM t1;
+ }
+} {1 {database or disk is full}}
+set sqlite_diskfull_pending 0
+set sqlite_io_error_hit 0
+integrity_check diskfull-1.6
+
+proc do_diskfull_test {prefix sql} {
+ set ::go 1
+ set ::sql $sql
+ set ::i 1
+ while {$::go} {
+ incr ::i
+ do_test ${prefix}.$::i.1 {
+ set ::sqlite_diskfull_pending $::i
+ set ::sqlite_diskfull 0
+ set r [catchsql $::sql]
+ if {!$::sqlite_diskfull} {
+ set r {1 {database or disk is full}}
+ set ::go 0
+ }
+ if {$r=="1 {disk I/O error}"} {
+ set r {1 {database or disk is full}}
+ }
+ set r
+ } {1 {database or disk is full}}
+ set ::sqlite_diskfull_pending 0
+ db close
+ sqlite3 db test.db
+ integrity_check ${prefix}.$::i.2
+ }
+}
+
+do_diskfull_test diskfull-2 VACUUM
+
+# db close
+# forcedelete test.db
+# forcedelete test.db-journal
+# sqlite3 db test.db
+#
+# do_test diskfull-3.1 {
+# execsql {
+# PRAGMA default_cache_size = 10;
+# CREATE TABLE t3(a, b, UNIQUE(a, b));
+# INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
+# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+# UPDATE t3
+# SET b = (SELECT a FROM t3 WHERE rowid = (SELECT max(rowid)-1 FROM t3))
+# WHERE rowid = (SELECT max(rowid) FROM t3);
+# PRAGMA cache_size;
+# }
+# } {10}
+#
+# do_diskfull_test diskfull-3.2 {
+# BEGIN;
+# INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
+# UPDATE t3 SET a = b;
+# COMMIT;
+# }
+
+finish_test
diff --git a/test/distinct.test b/test/distinct.test
new file mode 100644
index 0000000..e0a9136
--- /dev/null
+++ b/test/distinct.test
@@ -0,0 +1,166 @@
+# 2011 July 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is the DISTINCT modifier.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix distinct
+
+
+proc is_distinct_noop {sql} {
+ set sql1 $sql
+ set sql2 [string map {DISTINCT ""} $sql]
+
+ set program1 [list]
+ set program2 [list]
+ db eval "EXPLAIN $sql1" {
+ if {$opcode != "Noop"} { lappend program1 $opcode }
+ }
+ db eval "EXPLAIN $sql2" {
+ if {$opcode != "Noop"} { lappend program2 $opcode }
+ }
+
+ return [expr {$program1==$program2}]
+}
+
+proc do_distinct_noop_test {tn sql} {
+ uplevel [list do_test $tn [list is_distinct_noop $sql] 1]
+}
+proc do_distinct_not_noop_test {tn sql} {
+ uplevel [list do_test $tn [list is_distinct_noop $sql] 0]
+}
+
+proc do_temptables_test {tn sql temptables} {
+ uplevel [list do_test $tn [subst -novar {
+ set ret ""
+ db eval "EXPLAIN [set sql]" {
+ if {$opcode == "OpenEphemeral" || $opcode == "SorterOpen"} {
+ if {$p5 != "10" && $p5!="00"} { error "p5 = $p5" }
+ if {$p5 == "10"} {
+ lappend ret hash
+ } else {
+ lappend ret btree
+ }
+ }
+ }
+ set ret
+ }] $temptables]
+}
+
+
+#-------------------------------------------------------------------------
+# The following tests - distinct-1.* - check that the planner correctly
+# detects cases where a UNIQUE index means that a DISTINCT clause is
+# redundant. Currently the planner only detects such cases when there
+# is a single table in the FROM clause.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c, d);
+ CREATE UNIQUE INDEX i1 ON t1(b, c);
+ CREATE UNIQUE INDEX i2 ON t1(d COLLATE nocase);
+
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y);
+
+ CREATE TABLE t3(c1 PRIMARY KEY, c2);
+ CREATE INDEX i3 ON t3(c2);
+}
+foreach {tn noop sql} {
+
+ 1 1 "SELECT DISTINCT b, c FROM t1"
+ 2 1 "SELECT DISTINCT c FROM t1 WHERE b = ?"
+ 3 1 "SELECT DISTINCT rowid FROM t1"
+ 4 1 "SELECT DISTINCT rowid, a FROM t1"
+ 5 1 "SELECT DISTINCT x FROM t2"
+ 6 1 "SELECT DISTINCT * FROM t2"
+ 7 1 "SELECT DISTINCT * FROM (SELECT * FROM t2)"
+
+ 8 1 "SELECT DISTINCT * FROM t1"
+
+ 8 0 "SELECT DISTINCT a, b FROM t1"
+
+ 9 0 "SELECT DISTINCT c FROM t1 WHERE b IN (1,2)"
+ 10 0 "SELECT DISTINCT c FROM t1"
+ 11 0 "SELECT DISTINCT b FROM t1"
+
+ 12 0 "SELECT DISTINCT a, d FROM t1"
+ 13 0 "SELECT DISTINCT a, b, c COLLATE nocase FROM t1"
+ 14 1 "SELECT DISTINCT a, d COLLATE nocase FROM t1"
+ 15 0 "SELECT DISTINCT a, d COLLATE binary FROM t1"
+ 16 1 "SELECT DISTINCT a, b, c COLLATE binary FROM t1"
+
+ 16 0 "SELECT DISTINCT t1.rowid FROM t1, t2"
+ 17 0 { /* Technically, it would be possible to detect that DISTINCT
+ ** is a no-op in cases like the following. But SQLite does not
+ ** do so. */
+ SELECT DISTINCT t1.rowid FROM t1, t2 WHERE t1.rowid=t2.rowid }
+
+ 18 1 "SELECT DISTINCT c1, c2 FROM t3"
+ 19 1 "SELECT DISTINCT c1 FROM t3"
+ 20 1 "SELECT DISTINCT * FROM t3"
+ 21 0 "SELECT DISTINCT c2 FROM t3"
+
+ 22 0 "SELECT DISTINCT * FROM (SELECT 1, 2, 3 UNION SELECT 4, 5, 6)"
+ 23 1 "SELECT DISTINCT rowid FROM (SELECT 1, 2, 3 UNION SELECT 4, 5, 6)"
+
+ 24 0 "SELECT DISTINCT rowid/2 FROM t1"
+ 25 1 "SELECT DISTINCT rowid/2, rowid FROM t1"
+ 26 1 "SELECT DISTINCT rowid/2, b FROM t1 WHERE c = ?"
+} {
+ if {$noop} {
+ do_distinct_noop_test 1.$tn $sql
+ } else {
+ do_distinct_not_noop_test 1.$tn $sql
+ }
+}
+
+#-------------------------------------------------------------------------
+# The following tests - distinct-2.* - test cases where an index is
+# used to deliver results in order of the DISTINCT expressions.
+#
+drop_all_tables
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a, b, c);
+
+ CREATE INDEX i1 ON t1(a, b);
+ CREATE INDEX i2 ON t1(b COLLATE nocase, c COLLATE nocase);
+
+ INSERT INTO t1 VALUES('a', 'b', 'c');
+ INSERT INTO t1 VALUES('A', 'B', 'C');
+ INSERT INTO t1 VALUES('a', 'b', 'c');
+ INSERT INTO t1 VALUES('A', 'B', 'C');
+}
+
+foreach {tn sql temptables res} {
+ 1 "a, b FROM t1" {} {A B a b}
+ 2 "b, a FROM t1" {} {B A b a}
+ 3 "a, b, c FROM t1" {hash} {a b c A B C}
+ 4 "a, b, c FROM t1 ORDER BY a, b, c" {btree} {A B C a b c}
+ 5 "b FROM t1 WHERE a = 'a'" {} {b}
+ 6 "b FROM t1" {hash} {b B}
+ 7 "a FROM t1" {} {A a}
+ 8 "b COLLATE nocase FROM t1" {} {b}
+ 9 "b COLLATE nocase FROM t1 ORDER BY b COLLATE nocase" {} {B}
+} {
+ do_execsql_test 2.$tn.1 "SELECT DISTINCT $sql" $res
+ do_temptables_test 2.$tn.2 "SELECT DISTINCT $sql" $temptables
+}
+
+do_execsql_test 2.A {
+ SELECT (SELECT DISTINCT o.a FROM t1 AS i) FROM t1 AS o;
+} {a A a A}
+
+
+
+
+finish_test
diff --git a/test/distinctagg.test b/test/distinctagg.test
new file mode 100644
index 0000000..9b5dc21
--- /dev/null
+++ b/test/distinctagg.test
@@ -0,0 +1,62 @@
+# 2005 September 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is the DISTINCT modifier on aggregate functions.
+#
+# $Id: distinctagg.test,v 1.3 2009/02/09 13:19:28 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test distinctagg-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(1,3,4);
+ INSERT INTO t1 VALUES(1,3,5);
+ SELECT count(distinct a),
+ count(distinct b),
+ count(distinct c),
+ count(all a) FROM t1;
+ }
+} {1 2 3 3}
+do_test distinctagg-1.2 {
+ execsql {
+ SELECT b, count(distinct c) FROM t1 GROUP BY b ORDER BY b
+ }
+} {2 1 3 2}
+do_test distinctagg-1.3 {
+ execsql {
+ INSERT INTO t1 SELECT a+1, b+3, c+5 FROM t1;
+ INSERT INTO t1 SELECT a+2, b+6, c+10 FROM t1;
+ INSERT INTO t1 SELECT a+4, b+12, c+20 FROM t1;
+ SELECT count(*), count(distinct a), count(distinct b) FROM t1
+ }
+} {24 8 16}
+do_test distinctagg-1.4 {
+ execsql {
+ SELECT a, count(distinct c) FROM t1 GROUP BY a ORDER BY a
+ }
+} {1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3}
+
+do_test distinctagg-2.1 {
+ catchsql {
+ SELECT count(distinct) FROM t1;
+ }
+} {1 {DISTINCT aggregates must have exactly one argument}}
+do_test distinctagg-2.2 {
+ catchsql {
+ SELECT group_concat(distinct a,b) FROM t1;
+ }
+} {1 {DISTINCT aggregates must have exactly one argument}}
+
+finish_test
diff --git a/test/e_createtable.test b/test/e_createtable.test
new file mode 100644
index 0000000..f61db1c
--- /dev/null
+++ b/test/e_createtable.test
@@ -0,0 +1,1930 @@
+# 2010 September 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_createtable.html document are correct.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set ::testprefix e_createtable
+
+# Test organization:
+#
+# e_createtable-0.*: Test that the syntax diagrams are correct.
+#
+# e_createtable-1.*: Test statements related to table and database names,
+# the TEMP and TEMPORARY keywords, and the IF NOT EXISTS clause.
+#
+# e_createtable-2.*: Test "CREATE TABLE AS" statements.
+#
+
+proc do_createtable_tests {nm args} {
+ uplevel do_select_tests [list e_createtable-$nm] $args
+}
+
+
+#-------------------------------------------------------------------------
+# This command returns a serialized tcl array mapping from the name of
+# each attached database to a list of tables in that database. For example,
+# if the database schema is created with:
+#
+# CREATE TABLE t1(x);
+# CREATE TEMP TABLE t2(x);
+# CREATE TEMP TABLE t3(x);
+#
+# Then this command returns "main t1 temp {t2 t3}".
+#
+proc table_list {} {
+ set res [list]
+ db eval { pragma database_list } a {
+ set dbname $a(name)
+ set master $a(name).sqlite_master
+ if {$dbname == "temp"} { set master sqlite_temp_master }
+ lappend res $dbname [
+ db eval "SELECT DISTINCT tbl_name FROM $master ORDER BY tbl_name"
+ ]
+ }
+ set res
+}
+
+
+# EVIDENCE-OF: R-25262-01881 -- syntax diagram type-name
+#
+do_createtable_tests 0.1.1 -repair {
+ drop_all_tables
+} {
+ 1 "CREATE TABLE t1(c1 one)" {}
+ 2 "CREATE TABLE t1(c1 one two)" {}
+ 3 "CREATE TABLE t1(c1 one two three)" {}
+ 4 "CREATE TABLE t1(c1 one two three four)" {}
+ 5 "CREATE TABLE t1(c1 one two three four(14))" {}
+ 6 "CREATE TABLE t1(c1 one two three four(14, 22))" {}
+ 7 "CREATE TABLE t1(c1 var(+14, -22.3))" {}
+ 8 "CREATE TABLE t1(c1 var(1.0e10))" {}
+}
+do_createtable_tests 0.1.2 -error {
+ near "%s": syntax error
+} {
+ 1 "CREATE TABLE t1(c1 one(number))" {number}
+}
+
+
+# EVIDENCE-OF: R-18762-12428 -- syntax diagram column-constraint
+#
+# Note: Not shown in the syntax diagram is the "NULL" constraint. This
+# is the opposite of "NOT NULL" - it implies that the column may
+# take a NULL value. This is the default anyway, so this type of
+# constraint is rarely used.
+#
+do_createtable_tests 0.2.1 -repair {
+ drop_all_tables
+ execsql { CREATE TABLE t2(x PRIMARY KEY) }
+} {
+ 1.1 "CREATE TABLE t1(c1 text PRIMARY KEY)" {}
+ 1.2 "CREATE TABLE t1(c1 text PRIMARY KEY ASC)" {}
+ 1.3 "CREATE TABLE t1(c1 text PRIMARY KEY DESC)" {}
+ 1.4 "CREATE TABLE t1(c1 text CONSTRAINT cons PRIMARY KEY DESC)" {}
+
+ 2.1 "CREATE TABLE t1(c1 text NOT NULL)" {}
+ 2.2 "CREATE TABLE t1(c1 text CONSTRAINT nm NOT NULL)" {}
+ 2.3 "CREATE TABLE t1(c1 text NULL)" {}
+ 2.4 "CREATE TABLE t1(c1 text CONSTRAINT nm NULL)" {}
+
+ 3.1 "CREATE TABLE t1(c1 text UNIQUE)" {}
+ 3.2 "CREATE TABLE t1(c1 text CONSTRAINT un UNIQUE)" {}
+
+ 4.1 "CREATE TABLE t1(c1 text CHECK(c1!=0))" {}
+ 4.2 "CREATE TABLE t1(c1 text CONSTRAINT chk CHECK(c1!=0))" {}
+
+ 5.1 "CREATE TABLE t1(c1 text DEFAULT 1)" {}
+ 5.2 "CREATE TABLE t1(c1 text DEFAULT -1)" {}
+ 5.3 "CREATE TABLE t1(c1 text DEFAULT +1)" {}
+ 5.4 "CREATE TABLE t1(c1 text DEFAULT -45.8e22)" {}
+ 5.5 "CREATE TABLE t1(c1 text DEFAULT (1+1))" {}
+ 5.6 "CREATE TABLE t1(c1 text CONSTRAINT \"1 2\" DEFAULT (1+1))" {}
+
+ 6.1 "CREATE TABLE t1(c1 text COLLATE nocase)" {}
+ 6.2 "CREATE TABLE t1(c1 text CONSTRAINT 'a x' COLLATE nocase)" {}
+
+ 7.1 "CREATE TABLE t1(c1 REFERENCES t2)" {}
+ 7.2 "CREATE TABLE t1(c1 CONSTRAINT abc REFERENCES t2)" {}
+
+ 8.1 {
+ CREATE TABLE t1(c1
+ PRIMARY KEY NOT NULL UNIQUE CHECK(c1 IS 'ten') DEFAULT 123 REFERENCES t1
+ );
+ } {}
+ 8.2 {
+ CREATE TABLE t1(c1
+ REFERENCES t1 DEFAULT 123 CHECK(c1 IS 'ten') UNIQUE NOT NULL PRIMARY KEY
+ );
+ } {}
+}
+
+# EVIDENCE-OF: R-17905-31923 -- syntax diagram table-constraint
+#
+do_createtable_tests 0.3.1 -repair {
+ drop_all_tables
+ execsql { CREATE TABLE t2(x PRIMARY KEY) }
+} {
+ 1.1 "CREATE TABLE t1(c1, c2, PRIMARY KEY(c1))" {}
+ 1.2 "CREATE TABLE t1(c1, c2, PRIMARY KEY(c1, c2))" {}
+ 1.3 "CREATE TABLE t1(c1, c2, PRIMARY KEY(c1, c2) ON CONFLICT IGNORE)" {}
+
+ 2.1 "CREATE TABLE t1(c1, c2, UNIQUE(c1))" {}
+ 2.2 "CREATE TABLE t1(c1, c2, UNIQUE(c1, c2))" {}
+ 2.3 "CREATE TABLE t1(c1, c2, UNIQUE(c1, c2) ON CONFLICT IGNORE)" {}
+
+ 3.1 "CREATE TABLE t1(c1, c2, CHECK(c1 IS NOT c2))" {}
+
+ 4.1 "CREATE TABLE t1(c1, c2, FOREIGN KEY(c1) REFERENCES t2)" {}
+}
+
+# EVIDENCE-OF: R-18765-31171 -- syntax diagram column-def
+#
+do_createtable_tests 0.4.1 -repair {
+ drop_all_tables
+} {
+ 1 {CREATE TABLE t1(
+ col1,
+ col2 TEXT,
+ col3 INTEGER UNIQUE,
+ col4 VARCHAR(10, 10) PRIMARY KEY,
+ "name with spaces" REFERENCES t1
+ );
+ } {}
+}
+
+# EVIDENCE-OF: R-59573-11075 -- syntax diagram create-table-stmt
+#
+do_createtable_tests 0.5.1 -repair {
+ drop_all_tables
+ execsql { CREATE TABLE t2(a, b, c) }
+} {
+ 1 "CREATE TABLE t1(a, b, c)" {}
+ 2 "CREATE TEMP TABLE t1(a, b, c)" {}
+ 3 "CREATE TEMPORARY TABLE t1(a, b, c)" {}
+ 4 "CREATE TABLE IF NOT EXISTS t1(a, b, c)" {}
+ 5 "CREATE TEMP TABLE IF NOT EXISTS t1(a, b, c)" {}
+ 6 "CREATE TEMPORARY TABLE IF NOT EXISTS t1(a, b, c)" {}
+
+ 7 "CREATE TABLE main.t1(a, b, c)" {}
+ 8 "CREATE TEMP TABLE temp.t1(a, b, c)" {}
+ 9 "CREATE TEMPORARY TABLE temp.t1(a, b, c)" {}
+ 10 "CREATE TABLE IF NOT EXISTS main.t1(a, b, c)" {}
+ 11 "CREATE TEMP TABLE IF NOT EXISTS temp.t1(a, b, c)" {}
+ 12 "CREATE TEMPORARY TABLE IF NOT EXISTS temp.t1(a, b, c)" {}
+
+ 13 "CREATE TABLE t1 AS SELECT * FROM t2" {}
+ 14 "CREATE TEMP TABLE t1 AS SELECT c, b, a FROM t2" {}
+ 15 "CREATE TABLE t1 AS SELECT count(*), max(b), min(a) FROM t2" {}
+}
+
+# EVIDENCE-OF: R-32138-02228 -- syntax diagram foreign-key-clause
+#
+# 1: Explicit parent-key columns.
+# 2: Implicit child-key columns.
+#
+# 1: MATCH FULL
+# 2: MATCH PARTIAL
+# 3: MATCH SIMPLE
+# 4: MATCH STICK
+# 5:
+#
+# 1: ON DELETE SET NULL
+# 2: ON DELETE SET DEFAULT
+# 3: ON DELETE CASCADE
+# 4: ON DELETE RESTRICT
+# 5: ON DELETE NO ACTION
+# 6:
+#
+# 1: ON UPDATE SET NULL
+# 2: ON UPDATE SET DEFAULT
+# 3: ON UPDATE CASCADE
+# 4: ON UPDATE RESTRICT
+# 5: ON UPDATE NO ACTION
+# 6:
+#
+# 1: NOT DEFERRABLE INITIALLY DEFERRED
+# 2: NOT DEFERRABLE INITIALLY IMMEDIATE
+# 3: NOT DEFERRABLE
+# 4: DEFERRABLE INITIALLY DEFERRED
+# 5: DEFERRABLE INITIALLY IMMEDIATE
+# 6: DEFERRABLE
+# 7:
+#
+do_createtable_tests 0.6.1 -repair {
+ drop_all_tables
+ execsql { CREATE TABLE t2(x PRIMARY KEY, y) }
+ execsql { CREATE TABLE t3(i, j, UNIQUE(i, j) ) }
+} {
+ 11146 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH FULL
+ ON DELETE SET NULL ON UPDATE RESTRICT DEFERRABLE
+ )} {}
+ 11412 { CREATE TABLE t1(a
+ REFERENCES t2(x)
+ ON DELETE RESTRICT ON UPDATE SET NULL MATCH FULL
+ NOT DEFERRABLE INITIALLY IMMEDIATE
+ )} {}
+ 12135 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH PARTIAL
+ ON DELETE SET NULL ON UPDATE CASCADE DEFERRABLE INITIALLY IMMEDIATE
+ )} {}
+ 12427 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH PARTIAL
+ ON DELETE RESTRICT ON UPDATE SET DEFAULT
+ )} {}
+ 12446 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH PARTIAL
+ ON DELETE RESTRICT ON UPDATE RESTRICT DEFERRABLE
+ )} {}
+ 12522 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH PARTIAL
+ ON DELETE NO ACTION ON UPDATE SET DEFAULT NOT DEFERRABLE INITIALLY IMMEDIATE
+ )} {}
+ 13133 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH SIMPLE
+ ON DELETE SET NULL ON UPDATE CASCADE NOT DEFERRABLE
+ )} {}
+ 13216 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH SIMPLE
+ ON DELETE SET DEFAULT ON UPDATE SET NULL DEFERRABLE
+ )} {}
+ 13263 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH SIMPLE
+ ON DELETE SET DEFAULT NOT DEFERRABLE
+ )} {}
+ 13421 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH SIMPLE
+ ON DELETE RESTRICT ON UPDATE SET DEFAULT NOT DEFERRABLE INITIALLY DEFERRED
+ )} {}
+ 13432 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH SIMPLE
+ ON DELETE RESTRICT ON UPDATE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE
+ )} {}
+ 13523 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH SIMPLE
+ ON DELETE NO ACTION ON UPDATE SET DEFAULT NOT DEFERRABLE
+ )} {}
+ 14336 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH STICK
+ ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE
+ )} {}
+ 14611 { CREATE TABLE t1(a
+ REFERENCES t2(x) MATCH STICK
+ ON UPDATE SET NULL NOT DEFERRABLE INITIALLY DEFERRED
+ )} {}
+ 15155 { CREATE TABLE t1(a
+ REFERENCES t2(x)
+ ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY IMMEDIATE
+ )} {}
+ 15453 { CREATE TABLE t1(a
+ REFERENCES t2(x) ON DELETE RESTRICT ON UPDATE NO ACTION NOT DEFERRABLE
+ )} {}
+ 15661 { CREATE TABLE t1(a
+ REFERENCES t2(x) NOT DEFERRABLE INITIALLY DEFERRED
+ )} {}
+ 21115 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH FULL
+ ON DELETE SET NULL ON UPDATE SET NULL DEFERRABLE INITIALLY IMMEDIATE
+ )} {}
+ 21123 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH FULL
+ ON DELETE SET NULL ON UPDATE SET DEFAULT NOT DEFERRABLE
+ )} {}
+ 21217 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET NULL
+ )} {}
+ 21362 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH FULL
+ ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE
+ )} {}
+ 22143 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH PARTIAL
+ ON DELETE SET NULL ON UPDATE RESTRICT NOT DEFERRABLE
+ )} {}
+ 22156 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH PARTIAL
+ ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE
+ )} {}
+ 22327 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH PARTIAL ON DELETE CASCADE ON UPDATE SET DEFAULT
+ )} {}
+ 22663 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH PARTIAL NOT DEFERRABLE
+ )} {}
+ 23236 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH SIMPLE
+ ON DELETE SET DEFAULT ON UPDATE CASCADE DEFERRABLE
+ )} {}
+ 24155 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH STICK
+ ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY IMMEDIATE
+ )} {}
+ 24522 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH STICK
+ ON DELETE NO ACTION ON UPDATE SET DEFAULT NOT DEFERRABLE INITIALLY IMMEDIATE
+ )} {}
+ 24625 { CREATE TABLE t1(a
+ REFERENCES t2 MATCH STICK
+ ON UPDATE SET DEFAULT DEFERRABLE INITIALLY IMMEDIATE
+ )} {}
+ 25454 { CREATE TABLE t1(a
+ REFERENCES t2
+ ON DELETE RESTRICT ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED
+ )} {}
+}
+
+#-------------------------------------------------------------------------
+# Test cases e_createtable-1.* - test statements related to table and
+# database names, the TEMP and TEMPORARY keywords, and the IF NOT EXISTS
+# clause.
+#
+drop_all_tables
+forcedelete test.db2 test.db3
+
+do_execsql_test e_createtable-1.0 {
+ ATTACH 'test.db2' AS auxa;
+ ATTACH 'test.db3' AS auxb;
+} {}
+
+# EVIDENCE-OF: R-17899-04554 Table names that begin with "sqlite_" are
+# reserved for internal use. It is an error to attempt to create a table
+# with a name that starts with "sqlite_".
+#
+do_createtable_tests 1.1.1 -error {
+ object name reserved for internal use: %s
+} {
+ 1 "CREATE TABLE sqlite_abc(a, b, c)" sqlite_abc
+ 2 "CREATE TABLE temp.sqlite_helloworld(x)" sqlite_helloworld
+ 3 {CREATE TABLE auxa."sqlite__"(x, y)} sqlite__
+ 4 {CREATE TABLE auxb."sqlite_"(z)} sqlite_
+ 5 {CREATE TABLE "SQLITE_TBL"(z)} SQLITE_TBL
+}
+do_createtable_tests 1.1.2 {
+ 1 "CREATE TABLE sqlit_abc(a, b, c)" {}
+ 2 "CREATE TABLE temp.sqlitehelloworld(x)" {}
+ 3 {CREATE TABLE auxa."sqlite"(x, y)} {}
+ 4 {CREATE TABLE auxb."sqlite-"(z)} {}
+ 5 {CREATE TABLE "SQLITE-TBL"(z)} {}
+}
+
+
+# EVIDENCE-OF: R-10195-31023 If a <database-name> is specified, it
+# must be either "main", "temp", or the name of an attached database.
+#
+# EVIDENCE-OF: R-39822-07822 In this case the new table is created in
+# the named database.
+#
+# Test cases 1.2.* test the first of the two requirements above. The
+# second is verified by cases 1.3.*.
+#
+do_createtable_tests 1.2.1 -error {
+ unknown database %s
+} {
+ 1 "CREATE TABLE george.t1(a, b)" george
+ 2 "CREATE TABLE _.t1(a, b)" _
+}
+do_createtable_tests 1.2.2 {
+ 1 "CREATE TABLE main.abc(a, b, c)" {}
+ 2 "CREATE TABLE temp.helloworld(x)" {}
+ 3 {CREATE TABLE auxa."t 1"(x, y)} {}
+ 4 {CREATE TABLE auxb.xyz(z)} {}
+}
+drop_all_tables
+do_createtable_tests 1.3 -tclquery {
+ unset -nocomplain X
+ array set X [table_list]
+ list $X(main) $X(temp) $X(auxa) $X(auxb)
+} {
+ 1 "CREATE TABLE main.abc(a, b, c)" {abc {} {} {}}
+ 2 "CREATE TABLE main.t1(a, b, c)" {{abc t1} {} {} {}}
+ 3 "CREATE TABLE temp.tmp(a, b, c)" {{abc t1} tmp {} {}}
+ 4 "CREATE TABLE auxb.tbl(x, y)" {{abc t1} tmp {} tbl}
+ 5 "CREATE TABLE auxb.t1(k, v)" {{abc t1} tmp {} {t1 tbl}}
+ 6 "CREATE TABLE auxa.next(c, d)" {{abc t1} tmp next {t1 tbl}}
+}
+
+# EVIDENCE-OF: R-18895-27365 If the "TEMP" or "TEMPORARY" keyword occurs
+# between the "CREATE" and "TABLE" then the new table is created in the
+# temp database.
+#
+drop_all_tables
+do_createtable_tests 1.4 -tclquery {
+ unset -nocomplain X
+ array set X [table_list]
+ list $X(main) $X(temp) $X(auxa) $X(auxb)
+} {
+ 1 "CREATE TEMP TABLE t1(a, b)" {{} t1 {} {}}
+ 2 "CREATE TEMPORARY TABLE t2(a, b)" {{} {t1 t2} {} {}}
+}
+
+# EVIDENCE-OF: R-49439-47561 It is an error to specify both a
+# <database-name> and the TEMP or TEMPORARY keyword, unless the
+# <database-name> is "temp".
+#
+drop_all_tables
+do_createtable_tests 1.5.1 -error {
+ temporary table name must be unqualified
+} {
+ 1 "CREATE TEMP TABLE main.t1(a, b)" {}
+ 2 "CREATE TEMPORARY TABLE auxa.t2(a, b)" {}
+ 3 "CREATE TEMP TABLE auxb.t3(a, b)" {}
+ 4 "CREATE TEMPORARY TABLE main.xxx(x)" {}
+}
+drop_all_tables
+do_createtable_tests 1.5.2 -tclquery {
+ unset -nocomplain X
+ array set X [table_list]
+ list $X(main) $X(temp) $X(auxa) $X(auxb)
+} {
+ 1 "CREATE TEMP TABLE temp.t1(a, b)" {{} t1 {} {}}
+ 2 "CREATE TEMPORARY TABLE temp.t2(a, b)" {{} {t1 t2} {} {}}
+ 3 "CREATE TEMP TABLE TEMP.t3(a, b)" {{} {t1 t2 t3} {} {}}
+ 4 "CREATE TEMPORARY TABLE TEMP.xxx(x)" {{} {t1 t2 t3 xxx} {} {}}
+}
+
+# EVIDENCE-OF: R-00917-09393 If no database name is specified and the
+# TEMP keyword is not present then the table is created in the main
+# database.
+#
+drop_all_tables
+do_createtable_tests 1.6 -tclquery {
+ unset -nocomplain X
+ array set X [table_list]
+ list $X(main) $X(temp) $X(auxa) $X(auxb)
+} {
+ 1 "CREATE TABLE t1(a, b)" {t1 {} {} {}}
+ 2 "CREATE TABLE t2(a, b)" {{t1 t2} {} {} {}}
+ 3 "CREATE TABLE t3(a, b)" {{t1 t2 t3} {} {} {}}
+ 4 "CREATE TABLE xxx(x)" {{t1 t2 t3 xxx} {} {} {}}
+}
+
+drop_all_tables
+do_execsql_test e_createtable-1.7.0 {
+ CREATE TABLE t1(x, y);
+ CREATE INDEX i1 ON t1(x);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+
+ CREATE TABLE auxa.tbl1(x, y);
+ CREATE INDEX auxa.idx1 ON tbl1(x);
+ CREATE VIEW auxa.view1 AS SELECT * FROM tbl1;
+} {}
+
+# EVIDENCE-OF: R-01232-54838 It is usually an error to attempt to create
+# a new table in a database that already contains a table, index or view
+# of the same name.
+#
+# Test cases 1.7.1.* verify that creating a table in a database with a
+# table/index/view of the same name does fail. 1.7.2.* tests that creating
+# a table with the same name as a table/index/view in a different database
+# is Ok.
+#
+do_createtable_tests 1.7.1 -error { %s } {
+ 1 "CREATE TABLE t1(a, b)" {{table t1 already exists}}
+ 2 "CREATE TABLE i1(a, b)" {{there is already an index named i1}}
+ 3 "CREATE TABLE v1(a, b)" {{table v1 already exists}}
+ 4 "CREATE TABLE auxa.tbl1(a, b)" {{table tbl1 already exists}}
+ 5 "CREATE TABLE auxa.idx1(a, b)" {{there is already an index named idx1}}
+ 6 "CREATE TABLE auxa.view1(a, b)" {{table view1 already exists}}
+}
+do_createtable_tests 1.7.2 {
+ 1 "CREATE TABLE auxa.t1(a, b)" {}
+ 2 "CREATE TABLE auxa.i1(a, b)" {}
+ 3 "CREATE TABLE auxa.v1(a, b)" {}
+ 4 "CREATE TABLE tbl1(a, b)" {}
+ 5 "CREATE TABLE idx1(a, b)" {}
+ 6 "CREATE TABLE view1(a, b)" {}
+}
+
+# EVIDENCE-OF: R-33917-24086 However, if the "IF NOT EXISTS" clause is
+# specified as part of the CREATE TABLE statement and a table or view of
+# the same name already exists, the CREATE TABLE command simply has no
+# effect (and no error message is returned).
+#
+drop_all_tables
+do_execsql_test e_createtable-1.8.0 {
+ CREATE TABLE t1(x, y);
+ CREATE INDEX i1 ON t1(x);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE TABLE auxa.tbl1(x, y);
+ CREATE INDEX auxa.idx1 ON tbl1(x);
+ CREATE VIEW auxa.view1 AS SELECT * FROM tbl1;
+} {}
+do_createtable_tests 1.8 {
+ 1 "CREATE TABLE IF NOT EXISTS t1(a, b)" {}
+ 2 "CREATE TABLE IF NOT EXISTS auxa.tbl1(a, b)" {}
+ 3 "CREATE TABLE IF NOT EXISTS v1(a, b)" {}
+ 4 "CREATE TABLE IF NOT EXISTS auxa.view1(a, b)" {}
+}
+
+# EVIDENCE-OF: R-16465-40078 An error is still returned if the table
+# cannot be created because of an existing index, even if the "IF NOT
+# EXISTS" clause is specified.
+#
+do_createtable_tests 1.9 -error { %s } {
+ 1 "CREATE TABLE IF NOT EXISTS i1(a, b)"
+ {{there is already an index named i1}}
+ 2 "CREATE TABLE IF NOT EXISTS auxa.idx1(a, b)"
+ {{there is already an index named idx1}}
+}
+
+# EVIDENCE-OF: R-05513-33819 It is not an error to create a table that
+# has the same name as an existing trigger.
+#
+drop_all_tables
+do_execsql_test e_createtable-1.10.0 {
+ CREATE TABLE t1(x, y);
+ CREATE TABLE auxb.t2(x, y);
+
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ SELECT 1;
+ END;
+ CREATE TRIGGER auxb.tr2 AFTER INSERT ON t2 BEGIN
+ SELECT 1;
+ END;
+} {}
+do_createtable_tests 1.10 {
+ 1 "CREATE TABLE tr1(a, b)" {}
+ 2 "CREATE TABLE tr2(a, b)" {}
+ 3 "CREATE TABLE auxb.tr1(a, b)" {}
+ 4 "CREATE TABLE auxb.tr2(a, b)" {}
+}
+
+# EVIDENCE-OF: R-22283-14179 Tables are removed using the DROP TABLE
+# statement.
+#
+drop_all_tables
+do_execsql_test e_createtable-1.11.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ CREATE TABLE auxa.t3(a, b);
+ CREATE TABLE auxa.t4(a, b);
+} {}
+
+do_execsql_test e_createtable-1.11.1.1 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ SELECT * FROM t3;
+ SELECT * FROM t4;
+} {}
+do_execsql_test e_createtable-1.11.1.2 { DROP TABLE t1 } {}
+do_catchsql_test e_createtable-1.11.1.3 {
+ SELECT * FROM t1
+} {1 {no such table: t1}}
+do_execsql_test e_createtable-1.11.1.4 { DROP TABLE t3 } {}
+do_catchsql_test e_createtable-1.11.1.5 {
+ SELECT * FROM t3
+} {1 {no such table: t3}}
+
+do_execsql_test e_createtable-1.11.2.1 {
+ SELECT name FROM sqlite_master;
+ SELECT name FROM auxa.sqlite_master;
+} {t2 t4}
+do_execsql_test e_createtable-1.11.2.2 { DROP TABLE t2 } {}
+do_execsql_test e_createtable-1.11.2.3 { DROP TABLE t4 } {}
+do_execsql_test e_createtable-1.11.2.4 {
+ SELECT name FROM sqlite_master;
+ SELECT name FROM auxa.sqlite_master;
+} {}
+
+#-------------------------------------------------------------------------
+# Test cases e_createtable-2.* - test statements related to the CREATE
+# TABLE AS ... SELECT statement.
+#
+
+# Three Tcl commands:
+#
+# select_column_names SQL
+# The argument must be a SELECT statement. Return a list of the names
+# of the columns of the result-set that would be returned by executing
+# the SELECT.
+#
+# table_column_names TBL
+# The argument must be a table name. Return a list of column names, from
+# left to right, for the table.
+#
+# table_column_decltypes TBL
+# The argument must be a table name. Return a list of column declared
+# types, from left to right, for the table.
+#
+proc sci {select cmd} {
+ set res [list]
+ set STMT [sqlite3_prepare_v2 db $select -1 dummy]
+ for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {
+ lappend res [$cmd $STMT $i]
+ }
+ sqlite3_finalize $STMT
+ set res
+}
+proc tci {tbl cmd} { sci "SELECT * FROM $tbl" $cmd }
+proc select_column_names {sql} { sci $sql sqlite3_column_name }
+proc table_column_names {tbl} { tci $tbl sqlite3_column_name }
+proc table_column_decltypes {tbl} { tci $tbl sqlite3_column_decltype }
+
+# Create a database schema. This schema is used by tests 2.1.* through 2.3.*.
+#
+drop_all_tables
+do_execsql_test e_createtable-2.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e, f);
+ CREATE TABLE t3(g BIGINT, h VARCHAR(10));
+ CREATE TABLE t4(i BLOB, j ANYOLDATA);
+ CREATE TABLE t5(k FLOAT, l INTEGER);
+ CREATE TABLE t6(m DEFAULT 10, n DEFAULT 5, PRIMARY KEY(m, n));
+ CREATE TABLE t7(x INTEGER PRIMARY KEY);
+ CREATE TABLE t8(o COLLATE nocase DEFAULT 'abc');
+ CREATE TABLE t9(p NOT NULL, q DOUBLE CHECK (q!=0), r STRING UNIQUE);
+} {}
+
+# EVIDENCE-OF: R-64828-59568 The table has the same number of columns as
+# the rows returned by the SELECT statement. The name of each column is
+# the same as the name of the corresponding column in the result set of
+# the SELECT statement.
+#
+do_createtable_tests 2.1 -tclquery {
+ table_column_names x1
+} -repair {
+ catchsql { DROP TABLE x1 }
+} {
+ 1 "CREATE TABLE x1 AS SELECT * FROM t1" {a b c}
+ 2 "CREATE TABLE x1 AS SELECT c, b, a FROM t1" {c b a}
+ 3 "CREATE TABLE x1 AS SELECT * FROM t1, t2" {a b c d e f}
+ 4 "CREATE TABLE x1 AS SELECT count(*) FROM t1" {count(*)}
+ 5 "CREATE TABLE x1 AS SELECT count(a) AS a, max(b) FROM t1" {a max(b)}
+}
+
+# EVIDENCE-OF: R-37111-22855 The declared type of each column is
+# determined by the expression affinity of the corresponding expression
+# in the result set of the SELECT statement, as follows: Expression
+# Affinity Column Declared Type TEXT "TEXT" NUMERIC "NUM" INTEGER "INT"
+# REAL "REAL" NONE "" (empty string)
+#
+do_createtable_tests 2.2 -tclquery {
+ table_column_decltypes x1
+} -repair {
+ catchsql { DROP TABLE x1 }
+} {
+ 1 "CREATE TABLE x1 AS SELECT a FROM t1" {""}
+ 2 "CREATE TABLE x1 AS SELECT * FROM t3" {INT TEXT}
+ 3 "CREATE TABLE x1 AS SELECT * FROM t4" {"" NUM}
+ 4 "CREATE TABLE x1 AS SELECT * FROM t5" {REAL INT}
+}
+
+# EVIDENCE-OF: R-16667-09772 A table created using CREATE TABLE AS has
+# no PRIMARY KEY and no constraints of any kind. The default value of
+# each column is NULL. The default collation sequence for each column of
+# the new table is BINARY.
+#
+# The following tests create tables based on SELECT statements that read
+# from tables that have primary keys, constraints and explicit default
+# collation sequences. None of this is transfered to the definition of
+# the new table as stored in the sqlite_master table.
+#
+# Tests 2.3.2.* show that the default value of each column is NULL.
+#
+do_createtable_tests 2.3.1 -query {
+ SELECT sql FROM sqlite_master ORDER BY rowid DESC LIMIT 1
+} {
+ 1 "CREATE TABLE x1 AS SELECT * FROM t6" {{CREATE TABLE x1(m,n)}}
+ 2 "CREATE TABLE x2 AS SELECT * FROM t7" {{CREATE TABLE x2(x INT)}}
+ 3 "CREATE TABLE x3 AS SELECT * FROM t8" {{CREATE TABLE x3(o)}}
+ 4 "CREATE TABLE x4 AS SELECT * FROM t9" {{CREATE TABLE x4(p,q REAL,r NUM)}}
+}
+do_execsql_test e_createtable-2.3.2.1 {
+ INSERT INTO x1 DEFAULT VALUES;
+ INSERT INTO x2 DEFAULT VALUES;
+ INSERT INTO x3 DEFAULT VALUES;
+ INSERT INTO x4 DEFAULT VALUES;
+} {}
+db nullvalue null
+do_execsql_test e_createtable-2.3.2.2 { SELECT * FROM x1 } {null null}
+do_execsql_test e_createtable-2.3.2.3 { SELECT * FROM x2 } {null}
+do_execsql_test e_createtable-2.3.2.4 { SELECT * FROM x3 } {null}
+do_execsql_test e_createtable-2.3.2.5 { SELECT * FROM x4 } {null null null}
+db nullvalue {}
+
+drop_all_tables
+do_execsql_test e_createtable-2.4.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES('i', 'one');
+ INSERT INTO t1 VALUES('ii', 'two');
+ INSERT INTO t1 VALUES('iii', 'three');
+} {}
+
+# EVIDENCE-OF: R-24153-28352 Tables created using CREATE TABLE AS are
+# initially populated with the rows of data returned by the SELECT
+# statement.
+#
+# EVIDENCE-OF: R-08224-30249 Rows are assigned contiguously ascending
+# rowid values, starting with 1, in the order that they are returned by
+# the SELECT statement.
+#
+# Each test case below is specified as the name of a table to create
+# using "CREATE TABLE ... AS SELECT ..." and a SELECT statement to use in
+# creating it. The table is created.
+#
+# Test cases 2.4.*.1 check that after it has been created, the data in the
+# table is the same as the data returned by the SELECT statement executed as
+# a standalone command, verifying the first testable statement above.
+#
+# Test cases 2.4.*.2 check that the rowids were allocated contiguously
+# as required by the second testable statement above. That the rowids
+# from the contiguous block were allocated to rows in the order rows are
+# returned by the SELECT statement is verified by 2.4.*.1.
+#
+# EVIDENCE-OF: R-32365-09043 A "CREATE TABLE ... AS SELECT" statement
+# creates and populates a database table based on the results of a
+# SELECT statement.
+#
+# The above is also considered to be tested by the following. It is
+# clear that tables are being created and populated by the command in
+# question.
+#
+foreach {tn tbl select} {
+ 1 x1 "SELECT * FROM t1"
+ 2 x2 "SELECT * FROM t1 ORDER BY x DESC"
+ 3 x3 "SELECT * FROM t1 ORDER BY x ASC"
+} {
+ # Create the table using a "CREATE TABLE ... AS SELECT ..." command.
+ execsql [subst {CREATE TABLE $tbl AS $select}]
+
+ # Check that the rows inserted into the table, sorted in ascending rowid
+ # order, match those returned by executing the SELECT statement as a
+ # standalone command.
+ do_execsql_test e_createtable-2.4.$tn.1 [subst {
+ SELECT * FROM $tbl ORDER BY rowid;
+ }] [execsql $select]
+
+ # Check that the rowids in the new table are a contiguous block starting
+ # with rowid 1. Note that this will fail if SELECT statement $select
+ # returns 0 rows (as max(rowid) will be NULL).
+ do_execsql_test e_createtable-2.4.$tn.2 [subst {
+ SELECT min(rowid), count(rowid)==max(rowid) FROM $tbl
+ }] {1 1}
+}
+
+#--------------------------------------------------------------------------
+# Test cases for column defintions in CREATE TABLE statements that do not
+# use a SELECT statement. Not including data constraints. In other words,
+# tests for the specification of:
+#
+# * declared types,
+# * default values, and
+# * default collation sequences.
+#
+
+# EVIDENCE-OF: R-27219-49057 Unlike most SQL databases, SQLite does not
+# restrict the type of data that may be inserted into a column based on
+# the columns declared type.
+#
+# Test this by creating a few tables with varied declared types, then
+# inserting various different types of values into them.
+#
+drop_all_tables
+do_execsql_test e_createtable-3.1.0 {
+ CREATE TABLE t1(x VARCHAR(10), y INTEGER, z DOUBLE);
+ CREATE TABLE t2(a DATETIME, b STRING, c REAL);
+ CREATE TABLE t3(o, t);
+} {}
+
+# value type -> declared column type
+# ----------------------------------
+# integer -> VARCHAR(10)
+# string -> INTEGER
+# blob -> DOUBLE
+#
+do_execsql_test e_createtable-3.1.1 {
+ INSERT INTO t1 VALUES(14, 'quite a lengthy string', X'555655');
+ SELECT * FROM t1;
+} {14 {quite a lengthy string} UVU}
+
+# string -> DATETIME
+# integer -> STRING
+# time -> REAL
+#
+do_execsql_test e_createtable-3.1.2 {
+ INSERT INTO t2 VALUES('not a datetime', 13, '12:41:59');
+ SELECT * FROM t2;
+} {{not a datetime} 13 12:41:59}
+
+# EVIDENCE-OF: R-10565-09557 The declared type of a column is used to
+# determine the affinity of the column only.
+#
+# Affinities are tested in more detail elsewhere (see document
+# datatype3.html). Here, just test that affinity transformations
+# consistent with the expected affinity of each column (based on
+# the declared type) appear to take place.
+#
+# Affinities of t1 (test cases 3.2.1.*): TEXT, INTEGER, REAL
+# Affinities of t2 (test cases 3.2.2.*): NUMERIC, NUMERIC, REAL
+# Affinities of t3 (test cases 3.2.3.*): NONE, NONE
+#
+do_execsql_test e_createtable-3.2.0 { DELETE FROM t1; DELETE FROM t2; } {}
+
+do_createtable_tests 3.2.1 -query {
+ SELECT quote(x), quote(y), quote(z) FROM t1 ORDER BY rowid DESC LIMIT 1;
+} {
+ 1 "INSERT INTO t1 VALUES(15, '22.0', '14')" {'15' 22 14.0}
+ 2 "INSERT INTO t1 VALUES(22.0, 22.0, 22.0)" {'22.0' 22 22.0}
+}
+do_createtable_tests 3.2.2 -query {
+ SELECT quote(a), quote(b), quote(c) FROM t2 ORDER BY rowid DESC LIMIT 1;
+} {
+ 1 "INSERT INTO t2 VALUES(15, '22.0', '14')" {15 22 14.0}
+ 2 "INSERT INTO t2 VALUES(22.0, 22.0, 22.0)" {22 22 22.0}
+}
+do_createtable_tests 3.2.3 -query {
+ SELECT quote(o), quote(t) FROM t3 ORDER BY rowid DESC LIMIT 1;
+} {
+ 1 "INSERT INTO t3 VALUES('15', '22.0')" {'15' '22.0'}
+ 2 "INSERT INTO t3 VALUES(15, 22.0)" {15 22.0}
+}
+
+# EVIDENCE-OF: R-42316-09582 If there is no explicit DEFAULT clause
+# attached to a column definition, then the default value of the column
+# is NULL.
+#
+# None of the columns in table t1 have an explicit DEFAULT clause.
+# So testing that the default value of all columns in table t1 is
+# NULL serves to verify the above.
+#
+do_createtable_tests 3.2.3 -query {
+ SELECT quote(x), quote(y), quote(z) FROM t1
+} -repair {
+ execsql { DELETE FROM t1 }
+} {
+ 1 "INSERT INTO t1(x, y) VALUES('abc', 'xyz')" {'abc' 'xyz' NULL}
+ 2 "INSERT INTO t1(x, z) VALUES('abc', 'xyz')" {'abc' NULL 'xyz'}
+ 3 "INSERT INTO t1 DEFAULT VALUES" {NULL NULL NULL}
+}
+
+# EVIDENCE-OF: R-62940-43005 An explicit DEFAULT clause may specify that
+# the default value is NULL, a string constant, a blob constant, a
+# signed-number, or any constant expression enclosed in parentheses. An
+# explicit default value may also be one of the special case-independent
+# keywords CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP.
+#
+do_execsql_test e_createtable-3.3.1 {
+ CREATE TABLE t4(
+ a DEFAULT NULL,
+ b DEFAULT 'string constant',
+ c DEFAULT X'424C4F42',
+ d DEFAULT 1,
+ e DEFAULT -1,
+ f DEFAULT 3.14,
+ g DEFAULT -3.14,
+ h DEFAULT ( substr('abcd', 0, 2) || 'cd' ),
+ i DEFAULT CURRENT_TIME,
+ j DEFAULT CURRENT_DATE,
+ k DEFAULT CURRENT_TIMESTAMP
+ );
+} {}
+
+# EVIDENCE-OF: R-10288-43169 For the purposes of the DEFAULT clause, an
+# expression is considered constant provided that it does not contain
+# any sub-queries or string constants enclosed in double quotes.
+#
+do_createtable_tests 3.4.1 -error {
+ default value of column [x] is not constant
+} {
+ 1 {CREATE TABLE t5(x DEFAULT ( (SELECT 1) ))} {}
+ 2 {CREATE TABLE t5(x DEFAULT ( "abc" ))} {}
+ 3 {CREATE TABLE t5(x DEFAULT ( 1 IN (SELECT 1) ))} {}
+ 4 {CREATE TABLE t5(x DEFAULT ( EXISTS (SELECT 1) ))} {}
+}
+do_createtable_tests 3.4.2 -repair {
+ catchsql { DROP TABLE t5 }
+} {
+ 1 {CREATE TABLE t5(x DEFAULT ( 'abc' ))} {}
+ 2 {CREATE TABLE t5(x DEFAULT ( 1 IN (1, 2, 3) ))} {}
+}
+
+# EVIDENCE-OF: R-18814-23501 Each time a row is inserted into the table
+# by an INSERT statement that does not provide explicit values for all
+# table columns the values stored in the new row are determined by their
+# default values
+#
+# Verify this with some assert statements for which all, some and no
+# columns lack explicit values.
+#
+set sqlite_current_time 1000000000
+do_createtable_tests 3.5 -query {
+ SELECT quote(a), quote(b), quote(c), quote(d), quote(e), quote(f),
+ quote(g), quote(h), quote(i), quote(j), quote(k)
+ FROM t4 ORDER BY rowid DESC LIMIT 1;
+} {
+ 1 "INSERT INTO t4 DEFAULT VALUES" {
+ NULL {'string constant'} X'424C4F42' 1 -1 3.14 -3.14
+ 'acd' '01:46:40' '2001-09-09' {'2001-09-09 01:46:40'}
+ }
+
+ 2 "INSERT INTO t4(a, b, c) VALUES(1, 2, 3)" {
+ 1 2 3 1 -1 3.14 -3.14 'acd' '01:46:40' '2001-09-09' {'2001-09-09 01:46:40'}
+ }
+
+ 3 "INSERT INTO t4(k, j, i) VALUES(1, 2, 3)" {
+ NULL {'string constant'} X'424C4F42' 1 -1 3.14 -3.14 'acd' 3 2 1
+ }
+
+ 4 "INSERT INTO t4(a,b,c,d,e,f,g,h,i,j,k) VALUES(1,2,3,4,5,6,7,8,9,10,11)" {
+ 1 2 3 4 5 6 7 8 9 10 11
+ }
+}
+
+# EVIDENCE-OF: R-12572-62501 If the default value of the column is a
+# constant NULL, text, blob or signed-number value, then that value is
+# used directly in the new row.
+#
+do_execsql_test e_createtable-3.6.1 {
+ CREATE TABLE t5(
+ a DEFAULT NULL,
+ b DEFAULT 'text value',
+ c DEFAULT X'424C4F42',
+ d DEFAULT -45678.6,
+ e DEFAULT 394507
+ );
+} {}
+do_execsql_test e_createtable-3.6.2 {
+ INSERT INTO t5 DEFAULT VALUES;
+ SELECT quote(a), quote(b), quote(c), quote(d), quote(e) FROM t5;
+} {NULL {'text value'} X'424C4F42' -45678.6 394507}
+
+# EVIDENCE-OF: R-60616-50251 If the default value of a column is an
+# expression in parentheses, then the expression is evaluated once for
+# each row inserted and the results used in the new row.
+#
+# Test case 3.6.4 demonstrates that the expression is evaluated
+# separately for each row if the INSERT is an "INSERT INTO ... SELECT ..."
+# command.
+#
+set ::nextint 0
+proc nextint {} { incr ::nextint }
+db func nextint nextint
+
+do_execsql_test e_createtable-3.7.1 {
+ CREATE TABLE t6(a DEFAULT ( nextint() ), b DEFAULT ( nextint() ));
+} {}
+do_execsql_test e_createtable-3.7.2 {
+ INSERT INTO t6 DEFAULT VALUES;
+ SELECT quote(a), quote(b) FROM t6;
+} {1 2}
+do_execsql_test e_createtable-3.7.3 {
+ INSERT INTO t6(a) VALUES('X');
+ SELECT quote(a), quote(b) FROM t6;
+} {1 2 'X' 3}
+do_execsql_test e_createtable-3.7.4 {
+ INSERT INTO t6(a) SELECT a FROM t6;
+ SELECT quote(a), quote(b) FROM t6;
+} {1 2 'X' 3 1 4 'X' 5}
+
+# EVIDENCE-OF: R-15363-55230 If the default value of a column is
+# CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP, then the value used
+# in the new row is a text representation of the current UTC date and/or
+# time.
+#
+# This is difficult to test literally without knowing what time the
+# user will run the tests. Instead, we test that the three cases
+# above set the value to the current date and/or time according to
+# the xCurrentTime() method of the VFS. Which is usually the same
+# as UTC. In this case, however, we instrument it to always return
+# a time equivalent to "2001-09-09 01:46:40 UTC".
+#
+set sqlite_current_time 1000000000
+do_execsql_test e_createtable-3.8.1 {
+ CREATE TABLE t7(
+ a DEFAULT CURRENT_TIME,
+ b DEFAULT CURRENT_DATE,
+ c DEFAULT CURRENT_TIMESTAMP
+ );
+} {}
+do_execsql_test e_createtable-3.8.2 {
+ INSERT INTO t7 DEFAULT VALUES;
+ SELECT quote(a), quote(b), quote(c) FROM t7;
+} {'01:46:40' '2001-09-09' {'2001-09-09 01:46:40'}}
+
+
+# EVIDENCE-OF: R-62327-53843 For CURRENT_TIME, the format of the value
+# is "HH:MM:SS".
+#
+# EVIDENCE-OF: R-03775-43471 For CURRENT_DATE, "YYYY-MM-DD".
+#
+# EVIDENCE-OF: R-07677-44926 The format for CURRENT_TIMESTAMP is
+# "YYYY-MM-DD HH:MM:SS".
+#
+# The three above are demonstrated by tests 1, 2 and 3 below.
+# Respectively.
+#
+do_createtable_tests 3.8.3 -query {
+ SELECT a, b, c FROM t7 ORDER BY rowid DESC LIMIT 1;
+} {
+ 1 "INSERT INTO t7(b, c) VALUES('x', 'y')" {01:46:40 x y}
+ 2 "INSERT INTO t7(c, a) VALUES('x', 'y')" {y 2001-09-09 x}
+ 3 "INSERT INTO t7(a, b) VALUES('x', 'y')" {x y {2001-09-09 01:46:40}}
+}
+
+# EVIDENCE-OF: R-55061-47754 The COLLATE clause specifies the name of a
+# collating sequence to use as the default collation sequence for the
+# column.
+#
+# EVIDENCE-OF: R-40275-54363 If no COLLATE clause is specified, the
+# default collation sequence is BINARY.
+#
+do_execsql_test e_createtable-3-9.1 {
+ CREATE TABLE t8(a COLLATE nocase, b COLLATE rtrim, c COLLATE binary, d);
+ INSERT INTO t8 VALUES('abc', 'abc', 'abc', 'abc');
+ INSERT INTO t8 VALUES('abc ', 'abc ', 'abc ', 'abc ');
+ INSERT INTO t8 VALUES('ABC ', 'ABC ', 'ABC ', 'ABC ');
+ INSERT INTO t8 VALUES('ABC', 'ABC', 'ABC', 'ABC');
+} {}
+do_createtable_tests 3.9 {
+ 2 "SELECT a FROM t8 ORDER BY a, rowid" {abc ABC {abc } {ABC }}
+ 3 "SELECT b FROM t8 ORDER BY b, rowid" {{ABC } ABC abc {abc }}
+ 4 "SELECT c FROM t8 ORDER BY c, rowid" {ABC {ABC } abc {abc }}
+ 5 "SELECT d FROM t8 ORDER BY d, rowid" {ABC {ABC } abc {abc }}
+}
+
+# EVIDENCE-OF: R-25473-20557 The number of columns in a table is limited
+# by the SQLITE_MAX_COLUMN compile-time parameter.
+#
+proc columns {n} {
+ set res [list]
+ for {set i 0} {$i < $n} {incr i} { lappend res "c$i" }
+ join $res ", "
+}
+do_execsql_test e_createtable-3.10.1 [subst {
+ CREATE TABLE t9([columns $::SQLITE_MAX_COLUMN]);
+}] {}
+do_catchsql_test e_createtable-3.10.2 [subst {
+ CREATE TABLE t10([columns [expr $::SQLITE_MAX_COLUMN+1]]);
+}] {1 {too many columns on t10}}
+
+# EVIDENCE-OF: R-27775-64721 Both of these limits can be lowered at
+# runtime using the sqlite3_limit() C/C++ interface.
+#
+# A 30,000 byte blob consumes 30,003 bytes of record space. A record
+# that contains 3 such blobs consumes (30,000*3)+1 bytes of space. Tests
+# 3.11.4 and 3.11.5, which verify that SQLITE_MAX_LENGTH may be lowered
+# at runtime, are based on this calculation.
+#
+sqlite3_limit db SQLITE_LIMIT_COLUMN 500
+do_execsql_test e_createtable-3.11.1 [subst {
+ CREATE TABLE t10([columns 500]);
+}] {}
+do_catchsql_test e_createtable-3.11.2 [subst {
+ CREATE TABLE t11([columns 501]);
+}] {1 {too many columns on t11}}
+
+# Check that it is not possible to raise the column limit above its
+# default compile time value.
+#
+sqlite3_limit db SQLITE_LIMIT_COLUMN [expr $::SQLITE_MAX_COLUMN+2]
+do_catchsql_test e_createtable-3.11.3 [subst {
+ CREATE TABLE t11([columns [expr $::SQLITE_MAX_COLUMN+1]]);
+}] {1 {too many columns on t11}}
+
+sqlite3_limit db SQLITE_LIMIT_LENGTH 90010
+do_execsql_test e_createtable-3.11.4 {
+ CREATE TABLE t12(a, b, c);
+ INSERT INTO t12 VALUES(randomblob(30000),randomblob(30000),randomblob(30000));
+} {}
+do_catchsql_test e_createtable-3.11.5 {
+ INSERT INTO t12 VALUES(randomblob(30001),randomblob(30000),randomblob(30000));
+} {1 {string or blob too big}}
+
+#-------------------------------------------------------------------------
+# Tests for statements regarding constraints (PRIMARY KEY, UNIQUE, NOT
+# NULL and CHECK constraints).
+#
+
+# EVIDENCE-OF: R-52382-54248 Each table in SQLite may have at most one
+# PRIMARY KEY.
+#
+# EVIDENCE-OF: R-18080-47271 If there is more than one PRIMARY KEY
+# clause in a single CREATE TABLE statement, it is an error.
+#
+# To test the two above, show that zero primary keys is Ok, one primary
+# key is Ok, and two or more primary keys is an error.
+#
+drop_all_tables
+do_createtable_tests 4.1.1 {
+ 1 "CREATE TABLE t1(a, b, c)" {}
+ 2 "CREATE TABLE t2(a PRIMARY KEY, b, c)" {}
+ 3 "CREATE TABLE t3(a, b, c, PRIMARY KEY(a))" {}
+ 4 "CREATE TABLE t4(a, b, c, PRIMARY KEY(c,b,a))" {}
+}
+do_createtable_tests 4.1.2 -error {
+ table "t5" has more than one primary key
+} {
+ 1 "CREATE TABLE t5(a PRIMARY KEY, b PRIMARY KEY, c)" {}
+ 2 "CREATE TABLE t5(a, b PRIMARY KEY, c, PRIMARY KEY(a))" {}
+ 3 "CREATE TABLE t5(a INTEGER PRIMARY KEY, b PRIMARY KEY, c)" {}
+ 4 "CREATE TABLE t5(a INTEGER PRIMARY KEY, b, c, PRIMARY KEY(b, c))" {}
+ 5 "CREATE TABLE t5(a PRIMARY KEY, b, c, PRIMARY KEY(a))" {}
+ 6 "CREATE TABLE t5(a INTEGER PRIMARY KEY, b, c, PRIMARY KEY(a))" {}
+}
+
+proc table_pk {tbl} {
+ set pk [list]
+ db eval "pragma table_info($tbl)" a {
+ if {$a(pk)} { lappend pk $a(name) }
+ }
+ set pk
+}
+
+# EVIDENCE-OF: R-41411-18837 If the keywords PRIMARY KEY are added to a
+# column definition, then the primary key for the table consists of that
+# single column.
+#
+# The above is tested by 4.2.1.*
+#
+# EVIDENCE-OF: R-31775-48204 Or, if a PRIMARY KEY clause is specified as
+# a table-constraint, then the primary key of the table consists of the
+# list of columns specified as part of the PRIMARY KEY clause.
+#
+# The above is tested by 4.2.2.*
+#
+do_createtable_tests 4.2 -repair {
+ catchsql { DROP TABLE t5 }
+} -tclquery {
+ table_pk t5
+} {
+ 1.1 "CREATE TABLE t5(a, b INTEGER PRIMARY KEY, c)" {b}
+ 1.2 "CREATE TABLE t5(a PRIMARY KEY, b, c)" {a}
+
+ 2.1 "CREATE TABLE t5(a, b, c, PRIMARY KEY(a))" {a}
+ 2.2 "CREATE TABLE t5(a, b, c, PRIMARY KEY(c,b,a))" {a b c}
+ 2.3 "CREATE TABLE t5(a, b INTEGER PRIMARY KEY, c)" {b}
+}
+
+# EVIDENCE-OF: R-33986-09410 Each row in a table with a primary key must
+# feature a unique combination of values in its primary key columns.
+#
+# EVIDENCE-OF: R-39102-06737 If an INSERT or UPDATE statement attempts
+# to modify the table content so that two or more rows feature identical
+# primary key values, it is a constraint violation.
+#
+drop_all_tables
+do_execsql_test 4.3.0 {
+ CREATE TABLE t1(x PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(0, 'zero');
+ INSERT INTO t1 VALUES(45.5, 'one');
+ INSERT INTO t1 VALUES('brambles', 'two');
+ INSERT INTO t1 VALUES(X'ABCDEF', 'three');
+
+ CREATE TABLE t2(x, y, PRIMARY KEY(x, y));
+ INSERT INTO t2 VALUES(0, 'zero');
+ INSERT INTO t2 VALUES(45.5, 'one');
+ INSERT INTO t2 VALUES('brambles', 'two');
+ INSERT INTO t2 VALUES(X'ABCDEF', 'three');
+} {}
+
+do_createtable_tests 4.3.1 -error { %s not unique } {
+ 1 "INSERT INTO t1 VALUES(0, 0)" {"column x is"}
+ 2 "INSERT INTO t1 VALUES(45.5, 'abc')" {"column x is"}
+ 3 "INSERT INTO t1 VALUES(0.0, 'abc')" {"column x is"}
+ 4 "INSERT INTO t1 VALUES('brambles', 'abc')" {"column x is"}
+ 5 "INSERT INTO t1 VALUES(X'ABCDEF', 'abc')" {"column x is"}
+
+ 6 "INSERT INTO t2 VALUES(0, 'zero')" {"columns x, y are"}
+ 7 "INSERT INTO t2 VALUES(45.5, 'one')" {"columns x, y are"}
+ 8 "INSERT INTO t2 VALUES(0.0, 'zero')" {"columns x, y are"}
+ 9 "INSERT INTO t2 VALUES('brambles', 'two')" {"columns x, y are"}
+ 10 "INSERT INTO t2 VALUES(X'ABCDEF', 'three')" {"columns x, y are"}
+}
+do_createtable_tests 4.3.2 {
+ 1 "INSERT INTO t1 VALUES(-1, 0)" {}
+ 2 "INSERT INTO t1 VALUES(45.2, 'abc')" {}
+ 3 "INSERT INTO t1 VALUES(0.01, 'abc')" {}
+ 4 "INSERT INTO t1 VALUES('bramble', 'abc')" {}
+ 5 "INSERT INTO t1 VALUES(X'ABCDEE', 'abc')" {}
+
+ 6 "INSERT INTO t2 VALUES(0, 0)" {}
+ 7 "INSERT INTO t2 VALUES(45.5, 'abc')" {}
+ 8 "INSERT INTO t2 VALUES(0.0, 'abc')" {}
+ 9 "INSERT INTO t2 VALUES('brambles', 'abc')" {}
+ 10 "INSERT INTO t2 VALUES(X'ABCDEF', 'abc')" {}
+}
+do_createtable_tests 4.3.3 -error { %s not unique } {
+ 1 "UPDATE t1 SET x=0 WHERE y='two'" {"column x is"}
+ 2 "UPDATE t1 SET x='brambles' WHERE y='three'" {"column x is"}
+ 3 "UPDATE t1 SET x=45.5 WHERE y='zero'" {"column x is"}
+ 4 "UPDATE t1 SET x=X'ABCDEF' WHERE y='one'" {"column x is"}
+ 5 "UPDATE t1 SET x=0.0 WHERE y='three'" {"column x is"}
+
+ 6 "UPDATE t2 SET x=0, y='zero' WHERE y='two'" {"columns x, y are"}
+ 7 "UPDATE t2 SET x='brambles', y='two' WHERE y='three'"
+ {"columns x, y are"}
+ 8 "UPDATE t2 SET x=45.5, y='one' WHERE y='zero'" {"columns x, y are"}
+ 9 "UPDATE t2 SET x=X'ABCDEF', y='three' WHERE y='one'"
+ {"columns x, y are"}
+ 10 "UPDATE t2 SET x=0.0, y='zero' WHERE y='three'"
+ {"columns x, y are"}
+}
+
+
+# EVIDENCE-OF: R-52572-02078 For the purposes of determining the
+# uniqueness of primary key values, NULL values are considered distinct
+# from all other values, including other NULLs.
+#
+do_createtable_tests 4.4 {
+ 1 "INSERT INTO t1 VALUES(NULL, 0)" {}
+ 2 "INSERT INTO t1 VALUES(NULL, 0)" {}
+ 3 "INSERT INTO t1 VALUES(NULL, 0)" {}
+
+ 4 "INSERT INTO t2 VALUES(NULL, 'zero')" {}
+ 5 "INSERT INTO t2 VALUES(NULL, 'one')" {}
+ 6 "INSERT INTO t2 VALUES(NULL, 'two')" {}
+ 7 "INSERT INTO t2 VALUES(NULL, 'three')" {}
+
+ 8 "INSERT INTO t2 VALUES(0, NULL)" {}
+ 9 "INSERT INTO t2 VALUES(45.5, NULL)" {}
+ 10 "INSERT INTO t2 VALUES(0.0, NULL)" {}
+ 11 "INSERT INTO t2 VALUES('brambles', NULL)" {}
+ 12 "INSERT INTO t2 VALUES(X'ABCDEF', NULL)" {}
+
+ 13 "INSERT INTO t2 VALUES(NULL, NULL)" {}
+ 14 "INSERT INTO t2 VALUES(NULL, NULL)" {}
+}
+
+# EVIDENCE-OF: R-61866-38053 Unless the column is an INTEGER PRIMARY KEY
+# SQLite allows NULL values in a PRIMARY KEY column.
+#
+# If the column is an integer primary key, attempting to insert a NULL
+# into the column triggers the auto-increment behaviour. Attempting
+# to use UPDATE to set an ipk column to a NULL value is an error.
+#
+do_createtable_tests 4.5.1 {
+ 1 "SELECT count(*) FROM t1 WHERE x IS NULL" 3
+ 2 "SELECT count(*) FROM t2 WHERE x IS NULL" 6
+ 3 "SELECT count(*) FROM t2 WHERE y IS NULL" 7
+ 4 "SELECT count(*) FROM t2 WHERE x IS NULL AND y IS NULL" 2
+}
+do_execsql_test 4.5.2 {
+ CREATE TABLE t3(s, u INTEGER PRIMARY KEY, v);
+ INSERT INTO t3 VALUES(1, NULL, 2);
+ INSERT INTO t3 VALUES('x', NULL, 'y');
+ SELECT u FROM t3;
+} {1 2}
+do_catchsql_test 4.5.3 {
+ INSERT INTO t3 VALUES(2, 5, 3);
+ UPDATE t3 SET u = NULL WHERE s = 2;
+} {1 {datatype mismatch}}
+
+# EVIDENCE-OF: R-00227-21080 A UNIQUE constraint is similar to a PRIMARY
+# KEY constraint, except that a single table may have any number of
+# UNIQUE constraints.
+#
+drop_all_tables
+do_createtable_tests 4.6 {
+ 1 "CREATE TABLE t1(a UNIQUE, b UNIQUE)" {}
+ 2 "CREATE TABLE t2(a UNIQUE, b, c, UNIQUE(c, b))" {}
+ 3 "CREATE TABLE t3(a, b, c, UNIQUE(a), UNIQUE(b), UNIQUE(c))" {}
+ 4 "CREATE TABLE t4(a, b, c, UNIQUE(a, b, c))" {}
+}
+
+# EVIDENCE-OF: R-55240-58877 For each UNIQUE constraint on the table,
+# each row must feature a unique combination of values in the columns
+# identified by the UNIQUE constraint.
+#
+# EVIDENCE-OF: R-47733-51480 If an INSERT or UPDATE statement attempts
+# to modify the table content so that two or more rows feature identical
+# values in a set of columns that are subject to a UNIQUE constraint, it
+# is a constraint violation.
+#
+do_execsql_test 4.7.0 {
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(4.3, 5.5);
+ INSERT INTO t1 VALUES('reveal', 'variableness');
+ INSERT INTO t1 VALUES(X'123456', X'654321');
+
+ INSERT INTO t4 VALUES('xyx', 1, 1);
+ INSERT INTO t4 VALUES('xyx', 2, 1);
+ INSERT INTO t4 VALUES('uvw', 1, 1);
+}
+do_createtable_tests 4.7.1 -error { %s not unique } {
+ 1 "INSERT INTO t1 VALUES(1, 'one')" {{column a is}}
+ 2 "INSERT INTO t1 VALUES(4.3, 'two')" {{column a is}}
+ 3 "INSERT INTO t1 VALUES('reveal', 'three')" {{column a is}}
+ 4 "INSERT INTO t1 VALUES(X'123456', 'four')" {{column a is}}
+
+ 5 "UPDATE t1 SET a = 1 WHERE rowid=2" {{column a is}}
+ 6 "UPDATE t1 SET a = 4.3 WHERE rowid=3" {{column a is}}
+ 7 "UPDATE t1 SET a = 'reveal' WHERE rowid=4" {{column a is}}
+ 8 "UPDATE t1 SET a = X'123456' WHERE rowid=1" {{column a is}}
+
+ 9 "INSERT INTO t4 VALUES('xyx', 1, 1)" {{columns a, b, c are}}
+ 10 "INSERT INTO t4 VALUES('xyx', 2, 1)" {{columns a, b, c are}}
+ 11 "INSERT INTO t4 VALUES('uvw', 1, 1)" {{columns a, b, c are}}
+
+ 12 "UPDATE t4 SET a='xyx' WHERE rowid=3" {{columns a, b, c are}}
+ 13 "UPDATE t4 SET b=1 WHERE rowid=2" {{columns a, b, c are}}
+ 14 "UPDATE t4 SET a=0, b=0, c=0" {{columns a, b, c are}}
+}
+
+# EVIDENCE-OF: R-21289-11559 As with PRIMARY KEY constraints, for the
+# purposes of UNIQUE constraints NULL values are considered distinct
+# from all other values (including other NULLs).
+#
+do_createtable_tests 4.8 {
+ 1 "INSERT INTO t1 VALUES(NULL, NULL)" {}
+ 2 "INSERT INTO t1 VALUES(NULL, NULL)" {}
+ 3 "UPDATE t1 SET a = NULL" {}
+ 4 "UPDATE t1 SET b = NULL" {}
+
+ 5 "INSERT INTO t4 VALUES(NULL, NULL, NULL)" {}
+ 6 "INSERT INTO t4 VALUES(NULL, NULL, NULL)" {}
+ 7 "UPDATE t4 SET a = NULL" {}
+ 8 "UPDATE t4 SET b = NULL" {}
+ 9 "UPDATE t4 SET c = NULL" {}
+}
+
+# EVIDENCE-OF: R-26983-26377 INTEGER PRIMARY KEY columns aside, both
+# UNIQUE and PRIMARY KEY constraints are implemented by creating an
+# index in the database (in the same way as a "CREATE UNIQUE INDEX"
+# statement would).
+do_createtable_tests 4.9 -repair drop_all_tables -query {
+ SELECT count(*) FROM sqlite_master WHERE type='index'
+} {
+ 1 "CREATE TABLE t1(a TEXT PRIMARY KEY, b)" 1
+ 2 "CREATE TABLE t1(a INTEGER PRIMARY KEY, b)" 0
+ 3 "CREATE TABLE t1(a TEXT UNIQUE, b)" 1
+ 4 "CREATE TABLE t1(a PRIMARY KEY, b TEXT UNIQUE)" 2
+ 5 "CREATE TABLE t1(a PRIMARY KEY, b, c, UNIQUE(c, b))" 2
+}
+
+# EVIDENCE-OF: R-02252-33116 Such an index is used like any other index
+# in the database to optimize queries.
+#
+do_execsql_test 4.10.0 {
+ CREATE TABLE t1(a, b PRIMARY KEY);
+ CREATE TABLE t2(a, b, c, UNIQUE(b, c));
+}
+do_createtable_tests 4.10 {
+ 1 "EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b = 5"
+ {0 0 0 {SEARCH TABLE t1 USING INDEX sqlite_autoindex_t1_1 (b=?) (~1 rows)}}
+
+ 2 "EXPLAIN QUERY PLAN SELECT * FROM t2 ORDER BY b, c"
+ {0 0 0 {SCAN TABLE t2 USING INDEX sqlite_autoindex_t2_1 (~1000000 rows)}}
+
+ 3 "EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE b=10 AND c>10"
+ {0 0 0 {SEARCH TABLE t2 USING INDEX sqlite_autoindex_t2_1 (b=? AND c>?) (~2 rows)}}
+}
+
+# EVIDENCE-OF: R-45493-35653 A CHECK constraint may be attached to a
+# column definition or specified as a table constraint. In practice it
+# makes no difference.
+#
+# All the tests that deal with CHECK constraints below (4.11.* and
+# 4.12.*) are run once for a table with the check constraint attached
+# to a column definition, and once with a table where the check
+# condition is specified as a table constraint.
+#
+# EVIDENCE-OF: R-55435-14303 Each time a new row is inserted into the
+# table or an existing row is updated, the expression associated with
+# each CHECK constraint is evaluated and cast to a NUMERIC value in the
+# same way as a CAST expression. If the result is zero (integer value 0
+# or real value 0.0), then a constraint violation has occurred.
+#
+drop_all_tables
+do_execsql_test 4.11 {
+ CREATE TABLE x1(a TEXT, b INTEGER CHECK( b>0 ));
+ CREATE TABLE t1(a TEXT, b INTEGER, CHECK( b>0 ));
+ INSERT INTO x1 VALUES('x', 'xx');
+ INSERT INTO x1 VALUES('y', 'yy');
+ INSERT INTO t1 SELECT * FROM x1;
+
+ CREATE TABLE x2(a CHECK( a||b ), b);
+ CREATE TABLE t2(a, b, CHECK( a||b ));
+ INSERT INTO x2 VALUES(1, 'xx');
+ INSERT INTO x2 VALUES(1, 'yy');
+ INSERT INTO t2 SELECT * FROM x2;
+}
+
+do_createtable_tests 4.11 -error {constraint failed} {
+ 1a "INSERT INTO x1 VALUES('one', 0)" {}
+ 1b "INSERT INTO t1 VALUES('one', -4.0)" {}
+
+ 2a "INSERT INTO x2 VALUES('abc', 1)" {}
+ 2b "INSERT INTO t2 VALUES('abc', 1)" {}
+
+ 3a "INSERT INTO x2 VALUES(0, 'abc')" {}
+ 3b "INSERT INTO t2 VALUES(0, 'abc')" {}
+
+ 4a "UPDATE t1 SET b=-1 WHERE rowid=1" {}
+ 4b "UPDATE x1 SET b=-1 WHERE rowid=1" {}
+
+ 4a "UPDATE x2 SET a='' WHERE rowid=1" {}
+ 4b "UPDATE t2 SET a='' WHERE rowid=1" {}
+}
+
+# EVIDENCE-OF: R-34109-39108 If the CHECK expression evaluates to NULL,
+# or any other non-zero value, it is not a constraint violation.
+#
+do_createtable_tests 4.12 {
+ 1a "INSERT INTO x1 VALUES('one', NULL)" {}
+ 1b "INSERT INTO t1 VALUES('one', NULL)" {}
+
+ 2a "INSERT INTO x1 VALUES('one', 2)" {}
+ 2b "INSERT INTO t1 VALUES('one', 2)" {}
+
+ 3a "INSERT INTO x2 VALUES(1, 'abc')" {}
+ 3b "INSERT INTO t2 VALUES(1, 'abc')" {}
+}
+
+# EVIDENCE-OF: R-02060-64547 A NOT NULL constraint may only be attached
+# to a column definition, not specified as a table constraint.
+#
+drop_all_tables
+do_createtable_tests 4.13.1 {
+ 1 "CREATE TABLE t1(a NOT NULL, b)" {}
+ 2 "CREATE TABLE t2(a PRIMARY KEY NOT NULL, b)" {}
+ 3 "CREATE TABLE t3(a NOT NULL, b NOT NULL, c NOT NULL UNIQUE)" {}
+}
+do_createtable_tests 4.13.2 -error {
+ near "NOT": syntax error
+} {
+ 1 "CREATE TABLE t4(a, b, NOT NULL(a))" {}
+ 2 "CREATE TABLE t4(a PRIMARY KEY, b, NOT NULL(a))" {}
+ 3 "CREATE TABLE t4(a, b, c UNIQUE, NOT NULL(a, b, c))" {}
+}
+
+# EVIDENCE-OF: R-31795-57643 a NOT NULL constraint dictates that the
+# associated column may not contain a NULL value. Attempting to set the
+# column value to NULL when inserting a new row or updating an existing
+# one causes a constraint violation.
+#
+# These tests use the tables created by 4.13.
+#
+do_execsql_test 4.14.0 {
+ INSERT INTO t1 VALUES('x', 'y');
+ INSERT INTO t1 VALUES('z', NULL);
+
+ INSERT INTO t2 VALUES('x', 'y');
+ INSERT INTO t2 VALUES('z', NULL);
+
+ INSERT INTO t3 VALUES('x', 'y', 'z');
+ INSERT INTO t3 VALUES(1, 2, 3);
+}
+do_createtable_tests 4.14 -error {
+ %s may not be NULL
+} {
+ 1 "INSERT INTO t1 VALUES(NULL, 'a')" {t1.a}
+ 2 "INSERT INTO t2 VALUES(NULL, 'b')" {t2.a}
+ 3 "INSERT INTO t3 VALUES('c', 'd', NULL)" {t3.c}
+ 4 "INSERT INTO t3 VALUES('e', NULL, 'f')" {t3.b}
+ 5 "INSERT INTO t3 VALUES(NULL, 'g', 'h')" {t3.a}
+}
+
+# EVIDENCE-OF: R-42511-39459 PRIMARY KEY, UNIQUE and NOT NULL
+# constraints may be explicitly assigned a default conflict resolution
+# algorithm by including a conflict-clause in their definitions.
+#
+# Conflict clauses: ABORT, ROLLBACK, IGNORE, FAIL, REPLACE
+#
+# Test cases 4.15.*, 4.16.* and 4.17.* focus on PRIMARY KEY, NOT NULL
+# and UNIQUE constraints, respectively.
+#
+drop_all_tables
+do_execsql_test 4.15.0 {
+ CREATE TABLE t1_ab(a PRIMARY KEY ON CONFLICT ABORT, b);
+ CREATE TABLE t1_ro(a PRIMARY KEY ON CONFLICT ROLLBACK, b);
+ CREATE TABLE t1_ig(a PRIMARY KEY ON CONFLICT IGNORE, b);
+ CREATE TABLE t1_fa(a PRIMARY KEY ON CONFLICT FAIL, b);
+ CREATE TABLE t1_re(a PRIMARY KEY ON CONFLICT REPLACE, b);
+ CREATE TABLE t1_xx(a PRIMARY KEY, b);
+
+ INSERT INTO t1_ab VALUES(1, 'one');
+ INSERT INTO t1_ab VALUES(2, 'two');
+ INSERT INTO t1_ro SELECT * FROM t1_ab;
+ INSERT INTO t1_ig SELECT * FROM t1_ab;
+ INSERT INTO t1_fa SELECT * FROM t1_ab;
+ INSERT INTO t1_re SELECT * FROM t1_ab;
+ INSERT INTO t1_xx SELECT * FROM t1_ab;
+
+ CREATE TABLE t2_ab(a, b NOT NULL ON CONFLICT ABORT);
+ CREATE TABLE t2_ro(a, b NOT NULL ON CONFLICT ROLLBACK);
+ CREATE TABLE t2_ig(a, b NOT NULL ON CONFLICT IGNORE);
+ CREATE TABLE t2_fa(a, b NOT NULL ON CONFLICT FAIL);
+ CREATE TABLE t2_re(a, b NOT NULL ON CONFLICT REPLACE);
+ CREATE TABLE t2_xx(a, b NOT NULL);
+
+ INSERT INTO t2_ab VALUES(1, 'one');
+ INSERT INTO t2_ab VALUES(2, 'two');
+ INSERT INTO t2_ro SELECT * FROM t2_ab;
+ INSERT INTO t2_ig SELECT * FROM t2_ab;
+ INSERT INTO t2_fa SELECT * FROM t2_ab;
+ INSERT INTO t2_re SELECT * FROM t2_ab;
+ INSERT INTO t2_xx SELECT * FROM t2_ab;
+
+ CREATE TABLE t3_ab(a, b, UNIQUE(a, b) ON CONFLICT ABORT);
+ CREATE TABLE t3_ro(a, b, UNIQUE(a, b) ON CONFLICT ROLLBACK);
+ CREATE TABLE t3_ig(a, b, UNIQUE(a, b) ON CONFLICT IGNORE);
+ CREATE TABLE t3_fa(a, b, UNIQUE(a, b) ON CONFLICT FAIL);
+ CREATE TABLE t3_re(a, b, UNIQUE(a, b) ON CONFLICT REPLACE);
+ CREATE TABLE t3_xx(a, b, UNIQUE(a, b));
+
+ INSERT INTO t3_ab VALUES(1, 'one');
+ INSERT INTO t3_ab VALUES(2, 'two');
+ INSERT INTO t3_ro SELECT * FROM t3_ab;
+ INSERT INTO t3_ig SELECT * FROM t3_ab;
+ INSERT INTO t3_fa SELECT * FROM t3_ab;
+ INSERT INTO t3_re SELECT * FROM t3_ab;
+ INSERT INTO t3_xx SELECT * FROM t3_ab;
+}
+
+foreach {tn tbl res ac data} {
+ 1 t1_ab {1 {column a is not unique}} 0 {1 one 2 two 3 three}
+ 2 t1_ro {1 {column a is not unique}} 1 {1 one 2 two}
+ 3 t1_fa {1 {column a is not unique}} 0 {1 one 2 two 3 three 4 string}
+ 4 t1_ig {0 {}} 0 {1 one 2 two 3 three 4 string 6 string}
+ 5 t1_re {0 {}} 0 {1 one 2 two 4 string 3 string 6 string}
+ 6 t1_xx {1 {column a is not unique}} 0 {1 one 2 two 3 three}
+} {
+ catchsql COMMIT
+ do_execsql_test 4.15.$tn.1 "BEGIN; INSERT INTO $tbl VALUES(3, 'three')"
+
+ do_catchsql_test 4.15.$tn.2 "
+ INSERT INTO $tbl SELECT ((a%2)*a+3), 'string' FROM $tbl;
+ " $res
+
+ do_test e_createtable-4.15.$tn.3 { sqlite3_get_autocommit db } $ac
+ do_execsql_test 4.15.$tn.4 "SELECT * FROM $tbl" $data
+}
+foreach {tn tbl res ac data} {
+ 1 t2_ab {1 {t2_ab.b may not be NULL}} 0 {1 one 2 two 3 three}
+ 2 t2_ro {1 {t2_ro.b may not be NULL}} 1 {1 one 2 two}
+ 3 t2_fa {1 {t2_fa.b may not be NULL}} 0 {1 one 2 two 3 three 4 xx}
+ 4 t2_ig {0 {}} 0 {1 one 2 two 3 three 4 xx 6 xx}
+ 5 t2_re {1 {t2_re.b may not be NULL}} 0 {1 one 2 two 3 three}
+ 6 t2_xx {1 {t2_xx.b may not be NULL}} 0 {1 one 2 two 3 three}
+} {
+ catchsql COMMIT
+ do_execsql_test 4.16.$tn.1 "BEGIN; INSERT INTO $tbl VALUES(3, 'three')"
+
+ do_catchsql_test 4.16.$tn.2 "
+ INSERT INTO $tbl SELECT a+3, CASE a WHEN 2 THEN NULL ELSE 'xx' END FROM $tbl
+ " $res
+
+ do_test e_createtable-4.16.$tn.3 { sqlite3_get_autocommit db } $ac
+ do_execsql_test 4.16.$tn.4 "SELECT * FROM $tbl" $data
+}
+foreach {tn tbl res ac data} {
+ 1 t3_ab {1 {columns a, b are not unique}} 0 {1 one 2 two 3 three}
+ 2 t3_ro {1 {columns a, b are not unique}} 1 {1 one 2 two}
+ 3 t3_fa {1 {columns a, b are not unique}} 0 {1 one 2 two 3 three 4 three}
+ 4 t3_ig {0 {}} 0 {1 one 2 two 3 three 4 three 6 three}
+ 5 t3_re {0 {}} 0 {1 one 2 two 4 three 3 three 6 three}
+ 6 t3_xx {1 {columns a, b are not unique}} 0 {1 one 2 two 3 three}
+} {
+ catchsql COMMIT
+ do_execsql_test 4.17.$tn.1 "BEGIN; INSERT INTO $tbl VALUES(3, 'three')"
+
+ do_catchsql_test 4.17.$tn.2 "
+ INSERT INTO $tbl SELECT ((a%2)*a+3), 'three' FROM $tbl
+ " $res
+
+ do_test e_createtable-4.17.$tn.3 { sqlite3_get_autocommit db } $ac
+ do_execsql_test 4.17.$tn.4 "SELECT * FROM $tbl" $data
+}
+catchsql COMMIT
+
+# EVIDENCE-OF: R-12645-39772 Or, if a constraint definition does not
+# include a conflict-clause or it is a CHECK constraint, the default
+# conflict resolution algorithm is ABORT.
+#
+# The first half of the above is tested along with explicit ON
+# CONFLICT clauses above (specifically, the tests involving t1_xx, t2_xx
+# and t3_xx). The following just tests that the default conflict
+# handling for CHECK constraints is ABORT.
+#
+do_execsql_test 4.18.1 {
+ CREATE TABLE t4(a, b CHECK (b!=10));
+ INSERT INTO t4 VALUES(1, 2);
+ INSERT INTO t4 VALUES(3, 4);
+}
+do_execsql_test 4.18.2 { BEGIN; INSERT INTO t4 VALUES(5, 6) }
+do_catchsql_test 4.18.3 {
+ INSERT INTO t4 SELECT a+4, b+4 FROM t4
+} {1 {constraint failed}}
+do_test e_createtable-4.18.4 { sqlite3_get_autocommit db } 0
+do_execsql_test 4.18.5 { SELECT * FROM t4 } {1 2 3 4 5 6}
+
+# EVIDENCE-OF: R-19114-56113 Different constraints within the same table
+# may have different default conflict resolution algorithms.
+#
+do_execsql_test 4.19.0 {
+ CREATE TABLE t5(a NOT NULL ON CONFLICT IGNORE, b NOT NULL ON CONFLICT ABORT);
+}
+do_catchsql_test 4.19.1 { INSERT INTO t5 VALUES(NULL, 'not null') } {0 {}}
+do_execsql_test 4.19.2 { SELECT * FROM t5 } {}
+do_catchsql_test 4.19.3 { INSERT INTO t5 VALUES('not null', NULL) } \
+ {1 {t5.b may not be NULL}}
+do_execsql_test 4.19.4 { SELECT * FROM t5 } {}
+
+#------------------------------------------------------------------------
+# Tests for INTEGER PRIMARY KEY and rowid related statements.
+#
+
+# EVIDENCE-OF: R-52584-04009 The rowid value can be accessed using one
+# of the special case-independent names "rowid", "oid", or "_rowid_" in
+# place of a column name.
+#
+drop_all_tables
+do_execsql_test 5.1.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES('one', 'first');
+ INSERT INTO t1 VALUES('two', 'second');
+ INSERT INTO t1 VALUES('three', 'third');
+}
+do_createtable_tests 5.1 {
+ 1 "SELECT rowid FROM t1" {1 2 3}
+ 2 "SELECT oid FROM t1" {1 2 3}
+ 3 "SELECT _rowid_ FROM t1" {1 2 3}
+ 4 "SELECT ROWID FROM t1" {1 2 3}
+ 5 "SELECT OID FROM t1" {1 2 3}
+ 6 "SELECT _ROWID_ FROM t1" {1 2 3}
+ 7 "SELECT RoWiD FROM t1" {1 2 3}
+ 8 "SELECT OiD FROM t1" {1 2 3}
+ 9 "SELECT _RoWiD_ FROM t1" {1 2 3}
+}
+
+# EVIDENCE-OF: R-26501-17306 If a table contains a user defined column
+# named "rowid", "oid" or "_rowid_", then that name always refers the
+# explicitly declared column and cannot be used to retrieve the integer
+# rowid value.
+#
+do_execsql_test 5.2.0 {
+ CREATE TABLE t2(oid, b);
+ CREATE TABLE t3(a, _rowid_);
+ CREATE TABLE t4(a, b, rowid);
+
+ INSERT INTO t2 VALUES('one', 'two');
+ INSERT INTO t2 VALUES('three', 'four');
+
+ INSERT INTO t3 VALUES('five', 'six');
+ INSERT INTO t3 VALUES('seven', 'eight');
+
+ INSERT INTO t4 VALUES('nine', 'ten', 'eleven');
+ INSERT INTO t4 VALUES('twelve', 'thirteen', 'fourteen');
+}
+do_createtable_tests 5.2 {
+ 1 "SELECT oid, rowid, _rowid_ FROM t2" {one 1 1 three 2 2}
+ 2 "SELECT oid, rowid, _rowid_ FROM t3" {1 1 six 2 2 eight}
+ 3 "SELECT oid, rowid, _rowid_ FROM t4" {1 eleven 1 2 fourteen 2}
+}
+
+
+# Argument $tbl is the name of a table in the database. Argument $col is
+# the name of one of the tables columns. Return 1 if $col is an alias for
+# the rowid, or 0 otherwise.
+#
+proc is_integer_primary_key {tbl col} {
+ lindex [db eval [subst {
+ DELETE FROM $tbl;
+ INSERT INTO $tbl ($col) VALUES(0);
+ SELECT (rowid==$col) FROM $tbl;
+ DELETE FROM $tbl;
+ }]] 0
+}
+
+# EVIDENCE-OF: R-53738-31673 With one exception, if a table has a
+# primary key that consists of a single column, and the declared type of
+# that column is "INTEGER" in any mixture of upper and lower case, then
+# the column becomes an alias for the rowid.
+#
+# EVIDENCE-OF: R-45951-08347 if the declaration of a column with
+# declared type "INTEGER" includes an "PRIMARY KEY DESC" clause, it does
+# not become an alias for the rowid and is not classified as an integer
+# primary key.
+#
+do_createtable_tests 5.3 -tclquery {
+ is_integer_primary_key t5 pk
+} -repair {
+ catchsql { DROP TABLE t5 }
+} {
+ 1 "CREATE TABLE t5(pk integer primary key)" 1
+ 2 "CREATE TABLE t5(pk integer, primary key(pk))" 1
+ 3 "CREATE TABLE t5(pk integer, v integer, primary key(pk))" 1
+ 4 "CREATE TABLE t5(pk integer, v integer, primary key(pk, v))" 0
+ 5 "CREATE TABLE t5(pk int, v integer, primary key(pk, v))" 0
+ 6 "CREATE TABLE t5(pk int, v integer, primary key(pk))" 0
+ 7 "CREATE TABLE t5(pk int primary key, v integer)" 0
+ 8 "CREATE TABLE t5(pk inTEger primary key)" 1
+ 9 "CREATE TABLE t5(pk inteGEr, primary key(pk))" 1
+ 10 "CREATE TABLE t5(pk INTEGER, v integer, primary key(pk))" 1
+}
+
+# EVIDENCE-OF: R-41444-49665 Other integer type names like "INT" or
+# "BIGINT" or "SHORT INTEGER" or "UNSIGNED INTEGER" causes the primary
+# key column to behave as an ordinary table column with integer affinity
+# and a unique index, not as an alias for the rowid.
+#
+do_execsql_test 5.4.1 {
+ CREATE TABLE t6(pk INT primary key);
+ CREATE TABLE t7(pk BIGINT primary key);
+ CREATE TABLE t8(pk SHORT INTEGER primary key);
+ CREATE TABLE t9(pk UNSIGNED INTEGER primary key);
+}
+do_test e_createtable-5.4.2.1 { is_integer_primary_key t6 pk } 0
+do_test e_createtable-5.4.2.2 { is_integer_primary_key t7 pk } 0
+do_test e_createtable-5.4.2.3 { is_integer_primary_key t8 pk } 0
+do_test e_createtable-5.4.2.4 { is_integer_primary_key t9 pk } 0
+
+do_execsql_test 5.4.3 {
+ INSERT INTO t6 VALUES('2.0');
+ INSERT INTO t7 VALUES('2.0');
+ INSERT INTO t8 VALUES('2.0');
+ INSERT INTO t9 VALUES('2.0');
+ SELECT typeof(pk), pk FROM t6;
+ SELECT typeof(pk), pk FROM t7;
+ SELECT typeof(pk), pk FROM t8;
+ SELECT typeof(pk), pk FROM t9;
+} {integer 2 integer 2 integer 2 integer 2}
+
+do_catchsql_test 5.4.4.1 {
+ INSERT INTO t6 VALUES(2)
+} {1 {column pk is not unique}}
+do_catchsql_test 5.4.4.2 {
+ INSERT INTO t7 VALUES(2)
+} {1 {column pk is not unique}}
+do_catchsql_test 5.4.4.3 {
+ INSERT INTO t8 VALUES(2)
+} {1 {column pk is not unique}}
+do_catchsql_test 5.4.4.4 {
+ INSERT INTO t9 VALUES(2)
+} {1 {column pk is not unique}}
+
+# EVIDENCE-OF: R-56094-57830 the following three table declarations all
+# cause the column "x" to be an alias for the rowid (an integer primary
+# key): CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z); CREATE TABLE
+# t(x INTEGER, y, z, PRIMARY KEY(x ASC)); CREATE TABLE t(x INTEGER, y,
+# z, PRIMARY KEY(x DESC));
+#
+# EVIDENCE-OF: R-20149-25884 the following declaration does not result
+# in "x" being an alias for the rowid: CREATE TABLE t(x INTEGER PRIMARY
+# KEY DESC, y, z);
+#
+do_createtable_tests 5 -tclquery {
+ is_integer_primary_key t x
+} -repair {
+ catchsql { DROP TABLE t }
+} {
+ 5.1 "CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z)" 1
+ 5.2 "CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x ASC))" 1
+ 5.3 "CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x DESC))" 1
+ 6.1 "CREATE TABLE t(x INTEGER PRIMARY KEY DESC, y, z)" 0
+}
+
+# EVIDENCE-OF: R-03733-29734 Rowid values may be modified using an
+# UPDATE statement in the same way as any other column value can, either
+# using one of the built-in aliases ("rowid", "oid" or "_rowid_") or by
+# using an alias created by an integer primary key.
+#
+do_execsql_test 5.7.0 {
+ CREATE TABLE t10(a, b);
+ INSERT INTO t10 VALUES('ten', 10);
+
+ CREATE TABLE t11(a, b INTEGER PRIMARY KEY);
+ INSERT INTO t11 VALUES('ten', 10);
+}
+do_createtable_tests 5.7.1 -query {
+ SELECT rowid, _rowid_, oid FROM t10;
+} {
+ 1 "UPDATE t10 SET rowid = 5" {5 5 5}
+ 2 "UPDATE t10 SET _rowid_ = 6" {6 6 6}
+ 3 "UPDATE t10 SET oid = 7" {7 7 7}
+}
+do_createtable_tests 5.7.2 -query {
+ SELECT rowid, _rowid_, oid, b FROM t11;
+} {
+ 1 "UPDATE t11 SET rowid = 5" {5 5 5 5}
+ 2 "UPDATE t11 SET _rowid_ = 6" {6 6 6 6}
+ 3 "UPDATE t11 SET oid = 7" {7 7 7 7}
+ 4 "UPDATE t11 SET b = 8" {8 8 8 8}
+}
+
+# EVIDENCE-OF: R-58706-14229 Similarly, an INSERT statement may provide
+# a value to use as the rowid for each row inserted.
+#
+do_createtable_tests 5.8.1 -query {
+ SELECT rowid, _rowid_, oid FROM t10;
+} -repair {
+ execsql { DELETE FROM t10 }
+} {
+ 1 "INSERT INTO t10(oid) VALUES(15)" {15 15 15}
+ 2 "INSERT INTO t10(rowid) VALUES(16)" {16 16 16}
+ 3 "INSERT INTO t10(_rowid_) VALUES(17)" {17 17 17}
+ 4 "INSERT INTO t10(a, b, oid) VALUES(1,2,3)" {3 3 3}
+}
+do_createtable_tests 5.8.2 -query {
+ SELECT rowid, _rowid_, oid, b FROM t11;
+} -repair {
+ execsql { DELETE FROM t11 }
+} {
+ 1 "INSERT INTO t11(oid) VALUES(15)" {15 15 15 15}
+ 2 "INSERT INTO t11(rowid) VALUES(16)" {16 16 16 16}
+ 3 "INSERT INTO t11(_rowid_) VALUES(17)" {17 17 17 17}
+ 4 "INSERT INTO t11(a, b) VALUES(1,2)" {2 2 2 2}
+}
+
+# EVIDENCE-OF: R-32326-44592 Unlike normal SQLite columns, an integer
+# primary key or rowid column must contain integer values. Integer
+# primary key or rowid columns are not able to hold floating point
+# values, strings, BLOBs, or NULLs.
+#
+# This is considered by the tests for the following 3 statements,
+# which show that:
+#
+# 1. Attempts to UPDATE a rowid column to a non-integer value fail,
+# 2. Attempts to INSERT a real, string or blob value into a rowid
+# column fail, and
+# 3. Attempting to INSERT a NULL value into a rowid column causes the
+# system to automatically select an integer value to use.
+#
+
+
+# EVIDENCE-OF: R-64224-62578 If an UPDATE statement attempts to set an
+# integer primary key or rowid column to a NULL or blob value, or to a
+# string or real value that cannot be losslessly converted to an
+# integer, a "datatype mismatch" error occurs and the statement is
+# aborted.
+#
+drop_all_tables
+do_execsql_test 5.9.0 {
+ CREATE TABLE t12(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t12 VALUES(5, 'five');
+}
+do_createtable_tests 5.9.1 -query { SELECT typeof(x), x FROM t12 } {
+ 1 "UPDATE t12 SET x = 4" {integer 4}
+ 2 "UPDATE t12 SET x = 10.0" {integer 10}
+ 3 "UPDATE t12 SET x = '12.0'" {integer 12}
+ 4 "UPDATE t12 SET x = '-15.0'" {integer -15}
+}
+do_createtable_tests 5.9.2 -error {
+ datatype mismatch
+} {
+ 1 "UPDATE t12 SET x = 4.1" {}
+ 2 "UPDATE t12 SET x = 'hello'" {}
+ 3 "UPDATE t12 SET x = NULL" {}
+ 4 "UPDATE t12 SET x = X'ABCD'" {}
+ 5 "UPDATE t12 SET x = X'3900'" {}
+ 6 "UPDATE t12 SET x = X'39'" {}
+}
+
+# EVIDENCE-OF: R-05734-13629 If an INSERT statement attempts to insert a
+# blob value, or a string or real value that cannot be losslessly
+# converted to an integer into an integer primary key or rowid column, a
+# "datatype mismatch" error occurs and the statement is aborted.
+#
+do_execsql_test 5.10.0 { DELETE FROM t12 }
+do_createtable_tests 5.10.1 -error {
+ datatype mismatch
+} {
+ 1 "INSERT INTO t12(x) VALUES(4.1)" {}
+ 2 "INSERT INTO t12(x) VALUES('hello')" {}
+ 3 "INSERT INTO t12(x) VALUES(X'ABCD')" {}
+ 4 "INSERT INTO t12(x) VALUES(X'3900')" {}
+ 5 "INSERT INTO t12(x) VALUES(X'39')" {}
+}
+do_createtable_tests 5.10.2 -query {
+ SELECT typeof(x), x FROM t12
+} -repair {
+ execsql { DELETE FROM t12 }
+} {
+ 1 "INSERT INTO t12(x) VALUES(4)" {integer 4}
+ 2 "INSERT INTO t12(x) VALUES(10.0)" {integer 10}
+ 3 "INSERT INTO t12(x) VALUES('12.0')" {integer 12}
+ 4 "INSERT INTO t12(x) VALUES('4e3')" {integer 4000}
+ 5 "INSERT INTO t12(x) VALUES('-14.0')" {integer -14}
+}
+
+# EVIDENCE-OF: R-07986-46024 If an INSERT statement attempts to insert a
+# NULL value into a rowid or integer primary key column, the system
+# chooses an integer value to use as the rowid automatically.
+#
+do_execsql_test 5.11.0 { DELETE FROM t12 }
+do_createtable_tests 5.11 -query {
+ SELECT typeof(x), x FROM t12 WHERE y IS (SELECT max(y) FROM t12)
+} {
+ 1 "INSERT INTO t12 DEFAULT VALUES" {integer 1}
+ 2 "INSERT INTO t12(y) VALUES(5)" {integer 2}
+ 3 "INSERT INTO t12(x,y) VALUES(NULL, 10)" {integer 3}
+ 4 "INSERT INTO t12(x,y) SELECT NULL, 15 FROM t12"
+ {integer 4 integer 5 integer 6}
+ 5 "INSERT INTO t12(y) SELECT 20 FROM t12 LIMIT 3"
+ {integer 7 integer 8 integer 9}
+}
+
+finish_test
diff --git a/test/e_delete.test b/test/e_delete.test
new file mode 100644
index 0000000..c77d444
--- /dev/null
+++ b/test/e_delete.test
@@ -0,0 +1,470 @@
+# 2010 September 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_delete.html document are correct.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc do_delete_tests {args} {
+ uplevel do_select_tests $args
+}
+
+do_execsql_test e_delete-0.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+} {}
+
+# EVIDENCE-OF: R-24177-52883 -- syntax diagram delete-stmt
+#
+# EVIDENCE-OF: R-12802-60464 -- syntax diagram qualified-table-name
+#
+do_delete_tests e_delete-0.1 {
+ 1 "DELETE FROM t1" {}
+ 2 "DELETE FROM t1 INDEXED BY i1" {}
+ 3 "DELETE FROM t1 NOT INDEXED" {}
+ 4 "DELETE FROM main.t1" {}
+ 5 "DELETE FROM main.t1 INDEXED BY i1" {}
+ 6 "DELETE FROM main.t1 NOT INDEXED" {}
+ 7 "DELETE FROM t1 WHERE a>2" {}
+ 8 "DELETE FROM t1 INDEXED BY i1 WHERE a>2" {}
+ 9 "DELETE FROM t1 NOT INDEXED WHERE a>2" {}
+ 10 "DELETE FROM main.t1 WHERE a>2" {}
+ 11 "DELETE FROM main.t1 INDEXED BY i1 WHERE a>2" {}
+ 12 "DELETE FROM main.t1 NOT INDEXED WHERE a>2" {}
+}
+
+# EVIDENCE-OF: R-20205-17349 If the WHERE clause is not present, all
+# records in the table are deleted.
+#
+drop_all_tables
+do_test e_delete-1.0 {
+ db transaction {
+ foreach t {t1 t2 t3 t4 t5 t6} {
+ execsql [string map [list %T% $t] {
+ CREATE TABLE %T%(x, y);
+ INSERT INTO %T% VALUES(1, 'one');
+ INSERT INTO %T% VALUES(2, 'two');
+ INSERT INTO %T% VALUES(3, 'three');
+ INSERT INTO %T% VALUES(4, 'four');
+ INSERT INTO %T% VALUES(5, 'five');
+ }]
+ }
+ }
+} {}
+do_delete_tests e_delete-1.1 {
+ 1 "DELETE FROM t1 ; SELECT * FROM t1" {}
+ 2 "DELETE FROM main.t2 ; SELECT * FROM t2" {}
+}
+
+# EVIDENCE-OF: R-30203-16177 If a WHERE clause is supplied, then only
+# those rows for which the result of evaluating the WHERE clause as a
+# boolean expression is true are deleted.
+#
+do_delete_tests e_delete-1.2 {
+ 1 "DELETE FROM t3 WHERE 1 ; SELECT x FROM t3" {}
+ 2 "DELETE FROM main.t4 WHERE 0 ; SELECT x FROM t4" {1 2 3 4 5}
+ 3 "DELETE FROM t4 WHERE 0.0 ; SELECT x FROM t4" {1 2 3 4 5}
+ 4 "DELETE FROM t4 WHERE NULL ; SELECT x FROM t4" {1 2 3 4 5}
+ 5 "DELETE FROM t4 WHERE y!='two'; SELECT x FROM t4" {2}
+ 6 "DELETE FROM t4 WHERE y='two' ; SELECT x FROM t4" {}
+ 7 "DELETE FROM t5 WHERE x=(SELECT max(x) FROM t5);SELECT x FROM t5" {1 2 3 4}
+ 8 "DELETE FROM t5 WHERE (SELECT max(x) FROM t4) ;SELECT x FROM t5" {1 2 3 4}
+ 9 "DELETE FROM t5 WHERE (SELECT max(x) FROM t6) ;SELECT x FROM t5" {}
+ 10 "DELETE FROM t6 WHERE y>'seven' ; SELECT y FROM t6" {one four five}
+}
+
+
+#-------------------------------------------------------------------------
+# Tests for restrictions on DELETE statements that appear within trigger
+# programs.
+#
+forcedelete test.db2
+forcedelete test.db3
+do_execsql_test e_delete-2.0 {
+ ATTACH 'test.db2' AS aux;
+ ATTACH 'test.db3' AS aux2;
+
+ CREATE TABLE temp.t7(a, b); INSERT INTO temp.t7 VALUES(1, 2);
+ CREATE TABLE main.t7(a, b); INSERT INTO main.t7 VALUES(3, 4);
+ CREATE TABLE aux.t7(a, b); INSERT INTO aux.t7 VALUES(5, 6);
+ CREATE TABLE aux2.t7(a, b); INSERT INTO aux2.t7 VALUES(7, 8);
+
+ CREATE TABLE main.t8(a, b); INSERT INTO main.t8 VALUES(1, 2);
+ CREATE TABLE aux.t8(a, b); INSERT INTO aux.t8 VALUES(3, 4);
+ CREATE TABLE aux2.t8(a, b); INSERT INTO aux2.t8 VALUES(5, 6);
+
+ CREATE TABLE aux.t9(a, b); INSERT INTO aux.t9 VALUES(1, 2);
+ CREATE TABLE aux2.t9(a, b); INSERT INTO aux2.t9 VALUES(3, 4);
+
+ CREATE TABLE aux2.t10(a, b); INSERT INTO aux2.t10 VALUES(1, 2);
+} {}
+
+
+# EVIDENCE-OF: R-09681-58560 The table-name specified as part of a
+# DELETE statement within a trigger body must be unqualified.
+#
+# EVIDENCE-OF: R-36771-43788 In other words, the database-name. prefix
+# on the table name is not allowed within triggers.
+#
+do_delete_tests e_delete-2.1 -error {
+ qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers
+} {
+ 1 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ DELETE FROM main.t2;
+ END;
+ } {}
+
+ 2 {
+ CREATE TRIGGER tr1 BEFORE UPDATE ON t2 BEGIN
+ DELETE FROM temp.t7 WHERE a=new.a;
+ END;
+ } {}
+
+ 3 {
+ CREATE TRIGGER tr1 AFTER UPDATE ON t8 BEGIN
+ DELETE FROM aux2.t8 WHERE b!=a;
+ END;
+ } {}
+}
+
+# EVIDENCE-OF: R-28818-63526 If the table to which the trigger is
+# attached is not in the temp database, then DELETE statements within
+# the trigger body must operate on tables within the same database as
+# it.
+#
+# This is tested in two parts. First, check that if a table of the
+# specified name does not exist, an error is raised. Secondly, test
+# that if tables with the specified name exist in multiple databases,
+# the local database table is used.
+#
+do_delete_tests e_delete-2.2.1 -error { no such table: %s } {
+ 1 {
+ CREATE TRIGGER main.tr1 AFTER INSERT ON main.t7 BEGIN
+ DELETE FROM t9;
+ END;
+ INSERT INTO main.t7 VALUES(1, 2);
+ } {main.t9}
+
+ 2 {
+ CREATE TRIGGER aux.tr2 BEFORE UPDATE ON t9 BEGIN
+ DELETE FROM t10;
+ END;
+ UPDATE t9 SET a=1;
+ } {aux.t10}
+}
+do_execsql_test e_delete-2.2.X {
+ DROP TRIGGER main.tr1;
+ DROP TRIGGER aux.tr2;
+} {}
+
+do_delete_tests e_delete-2.2.2 {
+ 1 {
+ CREATE TRIGGER aux.tr1 AFTER INSERT ON t8 BEGIN
+ DELETE FROM t9;
+ END;
+ INSERT INTO aux.t8 VALUES(1, 2);
+
+ SELECT count(*) FROM aux.t9
+ UNION ALL
+ SELECT count(*) FROM aux2.t9;
+ } {0 1}
+
+ 2 {
+ CREATE TRIGGER main.tr1 AFTER INSERT ON t8 BEGIN
+ DELETE FROM t7;
+ END;
+ INSERT INTO main.t8 VALUES(1, 2);
+
+ SELECT count(*) FROM temp.t7
+ UNION ALL
+ SELECT count(*) FROM main.t7
+ UNION ALL
+ SELECT count(*) FROM aux.t7
+ UNION ALL
+ SELECT count(*) FROM aux2.t7;
+ } {1 0 1 1}
+}
+
+# EVIDENCE-OF: R-31567-38587 If the table to which the trigger is
+# attached is in the TEMP database, then the unqualified name of the
+# table being deleted is resolved in the same way as it is for a
+# top-level statement (by searching first the TEMP database, then the
+# main database, then any other databases in the order they were
+# attached).
+#
+do_execsql_test e_delete-2.3.0 {
+ DROP TRIGGER aux.tr1;
+ DROP TRIGGER main.tr1;
+ DELETE FROM main.t8 WHERE oid>1;
+ DELETE FROM aux.t8 WHERE oid>1;
+ INSERT INTO aux.t9 VALUES(1, 2);
+ INSERT INTO main.t7 VALUES(3, 4);
+} {}
+do_execsql_test e_delete-2.3.1 {
+ SELECT count(*) FROM temp.t7 UNION ALL SELECT count(*) FROM main.t7 UNION ALL
+ SELECT count(*) FROM aux.t7 UNION ALL SELECT count(*) FROM aux2.t7;
+
+ SELECT count(*) FROM main.t8 UNION ALL SELECT count(*) FROM aux.t8
+ UNION ALL SELECT count(*) FROM aux2.t8;
+
+ SELECT count(*) FROM aux.t9 UNION ALL SELECT count(*) FROM aux2.t9;
+
+ SELECT count(*) FROM aux2.t10;
+} {1 1 1 1 1 1 1 1 1 1}
+do_execsql_test e_delete-2.3.2 {
+ CREATE TRIGGER temp.tr1 AFTER INSERT ON t7 BEGIN
+ DELETE FROM t7;
+ DELETE FROM t8;
+ DELETE FROM t9;
+ DELETE FROM t10;
+ END;
+ INSERT INTO temp.t7 VALUES('hello', 'world');
+} {}
+do_execsql_test e_delete-2.3.3 {
+ SELECT count(*) FROM temp.t7 UNION ALL SELECT count(*) FROM main.t7 UNION ALL
+ SELECT count(*) FROM aux.t7 UNION ALL SELECT count(*) FROM aux2.t7;
+
+ SELECT count(*) FROM main.t8 UNION ALL SELECT count(*) FROM aux.t8
+ UNION ALL SELECT count(*) FROM aux2.t8;
+
+ SELECT count(*) FROM aux.t9 UNION ALL SELECT count(*) FROM aux2.t9;
+
+ SELECT count(*) FROM aux2.t10;
+} {0 1 1 1 0 1 1 0 1 0}
+
+# EVIDENCE-OF: R-28691-49464 The INDEXED BY and NOT INDEXED clauses are
+# not allowed on DELETE statements within triggers.
+#
+do_execsql_test e_delete-2.4.0 {
+ CREATE INDEX i8 ON t8(a, b);
+} {}
+do_delete_tests e_delete-2.4 -error {
+ the %s %s clause is not allowed on UPDATE or DELETE statements within triggers
+} {
+ 1 {
+ CREATE TRIGGER tr3 AFTER INSERT ON t8 BEGIN
+ DELETE FROM t8 INDEXED BY i8 WHERE a=5;
+ END;
+ } {INDEXED BY}
+ 2 {
+ CREATE TRIGGER tr3 AFTER INSERT ON t8 BEGIN
+ DELETE FROM t8 NOT INDEXED WHERE a=5;
+ END;
+ } {NOT INDEXED}
+}
+
+ifcapable update_delete_limit {
+
+# EVIDENCE-OF: R-64942-06615 The LIMIT and ORDER BY clauses (described
+# below) are unsupported for DELETE statements within triggers.
+#
+do_delete_tests e_delete-2.5 -error { near "%s": syntax error } {
+ 1 {
+ CREATE TRIGGER tr3 AFTER INSERT ON t8 BEGIN
+ DELETE FROM t8 LIMIT 10;
+ END;
+ } {LIMIT}
+ 2 {
+ CREATE TRIGGER tr3 AFTER INSERT ON t8 BEGIN
+ DELETE FROM t8 ORDER BY a LIMIT 5;
+ END;
+ } {ORDER}
+}
+
+# EVIDENCE-OF: R-40026-10531 If SQLite is compiled with the
+# SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option, then the syntax
+# of the DELETE statement is extended by the addition of optional ORDER
+# BY and LIMIT clauses:
+#
+# EVIDENCE-OF: R-45897-01670 -- syntax diagram delete-stmt-limited
+#
+do_delete_tests e_delete-3.1 {
+ 1 "DELETE FROM t1 LIMIT 5" {}
+ 2 "DELETE FROM t1 LIMIT 5-1 OFFSET 2+2" {}
+ 3 "DELETE FROM t1 LIMIT 2+2, 16/4" {}
+ 4 "DELETE FROM t1 ORDER BY x LIMIT 5" {}
+ 5 "DELETE FROM t1 ORDER BY x LIMIT 5-1 OFFSET 2+2" {}
+ 6 "DELETE FROM t1 ORDER BY x LIMIT 2+2, 16/4" {}
+ 7 "DELETE FROM t1 WHERE x>2 LIMIT 5" {}
+ 8 "DELETE FROM t1 WHERE x>2 LIMIT 5-1 OFFSET 2+2" {}
+ 9 "DELETE FROM t1 WHERE x>2 LIMIT 2+2, 16/4" {}
+ 10 "DELETE FROM t1 WHERE x>2 ORDER BY x LIMIT 5" {}
+ 11 "DELETE FROM t1 WHERE x>2 ORDER BY x LIMIT 5-1 OFFSET 2+2" {}
+ 12 "DELETE FROM t1 WHERE x>2 ORDER BY x LIMIT 2+2, 16/4" {}
+}
+
+drop_all_tables
+proc rebuild_t1 {} {
+ catchsql { DROP TABLE t1 }
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+ INSERT INTO t1 VALUES(4, 'four');
+ INSERT INTO t1 VALUES(5, 'five');
+ }
+}
+
+# EVIDENCE-OF: R-44062-08550 If a DELETE statement has a LIMIT clause,
+# the maximum number of rows that will be deleted is found by evaluating
+# the accompanying expression and casting it to an integer value.
+#
+rebuild_t1
+do_delete_tests e_delete-3.2 -repair rebuild_t1 -query {
+ SELECT a FROM t1
+} {
+ 1 "DELETE FROM t1 LIMIT 3" {4 5}
+ 2 "DELETE FROM t1 LIMIT 1+1" {3 4 5}
+ 3 "DELETE FROM t1 LIMIT '4'" {5}
+ 4 "DELETE FROM t1 LIMIT '1.0'" {2 3 4 5}
+}
+
+# EVIDENCE-OF: R-02661-56399 If the result of the evaluating the LIMIT
+# clause cannot be losslessly converted to an integer value, it is an
+# error.
+#
+do_delete_tests e_delete-3.3 -error { datatype mismatch } {
+ 1 "DELETE FROM t1 LIMIT 'abc'" {}
+ 2 "DELETE FROM t1 LIMIT NULL" {}
+ 3 "DELETE FROM t1 LIMIT X'ABCD'" {}
+ 4 "DELETE FROM t1 LIMIT 1.2" {}
+}
+
+# EVIDENCE-OF: R-00598-03741 A negative LIMIT value is interpreted as
+# "no limit".
+#
+do_delete_tests e_delete-3.4 -repair rebuild_t1 -query {
+ SELECT a FROM t1
+} {
+ 1 "DELETE FROM t1 LIMIT -1" {}
+ 2 "DELETE FROM t1 LIMIT 2-4" {}
+ 3 "DELETE FROM t1 LIMIT -4.0" {}
+ 4 "DELETE FROM t1 LIMIT 5*-1" {}
+}
+
+# EVIDENCE-OF: R-26377-49195 If the DELETE statement also has an OFFSET
+# clause, then it is similarly evaluated and cast to an integer value.
+# Again, it is an error if the value cannot be losslessly converted to
+# an integer.
+#
+do_delete_tests e_delete-3.5 -error { datatype mismatch } {
+ 1 "DELETE FROM t1 LIMIT 1 OFFSET 'abc'" {}
+ 2 "DELETE FROM t1 LIMIT 1 OFFSET NULL" {}
+ 3 "DELETE FROM t1 LIMIT 1 OFFSET X'ABCD'" {}
+ 4 "DELETE FROM t1 LIMIT 1 OFFSET 1.2" {}
+ 5 "DELETE FROM t1 LIMIT 'abc', 1" {}
+ 6 "DELETE FROM t1 LIMIT NULL, 1" {}
+ 7 "DELETE FROM t1 LIMIT X'ABCD', 1" {}
+ 8 "DELETE FROM t1 LIMIT 1.2, 1" {}
+}
+
+
+# EVIDENCE-OF: R-64004-53814 If there is no OFFSET clause, or the
+# calculated integer value is negative, the effective OFFSET value is
+# zero.
+#
+do_delete_tests e_delete-3.6 -repair rebuild_t1 -query {
+ SELECT a FROM t1
+} {
+ 1a "DELETE FROM t1 LIMIT 3 OFFSET 0" {4 5}
+ 1b "DELETE FROM t1 LIMIT 3" {4 5}
+ 1c "DELETE FROM t1 LIMIT 3 OFFSET -1" {4 5}
+ 2a "DELETE FROM t1 LIMIT 1+1 OFFSET 0" {3 4 5}
+ 2b "DELETE FROM t1 LIMIT 1+1" {3 4 5}
+ 2c "DELETE FROM t1 LIMIT 1+1 OFFSET 2-5" {3 4 5}
+ 3a "DELETE FROM t1 LIMIT '4' OFFSET 0" {5}
+ 3b "DELETE FROM t1 LIMIT '4'" {5}
+ 3c "DELETE FROM t1 LIMIT '4' OFFSET -1.0" {5}
+ 4a "DELETE FROM t1 LIMIT '1.0' OFFSET 0" {2 3 4 5}
+ 4b "DELETE FROM t1 LIMIT '1.0'" {2 3 4 5}
+ 4c "DELETE FROM t1 LIMIT '1.0' OFFSET -11" {2 3 4 5}
+}
+
+# EVIDENCE-OF: R-48141-52334 If the DELETE statement has an ORDER BY
+# clause, then all rows that would be deleted in the absence of the
+# LIMIT clause are sorted according to the ORDER BY. The first M rows,
+# where M is the value found by evaluating the OFFSET clause expression,
+# are skipped, and the following N, where N is the value of the LIMIT
+# expression, are deleted.
+#
+do_delete_tests e_delete-3.7 -repair rebuild_t1 -query {
+ SELECT a FROM t1
+} {
+ 1 "DELETE FROM t1 ORDER BY b LIMIT 2" {1 2 3}
+ 2 "DELETE FROM t1 ORDER BY length(b), a LIMIT 3" {3 5}
+ 3 "DELETE FROM t1 ORDER BY a DESC LIMIT 1 OFFSET 0" {1 2 3 4}
+ 4 "DELETE FROM t1 ORDER BY a DESC LIMIT 1 OFFSET 1" {1 2 3 5}
+ 5 "DELETE FROM t1 ORDER BY a DESC LIMIT 1 OFFSET 2" {1 2 4 5}
+}
+
+# EVIDENCE-OF: R-64535-08414 If there are less than N rows remaining
+# after taking the OFFSET clause into account, or if the LIMIT clause
+# evaluated to a negative value, then all remaining rows are deleted.
+#
+do_delete_tests e_delete-3.8 -repair rebuild_t1 -query {
+ SELECT a FROM t1
+} {
+ 1 "DELETE FROM t1 ORDER BY a ASC LIMIT 10" {}
+ 2 "DELETE FROM t1 ORDER BY a ASC LIMIT -1" {}
+ 3 "DELETE FROM t1 ORDER BY a ASC LIMIT 4 OFFSET 2" {1 2}
+}
+
+# EVIDENCE-OF: R-37284-06965 If the DELETE statement has no ORDER BY
+# clause, then all rows that would be deleted in the absence of the
+# LIMIT clause are assembled in an arbitrary order before applying the
+# LIMIT and OFFSET clauses to determine the subset that are actually
+# deleted.
+#
+# In practice, the "arbitrary order" is rowid order.
+#
+do_delete_tests e_delete-3.9 -repair rebuild_t1 -query {
+ SELECT a FROM t1
+} {
+ 1 "DELETE FROM t1 LIMIT 2" {3 4 5}
+ 2 "DELETE FROM t1 LIMIT 3" {4 5}
+ 3 "DELETE FROM t1 LIMIT 1 OFFSET 0" {2 3 4 5}
+ 4 "DELETE FROM t1 LIMIT 1 OFFSET 1" {1 3 4 5}
+ 5 "DELETE FROM t1 LIMIT 1 OFFSET 2" {1 2 4 5}
+}
+
+
+# EVIDENCE-OF: R-07548-13422 The ORDER BY clause on a DELETE statement
+# is used only to determine which rows fall within the LIMIT. The order
+# in which rows are deleted is arbitrary and is not influenced by the
+# ORDER BY clause.
+#
+# In practice, rows are always deleted in rowid order.
+#
+do_delete_tests e_delete-3.10 -repair {
+ rebuild_t1
+ catchsql { DROP TABLE t1log }
+ execsql {
+ CREATE TABLE t1log(x);
+ CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN
+ INSERT INTO t1log VALUES(old.a);
+ END;
+ }
+} -query {
+ SELECT x FROM t1log
+} {
+ 1 "DELETE FROM t1 ORDER BY a DESC LIMIT 2" {4 5}
+ 2 "DELETE FROM t1 ORDER BY a DESC LIMIT -1" {1 2 3 4 5}
+ 3 "DELETE FROM t1 ORDER BY a ASC LIMIT 2" {1 2}
+ 4 "DELETE FROM t1 ORDER BY a ASC LIMIT -1" {1 2 3 4 5}
+}
+
+}
+
+finish_test
diff --git a/test/e_droptrigger.test b/test/e_droptrigger.test
new file mode 100644
index 0000000..0c14831
--- /dev/null
+++ b/test/e_droptrigger.test
@@ -0,0 +1,218 @@
+# 2010 November 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_droptrigger.html document are correct.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix e_droptrigger
+
+ifcapable !trigger { finish_test ; return }
+
+proc do_droptrigger_tests {nm args} {
+ uplevel do_select_tests [list e_createtable-$nm] $args
+}
+
+proc list_all_triggers {{db db}} {
+ set res [list]
+ $db eval { PRAGMA database_list } {
+ if {$name == "temp"} {
+ set tbl sqlite_temp_master
+ } else {
+ set tbl "$name.sqlite_master"
+ }
+ lappend res {*}[
+ db eval "SELECT '$name.' || name FROM $tbl WHERE type = 'trigger'"
+ ]
+ }
+ set res
+}
+
+
+proc droptrigger_reopen_db {{event INSERT}} {
+ db close
+ forcedelete test.db test.db2
+ sqlite3 db test.db
+
+ set ::triggers_fired [list]
+ proc r {x} { lappend ::triggers_fired $x }
+ db func r r
+
+ db eval "
+ ATTACH 'test.db2' AS aux;
+
+ CREATE TEMP TABLE t1(a, b);
+ INSERT INTO t1 VALUES('a', 'b');
+ CREATE TRIGGER tr1 AFTER $event ON t1 BEGIN SELECT r('temp.tr1') ; END;
+
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES('a', 'b');
+ CREATE TRIGGER tr1 BEFORE $event ON t2 BEGIN SELECT r('main.tr1') ; END;
+ CREATE TRIGGER tr2 AFTER $event ON t2 BEGIN SELECT r('main.tr2') ; END;
+
+ CREATE TABLE aux.t3(a, b);
+ INSERT INTO t3 VALUES('a', 'b');
+ CREATE TRIGGER aux.tr1 BEFORE $event ON t3 BEGIN SELECT r('aux.tr1') ; END;
+ CREATE TRIGGER aux.tr2 AFTER $event ON t3 BEGIN SELECT r('aux.tr2') ; END;
+ CREATE TRIGGER aux.tr3 AFTER $event ON t3 BEGIN SELECT r('aux.tr3') ; END;
+ "
+}
+
+
+# EVIDENCE-OF: R-52650-16855 -- syntax diagram drop-trigger-stmt
+#
+do_droptrigger_tests 1.1 -repair {
+ droptrigger_reopen_db
+} -tclquery {
+ list_all_triggers
+} {
+ 1 "DROP TRIGGER main.tr1"
+ {main.tr2 temp.tr1 aux.tr1 aux.tr2 aux.tr3}
+ 2 "DROP TRIGGER IF EXISTS main.tr1"
+ {main.tr2 temp.tr1 aux.tr1 aux.tr2 aux.tr3}
+ 3 "DROP TRIGGER tr1"
+ {main.tr1 main.tr2 aux.tr1 aux.tr2 aux.tr3}
+ 4 "DROP TRIGGER IF EXISTS tr1"
+ {main.tr1 main.tr2 aux.tr1 aux.tr2 aux.tr3}
+
+ 5 "DROP TRIGGER aux.tr1"
+ {main.tr1 main.tr2 temp.tr1 aux.tr2 aux.tr3}
+ 6 "DROP TRIGGER IF EXISTS aux.tr1"
+ {main.tr1 main.tr2 temp.tr1 aux.tr2 aux.tr3}
+
+ 7 "DROP TRIGGER IF EXISTS aux.xxx"
+ {main.tr1 main.tr2 temp.tr1 aux.tr1 aux.tr2 aux.tr3}
+ 8 "DROP TRIGGER IF EXISTS aux.xxx"
+ {main.tr1 main.tr2 temp.tr1 aux.tr1 aux.tr2 aux.tr3}
+}
+
+# EVIDENCE-OF: R-61172-15671 The DROP TRIGGER statement removes a
+# trigger created by the CREATE TRIGGER statement.
+#
+foreach {tn tbl droptrigger before after} {
+ 1 t1 "DROP TRIGGER tr1" {temp.tr1} {}
+ 2 t2 "DROP TRIGGER tr1" {main.tr1 main.tr2} {main.tr1 main.tr2}
+ 3 t3 "DROP TRIGGER tr1" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}
+
+ 4 t1 "DROP TRIGGER tr2" {temp.tr1} {temp.tr1}
+ 5 t2 "DROP TRIGGER tr2" {main.tr1 main.tr2} {main.tr1}
+ 6 t3 "DROP TRIGGER tr2" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}
+
+ 7 t1 "DROP TRIGGER tr3" {temp.tr1} {temp.tr1}
+ 8 t2 "DROP TRIGGER tr3" {main.tr1 main.tr2} {main.tr1 main.tr2}
+ 9 t3 "DROP TRIGGER tr3" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr2}
+} {
+
+ do_test 2.$tn.1 {
+ droptrigger_reopen_db
+ execsql " INSERT INTO $tbl VALUES('1', '2') "
+ set ::triggers_fired
+ } $before
+
+ do_test 2.$tn.2 {
+ droptrigger_reopen_db
+ execsql $droptrigger
+ execsql " INSERT INTO $tbl VALUES('1', '2') "
+ set ::triggers_fired
+ } $after
+}
+
+# EVIDENCE-OF: R-50239-29811 Once removed, the trigger definition is no
+# longer present in the sqlite_master (or sqlite_temp_master) table and
+# is not fired by any subsequent INSERT, UPDATE or DELETE statements.
+#
+# Test cases e_droptrigger-1.* test the first part of this statement
+# (that dropped triggers do not appear in the schema table), and tests
+# droptrigger-2.* test that dropped triggers are not fired by INSERT
+# statements. The following tests verify that they are not fired by
+# UPDATE or DELETE statements.
+#
+foreach {tn tbl droptrigger before after} {
+ 1 t1 "DROP TRIGGER tr1" {temp.tr1} {}
+ 2 t2 "DROP TRIGGER tr1" {main.tr1 main.tr2} {main.tr1 main.tr2}
+ 3 t3 "DROP TRIGGER tr1" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}
+
+ 4 t1 "DROP TRIGGER tr2" {temp.tr1} {temp.tr1}
+ 5 t2 "DROP TRIGGER tr2" {main.tr1 main.tr2} {main.tr1}
+ 6 t3 "DROP TRIGGER tr2" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}
+
+ 7 t1 "DROP TRIGGER tr3" {temp.tr1} {temp.tr1}
+ 8 t2 "DROP TRIGGER tr3" {main.tr1 main.tr2} {main.tr1 main.tr2}
+ 9 t3 "DROP TRIGGER tr3" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr2}
+} {
+
+ do_test 3.1.$tn.1 {
+ droptrigger_reopen_db UPDATE
+ execsql "UPDATE $tbl SET a = 'abc'"
+ set ::triggers_fired
+ } $before
+
+ do_test 3.1.$tn.2 {
+ droptrigger_reopen_db UPDATE
+ execsql $droptrigger
+ execsql "UPDATE $tbl SET a = 'abc'"
+ set ::triggers_fired
+ } $after
+}
+foreach {tn tbl droptrigger before after} {
+ 1 t1 "DROP TRIGGER tr1" {temp.tr1} {}
+ 2 t2 "DROP TRIGGER tr1" {main.tr1 main.tr2} {main.tr1 main.tr2}
+ 3 t3 "DROP TRIGGER tr1" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}
+
+ 4 t1 "DROP TRIGGER tr2" {temp.tr1} {temp.tr1}
+ 5 t2 "DROP TRIGGER tr2" {main.tr1 main.tr2} {main.tr1}
+ 6 t3 "DROP TRIGGER tr2" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}
+
+ 7 t1 "DROP TRIGGER tr3" {temp.tr1} {temp.tr1}
+ 8 t2 "DROP TRIGGER tr3" {main.tr1 main.tr2} {main.tr1 main.tr2}
+ 9 t3 "DROP TRIGGER tr3" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr2}
+} {
+
+ do_test 3.2.$tn.1 {
+ droptrigger_reopen_db DELETE
+ execsql "DELETE FROM $tbl"
+ set ::triggers_fired
+ } $before
+
+ do_test 3.2.$tn.2 {
+ droptrigger_reopen_db DELETE
+ execsql $droptrigger
+ execsql "DELETE FROM $tbl"
+ set ::triggers_fired
+ } $after
+}
+
+# EVIDENCE-OF: R-37808-62273 Note that triggers are automatically
+# dropped when the associated table is dropped.
+#
+do_test 4.1 {
+ droptrigger_reopen_db
+ list_all_triggers
+} {main.tr1 main.tr2 temp.tr1 aux.tr1 aux.tr2 aux.tr3}
+do_test 4.2 {
+ droptrigger_reopen_db
+ execsql "DROP TABLE t1"
+ list_all_triggers
+} {main.tr1 main.tr2 aux.tr1 aux.tr2 aux.tr3}
+do_test 4.3 {
+ droptrigger_reopen_db
+ execsql "DROP TABLE t1"
+ list_all_triggers
+} {main.tr1 main.tr2 aux.tr1 aux.tr2 aux.tr3}
+do_test 4.4 {
+ droptrigger_reopen_db
+ execsql "DROP TABLE t1"
+ list_all_triggers
+} {main.tr1 main.tr2 aux.tr1 aux.tr2 aux.tr3}
+
+finish_test
diff --git a/test/e_dropview.test b/test/e_dropview.test
new file mode 100644
index 0000000..447e5c3
--- /dev/null
+++ b/test/e_dropview.test
@@ -0,0 +1,192 @@
+# 2010 November 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_dropview.html document are correct.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix e_dropview
+
+proc dropview_reopen_db {} {
+ db close
+ forcedelete test.db test.db2
+ sqlite3 db test.db
+
+ db eval {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('a main', 'b main');
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE VIEW v2 AS SELECT * FROM t1;
+
+ CREATE TEMP TABLE t1(a, b);
+ INSERT INTO temp.t1 VALUES('a temp', 'b temp');
+ CREATE VIEW temp.v1 AS SELECT * FROM t1;
+
+ CREATE TABLE aux.t1(a, b);
+ INSERT INTO aux.t1 VALUES('a aux', 'b aux');
+ CREATE VIEW aux.v1 AS SELECT * FROM t1;
+ CREATE VIEW aux.v2 AS SELECT * FROM t1;
+ CREATE VIEW aux.v3 AS SELECT * FROM t1;
+ }
+}
+
+proc list_all_views {{db db}} {
+ set res [list]
+ $db eval { PRAGMA database_list } {
+ set tbl "$name.sqlite_master"
+ if {$name == "temp"} { set tbl sqlite_temp_master }
+
+ set sql "SELECT '$name.' || name FROM $tbl WHERE type = 'view'"
+ lappend res {*}[$db eval $sql]
+ }
+ set res
+}
+
+proc list_all_data {{db db}} {
+ set res [list]
+ $db eval { PRAGMA database_list } {
+ set tbl "$name.sqlite_master"
+ if {$name == "temp"} { set tbl sqlite_temp_master }
+
+ db eval "SELECT '$name.' || name AS x FROM $tbl WHERE type = 'table'" {
+ lappend res [list $x [db eval "SELECT * FROM $x"]]
+ }
+ }
+ set res
+}
+
+proc do_dropview_tests {nm args} {
+ uplevel do_select_tests $nm $args
+}
+
+# EVIDENCE-OF: R-21739-51207 -- syntax diagram drop-view-stmt
+#
+# All paths in the syntax diagram for DROP VIEW are tested by tests 1.*.
+#
+do_dropview_tests 1 -repair {
+ dropview_reopen_db
+} -tclquery {
+ list_all_views
+} {
+ 1 "DROP VIEW v1" {main.v1 main.v2 aux.v1 aux.v2 aux.v3}
+ 2 "DROP VIEW v2" {main.v1 temp.v1 aux.v1 aux.v2 aux.v3}
+ 3 "DROP VIEW main.v1" {main.v2 temp.v1 aux.v1 aux.v2 aux.v3}
+ 4 "DROP VIEW main.v2" {main.v1 temp.v1 aux.v1 aux.v2 aux.v3}
+ 5 "DROP VIEW IF EXISTS v1" {main.v1 main.v2 aux.v1 aux.v2 aux.v3}
+ 6 "DROP VIEW IF EXISTS v2" {main.v1 temp.v1 aux.v1 aux.v2 aux.v3}
+ 7 "DROP VIEW IF EXISTS main.v1" {main.v2 temp.v1 aux.v1 aux.v2 aux.v3}
+ 8 "DROP VIEW IF EXISTS main.v2" {main.v1 temp.v1 aux.v1 aux.v2 aux.v3}
+}
+
+# EVIDENCE-OF: R-27002-52307 The DROP VIEW statement removes a view
+# created by the CREATE VIEW statement.
+#
+dropview_reopen_db
+do_execsql_test 2.1 {
+ CREATE VIEW "new view" AS SELECT * FROM t1 AS x, t1 AS y;
+ SELECT * FROM "new view";
+} {{a main} {b main} {a main} {b main}}
+do_execsql_test 2.2 {;
+ SELECT * FROM sqlite_master WHERE name = 'new view';
+} {
+ view {new view} {new view} 0
+ {CREATE VIEW "new view" AS SELECT * FROM t1 AS x, t1 AS y}
+}
+do_execsql_test 2.3 {
+ DROP VIEW "new view";
+ SELECT * FROM sqlite_master WHERE name = 'new view';
+} {}
+do_catchsql_test 2.4 {
+ SELECT * FROM "new view"
+} {1 {no such table: new view}}
+
+# EVIDENCE-OF: R-00359-41639 The view definition is removed from the
+# database schema, but no actual data in the underlying base tables is
+# modified.
+#
+# For each view in the database, check that it can be queried. Then drop
+# it. Check that it can no longer be queried and is no longer listed
+# in any schema table. Then check that the contents of the db tables have
+# not changed
+#
+set databasedata [list_all_data]
+
+do_execsql_test 3.1.0 { SELECT * FROM temp.v1 } {{a temp} {b temp}}
+do_execsql_test 3.1.1 { DROP VIEW temp.v1 } {}
+do_catchsql_test 3.1.2 { SELECT * FROM temp.v1 } {1 {no such table: temp.v1}}
+do_test 3.1.3 { list_all_views } {main.v1 main.v2 aux.v1 aux.v2 aux.v3}
+do_test 3.1.4 { list_all_data } $databasedata
+
+do_execsql_test 3.2.0 { SELECT * FROM v1 } {{a main} {b main}}
+do_execsql_test 3.2.1 { DROP VIEW v1 } {}
+do_catchsql_test 3.2.2 { SELECT * FROM main.v1 } {1 {no such table: main.v1}}
+do_test 3.2.3 { list_all_views } {main.v2 aux.v1 aux.v2 aux.v3}
+do_test 3.2.4 { list_all_data } $databasedata
+
+do_execsql_test 3.3.0 { SELECT * FROM v2 } {{a main} {b main}}
+do_execsql_test 3.3.1 { DROP VIEW v2 } {}
+do_catchsql_test 3.3.2 { SELECT * FROM main.v2 } {1 {no such table: main.v2}}
+do_test 3.3.3 { list_all_views } {aux.v1 aux.v2 aux.v3}
+do_test 3.3.4 { list_all_data } $databasedata
+
+do_execsql_test 3.4.0 { SELECT * FROM v1 } {{a aux} {b aux}}
+do_execsql_test 3.4.1 { DROP VIEW v1 } {}
+do_catchsql_test 3.4.2 { SELECT * FROM v1 } {1 {no such table: v1}}
+do_test 3.4.3 { list_all_views } {aux.v2 aux.v3}
+do_test 3.4.4 { list_all_data } $databasedata
+
+do_execsql_test 3.4.0 { SELECT * FROM aux.v2 } {{a aux} {b aux}}
+do_execsql_test 3.4.1 { DROP VIEW aux.v2 } {}
+do_catchsql_test 3.4.2 { SELECT * FROM aux.v2 } {1 {no such table: aux.v2}}
+do_test 3.4.3 { list_all_views } {aux.v3}
+do_test 3.4.4 { list_all_data } $databasedata
+
+do_execsql_test 3.5.0 { SELECT * FROM v3 } {{a aux} {b aux}}
+do_execsql_test 3.5.1 { DROP VIEW v3 } {}
+do_catchsql_test 3.5.2 { SELECT * FROM v3 } {1 {no such table: v3}}
+do_test 3.5.3 { list_all_views } {}
+do_test 3.5.4 { list_all_data } $databasedata
+
+# EVIDENCE-OF: R-25558-37487 If the specified view cannot be found and
+# the IF EXISTS clause is not present, it is an error.
+#
+do_dropview_tests 4 -repair {
+ dropview_reopen_db
+} -errorformat {
+ no such view: %s
+} {
+ 1 "DROP VIEW xx" xx
+ 2 "DROP VIEW main.xx" main.xx
+ 3 "DROP VIEW temp.v2" temp.v2
+}
+
+# EVIDENCE-OF: R-07490-32536 If the specified view cannot be found and
+# an IF EXISTS clause is present in the DROP VIEW statement, then the
+# statement is a no-op.
+#
+do_dropview_tests 5 -repair {
+ dropview_reopen_db
+} -tclquery {
+ list_all_views
+ expr {[list_all_views] == "main.v1 main.v2 temp.v1 aux.v1 aux.v2 aux.v3"}
+} {
+ 1 "DROP VIEW IF EXISTS xx" 1
+ 2 "DROP VIEW IF EXISTS main.xx" 1
+ 3 "DROP VIEW IF EXISTS temp.v2" 1
+}
+
+
+
+
+finish_test
diff --git a/test/e_expr.test b/test/e_expr.test
new file mode 100644
index 0000000..3c9678c
--- /dev/null
+++ b/test/e_expr.test
@@ -0,0 +1,1847 @@
+# 2010 July 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_expr.html document are correct.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+
+proc do_expr_test {tn expr type value} {
+ uplevel do_execsql_test $tn [list "SELECT typeof($expr), $expr"] [
+ list [list $type $value]
+ ]
+}
+
+proc do_qexpr_test {tn expr value} {
+ uplevel do_execsql_test $tn [list "SELECT quote($expr)"] [list $value]
+}
+
+# Set up three global variables:
+#
+# ::opname An array mapping from SQL operator to an easy to parse
+# name. The names are used as part of test case names.
+#
+# ::opprec An array mapping from SQL operator to a numeric
+# precedence value. Operators that group more tightly
+# have lower numeric precedences.
+#
+# ::oplist A list of all SQL operators supported by SQLite.
+#
+foreach {op opn} {
+ || cat * mul / div % mod + add
+ - sub << lshift >> rshift & bitand | bitor
+ < less <= lesseq > more >= moreeq = eq1
+ == eq2 <> ne1 != ne2 IS is LIKE like
+ GLOB glob AND and OR or MATCH match REGEXP regexp
+ {IS NOT} isnt
+} {
+ set ::opname($op) $opn
+}
+set oplist [list]
+foreach {prec opl} {
+ 1 ||
+ 2 {* / %}
+ 3 {+ -}
+ 4 {<< >> & |}
+ 5 {< <= > >=}
+ 6 {= == != <> IS {IS NOT} LIKE GLOB MATCH REGEXP}
+ 7 AND
+ 8 OR
+} {
+ foreach op $opl {
+ set ::opprec($op) $prec
+ lappend oplist $op
+ }
+}
+
+
+# Hook in definitions of MATCH and REGEX. The following implementations
+# cause MATCH and REGEX to behave similarly to the == operator.
+#
+proc matchfunc {a b} { return [expr {$a==$b}] }
+proc regexfunc {a b} { return [expr {$a==$b}] }
+db func match -argcount 2 matchfunc
+db func regexp -argcount 2 regexfunc
+
+#-------------------------------------------------------------------------
+# Test cases e_expr-1.* attempt to verify that all binary operators listed
+# in the documentation exist and that the relative precedences of the
+# operators are also as the documentation suggests.
+#
+# EVIDENCE-OF: R-15514-65163 SQLite understands the following binary
+# operators, in order from highest to lowest precedence: || * / % + -
+# << >> & | < <= > >= = == != <> IS IS
+# NOT IN LIKE GLOB MATCH REGEXP AND OR
+#
+# EVIDENCE-OF: R-38759-38789 Operators IS and IS NOT have the same
+# precedence as =.
+#
+
+unset -nocomplain untested
+foreach op1 $oplist {
+ foreach op2 $oplist {
+ set untested($op1,$op2) 1
+ foreach {tn A B C} {
+ 1 22 45 66
+ 2 0 0 0
+ 3 0 0 1
+ 4 0 1 0
+ 5 0 1 1
+ 6 1 0 0
+ 7 1 0 1
+ 8 1 1 0
+ 9 1 1 1
+ 10 5 6 1
+ 11 1 5 6
+ 12 1 5 5
+ 13 5 5 1
+
+ 14 5 2 1
+ 15 1 4 1
+ 16 -1 0 1
+ 17 0 1 -1
+
+ } {
+ set testname "e_expr-1.$opname($op1).$opname($op2).$tn"
+
+ # If $op2 groups more tightly than $op1, then the result
+ # of executing $sql1 whould be the same as executing $sql3.
+ # If $op1 groups more tightly, or if $op1 and $op2 have
+ # the same precedence, then executing $sql1 should return
+ # the same value as $sql2.
+ #
+ set sql1 "SELECT $A $op1 $B $op2 $C"
+ set sql2 "SELECT ($A $op1 $B) $op2 $C"
+ set sql3 "SELECT $A $op1 ($B $op2 $C)"
+
+ set a2 [db one $sql2]
+ set a3 [db one $sql3]
+
+ do_execsql_test $testname $sql1 [list [
+ if {$opprec($op2) < $opprec($op1)} {set a3} {set a2}
+ ]]
+ if {$a2 != $a3} { unset -nocomplain untested($op1,$op2) }
+ }
+ }
+}
+
+foreach op {* AND OR + || & |} { unset untested($op,$op) }
+unset untested(+,-) ;# Since (a+b)-c == a+(b-c)
+unset untested(*,<<) ;# Since (a*b)<<c == a*(b<<c)
+
+do_test e_expr-1.1 { array names untested } {}
+
+# At one point, test 1.2.2 was failing. Instead of the correct result, it
+# was returning {1 1 0}. This would seem to indicate that LIKE has the
+# same precedence as '<'. Which is incorrect. It has lower precedence.
+#
+do_execsql_test e_expr-1.2.1 {
+ SELECT 0 < 2 LIKE 1, (0 < 2) LIKE 1, 0 < (2 LIKE 1)
+} {1 1 0}
+do_execsql_test e_expr-1.2.2 {
+ SELECT 0 LIKE 0 < 2, (0 LIKE 0) < 2, 0 LIKE (0 < 2)
+} {0 1 0}
+
+# Showing that LIKE and == have the same precedence
+#
+do_execsql_test e_expr-1.2.3 {
+ SELECT 2 LIKE 2 == 1, (2 LIKE 2) == 1, 2 LIKE (2 == 1)
+} {1 1 0}
+do_execsql_test e_expr-1.2.4 {
+ SELECT 2 == 2 LIKE 1, (2 == 2) LIKE 1, 2 == (2 LIKE 1)
+} {1 1 0}
+
+# Showing that < groups more tightly than == (< has higher precedence).
+#
+do_execsql_test e_expr-1.2.5 {
+ SELECT 0 < 2 == 1, (0 < 2) == 1, 0 < (2 == 1)
+} {1 1 0}
+do_execsql_test e_expr-1.6 {
+ SELECT 0 == 0 < 2, (0 == 0) < 2, 0 == (0 < 2)
+} {0 1 0}
+
+#-------------------------------------------------------------------------
+# Check that the four unary prefix operators mentioned in the
+# documentation exist.
+#
+# EVIDENCE-OF: R-13958-53419 Supported unary prefix operators are these:
+# - + ~ NOT
+#
+do_execsql_test e_expr-2.1 { SELECT - 10 } {-10}
+do_execsql_test e_expr-2.2 { SELECT + 10 } {10}
+do_execsql_test e_expr-2.3 { SELECT ~ 10 } {-11}
+do_execsql_test e_expr-2.4 { SELECT NOT 10 } {0}
+
+#-------------------------------------------------------------------------
+# Tests for the two statements made regarding the unary + operator.
+#
+# EVIDENCE-OF: R-53670-03373 The unary operator + is a no-op.
+#
+# EVIDENCE-OF: R-19480-30968 It can be applied to strings, numbers,
+# blobs or NULL and it always returns a result with the same value as
+# the operand.
+#
+foreach {tn literal type} {
+ 1 'helloworld' text
+ 2 45 integer
+ 3 45.2 real
+ 4 45.0 real
+ 5 X'ABCDEF' blob
+ 6 NULL null
+} {
+ set sql " SELECT quote( + $literal ), typeof( + $literal) "
+ do_execsql_test e_expr-3.$tn $sql [list $literal $type]
+}
+
+#-------------------------------------------------------------------------
+# Check that both = and == are both acceptable as the "equals" operator.
+# Similarly, either != or <> work as the not-equals operator.
+#
+# EVIDENCE-OF: R-03679-60639 Equals can be either = or ==.
+#
+# EVIDENCE-OF: R-30082-38996 The non-equals operator can be either != or
+# <>.
+#
+foreach {tn literal different} {
+ 1 'helloworld' '12345'
+ 2 22 23
+ 3 'xyz' X'78797A'
+ 4 X'78797A00' 'xyz'
+} {
+ do_execsql_test e_expr-4.$tn "
+ SELECT $literal = $literal, $literal == $literal,
+ $literal = $different, $literal == $different,
+ $literal = NULL, $literal == NULL,
+ $literal != $literal, $literal <> $literal,
+ $literal != $different, $literal <> $different,
+ $literal != NULL, $literal != NULL
+
+ " {1 1 0 0 {} {} 0 0 1 1 {} {}}
+}
+
+#-------------------------------------------------------------------------
+# Test the || operator.
+#
+# EVIDENCE-OF: R-44409-62641 The || operator is "concatenate" - it joins
+# together the two strings of its operands.
+#
+foreach {tn a b} {
+ 1 'helloworld' '12345'
+ 2 22 23
+} {
+ set as [db one "SELECT $a"]
+ set bs [db one "SELECT $b"]
+
+ do_execsql_test e_expr-5.$tn "SELECT $a || $b" [list "${as}${bs}"]
+}
+
+#-------------------------------------------------------------------------
+# Test the % operator.
+#
+# EVIDENCE-OF: R-08914-63790 The operator % outputs the value of its
+# left operand modulo its right operand.
+#
+do_execsql_test e_expr-6.1 {SELECT 72%5} {2}
+do_execsql_test e_expr-6.2 {SELECT 72%-5} {2}
+do_execsql_test e_expr-6.3 {SELECT -72%-5} {-2}
+do_execsql_test e_expr-6.4 {SELECT -72%5} {-2}
+
+#-------------------------------------------------------------------------
+# Test that the results of all binary operators are either numeric or
+# NULL, except for the || operator, which may evaluate to either a text
+# value or NULL.
+#
+# EVIDENCE-OF: R-20665-17792 The result of any binary operator is either
+# a numeric value or NULL, except for the || concatenation operator
+# which always evaluates to either NULL or a text value.
+#
+set literals {
+ 1 'abc' 2 'hexadecimal' 3 ''
+ 4 123 5 -123 6 0
+ 7 123.4 8 0.0 9 -123.4
+ 10 X'ABCDEF' 11 X'' 12 X'0000'
+ 13 NULL
+}
+foreach op $oplist {
+ foreach {n1 rhs} $literals {
+ foreach {n2 lhs} $literals {
+
+ set t [db one " SELECT typeof($lhs $op $rhs) "]
+ do_test e_expr-7.$opname($op).$n1.$n2 {
+ expr {
+ ($op=="||" && ($t == "text" || $t == "null"))
+ || ($op!="||" && ($t == "integer" || $t == "real" || $t == "null"))
+ }
+ } 1
+
+ }}
+}
+
+#-------------------------------------------------------------------------
+# Test the IS and IS NOT operators.
+#
+# EVIDENCE-OF: R-24731-45773 The IS and IS NOT operators work like = and
+# != except when one or both of the operands are NULL.
+#
+# EVIDENCE-OF: R-06325-15315 In this case, if both operands are NULL,
+# then the IS operator evaluates to 1 (true) and the IS NOT operator
+# evaluates to 0 (false).
+#
+# EVIDENCE-OF: R-19812-36779 If one operand is NULL and the other is
+# not, then the IS operator evaluates to 0 (false) and the IS NOT
+# operator is 1 (true).
+#
+# EVIDENCE-OF: R-61975-13410 It is not possible for an IS or IS NOT
+# expression to evaluate to NULL.
+#
+do_execsql_test e_expr-8.1.1 { SELECT NULL IS NULL } {1}
+do_execsql_test e_expr-8.1.2 { SELECT 'ab' IS NULL } {0}
+do_execsql_test e_expr-8.1.3 { SELECT NULL IS 'ab' } {0}
+do_execsql_test e_expr-8.1.4 { SELECT 'ab' IS 'ab' } {1}
+do_execsql_test e_expr-8.1.5 { SELECT NULL == NULL } {{}}
+do_execsql_test e_expr-8.1.6 { SELECT 'ab' == NULL } {{}}
+do_execsql_test e_expr-8.1.7 { SELECT NULL == 'ab' } {{}}
+do_execsql_test e_expr-8.1.8 { SELECT 'ab' == 'ab' } {1}
+do_execsql_test e_expr-8.1.9 { SELECT NULL IS NOT NULL } {0}
+do_execsql_test e_expr-8.1.10 { SELECT 'ab' IS NOT NULL } {1}
+do_execsql_test e_expr-8.1.11 { SELECT NULL IS NOT 'ab' } {1}
+do_execsql_test e_expr-8.1.12 { SELECT 'ab' IS NOT 'ab' } {0}
+do_execsql_test e_expr-8.1.13 { SELECT NULL != NULL } {{}}
+do_execsql_test e_expr-8.1.14 { SELECT 'ab' != NULL } {{}}
+do_execsql_test e_expr-8.1.15 { SELECT NULL != 'ab' } {{}}
+do_execsql_test e_expr-8.1.16 { SELECT 'ab' != 'ab' } {0}
+
+foreach {n1 rhs} $literals {
+ foreach {n2 lhs} $literals {
+ if {$rhs!="NULL" && $lhs!="NULL"} {
+ set eq [execsql "SELECT $lhs = $rhs, $lhs != $rhs"]
+ } else {
+ set eq [list [expr {$lhs=="NULL" && $rhs=="NULL"}] \
+ [expr {$lhs!="NULL" || $rhs!="NULL"}]
+ ]
+ }
+ set test e_expr-8.2.$n1.$n2
+ do_execsql_test $test.1 "SELECT $lhs IS $rhs, $lhs IS NOT $rhs" $eq
+ do_execsql_test $test.2 "
+ SELECT ($lhs IS $rhs) IS NULL, ($lhs IS NOT $rhs) IS NULL
+ " {0 0}
+ }
+}
+
+#-------------------------------------------------------------------------
+# Run some tests on the COLLATE "unary postfix operator".
+#
+# This collation sequence reverses both arguments before using
+# [string compare] to compare them. For example, when comparing the
+# strings 'one' and 'four', return the result of:
+#
+# string compare eno ruof
+#
+proc reverse_str {zStr} {
+ set out ""
+ foreach c [split $zStr {}] { set out "${c}${out}" }
+ set out
+}
+proc reverse_collate {zLeft zRight} {
+ string compare [reverse_str $zLeft] [reverse_str $zRight]
+}
+db collate reverse reverse_collate
+
+# EVIDENCE-OF: R-59577-33471 The COLLATE operator is a unary postfix
+# operator that assigns a collating sequence to an expression.
+#
+# EVIDENCE-OF: R-23441-22541 The COLLATE operator has a higher
+# precedence (binds more tightly) than any prefix unary operator or any
+# binary operator.
+#
+do_execsql_test e_expr-9.1 { SELECT 'abcd' < 'bbbb' COLLATE reverse } 0
+do_execsql_test e_expr-9.2 { SELECT ('abcd' < 'bbbb') COLLATE reverse } 1
+do_execsql_test e_expr-9.3 { SELECT 'abcd' <= 'bbbb' COLLATE reverse } 0
+do_execsql_test e_expr-9.4 { SELECT ('abcd' <= 'bbbb') COLLATE reverse } 1
+
+do_execsql_test e_expr-9.5 { SELECT 'abcd' > 'bbbb' COLLATE reverse } 1
+do_execsql_test e_expr-9.6 { SELECT ('abcd' > 'bbbb') COLLATE reverse } 0
+do_execsql_test e_expr-9.7 { SELECT 'abcd' >= 'bbbb' COLLATE reverse } 1
+do_execsql_test e_expr-9.8 { SELECT ('abcd' >= 'bbbb') COLLATE reverse } 0
+
+do_execsql_test e_expr-9.10 { SELECT 'abcd' = 'ABCD' COLLATE nocase } 1
+do_execsql_test e_expr-9.11 { SELECT ('abcd' = 'ABCD') COLLATE nocase } 0
+do_execsql_test e_expr-9.12 { SELECT 'abcd' == 'ABCD' COLLATE nocase } 1
+do_execsql_test e_expr-9.13 { SELECT ('abcd' == 'ABCD') COLLATE nocase } 0
+do_execsql_test e_expr-9.14 { SELECT 'abcd' IS 'ABCD' COLLATE nocase } 1
+do_execsql_test e_expr-9.15 { SELECT ('abcd' IS 'ABCD') COLLATE nocase } 0
+
+do_execsql_test e_expr-9.16 { SELECT 'abcd' != 'ABCD' COLLATE nocase } 0
+do_execsql_test e_expr-9.17 { SELECT ('abcd' != 'ABCD') COLLATE nocase } 1
+do_execsql_test e_expr-9.18 { SELECT 'abcd' <> 'ABCD' COLLATE nocase } 0
+do_execsql_test e_expr-9.19 { SELECT ('abcd' <> 'ABCD') COLLATE nocase } 1
+do_execsql_test e_expr-9.20 { SELECT 'abcd' IS NOT 'ABCD' COLLATE nocase } 0
+do_execsql_test e_expr-9.21 { SELECT ('abcd' IS NOT 'ABCD') COLLATE nocase } 1
+
+do_execsql_test e_expr-9.22 {
+ SELECT 'bbb' BETWEEN 'AAA' AND 'CCC' COLLATE nocase
+} 1
+do_execsql_test e_expr-9.23 {
+ SELECT ('bbb' BETWEEN 'AAA' AND 'CCC') COLLATE nocase
+} 0
+
+# EVIDENCE-OF: R-58731-25439 The collating sequence set by the COLLATE
+# operator overrides the collating sequence determined by the COLLATE
+# clause in a table column definition.
+#
+do_execsql_test e_expr-9.24 {
+ CREATE TABLE t24(a COLLATE NOCASE, b);
+ INSERT INTO t24 VALUES('aaa', 1);
+ INSERT INTO t24 VALUES('bbb', 2);
+ INSERT INTO t24 VALUES('ccc', 3);
+} {}
+do_execsql_test e_expr-9.25 { SELECT 'BBB' = a FROM t24 } {0 1 0}
+do_execsql_test e_expr-9.25 { SELECT a = 'BBB' FROM t24 } {0 1 0}
+do_execsql_test e_expr-9.25 { SELECT 'BBB' = a COLLATE binary FROM t24 } {0 0 0}
+do_execsql_test e_expr-9.25 { SELECT a COLLATE binary = 'BBB' FROM t24 } {0 0 0}
+
+#-------------------------------------------------------------------------
+# Test statements related to literal values.
+#
+# EVIDENCE-OF: R-31536-32008 Literal values may be integers, floating
+# point numbers, strings, BLOBs, or NULLs.
+#
+do_execsql_test e_expr-10.1.1 { SELECT typeof(5) } {integer}
+do_execsql_test e_expr-10.1.2 { SELECT typeof(5.1) } {real}
+do_execsql_test e_expr-10.1.3 { SELECT typeof('5.1') } {text}
+do_execsql_test e_expr-10.1.4 { SELECT typeof(X'ABCD') } {blob}
+do_execsql_test e_expr-10.1.5 { SELECT typeof(NULL) } {null}
+
+# "Scientific notation is supported for point literal values."
+#
+do_execsql_test e_expr-10.2.1 { SELECT typeof(3.4e-02) } {real}
+do_execsql_test e_expr-10.2.2 { SELECT typeof(3e+5) } {real}
+do_execsql_test e_expr-10.2.3 { SELECT 3.4e-02 } {0.034}
+do_execsql_test e_expr-10.2.4 { SELECT 3e+4 } {30000.0}
+
+# EVIDENCE-OF: R-35229-17830 A string constant is formed by enclosing
+# the string in single quotes (').
+#
+# EVIDENCE-OF: R-07100-06606 A single quote within the string can be
+# encoded by putting two single quotes in a row - as in Pascal.
+#
+do_execsql_test e_expr-10.3.1 { SELECT 'is not' } {{is not}}
+do_execsql_test e_expr-10.3.2 { SELECT typeof('is not') } {text}
+do_execsql_test e_expr-10.3.3 { SELECT 'isn''t' } {isn't}
+do_execsql_test e_expr-10.3.4 { SELECT typeof('isn''t') } {text}
+
+# EVIDENCE-OF: R-09593-03321 BLOB literals are string literals
+# containing hexadecimal data and preceded by a single "x" or "X"
+# character.
+#
+# EVIDENCE-OF: R-39344-59787 For example: X'53514C697465'
+#
+do_execsql_test e_expr-10.4.1 { SELECT typeof(X'0123456789ABCDEF') } blob
+do_execsql_test e_expr-10.4.2 { SELECT typeof(x'0123456789ABCDEF') } blob
+do_execsql_test e_expr-10.4.3 { SELECT typeof(X'0123456789abcdef') } blob
+do_execsql_test e_expr-10.4.4 { SELECT typeof(x'0123456789abcdef') } blob
+do_execsql_test e_expr-10.4.5 { SELECT typeof(X'53514C697465') } blob
+
+# EVIDENCE-OF: R-23914-51476 A literal value can also be the token
+# "NULL".
+#
+do_execsql_test e_expr-10.5.1 { SELECT NULL } {{}}
+do_execsql_test e_expr-10.5.2 { SELECT typeof(NULL) } {null}
+
+#-------------------------------------------------------------------------
+# Test statements related to bound parameters
+#
+
+proc parameter_test {tn sql params result} {
+ set stmt [sqlite3_prepare_v2 db $sql -1]
+
+ foreach {number name} $params {
+ set nm [sqlite3_bind_parameter_name $stmt $number]
+ do_test $tn.name.$number [list set {} $nm] $name
+ sqlite3_bind_int $stmt $number [expr -1 * $number]
+ }
+
+ sqlite3_step $stmt
+
+ set res [list]
+ for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {
+ lappend res [sqlite3_column_text $stmt $i]
+ }
+
+ set rc [sqlite3_finalize $stmt]
+ do_test $tn.rc [list set {} $rc] SQLITE_OK
+ do_test $tn.res [list set {} $res] $result
+}
+
+# EVIDENCE-OF: R-33509-39458 A question mark followed by a number NNN
+# holds a spot for the NNN-th parameter. NNN must be between 1 and
+# SQLITE_MAX_VARIABLE_NUMBER.
+#
+set mvn $SQLITE_MAX_VARIABLE_NUMBER
+parameter_test e_expr-11.1 "
+ SELECT ?1, ?123, ?$SQLITE_MAX_VARIABLE_NUMBER, ?123, ?4
+" "1 ?1 123 ?123 $mvn ?$mvn 4 ?4" "-1 -123 -$mvn -123 -4"
+
+set errmsg "variable number must be between ?1 and ?$SQLITE_MAX_VARIABLE_NUMBER"
+foreach {tn param_number} [list \
+ 2 0 \
+ 3 [expr $SQLITE_MAX_VARIABLE_NUMBER+1] \
+ 4 [expr $SQLITE_MAX_VARIABLE_NUMBER+2] \
+ 5 12345678903456789034567890234567890 \
+ 6 2147483648 \
+ 7 2147483649 \
+ 8 4294967296 \
+ 9 4294967297 \
+ 10 9223372036854775808 \
+ 11 9223372036854775809 \
+ 12 18446744073709551616 \
+ 13 18446744073709551617 \
+] {
+ do_catchsql_test e_expr-11.1.$tn "SELECT ?$param_number" [list 1 $errmsg]
+}
+
+# EVIDENCE-OF: R-33670-36097 A question mark that is not followed by a
+# number creates a parameter with a number one greater than the largest
+# parameter number already assigned.
+#
+# EVIDENCE-OF: R-42938-07030 If this means the parameter number is
+# greater than SQLITE_MAX_VARIABLE_NUMBER, it is an error.
+#
+parameter_test e_expr-11.2.1 "SELECT ?" {1 {}} -1
+parameter_test e_expr-11.2.2 "SELECT ?, ?" {1 {} 2 {}} {-1 -2}
+parameter_test e_expr-11.2.3 "SELECT ?5, ?" {5 ?5 6 {}} {-5 -6}
+parameter_test e_expr-11.2.4 "SELECT ?, ?5" {1 {} 5 ?5} {-1 -5}
+parameter_test e_expr-11.2.5 "SELECT ?, ?456, ?" {
+ 1 {} 456 ?456 457 {}
+} {-1 -456 -457}
+parameter_test e_expr-11.2.5 "SELECT ?, ?456, ?4, ?" {
+ 1 {} 456 ?456 4 ?4 457 {}
+} {-1 -456 -4 -457}
+foreach {tn sql} [list \
+ 1 "SELECT ?$mvn, ?" \
+ 2 "SELECT ?[expr $mvn-5], ?, ?, ?, ?, ?, ?" \
+ 3 "SELECT ?[expr $mvn], ?5, ?6, ?" \
+] {
+ do_catchsql_test e_expr-11.3.$tn $sql [list 1 {too many SQL variables}]
+}
+
+# EVIDENCE-OF: R-11620-22743 A colon followed by an identifier name
+# holds a spot for a named parameter with the name :AAAA.
+#
+# Identifiers in SQLite consist of alphanumeric, '_' and '$' characters,
+# and any UTF characters with codepoints larger than 127 (non-ASCII
+# characters).
+#
+parameter_test e_expr-11.2.1 {SELECT :AAAA} {1 :AAAA} -1
+parameter_test e_expr-11.2.2 {SELECT :123} {1 :123} -1
+parameter_test e_expr-11.2.3 {SELECT :__} {1 :__} -1
+parameter_test e_expr-11.2.4 {SELECT :_$_} {1 :_$_} -1
+parameter_test e_expr-11.2.5 "
+ SELECT :\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25
+" "1 :\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25" -1
+parameter_test e_expr-11.2.6 "SELECT :\u0080" "1 :\u0080" -1
+
+# EVIDENCE-OF: R-49783-61279 An "at" sign works exactly like a colon,
+# except that the name of the parameter created is @AAAA.
+#
+parameter_test e_expr-11.3.1 {SELECT @AAAA} {1 @AAAA} -1
+parameter_test e_expr-11.3.2 {SELECT @123} {1 @123} -1
+parameter_test e_expr-11.3.3 {SELECT @__} {1 @__} -1
+parameter_test e_expr-11.3.4 {SELECT @_$_} {1 @_$_} -1
+parameter_test e_expr-11.3.5 "
+ SELECT @\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25
+" "1 @\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25" -1
+parameter_test e_expr-11.3.6 "SELECT @\u0080" "1 @\u0080" -1
+
+# EVIDENCE-OF: R-62610-51329 A dollar-sign followed by an identifier
+# name also holds a spot for a named parameter with the name $AAAA.
+#
+# EVIDENCE-OF: R-55025-21042 The identifier name in this case can
+# include one or more occurrences of "::" and a suffix enclosed in
+# "(...)" containing any text at all.
+#
+# Note: Looks like an identifier cannot consist entirely of "::"
+# characters or just a suffix. Also, the other named variable characters
+# (: and @) work the same way internally. Why not just document it that way?
+#
+parameter_test e_expr-11.4.1 {SELECT $AAAA} {1 $AAAA} -1
+parameter_test e_expr-11.4.2 {SELECT $123} {1 $123} -1
+parameter_test e_expr-11.4.3 {SELECT $__} {1 $__} -1
+parameter_test e_expr-11.4.4 {SELECT $_$_} {1 $_$_} -1
+parameter_test e_expr-11.4.5 "
+ SELECT \$\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25
+" "1 \$\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25" -1
+parameter_test e_expr-11.4.6 "SELECT \$\u0080" "1 \$\u0080" -1
+
+parameter_test e_expr-11.5.1 {SELECT $::::a(++--++)} {1 $::::a(++--++)} -1
+parameter_test e_expr-11.5.2 {SELECT $::a()} {1 $::a()} -1
+parameter_test e_expr-11.5.3 {SELECT $::1(::#$)} {1 $::1(::#$)} -1
+
+# EVIDENCE-OF: R-11370-04520 Named parameters are also numbered. The
+# number assigned is one greater than the largest parameter number
+# already assigned.
+#
+# EVIDENCE-OF: R-42620-22184 If this means the parameter would be
+# assigned a number greater than SQLITE_MAX_VARIABLE_NUMBER, it is an
+# error.
+#
+parameter_test e_expr-11.6.1 "SELECT ?, @abc" {1 {} 2 @abc} {-1 -2}
+parameter_test e_expr-11.6.2 "SELECT ?123, :a1" {123 ?123 124 :a1} {-123 -124}
+parameter_test e_expr-11.6.3 {SELECT $a, ?8, ?, $b, ?2, $c} {
+ 1 $a 8 ?8 9 {} 10 $b 2 ?2 11 $c
+} {-1 -8 -9 -10 -2 -11}
+foreach {tn sql} [list \
+ 1 "SELECT ?$mvn, \$::a" \
+ 2 "SELECT ?$mvn, ?4, @a1" \
+ 3 "SELECT ?[expr $mvn-2], :bag, @123, \$x" \
+] {
+ do_catchsql_test e_expr-11.7.$tn $sql [list 1 {too many SQL variables}]
+}
+
+# EVIDENCE-OF: R-14068-49671 Parameters that are not assigned values
+# using sqlite3_bind() are treated as NULL.
+#
+do_test e_expr-11.7.1 {
+ set stmt [sqlite3_prepare_v2 db { SELECT ?, :a, @b, $d } -1]
+ sqlite3_step $stmt
+
+ list [sqlite3_column_type $stmt 0] \
+ [sqlite3_column_type $stmt 1] \
+ [sqlite3_column_type $stmt 2] \
+ [sqlite3_column_type $stmt 3]
+} {NULL NULL NULL NULL}
+do_test e_expr-11.7.1 { sqlite3_finalize $stmt } SQLITE_OK
+
+#-------------------------------------------------------------------------
+# "Test" the syntax diagrams in lang_expr.html.
+#
+# EVIDENCE-OF: R-62067-43884 -- syntax diagram signed-number
+#
+do_execsql_test e_expr-12.1.1 { SELECT 0, +0, -0 } {0 0 0}
+do_execsql_test e_expr-12.1.2 { SELECT 1, +1, -1 } {1 1 -1}
+do_execsql_test e_expr-12.1.3 { SELECT 2, +2, -2 } {2 2 -2}
+do_execsql_test e_expr-12.1.4 {
+ SELECT 1.4, +1.4, -1.4
+} {1.4 1.4 -1.4}
+do_execsql_test e_expr-12.1.5 {
+ SELECT 1.5e+5, +1.5e+5, -1.5e+5
+} {150000.0 150000.0 -150000.0}
+do_execsql_test e_expr-12.1.6 {
+ SELECT 0.0001, +0.0001, -0.0001
+} {0.0001 0.0001 -0.0001}
+
+# EVIDENCE-OF: R-21258-25489 -- syntax diagram literal-value
+#
+set sqlite_current_time 1
+do_execsql_test e_expr-12.2.1 {SELECT 123} {123}
+do_execsql_test e_expr-12.2.2 {SELECT 123.4e05} {12340000.0}
+do_execsql_test e_expr-12.2.3 {SELECT 'abcde'} {abcde}
+do_execsql_test e_expr-12.2.4 {SELECT X'414243'} {ABC}
+do_execsql_test e_expr-12.2.5 {SELECT NULL} {{}}
+do_execsql_test e_expr-12.2.6 {SELECT CURRENT_TIME} {00:00:01}
+do_execsql_test e_expr-12.2.7 {SELECT CURRENT_DATE} {1970-01-01}
+do_execsql_test e_expr-12.2.8 {SELECT CURRENT_TIMESTAMP} {{1970-01-01 00:00:01}}
+set sqlite_current_time 0
+
+# EVIDENCE-OF: R-57598-59332 -- syntax diagram expr
+#
+forcedelete test.db2
+execsql {
+ ATTACH 'test.db2' AS dbname;
+ CREATE TABLE dbname.tblname(cname);
+}
+
+proc glob {args} {return 1}
+db function glob glob
+db function match glob
+db function regexp glob
+
+foreach {tn expr} {
+ 1 123
+ 2 123.4e05
+ 3 'abcde'
+ 4 X'414243'
+ 5 NULL
+ 6 CURRENT_TIME
+ 7 CURRENT_DATE
+ 8 CURRENT_TIMESTAMP
+
+ 9 ?
+ 10 ?123
+ 11 @hello
+ 12 :world
+ 13 $tcl
+ 14 $tcl(array)
+
+ 15 cname
+ 16 tblname.cname
+ 17 dbname.tblname.cname
+
+ 18 "+ EXPR"
+ 19 "- EXPR"
+ 20 "NOT EXPR"
+ 21 "~ EXPR"
+
+ 22 "EXPR1 || EXPR2"
+ 23 "EXPR1 * EXPR2"
+ 24 "EXPR1 / EXPR2"
+ 25 "EXPR1 % EXPR2"
+ 26 "EXPR1 + EXPR2"
+ 27 "EXPR1 - EXPR2"
+ 28 "EXPR1 << EXPR2"
+ 29 "EXPR1 >> EXPR2"
+ 30 "EXPR1 & EXPR2"
+ 31 "EXPR1 | EXPR2"
+ 32 "EXPR1 < EXPR2"
+ 33 "EXPR1 <= EXPR2"
+ 34 "EXPR1 > EXPR2"
+ 35 "EXPR1 >= EXPR2"
+ 36 "EXPR1 = EXPR2"
+ 37 "EXPR1 == EXPR2"
+ 38 "EXPR1 != EXPR2"
+ 39 "EXPR1 <> EXPR2"
+ 40 "EXPR1 IS EXPR2"
+ 41 "EXPR1 IS NOT EXPR2"
+ 42 "EXPR1 AND EXPR2"
+ 43 "EXPR1 OR EXPR2"
+
+ 44 "count(*)"
+ 45 "count(DISTINCT EXPR)"
+ 46 "substr(EXPR, 10, 20)"
+ 47 "changes()"
+
+ 48 "( EXPR )"
+
+ 49 "CAST ( EXPR AS integer )"
+ 50 "CAST ( EXPR AS 'abcd' )"
+ 51 "CAST ( EXPR AS 'ab$ $cd' )"
+
+ 52 "EXPR COLLATE nocase"
+ 53 "EXPR COLLATE binary"
+
+ 54 "EXPR1 LIKE EXPR2"
+ 55 "EXPR1 LIKE EXPR2 ESCAPE EXPR"
+ 56 "EXPR1 GLOB EXPR2"
+ 57 "EXPR1 GLOB EXPR2 ESCAPE EXPR"
+ 58 "EXPR1 REGEXP EXPR2"
+ 59 "EXPR1 REGEXP EXPR2 ESCAPE EXPR"
+ 60 "EXPR1 MATCH EXPR2"
+ 61 "EXPR1 MATCH EXPR2 ESCAPE EXPR"
+ 62 "EXPR1 NOT LIKE EXPR2"
+ 63 "EXPR1 NOT LIKE EXPR2 ESCAPE EXPR"
+ 64 "EXPR1 NOT GLOB EXPR2"
+ 65 "EXPR1 NOT GLOB EXPR2 ESCAPE EXPR"
+ 66 "EXPR1 NOT REGEXP EXPR2"
+ 67 "EXPR1 NOT REGEXP EXPR2 ESCAPE EXPR"
+ 68 "EXPR1 NOT MATCH EXPR2"
+ 69 "EXPR1 NOT MATCH EXPR2 ESCAPE EXPR"
+
+ 70 "EXPR ISNULL"
+ 71 "EXPR NOTNULL"
+ 72 "EXPR NOT NULL"
+
+ 73 "EXPR1 IS EXPR2"
+ 74 "EXPR1 IS NOT EXPR2"
+
+ 75 "EXPR NOT BETWEEN EXPR1 AND EXPR2"
+ 76 "EXPR BETWEEN EXPR1 AND EXPR2"
+
+ 77 "EXPR NOT IN (SELECT cname FROM tblname)"
+ 78 "EXPR NOT IN (1)"
+ 79 "EXPR NOT IN (1, 2, 3)"
+ 80 "EXPR NOT IN tblname"
+ 81 "EXPR NOT IN dbname.tblname"
+ 82 "EXPR IN (SELECT cname FROM tblname)"
+ 83 "EXPR IN (1)"
+ 84 "EXPR IN (1, 2, 3)"
+ 85 "EXPR IN tblname"
+ 86 "EXPR IN dbname.tblname"
+
+ 87 "EXISTS (SELECT cname FROM tblname)"
+ 88 "NOT EXISTS (SELECT cname FROM tblname)"
+
+ 89 "CASE EXPR WHEN EXPR1 THEN EXPR2 ELSE EXPR END"
+ 90 "CASE EXPR WHEN EXPR1 THEN EXPR2 END"
+ 91 "CASE EXPR WHEN EXPR1 THEN EXPR2 WHEN EXPR THEN EXPR1 ELSE EXPR2 END"
+ 92 "CASE EXPR WHEN EXPR1 THEN EXPR2 WHEN EXPR THEN EXPR1 END"
+ 93 "CASE WHEN EXPR1 THEN EXPR2 ELSE EXPR END"
+ 94 "CASE WHEN EXPR1 THEN EXPR2 END"
+ 95 "CASE WHEN EXPR1 THEN EXPR2 WHEN EXPR THEN EXPR1 ELSE EXPR2 END"
+ 96 "CASE WHEN EXPR1 THEN EXPR2 WHEN EXPR THEN EXPR1 END"
+} {
+
+ # If the expression string being parsed contains "EXPR2", then replace
+ # string "EXPR1" and "EXPR2" with arbitrary SQL expressions. If it
+ # contains "EXPR", then replace EXPR with an arbitrary SQL expression.
+ #
+ set elist [list $expr]
+ if {[string match *EXPR2* $expr]} {
+ set elist [list]
+ foreach {e1 e2} { cname "34+22" } {
+ lappend elist [string map [list EXPR1 $e1 EXPR2 $e2] $expr]
+ }
+ }
+ if {[string match *EXPR* $expr]} {
+ set elist2 [list]
+ foreach el $elist {
+ foreach e { cname "34+22" } {
+ lappend elist2 [string map [list EXPR $e] $el]
+ }
+ }
+ set elist $elist2
+ }
+
+ set x 0
+ foreach e $elist {
+ incr x
+ do_test e_expr-12.3.$tn.$x {
+ set rc [catch { execsql "SELECT $e FROM tblname" } msg]
+ } {0}
+ }
+}
+
+# EVIDENCE-OF: R-49462-56079 -- syntax diagram raise-function
+#
+foreach {tn raiseexpr} {
+ 1 "RAISE(IGNORE)"
+ 2 "RAISE(ROLLBACK, 'error message')"
+ 3 "RAISE(ABORT, 'error message')"
+ 4 "RAISE(FAIL, 'error message')"
+} {
+ do_execsql_test e_expr-12.4.$tn "
+ CREATE TRIGGER dbname.tr$tn BEFORE DELETE ON tblname BEGIN
+ SELECT $raiseexpr ;
+ END;
+ " {}
+}
+
+#-------------------------------------------------------------------------
+# Test the statements related to the BETWEEN operator.
+#
+# EVIDENCE-OF: R-40079-54503 The BETWEEN operator is logically
+# equivalent to a pair of comparisons. "x BETWEEN y AND z" is equivalent
+# to "x>=y AND x<=z" except that with BETWEEN, the x expression is
+# only evaluated once.
+#
+db func x x
+proc x {} { incr ::xcount ; return [expr $::x] }
+foreach {tn x expr res nEval} {
+ 1 10 "x() >= 5 AND x() <= 15" 1 2
+ 2 10 "x() BETWEEN 5 AND 15" 1 1
+
+ 3 5 "x() >= 5 AND x() <= 5" 1 2
+ 4 5 "x() BETWEEN 5 AND 5" 1 1
+} {
+ do_test e_expr-13.1.$tn {
+ set ::xcount 0
+ set a [execsql "SELECT $expr"]
+ list $::xcount $a
+ } [list $nEval $res]
+}
+
+# EVIDENCE-OF: R-05155-34454 The precedence of the BETWEEN operator is
+# the same as the precedence as operators == and != and LIKE and groups
+# left to right.
+#
+# Therefore, BETWEEN groups more tightly than operator "AND", but less
+# so than "<".
+#
+do_execsql_test e_expr-13.2.1 { SELECT 1 == 10 BETWEEN 0 AND 2 } 1
+do_execsql_test e_expr-13.2.2 { SELECT (1 == 10) BETWEEN 0 AND 2 } 1
+do_execsql_test e_expr-13.2.3 { SELECT 1 == (10 BETWEEN 0 AND 2) } 0
+do_execsql_test e_expr-13.2.4 { SELECT 6 BETWEEN 4 AND 8 == 1 } 1
+do_execsql_test e_expr-13.2.5 { SELECT (6 BETWEEN 4 AND 8) == 1 } 1
+do_execsql_test e_expr-13.2.6 { SELECT 6 BETWEEN 4 AND (8 == 1) } 0
+
+do_execsql_test e_expr-13.2.7 { SELECT 5 BETWEEN 0 AND 0 != 1 } 1
+do_execsql_test e_expr-13.2.8 { SELECT (5 BETWEEN 0 AND 0) != 1 } 1
+do_execsql_test e_expr-13.2.9 { SELECT 5 BETWEEN 0 AND (0 != 1) } 0
+do_execsql_test e_expr-13.2.10 { SELECT 1 != 0 BETWEEN 0 AND 2 } 1
+do_execsql_test e_expr-13.2.11 { SELECT (1 != 0) BETWEEN 0 AND 2 } 1
+do_execsql_test e_expr-13.2.12 { SELECT 1 != (0 BETWEEN 0 AND 2) } 0
+
+do_execsql_test e_expr-13.2.13 { SELECT 1 LIKE 10 BETWEEN 0 AND 2 } 1
+do_execsql_test e_expr-13.2.14 { SELECT (1 LIKE 10) BETWEEN 0 AND 2 } 1
+do_execsql_test e_expr-13.2.15 { SELECT 1 LIKE (10 BETWEEN 0 AND 2) } 0
+do_execsql_test e_expr-13.2.16 { SELECT 6 BETWEEN 4 AND 8 LIKE 1 } 1
+do_execsql_test e_expr-13.2.17 { SELECT (6 BETWEEN 4 AND 8) LIKE 1 } 1
+do_execsql_test e_expr-13.2.18 { SELECT 6 BETWEEN 4 AND (8 LIKE 1) } 0
+
+do_execsql_test e_expr-13.2.19 { SELECT 0 AND 0 BETWEEN 0 AND 1 } 0
+do_execsql_test e_expr-13.2.20 { SELECT 0 AND (0 BETWEEN 0 AND 1) } 0
+do_execsql_test e_expr-13.2.21 { SELECT (0 AND 0) BETWEEN 0 AND 1 } 1
+do_execsql_test e_expr-13.2.22 { SELECT 0 BETWEEN -1 AND 1 AND 0 } 0
+do_execsql_test e_expr-13.2.23 { SELECT (0 BETWEEN -1 AND 1) AND 0 } 0
+do_execsql_test e_expr-13.2.24 { SELECT 0 BETWEEN -1 AND (1 AND 0) } 1
+
+do_execsql_test e_expr-13.2.25 { SELECT 2 < 3 BETWEEN 0 AND 1 } 1
+do_execsql_test e_expr-13.2.26 { SELECT (2 < 3) BETWEEN 0 AND 1 } 1
+do_execsql_test e_expr-13.2.27 { SELECT 2 < (3 BETWEEN 0 AND 1) } 0
+do_execsql_test e_expr-13.2.28 { SELECT 2 BETWEEN 1 AND 2 < 3 } 0
+do_execsql_test e_expr-13.2.29 { SELECT 2 BETWEEN 1 AND (2 < 3) } 0
+do_execsql_test e_expr-13.2.30 { SELECT (2 BETWEEN 1 AND 2) < 3 } 1
+
+#-------------------------------------------------------------------------
+# Test the statements related to the LIKE and GLOB operators.
+#
+# EVIDENCE-OF: R-16584-60189 The LIKE operator does a pattern matching
+# comparison.
+#
+# EVIDENCE-OF: R-11295-04657 The operand to the right of the LIKE
+# operator contains the pattern and the left hand operand contains the
+# string to match against the pattern.
+#
+do_execsql_test e_expr-14.1.1 { SELECT 'abc%' LIKE 'abcde' } 0
+do_execsql_test e_expr-14.1.2 { SELECT 'abcde' LIKE 'abc%' } 1
+
+# EVIDENCE-OF: R-55406-38524 A percent symbol ("%") in the LIKE pattern
+# matches any sequence of zero or more characters in the string.
+#
+do_execsql_test e_expr-14.2.1 { SELECT 'abde' LIKE 'ab%de' } 1
+do_execsql_test e_expr-14.2.2 { SELECT 'abXde' LIKE 'ab%de' } 1
+do_execsql_test e_expr-14.2.3 { SELECT 'abABCde' LIKE 'ab%de' } 1
+
+# EVIDENCE-OF: R-30433-25443 An underscore ("_") in the LIKE pattern
+# matches any single character in the string.
+#
+do_execsql_test e_expr-14.3.1 { SELECT 'abde' LIKE 'ab_de' } 0
+do_execsql_test e_expr-14.3.2 { SELECT 'abXde' LIKE 'ab_de' } 1
+do_execsql_test e_expr-14.3.3 { SELECT 'abABCde' LIKE 'ab_de' } 0
+
+# EVIDENCE-OF: R-59007-20454 Any other character matches itself or its
+# lower/upper case equivalent (i.e. case-insensitive matching).
+#
+do_execsql_test e_expr-14.4.1 { SELECT 'abc' LIKE 'aBc' } 1
+do_execsql_test e_expr-14.4.2 { SELECT 'aBc' LIKE 'aBc' } 1
+do_execsql_test e_expr-14.4.3 { SELECT 'ac' LIKE 'aBc' } 0
+
+# EVIDENCE-OF: R-23648-58527 SQLite only understands upper/lower case
+# for ASCII characters by default.
+#
+# EVIDENCE-OF: R-04532-11527 The LIKE operator is case sensitive by
+# default for unicode characters that are beyond the ASCII range.
+#
+# EVIDENCE-OF: R-44381-11669 the expression
+# 'a'&nbsp;LIKE&nbsp;'A' is TRUE but
+# '&aelig;'&nbsp;LIKE&nbsp;'&AElig;' is FALSE.
+#
+# The restriction to ASCII characters does not apply if the ICU
+# library is compiled in. When ICU is enabled SQLite does not act
+# as it does "by default".
+#
+do_execsql_test e_expr-14.5.1 { SELECT 'A' LIKE 'a' } 1
+ifcapable !icu {
+ do_execsql_test e_expr-14.5.2 "SELECT '\u00c6' LIKE '\u00e6'" 0
+}
+
+# EVIDENCE-OF: R-56683-13731 If the optional ESCAPE clause is present,
+# then the expression following the ESCAPE keyword must evaluate to a
+# string consisting of a single character.
+#
+do_catchsql_test e_expr-14.6.1 {
+ SELECT 'A' LIKE 'a' ESCAPE '12'
+} {1 {ESCAPE expression must be a single character}}
+do_catchsql_test e_expr-14.6.2 {
+ SELECT 'A' LIKE 'a' ESCAPE ''
+} {1 {ESCAPE expression must be a single character}}
+do_catchsql_test e_expr-14.6.3 { SELECT 'A' LIKE 'a' ESCAPE 'x' } {0 1}
+do_catchsql_test e_expr-14.6.4 "SELECT 'A' LIKE 'a' ESCAPE '\u00e6'" {0 1}
+
+# EVIDENCE-OF: R-02045-23762 This character may be used in the LIKE
+# pattern to include literal percent or underscore characters.
+#
+# EVIDENCE-OF: R-13345-31830 The escape character followed by a percent
+# symbol (%), underscore (_), or a second instance of the escape
+# character itself matches a literal percent symbol, underscore, or a
+# single escape character, respectively.
+#
+do_execsql_test e_expr-14.7.1 { SELECT 'abc%' LIKE 'abcX%' ESCAPE 'X' } 1
+do_execsql_test e_expr-14.7.2 { SELECT 'abc5' LIKE 'abcX%' ESCAPE 'X' } 0
+do_execsql_test e_expr-14.7.3 { SELECT 'abc' LIKE 'abcX%' ESCAPE 'X' } 0
+do_execsql_test e_expr-14.7.4 { SELECT 'abcX%' LIKE 'abcX%' ESCAPE 'X' } 0
+do_execsql_test e_expr-14.7.5 { SELECT 'abc%%' LIKE 'abcX%' ESCAPE 'X' } 0
+
+do_execsql_test e_expr-14.7.6 { SELECT 'abc_' LIKE 'abcX_' ESCAPE 'X' } 1
+do_execsql_test e_expr-14.7.7 { SELECT 'abc5' LIKE 'abcX_' ESCAPE 'X' } 0
+do_execsql_test e_expr-14.7.8 { SELECT 'abc' LIKE 'abcX_' ESCAPE 'X' } 0
+do_execsql_test e_expr-14.7.9 { SELECT 'abcX_' LIKE 'abcX_' ESCAPE 'X' } 0
+do_execsql_test e_expr-14.7.10 { SELECT 'abc__' LIKE 'abcX_' ESCAPE 'X' } 0
+
+do_execsql_test e_expr-14.7.11 { SELECT 'abcX' LIKE 'abcXX' ESCAPE 'X' } 1
+do_execsql_test e_expr-14.7.12 { SELECT 'abc5' LIKE 'abcXX' ESCAPE 'X' } 0
+do_execsql_test e_expr-14.7.13 { SELECT 'abc' LIKE 'abcXX' ESCAPE 'X' } 0
+do_execsql_test e_expr-14.7.14 { SELECT 'abcXX' LIKE 'abcXX' ESCAPE 'X' } 0
+
+# EVIDENCE-OF: R-51359-17496 The infix LIKE operator is implemented by
+# calling the application-defined SQL functions like(Y,X) or like(Y,X,Z).
+#
+proc likefunc {args} {
+ eval lappend ::likeargs $args
+ return 1
+}
+db func like -argcount 2 likefunc
+db func like -argcount 3 likefunc
+set ::likeargs [list]
+do_execsql_test e_expr-15.1.1 { SELECT 'abc' LIKE 'def' } 1
+do_test e_expr-15.1.2 { set likeargs } {def abc}
+set ::likeargs [list]
+do_execsql_test e_expr-15.1.3 { SELECT 'abc' LIKE 'def' ESCAPE 'X' } 1
+do_test e_expr-15.1.4 { set likeargs } {def abc X}
+db close
+sqlite3 db test.db
+
+# EVIDENCE-OF: R-22868-25880 The LIKE operator can be made case
+# sensitive using the case_sensitive_like pragma.
+#
+do_execsql_test e_expr-16.1.1 { SELECT 'abcxyz' LIKE 'ABC%' } 1
+do_execsql_test e_expr-16.1.2 { PRAGMA case_sensitive_like = 1 } {}
+do_execsql_test e_expr-16.1.3 { SELECT 'abcxyz' LIKE 'ABC%' } 0
+do_execsql_test e_expr-16.1.4 { SELECT 'ABCxyz' LIKE 'ABC%' } 1
+do_execsql_test e_expr-16.1.5 { PRAGMA case_sensitive_like = 0 } {}
+do_execsql_test e_expr-16.1.6 { SELECT 'abcxyz' LIKE 'ABC%' } 1
+do_execsql_test e_expr-16.1.7 { SELECT 'ABCxyz' LIKE 'ABC%' } 1
+
+# EVIDENCE-OF: R-52087-12043 The GLOB operator is similar to LIKE but
+# uses the Unix file globbing syntax for its wildcards.
+#
+# EVIDENCE-OF: R-09813-17279 Also, GLOB is case sensitive, unlike LIKE.
+#
+do_execsql_test e_expr-17.1.1 { SELECT 'abcxyz' GLOB 'abc%' } 0
+do_execsql_test e_expr-17.1.2 { SELECT 'abcxyz' GLOB 'abc*' } 1
+do_execsql_test e_expr-17.1.3 { SELECT 'abcxyz' GLOB 'abc___' } 0
+do_execsql_test e_expr-17.1.4 { SELECT 'abcxyz' GLOB 'abc???' } 1
+
+do_execsql_test e_expr-17.1.5 { SELECT 'abcxyz' GLOB 'abc*' } 1
+do_execsql_test e_expr-17.1.6 { SELECT 'ABCxyz' GLOB 'abc*' } 0
+do_execsql_test e_expr-17.1.7 { SELECT 'abcxyz' GLOB 'ABC*' } 0
+
+# EVIDENCE-OF: R-39616-20555 Both GLOB and LIKE may be preceded by the
+# NOT keyword to invert the sense of the test.
+#
+do_execsql_test e_expr-17.2.1 { SELECT 'abcxyz' NOT GLOB 'ABC*' } 1
+do_execsql_test e_expr-17.2.2 { SELECT 'abcxyz' NOT GLOB 'abc*' } 0
+do_execsql_test e_expr-17.2.3 { SELECT 'abcxyz' NOT LIKE 'ABC%' } 0
+do_execsql_test e_expr-17.2.4 { SELECT 'abcxyz' NOT LIKE 'abc%' } 0
+do_execsql_test e_expr-17.2.5 { SELECT 'abdxyz' NOT LIKE 'abc%' } 1
+
+db nullvalue null
+do_execsql_test e_expr-17.2.6 { SELECT 'abcxyz' NOT GLOB NULL } null
+do_execsql_test e_expr-17.2.7 { SELECT 'abcxyz' NOT LIKE NULL } null
+do_execsql_test e_expr-17.2.8 { SELECT NULL NOT GLOB 'abc*' } null
+do_execsql_test e_expr-17.2.9 { SELECT NULL NOT LIKE 'ABC%' } null
+db nullvalue {}
+
+# EVIDENCE-OF: R-39414-35489 The infix GLOB operator is implemented by
+# calling the function glob(Y,X) and can be modified by overriding that
+# function.
+proc globfunc {args} {
+ eval lappend ::globargs $args
+ return 1
+}
+db func glob -argcount 2 globfunc
+set ::globargs [list]
+do_execsql_test e_expr-17.3.1 { SELECT 'abc' GLOB 'def' } 1
+do_test e_expr-17.3.2 { set globargs } {def abc}
+set ::globargs [list]
+do_execsql_test e_expr-17.3.3 { SELECT 'X' NOT GLOB 'Y' } 0
+do_test e_expr-17.3.4 { set globargs } {Y X}
+sqlite3 db test.db
+
+# EVIDENCE-OF: R-41650-20872 No regexp() user function is defined by
+# default and so use of the REGEXP operator will normally result in an
+# error message.
+#
+# There is a regexp function if ICU is enabled though.
+#
+ifcapable !icu {
+ do_catchsql_test e_expr-18.1.1 {
+ SELECT regexp('abc', 'def')
+ } {1 {no such function: regexp}}
+ do_catchsql_test e_expr-18.1.2 {
+ SELECT 'abc' REGEXP 'def'
+ } {1 {no such function: REGEXP}}
+}
+
+# EVIDENCE-OF: R-33693-50180 The REGEXP operator is a special syntax for
+# the regexp() user function.
+#
+# EVIDENCE-OF: R-57289-13578 If a application-defined SQL function named
+# "regexp" is added at run-time, that function will be called in order
+# to implement the REGEXP operator.
+#
+proc regexpfunc {args} {
+ eval lappend ::regexpargs $args
+ return 1
+}
+db func regexp -argcount 2 regexpfunc
+set ::regexpargs [list]
+do_execsql_test e_expr-18.2.1 { SELECT 'abc' REGEXP 'def' } 1
+do_test e_expr-18.2.2 { set regexpargs } {def abc}
+set ::regexpargs [list]
+do_execsql_test e_expr-18.2.3 { SELECT 'X' NOT REGEXP 'Y' } 0
+do_test e_expr-18.2.4 { set regexpargs } {Y X}
+sqlite3 db test.db
+
+# EVIDENCE-OF: R-42037-37826 The default match() function implementation
+# raises an exception and is not really useful for anything.
+#
+do_catchsql_test e_expr-19.1.1 {
+ SELECT 'abc' MATCH 'def'
+} {1 {unable to use function MATCH in the requested context}}
+do_catchsql_test e_expr-19.1.2 {
+ SELECT match('abc', 'def')
+} {1 {unable to use function MATCH in the requested context}}
+
+# EVIDENCE-OF: R-37916-47407 The MATCH operator is a special syntax for
+# the match() application-defined function.
+#
+# EVIDENCE-OF: R-06021-09373 But extensions can override the match()
+# function with more helpful logic.
+#
+proc matchfunc {args} {
+ eval lappend ::matchargs $args
+ return 1
+}
+db func match -argcount 2 matchfunc
+set ::matchargs [list]
+do_execsql_test e_expr-19.2.1 { SELECT 'abc' MATCH 'def' } 1
+do_test e_expr-19.2.2 { set matchargs } {def abc}
+set ::matchargs [list]
+do_execsql_test e_expr-19.2.3 { SELECT 'X' NOT MATCH 'Y' } 0
+do_test e_expr-19.2.4 { set matchargs } {Y X}
+sqlite3 db test.db
+
+#-------------------------------------------------------------------------
+# Test cases for the testable statements related to the CASE expression.
+#
+# EVIDENCE-OF: R-15199-61389 There are two basic forms of the CASE
+# expression: those with a base expression and those without.
+#
+do_execsql_test e_expr-20.1 {
+ SELECT CASE WHEN 1 THEN 'true' WHEN 0 THEN 'false' ELSE 'else' END;
+} {true}
+do_execsql_test e_expr-20.2 {
+ SELECT CASE 0 WHEN 1 THEN 'true' WHEN 0 THEN 'false' ELSE 'else' END;
+} {false}
+
+proc var {nm} {
+ lappend ::varlist $nm
+ return [set "::$nm"]
+}
+db func var var
+
+# EVIDENCE-OF: R-30638-59954 In a CASE without a base expression, each
+# WHEN expression is evaluated and the result treated as a boolean,
+# starting with the leftmost and continuing to the right.
+#
+foreach {a b c} {0 0 0} break
+set varlist [list]
+do_execsql_test e_expr-21.1.1 {
+ SELECT CASE WHEN var('a') THEN 'A'
+ WHEN var('b') THEN 'B'
+ WHEN var('c') THEN 'C' END
+} {{}}
+do_test e_expr-21.1.2 { set varlist } {a b c}
+set varlist [list]
+do_execsql_test e_expr-21.1.3 {
+ SELECT CASE WHEN var('c') THEN 'C'
+ WHEN var('b') THEN 'B'
+ WHEN var('a') THEN 'A'
+ ELSE 'no result'
+ END
+} {{no result}}
+do_test e_expr-21.1.4 { set varlist } {c b a}
+
+# EVIDENCE-OF: R-39009-25596 The result of the CASE expression is the
+# evaluation of the THEN expression that corresponds to the first WHEN
+# expression that evaluates to true.
+#
+foreach {a b c} {0 1 0} break
+do_execsql_test e_expr-21.2.1 {
+ SELECT CASE WHEN var('a') THEN 'A'
+ WHEN var('b') THEN 'B'
+ WHEN var('c') THEN 'C'
+ ELSE 'no result'
+ END
+} {B}
+foreach {a b c} {0 1 1} break
+do_execsql_test e_expr-21.2.2 {
+ SELECT CASE WHEN var('a') THEN 'A'
+ WHEN var('b') THEN 'B'
+ WHEN var('c') THEN 'C'
+ ELSE 'no result'
+ END
+} {B}
+foreach {a b c} {0 0 1} break
+do_execsql_test e_expr-21.2.3 {
+ SELECT CASE WHEN var('a') THEN 'A'
+ WHEN var('b') THEN 'B'
+ WHEN var('c') THEN 'C'
+ ELSE 'no result'
+ END
+} {C}
+
+# EVIDENCE-OF: R-24227-04807 Or, if none of the WHEN expressions
+# evaluate to true, the result of evaluating the ELSE expression, if
+# any.
+#
+foreach {a b c} {0 0 0} break
+do_execsql_test e_expr-21.3.1 {
+ SELECT CASE WHEN var('a') THEN 'A'
+ WHEN var('b') THEN 'B'
+ WHEN var('c') THEN 'C'
+ ELSE 'no result'
+ END
+} {{no result}}
+
+# EVIDENCE-OF: R-14168-07579 If there is no ELSE expression and none of
+# the WHEN expressions are true, then the overall result is NULL.
+#
+db nullvalue null
+do_execsql_test e_expr-21.3.2 {
+ SELECT CASE WHEN var('a') THEN 'A'
+ WHEN var('b') THEN 'B'
+ WHEN var('c') THEN 'C'
+ END
+} {null}
+db nullvalue {}
+
+# EVIDENCE-OF: R-13943-13592 A NULL result is considered untrue when
+# evaluating WHEN terms.
+#
+do_execsql_test e_expr-21.4.1 {
+ SELECT CASE WHEN NULL THEN 'A' WHEN 1 THEN 'B' END
+} {B}
+do_execsql_test e_expr-21.4.2 {
+ SELECT CASE WHEN 0 THEN 'A' WHEN NULL THEN 'B' ELSE 'C' END
+} {C}
+
+# EVIDENCE-OF: R-38620-19499 In a CASE with a base expression, the base
+# expression is evaluated just once and the result is compared against
+# the evaluation of each WHEN expression from left to right.
+#
+# Note: This test case tests the "evaluated just once" part of the above
+# statement. Tests associated with the next two statements test that the
+# comparisons take place.
+#
+foreach {a b c} [list [expr 3] [expr 4] [expr 5]] break
+set ::varlist [list]
+do_execsql_test e_expr-22.1.1 {
+ SELECT CASE var('a') WHEN 1 THEN 'A' WHEN 2 THEN 'B' WHEN 3 THEN 'C' END
+} {C}
+do_test e_expr-22.1.2 { set ::varlist } {a}
+
+# EVIDENCE-OF: R-07667-49537 The result of the CASE expression is the
+# evaluation of the THEN expression that corresponds to the first WHEN
+# expression for which the comparison is true.
+#
+do_execsql_test e_expr-22.2.1 {
+ SELECT CASE 23 WHEN 1 THEN 'A' WHEN 23 THEN 'B' WHEN 23 THEN 'C' END
+} {B}
+do_execsql_test e_expr-22.2.2 {
+ SELECT CASE 1 WHEN 1 THEN 'A' WHEN 23 THEN 'B' WHEN 23 THEN 'C' END
+} {A}
+
+# EVIDENCE-OF: R-47543-32145 Or, if none of the WHEN expressions
+# evaluate to a value equal to the base expression, the result of
+# evaluating the ELSE expression, if any.
+#
+do_execsql_test e_expr-22.3.1 {
+ SELECT CASE 24 WHEN 1 THEN 'A' WHEN 23 THEN 'B' WHEN 23 THEN 'C' ELSE 'D' END
+} {D}
+
+# EVIDENCE-OF: R-54721-48557 If there is no ELSE expression and none of
+# the WHEN expressions produce a result equal to the base expression,
+# the overall result is NULL.
+#
+do_execsql_test e_expr-22.4.1 {
+ SELECT CASE 24 WHEN 1 THEN 'A' WHEN 23 THEN 'B' WHEN 23 THEN 'C' END
+} {{}}
+db nullvalue null
+do_execsql_test e_expr-22.4.2 {
+ SELECT CASE 24 WHEN 1 THEN 'A' WHEN 23 THEN 'B' WHEN 23 THEN 'C' END
+} {null}
+db nullvalue {}
+
+# EVIDENCE-OF: R-11479-62774 When comparing a base expression against a
+# WHEN expression, the same collating sequence, affinity, and
+# NULL-handling rules apply as if the base expression and WHEN
+# expression are respectively the left- and right-hand operands of an =
+# operator.
+#
+proc rev {str} {
+ set ret ""
+ set chars [split $str]
+ for {set i [expr [llength $chars]-1]} {$i>=0} {incr i -1} {
+ append ret [lindex $chars $i]
+ }
+ set ret
+}
+proc reverse {lhs rhs} {
+ string compare [rev $lhs] [ref $rhs]
+}
+db collate reverse reverse
+do_execsql_test e_expr-23.1.1 {
+ CREATE TABLE t1(
+ a TEXT COLLATE NOCASE,
+ b COLLATE REVERSE,
+ c INTEGER,
+ d BLOB
+ );
+ INSERT INTO t1 VALUES('abc', 'cba', 55, 34.5);
+} {}
+do_execsql_test e_expr-23.1.2 {
+ SELECT CASE a WHEN 'xyz' THEN 'A' WHEN 'AbC' THEN 'B' END FROM t1
+} {B}
+do_execsql_test e_expr-23.1.3 {
+ SELECT CASE 'AbC' WHEN 'abc' THEN 'A' WHEN a THEN 'B' END FROM t1
+} {B}
+do_execsql_test e_expr-23.1.4 {
+ SELECT CASE a WHEN b THEN 'A' ELSE 'B' END FROM t1
+} {B}
+do_execsql_test e_expr-23.1.5 {
+ SELECT CASE b WHEN a THEN 'A' ELSE 'B' END FROM t1
+} {A}
+do_execsql_test e_expr-23.1.6 {
+ SELECT CASE 55 WHEN '55' THEN 'A' ELSE 'B' END
+} {B}
+do_execsql_test e_expr-23.1.7 {
+ SELECT CASE c WHEN '55' THEN 'A' ELSE 'B' END FROM t1
+} {A}
+do_execsql_test e_expr-23.1.8 {
+ SELECT CASE '34.5' WHEN d THEN 'A' ELSE 'B' END FROM t1
+} {B}
+do_execsql_test e_expr-23.1.9 {
+ SELECT CASE NULL WHEN NULL THEN 'A' ELSE 'B' END
+} {B}
+
+# EVIDENCE-OF: R-37304-39405 If the base expression is NULL then the
+# result of the CASE is always the result of evaluating the ELSE
+# expression if it exists, or NULL if it does not.
+#
+do_execsql_test e_expr-24.1.1 {
+ SELECT CASE NULL WHEN 'abc' THEN 'A' WHEN 'def' THEN 'B' END;
+} {{}}
+do_execsql_test e_expr-24.1.2 {
+ SELECT CASE NULL WHEN 'abc' THEN 'A' WHEN 'def' THEN 'B' ELSE 'C' END;
+} {C}
+
+# EVIDENCE-OF: R-56280-17369 Both forms of the CASE expression use lazy,
+# or short-circuit, evaluation.
+#
+set varlist [list]
+foreach {a b c} {0 1 0} break
+do_execsql_test e_expr-25.1.1 {
+ SELECT CASE WHEN var('a') THEN 'A'
+ WHEN var('b') THEN 'B'
+ WHEN var('c') THEN 'C'
+ END
+} {B}
+do_test e_expr-25.1.2 { set ::varlist } {a b}
+set varlist [list]
+do_execsql_test e_expr-25.1.3 {
+ SELECT CASE '0' WHEN var('a') THEN 'A'
+ WHEN var('b') THEN 'B'
+ WHEN var('c') THEN 'C'
+ END
+} {A}
+do_test e_expr-25.1.4 { set ::varlist } {a}
+
+# EVIDENCE-OF: R-34773-62253 The only difference between the following
+# two CASE expressions is that the x expression is evaluated exactly
+# once in the first example but might be evaluated multiple times in the
+# second: CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END CASE WHEN
+# x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END
+#
+proc ceval {x} {
+ incr ::evalcount
+ return $x
+}
+db func ceval ceval
+set ::evalcount 0
+
+do_execsql_test e_expr-26.1.1 {
+ CREATE TABLE t2(x, w1, r1, w2, r2, r3);
+ INSERT INTO t2 VALUES(1, 1, 'R1', 2, 'R2', 'R3');
+ INSERT INTO t2 VALUES(2, 1, 'R1', 2, 'R2', 'R3');
+ INSERT INTO t2 VALUES(3, 1, 'R1', 2, 'R2', 'R3');
+} {}
+do_execsql_test e_expr-26.1.2 {
+ SELECT CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END FROM t2
+} {R1 R2 R3}
+do_execsql_test e_expr-26.1.3 {
+ SELECT CASE WHEN x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END FROM t2
+} {R1 R2 R3}
+
+do_execsql_test e_expr-26.1.4 {
+ SELECT CASE ceval(x) WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END FROM t2
+} {R1 R2 R3}
+do_test e_expr-26.1.5 { set ::evalcount } {3}
+set ::evalcount 0
+do_execsql_test e_expr-26.1.6 {
+ SELECT CASE
+ WHEN ceval(x)=w1 THEN r1
+ WHEN ceval(x)=w2 THEN r2
+ ELSE r3 END
+ FROM t2
+} {R1 R2 R3}
+do_test e_expr-26.1.6 { set ::evalcount } {5}
+
+
+#-------------------------------------------------------------------------
+# Test statements related to CAST expressions.
+#
+# EVIDENCE-OF: R-65079-31758 Application of a CAST expression is
+# different to application of a column affinity, as with a CAST
+# expression the storage class conversion is forced even if it is lossy
+# and irrreversible.
+#
+do_execsql_test e_expr-27.1.1 {
+ CREATE TABLE t3(a TEXT, b REAL, c INTEGER);
+ INSERT INTO t3 VALUES(X'555655', '1.23abc', 4.5);
+ SELECT typeof(a), a, typeof(b), b, typeof(c), c FROM t3;
+} {blob UVU text 1.23abc real 4.5}
+do_execsql_test e_expr-27.1.2 {
+ SELECT
+ typeof(CAST(X'555655' as TEXT)), CAST(X'555655' as TEXT),
+ typeof(CAST('1.23abc' as REAL)), CAST('1.23abc' as REAL),
+ typeof(CAST(4.5 as INTEGER)), CAST(4.5 as INTEGER)
+} {text UVU real 1.23 integer 4}
+
+# EVIDENCE-OF: R-27225-65050 If the value of <expr> is NULL, then
+# the result of the CAST expression is also NULL.
+#
+do_expr_test e_expr-27.2.1 { CAST(NULL AS integer) } null {}
+do_expr_test e_expr-27.2.2 { CAST(NULL AS text) } null {}
+do_expr_test e_expr-27.2.3 { CAST(NULL AS blob) } null {}
+do_expr_test e_expr-27.2.4 { CAST(NULL AS number) } null {}
+
+# EVIDENCE-OF: R-31076-23575 Casting a value to a <type-name> with
+# no affinity causes the value to be converted into a BLOB.
+#
+do_expr_test e_expr-27.3.1 { CAST('abc' AS blob) } blob abc
+do_expr_test e_expr-27.3.2 { CAST('def' AS shobblob_x) } blob def
+do_expr_test e_expr-27.3.3 { CAST('ghi' AS abbLOb10) } blob ghi
+
+# EVIDENCE-OF: R-22956-37754 Casting to a BLOB consists of first casting
+# the value to TEXT in the encoding of the database connection, then
+# interpreting the resulting byte sequence as a BLOB instead of as TEXT.
+#
+do_qexpr_test e_expr-27.4.1 { CAST('ghi' AS blob) } X'676869'
+do_qexpr_test e_expr-27.4.2 { CAST(456 AS blob) } X'343536'
+do_qexpr_test e_expr-27.4.3 { CAST(1.78 AS blob) } X'312E3738'
+rename db db2
+sqlite3 db :memory:
+ifcapable {utf16} {
+db eval { PRAGMA encoding = 'utf-16le' }
+do_qexpr_test e_expr-27.4.4 { CAST('ghi' AS blob) } X'670068006900'
+do_qexpr_test e_expr-27.4.5 { CAST(456 AS blob) } X'340035003600'
+do_qexpr_test e_expr-27.4.6 { CAST(1.78 AS blob) } X'31002E0037003800'
+}
+db close
+sqlite3 db :memory:
+db eval { PRAGMA encoding = 'utf-16be' }
+ifcapable {utf16} {
+do_qexpr_test e_expr-27.4.7 { CAST('ghi' AS blob) } X'006700680069'
+do_qexpr_test e_expr-27.4.8 { CAST(456 AS blob) } X'003400350036'
+do_qexpr_test e_expr-27.4.9 { CAST(1.78 AS blob) } X'0031002E00370038'
+}
+db close
+rename db2 db
+
+# EVIDENCE-OF: R-04207-37981 To cast a BLOB value to TEXT, the sequence
+# of bytes that make up the BLOB is interpreted as text encoded using
+# the database encoding.
+#
+do_expr_test e_expr-28.1.1 { CAST (X'676869' AS text) } text ghi
+do_expr_test e_expr-28.1.2 { CAST (X'670068006900' AS text) } text g
+rename db db2
+sqlite3 db :memory:
+db eval { PRAGMA encoding = 'utf-16le' }
+ifcapable {utf16} {
+do_expr_test e_expr-28.1.3 { CAST (X'676869' AS text) == 'ghi' } integer 0
+do_expr_test e_expr-28.1.4 { CAST (X'670068006900' AS text) } text ghi
+}
+db close
+rename db2 db
+
+# EVIDENCE-OF: R-22235-47006 Casting an INTEGER or REAL value into TEXT
+# renders the value as if via sqlite3_snprintf() except that the
+# resulting TEXT uses the encoding of the database connection.
+#
+do_expr_test e_expr-28.2.1 { CAST (1 AS text) } text 1
+do_expr_test e_expr-28.2.2 { CAST (45 AS text) } text 45
+do_expr_test e_expr-28.2.3 { CAST (-45 AS text) } text -45
+do_expr_test e_expr-28.2.4 { CAST (8.8 AS text) } text 8.8
+do_expr_test e_expr-28.2.5 { CAST (2.3e+5 AS text) } text 230000.0
+do_expr_test e_expr-28.2.6 { CAST (-2.3e-5 AS text) } text -2.3e-05
+do_expr_test e_expr-28.2.7 { CAST (0.0 AS text) } text 0.0
+do_expr_test e_expr-28.2.7 { CAST (0 AS text) } text 0
+
+# EVIDENCE-OF: R-26346-36443 When casting a BLOB value to a REAL, the
+# value is first converted to TEXT.
+#
+do_expr_test e_expr-29.1.1 { CAST (X'312E3233' AS REAL) } real 1.23
+do_expr_test e_expr-29.1.2 { CAST (X'3233302E30' AS REAL) } real 230.0
+do_expr_test e_expr-29.1.3 { CAST (X'2D392E3837' AS REAL) } real -9.87
+do_expr_test e_expr-29.1.4 { CAST (X'302E30303031' AS REAL) } real 0.0001
+rename db db2
+sqlite3 db :memory:
+ifcapable {utf16} {
+db eval { PRAGMA encoding = 'utf-16le' }
+do_expr_test e_expr-29.1.5 {
+ CAST (X'31002E0032003300' AS REAL) } real 1.23
+do_expr_test e_expr-29.1.6 {
+ CAST (X'3200330030002E003000' AS REAL) } real 230.0
+do_expr_test e_expr-29.1.7 {
+ CAST (X'2D0039002E0038003700' AS REAL) } real -9.87
+do_expr_test e_expr-29.1.8 {
+ CAST (X'30002E003000300030003100' AS REAL) } real 0.0001
+}
+db close
+rename db2 db
+
+# EVIDENCE-OF: R-54898-34554 When casting a TEXT value to REAL, the
+# longest possible prefix of the value that can be interpreted as a real
+# number is extracted from the TEXT value and the remainder ignored.
+#
+do_expr_test e_expr-29.2.1 { CAST('1.23abcd' AS REAL) } real 1.23
+do_expr_test e_expr-29.2.2 { CAST('1.45.23abcd' AS REAL) } real 1.45
+do_expr_test e_expr-29.2.3 { CAST('-2.12e-01ABC' AS REAL) } real -0.212
+do_expr_test e_expr-29.2.4 { CAST('1 2 3 4' AS REAL) } real 1.0
+
+# EVIDENCE-OF: R-11321-47427 Any leading spaces in the TEXT value are
+# ignored when converging from TEXT to REAL.
+#
+do_expr_test e_expr-29.3.1 { CAST(' 1.23abcd' AS REAL) } real 1.23
+do_expr_test e_expr-29.3.2 { CAST(' 1.45.23abcd' AS REAL) } real 1.45
+do_expr_test e_expr-29.3.3 { CAST(' -2.12e-01ABC' AS REAL) } real -0.212
+do_expr_test e_expr-29.3.4 { CAST(' 1 2 3 4' AS REAL) } real 1.0
+
+# EVIDENCE-OF: R-22662-28218 If there is no prefix that can be
+# interpreted as a real number, the result of the conversion is 0.0.
+#
+do_expr_test e_expr-29.4.1 { CAST('' AS REAL) } real 0.0
+do_expr_test e_expr-29.4.2 { CAST('not a number' AS REAL) } real 0.0
+do_expr_test e_expr-29.4.3 { CAST('XXI' AS REAL) } real 0.0
+
+# EVIDENCE-OF: R-21829-14563 When casting a BLOB value to INTEGER, the
+# value is first converted to TEXT.
+#
+do_expr_test e_expr-30.1.1 { CAST(X'313233' AS INTEGER) } integer 123
+do_expr_test e_expr-30.1.2 { CAST(X'2D363738' AS INTEGER) } integer -678
+do_expr_test e_expr-30.1.3 {
+ CAST(X'31303030303030' AS INTEGER)
+} integer 1000000
+do_expr_test e_expr-30.1.4 {
+ CAST(X'2D31313235383939393036383432363234' AS INTEGER)
+} integer -1125899906842624
+
+rename db db2
+sqlite3 db :memory:
+ifcapable {utf16} {
+execsql { PRAGMA encoding = 'utf-16be' }
+do_expr_test e_expr-30.1.5 { CAST(X'003100320033' AS INTEGER) } integer 123
+do_expr_test e_expr-30.1.6 { CAST(X'002D003600370038' AS INTEGER) } integer -678
+do_expr_test e_expr-30.1.7 {
+ CAST(X'0031003000300030003000300030' AS INTEGER)
+} integer 1000000
+do_expr_test e_expr-30.1.8 {
+ CAST(X'002D0031003100320035003800390039003900300036003800340032003600320034' AS INTEGER)
+} integer -1125899906842624
+}
+db close
+rename db2 db
+
+# EVIDENCE-OF: R-47612-45842 When casting a TEXT value to INTEGER, the
+# longest possible prefix of the value that can be interpreted as an
+# integer number is extracted from the TEXT value and the remainder
+# ignored.
+#
+do_expr_test e_expr-30.2.1 { CAST('123abcd' AS INT) } integer 123
+do_expr_test e_expr-30.2.2 { CAST('14523abcd' AS INT) } integer 14523
+do_expr_test e_expr-30.2.3 { CAST('-2.12e-01ABC' AS INT) } integer -2
+do_expr_test e_expr-30.2.4 { CAST('1 2 3 4' AS INT) } integer 1
+
+# EVIDENCE-OF: R-34400-33772 Any leading spaces in the TEXT value when
+# converting from TEXT to INTEGER are ignored.
+#
+do_expr_test e_expr-30.3.1 { CAST(' 123abcd' AS INT) } integer 123
+do_expr_test e_expr-30.3.2 { CAST(' 14523abcd' AS INT) } integer 14523
+do_expr_test e_expr-30.3.3 { CAST(' -2.12e-01ABC' AS INT) } integer -2
+do_expr_test e_expr-30.3.4 { CAST(' 1 2 3 4' AS INT) } integer 1
+
+# EVIDENCE-OF: R-43164-44276 If there is no prefix that can be
+# interpreted as an integer number, the result of the conversion is 0.
+#
+do_expr_test e_expr-30.4.1 { CAST('' AS INTEGER) } integer 0
+do_expr_test e_expr-30.4.2 { CAST('not a number' AS INTEGER) } integer 0
+do_expr_test e_expr-30.4.3 { CAST('XXI' AS INTEGER) } integer 0
+
+# EVIDENCE-OF: R-00741-38776 A cast of a REAL value into an INTEGER will
+# truncate the fractional part of the REAL.
+#
+do_expr_test e_expr-31.1.1 { CAST(3.14159 AS INTEGER) } integer 3
+do_expr_test e_expr-31.1.2 { CAST(1.99999 AS INTEGER) } integer 1
+do_expr_test e_expr-31.1.3 { CAST(-1.99999 AS INTEGER) } integer -1
+do_expr_test e_expr-31.1.4 { CAST(-0.99999 AS INTEGER) } integer 0
+
+# EVIDENCE-OF: R-49503-28105 If a REAL is too large to be represented as
+# an INTEGER then the result of the cast is the largest negative
+# integer: -9223372036854775808.
+#
+do_expr_test e_expr-31.2.1 { CAST(2e+50 AS INT) } integer -9223372036854775808
+do_expr_test e_expr-31.2.2 { CAST(-2e+50 AS INT) } integer -9223372036854775808
+do_expr_test e_expr-31.2.3 {
+ CAST(-9223372036854775809.0 AS INT)
+} integer -9223372036854775808
+do_expr_test e_expr-31.2.4 {
+ CAST(9223372036854775809.0 AS INT)
+} integer -9223372036854775808
+
+
+# EVIDENCE-OF: R-09295-61337 Casting a TEXT or BLOB value into NUMERIC
+# first does a forced conversion into REAL but then further converts the
+# result into INTEGER if and only if the conversion from REAL to INTEGER
+# is lossless and reversible.
+#
+do_expr_test e_expr-32.1.1 { CAST('45' AS NUMERIC) } integer 45
+do_expr_test e_expr-32.1.2 { CAST('45.0' AS NUMERIC) } integer 45
+do_expr_test e_expr-32.1.3 { CAST('45.2' AS NUMERIC) } real 45.2
+do_expr_test e_expr-32.1.4 { CAST('11abc' AS NUMERIC) } integer 11
+do_expr_test e_expr-32.1.5 { CAST('11.1abc' AS NUMERIC) } real 11.1
+
+# EVIDENCE-OF: R-30347-18702 Casting a REAL or INTEGER value to NUMERIC
+# is a no-op, even if a real value could be losslessly converted to an
+# integer.
+#
+do_expr_test e_expr-32.2.1 { CAST(13.0 AS NUMERIC) } real 13.0
+do_expr_test e_expr-32.2.2 { CAST(13.5 AS NUMERIC) } real 13.5
+
+do_expr_test e_expr-32.2.3 {
+ CAST(-9223372036854775808 AS NUMERIC)
+} integer -9223372036854775808
+do_expr_test e_expr-32.2.4 {
+ CAST(9223372036854775807 AS NUMERIC)
+} integer 9223372036854775807
+
+# EVIDENCE-OF: R-64550-29191 Note that the result from casting any
+# non-BLOB value into a BLOB and the result from casting any BLOB value
+# into a non-BLOB value may be different depending on whether the
+# database encoding is UTF-8, UTF-16be, or UTF-16le.
+#
+ifcapable {utf16} {
+sqlite3 db1 :memory: ; db1 eval { PRAGMA encoding = 'utf-8' }
+sqlite3 db2 :memory: ; db2 eval { PRAGMA encoding = 'utf-16le' }
+sqlite3 db3 :memory: ; db3 eval { PRAGMA encoding = 'utf-16be' }
+foreach {tn castexpr differs} {
+ 1 { CAST(123 AS BLOB) } 1
+ 2 { CAST('' AS BLOB) } 0
+ 3 { CAST('abcd' AS BLOB) } 1
+
+ 4 { CAST(X'abcd' AS TEXT) } 1
+ 5 { CAST(X'' AS TEXT) } 0
+} {
+ set r1 [db1 eval "SELECT typeof($castexpr), quote($castexpr)"]
+ set r2 [db2 eval "SELECT typeof($castexpr), quote($castexpr)"]
+ set r3 [db3 eval "SELECT typeof($castexpr), quote($castexpr)"]
+
+ if {$differs} {
+ set res [expr {$r1!=$r2 && $r2!=$r3}]
+ } else {
+ set res [expr {$r1==$r2 && $r2==$r3}]
+ }
+
+ do_test e_expr-33.1.$tn {set res} 1
+}
+db1 close
+db2 close
+db3 close
+}
+
+#-------------------------------------------------------------------------
+# Test statements related to the EXISTS and NOT EXISTS operators.
+#
+catch { db close }
+forcedelete test.db
+sqlite3 db test.db
+
+do_execsql_test e_expr-34.1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(NULL, 2);
+ INSERT INTO t1 VALUES(1, NULL);
+ INSERT INTO t1 VALUES(NULL, NULL);
+} {}
+
+# EVIDENCE-OF: R-25588-27181 The EXISTS operator always evaluates to one
+# of the integer values 0 and 1.
+#
+# This statement is not tested by itself. Instead, all e_expr-34.* tests
+# following this point explicitly test that specific invocations of EXISTS
+# return either integer 0 or integer 1.
+#
+
+# EVIDENCE-OF: R-58553-63740 If executing the SELECT statement specified
+# as the right-hand operand of the EXISTS operator would return one or
+# more rows, then the EXISTS operator evaluates to 1.
+#
+foreach {tn expr} {
+ 1 { EXISTS ( SELECT a FROM t1 ) }
+ 2 { EXISTS ( SELECT b FROM t1 ) }
+ 3 { EXISTS ( SELECT 24 ) }
+ 4 { EXISTS ( SELECT NULL ) }
+ 5 { EXISTS ( SELECT a FROM t1 WHERE a IS NULL ) }
+} {
+ do_expr_test e_expr-34.2.$tn $expr integer 1
+}
+
+# EVIDENCE-OF: R-19673-40972 If executing the SELECT would return no
+# rows at all, then the EXISTS operator evaluates to 0.
+#
+foreach {tn expr} {
+ 1 { EXISTS ( SELECT a FROM t1 WHERE 0) }
+ 2 { EXISTS ( SELECT b FROM t1 WHERE a = 5) }
+ 3 { EXISTS ( SELECT 24 WHERE 0) }
+ 4 { EXISTS ( SELECT NULL WHERE 1=2) }
+} {
+ do_expr_test e_expr-34.3.$tn $expr integer 0
+}
+
+# EVIDENCE-OF: R-35109-49139 The number of columns in each row returned
+# by the SELECT statement (if any) and the specific values returned have
+# no effect on the results of the EXISTS operator.
+#
+foreach {tn expr res} {
+ 1 { EXISTS ( SELECT * FROM t1 ) } 1
+ 2 { EXISTS ( SELECT *, *, * FROM t1 ) } 1
+ 3 { EXISTS ( SELECT 24, 25 ) } 1
+ 4 { EXISTS ( SELECT NULL, NULL, NULL ) } 1
+ 5 { EXISTS ( SELECT a,b,a||b FROM t1 WHERE a IS NULL ) } 1
+
+ 6 { EXISTS ( SELECT a, a FROM t1 WHERE 0) } 0
+ 7 { EXISTS ( SELECT b, b, a FROM t1 WHERE a = 5) } 0
+ 8 { EXISTS ( SELECT 24, 46, 89 WHERE 0) } 0
+ 9 { EXISTS ( SELECT NULL, NULL WHERE 1=2) } 0
+} {
+ do_expr_test e_expr-34.4.$tn $expr integer $res
+}
+
+# EVIDENCE-OF: R-10645-12439 In particular, rows containing NULL values
+# are not handled any differently from rows without NULL values.
+#
+foreach {tn e1 e2} {
+ 1 { EXISTS (SELECT 'not null') } { EXISTS (SELECT NULL) }
+ 2 { EXISTS (SELECT NULL FROM t1) } { EXISTS (SELECT 'bread' FROM t1) }
+} {
+ set res [db one "SELECT $e1"]
+ do_expr_test e_expr-34.5.${tn}a $e1 integer $res
+ do_expr_test e_expr-34.5.${tn}b $e2 integer $res
+}
+
+#-------------------------------------------------------------------------
+# Test statements related to scalar sub-queries.
+#
+
+catch { db close }
+forcedelete test.db
+sqlite3 db test.db
+do_test e_expr-35.0 {
+ execsql {
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES('one', 'two');
+ INSERT INTO t2 VALUES('three', NULL);
+ INSERT INTO t2 VALUES(4, 5.0);
+ }
+} {}
+
+# EVIDENCE-OF: R-00980-39256 A SELECT statement enclosed in parentheses
+# may appear as a scalar quantity.
+#
+# EVIDENCE-OF: R-56294-03966 All types of SELECT statement, including
+# aggregate and compound SELECT queries (queries with keywords like
+# UNION or EXCEPT) are allowed as scalar subqueries.
+#
+do_expr_test e_expr-35.1.1 { (SELECT 35) } integer 35
+do_expr_test e_expr-35.1.2 { (SELECT NULL) } null {}
+
+do_expr_test e_expr-35.1.3 { (SELECT count(*) FROM t2) } integer 3
+do_expr_test e_expr-35.1.4 { (SELECT 4 FROM t2) } integer 4
+
+do_expr_test e_expr-35.1.5 {
+ (SELECT b FROM t2 UNION SELECT a+1 FROM t2)
+} null {}
+do_expr_test e_expr-35.1.6 {
+ (SELECT a FROM t2 UNION SELECT COALESCE(b, 55) FROM t2 ORDER BY 1)
+} integer 4
+
+# EVIDENCE-OF: R-46899-53765 A SELECT used as a scalar quantity must
+# return a result set with a single column.
+#
+# The following block tests that errors are returned in a bunch of cases
+# where a subquery returns more than one column.
+#
+set M {only a single result allowed for a SELECT that is part of an expression}
+foreach {tn sql} {
+ 1 { SELECT (SELECT * FROM t2 UNION SELECT a+1, b+1 FROM t2) }
+ 2 { SELECT (SELECT * FROM t2 UNION SELECT a+1, b+1 FROM t2 ORDER BY 1) }
+ 3 { SELECT (SELECT 1, 2) }
+ 4 { SELECT (SELECT NULL, NULL, NULL) }
+ 5 { SELECT (SELECT * FROM t2) }
+ 6 { SELECT (SELECT * FROM (SELECT 1, 2, 3)) }
+} {
+ do_catchsql_test e_expr-35.2.$tn $sql [list 1 $M]
+}
+
+# EVIDENCE-OF: R-35764-28041 The result of the expression is the value
+# of the only column in the first row returned by the SELECT statement.
+#
+# EVIDENCE-OF: R-41898-06686 If the SELECT yields more than one result
+# row, all rows after the first are ignored.
+#
+do_execsql_test e_expr-36.3.1 {
+ CREATE TABLE t4(x, y);
+ INSERT INTO t4 VALUES(1, 'one');
+ INSERT INTO t4 VALUES(2, 'two');
+ INSERT INTO t4 VALUES(3, 'three');
+} {}
+
+foreach {tn expr restype resval} {
+ 2 { ( SELECT x FROM t4 ORDER BY x ) } integer 1
+ 3 { ( SELECT x FROM t4 ORDER BY y ) } integer 1
+ 4 { ( SELECT x FROM t4 ORDER BY x DESC ) } integer 3
+ 5 { ( SELECT x FROM t4 ORDER BY y DESC ) } integer 2
+ 6 { ( SELECT y FROM t4 ORDER BY y DESC ) } text two
+
+ 7 { ( SELECT sum(x) FROM t4 ) } integer 6
+ 8 { ( SELECT group_concat(y,'') FROM t4 ) } text onetwothree
+ 9 { ( SELECT max(x) FROM t4 WHERE y LIKE '___') } integer 2
+
+} {
+ do_expr_test e_expr-36.3.$tn $expr $restype $resval
+}
+
+# EVIDENCE-OF: R-25492-41572 If the SELECT yields no rows, then the
+# value of the expression is NULL.
+#
+foreach {tn expr} {
+ 1 { ( SELECT x FROM t4 WHERE x>3 ORDER BY x ) }
+ 2 { ( SELECT x FROM t4 WHERE y<'one' ORDER BY y ) }
+} {
+ do_expr_test e_expr-36.4.$tn $expr null {}
+}
+
+
+finish_test
diff --git a/test/e_fkey.test b/test/e_fkey.test
new file mode 100644
index 0000000..ae789d5
--- /dev/null
+++ b/test/e_fkey.test
@@ -0,0 +1,3014 @@
+# 2009 October 7
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify the "testable statements" in the
+# foreignkeys.in document.
+#
+# The tests in this file are arranged to mirror the structure of
+# foreignkey.in, with one exception: The statements in section 2, which
+# deals with enabling/disabling foreign key support, is tested first,
+# before section 1. This is because some statements in section 2 deal
+# with builds that do not include complete foreign key support (because
+# either SQLITE_OMIT_TRIGGER or SQLITE_OMIT_FOREIGN_KEY was defined
+# at build time).
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc eqp {sql {db db}} { uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db }
+
+###########################################################################
+### SECTION 2: Enabling Foreign Key Support
+###########################################################################
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-33710-56344 In order to use foreign key constraints in
+# SQLite, the library must be compiled with neither
+# SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER defined.
+#
+ifcapable trigger&&foreignkey {
+ do_test e_fkey-1 {
+ execsql {
+ PRAGMA foreign_keys = ON;
+ CREATE TABLE p(i PRIMARY KEY);
+ CREATE TABLE c(j REFERENCES p ON UPDATE CASCADE);
+ INSERT INTO p VALUES('hello');
+ INSERT INTO c VALUES('hello');
+ UPDATE p SET i = 'world';
+ SELECT * FROM c;
+ }
+ } {world}
+}
+
+#-------------------------------------------------------------------------
+# Test the effects of defining OMIT_TRIGGER but not OMIT_FOREIGN_KEY.
+#
+# EVIDENCE-OF: R-44697-61543 If SQLITE_OMIT_TRIGGER is defined but
+# SQLITE_OMIT_FOREIGN_KEY is not, then SQLite behaves as it did prior to
+# version 3.6.19 - foreign key definitions are parsed and may be queried
+# using PRAGMA foreign_key_list, but foreign key constraints are not
+# enforced.
+#
+# Specifically, test that "PRAGMA foreign_keys" is a no-op in this case.
+# When using the pragma to query the current setting, 0 rows are returned.
+#
+# EVIDENCE-OF: R-22567-44039 The PRAGMA foreign_keys command is a no-op
+# in this configuration.
+#
+# EVIDENCE-OF: R-41784-13339 Tip: If the command "PRAGMA foreign_keys"
+# returns no data instead of a single row containing "0" or "1", then
+# the version of SQLite you are using does not support foreign keys
+# (either because it is older than 3.6.19 or because it was compiled
+# with SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER defined).
+#
+reset_db
+ifcapable !trigger&&foreignkey {
+ do_test e_fkey-2.1 {
+ execsql {
+ PRAGMA foreign_keys = ON;
+ CREATE TABLE p(i PRIMARY KEY);
+ CREATE TABLE c(j REFERENCES p ON UPDATE CASCADE);
+ INSERT INTO p VALUES('hello');
+ INSERT INTO c VALUES('hello');
+ UPDATE p SET i = 'world';
+ SELECT * FROM c;
+ }
+ } {hello}
+ do_test e_fkey-2.2 {
+ execsql { PRAGMA foreign_key_list(c) }
+ } {0 0 p j {} CASCADE {NO ACTION} NONE}
+ do_test e_fkey-2.3 {
+ execsql { PRAGMA foreign_keys }
+ } {}
+}
+
+
+#-------------------------------------------------------------------------
+# Test the effects of defining OMIT_FOREIGN_KEY.
+#
+# EVIDENCE-OF: R-58428-36660 If OMIT_FOREIGN_KEY is defined, then
+# foreign key definitions cannot even be parsed (attempting to specify a
+# foreign key definition is a syntax error).
+#
+# Specifically, test that foreign key constraints cannot even be parsed
+# in such a build.
+#
+reset_db
+ifcapable !foreignkey {
+ do_test e_fkey-3.1 {
+ execsql { CREATE TABLE p(i PRIMARY KEY) }
+ catchsql { CREATE TABLE c(j REFERENCES p ON UPDATE CASCADE) }
+ } {1 {near "ON": syntax error}}
+ do_test e_fkey-3.2 {
+ # This is allowed, as in this build, "REFERENCES" is not a keyword.
+ # The declared datatype of column j is "REFERENCES p".
+ execsql { CREATE TABLE c(j REFERENCES p) }
+ } {}
+ do_test e_fkey-3.3 {
+ execsql { PRAGMA table_info(c) }
+ } {0 j {REFERENCES p} 0 {} 0}
+ do_test e_fkey-3.4 {
+ execsql { PRAGMA foreign_key_list(c) }
+ } {}
+ do_test e_fkey-3.5 {
+ execsql { PRAGMA foreign_keys }
+ } {}
+}
+
+ifcapable !foreignkey||!trigger { finish_test ; return }
+reset_db
+
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-07280-60510 Assuming the library is compiled with
+# foreign key constraints enabled, it must still be enabled by the
+# application at runtime, using the PRAGMA foreign_keys command.
+#
+# This also tests that foreign key constraints are disabled by default.
+#
+# EVIDENCE-OF: R-59578-04990 Foreign key constraints are disabled by
+# default (for backwards compatibility), so must be enabled separately
+# for each database connection separately.
+#
+drop_all_tables
+do_test e_fkey-4.1 {
+ execsql {
+ CREATE TABLE p(i PRIMARY KEY);
+ CREATE TABLE c(j REFERENCES p ON UPDATE CASCADE);
+ INSERT INTO p VALUES('hello');
+ INSERT INTO c VALUES('hello');
+ UPDATE p SET i = 'world';
+ SELECT * FROM c;
+ }
+} {hello}
+do_test e_fkey-4.2 {
+ execsql {
+ DELETE FROM c;
+ DELETE FROM p;
+ PRAGMA foreign_keys = ON;
+ INSERT INTO p VALUES('hello');
+ INSERT INTO c VALUES('hello');
+ UPDATE p SET i = 'world';
+ SELECT * FROM c;
+ }
+} {world}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-15278-54456 The application can can also use a PRAGMA
+# foreign_keys statement to determine if foreign keys are currently
+# enabled.
+#
+# This also tests the example code in section 2 of foreignkeys.in.
+#
+# EVIDENCE-OF: R-11255-19907
+#
+reset_db
+do_test e_fkey-5.1 {
+ execsql { PRAGMA foreign_keys }
+} {0}
+do_test e_fkey-5.2 {
+ execsql {
+ PRAGMA foreign_keys = ON;
+ PRAGMA foreign_keys;
+ }
+} {1}
+do_test e_fkey-5.3 {
+ execsql {
+ PRAGMA foreign_keys = OFF;
+ PRAGMA foreign_keys;
+ }
+} {0}
+
+#-------------------------------------------------------------------------
+# Test that it is not possible to enable or disable foreign key support
+# while not in auto-commit mode.
+#
+# EVIDENCE-OF: R-46649-58537 It is not possible to enable or disable
+# foreign key constraints in the middle of a multi-statement transaction
+# (when SQLite is not in autocommit mode). Attempting to do so does not
+# return an error; it simply has no effect.
+#
+reset_db
+do_test e_fkey-6.1 {
+ execsql {
+ PRAGMA foreign_keys = ON;
+ CREATE TABLE t1(a UNIQUE, b);
+ CREATE TABLE t2(c, d REFERENCES t1(a));
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(2, 1);
+ BEGIN;
+ PRAGMA foreign_keys = OFF;
+ }
+ catchsql {
+ DELETE FROM t1
+ }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-6.2 {
+ execsql { PRAGMA foreign_keys }
+} {1}
+do_test e_fkey-6.3 {
+ execsql {
+ COMMIT;
+ PRAGMA foreign_keys = OFF;
+ BEGIN;
+ PRAGMA foreign_keys = ON;
+ DELETE FROM t1;
+ PRAGMA foreign_keys;
+ }
+} {0}
+do_test e_fkey-6.4 {
+ execsql COMMIT
+} {}
+
+###########################################################################
+### SECTION 1: Introduction to Foreign Key Constraints
+###########################################################################
+execsql "PRAGMA foreign_keys = ON"
+
+#-------------------------------------------------------------------------
+# Verify that the syntax in the first example in section 1 is valid.
+#
+# EVIDENCE-OF: R-04042-24825 To do so, a foreign key definition may be
+# added by modifying the declaration of the track table to the
+# following: CREATE TABLE track( trackid INTEGER, trackname TEXT,
+# trackartist INTEGER, FOREIGN KEY(trackartist) REFERENCES
+# artist(artistid) );
+#
+do_test e_fkey-7.1 {
+ execsql {
+ CREATE TABLE artist(
+ artistid INTEGER PRIMARY KEY,
+ artistname TEXT
+ );
+ CREATE TABLE track(
+ trackid INTEGER,
+ trackname TEXT,
+ trackartist INTEGER,
+ FOREIGN KEY(trackartist) REFERENCES artist(artistid)
+ );
+ }
+} {}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-61362-32087 Attempting to insert a row into the track
+# table that does not correspond to any row in the artist table will
+# fail,
+#
+do_test e_fkey-8.1 {
+ catchsql { INSERT INTO track VALUES(1, 'track 1', 1) }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-8.2 {
+ execsql { INSERT INTO artist VALUES(2, 'artist 1') }
+ catchsql { INSERT INTO track VALUES(1, 'track 1', 1) }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-8.2 {
+ execsql { INSERT INTO track VALUES(1, 'track 1', 2) }
+} {}
+
+#-------------------------------------------------------------------------
+# Attempting to delete a row from the 'artist' table while there are
+# dependent rows in the track table also fails.
+#
+# EVIDENCE-OF: R-24401-52400 as will attempting to delete a row from the
+# artist table when there exist dependent rows in the track table
+#
+do_test e_fkey-9.1 {
+ catchsql { DELETE FROM artist WHERE artistid = 2 }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-9.2 {
+ execsql {
+ DELETE FROM track WHERE trackartist = 2;
+ DELETE FROM artist WHERE artistid = 2;
+ }
+} {}
+
+#-------------------------------------------------------------------------
+# If the foreign key column (trackartist) in table 'track' is set to NULL,
+# there is no requirement for a matching row in the 'artist' table.
+#
+# EVIDENCE-OF: R-23980-48859 There is one exception: if the foreign key
+# column in the track table is NULL, then no corresponding entry in the
+# artist table is required.
+#
+do_test e_fkey-10.1 {
+ execsql {
+ INSERT INTO track VALUES(1, 'track 1', NULL);
+ INSERT INTO track VALUES(2, 'track 2', NULL);
+ }
+} {}
+do_test e_fkey-10.2 {
+ execsql { SELECT * FROM artist }
+} {}
+do_test e_fkey-10.3 {
+ # Setting the trackid to a non-NULL value fails, of course.
+ catchsql { UPDATE track SET trackartist = 5 WHERE trackid = 1 }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-10.4 {
+ execsql {
+ INSERT INTO artist VALUES(5, 'artist 5');
+ UPDATE track SET trackartist = 5 WHERE trackid = 1;
+ }
+ catchsql { DELETE FROM artist WHERE artistid = 5}
+} {1 {foreign key constraint failed}}
+do_test e_fkey-10.5 {
+ execsql {
+ UPDATE track SET trackartist = NULL WHERE trackid = 1;
+ DELETE FROM artist WHERE artistid = 5;
+ }
+} {}
+
+#-------------------------------------------------------------------------
+# Test that the following is true fo all rows in the track table:
+#
+# trackartist IS NULL OR
+# EXISTS(SELECT 1 FROM artist WHERE artistid=trackartist)
+#
+# EVIDENCE-OF: R-52486-21352 Expressed in SQL, this means that for every
+# row in the track table, the following expression evaluates to true:
+# trackartist IS NULL OR EXISTS(SELECT 1 FROM artist WHERE
+# artistid=trackartist)
+
+# This procedure executes a test case to check that statement
+# R-52486-21352 is true after executing the SQL statement passed.
+# as the second argument.
+proc test_r52486_21352 {tn sql} {
+ set res [catchsql $sql]
+ set results {
+ {0 {}}
+ {1 {PRIMARY KEY must be unique}}
+ {1 {foreign key constraint failed}}
+ }
+ if {[lsearch $results $res]<0} {
+ error $res
+ }
+
+ do_test e_fkey-11.$tn {
+ execsql {
+ SELECT count(*) FROM track WHERE NOT (
+ trackartist IS NULL OR
+ EXISTS(SELECT 1 FROM artist WHERE artistid=trackartist)
+ )
+ }
+ } {0}
+}
+
+# Execute a series of random INSERT, UPDATE and DELETE operations
+# (some of which may fail due to FK or PK constraint violations) on
+# the two tables in the example schema. Test that R-52486-21352
+# is true after executing each operation.
+#
+set Template {
+ {INSERT INTO track VALUES($t, 'track $t', $a)}
+ {DELETE FROM track WHERE trackid = $t}
+ {UPDATE track SET trackartist = $a WHERE trackid = $t}
+ {INSERT INTO artist VALUES($a, 'artist $a')}
+ {DELETE FROM artist WHERE artistid = $a}
+ {UPDATE artist SET artistid = $a2 WHERE artistid = $a}
+}
+for {set i 0} {$i < 500} {incr i} {
+ set a [expr int(rand()*10)]
+ set a2 [expr int(rand()*10)]
+ set t [expr int(rand()*50)]
+ set sql [subst [lindex $Template [expr int(rand()*6)]]]
+
+ test_r52486_21352 $i $sql
+}
+
+#-------------------------------------------------------------------------
+# Check that a NOT NULL constraint can be added to the example schema
+# to prohibit NULL child keys from being inserted.
+#
+# EVIDENCE-OF: R-42412-59321 Tip: If the application requires a stricter
+# relationship between artist and track, where NULL values are not
+# permitted in the trackartist column, simply add the appropriate "NOT
+# NULL" constraint to the schema.
+#
+drop_all_tables
+do_test e_fkey-12.1 {
+ execsql {
+ CREATE TABLE artist(
+ artistid INTEGER PRIMARY KEY,
+ artistname TEXT
+ );
+ CREATE TABLE track(
+ trackid INTEGER,
+ trackname TEXT,
+ trackartist INTEGER NOT NULL,
+ FOREIGN KEY(trackartist) REFERENCES artist(artistid)
+ );
+ }
+} {}
+do_test e_fkey-12.2 {
+ catchsql { INSERT INTO track VALUES(14, 'Mr. Bojangles', NULL) }
+} {1 {track.trackartist may not be NULL}}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-16127-35442
+#
+# Test an example from foreignkeys.html.
+#
+drop_all_tables
+do_test e_fkey-13.1 {
+ execsql {
+ CREATE TABLE artist(
+ artistid INTEGER PRIMARY KEY,
+ artistname TEXT
+ );
+ CREATE TABLE track(
+ trackid INTEGER,
+ trackname TEXT,
+ trackartist INTEGER,
+ FOREIGN KEY(trackartist) REFERENCES artist(artistid)
+ );
+ INSERT INTO artist VALUES(1, 'Dean Martin');
+ INSERT INTO artist VALUES(2, 'Frank Sinatra');
+ INSERT INTO track VALUES(11, 'That''s Amore', 1);
+ INSERT INTO track VALUES(12, 'Christmas Blues', 1);
+ INSERT INTO track VALUES(13, 'My Way', 2);
+ }
+} {}
+do_test e_fkey-13.2 {
+ catchsql { INSERT INTO track VALUES(14, 'Mr. Bojangles', 3) }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-13.3 {
+ execsql { INSERT INTO track VALUES(14, 'Mr. Bojangles', NULL) }
+} {}
+do_test e_fkey-13.4 {
+ catchsql {
+ UPDATE track SET trackartist = 3 WHERE trackname = 'Mr. Bojangles';
+ }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-13.5 {
+ execsql {
+ INSERT INTO artist VALUES(3, 'Sammy Davis Jr.');
+ UPDATE track SET trackartist = 3 WHERE trackname = 'Mr. Bojangles';
+ INSERT INTO track VALUES(15, 'Boogie Woogie', 3);
+ }
+} {}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-15958-50233
+#
+# Test the second example from the first section of foreignkeys.html.
+#
+do_test e_fkey-14.1 {
+ catchsql {
+ DELETE FROM artist WHERE artistname = 'Frank Sinatra';
+ }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-14.2 {
+ execsql {
+ DELETE FROM track WHERE trackname = 'My Way';
+ DELETE FROM artist WHERE artistname = 'Frank Sinatra';
+ }
+} {}
+do_test e_fkey-14.3 {
+ catchsql {
+ UPDATE artist SET artistid=4 WHERE artistname = 'Dean Martin';
+ }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-14.4 {
+ execsql {
+ DELETE FROM track WHERE trackname IN('That''s Amore', 'Christmas Blues');
+ UPDATE artist SET artistid=4 WHERE artistname = 'Dean Martin';
+ }
+} {}
+
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-56032-24923 The foreign key constraint is satisfied if
+# for each row in the child table either one or more of the child key
+# columns are NULL, or there exists a row in the parent table for which
+# each parent key column contains a value equal to the value in its
+# associated child key column.
+#
+# Test also that the usual comparison rules are used when testing if there
+# is a matching row in the parent table of a foreign key constraint.
+#
+# EVIDENCE-OF: R-57765-12380 In the above paragraph, the term "equal"
+# means equal when values are compared using the rules specified here.
+#
+drop_all_tables
+do_test e_fkey-15.1 {
+ execsql {
+ CREATE TABLE par(p PRIMARY KEY);
+ CREATE TABLE chi(c REFERENCES par);
+
+ INSERT INTO par VALUES(1);
+ INSERT INTO par VALUES('1');
+ INSERT INTO par VALUES(X'31');
+ SELECT typeof(p) FROM par;
+ }
+} {integer text blob}
+
+proc test_efkey_45 {tn isError sql} {
+ do_test e_fkey-15.$tn.1 "
+ catchsql {$sql}
+ " [lindex {{0 {}} {1 {foreign key constraint failed}}} $isError]
+
+ do_test e_fkey-15.$tn.2 {
+ execsql {
+ SELECT * FROM chi WHERE c IS NOT NULL AND c NOT IN (SELECT p FROM par)
+ }
+ } {}
+}
+
+test_efkey_45 1 0 "INSERT INTO chi VALUES(1)"
+test_efkey_45 2 1 "INSERT INTO chi VALUES('1.0')"
+test_efkey_45 3 0 "INSERT INTO chi VALUES('1')"
+test_efkey_45 4 1 "DELETE FROM par WHERE p = '1'"
+test_efkey_45 5 0 "DELETE FROM chi WHERE c = '1'"
+test_efkey_45 6 0 "DELETE FROM par WHERE p = '1'"
+test_efkey_45 7 1 "INSERT INTO chi VALUES('1')"
+test_efkey_45 8 0 "INSERT INTO chi VALUES(X'31')"
+test_efkey_45 9 1 "INSERT INTO chi VALUES(X'32')"
+
+#-------------------------------------------------------------------------
+# Specifically, test that when comparing child and parent key values the
+# default collation sequence of the parent key column is used.
+#
+# EVIDENCE-OF: R-15796-47513 When comparing text values, the collating
+# sequence associated with the parent key column is always used.
+#
+drop_all_tables
+do_test e_fkey-16.1 {
+ execsql {
+ CREATE TABLE t1(a COLLATE nocase PRIMARY KEY);
+ CREATE TABLE t2(b REFERENCES t1);
+ }
+} {}
+do_test e_fkey-16.2 {
+ execsql {
+ INSERT INTO t1 VALUES('oNe');
+ INSERT INTO t2 VALUES('one');
+ INSERT INTO t2 VALUES('ONE');
+ UPDATE t2 SET b = 'OnE';
+ UPDATE t1 SET a = 'ONE';
+ }
+} {}
+do_test e_fkey-16.3 {
+ catchsql { UPDATE t2 SET b = 'two' WHERE rowid = 1 }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-16.4 {
+ catchsql { DELETE FROM t1 WHERE rowid = 1 }
+} {1 {foreign key constraint failed}}
+
+#-------------------------------------------------------------------------
+# Specifically, test that when comparing child and parent key values the
+# affinity of the parent key column is applied to the child key value
+# before the comparison takes place.
+#
+# EVIDENCE-OF: R-04240-13860 When comparing values, if the parent key
+# column has an affinity, then that affinity is applied to the child key
+# value before the comparison is performed.
+#
+drop_all_tables
+do_test e_fkey-17.1 {
+ execsql {
+ CREATE TABLE t1(a NUMERIC PRIMARY KEY);
+ CREATE TABLE t2(b TEXT REFERENCES t1);
+ }
+} {}
+do_test e_fkey-17.2 {
+ execsql {
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES('three');
+ INSERT INTO t2 VALUES('2.0');
+ SELECT b, typeof(b) FROM t2;
+ }
+} {2.0 text}
+do_test e_fkey-17.3 {
+ execsql { SELECT typeof(a) FROM t1 }
+} {integer integer text}
+do_test e_fkey-17.4 {
+ catchsql { DELETE FROM t1 WHERE rowid = 2 }
+} {1 {foreign key constraint failed}}
+
+###########################################################################
+### SECTION 3: Required and Suggested Database Indexes
+###########################################################################
+
+#-------------------------------------------------------------------------
+# A parent key must be either a PRIMARY KEY, subject to a UNIQUE
+# constraint, or have a UNIQUE index created on it.
+#
+# EVIDENCE-OF: R-13435-26311 Usually, the parent key of a foreign key
+# constraint is the primary key of the parent table. If they are not the
+# primary key, then the parent key columns must be collectively subject
+# to a UNIQUE constraint or have a UNIQUE index.
+#
+# Also test that if a parent key is not subject to a PRIMARY KEY or UNIQUE
+# constraint, but does have a UNIQUE index created on it, then the UNIQUE index
+# must use the default collation sequences associated with the parent key
+# columns.
+#
+# EVIDENCE-OF: R-00376-39212 If the parent key columns have a UNIQUE
+# index, then that index must use the collation sequences that are
+# specified in the CREATE TABLE statement for the parent table.
+#
+drop_all_tables
+do_test e_fkey-18.1 {
+ execsql {
+ CREATE TABLE t2(a REFERENCES t1(x));
+ }
+} {}
+proc test_efkey_57 {tn isError sql} {
+ catchsql { DROP TABLE t1 }
+ execsql $sql
+ do_test e_fkey-18.$tn {
+ catchsql { INSERT INTO t2 VALUES(NULL) }
+ } [lindex {{0 {}} {1 {foreign key mismatch}}} $isError]
+}
+test_efkey_57 2 0 { CREATE TABLE t1(x PRIMARY KEY) }
+test_efkey_57 3 0 { CREATE TABLE t1(x UNIQUE) }
+test_efkey_57 4 0 { CREATE TABLE t1(x); CREATE UNIQUE INDEX t1i ON t1(x) }
+test_efkey_57 5 1 {
+ CREATE TABLE t1(x);
+ CREATE UNIQUE INDEX t1i ON t1(x COLLATE nocase);
+}
+test_efkey_57 6 1 { CREATE TABLE t1(x) }
+test_efkey_57 7 1 { CREATE TABLE t1(x, y, PRIMARY KEY(x, y)) }
+test_efkey_57 8 1 { CREATE TABLE t1(x, y, UNIQUE(x, y)) }
+test_efkey_57 9 1 {
+ CREATE TABLE t1(x, y);
+ CREATE UNIQUE INDEX t1i ON t1(x, y);
+}
+
+
+#-------------------------------------------------------------------------
+# This block tests an example in foreignkeys.html. Several testable
+# statements refer to this example, as follows
+#
+# EVIDENCE-OF: R-27484-01467
+#
+# FK Constraints on child1, child2 and child3 are Ok.
+#
+# Problem with FK on child4:
+#
+# EVIDENCE-OF: R-51039-44840 The foreign key declared as part of table
+# child4 is an error because even though the parent key column is
+# indexed, the index is not UNIQUE.
+#
+# Problem with FK on child5:
+#
+# EVIDENCE-OF: R-01060-48788 The foreign key for table child5 is an
+# error because even though the parent key column has a unique index,
+# the index uses a different collating sequence.
+#
+# Problem with FK on child6 and child7:
+#
+# EVIDENCE-OF: R-63088-37469 Tables child6 and child7 are incorrect
+# because while both have UNIQUE indices on their parent keys, the keys
+# are not an exact match to the columns of a single UNIQUE index.
+#
+drop_all_tables
+do_test e_fkey-19.1 {
+ execsql {
+ CREATE TABLE parent(a PRIMARY KEY, b UNIQUE, c, d, e, f);
+ CREATE UNIQUE INDEX i1 ON parent(c, d);
+ CREATE INDEX i2 ON parent(e);
+ CREATE UNIQUE INDEX i3 ON parent(f COLLATE nocase);
+
+ CREATE TABLE child1(f, g REFERENCES parent(a)); -- Ok
+ CREATE TABLE child2(h, i REFERENCES parent(b)); -- Ok
+ CREATE TABLE child3(j, k, FOREIGN KEY(j, k) REFERENCES parent(c, d)); -- Ok
+ CREATE TABLE child4(l, m REFERENCES parent(e)); -- Err
+ CREATE TABLE child5(n, o REFERENCES parent(f)); -- Err
+ CREATE TABLE child6(p, q, FOREIGN KEY(p,q) REFERENCES parent(b, c)); -- Err
+ CREATE TABLE child7(r REFERENCES parent(c)); -- Err
+ }
+} {}
+do_test e_fkey-19.2 {
+ execsql {
+ INSERT INTO parent VALUES(1, 2, 3, 4, 5, 6);
+ INSERT INTO child1 VALUES('xxx', 1);
+ INSERT INTO child2 VALUES('xxx', 2);
+ INSERT INTO child3 VALUES(3, 4);
+ }
+} {}
+do_test e_fkey-19.2 {
+ catchsql { INSERT INTO child4 VALUES('xxx', 5) }
+} {1 {foreign key mismatch}}
+do_test e_fkey-19.3 {
+ catchsql { INSERT INTO child5 VALUES('xxx', 6) }
+} {1 {foreign key mismatch}}
+do_test e_fkey-19.4 {
+ catchsql { INSERT INTO child6 VALUES(2, 3) }
+} {1 {foreign key mismatch}}
+do_test e_fkey-19.5 {
+ catchsql { INSERT INTO child7 VALUES(3) }
+} {1 {foreign key mismatch}}
+
+#-------------------------------------------------------------------------
+# Test errors in the database schema that are detected while preparing
+# DML statements. The error text for these messages always matches
+# either "foreign key mismatch" or "no such table*" (using [string match]).
+#
+# EVIDENCE-OF: R-45488-08504 If the database schema contains foreign key
+# errors that require looking at more than one table definition to
+# identify, then those errors are not detected when the tables are
+# created.
+#
+# EVIDENCE-OF: R-48391-38472 Instead, such errors prevent the
+# application from preparing SQL statements that modify the content of
+# the child or parent tables in ways that use the foreign keys.
+#
+# EVIDENCE-OF: R-03108-63659 The English language error message for
+# foreign key DML errors is usually "foreign key mismatch" but can also
+# be "no such table" if the parent table does not exist.
+#
+# EVIDENCE-OF: R-60781-26576 Foreign key DML errors are may be reported
+# if: The parent table does not exist, or The parent key columns named
+# in the foreign key constraint do not exist, or The parent key columns
+# named in the foreign key constraint are not the primary key of the
+# parent table and are not subject to a unique constraint using
+# collating sequence specified in the CREATE TABLE, or The child table
+# references the primary key of the parent without specifying the
+# primary key columns and the number of primary key columns in the
+# parent do not match the number of child key columns.
+#
+do_test e_fkey-20.1 {
+ execsql {
+ CREATE TABLE c1(c REFERENCES nosuchtable, d);
+
+ CREATE TABLE p2(a, b, UNIQUE(a, b));
+ CREATE TABLE c2(c, d, FOREIGN KEY(c, d) REFERENCES p2(a, x));
+
+ CREATE TABLE p3(a PRIMARY KEY, b);
+ CREATE TABLE c3(c REFERENCES p3(b), d);
+
+ CREATE TABLE p4(a PRIMARY KEY, b);
+ CREATE UNIQUE INDEX p4i ON p4(b COLLATE nocase);
+ CREATE TABLE c4(c REFERENCES p4(b), d);
+
+ CREATE TABLE p5(a PRIMARY KEY, b COLLATE nocase);
+ CREATE UNIQUE INDEX p5i ON p5(b COLLATE binary);
+ CREATE TABLE c5(c REFERENCES p5(b), d);
+
+ CREATE TABLE p6(a PRIMARY KEY, b);
+ CREATE TABLE c6(c, d, FOREIGN KEY(c, d) REFERENCES p6);
+
+ CREATE TABLE p7(a, b, PRIMARY KEY(a, b));
+ CREATE TABLE c7(c, d REFERENCES p7);
+ }
+} {}
+
+foreach {tn tbl ptbl err} {
+ 2 c1 {} "no such table: main.nosuchtable"
+ 3 c2 p2 "foreign key mismatch"
+ 4 c3 p3 "foreign key mismatch"
+ 5 c4 p4 "foreign key mismatch"
+ 6 c5 p5 "foreign key mismatch"
+ 7 c6 p6 "foreign key mismatch"
+ 8 c7 p7 "foreign key mismatch"
+} {
+ do_test e_fkey-20.$tn.1 {
+ catchsql "INSERT INTO $tbl VALUES('a', 'b')"
+ } [list 1 $err]
+ do_test e_fkey-20.$tn.2 {
+ catchsql "UPDATE $tbl SET c = ?, d = ?"
+ } [list 1 $err]
+ do_test e_fkey-20.$tn.3 {
+ catchsql "INSERT INTO $tbl SELECT ?, ?"
+ } [list 1 $err]
+
+ if {$ptbl ne ""} {
+ do_test e_fkey-20.$tn.4 {
+ catchsql "DELETE FROM $ptbl"
+ } [list 1 $err]
+ do_test e_fkey-20.$tn.5 {
+ catchsql "UPDATE $ptbl SET a = ?, b = ?"
+ } [list 1 $err]
+ do_test e_fkey-20.$tn.6 {
+ catchsql "INSERT INTO $ptbl SELECT ?, ?"
+ } [list 1 $err]
+ }
+}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-19353-43643
+#
+# Test the example of foreign key mismatch errors caused by implicitly
+# mapping a child key to the primary key of the parent table when the
+# child key consists of a different number of columns to that primary key.
+#
+drop_all_tables
+do_test e_fkey-21.1 {
+ execsql {
+ CREATE TABLE parent2(a, b, PRIMARY KEY(a,b));
+
+ CREATE TABLE child8(x, y, FOREIGN KEY(x,y) REFERENCES parent2); -- Ok
+ CREATE TABLE child9(x REFERENCES parent2); -- Err
+ CREATE TABLE child10(x,y,z, FOREIGN KEY(x,y,z) REFERENCES parent2); -- Err
+ }
+} {}
+do_test e_fkey-21.2 {
+ execsql {
+ INSERT INTO parent2 VALUES('I', 'II');
+ INSERT INTO child8 VALUES('I', 'II');
+ }
+} {}
+do_test e_fkey-21.3 {
+ catchsql { INSERT INTO child9 VALUES('I') }
+} {1 {foreign key mismatch}}
+do_test e_fkey-21.4 {
+ catchsql { INSERT INTO child9 VALUES('II') }
+} {1 {foreign key mismatch}}
+do_test e_fkey-21.5 {
+ catchsql { INSERT INTO child9 VALUES(NULL) }
+} {1 {foreign key mismatch}}
+do_test e_fkey-21.6 {
+ catchsql { INSERT INTO child10 VALUES('I', 'II', 'III') }
+} {1 {foreign key mismatch}}
+do_test e_fkey-21.7 {
+ catchsql { INSERT INTO child10 VALUES(1, 2, 3) }
+} {1 {foreign key mismatch}}
+do_test e_fkey-21.8 {
+ catchsql { INSERT INTO child10 VALUES(NULL, NULL, NULL) }
+} {1 {foreign key mismatch}}
+
+#-------------------------------------------------------------------------
+# Test errors that are reported when creating the child table.
+# Specifically:
+#
+# * different number of child and parent key columns, and
+# * child columns that do not exist.
+#
+# EVIDENCE-OF: R-23682-59820 By contrast, if foreign key errors can be
+# recognized simply by looking at the definition of the child table and
+# without having to consult the parent table definition, then the CREATE
+# TABLE statement for the child table fails.
+#
+# These errors are reported whether or not FK support is enabled.
+#
+# EVIDENCE-OF: R-33883-28833 Foreign key DDL errors are reported
+# regardless of whether or not foreign key constraints are enabled when
+# the table is created.
+#
+drop_all_tables
+foreach fk [list OFF ON] {
+ execsql "PRAGMA foreign_keys = $fk"
+ set i 0
+ foreach {sql error} {
+ "CREATE TABLE child1(a, b, FOREIGN KEY(a, b) REFERENCES p(c))"
+ {number of columns in foreign key does not match the number of columns in the referenced table}
+ "CREATE TABLE child2(a, b, FOREIGN KEY(a, b) REFERENCES p(c, d, e))"
+ {number of columns in foreign key does not match the number of columns in the referenced table}
+ "CREATE TABLE child2(a, b, FOREIGN KEY(a, c) REFERENCES p(c, d))"
+ {unknown column "c" in foreign key definition}
+ "CREATE TABLE child2(a, b, FOREIGN KEY(c, b) REFERENCES p(c, d))"
+ {unknown column "c" in foreign key definition}
+ } {
+ do_test e_fkey-22.$fk.[incr i] {
+ catchsql $sql
+ } [list 1 $error]
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test that a REFERENCING clause that does not specify parent key columns
+# implicitly maps to the primary key of the parent table.
+#
+# EVIDENCE-OF: R-43879-08025 Attaching a "REFERENCES <parent-table>"
+# clause to a column definition creates a foreign
+# key constraint that maps the column to the primary key of
+# <parent-table>.
+#
+do_test e_fkey-23.1 {
+ execsql {
+ CREATE TABLE p1(a, b, PRIMARY KEY(a, b));
+ CREATE TABLE p2(a, b PRIMARY KEY);
+ CREATE TABLE c1(c, d, FOREIGN KEY(c, d) REFERENCES p1);
+ CREATE TABLE c2(a, b REFERENCES p2);
+ }
+} {}
+proc test_efkey_60 {tn isError sql} {
+ do_test e_fkey-23.$tn "
+ catchsql {$sql}
+ " [lindex {{0 {}} {1 {foreign key constraint failed}}} $isError]
+}
+
+test_efkey_60 2 1 "INSERT INTO c1 VALUES(239, 231)"
+test_efkey_60 3 0 "INSERT INTO p1 VALUES(239, 231)"
+test_efkey_60 4 0 "INSERT INTO c1 VALUES(239, 231)"
+test_efkey_60 5 1 "INSERT INTO c2 VALUES(239, 231)"
+test_efkey_60 6 0 "INSERT INTO p2 VALUES(239, 231)"
+test_efkey_60 7 0 "INSERT INTO c2 VALUES(239, 231)"
+
+#-------------------------------------------------------------------------
+# Test that an index on on the child key columns of an FK constraint
+# is optional.
+#
+# EVIDENCE-OF: R-15417-28014 Indices are not required for child key
+# columns
+#
+# Also test that if an index is created on the child key columns, it does
+# not make a difference whether or not it is a UNIQUE index.
+#
+# EVIDENCE-OF: R-15741-50893 The child key index does not have to be
+# (and usually will not be) a UNIQUE index.
+#
+drop_all_tables
+do_test e_fkey-24.1 {
+ execsql {
+ CREATE TABLE parent(x, y, UNIQUE(y, x));
+ CREATE TABLE c1(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y));
+ CREATE TABLE c2(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y));
+ CREATE TABLE c3(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y));
+ CREATE INDEX c2i ON c2(a, b);
+ CREATE UNIQUE INDEX c3i ON c2(b, a);
+ }
+} {}
+proc test_efkey_61 {tn isError sql} {
+ do_test e_fkey-24.$tn "
+ catchsql {$sql}
+ " [lindex {{0 {}} {1 {foreign key constraint failed}}} $isError]
+}
+foreach {tn c} [list 2 c1 3 c2 4 c3] {
+ test_efkey_61 $tn.1 1 "INSERT INTO $c VALUES(1, 2)"
+ test_efkey_61 $tn.2 0 "INSERT INTO parent VALUES(1, 2)"
+ test_efkey_61 $tn.3 0 "INSERT INTO $c VALUES(1, 2)"
+
+ execsql "DELETE FROM $c ; DELETE FROM parent"
+}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-00279-52283
+#
+# Test an example showing that when a row is deleted from the parent
+# table, the child table is queried for orphaned rows as follows:
+#
+# SELECT rowid FROM track WHERE trackartist = ?
+#
+# EVIDENCE-OF: R-23302-30956 If this SELECT returns any rows at all,
+# then SQLite concludes that deleting the row from the parent table
+# would violate the foreign key constraint and returns an error.
+#
+do_test e_fkey-25.1 {
+ execsql {
+ CREATE TABLE artist(
+ artistid INTEGER PRIMARY KEY,
+ artistname TEXT
+ );
+ CREATE TABLE track(
+ trackid INTEGER,
+ trackname TEXT,
+ trackartist INTEGER,
+ FOREIGN KEY(trackartist) REFERENCES artist(artistid)
+ );
+ }
+} {}
+do_execsql_test e_fkey-25.2 {
+ PRAGMA foreign_keys = OFF;
+ EXPLAIN QUERY PLAN DELETE FROM artist WHERE 1;
+ EXPLAIN QUERY PLAN SELECT rowid FROM track WHERE trackartist = ?;
+} {
+ 0 0 0 {SCAN TABLE artist (~1000000 rows)}
+ 0 0 0 {SCAN TABLE track (~100000 rows)}
+}
+do_execsql_test e_fkey-25.3 {
+ PRAGMA foreign_keys = ON;
+ EXPLAIN QUERY PLAN DELETE FROM artist WHERE 1;
+} {
+ 0 0 0 {SCAN TABLE artist (~1000000 rows)}
+ 0 0 0 {SCAN TABLE track (~100000 rows)}
+}
+do_test e_fkey-25.4 {
+ execsql {
+ INSERT INTO artist VALUES(5, 'artist 5');
+ INSERT INTO artist VALUES(6, 'artist 6');
+ INSERT INTO artist VALUES(7, 'artist 7');
+ INSERT INTO track VALUES(1, 'track 1', 5);
+ INSERT INTO track VALUES(2, 'track 2', 6);
+ }
+} {}
+
+do_test e_fkey-25.5 {
+ concat \
+ [execsql { SELECT rowid FROM track WHERE trackartist = 5 }] \
+ [catchsql { DELETE FROM artist WHERE artistid = 5 }]
+} {1 1 {foreign key constraint failed}}
+
+do_test e_fkey-25.6 {
+ concat \
+ [execsql { SELECT rowid FROM track WHERE trackartist = 7 }] \
+ [catchsql { DELETE FROM artist WHERE artistid = 7 }]
+} {0 {}}
+
+do_test e_fkey-25.7 {
+ concat \
+ [execsql { SELECT rowid FROM track WHERE trackartist = 6 }] \
+ [catchsql { DELETE FROM artist WHERE artistid = 6 }]
+} {2 1 {foreign key constraint failed}}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-47936-10044 Or, more generally:
+# SELECT rowid FROM <child-table> WHERE <child-key> = :parent_key_value
+#
+# Test that when a row is deleted from the parent table of an FK
+# constraint, the child table is queried for orphaned rows. The
+# query is equivalent to:
+#
+# SELECT rowid FROM <child-table> WHERE <child-key> = :parent_key_value
+#
+# Also test that when a row is inserted into the parent table, or when the
+# parent key values of an existing row are modified, a query equivalent
+# to the following is planned. In some cases it is not executed, but it
+# is always planned.
+#
+# SELECT rowid FROM <child-table> WHERE <child-key> = :parent_key_value
+#
+# EVIDENCE-OF: R-61616-46700 Similar queries may be run if the content
+# of the parent key is modified or a new row is inserted into the parent
+# table.
+#
+#
+drop_all_tables
+do_test e_fkey-26.1 {
+ execsql { CREATE TABLE parent(x, y, UNIQUE(y, x)) }
+} {}
+foreach {tn sql} {
+ 2 {
+ CREATE TABLE child(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y))
+ }
+ 3 {
+ CREATE TABLE child(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y));
+ CREATE INDEX childi ON child(a, b);
+ }
+ 4 {
+ CREATE TABLE child(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y));
+ CREATE UNIQUE INDEX childi ON child(b, a);
+ }
+} {
+ execsql $sql
+
+ execsql {PRAGMA foreign_keys = OFF}
+ set delete [concat \
+ [eqp "DELETE FROM parent WHERE 1"] \
+ [eqp "SELECT rowid FROM child WHERE a = ? AND b = ?"]
+ ]
+ set update [concat \
+ [eqp "UPDATE parent SET x=?, y=?"] \
+ [eqp "SELECT rowid FROM child WHERE a = ? AND b = ?"] \
+ [eqp "SELECT rowid FROM child WHERE a = ? AND b = ?"]
+ ]
+ execsql {PRAGMA foreign_keys = ON}
+
+ do_test e_fkey-26.$tn.1 { eqp "DELETE FROM parent WHERE 1" } $delete
+ do_test e_fkey-26.$tn.2 { eqp "UPDATE parent set x=?, y=?" } $update
+
+ execsql {DROP TABLE child}
+}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-14553-34013
+#
+# Test the example schema at the end of section 3. Also test that is
+# is "efficient". In this case "efficient" means that foreign key
+# related operations on the parent table do not provoke linear scans.
+#
+drop_all_tables
+do_test e_fkey-27.1 {
+ execsql {
+ CREATE TABLE artist(
+ artistid INTEGER PRIMARY KEY,
+ artistname TEXT
+ );
+ CREATE TABLE track(
+ trackid INTEGER,
+ trackname TEXT,
+ trackartist INTEGER REFERENCES artist
+ );
+ CREATE INDEX trackindex ON track(trackartist);
+ }
+} {}
+do_test e_fkey-27.2 {
+ eqp { INSERT INTO artist VALUES(?, ?) }
+} {}
+do_execsql_test e_fkey-27.3 {
+ EXPLAIN QUERY PLAN UPDATE artist SET artistid = ?, artistname = ?
+} {
+ 0 0 0 {SCAN TABLE artist (~1000000 rows)}
+ 0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?) (~10 rows)}
+ 0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?) (~10 rows)}
+}
+do_execsql_test e_fkey-27.4 {
+ EXPLAIN QUERY PLAN DELETE FROM artist
+} {
+ 0 0 0 {SCAN TABLE artist (~1000000 rows)}
+ 0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?) (~10 rows)}
+}
+
+
+###########################################################################
+### SECTION 4.1: Composite Foreign Key Constraints
+###########################################################################
+
+#-------------------------------------------------------------------------
+# Check that parent and child keys must have the same number of columns.
+#
+# EVIDENCE-OF: R-41062-34431 Parent and child keys must have the same
+# cardinality.
+#
+foreach {tn sql err} {
+ 1 "CREATE TABLE c(jj REFERENCES p(x, y))"
+ {foreign key on jj should reference only one column of table p}
+
+ 2 "CREATE TABLE c(jj REFERENCES p())" {near ")": syntax error}
+
+ 3 "CREATE TABLE c(jj, FOREIGN KEY(jj) REFERENCES p(x, y))"
+ {number of columns in foreign key does not match the number of columns in the referenced table}
+
+ 4 "CREATE TABLE c(jj, FOREIGN KEY(jj) REFERENCES p())"
+ {near ")": syntax error}
+
+ 5 "CREATE TABLE c(ii, jj, FOREIGN KEY(jj, ii) REFERENCES p())"
+ {near ")": syntax error}
+
+ 6 "CREATE TABLE c(ii, jj, FOREIGN KEY(jj, ii) REFERENCES p(x))"
+ {number of columns in foreign key does not match the number of columns in the referenced table}
+
+ 7 "CREATE TABLE c(ii, jj, FOREIGN KEY(jj, ii) REFERENCES p(x,y,z))"
+ {number of columns in foreign key does not match the number of columns in the referenced table}
+} {
+ drop_all_tables
+ do_test e_fkey-28.$tn [list catchsql $sql] [list 1 $err]
+}
+do_test e_fkey-28.8 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE p(x PRIMARY KEY);
+ CREATE TABLE c(a, b, FOREIGN KEY(a,b) REFERENCES p);
+ }
+ catchsql {DELETE FROM p}
+} {1 {foreign key mismatch}}
+do_test e_fkey-28.9 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE p(x, y, PRIMARY KEY(x,y));
+ CREATE TABLE c(a REFERENCES p);
+ }
+ catchsql {DELETE FROM p}
+} {1 {foreign key mismatch}}
+
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-24676-09859
+#
+# Test the example schema in the "Composite Foreign Key Constraints"
+# section.
+#
+do_test e_fkey-29.1 {
+ execsql {
+ CREATE TABLE album(
+ albumartist TEXT,
+ albumname TEXT,
+ albumcover BINARY,
+ PRIMARY KEY(albumartist, albumname)
+ );
+ CREATE TABLE song(
+ songid INTEGER,
+ songartist TEXT,
+ songalbum TEXT,
+ songname TEXT,
+ FOREIGN KEY(songartist, songalbum) REFERENCES album(albumartist,albumname)
+ );
+ }
+} {}
+
+do_test e_fkey-29.2 {
+ execsql {
+ INSERT INTO album VALUES('Elvis Presley', 'Elvis'' Christmas Album', NULL);
+ INSERT INTO song VALUES(
+ 1, 'Elvis Presley', 'Elvis'' Christmas Album', 'Here Comes Santa Clause'
+ );
+ }
+} {}
+do_test e_fkey-29.3 {
+ catchsql {
+ INSERT INTO song VALUES(2, 'Elvis Presley', 'Elvis Is Back!', 'Fever');
+ }
+} {1 {foreign key constraint failed}}
+
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-33626-48418 In SQLite, if any of the child key columns
+# (in this case songartist and songalbum) are NULL, then there is no
+# requirement for a corresponding row in the parent table.
+#
+do_test e_fkey-30.1 {
+ execsql {
+ INSERT INTO song VALUES(2, 'Elvis Presley', NULL, 'Fever');
+ INSERT INTO song VALUES(3, NULL, 'Elvis Is Back', 'Soldier Boy');
+ }
+} {}
+
+###########################################################################
+### SECTION 4.2: Deferred Foreign Key Constraints
+###########################################################################
+
+#-------------------------------------------------------------------------
+# Test that if a statement violates an immediate FK constraint, and the
+# database does not satisfy the FK constraint once all effects of the
+# statement have been applied, an error is reported and the effects of
+# the statement rolled back.
+#
+# EVIDENCE-OF: R-09323-30470 If a statement modifies the contents of the
+# database so that an immediate foreign key constraint is in violation
+# at the conclusion the statement, an exception is thrown and the
+# effects of the statement are reverted.
+#
+drop_all_tables
+do_test e_fkey-31.1 {
+ execsql {
+ CREATE TABLE king(a, b, PRIMARY KEY(a));
+ CREATE TABLE prince(c REFERENCES king, d);
+ }
+} {}
+
+do_test e_fkey-31.2 {
+ # Execute a statement that violates the immediate FK constraint.
+ catchsql { INSERT INTO prince VALUES(1, 2) }
+} {1 {foreign key constraint failed}}
+
+do_test e_fkey-31.3 {
+ # This time, use a trigger to fix the constraint violation before the
+ # statement has finished executing. Then execute the same statement as
+ # in the previous test case. This time, no error.
+ execsql {
+ CREATE TRIGGER kt AFTER INSERT ON prince WHEN
+ NOT EXISTS (SELECT a FROM king WHERE a = new.c)
+ BEGIN
+ INSERT INTO king VALUES(new.c, NULL);
+ END
+ }
+ execsql { INSERT INTO prince VALUES(1, 2) }
+} {}
+
+# Test that operating inside a transaction makes no difference to
+# immediate constraint violation handling.
+do_test e_fkey-31.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO prince VALUES(2, 3);
+ DROP TRIGGER kt;
+ }
+ catchsql { INSERT INTO prince VALUES(3, 4) }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-31.5 {
+ execsql {
+ COMMIT;
+ SELECT * FROM king;
+ }
+} {1 {} 2 {}}
+
+#-------------------------------------------------------------------------
+# Test that if a deferred constraint is violated within a transaction,
+# nothing happens immediately and the database is allowed to persist
+# in a state that does not satisfy the FK constraint. However attempts
+# to COMMIT the transaction fail until the FK constraint is satisfied.
+#
+# EVIDENCE-OF: R-49178-21358 By contrast, if a statement modifies the
+# contents of the database such that a deferred foreign key constraint
+# is violated, the violation is not reported immediately.
+#
+# EVIDENCE-OF: R-39692-12488 Deferred foreign key constraints are not
+# checked until the transaction tries to COMMIT.
+#
+# EVIDENCE-OF: R-55147-47664 For as long as the user has an open
+# transaction, the database is allowed to exist in a state that violates
+# any number of deferred foreign key constraints.
+#
+# EVIDENCE-OF: R-29604-30395 However, COMMIT will fail as long as
+# foreign key constraints remain in violation.
+#
+proc test_efkey_34 {tn isError sql} {
+ do_test e_fkey-32.$tn "
+ catchsql {$sql}
+ " [lindex {{0 {}} {1 {foreign key constraint failed}}} $isError]
+}
+drop_all_tables
+
+test_efkey_34 1 0 {
+ CREATE TABLE ll(k PRIMARY KEY);
+ CREATE TABLE kk(c REFERENCES ll DEFERRABLE INITIALLY DEFERRED);
+}
+test_efkey_34 2 0 "BEGIN"
+test_efkey_34 3 0 "INSERT INTO kk VALUES(5)"
+test_efkey_34 4 0 "INSERT INTO kk VALUES(10)"
+test_efkey_34 5 1 "COMMIT"
+test_efkey_34 6 0 "INSERT INTO ll VALUES(10)"
+test_efkey_34 7 1 "COMMIT"
+test_efkey_34 8 0 "INSERT INTO ll VALUES(5)"
+test_efkey_34 9 0 "COMMIT"
+
+#-------------------------------------------------------------------------
+# When not running inside a transaction, a deferred constraint is similar
+# to an immediate constraint (violations are reported immediately).
+#
+# EVIDENCE-OF: R-56844-61705 If the current statement is not inside an
+# explicit transaction (a BEGIN/COMMIT/ROLLBACK block), then an implicit
+# transaction is committed as soon as the statement has finished
+# executing. In this case deferred constraints behave the same as
+# immediate constraints.
+#
+drop_all_tables
+proc test_efkey_35 {tn isError sql} {
+ do_test e_fkey-33.$tn "
+ catchsql {$sql}
+ " [lindex {{0 {}} {1 {foreign key constraint failed}}} $isError]
+}
+do_test e_fkey-33.1 {
+ execsql {
+ CREATE TABLE parent(x, y);
+ CREATE UNIQUE INDEX pi ON parent(x, y);
+ CREATE TABLE child(a, b,
+ FOREIGN KEY(a, b) REFERENCES parent(x, y) DEFERRABLE INITIALLY DEFERRED
+ );
+ }
+} {}
+test_efkey_35 2 1 "INSERT INTO child VALUES('x', 'y')"
+test_efkey_35 3 0 "INSERT INTO parent VALUES('x', 'y')"
+test_efkey_35 4 0 "INSERT INTO child VALUES('x', 'y')"
+
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-12782-61841
+#
+# Test that an FK constraint is made deferred by adding the following
+# to the definition:
+#
+# DEFERRABLE INITIALLY DEFERRED
+#
+# EVIDENCE-OF: R-09005-28791
+#
+# Also test that adding any of the following to a foreign key definition
+# makes the constraint IMMEDIATE:
+#
+# NOT DEFERRABLE INITIALLY DEFERRED
+# NOT DEFERRABLE INITIALLY IMMEDIATE
+# NOT DEFERRABLE
+# DEFERRABLE INITIALLY IMMEDIATE
+# DEFERRABLE
+#
+# Foreign keys are IMMEDIATE by default (if there is no DEFERRABLE or NOT
+# DEFERRABLE clause).
+#
+# EVIDENCE-OF: R-35290-16460 Foreign key constraints are immediate by
+# default.
+#
+# EVIDENCE-OF: R-30323-21917 Each foreign key constraint in SQLite is
+# classified as either immediate or deferred.
+#
+drop_all_tables
+do_test e_fkey-34.1 {
+ execsql {
+ CREATE TABLE parent(x, y, z, PRIMARY KEY(x,y,z));
+ CREATE TABLE c1(a, b, c,
+ FOREIGN KEY(a, b, c) REFERENCES parent NOT DEFERRABLE INITIALLY DEFERRED
+ );
+ CREATE TABLE c2(a, b, c,
+ FOREIGN KEY(a, b, c) REFERENCES parent NOT DEFERRABLE INITIALLY IMMEDIATE
+ );
+ CREATE TABLE c3(a, b, c,
+ FOREIGN KEY(a, b, c) REFERENCES parent NOT DEFERRABLE
+ );
+ CREATE TABLE c4(a, b, c,
+ FOREIGN KEY(a, b, c) REFERENCES parent DEFERRABLE INITIALLY IMMEDIATE
+ );
+ CREATE TABLE c5(a, b, c,
+ FOREIGN KEY(a, b, c) REFERENCES parent DEFERRABLE
+ );
+ CREATE TABLE c6(a, b, c, FOREIGN KEY(a, b, c) REFERENCES parent);
+
+ -- This FK constraint is the only deferrable one.
+ CREATE TABLE c7(a, b, c,
+ FOREIGN KEY(a, b, c) REFERENCES parent DEFERRABLE INITIALLY DEFERRED
+ );
+
+ INSERT INTO parent VALUES('a', 'b', 'c');
+ INSERT INTO parent VALUES('d', 'e', 'f');
+ INSERT INTO parent VALUES('g', 'h', 'i');
+ INSERT INTO parent VALUES('j', 'k', 'l');
+ INSERT INTO parent VALUES('m', 'n', 'o');
+ INSERT INTO parent VALUES('p', 'q', 'r');
+ INSERT INTO parent VALUES('s', 't', 'u');
+
+ INSERT INTO c1 VALUES('a', 'b', 'c');
+ INSERT INTO c2 VALUES('d', 'e', 'f');
+ INSERT INTO c3 VALUES('g', 'h', 'i');
+ INSERT INTO c4 VALUES('j', 'k', 'l');
+ INSERT INTO c5 VALUES('m', 'n', 'o');
+ INSERT INTO c6 VALUES('p', 'q', 'r');
+ INSERT INTO c7 VALUES('s', 't', 'u');
+ }
+} {}
+
+proc test_efkey_29 {tn sql isError} {
+ do_test e_fkey-34.$tn "catchsql {$sql}" [
+ lindex {{0 {}} {1 {foreign key constraint failed}}} $isError
+ ]
+}
+test_efkey_29 2 "BEGIN" 0
+test_efkey_29 3 "DELETE FROM parent WHERE x = 'a'" 1
+test_efkey_29 4 "DELETE FROM parent WHERE x = 'd'" 1
+test_efkey_29 5 "DELETE FROM parent WHERE x = 'g'" 1
+test_efkey_29 6 "DELETE FROM parent WHERE x = 'j'" 1
+test_efkey_29 7 "DELETE FROM parent WHERE x = 'm'" 1
+test_efkey_29 8 "DELETE FROM parent WHERE x = 'p'" 1
+test_efkey_29 9 "DELETE FROM parent WHERE x = 's'" 0
+test_efkey_29 10 "COMMIT" 1
+test_efkey_29 11 "ROLLBACK" 0
+
+test_efkey_29 9 "BEGIN" 0
+test_efkey_29 10 "UPDATE parent SET z = 'z' WHERE z = 'c'" 1
+test_efkey_29 11 "UPDATE parent SET z = 'z' WHERE z = 'f'" 1
+test_efkey_29 12 "UPDATE parent SET z = 'z' WHERE z = 'i'" 1
+test_efkey_29 13 "UPDATE parent SET z = 'z' WHERE z = 'l'" 1
+test_efkey_29 14 "UPDATE parent SET z = 'z' WHERE z = 'o'" 1
+test_efkey_29 15 "UPDATE parent SET z = 'z' WHERE z = 'r'" 1
+test_efkey_29 16 "UPDATE parent SET z = 'z' WHERE z = 'u'" 0
+test_efkey_29 17 "COMMIT" 1
+test_efkey_29 18 "ROLLBACK" 0
+
+test_efkey_29 17 "BEGIN" 0
+test_efkey_29 18 "INSERT INTO c1 VALUES(1, 2, 3)" 1
+test_efkey_29 19 "INSERT INTO c2 VALUES(1, 2, 3)" 1
+test_efkey_29 20 "INSERT INTO c3 VALUES(1, 2, 3)" 1
+test_efkey_29 21 "INSERT INTO c4 VALUES(1, 2, 3)" 1
+test_efkey_29 22 "INSERT INTO c5 VALUES(1, 2, 3)" 1
+test_efkey_29 22 "INSERT INTO c6 VALUES(1, 2, 3)" 1
+test_efkey_29 22 "INSERT INTO c7 VALUES(1, 2, 3)" 0
+test_efkey_29 23 "COMMIT" 1
+test_efkey_29 24 "INSERT INTO parent VALUES(1, 2, 3)" 0
+test_efkey_29 25 "COMMIT" 0
+
+test_efkey_29 26 "BEGIN" 0
+test_efkey_29 27 "UPDATE c1 SET a = 10" 1
+test_efkey_29 28 "UPDATE c2 SET a = 10" 1
+test_efkey_29 29 "UPDATE c3 SET a = 10" 1
+test_efkey_29 30 "UPDATE c4 SET a = 10" 1
+test_efkey_29 31 "UPDATE c5 SET a = 10" 1
+test_efkey_29 31 "UPDATE c6 SET a = 10" 1
+test_efkey_29 31 "UPDATE c7 SET a = 10" 0
+test_efkey_29 32 "COMMIT" 1
+test_efkey_29 33 "ROLLBACK" 0
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-24499-57071
+#
+# Test an example from foreignkeys.html dealing with a deferred foreign
+# key constraint.
+#
+do_test e_fkey-35.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE artist(
+ artistid INTEGER PRIMARY KEY,
+ artistname TEXT
+ );
+ CREATE TABLE track(
+ trackid INTEGER,
+ trackname TEXT,
+ trackartist INTEGER REFERENCES artist(artistid) DEFERRABLE INITIALLY DEFERRED
+ );
+ }
+} {}
+do_test e_fkey-35.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO track VALUES(1, 'White Christmas', 5);
+ }
+ catchsql COMMIT
+} {1 {foreign key constraint failed}}
+do_test e_fkey-35.3 {
+ execsql {
+ INSERT INTO artist VALUES(5, 'Bing Crosby');
+ COMMIT;
+ }
+} {}
+
+#-------------------------------------------------------------------------
+# Verify that a nested savepoint may be released without satisfying
+# deferred foreign key constraints.
+#
+# EVIDENCE-OF: R-07223-48323 A nested savepoint transaction may be
+# RELEASEd while the database is in a state that does not satisfy a
+# deferred foreign key constraint.
+#
+drop_all_tables
+do_test e_fkey-36.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY,
+ b REFERENCES t1 DEFERRABLE INITIALLY DEFERRED
+ );
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 2);
+ INSERT INTO t1 VALUES(3, 3);
+ }
+} {}
+do_test e_fkey-36.2 {
+ execsql {
+ BEGIN;
+ SAVEPOINT one;
+ INSERT INTO t1 VALUES(4, 5);
+ RELEASE one;
+ }
+} {}
+do_test e_fkey-36.3 {
+ catchsql COMMIT
+} {1 {foreign key constraint failed}}
+do_test e_fkey-36.4 {
+ execsql {
+ UPDATE t1 SET a = 5 WHERE a = 4;
+ COMMIT;
+ }
+} {}
+
+
+#-------------------------------------------------------------------------
+# Check that a transaction savepoint (an outermost savepoint opened when
+# the database was in auto-commit mode) cannot be released without
+# satisfying deferred foreign key constraints. It may be rolled back.
+#
+# EVIDENCE-OF: R-44295-13823 A transaction savepoint (a non-nested
+# savepoint that was opened while there was not currently an open
+# transaction), on the other hand, is subject to the same restrictions
+# as a COMMIT - attempting to RELEASE it while the database is in such a
+# state will fail.
+#
+do_test e_fkey-37.1 {
+ execsql {
+ SAVEPOINT one;
+ SAVEPOINT two;
+ INSERT INTO t1 VALUES(6, 7);
+ RELEASE two;
+ }
+} {}
+do_test e_fkey-37.2 {
+ catchsql {RELEASE one}
+} {1 {foreign key constraint failed}}
+do_test e_fkey-37.3 {
+ execsql {
+ UPDATE t1 SET a = 7 WHERE a = 6;
+ RELEASE one;
+ }
+} {}
+do_test e_fkey-37.4 {
+ execsql {
+ SAVEPOINT one;
+ SAVEPOINT two;
+ INSERT INTO t1 VALUES(9, 10);
+ RELEASE two;
+ }
+} {}
+do_test e_fkey-37.5 {
+ catchsql {RELEASE one}
+} {1 {foreign key constraint failed}}
+do_test e_fkey-37.6 {
+ execsql {ROLLBACK TO one ; RELEASE one}
+} {}
+
+#-------------------------------------------------------------------------
+# Test that if a COMMIT operation fails due to deferred foreign key
+# constraints, any nested savepoints remain open.
+#
+# EVIDENCE-OF: R-37736-42616 If a COMMIT statement (or the RELEASE of a
+# transaction SAVEPOINT) fails because the database is currently in a
+# state that violates a deferred foreign key constraint and there are
+# currently nested savepoints, the nested savepoints remain open.
+#
+do_test e_fkey-38.1 {
+ execsql {
+ DELETE FROM t1 WHERE a>3;
+ SELECT * FROM t1;
+ }
+} {1 1 2 2 3 3}
+do_test e_fkey-38.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(4, 4);
+ SAVEPOINT one;
+ INSERT INTO t1 VALUES(5, 6);
+ SELECT * FROM t1;
+ }
+} {1 1 2 2 3 3 4 4 5 6}
+do_test e_fkey-38.3 {
+ catchsql COMMIT
+} {1 {foreign key constraint failed}}
+do_test e_fkey-38.4 {
+ execsql {
+ ROLLBACK TO one;
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {1 1 2 2 3 3 4 4}
+
+do_test e_fkey-38.5 {
+ execsql {
+ SAVEPOINT a;
+ INSERT INTO t1 VALUES(5, 5);
+ SAVEPOINT b;
+ INSERT INTO t1 VALUES(6, 7);
+ SAVEPOINT c;
+ INSERT INTO t1 VALUES(7, 8);
+ }
+} {}
+do_test e_fkey-38.6 {
+ catchsql {RELEASE a}
+} {1 {foreign key constraint failed}}
+do_test e_fkey-38.7 {
+ execsql {ROLLBACK TO c}
+ catchsql {RELEASE a}
+} {1 {foreign key constraint failed}}
+do_test e_fkey-38.8 {
+ execsql {
+ ROLLBACK TO b;
+ RELEASE a;
+ SELECT * FROM t1;
+ }
+} {1 1 2 2 3 3 4 4 5 5}
+
+###########################################################################
+### SECTION 4.3: ON DELETE and ON UPDATE Actions
+###########################################################################
+
+#-------------------------------------------------------------------------
+# Test that configured ON DELETE and ON UPDATE actions take place when
+# deleting or modifying rows of the parent table, respectively.
+#
+# EVIDENCE-OF: R-48270-44282 Foreign key ON DELETE and ON UPDATE clauses
+# are used to configure actions that take place when deleting rows from
+# the parent table (ON DELETE), or modifying the parent key values of
+# existing rows (ON UPDATE).
+#
+# Test that a single FK constraint may have different actions configured
+# for ON DELETE and ON UPDATE.
+#
+# EVIDENCE-OF: R-48124-63225 A single foreign key constraint may have
+# different actions configured for ON DELETE and ON UPDATE.
+#
+do_test e_fkey-39.1 {
+ execsql {
+ CREATE TABLE p(a, b PRIMARY KEY, c);
+ CREATE TABLE c1(d, e, f DEFAULT 'k0' REFERENCES p
+ ON UPDATE SET DEFAULT
+ ON DELETE SET NULL
+ );
+
+ INSERT INTO p VALUES(0, 'k0', '');
+ INSERT INTO p VALUES(1, 'k1', 'I');
+ INSERT INTO p VALUES(2, 'k2', 'II');
+ INSERT INTO p VALUES(3, 'k3', 'III');
+
+ INSERT INTO c1 VALUES(1, 'xx', 'k1');
+ INSERT INTO c1 VALUES(2, 'xx', 'k2');
+ INSERT INTO c1 VALUES(3, 'xx', 'k3');
+ }
+} {}
+do_test e_fkey-39.2 {
+ execsql {
+ UPDATE p SET b = 'k4' WHERE a = 1;
+ SELECT * FROM c1;
+ }
+} {1 xx k0 2 xx k2 3 xx k3}
+do_test e_fkey-39.3 {
+ execsql {
+ DELETE FROM p WHERE a = 2;
+ SELECT * FROM c1;
+ }
+} {1 xx k0 2 xx {} 3 xx k3}
+do_test e_fkey-39.4 {
+ execsql {
+ CREATE UNIQUE INDEX pi ON p(c);
+ REPLACE INTO p VALUES(5, 'k5', 'III');
+ SELECT * FROM c1;
+ }
+} {1 xx k0 2 xx {} 3 xx {}}
+
+#-------------------------------------------------------------------------
+# Each foreign key in the system has an ON UPDATE and ON DELETE action,
+# either "NO ACTION", "RESTRICT", "SET NULL", "SET DEFAULT" or "CASCADE".
+#
+# EVIDENCE-OF: R-33326-45252 The ON DELETE and ON UPDATE action
+# associated with each foreign key in an SQLite database is one of "NO
+# ACTION", "RESTRICT", "SET NULL", "SET DEFAULT" or "CASCADE".
+#
+# If none is specified explicitly, "NO ACTION" is the default.
+#
+# EVIDENCE-OF: R-19803-45884 If an action is not explicitly specified,
+# it defaults to "NO ACTION".
+#
+drop_all_tables
+do_test e_fkey-40.1 {
+ execsql {
+ CREATE TABLE parent(x PRIMARY KEY, y);
+ CREATE TABLE child1(a,
+ b REFERENCES parent ON UPDATE NO ACTION ON DELETE RESTRICT
+ );
+ CREATE TABLE child2(a,
+ b REFERENCES parent ON UPDATE RESTRICT ON DELETE SET NULL
+ );
+ CREATE TABLE child3(a,
+ b REFERENCES parent ON UPDATE SET NULL ON DELETE SET DEFAULT
+ );
+ CREATE TABLE child4(a,
+ b REFERENCES parent ON UPDATE SET DEFAULT ON DELETE CASCADE
+ );
+
+ -- Create some foreign keys that use the default action - "NO ACTION"
+ CREATE TABLE child5(a, b REFERENCES parent ON UPDATE CASCADE);
+ CREATE TABLE child6(a, b REFERENCES parent ON DELETE RESTRICT);
+ CREATE TABLE child7(a, b REFERENCES parent ON DELETE NO ACTION);
+ CREATE TABLE child8(a, b REFERENCES parent ON UPDATE NO ACTION);
+ }
+} {}
+
+foreach {tn zTab lRes} {
+ 2 child1 {0 0 parent b {} {NO ACTION} RESTRICT NONE}
+ 3 child2 {0 0 parent b {} RESTRICT {SET NULL} NONE}
+ 4 child3 {0 0 parent b {} {SET NULL} {SET DEFAULT} NONE}
+ 5 child4 {0 0 parent b {} {SET DEFAULT} CASCADE NONE}
+ 6 child5 {0 0 parent b {} CASCADE {NO ACTION} NONE}
+ 7 child6 {0 0 parent b {} {NO ACTION} RESTRICT NONE}
+ 8 child7 {0 0 parent b {} {NO ACTION} {NO ACTION} NONE}
+ 9 child8 {0 0 parent b {} {NO ACTION} {NO ACTION} NONE}
+} {
+ do_test e_fkey-40.$tn { execsql "PRAGMA foreign_key_list($zTab)" } $lRes
+}
+
+#-------------------------------------------------------------------------
+# Test that "NO ACTION" means that nothing happens to a child row when
+# it's parent row is updated or deleted.
+#
+# EVIDENCE-OF: R-19971-54976 Configuring "NO ACTION" means just that:
+# when a parent key is modified or deleted from the database, no special
+# action is taken.
+#
+drop_all_tables
+do_test e_fkey-41.1 {
+ execsql {
+ CREATE TABLE parent(p1, p2, PRIMARY KEY(p1, p2));
+ CREATE TABLE child(c1, c2,
+ FOREIGN KEY(c1, c2) REFERENCES parent
+ ON UPDATE NO ACTION
+ ON DELETE NO ACTION
+ DEFERRABLE INITIALLY DEFERRED
+ );
+ INSERT INTO parent VALUES('j', 'k');
+ INSERT INTO parent VALUES('l', 'm');
+ INSERT INTO child VALUES('j', 'k');
+ INSERT INTO child VALUES('l', 'm');
+ }
+} {}
+do_test e_fkey-41.2 {
+ execsql {
+ BEGIN;
+ UPDATE parent SET p1='k' WHERE p1='j';
+ DELETE FROM parent WHERE p1='l';
+ SELECT * FROM child;
+ }
+} {j k l m}
+do_test e_fkey-41.3 {
+ catchsql COMMIT
+} {1 {foreign key constraint failed}}
+do_test e_fkey-41.4 {
+ execsql ROLLBACK
+} {}
+
+#-------------------------------------------------------------------------
+# Test that "RESTRICT" means the application is prohibited from deleting
+# or updating a parent table row when there exists one or more child keys
+# mapped to it.
+#
+# EVIDENCE-OF: R-04272-38653 The "RESTRICT" action means that the
+# application is prohibited from deleting (for ON DELETE RESTRICT) or
+# modifying (for ON UPDATE RESTRICT) a parent key when there exists one
+# or more child keys mapped to it.
+#
+drop_all_tables
+do_test e_fkey-41.1 {
+ execsql {
+ CREATE TABLE parent(p1, p2);
+ CREATE UNIQUE INDEX parent_i ON parent(p1, p2);
+ CREATE TABLE child1(c1, c2,
+ FOREIGN KEY(c2, c1) REFERENCES parent(p1, p2) ON DELETE RESTRICT
+ );
+ CREATE TABLE child2(c1, c2,
+ FOREIGN KEY(c2, c1) REFERENCES parent(p1, p2) ON UPDATE RESTRICT
+ );
+ }
+} {}
+do_test e_fkey-41.2 {
+ execsql {
+ INSERT INTO parent VALUES('a', 'b');
+ INSERT INTO parent VALUES('c', 'd');
+ INSERT INTO child1 VALUES('b', 'a');
+ INSERT INTO child2 VALUES('d', 'c');
+ }
+} {}
+do_test e_fkey-41.3 {
+ catchsql { DELETE FROM parent WHERE p1 = 'a' }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-41.4 {
+ catchsql { UPDATE parent SET p2 = 'e' WHERE p1 = 'c' }
+} {1 {foreign key constraint failed}}
+
+#-------------------------------------------------------------------------
+# Test that RESTRICT is slightly different from NO ACTION for IMMEDIATE
+# constraints, in that it is enforced immediately, not at the end of the
+# statement.
+#
+# EVIDENCE-OF: R-37997-42187 The difference between the effect of a
+# RESTRICT action and normal foreign key constraint enforcement is that
+# the RESTRICT action processing happens as soon as the field is updated
+# - not at the end of the current statement as it would with an
+# immediate constraint, or at the end of the current transaction as it
+# would with a deferred constraint.
+#
+drop_all_tables
+do_test e_fkey-42.1 {
+ execsql {
+ CREATE TABLE parent(x PRIMARY KEY);
+ CREATE TABLE child1(c REFERENCES parent ON UPDATE RESTRICT);
+ CREATE TABLE child2(c REFERENCES parent ON UPDATE NO ACTION);
+
+ INSERT INTO parent VALUES('key1');
+ INSERT INTO parent VALUES('key2');
+ INSERT INTO child1 VALUES('key1');
+ INSERT INTO child2 VALUES('key2');
+
+ CREATE TRIGGER parent_t AFTER UPDATE ON parent BEGIN
+ UPDATE child1 set c = new.x WHERE c = old.x;
+ UPDATE child2 set c = new.x WHERE c = old.x;
+ END;
+ }
+} {}
+do_test e_fkey-42.2 {
+ catchsql { UPDATE parent SET x = 'key one' WHERE x = 'key1' }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-42.3 {
+ execsql {
+ UPDATE parent SET x = 'key two' WHERE x = 'key2';
+ SELECT * FROM child2;
+ }
+} {{key two}}
+
+drop_all_tables
+do_test e_fkey-42.4 {
+ execsql {
+ CREATE TABLE parent(x PRIMARY KEY);
+ CREATE TABLE child1(c REFERENCES parent ON DELETE RESTRICT);
+ CREATE TABLE child2(c REFERENCES parent ON DELETE NO ACTION);
+
+ INSERT INTO parent VALUES('key1');
+ INSERT INTO parent VALUES('key2');
+ INSERT INTO child1 VALUES('key1');
+ INSERT INTO child2 VALUES('key2');
+
+ CREATE TRIGGER parent_t AFTER DELETE ON parent BEGIN
+ UPDATE child1 SET c = NULL WHERE c = old.x;
+ UPDATE child2 SET c = NULL WHERE c = old.x;
+ END;
+ }
+} {}
+do_test e_fkey-42.5 {
+ catchsql { DELETE FROM parent WHERE x = 'key1' }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-42.6 {
+ execsql {
+ DELETE FROM parent WHERE x = 'key2';
+ SELECT * FROM child2;
+ }
+} {{}}
+
+drop_all_tables
+do_test e_fkey-42.7 {
+ execsql {
+ CREATE TABLE parent(x PRIMARY KEY);
+ CREATE TABLE child1(c REFERENCES parent ON DELETE RESTRICT);
+ CREATE TABLE child2(c REFERENCES parent ON DELETE NO ACTION);
+
+ INSERT INTO parent VALUES('key1');
+ INSERT INTO parent VALUES('key2');
+ INSERT INTO child1 VALUES('key1');
+ INSERT INTO child2 VALUES('key2');
+ }
+} {}
+do_test e_fkey-42.8 {
+ catchsql { REPLACE INTO parent VALUES('key1') }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-42.9 {
+ execsql {
+ REPLACE INTO parent VALUES('key2');
+ SELECT * FROM child2;
+ }
+} {key2}
+
+#-------------------------------------------------------------------------
+# Test that RESTRICT is enforced immediately, even for a DEFERRED constraint.
+#
+# EVIDENCE-OF: R-24179-60523 Even if the foreign key constraint it is
+# attached to is deferred, configuring a RESTRICT action causes SQLite
+# to return an error immediately if a parent key with dependent child
+# keys is deleted or modified.
+#
+drop_all_tables
+do_test e_fkey-43.1 {
+ execsql {
+ CREATE TABLE parent(x PRIMARY KEY);
+ CREATE TABLE child1(c REFERENCES parent ON UPDATE RESTRICT
+ DEFERRABLE INITIALLY DEFERRED
+ );
+ CREATE TABLE child2(c REFERENCES parent ON UPDATE NO ACTION
+ DEFERRABLE INITIALLY DEFERRED
+ );
+
+ INSERT INTO parent VALUES('key1');
+ INSERT INTO parent VALUES('key2');
+ INSERT INTO child1 VALUES('key1');
+ INSERT INTO child2 VALUES('key2');
+ BEGIN;
+ }
+} {}
+do_test e_fkey-43.2 {
+ catchsql { UPDATE parent SET x = 'key one' WHERE x = 'key1' }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-43.3 {
+ execsql { UPDATE parent SET x = 'key two' WHERE x = 'key2' }
+} {}
+do_test e_fkey-43.4 {
+ catchsql COMMIT
+} {1 {foreign key constraint failed}}
+do_test e_fkey-43.5 {
+ execsql {
+ UPDATE child2 SET c = 'key two';
+ COMMIT;
+ }
+} {}
+
+drop_all_tables
+do_test e_fkey-43.6 {
+ execsql {
+ CREATE TABLE parent(x PRIMARY KEY);
+ CREATE TABLE child1(c REFERENCES parent ON DELETE RESTRICT
+ DEFERRABLE INITIALLY DEFERRED
+ );
+ CREATE TABLE child2(c REFERENCES parent ON DELETE NO ACTION
+ DEFERRABLE INITIALLY DEFERRED
+ );
+
+ INSERT INTO parent VALUES('key1');
+ INSERT INTO parent VALUES('key2');
+ INSERT INTO child1 VALUES('key1');
+ INSERT INTO child2 VALUES('key2');
+ BEGIN;
+ }
+} {}
+do_test e_fkey-43.7 {
+ catchsql { DELETE FROM parent WHERE x = 'key1' }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-43.8 {
+ execsql { DELETE FROM parent WHERE x = 'key2' }
+} {}
+do_test e_fkey-43.9 {
+ catchsql COMMIT
+} {1 {foreign key constraint failed}}
+do_test e_fkey-43.10 {
+ execsql {
+ UPDATE child2 SET c = NULL;
+ COMMIT;
+ }
+} {}
+
+#-------------------------------------------------------------------------
+# Test SET NULL actions.
+#
+# EVIDENCE-OF: R-03353-05327 If the configured action is "SET NULL",
+# then when a parent key is deleted (for ON DELETE SET NULL) or modified
+# (for ON UPDATE SET NULL), the child key columns of all rows in the
+# child table that mapped to the parent key are set to contain SQL NULL
+# values.
+#
+drop_all_tables
+do_test e_fkey-44.1 {
+ execsql {
+ CREATE TABLE pA(x PRIMARY KEY);
+ CREATE TABLE cA(c REFERENCES pA ON DELETE SET NULL);
+ CREATE TABLE cB(c REFERENCES pA ON UPDATE SET NULL);
+
+ INSERT INTO pA VALUES(X'ABCD');
+ INSERT INTO pA VALUES(X'1234');
+ INSERT INTO cA VALUES(X'ABCD');
+ INSERT INTO cB VALUES(X'1234');
+ }
+} {}
+do_test e_fkey-44.2 {
+ execsql {
+ DELETE FROM pA WHERE rowid = 1;
+ SELECT quote(x) FROM pA;
+ }
+} {X'1234'}
+do_test e_fkey-44.3 {
+ execsql {
+ SELECT quote(c) FROM cA;
+ }
+} {NULL}
+do_test e_fkey-44.4 {
+ execsql {
+ UPDATE pA SET x = X'8765' WHERE rowid = 2;
+ SELECT quote(x) FROM pA;
+ }
+} {X'8765'}
+do_test e_fkey-44.5 {
+ execsql { SELECT quote(c) FROM cB }
+} {NULL}
+
+#-------------------------------------------------------------------------
+# Test SET DEFAULT actions.
+#
+# EVIDENCE-OF: R-43054-54832 The "SET DEFAULT" actions are similar to
+# "SET NULL", except that each of the child key columns is set to
+# contain the columns default value instead of NULL.
+#
+drop_all_tables
+do_test e_fkey-45.1 {
+ execsql {
+ CREATE TABLE pA(x PRIMARY KEY);
+ CREATE TABLE cA(c DEFAULT X'0000' REFERENCES pA ON DELETE SET DEFAULT);
+ CREATE TABLE cB(c DEFAULT X'9999' REFERENCES pA ON UPDATE SET DEFAULT);
+
+ INSERT INTO pA(rowid, x) VALUES(1, X'0000');
+ INSERT INTO pA(rowid, x) VALUES(2, X'9999');
+ INSERT INTO pA(rowid, x) VALUES(3, X'ABCD');
+ INSERT INTO pA(rowid, x) VALUES(4, X'1234');
+
+ INSERT INTO cA VALUES(X'ABCD');
+ INSERT INTO cB VALUES(X'1234');
+ }
+} {}
+do_test e_fkey-45.2 {
+ execsql {
+ DELETE FROM pA WHERE rowid = 3;
+ SELECT quote(x) FROM pA;
+ }
+} {X'0000' X'9999' X'1234'}
+do_test e_fkey-45.3 {
+ execsql { SELECT quote(c) FROM cA }
+} {X'0000'}
+do_test e_fkey-45.4 {
+ execsql {
+ UPDATE pA SET x = X'8765' WHERE rowid = 4;
+ SELECT quote(x) FROM pA;
+ }
+} {X'0000' X'9999' X'8765'}
+do_test e_fkey-45.5 {
+ execsql { SELECT quote(c) FROM cB }
+} {X'9999'}
+
+#-------------------------------------------------------------------------
+# Test ON DELETE CASCADE actions.
+#
+# EVIDENCE-OF: R-61376-57267 A "CASCADE" action propagates the delete or
+# update operation on the parent key to each dependent child key.
+#
+# EVIDENCE-OF: R-61809-62207 For an "ON DELETE CASCADE" action, this
+# means that each row in the child table that was associated with the
+# deleted parent row is also deleted.
+#
+drop_all_tables
+do_test e_fkey-46.1 {
+ execsql {
+ CREATE TABLE p1(a, b UNIQUE);
+ CREATE TABLE c1(c REFERENCES p1(b) ON DELETE CASCADE, d);
+ INSERT INTO p1 VALUES(NULL, NULL);
+ INSERT INTO p1 VALUES(4, 4);
+ INSERT INTO p1 VALUES(5, 5);
+ INSERT INTO c1 VALUES(NULL, NULL);
+ INSERT INTO c1 VALUES(4, 4);
+ INSERT INTO c1 VALUES(5, 5);
+ SELECT count(*) FROM c1;
+ }
+} {3}
+do_test e_fkey-46.2 {
+ execsql {
+ DELETE FROM p1 WHERE a = 4;
+ SELECT d, c FROM c1;
+ }
+} {{} {} 5 5}
+do_test e_fkey-46.3 {
+ execsql {
+ DELETE FROM p1;
+ SELECT d, c FROM c1;
+ }
+} {{} {}}
+do_test e_fkey-46.4 {
+ execsql { SELECT * FROM p1 }
+} {}
+
+
+#-------------------------------------------------------------------------
+# Test ON UPDATE CASCADE actions.
+#
+# EVIDENCE-OF: R-13877-64542 For an "ON UPDATE CASCADE" action, it means
+# that the values stored in each dependent child key are modified to
+# match the new parent key values.
+#
+# EVIDENCE-OF: R-61376-57267 A "CASCADE" action propagates the delete or
+# update operation on the parent key to each dependent child key.
+#
+drop_all_tables
+do_test e_fkey-47.1 {
+ execsql {
+ CREATE TABLE p1(a, b UNIQUE);
+ CREATE TABLE c1(c REFERENCES p1(b) ON UPDATE CASCADE, d);
+ INSERT INTO p1 VALUES(NULL, NULL);
+ INSERT INTO p1 VALUES(4, 4);
+ INSERT INTO p1 VALUES(5, 5);
+ INSERT INTO c1 VALUES(NULL, NULL);
+ INSERT INTO c1 VALUES(4, 4);
+ INSERT INTO c1 VALUES(5, 5);
+ SELECT count(*) FROM c1;
+ }
+} {3}
+do_test e_fkey-47.2 {
+ execsql {
+ UPDATE p1 SET b = 10 WHERE b = 5;
+ SELECT d, c FROM c1;
+ }
+} {{} {} 4 4 5 10}
+do_test e_fkey-47.3 {
+ execsql {
+ UPDATE p1 SET b = 11 WHERE b = 4;
+ SELECT d, c FROM c1;
+ }
+} {{} {} 4 11 5 10}
+do_test e_fkey-47.4 {
+ execsql {
+ UPDATE p1 SET b = 6 WHERE b IS NULL;
+ SELECT d, c FROM c1;
+ }
+} {{} {} 4 11 5 10}
+do_test e_fkey-46.5 {
+ execsql { SELECT * FROM p1 }
+} {{} 6 4 11 5 10}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-65058-57158
+#
+# Test an example from the "ON DELETE and ON UPDATE Actions" section
+# of foreignkeys.html.
+#
+drop_all_tables
+do_test e_fkey-48.1 {
+ execsql {
+ CREATE TABLE artist(
+ artistid INTEGER PRIMARY KEY,
+ artistname TEXT
+ );
+ CREATE TABLE track(
+ trackid INTEGER,
+ trackname TEXT,
+ trackartist INTEGER REFERENCES artist(artistid) ON UPDATE CASCADE
+ );
+
+ INSERT INTO artist VALUES(1, 'Dean Martin');
+ INSERT INTO artist VALUES(2, 'Frank Sinatra');
+ INSERT INTO track VALUES(11, 'That''s Amore', 1);
+ INSERT INTO track VALUES(12, 'Christmas Blues', 1);
+ INSERT INTO track VALUES(13, 'My Way', 2);
+ }
+} {}
+do_test e_fkey-48.2 {
+ execsql {
+ UPDATE artist SET artistid = 100 WHERE artistname = 'Dean Martin';
+ }
+} {}
+do_test e_fkey-48.3 {
+ execsql { SELECT * FROM artist }
+} {2 {Frank Sinatra} 100 {Dean Martin}}
+do_test e_fkey-48.4 {
+ execsql { SELECT * FROM track }
+} {11 {That's Amore} 100 12 {Christmas Blues} 100 13 {My Way} 2}
+
+
+#-------------------------------------------------------------------------
+# Verify that adding an FK action does not absolve the user of the
+# requirement not to violate the foreign key constraint.
+#
+# EVIDENCE-OF: R-53968-51642 Configuring an ON UPDATE or ON DELETE
+# action does not mean that the foreign key constraint does not need to
+# be satisfied.
+#
+drop_all_tables
+do_test e_fkey-49.1 {
+ execsql {
+ CREATE TABLE parent(a COLLATE nocase, b, c, PRIMARY KEY(c, a));
+ CREATE TABLE child(d DEFAULT 'a', e, f DEFAULT 'c',
+ FOREIGN KEY(f, d) REFERENCES parent ON UPDATE SET DEFAULT
+ );
+
+ INSERT INTO parent VALUES('A', 'b', 'c');
+ INSERT INTO parent VALUES('ONE', 'two', 'three');
+ INSERT INTO child VALUES('one', 'two', 'three');
+ }
+} {}
+do_test e_fkey-49.2 {
+ execsql {
+ BEGIN;
+ UPDATE parent SET a = '' WHERE a = 'oNe';
+ SELECT * FROM child;
+ }
+} {a two c}
+do_test e_fkey-49.3 {
+ execsql {
+ ROLLBACK;
+ DELETE FROM parent WHERE a = 'A';
+ SELECT * FROM parent;
+ }
+} {ONE two three}
+do_test e_fkey-49.4 {
+ catchsql { UPDATE parent SET a = '' WHERE a = 'oNe' }
+} {1 {foreign key constraint failed}}
+
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-11856-19836
+#
+# Test an example from the "ON DELETE and ON UPDATE Actions" section
+# of foreignkeys.html. This example shows that adding an "ON DELETE DEFAULT"
+# clause does not abrogate the need to satisfy the foreign key constraint
+# (R-28220-46694).
+#
+# EVIDENCE-OF: R-28220-46694 For example, if an "ON DELETE SET DEFAULT"
+# action is configured, but there is no row in the parent table that
+# corresponds to the default values of the child key columns, deleting a
+# parent key while dependent child keys exist still causes a foreign key
+# violation.
+#
+drop_all_tables
+do_test e_fkey-50.1 {
+ execsql {
+ CREATE TABLE artist(
+ artistid INTEGER PRIMARY KEY,
+ artistname TEXT
+ );
+ CREATE TABLE track(
+ trackid INTEGER,
+ trackname TEXT,
+ trackartist INTEGER DEFAULT 0 REFERENCES artist(artistid) ON DELETE SET DEFAULT
+ );
+ INSERT INTO artist VALUES(3, 'Sammy Davis Jr.');
+ INSERT INTO track VALUES(14, 'Mr. Bojangles', 3);
+ }
+} {}
+do_test e_fkey-50.2 {
+ catchsql { DELETE FROM artist WHERE artistname = 'Sammy Davis Jr.' }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-50.3 {
+ execsql {
+ INSERT INTO artist VALUES(0, 'Unknown Artist');
+ DELETE FROM artist WHERE artistname = 'Sammy Davis Jr.';
+ }
+} {}
+do_test e_fkey-50.4 {
+ execsql { SELECT * FROM artist }
+} {0 {Unknown Artist}}
+do_test e_fkey-50.5 {
+ execsql { SELECT * FROM track }
+} {14 {Mr. Bojangles} 0}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-09564-22170
+#
+# Check that the order of steps in an UPDATE or DELETE on a parent
+# table is as follows:
+#
+# 1. Execute applicable BEFORE trigger programs,
+# 2. Check local (non foreign key) constraints,
+# 3. Update or delete the row in the parent table,
+# 4. Perform any required foreign key actions,
+# 5. Execute applicable AFTER trigger programs.
+#
+drop_all_tables
+do_test e_fkey-51.1 {
+ proc maxparent {args} { db one {SELECT max(x) FROM parent} }
+ db func maxparent maxparent
+
+ execsql {
+ CREATE TABLE parent(x PRIMARY KEY);
+
+ CREATE TRIGGER bu BEFORE UPDATE ON parent BEGIN
+ INSERT INTO parent VALUES(new.x-old.x);
+ END;
+ CREATE TABLE child(
+ a DEFAULT (maxparent()) REFERENCES parent ON UPDATE SET DEFAULT
+ );
+ CREATE TRIGGER au AFTER UPDATE ON parent BEGIN
+ INSERT INTO parent VALUES(new.x+old.x);
+ END;
+
+ INSERT INTO parent VALUES(1);
+ INSERT INTO child VALUES(1);
+ }
+} {}
+do_test e_fkey-51.2 {
+ execsql {
+ UPDATE parent SET x = 22;
+ SELECT * FROM parent UNION ALL SELECT 'xxx' UNION ALL SELECT a FROM child;
+ }
+} {22 21 23 xxx 22}
+do_test e_fkey-51.3 {
+ execsql {
+ DELETE FROM child;
+ DELETE FROM parent;
+ INSERT INTO parent VALUES(-1);
+ INSERT INTO child VALUES(-1);
+ UPDATE parent SET x = 22;
+ SELECT * FROM parent UNION ALL SELECT 'xxx' UNION ALL SELECT a FROM child;
+ }
+} {22 23 21 xxx 23}
+
+
+#-------------------------------------------------------------------------
+# Verify that ON UPDATE actions only actually take place if the parent key
+# is set to a new value that is distinct from the old value. The default
+# collation sequence and affinity are used to determine if the new value
+# is 'distinct' from the old or not.
+#
+# EVIDENCE-OF: R-27383-10246 An ON UPDATE action is only taken if the
+# values of the parent key are modified so that the new parent key
+# values are not equal to the old.
+#
+drop_all_tables
+do_test e_fkey-52.1 {
+ execsql {
+ CREATE TABLE zeus(a INTEGER COLLATE NOCASE, b, PRIMARY KEY(a, b));
+ CREATE TABLE apollo(c, d,
+ FOREIGN KEY(c, d) REFERENCES zeus ON UPDATE CASCADE
+ );
+ INSERT INTO zeus VALUES('abc', 'xyz');
+ INSERT INTO apollo VALUES('ABC', 'xyz');
+ }
+ execsql {
+ UPDATE zeus SET a = 'aBc';
+ SELECT * FROM apollo;
+ }
+} {ABC xyz}
+do_test e_fkey-52.2 {
+ execsql {
+ UPDATE zeus SET a = 1, b = 1;
+ SELECT * FROM apollo;
+ }
+} {1 1}
+do_test e_fkey-52.3 {
+ execsql {
+ UPDATE zeus SET a = 1, b = 1;
+ SELECT typeof(c), c, typeof(d), d FROM apollo;
+ }
+} {integer 1 integer 1}
+do_test e_fkey-52.4 {
+ execsql {
+ UPDATE zeus SET a = '1';
+ SELECT typeof(c), c, typeof(d), d FROM apollo;
+ }
+} {integer 1 integer 1}
+do_test e_fkey-52.5 {
+ execsql {
+ UPDATE zeus SET b = '1';
+ SELECT typeof(c), c, typeof(d), d FROM apollo;
+ }
+} {integer 1 text 1}
+do_test e_fkey-52.6 {
+ execsql {
+ UPDATE zeus SET b = NULL;
+ SELECT typeof(c), c, typeof(d), d FROM apollo;
+ }
+} {integer 1 null {}}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-35129-58141
+#
+# Test an example from the "ON DELETE and ON UPDATE Actions" section
+# of foreignkeys.html. This example demonstrates that ON UPDATE actions
+# only take place if at least one parent key column is set to a value
+# that is distinct from its previous value.
+#
+drop_all_tables
+do_test e_fkey-53.1 {
+ execsql {
+ CREATE TABLE parent(x PRIMARY KEY);
+ CREATE TABLE child(y REFERENCES parent ON UPDATE SET NULL);
+ INSERT INTO parent VALUES('key');
+ INSERT INTO child VALUES('key');
+ }
+} {}
+do_test e_fkey-53.2 {
+ execsql {
+ UPDATE parent SET x = 'key';
+ SELECT IFNULL(y, 'null') FROM child;
+ }
+} {key}
+do_test e_fkey-53.3 {
+ execsql {
+ UPDATE parent SET x = 'key2';
+ SELECT IFNULL(y, 'null') FROM child;
+ }
+} {null}
+
+###########################################################################
+### SECTION 5: CREATE, ALTER and DROP TABLE commands
+###########################################################################
+
+#-------------------------------------------------------------------------
+# Test that parent keys are not checked when tables are created.
+#
+# EVIDENCE-OF: R-36018-21755 The parent key definitions of foreign key
+# constraints are not checked when a table is created.
+#
+# EVIDENCE-OF: R-25384-39337 There is nothing stopping the user from
+# creating a foreign key definition that refers to a parent table that
+# does not exist, or to parent key columns that do not exist or are not
+# collectively bound by a PRIMARY KEY or UNIQUE constraint.
+#
+# Child keys are checked to ensure all component columns exist. If parent
+# key columns are explicitly specified, SQLite checks to make sure there
+# are the same number of columns in the child and parent keys. (TODO: This
+# is tested but does not correspond to any testable statement.)
+#
+# Also test that the above statements are true regardless of whether or not
+# foreign keys are enabled: "A CREATE TABLE command operates the same whether
+# or not foreign key constraints are enabled."
+#
+# EVIDENCE-OF: R-08908-23439 A CREATE TABLE command operates the same
+# whether or not foreign key constraints are enabled.
+#
+foreach {tn zCreateTbl lRes} {
+ 1 "CREATE TABLE t1(a, b REFERENCES t1)" {0 {}}
+ 2 "CREATE TABLE t1(a, b REFERENCES t2)" {0 {}}
+ 3 "CREATE TABLE t1(a, b, FOREIGN KEY(a,b) REFERENCES t1)" {0 {}}
+ 4 "CREATE TABLE t1(a, b, FOREIGN KEY(a,b) REFERENCES t2)" {0 {}}
+ 5 "CREATE TABLE t1(a, b, FOREIGN KEY(a,b) REFERENCES t2)" {0 {}}
+ 6 "CREATE TABLE t1(a, b, FOREIGN KEY(a,b) REFERENCES t2(n,d))" {0 {}}
+ 7 "CREATE TABLE t1(a, b, FOREIGN KEY(a,b) REFERENCES t1(a,b))" {0 {}}
+
+ A "CREATE TABLE t1(a, b, FOREIGN KEY(c,b) REFERENCES t2)"
+ {1 {unknown column "c" in foreign key definition}}
+ B "CREATE TABLE t1(a, b, FOREIGN KEY(c,b) REFERENCES t2(d))"
+ {1 {number of columns in foreign key does not match the number of columns in the referenced table}}
+} {
+ do_test e_fkey-54.$tn.off {
+ drop_all_tables
+ execsql {PRAGMA foreign_keys = OFF}
+ catchsql $zCreateTbl
+ } $lRes
+ do_test e_fkey-54.$tn.on {
+ drop_all_tables
+ execsql {PRAGMA foreign_keys = ON}
+ catchsql $zCreateTbl
+ } $lRes
+}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-47952-62498 It is not possible to use the "ALTER TABLE
+# ... ADD COLUMN" syntax to add a column that includes a REFERENCES
+# clause, unless the default value of the new column is NULL. Attempting
+# to do so returns an error.
+#
+proc test_efkey_6 {tn zAlter isError} {
+ drop_all_tables
+
+ do_test e_fkey-56.$tn.1 "
+ execsql { CREATE TABLE tbl(a, b) }
+ [list catchsql $zAlter]
+ " [lindex {{0 {}} {1 {Cannot add a REFERENCES column with non-NULL default value}}} $isError]
+
+}
+
+test_efkey_6 1 "ALTER TABLE tbl ADD COLUMN c REFERENCES xx" 0
+test_efkey_6 2 "ALTER TABLE tbl ADD COLUMN c DEFAULT NULL REFERENCES xx" 0
+test_efkey_6 3 "ALTER TABLE tbl ADD COLUMN c DEFAULT 0 REFERENCES xx" 1
+
+#-------------------------------------------------------------------------
+# Test that ALTER TABLE adjusts REFERENCES clauses when the parent table
+# is RENAMED.
+#
+# EVIDENCE-OF: R-47080-02069 If an "ALTER TABLE ... RENAME TO" command
+# is used to rename a table that is the parent table of one or more
+# foreign key constraints, the definitions of the foreign key
+# constraints are modified to refer to the parent table by its new name
+#
+# Test that these adjustments are visible in the sqlite_master table.
+#
+# EVIDENCE-OF: R-63827-54774 The text of the child CREATE TABLE
+# statement or statements stored in the sqlite_master table are modified
+# to reflect the new parent table name.
+#
+do_test e_fkey-56.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE 'p 1 "parent one"'(a REFERENCES 'p 1 "parent one"', b, PRIMARY KEY(b));
+
+ CREATE TABLE c1(c, d REFERENCES 'p 1 "parent one"' ON UPDATE CASCADE);
+ CREATE TABLE c2(e, f, FOREIGN KEY(f) REFERENCES 'p 1 "parent one"' ON UPDATE CASCADE);
+ CREATE TABLE c3(e, 'f col 2', FOREIGN KEY('f col 2') REFERENCES 'p 1 "parent one"' ON UPDATE CASCADE);
+
+ INSERT INTO 'p 1 "parent one"' VALUES(1, 1);
+ INSERT INTO c1 VALUES(1, 1);
+ INSERT INTO c2 VALUES(1, 1);
+ INSERT INTO c3 VALUES(1, 1);
+
+ -- CREATE TABLE q(a, b, PRIMARY KEY(b));
+ }
+} {}
+do_test e_fkey-56.2 {
+ execsql { ALTER TABLE 'p 1 "parent one"' RENAME TO p }
+} {}
+do_test e_fkey-56.3 {
+ execsql {
+ UPDATE p SET a = 'xxx', b = 'xxx';
+ SELECT * FROM p;
+ SELECT * FROM c1;
+ SELECT * FROM c2;
+ SELECT * FROM c3;
+ }
+} {xxx xxx 1 xxx 1 xxx 1 xxx}
+do_test e_fkey-56.4 {
+ execsql { SELECT sql FROM sqlite_master WHERE type = 'table'}
+} [list \
+ {CREATE TABLE "p"(a REFERENCES "p", b, PRIMARY KEY(b))} \
+ {CREATE TABLE c1(c, d REFERENCES "p" ON UPDATE CASCADE)} \
+ {CREATE TABLE c2(e, f, FOREIGN KEY(f) REFERENCES "p" ON UPDATE CASCADE)} \
+ {CREATE TABLE c3(e, 'f col 2', FOREIGN KEY('f col 2') REFERENCES "p" ON UPDATE CASCADE)} \
+]
+
+#-------------------------------------------------------------------------
+# Check that a DROP TABLE does an implicit DELETE FROM. Which does not
+# cause any triggers to fire, but does fire foreign key actions.
+#
+# EVIDENCE-OF: R-14208-23986 If foreign key constraints are enabled when
+# it is prepared, the DROP TABLE command performs an implicit DELETE to
+# remove all rows from the table before dropping it.
+#
+# EVIDENCE-OF: R-11078-03945 The implicit DELETE does not cause any SQL
+# triggers to fire, but may invoke foreign key actions or constraint
+# violations.
+#
+do_test e_fkey-57.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE p(a, b, PRIMARY KEY(a, b));
+
+ CREATE TABLE c1(c, d, FOREIGN KEY(c, d) REFERENCES p ON DELETE SET NULL);
+ CREATE TABLE c2(c, d, FOREIGN KEY(c, d) REFERENCES p ON DELETE SET DEFAULT);
+ CREATE TABLE c3(c, d, FOREIGN KEY(c, d) REFERENCES p ON DELETE CASCADE);
+ CREATE TABLE c4(c, d, FOREIGN KEY(c, d) REFERENCES p ON DELETE RESTRICT);
+ CREATE TABLE c5(c, d, FOREIGN KEY(c, d) REFERENCES p ON DELETE NO ACTION);
+
+ CREATE TABLE c6(c, d,
+ FOREIGN KEY(c, d) REFERENCES p ON DELETE RESTRICT
+ DEFERRABLE INITIALLY DEFERRED
+ );
+ CREATE TABLE c7(c, d,
+ FOREIGN KEY(c, d) REFERENCES p ON DELETE NO ACTION
+ DEFERRABLE INITIALLY DEFERRED
+ );
+
+ CREATE TABLE log(msg);
+ CREATE TRIGGER tt AFTER DELETE ON p BEGIN
+ INSERT INTO log VALUES('delete ' || old.rowid);
+ END;
+ }
+} {}
+
+do_test e_fkey-57.2 {
+ execsql {
+ INSERT INTO p VALUES('a', 'b');
+ INSERT INTO c1 VALUES('a', 'b');
+ INSERT INTO c2 VALUES('a', 'b');
+ INSERT INTO c3 VALUES('a', 'b');
+ BEGIN;
+ DROP TABLE p;
+ SELECT * FROM c1;
+ }
+} {{} {}}
+do_test e_fkey-57.3 {
+ execsql { SELECT * FROM c2 }
+} {{} {}}
+do_test e_fkey-57.4 {
+ execsql { SELECT * FROM c3 }
+} {}
+do_test e_fkey-57.5 {
+ execsql { SELECT * FROM log }
+} {}
+do_test e_fkey-57.6 {
+ execsql ROLLBACK
+} {}
+do_test e_fkey-57.7 {
+ execsql {
+ BEGIN;
+ DELETE FROM p;
+ SELECT * FROM log;
+ ROLLBACK;
+ }
+} {{delete 1}}
+
+#-------------------------------------------------------------------------
+# If an IMMEDIATE foreign key fails as a result of a DROP TABLE, the
+# DROP TABLE command fails.
+#
+# EVIDENCE-OF: R-32768-47925 If an immediate foreign key constraint is
+# violated, the DROP TABLE statement fails and the table is not dropped.
+#
+do_test e_fkey-58.1 {
+ execsql {
+ DELETE FROM c1;
+ DELETE FROM c2;
+ DELETE FROM c3;
+ }
+ execsql { INSERT INTO c5 VALUES('a', 'b') }
+ catchsql { DROP TABLE p }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-58.2 {
+ execsql { SELECT * FROM p }
+} {a b}
+do_test e_fkey-58.3 {
+ catchsql {
+ BEGIN;
+ DROP TABLE p;
+ }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-58.4 {
+ execsql {
+ SELECT * FROM p;
+ SELECT * FROM c5;
+ ROLLBACK;
+ }
+} {a b a b}
+
+#-------------------------------------------------------------------------
+# If a DEFERRED foreign key fails as a result of a DROP TABLE, attempting
+# to commit the transaction fails unless the violation is fixed.
+#
+# EVIDENCE-OF: R-05903-08460 If a deferred foreign key constraint is
+# violated, then an error is reported when the user attempts to commit
+# the transaction if the foreign key constraint violations still exist
+# at that point.
+#
+do_test e_fkey-59.1 {
+ execsql {
+ DELETE FROM c1 ; DELETE FROM c2 ; DELETE FROM c3 ;
+ DELETE FROM c4 ; DELETE FROM c5 ; DELETE FROM c6 ;
+ DELETE FROM c7
+ }
+} {}
+do_test e_fkey-59.2 {
+ execsql { INSERT INTO c7 VALUES('a', 'b') }
+ execsql {
+ BEGIN;
+ DROP TABLE p;
+ }
+} {}
+do_test e_fkey-59.3 {
+ catchsql COMMIT
+} {1 {foreign key constraint failed}}
+do_test e_fkey-59.4 {
+ execsql { CREATE TABLE p(a, b, PRIMARY KEY(a, b)) }
+ catchsql COMMIT
+} {1 {foreign key constraint failed}}
+do_test e_fkey-59.5 {
+ execsql { INSERT INTO p VALUES('a', 'b') }
+ execsql COMMIT
+} {}
+
+#-------------------------------------------------------------------------
+# Any "foreign key mismatch" errors encountered while running an implicit
+# "DELETE FROM tbl" are ignored.
+#
+# EVIDENCE-OF: R-57242-37005 Any "foreign key mismatch" errors
+# encountered as part of an implicit DELETE are ignored.
+#
+drop_all_tables
+do_test e_fkey-60.1 {
+ execsql {
+ PRAGMA foreign_keys = OFF;
+
+ CREATE TABLE p(a PRIMARY KEY, b REFERENCES nosuchtable);
+ CREATE TABLE c1(c, d, FOREIGN KEY(c, d) REFERENCES a);
+ CREATE TABLE c2(c REFERENCES p(b), d);
+ CREATE TABLE c3(c REFERENCES p ON DELETE SET NULL, d);
+
+ INSERT INTO p VALUES(1, 2);
+ INSERT INTO c1 VALUES(1, 2);
+ INSERT INTO c2 VALUES(1, 2);
+ INSERT INTO c3 VALUES(1, 2);
+ }
+} {}
+do_test e_fkey-60.2 {
+ execsql { PRAGMA foreign_keys = ON }
+ catchsql { DELETE FROM p }
+} {1 {no such table: main.nosuchtable}}
+do_test e_fkey-60.3 {
+ execsql {
+ BEGIN;
+ DROP TABLE p;
+ SELECT * FROM c3;
+ ROLLBACK;
+ }
+} {{} 2}
+do_test e_fkey-60.4 {
+ execsql { CREATE TABLE nosuchtable(x PRIMARY KEY) }
+ catchsql { DELETE FROM p }
+} {1 {foreign key mismatch}}
+do_test e_fkey-60.5 {
+ execsql { DROP TABLE c1 }
+ catchsql { DELETE FROM p }
+} {1 {foreign key mismatch}}
+do_test e_fkey-60.6 {
+ execsql { DROP TABLE c2 }
+ execsql { DELETE FROM p }
+} {}
+
+#-------------------------------------------------------------------------
+# Test that the special behaviours of ALTER and DROP TABLE are only
+# activated when foreign keys are enabled. Special behaviours are:
+#
+# 1. ADD COLUMN not allowing a REFERENCES clause with a non-NULL
+# default value.
+# 2. Modifying foreign key definitions when a parent table is RENAMEd.
+# 3. Running an implicit DELETE FROM command as part of DROP TABLE.
+#
+# EVIDENCE-OF: R-54142-41346 The properties of the DROP TABLE and ALTER
+# TABLE commands described above only apply if foreign keys are enabled.
+#
+do_test e_fkey-61.1.1 {
+ drop_all_tables
+ execsql { CREATE TABLE t1(a, b) }
+ catchsql { ALTER TABLE t1 ADD COLUMN c DEFAULT 'xxx' REFERENCES t2 }
+} {1 {Cannot add a REFERENCES column with non-NULL default value}}
+do_test e_fkey-61.1.2 {
+ execsql { PRAGMA foreign_keys = OFF }
+ execsql { ALTER TABLE t1 ADD COLUMN c DEFAULT 'xxx' REFERENCES t2 }
+ execsql { SELECT sql FROM sqlite_master WHERE name = 't1' }
+} {{CREATE TABLE t1(a, b, c DEFAULT 'xxx' REFERENCES t2)}}
+do_test e_fkey-61.1.3 {
+ execsql { PRAGMA foreign_keys = ON }
+} {}
+
+do_test e_fkey-61.2.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE p(a UNIQUE);
+ CREATE TABLE c(b REFERENCES p(a));
+ BEGIN;
+ ALTER TABLE p RENAME TO parent;
+ SELECT sql FROM sqlite_master WHERE name = 'c';
+ ROLLBACK;
+ }
+} {{CREATE TABLE c(b REFERENCES "parent"(a))}}
+do_test e_fkey-61.2.2 {
+ execsql {
+ PRAGMA foreign_keys = OFF;
+ ALTER TABLE p RENAME TO parent;
+ SELECT sql FROM sqlite_master WHERE name = 'c';
+ }
+} {{CREATE TABLE c(b REFERENCES p(a))}}
+do_test e_fkey-61.2.3 {
+ execsql { PRAGMA foreign_keys = ON }
+} {}
+
+do_test e_fkey-61.3.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE p(a UNIQUE);
+ CREATE TABLE c(b REFERENCES p(a) ON DELETE SET NULL);
+ INSERT INTO p VALUES('x');
+ INSERT INTO c VALUES('x');
+ BEGIN;
+ DROP TABLE p;
+ SELECT * FROM c;
+ ROLLBACK;
+ }
+} {{}}
+do_test e_fkey-61.3.2 {
+ execsql {
+ PRAGMA foreign_keys = OFF;
+ DROP TABLE p;
+ SELECT * FROM c;
+ }
+} {x}
+do_test e_fkey-61.3.3 {
+ execsql { PRAGMA foreign_keys = ON }
+} {}
+
+###########################################################################
+### SECTION 6: Limits and Unsupported Features
+###########################################################################
+
+#-------------------------------------------------------------------------
+# Test that MATCH clauses are parsed, but SQLite treats every foreign key
+# constraint as if it were "MATCH SIMPLE".
+#
+# EVIDENCE-OF: R-24728-13230 SQLite parses MATCH clauses (i.e. does not
+# report a syntax error if you specify one), but does not enforce them.
+#
+# EVIDENCE-OF: R-24450-46174 All foreign key constraints in SQLite are
+# handled as if MATCH SIMPLE were specified.
+#
+foreach zMatch [list SIMPLE PARTIAL FULL Simple parTIAL FuLL ] {
+ drop_all_tables
+ do_test e_fkey-62.$zMatch.1 {
+ execsql "
+ CREATE TABLE p(a, b, c, PRIMARY KEY(b, c));
+ CREATE TABLE c(d, e, f, FOREIGN KEY(e, f) REFERENCES p MATCH $zMatch);
+ "
+ } {}
+ do_test e_fkey-62.$zMatch.2 {
+ execsql { INSERT INTO p VALUES(1, 2, 3) }
+
+ # MATCH SIMPLE behaviour: Allow any child key that contains one or more
+ # NULL value to be inserted. Non-NULL values do not have to map to any
+ # parent key values, so long as at least one field of the child key is
+ # NULL.
+ execsql { INSERT INTO c VALUES('w', 2, 3) }
+ execsql { INSERT INTO c VALUES('x', 'x', NULL) }
+ execsql { INSERT INTO c VALUES('y', NULL, 'x') }
+ execsql { INSERT INTO c VALUES('z', NULL, NULL) }
+
+ # Check that the FK is enforced properly if there are no NULL values
+ # in the child key columns.
+ catchsql { INSERT INTO c VALUES('a', 2, 4) }
+ } {1 {foreign key constraint failed}}
+}
+
+#-------------------------------------------------------------------------
+# Test that SQLite does not support the SET CONSTRAINT statement. And
+# that it is possible to create both immediate and deferred constraints.
+#
+# EVIDENCE-OF: R-21599-16038 In SQLite, a foreign key constraint is
+# permanently marked as deferred or immediate when it is created.
+#
+drop_all_tables
+do_test e_fkey-62.1 {
+ catchsql { SET CONSTRAINTS ALL IMMEDIATE }
+} {1 {near "SET": syntax error}}
+do_test e_fkey-62.2 {
+ catchsql { SET CONSTRAINTS ALL DEFERRED }
+} {1 {near "SET": syntax error}}
+
+do_test e_fkey-62.3 {
+ execsql {
+ CREATE TABLE p(a, b, PRIMARY KEY(a, b));
+ CREATE TABLE cd(c, d,
+ FOREIGN KEY(c, d) REFERENCES p DEFERRABLE INITIALLY DEFERRED);
+ CREATE TABLE ci(c, d,
+ FOREIGN KEY(c, d) REFERENCES p DEFERRABLE INITIALLY IMMEDIATE);
+ BEGIN;
+ }
+} {}
+do_test e_fkey-62.4 {
+ catchsql { INSERT INTO ci VALUES('x', 'y') }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-62.5 {
+ catchsql { INSERT INTO cd VALUES('x', 'y') }
+} {0 {}}
+do_test e_fkey-62.6 {
+ catchsql { COMMIT }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-62.7 {
+ execsql {
+ DELETE FROM cd;
+ COMMIT;
+ }
+} {}
+
+#-------------------------------------------------------------------------
+# Test that the maximum recursion depth of foreign key action programs is
+# governed by the SQLITE_MAX_TRIGGER_DEPTH and SQLITE_LIMIT_TRIGGER_DEPTH
+# settings.
+#
+# EVIDENCE-OF: R-42264-30503 The SQLITE_MAX_TRIGGER_DEPTH and
+# SQLITE_LIMIT_TRIGGER_DEPTH settings determine the maximum allowable
+# depth of trigger program recursion. For the purposes of these limits,
+# foreign key actions are considered trigger programs.
+#
+proc test_on_delete_recursion {limit} {
+ drop_all_tables
+ execsql {
+ BEGIN;
+ CREATE TABLE t0(a PRIMARY KEY, b);
+ INSERT INTO t0 VALUES('x0', NULL);
+ }
+ for {set i 1} {$i <= $limit} {incr i} {
+ execsql "
+ CREATE TABLE t$i (
+ a PRIMARY KEY, b REFERENCES t[expr $i-1] ON DELETE CASCADE
+ );
+ INSERT INTO t$i VALUES('x$i', 'x[expr $i-1]');
+ "
+ }
+ execsql COMMIT
+ catchsql "
+ DELETE FROM t0;
+ SELECT count(*) FROM t$limit;
+ "
+}
+proc test_on_update_recursion {limit} {
+ drop_all_tables
+ execsql {
+ BEGIN;
+ CREATE TABLE t0(a PRIMARY KEY);
+ INSERT INTO t0 VALUES('xxx');
+ }
+ for {set i 1} {$i <= $limit} {incr i} {
+ set j [expr $i-1]
+
+ execsql "
+ CREATE TABLE t$i (a PRIMARY KEY REFERENCES t$j ON UPDATE CASCADE);
+ INSERT INTO t$i VALUES('xxx');
+ "
+ }
+ execsql COMMIT
+ catchsql "
+ UPDATE t0 SET a = 'yyy';
+ SELECT NOT (a='yyy') FROM t$limit;
+ "
+}
+
+do_test e_fkey-63.1.1 {
+ test_on_delete_recursion $SQLITE_MAX_TRIGGER_DEPTH
+} {0 0}
+do_test e_fkey-63.1.2 {
+ test_on_delete_recursion [expr $SQLITE_MAX_TRIGGER_DEPTH+1]
+} {1 {too many levels of trigger recursion}}
+do_test e_fkey-63.1.3 {
+ sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 5
+ test_on_delete_recursion 5
+} {0 0}
+do_test e_fkey-63.1.4 {
+ test_on_delete_recursion 6
+} {1 {too many levels of trigger recursion}}
+do_test e_fkey-63.1.5 {
+ sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1000000
+} {5}
+do_test e_fkey-63.2.1 {
+ test_on_update_recursion $SQLITE_MAX_TRIGGER_DEPTH
+} {0 0}
+do_test e_fkey-63.2.2 {
+ test_on_update_recursion [expr $SQLITE_MAX_TRIGGER_DEPTH+1]
+} {1 {too many levels of trigger recursion}}
+do_test e_fkey-63.2.3 {
+ sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 5
+ test_on_update_recursion 5
+} {0 0}
+do_test e_fkey-63.2.4 {
+ test_on_update_recursion 6
+} {1 {too many levels of trigger recursion}}
+do_test e_fkey-63.2.5 {
+ sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1000000
+} {5}
+
+#-------------------------------------------------------------------------
+# The setting of the recursive_triggers pragma does not affect foreign
+# key actions.
+#
+# EVIDENCE-OF: R-51769-32730 The PRAGMA recursive_triggers setting does
+# not not affect the operation of foreign key actions.
+#
+foreach recursive_triggers_setting [list 0 1 ON OFF] {
+ drop_all_tables
+ execsql "PRAGMA recursive_triggers = $recursive_triggers_setting"
+
+ do_test e_fkey-64.$recursive_triggers_setting.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1 ON DELETE CASCADE);
+ INSERT INTO t1 VALUES(1, NULL);
+ INSERT INTO t1 VALUES(2, 1);
+ INSERT INTO t1 VALUES(3, 2);
+ INSERT INTO t1 VALUES(4, 3);
+ INSERT INTO t1 VALUES(5, 4);
+ SELECT count(*) FROM t1;
+ }
+ } {5}
+ do_test e_fkey-64.$recursive_triggers_setting.2 {
+ execsql { SELECT count(*) FROM t1 WHERE a = 1 }
+ } {1}
+ do_test e_fkey-64.$recursive_triggers_setting.3 {
+ execsql {
+ DELETE FROM t1 WHERE a = 1;
+ SELECT count(*) FROM t1;
+ }
+ } {0}
+}
+
+finish_test
diff --git a/test/e_fts3.test b/test/e_fts3.test
new file mode 100644
index 0000000..2a580ca
--- /dev/null
+++ b/test/e_fts3.test
@@ -0,0 +1,706 @@
+# 2009 November 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify the "testable statements" in the
+# fts3.in document.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build does not include FTS3, skip the tests in this file.
+#
+ifcapable !fts3 { finish_test ; return }
+source $testdir/fts3_common.tcl
+source $testdir/malloc_common.tcl
+
+# Procs used to make the tests in this file easier to read.
+#
+proc ddl_test {tn ddl} {
+ uplevel [list do_write_test e_fts3-$tn sqlite_master $ddl]
+}
+proc write_test {tn tbl sql} {
+ uplevel [list do_write_test e_fts3-$tn $tbl $sql]
+}
+proc read_test {tn sql result} {
+ uplevel [list do_select_test e_fts3-$tn $sql $result]
+}
+proc error_test {tn sql result} {
+ uplevel [list do_error_test e_fts3-$tn $sql $result]
+}
+
+
+#-------------------------------------------------------------------------
+# The body of the following [foreach] block contains test cases to verify
+# that the example code in fts3.html works as expected. The tests run three
+# times, with different values for DO_MALLOC_TEST.
+#
+# DO_MALLOC_TEST=0: Run tests with no OOM errors.
+# DO_MALLOC_TEST=1: Run tests with transient OOM errors.
+# DO_MALLOC_TEST=2: Run tests with persistent OOM errors.
+#
+foreach {DO_MALLOC_TEST enc} {
+ 0 utf-8
+ 1 utf-8
+ 2 utf-8
+ 1 utf-16
+} {
+
+#if {$DO_MALLOC_TEST} break
+
+# Reset the database and database connection. If this iteration of the
+# [foreach] loop is testing with OOM errors, disable the lookaside buffer.
+#
+db close
+forcedelete test.db test.db-journal
+sqlite3 db test.db
+if {$DO_MALLOC_TEST} { sqlite3_db_config_lookaside db 0 0 0 }
+db eval "PRAGMA encoding = '$enc'"
+
+proc mit {blob} {
+ set scan(littleEndian) i*
+ set scan(bigEndian) I*
+ binary scan $blob $scan($::tcl_platform(byteOrder)) r
+ return $r
+}
+db func mit mit
+
+##########################################################################
+# Test the example CREATE VIRTUAL TABLE statements in section 1.1
+# of fts3.in.
+#
+ddl_test 1.1.1.1 {CREATE VIRTUAL TABLE data USING fts3()}
+read_test 1.1.1.2 {PRAGMA table_info(data)} {0 content {} 0 {} 0}
+
+ddl_test 1.1.2.1 {
+ CREATE VIRTUAL TABLE pages USING fts3(title, keywords, body)
+}
+read_test 1.1.2.2 {
+ PRAGMA table_info(pages)
+} {0 title {} 0 {} 0 1 keywords {} 0 {} 0 2 body {} 0 {} 0}
+
+ddl_test 1.1.3.1 {
+ CREATE VIRTUAL TABLE mail USING fts3(
+ subject VARCHAR(256) NOT NULL,
+ body TEXT CHECK(length(body)<10240)
+ )
+}
+read_test 1.1.3.2 {
+ PRAGMA table_info(mail)
+} {0 subject {} 0 {} 0 1 body {} 0 {} 0}
+
+# A very large string. Used to test if the constraint on column "body" of
+# table "mail" is enforced (it should not be - FTS3 tables do not support
+# constraints).
+set largetext [string repeat "the quick brown fox " 5000]
+write_test 1.1.3.3 mail_content { INSERT INTO mail VALUES(NULL, $largetext) }
+read_test 1.1.3.4 {
+ SELECT subject IS NULL, length(body) FROM mail
+} [list 1 100000]
+
+ddl_test 1.1.4.1 {
+ CREATE VIRTUAL TABLE papers USING fts3(author, document, tokenize=porter)
+}
+read_test 1.1.4.2 {
+ PRAGMA table_info(papers)
+} {0 author {} 0 {} 0 1 document {} 0 {} 0}
+
+ddl_test 1.1.5.1 {
+ CREATE VIRTUAL TABLE simpledata USING fts3(tokenize=simple)
+}
+read_test 1.1.5.2 {
+ PRAGMA table_info(simpledata)
+} {0 content {} 0 {} 0}
+
+ifcapable icu {
+ ddl_test 1.1.6.1 {
+ CREATE VIRTUAL TABLE names USING fts3(a, b, tokenize=icu en_AU)
+ }
+ read_test 1.1.6.2 {
+ PRAGMA table_info(names)
+ } {0 a {} 0 {} 0 1 b {} 0 {} 0}
+}
+
+ddl_test 1.1.7.1 {DROP TABLE data}
+ddl_test 1.1.7.2 {DROP TABLE pages}
+ddl_test 1.1.7.3 {DROP TABLE mail}
+ddl_test 1.1.7.4 {DROP TABLE papers}
+ddl_test 1.1.7.5 {DROP TABLE simpledata}
+read_test 1.1.7.6 {SELECT * FROM sqlite_master} {}
+
+# The following is not one of the examples in section 1.1. It tests
+# specifying an FTS3 table with no module arguments using a slightly
+# different syntax.
+ddl_test 1.1.8.1 {CREATE VIRTUAL TABLE data USING fts3;}
+read_test 1.1.8.2 {PRAGMA table_info(data)} {0 content {} 0 {} 0}
+ddl_test 1.1.8.3 {DROP TABLE data}
+
+##########################################################################
+# Test the examples in section 1.2 (populating fts3 tables)
+#
+ddl_test 1.2.1.1 {
+ CREATE VIRTUAL TABLE pages USING fts3(title, body);
+}
+write_test 1.2.1.2 pages_content {
+ INSERT INTO pages(docid, title, body)
+ VALUES(53, 'Home Page', 'SQLite is a software...');
+}
+read_test 1.2.1.3 {
+ SELECT docid, * FROM pages
+} {53 {Home Page} {SQLite is a software...}}
+
+write_test 1.2.1.4 pages_content {
+ INSERT INTO pages(title, body)
+ VALUES('Download', 'All SQLite source code...');
+}
+read_test 1.2.1.5 {
+ SELECT docid, * FROM pages
+} {53 {Home Page} {SQLite is a software...} 54 Download {All SQLite source code...}}
+
+write_test 1.2.1.6 pages_content {
+ UPDATE pages SET title = 'Download SQLite' WHERE rowid = 54
+}
+read_test 1.2.1.7 {
+ SELECT docid, * FROM pages
+} {53 {Home Page} {SQLite is a software...} 54 {Download SQLite} {All SQLite source code...}}
+
+write_test 1.2.1.8 pages_content { DELETE FROM pages }
+read_test 1.2.1.9 { SELECT docid, * FROM pages } {}
+
+do_error_test fts3-1.2.1.10 {
+ INSERT INTO pages(rowid, docid, title, body) VALUES(1, 2, 'A title', 'A document body');
+} {SQL logic error or missing database}
+
+# Test the optimize() function example:
+ddl_test 1.2.2.1 { CREATE VIRTUAL TABLE docs USING fts3 }
+write_test 1.2.2.2 docs_content {
+ INSERT INTO docs VALUES('Others translate the first clause as');
+}
+write_test 1.2.2.3 docs_content {
+ INSERT INTO docs VALUES('"which is for Solomon," meaning that');
+}
+write_test 1.2.2.4 docs_content {
+ INSERT INTO docs VALUES('the book is dedicated to Solomon.');
+}
+read_test 1.2.2.5 { SELECT count(*) FROM docs_segdir } {3}
+write_test 1.2.2.6 docs_segdir {
+ INSERT INTO docs(docs) VALUES('optimize');
+}
+read_test 1.2.2.7 { SELECT count(*) FROM docs_segdir } {1}
+ddl_test 1.2.2.8 { DROP TABLE docs }
+
+##########################################################################
+# Test the examples in section 1.3 (querying FTS3 tables)
+#
+ddl_test 1.3.1.1 { CREATE VIRTUAL TABLE mail USING fts3(subject, body) }
+read_test 1.3.1.2 {
+ SELECT * FROM mail WHERE rowid = 15; -- Fast. Rowid lookup.
+ SELECT * FROM mail WHERE body MATCH 'sqlite'; -- Fast. Full-text query.
+ SELECT * FROM mail WHERE mail MATCH 'search'; -- Fast. Full-text query.
+ SELECT * FROM mail WHERE rowid BETWEEN 15 AND 20; -- Slow. Linear scan.
+ SELECT * FROM mail WHERE subject = 'database'; -- Slow. Linear scan.
+ SELECT * FROM mail WHERE subject MATCH 'database'; -- Fast. Full-text query.
+} {}
+ddl_test 1.3.1.3 { DROP TABLE mail }
+
+ddl_test 1.3.2.1 { CREATE VIRTUAL TABLE mail USING fts3(subject, body) }
+
+write_test 1.3.2.2 mail_content {
+ INSERT INTO mail(docid, subject, body)
+ VALUES(1, 'software feedback', 'found it too slow')
+}
+write_test 1.3.2.3 mail_content {
+ INSERT INTO mail(docid, subject, body)
+ VALUES(2, 'software feedback', 'no feedback')
+}
+write_test 1.3.2.4 mail_content {
+ INSERT INTO mail(docid, subject, body)
+ VALUES(3, 'slow lunch order', 'was a software problem')
+}
+read_test 1.3.2.5 {
+ SELECT * FROM mail WHERE subject MATCH 'software'
+} {{software feedback} {found it too slow} {software feedback} {no feedback}}
+read_test 1.3.2.6 {
+ SELECT * FROM mail WHERE body MATCH 'feedback'
+} {{software feedback} {no feedback}}
+read_test 1.3.2.7 {
+ SELECT * FROM mail WHERE mail MATCH 'software'
+} {{software feedback} {found it too slow} {software feedback} {no feedback} {slow lunch order} {was a software problem}}
+read_test 1.3.2.7 {
+ SELECT * FROM mail WHERE mail MATCH 'slow'
+} {{software feedback} {found it too slow} {slow lunch order} {was a software problem}}
+ddl_test 1.3.2.8 { DROP TABLE mail }
+
+ddl_test 1.3.3.1 { CREATE VIRTUAL TABLE docs USING fts3(content) }
+read_test 1.3.3.2 { SELECT * FROM docs WHERE docs MATCH 'sqlite' } {}
+read_test 1.3.3.3 { SELECT * FROM docs WHERE docs.docs MATCH 'sqlite' } {}
+read_test 1.3.3.4 { SELECT * FROM docs WHERE main.docs.docs MATCH 'sqlite' } {}
+do_error_test e_fts3-1.3.3.5 {
+ SELECT * FROM docs WHERE main.docs MATCH 'sqlite'
+} {no such column: main.docs}
+ddl_test 1.3.2.8 { DROP TABLE docs }
+
+##########################################################################
+# Test the examples in section 3 (full-text index queries).
+#
+ddl_test 1.4.1.1 { CREATE VIRTUAL TABLE docs USING fts3(title, body) }
+unset -nocomplain R
+foreach {tn title body} {
+ 2 "linux driver" "a device"
+ 3 "driver" "linguistic trick"
+ 4 "problems" "linux problems"
+ 5 "linux" "big problems"
+ 6 "linux driver" "a device driver problem"
+ 7 "good times" "applications for linux"
+ 8 "not so good" "linux applications"
+ 9 "alternative" "linoleum appliances"
+ 10 "no L I N" "to be seen"
+} {
+ write_test 1.4.1.$tn docs_content { INSERT INTO docs VALUES($title,$body) }
+ set R($tn) [list $title $body]
+}
+
+read_test 1.4.1.11 {
+ SELECT * FROM docs WHERE docs MATCH 'linux'
+} [concat $R(2) $R(4) $R(5) $R(6) $R(7) $R(8)]
+read_test 1.4.1.12 {
+ SELECT * FROM docs WHERE docs MATCH 'lin*'
+} [concat $R(2) $R(3) $R(4) $R(5) $R(6) $R(7) $R(8) $R(9)]
+read_test 1.4.1.13 {
+ SELECT * FROM docs WHERE docs MATCH 'title:linux problems'
+} [concat $R(5)]
+read_test 1.4.1.14 {
+ SELECT * FROM docs WHERE body MATCH 'title:linux driver'
+} [concat $R(6)]
+read_test 1.4.1.15 {
+ SELECT * FROM docs WHERE docs MATCH '"linux applications"'
+} [concat $R(8)]
+read_test 1.4.1.16 {
+ SELECT * FROM docs WHERE docs MATCH '"lin* app*"'
+} [concat $R(8) $R(9)]
+ddl_test 1.4.1.17 { DROP TABLE docs }
+unset R
+
+ddl_test 1.4.2.1 { CREATE VIRTUAL TABLE docs USING fts3() }
+write_test 1.4.2.2 docs_content {
+ INSERT INTO docs VALUES(
+ 'SQLite is an ACID compliant embedded relational database management system')
+}
+foreach {tn query hit} {
+3 {SELECT * FROM docs WHERE docs MATCH 'sqlite NEAR database'} 1
+4 {SELECT * FROM docs WHERE docs MATCH 'database NEAR/6 sqlite'} 1
+5 {SELECT * FROM docs WHERE docs MATCH 'database NEAR/5 sqlite'} 0
+6 {SELECT * FROM docs WHERE docs MATCH 'database NEAR/2 "ACID compliant"'} 1
+7 {SELECT * FROM docs WHERE docs MATCH '"ACID compliant" NEAR/2 sqlite'} 1
+8 {SELECT * FROM docs WHERE docs MATCH 'sqlite NEAR/2 acid NEAR/2 relational'} 1
+9 {SELECT * FROM docs WHERE docs MATCH 'acid NEAR/2 sqlite NEAR/2 relational'} 0
+} {
+ set res [db eval {SELECT * FROM docs WHERE $hit}]
+ read_test 1.4.2.$tn $query $res
+}
+ddl_test 1.4.2.10 { DROP TABLE docs }
+
+##########################################################################
+# Test the example in section 3.1 (set operators with enhanced syntax).
+#
+set sqlite_fts3_enable_parentheses 1
+ddl_test 1.5.1.1 { CREATE VIRTUAL TABLE docs USING fts3() }
+foreach {tn docid content} {
+ 2 1 "a database is a software system"
+ 3 2 "sqlite is a software system"
+ 4 3 "sqlite is a database"
+} {
+ set R($docid) $content
+ write_test 1.5.1.$tn docs_content {
+ INSERT INTO docs(docid, content) VALUES($docid, $content)
+ }
+}
+read_test 1.5.1.4 {
+ SELECT * FROM docs WHERE docs MATCH 'sqlite AND database'
+} [list $R(3)]
+read_test 1.5.1.5 {
+ SELECT * FROM docs WHERE docs MATCH 'database sqlite'
+} [list $R(3)]
+read_test 1.5.1.6 {
+ SELECT * FROM docs WHERE docs MATCH 'sqlite OR database'
+} [list $R(1) $R(2) $R(3)]
+read_test 1.5.1.7 {
+ SELECT * FROM docs WHERE docs MATCH 'database NOT sqlite'
+} [list $R(1)]
+read_test 1.5.1.8 {
+ SELECT * FROM docs WHERE docs MATCH 'database and sqlite'
+} {}
+
+write_test 1.5.2.1 docs_content {
+ INSERT INTO docs
+ SELECT 'sqlite is also a library' UNION ALL
+ SELECT 'library software'
+}
+read_test 1.5.2.2 {
+ SELECT docid FROM docs WHERE docs MATCH 'sqlite AND database OR library'
+} {3 4 5}
+read_test 1.5.2.3 {
+ SELECT docid FROM docs WHERE docs MATCH 'sqlite AND database'
+ UNION
+ SELECT docid FROM docs WHERE docs MATCH 'library'
+} {3 4 5}
+write_test 1.5.2.4 docs_content {
+ INSERT INTO docs
+ SELECT 'the sqlite library runs on linux' UNION ALL
+ SELECT 'as does the sqlite database (on linux)' UNION ALL
+ SELECT 'the sqlite database is accessed by the sqlite library'
+}
+read_test 1.5.2.2 {
+ SELECT docid FROM docs
+ WHERE docs MATCH '("sqlite database" OR "sqlite library") AND linux';
+} {6 7}
+read_test 1.5.2.3 {
+ SELECT docid FROM docs WHERE docs MATCH 'linux'
+ INTERSECT
+ SELECT docid FROM (
+ SELECT docid FROM docs WHERE docs MATCH '"sqlite library"'
+ UNION
+ SELECT docid FROM docs WHERE docs MATCH '"sqlite database"'
+ );
+} {6 7}
+
+##########################################################################
+# Test the examples in section 3.2 (set operators with standard syntax).
+# These tests reuse the table populated by the block above.
+#
+set sqlite_fts3_enable_parentheses 0
+read_test 1.6.1.1 {
+ SELECT * FROM docs WHERE docs MATCH 'sqlite -database'
+} {{sqlite is a software system} {sqlite is also a library} {the sqlite library runs on linux}}
+read_test 1.6.1.2 {
+ SELECT * FROM docs WHERE docs MATCH 'sqlite OR database library'
+} {{sqlite is also a library} {the sqlite library runs on linux} {the sqlite database is accessed by the sqlite library}}
+
+set sqlite_fts3_enable_parentheses 1
+read_test 1.6.1.3 {
+ SELECT * FROM docs WHERE docs MATCH 'sqlite OR database library'
+} {{sqlite is a software system} {sqlite is a database} {sqlite is also a library} {the sqlite library runs on linux} {as does the sqlite database (on linux)} {the sqlite database is accessed by the sqlite library}}
+read_test 1.6.1.4 {
+ SELECT * FROM docs WHERE docs MATCH '(sqlite OR database) library'
+} {{sqlite is also a library} {the sqlite library runs on linux} {the sqlite database is accessed by the sqlite library}}
+set sqlite_fts3_enable_parentheses 0
+ddl_test 1.6.1.5 { DROP TABLE docs }
+
+##########################################################################
+# Test the examples in section 4 (auxillary functions).
+#
+ddl_test 1.7.1.1 { CREATE VIRTUAL TABLE mail USING fts3(subject, body) }
+
+write_test 1.7.1.2 mail_content {
+ INSERT INTO mail VALUES(
+ 'hello world', 'This message is a hello world message.');
+}
+write_test 1.7.1.3 mail_content {
+ INSERT INTO mail VALUES(
+ 'urgent: serious', 'This mail is seen as a more serious mail');
+}
+
+read_test 1.7.1.4 {
+ SELECT offsets(mail) FROM mail WHERE mail MATCH 'world';
+} {{0 0 6 5 1 0 24 5}}
+read_test 1.7.1.5 {
+ SELECT offsets(mail) FROM mail WHERE mail MATCH 'message'
+} {{1 0 5 7 1 0 30 7}}
+read_test 1.7.1.6 {
+ SELECT offsets(mail) FROM mail WHERE mail MATCH '"serious mail"'
+} {{1 0 28 7 1 1 36 4}}
+
+ddl_test 1.7.2.1 { CREATE VIRTUAL TABLE text USING fts3() }
+
+write_test 1.7.2.2 text_content {
+ INSERT INTO text VALUES('
+ During 30 Nov-1 Dec, 2-3oC drops. Cool in the upper portion, minimum temperature 14-16oC and cool elsewhere, minimum temperature 17-20oC. Cold to very cold on mountaintops, minimum temperature 6-12oC. Northeasterly winds 15-30 km/hr. After that, temperature increases. Northeasterly winds 15-30 km/hr.
+ ');
+}
+
+read_test 1.7.2.3 {
+ SELECT snippet(text) FROM text WHERE text MATCH 'cold'
+} {{<b>...</b>cool elsewhere, minimum temperature 17-20oC. <b>Cold</b> to very <b>cold</b> on mountaintops, minimum temperature 6<b>...</b>}}
+
+read_test 1.7.2.4 {
+ SELECT snippet(text, '[', ']', '...') FROM text WHERE text MATCH '"min* tem*"'
+} {{...the upper portion, [minimum] [temperature] 14-16oC and cool elsewhere, [minimum] [temperature] 17-20oC. Cold...}}
+
+ddl_test 1.7.3.1 { DROP TABLE IF EXISTS t1 }
+ddl_test 1.7.3.2 { CREATE VIRTUAL TABLE t1 USING fts3(a, b) }
+write_test 1.7.3.3 t1_content {
+ INSERT INTO t1 VALUES(
+ 'transaction default models default', 'Non transaction reads');
+}
+write_test 1.7.3.4 t1_content {
+ INSERT INTO t1 VALUES('the default transaction', 'these semantics present');
+}
+write_test 1.7.3.5 t1_content {
+ INSERT INTO t1 VALUES('single request', 'default data');
+}
+read_test 1.7.3.6 {
+ SELECT mit(matchinfo(t1)) FROM t1
+ WHERE t1 MATCH 'default transaction "these semantics"';
+} {{3 2 1 3 2 0 1 1 1 2 2 0 1 1 0 0 0 1 1 1}}
+
+##########################################################################
+# Test the example in section 5 (custom tokenizers).
+#
+ddl_test 1.8.1.1 { CREATE VIRTUAL TABLE simple USING fts3(tokenize=simple) }
+write_test 1.8.1.2 simple_content {
+ INSERT INTO simple VALUES('Right now they''re very frustrated')
+}
+read_test 1.8.1.3 {SELECT docid FROM simple WHERE simple MATCH 'Frustrated'} {1}
+read_test 1.8.1.4 {SELECT docid FROM simple WHERE simple MATCH 'Frustration'} {}
+
+ddl_test 1.8.2.1 { CREATE VIRTUAL TABLE porter USING fts3(tokenize=porter) }
+write_test 1.8.2.2 porter_content {
+ INSERT INTO porter VALUES('Right now they''re very frustrated')
+}
+read_test 1.8.2.4 {
+ SELECT docid FROM porter WHERE porter MATCH 'Frustration'
+} {1}
+
+}
+# End of tests of example code in fts3.html
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Test that errors in the arguments passed to the snippet and offsets
+# functions are handled correctly.
+#
+set DO_MALLOC_TEST 0
+ddl_test 2.1.0 { DROP TABLE IF EXISTS t1 }
+ddl_test 2.1.1 { CREATE VIRTUAL TABLE t1 USING fts3(a, b) }
+write_test 2.1.2 t1_content {
+ INSERT INTO t1 VALUES('one two three', x'A1B2C3D4E5F6');
+}
+error_test 2.1.3 {
+ SELECT offsets(a) FROM t1 WHERE a MATCH 'one'
+} {illegal first argument to offsets}
+error_test 2.1.4 {
+ SELECT offsets(b) FROM t1 WHERE a MATCH 'one'
+} {illegal first argument to offsets}
+error_test 2.1.5 {
+ SELECT optimize(a) FROM t1 LIMIT 1
+} {illegal first argument to optimize}
+error_test 2.1.6 {
+ SELECT snippet(a) FROM t1 WHERE a MATCH 'one'
+} {illegal first argument to snippet}
+error_test 2.1.7 {
+ SELECT snippet() FROM t1 WHERE a MATCH 'one'
+} {unable to use function snippet in the requested context}
+error_test 2.1.8 {
+ SELECT snippet(a, b, 'A', 'B', 'C', 'D', 'E') FROM t1 WHERE a MATCH 'one'
+} {wrong number of arguments to function snippet()}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Test the effect of an OOM error while installing the FTS3 module (i.e.
+# opening a database handle). This case was not tested by the OOM testing
+# of the document examples above.
+#
+do_malloc_test e_fts3-3 -tclbody {
+ if {[catch {sqlite3 db test.db}]} { error "out of memory" }
+}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Verify the return values of the optimize() function. If no error occurs,
+# the returned value should be "Index optimized" if the data structure
+# was modified, or "Index already optimal" if it were not.
+#
+set DO_MALLOC_TEST 0
+ddl_test 4.1 { CREATE VIRTUAL TABLE t4 USING fts3(a, b) }
+write_test 4.2 t4_content {
+ INSERT INTO t4 VALUES('In Xanadu', 'did Kubla Khan');
+}
+write_test 4.3 t4_content {
+ INSERT INTO t4 VALUES('a stately pleasure', 'dome decree');
+}
+do_test e_fts3-4.4 {
+ execsql { SELECT optimize(t4) FROM t4 LIMIT 1 }
+} {{Index optimized}}
+do_test e_fts3-4.5 {
+ execsql { SELECT optimize(t4) FROM t4 LIMIT 1 }
+} {{Index already optimal}}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Test that the snippet function appears to work correctly with 1, 2, 3
+# or 4 arguments passed to it.
+#
+set DO_MALLOC_TEST 0
+ddl_test 5.1 { CREATE VIRTUAL TABLE t5 USING fts3(x) }
+write_test 5.2 t5_content {
+ INSERT INTO t5 VALUES('In Xanadu did Kubla Khan A stately pleasure-dome decree Where Alph, the sacred river, ran Through caverns measureless to man Down to a sunless sea. So twice five miles of fertile ground With walls and towers were girdled round : And there were gardens bright with sinuous rills, Where blossomed many an incense-bearing tree ; And here were forests ancient as the hills, Enfolding sunny spots of greenery.');
+}
+read_test 5.3 {
+ SELECT snippet(t5) FROM t5 WHERE t5 MATCH 'miles'
+} {{<b>...</b>to a sunless sea. So twice five <b>miles</b> of fertile ground With walls and towers<b>...</b>}}
+read_test 5.4 {
+ SELECT snippet(t5, '<i>') FROM t5 WHERE t5 MATCH 'miles'
+} {{<b>...</b>to a sunless sea. So twice five <i>miles</b> of fertile ground With walls and towers<b>...</b>}}
+read_test 5.5 {
+ SELECT snippet(t5, '<i>', '</i>') FROM t5 WHERE t5 MATCH 'miles'
+} {{<b>...</b>to a sunless sea. So twice five <i>miles</i> of fertile ground With walls and towers<b>...</b>}}
+read_test 5.6 {
+ SELECT snippet(t5, '<i>', '</i>', 'XXX') FROM t5 WHERE t5 MATCH 'miles'
+} {{XXXto a sunless sea. So twice five <i>miles</i> of fertile ground With walls and towersXXX}}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Test that an empty MATCH expression returns an empty result set. As
+# does passing a NULL value as a MATCH expression.
+#
+set DO_MALLOC_TEST 0
+ddl_test 6.1 { CREATE VIRTUAL TABLE t6 USING fts3(x) }
+write_test 6.2 t5_content { INSERT INTO t6 VALUES('a'); }
+write_test 6.3 t5_content { INSERT INTO t6 VALUES('b'); }
+write_test 6.4 t5_content { INSERT INTO t6 VALUES('c'); }
+read_test 6.5 { SELECT * FROM t6 WHERE t6 MATCH '' } {}
+read_test 6.6 { SELECT * FROM t6 WHERE x MATCH '' } {}
+read_test 6.7 { SELECT * FROM t6 WHERE t6 MATCH NULL } {}
+read_test 6.8 { SELECT * FROM t6 WHERE x MATCH NULL } {}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Test a few facets of the FTS3 xFilter() callback implementation:
+#
+# 1. That the sqlite3_index_constraint.usable flag is respected.
+#
+# 2. That it is an error to use the "docid" or "rowid" column of
+# an FTS3 table as the LHS of a MATCH operator.
+#
+# 3. That it is an error to AND together two MATCH expressions in
+# that refer to a single FTS3 table in a WHERE clause.
+#
+#
+set DO_MALLOC_TEST 0
+ddl_test 7.1.1 { CREATE VIRTUAL TABLE t7 USING fts3(a) }
+ddl_test 7.1.2 { CREATE VIRTUAL TABLE t8 USING fts3(b) }
+write_test 7.1.3 t7_content { INSERT INTO t7(docid, a) VALUES(4,'number four') }
+write_test 7.1.4 t7_content { INSERT INTO t7(docid, a) VALUES(5,'number five') }
+write_test 7.1.5 t8_content { INSERT INTO t8(docid, b) VALUES(4,'letter D') }
+write_test 7.1.6 t8_content { INSERT INTO t8(docid, b) VALUES(5,'letter E') }
+read_test 7.1.7 {
+ SELECT a || ':' || b FROM t7 JOIN t8 USING(docid)
+} {{number four:letter D} {number five:letter E}}
+
+error_test 7.2.1 {
+ SELECT * FROM t7 WHERE docid MATCH 'number'
+} {unable to use function MATCH in the requested context}
+error_test 7.2.2 {
+ SELECT * FROM t7 WHERE rowid MATCH 'number'
+} {unable to use function MATCH in the requested context}
+
+error_test 7.3.1 {
+ SELECT * FROM t7 WHERE a MATCH 'number' AND a MATCH 'four'
+} {unable to use function MATCH in the requested context}
+error_test 7.3.2 {
+ SELECT * FROM t7, t8 WHERE a MATCH 'number' AND a MATCH 'four'
+} {unable to use function MATCH in the requested context}
+error_test 7.3.3 {
+ SELECT * FROM t7, t8 WHERE b MATCH 'letter' AND b MATCH 'd'
+} {unable to use function MATCH in the requested context}
+read_test 7.3.4 {
+ SELECT * FROM t7, t8 WHERE a MATCH 'number' AND b MATCH 'letter'
+} {{number four} {letter D} {number four} {letter E} {number five} {letter D} {number five} {letter E}}
+read_test 7.3.5 {
+ SELECT * FROM t7 WHERE a MATCH 'number' AND docid = 4
+} {{number four}}
+
+#-------------------------------------------------------------------------
+# Test the quoting of FTS3 table column names. Names may be quoted using
+# any of "", '', ``` or [].
+#
+set DO_MALLOC_TEST 0
+ddl_test 8.1.1 { CREATE VIRTUAL TABLE t9a USING fts3("c1", [c2]) }
+ddl_test 8.1.2 { CREATE VIRTUAL TABLE t9b USING fts3('c1', `c2`) }
+read_test 8.1.3 { PRAGMA table_info(t9a) } {0 c1 {} 0 {} 0 1 c2 {} 0 {} 0}
+read_test 8.1.4 { PRAGMA table_info(t9b) } {0 c1 {} 0 {} 0 1 c2 {} 0 {} 0}
+ddl_test 8.2.1 { CREATE VIRTUAL TABLE t9c USING fts3("c""1", 'c''2') }
+read_test 8.2.2 { PRAGMA table_info(t9c) } {0 c\"1 {} 0 {} 0 1 c'2 {} 0 {} 0}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Test that FTS3 tables can be renamed using the ALTER RENAME command.
+# OOM errors are tested during ALTER RENAME commands also.
+#
+foreach DO_MALLOC_TEST {0 1 2} {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ if {$DO_MALLOC_TEST} { sqlite3_db_config_lookaside db 0 0 0 }
+
+ ddl_test 9.1.1 { CREATE VIRTUAL TABLE t10 USING fts3(x) }
+ write_test 9.1.2 t10_content { INSERT INTO t10 VALUES('fts3 tables') }
+ write_test 9.1.3 t10_content { INSERT INTO t10 VALUES('are renameable') }
+
+ read_test 9.1.4 {
+ SELECT * FROM t10 WHERE t10 MATCH 'table*'
+ } {{fts3 tables}}
+ read_test 9.1.5 {
+ SELECT * FROM t10 WHERE x MATCH 'rename*'
+ } {{are renameable}}
+
+ ddl_test 9.1.6 { ALTER TABLE t10 RENAME TO t11 }
+
+ read_test 9.1.7 {
+ SELECT * FROM t11 WHERE t11 MATCH 'table*'
+ } {{fts3 tables}}
+ read_test 9.1.8 {
+ SELECT * FROM t11 WHERE x MATCH 'rename*'
+ } {{are renameable}}
+}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Test a couple of cases involving corrupt data structures:
+#
+# 1) A case where a document referenced by the full-text index is
+# not present in the %_content table.
+#
+# 2) A badly formatted b-tree segment node.
+#
+set DO_MALLOC_TEST 0
+ddl_test 10.1.1 { CREATE VIRTUAL TABLE ta USING fts3 }
+write_test 10.1.2 ta_content {
+ INSERT INTO ta VALUES('During a summer vacation in 1790') }
+write_test 10.1.3 ta_content {
+ INSERT INTO ta VALUES('Wordsworth went on a walking tour') }
+write_test 10.1.4 ta_content { DELETE FROM ta_content WHERE rowid = 2 }
+read_test 10.1.5 {
+ SELECT * FROM ta WHERE ta MATCH 'summer'
+} {{During a summer vacation in 1790}}
+error_test 10.1.6 {
+ SELECT * FROM ta WHERE ta MATCH 'walking'
+} {database disk image is malformed}
+
+write_test 10.2.1 ta_content { DELETE FROM ta }
+write_test 10.2.2 ta_content {
+ INSERT INTO ta VALUES('debate demonstrated the rising difficulty') }
+write_test 10.2.3 ta_content {
+ INSERT INTO ta VALUES('Google released its browser beta') }
+
+set blob [db one {SELECT root FROM ta_segdir WHERE rowid = 2}]
+binary scan $blob "a6 a3 a*" start middle end
+set middle "\x0E\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x06\x06"
+set blob [binary format "a6 a* a*" $start $middle $end]
+write_test 10.2.4 ta_segdir {
+ UPDATE ta_segdir SET root = $blob WHERE rowid = 2
+}
+error_test 10.2.5 {
+ SELECT * FROM ta WHERE ta MATCH 'beta'
+} {database disk image is malformed}
+
+
+finish_test
diff --git a/test/e_insert.test b/test/e_insert.test
new file mode 100644
index 0000000..fe8bfcf
--- /dev/null
+++ b/test/e_insert.test
@@ -0,0 +1,406 @@
+# 2010 September 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# The majority of this file implements tests to verify that the "testable
+# statements" in the lang_insert.html document are correct.
+#
+# Also, it contains tests to verify the statements in (the very short)
+# lang_replace.html.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Organization of tests:
+#
+# e_insert-0.*: Test the syntax diagram.
+#
+# e_insert-1.*: Test statements of the form "INSERT ... VALUES(...)".
+#
+# e_insert-2.*: Test statements of the form "INSERT ... SELECT ...".
+#
+# e_insert-3.*: Test statements of the form "INSERT ... DEFAULT VALUES".
+#
+# e_insert-4.*: Test statements regarding the conflict clause.
+#
+# e_insert-5.*: Test that the qualified table name and "DEFAULT VALUES"
+# syntaxes do not work in trigger bodies.
+#
+
+do_execsql_test e_insert-0.0 {
+ CREATE TABLE a1(a, b);
+ CREATE TABLE a2(a, b, c DEFAULT 'xyz');
+ CREATE TABLE a3(x DEFAULT 1.0, y DEFAULT 'string', z);
+ CREATE TABLE a4(c UNIQUE, d);
+} {}
+
+proc do_insert_tests {args} {
+ uplevel do_select_tests $args
+}
+
+# EVIDENCE-OF: R-41448-54465 -- syntax diagram insert-stmt
+#
+do_insert_tests e_insert-0 {
+ 1 "INSERT INTO a1 DEFAULT VALUES" {}
+ 2 "INSERT INTO main.a1 DEFAULT VALUES" {}
+ 3 "INSERT OR ROLLBACK INTO main.a1 DEFAULT VALUES" {}
+ 4 "INSERT OR ROLLBACK INTO a1 DEFAULT VALUES" {}
+ 5 "INSERT OR ABORT INTO main.a1 DEFAULT VALUES" {}
+ 6 "INSERT OR ABORT INTO a1 DEFAULT VALUES" {}
+ 7 "INSERT OR REPLACE INTO main.a1 DEFAULT VALUES" {}
+ 8 "INSERT OR REPLACE INTO a1 DEFAULT VALUES" {}
+ 9 "INSERT OR FAIL INTO main.a1 DEFAULT VALUES" {}
+ 10 "INSERT OR FAIL INTO a1 DEFAULT VALUES" {}
+ 11 "INSERT OR FAIL INTO main.a1 DEFAULT VALUES" {}
+ 12 "INSERT OR IGNORE INTO a1 DEFAULT VALUES" {}
+ 13 "REPLACE INTO a1 DEFAULT VALUES" {}
+ 14 "REPLACE INTO main.a1 DEFAULT VALUES" {}
+ 15 "INSERT INTO a1 VALUES(1, 2)" {}
+ 16 "INSERT INTO main.a1 VALUES(1, 2)" {}
+ 17 "INSERT OR ROLLBACK INTO main.a1 VALUES(1, 2)" {}
+ 18 "INSERT OR ROLLBACK INTO a1 VALUES(1, 2)" {}
+ 19 "INSERT OR ABORT INTO main.a1 VALUES(1, 2)" {}
+ 20 "INSERT OR ABORT INTO a1 VALUES(1, 2)" {}
+ 21 "INSERT OR REPLACE INTO main.a1 VALUES(1, 2)" {}
+ 22 "INSERT OR REPLACE INTO a1 VALUES(1, 2)" {}
+ 23 "INSERT OR FAIL INTO main.a1 VALUES(1, 2)" {}
+ 24 "INSERT OR FAIL INTO a1 VALUES(1, 2)" {}
+ 25 "INSERT OR FAIL INTO main.a1 VALUES(1, 2)" {}
+ 26 "INSERT OR IGNORE INTO a1 VALUES(1, 2)" {}
+ 27 "REPLACE INTO a1 VALUES(1, 2)" {}
+ 28 "REPLACE INTO main.a1 VALUES(1, 2)" {}
+ 29 "INSERT INTO a1 (b, a) VALUES(1, 2)" {}
+ 30 "INSERT INTO main.a1 (b, a) VALUES(1, 2)" {}
+ 31 "INSERT OR ROLLBACK INTO main.a1 (b, a) VALUES(1, 2)" {}
+ 32 "INSERT OR ROLLBACK INTO a1 (b, a) VALUES(1, 2)" {}
+ 33 "INSERT OR ABORT INTO main.a1 (b, a) VALUES(1, 2)" {}
+ 34 "INSERT OR ABORT INTO a1 (b, a) VALUES(1, 2)" {}
+ 35 "INSERT OR REPLACE INTO main.a1 (b, a) VALUES(1, 2)" {}
+ 36 "INSERT OR REPLACE INTO a1 (b, a) VALUES(1, 2)" {}
+ 37 "INSERT OR FAIL INTO main.a1 (b, a) VALUES(1, 2)" {}
+ 38 "INSERT OR FAIL INTO a1 (b, a) VALUES(1, 2)" {}
+ 39 "INSERT OR FAIL INTO main.a1 (b, a) VALUES(1, 2)" {}
+ 40 "INSERT OR IGNORE INTO a1 (b, a) VALUES(1, 2)" {}
+ 41 "REPLACE INTO a1 (b, a) VALUES(1, 2)" {}
+ 42 "REPLACE INTO main.a1 (b, a) VALUES(1, 2)" {}
+ 43 "INSERT INTO a1 SELECT c, b FROM a2" {}
+ 44 "INSERT INTO main.a1 SELECT c, b FROM a2" {}
+ 45 "INSERT OR ROLLBACK INTO main.a1 SELECT c, b FROM a2" {}
+ 46 "INSERT OR ROLLBACK INTO a1 SELECT c, b FROM a2" {}
+ 47 "INSERT OR ABORT INTO main.a1 SELECT c, b FROM a2" {}
+ 48 "INSERT OR ABORT INTO a1 SELECT c, b FROM a2" {}
+ 49 "INSERT OR REPLACE INTO main.a1 SELECT c, b FROM a2" {}
+ 50 "INSERT OR REPLACE INTO a1 SELECT c, b FROM a2" {}
+ 51 "INSERT OR FAIL INTO main.a1 SELECT c, b FROM a2" {}
+ 52 "INSERT OR FAIL INTO a1 SELECT c, b FROM a2" {}
+ 53 "INSERT OR FAIL INTO main.a1 SELECT c, b FROM a2" {}
+ 54 "INSERT OR IGNORE INTO a1 SELECT c, b FROM a2" {}
+ 55 "REPLACE INTO a1 SELECT c, b FROM a2" {}
+ 56 "REPLACE INTO main.a1 SELECT c, b FROM a2" {}
+ 57 "INSERT INTO a1 (b, a) SELECT c, b FROM a2" {}
+ 58 "INSERT INTO main.a1 (b, a) SELECT c, b FROM a2" {}
+ 59 "INSERT OR ROLLBACK INTO main.a1 (b, a) SELECT c, b FROM a2" {}
+ 60 "INSERT OR ROLLBACK INTO a1 (b, a) SELECT c, b FROM a2" {}
+ 61 "INSERT OR ABORT INTO main.a1 (b, a) SELECT c, b FROM a2" {}
+ 62 "INSERT OR ABORT INTO a1 (b, a) SELECT c, b FROM a2" {}
+ 63 "INSERT OR REPLACE INTO main.a1 (b, a) SELECT c, b FROM a2" {}
+ 64 "INSERT OR REPLACE INTO a1 (b, a) SELECT c, b FROM a2" {}
+ 65 "INSERT OR FAIL INTO main.a1 (b, a) SELECT c, b FROM a2" {}
+ 66 "INSERT OR FAIL INTO a1 (b, a) SELECT c, b FROM a2" {}
+ 67 "INSERT OR FAIL INTO main.a1 (b, a) SELECT c, b FROM a2" {}
+ 68 "INSERT OR IGNORE INTO a1 (b, a) SELECT c, b FROM a2" {}
+ 69 "REPLACE INTO a1 (b, a) SELECT c, b FROM a2" {}
+ 70 "REPLACE INTO main.a1 (b, a) SELECT c, b FROM a2" {}
+}
+
+delete_all_data
+
+# EVIDENCE-OF: R-20288-20462 The first form (with the "VALUES" keyword)
+# creates a single new row in an existing table.
+#
+do_insert_tests e_insert-1.1 {
+ 0 "SELECT count(*) FROM a2" {0}
+
+ 1a "INSERT INTO a2 VALUES(1, 2, 3)" {}
+ 1b "SELECT count(*) FROM a2" {1}
+
+ 2a "INSERT INTO a2(a, b) VALUES(1, 2)" {}
+ 2b "SELECT count(*) FROM a2" {2}
+}
+
+# EVIDENCE-OF: R-36040-20870 If no column-list is specified then the
+# number of values must be the same as the number of columns in the
+# table.
+#
+# A test in the block above verifies that if the VALUES list has the
+# correct number of columns (for table a2, 3 columns) works. So these
+# tests just show that other values cause an error.
+#
+do_insert_tests e_insert-1.2 -error {
+ table %s has %d columns but %d values were supplied
+} {
+ 1 "INSERT INTO a2 VALUES(1)" {a2 3 1}
+ 2 "INSERT INTO a2 VALUES(1,2)" {a2 3 2}
+ 3 "INSERT INTO a2 VALUES(1,2,3,4)" {a2 3 4}
+ 4 "INSERT INTO a2 VALUES(1,2,3,4,5)" {a2 3 5}
+}
+
+# EVIDENCE-OF: R-04006-57648 In this case the result of evaluating the
+# left-most expression in the VALUES list is inserted into the left-most
+# column of the new row, and so on.
+#
+delete_all_data
+do_insert_tests e_insert-1.3 {
+ 1a "INSERT INTO a2 VALUES(1, 2, 3)" {}
+ 1b "SELECT * FROM a2 WHERE oid=last_insert_rowid()" {1 2 3}
+
+ 2a "INSERT INTO a2 VALUES('abc', NULL, 3*3+1)" {}
+ 2b "SELECT * FROM a2 WHERE oid=last_insert_rowid()" {abc {} 10}
+
+ 3a "INSERT INTO a2 VALUES((SELECT count(*) FROM a2), 'x', 'y')" {}
+ 3b "SELECT * FROM a2 WHERE oid=last_insert_rowid()" {2 x y}
+}
+
+# EVIDENCE-OF: R-62524-00361 If a column-list is specified, then the
+# number of values must match the number of specified columns.
+#
+do_insert_tests e_insert-1.4 -error {
+ %d values for %d columns
+} {
+ 1 "INSERT INTO a2(a, b, c) VALUES(1)" {1 3}
+ 2 "INSERT INTO a2(a, b, c) VALUES(1,2)" {2 3}
+ 3 "INSERT INTO a2(a, b, c) VALUES(1,2,3,4)" {4 3}
+ 4 "INSERT INTO a2(a, b, c) VALUES(1,2,3,4,5)" {5 3}
+
+ 5 "INSERT INTO a2(c, a) VALUES(1)" {1 2}
+ 6 "INSERT INTO a2(c, a) VALUES(1,2,3)" {3 2}
+ 7 "INSERT INTO a2(c, a) VALUES(1,2,3,4)" {4 2}
+ 8 "INSERT INTO a2(c, a) VALUES(1,2,3,4,5)" {5 2}
+}
+
+# EVIDENCE-OF: R-07016-26442 Each of the named columns of the new row is
+# populated with the results of evaluating the corresponding VALUES
+# expression.
+#
+# EVIDENCE-OF: R-12183-43719 Table columns that do not appear in the
+# column list are populated with the default column value (specified as
+# part of the CREATE TABLE statement), or with NULL if no default value
+# is specified.
+#
+delete_all_data
+do_insert_tests e_insert-1.5 {
+ 1a "INSERT INTO a2(b, c) VALUES('b', 'c')" {}
+ 1b "SELECT * FROM a2" {{} b c}
+
+ 2a "INSERT INTO a2(a, b) VALUES('a', 'b')" {}
+ 2b "SELECT * FROM a2" {{} b c a b xyz}
+}
+
+# EVIDENCE-OF: R-52173-30215 A new entry is inserted into the table for
+# each row of data returned by executing the SELECT statement.
+#
+delete_all_data
+do_insert_tests e_insert-2.1 {
+ 0 "SELECT count(*) FROM a1" {0}
+
+ 1a "SELECT count(*) FROM (SELECT 1, 2)" {1}
+ 1b "INSERT INTO a1 SELECT 1, 2" {}
+ 1c "SELECT count(*) FROM a1" {1}
+
+ 2a "SELECT count(*) FROM (SELECT b, a FROM a1)" {1}
+ 2b "INSERT INTO a1 SELECT b, a FROM a1" {}
+ 2c "SELECT count(*) FROM a1" {2}
+
+ 3a "SELECT count(*) FROM (SELECT b, a FROM a1)" {2}
+ 3b "INSERT INTO a1 SELECT b, a FROM a1" {}
+ 3c "SELECT count(*) FROM a1" {4}
+
+ 4a "SELECT count(*) FROM (SELECT b, a FROM a1)" {4}
+ 4b "INSERT INTO a1 SELECT b, a FROM a1" {}
+ 4c "SELECT count(*) FROM a1" {8}
+
+ 4a "SELECT count(*) FROM (SELECT min(b), min(a) FROM a1)" {1}
+ 4b "INSERT INTO a1 SELECT min(b), min(a) FROM a1" {}
+ 4c "SELECT count(*) FROM a1" {9}
+}
+
+
+# EVIDENCE-OF: R-63614-47421 If a column-list is specified, the number
+# of columns in the result of the SELECT must be the same as the number
+# of items in the column-list.
+#
+do_insert_tests e_insert-2.2 -error {
+ %d values for %d columns
+} {
+ 1 "INSERT INTO a3(x, y) SELECT a, b, c FROM a2" {3 2}
+ 2 "INSERT INTO a3(x, y) SELECT * FROM a2" {3 2}
+ 3 "INSERT INTO a3(x, y) SELECT * FROM a2 CROSS JOIN a1" {5 2}
+ 4 "INSERT INTO a3(x, y) SELECT * FROM a2 NATURAL JOIN a1" {3 2}
+ 5 "INSERT INTO a3(x, y) SELECT a2.a FROM a2,a1" {1 2}
+
+ 6 "INSERT INTO a3(z) SELECT a, b, c FROM a2" {3 1}
+ 7 "INSERT INTO a3(z) SELECT * FROM a2" {3 1}
+ 8 "INSERT INTO a3(z) SELECT * FROM a2 CROSS JOIN a1" {5 1}
+ 9 "INSERT INTO a3(z) SELECT * FROM a2 NATURAL JOIN a1" {3 1}
+ 10 "INSERT INTO a3(z) SELECT a1.* FROM a2,a1" {2 1}
+}
+
+# EVIDENCE-OF: R-58951-07798 Otherwise, if no column-list is specified,
+# the number of columns in the result of the SELECT must be the same as
+# the number of columns in the table.
+#
+do_insert_tests e_insert-2.3 -error {
+ table %s has %d columns but %d values were supplied
+} {
+ 1 "INSERT INTO a1 SELECT a, b, c FROM a2" {a1 2 3}
+ 2 "INSERT INTO a1 SELECT * FROM a2" {a1 2 3}
+ 3 "INSERT INTO a1 SELECT * FROM a2 CROSS JOIN a1" {a1 2 5}
+ 4 "INSERT INTO a1 SELECT * FROM a2 NATURAL JOIN a1" {a1 2 3}
+ 5 "INSERT INTO a1 SELECT a2.a FROM a2,a1" {a1 2 1}
+}
+
+# EVIDENCE-OF: R-31074-37730 Any SELECT statement, including compound
+# SELECTs and SELECT statements with ORDER BY and/or LIMIT clauses, may
+# be used in an INSERT statement of this form.
+#
+delete_all_data
+do_execsql_test e_insert-2.3.0 {
+ INSERT INTO a1 VALUES('x', 'y');
+} {}
+do_insert_tests e_insert-2.3 {
+ 1 "INSERT INTO a1 SELECT a,b FROM a1 UNION SELECT b,a FROM a1 ORDER BY 1" {}
+ 2 "INSERT INTO a1(b, a) SELECT * FROM a1 LIMIT 1" {}
+ 3 "INSERT INTO a1 SELECT 'a'||a, 'b'||b FROM a1 LIMIT 2 OFFSET 1" {}
+ 4 "INSERT INTO a1 SELECT * FROM a1 ORDER BY b, a" {}
+ S "SELECT * FROM a1" {
+ x y
+ x y y x
+ y x
+ ax by ay bx
+ ay bx ax by y x y x x y x y
+ }
+}
+
+# EVIDENCE-OF: R-25149-22012 The INSERT ... DEFAULT VALUES statement
+# inserts a single new row into the named table.
+#
+delete_all_data
+do_insert_tests e_insert-3.1 {
+ 1 "SELECT count(*) FROM a3" {0}
+ 2a "INSERT INTO a3 DEFAULT VALUES" {}
+ 2b "SELECT count(*) FROM a3" {1}
+}
+
+# EVIDENCE-OF: R-18927-01951 Each column of the new row is populated
+# with its default value, or with a NULL if no default value is
+# specified as part of the column definition in the CREATE TABLE
+# statement.
+#
+delete_all_data
+do_insert_tests e_insert-3.2 {
+ 1.1 "INSERT INTO a3 DEFAULT VALUES" {}
+ 1.2 "SELECT * FROM a3" {1.0 string {}}
+
+ 2.1 "INSERT INTO a3 DEFAULT VALUES" {}
+ 2.2 "SELECT * FROM a3" {1.0 string {} 1.0 string {}}
+
+ 3.1 "INSERT INTO a2 DEFAULT VALUES" {}
+ 3.2 "SELECT * FROM a2" {{} {} xyz}
+
+ 4.1 "INSERT INTO a2 DEFAULT VALUES" {}
+ 4.2 "SELECT * FROM a2" {{} {} xyz {} {} xyz}
+
+ 5.1 "INSERT INTO a1 DEFAULT VALUES" {}
+ 5.2 "SELECT * FROM a1" {{} {}}
+
+ 6.1 "INSERT INTO a1 DEFAULT VALUES" {}
+ 6.2 "SELECT * FROM a1" {{} {} {} {}}
+}
+
+# EVIDENCE-OF: R-46928-50290 The optional conflict-clause allows the
+# specification of an alternative constraint conflict resolution
+# algorithm to use during this one INSERT command.
+#
+# EVIDENCE-OF: R-23110-47146 the parser allows the use of the single
+# keyword REPLACE as an alias for "INSERT OR REPLACE".
+#
+# The two requirements above are tested by e_select-4.1.* and
+# e_select-4.2.*, respectively.
+#
+# EVIDENCE-OF: R-03421-22330 The REPLACE command is an alias for the
+# "INSERT OR REPLACE" variant of the INSERT command.
+#
+# This is a dup of R-23110-47146. Therefore it is also verified
+# by e_select-4.2.*. This requirement is the only one from
+# lang_replace.html.
+#
+do_execsql_test e_insert-4.1.0 {
+ INSERT INTO a4 VALUES(1, 'a');
+ INSERT INTO a4 VALUES(2, 'a');
+ INSERT INTO a4 VALUES(3, 'a');
+} {}
+foreach {tn sql error ac data } {
+ 1.1 "INSERT INTO a4 VALUES(2,'b')" {column c is not unique} 1 {1 a 2 a 3 a}
+ 1.2 "INSERT OR REPLACE INTO a4 VALUES(2, 'b')" {} 1 {1 a 3 a 2 b}
+ 1.3 "INSERT OR IGNORE INTO a4 VALUES(3, 'c')" {} 1 {1 a 3 a 2 b}
+ 1.4 "BEGIN" {} 0 {1 a 3 a 2 b}
+ 1.5 "INSERT INTO a4 VALUES(1, 'd')" {column c is not unique} 0 {1 a 3 a 2 b}
+ 1.6 "INSERT OR ABORT INTO a4 VALUES(1, 'd')"
+ {column c is not unique} 0 {1 a 3 a 2 b}
+ 1.7 "INSERT OR ROLLBACK INTO a4 VALUES(1, 'd')"
+ {column c is not unique} 1 {1 a 3 a 2 b}
+ 1.8 "INSERT INTO a4 SELECT 4, 'e' UNION ALL SELECT 3, 'e'"
+ {column c is not unique} 1 {1 a 3 a 2 b}
+ 1.9 "INSERT OR FAIL INTO a4 SELECT 4, 'e' UNION ALL SELECT 3, 'e'"
+ {column c is not unique} 1 {1 a 3 a 2 b 4 e}
+
+ 2.1 "INSERT INTO a4 VALUES(2,'f')"
+ {column c is not unique} 1 {1 a 3 a 2 b 4 e}
+ 2.2 "REPLACE INTO a4 VALUES(2, 'f')" {} 1 {1 a 3 a 4 e 2 f}
+} {
+ do_catchsql_test e_insert-4.1.$tn.1 $sql [list [expr {$error!=""}] $error]
+ do_execsql_test e_insert-4.1.$tn.2 {SELECT * FROM a4} [list {*}$data]
+ do_test e_insert-4.1.$tn.3 {sqlite3_get_autocommit db} $ac
+}
+
+# EVIDENCE-OF: R-64196-02418 The optional "database-name." prefix on the
+# table-name is support for top-level INSERT statements only.
+#
+# EVIDENCE-OF: R-05731-00924 The table name must be unqualified for
+# INSERT statements that occur within CREATE TRIGGER statements.
+#
+set err {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}
+
+do_catchsql_test e_insert-5.1.1 {
+ CREATE TRIGGER AFTER UPDATE ON a1 BEGIN
+ INSERT INTO main.a4 VALUES(new.a, new.b);
+ END;
+} $err
+do_catchsql_test e_insert-5.1.2 {
+ CREATE TEMP TABLE IF NOT EXISTS tmptable(a, b);
+ CREATE TRIGGER AFTER DELETE ON a3 BEGIN
+ INSERT INTO temp.tmptable VALUES(1, 2);
+ END;
+} $err
+
+# EVIDENCE-OF: R-15888-36326 Similarly, the "DEFAULT VALUES" form of the
+# INSERT statement is supported for top-level INSERT statements only and
+# not for INSERT statements within triggers.
+#
+do_catchsql_test e_insert-5.2.1 {
+ CREATE TRIGGER AFTER UPDATE ON a1 BEGIN
+ INSERT INTO a4 DEFAULT VALUES;
+ END;
+} {1 {near "DEFAULT": syntax error}}
+
+
+delete_all_data
+
+finish_test
diff --git a/test/e_reindex.test b/test/e_reindex.test
new file mode 100644
index 0000000..e9419df
--- /dev/null
+++ b/test/e_reindex.test
@@ -0,0 +1,294 @@
+# 2010 September 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_reindex.html document are correct.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc do_reindex_tests {args} {
+ uplevel do_select_tests $args
+}
+
+do_execsql_test e_reindex-0.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ CREATE INDEX i2 ON t1(b, a);
+} {}
+
+# EVIDENCE-OF: R-57021-15304 -- syntax diagram reindex-stmt
+#
+do_reindex_tests e_reindex-0.1 {
+ 1 "REINDEX" {}
+ 2 "REINDEX nocase" {}
+ 3 "REINDEX binary" {}
+ 4 "REINDEX t1" {}
+ 5 "REINDEX main.t1" {}
+ 4 "REINDEX i1" {}
+ 5 "REINDEX main.i1" {}
+}
+
+# EVIDENCE-OF: R-52173-44778 The REINDEX command is used to delete and
+# recreate indices from scratch.
+#
+# Test this by corrupting some database indexes, running REINDEX, and
+# observing that the corruption is gone.
+#
+do_execsql_test e_reindex-1.1 {
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master SET sql = '-- ' || sql WHERE type = 'index';
+} {}
+
+db close
+sqlite3 db test.db
+do_execsql_test e_reindex-1.2 {
+ DELETE FROM t1 WHERE a = 3;
+ INSERT INTO t1 VALUES(7, 8);
+ INSERT INTO t1 VALUES(9, 10);
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master SET sql = substr(sql, 4) WHERE type = 'index';
+} {}
+
+db close
+sqlite3 db test.db
+do_execsql_test e_reindex-1.3 {
+ PRAGMA integrity_check;
+} [list \
+ {rowid 4 missing from index i2} \
+ {rowid 4 missing from index i1} \
+ {rowid 5 missing from index i2} \
+ {rowid 5 missing from index i1} \
+ {wrong # of entries in index i2} \
+ {wrong # of entries in index i1}
+]
+
+do_execsql_test e_reindex-1.4 {
+ REINDEX;
+ PRAGMA integrity_check;
+} {ok}
+
+#-------------------------------------------------------------------------
+# The remaining tests in this file focus on testing that the REINDEX
+# command reindexes the correct subset of the indexes in the database.
+# They all use the following dataset.
+#
+db close
+forcedelete test.db2
+forcedelete test.db
+sqlite3 db test.db
+
+proc sort_by_length {lhs rhs} {
+ set res [expr {[string length $lhs] - [string length $rhs]}]
+ if {$res!=0} {return $res}
+ return [string compare $lhs $rhs]
+}
+array set V {one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8}
+proc sort_by_value {lhs rhs} {
+ global V
+ set res [expr {$V($lhs) - $V(rhs)}]
+ if {$res!=0} {return $res}
+ return [string compare $lhs $rhs]
+}
+
+db collate collA sort_by_length
+db collate collB sort_by_value
+
+set BY(length) {one six two five four eight seven three}
+set BY(value) {one two three four five six seven eight}
+
+do_execsql_test e_reindex-2.0 {
+ ATTACH 'test.db2' AS aux;
+
+ CREATE TABLE t1(x);
+ CREATE INDEX i1_a ON t1(x COLLATE collA);
+ CREATE INDEX i1_b ON t1(x COLLATE collB);
+ INSERT INTO t1 VALUES('one');
+ INSERT INTO t1 VALUES('two');
+ INSERT INTO t1 VALUES('three');
+ INSERT INTO t1 VALUES('four');
+ INSERT INTO t1 VALUES('five');
+ INSERT INTO t1 VALUES('six');
+ INSERT INTO t1 VALUES('seven');
+ INSERT INTO t1 VALUES('eight');
+
+ CREATE TABLE t2(x);
+ CREATE INDEX i2_a ON t2(x COLLATE collA);
+ CREATE INDEX i2_b ON t2(x COLLATE collB);
+ INSERT INTO t2 SELECT x FROM t1;
+
+ CREATE TABLE aux.t1(x);
+ CREATE INDEX aux.i1_a ON t1(x COLLATE collA);
+ CREATE INDEX aux.i1_b ON t1(x COLLATE collB);
+ INSERT INTO aux.t1 SELECT x FROM main.t1;
+
+} {}
+
+proc test_index {tn tbl collation expected} {
+ set sql "SELECT x FROM $tbl ORDER BY x COLLATE $collation"
+ uplevel do_execsql_test e_reindex-2.$tn [list $sql] [list $::BY($expected)]
+}
+
+proc set_collations {a b} {
+ db collate collA "sort_by_$a"
+ db collate collB "sort_by_$b"
+}
+
+test_index 1.1 t1 collA length
+test_index 1.2 t1 collB value
+test_index 1.3 t2 collA length
+test_index 1.4 t2 collB value
+test_index 1.5 aux.t1 collA length
+test_index 1.6 aux.t1 collB value
+
+
+# EVIDENCE-OF: R-47362-07898 If the REINDEX keyword is not followed by a
+# collation-sequence or database object identifier, then all indices in
+# all attached databases are rebuilt.
+#
+set_collations value length
+do_execsql_test e_reindex-2.2.1 "REINDEX" {}
+test_index 2.2 t1 collA value
+test_index 2.3 t1 collB length
+test_index 2.4 t2 collA value
+test_index 2.5 t2 collB length
+test_index 2.6 aux.t1 collA value
+test_index 2.7 aux.t1 collB length
+
+# EVIDENCE-OF: R-45878-07697 If the REINDEX keyword is followed by a
+# collation-sequence name, then all indices in all attached databases
+# that use the named collation sequences are recreated.
+#
+set_collations length value
+do_execsql_test e_reindex-2.3.1 "REINDEX collA" {}
+test_index 3.2 t1 collA length
+test_index 3.3 t1 collB length
+test_index 3.4 t2 collA length
+test_index 3.5 t2 collB length
+test_index 3.6 aux.t1 collA length
+test_index 3.7 aux.t1 collB length
+do_execsql_test e_reindex-2.3.8 "REINDEX collB" {}
+test_index 3.9 t1 collA length
+test_index 3.10 t1 collB value
+test_index 3.11 t2 collA length
+test_index 3.12 t2 collB value
+test_index 3.13 aux.t1 collA length
+test_index 3.14 aux.t1 collB value
+
+# EVIDENCE-OF: R-49616-30196 Or, if the argument attached to the REINDEX
+# identifies a specific database table, then all indices attached to the
+# database table are rebuilt.
+#
+set_collations value length
+do_execsql_test e_reindex-2.4.1 "REINDEX t1" {}
+test_index 4.2 t1 collA value
+test_index 4.3 t1 collB length
+test_index 4.4 t2 collA length
+test_index 4.5 t2 collB value
+test_index 4.6 aux.t1 collA length
+test_index 4.7 aux.t1 collB value
+do_execsql_test e_reindex-2.4.8 "REINDEX aux.t1" {}
+test_index 4.9 t1 collA value
+test_index 4.10 t1 collB length
+test_index 4.11 t2 collA length
+test_index 4.12 t2 collB value
+test_index 4.13 aux.t1 collA value
+test_index 4.14 aux.t1 collB length
+do_execsql_test e_reindex-2.4.15 "REINDEX t2" {}
+test_index 4.16 t1 collA value
+test_index 4.17 t1 collB length
+test_index 4.18 t2 collA value
+test_index 4.19 t2 collB length
+test_index 4.20 aux.t1 collA value
+test_index 4.21 aux.t1 collB length
+
+# EVIDENCE-OF: R-58823-28748 If it identifies a specific database index,
+# then just that index is recreated.
+#
+set_collations length value
+do_execsql_test e_reindex-2.5.1 "REINDEX i1_a" {}
+test_index 5.2 t1 collA length
+test_index 5.3 t1 collB length
+test_index 5.4 t2 collA value
+test_index 5.5 t2 collB length
+test_index 5.6 aux.t1 collA value
+test_index 5.7 aux.t1 collB length
+do_execsql_test e_reindex-2.5.8 "REINDEX i2_b" {}
+test_index 5.9 t1 collA length
+test_index 5.10 t1 collB length
+test_index 5.11 t2 collA value
+test_index 5.12 t2 collB value
+test_index 5.13 aux.t1 collA value
+test_index 5.14 aux.t1 collB length
+do_execsql_test e_reindex-2.5.15 "REINDEX aux.i1_b" {}
+test_index 5.16 t1 collA length
+test_index 5.17 t1 collB length
+test_index 5.18 t2 collA value
+test_index 5.19 t2 collB value
+test_index 5.20 aux.t1 collA value
+test_index 5.21 aux.t1 collB value
+do_execsql_test e_reindex-2.5.22 "REINDEX i1_b" {}
+test_index 5.23 t1 collA length
+test_index 5.24 t1 collB value
+test_index 5.25 t2 collA value
+test_index 5.26 t2 collB value
+test_index 5.27 aux.t1 collA value
+test_index 5.28 aux.t1 collB value
+do_execsql_test e_reindex-2.5.29 "REINDEX i2_a" {}
+test_index 5.30 t1 collA length
+test_index 5.31 t1 collB value
+test_index 5.32 t2 collA length
+test_index 5.33 t2 collB value
+test_index 5.34 aux.t1 collA value
+test_index 5.35 aux.t1 collB value
+do_execsql_test e_reindex-2.5.36 "REINDEX aux.i1_a" {}
+test_index 5.37 t1 collA length
+test_index 5.38 t1 collB value
+test_index 5.39 t2 collA length
+test_index 5.40 t2 collB value
+test_index 5.41 aux.t1 collA length
+test_index 5.42 aux.t1 collB value
+
+# EVIDENCE-OF: R-15639-02023 If no database-name is specified and there
+# exists both a table or index and a collation sequence of the specified
+# name, SQLite interprets this as a request to rebuild the indices that
+# use the named collation sequence.
+#
+set_collations value length
+do_execsql_test e_reindex-2.6.0 {
+ CREATE TABLE collA(x);
+ CREATE INDEX icolla_a ON collA(x COLLATE collA);
+ CREATE INDEX icolla_b ON collA(x COLLATE collB);
+
+ INSERT INTO collA SELECT x FROM t1;
+} {}
+
+test_index 6.1 collA collA value
+test_index 6.2 collA collB length
+
+set_collations length value
+do_execsql_test e_reindex-2.6.3 "REINDEX collA" {}
+test_index 6.4 collA collA length
+test_index 6.5 collA collB length
+do_execsql_test e_reindex-2.6.3 "REINDEX main.collA" {}
+test_index 6.4 collA collA length
+test_index 6.5 collA collB value
+
+set_collations value length
+do_execsql_test e_reindex-2.6.6 "REINDEX main.collA" {}
+test_index 6.7 collA collA value
+test_index 6.8 collA collB length
+
+finish_test
diff --git a/test/e_resolve.test b/test/e_resolve.test
new file mode 100644
index 0000000..512fcf2
--- /dev/null
+++ b/test/e_resolve.test
@@ -0,0 +1,135 @@
+# 2010 November 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_naming.html document are correct.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix e_resolve
+
+# An example database schema for testing name resolution:
+#
+set schema {
+ ATTACH 'test.db2' AS at1;
+ ATTACH 'test.db3' AS at2;
+
+ CREATE TABLE temp.n1(x, y); INSERT INTO temp.n1 VALUES('temp', 'n1');
+ CREATE TRIGGER temp.n3 AFTER INSERT ON n1 BEGIN SELECT 1; END;
+ CREATE INDEX temp.n4 ON n1(x, y);
+
+ CREATE TABLE main.n1(x, y); INSERT INTO main.n1 VALUES('main', 'n1');
+ CREATE TABLE main.n2(x, y); INSERT INTO main.n2 VALUES('main', 'n2');
+ CREATE INDEX main.n3 ON n2(y, x);
+ CREATE TRIGGER main.n4 BEFORE INSERT ON n2 BEGIN SELECT 1; END;
+
+ CREATE TABLE at1.n1(x, y); INSERT INTO at1.n1 VALUES('at1', 'n1');
+ CREATE TABLE at1.n2(x, y); INSERT INTO at1.n2 VALUES('at1', 'n2');
+ CREATE TABLE at1.n3(x, y); INSERT INTO at1.n3 VALUES('at1', 'n3');
+
+ CREATE TABLE at2.n1(x, y); INSERT INTO at2.n1 VALUES('at2', 'n1');
+ CREATE TABLE at2.n2(x, y); INSERT INTO at2.n2 VALUES('at2', 'n2');
+ CREATE TABLE at2.n3(x, y); INSERT INTO at2.n3 VALUES('at2', 'n3');
+ CREATE TABLE at2.n4(x, y); INSERT INTO at2.n4 VALUES('at2', 'n4');
+ CREATE TRIGGER at2.n4 BEFORE INSERT ON n4 BEGIN SELECT 1; END;
+}
+
+proc resolve_reopen_db {} {
+ db close
+ forcedelete test.db test.db2 test.db3
+ sqlite3 db test.db
+ db eval $::schema
+}
+
+
+
+# EVIDENCE-OF: R-33528-20612 If no database is specified as part of the
+# object reference, then SQLite searches the main, temp and all attached
+# databases for an object with a matching name. The temp database is
+# searched first, followed by the main database, followed all attached
+# databases in the order that they were attached. The reference resolves
+# to the first match found.
+#
+resolve_reopen_db
+do_execsql_test 1.1 { SELECT * FROM n1 } {temp n1}
+do_execsql_test 1.2 { SELECT * FROM n2 } {main n2}
+do_execsql_test 1.3 { SELECT * FROM n3 } {at1 n3}
+do_execsql_test 1.4 { SELECT * FROM n4 } {at2 n4}
+
+# EVIDENCE-OF: R-54577-28142 If a database name is specified as part of
+# an object reference, it must be either "main", or "temp" or the name
+# of an attached database.
+#
+# Or else it is a "no such table: xxx" error.
+#
+resolve_reopen_db
+do_execsql_test 2.1.1 { SELECT * FROM main.n1 } {main n1}
+do_execsql_test 2.1.2 { SELECT * FROM temp.n1 } {temp n1}
+do_execsql_test 2.1.3 { SELECT * FROM at1.n1 } {at1 n1}
+do_execsql_test 2.1.4 { SELECT * FROM at2.n1 } {at2 n1}
+
+do_catchsql_test 2.2 { SELECT * FROM xxx.n1 } {1 {no such table: xxx.n1}}
+
+# EVIDENCE-OF: R-26223-47623 Like other SQL identifiers, database names
+# are case-insensitive.
+#
+resolve_reopen_db
+do_execsql_test 3.1 { SELECT * FROM MAIN.n1 } {main n1}
+do_execsql_test 3.2 { SELECT * FROM tEmP.n1 } {temp n1}
+do_execsql_test 3.3 { SELECT * FROM aT1.n1 } {at1 n1}
+do_execsql_test 3.4 { SELECT * FROM At2.n1 } {at2 n1}
+
+# EVIDENCE-OF: R-15639-28392 If a database name is specified, then only
+# the named database is searched for the named object.
+#
+do_catchsql_test 4.1 { SELECT * FROM temp.n2 } {1 {no such table: temp.n2}}
+do_catchsql_test 4.2 { SELECT * FROM main.n2 } {0 {main n2}}
+do_catchsql_test 4.3 { SELECT * FROM at1.n2 } {0 {at1 n2}}
+do_catchsql_test 4.4 { SELECT * FROM at2.n2 } {0 {at2 n2}}
+
+# EVIDENCE-OF: R-08951-19801 When searching database schemas for a named
+# object, objects of types that cannot be used in the context of the
+# reference are always ignored.
+#
+# In this case, "types that cannot be used" are triggers and indexes.
+# The temp and main databases both contain triggers and indexes named
+# "n3" and "n4". Database "at2" contains a trigger called "n4". And yet:
+#
+do_execsql_test 5.1 { SELECT * FROM n3 } {at1 n3}
+do_execsql_test 5.2 { SELECT * FROM n4 } {at2 n4}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-37286-42536
+#
+db close
+forcedelete test.db file.db
+sqlite3 db test.db
+do_execsql_test 6.1 {
+ ATTACH 'file.db' AS aux;
+ CREATE TABLE t1(x, y);
+ CREATE TEMP TABLE t1(x, y);
+ CREATE TABLE aux.t1(x, y);
+}
+
+do_execsql_test 6.2.0 { DROP TABLE t1 }
+do_catchsql_test 6.2.1 { SELECT * FROM temp.t1 } {1 {no such table: temp.t1}}
+do_catchsql_test 6.2.2 { SELECT * FROM main.t1 } {0 {}}
+do_catchsql_test 6.2.3 { SELECT * FROM aux.t1 } {0 {}}
+
+do_execsql_test 6.3.0 { DROP TABLE t1 }
+do_catchsql_test 6.3.1 { SELECT * FROM main.t1 } {1 {no such table: main.t1}}
+do_catchsql_test 6.3.3 { SELECT * FROM aux.t1 } {0 {}}
+
+do_execsql_test 6.4.0 { DROP TABLE t1 }
+do_catchsql_test 6.4.1 { SELECT * FROM aux.t1 } {1 {no such table: aux.t1}}
+
+finish_test
diff --git a/test/e_select.test b/test/e_select.test
new file mode 100644
index 0000000..e0f5f0f
--- /dev/null
+++ b/test/e_select.test
@@ -0,0 +1,2162 @@
+# 2010 July 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_select.html document are correct.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test e_select-1.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('a', 'one');
+ INSERT INTO t1 VALUES('b', 'two');
+ INSERT INTO t1 VALUES('c', 'three');
+
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES('a', 'I');
+ INSERT INTO t2 VALUES('b', 'II');
+ INSERT INTO t2 VALUES('c', 'III');
+
+ CREATE TABLE t3(a, c);
+ INSERT INTO t3 VALUES('a', 1);
+ INSERT INTO t3 VALUES('b', 2);
+
+ CREATE TABLE t4(a, c);
+ INSERT INTO t4 VALUES('a', NULL);
+ INSERT INTO t4 VALUES('b', 2);
+} {}
+set t1_cross_t2 [list \
+ a one a I a one b II \
+ a one c III b two a I \
+ b two b II b two c III \
+ c three a I c three b II \
+ c three c III \
+]
+set t1_cross_t1 [list \
+ a one a one a one b two \
+ a one c three b two a one \
+ b two b two b two c three \
+ c three a one c three b two \
+ c three c three \
+]
+
+
+# This proc is a specialized version of [do_execsql_test].
+#
+# The second argument to this proc must be a SELECT statement that
+# features a cross join of some time. Instead of the usual ",",
+# "CROSS JOIN" or "INNER JOIN" join-op, the string %JOIN% must be
+# substituted.
+#
+# This test runs the SELECT three times - once with:
+#
+# * s/%JOIN%/,/
+# * s/%JOIN%/JOIN/
+# * s/%JOIN%/INNER JOIN/
+# * s/%JOIN%/CROSS JOIN/
+#
+# and checks that each time the results of the SELECT are $res.
+#
+proc do_join_test {tn select res} {
+ foreach {tn2 joinop} [list 1 , 2 "CROSS JOIN" 3 "INNER JOIN"] {
+ set S [string map [list %JOIN% $joinop] $select]
+ uplevel do_execsql_test $tn.$tn2 [list $S] [list $res]
+ }
+}
+
+#-------------------------------------------------------------------------
+# The following tests check that all paths on the syntax diagrams on
+# the lang_select.html page may be taken.
+#
+# EVIDENCE-OF: R-18428-22111 -- syntax diagram join-constraint
+#
+do_join_test e_select-0.1.1 {
+ SELECT count(*) FROM t1 %JOIN% t2 ON (t1.a=t2.a)
+} {3}
+do_join_test e_select-0.1.2 {
+ SELECT count(*) FROM t1 %JOIN% t2 USING (a)
+} {3}
+do_join_test e_select-0.1.3 {
+ SELECT count(*) FROM t1 %JOIN% t2
+} {9}
+do_catchsql_test e_select-0.1.4 {
+ SELECT count(*) FROM t1, t2 ON (t1.a=t2.a) USING (a)
+} {1 {cannot have both ON and USING clauses in the same join}}
+do_catchsql_test e_select-0.1.5 {
+ SELECT count(*) FROM t1, t2 USING (a) ON (t1.a=t2.a)
+} {1 {near "ON": syntax error}}
+
+# EVIDENCE-OF: R-44854-11739 -- syntax diagram select-core
+#
+# 0: SELECT ...
+# 1: SELECT DISTINCT ...
+# 2: SELECT ALL ...
+#
+# 0: No FROM clause
+# 1: Has FROM clause
+#
+# 0: No WHERE clause
+# 1: Has WHERE clause
+#
+# 0: No GROUP BY clause
+# 1: Has GROUP BY clause
+# 2: Has GROUP BY and HAVING clauses
+#
+do_select_tests e_select-0.2 {
+ 0000.1 "SELECT 1, 2, 3 " {1 2 3}
+ 1000.1 "SELECT DISTINCT 1, 2, 3 " {1 2 3}
+ 2000.1 "SELECT ALL 1, 2, 3 " {1 2 3}
+
+ 0100.1 "SELECT a, b, a||b FROM t1 " {
+ a one aone b two btwo c three cthree
+ }
+ 1100.1 "SELECT DISTINCT a, b, a||b FROM t1 " {
+ a one aone b two btwo c three cthree
+ }
+ 1200.1 "SELECT ALL a, b, a||b FROM t1 " {
+ a one aone b two btwo c three cthree
+ }
+
+ 0010.1 "SELECT 1, 2, 3 WHERE 1 " {1 2 3}
+ 0010.2 "SELECT 1, 2, 3 WHERE 0 " {}
+ 0010.3 "SELECT 1, 2, 3 WHERE NULL " {}
+
+ 1010.1 "SELECT DISTINCT 1, 2, 3 WHERE 1 " {1 2 3}
+
+ 2010.1 "SELECT ALL 1, 2, 3 WHERE 1 " {1 2 3}
+
+ 0110.1 "SELECT a, b, a||b FROM t1 WHERE a!='x' " {
+ a one aone b two btwo c three cthree
+ }
+ 0110.2 "SELECT a, b, a||b FROM t1 WHERE a=='x'" {}
+
+ 1110.1 "SELECT DISTINCT a, b, a||b FROM t1 WHERE a!='x' " {
+ a one aone b two btwo c three cthree
+ }
+
+ 2110.0 "SELECT ALL a, b, a||b FROM t1 WHERE a=='x'" {}
+
+ 0001.1 "SELECT 1, 2, 3 GROUP BY 2" {1 2 3}
+ 0002.1 "SELECT 1, 2, 3 GROUP BY 2 HAVING count(*)=1" {1 2 3}
+ 0002.2 "SELECT 1, 2, 3 GROUP BY 2 HAVING count(*)>1" {}
+
+ 1001.1 "SELECT DISTINCT 1, 2, 3 GROUP BY 2" {1 2 3}
+ 1002.1 "SELECT DISTINCT 1, 2, 3 GROUP BY 2 HAVING count(*)=1" {1 2 3}
+ 1002.2 "SELECT DISTINCT 1, 2, 3 GROUP BY 2 HAVING count(*)>1" {}
+
+ 2001.1 "SELECT ALL 1, 2, 3 GROUP BY 2" {1 2 3}
+ 2002.1 "SELECT ALL 1, 2, 3 GROUP BY 2 HAVING count(*)=1" {1 2 3}
+ 2002.2 "SELECT ALL 1, 2, 3 GROUP BY 2 HAVING count(*)>1" {}
+
+ 0101.1 "SELECT count(*), max(a) FROM t1 GROUP BY b" {1 a 1 c 1 b}
+ 0102.1 "SELECT count(*), max(a) FROM t1 GROUP BY b HAVING count(*)=1" {
+ 1 a 1 c 1 b
+ }
+ 0102.2 "SELECT count(*), max(a) FROM t1 GROUP BY b HAVING count(*)=2" { }
+
+ 1101.1 "SELECT DISTINCT count(*), max(a) FROM t1 GROUP BY b" {1 a 1 c 1 b}
+ 1102.1 "SELECT DISTINCT count(*), max(a) FROM t1
+ GROUP BY b HAVING count(*)=1" {
+ 1 a 1 c 1 b
+ }
+ 1102.2 "SELECT DISTINCT count(*), max(a) FROM t1
+ GROUP BY b HAVING count(*)=2" {
+ }
+
+ 2101.1 "SELECT ALL count(*), max(a) FROM t1 GROUP BY b" {1 a 1 c 1 b}
+ 2102.1 "SELECT ALL count(*), max(a) FROM t1
+ GROUP BY b HAVING count(*)=1" {
+ 1 a 1 c 1 b
+ }
+ 2102.2 "SELECT ALL count(*), max(a) FROM t1
+ GROUP BY b HAVING count(*)=2" {
+ }
+
+ 0011.1 "SELECT 1, 2, 3 WHERE 1 GROUP BY 2" {1 2 3}
+ 0012.1 "SELECT 1, 2, 3 WHERE 0 GROUP BY 2 HAVING count(*)=1" {}
+ 0012.2 "SELECT 1, 2, 3 WHERE 0 GROUP BY 2 HAVING count(*)>1" {}
+
+ 1011.1 "SELECT DISTINCT 1, 2, 3 WHERE 0 GROUP BY 2" {}
+ 1012.1 "SELECT DISTINCT 1, 2, 3 WHERE 1 GROUP BY 2 HAVING count(*)=1"
+ {1 2 3}
+ 1012.2 "SELECT DISTINCT 1, 2, 3 WHERE NULL GROUP BY 2 HAVING count(*)>1" {}
+
+ 2011.1 "SELECT ALL 1, 2, 3 WHERE 1 GROUP BY 2" {1 2 3}
+ 2012.1 "SELECT ALL 1, 2, 3 WHERE 0 GROUP BY 2 HAVING count(*)=1" {}
+ 2012.2 "SELECT ALL 1, 2, 3 WHERE 'abc' GROUP BY 2 HAVING count(*)>1" {}
+
+ 0111.1 "SELECT count(*), max(a) FROM t1 WHERE a='a' GROUP BY b" {1 a}
+ 0112.1 "SELECT count(*), max(a) FROM t1
+ WHERE a='c' GROUP BY b HAVING count(*)=1" {1 c}
+ 0112.2 "SELECT count(*), max(a) FROM t1
+ WHERE 0 GROUP BY b HAVING count(*)=2" { }
+ 1111.1 "SELECT DISTINCT count(*), max(a) FROM t1 WHERE a<'c' GROUP BY b"
+ {1 a 1 b}
+ 1112.1 "SELECT DISTINCT count(*), max(a) FROM t1 WHERE a>'a'
+ GROUP BY b HAVING count(*)=1" {
+ 1 c 1 b
+ }
+ 1112.2 "SELECT DISTINCT count(*), max(a) FROM t1 WHERE 0
+ GROUP BY b HAVING count(*)=2" {
+ }
+
+ 2111.1 "SELECT ALL count(*), max(a) FROM t1 WHERE b>'one' GROUP BY b"
+ {1 c 1 b}
+ 2112.1 "SELECT ALL count(*), max(a) FROM t1 WHERE a!='b'
+ GROUP BY b HAVING count(*)=1" {
+ 1 a 1 c
+ }
+ 2112.2 "SELECT ALL count(*), max(a) FROM t1
+ WHERE 0 GROUP BY b HAVING count(*)=2" { }
+}
+
+
+# EVIDENCE-OF: R-23316-20169 -- syntax diagram result-column
+#
+do_select_tests e_select-0.3 {
+ 1 "SELECT * FROM t1" {a one b two c three}
+ 2 "SELECT t1.* FROM t1" {a one b two c three}
+ 3 "SELECT 'x'||a||'x' FROM t1" {xax xbx xcx}
+ 4 "SELECT 'x'||a||'x' alias FROM t1" {xax xbx xcx}
+ 5 "SELECT 'x'||a||'x' AS alias FROM t1" {xax xbx xcx}
+}
+
+# EVIDENCE-OF: R-41233-21397 -- syntax diagram join-source
+#
+# EVIDENCE-OF: R-45040-11121 -- syntax diagram join-op
+#
+do_select_tests e_select-0.4 {
+ 1 "SELECT t1.rowid FROM t1" {1 2 3}
+ 2 "SELECT t1.rowid FROM t1,t2" {1 1 1 2 2 2 3 3 3}
+ 3 "SELECT t1.rowid FROM t1,t2,t3" {1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3}
+
+ 4 "SELECT t1.rowid FROM t1" {1 2 3}
+ 5 "SELECT t1.rowid FROM t1 JOIN t2" {1 1 1 2 2 2 3 3 3}
+ 6 "SELECT t1.rowid FROM t1 JOIN t2 JOIN t3"
+ {1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3}
+
+ 7 "SELECT t1.rowid FROM t1 NATURAL JOIN t3" {1 2}
+ 8 "SELECT t1.rowid FROM t1 NATURAL LEFT OUTER JOIN t3" {1 2 3}
+ 9 "SELECT t1.rowid FROM t1 NATURAL LEFT JOIN t3" {1 2 3}
+ 10 "SELECT t1.rowid FROM t1 NATURAL INNER JOIN t3" {1 2}
+ 11 "SELECT t1.rowid FROM t1 NATURAL CROSS JOIN t3" {1 2}
+
+ 12 "SELECT t1.rowid FROM t1 JOIN t3" {1 1 2 2 3 3}
+ 13 "SELECT t1.rowid FROM t1 LEFT OUTER JOIN t3" {1 1 2 2 3 3}
+ 14 "SELECT t1.rowid FROM t1 LEFT JOIN t3" {1 1 2 2 3 3}
+ 15 "SELECT t1.rowid FROM t1 INNER JOIN t3" {1 1 2 2 3 3}
+ 16 "SELECT t1.rowid FROM t1 CROSS JOIN t3" {1 1 2 2 3 3}
+}
+
+# EVIDENCE-OF: R-56911-63533 -- syntax diagram compound-operator
+#
+do_select_tests e_select-0.5 {
+ 1 "SELECT rowid FROM t1 UNION ALL SELECT rowid+2 FROM t4" {1 2 3 3 4}
+ 2 "SELECT rowid FROM t1 UNION SELECT rowid+2 FROM t4" {1 2 3 4}
+ 3 "SELECT rowid FROM t1 INTERSECT SELECT rowid+2 FROM t4" {3}
+ 4 "SELECT rowid FROM t1 EXCEPT SELECT rowid+2 FROM t4" {1 2}
+}
+
+# EVIDENCE-OF: R-60388-27458 -- syntax diagram ordering-term
+#
+do_select_tests e_select-0.6 {
+ 1 "SELECT b||a FROM t1 ORDER BY b||a" {onea threec twob}
+ 2 "SELECT b||a FROM t1 ORDER BY (b||a) COLLATE nocase" {onea threec twob}
+ 3 "SELECT b||a FROM t1 ORDER BY (b||a) ASC" {onea threec twob}
+ 4 "SELECT b||a FROM t1 ORDER BY (b||a) DESC" {twob threec onea}
+}
+
+# EVIDENCE-OF: R-36494-33519 -- syntax diagram select-stmt
+#
+do_select_tests e_select-0.7 {
+ 1 "SELECT * FROM t1" {a one b two c three}
+ 2 "SELECT * FROM t1 ORDER BY b" {a one c three b two}
+ 3 "SELECT * FROM t1 ORDER BY b, a" {a one c three b two}
+
+ 4 "SELECT * FROM t1 LIMIT 10" {a one b two c three}
+ 5 "SELECT * FROM t1 LIMIT 10 OFFSET 5" {}
+ 6 "SELECT * FROM t1 LIMIT 10, 5" {}
+
+ 7 "SELECT * FROM t1 ORDER BY a LIMIT 10" {a one b two c three}
+ 8 "SELECT * FROM t1 ORDER BY b LIMIT 10 OFFSET 5" {}
+ 9 "SELECT * FROM t1 ORDER BY a,b LIMIT 10, 5" {}
+
+ 10 "SELECT * FROM t1 UNION SELECT b, a FROM t1"
+ {a one b two c three one a three c two b}
+ 11 "SELECT * FROM t1 UNION SELECT b, a FROM t1 ORDER BY b"
+ {one a two b three c a one c three b two}
+ 12 "SELECT * FROM t1 UNION SELECT b, a FROM t1 ORDER BY b, a"
+ {one a two b three c a one c three b two}
+ 13 "SELECT * FROM t1 UNION SELECT b, a FROM t1 LIMIT 10"
+ {a one b two c three one a three c two b}
+ 14 "SELECT * FROM t1 UNION SELECT b, a FROM t1 LIMIT 10 OFFSET 5"
+ {two b}
+ 15 "SELECT * FROM t1 UNION SELECT b, a FROM t1 LIMIT 10, 5"
+ {}
+ 16 "SELECT * FROM t1 UNION SELECT b, a FROM t1 ORDER BY a LIMIT 10"
+ {a one b two c three one a three c two b}
+ 17 "SELECT * FROM t1 UNION SELECT b, a FROM t1 ORDER BY b LIMIT 10 OFFSET 5"
+ {b two}
+ 18 "SELECT * FROM t1 UNION SELECT b, a FROM t1 ORDER BY a,b LIMIT 10, 5"
+ {}
+}
+
+#-------------------------------------------------------------------------
+# The following tests focus on FROM clause (join) processing.
+#
+
+# EVIDENCE-OF: R-16074-54196 If the FROM clause is omitted from a simple
+# SELECT statement, then the input data is implicitly a single row zero
+# columns wide
+#
+do_select_tests e_select-1.1 {
+ 1 "SELECT 'abc'" {abc}
+ 2 "SELECT 'abc' WHERE NULL" {}
+ 3 "SELECT NULL" {{}}
+ 4 "SELECT count(*)" {1}
+ 5 "SELECT count(*) WHERE 0" {0}
+ 6 "SELECT count(*) WHERE 1" {1}
+}
+
+# EVIDENCE-OF: R-48114-33255 If there is only a single table in the
+# join-source following the FROM clause, then the input data used by the
+# SELECT statement is the contents of the named table.
+#
+# The results of the SELECT queries suggest that they are operating on the
+# contents of the table 'xx'.
+#
+do_execsql_test e_select-1.2.0 {
+ CREATE TABLE xx(x, y);
+ INSERT INTO xx VALUES('IiJlsIPepMuAhU', X'10B00B897A15BAA02E3F98DCE8F2');
+ INSERT INTO xx VALUES(NULL, -16.87);
+ INSERT INTO xx VALUES(-17.89, 'linguistically');
+} {}
+do_select_tests e_select-1.2 {
+ 1 "SELECT quote(x), quote(y) FROM xx" {
+ 'IiJlsIPepMuAhU' X'10B00B897A15BAA02E3F98DCE8F2'
+ NULL -16.87
+ -17.89 'linguistically'
+ }
+
+ 2 "SELECT count(*), count(x), count(y) FROM xx" {3 2 3}
+ 3 "SELECT sum(x), sum(y) FROM xx" {-17.89 -16.87}
+}
+
+# EVIDENCE-OF: R-23593-12456 If there is more than one table specified
+# as part of the join-source following the FROM keyword, then the
+# contents of each named table are joined into a single dataset for the
+# simple SELECT statement to operate on.
+#
+# There are more detailed tests for subsequent requirements that add
+# more detail to this idea. We just add a single test that shows that
+# data is coming from each of the three tables following the FROM clause
+# here to show that the statement, vague as it is, is not incorrect.
+#
+do_select_tests e_select-1.3 {
+ 1 "SELECT * FROM t1, t2, t3" {
+ a one a I a 1 a one a I b 2 a one b II a 1
+ a one b II b 2 a one c III a 1 a one c III b 2
+ b two a I a 1 b two a I b 2 b two b II a 1
+ b two b II b 2 b two c III a 1 b two c III b 2
+ c three a I a 1 c three a I b 2 c three b II a 1
+ c three b II b 2 c three c III a 1 c three c III b 2
+ }
+}
+
+#
+# The following block of tests - e_select-1.4.* - test that the description
+# of cartesian joins in the SELECT documentation is consistent with SQLite.
+# In doing so, we test the following three requirements as a side-effect:
+#
+# EVIDENCE-OF: R-46122-14930 If the join-op is "CROSS JOIN", "INNER
+# JOIN", "JOIN" or a comma (",") and there is no ON or USING clause,
+# then the result of the join is simply the cartesian product of the
+# left and right-hand datasets.
+#
+# The tests are built on this assertion. Really, they test that the output
+# of a CROSS JOIN, JOIN, INNER JOIN or "," join matches the expected result
+# of calculating the cartesian product of the left and right-hand datasets.
+#
+# EVIDENCE-OF: R-46256-57243 There is no difference between the "INNER
+# JOIN", "JOIN" and "," join operators.
+#
+# EVIDENCE-OF: R-07544-24155 The "CROSS JOIN" join operator produces the
+# same data as the "INNER JOIN", "JOIN" and "," operators
+#
+# All tests are run 4 times, with the only difference in each run being
+# which of the 4 equivalent cartesian product join operators are used.
+# Since the output data is the same in all cases, we consider that this
+# qualifies as testing the two statements above.
+#
+do_execsql_test e_select-1.4.0 {
+ CREATE TABLE x1(a, b);
+ CREATE TABLE x2(c, d, e);
+ CREATE TABLE x3(f, g, h, i);
+
+ -- x1: 3 rows, 2 columns
+ INSERT INTO x1 VALUES(24, 'converging');
+ INSERT INTO x1 VALUES(NULL, X'CB71');
+ INSERT INTO x1 VALUES('blonds', 'proprietary');
+
+ -- x2: 2 rows, 3 columns
+ INSERT INTO x2 VALUES(-60.06, NULL, NULL);
+ INSERT INTO x2 VALUES(-58, NULL, 1.21);
+
+ -- x3: 5 rows, 4 columns
+ INSERT INTO x3 VALUES(-39.24, NULL, 'encompass', -1);
+ INSERT INTO x3 VALUES('presenting', 51, 'reformation', 'dignified');
+ INSERT INTO x3 VALUES('conducting', -87.24, 37.56, NULL);
+ INSERT INTO x3 VALUES('coldest', -96, 'dramatists', 82.3);
+ INSERT INTO x3 VALUES('alerting', NULL, -93.79, NULL);
+} {}
+
+# EVIDENCE-OF: R-59089-25828 The columns of the cartesian product
+# dataset are, in order, all the columns of the left-hand dataset
+# followed by all the columns of the right-hand dataset.
+#
+do_join_test e_select-1.4.1.1 {
+ SELECT * FROM x1 %JOIN% x2 LIMIT 1
+} [concat {24 converging} {-60.06 {} {}}]
+
+do_join_test e_select-1.4.1.2 {
+ SELECT * FROM x2 %JOIN% x1 LIMIT 1
+} [concat {-60.06 {} {}} {24 converging}]
+
+do_join_test e_select-1.4.1.3 {
+ SELECT * FROM x3 %JOIN% x2 LIMIT 1
+} [concat {-39.24 {} encompass -1} {-60.06 {} {}}]
+
+do_join_test e_select-1.4.1.4 {
+ SELECT * FROM x2 %JOIN% x3 LIMIT 1
+} [concat {-60.06 {} {}} {-39.24 {} encompass -1}]
+
+# EVIDENCE-OF: R-44414-54710 There is a row in the cartesian product
+# dataset formed by combining each unique combination of a row from the
+# left-hand and right-hand datasets.
+#
+do_join_test e_select-1.4.2.1 {
+ SELECT * FROM x2 %JOIN% x3
+} [list -60.06 {} {} -39.24 {} encompass -1 \
+ -60.06 {} {} presenting 51 reformation dignified \
+ -60.06 {} {} conducting -87.24 37.56 {} \
+ -60.06 {} {} coldest -96 dramatists 82.3 \
+ -60.06 {} {} alerting {} -93.79 {} \
+ -58 {} 1.21 -39.24 {} encompass -1 \
+ -58 {} 1.21 presenting 51 reformation dignified \
+ -58 {} 1.21 conducting -87.24 37.56 {} \
+ -58 {} 1.21 coldest -96 dramatists 82.3 \
+ -58 {} 1.21 alerting {} -93.79 {} \
+]
+# TODO: Come back and add a few more like the above.
+
+# EVIDENCE-OF: R-20659-43267 In other words, if the left-hand dataset
+# consists of Nlhs rows of Mlhs columns, and the right-hand dataset of
+# Nrhs rows of Mrhs columns, then the cartesian product is a dataset of
+# Nlhs.Nrhs rows, each containing Mlhs+Mrhs columns.
+#
+# x1, x2 (Nlhs=3, Nrhs=2) (Mlhs=2, Mrhs=3)
+do_join_test e_select-1.4.3.1 {
+ SELECT count(*) FROM x1 %JOIN% x2
+} [expr 3*2]
+do_test e_select-1.4.3.2 {
+ expr {[llength [execsql {SELECT * FROM x1, x2}]] / 6}
+} [expr 2+3]
+
+# x2, x3 (Nlhs=2, Nrhs=5) (Mlhs=3, Mrhs=4)
+do_join_test e_select-1.4.3.3 {
+ SELECT count(*) FROM x2 %JOIN% x3
+} [expr 2*5]
+do_test e_select-1.4.3.4 {
+ expr {[llength [execsql {SELECT * FROM x2 JOIN x3}]] / 10}
+} [expr 3+4]
+
+# x3, x1 (Nlhs=5, Nrhs=3) (Mlhs=4, Mrhs=2)
+do_join_test e_select-1.4.3.5 {
+ SELECT count(*) FROM x3 %JOIN% x1
+} [expr 5*3]
+do_test e_select-1.4.3.6 {
+ expr {[llength [execsql {SELECT * FROM x3 CROSS JOIN x1}]] / 15}
+} [expr 4+2]
+
+# x3, x3 (Nlhs=5, Nrhs=5) (Mlhs=4, Mrhs=4)
+do_join_test e_select-1.4.3.7 {
+ SELECT count(*) FROM x3 %JOIN% x3
+} [expr 5*5]
+do_test e_select-1.4.3.8 {
+ expr {[llength [execsql {SELECT * FROM x3 INNER JOIN x3 AS x4}]] / 25}
+} [expr 4+4]
+
+# Some extra cartesian product tests using tables t1 and t2.
+#
+do_execsql_test e_select-1.4.4.1 { SELECT * FROM t1, t2 } $t1_cross_t2
+do_execsql_test e_select-1.4.4.2 { SELECT * FROM t1 AS x, t1 AS y} $t1_cross_t1
+
+do_select_tests e_select-1.4.5 [list \
+ 1 { SELECT * FROM t1 CROSS JOIN t2 } $t1_cross_t2 \
+ 2 { SELECT * FROM t1 AS y CROSS JOIN t1 AS x } $t1_cross_t1 \
+ 3 { SELECT * FROM t1 INNER JOIN t2 } $t1_cross_t2 \
+ 4 { SELECT * FROM t1 AS y INNER JOIN t1 AS x } $t1_cross_t1 \
+]
+
+
+# EVIDENCE-OF: R-22775-56496 If there is an ON clause specified, then
+# the ON expression is evaluated for each row of the cartesian product
+# as a boolean expression. All rows for which the expression evaluates
+# to false are excluded from the dataset.
+#
+foreach {tn select res} [list \
+ 1 { SELECT * FROM t1 %JOIN% t2 ON (1) } $t1_cross_t2 \
+ 2 { SELECT * FROM t1 %JOIN% t2 ON (0) } [list] \
+ 3 { SELECT * FROM t1 %JOIN% t2 ON (NULL) } [list] \
+ 4 { SELECT * FROM t1 %JOIN% t2 ON ('abc') } [list] \
+ 5 { SELECT * FROM t1 %JOIN% t2 ON ('1ab') } $t1_cross_t2 \
+ 6 { SELECT * FROM t1 %JOIN% t2 ON (0.9) } $t1_cross_t2 \
+ 7 { SELECT * FROM t1 %JOIN% t2 ON ('0.9') } $t1_cross_t2 \
+ 8 { SELECT * FROM t1 %JOIN% t2 ON (0.0) } [list] \
+ \
+ 9 { SELECT t1.b, t2.b FROM t1 %JOIN% t2 ON (t1.a = t2.a) } \
+ {one I two II three III} \
+ 10 { SELECT t1.b, t2.b FROM t1 %JOIN% t2 ON (t1.a = 'a') } \
+ {one I one II one III} \
+ 11 { SELECT t1.b, t2.b
+ FROM t1 %JOIN% t2 ON (CASE WHEN t1.a = 'a' THEN NULL ELSE 1 END) } \
+ {two I two II two III three I three II three III} \
+] {
+ do_join_test e_select-1.3.$tn $select $res
+}
+
+# EVIDENCE-OF: R-63358-54862 If there is a USING clause specified as
+# part of the join-constraint, then each of the column names specified
+# must exist in the datasets to both the left and right of the join-op.
+#
+do_select_tests e_select-1.4 -error {
+ cannot join using column %s - column not present in both tables
+} {
+ 1 { SELECT * FROM t1, t3 USING (b) } "b"
+ 2 { SELECT * FROM t3, t1 USING (c) } "c"
+ 3 { SELECT * FROM t3, (SELECT a AS b, b AS c FROM t1) USING (a) } "a"
+}
+
+# EVIDENCE-OF: R-55987-04584 For each pair of namesake columns, the
+# expression "lhs.X = rhs.X" is evaluated for each row of the cartesian
+# product as a boolean expression. All rows for which one or more of the
+# expressions evaluates to false are excluded from the result set.
+#
+do_select_tests e_select-1.5 {
+ 1 { SELECT * FROM t1, t3 USING (a) } {a one 1 b two 2}
+ 2 { SELECT * FROM t3, t4 USING (a,c) } {b 2}
+}
+
+# EVIDENCE-OF: R-54046-48600 When comparing values as a result of a
+# USING clause, the normal rules for handling affinities, collation
+# sequences and NULL values in comparisons apply.
+#
+# EVIDENCE-OF: R-35466-18578 The column from the dataset on the
+# left-hand side of the join operator is considered to be on the
+# left-hand side of the comparison operator (=) for the purposes of
+# collation sequence and affinity precedence.
+#
+do_execsql_test e_select-1.6.0 {
+ CREATE TABLE t5(a COLLATE nocase, b COLLATE binary);
+ INSERT INTO t5 VALUES('AA', 'cc');
+ INSERT INTO t5 VALUES('BB', 'dd');
+ INSERT INTO t5 VALUES(NULL, NULL);
+ CREATE TABLE t6(a COLLATE binary, b COLLATE nocase);
+ INSERT INTO t6 VALUES('aa', 'cc');
+ INSERT INTO t6 VALUES('bb', 'DD');
+ INSERT INTO t6 VALUES(NULL, NULL);
+} {}
+foreach {tn select res} {
+ 1 { SELECT * FROM t5 %JOIN% t6 USING (a) } {AA cc cc BB dd DD}
+ 2 { SELECT * FROM t6 %JOIN% t5 USING (a) } {}
+ 3 { SELECT * FROM (SELECT a COLLATE nocase, b FROM t6) %JOIN% t5 USING (a) }
+ {aa cc cc bb DD dd}
+ 4 { SELECT * FROM t5 %JOIN% t6 USING (a,b) } {AA cc}
+ 5 { SELECT * FROM t6 %JOIN% t5 USING (a,b) } {}
+} {
+ do_join_test e_select-1.6.$tn $select $res
+}
+
+# EVIDENCE-OF: R-57047-10461 For each pair of columns identified by a
+# USING clause, the column from the right-hand dataset is omitted from
+# the joined dataset.
+#
+# EVIDENCE-OF: R-56132-15700 This is the only difference between a USING
+# clause and its equivalent ON constraint.
+#
+foreach {tn select res} {
+ 1a { SELECT * FROM t1 %JOIN% t2 USING (a) }
+ {a one I b two II c three III}
+ 1b { SELECT * FROM t1 %JOIN% t2 ON (t1.a=t2.a) }
+ {a one a I b two b II c three c III}
+
+ 2a { SELECT * FROM t3 %JOIN% t4 USING (a) }
+ {a 1 {} b 2 2}
+ 2b { SELECT * FROM t3 %JOIN% t4 ON (t3.a=t4.a) }
+ {a 1 a {} b 2 b 2}
+
+ 3a { SELECT * FROM t3 %JOIN% t4 USING (a,c) } {b 2}
+ 3b { SELECT * FROM t3 %JOIN% t4 ON (t3.a=t4.a AND t3.c=t4.c) } {b 2 b 2}
+
+ 4a { SELECT * FROM (SELECT a COLLATE nocase, b FROM t6) AS x
+ %JOIN% t5 USING (a) }
+ {aa cc cc bb DD dd}
+ 4b { SELECT * FROM (SELECT a COLLATE nocase, b FROM t6) AS x
+ %JOIN% t5 ON (x.a=t5.a) }
+ {aa cc AA cc bb DD BB dd}
+} {
+ do_join_test e_select-1.7.$tn $select $res
+}
+
+# EVIDENCE-OF: R-41434-12448 If the join-op is a "LEFT JOIN" or "LEFT
+# OUTER JOIN", then after the ON or USING filtering clauses have been
+# applied, an extra row is added to the output for each row in the
+# original left-hand input dataset that corresponds to no rows at all in
+# the composite dataset (if any).
+#
+do_execsql_test e_select-1.8.0 {
+ CREATE TABLE t7(a, b, c);
+ CREATE TABLE t8(a, d, e);
+
+ INSERT INTO t7 VALUES('x', 'ex', 24);
+ INSERT INTO t7 VALUES('y', 'why', 25);
+
+ INSERT INTO t8 VALUES('x', 'abc', 24);
+ INSERT INTO t8 VALUES('z', 'ghi', 26);
+} {}
+
+do_select_tests e_select-1.8 {
+ 1a "SELECT count(*) FROM t7 JOIN t8 ON (t7.a=t8.a)" {1}
+ 1b "SELECT count(*) FROM t7 LEFT JOIN t8 ON (t7.a=t8.a)" {2}
+ 2a "SELECT count(*) FROM t7 JOIN t8 USING (a)" {1}
+ 2b "SELECT count(*) FROM t7 LEFT JOIN t8 USING (a)" {2}
+}
+
+
+# EVIDENCE-OF: R-15607-52988 The added rows contain NULL values in the
+# columns that would normally contain values copied from the right-hand
+# input dataset.
+#
+do_select_tests e_select-1.9 {
+ 1a "SELECT * FROM t7 JOIN t8 ON (t7.a=t8.a)" {x ex 24 x abc 24}
+ 1b "SELECT * FROM t7 LEFT JOIN t8 ON (t7.a=t8.a)"
+ {x ex 24 x abc 24 y why 25 {} {} {}}
+ 2a "SELECT * FROM t7 JOIN t8 USING (a)" {x ex 24 abc 24}
+ 2b "SELECT * FROM t7 LEFT JOIN t8 USING (a)" {x ex 24 abc 24 y why 25 {} {}}
+}
+
+# EVIDENCE-OF: R-01809-52134 If the NATURAL keyword is added to any of
+# the join-ops, then an implicit USING clause is added to the
+# join-constraints. The implicit USING clause contains each of the
+# column names that appear in both the left and right-hand input
+# datasets.
+#
+do_select_tests e_select-1-10 {
+ 1a "SELECT * FROM t7 JOIN t8 USING (a)" {x ex 24 abc 24}
+ 1b "SELECT * FROM t7 NATURAL JOIN t8" {x ex 24 abc 24}
+
+ 2a "SELECT * FROM t8 JOIN t7 USING (a)" {x abc 24 ex 24}
+ 2b "SELECT * FROM t8 NATURAL JOIN t7" {x abc 24 ex 24}
+
+ 3a "SELECT * FROM t7 LEFT JOIN t8 USING (a)" {x ex 24 abc 24 y why 25 {} {}}
+ 3b "SELECT * FROM t7 NATURAL LEFT JOIN t8" {x ex 24 abc 24 y why 25 {} {}}
+
+ 4a "SELECT * FROM t8 LEFT JOIN t7 USING (a)" {x abc 24 ex 24 z ghi 26 {} {}}
+ 4b "SELECT * FROM t8 NATURAL LEFT JOIN t7" {x abc 24 ex 24 z ghi 26 {} {}}
+
+ 5a "SELECT * FROM t3 JOIN t4 USING (a,c)" {b 2}
+ 5b "SELECT * FROM t3 NATURAL JOIN t4" {b 2}
+
+ 6a "SELECT * FROM t3 LEFT JOIN t4 USING (a,c)" {a 1 b 2}
+ 6b "SELECT * FROM t3 NATURAL LEFT JOIN t4" {a 1 b 2}
+}
+
+# EVIDENCE-OF: R-49566-01570 If the left and right-hand input datasets
+# feature no common column names, then the NATURAL keyword has no effect
+# on the results of the join.
+#
+do_execsql_test e_select-1.11.0 {
+ CREATE TABLE t10(x, y);
+ INSERT INTO t10 VALUES(1, 'true');
+ INSERT INTO t10 VALUES(0, 'false');
+} {}
+do_select_tests e_select-1-11 {
+ 1a "SELECT a, x FROM t1 CROSS JOIN t10" {a 1 a 0 b 1 b 0 c 1 c 0}
+ 1b "SELECT a, x FROM t1 NATURAL CROSS JOIN t10" {a 1 a 0 b 1 b 0 c 1 c 0}
+}
+
+# EVIDENCE-OF: R-39625-59133 A USING or ON clause may not be added to a
+# join that specifies the NATURAL keyword.
+#
+foreach {tn sql} {
+ 1 {SELECT * FROM t1 NATURAL LEFT JOIN t2 USING (a)}
+ 2 {SELECT * FROM t1 NATURAL LEFT JOIN t2 ON (t1.a=t2.a)}
+ 3 {SELECT * FROM t1 NATURAL LEFT JOIN t2 ON (45)}
+} {
+ do_catchsql_test e_select-1.12.$tn "
+ $sql
+ " {1 {a NATURAL join may not have an ON or USING clause}}
+}
+
+#-------------------------------------------------------------------------
+# The next block of tests - e_select-3.* - concentrate on verifying
+# statements made regarding WHERE clause processing.
+#
+drop_all_tables
+do_execsql_test e_select-3.0 {
+ CREATE TABLE x1(k, x, y, z);
+ INSERT INTO x1 VALUES(1, 'relinquished', 'aphasia', 78.43);
+ INSERT INTO x1 VALUES(2, X'A8E8D66F', X'07CF', -81);
+ INSERT INTO x1 VALUES(3, -22, -27.57, NULL);
+ INSERT INTO x1 VALUES(4, NULL, 'bygone', 'picky');
+ INSERT INTO x1 VALUES(5, NULL, 96.28, NULL);
+ INSERT INTO x1 VALUES(6, 0, 1, 2);
+
+ CREATE TABLE x2(k, x, y2);
+ INSERT INTO x2 VALUES(1, 50, X'B82838');
+ INSERT INTO x2 VALUES(5, 84.79, 65.88);
+ INSERT INTO x2 VALUES(3, -22, X'0E1BE452A393');
+ INSERT INTO x2 VALUES(7, 'mistrusted', 'standardized');
+} {}
+
+# EVIDENCE-OF: R-06999-14330 If a WHERE clause is specified, the WHERE
+# expression is evaluated for each row in the input data as a boolean
+# expression. All rows for which the WHERE clause expression evaluates
+# to false are excluded from the dataset before continuing.
+#
+do_execsql_test e_select-3.1.1 { SELECT k FROM x1 WHERE x } {3}
+do_execsql_test e_select-3.1.2 { SELECT k FROM x1 WHERE y } {3 5 6}
+do_execsql_test e_select-3.1.3 { SELECT k FROM x1 WHERE z } {1 2 6}
+do_execsql_test e_select-3.1.4 { SELECT k FROM x1 WHERE '1'||z } {1 2 4 6}
+do_execsql_test e_select-3.1.5 { SELECT k FROM x1 WHERE x IS NULL } {4 5}
+do_execsql_test e_select-3.1.6 { SELECT k FROM x1 WHERE z - 78.43 } {2 4 6}
+
+do_execsql_test e_select-3.2.1a {
+ SELECT k FROM x1 LEFT JOIN x2 USING(k)
+} {1 2 3 4 5 6}
+do_execsql_test e_select-3.2.1b {
+ SELECT k FROM x1 LEFT JOIN x2 USING(k) WHERE x2.k
+} {1 3 5}
+do_execsql_test e_select-3.2.2 {
+ SELECT k FROM x1 LEFT JOIN x2 USING(k) WHERE x2.k IS NULL
+} {2 4 6}
+
+do_execsql_test e_select-3.2.3 {
+ SELECT k FROM x1 NATURAL JOIN x2 WHERE x2.k
+} {3}
+do_execsql_test e_select-3.2.4 {
+ SELECT k FROM x1 NATURAL JOIN x2 WHERE x2.k-3
+} {}
+
+#-------------------------------------------------------------------------
+# Tests below this point are focused on verifying the testable statements
+# related to caculating the result rows of a simple SELECT statement.
+#
+
+drop_all_tables
+do_execsql_test e_select-4.0 {
+ CREATE TABLE z1(a, b, c);
+ CREATE TABLE z2(d, e);
+ CREATE TABLE z3(a, b);
+
+ INSERT INTO z1 VALUES(51.65, -59.58, 'belfries');
+ INSERT INTO z1 VALUES(-5, NULL, 75);
+ INSERT INTO z1 VALUES(-2.2, -23.18, 'suiters');
+ INSERT INTO z1 VALUES(NULL, 67, 'quartets');
+ INSERT INTO z1 VALUES(-1.04, -32.3, 'aspen');
+ INSERT INTO z1 VALUES(63, 'born', -26);
+
+ INSERT INTO z2 VALUES(NULL, 21);
+ INSERT INTO z2 VALUES(36, 6);
+
+ INSERT INTO z3 VALUES('subsistence', 'gauze');
+ INSERT INTO z3 VALUES(49.17, -67);
+} {}
+
+# EVIDENCE-OF: R-36327-17224 If a result expression is the special
+# expression "*" then all columns in the input data are substituted for
+# that one expression.
+#
+# EVIDENCE-OF: R-43693-30522 If the expression is the alias of a table
+# or subquery in the FROM clause followed by ".*" then all columns from
+# the named table or subquery are substituted for the single expression.
+#
+do_select_tests e_select-4.1 {
+ 1 "SELECT * FROM z1 LIMIT 1" {51.65 -59.58 belfries}
+ 2 "SELECT * FROM z1,z2 LIMIT 1" {51.65 -59.58 belfries {} 21}
+ 3 "SELECT z1.* FROM z1,z2 LIMIT 1" {51.65 -59.58 belfries}
+ 4 "SELECT z2.* FROM z1,z2 LIMIT 1" {{} 21}
+ 5 "SELECT z2.*, z1.* FROM z1,z2 LIMIT 1" {{} 21 51.65 -59.58 belfries}
+
+ 6 "SELECT count(*), * FROM z1" {6 63 born -26}
+ 7 "SELECT max(a), * FROM z1" {63 63 born -26}
+ 8 "SELECT *, min(a) FROM z1" {63 born -26 -5}
+
+ 9 "SELECT *,* FROM z1,z2 LIMIT 1" {
+ 51.65 -59.58 belfries {} 21 51.65 -59.58 belfries {} 21
+ }
+ 10 "SELECT z1.*,z1.* FROM z2,z1 LIMIT 1" {
+ 51.65 -59.58 belfries 51.65 -59.58 belfries
+ }
+}
+
+# EVIDENCE-OF: R-61869-22578 It is an error to use a "*" or "alias.*"
+# expression in any context other than than a result expression list.
+#
+# EVIDENCE-OF: R-44324-41166 It is also an error to use a "*" or
+# "alias.*" expression in a simple SELECT query that does not have a
+# FROM clause.
+#
+foreach {tn select err} {
+ 1.1 "SELECT a, b, c FROM z1 WHERE *" {near "*": syntax error}
+ 1.2 "SELECT a, b, c FROM z1 GROUP BY *" {near "*": syntax error}
+ 1.3 "SELECT 1 + * FROM z1" {near "*": syntax error}
+ 1.4 "SELECT * + 1 FROM z1" {near "+": syntax error}
+
+ 2.1 "SELECT *" {no tables specified}
+ 2.2 "SELECT * WHERE 1" {no tables specified}
+ 2.3 "SELECT * WHERE 0" {no tables specified}
+ 2.4 "SELECT count(*), *" {no tables specified}
+} {
+ do_catchsql_test e_select-4.2.$tn $select [list 1 $err]
+}
+
+# EVIDENCE-OF: R-08669-22397 The number of columns in the rows returned
+# by a simple SELECT statement is equal to the number of expressions in
+# the result expression list after substitution of * and alias.*
+# expressions.
+#
+foreach {tn select nCol} {
+ 1 "SELECT * FROM z1" 3
+ 2 "SELECT * FROM z1 NATURAL JOIN z3" 3
+ 3 "SELECT z1.* FROM z1 NATURAL JOIN z3" 3
+ 4 "SELECT z3.* FROM z1 NATURAL JOIN z3" 2
+ 5 "SELECT z1.*, z3.* FROM z1 NATURAL JOIN z3" 5
+ 6 "SELECT 1, 2, z1.* FROM z1" 5
+ 7 "SELECT a, *, b, c FROM z1" 6
+} {
+ set ::stmt [sqlite3_prepare_v2 db $select -1 DUMMY]
+ do_test e_select-4.3.$tn { sqlite3_column_count $::stmt } $nCol
+ sqlite3_finalize $::stmt
+}
+
+
+
+# In lang_select.html, a non-aggregate query is defined as any simple SELECT
+# that has no GROUP BY clause and no aggregate expressions in the result
+# expression list. Other queries are aggregate queries. Test cases
+# e_select-4.4.* through e_select-4.12.*, inclusive, which test the part of
+# simple SELECT that is different for aggregate and non-aggregate queries
+# verify (in a way) that these definitions are consistent:
+#
+# EVIDENCE-OF: R-20637-43463 A simple SELECT statement is an aggregate
+# query if it contains either a GROUP BY clause or one or more aggregate
+# functions in the result-set.
+#
+# EVIDENCE-OF: R-23155-55597 Otherwise, if a simple SELECT contains no
+# aggregate functions or a GROUP BY clause, it is a non-aggregate query.
+#
+
+# EVIDENCE-OF: R-44050-47362 If the SELECT statement is a non-aggregate
+# query, then each expression in the result expression list is evaluated
+# for each row in the dataset filtered by the WHERE clause.
+#
+do_select_tests e_select-4.4 {
+ 1 "SELECT a, b FROM z1"
+ {51.65 -59.58 -5 {} -2.2 -23.18 {} 67 -1.04 -32.3 63 born}
+
+ 2 "SELECT a IS NULL, b+1, * FROM z1" {
+ 0 -58.58 51.65 -59.58 belfries
+ 0 {} -5 {} 75
+ 0 -22.18 -2.2 -23.18 suiters
+ 1 68 {} 67 quartets
+ 0 -31.3 -1.04 -32.3 aspen
+ 0 1 63 born -26
+ }
+
+ 3 "SELECT 32*32, d||e FROM z2" {1024 {} 1024 366}
+}
+
+
+# Test cases e_select-4.5.* and e_select-4.6.* together show that:
+#
+# EVIDENCE-OF: R-51988-01124 The single row of result-set data created
+# by evaluating the aggregate and non-aggregate expressions in the
+# result-set forms the result of an aggregate query without a GROUP BY
+# clause.
+#
+
+# EVIDENCE-OF: R-57629-25253 If the SELECT statement is an aggregate
+# query without a GROUP BY clause, then each aggregate expression in the
+# result-set is evaluated once across the entire dataset.
+#
+do_select_tests e_select-4.5 {
+ 1 "SELECT count(a), max(a), count(b), max(b) FROM z1" {5 63 5 born}
+ 2 "SELECT count(*), max(1)" {1 1}
+
+ 3 "SELECT sum(b+1) FROM z1 NATURAL LEFT JOIN z3" {-43.06}
+ 4 "SELECT sum(b+2) FROM z1 NATURAL LEFT JOIN z3" {-38.06}
+ 5 "SELECT sum(b IS NOT NULL) FROM z1 NATURAL LEFT JOIN z3" {5}
+}
+
+# EVIDENCE-OF: R-26684-40576 Each non-aggregate expression in the
+# result-set is evaluated once for an arbitrarily selected row of the
+# dataset.
+#
+# EVIDENCE-OF: R-27994-60376 The same arbitrarily selected row is used
+# for each non-aggregate expression.
+#
+# Note: The results of many of the queries in this block of tests are
+# technically undefined, as the documentation does not specify which row
+# SQLite will arbitrarily select to use for the evaluation of the
+# non-aggregate expressions.
+#
+drop_all_tables
+do_execsql_test e_select-4.6.0 {
+ CREATE TABLE a1(one PRIMARY KEY, two);
+ INSERT INTO a1 VALUES(1, 1);
+ INSERT INTO a1 VALUES(2, 3);
+ INSERT INTO a1 VALUES(3, 6);
+ INSERT INTO a1 VALUES(4, 10);
+
+ CREATE TABLE a2(one PRIMARY KEY, three);
+ INSERT INTO a2 VALUES(1, 1);
+ INSERT INTO a2 VALUES(3, 2);
+ INSERT INTO a2 VALUES(6, 3);
+ INSERT INTO a2 VALUES(10, 4);
+} {}
+do_select_tests e_select-4.6 {
+ 1 "SELECT one, two, count(*) FROM a1" {4 10 4}
+ 2 "SELECT one, two, count(*) FROM a1 WHERE one<3" {2 3 2}
+ 3 "SELECT one, two, count(*) FROM a1 WHERE one>3" {4 10 1}
+ 4 "SELECT *, count(*) FROM a1 JOIN a2" {4 10 10 4 16}
+ 5 "SELECT *, sum(three) FROM a1 NATURAL JOIN a2" {3 6 2 3}
+ 6 "SELECT *, sum(three) FROM a1 NATURAL JOIN a2" {3 6 2 3}
+ 7 "SELECT group_concat(three, ''), a1.* FROM a1 NATURAL JOIN a2" {12 3 6}
+}
+
+# EVIDENCE-OF: R-04486-07266 Or, if the dataset contains zero rows, then
+# each non-aggregate expression is evaluated against a row consisting
+# entirely of NULL values.
+#
+do_select_tests e_select-4.7 {
+ 1 "SELECT one, two, count(*) FROM a1 WHERE 0" {{} {} 0}
+ 2 "SELECT sum(two), * FROM a1, a2 WHERE three>5" {{} {} {} {} {}}
+ 3 "SELECT max(one) IS NULL, one IS NULL, two IS NULL FROM a1 WHERE two=7" {
+ 1 1 1
+ }
+}
+
+# EVIDENCE-OF: R-64138-28774 An aggregate query without a GROUP BY
+# clause always returns exactly one row of data, even if there are zero
+# rows of input data.
+#
+foreach {tn select} {
+ 8.1 "SELECT count(*) FROM a1"
+ 8.2 "SELECT count(*) FROM a1 WHERE 0"
+ 8.3 "SELECT count(*) FROM a1 WHERE 1"
+ 8.4 "SELECT max(a1.one)+min(two), a1.one, two, * FROM a1, a2 WHERE 1"
+ 8.5 "SELECT max(a1.one)+min(two), a1.one, two, * FROM a1, a2 WHERE 0"
+} {
+ # Set $nRow to the number of rows returned by $select:
+ set ::stmt [sqlite3_prepare_v2 db $select -1 DUMMY]
+ set nRow 0
+ while {"SQLITE_ROW" == [sqlite3_step $::stmt]} { incr nRow }
+ set rc [sqlite3_finalize $::stmt]
+
+ # Test that $nRow==1 and that statement execution was successful
+ # (rc==SQLITE_OK).
+ do_test e_select-4.$tn [list list $rc $nRow] {SQLITE_OK 1}
+}
+
+drop_all_tables
+do_execsql_test e_select-4.9.0 {
+ CREATE TABLE b1(one PRIMARY KEY, two);
+ INSERT INTO b1 VALUES(1, 'o');
+ INSERT INTO b1 VALUES(4, 'f');
+ INSERT INTO b1 VALUES(3, 't');
+ INSERT INTO b1 VALUES(2, 't');
+ INSERT INTO b1 VALUES(5, 'f');
+ INSERT INTO b1 VALUES(7, 's');
+ INSERT INTO b1 VALUES(6, 's');
+
+ CREATE TABLE b2(x, y);
+ INSERT INTO b2 VALUES(NULL, 0);
+ INSERT INTO b2 VALUES(NULL, 1);
+ INSERT INTO b2 VALUES('xyz', 2);
+ INSERT INTO b2 VALUES('abc', 3);
+ INSERT INTO b2 VALUES('xyz', 4);
+
+ CREATE TABLE b3(a COLLATE nocase, b COLLATE binary);
+ INSERT INTO b3 VALUES('abc', 'abc');
+ INSERT INTO b3 VALUES('aBC', 'aBC');
+ INSERT INTO b3 VALUES('Def', 'Def');
+ INSERT INTO b3 VALUES('dEF', 'dEF');
+} {}
+
+# EVIDENCE-OF: R-57754-57109 If the SELECT statement is an aggregate
+# query with a GROUP BY clause, then each of the expressions specified
+# as part of the GROUP BY clause is evaluated for each row of the
+# dataset. Each row is then assigned to a "group" based on the results;
+# rows for which the results of evaluating the GROUP BY expressions are
+# the same are assigned to the same group.
+#
+# These tests also show that the following is not untrue:
+#
+# EVIDENCE-OF: R-25883-55063 The expressions in the GROUP BY clause do
+# not have to be expressions that appear in the result.
+#
+do_select_tests e_select-4.9 {
+ 1 "SELECT group_concat(one), two FROM b1 GROUP BY two" {
+ 4,5 f 1 o 7,6 s 3,2 t
+ }
+ 2 "SELECT group_concat(one), sum(one) FROM b1 GROUP BY (one>4)" {
+ 1,4,3,2 10 5,7,6 18
+ }
+ 3 "SELECT group_concat(one) FROM b1 GROUP BY (two>'o'), one%2" {
+ 4 1,5 2,6 3,7
+ }
+ 4 "SELECT group_concat(one) FROM b1 GROUP BY (one==2 OR two=='o')" {
+ 4,3,5,7,6 1,2
+ }
+}
+
+# EVIDENCE-OF: R-14926-50129 For the purposes of grouping rows, NULL
+# values are considered equal.
+#
+do_select_tests e_select-4.10 {
+ 1 "SELECT group_concat(y) FROM b2 GROUP BY x" {0,1 3 2,4}
+ 2 "SELECT count(*) FROM b2 GROUP BY CASE WHEN y<4 THEN NULL ELSE 0 END" {4 1}
+}
+
+# EVIDENCE-OF: R-10470-30318 The usual rules for selecting a collation
+# sequence with which to compare text values apply when evaluating
+# expressions in a GROUP BY clause.
+#
+do_select_tests e_select-4.11 {
+ 1 "SELECT count(*) FROM b3 GROUP BY b" {1 1 1 1}
+ 2 "SELECT count(*) FROM b3 GROUP BY a" {2 2}
+ 3 "SELECT count(*) FROM b3 GROUP BY +b" {1 1 1 1}
+ 4 "SELECT count(*) FROM b3 GROUP BY +a" {2 2}
+ 5 "SELECT count(*) FROM b3 GROUP BY b||''" {1 1 1 1}
+ 6 "SELECT count(*) FROM b3 GROUP BY a||''" {1 1 1 1}
+}
+
+# EVIDENCE-OF: R-63573-50730 The expressions in a GROUP BY clause may
+# not be aggregate expressions.
+#
+foreach {tn select} {
+ 12.1 "SELECT * FROM b3 GROUP BY count(*)"
+ 12.2 "SELECT max(a) FROM b3 GROUP BY max(b)"
+ 12.3 "SELECT group_concat(a) FROM b3 GROUP BY a, max(b)"
+} {
+ set res {1 {aggregate functions are not allowed in the GROUP BY clause}}
+ do_catchsql_test e_select-4.$tn $select $res
+}
+
+# EVIDENCE-OF: R-31537-00101 If a HAVING clause is specified, it is
+# evaluated once for each group of rows as a boolean expression. If the
+# result of evaluating the HAVING clause is false, the group is
+# discarded.
+#
+# This requirement is tested by all e_select-4.13.* tests.
+#
+# EVIDENCE-OF: R-04132-09474 If the HAVING clause is an aggregate
+# expression, it is evaluated across all rows in the group.
+#
+# Tested by e_select-4.13.1.*
+#
+# EVIDENCE-OF: R-28262-47447 If a HAVING clause is a non-aggregate
+# expression, it is evaluated with respect to an arbitrarily selected
+# row from the group.
+#
+# Tested by e_select-4.13.2.*
+#
+# Tests in this block also show that this is not untrue:
+#
+# EVIDENCE-OF: R-55403-13450 The HAVING expression may refer to values,
+# even aggregate functions, that are not in the result.
+#
+do_execsql_test e_select-4.13.0 {
+ CREATE TABLE c1(up, down);
+ INSERT INTO c1 VALUES('x', 1);
+ INSERT INTO c1 VALUES('x', 2);
+ INSERT INTO c1 VALUES('x', 4);
+ INSERT INTO c1 VALUES('x', 8);
+ INSERT INTO c1 VALUES('y', 16);
+ INSERT INTO c1 VALUES('y', 32);
+
+ CREATE TABLE c2(i, j);
+ INSERT INTO c2 VALUES(1, 0);
+ INSERT INTO c2 VALUES(2, 1);
+ INSERT INTO c2 VALUES(3, 3);
+ INSERT INTO c2 VALUES(4, 6);
+ INSERT INTO c2 VALUES(5, 10);
+ INSERT INTO c2 VALUES(6, 15);
+ INSERT INTO c2 VALUES(7, 21);
+ INSERT INTO c2 VALUES(8, 28);
+ INSERT INTO c2 VALUES(9, 36);
+
+ CREATE TABLE c3(i PRIMARY KEY, k TEXT);
+ INSERT INTO c3 VALUES(1, 'hydrogen');
+ INSERT INTO c3 VALUES(2, 'helium');
+ INSERT INTO c3 VALUES(3, 'lithium');
+ INSERT INTO c3 VALUES(4, 'beryllium');
+ INSERT INTO c3 VALUES(5, 'boron');
+ INSERT INTO c3 VALUES(94, 'plutonium');
+} {}
+
+do_select_tests e_select-4.13 {
+ 1.1 "SELECT up FROM c1 GROUP BY up HAVING count(*)>3" {x}
+ 1.2 "SELECT up FROM c1 GROUP BY up HAVING sum(down)>16" {y}
+ 1.3 "SELECT up FROM c1 GROUP BY up HAVING sum(down)<16" {x}
+ 1.4 "SELECT up||down FROM c1 GROUP BY (down<5) HAVING max(down)<10" {x4}
+
+ 2.1 "SELECT up FROM c1 GROUP BY up HAVING down>10" {y}
+ 2.2 "SELECT up FROM c1 GROUP BY up HAVING up='y'" {y}
+
+ 2.3 "SELECT i, j FROM c2 GROUP BY i>4 HAVING i>6" {9 36}
+}
+
+# EVIDENCE-OF: R-23927-54081 Each expression in the result-set is then
+# evaluated once for each group of rows.
+#
+# EVIDENCE-OF: R-53735-47017 If the expression is an aggregate
+# expression, it is evaluated across all rows in the group.
+#
+do_select_tests e_select-4.15 {
+ 1 "SELECT sum(down) FROM c1 GROUP BY up" {15 48}
+ 2 "SELECT sum(j), max(j) FROM c2 GROUP BY (i%3)" {54 36 27 21 39 28}
+ 3 "SELECT sum(j), max(j) FROM c2 GROUP BY (j%2)" {80 36 40 21}
+ 4 "SELECT 1+sum(j), max(j)+1 FROM c2 GROUP BY (j%2)" {81 37 41 22}
+ 5 "SELECT count(*), round(avg(i),2) FROM c1, c2 ON (i=down) GROUP BY j%2"
+ {3 4.33 1 2.0}
+}
+
+# EVIDENCE-OF: R-62913-19830 Otherwise, it is evaluated against a single
+# arbitrarily chosen row from within the group.
+#
+# EVIDENCE-OF: R-53924-08809 If there is more than one non-aggregate
+# expression in the result-set, then all such expressions are evaluated
+# for the same row.
+#
+do_select_tests e_select-4.15 {
+ 1 "SELECT i, j FROM c2 GROUP BY i%2" {8 28 9 36}
+ 2 "SELECT i, j FROM c2 GROUP BY i%2 HAVING j<30" {8 28}
+ 3 "SELECT i, j FROM c2 GROUP BY i%2 HAVING j>30" {9 36}
+ 4 "SELECT i, j FROM c2 GROUP BY i%2 HAVING j>30" {9 36}
+ 5 "SELECT count(*), i, k FROM c2 NATURAL JOIN c3 GROUP BY substr(k, 1, 1)"
+ {2 5 boron 2 2 helium 1 3 lithium}
+}
+
+# EVIDENCE-OF: R-19334-12811 Each group of input dataset rows
+# contributes a single row to the set of result rows.
+#
+# EVIDENCE-OF: R-02223-49279 Subject to filtering associated with the
+# DISTINCT keyword, the number of rows returned by an aggregate query
+# with a GROUP BY clause is the same as the number of groups of rows
+# produced by applying the GROUP BY and HAVING clauses to the filtered
+# input dataset.
+#
+do_select_tests e_select.4.16 -count {
+ 1 "SELECT i, j FROM c2 GROUP BY i%2" 2
+ 2 "SELECT i, j FROM c2 GROUP BY i" 9
+ 3 "SELECT i, j FROM c2 GROUP BY i HAVING i<5" 4
+}
+
+#-------------------------------------------------------------------------
+# The following tests attempt to verify statements made regarding the ALL
+# and DISTINCT keywords.
+#
+drop_all_tables
+do_execsql_test e_select-5.1.0 {
+ CREATE TABLE h1(a, b);
+ INSERT INTO h1 VALUES(1, 'one');
+ INSERT INTO h1 VALUES(1, 'I');
+ INSERT INTO h1 VALUES(1, 'i');
+ INSERT INTO h1 VALUES(4, 'four');
+ INSERT INTO h1 VALUES(4, 'IV');
+ INSERT INTO h1 VALUES(4, 'iv');
+
+ CREATE TABLE h2(x COLLATE nocase);
+ INSERT INTO h2 VALUES('One');
+ INSERT INTO h2 VALUES('Two');
+ INSERT INTO h2 VALUES('Three');
+ INSERT INTO h2 VALUES('Four');
+ INSERT INTO h2 VALUES('one');
+ INSERT INTO h2 VALUES('two');
+ INSERT INTO h2 VALUES('three');
+ INSERT INTO h2 VALUES('four');
+
+ CREATE TABLE h3(c, d);
+ INSERT INTO h3 VALUES(1, NULL);
+ INSERT INTO h3 VALUES(2, NULL);
+ INSERT INTO h3 VALUES(3, NULL);
+ INSERT INTO h3 VALUES(4, '2');
+ INSERT INTO h3 VALUES(5, NULL);
+ INSERT INTO h3 VALUES(6, '2,3');
+ INSERT INTO h3 VALUES(7, NULL);
+ INSERT INTO h3 VALUES(8, '2,4');
+ INSERT INTO h3 VALUES(9, '3');
+} {}
+
+# EVIDENCE-OF: R-60770-10612 One of the ALL or DISTINCT keywords may
+# follow the SELECT keyword in a simple SELECT statement.
+#
+do_select_tests e_select-5.1 {
+ 1 "SELECT ALL a FROM h1" {1 1 1 4 4 4}
+ 2 "SELECT DISTINCT a FROM h1" {1 4}
+}
+
+# EVIDENCE-OF: R-08861-34280 If the simple SELECT is a SELECT ALL, then
+# the entire set of result rows are returned by the SELECT.
+#
+# EVIDENCE-OF: R-47911-02086 If neither ALL or DISTINCT are present,
+# then the behaviour is as if ALL were specified.
+#
+# EVIDENCE-OF: R-14442-41305 If the simple SELECT is a SELECT DISTINCT,
+# then duplicate rows are removed from the set of result rows before it
+# is returned.
+#
+# The three testable statements above are tested by e_select-5.2.*,
+# 5.3.* and 5.4.* respectively.
+#
+do_select_tests e_select-5 {
+ 3.1 "SELECT ALL x FROM h2" {One Two Three Four one two three four}
+ 3.2 "SELECT ALL x FROM h1, h2 ON (x=b)" {One one Four four}
+
+ 3.1 "SELECT x FROM h2" {One Two Three Four one two three four}
+ 3.2 "SELECT x FROM h1, h2 ON (x=b)" {One one Four four}
+
+ 4.1 "SELECT DISTINCT x FROM h2" {One Two Three Four}
+ 4.2 "SELECT DISTINCT x FROM h1, h2 ON (x=b)" {One Four}
+}
+
+# EVIDENCE-OF: R-02054-15343 For the purposes of detecting duplicate
+# rows, two NULL values are considered to be equal.
+#
+do_select_tests e_select-5.5 {
+ 1 "SELECT DISTINCT d FROM h3" {{} 2 2,3 2,4 3}
+}
+
+# EVIDENCE-OF: R-58359-52112 The normal rules for selecting a collation
+# sequence to compare text values with apply.
+#
+do_select_tests e_select-5.6 {
+ 1 "SELECT DISTINCT b FROM h1" {one I i four IV iv}
+ 2 "SELECT DISTINCT b COLLATE nocase FROM h1" {one I four IV}
+ 3 "SELECT DISTINCT x FROM h2" {One Two Three Four}
+ 4 "SELECT DISTINCT x COLLATE binary FROM h2" {
+ One Two Three Four one two three four
+ }
+}
+
+#-------------------------------------------------------------------------
+# The following tests - e_select-7.* - test that statements made to do
+# with compound SELECT statements are correct.
+#
+
+# EVIDENCE-OF: R-39368-64333 In a compound SELECT, all the constituent
+# SELECTs must return the same number of result columns.
+#
+# All the other tests in this section use compound SELECTs created
+# using component SELECTs that do return the same number of columns.
+# So the tests here just show that it is an error to attempt otherwise.
+#
+drop_all_tables
+do_execsql_test e_select-7.1.0 {
+ CREATE TABLE j1(a, b, c);
+ CREATE TABLE j2(e, f);
+ CREATE TABLE j3(g);
+} {}
+do_select_tests e_select-7.1 -error {
+ SELECTs to the left and right of %s do not have the same number of result columns
+} {
+ 1 "SELECT a, b FROM j1 UNION ALL SELECT g FROM j3" {{UNION ALL}}
+ 2 "SELECT * FROM j1 UNION ALL SELECT * FROM j3" {{UNION ALL}}
+ 3 "SELECT a, b FROM j1 UNION ALL SELECT g FROM j3" {{UNION ALL}}
+ 4 "SELECT a, b FROM j1 UNION ALL SELECT * FROM j3,j2" {{UNION ALL}}
+ 5 "SELECT * FROM j3,j2 UNION ALL SELECT a, b FROM j1" {{UNION ALL}}
+
+ 6 "SELECT a, b FROM j1 UNION SELECT g FROM j3" {UNION}
+ 7 "SELECT * FROM j1 UNION SELECT * FROM j3" {UNION}
+ 8 "SELECT a, b FROM j1 UNION SELECT g FROM j3" {UNION}
+ 9 "SELECT a, b FROM j1 UNION SELECT * FROM j3,j2" {UNION}
+ 10 "SELECT * FROM j3,j2 UNION SELECT a, b FROM j1" {UNION}
+
+ 11 "SELECT a, b FROM j1 INTERSECT SELECT g FROM j3" {INTERSECT}
+ 12 "SELECT * FROM j1 INTERSECT SELECT * FROM j3" {INTERSECT}
+ 13 "SELECT a, b FROM j1 INTERSECT SELECT g FROM j3" {INTERSECT}
+ 14 "SELECT a, b FROM j1 INTERSECT SELECT * FROM j3,j2" {INTERSECT}
+ 15 "SELECT * FROM j3,j2 INTERSECT SELECT a, b FROM j1" {INTERSECT}
+
+ 16 "SELECT a, b FROM j1 EXCEPT SELECT g FROM j3" {EXCEPT}
+ 17 "SELECT * FROM j1 EXCEPT SELECT * FROM j3" {EXCEPT}
+ 18 "SELECT a, b FROM j1 EXCEPT SELECT g FROM j3" {EXCEPT}
+ 19 "SELECT a, b FROM j1 EXCEPT SELECT * FROM j3,j2" {EXCEPT}
+ 20 "SELECT * FROM j3,j2 EXCEPT SELECT a, b FROM j1" {EXCEPT}
+}
+
+# EVIDENCE-OF: R-01450-11152 As the components of a compound SELECT must
+# be simple SELECT statements, they may not contain ORDER BY or LIMIT
+# clauses.
+#
+foreach {tn select op1 op2} {
+ 1 "SELECT * FROM j1 ORDER BY a UNION ALL SELECT * FROM j2,j3"
+ {ORDER BY} {UNION ALL}
+ 2 "SELECT count(*) FROM j1 ORDER BY 1 UNION ALL SELECT max(e) FROM j2"
+ {ORDER BY} {UNION ALL}
+ 3 "SELECT count(*), * FROM j1 ORDER BY 1,2,3 UNION ALL SELECT *,* FROM j2"
+ {ORDER BY} {UNION ALL}
+ 4 "SELECT * FROM j1 LIMIT 10 UNION ALL SELECT * FROM j2,j3"
+ LIMIT {UNION ALL}
+ 5 "SELECT * FROM j1 LIMIT 10 OFFSET 5 UNION ALL SELECT * FROM j2,j3"
+ LIMIT {UNION ALL}
+ 6 "SELECT a FROM j1 LIMIT (SELECT e FROM j2) UNION ALL SELECT g FROM j2,j3"
+ LIMIT {UNION ALL}
+
+ 7 "SELECT * FROM j1 ORDER BY a UNION SELECT * FROM j2,j3"
+ {ORDER BY} {UNION}
+ 8 "SELECT count(*) FROM j1 ORDER BY 1 UNION SELECT max(e) FROM j2"
+ {ORDER BY} {UNION}
+ 9 "SELECT count(*), * FROM j1 ORDER BY 1,2,3 UNION SELECT *,* FROM j2"
+ {ORDER BY} {UNION}
+ 10 "SELECT * FROM j1 LIMIT 10 UNION SELECT * FROM j2,j3"
+ LIMIT {UNION}
+ 11 "SELECT * FROM j1 LIMIT 10 OFFSET 5 UNION SELECT * FROM j2,j3"
+ LIMIT {UNION}
+ 12 "SELECT a FROM j1 LIMIT (SELECT e FROM j2) UNION SELECT g FROM j2,j3"
+ LIMIT {UNION}
+
+ 13 "SELECT * FROM j1 ORDER BY a EXCEPT SELECT * FROM j2,j3"
+ {ORDER BY} {EXCEPT}
+ 14 "SELECT count(*) FROM j1 ORDER BY 1 EXCEPT SELECT max(e) FROM j2"
+ {ORDER BY} {EXCEPT}
+ 15 "SELECT count(*), * FROM j1 ORDER BY 1,2,3 EXCEPT SELECT *,* FROM j2"
+ {ORDER BY} {EXCEPT}
+ 16 "SELECT * FROM j1 LIMIT 10 EXCEPT SELECT * FROM j2,j3"
+ LIMIT {EXCEPT}
+ 17 "SELECT * FROM j1 LIMIT 10 OFFSET 5 EXCEPT SELECT * FROM j2,j3"
+ LIMIT {EXCEPT}
+ 18 "SELECT a FROM j1 LIMIT (SELECT e FROM j2) EXCEPT SELECT g FROM j2,j3"
+ LIMIT {EXCEPT}
+
+ 19 "SELECT * FROM j1 ORDER BY a INTERSECT SELECT * FROM j2,j3"
+ {ORDER BY} {INTERSECT}
+ 20 "SELECT count(*) FROM j1 ORDER BY 1 INTERSECT SELECT max(e) FROM j2"
+ {ORDER BY} {INTERSECT}
+ 21 "SELECT count(*), * FROM j1 ORDER BY 1,2,3 INTERSECT SELECT *,* FROM j2"
+ {ORDER BY} {INTERSECT}
+ 22 "SELECT * FROM j1 LIMIT 10 INTERSECT SELECT * FROM j2,j3"
+ LIMIT {INTERSECT}
+ 23 "SELECT * FROM j1 LIMIT 10 OFFSET 5 INTERSECT SELECT * FROM j2,j3"
+ LIMIT {INTERSECT}
+ 24 "SELECT a FROM j1 LIMIT (SELECT e FROM j2) INTERSECT SELECT g FROM j2,j3"
+ LIMIT {INTERSECT}
+} {
+ set err "$op1 clause should come after $op2 not before"
+ do_catchsql_test e_select-7.2.$tn $select [list 1 $err]
+}
+
+# EVIDENCE-OF: R-22874-32655 ORDER BY and LIMIT clauses may only occur
+# at the end of the entire compound SELECT.
+#
+foreach {tn select} {
+ 1 "SELECT * FROM j1 UNION ALL SELECT * FROM j2,j3 ORDER BY a"
+ 2 "SELECT count(*) FROM j1 UNION ALL SELECT max(e) FROM j2 ORDER BY 1"
+ 3 "SELECT count(*), * FROM j1 UNION ALL SELECT *,* FROM j2 ORDER BY 1,2,3"
+ 4 "SELECT * FROM j1 UNION ALL SELECT * FROM j2,j3 LIMIT 10"
+ 5 "SELECT * FROM j1 UNION ALL SELECT * FROM j2,j3 LIMIT 10 OFFSET 5"
+ 6 "SELECT a FROM j1 UNION ALL SELECT g FROM j2,j3 LIMIT (SELECT 10)"
+
+ 7 "SELECT * FROM j1 UNION SELECT * FROM j2,j3 ORDER BY a"
+ 8 "SELECT count(*) FROM j1 UNION SELECT max(e) FROM j2 ORDER BY 1"
+ 9 "SELECT count(*), * FROM j1 UNION SELECT *,* FROM j2 ORDER BY 1,2,3"
+ 10 "SELECT * FROM j1 UNION SELECT * FROM j2,j3 LIMIT 10"
+ 11 "SELECT * FROM j1 UNION SELECT * FROM j2,j3 LIMIT 10 OFFSET 5"
+ 12 "SELECT a FROM j1 UNION SELECT g FROM j2,j3 LIMIT (SELECT 10)"
+
+ 13 "SELECT * FROM j1 EXCEPT SELECT * FROM j2,j3 ORDER BY a"
+ 14 "SELECT count(*) FROM j1 EXCEPT SELECT max(e) FROM j2 ORDER BY 1"
+ 15 "SELECT count(*), * FROM j1 EXCEPT SELECT *,* FROM j2 ORDER BY 1,2,3"
+ 16 "SELECT * FROM j1 EXCEPT SELECT * FROM j2,j3 LIMIT 10"
+ 17 "SELECT * FROM j1 EXCEPT SELECT * FROM j2,j3 LIMIT 10 OFFSET 5"
+ 18 "SELECT a FROM j1 EXCEPT SELECT g FROM j2,j3 LIMIT (SELECT 10)"
+
+ 19 "SELECT * FROM j1 INTERSECT SELECT * FROM j2,j3 ORDER BY a"
+ 20 "SELECT count(*) FROM j1 INTERSECT SELECT max(e) FROM j2 ORDER BY 1"
+ 21 "SELECT count(*), * FROM j1 INTERSECT SELECT *,* FROM j2 ORDER BY 1,2,3"
+ 22 "SELECT * FROM j1 INTERSECT SELECT * FROM j2,j3 LIMIT 10"
+ 23 "SELECT * FROM j1 INTERSECT SELECT * FROM j2,j3 LIMIT 10 OFFSET 5"
+ 24 "SELECT a FROM j1 INTERSECT SELECT g FROM j2,j3 LIMIT (SELECT 10)"
+} {
+ do_test e_select-7.3.$tn { catch {execsql $select} msg } 0
+}
+
+# EVIDENCE-OF: R-08531-36543 A compound SELECT created using UNION ALL
+# operator returns all the rows from the SELECT to the left of the UNION
+# ALL operator, and all the rows from the SELECT to the right of it.
+#
+drop_all_tables
+do_execsql_test e_select-7.4.0 {
+ CREATE TABLE q1(a TEXT, b INTEGER, c);
+ CREATE TABLE q2(d NUMBER, e BLOB);
+ CREATE TABLE q3(f REAL, g);
+
+ INSERT INTO q1 VALUES(16, -87.66, NULL);
+ INSERT INTO q1 VALUES('legible', 94, -42.47);
+ INSERT INTO q1 VALUES('beauty', 36, NULL);
+
+ INSERT INTO q2 VALUES('legible', 1);
+ INSERT INTO q2 VALUES('beauty', 2);
+ INSERT INTO q2 VALUES(-65.91, 4);
+ INSERT INTO q2 VALUES('emanating', -16.56);
+
+ INSERT INTO q3 VALUES('beauty', 2);
+ INSERT INTO q3 VALUES('beauty', 2);
+} {}
+do_select_tests e_select-7.4 {
+ 1 {SELECT a FROM q1 UNION ALL SELECT d FROM q2}
+ {16 legible beauty legible beauty -65.91 emanating}
+
+ 2 {SELECT * FROM q1 WHERE a=16 UNION ALL SELECT 'x', * FROM q2 WHERE oid=1}
+ {16 -87.66 {} x legible 1}
+
+ 3 {SELECT count(*) FROM q1 UNION ALL SELECT min(e) FROM q2}
+ {3 -16.56}
+
+ 4 {SELECT * FROM q2 UNION ALL SELECT * FROM q3}
+ {legible 1 beauty 2 -65.91 4 emanating -16.56 beauty 2 beauty 2}
+}
+
+# EVIDENCE-OF: R-20560-39162 The UNION operator works the same way as
+# UNION ALL, except that duplicate rows are removed from the final
+# result set.
+#
+do_select_tests e_select-7.5 {
+ 1 {SELECT a FROM q1 UNION SELECT d FROM q2}
+ {-65.91 16 beauty emanating legible}
+
+ 2 {SELECT * FROM q1 WHERE a=16 UNION SELECT 'x', * FROM q2 WHERE oid=1}
+ {16 -87.66 {} x legible 1}
+
+ 3 {SELECT count(*) FROM q1 UNION SELECT min(e) FROM q2}
+ {-16.56 3}
+
+ 4 {SELECT * FROM q2 UNION SELECT * FROM q3}
+ {-65.91 4 beauty 2 emanating -16.56 legible 1}
+}
+
+# EVIDENCE-OF: R-45764-31737 The INTERSECT operator returns the
+# intersection of the results of the left and right SELECTs.
+#
+do_select_tests e_select-7.6 {
+ 1 {SELECT a FROM q1 INTERSECT SELECT d FROM q2} {beauty legible}
+ 2 {SELECT * FROM q2 INTERSECT SELECT * FROM q3} {beauty 2}
+}
+
+# EVIDENCE-OF: R-25787-28949 The EXCEPT operator returns the subset of
+# rows returned by the left SELECT that are not also returned by the
+# right-hand SELECT.
+#
+do_select_tests e_select-7.7 {
+ 1 {SELECT a FROM q1 EXCEPT SELECT d FROM q2} {16}
+
+ 2 {SELECT * FROM q2 EXCEPT SELECT * FROM q3}
+ {-65.91 4 emanating -16.56 legible 1}
+}
+
+# EVIDENCE-OF: R-40729-56447 Duplicate rows are removed from the results
+# of INTERSECT and EXCEPT operators before the result set is returned.
+#
+do_select_tests e_select-7.8 {
+ 0 {SELECT * FROM q3} {beauty 2 beauty 2}
+
+ 1 {SELECT * FROM q3 INTERSECT SELECT * FROM q3} {beauty 2}
+ 2 {SELECT * FROM q3 EXCEPT SELECT a,b FROM q1} {beauty 2}
+}
+
+# EVIDENCE-OF: R-46765-43362 For the purposes of determining duplicate
+# rows for the results of compound SELECT operators, NULL values are
+# considered equal to other NULL values and distinct from all non-NULL
+# values.
+#
+db nullvalue null
+do_select_tests e_select-7.9 {
+ 1 {SELECT NULL UNION ALL SELECT NULL} {null null}
+ 2 {SELECT NULL UNION SELECT NULL} {null}
+ 3 {SELECT NULL INTERSECT SELECT NULL} {null}
+ 4 {SELECT NULL EXCEPT SELECT NULL} {}
+
+ 5 {SELECT NULL UNION ALL SELECT 'ab'} {null ab}
+ 6 {SELECT NULL UNION SELECT 'ab'} {null ab}
+ 7 {SELECT NULL INTERSECT SELECT 'ab'} {}
+ 8 {SELECT NULL EXCEPT SELECT 'ab'} {null}
+
+ 9 {SELECT NULL UNION ALL SELECT 0} {null 0}
+ 10 {SELECT NULL UNION SELECT 0} {null 0}
+ 11 {SELECT NULL INTERSECT SELECT 0} {}
+ 12 {SELECT NULL EXCEPT SELECT 0} {null}
+
+ 13 {SELECT c FROM q1 UNION ALL SELECT g FROM q3} {null -42.47 null 2 2}
+ 14 {SELECT c FROM q1 UNION SELECT g FROM q3} {null -42.47 2}
+ 15 {SELECT c FROM q1 INTERSECT SELECT g FROM q3} {}
+ 16 {SELECT c FROM q1 EXCEPT SELECT g FROM q3} {null -42.47}
+}
+db nullvalue {}
+
+# EVIDENCE-OF: R-51232-50224 The collation sequence used to compare two
+# text values is determined as if the columns of the left and right-hand
+# SELECT statements were the left and right-hand operands of the equals
+# (=) operator, except that greater precedence is not assigned to a
+# collation sequence specified with the postfix COLLATE operator.
+#
+drop_all_tables
+do_execsql_test e_select-7.10.0 {
+ CREATE TABLE y1(a COLLATE nocase, b COLLATE binary, c);
+ INSERT INTO y1 VALUES('Abc', 'abc', 'aBC');
+} {}
+do_select_tests e_select-7.10 {
+ 1 {SELECT 'abc' UNION SELECT 'ABC'} {ABC abc}
+ 2 {SELECT 'abc' COLLATE nocase UNION SELECT 'ABC'} {ABC}
+ 3 {SELECT 'abc' UNION SELECT 'ABC' COLLATE nocase} {ABC}
+ 4 {SELECT 'abc' COLLATE binary UNION SELECT 'ABC' COLLATE nocase} {ABC abc}
+ 5 {SELECT 'abc' COLLATE nocase UNION SELECT 'ABC' COLLATE binary} {ABC}
+
+ 6 {SELECT a FROM y1 UNION SELECT b FROM y1} {abc}
+ 7 {SELECT b FROM y1 UNION SELECT a FROM y1} {Abc abc}
+ 8 {SELECT a FROM y1 UNION SELECT c FROM y1} {aBC}
+
+ 9 {SELECT a FROM y1 UNION SELECT c COLLATE binary FROM y1} {aBC}
+}
+
+# EVIDENCE-OF: R-32706-07403 No affinity transformations are applied to
+# any values when comparing rows as part of a compound SELECT.
+#
+drop_all_tables
+do_execsql_test e_select-7.10.0 {
+ CREATE TABLE w1(a TEXT, b NUMBER);
+ CREATE TABLE w2(a, b TEXT);
+
+ INSERT INTO w1 VALUES('1', 4.1);
+ INSERT INTO w2 VALUES(1, 4.1);
+} {}
+
+do_select_tests e_select-7.11 {
+ 1 { SELECT a FROM w1 UNION SELECT a FROM w2 } {1 1}
+ 2 { SELECT a FROM w2 UNION SELECT a FROM w1 } {1 1}
+ 3 { SELECT b FROM w1 UNION SELECT b FROM w2 } {4.1 4.1}
+ 4 { SELECT b FROM w2 UNION SELECT b FROM w1 } {4.1 4.1}
+
+ 5 { SELECT a FROM w1 INTERSECT SELECT a FROM w2 } {}
+ 6 { SELECT a FROM w2 INTERSECT SELECT a FROM w1 } {}
+ 7 { SELECT b FROM w1 INTERSECT SELECT b FROM w2 } {}
+ 8 { SELECT b FROM w2 INTERSECT SELECT b FROM w1 } {}
+
+ 9 { SELECT a FROM w1 EXCEPT SELECT a FROM w2 } {1}
+ 10 { SELECT a FROM w2 EXCEPT SELECT a FROM w1 } {1}
+ 11 { SELECT b FROM w1 EXCEPT SELECT b FROM w2 } {4.1}
+ 12 { SELECT b FROM w2 EXCEPT SELECT b FROM w1 } {4.1}
+}
+
+
+# EVIDENCE-OF: R-32562-20566 When three or more simple SELECTs are
+# connected into a compound SELECT, they group from left to right. In
+# other words, if "A", "B" and "C" are all simple SELECT statements, (A
+# op B op C) is processed as ((A op B) op C).
+#
+# e_select-7.12.1: Precedence of UNION vs. INTERSECT
+# e_select-7.12.2: Precedence of UNION vs. UNION ALL
+# e_select-7.12.3: Precedence of UNION vs. EXCEPT
+# e_select-7.12.4: Precedence of INTERSECT vs. UNION ALL
+# e_select-7.12.5: Precedence of INTERSECT vs. EXCEPT
+# e_select-7.12.6: Precedence of UNION ALL vs. EXCEPT
+# e_select-7.12.7: Check that "a EXCEPT b EXCEPT c" is processed as
+# "(a EXCEPT b) EXCEPT c".
+#
+# The INTERSECT and EXCEPT operations are mutually commutative. So
+# the e_select-7.12.5 test cases do not prove very much.
+#
+drop_all_tables
+do_execsql_test e_select-7.12.0 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+} {}
+foreach {tn select res} {
+ 1a "(1,2) INTERSECT (1) UNION (3)" {1 3}
+ 1b "(3) UNION (1,2) INTERSECT (1)" {1}
+
+ 2a "(1,2) UNION (3) UNION ALL (1)" {1 2 3 1}
+ 2b "(1) UNION ALL (3) UNION (1,2)" {1 2 3}
+
+ 3a "(1,2) UNION (3) EXCEPT (1)" {2 3}
+ 3b "(1,2) EXCEPT (3) UNION (1)" {1 2}
+
+ 4a "(1,2) INTERSECT (1) UNION ALL (3)" {1 3}
+ 4b "(3) UNION (1,2) INTERSECT (1)" {1}
+
+ 5a "(1,2) INTERSECT (2) EXCEPT (2)" {}
+ 5b "(2,3) EXCEPT (2) INTERSECT (2)" {}
+
+ 6a "(2) UNION ALL (2) EXCEPT (2)" {}
+ 6b "(2) EXCEPT (2) UNION ALL (2)" {2}
+
+ 7 "(2,3) EXCEPT (2) EXCEPT (3)" {}
+} {
+ set select [string map {( {SELECT x FROM t1 WHERE x IN (}} $select]
+ do_execsql_test e_select-7.12.$tn $select [list {*}$res]
+}
+
+
+#-------------------------------------------------------------------------
+# ORDER BY clauses
+#
+
+drop_all_tables
+do_execsql_test e_select-8.1.0 {
+ CREATE TABLE d1(x, y, z);
+
+ INSERT INTO d1 VALUES(1, 2, 3);
+ INSERT INTO d1 VALUES(2, 5, -1);
+ INSERT INTO d1 VALUES(1, 2, 8);
+ INSERT INTO d1 VALUES(1, 2, 7);
+ INSERT INTO d1 VALUES(2, 4, 93);
+ INSERT INTO d1 VALUES(1, 2, -20);
+ INSERT INTO d1 VALUES(1, 4, 93);
+ INSERT INTO d1 VALUES(1, 5, -1);
+
+ CREATE TABLE d2(a, b);
+ INSERT INTO d2 VALUES('gently', 'failings');
+ INSERT INTO d2 VALUES('commercials', 'bathrobe');
+ INSERT INTO d2 VALUES('iterate', 'sexton');
+ INSERT INTO d2 VALUES('babied', 'charitableness');
+ INSERT INTO d2 VALUES('solemnness', 'annexed');
+ INSERT INTO d2 VALUES('rejoicing', 'liabilities');
+ INSERT INTO d2 VALUES('pragmatist', 'guarded');
+ INSERT INTO d2 VALUES('barked', 'interrupted');
+ INSERT INTO d2 VALUES('reemphasizes', 'reply');
+ INSERT INTO d2 VALUES('lad', 'relenting');
+} {}
+
+# EVIDENCE-OF: R-44988-41064 Rows are first sorted based on the results
+# of evaluating the left-most expression in the ORDER BY list, then ties
+# are broken by evaluating the second left-most expression and so on.
+#
+do_select_tests e_select-8.1 {
+ 1 "SELECT * FROM d1 ORDER BY x, y, z" {
+ 1 2 -20 1 2 3 1 2 7 1 2 8
+ 1 4 93 1 5 -1 2 4 93 2 5 -1
+ }
+}
+
+# EVIDENCE-OF: R-06617-54588 Each ORDER BY expression may be optionally
+# followed by one of the keywords ASC (smaller values are returned
+# first) or DESC (larger values are returned first).
+#
+# Test cases e_select-8.2.* test the above.
+#
+# EVIDENCE-OF: R-18705-33393 If neither ASC or DESC are specified, rows
+# are sorted in ascending (smaller values first) order by default.
+#
+# Test cases e_select-8.3.* test the above. All 8.3 test cases are
+# copies of 8.2 test cases with the explicit "ASC" removed.
+#
+do_select_tests e_select-8 {
+ 2.1 "SELECT * FROM d1 ORDER BY x ASC, y ASC, z ASC" {
+ 1 2 -20 1 2 3 1 2 7 1 2 8
+ 1 4 93 1 5 -1 2 4 93 2 5 -1
+ }
+ 2.2 "SELECT * FROM d1 ORDER BY x DESC, y DESC, z DESC" {
+ 2 5 -1 2 4 93 1 5 -1 1 4 93
+ 1 2 8 1 2 7 1 2 3 1 2 -20
+ }
+ 2.3 "SELECT * FROM d1 ORDER BY x DESC, y ASC, z DESC" {
+ 2 4 93 2 5 -1 1 2 8 1 2 7
+ 1 2 3 1 2 -20 1 4 93 1 5 -1
+ }
+ 2.4 "SELECT * FROM d1 ORDER BY x DESC, y ASC, z ASC" {
+ 2 4 93 2 5 -1 1 2 -20 1 2 3
+ 1 2 7 1 2 8 1 4 93 1 5 -1
+ }
+
+ 3.1 "SELECT * FROM d1 ORDER BY x, y, z" {
+ 1 2 -20 1 2 3 1 2 7 1 2 8
+ 1 4 93 1 5 -1 2 4 93 2 5 -1
+ }
+ 3.3 "SELECT * FROM d1 ORDER BY x DESC, y, z DESC" {
+ 2 4 93 2 5 -1 1 2 8 1 2 7
+ 1 2 3 1 2 -20 1 4 93 1 5 -1
+ }
+ 3.4 "SELECT * FROM d1 ORDER BY x DESC, y, z" {
+ 2 4 93 2 5 -1 1 2 -20 1 2 3
+ 1 2 7 1 2 8 1 4 93 1 5 -1
+ }
+}
+
+# EVIDENCE-OF: R-29779-04281 If the ORDER BY expression is a constant
+# integer K then the expression is considered an alias for the K-th
+# column of the result set (columns are numbered from left to right
+# starting with 1).
+#
+do_select_tests e_select-8.4 {
+ 1 "SELECT * FROM d1 ORDER BY 1 ASC, 2 ASC, 3 ASC" {
+ 1 2 -20 1 2 3 1 2 7 1 2 8
+ 1 4 93 1 5 -1 2 4 93 2 5 -1
+ }
+ 2 "SELECT * FROM d1 ORDER BY 1 DESC, 2 DESC, 3 DESC" {
+ 2 5 -1 2 4 93 1 5 -1 1 4 93
+ 1 2 8 1 2 7 1 2 3 1 2 -20
+ }
+ 3 "SELECT * FROM d1 ORDER BY 1 DESC, 2 ASC, 3 DESC" {
+ 2 4 93 2 5 -1 1 2 8 1 2 7
+ 1 2 3 1 2 -20 1 4 93 1 5 -1
+ }
+ 4 "SELECT * FROM d1 ORDER BY 1 DESC, 2 ASC, 3 ASC" {
+ 2 4 93 2 5 -1 1 2 -20 1 2 3
+ 1 2 7 1 2 8 1 4 93 1 5 -1
+ }
+ 5 "SELECT * FROM d1 ORDER BY 1, 2, 3" {
+ 1 2 -20 1 2 3 1 2 7 1 2 8
+ 1 4 93 1 5 -1 2 4 93 2 5 -1
+ }
+ 6 "SELECT * FROM d1 ORDER BY 1 DESC, 2, 3 DESC" {
+ 2 4 93 2 5 -1 1 2 8 1 2 7
+ 1 2 3 1 2 -20 1 4 93 1 5 -1
+ }
+ 7 "SELECT * FROM d1 ORDER BY 1 DESC, 2, 3" {
+ 2 4 93 2 5 -1 1 2 -20 1 2 3
+ 1 2 7 1 2 8 1 4 93 1 5 -1
+ }
+ 8 "SELECT z, x FROM d1 ORDER BY 2" {
+ 3 1 8 1 7 1 -20 1
+ 93 1 -1 1 -1 2 93 2
+ }
+ 9 "SELECT z, x FROM d1 ORDER BY 1" {
+ -20 1 -1 2 -1 1 3 1
+ 7 1 8 1 93 2 93 1
+ }
+}
+
+# EVIDENCE-OF: R-63286-51977 If the ORDER BY expression is an identifier
+# that corresponds to the alias of one of the output columns, then the
+# expression is considered an alias for that column.
+#
+do_select_tests e_select-8.5 {
+ 1 "SELECT z+1 AS abc FROM d1 ORDER BY abc" {
+ -19 0 0 4 8 9 94 94
+ }
+ 2 "SELECT z+1 AS abc FROM d1 ORDER BY abc DESC" {
+ 94 94 9 8 4 0 0 -19
+ }
+ 3 "SELECT z AS x, x AS z FROM d1 ORDER BY z" {
+ 3 1 8 1 7 1 -20 1 93 1 -1 1 -1 2 93 2
+ }
+ 4 "SELECT z AS x, x AS z FROM d1 ORDER BY x" {
+ -20 1 -1 2 -1 1 3 1 7 1 8 1 93 2 93 1
+ }
+}
+
+# EVIDENCE-OF: R-65068-27207 Otherwise, if the ORDER BY expression is
+# any other expression, it is evaluated and the returned value used to
+# order the output rows.
+#
+# EVIDENCE-OF: R-03421-57988 If the SELECT statement is a simple SELECT,
+# then an ORDER BY may contain any arbitrary expressions.
+#
+do_select_tests e_select-8.6 {
+ 1 "SELECT * FROM d1 ORDER BY x+y+z" {
+ 1 2 -20 1 5 -1 1 2 3 2 5 -1
+ 1 2 7 1 2 8 1 4 93 2 4 93
+ }
+ 2 "SELECT * FROM d1 ORDER BY x*z" {
+ 1 2 -20 2 5 -1 1 5 -1 1 2 3
+ 1 2 7 1 2 8 1 4 93 2 4 93
+ }
+ 3 "SELECT * FROM d1 ORDER BY y*z" {
+ 1 2 -20 2 5 -1 1 5 -1 1 2 3
+ 1 2 7 1 2 8 2 4 93 1 4 93
+ }
+}
+
+# EVIDENCE-OF: R-28853-08147 However, if the SELECT is a compound
+# SELECT, then ORDER BY expressions that are not aliases to output
+# columns must be exactly the same as an expression used as an output
+# column.
+#
+do_select_tests e_select-8.7.1 -error {
+ %s ORDER BY term does not match any column in the result set
+} {
+ 1 "SELECT x FROM d1 UNION ALL SELECT a FROM d2 ORDER BY x*z" 1st
+ 2 "SELECT x,z FROM d1 UNION ALL SELECT a,b FROM d2 ORDER BY x, x/z" 2nd
+}
+
+do_select_tests e_select-8.7.2 {
+ 1 "SELECT x*z FROM d1 UNION ALL SELECT a FROM d2 ORDER BY x*z" {
+ -20 -2 -1 3 7 8 93 186 babied barked commercials gently
+ iterate lad pragmatist reemphasizes rejoicing solemnness
+ }
+ 2 "SELECT x, x/z FROM d1 UNION ALL SELECT a,b FROM d2 ORDER BY x, x/z" {
+ 1 -1 1 0 1 0 1 0 1 0 1 0 2 -2 2 0
+ babied charitableness barked interrupted commercials bathrobe gently
+ failings iterate sexton lad relenting pragmatist guarded reemphasizes reply
+ rejoicing liabilities solemnness annexed
+ }
+}
+
+do_execsql_test e_select-8.8.0 {
+ CREATE TABLE d3(a);
+ INSERT INTO d3 VALUES('text');
+ INSERT INTO d3 VALUES(14.1);
+ INSERT INTO d3 VALUES(13);
+ INSERT INTO d3 VALUES(X'78787878');
+ INSERT INTO d3 VALUES(15);
+ INSERT INTO d3 VALUES(12.9);
+ INSERT INTO d3 VALUES(null);
+
+ CREATE TABLE d4(x COLLATE nocase);
+ INSERT INTO d4 VALUES('abc');
+ INSERT INTO d4 VALUES('ghi');
+ INSERT INTO d4 VALUES('DEF');
+ INSERT INTO d4 VALUES('JKL');
+} {}
+
+# EVIDENCE-OF: R-10883-17697 For the purposes of sorting rows, values
+# are compared in the same way as for comparison expressions.
+#
+# The following tests verify that values of different types are sorted
+# correctly, and that mixed real and integer values are compared properly.
+#
+do_execsql_test e_select-8.8.1 {
+ SELECT a FROM d3 ORDER BY a
+} {{} 12.9 13 14.1 15 text xxxx}
+do_execsql_test e_select-8.8.2 {
+ SELECT a FROM d3 ORDER BY a DESC
+} {xxxx text 15 14.1 13 12.9 {}}
+
+
+# EVIDENCE-OF: R-64199-22471 If the ORDER BY expression is assigned a
+# collation sequence using the postfix COLLATE operator, then the
+# specified collation sequence is used.
+#
+do_execsql_test e_select-8.9.1 {
+ SELECT x FROM d4 ORDER BY 1 COLLATE binary
+} {DEF JKL abc ghi}
+do_execsql_test e_select-8.9.2 {
+ SELECT x COLLATE binary FROM d4 ORDER BY 1 COLLATE nocase
+} {abc DEF ghi JKL}
+
+# EVIDENCE-OF: R-09398-26102 Otherwise, if the ORDER BY expression is
+# an alias to an expression that has been assigned a collation sequence
+# using the postfix COLLATE operator, then the collation sequence
+# assigned to the aliased expression is used.
+#
+# In the test 8.10.2, the only result-column expression has no alias. So the
+# ORDER BY expression is not a reference to it and therefore does not inherit
+# the collation sequence. In test 8.10.3, "x" is the alias (as well as the
+# column name), so the ORDER BY expression is interpreted as an alias and the
+# collation sequence attached to the result column is used for sorting.
+#
+do_execsql_test e_select-8.10.1 {
+ SELECT x COLLATE binary FROM d4 ORDER BY 1
+} {DEF JKL abc ghi}
+do_execsql_test e_select-8.10.2 {
+ SELECT x COLLATE binary FROM d4 ORDER BY x
+} {abc DEF ghi JKL}
+do_execsql_test e_select-8.10.3 {
+ SELECT x COLLATE binary AS x FROM d4 ORDER BY x
+} {DEF JKL abc ghi}
+
+# EVIDENCE-OF: R-27301-09658 Otherwise, if the ORDER BY expression is a
+# column or an alias of an expression that is a column, then the default
+# collation sequence for the column is used.
+#
+do_execsql_test e_select-8.11.1 {
+ SELECT x AS y FROM d4 ORDER BY y
+} {abc DEF ghi JKL}
+do_execsql_test e_select-8.11.2 {
+ SELECT x||'' FROM d4 ORDER BY x
+} {abc DEF ghi JKL}
+
+# EVIDENCE-OF: R-49925-55905 Otherwise, the BINARY collation sequence is
+# used.
+#
+do_execsql_test e_select-8.12.1 {
+ SELECT x FROM d4 ORDER BY x||''
+} {DEF JKL abc ghi}
+
+# EVIDENCE-OF: R-44130-32593 If an ORDER BY expression is not an integer
+# alias, then SQLite searches the left-most SELECT in the compound for a
+# result column that matches either the second or third rules above. If
+# a match is found, the search stops and the expression is handled as an
+# alias for the result column that it has been matched against.
+# Otherwise, the next SELECT to the right is tried, and so on.
+#
+do_execsql_test e_select-8.13.0 {
+ CREATE TABLE d5(a, b);
+ CREATE TABLE d6(c, d);
+ CREATE TABLE d7(e, f);
+
+ INSERT INTO d5 VALUES(1, 'f');
+ INSERT INTO d6 VALUES(2, 'e');
+ INSERT INTO d7 VALUES(3, 'd');
+ INSERT INTO d5 VALUES(4, 'c');
+ INSERT INTO d6 VALUES(5, 'b');
+ INSERT INTO d7 VALUES(6, 'a');
+
+ CREATE TABLE d8(x COLLATE nocase);
+ CREATE TABLE d9(y COLLATE nocase);
+
+ INSERT INTO d8 VALUES('a');
+ INSERT INTO d9 VALUES('B');
+ INSERT INTO d8 VALUES('c');
+ INSERT INTO d9 VALUES('D');
+} {}
+do_select_tests e_select-8.13 {
+ 1 { SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7
+ ORDER BY a
+ } {1 2 3 4 5 6}
+ 2 { SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7
+ ORDER BY c
+ } {1 2 3 4 5 6}
+ 3 { SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7
+ ORDER BY e
+ } {1 2 3 4 5 6}
+ 4 { SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7
+ ORDER BY 1
+ } {1 2 3 4 5 6}
+
+ 5 { SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY b }
+ {f 1 c 4 4 c 1 f}
+ 6 { SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY 2 }
+ {f 1 c 4 4 c 1 f}
+
+ 7 { SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY a }
+ {1 f 4 c c 4 f 1}
+ 8 { SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY 1 }
+ {1 f 4 c c 4 f 1}
+
+ 9 { SELECT a, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY a+1 }
+ {f 2 c 5 4 c 1 f}
+ 10 { SELECT a, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY 2 }
+ {f 2 c 5 4 c 1 f}
+
+ 11 { SELECT a+1, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY a+1 }
+ {2 f 5 c c 5 f 2}
+ 12 { SELECT a+1, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY 1 }
+ {2 f 5 c c 5 f 2}
+}
+
+# EVIDENCE-OF: R-39265-04070 If no matching expression can be found in
+# the result columns of any constituent SELECT, it is an error.
+#
+do_select_tests e_select-8.14 -error {
+ %s ORDER BY term does not match any column in the result set
+} {
+ 1 { SELECT a FROM d5 UNION SELECT c FROM d6 ORDER BY a+1 } 1st
+ 2 { SELECT a FROM d5 UNION SELECT c FROM d6 ORDER BY a, a+1 } 2nd
+ 3 { SELECT * FROM d5 INTERSECT SELECT * FROM d6 ORDER BY 'hello' } 1st
+ 4 { SELECT * FROM d5 INTERSECT SELECT * FROM d6 ORDER BY blah } 1st
+ 5 { SELECT * FROM d5 INTERSECT SELECT * FROM d6 ORDER BY c,d,c+d } 3rd
+ 6 { SELECT * FROM d5 EXCEPT SELECT * FROM d7 ORDER BY 1,2,b,a/b } 4th
+}
+
+# EVIDENCE-OF: R-03407-11483 Each term of the ORDER BY clause is
+# processed separately and may be matched against result columns from
+# different SELECT statements in the compound.
+#
+do_select_tests e_select-8.15 {
+ 1 { SELECT a, b FROM d5 UNION ALL SELECT c-1, d FROM d6 ORDER BY a, d }
+ {1 e 1 f 4 b 4 c}
+ 2 { SELECT a, b FROM d5 UNION ALL SELECT c-1, d FROM d6 ORDER BY c-1, b }
+ {1 e 1 f 4 b 4 c}
+ 3 { SELECT a, b FROM d5 UNION ALL SELECT c-1, d FROM d6 ORDER BY 1, 2 }
+ {1 e 1 f 4 b 4 c}
+}
+
+
+#-------------------------------------------------------------------------
+# Tests related to statements made about the LIMIT/OFFSET clause.
+#
+do_execsql_test e_select-9.0 {
+ CREATE TABLE f1(a, b);
+ INSERT INTO f1 VALUES(26, 'z');
+ INSERT INTO f1 VALUES(25, 'y');
+ INSERT INTO f1 VALUES(24, 'x');
+ INSERT INTO f1 VALUES(23, 'w');
+ INSERT INTO f1 VALUES(22, 'v');
+ INSERT INTO f1 VALUES(21, 'u');
+ INSERT INTO f1 VALUES(20, 't');
+ INSERT INTO f1 VALUES(19, 's');
+ INSERT INTO f1 VALUES(18, 'r');
+ INSERT INTO f1 VALUES(17, 'q');
+ INSERT INTO f1 VALUES(16, 'p');
+ INSERT INTO f1 VALUES(15, 'o');
+ INSERT INTO f1 VALUES(14, 'n');
+ INSERT INTO f1 VALUES(13, 'm');
+ INSERT INTO f1 VALUES(12, 'l');
+ INSERT INTO f1 VALUES(11, 'k');
+ INSERT INTO f1 VALUES(10, 'j');
+ INSERT INTO f1 VALUES(9, 'i');
+ INSERT INTO f1 VALUES(8, 'h');
+ INSERT INTO f1 VALUES(7, 'g');
+ INSERT INTO f1 VALUES(6, 'f');
+ INSERT INTO f1 VALUES(5, 'e');
+ INSERT INTO f1 VALUES(4, 'd');
+ INSERT INTO f1 VALUES(3, 'c');
+ INSERT INTO f1 VALUES(2, 'b');
+ INSERT INTO f1 VALUES(1, 'a');
+} {}
+
+# EVIDENCE-OF: R-30481-56627 Any scalar expression may be used in the
+# LIMIT clause, so long as it evaluates to an integer or a value that
+# can be losslessly converted to an integer.
+#
+do_select_tests e_select-9.1 {
+ 1 { SELECT b FROM f1 ORDER BY a LIMIT 5 } {a b c d e}
+ 2 { SELECT b FROM f1 ORDER BY a LIMIT 2+3 } {a b c d e}
+ 3 { SELECT b FROM f1 ORDER BY a LIMIT (SELECT a FROM f1 WHERE b = 'e') }
+ {a b c d e}
+ 4 { SELECT b FROM f1 ORDER BY a LIMIT 5.0 } {a b c d e}
+ 5 { SELECT b FROM f1 ORDER BY a LIMIT '5' } {a b c d e}
+}
+
+# EVIDENCE-OF: R-46155-47219 If the expression evaluates to a NULL value
+# or any other value that cannot be losslessly converted to an integer,
+# an error is returned.
+#
+
+do_select_tests e_select-9.2 -error "datatype mismatch" {
+ 1 { SELECT b FROM f1 ORDER BY a LIMIT 'hello' } {}
+ 2 { SELECT b FROM f1 ORDER BY a LIMIT NULL } {}
+ 3 { SELECT b FROM f1 ORDER BY a LIMIT X'ABCD' } {}
+ 4 { SELECT b FROM f1 ORDER BY a LIMIT 5.1 } {}
+ 5 { SELECT b FROM f1 ORDER BY a LIMIT (SELECT group_concat(b) FROM f1) } {}
+}
+
+# EVIDENCE-OF: R-03014-26414 If the LIMIT expression evaluates to a
+# negative value, then there is no upper bound on the number of rows
+# returned.
+#
+do_select_tests e_select-9.4 {
+ 1 { SELECT b FROM f1 ORDER BY a LIMIT -1 }
+ {a b c d e f g h i j k l m n o p q r s t u v w x y z}
+ 2 { SELECT b FROM f1 ORDER BY a LIMIT length('abc')-100 }
+ {a b c d e f g h i j k l m n o p q r s t u v w x y z}
+ 3 { SELECT b FROM f1 ORDER BY a LIMIT (SELECT count(*) FROM f1)/2 - 14 }
+ {a b c d e f g h i j k l m n o p q r s t u v w x y z}
+}
+
+# EVIDENCE-OF: R-33750-29536 Otherwise, the SELECT returns the first N
+# rows of its result set only, where N is the value that the LIMIT
+# expression evaluates to.
+#
+do_select_tests e_select-9.5 {
+ 1 { SELECT b FROM f1 ORDER BY a LIMIT 0 } {}
+ 2 { SELECT b FROM f1 ORDER BY a DESC LIMIT 4 } {z y x w}
+ 3 { SELECT b FROM f1 ORDER BY a DESC LIMIT 8 } {z y x w v u t s}
+ 4 { SELECT b FROM f1 ORDER BY a DESC LIMIT '12.0' } {z y x w v u t s r q p o}
+}
+
+# EVIDENCE-OF: R-54935-19057 Or, if the SELECT statement would return
+# less than N rows without a LIMIT clause, then the entire result set is
+# returned.
+#
+do_select_tests e_select-9.6 {
+ 1 { SELECT b FROM f1 WHERE a>21 ORDER BY a LIMIT 10 } {v w x y z}
+ 2 { SELECT count(*) FROM f1 GROUP BY a/5 ORDER BY 1 LIMIT 10 } {2 4 5 5 5 5}
+}
+
+
+# EVIDENCE-OF: R-24188-24349 The expression attached to the optional
+# OFFSET clause that may follow a LIMIT clause must also evaluate to an
+# integer, or a value that can be losslessly converted to an integer.
+#
+foreach {tn select} {
+ 1 { SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET 'hello' }
+ 2 { SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET NULL }
+ 3 { SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET X'ABCD' }
+ 4 { SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET 5.1 }
+ 5 { SELECT b FROM f1 ORDER BY a
+ LIMIT 2 OFFSET (SELECT group_concat(b) FROM f1)
+ }
+} {
+ do_catchsql_test e_select-9.7.$tn $select {1 {datatype mismatch}}
+}
+
+# EVIDENCE-OF: R-20467-43422 If an expression has an OFFSET clause, then
+# the first M rows are omitted from the result set returned by the
+# SELECT statement and the next N rows are returned, where M and N are
+# the values that the OFFSET and LIMIT clauses evaluate to,
+# respectively.
+#
+do_select_tests e_select-9.8 {
+ 1 { SELECT b FROM f1 ORDER BY a LIMIT 10 OFFSET 5} {f g h i j k l m n o}
+ 2 { SELECT b FROM f1 ORDER BY a LIMIT 2+3 OFFSET 10} {k l m n o}
+ 3 { SELECT b FROM f1 ORDER BY a
+ LIMIT (SELECT a FROM f1 WHERE b='j')
+ OFFSET (SELECT a FROM f1 WHERE b='b')
+ } {c d e f g h i j k l}
+ 4 { SELECT b FROM f1 ORDER BY a LIMIT '5' OFFSET 3.0 } {d e f g h}
+ 5 { SELECT b FROM f1 ORDER BY a LIMIT '5' OFFSET 0 } {a b c d e}
+ 6 { SELECT b FROM f1 ORDER BY a LIMIT 0 OFFSET 10 } {}
+ 7 { SELECT b FROM f1 ORDER BY a LIMIT 3 OFFSET '1'||'5' } {p q r}
+}
+
+# EVIDENCE-OF: R-34648-44875 Or, if the SELECT would return less than
+# M+N rows if it did not have a LIMIT clause, then the first M rows are
+# skipped and the remaining rows (if any) are returned.
+#
+do_select_tests e_select-9.9 {
+ 1 { SELECT b FROM f1 ORDER BY a LIMIT 10 OFFSET 20} {u v w x y z}
+ 2 { SELECT a FROM f1 ORDER BY a DESC LIMIT 100 OFFSET 18+4} {4 3 2 1}
+}
+
+
+# EVIDENCE-OF: R-23293-62447 If the OFFSET clause evaluates to a
+# negative value, the results are the same as if it had evaluated to
+# zero.
+#
+do_select_tests e_select-9.10 {
+ 1 { SELECT b FROM f1 ORDER BY a LIMIT 5 OFFSET -1 } {a b c d e}
+ 2 { SELECT b FROM f1 ORDER BY a LIMIT 5 OFFSET -500 } {a b c d e}
+ 3 { SELECT b FROM f1 ORDER BY a LIMIT 5 OFFSET 0 } {a b c d e}
+}
+
+# EVIDENCE-OF: R-19509-40356 Instead of a separate OFFSET clause, the
+# LIMIT clause may specify two scalar expressions separated by a comma.
+#
+# EVIDENCE-OF: R-33788-46243 In this case, the first expression is used
+# as the OFFSET expression and the second as the LIMIT expression.
+#
+do_select_tests e_select-9.11 {
+ 1 { SELECT b FROM f1 ORDER BY a LIMIT 5, 10 } {f g h i j k l m n o}
+ 2 { SELECT b FROM f1 ORDER BY a LIMIT 10, 2+3 } {k l m n o}
+ 3 { SELECT b FROM f1 ORDER BY a
+ LIMIT (SELECT a FROM f1 WHERE b='b'), (SELECT a FROM f1 WHERE b='j')
+ } {c d e f g h i j k l}
+ 4 { SELECT b FROM f1 ORDER BY a LIMIT 3.0, '5' } {d e f g h}
+ 5 { SELECT b FROM f1 ORDER BY a LIMIT 0, '5' } {a b c d e}
+ 6 { SELECT b FROM f1 ORDER BY a LIMIT 10, 0 } {}
+ 7 { SELECT b FROM f1 ORDER BY a LIMIT '1'||'5', 3 } {p q r}
+
+ 8 { SELECT b FROM f1 ORDER BY a LIMIT 20, 10 } {u v w x y z}
+ 9 { SELECT a FROM f1 ORDER BY a DESC LIMIT 18+4, 100 } {4 3 2 1}
+
+ 10 { SELECT b FROM f1 ORDER BY a LIMIT -1, 5 } {a b c d e}
+ 11 { SELECT b FROM f1 ORDER BY a LIMIT -500, 5 } {a b c d e}
+ 12 { SELECT b FROM f1 ORDER BY a LIMIT 0, 5 } {a b c d e}
+}
+
+finish_test
diff --git a/test/e_select2.test b/test/e_select2.test
new file mode 100644
index 0000000..b338d4f
--- /dev/null
+++ b/test/e_select2.test
@@ -0,0 +1,580 @@
+# 2010 September 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_select.html document are correct.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+#-------------------------------------------------------------------------
+# te_* commands:
+#
+#
+# te_read_sql DB SELECT-STATEMENT
+# te_read_tbl DB TABLENAME
+#
+# These two commands are used to read a dataset from the database. A dataset
+# consists of N rows of M named columns of values each, where each value has a
+# type (null, integer, real, text or blob) and a value within the types domain.
+# The tcl format for a "dataset" is a list of two elements:
+#
+# * A list of the column names.
+# * A list of data rows. Each row is itself a list, where each element is
+# the contents of a column of the row. Each of these is a list of two
+# elements, the type name and the actual value.
+#
+# For example, the contents of table [t1] as a dataset is:
+#
+# CREATE TABLE t1(a, b);
+# INSERT INTO t1 VALUES('abc', NULL);
+# INSERT INTO t1 VALUES(43.1, 22);
+#
+# {a b} {{{TEXT abc} {NULL {}}} {{REAL 43.1} {INTEGER 22}}}
+#
+# The [te_read_tbl] command returns a dataset read from a table. The
+# [te_read_sql] returns the dataset that results from executing a SELECT
+# command.
+#
+#
+# te_tbljoin ?SWITCHES? LHS-TABLE RHS-TABLE
+# te_join ?SWITCHES? LHS-DATASET RHS-DATASET
+#
+# This command joins the two datasets and returns the resulting dataset. If
+# there are no switches specified, then the results is the cartesian product
+# of the two inputs. The [te_tbljoin] command reads the left and right-hand
+# datasets from the specified tables. The [te_join] command is passed the
+# datasets directly.
+#
+# Optional switches are as follows:
+#
+# -on SCRIPT
+# -using COLUMN-LIST
+# -left
+#
+# The -on option specifies a tcl script that is executed for each row in the
+# cartesian product of the two datasets. The script has 4 arguments appended
+# to it, in the following order:
+#
+# * The list of column-names from the left-hand dataset.
+# * A single row from the left-hand dataset (one "data row" list as
+# described above.
+# * The list of column-names from the right-hand dataset.
+# * A single row from the right-hand dataset.
+#
+# The script must return a boolean value - true if the combination of rows
+# should be included in the output dataset, or false otherwise.
+#
+# The -using option specifies a list of the columns from the right-hand
+# dataset that should be omitted from the output dataset.
+#
+# If the -left option is present, the join is done LEFT JOIN style.
+# Specifically, an extra row is inserted if after the -on script is run there
+# exist rows in the left-hand dataset that have no corresponding rows in
+# the output. See the implementation for more specific comments.
+#
+#
+# te_equals ?SWITCHES? COLNAME1 COLNAME2 <-on script args>
+#
+# The only supported switch is "-nocase". If it is present, then text values
+# are compared in a case-independent fashion. Otherwise, they are compared
+# as if using the SQLite BINARY collation sequence.
+#
+#
+# te_and ONSCRIPT1 ONSCRIPT2...
+#
+#
+
+
+#
+# te_read_tbl DB TABLENAME
+# te_read_sql DB SELECT-STATEMENT
+#
+# These two procs are used to extract datasets from the database, either
+# by reading the contents of a named table (te_read_tbl), or by executing
+# a SELECT statement (t3_read_sql).
+#
+# See the comment above, describing "te_* commands", for details of the
+# return values.
+#
+proc te_read_tbl {db tbl} {
+ te_read_sql $db "SELECT * FROM '$tbl'"
+}
+proc te_read_sql {db sql} {
+ set S [sqlite3_prepare_v2 $db $sql -1 DUMMY]
+
+ set cols [list]
+ for {set i 0} {$i < [sqlite3_column_count $S]} {incr i} {
+ lappend cols [sqlite3_column_name $S $i]
+ }
+
+ set rows [list]
+ while {[sqlite3_step $S] == "SQLITE_ROW"} {
+ set r [list]
+ for {set i 0} {$i < [sqlite3_column_count $S]} {incr i} {
+ lappend r [list [sqlite3_column_type $S $i] [sqlite3_column_text $S $i]]
+ }
+ lappend rows $r
+ }
+ sqlite3_finalize $S
+
+ return [list $cols $rows]
+}
+
+#-------
+# Usage: te_join <table-data1> <table-data2> <join spec>...
+#
+# Where a join-spec is an optional list of arguments as follows:
+#
+# ?-left?
+# ?-using colname-list?
+# ?-on on-expr-proc?
+#
+proc te_join {data1 data2 args} {
+
+ set testproc ""
+ set usinglist [list]
+ set isleft 0
+ for {set i 0} {$i < [llength $args]} {incr i} {
+ set a [lindex $args $i]
+ switch -- $a {
+ -on { set testproc [lindex $args [incr i]] }
+ -using { set usinglist [lindex $args [incr i]] }
+ -left { set isleft 1 }
+ default {
+ error "Unknown argument: $a"
+ }
+ }
+ }
+
+ set c1 [lindex $data1 0]
+ set c2 [lindex $data2 0]
+ set omitlist [list]
+ set nullrowlist [list]
+ set cret $c1
+
+ set cidx 0
+ foreach col $c2 {
+ set idx [lsearch $usinglist $col]
+ if {$idx>=0} {lappend omitlist $cidx}
+ if {$idx<0} {
+ lappend nullrowlist {NULL {}}
+ lappend cret $col
+ }
+ incr cidx
+ }
+ set omitlist [lsort -integer -decreasing $omitlist]
+
+
+ set rret [list]
+ foreach r1 [lindex $data1 1] {
+ set one 0
+ foreach r2 [lindex $data2 1] {
+ set ok 1
+ if {$testproc != ""} {
+ set ok [eval $testproc [list $c1 $r1 $c2 $r2]]
+ }
+ if {$ok} {
+ set one 1
+ foreach idx $omitlist {set r2 [lreplace $r2 $idx $idx]}
+ lappend rret [concat $r1 $r2]
+ }
+ }
+
+ if {$isleft && $one==0} {
+ lappend rret [concat $r1 $nullrowlist]
+ }
+ }
+
+ list $cret $rret
+}
+
+proc te_tbljoin {db t1 t2 args} {
+ te_join [te_read_tbl $db $t1] [te_read_tbl $db $t2] {*}$args
+}
+
+proc te_apply_affinity {affinity typevar valvar} {
+ upvar $typevar type
+ upvar $valvar val
+
+ switch -- $affinity {
+ integer {
+ if {[string is double $val]} { set type REAL }
+ if {[string is wideinteger $val]} { set type INTEGER }
+ if {$type == "REAL" && int($val)==$val} {
+ set type INTEGER
+ set val [expr {int($val)}]
+ }
+ }
+ text {
+ set type TEXT
+ }
+ none { }
+
+ default { error "invalid affinity: $affinity" }
+ }
+}
+
+#----------
+# te_equals ?SWITCHES? c1 c2 cols1 row1 cols2 row2
+#
+proc te_equals {args} {
+
+ if {[llength $args]<6} {error "invalid arguments to te_equals"}
+ foreach {c1 c2 cols1 row1 cols2 row2} [lrange $args end-5 end] break
+
+ set nocase 0
+ set affinity none
+
+ for {set i 0} {$i < ([llength $args]-6)} {incr i} {
+ set a [lindex $args $i]
+ switch -- $a {
+ -nocase {
+ set nocase 1
+ }
+ -affinity {
+ set affinity [string tolower [lindex $args [incr i]]]
+ }
+ default {
+ error "invalid arguments to te_equals"
+ }
+ }
+ }
+
+ set idx2 [if {[string is integer $c2]} { set c2 } else { lsearch $cols2 $c2 }]
+ set idx1 [if {[string is integer $c1]} { set c1 } else { lsearch $cols1 $c1 }]
+
+ set t1 [lindex $row1 $idx1 0]
+ set t2 [lindex $row2 $idx2 0]
+ set v1 [lindex $row1 $idx1 1]
+ set v2 [lindex $row2 $idx2 1]
+
+ te_apply_affinity $affinity t1 v1
+ te_apply_affinity $affinity t2 v2
+
+ if {$t1 == "NULL" || $t2 == "NULL"} { return 0 }
+ if {$nocase && $t1 == "TEXT"} { set v1 [string tolower $v1] }
+ if {$nocase && $t2 == "TEXT"} { set v2 [string tolower $v2] }
+
+
+ set res [expr {$t1 == $t2 && [string equal $v1 $v2]}]
+ return $res
+}
+
+proc te_false {args} { return 0 }
+proc te_true {args} { return 1 }
+
+proc te_and {args} {
+ foreach a [lrange $args 0 end-4] {
+ set res [eval $a [lrange $args end-3 end]]
+ if {$res == 0} {return 0}
+ }
+ return 1
+}
+
+
+proc te_dataset_eq {testname got expected} {
+ uplevel #0 [list do_test $testname [list set {} $got] $expected]
+}
+proc te_dataset_eq_unordered {testname got expected} {
+ lset got 1 [lsort [lindex $got 1]]
+ lset expected 1 [lsort [lindex $expected 1]]
+ te_dataset_eq $testname $got $expected
+}
+
+proc te_dataset_ne {testname got unexpected} {
+ uplevel #0 [list do_test $testname [list string equal $got $unexpected] 0]
+}
+proc te_dataset_ne_unordered {testname got unexpected} {
+ lset got 1 [lsort [lindex $got 1]]
+ lset unexpected 1 [lsort [lindex $unexpected 1]]
+ te_dataset_ne $testname $got $unexpected
+}
+
+
+#-------------------------------------------------------------------------
+#
+proc test_join {tn sqljoin tbljoinargs} {
+ set sql [te_read_sql db "SELECT * FROM $sqljoin"]
+ set te [te_tbljoin db {*}$tbljoinargs]
+ te_dataset_eq_unordered $tn $sql $te
+}
+
+drop_all_tables
+do_execsql_test e_select-2.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ CREATE TABLE t3(b COLLATE nocase);
+
+ INSERT INTO t1 VALUES(2, 'B');
+ INSERT INTO t1 VALUES(1, 'A');
+ INSERT INTO t1 VALUES(4, 'D');
+ INSERT INTO t1 VALUES(NULL, NULL);
+ INSERT INTO t1 VALUES(3, NULL);
+
+ INSERT INTO t2 VALUES(1, 'A');
+ INSERT INTO t2 VALUES(2, NULL);
+ INSERT INTO t2 VALUES(5, 'E');
+ INSERT INTO t2 VALUES(NULL, NULL);
+ INSERT INTO t2 VALUES(3, 'C');
+
+ INSERT INTO t3 VALUES('a');
+ INSERT INTO t3 VALUES('c');
+ INSERT INTO t3 VALUES('b');
+} {}
+
+foreach {tn indexes} {
+ e_select-2.1.1 { }
+ e_select-2.1.2 { CREATE INDEX i1 ON t1(a) }
+ e_select-2.1.3 { CREATE INDEX i1 ON t2(a) }
+ e_select-2.1.4 { CREATE INDEX i1 ON t3(b) }
+} {
+
+ catchsql { DROP INDEX i1 }
+ catchsql { DROP INDEX i2 }
+ catchsql { DROP INDEX i3 }
+ execsql $indexes
+
+ # EVIDENCE-OF: R-46122-14930 If the join-op is "CROSS JOIN", "INNER
+ # JOIN", "JOIN" or a comma (",") and there is no ON or USING clause,
+ # then the result of the join is simply the cartesian product of the
+ # left and right-hand datasets.
+ #
+ # EVIDENCE-OF: R-46256-57243 There is no difference between the "INNER
+ # JOIN", "JOIN" and "," join operators.
+ #
+ # EVIDENCE-OF: R-07544-24155 The "CROSS JOIN" join operator produces the
+ # same data as the "INNER JOIN", "JOIN" and "," operators
+ #
+ test_join $tn.1.1 "t1, t2" {t1 t2}
+ test_join $tn.1.2 "t1 INNER JOIN t2" {t1 t2}
+ test_join $tn.1.3 "t1 CROSS JOIN t2" {t1 t2}
+ test_join $tn.1.4 "t1 JOIN t2" {t1 t2}
+ test_join $tn.1.5 "t2, t3" {t2 t3}
+ test_join $tn.1.6 "t2 INNER JOIN t3" {t2 t3}
+ test_join $tn.1.7 "t2 CROSS JOIN t3" {t2 t3}
+ test_join $tn.1.8 "t2 JOIN t3" {t2 t3}
+ test_join $tn.1.9 "t2, t2 AS x" {t2 t2}
+ test_join $tn.1.10 "t2 INNER JOIN t2 AS x" {t2 t2}
+ test_join $tn.1.11 "t2 CROSS JOIN t2 AS x" {t2 t2}
+ test_join $tn.1.12 "t2 JOIN t2 AS x" {t2 t2}
+
+ # EVIDENCE-OF: R-22775-56496 If there is an ON clause specified, then
+ # the ON expression is evaluated for each row of the cartesian product
+ # as a boolean expression. All rows for which the expression evaluates
+ # to false are excluded from the dataset.
+ #
+ test_join $tn.2.1 "t1, t2 ON (t1.a=t2.a)" {t1 t2 -on {te_equals a a}}
+ test_join $tn.2.2 "t2, t1 ON (t1.a=t2.a)" {t2 t1 -on {te_equals a a}}
+ test_join $tn.2.3 "t2, t1 ON (1)" {t2 t1 -on te_true}
+ test_join $tn.2.4 "t2, t1 ON (NULL)" {t2 t1 -on te_false}
+ test_join $tn.2.5 "t2, t1 ON (1.1-1.1)" {t2 t1 -on te_false}
+ test_join $tn.2.6 "t1, t2 ON (1.1-1.0)" {t1 t2 -on te_true}
+
+
+ test_join $tn.3 "t1 LEFT JOIN t2 ON (t1.a=t2.a)" {t1 t2 -left -on {te_equals a a}}
+ test_join $tn.4 "t1 LEFT JOIN t2 USING (a)" {
+ t1 t2 -left -using a -on {te_equals a a}
+ }
+ test_join $tn.5 "t1 CROSS JOIN t2 USING(b, a)" {
+ t1 t2 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.6 "t1 NATURAL JOIN t2" {
+ t1 t2 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.7 "t1 NATURAL INNER JOIN t2" {
+ t1 t2 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.8 "t1 NATURAL CROSS JOIN t2" {
+ t1 t2 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.9 "t1 NATURAL INNER JOIN t2" {
+ t1 t2 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.10 "t1 NATURAL LEFT JOIN t2" {
+ t1 t2 -left -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.11 "t1 NATURAL LEFT OUTER JOIN t2" {
+ t1 t2 -left -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.12 "t2 NATURAL JOIN t1" {
+ t2 t1 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.13 "t2 NATURAL INNER JOIN t1" {
+ t2 t1 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.14 "t2 NATURAL CROSS JOIN t1" {
+ t2 t1 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.15 "t2 NATURAL INNER JOIN t1" {
+ t2 t1 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.16 "t2 NATURAL LEFT JOIN t1" {
+ t2 t1 -left -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.17 "t2 NATURAL LEFT OUTER JOIN t1" {
+ t2 t1 -left -using {a b} -on {te_and {te_equals a a} {te_equals b b}}
+ }
+ test_join $tn.18 "t1 LEFT JOIN t2 USING (b)" {
+ t1 t2 -left -using b -on {te_equals b b}
+ }
+ test_join $tn.19 "t1 JOIN t3 USING(b)" {t1 t3 -using b -on {te_equals b b}}
+ test_join $tn.20 "t3 JOIN t1 USING(b)" {
+ t3 t1 -using b -on {te_equals -nocase b b}
+ }
+ test_join $tn.21 "t1 NATURAL JOIN t3" {
+ t1 t3 -using b -on {te_equals b b}
+ }
+ test_join $tn.22 "t3 NATURAL JOIN t1" {
+ t3 t1 -using b -on {te_equals -nocase b b}
+ }
+ test_join $tn.23 "t1 NATURAL LEFT JOIN t3" {
+ t1 t3 -left -using b -on {te_equals b b}
+ }
+ test_join $tn.24 "t3 NATURAL LEFT JOIN t1" {
+ t3 t1 -left -using b -on {te_equals -nocase b b}
+ }
+ test_join $tn.25 "t1 LEFT JOIN t3 ON (t3.b=t1.b)" {
+ t1 t3 -left -on {te_equals -nocase b b}
+ }
+ test_join $tn.26 "t1 LEFT JOIN t3 ON (t1.b=t3.b)" {
+ t1 t3 -left -on {te_equals b b}
+ }
+ test_join $tn.27 "t1 JOIN t3 ON (t1.b=t3.b)" { t1 t3 -on {te_equals b b} }
+
+ # EVIDENCE-OF: R-28760-53843 When more than two tables are joined
+ # together as part of a FROM clause, the join operations are processed
+ # in order from left to right. In other words, the FROM clause (A
+ # join-op-1 B join-op-2 C) is computed as ((A join-op-1 B) join-op-2 C).
+ #
+ # Tests 28a and 28b show that the statement above is true for this case.
+ # Test 28c shows that if the parenthesis force a different order of
+ # evaluation the result is different. Test 28d verifies that the result
+ # of the query with the parenthesis forcing a different order of evaluation
+ # is as calculated by the [te_*] procs.
+ #
+ set t3_natural_left_join_t2 [
+ te_tbljoin db t3 t2 -left -using {b} -on {te_equals -nocase b b}
+ ]
+ set t1 [te_read_tbl db t1]
+ te_dataset_eq_unordered $tn.28a [
+ te_read_sql db "SELECT * FROM t3 NATURAL LEFT JOIN t2 NATURAL JOIN t1"
+ ] [te_join $t3_natural_left_join_t2 $t1 \
+ -using {a b} -on {te_and {te_equals a a} {te_equals -nocase b b}} \
+ ]
+
+ te_dataset_eq_unordered $tn.28b [
+ te_read_sql db "SELECT * FROM (t3 NATURAL LEFT JOIN t2) NATURAL JOIN t1"
+ ] [te_join $t3_natural_left_join_t2 $t1 \
+ -using {a b} -on {te_and {te_equals a a} {te_equals -nocase b b}} \
+ ]
+
+ te_dataset_ne_unordered $tn.28c [
+ te_read_sql db "SELECT * FROM (t3 NATURAL LEFT JOIN t2) NATURAL JOIN t1"
+ ] [
+ te_read_sql db "SELECT * FROM t3 NATURAL LEFT JOIN (t2 NATURAL JOIN t1)"
+ ]
+
+ set t2_natural_join_t1 [te_tbljoin db t2 t1 -using {a b} \
+ -using {a b} -on {te_and {te_equals a a} {te_equals -nocase b b}} \
+ ]
+ set t3 [te_read_tbl db t3]
+ te_dataset_eq_unordered $tn.28d [
+ te_read_sql db "SELECT * FROM t3 NATURAL LEFT JOIN (t2 NATURAL JOIN t1)"
+ ] [te_join $t3 $t2_natural_join_t1 \
+ -left -using {b} -on {te_equals -nocase b b} \
+ ]
+}
+
+do_execsql_test e_select-2.2.0 {
+ CREATE TABLE t4(x TEXT COLLATE nocase);
+ CREATE TABLE t5(y INTEGER, z TEXT COLLATE binary);
+
+ INSERT INTO t4 VALUES('2.0');
+ INSERT INTO t4 VALUES('TWO');
+ INSERT INTO t5 VALUES(2, 'two');
+} {}
+
+# EVIDENCE-OF: R-55824-40976 A sub-select specified in the join-source
+# following the FROM clause in a simple SELECT statement is handled as
+# if it was a table containing the data returned by executing the
+# sub-select statement.
+#
+# EVIDENCE-OF: R-42612-06757 Each column of the sub-select dataset
+# inherits the collation sequence and affinity of the corresponding
+# expression in the sub-select statement.
+#
+foreach {tn subselect select spec} {
+ 1 "SELECT * FROM t2" "SELECT * FROM t1 JOIN %ss%"
+ {t1 %ss%}
+
+ 2 "SELECT * FROM t2" "SELECT * FROM t1 JOIN %ss% AS x ON (t1.a=x.a)"
+ {t1 %ss% -on {te_equals 0 0}}
+
+ 3 "SELECT * FROM t2" "SELECT * FROM %ss% AS x JOIN t1 ON (t1.a=x.a)"
+ {%ss% t1 -on {te_equals 0 0}}
+
+ 4 "SELECT * FROM t1, t2" "SELECT * FROM %ss% AS x JOIN t3"
+ {%ss% t3}
+
+ 5 "SELECT * FROM t1, t2" "SELECT * FROM %ss% NATURAL JOIN t3"
+ {%ss% t3 -using b -on {te_equals 1 0}}
+
+ 6 "SELECT * FROM t1, t2" "SELECT * FROM t3 NATURAL JOIN %ss%"
+ {t3 %ss% -using b -on {te_equals -nocase 0 1}}
+
+ 7 "SELECT * FROM t1, t2" "SELECT * FROM t3 NATURAL LEFT JOIN %ss%"
+ {t3 %ss% -left -using b -on {te_equals -nocase 0 1}}
+
+ 8 "SELECT count(*) AS y FROM t4" "SELECT * FROM t5, %ss% USING (y)"
+ {t5 %ss% -using y -on {te_equals -affinity text 0 0}}
+
+ 9 "SELECT count(*) AS y FROM t4" "SELECT * FROM %ss%, t5 USING (y)"
+ {%ss% t5 -using y -on {te_equals -affinity text 0 0}}
+
+ 10 "SELECT x AS y FROM t4" "SELECT * FROM %ss% JOIN t5 USING (y)"
+ {%ss% t5 -using y -on {te_equals -nocase -affinity integer 0 0}}
+
+ 11 "SELECT x AS y FROM t4" "SELECT * FROM t5 JOIN %ss% USING (y)"
+ {t5 %ss% -using y -on {te_equals -nocase -affinity integer 0 0}}
+
+ 12 "SELECT y AS x FROM t5" "SELECT * FROM %ss% JOIN t4 USING (x)"
+ {%ss% t4 -using x -on {te_equals -nocase -affinity integer 0 0}}
+
+ 13 "SELECT y AS x FROM t5" "SELECT * FROM t4 JOIN %ss% USING (x)"
+ {t4 %ss% -using x -on {te_equals -nocase -affinity integer 0 0}}
+
+ 14 "SELECT +y AS x FROM t5" "SELECT * FROM %ss% JOIN t4 USING (x)"
+ {%ss% t4 -using x -on {te_equals -nocase -affinity text 0 0}}
+
+ 15 "SELECT +y AS x FROM t5" "SELECT * FROM t4 JOIN %ss% USING (x)"
+ {t4 %ss% -using x -on {te_equals -nocase -affinity text 0 0}}
+} {
+
+ # Create a temporary table named %ss% containing the data returned by
+ # the sub-select. Then have the [te_tbljoin] proc use this table to
+ # compute the expected results of the $select query. Drop the temporary
+ # table before continuing.
+ #
+ execsql "CREATE TEMP TABLE '%ss%' AS $subselect"
+ set te [eval te_tbljoin db $spec]
+ execsql "DROP TABLE '%ss%'"
+
+ # Check that the actual data returned by the $select query is the same
+ # as the expected data calculated using [te_tbljoin] above.
+ #
+ te_dataset_eq_unordered e_select-2.2.1.$tn [
+ te_read_sql db [string map [list %ss% "($subselect)"] $select]
+ ] $te
+}
+
+finish_test
diff --git a/test/e_update.test b/test/e_update.test
new file mode 100644
index 0000000..c14b845
--- /dev/null
+++ b/test/e_update.test
@@ -0,0 +1,607 @@
+# 2010 September 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_update.html document are correct.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+#--------------------
+# Test organization:
+#
+# e_update-1.*: Test statements describing the workings of UPDATE statements.
+#
+# e_update-2.*: Test the restrictions on the UPDATE statement syntax that
+# can be used within triggers.
+#
+# e_update-3.*: Test the special LIMIT/OFFSET and ORDER BY clauses that can
+# be used with UPDATE when SQLite is compiled with
+# SQLITE_ENABLE_UPDATE_DELETE_LIMIT.
+#
+
+forcedelete test.db2
+
+do_execsql_test e_update-0.0 {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b, c);
+ CREATE TABLE t3(a, b UNIQUE);
+ CREATE TABLE t6(x, y);
+ CREATE INDEX i1 ON t1(a);
+
+ CREATE TEMP TABLE t4(x, y);
+ CREATE TEMP TABLE t6(x, y);
+
+ CREATE TABLE aux.t1(a, b);
+ CREATE TABLE aux.t5(a, b);
+} {}
+
+proc do_update_tests {args} {
+ uplevel do_select_tests $args
+}
+
+# EVIDENCE-OF: R-05685-44205 -- syntax diagram update-stmt
+#
+do_update_tests e_update-0 {
+ 1 "UPDATE t1 SET a=10" {}
+ 2 "UPDATE t1 SET a=10, b=5" {}
+ 3 "UPDATE t1 SET a=10 WHERE b=5" {}
+ 4 "UPDATE t1 SET b=5,a=10 WHERE 1" {}
+ 5 "UPDATE main.t1 SET a=10" {}
+ 6 "UPDATE main.t1 SET a=10, b=5" {}
+ 7 "UPDATE main.t1 SET a=10 WHERE b=5" {}
+ 9 "UPDATE OR ROLLBACK t1 SET a=10" {}
+ 10 "UPDATE OR ROLLBACK t1 SET a=10, b=5" {}
+ 11 "UPDATE OR ROLLBACK t1 SET a=10 WHERE b=5" {}
+ 12 "UPDATE OR ROLLBACK t1 SET b=5,a=10 WHERE 1" {}
+ 13 "UPDATE OR ROLLBACK main.t1 SET a=10" {}
+ 14 "UPDATE OR ROLLBACK main.t1 SET a=10, b=5" {}
+ 15 "UPDATE OR ROLLBACK main.t1 SET a=10 WHERE b=5" {}
+ 16 "UPDATE OR ROLLBACK main.t1 SET b=5,a=10 WHERE 1" {}
+ 17 "UPDATE OR ABORT t1 SET a=10" {}
+ 18 "UPDATE OR ABORT t1 SET a=10, b=5" {}
+ 19 "UPDATE OR ABORT t1 SET a=10 WHERE b=5" {}
+ 20 "UPDATE OR ABORT t1 SET b=5,a=10 WHERE 1" {}
+ 21 "UPDATE OR ABORT main.t1 SET a=10" {}
+ 22 "UPDATE OR ABORT main.t1 SET a=10, b=5" {}
+ 23 "UPDATE OR ABORT main.t1 SET a=10 WHERE b=5" {}
+ 24 "UPDATE OR ABORT main.t1 SET b=5,a=10 WHERE 1" {}
+ 25 "UPDATE OR REPLACE t1 SET a=10" {}
+ 26 "UPDATE OR REPLACE t1 SET a=10, b=5" {}
+ 27 "UPDATE OR REPLACE t1 SET a=10 WHERE b=5" {}
+ 28 "UPDATE OR REPLACE t1 SET b=5,a=10 WHERE 1" {}
+ 29 "UPDATE OR REPLACE main.t1 SET a=10" {}
+ 30 "UPDATE OR REPLACE main.t1 SET a=10, b=5" {}
+ 31 "UPDATE OR REPLACE main.t1 SET a=10 WHERE b=5" {}
+ 32 "UPDATE OR REPLACE main.t1 SET b=5,a=10 WHERE 1" {}
+ 33 "UPDATE OR FAIL t1 SET a=10" {}
+ 34 "UPDATE OR FAIL t1 SET a=10, b=5" {}
+ 35 "UPDATE OR FAIL t1 SET a=10 WHERE b=5" {}
+ 36 "UPDATE OR FAIL t1 SET b=5,a=10 WHERE 1" {}
+ 37 "UPDATE OR FAIL main.t1 SET a=10" {}
+ 38 "UPDATE OR FAIL main.t1 SET a=10, b=5" {}
+ 39 "UPDATE OR FAIL main.t1 SET a=10 WHERE b=5" {}
+ 40 "UPDATE OR FAIL main.t1 SET b=5,a=10 WHERE 1" {}
+ 41 "UPDATE OR IGNORE t1 SET a=10" {}
+ 42 "UPDATE OR IGNORE t1 SET a=10, b=5" {}
+ 43 "UPDATE OR IGNORE t1 SET a=10 WHERE b=5" {}
+ 44 "UPDATE OR IGNORE t1 SET b=5,a=10 WHERE 1" {}
+ 45 "UPDATE OR IGNORE main.t1 SET a=10" {}
+ 46 "UPDATE OR IGNORE main.t1 SET a=10, b=5" {}
+ 47 "UPDATE OR IGNORE main.t1 SET a=10 WHERE b=5" {}
+ 48 "UPDATE OR IGNORE main.t1 SET b=5,a=10 WHERE 1" {}
+}
+
+# EVIDENCE-OF: R-38515-45264 An UPDATE statement is used to modify a
+# subset of the values stored in zero or more rows of the database table
+# identified by the qualified-table-name specified as part of the UPDATE
+# statement.
+#
+# Test cases e_update-1.1.1.* test the "identified by the
+# qualified-table-name" part of the statement above. Tests
+# e_update-1.1.2.* show that the "zero or more rows" part is
+# accurate.
+#
+do_execsql_test e_update-1.1.0 {
+ INSERT INTO main.t1 VALUES(1, 'i');
+ INSERT INTO main.t1 VALUES(2, 'ii');
+ INSERT INTO main.t1 VALUES(3, 'iii');
+
+ INSERT INTO aux.t1 VALUES(1, 'I');
+ INSERT INTO aux.t1 VALUES(2, 'II');
+ INSERT INTO aux.t1 VALUES(3, 'III');
+} {}
+do_update_tests e_update-1.1 {
+ 1.1 "UPDATE t1 SET a = a+1; SELECT * FROM t1" {2 i 3 ii 4 iii}
+ 1.2 "UPDATE main.t1 SET a = a+1; SELECT * FROM main.t1" {3 i 4 ii 5 iii}
+ 1.3 "UPDATE aux.t1 SET a = a+1; SELECT * FROM aux.t1" {2 I 3 II 4 III}
+
+ 2.1 "UPDATE t1 SET a = a+1 WHERE a = 1; SELECT * FROM t1" {3 i 4 ii 5 iii}
+ 2.2 "UPDATE t1 SET a = a+1 WHERE a = 4; SELECT * FROM t1" {3 i 5 ii 5 iii}
+}
+
+# EVIDENCE-OF: R-55869-30521 If the UPDATE statement does not have a
+# WHERE clause, all rows in the table are modified by the UPDATE.
+#
+do_execsql_test e_update-1.2.0 {
+ DELETE FROM main.t1;
+ INSERT INTO main.t1 VALUES(1, 'i');
+ INSERT INTO main.t1 VALUES(2, 'ii');
+ INSERT INTO main.t1 VALUES(3, 'iii');
+} {}
+do_update_tests e_update-1.2 {
+ 1 "UPDATE t1 SET b = 'roman' ; SELECT * FROM t1"
+ {1 roman 2 roman 3 roman}
+
+ 2 "UPDATE t1 SET a = 'greek' ; SELECT * FROM t1"
+ {greek roman greek roman greek roman}
+}
+
+# EVIDENCE-OF: R-42117-40023 Otherwise, the UPDATE affects only those
+# rows for which the result of evaluating the WHERE clause expression as
+# a boolean expression is true.
+#
+do_execsql_test e_update-1.3.0 {
+ DELETE FROM main.t1;
+ INSERT INTO main.t1 VALUES(NULL, '');
+ INSERT INTO main.t1 VALUES(1, 'i');
+ INSERT INTO main.t1 VALUES(2, 'ii');
+ INSERT INTO main.t1 VALUES(3, 'iii');
+} {}
+do_update_tests e_update-1.3 {
+ 1 "UPDATE t1 SET b = 'roman' WHERE a<2 ; SELECT * FROM t1"
+ {{} {} 1 roman 2 ii 3 iii}
+
+ 2 "UPDATE t1 SET b = 'egyptian' WHERE (a-3)/10.0 ; SELECT * FROM t1"
+ {{} {} 1 egyptian 2 egyptian 3 iii}
+
+ 3 "UPDATE t1 SET b = 'macedonian' WHERE a; SELECT * FROM t1"
+ {{} {} 1 macedonian 2 macedonian 3 macedonian}
+
+ 4 "UPDATE t1 SET b = 'lithuanian' WHERE a IS NULL; SELECT * FROM t1"
+ {{} lithuanian 1 macedonian 2 macedonian 3 macedonian}
+}
+
+# EVIDENCE-OF: R-58129-20729 It is not an error if the WHERE clause does
+# not evaluate to true for any row in the table - this just means that
+# the UPDATE statement affects zero rows.
+#
+do_execsql_test e_update-1.4.0 {
+ DELETE FROM main.t1;
+ INSERT INTO main.t1 VALUES(NULL, '');
+ INSERT INTO main.t1 VALUES(1, 'i');
+ INSERT INTO main.t1 VALUES(2, 'ii');
+ INSERT INTO main.t1 VALUES(3, 'iii');
+} {}
+do_update_tests e_update-1.4 -query {
+ SELECT * FROM t1
+} {
+ 1 "UPDATE t1 SET b = 'burmese' WHERE a=5" {{} {} 1 i 2 ii 3 iii}
+
+ 2 "UPDATE t1 SET b = 'burmese' WHERE length(b)<1 AND a IS NOT NULL"
+ {{} {} 1 i 2 ii 3 iii}
+
+ 3 "UPDATE t1 SET b = 'burmese' WHERE 0" {{} {} 1 i 2 ii 3 iii}
+
+ 4 "UPDATE t1 SET b = 'burmese' WHERE (SELECT a FROM t1 WHERE rowid=1)"
+ {{} {} 1 i 2 ii 3 iii}
+}
+
+# EVIDENCE-OF: R-40598-36595 For each affected row, the named columns
+# are set to the values found by evaluating the corresponding scalar
+# expressions.
+#
+# EVIDENCE-OF: R-40472-60438 Columns that do not appear in the list of
+# assignments are left unmodified.
+#
+do_execsql_test e_update-1.5.0 {
+ INSERT INTO t2(rowid, a, b, c) VALUES(1, 3, 1, 4);
+ INSERT INTO t2(rowid, a, b, c) VALUES(2, 1, 5, 9);
+ INSERT INTO t2(rowid, a, b, c) VALUES(3, 2, 6, 5);
+} {}
+do_update_tests e_update-1.5 -query {
+ SELECT * FROM t2
+} {
+ 1 "UPDATE t2 SET c = 1+1 WHERE a=2"
+ {3 1 4 1 5 9 2 6 2}
+
+ 2 "UPDATE t2 SET b = 4/2, c=CAST((0.4*5) AS INTEGER) WHERE a<3"
+ {3 1 4 1 2 2 2 2 2}
+
+ 3 "UPDATE t2 SET a = 1"
+ {1 1 4 1 2 2 1 2 2}
+
+ 4 "UPDATE t2 SET b = (SELECT count(*)+2 FROM t2), c = 24/3+1 WHERE rowid=2"
+ {1 1 4 1 5 9 1 2 2}
+
+ 5 "UPDATE t2 SET a = 3 WHERE c = 4"
+ {3 1 4 1 5 9 1 2 2}
+
+ 6 "UPDATE t2 SET a = b WHERE rowid>2"
+ {3 1 4 1 5 9 2 2 2}
+
+ 6 "UPDATE t2 SET b=6, c=5 WHERE a=b AND b=c"
+ {3 1 4 1 5 9 2 6 5}
+}
+
+# EVIDENCE-OF: R-34751-18293 If a single column-name appears more than
+# once in the list of assignment expressions, all but the rightmost
+# occurrence is ignored.
+#
+do_update_tests e_update-1.6 -query {
+ SELECT * FROM t2
+} {
+ 1 "UPDATE t2 SET c=5, c=6, c=7 WHERE rowid=1" {3 1 7 1 5 9 2 6 5}
+ 2 "UPDATE t2 SET c=7, c=6, c=5 WHERE rowid=1" {3 1 5 1 5 9 2 6 5}
+ 3 "UPDATE t2 SET c=5, b=6, c=7 WHERE rowid=1" {3 6 7 1 5 9 2 6 5}
+}
+
+# EVIDENCE-OF: R-36239-04077 The scalar expressions may refer to columns
+# of the row being updated.
+#
+# EVIDENCE-OF: R-04558-24451 In this case all scalar expressions are
+# evaluated before any assignments are made.
+#
+do_execsql_test e_update-1.7.0 {
+ DELETE FROM t2;
+ INSERT INTO t2(rowid, a, b, c) VALUES(1, 3, 1, 4);
+ INSERT INTO t2(rowid, a, b, c) VALUES(2, 1, 5, 9);
+ INSERT INTO t2(rowid, a, b, c) VALUES(3, 2, 6, 5);
+} {}
+do_update_tests e_update-1.7 -query {
+ SELECT * FROM t2
+} {
+ 1 "UPDATE t2 SET a=b+c" {5 1 4 14 5 9 11 6 5}
+ 2 "UPDATE t2 SET a=b, b=a" {1 5 4 5 14 9 6 11 5}
+ 3 "UPDATE t2 SET a=c||c, c=NULL" {44 5 {} 99 14 {} 55 11 {}}
+}
+
+# EVIDENCE-OF: R-12619-24112 The optional conflict-clause allows the
+# user to nominate a specific constraint conflict resolution algorithm
+# to use during this one UPDATE command.
+#
+do_execsql_test e_update-1.8.0 {
+ DELETE FROM t3;
+ INSERT INTO t3 VALUES(1, 'one');
+ INSERT INTO t3 VALUES(2, 'two');
+ INSERT INTO t3 VALUES(3, 'three');
+ INSERT INTO t3 VALUES(4, 'four');
+} {}
+foreach {tn sql error ac data } {
+ 1 "UPDATE t3 SET b='one' WHERE a=3"
+ {column b is not unique} 1 {1 one 2 two 3 three 4 four}
+
+ 2 "UPDATE OR REPLACE t3 SET b='one' WHERE a=3"
+ {} 1 {2 two 3 one 4 four}
+
+ 3 "UPDATE OR FAIL t3 SET b='three'"
+ {column b is not unique} 1 {2 three 3 one 4 four}
+
+ 4 "UPDATE OR IGNORE t3 SET b='three' WHERE a=3"
+ {} 1 {2 three 3 one 4 four}
+
+ 5 "UPDATE OR ABORT t3 SET b='three' WHERE a=3"
+ {column b is not unique} 1 {2 three 3 one 4 four}
+
+ 6 "BEGIN" {} 0 {2 three 3 one 4 four}
+
+ 7 "UPDATE t3 SET b='three' WHERE a=3"
+ {column b is not unique} 0 {2 three 3 one 4 four}
+
+ 8 "UPDATE OR ABORT t3 SET b='three' WHERE a=3"
+ {column b is not unique} 0 {2 three 3 one 4 four}
+
+ 9 "UPDATE OR FAIL t3 SET b='two'"
+ {column b is not unique} 0 {2 two 3 one 4 four}
+
+ 10 "UPDATE OR IGNORE t3 SET b='four' WHERE a=3"
+ {} 0 {2 two 3 one 4 four}
+
+ 11 "UPDATE OR REPLACE t3 SET b='four' WHERE a=3"
+ {} 0 {2 two 3 four}
+
+ 12 "UPDATE OR ROLLBACK t3 SET b='four'"
+ {column b is not unique} 1 {2 three 3 one 4 four}
+} {
+ do_catchsql_test e_update-1.8.$tn.1 $sql [list [expr {$error!=""}] $error]
+ do_execsql_test e_update-1.8.$tn.2 {SELECT * FROM t3} [list {*}$data]
+ do_test e_update-1.8.$tn.3 {sqlite3_get_autocommit db} $ac
+}
+
+
+
+# EVIDENCE-OF: R-12123-54095 The table-name specified as part of an
+# UPDATE statement within a trigger body must be unqualified.
+#
+# EVIDENCE-OF: R-09690-36749 In other words, the database-name. prefix
+# on the table name of the UPDATE is not allowed within triggers.
+#
+do_update_tests e_update-2.1 -error {
+ qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers
+} {
+ 1 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ UPDATE main.t2 SET a=1, b=2, c=3;
+ END;
+ } {}
+
+ 2 {
+ CREATE TRIGGER tr1 BEFORE UPDATE ON t2 BEGIN
+ UPDATE aux.t1 SET a=1, b=2;
+ END;
+ } {}
+
+ 3 {
+ CREATE TRIGGER tr1 AFTER DELETE ON t4 BEGIN
+ UPDATE main.t1 SET a=1, b=2;
+ END;
+ } {}
+}
+
+# EVIDENCE-OF: R-06085-13761 Unless the table to which the trigger is
+# attached is in the TEMP database, the table being updated by the
+# trigger program must reside in the same database as it.
+#
+do_update_tests e_update-2.2 -error {
+ no such table: %s
+} {
+ 1 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ UPDATE t4 SET x=x+1;
+ END;
+ INSERT INTO t1 VALUES(1, 2);
+ } "main.t4"
+
+ 2 {
+ CREATE TRIGGER aux.tr1 AFTER INSERT ON t5 BEGIN
+ UPDATE t4 SET x=x+1;
+ END;
+ INSERT INTO t5 VALUES(1, 2);
+ } "aux.t4"
+}
+do_execsql_test e_update-2.2.X {
+ DROP TRIGGER tr1;
+ DROP TRIGGER aux.tr1;
+} {}
+
+# EVIDENCE-OF: R-29512-54644 If the table to which the trigger is
+# attached is in the TEMP database, then the unqualified name of the
+# table being updated is resolved in the same way as it is for a
+# top-level statement (by searching first the TEMP database, then the
+# main database, then any other databases in the order they were
+# attached).
+#
+do_execsql_test e_update-2.3.0 {
+ SELECT 'main', tbl_name FROM main.sqlite_master WHERE type = 'table'
+ UNION ALL
+ SELECT 'temp', tbl_name FROM sqlite_temp_master WHERE type = 'table'
+ UNION ALL
+ SELECT 'aux', tbl_name FROM aux.sqlite_master WHERE type = 'table'
+} [list {*}{
+ main t1
+ main t2
+ main t3
+ main t6
+ temp t4
+ temp t6
+ aux t1
+ aux t5
+}]
+do_execsql_test e_update-2.3.1 {
+ DELETE FROM main.t6;
+ DELETE FROM temp.t6;
+ INSERT INTO main.t6 VALUES(1, 2);
+ INSERT INTO temp.t6 VALUES(1, 2);
+
+ CREATE TRIGGER temp.tr1 AFTER INSERT ON t4 BEGIN
+ UPDATE t6 SET x=x+1;
+ END;
+
+ INSERT INTO t4 VALUES(1, 2);
+ SELECT * FROM main.t6;
+ SELECT * FROM temp.t6;
+} {1 2 2 2}
+do_execsql_test e_update-2.3.2 {
+ DELETE FROM main.t1;
+ DELETE FROM aux.t1;
+ INSERT INTO main.t1 VALUES(1, 2);
+ INSERT INTO aux.t1 VALUES(1, 2);
+
+ CREATE TRIGGER temp.tr2 AFTER DELETE ON t4 BEGIN
+ UPDATE t1 SET a=a+1;
+ END;
+
+ DELETE FROM t4;
+ SELECT * FROM main.t1;
+ SELECT * FROM aux.t1;
+} {2 2 1 2}
+do_execsql_test e_update-2.3.3 {
+ DELETE FROM aux.t5;
+ INSERT INTO aux.t5 VALUES(1, 2);
+
+ INSERT INTO t4 VALUES('x', 'y');
+ CREATE TRIGGER temp.tr3 AFTER UPDATE ON t4 BEGIN
+ UPDATE t5 SET a=a+1;
+ END;
+
+ UPDATE t4 SET x=10;
+ SELECT * FROM aux.t5;
+} {2 2}
+
+# EVIDENCE-OF: R-19619-42762 The INDEXED BY and NOT INDEXED clauses are
+# not allowed on UPDATE statements within triggers.
+#
+do_update_tests e_update-2.4 -error {
+ the %s %s clause is not allowed on UPDATE or DELETE statements within triggers
+} {
+ 1 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN
+ UPDATE t1 INDEXED BY i1 SET a=a+1;
+ END;
+ } {INDEXED BY}
+
+ 2 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN
+ UPDATE t1 NOT INDEXED SET a=a+1;
+ END;
+ } {NOT INDEXED}
+}
+
+ifcapable update_delete_limit {
+
+# EVIDENCE-OF: R-57359-59558 The LIMIT and ORDER BY clauses for UPDATE
+# are unsupported within triggers, regardless of the compilation options
+# used to build SQLite.
+#
+do_update_tests e_update-2.5 -error {
+ near "%s": syntax error
+} {
+ 1 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN
+ UPDATE t1 SET a=a+1 LIMIT 10;
+ END;
+ } {LIMIT}
+
+ 2 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN
+ UPDATE t1 SET a=a+1 ORDER BY a LIMIT 10;
+ END;
+ } {ORDER}
+
+ 3 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN
+ UPDATE t1 SET a=a+1 ORDER BY a LIMIT 10 OFFSET 2;
+ END;
+ } {ORDER}
+
+ 4 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN
+ UPDATE t1 SET a=a+1 LIMIT 10 OFFSET 2;
+ END;
+ } {LIMIT}
+}
+
+# EVIDENCE-OF: R-59581-44104 If SQLite is built with the
+# SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option then the syntax
+# of the UPDATE statement is extended with optional ORDER BY and LIMIT
+# clauses
+#
+# EVIDENCE-OF: R-08948-01887 -- syntax diagram update-stmt-limited
+#
+do_update_tests e_update-3.0 {
+ 1 "UPDATE t1 SET a=b LIMIT 5" {}
+ 2 "UPDATE t1 SET a=b LIMIT 5-1 OFFSET 2+2" {}
+ 3 "UPDATE t1 SET a=b LIMIT 2+2, 16/4" {}
+ 4 "UPDATE t1 SET a=b ORDER BY a LIMIT 5" {}
+ 5 "UPDATE t1 SET a=b ORDER BY a LIMIT 5-1 OFFSET 2+2" {}
+ 6 "UPDATE t1 SET a=b ORDER BY a LIMIT 2+2, 16/4" {}
+ 7 "UPDATE t1 SET a=b WHERE a>2 LIMIT 5" {}
+ 8 "UPDATE t1 SET a=b WHERE a>2 LIMIT 5-1 OFFSET 2+2" {}
+ 9 "UPDATE t1 SET a=b WHERE a>2 LIMIT 2+2, 16/4" {}
+ 10 "UPDATE t1 SET a=b WHERE a>2 ORDER BY a LIMIT 5" {}
+ 11 "UPDATE t1 SET a=b WHERE a>2 ORDER BY a LIMIT 5-1 OFFSET 2+2" {}
+ 12 "UPDATE t1 SET a=b WHERE a>2 ORDER BY a LIMIT 2+2, 16/4" {}
+}
+
+do_execsql_test e_update-3.1.0 {
+ CREATE TABLE t7(q, r, s);
+ INSERT INTO t7 VALUES(1, 'one', 'X');
+ INSERT INTO t7 VALUES(2, 'two', 'X');
+ INSERT INTO t7 VALUES(3, 'three', 'X');
+ INSERT INTO t7 VALUES(4, 'four', 'X');
+ INSERT INTO t7 VALUES(5, 'five', 'X');
+ INSERT INTO t7 VALUES(6, 'six', 'X');
+ INSERT INTO t7 VALUES(7, 'seven', 'X');
+ INSERT INTO t7 VALUES(8, 'eight', 'X');
+ INSERT INTO t7 VALUES(9, 'nine', 'X');
+ INSERT INTO t7 VALUES(10, 'ten', 'X');
+} {}
+
+# EVIDENCE-OF: R-58862-44169 If an UPDATE statement has a LIMIT clause,
+# the maximum number of rows that will be updated is found by evaluating
+# the accompanying expression and casting it to an integer value.
+#
+do_update_tests e_update-3.1 -query { SELECT s FROM t7 } {
+ 1 "UPDATE t7 SET s = q LIMIT 5" {1 2 3 4 5 X X X X X}
+ 2 "UPDATE t7 SET s = r WHERE q>2 LIMIT 4" {1 2 three four five six X X X X}
+ 3 "UPDATE t7 SET s = q LIMIT 0" {1 2 three four five six X X X X}
+}
+
+# EVIDENCE-OF: R-63582-45120 A negative value is interpreted as "no limit".
+#
+do_update_tests e_update-3.2 -query { SELECT s FROM t7 } {
+ 1 "UPDATE t7 SET s = q LIMIT -1" {1 2 3 4 5 6 7 8 9 10}
+ 2 "UPDATE t7 SET s = r WHERE q>4 LIMIT -1"
+ {1 2 3 4 five six seven eight nine ten}
+ 3 "UPDATE t7 SET s = 'X' LIMIT -1" {X X X X X X X X X X}
+}
+
+# EVIDENCE-OF: R-18628-11938 If the LIMIT expression evaluates to
+# non-negative value N and the UPDATE statement has an ORDER BY clause,
+# then all rows that would be updated in the absence of the LIMIT clause
+# are sorted according to the ORDER BY and the first N updated.
+#
+do_update_tests e_update-3.3 -query { SELECT s FROM t7 } {
+ 1 "UPDATE t7 SET s = q ORDER BY r LIMIT 3" {X X X 4 5 X X 8 X X}
+ 2 "UPDATE t7 SET s = r ORDER BY r DESC LIMIT 2" {X two three 4 5 X X 8 X X}
+ 3 "UPDATE t7 SET s = q ORDER BY q DESC LIMIT 5" {X two three 4 5 6 7 8 9 10}
+
+ X "UPDATE t7 SET s = 'X'" {X X X X X X X X X X}
+}
+
+# EVIDENCE-OF: R-30955-38324 If the UPDATE statement also has an OFFSET
+# clause, then it is similarly evaluated and cast to an integer value.
+# If the OFFSET expression evaluates to a non-negative value M, then the
+# first M rows are skipped and the following N rows updated instead.
+#
+do_update_tests e_update-3.3 -query { SELECT s FROM t7 } {
+ 1 "UPDATE t7 SET s = q ORDER BY q LIMIT 3 OFFSET 2" {X X 3 4 5 X X X X X}
+ 2 "UPDATE t7 SET s = q ORDER BY q DESC LIMIT 2, 3 " {X X 3 4 5 6 7 8 X X}
+
+ X "UPDATE t7 SET s = 'X'" {X X X X X X X X X X}
+}
+
+# EVIDENCE-OF: R-19486-35828 If the UPDATE statement has no ORDER BY
+# clause, then all rows that would be updated in the absence of the
+# LIMIT clause are assembled in an arbitrary order before applying the
+# LIMIT and OFFSET clauses to determine which are actually updated.
+#
+# In practice, "arbitrary order" is rowid order. This is also tested
+# by e_update-3.2.* above.
+#
+do_update_tests e_update-3.4 -query { SELECT s FROM t7 } {
+ 1 "UPDATE t7 SET s = q LIMIT 4, 2" {X X X X 5 6 X X X X}
+ 2 "UPDATE t7 SET s = q LIMIT 2 OFFSET 7" {X X X X 5 6 X 8 9 X}
+}
+
+# EVIDENCE-OF: R-10927-26133 The ORDER BY clause on an UPDATE statement
+# is used only to determine which rows fall within the LIMIT. The order
+# in which rows are modified is arbitrary and is not influenced by the
+# ORDER BY clause.
+#
+do_execsql_test e_update-3.5.0 {
+ CREATE TABLE t8(x);
+ CREATE TRIGGER tr7 BEFORE UPDATE ON t7 BEGIN
+ INSERT INTO t8 VALUES(old.q);
+ END;
+} {}
+do_update_tests e_update-3.5 -query { SELECT x FROM t8 ; DELETE FROM t8 } {
+ 1 "UPDATE t7 SET s = q ORDER BY r LIMIT -1" {1 2 3 4 5 6 7 8 9 10}
+ 2 "UPDATE t7 SET s = q ORDER BY r ASC LIMIT -1" {1 2 3 4 5 6 7 8 9 10}
+ 3 "UPDATE t7 SET s = q ORDER BY r DESC LIMIT -1" {1 2 3 4 5 6 7 8 9 10}
+ 4 "UPDATE t7 SET s = q ORDER BY q DESC LIMIT 5" {6 7 8 9 10}
+}
+
+
+} ;# ifcapable update_delete_limit
+
+finish_test
diff --git a/test/e_uri.test b/test/e_uri.test
new file mode 100644
index 0000000..5275ec1
--- /dev/null
+++ b/test/e_uri.test
@@ -0,0 +1,456 @@
+# 2011 May 06
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix e_uri
+
+db close
+
+proc parse_uri {uri} {
+ testvfs tvfs2
+ testvfs tvfs
+ tvfs filter xOpen
+ tvfs script parse_uri_open_cb
+
+ set ::uri_open [list]
+ set DB [sqlite3_open_v2 $uri {
+ SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_WAL
+ } tvfs]
+ sqlite3_close $DB
+ tvfs delete
+ tvfs2 delete
+
+ set ::uri_open
+}
+proc parse_uri_open_cb {method file arglist} {
+ set ::uri_open [list $file $arglist]
+}
+
+proc open_uri_error {uri} {
+ set flags {SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_WAL}
+ set DB [sqlite3_open_v2 $uri $flags ""]
+ set e [sqlite3_errmsg $DB]
+ sqlite3_close $DB
+ set e
+}
+
+# EVIDENCE-OF: R-35840-33204 If URI filename interpretation is enabled,
+# and the filename argument begins with "file:", then the filename is
+# interpreted as a URI.
+#
+# EVIDENCE-OF: R-24124-56960 URI filename interpretation is enabled if
+# the SQLITE_OPEN_URI flag is set in the fourth argument to
+# sqlite3_open_v2(), or if it has been enabled globally using the
+# SQLITE_CONFIG_URI option with the sqlite3_config() method or by the
+# SQLITE_USE_URI compile-time option.
+#
+if {$tcl_platform(platform) == "unix"} {
+ set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE]
+
+ # Tests with SQLITE_CONFIG_URI configured to false. URI intepretation is
+ # only enabled if the SQLITE_OPEN_URI flag is specified.
+ sqlite3_shutdown
+ sqlite3_config_uri 0
+ do_test 1.1 {
+ forcedelete file:test.db test.db
+ set DB [sqlite3_open_v2 file:test.db [concat $flags SQLITE_OPEN_URI] ""]
+ list [file exists file:test.db] [file exists test.db]
+ } {0 1}
+ do_test 1.2 {
+ forcedelete file:test.db2 test.db2
+ set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ list [file exists file:test.db2] [file exists test.db2]
+ } {0 1}
+ sqlite3_close $DB
+ do_test 1.3 {
+ forcedelete file:test.db test.db
+ set DB [sqlite3_open_v2 file:test.db [concat $flags] ""]
+ list [file exists file:test.db] [file exists test.db]
+ } {1 0}
+ do_test 1.4 {
+ forcedelete file:test.db2 test.db2
+ set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ list [file exists file:test.db2] [file exists test.db2]
+ } {1 0}
+ sqlite3_close $DB
+
+ # Tests with SQLITE_CONFIG_URI configured to true. URI intepretation is
+ # enabled with or without SQLITE_OPEN_URI.
+ #
+ sqlite3_shutdown
+ sqlite3_config_uri 1
+ do_test 1.5 {
+ forcedelete file:test.db test.db
+ set DB [sqlite3_open_v2 file:test.db [concat $flags SQLITE_OPEN_URI] ""]
+ list [file exists file:test.db] [file exists test.db]
+ } {0 1}
+ do_test 1.6 {
+ forcedelete file:test.db2 test.db2
+ set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ list [file exists file:test.db2] [file exists test.db2]
+ } {0 1}
+ sqlite3_close $DB
+ do_test 1.7 {
+ forcedelete file:test.db test.db
+ set DB [sqlite3_open_v2 file:test.db [concat $flags] ""]
+ list [file exists file:test.db] [file exists test.db]
+ } {0 1}
+ do_test 1.8 {
+ forcedelete file:test.db2 test.db2
+ set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ list [file exists file:test.db2] [file exists test.db2]
+ } {0 1}
+ sqlite3_close $DB
+}
+
+# ensure uri processing enabled for the rest of the tests
+sqlite3_shutdown
+sqlite3_config_uri 1
+
+# EVIDENCE-OF: R-17482-00398 If the authority is not an empty string or
+# "localhost", an error is returned to the caller.
+#
+if {$tcl_platform(platform) == "unix"} {
+ set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]
+ foreach {tn uri error} "
+ 1 {file://localhost[pwd]/test.db} {not an error}
+ 2 {file://[pwd]/test.db} {not an error}
+ 3 {file://x[pwd]/test.db} {invalid uri authority: x}
+ 4 {file://invalid[pwd]/test.db} {invalid uri authority: invalid}
+ " {
+ do_test 2.$tn {
+ set DB [sqlite3_open_v2 $uri $flags ""]
+ set e [sqlite3_errmsg $DB]
+ sqlite3_close $DB
+ set e
+ } $error
+ }
+}
+
+# EVIDENCE-OF: R-45981-25528 The fragment component of a URI, if
+# present, is ignored.
+#
+# It is difficult to test that something is ignored correctly. So these tests
+# just show that adding a fragment does not interfere with the pathname or
+# parameters passed through to the VFS xOpen() methods.
+#
+foreach {tn uri parse} "
+ 1 {file:test.db#abc} {[pwd]/test.db {}}
+ 2 {file:test.db?a=b#abc} {[pwd]/test.db {a b}}
+ 3 {file:test.db?a=b#?c=d} {[pwd]/test.db {a b}}
+" {
+ do_filepath_test 3.$tn { parse_uri $uri } $parse
+}
+
+# EVIDENCE-OF: R-62557-09390 SQLite uses the path component of the URI
+# as the name of the disk file which contains the database.
+#
+# EVIDENCE-OF: R-28659-11035 If the path begins with a '/' character,
+# then it is interpreted as an absolute path.
+#
+# EVIDENCE-OF: R-46234-61323 If the path does not begin with a '/'
+# (meaning that the authority section is omitted from the URI) then the
+# path is interpreted as a relative path.
+#
+foreach {tn uri parse} "
+ 1 {file:test.db} {[pwd]/test.db {}}
+ 2 {file:/test.db} {/test.db {}}
+ 3 {file:///test.db} {/test.db {}}
+ 4 {file://localhost/test.db} {/test.db {}}
+ 5 {file:/a/b/c/test.db} {/a/b/c/test.db {}}
+" {
+ do_filepath_test 4.$tn { parse_uri $uri } $parse
+}
+
+# EVIDENCE-OF: R-01612-30877 The "vfs" parameter may be used to specify
+# the name of a VFS object that provides the operating system interface
+# that should be used to access the database file on disk.
+#
+# The above is tested by cases 1.* below.
+#
+# EVIDENCE-OF: R-52293-58497 If this option is set to an empty string
+# the default VFS object is used.
+#
+# The above is tested by cases 2.* below.
+#
+# EVIDENCE-OF: R-31855-18665 If sqlite3_open_v2() is used and the vfs
+# option is present, then the VFS specified by the option takes
+# precedence over the value passed as the fourth parameter to
+# sqlite3_open_v2().
+#
+# The above is tested by cases 3.* below.
+#
+proc vfs_open_cb {name args} {
+ set ::vfs $name
+}
+foreach {name default} {vfs1 0 vfs2 0 vfs3 1} {
+ testvfs $name -default $default
+ $name filter xOpen
+ $name script [list vfs_open_cb $name]
+}
+foreach {tn uri defvfs vfs} {
+ 1.1 "file:test.db?vfs=vfs1" "" vfs1
+ 1.2 "file:test.db?vfs=vfs2" "" vfs2
+
+ 2.1 "file:test.db" vfs1 vfs1
+ 2.2 "file:test.db?vfs=" vfs1 vfs3
+
+ 3.1 "file:test.db?vfs=vfs1" vfs2 vfs1
+ 3.2 "file:test.db?vfs=vfs2" vfs1 vfs2
+ 3.3 "file:test.db?xvfs=vfs1" vfs2 vfs2
+ 3.4 "file:test.db?xvfs=vfs2" vfs1 vfs1
+} {
+ do_test 5.$tn {
+ set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]
+ sqlite3_close [
+ sqlite3_open_v2 $uri $flags $defvfs
+ ]
+ set ::vfs
+ } $vfs
+}
+vfs1 delete
+vfs2 delete
+vfs3 delete
+
+# EVIDENCE-OF: R-48365-36308 Specifying an unknown VFS is an error.
+#
+set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]
+do_test 6.1 {
+ set DB [sqlite3_open_v2 file:test.db?vfs=nosuchvfs $flags ""]
+ set errmsg [sqlite3_errmsg $DB]
+ sqlite3_close $DB
+ set errmsg
+} {no such vfs: nosuchvfs}
+
+
+# EVIDENCE-OF: R-60479-64270 The mode parameter may be set to either
+# "ro", "rw" or "rwc". Attempting to set it to any other value is an
+# error
+#
+sqlite3 db test.db
+db close
+foreach {tn uri error} "
+ 1 {file:test.db?mode=ro} {not an error}
+ 2 {file:test.db?mode=rw} {not an error}
+ 3 {file:test.db?mode=rwc} {not an error}
+ 4 {file:test.db?mode=Ro} {no such access mode: Ro}
+ 5 {file:test.db?mode=Rw} {no such access mode: Rw}
+ 6 {file:test.db?mode=Rwc} {no such access mode: Rwc}
+" {
+ do_test 7.$tn { open_uri_error $uri } $error
+}
+
+
+# EVIDENCE-OF: R-09651-31805 If "ro" is specified, then the database is
+# opened for read-only access, just as if the SQLITE_OPEN_READONLY flag
+# had been set in the third argument to sqlite3_prepare_v2().
+#
+# EVIDENCE-OF: R-40137-26050 If the mode option is set to "rw", then the
+# database is opened for read-write (but not create) access, as if
+# SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had been set.
+#
+# EVIDENCE-OF: R-26845-32976 Value "rwc" is equivalent to setting both
+# SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.
+#
+foreach {tn uri read write create} {
+ 1 {file:test.db?mode=ro} 1 0 0
+ 2 {file:test.db?mode=rw} 1 1 0
+ 3 {file:test.db?mode=rwc} 1 1 1
+} {
+ set RES(c,0) {1 {unable to open database file}}
+ set RES(c,1) {0 {}}
+ set RES(w,0) {1 {attempt to write a readonly database}}
+ set RES(w,1) {0 {}}
+ set RES(r,0) {1 {this never happens}}
+ set RES(r,1) {0 {a b}}
+
+ # Test CREATE access:
+ forcedelete test.db
+ do_test 8.$tn.c { list [catch { sqlite3 db $uri } msg] $msg } $RES(c,$create)
+ catch { db close }
+
+ sqlite3 db test.db
+ db eval { CREATE TABLE t1(a, b) ; INSERT INTO t1 VALUES('a', 'b') ;}
+ db close
+
+ # Test READ access:
+ do_test 8.$tn.r {
+ sqlite3 db $uri
+ catchsql { SELECT * FROM t1 }
+ } $RES(r,$read)
+
+ # Test WRITE access:
+ do_test 8.$tn.w {
+ sqlite3 db $uri
+ catchsql { INSERT INTO t1 VALUES(1, 2) }
+ } $RES(w,$write)
+
+ catch {db close}
+}
+
+# EVIDENCE-OF: R-56032-32287 If sqlite3_open_v2() is used, it is an
+# error to specify a value for the mode parameter that is less
+# restrictive than that specified by the flags passed as the third
+# parameter.
+#
+forcedelete test.db
+sqlite3 db test.db
+db close
+foreach {tn uri flags error} {
+ 1 {file:test.db?mode=ro} ro {not an error}
+ 2 {file:test.db?mode=ro} rw {not an error}
+ 3 {file:test.db?mode=ro} rwc {not an error}
+
+ 4 {file:test.db?mode=rw} ro {access mode not allowed: rw}
+ 5 {file:test.db?mode=rw} rw {not an error}
+ 6 {file:test.db?mode=rw} rwc {not an error}
+
+ 7 {file:test.db?mode=rwc} ro {access mode not allowed: rwc}
+ 8 {file:test.db?mode=rwc} rw {access mode not allowed: rwc}
+ 9 {file:test.db?mode=rwc} rwc {not an error}
+} {
+ set f(ro) [list SQLITE_OPEN_READONLY SQLITE_OPEN_URI]
+ set f(rw) [list SQLITE_OPEN_READWRITE SQLITE_OPEN_URI]
+ set f(rwc) [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]
+
+ set DB [sqlite3_open_v2 $uri $f($flags) ""]
+ set e [sqlite3_errmsg $DB]
+ sqlite3_close $DB
+
+ do_test 9.$tn { set e } $error
+}
+
+# EVIDENCE-OF: R-23182-54295 The cache parameter may be set to either
+# "shared" or "private".
+sqlite3 db test.db
+db close
+foreach {tn uri error} "
+ 1 {file:test.db?cache=private} {not an error}
+ 2 {file:test.db?cache=shared} {not an error}
+ 3 {file:test.db?cache=yes} {no such cache mode: yes}
+ 4 {file:test.db?cache=} {no such cache mode: }
+" {
+ do_test 10.$tn { open_uri_error $uri } $error
+}
+
+# EVIDENCE-OF: R-23027-03515 Setting it to "shared" is equivalent to
+# setting the SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed
+# to sqlite3_open_v2().
+#
+# EVIDENCE-OF: R-49793-28525 Setting the cache parameter to "private" is
+# equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.
+#
+# EVIDENCE-OF: R-19510-48080 If sqlite3_open_v2() is used and the
+# "cache" parameter is present in a URI filename, its value overrides
+# any behaviour requested by setting SQLITE_OPEN_PRIVATECACHE or
+# SQLITE_OPEN_SHAREDCACHE flag.
+#
+set orig [sqlite3_enable_shared_cache]
+foreach {tn uri flags shared_default isshared} {
+ 1.1 "file:test.db" "" 0 0
+ 1.2 "file:test.db" "" 1 1
+ 1.3 "file:test.db" private 0 0
+ 1.4 "file:test.db" private 1 0
+ 1.5 "file:test.db" shared 0 1
+ 1.6 "file:test.db" shared 1 1
+
+ 2.1 "file:test.db?cache=private" "" 0 0
+ 2.2 "file:test.db?cache=private" "" 1 0
+ 2.3 "file:test.db?cache=private" private 0 0
+ 2.4 "file:test.db?cache=private" private 1 0
+ 2.5 "file:test.db?cache=private" shared 0 0
+ 2.6 "file:test.db?cache=private" shared 1 0
+
+ 3.1 "file:test.db?cache=shared" "" 0 1
+ 3.2 "file:test.db?cache=shared" "" 1 1
+ 3.3 "file:test.db?cache=shared" private 0 1
+ 3.4 "file:test.db?cache=shared" private 1 1
+ 3.5 "file:test.db?cache=shared" shared 0 1
+ 3.6 "file:test.db?cache=shared" shared 1 1
+} {
+ forcedelete test.db
+ sqlite3_enable_shared_cache 1
+ sqlite3 db test.db
+ sqlite3_enable_shared_cache 0
+
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('ok');
+ }
+
+ unset -nocomplain f
+ set f() {SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI}
+ set f(shared) [concat $f() SQLITE_OPEN_SHAREDCACHE]
+ set f(private) [concat $f() SQLITE_OPEN_PRIVATECACHE]
+
+ sqlite3_enable_shared_cache $shared_default
+ set DB [sqlite3_open_v2 $uri $f($flags) ""]
+
+ set STMT [sqlite3_prepare $DB "SELECT * FROM t1" -1 dummy]
+
+ db eval {
+ BEGIN;
+ INSERT INTO t1 VALUES('ko');
+ }
+
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+
+ set RES(0) {not an error}
+ set RES(1) {database table is locked: t1}
+
+ do_test 11.$tn { sqlite3_errmsg $DB } $RES($isshared)
+
+ sqlite3_close $DB
+ db close
+}
+sqlite3_enable_shared_cache $orig
+
+# EVIDENCE-OF: R-63472-46769 Specifying an unknown parameter in the
+# query component of a URI is not an error.
+#
+do_filepath_test 12.1 {
+ parse_uri file://localhost/test.db?an=unknown&parameter=is&ok=
+} {/test.db {an unknown parameter is ok {}}}
+do_filepath_test 12.2 {
+ parse_uri file://localhost/test.db?an&unknown&parameter&is&ok
+} {/test.db {an {} unknown {} parameter {} is {} ok {}}}
+
+# EVIDENCE-OF: R-27458-04043 URI hexadecimal escape sequences (%HH) are
+# supported within the path and query components of a URI.
+#
+# EVIDENCE-OF: R-52765-50368 Before the path or query components of a
+# URI filename are interpreted, they are encoded using UTF-8 and all
+# hexadecimal escape sequences replaced by a single byte containing the
+# corresponding octet.
+#
+# The second of the two statements above is tested by creating a
+# multi-byte utf-8 character using a sequence of %HH escapes.
+#
+foreach {tn uri parse} "
+ 1 {file:/test.%64%62} {/test.db {}}
+ 2 {file:/test.db?%68%65%6c%6c%6f=%77%6f%72%6c%64} {/test.db {hello world}}
+ 3 {file:/%C3%BF.db} {/\xFF.db {}}
+" {
+ do_filepath_test 13.$tn { parse_uri $uri } $parse
+}
+
+finish_test
diff --git a/test/e_vacuum.test b/test/e_vacuum.test
new file mode 100644
index 0000000..414c854
--- /dev/null
+++ b/test/e_vacuum.test
@@ -0,0 +1,303 @@
+# 2010 September 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that the "testable statements" in
+# the lang_vacuum.html document are correct.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+sqlite3_test_control_pending_byte 0x1000000
+
+proc create_db {{sql ""}} {
+ catch { db close }
+ forcedelete test.db
+ sqlite3 db test.db
+
+ db transaction {
+ execsql { PRAGMA page_size = 1024; }
+ execsql $sql
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 VALUES(1, randomblob(400));
+ INSERT INTO t1 SELECT a+1, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+2, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+4, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+8, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+16, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+32, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+64, randomblob(400) FROM t1;
+
+ CREATE TABLE t2(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t2 SELECT * FROM t1;
+ }
+ }
+
+ return [expr {[file size test.db] / 1024}]
+}
+
+# This proc returns the number of contiguous blocks of pages that make up
+# the table or index named by the only argument. For example, if the table
+# occupies database pages 3, 4, 8 and 9, then this command returns 2 (there
+# are 2 fragments - one consisting of pages 3 and 4, the other of fragments
+# 8 and 9).
+#
+proc fragment_count {name} {
+ execsql { CREATE VIRTUAL TABLE temp.stat USING dbstat }
+ set nFrag 1
+ db eval {SELECT pageno FROM stat WHERE name = 't1' ORDER BY pageno} {
+ if {[info exists prevpageno] && $prevpageno != $pageno-1} {
+ incr nFrag
+ }
+ set prevpageno $pageno
+ }
+ execsql { DROP TABLE temp.stat }
+ set nFrag
+}
+
+
+# EVIDENCE-OF: R-63707-33375 -- syntax diagram vacuum-stmt
+#
+do_execsql_test e_vacuum-0.1 { VACUUM } {}
+
+# EVIDENCE-OF: R-51469-36013 Unless SQLite is running in
+# "auto_vacuum=FULL" mode, when a large amount of data is deleted from
+# the database file it leaves behind empty space, or "free" database
+# pages.
+#
+# EVIDENCE-OF: R-60541-63059 Running VACUUM to rebuild the database
+# reclaims this space and reduces the size of the database file.
+#
+foreach {tn avmode sz} {
+ 1 none 7
+ 2 full 8
+ 3 incremental 8
+} {
+ set nPage [create_db "PRAGMA auto_vacuum = $avmode"]
+
+ do_execsql_test e_vacuum-1.1.$tn.1 {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ } {}
+
+ if {$avmode == "full"} {
+ # This branch tests the "unless ... auto_vacuum=FULL" in the requirement
+ # above. If auto_vacuum is set to FULL, then no empty space is left in
+ # the database file.
+ do_execsql_test e_vacuum-1.1.$tn.2 {PRAGMA freelist_count} 0
+ } else {
+ set freelist [expr {$nPage - $sz}]
+ if {$avmode == "incremental"} {
+ # The page size is 1024 bytes. Therefore, assuming the database contains
+ # somewhere between 207 and 411 pages (it does), there are 2 pointer-map
+ # pages.
+ incr freelist -2
+ }
+ do_execsql_test e_vacuum-1.1.$tn.3 {PRAGMA freelist_count} $freelist
+ do_execsql_test e_vacuum-1.1.$tn.4 {VACUUM} {}
+ }
+
+ do_test e_vacuum-1.1.$tn.5 { expr {[file size test.db] / 1024} } $sz
+}
+
+# EVIDENCE-OF: R-50943-18433 Frequent inserts, updates, and deletes can
+# cause the database file to become fragmented - where data for a single
+# table or index is scattered around the database file.
+#
+# EVIDENCE-OF: R-05791-54928 Running VACUUM ensures that each table and
+# index is largely stored contiguously within the database file.
+#
+# e_vacuum-1.2.1 - Perform many INSERT, UPDATE and DELETE ops on table t1.
+# e_vacuum-1.2.2 - Verify that t1 and its indexes are now quite fragmented.
+# e_vacuum-1.2.3 - Run VACUUM.
+# e_vacuum-1.2.4 - Verify that t1 and its indexes are now much
+# less fragmented.
+#
+ifcapable vtab {
+ create_db
+ register_dbstat_vtab db
+ do_execsql_test e_vacuum-1.2.1 {
+ DELETE FROM t1 WHERE a%2;
+ INSERT INTO t1 SELECT b, a FROM t2 WHERE a%2;
+ UPDATE t1 SET b=randomblob(600) WHERE (a%2)==0;
+ } {}
+
+ do_test e_vacuum-1.2.2.1 { expr [fragment_count t1]>100 } 1
+ do_test e_vacuum-1.2.2.2 { expr [fragment_count sqlite_autoindex_t1_1]>100 } 1
+ do_test e_vacuum-1.2.2.3 { expr [fragment_count sqlite_autoindex_t1_2]>100 } 1
+
+ do_execsql_test e_vacuum-1.2.3 { VACUUM } {}
+
+ # In practice, the tables and indexes each end up stored as two fragments -
+ # one containing the root page and another containing all other pages.
+ #
+ do_test e_vacuum-1.2.4.1 { fragment_count t1 } 2
+ do_test e_vacuum-1.2.4.2 { fragment_count sqlite_autoindex_t1_1 } 2
+ do_test e_vacuum-1.2.4.3 { fragment_count sqlite_autoindex_t1_2 } 2
+}
+
+# EVIDENCE-OF: R-20474-44465 Normally, the database page_size and
+# whether or not the database supports auto_vacuum must be configured
+# before the database file is actually created.
+#
+do_test e_vacuum-1.3.1.1 {
+ create_db "PRAGMA page_size = 1024 ; PRAGMA auto_vacuum = FULL"
+ execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
+} {1024 1}
+do_test e_vacuum-1.3.1.2 {
+ execsql { PRAGMA page_size = 2048 }
+ execsql { PRAGMA auto_vacuum = NONE }
+ execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
+} {1024 1}
+
+# EVIDENCE-OF: R-08570-19916 However, when not in write-ahead log mode,
+# the page_size and/or auto_vacuum properties of an existing database
+# may be changed by using the page_size and/or pragma auto_vacuum
+# pragmas and then immediately VACUUMing the database.
+#
+do_test e_vacuum-1.3.2.1 {
+ execsql { PRAGMA journal_mode = delete }
+ execsql { PRAGMA page_size = 2048 }
+ execsql { PRAGMA auto_vacuum = NONE }
+ execsql VACUUM
+ execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
+} {2048 0}
+
+# EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the
+# auto_vacuum support property can be changed using VACUUM.
+#
+ifcapable wal {
+do_test e_vacuum-1.3.3.1 {
+ execsql { PRAGMA journal_mode = wal }
+ execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
+} {2048 0}
+do_test e_vacuum-1.3.3.2 {
+ execsql { PRAGMA page_size = 1024 }
+ execsql { PRAGMA auto_vacuum = FULL }
+ execsql VACUUM
+ execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
+} {2048 1}
+}
+
+# EVIDENCE-OF: R-38001-03952 VACUUM only works on the main database. It
+# is not possible to VACUUM an attached database file.
+forcedelete test.db2
+create_db { PRAGMA auto_vacuum = NONE }
+do_execsql_test e_vacuum-2.1.1 {
+ ATTACH 'test.db2' AS aux;
+ PRAGMA aux.page_size = 1024;
+ CREATE TABLE aux.t3 AS SELECT * FROM t1;
+ DELETE FROM t3;
+} {}
+set original_size [file size test.db2]
+
+# Try everything we can think of to get the aux database vacuumed:
+do_execsql_test e_vacuum-2.1.3 { VACUUM } {}
+do_execsql_test e_vacuum-2.1.4 { VACUUM aux } {}
+do_execsql_test e_vacuum-2.1.5 { VACUUM 'test.db2' } {}
+
+# Despite our efforts, space in the aux database has not been reclaimed:
+do_test e_vacuum-2.1.6 { expr {[file size test.db2]==$::original_size} } 1
+
+# EVIDENCE-OF: R-17495-17419 The VACUUM command may change the ROWIDs of
+# entries in any tables that do not have an explicit INTEGER PRIMARY
+# KEY.
+#
+# Tests e_vacuum-3.1.1 - 3.1.2 demonstrate that rowids can change when
+# a database is VACUUMed. Tests e_vacuum-3.1.3 - 3.1.4 show that adding
+# an INTEGER PRIMARY KEY column to a table stops this from happening.
+#
+do_execsql_test e_vacuum-3.1.1 {
+ CREATE TABLE t4(x);
+ INSERT INTO t4(x) VALUES('x');
+ INSERT INTO t4(x) VALUES('y');
+ INSERT INTO t4(x) VALUES('z');
+ DELETE FROM t4 WHERE x = 'y';
+ SELECT rowid, x FROM t4;
+} {1 x 3 z}
+do_execsql_test e_vacuum-3.1.2 {
+ VACUUM;
+ SELECT rowid, x FROM t4;
+} {1 x 2 z}
+
+do_execsql_test e_vacuum-3.1.3 {
+ CREATE TABLE t5(x, y INTEGER PRIMARY KEY);
+ INSERT INTO t5(x) VALUES('x');
+ INSERT INTO t5(x) VALUES('y');
+ INSERT INTO t5(x) VALUES('z');
+ DELETE FROM t5 WHERE x = 'y';
+ SELECT rowid, x FROM t5;
+} {1 x 3 z}
+do_execsql_test e_vacuum-3.1.4 {
+ VACUUM;
+ SELECT rowid, x FROM t5;
+} {1 x 3 z}
+
+# EVIDENCE-OF: R-49563-33883 A VACUUM will fail if there is an open
+# transaction, or if there are one or more active SQL statements when it
+# is run.
+#
+do_execsql_test e_vacuum-3.2.1.1 { BEGIN } {}
+do_catchsql_test e_vacuum-3.2.1.2 {
+ VACUUM
+} {1 {cannot VACUUM from within a transaction}}
+do_execsql_test e_vacuum-3.2.1.3 { COMMIT } {}
+do_execsql_test e_vacuum-3.2.1.4 { VACUUM } {}
+do_execsql_test e_vacuum-3.2.1.5 { SAVEPOINT x } {}
+do_catchsql_test e_vacuum-3.2.1.6 {
+ VACUUM
+} {1 {cannot VACUUM from within a transaction}}
+do_execsql_test e_vacuum-3.2.1.7 { COMMIT } {}
+do_execsql_test e_vacuum-3.2.1.8 { VACUUM } {}
+
+create_db
+do_test e_vacuum-3.2.2.1 {
+ set res ""
+ db eval { SELECT a FROM t1 } {
+ if {$a == 10} { set res [catchsql VACUUM] }
+ }
+ set res
+} {1 {cannot VACUUM - SQL statements in progress}}
+
+
+# EVIDENCE-OF: R-38735-12540 As of SQLite version 3.1, an alternative to
+# using the VACUUM command to reclaim space after data has been deleted
+# is auto-vacuum mode, enabled using the auto_vacuum pragma.
+#
+do_test e_vacuum-3.3.1 {
+ create_db { PRAGMA auto_vacuum = FULL }
+ execsql { PRAGMA auto_vacuum }
+} {1}
+
+# EVIDENCE-OF: R-64844-34873 When auto_vacuum is enabled for a database
+# free pages may be reclaimed after deleting data, causing the file to
+# shrink, without rebuilding the entire database using VACUUM.
+#
+do_test e_vacuum-3.3.2.1 {
+ create_db { PRAGMA auto_vacuum = FULL }
+ execsql {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ }
+ expr {[file size test.db] / 1024}
+} {8}
+do_test e_vacuum-3.3.2.2 {
+ create_db { PRAGMA auto_vacuum = INCREMENTAL }
+ execsql {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ PRAGMA incremental_vacuum;
+ }
+ expr {[file size test.db] / 1024}
+} {8}
+
+finish_test
diff --git a/test/enc.test b/test/enc.test
new file mode 100644
index 0000000..5c24bbb
--- /dev/null
+++ b/test/enc.test
@@ -0,0 +1,172 @@
+# 2002 May 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus of
+# this file is testing the SQLite routines used for converting between the
+# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
+# UTF-16be).
+#
+# $Id: enc.test,v 1.7 2007/05/23 16:23:09 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Skip this test if the build does not support multiple encodings.
+#
+ifcapable {!utf16} {
+ finish_test
+ return
+}
+
+proc do_bincmp_test {testname got expect} {
+ binary scan $expect \c* expectvals
+ binary scan $got \c* gotvals
+ do_test $testname [list set dummy $gotvals] $expectvals
+}
+
+# $utf16 is a UTF-16 encoded string. Swap each pair of bytes around
+# to change the byte-order of the string.
+proc swap_byte_order {utf16} {
+ binary scan $utf16 \c* ints
+
+ foreach {a b} $ints {
+ lappend ints2 $b
+ lappend ints2 $a
+ }
+
+ return [binary format \c* $ints2]
+}
+
+#
+# Test that the SQLite routines for converting between UTF encodings
+# produce the same results as their TCL counterparts.
+#
+# $testname is the prefix to be used for the test names.
+# $str is a string to use for testing (encoded in UTF-8, as normal for TCL).
+#
+# The test procedure is:
+# 1. Convert the string from UTF-8 to UTF-16le and check that the TCL and
+# SQLite routines produce the same results.
+#
+# 2. Convert the string from UTF-8 to UTF-16be and check that the TCL and
+# SQLite routines produce the same results.
+#
+# 3. Use the SQLite routines to convert the native machine order UTF-16
+# representation back to the original UTF-8. Check that the result
+# matches the original representation.
+#
+# 4. Add a byte-order mark to each of the UTF-16 representations and
+# check that the SQLite routines can convert them back to UTF-8. For
+# byte-order mark info, refer to section 3.10 of the unicode standard.
+#
+# 5. Take the byte-order marked UTF-16 strings from step 4 and ensure
+# that SQLite can convert them both to native byte order UTF-16
+# strings, sans BOM.
+#
+# Coverage:
+#
+# sqlite_utf8to16be (step 2)
+# sqlite_utf8to16le (step 1)
+# sqlite_utf16to8 (steps 3, 4)
+# sqlite_utf16to16le (step 5)
+# sqlite_utf16to16be (step 5)
+#
+proc test_conversion {testname str} {
+
+ # Step 1.
+ set utf16le_sqlite3 [test_translate $str UTF8 UTF16LE]
+ set utf16le_tcl [encoding convertto unicode $str]
+ append utf16le_tcl "\x00\x00"
+ if { $::tcl_platform(byteOrder)!="littleEndian" } {
+ set utf16le_tcl [swap_byte_order $utf16le_tcl]
+ }
+ do_bincmp_test $testname.1 $utf16le_sqlite3 $utf16le_tcl
+ set utf16le $utf16le_tcl
+
+ # Step 2.
+ set utf16be_sqlite3 [test_translate $str UTF8 UTF16BE]
+ set utf16be_tcl [encoding convertto unicode $str]
+ append utf16be_tcl "\x00\x00"
+ if { $::tcl_platform(byteOrder)=="littleEndian" } {
+ set utf16be_tcl [swap_byte_order $utf16be_tcl]
+ }
+ do_bincmp_test $testname.2 $utf16be_sqlite3 $utf16be_tcl
+ set utf16be $utf16be_tcl
+
+ # Step 3.
+ if { $::tcl_platform(byteOrder)=="littleEndian" } {
+ set utf16 $utf16le
+ } else {
+ set utf16 $utf16be
+ }
+ set utf8_sqlite3 [test_translate $utf16 UTF16 UTF8]
+ do_bincmp_test $testname.3 $utf8_sqlite3 [binarize $str]
+
+ # Step 4 (little endian).
+ append utf16le_bom "\xFF\xFE" $utf16le
+ set utf8_sqlite3 [test_translate $utf16le_bom UTF16 UTF8 1]
+ do_bincmp_test $testname.4.le $utf8_sqlite3 [binarize $str]
+
+ # Step 4 (big endian).
+ append utf16be_bom "\xFE\xFF" $utf16be
+ set utf8_sqlite3 [test_translate $utf16be_bom UTF16 UTF8]
+ do_bincmp_test $testname.4.be $utf8_sqlite3 [binarize $str]
+
+ # Step 5 (little endian to little endian).
+ set utf16_sqlite3 [test_translate $utf16le_bom UTF16LE UTF16LE]
+ do_bincmp_test $testname.5.le.le $utf16_sqlite3 $utf16le
+
+ # Step 5 (big endian to big endian).
+ set utf16_sqlite3 [test_translate $utf16be_bom UTF16 UTF16BE]
+ do_bincmp_test $testname.5.be.be $utf16_sqlite3 $utf16be
+
+ # Step 5 (big endian to little endian).
+ set utf16_sqlite3 [test_translate $utf16be_bom UTF16 UTF16LE]
+ do_bincmp_test $testname.5.be.le $utf16_sqlite3 $utf16le
+
+ # Step 5 (little endian to big endian).
+ set utf16_sqlite3 [test_translate $utf16le_bom UTF16 UTF16BE]
+ do_bincmp_test $testname.5.le.be $utf16_sqlite3 $utf16be
+}
+
+translate_selftest
+
+test_conversion enc-1 "hello world"
+test_conversion enc-2 "sqlite"
+test_conversion enc-3 ""
+test_conversion enc-X "\u0100"
+test_conversion enc-4 "\u1234"
+test_conversion enc-5 "\u4321abc"
+test_conversion enc-6 "\u4321\u1234"
+test_conversion enc-7 [string repeat "abcde\u00EF\u00EE\uFFFCabc" 100]
+test_conversion enc-8 [string repeat "\u007E\u007F\u0080\u0081" 100]
+test_conversion enc-9 [string repeat "\u07FE\u07FF\u0800\u0801\uFFF0" 100]
+test_conversion enc-10 [string repeat "\uE000" 100]
+
+proc test_collate {enc zLeft zRight} {
+ return [string compare $zLeft $zRight]
+}
+add_test_collate $::DB 0 0 1
+do_test enc-11.1 {
+ execsql {
+ CREATE TABLE ab(a COLLATE test_collate, b);
+ INSERT INTO ab VALUES(CAST (X'C388' AS TEXT), X'888800');
+ INSERT INTO ab VALUES(CAST (X'C0808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808388' AS TEXT), X'888800');
+ CREATE INDEX ab_i ON ab(a, b);
+ }
+} {}
+do_test enc-11.2 {
+ set cp200 "\u00C8"
+ execsql {
+ SELECT count(*) FROM ab WHERE a = $::cp200;
+ }
+} {2}
+
+finish_test
diff --git a/test/enc2.test b/test/enc2.test
new file mode 100644
index 0000000..415bc0f
--- /dev/null
+++ b/test/enc2.test
@@ -0,0 +1,555 @@
+# 2002 May 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus of
+# this file is testing the SQLite routines used for converting between the
+# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
+# UTF-16be).
+#
+# $Id: enc2.test,v 1.29 2007/10/09 08:29:32 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If UTF16 support is disabled, ignore the tests in this file
+#
+ifcapable {!utf16} {
+ finish_test
+ return
+}
+
+# The rough organisation of tests in this file is:
+#
+# enc2.1.*: Simple tests with a UTF-8 db.
+# enc2.2.*: Simple tests with a UTF-16LE db.
+# enc2.3.*: Simple tests with a UTF-16BE db.
+# enc2.4.*: Test that attached databases must have the same text encoding
+# as the main database.
+# enc2.5.*: Test the behaviour of the library when a collation sequence is
+# not available for the most desirable text encoding.
+# enc2.6.*: Similar test for user functions.
+# enc2.7.*: Test that the VerifyCookie opcode protects against assuming the
+# wrong text encoding for the database.
+# enc2.8.*: Test sqlite3_complete16()
+#
+
+db close
+
+# Return the UTF-8 representation of the supplied UTF-16 string $str.
+proc utf8 {str} {
+ # If $str ends in two 0x00 0x00 bytes, knock these off before
+ # converting to UTF-8 using TCL.
+ binary scan $str \c* vals
+ if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {
+ set str [binary format \c* [lrange $vals 0 end-2]]
+ }
+
+ set r [encoding convertfrom unicode $str]
+ return $r
+}
+
+#
+# This proc contains all the tests in this file. It is run
+# three times. Each time the file 'test.db' contains a database
+# with the following contents:
+set dbcontents {
+ CREATE TABLE t1(a PRIMARY KEY, b, c);
+ INSERT INTO t1 VALUES('one', 'I', 1);
+}
+# This proc tests that we can open and manipulate the test.db
+# database, and that it is possible to retreive values in
+# various text encodings.
+#
+proc run_test_script {t enc} {
+
+# Open the database and pull out a (the) row.
+do_test $t.1 {
+ sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+ execsql {SELECT * FROM t1}
+} {one I 1}
+
+# Insert some data
+do_test $t.2 {
+ execsql {INSERT INTO t1 VALUES('two', 'II', 2);}
+ execsql {SELECT * FROM t1}
+} {one I 1 two II 2}
+
+# Insert some data
+do_test $t.3 {
+ execsql {
+ INSERT INTO t1 VALUES('three','III',3);
+ INSERT INTO t1 VALUES('four','IV',4);
+ INSERT INTO t1 VALUES('five','V',5);
+ }
+ execsql {SELECT * FROM t1}
+} {one I 1 two II 2 three III 3 four IV 4 five V 5}
+
+# Use the index
+do_test $t.4 {
+ execsql {
+ SELECT * FROM t1 WHERE a = 'one';
+ }
+} {one I 1}
+do_test $t.5 {
+ execsql {
+ SELECT * FROM t1 WHERE a = 'four';
+ }
+} {four IV 4}
+ifcapable subquery {
+ do_test $t.6 {
+ execsql {
+ SELECT * FROM t1 WHERE a IN ('one', 'two');
+ }
+ } {one I 1 two II 2}
+}
+
+# Now check that we can retrieve data in both UTF-16 and UTF-8
+do_test $t.7 {
+ set STMT [sqlite3_prepare $DB "SELECT a FROM t1 WHERE c>3;" -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_column_text $STMT 0
+} {four}
+
+do_test $t.8 {
+ sqlite3_step $STMT
+ utf8 [sqlite3_column_text16 $STMT 0]
+} {five}
+
+do_test $t.9 {
+ sqlite3_finalize $STMT
+} SQLITE_OK
+
+ifcapable vacuum {
+ execsql VACUUM
+}
+
+do_test $t.10 {
+ db eval {PRAGMA encoding}
+} $enc
+
+}
+
+# The three unicode encodings understood by SQLite.
+set encodings [list UTF-8 UTF-16le UTF-16be]
+
+set sqlite_os_trace 0
+set i 1
+foreach enc $encodings {
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval "PRAGMA encoding = \"$enc\""
+ execsql $dbcontents
+ do_test enc2-$i.0.1 {
+ db eval {PRAGMA encoding}
+ } $enc
+ do_test enc2-$i.0.2 {
+ db eval {PRAGMA encoding=UTF8}
+ db eval {PRAGMA encoding}
+ } $enc
+ do_test enc2-$i.0.3 {
+ db eval {PRAGMA encoding=UTF16le}
+ db eval {PRAGMA encoding}
+ } $enc
+ do_test enc2-$i.0.4 {
+ db eval {PRAGMA encoding=UTF16be}
+ db eval {PRAGMA encoding}
+ } $enc
+
+ db close
+ run_test_script enc2-$i $enc
+ db close
+ incr i
+}
+
+# Test that it is an error to try to attach a database with a different
+# encoding to the main database.
+ifcapable attach {
+ do_test enc2-4.1 {
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval "PRAGMA encoding = 'UTF-8'"
+ db eval "CREATE TABLE abc(a, b, c);"
+ } {}
+ do_test enc2-4.2 {
+ forcedelete test2.db
+ sqlite3 db2 test2.db
+ db2 eval "PRAGMA encoding = 'UTF-16'"
+ db2 eval "CREATE TABLE abc(a, b, c);"
+ } {}
+ do_test enc2-4.3 {
+ catchsql {
+ ATTACH 'test2.db' as aux;
+ }
+ } {1 {attached databases must use the same text encoding as main database}}
+ db2 close
+ db close
+}
+
+# The following tests - enc2-5.* - test that SQLite selects the correct
+# collation sequence when more than one is available.
+
+set ::values [list one two three four five]
+set ::test_collate_enc INVALID
+proc test_collate {enc lhs rhs} {
+ set ::test_collate_enc $enc
+ set l [lsearch -exact $::values $lhs]
+ set r [lsearch -exact $::values $rhs]
+ set res [expr $l - $r]
+ # puts "enc=$enc lhs=$lhs/$l rhs=$rhs/$r res=$res"
+ return $res
+}
+
+forcedelete test.db
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+do_test enc2-5.0 {
+ execsql {
+ CREATE TABLE t5(a);
+ INSERT INTO t5 VALUES('one');
+ INSERT INTO t5 VALUES('two');
+ INSERT INTO t5 VALUES('five');
+ INSERT INTO t5 VALUES('three');
+ INSERT INTO t5 VALUES('four');
+ }
+} {}
+do_test enc2-5.1 {
+ add_test_collate $DB 1 1 1
+ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate;}]
+ lappend res $::test_collate_enc
+} {one two three four five UTF-8}
+do_test enc2-5.2 {
+ add_test_collate $DB 0 1 0
+ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
+ lappend res $::test_collate_enc
+} {one two three four five UTF-16LE}
+do_test enc2-5.3 {
+ add_test_collate $DB 0 0 1
+ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
+ lappend res $::test_collate_enc
+} {one two three four five UTF-16BE}
+
+db close
+forcedelete test.db
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+execsql {pragma encoding = 'UTF-16LE'}
+do_test enc2-5.4 {
+ execsql {
+ CREATE TABLE t5(a);
+ INSERT INTO t5 VALUES('one');
+ INSERT INTO t5 VALUES('two');
+ INSERT INTO t5 VALUES('five');
+ INSERT INTO t5 VALUES('three');
+ INSERT INTO t5 VALUES('four');
+ }
+} {}
+do_test enc2-5.5 {
+ add_test_collate $DB 1 1 1
+ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
+ lappend res $::test_collate_enc
+} {one two three four five UTF-16LE}
+do_test enc2-5.6 {
+ add_test_collate $DB 1 0 1
+ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
+ lappend res $::test_collate_enc
+} {one two three four five UTF-16BE}
+do_test enc2-5.7 {
+ add_test_collate $DB 1 0 0
+ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
+ lappend res $::test_collate_enc
+} {one two three four five UTF-8}
+
+db close
+forcedelete test.db
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+execsql {pragma encoding = 'UTF-16BE'}
+do_test enc2-5.8 {
+ execsql {
+ CREATE TABLE t5(a);
+ INSERT INTO t5 VALUES('one');
+ INSERT INTO t5 VALUES('two');
+ INSERT INTO t5 VALUES('five');
+ INSERT INTO t5 VALUES('three');
+ INSERT INTO t5 VALUES('four');
+ }
+} {}
+do_test enc2-5.9 {
+ add_test_collate $DB 1 1 1
+ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
+ lappend res $::test_collate_enc
+} {one two three four five UTF-16BE}
+do_test enc2-5.10 {
+ add_test_collate $DB 1 1 0
+ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
+ lappend res $::test_collate_enc
+} {one two three four five UTF-16LE}
+do_test enc2-5.11 {
+ add_test_collate $DB 1 0 0
+ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
+ lappend res $::test_collate_enc
+} {one two three four five UTF-8}
+
+# Also test that a UTF-16 collation factory works.
+do_test enc2-5-12 {
+ add_test_collate $DB 0 0 0
+ catchsql {
+ SELECT * FROM t5 ORDER BY 1 COLLATE test_collate
+ }
+} {1 {no such collation sequence: test_collate}}
+do_test enc2-5.13 {
+ add_test_collate_needed $DB
+ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate; }]
+ lappend res $::test_collate_enc
+} {one two three four five UTF-16BE}
+do_test enc2-5.14 {
+ set ::sqlite_last_needed_collation
+} test_collate
+
+db close
+forcedelete test.db
+
+do_test enc2-5.15 {
+ sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db]
+ add_test_collate_needed $::DB
+ set ::sqlite_last_needed_collation
+} {}
+do_test enc2-5.16 {
+ execsql {CREATE TABLE t1(a varchar collate test_collate);}
+} {}
+do_test enc2-5.17 {
+ set ::sqlite_last_needed_collation
+} {test_collate}
+
+# The following tests - enc2-6.* - test that SQLite selects the correct
+# user function when more than one is available.
+
+proc test_function {enc arg} {
+ return "$enc $arg"
+}
+
+db close
+forcedelete test.db
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+execsql {pragma encoding = 'UTF-8'}
+do_test enc2-6.0 {
+ execsql {
+ CREATE TABLE t5(a);
+ INSERT INTO t5 VALUES('one');
+ }
+} {}
+do_test enc2-6.1 {
+ add_test_function $DB 1 1 1
+ execsql {
+ SELECT test_function('sqlite')
+ }
+} {{UTF-8 sqlite}}
+db close
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+do_test enc2-6.2 {
+ add_test_function $DB 0 1 0
+ execsql {
+ SELECT test_function('sqlite')
+ }
+} {{UTF-16LE sqlite}}
+db close
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+do_test enc2-6.3 {
+ add_test_function $DB 0 0 1
+ execsql {
+ SELECT test_function('sqlite')
+ }
+} {{UTF-16BE sqlite}}
+
+db close
+forcedelete test.db
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+execsql {pragma encoding = 'UTF-16LE'}
+do_test enc2-6.3 {
+ execsql {
+ CREATE TABLE t5(a);
+ INSERT INTO t5 VALUES('sqlite');
+ }
+} {}
+do_test enc2-6.4 {
+ add_test_function $DB 1 1 1
+ execsql {
+ SELECT test_function('sqlite')
+ }
+} {{UTF-16LE sqlite}}
+db close
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+do_test enc2-6.5 {
+ add_test_function $DB 0 1 0
+ execsql {
+ SELECT test_function('sqlite')
+ }
+} {{UTF-16LE sqlite}}
+db close
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+do_test enc2-6.6 {
+ add_test_function $DB 0 0 1
+ execsql {
+ SELECT test_function('sqlite')
+ }
+} {{UTF-16BE sqlite}}
+
+db close
+forcedelete test.db
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+execsql {pragma encoding = 'UTF-16BE'}
+do_test enc2-6.7 {
+ execsql {
+ CREATE TABLE t5(a);
+ INSERT INTO t5 VALUES('sqlite');
+ }
+} {}
+do_test enc2-6.8 {
+ add_test_function $DB 1 1 1
+ execsql {
+ SELECT test_function('sqlite')
+ }
+} {{UTF-16BE sqlite}}
+db close
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+do_test enc2-6.9 {
+ add_test_function $DB 0 1 0
+ execsql {
+ SELECT test_function('sqlite')
+ }
+} {{UTF-16LE sqlite}}
+db close
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+do_test enc2-6.10 {
+ add_test_function $DB 0 0 1
+ execsql {
+ SELECT test_function('sqlite')
+ }
+} {{UTF-16BE sqlite}}
+
+
+db close
+forcedelete test.db
+
+# The following tests - enc2-7.* - function as follows:
+#
+# 1: Open an empty database file assuming UTF-16 encoding.
+# 2: Open the same database with a different handle assuming UTF-8. Create
+# a table using this handle.
+# 3: Read the sqlite_master table from the first handle.
+# 4: Ensure the first handle recognises the database encoding is UTF-8.
+#
+do_test enc2-7.1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA encoding = 'UTF-16';
+ SELECT * FROM sqlite_master;
+ }
+} {}
+do_test enc2-7.2 {
+ set enc [execsql {
+ PRAGMA encoding;
+ }]
+ string range $enc 0 end-2 ;# Chop off the "le" or "be"
+} {UTF-16}
+do_test enc2-7.3 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA encoding = 'UTF-8';
+ CREATE TABLE abc(a, b, c);
+ } db2
+} {}
+do_test enc2-7.4 {
+ execsql {
+ SELECT * FROM sqlite_master;
+ }
+} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}"
+do_test enc2-7.5 {
+ execsql {
+ PRAGMA encoding;
+ }
+} {UTF-8}
+
+db close
+db2 close
+
+proc utf16 {utf8} {
+ set utf16 [encoding convertto unicode $utf8]
+ append utf16 "\x00\x00"
+ return $utf16
+}
+ifcapable {complete} {
+ do_test enc2-8.1 {
+ sqlite3_complete16 [utf16 "SELECT * FROM t1;"]
+ } {1}
+ do_test enc2-8.2 {
+ sqlite3_complete16 [utf16 "SELECT * FROM"]
+ } {0}
+}
+
+# Test that the encoding of an empty database may still be set after the
+# (empty) schema has been initialized.
+forcedelete test.db
+do_test enc2-9.1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA encoding = 'UTF-8';
+ PRAGMA encoding;
+ }
+} {UTF-8}
+do_test enc2-9.2 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA encoding = 'UTF-16le';
+ PRAGMA encoding;
+ }
+} {UTF-16le}
+do_test enc2-9.3 {
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM sqlite_master;
+ PRAGMA encoding = 'UTF-8';
+ PRAGMA encoding;
+ }
+} {UTF-8}
+do_test enc2-9.4 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA encoding = 'UTF-16le';
+ CREATE TABLE abc(a, b, c);
+ PRAGMA encoding;
+ }
+} {UTF-16le}
+do_test enc2-9.5 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA encoding = 'UTF-8';
+ PRAGMA encoding;
+ }
+} {UTF-16le}
+
+# Ticket #1987.
+# Disallow encoding changes once the encoding has been set.
+#
+do_test enc2-10.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ db eval {
+ PRAGMA encoding=UTF16;
+ CREATE TABLE t1(a);
+ PRAGMA encoding=UTF8;
+ CREATE TABLE t2(b);
+ }
+ db close
+ sqlite3 db test.db
+ db eval {
+ SELECT name FROM sqlite_master
+ }
+} {t1 t2}
+
+finish_test
diff --git a/test/enc3.test b/test/enc3.test
new file mode 100644
index 0000000..1d8a258
--- /dev/null
+++ b/test/enc3.test
@@ -0,0 +1,107 @@
+# 2002 May 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# The focus of this file is testing of the proper handling of conversions
+# to the native text representation.
+#
+# $Id: enc3.test,v 1.8 2008/01/22 01:48:09 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {utf16} {
+ do_test enc3-1.1 {
+ execsql {
+ PRAGMA encoding=utf16le;
+ PRAGMA encoding;
+ }
+ } {UTF-16le}
+}
+do_test enc3-1.2 {
+ execsql {
+ CREATE TABLE t1(x,y);
+ INSERT INTO t1 VALUES('abc''123',5);
+ SELECT * FROM t1
+ }
+} {abc'123 5}
+do_test enc3-1.3 {
+ execsql {
+ SELECT quote(x) || ' ' || quote(y) FROM t1
+ }
+} {{'abc''123' 5}}
+ifcapable {bloblit} {
+ do_test enc3-1.4 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(x'616263646566',NULL);
+ SELECT * FROM t1
+ }
+ } {abcdef {}}
+ do_test enc3-1.5 {
+ execsql {
+ SELECT quote(x) || ' ' || quote(y) FROM t1
+ }
+ } {{X'616263646566' NULL}}
+}
+ifcapable {bloblit && utf16} {
+ do_test enc3-2.1 {
+ execsql {
+ PRAGMA encoding
+ }
+ } {UTF-16le}
+ do_test enc3-2.2 {
+ execsql {
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(x'61006200630064006500');
+ SELECT CAST(a AS text) FROM t2 WHERE a LIKE 'abc%';
+ }
+ } {abcde}
+ do_test enc3-2.3 {
+ execsql {
+ SELECT CAST(x'61006200630064006500' AS text);
+ }
+ } {abcde}
+ do_test enc3-2.4 {
+ execsql {
+ SELECT rowid FROM t2 WHERE a LIKE x'610062002500';
+ }
+ } {1}
+}
+
+# Try to attach a database with a different encoding.
+#
+ifcapable {utf16 && shared_cache} {
+ db close
+ forcedelete test8.db test8.db-journal
+ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+ sqlite3 dbaux test8.db
+ sqlite3 db test.db
+ db eval {SELECT 1 FROM sqlite_master LIMIT 1}
+ do_test enc3-3.1 {
+ dbaux eval {
+ PRAGMA encoding='utf8';
+ CREATE TABLE t1(x);
+ PRAGMA encoding
+ }
+ } {UTF-8}
+ do_test enc3-3.2 {
+ catchsql {
+ ATTACH 'test.db' AS utf16;
+ SELECT 1 FROM utf16.sqlite_master LIMIT 1;
+ } dbaux
+ } {1 {attached databases must use the same text encoding as main database}}
+ dbaux close
+ forcedelete test8.db test8.db-journal
+ sqlite3_enable_shared_cache $::enable_shared_cache
+}
+
+finish_test
diff --git a/test/enc4.test b/test/enc4.test
new file mode 100644
index 0000000..94869b6
--- /dev/null
+++ b/test/enc4.test
@@ -0,0 +1,137 @@
+# 2010 Sept 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus of
+# this file is testing the SQLite routines used for converting between the
+# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
+# UTF-16be).
+#
+# $Id: enc4.test,v 1.0 2010/09/29 08:29:32 shaneh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If UTF16 support is disabled, ignore the tests in this file
+#
+ifcapable {!utf16} {
+ finish_test
+ return
+}
+
+db close
+
+# The three unicode encodings understood by SQLite.
+set encodings [list UTF-8 UTF-16le UTF-16be]
+
+# initial value to use in SELECT
+set inits [list 1 1.0 1. 1e0]
+
+# vals
+set vals [list\
+"922337203685477580792233720368547758079223372036854775807"\
+"100000000000000000000000000000000000000000000000000000000"\
+"1.0000000000000000000000000000000000000000000000000000000"\
+]
+
+set i 1
+foreach enc $encodings {
+
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval "PRAGMA encoding = \"$enc\""
+
+ do_test enc4-$i.1 {
+ db eval {PRAGMA encoding}
+ } $enc
+
+ set j 1
+ foreach init $inits {
+
+ do_test enc4-$i.$j.2 {
+ set S [sqlite3_prepare_v2 db "SELECT $init+?" -1 dummy]
+ sqlite3_expired $S
+ } {0}
+
+ set k 1
+ foreach val $vals {
+ for {set x 1} {$x<16} {incr x} {
+ set part [expr $init + [string range $val 0 [expr $x-1]]]
+
+ do_realnum_test enc4-$i.$j.$k.3.$x {
+ sqlite3_reset $S
+ sqlite3_bind_text $S 1 $val $x
+ sqlite3_step $S
+ sqlite3_column_text $S 0
+ } [list $part]
+
+ do_realnum_test enc4-$i.$j.$k.4.$x {
+ sqlite3_reset $S
+ sqlite3_bind_text16 $S 1 [encoding convertto unicode $val] [expr $x*2]
+ sqlite3_step $S
+ sqlite3_column_text $S 0
+ } [list $part]
+ }
+
+ incr k
+ }
+
+ do_test enc4-$i.$j.5 {
+ sqlite3_finalize $S
+ } {SQLITE_OK}
+
+ incr j
+ }
+
+ db close
+ incr i
+}
+
+forcedelete test.db
+sqlite3 db test.db
+
+do_test enc4-4.1 {
+ db eval "select 1+1."
+} {2.0}
+
+do_test enc4-4.2.1 {
+ set S [sqlite3_prepare_v2 db "SELECT 1+1." -1 dummy]
+ sqlite3_step $S
+ sqlite3_column_text $S 0
+} {2.0}
+
+do_test enc4-4.2.2 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+do_test enc4-4.3.1 {
+ set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
+ sqlite3_bind_text $S 1 "1." 2
+ sqlite3_step $S
+ sqlite3_column_text $S 0
+} {2.0}
+
+do_test enc4-4.3.2 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+do_test enc4-4.4.1 {
+ set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
+ sqlite3_bind_text $S 1 "1.0" 2
+ sqlite3_step $S
+ sqlite3_column_text $S 0
+} {2.0}
+
+do_test enc4-4.4.2 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+db close
+
+finish_test
diff --git a/test/eqp.test b/test/eqp.test
new file mode 100644
index 0000000..91a18d0
--- /dev/null
+++ b/test/eqp.test
@@ -0,0 +1,578 @@
+# 2010 November 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix eqp
+
+#-------------------------------------------------------------------------
+#
+# eqp-1.*: Assorted tests.
+# eqp-2.*: Tests for single select statements.
+# eqp-3.*: Select statements that execute sub-selects.
+# eqp-4.*: Compound select statements.
+# ...
+# eqp-7.*: "SELECT count(*) FROM tbl" statements (VDBE code OP_Count).
+#
+
+proc det {args} { uplevel do_eqp_test $args }
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+ CREATE TABLE t2(a, b);
+ CREATE TABLE t3(a, b);
+}
+
+do_eqp_test 1.2 {
+ SELECT * FROM t2, t1 WHERE t1.a=1 OR t1.b=2;
+} {
+ 0 0 1 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)}
+ 0 0 1 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~10 rows)}
+ 0 1 0 {SCAN TABLE t2 (~1000000 rows)}
+}
+do_eqp_test 1.3 {
+ SELECT * FROM t2 CROSS JOIN t1 WHERE t1.a=1 OR t1.b=2;
+} {
+ 0 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 0 1 1 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)}
+ 0 1 1 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~10 rows)}
+}
+do_eqp_test 1.3 {
+ SELECT a FROM t1 ORDER BY a
+} {
+ 0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
+}
+do_eqp_test 1.4 {
+ SELECT a FROM t1 ORDER BY +a
+} {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+do_eqp_test 1.5 {
+ SELECT a FROM t1 WHERE a=4
+} {
+ 0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?) (~10 rows)}
+}
+do_eqp_test 1.6 {
+ SELECT DISTINCT count(*) FROM t3 GROUP BY a;
+} {
+ 0 0 0 {SCAN TABLE t3 (~1000000 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR GROUP BY}
+ 0 0 0 {USE TEMP B-TREE FOR DISTINCT}
+}
+
+do_eqp_test 1.7 {
+ SELECT * FROM t3 JOIN (SELECT 1)
+} {
+ 0 0 1 {SCAN SUBQUERY 1 (~1 rows)}
+ 0 1 0 {SCAN TABLE t3 (~1000000 rows)}
+}
+do_eqp_test 1.8 {
+ SELECT * FROM t3 JOIN (SELECT 1 UNION SELECT 2)
+} {
+ 1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (UNION)}
+ 0 0 1 {SCAN SUBQUERY 1 (~2 rows)}
+ 0 1 0 {SCAN TABLE t3 (~1000000 rows)}
+}
+do_eqp_test 1.9 {
+ SELECT * FROM t3 JOIN (SELECT 1 EXCEPT SELECT a FROM t3 LIMIT 17)
+} {
+ 3 0 0 {SCAN TABLE t3 (~1000000 rows)}
+ 1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (EXCEPT)}
+ 0 0 1 {SCAN SUBQUERY 1 (~17 rows)}
+ 0 1 0 {SCAN TABLE t3 (~1000000 rows)}
+}
+do_eqp_test 1.10 {
+ SELECT * FROM t3 JOIN (SELECT 1 INTERSECT SELECT a FROM t3 LIMIT 17)
+} {
+ 3 0 0 {SCAN TABLE t3 (~1000000 rows)}
+ 1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (INTERSECT)}
+ 0 0 1 {SCAN SUBQUERY 1 (~1 rows)}
+ 0 1 0 {SCAN TABLE t3 (~1000000 rows)}
+}
+
+do_eqp_test 1.11 {
+ SELECT * FROM t3 JOIN (SELECT 1 UNION ALL SELECT a FROM t3 LIMIT 17)
+} {
+ 3 0 0 {SCAN TABLE t3 (~1000000 rows)}
+ 1 0 0 {COMPOUND SUBQUERIES 2 AND 3 (UNION ALL)}
+ 0 0 1 {SCAN SUBQUERY 1 (~17 rows)}
+ 0 1 0 {SCAN TABLE t3 (~1000000 rows)}
+}
+
+#-------------------------------------------------------------------------
+# Test cases eqp-2.* - tests for single select statements.
+#
+drop_all_tables
+do_execsql_test 2.1 {
+ CREATE TABLE t1(x, y);
+
+ CREATE TABLE t2(x, y);
+ CREATE INDEX t2i1 ON t2(x);
+}
+
+det 2.2.1 "SELECT DISTINCT min(x), max(x) FROM t1 GROUP BY x ORDER BY 1" {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR GROUP BY}
+ 0 0 0 {USE TEMP B-TREE FOR DISTINCT}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+det 2.2.2 "SELECT DISTINCT min(x), max(x) FROM t2 GROUP BY x ORDER BY 1" {
+ 0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR DISTINCT}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+det 2.2.3 "SELECT DISTINCT * FROM t1" {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR DISTINCT}
+}
+det 2.2.4 "SELECT DISTINCT * FROM t1, t2" {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 1 1 {SCAN TABLE t2 (~1000000 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR DISTINCT}
+}
+det 2.2.5 "SELECT DISTINCT * FROM t1, t2 ORDER BY t1.x" {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 1 1 {SCAN TABLE t2 (~1000000 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR DISTINCT}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+det 2.2.6 "SELECT DISTINCT t2.x FROM t1, t2 ORDER BY t2.x" {
+ 0 0 1 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
+ 0 1 0 {SCAN TABLE t1 (~1000000 rows)}
+}
+
+det 2.3.1 "SELECT max(x) FROM t2" {
+ 0 0 0 {SEARCH TABLE t2 USING COVERING INDEX t2i1 (~1 rows)}
+}
+det 2.3.2 "SELECT min(x) FROM t2" {
+ 0 0 0 {SEARCH TABLE t2 USING COVERING INDEX t2i1 (~1 rows)}
+}
+det 2.3.3 "SELECT min(x), max(x) FROM t2" {
+ 0 0 0 {SCAN TABLE t2 (~1000000 rows)}
+}
+
+det 2.4.1 "SELECT * FROM t1 WHERE rowid=?" {
+ 0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+}
+
+
+
+#-------------------------------------------------------------------------
+# Test cases eqp-3.* - tests for select statements that use sub-selects.
+#
+do_eqp_test 3.1.1 {
+ SELECT (SELECT x FROM t1 AS sub) FROM t1;
+} {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 0 0 {EXECUTE SCALAR SUBQUERY 1}
+ 1 0 0 {SCAN TABLE t1 AS sub (~1000000 rows)}
+}
+do_eqp_test 3.1.2 {
+ SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub);
+} {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 0 0 {EXECUTE SCALAR SUBQUERY 1}
+ 1 0 0 {SCAN TABLE t1 AS sub (~1000000 rows)}
+}
+do_eqp_test 3.1.3 {
+ SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub ORDER BY y);
+} {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 0 0 {EXECUTE SCALAR SUBQUERY 1}
+ 1 0 0 {SCAN TABLE t1 AS sub (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+do_eqp_test 3.1.4 {
+ SELECT * FROM t1 WHERE (SELECT x FROM t2 ORDER BY x);
+} {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 0 0 {EXECUTE SCALAR SUBQUERY 1}
+ 1 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
+}
+
+det 3.2.1 {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY x LIMIT 10) ORDER BY y LIMIT 5
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {SCAN SUBQUERY 1 (~10 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+det 3.2.2 {
+ SELECT * FROM
+ (SELECT * FROM t1 ORDER BY x LIMIT 10) AS x1,
+ (SELECT * FROM t2 ORDER BY x LIMIT 10) AS x2
+ ORDER BY x2.y LIMIT 5
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 2 0 0 {SCAN TABLE t2 USING INDEX t2i1 (~1000000 rows)}
+ 0 0 0 {SCAN SUBQUERY 1 AS x1 (~10 rows)}
+ 0 1 1 {SCAN SUBQUERY 2 AS x2 (~10 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+
+det 3.3.1 {
+ SELECT * FROM t1 WHERE y IN (SELECT y FROM t2)
+} {
+ 0 0 0 {SCAN TABLE t1 (~100000 rows)}
+ 0 0 0 {EXECUTE LIST SUBQUERY 1}
+ 1 0 0 {SCAN TABLE t2 (~1000000 rows)}
+}
+det 3.3.2 {
+ SELECT * FROM t1 WHERE y IN (SELECT y FROM t2 WHERE t1.x!=t2.x)
+} {
+ 0 0 0 {SCAN TABLE t1 (~500000 rows)}
+ 0 0 0 {EXECUTE CORRELATED LIST SUBQUERY 1}
+ 1 0 0 {SCAN TABLE t2 (~500000 rows)}
+}
+det 3.3.3 {
+ SELECT * FROM t1 WHERE EXISTS (SELECT y FROM t2 WHERE t1.x!=t2.x)
+} {
+ 0 0 0 {SCAN TABLE t1 (~500000 rows)}
+ 0 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 1}
+ 1 0 0 {SCAN TABLE t2 (~500000 rows)}
+}
+
+#-------------------------------------------------------------------------
+# Test cases eqp-4.* - tests for composite select statements.
+#
+do_eqp_test 4.1.1 {
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)}
+}
+do_eqp_test 4.1.2 {
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY 2
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 2 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)}
+}
+do_eqp_test 4.1.3 {
+ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY 2
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 2 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION)}
+}
+do_eqp_test 4.1.4 {
+ SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 2
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 2 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (INTERSECT)}
+}
+do_eqp_test 4.1.5 {
+ SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 2
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 2 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)}
+}
+
+do_eqp_test 4.2.2 {
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY 1
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 2 0 0 {SCAN TABLE t2 USING INDEX t2i1 (~1000000 rows)}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)}
+}
+do_eqp_test 4.2.3 {
+ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY 1
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 2 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION)}
+}
+do_eqp_test 4.2.4 {
+ SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 1
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 2 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (INTERSECT)}
+}
+do_eqp_test 4.2.5 {
+ SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 1
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 1 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 2 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)}
+}
+
+do_eqp_test 4.3.1 {
+ SELECT x FROM t1 UNION SELECT x FROM t2
+} {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)}
+}
+
+do_eqp_test 4.3.2 {
+ SELECT x FROM t1 UNION SELECT x FROM t2 UNION SELECT x FROM t1
+} {
+ 2 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 3 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (UNION)}
+ 4 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 4 USING TEMP B-TREE (UNION)}
+}
+do_eqp_test 4.3.3 {
+ SELECT x FROM t1 UNION SELECT x FROM t2 UNION SELECT x FROM t1 ORDER BY 1
+} {
+ 2 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 2 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 3 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
+ 1 0 0 {COMPOUND SUBQUERIES 2 AND 3 (UNION)}
+ 4 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 4 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 4 (UNION)}
+}
+
+#-------------------------------------------------------------------------
+# This next block of tests verifies that the examples on the
+# lang_explain.html page are correct.
+#
+drop_all_tables
+
+# EVIDENCE-OF: R-64208-08323 sqlite> EXPLAIN QUERY PLAN SELECT a, b
+# FROM t1 WHERE a=1; 0|0|0|SCAN TABLE t1 (~100000 rows)
+do_execsql_test 5.1.0 { CREATE TABLE t1(a, b) }
+det 5.1.1 "SELECT a, b FROM t1 WHERE a=1" {
+ 0 0 0 {SCAN TABLE t1 (~100000 rows)}
+}
+
+# EVIDENCE-OF: R-09022-44606 sqlite> CREATE INDEX i1 ON t1(a);
+# sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1;
+# 0|0|0|SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)
+do_execsql_test 5.2.0 { CREATE INDEX i1 ON t1(a) }
+det 5.2.1 "SELECT a, b FROM t1 WHERE a=1" {
+ 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)}
+}
+
+# EVIDENCE-OF: R-62228-34103 sqlite> CREATE INDEX i2 ON t1(a, b);
+# sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1;
+# 0|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)
+do_execsql_test 5.3.0 { CREATE INDEX i2 ON t1(a, b) }
+det 5.3.1 "SELECT a, b FROM t1 WHERE a=1" {
+ 0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)}
+}
+
+# EVIDENCE-OF: R-22253-05302 sqlite> EXPLAIN QUERY PLAN SELECT t1.*,
+# t2.* FROM t1, t2 WHERE t1.a=1 AND t1.b>2; 0|0|0|SEARCH TABLE t1
+# USING COVERING INDEX i2 (a=? AND b>?) (~3 rows) 0|1|1|SCAN TABLE t2
+# (~1000000 rows)
+do_execsql_test 5.4.0 {CREATE TABLE t2(c, d)}
+det 5.4.1 "SELECT t1.*, t2.* FROM t1, t2 WHERE t1.a=1 AND t1.b>2" {
+ 0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=? AND b>?) (~2 rows)}
+ 0 1 1 {SCAN TABLE t2 (~1000000 rows)}
+}
+
+# EVIDENCE-OF: R-21040-07025 sqlite> EXPLAIN QUERY PLAN SELECT t1.*,
+# t2.* FROM t2, t1 WHERE t1.a=1 AND t1.b>2; 0|0|1|SEARCH TABLE t1
+# USING COVERING INDEX i2 (a=? AND b>?) (~3 rows) 0|1|0|SCAN TABLE t2
+# (~1000000 rows)
+det 5.5 "SELECT t1.*, t2.* FROM t2, t1 WHERE t1.a=1 AND t1.b>2" {
+ 0 0 1 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=? AND b>?) (~2 rows)}
+ 0 1 0 {SCAN TABLE t2 (~1000000 rows)}
+}
+
+# EVIDENCE-OF: R-39007-61103 sqlite> CREATE INDEX i3 ON t1(b);
+# sqlite> EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=1 OR b=2;
+# 0|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)
+# 0|0|0|SEARCH TABLE t1 USING INDEX i3 (b=?) (~10 rows)
+do_execsql_test 5.5.0 {CREATE INDEX i3 ON t1(b)}
+det 5.6.1 "SELECT * FROM t1 WHERE a=1 OR b=2" {
+ 0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)}
+ 0 0 0 {SEARCH TABLE t1 USING INDEX i3 (b=?) (~10 rows)}
+}
+
+# EVIDENCE-OF: R-33025-54904 sqlite> EXPLAIN QUERY PLAN SELECT c, d
+# FROM t2 ORDER BY c; 0|0|0|SCAN TABLE t2 (~1000000 rows) 0|0|0|USE TEMP
+# B-TREE FOR ORDER BY
+det 5.7 "SELECT c, d FROM t2 ORDER BY c" {
+ 0 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+
+# EVIDENCE-OF: R-38854-22809 sqlite> CREATE INDEX i4 ON t2(c);
+# sqlite> EXPLAIN QUERY PLAN SELECT c, d FROM t2 ORDER BY c;
+# 0|0|0|SCAN TABLE t2 USING INDEX i4 (~1000000 rows)
+do_execsql_test 5.8.0 {CREATE INDEX i4 ON t2(c)}
+det 5.8.1 "SELECT c, d FROM t2 ORDER BY c" {
+ 0 0 0 {SCAN TABLE t2 USING INDEX i4 (~1000000 rows)}
+}
+
+# EVIDENCE-OF: R-29884-43993 sqlite> EXPLAIN QUERY PLAN SELECT
+# (SELECT b FROM t1 WHERE a=0), (SELECT a FROM t1 WHERE b=t2.c) FROM t2;
+# 0|0|0|SCAN TABLE t2 (~1000000 rows) 0|0|0|EXECUTE SCALAR SUBQUERY 1
+# 1|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)
+# 0|0|0|EXECUTE CORRELATED SCALAR SUBQUERY 2 2|0|0|SEARCH TABLE t1 USING
+# INDEX i3 (b=?) (~10 rows)
+det 5.9 {
+ SELECT (SELECT b FROM t1 WHERE a=0), (SELECT a FROM t1 WHERE b=t2.c) FROM t2
+} {
+ 0 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 0 0 0 {EXECUTE SCALAR SUBQUERY 1}
+ 1 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)}
+ 0 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 2}
+ 2 0 0 {SEARCH TABLE t1 USING INDEX i3 (b=?) (~10 rows)}
+}
+
+# EVIDENCE-OF: R-17911-16445 sqlite> EXPLAIN QUERY PLAN SELECT
+# count(*) FROM (SELECT max(b) AS x FROM t1 GROUP BY a) GROUP BY x;
+# 1|0|0|SCAN TABLE t1 USING COVERING INDEX i2 (~1000000 rows) 0|0|0|SCAN
+# SUBQUERY 1 (~1000000 rows) 0|0|0|USE TEMP B-TREE FOR GROUP BY
+det 5.10 {
+ SELECT count(*) FROM (SELECT max(b) AS x FROM t1 GROUP BY a) GROUP BY x
+} {
+ 1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2 (~1000000 rows)}
+ 0 0 0 {SCAN SUBQUERY 1 (~100 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR GROUP BY}
+}
+
+# EVIDENCE-OF: R-18544-33103 sqlite> EXPLAIN QUERY PLAN SELECT * FROM
+# (SELECT * FROM t2 WHERE c=1), t1; 0|0|0|SEARCH TABLE t2 USING INDEX i4
+# (c=?) (~10 rows) 0|1|1|SCAN TABLE t1 (~1000000 rows)
+det 5.11 "SELECT * FROM (SELECT * FROM t2 WHERE c=1), t1" {
+ 0 0 0 {SEARCH TABLE t2 USING INDEX i4 (c=?) (~10 rows)}
+ 0 1 1 {SCAN TABLE t1 (~1000000 rows)}
+}
+
+# EVIDENCE-OF: R-40701-42164 sqlite> EXPLAIN QUERY PLAN SELECT a FROM
+# t1 UNION SELECT c FROM t2; 1|0|0|SCAN TABLE t1 (~1000000 rows)
+# 2|0|0|SCAN TABLE t2 (~1000000 rows) 0|0|0|COMPOUND SUBQUERIES 1 AND 2
+# USING TEMP B-TREE (UNION)
+det 5.12 "SELECT a FROM t1 UNION SELECT c FROM t2" {
+ 1 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)}
+}
+
+# EVIDENCE-OF: R-61538-24748 sqlite> EXPLAIN QUERY PLAN SELECT a FROM
+# t1 EXCEPT SELECT d FROM t2 ORDER BY 1; 1|0|0|SCAN TABLE t1 USING
+# COVERING INDEX i2 (~1000000 rows) 2|0|0|SCAN TABLE t2 (~1000000 rows)
+# 2|0|0|USE TEMP B-TREE FOR ORDER BY 0|0|0|COMPOUND SUBQUERIES 1 AND 2
+# (EXCEPT)
+det 5.13 "SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1" {
+ 1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2 (~1000000 rows)}
+ 2 0 0 {SCAN TABLE t2 (~1000000 rows)}
+ 2 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)}
+}
+
+
+#-------------------------------------------------------------------------
+# The following tests - eqp-6.* - test that the example C code on
+# documentation page eqp.html works. The C code is duplicated in test1.c
+# and wrapped in Tcl command [print_explain_query_plan]
+#
+set boilerplate {
+ proc explain_query_plan {db sql} {
+ set stmt [sqlite3_prepare_v2 db $sql -1 DUMMY]
+ print_explain_query_plan $stmt
+ sqlite3_finalize $stmt
+ }
+ sqlite3 db test.db
+ explain_query_plan db {%SQL%}
+ db close
+ exit
+}
+
+# Do a "Print Explain Query Plan" test.
+proc do_peqp_test {tn sql res} {
+ set fd [open script.tcl w]
+ puts $fd [string map [list %SQL% $sql] $::boilerplate]
+ close $fd
+
+ uplevel do_test $tn [list {
+ set fd [open "|[info nameofexec] script.tcl"]
+ set data [read $fd]
+ close $fd
+ set data
+ }] [list $res]
+}
+
+do_peqp_test 6.1 {
+ SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1
+} [string trimleft {
+1 0 0 SCAN TABLE t1 USING COVERING INDEX i2 (~1000000 rows)
+2 0 0 SCAN TABLE t2 (~1000000 rows)
+2 0 0 USE TEMP B-TREE FOR ORDER BY
+0 0 0 COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)
+}]
+
+#-------------------------------------------------------------------------
+# The following tests - eqp-7.* - test that queries that use the OP_Count
+# optimization return something sensible with EQP.
+#
+drop_all_tables
+
+do_execsql_test 7.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ CREATE INDEX i1 ON t2(a);
+}
+
+det 7.1 "SELECT count(*) FROM t1" {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+}
+
+det 7.2 "SELECT count(*) FROM t2" {
+ 0 0 0 {SCAN TABLE t2 USING COVERING INDEX i1(~1000000 rows)}
+}
+
+do_execsql_test 7.3 {
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+
+ INSERT INTO t2 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ INSERT INTO t2 VALUES(5, 6);
+
+ ANALYZE;
+}
+
+db close
+sqlite3 db test.db
+
+det 7.4 "SELECT count(*) FROM t1" {
+ 0 0 0 {SCAN TABLE t1 (~2 rows)}
+}
+
+det 7.5 "SELECT count(*) FROM t2" {
+ 0 0 0 {SCAN TABLE t2 USING COVERING INDEX i1(~3 rows)}
+}
+
+
+finish_test
diff --git a/test/errmsg.test b/test/errmsg.test
new file mode 100644
index 0000000..9f8409b
--- /dev/null
+++ b/test/errmsg.test
@@ -0,0 +1,116 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# Test that if sqlite3_prepare_v2() is used to prepare a query, the
+# error-message associated with an sqlite3_step() error is available
+# immediately. Whereas if sqlite3_prepare() is used, it is not available
+# until sqlite3_finalize() or sqlite3_reset() has been called.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix errmsg
+
+# Test organization:
+#
+# errmsg-1.* User-defined SQL function errors
+# errmsg-2.* Errors generated by the VDBE (constraint failures etc.)
+# errmsg-3.* SQLITE_SCHEMA and statement recompilation errors.
+#
+
+proc error_messages_worker {prepare sql schema} {
+ set ret [list]
+
+ set stmt [$prepare db $sql -1 dummy]
+ execsql $schema
+ lappend ret [sqlite3_step $stmt]
+ lappend ret [sqlite3_errmsg db]
+ lappend ret [sqlite3_finalize $stmt]
+ lappend ret [sqlite3_errmsg db]
+
+ set ret
+}
+
+proc error_messages_v2 {sql {schema {}}} {
+ error_messages_worker sqlite3_prepare_v2 $sql $schema
+}
+
+proc error_messages {sql {schema {}}} {
+ error_messages_worker sqlite3_prepare $sql $schema
+}
+
+proc sql_error {msg} { error $msg }
+db func sql_error sql_error
+
+#-------------------------------------------------------------------------
+# Test error messages returned by user-defined SQL functions.
+#
+do_test 1.1 {
+ error_messages "SELECT sql_error('custom message')"
+} [list {*}{
+ SQLITE_ERROR {SQL logic error or missing database}
+ SQLITE_ERROR {custom message}
+}]
+do_test 1.2 {
+ error_messages_v2 "SELECT sql_error('custom message')"
+} [list {*}{
+ SQLITE_ERROR {custom message}
+ SQLITE_ERROR {custom message}
+}]
+
+#-------------------------------------------------------------------------
+# Test error messages generated directly by VDBE code (e.g. constraint
+# failures).
+#
+do_execsql_test 2.1 {
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 VALUES('abc', 'def');
+}
+do_test 2.2 {
+ error_messages "INSERT INTO t1 VALUES('ghi', 'def')"
+} [list {*}{
+ SQLITE_ERROR {SQL logic error or missing database}
+ SQLITE_CONSTRAINT {column b is not unique}
+}]
+do_test 2.3 {
+ error_messages_v2 "INSERT INTO t1 VALUES('ghi', 'def')"
+} [list {*}{
+ SQLITE_CONSTRAINT {column b is not unique}
+ SQLITE_CONSTRAINT {column b is not unique}
+}]
+
+#-------------------------------------------------------------------------
+# Test SQLITE_SCHEMA errors. And, for _v2(), test that if the schema
+# change invalidates the SQL statement itself the error message is returned
+# correctly.
+#
+do_execsql_test 3.1.1 {
+ CREATE TABLE t2(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t2 VALUES('abc', 'def');
+}
+do_test 3.1.2 {
+ error_messages "SELECT a FROM t2" "DROP TABLE t2"
+} [list {*}{
+ SQLITE_ERROR {SQL logic error or missing database}
+ SQLITE_SCHEMA {database schema has changed}
+}]
+do_execsql_test 3.2.1 {
+ CREATE TABLE t2(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t2 VALUES('abc', 'def');
+}
+do_test 3.2.2 {
+ error_messages_v2 "SELECT a FROM t2" "DROP TABLE t2"
+} [list {*}{
+ SQLITE_ERROR {no such table: t2}
+ SQLITE_ERROR {no such table: t2}
+}]
+
+finish_test
diff --git a/test/eval.test b/test/eval.test
new file mode 100644
index 0000000..912dc82
--- /dev/null
+++ b/test/eval.test
@@ -0,0 +1,75 @@
+# 2008 July 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file experiments with recursion using the "test_eval()" SQL function
+# in order to make sure that SQLite is reentrant.
+#
+# $Id: eval.test,v 1.2 2008/10/13 10:37:50 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table to work with.
+#
+do_test eval-1.1 {
+ execsql {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 SELECT x+2 FROM t1;
+ INSERT INTO t1 SELECT x+4 FROM t1;
+ INSERT INTO t1 SELECT x+8 FROM t1;
+ INSERT INTO t1 SELECT x+16 FROM t1;
+ INSERT INTO t1 SELECT x+32 FROM t1;
+ INSERT INTO t1 SELECT x+64 FROM t1;
+ INSERT INTO t1 SELECT x+128 FROM t1;
+ INSERT INTO t1 SELECT x+256 FROM t1;
+ SELECT count(*), max(x) FROM t1;
+ }
+} {512 512}
+do_test eval-1.2 {
+ execsql {
+ SELECT x, test_eval('SELECT max(x) FROM t1 WHERE x<' || x) FROM t1 LIMIT 5
+ }
+} {1 {} 2 1 3 2 4 3 5 4}
+
+# Delete a row out from under a read cursor in the middle of
+# collecting the arguments for a single row in a result set.
+# Verify that subsequent rows come out as NULL.
+#
+do_test eval-2.1 {
+ execsql {
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;
+ SELECT x, test_eval('DELETE FROM t2 WHERE x='||x), y FROM t2;
+ }
+} {1 {} {} 2 {} {} 3 {} {} 4 {} {}}
+do_test eval-2.2 {
+ execsql {
+ SELECT * FROM t2
+ }
+} {}
+
+# Modify a row while it is being read.
+#
+do_test eval-3.1 {
+ execsql {
+ INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;
+ SELECT x, test_eval('UPDATE t2 SET y=y+100 WHERE x='||x), y FROM t2;
+ }
+} {1 {} 102 2 {} 103 3 {} 104 4 {} 105}
+
+do_test eval-4.1 {
+ execsql { SELECT test_eval('SELECT "abcdefghij"') }
+} {abcdefghij}
+
+finish_test
diff --git a/test/exclusive.test b/test/exclusive.test
new file mode 100644
index 0000000..ffde891
--- /dev/null
+++ b/test/exclusive.test
@@ -0,0 +1,509 @@
+# 2007 March 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of these tests is exclusive access mode (i.e. the thing activated by
+# "PRAGMA locking_mode = EXCLUSIVE").
+#
+# $Id: exclusive.test,v 1.15 2009/06/26 12:30:40 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!pager_pragmas} {
+ finish_test
+ return
+}
+
+forcedelete test2.db-journal
+forcedelete test2.db
+forcedelete test3.db-journal
+forcedelete test3.db
+forcedelete test4.db-journal
+forcedelete test4.db
+
+#----------------------------------------------------------------------
+# Test cases exclusive-1.X test the PRAGMA logic.
+#
+do_test exclusive-1.0 {
+ execsql {
+ pragma locking_mode;
+ pragma main.locking_mode;
+ pragma temp.locking_mode;
+ }
+} [list normal normal exclusive]
+do_test exclusive-1.1 {
+ execsql {
+ pragma locking_mode = exclusive;
+ }
+} {exclusive}
+do_test exclusive-1.2 {
+ execsql {
+ pragma locking_mode;
+ pragma main.locking_mode;
+ pragma temp.locking_mode;
+ }
+} [list exclusive exclusive exclusive]
+do_test exclusive-1.3 {
+ execsql {
+ pragma locking_mode = normal;
+ }
+} {normal}
+do_test exclusive-1.4 {
+ execsql {
+ pragma locking_mode;
+ pragma main.locking_mode;
+ pragma temp.locking_mode;
+ }
+} [list normal normal exclusive]
+do_test exclusive-1.5 {
+ execsql {
+ pragma locking_mode = invalid;
+ }
+} {normal}
+do_test exclusive-1.6 {
+ execsql {
+ pragma locking_mode;
+ pragma main.locking_mode;
+ pragma temp.locking_mode;
+ }
+} [list normal normal exclusive]
+ifcapable attach {
+ do_test exclusive-1.7 {
+ execsql {
+ pragma locking_mode = exclusive;
+ ATTACH 'test2.db' as aux;
+ }
+ execsql {
+ pragma main.locking_mode;
+ pragma aux.locking_mode;
+ }
+ } {exclusive exclusive}
+ do_test exclusive-1.8 {
+ execsql {
+ pragma main.locking_mode = normal;
+ }
+ execsql {
+ pragma main.locking_mode;
+ pragma temp.locking_mode;
+ pragma aux.locking_mode;
+ }
+ } [list normal exclusive exclusive]
+ do_test exclusive-1.9 {
+ execsql {
+ pragma locking_mode;
+ }
+ } {exclusive}
+ do_test exclusive-1.10 {
+ execsql {
+ ATTACH 'test3.db' as aux2;
+ }
+ execsql {
+ pragma main.locking_mode;
+ pragma aux.locking_mode;
+ pragma aux2.locking_mode;
+ }
+ } {normal exclusive exclusive}
+ do_test exclusive-1.11 {
+ execsql {
+ pragma aux.locking_mode = normal;
+ }
+ execsql {
+ pragma main.locking_mode;
+ pragma aux.locking_mode;
+ pragma aux2.locking_mode;
+ }
+ } {normal normal exclusive}
+ do_test exclusive-1.12 {
+ execsql {
+ pragma locking_mode = normal;
+ }
+ execsql {
+ pragma main.locking_mode;
+ pragma temp.locking_mode;
+ pragma aux.locking_mode;
+ pragma aux2.locking_mode;
+ }
+ } [list normal exclusive normal normal]
+ do_test exclusive-1.13 {
+ execsql {
+ ATTACH 'test4.db' as aux3;
+ }
+ execsql {
+ pragma main.locking_mode;
+ pragma temp.locking_mode;
+ pragma aux.locking_mode;
+ pragma aux2.locking_mode;
+ pragma aux3.locking_mode;
+ }
+ } [list normal exclusive normal normal normal]
+
+ do_test exclusive-1.99 {
+ execsql {
+ DETACH aux;
+ DETACH aux2;
+ DETACH aux3;
+ }
+ } {}
+}
+
+#----------------------------------------------------------------------
+# Test cases exclusive-2.X verify that connections in exclusive
+# locking_mode do not relinquish locks.
+#
+do_test exclusive-2.0 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ PRAGMA locking_mode = exclusive;
+ }
+} {exclusive}
+do_test exclusive-2.1 {
+ sqlite3 db2 test.db
+ execsql {
+ INSERT INTO abc VALUES(4, 5, 6);
+ SELECT * FROM abc;
+ } db2
+} {1 2 3 4 5 6}
+do_test exclusive-2.2 {
+ # This causes connection 'db' (in exclusive mode) to establish
+ # a shared-lock on the db. The other connection should now be
+ # locked out as a writer.
+ execsql {
+ SELECT * FROM abc;
+ } db
+} {1 2 3 4 5 6}
+do_test exclusive-2.4 {
+ execsql {
+ SELECT * FROM abc;
+ } db2
+} {1 2 3 4 5 6}
+do_test exclusive-2.5 {
+ catchsql {
+ INSERT INTO abc VALUES(7, 8, 9);
+ } db2
+} {1 {database is locked}}
+sqlite3_soft_heap_limit 0
+do_test exclusive-2.6 {
+ # Because connection 'db' only has a shared-lock, the other connection
+ # will be able to get a RESERVED, but will fail to upgrade to EXCLUSIVE.
+ execsql {
+ BEGIN;
+ INSERT INTO abc VALUES(7, 8, 9);
+ } db2
+ catchsql {
+ COMMIT
+ } db2
+} {1 {database is locked}}
+do_test exclusive-2.7 {
+ catchsql {
+ COMMIT
+ } db2
+} {1 {database is locked}}
+do_test exclusive-2.8 {
+ execsql {
+ ROLLBACK;
+ } db2
+} {}
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+
+do_test exclusive-2.9 {
+ # Write the database to establish the exclusive lock with connection 'db.
+ execsql {
+ INSERT INTO abc VALUES(7, 8, 9);
+ } db
+ catchsql {
+ SELECT * FROM abc;
+ } db2
+} {1 {database is locked}}
+do_test exclusive-2.10 {
+ # Changing the locking-mode does not release any locks.
+ execsql {
+ PRAGMA locking_mode = normal;
+ } db
+ catchsql {
+ SELECT * FROM abc;
+ } db2
+} {1 {database is locked}}
+do_test exclusive-2.11 {
+ # After changing the locking mode, accessing the db releases locks.
+ execsql {
+ SELECT * FROM abc;
+ } db
+ execsql {
+ SELECT * FROM abc;
+ } db2
+} {1 2 3 4 5 6 7 8 9}
+db2 close
+
+#----------------------------------------------------------------------
+# Tests exclusive-3.X - test that a connection in exclusive mode
+# truncates instead of deletes the journal file when committing
+# a transaction.
+#
+# These tests are not run on windows because the windows backend
+# opens the journal file for exclusive access, preventing its contents
+# from being inspected externally.
+#
+if {$tcl_platform(platform) != "windows"} {
+
+ # Return a list of two booleans (either 0 or 1). The first is true
+ # if the named file exists. The second is true only if the file
+ # exists and the first 28 bytes contain at least one non-zero byte.
+ #
+ proc filestate {fname} {
+ set exists 0
+ set content 0
+ if {[file exists $fname]} {
+ set exists 1
+ set hdr [hexio_read $fname 0 28]
+ set content [expr {0==[string match $hdr [string repeat 0 56]]}]
+ }
+ list $exists $content
+ }
+
+ do_test exclusive-3.0 {
+ filestate test.db-journal
+ } {0 0}
+ do_test exclusive-3.1 {
+ execsql {
+ PRAGMA locking_mode = exclusive;
+ BEGIN;
+ DELETE FROM abc;
+ }
+ filestate test.db-journal
+ } {1 1}
+ do_test exclusive-3.2 {
+ execsql {
+ COMMIT;
+ }
+ filestate test.db-journal
+ } {1 0}
+ do_test exclusive-3.3 {
+ execsql {
+ INSERT INTO abc VALUES('A', 'B', 'C');
+ SELECT * FROM abc;
+ }
+ } {A B C}
+ do_test exclusive-3.4 {
+ execsql {
+ BEGIN;
+ UPDATE abc SET a = 1, b = 2, c = 3;
+ ROLLBACK;
+ SELECT * FROM abc;
+ }
+ } {A B C}
+ do_test exclusive-3.5 {
+ filestate test.db-journal
+ } {1 0}
+ do_test exclusive-3.6 {
+ execsql {
+ PRAGMA locking_mode = normal;
+ SELECT * FROM abc;
+ }
+ filestate test.db-journal
+ } {0 0}
+}
+
+#----------------------------------------------------------------------
+# Tests exclusive-4.X - test that rollback works correctly when
+# in exclusive-access mode.
+#
+
+# The following procedure computes a "signature" for table "t3". If
+# T3 changes in any way, the signature should change.
+#
+# This is used to test ROLLBACK. We gather a signature for t3, then
+# make lots of changes to t3, then rollback and take another signature.
+# The two signatures should be the same.
+#
+proc signature {} {
+ return [db eval {SELECT count(*), md5sum(x) FROM t3}]
+}
+
+do_test exclusive-4.0 {
+ execsql { PRAGMA locking_mode = exclusive; }
+ execsql { PRAGMA default_cache_size = 10; }
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(x TEXT);
+ INSERT INTO t3 VALUES(randstr(10,400));
+ INSERT INTO t3 VALUES(randstr(10,400));
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ COMMIT;
+ }
+ execsql {SELECT count(*) FROM t3;}
+} {32}
+
+set ::X [signature]
+do_test exclusive-4.1 {
+ execsql {
+ BEGIN;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ SELECT count(*) FROM t3;
+ ROLLBACK;
+ }
+ signature
+} $::X
+
+do_test exclusive-4.2 {
+ execsql {
+ BEGIN;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ ROLLBACK;
+ }
+ signature
+} $::X
+
+do_test exclusive-4.3 {
+ execsql {
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE random()%10==0;
+ }
+} {}
+
+do_test exclusive-4.4 {
+ catch {set ::X [signature]}
+} {0}
+do_test exclusive-4.5 {
+ execsql {
+ PRAGMA locking_mode = NORMAL;
+ DROP TABLE t3;
+ DROP TABLE abc;
+ }
+} {normal}
+
+#----------------------------------------------------------------------
+# Tests exclusive-5.X - test that statement journals are truncated
+# instead of deleted when in exclusive access mode.
+#
+
+# Close and reopen the database so that the temp database is no
+# longer active.
+#
+db close
+sqlite3 db test.db
+
+# if we're using proxy locks, we use 3 filedescriptors for a db
+# that is open but NOT writing changes, normally
+# sqlite uses 1 (proxy locking adds the conch and the local lock)
+set using_proxy 0
+foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
+ set using_proxy $value
+}
+set extrafds 0
+if {$using_proxy!=0} {
+ set extrafds 2
+}
+
+do_test exclusive-5.0 {
+ execsql {
+ CREATE TABLE abc(a UNIQUE, b UNIQUE, c UNIQUE);
+ BEGIN;
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc SELECT a+1, b+1, c+1 FROM abc;
+ }
+} {}
+do_test exclusive-5.1 {
+ # Three files are open: The db, journal and statement-journal.
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-$extrafds
+} [expr 3 - ($TEMP_STORE>=2)]
+do_test exclusive-5.2 {
+ execsql {
+ COMMIT;
+ }
+ # One file open: the db.
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-$extrafds
+} {1}
+do_test exclusive-5.3 {
+ execsql {
+ PRAGMA locking_mode = exclusive;
+ BEGIN;
+ INSERT INTO abc VALUES(5, 6, 7);
+ }
+ # Two files open: the db and journal.
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-$extrafds
+} {2}
+do_test exclusive-5.4 {
+ execsql {
+ INSERT INTO abc SELECT a+10, b+10, c+10 FROM abc;
+ }
+ # Three files are open: The db, journal and statement-journal.
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-$extrafds
+} [expr 3 - ($TEMP_STORE>=2)]
+do_test exclusive-5.5 {
+ execsql {
+ COMMIT;
+ }
+ # Three files are still open: The db, journal and statement-journal.
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-$extrafds
+} [expr 3 - ($TEMP_STORE>=2)]
+do_test exclusive-5.6 {
+ execsql {
+ PRAGMA locking_mode = normal;
+ SELECT * FROM abc;
+ }
+} {normal 1 2 3 2 3 4 5 6 7 11 12 13 12 13 14 15 16 17}
+do_test exclusive-5.7 {
+ # Just the db open.
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-$extrafds
+} {1}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test exclusive-6.1 {
+ CREATE TABLE t4(a, b);
+ INSERT INTO t4 VALUES('Eden', 1955);
+ BEGIN;
+ INSERT INTO t4 VALUES('Macmillan', 1957);
+ INSERT INTO t4 VALUES('Douglas-Home', 1963);
+ INSERT INTO t4 VALUES('Wilson', 1964);
+}
+do_test exclusive-6.2 {
+ forcedelete test2.db test2.db-journal
+ copy_file test.db test2.db
+ copy_file test.db-journal test2.db-journal
+ sqlite3 db test2.db
+} {}
+
+do_execsql_test exclusive-6.3 {
+ PRAGMA locking_mode = EXCLUSIVE;
+ SELECT * FROM t4;
+} {exclusive Eden 1955}
+
+do_test exclusive-6.4 {
+ db close
+ forcedelete test.db test.db-journal
+ set fd [open test.db-journal w]
+ puts $fd x
+ close $fd
+ sqlite3 db test.db
+} {}
+
+do_execsql_test exclusive-6.5 {
+ PRAGMA locking_mode = EXCLUSIVE;
+ SELECT * FROM sqlite_master;
+} {exclusive}
+
+finish_test
+
diff --git a/test/exclusive2.test b/test/exclusive2.test
new file mode 100644
index 0000000..2208da5
--- /dev/null
+++ b/test/exclusive2.test
@@ -0,0 +1,317 @@
+# 2007 March 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# $Id: exclusive2.test,v 1.10 2008/11/27 02:22:11 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+ifcapable {!pager_pragmas} {
+ finish_test
+ return
+}
+
+# This module does not work right if the cache spills at unexpected
+# moments. So disable the soft-heap-limit.
+#
+sqlite3_soft_heap_limit 0
+
+proc pagerChangeCounter {filename new {fd ""}} {
+ if {$fd==""} {
+ set fd [open $filename RDWR]
+ fconfigure $fd -translation binary -encoding binary
+ set needClose 1
+ } else {
+ set needClose 0
+ }
+ if {$new ne ""} {
+ seek $fd 24
+ set a [expr {($new&0xFF000000)>>24}]
+ set b [expr {($new&0x00FF0000)>>16}]
+ set c [expr {($new&0x0000FF00)>>8}]
+ set d [expr {($new&0x000000FF)}]
+ puts -nonewline $fd [binary format cccc $a $b $c $d]
+ flush $fd
+ }
+
+ seek $fd 24
+ foreach {a b c d} [list 0 0 0 0] {}
+ binary scan [read $fd 4] cccc a b c d
+ set ret [expr ($a&0x000000FF)<<24]
+ incr ret [expr ($b&0x000000FF)<<16]
+ incr ret [expr ($c&0x000000FF)<<8]
+ incr ret [expr ($d&0x000000FF)<<0]
+
+ if {$needClose} {close $fd}
+ return $ret
+}
+
+proc readPagerChangeCounter {filename} {
+ set fd [open $filename RDONLY]
+ fconfigure $fd -translation binary -encoding binary
+
+ seek $fd 24
+ foreach {a b c d} [list 0 0 0 0] {}
+ binary scan [read $fd 4] cccc a b c d
+ set ret [expr ($a&0x000000FF)<<24]
+ incr ret [expr ($b&0x000000FF)<<16]
+ incr ret [expr ($c&0x000000FF)<<8]
+ incr ret [expr ($d&0x000000FF)<<0]
+
+ close $fd
+ return $ret
+}
+
+
+proc t1sig {{db db}} {
+ execsql {SELECT count(*), md5sum(a) FROM t1} $db
+}
+do_test exclusive2-1.0 {
+ readPagerChangeCounter test.db
+} {0}
+
+#-----------------------------------------------------------------------
+# The following tests - exclusive2-1.X - check that:
+#
+# 1-3: Build a database with connection 1, calculate a signature.
+# 4-7: Modify the database using a second connection in a way that
+# does not modify the freelist, then reset the pager change-counter
+# to the value it had before the modifications.
+# 8: Check that using the first connection, the database signature
+# is still the same. This is because it uses the in-memory cache.
+# It can't tell the db has changed because we reset the change-counter.
+# 9: Increment the change-counter.
+# 10: Ensure that the first connection now sees the updated database. It
+# sees the change-counter has been incremented and discards the
+# invalid in-memory cache.
+#
+# This will only work if the database cache is large enough to hold
+# the entire database. In the case of 1024 byte pages, this means
+# the cache size must be at least 17. Otherwise, some pages will be
+# loaded from the database file in step 8.
+#
+# For similar reasons, this test does not work with the memsubsys1 permutation.
+# Permutation memsubsys1 configures the pcache subsystem to use a static
+# allocation of 24 pages (shared between all pagers). This is not enough for
+# this test.
+#
+do_test exclusive2-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1(a) VALUES(randstr(10, 400));
+ INSERT INTO t1(a) VALUES(randstr(10, 400));
+ INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
+ INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
+ INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
+ INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
+ INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+} {64}
+do_test exclusive2-1.2.1 {
+ # Make sure the pager cache is large enough to store the
+ # entire database.
+ set nPage [expr [file size test.db]/1024]
+ if {$::SQLITE_DEFAULT_CACHE_SIZE < $nPage} {
+ execsql "PRAGMA cache_size = $nPage"
+ }
+ expr {[execsql {PRAGMA cache_size}] >= $nPage}
+} {1}
+do_test exclusive2-1.2 {
+ set ::sig [t1sig]
+ readPagerChangeCounter test.db
+} {1}
+do_test exclusive2-1.3 {
+ t1sig
+} $::sig
+do_test exclusive2-1.4 {
+ sqlite3 db2 test.db
+ t1sig db2
+} $::sig
+do_test exclusive2-1.5 {
+ execsql {
+ UPDATE t1 SET b=a, a=NULL;
+ } db2
+ expr {[t1sig db2] eq $::sig}
+} 0
+do_test exclusive2-1.6 {
+ readPagerChangeCounter test.db
+} {2}
+do_test exclusive2-1.7 {
+ pagerChangeCounter test.db 1
+} {1}
+if {[permutation] != "memsubsys1"} {
+ do_test exclusive2-1.9 {
+ t1sig
+ expr {[t1sig] eq $::sig}
+ } {1}
+}
+do_test exclusive2-1.10 {
+ pagerChangeCounter test.db 2
+} {2}
+do_test exclusive2-1.11 {
+ expr {[t1sig] eq $::sig}
+} {0}
+db2 close
+
+#--------------------------------------------------------------------
+# These tests - exclusive2-2.X - are similar to exclusive2-1.X,
+# except that they are run with locking_mode=EXCLUSIVE.
+#
+# 1-3: Build a database with exclusive-access connection 1,
+# calculate a signature.
+# 4: Corrupt the database by writing 10000 bytes of garbage
+# starting at the beginning of page 2. Check that connection 1
+# still works. It should be accessing the in-memory cache.
+# 5-6: Modify the dataase change-counter. Connection 1 still works
+# entirely from in-memory cache, because it doesn't check the
+# change-counter.
+# 7-8 Set the locking-mode back to normal. After the db is unlocked,
+# SQLite detects the modified change-counter and discards the
+# in-memory cache. Then it finds the corruption caused in step 4....
+#
+# As above, this test is only applicable if the pager cache is
+# large enough to hold the entire database. With 1024 byte pages,
+# this means 19 pages. We also need to disable the soft-heap-limit
+# to prevent memory-induced cache spills.
+#
+do_test exclusive2-2.1 {
+ execsql {PRAGMA cache_size=1000;}
+ execsql {PRAGMA locking_mode = exclusive;}
+ execsql {
+ BEGIN;
+ DELETE FROM t1;
+ INSERT INTO t1(a) VALUES(randstr(10, 400));
+ INSERT INTO t1(a) VALUES(randstr(10, 400));
+ INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
+ INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
+ INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
+ INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
+ INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+} {64}
+do_test exclusive2-2.2.1 {
+ # Make sure the pager cache is large enough to store the
+ # entire database.
+ set nPage [expr [file size test.db]/1024]
+ if {$::SQLITE_DEFAULT_CACHE_SIZE < $nPage} {
+ execsql "PRAGMA cache_size = $nPage"
+ }
+ expr {[execsql {PRAGMA cache_size}] >= $nPage}
+} {1}
+do_test exclusive2-2.2 {
+ set ::sig [t1sig]
+ readPagerChangeCounter test.db
+} {3}
+do_test exclusive2-2.3 {
+ t1sig
+} $::sig
+
+do_test exclusive2-2.4 {
+ set ::fd [open test.db RDWR]
+ fconfigure $::fd -translation binary
+ seek $::fd 1024
+ puts -nonewline $::fd [string repeat [binary format c 0] 10000]
+ flush $::fd
+ t1sig
+} $::sig
+
+do_test exclusive2-2.5 {
+ pagerChangeCounter test.db 5 $::fd
+} {5}
+do_test exclusive2-2.6 {
+ t1sig
+} $::sig
+do_test exclusive2-2.7 {
+ execsql {PRAGMA locking_mode = normal}
+ t1sig
+} $::sig
+
+do_test exclusive2-2.8 {
+ set rc [catch {t1sig} msg]
+ list $rc $msg
+} {1 {database disk image is malformed}}
+
+#--------------------------------------------------------------------
+# These tests - exclusive2-3.X - verify that the pager change-counter
+# is only incremented by the first change when in exclusive access
+# mode. In normal mode, the change-counter is incremented once
+# per write-transaction.
+#
+
+db close
+catch {close $::fd}
+forcedelete test.db
+forcedelete test.db-journal
+
+do_test exclusive2-3.0 {
+ sqlite3 db test.db
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a UNIQUE);
+ INSERT INTO t1 VALUES(randstr(200, 200));
+ INSERT INTO t1 VALUES(randstr(200, 200));
+ COMMIT;
+ }
+ readPagerChangeCounter test.db
+} {1}
+do_test exclusive2-3.1 {
+ execsql {
+ INSERT INTO t1 VALUES(randstr(200, 200));
+ }
+ readPagerChangeCounter test.db
+} {2}
+do_test exclusive2-3.2 {
+ execsql {
+ INSERT INTO t1 VALUES(randstr(200, 200));
+ }
+ readPagerChangeCounter test.db
+} {3}
+do_test exclusive2-3.3 {
+ execsql {
+ PRAGMA locking_mode = exclusive;
+ INSERT INTO t1 VALUES(randstr(200, 200));
+ }
+ readPagerChangeCounter test.db
+} {4}
+do_test exclusive2-3.4 {
+breakpoint
+ execsql {
+ INSERT INTO t1 VALUES(randstr(200, 200));
+ }
+ readPagerChangeCounter test.db
+} {4}
+do_test exclusive2-3.5 {
+ execsql {
+ PRAGMA locking_mode = normal;
+ INSERT INTO t1 VALUES(randstr(200, 200));
+ }
+ readPagerChangeCounter test.db
+} {4}
+do_test exclusive2-3.6 {
+ execsql {
+ INSERT INTO t1 VALUES(randstr(200, 200));
+ }
+ readPagerChangeCounter test.db
+} {5}
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+
+finish_test
diff --git a/test/exec.test b/test/exec.test
new file mode 100644
index 0000000..dbcc626
--- /dev/null
+++ b/test/exec.test
@@ -0,0 +1,37 @@
+# 2008 Jan 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the sqlite3_exec interface
+#
+# $Id: exec.test,v 1.1 2008/01/21 16:22:46 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test exec-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t1;
+ }
+} {1 2}
+do_test exec-1.2 {
+ sqlite3_exec db {/* comment */;;; SELECT * FROM t1; /* comment */}
+} {0 {a b 1 2}}
+do_test exec-1.3 {
+ sqlite3 db2 test.db
+ db2 eval {CREATE TABLE t2(x, y);}
+ db2 close
+ sqlite3_exec db {SELECT * FROM t1}
+} {0 {a b 1 2}}
+
+finish_test
diff --git a/test/exists.test b/test/exists.test
new file mode 100644
index 0000000..fb73797
--- /dev/null
+++ b/test/exists.test
@@ -0,0 +1,198 @@
+# 2011 April 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the various schema modification statements
+# that feature "IF EXISTS" or "IF NOT EXISTS" clauses.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+
+
+foreach jm {rollback wal} {
+
+ set testprefix exists-$jm
+
+ # This block of tests is targeted at CREATE XXX IF NOT EXISTS statements.
+ #
+ do_multiclient_test tn {
+
+ # TABLE objects.
+ #
+ do_test 1.$tn.1.1 {
+ if {$jm == "wal"} { sql2 { PRAGMA journal_mode = WAL } }
+ sql2 { CREATE TABLE t1(x) }
+ sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) }
+ sql2 { DROP TABLE t1 }
+ sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
+ } {t1}
+
+ do_test 1.$tn.1.2 {
+ sql2 { CREATE TABLE t2(x) }
+ sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 }
+ sql2 { DROP TABLE t2 }
+ sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
+ } {t1 t2}
+
+
+ # INDEX objects.
+ #
+ do_test 1.$tn.2 {
+ sql2 { CREATE INDEX i1 ON t1(a) }
+ sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) }
+ sql2 { DROP INDEX i1 }
+ sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'index' }
+ } {i1}
+
+ # VIEW objects.
+ #
+ do_test 1.$tn.3 {
+ sql2 { CREATE VIEW v1 AS SELECT * FROM t1 }
+ sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 }
+ sql2 { DROP VIEW v1 }
+ sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'view' }
+ } {v1}
+
+ # TRIGGER objects.
+ #
+ do_test $tn.4 {
+ sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
+ sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
+ sql2 { DROP TRIGGER tr1 }
+ sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' }
+ } {tr1}
+ }
+
+ # This block of tests is targeted at DROP XXX IF EXISTS statements.
+ #
+ do_multiclient_test tn {
+
+ # TABLE objects.
+ #
+ do_test 2.$tn.1 {
+ if {$jm == "wal"} { sql1 { PRAGMA journal_mode = WAL } }
+ sql1 { DROP TABLE IF EXISTS t1 }
+ sql2 { CREATE TABLE t1(x) }
+ sql1 { DROP TABLE IF EXISTS t1 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
+ } {}
+
+ # INDEX objects.
+ #
+ do_test 2.$tn.2 {
+ sql1 { CREATE TABLE t2(x) }
+ sql1 { DROP INDEX IF EXISTS i2 }
+ sql2 { CREATE INDEX i2 ON t2(x) }
+ sql1 { DROP INDEX IF EXISTS i2 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'index' }
+ } {}
+
+ # VIEW objects.
+ #
+ do_test 2.$tn.3 {
+ sql1 { DROP VIEW IF EXISTS v1 }
+ sql2 { CREATE VIEW v1 AS SELECT * FROM t2 }
+ sql1 { DROP VIEW IF EXISTS v1 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'view' }
+ } {}
+
+ # TRIGGER objects.
+ #
+ do_test 2.$tn.4 {
+ sql1 { DROP TRIGGER IF EXISTS tr1 }
+ sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
+ sql1 { DROP TRIGGER IF EXISTS tr1 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' }
+ } {}
+ }
+
+ # This block of tests is targeted at DROP XXX IF EXISTS statements with
+ # attached databases.
+ #
+ do_multiclient_test tn {
+
+ forcedelete test.db2
+ do_test 3.$tn.0 {
+ sql1 { ATTACH 'test.db2' AS aux }
+ sql2 { ATTACH 'test.db2' AS aux }
+ } {}
+
+ # TABLE objects.
+ #
+ do_test 3.$tn.1.1 {
+ sql1 { DROP TABLE IF EXISTS aux.t1 }
+ sql2 { CREATE TABLE aux.t1(x) }
+ sql1 { DROP TABLE IF EXISTS aux.t1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' }
+ } {}
+ do_test 3.$tn.1.2 {
+ sql1 { DROP TABLE IF EXISTS t1 }
+ sql2 { CREATE TABLE aux.t1(x) }
+ sql1 { DROP TABLE IF EXISTS t1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' }
+ } {}
+
+ # INDEX objects.
+ #
+ do_test 3.$tn.2.1 {
+ sql1 { CREATE TABLE aux.t2(x) }
+ sql1 { DROP INDEX IF EXISTS aux.i2 }
+ sql2 { CREATE INDEX aux.i2 ON t2(x) }
+ sql1 { DROP INDEX IF EXISTS aux.i2 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'index' }
+ } {}
+ do_test 3.$tn.2.2 {
+ sql1 { DROP INDEX IF EXISTS i2 }
+ sql2 { CREATE INDEX aux.i2 ON t2(x) }
+ sql1 { DROP INDEX IF EXISTS i2 }
+ sql2 { SELECT * FROM aux.sqlite_master WHERE type = 'index' }
+ } {}
+
+ # VIEW objects.
+ #
+ do_test 3.$tn.3.1 {
+ sql1 { DROP VIEW IF EXISTS aux.v1 }
+ sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 }
+ sql1 { DROP VIEW IF EXISTS aux.v1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' }
+ } {}
+ do_test 3.$tn.3.2 {
+ sql1 { DROP VIEW IF EXISTS v1 }
+ sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 }
+ sql1 { DROP VIEW IF EXISTS v1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' }
+ } {}
+
+ # TRIGGER objects.
+ #
+ do_test 3.$tn.4.1 {
+ sql1 { DROP TRIGGER IF EXISTS aux.tr1 }
+ sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
+ sql1 { DROP TRIGGER IF EXISTS aux.tr1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' }
+ } {}
+ do_test 3.$tn.4.2 {
+ sql1 { DROP TRIGGER IF EXISTS tr1 }
+ sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
+ sql1 { DROP TRIGGER IF EXISTS tr1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' }
+ } {}
+ }
+}
+
+
+finish_test
diff --git a/test/expr.test b/test/expr.test
new file mode 100644
index 0000000..cc4c9c6
--- /dev/null
+++ b/test/expr.test
@@ -0,0 +1,943 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing expressions.
+#
+# $Id: expr.test,v 1.67 2009/02/04 03:59:25 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table to work with.
+#
+ifcapable floatingpoint {
+ execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
+ execsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')}
+}
+ifcapable !floatingpoint {
+ execsql {CREATE TABLE test1(i1 int, i2 int, t1 text, t2 text)}
+ execsql {INSERT INTO test1 VALUES(1,2,'hello','world')}
+}
+
+proc test_expr {name settings expr result} {
+ do_test $name [format {
+ execsql {BEGIN; UPDATE test1 SET %s; SELECT %s FROM test1; ROLLBACK;}
+ } $settings $expr] $result
+}
+proc test_realnum_expr {name settings expr result} {
+ do_realnum_test $name [format {
+ execsql {BEGIN; UPDATE test1 SET %s; SELECT %s FROM test1; ROLLBACK;}
+ } $settings $expr] $result
+}
+
+test_expr expr-1.1 {i1=10, i2=20} {i1+i2} 30
+test_expr expr-1.2 {i1=10, i2=20} {i1-i2} -10
+test_expr expr-1.3 {i1=10, i2=20} {i1*i2} 200
+test_expr expr-1.4 {i1=10, i2=20} {i1/i2} 0
+test_expr expr-1.5 {i1=10, i2=20} {i2/i1} 2
+test_expr expr-1.6 {i1=10, i2=20} {i2<i1} 0
+test_expr expr-1.7 {i1=10, i2=20} {i2<=i1} 0
+test_expr expr-1.8 {i1=10, i2=20} {i2>i1} 1
+test_expr expr-1.9 {i1=10, i2=20} {i2>=i1} 1
+test_expr expr-1.10 {i1=10, i2=20} {i2!=i1} 1
+test_expr expr-1.11 {i1=10, i2=20} {i2=i1} 0
+test_expr expr-1.12 {i1=10, i2=20} {i2<>i1} 1
+test_expr expr-1.13 {i1=10, i2=20} {i2==i1} 0
+test_expr expr-1.14 {i1=20, i2=20} {i2<i1} 0
+test_expr expr-1.15 {i1=20, i2=20} {i2<=i1} 1
+test_expr expr-1.16 {i1=20, i2=20} {i2>i1} 0
+test_expr expr-1.17 {i1=20, i2=20} {i2>=i1} 1
+test_expr expr-1.18 {i1=20, i2=20} {i2!=i1} 0
+test_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1
+test_expr expr-1.20 {i1=20, i2=20} {i2<>i1} 0
+test_expr expr-1.21 {i1=20, i2=20} {i2==i1} 1
+ifcapable floatingpoint {
+ test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7.0}
+ test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9.0}
+}
+test_expr expr-1.24 {i1=1, i2=2} {min(i1,i2,i1+i2,i1-i2)} {-1}
+test_expr expr-1.25 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
+test_expr expr-1.26 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
+test_expr expr-1.27 {i1=1, i2=2} {i1==1 AND i2=2} {1}
+test_expr expr-1.28 {i1=1, i2=2} {i1=2 AND i2=1} {0}
+test_expr expr-1.29 {i1=1, i2=2} {i1=1 AND i2=1} {0}
+test_expr expr-1.30 {i1=1, i2=2} {i1=2 AND i2=2} {0}
+test_expr expr-1.31 {i1=1, i2=2} {i1==1 OR i2=2} {1}
+test_expr expr-1.32 {i1=1, i2=2} {i1=2 OR i2=1} {0}
+test_expr expr-1.33 {i1=1, i2=2} {i1=1 OR i2=1} {1}
+test_expr expr-1.34 {i1=1, i2=2} {i1=2 OR i2=2} {1}
+test_expr expr-1.35 {i1=1, i2=2} {i1-i2=-1} {1}
+test_expr expr-1.36 {i1=1, i2=0} {not i1} {0}
+test_expr expr-1.37 {i1=1, i2=0} {not i2} {1}
+test_expr expr-1.38 {i1=1} {-i1} {-1}
+test_expr expr-1.39 {i1=1} {+i1} {1}
+test_expr expr-1.40 {i1=1, i2=2} {+(i2+i1)} {3}
+test_expr expr-1.41 {i1=1, i2=2} {-(i2+i1)} {-3}
+test_expr expr-1.42 {i1=1, i2=2} {i1|i2} {3}
+test_expr expr-1.42b {i1=1, i2=2} {4|2} {6}
+test_expr expr-1.43 {i1=1, i2=2} {i1&i2} {0}
+test_expr expr-1.43b {i1=1, i2=2} {4&5} {4}
+test_expr expr-1.44 {i1=1} {~i1} {-2}
+test_expr expr-1.44b {i1=NULL} {~i1} {{}}
+test_expr expr-1.45a {i1=1, i2=3} {i1<<i2} {8}
+test_expr expr-1.45b {i1=1, i2=-3} {i1>>i2} {8}
+test_expr expr-1.45c {i1=1, i2=0} {i1<<i2} {1}
+test_expr expr-1.45d {i1=1, i2=62} {i1<<i2} {4611686018427387904}
+test_expr expr-1.45e {i1=1, i2=63} {i1<<i2} {-9223372036854775808}
+test_expr expr-1.45f {i1=1, i2=64} {i1<<i2} {0}
+test_expr expr-1.45g {i1=32, i2=-9223372036854775808} {i1>>i2} {0}
+test_expr expr-1.46a {i1=32, i2=3} {i1>>i2} {4}
+test_expr expr-1.46b {i1=32, i2=6} {i1>>i2} {0}
+test_expr expr-1.46c {i1=-32, i2=3} {i1>>i2} {-4}
+test_expr expr-1.46d {i1=-32, i2=100} {i1>>i2} {-1}
+test_expr expr-1.46e {i1=32, i2=-3} {i1>>i2} {256}
+test_expr expr-1.47 {i1=9999999999, i2=8888888888} {i1<i2} 0
+test_expr expr-1.48 {i1=9999999999, i2=8888888888} {i1=i2} 0
+test_expr expr-1.49 {i1=9999999999, i2=8888888888} {i1>i2} 1
+test_expr expr-1.50 {i1=99999999999, i2=99999999998} {i1<i2} 0
+test_expr expr-1.51 {i1=99999999999, i2=99999999998} {i1=i2} 0
+test_expr expr-1.52 {i1=99999999999, i2=99999999998} {i1>i2} 1
+test_expr expr-1.53 {i1=099999999999, i2=99999999999} {i1<i2} 0
+test_expr expr-1.54 {i1=099999999999, i2=99999999999} {i1=i2} 1
+test_expr expr-1.55 {i1=099999999999, i2=99999999999} {i1>i2} 0
+test_expr expr-1.56 {i1=25, i2=11} {i1%i2} 3
+test_expr expr-1.58 {i1=NULL, i2=1} {coalesce(i1+i2,99)} 99
+test_expr expr-1.59 {i1=1, i2=NULL} {coalesce(i1+i2,99)} 99
+test_expr expr-1.60 {i1=NULL, i2=NULL} {coalesce(i1+i2,99)} 99
+test_expr expr-1.61 {i1=NULL, i2=1} {coalesce(i1-i2,99)} 99
+test_expr expr-1.62 {i1=1, i2=NULL} {coalesce(i1-i2,99)} 99
+test_expr expr-1.63 {i1=NULL, i2=NULL} {coalesce(i1-i2,99)} 99
+test_expr expr-1.64 {i1=NULL, i2=1} {coalesce(i1*i2,99)} 99
+test_expr expr-1.65 {i1=1, i2=NULL} {coalesce(i1*i2,99)} 99
+test_expr expr-1.66 {i1=NULL, i2=NULL} {coalesce(i1*i2,99)} 99
+test_expr expr-1.67 {i1=NULL, i2=1} {coalesce(i1/i2,99)} 99
+test_expr expr-1.68 {i1=1, i2=NULL} {coalesce(i1/i2,99)} 99
+test_expr expr-1.69 {i1=NULL, i2=NULL} {coalesce(i1/i2,99)} 99
+test_expr expr-1.70 {i1=NULL, i2=1} {coalesce(i1<i2,99)} 99
+test_expr expr-1.71 {i1=1, i2=NULL} {coalesce(i1>i2,99)} 99
+test_expr expr-1.72 {i1=NULL, i2=NULL} {coalesce(i1<=i2,99)} 99
+test_expr expr-1.73 {i1=NULL, i2=1} {coalesce(i1>=i2,99)} 99
+test_expr expr-1.74 {i1=1, i2=NULL} {coalesce(i1!=i2,99)} 99
+test_expr expr-1.75 {i1=NULL, i2=NULL} {coalesce(i1==i2,99)} 99
+test_expr expr-1.76 {i1=NULL, i2=NULL} {coalesce(not i1,99)} 99
+test_expr expr-1.77 {i1=NULL, i2=NULL} {coalesce(-i1,99)} 99
+test_expr expr-1.78 {i1=NULL, i2=NULL} {coalesce(i1 IS NULL AND i2=5,99)} 99
+test_expr expr-1.79 {i1=NULL, i2=NULL} {coalesce(i1 IS NULL OR i2=5,99)} 1
+test_expr expr-1.80 {i1=NULL, i2=NULL} {coalesce(i1=5 AND i2 IS NULL,99)} 99
+test_expr expr-1.81 {i1=NULL, i2=NULL} {coalesce(i1=5 OR i2 IS NULL,99)} 1
+test_expr expr-1.82 {i1=NULL, i2=3} {coalesce(min(i1,i2,1),99)} 99
+test_expr expr-1.83 {i1=NULL, i2=3} {coalesce(max(i1,i2,1),99)} 99
+test_expr expr-1.84 {i1=3, i2=NULL} {coalesce(min(i1,i2,1),99)} 99
+test_expr expr-1.85 {i1=3, i2=NULL} {coalesce(max(i1,i2,1),99)} 99
+test_expr expr-1.86 {i1=3, i2=8} {5 between i1 and i2} 1
+test_expr expr-1.87 {i1=3, i2=8} {5 not between i1 and i2} 0
+test_expr expr-1.88 {i1=3, i2=8} {55 between i1 and i2} 0
+test_expr expr-1.89 {i1=3, i2=8} {55 not between i1 and i2} 1
+test_expr expr-1.90 {i1=3, i2=NULL} {5 between i1 and i2} {{}}
+test_expr expr-1.91 {i1=3, i2=NULL} {5 not between i1 and i2} {{}}
+test_expr expr-1.92 {i1=3, i2=NULL} {2 between i1 and i2} 0
+test_expr expr-1.93 {i1=3, i2=NULL} {2 not between i1 and i2} 1
+test_expr expr-1.94 {i1=NULL, i2=8} {2 between i1 and i2} {{}}
+test_expr expr-1.95 {i1=NULL, i2=8} {2 not between i1 and i2} {{}}
+test_expr expr-1.94 {i1=NULL, i2=8} {55 between i1 and i2} 0
+test_expr expr-1.95 {i1=NULL, i2=8} {55 not between i1 and i2} 1
+test_expr expr-1.96 {i1=NULL, i2=3} {coalesce(i1<<i2,99)} 99
+test_expr expr-1.97 {i1=32, i2=NULL} {coalesce(i1>>i2,99)} 99
+test_expr expr-1.98 {i1=NULL, i2=NULL} {coalesce(i1|i2,99)} 99
+test_expr expr-1.99 {i1=32, i2=NULL} {coalesce(i1&i2,99)} 99
+test_expr expr-1.100 {i1=1, i2=''} {i1=i2} 0
+test_expr expr-1.101 {i1=0, i2=''} {i1=i2} 0
+
+# Check for proper handling of 64-bit integer values.
+#
+if {[working_64bit_int]} {
+ test_expr expr-1.102 {i1=40, i2=1} {i2<<i1} 1099511627776
+}
+
+ifcapable floatingpoint {
+ test_expr expr-1.103 {i1=0} {(-2147483648.0 % -1)} 0.0
+ test_expr expr-1.104 {i1=0} {(-9223372036854775808.0 % -1)} 0.0
+ test_expr expr-1.105 {i1=0} {(-9223372036854775808.0 / -1)>1} 1
+}
+
+if {[working_64bit_int]} {
+ test_realnum_expr expr-1.106 {i1=0} {-9223372036854775808/-1} 9.22337203685478e+18
+}
+
+test_expr expr-1.107 {i1=0} {-9223372036854775808%-1} 0
+test_expr expr-1.108 {i1=0} {1%0} {{}}
+test_expr expr-1.109 {i1=0} {1/0} {{}}
+
+if {[working_64bit_int]} {
+ test_expr expr-1.110 {i1=0} {-9223372036854775807/-1} 9223372036854775807
+}
+
+test_expr expr-1.111 {i1=NULL, i2=8} {i1 IS i2} 0
+test_expr expr-1.112 {i1=NULL, i2=NULL} {i1 IS i2} 1
+test_expr expr-1.113 {i1=6, i2=NULL} {i1 IS i2} 0
+test_expr expr-1.114 {i1=6, i2=6} {i1 IS i2} 1
+test_expr expr-1.115 {i1=NULL, i2=8} \
+ {CASE WHEN i1 IS i2 THEN 'yes' ELSE 'no' END} no
+test_expr expr-1.116 {i1=NULL, i2=NULL} \
+ {CASE WHEN i1 IS i2 THEN 'yes' ELSE 'no' END} yes
+test_expr expr-1.117 {i1=6, i2=NULL} \
+ {CASE WHEN i1 IS i2 THEN 'yes' ELSE 'no' END} no
+test_expr expr-1.118 {i1=8, i2=8} \
+ {CASE WHEN i1 IS i2 THEN 'yes' ELSE 'no' END} yes
+test_expr expr-1.119 {i1=NULL, i2=8} {i1 IS NOT i2} 1
+test_expr expr-1.120 {i1=NULL, i2=NULL} {i1 IS NOT i2} 0
+test_expr expr-1.121 {i1=6, i2=NULL} {i1 IS NOT i2} 1
+test_expr expr-1.122 {i1=6, i2=6} {i1 IS NOT i2} 0
+test_expr expr-1.123 {i1=NULL, i2=8} \
+ {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} yes
+test_expr expr-1.124 {i1=NULL, i2=NULL} \
+ {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} no
+test_expr expr-1.125 {i1=6, i2=NULL} \
+ {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} yes
+test_expr expr-1.126 {i1=8, i2=8} \
+ {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} no
+
+ifcapable floatingpoint {if {[working_64bit_int]} {
+ test_expr expr-1.200\
+ {i1=9223372036854775806, i2=1} {i1+i2} 9223372036854775807
+ test_realnum_expr expr-1.201\
+ {i1=9223372036854775806, i2=2} {i1+i2} 9.22337203685478e+18
+ test_realnum_expr expr-1.202\
+ {i1=9223372036854775806, i2=100000} {i1+i2} 9.22337203685488e+18
+ test_realnum_expr expr-1.203\
+ {i1=9223372036854775807, i2=0} {i1+i2} 9223372036854775807
+ test_realnum_expr expr-1.204\
+ {i1=9223372036854775807, i2=1} {i1+i2} 9.22337203685478e+18
+ test_realnum_expr expr-1.205\
+ {i2=9223372036854775806, i1=1} {i1+i2} 9223372036854775807
+ test_realnum_expr expr-1.206\
+ {i2=9223372036854775806, i1=2} {i1+i2} 9.22337203685478e+18
+ test_realnum_expr expr-1.207\
+ {i2=9223372036854775806, i1=100000} {i1+i2} 9.22337203685488e+18
+ test_realnum_expr expr-1.208\
+ {i2=9223372036854775807, i1=0} {i1+i2} 9223372036854775807
+ test_realnum_expr expr-1.209\
+ {i2=9223372036854775807, i1=1} {i1+i2} 9.22337203685478e+18
+ test_realnum_expr expr-1.210\
+ {i1=-9223372036854775807, i2=-1} {i1+i2} -9223372036854775808
+ test_realnum_expr expr-1.211\
+ {i1=-9223372036854775807, i2=-2} {i1+i2} -9.22337203685478e+18
+ test_realnum_expr expr-1.212\
+ {i1=-9223372036854775807, i2=-100000} {i1+i2} -9.22337203685488e+18
+ test_realnum_expr expr-1.213\
+ {i1=-9223372036854775808, i2=0} {i1+i2} -9223372036854775808
+ test_realnum_expr expr-1.214\
+ {i1=-9223372036854775808, i2=-1} {i1+i2} -9.22337203685478e+18
+ test_realnum_expr expr-1.215\
+ {i2=-9223372036854775807, i1=-1} {i1+i2} -9223372036854775808
+ test_realnum_expr expr-1.216\
+ {i2=-9223372036854775807, i1=-2} {i1+i2} -9.22337203685478e+18
+ test_realnum_expr expr-1.217\
+ {i2=-9223372036854775807, i1=-100000} {i1+i2} -9.22337203685488e+18
+ test_realnum_expr expr-1.218\
+ {i2=-9223372036854775808, i1=0} {i1+i2} -9223372036854775808
+ test_realnum_expr expr-1.219\
+ {i2=-9223372036854775808, i1=-1} {i1+i2} -9.22337203685478e+18
+ test_realnum_expr expr-1.220\
+ {i1=9223372036854775806, i2=-1} {i1-i2} 9223372036854775807
+ test_realnum_expr expr-1.221\
+ {i1=9223372036854775806, i2=-2} {i1-i2} 9.22337203685478e+18
+ test_realnum_expr expr-1.222\
+ {i1=9223372036854775806, i2=-100000} {i1-i2} 9.22337203685488e+18
+ test_realnum_expr expr-1.223\
+ {i1=9223372036854775807, i2=0} {i1-i2} 9223372036854775807
+ test_realnum_expr expr-1.224\
+ {i1=9223372036854775807, i2=-1} {i1-i2} 9.22337203685478e+18
+ test_realnum_expr expr-1.225\
+ {i2=-9223372036854775806, i1=1} {i1-i2} 9223372036854775807
+ test_realnum_expr expr-1.226\
+ {i2=-9223372036854775806, i1=2} {i1-i2} 9.22337203685478e+18
+ test_realnum_expr expr-1.227\
+ {i2=-9223372036854775806, i1=100000} {i1-i2} 9.22337203685488e+18
+ test_realnum_expr expr-1.228\
+ {i2=-9223372036854775807, i1=0} {i1-i2} 9223372036854775807
+ test_realnum_expr expr-1.229\
+ {i2=-9223372036854775807, i1=1} {i1-i2} 9.22337203685478e+18
+ test_realnum_expr expr-1.230\
+ {i1=-9223372036854775807, i2=1} {i1-i2} -9223372036854775808
+ test_realnum_expr expr-1.231\
+ {i1=-9223372036854775807, i2=2} {i1-i2} -9.22337203685478e+18
+ test_realnum_expr expr-1.232\
+ {i1=-9223372036854775807, i2=100000} {i1-i2} -9.22337203685488e+18
+ test_realnum_expr expr-1.233\
+ {i1=-9223372036854775808, i2=0} {i1-i2} -9223372036854775808
+ test_realnum_expr expr-1.234\
+ {i1=-9223372036854775808, i2=1} {i1-i2} -9.22337203685478e+18
+ test_realnum_expr expr-1.235\
+ {i2=9223372036854775807, i1=-1} {i1-i2} -9223372036854775808
+ test_realnum_expr expr-1.236\
+ {i2=9223372036854775807, i1=-2} {i1-i2} -9.22337203685478e+18
+ test_realnum_expr expr-1.237\
+ {i2=9223372036854775807, i1=-100000} {i1-i2} -9.22337203685488e+18
+ test_realnum_expr expr-1.238\
+ {i2=9223372036854775807, i1=0} {i1-i2} -9223372036854775807
+ test_realnum_expr expr-1.239\
+ {i2=9223372036854775807, i1=-1} {i1-i2} -9223372036854775808
+
+ test_realnum_expr expr-1.250\
+ {i1=4294967296, i2=2147483648} {i1*i2} 9.22337203685478e+18
+ test_realnum_expr expr-1.251\
+ {i1=4294967296, i2=2147483647} {i1*i2} 9223372032559808512
+ test_realnum_expr expr-1.252\
+ {i1=-4294967296, i2=2147483648} {i1*i2} -9223372036854775808
+ test_realnum_expr expr-1.253\
+ {i1=-4294967296, i2=2147483647} {i1*i2} -9223372032559808512
+ test_realnum_expr expr-1.254\
+ {i1=4294967296, i2=-2147483648} {i1*i2} -9223372036854775808
+ test_realnum_expr expr-1.255\
+ {i1=4294967296, i2=-2147483647} {i1*i2} -9223372032559808512
+ test_realnum_expr expr-1.256\
+ {i1=-4294967296, i2=-2147483648} {i1*i2} 9.22337203685478e+18
+ test_realnum_expr expr-1.257\
+ {i1=-4294967296, i2=-2147483647} {i1*i2} 9223372032559808512
+
+}}
+
+ifcapable floatingpoint {
+ test_expr expr-2.1 {r1=1.23, r2=2.34} {r1+r2} 3.57
+ test_expr expr-2.2 {r1=1.23, r2=2.34} {r1-r2} -1.11
+ test_expr expr-2.3 {r1=1.23, r2=2.34} {r1*r2} 2.8782
+}
+set tcl_precision 15
+ifcapable floatingpoint {
+ test_expr expr-2.4 {r1=1.23, r2=2.34} {r1/r2} 0.525641025641026
+ test_expr expr-2.5 {r1=1.23, r2=2.34} {r2/r1} 1.90243902439024
+ test_expr expr-2.6 {r1=1.23, r2=2.34} {r2<r1} 0
+ test_expr expr-2.7 {r1=1.23, r2=2.34} {r2<=r1} 0
+ test_expr expr-2.8 {r1=1.23, r2=2.34} {r2>r1} 1
+ test_expr expr-2.9 {r1=1.23, r2=2.34} {r2>=r1} 1
+ test_expr expr-2.10 {r1=1.23, r2=2.34} {r2!=r1} 1
+ test_expr expr-2.11 {r1=1.23, r2=2.34} {r2=r1} 0
+ test_expr expr-2.12 {r1=1.23, r2=2.34} {r2<>r1} 1
+ test_expr expr-2.13 {r1=1.23, r2=2.34} {r2==r1} 0
+ test_expr expr-2.14 {r1=2.34, r2=2.34} {r2<r1} 0
+ test_expr expr-2.15 {r1=2.34, r2=2.34} {r2<=r1} 1
+ test_expr expr-2.16 {r1=2.34, r2=2.34} {r2>r1} 0
+ test_expr expr-2.17 {r1=2.34, r2=2.34} {r2>=r1} 1
+ test_expr expr-2.18 {r1=2.34, r2=2.34} {r2!=r1} 0
+ test_expr expr-2.19 {r1=2.34, r2=2.34} {r2=r1} 1
+ test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0
+ test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1
+ test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11}
+ test_expr expr-2.23 {r1=1.23, r2=2.34} {max(r1,r2,r1+r2,r1-r2)} {3.57}
+ test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3.0
+ test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99.0
+ test_expr expr-2.26 {r1=1e300, r2=1e300} {coalesce((r1*r2)*0.0,99.0)} 99.0
+ test_expr expr-2.26b {r1=1e300, r2=-1e300} {coalesce((r1*r2)*0.0,99.0)} 99.0
+ test_expr expr-2.27 {r1=1.1, r2=0.0} {r1/r2} {{}}
+ test_expr expr-2.28 {r1=1.1, r2=0.0} {r1%r2} {{}}
+}
+
+test_expr expr-3.1 {t1='abc', t2='xyz'} {t1<t2} 1
+test_expr expr-3.2 {t1='xyz', t2='abc'} {t1<t2} 0
+test_expr expr-3.3 {t1='abc', t2='abc'} {t1<t2} 0
+test_expr expr-3.4 {t1='abc', t2='xyz'} {t1<=t2} 1
+test_expr expr-3.5 {t1='xyz', t2='abc'} {t1<=t2} 0
+test_expr expr-3.6 {t1='abc', t2='abc'} {t1<=t2} 1
+test_expr expr-3.7 {t1='abc', t2='xyz'} {t1>t2} 0
+test_expr expr-3.8 {t1='xyz', t2='abc'} {t1>t2} 1
+test_expr expr-3.9 {t1='abc', t2='abc'} {t1>t2} 0
+test_expr expr-3.10 {t1='abc', t2='xyz'} {t1>=t2} 0
+test_expr expr-3.11 {t1='xyz', t2='abc'} {t1>=t2} 1
+test_expr expr-3.12 {t1='abc', t2='abc'} {t1>=t2} 1
+test_expr expr-3.13 {t1='abc', t2='xyz'} {t1=t2} 0
+test_expr expr-3.14 {t1='xyz', t2='abc'} {t1=t2} 0
+test_expr expr-3.15 {t1='abc', t2='abc'} {t1=t2} 1
+test_expr expr-3.16 {t1='abc', t2='xyz'} {t1==t2} 0
+test_expr expr-3.17 {t1='xyz', t2='abc'} {t1==t2} 0
+test_expr expr-3.18 {t1='abc', t2='abc'} {t1==t2} 1
+test_expr expr-3.19 {t1='abc', t2='xyz'} {t1<>t2} 1
+test_expr expr-3.20 {t1='xyz', t2='abc'} {t1<>t2} 1
+test_expr expr-3.21 {t1='abc', t2='abc'} {t1<>t2} 0
+test_expr expr-3.22 {t1='abc', t2='xyz'} {t1!=t2} 1
+test_expr expr-3.23 {t1='xyz', t2='abc'} {t1!=t2} 1
+test_expr expr-3.24 {t1='abc', t2='abc'} {t1!=t2} 0
+test_expr expr-3.25 {t1=NULL, t2='hi'} {t1 isnull} 1
+test_expr expr-3.25b {t1=NULL, t2='hi'} {t1 is null} 1
+test_expr expr-3.26 {t1=NULL, t2='hi'} {t2 isnull} 0
+test_expr expr-3.27 {t1=NULL, t2='hi'} {t1 notnull} 0
+test_expr expr-3.28 {t1=NULL, t2='hi'} {t2 notnull} 1
+test_expr expr-3.28b {t1=NULL, t2='hi'} {t2 is not null} 1
+test_expr expr-3.29 {t1='xyz', t2='abc'} {t1||t2} {xyzabc}
+test_expr expr-3.30 {t1=NULL, t2='abc'} {t1||t2} {{}}
+test_expr expr-3.31 {t1='xyz', t2=NULL} {t1||t2} {{}}
+test_expr expr-3.32 {t1='xyz', t2='abc'} {t1||' hi '||t2} {{xyz hi abc}}
+test_expr epxr-3.33 {t1='abc', t2=NULL} {coalesce(t1<t2,99)} 99
+test_expr epxr-3.34 {t1='abc', t2=NULL} {coalesce(t2<t1,99)} 99
+test_expr epxr-3.35 {t1='abc', t2=NULL} {coalesce(t1>t2,99)} 99
+test_expr epxr-3.36 {t1='abc', t2=NULL} {coalesce(t2>t1,99)} 99
+test_expr epxr-3.37 {t1='abc', t2=NULL} {coalesce(t1<=t2,99)} 99
+test_expr epxr-3.38 {t1='abc', t2=NULL} {coalesce(t2<=t1,99)} 99
+test_expr epxr-3.39 {t1='abc', t2=NULL} {coalesce(t1>=t2,99)} 99
+test_expr epxr-3.40 {t1='abc', t2=NULL} {coalesce(t2>=t1,99)} 99
+test_expr epxr-3.41 {t1='abc', t2=NULL} {coalesce(t1==t2,99)} 99
+test_expr epxr-3.42 {t1='abc', t2=NULL} {coalesce(t2==t1,99)} 99
+test_expr epxr-3.43 {t1='abc', t2=NULL} {coalesce(t1!=t2,99)} 99
+test_expr epxr-3.44 {t1='abc', t2=NULL} {coalesce(t2!=t1,99)} 99
+
+test_expr expr-4.1 {t1='abc', t2='Abc'} {t1<t2} 0
+test_expr expr-4.2 {t1='abc', t2='Abc'} {t1>t2} 1
+test_expr expr-4.3 {t1='abc', t2='Bbc'} {t1<t2} 0
+test_expr expr-4.4 {t1='abc', t2='Bbc'} {t1>t2} 1
+test_expr expr-4.5 {t1='0', t2='0.0'} {t1==t2} 0
+test_expr expr-4.6 {t1='0.000', t2='0.0'} {t1==t2} 0
+test_expr expr-4.7 {t1=' 0.000', t2=' 0.0'} {t1==t2} 0
+test_expr expr-4.8 {t1='0.0', t2='abc'} {t1<t2} 1
+test_expr expr-4.9 {t1='0.0', t2='abc'} {t1==t2} 0
+
+ifcapable floatingpoint {
+ test_expr expr-4.10 {r1='0.0', r2='abc'} {r1>r2} 0
+ test_expr expr-4.11 {r1='abc', r2='Abc'} {r1<r2} 0
+ test_expr expr-4.12 {r1='abc', r2='Abc'} {r1>r2} 1
+ test_expr expr-4.13 {r1='abc', r2='Bbc'} {r1<r2} 0
+ test_expr expr-4.14 {r1='abc', r2='Bbc'} {r1>r2} 1
+ test_expr expr-4.15 {r1='0', r2='0.0'} {r1==r2} 1
+ test_expr expr-4.16 {r1='0.000', r2='0.0'} {r1==r2} 1
+ test_expr expr-4.17 {r1=' 0.000', r2=' 0.0'} {r1==r2} 1
+ test_expr expr-4.18 {r1='0.0', r2='abc'} {r1<r2} 1
+ test_expr expr-4.19 {r1='0.0', r2='abc'} {r1==r2} 0
+ test_expr expr-4.20 {r1='0.0', r2='abc'} {r1>r2} 0
+}
+
+# CSL is true if LIKE is case sensitive and false if not.
+# NCSL is the opposite. Use these variables as the result
+# on operations where case makes a difference.
+set CSL $sqlite_options(casesensitivelike)
+set NCSL [expr {!$CSL}]
+
+test_expr expr-5.1 {t1='abc', t2='xyz'} {t1 LIKE t2} 0
+test_expr expr-5.2a {t1='abc', t2='abc'} {t1 LIKE t2} 1
+test_expr expr-5.2b {t1='abc', t2='ABC'} {t1 LIKE t2} $NCSL
+test_expr expr-5.3a {t1='abc', t2='a_c'} {t1 LIKE t2} 1
+test_expr expr-5.3b {t1='abc', t2='A_C'} {t1 LIKE t2} $NCSL
+test_expr expr-5.4 {t1='abc', t2='abc_'} {t1 LIKE t2} 0
+test_expr expr-5.5a {t1='abc', t2='a%c'} {t1 LIKE t2} 1
+test_expr expr-5.5b {t1='abc', t2='A%C'} {t1 LIKE t2} $NCSL
+test_expr expr-5.5c {t1='abdc', t2='a%c'} {t1 LIKE t2} 1
+test_expr expr-5.5d {t1='ac', t2='a%c'} {t1 LIKE t2} 1
+test_expr expr-5.5e {t1='ac', t2='A%C'} {t1 LIKE t2} $NCSL
+test_expr expr-5.6a {t1='abxyzzyc', t2='a%c'} {t1 LIKE t2} 1
+test_expr expr-5.6b {t1='abxyzzyc', t2='A%C'} {t1 LIKE t2} $NCSL
+test_expr expr-5.7a {t1='abxyzzy', t2='a%c'} {t1 LIKE t2} 0
+test_expr expr-5.7b {t1='abxyzzy', t2='A%C'} {t1 LIKE t2} 0
+test_expr expr-5.8a {t1='abxyzzycx', t2='a%c'} {t1 LIKE t2} 0
+test_expr expr-5.8b {t1='abxyzzycy', t2='a%cx'} {t1 LIKE t2} 0
+test_expr expr-5.8c {t1='abxyzzycx', t2='A%C'} {t1 LIKE t2} 0
+test_expr expr-5.8d {t1='abxyzzycy', t2='A%CX'} {t1 LIKE t2} 0
+test_expr expr-5.9a {t1='abc', t2='a%_c'} {t1 LIKE t2} 1
+test_expr expr-5.9b {t1='ac', t2='a%_c'} {t1 LIKE t2} 0
+test_expr expr-5.9c {t1='abc', t2='A%_C'} {t1 LIKE t2} $NCSL
+test_expr expr-5.9d {t1='ac', t2='A%_C'} {t1 LIKE t2} 0
+test_expr expr-5.10a {t1='abxyzzyc', t2='a%_c'} {t1 LIKE t2} 1
+test_expr expr-5.10b {t1='abxyzzyc', t2='A%_C'} {t1 LIKE t2} $NCSL
+test_expr expr-5.11 {t1='abc', t2='xyz'} {t1 NOT LIKE t2} 1
+test_expr expr-5.12a {t1='abc', t2='abc'} {t1 NOT LIKE t2} 0
+test_expr expr-5.12b {t1='abc', t2='ABC'} {t1 NOT LIKE t2} $CSL
+test_expr expr-5.13 {t1='A'} {t1 LIKE 'A%_'} 0
+test_expr expr-5.14 {t1='AB'} {t1 LIKE 'A%b' ESCAPE 'b'} 0
+
+# The following tests only work on versions of TCL that support Unicode
+#
+if {"\u1234"!="u1234"} {
+ test_expr expr-5.13a "t1='a\u0080c', t2='a_c'" {t1 LIKE t2} 1
+ test_expr expr-5.13b "t1='a\u0080c', t2='A_C'" {t1 LIKE t2} $NCSL
+ test_expr expr-5.14a "t1='a\u07FFc', t2='a_c'" {t1 LIKE t2} 1
+ test_expr expr-5.14b "t1='a\u07FFc', t2='A_C'" {t1 LIKE t2} $NCSL
+ test_expr expr-5.15a "t1='a\u0800c', t2='a_c'" {t1 LIKE t2} 1
+ test_expr expr-5.15b "t1='a\u0800c', t2='A_C'" {t1 LIKE t2} $NCSL
+ test_expr expr-5.16a "t1='a\uFFFFc', t2='a_c'" {t1 LIKE t2} 1
+ test_expr expr-5.16b "t1='a\uFFFFc', t2='A_C'" {t1 LIKE t2} $NCSL
+ test_expr expr-5.17 "t1='a\u0080', t2='A__'" {t1 LIKE t2} 0
+ test_expr expr-5.18 "t1='a\u07FF', t2='A__'" {t1 LIKE t2} 0
+ test_expr expr-5.19 "t1='a\u0800', t2='A__'" {t1 LIKE t2} 0
+ test_expr expr-5.20 "t1='a\uFFFF', t2='A__'" {t1 LIKE t2} 0
+ test_expr expr-5.21a "t1='ax\uABCD', t2='a_\uABCD'" {t1 LIKE t2} 1
+ test_expr expr-5.21b "t1='ax\uABCD', t2='A_\uABCD'" {t1 LIKE t2} $NCSL
+ test_expr expr-5.22a "t1='ax\u1234', t2='a%\u1234'" {t1 LIKE t2} 1
+ test_expr expr-5.22b "t1='ax\u1234', t2='A%\u1234'" {t1 LIKE t2} $NCSL
+ test_expr expr-5.23a "t1='ax\uFEDC', t2='a_%'" {t1 LIKE t2} 1
+ test_expr expr-5.23b "t1='ax\uFEDC', t2='A_%'" {t1 LIKE t2} $NCSL
+ test_expr expr-5.24a "t1='ax\uFEDCy\uFEDC', t2='a%\uFEDC'" {t1 LIKE t2} 1
+ test_expr expr-5.24b "t1='ax\uFEDCy\uFEDC', t2='A%\uFEDC'" {t1 LIKE t2} $NCSL
+}
+
+test_expr expr-5.54 {t1='abc', t2=NULL} {t1 LIKE t2} {{}}
+test_expr expr-5.55 {t1='abc', t2=NULL} {t1 NOT LIKE t2} {{}}
+test_expr expr-5.56 {t1='abc', t2=NULL} {t2 LIKE t1} {{}}
+test_expr expr-5.57 {t1='abc', t2=NULL} {t2 NOT LIKE t1} {{}}
+
+# LIKE expressions that use ESCAPE characters.
+test_expr expr-5.58a {t1='abc', t2='a_c'} {t1 LIKE t2 ESCAPE '7'} 1
+test_expr expr-5.58b {t1='abc', t2='A_C'} {t1 LIKE t2 ESCAPE '7'} $NCSL
+test_expr expr-5.59a {t1='a_c', t2='a7_c'} {t1 LIKE t2 ESCAPE '7'} 1
+test_expr expr-5.59b {t1='a_c', t2='A7_C'} {t1 LIKE t2 ESCAPE '7'} $NCSL
+test_expr expr-5.60a {t1='abc', t2='a7_c'} {t1 LIKE t2 ESCAPE '7'} 0
+test_expr expr-5.60b {t1='abc', t2='A7_C'} {t1 LIKE t2 ESCAPE '7'} 0
+test_expr expr-5.61a {t1='a7Xc', t2='a7_c'} {t1 LIKE t2 ESCAPE '7'} 0
+test_expr expr-5.61b {t1='a7Xc', t2='A7_C'} {t1 LIKE t2 ESCAPE '7'} 0
+test_expr expr-5.62a {t1='abcde', t2='a%e'} {t1 LIKE t2 ESCAPE '7'} 1
+test_expr expr-5.62b {t1='abcde', t2='A%E'} {t1 LIKE t2 ESCAPE '7'} $NCSL
+test_expr expr-5.63a {t1='abcde', t2='a7%e'} {t1 LIKE t2 ESCAPE '7'} 0
+test_expr expr-5.63b {t1='abcde', t2='A7%E'} {t1 LIKE t2 ESCAPE '7'} 0
+test_expr expr-5.64a {t1='a7cde', t2='a7%e'} {t1 LIKE t2 ESCAPE '7'} 0
+test_expr expr-5.64b {t1='a7cde', t2='A7%E'} {t1 LIKE t2 ESCAPE '7'} 0
+test_expr expr-5.65a {t1='a7cde', t2='a77%e'} {t1 LIKE t2 ESCAPE '7'} 1
+test_expr expr-5.65b {t1='a7cde', t2='A77%E'} {t1 LIKE t2 ESCAPE '7'} $NCSL
+test_expr expr-5.66a {t1='abc7', t2='a%77'} {t1 LIKE t2 ESCAPE '7'} 1
+test_expr expr-5.66b {t1='abc7', t2='A%77'} {t1 LIKE t2 ESCAPE '7'} $NCSL
+test_expr expr-5.67a {t1='abc_', t2='a%7_'} {t1 LIKE t2 ESCAPE '7'} 1
+test_expr expr-5.67b {t1='abc_', t2='A%7_'} {t1 LIKE t2 ESCAPE '7'} $NCSL
+test_expr expr-5.68a {t1='abc7', t2='a%7_'} {t1 LIKE t2 ESCAPE '7'} 0
+test_expr expr-5.68b {t1='abc7', t2='A%7_'} {t1 LIKE t2 ESCAPE '7'} 0
+
+# These are the same test as the block above, but using a multi-byte
+# character as the escape character.
+if {"\u1234"!="u1234"} {
+ test_expr expr-5.69a "t1='abc', t2='a_c'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 1
+ test_expr expr-5.69b "t1='abc', t2='A_C'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" $NCSL
+ test_expr expr-5.70a "t1='a_c', t2='a\u1234_c'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 1
+ test_expr expr-5.70b "t1='a_c', t2='A\u1234_C'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" $NCSL
+ test_expr expr-5.71a "t1='abc', t2='a\u1234_c'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 0
+ test_expr expr-5.71b "t1='abc', t2='A\u1234_C'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 0
+ test_expr expr-5.72a "t1='a\u1234Xc', t2='a\u1234_c'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 0
+ test_expr expr-5.72b "t1='a\u1234Xc', t2='A\u1234_C'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 0
+ test_expr expr-5.73a "t1='abcde', t2='a%e'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 1
+ test_expr expr-5.73b "t1='abcde', t2='A%E'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" $NCSL
+ test_expr expr-5.74a "t1='abcde', t2='a\u1234%e'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 0
+ test_expr expr-5.74b "t1='abcde', t2='A\u1234%E'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 0
+ test_expr expr-5.75a "t1='a\u1234cde', t2='a\u1234%e'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 0
+ test_expr expr-5.75b "t1='a\u1234cde', t2='A\u1234%E'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 0
+ test_expr expr-5.76a "t1='a\u1234cde', t2='a\u1234\u1234%e'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 1
+ test_expr expr-5.76b "t1='a\u1234cde', t2='A\u1234\u1234%E'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" $NCSL
+ test_expr expr-5.77a "t1='abc\u1234', t2='a%\u1234\u1234'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 1
+ test_expr expr-5.77b "t1='abc\u1234', t2='A%\u1234\u1234'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" $NCSL
+ test_expr expr-5.78a "t1='abc_', t2='a%\u1234_'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 1
+ test_expr expr-5.78b "t1='abc_', t2='A%\u1234_'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" $NCSL
+ test_expr expr-5.79a "t1='abc\u1234', t2='a%\u1234_'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 0
+ test_expr expr-5.79b "t1='abc\u1234', t2='A%\u1234_'" \
+ "t1 LIKE t2 ESCAPE '\u1234'" 0
+}
+
+test_expr expr-6.1 {t1='abc', t2='xyz'} {t1 GLOB t2} 0
+test_expr expr-6.2 {t1='abc', t2='ABC'} {t1 GLOB t2} 0
+test_expr expr-6.3 {t1='abc', t2='A?C'} {t1 GLOB t2} 0
+test_expr expr-6.4 {t1='abc', t2='a?c'} {t1 GLOB t2} 1
+test_expr expr-6.5 {t1='abc', t2='abc?'} {t1 GLOB t2} 0
+test_expr expr-6.6 {t1='abc', t2='A*C'} {t1 GLOB t2} 0
+test_expr expr-6.7 {t1='abc', t2='a*c'} {t1 GLOB t2} 1
+test_expr expr-6.8 {t1='abxyzzyc', t2='a*c'} {t1 GLOB t2} 1
+test_expr expr-6.9 {t1='abxyzzy', t2='a*c'} {t1 GLOB t2} 0
+test_expr expr-6.10 {t1='abxyzzycx', t2='a*c'} {t1 GLOB t2} 0
+test_expr expr-6.11 {t1='abc', t2='xyz'} {t1 NOT GLOB t2} 1
+test_expr expr-6.12 {t1='abc', t2='abc'} {t1 NOT GLOB t2} 0
+test_expr expr-6.13 {t1='abc', t2='a[bx]c'} {t1 GLOB t2} 1
+test_expr expr-6.14 {t1='abc', t2='a[cx]c'} {t1 GLOB t2} 0
+test_expr expr-6.15 {t1='abc', t2='a[a-d]c'} {t1 GLOB t2} 1
+test_expr expr-6.16 {t1='abc', t2='a[^a-d]c'} {t1 GLOB t2} 0
+test_expr expr-6.17 {t1='abc', t2='a[A-Dc]c'} {t1 GLOB t2} 0
+test_expr expr-6.18 {t1='abc', t2='a[^A-Dc]c'} {t1 GLOB t2} 1
+test_expr expr-6.19 {t1='abc', t2='a[]b]c'} {t1 GLOB t2} 1
+test_expr expr-6.20 {t1='abc', t2='a[^]b]c'} {t1 GLOB t2} 0
+test_expr expr-6.21a {t1='abcdefg', t2='a*[de]g'} {t1 GLOB t2} 0
+test_expr expr-6.21b {t1='abcdefg', t2='a*[df]g'} {t1 GLOB t2} 1
+test_expr expr-6.21c {t1='abcdefg', t2='a*[d-h]g'} {t1 GLOB t2} 1
+test_expr expr-6.21d {t1='abcdefg', t2='a*[b-e]g'} {t1 GLOB t2} 0
+test_expr expr-6.22a {t1='abcdefg', t2='a*[^de]g'} {t1 GLOB t2} 1
+test_expr expr-6.22b {t1='abcdefg', t2='a*[^def]g'} {t1 GLOB t2} 0
+test_expr expr-6.23 {t1='abcdefg', t2='a*?g'} {t1 GLOB t2} 1
+test_expr expr-6.24 {t1='ac', t2='a*c'} {t1 GLOB t2} 1
+test_expr expr-6.25 {t1='ac', t2='a*?c'} {t1 GLOB t2} 0
+test_expr expr-6.26 {t1='a*c', t2='a[*]c'} {t1 GLOB t2} 1
+test_expr expr-6.27 {t1='a?c', t2='a[?]c'} {t1 GLOB t2} 1
+test_expr expr-6.28 {t1='a[c', t2='a[[]c'} {t1 GLOB t2} 1
+
+
+# These tests only work on versions of TCL that support Unicode
+#
+if {"\u1234"!="u1234"} {
+ test_expr expr-6.26 "t1='a\u0080c', t2='a?c'" {t1 GLOB t2} 1
+ test_expr expr-6.27 "t1='a\u07ffc', t2='a?c'" {t1 GLOB t2} 1
+ test_expr expr-6.28 "t1='a\u0800c', t2='a?c'" {t1 GLOB t2} 1
+ test_expr expr-6.29 "t1='a\uffffc', t2='a?c'" {t1 GLOB t2} 1
+ test_expr expr-6.30 "t1='a\u1234', t2='a?'" {t1 GLOB t2} 1
+ test_expr expr-6.31 "t1='a\u1234', t2='a??'" {t1 GLOB t2} 0
+ test_expr expr-6.32 "t1='ax\u1234', t2='a?\u1234'" {t1 GLOB t2} 1
+ test_expr expr-6.33 "t1='ax\u1234', t2='a*\u1234'" {t1 GLOB t2} 1
+ test_expr expr-6.34 "t1='ax\u1234y\u1234', t2='a*\u1234'" {t1 GLOB t2} 1
+ test_expr expr-6.35 "t1='a\u1234b', t2='a\[x\u1234y\]b'" {t1 GLOB t2} 1
+ test_expr expr-6.36 "t1='a\u1234b', t2='a\[\u1233-\u1235\]b'" {t1 GLOB t2} 1
+ test_expr expr-6.37 "t1='a\u1234b', t2='a\[\u1234-\u124f\]b'" {t1 GLOB t2} 1
+ test_expr expr-6.38 "t1='a\u1234b', t2='a\[\u1235-\u124f\]b'" {t1 GLOB t2} 0
+ test_expr expr-6.39 "t1='a\u1234b', t2='a\[a-\u1235\]b'" {t1 GLOB t2} 1
+ test_expr expr-6.40 "t1='a\u1234b', t2='a\[a-\u1234\]b'" {t1 GLOB t2} 1
+ test_expr expr-6.41 "t1='a\u1234b', t2='a\[a-\u1233\]b'" {t1 GLOB t2} 0
+}
+
+test_expr expr-6.51 {t1='ABC', t2='xyz'} {t1 GLOB t2} 0
+test_expr expr-6.52 {t1='ABC', t2='abc'} {t1 GLOB t2} 0
+test_expr expr-6.53 {t1='ABC', t2='a?c'} {t1 GLOB t2} 0
+test_expr expr-6.54 {t1='ABC', t2='A?C'} {t1 GLOB t2} 1
+test_expr expr-6.55 {t1='ABC', t2='abc?'} {t1 GLOB t2} 0
+test_expr expr-6.56 {t1='ABC', t2='a*c'} {t1 GLOB t2} 0
+test_expr expr-6.57 {t1='ABC', t2='A*C'} {t1 GLOB t2} 1
+test_expr expr-6.58 {t1='ABxyzzyC', t2='A*C'} {t1 GLOB t2} 1
+test_expr expr-6.59 {t1='ABxyzzy', t2='A*C'} {t1 GLOB t2} 0
+test_expr expr-6.60 {t1='ABxyzzyCx', t2='A*C'} {t1 GLOB t2} 0
+test_expr expr-6.61 {t1='ABC', t2='xyz'} {t1 NOT GLOB t2} 1
+test_expr expr-6.62 {t1='ABC', t2='ABC'} {t1 NOT GLOB t2} 0
+test_expr expr-6.63 {t1='ABC', t2='A[Bx]C'} {t1 GLOB t2} 1
+test_expr expr-6.64 {t1='ABC', t2='A[Cx]C'} {t1 GLOB t2} 0
+test_expr expr-6.65 {t1='ABC', t2='A[A-D]C'} {t1 GLOB t2} 1
+test_expr expr-6.66 {t1='ABC', t2='A[^A-D]C'} {t1 GLOB t2} 0
+test_expr expr-6.67 {t1='ABC', t2='A[a-dC]C'} {t1 GLOB t2} 0
+test_expr expr-6.68 {t1='ABC', t2='A[^a-dC]C'} {t1 GLOB t2} 1
+test_expr expr-6.69a {t1='ABC', t2='A[]B]C'} {t1 GLOB t2} 1
+test_expr expr-6.69b {t1='A]C', t2='A[]B]C'} {t1 GLOB t2} 1
+test_expr expr-6.70a {t1='ABC', t2='A[^]B]C'} {t1 GLOB t2} 0
+test_expr expr-6.70b {t1='AxC', t2='A[^]B]C'} {t1 GLOB t2} 1
+test_expr expr-6.70c {t1='A]C', t2='A[^]B]C'} {t1 GLOB t2} 0
+test_expr expr-6.71 {t1='ABCDEFG', t2='A*[DE]G'} {t1 GLOB t2} 0
+test_expr expr-6.72 {t1='ABCDEFG', t2='A*[^DE]G'} {t1 GLOB t2} 1
+test_expr expr-6.73 {t1='ABCDEFG', t2='A*?G'} {t1 GLOB t2} 1
+test_expr expr-6.74 {t1='AC', t2='A*C'} {t1 GLOB t2} 1
+test_expr expr-6.75 {t1='AC', t2='A*?C'} {t1 GLOB t2} 0
+
+test_expr expr-6.63 {t1=NULL, t2='a*?c'} {t1 GLOB t2} {{}}
+test_expr expr-6.64 {t1='ac', t2=NULL} {t1 GLOB t2} {{}}
+test_expr expr-6.65 {t1=NULL, t2='a*?c'} {t1 NOT GLOB t2} {{}}
+test_expr expr-6.66 {t1='ac', t2=NULL} {t1 NOT GLOB t2} {{}}
+
+# Check that the affinity of a CAST expression is calculated correctly.
+ifcapable cast {
+ test_expr expr-6.67 {t1='01', t2=1} {t1 = t2} 0
+ test_expr expr-6.68 {t1='1', t2=1} {t1 = t2} 1
+ test_expr expr-6.69 {t1='01', t2=1} {CAST(t1 AS INTEGER) = t2} 1
+}
+
+test_expr expr-case.1 {i1=1, i2=2} \
+ {CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} ne
+test_expr expr-case.2 {i1=2, i2=2} \
+ {CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} eq
+test_expr expr-case.3 {i1=NULL, i2=2} \
+ {CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} ne
+test_expr expr-case.4 {i1=2, i2=NULL} \
+ {CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} ne
+test_expr expr-case.5 {i1=2} \
+ {CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'error' END} two
+test_expr expr-case.6 {i1=1} \
+ {CASE i1 WHEN 1 THEN 'one' WHEN NULL THEN 'two' ELSE 'error' END} one
+test_expr expr-case.7 {i1=2} \
+ {CASE i1 WHEN 1 THEN 'one' WHEN NULL THEN 'two' ELSE 'error' END} error
+test_expr expr-case.8 {i1=3} \
+ {CASE i1 WHEN 1 THEN 'one' WHEN NULL THEN 'two' ELSE 'error' END} error
+test_expr expr-case.9 {i1=3} \
+ {CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'error' END} error
+test_expr expr-case.10 {i1=3} \
+ {CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' END} {{}}
+test_expr expr-case.11 {i1=null} \
+ {CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 3 END} 3
+test_expr expr-case.12 {i1=1} \
+ {CASE i1 WHEN 1 THEN null WHEN 2 THEN 'two' ELSE 3 END} {{}}
+test_expr expr-case.13 {i1=7} \
+ { CASE WHEN i1 < 5 THEN 'low'
+ WHEN i1 < 10 THEN 'medium'
+ WHEN i1 < 15 THEN 'high' ELSE 'error' END} medium
+
+
+# The sqliteExprIfFalse and sqliteExprIfTrue routines are only
+# executed as part of a WHERE clause. Create a table suitable
+# for testing these functions.
+#
+execsql {DROP TABLE test1}
+execsql {CREATE TABLE test1(a int, b int);}
+for {set i 1} {$i<=20} {incr i} {
+ execsql "INSERT INTO test1 VALUES($i,[expr {1<<$i}])"
+}
+execsql "INSERT INTO test1 VALUES(NULL,0)"
+do_test expr-7.1 {
+ execsql {SELECT * FROM test1 ORDER BY a}
+} {{} 0 1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024 11 2048 12 4096 13 8192 14 16384 15 32768 16 65536 17 131072 18 262144 19 524288 20 1048576}
+
+proc test_expr2 {name expr result} {
+ do_test $name [format {
+ execsql {SELECT a FROM test1 WHERE %s ORDER BY a}
+ } $expr] $result
+}
+
+test_expr2 expr-7.2 {a<10 AND a>8} {9}
+test_expr2 expr-7.3 {a<=10 AND a>=8} {8 9 10}
+test_expr2 expr-7.4 {a>=8 AND a<=10} {8 9 10}
+test_expr2 expr-7.5 {a>=20 OR a<=1} {1 20}
+test_expr2 expr-7.6 {b!=4 AND a<=3} {1 3}
+test_expr2 expr-7.7 {b==8 OR b==16 OR b==32} {3 4 5}
+test_expr2 expr-7.8 {NOT b<>8 OR b==1024} {3 10}
+test_expr2 expr-7.9 {b LIKE '10%'} {10 20}
+test_expr2 expr-7.10 {b LIKE '_4'} {6}
+test_expr2 expr-7.11 {a GLOB '1?'} {10 11 12 13 14 15 16 17 18 19}
+test_expr2 expr-7.12 {b GLOB '1*4'} {10 14}
+test_expr2 expr-7.13 {b GLOB '*1[456]'} {4}
+test_expr2 expr-7.14 {a ISNULL} {{}}
+test_expr2 expr-7.15 {a NOTNULL AND a<3} {1 2}
+test_expr2 expr-7.16 {a AND a<3} {1 2}
+test_expr2 expr-7.17 {NOT a} {}
+test_expr2 expr-7.18 {a==11 OR (b>1000 AND b<2000)} {10 11}
+test_expr2 expr-7.19 {a<=1 OR a>=20} {1 20}
+test_expr2 expr-7.20 {a<1 OR a>20} {}
+test_expr2 expr-7.21 {a>19 OR a<1} {20}
+test_expr2 expr-7.22 {a!=1 OR a=100} \
+ {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
+test_expr2 expr-7.23 {(a notnull AND a<4) OR a==8} {1 2 3 8}
+test_expr2 expr-7.24 {a LIKE '2_' OR a==8} {8 20}
+test_expr2 expr-7.25 {a GLOB '2?' OR a==8} {8 20}
+test_expr2 expr-7.26 {a isnull OR a=8} {{} 8}
+test_expr2 expr-7.27 {a notnull OR a=8} \
+ {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
+test_expr2 expr-7.28 {a<0 OR b=0} {{}}
+test_expr2 expr-7.29 {b=0 OR a<0} {{}}
+test_expr2 expr-7.30 {a<0 AND b=0} {}
+test_expr2 expr-7.31 {b=0 AND a<0} {}
+test_expr2 expr-7.32 {a IS NULL AND (a<0 OR b=0)} {{}}
+test_expr2 expr-7.33 {a IS NULL AND (b=0 OR a<0)} {{}}
+test_expr2 expr-7.34 {a IS NULL AND (a<0 AND b=0)} {}
+test_expr2 expr-7.35 {a IS NULL AND (b=0 AND a<0)} {}
+test_expr2 expr-7.32 {(a<0 OR b=0) AND a IS NULL} {{}}
+test_expr2 expr-7.33 {(b=0 OR a<0) AND a IS NULL} {{}}
+test_expr2 expr-7.34 {(a<0 AND b=0) AND a IS NULL} {}
+test_expr2 expr-7.35 {(b=0 AND a<0) AND a IS NULL} {}
+test_expr2 expr-7.36 {a<2 OR (a<0 OR b=0)} {{} 1}
+test_expr2 expr-7.37 {a<2 OR (b=0 OR a<0)} {{} 1}
+test_expr2 expr-7.38 {a<2 OR (a<0 AND b=0)} {1}
+test_expr2 expr-7.39 {a<2 OR (b=0 AND a<0)} {1}
+ifcapable floatingpoint {
+ test_expr2 expr-7.40 {((a<2 OR a IS NULL) AND b<3) OR b>1e10} {{} 1}
+}
+test_expr2 expr-7.41 {a BETWEEN -1 AND 1} {1}
+test_expr2 expr-7.42 {a NOT BETWEEN 2 AND 100} {1}
+test_expr2 expr-7.43 {(b+1234)||'this is a string that is at least 32 characters long' BETWEEN 1 AND 2} {}
+test_expr2 expr-7.44 {123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a BETWEEN '123a' AND '123b'} {}
+test_expr2 expr-7.45 {((123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a) BETWEEN '123a' AND '123b')<0} {}
+test_expr2 expr-7.46 {((123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a) BETWEEN '123a' AND '123z')>0} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
+
+test_expr2 expr-7.50 {((a between 1 and 2 OR 0) AND 1) OR 0} {1 2}
+test_expr2 expr-7.51 {((a not between 3 and 100 OR 0) AND 1) OR 0} {1 2}
+
+ifcapable subquery {
+ test_expr2 expr-7.52 {((a in (1,2) OR 0) AND 1) OR 0} {1 2}
+ test_expr2 expr-7.53 \
+ {((a not in (3,4,5,6,7,8,9,10) OR 0) AND a<11) OR 0} {1 2}
+}
+test_expr2 expr-7.54 {((a>0 OR 0) AND a<3) OR 0} {1 2}
+ifcapable subquery {
+ test_expr2 expr-7.55 {((a in (1,2) OR 0) IS NULL AND 1) OR 0} {{}}
+ test_expr2 expr-7.56 \
+ {((a not in (3,4,5,6,7,8,9,10) IS NULL OR 0) AND 1) OR 0} {{}}
+}
+test_expr2 expr-7.57 {((a>0 IS NULL OR 0) AND 1) OR 0} {{}}
+
+test_expr2 expr-7.58 {(a||'')<='1'} {1}
+
+test_expr2 expr-7.59 {LIKE('10%',b)} {10 20}
+test_expr2 expr-7.60 {LIKE('_4',b)} {6}
+test_expr2 expr-7.61 {GLOB('1?',a)} {10 11 12 13 14 15 16 17 18 19}
+test_expr2 expr-7.62 {GLOB('1*4',b)} {10 14}
+test_expr2 expr-7.63 {GLOB('*1[456]',b)} {4}
+test_expr2 expr-7.64 {b = abs(-2)} {1}
+test_expr2 expr-7.65 {b = abs(+-2)} {1}
+test_expr2 expr-7.66 {b = abs(++-2)} {1}
+test_expr2 expr-7.67 {b = abs(+-+-2)} {1}
+test_expr2 expr-7.68 {b = abs(+-++-2)} {1}
+test_expr2 expr-7.69 {b = abs(++++-2)} {1}
+test_expr2 expr-7.70 {b = 5 - abs(+3)} {1}
+test_expr2 expr-7.71 {b = 5 - abs(-3)} {1}
+ifcapable floatingpoint {
+ test_expr2 expr-7.72 {b = abs(-2.0)} {1}
+}
+test_expr2 expr-7.73 {b = 6 - abs(-a)} {2}
+ifcapable floatingpoint {
+ test_expr2 expr-7.74 {b = abs(8.0)} {3}
+}
+
+# Test the CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP expressions.
+#
+ifcapable {floatingpoint} {
+ set sqlite_current_time 1157124849
+ do_test expr-8.1 {
+ execsql {SELECT CURRENT_TIME}
+ } {15:34:09}
+ do_test expr-8.2 {
+ execsql {SELECT CURRENT_DATE}
+ } {2006-09-01}
+ do_test expr-8.3 {
+ execsql {SELECT CURRENT_TIMESTAMP}
+ } {{2006-09-01 15:34:09}}
+}
+ifcapable datetime {
+ do_test expr-8.4 {
+ execsql {SELECT CURRENT_TIME==time('now');}
+ } 1
+ do_test expr-8.5 {
+ execsql {SELECT CURRENT_DATE==date('now');}
+ } 1
+ do_test expr-8.6 {
+ execsql {SELECT CURRENT_TIMESTAMP==datetime('now');}
+ } 1
+}
+set sqlite_current_time 0
+
+ifcapable floatingpoint {
+ do_test expr-9.1 {
+ execsql {SELECT round(-('-'||'123'))}
+ } 123.0
+}
+
+# Test an error message that can be generated by the LIKE expression
+do_test expr-10.1 {
+ catchsql {SELECT 'abc' LIKE 'abc' ESCAPE ''}
+} {1 {ESCAPE expression must be a single character}}
+do_test expr-10.2 {
+ catchsql {SELECT 'abc' LIKE 'abc' ESCAPE 'ab'}
+} {1 {ESCAPE expression must be a single character}}
+
+# If we specify an integer constant that is bigger than the largest
+# possible integer, code the integer as a real number.
+#
+do_test expr-11.1 {
+ execsql {SELECT typeof(9223372036854775807)}
+} {integer}
+do_test expr-11.2 {
+ execsql {SELECT typeof(00000009223372036854775807)}
+} {integer}
+do_test expr-11.3 {
+ execsql {SELECT typeof(+9223372036854775807)}
+} {integer}
+do_test expr-11.4 {
+ execsql {SELECT typeof(+000000009223372036854775807)}
+} {integer}
+do_test expr-11.5 {
+ execsql {SELECT typeof(9223372036854775808)}
+} {real}
+do_test expr-11.6 {
+ execsql {SELECT typeof(00000009223372036854775808)}
+} {real}
+do_test expr-11.7 {
+ execsql {SELECT typeof(+9223372036854775808)}
+} {real}
+do_test expr-11.8 {
+ execsql {SELECT typeof(+0000009223372036854775808)}
+} {real}
+do_test expr-11.11 {
+ execsql {SELECT typeof(-9223372036854775808)}
+} {integer}
+do_test expr-11.12 {
+ execsql {SELECT typeof(-00000009223372036854775808)}
+} {integer}
+ifcapable floatingpoint {
+ do_test expr-11.13 {
+ execsql {SELECT typeof(-9223372036854775809)}
+ } {real}
+ do_test expr-11.14 {
+ execsql {SELECT typeof(-00000009223372036854775809)}
+ } {real}
+}
+
+# These two statements used to leak memory (because of missing %destructor
+# directives in parse.y).
+do_test expr-12.1 {
+ catchsql {
+ SELECT (CASE a>4 THEN 1 ELSE 0 END) FROM test1;
+ }
+} {1 {near "THEN": syntax error}}
+do_test expr-12.2 {
+ catchsql {
+ SELECT (CASE WHEN a>4 THEN 1 ELSE 0) FROM test1;
+ }
+} {1 {near ")": syntax error}}
+
+ifcapable floatingpoint {
+ do_realnum_test expr-13.1 {
+ execsql {
+ SELECT 12345678901234567890;
+ }
+ } {1.23456789012346e+19}
+}
+
+# Implicit String->Integer conversion is used when possible.
+#
+if {[working_64bit_int]} {
+ do_test expr-13.2 {
+ execsql {
+ SELECT 0+'9223372036854775807'
+ }
+ } {9223372036854775807}
+ do_test expr-13.3 {
+ execsql {
+ SELECT '9223372036854775807'+0
+ }
+ } {9223372036854775807}
+}
+
+# If the value is too large, use String->Float conversion.
+#
+ifcapable floatingpoint {
+ do_realnum_test expr-13.4 {
+ execsql {
+ SELECT 0+'9223372036854775808'
+ }
+ } {9.22337203685478e+18}
+ do_realnum_test expr-13.5 {
+ execsql {
+ SELECT '9223372036854775808'+0
+ }
+ } {9.22337203685478e+18}
+}
+
+# Use String->float conversion if the value is explicitly a floating
+# point value.
+#
+do_realnum_test expr-13.6 {
+ execsql {
+ SELECT 0+'9223372036854775807.0'
+ }
+} {9.22337203685478e+18}
+do_realnum_test expr-13.7 {
+ execsql {
+ SELECT '9223372036854775807.0'+0
+ }
+} {9.22337203685478e+18}
+
+
+finish_test
diff --git a/test/fallocate.test b/test/fallocate.test
new file mode 100644
index 0000000..8a5fa32
--- /dev/null
+++ b/test/fallocate.test
@@ -0,0 +1,146 @@
+# 2010 July 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+file_control_chunksize_test db main [expr 1024*1024]
+
+do_test fallocate-1.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(a, b);
+ }
+ file size test.db
+} [expr 1*1024*1024]
+
+do_test fallocate-1.2 {
+ execsql { INSERT INTO t1 VALUES(1, zeroblob(1024*900)) }
+ file size test.db
+} [expr 1*1024*1024]
+
+do_test fallocate-1.3 {
+ execsql { INSERT INTO t1 VALUES(2, zeroblob(1024*900)) }
+ file size test.db
+} [expr 2*1024*1024]
+
+do_test fallocate-1.4 {
+ execsql { DELETE FROM t1 WHERE a = 1 }
+ file size test.db
+} [expr 1*1024*1024]
+
+do_test fallocate-1.5 {
+ execsql { DELETE FROM t1 WHERE a = 2 }
+ file size test.db
+} [expr 1*1024*1024]
+
+do_test fallocate-1.6 {
+ execsql { PRAGMA freelist_count }
+} {0}
+
+# Start a write-transaction and read the "database file size" field from
+# the journal file. This field should be set to the number of pages in
+# the database file based on the size of the file on disk, not the actual
+# logical size of the database within the file.
+#
+# We need to check this to verify that if in the unlikely event a rollback
+# causes a database file to grow, the database grows to its previous size
+# on disk, not to the minimum size required to hold the database image.
+#
+do_test fallocate-1.7 {
+ execsql { BEGIN; INSERT INTO t1 VALUES(1, 2); }
+ if {[permutation] != "inmemory_journal"} {
+ hexio_get_int [hexio_read test.db-journal 16 4]
+ } else {
+ set {} 1024
+ }
+} {1024}
+do_test fallocate-1.8 { execsql { COMMIT } } {}
+
+
+#-------------------------------------------------------------------------
+# The following tests - fallocate-2.* - test that things work in WAL
+# mode as well.
+#
+set skipwaltests [expr {
+ [permutation]=="journaltest" || [permutation]=="inmemory_journal"
+}]
+ifcapable !wal { set skipwaltests 1 }
+
+if {!$skipwaltests} {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ file_control_chunksize_test db main [expr 32*1024]
+
+ do_test fallocate-2.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ }
+ file size test.db
+ } [expr 32*1024]
+
+ do_test fallocate-2.2 {
+ execsql { INSERT INTO t1 VALUES(1, zeroblob(35*1024)) }
+ execsql { PRAGMA wal_checkpoint }
+ file size test.db
+ } [expr 64*1024]
+
+ do_test fallocate-2.3 {
+ execsql { DELETE FROM t1 }
+ execsql { VACUUM }
+ file size test.db
+ } [expr 64*1024]
+
+ do_test fallocate-2.4 {
+ execsql { PRAGMA wal_checkpoint }
+ file size test.db
+ } [expr 32*1024]
+
+ do_test fallocate-2.5 {
+ execsql {
+ INSERT INTO t1 VALUES(2, randomblob(35*1024));
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES(3, randomblob(128));
+ DELETE FROM t1 WHERE a = 2;
+ VACUUM;
+ }
+ file size test.db
+ } [expr 64*1024]
+
+ do_test fallocate-2.6 {
+ sqlite3 db2 test.db
+ execsql { BEGIN ; SELECT count(a) FROM t1 } db2
+ execsql {
+ INSERT INTO t1 VALUES(4, randomblob(128));
+ PRAGMA wal_checkpoint;
+ }
+ file size test.db
+ } [expr 64*1024]
+
+ do_test fallocate-2.7 {
+ execsql { SELECT count(b) FROM t1 } db2
+ } {1}
+
+ do_test fallocate-2.8 {
+ execsql { COMMIT } db2
+ execsql { PRAGMA wal_checkpoint }
+ file size test.db
+ } [expr 32*1024]
+}
+
+
+finish_test
+
diff --git a/test/filectrl.test b/test/filectrl.test
new file mode 100644
index 0000000..9f077d5
--- /dev/null
+++ b/test/filectrl.test
@@ -0,0 +1,41 @@
+# 2008 Jan 22
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: filectrl.test,v 1.2 2008/11/21 00:10:35 aswift Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+do_test filectrl-1.1 {
+ file_control_test db
+} {}
+do_test filectrl-1.2 {
+ db eval {CREATE TEMP TABLE x(y);}
+ file_control_test db
+} {}
+do_test filectrl-1.3 {
+ db close
+ sqlite3 db :memory:
+ file_control_test db
+} {}
+do_test filectrl-1.4 {
+ sqlite3 db test.db
+ file_control_lasterrno_test db
+} {}
+do_test filectrl-1.5 {
+ db close
+ sqlite3 db test_control_lockproxy.db
+ file_control_lockproxy_test db [pwd]
+} {}
+db close
+forcedelete .test_control_lockproxy.db-conch test.proxy
+finish_test
diff --git a/test/filefmt.test b/test/filefmt.test
new file mode 100644
index 0000000..1165cd6
--- /dev/null
+++ b/test/filefmt.test
@@ -0,0 +1,216 @@
+# 2007 April 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify database file format.
+#
+# $Id: filefmt.test,v 1.3 2009/06/18 11:34:43 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+db close
+forcedelete test.db test.db-journal
+
+# Database begins with valid 16-byte header string.
+#
+do_test filefmt-1.1 {
+ sqlite3 db test.db
+ db eval {CREATE TABLE t1(x)}
+ db close
+ hexio_read test.db 0 16
+} {53514C69746520666F726D6174203300}
+
+# If the 16-byte header is changed, the file will not open
+#
+do_test filefmt-1.2 {
+ hexio_write test.db 0 54
+ set x [catch {sqlite3 db test.db} err]
+ lappend x $err
+} {0 {}}
+do_test filefmt-1.3 {
+ catchsql {
+ SELECT count(*) FROM sqlite_master
+ }
+} {1 {file is encrypted or is not a database}}
+do_test filefmt-1.4 {
+ db close
+ hexio_write test.db 0 53
+ sqlite3 db test.db
+ catchsql {
+ SELECT count(*) FROM sqlite_master
+ }
+} {0 1}
+
+# The page-size is stored at offset 16
+#
+ifcapable pager_pragmas {
+ foreach pagesize {512 1024 2048 4096 8192 16384 32768} {
+ if {[info exists SQLITE_MAX_PAGE_SIZE]
+ && $pagesize>$SQLITE_MAX_PAGE_SIZE} continue
+ do_test filefmt-1.5.$pagesize.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval "PRAGMA auto_vacuum=OFF"
+ db eval "PRAGMA page_size=$pagesize"
+ db eval {CREATE TABLE t1(x)}
+ file size test.db
+ } [expr $pagesize*2]
+ do_test filefmt-1.5.$pagesize.2 {
+ hexio_get_int [hexio_read test.db 16 2]
+ } $pagesize
+ }
+}
+
+# The page-size must be a power of 2
+#
+do_test filefmt-1.6 {
+ db close
+ hexio_write test.db 16 [hexio_render_int16 1025]
+ sqlite3 db test.db
+ catchsql {
+ SELECT count(*) FROM sqlite_master
+ }
+} {1 {file is encrypted or is not a database}}
+
+
+# The page-size must be at least 512 bytes
+#
+do_test filefmt-1.7 {
+ db close
+ hexio_write test.db 16 [hexio_render_int16 256]
+ sqlite3 db test.db
+ catchsql {
+ SELECT count(*) FROM sqlite_master
+ }
+} {1 {file is encrypted or is not a database}}
+
+# Usable space per page (page-size minus unused space per page)
+# must be at least 480 bytes
+#
+ifcapable pager_pragmas {
+ do_test filefmt-1.8 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {PRAGMA page_size=512; CREATE TABLE t1(x)}
+ db close
+ hexio_write test.db 20 21
+ sqlite3 db test.db
+ catchsql {
+ SELECT count(*) FROM sqlite_master
+ }
+ } {1 {file is encrypted or is not a database}}
+}
+
+#-------------------------------------------------------------------------
+# The following block of tests - filefmt-2.* - test that versions 3.7.0
+# and later can read and write databases that have been modified or created
+# by 3.6.23.1 and earlier. The difference difference is that 3.7.0 stores
+# the size of the database in the database file header, whereas 3.6.23.1
+# always derives this from the size of the file.
+#
+db close
+forcedelete test.db
+
+set a_string_counter 1
+proc a_string {n} {
+ incr ::a_string_counter
+ string range [string repeat "${::a_string_counter}." $n] 1 $n
+}
+sqlite3 db test.db
+db func a_string a_string
+
+do_execsql_test filefmt-2.1.1 {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1 VALUES(a_string(3000));
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(1);
+} {}
+do_test filefmt-2.1.2 {
+ hexio_read test.db 28 4
+} {00000009}
+
+do_test filefmt-2.1.3 {
+ sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }
+} {}
+
+do_execsql_test filefmt-2.1.4 { INSERT INTO t2 VALUES(2) } {}
+integrity_check filefmt-2.1.5
+do_test filefmt-2.1.6 { hexio_read test.db 28 4 } {00000010}
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+db func a_string a_string
+
+do_execsql_test filefmt-2.2.1 {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1 VALUES(a_string(3000));
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(1);
+} {}
+do_test filefmt-2.2.2 {
+ hexio_read test.db 28 4
+} {00000009}
+
+do_test filefmt-2.2.3 {
+ sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }
+} {}
+
+do_execsql_test filefmt-2.2.4 {
+ PRAGMA integrity_check;
+ BEGIN;
+ INSERT INTO t2 VALUES(2);
+ SAVEPOINT a;
+ INSERT INTO t2 VALUES(3);
+ ROLLBACK TO a;
+} {ok}
+
+integrity_check filefmt-2.2.5
+do_execsql_test filefmt-2.2.6 { COMMIT } {}
+db close
+sqlite3 db test.db
+integrity_check filefmt-2.2.7
+
+#--------------------------------------------------------------------------
+# Check that ticket 89b8c9ac54 is fixed. Before the fix, the SELECT
+# statement would return SQLITE_CORRUPT. The database file was not actually
+# corrupted, but SQLite was reporting that it was.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test filefmt-3.1 {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(a, b);
+} {}
+do_test filefmt-3.2 {
+ sql36231 { DROP TABLE t1 }
+} {}
+do_execsql_test filefmt-3.3 {
+ SELECT * FROM sqlite_master;
+ PRAGMA integrity_check;
+} {ok}
+
+finish_test
diff --git a/test/fkey1.test b/test/fkey1.test
new file mode 100644
index 0000000..e7c00d1
--- /dev/null
+++ b/test/fkey1.test
@@ -0,0 +1,121 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for foreign keys.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!foreignkey} {
+ finish_test
+ return
+}
+
+# Create a table and some data to work with.
+#
+do_test fkey1-1.0 {
+ execsql {
+ CREATE TABLE t1(
+ a INTEGER PRIMARY KEY,
+ b INTEGER
+ REFERENCES t1 ON DELETE CASCADE
+ REFERENCES t2,
+ c TEXT,
+ FOREIGN KEY (b,c) REFERENCES t2(x,y) ON UPDATE CASCADE
+ );
+ }
+} {}
+do_test fkey1-1.1 {
+ execsql {
+ CREATE TABLE t2(
+ x INTEGER PRIMARY KEY,
+ y TEXT
+ );
+ }
+} {}
+do_test fkey1-1.2 {
+ execsql {
+ CREATE TABLE t3(
+ a INTEGER REFERENCES t2,
+ b INTEGER REFERENCES t1,
+ FOREIGN KEY (a,b) REFERENCES t2(x,y)
+ );
+ }
+} {}
+
+do_test fkey1-2.1 {
+ execsql {
+ CREATE TABLE t4(a integer primary key);
+ CREATE TABLE t5(x references t4);
+ CREATE TABLE t6(x references t4);
+ CREATE TABLE t7(x references t4);
+ CREATE TABLE t8(x references t4);
+ CREATE TABLE t9(x references t4);
+ CREATE TABLE t10(x references t4);
+ DROP TABLE t7;
+ DROP TABLE t9;
+ DROP TABLE t5;
+ DROP TABLE t8;
+ DROP TABLE t6;
+ DROP TABLE t10;
+ }
+} {}
+
+do_test fkey1-3.1 {
+ execsql {
+ CREATE TABLE t5(a PRIMARY KEY, b, c);
+ CREATE TABLE t6(
+ d REFERENCES t5,
+ e REFERENCES t5(c)
+ );
+ PRAGMA foreign_key_list(t6);
+ }
+} [concat \
+ {0 0 t5 e c {NO ACTION} {NO ACTION} NONE} \
+ {1 0 t5 d {} {NO ACTION} {NO ACTION} NONE} \
+]
+do_test fkey1-3.2 {
+ execsql {
+ CREATE TABLE t7(d, e, f,
+ FOREIGN KEY (d, e) REFERENCES t5(a, b)
+ );
+ PRAGMA foreign_key_list(t7);
+ }
+} [concat \
+ {0 0 t5 d a {NO ACTION} {NO ACTION} NONE} \
+ {0 1 t5 e b {NO ACTION} {NO ACTION} NONE} \
+]
+do_test fkey1-3.3 {
+ execsql {
+ CREATE TABLE t8(d, e, f,
+ FOREIGN KEY (d, e) REFERENCES t5 ON DELETE CASCADE ON UPDATE SET NULL
+ );
+ PRAGMA foreign_key_list(t8);
+ }
+} [concat \
+ {0 0 t5 d {} {SET NULL} CASCADE NONE} \
+ {0 1 t5 e {} {SET NULL} CASCADE NONE} \
+]
+do_test fkey1-3.4 {
+ execsql {
+ CREATE TABLE t9(d, e, f,
+ FOREIGN KEY (d, e) REFERENCES t5 ON DELETE CASCADE ON UPDATE SET DEFAULT
+ );
+ PRAGMA foreign_key_list(t9);
+ }
+} [concat \
+ {0 0 t5 d {} {SET DEFAULT} CASCADE NONE} \
+ {0 1 t5 e {} {SET DEFAULT} CASCADE NONE} \
+]
+
+finish_test
diff --git a/test/fkey2.test b/test/fkey2.test
new file mode 100644
index 0000000..f0cc4d2
--- /dev/null
+++ b/test/fkey2.test
@@ -0,0 +1,1991 @@
+# 2009 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for foreign keys.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!foreignkey||!trigger} {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Test structure:
+#
+# fkey2-1.*: Simple tests to check that immediate and deferred foreign key
+# constraints work when not inside a transaction.
+#
+# fkey2-2.*: Tests to verify that deferred foreign keys work inside
+# explicit transactions (i.e that processing really is deferred).
+#
+# fkey2-3.*: Tests that a statement transaction is rolled back if an
+# immediate foreign key constraint is violated.
+#
+# fkey2-4.*: Test that FK actions may recurse even when recursive triggers
+# are disabled.
+#
+# fkey2-5.*: Check that if foreign-keys are enabled, it is not possible
+# to write to an FK column using the incremental blob API.
+#
+# fkey2-6.*: Test that FK processing is automatically disabled when
+# running VACUUM.
+#
+# fkey2-7.*: Test using an IPK as the key in the child (referencing) table.
+#
+# fkey2-8.*: Test that enabling/disabling foreign key support while a
+# transaction is active is not possible.
+#
+# fkey2-9.*: Test SET DEFAULT actions.
+#
+# fkey2-10.*: Test errors.
+#
+# fkey2-11.*: Test CASCADE actions.
+#
+# fkey2-12.*: Test RESTRICT actions.
+#
+# fkey2-13.*: Test that FK processing is performed when a row is REPLACED by
+# an UPDATE or INSERT statement.
+#
+# fkey2-14.*: Test the ALTER TABLE and DROP TABLE commands.
+#
+# fkey2-15.*: Test that if there are no (known) outstanding foreign key
+# constraint violations in the database, inserting into a parent
+# table or deleting from a child table does not cause SQLite
+# to check if this has repaired an outstanding violation.
+#
+# fkey2-16.*: Test that rows that refer to themselves may be inserted,
+# updated and deleted.
+#
+# fkey2-17.*: Test that the "count_changes" pragma does not interfere with
+# FK constraint processing.
+#
+# fkey2-18.*: Test that the authorization callback is invoked when processing
+# FK constraints.
+#
+# fkey2-20.*: Test that ON CONFLICT clauses specified as part of statements
+# do not affect the operation of FK constraints.
+#
+# fkey2-genfkey.*: Tests that were used with the shell tool .genfkey
+# command. Recycled to test the built-in implementation.
+#
+# fkey2-dd08e5.*: Tests to verify that ticket dd08e5a988d00decc4a543daa8d
+# has been fixed.
+#
+
+
+execsql { PRAGMA foreign_keys = on }
+
+set FkeySimpleSchema {
+ PRAGMA foreign_keys = on;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TABLE t2(c REFERENCES t1(a) /D/ , d);
+
+ CREATE TABLE t3(a PRIMARY KEY, b);
+ CREATE TABLE t4(c REFERENCES t3 /D/, d);
+
+ CREATE TABLE t7(a, b INTEGER PRIMARY KEY);
+ CREATE TABLE t8(c REFERENCES t7 /D/, d);
+
+ CREATE TABLE t9(a REFERENCES nosuchtable, b);
+ CREATE TABLE t10(a REFERENCES t9(c) /D/, b);
+}
+
+
+set FkeySimpleTests {
+ 1.1 "INSERT INTO t2 VALUES(1, 3)" {1 {foreign key constraint failed}}
+ 1.2 "INSERT INTO t1 VALUES(1, 2)" {0 {}}
+ 1.3 "INSERT INTO t2 VALUES(1, 3)" {0 {}}
+ 1.4 "INSERT INTO t2 VALUES(2, 4)" {1 {foreign key constraint failed}}
+ 1.5 "INSERT INTO t2 VALUES(NULL, 4)" {0 {}}
+ 1.6 "UPDATE t2 SET c=2 WHERE d=4" {1 {foreign key constraint failed}}
+ 1.7 "UPDATE t2 SET c=1 WHERE d=4" {0 {}}
+ 1.9 "UPDATE t2 SET c=1 WHERE d=4" {0 {}}
+ 1.10 "UPDATE t2 SET c=NULL WHERE d=4" {0 {}}
+ 1.11 "DELETE FROM t1 WHERE a=1" {1 {foreign key constraint failed}}
+ 1.12 "UPDATE t1 SET a = 2" {1 {foreign key constraint failed}}
+ 1.13 "UPDATE t1 SET a = 1" {0 {}}
+
+ 2.1 "INSERT INTO t4 VALUES(1, 3)" {1 {foreign key constraint failed}}
+ 2.2 "INSERT INTO t3 VALUES(1, 2)" {0 {}}
+ 2.3 "INSERT INTO t4 VALUES(1, 3)" {0 {}}
+
+ 4.1 "INSERT INTO t8 VALUES(1, 3)" {1 {foreign key constraint failed}}
+ 4.2 "INSERT INTO t7 VALUES(2, 1)" {0 {}}
+ 4.3 "INSERT INTO t8 VALUES(1, 3)" {0 {}}
+ 4.4 "INSERT INTO t8 VALUES(2, 4)" {1 {foreign key constraint failed}}
+ 4.5 "INSERT INTO t8 VALUES(NULL, 4)" {0 {}}
+ 4.6 "UPDATE t8 SET c=2 WHERE d=4" {1 {foreign key constraint failed}}
+ 4.7 "UPDATE t8 SET c=1 WHERE d=4" {0 {}}
+ 4.9 "UPDATE t8 SET c=1 WHERE d=4" {0 {}}
+ 4.10 "UPDATE t8 SET c=NULL WHERE d=4" {0 {}}
+ 4.11 "DELETE FROM t7 WHERE b=1" {1 {foreign key constraint failed}}
+ 4.12 "UPDATE t7 SET b = 2" {1 {foreign key constraint failed}}
+ 4.13 "UPDATE t7 SET b = 1" {0 {}}
+ 4.14 "INSERT INTO t8 VALUES('a', 'b')" {1 {foreign key constraint failed}}
+ 4.15 "UPDATE t7 SET b = 5" {1 {foreign key constraint failed}}
+ 4.16 "UPDATE t7 SET rowid = 5" {1 {foreign key constraint failed}}
+ 4.17 "UPDATE t7 SET a = 10" {0 {}}
+
+ 5.1 "INSERT INTO t9 VALUES(1, 3)" {1 {no such table: main.nosuchtable}}
+ 5.2 "INSERT INTO t10 VALUES(1, 3)" {1 {foreign key mismatch}}
+}
+
+do_test fkey2-1.1.0 {
+ execsql [string map {/D/ {}} $FkeySimpleSchema]
+} {}
+foreach {tn zSql res} $FkeySimpleTests {
+ do_test fkey2-1.1.$tn { catchsql $zSql } $res
+}
+drop_all_tables
+
+do_test fkey2-1.2.0 {
+ execsql [string map {/D/ {DEFERRABLE INITIALLY DEFERRED}} $FkeySimpleSchema]
+} {}
+foreach {tn zSql res} $FkeySimpleTests {
+ do_test fkey2-1.2.$tn { catchsql $zSql } $res
+}
+drop_all_tables
+
+do_test fkey2-1.3.0 {
+ execsql [string map {/D/ {}} $FkeySimpleSchema]
+ execsql { PRAGMA count_changes = 1 }
+} {}
+foreach {tn zSql res} $FkeySimpleTests {
+ if {$res == "0 {}"} { set res {0 1} }
+ do_test fkey2-1.3.$tn { catchsql $zSql } $res
+}
+execsql { PRAGMA count_changes = 0 }
+drop_all_tables
+
+do_test fkey2-1.4.0 {
+ execsql [string map {/D/ {}} $FkeySimpleSchema]
+ execsql { PRAGMA count_changes = 1 }
+} {}
+foreach {tn zSql res} $FkeySimpleTests {
+ if {$res == "0 {}"} { set res {0 1} }
+ execsql BEGIN
+ do_test fkey2-1.4.$tn { catchsql $zSql } $res
+ execsql COMMIT
+}
+execsql { PRAGMA count_changes = 0 }
+drop_all_tables
+
+# Special test: When the parent key is an IPK, make sure the affinity of
+# the IPK is not applied to the child key value before it is inserted
+# into the child table.
+do_test fkey2-1.5.1 {
+ execsql {
+ CREATE TABLE i(i INTEGER PRIMARY KEY);
+ CREATE TABLE j(j REFERENCES i);
+ INSERT INTO i VALUES(35);
+ INSERT INTO j VALUES('35.0');
+ SELECT j, typeof(j) FROM j;
+ }
+} {35.0 text}
+do_test fkey2-1.5.2 {
+ catchsql { DELETE FROM i }
+} {1 {foreign key constraint failed}}
+
+# Same test using a regular primary key with integer affinity.
+drop_all_tables
+do_test fkey2-1.6.1 {
+ execsql {
+ CREATE TABLE i(i INT UNIQUE);
+ CREATE TABLE j(j REFERENCES i(i));
+ INSERT INTO i VALUES('35.0');
+ INSERT INTO j VALUES('35.0');
+ SELECT j, typeof(j) FROM j;
+ SELECT i, typeof(i) FROM i;
+ }
+} {35.0 text 35 integer}
+do_test fkey2-1.6.2 {
+ catchsql { DELETE FROM i }
+} {1 {foreign key constraint failed}}
+
+# Use a collation sequence on the parent key.
+drop_all_tables
+do_test fkey2-1.7.1 {
+ execsql {
+ CREATE TABLE i(i TEXT COLLATE nocase PRIMARY KEY);
+ CREATE TABLE j(j TEXT COLLATE binary REFERENCES i(i));
+ INSERT INTO i VALUES('SQLite');
+ INSERT INTO j VALUES('sqlite');
+ }
+ catchsql { DELETE FROM i }
+} {1 {foreign key constraint failed}}
+
+# Use the parent key collation even if it is default and the child key
+# has an explicit value.
+drop_all_tables
+do_test fkey2-1.7.2 {
+ execsql {
+ CREATE TABLE i(i TEXT PRIMARY KEY); -- Colseq is "BINARY"
+ CREATE TABLE j(j TEXT COLLATE nocase REFERENCES i(i));
+ INSERT INTO i VALUES('SQLite');
+ }
+ catchsql { INSERT INTO j VALUES('sqlite') }
+} {1 {foreign key constraint failed}}
+do_test fkey2-1.7.3 {
+ execsql {
+ INSERT INTO i VALUES('sqlite');
+ INSERT INTO j VALUES('sqlite');
+ DELETE FROM i WHERE i = 'SQLite';
+ }
+ catchsql { DELETE FROM i WHERE i = 'sqlite' }
+} {1 {foreign key constraint failed}}
+
+#-------------------------------------------------------------------------
+# This section (test cases fkey2-2.*) contains tests to check that the
+# deferred foreign key constraint logic works.
+#
+proc fkey2-2-test {tn nocommit sql {res {}}} {
+ if {$res eq "FKV"} {
+ set expected {1 {foreign key constraint failed}}
+ } else {
+ set expected [list 0 $res]
+ }
+ do_test fkey2-2.$tn [list catchsql $sql] $expected
+ if {$nocommit} {
+ do_test fkey2-2.${tn}c {
+ catchsql COMMIT
+ } {1 {foreign key constraint failed}}
+ }
+}
+
+fkey2-2-test 1 0 {
+ CREATE TABLE node(
+ nodeid PRIMARY KEY,
+ parent REFERENCES node DEFERRABLE INITIALLY DEFERRED
+ );
+ CREATE TABLE leaf(
+ cellid PRIMARY KEY,
+ parent REFERENCES node DEFERRABLE INITIALLY DEFERRED
+ );
+}
+
+fkey2-2-test 1 0 "INSERT INTO node VALUES(1, 0)" FKV
+fkey2-2-test 2 0 "BEGIN"
+fkey2-2-test 3 1 "INSERT INTO node VALUES(1, 0)"
+fkey2-2-test 4 0 "UPDATE node SET parent = NULL"
+fkey2-2-test 5 0 "COMMIT"
+fkey2-2-test 6 0 "SELECT * FROM node" {1 {}}
+
+fkey2-2-test 7 0 "BEGIN"
+fkey2-2-test 8 1 "INSERT INTO leaf VALUES('a', 2)"
+fkey2-2-test 9 1 "INSERT INTO node VALUES(2, 0)"
+fkey2-2-test 10 0 "UPDATE node SET parent = 1 WHERE nodeid = 2"
+fkey2-2-test 11 0 "COMMIT"
+fkey2-2-test 12 0 "SELECT * FROM node" {1 {} 2 1}
+fkey2-2-test 13 0 "SELECT * FROM leaf" {a 2}
+
+fkey2-2-test 14 0 "BEGIN"
+fkey2-2-test 15 1 "DELETE FROM node WHERE nodeid = 2"
+fkey2-2-test 16 0 "INSERT INTO node VALUES(2, NULL)"
+fkey2-2-test 17 0 "COMMIT"
+fkey2-2-test 18 0 "SELECT * FROM node" {1 {} 2 {}}
+fkey2-2-test 19 0 "SELECT * FROM leaf" {a 2}
+
+fkey2-2-test 20 0 "BEGIN"
+fkey2-2-test 21 0 "INSERT INTO leaf VALUES('b', 1)"
+fkey2-2-test 22 0 "SAVEPOINT save"
+fkey2-2-test 23 0 "DELETE FROM node WHERE nodeid = 1"
+fkey2-2-test 24 0 "ROLLBACK TO save"
+fkey2-2-test 25 0 "COMMIT"
+fkey2-2-test 26 0 "SELECT * FROM node" {1 {} 2 {}}
+fkey2-2-test 27 0 "SELECT * FROM leaf" {a 2 b 1}
+
+fkey2-2-test 28 0 "BEGIN"
+fkey2-2-test 29 0 "INSERT INTO leaf VALUES('c', 1)"
+fkey2-2-test 30 0 "SAVEPOINT save"
+fkey2-2-test 31 0 "DELETE FROM node WHERE nodeid = 1"
+fkey2-2-test 32 1 "RELEASE save"
+fkey2-2-test 33 1 "DELETE FROM leaf WHERE cellid = 'b'"
+fkey2-2-test 34 0 "DELETE FROM leaf WHERE cellid = 'c'"
+fkey2-2-test 35 0 "COMMIT"
+fkey2-2-test 36 0 "SELECT * FROM node" {2 {}}
+fkey2-2-test 37 0 "SELECT * FROM leaf" {a 2}
+
+fkey2-2-test 38 0 "SAVEPOINT outer"
+fkey2-2-test 39 1 "INSERT INTO leaf VALUES('d', 3)"
+fkey2-2-test 40 1 "RELEASE outer" FKV
+fkey2-2-test 41 1 "INSERT INTO leaf VALUES('e', 3)"
+fkey2-2-test 42 0 "INSERT INTO node VALUES(3, 2)"
+fkey2-2-test 43 0 "RELEASE outer"
+
+fkey2-2-test 44 0 "SAVEPOINT outer"
+fkey2-2-test 45 1 "DELETE FROM node WHERE nodeid=3"
+fkey2-2-test 47 0 "INSERT INTO node VALUES(3, 2)"
+fkey2-2-test 48 0 "ROLLBACK TO outer"
+fkey2-2-test 49 0 "RELEASE outer"
+
+fkey2-2-test 50 0 "SAVEPOINT outer"
+fkey2-2-test 51 1 "INSERT INTO leaf VALUES('f', 4)"
+fkey2-2-test 52 1 "SAVEPOINT inner"
+fkey2-2-test 53 1 "INSERT INTO leaf VALUES('g', 4)"
+fkey2-2-test 54 1 "RELEASE outer" FKV
+fkey2-2-test 55 1 "ROLLBACK TO inner"
+fkey2-2-test 56 0 "COMMIT" FKV
+fkey2-2-test 57 0 "INSERT INTO node VALUES(4, NULL)"
+fkey2-2-test 58 0 "RELEASE outer"
+fkey2-2-test 59 0 "SELECT * FROM node" {2 {} 3 2 4 {}}
+fkey2-2-test 60 0 "SELECT * FROM leaf" {a 2 d 3 e 3 f 4}
+
+# The following set of tests check that if a statement that affects
+# multiple rows violates some foreign key constraints, then strikes a
+# constraint that causes the statement-transaction to be rolled back,
+# the deferred constraint counter is correctly reset to the value it
+# had before the statement-transaction was opened.
+#
+fkey2-2-test 61 0 "BEGIN"
+fkey2-2-test 62 0 "DELETE FROM leaf"
+fkey2-2-test 63 0 "DELETE FROM node"
+fkey2-2-test 64 1 "INSERT INTO leaf VALUES('a', 1)"
+fkey2-2-test 65 1 "INSERT INTO leaf VALUES('b', 2)"
+fkey2-2-test 66 1 "INSERT INTO leaf VALUES('c', 1)"
+do_test fkey2-2-test-67 {
+ catchsql "INSERT INTO node SELECT parent, 3 FROM leaf"
+} {1 {column nodeid is not unique}}
+fkey2-2-test 68 0 "COMMIT" FKV
+fkey2-2-test 69 1 "INSERT INTO node VALUES(1, NULL)"
+fkey2-2-test 70 0 "INSERT INTO node VALUES(2, NULL)"
+fkey2-2-test 71 0 "COMMIT"
+
+fkey2-2-test 72 0 "BEGIN"
+fkey2-2-test 73 1 "DELETE FROM node"
+fkey2-2-test 74 0 "INSERT INTO node(nodeid) SELECT DISTINCT parent FROM leaf"
+fkey2-2-test 75 0 "COMMIT"
+
+#-------------------------------------------------------------------------
+# Test cases fkey2-3.* test that a program that executes foreign key
+# actions (CASCADE, SET DEFAULT, SET NULL etc.) or tests FK constraints
+# opens a statement transaction if required.
+#
+# fkey2-3.1.*: Test UPDATE statements.
+# fkey2-3.2.*: Test DELETE statements.
+#
+drop_all_tables
+do_test fkey2-3.1.1 {
+ execsql {
+ CREATE TABLE ab(a PRIMARY KEY, b);
+ CREATE TABLE cd(
+ c PRIMARY KEY REFERENCES ab ON UPDATE CASCADE ON DELETE CASCADE,
+ d
+ );
+ CREATE TABLE ef(
+ e REFERENCES cd ON UPDATE CASCADE,
+ f, CHECK (e!=5)
+ );
+ }
+} {}
+do_test fkey2-3.1.2 {
+ execsql {
+ INSERT INTO ab VALUES(1, 'b');
+ INSERT INTO cd VALUES(1, 'd');
+ INSERT INTO ef VALUES(1, 'e');
+ }
+} {}
+do_test fkey2-3.1.3 {
+ catchsql { UPDATE ab SET a = 5 }
+} {1 {constraint failed}}
+do_test fkey2-3.1.4 {
+ execsql { SELECT * FROM ab }
+} {1 b}
+do_test fkey2-3.1.4 {
+ execsql BEGIN;
+ catchsql { UPDATE ab SET a = 5 }
+} {1 {constraint failed}}
+do_test fkey2-3.1.5 {
+ execsql COMMIT;
+ execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }
+} {1 b 1 d 1 e}
+
+do_test fkey2-3.2.1 {
+ execsql BEGIN;
+ catchsql { DELETE FROM ab }
+} {1 {foreign key constraint failed}}
+do_test fkey2-3.2.2 {
+ execsql COMMIT
+ execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }
+} {1 b 1 d 1 e}
+
+#-------------------------------------------------------------------------
+# Test cases fkey2-4.* test that recursive foreign key actions
+# (i.e. CASCADE) are allowed even if recursive triggers are disabled.
+#
+drop_all_tables
+do_test fkey2-4.1 {
+ execsql {
+ CREATE TABLE t1(
+ node PRIMARY KEY,
+ parent REFERENCES t1 ON DELETE CASCADE
+ );
+ CREATE TABLE t2(node PRIMARY KEY, parent);
+ CREATE TRIGGER t2t AFTER DELETE ON t2 BEGIN
+ DELETE FROM t2 WHERE parent = old.node;
+ END;
+ INSERT INTO t1 VALUES(1, NULL);
+ INSERT INTO t1 VALUES(2, 1);
+ INSERT INTO t1 VALUES(3, 1);
+ INSERT INTO t1 VALUES(4, 2);
+ INSERT INTO t1 VALUES(5, 2);
+ INSERT INTO t1 VALUES(6, 3);
+ INSERT INTO t1 VALUES(7, 3);
+ INSERT INTO t2 SELECT * FROM t1;
+ }
+} {}
+do_test fkey2-4.2 {
+ execsql { PRAGMA recursive_triggers = off }
+ execsql {
+ BEGIN;
+ DELETE FROM t1 WHERE node = 1;
+ SELECT node FROM t1;
+ }
+} {}
+do_test fkey2-4.3 {
+ execsql {
+ DELETE FROM t2 WHERE node = 1;
+ SELECT node FROM t2;
+ ROLLBACK;
+ }
+} {4 5 6 7}
+do_test fkey2-4.4 {
+ execsql { PRAGMA recursive_triggers = on }
+ execsql {
+ BEGIN;
+ DELETE FROM t1 WHERE node = 1;
+ SELECT node FROM t1;
+ }
+} {}
+do_test fkey2-4.3 {
+ execsql {
+ DELETE FROM t2 WHERE node = 1;
+ SELECT node FROM t2;
+ ROLLBACK;
+ }
+} {}
+
+#-------------------------------------------------------------------------
+# Test cases fkey2-5.* verify that the incremental blob API may not
+# write to a foreign key column while foreign-keys are enabled.
+#
+drop_all_tables
+ifcapable incrblob {
+ do_test fkey2-5.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1(a));
+ INSERT INTO t1 VALUES('hello', 'world');
+ INSERT INTO t2 VALUES('key', 'hello');
+ }
+ } {}
+ do_test fkey2-5.2 {
+ set rc [catch { set fd [db incrblob t2 b 1] } msg]
+ list $rc $msg
+ } {1 {cannot open foreign key column for writing}}
+ do_test fkey2-5.3 {
+ set rc [catch { set fd [db incrblob -readonly t2 b 1] } msg]
+ close $fd
+ set rc
+ } {0}
+ do_test fkey2-5.4 {
+ execsql { PRAGMA foreign_keys = off }
+ set rc [catch { set fd [db incrblob t2 b 1] } msg]
+ close $fd
+ set rc
+ } {0}
+ do_test fkey2-5.5 {
+ execsql { PRAGMA foreign_keys = on }
+ } {}
+}
+
+drop_all_tables
+ifcapable vacuum {
+ do_test fkey2-6.1 {
+ execsql {
+ CREATE TABLE t1(a REFERENCES t2(c), b);
+ CREATE TABLE t2(c UNIQUE, b);
+ INSERT INTO t2 VALUES(1, 2);
+ INSERT INTO t1 VALUES(1, 2);
+ VACUUM;
+ }
+ } {}
+}
+
+#-------------------------------------------------------------------------
+# Test that it is possible to use an INTEGER PRIMARY KEY as the child key
+# of a foreign constraint.
+#
+drop_all_tables
+do_test fkey2-7.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TABLE t2(c INTEGER PRIMARY KEY REFERENCES t1, b);
+ }
+} {}
+do_test fkey2-7.2 {
+ catchsql { INSERT INTO t2 VALUES(1, 'A'); }
+} {1 {foreign key constraint failed}}
+do_test fkey2-7.3 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(2, 3);
+ INSERT INTO t2 VALUES(1, 'A');
+ }
+} {}
+do_test fkey2-7.4 {
+ execsql { UPDATE t2 SET c = 2 }
+} {}
+do_test fkey2-7.5 {
+ catchsql { UPDATE t2 SET c = 3 }
+} {1 {foreign key constraint failed}}
+do_test fkey2-7.6 {
+ catchsql { DELETE FROM t1 WHERE a = 2 }
+} {1 {foreign key constraint failed}}
+do_test fkey2-7.7 {
+ execsql { DELETE FROM t1 WHERE a = 1 }
+} {}
+do_test fkey2-7.8 {
+ catchsql { UPDATE t1 SET a = 3 }
+} {1 {foreign key constraint failed}}
+do_test fkey2-7.9 {
+ catchsql { UPDATE t2 SET rowid = 3 }
+} {1 {foreign key constraint failed}}
+
+#-------------------------------------------------------------------------
+# Test that it is not possible to enable/disable FK support while a
+# transaction is open.
+#
+drop_all_tables
+proc fkey2-8-test {tn zSql value} {
+ do_test fkey-2.8.$tn.1 [list execsql $zSql] {}
+ do_test fkey-2.8.$tn.2 { execsql "PRAGMA foreign_keys" } $value
+}
+fkey2-8-test 1 { PRAGMA foreign_keys = 0 } 0
+fkey2-8-test 2 { PRAGMA foreign_keys = 1 } 1
+fkey2-8-test 3 { BEGIN } 1
+fkey2-8-test 4 { PRAGMA foreign_keys = 0 } 1
+fkey2-8-test 5 { COMMIT } 1
+fkey2-8-test 6 { PRAGMA foreign_keys = 0 } 0
+fkey2-8-test 7 { BEGIN } 0
+fkey2-8-test 8 { PRAGMA foreign_keys = 1 } 0
+fkey2-8-test 9 { COMMIT } 0
+fkey2-8-test 10 { PRAGMA foreign_keys = 1 } 1
+fkey2-8-test 11 { PRAGMA foreign_keys = off } 0
+fkey2-8-test 12 { PRAGMA foreign_keys = on } 1
+fkey2-8-test 13 { PRAGMA foreign_keys = no } 0
+fkey2-8-test 14 { PRAGMA foreign_keys = yes } 1
+fkey2-8-test 15 { PRAGMA foreign_keys = false } 0
+fkey2-8-test 16 { PRAGMA foreign_keys = true } 1
+
+#-------------------------------------------------------------------------
+# The following tests, fkey2-9.*, test SET DEFAULT actions.
+#
+drop_all_tables
+do_test fkey2-9.1.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t2(
+ c INTEGER PRIMARY KEY,
+ d INTEGER DEFAULT 1 REFERENCES t1 ON DELETE SET DEFAULT
+ );
+ DELETE FROM t1;
+ }
+} {}
+do_test fkey2-9.1.2 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t2 VALUES(1, 2);
+ SELECT * FROM t2;
+ DELETE FROM t1 WHERE a = 2;
+ SELECT * FROM t2;
+ }
+} {1 2 1 1}
+do_test fkey2-9.1.3 {
+ execsql {
+ INSERT INTO t1 VALUES(2, 'two');
+ UPDATE t2 SET d = 2;
+ DELETE FROM t1 WHERE a = 1;
+ SELECT * FROM t2;
+ }
+} {1 2}
+do_test fkey2-9.1.4 {
+ execsql { SELECT * FROM t1 }
+} {2 two}
+do_test fkey2-9.1.5 {
+ catchsql { DELETE FROM t1 }
+} {1 {foreign key constraint failed}}
+
+do_test fkey2-9.2.1 {
+ execsql {
+ CREATE TABLE pp(a, b, c, PRIMARY KEY(b, c));
+ CREATE TABLE cc(d DEFAULT 3, e DEFAULT 1, f DEFAULT 2,
+ FOREIGN KEY(f, d) REFERENCES pp
+ ON UPDATE SET DEFAULT
+ ON DELETE SET NULL
+ );
+ INSERT INTO pp VALUES(1, 2, 3);
+ INSERT INTO pp VALUES(4, 5, 6);
+ INSERT INTO pp VALUES(7, 8, 9);
+ }
+} {}
+do_test fkey2-9.2.2 {
+ execsql {
+ INSERT INTO cc VALUES(6, 'A', 5);
+ INSERT INTO cc VALUES(6, 'B', 5);
+ INSERT INTO cc VALUES(9, 'A', 8);
+ INSERT INTO cc VALUES(9, 'B', 8);
+ UPDATE pp SET b = 1 WHERE a = 7;
+ SELECT * FROM cc;
+ }
+} {6 A 5 6 B 5 3 A 2 3 B 2}
+do_test fkey2-9.2.3 {
+ execsql {
+ DELETE FROM pp WHERE a = 4;
+ SELECT * FROM cc;
+ }
+} {{} A {} {} B {} 3 A 2 3 B 2}
+
+#-------------------------------------------------------------------------
+# The following tests, fkey2-10.*, test "foreign key mismatch" and
+# other errors.
+#
+set tn 0
+foreach zSql [list {
+ CREATE TABLE p(a PRIMARY KEY, b);
+ CREATE TABLE c(x REFERENCES p(c));
+} {
+ CREATE TABLE c(x REFERENCES v(y));
+ CREATE VIEW v AS SELECT x AS y FROM c;
+} {
+ CREATE TABLE p(a, b, PRIMARY KEY(a, b));
+ CREATE TABLE c(x REFERENCES p);
+} {
+ CREATE TABLE p(a COLLATE binary, b);
+ CREATE UNIQUE INDEX i ON p(a COLLATE nocase);
+ CREATE TABLE c(x REFERENCES p(a));
+}] {
+ drop_all_tables
+ do_test fkey2-10.1.[incr tn] {
+ execsql $zSql
+ catchsql { INSERT INTO c DEFAULT VALUES }
+ } {1 {foreign key mismatch}}
+}
+
+# "rowid" cannot be used as part of a child or parent key definition
+# unless it happens to be the name of an explicitly declared column.
+#
+do_test fkey2-10.2.1 {
+ drop_all_tables
+ catchsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TABLE t2(c, d, FOREIGN KEY(rowid) REFERENCES t1(a));
+ }
+} {1 {unknown column "rowid" in foreign key definition}}
+do_test fkey2-10.2.2 {
+ drop_all_tables
+ catchsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TABLE t2(rowid, d, FOREIGN KEY(rowid) REFERENCES t1(a));
+ }
+} {0 {}}
+do_test fkey2-10.2.1 {
+ drop_all_tables
+ catchsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d, FOREIGN KEY(c) REFERENCES t1(rowid));
+ INSERT INTO t1(rowid, a, b) VALUES(1, 1, 1);
+ INSERT INTO t2 VALUES(1, 1);
+ }
+} {1 {foreign key mismatch}}
+do_test fkey2-10.2.2 {
+ drop_all_tables
+ catchsql {
+ CREATE TABLE t1(rowid PRIMARY KEY, b);
+ CREATE TABLE t2(c, d, FOREIGN KEY(c) REFERENCES t1(rowid));
+ INSERT INTO t1(rowid, b) VALUES(1, 1);
+ INSERT INTO t2 VALUES(1, 1);
+ }
+} {0 {}}
+
+
+#-------------------------------------------------------------------------
+# The following tests, fkey2-11.*, test CASCADE actions.
+#
+drop_all_tables
+do_test fkey2-11.1.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t2(c, d, FOREIGN KEY(c) REFERENCES t1(a) ON UPDATE CASCADE);
+
+ INSERT INTO t1 VALUES(10, 100);
+ INSERT INTO t2 VALUES(10, 100);
+ UPDATE t1 SET a = 15;
+ SELECT * FROM t2;
+ }
+} {15 100}
+
+#-------------------------------------------------------------------------
+# The following tests, fkey2-12.*, test RESTRICT actions.
+#
+drop_all_tables
+do_test fkey2-12.1.1 {
+ execsql {
+ CREATE TABLE t1(a, b PRIMARY KEY);
+ CREATE TABLE t2(
+ x REFERENCES t1 ON UPDATE RESTRICT DEFERRABLE INITIALLY DEFERRED
+ );
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+ }
+} {}
+do_test fkey2-12.1.2 {
+ execsql "BEGIN"
+ execsql "INSERT INTO t2 VALUES('two')"
+} {}
+do_test fkey2-12.1.3 {
+ execsql "UPDATE t1 SET b = 'four' WHERE b = 'one'"
+} {}
+do_test fkey2-12.1.4 {
+ catchsql "UPDATE t1 SET b = 'five' WHERE b = 'two'"
+} {1 {foreign key constraint failed}}
+do_test fkey2-12.1.5 {
+ execsql "DELETE FROM t1 WHERE b = 'two'"
+} {}
+do_test fkey2-12.1.6 {
+ catchsql "COMMIT"
+} {1 {foreign key constraint failed}}
+do_test fkey2-12.1.7 {
+ execsql {
+ INSERT INTO t1 VALUES(2, 'two');
+ COMMIT;
+ }
+} {}
+
+drop_all_tables
+do_test fkey2-12.2.1 {
+ execsql {
+ CREATE TABLE t1(x COLLATE NOCASE PRIMARY KEY);
+ CREATE TRIGGER tt1 AFTER DELETE ON t1
+ WHEN EXISTS ( SELECT 1 FROM t2 WHERE old.x = y )
+ BEGIN
+ INSERT INTO t1 VALUES(old.x);
+ END;
+ CREATE TABLE t2(y REFERENCES t1);
+ INSERT INTO t1 VALUES('A');
+ INSERT INTO t1 VALUES('B');
+ INSERT INTO t2 VALUES('a');
+ INSERT INTO t2 VALUES('b');
+
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+} {A B a b}
+do_test fkey2-12.2.2 {
+ execsql { DELETE FROM t1 }
+ execsql {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+} {A B a b}
+do_test fkey2-12.2.3 {
+ execsql {
+ DROP TABLE t2;
+ CREATE TABLE t2(y REFERENCES t1 ON DELETE RESTRICT);
+ INSERT INTO t2 VALUES('a');
+ INSERT INTO t2 VALUES('b');
+ }
+ catchsql { DELETE FROM t1 }
+} {1 {foreign key constraint failed}}
+do_test fkey2-12.2.4 {
+ execsql {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+} {A B a b}
+
+drop_all_tables
+do_test fkey2-12.3.1 {
+ execsql {
+ CREATE TABLE up(
+ c00, c01, c02, c03, c04, c05, c06, c07, c08, c09,
+ c10, c11, c12, c13, c14, c15, c16, c17, c18, c19,
+ c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,
+ c30, c31, c32, c33, c34, c35, c36, c37, c38, c39,
+ PRIMARY KEY(c34, c35)
+ );
+ CREATE TABLE down(
+ c00, c01, c02, c03, c04, c05, c06, c07, c08, c09,
+ c10, c11, c12, c13, c14, c15, c16, c17, c18, c19,
+ c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,
+ c30, c31, c32, c33, c34, c35, c36, c37, c38, c39,
+ FOREIGN KEY(c39, c38) REFERENCES up ON UPDATE CASCADE
+ );
+ }
+} {}
+do_test fkey2-12.3.2 {
+ execsql {
+ INSERT INTO up(c34, c35) VALUES('yes', 'no');
+ INSERT INTO down(c39, c38) VALUES('yes', 'no');
+ UPDATE up SET c34 = 'possibly';
+ SELECT c38, c39 FROM down;
+ DELETE FROM down;
+ }
+} {no possibly}
+do_test fkey2-12.3.3 {
+ catchsql { INSERT INTO down(c39, c38) VALUES('yes', 'no') }
+} {1 {foreign key constraint failed}}
+do_test fkey2-12.3.4 {
+ execsql {
+ INSERT INTO up(c34, c35) VALUES('yes', 'no');
+ INSERT INTO down(c39, c38) VALUES('yes', 'no');
+ }
+ catchsql { DELETE FROM up WHERE c34 = 'yes' }
+} {1 {foreign key constraint failed}}
+do_test fkey2-12.3.5 {
+ execsql {
+ DELETE FROM up WHERE c34 = 'possibly';
+ SELECT c34, c35 FROM up;
+ SELECT c39, c38 FROM down;
+ }
+} {yes no yes no}
+
+#-------------------------------------------------------------------------
+# The following tests, fkey2-13.*, test that FK processing is performed
+# when rows are REPLACEd.
+#
+drop_all_tables
+do_test fkey2-13.1.1 {
+ execsql {
+ CREATE TABLE pp(a UNIQUE, b, c, PRIMARY KEY(b, c));
+ CREATE TABLE cc(d, e, f UNIQUE, FOREIGN KEY(d, e) REFERENCES pp);
+ INSERT INTO pp VALUES(1, 2, 3);
+ INSERT INTO cc VALUES(2, 3, 1);
+ }
+} {}
+foreach {tn stmt} {
+ 1 "REPLACE INTO pp VALUES(1, 4, 5)"
+ 2 "REPLACE INTO pp(rowid, a, b, c) VALUES(1, 2, 3, 4)"
+} {
+ do_test fkey2-13.1.$tn.1 {
+ catchsql $stmt
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-13.1.$tn.2 {
+ execsql {
+ SELECT * FROM pp;
+ SELECT * FROM cc;
+ }
+ } {1 2 3 2 3 1}
+ do_test fkey2-13.1.$tn.3 {
+ execsql BEGIN;
+ catchsql $stmt
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-13.1.$tn.4 {
+ execsql {
+ COMMIT;
+ SELECT * FROM pp;
+ SELECT * FROM cc;
+ }
+ } {1 2 3 2 3 1}
+}
+do_test fkey2-13.1.3 {
+ execsql {
+ REPLACE INTO pp(rowid, a, b, c) VALUES(1, 2, 2, 3);
+ SELECT rowid, * FROM pp;
+ SELECT * FROM cc;
+ }
+} {1 2 2 3 2 3 1}
+do_test fkey2-13.1.4 {
+ execsql {
+ REPLACE INTO pp(rowid, a, b, c) VALUES(2, 2, 2, 3);
+ SELECT rowid, * FROM pp;
+ SELECT * FROM cc;
+ }
+} {2 2 2 3 2 3 1}
+
+#-------------------------------------------------------------------------
+# The following tests, fkey2-14.*, test that the "DROP TABLE" and "ALTER
+# TABLE" commands work as expected wrt foreign key constraints.
+#
+# fkey2-14.1*: ALTER TABLE ADD COLUMN
+# fkey2-14.2*: ALTER TABLE RENAME TABLE
+# fkey2-14.3*: DROP TABLE
+#
+drop_all_tables
+ifcapable altertable {
+ do_test fkey2-14.1.1 {
+ # Adding a column with a REFERENCES clause is not supported.
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY);
+ CREATE TABLE t2(a, b);
+ }
+ catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }
+ } {0 {}}
+ do_test fkey2-14.1.2 {
+ catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }
+ } {0 {}}
+ do_test fkey2-14.1.3 {
+ catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}
+ } {0 {}}
+ do_test fkey2-14.1.4 {
+ catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'}
+ } {1 {Cannot add a REFERENCES column with non-NULL default value}}
+ do_test fkey2-14.1.5 {
+ catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }
+ } {1 {Cannot add a REFERENCES column with non-NULL default value}}
+ do_test fkey2-14.1.6 {
+ execsql {
+ PRAGMA foreign_keys = off;
+ ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;
+ PRAGMA foreign_keys = on;
+ SELECT sql FROM sqlite_master WHERE name='t2';
+ }
+ } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}
+
+
+ # Test the sqlite_rename_parent() function directly.
+ #
+ proc test_rename_parent {zCreate zOld zNew} {
+ db eval {SELECT sqlite_rename_parent($zCreate, $zOld, $zNew)}
+ }
+ do_test fkey2-14.2.1.1 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+ do_test fkey2-14.2.1.2 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
+ } {{CREATE TABLE t1(a REFERENCES t2)}}
+ do_test fkey2-14.2.1.3 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+
+ # Test ALTER TABLE RENAME TABLE a bit.
+ #
+ do_test fkey2-14.2.2.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1);
+ CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2);
+ CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);
+ }
+ execsql { SELECT sql FROM sqlite_master WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)} \
+ {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)} \
+ ]
+ do_test fkey2-14.2.2.2 {
+ execsql { ALTER TABLE t1 RENAME TO t4 }
+ execsql { SELECT sql FROM sqlite_master WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)} \
+ {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
+ ]
+ do_test fkey2-14.2.2.3 {
+ catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-14.2.2.4 {
+ execsql { INSERT INTO t4 VALUES(1, NULL) }
+ } {}
+ do_test fkey2-14.2.2.5 {
+ catchsql { UPDATE t4 SET b = 5 }
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-14.2.2.6 {
+ catchsql { UPDATE t4 SET b = 1 }
+ } {0 {}}
+ do_test fkey2-14.2.2.7 {
+ execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
+ } {}
+
+ # Repeat for TEMP tables
+ #
+ drop_all_tables
+ do_test fkey2-14.1tmp.1 {
+ # Adding a column with a REFERENCES clause is not supported.
+ execsql {
+ CREATE TEMP TABLE t1(a PRIMARY KEY);
+ CREATE TEMP TABLE t2(a, b);
+ }
+ catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }
+ } {0 {}}
+ do_test fkey2-14.1tmp.2 {
+ catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }
+ } {0 {}}
+ do_test fkey2-14.1tmp.3 {
+ catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}
+ } {0 {}}
+ do_test fkey2-14.1tmp.4 {
+ catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'}
+ } {1 {Cannot add a REFERENCES column with non-NULL default value}}
+ do_test fkey2-14.1tmp.5 {
+ catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }
+ } {1 {Cannot add a REFERENCES column with non-NULL default value}}
+ do_test fkey2-14.1tmp.6 {
+ execsql {
+ PRAGMA foreign_keys = off;
+ ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;
+ PRAGMA foreign_keys = on;
+ SELECT sql FROM sqlite_temp_master WHERE name='t2';
+ }
+ } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}
+
+ do_test fkey2-14.2tmp.1.1 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+ do_test fkey2-14.2tmp.1.2 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
+ } {{CREATE TABLE t1(a REFERENCES t2)}}
+ do_test fkey2-14.2tmp.1.3 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+
+ # Test ALTER TABLE RENAME TABLE a bit.
+ #
+ do_test fkey2-14.2tmp.2.1 {
+ drop_all_tables
+ execsql {
+ CREATE TEMP TABLE t1(a PRIMARY KEY, b REFERENCES t1);
+ CREATE TEMP TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2);
+ CREATE TEMP TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);
+ }
+ execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)} \
+ {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)} \
+ ]
+ do_test fkey2-14.2tmp.2.2 {
+ execsql { ALTER TABLE t1 RENAME TO t4 }
+ execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)} \
+ {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
+ ]
+ do_test fkey2-14.2tmp.2.3 {
+ catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-14.2tmp.2.4 {
+ execsql { INSERT INTO t4 VALUES(1, NULL) }
+ } {}
+ do_test fkey2-14.2tmp.2.5 {
+ catchsql { UPDATE t4 SET b = 5 }
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-14.2tmp.2.6 {
+ catchsql { UPDATE t4 SET b = 1 }
+ } {0 {}}
+ do_test fkey2-14.2tmp.2.7 {
+ execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
+ } {}
+
+ # Repeat for ATTACH-ed tables
+ #
+ drop_all_tables
+ do_test fkey2-14.1aux.1 {
+ # Adding a column with a REFERENCES clause is not supported.
+ execsql {
+ ATTACH ':memory:' AS aux;
+ CREATE TABLE aux.t1(a PRIMARY KEY);
+ CREATE TABLE aux.t2(a, b);
+ }
+ catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }
+ } {0 {}}
+ do_test fkey2-14.1aux.2 {
+ catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }
+ } {0 {}}
+ do_test fkey2-14.1aux.3 {
+ catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}
+ } {0 {}}
+ do_test fkey2-14.1aux.4 {
+ catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'}
+ } {1 {Cannot add a REFERENCES column with non-NULL default value}}
+ do_test fkey2-14.1aux.5 {
+ catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }
+ } {1 {Cannot add a REFERENCES column with non-NULL default value}}
+ do_test fkey2-14.1aux.6 {
+ execsql {
+ PRAGMA foreign_keys = off;
+ ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;
+ PRAGMA foreign_keys = on;
+ SELECT sql FROM aux.sqlite_master WHERE name='t2';
+ }
+ } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}
+
+ do_test fkey2-14.2aux.1.1 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+ do_test fkey2-14.2aux.1.2 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
+ } {{CREATE TABLE t1(a REFERENCES t2)}}
+ do_test fkey2-14.2aux.1.3 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+
+ # Test ALTER TABLE RENAME TABLE a bit.
+ #
+ do_test fkey2-14.2aux.2.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE aux.t1(a PRIMARY KEY, b REFERENCES t1);
+ CREATE TABLE aux.t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2);
+ CREATE TABLE aux.t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);
+ }
+ execsql { SELECT sql FROM aux.sqlite_master WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)} \
+ {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)} \
+ ]
+ do_test fkey2-14.2aux.2.2 {
+ execsql { ALTER TABLE t1 RENAME TO t4 }
+ execsql { SELECT sql FROM aux.sqlite_master WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)} \
+ {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
+ ]
+ do_test fkey2-14.2aux.2.3 {
+ catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-14.2aux.2.4 {
+ execsql { INSERT INTO t4 VALUES(1, NULL) }
+ } {}
+ do_test fkey2-14.2aux.2.5 {
+ catchsql { UPDATE t4 SET b = 5 }
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-14.2aux.2.6 {
+ catchsql { UPDATE t4 SET b = 1 }
+ } {0 {}}
+ do_test fkey2-14.2aux.2.7 {
+ execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
+ } {}
+}
+
+do_test fkey-2.14.3.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE t1(a, b REFERENCES nosuchtable);
+ DROP TABLE t1;
+ }
+} {}
+do_test fkey-2.14.3.2 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES('a', 1);
+ CREATE TABLE t2(x REFERENCES t1);
+ INSERT INTO t2 VALUES('a');
+ }
+} {}
+do_test fkey-2.14.3.3 {
+ catchsql { DROP TABLE t1 }
+} {1 {foreign key constraint failed}}
+do_test fkey-2.14.3.4 {
+ execsql {
+ DELETE FROM t2;
+ DROP TABLE t1;
+ }
+} {}
+do_test fkey-2.14.3.4 {
+ catchsql { INSERT INTO t2 VALUES('x') }
+} {1 {no such table: main.t1}}
+do_test fkey-2.14.3.5 {
+ execsql {
+ CREATE TABLE t1(x PRIMARY KEY);
+ INSERT INTO t1 VALUES('x');
+ }
+ execsql { INSERT INTO t2 VALUES('x') }
+} {}
+do_test fkey-2.14.3.6 {
+ catchsql { DROP TABLE t1 }
+} {1 {foreign key constraint failed}}
+do_test fkey-2.14.3.7 {
+ execsql {
+ DROP TABLE t2;
+ DROP TABLE t1;
+ }
+} {}
+do_test fkey-2.14.3.8 {
+ execsql {
+ CREATE TABLE pp(x, y, PRIMARY KEY(x, y));
+ CREATE TABLE cc(a, b, FOREIGN KEY(a, b) REFERENCES pp(x, z));
+ }
+ catchsql { INSERT INTO cc VALUES(1, 2) }
+} {1 {foreign key mismatch}}
+do_test fkey-2.14.3.9 {
+ execsql { DROP TABLE cc }
+} {}
+do_test fkey-2.14.3.10 {
+ execsql {
+ CREATE TABLE cc(a, b,
+ FOREIGN KEY(a, b) REFERENCES pp DEFERRABLE INITIALLY DEFERRED
+ );
+ }
+ execsql {
+ INSERT INTO pp VALUES('a', 'b');
+ INSERT INTO cc VALUES('a', 'b');
+ BEGIN;
+ DROP TABLE pp;
+ CREATE TABLE pp(a, b, c, PRIMARY KEY(b, c));
+ INSERT INTO pp VALUES(1, 'a', 'b');
+ COMMIT;
+ }
+} {}
+do_test fkey-2.14.3.11 {
+ execsql {
+ BEGIN;
+ DROP TABLE cc;
+ DROP TABLE pp;
+ COMMIT;
+ }
+} {}
+do_test fkey-2.14.3.12 {
+ execsql {
+ CREATE TABLE b1(a, b);
+ CREATE TABLE b2(a, b REFERENCES b1);
+ DROP TABLE b1;
+ }
+} {}
+do_test fkey-2.14.3.13 {
+ execsql {
+ CREATE TABLE b3(a, b REFERENCES b2 DEFERRABLE INITIALLY DEFERRED);
+ DROP TABLE b2;
+ }
+} {}
+
+# Test that nothing goes wrong when dropping a table that refers to a view.
+# Or dropping a view that an existing FK (incorrectly) refers to. Or either
+# of the above scenarios with a virtual table.
+drop_all_tables
+do_test fkey-2.14.4.1 {
+ execsql {
+ CREATE TABLE t1(x REFERENCES v);
+ CREATE VIEW v AS SELECT * FROM t1;
+ }
+} {}
+do_test fkey-2.14.4.2 {
+ execsql {
+ DROP VIEW v;
+ }
+} {}
+ifcapable vtab {
+ register_echo_module db
+ do_test fkey-2.14.4.3 {
+ execsql { CREATE VIRTUAL TABLE v USING echo(t1) }
+ } {}
+ do_test fkey-2.14.4.2 {
+ execsql {
+ DROP TABLE v;
+ }
+ } {}
+}
+
+#-------------------------------------------------------------------------
+# The following tests, fkey2-15.*, test that unnecessary FK related scans
+# and lookups are avoided when the constraint counters are zero.
+#
+drop_all_tables
+proc execsqlS {zSql} {
+ set ::sqlite_search_count 0
+ set ::sqlite_found_count 0
+ set res [uplevel [list execsql $zSql]]
+ concat [expr $::sqlite_found_count + $::sqlite_search_count] $res
+}
+do_test fkey2-15.1.1 {
+ execsql {
+ CREATE TABLE pp(a PRIMARY KEY, b);
+ CREATE TABLE cc(x, y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);
+ INSERT INTO pp VALUES(1, 'one');
+ INSERT INTO pp VALUES(2, 'two');
+ INSERT INTO cc VALUES('neung', 1);
+ INSERT INTO cc VALUES('song', 2);
+ }
+} {}
+do_test fkey2-15.1.2 {
+ execsqlS { INSERT INTO pp VALUES(3, 'three') }
+} {0}
+do_test fkey2-15.1.3 {
+ execsql {
+ BEGIN;
+ INSERT INTO cc VALUES('see', 4); -- Violates deferred constraint
+ }
+ execsqlS { INSERT INTO pp VALUES(5, 'five') }
+} {2}
+do_test fkey2-15.1.4 {
+ execsql { DELETE FROM cc WHERE x = 'see' }
+ execsqlS { INSERT INTO pp VALUES(6, 'six') }
+} {0}
+do_test fkey2-15.1.5 {
+ execsql COMMIT
+} {}
+do_test fkey2-15.1.6 {
+ execsql BEGIN
+ execsqlS {
+ DELETE FROM cc WHERE x = 'neung';
+ ROLLBACK;
+ }
+} {1}
+do_test fkey2-15.1.7 {
+ execsql {
+ BEGIN;
+ DELETE FROM pp WHERE a = 2;
+ }
+ execsqlS {
+ DELETE FROM cc WHERE x = 'neung';
+ ROLLBACK;
+ }
+} {2}
+
+#-------------------------------------------------------------------------
+# This next block of tests, fkey2-16.*, test that rows that refer to
+# themselves may be inserted and deleted.
+#
+foreach {tn zSchema} {
+ 1 { CREATE TABLE self(a INTEGER PRIMARY KEY, b REFERENCES self(a)) }
+ 2 { CREATE TABLE self(a PRIMARY KEY, b REFERENCES self(a)) }
+ 3 { CREATE TABLE self(a UNIQUE, b INTEGER PRIMARY KEY REFERENCES self(a)) }
+} {
+ drop_all_tables
+ do_test fkey2-16.1.$tn.1 {
+ execsql $zSchema
+ execsql { INSERT INTO self VALUES(13, 13) }
+ } {}
+ do_test fkey2-16.1.$tn.2 {
+ execsql { UPDATE self SET a = 14, b = 14 }
+ } {}
+
+ do_test fkey2-16.1.$tn.3 {
+ catchsql { UPDATE self SET b = 15 }
+ } {1 {foreign key constraint failed}}
+
+ do_test fkey2-16.1.$tn.4 {
+ catchsql { UPDATE self SET a = 15 }
+ } {1 {foreign key constraint failed}}
+
+ do_test fkey2-16.1.$tn.5 {
+ catchsql { UPDATE self SET a = 15, b = 16 }
+ } {1 {foreign key constraint failed}}
+
+ do_test fkey2-16.1.$tn.6 {
+ catchsql { UPDATE self SET a = 17, b = 17 }
+ } {0 {}}
+
+ do_test fkey2-16.1.$tn.7 {
+ execsql { DELETE FROM self }
+ } {}
+ do_test fkey2-16.1.$tn.8 {
+ catchsql { INSERT INTO self VALUES(20, 21) }
+ } {1 {foreign key constraint failed}}
+}
+
+#-------------------------------------------------------------------------
+# This next block of tests, fkey2-17.*, tests that if "PRAGMA count_changes"
+# is turned on statements that violate immediate FK constraints return
+# SQLITE_CONSTRAINT immediately, not after returning a number of rows.
+# Whereas statements that violate deferred FK constraints return the number
+# of rows before failing.
+#
+# Also test that rows modified by FK actions are not counted in either the
+# returned row count or the values returned by sqlite3_changes(). Like
+# trigger related changes, they are included in sqlite3_total_changes() though.
+#
+drop_all_tables
+do_test fkey2-17.1.1 {
+ execsql { PRAGMA count_changes = 1 }
+ execsql {
+ CREATE TABLE one(a, b, c, UNIQUE(b, c));
+ CREATE TABLE two(d, e, f, FOREIGN KEY(e, f) REFERENCES one(b, c));
+ INSERT INTO one VALUES(1, 2, 3);
+ }
+} {1}
+do_test fkey2-17.1.2 {
+ set STMT [sqlite3_prepare_v2 db "INSERT INTO two VALUES(4, 5, 6)" -1 dummy]
+ sqlite3_step $STMT
+} {SQLITE_CONSTRAINT}
+ifcapable autoreset {
+ do_test fkey2-17.1.3 {
+ sqlite3_step $STMT
+ } {SQLITE_CONSTRAINT}
+} else {
+ do_test fkey2-17.1.3 {
+ sqlite3_step $STMT
+ } {SQLITE_MISUSE}
+}
+do_test fkey2-17.1.4 {
+ sqlite3_finalize $STMT
+} {SQLITE_CONSTRAINT}
+do_test fkey2-17.1.5 {
+ execsql {
+ INSERT INTO one VALUES(2, 3, 4);
+ INSERT INTO one VALUES(3, 4, 5);
+ INSERT INTO two VALUES(1, 2, 3);
+ INSERT INTO two VALUES(2, 3, 4);
+ INSERT INTO two VALUES(3, 4, 5);
+ }
+} {1 1 1 1 1}
+do_test fkey2-17.1.6 {
+ catchsql {
+ BEGIN;
+ INSERT INTO one VALUES(0, 0, 0);
+ UPDATE two SET e=e+1, f=f+1;
+ }
+} {1 {foreign key constraint failed}}
+do_test fkey2-17.1.7 {
+ execsql { SELECT * FROM one }
+} {1 2 3 2 3 4 3 4 5 0 0 0}
+do_test fkey2-17.1.8 {
+ execsql { SELECT * FROM two }
+} {1 2 3 2 3 4 3 4 5}
+do_test fkey2-17.1.9 {
+ execsql COMMIT
+} {}
+do_test fkey2-17.1.10 {
+ execsql {
+ CREATE TABLE three(
+ g, h, i,
+ FOREIGN KEY(h, i) REFERENCES one(b, c) DEFERRABLE INITIALLY DEFERRED
+ );
+ }
+} {}
+do_test fkey2-17.1.11 {
+ set STMT [sqlite3_prepare_v2 db "INSERT INTO three VALUES(7, 8, 9)" -1 dummy]
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test fkey2-17.1.12 {
+ sqlite3_column_text $STMT 0
+} {1}
+do_test fkey2-17.1.13 {
+ sqlite3_step $STMT
+} {SQLITE_CONSTRAINT}
+do_test fkey2-17.1.14 {
+ sqlite3_finalize $STMT
+} {SQLITE_CONSTRAINT}
+
+drop_all_tables
+do_test fkey2-17.2.1 {
+ execsql {
+ CREATE TABLE high("a'b!" PRIMARY KEY, b);
+ CREATE TABLE low(
+ c,
+ "d&6" REFERENCES high ON UPDATE CASCADE ON DELETE CASCADE
+ );
+ }
+} {}
+do_test fkey2-17.2.2 {
+ execsql {
+ INSERT INTO high VALUES('a', 'b');
+ INSERT INTO low VALUES('b', 'a');
+ }
+ db changes
+} {1}
+set nTotal [db total_changes]
+do_test fkey2-17.2.3 {
+ execsql { UPDATE high SET "a'b!" = 'c' }
+} {1}
+do_test fkey2-17.2.4 {
+ db changes
+} {1}
+do_test fkey2-17.2.5 {
+ expr [db total_changes] - $nTotal
+} {2}
+do_test fkey2-17.2.6 {
+ execsql { SELECT * FROM high ; SELECT * FROM low }
+} {c b b c}
+do_test fkey2-17.2.7 {
+ execsql { DELETE FROM high }
+} {1}
+do_test fkey2-17.2.8 {
+ db changes
+} {1}
+do_test fkey2-17.2.9 {
+ expr [db total_changes] - $nTotal
+} {4}
+do_test fkey2-17.2.10 {
+ execsql { SELECT * FROM high ; SELECT * FROM low }
+} {}
+execsql { PRAGMA count_changes = 0 }
+
+#-------------------------------------------------------------------------
+# Test that the authorization callback works.
+#
+
+ifcapable auth {
+ do_test fkey2-18.1 {
+ execsql {
+ CREATE TABLE long(a, b PRIMARY KEY, c);
+ CREATE TABLE short(d, e, f REFERENCES long);
+ CREATE TABLE mid(g, h, i REFERENCES long DEFERRABLE INITIALLY DEFERRED);
+ }
+ } {}
+
+ proc auth {args} {eval lappend ::authargs $args ; return SQLITE_OK}
+ db auth auth
+
+ # An insert on the parent table must read the child key of any deferred
+ # foreign key constraints. But not the child key of immediate constraints.
+ set authargs {}
+ do_test fkey2-18.2 {
+ execsql { INSERT INTO long VALUES(1, 2, 3) }
+ set authargs
+ } {SQLITE_INSERT long {} main {} SQLITE_READ mid i main {}}
+
+ # An insert on the child table of an immediate constraint must read the
+ # parent key columns (to see if it is a violation or not).
+ set authargs {}
+ do_test fkey2-18.3 {
+ execsql { INSERT INTO short VALUES(1, 3, 2) }
+ set authargs
+ } {SQLITE_INSERT short {} main {} SQLITE_READ long b main {}}
+
+ # As must an insert on the child table of a deferred constraint.
+ set authargs {}
+ do_test fkey2-18.4 {
+ execsql { INSERT INTO mid VALUES(1, 3, 2) }
+ set authargs
+ } {SQLITE_INSERT mid {} main {} SQLITE_READ long b main {}}
+
+ do_test fkey2-18.5 {
+ execsql {
+ CREATE TABLE nought(a, b PRIMARY KEY, c);
+ CREATE TABLE cross(d, e, f,
+ FOREIGN KEY(e) REFERENCES nought(b) ON UPDATE CASCADE
+ );
+ }
+ execsql { INSERT INTO nought VALUES(2, 1, 2) }
+ execsql { INSERT INTO cross VALUES(0, 1, 0) }
+ set authargs [list]
+ execsql { UPDATE nought SET b = 5 }
+ set authargs
+ } {SQLITE_UPDATE nought b main {} SQLITE_READ cross e main {} SQLITE_READ cross e main {} SQLITE_READ nought b main {} SQLITE_READ nought b main {} SQLITE_READ nought b main {} SQLITE_UPDATE cross e main {} SQLITE_READ nought b main {} SQLITE_READ cross e main {} SQLITE_READ nought b main {} SQLITE_READ nought b main {}}
+
+ do_test fkey2-18.6 {
+ execsql {SELECT * FROM cross}
+ } {0 5 0}
+
+ do_test fkey2-18.7 {
+ execsql {
+ CREATE TABLE one(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE two(b, c REFERENCES one);
+ INSERT INTO one VALUES(101, 102);
+ }
+ set authargs [list]
+ execsql { INSERT INTO two VALUES(100, 101); }
+ set authargs
+ } {SQLITE_INSERT two {} main {} SQLITE_READ one a main {}}
+
+ # Return SQLITE_IGNORE to requests to read from the parent table. This
+ # causes inserts of non-NULL keys into the child table to fail.
+ #
+ rename auth {}
+ proc auth {args} {
+ if {[lindex $args 1] == "long"} {return SQLITE_IGNORE}
+ return SQLITE_OK
+ }
+ do_test fkey2-18.8 {
+ catchsql { INSERT INTO short VALUES(1, 3, 2) }
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-18.9 {
+ execsql { INSERT INTO short VALUES(1, 3, NULL) }
+ } {}
+ do_test fkey2-18.10 {
+ execsql { SELECT * FROM short }
+ } {1 3 2 1 3 {}}
+ do_test fkey2-18.11 {
+ catchsql { UPDATE short SET f = 2 WHERE f IS NULL }
+ } {1 {foreign key constraint failed}}
+
+ db auth {}
+ unset authargs
+}
+
+
+do_test fkey2-19.1 {
+ execsql {
+ CREATE TABLE main(id INTEGER PRIMARY KEY);
+ CREATE TABLE sub(id INT REFERENCES main(id));
+ INSERT INTO main VALUES(1);
+ INSERT INTO main VALUES(2);
+ INSERT INTO sub VALUES(2);
+ }
+} {}
+do_test fkey2-19.2 {
+ set S [sqlite3_prepare_v2 db "DELETE FROM main WHERE id = ?" -1 dummy]
+ sqlite3_bind_int $S 1 2
+ sqlite3_step $S
+} {SQLITE_CONSTRAINT}
+do_test fkey2-19.3 {
+ sqlite3_reset $S
+} {SQLITE_CONSTRAINT}
+do_test fkey2-19.4 {
+ sqlite3_bind_int $S 1 1
+ sqlite3_step $S
+} {SQLITE_DONE}
+do_test fkey2-19.4 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+drop_all_tables
+do_test fkey2-20.1 {
+ execsql {
+ CREATE TABLE pp(a PRIMARY KEY, b);
+ CREATE TABLE cc(c PRIMARY KEY, d REFERENCES pp);
+ }
+} {}
+
+foreach {tn insert} {
+ 1 "INSERT"
+ 2 "INSERT OR IGNORE"
+ 3 "INSERT OR ABORT"
+ 4 "INSERT OR ROLLBACK"
+ 5 "INSERT OR REPLACE"
+ 6 "INSERT OR FAIL"
+} {
+ do_test fkey2-20.2.$tn.1 {
+ catchsql "$insert INTO cc VALUES(1, 2)"
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-20.2.$tn.2 {
+ execsql { SELECT * FROM cc }
+ } {}
+ do_test fkey2-20.2.$tn.3 {
+ execsql {
+ BEGIN;
+ INSERT INTO pp VALUES(2, 'two');
+ INSERT INTO cc VALUES(1, 2);
+ }
+ catchsql "$insert INTO cc VALUES(3, 4)"
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-20.2.$tn.4 {
+ execsql { COMMIT ; SELECT * FROM cc }
+ } {1 2}
+ do_test fkey2-20.2.$tn.5 {
+ execsql { DELETE FROM cc ; DELETE FROM pp }
+ } {}
+}
+
+foreach {tn update} {
+ 1 "UPDATE"
+ 2 "UPDATE OR IGNORE"
+ 3 "UPDATE OR ABORT"
+ 4 "UPDATE OR ROLLBACK"
+ 5 "UPDATE OR REPLACE"
+ 6 "UPDATE OR FAIL"
+} {
+ do_test fkey2-20.3.$tn.1 {
+ execsql {
+ INSERT INTO pp VALUES(2, 'two');
+ INSERT INTO cc VALUES(1, 2);
+ }
+ } {}
+ do_test fkey2-20.3.$tn.2 {
+ catchsql "$update pp SET a = 1"
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-20.3.$tn.3 {
+ execsql { SELECT * FROM pp }
+ } {2 two}
+ do_test fkey2-20.3.$tn.4 {
+ catchsql "$update cc SET d = 1"
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-20.3.$tn.5 {
+ execsql { SELECT * FROM cc }
+ } {1 2}
+ do_test fkey2-20.3.$tn.6 {
+ execsql {
+ BEGIN;
+ INSERT INTO pp VALUES(3, 'three');
+ }
+ catchsql "$update pp SET a = 1 WHERE a = 2"
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-20.3.$tn.7 {
+ execsql { COMMIT ; SELECT * FROM pp }
+ } {2 two 3 three}
+ do_test fkey2-20.3.$tn.8 {
+ execsql {
+ BEGIN;
+ INSERT INTO cc VALUES(2, 2);
+ }
+ catchsql "$update cc SET d = 1 WHERE c = 1"
+ } {1 {foreign key constraint failed}}
+ do_test fkey2-20.3.$tn.9 {
+ execsql { COMMIT ; SELECT * FROM cc }
+ } {1 2 2 2}
+ do_test fkey2-20.3.$tn.10 {
+ execsql { DELETE FROM cc ; DELETE FROM pp }
+ } {}
+}
+
+#-------------------------------------------------------------------------
+# The following block of tests, those prefixed with "fkey2-genfkey.", are
+# the same tests that were used to test the ".genfkey" command provided
+# by the shell tool. So these tests show that the built-in foreign key
+# implementation is more or less compatible with the triggers generated
+# by genfkey.
+#
+drop_all_tables
+do_test fkey2-genfkey.1.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));
+ CREATE TABLE t2(e REFERENCES t1, f);
+ CREATE TABLE t3(g, h, i, FOREIGN KEY (h, i) REFERENCES t1(b, c));
+ }
+} {}
+do_test fkey2-genfkey.1.2 {
+ catchsql { INSERT INTO t2 VALUES(1, 2) }
+} {1 {foreign key constraint failed}}
+do_test fkey2-genfkey.1.3 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(1, 2);
+ }
+} {}
+do_test fkey2-genfkey.1.4 {
+ execsql { INSERT INTO t2 VALUES(NULL, 3) }
+} {}
+do_test fkey2-genfkey.1.5 {
+ catchsql { UPDATE t2 SET e = 5 WHERE e IS NULL }
+} {1 {foreign key constraint failed}}
+do_test fkey2-genfkey.1.6 {
+ execsql { UPDATE t2 SET e = 1 WHERE e IS NULL }
+} {}
+do_test fkey2-genfkey.1.7 {
+ execsql { UPDATE t2 SET e = NULL WHERE f = 3 }
+} {}
+do_test fkey2-genfkey.1.8 {
+ catchsql { UPDATE t1 SET a = 10 }
+} {1 {foreign key constraint failed}}
+do_test fkey2-genfkey.1.9 {
+ catchsql { UPDATE t1 SET a = NULL }
+} {1 {datatype mismatch}}
+do_test fkey2-genfkey.1.10 {
+ catchsql { DELETE FROM t1 }
+} {1 {foreign key constraint failed}}
+do_test fkey2-genfkey.1.11 {
+ execsql { UPDATE t2 SET e = NULL }
+} {}
+do_test fkey2-genfkey.1.12 {
+ execsql {
+ UPDATE t1 SET a = 10;
+ DELETE FROM t1;
+ DELETE FROM t2;
+ }
+} {}
+do_test fkey2-genfkey.1.13 {
+ execsql {
+ INSERT INTO t3 VALUES(1, NULL, NULL);
+ INSERT INTO t3 VALUES(1, 2, NULL);
+ INSERT INTO t3 VALUES(1, NULL, 3);
+ }
+} {}
+do_test fkey2-genfkey.1.14 {
+ catchsql { INSERT INTO t3 VALUES(3, 1, 4) }
+} {1 {foreign key constraint failed}}
+do_test fkey2-genfkey.1.15 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 1, 4);
+ INSERT INTO t3 VALUES(3, 1, 4);
+ }
+} {}
+do_test fkey2-genfkey.1.16 {
+ catchsql { DELETE FROM t1 }
+} {1 {foreign key constraint failed}}
+do_test fkey2-genfkey.1.17 {
+ catchsql { UPDATE t1 SET b = 10}
+} {1 {foreign key constraint failed}}
+do_test fkey2-genfkey.1.18 {
+ execsql { UPDATE t1 SET a = 10}
+} {}
+do_test fkey2-genfkey.1.19 {
+ catchsql { UPDATE t3 SET h = 'hello' WHERE i = 3}
+} {1 {foreign key constraint failed}}
+
+drop_all_tables
+do_test fkey2-genfkey.2.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));
+ CREATE TABLE t2(e REFERENCES t1 ON UPDATE CASCADE ON DELETE CASCADE, f);
+ CREATE TABLE t3(g, h, i,
+ FOREIGN KEY (h, i)
+ REFERENCES t1(b, c) ON UPDATE CASCADE ON DELETE CASCADE
+ );
+ }
+} {}
+do_test fkey2-genfkey.2.2 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ INSERT INTO t2 VALUES(1, 'one');
+ INSERT INTO t2 VALUES(4, 'four');
+ }
+} {}
+do_test fkey2-genfkey.2.3 {
+ execsql {
+ UPDATE t1 SET a = 2 WHERE a = 1;
+ SELECT * FROM t2;
+ }
+} {2 one 4 four}
+do_test fkey2-genfkey.2.4 {
+ execsql {
+ DELETE FROM t1 WHERE a = 4;
+ SELECT * FROM t2;
+ }
+} {2 one}
+
+do_test fkey2-genfkey.2.5 {
+ execsql {
+ INSERT INTO t3 VALUES('hello', 2, 3);
+ UPDATE t1 SET c = 2;
+ SELECT * FROM t3;
+ }
+} {hello 2 2}
+do_test fkey2-genfkey.2.6 {
+ execsql {
+ DELETE FROM t1;
+ SELECT * FROM t3;
+ }
+} {}
+
+drop_all_tables
+do_test fkey2-genfkey.3.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(c, b));
+ CREATE TABLE t2(e REFERENCES t1 ON UPDATE SET NULL ON DELETE SET NULL, f);
+ CREATE TABLE t3(g, h, i,
+ FOREIGN KEY (h, i)
+ REFERENCES t1(b, c) ON UPDATE SET NULL ON DELETE SET NULL
+ );
+ }
+} {}
+do_test fkey2-genfkey.3.2 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ INSERT INTO t2 VALUES(1, 'one');
+ INSERT INTO t2 VALUES(4, 'four');
+ }
+} {}
+do_test fkey2-genfkey.3.3 {
+ execsql {
+ UPDATE t1 SET a = 2 WHERE a = 1;
+ SELECT * FROM t2;
+ }
+} {{} one 4 four}
+do_test fkey2-genfkey.3.4 {
+ execsql {
+ DELETE FROM t1 WHERE a = 4;
+ SELECT * FROM t2;
+ }
+} {{} one {} four}
+do_test fkey2-genfkey.3.5 {
+ execsql {
+ INSERT INTO t3 VALUES('hello', 2, 3);
+ UPDATE t1 SET c = 2;
+ SELECT * FROM t3;
+ }
+} {hello {} {}}
+do_test fkey2-genfkey.3.6 {
+ execsql {
+ UPDATE t3 SET h = 2, i = 2;
+ DELETE FROM t1;
+ SELECT * FROM t3;
+ }
+} {hello {} {}}
+
+#-------------------------------------------------------------------------
+# Verify that ticket dd08e5a988d00decc4a543daa8dbbfab9c577ad8 has been
+# fixed.
+#
+do_test fkey2-dd08e5.1.1 {
+ execsql {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE tdd08(a INTEGER PRIMARY KEY, b);
+ CREATE UNIQUE INDEX idd08 ON tdd08(a,b);
+ INSERT INTO tdd08 VALUES(200,300);
+
+ CREATE TABLE tdd08_b(w,x,y, FOREIGN KEY(x,y) REFERENCES tdd08(a,b));
+ INSERT INTO tdd08_b VALUES(100,200,300);
+ }
+} {}
+do_test fkey2-dd08e5.1.2 {
+ catchsql {
+ DELETE FROM tdd08;
+ }
+} {1 {foreign key constraint failed}}
+do_test fkey2-dd08e5.1.3 {
+ execsql {
+ SELECT * FROM tdd08;
+ }
+} {200 300}
+do_test fkey2-dd08e5.1.4 {
+ catchsql {
+ INSERT INTO tdd08_b VALUES(400,500,300);
+ }
+} {1 {foreign key constraint failed}}
+do_test fkey2-dd08e5.1.5 {
+ catchsql {
+ UPDATE tdd08_b SET x=x+1;
+ }
+} {1 {foreign key constraint failed}}
+do_test fkey2-dd08e5.1.6 {
+ catchsql {
+ UPDATE tdd08 SET a=a+1;
+ }
+} {1 {foreign key constraint failed}}
+
+#-------------------------------------------------------------------------
+# Verify that ticket ce7c133ea6cc9ccdc1a60d80441f80b6180f5eba
+# fixed.
+#
+do_test fkey2-ce7c13.1.1 {
+ execsql {
+ CREATE TABLE tce71(a INTEGER PRIMARY KEY, b);
+ CREATE UNIQUE INDEX ice71 ON tce71(a,b);
+ INSERT INTO tce71 VALUES(100,200);
+ CREATE TABLE tce72(w, x, y, FOREIGN KEY(x,y) REFERENCES tce71(a,b));
+ INSERT INTO tce72 VALUES(300,100,200);
+ UPDATE tce71 set b = 200 where a = 100;
+ SELECT * FROM tce71, tce72;
+ }
+} {100 200 300 100 200}
+do_test fkey2-ce7c13.1.2 {
+ catchsql {
+ UPDATE tce71 set b = 201 where a = 100;
+ }
+} {1 {foreign key constraint failed}}
+do_test fkey2-ce7c13.1.3 {
+ catchsql {
+ UPDATE tce71 set a = 101 where a = 100;
+ }
+} {1 {foreign key constraint failed}}
+do_test fkey2-ce7c13.1.4 {
+ execsql {
+ CREATE TABLE tce73(a INTEGER PRIMARY KEY, b, UNIQUE(a,b));
+ INSERT INTO tce73 VALUES(100,200);
+ CREATE TABLE tce74(w, x, y, FOREIGN KEY(x,y) REFERENCES tce73(a,b));
+ INSERT INTO tce74 VALUES(300,100,200);
+ UPDATE tce73 set b = 200 where a = 100;
+ SELECT * FROM tce73, tce74;
+ }
+} {100 200 300 100 200}
+do_test fkey2-ce7c13.1.5 {
+ catchsql {
+ UPDATE tce73 set b = 201 where a = 100;
+ }
+} {1 {foreign key constraint failed}}
+do_test fkey2-ce7c13.1.6 {
+ catchsql {
+ UPDATE tce73 set a = 101 where a = 100;
+ }
+} {1 {foreign key constraint failed}}
+
+finish_test
diff --git a/test/fkey3.test b/test/fkey3.test
new file mode 100644
index 0000000..6a11f88
--- /dev/null
+++ b/test/fkey3.test
@@ -0,0 +1,186 @@
+# 2009 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for foreign keys.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!foreignkey||!trigger} {
+ finish_test
+ return
+}
+
+set testprefix fkey3
+
+# Create a table and some data to work with.
+#
+do_test fkey3-1.1 {
+ execsql {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(100);
+ INSERT INTO t1 VALUES(101);
+ CREATE TABLE t2(y INTEGER REFERENCES t1 (x));
+ INSERT INTO t2 VALUES(100);
+ INSERT INTO t2 VALUES(101);
+ SELECT 1, x FROM t1;
+ SELECT 2, y FROM t2;
+ }
+} {1 100 1 101 2 100 2 101}
+
+do_test fkey3-1.2 {
+ catchsql {
+ DELETE FROM t1 WHERE x=100;
+ }
+} {1 {foreign key constraint failed}}
+
+do_test fkey3-1.3 {
+ catchsql {
+ DROP TABLE t1;
+ }
+} {1 {foreign key constraint failed}}
+
+do_test fkey3-1.4 {
+ execsql {
+ DROP TABLE t2;
+ }
+} {}
+
+do_test fkey3-1.5 {
+ execsql {
+ DROP TABLE t1;
+ }
+} {}
+
+do_test fkey3-2.1 {
+ execsql {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(100);
+ INSERT INTO t1 VALUES(101);
+ CREATE TABLE t2(y INTEGER PRIMARY KEY REFERENCES t1 (x) ON UPDATE SET NULL);
+ }
+ execsql {
+ INSERT INTO t2 VALUES(100);
+ INSERT INTO t2 VALUES(101);
+ SELECT 1, x FROM t1;
+ SELECT 2, y FROM t2;
+ }
+} {1 100 1 101 2 100 2 101}
+
+
+#-------------------------------------------------------------------------
+# The following tests - fkey-3.* - test some edge cases to do with
+# inserting rows into tables that have foreign keys where the parent
+# table is the same as the child table. Especially cases where the
+# new row being inserted matches itself.
+#
+do_execsql_test 3.1.1 {
+ CREATE TABLE t3(a, b, c, d,
+ UNIQUE(a, b),
+ FOREIGN KEY(c, d) REFERENCES t3(a, b)
+ );
+ INSERT INTO t3 VALUES(1, 2, 1, 2);
+} {}
+do_catchsql_test 3.1.2 {
+ INSERT INTO t3 VALUES(NULL, 2, 5, 2);
+} {1 {foreign key constraint failed}}
+do_catchsql_test 3.1.3 {
+ INSERT INTO t3 VALUES(NULL, 3, 5, 2);
+} {1 {foreign key constraint failed}}
+
+do_execsql_test 3.2.1 {
+ CREATE TABLE t4(a UNIQUE, b REFERENCES t4(a));
+}
+do_catchsql_test 3.2.2 {
+ INSERT INTO t4 VALUES(NULL, 1);
+} {1 {foreign key constraint failed}}
+
+do_execsql_test 3.3.1 {
+ CREATE TABLE t5(a INTEGER PRIMARY KEY, b REFERENCES t5(a));
+ INSERT INTO t5 VALUES(NULL, 1);
+} {}
+do_catchsql_test 3.3.2 {
+ INSERT INTO t5 VALUES(NULL, 3);
+} {1 {foreign key constraint failed}}
+
+do_execsql_test 3.4.1 {
+ CREATE TABLE t6(a INTEGER PRIMARY KEY, b, c, d,
+ FOREIGN KEY(c, d) REFERENCES t6(a, b)
+ );
+ CREATE UNIQUE INDEX t6i ON t6(b, a);
+}
+do_execsql_test 3.4.2 { INSERT INTO t6 VALUES(NULL, 'a', 1, 'a'); } {}
+do_execsql_test 3.4.3 { INSERT INTO t6 VALUES(2, 'a', 2, 'a'); } {}
+do_execsql_test 3.4.4 { INSERT INTO t6 VALUES(NULL, 'a', 1, 'a'); } {}
+do_execsql_test 3.4.5 { INSERT INTO t6 VALUES(5, 'a', 2, 'a'); } {}
+do_catchsql_test 3.4.6 {
+ INSERT INTO t6 VALUES(NULL, 'a', 65, 'a');
+} {1 {foreign key constraint failed}}
+
+do_execsql_test 3.4.7 {
+ INSERT INTO t6 VALUES(100, 'one', 100, 'one');
+ DELETE FROM t6 WHERE a = 100;
+}
+do_execsql_test 3.4.8 {
+ INSERT INTO t6 VALUES(100, 'one', 100, 'one');
+ UPDATE t6 SET c = 1, d = 'a' WHERE a = 100;
+ DELETE FROM t6 WHERE a = 100;
+}
+
+do_execsql_test 3.5.1 {
+ CREATE TABLE t7(a, b, c, d INTEGER PRIMARY KEY,
+ FOREIGN KEY(c, d) REFERENCES t7(a, b)
+ );
+ CREATE UNIQUE INDEX t7i ON t7(a, b);
+}
+do_execsql_test 3.5.2 { INSERT INTO t7 VALUES('x', 1, 'x', NULL) } {}
+do_execsql_test 3.5.3 { INSERT INTO t7 VALUES('x', 2, 'x', 2) } {}
+do_catchsql_test 3.5.4 {
+ INSERT INTO t7 VALUES('x', 450, 'x', NULL);
+} {1 {foreign key constraint failed}}
+do_catchsql_test 3.5.5 {
+ INSERT INTO t7 VALUES('x', 450, 'x', 451);
+} {1 {foreign key constraint failed}}
+
+
+do_execsql_test 3.6.1 {
+ CREATE TABLE t8(a, b, c, d, e, FOREIGN KEY(c, d) REFERENCES t8(a, b));
+ CREATE UNIQUE INDEX t8i1 ON t8(a, b);
+ CREATE UNIQUE INDEX t8i2 ON t8(c);
+ INSERT INTO t8 VALUES(1, 1, 1, 1, 1);
+}
+do_catchsql_test 3.6.2 {
+ UPDATE t8 SET d = 2;
+} {1 {foreign key constraint failed}}
+do_execsql_test 3.6.3 { UPDATE t8 SET d = 1; }
+do_execsql_test 3.6.4 { UPDATE t8 SET e = 2; }
+
+do_catchsql_test 3.6.5 {
+ CREATE TABLE TestTable (
+ id INTEGER PRIMARY KEY,
+ name text,
+ source_id integer not null,
+ parent_id integer,
+
+ foreign key(source_id, parent_id) references TestTable(source_id, id)
+ );
+ CREATE UNIQUE INDEX testindex on TestTable(source_id, id);
+ PRAGMA foreign_keys=1;
+ INSERT INTO TestTable VALUES (1, 'parent', 1, null);
+ INSERT INTO TestTable VALUES (2, 'child', 1, 1);
+ UPDATE TestTable SET parent_id=1000 where id=2;
+} {1 {foreign key constraint failed}}
+
+finish_test
diff --git a/test/fkey4.test b/test/fkey4.test
new file mode 100644
index 0000000..d6dd2fc
--- /dev/null
+++ b/test/fkey4.test
@@ -0,0 +1,55 @@
+# 2011 Feb 04
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file test deferred foreign key constraint processing to make
+# sure that when a statement not within BEGIN...END fails a constraint,
+# that statement doesn't hold the transaction open thus allowing
+# a subsequent statement to fail a deferred constraint with impunity.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!foreignkey||!trigger} {
+ finish_test
+ return
+}
+
+# Create a table and some data to work with.
+#
+do_test fkey4-1.1 {
+ execsql {
+ PRAGMA foreign_keys = ON;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TABLE t2(c REFERENCES t1 DEFERRABLE INITIALLY DEFERRED, d);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(1,3);
+ }
+} {}
+
+do_test fkey4-1.2 {
+ set ::DB [sqlite3_connection_pointer db]
+ set ::SQL {INSERT INTO t2 VALUES(2,4)}
+ set ::STMT1 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL]
+ sqlite3_step $::STMT1
+} {SQLITE_CONSTRAINT}
+do_test fkey4-1.3 {
+ set ::STMT2 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL]
+ sqlite3_step $::STMT2
+} {SQLITE_CONSTRAINT}
+do_test fkey4-1.4 {
+ db eval {SELECT * FROM t2}
+} {1 3}
+sqlite3_finalize $::STMT1
+sqlite3_finalize $::STMT2
+
+finish_test
diff --git a/test/fkey_malloc.test b/test/fkey_malloc.test
new file mode 100644
index 0000000..4a36f5f
--- /dev/null
+++ b/test/fkey_malloc.test
@@ -0,0 +1,132 @@
+# 2009 September 22
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !foreignkey||!trigger {
+ finish_test
+ return
+}
+source $testdir/malloc_common.tcl
+
+do_malloc_test fkey_malloc-1 -sqlprep {
+ PRAGMA foreign_keys = 1;
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ CREATE TABLE t2(x REFERENCES t1 ON UPDATE CASCADE ON DELETE CASCADE);
+} -sqlbody {
+ INSERT INTO t1 VALUES('aaa', 1);
+ INSERT INTO t2 VALUES('aaa');
+ UPDATE t1 SET a = 'bbb';
+ DELETE FROM t1;
+}
+
+do_malloc_test fkey_malloc-2 -sqlprep {
+ PRAGMA foreign_keys = 1;
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+} -sqlbody {
+ CREATE TABLE t2(x, y,
+ FOREIGN KEY(x, y) REFERENCES t1(a, b) DEFERRABLE INITIALLY DEFERRED
+ );
+ BEGIN;
+ INSERT INTO t2 VALUES('a', 'b');
+ INSERT INTO t1 VALUES('a', 'b');
+ UPDATE t1 SET a = 'c';
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES('d', 'b');
+ UPDATE t2 SET x = 'c';
+ COMMIT;
+}
+
+do_malloc_test fkey_malloc-3 -sqlprep {
+ PRAGMA foreign_keys = 1;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ CREATE TABLE t2(y DEFAULT 14 REFERENCES t1(x) ON UPDATE SET DEFAULT);
+ CREATE TABLE t3(y REFERENCES t1 ON UPDATE SET NULL);
+ INSERT INTO t1 VALUES(13);
+ INSERT INTO t2 VALUES(13);
+ INSERT INTO t3 VALUES(13);
+} -sqlbody {
+ UPDATE t1 SET x = 14;
+}
+
+proc catch_fk_error {zSql} {
+ set rc [catch {db eval $zSql} msg]
+ if {$rc==0} {
+ return $msg
+ }
+ if {[string match {*foreign key*} $msg]} {
+ return ""
+ }
+ if {$msg eq "out of memory" || $msg eq "constraint failed"} {
+ error 1
+ }
+ error $msg
+}
+
+do_malloc_test fkey_malloc-4 -sqlprep {
+ PRAGMA foreign_keys = 1;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE);
+ CREATE TABLE t2(z REFERENCES t1(x), a REFERENCES t1(y));
+ CREATE TABLE t3(x);
+ CREATE TABLE t4(z REFERENCES t3);
+ CREATE TABLE t5(x, y);
+ CREATE TABLE t6(z REFERENCES t5(x));
+ CREATE INDEX i51 ON t5(x);
+ CREATE INDEX i52 ON t5(y, x);
+ INSERT INTO t1 VALUES(1, 2);
+} -tclbody {
+ catch_fk_error {INSERT INTO t2 VALUES(1, 3)}
+ catch_fk_error {INSERT INTO t4 VALUES(2)}
+ catch_fk_error {INSERT INTO t6 VALUES(2)}
+}
+
+do_malloc_test fkey_malloc-5 -sqlprep {
+ PRAGMA foreign_keys = 1;
+ CREATE TABLE t1(x, y, PRIMARY KEY(x, y));
+ CREATE TABLE t2(a, b, FOREIGN KEY(a, b) REFERENCES t1 ON UPDATE CASCADE);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(1, 2);
+} -sqlbody {
+ UPDATE t1 SET x = 5;
+}
+
+do_malloc_test fkey_malloc-6 -sqlprep {
+ PRAGMA foreign_keys = 1;
+ CREATE TABLE t1(
+ x PRIMARY KEY,
+ y REFERENCES t1 ON DELETE RESTRICT ON UPDATE SET DEFAULT
+ );
+ INSERT INTO t1 VALUES('abc', 'abc');
+ INSERT INTO t1 VALUES('def', 'def');
+} -sqlbody {
+ INSERT INTO t1 VALUES('ghi', 'ghi');
+ DELETE FROM t1 WHERE rowid>1;
+ UPDATE t1 SET x='jkl', y='jkl';
+}
+
+do_malloc_test fkey_malloc-7 -sqlprep {
+ PRAGMA foreign_keys = 1;
+ CREATE TABLE x(a, b, PRIMARY KEY(a, b));
+ CREATE TABLE y(c, d,
+ FOREIGN KEY(d, c) REFERENCES x DEFERRABLE INITIALLY DEFERRED
+ );
+ CREATE TABLE z(e, f, FOREIGN KEY(e, f) REFERENCES x);
+} -sqlbody {
+ DROP TABLE y;
+ DROP TABLE x;
+}
+
+finish_test
+
+
diff --git a/test/format4.test b/test/format4.test
new file mode 100644
index 0000000..14d7947
--- /dev/null
+++ b/test/format4.test
@@ -0,0 +1,65 @@
+# 2005 December 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that the new serial_type
+# values of 8 (integer 0) and 9 (integer 1) work correctly.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+db eval {PRAGMA legacy_file_format=OFF}
+
+# The size of the database depends on whether or not autovacuum
+# is enabled.
+#
+ifcapable autovacuum {
+ if {[db one {PRAGMA auto_vacuum}]} {
+ set small 3072
+ set large 5120
+ } else {
+ set small 2048
+ set large 4096
+ }
+} else {
+ set small 2048
+ set large 4096
+}
+
+do_test format4-1.1 {
+ execsql {
+ CREATE TABLE t1(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9);
+ INSERT INTO t1 VALUES(0,0,0,0,0,0,0,0,0,0);
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ }
+ file size test.db
+} $small
+do_test format4-1.2 {
+ execsql {
+ UPDATE t1 SET x0=1, x1=1, x2=1, x3=1, x4=1, x5=1, x6=1, x7=1, x8=1, x9=1
+ }
+ file size test.db
+} $small
+do_test format4-1.3 {
+ execsql {
+ UPDATE t1 SET x0=2, x1=2, x2=2, x3=2, x4=2, x5=2, x6=2, x7=2, x8=2, x9=2
+ }
+ file size test.db
+} $large
+
+
+finish_test
diff --git a/test/fts-9fd058691.test b/test/fts-9fd058691.test
new file mode 100644
index 0000000..b228482
--- /dev/null
+++ b/test/fts-9fd058691.test
@@ -0,0 +1,59 @@
+# 2011 October 13
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for the FTS SQLite module.
+#
+# This file implements tests to verify that ticket [9fd058691] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+set ::testprefix fts3-9fd058691
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE fts USING fts3( tags TEXT);
+ INSERT INTO fts (tags) VALUES ('tag1');
+ SELECT * FROM fts WHERE tags MATCH 'tag1';
+} {tag1}
+
+do_test 1.1 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ UPDATE fts SET tags = 'tag1' WHERE rowid = 1;
+ SELECT * FROM fts WHERE tags MATCH 'tag1';
+ }
+} {tag1}
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE fts USING fts3(tags TEXT);
+ INSERT INTO fts (docid, tags) VALUES (1, 'tag1');
+ INSERT INTO fts (docid, tags) VALUES (2, NULL);
+ INSERT INTO fts (docid, tags) VALUES (3, 'three');
+} {}
+
+do_test 2.1 {
+ execsql {
+ UPDATE fts SET tags = 'two' WHERE rowid = 2;
+ SELECT * FROM fts WHERE tags MATCH 'two';
+ }
+} {two}
+
+finish_test
diff --git a/test/fts1a.test b/test/fts1a.test
new file mode 100644
index 0000000..b63e79a
--- /dev/null
+++ b/test/fts1a.test
@@ -0,0 +1,186 @@
+# 2006 September 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS1 module.
+#
+# $Id: fts1a.test,v 1.4 2006/09/28 19:43:32 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+# Construct a full-text search table containing five keywords:
+# one, two, three, four, and five, in various combinations. The
+# rowid for each will be a bitmask for the elements it contains.
+#
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts1(content);
+ INSERT INTO t1(content) VALUES('one');
+ INSERT INTO t1(content) VALUES('two');
+ INSERT INTO t1(content) VALUES('one two');
+ INSERT INTO t1(content) VALUES('three');
+ INSERT INTO t1(content) VALUES('one three');
+ INSERT INTO t1(content) VALUES('two three');
+ INSERT INTO t1(content) VALUES('one two three');
+ INSERT INTO t1(content) VALUES('four');
+ INSERT INTO t1(content) VALUES('one four');
+ INSERT INTO t1(content) VALUES('two four');
+ INSERT INTO t1(content) VALUES('one two four');
+ INSERT INTO t1(content) VALUES('three four');
+ INSERT INTO t1(content) VALUES('one three four');
+ INSERT INTO t1(content) VALUES('two three four');
+ INSERT INTO t1(content) VALUES('one two three four');
+ INSERT INTO t1(content) VALUES('five');
+ INSERT INTO t1(content) VALUES('one five');
+ INSERT INTO t1(content) VALUES('two five');
+ INSERT INTO t1(content) VALUES('one two five');
+ INSERT INTO t1(content) VALUES('three five');
+ INSERT INTO t1(content) VALUES('one three five');
+ INSERT INTO t1(content) VALUES('two three five');
+ INSERT INTO t1(content) VALUES('one two three five');
+ INSERT INTO t1(content) VALUES('four five');
+ INSERT INTO t1(content) VALUES('one four five');
+ INSERT INTO t1(content) VALUES('two four five');
+ INSERT INTO t1(content) VALUES('one two four five');
+ INSERT INTO t1(content) VALUES('three four five');
+ INSERT INTO t1(content) VALUES('one three four five');
+ INSERT INTO t1(content) VALUES('two three four five');
+ INSERT INTO t1(content) VALUES('one two three four five');
+}
+
+do_test fts1a-1.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts1a-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}
+} {3 7 11 15 19 23 27 31}
+do_test fts1a-1.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}
+} {3 7 11 15 19 23 27 31}
+do_test fts1a-1.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}
+} {7 15 23 31}
+do_test fts1a-1.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}
+} {7 15 23 31}
+do_test fts1a-1.6 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}
+} {7 15 23 31}
+do_test fts1a-1.7 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}
+} {7 15 23 31}
+do_test fts1a-1.8 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}
+} {7 15 23 31}
+do_test fts1a-1.9 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}
+} {7 15 23 31}
+do_test fts1a-1.10 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}
+} {7 15 23 31}
+do_test fts1a-1.11 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH ' ONE Two three '}
+} {7 15 23 31}
+
+do_test fts1a-2.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one"'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts1a-2.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two"'}
+} {3 7 11 15 19 23 27 31}
+do_test fts1a-2.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"two one"'}
+} {}
+do_test fts1a-2.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three"'}
+} {7 15 23 31}
+do_test fts1a-2.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two"'}
+} {}
+do_test fts1a-2.6 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three four"'}
+} {15 31}
+do_test fts1a-2.7 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two four"'}
+} {}
+do_test fts1a-2.8 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three five"'}
+} {21}
+do_test fts1a-2.9 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" five'}
+} {21 29}
+do_test fts1a-2.10 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three"'}
+} {21 29}
+do_test fts1a-2.11 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three" four'}
+} {29}
+do_test fts1a-2.12 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four "one three"'}
+} {29}
+do_test fts1a-2.13 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" four five'}
+} {29}
+
+do_test fts1a-3.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts1a-3.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}
+} {1 5 9 13 17 21 25 29}
+do_test fts1a-3.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}
+} {1 5 9 13 17 21 25 29}
+
+do_test fts1a-4.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one OR two'}
+} {1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 25 26 27 29 30 31}
+do_test fts1a-4.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two" OR three'}
+} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
+do_test fts1a-4.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR "one two"'}
+} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
+do_test fts1a-4.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three'}
+} {3 5 7 11 13 15 19 21 23 27 29 31}
+do_test fts1a-4.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR two one'}
+} {3 5 7 11 13 15 19 21 23 27 29 31}
+do_test fts1a-4.6 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three OR four'}
+} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
+do_test fts1a-4.7 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two OR three OR four one'}
+} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
+
+# Test the ability to handle NULL content
+#
+do_test fts1a-5.1 {
+ execsql {INSERT INTO t1(content) VALUES(NULL)}
+} {}
+do_test fts1a-5.2 {
+ set rowid [db last_insert_rowid]
+ execsql {SELECT content FROM t1 WHERE rowid=$rowid}
+} {{}}
+do_test fts1a-5.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}
+} {}
+
+
+
+finish_test
diff --git a/test/fts1b.test b/test/fts1b.test
new file mode 100644
index 0000000..2bbe1aa
--- /dev/null
+++ b/test/fts1b.test
@@ -0,0 +1,147 @@
+# 2006 September 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS1 module.
+#
+# $Id: fts1b.test,v 1.4 2006/09/18 02:12:48 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+# Fill the full-text index "t1" with phrases in english, spanish,
+# and german. For the i-th row, fill in the names for the bits
+# that are set in the value of i. The least significant bit is
+# 1. For example, the value 5 is 101 in binary which will be
+# converted to "one three" in english.
+#
+proc fill_multilanguage_fulltext_t1 {} {
+ set english {one two three four five}
+ set spanish {un dos tres cuatro cinco}
+ set german {eine zwei drei vier funf}
+
+ for {set i 1} {$i<=31} {incr i} {
+ set cmd "INSERT INTO t1 VALUES"
+ set vset {}
+ foreach lang {english spanish german} {
+ set words {}
+ for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
+ if {$k&$i} {lappend words [lindex [set $lang] $j]}
+ }
+ lappend vset "'$words'"
+ }
+ set sql "INSERT INTO t1(english,spanish,german) VALUES([join $vset ,])"
+ # puts $sql
+ db eval $sql
+ }
+}
+
+# Construct a full-text search table containing five keywords:
+# one, two, three, four, and five, in various combinations. The
+# rowid for each will be a bitmask for the elements it contains.
+#
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts1(english,spanish,german);
+}
+fill_multilanguage_fulltext_t1
+
+do_test fts1b-1.1 {
+ execsql {SELECT rowid FROM t1 WHERE english MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts1b-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE spanish MATCH 'one'}
+} {}
+do_test fts1b-1.3 {
+ execsql {SELECT rowid FROM t1 WHERE german MATCH 'one'}
+} {}
+do_test fts1b-1.4 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts1b-1.5 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one dos drei'}
+} {7 15 23 31}
+do_test fts1b-1.6 {
+ execsql {SELECT english, spanish, german FROM t1 WHERE rowid=1}
+} {one un eine}
+do_test fts1b-1.7 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"one un"'}
+} {}
+
+do_test fts1b-2.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t2 USING fts1(from,to);
+ INSERT INTO t2([from],[to]) VALUES ('one two three', 'four five six');
+ SELECT [from], [to] FROM t2
+ }
+} {{one two three} {four five six}}
+
+
+# Compute an SQL string that contains the words one, two, three,... to
+# describe bits set in the value $i. Only the lower 5 bits are examined.
+#
+proc wordset {i} {
+ set x {}
+ for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
+ if {$k&$i} {lappend x [lindex {one two three four five} $j]}
+ }
+ return '$x'
+}
+
+# Create a new FTS table with three columns:
+#
+# norm: words for the bits of rowid
+# plusone: words for the bits of rowid+1
+# invert: words for the bits of ~rowid
+#
+db eval {
+ CREATE VIRTUAL TABLE t4 USING fts1([norm],'plusone',"invert");
+}
+for {set i 1} {$i<=15} {incr i} {
+ set vset [list [wordset $i] [wordset [expr {$i+1}]] [wordset [expr {~$i}]]]
+ db eval "INSERT INTO t4(norm,plusone,invert) VALUES([join $vset ,]);"
+}
+
+do_test fts1b-4.1 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one'}
+} {1 3 5 7 9 11 13 15}
+do_test fts1b-4.2 {
+ execsql {SELECT rowid FROM t4 WHERE norm MATCH 'one'}
+} {1 3 5 7 9 11 13 15}
+do_test fts1b-4.3 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'one'}
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}
+do_test fts1b-4.4 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:one'}
+} {2 4 6 8 10 12 14}
+do_test fts1b-4.5 {
+ execsql {SELECT rowid FROM t4 WHERE plusone MATCH 'one'}
+} {2 4 6 8 10 12 14}
+do_test fts1b-4.6 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one plusone:two'}
+} {1 5 9 13}
+do_test fts1b-4.7 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one two'}
+} {1 3 5 7 9 11 13 15}
+do_test fts1b-4.8 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:two norm:one'}
+} {1 5 9 13}
+do_test fts1b-4.9 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'two norm:one'}
+} {1 3 5 7 9 11 13 15}
+
+
+finish_test
diff --git a/test/fts1c.test b/test/fts1c.test
new file mode 100644
index 0000000..a124695
--- /dev/null
+++ b/test/fts1c.test
@@ -0,0 +1,1213 @@
+# 2006 September 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS1 module.
+#
+# $Id: fts1c.test,v 1.11 2006/10/04 17:35:28 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+# Create a table of sample email data. The data comes from email
+# archives of Enron executives that was published as part of the
+# litigation against that company.
+#
+do_test fts1c-1.1 {
+ db eval {
+ CREATE VIRTUAL TABLE email USING fts1([from],[to],subject,body);
+ BEGIN TRANSACTION;
+INSERT INTO email([from],[to],subject,body) VALUES('savita.puthigai@enron.com', 'traders.eol@enron.com, traders.eol@enron.com', 'EnronOnline- Change to Autohedge', 'Effective Monday, October 22, 2001 the following changes will be made to the Autohedge functionality on EnronOnline.
+
+The volume on the hedge will now respect the minimum volume and volume increment settings on the parent product. See rules below:
+
+? If the transaction volume on the child is less than half of the parent''s minimum volume no hedge will occur.
+? If the transaction volume on the child is more than half the parent''s minimum volume but less than half the volume increment on the parent, the hedge will volume will be the parent''s minimum volume.
+? For all other volumes, the same rounding rules will apply based on the volume increment on the parent product.
+
+Please see example below:
+
+Parent''s Settings:
+Minimum: 5000
+Increment: 1000
+
+Volume on Autohedge transaction Volume Hedged
+1 - 2499 0
+2500 - 5499 5000
+5500 - 6499 6000');
+INSERT INTO email([from],[to],subject,body) VALUES('dana.davis@enron.com', 'laynie.east@enron.com, lisa.king@enron.com, lisa.best@enron.com,', 'Leaving Early', 'FYI:
+If it''s ok with everyone''s needs, I would like to leave @4pm. If you think
+you will need my assistance past the 4 o''clock hour just let me know; I''ll
+be more than willing to stay.');
+INSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'louise.kitchen@enron.com', '<<Concur Expense Document>> - CC02.06.02', 'The following expense report is ready for approval:
+
+Employee Name: Christopher F. Calger
+Status last changed by: Mollie E. Gustafson Ms
+Expense Report Name: CC02.06.02
+Report Total: $3,972.93
+Amount Due Employee: $3,972.93
+
+
+To approve this expense report, click on the following link for Concur Expense.
+http://expensexms.enron.com');
+INSERT INTO email([from],[to],subject,body) VALUES('jeff.duff@enron.com', 'julie.johnson@enron.com', 'Work request', 'Julie,
+
+Could you print off the current work request report by 1:30 today?
+
+Gentlemen,
+
+I''d like to review this today at 1:30 in our office. Also, could you provide
+me with your activity reports so I can have Julie enter this information.
+
+JD');
+INSERT INTO email([from],[to],subject,body) VALUES('v.weldon@enron.com', 'gary.l.carrier@usa.dupont.com, scott.joyce@bankofamerica.com', 'Enron News', 'This could turn into something big....
+http://biz.yahoo.com/rf/010129/n29305829.html');
+INSERT INTO email([from],[to],subject,body) VALUES('mark.haedicke@enron.com', 'paul.simons@enron.com', 'Re: First Polish Deal!', 'Congrats! Things seem to be building rapidly now on the Continent. Mark');
+INSERT INTO email([from],[to],subject,body) VALUES('e..carter@enron.com', 't..robinson@enron.com', 'FW: Producers Newsletter 9-24-2001', '
+The producer lumber pricing sheet.
+ -----Original Message-----
+From: Johnson, Jay
+Sent: Tuesday, October 16, 2001 3:42 PM
+To: Carter, Karen E.
+Subject: FW: Producers Newsletter 9-24-2001
+
+
+
+ -----Original Message-----
+From: Daigre, Sergai
+Sent: Friday, September 21, 2001 8:33 PM
+Subject: Producers Newsletter 9-24-2001
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('david.delainey@enron.com', 'kenneth.lay@enron.com', 'Greater Houston Partnership', 'Ken, in response to the letter from Mr Miguel San Juan, my suggestion would
+be to offer up the Falcon for their use; however, given the tight time frame
+and your recent visit with Mr. Fox that it would be difficult for either you
+or me to participate.
+
+I spoke to Max and he agrees with this approach.
+
+I hope this meets with your approval.
+
+Regards
+Delainey');
+INSERT INTO email([from],[to],subject,body) VALUES('lachandra.fenceroy@enron.com', 'lindy.donoho@enron.com', 'FW: Bus Applications Meeting Follow Up', 'Lindy,
+
+Here is the original memo we discussed earlier. Please provide any information that you may have.
+
+Your cooperation is greatly appreciated.
+
+Thanks,
+
+lachandra.fenceroy@enron.com
+713.853.3884
+877.498.3401 Pager
+
+ -----Original Message-----
+From: Bisbee, Joanne
+Sent: Wednesday, September 26, 2001 7:50 AM
+To: Fenceroy, LaChandra
+Subject: FW: Bus Applications Meeting Follow Up
+
+Lachandra, Please get with David Duff today and see what this is about. Who are our TW accounting business users?
+
+ -----Original Message-----
+From: Koh, Wendy
+Sent: Tuesday, September 25, 2001 2:41 PM
+To: Bisbee, Joanne
+Subject: Bus Applications Meeting Follow Up
+
+Lisa brought up a TW change effective Nov 1. It involves eliminating a turnback surcharge. I have no other information, but you might check with the business folks for any system changes required.
+
+Wendy');
+INSERT INTO email([from],[to],subject,body) VALUES('danny.mccarty@enron.com', 'fran.fagan@enron.com', 'RE: worksheets', 'Fran,
+ If Julie''s merit needs to be lump sum, just move it over to that column. Also, send me Eric Gadd''s sheets as well. Thanks.
+Dan
+
+ -----Original Message-----
+From: Fagan, Fran
+Sent: Thursday, December 20, 2001 11:10 AM
+To: McCarty, Danny
+Subject: worksheets
+
+As discussed, attached are your sheets for bonus and merit.
+
+Thanks,
+
+Fran Fagan
+Sr. HR Rep
+713.853.5219
+
+
+ << File: McCartyMerit.xls >> << File: mccartyBonusCommercial_UnP.xls >>
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('bert.meyers@enron.com', 'shift.dl-portland@enron.com', 'OCTOBER SCHEDULE', 'TEAM,
+
+PLEASE SEND ME ANY REQUESTS THAT YOU HAVE FOR OCTOBER. SO FAR I HAVE THEM FOR LEAF. I WOULD LIKE TO HAVE IT DONE BY THE 15TH OF THE MONTH. ANY QUESTIONS PLEASE GIVE ME A CALL.
+
+BERT');
+INSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'john.arnold@enron.com, bilal.bajwa@enron.com, john.griffith@enron.com,', 'TRV Notification: (NG - PROPT P/L - 09/27/2001)', 'The report named: NG - PROPT P/L <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=11&report_name=NG+-+PROPT+P/L&category_cd=5&category_name=FINANCIAL&toc_hide=1&sTV1=5&TV1Exp=Y&current_efct_date=09/27/2001>, published as of 09/27/2001 is now available for viewing on the website.');
+INSERT INTO email([from],[to],subject,body) VALUES('patrice.mims@enron.com', 'calvin.eakins@enron.com', 'Re: Small business supply assistance', 'Hi Calvin
+
+
+I spoke with Rickey (boy, is he long-winded!!). Gave him the name of our
+credit guy, Russell Diamond.
+
+Thank for your help!');
+INSERT INTO email([from],[to],subject,body) VALUES('legal <.hall@enron.com>', 'stephanie.panus@enron.com', 'Termination update', 'City of Vernon and Salt River Project terminated their contracts. I will fax these notices to you.');
+INSERT INTO email([from],[to],subject,body) VALUES('d..steffes@enron.com', 'richard.shapiro@enron.com', 'EES / ENA Government Affairs Staffing & Outside Services', 'Rick --
+
+Here is the information on staffing and outside services. Call if you need anything else.
+
+Jim
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('gelliott@industrialinfo.com', 'pcopello@industrialinfo.com', 'ECAAR (Gavin), WSCC (Diablo Canyon), & NPCC (Seabrook)', 'Dear Power Outage Database Customer,
+Attached you will find an excel document. The outages contained within are forced or rescheduled outages. Your daily delivery will still contain these outages.
+In addition to the two excel documents, there is a dbf file that is formatted like your daily deliveries you receive nightly. This will enable you to load the data into your regular database. Any questions please let me know. Thanks.
+Greg Elliott
+IIR, Inc.
+713-783-5147 x 3481
+outages@industrialinfo.com
+THE INFORMATION CONTAINED IN THIS E-MAIL IS LEGALLY PRIVILEGED AND CONFIDENTIAL INFORMATION INTENDED ONLY FOR THE USE OF THE INDIVIDUAL OR ENTITY NAMED ABOVE. YOU ARE HEREBY NOTIFIED THAT ANY DISSEMINATION, DISTRIBUTION, OR COPY OF THIS E-MAIL TO UNAUTHORIZED ENTITIES IS STRICTLY PROHIBITED. IF YOU HAVE RECEIVED THIS
+E-MAIL IN ERROR, PLEASE DELETE IT.
+ - OUTAGE.dbf
+ - 111201R.xls
+ - 111201.xls ');
+INSERT INTO email([from],[to],subject,body) VALUES('enron.announcements@enron.com', 'all_ena_egm_eim@enron.com', 'EWS Brown Bag', 'MARK YOUR LUNCH CALENDARS NOW !
+
+You are invited to attend the EWS Brown Bag Lunch Series
+
+Featuring: RAY BOWEN, COO
+
+Topic: Enron Industrial Markets
+
+Thursday, March 15, 2001
+11:30 am - 12:30 pm
+EB 5 C2
+
+
+You bring your lunch, Limited Seating
+We provide drinks and dessert. RSVP x 3-9610');
+INSERT INTO email([from],[to],subject,body) VALUES('chris.germany@enron.com', 'ingrid.immer@williams.com', 'Re: About St Pauls', 'Sounds good to me. I bet this is next to the Warick?? Hotel.
+
+
+
+
+"Immer, Ingrid" <Ingrid.Immer@Williams.com> on 12/21/2000 11:48:47 AM
+To: "''chris.germany@enron.com''" <chris.germany@enron.com>
+cc:
+Subject: About St Pauls
+
+
+
+
+ <<About St Pauls.url>>
+?
+?http://www.stpaulshouston.org/about.html
+
+Chris,
+
+I like the looks of this place.? What do you think about going here Christmas
+eve?? They have an 11:00 a.m. service and a candlelight service at 5:00 p.m.,
+among others.
+
+Let me know.?? ii
+
+ - About St Pauls.url
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('nas@cpuc.ca.gov', 'skatz@sempratrading.com, kmccrea@sablaw.com, thompson@wrightlaw.com,', 'Reply Brief filed July 31, 2000', ' - CPUC01-#76371-v1-Revised_Reply_Brief__Due_today_7_31_.doc');
+INSERT INTO email([from],[to],subject,body) VALUES('gascontrol@aglresources.com', 'dscott4@enron.com, lcampbel@enron.com', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder
+As discussed in the Winter Operations Meeting on Sept.29,2000,
+E-Gas(Emergency Gas) will not be offered this winter as a service from AGLC.
+Marketers and Poolers can receive gas via Peaking and IBSS nominations(daisy
+chain) from other marketers up to the 6 p.m. Same Day 2 nomination cycle.
+');
+INSERT INTO email([from],[to],subject,body) VALUES('dutch.quigley@enron.com', 'rwolkwitz@powermerchants.com', '', '
+
+Here is a goody for you');
+INSERT INTO email([from],[to],subject,body) VALUES('ryan.o''rourke@enron.com', 'k..allen@enron.com, randy.bhatia@enron.com, frank.ermis@enron.com,', 'TRV Notification: (West VaR - 11/07/2001)', 'The report named: West VaR <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=36&report_name=West+VaR&category_cd=2&category_name=WEST&toc_hide=1&sTV1=2&TV1Exp=Y&current_efct_date=11/07/2001>, published as of 11/07/2001 is now available for viewing on the website.');
+INSERT INTO email([from],[to],subject,body) VALUES('mjones7@txu.com', 'cstone1@txu.com, ggreen2@txu.com, timpowell@txu.com,', 'Enron / HPL Actuals for July 10, 2000', 'Teco Tap 10.000 / Enron ; 110.000 / HPL IFERC
+
+LS HPL LSK IC 30.000 / Enron
+');
+INSERT INTO email([from],[to],subject,body) VALUES('susan.pereira@enron.com', 'kkw816@aol.com', 'soccer practice', 'Kathy-
+
+Is it safe to assume that practice is cancelled for tonight??
+
+Susan Pereira');
+INSERT INTO email([from],[to],subject,body) VALUES('mark.whitt@enron.com', 'barry.tycholiz@enron.com', 'Huber Internal Memo', 'Please look at this. I didn''t know how deep to go with the desk. Do you think this works.
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('m..forney@enron.com', 'george.phillips@enron.com', '', 'George,
+Give me a call and we will further discuss opportunities on the 13st floor.
+
+Thanks,
+JMForney
+3-7160');
+INSERT INTO email([from],[to],subject,body) VALUES('brad.mckay@enron.com', 'angusmcka@aol.com', 'Re: (no subject)', 'not yet');
+INSERT INTO email([from],[to],subject,body) VALUES('adam.bayer@enron.com', 'jonathan.mckay@enron.com', 'FW: Curve Fetch File', 'Here is the curve fetch file sent to me. It has plenty of points in it. If you give me a list of which ones you need we may be able to construct a secondary worksheet to vlookup the values.
+
+adam
+35227
+
+
+ -----Original Message-----
+From: Royed, Jeff
+Sent: Tuesday, September 25, 2001 11:37 AM
+To: Bayer, Adam
+Subject: Curve Fetch File
+
+Let me know if it works. It may be required to have a certain version of Oracle for it to work properly.
+
+
+
+Jeff Royed
+Enron
+Energy Operations
+Phone: 713-853-5295');
+INSERT INTO email([from],[to],subject,body) VALUES('matt.smith@enron.com', 'yan.wang@enron.com', 'Report Formats', 'Yan,
+
+The merged reports look great. I believe the only orientation changes are to
+"unmerge" the following six reports:
+
+31 Keystone Receipts
+15 Questar Pipeline
+40 Rockies Production
+22 West_2
+23 West_3
+25 CIG_WIC
+
+The orientation of the individual reports should be correct. Thanks.
+
+Mat
+
+PS. Just a reminder to add the "*" by the title of calculated points.');
+INSERT INTO email([from],[to],subject,body) VALUES('michelle.lokay@enron.com', 'jimboman@bigfoot.com', 'Egyptian Festival', '---------------------- Forwarded by Michelle Lokay/ET&S/Enron on 09/07/2000
+10:08 AM ---------------------------
+
+
+"Karkour, Randa" <Randa.Karkour@COMPAQ.com> on 09/07/2000 09:01:04 AM
+To: "''Agheb (E-mail)" <Agheb@aol.com>, "Leila Mankarious (E-mail)"
+<Leila_Mankarious@mhhs.org>, "''Marymankarious (E-mail)"
+<marymankarious@aol.com>, "Michelle lokay (E-mail)" <mlokay@enron.com>, "Ramy
+Mankarious (E-mail)" <Mankarious@aol.com>
+cc:
+
+Subject: Egyptian Festival
+
+
+ <<Egyptian Festival.url>>
+
+ http://www.egyptianfestival.com/
+
+ - Egyptian Festival.url
+');
+INSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'sherry.dawson@enron.com', 'Urgent!!! --- New EAST books', 'This has to be done..................................
+
+Thanks
+---------------------- Forwarded by Errol McLaughlin/Corp/Enron on 12/20/2000
+08:39 AM ---------------------------
+
+
+
+ From: William Kelly @ ECT 12/20/2000 08:31 AM
+
+
+To: Kam Keiser/HOU/ECT@ECT, Darron C Giron/HOU/ECT@ECT, David
+Baumbach/HOU/ECT@ECT, Errol McLaughlin/Corp/Enron@ENRON
+cc: Kimat Singla/HOU/ECT@ECT, Kulvinder Fowler/NA/Enron@ENRON, Kyle R
+Lilly/HOU/ECT@ECT, Jeff Royed/Corp/Enron@ENRON, Alejandra
+Chavez/NA/Enron@ENRON, Crystal Hyde/HOU/ECT@ECT
+
+Subject: New EAST books
+
+We have new book names in TAGG for our intramonth portfolios and it is
+extremely important that any deal booked to the East is communicated quickly
+to someone on my team. I know it will take some time for the new names to
+sink in and I do not want us to miss any positions or P&L.
+
+Thanks for your help on this.
+
+New:
+Scott Neal : East Northeast
+Dick Jenkins: East Marketeast
+
+WK
+');
+INSERT INTO email([from],[to],subject,body) VALUES('david.forster@enron.com', 'eol.wide@enron.com', 'Change to Stack Manager', 'Effective immediately, there is a change to the Stack Manager which will
+affect any Inactive Child.
+
+An inactive Child with links to Parent products will not have their
+calculated prices updated until the Child product is Activated.
+
+When the Child Product is activated, the price will be recalculated and
+updated BEFORE it is displayed on the web.
+
+This means that if you are inputting a basis price on a Child product, you
+will not see the final, calculated price until you Activate the product, at
+which time the customer will also see it.
+
+If you have any questions, please contact the Help Desk on:
+
+Americas: 713 853 4357
+Europe: + 44 (0) 20 7783 7783
+Asia/Australia: +61 2 9229 2300
+
+Dave');
+INSERT INTO email([from],[to],subject,body) VALUES('vince.kaminski@enron.com', 'jhh1@email.msn.com', 'Re: Light reading - see pieces beginning on page 7', 'John,
+
+I saw it. Very interesting.
+
+Vince
+
+
+
+
+
+"John H Herbert" <jhh1@email.msn.com> on 07/28/2000 08:38:08 AM
+To: "Vince J Kaminski" <Vince_J_Kaminski@enron.com>
+cc:
+Subject: Light reading - see pieces beginning on page 7
+
+
+Cheers and have a nice weekend,
+
+
+JHHerbert
+
+
+
+
+ - gd000728.pdf
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('matthew.lenhart@enron.com', 'mmmarcantel@equiva.com', 'RE:', 'i will try to line up a pig for you ');
+INSERT INTO email([from],[to],subject,body) VALUES('jae.black@enron.com', 'claudette.harvey@enron.com, chaun.roberts@enron.com, judy.martinez@enron.com,', 'Disaster Recovery Equipment', 'As a reminder...there are several pieces of equipment that are set up on the 30th Floor, as well as on our floor, for the Disaster Recovery Team. PLEASE DO NOT TAKE, BORROW OR USE this equipment. Should you need to use another computer system, other than yours, or make conference calls please work with your Assistant to help find or set up equipment for you to use.
+
+Thanks for your understanding in this matter.
+
+T.Jae Black
+East Power Trading
+Assistant to Kevin Presto
+off. 713-853-5800
+fax 713-646-8272
+cell 713-539-4760');
+INSERT INTO email([from],[to],subject,body) VALUES('eric.bass@enron.com', 'dale.neuner@enron.com', '5 X 24', 'Dale,
+
+Have you heard anything more on the 5 X 24s? We would like to get this
+product out ASAP.
+
+
+Thanks,
+
+Eric');
+INSERT INTO email([from],[to],subject,body) VALUES('messenger@smartreminders.com', 'm..tholt@enron.com', '10% Coupon - PrintPal Printer Cartridges - 100% Guaranteed', '[IMAGE]
+[IMAGE][IMAGE][IMAGE]
+Dear SmartReminders Member,
+ [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+We respect your privacy and are a Certified Participant of the BBBOnLine
+ Privacy Program. To be removed from future offers,click here.
+SmartReminders.com is a permission based service. To unsubscribe click here . ');
+INSERT INTO email([from],[to],subject,body) VALUES('benjamin.rogers@enron.com', 'mark.bernstein@enron.com', '', 'The guy you are talking about left CIN under a "cloud of suspicion" sort of
+speak. He was the one who got into several bad deals and PPA''s in California
+for CIN, thus he left on a bad note. Let me know if you need more detail
+than that, I felt this was the type of info you were looking for. Thanks!
+Ben');
+INSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'michelle.cash@enron.com', 'Expense Report Receipts Not Received', 'Employee Name: Michelle Cash
+Report Name: Houston Cellular 8-11-01
+Report Date: 12/13/01
+Report ID: 594D37C9ED2111D5B452
+Submitted On: 12/13/01
+
+You are only allowed 2 reports with receipts outstanding. Your expense reports will not be paid until you meet this requirement.');
+INSERT INTO email([from],[to],subject,body) VALUES('susan.mara@enron.com', 'ray.alvarez@enron.com, mark.palmer@enron.com, karen.denne@enron.com,', 'CAISO Emergency Motion -- to discontinue market-based rates for', 'FYI. the latest broadside against the generators.
+
+Sue Mara
+Enron Corp.
+Tel: (415) 782-7802
+Fax:(415) 782-7854
+----- Forwarded by Susan J Mara/NA/Enron on 06/08/2001 12:24 PM -----
+
+
+ "Milner, Marcie" <MMilner@coral-energy.com> 06/08/2001 11:13 AM To: "''smara@enron.com''" <smara@enron.com> cc: Subject: CAISO Emergency Motion
+
+
+Sue, did you see this emergency motion the CAISO filed today? Apparently
+they are requesting that FERC discontinue market-based rates immediately and
+grant refunds plus interest on the difference between cost-based rates and
+market revenues received back to May 2000. They are requesting the
+commission act within 14 days. Have you heard anything about what they are
+doing?
+
+Marcie
+
+http://www.caiso.com/docs/2001/06/08/200106081005526469.pdf
+');
+INSERT INTO email([from],[to],subject,body) VALUES('fletcher.sturm@enron.com', 'eloy.escobar@enron.com', 'Re: General Brinks Position Meeting', 'Eloy,
+
+Who is General Brinks?
+
+Fletch');
+INSERT INTO email([from],[to],subject,body) VALUES('nailia.dindarova@enron.com', 'richard.shapiro@enron.com', 'Documents for Mark Frevert (on EU developments and lessons from', 'Rick,
+
+Here are the documents that Peter has prepared for Mark Frevert.
+
+Nailia
+---------------------- Forwarded by Nailia Dindarova/LON/ECT on 25/06/2001
+16:36 ---------------------------
+
+
+Nailia Dindarova
+25/06/2001 15:36
+To: Michael Brown/Enron@EUEnronXGate
+cc: Ross Sankey/Enron@EUEnronXGate, Eric Shaw/ENRON@EUEnronXGate, Peter
+Styles/LON/ECT@ECT
+
+Subject: Documents for Mark Frevert (on EU developments and lessons from
+California)
+
+Michael,
+
+
+These are the documents that Peter promised to give to you for Mark Frevert.
+He has now handed them to him in person but asked me to transmit them
+electronically to you, as well as Eric and Ross.
+
+Nailia
+
+
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('peggy.a.kostial@accenture.com', 'dave.samuels@enron.com', 'EOL-Accenture Deal Sheet', 'Dave -
+
+Attached are our comments and suggested changes. Please call to review.
+
+On the time line for completion, we have four critical steps to complete:
+ Finalize market analysis to refine business case, specifically
+ projected revenue stream
+ Complete counterparty surveying, including targeting 3 CPs for letters
+ of intent
+ Review Enron asset base for potential reuse/ licensing
+ Contract negotiations
+
+Joe will come back to us with an updated time line, but it is my
+expectation that we are still on the same schedule (we just begun week
+three) with possibly a week or so slippage.....contract negotiations will
+probably be the critical path.
+
+We will send our cut at the actual time line here shortly. Thanks,
+
+Peggy
+
+(See attached file: accenture-dealpoints v2.doc)
+ - accenture-dealpoints v2.doc ');
+INSERT INTO email([from],[to],subject,body) VALUES('thomas.martin@enron.com', 'thomas.martin@enron.com', 'Re: Guadalupe Power Partners LP', '---------------------- Forwarded by Thomas A Martin/HOU/ECT on 03/20/2001
+03:49 PM ---------------------------
+
+
+Thomas A Martin
+10/11/2000 03:55 PM
+To: Patrick Wade/HOU/ECT@ECT
+cc:
+Subject: Re: Guadalupe Power Partners LP
+
+The deal is physically served at Oasis Waha or Oasis Katy and is priced at
+either HSC, Waha or Katytailgate GD at buyers option three days prior to
+NYMEX close.
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('judy.townsend@enron.com', 'dan.junek@enron.com, chris.germany@enron.com', 'Columbia Distribution''s Capacity Available for Release - Sum', '---------------------- Forwarded by Judy Townsend/HOU/ECT on 03/09/2001 11:04
+AM ---------------------------
+
+
+agoddard@nisource.com on 03/08/2001 09:16:57 AM
+To: " - *Koch, Kent" <kkoch@nisource.com>, " -
+*Millar, Debra" <dmillar@nisource.com>, " - *Burke, Lynn"
+<lburke@nisource.com>
+cc: " - *Heckathorn, Tom" <theckathorn@nisource.com>
+Subject: Columbia Distribution''s Capacity Available for Release - Sum
+
+
+Attached is Columbia Distribution''s notice of capacity available for release
+for
+the summer of 2001 (Apr. 2001 through Oct. 2001).
+
+Please note that the deadline for bids is 3:00pm EST on March 20, 2001.
+
+If you have any questions, feel free to contact any of the representatives
+listed
+at the bottom of the attachment.
+
+Aaron Goddard
+
+
+
+
+ - 2001Summer.doc
+');
+INSERT INTO email([from],[to],subject,body) VALUES('rhonda.denton@enron.com', 'tim.belden@enron.com, dana.davis@enron.com, genia.fitzgerald@enron.com,', 'Split Rock Energy LLC', 'We have received the executed EEI contract from this CP dated 12/12/2000.
+Copies will be distributed to Legal and Credit.');
+INSERT INTO email([from],[to],subject,body) VALUES('kerrymcelroy@dwt.com', 'jack.speer@alcoa.com, crow@millernash.com, michaelearly@earthlink.net,', 'Oral Argument Request', ' - Oral Argument Request.doc');
+INSERT INTO email([from],[to],subject,body) VALUES('mike.carson@enron.com', 'rlmichaelis@hormel.com', '', 'Did you come in town this wk end..... My new number at our house is :
+713-668-3712...... my cell # is 281-381-7332
+
+the kid');
+INSERT INTO email([from],[to],subject,body) VALUES('cooper.richey@enron.com', 'trycooper@hotmail.com', 'FW: Contact Info', '
+
+-----Original Message-----
+From: Punja, Karim
+Sent: Thursday, December 13, 2001 2:35 PM
+To: Richey, Cooper
+Subject: Contact Info
+
+
+Cooper,
+
+Its been a real pleasure working with you (even though it was for only a small amount of time)
+I hope we can stay in touch.
+
+Home# 234-0249
+email: kpunja@hotmail.com
+
+Take Care,
+
+Karim.
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('bjm30@earthlink.net', 'mcguinn.k@enron.com, mcguinn.ian@enron.com, mcguinn.stephen@enron.com,', 'email address change', 'Hello all.
+
+I haven''t talked to many of you via email recently but I do want to give you
+my new address for your email file:
+
+ bjm30@earthlink.net
+
+I hope all is well.
+
+Brian McGuinn');
+INSERT INTO email([from],[to],subject,body) VALUES('shelley.corman@enron.com', 'steve.hotte@enron.com', 'Flat Panels', 'Can you please advise what is going on with the flat panels that we had planned to distribute to our gas logistics team. It was in the budget and we had the okay, but now I''m hearing there is some hold-up & the units are stored on 44.
+
+Shelley');
+INSERT INTO email([from],[to],subject,body) VALUES('sara.davidson@enron.com', 'john.schwartzenburg@enron.com, scott.dieball@enron.com, recipients@enron.com,', '2001 Enron Law Conference (Distribution List 2)', ' Enron Law Conference
+
+San Antonio, Texas May 2-4, 2001 Westin Riverwalk
+
+ See attached memo for more details!!
+
+
+? Registration for the law conference this year will be handled through an
+Online RSVP Form on the Enron Law Conference Website at
+http://lawconference.corp.enron.com. The website is still under construction
+and will not be available until Thursday, March 15, 2001.
+
+? We will send you another e-mail to confirm when the Law Conference Website
+is operational.
+
+? Please complete the Online RSVP Form as soon as it is available and submit
+it no later than Friday, March 30th.
+
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('tori.kuykendall@enron.com', 'heath.b.taylor@accenture.com', 'Re:', 'hey - thats funny about john - he definitely remembers him - i''ll call pat
+and let him know - we are coming on saturday - i just havent had a chance to
+call you guys back -- looking forward to it -- i probably need the
+directions again though');
+INSERT INTO email([from],[to],subject,body) VALUES('darron.giron@enron.com', 'bryce.baxter@enron.com', 'Re: Feedback for Audrey Cook', 'Bryce,
+
+I''ll get it done today.
+
+DG 3-9573
+
+
+
+
+
+ From: Bryce Baxter 06/12/2000 07:15 PM
+
+
+To: Darron C Giron/HOU/ECT@ECT
+cc:
+Subject: Feedback for Audrey Cook
+
+You were identified as a reviewer for Audrey Cook. If possible, could you
+complete her feedback by end of business Wednesday? It will really help me
+in the PRC process to have your input. Thanks.
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('casey.evans@enron.com', 'stephanie.sever@enron.com', 'Gas EOL ID', 'Stephanie,
+
+In conjunction with the recent movement of several power traders, they are changing the names of their gas books as well. The names of the new gas books and traders are as follows:
+
+PWR-NG-LT-SPP: Mike Carson
+PWR-NG-LT-SERC: Jeff King
+
+If you need to know their power desk to map their ID to their gas books, those desks are as follows:
+
+EPMI-LT-SPP: Mike Carson
+EPMI-LT-SERC: Jeff King
+
+I will be in training this afternoon, but will be back when class is over. Let me know if you have any questions.
+
+Thanks for your help!
+Casey');
+INSERT INTO email([from],[to],subject,body) VALUES('darrell.schoolcraft@enron.com', 'david.roensch@enron.com, kimberly.watson@enron.com, michelle.lokay@enron.com,', 'Postings', 'Please see the attached.
+
+
+ds
+
+
+
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('mcominsky@aol.com', 'cpatman@bracepatt.com, james_derrick@enron.com', 'Jurisprudence Luncheon', 'Carrin & Jim --
+
+It was an honor and a pleasure to meet both of you yesterday. I know we will
+have fun working together on this very special event.
+
+Jeff left the jurisprudence luncheon lists for me before he left on vacation.
+ I wasn''t sure whether he transmitted them to you as well. Would you please
+advise me if you would like them sent to you? I can email the MS Excel files
+or I can fax the hard copies to you. Please advise what is most convenient.
+
+I plan to be in town through the holidays and can be reached by phone, email,
+or cell phone at any time. My cell phone number is 713/705-4829.
+
+Thanks again for your interest in the ADL''s work. Martin.
+
+Martin B. Cominsky
+Director, Southwest Region
+Anti-Defamation League
+713/627-3490, ext. 122
+713/627-2011 (fax)
+MCominsky@aol.com');
+INSERT INTO email([from],[to],subject,body) VALUES('phillip.love@enron.com', 'todagost@utmb.edu, gbsonnta@utmb.edu', 'New President', 'I had a little bird put a word in my ear. Is there any possibility for Ben
+Raimer to be Bush''s secretary of HHS? Just curious about that infamous UTMB
+rumor mill. Hope things are well, happy holidays.
+PL');
+INSERT INTO email([from],[to],subject,body) VALUES('marie.heard@enron.com', 'ehamilton@fna.com', 'ISDA Master Agreement', 'Erin:
+
+Pursuant to your request, attached are the Schedule to the ISDA Master Agreement, together with Paragraph 13 to the ISDA Credit Support Annex. Please let me know if you need anything else. We look forward to hearing your comments.
+
+Marie
+
+Marie Heard
+Senior Legal Specialist
+Enron North America Corp.
+Phone: (713) 853-3907
+Fax: (713) 646-3490
+marie.heard@enron.com
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('andrea.ring@enron.com', 'beverly.beaty@enron.com', 'Re: Tennessee Buy - Louis Dreyfus', 'Beverly - once again thanks so much for your help on this.
+
+
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('karolyn.criado@enron.com', 'j..bonin@enron.com, felicia.case@enron.com, b..clapp@enron.com,', 'Price List week of Oct. 8-9, 2001', '
+Please contact me if you have any questions regarding last weeks prices.
+
+Thank you,
+Karolyn Criado
+3-9441
+
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('kevin.presto@enron.com', 'edward.baughman@enron.com, billy.braddock@enron.com', 'Associated', 'Please begin working on filling our Associated short position in 02. I would like to take this risk off the books.
+
+In addition, please find out what a buy-out of VEPCO would cost us. With Rogers transitioning to run our retail risk management, I would like to clean up our customer positions.
+
+We also need to continue to explore a JEA buy-out.
+
+Thanks.');
+INSERT INTO email([from],[to],subject,body) VALUES('stacy.dickson@enron.com', 'gregg.penman@enron.com', 'RE: Constellation TC 5-7-01', 'Gregg,
+
+I am at home with a sick baby. (Lots of fun!) I will call you about this
+tomorrow.
+
+Stacy');
+INSERT INTO email([from],[to],subject,body) VALUES('joe.quenet@enron.com', 'dfincher@utilicorp.com', '', 'hey big guy.....check this out.....
+
+ w ww.gorelieberman-2000.com/');
+INSERT INTO email([from],[to],subject,body) VALUES('k..allen@enron.com', 'jacqestc@aol.com', '', 'Jacques,
+
+I sent you a fax of Kevin Kolb''s comments on the release. The payoff on the note would be $36,248 ($36090(principal) + $158 (accrued interest)).
+This is assuming we wrap this up on Tuesday.
+
+Please email to confirm that their changes are ok so I can set up a meeting on Tuesday to reach closure.
+
+Phillip');
+INSERT INTO email([from],[to],subject,body) VALUES('kourtney.nelson@enron.com', 'mike.swerzbin@enron.com', 'Adjusted L/R Balance', 'Mike,
+
+I placed the adjusted L/R Balance on the Enronwest site. It is under the "Staff/Kourtney Nelson". There are two links:
+
+1) "Adj L_R" is the same data/format from the weekly strategy meeting.
+2) "New Gen 2001_2002" link has all of the supply side info that is used to calculate the L/R balance
+ -Please note the Data Flag column, a value of "3" indicates the project was cancelled, on hold, etc and is not included in the calc.
+
+Both of these sheets are interactive Excel spreadsheets and thus you can play around with the data as you please. Also, James Bruce is working to get his gen report on the web. That will help with your access to information on new gen.
+
+Please let me know if you have any questions or feedback,
+
+Kourtney
+
+
+
+Kourtney Nelson
+Fundamental Analysis
+Enron North America
+(503) 464-8280
+kourtney.nelson@enron.com');
+INSERT INTO email([from],[to],subject,body) VALUES('d..thomas@enron.com', 'naveed.ahmed@enron.com', 'FW: Current Enron TCC Portfolio', '
+
+-----Original Message-----
+From: Grace, Rebecca M.
+Sent: Monday, December 17, 2001 9:44 AM
+To: Thomas, Paul D.
+Cc: Cashion, Jim; Allen, Thresa A.; May, Tom
+Subject: RE: Current Enron TCC Portfolio
+
+
+Paul,
+
+I reviewed NY''s list. I agree with all of their contracts numbers and mw amounts.
+
+Call if you have any more questions.
+
+Rebecca
+
+
+
+ -----Original Message-----
+From: Thomas, Paul D.
+Sent: Monday, December 17, 2001 9:08 AM
+To: Grace, Rebecca M.
+Subject: FW: Current Enron TCC Portfolio
+
+ << File: enrontccs.xls >>
+Rebecca,
+Let me know if you see any differences.
+
+Paul
+X 3-0403
+-----Original Message-----
+From: Thomas, Paul D.
+Sent: Monday, December 17, 2001 9:04 AM
+To: Ahmed, Naveed
+Subject: FW: Current Enron TCC Portfolio
+
+
+
+
+-----Original Message-----
+From: Thomas, Paul D.
+Sent: Thursday, December 13, 2001 10:01 AM
+To: Baughman, Edward D.
+Subject: Current Enron TCC Portfolio
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('stephanie.panus@enron.com', 'william.bradford@enron.com, debbie.brackett@enron.com,', 'Coastal Merchant Energy/El Paso Merchant Energy', 'Coastal Merchant Energy, L.P. merged with and into El Paso Merchant Energy,
+L.P., effective February 1, 2001, with the surviving entity being El Paso
+Merchant Energy, L.P. We currently have ISDA Master Agreements with both
+counterparties. Please see the attached memo regarding the existing Masters
+and let us know which agreement should be terminated.
+
+Thanks,
+Stephanie
+');
+INSERT INTO email([from],[to],subject,body) VALUES('kam.keiser@enron.com', 'c..kenne@enron.com', 'RE: What about this too???', '
+
+ -----Original Message-----
+From: Kenne, Dawn C.
+Sent: Wednesday, February 06, 2002 11:50 AM
+To: Keiser, Kam
+Subject: What about this too???
+
+
+ << File: Netco Trader Matrix.xls >>
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('chris.meyer@enron.com', 'joe.parks@enron.com', 'Centana', 'Talked to Chip. We do need Cash Committe approval given the netting feature of your deal, which means Batch Funding Request. Please update per my previous e-mail and forward.
+
+Thanks
+
+chris
+x31666');
+INSERT INTO email([from],[to],subject,body) VALUES('debra.perlingiere@enron.com', 'jworman@academyofhealth.com', '', 'Have a great weekend! Happy Fathers Day!
+
+
+Debra Perlingiere
+Enron North America Corp.
+1400 Smith Street, EB 3885
+Houston, Texas 77002
+dperlin@enron.com
+Phone 713-853-7658
+Fax 713-646-3490');
+INSERT INTO email([from],[to],subject,body) VALUES('outlook.team@enron.com', '', 'Demo by Martha Janousek of Dashboard & Pipeline Profile / Julia &', 'CALENDAR ENTRY: APPOINTMENT
+
+Description:
+ Demo by Martha Janousek of Dashboard & Pipeline Profile / Julia & Dir Rpts. - 4102
+
+Date: 1/5/2001
+Time: 9:00 AM - 10:00 AM (Central Standard Time)
+
+Chairperson: Outlook Migration Team
+
+Detailed Description:');
+INSERT INTO email([from],[to],subject,body) VALUES('diana.seifert@enron.com', 'mark.taylor@enron.com', 'Guest access Chile', 'Hello Mark,
+
+Justin Boyd told me that your can help me with questions regarding Chile.
+We got a request for guest access through MG.
+The company is called Escondida and is a subsidiary of BHP Australia.
+
+Please advise if I can set up a guest account or not.
+F.Y.I.: MG is planning to put a "in w/h Chile" contract for Copper on-line as
+soon as Enron has done the due diligence for this country.
+Thanks !
+
+
+Best regards
+
+Diana Seifert
+EOL PCG');
+INSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'mark.whitt@enron.com', '<<Concur Expense Document>> - 121001', 'The Approval status has changed on the following report:
+
+Status last changed by: Barry L. Tycholiz
+Expense Report Name: 121001
+Report Total: $198.98
+Amount Due Employee: $198.98
+Amount Approved: $198.98
+Amount Paid: $0.00
+Approval Status: Approved
+Payment Status: Pending
+
+
+To review this expense report, click on the following link for Concur Expense.
+http://expensexms.enron.com');
+INSERT INTO email([from],[to],subject,body) VALUES('kevin.hyatt@enron.com', '', 'Technical Support', 'Outside the U.S., please refer to the list below:
+
+Australia:
+1800 678-515
+support@palm-au.com
+
+Canada:
+1905 305-6530
+support@palm.com
+
+New Zealand:
+0800 446-398
+support@palm-nz.com
+
+U.K.:
+0171 867 0108
+eurosupport@palm.3com.com
+
+Please refer to the Worldwide Customer Support card for a complete technical support contact list.');
+INSERT INTO email([from],[to],subject,body) VALUES('geoff.storey@enron.com', 'dutch.quigley@enron.com', 'RE:', 'duke contact?
+
+ -----Original Message-----
+From: Quigley, Dutch
+Sent: Wednesday, October 31, 2001 10:14 AM
+To: Storey, Geoff
+Subject: RE:
+
+bp corp Albert LaMore 281-366-4962
+
+running the reports now
+
+
+ -----Original Message-----
+From: Storey, Geoff
+Sent: Wednesday, October 31, 2001 10:10 AM
+To: Quigley, Dutch
+Subject: RE:
+
+give me a contact over there too
+BP
+
+
+ -----Original Message-----
+From: Quigley, Dutch
+Sent: Wednesday, October 31, 2001 9:42 AM
+To: Storey, Geoff
+Subject:
+
+Coral Jeff Whitnah 713-767-5374
+Relaint Steve McGinn 713-207-4000');
+INSERT INTO email([from],[to],subject,body) VALUES('pete.davis@enron.com', 'pete.davis@enron.com', 'Start Date: 4/22/01; HourAhead hour: 3; <CODESITE>', 'Start Date: 4/22/01; HourAhead hour: 3; No ancillary schedules awarded.
+Variances detected.
+Variances detected in Load schedule.
+
+ LOG MESSAGES:
+
+PARSING FILE -->> O:\Portland\WestDesk\California Scheduling\ISO Final
+Schedules\2001042203.txt
+
+---- Load Schedule ----
+$$$ Variance found in table tblLoads.
+ Details: (Hour: 3 / Preferred: 1.92 / Final: 1.89)
+ TRANS_TYPE: FINAL
+ LOAD_ID: PGE4
+ MKT_TYPE: 2
+ TRANS_DATE: 4/22/01
+ SC_ID: EPMI
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('john.postlethwaite@enron.com', 'john.zufferli@enron.com', 'Reference', 'John, hope things are going well up there for you. The big day is almost here for you and Jessica. I was wondering if I could use your name as a job reference if need be. I am just trying to get everything in order just in case something happens.
+
+John');
+INSERT INTO email([from],[to],subject,body) VALUES('jeffrey.shankman@enron.com', 'lschiffm@jonesday.com', 'Re:', 'I saw you called on the cell this a.m. Sorry I missed you. (I was in the
+shower). I have had a shitty week--I suspect my silence (not only to you,
+but others) after our phone call is a result of the week. I''m seeing Glen at
+11:15....talk to you');
+INSERT INTO email([from],[to],subject,body) VALUES('litebytz@enron.com', '', 'Lite Bytz RSVP', '
+This week''s Lite Bytz presentation will feature the following TOOLZ speaker:
+
+Richard McDougall
+Solaris 8
+Thursday, June 7, 2001
+
+If you have not already signed up, please RSVP via email to litebytz@enron.com by the end of the day Tuesday, June 5, 2001.
+
+*Remember: this is now a Brown Bag Event--so bring your lunch and we will provide cookies and drinks.
+
+Click below for more details.
+
+http://home.enron.com:84/messaging/litebytztoolzprint.jpg');
+ COMMIT;
+ }
+} {}
+
+###############################################################################
+# Everything above just builds an interesting test database. The actual
+# tests come after this comment.
+###############################################################################
+
+do_test fts1c-1.2 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark'
+ }
+} {6 17 25 38 40 42 73 74}
+do_test fts1c-1.3 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'susan'
+ }
+} {24 40}
+do_test fts1c-1.4 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark susan'
+ }
+} {40}
+do_test fts1c-1.5 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'susan mark'
+ }
+} {40}
+do_test fts1c-1.6 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH '"mark susan"'
+ }
+} {}
+do_test fts1c-1.7 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark -susan'
+ }
+} {6 17 25 38 42 73 74}
+do_test fts1c-1.8 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH '-mark susan'
+ }
+} {24}
+do_test fts1c-1.9 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark OR susan'
+ }
+} {6 17 24 25 38 40 42 73 74}
+
+# Some simple tests of the automatic "offsets(email)" column. In the sample
+# data set above, only one message, number 20, contains the words
+# "gas" and "reminder" in both body and subject.
+#
+do_test fts1c-2.1 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE email MATCH 'gas reminder'
+ }
+} {20 {2 0 42 3 2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}
+do_test fts1c-2.2 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE email MATCH 'subject:gas reminder'
+ }
+} {20 {2 0 42 3 2 1 54 8 3 1 54 8}}
+do_test fts1c-2.3 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE email MATCH 'body:gas reminder'
+ }
+} {20 {2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}
+do_test fts1c-2.4 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE subject MATCH 'gas reminder'
+ }
+} {20 {2 0 42 3 2 1 54 8}}
+do_test fts1c-2.5 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE body MATCH 'gas reminder'
+ }
+} {20 {3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}
+
+# Document 32 contains 5 instances of the world "child". But only
+# 3 of them are paired with "product". Make sure only those instances
+# that match the phrase appear in the offsets(email) list.
+#
+do_test fts1c-3.1 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE body MATCH 'child product' AND +rowid=32
+ }
+} {32 {3 0 94 5 3 0 114 5 3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7 3 1 493 7}}
+do_test fts1c-3.2 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE body MATCH '"child product"'
+ }
+} {32 {3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7}}
+
+# Snippet generator tests
+#
+do_test fts1c-4.1 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'subject:gas reminder'
+ }
+} {{Alert Posted 10:00 AM November 20,2000: E-<b>GAS</b> Request <b>Reminder</b>}}
+do_test fts1c-4.2 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'christmas candlelight'
+ }
+} {{<b>...</b> place.? What do you think about going here <b>Christmas</b>
+eve?? They have an 11:00 a.m. service and a <b>candlelight</b> service at 5:00 p.m.,
+among others. <b>...</b>}}
+
+do_test fts1c-4.3 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'deal sheet potential reuse'
+ }
+} {{EOL-Accenture <b>Deal</b> <b>Sheet</b> <b>...</b> intent
+ Review Enron asset base for <b>potential</b> <b>reuse</b>/ licensing
+ Contract negotiations <b>...</b>}}
+do_test fts1c-4.4 {
+ execsql {
+ SELECT snippet(email,'<<<','>>>',' ') FROM email
+ WHERE email MATCH 'deal sheet potential reuse'
+ }
+} {{EOL-Accenture <<<Deal>>> <<<Sheet>>> intent
+ Review Enron asset base for <<<potential>>> <<<reuse>>>/ licensing
+ Contract negotiations }}
+do_test fts1c-4.5 {
+ execsql {
+ SELECT snippet(email,'<<<','>>>',' ') FROM email
+ WHERE email MATCH 'first things'
+ }
+} {{Re: <<<First>>> Polish Deal! Congrats! <<<Things>>> seem to be building rapidly now on the }}
+do_test fts1c-4.6 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'chris is here'
+ }
+} {{<b>chris</b>.germany@enron.com <b>...</b> Sounds good to me. I bet this <b>is</b> next to the Warick?? Hotel. <b>...</b> place.? What do you think about going <b>here</b> Christmas
+eve?? They have an 11:00 a.m. <b>...</b>}}
+do_test fts1c-4.7 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH '"pursuant to"'
+ }
+} {{Erin:
+
+<b>Pursuant</b> <b>to</b> your request, attached are the Schedule to <b>...</b>}}
+do_test fts1c-4.8 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'ancillary load davis'
+ }
+} {{pete.<b>davis</b>@enron.com <b>...</b> Start Date: 4/22/01; HourAhead hour: 3; No <b>ancillary</b> schedules awarded.
+Variances detected.
+Variances detected in <b>Load</b> schedule.
+
+ LOG MESSAGES:
+
+PARSING <b>...</b>}}
+
+# Combinations of AND and OR operators:
+#
+do_test fts1c-5.1 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'questar enron OR com'
+ }
+} {{matt.smith@<b>enron</b>.<b>com</b> <b>...</b> six reports:
+
+31 Keystone Receipts
+15 <b>Questar</b> Pipeline
+40 Rockies Production
+22 West_2 <b>...</b>}}
+do_test fts1c-5.2 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'enron OR com questar'
+ }
+} {{matt.smith@<b>enron</b>.<b>com</b> <b>...</b> six reports:
+
+31 Keystone Receipts
+15 <b>Questar</b> Pipeline
+40 Rockies Production
+22 West_2 <b>...</b>}}
+
+finish_test
diff --git a/test/fts1d.test b/test/fts1d.test
new file mode 100644
index 0000000..ea23034
--- /dev/null
+++ b/test/fts1d.test
@@ -0,0 +1,65 @@
+# 2006 October 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS1 module, and in particular
+# the Porter stemmer.
+#
+# $Id: fts1d.test,v 1.1 2006/10/01 18:41:21 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+do_test fts1d-1.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts1(content, tokenize porter);
+ INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
+ SELECT rowid FROM t1 WHERE content MATCH 'run jump';
+ }
+} {1}
+do_test fts1d-1.2 {
+ execsql {
+ SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'run jump';
+ }
+} {{<b>running</b> and <b>jumping</b>}}
+do_test fts1d-1.3 {
+ execsql {
+ INSERT INTO t1(rowid, content)
+ VALUES(2, 'abcdefghijklmnopqrstuvwyxz');
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijqrstuvwyxz'
+ }
+} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
+do_test fts1d-1.4 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'
+ }
+} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
+do_test fts1d-1.5 {
+ execsql {
+ INSERT INTO t1(rowid, content)
+ VALUES(3, 'The value is 123456789');
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123789'
+ }
+} {3 {The value is <b>123456789</b>}}
+do_test fts1d-1.6 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123000000789'
+ }
+} {3 {The value is <b>123456789</b>}}
+
+
+finish_test
diff --git a/test/fts1e.test b/test/fts1e.test
new file mode 100644
index 0000000..479cfac
--- /dev/null
+++ b/test/fts1e.test
@@ -0,0 +1,85 @@
+# 2006 October 19
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing deletions in the FTS1 module.
+#
+# $Id: fts1e.test,v 1.1 2006/10/19 23:28:35 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+# Construct a full-text search table containing keywords which are the
+# ordinal numbers of the bit positions set for a sequence of integers,
+# which are used for the rowid. There are a total of 30 INSERT and
+# DELETE statements, so that we'll test both the segmentMerge() merge
+# (over the first 16) and the termSelect() merge (over the level-1
+# segment and 14 level-0 segments).
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts1(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, 'one');
+ INSERT INTO t1 (rowid, content) VALUES(2, 'two');
+ INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
+ INSERT INTO t1 (rowid, content) VALUES(4, 'three');
+ DELETE FROM t1 WHERE rowid = 1;
+ INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
+ INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
+ INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
+ DELETE FROM t1 WHERE rowid = 4;
+ INSERT INTO t1 (rowid, content) VALUES(8, 'four');
+ INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
+ INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
+ DELETE FROM t1 WHERE rowid = 7;
+ INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
+ INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
+ INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
+ DELETE FROM t1 WHERE rowid = 10;
+ INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
+ INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
+ INSERT INTO t1 (rowid, content) VALUES(16, 'five');
+ DELETE FROM t1 WHERE rowid = 13;
+ INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
+ INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
+ INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
+ DELETE FROM t1 WHERE rowid = 16;
+ INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
+ INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
+ INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
+ DELETE FROM t1 WHERE rowid = 19;
+ DELETE FROM t1 WHERE rowid = 22;
+}
+
+do_test fts1f-1.1 {
+ execsql {SELECT COUNT(*) FROM t1}
+} {14}
+
+do_test fts1e-2.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {3 5 9 11 15 17 21}
+
+do_test fts1e-2.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
+} {2 3 6 11 14 15 18}
+
+do_test fts1e-2.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
+} {5 6 12 14 15 20 21}
+
+do_test fts1e-2.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
+} {8 9 11 12 14 15}
+
+do_test fts1e-2.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
+} {17 18 20 21}
+
+finish_test
diff --git a/test/fts1f.test b/test/fts1f.test
new file mode 100644
index 0000000..19dea0a
--- /dev/null
+++ b/test/fts1f.test
@@ -0,0 +1,90 @@
+# 2006 October 19
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing updates in the FTS1 module.
+#
+# $Id: fts1f.test,v 1.2 2007/02/23 00:14:06 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+# Construct a full-text search table containing keywords which are the
+# ordinal numbers of the bit positions set for a sequence of integers,
+# which are used for the rowid. There are a total of 31 INSERT,
+# UPDATE, and DELETE statements, so that we'll test both the
+# segmentMerge() merge (over the first 16) and the termSelect() merge
+# (over the level-1 segment and 15 level-0 segments).
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts1(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, 'one');
+ INSERT INTO t1 (rowid, content) VALUES(2, 'two');
+ INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
+ INSERT INTO t1 (rowid, content) VALUES(4, 'three');
+ INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
+ INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
+ INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
+ DELETE FROM t1 WHERE rowid = 4;
+ INSERT INTO t1 (rowid, content) VALUES(8, 'four');
+ UPDATE t1 SET content = 'update one three' WHERE rowid = 1;
+ INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
+ INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
+ DELETE FROM t1 WHERE rowid = 7;
+ INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
+ INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
+ INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
+ DELETE FROM t1 WHERE rowid = 10;
+ INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
+ INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
+ UPDATE t1 SET content = 'update two five' WHERE rowid = 8;
+ INSERT INTO t1 (rowid, content) VALUES(16, 'five');
+ DELETE FROM t1 WHERE rowid = 13;
+ INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
+ INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
+ INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
+ DELETE FROM t1 WHERE rowid = 16;
+ INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
+ INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
+ INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
+ DELETE FROM t1 WHERE rowid = 19;
+ UPDATE t1 SET content = 'update' WHERE rowid = 15;
+}
+
+do_test fts1f-1.1 {
+ execsql {SELECT COUNT(*) FROM t1}
+} {16}
+
+do_test fts1f-2.0 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}
+} {1 8 15}
+
+do_test fts1f-2.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {1 3 5 9 11 17 21}
+
+do_test fts1f-2.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
+} {2 3 6 8 11 14 18 22}
+
+do_test fts1f-2.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
+} {1 5 6 12 14 20 21 22}
+
+do_test fts1f-2.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
+} {9 11 12 14}
+
+do_test fts1f-2.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
+} {8 17 18 20 21 22}
+
+finish_test
diff --git a/test/fts1i.test b/test/fts1i.test
new file mode 100644
index 0000000..803b93b
--- /dev/null
+++ b/test/fts1i.test
@@ -0,0 +1,88 @@
+# 2007 January 17
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite fts1 library. The
+# focus here is testing handling of UPDATE when using UTF-16-encoded
+# databases.
+#
+# $Id: fts1i.test,v 1.2 2007/01/24 03:43:20 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+
+# Return the UTF-16 representation of the supplied UTF-8 string $str.
+# If $nt is true, append two 0x00 bytes as a nul terminator.
+# NOTE(shess) Copied from capi3.test.
+proc utf16 {str {nt 1}} {
+ set r [encoding convertto unicode $str]
+ if {$nt} {
+ append r "\x00\x00"
+ }
+ return $r
+}
+
+db eval {
+ PRAGMA encoding = "UTF-16le";
+ CREATE VIRTUAL TABLE t1 USING fts1(content);
+}
+
+do_test fts1i-1.0 {
+ execsql {PRAGMA encoding}
+} {UTF-16le}
+
+do_test fts1i-1.1 {
+ execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')}
+ execsql {SELECT content FROM t1 WHERE rowid = 1}
+} {one}
+
+do_test fts1i-1.2 {
+ set sql "INSERT INTO t1 (rowid, content) VALUES(2, 'two')"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 2}
+} {two}
+
+do_test fts1i-1.3 {
+ set sql "INSERT INTO t1 (rowid, content) VALUES(3, 'three')"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ set sql "UPDATE t1 SET content = 'trois' WHERE rowid = 3"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 3}
+} {trois}
+
+do_test fts1i-1.4 {
+ set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}]
+ set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 4}
+} {four}
+
+do_test fts1i-1.5 {
+ set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}]
+ set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ set sql "UPDATE t1 SET content = 'cinq' WHERE rowid = 5"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 5}
+} {cinq}
+
+finish_test
diff --git a/test/fts1j.test b/test/fts1j.test
new file mode 100644
index 0000000..4dac22a
--- /dev/null
+++ b/test/fts1j.test
@@ -0,0 +1,89 @@
+# 2007 February 6
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. This
+# tests creating fts1 tables in an attached database.
+#
+# $Id: fts1j.test,v 1.1 2007/02/07 01:01:18 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+# Clean up anything left over from a previous pass.
+forcedelete test2.db
+forcedelete test2.db-journal
+sqlite3 db2 test2.db
+
+db eval {
+ CREATE VIRTUAL TABLE t3 USING fts1(content);
+ INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
+}
+
+db2 eval {
+ CREATE VIRTUAL TABLE t1 USING fts1(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
+ INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
+}
+
+# This has always worked because the t1_* tables used by fts1 will be
+# the defaults.
+do_test fts1j-1.1 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS two;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'hello';
+ DETACH DATABASE two;
+ }
+} {1 2}
+# Make certain we're detached if there was an error.
+catch {db eval {DETACH DATABASE two}}
+
+# In older code, this appears to work fine, but the t2_* tables used
+# by fts1 will be created in database 'main' instead of database
+# 'two'. It appears to work fine because the tables end up being the
+# defaults, but obviously is badly broken if you hope to use things
+# other than in the exact same ATTACH setup.
+do_test fts1j-1.2 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS two;
+ CREATE VIRTUAL TABLE two.t2 USING fts1(content);
+ INSERT INTO t2 (rowid, content) VALUES(1, "hello world");
+ INSERT INTO t2 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO t2 (rowid, content) VALUES(3, "cruel world");
+ SELECT rowid FROM t2 WHERE t2 MATCH 'hello';
+ DETACH DATABASE two;
+ }
+} {1 2}
+catch {db eval {DETACH DATABASE two}}
+
+# In older code, this broke because the fts1 code attempted to create
+# t3_* tables in database 'main', but they already existed. Normally
+# this wouldn't happen without t3 itself existing, in which case the
+# fts1 code would never be called in the first place.
+do_test fts1j-1.3 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS two;
+
+ CREATE VIRTUAL TABLE two.t3 USING fts1(content);
+ INSERT INTO two.t3 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO two.t3 (rowid, content) VALUES(3, "cruel world");
+ SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello';
+
+ DETACH DATABASE two;
+ } db2
+} {2}
+catch {db eval {DETACH DATABASE two}}
+
+catch {db2 close}
+forcedelete test2.db
+
+finish_test
diff --git a/test/fts1k.test b/test/fts1k.test
new file mode 100644
index 0000000..35b94d2
--- /dev/null
+++ b/test/fts1k.test
@@ -0,0 +1,69 @@
+# 2007 March 28
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing isspace/isalnum/tolower problems with the
+# FTS1 module. Unfortunately, this code isn't a really principled set
+# of tests, because it is impossible to know where new uses of these
+# functions might appear.
+#
+# $Id: fts1k.test,v 1.2 2007/12/13 21:54:11 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+# Tests that startsWith() (calls isspace, tolower, isalnum) can handle
+# hi-bit chars. parseSpec() also calls isalnum here.
+do_test fts1k-1.1 {
+ execsql "CREATE VIRTUAL TABLE t1 USING fts1(content, \x80)"
+} {}
+
+# Additionally tests isspace() call in getToken(), and isalnum() call
+# in tokenListToIdList().
+do_test fts1k-1.2 {
+ catch {
+ execsql "CREATE VIRTUAL TABLE t2 USING fts1(content, tokenize \x80)"
+ }
+ sqlite3_errmsg $DB
+} "unknown tokenizer: \x80"
+
+# Additionally test final isalnum() in startsWith().
+do_test fts1k-1.3 {
+ execsql "CREATE VIRTUAL TABLE t3 USING fts1(content, tokenize\x80)"
+} {}
+
+# The snippet-generation code has calls to isspace() which are sort of
+# hard to get to. It finds convenient breakpoints by starting ~40
+# chars before and after the matched term, and scanning ~10 chars
+# around that position for isspace() characters. The long word with
+# embedded hi-bit chars causes one of these isspace() calls to be
+# exercised. The version with a couple extra spaces should cause the
+# other isspace() call to be exercised. [Both cases have been tested
+# in the debugger, but I'm hoping to continue to catch it if simple
+# constant changes change things slightly.
+#
+# The trailing and leading hi-bit chars help with code which tests for
+# isspace() to coalesce multiple spaces.
+
+set word "\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80"
+set phrase1 "$word $word $word target $word $word $word"
+set phrase2 "$word $word $word target $word $word $word"
+
+db eval {CREATE VIRTUAL TABLE t4 USING fts1(content)}
+db eval "INSERT INTO t4 (content) VALUES ('$phrase1')"
+db eval "INSERT INTO t4 (content) VALUES ('$phrase2')"
+
+do_test fts1k-1.4 {
+ execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}
+} {1 111 2 117}
+
+finish_test
diff --git a/test/fts1l.test b/test/fts1l.test
new file mode 100644
index 0000000..924be33
--- /dev/null
+++ b/test/fts1l.test
@@ -0,0 +1,65 @@
+# 2007 April 9
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. fts1
+# DELETE handling assumed all fields were non-null. This was not
+# the intention at all.
+#
+# $Id: fts1l.test,v 1.1 2007/04/09 20:45:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts1(col_a, col_b);
+
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing');
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null);
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b');
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null);
+}
+
+do_test fts1m-1.0 {
+ execsql {
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {2 2 4}
+
+do_test fts1m-1.1 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 1;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {1 1 3}
+
+do_test fts1m-1.2 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 2;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {0 1 2}
+
+do_test fts1m-1.3 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 3;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {0 0 1}
+
+do_test fts1m-1.4 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 4;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {0 0 0}
+
+finish_test
diff --git a/test/fts1m.test b/test/fts1m.test
new file mode 100644
index 0000000..c2f8f91
--- /dev/null
+++ b/test/fts1m.test
@@ -0,0 +1,50 @@
+# 2007 July 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing the FTS1 module, specifically snippet
+# generation. Extracted from fts2o.test.
+#
+# $Id: fts1m.test,v 1.1 2007/07/25 00:25:20 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is not defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+#---------------------------------------------------------------------
+# These tests, fts1m-1.*, test that ticket #2429 is fixed.
+#
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts1(a, b, c);
+ INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');
+}
+do_test fts1m-1.1 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four';
+ }
+} {1 {one <b>four</b> two}}
+do_test fts1m-1.2 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE b MATCH 'four';
+ }
+} {1 {one <b>four</b>}}
+do_test fts1m-1.3 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE a MATCH 'four';
+ }
+} {1 {one three <b>four</b>}}
+
+finish_test
diff --git a/test/fts1n.test b/test/fts1n.test
new file mode 100644
index 0000000..2f102b4
--- /dev/null
+++ b/test/fts1n.test
@@ -0,0 +1,45 @@
+# 2007 July 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing the FTS1 module for errors in the handling
+# of SQLITE_SCHEMA.
+#
+# $Id: fts1n.test,v 1.1 2007/07/25 00:38:06 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is not defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+do_test fts1m-1.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts1(a, b, c);
+ INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two');
+ SELECT a, b, c FROM t1 WHERE c MATCH 'two';
+ }
+} {{one three four} {one four} {one two}}
+
+# This test was crashing at one point.
+#
+do_test fts1m-1.2 {
+ execsql {
+ SELECT a, b, c FROM t1 WHERE c MATCH 'two';
+ CREATE TABLE t3(a, b, c);
+ SELECT a, b, c FROM t1 WHERE c MATCH 'two';
+ }
+} {{one three four} {one four} {one two} {one three four} {one four} {one two}}
+
+finish_test
diff --git a/test/fts1o.test b/test/fts1o.test
new file mode 100644
index 0000000..61fd74c
--- /dev/null
+++ b/test/fts1o.test
@@ -0,0 +1,138 @@
+# 2007 July 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing the FTS1 module rename functionality. Mostly
+# copied from fts2o.test.
+#
+# $Id: fts1o.test,v 1.2 2007/08/30 20:01:33 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is not defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts1(a, b, c);
+ INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');
+}
+
+#---------------------------------------------------------------------
+# Test that it is possible to rename an fts1 table.
+#
+do_test fts1o-1.1 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {t1 t1_content t1_term}
+do_test fts1o-1.2 {
+ execsql { ALTER TABLE t1 RENAME to fts_t1; }
+} {}
+do_test fts1o-1.3 {
+ execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
+} {1 {one three <b>four</b>}}
+do_test fts1o-1.4 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {fts_t1 fts_t1_content fts_t1_term}
+
+# See what happens when renaming the fts1 table fails.
+#
+do_test fts1o-2.1 {
+ catchsql {
+ CREATE TABLE t1_term(a, b, c);
+ ALTER TABLE fts_t1 RENAME to t1;
+ }
+} {1 {SQL logic error or missing database}}
+do_test fts1o-2.2 {
+ execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
+} {1 {one three <b>four</b>}}
+do_test fts1o-2.3 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {fts_t1 fts_t1_content fts_t1_term t1_term}
+
+# See what happens when renaming the fts1 table fails inside a transaction.
+#
+do_test fts1o-3.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO fts_t1(a, b, c) VALUES('one two three', 'one four', 'one two');
+ }
+} {}
+do_test fts1o-3.2 {
+ catchsql {
+ ALTER TABLE fts_t1 RENAME to t1;
+ }
+} {1 {SQL logic error or missing database}}
+# NOTE(shess) rowid AS rowid to defeat caching. Otherwise, this
+# seg-faults, I suspect that there's something up with a stale
+# virtual-table reference, but I'm not quite sure how it happens here
+# but not for fts2o.test.
+do_test fts1o-3.3 {
+ execsql { SELECT rowid AS rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
+} {1 {one three <b>four</b>}}
+do_test fts1o-3.4 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {fts_t1 fts_t1_content fts_t1_term t1_term}
+do_test fts1o-3.5 {
+ execsql COMMIT
+ execsql {SELECT a FROM fts_t1}
+} {{one three four} {one two three}}
+do_test fts1o-3.6 {
+ execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; }
+} {{one three four} {one four} {one four two}}
+
+#---------------------------------------------------------------------
+# Test that it is possible to rename an fts1 table in an attached
+# database.
+#
+forcedelete test2.db test2.db-journal
+
+do_test fts1o-4.1 {
+ execsql {
+ DROP TABLE t1_term;
+ ALTER TABLE fts_t1 RENAME to t1;
+ SELECT a, b, c FROM t1 WHERE c MATCH 'two';
+ }
+} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}
+
+do_test fts1o-4.2 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ CREATE VIRTUAL TABLE aux.t1 USING fts1(a, b, c);
+ INSERT INTO aux.t1(a, b, c) VALUES(
+ 'neung song sahm', 'neung see', 'neung see song'
+ );
+ }
+} {}
+
+do_test fts1o-4.3 {
+ execsql { SELECT a, b, c FROM aux.t1 WHERE a MATCH 'song'; }
+} {{neung song sahm} {neung see} {neung see song}}
+
+do_test fts1o-4.4 {
+ execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
+} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}
+
+do_test fts1o-4.5 {
+ execsql { ALTER TABLE aux.t1 RENAME TO t2 }
+} {}
+
+do_test fts1o-4.6 {
+ execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; }
+} {{neung song sahm} {neung see} {neung see song}}
+
+do_test fts1o-4.7 {
+ execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
+} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}
+
+finish_test
diff --git a/test/fts1porter.test b/test/fts1porter.test
new file mode 100644
index 0000000..0ca87a0
--- /dev/null
+++ b/test/fts1porter.test
@@ -0,0 +1,23590 @@
+# 2006 October 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS1 module, and in particular
+# the Porter stemmer.
+#
+# $Id: fts1porter.test,v 1.5 2006/10/03 19:37:37 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS1 is defined, omit this file.
+ifcapable !fts1 {
+ finish_test
+ return
+}
+
+# Test data for the Porter stemmer. The first word of each line
+# is the input. The second word is the desired output.
+#
+# This test data is taken from http://www.tartarus.org/martin/PorterStemmer/
+# There is no claim of copyright made on that page, but you should
+# probably contact the author (Martin Porter - the inventor of the
+# Porter Stemmer algorithm) if you want to use this test data in a
+# commerical product of some kind. The stemmer code in FTS1 is a
+# complete rewrite from scratch based on the algorithm specification
+# and does not contain any code under copyright.
+#
+set porter_test_data {
+ a a
+ aaron aaron
+ abaissiez abaissiez
+ abandon abandon
+ abandoned abandon
+ abase abas
+ abash abash
+ abate abat
+ abated abat
+ abatement abat
+ abatements abat
+ abates abat
+ abbess abbess
+ abbey abbei
+ abbeys abbei
+ abbominable abbomin
+ abbot abbot
+ abbots abbot
+ abbreviated abbrevi
+ abed ab
+ abel abel
+ aberga aberga
+ abergavenny abergavenni
+ abet abet
+ abetting abet
+ abhominable abhomin
+ abhor abhor
+ abhorr abhorr
+ abhorred abhor
+ abhorring abhor
+ abhors abhor
+ abhorson abhorson
+ abide abid
+ abides abid
+ abilities abil
+ ability abil
+ abject abject
+ abjectly abjectli
+ abjects abject
+ abjur abjur
+ abjure abjur
+ able abl
+ abler abler
+ aboard aboard
+ abode abod
+ aboded abod
+ abodements abod
+ aboding abod
+ abominable abomin
+ abominably abomin
+ abominations abomin
+ abortive abort
+ abortives abort
+ abound abound
+ abounding abound
+ about about
+ above abov
+ abr abr
+ abraham abraham
+ abram abram
+ abreast abreast
+ abridg abridg
+ abridge abridg
+ abridged abridg
+ abridgment abridg
+ abroach abroach
+ abroad abroad
+ abrogate abrog
+ abrook abrook
+ abrupt abrupt
+ abruption abrupt
+ abruptly abruptli
+ absence absenc
+ absent absent
+ absey absei
+ absolute absolut
+ absolutely absolut
+ absolv absolv
+ absolver absolv
+ abstains abstain
+ abstemious abstemi
+ abstinence abstin
+ abstract abstract
+ absurd absurd
+ absyrtus absyrtu
+ abundance abund
+ abundant abund
+ abundantly abundantli
+ abus abu
+ abuse abus
+ abused abus
+ abuser abus
+ abuses abus
+ abusing abus
+ abutting abut
+ aby abi
+ abysm abysm
+ ac ac
+ academe academ
+ academes academ
+ accent accent
+ accents accent
+ accept accept
+ acceptable accept
+ acceptance accept
+ accepted accept
+ accepts accept
+ access access
+ accessary accessari
+ accessible access
+ accidence accid
+ accident accid
+ accidental accident
+ accidentally accident
+ accidents accid
+ accite accit
+ accited accit
+ accites accit
+ acclamations acclam
+ accommodate accommod
+ accommodated accommod
+ accommodation accommod
+ accommodations accommod
+ accommodo accommodo
+ accompanied accompani
+ accompany accompani
+ accompanying accompani
+ accomplices accomplic
+ accomplish accomplish
+ accomplished accomplish
+ accomplishing accomplish
+ accomplishment accomplish
+ accompt accompt
+ accord accord
+ accordant accord
+ accorded accord
+ accordeth accordeth
+ according accord
+ accordingly accordingli
+ accords accord
+ accost accost
+ accosted accost
+ account account
+ accountant account
+ accounted account
+ accounts account
+ accoutred accoutr
+ accoutrement accoutr
+ accoutrements accoutr
+ accrue accru
+ accumulate accumul
+ accumulated accumul
+ accumulation accumul
+ accurs accur
+ accursed accurs
+ accurst accurst
+ accus accu
+ accusation accus
+ accusations accus
+ accusative accus
+ accusativo accusativo
+ accuse accus
+ accused accus
+ accuser accus
+ accusers accus
+ accuses accus
+ accuseth accuseth
+ accusing accus
+ accustom accustom
+ accustomed accustom
+ ace ac
+ acerb acerb
+ ache ach
+ acheron acheron
+ aches ach
+ achiev achiev
+ achieve achiev
+ achieved achiev
+ achievement achiev
+ achievements achiev
+ achiever achiev
+ achieves achiev
+ achieving achiev
+ achilles achil
+ aching ach
+ achitophel achitophel
+ acknowledg acknowledg
+ acknowledge acknowledg
+ acknowledged acknowledg
+ acknowledgment acknowledg
+ acknown acknown
+ acold acold
+ aconitum aconitum
+ acordo acordo
+ acorn acorn
+ acquaint acquaint
+ acquaintance acquaint
+ acquainted acquaint
+ acquaints acquaint
+ acquir acquir
+ acquire acquir
+ acquisition acquisit
+ acquit acquit
+ acquittance acquitt
+ acquittances acquitt
+ acquitted acquit
+ acre acr
+ acres acr
+ across across
+ act act
+ actaeon actaeon
+ acted act
+ acting act
+ action action
+ actions action
+ actium actium
+ active activ
+ actively activ
+ activity activ
+ actor actor
+ actors actor
+ acts act
+ actual actual
+ acture actur
+ acute acut
+ acutely acut
+ ad ad
+ adage adag
+ adallas adalla
+ adam adam
+ adamant adam
+ add add
+ added ad
+ adder adder
+ adders adder
+ addeth addeth
+ addict addict
+ addicted addict
+ addiction addict
+ adding ad
+ addition addit
+ additions addit
+ addle addl
+ address address
+ addressing address
+ addrest addrest
+ adds add
+ adhere adher
+ adheres adher
+ adieu adieu
+ adieus adieu
+ adjacent adjac
+ adjoin adjoin
+ adjoining adjoin
+ adjourn adjourn
+ adjudg adjudg
+ adjudged adjudg
+ adjunct adjunct
+ administer administ
+ administration administr
+ admir admir
+ admirable admir
+ admiral admir
+ admiration admir
+ admire admir
+ admired admir
+ admirer admir
+ admiring admir
+ admiringly admiringli
+ admission admiss
+ admit admit
+ admits admit
+ admittance admitt
+ admitted admit
+ admitting admit
+ admonish admonish
+ admonishing admonish
+ admonishment admonish
+ admonishments admonish
+ admonition admonit
+ ado ado
+ adonis adoni
+ adopt adopt
+ adopted adopt
+ adoptedly adoptedli
+ adoption adopt
+ adoptious adopti
+ adopts adopt
+ ador ador
+ adoration ador
+ adorations ador
+ adore ador
+ adorer ador
+ adores ador
+ adorest adorest
+ adoreth adoreth
+ adoring ador
+ adorn adorn
+ adorned adorn
+ adornings adorn
+ adornment adorn
+ adorns adorn
+ adown adown
+ adramadio adramadio
+ adrian adrian
+ adriana adriana
+ adriano adriano
+ adriatic adriat
+ adsum adsum
+ adulation adul
+ adulterate adulter
+ adulterates adulter
+ adulterers adulter
+ adulteress adulteress
+ adulteries adulteri
+ adulterous adulter
+ adultery adulteri
+ adultress adultress
+ advanc advanc
+ advance advanc
+ advanced advanc
+ advancement advanc
+ advancements advanc
+ advances advanc
+ advancing advanc
+ advantage advantag
+ advantageable advantag
+ advantaged advantag
+ advantageous advantag
+ advantages advantag
+ advantaging advantag
+ advent advent
+ adventur adventur
+ adventure adventur
+ adventures adventur
+ adventuring adventur
+ adventurous adventur
+ adventurously adventur
+ adversaries adversari
+ adversary adversari
+ adverse advers
+ adversely advers
+ adversities advers
+ adversity advers
+ advertis adverti
+ advertise advertis
+ advertised advertis
+ advertisement advertis
+ advertising advertis
+ advice advic
+ advis advi
+ advise advis
+ advised advis
+ advisedly advisedli
+ advises advis
+ advisings advis
+ advocate advoc
+ advocation advoc
+ aeacida aeacida
+ aeacides aeacid
+ aedile aedil
+ aediles aedil
+ aegeon aegeon
+ aegion aegion
+ aegles aegl
+ aemelia aemelia
+ aemilia aemilia
+ aemilius aemiliu
+ aeneas aenea
+ aeolus aeolu
+ aer aer
+ aerial aerial
+ aery aeri
+ aesculapius aesculapiu
+ aeson aeson
+ aesop aesop
+ aetna aetna
+ afar afar
+ afear afear
+ afeard afeard
+ affability affabl
+ affable affabl
+ affair affair
+ affaire affair
+ affairs affair
+ affect affect
+ affectation affect
+ affectations affect
+ affected affect
+ affectedly affectedli
+ affecteth affecteth
+ affecting affect
+ affection affect
+ affectionate affection
+ affectionately affection
+ affections affect
+ affects affect
+ affeer affeer
+ affianc affianc
+ affiance affianc
+ affianced affianc
+ affied affi
+ affin affin
+ affined affin
+ affinity affin
+ affirm affirm
+ affirmation affirm
+ affirmatives affirm
+ afflict afflict
+ afflicted afflict
+ affliction afflict
+ afflictions afflict
+ afflicts afflict
+ afford afford
+ affordeth affordeth
+ affords afford
+ affray affrai
+ affright affright
+ affrighted affright
+ affrights affright
+ affront affront
+ affronted affront
+ affy affi
+ afield afield
+ afire afir
+ afloat afloat
+ afoot afoot
+ afore afor
+ aforehand aforehand
+ aforesaid aforesaid
+ afraid afraid
+ afresh afresh
+ afric afric
+ africa africa
+ african african
+ afront afront
+ after after
+ afternoon afternoon
+ afterward afterward
+ afterwards afterward
+ ag ag
+ again again
+ against against
+ agamemmon agamemmon
+ agamemnon agamemnon
+ agate agat
+ agaz agaz
+ age ag
+ aged ag
+ agenor agenor
+ agent agent
+ agents agent
+ ages ag
+ aggravate aggrav
+ aggrief aggrief
+ agile agil
+ agincourt agincourt
+ agitation agit
+ aglet aglet
+ agnize agniz
+ ago ago
+ agone agon
+ agony agoni
+ agree agre
+ agreed agre
+ agreeing agre
+ agreement agreement
+ agrees agre
+ agrippa agrippa
+ aground aground
+ ague agu
+ aguecheek aguecheek
+ agued agu
+ agueface aguefac
+ agues agu
+ ah ah
+ aha aha
+ ahungry ahungri
+ ai ai
+ aialvolio aialvolio
+ aiaria aiaria
+ aid aid
+ aidance aidanc
+ aidant aidant
+ aided aid
+ aiding aid
+ aidless aidless
+ aids aid
+ ail ail
+ aim aim
+ aimed aim
+ aimest aimest
+ aiming aim
+ aims aim
+ ainsi ainsi
+ aio aio
+ air air
+ aired air
+ airless airless
+ airs air
+ airy airi
+ ajax ajax
+ akilling akil
+ al al
+ alabaster alabast
+ alack alack
+ alacrity alacr
+ alarbus alarbu
+ alarm alarm
+ alarms alarm
+ alarum alarum
+ alarums alarum
+ alas ala
+ alb alb
+ alban alban
+ albans alban
+ albany albani
+ albeit albeit
+ albion albion
+ alchemist alchemist
+ alchemy alchemi
+ alcibiades alcibiad
+ alcides alcid
+ alder alder
+ alderman alderman
+ aldermen aldermen
+ ale al
+ alecto alecto
+ alehouse alehous
+ alehouses alehous
+ alencon alencon
+ alengon alengon
+ aleppo aleppo
+ ales al
+ alewife alewif
+ alexander alexand
+ alexanders alexand
+ alexandria alexandria
+ alexandrian alexandrian
+ alexas alexa
+ alias alia
+ alice alic
+ alien alien
+ aliena aliena
+ alight alight
+ alighted alight
+ alights alight
+ aliis alii
+ alike alik
+ alisander alisand
+ alive aliv
+ all all
+ alla alla
+ allay allai
+ allayed allai
+ allaying allai
+ allayment allay
+ allayments allay
+ allays allai
+ allegation alleg
+ allegations alleg
+ allege alleg
+ alleged alleg
+ allegiance allegi
+ allegiant allegi
+ alley allei
+ alleys allei
+ allhallowmas allhallowma
+ alliance allianc
+ allicholy allicholi
+ allied alli
+ allies alli
+ alligant allig
+ alligator allig
+ allons allon
+ allot allot
+ allots allot
+ allotted allot
+ allottery allotteri
+ allow allow
+ allowance allow
+ allowed allow
+ allowing allow
+ allows allow
+ allur allur
+ allure allur
+ allurement allur
+ alluring allur
+ allusion allus
+ ally alli
+ allycholly allycholli
+ almain almain
+ almanac almanac
+ almanack almanack
+ almanacs almanac
+ almighty almighti
+ almond almond
+ almost almost
+ alms alm
+ almsman almsman
+ aloes alo
+ aloft aloft
+ alone alon
+ along along
+ alonso alonso
+ aloof aloof
+ aloud aloud
+ alphabet alphabet
+ alphabetical alphabet
+ alphonso alphonso
+ alps alp
+ already alreadi
+ also also
+ alt alt
+ altar altar
+ altars altar
+ alter alter
+ alteration alter
+ altered alter
+ alters alter
+ althaea althaea
+ although although
+ altitude altitud
+ altogether altogeth
+ alton alton
+ alway alwai
+ always alwai
+ am am
+ amaimon amaimon
+ amain amain
+ amaking amak
+ amamon amamon
+ amaz amaz
+ amaze amaz
+ amazed amaz
+ amazedly amazedli
+ amazedness amazed
+ amazement amaz
+ amazes amaz
+ amazeth amazeth
+ amazing amaz
+ amazon amazon
+ amazonian amazonian
+ amazons amazon
+ ambassador ambassador
+ ambassadors ambassador
+ amber amber
+ ambiguides ambiguid
+ ambiguities ambigu
+ ambiguous ambigu
+ ambition ambit
+ ambitions ambit
+ ambitious ambiti
+ ambitiously ambiti
+ amble ambl
+ ambled ambl
+ ambles ambl
+ ambling ambl
+ ambo ambo
+ ambuscadoes ambuscado
+ ambush ambush
+ amen amen
+ amend amend
+ amended amend
+ amendment amend
+ amends amend
+ amerce amerc
+ america america
+ ames am
+ amiable amiabl
+ amid amid
+ amidst amidst
+ amiens amien
+ amis ami
+ amiss amiss
+ amities amiti
+ amity amiti
+ amnipotent amnipot
+ among among
+ amongst amongst
+ amorous amor
+ amorously amor
+ amort amort
+ amount amount
+ amounts amount
+ amour amour
+ amphimacus amphimacu
+ ample ampl
+ ampler ampler
+ amplest amplest
+ amplified amplifi
+ amplify amplifi
+ amply ampli
+ ampthill ampthil
+ amurath amurath
+ amyntas amynta
+ an an
+ anatomiz anatomiz
+ anatomize anatom
+ anatomy anatomi
+ ancestor ancestor
+ ancestors ancestor
+ ancestry ancestri
+ anchises anchis
+ anchor anchor
+ anchorage anchorag
+ anchored anchor
+ anchoring anchor
+ anchors anchor
+ anchovies anchovi
+ ancient ancient
+ ancientry ancientri
+ ancients ancient
+ ancus ancu
+ and and
+ andirons andiron
+ andpholus andpholu
+ andren andren
+ andrew andrew
+ andromache andromach
+ andronici andronici
+ andronicus andronicu
+ anew anew
+ ang ang
+ angel angel
+ angelica angelica
+ angelical angel
+ angelo angelo
+ angels angel
+ anger anger
+ angerly angerli
+ angers anger
+ anges ang
+ angiers angier
+ angl angl
+ anglais anglai
+ angle angl
+ angler angler
+ angleterre angleterr
+ angliae anglia
+ angling angl
+ anglish anglish
+ angrily angrili
+ angry angri
+ anguish anguish
+ angus angu
+ animal anim
+ animals anim
+ animis animi
+ anjou anjou
+ ankle ankl
+ anna anna
+ annals annal
+ anne ann
+ annex annex
+ annexed annex
+ annexions annexion
+ annexment annex
+ annothanize annothan
+ announces announc
+ annoy annoi
+ annoyance annoy
+ annoying annoi
+ annual annual
+ anoint anoint
+ anointed anoint
+ anon anon
+ another anoth
+ anselmo anselmo
+ answer answer
+ answerable answer
+ answered answer
+ answerest answerest
+ answering answer
+ answers answer
+ ant ant
+ ante ant
+ antenor antenor
+ antenorides antenorid
+ anteroom anteroom
+ anthem anthem
+ anthems anthem
+ anthony anthoni
+ anthropophagi anthropophagi
+ anthropophaginian anthropophaginian
+ antiates antiat
+ antic antic
+ anticipate anticip
+ anticipates anticip
+ anticipatest anticipatest
+ anticipating anticip
+ anticipation anticip
+ antick antick
+ anticly anticli
+ antics antic
+ antidote antidot
+ antidotes antidot
+ antigonus antigonu
+ antiopa antiopa
+ antipathy antipathi
+ antipholus antipholu
+ antipholuses antipholus
+ antipodes antipod
+ antiquary antiquari
+ antique antiqu
+ antiquity antiqu
+ antium antium
+ antoniad antoniad
+ antonio antonio
+ antonius antoniu
+ antony antoni
+ antres antr
+ anvil anvil
+ any ani
+ anybody anybodi
+ anyone anyon
+ anything anyth
+ anywhere anywher
+ ap ap
+ apace apac
+ apart apart
+ apartment apart
+ apartments apart
+ ape ap
+ apemantus apemantu
+ apennines apennin
+ apes ap
+ apiece apiec
+ apish apish
+ apollinem apollinem
+ apollo apollo
+ apollodorus apollodoru
+ apology apolog
+ apoplex apoplex
+ apoplexy apoplexi
+ apostle apostl
+ apostles apostl
+ apostrophas apostropha
+ apoth apoth
+ apothecary apothecari
+ appal appal
+ appall appal
+ appalled appal
+ appals appal
+ apparel apparel
+ apparell apparel
+ apparelled apparel
+ apparent appar
+ apparently appar
+ apparition apparit
+ apparitions apparit
+ appeach appeach
+ appeal appeal
+ appeals appeal
+ appear appear
+ appearance appear
+ appeared appear
+ appeareth appeareth
+ appearing appear
+ appears appear
+ appeas appea
+ appease appeas
+ appeased appeas
+ appelant appel
+ appele appel
+ appelee appele
+ appeles appel
+ appelez appelez
+ appellant appel
+ appellants appel
+ appelons appelon
+ appendix appendix
+ apperil apperil
+ appertain appertain
+ appertaining appertain
+ appertainings appertain
+ appertains appertain
+ appertinent appertin
+ appertinents appertin
+ appetite appetit
+ appetites appetit
+ applaud applaud
+ applauded applaud
+ applauding applaud
+ applause applaus
+ applauses applaus
+ apple appl
+ apples appl
+ appletart appletart
+ appliance applianc
+ appliances applianc
+ applications applic
+ applied appli
+ applies appli
+ apply appli
+ applying appli
+ appoint appoint
+ appointed appoint
+ appointment appoint
+ appointments appoint
+ appoints appoint
+ apprehend apprehend
+ apprehended apprehend
+ apprehends apprehend
+ apprehension apprehens
+ apprehensions apprehens
+ apprehensive apprehens
+ apprendre apprendr
+ apprenne apprenn
+ apprenticehood apprenticehood
+ appris appri
+ approach approach
+ approachers approach
+ approaches approach
+ approacheth approacheth
+ approaching approach
+ approbation approb
+ approof approof
+ appropriation appropri
+ approv approv
+ approve approv
+ approved approv
+ approvers approv
+ approves approv
+ appurtenance appurten
+ appurtenances appurten
+ apricocks apricock
+ april april
+ apron apron
+ aprons apron
+ apt apt
+ apter apter
+ aptest aptest
+ aptly aptli
+ aptness apt
+ aqua aqua
+ aquilon aquilon
+ aquitaine aquitain
+ arabia arabia
+ arabian arabian
+ araise arais
+ arbitrate arbitr
+ arbitrating arbitr
+ arbitrator arbitr
+ arbitrement arbitr
+ arbors arbor
+ arbour arbour
+ arc arc
+ arch arch
+ archbishop archbishop
+ archbishopric archbishopr
+ archdeacon archdeacon
+ arched arch
+ archelaus archelau
+ archer archer
+ archers archer
+ archery archeri
+ archibald archibald
+ archidamus archidamu
+ architect architect
+ arcu arcu
+ arde ard
+ arden arden
+ ardent ardent
+ ardour ardour
+ are ar
+ argal argal
+ argier argier
+ argo argo
+ argosies argosi
+ argosy argosi
+ argu argu
+ argue argu
+ argued argu
+ argues argu
+ arguing argu
+ argument argument
+ arguments argument
+ argus argu
+ ariachne ariachn
+ ariadne ariadn
+ ariel ariel
+ aries ari
+ aright aright
+ arinado arinado
+ arinies arini
+ arion arion
+ arise aris
+ arises aris
+ ariseth ariseth
+ arising aris
+ aristode aristod
+ aristotle aristotl
+ arithmetic arithmet
+ arithmetician arithmetician
+ ark ark
+ arm arm
+ arma arma
+ armado armado
+ armadoes armado
+ armagnac armagnac
+ arme arm
+ armed arm
+ armenia armenia
+ armies armi
+ armigero armigero
+ arming arm
+ armipotent armipot
+ armor armor
+ armour armour
+ armourer armour
+ armourers armour
+ armours armour
+ armoury armouri
+ arms arm
+ army armi
+ arn arn
+ aroint aroint
+ arose aros
+ arouse arous
+ aroused arous
+ arragon arragon
+ arraign arraign
+ arraigned arraign
+ arraigning arraign
+ arraignment arraign
+ arrant arrant
+ arras arra
+ array arrai
+ arrearages arrearag
+ arrest arrest
+ arrested arrest
+ arrests arrest
+ arriv arriv
+ arrival arriv
+ arrivance arriv
+ arrive arriv
+ arrived arriv
+ arrives arriv
+ arriving arriv
+ arrogance arrog
+ arrogancy arrog
+ arrogant arrog
+ arrow arrow
+ arrows arrow
+ art art
+ artemidorus artemidoru
+ arteries arteri
+ arthur arthur
+ article articl
+ articles articl
+ articulate articul
+ artificer artific
+ artificial artifici
+ artillery artilleri
+ artire artir
+ artist artist
+ artists artist
+ artless artless
+ artois artoi
+ arts art
+ artus artu
+ arviragus arviragu
+ as as
+ asaph asaph
+ ascanius ascaniu
+ ascend ascend
+ ascended ascend
+ ascendeth ascendeth
+ ascends ascend
+ ascension ascens
+ ascent ascent
+ ascribe ascrib
+ ascribes ascrib
+ ash ash
+ asham asham
+ ashamed asham
+ asher asher
+ ashes ash
+ ashford ashford
+ ashore ashor
+ ashouting ashout
+ ashy ashi
+ asia asia
+ aside asid
+ ask ask
+ askance askanc
+ asked ask
+ asker asker
+ asketh asketh
+ asking ask
+ asks ask
+ aslant aslant
+ asleep asleep
+ asmath asmath
+ asp asp
+ aspect aspect
+ aspects aspect
+ aspen aspen
+ aspersion aspers
+ aspic aspic
+ aspicious aspici
+ aspics aspic
+ aspir aspir
+ aspiration aspir
+ aspire aspir
+ aspiring aspir
+ asquint asquint
+ ass ass
+ assail assail
+ assailable assail
+ assailant assail
+ assailants assail
+ assailed assail
+ assaileth assaileth
+ assailing assail
+ assails assail
+ assassination assassin
+ assault assault
+ assaulted assault
+ assaults assault
+ assay assai
+ assaying assai
+ assays assai
+ assemblance assembl
+ assemble assembl
+ assembled assembl
+ assemblies assembl
+ assembly assembl
+ assent assent
+ asses ass
+ assez assez
+ assign assign
+ assigned assign
+ assigns assign
+ assinico assinico
+ assist assist
+ assistance assist
+ assistances assist
+ assistant assist
+ assistants assist
+ assisted assist
+ assisting assist
+ associate associ
+ associated associ
+ associates associ
+ assuage assuag
+ assubjugate assubjug
+ assum assum
+ assume assum
+ assumes assum
+ assumption assumpt
+ assur assur
+ assurance assur
+ assure assur
+ assured assur
+ assuredly assuredli
+ assures assur
+ assyrian assyrian
+ astonish astonish
+ astonished astonish
+ astraea astraea
+ astray astrai
+ astrea astrea
+ astronomer astronom
+ astronomers astronom
+ astronomical astronom
+ astronomy astronomi
+ asunder asund
+ at at
+ atalanta atalanta
+ ate at
+ ates at
+ athenian athenian
+ athenians athenian
+ athens athen
+ athol athol
+ athversary athversari
+ athwart athwart
+ atlas atla
+ atomies atomi
+ atomy atomi
+ atone aton
+ atonement aton
+ atonements aton
+ atropos atropo
+ attach attach
+ attached attach
+ attachment attach
+ attain attain
+ attainder attaind
+ attains attain
+ attaint attaint
+ attainted attaint
+ attainture attaintur
+ attempt attempt
+ attemptable attempt
+ attempted attempt
+ attempting attempt
+ attempts attempt
+ attend attend
+ attendance attend
+ attendant attend
+ attendants attend
+ attended attend
+ attendents attend
+ attendeth attendeth
+ attending attend
+ attends attend
+ attent attent
+ attention attent
+ attentive attent
+ attentivenes attentiven
+ attest attest
+ attested attest
+ attir attir
+ attire attir
+ attired attir
+ attires attir
+ attorney attornei
+ attorneyed attornei
+ attorneys attornei
+ attorneyship attorneyship
+ attract attract
+ attraction attract
+ attractive attract
+ attracts attract
+ attribute attribut
+ attributed attribut
+ attributes attribut
+ attribution attribut
+ attributive attribut
+ atwain atwain
+ au au
+ aubrey aubrei
+ auburn auburn
+ aucun aucun
+ audacious audaci
+ audaciously audaci
+ audacity audac
+ audible audibl
+ audience audienc
+ audis audi
+ audit audit
+ auditor auditor
+ auditors auditor
+ auditory auditori
+ audre audr
+ audrey audrei
+ aufidius aufidiu
+ aufidiuses aufidius
+ auger auger
+ aught aught
+ augment augment
+ augmentation augment
+ augmented augment
+ augmenting augment
+ augurer augur
+ augurers augur
+ augures augur
+ auguring augur
+ augurs augur
+ augury auguri
+ august august
+ augustus augustu
+ auld auld
+ aumerle aumerl
+ aunchient aunchient
+ aunt aunt
+ aunts aunt
+ auricular auricular
+ aurora aurora
+ auspicious auspici
+ aussi aussi
+ austere auster
+ austerely auster
+ austereness auster
+ austerity auster
+ austria austria
+ aut aut
+ authentic authent
+ author author
+ authorities author
+ authority author
+ authorized author
+ authorizing author
+ authors author
+ autolycus autolycu
+ autre autr
+ autumn autumn
+ auvergne auvergn
+ avail avail
+ avails avail
+ avarice avaric
+ avaricious avarici
+ avaunt avaunt
+ ave av
+ aveng aveng
+ avenge aveng
+ avenged aveng
+ averring aver
+ avert avert
+ aves av
+ avez avez
+ avis avi
+ avoid avoid
+ avoided avoid
+ avoiding avoid
+ avoids avoid
+ avoirdupois avoirdupoi
+ avouch avouch
+ avouched avouch
+ avouches avouch
+ avouchment avouch
+ avow avow
+ aw aw
+ await await
+ awaits await
+ awak awak
+ awake awak
+ awaked awak
+ awaken awaken
+ awakened awaken
+ awakens awaken
+ awakes awak
+ awaking awak
+ award award
+ awards award
+ awasy awasi
+ away awai
+ awe aw
+ aweary aweari
+ aweless aweless
+ awful aw
+ awhile awhil
+ awkward awkward
+ awl awl
+ awooing awoo
+ awork awork
+ awry awri
+ axe ax
+ axle axl
+ axletree axletre
+ ay ay
+ aye ay
+ ayez ayez
+ ayli ayli
+ azur azur
+ azure azur
+ b b
+ ba ba
+ baa baa
+ babbl babbl
+ babble babbl
+ babbling babbl
+ babe babe
+ babes babe
+ babies babi
+ baboon baboon
+ baboons baboon
+ baby babi
+ babylon babylon
+ bacare bacar
+ bacchanals bacchan
+ bacchus bacchu
+ bach bach
+ bachelor bachelor
+ bachelors bachelor
+ back back
+ backbite backbit
+ backbitten backbitten
+ backing back
+ backs back
+ backward backward
+ backwardly backwardli
+ backwards backward
+ bacon bacon
+ bacons bacon
+ bad bad
+ bade bade
+ badge badg
+ badged badg
+ badges badg
+ badly badli
+ badness bad
+ baes bae
+ baffl baffl
+ baffle baffl
+ baffled baffl
+ bag bag
+ baggage baggag
+ bagot bagot
+ bagpipe bagpip
+ bags bag
+ bail bail
+ bailiff bailiff
+ baillez baillez
+ baily baili
+ baisant baisant
+ baisees baise
+ baiser baiser
+ bait bait
+ baited bait
+ baiting bait
+ baitings bait
+ baits bait
+ bajazet bajazet
+ bak bak
+ bake bake
+ baked bake
+ baker baker
+ bakers baker
+ bakes bake
+ baking bake
+ bal bal
+ balanc balanc
+ balance balanc
+ balcony balconi
+ bald bald
+ baldrick baldrick
+ bale bale
+ baleful bale
+ balk balk
+ ball ball
+ ballad ballad
+ ballads ballad
+ ballast ballast
+ ballasting ballast
+ ballet ballet
+ ballow ballow
+ balls ball
+ balm balm
+ balms balm
+ balmy balmi
+ balsam balsam
+ balsamum balsamum
+ balth balth
+ balthasar balthasar
+ balthazar balthazar
+ bames bame
+ ban ban
+ banbury banburi
+ band band
+ bandied bandi
+ banding band
+ bandit bandit
+ banditti banditti
+ banditto banditto
+ bands band
+ bandy bandi
+ bandying bandi
+ bane bane
+ banes bane
+ bang bang
+ bangor bangor
+ banish banish
+ banished banish
+ banishers banish
+ banishment banish
+ banister banist
+ bank bank
+ bankrout bankrout
+ bankrupt bankrupt
+ bankrupts bankrupt
+ banks bank
+ banner banner
+ bannerets banneret
+ banners banner
+ banning ban
+ banns bann
+ banquet banquet
+ banqueted banquet
+ banqueting banquet
+ banquets banquet
+ banquo banquo
+ bans ban
+ baptism baptism
+ baptista baptista
+ baptiz baptiz
+ bar bar
+ barbarian barbarian
+ barbarians barbarian
+ barbarism barbar
+ barbarous barbar
+ barbary barbari
+ barbason barbason
+ barbed barb
+ barber barber
+ barbermonger barbermong
+ bard bard
+ bardolph bardolph
+ bards bard
+ bare bare
+ bared bare
+ barefac barefac
+ barefaced barefac
+ barefoot barefoot
+ bareheaded barehead
+ barely bare
+ bareness bare
+ barful bar
+ bargain bargain
+ bargains bargain
+ barge barg
+ bargulus bargulu
+ baring bare
+ bark bark
+ barking bark
+ barkloughly barkloughli
+ barks bark
+ barky barki
+ barley barlei
+ barm barm
+ barn barn
+ barnacles barnacl
+ barnardine barnardin
+ barne barn
+ barnes barn
+ barnet barnet
+ barns barn
+ baron baron
+ barons baron
+ barony baroni
+ barr barr
+ barrabas barraba
+ barrel barrel
+ barrels barrel
+ barren barren
+ barrenly barrenli
+ barrenness barren
+ barricado barricado
+ barricadoes barricado
+ barrow barrow
+ bars bar
+ barson barson
+ barter barter
+ bartholomew bartholomew
+ bas ba
+ basan basan
+ base base
+ baseless baseless
+ basely base
+ baseness base
+ baser baser
+ bases base
+ basest basest
+ bashful bash
+ bashfulness bash
+ basilisco basilisco
+ basilisk basilisk
+ basilisks basilisk
+ basimecu basimecu
+ basin basin
+ basingstoke basingstok
+ basins basin
+ basis basi
+ bask bask
+ basket basket
+ baskets basket
+ bass bass
+ bassanio bassanio
+ basset basset
+ bassianus bassianu
+ basta basta
+ bastard bastard
+ bastardizing bastard
+ bastardly bastardli
+ bastards bastard
+ bastardy bastardi
+ basted bast
+ bastes bast
+ bastinado bastinado
+ basting bast
+ bat bat
+ batailles batail
+ batch batch
+ bate bate
+ bated bate
+ bates bate
+ bath bath
+ bathe bath
+ bathed bath
+ bathing bath
+ baths bath
+ bating bate
+ batler batler
+ bats bat
+ batt batt
+ battalia battalia
+ battalions battalion
+ batten batten
+ batter batter
+ battering batter
+ batters batter
+ battery batteri
+ battle battl
+ battled battl
+ battlefield battlefield
+ battlements battlement
+ battles battl
+ batty batti
+ bauble baubl
+ baubles baubl
+ baubling baubl
+ baulk baulk
+ bavin bavin
+ bawcock bawcock
+ bawd bawd
+ bawdry bawdri
+ bawds bawd
+ bawdy bawdi
+ bawl bawl
+ bawling bawl
+ bay bai
+ baying bai
+ baynard baynard
+ bayonne bayonn
+ bays bai
+ be be
+ beach beach
+ beached beach
+ beachy beachi
+ beacon beacon
+ bead bead
+ beaded bead
+ beadle beadl
+ beadles beadl
+ beads bead
+ beadsmen beadsmen
+ beagle beagl
+ beagles beagl
+ beak beak
+ beaks beak
+ beam beam
+ beamed beam
+ beams beam
+ bean bean
+ beans bean
+ bear bear
+ beard beard
+ bearded beard
+ beardless beardless
+ beards beard
+ bearer bearer
+ bearers bearer
+ bearest bearest
+ beareth beareth
+ bearing bear
+ bears bear
+ beast beast
+ beastliest beastliest
+ beastliness beastli
+ beastly beastli
+ beasts beast
+ beat beat
+ beated beat
+ beaten beaten
+ beating beat
+ beatrice beatric
+ beats beat
+ beau beau
+ beaufort beaufort
+ beaumond beaumond
+ beaumont beaumont
+ beauteous beauteou
+ beautied beauti
+ beauties beauti
+ beautified beautifi
+ beautiful beauti
+ beautify beautifi
+ beauty beauti
+ beaver beaver
+ beavers beaver
+ became becam
+ because becaus
+ bechanc bechanc
+ bechance bechanc
+ bechanced bechanc
+ beck beck
+ beckon beckon
+ beckons beckon
+ becks beck
+ becom becom
+ become becom
+ becomed becom
+ becomes becom
+ becoming becom
+ becomings becom
+ bed bed
+ bedabbled bedabbl
+ bedash bedash
+ bedaub bedaub
+ bedazzled bedazzl
+ bedchamber bedchamb
+ bedclothes bedcloth
+ bedded bed
+ bedeck bedeck
+ bedecking bedeck
+ bedew bedew
+ bedfellow bedfellow
+ bedfellows bedfellow
+ bedford bedford
+ bedlam bedlam
+ bedrench bedrench
+ bedrid bedrid
+ beds bed
+ bedtime bedtim
+ bedward bedward
+ bee bee
+ beef beef
+ beefs beef
+ beehives beehiv
+ been been
+ beer beer
+ bees bee
+ beest beest
+ beetle beetl
+ beetles beetl
+ beeves beev
+ befall befal
+ befallen befallen
+ befalls befal
+ befell befel
+ befits befit
+ befitted befit
+ befitting befit
+ befor befor
+ before befor
+ beforehand beforehand
+ befortune befortun
+ befriend befriend
+ befriended befriend
+ befriends befriend
+ beg beg
+ began began
+ beget beget
+ begets beget
+ begetting beget
+ begg begg
+ beggar beggar
+ beggared beggar
+ beggarly beggarli
+ beggarman beggarman
+ beggars beggar
+ beggary beggari
+ begging beg
+ begin begin
+ beginners beginn
+ beginning begin
+ beginnings begin
+ begins begin
+ begnawn begnawn
+ begone begon
+ begot begot
+ begotten begotten
+ begrimed begrim
+ begs beg
+ beguil beguil
+ beguile beguil
+ beguiled beguil
+ beguiles beguil
+ beguiling beguil
+ begun begun
+ behalf behalf
+ behalfs behalf
+ behav behav
+ behaved behav
+ behavedst behavedst
+ behavior behavior
+ behaviors behavior
+ behaviour behaviour
+ behaviours behaviour
+ behead behead
+ beheaded behead
+ beheld beheld
+ behest behest
+ behests behest
+ behind behind
+ behold behold
+ beholder behold
+ beholders behold
+ beholdest beholdest
+ beholding behold
+ beholds behold
+ behoof behoof
+ behooffull behoofful
+ behooves behoov
+ behove behov
+ behoves behov
+ behowls behowl
+ being be
+ bel bel
+ belarius belariu
+ belch belch
+ belching belch
+ beldam beldam
+ beldame beldam
+ beldams beldam
+ belee bele
+ belgia belgia
+ belie beli
+ belied beli
+ belief belief
+ beliest beliest
+ believ believ
+ believe believ
+ believed believ
+ believes believ
+ believest believest
+ believing believ
+ belike belik
+ bell bell
+ bellario bellario
+ belle bell
+ bellied belli
+ bellies belli
+ bellman bellman
+ bellona bellona
+ bellow bellow
+ bellowed bellow
+ bellowing bellow
+ bellows bellow
+ bells bell
+ belly belli
+ bellyful belly
+ belman belman
+ belmont belmont
+ belock belock
+ belong belong
+ belonging belong
+ belongings belong
+ belongs belong
+ belov belov
+ beloved belov
+ beloving belov
+ below below
+ belt belt
+ belzebub belzebub
+ bemadding bemad
+ bemet bemet
+ bemete bemet
+ bemoan bemoan
+ bemoaned bemoan
+ bemock bemock
+ bemoil bemoil
+ bemonster bemonst
+ ben ben
+ bench bench
+ bencher bencher
+ benches bench
+ bend bend
+ bended bend
+ bending bend
+ bends bend
+ bene bene
+ beneath beneath
+ benedicite benedicit
+ benedick benedick
+ benediction benedict
+ benedictus benedictu
+ benefactors benefactor
+ benefice benefic
+ beneficial benefici
+ benefit benefit
+ benefited benefit
+ benefits benefit
+ benetted benet
+ benevolence benevol
+ benevolences benevol
+ benied beni
+ benison benison
+ bennet bennet
+ bent bent
+ bentii bentii
+ bentivolii bentivolii
+ bents bent
+ benumbed benumb
+ benvolio benvolio
+ bepaint bepaint
+ bepray beprai
+ bequeath bequeath
+ bequeathed bequeath
+ bequeathing bequeath
+ bequest bequest
+ ber ber
+ berard berard
+ berattle berattl
+ beray berai
+ bere bere
+ bereave bereav
+ bereaved bereav
+ bereaves bereav
+ bereft bereft
+ bergamo bergamo
+ bergomask bergomask
+ berhym berhym
+ berhyme berhym
+ berkeley berkelei
+ bermoothes bermooth
+ bernardo bernardo
+ berod berod
+ berowne berown
+ berri berri
+ berries berri
+ berrord berrord
+ berry berri
+ bertram bertram
+ berwick berwick
+ bescreen bescreen
+ beseech beseech
+ beseeched beseech
+ beseechers beseech
+ beseeching beseech
+ beseek beseek
+ beseem beseem
+ beseemeth beseemeth
+ beseeming beseem
+ beseems beseem
+ beset beset
+ beshrew beshrew
+ beside besid
+ besides besid
+ besieg besieg
+ besiege besieg
+ besieged besieg
+ beslubber beslubb
+ besmear besmear
+ besmeared besmear
+ besmirch besmirch
+ besom besom
+ besort besort
+ besotted besot
+ bespake bespak
+ bespeak bespeak
+ bespice bespic
+ bespoke bespok
+ bespotted bespot
+ bess bess
+ bessy bessi
+ best best
+ bestained bestain
+ bested best
+ bestial bestial
+ bestir bestir
+ bestirr bestirr
+ bestow bestow
+ bestowed bestow
+ bestowing bestow
+ bestows bestow
+ bestraught bestraught
+ bestrew bestrew
+ bestrid bestrid
+ bestride bestrid
+ bestrides bestrid
+ bet bet
+ betake betak
+ beteem beteem
+ bethink bethink
+ bethought bethought
+ bethrothed bethroth
+ bethump bethump
+ betid betid
+ betide betid
+ betideth betideth
+ betime betim
+ betimes betim
+ betoken betoken
+ betook betook
+ betossed betoss
+ betray betrai
+ betrayed betrai
+ betraying betrai
+ betrays betrai
+ betrims betrim
+ betroth betroth
+ betrothed betroth
+ betroths betroth
+ bett bett
+ betted bet
+ better better
+ bettered better
+ bettering better
+ betters better
+ betting bet
+ bettre bettr
+ between between
+ betwixt betwixt
+ bevel bevel
+ beverage beverag
+ bevis bevi
+ bevy bevi
+ bewail bewail
+ bewailed bewail
+ bewailing bewail
+ bewails bewail
+ beware bewar
+ bewasted bewast
+ beweep beweep
+ bewept bewept
+ bewet bewet
+ bewhored bewhor
+ bewitch bewitch
+ bewitched bewitch
+ bewitchment bewitch
+ bewray bewrai
+ beyond beyond
+ bezonian bezonian
+ bezonians bezonian
+ bianca bianca
+ bianco bianco
+ bias bia
+ bibble bibbl
+ bickerings bicker
+ bid bid
+ bidden bidden
+ bidding bid
+ biddings bid
+ biddy biddi
+ bide bide
+ bides bide
+ biding bide
+ bids bid
+ bien bien
+ bier bier
+ bifold bifold
+ big big
+ bigamy bigami
+ biggen biggen
+ bigger bigger
+ bigness big
+ bigot bigot
+ bilberry bilberri
+ bilbo bilbo
+ bilboes bilbo
+ bilbow bilbow
+ bill bill
+ billeted billet
+ billets billet
+ billiards billiard
+ billing bill
+ billow billow
+ billows billow
+ bills bill
+ bin bin
+ bind bind
+ bindeth bindeth
+ binding bind
+ binds bind
+ biondello biondello
+ birch birch
+ bird bird
+ birding bird
+ birdlime birdlim
+ birds bird
+ birnam birnam
+ birth birth
+ birthday birthdai
+ birthdom birthdom
+ birthplace birthplac
+ birthright birthright
+ birthrights birthright
+ births birth
+ bis bi
+ biscuit biscuit
+ bishop bishop
+ bishops bishop
+ bisson bisson
+ bit bit
+ bitch bitch
+ bite bite
+ biter biter
+ bites bite
+ biting bite
+ bits bit
+ bitt bitt
+ bitten bitten
+ bitter bitter
+ bitterest bitterest
+ bitterly bitterli
+ bitterness bitter
+ blab blab
+ blabb blabb
+ blabbing blab
+ blabs blab
+ black black
+ blackamoor blackamoor
+ blackamoors blackamoor
+ blackberries blackberri
+ blackberry blackberri
+ blacker blacker
+ blackest blackest
+ blackfriars blackfriar
+ blackheath blackheath
+ blackmere blackmer
+ blackness black
+ blacks black
+ bladder bladder
+ bladders bladder
+ blade blade
+ bladed blade
+ blades blade
+ blains blain
+ blam blam
+ blame blame
+ blamed blame
+ blameful blame
+ blameless blameless
+ blames blame
+ blanc blanc
+ blanca blanca
+ blanch blanch
+ blank blank
+ blanket blanket
+ blanks blank
+ blaspheme blasphem
+ blaspheming blasphem
+ blasphemous blasphem
+ blasphemy blasphemi
+ blast blast
+ blasted blast
+ blasting blast
+ blastments blastment
+ blasts blast
+ blaz blaz
+ blaze blaze
+ blazes blaze
+ blazing blaze
+ blazon blazon
+ blazoned blazon
+ blazoning blazon
+ bleach bleach
+ bleaching bleach
+ bleak bleak
+ blear blear
+ bleared blear
+ bleat bleat
+ bleated bleat
+ bleats bleat
+ bled bled
+ bleed bleed
+ bleedest bleedest
+ bleedeth bleedeth
+ bleeding bleed
+ bleeds bleed
+ blemish blemish
+ blemishes blemish
+ blench blench
+ blenches blench
+ blend blend
+ blended blend
+ blent blent
+ bless bless
+ blessed bless
+ blessedly blessedli
+ blessedness blessed
+ blesses bless
+ blesseth blesseth
+ blessing bless
+ blessings bless
+ blest blest
+ blew blew
+ blind blind
+ blinded blind
+ blindfold blindfold
+ blinding blind
+ blindly blindli
+ blindness blind
+ blinds blind
+ blink blink
+ blinking blink
+ bliss bliss
+ blist blist
+ blister blister
+ blisters blister
+ blithe blith
+ blithild blithild
+ bloat bloat
+ block block
+ blockish blockish
+ blocks block
+ blois bloi
+ blood blood
+ blooded blood
+ bloodhound bloodhound
+ bloodied bloodi
+ bloodier bloodier
+ bloodiest bloodiest
+ bloodily bloodili
+ bloodless bloodless
+ bloods blood
+ bloodshed bloodsh
+ bloodshedding bloodshed
+ bloodstained bloodstain
+ bloody bloodi
+ bloom bloom
+ blooms bloom
+ blossom blossom
+ blossoming blossom
+ blossoms blossom
+ blot blot
+ blots blot
+ blotted blot
+ blotting blot
+ blount blount
+ blow blow
+ blowed blow
+ blowers blower
+ blowest blowest
+ blowing blow
+ blown blown
+ blows blow
+ blowse blows
+ blubb blubb
+ blubber blubber
+ blubbering blubber
+ blue blue
+ bluecaps bluecap
+ bluest bluest
+ blunt blunt
+ blunted blunt
+ blunter blunter
+ bluntest bluntest
+ blunting blunt
+ bluntly bluntli
+ bluntness blunt
+ blunts blunt
+ blur blur
+ blurr blurr
+ blurs blur
+ blush blush
+ blushes blush
+ blushest blushest
+ blushing blush
+ blust blust
+ bluster bluster
+ blusterer bluster
+ blusters bluster
+ bo bo
+ boar boar
+ board board
+ boarded board
+ boarding board
+ boards board
+ boarish boarish
+ boars boar
+ boast boast
+ boasted boast
+ boastful boast
+ boasting boast
+ boasts boast
+ boat boat
+ boats boat
+ boatswain boatswain
+ bob bob
+ bobb bobb
+ boblibindo boblibindo
+ bobtail bobtail
+ bocchus bocchu
+ bode bode
+ boded bode
+ bodements bodement
+ bodes bode
+ bodg bodg
+ bodied bodi
+ bodies bodi
+ bodiless bodiless
+ bodily bodili
+ boding bode
+ bodkin bodkin
+ body bodi
+ bodykins bodykin
+ bog bog
+ boggle boggl
+ boggler boggler
+ bogs bog
+ bohemia bohemia
+ bohemian bohemian
+ bohun bohun
+ boil boil
+ boiling boil
+ boils boil
+ boist boist
+ boisterous boister
+ boisterously boister
+ boitier boitier
+ bold bold
+ bolden bolden
+ bolder bolder
+ boldest boldest
+ boldly boldli
+ boldness bold
+ bolds bold
+ bolingbroke bolingbrok
+ bolster bolster
+ bolt bolt
+ bolted bolt
+ bolter bolter
+ bolters bolter
+ bolting bolt
+ bolts bolt
+ bombard bombard
+ bombards bombard
+ bombast bombast
+ bon bon
+ bona bona
+ bond bond
+ bondage bondag
+ bonded bond
+ bondmaid bondmaid
+ bondman bondman
+ bondmen bondmen
+ bonds bond
+ bondslave bondslav
+ bone bone
+ boneless boneless
+ bones bone
+ bonfire bonfir
+ bonfires bonfir
+ bonjour bonjour
+ bonne bonn
+ bonnet bonnet
+ bonneted bonnet
+ bonny bonni
+ bonos bono
+ bonto bonto
+ bonville bonvil
+ bood bood
+ book book
+ bookish bookish
+ books book
+ boon boon
+ boor boor
+ boorish boorish
+ boors boor
+ boot boot
+ booted boot
+ booties booti
+ bootless bootless
+ boots boot
+ booty booti
+ bor bor
+ bora bora
+ borachio borachio
+ bordeaux bordeaux
+ border border
+ bordered border
+ borderers border
+ borders border
+ bore bore
+ boreas borea
+ bores bore
+ boring bore
+ born born
+ borne born
+ borough borough
+ boroughs borough
+ borrow borrow
+ borrowed borrow
+ borrower borrow
+ borrowing borrow
+ borrows borrow
+ bosko bosko
+ boskos bosko
+ bosky boski
+ bosom bosom
+ bosoms bosom
+ boson boson
+ boss boss
+ bosworth bosworth
+ botch botch
+ botcher botcher
+ botches botch
+ botchy botchi
+ both both
+ bots bot
+ bottle bottl
+ bottled bottl
+ bottles bottl
+ bottom bottom
+ bottomless bottomless
+ bottoms bottom
+ bouciqualt bouciqualt
+ bouge boug
+ bough bough
+ boughs bough
+ bought bought
+ bounce bounc
+ bouncing bounc
+ bound bound
+ bounded bound
+ bounden bounden
+ boundeth boundeth
+ bounding bound
+ boundless boundless
+ bounds bound
+ bounteous bounteou
+ bounteously bounteous
+ bounties bounti
+ bountiful bounti
+ bountifully bountifulli
+ bounty bounti
+ bourbier bourbier
+ bourbon bourbon
+ bourchier bourchier
+ bourdeaux bourdeaux
+ bourn bourn
+ bout bout
+ bouts bout
+ bove bove
+ bow bow
+ bowcase bowcas
+ bowed bow
+ bowels bowel
+ bower bower
+ bowing bow
+ bowl bowl
+ bowler bowler
+ bowling bowl
+ bowls bowl
+ bows bow
+ bowsprit bowsprit
+ bowstring bowstr
+ box box
+ boxes box
+ boy boi
+ boyet boyet
+ boyish boyish
+ boys boi
+ brabant brabant
+ brabantio brabantio
+ brabble brabbl
+ brabbler brabbler
+ brac brac
+ brace brace
+ bracelet bracelet
+ bracelets bracelet
+ brach brach
+ bracy braci
+ brag brag
+ bragg bragg
+ braggardism braggard
+ braggards braggard
+ braggart braggart
+ braggarts braggart
+ bragged brag
+ bragging brag
+ bragless bragless
+ brags brag
+ braid braid
+ braided braid
+ brain brain
+ brained brain
+ brainford brainford
+ brainish brainish
+ brainless brainless
+ brains brain
+ brainsick brainsick
+ brainsickly brainsickli
+ brake brake
+ brakenbury brakenburi
+ brakes brake
+ brambles brambl
+ bran bran
+ branch branch
+ branches branch
+ branchless branchless
+ brand brand
+ branded brand
+ brandish brandish
+ brandon brandon
+ brands brand
+ bras bra
+ brass brass
+ brassy brassi
+ brat brat
+ brats brat
+ brav brav
+ brave brave
+ braved brave
+ bravely brave
+ braver braver
+ bravery braveri
+ braves brave
+ bravest bravest
+ braving brave
+ brawl brawl
+ brawler brawler
+ brawling brawl
+ brawls brawl
+ brawn brawn
+ brawns brawn
+ bray brai
+ braying brai
+ braz braz
+ brazen brazen
+ brazier brazier
+ breach breach
+ breaches breach
+ bread bread
+ breadth breadth
+ break break
+ breaker breaker
+ breakfast breakfast
+ breaking break
+ breaks break
+ breast breast
+ breasted breast
+ breasting breast
+ breastplate breastplat
+ breasts breast
+ breath breath
+ breathe breath
+ breathed breath
+ breather breather
+ breathers breather
+ breathes breath
+ breathest breathest
+ breathing breath
+ breathless breathless
+ breaths breath
+ brecknock brecknock
+ bred bred
+ breech breech
+ breeches breech
+ breeching breech
+ breed breed
+ breeder breeder
+ breeders breeder
+ breeding breed
+ breeds breed
+ breese brees
+ breeze breez
+ breff breff
+ bretagne bretagn
+ brethen brethen
+ bretheren bretheren
+ brethren brethren
+ brevis brevi
+ brevity breviti
+ brew brew
+ brewage brewag
+ brewer brewer
+ brewers brewer
+ brewing brew
+ brews brew
+ briareus briareu
+ briars briar
+ brib brib
+ bribe bribe
+ briber briber
+ bribes bribe
+ brick brick
+ bricklayer bricklay
+ bricks brick
+ bridal bridal
+ bride bride
+ bridegroom bridegroom
+ bridegrooms bridegroom
+ brides bride
+ bridge bridg
+ bridgenorth bridgenorth
+ bridges bridg
+ bridget bridget
+ bridle bridl
+ bridled bridl
+ brief brief
+ briefer briefer
+ briefest briefest
+ briefly briefli
+ briefness brief
+ brier brier
+ briers brier
+ brigandine brigandin
+ bright bright
+ brighten brighten
+ brightest brightest
+ brightly brightli
+ brightness bright
+ brim brim
+ brimful brim
+ brims brim
+ brimstone brimston
+ brinded brind
+ brine brine
+ bring bring
+ bringer bringer
+ bringeth bringeth
+ bringing bring
+ bringings bring
+ brings bring
+ brinish brinish
+ brink brink
+ brisk brisk
+ brisky briski
+ bristle bristl
+ bristled bristl
+ bristly bristli
+ bristol bristol
+ bristow bristow
+ britain britain
+ britaine britain
+ britaines britain
+ british british
+ briton briton
+ britons briton
+ brittany brittani
+ brittle brittl
+ broach broach
+ broached broach
+ broad broad
+ broader broader
+ broadsides broadsid
+ brocas broca
+ brock brock
+ brogues brogu
+ broil broil
+ broiling broil
+ broils broil
+ broke broke
+ broken broken
+ brokenly brokenli
+ broker broker
+ brokers broker
+ brokes broke
+ broking broke
+ brooch brooch
+ brooches brooch
+ brood brood
+ brooded brood
+ brooding brood
+ brook brook
+ brooks brook
+ broom broom
+ broomstaff broomstaff
+ broth broth
+ brothel brothel
+ brother brother
+ brotherhood brotherhood
+ brotherhoods brotherhood
+ brotherly brotherli
+ brothers brother
+ broths broth
+ brought brought
+ brow brow
+ brown brown
+ browner browner
+ brownist brownist
+ browny browni
+ brows brow
+ browse brows
+ browsing brows
+ bruis brui
+ bruise bruis
+ bruised bruis
+ bruises bruis
+ bruising bruis
+ bruit bruit
+ bruited bruit
+ brundusium brundusium
+ brunt brunt
+ brush brush
+ brushes brush
+ brute brute
+ brutish brutish
+ brutus brutu
+ bubble bubbl
+ bubbles bubbl
+ bubbling bubbl
+ bubukles bubukl
+ buck buck
+ bucket bucket
+ buckets bucket
+ bucking buck
+ buckingham buckingham
+ buckle buckl
+ buckled buckl
+ buckler buckler
+ bucklers buckler
+ bucklersbury bucklersburi
+ buckles buckl
+ buckram buckram
+ bucks buck
+ bud bud
+ budded bud
+ budding bud
+ budge budg
+ budger budger
+ budget budget
+ buds bud
+ buff buff
+ buffet buffet
+ buffeting buffet
+ buffets buffet
+ bug bug
+ bugbear bugbear
+ bugle bugl
+ bugs bug
+ build build
+ builded build
+ buildeth buildeth
+ building build
+ buildings build
+ builds build
+ built built
+ bulk bulk
+ bulks bulk
+ bull bull
+ bullcalf bullcalf
+ bullen bullen
+ bullens bullen
+ bullet bullet
+ bullets bullet
+ bullocks bullock
+ bulls bull
+ bully bulli
+ bulmer bulmer
+ bulwark bulwark
+ bulwarks bulwark
+ bum bum
+ bumbast bumbast
+ bump bump
+ bumper bumper
+ bums bum
+ bunch bunch
+ bunches bunch
+ bundle bundl
+ bung bung
+ bunghole bunghol
+ bungle bungl
+ bunting bunt
+ buoy buoi
+ bur bur
+ burbolt burbolt
+ burd burd
+ burden burden
+ burdened burden
+ burdening burden
+ burdenous burden
+ burdens burden
+ burgh burgh
+ burgher burgher
+ burghers burgher
+ burglary burglari
+ burgomasters burgomast
+ burgonet burgonet
+ burgundy burgundi
+ burial burial
+ buried buri
+ burier burier
+ buriest buriest
+ burly burli
+ burn burn
+ burned burn
+ burnet burnet
+ burneth burneth
+ burning burn
+ burnish burnish
+ burns burn
+ burnt burnt
+ burr burr
+ burrows burrow
+ burs bur
+ burst burst
+ bursting burst
+ bursts burst
+ burthen burthen
+ burthens burthen
+ burton burton
+ bury buri
+ burying buri
+ bush bush
+ bushels bushel
+ bushes bush
+ bushy bushi
+ busied busi
+ busily busili
+ busines busin
+ business busi
+ businesses busi
+ buskin buskin
+ busky buski
+ buss buss
+ busses buss
+ bussing buss
+ bustle bustl
+ bustling bustl
+ busy busi
+ but but
+ butcheed butche
+ butcher butcher
+ butchered butcher
+ butcheries butcheri
+ butcherly butcherli
+ butchers butcher
+ butchery butcheri
+ butler butler
+ butt butt
+ butter butter
+ buttered butter
+ butterflies butterfli
+ butterfly butterfli
+ butterwoman butterwoman
+ buttery butteri
+ buttock buttock
+ buttocks buttock
+ button button
+ buttonhole buttonhol
+ buttons button
+ buttress buttress
+ buttry buttri
+ butts butt
+ buxom buxom
+ buy bui
+ buyer buyer
+ buying bui
+ buys bui
+ buzz buzz
+ buzzard buzzard
+ buzzards buzzard
+ buzzers buzzer
+ buzzing buzz
+ by by
+ bye bye
+ byzantium byzantium
+ c c
+ ca ca
+ cabbage cabbag
+ cabileros cabilero
+ cabin cabin
+ cabins cabin
+ cable cabl
+ cables cabl
+ cackling cackl
+ cacodemon cacodemon
+ caddis caddi
+ caddisses caddiss
+ cade cade
+ cadence cadenc
+ cadent cadent
+ cades cade
+ cadmus cadmu
+ caduceus caduceu
+ cadwal cadwal
+ cadwallader cadwallad
+ caelius caeliu
+ caelo caelo
+ caesar caesar
+ caesarion caesarion
+ caesars caesar
+ cage cage
+ caged cage
+ cagion cagion
+ cain cain
+ caithness caith
+ caitiff caitiff
+ caitiffs caitiff
+ caius caiu
+ cak cak
+ cake cake
+ cakes cake
+ calaber calab
+ calais calai
+ calamities calam
+ calamity calam
+ calchas calcha
+ calculate calcul
+ calen calen
+ calendar calendar
+ calendars calendar
+ calf calf
+ caliban caliban
+ calibans caliban
+ calipolis calipoli
+ cality caliti
+ caliver caliv
+ call call
+ callat callat
+ called call
+ callet callet
+ calling call
+ calls call
+ calm calm
+ calmest calmest
+ calmly calmli
+ calmness calm
+ calms calm
+ calpurnia calpurnia
+ calumniate calumni
+ calumniating calumni
+ calumnious calumni
+ calumny calumni
+ calve calv
+ calved calv
+ calves calv
+ calveskins calveskin
+ calydon calydon
+ cam cam
+ cambio cambio
+ cambria cambria
+ cambric cambric
+ cambrics cambric
+ cambridge cambridg
+ cambyses cambys
+ came came
+ camel camel
+ camelot camelot
+ camels camel
+ camest camest
+ camillo camillo
+ camlet camlet
+ camomile camomil
+ camp camp
+ campeius campeiu
+ camping camp
+ camps camp
+ can can
+ canakin canakin
+ canaries canari
+ canary canari
+ cancel cancel
+ cancell cancel
+ cancelled cancel
+ cancelling cancel
+ cancels cancel
+ cancer cancer
+ candidatus candidatu
+ candied candi
+ candle candl
+ candles candl
+ candlesticks candlestick
+ candy candi
+ canidius canidiu
+ cank cank
+ canker canker
+ cankerblossom cankerblossom
+ cankers canker
+ cannibally cannib
+ cannibals cannib
+ cannon cannon
+ cannoneer cannon
+ cannons cannon
+ cannot cannot
+ canon canon
+ canoniz canoniz
+ canonize canon
+ canonized canon
+ canons canon
+ canopied canopi
+ canopies canopi
+ canopy canopi
+ canst canst
+ canstick canstick
+ canterbury canterburi
+ cantle cantl
+ cantons canton
+ canus canu
+ canvas canva
+ canvass canvass
+ canzonet canzonet
+ cap cap
+ capability capabl
+ capable capabl
+ capacities capac
+ capacity capac
+ caparison caparison
+ capdv capdv
+ cape cape
+ capel capel
+ capels capel
+ caper caper
+ capers caper
+ capet capet
+ caphis caphi
+ capilet capilet
+ capitaine capitain
+ capital capit
+ capite capit
+ capitol capitol
+ capitulate capitul
+ capocchia capocchia
+ capon capon
+ capons capon
+ capp capp
+ cappadocia cappadocia
+ capriccio capriccio
+ capricious caprici
+ caps cap
+ capt capt
+ captain captain
+ captains captain
+ captainship captainship
+ captious captiou
+ captivate captiv
+ captivated captiv
+ captivates captiv
+ captive captiv
+ captives captiv
+ captivity captiv
+ captum captum
+ capucius capuciu
+ capulet capulet
+ capulets capulet
+ car car
+ carack carack
+ caracks carack
+ carat carat
+ caraways carawai
+ carbonado carbonado
+ carbuncle carbuncl
+ carbuncled carbuncl
+ carbuncles carbuncl
+ carcanet carcanet
+ carcase carcas
+ carcases carcas
+ carcass carcass
+ carcasses carcass
+ card card
+ cardecue cardecu
+ carded card
+ carders carder
+ cardinal cardin
+ cardinally cardin
+ cardinals cardin
+ cardmaker cardmak
+ cards card
+ carduus carduu
+ care care
+ cared care
+ career career
+ careers career
+ careful care
+ carefully carefulli
+ careless careless
+ carelessly carelessli
+ carelessness careless
+ cares care
+ caret caret
+ cargo cargo
+ carl carl
+ carlisle carlisl
+ carlot carlot
+ carman carman
+ carmen carmen
+ carnal carnal
+ carnally carnal
+ carnarvonshire carnarvonshir
+ carnation carnat
+ carnations carnat
+ carol carol
+ carous carou
+ carouse carous
+ caroused carous
+ carouses carous
+ carousing carous
+ carp carp
+ carpenter carpent
+ carper carper
+ carpet carpet
+ carpets carpet
+ carping carp
+ carriage carriag
+ carriages carriag
+ carried carri
+ carrier carrier
+ carriers carrier
+ carries carri
+ carrion carrion
+ carrions carrion
+ carry carri
+ carrying carri
+ cars car
+ cart cart
+ carters carter
+ carthage carthag
+ carts cart
+ carv carv
+ carve carv
+ carved carv
+ carver carver
+ carves carv
+ carving carv
+ cas ca
+ casa casa
+ casaer casaer
+ casca casca
+ case case
+ casement casement
+ casements casement
+ cases case
+ cash cash
+ cashier cashier
+ casing case
+ cask cask
+ casket casket
+ casketed casket
+ caskets casket
+ casque casqu
+ casques casqu
+ cassado cassado
+ cassandra cassandra
+ cassibelan cassibelan
+ cassio cassio
+ cassius cassiu
+ cassocks cassock
+ cast cast
+ castalion castalion
+ castaway castawai
+ castaways castawai
+ casted cast
+ caster caster
+ castigate castig
+ castigation castig
+ castile castil
+ castiliano castiliano
+ casting cast
+ castle castl
+ castles castl
+ casts cast
+ casual casual
+ casually casual
+ casualties casualti
+ casualty casualti
+ cat cat
+ cataian cataian
+ catalogue catalogu
+ cataplasm cataplasm
+ cataracts cataract
+ catarrhs catarrh
+ catastrophe catastroph
+ catch catch
+ catcher catcher
+ catches catch
+ catching catch
+ cate cate
+ catechising catechis
+ catechism catech
+ catechize catech
+ cater cater
+ caterpillars caterpillar
+ caters cater
+ caterwauling caterwaul
+ cates cate
+ catesby catesbi
+ cathedral cathedr
+ catlike catlik
+ catling catl
+ catlings catl
+ cato cato
+ cats cat
+ cattle cattl
+ caucasus caucasu
+ caudle caudl
+ cauf cauf
+ caught caught
+ cauldron cauldron
+ caus cau
+ cause caus
+ caused caus
+ causeless causeless
+ causer causer
+ causes caus
+ causest causest
+ causeth causeth
+ cautel cautel
+ cautelous cautel
+ cautels cautel
+ cauterizing cauter
+ caution caution
+ cautions caution
+ cavaleiro cavaleiro
+ cavalery cavaleri
+ cavaliers cavali
+ cave cave
+ cavern cavern
+ caverns cavern
+ caves cave
+ caveto caveto
+ caviary caviari
+ cavil cavil
+ cavilling cavil
+ cawdor cawdor
+ cawdron cawdron
+ cawing caw
+ ce ce
+ ceas cea
+ cease ceas
+ ceases ceas
+ ceaseth ceaseth
+ cedar cedar
+ cedars cedar
+ cedius cediu
+ celebrate celebr
+ celebrated celebr
+ celebrates celebr
+ celebration celebr
+ celerity celer
+ celestial celesti
+ celia celia
+ cell cell
+ cellar cellar
+ cellarage cellarag
+ celsa celsa
+ cement cement
+ censer censer
+ censor censor
+ censorinus censorinu
+ censur censur
+ censure censur
+ censured censur
+ censurers censur
+ censures censur
+ censuring censur
+ centaur centaur
+ centaurs centaur
+ centre centr
+ cents cent
+ centuries centuri
+ centurion centurion
+ centurions centurion
+ century centuri
+ cerberus cerberu
+ cerecloth cerecloth
+ cerements cerement
+ ceremonial ceremoni
+ ceremonies ceremoni
+ ceremonious ceremoni
+ ceremoniously ceremoni
+ ceremony ceremoni
+ ceres cere
+ cerns cern
+ certain certain
+ certainer certain
+ certainly certainli
+ certainties certainti
+ certainty certainti
+ certes cert
+ certificate certif
+ certified certifi
+ certifies certifi
+ certify certifi
+ ces ce
+ cesario cesario
+ cess cess
+ cesse cess
+ cestern cestern
+ cetera cetera
+ cette cett
+ chaces chace
+ chaf chaf
+ chafe chafe
+ chafed chafe
+ chafes chafe
+ chaff chaff
+ chaffless chaffless
+ chafing chafe
+ chain chain
+ chains chain
+ chair chair
+ chairs chair
+ chalic chalic
+ chalice chalic
+ chalices chalic
+ chalk chalk
+ chalks chalk
+ chalky chalki
+ challeng challeng
+ challenge challeng
+ challenged challeng
+ challenger challeng
+ challengers challeng
+ challenges challeng
+ cham cham
+ chamber chamber
+ chamberers chamber
+ chamberlain chamberlain
+ chamberlains chamberlain
+ chambermaid chambermaid
+ chambermaids chambermaid
+ chambers chamber
+ chameleon chameleon
+ champ champ
+ champagne champagn
+ champain champain
+ champains champain
+ champion champion
+ champions champion
+ chanc chanc
+ chance chanc
+ chanced chanc
+ chancellor chancellor
+ chances chanc
+ chandler chandler
+ chang chang
+ change chang
+ changeable changeabl
+ changed chang
+ changeful chang
+ changeling changel
+ changelings changel
+ changer changer
+ changes chang
+ changest changest
+ changing chang
+ channel channel
+ channels channel
+ chanson chanson
+ chant chant
+ chanticleer chanticl
+ chanting chant
+ chantries chantri
+ chantry chantri
+ chants chant
+ chaos chao
+ chap chap
+ chape chape
+ chapel chapel
+ chapeless chapeless
+ chapels chapel
+ chaplain chaplain
+ chaplains chaplain
+ chapless chapless
+ chaplet chaplet
+ chapmen chapmen
+ chaps chap
+ chapter chapter
+ character charact
+ charactered charact
+ characterless characterless
+ characters charact
+ charactery characteri
+ characts charact
+ charbon charbon
+ chare chare
+ chares chare
+ charg charg
+ charge charg
+ charged charg
+ chargeful charg
+ charges charg
+ chargeth chargeth
+ charging charg
+ chariest chariest
+ chariness chari
+ charing chare
+ chariot chariot
+ chariots chariot
+ charitable charit
+ charitably charit
+ charities chariti
+ charity chariti
+ charlemain charlemain
+ charles charl
+ charm charm
+ charmed charm
+ charmer charmer
+ charmeth charmeth
+ charmian charmian
+ charming charm
+ charmingly charmingli
+ charms charm
+ charneco charneco
+ charnel charnel
+ charolois charoloi
+ charon charon
+ charter charter
+ charters charter
+ chartreux chartreux
+ chary chari
+ charybdis charybdi
+ chas cha
+ chase chase
+ chased chase
+ chaser chaser
+ chaseth chaseth
+ chasing chase
+ chaste chast
+ chastely chast
+ chastis chasti
+ chastise chastis
+ chastised chastis
+ chastisement chastis
+ chastity chastiti
+ chat chat
+ chatham chatham
+ chatillon chatillon
+ chats chat
+ chatt chatt
+ chattels chattel
+ chatter chatter
+ chattering chatter
+ chattles chattl
+ chaud chaud
+ chaunted chaunt
+ chaw chaw
+ chawdron chawdron
+ che che
+ cheap cheap
+ cheapen cheapen
+ cheaper cheaper
+ cheapest cheapest
+ cheaply cheapli
+ cheapside cheapsid
+ cheat cheat
+ cheated cheat
+ cheater cheater
+ cheaters cheater
+ cheating cheat
+ cheats cheat
+ check check
+ checked check
+ checker checker
+ checking check
+ checks check
+ cheek cheek
+ cheeks cheek
+ cheer cheer
+ cheered cheer
+ cheerer cheerer
+ cheerful cheer
+ cheerfully cheerfulli
+ cheering cheer
+ cheerless cheerless
+ cheerly cheerli
+ cheers cheer
+ cheese chees
+ chequer chequer
+ cher cher
+ cherish cherish
+ cherished cherish
+ cherisher cherish
+ cherishes cherish
+ cherishing cherish
+ cherries cherri
+ cherry cherri
+ cherrypit cherrypit
+ chertsey chertsei
+ cherub cherub
+ cherubims cherubim
+ cherubin cherubin
+ cherubins cherubin
+ cheshu cheshu
+ chess chess
+ chest chest
+ chester chester
+ chestnut chestnut
+ chestnuts chestnut
+ chests chest
+ chetas cheta
+ chev chev
+ cheval cheval
+ chevalier chevali
+ chevaliers chevali
+ cheveril cheveril
+ chew chew
+ chewed chew
+ chewet chewet
+ chewing chew
+ chez chez
+ chi chi
+ chick chick
+ chicken chicken
+ chickens chicken
+ chicurmurco chicurmurco
+ chid chid
+ chidden chidden
+ chide chide
+ chiders chider
+ chides chide
+ chiding chide
+ chief chief
+ chiefest chiefest
+ chiefly chiefli
+ chien chien
+ child child
+ childed child
+ childeric childer
+ childhood childhood
+ childhoods childhood
+ childing child
+ childish childish
+ childishness childish
+ childlike childlik
+ childness child
+ children children
+ chill chill
+ chilling chill
+ chime chime
+ chimes chime
+ chimney chimnei
+ chimneypiece chimneypiec
+ chimneys chimnei
+ chimurcho chimurcho
+ chin chin
+ china china
+ chine chine
+ chines chine
+ chink chink
+ chinks chink
+ chins chin
+ chipp chipp
+ chipper chipper
+ chips chip
+ chiron chiron
+ chirping chirp
+ chirrah chirrah
+ chirurgeonly chirurgeonli
+ chisel chisel
+ chitopher chitoph
+ chivalrous chivalr
+ chivalry chivalri
+ choice choic
+ choicely choic
+ choicest choicest
+ choir choir
+ choirs choir
+ chok chok
+ choke choke
+ choked choke
+ chokes choke
+ choking choke
+ choler choler
+ choleric choler
+ cholers choler
+ chollors chollor
+ choose choos
+ chooser chooser
+ chooses choos
+ chooseth chooseth
+ choosing choos
+ chop chop
+ chopine chopin
+ choplogic choplog
+ chopp chopp
+ chopped chop
+ chopping chop
+ choppy choppi
+ chops chop
+ chopt chopt
+ chor chor
+ choristers chorist
+ chorus choru
+ chose chose
+ chosen chosen
+ chough chough
+ choughs chough
+ chrish chrish
+ christ christ
+ christen christen
+ christendom christendom
+ christendoms christendom
+ christening christen
+ christenings christen
+ christian christian
+ christianlike christianlik
+ christians christian
+ christmas christma
+ christom christom
+ christopher christoph
+ christophero christophero
+ chronicle chronicl
+ chronicled chronicl
+ chronicler chronicl
+ chroniclers chronicl
+ chronicles chronicl
+ chrysolite chrysolit
+ chuck chuck
+ chucks chuck
+ chud chud
+ chuffs chuff
+ church church
+ churches church
+ churchman churchman
+ churchmen churchmen
+ churchyard churchyard
+ churchyards churchyard
+ churl churl
+ churlish churlish
+ churlishly churlishli
+ churls churl
+ churn churn
+ chus chu
+ cicatrice cicatric
+ cicatrices cicatric
+ cicely cice
+ cicero cicero
+ ciceter cicet
+ ciel ciel
+ ciitzens ciitzen
+ cilicia cilicia
+ cimber cimber
+ cimmerian cimmerian
+ cinable cinabl
+ cincture cinctur
+ cinders cinder
+ cine cine
+ cinna cinna
+ cinque cinqu
+ cipher cipher
+ ciphers cipher
+ circa circa
+ circe circ
+ circle circl
+ circled circl
+ circlets circlet
+ circling circl
+ circuit circuit
+ circum circum
+ circumcised circumcis
+ circumference circumfer
+ circummur circummur
+ circumscrib circumscrib
+ circumscribed circumscrib
+ circumscription circumscript
+ circumspect circumspect
+ circumstance circumst
+ circumstanced circumstanc
+ circumstances circumst
+ circumstantial circumstanti
+ circumvent circumv
+ circumvention circumvent
+ cistern cistern
+ citadel citadel
+ cital cital
+ cite cite
+ cited cite
+ cites cite
+ cities citi
+ citing cite
+ citizen citizen
+ citizens citizen
+ cittern cittern
+ city citi
+ civet civet
+ civil civil
+ civility civil
+ civilly civilli
+ clack clack
+ clad clad
+ claim claim
+ claiming claim
+ claims claim
+ clamb clamb
+ clamber clamber
+ clammer clammer
+ clamor clamor
+ clamorous clamor
+ clamors clamor
+ clamour clamour
+ clamours clamour
+ clang clang
+ clangor clangor
+ clap clap
+ clapp clapp
+ clapped clap
+ clapper clapper
+ clapping clap
+ claps clap
+ clare clare
+ clarence clarenc
+ claret claret
+ claribel claribel
+ clasp clasp
+ clasps clasp
+ clatter clatter
+ claud claud
+ claudio claudio
+ claudius claudiu
+ clause claus
+ claw claw
+ clawed claw
+ clawing claw
+ claws claw
+ clay clai
+ clays clai
+ clean clean
+ cleanliest cleanliest
+ cleanly cleanli
+ cleans clean
+ cleanse cleans
+ cleansing cleans
+ clear clear
+ clearer clearer
+ clearest clearest
+ clearly clearli
+ clearness clear
+ clears clear
+ cleave cleav
+ cleaving cleav
+ clef clef
+ cleft cleft
+ cleitus cleitu
+ clemency clemenc
+ clement clement
+ cleomenes cleomen
+ cleopatpa cleopatpa
+ cleopatra cleopatra
+ clepeth clepeth
+ clept clept
+ clerestories clerestori
+ clergy clergi
+ clergyman clergyman
+ clergymen clergymen
+ clerk clerk
+ clerkly clerkli
+ clerks clerk
+ clew clew
+ client client
+ clients client
+ cliff cliff
+ clifford clifford
+ cliffords clifford
+ cliffs cliff
+ clifton clifton
+ climate climat
+ climature climatur
+ climb climb
+ climbed climb
+ climber climber
+ climbeth climbeth
+ climbing climb
+ climbs climb
+ clime clime
+ cling cling
+ clink clink
+ clinking clink
+ clinquant clinquant
+ clip clip
+ clipp clipp
+ clipper clipper
+ clippeth clippeth
+ clipping clip
+ clipt clipt
+ clitus clitu
+ clo clo
+ cloak cloak
+ cloakbag cloakbag
+ cloaks cloak
+ clock clock
+ clocks clock
+ clod clod
+ cloddy cloddi
+ clodpole clodpol
+ clog clog
+ clogging clog
+ clogs clog
+ cloister cloister
+ cloistress cloistress
+ cloquence cloquenc
+ clos clo
+ close close
+ closed close
+ closely close
+ closeness close
+ closer closer
+ closes close
+ closest closest
+ closet closet
+ closing close
+ closure closur
+ cloten cloten
+ clotens cloten
+ cloth cloth
+ clothair clothair
+ clotharius clothariu
+ clothe cloth
+ clothes cloth
+ clothier clothier
+ clothiers clothier
+ clothing cloth
+ cloths cloth
+ clotpoles clotpol
+ clotpoll clotpol
+ cloud cloud
+ clouded cloud
+ cloudiness cloudi
+ clouds cloud
+ cloudy cloudi
+ clout clout
+ clouted clout
+ clouts clout
+ cloven cloven
+ clover clover
+ cloves clove
+ clovest clovest
+ clowder clowder
+ clown clown
+ clownish clownish
+ clowns clown
+ cloy cloi
+ cloyed cloi
+ cloying cloi
+ cloyless cloyless
+ cloyment cloyment
+ cloys cloi
+ club club
+ clubs club
+ cluck cluck
+ clung clung
+ clust clust
+ clusters cluster
+ clutch clutch
+ clyster clyster
+ cneius cneiu
+ cnemies cnemi
+ co co
+ coach coach
+ coaches coach
+ coachmakers coachmak
+ coact coact
+ coactive coactiv
+ coagulate coagul
+ coal coal
+ coals coal
+ coarse coars
+ coarsely coars
+ coast coast
+ coasting coast
+ coasts coast
+ coat coat
+ coated coat
+ coats coat
+ cobble cobbl
+ cobbled cobbl
+ cobbler cobbler
+ cobham cobham
+ cobloaf cobloaf
+ cobweb cobweb
+ cobwebs cobweb
+ cock cock
+ cockatrice cockatric
+ cockatrices cockatric
+ cockle cockl
+ cockled cockl
+ cockney cocknei
+ cockpit cockpit
+ cocks cock
+ cocksure cocksur
+ coctus coctu
+ cocytus cocytu
+ cod cod
+ codding cod
+ codling codl
+ codpiece codpiec
+ codpieces codpiec
+ cods cod
+ coelestibus coelestibu
+ coesar coesar
+ coeur coeur
+ coffer coffer
+ coffers coffer
+ coffin coffin
+ coffins coffin
+ cog cog
+ cogging cog
+ cogitation cogit
+ cogitations cogit
+ cognition cognit
+ cognizance cogniz
+ cogscomb cogscomb
+ cohabitants cohabit
+ coher coher
+ cohere coher
+ coherence coher
+ coherent coher
+ cohorts cohort
+ coif coif
+ coign coign
+ coil coil
+ coin coin
+ coinage coinag
+ coiner coiner
+ coining coin
+ coins coin
+ col col
+ colbrand colbrand
+ colchos colcho
+ cold cold
+ colder colder
+ coldest coldest
+ coldly coldli
+ coldness cold
+ coldspur coldspur
+ colebrook colebrook
+ colic colic
+ collar collar
+ collars collar
+ collateral collater
+ colleagued colleagu
+ collect collect
+ collected collect
+ collection collect
+ college colleg
+ colleges colleg
+ collied colli
+ collier collier
+ colliers collier
+ collop collop
+ collusion collus
+ colme colm
+ colmekill colmekil
+ coloquintida coloquintida
+ color color
+ colors color
+ colossus colossu
+ colour colour
+ colourable colour
+ coloured colour
+ colouring colour
+ colours colour
+ colt colt
+ colted colt
+ colts colt
+ columbine columbin
+ columbines columbin
+ colville colvil
+ com com
+ comagene comagen
+ comart comart
+ comb comb
+ combat combat
+ combatant combat
+ combatants combat
+ combated combat
+ combating combat
+ combin combin
+ combinate combin
+ combination combin
+ combine combin
+ combined combin
+ combless combless
+ combustion combust
+ come come
+ comedian comedian
+ comedians comedian
+ comedy comedi
+ comeliness comeli
+ comely come
+ comer comer
+ comers comer
+ comes come
+ comest comest
+ comet comet
+ cometh cometh
+ comets comet
+ comfect comfect
+ comfit comfit
+ comfits comfit
+ comfort comfort
+ comfortable comfort
+ comforted comfort
+ comforter comfort
+ comforting comfort
+ comfortless comfortless
+ comforts comfort
+ comic comic
+ comical comic
+ coming come
+ comings come
+ cominius cominiu
+ comma comma
+ command command
+ commande command
+ commanded command
+ commander command
+ commanders command
+ commanding command
+ commandment command
+ commandments command
+ commands command
+ comme comm
+ commenc commenc
+ commence commenc
+ commenced commenc
+ commencement commenc
+ commences commenc
+ commencing commenc
+ commend commend
+ commendable commend
+ commendation commend
+ commendations commend
+ commended commend
+ commending commend
+ commends commend
+ comment comment
+ commentaries commentari
+ commenting comment
+ comments comment
+ commerce commerc
+ commingled commingl
+ commiseration commiser
+ commission commiss
+ commissioners commission
+ commissions commiss
+ commit commit
+ commits commit
+ committ committ
+ committed commit
+ committing commit
+ commix commix
+ commixed commix
+ commixtion commixt
+ commixture commixtur
+ commodious commodi
+ commodities commod
+ commodity commod
+ common common
+ commonalty commonalti
+ commoner common
+ commoners common
+ commonly commonli
+ commons common
+ commonweal commonw
+ commonwealth commonwealth
+ commotion commot
+ commotions commot
+ commune commun
+ communicat communicat
+ communicate commun
+ communication commun
+ communities commun
+ community commun
+ comonty comonti
+ compact compact
+ companies compani
+ companion companion
+ companions companion
+ companionship companionship
+ company compani
+ compar compar
+ comparative compar
+ compare compar
+ compared compar
+ comparing compar
+ comparison comparison
+ comparisons comparison
+ compartner compartn
+ compass compass
+ compasses compass
+ compassing compass
+ compassion compass
+ compassionate compassion
+ compeers compeer
+ compel compel
+ compell compel
+ compelled compel
+ compelling compel
+ compels compel
+ compensation compens
+ competence compet
+ competency compet
+ competent compet
+ competitor competitor
+ competitors competitor
+ compil compil
+ compile compil
+ compiled compil
+ complain complain
+ complainer complain
+ complainest complainest
+ complaining complain
+ complainings complain
+ complains complain
+ complaint complaint
+ complaints complaint
+ complement complement
+ complements complement
+ complete complet
+ complexion complexion
+ complexioned complexion
+ complexions complexion
+ complices complic
+ complies compli
+ compliment compliment
+ complimental compliment
+ compliments compliment
+ complot complot
+ complots complot
+ complotted complot
+ comply compli
+ compos compo
+ compose compos
+ composed compos
+ composition composit
+ compost compost
+ composture compostur
+ composure composur
+ compound compound
+ compounded compound
+ compounds compound
+ comprehend comprehend
+ comprehended comprehend
+ comprehends comprehend
+ compremises compremis
+ compris compri
+ comprising compris
+ compromis compromi
+ compromise compromis
+ compt compt
+ comptible comptibl
+ comptrollers comptrol
+ compulsatory compulsatori
+ compulsion compuls
+ compulsive compuls
+ compunctious compuncti
+ computation comput
+ comrade comrad
+ comrades comrad
+ comutual comutu
+ con con
+ concave concav
+ concavities concav
+ conceal conceal
+ concealed conceal
+ concealing conceal
+ concealment conceal
+ concealments conceal
+ conceals conceal
+ conceit conceit
+ conceited conceit
+ conceitless conceitless
+ conceits conceit
+ conceiv conceiv
+ conceive conceiv
+ conceived conceiv
+ conceives conceiv
+ conceiving conceiv
+ conception concept
+ conceptions concept
+ conceptious concepti
+ concern concern
+ concernancy concern
+ concerneth concerneth
+ concerning concern
+ concernings concern
+ concerns concern
+ conclave conclav
+ conclud conclud
+ conclude conclud
+ concluded conclud
+ concludes conclud
+ concluding conclud
+ conclusion conclus
+ conclusions conclus
+ concolinel concolinel
+ concord concord
+ concubine concubin
+ concupiscible concupisc
+ concupy concupi
+ concur concur
+ concurring concur
+ concurs concur
+ condemn condemn
+ condemnation condemn
+ condemned condemn
+ condemning condemn
+ condemns condemn
+ condescend condescend
+ condign condign
+ condition condit
+ conditionally condition
+ conditions condit
+ condole condol
+ condolement condol
+ condoling condol
+ conduce conduc
+ conduct conduct
+ conducted conduct
+ conducting conduct
+ conductor conductor
+ conduit conduit
+ conduits conduit
+ conected conect
+ coney conei
+ confection confect
+ confectionary confectionari
+ confections confect
+ confederacy confederaci
+ confederate confeder
+ confederates confeder
+ confer confer
+ conference confer
+ conferr conferr
+ conferring confer
+ confess confess
+ confessed confess
+ confesses confess
+ confesseth confesseth
+ confessing confess
+ confession confess
+ confessions confess
+ confessor confessor
+ confidence confid
+ confident confid
+ confidently confid
+ confin confin
+ confine confin
+ confined confin
+ confineless confineless
+ confiners confin
+ confines confin
+ confining confin
+ confirm confirm
+ confirmation confirm
+ confirmations confirm
+ confirmed confirm
+ confirmer confirm
+ confirmers confirm
+ confirming confirm
+ confirmities confirm
+ confirms confirm
+ confiscate confisc
+ confiscated confisc
+ confiscation confisc
+ confixed confix
+ conflict conflict
+ conflicting conflict
+ conflicts conflict
+ confluence confluenc
+ conflux conflux
+ conform conform
+ conformable conform
+ confound confound
+ confounded confound
+ confounding confound
+ confounds confound
+ confront confront
+ confronted confront
+ confus confu
+ confused confus
+ confusedly confusedli
+ confusion confus
+ confusions confus
+ confutation confut
+ confutes confut
+ congeal congeal
+ congealed congeal
+ congealment congeal
+ congee conge
+ conger conger
+ congest congest
+ congied congi
+ congratulate congratul
+ congreeing congre
+ congreeted congreet
+ congregate congreg
+ congregated congreg
+ congregation congreg
+ congregations congreg
+ congruent congruent
+ congruing congru
+ conies coni
+ conjectural conjectur
+ conjecture conjectur
+ conjectures conjectur
+ conjoin conjoin
+ conjoined conjoin
+ conjoins conjoin
+ conjointly conjointli
+ conjunct conjunct
+ conjunction conjunct
+ conjunctive conjunct
+ conjur conjur
+ conjuration conjur
+ conjurations conjur
+ conjure conjur
+ conjured conjur
+ conjurer conjur
+ conjurers conjur
+ conjures conjur
+ conjuring conjur
+ conjuro conjuro
+ conn conn
+ connected connect
+ connive conniv
+ conqu conqu
+ conquer conquer
+ conquered conquer
+ conquering conquer
+ conqueror conqueror
+ conquerors conqueror
+ conquers conquer
+ conquest conquest
+ conquests conquest
+ conquring conqur
+ conrade conrad
+ cons con
+ consanguineous consanguin
+ consanguinity consanguin
+ conscienc conscienc
+ conscience conscienc
+ consciences conscienc
+ conscionable conscion
+ consecrate consecr
+ consecrated consecr
+ consecrations consecr
+ consent consent
+ consented consent
+ consenting consent
+ consents consent
+ consequence consequ
+ consequences consequ
+ consequently consequ
+ conserve conserv
+ conserved conserv
+ conserves conserv
+ consider consid
+ considerance consider
+ considerate consider
+ consideration consider
+ considerations consider
+ considered consid
+ considering consid
+ considerings consid
+ considers consid
+ consign consign
+ consigning consign
+ consist consist
+ consisteth consisteth
+ consisting consist
+ consistory consistori
+ consists consist
+ consolate consol
+ consolation consol
+ consonancy conson
+ consonant conson
+ consort consort
+ consorted consort
+ consortest consortest
+ conspectuities conspectu
+ conspir conspir
+ conspiracy conspiraci
+ conspirant conspir
+ conspirator conspir
+ conspirators conspir
+ conspire conspir
+ conspired conspir
+ conspirers conspir
+ conspires conspir
+ conspiring conspir
+ constable constabl
+ constables constabl
+ constance constanc
+ constancies constanc
+ constancy constanc
+ constant constant
+ constantine constantin
+ constantinople constantinopl
+ constantly constantli
+ constellation constel
+ constitution constitut
+ constrain constrain
+ constrained constrain
+ constraineth constraineth
+ constrains constrain
+ constraint constraint
+ constring constr
+ construction construct
+ construe constru
+ consul consul
+ consuls consul
+ consulship consulship
+ consulships consulship
+ consult consult
+ consulting consult
+ consults consult
+ consum consum
+ consume consum
+ consumed consum
+ consumes consum
+ consuming consum
+ consummate consumm
+ consummation consumm
+ consumption consumpt
+ consumptions consumpt
+ contagion contagion
+ contagious contagi
+ contain contain
+ containing contain
+ contains contain
+ contaminate contamin
+ contaminated contamin
+ contemn contemn
+ contemned contemn
+ contemning contemn
+ contemns contemn
+ contemplate contempl
+ contemplation contempl
+ contemplative contempl
+ contempt contempt
+ contemptible contempt
+ contempts contempt
+ contemptuous contemptu
+ contemptuously contemptu
+ contend contend
+ contended contend
+ contending contend
+ contendon contendon
+ content content
+ contenta contenta
+ contented content
+ contenteth contenteth
+ contention content
+ contentious contenti
+ contentless contentless
+ contento contento
+ contents content
+ contest contest
+ contestation contest
+ continence contin
+ continency contin
+ continent contin
+ continents contin
+ continu continu
+ continual continu
+ continually continu
+ continuance continu
+ continuantly continuantli
+ continuate continu
+ continue continu
+ continued continu
+ continuer continu
+ continues continu
+ continuing continu
+ contract contract
+ contracted contract
+ contracting contract
+ contraction contract
+ contradict contradict
+ contradicted contradict
+ contradiction contradict
+ contradicts contradict
+ contraries contrari
+ contrarieties contrarieti
+ contrariety contrarieti
+ contrarious contrari
+ contrariously contrari
+ contrary contrari
+ contre contr
+ contribution contribut
+ contributors contributor
+ contrite contrit
+ contriv contriv
+ contrive contriv
+ contrived contriv
+ contriver contriv
+ contrives contriv
+ contriving contriv
+ control control
+ controll control
+ controller control
+ controlling control
+ controlment control
+ controls control
+ controversy controversi
+ contumelious contumeli
+ contumeliously contumeli
+ contumely contum
+ contusions contus
+ convenience conveni
+ conveniences conveni
+ conveniency conveni
+ convenient conveni
+ conveniently conveni
+ convented convent
+ conventicles conventicl
+ convents convent
+ convers conver
+ conversant convers
+ conversation convers
+ conversations convers
+ converse convers
+ conversed convers
+ converses convers
+ conversing convers
+ conversion convers
+ convert convert
+ converted convert
+ convertest convertest
+ converting convert
+ convertite convertit
+ convertites convertit
+ converts convert
+ convey convei
+ conveyance convey
+ conveyances convey
+ conveyers convey
+ conveying convei
+ convict convict
+ convicted convict
+ convince convinc
+ convinced convinc
+ convinces convinc
+ convive conviv
+ convocation convoc
+ convoy convoi
+ convulsions convuls
+ cony coni
+ cook cook
+ cookery cookeri
+ cooks cook
+ cool cool
+ cooled cool
+ cooling cool
+ cools cool
+ coop coop
+ coops coop
+ cop cop
+ copatain copatain
+ cope cope
+ cophetua cophetua
+ copied copi
+ copies copi
+ copious copiou
+ copper copper
+ copperspur copperspur
+ coppice coppic
+ copulation copul
+ copulatives copul
+ copy copi
+ cor cor
+ coragio coragio
+ coral coral
+ coram coram
+ corambus corambu
+ coranto coranto
+ corantos coranto
+ corbo corbo
+ cord cord
+ corded cord
+ cordelia cordelia
+ cordial cordial
+ cordis cordi
+ cords cord
+ core core
+ corin corin
+ corinth corinth
+ corinthian corinthian
+ coriolanus coriolanu
+ corioli corioli
+ cork cork
+ corky corki
+ cormorant cormor
+ corn corn
+ cornelia cornelia
+ cornelius corneliu
+ corner corner
+ corners corner
+ cornerstone cornerston
+ cornets cornet
+ cornish cornish
+ corns corn
+ cornuto cornuto
+ cornwall cornwal
+ corollary corollari
+ coronal coron
+ coronation coron
+ coronet coronet
+ coronets coronet
+ corporal corpor
+ corporals corpor
+ corporate corpor
+ corpse corps
+ corpulent corpul
+ correct correct
+ corrected correct
+ correcting correct
+ correction correct
+ correctioner correction
+ corrects correct
+ correspondence correspond
+ correspondent correspond
+ corresponding correspond
+ corresponsive correspons
+ corrigible corrig
+ corrival corriv
+ corrivals corriv
+ corroborate corrobor
+ corrosive corros
+ corrupt corrupt
+ corrupted corrupt
+ corrupter corrupt
+ corrupters corrupt
+ corruptible corrupt
+ corruptibly corrupt
+ corrupting corrupt
+ corruption corrupt
+ corruptly corruptli
+ corrupts corrupt
+ corse cors
+ corses cors
+ corslet corslet
+ cosmo cosmo
+ cost cost
+ costard costard
+ costermongers costermong
+ costlier costlier
+ costly costli
+ costs cost
+ cot cot
+ cote cote
+ coted cote
+ cotsall cotsal
+ cotsole cotsol
+ cotswold cotswold
+ cottage cottag
+ cottages cottag
+ cotus cotu
+ couch couch
+ couched couch
+ couching couch
+ couchings couch
+ coude coud
+ cough cough
+ coughing cough
+ could could
+ couldst couldst
+ coulter coulter
+ council council
+ councillor councillor
+ councils council
+ counsel counsel
+ counsell counsel
+ counsellor counsellor
+ counsellors counsellor
+ counselor counselor
+ counselors counselor
+ counsels counsel
+ count count
+ counted count
+ countenanc countenanc
+ countenance counten
+ countenances counten
+ counter counter
+ counterchange counterchang
+ countercheck countercheck
+ counterfeit counterfeit
+ counterfeited counterfeit
+ counterfeiting counterfeit
+ counterfeitly counterfeitli
+ counterfeits counterfeit
+ countermand countermand
+ countermands countermand
+ countermines countermin
+ counterpart counterpart
+ counterpoints counterpoint
+ counterpois counterpoi
+ counterpoise counterpois
+ counters counter
+ countervail countervail
+ countess countess
+ countesses countess
+ counties counti
+ counting count
+ countless countless
+ countries countri
+ countrv countrv
+ country countri
+ countryman countryman
+ countrymen countrymen
+ counts count
+ county counti
+ couper couper
+ couple coupl
+ coupled coupl
+ couplement couplement
+ couples coupl
+ couplet couplet
+ couplets couplet
+ cour cour
+ courage courag
+ courageous courag
+ courageously courag
+ courages courag
+ courier courier
+ couriers courier
+ couronne couronn
+ cours cour
+ course cours
+ coursed cours
+ courser courser
+ coursers courser
+ courses cours
+ coursing cours
+ court court
+ courted court
+ courteous courteou
+ courteously courteous
+ courtesan courtesan
+ courtesies courtesi
+ courtesy courtesi
+ courtezan courtezan
+ courtezans courtezan
+ courtier courtier
+ courtiers courtier
+ courtlike courtlik
+ courtly courtli
+ courtney courtnei
+ courts court
+ courtship courtship
+ cousin cousin
+ cousins cousin
+ couterfeit couterfeit
+ coutume coutum
+ covenant coven
+ covenants coven
+ covent covent
+ coventry coventri
+ cover cover
+ covered cover
+ covering cover
+ coverlet coverlet
+ covers cover
+ covert covert
+ covertly covertli
+ coverture covertur
+ covet covet
+ coveted covet
+ coveting covet
+ covetings covet
+ covetous covet
+ covetously covet
+ covetousness covet
+ covets covet
+ cow cow
+ coward coward
+ cowarded coward
+ cowardice cowardic
+ cowardly cowardli
+ cowards coward
+ cowardship cowardship
+ cowish cowish
+ cowl cowl
+ cowslip cowslip
+ cowslips cowslip
+ cox cox
+ coxcomb coxcomb
+ coxcombs coxcomb
+ coy coi
+ coystrill coystril
+ coz coz
+ cozen cozen
+ cozenage cozenag
+ cozened cozen
+ cozener cozen
+ cozeners cozen
+ cozening cozen
+ coziers cozier
+ crab crab
+ crabbed crab
+ crabs crab
+ crack crack
+ cracked crack
+ cracker cracker
+ crackers cracker
+ cracking crack
+ cracks crack
+ cradle cradl
+ cradled cradl
+ cradles cradl
+ craft craft
+ crafted craft
+ craftied crafti
+ craftier craftier
+ craftily craftili
+ crafts craft
+ craftsmen craftsmen
+ crafty crafti
+ cram cram
+ cramm cramm
+ cramp cramp
+ cramps cramp
+ crams cram
+ cranking crank
+ cranks crank
+ cranmer cranmer
+ crannied cranni
+ crannies cranni
+ cranny cranni
+ crants crant
+ crare crare
+ crash crash
+ crassus crassu
+ crav crav
+ crave crave
+ craved crave
+ craven craven
+ cravens craven
+ craves crave
+ craveth craveth
+ craving crave
+ crawl crawl
+ crawling crawl
+ crawls crawl
+ craz craz
+ crazed craze
+ crazy crazi
+ creaking creak
+ cream cream
+ create creat
+ created creat
+ creates creat
+ creating creat
+ creation creation
+ creator creator
+ creature creatur
+ creatures creatur
+ credence credenc
+ credent credent
+ credible credibl
+ credit credit
+ creditor creditor
+ creditors creditor
+ credo credo
+ credulity credul
+ credulous credul
+ creed creed
+ creek creek
+ creeks creek
+ creep creep
+ creeping creep
+ creeps creep
+ crept crept
+ crescent crescent
+ crescive cresciv
+ cressets cresset
+ cressid cressid
+ cressida cressida
+ cressids cressid
+ cressy cressi
+ crest crest
+ crested crest
+ crestfall crestfal
+ crestless crestless
+ crests crest
+ cretan cretan
+ crete crete
+ crevice crevic
+ crew crew
+ crews crew
+ crib crib
+ cribb cribb
+ cribs crib
+ cricket cricket
+ crickets cricket
+ cried cri
+ criedst criedst
+ crier crier
+ cries cri
+ criest criest
+ crieth crieth
+ crime crime
+ crimeful crime
+ crimeless crimeless
+ crimes crime
+ criminal crimin
+ crimson crimson
+ cringe cring
+ cripple crippl
+ crisp crisp
+ crisped crisp
+ crispian crispian
+ crispianus crispianu
+ crispin crispin
+ critic critic
+ critical critic
+ critics critic
+ croak croak
+ croaking croak
+ croaks croak
+ crocodile crocodil
+ cromer cromer
+ cromwell cromwel
+ crone crone
+ crook crook
+ crookback crookback
+ crooked crook
+ crooking crook
+ crop crop
+ cropp cropp
+ crosby crosbi
+ cross cross
+ crossed cross
+ crosses cross
+ crossest crossest
+ crossing cross
+ crossings cross
+ crossly crossli
+ crossness cross
+ crost crost
+ crotchets crotchet
+ crouch crouch
+ crouching crouch
+ crow crow
+ crowd crowd
+ crowded crowd
+ crowding crowd
+ crowds crowd
+ crowflowers crowflow
+ crowing crow
+ crowkeeper crowkeep
+ crown crown
+ crowned crown
+ crowner crowner
+ crownet crownet
+ crownets crownet
+ crowning crown
+ crowns crown
+ crows crow
+ crudy crudi
+ cruel cruel
+ cruell cruell
+ crueller crueller
+ cruelly cruelli
+ cruels cruel
+ cruelty cruelti
+ crum crum
+ crumble crumbl
+ crumbs crumb
+ crupper crupper
+ crusadoes crusado
+ crush crush
+ crushed crush
+ crushest crushest
+ crushing crush
+ crust crust
+ crusts crust
+ crusty crusti
+ crutch crutch
+ crutches crutch
+ cry cry
+ crying cry
+ crystal crystal
+ crystalline crystallin
+ crystals crystal
+ cub cub
+ cubbert cubbert
+ cubiculo cubiculo
+ cubit cubit
+ cubs cub
+ cuckold cuckold
+ cuckoldly cuckoldli
+ cuckolds cuckold
+ cuckoo cuckoo
+ cucullus cucullu
+ cudgel cudgel
+ cudgeled cudgel
+ cudgell cudgel
+ cudgelling cudgel
+ cudgels cudgel
+ cue cue
+ cues cue
+ cuff cuff
+ cuffs cuff
+ cuique cuiqu
+ cull cull
+ culling cull
+ cullion cullion
+ cullionly cullionli
+ cullions cullion
+ culpable culpabl
+ culverin culverin
+ cum cum
+ cumber cumber
+ cumberland cumberland
+ cunning cun
+ cunningly cunningli
+ cunnings cun
+ cuore cuor
+ cup cup
+ cupbearer cupbear
+ cupboarding cupboard
+ cupid cupid
+ cupids cupid
+ cuppele cuppel
+ cups cup
+ cur cur
+ curan curan
+ curate curat
+ curb curb
+ curbed curb
+ curbing curb
+ curbs curb
+ curd curd
+ curdied curdi
+ curds curd
+ cure cure
+ cured cure
+ cureless cureless
+ curer curer
+ cures cure
+ curfew curfew
+ curing cure
+ curio curio
+ curiosity curios
+ curious curiou
+ curiously curious
+ curl curl
+ curled curl
+ curling curl
+ curls curl
+ currance curranc
+ currants currant
+ current current
+ currents current
+ currish currish
+ curry curri
+ curs cur
+ curse curs
+ cursed curs
+ curses curs
+ cursies cursi
+ cursing curs
+ cursorary cursorari
+ curst curst
+ curster curster
+ curstest curstest
+ curstness curst
+ cursy cursi
+ curtail curtail
+ curtain curtain
+ curtains curtain
+ curtal curtal
+ curtis curti
+ curtle curtl
+ curtsied curtsi
+ curtsies curtsi
+ curtsy curtsi
+ curvet curvet
+ curvets curvet
+ cushes cush
+ cushion cushion
+ cushions cushion
+ custalorum custalorum
+ custard custard
+ custody custodi
+ custom custom
+ customary customari
+ customed custom
+ customer custom
+ customers custom
+ customs custom
+ custure custur
+ cut cut
+ cutler cutler
+ cutpurse cutpurs
+ cutpurses cutpurs
+ cuts cut
+ cutter cutter
+ cutting cut
+ cuttle cuttl
+ cxsar cxsar
+ cyclops cyclop
+ cydnus cydnu
+ cygnet cygnet
+ cygnets cygnet
+ cym cym
+ cymbals cymbal
+ cymbeline cymbelin
+ cyme cyme
+ cynic cynic
+ cynthia cynthia
+ cypress cypress
+ cypriot cypriot
+ cyprus cypru
+ cyrus cyru
+ cytherea cytherea
+ d d
+ dabbled dabbl
+ dace dace
+ dad dad
+ daedalus daedalu
+ daemon daemon
+ daff daff
+ daffed daf
+ daffest daffest
+ daffodils daffodil
+ dagger dagger
+ daggers dagger
+ dagonet dagonet
+ daily daili
+ daintier daintier
+ dainties dainti
+ daintiest daintiest
+ daintily daintili
+ daintiness dainti
+ daintry daintri
+ dainty dainti
+ daisied daisi
+ daisies daisi
+ daisy daisi
+ dale dale
+ dalliance dallianc
+ dallied dalli
+ dallies dalli
+ dally dalli
+ dallying dalli
+ dalmatians dalmatian
+ dam dam
+ damage damag
+ damascus damascu
+ damask damask
+ damasked damask
+ dame dame
+ dames dame
+ damm damm
+ damn damn
+ damnable damnabl
+ damnably damnabl
+ damnation damnat
+ damned damn
+ damns damn
+ damoiselle damoisel
+ damon damon
+ damosella damosella
+ damp damp
+ dams dam
+ damsel damsel
+ damsons damson
+ dan dan
+ danc danc
+ dance danc
+ dancer dancer
+ dances danc
+ dancing danc
+ dandle dandl
+ dandy dandi
+ dane dane
+ dang dang
+ danger danger
+ dangerous danger
+ dangerously danger
+ dangers danger
+ dangling dangl
+ daniel daniel
+ danish danish
+ dank dank
+ dankish dankish
+ danskers dansker
+ daphne daphn
+ dappled dappl
+ dapples dappl
+ dar dar
+ dardan dardan
+ dardanian dardanian
+ dardanius dardaniu
+ dare dare
+ dared dare
+ dareful dare
+ dares dare
+ darest darest
+ daring dare
+ darius dariu
+ dark dark
+ darken darken
+ darkening darken
+ darkens darken
+ darker darker
+ darkest darkest
+ darkling darkl
+ darkly darkli
+ darkness dark
+ darling darl
+ darlings darl
+ darnel darnel
+ darraign darraign
+ dart dart
+ darted dart
+ darter darter
+ dartford dartford
+ darting dart
+ darts dart
+ dash dash
+ dashes dash
+ dashing dash
+ dastard dastard
+ dastards dastard
+ dat dat
+ datchet datchet
+ date date
+ dated date
+ dateless dateless
+ dates date
+ daub daub
+ daughter daughter
+ daughters daughter
+ daunt daunt
+ daunted daunt
+ dauntless dauntless
+ dauphin dauphin
+ daventry daventri
+ davy davi
+ daw daw
+ dawn dawn
+ dawning dawn
+ daws daw
+ day dai
+ daylight daylight
+ days dai
+ dazzle dazzl
+ dazzled dazzl
+ dazzling dazzl
+ de de
+ dead dead
+ deadly deadli
+ deaf deaf
+ deafing deaf
+ deafness deaf
+ deafs deaf
+ deal deal
+ dealer dealer
+ dealers dealer
+ dealest dealest
+ dealing deal
+ dealings deal
+ deals deal
+ dealt dealt
+ dean dean
+ deanery deaneri
+ dear dear
+ dearer dearer
+ dearest dearest
+ dearly dearli
+ dearness dear
+ dears dear
+ dearth dearth
+ dearths dearth
+ death death
+ deathbed deathb
+ deathful death
+ deaths death
+ deathsman deathsman
+ deathsmen deathsmen
+ debarred debar
+ debase debas
+ debate debat
+ debated debat
+ debatement debat
+ debateth debateth
+ debating debat
+ debauch debauch
+ debile debil
+ debility debil
+ debitor debitor
+ debonair debonair
+ deborah deborah
+ debosh debosh
+ debt debt
+ debted debt
+ debtor debtor
+ debtors debtor
+ debts debt
+ debuty debuti
+ decay decai
+ decayed decai
+ decayer decay
+ decaying decai
+ decays decai
+ deceas decea
+ decease deceas
+ deceased deceas
+ deceit deceit
+ deceitful deceit
+ deceits deceit
+ deceiv deceiv
+ deceivable deceiv
+ deceive deceiv
+ deceived deceiv
+ deceiver deceiv
+ deceivers deceiv
+ deceives deceiv
+ deceivest deceivest
+ deceiveth deceiveth
+ deceiving deceiv
+ december decemb
+ decent decent
+ deceptious decepti
+ decerns decern
+ decide decid
+ decides decid
+ decimation decim
+ decipher deciph
+ deciphers deciph
+ decision decis
+ decius deciu
+ deck deck
+ decking deck
+ decks deck
+ deckt deckt
+ declare declar
+ declares declar
+ declension declens
+ declensions declens
+ declin declin
+ decline declin
+ declined declin
+ declines declin
+ declining declin
+ decoct decoct
+ decorum decorum
+ decreas decrea
+ decrease decreas
+ decreasing decreas
+ decree decre
+ decreed decre
+ decrees decre
+ decrepit decrepit
+ dedicate dedic
+ dedicated dedic
+ dedicates dedic
+ dedication dedic
+ deed deed
+ deedless deedless
+ deeds deed
+ deem deem
+ deemed deem
+ deep deep
+ deeper deeper
+ deepest deepest
+ deeply deepli
+ deeps deep
+ deepvow deepvow
+ deer deer
+ deesse deess
+ defac defac
+ deface defac
+ defaced defac
+ defacer defac
+ defacers defac
+ defacing defac
+ defam defam
+ default default
+ defeat defeat
+ defeated defeat
+ defeats defeat
+ defeatures defeatur
+ defect defect
+ defective defect
+ defects defect
+ defence defenc
+ defences defenc
+ defend defend
+ defendant defend
+ defended defend
+ defender defend
+ defenders defend
+ defending defend
+ defends defend
+ defense defens
+ defensible defens
+ defensive defens
+ defer defer
+ deferr deferr
+ defiance defianc
+ deficient defici
+ defied defi
+ defies defi
+ defil defil
+ defile defil
+ defiler defil
+ defiles defil
+ defiling defil
+ define defin
+ definement defin
+ definite definit
+ definitive definit
+ definitively definit
+ deflow deflow
+ deflower deflow
+ deflowered deflow
+ deform deform
+ deformed deform
+ deformities deform
+ deformity deform
+ deftly deftli
+ defunct defunct
+ defunction defunct
+ defuse defus
+ defy defi
+ defying defi
+ degenerate degener
+ degraded degrad
+ degree degre
+ degrees degre
+ deified deifi
+ deifying deifi
+ deign deign
+ deigned deign
+ deiphobus deiphobu
+ deities deiti
+ deity deiti
+ deja deja
+ deject deject
+ dejected deject
+ delabreth delabreth
+ delay delai
+ delayed delai
+ delaying delai
+ delays delai
+ delectable delect
+ deliberate deliber
+ delicate delic
+ delicates delic
+ delicious delici
+ deliciousness delici
+ delight delight
+ delighted delight
+ delightful delight
+ delights delight
+ delinquents delinqu
+ deliv deliv
+ deliver deliv
+ deliverance deliver
+ delivered deliv
+ delivering deliv
+ delivers deliv
+ delivery deliveri
+ delphos delpho
+ deluded delud
+ deluding delud
+ deluge delug
+ delve delv
+ delver delver
+ delves delv
+ demand demand
+ demanded demand
+ demanding demand
+ demands demand
+ demean demean
+ demeanor demeanor
+ demeanour demeanour
+ demerits demerit
+ demesnes demesn
+ demetrius demetriu
+ demi demi
+ demigod demigod
+ demise demis
+ demoiselles demoisel
+ demon demon
+ demonstrable demonstr
+ demonstrate demonstr
+ demonstrated demonstr
+ demonstrating demonstr
+ demonstration demonstr
+ demonstrative demonstr
+ demure demur
+ demurely demur
+ demuring demur
+ den den
+ denay denai
+ deni deni
+ denial denial
+ denials denial
+ denied deni
+ denier denier
+ denies deni
+ deniest deniest
+ denis deni
+ denmark denmark
+ dennis denni
+ denny denni
+ denote denot
+ denoted denot
+ denotement denot
+ denounc denounc
+ denounce denounc
+ denouncing denounc
+ dens den
+ denunciation denunci
+ deny deni
+ denying deni
+ deo deo
+ depart depart
+ departed depart
+ departest departest
+ departing depart
+ departure departur
+ depeche depech
+ depend depend
+ dependant depend
+ dependants depend
+ depended depend
+ dependence depend
+ dependences depend
+ dependency depend
+ dependent depend
+ dependents depend
+ depender depend
+ depending depend
+ depends depend
+ deplore deplor
+ deploring deplor
+ depopulate depopul
+ depos depo
+ depose depos
+ deposed depos
+ deposing depos
+ depositaries depositari
+ deprav deprav
+ depravation deprav
+ deprave deprav
+ depraved deprav
+ depraves deprav
+ depress depress
+ depriv depriv
+ deprive depriv
+ depth depth
+ depths depth
+ deputation deput
+ depute deput
+ deputed deput
+ deputies deputi
+ deputing deput
+ deputy deputi
+ deracinate deracin
+ derby derbi
+ dercetas derceta
+ dere dere
+ derides derid
+ derision deris
+ deriv deriv
+ derivation deriv
+ derivative deriv
+ derive deriv
+ derived deriv
+ derives deriv
+ derogate derog
+ derogately derog
+ derogation derog
+ des de
+ desartless desartless
+ descant descant
+ descend descend
+ descended descend
+ descending descend
+ descends descend
+ descension descens
+ descent descent
+ descents descent
+ describe describ
+ described describ
+ describes describ
+ descried descri
+ description descript
+ descriptions descript
+ descry descri
+ desdemon desdemon
+ desdemona desdemona
+ desert desert
+ deserts desert
+ deserv deserv
+ deserve deserv
+ deserved deserv
+ deservedly deservedli
+ deserver deserv
+ deservers deserv
+ deserves deserv
+ deservest deservest
+ deserving deserv
+ deservings deserv
+ design design
+ designment design
+ designments design
+ designs design
+ desir desir
+ desire desir
+ desired desir
+ desirers desir
+ desires desir
+ desirest desirest
+ desiring desir
+ desirous desir
+ desist desist
+ desk desk
+ desolate desol
+ desolation desol
+ desp desp
+ despair despair
+ despairing despair
+ despairs despair
+ despatch despatch
+ desperate desper
+ desperately desper
+ desperation desper
+ despis despi
+ despise despis
+ despised despis
+ despiser despis
+ despiseth despiseth
+ despising despis
+ despite despit
+ despiteful despit
+ despoiled despoil
+ dest dest
+ destin destin
+ destined destin
+ destinies destini
+ destiny destini
+ destitute destitut
+ destroy destroi
+ destroyed destroi
+ destroyer destroy
+ destroyers destroy
+ destroying destroi
+ destroys destroi
+ destruction destruct
+ destructions destruct
+ det det
+ detain detain
+ detains detain
+ detect detect
+ detected detect
+ detecting detect
+ detection detect
+ detector detector
+ detects detect
+ detention detent
+ determin determin
+ determinate determin
+ determination determin
+ determinations determin
+ determine determin
+ determined determin
+ determines determin
+ detest detest
+ detestable detest
+ detested detest
+ detesting detest
+ detests detest
+ detract detract
+ detraction detract
+ detractions detract
+ deucalion deucalion
+ deuce deuc
+ deum deum
+ deux deux
+ devant devant
+ devesting devest
+ device devic
+ devices devic
+ devil devil
+ devilish devilish
+ devils devil
+ devis devi
+ devise devis
+ devised devis
+ devises devis
+ devising devis
+ devoid devoid
+ devonshire devonshir
+ devote devot
+ devoted devot
+ devotion devot
+ devour devour
+ devoured devour
+ devourers devour
+ devouring devour
+ devours devour
+ devout devout
+ devoutly devoutli
+ dew dew
+ dewberries dewberri
+ dewdrops dewdrop
+ dewlap dewlap
+ dewlapp dewlapp
+ dews dew
+ dewy dewi
+ dexter dexter
+ dexteriously dexteri
+ dexterity dexter
+ di di
+ diable diabl
+ diablo diablo
+ diadem diadem
+ dial dial
+ dialect dialect
+ dialogue dialogu
+ dialogued dialogu
+ dials dial
+ diameter diamet
+ diamond diamond
+ diamonds diamond
+ dian dian
+ diana diana
+ diaper diaper
+ dibble dibbl
+ dic dic
+ dice dice
+ dicers dicer
+ dich dich
+ dick dick
+ dickens dicken
+ dickon dickon
+ dicky dicki
+ dictator dictat
+ diction diction
+ dictynna dictynna
+ did did
+ diddle diddl
+ didest didest
+ dido dido
+ didst didst
+ die die
+ died di
+ diedst diedst
+ dies di
+ diest diest
+ diet diet
+ dieted diet
+ dieter dieter
+ dieu dieu
+ diff diff
+ differ differ
+ difference differ
+ differences differ
+ differency differ
+ different differ
+ differing differ
+ differs differ
+ difficile difficil
+ difficult difficult
+ difficulties difficulti
+ difficulty difficulti
+ diffidence diffid
+ diffidences diffid
+ diffus diffu
+ diffused diffus
+ diffusest diffusest
+ dig dig
+ digest digest
+ digested digest
+ digestion digest
+ digestions digest
+ digg digg
+ digging dig
+ dighton dighton
+ dignified dignifi
+ dignifies dignifi
+ dignify dignifi
+ dignities digniti
+ dignity digniti
+ digress digress
+ digressing digress
+ digression digress
+ digs dig
+ digt digt
+ dilate dilat
+ dilated dilat
+ dilations dilat
+ dilatory dilatori
+ dild dild
+ dildos dildo
+ dilemma dilemma
+ dilemmas dilemma
+ diligence dilig
+ diligent dilig
+ diluculo diluculo
+ dim dim
+ dimension dimens
+ dimensions dimens
+ diminish diminish
+ diminishing diminish
+ diminution diminut
+ diminutive diminut
+ diminutives diminut
+ dimm dimm
+ dimmed dim
+ dimming dim
+ dimpled dimpl
+ dimples dimpl
+ dims dim
+ din din
+ dine dine
+ dined dine
+ diner diner
+ dines dine
+ ding ding
+ dining dine
+ dinner dinner
+ dinners dinner
+ dinnertime dinnertim
+ dint dint
+ diomed diom
+ diomede diomed
+ diomedes diomed
+ dion dion
+ dip dip
+ dipp dipp
+ dipping dip
+ dips dip
+ dir dir
+ dire dire
+ direct direct
+ directed direct
+ directing direct
+ direction direct
+ directions direct
+ directitude directitud
+ directive direct
+ directly directli
+ directs direct
+ direful dire
+ direness dire
+ direst direst
+ dirge dirg
+ dirges dirg
+ dirt dirt
+ dirty dirti
+ dis di
+ disability disabl
+ disable disabl
+ disabled disabl
+ disabling disabl
+ disadvantage disadvantag
+ disagree disagre
+ disallow disallow
+ disanimates disanim
+ disannul disannul
+ disannuls disannul
+ disappointed disappoint
+ disarm disarm
+ disarmed disarm
+ disarmeth disarmeth
+ disarms disarm
+ disaster disast
+ disasters disast
+ disastrous disastr
+ disbench disbench
+ disbranch disbranch
+ disburdened disburden
+ disburs disbur
+ disburse disburs
+ disbursed disburs
+ discandy discandi
+ discandying discandi
+ discard discard
+ discarded discard
+ discase discas
+ discased discas
+ discern discern
+ discerner discern
+ discerning discern
+ discernings discern
+ discerns discern
+ discharg discharg
+ discharge discharg
+ discharged discharg
+ discharging discharg
+ discipled discipl
+ disciples discipl
+ disciplin disciplin
+ discipline disciplin
+ disciplined disciplin
+ disciplines disciplin
+ disclaim disclaim
+ disclaiming disclaim
+ disclaims disclaim
+ disclos disclo
+ disclose disclos
+ disclosed disclos
+ discloses disclos
+ discolour discolour
+ discoloured discolour
+ discolours discolour
+ discomfit discomfit
+ discomfited discomfit
+ discomfiture discomfitur
+ discomfort discomfort
+ discomfortable discomfort
+ discommend discommend
+ disconsolate disconsol
+ discontent discont
+ discontented discont
+ discontentedly discontentedli
+ discontenting discont
+ discontents discont
+ discontinue discontinu
+ discontinued discontinu
+ discord discord
+ discordant discord
+ discords discord
+ discourse discours
+ discoursed discours
+ discourser discours
+ discourses discours
+ discoursive discours
+ discourtesy discourtesi
+ discov discov
+ discover discov
+ discovered discov
+ discoverers discover
+ discoveries discoveri
+ discovering discov
+ discovers discov
+ discovery discoveri
+ discredit discredit
+ discredited discredit
+ discredits discredit
+ discreet discreet
+ discreetly discreetli
+ discretion discret
+ discretions discret
+ discuss discuss
+ disdain disdain
+ disdained disdain
+ disdaineth disdaineth
+ disdainful disdain
+ disdainfully disdainfulli
+ disdaining disdain
+ disdains disdain
+ disdnguish disdnguish
+ diseas disea
+ disease diseas
+ diseased diseas
+ diseases diseas
+ disedg disedg
+ disembark disembark
+ disfigure disfigur
+ disfigured disfigur
+ disfurnish disfurnish
+ disgorge disgorg
+ disgrac disgrac
+ disgrace disgrac
+ disgraced disgrac
+ disgraceful disgrac
+ disgraces disgrac
+ disgracing disgrac
+ disgracious disgraci
+ disguis disgui
+ disguise disguis
+ disguised disguis
+ disguiser disguis
+ disguises disguis
+ disguising disguis
+ dish dish
+ dishabited dishabit
+ dishclout dishclout
+ dishearten dishearten
+ disheartens dishearten
+ dishes dish
+ dishonest dishonest
+ dishonestly dishonestli
+ dishonesty dishonesti
+ dishonor dishonor
+ dishonorable dishonor
+ dishonors dishonor
+ dishonour dishonour
+ dishonourable dishonour
+ dishonoured dishonour
+ dishonours dishonour
+ disinherit disinherit
+ disinherited disinherit
+ disjoin disjoin
+ disjoining disjoin
+ disjoins disjoin
+ disjoint disjoint
+ disjunction disjunct
+ dislik dislik
+ dislike dislik
+ disliken disliken
+ dislikes dislik
+ dislimns dislimn
+ dislocate disloc
+ dislodg dislodg
+ disloyal disloy
+ disloyalty disloyalti
+ dismal dismal
+ dismantle dismantl
+ dismantled dismantl
+ dismask dismask
+ dismay dismai
+ dismayed dismai
+ dismemb dismemb
+ dismember dismemb
+ dismes dism
+ dismiss dismiss
+ dismissed dismiss
+ dismissing dismiss
+ dismission dismiss
+ dismount dismount
+ dismounted dismount
+ disnatur disnatur
+ disobedience disobedi
+ disobedient disobedi
+ disobey disobei
+ disobeys disobei
+ disorb disorb
+ disorder disord
+ disordered disord
+ disorderly disorderli
+ disorders disord
+ disparage disparag
+ disparagement disparag
+ disparagements disparag
+ dispark dispark
+ dispatch dispatch
+ dispensation dispens
+ dispense dispens
+ dispenses dispens
+ dispers disper
+ disperse dispers
+ dispersed dispers
+ dispersedly dispersedli
+ dispersing dispers
+ dispiteous dispit
+ displac displac
+ displace displac
+ displaced displac
+ displant displant
+ displanting displant
+ display displai
+ displayed displai
+ displeas displea
+ displease displeas
+ displeased displeas
+ displeasing displeas
+ displeasure displeasur
+ displeasures displeasur
+ disponge dispong
+ disport disport
+ disports disport
+ dispos dispo
+ dispose dispos
+ disposed dispos
+ disposer dispos
+ disposing dispos
+ disposition disposit
+ dispositions disposit
+ dispossess dispossess
+ dispossessing dispossess
+ disprais disprai
+ dispraise disprais
+ dispraising disprais
+ dispraisingly dispraisingli
+ dispropertied disproperti
+ disproportion disproport
+ disproportioned disproport
+ disprov disprov
+ disprove disprov
+ disproved disprov
+ dispursed dispurs
+ disputable disput
+ disputation disput
+ disputations disput
+ dispute disput
+ disputed disput
+ disputes disput
+ disputing disput
+ disquantity disquant
+ disquiet disquiet
+ disquietly disquietli
+ disrelish disrelish
+ disrobe disrob
+ disseat disseat
+ dissemble dissembl
+ dissembled dissembl
+ dissembler dissembl
+ dissemblers dissembl
+ dissembling dissembl
+ dissembly dissembl
+ dissension dissens
+ dissensions dissens
+ dissentious dissenti
+ dissever dissev
+ dissipation dissip
+ dissolute dissolut
+ dissolutely dissolut
+ dissolution dissolut
+ dissolutions dissolut
+ dissolv dissolv
+ dissolve dissolv
+ dissolved dissolv
+ dissolves dissolv
+ dissuade dissuad
+ dissuaded dissuad
+ distaff distaff
+ distaffs distaff
+ distain distain
+ distains distain
+ distance distanc
+ distant distant
+ distaste distast
+ distasted distast
+ distasteful distast
+ distemp distemp
+ distemper distemp
+ distemperature distemperatur
+ distemperatures distemperatur
+ distempered distemp
+ distempering distemp
+ distil distil
+ distill distil
+ distillation distil
+ distilled distil
+ distills distil
+ distilment distil
+ distinct distinct
+ distinction distinct
+ distinctly distinctli
+ distingue distingu
+ distinguish distinguish
+ distinguishes distinguish
+ distinguishment distinguish
+ distract distract
+ distracted distract
+ distractedly distractedli
+ distraction distract
+ distractions distract
+ distracts distract
+ distrain distrain
+ distraught distraught
+ distress distress
+ distressed distress
+ distresses distress
+ distressful distress
+ distribute distribut
+ distributed distribut
+ distribution distribut
+ distrust distrust
+ distrustful distrust
+ disturb disturb
+ disturbed disturb
+ disturbers disturb
+ disturbing disturb
+ disunite disunit
+ disvalued disvalu
+ disvouch disvouch
+ dit dit
+ ditch ditch
+ ditchers ditcher
+ ditches ditch
+ dites dite
+ ditties ditti
+ ditty ditti
+ diurnal diurnal
+ div div
+ dive dive
+ diver diver
+ divers diver
+ diversely divers
+ diversity divers
+ divert divert
+ diverted divert
+ diverts divert
+ dives dive
+ divest divest
+ dividable divid
+ dividant divid
+ divide divid
+ divided divid
+ divides divid
+ divideth divideth
+ divin divin
+ divination divin
+ divine divin
+ divinely divin
+ divineness divin
+ diviner divin
+ divines divin
+ divinest divinest
+ divining divin
+ divinity divin
+ division divis
+ divisions divis
+ divorc divorc
+ divorce divorc
+ divorced divorc
+ divorcement divorc
+ divorcing divorc
+ divulg divulg
+ divulge divulg
+ divulged divulg
+ divulging divulg
+ dizy dizi
+ dizzy dizzi
+ do do
+ doating doat
+ dobbin dobbin
+ dock dock
+ docks dock
+ doct doct
+ doctor doctor
+ doctors doctor
+ doctrine doctrin
+ document document
+ dodge dodg
+ doe doe
+ doer doer
+ doers doer
+ does doe
+ doest doest
+ doff doff
+ dog dog
+ dogberry dogberri
+ dogfish dogfish
+ dogg dogg
+ dogged dog
+ dogs dog
+ doigts doigt
+ doing do
+ doings do
+ doit doit
+ doits doit
+ dolabella dolabella
+ dole dole
+ doleful dole
+ doll doll
+ dollar dollar
+ dollars dollar
+ dolor dolor
+ dolorous dolor
+ dolour dolour
+ dolours dolour
+ dolphin dolphin
+ dolt dolt
+ dolts dolt
+ domestic domest
+ domestics domest
+ dominance domin
+ dominations domin
+ dominator domin
+ domine domin
+ domineer domin
+ domineering domin
+ dominical domin
+ dominion dominion
+ dominions dominion
+ domitius domitiu
+ dommelton dommelton
+ don don
+ donalbain donalbain
+ donation donat
+ donc donc
+ doncaster doncast
+ done done
+ dong dong
+ donn donn
+ donne donn
+ donner donner
+ donnerai donnerai
+ doom doom
+ doomsday doomsdai
+ door door
+ doorkeeper doorkeep
+ doors door
+ dorcas dorca
+ doreus doreu
+ doricles doricl
+ dormouse dormous
+ dorothy dorothi
+ dorset dorset
+ dorsetshire dorsetshir
+ dost dost
+ dotage dotag
+ dotant dotant
+ dotard dotard
+ dotards dotard
+ dote dote
+ doted dote
+ doters doter
+ dotes dote
+ doteth doteth
+ doth doth
+ doting dote
+ double doubl
+ doubled doubl
+ doubleness doubl
+ doubler doubler
+ doublet doublet
+ doublets doublet
+ doubling doubl
+ doubly doubli
+ doubt doubt
+ doubted doubt
+ doubtful doubt
+ doubtfully doubtfulli
+ doubting doubt
+ doubtless doubtless
+ doubts doubt
+ doug doug
+ dough dough
+ doughty doughti
+ doughy doughi
+ douglas dougla
+ dout dout
+ doute dout
+ douts dout
+ dove dove
+ dovehouse dovehous
+ dover dover
+ doves dove
+ dow dow
+ dowager dowag
+ dowdy dowdi
+ dower dower
+ dowerless dowerless
+ dowers dower
+ dowlas dowla
+ dowle dowl
+ down down
+ downfall downfal
+ downright downright
+ downs down
+ downstairs downstair
+ downtrod downtrod
+ downward downward
+ downwards downward
+ downy downi
+ dowries dowri
+ dowry dowri
+ dowsabel dowsabel
+ doxy doxi
+ dozed doze
+ dozen dozen
+ dozens dozen
+ dozy dozi
+ drab drab
+ drabbing drab
+ drabs drab
+ drachma drachma
+ drachmas drachma
+ draff draff
+ drag drag
+ dragg dragg
+ dragged drag
+ dragging drag
+ dragon dragon
+ dragonish dragonish
+ dragons dragon
+ drain drain
+ drained drain
+ drains drain
+ drake drake
+ dram dram
+ dramatis dramati
+ drank drank
+ draught draught
+ draughts draught
+ drave drave
+ draw draw
+ drawbridge drawbridg
+ drawer drawer
+ drawers drawer
+ draweth draweth
+ drawing draw
+ drawling drawl
+ drawn drawn
+ draws draw
+ drayman drayman
+ draymen draymen
+ dread dread
+ dreaded dread
+ dreadful dread
+ dreadfully dreadfulli
+ dreading dread
+ dreads dread
+ dream dream
+ dreamer dreamer
+ dreamers dreamer
+ dreaming dream
+ dreams dream
+ dreamt dreamt
+ drearning drearn
+ dreary dreari
+ dreg dreg
+ dregs dreg
+ drench drench
+ drenched drench
+ dress dress
+ dressed dress
+ dresser dresser
+ dressing dress
+ dressings dress
+ drest drest
+ drew drew
+ dribbling dribbl
+ dried dri
+ drier drier
+ dries dri
+ drift drift
+ drily drili
+ drink drink
+ drinketh drinketh
+ drinking drink
+ drinkings drink
+ drinks drink
+ driv driv
+ drive drive
+ drivelling drivel
+ driven driven
+ drives drive
+ driveth driveth
+ driving drive
+ drizzle drizzl
+ drizzled drizzl
+ drizzles drizzl
+ droit droit
+ drollery drolleri
+ dromio dromio
+ dromios dromio
+ drone drone
+ drones drone
+ droop droop
+ droopeth droopeth
+ drooping droop
+ droops droop
+ drop drop
+ dropheir dropheir
+ droplets droplet
+ dropp dropp
+ dropper dropper
+ droppeth droppeth
+ dropping drop
+ droppings drop
+ drops drop
+ dropsied dropsi
+ dropsies dropsi
+ dropsy dropsi
+ dropt dropt
+ dross dross
+ drossy drossi
+ drought drought
+ drove drove
+ droven droven
+ drovier drovier
+ drown drown
+ drowned drown
+ drowning drown
+ drowns drown
+ drows drow
+ drowse drows
+ drowsily drowsili
+ drowsiness drowsi
+ drowsy drowsi
+ drudge drudg
+ drudgery drudgeri
+ drudges drudg
+ drug drug
+ drugg drugg
+ drugs drug
+ drum drum
+ drumble drumbl
+ drummer drummer
+ drumming drum
+ drums drum
+ drunk drunk
+ drunkard drunkard
+ drunkards drunkard
+ drunken drunken
+ drunkenly drunkenli
+ drunkenness drunken
+ dry dry
+ dryness dryness
+ dst dst
+ du du
+ dub dub
+ dubb dubb
+ ducat ducat
+ ducats ducat
+ ducdame ducdam
+ duchess duchess
+ duchies duchi
+ duchy duchi
+ duck duck
+ ducking duck
+ ducks duck
+ dudgeon dudgeon
+ due due
+ duellist duellist
+ duello duello
+ duer duer
+ dues due
+ duff duff
+ dug dug
+ dugs dug
+ duke duke
+ dukedom dukedom
+ dukedoms dukedom
+ dukes duke
+ dulcet dulcet
+ dulche dulch
+ dull dull
+ dullard dullard
+ duller duller
+ dullest dullest
+ dulling dull
+ dullness dull
+ dulls dull
+ dully dulli
+ dulness dul
+ duly duli
+ dumain dumain
+ dumb dumb
+ dumbe dumb
+ dumbly dumbl
+ dumbness dumb
+ dump dump
+ dumps dump
+ dun dun
+ duncan duncan
+ dung dung
+ dungeon dungeon
+ dungeons dungeon
+ dunghill dunghil
+ dunghills dunghil
+ dungy dungi
+ dunnest dunnest
+ dunsinane dunsinan
+ dunsmore dunsmor
+ dunstable dunstabl
+ dupp dupp
+ durance duranc
+ during dure
+ durst durst
+ dusky duski
+ dust dust
+ dusted dust
+ dusty dusti
+ dutch dutch
+ dutchman dutchman
+ duteous duteou
+ duties duti
+ dutiful duti
+ duty duti
+ dwarf dwarf
+ dwarfish dwarfish
+ dwell dwell
+ dwellers dweller
+ dwelling dwell
+ dwells dwell
+ dwelt dwelt
+ dwindle dwindl
+ dy dy
+ dye dye
+ dyed dy
+ dyer dyer
+ dying dy
+ e e
+ each each
+ eager eager
+ eagerly eagerli
+ eagerness eager
+ eagle eagl
+ eagles eagl
+ eaning ean
+ eanlings eanl
+ ear ear
+ earing ear
+ earl earl
+ earldom earldom
+ earlier earlier
+ earliest earliest
+ earliness earli
+ earls earl
+ early earli
+ earn earn
+ earned earn
+ earnest earnest
+ earnestly earnestli
+ earnestness earnest
+ earns earn
+ ears ear
+ earth earth
+ earthen earthen
+ earthlier earthlier
+ earthly earthli
+ earthquake earthquak
+ earthquakes earthquak
+ earthy earthi
+ eas ea
+ ease eas
+ eased eas
+ easeful eas
+ eases eas
+ easier easier
+ easiest easiest
+ easiliest easiliest
+ easily easili
+ easiness easi
+ easing eas
+ east east
+ eastcheap eastcheap
+ easter easter
+ eastern eastern
+ eastward eastward
+ easy easi
+ eat eat
+ eaten eaten
+ eater eater
+ eaters eater
+ eating eat
+ eats eat
+ eaux eaux
+ eaves eav
+ ebb ebb
+ ebbing eb
+ ebbs ebb
+ ebon ebon
+ ebony eboni
+ ebrew ebrew
+ ecce ecc
+ echapper echapp
+ echo echo
+ echoes echo
+ eclips eclip
+ eclipse eclips
+ eclipses eclips
+ ecolier ecoli
+ ecoutez ecoutez
+ ecstacy ecstaci
+ ecstasies ecstasi
+ ecstasy ecstasi
+ ecus ecu
+ eden eden
+ edg edg
+ edgar edgar
+ edge edg
+ edged edg
+ edgeless edgeless
+ edges edg
+ edict edict
+ edicts edict
+ edifice edific
+ edifices edific
+ edified edifi
+ edifies edifi
+ edition edit
+ edm edm
+ edmund edmund
+ edmunds edmund
+ edmundsbury edmundsburi
+ educate educ
+ educated educ
+ education educ
+ edward edward
+ eel eel
+ eels eel
+ effect effect
+ effected effect
+ effectless effectless
+ effects effect
+ effectual effectu
+ effectually effectu
+ effeminate effemin
+ effigies effigi
+ effus effu
+ effuse effus
+ effusion effus
+ eftest eftest
+ egal egal
+ egally egal
+ eget eget
+ egeus egeu
+ egg egg
+ eggs egg
+ eggshell eggshel
+ eglamour eglamour
+ eglantine eglantin
+ egma egma
+ ego ego
+ egregious egregi
+ egregiously egregi
+ egress egress
+ egypt egypt
+ egyptian egyptian
+ egyptians egyptian
+ eie eie
+ eight eight
+ eighteen eighteen
+ eighth eighth
+ eightpenny eightpenni
+ eighty eighti
+ eisel eisel
+ either either
+ eject eject
+ eke ek
+ el el
+ elbe elb
+ elbow elbow
+ elbows elbow
+ eld eld
+ elder elder
+ elders elder
+ eldest eldest
+ eleanor eleanor
+ elect elect
+ elected elect
+ election elect
+ elegancy eleg
+ elegies elegi
+ element element
+ elements element
+ elephant eleph
+ elephants eleph
+ elevated elev
+ eleven eleven
+ eleventh eleventh
+ elf elf
+ elflocks elflock
+ eliads eliad
+ elinor elinor
+ elizabeth elizabeth
+ ell ell
+ elle ell
+ ellen ellen
+ elm elm
+ eloquence eloqu
+ eloquent eloqu
+ else els
+ elsewhere elsewher
+ elsinore elsinor
+ eltham eltham
+ elves elv
+ elvish elvish
+ ely eli
+ elysium elysium
+ em em
+ emballing embal
+ embalm embalm
+ embalms embalm
+ embark embark
+ embarked embark
+ embarquements embarqu
+ embassade embassad
+ embassage embassag
+ embassies embassi
+ embassy embassi
+ embattailed embattail
+ embattl embattl
+ embattle embattl
+ embay embai
+ embellished embellish
+ embers ember
+ emblaze emblaz
+ emblem emblem
+ emblems emblem
+ embodied embodi
+ embold embold
+ emboldens embolden
+ emboss emboss
+ embossed emboss
+ embounded embound
+ embowel embowel
+ embowell embowel
+ embrac embrac
+ embrace embrac
+ embraced embrac
+ embracement embrac
+ embracements embrac
+ embraces embrac
+ embracing embrac
+ embrasures embrasur
+ embroider embroid
+ embroidery embroideri
+ emhracing emhrac
+ emilia emilia
+ eminence emin
+ eminent emin
+ eminently emin
+ emmanuel emmanuel
+ emnity emniti
+ empale empal
+ emperal emper
+ emperess emperess
+ emperial emperi
+ emperor emperor
+ empery emperi
+ emphasis emphasi
+ empire empir
+ empirics empir
+ empiricutic empiricut
+ empleached empleach
+ employ emploi
+ employed emploi
+ employer employ
+ employment employ
+ employments employ
+ empoison empoison
+ empress empress
+ emptied empti
+ emptier emptier
+ empties empti
+ emptiness empti
+ empty empti
+ emptying empti
+ emulate emul
+ emulation emul
+ emulations emul
+ emulator emul
+ emulous emul
+ en en
+ enact enact
+ enacted enact
+ enacts enact
+ enactures enactur
+ enamell enamel
+ enamelled enamel
+ enamour enamour
+ enamoured enamour
+ enanmour enanmour
+ encamp encamp
+ encamped encamp
+ encave encav
+ enceladus enceladu
+ enchaf enchaf
+ enchafed enchaf
+ enchant enchant
+ enchanted enchant
+ enchanting enchant
+ enchantingly enchantingli
+ enchantment enchant
+ enchantress enchantress
+ enchants enchant
+ enchas encha
+ encircle encircl
+ encircled encircl
+ enclos enclo
+ enclose enclos
+ enclosed enclos
+ encloses enclos
+ encloseth encloseth
+ enclosing enclos
+ enclouded encloud
+ encompass encompass
+ encompassed encompass
+ encompasseth encompasseth
+ encompassment encompass
+ encore encor
+ encorporal encorpor
+ encount encount
+ encounter encount
+ encountered encount
+ encounters encount
+ encourage encourag
+ encouraged encourag
+ encouragement encourag
+ encrimsoned encrimson
+ encroaching encroach
+ encumb encumb
+ end end
+ endamage endamag
+ endamagement endamag
+ endanger endang
+ endart endart
+ endear endear
+ endeared endear
+ endeavour endeavour
+ endeavours endeavour
+ ended end
+ ender ender
+ ending end
+ endings end
+ endite endit
+ endless endless
+ endow endow
+ endowed endow
+ endowments endow
+ endows endow
+ ends end
+ endu endu
+ endue endu
+ endur endur
+ endurance endur
+ endure endur
+ endured endur
+ endures endur
+ enduring endur
+ endymion endymion
+ eneas enea
+ enemies enemi
+ enemy enemi
+ enernies enerni
+ enew enew
+ enfeebled enfeebl
+ enfeebles enfeebl
+ enfeoff enfeoff
+ enfetter enfett
+ enfoldings enfold
+ enforc enforc
+ enforce enforc
+ enforced enforc
+ enforcedly enforcedli
+ enforcement enforc
+ enforces enforc
+ enforcest enforcest
+ enfranched enfranch
+ enfranchis enfranchi
+ enfranchise enfranchis
+ enfranchised enfranchis
+ enfranchisement enfranchis
+ enfreed enfre
+ enfreedoming enfreedom
+ engag engag
+ engage engag
+ engaged engag
+ engagements engag
+ engaging engag
+ engaol engaol
+ engend engend
+ engender engend
+ engenders engend
+ engilds engild
+ engine engin
+ engineer engin
+ enginer engin
+ engines engin
+ engirt engirt
+ england england
+ english english
+ englishman englishman
+ englishmen englishmen
+ engluts englut
+ englutted englut
+ engraffed engraf
+ engraft engraft
+ engrafted engraft
+ engrav engrav
+ engrave engrav
+ engross engross
+ engrossed engross
+ engrossest engrossest
+ engrossing engross
+ engrossments engross
+ enguard enguard
+ enigma enigma
+ enigmatical enigmat
+ enjoin enjoin
+ enjoined enjoin
+ enjoy enjoi
+ enjoyed enjoi
+ enjoyer enjoy
+ enjoying enjoi
+ enjoys enjoi
+ enkindle enkindl
+ enkindled enkindl
+ enlard enlard
+ enlarg enlarg
+ enlarge enlarg
+ enlarged enlarg
+ enlargement enlarg
+ enlargeth enlargeth
+ enlighten enlighten
+ enlink enlink
+ enmesh enmesh
+ enmities enmiti
+ enmity enmiti
+ ennoble ennobl
+ ennobled ennobl
+ enobarb enobarb
+ enobarbus enobarbu
+ enon enon
+ enormity enorm
+ enormous enorm
+ enough enough
+ enow enow
+ enpatron enpatron
+ enpierced enpierc
+ enquir enquir
+ enquire enquir
+ enquired enquir
+ enrag enrag
+ enrage enrag
+ enraged enrag
+ enrages enrag
+ enrank enrank
+ enrapt enrapt
+ enrich enrich
+ enriched enrich
+ enriches enrich
+ enridged enridg
+ enrings enr
+ enrob enrob
+ enrobe enrob
+ enroll enrol
+ enrolled enrol
+ enrooted enroot
+ enrounded enround
+ enschedul enschedul
+ ensconce ensconc
+ ensconcing ensconc
+ enseamed enseam
+ ensear ensear
+ enseigne enseign
+ enseignez enseignez
+ ensemble ensembl
+ enshelter enshelt
+ enshielded enshield
+ enshrines enshrin
+ ensign ensign
+ ensigns ensign
+ enskied enski
+ ensman ensman
+ ensnare ensnar
+ ensnared ensnar
+ ensnareth ensnareth
+ ensteep ensteep
+ ensu ensu
+ ensue ensu
+ ensued ensu
+ ensues ensu
+ ensuing ensu
+ enswathed enswath
+ ent ent
+ entail entail
+ entame entam
+ entangled entangl
+ entangles entangl
+ entendre entendr
+ enter enter
+ entered enter
+ entering enter
+ enterprise enterpris
+ enterprises enterpris
+ enters enter
+ entertain entertain
+ entertained entertain
+ entertainer entertain
+ entertaining entertain
+ entertainment entertain
+ entertainments entertain
+ enthrall enthral
+ enthralled enthral
+ enthron enthron
+ enthroned enthron
+ entice entic
+ enticements entic
+ enticing entic
+ entire entir
+ entirely entir
+ entitle entitl
+ entitled entitl
+ entitling entitl
+ entomb entomb
+ entombed entomb
+ entrails entrail
+ entrance entranc
+ entrances entranc
+ entrap entrap
+ entrapp entrapp
+ entre entr
+ entreat entreat
+ entreated entreat
+ entreaties entreati
+ entreating entreat
+ entreatments entreat
+ entreats entreat
+ entreaty entreati
+ entrench entrench
+ entry entri
+ entwist entwist
+ envelop envelop
+ envenom envenom
+ envenomed envenom
+ envenoms envenom
+ envied envi
+ envies envi
+ envious enviou
+ enviously envious
+ environ environ
+ environed environ
+ envoy envoi
+ envy envi
+ envying envi
+ enwheel enwheel
+ enwombed enwomb
+ enwraps enwrap
+ ephesian ephesian
+ ephesians ephesian
+ ephesus ephesu
+ epicure epicur
+ epicurean epicurean
+ epicures epicur
+ epicurism epicur
+ epicurus epicuru
+ epidamnum epidamnum
+ epidaurus epidauru
+ epigram epigram
+ epilepsy epilepsi
+ epileptic epilept
+ epilogue epilogu
+ epilogues epilogu
+ epistles epistl
+ epistrophus epistrophu
+ epitaph epitaph
+ epitaphs epitaph
+ epithet epithet
+ epitheton epitheton
+ epithets epithet
+ epitome epitom
+ equal equal
+ equalities equal
+ equality equal
+ equall equal
+ equally equal
+ equalness equal
+ equals equal
+ equinoctial equinocti
+ equinox equinox
+ equipage equipag
+ equity equiti
+ equivocal equivoc
+ equivocate equivoc
+ equivocates equivoc
+ equivocation equivoc
+ equivocator equivoc
+ er er
+ erbear erbear
+ erbearing erbear
+ erbears erbear
+ erbeat erbeat
+ erblows erblow
+ erboard erboard
+ erborne erborn
+ ercame ercam
+ ercast ercast
+ ercharg ercharg
+ ercharged ercharg
+ ercharging ercharg
+ ercles ercl
+ ercome ercom
+ ercover ercov
+ ercrows ercrow
+ erdoing erdo
+ ere er
+ erebus erebu
+ erect erect
+ erected erect
+ erecting erect
+ erection erect
+ erects erect
+ erewhile erewhil
+ erflourish erflourish
+ erflow erflow
+ erflowing erflow
+ erflows erflow
+ erfraught erfraught
+ erga erga
+ ergalled ergal
+ erglanced erglanc
+ ergo ergo
+ ergone ergon
+ ergrow ergrow
+ ergrown ergrown
+ ergrowth ergrowth
+ erhang erhang
+ erhanging erhang
+ erhasty erhasti
+ erhear erhear
+ erheard erheard
+ eringoes eringo
+ erjoy erjoi
+ erleap erleap
+ erleaps erleap
+ erleavens erleaven
+ erlook erlook
+ erlooking erlook
+ ermaster ermast
+ ermengare ermengar
+ ermount ermount
+ ern ern
+ ernight ernight
+ eros ero
+ erpaid erpaid
+ erparted erpart
+ erpast erpast
+ erpays erpai
+ erpeer erpeer
+ erperch erperch
+ erpicturing erpictur
+ erpingham erpingham
+ erposting erpost
+ erpow erpow
+ erpress erpress
+ erpressed erpress
+ err err
+ errand errand
+ errands errand
+ errant errant
+ errate errat
+ erraught erraught
+ erreaches erreach
+ erred er
+ errest errest
+ erring er
+ erroneous erron
+ error error
+ errors error
+ errs err
+ errule errul
+ errun errun
+ erset erset
+ ershade ershad
+ ershades ershad
+ ershine ershin
+ ershot ershot
+ ersized ersiz
+ erskip erskip
+ erslips erslip
+ erspreads erspread
+ erst erst
+ erstare erstar
+ erstep erstep
+ erstunk erstunk
+ ersway erswai
+ ersways erswai
+ erswell erswel
+ erta erta
+ ertake ertak
+ erteemed erteem
+ erthrow erthrow
+ erthrown erthrown
+ erthrows erthrow
+ ertook ertook
+ ertop ertop
+ ertopping ertop
+ ertrip ertrip
+ erturn erturn
+ erudition erudit
+ eruption erupt
+ eruptions erupt
+ ervalues ervalu
+ erwalk erwalk
+ erwatch erwatch
+ erween erween
+ erweens erween
+ erweigh erweigh
+ erweighs erweigh
+ erwhelm erwhelm
+ erwhelmed erwhelm
+ erworn erworn
+ es es
+ escalus escalu
+ escap escap
+ escape escap
+ escaped escap
+ escapes escap
+ eschew eschew
+ escoted escot
+ esill esil
+ especial especi
+ especially especi
+ esperance esper
+ espials espial
+ espied espi
+ espies espi
+ espous espou
+ espouse espous
+ espy espi
+ esquire esquir
+ esquires esquir
+ essay essai
+ essays essai
+ essence essenc
+ essential essenti
+ essentially essenti
+ esses ess
+ essex essex
+ est est
+ establish establish
+ established establish
+ estate estat
+ estates estat
+ esteem esteem
+ esteemed esteem
+ esteemeth esteemeth
+ esteeming esteem
+ esteems esteem
+ estimable estim
+ estimate estim
+ estimation estim
+ estimations estim
+ estime estim
+ estranged estrang
+ estridge estridg
+ estridges estridg
+ et et
+ etc etc
+ etceteras etcetera
+ ete et
+ eternal etern
+ eternally etern
+ eterne etern
+ eternity etern
+ eterniz eterniz
+ etes et
+ ethiop ethiop
+ ethiope ethiop
+ ethiopes ethiop
+ ethiopian ethiopian
+ etna etna
+ eton eton
+ etre etr
+ eunuch eunuch
+ eunuchs eunuch
+ euphrates euphrat
+ euphronius euphroniu
+ euriphile euriphil
+ europa europa
+ europe europ
+ ev ev
+ evade evad
+ evades evad
+ evans evan
+ evasion evas
+ evasions evas
+ eve ev
+ even even
+ evening even
+ evenly evenli
+ event event
+ eventful event
+ events event
+ ever ever
+ everlasting everlast
+ everlastingly everlastingli
+ evermore evermor
+ every everi
+ everyone everyon
+ everything everyth
+ everywhere everywher
+ evidence evid
+ evidences evid
+ evident evid
+ evil evil
+ evilly evilli
+ evils evil
+ evitate evit
+ ewe ew
+ ewer ewer
+ ewers ewer
+ ewes ew
+ exact exact
+ exacted exact
+ exactest exactest
+ exacting exact
+ exaction exact
+ exactions exact
+ exactly exactli
+ exacts exact
+ exalt exalt
+ exalted exalt
+ examin examin
+ examination examin
+ examinations examin
+ examine examin
+ examined examin
+ examines examin
+ exampl exampl
+ example exampl
+ exampled exampl
+ examples exampl
+ exasperate exasper
+ exasperates exasper
+ exceed exce
+ exceeded exceed
+ exceedeth exceedeth
+ exceeding exceed
+ exceedingly exceedingli
+ exceeds exce
+ excel excel
+ excelled excel
+ excellence excel
+ excellencies excel
+ excellency excel
+ excellent excel
+ excellently excel
+ excelling excel
+ excels excel
+ except except
+ excepted except
+ excepting except
+ exception except
+ exceptions except
+ exceptless exceptless
+ excess excess
+ excessive excess
+ exchang exchang
+ exchange exchang
+ exchanged exchang
+ exchequer exchequ
+ exchequers exchequ
+ excite excit
+ excited excit
+ excitements excit
+ excites excit
+ exclaim exclaim
+ exclaims exclaim
+ exclamation exclam
+ exclamations exclam
+ excludes exclud
+ excommunicate excommun
+ excommunication excommun
+ excrement excrement
+ excrements excrement
+ excursion excurs
+ excursions excurs
+ excus excu
+ excusable excus
+ excuse excus
+ excused excus
+ excuses excus
+ excusez excusez
+ excusing excus
+ execrable execr
+ execrations execr
+ execute execut
+ executed execut
+ executing execut
+ execution execut
+ executioner execution
+ executioners execution
+ executor executor
+ executors executor
+ exempt exempt
+ exempted exempt
+ exequies exequi
+ exercise exercis
+ exercises exercis
+ exeter exet
+ exeunt exeunt
+ exhal exhal
+ exhalation exhal
+ exhalations exhal
+ exhale exhal
+ exhales exhal
+ exhaust exhaust
+ exhibit exhibit
+ exhibiters exhibit
+ exhibition exhibit
+ exhort exhort
+ exhortation exhort
+ exigent exig
+ exil exil
+ exile exil
+ exiled exil
+ exion exion
+ exist exist
+ exists exist
+ exit exit
+ exits exit
+ exorciser exorcis
+ exorcisms exorc
+ exorcist exorcist
+ expect expect
+ expectance expect
+ expectancy expect
+ expectation expect
+ expectations expect
+ expected expect
+ expecters expect
+ expecting expect
+ expects expect
+ expedience expedi
+ expedient expedi
+ expediently expedi
+ expedition expedit
+ expeditious expediti
+ expel expel
+ expell expel
+ expelling expel
+ expels expel
+ expend expend
+ expense expens
+ expenses expens
+ experienc experienc
+ experience experi
+ experiences experi
+ experiment experi
+ experimental experiment
+ experiments experi
+ expert expert
+ expertness expert
+ expiate expiat
+ expiation expiat
+ expir expir
+ expiration expir
+ expire expir
+ expired expir
+ expires expir
+ expiring expir
+ explication explic
+ exploit exploit
+ exploits exploit
+ expos expo
+ expose expos
+ exposing expos
+ exposition exposit
+ expositor expositor
+ expostulate expostul
+ expostulation expostul
+ exposture expostur
+ exposure exposur
+ expound expound
+ expounded expound
+ express express
+ expressed express
+ expresseth expresseth
+ expressing express
+ expressive express
+ expressly expressli
+ expressure expressur
+ expuls expul
+ expulsion expuls
+ exquisite exquisit
+ exsufflicate exsuffl
+ extant extant
+ extemporal extempor
+ extemporally extempor
+ extempore extempor
+ extend extend
+ extended extend
+ extends extend
+ extent extent
+ extenuate extenu
+ extenuated extenu
+ extenuates extenu
+ extenuation extenu
+ exterior exterior
+ exteriorly exteriorli
+ exteriors exterior
+ extermin extermin
+ extern extern
+ external extern
+ extinct extinct
+ extincted extinct
+ extincture extinctur
+ extinguish extinguish
+ extirp extirp
+ extirpate extirp
+ extirped extirp
+ extol extol
+ extoll extol
+ extolment extol
+ exton exton
+ extort extort
+ extorted extort
+ extortion extort
+ extortions extort
+ extra extra
+ extract extract
+ extracted extract
+ extracting extract
+ extraordinarily extraordinarili
+ extraordinary extraordinari
+ extraught extraught
+ extravagancy extravag
+ extravagant extravag
+ extreme extrem
+ extremely extrem
+ extremes extrem
+ extremest extremest
+ extremities extrem
+ extremity extrem
+ exuent exuent
+ exult exult
+ exultation exult
+ ey ey
+ eyas eya
+ eyases eyas
+ eye ey
+ eyeball eyebal
+ eyeballs eyebal
+ eyebrow eyebrow
+ eyebrows eyebrow
+ eyed ei
+ eyeless eyeless
+ eyelid eyelid
+ eyelids eyelid
+ eyes ey
+ eyesight eyesight
+ eyestrings eyestr
+ eying ei
+ eyne eyn
+ eyrie eyri
+ fa fa
+ fabian fabian
+ fable fabl
+ fables fabl
+ fabric fabric
+ fabulous fabul
+ fac fac
+ face face
+ faced face
+ facere facer
+ faces face
+ faciant faciant
+ facile facil
+ facility facil
+ facinerious facineri
+ facing face
+ facit facit
+ fact fact
+ faction faction
+ factionary factionari
+ factions faction
+ factious factiou
+ factor factor
+ factors factor
+ faculties faculti
+ faculty faculti
+ fade fade
+ faded fade
+ fadeth fadeth
+ fadge fadg
+ fading fade
+ fadings fade
+ fadom fadom
+ fadoms fadom
+ fagot fagot
+ fagots fagot
+ fail fail
+ failing fail
+ fails fail
+ fain fain
+ faint faint
+ fainted faint
+ fainter fainter
+ fainting faint
+ faintly faintli
+ faintness faint
+ faints faint
+ fair fair
+ fairer fairer
+ fairest fairest
+ fairies fairi
+ fairing fair
+ fairings fair
+ fairly fairli
+ fairness fair
+ fairs fair
+ fairwell fairwel
+ fairy fairi
+ fais fai
+ fait fait
+ faites fait
+ faith faith
+ faithful faith
+ faithfull faithful
+ faithfully faithfulli
+ faithless faithless
+ faiths faith
+ faitors faitor
+ fal fal
+ falchion falchion
+ falcon falcon
+ falconbridge falconbridg
+ falconer falcon
+ falconers falcon
+ fall fall
+ fallacy fallaci
+ fallen fallen
+ falleth falleth
+ falliable falliabl
+ fallible fallibl
+ falling fall
+ fallow fallow
+ fallows fallow
+ falls fall
+ fally falli
+ falorous falor
+ false fals
+ falsehood falsehood
+ falsely fals
+ falseness fals
+ falser falser
+ falsify falsifi
+ falsing fals
+ falstaff falstaff
+ falstaffs falstaff
+ falter falter
+ fam fam
+ fame fame
+ famed fame
+ familiar familiar
+ familiarity familiar
+ familiarly familiarli
+ familiars familiar
+ family famili
+ famine famin
+ famish famish
+ famished famish
+ famous famou
+ famoused famous
+ famously famous
+ fan fan
+ fanatical fanat
+ fancies fanci
+ fancy fanci
+ fane fane
+ fanes fane
+ fang fang
+ fangled fangl
+ fangless fangless
+ fangs fang
+ fann fann
+ fanning fan
+ fans fan
+ fantasied fantasi
+ fantasies fantasi
+ fantastic fantast
+ fantastical fantast
+ fantastically fantast
+ fantasticoes fantastico
+ fantasy fantasi
+ fap fap
+ far far
+ farborough farborough
+ farced farc
+ fardel fardel
+ fardels fardel
+ fare fare
+ fares fare
+ farewell farewel
+ farewells farewel
+ fariner farin
+ faring fare
+ farm farm
+ farmer farmer
+ farmhouse farmhous
+ farms farm
+ farre farr
+ farrow farrow
+ farther farther
+ farthest farthest
+ farthing farth
+ farthingale farthingal
+ farthingales farthingal
+ farthings farth
+ fartuous fartuou
+ fas fa
+ fashion fashion
+ fashionable fashion
+ fashioning fashion
+ fashions fashion
+ fast fast
+ fasted fast
+ fasten fasten
+ fastened fasten
+ faster faster
+ fastest fastest
+ fasting fast
+ fastly fastli
+ fastolfe fastolf
+ fasts fast
+ fat fat
+ fatal fatal
+ fatally fatal
+ fate fate
+ fated fate
+ fates fate
+ father father
+ fathered father
+ fatherless fatherless
+ fatherly fatherli
+ fathers father
+ fathom fathom
+ fathomless fathomless
+ fathoms fathom
+ fatigate fatig
+ fatness fat
+ fats fat
+ fatted fat
+ fatter fatter
+ fattest fattest
+ fatting fat
+ fatuus fatuu
+ fauconbridge fauconbridg
+ faulconbridge faulconbridg
+ fault fault
+ faultiness faulti
+ faultless faultless
+ faults fault
+ faulty faulti
+ fausse fauss
+ fauste faust
+ faustuses faustus
+ faut faut
+ favor favor
+ favorable favor
+ favorably favor
+ favors favor
+ favour favour
+ favourable favour
+ favoured favour
+ favouredly favouredli
+ favourer favour
+ favourers favour
+ favouring favour
+ favourite favourit
+ favourites favourit
+ favours favour
+ favout favout
+ fawn fawn
+ fawneth fawneth
+ fawning fawn
+ fawns fawn
+ fay fai
+ fe fe
+ fealty fealti
+ fear fear
+ feared fear
+ fearest fearest
+ fearful fear
+ fearfull fearful
+ fearfully fearfulli
+ fearfulness fear
+ fearing fear
+ fearless fearless
+ fears fear
+ feast feast
+ feasted feast
+ feasting feast
+ feasts feast
+ feat feat
+ feated feat
+ feater feater
+ feather feather
+ feathered feather
+ feathers feather
+ featly featli
+ feats feat
+ featur featur
+ feature featur
+ featured featur
+ featureless featureless
+ features featur
+ february februari
+ fecks feck
+ fed fed
+ fedary fedari
+ federary federari
+ fee fee
+ feeble feebl
+ feebled feebl
+ feebleness feebl
+ feebling feebl
+ feebly feebli
+ feed feed
+ feeder feeder
+ feeders feeder
+ feedeth feedeth
+ feeding feed
+ feeds feed
+ feel feel
+ feeler feeler
+ feeling feel
+ feelingly feelingli
+ feels feel
+ fees fee
+ feet feet
+ fehemently fehement
+ feign feign
+ feigned feign
+ feigning feign
+ feil feil
+ feith feith
+ felicitate felicit
+ felicity felic
+ fell fell
+ fellest fellest
+ fellies felli
+ fellow fellow
+ fellowly fellowli
+ fellows fellow
+ fellowship fellowship
+ fellowships fellowship
+ fells fell
+ felon felon
+ felonious feloni
+ felony feloni
+ felt felt
+ female femal
+ females femal
+ feminine feminin
+ fen fen
+ fenc fenc
+ fence fenc
+ fencer fencer
+ fencing fenc
+ fends fend
+ fennel fennel
+ fenny fenni
+ fens fen
+ fenton fenton
+ fer fer
+ ferdinand ferdinand
+ fere fere
+ fernseed fernse
+ ferrara ferrara
+ ferrers ferrer
+ ferret ferret
+ ferry ferri
+ ferryman ferryman
+ fertile fertil
+ fertility fertil
+ fervency fervenc
+ fervour fervour
+ fery feri
+ fest fest
+ feste fest
+ fester fester
+ festinate festin
+ festinately festin
+ festival festiv
+ festivals festiv
+ fet fet
+ fetch fetch
+ fetches fetch
+ fetching fetch
+ fetlock fetlock
+ fetlocks fetlock
+ fett fett
+ fetter fetter
+ fettering fetter
+ fetters fetter
+ fettle fettl
+ feu feu
+ feud feud
+ fever fever
+ feverous fever
+ fevers fever
+ few few
+ fewer fewer
+ fewest fewest
+ fewness few
+ fickle fickl
+ fickleness fickl
+ fico fico
+ fiction fiction
+ fiddle fiddl
+ fiddler fiddler
+ fiddlestick fiddlestick
+ fidele fidel
+ fidelicet fidelicet
+ fidelity fidel
+ fidius fidiu
+ fie fie
+ field field
+ fielded field
+ fields field
+ fiend fiend
+ fiends fiend
+ fierce fierc
+ fiercely fierc
+ fierceness fierc
+ fiery fieri
+ fife fife
+ fifes fife
+ fifteen fifteen
+ fifteens fifteen
+ fifteenth fifteenth
+ fifth fifth
+ fifty fifti
+ fiftyfold fiftyfold
+ fig fig
+ fight fight
+ fighter fighter
+ fightest fightest
+ fighteth fighteth
+ fighting fight
+ fights fight
+ figo figo
+ figs fig
+ figur figur
+ figure figur
+ figured figur
+ figures figur
+ figuring figur
+ fike fike
+ fil fil
+ filberts filbert
+ filch filch
+ filches filch
+ filching filch
+ file file
+ filed file
+ files file
+ filial filial
+ filius filiu
+ fill fill
+ filled fill
+ fillet fillet
+ filling fill
+ fillip fillip
+ fills fill
+ filly filli
+ film film
+ fils fil
+ filth filth
+ filths filth
+ filthy filthi
+ fin fin
+ finally final
+ finch finch
+ find find
+ finder finder
+ findeth findeth
+ finding find
+ findings find
+ finds find
+ fine fine
+ fineless fineless
+ finely fine
+ finem finem
+ fineness fine
+ finer finer
+ fines fine
+ finest finest
+ fing fing
+ finger finger
+ fingering finger
+ fingers finger
+ fingre fingr
+ fingres fingr
+ finical finic
+ finish finish
+ finished finish
+ finisher finish
+ finless finless
+ finn finn
+ fins fin
+ finsbury finsburi
+ fir fir
+ firago firago
+ fire fire
+ firebrand firebrand
+ firebrands firebrand
+ fired fire
+ fires fire
+ firework firework
+ fireworks firework
+ firing fire
+ firk firk
+ firm firm
+ firmament firmament
+ firmly firmli
+ firmness firm
+ first first
+ firstlings firstl
+ fish fish
+ fisher fisher
+ fishermen fishermen
+ fishers fisher
+ fishes fish
+ fishified fishifi
+ fishmonger fishmong
+ fishpond fishpond
+ fisnomy fisnomi
+ fist fist
+ fisting fist
+ fists fist
+ fistula fistula
+ fit fit
+ fitchew fitchew
+ fitful fit
+ fitly fitli
+ fitment fitment
+ fitness fit
+ fits fit
+ fitted fit
+ fitter fitter
+ fittest fittest
+ fitteth fitteth
+ fitting fit
+ fitzwater fitzwat
+ five five
+ fivepence fivep
+ fives five
+ fix fix
+ fixed fix
+ fixes fix
+ fixeth fixeth
+ fixing fix
+ fixture fixtur
+ fl fl
+ flag flag
+ flagging flag
+ flagon flagon
+ flagons flagon
+ flags flag
+ flail flail
+ flakes flake
+ flaky flaki
+ flam flam
+ flame flame
+ flamen flamen
+ flamens flamen
+ flames flame
+ flaming flame
+ flaminius flaminiu
+ flanders flander
+ flannel flannel
+ flap flap
+ flaring flare
+ flash flash
+ flashes flash
+ flashing flash
+ flask flask
+ flat flat
+ flatly flatli
+ flatness flat
+ flats flat
+ flatt flatt
+ flatter flatter
+ flattered flatter
+ flatterer flatter
+ flatterers flatter
+ flatterest flatterest
+ flatteries flatteri
+ flattering flatter
+ flatters flatter
+ flattery flatteri
+ flaunts flaunt
+ flavio flavio
+ flavius flaviu
+ flaw flaw
+ flaws flaw
+ flax flax
+ flaxen flaxen
+ flay flai
+ flaying flai
+ flea flea
+ fleance fleanc
+ fleas flea
+ flecked fleck
+ fled fled
+ fledge fledg
+ flee flee
+ fleec fleec
+ fleece fleec
+ fleeces fleec
+ fleer fleer
+ fleering fleer
+ fleers fleer
+ fleet fleet
+ fleeter fleeter
+ fleeting fleet
+ fleming fleme
+ flemish flemish
+ flesh flesh
+ fleshes flesh
+ fleshly fleshli
+ fleshment fleshment
+ fleshmonger fleshmong
+ flew flew
+ flexible flexibl
+ flexure flexur
+ flibbertigibbet flibbertigibbet
+ flickering flicker
+ flidge flidg
+ fliers flier
+ flies fli
+ flieth flieth
+ flight flight
+ flights flight
+ flighty flighti
+ flinch flinch
+ fling fling
+ flint flint
+ flints flint
+ flinty flinti
+ flirt flirt
+ float float
+ floated float
+ floating float
+ flock flock
+ flocks flock
+ flood flood
+ floodgates floodgat
+ floods flood
+ floor floor
+ flora flora
+ florence florenc
+ florentine florentin
+ florentines florentin
+ florentius florentiu
+ florizel florizel
+ flote flote
+ floulish floulish
+ flour flour
+ flourish flourish
+ flourishes flourish
+ flourisheth flourisheth
+ flourishing flourish
+ flout flout
+ flouted flout
+ flouting flout
+ flouts flout
+ flow flow
+ flowed flow
+ flower flower
+ flowerets floweret
+ flowers flower
+ flowing flow
+ flown flown
+ flows flow
+ fluellen fluellen
+ fluent fluent
+ flung flung
+ flush flush
+ flushing flush
+ fluster fluster
+ flute flute
+ flutes flute
+ flutter flutter
+ flux flux
+ fluxive fluxiv
+ fly fly
+ flying fly
+ fo fo
+ foal foal
+ foals foal
+ foam foam
+ foamed foam
+ foaming foam
+ foams foam
+ foamy foami
+ fob fob
+ focative foc
+ fodder fodder
+ foe foe
+ foeman foeman
+ foemen foemen
+ foes foe
+ fog fog
+ foggy foggi
+ fogs fog
+ foh foh
+ foi foi
+ foil foil
+ foiled foil
+ foils foil
+ foin foin
+ foining foin
+ foins foin
+ fois foi
+ foison foison
+ foisons foison
+ foist foist
+ foix foix
+ fold fold
+ folded fold
+ folds fold
+ folio folio
+ folk folk
+ folks folk
+ follies folli
+ follow follow
+ followed follow
+ follower follow
+ followers follow
+ followest followest
+ following follow
+ follows follow
+ folly folli
+ fond fond
+ fonder fonder
+ fondly fondli
+ fondness fond
+ font font
+ fontibell fontibel
+ food food
+ fool fool
+ fooleries fooleri
+ foolery fooleri
+ foolhardy foolhardi
+ fooling fool
+ foolish foolish
+ foolishly foolishli
+ foolishness foolish
+ fools fool
+ foot foot
+ football footbal
+ footboy footboi
+ footboys footboi
+ footed foot
+ footfall footfal
+ footing foot
+ footman footman
+ footmen footmen
+ footpath footpath
+ footsteps footstep
+ footstool footstool
+ fopp fopp
+ fopped fop
+ foppery fopperi
+ foppish foppish
+ fops fop
+ for for
+ forage forag
+ foragers forag
+ forbade forbad
+ forbear forbear
+ forbearance forbear
+ forbears forbear
+ forbid forbid
+ forbidden forbidden
+ forbiddenly forbiddenli
+ forbids forbid
+ forbod forbod
+ forborne forborn
+ forc forc
+ force forc
+ forced forc
+ forceful forc
+ forceless forceless
+ forces forc
+ forcible forcibl
+ forcibly forcibl
+ forcing forc
+ ford ford
+ fordid fordid
+ fordo fordo
+ fordoes fordo
+ fordone fordon
+ fore fore
+ forecast forecast
+ forefather forefath
+ forefathers forefath
+ forefinger forefing
+ forego forego
+ foregone foregon
+ forehand forehand
+ forehead forehead
+ foreheads forehead
+ forehorse forehors
+ foreign foreign
+ foreigner foreign
+ foreigners foreign
+ foreknowing foreknow
+ foreknowledge foreknowledg
+ foremost foremost
+ forenamed forenam
+ forenoon forenoon
+ forerun forerun
+ forerunner forerunn
+ forerunning forerun
+ foreruns forerun
+ foresaid foresaid
+ foresaw foresaw
+ foresay foresai
+ foresee forese
+ foreseeing forese
+ foresees forese
+ foreshow foreshow
+ foreskirt foreskirt
+ forespent foresp
+ forest forest
+ forestall forestal
+ forestalled forestal
+ forester forest
+ foresters forest
+ forests forest
+ foretell foretel
+ foretelling foretel
+ foretells foretel
+ forethink forethink
+ forethought forethought
+ foretold foretold
+ forever forev
+ foreward foreward
+ forewarn forewarn
+ forewarned forewarn
+ forewarning forewarn
+ forfeit forfeit
+ forfeited forfeit
+ forfeiters forfeit
+ forfeiting forfeit
+ forfeits forfeit
+ forfeiture forfeitur
+ forfeitures forfeitur
+ forfend forfend
+ forfended forfend
+ forg forg
+ forgave forgav
+ forge forg
+ forged forg
+ forgeries forgeri
+ forgery forgeri
+ forges forg
+ forget forget
+ forgetful forget
+ forgetfulness forget
+ forgetive forget
+ forgets forget
+ forgetting forget
+ forgive forgiv
+ forgiven forgiven
+ forgiveness forgiv
+ forgo forgo
+ forgoing forgo
+ forgone forgon
+ forgot forgot
+ forgotten forgotten
+ fork fork
+ forked fork
+ forks fork
+ forlorn forlorn
+ form form
+ formal formal
+ formally formal
+ formed form
+ former former
+ formerly formerli
+ formless formless
+ forms form
+ fornication fornic
+ fornications fornic
+ fornicatress fornicatress
+ forres forr
+ forrest forrest
+ forsake forsak
+ forsaken forsaken
+ forsaketh forsaketh
+ forslow forslow
+ forsook forsook
+ forsooth forsooth
+ forspent forspent
+ forspoke forspok
+ forswear forswear
+ forswearing forswear
+ forswore forswor
+ forsworn forsworn
+ fort fort
+ forted fort
+ forth forth
+ forthcoming forthcom
+ forthlight forthlight
+ forthright forthright
+ forthwith forthwith
+ fortification fortif
+ fortifications fortif
+ fortified fortifi
+ fortifies fortifi
+ fortify fortifi
+ fortinbras fortinbra
+ fortitude fortitud
+ fortnight fortnight
+ fortress fortress
+ fortresses fortress
+ forts fort
+ fortun fortun
+ fortuna fortuna
+ fortunate fortun
+ fortunately fortun
+ fortune fortun
+ fortuned fortun
+ fortunes fortun
+ fortward fortward
+ forty forti
+ forum forum
+ forward forward
+ forwarding forward
+ forwardness forward
+ forwards forward
+ forwearied forweari
+ fosset fosset
+ fost fost
+ foster foster
+ fostered foster
+ fought fought
+ foughten foughten
+ foul foul
+ fouler fouler
+ foulest foulest
+ foully foulli
+ foulness foul
+ found found
+ foundation foundat
+ foundations foundat
+ founded found
+ founder founder
+ fount fount
+ fountain fountain
+ fountains fountain
+ founts fount
+ four four
+ fourscore fourscor
+ fourteen fourteen
+ fourth fourth
+ foutra foutra
+ fowl fowl
+ fowler fowler
+ fowling fowl
+ fowls fowl
+ fox fox
+ foxes fox
+ foxship foxship
+ fracted fract
+ fraction fraction
+ fractions fraction
+ fragile fragil
+ fragment fragment
+ fragments fragment
+ fragrant fragrant
+ frail frail
+ frailer frailer
+ frailties frailti
+ frailty frailti
+ fram fram
+ frame frame
+ framed frame
+ frames frame
+ frampold frampold
+ fran fran
+ francais francai
+ france franc
+ frances franc
+ franchise franchis
+ franchised franchis
+ franchisement franchis
+ franchises franchis
+ franciae francia
+ francis franci
+ francisca francisca
+ franciscan franciscan
+ francisco francisco
+ frank frank
+ franker franker
+ frankfort frankfort
+ franklin franklin
+ franklins franklin
+ frankly frankli
+ frankness frank
+ frantic frantic
+ franticly franticli
+ frateretto frateretto
+ fratrum fratrum
+ fraud fraud
+ fraudful fraud
+ fraught fraught
+ fraughtage fraughtag
+ fraughting fraught
+ fray frai
+ frays frai
+ freckl freckl
+ freckled freckl
+ freckles freckl
+ frederick frederick
+ free free
+ freed freed
+ freedom freedom
+ freedoms freedom
+ freehearted freeheart
+ freelier freelier
+ freely freeli
+ freeman freeman
+ freemen freemen
+ freeness freeness
+ freer freer
+ frees free
+ freestone freeston
+ freetown freetown
+ freeze freez
+ freezes freez
+ freezing freez
+ freezings freez
+ french french
+ frenchman frenchman
+ frenchmen frenchmen
+ frenchwoman frenchwoman
+ frenzy frenzi
+ frequent frequent
+ frequents frequent
+ fresh fresh
+ fresher fresher
+ freshes fresh
+ freshest freshest
+ freshly freshli
+ freshness fresh
+ fret fret
+ fretful fret
+ frets fret
+ fretted fret
+ fretten fretten
+ fretting fret
+ friar friar
+ friars friar
+ friday fridai
+ fridays fridai
+ friend friend
+ friended friend
+ friending friend
+ friendless friendless
+ friendliness friendli
+ friendly friendli
+ friends friend
+ friendship friendship
+ friendships friendship
+ frieze friez
+ fright fright
+ frighted fright
+ frightened frighten
+ frightful fright
+ frighting fright
+ frights fright
+ fringe fring
+ fringed fring
+ frippery fripperi
+ frisk frisk
+ fritters fritter
+ frivolous frivol
+ fro fro
+ frock frock
+ frog frog
+ frogmore frogmor
+ froissart froissart
+ frolic frolic
+ from from
+ front front
+ fronted front
+ frontier frontier
+ frontiers frontier
+ fronting front
+ frontlet frontlet
+ fronts front
+ frost frost
+ frosts frost
+ frosty frosti
+ froth froth
+ froward froward
+ frown frown
+ frowning frown
+ frowningly frowningli
+ frowns frown
+ froze froze
+ frozen frozen
+ fructify fructifi
+ frugal frugal
+ fruit fruit
+ fruiterer fruiter
+ fruitful fruit
+ fruitfully fruitfulli
+ fruitfulness fruit
+ fruition fruition
+ fruitless fruitless
+ fruits fruit
+ frush frush
+ frustrate frustrat
+ frutify frutifi
+ fry fry
+ fubb fubb
+ fuel fuel
+ fugitive fugit
+ fulfil fulfil
+ fulfill fulfil
+ fulfilling fulfil
+ fulfils fulfil
+ full full
+ fullam fullam
+ fuller fuller
+ fullers fuller
+ fullest fullest
+ fullness full
+ fully fulli
+ fulness ful
+ fulsome fulsom
+ fulvia fulvia
+ fum fum
+ fumble fumbl
+ fumbles fumbl
+ fumblest fumblest
+ fumbling fumbl
+ fume fume
+ fumes fume
+ fuming fume
+ fumiter fumit
+ fumitory fumitori
+ fun fun
+ function function
+ functions function
+ fundamental fundament
+ funeral funer
+ funerals funer
+ fur fur
+ furbish furbish
+ furies furi
+ furious furiou
+ furlongs furlong
+ furnace furnac
+ furnaces furnac
+ furnish furnish
+ furnished furnish
+ furnishings furnish
+ furniture furnitur
+ furnival furniv
+ furor furor
+ furr furr
+ furrow furrow
+ furrowed furrow
+ furrows furrow
+ furth furth
+ further further
+ furtherance further
+ furtherer further
+ furthermore furthermor
+ furthest furthest
+ fury furi
+ furze furz
+ furzes furz
+ fust fust
+ fustian fustian
+ fustilarian fustilarian
+ fusty fusti
+ fut fut
+ future futur
+ futurity futur
+ g g
+ gabble gabbl
+ gaberdine gaberdin
+ gabriel gabriel
+ gad gad
+ gadding gad
+ gads gad
+ gadshill gadshil
+ gag gag
+ gage gage
+ gaged gage
+ gagg gagg
+ gaging gage
+ gagne gagn
+ gain gain
+ gained gain
+ gainer gainer
+ gaingiving gaingiv
+ gains gain
+ gainsaid gainsaid
+ gainsay gainsai
+ gainsaying gainsai
+ gainsays gainsai
+ gainst gainst
+ gait gait
+ gaited gait
+ galathe galath
+ gale gale
+ galen galen
+ gales gale
+ gall gall
+ gallant gallant
+ gallantly gallantli
+ gallantry gallantri
+ gallants gallant
+ galled gall
+ gallery galleri
+ galley gallei
+ galleys gallei
+ gallia gallia
+ gallian gallian
+ galliard galliard
+ galliasses galliass
+ gallimaufry gallimaufri
+ galling gall
+ gallons gallon
+ gallop gallop
+ galloping gallop
+ gallops gallop
+ gallow gallow
+ galloway gallowai
+ gallowglasses gallowglass
+ gallows gallow
+ gallowses gallows
+ galls gall
+ gallus gallu
+ gam gam
+ gambol gambol
+ gambold gambold
+ gambols gambol
+ gamboys gamboi
+ game game
+ gamers gamer
+ games game
+ gamesome gamesom
+ gamester gamest
+ gaming game
+ gammon gammon
+ gamut gamut
+ gan gan
+ gangren gangren
+ ganymede ganymed
+ gaol gaol
+ gaoler gaoler
+ gaolers gaoler
+ gaols gaol
+ gap gap
+ gape gape
+ gapes gape
+ gaping gape
+ gar gar
+ garb garb
+ garbage garbag
+ garboils garboil
+ garcon garcon
+ gard gard
+ garde gard
+ garden garden
+ gardener garden
+ gardeners garden
+ gardens garden
+ gardez gardez
+ gardiner gardin
+ gardon gardon
+ gargantua gargantua
+ gargrave gargrav
+ garish garish
+ garland garland
+ garlands garland
+ garlic garlic
+ garment garment
+ garments garment
+ garmet garmet
+ garner garner
+ garners garner
+ garnish garnish
+ garnished garnish
+ garret garret
+ garrison garrison
+ garrisons garrison
+ gart gart
+ garter garter
+ garterd garterd
+ gartering garter
+ garters garter
+ gascony gasconi
+ gash gash
+ gashes gash
+ gaskins gaskin
+ gasp gasp
+ gasping gasp
+ gasted gast
+ gastness gast
+ gat gat
+ gate gate
+ gated gate
+ gates gate
+ gath gath
+ gather gather
+ gathered gather
+ gathering gather
+ gathers gather
+ gatories gatori
+ gatory gatori
+ gaud gaud
+ gaudeo gaudeo
+ gaudy gaudi
+ gauge gaug
+ gaul gaul
+ gaultree gaultre
+ gaunt gaunt
+ gauntlet gauntlet
+ gauntlets gauntlet
+ gav gav
+ gave gave
+ gavest gavest
+ gawded gawd
+ gawds gawd
+ gawsey gawsei
+ gay gai
+ gayness gay
+ gaz gaz
+ gaze gaze
+ gazed gaze
+ gazer gazer
+ gazers gazer
+ gazes gaze
+ gazeth gazeth
+ gazing gaze
+ gear gear
+ geck geck
+ geese gees
+ geffrey geffrei
+ geld geld
+ gelded geld
+ gelding geld
+ gelida gelida
+ gelidus gelidu
+ gelt gelt
+ gem gem
+ geminy gemini
+ gems gem
+ gen gen
+ gender gender
+ genders gender
+ general gener
+ generally gener
+ generals gener
+ generation gener
+ generations gener
+ generative gener
+ generosity generos
+ generous gener
+ genitive genit
+ genitivo genitivo
+ genius geniu
+ gennets gennet
+ genoa genoa
+ genoux genoux
+ gens gen
+ gent gent
+ gentilhomme gentilhomm
+ gentility gentil
+ gentle gentl
+ gentlefolks gentlefolk
+ gentleman gentleman
+ gentlemanlike gentlemanlik
+ gentlemen gentlemen
+ gentleness gentl
+ gentler gentler
+ gentles gentl
+ gentlest gentlest
+ gentlewoman gentlewoman
+ gentlewomen gentlewomen
+ gently gentli
+ gentry gentri
+ george georg
+ gerard gerard
+ germaines germain
+ germains germain
+ german german
+ germane german
+ germans german
+ germany germani
+ gertrude gertrud
+ gest gest
+ gests gest
+ gesture gestur
+ gestures gestur
+ get get
+ getrude getrud
+ gets get
+ getter getter
+ getting get
+ ghastly ghastli
+ ghost ghost
+ ghosted ghost
+ ghostly ghostli
+ ghosts ghost
+ gi gi
+ giant giant
+ giantess giantess
+ giantlike giantlik
+ giants giant
+ gib gib
+ gibber gibber
+ gibbet gibbet
+ gibbets gibbet
+ gibe gibe
+ giber giber
+ gibes gibe
+ gibing gibe
+ gibingly gibingli
+ giddily giddili
+ giddiness giddi
+ giddy giddi
+ gift gift
+ gifts gift
+ gig gig
+ giglets giglet
+ giglot giglot
+ gilbert gilbert
+ gild gild
+ gilded gild
+ gilding gild
+ gilliams gilliam
+ gillian gillian
+ gills gill
+ gillyvors gillyvor
+ gilt gilt
+ gimmal gimmal
+ gimmers gimmer
+ gin gin
+ ging ging
+ ginger ginger
+ gingerbread gingerbread
+ gingerly gingerli
+ ginn ginn
+ gins gin
+ gioucestershire gioucestershir
+ gipes gipe
+ gipsies gipsi
+ gipsy gipsi
+ gird gird
+ girded gird
+ girdle girdl
+ girdled girdl
+ girdles girdl
+ girdling girdl
+ girl girl
+ girls girl
+ girt girt
+ girth girth
+ gis gi
+ giv giv
+ give give
+ given given
+ giver giver
+ givers giver
+ gives give
+ givest givest
+ giveth giveth
+ giving give
+ givings give
+ glad glad
+ gladded glad
+ gladding glad
+ gladly gladli
+ gladness glad
+ glamis glami
+ glanc glanc
+ glance glanc
+ glanced glanc
+ glances glanc
+ glancing glanc
+ glanders glander
+ glansdale glansdal
+ glare glare
+ glares glare
+ glass glass
+ glasses glass
+ glassy glassi
+ glaz glaz
+ glazed glaze
+ gleams gleam
+ glean glean
+ gleaned glean
+ gleaning glean
+ gleeful gleeful
+ gleek gleek
+ gleeking gleek
+ gleeks gleek
+ glend glend
+ glendower glendow
+ glib glib
+ glide glide
+ glided glide
+ glides glide
+ glideth glideth
+ gliding glide
+ glimmer glimmer
+ glimmering glimmer
+ glimmers glimmer
+ glimpse glimps
+ glimpses glimps
+ glist glist
+ glistening glisten
+ glister glister
+ glistering glister
+ glisters glister
+ glitt glitt
+ glittering glitter
+ globe globe
+ globes globe
+ glooming gloom
+ gloomy gloomi
+ glories glori
+ glorified glorifi
+ glorify glorifi
+ glorious gloriou
+ gloriously glorious
+ glory glori
+ glose glose
+ gloss gloss
+ glosses gloss
+ glou glou
+ glouceste gloucest
+ gloucester gloucest
+ gloucestershire gloucestershir
+ glove glove
+ glover glover
+ gloves glove
+ glow glow
+ glowed glow
+ glowing glow
+ glowworm glowworm
+ gloz gloz
+ gloze gloze
+ glozes gloze
+ glu glu
+ glue glue
+ glued glu
+ glues glue
+ glut glut
+ glutt glutt
+ glutted glut
+ glutton glutton
+ gluttoning glutton
+ gluttony gluttoni
+ gnarled gnarl
+ gnarling gnarl
+ gnat gnat
+ gnats gnat
+ gnaw gnaw
+ gnawing gnaw
+ gnawn gnawn
+ gnaws gnaw
+ go go
+ goad goad
+ goaded goad
+ goads goad
+ goal goal
+ goat goat
+ goatish goatish
+ goats goat
+ gobbets gobbet
+ gobbo gobbo
+ goblet goblet
+ goblets goblet
+ goblin goblin
+ goblins goblin
+ god god
+ godded god
+ godden godden
+ goddess goddess
+ goddesses goddess
+ goddild goddild
+ godfather godfath
+ godfathers godfath
+ godhead godhead
+ godlike godlik
+ godliness godli
+ godly godli
+ godmother godmoth
+ gods god
+ godson godson
+ goer goer
+ goers goer
+ goes goe
+ goest goest
+ goeth goeth
+ goffe goff
+ gogs gog
+ going go
+ gold gold
+ golden golden
+ goldenly goldenli
+ goldsmith goldsmith
+ goldsmiths goldsmith
+ golgotha golgotha
+ goliases golias
+ goliath goliath
+ gon gon
+ gondola gondola
+ gondolier gondoli
+ gone gone
+ goneril goneril
+ gong gong
+ gonzago gonzago
+ gonzalo gonzalo
+ good good
+ goodfellow goodfellow
+ goodlier goodlier
+ goodliest goodliest
+ goodly goodli
+ goodman goodman
+ goodness good
+ goodnight goodnight
+ goodrig goodrig
+ goods good
+ goodwife goodwif
+ goodwill goodwil
+ goodwin goodwin
+ goodwins goodwin
+ goodyear goodyear
+ goodyears goodyear
+ goose goos
+ gooseberry gooseberri
+ goosequills goosequil
+ goot goot
+ gor gor
+ gorbellied gorbelli
+ gorboduc gorboduc
+ gordian gordian
+ gore gore
+ gored gore
+ gorg gorg
+ gorge gorg
+ gorgeous gorgeou
+ gorget gorget
+ gorging gorg
+ gorgon gorgon
+ gormandize gormand
+ gormandizing gormand
+ gory gori
+ gosling gosl
+ gospel gospel
+ gospels gospel
+ goss goss
+ gossamer gossam
+ gossip gossip
+ gossiping gossip
+ gossiplike gossiplik
+ gossips gossip
+ got got
+ goth goth
+ goths goth
+ gotten gotten
+ gourd gourd
+ gout gout
+ gouts gout
+ gouty gouti
+ govern govern
+ governance govern
+ governed govern
+ governess gover
+ government govern
+ governor governor
+ governors governor
+ governs govern
+ gower gower
+ gown gown
+ gowns gown
+ grac grac
+ grace grace
+ graced grace
+ graceful grace
+ gracefully gracefulli
+ graceless graceless
+ graces grace
+ gracing grace
+ gracious graciou
+ graciously gracious
+ gradation gradat
+ graff graff
+ graffing graf
+ graft graft
+ grafted graft
+ grafters grafter
+ grain grain
+ grained grain
+ grains grain
+ gramercies gramerci
+ gramercy gramerci
+ grammar grammar
+ grand grand
+ grandam grandam
+ grandame grandam
+ grandchild grandchild
+ grande grand
+ grandeur grandeur
+ grandfather grandfath
+ grandjurors grandjuror
+ grandmother grandmoth
+ grandpre grandpr
+ grandsir grandsir
+ grandsire grandsir
+ grandsires grandsir
+ grange grang
+ grant grant
+ granted grant
+ granting grant
+ grants grant
+ grape grape
+ grapes grape
+ grapple grappl
+ grapples grappl
+ grappling grappl
+ grasp grasp
+ grasped grasp
+ grasps grasp
+ grass grass
+ grasshoppers grasshopp
+ grassy grassi
+ grate grate
+ grated grate
+ grateful grate
+ grates grate
+ gratiano gratiano
+ gratify gratifi
+ gratii gratii
+ gratillity gratil
+ grating grate
+ gratis grati
+ gratitude gratitud
+ gratulate gratul
+ grav grav
+ grave grave
+ gravediggers gravedigg
+ gravel gravel
+ graveless graveless
+ gravell gravel
+ gravely grave
+ graven graven
+ graveness grave
+ graver graver
+ graves grave
+ gravest gravest
+ gravestone graveston
+ gravities graviti
+ gravity graviti
+ gravy gravi
+ gray grai
+ graymalkin graymalkin
+ graz graz
+ graze graze
+ grazed graze
+ grazing graze
+ grease greas
+ greases greas
+ greasily greasili
+ greasy greasi
+ great great
+ greater greater
+ greatest greatest
+ greatly greatli
+ greatness great
+ grecian grecian
+ grecians grecian
+ gree gree
+ greece greec
+ greed greed
+ greedily greedili
+ greediness greedi
+ greedy greedi
+ greeing gree
+ greek greek
+ greekish greekish
+ greeks greek
+ green green
+ greener greener
+ greenly greenli
+ greens green
+ greensleeves greensleev
+ greenwich greenwich
+ greenwood greenwood
+ greet greet
+ greeted greet
+ greeting greet
+ greetings greet
+ greets greet
+ greg greg
+ gregory gregori
+ gremio gremio
+ grew grew
+ grey grei
+ greybeard greybeard
+ greybeards greybeard
+ greyhound greyhound
+ greyhounds greyhound
+ grief grief
+ griefs grief
+ griev griev
+ grievance grievanc
+ grievances grievanc
+ grieve griev
+ grieved griev
+ grieves griev
+ grievest grievest
+ grieving griev
+ grievingly grievingli
+ grievous grievou
+ grievously grievous
+ griffin griffin
+ griffith griffith
+ grim grim
+ grime grime
+ grimly grimli
+ grin grin
+ grind grind
+ grinding grind
+ grindstone grindston
+ grinning grin
+ grip grip
+ gripe gripe
+ gripes gripe
+ griping gripe
+ grise grise
+ grisly grisli
+ grissel grissel
+ grize grize
+ grizzle grizzl
+ grizzled grizzl
+ groan groan
+ groaning groan
+ groans groan
+ groat groat
+ groats groat
+ groin groin
+ groom groom
+ grooms groom
+ grop grop
+ groping grope
+ gros gro
+ gross gross
+ grosser grosser
+ grossly grossli
+ grossness gross
+ ground ground
+ grounded ground
+ groundlings groundl
+ grounds ground
+ grove grove
+ grovel grovel
+ grovelling grovel
+ groves grove
+ grow grow
+ groweth groweth
+ growing grow
+ grown grown
+ grows grow
+ growth growth
+ grub grub
+ grubb grubb
+ grubs grub
+ grudge grudg
+ grudged grudg
+ grudges grudg
+ grudging grudg
+ gruel gruel
+ grumble grumbl
+ grumblest grumblest
+ grumbling grumbl
+ grumblings grumbl
+ grumio grumio
+ grund grund
+ grunt grunt
+ gualtier gualtier
+ guard guard
+ guardage guardag
+ guardant guardant
+ guarded guard
+ guardian guardian
+ guardians guardian
+ guards guard
+ guardsman guardsman
+ gud gud
+ gudgeon gudgeon
+ guerdon guerdon
+ guerra guerra
+ guess guess
+ guesses guess
+ guessingly guessingli
+ guest guest
+ guests guest
+ guiana guiana
+ guichard guichard
+ guide guid
+ guided guid
+ guider guider
+ guiderius guideriu
+ guides guid
+ guiding guid
+ guidon guidon
+ guienne guienn
+ guil guil
+ guildenstern guildenstern
+ guilders guilder
+ guildford guildford
+ guildhall guildhal
+ guile guil
+ guiled guil
+ guileful guil
+ guilfords guilford
+ guilt guilt
+ guiltian guiltian
+ guiltier guiltier
+ guiltily guiltili
+ guiltiness guilti
+ guiltless guiltless
+ guilts guilt
+ guilty guilti
+ guinea guinea
+ guinever guinev
+ guise guis
+ gul gul
+ gules gule
+ gulf gulf
+ gulfs gulf
+ gull gull
+ gulls gull
+ gum gum
+ gumm gumm
+ gums gum
+ gun gun
+ gunner gunner
+ gunpowder gunpowd
+ guns gun
+ gurnet gurnet
+ gurney gurnei
+ gust gust
+ gusts gust
+ gusty gusti
+ guts gut
+ gutter gutter
+ guy gui
+ guynes guyn
+ guysors guysor
+ gypsy gypsi
+ gyve gyve
+ gyved gyve
+ gyves gyve
+ h h
+ ha ha
+ haberdasher haberdash
+ habiliment habili
+ habiliments habili
+ habit habit
+ habitation habit
+ habited habit
+ habits habit
+ habitude habitud
+ hack hack
+ hacket hacket
+ hackney hacknei
+ hacks hack
+ had had
+ hadst hadst
+ haec haec
+ haeres haer
+ hag hag
+ hagar hagar
+ haggard haggard
+ haggards haggard
+ haggish haggish
+ haggled haggl
+ hags hag
+ hail hail
+ hailed hail
+ hailstone hailston
+ hailstones hailston
+ hair hair
+ hairless hairless
+ hairs hair
+ hairy hairi
+ hal hal
+ halberd halberd
+ halberds halberd
+ halcyon halcyon
+ hale hale
+ haled hale
+ hales hale
+ half half
+ halfcan halfcan
+ halfpence halfpenc
+ halfpenny halfpenni
+ halfpennyworth halfpennyworth
+ halfway halfwai
+ halidom halidom
+ hall hall
+ halloa halloa
+ halloing hallo
+ hallond hallond
+ halloo halloo
+ hallooing halloo
+ hallow hallow
+ hallowed hallow
+ hallowmas hallowma
+ hallown hallown
+ hals hal
+ halt halt
+ halter halter
+ halters halter
+ halting halt
+ halts halt
+ halves halv
+ ham ham
+ hames hame
+ hamlet hamlet
+ hammer hammer
+ hammered hammer
+ hammering hammer
+ hammers hammer
+ hamper hamper
+ hampton hampton
+ hams ham
+ hamstring hamstr
+ hand hand
+ handed hand
+ handful hand
+ handicraft handicraft
+ handicraftsmen handicraftsmen
+ handing hand
+ handiwork handiwork
+ handkercher handkerch
+ handkerchers handkerch
+ handkerchief handkerchief
+ handle handl
+ handled handl
+ handles handl
+ handless handless
+ handlest handlest
+ handling handl
+ handmaid handmaid
+ handmaids handmaid
+ hands hand
+ handsaw handsaw
+ handsome handsom
+ handsomely handsom
+ handsomeness handsom
+ handwriting handwrit
+ handy handi
+ hang hang
+ hanged hang
+ hangers hanger
+ hangeth hangeth
+ hanging hang
+ hangings hang
+ hangman hangman
+ hangmen hangmen
+ hangs hang
+ hannibal hannib
+ hap hap
+ hapless hapless
+ haply hapli
+ happ happ
+ happen happen
+ happened happen
+ happier happier
+ happies happi
+ happiest happiest
+ happily happili
+ happiness happi
+ happy happi
+ haps hap
+ harbinger harbing
+ harbingers harbing
+ harbor harbor
+ harbour harbour
+ harbourage harbourag
+ harbouring harbour
+ harbours harbour
+ harcourt harcourt
+ hard hard
+ harder harder
+ hardest hardest
+ hardiest hardiest
+ hardiment hardiment
+ hardiness hardi
+ hardly hardli
+ hardness hard
+ hardocks hardock
+ hardy hardi
+ hare hare
+ harelip harelip
+ hares hare
+ harfleur harfleur
+ hark hark
+ harlot harlot
+ harlotry harlotri
+ harlots harlot
+ harm harm
+ harmed harm
+ harmful harm
+ harming harm
+ harmless harmless
+ harmonious harmoni
+ harmony harmoni
+ harms harm
+ harness har
+ harp harp
+ harper harper
+ harpier harpier
+ harping harp
+ harpy harpi
+ harried harri
+ harrow harrow
+ harrows harrow
+ harry harri
+ harsh harsh
+ harshly harshli
+ harshness harsh
+ hart hart
+ harts hart
+ harum harum
+ harvest harvest
+ has ha
+ hast hast
+ haste hast
+ hasted hast
+ hasten hasten
+ hastes hast
+ hastily hastili
+ hasting hast
+ hastings hast
+ hasty hasti
+ hat hat
+ hatch hatch
+ hatches hatch
+ hatchet hatchet
+ hatching hatch
+ hatchment hatchment
+ hate hate
+ hated hate
+ hateful hate
+ hater hater
+ haters hater
+ hates hate
+ hateth hateth
+ hatfield hatfield
+ hath hath
+ hating hate
+ hatred hatr
+ hats hat
+ haud haud
+ hauf hauf
+ haught haught
+ haughtiness haughti
+ haughty haughti
+ haunch haunch
+ haunches haunch
+ haunt haunt
+ haunted haunt
+ haunting haunt
+ haunts haunt
+ hautboy hautboi
+ hautboys hautboi
+ have have
+ haven haven
+ havens haven
+ haver haver
+ having have
+ havings have
+ havior havior
+ haviour haviour
+ havoc havoc
+ hawk hawk
+ hawking hawk
+ hawks hawk
+ hawthorn hawthorn
+ hawthorns hawthorn
+ hay hai
+ hazard hazard
+ hazarded hazard
+ hazards hazard
+ hazel hazel
+ hazelnut hazelnut
+ he he
+ head head
+ headborough headborough
+ headed head
+ headier headier
+ heading head
+ headland headland
+ headless headless
+ headlong headlong
+ heads head
+ headsman headsman
+ headstrong headstrong
+ heady headi
+ heal heal
+ healed heal
+ healing heal
+ heals heal
+ health health
+ healthful health
+ healths health
+ healthsome healthsom
+ healthy healthi
+ heap heap
+ heaping heap
+ heaps heap
+ hear hear
+ heard heard
+ hearer hearer
+ hearers hearer
+ hearest hearest
+ heareth heareth
+ hearing hear
+ hearings hear
+ heark heark
+ hearken hearken
+ hearkens hearken
+ hears hear
+ hearsay hearsai
+ hearse hears
+ hearsed hears
+ hearst hearst
+ heart heart
+ heartache heartach
+ heartbreak heartbreak
+ heartbreaking heartbreak
+ hearted heart
+ hearten hearten
+ hearth hearth
+ hearths hearth
+ heartily heartili
+ heartiness hearti
+ heartless heartless
+ heartlings heartl
+ heartly heartli
+ hearts heart
+ heartsick heartsick
+ heartstrings heartstr
+ hearty hearti
+ heat heat
+ heated heat
+ heath heath
+ heathen heathen
+ heathenish heathenish
+ heating heat
+ heats heat
+ heauties heauti
+ heav heav
+ heave heav
+ heaved heav
+ heaven heaven
+ heavenly heavenli
+ heavens heaven
+ heaves heav
+ heavier heavier
+ heaviest heaviest
+ heavily heavili
+ heaviness heavi
+ heaving heav
+ heavings heav
+ heavy heavi
+ hebona hebona
+ hebrew hebrew
+ hecate hecat
+ hectic hectic
+ hector hector
+ hectors hector
+ hecuba hecuba
+ hedg hedg
+ hedge hedg
+ hedgehog hedgehog
+ hedgehogs hedgehog
+ hedges hedg
+ heed heed
+ heeded heed
+ heedful heed
+ heedfull heedful
+ heedfully heedfulli
+ heedless heedless
+ heel heel
+ heels heel
+ hefted heft
+ hefts heft
+ heifer heifer
+ heifers heifer
+ heigh heigh
+ height height
+ heighten heighten
+ heinous heinou
+ heinously heinous
+ heir heir
+ heiress heiress
+ heirless heirless
+ heirs heir
+ held held
+ helen helen
+ helena helena
+ helenus helenu
+ helias helia
+ helicons helicon
+ hell hell
+ hellespont hellespont
+ hellfire hellfir
+ hellish hellish
+ helm helm
+ helmed helm
+ helmet helmet
+ helmets helmet
+ helms helm
+ help help
+ helper helper
+ helpers helper
+ helpful help
+ helping help
+ helpless helpless
+ helps help
+ helter helter
+ hem hem
+ heme heme
+ hemlock hemlock
+ hemm hemm
+ hemp hemp
+ hempen hempen
+ hems hem
+ hen hen
+ hence henc
+ henceforth henceforth
+ henceforward henceforward
+ henchman henchman
+ henri henri
+ henricus henricu
+ henry henri
+ hens hen
+ hent hent
+ henton henton
+ her her
+ herald herald
+ heraldry heraldri
+ heralds herald
+ herb herb
+ herbert herbert
+ herblets herblet
+ herbs herb
+ herculean herculean
+ hercules hercul
+ herd herd
+ herds herd
+ herdsman herdsman
+ herdsmen herdsmen
+ here here
+ hereabout hereabout
+ hereabouts hereabout
+ hereafter hereaft
+ hereby herebi
+ hereditary hereditari
+ hereford hereford
+ herefordshire herefordshir
+ herein herein
+ hereof hereof
+ heresies heresi
+ heresy heresi
+ heretic heret
+ heretics heret
+ hereto hereto
+ hereupon hereupon
+ heritage heritag
+ heritier heriti
+ hermes herm
+ hermia hermia
+ hermione hermion
+ hermit hermit
+ hermitage hermitag
+ hermits hermit
+ herne hern
+ hero hero
+ herod herod
+ herods herod
+ heroes hero
+ heroic heroic
+ heroical heroic
+ herring her
+ herrings her
+ hers her
+ herself herself
+ hesperides hesperid
+ hesperus hesperu
+ hest hest
+ hests hest
+ heure heur
+ heureux heureux
+ hew hew
+ hewgh hewgh
+ hewing hew
+ hewn hewn
+ hews hew
+ hey hei
+ heyday heydai
+ hibocrates hibocr
+ hic hic
+ hiccups hiccup
+ hick hick
+ hid hid
+ hidden hidden
+ hide hide
+ hideous hideou
+ hideously hideous
+ hideousness hideous
+ hides hide
+ hidest hidest
+ hiding hide
+ hie hie
+ hied hi
+ hiems hiem
+ hies hi
+ hig hig
+ high high
+ higher higher
+ highest highest
+ highly highli
+ highmost highmost
+ highness high
+ hight hight
+ highway highwai
+ highways highwai
+ hilding hild
+ hildings hild
+ hill hill
+ hillo hillo
+ hilloa hilloa
+ hills hill
+ hilt hilt
+ hilts hilt
+ hily hili
+ him him
+ himself himself
+ hinc hinc
+ hinckley hincklei
+ hind hind
+ hinder hinder
+ hindered hinder
+ hinders hinder
+ hindmost hindmost
+ hinds hind
+ hing hing
+ hinge hing
+ hinges hing
+ hint hint
+ hip hip
+ hipp hipp
+ hipparchus hipparchu
+ hippolyta hippolyta
+ hips hip
+ hir hir
+ hire hire
+ hired hire
+ hiren hiren
+ hirtius hirtiu
+ his hi
+ hisperia hisperia
+ hiss hiss
+ hisses hiss
+ hissing hiss
+ hist hist
+ historical histor
+ history histori
+ hit hit
+ hither hither
+ hitherto hitherto
+ hitherward hitherward
+ hitherwards hitherward
+ hits hit
+ hitting hit
+ hive hive
+ hives hive
+ hizzing hizz
+ ho ho
+ hoa hoa
+ hoar hoar
+ hoard hoard
+ hoarded hoard
+ hoarding hoard
+ hoars hoar
+ hoarse hoars
+ hoary hoari
+ hob hob
+ hobbididence hobbidid
+ hobby hobbi
+ hobbyhorse hobbyhors
+ hobgoblin hobgoblin
+ hobnails hobnail
+ hoc hoc
+ hod hod
+ hodge hodg
+ hog hog
+ hogs hog
+ hogshead hogshead
+ hogsheads hogshead
+ hois hoi
+ hoise hois
+ hoist hoist
+ hoisted hoist
+ hoists hoist
+ holborn holborn
+ hold hold
+ holden holden
+ holder holder
+ holdeth holdeth
+ holdfast holdfast
+ holding hold
+ holds hold
+ hole hole
+ holes hole
+ holidam holidam
+ holidame holidam
+ holiday holidai
+ holidays holidai
+ holier holier
+ holiest holiest
+ holily holili
+ holiness holi
+ holla holla
+ holland holland
+ hollander holland
+ hollanders holland
+ holloa holloa
+ holloaing holloa
+ hollow hollow
+ hollowly hollowli
+ hollowness hollow
+ holly holli
+ holmedon holmedon
+ holofernes holofern
+ holp holp
+ holy holi
+ homage homag
+ homager homag
+ home home
+ homely home
+ homes home
+ homespuns homespun
+ homeward homeward
+ homewards homeward
+ homicide homicid
+ homicides homicid
+ homily homili
+ hominem hominem
+ hommes homm
+ homo homo
+ honest honest
+ honester honest
+ honestest honestest
+ honestly honestli
+ honesty honesti
+ honey honei
+ honeycomb honeycomb
+ honeying honei
+ honeyless honeyless
+ honeysuckle honeysuckl
+ honeysuckles honeysuckl
+ honi honi
+ honneur honneur
+ honor honor
+ honorable honor
+ honorably honor
+ honorato honorato
+ honors honor
+ honour honour
+ honourable honour
+ honourably honour
+ honoured honour
+ honourest honourest
+ honourible honour
+ honouring honour
+ honours honour
+ hoo hoo
+ hood hood
+ hooded hood
+ hoodman hoodman
+ hoods hood
+ hoodwink hoodwink
+ hoof hoof
+ hoofs hoof
+ hook hook
+ hooking hook
+ hooks hook
+ hoop hoop
+ hoops hoop
+ hoot hoot
+ hooted hoot
+ hooting hoot
+ hoots hoot
+ hop hop
+ hope hope
+ hopeful hope
+ hopeless hopeless
+ hopes hope
+ hopest hopest
+ hoping hope
+ hopkins hopkin
+ hoppedance hopped
+ hor hor
+ horace horac
+ horatio horatio
+ horizon horizon
+ horn horn
+ hornbook hornbook
+ horned horn
+ horner horner
+ horning horn
+ hornpipes hornpip
+ horns horn
+ horologe horolog
+ horrible horribl
+ horribly horribl
+ horrid horrid
+ horrider horrid
+ horridly horridli
+ horror horror
+ horrors horror
+ hors hor
+ horse hors
+ horseback horseback
+ horsed hors
+ horsehairs horsehair
+ horseman horseman
+ horsemanship horsemanship
+ horsemen horsemen
+ horses hors
+ horseway horsewai
+ horsing hors
+ hortensio hortensio
+ hortensius hortensiu
+ horum horum
+ hose hose
+ hospitable hospit
+ hospital hospit
+ hospitality hospit
+ host host
+ hostage hostag
+ hostages hostag
+ hostess hostess
+ hostile hostil
+ hostility hostil
+ hostilius hostiliu
+ hosts host
+ hot hot
+ hotly hotli
+ hotspur hotspur
+ hotter hotter
+ hottest hottest
+ hound hound
+ hounds hound
+ hour hour
+ hourly hourli
+ hours hour
+ hous hou
+ house hous
+ household household
+ householder household
+ householders household
+ households household
+ housekeeper housekeep
+ housekeepers housekeep
+ housekeeping housekeep
+ houseless houseless
+ houses hous
+ housewife housewif
+ housewifery housewiferi
+ housewives housew
+ hovel hovel
+ hover hover
+ hovered hover
+ hovering hover
+ hovers hover
+ how how
+ howbeit howbeit
+ howe how
+ howeer howeer
+ however howev
+ howl howl
+ howled howl
+ howlet howlet
+ howling howl
+ howls howl
+ howsoe howso
+ howsoever howsoev
+ howsome howsom
+ hoxes hox
+ hoy hoi
+ hoyday hoydai
+ hubert hubert
+ huddled huddl
+ huddling huddl
+ hue hue
+ hued hu
+ hues hue
+ hug hug
+ huge huge
+ hugely huge
+ hugeness huge
+ hugg hugg
+ hugger hugger
+ hugh hugh
+ hugs hug
+ hujus huju
+ hulk hulk
+ hulks hulk
+ hull hull
+ hulling hull
+ hullo hullo
+ hum hum
+ human human
+ humane human
+ humanely human
+ humanity human
+ humble humbl
+ humbled humbl
+ humbleness humbl
+ humbler humbler
+ humbles humbl
+ humblest humblest
+ humbling humbl
+ humbly humbl
+ hume hume
+ humh humh
+ humidity humid
+ humility humil
+ humming hum
+ humor humor
+ humorous humor
+ humors humor
+ humour humour
+ humourists humourist
+ humours humour
+ humphrey humphrei
+ humphry humphri
+ hums hum
+ hundred hundr
+ hundreds hundr
+ hundredth hundredth
+ hung hung
+ hungarian hungarian
+ hungary hungari
+ hunger hunger
+ hungerford hungerford
+ hungerly hungerli
+ hungry hungri
+ hunt hunt
+ hunted hunt
+ hunter hunter
+ hunters hunter
+ hunteth hunteth
+ hunting hunt
+ huntington huntington
+ huntress huntress
+ hunts hunt
+ huntsman huntsman
+ huntsmen huntsmen
+ hurdle hurdl
+ hurl hurl
+ hurling hurl
+ hurls hurl
+ hurly hurli
+ hurlyburly hurlyburli
+ hurricano hurricano
+ hurricanoes hurricano
+ hurried hurri
+ hurries hurri
+ hurry hurri
+ hurt hurt
+ hurting hurt
+ hurtled hurtl
+ hurtless hurtless
+ hurtling hurtl
+ hurts hurt
+ husband husband
+ husbanded husband
+ husbandless husbandless
+ husbandry husbandri
+ husbands husband
+ hush hush
+ hushes hush
+ husht husht
+ husks husk
+ huswife huswif
+ huswifes huswif
+ hutch hutch
+ hybla hybla
+ hydra hydra
+ hyen hyen
+ hymen hymen
+ hymenaeus hymenaeu
+ hymn hymn
+ hymns hymn
+ hyperboles hyperbol
+ hyperbolical hyperbol
+ hyperion hyperion
+ hypocrisy hypocrisi
+ hypocrite hypocrit
+ hypocrites hypocrit
+ hyrcan hyrcan
+ hyrcania hyrcania
+ hyrcanian hyrcanian
+ hyssop hyssop
+ hysterica hysterica
+ i i
+ iachimo iachimo
+ iaculis iaculi
+ iago iago
+ iament iament
+ ibat ibat
+ icarus icaru
+ ice ic
+ iceland iceland
+ ici ici
+ icicle icicl
+ icicles icicl
+ icy ici
+ idea idea
+ ideas idea
+ idem idem
+ iden iden
+ ides id
+ idiot idiot
+ idiots idiot
+ idle idl
+ idleness idl
+ idles idl
+ idly idli
+ idol idol
+ idolatrous idolatr
+ idolatry idolatri
+ ield ield
+ if if
+ ifs if
+ ignis igni
+ ignoble ignobl
+ ignobly ignobl
+ ignominious ignomini
+ ignominy ignomini
+ ignomy ignomi
+ ignorance ignor
+ ignorant ignor
+ ii ii
+ iii iii
+ iiii iiii
+ il il
+ ilbow ilbow
+ ild ild
+ ilion ilion
+ ilium ilium
+ ill ill
+ illegitimate illegitim
+ illiterate illiter
+ illness ill
+ illo illo
+ ills ill
+ illume illum
+ illumin illumin
+ illuminate illumin
+ illumineth illumineth
+ illusion illus
+ illusions illus
+ illustrate illustr
+ illustrated illustr
+ illustrious illustri
+ illyria illyria
+ illyrian illyrian
+ ils il
+ im im
+ image imag
+ imagery imageri
+ images imag
+ imagin imagin
+ imaginary imaginari
+ imagination imagin
+ imaginations imagin
+ imagine imagin
+ imagining imagin
+ imaginings imagin
+ imbar imbar
+ imbecility imbecil
+ imbrue imbru
+ imitari imitari
+ imitate imit
+ imitated imit
+ imitation imit
+ imitations imit
+ immaculate immacul
+ immanity imman
+ immask immask
+ immaterial immateri
+ immediacy immediaci
+ immediate immedi
+ immediately immedi
+ imminence immin
+ imminent immin
+ immoderate immoder
+ immoderately immoder
+ immodest immodest
+ immoment immoment
+ immortal immort
+ immortaliz immortaliz
+ immortally immort
+ immur immur
+ immured immur
+ immures immur
+ imogen imogen
+ imp imp
+ impaint impaint
+ impair impair
+ impairing impair
+ impale impal
+ impaled impal
+ impanelled impanel
+ impart impart
+ imparted impart
+ impartial imparti
+ impartment impart
+ imparts impart
+ impasted impast
+ impatience impati
+ impatient impati
+ impatiently impati
+ impawn impawn
+ impeach impeach
+ impeached impeach
+ impeachment impeach
+ impeachments impeach
+ impedes imped
+ impediment impedi
+ impediments impedi
+ impenetrable impenetr
+ imperator imper
+ imperceiverant imperceiver
+ imperfect imperfect
+ imperfection imperfect
+ imperfections imperfect
+ imperfectly imperfectli
+ imperial imperi
+ imperious imperi
+ imperiously imperi
+ impertinency impertin
+ impertinent impertin
+ impeticos impetico
+ impetuosity impetuos
+ impetuous impetu
+ impieties impieti
+ impiety impieti
+ impious impiou
+ implacable implac
+ implements implement
+ implies impli
+ implor implor
+ implorators implor
+ implore implor
+ implored implor
+ imploring implor
+ impon impon
+ import import
+ importance import
+ importancy import
+ important import
+ importantly importantli
+ imported import
+ importeth importeth
+ importing import
+ importless importless
+ imports import
+ importun importun
+ importunacy importunaci
+ importunate importun
+ importune importun
+ importunes importun
+ importunity importun
+ impos impo
+ impose impos
+ imposed impos
+ imposition imposit
+ impositions imposit
+ impossibilities imposs
+ impossibility imposs
+ impossible imposs
+ imposthume imposthum
+ impostor impostor
+ impostors impostor
+ impotence impot
+ impotent impot
+ impounded impound
+ impregnable impregn
+ imprese impres
+ impress impress
+ impressed impress
+ impressest impressest
+ impression impress
+ impressure impressur
+ imprimendum imprimendum
+ imprimis imprimi
+ imprint imprint
+ imprinted imprint
+ imprison imprison
+ imprisoned imprison
+ imprisoning imprison
+ imprisonment imprison
+ improbable improb
+ improper improp
+ improve improv
+ improvident improvid
+ impudence impud
+ impudency impud
+ impudent impud
+ impudently impud
+ impudique impudiqu
+ impugn impugn
+ impugns impugn
+ impure impur
+ imputation imput
+ impute imput
+ in in
+ inaccessible inaccess
+ inaidable inaid
+ inaudible inaud
+ inauspicious inauspici
+ incaged incag
+ incantations incant
+ incapable incap
+ incardinate incardin
+ incarnadine incarnadin
+ incarnate incarn
+ incarnation incarn
+ incens incen
+ incense incens
+ incensed incens
+ incensement incens
+ incenses incens
+ incensing incens
+ incertain incertain
+ incertainties incertainti
+ incertainty incertainti
+ incessant incess
+ incessantly incessantli
+ incest incest
+ incestuous incestu
+ inch inch
+ incharitable incharit
+ inches inch
+ incidency incid
+ incident incid
+ incision incis
+ incite incit
+ incites incit
+ incivil incivil
+ incivility incivil
+ inclin inclin
+ inclinable inclin
+ inclination inclin
+ incline inclin
+ inclined inclin
+ inclines inclin
+ inclining inclin
+ inclips inclip
+ include includ
+ included includ
+ includes includ
+ inclusive inclus
+ incomparable incompar
+ incomprehensible incomprehens
+ inconsiderate inconsider
+ inconstancy inconst
+ inconstant inconst
+ incontinency incontin
+ incontinent incontin
+ incontinently incontin
+ inconvenience inconveni
+ inconveniences inconveni
+ inconvenient inconveni
+ incony inconi
+ incorporate incorpor
+ incorps incorp
+ incorrect incorrect
+ increas increa
+ increase increas
+ increases increas
+ increaseth increaseth
+ increasing increas
+ incredible incred
+ incredulous incredul
+ incur incur
+ incurable incur
+ incurr incurr
+ incurred incur
+ incursions incurs
+ ind ind
+ inde ind
+ indebted indebt
+ indeed inde
+ indent indent
+ indented indent
+ indenture indentur
+ indentures indentur
+ index index
+ indexes index
+ india india
+ indian indian
+ indict indict
+ indicted indict
+ indictment indict
+ indies indi
+ indifferency indiffer
+ indifferent indiffer
+ indifferently indiffer
+ indigent indig
+ indigest indigest
+ indigested indigest
+ indign indign
+ indignation indign
+ indignations indign
+ indigne indign
+ indignities indign
+ indignity indign
+ indirect indirect
+ indirection indirect
+ indirections indirect
+ indirectly indirectli
+ indiscreet indiscreet
+ indiscretion indiscret
+ indispos indispo
+ indisposition indisposit
+ indissoluble indissolubl
+ indistinct indistinct
+ indistinguish indistinguish
+ indistinguishable indistinguish
+ indited indit
+ individable individ
+ indrench indrench
+ indu indu
+ indubitate indubit
+ induc induc
+ induce induc
+ induced induc
+ inducement induc
+ induction induct
+ inductions induct
+ indue indu
+ indued indu
+ indues indu
+ indulgence indulg
+ indulgences indulg
+ indulgent indulg
+ indurance indur
+ industrious industri
+ industriously industri
+ industry industri
+ inequality inequ
+ inestimable inestim
+ inevitable inevit
+ inexecrable inexecr
+ inexorable inexor
+ inexplicable inexplic
+ infallible infal
+ infallibly infal
+ infamonize infamon
+ infamous infam
+ infamy infami
+ infancy infanc
+ infant infant
+ infants infant
+ infect infect
+ infected infect
+ infecting infect
+ infection infect
+ infections infect
+ infectious infecti
+ infectiously infecti
+ infects infect
+ infer infer
+ inference infer
+ inferior inferior
+ inferiors inferior
+ infernal infern
+ inferr inferr
+ inferreth inferreth
+ inferring infer
+ infest infest
+ infidel infidel
+ infidels infidel
+ infinite infinit
+ infinitely infinit
+ infinitive infinit
+ infirm infirm
+ infirmities infirm
+ infirmity infirm
+ infixed infix
+ infixing infix
+ inflam inflam
+ inflame inflam
+ inflaming inflam
+ inflammation inflamm
+ inflict inflict
+ infliction inflict
+ influence influenc
+ influences influenc
+ infold infold
+ inform inform
+ informal inform
+ information inform
+ informations inform
+ informed inform
+ informer inform
+ informs inform
+ infortunate infortun
+ infring infr
+ infringe infring
+ infringed infring
+ infus infu
+ infuse infus
+ infused infus
+ infusing infus
+ infusion infus
+ ingener ingen
+ ingenious ingeni
+ ingeniously ingeni
+ inglorious inglori
+ ingots ingot
+ ingraffed ingraf
+ ingraft ingraft
+ ingrate ingrat
+ ingrated ingrat
+ ingrateful ingrat
+ ingratitude ingratitud
+ ingratitudes ingratitud
+ ingredient ingredi
+ ingredients ingredi
+ ingross ingross
+ inhabit inhabit
+ inhabitable inhabit
+ inhabitants inhabit
+ inhabited inhabit
+ inhabits inhabit
+ inhearse inhears
+ inhearsed inhears
+ inherent inher
+ inherit inherit
+ inheritance inherit
+ inherited inherit
+ inheriting inherit
+ inheritor inheritor
+ inheritors inheritor
+ inheritrix inheritrix
+ inherits inherit
+ inhibited inhibit
+ inhibition inhibit
+ inhoop inhoop
+ inhuman inhuman
+ iniquities iniqu
+ iniquity iniqu
+ initiate initi
+ injointed injoint
+ injunction injunct
+ injunctions injunct
+ injur injur
+ injure injur
+ injurer injur
+ injuries injuri
+ injurious injuri
+ injury injuri
+ injustice injustic
+ ink ink
+ inkhorn inkhorn
+ inkle inkl
+ inkles inkl
+ inkling inkl
+ inky inki
+ inlaid inlaid
+ inland inland
+ inlay inlai
+ inly inli
+ inmost inmost
+ inn inn
+ inner inner
+ innkeeper innkeep
+ innocence innoc
+ innocency innoc
+ innocent innoc
+ innocents innoc
+ innovation innov
+ innovator innov
+ inns inn
+ innumerable innumer
+ inoculate inocul
+ inordinate inordin
+ inprimis inprimi
+ inquir inquir
+ inquire inquir
+ inquiry inquiri
+ inquisition inquisit
+ inquisitive inquisit
+ inroads inroad
+ insane insan
+ insanie insani
+ insatiate insati
+ insconce insconc
+ inscrib inscrib
+ inscription inscript
+ inscriptions inscript
+ inscroll inscrol
+ inscrutable inscrut
+ insculp insculp
+ insculpture insculptur
+ insensible insens
+ inseparable insepar
+ inseparate insepar
+ insert insert
+ inserted insert
+ inset inset
+ inshell inshel
+ inshipp inshipp
+ inside insid
+ insinewed insinew
+ insinuate insinu
+ insinuateth insinuateth
+ insinuating insinu
+ insinuation insinu
+ insisted insist
+ insisting insist
+ insisture insistur
+ insociable insoci
+ insolence insol
+ insolent insol
+ insomuch insomuch
+ inspir inspir
+ inspiration inspir
+ inspirations inspir
+ inspire inspir
+ inspired inspir
+ install instal
+ installed instal
+ instalment instal
+ instance instanc
+ instances instanc
+ instant instant
+ instantly instantli
+ instate instat
+ instead instead
+ insteeped insteep
+ instigate instig
+ instigated instig
+ instigation instig
+ instigations instig
+ instigator instig
+ instinct instinct
+ instinctively instinct
+ institute institut
+ institutions institut
+ instruct instruct
+ instructed instruct
+ instruction instruct
+ instructions instruct
+ instructs instruct
+ instrument instrument
+ instrumental instrument
+ instruments instrument
+ insubstantial insubstanti
+ insufficience insuffici
+ insufficiency insuffici
+ insult insult
+ insulted insult
+ insulting insult
+ insultment insult
+ insults insult
+ insupportable insupport
+ insuppressive insuppress
+ insurrection insurrect
+ insurrections insurrect
+ int int
+ integer integ
+ integritas integrita
+ integrity integr
+ intellect intellect
+ intellects intellect
+ intellectual intellectu
+ intelligence intellig
+ intelligencer intelligenc
+ intelligencing intelligenc
+ intelligent intellig
+ intelligis intelligi
+ intelligo intelligo
+ intemperance intemper
+ intemperate intemper
+ intend intend
+ intended intend
+ intendeth intendeth
+ intending intend
+ intendment intend
+ intends intend
+ intenible inten
+ intent intent
+ intention intent
+ intentively intent
+ intents intent
+ inter inter
+ intercept intercept
+ intercepted intercept
+ intercepter intercept
+ interception intercept
+ intercepts intercept
+ intercession intercess
+ intercessors intercessor
+ interchained interchain
+ interchang interchang
+ interchange interchang
+ interchangeably interchang
+ interchangement interchang
+ interchanging interchang
+ interdiction interdict
+ interest interest
+ interim interim
+ interims interim
+ interior interior
+ interjections interject
+ interjoin interjoin
+ interlude interlud
+ intermingle intermingl
+ intermission intermiss
+ intermissive intermiss
+ intermit intermit
+ intermix intermix
+ intermixed intermix
+ interpose interpos
+ interposer interpos
+ interposes interpos
+ interpret interpret
+ interpretation interpret
+ interpreted interpret
+ interpreter interpret
+ interpreters interpret
+ interprets interpret
+ interr interr
+ interred inter
+ interrogatories interrogatori
+ interrupt interrupt
+ interrupted interrupt
+ interrupter interrupt
+ interruptest interruptest
+ interruption interrupt
+ interrupts interrupt
+ intertissued intertissu
+ intervallums intervallum
+ interview interview
+ intestate intest
+ intestine intestin
+ intil intil
+ intimate intim
+ intimation intim
+ intitled intitl
+ intituled intitul
+ into into
+ intolerable intoler
+ intoxicates intox
+ intreasured intreasur
+ intreat intreat
+ intrench intrench
+ intrenchant intrench
+ intricate intric
+ intrinse intrins
+ intrinsicate intrins
+ intrude intrud
+ intruder intrud
+ intruding intrud
+ intrusion intrus
+ inundation inund
+ inure inur
+ inurn inurn
+ invade invad
+ invades invad
+ invasion invas
+ invasive invas
+ invectively invect
+ invectives invect
+ inveigled inveigl
+ invent invent
+ invented invent
+ invention invent
+ inventions invent
+ inventor inventor
+ inventorially inventori
+ inventoried inventori
+ inventors inventor
+ inventory inventori
+ inverness inver
+ invert invert
+ invest invest
+ invested invest
+ investing invest
+ investments invest
+ inveterate inveter
+ invincible invinc
+ inviolable inviol
+ invised invis
+ invisible invis
+ invitation invit
+ invite invit
+ invited invit
+ invites invit
+ inviting invit
+ invitis inviti
+ invocate invoc
+ invocation invoc
+ invoke invok
+ invoked invok
+ invulnerable invulner
+ inward inward
+ inwardly inwardli
+ inwardness inward
+ inwards inward
+ ionia ionia
+ ionian ionian
+ ipse ips
+ ipswich ipswich
+ ira ira
+ irae ira
+ iras ira
+ ire ir
+ ireful ir
+ ireland ireland
+ iris iri
+ irish irish
+ irishman irishman
+ irishmen irishmen
+ irks irk
+ irksome irksom
+ iron iron
+ irons iron
+ irreconcil irreconcil
+ irrecoverable irrecover
+ irregular irregular
+ irregulous irregul
+ irreligious irreligi
+ irremovable irremov
+ irreparable irrepar
+ irresolute irresolut
+ irrevocable irrevoc
+ is is
+ isabel isabel
+ isabella isabella
+ isbel isbel
+ isbels isbel
+ iscariot iscariot
+ ise is
+ ish ish
+ isidore isidor
+ isis isi
+ island island
+ islander island
+ islanders island
+ islands island
+ isle isl
+ isles isl
+ israel israel
+ issu issu
+ issue issu
+ issued issu
+ issueless issueless
+ issues issu
+ issuing issu
+ ist ist
+ ista ista
+ it it
+ italian italian
+ italy itali
+ itch itch
+ itches itch
+ itching itch
+ item item
+ items item
+ iteration iter
+ ithaca ithaca
+ its it
+ itself itself
+ itshall itshal
+ iv iv
+ ivory ivori
+ ivy ivi
+ iwis iwi
+ ix ix
+ j j
+ jacet jacet
+ jack jack
+ jackanapes jackanap
+ jacks jack
+ jacksauce jacksauc
+ jackslave jackslav
+ jacob jacob
+ jade jade
+ jaded jade
+ jades jade
+ jail jail
+ jakes jake
+ jamany jamani
+ james jame
+ jamy jami
+ jane jane
+ jangled jangl
+ jangling jangl
+ january januari
+ janus janu
+ japhet japhet
+ jaquenetta jaquenetta
+ jaques jaqu
+ jar jar
+ jarring jar
+ jars jar
+ jarteer jarteer
+ jasons jason
+ jaunce jaunc
+ jauncing jaunc
+ jaundice jaundic
+ jaundies jaundi
+ jaw jaw
+ jawbone jawbon
+ jaws jaw
+ jay jai
+ jays jai
+ jc jc
+ je je
+ jealous jealou
+ jealousies jealousi
+ jealousy jealousi
+ jeer jeer
+ jeering jeer
+ jelly jelli
+ jenny jenni
+ jeopardy jeopardi
+ jephtha jephtha
+ jephthah jephthah
+ jerkin jerkin
+ jerkins jerkin
+ jerks jerk
+ jeronimy jeronimi
+ jerusalem jerusalem
+ jeshu jeshu
+ jesses jess
+ jessica jessica
+ jest jest
+ jested jest
+ jester jester
+ jesters jester
+ jesting jest
+ jests jest
+ jesu jesu
+ jesus jesu
+ jet jet
+ jets jet
+ jew jew
+ jewel jewel
+ jeweller jewel
+ jewels jewel
+ jewess jewess
+ jewish jewish
+ jewry jewri
+ jews jew
+ jezebel jezebel
+ jig jig
+ jigging jig
+ jill jill
+ jills jill
+ jingling jingl
+ joan joan
+ job job
+ jockey jockei
+ jocund jocund
+ jog jog
+ jogging jog
+ john john
+ johns john
+ join join
+ joinder joinder
+ joined join
+ joiner joiner
+ joineth joineth
+ joins join
+ joint joint
+ jointed joint
+ jointing joint
+ jointly jointli
+ jointress jointress
+ joints joint
+ jointure jointur
+ jollity jolliti
+ jolly jolli
+ jolt jolt
+ joltheads jolthead
+ jordan jordan
+ joseph joseph
+ joshua joshua
+ jot jot
+ jour jour
+ jourdain jourdain
+ journal journal
+ journey journei
+ journeying journei
+ journeyman journeyman
+ journeymen journeymen
+ journeys journei
+ jove jove
+ jovem jovem
+ jovial jovial
+ jowl jowl
+ jowls jowl
+ joy joi
+ joyed joi
+ joyful joy
+ joyfully joyfulli
+ joyless joyless
+ joyous joyou
+ joys joi
+ juan juan
+ jud jud
+ judas juda
+ judases judas
+ jude jude
+ judg judg
+ judge judg
+ judged judg
+ judgement judgement
+ judges judg
+ judgest judgest
+ judging judg
+ judgment judgment
+ judgments judgment
+ judicious judici
+ jug jug
+ juggle juggl
+ juggled juggl
+ juggler juggler
+ jugglers juggler
+ juggling juggl
+ jugs jug
+ juice juic
+ juiced juic
+ jul jul
+ jule jule
+ julia julia
+ juliet juliet
+ julietta julietta
+ julio julio
+ julius juliu
+ july juli
+ jump jump
+ jumpeth jumpeth
+ jumping jump
+ jumps jump
+ june june
+ junes june
+ junior junior
+ junius juniu
+ junkets junket
+ juno juno
+ jupiter jupit
+ jure jure
+ jurement jurement
+ jurisdiction jurisdict
+ juror juror
+ jurors juror
+ jury juri
+ jurymen jurymen
+ just just
+ justeius justeiu
+ justest justest
+ justice justic
+ justicer justic
+ justicers justic
+ justices justic
+ justification justif
+ justified justifi
+ justify justifi
+ justle justl
+ justled justl
+ justles justl
+ justling justl
+ justly justli
+ justness just
+ justs just
+ jutting jut
+ jutty jutti
+ juvenal juven
+ kam kam
+ kate kate
+ kated kate
+ kates kate
+ katharine katharin
+ katherina katherina
+ katherine katherin
+ kecksies kecksi
+ keech keech
+ keel keel
+ keels keel
+ keen keen
+ keenness keen
+ keep keep
+ keepdown keepdown
+ keeper keeper
+ keepers keeper
+ keepest keepest
+ keeping keep
+ keeps keep
+ keiser keiser
+ ken ken
+ kendal kendal
+ kennel kennel
+ kent kent
+ kentish kentish
+ kentishman kentishman
+ kentishmen kentishmen
+ kept kept
+ kerchief kerchief
+ kerely kere
+ kern kern
+ kernal kernal
+ kernel kernel
+ kernels kernel
+ kerns kern
+ kersey kersei
+ kettle kettl
+ kettledrum kettledrum
+ kettledrums kettledrum
+ key kei
+ keys kei
+ kibe kibe
+ kibes kibe
+ kick kick
+ kicked kick
+ kickshaws kickshaw
+ kickshawses kickshaws
+ kicky kicki
+ kid kid
+ kidney kidnei
+ kikely kike
+ kildare kildar
+ kill kill
+ killed kill
+ killer killer
+ killeth killeth
+ killing kill
+ killingworth killingworth
+ kills kill
+ kiln kiln
+ kimbolton kimbolton
+ kin kin
+ kind kind
+ kinder kinder
+ kindest kindest
+ kindle kindl
+ kindled kindl
+ kindless kindless
+ kindlier kindlier
+ kindling kindl
+ kindly kindli
+ kindness kind
+ kindnesses kind
+ kindred kindr
+ kindreds kindr
+ kinds kind
+ kine kine
+ king king
+ kingdom kingdom
+ kingdoms kingdom
+ kingly kingli
+ kings king
+ kinred kinr
+ kins kin
+ kinsman kinsman
+ kinsmen kinsmen
+ kinswoman kinswoman
+ kirtle kirtl
+ kirtles kirtl
+ kiss kiss
+ kissed kiss
+ kisses kiss
+ kissing kiss
+ kitchen kitchen
+ kitchens kitchen
+ kite kite
+ kites kite
+ kitten kitten
+ kj kj
+ kl kl
+ klll klll
+ knack knack
+ knacks knack
+ knapp knapp
+ knav knav
+ knave knave
+ knaveries knaveri
+ knavery knaveri
+ knaves knave
+ knavish knavish
+ knead knead
+ kneaded knead
+ kneading knead
+ knee knee
+ kneel kneel
+ kneeling kneel
+ kneels kneel
+ knees knee
+ knell knell
+ knew knew
+ knewest knewest
+ knife knife
+ knight knight
+ knighted knight
+ knighthood knighthood
+ knighthoods knighthood
+ knightly knightli
+ knights knight
+ knit knit
+ knits knit
+ knitters knitter
+ knitteth knitteth
+ knives knive
+ knobs knob
+ knock knock
+ knocking knock
+ knocks knock
+ knog knog
+ knoll knoll
+ knot knot
+ knots knot
+ knotted knot
+ knotty knotti
+ know know
+ knower knower
+ knowest knowest
+ knowing know
+ knowingly knowingli
+ knowings know
+ knowledge knowledg
+ known known
+ knows know
+ l l
+ la la
+ laban laban
+ label label
+ labell label
+ labienus labienu
+ labio labio
+ labor labor
+ laboring labor
+ labors labor
+ labour labour
+ laboured labour
+ labourer labour
+ labourers labour
+ labouring labour
+ labours labour
+ laboursome laboursom
+ labras labra
+ labyrinth labyrinth
+ lac lac
+ lace lace
+ laced lace
+ lacedaemon lacedaemon
+ laces lace
+ lacies laci
+ lack lack
+ lackbeard lackbeard
+ lacked lack
+ lackey lackei
+ lackeying lackei
+ lackeys lackei
+ lacking lack
+ lacks lack
+ lad lad
+ ladder ladder
+ ladders ladder
+ lade lade
+ laden laden
+ ladies ladi
+ lading lade
+ lads lad
+ lady ladi
+ ladybird ladybird
+ ladyship ladyship
+ ladyships ladyship
+ laer laer
+ laertes laert
+ lafeu lafeu
+ lag lag
+ lagging lag
+ laid laid
+ lain lain
+ laissez laissez
+ lake lake
+ lakes lake
+ lakin lakin
+ lam lam
+ lamb lamb
+ lambert lambert
+ lambkin lambkin
+ lambkins lambkin
+ lambs lamb
+ lame lame
+ lamely lame
+ lameness lame
+ lament lament
+ lamentable lament
+ lamentably lament
+ lamentation lament
+ lamentations lament
+ lamented lament
+ lamenting lament
+ lamentings lament
+ laments lament
+ lames lame
+ laming lame
+ lammas lamma
+ lammastide lammastid
+ lamound lamound
+ lamp lamp
+ lampass lampass
+ lamps lamp
+ lanc lanc
+ lancaster lancast
+ lance lanc
+ lances lanc
+ lanceth lanceth
+ lanch lanch
+ land land
+ landed land
+ landing land
+ landless landless
+ landlord landlord
+ landmen landmen
+ lands land
+ lane lane
+ lanes lane
+ langage langag
+ langley langlei
+ langton langton
+ language languag
+ languageless languageless
+ languages languag
+ langues langu
+ languish languish
+ languished languish
+ languishes languish
+ languishing languish
+ languishings languish
+ languishment languish
+ languor languor
+ lank lank
+ lantern lantern
+ lanterns lantern
+ lanthorn lanthorn
+ lap lap
+ lapis lapi
+ lapland lapland
+ lapp lapp
+ laps lap
+ lapse laps
+ lapsed laps
+ lapsing laps
+ lapwing lapw
+ laquais laquai
+ larded lard
+ larder larder
+ larding lard
+ lards lard
+ large larg
+ largely larg
+ largeness larg
+ larger larger
+ largess largess
+ largest largest
+ lark lark
+ larks lark
+ larron larron
+ lartius lartiu
+ larum larum
+ larums larum
+ las la
+ lascivious lascivi
+ lash lash
+ lass lass
+ lasses lass
+ last last
+ lasted last
+ lasting last
+ lastly lastli
+ lasts last
+ latch latch
+ latches latch
+ late late
+ lated late
+ lately late
+ later later
+ latest latest
+ lath lath
+ latin latin
+ latten latten
+ latter latter
+ lattice lattic
+ laud laud
+ laudable laudabl
+ laudis laudi
+ laugh laugh
+ laughable laughabl
+ laughed laugh
+ laugher laugher
+ laughest laughest
+ laughing laugh
+ laughs laugh
+ laughter laughter
+ launce launc
+ launcelot launcelot
+ launces launc
+ launch launch
+ laund laund
+ laundress laundress
+ laundry laundri
+ laur laur
+ laura laura
+ laurel laurel
+ laurels laurel
+ laurence laurenc
+ laus lau
+ lavache lavach
+ lave lave
+ lavee lave
+ lavender lavend
+ lavina lavina
+ lavinia lavinia
+ lavish lavish
+ lavishly lavishli
+ lavolt lavolt
+ lavoltas lavolta
+ law law
+ lawful law
+ lawfully lawfulli
+ lawless lawless
+ lawlessly lawlessli
+ lawn lawn
+ lawns lawn
+ lawrence lawrenc
+ laws law
+ lawyer lawyer
+ lawyers lawyer
+ lay lai
+ layer layer
+ layest layest
+ laying lai
+ lays lai
+ lazar lazar
+ lazars lazar
+ lazarus lazaru
+ lazy lazi
+ lc lc
+ ld ld
+ ldst ldst
+ le le
+ lead lead
+ leaden leaden
+ leader leader
+ leaders leader
+ leadest leadest
+ leading lead
+ leads lead
+ leaf leaf
+ leagu leagu
+ league leagu
+ leagued leagu
+ leaguer leaguer
+ leagues leagu
+ leah leah
+ leak leak
+ leaky leaki
+ lean lean
+ leander leander
+ leaner leaner
+ leaning lean
+ leanness lean
+ leans lean
+ leap leap
+ leaped leap
+ leaping leap
+ leaps leap
+ leapt leapt
+ lear lear
+ learn learn
+ learned learn
+ learnedly learnedli
+ learning learn
+ learnings learn
+ learns learn
+ learnt learnt
+ leas lea
+ lease leas
+ leases leas
+ leash leash
+ leasing leas
+ least least
+ leather leather
+ leathern leathern
+ leav leav
+ leave leav
+ leaven leaven
+ leavening leaven
+ leaver leaver
+ leaves leav
+ leaving leav
+ leavy leavi
+ lecher lecher
+ lecherous lecher
+ lechers lecher
+ lechery lecheri
+ lecon lecon
+ lecture lectur
+ lectures lectur
+ led led
+ leda leda
+ leech leech
+ leeches leech
+ leek leek
+ leeks leek
+ leer leer
+ leers leer
+ lees lee
+ leese lees
+ leet leet
+ leets leet
+ left left
+ leg leg
+ legacies legaci
+ legacy legaci
+ legate legat
+ legatine legatin
+ lege lege
+ legerity leger
+ leges lege
+ legg legg
+ legion legion
+ legions legion
+ legitimate legitim
+ legitimation legitim
+ legs leg
+ leicester leicest
+ leicestershire leicestershir
+ leiger leiger
+ leigers leiger
+ leisure leisur
+ leisurely leisur
+ leisures leisur
+ leman leman
+ lemon lemon
+ lena lena
+ lend lend
+ lender lender
+ lending lend
+ lendings lend
+ lends lend
+ length length
+ lengthen lengthen
+ lengthens lengthen
+ lengths length
+ lenity leniti
+ lennox lennox
+ lent lent
+ lenten lenten
+ lentus lentu
+ leo leo
+ leon leon
+ leonardo leonardo
+ leonati leonati
+ leonato leonato
+ leonatus leonatu
+ leontes leont
+ leopard leopard
+ leopards leopard
+ leper leper
+ leperous leper
+ lepidus lepidu
+ leprosy leprosi
+ lequel lequel
+ lers ler
+ les le
+ less less
+ lessen lessen
+ lessens lessen
+ lesser lesser
+ lesson lesson
+ lessoned lesson
+ lessons lesson
+ lest lest
+ lestrake lestrak
+ let let
+ lethargied lethargi
+ lethargies lethargi
+ lethargy lethargi
+ lethe leth
+ lets let
+ lett lett
+ letter letter
+ letters letter
+ letting let
+ lettuce lettuc
+ leur leur
+ leve leve
+ level level
+ levell level
+ levelled level
+ levels level
+ leven leven
+ levers lever
+ leviathan leviathan
+ leviathans leviathan
+ levied levi
+ levies levi
+ levity leviti
+ levy levi
+ levying levi
+ lewd lewd
+ lewdly lewdli
+ lewdness lewd
+ lewdsters lewdster
+ lewis lewi
+ liable liabl
+ liar liar
+ liars liar
+ libbard libbard
+ libelling libel
+ libels libel
+ liberal liber
+ liberality liber
+ liberte libert
+ liberties liberti
+ libertine libertin
+ libertines libertin
+ liberty liberti
+ library librari
+ libya libya
+ licence licenc
+ licens licen
+ license licens
+ licentious licenti
+ lichas licha
+ licio licio
+ lick lick
+ licked lick
+ licker licker
+ lictors lictor
+ lid lid
+ lids lid
+ lie lie
+ lied li
+ lief lief
+ liefest liefest
+ liege lieg
+ liegeman liegeman
+ liegemen liegemen
+ lien lien
+ lies li
+ liest liest
+ lieth lieth
+ lieu lieu
+ lieutenant lieuten
+ lieutenantry lieutenantri
+ lieutenants lieuten
+ lieve liev
+ life life
+ lifeblood lifeblood
+ lifeless lifeless
+ lifelings lifel
+ lift lift
+ lifted lift
+ lifter lifter
+ lifteth lifteth
+ lifting lift
+ lifts lift
+ lig lig
+ ligarius ligariu
+ liggens liggen
+ light light
+ lighted light
+ lighten lighten
+ lightens lighten
+ lighter lighter
+ lightest lightest
+ lightly lightli
+ lightness light
+ lightning lightn
+ lightnings lightn
+ lights light
+ lik lik
+ like like
+ liked like
+ likeliest likeliest
+ likelihood likelihood
+ likelihoods likelihood
+ likely like
+ likeness like
+ liker liker
+ likes like
+ likest likest
+ likewise likewis
+ liking like
+ likings like
+ lilies lili
+ lily lili
+ lim lim
+ limander limand
+ limb limb
+ limbeck limbeck
+ limbecks limbeck
+ limber limber
+ limbo limbo
+ limbs limb
+ lime lime
+ limed lime
+ limehouse limehous
+ limekilns limekiln
+ limit limit
+ limitation limit
+ limited limit
+ limits limit
+ limn limn
+ limp limp
+ limping limp
+ limps limp
+ lin lin
+ lincoln lincoln
+ lincolnshire lincolnshir
+ line line
+ lineal lineal
+ lineally lineal
+ lineament lineament
+ lineaments lineament
+ lined line
+ linen linen
+ linens linen
+ lines line
+ ling ling
+ lingare lingar
+ linger linger
+ lingered linger
+ lingers linger
+ linguist linguist
+ lining line
+ link link
+ links link
+ linsey linsei
+ linstock linstock
+ linta linta
+ lion lion
+ lionel lionel
+ lioness lioness
+ lions lion
+ lip lip
+ lipp lipp
+ lips lip
+ lipsbury lipsburi
+ liquid liquid
+ liquor liquor
+ liquorish liquorish
+ liquors liquor
+ lirra lirra
+ lisbon lisbon
+ lisp lisp
+ lisping lisp
+ list list
+ listen listen
+ listening listen
+ lists list
+ literatured literatur
+ lither lither
+ litter litter
+ little littl
+ littlest littlest
+ liv liv
+ live live
+ lived live
+ livelier liveli
+ livelihood livelihood
+ livelong livelong
+ lively live
+ liver liver
+ liveries liveri
+ livers liver
+ livery liveri
+ lives live
+ livest livest
+ liveth liveth
+ livia livia
+ living live
+ livings live
+ lizard lizard
+ lizards lizard
+ ll ll
+ lll lll
+ llous llou
+ lnd lnd
+ lo lo
+ loa loa
+ loach loach
+ load load
+ loaden loaden
+ loading load
+ loads load
+ loaf loaf
+ loam loam
+ loan loan
+ loath loath
+ loathe loath
+ loathed loath
+ loather loather
+ loathes loath
+ loathing loath
+ loathly loathli
+ loathness loath
+ loathsome loathsom
+ loathsomeness loathsom
+ loathsomest loathsomest
+ loaves loav
+ lob lob
+ lobbies lobbi
+ lobby lobbi
+ local local
+ lochaber lochab
+ lock lock
+ locked lock
+ locking lock
+ lockram lockram
+ locks lock
+ locusts locust
+ lode lode
+ lodg lodg
+ lodge lodg
+ lodged lodg
+ lodgers lodger
+ lodges lodg
+ lodging lodg
+ lodgings lodg
+ lodovico lodovico
+ lodowick lodowick
+ lofty lofti
+ log log
+ logger logger
+ loggerhead loggerhead
+ loggerheads loggerhead
+ loggets logget
+ logic logic
+ logs log
+ loins loin
+ loiter loiter
+ loiterer loiter
+ loiterers loiter
+ loitering loiter
+ lolling loll
+ lolls loll
+ lombardy lombardi
+ london london
+ londoners london
+ lone lone
+ loneliness loneli
+ lonely lone
+ long long
+ longaville longavil
+ longboat longboat
+ longed long
+ longer longer
+ longest longest
+ longeth longeth
+ longing long
+ longings long
+ longly longli
+ longs long
+ longtail longtail
+ loo loo
+ loof loof
+ look look
+ looked look
+ looker looker
+ lookers looker
+ lookest lookest
+ looking look
+ looks look
+ loon loon
+ loop loop
+ loos loo
+ loose loos
+ loosed loos
+ loosely loos
+ loosen loosen
+ loosing loos
+ lop lop
+ lopp lopp
+ loquitur loquitur
+ lord lord
+ lorded lord
+ lording lord
+ lordings lord
+ lordliness lordli
+ lordly lordli
+ lords lord
+ lordship lordship
+ lordships lordship
+ lorenzo lorenzo
+ lorn lorn
+ lorraine lorrain
+ lorship lorship
+ los lo
+ lose lose
+ loser loser
+ losers loser
+ loses lose
+ losest losest
+ loseth loseth
+ losing lose
+ loss loss
+ losses loss
+ lost lost
+ lot lot
+ lots lot
+ lott lott
+ lottery lotteri
+ loud loud
+ louder louder
+ loudly loudli
+ lour lour
+ loureth loureth
+ louring lour
+ louse lous
+ louses lous
+ lousy lousi
+ lout lout
+ louted lout
+ louts lout
+ louvre louvr
+ lov lov
+ love love
+ loved love
+ lovedst lovedst
+ lovel lovel
+ lovelier loveli
+ loveliness loveli
+ lovell lovel
+ lovely love
+ lover lover
+ lovered lover
+ lovers lover
+ loves love
+ lovest lovest
+ loveth loveth
+ loving love
+ lovingly lovingli
+ low low
+ lowe low
+ lower lower
+ lowest lowest
+ lowing low
+ lowliness lowli
+ lowly lowli
+ lown lown
+ lowness low
+ loyal loyal
+ loyally loyal
+ loyalties loyalti
+ loyalty loyalti
+ lozel lozel
+ lt lt
+ lubber lubber
+ lubberly lubberli
+ luc luc
+ luccicos luccico
+ luce luce
+ lucentio lucentio
+ luces luce
+ lucetta lucetta
+ luciana luciana
+ lucianus lucianu
+ lucifer lucif
+ lucifier lucifi
+ lucilius luciliu
+ lucina lucina
+ lucio lucio
+ lucius luciu
+ luck luck
+ luckier luckier
+ luckiest luckiest
+ luckily luckili
+ luckless luckless
+ lucky lucki
+ lucre lucr
+ lucrece lucrec
+ lucretia lucretia
+ lucullius luculliu
+ lucullus lucullu
+ lucy luci
+ lud lud
+ ludlow ludlow
+ lug lug
+ lugg lugg
+ luggage luggag
+ luke luke
+ lukewarm lukewarm
+ lull lull
+ lulla lulla
+ lullaby lullabi
+ lulls lull
+ lumbert lumbert
+ lump lump
+ lumpish lumpish
+ luna luna
+ lunacies lunaci
+ lunacy lunaci
+ lunatic lunat
+ lunatics lunat
+ lunes lune
+ lungs lung
+ lupercal luperc
+ lurch lurch
+ lure lure
+ lurk lurk
+ lurketh lurketh
+ lurking lurk
+ lurks lurk
+ luscious lusciou
+ lush lush
+ lust lust
+ lusted lust
+ luster luster
+ lustful lust
+ lustier lustier
+ lustiest lustiest
+ lustig lustig
+ lustihood lustihood
+ lustily lustili
+ lustre lustr
+ lustrous lustrou
+ lusts lust
+ lusty lusti
+ lute lute
+ lutes lute
+ lutestring lutestr
+ lutheran lutheran
+ luxurious luxuri
+ luxuriously luxuri
+ luxury luxuri
+ ly ly
+ lycaonia lycaonia
+ lycurguses lycurgus
+ lydia lydia
+ lye lye
+ lyen lyen
+ lying ly
+ lym lym
+ lymoges lymog
+ lynn lynn
+ lysander lysand
+ m m
+ ma ma
+ maan maan
+ mab mab
+ macbeth macbeth
+ maccabaeus maccabaeu
+ macdonwald macdonwald
+ macduff macduff
+ mace mace
+ macedon macedon
+ maces mace
+ machiavel machiavel
+ machination machin
+ machinations machin
+ machine machin
+ mack mack
+ macmorris macmorri
+ maculate macul
+ maculation macul
+ mad mad
+ madam madam
+ madame madam
+ madams madam
+ madcap madcap
+ madded mad
+ madding mad
+ made made
+ madeira madeira
+ madly madli
+ madman madman
+ madmen madmen
+ madness mad
+ madonna madonna
+ madrigals madrig
+ mads mad
+ maecenas maecena
+ maggot maggot
+ maggots maggot
+ magic magic
+ magical magic
+ magician magician
+ magistrate magistr
+ magistrates magistr
+ magnanimity magnanim
+ magnanimous magnanim
+ magni magni
+ magnifi magnifi
+ magnificence magnific
+ magnificent magnific
+ magnifico magnifico
+ magnificoes magnifico
+ magnus magnu
+ mahomet mahomet
+ mahu mahu
+ maid maid
+ maiden maiden
+ maidenhead maidenhead
+ maidenheads maidenhead
+ maidenhood maidenhood
+ maidenhoods maidenhood
+ maidenliest maidenliest
+ maidenly maidenli
+ maidens maiden
+ maidhood maidhood
+ maids maid
+ mail mail
+ mailed mail
+ mails mail
+ maim maim
+ maimed maim
+ maims maim
+ main main
+ maincourse maincours
+ maine main
+ mainly mainli
+ mainmast mainmast
+ mains main
+ maintain maintain
+ maintained maintain
+ maintains maintain
+ maintenance mainten
+ mais mai
+ maison maison
+ majestas majesta
+ majestee majeste
+ majestic majest
+ majestical majest
+ majestically majest
+ majesties majesti
+ majesty majesti
+ major major
+ majority major
+ mak mak
+ make make
+ makeless makeless
+ maker maker
+ makers maker
+ makes make
+ makest makest
+ maketh maketh
+ making make
+ makings make
+ mal mal
+ mala mala
+ maladies maladi
+ malady maladi
+ malapert malapert
+ malcolm malcolm
+ malcontent malcont
+ malcontents malcont
+ male male
+ maledictions maledict
+ malefactions malefact
+ malefactor malefactor
+ malefactors malefactor
+ males male
+ malevolence malevol
+ malevolent malevol
+ malhecho malhecho
+ malice malic
+ malicious malici
+ maliciously malici
+ malign malign
+ malignancy malign
+ malignant malign
+ malignantly malignantli
+ malkin malkin
+ mall mall
+ mallard mallard
+ mallet mallet
+ mallows mallow
+ malmsey malmsei
+ malt malt
+ maltworms maltworm
+ malvolio malvolio
+ mamillius mamilliu
+ mammering mammer
+ mammet mammet
+ mammets mammet
+ mammock mammock
+ man man
+ manacle manacl
+ manacles manacl
+ manage manag
+ managed manag
+ manager manag
+ managing manag
+ manakin manakin
+ manchus manchu
+ mandate mandat
+ mandragora mandragora
+ mandrake mandrak
+ mandrakes mandrak
+ mane mane
+ manent manent
+ manes mane
+ manet manet
+ manfully manfulli
+ mangle mangl
+ mangled mangl
+ mangles mangl
+ mangling mangl
+ mangy mangi
+ manhood manhood
+ manhoods manhood
+ manifest manifest
+ manifested manifest
+ manifests manifest
+ manifold manifold
+ manifoldly manifoldli
+ manka manka
+ mankind mankind
+ manlike manlik
+ manly manli
+ mann mann
+ manna manna
+ manner manner
+ mannerly mannerli
+ manners manner
+ manningtree manningtre
+ mannish mannish
+ manor manor
+ manors manor
+ mans man
+ mansion mansion
+ mansionry mansionri
+ mansions mansion
+ manslaughter manslaught
+ mantle mantl
+ mantled mantl
+ mantles mantl
+ mantua mantua
+ mantuan mantuan
+ manual manual
+ manure manur
+ manured manur
+ manus manu
+ many mani
+ map map
+ mapp mapp
+ maps map
+ mar mar
+ marble marbl
+ marbled marbl
+ marcade marcad
+ marcellus marcellu
+ march march
+ marches march
+ marcheth marcheth
+ marching march
+ marchioness marchio
+ marchpane marchpan
+ marcians marcian
+ marcius marciu
+ marcus marcu
+ mardian mardian
+ mare mare
+ mares mare
+ marg marg
+ margarelon margarelon
+ margaret margaret
+ marge marg
+ margent margent
+ margery margeri
+ maria maria
+ marian marian
+ mariana mariana
+ maries mari
+ marigold marigold
+ mariner marin
+ mariners marin
+ maritime maritim
+ marjoram marjoram
+ mark mark
+ marked mark
+ market market
+ marketable market
+ marketplace marketplac
+ markets market
+ marking mark
+ markman markman
+ marks mark
+ marl marl
+ marle marl
+ marmoset marmoset
+ marquess marquess
+ marquis marqui
+ marr marr
+ marriage marriag
+ marriages marriag
+ married marri
+ marries marri
+ marring mar
+ marrow marrow
+ marrowless marrowless
+ marrows marrow
+ marry marri
+ marrying marri
+ mars mar
+ marseilles marseil
+ marsh marsh
+ marshal marshal
+ marshalsea marshalsea
+ marshalship marshalship
+ mart mart
+ marted mart
+ martem martem
+ martext martext
+ martial martial
+ martin martin
+ martino martino
+ martius martiu
+ martlemas martlema
+ martlet martlet
+ marts mart
+ martyr martyr
+ martyrs martyr
+ marullus marullu
+ marv marv
+ marvel marvel
+ marvell marvel
+ marvellous marvel
+ marvellously marvel
+ marvels marvel
+ mary mari
+ mas ma
+ masculine masculin
+ masham masham
+ mask mask
+ masked mask
+ masker masker
+ maskers masker
+ masking mask
+ masks mask
+ mason mason
+ masonry masonri
+ masons mason
+ masque masqu
+ masquers masquer
+ masques masqu
+ masquing masqu
+ mass mass
+ massacre massacr
+ massacres massacr
+ masses mass
+ massy massi
+ mast mast
+ mastcr mastcr
+ master master
+ masterdom masterdom
+ masterest masterest
+ masterless masterless
+ masterly masterli
+ masterpiece masterpiec
+ masters master
+ mastership mastership
+ mastic mastic
+ mastiff mastiff
+ mastiffs mastiff
+ masts mast
+ match match
+ matches match
+ matcheth matcheth
+ matching match
+ matchless matchless
+ mate mate
+ mated mate
+ mater mater
+ material materi
+ mates mate
+ mathematics mathemat
+ matin matin
+ matron matron
+ matrons matron
+ matter matter
+ matters matter
+ matthew matthew
+ mattock mattock
+ mattress mattress
+ mature matur
+ maturity matur
+ maud maud
+ maudlin maudlin
+ maugre maugr
+ maul maul
+ maund maund
+ mauri mauri
+ mauritania mauritania
+ mauvais mauvai
+ maw maw
+ maws maw
+ maxim maxim
+ may mai
+ mayday maydai
+ mayest mayest
+ mayor mayor
+ maypole maypol
+ mayst mayst
+ maz maz
+ maze maze
+ mazed maze
+ mazes maze
+ mazzard mazzard
+ me me
+ meacock meacock
+ mead mead
+ meadow meadow
+ meadows meadow
+ meads mead
+ meagre meagr
+ meal meal
+ meals meal
+ mealy meali
+ mean mean
+ meanders meander
+ meaner meaner
+ meanest meanest
+ meaneth meaneth
+ meaning mean
+ meanings mean
+ meanly meanli
+ means mean
+ meant meant
+ meantime meantim
+ meanwhile meanwhil
+ measles measl
+ measur measur
+ measurable measur
+ measure measur
+ measured measur
+ measureless measureless
+ measures measur
+ measuring measur
+ meat meat
+ meats meat
+ mechanic mechan
+ mechanical mechan
+ mechanicals mechan
+ mechanics mechan
+ mechante mechant
+ med med
+ medal medal
+ meddle meddl
+ meddler meddler
+ meddling meddl
+ mede mede
+ medea medea
+ media media
+ mediation mediat
+ mediators mediat
+ medice medic
+ medicinal medicin
+ medicine medicin
+ medicines medicin
+ meditate medit
+ meditates medit
+ meditating medit
+ meditation medit
+ meditations medit
+ mediterranean mediterranean
+ mediterraneum mediterraneum
+ medlar medlar
+ medlars medlar
+ meed meed
+ meeds meed
+ meek meek
+ meekly meekli
+ meekness meek
+ meet meet
+ meeter meeter
+ meetest meetest
+ meeting meet
+ meetings meet
+ meetly meetli
+ meetness meet
+ meets meet
+ meg meg
+ mehercle mehercl
+ meilleur meilleur
+ meiny meini
+ meisen meisen
+ melancholies melancholi
+ melancholy melancholi
+ melford melford
+ mell mell
+ mellifluous melliflu
+ mellow mellow
+ mellowing mellow
+ melodious melodi
+ melody melodi
+ melt melt
+ melted melt
+ melteth melteth
+ melting melt
+ melts melt
+ melun melun
+ member member
+ members member
+ memento memento
+ memorable memor
+ memorandums memorandum
+ memorial memori
+ memorials memori
+ memories memori
+ memoriz memoriz
+ memorize memor
+ memory memori
+ memphis memphi
+ men men
+ menac menac
+ menace menac
+ menaces menac
+ menaphon menaphon
+ menas mena
+ mend mend
+ mended mend
+ mender mender
+ mending mend
+ mends mend
+ menecrates menecr
+ menelaus menelau
+ menenius meneniu
+ mental mental
+ menteith menteith
+ mention mention
+ mentis menti
+ menton menton
+ mephostophilus mephostophilu
+ mer mer
+ mercatante mercatant
+ mercatio mercatio
+ mercenaries mercenari
+ mercenary mercenari
+ mercer mercer
+ merchandise merchandis
+ merchandized merchand
+ merchant merchant
+ merchants merchant
+ mercies merci
+ merciful merci
+ mercifully mercifulli
+ merciless merciless
+ mercurial mercuri
+ mercuries mercuri
+ mercury mercuri
+ mercutio mercutio
+ mercy merci
+ mere mere
+ mered mere
+ merely mere
+ merest merest
+ meridian meridian
+ merit merit
+ merited merit
+ meritorious meritori
+ merits merit
+ merlin merlin
+ mermaid mermaid
+ mermaids mermaid
+ merops merop
+ merrier merrier
+ merriest merriest
+ merrily merrili
+ merriman merriman
+ merriment merriment
+ merriments merriment
+ merriness merri
+ merry merri
+ mervailous mervail
+ mes me
+ mesh mesh
+ meshes mesh
+ mesopotamia mesopotamia
+ mess mess
+ message messag
+ messages messag
+ messala messala
+ messaline messalin
+ messenger messeng
+ messengers messeng
+ messes mess
+ messina messina
+ met met
+ metal metal
+ metals metal
+ metamorphis metamorphi
+ metamorphoses metamorphos
+ metaphor metaphor
+ metaphysical metaphys
+ metaphysics metaphys
+ mete mete
+ metellus metellu
+ meteor meteor
+ meteors meteor
+ meteyard meteyard
+ metheglin metheglin
+ metheglins metheglin
+ methink methink
+ methinks methink
+ method method
+ methods method
+ methought methought
+ methoughts methought
+ metre metr
+ metres metr
+ metropolis metropoli
+ mette mett
+ mettle mettl
+ mettled mettl
+ meus meu
+ mew mew
+ mewed mew
+ mewling mewl
+ mexico mexico
+ mi mi
+ mice mice
+ michael michael
+ michaelmas michaelma
+ micher micher
+ miching mich
+ mickle mickl
+ microcosm microcosm
+ mid mid
+ midas mida
+ middest middest
+ middle middl
+ middleham middleham
+ midnight midnight
+ midriff midriff
+ midst midst
+ midsummer midsumm
+ midway midwai
+ midwife midwif
+ midwives midwiv
+ mienne mienn
+ might might
+ mightful might
+ mightier mightier
+ mightiest mightiest
+ mightily mightili
+ mightiness mighti
+ mightst mightst
+ mighty mighti
+ milan milan
+ milch milch
+ mild mild
+ milder milder
+ mildest mildest
+ mildew mildew
+ mildews mildew
+ mildly mildli
+ mildness mild
+ mile mile
+ miles mile
+ milford milford
+ militarist militarist
+ military militari
+ milk milk
+ milking milk
+ milkmaid milkmaid
+ milks milk
+ milksops milksop
+ milky milki
+ mill mill
+ mille mill
+ miller miller
+ milliner millin
+ million million
+ millioned million
+ millions million
+ mills mill
+ millstones millston
+ milo milo
+ mimic mimic
+ minc minc
+ mince minc
+ minces minc
+ mincing minc
+ mind mind
+ minded mind
+ minding mind
+ mindless mindless
+ minds mind
+ mine mine
+ mineral miner
+ minerals miner
+ minerva minerva
+ mines mine
+ mingle mingl
+ mingled mingl
+ mingling mingl
+ minikin minikin
+ minim minim
+ minime minim
+ minimo minimo
+ minimus minimu
+ mining mine
+ minion minion
+ minions minion
+ minist minist
+ minister minist
+ ministers minist
+ ministration ministr
+ minnow minnow
+ minnows minnow
+ minola minola
+ minority minor
+ minos mino
+ minotaurs minotaur
+ minstrel minstrel
+ minstrels minstrel
+ minstrelsy minstrelsi
+ mint mint
+ mints mint
+ minute minut
+ minutely minut
+ minutes minut
+ minx minx
+ mio mio
+ mir mir
+ mirable mirabl
+ miracle miracl
+ miracles miracl
+ miraculous miracul
+ miranda miranda
+ mire mire
+ mirror mirror
+ mirrors mirror
+ mirth mirth
+ mirthful mirth
+ miry miri
+ mis mi
+ misadventur misadventur
+ misadventure misadventur
+ misanthropos misanthropo
+ misapplied misappli
+ misbecame misbecam
+ misbecom misbecom
+ misbecome misbecom
+ misbegot misbegot
+ misbegotten misbegotten
+ misbeliever misbeliev
+ misbelieving misbeliev
+ misbhav misbhav
+ miscall miscal
+ miscalled miscal
+ miscarried miscarri
+ miscarries miscarri
+ miscarry miscarri
+ miscarrying miscarri
+ mischance mischanc
+ mischances mischanc
+ mischief mischief
+ mischiefs mischief
+ mischievous mischiev
+ misconceived misconceiv
+ misconst misconst
+ misconster misconst
+ misconstruction misconstruct
+ misconstrued misconstru
+ misconstrues misconstru
+ miscreant miscreant
+ miscreate miscreat
+ misdeed misde
+ misdeeds misde
+ misdemean misdemean
+ misdemeanours misdemeanour
+ misdoubt misdoubt
+ misdoubteth misdoubteth
+ misdoubts misdoubt
+ misenum misenum
+ miser miser
+ miserable miser
+ miserably miser
+ misericorde misericord
+ miseries miseri
+ misers miser
+ misery miseri
+ misfortune misfortun
+ misfortunes misfortun
+ misgive misgiv
+ misgives misgiv
+ misgiving misgiv
+ misgoverned misgovern
+ misgovernment misgovern
+ misgraffed misgraf
+ misguide misguid
+ mishap mishap
+ mishaps mishap
+ misheard misheard
+ misinterpret misinterpret
+ mislead mislead
+ misleader mislead
+ misleaders mislead
+ misleading mislead
+ misled misl
+ mislike mislik
+ misord misord
+ misplac misplac
+ misplaced misplac
+ misplaces misplac
+ mispris mispri
+ misprised mispris
+ misprision mispris
+ misprizing mispriz
+ misproud misproud
+ misquote misquot
+ misreport misreport
+ miss miss
+ missed miss
+ misses miss
+ misshap misshap
+ misshapen misshapen
+ missheathed missheath
+ missing miss
+ missingly missingli
+ missions mission
+ missive missiv
+ missives missiv
+ misspoke misspok
+ mist mist
+ mista mista
+ mistak mistak
+ mistake mistak
+ mistaken mistaken
+ mistakes mistak
+ mistaketh mistaketh
+ mistaking mistak
+ mistakings mistak
+ mistemp mistemp
+ mistempered mistemp
+ misterm misterm
+ mistful mist
+ misthink misthink
+ misthought misthought
+ mistletoe mistleto
+ mistook mistook
+ mistreadings mistread
+ mistress mistress
+ mistresses mistress
+ mistresss mistresss
+ mistriship mistriship
+ mistrust mistrust
+ mistrusted mistrust
+ mistrustful mistrust
+ mistrusting mistrust
+ mists mist
+ misty misti
+ misus misu
+ misuse misus
+ misused misus
+ misuses misus
+ mites mite
+ mithridates mithrid
+ mitigate mitig
+ mitigation mitig
+ mix mix
+ mixed mix
+ mixture mixtur
+ mixtures mixtur
+ mm mm
+ mnd mnd
+ moan moan
+ moans moan
+ moat moat
+ moated moat
+ mobled mobl
+ mock mock
+ mockable mockabl
+ mocker mocker
+ mockeries mockeri
+ mockers mocker
+ mockery mockeri
+ mocking mock
+ mocks mock
+ mockvater mockvat
+ mockwater mockwat
+ model model
+ modena modena
+ moderate moder
+ moderately moder
+ moderation moder
+ modern modern
+ modest modest
+ modesties modesti
+ modestly modestli
+ modesty modesti
+ modicums modicum
+ modo modo
+ module modul
+ moe moe
+ moi moi
+ moiety moieti
+ moist moist
+ moisten moisten
+ moisture moistur
+ moldwarp moldwarp
+ mole mole
+ molehill molehil
+ moles mole
+ molest molest
+ molestation molest
+ mollification mollif
+ mollis molli
+ molten molten
+ molto molto
+ mome mome
+ moment moment
+ momentary momentari
+ moming mome
+ mon mon
+ monachum monachum
+ monarch monarch
+ monarchies monarchi
+ monarchize monarch
+ monarcho monarcho
+ monarchs monarch
+ monarchy monarchi
+ monast monast
+ monastery monasteri
+ monastic monast
+ monday mondai
+ monde mond
+ money monei
+ moneys monei
+ mong mong
+ monger monger
+ mongers monger
+ monging mong
+ mongrel mongrel
+ mongrels mongrel
+ mongst mongst
+ monk monk
+ monkey monkei
+ monkeys monkei
+ monks monk
+ monmouth monmouth
+ monopoly monopoli
+ mons mon
+ monsieur monsieur
+ monsieurs monsieur
+ monster monster
+ monsters monster
+ monstrous monstrou
+ monstrously monstrous
+ monstrousness monstrous
+ monstruosity monstruos
+ montacute montacut
+ montage montag
+ montague montagu
+ montagues montagu
+ montano montano
+ montant montant
+ montez montez
+ montferrat montferrat
+ montgomery montgomeri
+ month month
+ monthly monthli
+ months month
+ montjoy montjoi
+ monument monument
+ monumental monument
+ monuments monument
+ mood mood
+ moods mood
+ moody moodi
+ moon moon
+ moonbeams moonbeam
+ moonish moonish
+ moonlight moonlight
+ moons moon
+ moonshine moonshin
+ moonshines moonshin
+ moor moor
+ moorfields moorfield
+ moors moor
+ moorship moorship
+ mop mop
+ mope mope
+ moping mope
+ mopping mop
+ mopsa mopsa
+ moral moral
+ moraler moral
+ morality moral
+ moralize moral
+ mordake mordak
+ more more
+ moreover moreov
+ mores more
+ morgan morgan
+ mori mori
+ morisco morisco
+ morn morn
+ morning morn
+ mornings morn
+ morocco morocco
+ morris morri
+ morrow morrow
+ morrows morrow
+ morsel morsel
+ morsels morsel
+ mort mort
+ mortal mortal
+ mortality mortal
+ mortally mortal
+ mortals mortal
+ mortar mortar
+ mortgaged mortgag
+ mortified mortifi
+ mortifying mortifi
+ mortimer mortim
+ mortimers mortim
+ mortis morti
+ mortise mortis
+ morton morton
+ mose mose
+ moss moss
+ mossgrown mossgrown
+ most most
+ mote mote
+ moth moth
+ mother mother
+ mothers mother
+ moths moth
+ motion motion
+ motionless motionless
+ motions motion
+ motive motiv
+ motives motiv
+ motley motlei
+ mots mot
+ mought mought
+ mould mould
+ moulded mould
+ mouldeth mouldeth
+ moulds mould
+ mouldy mouldi
+ moult moult
+ moulten moulten
+ mounch mounch
+ mounseur mounseur
+ mounsieur mounsieur
+ mount mount
+ mountain mountain
+ mountaineer mountain
+ mountaineers mountain
+ mountainous mountain
+ mountains mountain
+ mountant mountant
+ mountanto mountanto
+ mountebank mountebank
+ mountebanks mountebank
+ mounted mount
+ mounteth mounteth
+ mounting mount
+ mounts mount
+ mourn mourn
+ mourned mourn
+ mourner mourner
+ mourners mourner
+ mournful mourn
+ mournfully mournfulli
+ mourning mourn
+ mourningly mourningli
+ mournings mourn
+ mourns mourn
+ mous mou
+ mouse mous
+ mousetrap mousetrap
+ mousing mous
+ mouth mouth
+ mouthed mouth
+ mouths mouth
+ mov mov
+ movables movabl
+ move move
+ moveable moveabl
+ moveables moveabl
+ moved move
+ mover mover
+ movers mover
+ moves move
+ moveth moveth
+ moving move
+ movingly movingli
+ movousus movousu
+ mow mow
+ mowbray mowbrai
+ mower mower
+ mowing mow
+ mows mow
+ moy moi
+ moys moi
+ moyses moys
+ mrs mr
+ much much
+ muck muck
+ mud mud
+ mudded mud
+ muddied muddi
+ muddy muddi
+ muffins muffin
+ muffl muffl
+ muffle muffl
+ muffled muffl
+ muffler muffler
+ muffling muffl
+ mugger mugger
+ mugs mug
+ mulberries mulberri
+ mulberry mulberri
+ mule mule
+ mules mule
+ muleteers mulet
+ mulier mulier
+ mulieres mulier
+ muliteus muliteu
+ mull mull
+ mulmutius mulmutiu
+ multiplied multipli
+ multiply multipli
+ multiplying multipli
+ multipotent multipot
+ multitude multitud
+ multitudes multitud
+ multitudinous multitudin
+ mum mum
+ mumble mumbl
+ mumbling mumbl
+ mummers mummer
+ mummy mummi
+ mun mun
+ munch munch
+ muniments muniment
+ munition munit
+ murd murd
+ murder murder
+ murdered murder
+ murderer murder
+ murderers murder
+ murdering murder
+ murderous murder
+ murders murder
+ mure mure
+ murk murk
+ murkiest murkiest
+ murky murki
+ murmur murmur
+ murmurers murmur
+ murmuring murmur
+ murrain murrain
+ murray murrai
+ murrion murrion
+ murther murther
+ murtherer murther
+ murtherers murther
+ murthering murther
+ murtherous murther
+ murthers murther
+ mus mu
+ muscadel muscadel
+ muscovites muscovit
+ muscovits muscovit
+ muscovy muscovi
+ muse muse
+ muses muse
+ mush mush
+ mushrooms mushroom
+ music music
+ musical music
+ musician musician
+ musicians musician
+ musics music
+ musing muse
+ musings muse
+ musk musk
+ musket musket
+ muskets musket
+ muskos musko
+ muss muss
+ mussel mussel
+ mussels mussel
+ must must
+ mustachio mustachio
+ mustard mustard
+ mustardseed mustardse
+ muster muster
+ mustering muster
+ musters muster
+ musty musti
+ mutability mutabl
+ mutable mutabl
+ mutation mutat
+ mutations mutat
+ mute mute
+ mutes mute
+ mutest mutest
+ mutine mutin
+ mutineer mutin
+ mutineers mutin
+ mutines mutin
+ mutinies mutini
+ mutinous mutin
+ mutiny mutini
+ mutius mutiu
+ mutter mutter
+ muttered mutter
+ mutton mutton
+ muttons mutton
+ mutual mutual
+ mutualities mutual
+ mutually mutual
+ muzzl muzzl
+ muzzle muzzl
+ muzzled muzzl
+ mv mv
+ mww mww
+ my my
+ mynheers mynheer
+ myrmidon myrmidon
+ myrmidons myrmidon
+ myrtle myrtl
+ myself myself
+ myst myst
+ mysteries mysteri
+ mystery mysteri
+ n n
+ nag nag
+ nage nage
+ nags nag
+ naiads naiad
+ nail nail
+ nails nail
+ nak nak
+ naked nake
+ nakedness naked
+ nal nal
+ nam nam
+ name name
+ named name
+ nameless nameless
+ namely name
+ names name
+ namest namest
+ naming name
+ nan nan
+ nance nanc
+ nap nap
+ nape nape
+ napes nape
+ napkin napkin
+ napkins napkin
+ naples napl
+ napless napless
+ napping nap
+ naps nap
+ narbon narbon
+ narcissus narcissu
+ narines narin
+ narrow narrow
+ narrowly narrowli
+ naso naso
+ nasty nasti
+ nathaniel nathaniel
+ natifs natif
+ nation nation
+ nations nation
+ native nativ
+ nativity nativ
+ natur natur
+ natural natur
+ naturalize natur
+ naturally natur
+ nature natur
+ natured natur
+ natures natur
+ natus natu
+ naught naught
+ naughtily naughtili
+ naughty naughti
+ navarre navarr
+ nave nave
+ navel navel
+ navigation navig
+ navy navi
+ nay nai
+ nayward nayward
+ nayword nayword
+ nazarite nazarit
+ ne ne
+ neaf neaf
+ neamnoins neamnoin
+ neanmoins neanmoin
+ neapolitan neapolitan
+ neapolitans neapolitan
+ near near
+ nearer nearer
+ nearest nearest
+ nearly nearli
+ nearness near
+ neat neat
+ neatly neatli
+ neb neb
+ nebour nebour
+ nebuchadnezzar nebuchadnezzar
+ nec nec
+ necessaries necessari
+ necessarily necessarili
+ necessary necessari
+ necessitied necess
+ necessities necess
+ necessity necess
+ neck neck
+ necklace necklac
+ necks neck
+ nectar nectar
+ ned ned
+ nedar nedar
+ need need
+ needed need
+ needer needer
+ needful need
+ needfull needful
+ needing need
+ needle needl
+ needles needl
+ needless needless
+ needly needli
+ needs need
+ needy needi
+ neer neer
+ neeze neez
+ nefas nefa
+ negation negat
+ negative neg
+ negatives neg
+ neglect neglect
+ neglected neglect
+ neglecting neglect
+ neglectingly neglectingli
+ neglection neglect
+ negligence neglig
+ negligent neglig
+ negotiate negoti
+ negotiations negoti
+ negro negro
+ neigh neigh
+ neighbors neighbor
+ neighbour neighbour
+ neighbourhood neighbourhood
+ neighbouring neighbour
+ neighbourly neighbourli
+ neighbours neighbour
+ neighing neigh
+ neighs neigh
+ neither neither
+ nell nell
+ nemean nemean
+ nemesis nemesi
+ neoptolemus neoptolemu
+ nephew nephew
+ nephews nephew
+ neptune neptun
+ ner ner
+ nereides nereid
+ nerissa nerissa
+ nero nero
+ neroes nero
+ ners ner
+ nerve nerv
+ nerves nerv
+ nervii nervii
+ nervy nervi
+ nessus nessu
+ nest nest
+ nestor nestor
+ nests nest
+ net net
+ nether nether
+ netherlands netherland
+ nets net
+ nettle nettl
+ nettled nettl
+ nettles nettl
+ neuter neuter
+ neutral neutral
+ nev nev
+ never never
+ nevil nevil
+ nevils nevil
+ new new
+ newborn newborn
+ newer newer
+ newest newest
+ newgate newgat
+ newly newli
+ newness new
+ news new
+ newsmongers newsmong
+ newt newt
+ newts newt
+ next next
+ nibbling nibbl
+ nicanor nicanor
+ nice nice
+ nicely nice
+ niceness nice
+ nicer nicer
+ nicety niceti
+ nicholas nichola
+ nick nick
+ nickname nicknam
+ nicks nick
+ niece niec
+ nieces niec
+ niggard niggard
+ niggarding niggard
+ niggardly niggardli
+ nigh nigh
+ night night
+ nightcap nightcap
+ nightcaps nightcap
+ nighted night
+ nightgown nightgown
+ nightingale nightingal
+ nightingales nightingal
+ nightly nightli
+ nightmare nightmar
+ nights night
+ nightwork nightwork
+ nihil nihil
+ nile nile
+ nill nill
+ nilus nilu
+ nimble nimbl
+ nimbleness nimbl
+ nimbler nimbler
+ nimbly nimbl
+ nine nine
+ nineteen nineteen
+ ning ning
+ ningly ningli
+ ninny ninni
+ ninth ninth
+ ninus ninu
+ niobe niob
+ niobes niob
+ nip nip
+ nipp nipp
+ nipping nip
+ nipple nippl
+ nips nip
+ nit nit
+ nly nly
+ nnight nnight
+ nnights nnight
+ no no
+ noah noah
+ nob nob
+ nobility nobil
+ nobis nobi
+ noble nobl
+ nobleman nobleman
+ noblemen noblemen
+ nobleness nobl
+ nobler nobler
+ nobles nobl
+ noblesse nobless
+ noblest noblest
+ nobly nobli
+ nobody nobodi
+ noces noce
+ nod nod
+ nodded nod
+ nodding nod
+ noddle noddl
+ noddles noddl
+ noddy noddi
+ nods nod
+ noes noe
+ nointed noint
+ nois noi
+ noise nois
+ noiseless noiseless
+ noisemaker noisemak
+ noises nois
+ noisome noisom
+ nole nole
+ nominate nomin
+ nominated nomin
+ nomination nomin
+ nominativo nominativo
+ non non
+ nonage nonag
+ nonce nonc
+ none none
+ nonino nonino
+ nonny nonni
+ nonpareil nonpareil
+ nonsuits nonsuit
+ nony noni
+ nook nook
+ nooks nook
+ noon noon
+ noonday noondai
+ noontide noontid
+ nor nor
+ norbery norberi
+ norfolk norfolk
+ norman norman
+ normandy normandi
+ normans norman
+ north north
+ northampton northampton
+ northamptonshire northamptonshir
+ northerly northerli
+ northern northern
+ northgate northgat
+ northumberland northumberland
+ northumberlands northumberland
+ northward northward
+ norway norwai
+ norways norwai
+ norwegian norwegian
+ norweyan norweyan
+ nos no
+ nose nose
+ nosegays nosegai
+ noseless noseless
+ noses nose
+ noster noster
+ nostra nostra
+ nostril nostril
+ nostrils nostril
+ not not
+ notable notabl
+ notably notabl
+ notary notari
+ notch notch
+ note note
+ notebook notebook
+ noted note
+ notedly notedli
+ notes note
+ notest notest
+ noteworthy noteworthi
+ nothing noth
+ nothings noth
+ notice notic
+ notify notifi
+ noting note
+ notion notion
+ notorious notori
+ notoriously notori
+ notre notr
+ notwithstanding notwithstand
+ nought nought
+ noun noun
+ nouns noun
+ nourish nourish
+ nourished nourish
+ nourisher nourish
+ nourishes nourish
+ nourisheth nourisheth
+ nourishing nourish
+ nourishment nourish
+ nous nou
+ novel novel
+ novelties novelti
+ novelty novelti
+ noverbs noverb
+ novi novi
+ novice novic
+ novices novic
+ novum novum
+ now now
+ nowhere nowher
+ noyance noyanc
+ ns ns
+ nt nt
+ nubibus nubibu
+ numa numa
+ numb numb
+ number number
+ numbered number
+ numbering number
+ numberless numberless
+ numbers number
+ numbness numb
+ nun nun
+ nuncio nuncio
+ nuncle nuncl
+ nunnery nunneri
+ nuns nun
+ nuntius nuntiu
+ nuptial nuptial
+ nurs nur
+ nurse nurs
+ nursed nurs
+ nurser nurser
+ nursery nurseri
+ nurses nurs
+ nurseth nurseth
+ nursh nursh
+ nursing nurs
+ nurtur nurtur
+ nurture nurtur
+ nut nut
+ nuthook nuthook
+ nutmeg nutmeg
+ nutmegs nutmeg
+ nutriment nutriment
+ nuts nut
+ nutshell nutshel
+ ny ny
+ nym nym
+ nymph nymph
+ nymphs nymph
+ o o
+ oak oak
+ oaken oaken
+ oaks oak
+ oared oar
+ oars oar
+ oatcake oatcak
+ oaten oaten
+ oath oath
+ oathable oathabl
+ oaths oath
+ oats oat
+ ob ob
+ obduracy obduraci
+ obdurate obdur
+ obedience obedi
+ obedient obedi
+ obeisance obeis
+ oberon oberon
+ obey obei
+ obeyed obei
+ obeying obei
+ obeys obei
+ obidicut obidicut
+ object object
+ objected object
+ objections object
+ objects object
+ oblation oblat
+ oblations oblat
+ obligation oblig
+ obligations oblig
+ obliged oblig
+ oblique obliqu
+ oblivion oblivion
+ oblivious oblivi
+ obloquy obloqui
+ obscene obscen
+ obscenely obscen
+ obscur obscur
+ obscure obscur
+ obscured obscur
+ obscurely obscur
+ obscures obscur
+ obscuring obscur
+ obscurity obscur
+ obsequies obsequi
+ obsequious obsequi
+ obsequiously obsequi
+ observ observ
+ observance observ
+ observances observ
+ observancy observ
+ observant observ
+ observants observ
+ observation observ
+ observe observ
+ observed observ
+ observer observ
+ observers observ
+ observing observ
+ observingly observingli
+ obsque obsqu
+ obstacle obstacl
+ obstacles obstacl
+ obstinacy obstinaci
+ obstinate obstin
+ obstinately obstin
+ obstruct obstruct
+ obstruction obstruct
+ obstructions obstruct
+ obtain obtain
+ obtained obtain
+ obtaining obtain
+ occasion occas
+ occasions occas
+ occident occid
+ occidental occident
+ occulted occult
+ occupat occupat
+ occupation occup
+ occupations occup
+ occupied occupi
+ occupies occupi
+ occupy occupi
+ occurrence occurr
+ occurrences occurr
+ occurrents occurr
+ ocean ocean
+ oceans ocean
+ octavia octavia
+ octavius octaviu
+ ocular ocular
+ od od
+ odd odd
+ oddest oddest
+ oddly oddli
+ odds odd
+ ode od
+ odes od
+ odious odiou
+ odoriferous odorifer
+ odorous odor
+ odour odour
+ odours odour
+ ods od
+ oeillades oeillad
+ oes oe
+ oeuvres oeuvr
+ of of
+ ofephesus ofephesu
+ off off
+ offal offal
+ offence offenc
+ offenceful offenc
+ offences offenc
+ offend offend
+ offended offend
+ offendendo offendendo
+ offender offend
+ offenders offend
+ offendeth offendeth
+ offending offend
+ offendress offendress
+ offends offend
+ offense offens
+ offenseless offenseless
+ offenses offens
+ offensive offens
+ offer offer
+ offered offer
+ offering offer
+ offerings offer
+ offers offer
+ offert offert
+ offic offic
+ office offic
+ officed offic
+ officer offic
+ officers offic
+ offices offic
+ official offici
+ officious offici
+ offspring offspr
+ oft oft
+ often often
+ oftener often
+ oftentimes oftentim
+ oh oh
+ oil oil
+ oils oil
+ oily oili
+ old old
+ oldcastle oldcastl
+ olden olden
+ older older
+ oldest oldest
+ oldness old
+ olive oliv
+ oliver oliv
+ olivers oliv
+ olives oliv
+ olivia olivia
+ olympian olympian
+ olympus olympu
+ oman oman
+ omans oman
+ omen omen
+ ominous omin
+ omission omiss
+ omit omit
+ omittance omitt
+ omitted omit
+ omitting omit
+ omne omn
+ omnes omn
+ omnipotent omnipot
+ on on
+ once onc
+ one on
+ ones on
+ oneyers oney
+ ongles ongl
+ onion onion
+ onions onion
+ only onli
+ onset onset
+ onward onward
+ onwards onward
+ oo oo
+ ooze ooz
+ oozes ooz
+ oozy oozi
+ op op
+ opal opal
+ ope op
+ open open
+ opener open
+ opening open
+ openly openli
+ openness open
+ opens open
+ operant oper
+ operate oper
+ operation oper
+ operations oper
+ operative oper
+ opes op
+ oph oph
+ ophelia ophelia
+ opinion opinion
+ opinions opinion
+ opportune opportun
+ opportunities opportun
+ opportunity opportun
+ oppos oppo
+ oppose oppos
+ opposed oppos
+ opposeless opposeless
+ opposer oppos
+ opposers oppos
+ opposes oppos
+ opposing oppos
+ opposite opposit
+ opposites opposit
+ opposition opposit
+ oppositions opposit
+ oppress oppress
+ oppressed oppress
+ oppresses oppress
+ oppresseth oppresseth
+ oppressing oppress
+ oppression oppress
+ oppressor oppressor
+ opprest opprest
+ opprobriously opprobri
+ oppugnancy oppugn
+ opulency opul
+ opulent opul
+ or or
+ oracle oracl
+ oracles oracl
+ orange orang
+ oration orat
+ orator orat
+ orators orat
+ oratory oratori
+ orb orb
+ orbed orb
+ orbs orb
+ orchard orchard
+ orchards orchard
+ ord ord
+ ordain ordain
+ ordained ordain
+ ordaining ordain
+ order order
+ ordered order
+ ordering order
+ orderless orderless
+ orderly orderli
+ orders order
+ ordinance ordin
+ ordinant ordin
+ ordinaries ordinari
+ ordinary ordinari
+ ordnance ordnanc
+ ords ord
+ ordure ordur
+ ore or
+ organ organ
+ organs organ
+ orgillous orgil
+ orient orient
+ orifex orifex
+ origin origin
+ original origin
+ orisons orison
+ ork ork
+ orlando orlando
+ orld orld
+ orleans orlean
+ ornament ornament
+ ornaments ornament
+ orodes orod
+ orphan orphan
+ orphans orphan
+ orpheus orpheu
+ orsino orsino
+ ort ort
+ orthography orthographi
+ orts ort
+ oscorbidulchos oscorbidulcho
+ osier osier
+ osiers osier
+ osprey osprei
+ osr osr
+ osric osric
+ ossa ossa
+ ost ost
+ ostent ostent
+ ostentare ostentar
+ ostentation ostent
+ ostents ostent
+ ostler ostler
+ ostlers ostler
+ ostrich ostrich
+ osw osw
+ oswald oswald
+ othello othello
+ other other
+ othergates otherg
+ others other
+ otherwhere otherwher
+ otherwhiles otherwhil
+ otherwise otherwis
+ otter otter
+ ottoman ottoman
+ ottomites ottomit
+ oublie oubli
+ ouches ouch
+ ought ought
+ oui oui
+ ounce ounc
+ ounces ounc
+ ouphes ouph
+ our our
+ ours our
+ ourself ourself
+ ourselves ourselv
+ ousel ousel
+ out out
+ outbids outbid
+ outbrave outbrav
+ outbraves outbrav
+ outbreak outbreak
+ outcast outcast
+ outcries outcri
+ outcry outcri
+ outdar outdar
+ outdare outdar
+ outdares outdar
+ outdone outdon
+ outfac outfac
+ outface outfac
+ outfaced outfac
+ outfacing outfac
+ outfly outfli
+ outfrown outfrown
+ outgo outgo
+ outgoes outgo
+ outgrown outgrown
+ outjest outjest
+ outlaw outlaw
+ outlawry outlawri
+ outlaws outlaw
+ outliv outliv
+ outlive outliv
+ outlives outliv
+ outliving outliv
+ outlook outlook
+ outlustres outlustr
+ outpriz outpriz
+ outrage outrag
+ outrageous outrag
+ outrages outrag
+ outran outran
+ outright outright
+ outroar outroar
+ outrun outrun
+ outrunning outrun
+ outruns outrun
+ outscold outscold
+ outscorn outscorn
+ outsell outsel
+ outsells outsel
+ outside outsid
+ outsides outsid
+ outspeaks outspeak
+ outsport outsport
+ outstare outstar
+ outstay outstai
+ outstood outstood
+ outstretch outstretch
+ outstretched outstretch
+ outstrike outstrik
+ outstrip outstrip
+ outstripped outstrip
+ outswear outswear
+ outvenoms outvenom
+ outward outward
+ outwardly outwardli
+ outwards outward
+ outwear outwear
+ outweighs outweigh
+ outwent outwent
+ outworn outworn
+ outworths outworth
+ oven oven
+ over over
+ overawe overaw
+ overbear overbear
+ overblown overblown
+ overboard overboard
+ overbold overbold
+ overborne overborn
+ overbulk overbulk
+ overbuys overbui
+ overcame overcam
+ overcast overcast
+ overcharg overcharg
+ overcharged overcharg
+ overcome overcom
+ overcomes overcom
+ overdone overdon
+ overearnest overearnest
+ overfar overfar
+ overflow overflow
+ overflown overflown
+ overglance overgl
+ overgo overgo
+ overgone overgon
+ overgorg overgorg
+ overgrown overgrown
+ overhead overhead
+ overhear overhear
+ overheard overheard
+ overhold overhold
+ overjoyed overjoi
+ overkind overkind
+ overland overland
+ overleather overleath
+ overlive overl
+ overlook overlook
+ overlooking overlook
+ overlooks overlook
+ overmaster overmast
+ overmounting overmount
+ overmuch overmuch
+ overpass overpass
+ overpeer overp
+ overpeering overp
+ overplus overplu
+ overrul overrul
+ overrun overrun
+ overscutch overscutch
+ overset overset
+ overshades overshad
+ overshine overshin
+ overshines overshin
+ overshot overshot
+ oversights oversight
+ overspread overspread
+ overstain overstain
+ overswear overswear
+ overt overt
+ overta overta
+ overtake overtak
+ overtaketh overtaketh
+ overthrow overthrow
+ overthrown overthrown
+ overthrows overthrow
+ overtook overtook
+ overtopp overtopp
+ overture overtur
+ overturn overturn
+ overwatch overwatch
+ overween overween
+ overweening overween
+ overweigh overweigh
+ overwhelm overwhelm
+ overwhelming overwhelm
+ overworn overworn
+ ovid ovid
+ ovidius ovidiu
+ ow ow
+ owe ow
+ owed ow
+ owedst owedst
+ owen owen
+ owes ow
+ owest owest
+ oweth oweth
+ owing ow
+ owl owl
+ owls owl
+ own own
+ owner owner
+ owners owner
+ owning own
+ owns own
+ owy owi
+ ox ox
+ oxen oxen
+ oxford oxford
+ oxfordshire oxfordshir
+ oxlips oxlip
+ oyes oy
+ oyster oyster
+ p p
+ pabble pabbl
+ pabylon pabylon
+ pac pac
+ pace pace
+ paced pace
+ paces pace
+ pacified pacifi
+ pacify pacifi
+ pacing pace
+ pack pack
+ packet packet
+ packets packet
+ packhorses packhors
+ packing pack
+ packings pack
+ packs pack
+ packthread packthread
+ pacorus pacoru
+ paction paction
+ pad pad
+ paddle paddl
+ paddling paddl
+ paddock paddock
+ padua padua
+ pagan pagan
+ pagans pagan
+ page page
+ pageant pageant
+ pageants pageant
+ pages page
+ pah pah
+ paid paid
+ pail pail
+ pailfuls pail
+ pails pail
+ pain pain
+ pained pain
+ painful pain
+ painfully painfulli
+ pains pain
+ paint paint
+ painted paint
+ painter painter
+ painting paint
+ paintings paint
+ paints paint
+ pair pair
+ paired pair
+ pairs pair
+ pajock pajock
+ pal pal
+ palabras palabra
+ palace palac
+ palaces palac
+ palamedes palamed
+ palate palat
+ palates palat
+ palatine palatin
+ palating palat
+ pale pale
+ paled pale
+ paleness pale
+ paler paler
+ pales pale
+ palestine palestin
+ palfrey palfrei
+ palfreys palfrei
+ palisadoes palisado
+ pall pall
+ pallabris pallabri
+ pallas palla
+ pallets pallet
+ palm palm
+ palmer palmer
+ palmers palmer
+ palms palm
+ palmy palmi
+ palpable palpabl
+ palsied palsi
+ palsies palsi
+ palsy palsi
+ palt palt
+ palter palter
+ paltry paltri
+ paly pali
+ pamp pamp
+ pamper pamper
+ pamphlets pamphlet
+ pan pan
+ pancackes pancack
+ pancake pancak
+ pancakes pancak
+ pandar pandar
+ pandars pandar
+ pandarus pandaru
+ pander pander
+ panderly panderli
+ panders pander
+ pandulph pandulph
+ panel panel
+ pang pang
+ panging pang
+ pangs pang
+ pannier pannier
+ pannonians pannonian
+ pansa pansa
+ pansies pansi
+ pant pant
+ pantaloon pantaloon
+ panted pant
+ pantheon pantheon
+ panther panther
+ panthino panthino
+ panting pant
+ pantingly pantingli
+ pantler pantler
+ pantry pantri
+ pants pant
+ pap pap
+ papal papal
+ paper paper
+ papers paper
+ paphlagonia paphlagonia
+ paphos papho
+ papist papist
+ paps pap
+ par par
+ parable parabl
+ paracelsus paracelsu
+ paradise paradis
+ paradox paradox
+ paradoxes paradox
+ paragon paragon
+ paragons paragon
+ parallel parallel
+ parallels parallel
+ paramour paramour
+ paramours paramour
+ parapets parapet
+ paraquito paraquito
+ parasite parasit
+ parasites parasit
+ parca parca
+ parcel parcel
+ parcell parcel
+ parcels parcel
+ parch parch
+ parched parch
+ parching parch
+ parchment parchment
+ pard pard
+ pardon pardon
+ pardona pardona
+ pardoned pardon
+ pardoner pardon
+ pardoning pardon
+ pardonne pardonn
+ pardonner pardonn
+ pardonnez pardonnez
+ pardons pardon
+ pare pare
+ pared pare
+ parel parel
+ parent parent
+ parentage parentag
+ parents parent
+ parfect parfect
+ paring pare
+ parings pare
+ paris pari
+ parish parish
+ parishioners parishion
+ parisians parisian
+ paritors paritor
+ park park
+ parks park
+ parle parl
+ parler parler
+ parles parl
+ parley parlei
+ parlez parlez
+ parliament parliament
+ parlors parlor
+ parlour parlour
+ parlous parlou
+ parmacity parmac
+ parolles parol
+ parricide parricid
+ parricides parricid
+ parrot parrot
+ parrots parrot
+ parsley parslei
+ parson parson
+ part part
+ partake partak
+ partaken partaken
+ partaker partak
+ partakers partak
+ parted part
+ parthia parthia
+ parthian parthian
+ parthians parthian
+ parti parti
+ partial partial
+ partialize partial
+ partially partial
+ participate particip
+ participation particip
+ particle particl
+ particular particular
+ particularities particular
+ particularize particular
+ particularly particularli
+ particulars particular
+ parties parti
+ parting part
+ partisan partisan
+ partisans partisan
+ partition partit
+ partizan partizan
+ partlet partlet
+ partly partli
+ partner partner
+ partners partner
+ partridge partridg
+ parts part
+ party parti
+ pas pa
+ pash pash
+ pashed pash
+ pashful pash
+ pass pass
+ passable passabl
+ passado passado
+ passage passag
+ passages passag
+ passant passant
+ passed pass
+ passenger passeng
+ passengers passeng
+ passes pass
+ passeth passeth
+ passing pass
+ passio passio
+ passion passion
+ passionate passion
+ passioning passion
+ passions passion
+ passive passiv
+ passport passport
+ passy passi
+ past past
+ paste past
+ pasterns pastern
+ pasties pasti
+ pastime pastim
+ pastimes pastim
+ pastoral pastor
+ pastorals pastor
+ pastors pastor
+ pastry pastri
+ pasture pastur
+ pastures pastur
+ pasty pasti
+ pat pat
+ patay patai
+ patch patch
+ patchery patcheri
+ patches patch
+ pate pate
+ pated pate
+ patent patent
+ patents patent
+ paternal patern
+ pates pate
+ path path
+ pathetical pathet
+ paths path
+ pathway pathwai
+ pathways pathwai
+ patience patienc
+ patient patient
+ patiently patient
+ patients patient
+ patines patin
+ patrician patrician
+ patricians patrician
+ patrick patrick
+ patrimony patrimoni
+ patroclus patroclu
+ patron patron
+ patronage patronag
+ patroness patro
+ patrons patron
+ patrum patrum
+ patter patter
+ pattern pattern
+ patterns pattern
+ pattle pattl
+ pauca pauca
+ paucas pauca
+ paul paul
+ paulina paulina
+ paunch paunch
+ paunches paunch
+ pause paus
+ pauser pauser
+ pauses paus
+ pausingly pausingli
+ pauvres pauvr
+ pav pav
+ paved pave
+ pavement pavement
+ pavilion pavilion
+ pavilions pavilion
+ pavin pavin
+ paw paw
+ pawn pawn
+ pawns pawn
+ paws paw
+ pax pax
+ pay pai
+ payest payest
+ paying pai
+ payment payment
+ payments payment
+ pays pai
+ paysan paysan
+ paysans paysan
+ pe pe
+ peace peac
+ peaceable peaceabl
+ peaceably peaceabl
+ peaceful peac
+ peacemakers peacemak
+ peaces peac
+ peach peach
+ peaches peach
+ peacock peacock
+ peacocks peacock
+ peak peak
+ peaking peak
+ peal peal
+ peals peal
+ pear pear
+ peard peard
+ pearl pearl
+ pearls pearl
+ pears pear
+ peas pea
+ peasant peasant
+ peasantry peasantri
+ peasants peasant
+ peascod peascod
+ pease peas
+ peaseblossom peaseblossom
+ peat peat
+ peaten peaten
+ peating peat
+ pebble pebbl
+ pebbled pebbl
+ pebbles pebbl
+ peck peck
+ pecks peck
+ peculiar peculiar
+ pecus pecu
+ pedant pedant
+ pedantical pedant
+ pedascule pedascul
+ pede pede
+ pedestal pedest
+ pedigree pedigre
+ pedlar pedlar
+ pedlars pedlar
+ pedro pedro
+ peds ped
+ peel peel
+ peep peep
+ peeped peep
+ peeping peep
+ peeps peep
+ peer peer
+ peereth peereth
+ peering peer
+ peerless peerless
+ peers peer
+ peesel peesel
+ peevish peevish
+ peevishly peevishli
+ peflur peflur
+ peg peg
+ pegasus pegasu
+ pegs peg
+ peise peis
+ peised peis
+ peize peiz
+ pelf pelf
+ pelican pelican
+ pelion pelion
+ pell pell
+ pella pella
+ pelleted pellet
+ peloponnesus peloponnesu
+ pelt pelt
+ pelting pelt
+ pembroke pembrok
+ pen pen
+ penalties penalti
+ penalty penalti
+ penance penanc
+ pence penc
+ pencil pencil
+ pencill pencil
+ pencils pencil
+ pendant pendant
+ pendent pendent
+ pendragon pendragon
+ pendulous pendul
+ penelope penelop
+ penetrable penetr
+ penetrate penetr
+ penetrative penetr
+ penitence penit
+ penitent penit
+ penitential penitenti
+ penitently penit
+ penitents penit
+ penker penker
+ penknife penknif
+ penn penn
+ penned pen
+ penning pen
+ pennons pennon
+ penny penni
+ pennyworth pennyworth
+ pennyworths pennyworth
+ pens pen
+ pense pens
+ pension pension
+ pensioners pension
+ pensive pensiv
+ pensived pensiv
+ pensively pensiv
+ pent pent
+ pentecost pentecost
+ penthesilea penthesilea
+ penthouse penthous
+ penurious penuri
+ penury penuri
+ peopl peopl
+ people peopl
+ peopled peopl
+ peoples peopl
+ pepin pepin
+ pepper pepper
+ peppercorn peppercorn
+ peppered pepper
+ per per
+ peradventure peradventur
+ peradventures peradventur
+ perceiv perceiv
+ perceive perceiv
+ perceived perceiv
+ perceives perceiv
+ perceiveth perceiveth
+ perch perch
+ perchance perchanc
+ percies perci
+ percussion percuss
+ percy perci
+ perdie perdi
+ perdita perdita
+ perdition perdit
+ perdonato perdonato
+ perdu perdu
+ perdurable perdur
+ perdurably perdur
+ perdy perdi
+ pere pere
+ peregrinate peregrin
+ peremptorily peremptorili
+ peremptory peremptori
+ perfect perfect
+ perfected perfect
+ perfecter perfect
+ perfectest perfectest
+ perfection perfect
+ perfections perfect
+ perfectly perfectli
+ perfectness perfect
+ perfidious perfidi
+ perfidiously perfidi
+ perforce perforc
+ perform perform
+ performance perform
+ performances perform
+ performed perform
+ performer perform
+ performers perform
+ performing perform
+ performs perform
+ perfum perfum
+ perfume perfum
+ perfumed perfum
+ perfumer perfum
+ perfumes perfum
+ perge perg
+ perhaps perhap
+ periapts periapt
+ perigort perigort
+ perigouna perigouna
+ peril peril
+ perilous peril
+ perils peril
+ period period
+ periods period
+ perish perish
+ perished perish
+ perishest perishest
+ perisheth perisheth
+ perishing perish
+ periwig periwig
+ perjur perjur
+ perjure perjur
+ perjured perjur
+ perjuries perjuri
+ perjury perjuri
+ perk perk
+ perkes perk
+ permafoy permafoi
+ permanent perman
+ permission permiss
+ permissive permiss
+ permit permit
+ permitted permit
+ pernicious pernici
+ perniciously pernici
+ peroration peror
+ perpend perpend
+ perpendicular perpendicular
+ perpendicularly perpendicularli
+ perpetual perpetu
+ perpetually perpetu
+ perpetuity perpetu
+ perplex perplex
+ perplexed perplex
+ perplexity perplex
+ pers per
+ persecuted persecut
+ persecutions persecut
+ persecutor persecutor
+ perseus perseu
+ persever persev
+ perseverance persever
+ persevers persev
+ persia persia
+ persian persian
+ persist persist
+ persisted persist
+ persistency persist
+ persistive persist
+ persists persist
+ person person
+ personae persona
+ personage personag
+ personages personag
+ personal person
+ personally person
+ personate person
+ personated person
+ personates person
+ personating person
+ persons person
+ perspective perspect
+ perspectively perspect
+ perspectives perspect
+ perspicuous perspicu
+ persuade persuad
+ persuaded persuad
+ persuades persuad
+ persuading persuad
+ persuasion persuas
+ persuasions persuas
+ pert pert
+ pertain pertain
+ pertaining pertain
+ pertains pertain
+ pertaunt pertaunt
+ pertinent pertin
+ pertly pertli
+ perturb perturb
+ perturbation perturb
+ perturbations perturb
+ perturbed perturb
+ perus peru
+ perusal perus
+ peruse perus
+ perused perus
+ perusing perus
+ perverse pervers
+ perversely pervers
+ perverseness pervers
+ pervert pervert
+ perverted pervert
+ peseech peseech
+ pest pest
+ pester pester
+ pestiferous pestifer
+ pestilence pestil
+ pestilent pestil
+ pet pet
+ petar petar
+ peter peter
+ petit petit
+ petition petit
+ petitionary petitionari
+ petitioner petition
+ petitioners petition
+ petitions petit
+ peto peto
+ petrarch petrarch
+ petruchio petruchio
+ petter petter
+ petticoat petticoat
+ petticoats petticoat
+ pettiness petti
+ pettish pettish
+ pettitoes pettito
+ petty petti
+ peu peu
+ pew pew
+ pewter pewter
+ pewterer pewter
+ phaethon phaethon
+ phaeton phaeton
+ phantasime phantasim
+ phantasimes phantasim
+ phantasma phantasma
+ pharamond pharamond
+ pharaoh pharaoh
+ pharsalia pharsalia
+ pheasant pheasant
+ pheazar pheazar
+ phebe phebe
+ phebes phebe
+ pheebus pheebu
+ pheeze pheez
+ phibbus phibbu
+ philadelphos philadelpho
+ philario philario
+ philarmonus philarmonu
+ philemon philemon
+ philip philip
+ philippan philippan
+ philippe philipp
+ philippi philippi
+ phillida phillida
+ philo philo
+ philomel philomel
+ philomela philomela
+ philosopher philosoph
+ philosophers philosoph
+ philosophical philosoph
+ philosophy philosophi
+ philostrate philostr
+ philotus philotu
+ phlegmatic phlegmat
+ phoebe phoeb
+ phoebus phoebu
+ phoenicia phoenicia
+ phoenicians phoenician
+ phoenix phoenix
+ phorbus phorbu
+ photinus photinu
+ phrase phrase
+ phraseless phraseless
+ phrases phrase
+ phrygia phrygia
+ phrygian phrygian
+ phrynia phrynia
+ physic physic
+ physical physic
+ physician physician
+ physicians physician
+ physics physic
+ pia pia
+ pibble pibbl
+ pible pibl
+ picardy picardi
+ pick pick
+ pickaxe pickax
+ pickaxes pickax
+ pickbone pickbon
+ picked pick
+ pickers picker
+ picking pick
+ pickle pickl
+ picklock picklock
+ pickpurse pickpurs
+ picks pick
+ pickt pickt
+ pickthanks pickthank
+ pictur pictur
+ picture pictur
+ pictured pictur
+ pictures pictur
+ pid pid
+ pie pie
+ piec piec
+ piece piec
+ pieces piec
+ piecing piec
+ pied pi
+ piedness pied
+ pier pier
+ pierc pierc
+ pierce pierc
+ pierced pierc
+ pierces pierc
+ pierceth pierceth
+ piercing pierc
+ piercy pierci
+ piers pier
+ pies pi
+ piety pieti
+ pig pig
+ pigeon pigeon
+ pigeons pigeon
+ pight pight
+ pigmy pigmi
+ pigrogromitus pigrogromitu
+ pike pike
+ pikes pike
+ pil pil
+ pilate pilat
+ pilates pilat
+ pilchers pilcher
+ pile pile
+ piles pile
+ pilf pilf
+ pilfering pilfer
+ pilgrim pilgrim
+ pilgrimage pilgrimag
+ pilgrims pilgrim
+ pill pill
+ pillage pillag
+ pillagers pillag
+ pillar pillar
+ pillars pillar
+ pillicock pillicock
+ pillory pillori
+ pillow pillow
+ pillows pillow
+ pills pill
+ pilot pilot
+ pilots pilot
+ pimpernell pimpernel
+ pin pin
+ pinch pinch
+ pinched pinch
+ pinches pinch
+ pinching pinch
+ pindarus pindaru
+ pine pine
+ pined pine
+ pines pine
+ pinfold pinfold
+ pining pine
+ pinion pinion
+ pink pink
+ pinn pinn
+ pinnace pinnac
+ pins pin
+ pinse pins
+ pint pint
+ pintpot pintpot
+ pioned pion
+ pioneers pioneer
+ pioner pioner
+ pioners pioner
+ pious piou
+ pip pip
+ pipe pipe
+ piper piper
+ pipers piper
+ pipes pipe
+ piping pipe
+ pippin pippin
+ pippins pippin
+ pirate pirat
+ pirates pirat
+ pisa pisa
+ pisanio pisanio
+ pish pish
+ pismires pismir
+ piss piss
+ pissing piss
+ pistol pistol
+ pistols pistol
+ pit pit
+ pitch pitch
+ pitched pitch
+ pitcher pitcher
+ pitchers pitcher
+ pitchy pitchi
+ piteous piteou
+ piteously piteous
+ pitfall pitfal
+ pith pith
+ pithless pithless
+ pithy pithi
+ pitie piti
+ pitied piti
+ pities piti
+ pitiful piti
+ pitifully pitifulli
+ pitiless pitiless
+ pits pit
+ pittance pittanc
+ pittie pitti
+ pittikins pittikin
+ pity piti
+ pitying piti
+ pius piu
+ plac plac
+ place place
+ placed place
+ placentio placentio
+ places place
+ placeth placeth
+ placid placid
+ placing place
+ plack plack
+ placket placket
+ plackets placket
+ plagu plagu
+ plague plagu
+ plagued plagu
+ plagues plagu
+ plaguing plagu
+ plaguy plagui
+ plain plain
+ plainer plainer
+ plainest plainest
+ plaining plain
+ plainings plain
+ plainly plainli
+ plainness plain
+ plains plain
+ plainsong plainsong
+ plaintful plaint
+ plaintiff plaintiff
+ plaintiffs plaintiff
+ plaints plaint
+ planched planch
+ planet planet
+ planetary planetari
+ planets planet
+ planks plank
+ plant plant
+ plantage plantag
+ plantagenet plantagenet
+ plantagenets plantagenet
+ plantain plantain
+ plantation plantat
+ planted plant
+ planteth planteth
+ plants plant
+ plash plash
+ plashy plashi
+ plast plast
+ plaster plaster
+ plasterer plaster
+ plat plat
+ plate plate
+ plated plate
+ plates plate
+ platform platform
+ platforms platform
+ plats plat
+ platted plat
+ plausible plausibl
+ plausive plausiv
+ plautus plautu
+ play plai
+ played plai
+ player player
+ players player
+ playeth playeth
+ playfellow playfellow
+ playfellows playfellow
+ playhouse playhous
+ playing plai
+ plays plai
+ plea plea
+ pleach pleach
+ pleached pleach
+ plead plead
+ pleaded plead
+ pleader pleader
+ pleaders pleader
+ pleading plead
+ pleads plead
+ pleas plea
+ pleasance pleasanc
+ pleasant pleasant
+ pleasantly pleasantli
+ please pleas
+ pleased pleas
+ pleaser pleaser
+ pleasers pleaser
+ pleases pleas
+ pleasest pleasest
+ pleaseth pleaseth
+ pleasing pleas
+ pleasure pleasur
+ pleasures pleasur
+ plebeians plebeian
+ plebeii plebeii
+ plebs pleb
+ pledge pledg
+ pledges pledg
+ pleines plein
+ plenitude plenitud
+ plenteous plenteou
+ plenteously plenteous
+ plenties plenti
+ plentiful plenti
+ plentifully plentifulli
+ plenty plenti
+ pless pless
+ plessed pless
+ plessing pless
+ pliant pliant
+ plied pli
+ plies pli
+ plight plight
+ plighted plight
+ plighter plighter
+ plod plod
+ plodded plod
+ plodders plodder
+ plodding plod
+ plods plod
+ plood plood
+ ploody ploodi
+ plot plot
+ plots plot
+ plotted plot
+ plotter plotter
+ plough plough
+ ploughed plough
+ ploughman ploughman
+ ploughmen ploughmen
+ plow plow
+ plows plow
+ pluck pluck
+ plucked pluck
+ plucker plucker
+ plucking pluck
+ plucks pluck
+ plue plue
+ plum plum
+ plume plume
+ plumed plume
+ plumes plume
+ plummet plummet
+ plump plump
+ plumpy plumpi
+ plums plum
+ plung plung
+ plunge plung
+ plunged plung
+ plural plural
+ plurisy plurisi
+ plus plu
+ pluto pluto
+ plutus plutu
+ ply ply
+ po po
+ pocket pocket
+ pocketing pocket
+ pockets pocket
+ pocky pocki
+ pody podi
+ poem poem
+ poesy poesi
+ poet poet
+ poetical poetic
+ poetry poetri
+ poets poet
+ poictiers poictier
+ poinards poinard
+ poins poin
+ point point
+ pointblank pointblank
+ pointed point
+ pointing point
+ points point
+ pois poi
+ poise pois
+ poising pois
+ poison poison
+ poisoned poison
+ poisoner poison
+ poisoning poison
+ poisonous poison
+ poisons poison
+ poke poke
+ poking poke
+ pol pol
+ polack polack
+ polacks polack
+ poland poland
+ pold pold
+ pole pole
+ poleaxe poleax
+ polecat polecat
+ polecats polecat
+ polemon polemon
+ poles pole
+ poli poli
+ policies polici
+ policy polici
+ polish polish
+ polished polish
+ politic polit
+ politician politician
+ politicians politician
+ politicly politicli
+ polixenes polixen
+ poll poll
+ polluted pollut
+ pollution pollut
+ polonius poloniu
+ poltroons poltroon
+ polusion polus
+ polydamus polydamu
+ polydore polydor
+ polyxena polyxena
+ pomander pomand
+ pomegranate pomegran
+ pomewater pomewat
+ pomfret pomfret
+ pomgarnet pomgarnet
+ pommel pommel
+ pomp pomp
+ pompeius pompeiu
+ pompey pompei
+ pompion pompion
+ pompous pompou
+ pomps pomp
+ pond pond
+ ponder ponder
+ ponderous ponder
+ ponds pond
+ poniard poniard
+ poniards poniard
+ pont pont
+ pontic pontic
+ pontifical pontif
+ ponton ponton
+ pooh pooh
+ pool pool
+ poole pool
+ poop poop
+ poor poor
+ poorer poorer
+ poorest poorest
+ poorly poorli
+ pop pop
+ pope pope
+ popedom popedom
+ popilius popiliu
+ popingay popingai
+ popish popish
+ popp popp
+ poppy poppi
+ pops pop
+ popular popular
+ popularity popular
+ populous popul
+ porch porch
+ porches porch
+ pore pore
+ poring pore
+ pork pork
+ porn porn
+ porpentine porpentin
+ porridge porridg
+ porringer porring
+ port port
+ portable portabl
+ portage portag
+ portal portal
+ portance portanc
+ portcullis portculli
+ portend portend
+ portends portend
+ portent portent
+ portentous portent
+ portents portent
+ porter porter
+ porters porter
+ portia portia
+ portion portion
+ portly portli
+ portotartarossa portotartarossa
+ portrait portrait
+ portraiture portraitur
+ ports port
+ portugal portug
+ pose pose
+ posied posi
+ posies posi
+ position posit
+ positive posit
+ positively posit
+ posse poss
+ possess possess
+ possessed possess
+ possesses possess
+ possesseth possesseth
+ possessing possess
+ possession possess
+ possessions possess
+ possessor possessor
+ posset posset
+ possets posset
+ possibilities possibl
+ possibility possibl
+ possible possibl
+ possibly possibl
+ possitable possit
+ post post
+ poste post
+ posted post
+ posterior posterior
+ posteriors posterior
+ posterity poster
+ postern postern
+ posterns postern
+ posters poster
+ posthorse posthors
+ posthorses posthors
+ posthumus posthumu
+ posting post
+ postmaster postmast
+ posts post
+ postscript postscript
+ posture postur
+ postures postur
+ posy posi
+ pot pot
+ potable potabl
+ potations potat
+ potato potato
+ potatoes potato
+ potch potch
+ potency potenc
+ potent potent
+ potentates potent
+ potential potenti
+ potently potent
+ potents potent
+ pothecary pothecari
+ pother pother
+ potion potion
+ potions potion
+ potpan potpan
+ pots pot
+ potter potter
+ potting pot
+ pottle pottl
+ pouch pouch
+ poulter poulter
+ poultice poultic
+ poultney poultnei
+ pouncet pouncet
+ pound pound
+ pounds pound
+ pour pour
+ pourest pourest
+ pouring pour
+ pourquoi pourquoi
+ pours pour
+ pout pout
+ poverty poverti
+ pow pow
+ powd powd
+ powder powder
+ power power
+ powerful power
+ powerfully powerfulli
+ powerless powerless
+ powers power
+ pox pox
+ poys poi
+ poysam poysam
+ prabbles prabbl
+ practic practic
+ practice practic
+ practiced practic
+ practicer practic
+ practices practic
+ practicing practic
+ practis practi
+ practisants practis
+ practise practis
+ practiser practis
+ practisers practis
+ practises practis
+ practising practis
+ praeclarissimus praeclarissimu
+ praemunire praemunir
+ praetor praetor
+ praetors praetor
+ pragging prag
+ prague pragu
+ prain prain
+ prains prain
+ prais prai
+ praise prais
+ praised prais
+ praises prais
+ praisest praisest
+ praiseworthy praiseworthi
+ praising prais
+ prancing pranc
+ prank prank
+ pranks prank
+ prat prat
+ prate prate
+ prated prate
+ prater prater
+ prating prate
+ prattle prattl
+ prattler prattler
+ prattling prattl
+ prave prave
+ prawls prawl
+ prawns prawn
+ pray prai
+ prayer prayer
+ prayers prayer
+ praying prai
+ prays prai
+ pre pre
+ preach preach
+ preached preach
+ preachers preacher
+ preaches preach
+ preaching preach
+ preachment preachment
+ pread pread
+ preambulate preambul
+ precedence preced
+ precedent preced
+ preceding preced
+ precept precept
+ preceptial precepti
+ precepts precept
+ precinct precinct
+ precious preciou
+ preciously precious
+ precipice precipic
+ precipitating precipit
+ precipitation precipit
+ precise precis
+ precisely precis
+ preciseness precis
+ precisian precisian
+ precor precor
+ precurse precurs
+ precursors precursor
+ predeceased predeceas
+ predecessor predecessor
+ predecessors predecessor
+ predestinate predestin
+ predicament predica
+ predict predict
+ prediction predict
+ predictions predict
+ predominance predomin
+ predominant predomin
+ predominate predomin
+ preeches preech
+ preeminence preemin
+ preface prefac
+ prefer prefer
+ preferment prefer
+ preferments prefer
+ preferr preferr
+ preferreth preferreth
+ preferring prefer
+ prefers prefer
+ prefiguring prefigur
+ prefix prefix
+ prefixed prefix
+ preformed preform
+ pregnancy pregnanc
+ pregnant pregnant
+ pregnantly pregnantli
+ prejudicates prejud
+ prejudice prejudic
+ prejudicial prejudici
+ prelate prelat
+ premeditated premedit
+ premeditation premedit
+ premised premis
+ premises premis
+ prenez prenez
+ prenominate prenomin
+ prentice prentic
+ prentices prentic
+ preordinance preordin
+ prepar prepar
+ preparation prepar
+ preparations prepar
+ prepare prepar
+ prepared prepar
+ preparedly preparedli
+ prepares prepar
+ preparing prepar
+ prepost prepost
+ preposterous preposter
+ preposterously preposter
+ prerogatifes prerogatif
+ prerogative prerog
+ prerogatived prerogativ
+ presage presag
+ presagers presag
+ presages presag
+ presageth presageth
+ presaging presag
+ prescience prescienc
+ prescribe prescrib
+ prescript prescript
+ prescription prescript
+ prescriptions prescript
+ prescripts prescript
+ presence presenc
+ presences presenc
+ present present
+ presentation present
+ presented present
+ presenter present
+ presenters present
+ presenteth presenteth
+ presenting present
+ presently present
+ presentment present
+ presents present
+ preserv preserv
+ preservation preserv
+ preservative preserv
+ preserve preserv
+ preserved preserv
+ preserver preserv
+ preservers preserv
+ preserving preserv
+ president presid
+ press press
+ pressed press
+ presser presser
+ presses press
+ pressing press
+ pressure pressur
+ pressures pressur
+ prest prest
+ prester prester
+ presume presum
+ presumes presum
+ presuming presum
+ presumption presumpt
+ presumptuous presumptu
+ presuppos presuppo
+ pret pret
+ pretence pretenc
+ pretences pretenc
+ pretend pretend
+ pretended pretend
+ pretending pretend
+ pretense pretens
+ pretext pretext
+ pretia pretia
+ prettier prettier
+ prettiest prettiest
+ prettily prettili
+ prettiness pretti
+ pretty pretti
+ prevail prevail
+ prevailed prevail
+ prevaileth prevaileth
+ prevailing prevail
+ prevailment prevail
+ prevails prevail
+ prevent prevent
+ prevented prevent
+ prevention prevent
+ preventions prevent
+ prevents prevent
+ prey prei
+ preyful prey
+ preys prei
+ priam priam
+ priami priami
+ priamus priamu
+ pribbles pribbl
+ price price
+ prick prick
+ pricked prick
+ pricket pricket
+ pricking prick
+ pricks prick
+ pricksong pricksong
+ pride pride
+ prides pride
+ pridge pridg
+ prie prie
+ pried pri
+ prief prief
+ pries pri
+ priest priest
+ priesthood priesthood
+ priests priest
+ prig prig
+ primal primal
+ prime prime
+ primer primer
+ primero primero
+ primest primest
+ primitive primit
+ primo primo
+ primogenity primogen
+ primrose primros
+ primroses primros
+ primy primi
+ prince princ
+ princely princ
+ princes princ
+ princess princess
+ principal princip
+ principalities princip
+ principality princip
+ principle principl
+ principles principl
+ princox princox
+ prings pring
+ print print
+ printed print
+ printing print
+ printless printless
+ prints print
+ prioress prioress
+ priories priori
+ priority prioriti
+ priory priori
+ priscian priscian
+ prison prison
+ prisoner prison
+ prisoners prison
+ prisonment prison
+ prisonnier prisonni
+ prisons prison
+ pristine pristin
+ prithe prith
+ prithee prithe
+ privacy privaci
+ private privat
+ privately privat
+ privates privat
+ privilage privilag
+ privileg privileg
+ privilege privileg
+ privileged privileg
+ privileges privileg
+ privilegio privilegio
+ privily privili
+ privity priviti
+ privy privi
+ priz priz
+ prize prize
+ prized prize
+ prizer prizer
+ prizes prize
+ prizest prizest
+ prizing prize
+ pro pro
+ probable probabl
+ probal probal
+ probation probat
+ proceed proce
+ proceeded proceed
+ proceeders proceed
+ proceeding proceed
+ proceedings proceed
+ proceeds proce
+ process process
+ procession process
+ proclaim proclaim
+ proclaimed proclaim
+ proclaimeth proclaimeth
+ proclaims proclaim
+ proclamation proclam
+ proclamations proclam
+ proconsul proconsul
+ procrastinate procrastin
+ procreant procreant
+ procreants procreant
+ procreation procreat
+ procrus procru
+ proculeius proculeiu
+ procur procur
+ procurator procur
+ procure procur
+ procured procur
+ procures procur
+ procuring procur
+ prodigal prodig
+ prodigality prodig
+ prodigally prodig
+ prodigals prodig
+ prodigies prodigi
+ prodigious prodigi
+ prodigiously prodigi
+ prodigy prodigi
+ proditor proditor
+ produc produc
+ produce produc
+ produced produc
+ produces produc
+ producing produc
+ proface profac
+ profan profan
+ profanation profan
+ profane profan
+ profaned profan
+ profanely profan
+ profaneness profan
+ profaners profan
+ profaning profan
+ profess profess
+ professed profess
+ professes profess
+ profession profess
+ professions profess
+ professors professor
+ proffer proffer
+ proffered proffer
+ profferer proffer
+ proffers proffer
+ proficient profici
+ profit profit
+ profitable profit
+ profitably profit
+ profited profit
+ profiting profit
+ profitless profitless
+ profits profit
+ profound profound
+ profoundest profoundest
+ profoundly profoundli
+ progenitors progenitor
+ progeny progeni
+ progne progn
+ prognosticate prognost
+ prognostication prognost
+ progress progress
+ progression progress
+ prohibit prohibit
+ prohibition prohibit
+ project project
+ projection project
+ projects project
+ prolixious prolixi
+ prolixity prolix
+ prologue prologu
+ prologues prologu
+ prolong prolong
+ prolongs prolong
+ promethean promethean
+ prometheus prometheu
+ promis promi
+ promise promis
+ promised promis
+ promises promis
+ promiseth promiseth
+ promising promis
+ promontory promontori
+ promotion promot
+ promotions promot
+ prompt prompt
+ prompted prompt
+ promptement promptement
+ prompter prompter
+ prompting prompt
+ prompts prompt
+ prompture promptur
+ promulgate promulg
+ prone prone
+ prononcer prononc
+ prononcez prononcez
+ pronoun pronoun
+ pronounc pronounc
+ pronounce pronounc
+ pronounced pronounc
+ pronouncing pronounc
+ pronouns pronoun
+ proof proof
+ proofs proof
+ prop prop
+ propagate propag
+ propagation propag
+ propend propend
+ propension propens
+ proper proper
+ properer proper
+ properly properli
+ propertied properti
+ properties properti
+ property properti
+ prophecies propheci
+ prophecy propheci
+ prophesied prophesi
+ prophesier prophesi
+ prophesy prophesi
+ prophesying prophesi
+ prophet prophet
+ prophetess prophetess
+ prophetic prophet
+ prophetically prophet
+ prophets prophet
+ propinquity propinqu
+ propontic propont
+ proportion proport
+ proportionable proportion
+ proportions proport
+ propos propo
+ propose propos
+ proposed propos
+ proposer propos
+ proposes propos
+ proposing propos
+ proposition proposit
+ propositions proposit
+ propounded propound
+ propp propp
+ propre propr
+ propriety proprieti
+ props prop
+ propugnation propugn
+ prorogue prorogu
+ prorogued prorogu
+ proscription proscript
+ proscriptions proscript
+ prose prose
+ prosecute prosecut
+ prosecution prosecut
+ proselytes proselyt
+ proserpina proserpina
+ prosp prosp
+ prospect prospect
+ prosper prosper
+ prosperity prosper
+ prospero prospero
+ prosperous prosper
+ prosperously prosper
+ prospers prosper
+ prostitute prostitut
+ prostrate prostrat
+ protect protect
+ protected protect
+ protection protect
+ protector protector
+ protectors protector
+ protectorship protectorship
+ protectress protectress
+ protects protect
+ protest protest
+ protestation protest
+ protestations protest
+ protested protest
+ protester protest
+ protesting protest
+ protests protest
+ proteus proteu
+ protheus protheu
+ protract protract
+ protractive protract
+ proud proud
+ prouder prouder
+ proudest proudest
+ proudlier proudlier
+ proudly proudli
+ prouds proud
+ prov prov
+ provand provand
+ prove prove
+ proved prove
+ provender provend
+ proverb proverb
+ proverbs proverb
+ proves prove
+ proveth proveth
+ provide provid
+ provided provid
+ providence provid
+ provident provid
+ providently provid
+ provider provid
+ provides provid
+ province provinc
+ provinces provinc
+ provincial provinci
+ proving prove
+ provision provis
+ proviso proviso
+ provocation provoc
+ provok provok
+ provoke provok
+ provoked provok
+ provoker provok
+ provokes provok
+ provoketh provoketh
+ provoking provok
+ provost provost
+ prowess prowess
+ prudence prudenc
+ prudent prudent
+ prun prun
+ prune prune
+ prunes prune
+ pruning prune
+ pry pry
+ prying pry
+ psalm psalm
+ psalmist psalmist
+ psalms psalm
+ psalteries psalteri
+ ptolemies ptolemi
+ ptolemy ptolemi
+ public public
+ publican publican
+ publication public
+ publicly publicli
+ publicola publicola
+ publish publish
+ published publish
+ publisher publish
+ publishing publish
+ publius publiu
+ pucelle pucel
+ puck puck
+ pudder pudder
+ pudding pud
+ puddings pud
+ puddle puddl
+ puddled puddl
+ pudency pudenc
+ pueritia pueritia
+ puff puff
+ puffing puf
+ puffs puff
+ pugging pug
+ puis pui
+ puissance puissanc
+ puissant puissant
+ puke puke
+ puking puke
+ pulcher pulcher
+ puling pule
+ pull pull
+ puller puller
+ pullet pullet
+ pulling pull
+ pulls pull
+ pulpit pulpit
+ pulpiter pulpit
+ pulpits pulpit
+ pulse puls
+ pulsidge pulsidg
+ pump pump
+ pumpion pumpion
+ pumps pump
+ pun pun
+ punched punch
+ punish punish
+ punished punish
+ punishes punish
+ punishment punish
+ punishments punish
+ punk punk
+ punto punto
+ puny puni
+ pupil pupil
+ pupils pupil
+ puppet puppet
+ puppets puppet
+ puppies puppi
+ puppy puppi
+ pur pur
+ purblind purblind
+ purchas purcha
+ purchase purchas
+ purchased purchas
+ purchases purchas
+ purchaseth purchaseth
+ purchasing purchas
+ pure pure
+ purely pure
+ purer purer
+ purest purest
+ purg purg
+ purgation purgat
+ purgative purg
+ purgatory purgatori
+ purge purg
+ purged purg
+ purgers purger
+ purging purg
+ purifies purifi
+ purifying purifi
+ puritan puritan
+ purity puriti
+ purlieus purlieu
+ purple purpl
+ purpled purpl
+ purples purpl
+ purport purport
+ purpos purpo
+ purpose purpos
+ purposed purpos
+ purposely purpos
+ purposes purpos
+ purposeth purposeth
+ purposing purpos
+ purr purr
+ purs pur
+ purse purs
+ pursents pursent
+ purses purs
+ pursu pursu
+ pursue pursu
+ pursued pursu
+ pursuers pursuer
+ pursues pursu
+ pursuest pursuest
+ pursueth pursueth
+ pursuing pursu
+ pursuit pursuit
+ pursuivant pursuiv
+ pursuivants pursuiv
+ pursy pursi
+ purus puru
+ purveyor purveyor
+ push push
+ pushes push
+ pusillanimity pusillanim
+ put put
+ putrefy putrefi
+ putrified putrifi
+ puts put
+ putter putter
+ putting put
+ puttock puttock
+ puzzel puzzel
+ puzzle puzzl
+ puzzled puzzl
+ puzzles puzzl
+ py py
+ pygmalion pygmalion
+ pygmies pygmi
+ pygmy pygmi
+ pyramid pyramid
+ pyramides pyramid
+ pyramids pyramid
+ pyramis pyrami
+ pyramises pyramis
+ pyramus pyramu
+ pyrenean pyrenean
+ pyrrhus pyrrhu
+ pythagoras pythagora
+ qu qu
+ quadrangle quadrangl
+ quae quae
+ quaff quaff
+ quaffing quaf
+ quagmire quagmir
+ quail quail
+ quailing quail
+ quails quail
+ quaint quaint
+ quaintly quaintli
+ quak quak
+ quake quak
+ quakes quak
+ qualification qualif
+ qualified qualifi
+ qualifies qualifi
+ qualify qualifi
+ qualifying qualifi
+ qualite qualit
+ qualities qualiti
+ quality qualiti
+ qualm qualm
+ qualmish qualmish
+ quam quam
+ quand quand
+ quando quando
+ quantities quantiti
+ quantity quantiti
+ quare quar
+ quarrel quarrel
+ quarrell quarrel
+ quarreller quarrel
+ quarrelling quarrel
+ quarrelous quarrel
+ quarrels quarrel
+ quarrelsome quarrelsom
+ quarries quarri
+ quarry quarri
+ quart quart
+ quarter quarter
+ quartered quarter
+ quartering quarter
+ quarters quarter
+ quarts quart
+ quasi quasi
+ quat quat
+ quatch quatch
+ quay quai
+ que que
+ quean quean
+ queas quea
+ queasiness queasi
+ queasy queasi
+ queen queen
+ queens queen
+ quell quell
+ queller queller
+ quench quench
+ quenched quench
+ quenching quench
+ quenchless quenchless
+ quern quern
+ quest quest
+ questant questant
+ question question
+ questionable question
+ questioned question
+ questioning question
+ questionless questionless
+ questions question
+ questrists questrist
+ quests quest
+ queubus queubu
+ qui qui
+ quick quick
+ quicken quicken
+ quickens quicken
+ quicker quicker
+ quicklier quicklier
+ quickly quickli
+ quickness quick
+ quicksand quicksand
+ quicksands quicksand
+ quicksilverr quicksilverr
+ quid quid
+ quiddities quidditi
+ quiddits quiddit
+ quier quier
+ quiet quiet
+ quieter quieter
+ quietly quietli
+ quietness quiet
+ quietus quietu
+ quill quill
+ quillets quillet
+ quills quill
+ quilt quilt
+ quinapalus quinapalu
+ quince quinc
+ quinces quinc
+ quintain quintain
+ quintessence quintess
+ quintus quintu
+ quip quip
+ quips quip
+ quire quir
+ quiring quir
+ quirk quirk
+ quirks quirk
+ quis qui
+ quit quit
+ quite quit
+ quits quit
+ quittance quittanc
+ quitted quit
+ quitting quit
+ quiver quiver
+ quivering quiver
+ quivers quiver
+ quo quo
+ quod quod
+ quoifs quoif
+ quoint quoint
+ quoit quoit
+ quoits quoit
+ quondam quondam
+ quoniam quoniam
+ quote quot
+ quoted quot
+ quotes quot
+ quoth quoth
+ quotidian quotidian
+ r r
+ rabbit rabbit
+ rabble rabbl
+ rabblement rabblement
+ race race
+ rack rack
+ rackers racker
+ racket racket
+ rackets racket
+ racking rack
+ racks rack
+ radiance radianc
+ radiant radiant
+ radish radish
+ rafe rafe
+ raft raft
+ rag rag
+ rage rage
+ rages rage
+ rageth rageth
+ ragg ragg
+ ragged rag
+ raggedness ragged
+ raging rage
+ ragozine ragozin
+ rags rag
+ rah rah
+ rail rail
+ railed rail
+ railer railer
+ railest railest
+ raileth raileth
+ railing rail
+ rails rail
+ raiment raiment
+ rain rain
+ rainbow rainbow
+ raineth raineth
+ raining rain
+ rainold rainold
+ rains rain
+ rainy raini
+ rais rai
+ raise rais
+ raised rais
+ raises rais
+ raising rais
+ raisins raisin
+ rak rak
+ rake rake
+ rakers raker
+ rakes rake
+ ral ral
+ rald rald
+ ralph ralph
+ ram ram
+ rambures rambur
+ ramm ramm
+ rampallian rampallian
+ rampant rampant
+ ramping ramp
+ rampir rampir
+ ramps ramp
+ rams ram
+ ramsey ramsei
+ ramston ramston
+ ran ran
+ rance ranc
+ rancorous rancor
+ rancors rancor
+ rancour rancour
+ random random
+ rang rang
+ range rang
+ ranged rang
+ rangers ranger
+ ranges rang
+ ranging rang
+ rank rank
+ ranker ranker
+ rankest rankest
+ ranking rank
+ rankle rankl
+ rankly rankli
+ rankness rank
+ ranks rank
+ ransack ransack
+ ransacking ransack
+ ransom ransom
+ ransomed ransom
+ ransoming ransom
+ ransomless ransomless
+ ransoms ransom
+ rant rant
+ ranting rant
+ rap rap
+ rape rape
+ rapes rape
+ rapier rapier
+ rapiers rapier
+ rapine rapin
+ raps rap
+ rapt rapt
+ rapture raptur
+ raptures raptur
+ rar rar
+ rare rare
+ rarely rare
+ rareness rare
+ rarer rarer
+ rarest rarest
+ rarities rariti
+ rarity rariti
+ rascal rascal
+ rascalliest rascalliest
+ rascally rascal
+ rascals rascal
+ rased rase
+ rash rash
+ rasher rasher
+ rashly rashli
+ rashness rash
+ rat rat
+ ratcatcher ratcatch
+ ratcliff ratcliff
+ rate rate
+ rated rate
+ rately rate
+ rates rate
+ rather rather
+ ratherest ratherest
+ ratified ratifi
+ ratifiers ratifi
+ ratify ratifi
+ rating rate
+ rational ration
+ ratolorum ratolorum
+ rats rat
+ ratsbane ratsban
+ rattle rattl
+ rattles rattl
+ rattling rattl
+ rature ratur
+ raught raught
+ rav rav
+ rave rave
+ ravel ravel
+ raven raven
+ ravening raven
+ ravenous raven
+ ravens raven
+ ravenspurgh ravenspurgh
+ raves rave
+ ravin ravin
+ raving rave
+ ravish ravish
+ ravished ravish
+ ravisher ravish
+ ravishing ravish
+ ravishments ravish
+ raw raw
+ rawer rawer
+ rawly rawli
+ rawness raw
+ ray rai
+ rayed rai
+ rays rai
+ raz raz
+ raze raze
+ razed raze
+ razes raze
+ razeth razeth
+ razing raze
+ razor razor
+ razorable razor
+ razors razor
+ razure razur
+ re re
+ reach reach
+ reaches reach
+ reacheth reacheth
+ reaching reach
+ read read
+ reader reader
+ readiest readiest
+ readily readili
+ readiness readi
+ reading read
+ readins readin
+ reads read
+ ready readi
+ real real
+ really realli
+ realm realm
+ realms realm
+ reap reap
+ reapers reaper
+ reaping reap
+ reaps reap
+ rear rear
+ rears rear
+ rearward rearward
+ reason reason
+ reasonable reason
+ reasonably reason
+ reasoned reason
+ reasoning reason
+ reasonless reasonless
+ reasons reason
+ reave reav
+ rebate rebat
+ rebato rebato
+ rebeck rebeck
+ rebel rebel
+ rebell rebel
+ rebelling rebel
+ rebellion rebellion
+ rebellious rebelli
+ rebels rebel
+ rebound rebound
+ rebuk rebuk
+ rebuke rebuk
+ rebukeable rebuk
+ rebuked rebuk
+ rebukes rebuk
+ rebus rebu
+ recall recal
+ recant recant
+ recantation recant
+ recanter recant
+ recanting recant
+ receipt receipt
+ receipts receipt
+ receiv receiv
+ receive receiv
+ received receiv
+ receiver receiv
+ receives receiv
+ receivest receivest
+ receiveth receiveth
+ receiving receiv
+ receptacle receptacl
+ rechate rechat
+ reciprocal reciproc
+ reciprocally reciproc
+ recite recit
+ recited recit
+ reciterai reciterai
+ reck reck
+ recking reck
+ reckless reckless
+ reckon reckon
+ reckoned reckon
+ reckoning reckon
+ reckonings reckon
+ recks reck
+ reclaim reclaim
+ reclaims reclaim
+ reclusive reclus
+ recognizance recogniz
+ recognizances recogniz
+ recoil recoil
+ recoiling recoil
+ recollected recollect
+ recomforted recomfort
+ recomforture recomfortur
+ recommend recommend
+ recommended recommend
+ recommends recommend
+ recompens recompen
+ recompense recompens
+ reconcil reconcil
+ reconcile reconcil
+ reconciled reconcil
+ reconcilement reconcil
+ reconciler reconcil
+ reconciles reconcil
+ reconciliation reconcili
+ record record
+ recordation record
+ recorded record
+ recorder record
+ recorders record
+ records record
+ recount recount
+ recounted recount
+ recounting recount
+ recountments recount
+ recounts recount
+ recourse recours
+ recov recov
+ recover recov
+ recoverable recover
+ recovered recov
+ recoveries recoveri
+ recovers recov
+ recovery recoveri
+ recreant recreant
+ recreants recreant
+ recreate recreat
+ recreation recreat
+ rectify rectifi
+ rector rector
+ rectorship rectorship
+ recure recur
+ recured recur
+ red red
+ redbreast redbreast
+ redder redder
+ reddest reddest
+ rede rede
+ redeem redeem
+ redeemed redeem
+ redeemer redeem
+ redeeming redeem
+ redeems redeem
+ redeliver redeliv
+ redemption redempt
+ redime redim
+ redness red
+ redoubled redoubl
+ redoubted redoubt
+ redound redound
+ redress redress
+ redressed redress
+ redresses redress
+ reduce reduc
+ reechy reechi
+ reed reed
+ reeds reed
+ reek reek
+ reeking reek
+ reeks reek
+ reeky reeki
+ reel reel
+ reeleth reeleth
+ reeling reel
+ reels reel
+ refell refel
+ refer refer
+ reference refer
+ referr referr
+ referred refer
+ refigured refigur
+ refin refin
+ refined refin
+ reflect reflect
+ reflecting reflect
+ reflection reflect
+ reflex reflex
+ reform reform
+ reformation reform
+ reformed reform
+ refractory refractori
+ refrain refrain
+ refresh refresh
+ refreshing refresh
+ reft reft
+ refts reft
+ refuge refug
+ refus refu
+ refusal refus
+ refuse refus
+ refused refus
+ refusest refusest
+ refusing refus
+ reg reg
+ regal regal
+ regalia regalia
+ regan regan
+ regard regard
+ regardance regard
+ regarded regard
+ regardfully regardfulli
+ regarding regard
+ regards regard
+ regenerate regener
+ regent regent
+ regentship regentship
+ regia regia
+ regiment regiment
+ regiments regiment
+ regina regina
+ region region
+ regions region
+ regist regist
+ register regist
+ registers regist
+ regreet regreet
+ regreets regreet
+ regress regress
+ reguerdon reguerdon
+ regular regular
+ rehears rehear
+ rehearsal rehears
+ rehearse rehears
+ reign reign
+ reigned reign
+ reignier reignier
+ reigning reign
+ reigns reign
+ rein rein
+ reinforc reinforc
+ reinforce reinforc
+ reinforcement reinforc
+ reins rein
+ reiterate reiter
+ reject reject
+ rejected reject
+ rejoic rejoic
+ rejoice rejoic
+ rejoices rejoic
+ rejoiceth rejoiceth
+ rejoicing rejoic
+ rejoicingly rejoicingli
+ rejoindure rejoindur
+ rejourn rejourn
+ rel rel
+ relapse relaps
+ relate relat
+ relates relat
+ relation relat
+ relations relat
+ relative rel
+ releas relea
+ release releas
+ released releas
+ releasing releas
+ relent relent
+ relenting relent
+ relents relent
+ reliances relianc
+ relics relic
+ relief relief
+ reliev reliev
+ relieve reliev
+ relieved reliev
+ relieves reliev
+ relieving reliev
+ religion religion
+ religions religion
+ religious religi
+ religiously religi
+ relinquish relinquish
+ reliques reliqu
+ reliquit reliquit
+ relish relish
+ relume relum
+ rely reli
+ relying reli
+ remain remain
+ remainder remaind
+ remainders remaind
+ remained remain
+ remaineth remaineth
+ remaining remain
+ remains remain
+ remark remark
+ remarkable remark
+ remediate remedi
+ remedied remedi
+ remedies remedi
+ remedy remedi
+ rememb rememb
+ remember rememb
+ remembered rememb
+ remembers rememb
+ remembrance remembr
+ remembrancer remembranc
+ remembrances remembr
+ remercimens remercimen
+ remiss remiss
+ remission remiss
+ remissness remiss
+ remit remit
+ remnant remnant
+ remnants remnant
+ remonstrance remonstr
+ remorse remors
+ remorseful remors
+ remorseless remorseless
+ remote remot
+ remotion remot
+ remov remov
+ remove remov
+ removed remov
+ removedness removed
+ remover remov
+ removes remov
+ removing remov
+ remunerate remuner
+ remuneration remuner
+ rence renc
+ rend rend
+ render render
+ rendered render
+ renders render
+ rendezvous rendezv
+ renegado renegado
+ renege reneg
+ reneges reneg
+ renew renew
+ renewed renew
+ renewest renewest
+ renounce renounc
+ renouncement renounc
+ renouncing renounc
+ renowmed renowm
+ renown renown
+ renowned renown
+ rent rent
+ rents rent
+ repaid repaid
+ repair repair
+ repaired repair
+ repairing repair
+ repairs repair
+ repass repass
+ repast repast
+ repasture repastur
+ repay repai
+ repaying repai
+ repays repai
+ repeal repeal
+ repealing repeal
+ repeals repeal
+ repeat repeat
+ repeated repeat
+ repeating repeat
+ repeats repeat
+ repel repel
+ repent repent
+ repentance repent
+ repentant repent
+ repented repent
+ repenting repent
+ repents repent
+ repetition repetit
+ repetitions repetit
+ repin repin
+ repine repin
+ repining repin
+ replant replant
+ replenish replenish
+ replenished replenish
+ replete replet
+ replication replic
+ replied repli
+ replies repli
+ repliest repliest
+ reply repli
+ replying repli
+ report report
+ reported report
+ reporter report
+ reportest reportest
+ reporting report
+ reportingly reportingli
+ reports report
+ reposal repos
+ repose repos
+ reposeth reposeth
+ reposing repos
+ repossess repossess
+ reprehend reprehend
+ reprehended reprehend
+ reprehending reprehend
+ represent repres
+ representing repres
+ reprieve repriev
+ reprieves repriev
+ reprisal repris
+ reproach reproach
+ reproaches reproach
+ reproachful reproach
+ reproachfully reproachfulli
+ reprobate reprob
+ reprobation reprob
+ reproof reproof
+ reprov reprov
+ reprove reprov
+ reproveable reprov
+ reproves reprov
+ reproving reprov
+ repugn repugn
+ repugnancy repugn
+ repugnant repugn
+ repulse repuls
+ repulsed repuls
+ repurchas repurcha
+ repured repur
+ reputation reput
+ repute reput
+ reputed reput
+ reputeless reputeless
+ reputes reput
+ reputing reput
+ request request
+ requested request
+ requesting request
+ requests request
+ requiem requiem
+ requir requir
+ require requir
+ required requir
+ requires requir
+ requireth requireth
+ requiring requir
+ requisite requisit
+ requisites requisit
+ requit requit
+ requital requit
+ requite requit
+ requited requit
+ requites requit
+ rer rer
+ rere rere
+ rers rer
+ rescu rescu
+ rescue rescu
+ rescued rescu
+ rescues rescu
+ rescuing rescu
+ resemblance resembl
+ resemble resembl
+ resembled resembl
+ resembles resembl
+ resembleth resembleth
+ resembling resembl
+ reserv reserv
+ reservation reserv
+ reserve reserv
+ reserved reserv
+ reserves reserv
+ reside resid
+ residence resid
+ resident resid
+ resides resid
+ residing resid
+ residue residu
+ resign resign
+ resignation resign
+ resist resist
+ resistance resist
+ resisted resist
+ resisting resist
+ resists resist
+ resolute resolut
+ resolutely resolut
+ resolutes resolut
+ resolution resolut
+ resolv resolv
+ resolve resolv
+ resolved resolv
+ resolvedly resolvedli
+ resolves resolv
+ resolveth resolveth
+ resort resort
+ resorted resort
+ resounding resound
+ resounds resound
+ respeaking respeak
+ respect respect
+ respected respect
+ respecting respect
+ respective respect
+ respectively respect
+ respects respect
+ respice respic
+ respite respit
+ respites respit
+ responsive respons
+ respose respos
+ ress ress
+ rest rest
+ rested rest
+ resteth resteth
+ restful rest
+ resting rest
+ restitution restitut
+ restless restless
+ restor restor
+ restoration restor
+ restorative restor
+ restore restor
+ restored restor
+ restores restor
+ restoring restor
+ restrain restrain
+ restrained restrain
+ restraining restrain
+ restrains restrain
+ restraint restraint
+ rests rest
+ resty resti
+ resum resum
+ resume resum
+ resumes resum
+ resurrections resurrect
+ retail retail
+ retails retail
+ retain retain
+ retainers retain
+ retaining retain
+ retell retel
+ retention retent
+ retentive retent
+ retinue retinu
+ retir retir
+ retire retir
+ retired retir
+ retirement retir
+ retires retir
+ retiring retir
+ retold retold
+ retort retort
+ retorts retort
+ retourne retourn
+ retract retract
+ retreat retreat
+ retrograde retrograd
+ rets ret
+ return return
+ returned return
+ returnest returnest
+ returneth returneth
+ returning return
+ returns return
+ revania revania
+ reveal reveal
+ reveals reveal
+ revel revel
+ reveler revel
+ revell revel
+ reveller revel
+ revellers revel
+ revelling revel
+ revelry revelri
+ revels revel
+ reveng reveng
+ revenge reveng
+ revenged reveng
+ revengeful reveng
+ revengement reveng
+ revenger reveng
+ revengers reveng
+ revenges reveng
+ revenging reveng
+ revengingly revengingli
+ revenue revenu
+ revenues revenu
+ reverb reverb
+ reverberate reverber
+ reverbs reverb
+ reverenc reverenc
+ reverence rever
+ reverend reverend
+ reverent rever
+ reverently rever
+ revers rever
+ reverse revers
+ reversion revers
+ reverted revert
+ review review
+ reviewest reviewest
+ revil revil
+ revile revil
+ revisits revisit
+ reviv reviv
+ revive reviv
+ revives reviv
+ reviving reviv
+ revok revok
+ revoke revok
+ revokement revok
+ revolt revolt
+ revolted revolt
+ revolting revolt
+ revolts revolt
+ revolution revolut
+ revolutions revolut
+ revolve revolv
+ revolving revolv
+ reward reward
+ rewarded reward
+ rewarder reward
+ rewarding reward
+ rewards reward
+ reword reword
+ reworded reword
+ rex rex
+ rey rei
+ reynaldo reynaldo
+ rford rford
+ rful rful
+ rfull rfull
+ rhapsody rhapsodi
+ rheims rheim
+ rhenish rhenish
+ rhesus rhesu
+ rhetoric rhetor
+ rheum rheum
+ rheumatic rheumat
+ rheums rheum
+ rheumy rheumi
+ rhinoceros rhinocero
+ rhodes rhode
+ rhodope rhodop
+ rhubarb rhubarb
+ rhym rhym
+ rhyme rhyme
+ rhymers rhymer
+ rhymes rhyme
+ rhyming rhyme
+ rialto rialto
+ rib rib
+ ribald ribald
+ riband riband
+ ribands riband
+ ribaudred ribaudr
+ ribb ribb
+ ribbed rib
+ ribbon ribbon
+ ribbons ribbon
+ ribs rib
+ rice rice
+ rich rich
+ richard richard
+ richer richer
+ riches rich
+ richest richest
+ richly richli
+ richmond richmond
+ richmonds richmond
+ rid rid
+ riddance riddanc
+ ridden ridden
+ riddle riddl
+ riddles riddl
+ riddling riddl
+ ride ride
+ rider rider
+ riders rider
+ rides ride
+ ridest ridest
+ rideth rideth
+ ridge ridg
+ ridges ridg
+ ridiculous ridicul
+ riding ride
+ rids rid
+ rien rien
+ ries ri
+ rifle rifl
+ rift rift
+ rifted rift
+ rig rig
+ rigg rigg
+ riggish riggish
+ right right
+ righteous righteou
+ righteously righteous
+ rightful right
+ rightfully rightfulli
+ rightly rightli
+ rights right
+ rigol rigol
+ rigorous rigor
+ rigorously rigor
+ rigour rigour
+ ril ril
+ rim rim
+ rin rin
+ rinaldo rinaldo
+ rind rind
+ ring ring
+ ringing ring
+ ringleader ringlead
+ ringlets ringlet
+ rings ring
+ ringwood ringwood
+ riot riot
+ rioter rioter
+ rioting riot
+ riotous riotou
+ riots riot
+ rip rip
+ ripe ripe
+ ripely ripe
+ ripen ripen
+ ripened ripen
+ ripeness ripe
+ ripening ripen
+ ripens ripen
+ riper riper
+ ripest ripest
+ riping ripe
+ ripp ripp
+ ripping rip
+ rise rise
+ risen risen
+ rises rise
+ riseth riseth
+ rish rish
+ rising rise
+ rite rite
+ rites rite
+ rivage rivag
+ rival rival
+ rivality rival
+ rivall rival
+ rivals rival
+ rive rive
+ rived rive
+ rivelled rivel
+ river river
+ rivers river
+ rivet rivet
+ riveted rivet
+ rivets rivet
+ rivo rivo
+ rj rj
+ rless rless
+ road road
+ roads road
+ roam roam
+ roaming roam
+ roan roan
+ roar roar
+ roared roar
+ roarers roarer
+ roaring roar
+ roars roar
+ roast roast
+ roasted roast
+ rob rob
+ roba roba
+ robas roba
+ robb robb
+ robbed rob
+ robber robber
+ robbers robber
+ robbery robberi
+ robbing rob
+ robe robe
+ robed robe
+ robert robert
+ robes robe
+ robin robin
+ robs rob
+ robustious robusti
+ rochester rochest
+ rochford rochford
+ rock rock
+ rocks rock
+ rocky rocki
+ rod rod
+ rode rode
+ roderigo roderigo
+ rods rod
+ roe roe
+ roes roe
+ roger roger
+ rogero rogero
+ rogue rogu
+ roguery rogueri
+ rogues rogu
+ roguish roguish
+ roi roi
+ roisting roist
+ roll roll
+ rolled roll
+ rolling roll
+ rolls roll
+ rom rom
+ romage romag
+ roman roman
+ romano romano
+ romanos romano
+ romans roman
+ rome rome
+ romeo romeo
+ romish romish
+ rondure rondur
+ ronyon ronyon
+ rood rood
+ roof roof
+ roofs roof
+ rook rook
+ rooks rook
+ rooky rooki
+ room room
+ rooms room
+ root root
+ rooted root
+ rootedly rootedli
+ rooteth rooteth
+ rooting root
+ roots root
+ rope rope
+ ropery roperi
+ ropes rope
+ roping rope
+ ros ro
+ rosalind rosalind
+ rosalinda rosalinda
+ rosalinde rosalind
+ rosaline rosalin
+ roscius rosciu
+ rose rose
+ rosed rose
+ rosemary rosemari
+ rosencrantz rosencrantz
+ roses rose
+ ross ross
+ rosy rosi
+ rot rot
+ rote rote
+ roted rote
+ rother rother
+ rotherham rotherham
+ rots rot
+ rotted rot
+ rotten rotten
+ rottenness rotten
+ rotting rot
+ rotundity rotund
+ rouen rouen
+ rough rough
+ rougher rougher
+ roughest roughest
+ roughly roughli
+ roughness rough
+ round round
+ rounded round
+ roundel roundel
+ rounder rounder
+ roundest roundest
+ rounding round
+ roundly roundli
+ rounds round
+ roundure roundur
+ rous rou
+ rouse rous
+ roused rous
+ rousillon rousillon
+ rously rousli
+ roussi roussi
+ rout rout
+ routed rout
+ routs rout
+ rove rove
+ rover rover
+ row row
+ rowel rowel
+ rowland rowland
+ rowlands rowland
+ roy roi
+ royal royal
+ royalize royal
+ royally royal
+ royalties royalti
+ royalty royalti
+ roynish roynish
+ rs rs
+ rt rt
+ rub rub
+ rubb rubb
+ rubbing rub
+ rubbish rubbish
+ rubies rubi
+ rubious rubiou
+ rubs rub
+ ruby rubi
+ rud rud
+ rudand rudand
+ rudder rudder
+ ruddiness ruddi
+ ruddock ruddock
+ ruddy ruddi
+ rude rude
+ rudely rude
+ rudeness rude
+ ruder ruder
+ rudesby rudesbi
+ rudest rudest
+ rudiments rudiment
+ rue rue
+ rued ru
+ ruff ruff
+ ruffian ruffian
+ ruffians ruffian
+ ruffle ruffl
+ ruffling ruffl
+ ruffs ruff
+ rug rug
+ rugby rugbi
+ rugemount rugemount
+ rugged rug
+ ruin ruin
+ ruinate ruinat
+ ruined ruin
+ ruining ruin
+ ruinous ruinou
+ ruins ruin
+ rul rul
+ rule rule
+ ruled rule
+ ruler ruler
+ rulers ruler
+ rules rule
+ ruling rule
+ rumble rumbl
+ ruminaies ruminai
+ ruminat ruminat
+ ruminate rumin
+ ruminated rumin
+ ruminates rumin
+ rumination rumin
+ rumor rumor
+ rumour rumour
+ rumourer rumour
+ rumours rumour
+ rump rump
+ run run
+ runagate runag
+ runagates runag
+ runaway runawai
+ runaways runawai
+ rung rung
+ runn runn
+ runner runner
+ runners runner
+ running run
+ runs run
+ rupture ruptur
+ ruptures ruptur
+ rural rural
+ rush rush
+ rushes rush
+ rushing rush
+ rushling rushl
+ rushy rushi
+ russet russet
+ russia russia
+ russian russian
+ russians russian
+ rust rust
+ rusted rust
+ rustic rustic
+ rustically rustic
+ rustics rustic
+ rustle rustl
+ rustling rustl
+ rusts rust
+ rusty rusti
+ rut rut
+ ruth ruth
+ ruthful ruth
+ ruthless ruthless
+ rutland rutland
+ ruttish ruttish
+ ry ry
+ rye rye
+ rything ryth
+ s s
+ sa sa
+ saba saba
+ sabbath sabbath
+ sable sabl
+ sables sabl
+ sack sack
+ sackbuts sackbut
+ sackcloth sackcloth
+ sacked sack
+ sackerson sackerson
+ sacks sack
+ sacrament sacrament
+ sacred sacr
+ sacrific sacrif
+ sacrifice sacrific
+ sacrificers sacrific
+ sacrifices sacrific
+ sacrificial sacrifici
+ sacrificing sacrif
+ sacrilegious sacrilegi
+ sacring sacr
+ sad sad
+ sadder sadder
+ saddest saddest
+ saddle saddl
+ saddler saddler
+ saddles saddl
+ sadly sadli
+ sadness sad
+ saf saf
+ safe safe
+ safeguard safeguard
+ safely safe
+ safer safer
+ safest safest
+ safeties safeti
+ safety safeti
+ saffron saffron
+ sag sag
+ sage sage
+ sagittary sagittari
+ said said
+ saidst saidst
+ sail sail
+ sailing sail
+ sailmaker sailmak
+ sailor sailor
+ sailors sailor
+ sails sail
+ sain sain
+ saint saint
+ sainted saint
+ saintlike saintlik
+ saints saint
+ saith saith
+ sake sake
+ sakes sake
+ sala sala
+ salad salad
+ salamander salamand
+ salary salari
+ sale sale
+ salerio salerio
+ salicam salicam
+ salique saliqu
+ salisbury salisburi
+ sall sall
+ sallet sallet
+ sallets sallet
+ sallies salli
+ sallow sallow
+ sally salli
+ salmon salmon
+ salmons salmon
+ salt salt
+ salter salter
+ saltiers saltier
+ saltness salt
+ saltpetre saltpetr
+ salutation salut
+ salutations salut
+ salute salut
+ saluted salut
+ salutes salut
+ saluteth saluteth
+ salv salv
+ salvation salvat
+ salve salv
+ salving salv
+ same same
+ samingo samingo
+ samp samp
+ sampire sampir
+ sample sampl
+ sampler sampler
+ sampson sampson
+ samson samson
+ samsons samson
+ sancta sancta
+ sanctified sanctifi
+ sanctifies sanctifi
+ sanctify sanctifi
+ sanctimonies sanctimoni
+ sanctimonious sanctimoni
+ sanctimony sanctimoni
+ sanctities sanctiti
+ sanctity sanctiti
+ sanctuarize sanctuar
+ sanctuary sanctuari
+ sand sand
+ sandal sandal
+ sandbag sandbag
+ sanded sand
+ sands sand
+ sandy sandi
+ sandys sandi
+ sang sang
+ sanguine sanguin
+ sanguis sangui
+ sanity saniti
+ sans san
+ santrailles santrail
+ sap sap
+ sapient sapient
+ sapit sapit
+ sapless sapless
+ sapling sapl
+ sapphire sapphir
+ sapphires sapphir
+ saracens saracen
+ sarcenet sarcenet
+ sard sard
+ sardians sardian
+ sardinia sardinia
+ sardis sardi
+ sarum sarum
+ sat sat
+ satan satan
+ satchel satchel
+ sate sate
+ sated sate
+ satiate satiat
+ satiety satieti
+ satin satin
+ satire satir
+ satirical satir
+ satis sati
+ satisfaction satisfact
+ satisfied satisfi
+ satisfies satisfi
+ satisfy satisfi
+ satisfying satisfi
+ saturday saturdai
+ saturdays saturdai
+ saturn saturn
+ saturnine saturnin
+ saturninus saturninu
+ satyr satyr
+ satyrs satyr
+ sauc sauc
+ sauce sauc
+ sauced sauc
+ saucers saucer
+ sauces sauc
+ saucily saucili
+ sauciness sauci
+ saucy sauci
+ sauf sauf
+ saunder saunder
+ sav sav
+ savage savag
+ savagely savag
+ savageness savag
+ savagery savageri
+ savages savag
+ save save
+ saved save
+ saves save
+ saving save
+ saviour saviour
+ savory savori
+ savour savour
+ savouring savour
+ savours savour
+ savoury savouri
+ savoy savoi
+ saw saw
+ sawed saw
+ sawest sawest
+ sawn sawn
+ sawpit sawpit
+ saws saw
+ sawyer sawyer
+ saxons saxon
+ saxony saxoni
+ saxton saxton
+ say sai
+ sayest sayest
+ saying sai
+ sayings sai
+ says sai
+ sayst sayst
+ sblood sblood
+ sc sc
+ scab scab
+ scabbard scabbard
+ scabs scab
+ scaffold scaffold
+ scaffoldage scaffoldag
+ scal scal
+ scald scald
+ scalded scald
+ scalding scald
+ scale scale
+ scaled scale
+ scales scale
+ scaling scale
+ scall scall
+ scalp scalp
+ scalps scalp
+ scaly scali
+ scamble scambl
+ scambling scambl
+ scamels scamel
+ scan scan
+ scandal scandal
+ scandaliz scandaliz
+ scandalous scandal
+ scandy scandi
+ scann scann
+ scant scant
+ scanted scant
+ scanter scanter
+ scanting scant
+ scantling scantl
+ scants scant
+ scap scap
+ scape scape
+ scaped scape
+ scapes scape
+ scapeth scapeth
+ scar scar
+ scarce scarc
+ scarcely scarc
+ scarcity scarciti
+ scare scare
+ scarecrow scarecrow
+ scarecrows scarecrow
+ scarf scarf
+ scarfed scarf
+ scarfs scarf
+ scaring scare
+ scarlet scarlet
+ scarr scarr
+ scarre scarr
+ scars scar
+ scarus scaru
+ scath scath
+ scathe scath
+ scathful scath
+ scatt scatt
+ scatter scatter
+ scattered scatter
+ scattering scatter
+ scatters scatter
+ scelera scelera
+ scelerisque scelerisqu
+ scene scene
+ scenes scene
+ scent scent
+ scented scent
+ scept scept
+ scepter scepter
+ sceptre sceptr
+ sceptred sceptr
+ sceptres sceptr
+ schedule schedul
+ schedules schedul
+ scholar scholar
+ scholarly scholarli
+ scholars scholar
+ school school
+ schoolboy schoolboi
+ schoolboys schoolboi
+ schoolfellows schoolfellow
+ schooling school
+ schoolmaster schoolmast
+ schoolmasters schoolmast
+ schools school
+ sciatica sciatica
+ sciaticas sciatica
+ science scienc
+ sciences scienc
+ scimitar scimitar
+ scion scion
+ scions scion
+ scissors scissor
+ scoff scoff
+ scoffer scoffer
+ scoffing scof
+ scoffs scoff
+ scoggin scoggin
+ scold scold
+ scolding scold
+ scolds scold
+ sconce sconc
+ scone scone
+ scope scope
+ scopes scope
+ scorch scorch
+ scorched scorch
+ score score
+ scored score
+ scores score
+ scoring score
+ scorn scorn
+ scorned scorn
+ scornful scorn
+ scornfully scornfulli
+ scorning scorn
+ scorns scorn
+ scorpion scorpion
+ scorpions scorpion
+ scot scot
+ scotch scotch
+ scotches scotch
+ scotland scotland
+ scots scot
+ scottish scottish
+ scoundrels scoundrel
+ scour scour
+ scoured scour
+ scourg scourg
+ scourge scourg
+ scouring scour
+ scout scout
+ scouts scout
+ scowl scowl
+ scrap scrap
+ scrape scrape
+ scraping scrape
+ scraps scrap
+ scratch scratch
+ scratches scratch
+ scratching scratch
+ scream scream
+ screams scream
+ screech screech
+ screeching screech
+ screen screen
+ screens screen
+ screw screw
+ screws screw
+ scribbl scribbl
+ scribbled scribbl
+ scribe scribe
+ scribes scribe
+ scrimers scrimer
+ scrip scrip
+ scrippage scrippag
+ scripture scriptur
+ scriptures scriptur
+ scrivener scriven
+ scroll scroll
+ scrolls scroll
+ scroop scroop
+ scrowl scrowl
+ scroyles scroyl
+ scrubbed scrub
+ scruple scrupl
+ scruples scrupl
+ scrupulous scrupul
+ scuffles scuffl
+ scuffling scuffl
+ scullion scullion
+ sculls scull
+ scum scum
+ scurril scurril
+ scurrility scurril
+ scurrilous scurril
+ scurvy scurvi
+ scuse scuse
+ scut scut
+ scutcheon scutcheon
+ scutcheons scutcheon
+ scylla scylla
+ scythe scyth
+ scythed scyth
+ scythia scythia
+ scythian scythian
+ sdeath sdeath
+ se se
+ sea sea
+ seacoal seacoal
+ seafaring seafar
+ seal seal
+ sealed seal
+ sealing seal
+ seals seal
+ seam seam
+ seamen seamen
+ seamy seami
+ seaport seaport
+ sear sear
+ searce searc
+ search search
+ searchers searcher
+ searches search
+ searcheth searcheth
+ searching search
+ seared sear
+ seas sea
+ seasick seasick
+ seaside seasid
+ season season
+ seasoned season
+ seasons season
+ seat seat
+ seated seat
+ seats seat
+ sebastian sebastian
+ second second
+ secondarily secondarili
+ secondary secondari
+ seconded second
+ seconds second
+ secrecy secreci
+ secret secret
+ secretaries secretari
+ secretary secretari
+ secretly secretli
+ secrets secret
+ sect sect
+ sectary sectari
+ sects sect
+ secundo secundo
+ secure secur
+ securely secur
+ securing secur
+ security secur
+ sedg sedg
+ sedge sedg
+ sedges sedg
+ sedgy sedgi
+ sedition sedit
+ seditious sediti
+ seduc seduc
+ seduce seduc
+ seduced seduc
+ seducer seduc
+ seducing seduc
+ see see
+ seed seed
+ seeded seed
+ seedness seed
+ seeds seed
+ seedsman seedsman
+ seein seein
+ seeing see
+ seek seek
+ seeking seek
+ seeks seek
+ seel seel
+ seeling seel
+ seely seeli
+ seem seem
+ seemed seem
+ seemers seemer
+ seemest seemest
+ seemeth seemeth
+ seeming seem
+ seemingly seemingli
+ seemly seemli
+ seems seem
+ seen seen
+ seer seer
+ sees see
+ seese sees
+ seest seest
+ seethe seeth
+ seethes seeth
+ seething seeth
+ seeting seet
+ segregation segreg
+ seigneur seigneur
+ seigneurs seigneur
+ seiz seiz
+ seize seiz
+ seized seiz
+ seizes seiz
+ seizeth seizeth
+ seizing seiz
+ seizure seizur
+ seld seld
+ seldom seldom
+ select select
+ seleucus seleucu
+ self self
+ selfsame selfsam
+ sell sell
+ seller seller
+ selling sell
+ sells sell
+ selves selv
+ semblable semblabl
+ semblably semblabl
+ semblance semblanc
+ semblances semblanc
+ semblative sembl
+ semi semi
+ semicircle semicircl
+ semiramis semirami
+ semper semper
+ sempronius semproniu
+ senate senat
+ senator senat
+ senators senat
+ send send
+ sender sender
+ sendeth sendeth
+ sending send
+ sends send
+ seneca seneca
+ senior senior
+ seniory seniori
+ senis seni
+ sennet sennet
+ senoys senoi
+ sense sens
+ senseless senseless
+ senses sens
+ sensible sensibl
+ sensibly sensibl
+ sensual sensual
+ sensuality sensual
+ sent sent
+ sentenc sentenc
+ sentence sentenc
+ sentences sentenc
+ sententious sententi
+ sentinel sentinel
+ sentinels sentinel
+ separable separ
+ separate separ
+ separated separ
+ separates separ
+ separation separ
+ septentrion septentrion
+ sepulchre sepulchr
+ sepulchres sepulchr
+ sepulchring sepulchr
+ sequel sequel
+ sequence sequenc
+ sequent sequent
+ sequest sequest
+ sequester sequest
+ sequestration sequestr
+ sere sere
+ serenis sereni
+ serge serg
+ sergeant sergeant
+ serious seriou
+ seriously serious
+ sermon sermon
+ sermons sermon
+ serpent serpent
+ serpentine serpentin
+ serpents serpent
+ serpigo serpigo
+ serv serv
+ servant servant
+ servanted servant
+ servants servant
+ serve serv
+ served serv
+ server server
+ serves serv
+ serveth serveth
+ service servic
+ serviceable servic
+ services servic
+ servile servil
+ servility servil
+ servilius serviliu
+ serving serv
+ servingman servingman
+ servingmen servingmen
+ serviteur serviteur
+ servitor servitor
+ servitors servitor
+ servitude servitud
+ sessa sessa
+ session session
+ sessions session
+ sestos sesto
+ set set
+ setebos setebo
+ sets set
+ setter setter
+ setting set
+ settle settl
+ settled settl
+ settlest settlest
+ settling settl
+ sev sev
+ seven seven
+ sevenfold sevenfold
+ sevennight sevennight
+ seventeen seventeen
+ seventh seventh
+ seventy seventi
+ sever sever
+ several sever
+ severally sever
+ severals sever
+ severe sever
+ severed sever
+ severely sever
+ severest severest
+ severing sever
+ severity sever
+ severn severn
+ severs sever
+ sew sew
+ seward seward
+ sewer sewer
+ sewing sew
+ sex sex
+ sexes sex
+ sexton sexton
+ sextus sextu
+ seymour seymour
+ seyton seyton
+ sfoot sfoot
+ sh sh
+ shackle shackl
+ shackles shackl
+ shade shade
+ shades shade
+ shadow shadow
+ shadowed shadow
+ shadowing shadow
+ shadows shadow
+ shadowy shadowi
+ shady shadi
+ shafalus shafalu
+ shaft shaft
+ shafts shaft
+ shag shag
+ shak shak
+ shake shake
+ shaked shake
+ shaken shaken
+ shakes shake
+ shaking shake
+ shales shale
+ shall shall
+ shallenge shalleng
+ shallow shallow
+ shallowest shallowest
+ shallowly shallowli
+ shallows shallow
+ shalt shalt
+ sham sham
+ shambles shambl
+ shame shame
+ shamed shame
+ shameful shame
+ shamefully shamefulli
+ shameless shameless
+ shames shame
+ shamest shamest
+ shaming shame
+ shank shank
+ shanks shank
+ shap shap
+ shape shape
+ shaped shape
+ shapeless shapeless
+ shapen shapen
+ shapes shape
+ shaping shape
+ shar shar
+ shard shard
+ sharded shard
+ shards shard
+ share share
+ shared share
+ sharers sharer
+ shares share
+ sharing share
+ shark shark
+ sharp sharp
+ sharpen sharpen
+ sharpened sharpen
+ sharpens sharpen
+ sharper sharper
+ sharpest sharpest
+ sharply sharpli
+ sharpness sharp
+ sharps sharp
+ shatter shatter
+ shav shav
+ shave shave
+ shaven shaven
+ shaw shaw
+ she she
+ sheaf sheaf
+ sheal sheal
+ shear shear
+ shearers shearer
+ shearing shear
+ shearman shearman
+ shears shear
+ sheath sheath
+ sheathe sheath
+ sheathed sheath
+ sheathes sheath
+ sheathing sheath
+ sheaved sheav
+ sheaves sheav
+ shed shed
+ shedding shed
+ sheds shed
+ sheen sheen
+ sheep sheep
+ sheepcote sheepcot
+ sheepcotes sheepcot
+ sheeps sheep
+ sheepskins sheepskin
+ sheer sheer
+ sheet sheet
+ sheeted sheet
+ sheets sheet
+ sheffield sheffield
+ shelf shelf
+ shell shell
+ shells shell
+ shelt shelt
+ shelter shelter
+ shelters shelter
+ shelves shelv
+ shelving shelv
+ shelvy shelvi
+ shent shent
+ shepherd shepherd
+ shepherdes shepherd
+ shepherdess shepherdess
+ shepherdesses shepherdess
+ shepherds shepherd
+ sher sher
+ sheriff sheriff
+ sherris sherri
+ shes she
+ sheweth sheweth
+ shield shield
+ shielded shield
+ shields shield
+ shift shift
+ shifted shift
+ shifting shift
+ shifts shift
+ shilling shill
+ shillings shill
+ shin shin
+ shine shine
+ shines shine
+ shineth shineth
+ shining shine
+ shins shin
+ shiny shini
+ ship ship
+ shipboard shipboard
+ shipman shipman
+ shipmaster shipmast
+ shipmen shipmen
+ shipp shipp
+ shipped ship
+ shipping ship
+ ships ship
+ shipt shipt
+ shipwreck shipwreck
+ shipwrecking shipwreck
+ shipwright shipwright
+ shipwrights shipwright
+ shire shire
+ shirley shirlei
+ shirt shirt
+ shirts shirt
+ shive shive
+ shiver shiver
+ shivering shiver
+ shivers shiver
+ shoal shoal
+ shoals shoal
+ shock shock
+ shocks shock
+ shod shod
+ shoe shoe
+ shoeing shoe
+ shoemaker shoemak
+ shoes shoe
+ shog shog
+ shone shone
+ shook shook
+ shoon shoon
+ shoot shoot
+ shooter shooter
+ shootie shooti
+ shooting shoot
+ shoots shoot
+ shop shop
+ shops shop
+ shore shore
+ shores shore
+ shorn shorn
+ short short
+ shortcake shortcak
+ shorten shorten
+ shortened shorten
+ shortens shorten
+ shorter shorter
+ shortly shortli
+ shortness short
+ shot shot
+ shotten shotten
+ shoughs shough
+ should should
+ shoulder shoulder
+ shouldering shoulder
+ shoulders shoulder
+ shouldst shouldst
+ shout shout
+ shouted shout
+ shouting shout
+ shouts shout
+ shov shov
+ shove shove
+ shovel shovel
+ shovels shovel
+ show show
+ showed show
+ shower shower
+ showers shower
+ showest showest
+ showing show
+ shown shown
+ shows show
+ shreds shred
+ shrew shrew
+ shrewd shrewd
+ shrewdly shrewdli
+ shrewdness shrewd
+ shrewish shrewish
+ shrewishly shrewishli
+ shrewishness shrewish
+ shrews shrew
+ shrewsbury shrewsburi
+ shriek shriek
+ shrieking shriek
+ shrieks shriek
+ shrieve shriev
+ shrift shrift
+ shrill shrill
+ shriller shriller
+ shrills shrill
+ shrilly shrilli
+ shrimp shrimp
+ shrine shrine
+ shrink shrink
+ shrinking shrink
+ shrinks shrink
+ shriv shriv
+ shrive shrive
+ shriver shriver
+ shrives shrive
+ shriving shrive
+ shroud shroud
+ shrouded shroud
+ shrouding shroud
+ shrouds shroud
+ shrove shrove
+ shrow shrow
+ shrows shrow
+ shrub shrub
+ shrubs shrub
+ shrug shrug
+ shrugs shrug
+ shrunk shrunk
+ shudd shudd
+ shudders shudder
+ shuffl shuffl
+ shuffle shuffl
+ shuffled shuffl
+ shuffling shuffl
+ shun shun
+ shunless shunless
+ shunn shunn
+ shunned shun
+ shunning shun
+ shuns shun
+ shut shut
+ shuts shut
+ shuttle shuttl
+ shy shy
+ shylock shylock
+ si si
+ sibyl sibyl
+ sibylla sibylla
+ sibyls sibyl
+ sicil sicil
+ sicilia sicilia
+ sicilian sicilian
+ sicilius siciliu
+ sicils sicil
+ sicily sicili
+ sicinius siciniu
+ sick sick
+ sicken sicken
+ sickens sicken
+ sicker sicker
+ sickle sickl
+ sicklemen sicklemen
+ sicklied sickli
+ sickliness sickli
+ sickly sickli
+ sickness sick
+ sicles sicl
+ sicyon sicyon
+ side side
+ sided side
+ sides side
+ siege sieg
+ sieges sieg
+ sienna sienna
+ sies si
+ sieve siev
+ sift sift
+ sifted sift
+ sigeia sigeia
+ sigh sigh
+ sighed sigh
+ sighing sigh
+ sighs sigh
+ sight sight
+ sighted sight
+ sightless sightless
+ sightly sightli
+ sights sight
+ sign sign
+ signal signal
+ signet signet
+ signieur signieur
+ significant signific
+ significants signific
+ signified signifi
+ signifies signifi
+ signify signifi
+ signifying signifi
+ signior signior
+ signiories signiori
+ signiors signior
+ signiory signiori
+ signor signor
+ signories signori
+ signs sign
+ signum signum
+ silenc silenc
+ silence silenc
+ silenced silenc
+ silencing silenc
+ silent silent
+ silently silent
+ silius siliu
+ silk silk
+ silken silken
+ silkman silkman
+ silks silk
+ silliest silliest
+ silliness silli
+ silling sill
+ silly silli
+ silva silva
+ silver silver
+ silvered silver
+ silverly silverli
+ silvia silvia
+ silvius silviu
+ sima sima
+ simile simil
+ similes simil
+ simois simoi
+ simon simon
+ simony simoni
+ simp simp
+ simpcox simpcox
+ simple simpl
+ simpleness simpl
+ simpler simpler
+ simples simpl
+ simplicity simplic
+ simply simpli
+ simular simular
+ simulation simul
+ sin sin
+ since sinc
+ sincere sincer
+ sincerely sincer
+ sincerity sincer
+ sinel sinel
+ sinew sinew
+ sinewed sinew
+ sinews sinew
+ sinewy sinewi
+ sinful sin
+ sinfully sinfulli
+ sing sing
+ singe sing
+ singeing sing
+ singer singer
+ singes sing
+ singeth singeth
+ singing sing
+ single singl
+ singled singl
+ singleness singl
+ singly singli
+ sings sing
+ singular singular
+ singulariter singularit
+ singularities singular
+ singularity singular
+ singuled singul
+ sinister sinist
+ sink sink
+ sinking sink
+ sinks sink
+ sinn sinn
+ sinner sinner
+ sinners sinner
+ sinning sin
+ sinon sinon
+ sins sin
+ sip sip
+ sipping sip
+ sir sir
+ sire sire
+ siren siren
+ sirrah sirrah
+ sirs sir
+ sist sist
+ sister sister
+ sisterhood sisterhood
+ sisterly sisterli
+ sisters sister
+ sit sit
+ sith sith
+ sithence sithenc
+ sits sit
+ sitting sit
+ situate situat
+ situation situat
+ situations situat
+ siward siward
+ six six
+ sixpence sixpenc
+ sixpences sixpenc
+ sixpenny sixpenni
+ sixteen sixteen
+ sixth sixth
+ sixty sixti
+ siz siz
+ size size
+ sizes size
+ sizzle sizzl
+ skains skain
+ skamble skambl
+ skein skein
+ skelter skelter
+ skies ski
+ skilful skil
+ skilfully skilfulli
+ skill skill
+ skilless skilless
+ skillet skillet
+ skillful skill
+ skills skill
+ skim skim
+ skimble skimbl
+ skin skin
+ skinker skinker
+ skinny skinni
+ skins skin
+ skip skip
+ skipp skipp
+ skipper skipper
+ skipping skip
+ skirmish skirmish
+ skirmishes skirmish
+ skirr skirr
+ skirted skirt
+ skirts skirt
+ skittish skittish
+ skulking skulk
+ skull skull
+ skulls skull
+ sky sky
+ skyey skyei
+ skyish skyish
+ slab slab
+ slack slack
+ slackly slackli
+ slackness slack
+ slain slain
+ slake slake
+ sland sland
+ slander slander
+ slandered slander
+ slanderer slander
+ slanderers slander
+ slandering slander
+ slanderous slander
+ slanders slander
+ slash slash
+ slaught slaught
+ slaughter slaughter
+ slaughtered slaughter
+ slaughterer slaughter
+ slaughterman slaughterman
+ slaughtermen slaughtermen
+ slaughterous slaughter
+ slaughters slaughter
+ slave slave
+ slaver slaver
+ slavery slaveri
+ slaves slave
+ slavish slavish
+ slay slai
+ slayeth slayeth
+ slaying slai
+ slays slai
+ sleave sleav
+ sledded sled
+ sleek sleek
+ sleekly sleekli
+ sleep sleep
+ sleeper sleeper
+ sleepers sleeper
+ sleepest sleepest
+ sleeping sleep
+ sleeps sleep
+ sleepy sleepi
+ sleeve sleev
+ sleeves sleev
+ sleid sleid
+ sleided sleid
+ sleight sleight
+ sleights sleight
+ slender slender
+ slenderer slender
+ slenderly slenderli
+ slept slept
+ slew slew
+ slewest slewest
+ slice slice
+ slid slid
+ slide slide
+ slides slide
+ sliding slide
+ slight slight
+ slighted slight
+ slightest slightest
+ slightly slightli
+ slightness slight
+ slights slight
+ slily slili
+ slime slime
+ slimy slimi
+ slings sling
+ slink slink
+ slip slip
+ slipp slipp
+ slipper slipper
+ slippers slipper
+ slippery slipperi
+ slips slip
+ slish slish
+ slit slit
+ sliver sliver
+ slobb slobb
+ slomber slomber
+ slop slop
+ slope slope
+ slops slop
+ sloth sloth
+ slothful sloth
+ slough slough
+ slovenly slovenli
+ slovenry slovenri
+ slow slow
+ slower slower
+ slowly slowli
+ slowness slow
+ slubber slubber
+ slug slug
+ sluggard sluggard
+ sluggardiz sluggardiz
+ sluggish sluggish
+ sluic sluic
+ slumb slumb
+ slumber slumber
+ slumbers slumber
+ slumbery slumberi
+ slunk slunk
+ slut slut
+ sluts slut
+ sluttery slutteri
+ sluttish sluttish
+ sluttishness sluttish
+ sly sly
+ slys sly
+ smack smack
+ smacking smack
+ smacks smack
+ small small
+ smaller smaller
+ smallest smallest
+ smallness small
+ smalus smalu
+ smart smart
+ smarting smart
+ smartly smartli
+ smatch smatch
+ smatter smatter
+ smear smear
+ smell smell
+ smelling smell
+ smells smell
+ smelt smelt
+ smil smil
+ smile smile
+ smiled smile
+ smiles smile
+ smilest smilest
+ smilets smilet
+ smiling smile
+ smilingly smilingli
+ smirch smirch
+ smirched smirch
+ smit smit
+ smite smite
+ smites smite
+ smith smith
+ smithfield smithfield
+ smock smock
+ smocks smock
+ smok smok
+ smoke smoke
+ smoked smoke
+ smokes smoke
+ smoking smoke
+ smoky smoki
+ smooth smooth
+ smoothed smooth
+ smoothing smooth
+ smoothly smoothli
+ smoothness smooth
+ smooths smooth
+ smote smote
+ smoth smoth
+ smother smother
+ smothered smother
+ smothering smother
+ smug smug
+ smulkin smulkin
+ smutch smutch
+ snaffle snaffl
+ snail snail
+ snails snail
+ snake snake
+ snakes snake
+ snaky snaki
+ snap snap
+ snapp snapp
+ snapper snapper
+ snar snar
+ snare snare
+ snares snare
+ snarl snarl
+ snarleth snarleth
+ snarling snarl
+ snatch snatch
+ snatchers snatcher
+ snatches snatch
+ snatching snatch
+ sneak sneak
+ sneaking sneak
+ sneap sneap
+ sneaping sneap
+ sneck sneck
+ snip snip
+ snipe snipe
+ snipt snipt
+ snore snore
+ snores snore
+ snoring snore
+ snorting snort
+ snout snout
+ snow snow
+ snowballs snowbal
+ snowed snow
+ snowy snowi
+ snuff snuff
+ snuffs snuff
+ snug snug
+ so so
+ soak soak
+ soaking soak
+ soaks soak
+ soar soar
+ soaring soar
+ soars soar
+ sob sob
+ sobbing sob
+ sober sober
+ soberly soberli
+ sobriety sobrieti
+ sobs sob
+ sociable sociabl
+ societies societi
+ society societi
+ socks sock
+ socrates socrat
+ sod sod
+ sodden sodden
+ soe soe
+ soever soever
+ soft soft
+ soften soften
+ softens soften
+ softer softer
+ softest softest
+ softly softli
+ softness soft
+ soil soil
+ soiled soil
+ soilure soilur
+ soit soit
+ sojourn sojourn
+ sol sol
+ sola sola
+ solace solac
+ solanio solanio
+ sold sold
+ soldat soldat
+ solder solder
+ soldest soldest
+ soldier soldier
+ soldiers soldier
+ soldiership soldiership
+ sole sole
+ solely sole
+ solem solem
+ solemn solemn
+ solemness solem
+ solemnities solemn
+ solemnity solemn
+ solemniz solemniz
+ solemnize solemn
+ solemnized solemn
+ solemnly solemnli
+ soles sole
+ solicit solicit
+ solicitation solicit
+ solicited solicit
+ soliciting solicit
+ solicitings solicit
+ solicitor solicitor
+ solicits solicit
+ solid solid
+ solidares solidar
+ solidity solid
+ solinus solinu
+ solitary solitari
+ solomon solomon
+ solon solon
+ solum solum
+ solus solu
+ solyman solyman
+ some some
+ somebody somebodi
+ someone someon
+ somerset somerset
+ somerville somervil
+ something someth
+ sometime sometim
+ sometimes sometim
+ somever somev
+ somewhat somewhat
+ somewhere somewher
+ somewhither somewhith
+ somme somm
+ son son
+ sonance sonanc
+ song song
+ songs song
+ sonnet sonnet
+ sonneting sonnet
+ sonnets sonnet
+ sons son
+ sont sont
+ sonties sonti
+ soon soon
+ sooner sooner
+ soonest soonest
+ sooth sooth
+ soothe sooth
+ soothers soother
+ soothing sooth
+ soothsay soothsai
+ soothsayer soothsay
+ sooty sooti
+ sop sop
+ sophister sophist
+ sophisticated sophist
+ sophy sophi
+ sops sop
+ sorcerer sorcer
+ sorcerers sorcer
+ sorceress sorceress
+ sorceries sorceri
+ sorcery sorceri
+ sore sore
+ sorel sorel
+ sorely sore
+ sorer sorer
+ sores sore
+ sorrier sorrier
+ sorriest sorriest
+ sorrow sorrow
+ sorrowed sorrow
+ sorrowest sorrowest
+ sorrowful sorrow
+ sorrowing sorrow
+ sorrows sorrow
+ sorry sorri
+ sort sort
+ sortance sortanc
+ sorted sort
+ sorting sort
+ sorts sort
+ sossius sossiu
+ sot sot
+ soto soto
+ sots sot
+ sottish sottish
+ soud soud
+ sought sought
+ soul soul
+ sould sould
+ soulless soulless
+ souls soul
+ sound sound
+ sounded sound
+ sounder sounder
+ soundest soundest
+ sounding sound
+ soundless soundless
+ soundly soundli
+ soundness sound
+ soundpost soundpost
+ sounds sound
+ sour sour
+ source sourc
+ sources sourc
+ sourest sourest
+ sourly sourli
+ sours sour
+ sous sou
+ souse sous
+ south south
+ southam southam
+ southampton southampton
+ southerly southerli
+ southern southern
+ southward southward
+ southwark southwark
+ southwell southwel
+ souviendrai souviendrai
+ sov sov
+ sovereign sovereign
+ sovereignest sovereignest
+ sovereignly sovereignli
+ sovereignty sovereignti
+ sovereignvours sovereignvour
+ sow sow
+ sowing sow
+ sowl sowl
+ sowter sowter
+ space space
+ spaces space
+ spacious spaciou
+ spade spade
+ spades spade
+ spain spain
+ spak spak
+ spake spake
+ spakest spakest
+ span span
+ spangle spangl
+ spangled spangl
+ spaniard spaniard
+ spaniel spaniel
+ spaniels spaniel
+ spanish spanish
+ spann spann
+ spans span
+ spar spar
+ spare spare
+ spares spare
+ sparing spare
+ sparingly sparingli
+ spark spark
+ sparkle sparkl
+ sparkles sparkl
+ sparkling sparkl
+ sparks spark
+ sparrow sparrow
+ sparrows sparrow
+ sparta sparta
+ spartan spartan
+ spavin spavin
+ spavins spavin
+ spawn spawn
+ speak speak
+ speaker speaker
+ speakers speaker
+ speakest speakest
+ speaketh speaketh
+ speaking speak
+ speaks speak
+ spear spear
+ speargrass speargrass
+ spears spear
+ special special
+ specialities special
+ specially special
+ specialties specialti
+ specialty specialti
+ specify specifi
+ speciously specious
+ spectacle spectacl
+ spectacled spectacl
+ spectacles spectacl
+ spectators spectat
+ spectatorship spectatorship
+ speculation specul
+ speculations specul
+ speculative specul
+ sped sped
+ speech speech
+ speeches speech
+ speechless speechless
+ speed speed
+ speeded speed
+ speedier speedier
+ speediest speediest
+ speedily speedili
+ speediness speedi
+ speeding speed
+ speeds speed
+ speedy speedi
+ speens speen
+ spell spell
+ spelling spell
+ spells spell
+ spelt spelt
+ spencer spencer
+ spend spend
+ spendest spendest
+ spending spend
+ spends spend
+ spendthrift spendthrift
+ spent spent
+ sperato sperato
+ sperm sperm
+ spero spero
+ sperr sperr
+ spher spher
+ sphere sphere
+ sphered sphere
+ spheres sphere
+ spherical spheric
+ sphery spheri
+ sphinx sphinx
+ spice spice
+ spiced spice
+ spicery spiceri
+ spices spice
+ spider spider
+ spiders spider
+ spied spi
+ spies spi
+ spieth spieth
+ spightfully spightfulli
+ spigot spigot
+ spill spill
+ spilling spill
+ spills spill
+ spilt spilt
+ spilth spilth
+ spin spin
+ spinii spinii
+ spinners spinner
+ spinster spinster
+ spinsters spinster
+ spire spire
+ spirit spirit
+ spirited spirit
+ spiritless spiritless
+ spirits spirit
+ spiritual spiritu
+ spiritualty spiritualti
+ spirt spirt
+ spit spit
+ spital spital
+ spite spite
+ spited spite
+ spiteful spite
+ spites spite
+ spits spit
+ spitted spit
+ spitting spit
+ splay splai
+ spleen spleen
+ spleenful spleen
+ spleens spleen
+ spleeny spleeni
+ splendour splendour
+ splenitive splenit
+ splinter splinter
+ splinters splinter
+ split split
+ splits split
+ splitted split
+ splitting split
+ spoil spoil
+ spoils spoil
+ spok spok
+ spoke spoke
+ spoken spoken
+ spokes spoke
+ spokesman spokesman
+ sponge spong
+ spongy spongi
+ spoon spoon
+ spoons spoon
+ sport sport
+ sportful sport
+ sporting sport
+ sportive sportiv
+ sports sport
+ spot spot
+ spotless spotless
+ spots spot
+ spotted spot
+ spousal spousal
+ spouse spous
+ spout spout
+ spouting spout
+ spouts spout
+ sprag sprag
+ sprang sprang
+ sprat sprat
+ sprawl sprawl
+ spray sprai
+ sprays sprai
+ spread spread
+ spreading spread
+ spreads spread
+ sprighted spright
+ sprightful spright
+ sprightly sprightli
+ sprigs sprig
+ spring spring
+ springe spring
+ springes spring
+ springeth springeth
+ springhalt springhalt
+ springing spring
+ springs spring
+ springtime springtim
+ sprinkle sprinkl
+ sprinkles sprinkl
+ sprite sprite
+ sprited sprite
+ spritely sprite
+ sprites sprite
+ spriting sprite
+ sprout sprout
+ spruce spruce
+ sprung sprung
+ spun spun
+ spur spur
+ spurio spurio
+ spurn spurn
+ spurns spurn
+ spurr spurr
+ spurrer spurrer
+ spurring spur
+ spurs spur
+ spy spy
+ spying spy
+ squabble squabbl
+ squadron squadron
+ squadrons squadron
+ squand squand
+ squar squar
+ square squar
+ squarer squarer
+ squares squar
+ squash squash
+ squeak squeak
+ squeaking squeak
+ squeal squeal
+ squealing squeal
+ squeezes squeez
+ squeezing squeez
+ squele squel
+ squier squier
+ squints squint
+ squiny squini
+ squire squir
+ squires squir
+ squirrel squirrel
+ st st
+ stab stab
+ stabb stabb
+ stabbed stab
+ stabbing stab
+ stable stabl
+ stableness stabl
+ stables stabl
+ stablish stablish
+ stablishment stablish
+ stabs stab
+ stacks stack
+ staff staff
+ stafford stafford
+ staffords stafford
+ staffordshire staffordshir
+ stag stag
+ stage stage
+ stages stage
+ stagger stagger
+ staggering stagger
+ staggers stagger
+ stags stag
+ staid staid
+ staider staider
+ stain stain
+ stained stain
+ staines stain
+ staineth staineth
+ staining stain
+ stainless stainless
+ stains stain
+ stair stair
+ stairs stair
+ stake stake
+ stakes stake
+ stale stale
+ staled stale
+ stalk stalk
+ stalking stalk
+ stalks stalk
+ stall stall
+ stalling stall
+ stalls stall
+ stamford stamford
+ stammer stammer
+ stamp stamp
+ stamped stamp
+ stamps stamp
+ stanch stanch
+ stanchless stanchless
+ stand stand
+ standard standard
+ standards standard
+ stander stander
+ standers stander
+ standest standest
+ standeth standeth
+ standing stand
+ stands stand
+ staniel staniel
+ stanley stanlei
+ stanze stanz
+ stanzo stanzo
+ stanzos stanzo
+ staple stapl
+ staples stapl
+ star star
+ stare stare
+ stared stare
+ stares stare
+ staring stare
+ starings stare
+ stark stark
+ starkly starkli
+ starlight starlight
+ starling starl
+ starr starr
+ starry starri
+ stars star
+ start start
+ started start
+ starting start
+ startingly startingli
+ startle startl
+ startles startl
+ starts start
+ starv starv
+ starve starv
+ starved starv
+ starvelackey starvelackei
+ starveling starvel
+ starveth starveth
+ starving starv
+ state state
+ statelier stateli
+ stately state
+ states state
+ statesman statesman
+ statesmen statesmen
+ statilius statiliu
+ station station
+ statist statist
+ statists statist
+ statue statu
+ statues statu
+ stature statur
+ statures statur
+ statute statut
+ statutes statut
+ stave stave
+ staves stave
+ stay stai
+ stayed stai
+ stayest stayest
+ staying stai
+ stays stai
+ stead stead
+ steaded stead
+ steadfast steadfast
+ steadier steadier
+ steads stead
+ steal steal
+ stealer stealer
+ stealers stealer
+ stealing steal
+ steals steal
+ stealth stealth
+ stealthy stealthi
+ steed steed
+ steeds steed
+ steel steel
+ steeled steel
+ steely steeli
+ steep steep
+ steeped steep
+ steeple steepl
+ steeples steepl
+ steeps steep
+ steepy steepi
+ steer steer
+ steerage steerag
+ steering steer
+ steers steer
+ stelled stell
+ stem stem
+ stemming stem
+ stench stench
+ step step
+ stepdame stepdam
+ stephano stephano
+ stephen stephen
+ stepmothers stepmoth
+ stepp stepp
+ stepping step
+ steps step
+ sterile steril
+ sterility steril
+ sterling sterl
+ stern stern
+ sternage sternag
+ sterner sterner
+ sternest sternest
+ sternness stern
+ steterat steterat
+ stew stew
+ steward steward
+ stewards steward
+ stewardship stewardship
+ stewed stew
+ stews stew
+ stick stick
+ sticking stick
+ stickler stickler
+ sticks stick
+ stiff stiff
+ stiffen stiffen
+ stiffly stiffli
+ stifle stifl
+ stifled stifl
+ stifles stifl
+ stigmatic stigmat
+ stigmatical stigmat
+ stile stile
+ still still
+ stiller stiller
+ stillest stillest
+ stillness still
+ stilly stilli
+ sting sting
+ stinging sting
+ stingless stingless
+ stings sting
+ stink stink
+ stinking stink
+ stinkingly stinkingli
+ stinks stink
+ stint stint
+ stinted stint
+ stints stint
+ stir stir
+ stirr stirr
+ stirred stir
+ stirrer stirrer
+ stirrers stirrer
+ stirreth stirreth
+ stirring stir
+ stirrup stirrup
+ stirrups stirrup
+ stirs stir
+ stitchery stitcheri
+ stitches stitch
+ stithied stithi
+ stithy stithi
+ stoccadoes stoccado
+ stoccata stoccata
+ stock stock
+ stockfish stockfish
+ stocking stock
+ stockings stock
+ stockish stockish
+ stocks stock
+ stog stog
+ stogs stog
+ stoics stoic
+ stokesly stokesli
+ stol stol
+ stole stole
+ stolen stolen
+ stolest stolest
+ stomach stomach
+ stomachers stomach
+ stomaching stomach
+ stomachs stomach
+ ston ston
+ stone stone
+ stonecutter stonecutt
+ stones stone
+ stonish stonish
+ stony stoni
+ stood stood
+ stool stool
+ stools stool
+ stoop stoop
+ stooping stoop
+ stoops stoop
+ stop stop
+ stope stope
+ stopp stopp
+ stopped stop
+ stopping stop
+ stops stop
+ stor stor
+ store store
+ storehouse storehous
+ storehouses storehous
+ stores store
+ stories stori
+ storm storm
+ stormed storm
+ storming storm
+ storms storm
+ stormy stormi
+ story stori
+ stoup stoup
+ stoups stoup
+ stout stout
+ stouter stouter
+ stoutly stoutli
+ stoutness stout
+ stover stover
+ stow stow
+ stowage stowag
+ stowed stow
+ strachy strachi
+ stragglers straggler
+ straggling straggl
+ straight straight
+ straightest straightest
+ straightway straightwai
+ strain strain
+ strained strain
+ straining strain
+ strains strain
+ strait strait
+ straited strait
+ straiter straiter
+ straitly straitli
+ straitness strait
+ straits strait
+ strand strand
+ strange strang
+ strangely strang
+ strangeness strang
+ stranger stranger
+ strangers stranger
+ strangest strangest
+ strangle strangl
+ strangled strangl
+ strangler strangler
+ strangles strangl
+ strangling strangl
+ strappado strappado
+ straps strap
+ stratagem stratagem
+ stratagems stratagem
+ stratford stratford
+ strato strato
+ straw straw
+ strawberries strawberri
+ strawberry strawberri
+ straws straw
+ strawy strawi
+ stray strai
+ straying strai
+ strays strai
+ streak streak
+ streaks streak
+ stream stream
+ streamers streamer
+ streaming stream
+ streams stream
+ streching strech
+ street street
+ streets street
+ strength strength
+ strengthen strengthen
+ strengthened strengthen
+ strengthless strengthless
+ strengths strength
+ stretch stretch
+ stretched stretch
+ stretches stretch
+ stretching stretch
+ strew strew
+ strewing strew
+ strewings strew
+ strewments strewment
+ stricken stricken
+ strict strict
+ stricter stricter
+ strictest strictest
+ strictly strictli
+ stricture strictur
+ stride stride
+ strides stride
+ striding stride
+ strife strife
+ strifes strife
+ strik strik
+ strike strike
+ strikers striker
+ strikes strike
+ strikest strikest
+ striking strike
+ string string
+ stringless stringless
+ strings string
+ strip strip
+ stripes stripe
+ stripling stripl
+ striplings stripl
+ stripp stripp
+ stripping strip
+ striv striv
+ strive strive
+ strives strive
+ striving strive
+ strok strok
+ stroke stroke
+ strokes stroke
+ strond strond
+ stronds strond
+ strong strong
+ stronger stronger
+ strongest strongest
+ strongly strongli
+ strooke strook
+ strossers strosser
+ strove strove
+ strown strown
+ stroy stroi
+ struck struck
+ strucken strucken
+ struggle struggl
+ struggles struggl
+ struggling struggl
+ strumpet strumpet
+ strumpeted strumpet
+ strumpets strumpet
+ strung strung
+ strut strut
+ struts strut
+ strutted strut
+ strutting strut
+ stubble stubbl
+ stubborn stubborn
+ stubbornest stubbornest
+ stubbornly stubbornli
+ stubbornness stubborn
+ stuck stuck
+ studded stud
+ student student
+ students student
+ studied studi
+ studies studi
+ studious studiou
+ studiously studious
+ studs stud
+ study studi
+ studying studi
+ stuff stuff
+ stuffing stuf
+ stuffs stuff
+ stumble stumbl
+ stumbled stumbl
+ stumblest stumblest
+ stumbling stumbl
+ stump stump
+ stumps stump
+ stung stung
+ stupefy stupefi
+ stupid stupid
+ stupified stupifi
+ stuprum stuprum
+ sturdy sturdi
+ sty sty
+ styga styga
+ stygian stygian
+ styl styl
+ style style
+ styx styx
+ su su
+ sub sub
+ subcontracted subcontract
+ subdu subdu
+ subdue subdu
+ subdued subdu
+ subduements subduement
+ subdues subdu
+ subduing subdu
+ subject subject
+ subjected subject
+ subjection subject
+ subjects subject
+ submerg submerg
+ submission submiss
+ submissive submiss
+ submit submit
+ submits submit
+ submitting submit
+ suborn suborn
+ subornation suborn
+ suborned suborn
+ subscrib subscrib
+ subscribe subscrib
+ subscribed subscrib
+ subscribes subscrib
+ subscription subscript
+ subsequent subsequ
+ subsidies subsidi
+ subsidy subsidi
+ subsist subsist
+ subsisting subsist
+ substance substanc
+ substances substanc
+ substantial substanti
+ substitute substitut
+ substituted substitut
+ substitutes substitut
+ substitution substitut
+ subtile subtil
+ subtilly subtilli
+ subtle subtl
+ subtleties subtleti
+ subtlety subtleti
+ subtly subtli
+ subtractors subtractor
+ suburbs suburb
+ subversion subvers
+ subverts subvert
+ succedant succed
+ succeed succe
+ succeeded succeed
+ succeeders succeed
+ succeeding succeed
+ succeeds succe
+ success success
+ successantly successantli
+ successes success
+ successful success
+ successfully successfulli
+ succession success
+ successive success
+ successively success
+ successor successor
+ successors successor
+ succour succour
+ succours succour
+ such such
+ suck suck
+ sucker sucker
+ suckers sucker
+ sucking suck
+ suckle suckl
+ sucks suck
+ sudden sudden
+ suddenly suddenli
+ sue sue
+ sued su
+ suerly suerli
+ sues sue
+ sueth sueth
+ suff suff
+ suffer suffer
+ sufferance suffer
+ sufferances suffer
+ suffered suffer
+ suffering suffer
+ suffers suffer
+ suffic suffic
+ suffice suffic
+ sufficed suffic
+ suffices suffic
+ sufficeth sufficeth
+ sufficiency suffici
+ sufficient suffici
+ sufficiently suffici
+ sufficing suffic
+ sufficit sufficit
+ suffigance suffig
+ suffocate suffoc
+ suffocating suffoc
+ suffocation suffoc
+ suffolk suffolk
+ suffrage suffrag
+ suffrages suffrag
+ sug sug
+ sugar sugar
+ sugarsop sugarsop
+ suggest suggest
+ suggested suggest
+ suggesting suggest
+ suggestion suggest
+ suggestions suggest
+ suggests suggest
+ suis sui
+ suit suit
+ suitable suitabl
+ suited suit
+ suiting suit
+ suitor suitor
+ suitors suitor
+ suits suit
+ suivez suivez
+ sullen sullen
+ sullens sullen
+ sullied sulli
+ sullies sulli
+ sully sulli
+ sulph sulph
+ sulpherous sulpher
+ sulphur sulphur
+ sulphurous sulphur
+ sultan sultan
+ sultry sultri
+ sum sum
+ sumless sumless
+ summ summ
+ summa summa
+ summary summari
+ summer summer
+ summers summer
+ summit summit
+ summon summon
+ summoners summon
+ summons summon
+ sumpter sumpter
+ sumptuous sumptuou
+ sumptuously sumptuous
+ sums sum
+ sun sun
+ sunbeams sunbeam
+ sunburning sunburn
+ sunburnt sunburnt
+ sund sund
+ sunday sundai
+ sundays sundai
+ sunder sunder
+ sunders sunder
+ sundry sundri
+ sung sung
+ sunk sunk
+ sunken sunken
+ sunny sunni
+ sunrising sunris
+ suns sun
+ sunset sunset
+ sunshine sunshin
+ sup sup
+ super super
+ superficial superfici
+ superficially superfici
+ superfluity superflu
+ superfluous superflu
+ superfluously superflu
+ superflux superflux
+ superior superior
+ supernal supern
+ supernatural supernatur
+ superpraise superprais
+ superscript superscript
+ superscription superscript
+ superserviceable superservic
+ superstition superstit
+ superstitious superstiti
+ superstitiously superstiti
+ supersubtle supersubtl
+ supervise supervis
+ supervisor supervisor
+ supp supp
+ supper supper
+ suppers supper
+ suppertime suppertim
+ supping sup
+ supplant supplant
+ supple suppl
+ suppler suppler
+ suppliance supplianc
+ suppliant suppliant
+ suppliants suppliant
+ supplicant supplic
+ supplication supplic
+ supplications supplic
+ supplie suppli
+ supplied suppli
+ supplies suppli
+ suppliest suppliest
+ supply suppli
+ supplyant supplyant
+ supplying suppli
+ supplyment supplyment
+ support support
+ supportable support
+ supportance support
+ supported support
+ supporter support
+ supporters support
+ supporting support
+ supportor supportor
+ suppos suppo
+ supposal suppos
+ suppose suppos
+ supposed suppos
+ supposes suppos
+ supposest supposest
+ supposing suppos
+ supposition supposit
+ suppress suppress
+ suppressed suppress
+ suppresseth suppresseth
+ supremacy supremaci
+ supreme suprem
+ sups sup
+ sur sur
+ surance suranc
+ surcease surceas
+ surd surd
+ sure sure
+ surecard surecard
+ surely sure
+ surer surer
+ surest surest
+ sureties sureti
+ surety sureti
+ surfeit surfeit
+ surfeited surfeit
+ surfeiter surfeit
+ surfeiting surfeit
+ surfeits surfeit
+ surge surg
+ surgeon surgeon
+ surgeons surgeon
+ surgere surger
+ surgery surgeri
+ surges surg
+ surly surli
+ surmis surmi
+ surmise surmis
+ surmised surmis
+ surmises surmis
+ surmount surmount
+ surmounted surmount
+ surmounts surmount
+ surnam surnam
+ surname surnam
+ surnamed surnam
+ surpasseth surpasseth
+ surpassing surpass
+ surplice surplic
+ surplus surplu
+ surpris surpri
+ surprise surpris
+ surprised surpris
+ surrender surrend
+ surrey surrei
+ surreys surrei
+ survey survei
+ surveyest surveyest
+ surveying survei
+ surveyor surveyor
+ surveyors surveyor
+ surveys survei
+ survive surviv
+ survives surviv
+ survivor survivor
+ susan susan
+ suspect suspect
+ suspected suspect
+ suspecting suspect
+ suspects suspect
+ suspend suspend
+ suspense suspens
+ suspicion suspicion
+ suspicions suspicion
+ suspicious suspici
+ suspiration suspir
+ suspire suspir
+ sust sust
+ sustain sustain
+ sustaining sustain
+ sutler sutler
+ sutton sutton
+ suum suum
+ swabber swabber
+ swaddling swaddl
+ swag swag
+ swagg swagg
+ swagger swagger
+ swaggerer swagger
+ swaggerers swagger
+ swaggering swagger
+ swain swain
+ swains swain
+ swallow swallow
+ swallowed swallow
+ swallowing swallow
+ swallows swallow
+ swam swam
+ swan swan
+ swans swan
+ sward sward
+ sware sware
+ swarm swarm
+ swarming swarm
+ swart swart
+ swarth swarth
+ swarths swarth
+ swarthy swarthi
+ swashers swasher
+ swashing swash
+ swath swath
+ swathing swath
+ swathling swathl
+ sway swai
+ swaying swai
+ sways swai
+ swear swear
+ swearer swearer
+ swearers swearer
+ swearest swearest
+ swearing swear
+ swearings swear
+ swears swear
+ sweat sweat
+ sweaten sweaten
+ sweating sweat
+ sweats sweat
+ sweaty sweati
+ sweep sweep
+ sweepers sweeper
+ sweeps sweep
+ sweet sweet
+ sweeten sweeten
+ sweetens sweeten
+ sweeter sweeter
+ sweetest sweetest
+ sweetheart sweetheart
+ sweeting sweet
+ sweetly sweetli
+ sweetmeats sweetmeat
+ sweetness sweet
+ sweets sweet
+ swell swell
+ swelling swell
+ swellings swell
+ swells swell
+ swelter swelter
+ sweno sweno
+ swept swept
+ swerve swerv
+ swerver swerver
+ swerving swerv
+ swift swift
+ swifter swifter
+ swiftest swiftest
+ swiftly swiftli
+ swiftness swift
+ swill swill
+ swills swill
+ swim swim
+ swimmer swimmer
+ swimmers swimmer
+ swimming swim
+ swims swim
+ swine swine
+ swineherds swineherd
+ swing swing
+ swinge swing
+ swinish swinish
+ swinstead swinstead
+ switches switch
+ swits swit
+ switzers switzer
+ swol swol
+ swoll swoll
+ swoln swoln
+ swoon swoon
+ swooned swoon
+ swooning swoon
+ swoons swoon
+ swoop swoop
+ swoopstake swoopstak
+ swor swor
+ sword sword
+ sworder sworder
+ swords sword
+ swore swore
+ sworn sworn
+ swounded swound
+ swounds swound
+ swum swum
+ swung swung
+ sy sy
+ sycamore sycamor
+ sycorax sycorax
+ sylla sylla
+ syllable syllabl
+ syllables syllabl
+ syllogism syllog
+ symbols symbol
+ sympathise sympathis
+ sympathiz sympathiz
+ sympathize sympath
+ sympathized sympath
+ sympathy sympathi
+ synagogue synagogu
+ synod synod
+ synods synod
+ syracuse syracus
+ syracusian syracusian
+ syracusians syracusian
+ syria syria
+ syrups syrup
+ t t
+ ta ta
+ taber taber
+ table tabl
+ tabled tabl
+ tables tabl
+ tablet tablet
+ tabor tabor
+ taborer tabor
+ tabors tabor
+ tabourines tabourin
+ taciturnity taciturn
+ tack tack
+ tackle tackl
+ tackled tackl
+ tackles tackl
+ tackling tackl
+ tacklings tackl
+ taddle taddl
+ tadpole tadpol
+ taffeta taffeta
+ taffety taffeti
+ tag tag
+ tagrag tagrag
+ tah tah
+ tail tail
+ tailor tailor
+ tailors tailor
+ tails tail
+ taint taint
+ tainted taint
+ tainting taint
+ taints taint
+ tainture taintur
+ tak tak
+ take take
+ taken taken
+ taker taker
+ takes take
+ takest takest
+ taketh taketh
+ taking take
+ tal tal
+ talbot talbot
+ talbotites talbotit
+ talbots talbot
+ tale tale
+ talent talent
+ talents talent
+ taleporter taleport
+ tales tale
+ talk talk
+ talked talk
+ talker talker
+ talkers talker
+ talkest talkest
+ talking talk
+ talks talk
+ tall tall
+ taller taller
+ tallest tallest
+ tallies talli
+ tallow tallow
+ tally talli
+ talons talon
+ tam tam
+ tambourines tambourin
+ tame tame
+ tamed tame
+ tamely tame
+ tameness tame
+ tamer tamer
+ tames tame
+ taming tame
+ tamora tamora
+ tamworth tamworth
+ tan tan
+ tang tang
+ tangle tangl
+ tangled tangl
+ tank tank
+ tanlings tanl
+ tann tann
+ tanned tan
+ tanner tanner
+ tanquam tanquam
+ tanta tanta
+ tantaene tantaen
+ tap tap
+ tape tape
+ taper taper
+ tapers taper
+ tapestries tapestri
+ tapestry tapestri
+ taphouse taphous
+ tapp tapp
+ tapster tapster
+ tapsters tapster
+ tar tar
+ tardied tardi
+ tardily tardili
+ tardiness tardi
+ tardy tardi
+ tarentum tarentum
+ targe targ
+ targes targ
+ target target
+ targets target
+ tarpeian tarpeian
+ tarquin tarquin
+ tarquins tarquin
+ tarr tarr
+ tarre tarr
+ tarriance tarrianc
+ tarried tarri
+ tarries tarri
+ tarry tarri
+ tarrying tarri
+ tart tart
+ tartar tartar
+ tartars tartar
+ tartly tartli
+ tartness tart
+ task task
+ tasker tasker
+ tasking task
+ tasks task
+ tassel tassel
+ taste tast
+ tasted tast
+ tastes tast
+ tasting tast
+ tatt tatt
+ tatter tatter
+ tattered tatter
+ tatters tatter
+ tattle tattl
+ tattling tattl
+ tattlings tattl
+ taught taught
+ taunt taunt
+ taunted taunt
+ taunting taunt
+ tauntingly tauntingli
+ taunts taunt
+ taurus tauru
+ tavern tavern
+ taverns tavern
+ tavy tavi
+ tawdry tawdri
+ tawny tawni
+ tax tax
+ taxation taxat
+ taxations taxat
+ taxes tax
+ taxing tax
+ tc tc
+ te te
+ teach teach
+ teacher teacher
+ teachers teacher
+ teaches teach
+ teachest teachest
+ teacheth teacheth
+ teaching teach
+ team team
+ tear tear
+ tearful tear
+ tearing tear
+ tears tear
+ tearsheet tearsheet
+ teat teat
+ tedious tediou
+ tediously tedious
+ tediousness tedious
+ teem teem
+ teeming teem
+ teems teem
+ teen teen
+ teeth teeth
+ teipsum teipsum
+ telamon telamon
+ telamonius telamoniu
+ tell tell
+ teller teller
+ telling tell
+ tells tell
+ tellus tellu
+ temp temp
+ temper temper
+ temperality temper
+ temperance temper
+ temperate temper
+ temperately temper
+ tempers temper
+ tempest tempest
+ tempests tempest
+ tempestuous tempestu
+ temple templ
+ temples templ
+ temporal tempor
+ temporary temporari
+ temporiz temporiz
+ temporize tempor
+ temporizer tempor
+ temps temp
+ tempt tempt
+ temptation temptat
+ temptations temptat
+ tempted tempt
+ tempter tempter
+ tempters tempter
+ tempteth tempteth
+ tempting tempt
+ tempts tempt
+ ten ten
+ tenable tenabl
+ tenant tenant
+ tenantius tenantiu
+ tenantless tenantless
+ tenants tenant
+ tench tench
+ tend tend
+ tendance tendanc
+ tended tend
+ tender tender
+ tendered tender
+ tenderly tenderli
+ tenderness tender
+ tenders tender
+ tending tend
+ tends tend
+ tenedos tenedo
+ tenement tenement
+ tenements tenement
+ tenfold tenfold
+ tennis tenni
+ tenour tenour
+ tenours tenour
+ tens ten
+ tent tent
+ tented tent
+ tenth tenth
+ tenths tenth
+ tents tent
+ tenure tenur
+ tenures tenur
+ tercel tercel
+ tereus tereu
+ term term
+ termagant termag
+ termed term
+ terminations termin
+ termless termless
+ terms term
+ terra terra
+ terrace terrac
+ terram terram
+ terras terra
+ terre terr
+ terrene terren
+ terrestrial terrestri
+ terrible terribl
+ terribly terribl
+ territories territori
+ territory territori
+ terror terror
+ terrors terror
+ tertian tertian
+ tertio tertio
+ test test
+ testament testament
+ tested test
+ tester tester
+ testern testern
+ testify testifi
+ testimonied testimoni
+ testimonies testimoni
+ testimony testimoni
+ testiness testi
+ testril testril
+ testy testi
+ tetchy tetchi
+ tether tether
+ tetter tetter
+ tevil tevil
+ tewksbury tewksburi
+ text text
+ tgv tgv
+ th th
+ thaes thae
+ thames thame
+ than than
+ thane thane
+ thanes thane
+ thank thank
+ thanked thank
+ thankful thank
+ thankfully thankfulli
+ thankfulness thank
+ thanking thank
+ thankings thank
+ thankless thankless
+ thanks thank
+ thanksgiving thanksgiv
+ thasos thaso
+ that that
+ thatch thatch
+ thaw thaw
+ thawing thaw
+ thaws thaw
+ the the
+ theatre theatr
+ theban theban
+ thebes thebe
+ thee thee
+ theft theft
+ thefts theft
+ thein thein
+ their their
+ theirs their
+ theise theis
+ them them
+ theme theme
+ themes theme
+ themselves themselv
+ then then
+ thence thenc
+ thenceforth thenceforth
+ theoric theoric
+ there there
+ thereabout thereabout
+ thereabouts thereabout
+ thereafter thereaft
+ thereat thereat
+ thereby therebi
+ therefore therefor
+ therein therein
+ thereof thereof
+ thereon thereon
+ thereto thereto
+ thereunto thereunto
+ thereupon thereupon
+ therewith therewith
+ therewithal therewith
+ thersites thersit
+ these these
+ theseus theseu
+ thessalian thessalian
+ thessaly thessali
+ thetis theti
+ thews thew
+ they thei
+ thick thick
+ thicken thicken
+ thickens thicken
+ thicker thicker
+ thickest thickest
+ thicket thicket
+ thickskin thickskin
+ thief thief
+ thievery thieveri
+ thieves thiev
+ thievish thievish
+ thigh thigh
+ thighs thigh
+ thimble thimbl
+ thimbles thimbl
+ thin thin
+ thine thine
+ thing thing
+ things thing
+ think think
+ thinkest thinkest
+ thinking think
+ thinkings think
+ thinks think
+ thinkst thinkst
+ thinly thinli
+ third third
+ thirdly thirdli
+ thirds third
+ thirst thirst
+ thirsting thirst
+ thirsts thirst
+ thirsty thirsti
+ thirteen thirteen
+ thirties thirti
+ thirtieth thirtieth
+ thirty thirti
+ this thi
+ thisby thisbi
+ thisne thisn
+ thistle thistl
+ thistles thistl
+ thither thither
+ thitherward thitherward
+ thoas thoa
+ thomas thoma
+ thorn thorn
+ thorns thorn
+ thorny thorni
+ thorough thorough
+ thoroughly thoroughli
+ those those
+ thou thou
+ though though
+ thought thought
+ thoughtful thought
+ thoughts thought
+ thousand thousand
+ thousands thousand
+ thracian thracian
+ thraldom thraldom
+ thrall thrall
+ thralled thrall
+ thralls thrall
+ thrash thrash
+ thrasonical thrason
+ thread thread
+ threadbare threadbar
+ threaden threaden
+ threading thread
+ threat threat
+ threaten threaten
+ threatening threaten
+ threatens threaten
+ threatest threatest
+ threats threat
+ three three
+ threefold threefold
+ threepence threepenc
+ threepile threepil
+ threes three
+ threescore threescor
+ thresher thresher
+ threshold threshold
+ threw threw
+ thrice thrice
+ thrift thrift
+ thriftless thriftless
+ thrifts thrift
+ thrifty thrifti
+ thrill thrill
+ thrilling thrill
+ thrills thrill
+ thrive thrive
+ thrived thrive
+ thrivers thriver
+ thrives thrive
+ thriving thrive
+ throat throat
+ throats throat
+ throbbing throb
+ throbs throb
+ throca throca
+ throe throe
+ throes throe
+ thromuldo thromuldo
+ thron thron
+ throne throne
+ throned throne
+ thrones throne
+ throng throng
+ thronging throng
+ throngs throng
+ throstle throstl
+ throttle throttl
+ through through
+ throughfare throughfar
+ throughfares throughfar
+ throughly throughli
+ throughout throughout
+ throw throw
+ thrower thrower
+ throwest throwest
+ throwing throw
+ thrown thrown
+ throws throw
+ thrum thrum
+ thrumm thrumm
+ thrush thrush
+ thrust thrust
+ thrusteth thrusteth
+ thrusting thrust
+ thrusts thrust
+ thumb thumb
+ thumbs thumb
+ thump thump
+ thund thund
+ thunder thunder
+ thunderbolt thunderbolt
+ thunderbolts thunderbolt
+ thunderer thunder
+ thunders thunder
+ thunderstone thunderston
+ thunderstroke thunderstrok
+ thurio thurio
+ thursday thursdai
+ thus thu
+ thwack thwack
+ thwart thwart
+ thwarted thwart
+ thwarting thwart
+ thwartings thwart
+ thy thy
+ thyme thyme
+ thymus thymu
+ thyreus thyreu
+ thyself thyself
+ ti ti
+ tib tib
+ tiber tiber
+ tiberio tiberio
+ tibey tibei
+ ticed tice
+ tick tick
+ tickl tickl
+ tickle tickl
+ tickled tickl
+ tickles tickl
+ tickling tickl
+ ticklish ticklish
+ tiddle tiddl
+ tide tide
+ tides tide
+ tidings tide
+ tidy tidi
+ tie tie
+ tied ti
+ ties ti
+ tiff tiff
+ tiger tiger
+ tigers tiger
+ tight tight
+ tightly tightli
+ tike tike
+ til til
+ tile tile
+ till till
+ tillage tillag
+ tilly tilli
+ tilt tilt
+ tilter tilter
+ tilth tilth
+ tilting tilt
+ tilts tilt
+ tiltyard tiltyard
+ tim tim
+ timandra timandra
+ timber timber
+ time time
+ timeless timeless
+ timelier timeli
+ timely time
+ times time
+ timon timon
+ timor timor
+ timorous timor
+ timorously timor
+ tinct tinct
+ tincture tinctur
+ tinctures tinctur
+ tinder tinder
+ tingling tingl
+ tinker tinker
+ tinkers tinker
+ tinsel tinsel
+ tiny tini
+ tip tip
+ tipp tipp
+ tippling tippl
+ tips tip
+ tipsy tipsi
+ tiptoe tipto
+ tir tir
+ tire tire
+ tired tire
+ tires tire
+ tirest tirest
+ tiring tire
+ tirra tirra
+ tirrits tirrit
+ tis ti
+ tish tish
+ tisick tisick
+ tissue tissu
+ titan titan
+ titania titania
+ tithe tith
+ tithed tith
+ tithing tith
+ titinius titiniu
+ title titl
+ titled titl
+ titleless titleless
+ titles titl
+ tittle tittl
+ tittles tittl
+ titular titular
+ titus titu
+ tn tn
+ to to
+ toad toad
+ toads toad
+ toadstool toadstool
+ toast toast
+ toasted toast
+ toasting toast
+ toasts toast
+ toaze toaz
+ toby tobi
+ tock tock
+ tod tod
+ today todai
+ todpole todpol
+ tods tod
+ toe toe
+ toes toe
+ tofore tofor
+ toge toge
+ toged toge
+ together togeth
+ toil toil
+ toiled toil
+ toiling toil
+ toils toil
+ token token
+ tokens token
+ told told
+ toledo toledo
+ tolerable toler
+ toll toll
+ tolling toll
+ tom tom
+ tomb tomb
+ tombe tomb
+ tombed tomb
+ tombless tombless
+ tomboys tomboi
+ tombs tomb
+ tomorrow tomorrow
+ tomyris tomyri
+ ton ton
+ tongs tong
+ tongu tongu
+ tongue tongu
+ tongued tongu
+ tongueless tongueless
+ tongues tongu
+ tonight tonight
+ too too
+ took took
+ tool tool
+ tools tool
+ tooth tooth
+ toothache toothach
+ toothpick toothpick
+ toothpicker toothpick
+ top top
+ topas topa
+ topful top
+ topgallant topgal
+ topless topless
+ topmast topmast
+ topp topp
+ topping top
+ topple toppl
+ topples toppl
+ tops top
+ topsail topsail
+ topsy topsi
+ torch torch
+ torchbearer torchbear
+ torchbearers torchbear
+ torcher torcher
+ torches torch
+ torchlight torchlight
+ tore tore
+ torment torment
+ tormenta tormenta
+ tormente torment
+ tormented torment
+ tormenting torment
+ tormentors tormentor
+ torments torment
+ torn torn
+ torrent torrent
+ tortive tortiv
+ tortoise tortois
+ tortur tortur
+ torture tortur
+ tortured tortur
+ torturer tortur
+ torturers tortur
+ tortures tortur
+ torturest torturest
+ torturing tortur
+ toryne toryn
+ toss toss
+ tossed toss
+ tosseth tosseth
+ tossing toss
+ tot tot
+ total total
+ totally total
+ tott tott
+ tottered totter
+ totters totter
+ tou tou
+ touch touch
+ touched touch
+ touches touch
+ toucheth toucheth
+ touching touch
+ touchstone touchston
+ tough tough
+ tougher tougher
+ toughness tough
+ touraine tourain
+ tournaments tournament
+ tours tour
+ tous tou
+ tout tout
+ touze touz
+ tow tow
+ toward toward
+ towardly towardli
+ towards toward
+ tower tower
+ towering tower
+ towers tower
+ town town
+ towns town
+ township township
+ townsman townsman
+ townsmen townsmen
+ towton towton
+ toy toi
+ toys toi
+ trace trace
+ traces trace
+ track track
+ tract tract
+ tractable tractabl
+ trade trade
+ traded trade
+ traders trader
+ trades trade
+ tradesman tradesman
+ tradesmen tradesmen
+ trading trade
+ tradition tradit
+ traditional tradit
+ traduc traduc
+ traduced traduc
+ traducement traduc
+ traffic traffic
+ traffickers traffick
+ traffics traffic
+ tragedian tragedian
+ tragedians tragedian
+ tragedies tragedi
+ tragedy tragedi
+ tragic tragic
+ tragical tragic
+ trail trail
+ train train
+ trained train
+ training train
+ trains train
+ trait trait
+ traitor traitor
+ traitorly traitorli
+ traitorous traitor
+ traitorously traitor
+ traitors traitor
+ traitress traitress
+ traject traject
+ trammel trammel
+ trample trampl
+ trampled trampl
+ trampling trampl
+ tranc tranc
+ trance tranc
+ tranio tranio
+ tranquil tranquil
+ tranquillity tranquil
+ transcendence transcend
+ transcends transcend
+ transferred transfer
+ transfigur transfigur
+ transfix transfix
+ transform transform
+ transformation transform
+ transformations transform
+ transformed transform
+ transgress transgress
+ transgresses transgress
+ transgressing transgress
+ transgression transgress
+ translate translat
+ translated translat
+ translates translat
+ translation translat
+ transmigrates transmigr
+ transmutation transmut
+ transparent transpar
+ transport transport
+ transportance transport
+ transported transport
+ transporting transport
+ transports transport
+ transpose transpos
+ transshape transshap
+ trap trap
+ trapp trapp
+ trappings trap
+ traps trap
+ trash trash
+ travail travail
+ travails travail
+ travel travel
+ traveler travel
+ traveling travel
+ travell travel
+ travelled travel
+ traveller travel
+ travellers travel
+ travellest travellest
+ travelling travel
+ travels travel
+ travers traver
+ traverse travers
+ tray trai
+ treacherous treacher
+ treacherously treacher
+ treachers treacher
+ treachery treacheri
+ tread tread
+ treading tread
+ treads tread
+ treason treason
+ treasonable treason
+ treasonous treason
+ treasons treason
+ treasure treasur
+ treasurer treasur
+ treasures treasur
+ treasuries treasuri
+ treasury treasuri
+ treat treat
+ treaties treati
+ treatise treatis
+ treats treat
+ treaty treati
+ treble trebl
+ trebled trebl
+ trebles trebl
+ trebonius treboniu
+ tree tree
+ trees tree
+ tremble trembl
+ trembled trembl
+ trembles trembl
+ tremblest tremblest
+ trembling trembl
+ tremblingly tremblingli
+ tremor tremor
+ trempling trempl
+ trench trench
+ trenchant trenchant
+ trenched trench
+ trencher trencher
+ trenchering trencher
+ trencherman trencherman
+ trenchers trencher
+ trenches trench
+ trenching trench
+ trent trent
+ tres tre
+ trespass trespass
+ trespasses trespass
+ tressel tressel
+ tresses tress
+ treys trei
+ trial trial
+ trials trial
+ trib trib
+ tribe tribe
+ tribes tribe
+ tribulation tribul
+ tribunal tribun
+ tribune tribun
+ tribunes tribun
+ tributaries tributari
+ tributary tributari
+ tribute tribut
+ tributes tribut
+ trice trice
+ trick trick
+ tricking trick
+ trickling trickl
+ tricks trick
+ tricksy tricksi
+ trident trident
+ tried tri
+ trier trier
+ trifle trifl
+ trifled trifl
+ trifler trifler
+ trifles trifl
+ trifling trifl
+ trigon trigon
+ trill trill
+ trim trim
+ trimly trimli
+ trimm trimm
+ trimmed trim
+ trimming trim
+ trims trim
+ trinculo trinculo
+ trinculos trinculo
+ trinkets trinket
+ trip trip
+ tripartite tripartit
+ tripe tripe
+ triple tripl
+ triplex triplex
+ tripoli tripoli
+ tripolis tripoli
+ tripp tripp
+ tripping trip
+ trippingly trippingli
+ trips trip
+ tristful trist
+ triton triton
+ triumph triumph
+ triumphant triumphant
+ triumphantly triumphantli
+ triumpher triumpher
+ triumphers triumpher
+ triumphing triumph
+ triumphs triumph
+ triumvir triumvir
+ triumvirate triumvir
+ triumvirs triumvir
+ triumviry triumviri
+ trivial trivial
+ troat troat
+ trod trod
+ trodden trodden
+ troiant troiant
+ troien troien
+ troilus troilu
+ troiluses troilus
+ trojan trojan
+ trojans trojan
+ troll troll
+ tromperies tromperi
+ trompet trompet
+ troop troop
+ trooping troop
+ troops troop
+ trop trop
+ trophies trophi
+ trophy trophi
+ tropically tropic
+ trot trot
+ troth troth
+ trothed troth
+ troths troth
+ trots trot
+ trotting trot
+ trouble troubl
+ troubled troubl
+ troubler troubler
+ troubles troubl
+ troublesome troublesom
+ troublest troublest
+ troublous troublou
+ trough trough
+ trout trout
+ trouts trout
+ trovato trovato
+ trow trow
+ trowel trowel
+ trowest trowest
+ troy troi
+ troyan troyan
+ troyans troyan
+ truant truant
+ truce truce
+ truckle truckl
+ trudge trudg
+ true true
+ trueborn trueborn
+ truepenny truepenni
+ truer truer
+ truest truest
+ truie truie
+ trull trull
+ trulls trull
+ truly truli
+ trump trump
+ trumpery trumperi
+ trumpet trumpet
+ trumpeter trumpet
+ trumpeters trumpet
+ trumpets trumpet
+ truncheon truncheon
+ truncheoners truncheon
+ trundle trundl
+ trunk trunk
+ trunks trunk
+ trust trust
+ trusted trust
+ truster truster
+ trusters truster
+ trusting trust
+ trusts trust
+ trusty trusti
+ truth truth
+ truths truth
+ try try
+ ts ts
+ tu tu
+ tuae tuae
+ tub tub
+ tubal tubal
+ tubs tub
+ tuck tuck
+ tucket tucket
+ tuesday tuesdai
+ tuft tuft
+ tufts tuft
+ tug tug
+ tugg tugg
+ tugging tug
+ tuition tuition
+ tullus tullu
+ tully tulli
+ tumble tumbl
+ tumbled tumbl
+ tumbler tumbler
+ tumbling tumbl
+ tumult tumult
+ tumultuous tumultu
+ tun tun
+ tune tune
+ tuneable tuneabl
+ tuned tune
+ tuners tuner
+ tunes tune
+ tunis tuni
+ tuns tun
+ tupping tup
+ turban turban
+ turbans turban
+ turbulence turbul
+ turbulent turbul
+ turd turd
+ turf turf
+ turfy turfi
+ turk turk
+ turkey turkei
+ turkeys turkei
+ turkish turkish
+ turks turk
+ turlygod turlygod
+ turmoil turmoil
+ turmoiled turmoil
+ turn turn
+ turnbull turnbul
+ turncoat turncoat
+ turncoats turncoat
+ turned turn
+ turneth turneth
+ turning turn
+ turnips turnip
+ turns turn
+ turph turph
+ turpitude turpitud
+ turquoise turquois
+ turret turret
+ turrets turret
+ turtle turtl
+ turtles turtl
+ turvy turvi
+ tuscan tuscan
+ tush tush
+ tut tut
+ tutor tutor
+ tutored tutor
+ tutors tutor
+ tutto tutto
+ twain twain
+ twang twang
+ twangling twangl
+ twas twa
+ tway twai
+ tweaks tweak
+ tween tween
+ twelfth twelfth
+ twelve twelv
+ twelvemonth twelvemonth
+ twentieth twentieth
+ twenty twenti
+ twere twere
+ twice twice
+ twig twig
+ twiggen twiggen
+ twigs twig
+ twilight twilight
+ twill twill
+ twilled twill
+ twin twin
+ twine twine
+ twink twink
+ twinkle twinkl
+ twinkled twinkl
+ twinkling twinkl
+ twinn twinn
+ twins twin
+ twire twire
+ twist twist
+ twisted twist
+ twit twit
+ twits twit
+ twitting twit
+ twixt twixt
+ two two
+ twofold twofold
+ twopence twopenc
+ twopences twopenc
+ twos two
+ twould twould
+ tyb tyb
+ tybalt tybalt
+ tybalts tybalt
+ tyburn tyburn
+ tying ty
+ tyke tyke
+ tymbria tymbria
+ type type
+ types type
+ typhon typhon
+ tyrannical tyrann
+ tyrannically tyrann
+ tyrannize tyrann
+ tyrannous tyrann
+ tyranny tyranni
+ tyrant tyrant
+ tyrants tyrant
+ tyrian tyrian
+ tyrrel tyrrel
+ u u
+ ubique ubiqu
+ udders udder
+ udge udg
+ uds ud
+ uglier uglier
+ ugliest ugliest
+ ugly ugli
+ ulcer ulcer
+ ulcerous ulcer
+ ulysses ulyss
+ um um
+ umber umber
+ umbra umbra
+ umbrage umbrag
+ umfrevile umfrevil
+ umpire umpir
+ umpires umpir
+ un un
+ unable unabl
+ unaccommodated unaccommod
+ unaccompanied unaccompani
+ unaccustom unaccustom
+ unaching unach
+ unacquainted unacquaint
+ unactive unact
+ unadvis unadvi
+ unadvised unadvis
+ unadvisedly unadvisedli
+ unagreeable unagre
+ unanel unanel
+ unanswer unansw
+ unappeas unappea
+ unapproved unapprov
+ unapt unapt
+ unaptness unapt
+ unarm unarm
+ unarmed unarm
+ unarms unarm
+ unassail unassail
+ unassailable unassail
+ unattainted unattaint
+ unattempted unattempt
+ unattended unattend
+ unauspicious unauspici
+ unauthorized unauthor
+ unavoided unavoid
+ unawares unawar
+ unback unback
+ unbak unbak
+ unbanded unband
+ unbar unbar
+ unbarb unbarb
+ unbashful unbash
+ unbated unbat
+ unbatter unbatt
+ unbecoming unbecom
+ unbefitting unbefit
+ unbegot unbegot
+ unbegotten unbegotten
+ unbelieved unbeliev
+ unbend unbend
+ unbent unbent
+ unbewail unbewail
+ unbid unbid
+ unbidden unbidden
+ unbind unbind
+ unbinds unbind
+ unbitted unbit
+ unbless unbless
+ unblest unblest
+ unbloodied unbloodi
+ unblown unblown
+ unbodied unbodi
+ unbolt unbolt
+ unbolted unbolt
+ unbonneted unbonnet
+ unbookish unbookish
+ unborn unborn
+ unbosom unbosom
+ unbound unbound
+ unbounded unbound
+ unbow unbow
+ unbowed unbow
+ unbrac unbrac
+ unbraced unbrac
+ unbraided unbraid
+ unbreathed unbreath
+ unbred unbr
+ unbreech unbreech
+ unbridled unbridl
+ unbroke unbrok
+ unbruis unbrui
+ unbruised unbruis
+ unbuckle unbuckl
+ unbuckles unbuckl
+ unbuckling unbuckl
+ unbuild unbuild
+ unburden unburden
+ unburdens unburden
+ unburied unburi
+ unburnt unburnt
+ unburthen unburthen
+ unbutton unbutton
+ unbuttoning unbutton
+ uncapable uncap
+ uncape uncap
+ uncase uncas
+ uncasing uncas
+ uncaught uncaught
+ uncertain uncertain
+ uncertainty uncertainti
+ unchain unchain
+ unchanging unchang
+ uncharge uncharg
+ uncharged uncharg
+ uncharitably uncharit
+ unchary unchari
+ unchaste unchast
+ uncheck uncheck
+ unchilded unchild
+ uncivil uncivil
+ unclaim unclaim
+ unclasp unclasp
+ uncle uncl
+ unclean unclean
+ uncleanliness uncleanli
+ uncleanly uncleanli
+ uncleanness unclean
+ uncles uncl
+ unclew unclew
+ unclog unclog
+ uncoined uncoin
+ uncolted uncolt
+ uncomeliness uncomeli
+ uncomfortable uncomfort
+ uncompassionate uncompassion
+ uncomprehensive uncomprehens
+ unconfinable unconfin
+ unconfirm unconfirm
+ unconfirmed unconfirm
+ unconquer unconqu
+ unconquered unconqu
+ unconsidered unconsid
+ unconstant unconst
+ unconstrain unconstrain
+ unconstrained unconstrain
+ uncontemn uncontemn
+ uncontroll uncontrol
+ uncorrected uncorrect
+ uncounted uncount
+ uncouple uncoupl
+ uncourteous uncourt
+ uncouth uncouth
+ uncover uncov
+ uncovered uncov
+ uncropped uncrop
+ uncross uncross
+ uncrown uncrown
+ unction unction
+ unctuous unctuou
+ uncuckolded uncuckold
+ uncurable uncur
+ uncurbable uncurb
+ uncurbed uncurb
+ uncurls uncurl
+ uncurrent uncurr
+ uncurse uncurs
+ undaunted undaunt
+ undeaf undeaf
+ undeck undeck
+ undeeded undeed
+ under under
+ underbearing underbear
+ underborne underborn
+ undercrest undercrest
+ underfoot underfoot
+ undergo undergo
+ undergoes undergo
+ undergoing undergo
+ undergone undergon
+ underground underground
+ underhand underhand
+ underlings underl
+ undermine undermin
+ underminers undermin
+ underneath underneath
+ underprizing underpr
+ underprop underprop
+ understand understand
+ understandeth understandeth
+ understanding understand
+ understandings understand
+ understands understand
+ understood understood
+ underta underta
+ undertake undertak
+ undertakeing undertak
+ undertaker undertak
+ undertakes undertak
+ undertaking undertak
+ undertakings undertak
+ undertook undertook
+ undervalu undervalu
+ undervalued undervalu
+ underwent underw
+ underwrit underwrit
+ underwrite underwrit
+ undescried undescri
+ undeserved undeserv
+ undeserver undeserv
+ undeservers undeserv
+ undeserving undeserv
+ undetermin undetermin
+ undid undid
+ undinted undint
+ undiscernible undiscern
+ undiscover undiscov
+ undishonoured undishonour
+ undispos undispo
+ undistinguishable undistinguish
+ undistinguished undistinguish
+ undividable undivid
+ undivided undivid
+ undivulged undivulg
+ undo undo
+ undoes undo
+ undoing undo
+ undone undon
+ undoubted undoubt
+ undoubtedly undoubtedli
+ undream undream
+ undress undress
+ undressed undress
+ undrown undrown
+ unduteous undut
+ undutiful unduti
+ une un
+ uneared unear
+ unearned unearn
+ unearthly unearthli
+ uneasines uneasin
+ uneasy uneasi
+ uneath uneath
+ uneducated uneduc
+ uneffectual uneffectu
+ unelected unelect
+ unequal unequ
+ uneven uneven
+ unexamin unexamin
+ unexecuted unexecut
+ unexpected unexpect
+ unexperienc unexperienc
+ unexperient unexperi
+ unexpressive unexpress
+ unfair unfair
+ unfaithful unfaith
+ unfallible unfal
+ unfam unfam
+ unfashionable unfashion
+ unfasten unfasten
+ unfather unfath
+ unfathered unfath
+ unfed unf
+ unfeed unfe
+ unfeeling unfeel
+ unfeigned unfeign
+ unfeignedly unfeignedli
+ unfellowed unfellow
+ unfelt unfelt
+ unfenced unfenc
+ unfilial unfili
+ unfill unfil
+ unfinish unfinish
+ unfirm unfirm
+ unfit unfit
+ unfitness unfit
+ unfix unfix
+ unfledg unfledg
+ unfold unfold
+ unfolded unfold
+ unfoldeth unfoldeth
+ unfolding unfold
+ unfolds unfold
+ unfool unfool
+ unforc unforc
+ unforced unforc
+ unforfeited unforfeit
+ unfortified unfortifi
+ unfortunate unfortun
+ unfought unfought
+ unfrequented unfrequ
+ unfriended unfriend
+ unfurnish unfurnish
+ ungain ungain
+ ungalled ungal
+ ungart ungart
+ ungarter ungart
+ ungenitur ungenitur
+ ungentle ungentl
+ ungentleness ungentl
+ ungently ungent
+ ungird ungird
+ ungodly ungodli
+ ungor ungor
+ ungot ungot
+ ungotten ungotten
+ ungovern ungovern
+ ungracious ungraci
+ ungrateful ungrat
+ ungravely ungrav
+ ungrown ungrown
+ unguarded unguard
+ unguem unguem
+ unguided unguid
+ unhack unhack
+ unhair unhair
+ unhallow unhallow
+ unhallowed unhallow
+ unhand unhand
+ unhandled unhandl
+ unhandsome unhandsom
+ unhang unhang
+ unhappied unhappi
+ unhappily unhappili
+ unhappiness unhappi
+ unhappy unhappi
+ unhardened unharden
+ unharm unharm
+ unhatch unhatch
+ unheard unheard
+ unhearts unheart
+ unheedful unheed
+ unheedfully unheedfulli
+ unheedy unheedi
+ unhelpful unhelp
+ unhidden unhidden
+ unholy unholi
+ unhop unhop
+ unhopefullest unhopefullest
+ unhorse unhors
+ unhospitable unhospit
+ unhous unhou
+ unhoused unhous
+ unhurtful unhurt
+ unicorn unicorn
+ unicorns unicorn
+ unimproved unimprov
+ uninhabitable uninhabit
+ uninhabited uninhabit
+ unintelligent unintellig
+ union union
+ unions union
+ unite unit
+ united unit
+ unity uniti
+ universal univers
+ universe univers
+ universities univers
+ university univers
+ unjointed unjoint
+ unjust unjust
+ unjustice unjustic
+ unjustly unjustli
+ unkennel unkennel
+ unkept unkept
+ unkind unkind
+ unkindest unkindest
+ unkindly unkindli
+ unkindness unkind
+ unking unk
+ unkinglike unkinglik
+ unkiss unkiss
+ unknit unknit
+ unknowing unknow
+ unknown unknown
+ unlace unlac
+ unlaid unlaid
+ unlawful unlaw
+ unlawfully unlawfulli
+ unlearn unlearn
+ unlearned unlearn
+ unless unless
+ unlesson unlesson
+ unletter unlett
+ unlettered unlett
+ unlick unlick
+ unlike unlik
+ unlikely unlik
+ unlimited unlimit
+ unlineal unlin
+ unlink unlink
+ unload unload
+ unloaded unload
+ unloading unload
+ unloads unload
+ unlock unlock
+ unlocks unlock
+ unlook unlook
+ unlooked unlook
+ unloos unloo
+ unloose unloos
+ unlov unlov
+ unloving unlov
+ unluckily unluckili
+ unlucky unlucki
+ unmade unmad
+ unmake unmak
+ unmanly unmanli
+ unmann unmann
+ unmanner unmann
+ unmannerd unmannerd
+ unmannerly unmannerli
+ unmarried unmarri
+ unmask unmask
+ unmasked unmask
+ unmasking unmask
+ unmasks unmask
+ unmast unmast
+ unmatch unmatch
+ unmatchable unmatch
+ unmatched unmatch
+ unmeasurable unmeasur
+ unmeet unmeet
+ unmellowed unmellow
+ unmerciful unmerci
+ unmeritable unmerit
+ unmeriting unmerit
+ unminded unmind
+ unmindfull unmindful
+ unmingled unmingl
+ unmitigable unmitig
+ unmitigated unmitig
+ unmix unmix
+ unmoan unmoan
+ unmov unmov
+ unmoved unmov
+ unmoving unmov
+ unmuffles unmuffl
+ unmuffling unmuffl
+ unmusical unmus
+ unmuzzle unmuzzl
+ unmuzzled unmuzzl
+ unnatural unnatur
+ unnaturally unnatur
+ unnaturalness unnatur
+ unnecessarily unnecessarili
+ unnecessary unnecessari
+ unneighbourly unneighbourli
+ unnerved unnerv
+ unnoble unnobl
+ unnoted unnot
+ unnumb unnumb
+ unnumber unnumb
+ unowed unow
+ unpack unpack
+ unpaid unpaid
+ unparagon unparagon
+ unparallel unparallel
+ unpartial unparti
+ unpath unpath
+ unpaved unpav
+ unpay unpai
+ unpeaceable unpeac
+ unpeg unpeg
+ unpeople unpeopl
+ unpeopled unpeopl
+ unperfect unperfect
+ unperfectness unperfect
+ unpick unpick
+ unpin unpin
+ unpink unpink
+ unpitied unpiti
+ unpitifully unpitifulli
+ unplagu unplagu
+ unplausive unplaus
+ unpleas unplea
+ unpleasant unpleas
+ unpleasing unpleas
+ unpolicied unpolici
+ unpolish unpolish
+ unpolished unpolish
+ unpolluted unpollut
+ unpossess unpossess
+ unpossessing unpossess
+ unpossible unposs
+ unpractis unpracti
+ unpregnant unpregn
+ unpremeditated unpremedit
+ unprepar unprepar
+ unprepared unprepar
+ unpress unpress
+ unprevailing unprevail
+ unprevented unprev
+ unpriz unpriz
+ unprizable unpriz
+ unprofitable unprofit
+ unprofited unprofit
+ unproper unprop
+ unproperly unproperli
+ unproportion unproport
+ unprovide unprovid
+ unprovided unprovid
+ unprovident unprovid
+ unprovokes unprovok
+ unprun unprun
+ unpruned unprun
+ unpublish unpublish
+ unpurged unpurg
+ unpurpos unpurpo
+ unqualitied unqual
+ unqueen unqueen
+ unquestion unquest
+ unquestionable unquestion
+ unquiet unquiet
+ unquietly unquietli
+ unquietness unquiet
+ unraised unrais
+ unrak unrak
+ unread unread
+ unready unreadi
+ unreal unreal
+ unreasonable unreason
+ unreasonably unreason
+ unreclaimed unreclaim
+ unreconciled unreconcil
+ unreconciliable unreconcili
+ unrecounted unrecount
+ unrecuring unrecur
+ unregarded unregard
+ unregist unregist
+ unrelenting unrel
+ unremovable unremov
+ unremovably unremov
+ unreprievable unrepriev
+ unresolv unresolv
+ unrespected unrespect
+ unrespective unrespect
+ unrest unrest
+ unrestor unrestor
+ unrestrained unrestrain
+ unreveng unreveng
+ unreverend unreverend
+ unreverent unrever
+ unrevers unrev
+ unrewarded unreward
+ unrighteous unright
+ unrightful unright
+ unripe unrip
+ unripp unripp
+ unrivall unrival
+ unroll unrol
+ unroof unroof
+ unroosted unroost
+ unroot unroot
+ unrough unrough
+ unruly unruli
+ unsafe unsaf
+ unsaluted unsalut
+ unsanctified unsanctifi
+ unsatisfied unsatisfi
+ unsavoury unsavouri
+ unsay unsai
+ unscalable unscal
+ unscann unscann
+ unscarr unscarr
+ unschool unschool
+ unscorch unscorch
+ unscour unscour
+ unscratch unscratch
+ unseal unseal
+ unseam unseam
+ unsearch unsearch
+ unseason unseason
+ unseasonable unseason
+ unseasonably unseason
+ unseasoned unseason
+ unseconded unsecond
+ unsecret unsecret
+ unseduc unseduc
+ unseeing unse
+ unseeming unseem
+ unseemly unseemli
+ unseen unseen
+ unseminar unseminar
+ unseparable unsepar
+ unserviceable unservic
+ unset unset
+ unsettle unsettl
+ unsettled unsettl
+ unsever unsev
+ unsex unsex
+ unshak unshak
+ unshaked unshak
+ unshaken unshaken
+ unshaped unshap
+ unshapes unshap
+ unsheath unsheath
+ unsheathe unsheath
+ unshorn unshorn
+ unshout unshout
+ unshown unshown
+ unshrinking unshrink
+ unshrubb unshrubb
+ unshunn unshunn
+ unshunnable unshunn
+ unsifted unsift
+ unsightly unsightli
+ unsinew unsinew
+ unsisting unsist
+ unskilful unskil
+ unskilfully unskilfulli
+ unskillful unskil
+ unslipping unslip
+ unsmirched unsmirch
+ unsoil unsoil
+ unsolicited unsolicit
+ unsorted unsort
+ unsought unsought
+ unsound unsound
+ unsounded unsound
+ unspeak unspeak
+ unspeakable unspeak
+ unspeaking unspeak
+ unsphere unspher
+ unspoke unspok
+ unspoken unspoken
+ unspotted unspot
+ unsquar unsquar
+ unstable unstabl
+ unstaid unstaid
+ unstain unstain
+ unstained unstain
+ unstanched unstanch
+ unstate unstat
+ unsteadfast unsteadfast
+ unstooping unstoop
+ unstringed unstring
+ unstuff unstuff
+ unsubstantial unsubstanti
+ unsuitable unsuit
+ unsuiting unsuit
+ unsullied unsulli
+ unsunn unsunn
+ unsur unsur
+ unsure unsur
+ unsuspected unsuspect
+ unsway unswai
+ unswayable unsway
+ unswayed unswai
+ unswear unswear
+ unswept unswept
+ unsworn unsworn
+ untainted untaint
+ untalk untalk
+ untangle untangl
+ untangled untangl
+ untasted untast
+ untaught untaught
+ untempering untemp
+ untender untend
+ untent untent
+ untented untent
+ unthankful unthank
+ unthankfulness unthank
+ unthink unthink
+ unthought unthought
+ unthread unthread
+ unthrift unthrift
+ unthrifts unthrift
+ unthrifty unthrifti
+ untie unti
+ untied unti
+ until until
+ untimber untimb
+ untimely untim
+ untir untir
+ untirable untir
+ untired untir
+ untitled untitl
+ unto unto
+ untold untold
+ untouch untouch
+ untoward untoward
+ untowardly untowardli
+ untraded untrad
+ untrain untrain
+ untrained untrain
+ untread untread
+ untreasur untreasur
+ untried untri
+ untrimmed untrim
+ untrod untrod
+ untrodden untrodden
+ untroubled untroubl
+ untrue untru
+ untrussing untruss
+ untruth untruth
+ untruths untruth
+ untucked untuck
+ untun untun
+ untune untun
+ untuneable untun
+ untutor untutor
+ untutored untutor
+ untwine untwin
+ unurg unurg
+ unus unu
+ unused unus
+ unusual unusu
+ unvalued unvalu
+ unvanquish unvanquish
+ unvarnish unvarnish
+ unveil unveil
+ unveiling unveil
+ unvenerable unvener
+ unvex unvex
+ unviolated unviol
+ unvirtuous unvirtu
+ unvisited unvisit
+ unvulnerable unvulner
+ unwares unwar
+ unwarily unwarili
+ unwash unwash
+ unwatch unwatch
+ unwearied unweari
+ unwed unw
+ unwedgeable unwedg
+ unweeded unweed
+ unweighed unweigh
+ unweighing unweigh
+ unwelcome unwelcom
+ unwept unwept
+ unwhipp unwhipp
+ unwholesome unwholesom
+ unwieldy unwieldi
+ unwilling unwil
+ unwillingly unwillingli
+ unwillingness unwilling
+ unwind unwind
+ unwiped unwip
+ unwise unwis
+ unwisely unwis
+ unwish unwish
+ unwished unwish
+ unwitted unwit
+ unwittingly unwittingli
+ unwonted unwont
+ unwooed unwoo
+ unworthier unworthi
+ unworthiest unworthiest
+ unworthily unworthili
+ unworthiness unworthi
+ unworthy unworthi
+ unwrung unwrung
+ unyok unyok
+ unyoke unyok
+ up up
+ upbraid upbraid
+ upbraided upbraid
+ upbraidings upbraid
+ upbraids upbraid
+ uphoarded uphoard
+ uphold uphold
+ upholdeth upholdeth
+ upholding uphold
+ upholds uphold
+ uplift uplift
+ uplifted uplift
+ upmost upmost
+ upon upon
+ upper upper
+ uprear uprear
+ upreared uprear
+ upright upright
+ uprighteously upright
+ uprightness upright
+ uprise upris
+ uprising upris
+ uproar uproar
+ uproars uproar
+ uprous uprou
+ upshoot upshoot
+ upshot upshot
+ upside upsid
+ upspring upspr
+ upstairs upstair
+ upstart upstart
+ upturned upturn
+ upward upward
+ upwards upward
+ urchin urchin
+ urchinfield urchinfield
+ urchins urchin
+ urg urg
+ urge urg
+ urged urg
+ urgent urgent
+ urges urg
+ urgest urgest
+ urging urg
+ urinal urin
+ urinals urin
+ urine urin
+ urn urn
+ urns urn
+ urs ur
+ ursa ursa
+ ursley urslei
+ ursula ursula
+ urswick urswick
+ us us
+ usage usag
+ usance usanc
+ usances usanc
+ use us
+ used us
+ useful us
+ useless useless
+ user user
+ uses us
+ usest usest
+ useth useth
+ usher usher
+ ushered usher
+ ushering usher
+ ushers usher
+ using us
+ usual usual
+ usually usual
+ usurer usur
+ usurers usur
+ usuries usuri
+ usuring usur
+ usurp usurp
+ usurpation usurp
+ usurped usurp
+ usurper usurp
+ usurpers usurp
+ usurping usurp
+ usurpingly usurpingli
+ usurps usurp
+ usury usuri
+ ut ut
+ utensil utensil
+ utensils utensil
+ utility util
+ utmost utmost
+ utt utt
+ utter utter
+ utterance utter
+ uttered utter
+ uttereth uttereth
+ uttering utter
+ utterly utterli
+ uttermost uttermost
+ utters utter
+ uy uy
+ v v
+ va va
+ vacancy vacanc
+ vacant vacant
+ vacation vacat
+ vade vade
+ vagabond vagabond
+ vagabonds vagabond
+ vagram vagram
+ vagrom vagrom
+ vail vail
+ vailed vail
+ vailing vail
+ vaillant vaillant
+ vain vain
+ vainer vainer
+ vainglory vainglori
+ vainly vainli
+ vainness vain
+ vais vai
+ valanc valanc
+ valance valanc
+ vale vale
+ valence valenc
+ valentine valentin
+ valentinus valentinu
+ valentio valentio
+ valeria valeria
+ valerius valeriu
+ vales vale
+ valiant valiant
+ valiantly valiantli
+ valiantness valiant
+ validity valid
+ vallant vallant
+ valley vallei
+ valleys vallei
+ vally valli
+ valor valor
+ valorous valor
+ valorously valor
+ valour valour
+ valu valu
+ valuation valuat
+ value valu
+ valued valu
+ valueless valueless
+ values valu
+ valuing valu
+ vane vane
+ vanish vanish
+ vanished vanish
+ vanishes vanish
+ vanishest vanishest
+ vanishing vanish
+ vanities vaniti
+ vanity vaniti
+ vanquish vanquish
+ vanquished vanquish
+ vanquisher vanquish
+ vanquishest vanquishest
+ vanquisheth vanquisheth
+ vant vant
+ vantage vantag
+ vantages vantag
+ vantbrace vantbrac
+ vapians vapian
+ vapor vapor
+ vaporous vapor
+ vapour vapour
+ vapours vapour
+ vara vara
+ variable variabl
+ variance varianc
+ variation variat
+ variations variat
+ varied vari
+ variest variest
+ variety varieti
+ varld varld
+ varlet varlet
+ varletry varletri
+ varlets varlet
+ varletto varletto
+ varnish varnish
+ varrius varriu
+ varro varro
+ vary vari
+ varying vari
+ vassal vassal
+ vassalage vassalag
+ vassals vassal
+ vast vast
+ vastidity vastid
+ vasty vasti
+ vat vat
+ vater vater
+ vaudemont vaudemont
+ vaughan vaughan
+ vault vault
+ vaultages vaultag
+ vaulted vault
+ vaulting vault
+ vaults vault
+ vaulty vaulti
+ vaumond vaumond
+ vaunt vaunt
+ vaunted vaunt
+ vaunter vaunter
+ vaunting vaunt
+ vauntingly vauntingli
+ vaunts vaunt
+ vauvado vauvado
+ vaux vaux
+ vaward vaward
+ ve ve
+ veal veal
+ vede vede
+ vehemence vehem
+ vehemency vehem
+ vehement vehement
+ vehor vehor
+ veil veil
+ veiled veil
+ veiling veil
+ vein vein
+ veins vein
+ vell vell
+ velure velur
+ velutus velutu
+ velvet velvet
+ vendible vendibl
+ venerable vener
+ venereal vener
+ venetia venetia
+ venetian venetian
+ venetians venetian
+ veneys venei
+ venge veng
+ vengeance vengeanc
+ vengeances vengeanc
+ vengeful veng
+ veni veni
+ venial venial
+ venice venic
+ venison venison
+ venit venit
+ venom venom
+ venomous venom
+ venomously venom
+ vent vent
+ ventages ventag
+ vented vent
+ ventidius ventidiu
+ ventricle ventricl
+ vents vent
+ ventur ventur
+ venture ventur
+ ventured ventur
+ ventures ventur
+ venturing ventur
+ venturous ventur
+ venue venu
+ venus venu
+ venuto venuto
+ ver ver
+ verb verb
+ verba verba
+ verbal verbal
+ verbatim verbatim
+ verbosity verbos
+ verdict verdict
+ verdun verdun
+ verdure verdur
+ vere vere
+ verefore verefor
+ verg verg
+ verge verg
+ vergers verger
+ verges verg
+ verier verier
+ veriest veriest
+ verified verifi
+ verify verifi
+ verily verili
+ veritable verit
+ verite verit
+ verities veriti
+ verity veriti
+ vermilion vermilion
+ vermin vermin
+ vernon vernon
+ verona verona
+ veronesa veronesa
+ versal versal
+ verse vers
+ verses vers
+ versing vers
+ vert vert
+ very veri
+ vesper vesper
+ vessel vessel
+ vessels vessel
+ vestal vestal
+ vestments vestment
+ vesture vestur
+ vetch vetch
+ vetches vetch
+ veux veux
+ vex vex
+ vexation vexat
+ vexations vexat
+ vexed vex
+ vexes vex
+ vexest vexest
+ vexeth vexeth
+ vexing vex
+ vi vi
+ via via
+ vial vial
+ vials vial
+ viand viand
+ viands viand
+ vic vic
+ vicar vicar
+ vice vice
+ vicegerent viceger
+ vicentio vicentio
+ viceroy viceroi
+ viceroys viceroi
+ vices vice
+ vici vici
+ vicious viciou
+ viciousness vicious
+ vict vict
+ victims victim
+ victor victor
+ victoress victoress
+ victories victori
+ victorious victori
+ victors victor
+ victory victori
+ victual victual
+ victuall victual
+ victuals victual
+ videlicet videlicet
+ video video
+ vides vide
+ videsne videsn
+ vidi vidi
+ vie vie
+ vied vi
+ vienna vienna
+ view view
+ viewest viewest
+ vieweth vieweth
+ viewing view
+ viewless viewless
+ views view
+ vigil vigil
+ vigilance vigil
+ vigilant vigil
+ vigitant vigit
+ vigour vigour
+ vii vii
+ viii viii
+ vile vile
+ vilely vile
+ vileness vile
+ viler viler
+ vilest vilest
+ vill vill
+ village villag
+ villager villag
+ villagery villageri
+ villages villag
+ villain villain
+ villainies villaini
+ villainous villain
+ villainously villain
+ villains villain
+ villainy villaini
+ villanies villani
+ villanous villan
+ villany villani
+ villiago villiago
+ villian villian
+ villianda villianda
+ villians villian
+ vinaigre vinaigr
+ vincentio vincentio
+ vincere vincer
+ vindicative vindic
+ vine vine
+ vinegar vinegar
+ vines vine
+ vineyard vineyard
+ vineyards vineyard
+ vint vint
+ vintner vintner
+ viol viol
+ viola viola
+ violate violat
+ violated violat
+ violates violat
+ violation violat
+ violator violat
+ violence violenc
+ violent violent
+ violenta violenta
+ violenteth violenteth
+ violently violent
+ violet violet
+ violets violet
+ viper viper
+ viperous viper
+ vipers viper
+ vir vir
+ virgilia virgilia
+ virgin virgin
+ virginal virgin
+ virginalling virginal
+ virginity virgin
+ virginius virginiu
+ virgins virgin
+ virgo virgo
+ virtue virtu
+ virtues virtu
+ virtuous virtuou
+ virtuously virtuous
+ visag visag
+ visage visag
+ visages visag
+ visard visard
+ viscount viscount
+ visible visibl
+ visibly visibl
+ vision vision
+ visions vision
+ visit visit
+ visitation visit
+ visitations visit
+ visited visit
+ visiting visit
+ visitings visit
+ visitor visitor
+ visitors visitor
+ visits visit
+ visor visor
+ vita vita
+ vitae vita
+ vital vital
+ vitement vitement
+ vitruvio vitruvio
+ vitx vitx
+ viva viva
+ vivant vivant
+ vive vive
+ vixen vixen
+ viz viz
+ vizaments vizament
+ vizard vizard
+ vizarded vizard
+ vizards vizard
+ vizor vizor
+ vlouting vlout
+ vocation vocat
+ vocativo vocativo
+ vocatur vocatur
+ voce voce
+ voic voic
+ voice voic
+ voices voic
+ void void
+ voided void
+ voiding void
+ voke voke
+ volable volabl
+ volant volant
+ volivorco volivorco
+ volley vollei
+ volquessen volquessen
+ volsce volsc
+ volsces volsc
+ volscian volscian
+ volscians volscian
+ volt volt
+ voltemand voltemand
+ volubility volubl
+ voluble volubl
+ volume volum
+ volumes volum
+ volumnia volumnia
+ volumnius volumniu
+ voluntaries voluntari
+ voluntary voluntari
+ voluptuously voluptu
+ voluptuousness voluptu
+ vomissement vomiss
+ vomit vomit
+ vomits vomit
+ vor vor
+ vore vore
+ vortnight vortnight
+ vot vot
+ votaries votari
+ votarist votarist
+ votarists votarist
+ votary votari
+ votre votr
+ vouch vouch
+ voucher voucher
+ vouchers voucher
+ vouches vouch
+ vouching vouch
+ vouchsaf vouchsaf
+ vouchsafe vouchsaf
+ vouchsafed vouchsaf
+ vouchsafes vouchsaf
+ vouchsafing vouchsaf
+ voudrais voudrai
+ vour vour
+ vous vou
+ voutsafe voutsaf
+ vow vow
+ vowed vow
+ vowel vowel
+ vowels vowel
+ vowing vow
+ vows vow
+ vox vox
+ voyage voyag
+ voyages voyag
+ vraiment vraiment
+ vulcan vulcan
+ vulgar vulgar
+ vulgarly vulgarli
+ vulgars vulgar
+ vulgo vulgo
+ vulnerable vulner
+ vulture vultur
+ vultures vultur
+ vurther vurther
+ w w
+ wad wad
+ waddled waddl
+ wade wade
+ waded wade
+ wafer wafer
+ waft waft
+ waftage waftag
+ wafting waft
+ wafts waft
+ wag wag
+ wage wage
+ wager wager
+ wagers wager
+ wages wage
+ wagging wag
+ waggish waggish
+ waggling waggl
+ waggon waggon
+ waggoner waggon
+ wagon wagon
+ wagoner wagon
+ wags wag
+ wagtail wagtail
+ wail wail
+ wailful wail
+ wailing wail
+ wails wail
+ wain wain
+ wainropes wainrop
+ wainscot wainscot
+ waist waist
+ wait wait
+ waited wait
+ waiter waiter
+ waiteth waiteth
+ waiting wait
+ waits wait
+ wak wak
+ wake wake
+ waked wake
+ wakefield wakefield
+ waken waken
+ wakened waken
+ wakes wake
+ wakest wakest
+ waking wake
+ wales wale
+ walk walk
+ walked walk
+ walking walk
+ walks walk
+ wall wall
+ walled wall
+ wallet wallet
+ wallets wallet
+ wallon wallon
+ walloon walloon
+ wallow wallow
+ walls wall
+ walnut walnut
+ walter walter
+ wan wan
+ wand wand
+ wander wander
+ wanderer wander
+ wanderers wander
+ wandering wander
+ wanders wander
+ wands wand
+ wane wane
+ waned wane
+ wanes wane
+ waning wane
+ wann wann
+ want want
+ wanted want
+ wanteth wanteth
+ wanting want
+ wanton wanton
+ wantonly wantonli
+ wantonness wanton
+ wantons wanton
+ wants want
+ wappen wappen
+ war war
+ warble warbl
+ warbling warbl
+ ward ward
+ warded ward
+ warden warden
+ warder warder
+ warders warder
+ wardrobe wardrob
+ wardrop wardrop
+ wards ward
+ ware ware
+ wares ware
+ warily warili
+ warkworth warkworth
+ warlike warlik
+ warm warm
+ warmed warm
+ warmer warmer
+ warming warm
+ warms warm
+ warmth warmth
+ warn warn
+ warned warn
+ warning warn
+ warnings warn
+ warns warn
+ warp warp
+ warped warp
+ warr warr
+ warrant warrant
+ warranted warrant
+ warranteth warranteth
+ warrantise warrantis
+ warrantize warrant
+ warrants warrant
+ warranty warranti
+ warren warren
+ warrener warren
+ warring war
+ warrior warrior
+ warriors warrior
+ wars war
+ wart wart
+ warwick warwick
+ warwickshire warwickshir
+ wary wari
+ was wa
+ wash wash
+ washed wash
+ washer washer
+ washes wash
+ washford washford
+ washing wash
+ wasp wasp
+ waspish waspish
+ wasps wasp
+ wassail wassail
+ wassails wassail
+ wast wast
+ waste wast
+ wasted wast
+ wasteful wast
+ wasters waster
+ wastes wast
+ wasting wast
+ wat wat
+ watch watch
+ watched watch
+ watchers watcher
+ watches watch
+ watchful watch
+ watching watch
+ watchings watch
+ watchman watchman
+ watchmen watchmen
+ watchword watchword
+ water water
+ waterdrops waterdrop
+ watered water
+ waterfly waterfli
+ waterford waterford
+ watering water
+ waterish waterish
+ waterpots waterpot
+ waterrugs waterrug
+ waters water
+ waterton waterton
+ watery wateri
+ wav wav
+ wave wave
+ waved wave
+ waver waver
+ waverer waver
+ wavering waver
+ waves wave
+ waving wave
+ waw waw
+ wawl wawl
+ wax wax
+ waxed wax
+ waxen waxen
+ waxes wax
+ waxing wax
+ way wai
+ waylaid waylaid
+ waylay waylai
+ ways wai
+ wayward wayward
+ waywarder wayward
+ waywardness wayward
+ we we
+ weak weak
+ weaken weaken
+ weakens weaken
+ weaker weaker
+ weakest weakest
+ weakling weakl
+ weakly weakli
+ weakness weak
+ weal weal
+ wealsmen wealsmen
+ wealth wealth
+ wealthiest wealthiest
+ wealthily wealthili
+ wealthy wealthi
+ wealtlly wealtlli
+ wean wean
+ weapon weapon
+ weapons weapon
+ wear wear
+ wearer wearer
+ wearers wearer
+ wearied weari
+ wearies weari
+ weariest weariest
+ wearily wearili
+ weariness weari
+ wearing wear
+ wearisome wearisom
+ wears wear
+ weary weari
+ weasel weasel
+ weather weather
+ weathercock weathercock
+ weathers weather
+ weav weav
+ weave weav
+ weaver weaver
+ weavers weaver
+ weaves weav
+ weaving weav
+ web web
+ wed wed
+ wedded wed
+ wedding wed
+ wedg wedg
+ wedged wedg
+ wedges wedg
+ wedlock wedlock
+ wednesday wednesdai
+ weed weed
+ weeded weed
+ weeder weeder
+ weeding weed
+ weeds weed
+ weedy weedi
+ week week
+ weeke week
+ weekly weekli
+ weeks week
+ ween ween
+ weening ween
+ weep weep
+ weeper weeper
+ weeping weep
+ weepingly weepingli
+ weepings weep
+ weeps weep
+ weet weet
+ weigh weigh
+ weighed weigh
+ weighing weigh
+ weighs weigh
+ weight weight
+ weightier weightier
+ weightless weightless
+ weights weight
+ weighty weighti
+ weird weird
+ welcom welcom
+ welcome welcom
+ welcomer welcom
+ welcomes welcom
+ welcomest welcomest
+ welfare welfar
+ welkin welkin
+ well well
+ wells well
+ welsh welsh
+ welshman welshman
+ welshmen welshmen
+ welshwomen welshwomen
+ wench wench
+ wenches wench
+ wenching wench
+ wend wend
+ went went
+ wept wept
+ weraday weradai
+ were were
+ wert wert
+ west west
+ western western
+ westminster westminst
+ westmoreland westmoreland
+ westward westward
+ wet wet
+ wether wether
+ wetting wet
+ wezand wezand
+ whale whale
+ whales whale
+ wharf wharf
+ wharfs wharf
+ what what
+ whate whate
+ whatever whatev
+ whatsoe whatso
+ whatsoever whatsoev
+ whatsome whatsom
+ whe whe
+ wheat wheat
+ wheaten wheaten
+ wheel wheel
+ wheeling wheel
+ wheels wheel
+ wheer wheer
+ wheeson wheeson
+ wheezing wheez
+ whelk whelk
+ whelks whelk
+ whelm whelm
+ whelp whelp
+ whelped whelp
+ whelps whelp
+ when when
+ whenas whena
+ whence whenc
+ whencesoever whencesoev
+ whene whene
+ whenever whenev
+ whensoever whensoev
+ where where
+ whereabout whereabout
+ whereas wherea
+ whereat whereat
+ whereby wherebi
+ wherefore wherefor
+ wherein wherein
+ whereinto whereinto
+ whereof whereof
+ whereon whereon
+ whereout whereout
+ whereso whereso
+ wheresoe whereso
+ wheresoever wheresoev
+ wheresome wheresom
+ whereto whereto
+ whereuntil whereuntil
+ whereunto whereunto
+ whereupon whereupon
+ wherever wherev
+ wherewith wherewith
+ wherewithal wherewith
+ whet whet
+ whether whether
+ whetstone whetston
+ whetted whet
+ whew whew
+ whey whei
+ which which
+ whiff whiff
+ whiffler whiffler
+ while while
+ whiles while
+ whilst whilst
+ whin whin
+ whine whine
+ whined whine
+ whinid whinid
+ whining whine
+ whip whip
+ whipp whipp
+ whippers whipper
+ whipping whip
+ whips whip
+ whipster whipster
+ whipstock whipstock
+ whipt whipt
+ whirl whirl
+ whirled whirl
+ whirligig whirligig
+ whirling whirl
+ whirlpool whirlpool
+ whirls whirl
+ whirlwind whirlwind
+ whirlwinds whirlwind
+ whisp whisp
+ whisper whisper
+ whispering whisper
+ whisperings whisper
+ whispers whisper
+ whist whist
+ whistle whistl
+ whistles whistl
+ whistling whistl
+ whit whit
+ white white
+ whitehall whitehal
+ whitely white
+ whiteness white
+ whiter whiter
+ whites white
+ whitest whitest
+ whither whither
+ whiting white
+ whitmore whitmor
+ whitsters whitster
+ whitsun whitsun
+ whittle whittl
+ whizzing whizz
+ who who
+ whoa whoa
+ whoe whoe
+ whoever whoever
+ whole whole
+ wholesom wholesom
+ wholesome wholesom
+ wholly wholli
+ whom whom
+ whoobub whoobub
+ whoop whoop
+ whooping whoop
+ whor whor
+ whore whore
+ whoremaster whoremast
+ whoremasterly whoremasterli
+ whoremonger whoremong
+ whores whore
+ whoreson whoreson
+ whoresons whoreson
+ whoring whore
+ whorish whorish
+ whose whose
+ whoso whoso
+ whosoe whoso
+ whosoever whosoev
+ why why
+ wi wi
+ wick wick
+ wicked wick
+ wickednes wickedn
+ wickedness wicked
+ wicket wicket
+ wicky wicki
+ wid wid
+ wide wide
+ widens widen
+ wider wider
+ widow widow
+ widowed widow
+ widower widow
+ widowhood widowhood
+ widows widow
+ wield wield
+ wife wife
+ wight wight
+ wights wight
+ wild wild
+ wildcats wildcat
+ wilder wilder
+ wilderness wilder
+ wildest wildest
+ wildfire wildfir
+ wildly wildli
+ wildness wild
+ wilds wild
+ wiles wile
+ wilful wil
+ wilfull wilful
+ wilfully wilfulli
+ wilfulnes wilfuln
+ wilfulness wil
+ will will
+ willed will
+ willers willer
+ willeth willeth
+ william william
+ williams william
+ willing will
+ willingly willingli
+ willingness willing
+ willoughby willoughbi
+ willow willow
+ wills will
+ wilt wilt
+ wiltshire wiltshir
+ wimpled wimpl
+ win win
+ wince winc
+ winch winch
+ winchester winchest
+ wincot wincot
+ wind wind
+ winded wind
+ windgalls windgal
+ winding wind
+ windlasses windlass
+ windmill windmil
+ window window
+ windows window
+ windpipe windpip
+ winds wind
+ windsor windsor
+ windy windi
+ wine wine
+ wing wing
+ winged wing
+ wingfield wingfield
+ wingham wingham
+ wings wing
+ wink wink
+ winking wink
+ winks wink
+ winner winner
+ winners winner
+ winning win
+ winnow winnow
+ winnowed winnow
+ winnows winnow
+ wins win
+ winter winter
+ winterly winterli
+ winters winter
+ wip wip
+ wipe wipe
+ wiped wipe
+ wipes wipe
+ wiping wipe
+ wire wire
+ wires wire
+ wiry wiri
+ wisdom wisdom
+ wisdoms wisdom
+ wise wise
+ wiselier wiseli
+ wisely wise
+ wiser wiser
+ wisest wisest
+ wish wish
+ wished wish
+ wisher wisher
+ wishers wisher
+ wishes wish
+ wishest wishest
+ wisheth wisheth
+ wishful wish
+ wishing wish
+ wishtly wishtli
+ wisp wisp
+ wist wist
+ wit wit
+ witb witb
+ witch witch
+ witchcraft witchcraft
+ witches witch
+ witching witch
+ with with
+ withal withal
+ withdraw withdraw
+ withdrawing withdraw
+ withdrawn withdrawn
+ withdrew withdrew
+ wither wither
+ withered wither
+ withering wither
+ withers wither
+ withheld withheld
+ withhold withhold
+ withholds withhold
+ within within
+ withold withold
+ without without
+ withstand withstand
+ withstanding withstand
+ withstood withstood
+ witless witless
+ witness wit
+ witnesses wit
+ witnesseth witnesseth
+ witnessing wit
+ wits wit
+ witted wit
+ wittenberg wittenberg
+ wittiest wittiest
+ wittily wittili
+ witting wit
+ wittingly wittingli
+ wittol wittol
+ wittolly wittolli
+ witty witti
+ wiv wiv
+ wive wive
+ wived wive
+ wives wive
+ wiving wive
+ wizard wizard
+ wizards wizard
+ wo wo
+ woe woe
+ woeful woeful
+ woefull woeful
+ woefullest woefullest
+ woes woe
+ woful woful
+ wolf wolf
+ wolfish wolfish
+ wolsey wolsei
+ wolves wolv
+ wolvish wolvish
+ woman woman
+ womanhood womanhood
+ womanish womanish
+ womankind womankind
+ womanly womanli
+ womb womb
+ wombs womb
+ womby wombi
+ women women
+ won won
+ woncot woncot
+ wond wond
+ wonder wonder
+ wondered wonder
+ wonderful wonder
+ wonderfully wonderfulli
+ wondering wonder
+ wonders wonder
+ wondrous wondrou
+ wondrously wondrous
+ wont wont
+ wonted wont
+ woo woo
+ wood wood
+ woodbine woodbin
+ woodcock woodcock
+ woodcocks woodcock
+ wooden wooden
+ woodland woodland
+ woodman woodman
+ woodmonger woodmong
+ woods wood
+ woodstock woodstock
+ woodville woodvil
+ wooed woo
+ wooer wooer
+ wooers wooer
+ wooes wooe
+ woof woof
+ wooing woo
+ wooingly wooingli
+ wool wool
+ woollen woollen
+ woolly woolli
+ woolsack woolsack
+ woolsey woolsei
+ woolward woolward
+ woos woo
+ wor wor
+ worcester worcest
+ word word
+ words word
+ wore wore
+ worins worin
+ work work
+ workers worker
+ working work
+ workings work
+ workman workman
+ workmanly workmanli
+ workmanship workmanship
+ workmen workmen
+ works work
+ worky worki
+ world world
+ worldlings worldl
+ worldly worldli
+ worlds world
+ worm worm
+ worms worm
+ wormwood wormwood
+ wormy wormi
+ worn worn
+ worried worri
+ worries worri
+ worry worri
+ worrying worri
+ worse wors
+ worser worser
+ worship worship
+ worshipful worship
+ worshipfully worshipfulli
+ worshipp worshipp
+ worshipper worshipp
+ worshippers worshipp
+ worshippest worshippest
+ worships worship
+ worst worst
+ worsted worst
+ wort wort
+ worth worth
+ worthied worthi
+ worthier worthier
+ worthies worthi
+ worthiest worthiest
+ worthily worthili
+ worthiness worthi
+ worthless worthless
+ worths worth
+ worthy worthi
+ worts wort
+ wot wot
+ wots wot
+ wotting wot
+ wouid wouid
+ would would
+ wouldest wouldest
+ wouldst wouldst
+ wound wound
+ wounded wound
+ wounding wound
+ woundings wound
+ woundless woundless
+ wounds wound
+ wouns woun
+ woven woven
+ wow wow
+ wrack wrack
+ wrackful wrack
+ wrangle wrangl
+ wrangler wrangler
+ wranglers wrangler
+ wrangling wrangl
+ wrap wrap
+ wrapp wrapp
+ wraps wrap
+ wrapt wrapt
+ wrath wrath
+ wrathful wrath
+ wrathfully wrathfulli
+ wraths wrath
+ wreak wreak
+ wreakful wreak
+ wreaks wreak
+ wreath wreath
+ wreathed wreath
+ wreathen wreathen
+ wreaths wreath
+ wreck wreck
+ wrecked wreck
+ wrecks wreck
+ wren wren
+ wrench wrench
+ wrenching wrench
+ wrens wren
+ wrest wrest
+ wrested wrest
+ wresting wrest
+ wrestle wrestl
+ wrestled wrestl
+ wrestler wrestler
+ wrestling wrestl
+ wretch wretch
+ wretchcd wretchcd
+ wretched wretch
+ wretchedness wretched
+ wretches wretch
+ wring wring
+ wringer wringer
+ wringing wring
+ wrings wring
+ wrinkle wrinkl
+ wrinkled wrinkl
+ wrinkles wrinkl
+ wrist wrist
+ wrists wrist
+ writ writ
+ write write
+ writer writer
+ writers writer
+ writes write
+ writhled writhl
+ writing write
+ writings write
+ writs writ
+ written written
+ wrong wrong
+ wronged wrong
+ wronger wronger
+ wrongful wrong
+ wrongfully wrongfulli
+ wronging wrong
+ wrongly wrongli
+ wrongs wrong
+ wronk wronk
+ wrote wrote
+ wroth wroth
+ wrought wrought
+ wrung wrung
+ wry wry
+ wrying wry
+ wt wt
+ wul wul
+ wye wye
+ x x
+ xanthippe xanthipp
+ xi xi
+ xii xii
+ xiii xiii
+ xiv xiv
+ xv xv
+ y y
+ yard yard
+ yards yard
+ yare yare
+ yarely yare
+ yarn yarn
+ yaughan yaughan
+ yaw yaw
+ yawn yawn
+ yawning yawn
+ ycleped yclepe
+ ycliped yclipe
+ ye ye
+ yea yea
+ yead yead
+ year year
+ yearly yearli
+ yearn yearn
+ yearns yearn
+ years year
+ yeas yea
+ yeast yeast
+ yedward yedward
+ yell yell
+ yellow yellow
+ yellowed yellow
+ yellowing yellow
+ yellowness yellow
+ yellows yellow
+ yells yell
+ yelping yelp
+ yeoman yeoman
+ yeomen yeomen
+ yerk yerk
+ yes ye
+ yesterday yesterdai
+ yesterdays yesterdai
+ yesternight yesternight
+ yesty yesti
+ yet yet
+ yew yew
+ yicld yicld
+ yield yield
+ yielded yield
+ yielder yielder
+ yielders yielder
+ yielding yield
+ yields yield
+ yok yok
+ yoke yoke
+ yoked yoke
+ yokefellow yokefellow
+ yokes yoke
+ yoketh yoketh
+ yon yon
+ yond yond
+ yonder yonder
+ yongrey yongrei
+ yore yore
+ yorick yorick
+ york york
+ yorkists yorkist
+ yorks york
+ yorkshire yorkshir
+ you you
+ young young
+ younger younger
+ youngest youngest
+ youngling youngl
+ younglings youngl
+ youngly youngli
+ younker younker
+ your your
+ yours your
+ yourself yourself
+ yourselves yourselv
+ youth youth
+ youthful youth
+ youths youth
+ youtli youtli
+ zanies zani
+ zany zani
+ zeal zeal
+ zealous zealou
+ zeals zeal
+ zed zed
+ zenelophon zenelophon
+ zenith zenith
+ zephyrs zephyr
+ zir zir
+ zo zo
+ zodiac zodiac
+ zodiacs zodiac
+ zone zone
+ zounds zound
+ zwagger zwagger
+}
+
+# Create a full-text index to use for testing the stemmer.
+#
+db close
+sqlite3 db :memory:
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts1(word, tokenize Porter);
+}
+
+foreach {pfrom pto} $porter_test_data {
+ do_test fts1porter-$pfrom {
+ execsql {
+ DELETE FROM t1_term;
+ DELETE FROM t1_content;
+ INSERT INTO t1(word) VALUES($pfrom);
+ SELECT term FROM t1_term;
+ }
+ } $pto
+}
+
+finish_test
diff --git a/test/fts2.test b/test/fts2.test
new file mode 100644
index 0000000..b1e2959
--- /dev/null
+++ b/test/fts2.test
@@ -0,0 +1,67 @@
+# 2008 July 22
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file runs all tests.
+#
+# $Id: fts2.test,v 1.2 2008/07/23 18:17:32 drh Exp $
+
+proc lshift {lvar} {
+ upvar $lvar l
+ set ret [lindex $l 0]
+ set l [lrange $l 1 end]
+ return $ret
+}
+while {[set arg [lshift argv]] != ""} {
+ switch -- $arg {
+ -sharedpagercache {
+ sqlite3_enable_shared_cache 1
+ }
+ -soak {
+ set G(issoak) 1
+ }
+ default {
+ set argv [linsert $argv 0 $arg]
+ break
+ }
+ }
+}
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ return
+}
+rename finish_test really_finish_test
+proc finish_test {} {}
+set G(isquick) 1
+
+set EXCLUDE {
+ fts2.test
+}
+
+# Files to include in the test. If this list is empty then everything
+# that is not in the EXCLUDE list is run.
+#
+set INCLUDE {
+}
+
+foreach testfile [lsort -dictionary [glob $testdir/fts2*.test]] {
+ set tail [file tail $testfile]
+ if {[lsearch -exact $EXCLUDE $tail]>=0} continue
+ if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
+ source $testfile
+ catch {db close}
+ if {$sqlite_open_file_count>0} {
+ puts "$tail did not close all files: $sqlite_open_file_count"
+ fail_test $tail
+ set sqlite_open_file_count 0
+ }
+}
+
+set sqlite_open_file_count 0
+really_finish_test
diff --git a/test/fts2a.test b/test/fts2a.test
new file mode 100644
index 0000000..2d1566f
--- /dev/null
+++ b/test/fts2a.test
@@ -0,0 +1,202 @@
+# 2006 September 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS2 module.
+#
+# $Id: fts2a.test,v 1.2 2007/05/21 21:59:18 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+# Construct a full-text search table containing five keywords:
+# one, two, three, four, and five, in various combinations. The
+# rowid for each will be a bitmask for the elements it contains.
+#
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(content);
+ INSERT INTO t1(content) VALUES('one');
+ INSERT INTO t1(content) VALUES('two');
+ INSERT INTO t1(content) VALUES('one two');
+ INSERT INTO t1(content) VALUES('three');
+ INSERT INTO t1(content) VALUES('one three');
+ INSERT INTO t1(content) VALUES('two three');
+ INSERT INTO t1(content) VALUES('one two three');
+ INSERT INTO t1(content) VALUES('four');
+ INSERT INTO t1(content) VALUES('one four');
+ INSERT INTO t1(content) VALUES('two four');
+ INSERT INTO t1(content) VALUES('one two four');
+ INSERT INTO t1(content) VALUES('three four');
+ INSERT INTO t1(content) VALUES('one three four');
+ INSERT INTO t1(content) VALUES('two three four');
+ INSERT INTO t1(content) VALUES('one two three four');
+ INSERT INTO t1(content) VALUES('five');
+ INSERT INTO t1(content) VALUES('one five');
+ INSERT INTO t1(content) VALUES('two five');
+ INSERT INTO t1(content) VALUES('one two five');
+ INSERT INTO t1(content) VALUES('three five');
+ INSERT INTO t1(content) VALUES('one three five');
+ INSERT INTO t1(content) VALUES('two three five');
+ INSERT INTO t1(content) VALUES('one two three five');
+ INSERT INTO t1(content) VALUES('four five');
+ INSERT INTO t1(content) VALUES('one four five');
+ INSERT INTO t1(content) VALUES('two four five');
+ INSERT INTO t1(content) VALUES('one two four five');
+ INSERT INTO t1(content) VALUES('three four five');
+ INSERT INTO t1(content) VALUES('one three four five');
+ INSERT INTO t1(content) VALUES('two three four five');
+ INSERT INTO t1(content) VALUES('one two three four five');
+}
+
+do_test fts2a-1.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts2a-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}
+} {3 7 11 15 19 23 27 31}
+do_test fts2a-1.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}
+} {3 7 11 15 19 23 27 31}
+do_test fts2a-1.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}
+} {7 15 23 31}
+do_test fts2a-1.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}
+} {7 15 23 31}
+do_test fts2a-1.6 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}
+} {7 15 23 31}
+do_test fts2a-1.7 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}
+} {7 15 23 31}
+do_test fts2a-1.8 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}
+} {7 15 23 31}
+do_test fts2a-1.9 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}
+} {7 15 23 31}
+do_test fts2a-1.10 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}
+} {7 15 23 31}
+do_test fts2a-1.11 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH ' ONE Two three '}
+} {7 15 23 31}
+
+do_test fts2a-2.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one"'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts2a-2.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two"'}
+} {3 7 11 15 19 23 27 31}
+do_test fts2a-2.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"two one"'}
+} {}
+do_test fts2a-2.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three"'}
+} {7 15 23 31}
+do_test fts2a-2.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two"'}
+} {}
+do_test fts2a-2.6 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three four"'}
+} {15 31}
+do_test fts2a-2.7 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two four"'}
+} {}
+do_test fts2a-2.8 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three five"'}
+} {21}
+do_test fts2a-2.9 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" five'}
+} {21 29}
+do_test fts2a-2.10 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three"'}
+} {21 29}
+do_test fts2a-2.11 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three" four'}
+} {29}
+do_test fts2a-2.12 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four "one three"'}
+} {29}
+do_test fts2a-2.13 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" four five'}
+} {29}
+
+do_test fts2a-3.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts2a-3.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}
+} {1 5 9 13 17 21 25 29}
+do_test fts2a-3.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}
+} {1 5 9 13 17 21 25 29}
+
+do_test fts2a-4.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one OR two'}
+} {1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 25 26 27 29 30 31}
+do_test fts2a-4.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two" OR three'}
+} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
+do_test fts2a-4.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR "one two"'}
+} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
+do_test fts2a-4.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three'}
+} {3 5 7 11 13 15 19 21 23 27 29 31}
+do_test fts2a-4.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR two one'}
+} {3 5 7 11 13 15 19 21 23 27 29 31}
+do_test fts2a-4.6 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three OR four'}
+} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
+do_test fts2a-4.7 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two OR three OR four one'}
+} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
+
+# Test the ability to handle NULL content
+#
+do_test fts2a-5.1 {
+ execsql {INSERT INTO t1(content) VALUES(NULL)}
+} {}
+do_test fts2a-5.2 {
+ set rowid [db last_insert_rowid]
+ execsql {SELECT content FROM t1 WHERE rowid=$rowid}
+} {{}}
+do_test fts2a-5.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}
+} {}
+
+# Test the ability to handle non-positive rowids
+#
+do_test fts2a-6.0 {
+ execsql {INSERT INTO t1(rowid, content) VALUES(0, 'four five')}
+} {}
+do_test fts2a-6.1 {
+ execsql {SELECT content FROM t1 WHERE rowid = 0}
+} {{four five}}
+do_test fts2a-6.2 {
+ execsql {INSERT INTO t1(rowid, content) VALUES(-1, 'three four')}
+} {}
+do_test fts2a-6.3 {
+ execsql {SELECT content FROM t1 WHERE rowid = -1}
+} {{three four}}
+do_test fts2a-6.4 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'four'}
+} {-1 0 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31}
+
+finish_test
diff --git a/test/fts2b.test b/test/fts2b.test
new file mode 100644
index 0000000..169cd8a
--- /dev/null
+++ b/test/fts2b.test
@@ -0,0 +1,147 @@
+# 2006 September 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS2 module.
+#
+# $Id: fts2b.test,v 1.1 2006/10/19 23:36:26 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+# Fill the full-text index "t1" with phrases in english, spanish,
+# and german. For the i-th row, fill in the names for the bits
+# that are set in the value of i. The least significant bit is
+# 1. For example, the value 5 is 101 in binary which will be
+# converted to "one three" in english.
+#
+proc fill_multilanguage_fulltext_t1 {} {
+ set english {one two three four five}
+ set spanish {un dos tres cuatro cinco}
+ set german {eine zwei drei vier funf}
+
+ for {set i 1} {$i<=31} {incr i} {
+ set cmd "INSERT INTO t1 VALUES"
+ set vset {}
+ foreach lang {english spanish german} {
+ set words {}
+ for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
+ if {$k&$i} {lappend words [lindex [set $lang] $j]}
+ }
+ lappend vset "'$words'"
+ }
+ set sql "INSERT INTO t1(english,spanish,german) VALUES([join $vset ,])"
+ # puts $sql
+ db eval $sql
+ }
+}
+
+# Construct a full-text search table containing five keywords:
+# one, two, three, four, and five, in various combinations. The
+# rowid for each will be a bitmask for the elements it contains.
+#
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(english,spanish,german);
+}
+fill_multilanguage_fulltext_t1
+
+do_test fts2b-1.1 {
+ execsql {SELECT rowid FROM t1 WHERE english MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts2b-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE spanish MATCH 'one'}
+} {}
+do_test fts2b-1.3 {
+ execsql {SELECT rowid FROM t1 WHERE german MATCH 'one'}
+} {}
+do_test fts2b-1.4 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts2b-1.5 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one dos drei'}
+} {7 15 23 31}
+do_test fts2b-1.6 {
+ execsql {SELECT english, spanish, german FROM t1 WHERE rowid=1}
+} {one un eine}
+do_test fts2b-1.7 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"one un"'}
+} {}
+
+do_test fts2b-2.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t2 USING fts2(from,to);
+ INSERT INTO t2([from],[to]) VALUES ('one two three', 'four five six');
+ SELECT [from], [to] FROM t2
+ }
+} {{one two three} {four five six}}
+
+
+# Compute an SQL string that contains the words one, two, three,... to
+# describe bits set in the value $i. Only the lower 5 bits are examined.
+#
+proc wordset {i} {
+ set x {}
+ for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
+ if {$k&$i} {lappend x [lindex {one two three four five} $j]}
+ }
+ return '$x'
+}
+
+# Create a new FTS table with three columns:
+#
+# norm: words for the bits of rowid
+# plusone: words for the bits of rowid+1
+# invert: words for the bits of ~rowid
+#
+db eval {
+ CREATE VIRTUAL TABLE t4 USING fts2([norm],'plusone',"invert");
+}
+for {set i 1} {$i<=15} {incr i} {
+ set vset [list [wordset $i] [wordset [expr {$i+1}]] [wordset [expr {~$i}]]]
+ db eval "INSERT INTO t4(norm,plusone,invert) VALUES([join $vset ,]);"
+}
+
+do_test fts2b-4.1 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one'}
+} {1 3 5 7 9 11 13 15}
+do_test fts2b-4.2 {
+ execsql {SELECT rowid FROM t4 WHERE norm MATCH 'one'}
+} {1 3 5 7 9 11 13 15}
+do_test fts2b-4.3 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'one'}
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}
+do_test fts2b-4.4 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:one'}
+} {2 4 6 8 10 12 14}
+do_test fts2b-4.5 {
+ execsql {SELECT rowid FROM t4 WHERE plusone MATCH 'one'}
+} {2 4 6 8 10 12 14}
+do_test fts2b-4.6 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one plusone:two'}
+} {1 5 9 13}
+do_test fts2b-4.7 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one two'}
+} {1 3 5 7 9 11 13 15}
+do_test fts2b-4.8 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:two norm:one'}
+} {1 5 9 13}
+do_test fts2b-4.9 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'two norm:one'}
+} {1 3 5 7 9 11 13 15}
+
+
+finish_test
diff --git a/test/fts2c.test b/test/fts2c.test
new file mode 100644
index 0000000..cc6c9bb
--- /dev/null
+++ b/test/fts2c.test
@@ -0,0 +1,1213 @@
+# 2006 September 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS2 module.
+#
+# $Id: fts2c.test,v 1.1 2006/10/19 23:36:26 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+# Create a table of sample email data. The data comes from email
+# archives of Enron executives that was published as part of the
+# litigation against that company.
+#
+do_test fts2c-1.1 {
+ db eval {
+ CREATE VIRTUAL TABLE email USING fts2([from],[to],subject,body);
+ BEGIN TRANSACTION;
+INSERT INTO email([from],[to],subject,body) VALUES('savita.puthigai@enron.com', 'traders.eol@enron.com, traders.eol@enron.com', 'EnronOnline- Change to Autohedge', 'Effective Monday, October 22, 2001 the following changes will be made to the Autohedge functionality on EnronOnline.
+
+The volume on the hedge will now respect the minimum volume and volume increment settings on the parent product. See rules below:
+
+? If the transaction volume on the child is less than half of the parent''s minimum volume no hedge will occur.
+? If the transaction volume on the child is more than half the parent''s minimum volume but less than half the volume increment on the parent, the hedge will volume will be the parent''s minimum volume.
+? For all other volumes, the same rounding rules will apply based on the volume increment on the parent product.
+
+Please see example below:
+
+Parent''s Settings:
+Minimum: 5000
+Increment: 1000
+
+Volume on Autohedge transaction Volume Hedged
+1 - 2499 0
+2500 - 5499 5000
+5500 - 6499 6000');
+INSERT INTO email([from],[to],subject,body) VALUES('dana.davis@enron.com', 'laynie.east@enron.com, lisa.king@enron.com, lisa.best@enron.com,', 'Leaving Early', 'FYI:
+If it''s ok with everyone''s needs, I would like to leave @4pm. If you think
+you will need my assistance past the 4 o''clock hour just let me know; I''ll
+be more than willing to stay.');
+INSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'louise.kitchen@enron.com', '<<Concur Expense Document>> - CC02.06.02', 'The following expense report is ready for approval:
+
+Employee Name: Christopher F. Calger
+Status last changed by: Mollie E. Gustafson Ms
+Expense Report Name: CC02.06.02
+Report Total: $3,972.93
+Amount Due Employee: $3,972.93
+
+
+To approve this expense report, click on the following link for Concur Expense.
+http://expensexms.enron.com');
+INSERT INTO email([from],[to],subject,body) VALUES('jeff.duff@enron.com', 'julie.johnson@enron.com', 'Work request', 'Julie,
+
+Could you print off the current work request report by 1:30 today?
+
+Gentlemen,
+
+I''d like to review this today at 1:30 in our office. Also, could you provide
+me with your activity reports so I can have Julie enter this information.
+
+JD');
+INSERT INTO email([from],[to],subject,body) VALUES('v.weldon@enron.com', 'gary.l.carrier@usa.dupont.com, scott.joyce@bankofamerica.com', 'Enron News', 'This could turn into something big....
+http://biz.yahoo.com/rf/010129/n29305829.html');
+INSERT INTO email([from],[to],subject,body) VALUES('mark.haedicke@enron.com', 'paul.simons@enron.com', 'Re: First Polish Deal!', 'Congrats! Things seem to be building rapidly now on the Continent. Mark');
+INSERT INTO email([from],[to],subject,body) VALUES('e..carter@enron.com', 't..robinson@enron.com', 'FW: Producers Newsletter 9-24-2001', '
+The producer lumber pricing sheet.
+ -----Original Message-----
+From: Johnson, Jay
+Sent: Tuesday, October 16, 2001 3:42 PM
+To: Carter, Karen E.
+Subject: FW: Producers Newsletter 9-24-2001
+
+
+
+ -----Original Message-----
+From: Daigre, Sergai
+Sent: Friday, September 21, 2001 8:33 PM
+Subject: Producers Newsletter 9-24-2001
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('david.delainey@enron.com', 'kenneth.lay@enron.com', 'Greater Houston Partnership', 'Ken, in response to the letter from Mr Miguel San Juan, my suggestion would
+be to offer up the Falcon for their use; however, given the tight time frame
+and your recent visit with Mr. Fox that it would be difficult for either you
+or me to participate.
+
+I spoke to Max and he agrees with this approach.
+
+I hope this meets with your approval.
+
+Regards
+Delainey');
+INSERT INTO email([from],[to],subject,body) VALUES('lachandra.fenceroy@enron.com', 'lindy.donoho@enron.com', 'FW: Bus Applications Meeting Follow Up', 'Lindy,
+
+Here is the original memo we discussed earlier. Please provide any information that you may have.
+
+Your cooperation is greatly appreciated.
+
+Thanks,
+
+lachandra.fenceroy@enron.com
+713.853.3884
+877.498.3401 Pager
+
+ -----Original Message-----
+From: Bisbee, Joanne
+Sent: Wednesday, September 26, 2001 7:50 AM
+To: Fenceroy, LaChandra
+Subject: FW: Bus Applications Meeting Follow Up
+
+Lachandra, Please get with David Duff today and see what this is about. Who are our TW accounting business users?
+
+ -----Original Message-----
+From: Koh, Wendy
+Sent: Tuesday, September 25, 2001 2:41 PM
+To: Bisbee, Joanne
+Subject: Bus Applications Meeting Follow Up
+
+Lisa brought up a TW change effective Nov 1. It involves eliminating a turnback surcharge. I have no other information, but you might check with the business folks for any system changes required.
+
+Wendy');
+INSERT INTO email([from],[to],subject,body) VALUES('danny.mccarty@enron.com', 'fran.fagan@enron.com', 'RE: worksheets', 'Fran,
+ If Julie''s merit needs to be lump sum, just move it over to that column. Also, send me Eric Gadd''s sheets as well. Thanks.
+Dan
+
+ -----Original Message-----
+From: Fagan, Fran
+Sent: Thursday, December 20, 2001 11:10 AM
+To: McCarty, Danny
+Subject: worksheets
+
+As discussed, attached are your sheets for bonus and merit.
+
+Thanks,
+
+Fran Fagan
+Sr. HR Rep
+713.853.5219
+
+
+ << File: McCartyMerit.xls >> << File: mccartyBonusCommercial_UnP.xls >>
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('bert.meyers@enron.com', 'shift.dl-portland@enron.com', 'OCTOBER SCHEDULE', 'TEAM,
+
+PLEASE SEND ME ANY REQUESTS THAT YOU HAVE FOR OCTOBER. SO FAR I HAVE THEM FOR LEAF. I WOULD LIKE TO HAVE IT DONE BY THE 15TH OF THE MONTH. ANY QUESTIONS PLEASE GIVE ME A CALL.
+
+BERT');
+INSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'john.arnold@enron.com, bilal.bajwa@enron.com, john.griffith@enron.com,', 'TRV Notification: (NG - PROPT P/L - 09/27/2001)', 'The report named: NG - PROPT P/L <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=11&report_name=NG+-+PROPT+P/L&category_cd=5&category_name=FINANCIAL&toc_hide=1&sTV1=5&TV1Exp=Y&current_efct_date=09/27/2001>, published as of 09/27/2001 is now available for viewing on the website.');
+INSERT INTO email([from],[to],subject,body) VALUES('patrice.mims@enron.com', 'calvin.eakins@enron.com', 'Re: Small business supply assistance', 'Hi Calvin
+
+
+I spoke with Rickey (boy, is he long-winded!!). Gave him the name of our
+credit guy, Russell Diamond.
+
+Thank for your help!');
+INSERT INTO email([from],[to],subject,body) VALUES('legal <.hall@enron.com>', 'stephanie.panus@enron.com', 'Termination update', 'City of Vernon and Salt River Project terminated their contracts. I will fax these notices to you.');
+INSERT INTO email([from],[to],subject,body) VALUES('d..steffes@enron.com', 'richard.shapiro@enron.com', 'EES / ENA Government Affairs Staffing & Outside Services', 'Rick --
+
+Here is the information on staffing and outside services. Call if you need anything else.
+
+Jim
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('gelliott@industrialinfo.com', 'pcopello@industrialinfo.com', 'ECAAR (Gavin), WSCC (Diablo Canyon), & NPCC (Seabrook)', 'Dear Power Outage Database Customer,
+Attached you will find an excel document. The outages contained within are forced or rescheduled outages. Your daily delivery will still contain these outages.
+In addition to the two excel documents, there is a dbf file that is formatted like your daily deliveries you receive nightly. This will enable you to load the data into your regular database. Any questions please let me know. Thanks.
+Greg Elliott
+IIR, Inc.
+713-783-5147 x 3481
+outages@industrialinfo.com
+THE INFORMATION CONTAINED IN THIS E-MAIL IS LEGALLY PRIVILEGED AND CONFIDENTIAL INFORMATION INTENDED ONLY FOR THE USE OF THE INDIVIDUAL OR ENTITY NAMED ABOVE. YOU ARE HEREBY NOTIFIED THAT ANY DISSEMINATION, DISTRIBUTION, OR COPY OF THIS E-MAIL TO UNAUTHORIZED ENTITIES IS STRICTLY PROHIBITED. IF YOU HAVE RECEIVED THIS
+E-MAIL IN ERROR, PLEASE DELETE IT.
+ - OUTAGE.dbf
+ - 111201R.xls
+ - 111201.xls ');
+INSERT INTO email([from],[to],subject,body) VALUES('enron.announcements@enron.com', 'all_ena_egm_eim@enron.com', 'EWS Brown Bag', 'MARK YOUR LUNCH CALENDARS NOW !
+
+You are invited to attend the EWS Brown Bag Lunch Series
+
+Featuring: RAY BOWEN, COO
+
+Topic: Enron Industrial Markets
+
+Thursday, March 15, 2001
+11:30 am - 12:30 pm
+EB 5 C2
+
+
+You bring your lunch, Limited Seating
+We provide drinks and dessert. RSVP x 3-9610');
+INSERT INTO email([from],[to],subject,body) VALUES('chris.germany@enron.com', 'ingrid.immer@williams.com', 'Re: About St Pauls', 'Sounds good to me. I bet this is next to the Warick?? Hotel.
+
+
+
+
+"Immer, Ingrid" <Ingrid.Immer@Williams.com> on 12/21/2000 11:48:47 AM
+To: "''chris.germany@enron.com''" <chris.germany@enron.com>
+cc:
+Subject: About St Pauls
+
+
+
+
+ <<About St Pauls.url>>
+?
+?http://www.stpaulshouston.org/about.html
+
+Chris,
+
+I like the looks of this place.? What do you think about going here Christmas
+eve?? They have an 11:00 a.m. service and a candlelight service at 5:00 p.m.,
+among others.
+
+Let me know.?? ii
+
+ - About St Pauls.url
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('nas@cpuc.ca.gov', 'skatz@sempratrading.com, kmccrea@sablaw.com, thompson@wrightlaw.com,', 'Reply Brief filed July 31, 2000', ' - CPUC01-#76371-v1-Revised_Reply_Brief__Due_today_7_31_.doc');
+INSERT INTO email([from],[to],subject,body) VALUES('gascontrol@aglresources.com', 'dscott4@enron.com, lcampbel@enron.com', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder
+As discussed in the Winter Operations Meeting on Sept.29,2000,
+E-Gas(Emergency Gas) will not be offered this winter as a service from AGLC.
+Marketers and Poolers can receive gas via Peaking and IBSS nominations(daisy
+chain) from other marketers up to the 6 p.m. Same Day 2 nomination cycle.
+');
+INSERT INTO email([from],[to],subject,body) VALUES('dutch.quigley@enron.com', 'rwolkwitz@powermerchants.com', '', '
+
+Here is a goody for you');
+INSERT INTO email([from],[to],subject,body) VALUES('ryan.o''rourke@enron.com', 'k..allen@enron.com, randy.bhatia@enron.com, frank.ermis@enron.com,', 'TRV Notification: (West VaR - 11/07/2001)', 'The report named: West VaR <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=36&report_name=West+VaR&category_cd=2&category_name=WEST&toc_hide=1&sTV1=2&TV1Exp=Y&current_efct_date=11/07/2001>, published as of 11/07/2001 is now available for viewing on the website.');
+INSERT INTO email([from],[to],subject,body) VALUES('mjones7@txu.com', 'cstone1@txu.com, ggreen2@txu.com, timpowell@txu.com,', 'Enron / HPL Actuals for July 10, 2000', 'Teco Tap 10.000 / Enron ; 110.000 / HPL IFERC
+
+LS HPL LSK IC 30.000 / Enron
+');
+INSERT INTO email([from],[to],subject,body) VALUES('susan.pereira@enron.com', 'kkw816@aol.com', 'soccer practice', 'Kathy-
+
+Is it safe to assume that practice is cancelled for tonight??
+
+Susan Pereira');
+INSERT INTO email([from],[to],subject,body) VALUES('mark.whitt@enron.com', 'barry.tycholiz@enron.com', 'Huber Internal Memo', 'Please look at this. I didn''t know how deep to go with the desk. Do you think this works.
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('m..forney@enron.com', 'george.phillips@enron.com', '', 'George,
+Give me a call and we will further discuss opportunities on the 13st floor.
+
+Thanks,
+JMForney
+3-7160');
+INSERT INTO email([from],[to],subject,body) VALUES('brad.mckay@enron.com', 'angusmcka@aol.com', 'Re: (no subject)', 'not yet');
+INSERT INTO email([from],[to],subject,body) VALUES('adam.bayer@enron.com', 'jonathan.mckay@enron.com', 'FW: Curve Fetch File', 'Here is the curve fetch file sent to me. It has plenty of points in it. If you give me a list of which ones you need we may be able to construct a secondary worksheet to vlookup the values.
+
+adam
+35227
+
+
+ -----Original Message-----
+From: Royed, Jeff
+Sent: Tuesday, September 25, 2001 11:37 AM
+To: Bayer, Adam
+Subject: Curve Fetch File
+
+Let me know if it works. It may be required to have a certain version of Oracle for it to work properly.
+
+
+
+Jeff Royed
+Enron
+Energy Operations
+Phone: 713-853-5295');
+INSERT INTO email([from],[to],subject,body) VALUES('matt.smith@enron.com', 'yan.wang@enron.com', 'Report Formats', 'Yan,
+
+The merged reports look great. I believe the only orientation changes are to
+"unmerge" the following six reports:
+
+31 Keystone Receipts
+15 Questar Pipeline
+40 Rockies Production
+22 West_2
+23 West_3
+25 CIG_WIC
+
+The orientation of the individual reports should be correct. Thanks.
+
+Mat
+
+PS. Just a reminder to add the "*" by the title of calculated points.');
+INSERT INTO email([from],[to],subject,body) VALUES('michelle.lokay@enron.com', 'jimboman@bigfoot.com', 'Egyptian Festival', '---------------------- Forwarded by Michelle Lokay/ET&S/Enron on 09/07/2000
+10:08 AM ---------------------------
+
+
+"Karkour, Randa" <Randa.Karkour@COMPAQ.com> on 09/07/2000 09:01:04 AM
+To: "''Agheb (E-mail)" <Agheb@aol.com>, "Leila Mankarious (E-mail)"
+<Leila_Mankarious@mhhs.org>, "''Marymankarious (E-mail)"
+<marymankarious@aol.com>, "Michelle lokay (E-mail)" <mlokay@enron.com>, "Ramy
+Mankarious (E-mail)" <Mankarious@aol.com>
+cc:
+
+Subject: Egyptian Festival
+
+
+ <<Egyptian Festival.url>>
+
+ http://www.egyptianfestival.com/
+
+ - Egyptian Festival.url
+');
+INSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'sherry.dawson@enron.com', 'Urgent!!! --- New EAST books', 'This has to be done..................................
+
+Thanks
+---------------------- Forwarded by Errol McLaughlin/Corp/Enron on 12/20/2000
+08:39 AM ---------------------------
+
+
+
+ From: William Kelly @ ECT 12/20/2000 08:31 AM
+
+
+To: Kam Keiser/HOU/ECT@ECT, Darron C Giron/HOU/ECT@ECT, David
+Baumbach/HOU/ECT@ECT, Errol McLaughlin/Corp/Enron@ENRON
+cc: Kimat Singla/HOU/ECT@ECT, Kulvinder Fowler/NA/Enron@ENRON, Kyle R
+Lilly/HOU/ECT@ECT, Jeff Royed/Corp/Enron@ENRON, Alejandra
+Chavez/NA/Enron@ENRON, Crystal Hyde/HOU/ECT@ECT
+
+Subject: New EAST books
+
+We have new book names in TAGG for our intramonth portfolios and it is
+extremely important that any deal booked to the East is communicated quickly
+to someone on my team. I know it will take some time for the new names to
+sink in and I do not want us to miss any positions or P&L.
+
+Thanks for your help on this.
+
+New:
+Scott Neal : East Northeast
+Dick Jenkins: East Marketeast
+
+WK
+');
+INSERT INTO email([from],[to],subject,body) VALUES('david.forster@enron.com', 'eol.wide@enron.com', 'Change to Stack Manager', 'Effective immediately, there is a change to the Stack Manager which will
+affect any Inactive Child.
+
+An inactive Child with links to Parent products will not have their
+calculated prices updated until the Child product is Activated.
+
+When the Child Product is activated, the price will be recalculated and
+updated BEFORE it is displayed on the web.
+
+This means that if you are inputting a basis price on a Child product, you
+will not see the final, calculated price until you Activate the product, at
+which time the customer will also see it.
+
+If you have any questions, please contact the Help Desk on:
+
+Americas: 713 853 4357
+Europe: + 44 (0) 20 7783 7783
+Asia/Australia: +61 2 9229 2300
+
+Dave');
+INSERT INTO email([from],[to],subject,body) VALUES('vince.kaminski@enron.com', 'jhh1@email.msn.com', 'Re: Light reading - see pieces beginning on page 7', 'John,
+
+I saw it. Very interesting.
+
+Vince
+
+
+
+
+
+"John H Herbert" <jhh1@email.msn.com> on 07/28/2000 08:38:08 AM
+To: "Vince J Kaminski" <Vince_J_Kaminski@enron.com>
+cc:
+Subject: Light reading - see pieces beginning on page 7
+
+
+Cheers and have a nice weekend,
+
+
+JHHerbert
+
+
+
+
+ - gd000728.pdf
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('matthew.lenhart@enron.com', 'mmmarcantel@equiva.com', 'RE:', 'i will try to line up a pig for you ');
+INSERT INTO email([from],[to],subject,body) VALUES('jae.black@enron.com', 'claudette.harvey@enron.com, chaun.roberts@enron.com, judy.martinez@enron.com,', 'Disaster Recovery Equipment', 'As a reminder...there are several pieces of equipment that are set up on the 30th Floor, as well as on our floor, for the Disaster Recovery Team. PLEASE DO NOT TAKE, BORROW OR USE this equipment. Should you need to use another computer system, other than yours, or make conference calls please work with your Assistant to help find or set up equipment for you to use.
+
+Thanks for your understanding in this matter.
+
+T.Jae Black
+East Power Trading
+Assistant to Kevin Presto
+off. 713-853-5800
+fax 713-646-8272
+cell 713-539-4760');
+INSERT INTO email([from],[to],subject,body) VALUES('eric.bass@enron.com', 'dale.neuner@enron.com', '5 X 24', 'Dale,
+
+Have you heard anything more on the 5 X 24s? We would like to get this
+product out ASAP.
+
+
+Thanks,
+
+Eric');
+INSERT INTO email([from],[to],subject,body) VALUES('messenger@smartreminders.com', 'm..tholt@enron.com', '10% Coupon - PrintPal Printer Cartridges - 100% Guaranteed', '[IMAGE]
+[IMAGE][IMAGE][IMAGE]
+Dear SmartReminders Member,
+ [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+We respect your privacy and are a Certified Participant of the BBBOnLine
+ Privacy Program. To be removed from future offers,click here.
+SmartReminders.com is a permission based service. To unsubscribe click here . ');
+INSERT INTO email([from],[to],subject,body) VALUES('benjamin.rogers@enron.com', 'mark.bernstein@enron.com', '', 'The guy you are talking about left CIN under a "cloud of suspicion" sort of
+speak. He was the one who got into several bad deals and PPA''s in California
+for CIN, thus he left on a bad note. Let me know if you need more detail
+than that, I felt this was the type of info you were looking for. Thanks!
+Ben');
+INSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'michelle.cash@enron.com', 'Expense Report Receipts Not Received', 'Employee Name: Michelle Cash
+Report Name: Houston Cellular 8-11-01
+Report Date: 12/13/01
+Report ID: 594D37C9ED2111D5B452
+Submitted On: 12/13/01
+
+You are only allowed 2 reports with receipts outstanding. Your expense reports will not be paid until you meet this requirement.');
+INSERT INTO email([from],[to],subject,body) VALUES('susan.mara@enron.com', 'ray.alvarez@enron.com, mark.palmer@enron.com, karen.denne@enron.com,', 'CAISO Emergency Motion -- to discontinue market-based rates for', 'FYI. the latest broadside against the generators.
+
+Sue Mara
+Enron Corp.
+Tel: (415) 782-7802
+Fax:(415) 782-7854
+----- Forwarded by Susan J Mara/NA/Enron on 06/08/2001 12:24 PM -----
+
+
+ "Milner, Marcie" <MMilner@coral-energy.com> 06/08/2001 11:13 AM To: "''smara@enron.com''" <smara@enron.com> cc: Subject: CAISO Emergency Motion
+
+
+Sue, did you see this emergency motion the CAISO filed today? Apparently
+they are requesting that FERC discontinue market-based rates immediately and
+grant refunds plus interest on the difference between cost-based rates and
+market revenues received back to May 2000. They are requesting the
+commission act within 14 days. Have you heard anything about what they are
+doing?
+
+Marcie
+
+http://www.caiso.com/docs/2001/06/08/200106081005526469.pdf
+');
+INSERT INTO email([from],[to],subject,body) VALUES('fletcher.sturm@enron.com', 'eloy.escobar@enron.com', 'Re: General Brinks Position Meeting', 'Eloy,
+
+Who is General Brinks?
+
+Fletch');
+INSERT INTO email([from],[to],subject,body) VALUES('nailia.dindarova@enron.com', 'richard.shapiro@enron.com', 'Documents for Mark Frevert (on EU developments and lessons from', 'Rick,
+
+Here are the documents that Peter has prepared for Mark Frevert.
+
+Nailia
+---------------------- Forwarded by Nailia Dindarova/LON/ECT on 25/06/2001
+16:36 ---------------------------
+
+
+Nailia Dindarova
+25/06/2001 15:36
+To: Michael Brown/Enron@EUEnronXGate
+cc: Ross Sankey/Enron@EUEnronXGate, Eric Shaw/ENRON@EUEnronXGate, Peter
+Styles/LON/ECT@ECT
+
+Subject: Documents for Mark Frevert (on EU developments and lessons from
+California)
+
+Michael,
+
+
+These are the documents that Peter promised to give to you for Mark Frevert.
+He has now handed them to him in person but asked me to transmit them
+electronically to you, as well as Eric and Ross.
+
+Nailia
+
+
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('peggy.a.kostial@accenture.com', 'dave.samuels@enron.com', 'EOL-Accenture Deal Sheet', 'Dave -
+
+Attached are our comments and suggested changes. Please call to review.
+
+On the time line for completion, we have four critical steps to complete:
+ Finalize market analysis to refine business case, specifically
+ projected revenue stream
+ Complete counterparty surveying, including targeting 3 CPs for letters
+ of intent
+ Review Enron asset base for potential reuse/ licensing
+ Contract negotiations
+
+Joe will come back to us with an updated time line, but it is my
+expectation that we are still on the same schedule (we just begun week
+three) with possibly a week or so slippage.....contract negotiations will
+probably be the critical path.
+
+We will send our cut at the actual time line here shortly. Thanks,
+
+Peggy
+
+(See attached file: accenture-dealpoints v2.doc)
+ - accenture-dealpoints v2.doc ');
+INSERT INTO email([from],[to],subject,body) VALUES('thomas.martin@enron.com', 'thomas.martin@enron.com', 'Re: Guadalupe Power Partners LP', '---------------------- Forwarded by Thomas A Martin/HOU/ECT on 03/20/2001
+03:49 PM ---------------------------
+
+
+Thomas A Martin
+10/11/2000 03:55 PM
+To: Patrick Wade/HOU/ECT@ECT
+cc:
+Subject: Re: Guadalupe Power Partners LP
+
+The deal is physically served at Oasis Waha or Oasis Katy and is priced at
+either HSC, Waha or Katytailgate GD at buyers option three days prior to
+NYMEX close.
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('judy.townsend@enron.com', 'dan.junek@enron.com, chris.germany@enron.com', 'Columbia Distribution''s Capacity Available for Release - Sum', '---------------------- Forwarded by Judy Townsend/HOU/ECT on 03/09/2001 11:04
+AM ---------------------------
+
+
+agoddard@nisource.com on 03/08/2001 09:16:57 AM
+To: " - *Koch, Kent" <kkoch@nisource.com>, " -
+*Millar, Debra" <dmillar@nisource.com>, " - *Burke, Lynn"
+<lburke@nisource.com>
+cc: " - *Heckathorn, Tom" <theckathorn@nisource.com>
+Subject: Columbia Distribution''s Capacity Available for Release - Sum
+
+
+Attached is Columbia Distribution''s notice of capacity available for release
+for
+the summer of 2001 (Apr. 2001 through Oct. 2001).
+
+Please note that the deadline for bids is 3:00pm EST on March 20, 2001.
+
+If you have any questions, feel free to contact any of the representatives
+listed
+at the bottom of the attachment.
+
+Aaron Goddard
+
+
+
+
+ - 2001Summer.doc
+');
+INSERT INTO email([from],[to],subject,body) VALUES('rhonda.denton@enron.com', 'tim.belden@enron.com, dana.davis@enron.com, genia.fitzgerald@enron.com,', 'Split Rock Energy LLC', 'We have received the executed EEI contract from this CP dated 12/12/2000.
+Copies will be distributed to Legal and Credit.');
+INSERT INTO email([from],[to],subject,body) VALUES('kerrymcelroy@dwt.com', 'jack.speer@alcoa.com, crow@millernash.com, michaelearly@earthlink.net,', 'Oral Argument Request', ' - Oral Argument Request.doc');
+INSERT INTO email([from],[to],subject,body) VALUES('mike.carson@enron.com', 'rlmichaelis@hormel.com', '', 'Did you come in town this wk end..... My new number at our house is :
+713-668-3712...... my cell # is 281-381-7332
+
+the kid');
+INSERT INTO email([from],[to],subject,body) VALUES('cooper.richey@enron.com', 'trycooper@hotmail.com', 'FW: Contact Info', '
+
+-----Original Message-----
+From: Punja, Karim
+Sent: Thursday, December 13, 2001 2:35 PM
+To: Richey, Cooper
+Subject: Contact Info
+
+
+Cooper,
+
+Its been a real pleasure working with you (even though it was for only a small amount of time)
+I hope we can stay in touch.
+
+Home# 234-0249
+email: kpunja@hotmail.com
+
+Take Care,
+
+Karim.
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('bjm30@earthlink.net', 'mcguinn.k@enron.com, mcguinn.ian@enron.com, mcguinn.stephen@enron.com,', 'email address change', 'Hello all.
+
+I haven''t talked to many of you via email recently but I do want to give you
+my new address for your email file:
+
+ bjm30@earthlink.net
+
+I hope all is well.
+
+Brian McGuinn');
+INSERT INTO email([from],[to],subject,body) VALUES('shelley.corman@enron.com', 'steve.hotte@enron.com', 'Flat Panels', 'Can you please advise what is going on with the flat panels that we had planned to distribute to our gas logistics team. It was in the budget and we had the okay, but now I''m hearing there is some hold-up & the units are stored on 44.
+
+Shelley');
+INSERT INTO email([from],[to],subject,body) VALUES('sara.davidson@enron.com', 'john.schwartzenburg@enron.com, scott.dieball@enron.com, recipients@enron.com,', '2001 Enron Law Conference (Distribution List 2)', ' Enron Law Conference
+
+San Antonio, Texas May 2-4, 2001 Westin Riverwalk
+
+ See attached memo for more details!!
+
+
+? Registration for the law conference this year will be handled through an
+Online RSVP Form on the Enron Law Conference Website at
+http://lawconference.corp.enron.com. The website is still under construction
+and will not be available until Thursday, March 15, 2001.
+
+? We will send you another e-mail to confirm when the Law Conference Website
+is operational.
+
+? Please complete the Online RSVP Form as soon as it is available and submit
+it no later than Friday, March 30th.
+
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('tori.kuykendall@enron.com', 'heath.b.taylor@accenture.com', 'Re:', 'hey - thats funny about john - he definitely remembers him - i''ll call pat
+and let him know - we are coming on saturday - i just havent had a chance to
+call you guys back -- looking forward to it -- i probably need the
+directions again though');
+INSERT INTO email([from],[to],subject,body) VALUES('darron.giron@enron.com', 'bryce.baxter@enron.com', 'Re: Feedback for Audrey Cook', 'Bryce,
+
+I''ll get it done today.
+
+DG 3-9573
+
+
+
+
+
+ From: Bryce Baxter 06/12/2000 07:15 PM
+
+
+To: Darron C Giron/HOU/ECT@ECT
+cc:
+Subject: Feedback for Audrey Cook
+
+You were identified as a reviewer for Audrey Cook. If possible, could you
+complete her feedback by end of business Wednesday? It will really help me
+in the PRC process to have your input. Thanks.
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('casey.evans@enron.com', 'stephanie.sever@enron.com', 'Gas EOL ID', 'Stephanie,
+
+In conjunction with the recent movement of several power traders, they are changing the names of their gas books as well. The names of the new gas books and traders are as follows:
+
+PWR-NG-LT-SPP: Mike Carson
+PWR-NG-LT-SERC: Jeff King
+
+If you need to know their power desk to map their ID to their gas books, those desks are as follows:
+
+EPMI-LT-SPP: Mike Carson
+EPMI-LT-SERC: Jeff King
+
+I will be in training this afternoon, but will be back when class is over. Let me know if you have any questions.
+
+Thanks for your help!
+Casey');
+INSERT INTO email([from],[to],subject,body) VALUES('darrell.schoolcraft@enron.com', 'david.roensch@enron.com, kimberly.watson@enron.com, michelle.lokay@enron.com,', 'Postings', 'Please see the attached.
+
+
+ds
+
+
+
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('mcominsky@aol.com', 'cpatman@bracepatt.com, james_derrick@enron.com', 'Jurisprudence Luncheon', 'Carrin & Jim --
+
+It was an honor and a pleasure to meet both of you yesterday. I know we will
+have fun working together on this very special event.
+
+Jeff left the jurisprudence luncheon lists for me before he left on vacation.
+ I wasn''t sure whether he transmitted them to you as well. Would you please
+advise me if you would like them sent to you? I can email the MS Excel files
+or I can fax the hard copies to you. Please advise what is most convenient.
+
+I plan to be in town through the holidays and can be reached by phone, email,
+or cell phone at any time. My cell phone number is 713/705-4829.
+
+Thanks again for your interest in the ADL''s work. Martin.
+
+Martin B. Cominsky
+Director, Southwest Region
+Anti-Defamation League
+713/627-3490, ext. 122
+713/627-2011 (fax)
+MCominsky@aol.com');
+INSERT INTO email([from],[to],subject,body) VALUES('phillip.love@enron.com', 'todagost@utmb.edu, gbsonnta@utmb.edu', 'New President', 'I had a little bird put a word in my ear. Is there any possibility for Ben
+Raimer to be Bush''s secretary of HHS? Just curious about that infamous UTMB
+rumor mill. Hope things are well, happy holidays.
+PL');
+INSERT INTO email([from],[to],subject,body) VALUES('marie.heard@enron.com', 'ehamilton@fna.com', 'ISDA Master Agreement', 'Erin:
+
+Pursuant to your request, attached are the Schedule to the ISDA Master Agreement, together with Paragraph 13 to the ISDA Credit Support Annex. Please let me know if you need anything else. We look forward to hearing your comments.
+
+Marie
+
+Marie Heard
+Senior Legal Specialist
+Enron North America Corp.
+Phone: (713) 853-3907
+Fax: (713) 646-3490
+marie.heard@enron.com
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('andrea.ring@enron.com', 'beverly.beaty@enron.com', 'Re: Tennessee Buy - Louis Dreyfus', 'Beverly - once again thanks so much for your help on this.
+
+
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('karolyn.criado@enron.com', 'j..bonin@enron.com, felicia.case@enron.com, b..clapp@enron.com,', 'Price List week of Oct. 8-9, 2001', '
+Please contact me if you have any questions regarding last weeks prices.
+
+Thank you,
+Karolyn Criado
+3-9441
+
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('kevin.presto@enron.com', 'edward.baughman@enron.com, billy.braddock@enron.com', 'Associated', 'Please begin working on filling our Associated short position in 02. I would like to take this risk off the books.
+
+In addition, please find out what a buy-out of VEPCO would cost us. With Rogers transitioning to run our retail risk management, I would like to clean up our customer positions.
+
+We also need to continue to explore a JEA buy-out.
+
+Thanks.');
+INSERT INTO email([from],[to],subject,body) VALUES('stacy.dickson@enron.com', 'gregg.penman@enron.com', 'RE: Constellation TC 5-7-01', 'Gregg,
+
+I am at home with a sick baby. (Lots of fun!) I will call you about this
+tomorrow.
+
+Stacy');
+INSERT INTO email([from],[to],subject,body) VALUES('joe.quenet@enron.com', 'dfincher@utilicorp.com', '', 'hey big guy.....check this out.....
+
+ w ww.gorelieberman-2000.com/');
+INSERT INTO email([from],[to],subject,body) VALUES('k..allen@enron.com', 'jacqestc@aol.com', '', 'Jacques,
+
+I sent you a fax of Kevin Kolb''s comments on the release. The payoff on the note would be $36,248 ($36090(principal) + $158 (accrued interest)).
+This is assuming we wrap this up on Tuesday.
+
+Please email to confirm that their changes are ok so I can set up a meeting on Tuesday to reach closure.
+
+Phillip');
+INSERT INTO email([from],[to],subject,body) VALUES('kourtney.nelson@enron.com', 'mike.swerzbin@enron.com', 'Adjusted L/R Balance', 'Mike,
+
+I placed the adjusted L/R Balance on the Enronwest site. It is under the "Staff/Kourtney Nelson". There are two links:
+
+1) "Adj L_R" is the same data/format from the weekly strategy meeting.
+2) "New Gen 2001_2002" link has all of the supply side info that is used to calculate the L/R balance
+ -Please note the Data Flag column, a value of "3" indicates the project was cancelled, on hold, etc and is not included in the calc.
+
+Both of these sheets are interactive Excel spreadsheets and thus you can play around with the data as you please. Also, James Bruce is working to get his gen report on the web. That will help with your access to information on new gen.
+
+Please let me know if you have any questions or feedback,
+
+Kourtney
+
+
+
+Kourtney Nelson
+Fundamental Analysis
+Enron North America
+(503) 464-8280
+kourtney.nelson@enron.com');
+INSERT INTO email([from],[to],subject,body) VALUES('d..thomas@enron.com', 'naveed.ahmed@enron.com', 'FW: Current Enron TCC Portfolio', '
+
+-----Original Message-----
+From: Grace, Rebecca M.
+Sent: Monday, December 17, 2001 9:44 AM
+To: Thomas, Paul D.
+Cc: Cashion, Jim; Allen, Thresa A.; May, Tom
+Subject: RE: Current Enron TCC Portfolio
+
+
+Paul,
+
+I reviewed NY''s list. I agree with all of their contracts numbers and mw amounts.
+
+Call if you have any more questions.
+
+Rebecca
+
+
+
+ -----Original Message-----
+From: Thomas, Paul D.
+Sent: Monday, December 17, 2001 9:08 AM
+To: Grace, Rebecca M.
+Subject: FW: Current Enron TCC Portfolio
+
+ << File: enrontccs.xls >>
+Rebecca,
+Let me know if you see any differences.
+
+Paul
+X 3-0403
+-----Original Message-----
+From: Thomas, Paul D.
+Sent: Monday, December 17, 2001 9:04 AM
+To: Ahmed, Naveed
+Subject: FW: Current Enron TCC Portfolio
+
+
+
+
+-----Original Message-----
+From: Thomas, Paul D.
+Sent: Thursday, December 13, 2001 10:01 AM
+To: Baughman, Edward D.
+Subject: Current Enron TCC Portfolio
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('stephanie.panus@enron.com', 'william.bradford@enron.com, debbie.brackett@enron.com,', 'Coastal Merchant Energy/El Paso Merchant Energy', 'Coastal Merchant Energy, L.P. merged with and into El Paso Merchant Energy,
+L.P., effective February 1, 2001, with the surviving entity being El Paso
+Merchant Energy, L.P. We currently have ISDA Master Agreements with both
+counterparties. Please see the attached memo regarding the existing Masters
+and let us know which agreement should be terminated.
+
+Thanks,
+Stephanie
+');
+INSERT INTO email([from],[to],subject,body) VALUES('kam.keiser@enron.com', 'c..kenne@enron.com', 'RE: What about this too???', '
+
+ -----Original Message-----
+From: Kenne, Dawn C.
+Sent: Wednesday, February 06, 2002 11:50 AM
+To: Keiser, Kam
+Subject: What about this too???
+
+
+ << File: Netco Trader Matrix.xls >>
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('chris.meyer@enron.com', 'joe.parks@enron.com', 'Centana', 'Talked to Chip. We do need Cash Committe approval given the netting feature of your deal, which means Batch Funding Request. Please update per my previous e-mail and forward.
+
+Thanks
+
+chris
+x31666');
+INSERT INTO email([from],[to],subject,body) VALUES('debra.perlingiere@enron.com', 'jworman@academyofhealth.com', '', 'Have a great weekend! Happy Fathers Day!
+
+
+Debra Perlingiere
+Enron North America Corp.
+1400 Smith Street, EB 3885
+Houston, Texas 77002
+dperlin@enron.com
+Phone 713-853-7658
+Fax 713-646-3490');
+INSERT INTO email([from],[to],subject,body) VALUES('outlook.team@enron.com', '', 'Demo by Martha Janousek of Dashboard & Pipeline Profile / Julia &', 'CALENDAR ENTRY: APPOINTMENT
+
+Description:
+ Demo by Martha Janousek of Dashboard & Pipeline Profile / Julia & Dir Rpts. - 4102
+
+Date: 1/5/2001
+Time: 9:00 AM - 10:00 AM (Central Standard Time)
+
+Chairperson: Outlook Migration Team
+
+Detailed Description:');
+INSERT INTO email([from],[to],subject,body) VALUES('diana.seifert@enron.com', 'mark.taylor@enron.com', 'Guest access Chile', 'Hello Mark,
+
+Justin Boyd told me that your can help me with questions regarding Chile.
+We got a request for guest access through MG.
+The company is called Escondida and is a subsidiary of BHP Australia.
+
+Please advise if I can set up a guest account or not.
+F.Y.I.: MG is planning to put a "in w/h Chile" contract for Copper on-line as
+soon as Enron has done the due diligence for this country.
+Thanks !
+
+
+Best regards
+
+Diana Seifert
+EOL PCG');
+INSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'mark.whitt@enron.com', '<<Concur Expense Document>> - 121001', 'The Approval status has changed on the following report:
+
+Status last changed by: Barry L. Tycholiz
+Expense Report Name: 121001
+Report Total: $198.98
+Amount Due Employee: $198.98
+Amount Approved: $198.98
+Amount Paid: $0.00
+Approval Status: Approved
+Payment Status: Pending
+
+
+To review this expense report, click on the following link for Concur Expense.
+http://expensexms.enron.com');
+INSERT INTO email([from],[to],subject,body) VALUES('kevin.hyatt@enron.com', '', 'Technical Support', 'Outside the U.S., please refer to the list below:
+
+Australia:
+1800 678-515
+support@palm-au.com
+
+Canada:
+1905 305-6530
+support@palm.com
+
+New Zealand:
+0800 446-398
+support@palm-nz.com
+
+U.K.:
+0171 867 0108
+eurosupport@palm.3com.com
+
+Please refer to the Worldwide Customer Support card for a complete technical support contact list.');
+INSERT INTO email([from],[to],subject,body) VALUES('geoff.storey@enron.com', 'dutch.quigley@enron.com', 'RE:', 'duke contact?
+
+ -----Original Message-----
+From: Quigley, Dutch
+Sent: Wednesday, October 31, 2001 10:14 AM
+To: Storey, Geoff
+Subject: RE:
+
+bp corp Albert LaMore 281-366-4962
+
+running the reports now
+
+
+ -----Original Message-----
+From: Storey, Geoff
+Sent: Wednesday, October 31, 2001 10:10 AM
+To: Quigley, Dutch
+Subject: RE:
+
+give me a contact over there too
+BP
+
+
+ -----Original Message-----
+From: Quigley, Dutch
+Sent: Wednesday, October 31, 2001 9:42 AM
+To: Storey, Geoff
+Subject:
+
+Coral Jeff Whitnah 713-767-5374
+Relaint Steve McGinn 713-207-4000');
+INSERT INTO email([from],[to],subject,body) VALUES('pete.davis@enron.com', 'pete.davis@enron.com', 'Start Date: 4/22/01; HourAhead hour: 3; <CODESITE>', 'Start Date: 4/22/01; HourAhead hour: 3; No ancillary schedules awarded.
+Variances detected.
+Variances detected in Load schedule.
+
+ LOG MESSAGES:
+
+PARSING FILE -->> O:\Portland\WestDesk\California Scheduling\ISO Final
+Schedules\2001042203.txt
+
+---- Load Schedule ----
+$$$ Variance found in table tblLoads.
+ Details: (Hour: 3 / Preferred: 1.92 / Final: 1.89)
+ TRANS_TYPE: FINAL
+ LOAD_ID: PGE4
+ MKT_TYPE: 2
+ TRANS_DATE: 4/22/01
+ SC_ID: EPMI
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('john.postlethwaite@enron.com', 'john.zufferli@enron.com', 'Reference', 'John, hope things are going well up there for you. The big day is almost here for you and Jessica. I was wondering if I could use your name as a job reference if need be. I am just trying to get everything in order just in case something happens.
+
+John');
+INSERT INTO email([from],[to],subject,body) VALUES('jeffrey.shankman@enron.com', 'lschiffm@jonesday.com', 'Re:', 'I saw you called on the cell this a.m. Sorry I missed you. (I was in the
+shower). I have had a shitty week--I suspect my silence (not only to you,
+but others) after our phone call is a result of the week. I''m seeing Glen at
+11:15....talk to you');
+INSERT INTO email([from],[to],subject,body) VALUES('litebytz@enron.com', '', 'Lite Bytz RSVP', '
+This week''s Lite Bytz presentation will feature the following TOOLZ speaker:
+
+Richard McDougall
+Solaris 8
+Thursday, June 7, 2001
+
+If you have not already signed up, please RSVP via email to litebytz@enron.com by the end of the day Tuesday, June 5, 2001.
+
+*Remember: this is now a Brown Bag Event--so bring your lunch and we will provide cookies and drinks.
+
+Click below for more details.
+
+http://home.enron.com:84/messaging/litebytztoolzprint.jpg');
+ COMMIT;
+ }
+} {}
+
+###############################################################################
+# Everything above just builds an interesting test database. The actual
+# tests come after this comment.
+###############################################################################
+
+do_test fts2c-1.2 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark'
+ }
+} {6 17 25 38 40 42 73 74}
+do_test fts2c-1.3 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'susan'
+ }
+} {24 40}
+do_test fts2c-1.4 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark susan'
+ }
+} {40}
+do_test fts2c-1.5 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'susan mark'
+ }
+} {40}
+do_test fts2c-1.6 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH '"mark susan"'
+ }
+} {}
+do_test fts2c-1.7 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark -susan'
+ }
+} {6 17 25 38 42 73 74}
+do_test fts2c-1.8 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH '-mark susan'
+ }
+} {24}
+do_test fts2c-1.9 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark OR susan'
+ }
+} {6 17 24 25 38 40 42 73 74}
+
+# Some simple tests of the automatic "offsets(email)" column. In the sample
+# data set above, only one message, number 20, contains the words
+# "gas" and "reminder" in both body and subject.
+#
+do_test fts2c-2.1 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE email MATCH 'gas reminder'
+ }
+} {20 {2 0 42 3 2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}
+do_test fts2c-2.2 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE email MATCH 'subject:gas reminder'
+ }
+} {20 {2 0 42 3 2 1 54 8 3 1 54 8}}
+do_test fts2c-2.3 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE email MATCH 'body:gas reminder'
+ }
+} {20 {2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}
+do_test fts2c-2.4 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE subject MATCH 'gas reminder'
+ }
+} {20 {2 0 42 3 2 1 54 8}}
+do_test fts2c-2.5 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE body MATCH 'gas reminder'
+ }
+} {20 {3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}
+
+# Document 32 contains 5 instances of the world "child". But only
+# 3 of them are paired with "product". Make sure only those instances
+# that match the phrase appear in the offsets(email) list.
+#
+do_test fts2c-3.1 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE body MATCH 'child product' AND +rowid=32
+ }
+} {32 {3 0 94 5 3 0 114 5 3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7 3 1 493 7}}
+do_test fts2c-3.2 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE body MATCH '"child product"'
+ }
+} {32 {3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7}}
+
+# Snippet generator tests
+#
+do_test fts2c-4.1 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'subject:gas reminder'
+ }
+} {{Alert Posted 10:00 AM November 20,2000: E-<b>GAS</b> Request <b>Reminder</b>}}
+do_test fts2c-4.2 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'christmas candlelight'
+ }
+} {{<b>...</b> place.? What do you think about going here <b>Christmas</b>
+eve?? They have an 11:00 a.m. service and a <b>candlelight</b> service at 5:00 p.m.,
+among others. <b>...</b>}}
+
+do_test fts2c-4.3 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'deal sheet potential reuse'
+ }
+} {{EOL-Accenture <b>Deal</b> <b>Sheet</b> <b>...</b> intent
+ Review Enron asset base for <b>potential</b> <b>reuse</b>/ licensing
+ Contract negotiations <b>...</b>}}
+do_test fts2c-4.4 {
+ execsql {
+ SELECT snippet(email,'<<<','>>>',' ') FROM email
+ WHERE email MATCH 'deal sheet potential reuse'
+ }
+} {{EOL-Accenture <<<Deal>>> <<<Sheet>>> intent
+ Review Enron asset base for <<<potential>>> <<<reuse>>>/ licensing
+ Contract negotiations }}
+do_test fts2c-4.5 {
+ execsql {
+ SELECT snippet(email,'<<<','>>>',' ') FROM email
+ WHERE email MATCH 'first things'
+ }
+} {{Re: <<<First>>> Polish Deal! Congrats! <<<Things>>> seem to be building rapidly now on the }}
+do_test fts2c-4.6 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'chris is here'
+ }
+} {{<b>chris</b>.germany@enron.com <b>...</b> Sounds good to me. I bet this <b>is</b> next to the Warick?? Hotel. <b>...</b> place.? What do you think about going <b>here</b> Christmas
+eve?? They have an 11:00 a.m. <b>...</b>}}
+do_test fts2c-4.7 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH '"pursuant to"'
+ }
+} {{Erin:
+
+<b>Pursuant</b> <b>to</b> your request, attached are the Schedule to <b>...</b>}}
+do_test fts2c-4.8 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'ancillary load davis'
+ }
+} {{pete.<b>davis</b>@enron.com <b>...</b> Start Date: 4/22/01; HourAhead hour: 3; No <b>ancillary</b> schedules awarded.
+Variances detected.
+Variances detected in <b>Load</b> schedule.
+
+ LOG MESSAGES:
+
+PARSING <b>...</b>}}
+
+# Combinations of AND and OR operators:
+#
+do_test fts2c-5.1 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'questar enron OR com'
+ }
+} {{matt.smith@<b>enron</b>.<b>com</b> <b>...</b> six reports:
+
+31 Keystone Receipts
+15 <b>Questar</b> Pipeline
+40 Rockies Production
+22 West_2 <b>...</b>}}
+do_test fts2c-5.2 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'enron OR com questar'
+ }
+} {{matt.smith@<b>enron</b>.<b>com</b> <b>...</b> six reports:
+
+31 Keystone Receipts
+15 <b>Questar</b> Pipeline
+40 Rockies Production
+22 West_2 <b>...</b>}}
+
+finish_test
diff --git a/test/fts2d.test b/test/fts2d.test
new file mode 100644
index 0000000..d8090d8
--- /dev/null
+++ b/test/fts2d.test
@@ -0,0 +1,65 @@
+# 2006 October 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS2 module, and in particular
+# the Porter stemmer.
+#
+# $Id: fts2d.test,v 1.1 2006/10/19 23:36:26 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+do_test fts2d-1.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts2(content, tokenize porter);
+ INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
+ SELECT rowid FROM t1 WHERE content MATCH 'run jump';
+ }
+} {1}
+do_test fts2d-1.2 {
+ execsql {
+ SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'run jump';
+ }
+} {{<b>running</b> and <b>jumping</b>}}
+do_test fts2d-1.3 {
+ execsql {
+ INSERT INTO t1(rowid, content)
+ VALUES(2, 'abcdefghijklmnopqrstuvwyxz');
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijqrstuvwyxz'
+ }
+} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
+do_test fts2d-1.4 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'
+ }
+} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
+do_test fts2d-1.5 {
+ execsql {
+ INSERT INTO t1(rowid, content)
+ VALUES(3, 'The value is 123456789');
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123789'
+ }
+} {3 {The value is <b>123456789</b>}}
+do_test fts2d-1.6 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123000000789'
+ }
+} {3 {The value is <b>123456789</b>}}
+
+
+finish_test
diff --git a/test/fts2e.test b/test/fts2e.test
new file mode 100644
index 0000000..71845ac
--- /dev/null
+++ b/test/fts2e.test
@@ -0,0 +1,85 @@
+# 2006 October 19
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing deletions in the FTS2 module.
+#
+# $Id: fts2e.test,v 1.1 2006/10/19 23:36:26 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+# Construct a full-text search table containing keywords which are the
+# ordinal numbers of the bit positions set for a sequence of integers,
+# which are used for the rowid. There are a total of 30 INSERT and
+# DELETE statements, so that we'll test both the segmentMerge() merge
+# (over the first 16) and the termSelect() merge (over the level-1
+# segment and 14 level-0 segments).
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, 'one');
+ INSERT INTO t1 (rowid, content) VALUES(2, 'two');
+ INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
+ INSERT INTO t1 (rowid, content) VALUES(4, 'three');
+ DELETE FROM t1 WHERE rowid = 1;
+ INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
+ INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
+ INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
+ DELETE FROM t1 WHERE rowid = 4;
+ INSERT INTO t1 (rowid, content) VALUES(8, 'four');
+ INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
+ INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
+ DELETE FROM t1 WHERE rowid = 7;
+ INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
+ INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
+ INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
+ DELETE FROM t1 WHERE rowid = 10;
+ INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
+ INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
+ INSERT INTO t1 (rowid, content) VALUES(16, 'five');
+ DELETE FROM t1 WHERE rowid = 13;
+ INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
+ INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
+ INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
+ DELETE FROM t1 WHERE rowid = 16;
+ INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
+ INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
+ INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
+ DELETE FROM t1 WHERE rowid = 19;
+ DELETE FROM t1 WHERE rowid = 22;
+}
+
+do_test fts2f-1.1 {
+ execsql {SELECT COUNT(*) FROM t1}
+} {14}
+
+do_test fts2e-2.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {3 5 9 11 15 17 21}
+
+do_test fts2e-2.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
+} {2 3 6 11 14 15 18}
+
+do_test fts2e-2.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
+} {5 6 12 14 15 20 21}
+
+do_test fts2e-2.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
+} {8 9 11 12 14 15}
+
+do_test fts2e-2.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
+} {17 18 20 21}
+
+finish_test
diff --git a/test/fts2f.test b/test/fts2f.test
new file mode 100644
index 0000000..49cff14
--- /dev/null
+++ b/test/fts2f.test
@@ -0,0 +1,90 @@
+# 2006 October 19
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing updates in the FTS2 module.
+#
+# $Id: fts2f.test,v 1.2 2007/02/23 00:14:06 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+# Construct a full-text search table containing keywords which are the
+# ordinal numbers of the bit positions set for a sequence of integers,
+# which are used for the rowid. There are a total of 31 INSERT,
+# UPDATE, and DELETE statements, so that we'll test both the
+# segmentMerge() merge (over the first 16) and the termSelect() merge
+# (over the level-1 segment and 15 level-0 segments).
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, 'one');
+ INSERT INTO t1 (rowid, content) VALUES(2, 'two');
+ INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
+ INSERT INTO t1 (rowid, content) VALUES(4, 'three');
+ INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
+ INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
+ INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
+ DELETE FROM t1 WHERE rowid = 4;
+ INSERT INTO t1 (rowid, content) VALUES(8, 'four');
+ UPDATE t1 SET content = 'update one three' WHERE rowid = 1;
+ INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
+ INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
+ DELETE FROM t1 WHERE rowid = 7;
+ INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
+ INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
+ INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
+ DELETE FROM t1 WHERE rowid = 10;
+ INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
+ INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
+ UPDATE t1 SET content = 'update two five' WHERE rowid = 8;
+ INSERT INTO t1 (rowid, content) VALUES(16, 'five');
+ DELETE FROM t1 WHERE rowid = 13;
+ INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
+ INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
+ INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
+ DELETE FROM t1 WHERE rowid = 16;
+ INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
+ INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
+ INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
+ DELETE FROM t1 WHERE rowid = 19;
+ UPDATE t1 SET content = 'update' WHERE rowid = 15;
+}
+
+do_test fts2f-1.1 {
+ execsql {SELECT COUNT(*) FROM t1}
+} {16}
+
+do_test fts2f-2.0 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}
+} {1 8 15}
+
+do_test fts2f-2.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {1 3 5 9 11 17 21}
+
+do_test fts2f-2.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
+} {2 3 6 8 11 14 18 22}
+
+do_test fts2f-2.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
+} {1 5 6 12 14 20 21 22}
+
+do_test fts2f-2.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
+} {9 11 12 14}
+
+do_test fts2f-2.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
+} {8 17 18 20 21 22}
+
+finish_test
diff --git a/test/fts2g.test b/test/fts2g.test
new file mode 100644
index 0000000..4cffb91
--- /dev/null
+++ b/test/fts2g.test
@@ -0,0 +1,93 @@
+# 2006 October 19
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing handling of edge cases for various doclist
+# merging functions in the FTS2 module query logic.
+#
+# $Id: fts2g.test,v 1.3 2007/11/16 00:23:08 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, 'this is a test');
+ INSERT INTO t1 (rowid, content) VALUES(2, 'also a test');
+}
+
+# No hits at all. Returns empty doclists from termSelect().
+do_test fts2g-1.1 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
+} {}
+
+# Empty left in docListExceptMerge().
+do_test fts2g-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this something'}
+} {}
+
+# Empty right in docListExceptMerge().
+do_test fts2g-1.3 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this -something'}
+} {1}
+
+# Empty left in docListPhraseMerge().
+do_test fts2g-1.4 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"this something"'}
+} {}
+
+# Empty right in docListPhraseMerge().
+do_test fts2g-1.5 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"something is"'}
+} {}
+
+# Empty left in docListOrMerge().
+do_test fts2g-1.6 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR this'}
+} {1}
+
+# Empty right in docListOrMerge().
+do_test fts2g-1.7 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR something'}
+} {1}
+
+# Empty left in docListAndMerge().
+do_test fts2g-1.8 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something this'}
+} {}
+
+# Empty right in docListAndMerge().
+do_test fts2g-1.9 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this something'}
+} {}
+
+# No support for all-except queries.
+do_test fts2g-1.10 {
+ catchsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this -something'}
+} {1 {SQL logic error or missing database}}
+
+# Test that docListOrMerge() correctly handles reaching the end of one
+# doclist before it reaches the end of the other.
+do_test fts2g-1.11 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR also'}
+} {1 2}
+do_test fts2g-1.12 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'also OR this'}
+} {1 2}
+
+# Empty left and right in docListOrMerge(). Each term matches neither
+# row, and when combined there was an assertion failure.
+do_test fts2g-1.13 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR nothing'}
+} {}
+
+finish_test
diff --git a/test/fts2h.test b/test/fts2h.test
new file mode 100644
index 0000000..72561d8
--- /dev/null
+++ b/test/fts2h.test
@@ -0,0 +1,76 @@
+# 2006 October 31 (scaaarey)
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# here is testing correct handling of excessively long terms.
+#
+# $Id: fts2h.test,v 1.1 2006/11/29 21:03:01 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+# Generate a term of len copies of char.
+proc bigterm {char len} {
+ for {set term ""} {$len>0} {incr len -1} {
+ append term $char
+ }
+ return $term
+}
+
+# Generate a document of bigterms based on characters from the list
+# chars.
+proc bigtermdoc {chars len} {
+ set doc ""
+ foreach char $chars {
+ append doc " " [bigterm $char $len]
+ }
+ return $doc
+}
+
+set len 5000
+set doc1 [bigtermdoc {a b c d} $len]
+set doc2 [bigtermdoc {b d e f} $len]
+set doc3 [bigtermdoc {a c e} $len]
+
+set aterm [bigterm a $len]
+set bterm [bigterm b $len]
+set xterm [bigterm x $len]
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, $doc1);
+ INSERT INTO t1 (rowid, content) VALUES(2, $doc2);
+ INSERT INTO t1 (rowid, content) VALUES(3, $doc3);
+}
+
+# No hits at all. Returns empty doclists from termSelect().
+do_test fts2h-1.1 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
+} {}
+
+do_test fts2h-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}
+} {1 3}
+
+do_test fts2h-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}
+} {}
+
+do_test fts2h-1.3 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'"
+} {1 3}
+
+do_test fts2h-1.4 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'"
+} {1}
+
+finish_test
diff --git a/test/fts2i.test b/test/fts2i.test
new file mode 100644
index 0000000..e732e6a
--- /dev/null
+++ b/test/fts2i.test
@@ -0,0 +1,87 @@
+# 2007 January 17
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite fts2 library. The
+# focus here is testing handling of UPDATE when using UTF-16-encoded
+# databases.
+#
+# $Id: fts2i.test,v 1.2 2007/01/24 03:46:35 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+# Return the UTF-16 representation of the supplied UTF-8 string $str.
+# If $nt is true, append two 0x00 bytes as a nul terminator.
+# NOTE(shess) Copied from capi3.test.
+proc utf16 {str {nt 1}} {
+ set r [encoding convertto unicode $str]
+ if {$nt} {
+ append r "\x00\x00"
+ }
+ return $r
+}
+
+db eval {
+ PRAGMA encoding = "UTF-16le";
+ CREATE VIRTUAL TABLE t1 USING fts2(content);
+}
+
+do_test fts2i-1.0 {
+ execsql {PRAGMA encoding}
+} {UTF-16le}
+
+do_test fts2i-1.1 {
+ execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')}
+ execsql {SELECT content FROM t1 WHERE rowid = 1}
+} {one}
+
+do_test fts2i-1.2 {
+ set sql "INSERT INTO t1 (rowid, content) VALUES(2, 'two')"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 2}
+} {two}
+
+do_test fts2i-1.3 {
+ set sql "INSERT INTO t1 (rowid, content) VALUES(3, 'three')"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ set sql "UPDATE t1 SET content = 'trois' WHERE rowid = 3"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 3}
+} {trois}
+
+do_test fts2i-1.4 {
+ set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}]
+ set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 4}
+} {four}
+
+do_test fts2i-1.5 {
+ set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}]
+ set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ set sql "UPDATE t1 SET content = 'cinq' WHERE rowid = 5"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 5}
+} {cinq}
+
+finish_test
diff --git a/test/fts2j.test b/test/fts2j.test
new file mode 100644
index 0000000..a8a2c07
--- /dev/null
+++ b/test/fts2j.test
@@ -0,0 +1,89 @@
+# 2007 February 6
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. This
+# tests creating fts2 tables in an attached database.
+#
+# $Id: fts2j.test,v 1.1 2007/02/07 01:01:18 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+# Clean up anything left over from a previous pass.
+forcedelete test2.db
+forcedelete test2.db-journal
+sqlite3 db2 test2.db
+
+db eval {
+ CREATE VIRTUAL TABLE t3 USING fts2(content);
+ INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
+}
+
+db2 eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
+ INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
+}
+
+# This has always worked because the t1_* tables used by fts2 will be
+# the defaults.
+do_test fts2j-1.1 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS two;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'hello';
+ DETACH DATABASE two;
+ }
+} {1 2}
+# Make certain we're detached if there was an error.
+catch {db eval {DETACH DATABASE two}}
+
+# In older code, this appears to work fine, but the t2_* tables used
+# by fts2 will be created in database 'main' instead of database
+# 'two'. It appears to work fine because the tables end up being the
+# defaults, but obviously is badly broken if you hope to use things
+# other than in the exact same ATTACH setup.
+do_test fts2j-1.2 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS two;
+ CREATE VIRTUAL TABLE two.t2 USING fts2(content);
+ INSERT INTO t2 (rowid, content) VALUES(1, "hello world");
+ INSERT INTO t2 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO t2 (rowid, content) VALUES(3, "cruel world");
+ SELECT rowid FROM t2 WHERE t2 MATCH 'hello';
+ DETACH DATABASE two;
+ }
+} {1 2}
+catch {db eval {DETACH DATABASE two}}
+
+# In older code, this broke because the fts2 code attempted to create
+# t3_* tables in database 'main', but they already existed. Normally
+# this wouldn't happen without t3 itself existing, in which case the
+# fts2 code would never be called in the first place.
+do_test fts2j-1.3 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS two;
+
+ CREATE VIRTUAL TABLE two.t3 USING fts2(content);
+ INSERT INTO two.t3 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO two.t3 (rowid, content) VALUES(3, "cruel world");
+ SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello';
+
+ DETACH DATABASE two;
+ } db2
+} {2}
+catch {db eval {DETACH DATABASE two}}
+
+catch {db2 close}
+forcedelete test2.db
+
+finish_test
diff --git a/test/fts2k.test b/test/fts2k.test
new file mode 100644
index 0000000..e7d5f0d
--- /dev/null
+++ b/test/fts2k.test
@@ -0,0 +1,105 @@
+# 2007 March 9
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. These
+# make sure that fts2 insertion buffering is fully transparent when
+# using transactions.
+#
+# $Id: fts2k.test,v 1.2 2007/08/10 23:47:04 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
+ INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
+}
+
+# Test that possibly-buffered inserts went through after commit.
+do_test fts2k-1.1 {
+ execsql {
+ BEGIN TRANSACTION;
+ INSERT INTO t1 (rowid, content) VALUES(4, "false world");
+ INSERT INTO t1 (rowid, content) VALUES(5, "false door");
+ COMMIT TRANSACTION;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+ }
+} {1 3 4}
+
+# Test that buffered inserts are seen by selects in the same
+# transaction.
+do_test fts2k-1.2 {
+ execsql {
+ BEGIN TRANSACTION;
+ INSERT INTO t1 (rowid, content) VALUES(6, "another world");
+ INSERT INTO t1 (rowid, content) VALUES(7, "another test");
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+ COMMIT TRANSACTION;
+ }
+} {1 3 4 6}
+
+# Test that buffered inserts are seen within a transaction. This is
+# really the same test as 1.2.
+do_test fts2k-1.3 {
+ execsql {
+ BEGIN TRANSACTION;
+ INSERT INTO t1 (rowid, content) VALUES(8, "second world");
+ INSERT INTO t1 (rowid, content) VALUES(9, "second sight");
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+ ROLLBACK TRANSACTION;
+ }
+} {1 3 4 6 8}
+
+# Double-check that the previous result doesn't persist past the
+# rollback!
+do_test fts2k-1.4 {
+ execsql {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+ }
+} {1 3 4 6}
+
+# Test it all together.
+do_test fts2k-1.5 {
+ execsql {
+ BEGIN TRANSACTION;
+ INSERT INTO t1 (rowid, content) VALUES(10, "second world");
+ INSERT INTO t1 (rowid, content) VALUES(11, "second sight");
+ ROLLBACK TRANSACTION;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+ }
+} {1 3 4 6}
+
+# Test that the obvious case works.
+do_test fts2k-1.6 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 (rowid, content) VALUES(12, "third world");
+ COMMIT;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'third';
+ }
+} {12}
+
+# This is exactly the same as the previous test, except that older
+# code loses the INSERT due to an SQLITE_SCHEMA error.
+do_test fts2k-1.7 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 (rowid, content) VALUES(13, "third dimension");
+ CREATE TABLE x (c);
+ COMMIT;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'dimension';
+ }
+} {13}
+
+finish_test
diff --git a/test/fts2l.test b/test/fts2l.test
new file mode 100644
index 0000000..42f5ba1
--- /dev/null
+++ b/test/fts2l.test
@@ -0,0 +1,69 @@
+# 2007 March 28
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing isspace/isalnum/tolower problems with the
+# FTS2 module. Unfortunately, this code isn't a really principled set
+# of tests, because it is impossible to know where new uses of these
+# functions might appear.
+#
+# $Id: fts2l.test,v 1.2 2007/12/13 21:54:11 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+# Tests that startsWith() (calls isspace, tolower, isalnum) can handle
+# hi-bit chars. parseSpec() also calls isalnum here.
+do_test fts2l-1.1 {
+ execsql "CREATE VIRTUAL TABLE t1 USING fts2(content, \x80)"
+} {}
+
+# Additionally tests isspace() call in getToken(), and isalnum() call
+# in tokenListToIdList().
+do_test fts2l-1.2 {
+ catch {
+ execsql "CREATE VIRTUAL TABLE t2 USING fts2(content, tokenize \x80)"
+ }
+ sqlite3_errmsg $DB
+} "unknown tokenizer: \x80"
+
+# Additionally test final isalnum() in startsWith().
+do_test fts2l-1.3 {
+ execsql "CREATE VIRTUAL TABLE t3 USING fts2(content, tokenize\x80)"
+} {}
+
+# The snippet-generation code has calls to isspace() which are sort of
+# hard to get to. It finds convenient breakpoints by starting ~40
+# chars before and after the matched term, and scanning ~10 chars
+# around that position for isspace() characters. The long word with
+# embedded hi-bit chars causes one of these isspace() calls to be
+# exercised. The version with a couple extra spaces should cause the
+# other isspace() call to be exercised. [Both cases have been tested
+# in the debugger, but I'm hoping to continue to catch it if simple
+# constant changes change things slightly.
+#
+# The trailing and leading hi-bit chars help with code which tests for
+# isspace() to coalesce multiple spaces.
+
+set word "\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80"
+set phrase1 "$word $word $word target $word $word $word"
+set phrase2 "$word $word $word target $word $word $word"
+
+db eval {CREATE VIRTUAL TABLE t4 USING fts2(content)}
+db eval "INSERT INTO t4 (content) VALUES ('$phrase1')"
+db eval "INSERT INTO t4 (content) VALUES ('$phrase2')"
+
+do_test fts2l-1.4 {
+ execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}
+} {1 111 2 117}
+
+finish_test
diff --git a/test/fts2m.test b/test/fts2m.test
new file mode 100644
index 0000000..6552637
--- /dev/null
+++ b/test/fts2m.test
@@ -0,0 +1,65 @@
+# 2007 April 9
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. fts2
+# DELETE handling assumed all fields were non-null. This was not
+# the intention at all.
+#
+# $Id: fts2m.test,v 1.1 2007/04/09 20:45:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(col_a, col_b);
+
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing');
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null);
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b');
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null);
+}
+
+do_test fts2m-1.0 {
+ execsql {
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {2 2 4}
+
+do_test fts2m-1.1 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 1;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {1 1 3}
+
+do_test fts2m-1.2 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 2;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {0 1 2}
+
+do_test fts2m-1.3 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 3;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {0 0 1}
+
+do_test fts2m-1.4 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 4;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {0 0 0}
+
+finish_test
diff --git a/test/fts2n.test b/test/fts2n.test
new file mode 100644
index 0000000..ca0b4fe
--- /dev/null
+++ b/test/fts2n.test
@@ -0,0 +1,196 @@
+# 2007 April 26
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements tests for prefix-searching in the fts2
+# component of the SQLite library.
+#
+# $Id: fts2n.test,v 1.2 2007/12/13 21:54:11 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+# A large string to prime the pump with.
+set text {
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
+ iaculis mollis ipsum. Praesent rhoncus placerat justo. Duis non quam
+ sed turpis posuere placerat. Curabitur et lorem in lorem porttitor
+ aliquet. Pellentesque bibendum tincidunt diam. Vestibulum blandit
+ ante nec elit. In sapien diam, facilisis eget, dictum sed, viverra
+ at, felis. Vestibulum magna. Sed magna dolor, vestibulum rhoncus,
+ ornare vel, vulputate sit amet, felis. Integer malesuada, tellus at
+ luctus gravida, diam nunc porta nibh, nec imperdiet massa metus eu
+ lectus. Aliquam nisi. Nunc fringilla nulla at lectus. Suspendisse
+ potenti. Cum sociis natoque penatibus et magnis dis parturient
+ montes, nascetur ridiculus mus. Pellentesque odio nulla, feugiat eu,
+ suscipit nec, consequat quis, risus.
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+
+ INSERT INTO t1(rowid, c) VALUES(1, $text);
+ INSERT INTO t1(rowid, c) VALUES(2, 'Another lovely row');
+}
+
+# Exact match
+do_test fts2n-1.1 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lorem'"
+} {1}
+
+# And a prefix
+do_test fts2n-1.2 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lore*'"
+} {1}
+
+# Prefix includes exact match
+do_test fts2n-1.3 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lorem*'"
+} {1}
+
+# Make certain everything isn't considered a prefix!
+do_test fts2n-1.4 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lore'"
+} {}
+
+# Prefix across multiple rows.
+do_test fts2n-1.5 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lo*'"
+} {1 2}
+
+# Likewise, with multiple hits in one document.
+do_test fts2n-1.6 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'l*'"
+} {1 2}
+
+# Prefix which should only hit one document.
+do_test fts2n-1.7 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lov*'"
+} {2}
+
+# * not at end is dropped.
+do_test fts2n-1.8 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lo *'"
+} {}
+
+# Stand-alone * is dropped.
+do_test fts2n-1.9 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '*'"
+} {}
+
+# Phrase-query prefix.
+do_test fts2n-1.10 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"lovely r*\"'"
+} {2}
+do_test fts2n-1.11 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"lovely r\"'"
+} {}
+
+# Phrase query with multiple prefix matches.
+do_test fts2n-1.12 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"a* l*\"'"
+} {1 2}
+
+# Phrase query with multiple prefix matches.
+do_test fts2n-1.13 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"a* l* row\"'"
+} {2}
+
+
+
+
+# Test across updates (and, by implication, deletes).
+
+# Version of text without "lorem".
+regsub -all {[Ll]orem} $text '' ntext
+
+db eval {
+ CREATE VIRTUAL TABLE t2 USING fts2(c);
+
+ INSERT INTO t2(rowid, c) VALUES(1, $text);
+ INSERT INTO t2(rowid, c) VALUES(2, 'Another lovely row');
+ UPDATE t2 SET c = $ntext WHERE rowid = 1;
+}
+
+# Can't see lorem as an exact match.
+do_test fts2n-2.1 {
+ execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lorem'"
+} {}
+
+# Can't see a prefix of lorem, either.
+do_test fts2n-2.2 {
+ execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lore*'"
+} {}
+
+# Can see lovely in the other document.
+do_test fts2n-2.3 {
+ execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lo*'"
+} {2}
+
+# Can still see other hits.
+do_test fts2n-2.4 {
+ execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'l*'"
+} {1 2}
+
+# Prefix which should only hit one document.
+do_test fts2n-2.5 {
+ execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lov*'"
+} {2}
+
+
+
+# Test with a segment which will have multiple levels in the tree.
+
+# Build a big document with lots of unique terms.
+set bigtext $text
+foreach c {a b c d e} {
+ regsub -all {[A-Za-z]+} $bigtext "&$c" t
+ append bigtext $t
+}
+
+# Populate a table with many copies of the big document, so that we
+# can test the number of hits found. Populate $ret with the expected
+# hit counts for each row. offsets() returns 4 elements for every
+# hit. We'll have 6 hits for row 1, 1 for row 2, and 6*(2^5)==192 for
+# $bigtext.
+set ret {6 1}
+db eval {
+ BEGIN;
+ CREATE VIRTUAL TABLE t3 USING fts2(c);
+
+ INSERT INTO t3(rowid, c) VALUES(1, $text);
+ INSERT INTO t3(rowid, c) VALUES(2, 'Another lovely row');
+}
+for {set i 0} {$i<100} {incr i} {
+ db eval {INSERT INTO t3(rowid, c) VALUES(3+$i, $bigtext)}
+ lappend ret 192
+}
+db eval {COMMIT;}
+
+# Test that we get the expected number of hits.
+do_test fts2n-3.1 {
+ set t {}
+ db eval {SELECT offsets(t3) as o FROM t3 WHERE t3 MATCH 'l*'} {
+ set l [llength $o]
+ lappend t [expr {$l/4}]
+ }
+ set t
+} $ret
+
+# TODO(shess) It would be useful to test a couple edge cases, but I
+# don't know if we have the precision to manage it from here at this
+# time. Prefix hits can cross leaves, which the code above _should_
+# hit by virtue of size. There are two variations on this. If the
+# tree is 2 levels high, the code will find the leaf-node extent
+# directly, but if its higher, the code will have to follow two
+# separate interior branches down the tree. Both should be tested.
+
+finish_test
diff --git a/test/fts2o.test b/test/fts2o.test
new file mode 100644
index 0000000..63e71b9
--- /dev/null
+++ b/test/fts2o.test
@@ -0,0 +1,169 @@
+# 2007 June 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS2 module.
+#
+# $Id: fts2o.test,v 1.4 2007/07/02 10:16:50 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is not defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+#---------------------------------------------------------------------
+# These tests, fts2o-1.*, test that ticket #2429 is fixed.
+#
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts2(a, b, c);
+ INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');
+}
+do_test fts2o-1.1 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four';
+ }
+} {1 {one <b>four</b> two}}
+do_test fts2o-1.2 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE b MATCH 'four';
+ }
+} {1 {one <b>four</b>}}
+do_test fts2o-1.3 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE a MATCH 'four';
+ }
+} {1 {one three <b>four</b>}}
+
+#---------------------------------------------------------------------
+# Test that it is possible to rename an fts2 table.
+#
+do_test fts2o-2.1 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {t1 t1_content t1_segments t1_segdir}
+do_test fts2o-2.2 {
+ execsql { ALTER TABLE t1 RENAME to fts_t1; }
+} {}
+do_test fts2o-2.3 {
+ execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
+} {1 {one three <b>four</b>}}
+do_test fts2o-2.4 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir}
+
+# See what happens when renaming the fts2 table fails.
+#
+do_test fts2o-2.5 {
+ catchsql {
+ CREATE TABLE t1_segdir(a, b, c);
+ ALTER TABLE fts_t1 RENAME to t1;
+ }
+} {1 {SQL logic error or missing database}}
+do_test fts2o-2.6 {
+ execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
+} {1 {one three <b>four</b>}}
+do_test fts2o-2.7 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir t1_segdir}
+
+# See what happens when renaming the fts2 table fails inside a transaction.
+#
+do_test fts2o-2.8 {
+ execsql {
+ BEGIN;
+ INSERT INTO fts_t1(a, b, c) VALUES('one two three', 'one four', 'one two');
+ }
+} {}
+do_test fts2o-2.9 {
+ catchsql {
+ ALTER TABLE fts_t1 RENAME to t1;
+ }
+} {1 {SQL logic error or missing database}}
+do_test fts2o-2.10 {
+ execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
+} {1 {one three <b>four</b>}}
+do_test fts2o-2.11 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir t1_segdir}
+do_test fts2o-2.12 {
+ execsql COMMIT
+ execsql {SELECT a FROM fts_t1}
+} {{one three four} {one two three}}
+do_test fts2o-2.12 {
+ execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; }
+} {{one three four} {one four} {one four two}}
+
+#-------------------------------------------------------------------
+# Close, delete and reopen the database. The following test should
+# be run on an initially empty db.
+#
+db close
+forcedelete test.db test.db-journal
+sqlite3 db test.db
+
+do_test fts2o-3.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts2(a, b, c);
+ INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two');
+ SELECT a, b, c FROM t1 WHERE c MATCH 'two';
+ }
+} {{one three four} {one four} {one two}}
+
+# This test was crashing at one point.
+#
+do_test fts2o-3.2 {
+ execsql {
+ SELECT a, b, c FROM t1 WHERE c MATCH 'two';
+ CREATE TABLE t3(a, b, c);
+ SELECT a, b, c FROM t1 WHERE c MATCH 'two';
+ }
+} {{one three four} {one four} {one two} {one three four} {one four} {one two}}
+
+#---------------------------------------------------------------------
+# Test that it is possible to rename an fts2 table in an attached
+# database.
+#
+forcedelete test2.db test2.db-journal
+
+do_test fts2o-3.1 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ CREATE VIRTUAL TABLE aux.t1 USING fts2(a, b, c);
+ INSERT INTO aux.t1(a, b, c) VALUES(
+ 'neung song sahm', 'neung see', 'neung see song'
+ );
+ }
+} {}
+
+do_test fts2o-3.2 {
+ execsql { SELECT a, b, c FROM aux.t1 WHERE a MATCH 'song'; }
+} {{neung song sahm} {neung see} {neung see song}}
+
+do_test fts2o-3.3 {
+ execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
+} {{one three four} {one four} {one two}}
+
+do_test fts2o-3.4 {
+ execsql { ALTER TABLE aux.t1 RENAME TO t2 }
+} {}
+
+do_test fts2o-3.2 {
+ execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; }
+} {{neung song sahm} {neung see} {neung see song}}
+
+do_test fts2o-3.3 {
+ execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
+} {{one three four} {one four} {one two}}
+
+finish_test
diff --git a/test/fts2p.test b/test/fts2p.test
new file mode 100644
index 0000000..38a8079
--- /dev/null
+++ b/test/fts2p.test
@@ -0,0 +1,357 @@
+# 2008 June 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file exercises some new testing functions in the FTS2 module,
+# and then uses them to do some basic tests that FTS2 is internally
+# working as expected.
+#
+# $Id: fts2p.test,v 1.1 2008/07/22 23:32:28 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is not defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+#*************************************************************************
+# Probe to see if support for these functions is compiled in.
+# TODO(shess): Change main.mk to do the right thing and remove this test.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) VALUES (1, 'x');
+}
+
+set s {SELECT dump_terms(t1, 1) FROM t1 LIMIT 1}
+set r {1 {unable to use function dump_terms in the requested context}}
+if {[catchsql $s]==$r} {
+ finish_test
+ return
+}
+
+#*************************************************************************
+# Test that the new functions give appropriate errors.
+do_test fts2p-0.0 {
+ catchsql {
+ SELECT dump_terms(t1, 1) FROM t1 LIMIT 1;
+ }
+} {1 {dump_terms: incorrect arguments}}
+
+do_test fts2p-0.1 {
+ catchsql {
+ SELECT dump_terms(t1, 0, 0, 0) FROM t1 LIMIT 1;
+ }
+} {1 {dump_terms: incorrect arguments}}
+
+do_test fts2p-0.2 {
+ catchsql {
+ SELECT dump_terms(1, t1) FROM t1 LIMIT 1;
+ }
+} {1 {unable to use function dump_terms in the requested context}}
+
+do_test fts2p-0.3 {
+ catchsql {
+ SELECT dump_terms(t1, 16, 16) FROM t1 LIMIT 1;
+ }
+} {1 {dump_terms: segment not found}}
+
+do_test fts2p-0.4 {
+ catchsql {
+ SELECT dump_doclist(t1) FROM t1 LIMIT 1;
+ }
+} {1 {dump_doclist: incorrect arguments}}
+
+do_test fts2p-0.5 {
+ catchsql {
+ SELECT dump_doclist(t1, NULL) FROM t1 LIMIT 1;
+ }
+} {1 {dump_doclist: empty second argument}}
+
+do_test fts2p-0.6 {
+ catchsql {
+ SELECT dump_doclist(t1, '') FROM t1 LIMIT 1;
+ }
+} {1 {dump_doclist: empty second argument}}
+
+do_test fts2p-0.7 {
+ catchsql {
+ SELECT dump_doclist(t1, 'a', 0) FROM t1 LIMIT 1;
+ }
+} {1 {dump_doclist: incorrect arguments}}
+
+do_test fts2p-0.8 {
+ catchsql {
+ SELECT dump_doclist(t1, 'a', 0, 0, 0) FROM t1 LIMIT 1;
+ }
+} {1 {dump_doclist: incorrect arguments}}
+
+do_test fts2p-0.9 {
+ catchsql {
+ SELECT dump_doclist(t1, 'a', 16, 16) FROM t1 LIMIT 1;
+ }
+} {1 {dump_doclist: segment not found}}
+
+#*************************************************************************
+# Utility function to check for the expected terms in the segment
+# level/index. _all version does same but for entire index.
+proc check_terms {test level index terms} {
+ # TODO(shess): Figure out why uplevel in do_test can't catch
+ # $level and $index directly.
+ set ::level $level
+ set ::index $index
+ do_test $test.terms {
+ execsql {
+ SELECT dump_terms(t1, $::level, $::index) FROM t1 LIMIT 1;
+ }
+ } [list $terms]
+}
+proc check_terms_all {test terms} {
+ do_test $test.terms {
+ execsql {
+ SELECT dump_terms(t1) FROM t1 LIMIT 1;
+ }
+ } [list $terms]
+}
+
+# Utility function to check for the expected doclist for the term in
+# segment level/index. _all version does same for entire index.
+proc check_doclist {test level index term doclist} {
+ # TODO(shess): Again, why can't the non-:: versions work?
+ set ::term $term
+ set ::level $level
+ set ::index $index
+ do_test $test {
+ execsql {
+ SELECT dump_doclist(t1, $::term, $::level, $::index) FROM t1 LIMIT 1;
+ }
+ } [list $doclist]
+}
+proc check_doclist_all {test term doclist} {
+ set ::term $term
+ do_test $test {
+ execsql {
+ SELECT dump_doclist(t1, $::term) FROM t1 LIMIT 1;
+ }
+ } [list $doclist]
+}
+
+#*************************************************************************
+# Test the segments resulting from straight-forward inserts.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
+}
+
+# Check for expected segments and expected matches.
+do_test fts2p-1.0.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0 0 1 0 2}
+do_test fts2p-1.0.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
+ }
+} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \
+ {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \
+ {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]
+
+# Check the specifics of the segments constructed.
+# Logical view of entire index.
+check_terms_all fts2p-1.0.1 {a is test that this was}
+check_doclist_all fts2p-1.0.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}
+check_doclist_all fts2p-1.0.1.2 is {[1 0[1]] [3 0[1]]}
+check_doclist_all fts2p-1.0.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]}
+check_doclist_all fts2p-1.0.1.4 that {[2 0[0]]}
+check_doclist_all fts2p-1.0.1.5 this {[1 0[0]] [3 0[0]]}
+check_doclist_all fts2p-1.0.1.6 was {[2 0[1]]}
+
+# Segment 0,0
+check_terms fts2p-1.0.2 0 0 {a is test this}
+check_doclist fts2p-1.0.2.1 0 0 a {[1 0[2]]}
+check_doclist fts2p-1.0.2.2 0 0 is {[1 0[1]]}
+check_doclist fts2p-1.0.2.3 0 0 test {[1 0[3]]}
+check_doclist fts2p-1.0.2.4 0 0 this {[1 0[0]]}
+
+# Segment 0,1
+check_terms fts2p-1.0.3 0 1 {a test that was}
+check_doclist fts2p-1.0.3.1 0 1 a {[2 0[2]]}
+check_doclist fts2p-1.0.3.2 0 1 test {[2 0[3]]}
+check_doclist fts2p-1.0.3.3 0 1 that {[2 0[0]]}
+check_doclist fts2p-1.0.3.4 0 1 was {[2 0[1]]}
+
+# Segment 0,2
+check_terms fts2p-1.0.4 0 2 {a is test this}
+check_doclist fts2p-1.0.4.1 0 2 a {[3 0[2]]}
+check_doclist fts2p-1.0.4.2 0 2 is {[3 0[1]]}
+check_doclist fts2p-1.0.4.3 0 2 test {[3 0[3]]}
+check_doclist fts2p-1.0.4.4 0 2 this {[3 0[0]]}
+
+#*************************************************************************
+# Test the segments resulting from inserts followed by a delete.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE rowid = 1;
+}
+
+do_test fts2p-1.1.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0 0 1 0 2 0 3}
+do_test fts2p-1.1.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
+ }
+} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}}
+
+check_terms_all fts2p-1.1.1 {a is test that this was}
+check_doclist_all fts2p-1.1.1.1 a {[2 0[2]] [3 0[2]]}
+check_doclist_all fts2p-1.1.1.2 is {[3 0[1]]}
+check_doclist_all fts2p-1.1.1.3 test {[2 0[3]] [3 0[3]]}
+check_doclist_all fts2p-1.1.1.4 that {[2 0[0]]}
+check_doclist_all fts2p-1.1.1.5 this {[3 0[0]]}
+check_doclist_all fts2p-1.1.1.6 was {[2 0[1]]}
+
+check_terms fts2p-1.1.2 0 0 {a is test this}
+check_doclist fts2p-1.1.2.1 0 0 a {[1 0[2]]}
+check_doclist fts2p-1.1.2.2 0 0 is {[1 0[1]]}
+check_doclist fts2p-1.1.2.3 0 0 test {[1 0[3]]}
+check_doclist fts2p-1.1.2.4 0 0 this {[1 0[0]]}
+
+check_terms fts2p-1.1.3 0 1 {a test that was}
+check_doclist fts2p-1.1.3.1 0 1 a {[2 0[2]]}
+check_doclist fts2p-1.1.3.2 0 1 test {[2 0[3]]}
+check_doclist fts2p-1.1.3.3 0 1 that {[2 0[0]]}
+check_doclist fts2p-1.1.3.4 0 1 was {[2 0[1]]}
+
+check_terms fts2p-1.1.4 0 2 {a is test this}
+check_doclist fts2p-1.1.4.1 0 2 a {[3 0[2]]}
+check_doclist fts2p-1.1.4.2 0 2 is {[3 0[1]]}
+check_doclist fts2p-1.1.4.3 0 2 test {[3 0[3]]}
+check_doclist fts2p-1.1.4.4 0 2 this {[3 0[0]]}
+
+check_terms fts2p-1.1.5 0 3 {a is test this}
+check_doclist fts2p-1.1.5.1 0 3 a {[1]}
+check_doclist fts2p-1.1.5.2 0 3 is {[1]}
+check_doclist fts2p-1.1.5.3 0 3 test {[1]}
+check_doclist fts2p-1.1.5.4 0 3 this {[1]}
+
+#*************************************************************************
+# Test results when all references to certain tokens are deleted.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE rowid IN (1,3);
+}
+
+# Still 4 segments because 0,3 will contain deletes for rowid 1 and 3.
+do_test fts2p-1.2.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0 0 1 0 2 0 3}
+do_test fts2p-1.2.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
+ }
+} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
+
+check_terms_all fts2p-1.2.1 {a is test that this was}
+check_doclist_all fts2p-1.2.1.1 a {[2 0[2]]}
+check_doclist_all fts2p-1.2.1.2 is {}
+check_doclist_all fts2p-1.2.1.3 test {[2 0[3]]}
+check_doclist_all fts2p-1.2.1.4 that {[2 0[0]]}
+check_doclist_all fts2p-1.2.1.5 this {}
+check_doclist_all fts2p-1.2.1.6 was {[2 0[1]]}
+
+check_terms fts2p-1.2.2 0 0 {a is test this}
+check_doclist fts2p-1.2.2.1 0 0 a {[1 0[2]]}
+check_doclist fts2p-1.2.2.2 0 0 is {[1 0[1]]}
+check_doclist fts2p-1.2.2.3 0 0 test {[1 0[3]]}
+check_doclist fts2p-1.2.2.4 0 0 this {[1 0[0]]}
+
+check_terms fts2p-1.2.3 0 1 {a test that was}
+check_doclist fts2p-1.2.3.1 0 1 a {[2 0[2]]}
+check_doclist fts2p-1.2.3.2 0 1 test {[2 0[3]]}
+check_doclist fts2p-1.2.3.3 0 1 that {[2 0[0]]}
+check_doclist fts2p-1.2.3.4 0 1 was {[2 0[1]]}
+
+check_terms fts2p-1.2.4 0 2 {a is test this}
+check_doclist fts2p-1.2.4.1 0 2 a {[3 0[2]]}
+check_doclist fts2p-1.2.4.2 0 2 is {[3 0[1]]}
+check_doclist fts2p-1.2.4.3 0 2 test {[3 0[3]]}
+check_doclist fts2p-1.2.4.4 0 2 this {[3 0[0]]}
+
+check_terms fts2p-1.2.5 0 3 {a is test this}
+check_doclist fts2p-1.2.5.1 0 3 a {[1] [3]}
+check_doclist fts2p-1.2.5.2 0 3 is {[1] [3]}
+check_doclist fts2p-1.2.5.3 0 3 test {[1] [3]}
+check_doclist fts2p-1.2.5.4 0 3 this {[1] [3]}
+
+#*************************************************************************
+# Test results when everything is optimized manually.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE rowid IN (1,3);
+ DROP TABLE IF EXISTS t1old;
+ ALTER TABLE t1 RENAME TO t1old;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) SELECT rowid, c FROM t1old;
+ DROP TABLE t1old;
+}
+
+# Should be a single optimal segment with the same logical results.
+do_test fts2p-1.3.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0}
+do_test fts2p-1.3.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
+ }
+} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
+
+check_terms_all fts2p-1.3.1 {a test that was}
+check_doclist_all fts2p-1.3.1.1 a {[2 0[2]]}
+check_doclist_all fts2p-1.3.1.2 test {[2 0[3]]}
+check_doclist_all fts2p-1.3.1.3 that {[2 0[0]]}
+check_doclist_all fts2p-1.3.1.4 was {[2 0[1]]}
+
+check_terms fts2p-1.3.2 0 0 {a test that was}
+check_doclist fts2p-1.3.2.1 0 0 a {[2 0[2]]}
+check_doclist fts2p-1.3.2.2 0 0 test {[2 0[3]]}
+check_doclist fts2p-1.3.2.3 0 0 that {[2 0[0]]}
+check_doclist fts2p-1.3.2.4 0 0 was {[2 0[1]]}
+
+finish_test
diff --git a/test/fts2q.test b/test/fts2q.test
new file mode 100644
index 0000000..cba78d5
--- /dev/null
+++ b/test/fts2q.test
@@ -0,0 +1,346 @@
+# 2008 June 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing the FTS2 module's optimize() function.
+#
+# $Id: fts2q.test,v 1.2 2008/07/22 23:49:44 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is not defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+#*************************************************************************
+# Probe to see if support for the FTS2 dump_* functions is compiled in.
+# TODO(shess): Change main.mk to do the right thing and remove this test.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) VALUES (1, 'x');
+}
+
+set s {SELECT dump_terms(t1, 1) FROM t1 LIMIT 1}
+set r {1 {unable to use function dump_terms in the requested context}}
+if {[catchsql $s]==$r} {
+ finish_test
+ return
+}
+
+#*************************************************************************
+# Utility function to check for the expected terms in the segment
+# level/index. _all version does same but for entire index.
+proc check_terms {test level index terms} {
+ # TODO(shess): Figure out why uplevel in do_test can't catch
+ # $level and $index directly.
+ set ::level $level
+ set ::index $index
+ do_test $test.terms {
+ execsql {
+ SELECT dump_terms(t1, $::level, $::index) FROM t1 LIMIT 1;
+ }
+ } [list $terms]
+}
+proc check_terms_all {test terms} {
+ do_test $test.terms {
+ execsql {
+ SELECT dump_terms(t1) FROM t1 LIMIT 1;
+ }
+ } [list $terms]
+}
+
+# Utility function to check for the expected doclist for the term in
+# segment level/index. _all version does same for entire index.
+proc check_doclist {test level index term doclist} {
+ # TODO(shess): Again, why can't the non-:: versions work?
+ set ::term $term
+ set ::level $level
+ set ::index $index
+ do_test $test {
+ execsql {
+ SELECT dump_doclist(t1, $::term, $::level, $::index) FROM t1 LIMIT 1;
+ }
+ } [list $doclist]
+}
+proc check_doclist_all {test term doclist} {
+ set ::term $term
+ do_test $test {
+ execsql {
+ SELECT dump_doclist(t1, $::term) FROM t1 LIMIT 1;
+ }
+ } [list $doclist]
+}
+
+#*************************************************************************
+# Test results when all rows are deleted and one is added back.
+# Previously older segments would continue to exist, but now the index
+# should be dropped when the table is empty. The results should look
+# exactly like we never added the earlier rows in the first place.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE 1=1; -- Delete each row rather than dropping table.
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+}
+
+# Should be a single initial segment.
+do_test fts2q-1.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0}
+do_test fts2q-1.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
+ }
+} {{0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}}
+
+check_terms_all fts2q-1.1 {a is test this}
+check_doclist_all fts2q-1.1.1 a {[1 0[2]]}
+check_doclist_all fts2q-1.1.2 is {[1 0[1]]}
+check_doclist_all fts2q-1.1.3 test {[1 0[3]]}
+check_doclist_all fts2q-1.1.4 this {[1 0[0]]}
+
+check_terms fts2q-1.2 0 0 {a is test this}
+check_doclist fts2q-1.2.1 0 0 a {[1 0[2]]}
+check_doclist fts2q-1.2.2 0 0 is {[1 0[1]]}
+check_doclist fts2q-1.2.3 0 0 test {[1 0[3]]}
+check_doclist fts2q-1.2.4 0 0 this {[1 0[0]]}
+
+#*************************************************************************
+# Test results when everything is optimized manually.
+# NOTE(shess): This is a copy of fts2c-1.3. I've pulled a copy here
+# because fts2q-2 and fts2q-3 should have identical results.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE rowid IN (1,3);
+ DROP TABLE IF EXISTS t1old;
+ ALTER TABLE t1 RENAME TO t1old;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) SELECT rowid, c FROM t1old;
+ DROP TABLE t1old;
+}
+
+# Should be a single optimal segment with the same logical results.
+do_test fts2q-2.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0}
+do_test fts2q-2.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
+ }
+} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
+
+check_terms_all fts2q-2.1 {a test that was}
+check_doclist_all fts2q-2.1.1 a {[2 0[2]]}
+check_doclist_all fts2q-2.1.2 test {[2 0[3]]}
+check_doclist_all fts2q-2.1.3 that {[2 0[0]]}
+check_doclist_all fts2q-2.1.4 was {[2 0[1]]}
+
+check_terms fts2q-2.2 0 0 {a test that was}
+check_doclist fts2q-2.2.1 0 0 a {[2 0[2]]}
+check_doclist fts2q-2.2.2 0 0 test {[2 0[3]]}
+check_doclist fts2q-2.2.3 0 0 that {[2 0[0]]}
+check_doclist fts2q-2.2.4 0 0 was {[2 0[1]]}
+
+#*************************************************************************
+# Test results when everything is optimized via optimize().
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE rowid IN (1,3);
+ SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
+}
+
+# Should be a single optimal segment with the same logical results.
+do_test fts2q-3.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0}
+do_test fts2q-3.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
+ }
+} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
+
+check_terms_all fts2q-3.1 {a test that was}
+check_doclist_all fts2q-3.1.1 a {[2 0[2]]}
+check_doclist_all fts2q-3.1.2 test {[2 0[3]]}
+check_doclist_all fts2q-3.1.3 that {[2 0[0]]}
+check_doclist_all fts2q-3.1.4 was {[2 0[1]]}
+
+check_terms fts2q-3.2 0 0 {a test that was}
+check_doclist fts2q-3.2.1 0 0 a {[2 0[2]]}
+check_doclist fts2q-3.2.2 0 0 test {[2 0[3]]}
+check_doclist fts2q-3.2.3 0 0 that {[2 0[0]]}
+check_doclist fts2q-3.2.4 0 0 was {[2 0[1]]}
+
+#*************************************************************************
+# Test optimize() against a table involving segment merges.
+# NOTE(shess): Since there's no transaction, each of the INSERT/UPDATE
+# statements generates a segment.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
+
+ UPDATE t1 SET c = 'This is a test one' WHERE rowid = 1;
+ UPDATE t1 SET c = 'That was a test one' WHERE rowid = 2;
+ UPDATE t1 SET c = 'This is a test one' WHERE rowid = 3;
+
+ UPDATE t1 SET c = 'This is a test two' WHERE rowid = 1;
+ UPDATE t1 SET c = 'That was a test two' WHERE rowid = 2;
+ UPDATE t1 SET c = 'This is a test two' WHERE rowid = 3;
+
+ UPDATE t1 SET c = 'This is a test three' WHERE rowid = 1;
+ UPDATE t1 SET c = 'That was a test three' WHERE rowid = 2;
+ UPDATE t1 SET c = 'This is a test three' WHERE rowid = 3;
+
+ UPDATE t1 SET c = 'This is a test four' WHERE rowid = 1;
+ UPDATE t1 SET c = 'That was a test four' WHERE rowid = 2;
+ UPDATE t1 SET c = 'This is a test four' WHERE rowid = 3;
+
+ UPDATE t1 SET c = 'This is a test' WHERE rowid = 1;
+ UPDATE t1 SET c = 'That was a test' WHERE rowid = 2;
+ UPDATE t1 SET c = 'This is a test' WHERE rowid = 3;
+}
+
+# 2 segments in level 0, 1 in level 1 (18 segments created, 16
+# merged).
+do_test fts2q-4.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0 0 1 1 0}
+
+do_test fts2q-4.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
+ }
+} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \
+ {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \
+ {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]
+
+check_terms_all fts2q-4.1 {a four is one test that this three two was}
+check_doclist_all fts2q-4.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}
+check_doclist_all fts2q-4.1.2 four {}
+check_doclist_all fts2q-4.1.3 is {[1 0[1]] [3 0[1]]}
+check_doclist_all fts2q-4.1.4 one {}
+check_doclist_all fts2q-4.1.5 test {[1 0[3]] [2 0[3]] [3 0[3]]}
+check_doclist_all fts2q-4.1.6 that {[2 0[0]]}
+check_doclist_all fts2q-4.1.7 this {[1 0[0]] [3 0[0]]}
+check_doclist_all fts2q-4.1.8 three {}
+check_doclist_all fts2q-4.1.9 two {}
+check_doclist_all fts2q-4.1.10 was {[2 0[1]]}
+
+check_terms fts2q-4.2 0 0 {a four test that was}
+check_doclist fts2q-4.2.1 0 0 a {[2 0[2]]}
+check_doclist fts2q-4.2.2 0 0 four {[2]}
+check_doclist fts2q-4.2.3 0 0 test {[2 0[3]]}
+check_doclist fts2q-4.2.4 0 0 that {[2 0[0]]}
+check_doclist fts2q-4.2.5 0 0 was {[2 0[1]]}
+
+check_terms fts2q-4.3 0 1 {a four is test this}
+check_doclist fts2q-4.3.1 0 1 a {[3 0[2]]}
+check_doclist fts2q-4.3.2 0 1 four {[3]}
+check_doclist fts2q-4.3.3 0 1 is {[3 0[1]]}
+check_doclist fts2q-4.3.4 0 1 test {[3 0[3]]}
+check_doclist fts2q-4.3.5 0 1 this {[3 0[0]]}
+
+check_terms fts2q-4.4 1 0 {a four is one test that this three two was}
+check_doclist fts2q-4.4.1 1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]}
+check_doclist fts2q-4.4.2 1 0 four {[1] [2 0[4]] [3 0[4]]}
+check_doclist fts2q-4.4.3 1 0 is {[1 0[1]] [3 0[1]]}
+check_doclist fts2q-4.4.4 1 0 one {[1] [2] [3]}
+check_doclist fts2q-4.4.5 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}
+check_doclist fts2q-4.4.6 1 0 that {[2 0[0]]}
+check_doclist fts2q-4.4.7 1 0 this {[1 0[0]] [3 0[0]]}
+check_doclist fts2q-4.4.8 1 0 three {[1] [2] [3]}
+check_doclist fts2q-4.4.9 1 0 two {[1] [2] [3]}
+check_doclist fts2q-4.4.10 1 0 was {[2 0[1]]}
+
+# Optimize should leave the result in the level of the highest-level
+# prior segment.
+do_test fts2q-4.5 {
+ execsql {
+ SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {{Index optimized} 1 0}
+
+# Identical to fts2q-4.matches.
+do_test fts2q-4.5.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
+ }
+} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \
+ {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \
+ {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]
+
+check_terms_all fts2q-4.5.1 {a is test that this was}
+check_doclist_all fts2q-4.5.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}
+check_doclist_all fts2q-4.5.1.2 is {[1 0[1]] [3 0[1]]}
+check_doclist_all fts2q-4.5.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]}
+check_doclist_all fts2q-4.5.1.4 that {[2 0[0]]}
+check_doclist_all fts2q-4.5.1.5 this {[1 0[0]] [3 0[0]]}
+check_doclist_all fts2q-4.5.1.6 was {[2 0[1]]}
+
+check_terms fts2q-4.5.2 1 0 {a is test that this was}
+check_doclist fts2q-4.5.2.1 1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]}
+check_doclist fts2q-4.5.2.2 1 0 is {[1 0[1]] [3 0[1]]}
+check_doclist fts2q-4.5.2.3 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}
+check_doclist fts2q-4.5.2.4 1 0 that {[2 0[0]]}
+check_doclist fts2q-4.5.2.5 1 0 this {[1 0[0]] [3 0[0]]}
+check_doclist fts2q-4.5.2.6 1 0 was {[2 0[1]]}
+
+# Re-optimizing does nothing.
+do_test fts2q-5.0 {
+ execsql {
+ SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {{Index already optimal} 1 0}
+
+# Even if we move things around, still does nothing.
+do_test fts2q-5.1 {
+ execsql {
+ UPDATE t1_segdir SET level = 2 WHERE level = 1 AND idx = 0;
+ SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {{Index already optimal} 2 0}
+
+finish_test
diff --git a/test/fts2r.test b/test/fts2r.test
new file mode 100644
index 0000000..c0be367
--- /dev/null
+++ b/test/fts2r.test
@@ -0,0 +1,121 @@
+# 2008 July 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# These tests exercise the various types of fts2 cursors.
+#
+# $Id: fts2r.test,v 1.1 2008/07/29 20:38:18 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is not defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+#*************************************************************************
+# Test table scan (QUERY_GENERIC). This kind of query happens for
+# queries with no WHERE clause, or for WHERE clauses which cannot be
+# satisfied by an index.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
+}
+
+do_test fts2e-1.1 {
+ execsql {
+ SELECT rowid FROM t1 ORDER BY rowid;
+ }
+} {1 2 3}
+
+do_test fts2e-1.2 {
+ execsql {
+ SELECT rowid FROM t1 WHERE c LIKE '%test' ORDER BY rowid;
+ }
+} {1 2 3}
+
+do_test fts2e-1.3 {
+ execsql {
+ SELECT rowid FROM t1 WHERE c LIKE 'That%' ORDER BY rowid;
+ }
+} {2}
+
+#*************************************************************************
+# Test lookup by rowid (QUERY_ROWID). This kind of query happens for
+# queries which select by the rowid implicit index.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE);
+ INSERT INTO t2 VALUES (null, 10);
+ INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');
+ INSERT INTO t2 VALUES (null, 5);
+ INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'That was a test');
+ INSERT INTO t2 VALUES (null, 20);
+ INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');
+}
+
+# TODO(shess): This actually is doing QUERY_GENERIC? I'd have
+# expected QUERY_ROWID in this case, as for a very large table the
+# full scan is less efficient.
+do_test fts2e-2.1 {
+ execsql {
+ SELECT rowid FROM t1 WHERE rowid in (1, 2, 10);
+ }
+} {1 2}
+
+do_test fts2e-2.2 {
+ execsql {
+ SELECT t1.rowid, weight FROM t1, t2 WHERE t2.id = t1.rowid ORDER BY weight;
+ }
+} {2 5 1 10 3 20}
+
+do_test fts2e-2.3 {
+ execsql {
+ SELECT t1.rowid, weight FROM t1, t2
+ WHERE t2.weight>5 AND t2.id = t1.rowid ORDER BY weight;
+ }
+} {1 10 3 20}
+
+#*************************************************************************
+# Test lookup by MATCH (QUERY_FULLTEXT). This is the fulltext index.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE VIRTUAL TABLE t1 USING fts2(c);
+ CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE);
+ INSERT INTO t2 VALUES (null, 10);
+ INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');
+ INSERT INTO t2 VALUES (null, 5);
+ INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'That was a test');
+ INSERT INTO t2 VALUES (null, 20);
+ INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');
+}
+
+do_test fts2e-3.1 {
+ execsql {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'this' ORDER BY rowid;
+ }
+} {1 3}
+
+do_test fts2e-3.2 {
+ execsql {
+ SELECT t1.rowid, weight FROM t1, t2
+ WHERE t1 MATCH 'this' AND t1.rowid = t2.id ORDER BY weight;
+ }
+} {1 10 3 20}
+
+finish_test
diff --git a/test/fts2token.test b/test/fts2token.test
new file mode 100644
index 0000000..de5f94d
--- /dev/null
+++ b/test/fts2token.test
@@ -0,0 +1,174 @@
+# 2007 June 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing the pluggable tokeniser feature of the
+# FTS2 module.
+#
+# $Id: fts2token.test,v 1.3 2007/06/25 12:05:40 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS2 is defined, omit this file.
+ifcapable !fts2 {
+ finish_test
+ return
+}
+
+proc escape_string {str} {
+ set out ""
+ foreach char [split $str ""] {
+ scan $char %c i
+ if {$i<=127} {
+ append out $char
+ } else {
+ append out [format {\x%.4x} $i]
+ }
+ }
+ set out
+}
+
+#--------------------------------------------------------------------------
+# Test cases fts2token-1.* are the warm-body test for the SQL scalar
+# function fts2_tokenizer(). The procedure is as follows:
+#
+# 1: Verify that there is no such fts2 tokenizer as 'blah'.
+#
+# 2: Query for the built-in tokenizer 'simple'. Insert a copy of the
+# retrieved value as tokenizer 'blah'.
+#
+# 3: Test that the value returned for tokenizer 'blah' is now the
+# same as that retrieved for 'simple'.
+#
+# 4: Test that it is now possible to create an fts2 table using
+# tokenizer 'blah' (it was not possible in step 1).
+#
+# 5: Test that the table created to use tokenizer 'blah' is usable.
+#
+do_test fts2token-1.1 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING fts2(content, tokenize blah);
+ }
+} {1 {unknown tokenizer: blah}}
+do_test fts2token-1.2 {
+ execsql {
+ SELECT fts2_tokenizer('blah', fts2_tokenizer('simple')) IS NULL;
+ }
+} {0}
+do_test fts2token-1.3 {
+ execsql {
+ SELECT fts2_tokenizer('blah') == fts2_tokenizer('simple');
+ }
+} {1}
+do_test fts2token-1.4 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING fts2(content, tokenize blah);
+ }
+} {0 {}}
+do_test fts2token-1.5 {
+ execsql {
+ INSERT INTO t1(content) VALUES('There was movement at the station');
+ INSERT INTO t1(content) VALUES('For the word has passed around');
+ INSERT INTO t1(content) VALUES('That the colt from ol regret had got away');
+ SELECT content FROM t1 WHERE content MATCH 'movement'
+ }
+} {{There was movement at the station}}
+
+#--------------------------------------------------------------------------
+# Test cases fts2token-2.* test error cases in the scalar function based
+# API for getting and setting tokenizers.
+#
+do_test fts2token-2.1 {
+ catchsql {
+ SELECT fts2_tokenizer('nosuchtokenizer');
+ }
+} {1 {unknown tokenizer: nosuchtokenizer}}
+
+#--------------------------------------------------------------------------
+# Test cases fts2token-3.* test the three built-in tokenizers with a
+# simple input string via the built-in test function. This is as much
+# to test the test function as the tokenizer implementations.
+#
+do_test fts2token-3.1 {
+ execsql {
+ SELECT fts2_tokenizer_test('simple', 'I don''t see how');
+ }
+} {{0 i I 1 don don 2 t t 3 see see 4 how how}}
+do_test fts2token-3.2 {
+ execsql {
+ SELECT fts2_tokenizer_test('porter', 'I don''t see how');
+ }
+} {{0 i I 1 don don 2 t t 3 see see 4 how how}}
+ifcapable icu {
+ do_test fts2token-3.3 {
+ execsql {
+ SELECT fts2_tokenizer_test('icu', 'I don''t see how');
+ }
+ } {{0 i I 1 don't don't 2 see see 3 how how}}
+}
+
+#--------------------------------------------------------------------------
+# Test cases fts2token-4.* test the ICU tokenizer. In practice, this
+# tokenizer only has two modes - "thai" and "everybody else". Some other
+# Asian languages (Lao, Khmer etc.) require the same special treatment as
+# Thai, but ICU doesn't support them yet.
+#
+ifcapable icu {
+
+ proc do_icu_test {name locale input output} {
+ set ::out [db eval { SELECT fts2_tokenizer_test('icu', $locale, $input) }]
+ do_test $name {
+ lindex $::out 0
+ } $output
+ }
+
+ do_icu_test fts2token-4.1 en_US {} {}
+ do_icu_test fts2token-4.2 en_US {Test cases fts2} [list \
+ 0 test Test 1 cases cases 2 fts2 fts2
+ ]
+
+ # The following test shows that ICU is smart enough to recognise
+ # Thai chararacters, even when the locale is set to English/United
+ # States.
+ #
+ set input "\u0e2d\u0e30\u0e44\u0e23\u0e19\u0e30\u0e04\u0e23\u0e31\u0e1a"
+ set output "0 \u0e2d\u0e30\u0e44\u0e23 \u0e2d\u0e30\u0e44\u0e23 "
+ append output "1 \u0e19\u0e30 \u0e19\u0e30 "
+ append output "2 \u0e04\u0e23\u0e31\u0e1a \u0e04\u0e23\u0e31\u0e1a"
+
+ do_icu_test fts2token-4.3 th_TH $input $output
+ do_icu_test fts2token-4.4 en_US $input $output
+
+ # ICU handles an unknown locale by falling back to the default.
+ # So this is not an error.
+ do_icu_test fts2token-4.5 MiddleOfTheOcean $input $output
+
+ set longtoken "AReallyReallyLongTokenOneThatWillSurelyRequire"
+ append longtoken "AReallocInTheIcuTokenizerCode"
+
+ set input "short tokens then "
+ append input $longtoken
+ set output "0 short short "
+ append output "1 tokens tokens "
+ append output "2 then then "
+ append output "3 [string tolower $longtoken] $longtoken"
+
+ do_icu_test fts2token-4.6 MiddleOfTheOcean $input $output
+ do_icu_test fts2token-4.7 th_TH $input $output
+ do_icu_test fts2token-4.8 en_US $input $output
+}
+
+do_test fts2token-internal {
+ execsql { SELECT fts2_tokenizer_internal_test() }
+} {ok}
+
+finish_test
diff --git a/test/fts3.test b/test/fts3.test
new file mode 100644
index 0000000..f42220b
--- /dev/null
+++ b/test/fts3.test
@@ -0,0 +1,19 @@
+# 2007 November 23
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file runs all tests.
+#
+# $Id: fts3.test,v 1.2 2008/07/23 18:17:32 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/permutations.test
+
+ifcapable fts3 {
+ run_test_suite fts3
+}
+
+finish_test
diff --git a/test/fts3_common.tcl b/test/fts3_common.tcl
new file mode 100644
index 0000000..4d4ae38
--- /dev/null
+++ b/test/fts3_common.tcl
@@ -0,0 +1,290 @@
+# 2009 November 04
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains common code used the fts3 tests. At one point
+# equivalent functionality was implemented in C code. But it is easier
+# to use Tcl.
+#
+
+#-------------------------------------------------------------------------
+# USAGE: fts3_integrity_check TBL
+#
+# This proc is used to verify that the full-text index is consistent with
+# the contents of the fts3 table. In other words, it checks that the
+# data in the %_contents table matches that in the %_segdir and %_segments
+# tables.
+#
+# This is not an efficient procedure. It uses a lot of memory and a lot
+# of CPU. But it is better than not checking at all.
+#
+# The procedure is:
+#
+# 1) Read the entire full-text index from the %_segdir and %_segments
+# tables into memory. For each entry in the index, the following is
+# done:
+#
+# set C($iDocid,$iCol,$iPosition) $zTerm
+#
+# 2) Iterate through each column of each row of the %_content table.
+# Tokenize all documents, and check that for each token there is
+# a corresponding entry in the $C array. After checking a token,
+# [unset] the $C array entry.
+#
+# 3) Check that array $C is now empty.
+#
+#
+proc fts3_integrity_check {tbl} {
+
+ fts3_read2 $tbl 1 A
+
+ foreach zTerm [array names A] {
+ foreach doclist $A($zTerm) {
+ set docid 0
+ while {[string length $doclist]>0} {
+ set iCol 0
+ set iPos 0
+ set lPos [list]
+ set lCol [list]
+
+ # First varint of a doclist-entry is the docid. Delta-compressed
+ # with respect to the docid of the previous entry.
+ #
+ incr docid [gobble_varint doclist]
+ if {[info exists D($zTerm,$docid)]} {
+ while {[set iDelta [gobble_varint doclist]] != 0} {}
+ continue
+ }
+ set D($zTerm,$docid) 1
+
+ # Gobble varints until the 0x00 that terminates the doclist-entry
+ # is found.
+ while {[set iDelta [gobble_varint doclist]] > 0} {
+ if {$iDelta == 1} {
+ set iCol [gobble_varint doclist]
+ set iPos 0
+ } else {
+ incr iPos $iDelta
+ incr iPos -2
+ set C($docid,$iCol,$iPos) $zTerm
+ }
+ }
+ }
+ }
+ }
+
+ foreach key [array names C] {
+ #puts "$key -> $C($key)"
+ }
+
+
+ db eval "SELECT * FROM ${tbl}_content" E {
+ set iCol 0
+ set iDoc $E(docid)
+ foreach col [lrange $E(*) 1 end] {
+ set c $E($col)
+ set sql {SELECT fts3_tokenizer_test('simple', $c)}
+
+ foreach {pos term dummy} [db one $sql] {
+ if {![info exists C($iDoc,$iCol,$pos)]} {
+ set es "Error at docid=$iDoc col=$iCol pos=$pos. Index is missing"
+ lappend errors $es
+ } else {
+ if {$C($iDoc,$iCol,$pos) != "$term"} {
+ set es "Error at docid=$iDoc col=$iCol pos=$pos. Index "
+ append es "has \"$C($iDoc,$iCol,$pos)\", document has \"$term\""
+ lappend errors $es
+ }
+ unset C($iDoc,$iCol,$pos)
+ }
+ }
+ incr iCol
+ }
+ }
+
+ foreach c [array names C] {
+ lappend errors "Bad index entry: $c -> $C($c)"
+ }
+
+ if {[info exists errors]} { return [join $errors "\n"] }
+ return "ok"
+}
+
+# USAGE: fts3_terms TBL WHERE
+#
+# Argument TBL must be the name of an FTS3 table. Argument WHERE is an
+# SQL expression that will be used as the WHERE clause when scanning
+# the %_segdir table. As in the following query:
+#
+# "SELECT * FROM ${TBL}_segdir WHERE ${WHERE}"
+#
+# This function returns a list of all terms present in the segments
+# selected by the statement above.
+#
+proc fts3_terms {tbl where} {
+ fts3_read $tbl $where a
+ return [lsort [array names a]]
+}
+
+
+# USAGE: fts3_doclist TBL TERM WHERE
+#
+# Argument TBL must be the name of an FTS3 table. TERM is a term that may
+# or may not be present in the table. Argument WHERE is used to select a
+# subset of the b-tree segments in the associated full-text index as
+# described above for [fts3_terms].
+#
+# This function returns the results of merging the doclists associated
+# with TERM in the selected segments. Each doclist is an element of the
+# returned list. Each doclist is formatted as follows:
+#
+# [$docid ?$col[$off1 $off2...]?...]
+#
+# The formatting is odd for a Tcl command in order to be compatible with
+# the original C-language implementation. If argument WHERE is "1", then
+# any empty doclists are omitted from the returned list.
+#
+proc fts3_doclist {tbl term where} {
+ fts3_read $tbl $where a
+
+
+ foreach doclist $a($term) {
+ set docid 0
+
+ while {[string length $doclist]>0} {
+ set iCol 0
+ set iPos 0
+ set lPos [list]
+ set lCol [list]
+ incr docid [gobble_varint doclist]
+
+ while {[set iDelta [gobble_varint doclist]] > 0} {
+ if {$iDelta == 1} {
+ lappend lCol [list $iCol $lPos]
+ set iPos 0
+ set lPos [list]
+ set iCol [gobble_varint doclist]
+ } else {
+ incr iPos $iDelta
+ incr iPos -2
+ lappend lPos $iPos
+ }
+ }
+
+ if {[llength $lPos]>0} {
+ lappend lCol [list $iCol $lPos]
+ }
+
+ if {$where != "1" || [llength $lCol]>0} {
+ set ret($docid) $lCol
+ } else {
+ unset -nocomplain ret($docid)
+ }
+ }
+ }
+
+ set lDoc [list]
+ foreach docid [lsort -integer [array names ret]] {
+ set lCol [list]
+ set cols ""
+ foreach col $ret($docid) {
+ foreach {iCol lPos} $col {}
+ append cols " $iCol\[[join $lPos { }]\]"
+ }
+ lappend lDoc "\[${docid}${cols}\]"
+ }
+
+ join $lDoc " "
+}
+
+###########################################################################
+
+proc gobble_varint {varname} {
+ upvar $varname blob
+ set n [read_fts3varint $blob ret]
+ set blob [string range $blob $n end]
+ return $ret
+}
+proc gobble_string {varname nLength} {
+ upvar $varname blob
+ set ret [string range $blob 0 [expr $nLength-1]]
+ set blob [string range $blob $nLength end]
+ return $ret
+}
+
+# The argument is a blob of data representing an FTS3 segment leaf.
+# Return a list consisting of alternating terms (strings) and doclists
+# (blobs of data).
+#
+proc fts3_readleaf {blob} {
+ set zPrev ""
+ set terms [list]
+
+ while {[string length $blob] > 0} {
+ set nPrefix [gobble_varint blob]
+ set nSuffix [gobble_varint blob]
+
+ set zTerm [string range $zPrev 0 [expr $nPrefix-1]]
+ append zTerm [gobble_string blob $nSuffix]
+ set doclist [gobble_string blob [gobble_varint blob]]
+
+ lappend terms $zTerm $doclist
+ set zPrev $zTerm
+ }
+
+ return $terms
+}
+
+proc fts3_read2 {tbl where varname} {
+ upvar $varname a
+ array unset a
+ db eval " SELECT start_block, leaves_end_block, root
+ FROM ${tbl}_segdir WHERE $where
+ ORDER BY level ASC, idx DESC
+ " {
+ if {$start_block == 0} {
+ foreach {t d} [fts3_readleaf $root] { lappend a($t) $d }
+ } else {
+ db eval " SELECT block
+ FROM ${tbl}_segments
+ WHERE blockid>=$start_block AND blockid<=$leaves_end_block
+ ORDER BY blockid
+ " {
+ foreach {t d} [fts3_readleaf $block] { lappend a($t) $d }
+
+ }
+ }
+ }
+}
+
+proc fts3_read {tbl where varname} {
+ upvar $varname a
+ array unset a
+ db eval " SELECT start_block, leaves_end_block, root
+ FROM ${tbl}_segdir WHERE $where
+ ORDER BY level DESC, idx ASC
+ " {
+ if {$start_block == 0} {
+ foreach {t d} [fts3_readleaf $root] { lappend a($t) $d }
+ } else {
+ db eval " SELECT block
+ FROM ${tbl}_segments
+ WHERE blockid>=$start_block AND blockid<$leaves_end_block
+ ORDER BY blockid
+ " {
+ foreach {t d} [fts3_readleaf $block] { lappend a($t) $d }
+
+ }
+ }
+ }
+}
+
+##########################################################################
+
diff --git a/test/fts3aa.test b/test/fts3aa.test
new file mode 100644
index 0000000..5d79e93
--- /dev/null
+++ b/test/fts3aa.test
@@ -0,0 +1,227 @@
+# 2006 September 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module.
+#
+# $Id: fts3aa.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Construct a full-text search table containing five keywords:
+# one, two, three, four, and five, in various combinations. The
+# rowid for each will be a bitmask for the elements it contains.
+#
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(content);
+ INSERT INTO t1(content) VALUES('one');
+ INSERT INTO t1(content) VALUES('two');
+ INSERT INTO t1(content) VALUES('one two');
+ INSERT INTO t1(content) VALUES('three');
+ INSERT INTO t1(content) VALUES('one three');
+ INSERT INTO t1(content) VALUES('two three');
+ INSERT INTO t1(content) VALUES('one two three');
+ INSERT INTO t1(content) VALUES('four');
+ INSERT INTO t1(content) VALUES('one four');
+ INSERT INTO t1(content) VALUES('two four');
+ INSERT INTO t1(content) VALUES('one two four');
+ INSERT INTO t1(content) VALUES('three four');
+ INSERT INTO t1(content) VALUES('one three four');
+ INSERT INTO t1(content) VALUES('two three four');
+ INSERT INTO t1(content) VALUES('one two three four');
+ INSERT INTO t1(content) VALUES('five');
+ INSERT INTO t1(content) VALUES('one five');
+ INSERT INTO t1(content) VALUES('two five');
+ INSERT INTO t1(content) VALUES('one two five');
+ INSERT INTO t1(content) VALUES('three five');
+ INSERT INTO t1(content) VALUES('one three five');
+ INSERT INTO t1(content) VALUES('two three five');
+ INSERT INTO t1(content) VALUES('one two three five');
+ INSERT INTO t1(content) VALUES('four five');
+ INSERT INTO t1(content) VALUES('one four five');
+ INSERT INTO t1(content) VALUES('two four five');
+ INSERT INTO t1(content) VALUES('one two four five');
+ INSERT INTO t1(content) VALUES('three four five');
+ INSERT INTO t1(content) VALUES('one three four five');
+ INSERT INTO t1(content) VALUES('two three four five');
+ INSERT INTO t1(content) VALUES('one two three four five');
+}
+
+do_test fts3aa-1.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts3aa-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}
+} {3 7 11 15 19 23 27 31}
+do_test fts3aa-1.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}
+} {3 7 11 15 19 23 27 31}
+do_test fts3aa-1.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}
+} {7 15 23 31}
+do_test fts3aa-1.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}
+} {7 15 23 31}
+do_test fts3aa-1.6 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}
+} {7 15 23 31}
+do_test fts3aa-1.7 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}
+} {7 15 23 31}
+do_test fts3aa-1.8 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}
+} {7 15 23 31}
+do_test fts3aa-1.9 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}
+} {7 15 23 31}
+do_test fts3aa-1.10 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}
+} {7 15 23 31}
+do_test fts3aa-1.11 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH ' ONE Two three '}
+} {7 15 23 31}
+
+do_test fts3aa-2.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one"'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts3aa-2.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two"'}
+} {3 7 11 15 19 23 27 31}
+do_test fts3aa-2.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"two one"'}
+} {}
+do_test fts3aa-2.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three"'}
+} {7 15 23 31}
+do_test fts3aa-2.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two"'}
+} {}
+do_test fts3aa-2.6 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three four"'}
+} {15 31}
+do_test fts3aa-2.7 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two four"'}
+} {}
+do_test fts3aa-2.8 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three five"'}
+} {21}
+do_test fts3aa-2.9 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" five'}
+} {21 29}
+do_test fts3aa-2.10 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three"'}
+} {21 29}
+do_test fts3aa-2.11 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three" four'}
+} {29}
+do_test fts3aa-2.12 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four "one three"'}
+} {29}
+do_test fts3aa-2.13 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" four five'}
+} {29}
+
+do_test fts3aa-3.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts3aa-3.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}
+} {1 5 9 13 17 21 25 29}
+do_test fts3aa-3.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}
+} {1 5 9 13 17 21 25 29}
+
+breakpoint
+do_test fts3aa-4.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one OR two'}
+} {1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 25 26 27 29 30 31}
+do_test fts3aa-4.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two" OR three'}
+} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
+do_test fts3aa-4.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR "one two"'}
+} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
+do_test fts3aa-4.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three'}
+} {3 5 7 11 13 15 19 21 23 27 29 31}
+do_test fts3aa-4.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR two one'}
+} {3 5 7 11 13 15 19 21 23 27 29 31}
+do_test fts3aa-4.6 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three OR four'}
+} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
+do_test fts3aa-4.7 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two OR three OR four one'}
+} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
+
+# Test the ability to handle NULL content
+#
+do_test fts3aa-5.1 {
+ execsql {INSERT INTO t1(content) VALUES(NULL)}
+} {}
+do_test fts3aa-5.2 {
+ set rowid [db last_insert_rowid]
+ execsql {SELECT content FROM t1 WHERE rowid=$rowid}
+} {{}}
+do_test fts3aa-5.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}
+} {}
+
+# Test the ability to handle non-positive rowids
+#
+do_test fts3aa-6.0 {
+ execsql {INSERT INTO t1(rowid, content) VALUES(0, 'four five')}
+} {}
+do_test fts3aa-6.1 {
+ execsql {SELECT content FROM t1 WHERE rowid = 0}
+} {{four five}}
+do_test fts3aa-6.2 {
+ execsql {INSERT INTO t1(rowid, content) VALUES(-1, 'three four')}
+} {}
+do_test fts3aa-6.3 {
+ execsql {SELECT content FROM t1 WHERE rowid = -1}
+} {{three four}}
+do_test fts3aa-6.4 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'four'}
+} {-1 0 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31}
+
+# Test creation of FTS3 and FTS4 tables with columns that contain
+# an "=" character.
+#
+do_execsql_test fts3aa-7.1 {
+ CREATE VIRTUAL TABLE t2 USING fts3(xyz=abc);
+ SELECT xyz FROM t2;
+} {}
+do_catchsql_test fts3aa-7.2 {
+ CREATE VIRTUAL TABLE t3 USING fts4(xyz=abc);
+} {1 {unrecognized parameter: xyz=abc}}
+do_catchsql_test fts3aa-7.3 {
+ CREATE VIRTUAL TABLE t3 USING fts4(xyz = abc);
+} {1 {unrecognized parameter: xyz = abc}}
+
+do_execsql_test fts3aa-7.4 {
+ CREATE VIRTUAL TABLE t3 USING fts3(tokenize=simple, tokenize=simple);
+ SELECT tokenize FROM t3;
+} {}
+do_catchsql_test fts3aa-7.5 {
+ CREATE VIRTUAL TABLE t4 USING fts4(tokenize=simple, tokenize=simple);
+} {1 {unrecognized parameter: tokenize=simple}}
+
+
+finish_test
+
diff --git a/test/fts3ab.test b/test/fts3ab.test
new file mode 100644
index 0000000..e1f3bdc
--- /dev/null
+++ b/test/fts3ab.test
@@ -0,0 +1,148 @@
+# 2006 September 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module.
+#
+# $Id: fts3ab.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Fill the full-text index "t1" with phrases in english, spanish,
+# and german. For the i-th row, fill in the names for the bits
+# that are set in the value of i. The least significant bit is
+# 1. For example, the value 5 is 101 in binary which will be
+# converted to "one three" in english.
+#
+proc fill_multilanguage_fulltext_t1 {} {
+ set english {one two three four five}
+ set spanish {un dos tres cuatro cinco}
+ set german {eine zwei drei vier funf}
+
+ for {set i 1} {$i<=31} {incr i} {
+ set cmd "INSERT INTO t1 VALUES"
+ set vset {}
+ foreach lang {english spanish german} {
+ set words {}
+ for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
+ if {$k&$i} {lappend words [lindex [set $lang] $j]}
+ }
+ lappend vset "'$words'"
+ }
+ set sql "INSERT INTO t1(english,spanish,german) VALUES([join $vset ,])"
+ # puts $sql
+ db eval $sql
+ }
+}
+
+# Construct a full-text search table containing five keywords:
+# one, two, three, four, and five, in various combinations. The
+# rowid for each will be a bitmask for the elements it contains.
+#
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(english,spanish,german);
+}
+fill_multilanguage_fulltext_t1
+
+do_test fts3ab-1.1 {
+ execsql {SELECT rowid FROM t1 WHERE english MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts3ab-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE spanish MATCH 'one'}
+} {}
+do_test fts3ab-1.3 {
+ execsql {SELECT rowid FROM t1 WHERE german MATCH 'one'}
+} {}
+do_test fts3ab-1.4 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one'}
+} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
+do_test fts3ab-1.5 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one dos drei'}
+} {7 15 23 31}
+do_test fts3ab-1.6 {
+ execsql {SELECT english, spanish, german FROM t1 WHERE rowid=1}
+} {one un eine}
+do_test fts3ab-1.7 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"one un"'}
+} {}
+
+do_test fts3ab-2.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t2 USING fts3(from,to);
+ INSERT INTO t2([from],[to]) VALUES ('one two three', 'four five six');
+ SELECT [from], [to] FROM t2
+ }
+} {{one two three} {four five six}}
+
+
+# Compute an SQL string that contains the words one, two, three,... to
+# describe bits set in the value $i. Only the lower 5 bits are examined.
+#
+proc wordset {i} {
+ set x {}
+ for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
+ if {$k&$i} {lappend x [lindex {one two three four five} $j]}
+ }
+ return '$x'
+}
+
+# Create a new FTS table with three columns:
+#
+# norm: words for the bits of rowid
+# plusone: words for the bits of rowid+1
+# invert: words for the bits of ~rowid
+#
+db eval {
+ CREATE VIRTUAL TABLE t4 USING fts3([norm],'plusone',"invert");
+}
+for {set i 1} {$i<=15} {incr i} {
+ set vset [list [wordset $i] [wordset [expr {$i+1}]] [wordset [expr {~$i}]]]
+ db eval "INSERT INTO t4(norm,plusone,invert) VALUES([join $vset ,]);"
+}
+
+breakpoint
+do_test fts3ab-4.1 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one'}
+} {1 3 5 7 9 11 13 15}
+do_test fts3ab-4.2 {
+ execsql {SELECT rowid FROM t4 WHERE norm MATCH 'one'}
+} {1 3 5 7 9 11 13 15}
+do_test fts3ab-4.3 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'one'}
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}
+do_test fts3ab-4.4 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:one'}
+} {2 4 6 8 10 12 14}
+do_test fts3ab-4.5 {
+ execsql {SELECT rowid FROM t4 WHERE plusone MATCH 'one'}
+} {2 4 6 8 10 12 14}
+do_test fts3ab-4.6 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one plusone:two'}
+} {1 5 9 13}
+do_test fts3ab-4.7 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one two'}
+} {1 3 5 7 9 11 13 15}
+do_test fts3ab-4.8 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:two norm:one'}
+} {1 5 9 13}
+do_test fts3ab-4.9 {
+ execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'two norm:one'}
+} {1 3 5 7 9 11 13 15}
+
+
+finish_test
diff --git a/test/fts3ac.test b/test/fts3ac.test
new file mode 100644
index 0000000..84da924
--- /dev/null
+++ b/test/fts3ac.test
@@ -0,0 +1,1219 @@
+# 2006 September 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module.
+#
+# $Id: fts3ac.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Create a table of sample email data. The data comes from email
+# archives of Enron executives that was published as part of the
+# litigation against that company.
+#
+do_test fts3ac-1.1 {
+ db eval {
+ CREATE VIRTUAL TABLE email USING fts3([from],[to],subject,body);
+ BEGIN TRANSACTION;
+INSERT INTO email([from],[to],subject,body) VALUES('savita.puthigai@enron.com', 'traders.eol@enron.com, traders.eol@enron.com', 'EnronOnline- Change to Autohedge', 'Effective Monday, October 22, 2001 the following changes will be made to the Autohedge functionality on EnronOnline.
+
+The volume on the hedge will now respect the minimum volume and volume increment settings on the parent product. See rules below:
+
+? If the transaction volume on the child is less than half of the parent''s minimum volume no hedge will occur.
+? If the transaction volume on the child is more than half the parent''s minimum volume but less than half the volume increment on the parent, the hedge will volume will be the parent''s minimum volume.
+? For all other volumes, the same rounding rules will apply based on the volume increment on the parent product.
+
+Please see example below:
+
+Parent''s Settings:
+Minimum: 5000
+Increment: 1000
+
+Volume on Autohedge transaction Volume Hedged
+1 - 2499 0
+2500 - 5499 5000
+5500 - 6499 6000');
+INSERT INTO email([from],[to],subject,body) VALUES('dana.davis@enron.com', 'laynie.east@enron.com, lisa.king@enron.com, lisa.best@enron.com,', 'Leaving Early', 'FYI:
+If it''s ok with everyone''s needs, I would like to leave @4pm. If you think
+you will need my assistance past the 4 o''clock hour just let me know; I''ll
+be more than willing to stay.');
+INSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'louise.kitchen@enron.com', '<<Concur Expense Document>> - CC02.06.02', 'The following expense report is ready for approval:
+
+Employee Name: Christopher F. Calger
+Status last changed by: Mollie E. Gustafson Ms
+Expense Report Name: CC02.06.02
+Report Total: $3,972.93
+Amount Due Employee: $3,972.93
+
+
+To approve this expense report, click on the following link for Concur Expense.
+http://expensexms.enron.com');
+INSERT INTO email([from],[to],subject,body) VALUES('jeff.duff@enron.com', 'julie.johnson@enron.com', 'Work request', 'Julie,
+
+Could you print off the current work request report by 1:30 today?
+
+Gentlemen,
+
+I''d like to review this today at 1:30 in our office. Also, could you provide
+me with your activity reports so I can have Julie enter this information.
+
+JD');
+INSERT INTO email([from],[to],subject,body) VALUES('v.weldon@enron.com', 'gary.l.carrier@usa.dupont.com, scott.joyce@bankofamerica.com', 'Enron News', 'This could turn into something big....
+http://biz.yahoo.com/rf/010129/n29305829.html');
+INSERT INTO email([from],[to],subject,body) VALUES('mark.haedicke@enron.com', 'paul.simons@enron.com', 'Re: First Polish Deal!', 'Congrats! Things seem to be building rapidly now on the Continent. Mark');
+INSERT INTO email([from],[to],subject,body) VALUES('e..carter@enron.com', 't..robinson@enron.com', 'FW: Producers Newsletter 9-24-2001', '
+The producer lumber pricing sheet.
+ -----Original Message-----
+From: Johnson, Jay
+Sent: Tuesday, October 16, 2001 3:42 PM
+To: Carter, Karen E.
+Subject: FW: Producers Newsletter 9-24-2001
+
+
+
+ -----Original Message-----
+From: Daigre, Sergai
+Sent: Friday, September 21, 2001 8:33 PM
+Subject: Producers Newsletter 9-24-2001
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('david.delainey@enron.com', 'kenneth.lay@enron.com', 'Greater Houston Partnership', 'Ken, in response to the letter from Mr Miguel San Juan, my suggestion would
+be to offer up the Falcon for their use; however, given the tight time frame
+and your recent visit with Mr. Fox that it would be difficult for either you
+or me to participate.
+
+I spoke to Max and he agrees with this approach.
+
+I hope this meets with your approval.
+
+Regards
+Delainey');
+INSERT INTO email([from],[to],subject,body) VALUES('lachandra.fenceroy@enron.com', 'lindy.donoho@enron.com', 'FW: Bus Applications Meeting Follow Up', 'Lindy,
+
+Here is the original memo we discussed earlier. Please provide any information that you may have.
+
+Your cooperation is greatly appreciated.
+
+Thanks,
+
+lachandra.fenceroy@enron.com
+713.853.3884
+877.498.3401 Pager
+
+ -----Original Message-----
+From: Bisbee, Joanne
+Sent: Wednesday, September 26, 2001 7:50 AM
+To: Fenceroy, LaChandra
+Subject: FW: Bus Applications Meeting Follow Up
+
+Lachandra, Please get with David Duff today and see what this is about. Who are our TW accounting business users?
+
+ -----Original Message-----
+From: Koh, Wendy
+Sent: Tuesday, September 25, 2001 2:41 PM
+To: Bisbee, Joanne
+Subject: Bus Applications Meeting Follow Up
+
+Lisa brought up a TW change effective Nov 1. It involves eliminating a turnback surcharge. I have no other information, but you might check with the business folks for any system changes required.
+
+Wendy');
+INSERT INTO email([from],[to],subject,body) VALUES('danny.mccarty@enron.com', 'fran.fagan@enron.com', 'RE: worksheets', 'Fran,
+ If Julie''s merit needs to be lump sum, just move it over to that column. Also, send me Eric Gadd''s sheets as well. Thanks.
+Dan
+
+ -----Original Message-----
+From: Fagan, Fran
+Sent: Thursday, December 20, 2001 11:10 AM
+To: McCarty, Danny
+Subject: worksheets
+
+As discussed, attached are your sheets for bonus and merit.
+
+Thanks,
+
+Fran Fagan
+Sr. HR Rep
+713.853.5219
+
+
+ << File: McCartyMerit.xls >> << File: mccartyBonusCommercial_UnP.xls >>
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('bert.meyers@enron.com', 'shift.dl-portland@enron.com', 'OCTOBER SCHEDULE', 'TEAM,
+
+PLEASE SEND ME ANY REQUESTS THAT YOU HAVE FOR OCTOBER. SO FAR I HAVE THEM FOR LEAF. I WOULD LIKE TO HAVE IT DONE BY THE 15TH OF THE MONTH. ANY QUESTIONS PLEASE GIVE ME A CALL.
+
+BERT');
+INSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'john.arnold@enron.com, bilal.bajwa@enron.com, john.griffith@enron.com,', 'TRV Notification: (NG - PROPT P/L - 09/27/2001)', 'The report named: NG - PROPT P/L <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=11&report_name=NG+-+PROPT+P/L&category_cd=5&category_name=FINANCIAL&toc_hide=1&sTV1=5&TV1Exp=Y&current_efct_date=09/27/2001>, published as of 09/27/2001 is now available for viewing on the website.');
+INSERT INTO email([from],[to],subject,body) VALUES('patrice.mims@enron.com', 'calvin.eakins@enron.com', 'Re: Small business supply assistance', 'Hi Calvin
+
+
+I spoke with Rickey (boy, is he long-winded!!). Gave him the name of our
+credit guy, Russell Diamond.
+
+Thank for your help!');
+INSERT INTO email([from],[to],subject,body) VALUES('legal <.hall@enron.com>', 'stephanie.panus@enron.com', 'Termination update', 'City of Vernon and Salt River Project terminated their contracts. I will fax these notices to you.');
+INSERT INTO email([from],[to],subject,body) VALUES('d..steffes@enron.com', 'richard.shapiro@enron.com', 'EES / ENA Government Affairs Staffing & Outside Services', 'Rick --
+
+Here is the information on staffing and outside services. Call if you need anything else.
+
+Jim
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('gelliott@industrialinfo.com', 'pcopello@industrialinfo.com', 'ECAAR (Gavin), WSCC (Diablo Canyon), & NPCC (Seabrook)', 'Dear Power Outage Database Customer,
+Attached you will find an excel document. The outages contained within are forced or rescheduled outages. Your daily delivery will still contain these outages.
+In addition to the two excel documents, there is a dbf file that is formatted like your daily deliveries you receive nightly. This will enable you to load the data into your regular database. Any questions please let me know. Thanks.
+Greg Elliott
+IIR, Inc.
+713-783-5147 x 3481
+outages@industrialinfo.com
+THE INFORMATION CONTAINED IN THIS E-MAIL IS LEGALLY PRIVILEGED AND CONFIDENTIAL INFORMATION INTENDED ONLY FOR THE USE OF THE INDIVIDUAL OR ENTITY NAMED ABOVE. YOU ARE HEREBY NOTIFIED THAT ANY DISSEMINATION, DISTRIBUTION, OR COPY OF THIS E-MAIL TO UNAUTHORIZED ENTITIES IS STRICTLY PROHIBITED. IF YOU HAVE RECEIVED THIS
+E-MAIL IN ERROR, PLEASE DELETE IT.
+ - OUTAGE.dbf
+ - 111201R.xls
+ - 111201.xls ');
+INSERT INTO email([from],[to],subject,body) VALUES('enron.announcements@enron.com', 'all_ena_egm_eim@enron.com', 'EWS Brown Bag', 'MARK YOUR LUNCH CALENDARS NOW !
+
+You are invited to attend the EWS Brown Bag Lunch Series
+
+Featuring: RAY BOWEN, COO
+
+Topic: Enron Industrial Markets
+
+Thursday, March 15, 2001
+11:30 am - 12:30 pm
+EB 5 C2
+
+
+You bring your lunch, Limited Seating
+We provide drinks and dessert. RSVP x 3-9610');
+INSERT INTO email([from],[to],subject,body) VALUES('chris.germany@enron.com', 'ingrid.immer@williams.com', 'Re: About St Pauls', 'Sounds good to me. I bet this is next to the Warick?? Hotel.
+
+
+
+
+"Immer, Ingrid" <Ingrid.Immer@Williams.com> on 12/21/2000 11:48:47 AM
+To: "''chris.germany@enron.com''" <chris.germany@enron.com>
+cc:
+Subject: About St Pauls
+
+
+
+
+ <<About St Pauls.url>>
+?
+?http://www.stpaulshouston.org/about.html
+
+Chris,
+
+I like the looks of this place.? What do you think about going here Christmas
+eve?? They have an 11:00 a.m. service and a candlelight service at 5:00 p.m.,
+among others.
+
+Let me know.?? ii
+
+ - About St Pauls.url
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('nas@cpuc.ca.gov', 'skatz@sempratrading.com, kmccrea@sablaw.com, thompson@wrightlaw.com,', 'Reply Brief filed July 31, 2000', ' - CPUC01-#76371-v1-Revised_Reply_Brief__Due_today_7_31_.doc');
+INSERT INTO email([from],[to],subject,body) VALUES('gascontrol@aglresources.com', 'dscott4@enron.com, lcampbel@enron.com', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder
+As discussed in the Winter Operations Meeting on Sept.29,2000,
+E-Gas(Emergency Gas) will not be offered this winter as a service from AGLC.
+Marketers and Poolers can receive gas via Peaking and IBSS nominations(daisy
+chain) from other marketers up to the 6 p.m. Same Day 2 nomination cycle.
+');
+INSERT INTO email([from],[to],subject,body) VALUES('dutch.quigley@enron.com', 'rwolkwitz@powermerchants.com', '', '
+
+Here is a goody for you');
+INSERT INTO email([from],[to],subject,body) VALUES('ryan.o''rourke@enron.com', 'k..allen@enron.com, randy.bhatia@enron.com, frank.ermis@enron.com,', 'TRV Notification: (West VaR - 11/07/2001)', 'The report named: West VaR <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=36&report_name=West+VaR&category_cd=2&category_name=WEST&toc_hide=1&sTV1=2&TV1Exp=Y&current_efct_date=11/07/2001>, published as of 11/07/2001 is now available for viewing on the website.');
+INSERT INTO email([from],[to],subject,body) VALUES('mjones7@txu.com', 'cstone1@txu.com, ggreen2@txu.com, timpowell@txu.com,', 'Enron / HPL Actuals for July 10, 2000', 'Teco Tap 10.000 / Enron ; 110.000 / HPL IFERC
+
+LS HPL LSK IC 30.000 / Enron
+');
+INSERT INTO email([from],[to],subject,body) VALUES('susan.pereira@enron.com', 'kkw816@aol.com', 'soccer practice', 'Kathy-
+
+Is it safe to assume that practice is cancelled for tonight??
+
+Susan Pereira');
+INSERT INTO email([from],[to],subject,body) VALUES('mark.whitt@enron.com', 'barry.tycholiz@enron.com', 'Huber Internal Memo', 'Please look at this. I didn''t know how deep to go with the desk. Do you think this works.
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('m..forney@enron.com', 'george.phillips@enron.com', '', 'George,
+Give me a call and we will further discuss opportunities on the 13st floor.
+
+Thanks,
+JMForney
+3-7160');
+INSERT INTO email([from],[to],subject,body) VALUES('brad.mckay@enron.com', 'angusmcka@aol.com', 'Re: (no subject)', 'not yet');
+INSERT INTO email([from],[to],subject,body) VALUES('adam.bayer@enron.com', 'jonathan.mckay@enron.com', 'FW: Curve Fetch File', 'Here is the curve fetch file sent to me. It has plenty of points in it. If you give me a list of which ones you need we may be able to construct a secondary worksheet to vlookup the values.
+
+adam
+35227
+
+
+ -----Original Message-----
+From: Royed, Jeff
+Sent: Tuesday, September 25, 2001 11:37 AM
+To: Bayer, Adam
+Subject: Curve Fetch File
+
+Let me know if it works. It may be required to have a certain version of Oracle for it to work properly.
+
+
+
+Jeff Royed
+Enron
+Energy Operations
+Phone: 713-853-5295');
+INSERT INTO email([from],[to],subject,body) VALUES('matt.smith@enron.com', 'yan.wang@enron.com', 'Report Formats', 'Yan,
+
+The merged reports look great. I believe the only orientation changes are to
+"unmerge" the following six reports:
+
+31 Keystone Receipts
+15 Questar Pipeline
+40 Rockies Production
+22 West_2
+23 West_3
+25 CIG_WIC
+
+The orientation of the individual reports should be correct. Thanks.
+
+Mat
+
+PS. Just a reminder to add the "*" by the title of calculated points.');
+INSERT INTO email([from],[to],subject,body) VALUES('michelle.lokay@enron.com', 'jimboman@bigfoot.com', 'Egyptian Festival', '---------------------- Forwarded by Michelle Lokay/ET&S/Enron on 09/07/2000
+10:08 AM ---------------------------
+
+
+"Karkour, Randa" <Randa.Karkour@COMPAQ.com> on 09/07/2000 09:01:04 AM
+To: "''Agheb (E-mail)" <Agheb@aol.com>, "Leila Mankarious (E-mail)"
+<Leila_Mankarious@mhhs.org>, "''Marymankarious (E-mail)"
+<marymankarious@aol.com>, "Michelle lokay (E-mail)" <mlokay@enron.com>, "Ramy
+Mankarious (E-mail)" <Mankarious@aol.com>
+cc:
+
+Subject: Egyptian Festival
+
+
+ <<Egyptian Festival.url>>
+
+ http://www.egyptianfestival.com/
+
+ - Egyptian Festival.url
+');
+INSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'sherry.dawson@enron.com', 'Urgent!!! --- New EAST books', 'This has to be done..................................
+
+Thanks
+---------------------- Forwarded by Errol McLaughlin/Corp/Enron on 12/20/2000
+08:39 AM ---------------------------
+
+
+
+ From: William Kelly @ ECT 12/20/2000 08:31 AM
+
+
+To: Kam Keiser/HOU/ECT@ECT, Darron C Giron/HOU/ECT@ECT, David
+Baumbach/HOU/ECT@ECT, Errol McLaughlin/Corp/Enron@ENRON
+cc: Kimat Singla/HOU/ECT@ECT, Kulvinder Fowler/NA/Enron@ENRON, Kyle R
+Lilly/HOU/ECT@ECT, Jeff Royed/Corp/Enron@ENRON, Alejandra
+Chavez/NA/Enron@ENRON, Crystal Hyde/HOU/ECT@ECT
+
+Subject: New EAST books
+
+We have new book names in TAGG for our intramonth portfolios and it is
+extremely important that any deal booked to the East is communicated quickly
+to someone on my team. I know it will take some time for the new names to
+sink in and I do not want us to miss any positions or P&L.
+
+Thanks for your help on this.
+
+New:
+Scott Neal : East Northeast
+Dick Jenkins: East Marketeast
+
+WK
+');
+INSERT INTO email([from],[to],subject,body) VALUES('david.forster@enron.com', 'eol.wide@enron.com', 'Change to Stack Manager', 'Effective immediately, there is a change to the Stack Manager which will
+affect any Inactive Child.
+
+An inactive Child with links to Parent products will not have their
+calculated prices updated until the Child product is Activated.
+
+When the Child Product is activated, the price will be recalculated and
+updated BEFORE it is displayed on the web.
+
+This means that if you are inputting a basis price on a Child product, you
+will not see the final, calculated price until you Activate the product, at
+which time the customer will also see it.
+
+If you have any questions, please contact the Help Desk on:
+
+Americas: 713 853 4357
+Europe: + 44 (0) 20 7783 7783
+Asia/Australia: +61 2 9229 2300
+
+Dave');
+INSERT INTO email([from],[to],subject,body) VALUES('vince.kaminski@enron.com', 'jhh1@email.msn.com', 'Re: Light reading - see pieces beginning on page 7', 'John,
+
+I saw it. Very interesting.
+
+Vince
+
+
+
+
+
+"John H Herbert" <jhh1@email.msn.com> on 07/28/2000 08:38:08 AM
+To: "Vince J Kaminski" <Vince_J_Kaminski@enron.com>
+cc:
+Subject: Light reading - see pieces beginning on page 7
+
+
+Cheers and have a nice weekend,
+
+
+JHHerbert
+
+
+
+
+ - gd000728.pdf
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('matthew.lenhart@enron.com', 'mmmarcantel@equiva.com', 'RE:', 'i will try to line up a pig for you ');
+INSERT INTO email([from],[to],subject,body) VALUES('jae.black@enron.com', 'claudette.harvey@enron.com, chaun.roberts@enron.com, judy.martinez@enron.com,', 'Disaster Recovery Equipment', 'As a reminder...there are several pieces of equipment that are set up on the 30th Floor, as well as on our floor, for the Disaster Recovery Team. PLEASE DO NOT TAKE, BORROW OR USE this equipment. Should you need to use another computer system, other than yours, or make conference calls please work with your Assistant to help find or set up equipment for you to use.
+
+Thanks for your understanding in this matter.
+
+T.Jae Black
+East Power Trading
+Assistant to Kevin Presto
+off. 713-853-5800
+fax 713-646-8272
+cell 713-539-4760');
+INSERT INTO email([from],[to],subject,body) VALUES('eric.bass@enron.com', 'dale.neuner@enron.com', '5 X 24', 'Dale,
+
+Have you heard anything more on the 5 X 24s? We would like to get this
+product out ASAP.
+
+
+Thanks,
+
+Eric');
+INSERT INTO email([from],[to],subject,body) VALUES('messenger@smartreminders.com', 'm..tholt@enron.com', '10% Coupon - PrintPal Printer Cartridges - 100% Guaranteed', '[IMAGE]
+[IMAGE][IMAGE][IMAGE]
+Dear SmartReminders Member,
+ [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+We respect your privacy and are a Certified Participant of the BBBOnLine
+ Privacy Program. To be removed from future offers,click here.
+SmartReminders.com is a permission based service. To unsubscribe click here . ');
+INSERT INTO email([from],[to],subject,body) VALUES('benjamin.rogers@enron.com', 'mark.bernstein@enron.com', '', 'The guy you are talking about left CIN under a "cloud of suspicion" sort of
+speak. He was the one who got into several bad deals and PPA''s in California
+for CIN, thus he left on a bad note. Let me know if you need more detail
+than that, I felt this was the type of info you were looking for. Thanks!
+Ben');
+INSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'michelle.cash@enron.com', 'Expense Report Receipts Not Received', 'Employee Name: Michelle Cash
+Report Name: Houston Cellular 8-11-01
+Report Date: 12/13/01
+Report ID: 594D37C9ED2111D5B452
+Submitted On: 12/13/01
+
+You are only allowed 2 reports with receipts outstanding. Your expense reports will not be paid until you meet this requirement.');
+INSERT INTO email([from],[to],subject,body) VALUES('susan.mara@enron.com', 'ray.alvarez@enron.com, mark.palmer@enron.com, karen.denne@enron.com,', 'CAISO Emergency Motion -- to discontinue market-based rates for', 'FYI. the latest broadside against the generators.
+
+Sue Mara
+Enron Corp.
+Tel: (415) 782-7802
+Fax:(415) 782-7854
+----- Forwarded by Susan J Mara/NA/Enron on 06/08/2001 12:24 PM -----
+
+
+ "Milner, Marcie" <MMilner@coral-energy.com> 06/08/2001 11:13 AM To: "''smara@enron.com''" <smara@enron.com> cc: Subject: CAISO Emergency Motion
+
+
+Sue, did you see this emergency motion the CAISO filed today? Apparently
+they are requesting that FERC discontinue market-based rates immediately and
+grant refunds plus interest on the difference between cost-based rates and
+market revenues received back to May 2000. They are requesting the
+commission act within 14 days. Have you heard anything about what they are
+doing?
+
+Marcie
+
+http://www.caiso.com/docs/2001/06/08/200106081005526469.pdf
+');
+INSERT INTO email([from],[to],subject,body) VALUES('fletcher.sturm@enron.com', 'eloy.escobar@enron.com', 'Re: General Brinks Position Meeting', 'Eloy,
+
+Who is General Brinks?
+
+Fletch');
+INSERT INTO email([from],[to],subject,body) VALUES('nailia.dindarova@enron.com', 'richard.shapiro@enron.com', 'Documents for Mark Frevert (on EU developments and lessons from', 'Rick,
+
+Here are the documents that Peter has prepared for Mark Frevert.
+
+Nailia
+---------------------- Forwarded by Nailia Dindarova/LON/ECT on 25/06/2001
+16:36 ---------------------------
+
+
+Nailia Dindarova
+25/06/2001 15:36
+To: Michael Brown/Enron@EUEnronXGate
+cc: Ross Sankey/Enron@EUEnronXGate, Eric Shaw/ENRON@EUEnronXGate, Peter
+Styles/LON/ECT@ECT
+
+Subject: Documents for Mark Frevert (on EU developments and lessons from
+California)
+
+Michael,
+
+
+These are the documents that Peter promised to give to you for Mark Frevert.
+He has now handed them to him in person but asked me to transmit them
+electronically to you, as well as Eric and Ross.
+
+Nailia
+
+
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('peggy.a.kostial@accenture.com', 'dave.samuels@enron.com', 'EOL-Accenture Deal Sheet', 'Dave -
+
+Attached are our comments and suggested changes. Please call to review.
+
+On the time line for completion, we have four critical steps to complete:
+ Finalize market analysis to refine business case, specifically
+ projected revenue stream
+ Complete counterparty surveying, including targeting 3 CPs for letters
+ of intent
+ Review Enron asset base for potential reuse/ licensing
+ Contract negotiations
+
+Joe will come back to us with an updated time line, but it is my
+expectation that we are still on the same schedule (we just begun week
+three) with possibly a week or so slippage.....contract negotiations will
+probably be the critical path.
+
+We will send our cut at the actual time line here shortly. Thanks,
+
+Peggy
+
+(See attached file: accenture-dealpoints v2.doc)
+ - accenture-dealpoints v2.doc ');
+INSERT INTO email([from],[to],subject,body) VALUES('thomas.martin@enron.com', 'thomas.martin@enron.com', 'Re: Guadalupe Power Partners LP', '---------------------- Forwarded by Thomas A Martin/HOU/ECT on 03/20/2001
+03:49 PM ---------------------------
+
+
+Thomas A Martin
+10/11/2000 03:55 PM
+To: Patrick Wade/HOU/ECT@ECT
+cc:
+Subject: Re: Guadalupe Power Partners LP
+
+The deal is physically served at Oasis Waha or Oasis Katy and is priced at
+either HSC, Waha or Katytailgate GD at buyers option three days prior to
+NYMEX close.
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('judy.townsend@enron.com', 'dan.junek@enron.com, chris.germany@enron.com', 'Columbia Distribution''s Capacity Available for Release - Sum', '---------------------- Forwarded by Judy Townsend/HOU/ECT on 03/09/2001 11:04
+AM ---------------------------
+
+
+agoddard@nisource.com on 03/08/2001 09:16:57 AM
+To: " - *Koch, Kent" <kkoch@nisource.com>, " -
+*Millar, Debra" <dmillar@nisource.com>, " - *Burke, Lynn"
+<lburke@nisource.com>
+cc: " - *Heckathorn, Tom" <theckathorn@nisource.com>
+Subject: Columbia Distribution''s Capacity Available for Release - Sum
+
+
+Attached is Columbia Distribution''s notice of capacity available for release
+for
+the summer of 2001 (Apr. 2001 through Oct. 2001).
+
+Please note that the deadline for bids is 3:00pm EST on March 20, 2001.
+
+If you have any questions, feel free to contact any of the representatives
+listed
+at the bottom of the attachment.
+
+Aaron Goddard
+
+
+
+
+ - 2001Summer.doc
+');
+INSERT INTO email([from],[to],subject,body) VALUES('rhonda.denton@enron.com', 'tim.belden@enron.com, dana.davis@enron.com, genia.fitzgerald@enron.com,', 'Split Rock Energy LLC', 'We have received the executed EEI contract from this CP dated 12/12/2000.
+Copies will be distributed to Legal and Credit.');
+INSERT INTO email([from],[to],subject,body) VALUES('kerrymcelroy@dwt.com', 'jack.speer@alcoa.com, crow@millernash.com, michaelearly@earthlink.net,', 'Oral Argument Request', ' - Oral Argument Request.doc');
+INSERT INTO email([from],[to],subject,body) VALUES('mike.carson@enron.com', 'rlmichaelis@hormel.com', '', 'Did you come in town this wk end..... My new number at our house is :
+713-668-3712...... my cell # is 281-381-7332
+
+the kid');
+INSERT INTO email([from],[to],subject,body) VALUES('cooper.richey@enron.com', 'trycooper@hotmail.com', 'FW: Contact Info', '
+
+-----Original Message-----
+From: Punja, Karim
+Sent: Thursday, December 13, 2001 2:35 PM
+To: Richey, Cooper
+Subject: Contact Info
+
+
+Cooper,
+
+Its been a real pleasure working with you (even though it was for only a small amount of time)
+I hope we can stay in touch.
+
+Home# 234-0249
+email: kpunja@hotmail.com
+
+Take Care,
+
+Karim.
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('bjm30@earthlink.net', 'mcguinn.k@enron.com, mcguinn.ian@enron.com, mcguinn.stephen@enron.com,', 'email address change', 'Hello all.
+
+I haven''t talked to many of you via email recently but I do want to give you
+my new address for your email file:
+
+ bjm30@earthlink.net
+
+I hope all is well.
+
+Brian McGuinn');
+INSERT INTO email([from],[to],subject,body) VALUES('shelley.corman@enron.com', 'steve.hotte@enron.com', 'Flat Panels', 'Can you please advise what is going on with the flat panels that we had planned to distribute to our gas logistics team. It was in the budget and we had the okay, but now I''m hearing there is some hold-up & the units are stored on 44.
+
+Shelley');
+INSERT INTO email([from],[to],subject,body) VALUES('sara.davidson@enron.com', 'john.schwartzenburg@enron.com, scott.dieball@enron.com, recipients@enron.com,', '2001 Enron Law Conference (Distribution List 2)', ' Enron Law Conference
+
+San Antonio, Texas May 2-4, 2001 Westin Riverwalk
+
+ See attached memo for more details!!
+
+
+? Registration for the law conference this year will be handled through an
+Online RSVP Form on the Enron Law Conference Website at
+http://lawconference.corp.enron.com. The website is still under construction
+and will not be available until Thursday, March 15, 2001.
+
+? We will send you another e-mail to confirm when the Law Conference Website
+is operational.
+
+? Please complete the Online RSVP Form as soon as it is available and submit
+it no later than Friday, March 30th.
+
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('tori.kuykendall@enron.com', 'heath.b.taylor@accenture.com', 'Re:', 'hey - thats funny about john - he definitely remembers him - i''ll call pat
+and let him know - we are coming on saturday - i just havent had a chance to
+call you guys back -- looking forward to it -- i probably need the
+directions again though');
+INSERT INTO email([from],[to],subject,body) VALUES('darron.giron@enron.com', 'bryce.baxter@enron.com', 'Re: Feedback for Audrey Cook', 'Bryce,
+
+I''ll get it done today.
+
+DG 3-9573
+
+
+
+
+
+ From: Bryce Baxter 06/12/2000 07:15 PM
+
+
+To: Darron C Giron/HOU/ECT@ECT
+cc:
+Subject: Feedback for Audrey Cook
+
+You were identified as a reviewer for Audrey Cook. If possible, could you
+complete her feedback by end of business Wednesday? It will really help me
+in the PRC process to have your input. Thanks.
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('casey.evans@enron.com', 'stephanie.sever@enron.com', 'Gas EOL ID', 'Stephanie,
+
+In conjunction with the recent movement of several power traders, they are changing the names of their gas books as well. The names of the new gas books and traders are as follows:
+
+PWR-NG-LT-SPP: Mike Carson
+PWR-NG-LT-SERC: Jeff King
+
+If you need to know their power desk to map their ID to their gas books, those desks are as follows:
+
+EPMI-LT-SPP: Mike Carson
+EPMI-LT-SERC: Jeff King
+
+I will be in training this afternoon, but will be back when class is over. Let me know if you have any questions.
+
+Thanks for your help!
+Casey');
+INSERT INTO email([from],[to],subject,body) VALUES('darrell.schoolcraft@enron.com', 'david.roensch@enron.com, kimberly.watson@enron.com, michelle.lokay@enron.com,', 'Postings', 'Please see the attached.
+
+
+ds
+
+
+
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('mcominsky@aol.com', 'cpatman@bracepatt.com, james_derrick@enron.com', 'Jurisprudence Luncheon', 'Carrin & Jim --
+
+It was an honor and a pleasure to meet both of you yesterday. I know we will
+have fun working together on this very special event.
+
+Jeff left the jurisprudence luncheon lists for me before he left on vacation.
+ I wasn''t sure whether he transmitted them to you as well. Would you please
+advise me if you would like them sent to you? I can email the MS Excel files
+or I can fax the hard copies to you. Please advise what is most convenient.
+
+I plan to be in town through the holidays and can be reached by phone, email,
+or cell phone at any time. My cell phone number is 713/705-4829.
+
+Thanks again for your interest in the ADL''s work. Martin.
+
+Martin B. Cominsky
+Director, Southwest Region
+Anti-Defamation League
+713/627-3490, ext. 122
+713/627-2011 (fax)
+MCominsky@aol.com');
+INSERT INTO email([from],[to],subject,body) VALUES('phillip.love@enron.com', 'todagost@utmb.edu, gbsonnta@utmb.edu', 'New President', 'I had a little bird put a word in my ear. Is there any possibility for Ben
+Raimer to be Bush''s secretary of HHS? Just curious about that infamous UTMB
+rumor mill. Hope things are well, happy holidays.
+PL');
+INSERT INTO email([from],[to],subject,body) VALUES('marie.heard@enron.com', 'ehamilton@fna.com', 'ISDA Master Agreement', 'Erin:
+
+Pursuant to your request, attached are the Schedule to the ISDA Master Agreement, together with Paragraph 13 to the ISDA Credit Support Annex. Please let me know if you need anything else. We look forward to hearing your comments.
+
+Marie
+
+Marie Heard
+Senior Legal Specialist
+Enron North America Corp.
+Phone: (713) 853-3907
+Fax: (713) 646-3490
+marie.heard@enron.com
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('andrea.ring@enron.com', 'beverly.beaty@enron.com', 'Re: Tennessee Buy - Louis Dreyfus', 'Beverly - once again thanks so much for your help on this.
+
+
+
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('karolyn.criado@enron.com', 'j..bonin@enron.com, felicia.case@enron.com, b..clapp@enron.com,', 'Price List week of Oct. 8-9, 2001', '
+Please contact me if you have any questions regarding last weeks prices.
+
+Thank you,
+Karolyn Criado
+3-9441
+
+
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('kevin.presto@enron.com', 'edward.baughman@enron.com, billy.braddock@enron.com', 'Associated', 'Please begin working on filling our Associated short position in 02. I would like to take this risk off the books.
+
+In addition, please find out what a buy-out of VEPCO would cost us. With Rogers transitioning to run our retail risk management, I would like to clean up our customer positions.
+
+We also need to continue to explore a JEA buy-out.
+
+Thanks.');
+INSERT INTO email([from],[to],subject,body) VALUES('stacy.dickson@enron.com', 'gregg.penman@enron.com', 'RE: Constellation TC 5-7-01', 'Gregg,
+
+I am at home with a sick baby. (Lots of fun!) I will call you about this
+tomorrow.
+
+Stacy');
+INSERT INTO email([from],[to],subject,body) VALUES('joe.quenet@enron.com', 'dfincher@utilicorp.com', '', 'hey big guy.....check this out.....
+
+ w ww.gorelieberman-2000.com/');
+INSERT INTO email([from],[to],subject,body) VALUES('k..allen@enron.com', 'jacqestc@aol.com', '', 'Jacques,
+
+I sent you a fax of Kevin Kolb''s comments on the release. The payoff on the note would be $36,248 ($36090(principal) + $158 (accrued interest)).
+This is assuming we wrap this up on Tuesday.
+
+Please email to confirm that their changes are ok so I can set up a meeting on Tuesday to reach closure.
+
+Phillip');
+INSERT INTO email([from],[to],subject,body) VALUES('kourtney.nelson@enron.com', 'mike.swerzbin@enron.com', 'Adjusted L/R Balance', 'Mike,
+
+I placed the adjusted L/R Balance on the Enronwest site. It is under the "Staff/Kourtney Nelson". There are two links:
+
+1) "Adj L_R" is the same data/format from the weekly strategy meeting.
+2) "New Gen 2001_2002" link has all of the supply side info that is used to calculate the L/R balance
+ -Please note the Data Flag column, a value of "3" indicates the project was cancelled, on hold, etc and is not included in the calc.
+
+Both of these sheets are interactive Excel spreadsheets and thus you can play around with the data as you please. Also, James Bruce is working to get his gen report on the web. That will help with your access to information on new gen.
+
+Please let me know if you have any questions or feedback,
+
+Kourtney
+
+
+
+Kourtney Nelson
+Fundamental Analysis
+Enron North America
+(503) 464-8280
+kourtney.nelson@enron.com');
+INSERT INTO email([from],[to],subject,body) VALUES('d..thomas@enron.com', 'naveed.ahmed@enron.com', 'FW: Current Enron TCC Portfolio', '
+
+-----Original Message-----
+From: Grace, Rebecca M.
+Sent: Monday, December 17, 2001 9:44 AM
+To: Thomas, Paul D.
+Cc: Cashion, Jim; Allen, Thresa A.; May, Tom
+Subject: RE: Current Enron TCC Portfolio
+
+
+Paul,
+
+I reviewed NY''s list. I agree with all of their contracts numbers and mw amounts.
+
+Call if you have any more questions.
+
+Rebecca
+
+
+
+ -----Original Message-----
+From: Thomas, Paul D.
+Sent: Monday, December 17, 2001 9:08 AM
+To: Grace, Rebecca M.
+Subject: FW: Current Enron TCC Portfolio
+
+ << File: enrontccs.xls >>
+Rebecca,
+Let me know if you see any differences.
+
+Paul
+X 3-0403
+-----Original Message-----
+From: Thomas, Paul D.
+Sent: Monday, December 17, 2001 9:04 AM
+To: Ahmed, Naveed
+Subject: FW: Current Enron TCC Portfolio
+
+
+
+
+-----Original Message-----
+From: Thomas, Paul D.
+Sent: Thursday, December 13, 2001 10:01 AM
+To: Baughman, Edward D.
+Subject: Current Enron TCC Portfolio
+
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('stephanie.panus@enron.com', 'william.bradford@enron.com, debbie.brackett@enron.com,', 'Coastal Merchant Energy/El Paso Merchant Energy', 'Coastal Merchant Energy, L.P. merged with and into El Paso Merchant Energy,
+L.P., effective February 1, 2001, with the surviving entity being El Paso
+Merchant Energy, L.P. We currently have ISDA Master Agreements with both
+counterparties. Please see the attached memo regarding the existing Masters
+and let us know which agreement should be terminated.
+
+Thanks,
+Stephanie
+');
+INSERT INTO email([from],[to],subject,body) VALUES('kam.keiser@enron.com', 'c..kenne@enron.com', 'RE: What about this too???', '
+
+ -----Original Message-----
+From: Kenne, Dawn C.
+Sent: Wednesday, February 06, 2002 11:50 AM
+To: Keiser, Kam
+Subject: What about this too???
+
+
+ << File: Netco Trader Matrix.xls >>
+ ');
+INSERT INTO email([from],[to],subject,body) VALUES('chris.meyer@enron.com', 'joe.parks@enron.com', 'Centana', 'Talked to Chip. We do need Cash Committe approval given the netting feature of your deal, which means Batch Funding Request. Please update per my previous e-mail and forward.
+
+Thanks
+
+chris
+x31666');
+INSERT INTO email([from],[to],subject,body) VALUES('debra.perlingiere@enron.com', 'jworman@academyofhealth.com', '', 'Have a great weekend! Happy Fathers Day!
+
+
+Debra Perlingiere
+Enron North America Corp.
+1400 Smith Street, EB 3885
+Houston, Texas 77002
+dperlin@enron.com
+Phone 713-853-7658
+Fax 713-646-3490');
+INSERT INTO email([from],[to],subject,body) VALUES('outlook.team@enron.com', '', 'Demo by Martha Janousek of Dashboard & Pipeline Profile / Julia &', 'CALENDAR ENTRY: APPOINTMENT
+
+Description:
+ Demo by Martha Janousek of Dashboard & Pipeline Profile / Julia & Dir Rpts. - 4102
+
+Date: 1/5/2001
+Time: 9:00 AM - 10:00 AM (Central Standard Time)
+
+Chairperson: Outlook Migration Team
+
+Detailed Description:');
+INSERT INTO email([from],[to],subject,body) VALUES('diana.seifert@enron.com', 'mark.taylor@enron.com', 'Guest access Chile', 'Hello Mark,
+
+Justin Boyd told me that your can help me with questions regarding Chile.
+We got a request for guest access through MG.
+The company is called Escondida and is a subsidiary of BHP Australia.
+
+Please advise if I can set up a guest account or not.
+F.Y.I.: MG is planning to put a "in w/h Chile" contract for Copper on-line as
+soon as Enron has done the due diligence for this country.
+Thanks !
+
+
+Best regards
+
+Diana Seifert
+EOL PCG');
+INSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'mark.whitt@enron.com', '<<Concur Expense Document>> - 121001', 'The Approval status has changed on the following report:
+
+Status last changed by: Barry L. Tycholiz
+Expense Report Name: 121001
+Report Total: $198.98
+Amount Due Employee: $198.98
+Amount Approved: $198.98
+Amount Paid: $0.00
+Approval Status: Approved
+Payment Status: Pending
+
+
+To review this expense report, click on the following link for Concur Expense.
+http://expensexms.enron.com');
+INSERT INTO email([from],[to],subject,body) VALUES('kevin.hyatt@enron.com', '', 'Technical Support', 'Outside the U.S., please refer to the list below:
+
+Australia:
+1800 678-515
+support@palm-au.com
+
+Canada:
+1905 305-6530
+support@palm.com
+
+New Zealand:
+0800 446-398
+support@palm-nz.com
+
+U.K.:
+0171 867 0108
+eurosupport@palm.3com.com
+
+Please refer to the Worldwide Customer Support card for a complete technical support contact list.');
+INSERT INTO email([from],[to],subject,body) VALUES('geoff.storey@enron.com', 'dutch.quigley@enron.com', 'RE:', 'duke contact?
+
+ -----Original Message-----
+From: Quigley, Dutch
+Sent: Wednesday, October 31, 2001 10:14 AM
+To: Storey, Geoff
+Subject: RE:
+
+bp corp Albert LaMore 281-366-4962
+
+running the reports now
+
+
+ -----Original Message-----
+From: Storey, Geoff
+Sent: Wednesday, October 31, 2001 10:10 AM
+To: Quigley, Dutch
+Subject: RE:
+
+give me a contact over there too
+BP
+
+
+ -----Original Message-----
+From: Quigley, Dutch
+Sent: Wednesday, October 31, 2001 9:42 AM
+To: Storey, Geoff
+Subject:
+
+Coral Jeff Whitnah 713-767-5374
+Relaint Steve McGinn 713-207-4000');
+INSERT INTO email([from],[to],subject,body) VALUES('pete.davis@enron.com', 'pete.davis@enron.com', 'Start Date: 4/22/01; HourAhead hour: 3; <CODESITE>', 'Start Date: 4/22/01; HourAhead hour: 3; No ancillary schedules awarded.
+Variances detected.
+Variances detected in Load schedule.
+
+ LOG MESSAGES:
+
+PARSING FILE -->> O:\Portland\WestDesk\California Scheduling\ISO Final
+Schedules\2001042203.txt
+
+---- Load Schedule ----
+$$$ Variance found in table tblLoads.
+ Details: (Hour: 3 / Preferred: 1.92 / Final: 1.89)
+ TRANS_TYPE: FINAL
+ LOAD_ID: PGE4
+ MKT_TYPE: 2
+ TRANS_DATE: 4/22/01
+ SC_ID: EPMI
+
+');
+INSERT INTO email([from],[to],subject,body) VALUES('john.postlethwaite@enron.com', 'john.zufferli@enron.com', 'Reference', 'John, hope things are going well up there for you. The big day is almost here for you and Jessica. I was wondering if I could use your name as a job reference if need be. I am just trying to get everything in order just in case something happens.
+
+John');
+INSERT INTO email([from],[to],subject,body) VALUES('jeffrey.shankman@enron.com', 'lschiffm@jonesday.com', 'Re:', 'I saw you called on the cell this a.m. Sorry I missed you. (I was in the
+shower). I have had a shitty week--I suspect my silence (not only to you,
+but others) after our phone call is a result of the week. I''m seeing Glen at
+11:15....talk to you');
+INSERT INTO email([from],[to],subject,body) VALUES('litebytz@enron.com', '', 'Lite Bytz RSVP', '
+This week''s Lite Bytz presentation will feature the following TOOLZ speaker:
+
+Richard McDougall
+Solaris 8
+Thursday, June 7, 2001
+
+If you have not already signed up, please RSVP via email to litebytz@enron.com by the end of the day Tuesday, June 5, 2001.
+
+*Remember: this is now a Brown Bag Event--so bring your lunch and we will provide cookies and drinks.
+
+Click below for more details.
+
+http://home.enron.com:84/messaging/litebytztoolzprint.jpg');
+ COMMIT;
+ }
+} {}
+
+###############################################################################
+# Everything above just builds an interesting test database. The actual
+# tests come after this comment.
+###############################################################################
+
+do_test fts3ac-1.2 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark'
+ }
+} {6 17 25 38 40 42 73 74}
+do_test fts3ac-1.3 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'susan'
+ }
+} {24 40}
+do_test fts3ac-1.4 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark susan'
+ }
+} {40}
+do_test fts3ac-1.5 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'susan mark'
+ }
+} {40}
+do_test fts3ac-1.6 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH '"mark susan"'
+ }
+} {}
+do_test fts3ac-1.7 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark -susan'
+ }
+} {6 17 25 38 42 73 74}
+do_test fts3ac-1.8 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH '-mark susan'
+ }
+} {24}
+do_test fts3ac-1.9 {
+ execsql {
+ SELECT rowid FROM email WHERE email MATCH 'mark OR susan'
+ }
+} {6 17 24 25 38 40 42 73 74}
+
+# Some simple tests of the automatic "offsets(email)" column. In the sample
+# data set above, only one message, number 20, contains the words
+# "gas" and "reminder" in both body and subject.
+#
+do_test fts3ac-2.1 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE email MATCH 'gas reminder'
+ }
+} {20 {2 0 42 3 2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}
+do_test fts3ac-2.2 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE email MATCH 'subject:gas reminder'
+ }
+} {20 {2 0 42 3 2 1 54 8 3 1 54 8}}
+do_test fts3ac-2.3 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE email MATCH 'body:gas reminder'
+ }
+} {20 {2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}
+do_test fts3ac-2.4 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE subject MATCH 'gas reminder'
+ }
+} {20 {2 0 42 3 2 1 54 8}}
+do_test fts3ac-2.5 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE body MATCH 'gas reminder'
+ }
+} {20 {3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}
+
+# Document 32 contains 5 instances of the world "child". But only
+# 3 of them are paired with "product". Make sure only those instances
+# that match the phrase appear in the offsets(email) list.
+#
+do_test fts3ac-3.1 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE body MATCH 'child product' AND +rowid=32
+ }
+} {32 {3 0 94 5 3 0 114 5 3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7 3 1 493 7}}
+do_test fts3ac-3.2 {
+ execsql {
+ SELECT rowid, offsets(email) FROM email
+ WHERE body MATCH '"child product"'
+ }
+} {32 {3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7}}
+
+# Snippet generator tests
+#
+do_test fts3ac-4.1 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'subject:gas reminder'
+ }
+} {{Alert Posted 10:00 AM November 20,2000: E-<b>GAS</b> Request <b>Reminder</b>}}
+do_test fts3ac-4.2 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'christmas candlelight'
+ }
+} {{<b>...</b>here <b>Christmas</b>
+eve?? They have an 11:00 a.m. service and a <b>candlelight</b> service<b>...</b>}}
+
+do_test fts3ac-4.3 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'deal sheet potential reuse'
+ }
+} {{EOL-Accenture <b>Deal</b> <b>Sheet</b><b>...</b>asset base for <b>potential</b> <b>reuse</b>/ licensing
+ Contract negotiations<b>...</b>}}
+do_test fts3ac-4.4 {
+ execsql {
+ SELECT snippet(email,'<<<','>>>',' ') FROM email
+ WHERE email MATCH 'deal sheet potential reuse'
+ }
+} {{EOL-Accenture <<<Deal>>> <<<Sheet>>> asset base for <<<potential>>> <<<reuse>>>/ licensing
+ Contract negotiations }}
+do_test fts3ac-4.5 {
+ execsql {
+ SELECT snippet(email,'<<<','>>>',' ') FROM email
+ WHERE email MATCH 'first things'
+ }
+} {{Re: <<<First>>> Polish Deal! Congrats! <<<Things>>> seem to be building rapidly now }}
+do_test fts3ac-4.6 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'chris is here'
+ }
+} {{<b>...</b><b>chris</b>.germany@enron.com'" <<b>chris</b><b>...</b>bet this <b>is</b> next to<b>...</b>about going <b>here</b> Christmas
+eve<b>...</b>}}
+do_test fts3ac-4.7 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH '"pursuant to"'
+ }
+} {{Erin:
+
+<b>Pursuant</b> <b>to</b> your request, attached are the Schedule to the ISDA Master Agreement, together<b>...</b>}}
+do_test fts3ac-4.8 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'ancillary load davis'
+ }
+} {{pete.<b>davis</b>@enron.com<b>...</b>3; No <b>ancillary</b> schedules awarded<b>...</b>detected in <b>Load</b> schedule.
+
+ LOG<b>...</b>}}
+
+# Combinations of AND and OR operators:
+#
+do_test fts3ac-5.1 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'questar enron OR com'
+ }
+} {{matt.smith@<b>enron</b>.<b>com</b><b>...</b>31 Keystone Receipts
+15 <b>Questar</b> Pipeline
+40 Rockies<b>...</b>}}
+
+do_test fts3ac-5.2 {
+ execsql {
+ SELECT snippet(email) FROM email
+ WHERE email MATCH 'enron OR com questar'
+ }
+} {{matt.smith@<b>enron</b>.<b>com</b><b>...</b>31 Keystone Receipts
+15 <b>Questar</b> Pipeline
+40 Rockies<b>...</b>}}
+
+#-------------------------------------------------------------------------
+# Test a problem reported on the mailing list.
+#
+do_test fts3ac-6.1 {
+ execsql {
+ CREATE VIRTUAL TABLE ft USING fts3(one, two);
+ INSERT INTO ft VALUES('', 'foo');
+ INSERT INTO ft VALUES('foo', 'foo');
+ SELECT offsets(ft) FROM ft WHERE ft MATCH 'foo';
+ }
+} {{1 0 0 3} {0 0 0 3 1 0 0 3}}
+do_test fts3ac-6.2 {
+ execsql {
+ DELETE FROM ft WHERE one = 'foo';
+ SELECT offsets(ft) FROM ft WHERE ft MATCH 'foo';
+ }
+} {{1 0 0 3}}
+
+finish_test
diff --git a/test/fts3ad.test b/test/fts3ad.test
new file mode 100644
index 0000000..e373339
--- /dev/null
+++ b/test/fts3ad.test
@@ -0,0 +1,106 @@
+# 2006 October 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module, and in particular
+# the Porter stemmer.
+#
+# $Id: fts3ad.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_test fts3ad-1.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize porter);
+ INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
+ SELECT rowid FROM t1 WHERE content MATCH 'run jump';
+ }
+} {1}
+do_test fts3ad-1.2 {
+ execsql {
+ SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'run jump';
+ }
+} {{<b>running</b> and <b>jumping</b>}}
+do_test fts3ad-1.3 {
+ execsql {
+ INSERT INTO t1(rowid, content)
+ VALUES(2, 'abcdefghijklmnopqrstuvwyxz');
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijqrstuvwyxz'
+ }
+} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
+do_test fts3ad-1.4 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'
+ }
+} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
+do_test fts3ad-1.5 {
+ execsql {
+ INSERT INTO t1(rowid, content)
+ VALUES(3, 'The value is 123456789');
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123789'
+ }
+} {3 {The value is <b>123456789</b>}}
+do_test fts3ad-1.6 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123000000789'
+ }
+} {3 {The value is <b>123456789</b>}}
+
+do_test fts3ad-2.1 {
+ execsql {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize porter);
+ INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
+ SELECT rowid FROM t1 WHERE content MATCH 'run jump';
+ }
+} {1}
+do_test fts3ad-2.2 {
+ execsql {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize= porter);
+ INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
+ SELECT rowid FROM t1 WHERE content MATCH 'run jump';
+ }
+} {1}
+do_test fts3ad-2.3 {
+ execsql {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize= simple);
+ INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
+ SELECT rowid FROM t1 WHERE content MATCH 'run jump';
+ }
+} {}
+do_test fts3ad-2.4 {
+ execsql {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize= porter);
+ INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
+ SELECT rowid FROM t1 WHERE content MATCH 'run jump';
+ }
+} {1}
+do_test fts3ad-2.5 {
+ execsql {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize = porter);
+ INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
+ SELECT rowid FROM t1 WHERE content MATCH 'run jump';
+ }
+} {1}
+
+
+finish_test
diff --git a/test/fts3ae.test b/test/fts3ae.test
new file mode 100644
index 0000000..b872688
--- /dev/null
+++ b/test/fts3ae.test
@@ -0,0 +1,85 @@
+# 2006 October 19
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing deletions in the FTS3 module.
+#
+# $Id: fts3ae.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Construct a full-text search table containing keywords which are the
+# ordinal numbers of the bit positions set for a sequence of integers,
+# which are used for the rowid. There are a total of 30 INSERT and
+# DELETE statements, so that we'll test both the segmentMerge() merge
+# (over the first 16) and the termSelect() merge (over the level-1
+# segment and 14 level-0 segments).
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, 'one');
+ INSERT INTO t1 (rowid, content) VALUES(2, 'two');
+ INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
+ INSERT INTO t1 (rowid, content) VALUES(4, 'three');
+ DELETE FROM t1 WHERE rowid = 1;
+ INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
+ INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
+ INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
+ DELETE FROM t1 WHERE rowid = 4;
+ INSERT INTO t1 (rowid, content) VALUES(8, 'four');
+ INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
+ INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
+ DELETE FROM t1 WHERE rowid = 7;
+ INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
+ INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
+ INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
+ DELETE FROM t1 WHERE rowid = 10;
+ INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
+ INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
+ INSERT INTO t1 (rowid, content) VALUES(16, 'five');
+ DELETE FROM t1 WHERE rowid = 13;
+ INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
+ INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
+ INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
+ DELETE FROM t1 WHERE rowid = 16;
+ INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
+ INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
+ INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
+ DELETE FROM t1 WHERE rowid = 19;
+ DELETE FROM t1 WHERE rowid = 22;
+}
+
+do_test fts3ae-1.1 {
+ execsql {SELECT COUNT(*) FROM t1}
+} {14}
+
+do_test fts3ae-2.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {3 5 9 11 15 17 21}
+
+do_test fts3ae-2.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
+} {2 3 6 11 14 15 18}
+
+do_test fts3ae-2.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
+} {5 6 12 14 15 20 21}
+
+do_test fts3ae-2.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
+} {8 9 11 12 14 15}
+
+do_test fts3ae-2.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
+} {17 18 20 21}
+
+finish_test
diff --git a/test/fts3af.test b/test/fts3af.test
new file mode 100644
index 0000000..221ac4c
--- /dev/null
+++ b/test/fts3af.test
@@ -0,0 +1,90 @@
+# 2006 October 19
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing updates in the FTS3 module.
+#
+# $Id: fts3af.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Construct a full-text search table containing keywords which are the
+# ordinal numbers of the bit positions set for a sequence of integers,
+# which are used for the rowid. There are a total of 31 INSERT,
+# UPDATE, and DELETE statements, so that we'll test both the
+# segmentMerge() merge (over the first 16) and the termSelect() merge
+# (over the level-1 segment and 15 level-0 segments).
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, 'one');
+ INSERT INTO t1 (rowid, content) VALUES(2, 'two');
+ INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
+ INSERT INTO t1 (rowid, content) VALUES(4, 'three');
+ INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
+ INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
+ INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
+ DELETE FROM t1 WHERE rowid = 4;
+ INSERT INTO t1 (rowid, content) VALUES(8, 'four');
+ UPDATE t1 SET content = 'update one three' WHERE rowid = 1;
+ INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
+ INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
+ DELETE FROM t1 WHERE rowid = 7;
+ INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
+ INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
+ INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
+ DELETE FROM t1 WHERE rowid = 10;
+ INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
+ INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
+ UPDATE t1 SET content = 'update two five' WHERE rowid = 8;
+ INSERT INTO t1 (rowid, content) VALUES(16, 'five');
+ DELETE FROM t1 WHERE rowid = 13;
+ INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
+ INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
+ INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
+ DELETE FROM t1 WHERE rowid = 16;
+ INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
+ INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
+ INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
+ DELETE FROM t1 WHERE rowid = 19;
+ UPDATE t1 SET content = 'update' WHERE rowid = 15;
+}
+
+do_test fts3af-1.1 {
+ execsql {SELECT COUNT(*) FROM t1}
+} {16}
+
+do_test fts3af-2.0 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}
+} {1 8 15}
+
+do_test fts3af-2.1 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
+} {1 3 5 9 11 17 21}
+
+do_test fts3af-2.2 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
+} {2 3 6 8 11 14 18 22}
+
+do_test fts3af-2.3 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
+} {1 5 6 12 14 20 21 22}
+
+do_test fts3af-2.4 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
+} {9 11 12 14}
+
+do_test fts3af-2.5 {
+ execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
+} {8 17 18 20 21 22}
+
+finish_test
diff --git a/test/fts3ag.test b/test/fts3ag.test
new file mode 100644
index 0000000..18ed5ae
--- /dev/null
+++ b/test/fts3ag.test
@@ -0,0 +1,94 @@
+# 2006 October 19
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing handling of edge cases for various doclist
+# merging functions in the FTS3 module query logic.
+#
+# $Id: fts3ag.test,v 1.2 2007/11/16 00:23:08 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, 'this is a test');
+ INSERT INTO t1 (rowid, content) VALUES(2, 'also a test');
+}
+
+# No hits at all. Returns empty doclists from termSelect().
+do_test fts3ag-1.1 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
+} {}
+
+# Empty left in docListExceptMerge().
+do_test fts3ag-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this something'}
+} {}
+
+# Empty right in docListExceptMerge().
+do_test fts3ag-1.3 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this -something'}
+} {1}
+
+# Empty left in docListPhraseMerge().
+do_test fts3ag-1.4 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"this something"'}
+} {}
+
+# Empty right in docListPhraseMerge().
+do_test fts3ag-1.5 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"something is"'}
+} {}
+
+# Empty left in docListOrMerge().
+do_test fts3ag-1.6 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR this'}
+} {1}
+
+# Empty right in docListOrMerge().
+do_test fts3ag-1.7 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR something'}
+} {1}
+
+# Empty left in docListAndMerge().
+do_test fts3ag-1.8 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something this'}
+} {}
+
+# Empty right in docListAndMerge().
+do_test fts3ag-1.9 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this something'}
+} {}
+
+# No support for all-except queries.
+do_test fts3ag-1.10 {
+ catchsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this -something'}
+} {1 {malformed MATCH expression: [-this -something]}}
+
+# Test that docListOrMerge() correctly handles reaching the end of one
+# doclist before it reaches the end of the other.
+do_test fts3ag-1.11 {
+breakpoint
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR also'}
+} {1 2}
+do_test fts3ag-1.12 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'also OR this'}
+} {1 2}
+
+# Empty left and right in docListOrMerge(). Each term matches neither
+# row, and when combined there was an assertion failure.
+do_test fts3ag-1.13 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR nothing'}
+} {}
+
+finish_test
diff --git a/test/fts3ah.test b/test/fts3ah.test
new file mode 100644
index 0000000..3810ec3
--- /dev/null
+++ b/test/fts3ah.test
@@ -0,0 +1,71 @@
+# 2006 October 31
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# here is testing correct handling of very long terms.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Generate a document of bigterms based on characters from the list
+# chars.
+proc bigtermdoc {chars len} {
+ set doc ""
+ foreach char $chars {
+ append doc " " [string repeat $char $len]
+ }
+ return $doc
+}
+
+set len 5000
+set doc1 [bigtermdoc {a b c d} $len]
+set doc2 [bigtermdoc {b d e f} $len]
+set doc3 [bigtermdoc {a c e} $len]
+
+set aterm [string repeat a $len]
+set bterm [string repeat b $len]
+set xterm [string repeat x $len]
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, $doc1);
+ INSERT INTO t1 (rowid, content) VALUES(2, $doc2);
+ INSERT INTO t1 (rowid, content) VALUES(3, $doc3);
+}
+
+# No hits at all. Returns empty doclists from termSelect().
+do_test fts3ah-1.1 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
+} {}
+
+do_test fts3ah-1.2 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}
+} {1 3}
+
+do_test fts3ah-1.3 {
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}
+} {}
+
+do_test fts3ah-1.4 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'"
+} {1 3}
+
+do_test fts3ah-1.5 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'"
+} {1}
+
+finish_test
diff --git a/test/fts3ai.test b/test/fts3ai.test
new file mode 100644
index 0000000..144b4c3
--- /dev/null
+++ b/test/fts3ai.test
@@ -0,0 +1,87 @@
+# 2007 January 17
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite fts3 library. The
+# focus here is testing handling of UPDATE when using UTF-16-encoded
+# databases.
+#
+# $Id: fts3ai.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Return the UTF-16 representation of the supplied UTF-8 string $str.
+# If $nt is true, append two 0x00 bytes as a nul terminator.
+# NOTE(shess) Copied from capi3.test.
+proc utf16 {str {nt 1}} {
+ set r [encoding convertto unicode $str]
+ if {$nt} {
+ append r "\x00\x00"
+ }
+ return $r
+}
+
+db eval {
+ PRAGMA encoding = "UTF-16le";
+ CREATE VIRTUAL TABLE t1 USING fts3(content);
+}
+
+do_test fts3ai-1.0 {
+ execsql {PRAGMA encoding}
+} {UTF-16le}
+
+do_test fts3ai-1.1 {
+ execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')}
+ execsql {SELECT content FROM t1 WHERE rowid = 1}
+} {one}
+
+do_test fts3ai-1.2 {
+ set sql "INSERT INTO t1 (rowid, content) VALUES(2, 'two')"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 2}
+} {two}
+
+do_test fts3ai-1.3 {
+ set sql "INSERT INTO t1 (rowid, content) VALUES(3, 'three')"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ set sql "UPDATE t1 SET content = 'trois' WHERE rowid = 3"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 3}
+} {trois}
+
+do_test fts3ai-1.4 {
+ set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}]
+ set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 4}
+} {four}
+
+do_test fts3ai-1.5 {
+ set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}]
+ set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ set sql "UPDATE t1 SET content = 'cinq' WHERE rowid = 5"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+ sqlite3_finalize $STMT
+ execsql {SELECT content FROM t1 WHERE rowid = 5}
+} {cinq}
+
+finish_test
diff --git a/test/fts3aj.test b/test/fts3aj.test
new file mode 100644
index 0000000..f3d46f2
--- /dev/null
+++ b/test/fts3aj.test
@@ -0,0 +1,89 @@
+# 2007 February 6
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. This
+# tests creating fts3 tables in an attached database.
+#
+# $Id: fts3aj.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Clean up anything left over from a previous pass.
+forcedelete test2.db
+forcedelete test2.db-journal
+sqlite3 db2 test2.db
+
+db eval {
+ CREATE VIRTUAL TABLE t3 USING fts3(content);
+ INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
+}
+
+db2 eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
+ INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
+}
+
+# This has always worked because the t1_* tables used by fts3 will be
+# the defaults.
+do_test fts3aj-1.1 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS two;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'hello';
+ DETACH DATABASE two;
+ }
+} {1 2}
+# Make certain we're detached if there was an error.
+catch {db eval {DETACH DATABASE two}}
+
+# In older code, this appears to work fine, but the t2_* tables used
+# by fts3 will be created in database 'main' instead of database
+# 'two'. It appears to work fine because the tables end up being the
+# defaults, but obviously is badly broken if you hope to use things
+# other than in the exact same ATTACH setup.
+do_test fts3aj-1.2 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS two;
+ CREATE VIRTUAL TABLE two.t2 USING fts3(content);
+ INSERT INTO t2 (rowid, content) VALUES(1, "hello world");
+ INSERT INTO t2 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO t2 (rowid, content) VALUES(3, "cruel world");
+ SELECT rowid FROM t2 WHERE t2 MATCH 'hello';
+ DETACH DATABASE two;
+ }
+} {1 2}
+catch {db eval {DETACH DATABASE two}}
+
+# In older code, this broke because the fts3 code attempted to create
+# t3_* tables in database 'main', but they already existed. Normally
+# this wouldn't happen without t3 itself existing, in which case the
+# fts3 code would never be called in the first place.
+do_test fts3aj-1.3 {
+ execsql {
+ ATTACH DATABASE 'test2.db' AS two;
+
+ CREATE VIRTUAL TABLE two.t3 USING fts3(content);
+ INSERT INTO two.t3 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO two.t3 (rowid, content) VALUES(3, "cruel world");
+ SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello';
+
+ DETACH DATABASE two;
+ } db2
+} {2}
+catch {db eval {DETACH DATABASE two}}
+
+catch {db2 close}
+forcedelete test2.db
+
+finish_test
diff --git a/test/fts3ak.test b/test/fts3ak.test
new file mode 100644
index 0000000..a263f0b
--- /dev/null
+++ b/test/fts3ak.test
@@ -0,0 +1,105 @@
+# 2007 March 9
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. These
+# make sure that fts3 insertion buffering is fully transparent when
+# using transactions.
+#
+# $Id: fts3ak.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(content);
+ INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
+ INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
+ INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
+}
+
+# Test that possibly-buffered inserts went through after commit.
+do_test fts3ak-1.1 {
+ execsql {
+ BEGIN TRANSACTION;
+ INSERT INTO t1 (rowid, content) VALUES(4, "false world");
+ INSERT INTO t1 (rowid, content) VALUES(5, "false door");
+ COMMIT TRANSACTION;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+ }
+} {1 3 4}
+
+# Test that buffered inserts are seen by selects in the same
+# transaction.
+do_test fts3ak-1.2 {
+ execsql {
+ BEGIN TRANSACTION;
+ INSERT INTO t1 (rowid, content) VALUES(6, "another world");
+ INSERT INTO t1 (rowid, content) VALUES(7, "another test");
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+ COMMIT TRANSACTION;
+ }
+} {1 3 4 6}
+
+# Test that buffered inserts are seen within a transaction. This is
+# really the same test as 1.2.
+do_test fts3ak-1.3 {
+ execsql {
+ BEGIN TRANSACTION;
+ INSERT INTO t1 (rowid, content) VALUES(8, "second world");
+ INSERT INTO t1 (rowid, content) VALUES(9, "second sight");
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+ ROLLBACK TRANSACTION;
+ }
+} {1 3 4 6 8}
+
+# Double-check that the previous result doesn't persist past the
+# rollback!
+do_test fts3ak-1.4 {
+ execsql {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+ }
+} {1 3 4 6}
+
+# Test it all together.
+do_test fts3ak-1.5 {
+ execsql {
+ BEGIN TRANSACTION;
+ INSERT INTO t1 (rowid, content) VALUES(10, "second world");
+ INSERT INTO t1 (rowid, content) VALUES(11, "second sight");
+ ROLLBACK TRANSACTION;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+ }
+} {1 3 4 6}
+
+# Test that the obvious case works.
+do_test fts3ak-1.6 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 (rowid, content) VALUES(12, "third world");
+ COMMIT;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'third';
+ }
+} {12}
+
+# This is exactly the same as the previous test, except that older
+# code loses the INSERT due to an SQLITE_SCHEMA error.
+do_test fts3ak-1.7 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 (rowid, content) VALUES(13, "third dimension");
+ CREATE TABLE x (c);
+ COMMIT;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'dimension';
+ }
+} {13}
+
+finish_test
diff --git a/test/fts3al.test b/test/fts3al.test
new file mode 100644
index 0000000..02cc0d1
--- /dev/null
+++ b/test/fts3al.test
@@ -0,0 +1,73 @@
+# 2007 March 28
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing isspace/isalnum/tolower problems with the
+# FTS3 module. Unfortunately, this code isn't a really principled set
+# of tests, because it is impossible to know where new uses of these
+# functions might appear.
+#
+# $Id: fts3al.test,v 1.2 2007/12/13 21:54:11 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Tests that startsWith() (calls isspace, tolower, isalnum) can handle
+# hi-bit chars. parseSpec() also calls isalnum here.
+do_test fts3al-1.1 {
+ execsql "CREATE VIRTUAL TABLE t1 USING fts3(content, \x80)"
+} {}
+
+# Additionally tests isspace() call in getToken(), and isalnum() call
+# in tokenListToIdList().
+do_test fts3al-1.2 {
+ catch {
+ execsql "CREATE VIRTUAL TABLE t2 USING fts3(content, tokenize \x80)"
+ }
+ sqlite3_errmsg $DB
+} "unknown tokenizer: \x80"
+
+# Additionally test final isalnum() in startsWith().
+do_test fts3al-1.3 {
+ execsql "CREATE VIRTUAL TABLE t3 USING fts3(content, tokenize\x80)"
+} {}
+
+# The snippet-generation code has calls to isspace() which are sort of
+# hard to get to. It finds convenient breakpoints by starting ~40
+# chars before and after the matched term, and scanning ~10 chars
+# around that position for isspace() characters. The long word with
+# embedded hi-bit chars causes one of these isspace() calls to be
+# exercised. The version with a couple extra spaces should cause the
+# other isspace() call to be exercised. [Both cases have been tested
+# in the debugger, but I'm hoping to continue to catch it if simple
+# constant changes change things slightly.
+#
+# The trailing and leading hi-bit chars help with code which tests for
+# isspace() to coalesce multiple spaces.
+#
+# UPDATE: The above is no longer true; there is no such code in fts3.
+# But leave the test in just the same.
+#
+
+set word "\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80"
+set phrase1 "$word $word $word target $word $word $word"
+set phrase2 "$word $word $word target $word $word $word"
+
+db eval {CREATE VIRTUAL TABLE t4 USING fts3(content)}
+db eval "INSERT INTO t4 (content) VALUES ('$phrase1')"
+db eval "INSERT INTO t4 (content) VALUES ('$phrase2')"
+
+do_test fts3al-1.4 {
+ execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}
+} {1 241 2 247}
+
+finish_test
diff --git a/test/fts3am.test b/test/fts3am.test
new file mode 100644
index 0000000..4a09cd8
--- /dev/null
+++ b/test/fts3am.test
@@ -0,0 +1,65 @@
+# 2007 April 9
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. fts3
+# DELETE handling assumed all fields were non-null. This was not
+# the intention at all.
+#
+# $Id: fts3am.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(col_a, col_b);
+
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing');
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null);
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b');
+ INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null);
+}
+
+do_test fts3am-1.0 {
+ execsql {
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {2 2 4}
+
+do_test fts3am-1.1 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 1;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {1 1 3}
+
+do_test fts3am-1.2 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 2;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {0 1 2}
+
+do_test fts3am-1.3 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 3;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {0 0 1}
+
+do_test fts3am-1.4 {
+ execsql {
+ DELETE FROM t1 WHERE rowid = 4;
+ SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
+ }
+} {0 0 0}
+
+finish_test
diff --git a/test/fts3an.test b/test/fts3an.test
new file mode 100644
index 0000000..5211027
--- /dev/null
+++ b/test/fts3an.test
@@ -0,0 +1,218 @@
+# 2007 April 26
+#
+# The author disclaims copyright to this source code.
+#
+#*************************************************************************
+# This file implements tests for prefix-searching in the fts3
+# component of the SQLite library.
+#
+# $Id: fts3an.test,v 1.2 2007/12/13 21:54:11 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# A large string to prime the pump with.
+set text {
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
+ iaculis mollis ipsum. Praesent rhoncus placerat justo. Duis non quam
+ sed turpis posuere placerat. Curabitur et lorem in lorem porttitor
+ aliquet. Pellentesque bibendum tincidunt diam. Vestibulum blandit
+ ante nec elit. In sapien diam, facilisis eget, dictum sed, viverra
+ at, felis. Vestibulum magna. Sed magna dolor, vestibulum rhoncus,
+ ornare vel, vulputate sit amet, felis. Integer malesuada, tellus at
+ luctus gravida, diam nunc porta nibh, nec imperdiet massa metus eu
+ lectus. Aliquam nisi. Nunc fringilla nulla at lectus. Suspendisse
+ potenti. Cum sociis natoque penatibus et magnis dis parturient
+ montes, nascetur ridiculus mus. Pellentesque odio nulla, feugiat eu,
+ suscipit nec, consequat quis, risus.
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+
+ INSERT INTO t1(rowid, c) VALUES(1, $text);
+ INSERT INTO t1(rowid, c) VALUES(2, 'Another lovely row');
+}
+
+# Exact match
+do_test fts3an-1.1 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lorem'"
+} {1}
+
+# And a prefix
+do_test fts3an-1.2 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lore*'"
+} {1}
+
+# Prefix includes exact match
+do_test fts3an-1.3 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lorem*'"
+} {1}
+
+# Make certain everything isn't considered a prefix!
+do_test fts3an-1.4 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lore'"
+} {}
+
+# Prefix across multiple rows.
+do_test fts3an-1.5 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lo*'"
+} {1 2}
+
+# Likewise, with multiple hits in one document.
+do_test fts3an-1.6 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'l*'"
+} {1 2}
+
+# Prefix which should only hit one document.
+do_test fts3an-1.7 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lov*'"
+} {2}
+
+# * not at end is dropped.
+do_test fts3an-1.8 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lo *'"
+} {}
+
+# Stand-alone * is dropped.
+do_test fts3an-1.9 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '*'"
+} {}
+
+# Phrase-query prefix.
+do_test fts3an-1.10 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"lovely r*\"'"
+} {2}
+do_test fts3an-1.11 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"lovely r\"'"
+} {}
+
+# Phrase query with multiple prefix matches.
+do_test fts3an-1.12 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"a* l*\"'"
+} {1 2}
+
+# Phrase query with multiple prefix matches.
+do_test fts3an-1.13 {
+ execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"a* l* row\"'"
+} {2}
+
+
+
+
+# Test across updates (and, by implication, deletes).
+
+# Version of text without "lorem".
+regsub -all {[Ll]orem} $text '' ntext
+
+db eval {
+ CREATE VIRTUAL TABLE t2 USING fts3(c);
+
+ INSERT INTO t2(rowid, c) VALUES(1, $text);
+ INSERT INTO t2(rowid, c) VALUES(2, 'Another lovely row');
+ UPDATE t2 SET c = $ntext WHERE rowid = 1;
+}
+
+# Can't see lorem as an exact match.
+do_test fts3an-2.1 {
+ execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lorem'"
+} {}
+
+# Can't see a prefix of lorem, either.
+do_test fts3an-2.2 {
+ execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lore*'"
+} {}
+
+# Can see lovely in the other document.
+do_test fts3an-2.3 {
+ execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lo*'"
+} {2}
+
+# Can still see other hits.
+do_test fts3an-2.4 {
+ execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'l*'"
+} {1 2}
+
+# Prefix which should only hit one document.
+do_test fts3an-2.5 {
+ execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lov*'"
+} {2}
+
+
+
+# Test with a segment which will have multiple levels in the tree.
+
+# Build a big document with lots of unique terms.
+set bigtext $text
+foreach c {a b c d e} {
+ regsub -all {[A-Za-z]+} $bigtext "&$c" t
+ append bigtext $t
+}
+
+# Populate a table with many copies of the big document, so that we
+# can test the number of hits found. Populate $ret with the expected
+# hit counts for each row. offsets() returns 4 elements for every
+# hit. We'll have 6 hits for row 1, 1 for row 2, and 6*(2^5)==192 for
+# $bigtext.
+set ret {6 1}
+db eval {
+ BEGIN;
+ CREATE VIRTUAL TABLE t3 USING fts3(c);
+
+ INSERT INTO t3(rowid, c) VALUES(1, $text);
+ INSERT INTO t3(rowid, c) VALUES(2, 'Another lovely row');
+}
+for {set i 0} {$i<68} {incr i} {
+ db eval {INSERT INTO t3(rowid, c) VALUES(3+$i, $bigtext)}
+ lappend ret 192
+}
+db eval {COMMIT;}
+
+# Test that we get the expected number of hits.
+do_test fts3an-3.1 {
+ set t {}
+ db eval {SELECT offsets(t3) as o FROM t3 WHERE t3 MATCH 'l*'} {
+ set l [llength $o]
+ lappend t [expr {$l/4}]
+ }
+ set t
+} $ret
+
+# Test a boundary condition: More than 2^16 terms that match a searched for
+# prefix in a single segment.
+#
+puts "This next test can take a little while (~ 30 seconds)..."
+do_test fts3an-4.1 {
+ execsql { CREATE VIRTUAL TABLE ft USING fts3(x) }
+ execsql BEGIN
+ execsql { INSERT INTO ft VALUES(NULL) }
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 2
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 4
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 8
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 16
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 32
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 64
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 128
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 256
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 512
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 1024
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 2048
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 4096
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 8192
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 16384
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 32768
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 65536
+ execsql { INSERT INTO ft SELECT * FROM ft } ;# 131072
+ execsql COMMIT
+ execsql { UPDATE ft SET x = 'abc' || rowid }
+ execsql { SELECT count(*) FROM ft WHERE x MATCH 'abc*' }
+} {131072}
+
+finish_test
diff --git a/test/fts3ao.test b/test/fts3ao.test
new file mode 100644
index 0000000..786667a
--- /dev/null
+++ b/test/fts3ao.test
@@ -0,0 +1,223 @@
+# 2007 June 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module.
+#
+# $Id: fts3ao.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+set ::testprefix fts3ao
+
+#---------------------------------------------------------------------
+# These tests, fts3ao-1.*, test that ticket #2429 is fixed.
+#
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(a, b, c);
+ INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');
+}
+do_test fts3ao-1.1 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four';
+ }
+} {1 {one <b>four</b> two}}
+do_test fts3ao-1.2 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE b MATCH 'four';
+ }
+} {1 {one <b>four</b>}}
+do_test fts3ao-1.3 {
+ execsql {
+ SELECT rowid, snippet(t1) FROM t1 WHERE a MATCH 'four';
+ }
+} {1 {one three <b>four</b>}}
+
+#---------------------------------------------------------------------
+# Test that it is possible to rename an fts3 table.
+#
+do_test fts3ao-2.1 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {t1 t1_content t1_segments t1_segdir}
+do_test fts3ao-2.2 {
+ execsql { ALTER TABLE t1 RENAME to fts_t1; }
+} {}
+do_test fts3ao-2.3 {
+ execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
+} {1 {one three <b>four</b>}}
+do_test fts3ao-2.4 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir}
+
+# See what happens when renaming the fts3 table fails.
+#
+do_test fts3ao-2.5 {
+ catchsql {
+ CREATE TABLE t1_segdir(a, b, c);
+ ALTER TABLE fts_t1 RENAME to t1;
+ }
+} {1 {SQL logic error or missing database}}
+do_test fts3ao-2.6 {
+ execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
+} {1 {one three <b>four</b>}}
+do_test fts3ao-2.7 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir t1_segdir}
+
+# See what happens when renaming the fts3 table fails inside a transaction.
+#
+do_test fts3ao-2.8 {
+ execsql {
+ BEGIN;
+ INSERT INTO fts_t1(a, b, c) VALUES('one two three', 'one four', 'one two');
+ }
+} {}
+do_test fts3ao-2.9 {
+ catchsql {
+ ALTER TABLE fts_t1 RENAME to t1;
+ }
+} {1 {SQL logic error or missing database}}
+do_test fts3ao-2.10 {
+ execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
+} {1 {one three <b>four</b>}}
+do_test fts3ao-2.11 {
+ execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
+} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir t1_segdir}
+do_test fts3ao-2.12 {
+ execsql COMMIT
+ execsql {SELECT a FROM fts_t1}
+} {{one three four} {one two three}}
+do_test fts3ao-2.12 {
+ execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; }
+} {{one three four} {one four} {one four two}}
+
+#-------------------------------------------------------------------
+# Close, delete and reopen the database. The following test should
+# be run on an initially empty db.
+#
+db close
+forcedelete test.db test.db-journal
+sqlite3 db test.db
+
+do_test fts3ao-3.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts3(a, b, c);
+ INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two');
+ SELECT a, b, c FROM t1 WHERE c MATCH 'two';
+ }
+} {{one three four} {one four} {one two}}
+
+# This test was crashing at one point.
+#
+do_test fts3ao-3.2 {
+ execsql {
+ SELECT a, b, c FROM t1 WHERE c MATCH 'two';
+ CREATE TABLE t3(a, b, c);
+ SELECT a, b, c FROM t1 WHERE c MATCH 'two';
+ }
+} {{one three four} {one four} {one two} {one three four} {one four} {one two}}
+
+#---------------------------------------------------------------------
+# Test that it is possible to rename an fts3 table in an attached
+# database.
+#
+forcedelete test2.db test2.db-journal
+
+do_test fts3ao-3.1 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ CREATE VIRTUAL TABLE aux.t1 USING fts3(a, b, c);
+ INSERT INTO aux.t1(a, b, c) VALUES(
+ 'neung song sahm', 'neung see', 'neung see song'
+ );
+ }
+} {}
+
+do_test fts3ao-3.2 {
+ execsql { SELECT a, b, c FROM aux.t1 WHERE a MATCH 'song'; }
+} {{neung song sahm} {neung see} {neung see song}}
+
+do_test fts3ao-3.3 {
+ execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
+} {{one three four} {one four} {one two}}
+
+do_test fts3ao-3.4 {
+ execsql { ALTER TABLE aux.t1 RENAME TO t2 }
+} {}
+
+do_test fts3ao-3.2 {
+ execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; }
+} {{neung song sahm} {neung see} {neung see song}}
+
+do_test fts3ao-3.3 {
+ execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
+} {{one three four} {one four} {one two}}
+
+#---------------------------------------------------------------------
+# Test that it is possible to rename an fts3 table within a
+# transaction.
+#
+do_test fts3ao-4.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t4 USING fts3;
+ INSERT INTO t4 VALUES('the quick brown fox');
+ }
+} {}
+do_test fts3ao-4.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO t4 VALUES('jumped over the');
+ }
+} {}
+do_test fts3ao-4.3 { execsql { ALTER TABLE t4 RENAME TO t5; } } {}
+do_test fts3ao-4.4 { execsql { INSERT INTO t5 VALUES('lazy dog'); } } {}
+do_test fts3ao-4.5 { execsql COMMIT } {}
+do_test fts3ao-4.6 {
+ execsql { SELECT * FROM t5 }
+} {{the quick brown fox} {jumped over the} {lazy dog}}
+do_test fts3ao-4.7 {
+ execsql {
+ BEGIN;
+ INSERT INTO t5 VALUES('Down came a jumbuck to drink at that billabong');
+ ALTER TABLE t5 RENAME TO t6;
+ INSERT INTO t6 VALUES('Down came the troopers, one, two, three');
+ ROLLBACK;
+ SELECT * FROM t5;
+ }
+} {{the quick brown fox} {jumped over the} {lazy dog}}
+do_execsql_test fts3ao-4.8 {
+ SELECT snippet(t5, '[', ']') FROM t5 WHERE t5 MATCH 'the'
+} {{[the] quick brown fox} {jumped over [the]}}
+
+# Test that it is possible to rename an FTS4 table. Renaming an FTS4 table
+# involves renaming the extra %_docsize and %_stat tables.
+#
+do_execsql_test 5.1 {
+ CREATE VIRTUAL TABLE t7 USING FTS4;
+ INSERT INTO t7 VALUES('coined by a German clinician');
+ SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%';
+ SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%';
+} {6 0}
+do_execsql_test 5.2 {
+ ALTER TABLE t7 RENAME TO t8;
+ SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%';
+ SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%';
+} {0 6}
+
+finish_test
+
diff --git a/test/fts3atoken.test b/test/fts3atoken.test
new file mode 100644
index 0000000..554259d
--- /dev/null
+++ b/test/fts3atoken.test
@@ -0,0 +1,187 @@
+# 2007 June 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing the pluggable tokeniser feature of the
+# FTS3 module.
+#
+# $Id: fts3atoken.test,v 1.1 2007/08/20 17:38:42 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+set ::testprefix fts3token
+
+proc escape_string {str} {
+ set out ""
+ foreach char [split $str ""] {
+ scan $char %c i
+ if {$i<=127} {
+ append out $char
+ } else {
+ append out [format {\x%.4x} $i]
+ }
+ }
+ set out
+}
+
+#--------------------------------------------------------------------------
+# Test cases fts3token-1.* are the warm-body test for the SQL scalar
+# function fts3_tokenizer(). The procedure is as follows:
+#
+# 1: Verify that there is no such fts3 tokenizer as 'blah'.
+#
+# 2: Query for the built-in tokenizer 'simple'. Insert a copy of the
+# retrieved value as tokenizer 'blah'.
+#
+# 3: Test that the value returned for tokenizer 'blah' is now the
+# same as that retrieved for 'simple'.
+#
+# 4: Test that it is now possible to create an fts3 table using
+# tokenizer 'blah' (it was not possible in step 1).
+#
+# 5: Test that the table created to use tokenizer 'blah' is usable.
+#
+do_test fts3token-1.1 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);
+ }
+} {1 {unknown tokenizer: blah}}
+do_test fts3token-1.2 {
+ execsql {
+ SELECT fts3_tokenizer('blah', fts3_tokenizer('simple')) IS NULL;
+ }
+} {0}
+do_test fts3token-1.3 {
+ execsql {
+ SELECT fts3_tokenizer('blah') == fts3_tokenizer('simple');
+ }
+} {1}
+do_test fts3token-1.4 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);
+ }
+} {0 {}}
+do_test fts3token-1.5 {
+ execsql {
+ INSERT INTO t1(content) VALUES('There was movement at the station');
+ INSERT INTO t1(content) VALUES('For the word has passed around');
+ INSERT INTO t1(content) VALUES('That the colt from ol regret had got away');
+ SELECT content FROM t1 WHERE content MATCH 'movement'
+ }
+} {{There was movement at the station}}
+
+#--------------------------------------------------------------------------
+# Test cases fts3token-2.* test error cases in the scalar function based
+# API for getting and setting tokenizers.
+#
+do_test fts3token-2.1 {
+ catchsql {
+ SELECT fts3_tokenizer('nosuchtokenizer');
+ }
+} {1 {unknown tokenizer: nosuchtokenizer}}
+
+#--------------------------------------------------------------------------
+# Test cases fts3token-3.* test the three built-in tokenizers with a
+# simple input string via the built-in test function. This is as much
+# to test the test function as the tokenizer implementations.
+#
+do_test fts3token-3.1 {
+ execsql {
+ SELECT fts3_tokenizer_test('simple', 'I don''t see how');
+ }
+} {{0 i I 1 don don 2 t t 3 see see 4 how how}}
+do_test fts3token-3.2 {
+ execsql {
+ SELECT fts3_tokenizer_test('porter', 'I don''t see how');
+ }
+} {{0 i I 1 don don 2 t t 3 see see 4 how how}}
+ifcapable icu {
+ do_test fts3token-3.3 {
+ execsql {
+ SELECT fts3_tokenizer_test('icu', 'I don''t see how');
+ }
+ } {{0 i I 1 don't don't 2 see see 3 how how}}
+}
+
+#--------------------------------------------------------------------------
+# Test cases fts3token-4.* test the ICU tokenizer. In practice, this
+# tokenizer only has two modes - "thai" and "everybody else". Some other
+# Asian languages (Lao, Khmer etc.) require the same special treatment as
+# Thai, but ICU doesn't support them yet.
+#
+ifcapable icu {
+
+ proc do_icu_test {name locale input output} {
+ set ::out [db eval { SELECT fts3_tokenizer_test('icu', $locale, $input) }]
+ do_test $name {
+ lindex $::out 0
+ } $output
+ }
+
+ do_icu_test fts3token-4.1 en_US {} {}
+ do_icu_test fts3token-4.2 en_US {Test cases fts3} [list \
+ 0 test Test 1 cases cases 2 fts3 fts3
+ ]
+
+ # The following test shows that ICU is smart enough to recognise
+ # Thai chararacters, even when the locale is set to English/United
+ # States.
+ #
+ set input "\u0e2d\u0e30\u0e44\u0e23\u0e19\u0e30\u0e04\u0e23\u0e31\u0e1a"
+ set output "0 \u0e2d\u0e30\u0e44\u0e23 \u0e2d\u0e30\u0e44\u0e23 "
+ append output "1 \u0e19\u0e30 \u0e19\u0e30 "
+ append output "2 \u0e04\u0e23\u0e31\u0e1a \u0e04\u0e23\u0e31\u0e1a"
+
+ do_icu_test fts3token-4.3 th_TH $input $output
+ do_icu_test fts3token-4.4 en_US $input $output
+
+ # ICU handles an unknown locale by falling back to the default.
+ # So this is not an error.
+ do_icu_test fts3token-4.5 MiddleOfTheOcean $input $output
+
+ set longtoken "AReallyReallyLongTokenOneThatWillSurelyRequire"
+ append longtoken "AReallocInTheIcuTokenizerCode"
+
+ set input "short tokens then "
+ append input $longtoken
+ set output "0 short short "
+ append output "1 tokens tokens "
+ append output "2 then then "
+ append output "3 [string tolower $longtoken] $longtoken"
+
+ do_icu_test fts3token-4.6 MiddleOfTheOcean $input $output
+ do_icu_test fts3token-4.7 th_TH $input $output
+ do_icu_test fts3token-4.8 en_US $input $output
+
+ do_execsql_test 5.1 {
+ CREATE VIRTUAL TABLE x1 USING fts3(name,TOKENIZE icu en_US);
+ insert into x1 (name) values (NULL);
+ insert into x1 (name) values (NULL);
+ delete from x1;
+ }
+}
+
+
+do_test fts3token-internal {
+ execsql { SELECT fts3_tokenizer_internal_test() }
+} {ok}
+
+
+finish_test
+
+
diff --git a/test/fts3auto.test b/test/fts3auto.test
new file mode 100644
index 0000000..1c58a17
--- /dev/null
+++ b/test/fts3auto.test
@@ -0,0 +1,704 @@
+# 2011 June 10
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build does not include FTS3, skip the tests in this file.
+#
+ifcapable !fts3 { finish_test ; return }
+source $testdir/fts3_common.tcl
+source $testdir/malloc_common.tcl
+
+set testprefix fts3auto
+set sfep $sqlite_fts3_enable_parentheses
+set sqlite_fts3_enable_parentheses 1
+
+#--------------------------------------------------------------------------
+# Start of Tcl infrastructure used by tests. The entry points are:
+#
+# do_fts3query_test
+# fts3_make_deferrable
+# fts3_zero_long_segments
+#
+
+#
+# do_fts3query_test TESTNAME ?OPTIONS? TABLE MATCHEXPR
+#
+# This proc runs several test cases on FTS3/4 table $TABLE using match
+# expression $MATCHEXPR. All documents in $TABLE must be formatted so that
+# they can be "tokenized" using the Tcl list commands (llength, lindex etc.).
+# The name and column names used by $TABLE must not require any quoting or
+# escaping when used in SQL statements.
+#
+# $MATCHINFO may be any expression accepted by the FTS4 MATCH operator,
+# except that the "<column-name>:token" syntax is not supported. Tcl list
+# commands are used to tokenize the expression. Any parenthesis must appear
+# either as separate list elements, or as the first (for opening) or last
+# (for closing) character of a list element. i.e. the expression "(a OR b)c"
+# will not be parsed correctly, but "( a OR b) c" will.
+#
+# Available OPTIONS are:
+#
+# -deferred TOKENLIST
+#
+# If the "deferred" option is supplied, it is passed a list of tokens that
+# are deferred by FTS and result in the relevant matchinfo() stats being an
+# approximation.
+#
+set sqlite_fts3_enable_parentheses 1
+proc do_fts3query_test {tn args} {
+
+ set nArg [llength $args]
+ if {$nArg < 2 || ($nArg % 2)} {
+ set cmd do_fts3query_test
+ error "wrong # args: should be \"$cmd ?-deferred LIST? TABLE MATCHEXPR\""
+ }
+ set tbl [lindex $args [expr $nArg-2]]
+ set match [lindex $args [expr $nArg-1]]
+ set deferred [list]
+
+ foreach {k v} [lrange $args 0 [expr $nArg-3]] {
+ switch -- $k {
+ -deferred {
+ set deferred $v
+ }
+ default {
+ error "bad option \"$k\": must be -deferred"
+ }
+ }
+ }
+
+ get_near_results $tbl $match $deferred aMatchinfo
+
+ set matchinfo_asc [list]
+ foreach docid [lsort -integer -incr [array names aMatchinfo]] {
+ lappend matchinfo_asc $docid $aMatchinfo($docid)
+ }
+ set matchinfo_desc [list]
+ foreach docid [lsort -integer -decr [array names aMatchinfo]] {
+ lappend matchinfo_desc $docid $aMatchinfo($docid)
+ }
+
+ set title "(\"$match\" -> [llength [array names aMatchinfo]] rows)"
+
+ do_execsql_test $tn$title.1 "
+ SELECT docid FROM $tbl WHERE $tbl MATCH '$match' ORDER BY docid ASC
+ " [lsort -integer -incr [array names aMatchinfo]]
+
+ do_execsql_test $tn$title.2 "
+ SELECT docid FROM $tbl WHERE $tbl MATCH '$match' ORDER BY docid DESC
+ " [lsort -integer -decr [array names aMatchinfo]]
+
+ do_execsql_test $tn$title.3 "
+ SELECT docid, mit(matchinfo($tbl, 'x')) FROM $tbl
+ WHERE $tbl MATCH '$match' ORDER BY docid DESC
+ " $matchinfo_desc
+
+ do_execsql_test $tn$title.4 "
+ SELECT docid, mit(matchinfo($tbl, 'x')) FROM $tbl
+ WHERE $tbl MATCH '$match' ORDER BY docid ASC
+ " $matchinfo_asc
+}
+
+# fts3_make_deferrable TABLE TOKEN ?NROW?
+#
+proc fts3_make_deferrable {tbl token {nRow 0}} {
+
+ set stmt [sqlite3_prepare db "SELECT * FROM $tbl" -1 dummy]
+ set name [sqlite3_column_name $stmt 0]
+ sqlite3_finalize $stmt
+
+ if {$nRow==0} {
+ set nRow [db one "SELECT count(*) FROM $tbl"]
+ }
+ set pgsz [db one "PRAGMA page_size"]
+ execsql BEGIN
+ for {set i 0} {$i < ($nRow * $pgsz * 1.2)/100} {incr i} {
+ set doc [string repeat "$token " 100]
+ execsql "INSERT INTO $tbl ($name) VALUES(\$doc)"
+ }
+ execsql "INSERT INTO $tbl ($name) VALUES('aaaaaaa ${token}aaaaa')"
+ execsql COMMIT
+
+ return [expr $nRow*$pgsz]
+}
+
+# fts3_zero_long_segments TABLE ?LIMIT?
+#
+proc fts3_zero_long_segments {tbl limit} {
+ execsql "
+ UPDATE ${tbl}_segments
+ SET block = zeroblob(length(block))
+ WHERE length(block)>$limit
+ "
+ return [db changes]
+}
+
+
+proc mit {blob} {
+ set scan(littleEndian) i*
+ set scan(bigEndian) I*
+ binary scan $blob $scan($::tcl_platform(byteOrder)) r
+ return $r
+}
+db func mit mit
+
+proc fix_phrase_expr {cols expr colfiltervar} {
+ upvar $colfiltervar iColFilter
+
+ set out [list]
+ foreach t $expr {
+ if {[string match *:* $t]} {
+ set col [lindex [split $t :] 0]
+ set t [lindex [split $t :] 1]
+ set iCol [lsearch $cols $col]
+ if {$iCol<0} { error "unknown column: $col" }
+ if {$iColFilter < 0} {
+ set iColFilter $iCol
+ } elseif {$iColFilter != $iCol} {
+ set iColFilter [llength $cols]
+ }
+ }
+ lappend out $t
+ }
+
+ return $out
+}
+
+proc fix_near_expr {cols expr colfiltervar} {
+ upvar $colfiltervar iColFilter
+
+ set iColFilter -1
+
+ set out [list]
+ lappend out [fix_phrase_expr $cols [lindex $expr 0] iColFilter]
+ foreach {a b} [lrange $expr 1 end] {
+ if {[string match -nocase near $a]} { set a 10 }
+ if {[string match -nocase near/* $a]} { set a [string range $a 5 end] }
+ lappend out $a
+ lappend out [fix_phrase_expr $cols $b iColFilter]
+ }
+ return $out
+}
+
+proc get_single_near_results {tbl expr deferred arrayvar nullvar} {
+ upvar $arrayvar aMatchinfo
+ upvar $nullvar nullentry
+ catch {array unset aMatchinfo}
+
+ set cols [list]
+ set miss [list]
+ db eval "PRAGMA table_info($tbl)" A { lappend cols $A(name) ; lappend miss 0 }
+ set expr [fix_near_expr $cols $expr iColFilter]
+
+ # Calculate the expected results using [fts3_near_match]. The following
+ # loop populates the "hits" and "counts" arrays as follows:
+ #
+ # 1. For each document in the table that matches the NEAR expression,
+ # hits($docid) is set to 1. The set of docids that match the expression
+ # can therefore be found using [array names hits].
+ #
+ # 2. For each column of each document in the table, counts($docid,$iCol)
+ # is set to the -phrasecountvar output.
+ #
+ set res [list]
+ catch { array unset hits }
+ db eval "SELECT docid, * FROM $tbl" d {
+ set iCol 0
+ foreach col [lrange $d(*) 1 end] {
+ set docid $d(docid)
+ if {$iColFilter<0 || $iCol==$iColFilter} {
+ set hit [fts3_near_match $d($col) $expr -p counts($docid,$iCol)]
+ if {$hit} { set hits($docid) 1 }
+ } else {
+ set counts($docid,$iCol) $miss
+ }
+ incr iCol
+ }
+ }
+ set nPhrase [expr ([llength $expr]+1)/2]
+ set nCol $iCol
+
+ # This block populates the nHit and nDoc arrays. For each phrase/column
+ # in the query/table, array elements are set as follows:
+ #
+ # nHit($iPhrase,$iCol) - Total number of hits for phrase $iPhrase in
+ # column $iCol.
+ #
+ # nDoc($iPhrase,$iCol) - Number of documents with at least one hit for
+ # phrase $iPhrase in column $iCol.
+ #
+ for {set iPhrase 0} {$iPhrase < $nPhrase} {incr iPhrase} {
+ for {set iCol 0} {$iCol < $nCol} {incr iCol} {
+ set nHit($iPhrase,$iCol) 0
+ set nDoc($iPhrase,$iCol) 0
+ }
+ }
+ foreach key [array names counts] {
+ set iCol [lindex [split $key ,] 1]
+ set iPhrase 0
+ foreach c $counts($key) {
+ if {$c>0} { incr nDoc($iPhrase,$iCol) 1 }
+ incr nHit($iPhrase,$iCol) $c
+ incr iPhrase
+ }
+ }
+
+ if {[llength $deferred] && [llength $expr]==1} {
+ set phrase [lindex $expr 0]
+ set rewritten [list]
+ set partial 0
+ foreach tok $phrase {
+ if {[lsearch $deferred $tok]>=0} {
+ lappend rewritten *
+ } else {
+ lappend rewritten $tok
+ set partial 1
+ }
+ }
+ if {$partial==0} {
+ set tblsize [db one "SELECT count(*) FROM $tbl"]
+ for {set iCol 0} {$iCol < $nCol} {incr iCol} {
+ set nHit(0,$iCol) $tblsize
+ set nDoc(0,$iCol) $tblsize
+ }
+ } elseif {$rewritten != $phrase} {
+ while {[lindex $rewritten end] == "*"} {
+ set rewritten [lrange $rewritten 0 end-1]
+ }
+ while {[lindex $rewritten 0] == "*"} {
+ set rewritten [lrange $rewritten 1 end]
+ }
+ get_single_near_results $tbl [list $rewritten] {} aRewrite nullentry
+ foreach docid [array names hits] {
+ set aMatchinfo($docid) $aRewrite($docid)
+ }
+ return
+ }
+ }
+
+ # Set up the aMatchinfo array. For each document, set aMatchinfo($docid) to
+ # contain the output of matchinfo('x') for the document.
+ #
+ foreach docid [array names hits] {
+ set mi [list]
+ for {set iPhrase 0} {$iPhrase<$nPhrase} {incr iPhrase} {
+ for {set iCol 0} {$iCol<$nCol} {incr iCol} {
+ lappend mi [lindex $counts($docid,$iCol) $iPhrase]
+ lappend mi $nHit($iPhrase,$iCol)
+ lappend mi $nDoc($iPhrase,$iCol)
+ }
+ }
+ set aMatchinfo($docid) $mi
+ }
+
+ # Set up the nullentry output.
+ #
+ set nullentry [list]
+ for {set iPhrase 0} {$iPhrase<$nPhrase} {incr iPhrase} {
+ for {set iCol 0} {$iCol<$nCol} {incr iCol} {
+ lappend nullentry 0 $nHit($iPhrase,$iCol) $nDoc($iPhrase,$iCol)
+ }
+ }
+}
+
+
+proc matching_brackets {expr} {
+ if {[string range $expr 0 0]!="(" || [string range $expr end end] !=")"} {
+ return 0
+ }
+
+ set iBracket 1
+ set nExpr [string length $expr]
+ for {set i 1} {$iBracket && $i < $nExpr} {incr i} {
+ set c [string range $expr $i $i]
+ if {$c == "("} {incr iBracket}
+ if {$c == ")"} {incr iBracket -1}
+ }
+
+ return [expr ($iBracket==0 && $i==$nExpr)]
+}
+
+proc get_near_results {tbl expr deferred arrayvar {nullvar ""}} {
+ upvar $arrayvar aMatchinfo
+ if {$nullvar != ""} { upvar $nullvar nullentry }
+
+ set expr [string trim $expr]
+ while { [matching_brackets $expr] } {
+ set expr [string trim [string range $expr 1 end-1]]
+ }
+
+ set prec(NOT) 1
+ set prec(AND) 2
+ set prec(OR) 3
+
+ set currentprec 0
+ set iBracket 0
+ set expr_length [llength $expr]
+ for {set i 0} {$i < $expr_length} {incr i} {
+ set op [lindex $expr $i]
+ if {$iBracket==0 && [info exists prec($op)] && $prec($op)>=$currentprec } {
+ set opidx $i
+ set currentprec $prec($op)
+ } else {
+ for {set j 0} {$j < [string length $op]} {incr j} {
+ set c [string range $op $j $j]
+ if {$c == "("} { incr iBracket +1 }
+ if {$c == ")"} { incr iBracket -1 }
+ }
+ }
+ }
+ if {$iBracket!=0} { error "mismatched brackets in: $expr" }
+
+ if {[info exists opidx]==0} {
+ get_single_near_results $tbl $expr $deferred aMatchinfo nullentry
+ } else {
+ set eLeft [lrange $expr 0 [expr $opidx-1]]
+ set eRight [lrange $expr [expr $opidx+1] end]
+
+ get_near_results $tbl $eLeft $deferred aLeft nullleft
+ get_near_results $tbl $eRight $deferred aRight nullright
+
+ switch -- [lindex $expr $opidx] {
+ "NOT" {
+ foreach hit [array names aLeft] {
+ if {0==[info exists aRight($hit)]} {
+ set aMatchinfo($hit) $aLeft($hit)
+ }
+ }
+ set nullentry $nullleft
+ }
+
+ "AND" {
+ foreach hit [array names aLeft] {
+ if {[info exists aRight($hit)]} {
+ set aMatchinfo($hit) [concat $aLeft($hit) $aRight($hit)]
+ }
+ }
+ set nullentry [concat $nullleft $nullright]
+ }
+
+ "OR" {
+ foreach hit [array names aLeft] {
+ if {[info exists aRight($hit)]} {
+ set aMatchinfo($hit) [concat $aLeft($hit) $aRight($hit)]
+ unset aRight($hit)
+ } else {
+ set aMatchinfo($hit) [concat $aLeft($hit) $nullright]
+ }
+ }
+ foreach hit [array names aRight] {
+ set aMatchinfo($hit) [concat $nullleft $aRight($hit)]
+ }
+
+ set nullentry [concat $nullleft $nullright]
+ }
+ }
+ }
+}
+
+
+# End of test procs. Actual tests are below this line.
+#--------------------------------------------------------------------------
+
+#--------------------------------------------------------------------------
+# The following test cases - fts3auto-1.* - focus on testing the Tcl
+# command [fts3_near_match], which is used by other tests in this file.
+#
+proc test_fts3_near_match {tn doc expr res} {
+ fts3_near_match $doc $expr -phrasecountvar p
+ uplevel do_test [list $tn] [list [list set {} $p]] [list $res]
+}
+
+test_fts3_near_match 1.1.1 {a b c a b} a {2}
+test_fts3_near_match 1.1.2 {a b c a b} {a 5 b 6 c} {2 2 1}
+test_fts3_near_match 1.1.3 {a b c a b} {"a b"} {2}
+test_fts3_near_match 1.1.4 {a b c a b} {"b c"} {1}
+test_fts3_near_match 1.1.5 {a b c a b} {"c c"} {0}
+
+test_fts3_near_match 1.2.1 "a b c d e f g" {b 2 f} {0 0}
+test_fts3_near_match 1.2.2 "a b c d e f g" {b 3 f} {1 1}
+test_fts3_near_match 1.2.3 "a b c d e f g" {f 2 b} {0 0}
+test_fts3_near_match 1.2.4 "a b c d e f g" {f 3 b} {1 1}
+test_fts3_near_match 1.2.5 "a b c d e f g" {"a b" 2 "f g"} {0 0}
+test_fts3_near_match 1.2.6 "a b c d e f g" {"a b" 3 "f g"} {1 1}
+
+set A "a b c d e f g h i j k l m n o p q r s t u v w x y z"
+test_fts3_near_match 1.3.1 $A {"c d" 5 "i j" 1 "e f"} {0 0 0}
+test_fts3_near_match 1.3.2 $A {"c d" 5 "i j" 2 "e f"} {1 1 1}
+
+#--------------------------------------------------------------------------
+# Test cases fts3auto-2.* run some simple tests using the
+# [do_fts3query_test] proc.
+#
+foreach {tn create} {
+ 1 "fts4(a, b)"
+ 2 "fts4(a, b, order=DESC)"
+ 3 "fts4(a, b, order=ASC)"
+ 4 "fts4(a, b, prefix=1)"
+ 5 "fts4(a, b, order=DESC, prefix=1)"
+ 6 "fts4(a, b, order=ASC, prefix=1)"
+} {
+ do_test 2.$tn.1 {
+ catchsql { DROP TABLE t1 }
+ execsql "CREATE VIRTUAL TABLE t1 USING $create"
+ for {set i 0} {$i<32} {incr i} {
+ set doc [list]
+ if {$i&0x01} {lappend doc one}
+ if {$i&0x02} {lappend doc two}
+ if {$i&0x04} {lappend doc three}
+ if {$i&0x08} {lappend doc four}
+ if {$i&0x10} {lappend doc five}
+ execsql { INSERT INTO t1 VALUES($doc, null) }
+ }
+ } {}
+
+ foreach {tn2 expr} {
+ 1 {one}
+ 2 {one NEAR/1 five}
+ 3 {t*}
+ 4 {t* NEAR/0 five}
+ 5 {o* NEAR/1 f*}
+ 6 {one NEAR five NEAR two NEAR four NEAR three}
+ 7 {one NEAR xyz}
+ 8 {one OR two}
+ 9 {one AND two}
+ 10 {one NOT two}
+ 11 {one AND two OR three}
+ 12 {three OR one AND two}
+ 13 {(three OR one) AND two}
+ 14 {(three OR one) AND two NOT (five NOT four)}
+ 15 {"one two"}
+ 16 {"one two" NOT "three four"}
+ } {
+ do_fts3query_test 2.$tn.2.$tn2 t1 $expr
+ }
+}
+
+#--------------------------------------------------------------------------
+# Some test cases involving deferred tokens.
+#
+
+foreach {tn create} {
+ 1 "fts4(x)"
+ 2 "fts4(x, order=DESC)"
+} {
+ catchsql { DROP TABLE t1 }
+ execsql "CREATE VIRTUAL TABLE t1 USING $create"
+ do_execsql_test 3.$tn.1 {
+ INSERT INTO t1(docid, x) VALUES(-2, 'a b c d e f g h i j k');
+ INSERT INTO t1(docid, x) VALUES(-1, 'b c d e f g h i j k a');
+ INSERT INTO t1(docid, x) VALUES(0, 'c d e f g h i j k a b');
+ INSERT INTO t1(docid, x) VALUES(1, 'd e f g h i j k a b c');
+ INSERT INTO t1(docid, x) VALUES(2, 'e f g h i j k a b c d');
+ INSERT INTO t1(docid, x) VALUES(3, 'f g h i j k a b c d e');
+ INSERT INTO t1(docid, x) VALUES(4, 'a c e g i k');
+ INSERT INTO t1(docid, x) VALUES(5, 'a d g j');
+ INSERT INTO t1(docid, x) VALUES(6, 'c a b');
+ }
+
+ set limit [fts3_make_deferrable t1 c]
+
+ do_fts3query_test 3.$tn.2.1 t1 {a OR c}
+
+ do_test 3.$tn.3 {
+ fts3_zero_long_segments t1 $limit
+ } {1}
+
+ foreach {tn2 expr def} {
+ 1 {a NEAR c} {}
+ 2 {a AND c} c
+ 3 {"a c"} c
+ 4 {"c a"} c
+ 5 {"a c" NEAR/1 g} {}
+ 6 {"a c" NEAR/0 g} {}
+ } {
+ do_fts3query_test 3.$tn.4.$tn2 -deferred $def t1 $expr
+ }
+}
+
+#--------------------------------------------------------------------------
+#
+foreach {tn create} {
+ 1 "fts4(x, y)"
+ 2 "fts4(x, y, order=DESC)"
+ 3 "fts4(x, y, order=DESC, prefix=2)"
+} {
+
+ execsql [subst {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING $create;
+ INSERT INTO t1 VALUES('one two five four five', '');
+ INSERT INTO t1 VALUES('', 'one two five four five');
+ INSERT INTO t1 VALUES('one two', 'five four five');
+ }]
+
+ do_fts3query_test 4.$tn.1.1 t1 {one AND five}
+ do_fts3query_test 4.$tn.1.2 t1 {one NEAR five}
+ do_fts3query_test 4.$tn.1.3 t1 {one NEAR/1 five}
+ do_fts3query_test 4.$tn.1.4 t1 {one NEAR/2 five}
+ do_fts3query_test 4.$tn.1.5 t1 {one NEAR/3 five}
+
+ do_test 4.$tn.2 {
+ set limit [fts3_make_deferrable t1 five]
+ execsql { INSERT INTO t1(t1) VALUES('optimize') }
+ expr {[fts3_zero_long_segments t1 $limit]>0}
+ } {1}
+
+ do_fts3query_test 4.$tn.3.1 -deferred five t1 {one AND five}
+ do_fts3query_test 4.$tn.3.2 -deferred five t1 {one NEAR five}
+ do_fts3query_test 4.$tn.3.3 -deferred five t1 {one NEAR/1 five}
+ do_fts3query_test 4.$tn.3.4 -deferred five t1 {one NEAR/2 five}
+
+ do_fts3query_test 4.$tn.3.5 -deferred five t1 {one NEAR/3 five}
+
+ do_fts3query_test 4.$tn.4.1 -deferred fi* t1 {on* AND fi*}
+ do_fts3query_test 4.$tn.4.2 -deferred fi* t1 {on* NEAR fi*}
+ do_fts3query_test 4.$tn.4.3 -deferred fi* t1 {on* NEAR/1 fi*}
+ do_fts3query_test 4.$tn.4.4 -deferred fi* t1 {on* NEAR/2 fi*}
+ do_fts3query_test 4.$tn.4.5 -deferred fi* t1 {on* NEAR/3 fi*}
+}
+
+#--------------------------------------------------------------------------
+# The following test cases - fts3auto-5.* - focus on using prefix indexes.
+#
+set chunkconfig [fts3_configure_incr_load 1 1]
+foreach {tn create pending} {
+ 1 "fts4(a, b)" 1
+ 2 "fts4(a, b, order=ASC, prefix=1)" 1
+ 3 "fts4(a, b, order=ASC, prefix=1,3)" 0
+ 4 "fts4(a, b, order=DESC, prefix=2,4)" 0
+ 5 "fts4(a, b, order=DESC, prefix=1)" 0
+ 6 "fts4(a, b, order=ASC, prefix=1,3)" 0
+} {
+
+ execsql [subst {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING $create;
+ }]
+
+ if {$pending} {execsql BEGIN}
+
+ foreach {a b} {
+ "the song of songs which is solomons"
+ "let him kiss me with the kisses of his mouth for thy love is better than wine"
+ "because of the savour of thy good ointments thy name is as ointment poured forth therefore do the virgins love thee"
+ "draw me we will run after thee the king hath brought me into his chambers we will be glad and rejoice in thee we will remember thy love more than wine the upright love thee"
+ "i am black but comely o ye daughters of jerusalem as the tents of kedar as the curtains of solomon"
+ "look not upon me because i am black because the sun hath looked upon me my mothers children were angry with me they made me the keeper of the vineyards but mine own vineyard have i not kept"
+ "tell me o thou whom my soul loveth where thou feedest where thou makest thy flock to rest at noon for why should i be as one that turneth aside by the flocks of thy companions?"
+ "if thou know not o thou fairest among women go thy way forth by the footsteps of the flock and feed thy kids beside the shepherds tents"
+ "i have compared thee o my love to a company of horses in pharaohs chariots"
+ "thy cheeks are comely with rows of jewels thy neck with chains of gold"
+ "we will make thee borders of gold with studs of silver"
+ "while the king sitteth at his table my spikenard sendeth forth the smell thereof"
+ "a bundle of myrrh is my wellbeloved unto me he shall lie all night betwixt my breasts"
+ "my beloved is unto me as a cluster of camphire in the vineyards of en gedi"
+ "behold thou art fair my love behold thou art fair thou hast doves eyes"
+ "behold thou art fair my beloved yea pleasant also our bed is green"
+ "the beams of our house are cedar and our rafters of fir"
+ } {
+ execsql {INSERT INTO t1(a, b) VALUES($a, $b)}
+ }
+
+
+ do_fts3query_test 5.$tn.1.1 t1 {s*}
+ do_fts3query_test 5.$tn.1.2 t1 {so*}
+ do_fts3query_test 5.$tn.1.3 t1 {"s* o*"}
+ do_fts3query_test 5.$tn.1.4 t1 {b* NEAR/3 a*}
+ do_fts3query_test 5.$tn.1.5 t1 {a*}
+ do_fts3query_test 5.$tn.1.6 t1 {th* NEAR/5 a* NEAR/5 w*}
+ do_fts3query_test 5.$tn.1.7 t1 {"b* th* art* fair*"}
+
+ if {$pending} {execsql COMMIT}
+}
+eval fts3_configure_incr_load $chunkconfig
+
+foreach {tn pending create} {
+ 1 0 "fts4(a, b, c, d)"
+ 2 1 "fts4(a, b, c, d)"
+ 3 0 "fts4(a, b, c, d, order=DESC)"
+ 4 1 "fts4(a, b, c, d, order=DESC)"
+} {
+ execsql [subst {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING $create;
+ }]
+
+
+ if {$pending} { execsql BEGIN }
+
+ foreach {a b c d} {
+ "A B C" "D E F" "G H I" "J K L"
+ "B C D" "E F G" "H I J" "K L A"
+ "C D E" "F G H" "I J K" "L A B"
+ "D E F" "G H I" "J K L" "A B C"
+ "E F G" "H I J" "K L A" "B C D"
+ "F G H" "I J K" "L A B" "C D E"
+ } {
+ execsql { INSERT INTO t1 VALUES($a, $b, $c, $d) }
+ }
+
+ do_fts3query_test 6.$tn.1 t1 {b:G}
+ do_fts3query_test 6.$tn.2 t1 {b:G AND c:I}
+ do_fts3query_test 6.$tn.3 t1 {b:G NEAR c:I}
+ do_fts3query_test 6.$tn.4 t1 {a:C OR b:G OR c:K OR d:C}
+ do_fts3query_test 6.$tn.5 t1 {a:G OR b:G}
+
+ catchsql { COMMIT }
+}
+
+foreach {tn create} {
+ 1 "fts4(x)"
+ 2 "fts4(x, order=DESC)"
+} {
+ execsql [subst {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING $create;
+ }]
+
+ foreach {x} {
+ "F E N O T K X V A X I E X A P G Q V H U"
+ "R V A E T C V Q N I E L O N U G J K L U"
+ "U Y I G W M V F J L X I D C H F P J Q B"
+ "S G D Z X R P G S S Y B K A S G A I L L"
+ "L S I C H T Z S R Q P R N K J X L F M J"
+ "C C C D P X B Z C M A D A C X S B T X V"
+ "W Y J M D R G V R K B X S A W R I T N C"
+ "P K L W T M S P O Y Y V V O E H Q A I R"
+ "C D Y I C Z F H J C O Y A Q F L S B D K"
+ "P G S C Y C Y V I M B D S Z D D Y W I E"
+ "Z K Z U E E S F Y X T U A L W O U J C Q"
+ "P A T Z S W L P L Q V Y Y I P W U X S S"
+ "I U I H U O F Z F R H R F T N D X A G M"
+ "N A B M S H K X S O Y D T X S B R Y H Z"
+ "L U D A S K I L S V Z J P U B E B Y H M"
+ } {
+ execsql { INSERT INTO t1 VALUES($x) }
+ }
+
+ # Add extra documents to the database such that token "B" will be considered
+ # deferrable if considering the other tokens means that 2 or fewer documents
+ # will be loaded into memory.
+ #
+ fts3_make_deferrable t1 B 2
+
+ # B is not deferred in either of the first two tests below, since filtering
+ # on "M" or "D" returns 10 documents or so. But filtering on "M * D" only
+ # returns 2, so B is deferred in this case.
+ #
+ do_fts3query_test 7.$tn.1 t1 {"M B"}
+ do_fts3query_test 7.$tn.2 t1 {"B D"}
+ do_fts3query_test 7.$tn.3 -deferred B t1 {"M B D"}
+}
+
+set sqlite_fts3_enable_parentheses $sfep
+finish_test
+
diff --git a/test/fts3aux1.test b/test/fts3aux1.test
new file mode 100644
index 0000000..adda586
--- /dev/null
+++ b/test/fts3aux1.test
@@ -0,0 +1,462 @@
+# 2011 January 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !fts3 { finish_test ; return }
+set ::testprefix fts3aux1
+
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4;
+ INSERT INTO t1 VALUES('one two three four');
+ INSERT INTO t1 VALUES('three four five six');
+ INSERT INTO t1 VALUES('one three five seven');
+
+ CREATE VIRTUAL TABLE terms USING fts4aux(t1);
+ SELECT term, documents, occurrences FROM terms WHERE col = '*';
+} {
+ five 2 2 four 2 2 one 2 2 seven 1 1
+ six 1 1 three 3 3 two 1 1
+}
+
+do_execsql_test 1.2 {
+ INSERT INTO t1 VALUES('one one one three three three');
+ SELECT term, documents, occurrences FROM terms WHERE col = '*';
+} {
+ five 2 2 four 2 2 one 3 5 seven 1 1
+ six 1 1 three 4 6 two 1 1
+}
+
+do_execsql_test 1.3.1 { DELETE FROM t1; }
+do_execsql_test 1.3.2 {
+ SELECT term, documents, occurrences FROM terms WHERE col = '*';
+}
+
+do_execsql_test 1.4 {
+ INSERT INTO t1 VALUES('a b a b a b a');
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ SELECT term, documents, occurrences FROM terms WHERE col = '*';
+} {a 256 1024 b 256 768}
+
+#-------------------------------------------------------------------------
+# The following tests verify that the fts4aux module uses the full-text
+# index to reduce the number of rows scanned in the following circumstances:
+#
+# * when there is equality comparison against the term column using the
+# BINARY collating sequence.
+#
+# * when there is a range constraint on the term column using the BINARY
+# collating sequence.
+#
+# And also uses the full-text index to optimize ORDER BY clauses of the
+# form "ORDER BY term ASC" or equivalent.
+#
+# Test organization is:
+#
+# fts3aux1-2.1.*: equality constraints.
+# fts3aux1-2.2.*: range constraints.
+# fts3aux1-2.3.*: ORDER BY optimization.
+#
+
+do_execsql_test 2.0 {
+ DROP TABLE t1;
+ DROP TABLE terms;
+
+ CREATE VIRTUAL TABLE x1 USING fts4(x);
+ INSERT INTO x1(x1) VALUES('nodesize=24');
+ CREATE VIRTUAL TABLE terms USING fts4aux(x1);
+
+ CREATE VIEW terms_v AS
+ SELECT term, documents, occurrences FROM terms WHERE col = '*';
+
+ INSERT INTO x1 VALUES('braes brag bragged bragger bragging');
+ INSERT INTO x1 VALUES('brags braid braided braiding braids');
+ INSERT INTO x1 VALUES('brain brainchild brained braining brains');
+ INSERT INTO x1 VALUES('brainstem brainstems brainstorm brainstorms');
+}
+
+proc rec {varname x} {
+ global $varname
+ incr $varname
+ return 1
+}
+db func rec rec
+
+# Use EQP to show that the WHERE expression "term='braid'" uses a different
+# index number (1) than "+term='braid'" (0).
+#
+do_execsql_test 2.1.1.1 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term='braid'
+} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 1: (~0 rows)} }
+do_execsql_test 2.1.1.2 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term='braid'
+} {0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)}}
+
+# Now show that using "term='braid'" means the virtual table returns
+# only 1 row to SQLite, but "+term='braid'" means all 19 are returned.
+#
+do_test 2.1.2.1 {
+ set cnt 0
+ execsql { SELECT * FROM terms_v WHERE rec('cnt', term) AND term='braid' }
+ set cnt
+} {2}
+do_test 2.1.2.2 {
+ set cnt 0
+ execsql { SELECT * FROM terms_v WHERE rec('cnt', term) AND +term='braid' }
+ set cnt
+} {38}
+
+# Similar to the test immediately above, but using a term ("breakfast") that
+# is not featured in the dataset.
+#
+do_test 2.1.3.1 {
+ set cnt 0
+ execsql { SELECT * FROM terms_v WHERE rec('cnt', term) AND term='breakfast' }
+ set cnt
+} {0}
+do_test 2.1.3.2 {
+ set cnt 0
+ execsql { SELECT * FROM terms_v WHERE rec('cnt', term) AND +term='breakfast' }
+ set cnt
+} {38}
+
+do_execsql_test 2.1.4.1 { SELECT * FROM terms_v WHERE term='braid' } {braid 1 1}
+do_execsql_test 2.1.4.2 { SELECT * FROM terms_v WHERE +term='braid'} {braid 1 1}
+do_execsql_test 2.1.4.3 { SELECT * FROM terms_v WHERE term='breakfast' } {}
+do_execsql_test 2.1.4.4 { SELECT * FROM terms_v WHERE +term='breakfast' } {}
+
+do_execsql_test 2.1.4.5 { SELECT * FROM terms_v WHERE term='cba' } {}
+do_execsql_test 2.1.4.6 { SELECT * FROM terms_v WHERE +term='cba' } {}
+do_execsql_test 2.1.4.7 { SELECT * FROM terms_v WHERE term='abc' } {}
+do_execsql_test 2.1.4.8 { SELECT * FROM terms_v WHERE +term='abc' } {}
+
+# Special case: term=NULL
+#
+do_execsql_test 2.1.5 { SELECT * FROM terms WHERE term=NULL } {}
+
+do_execsql_test 2.2.1.1 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term>'brain'
+} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 2: (~0 rows)} }
+do_execsql_test 2.2.1.2 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term>'brain'
+} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)} }
+
+do_execsql_test 2.2.1.3 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term<'brain'
+} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 4: (~0 rows)} }
+do_execsql_test 2.2.1.4 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term<'brain'
+} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)} }
+
+do_execsql_test 2.2.1.5 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term BETWEEN 'brags' AND 'brain'
+} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 6: (~0 rows)} }
+do_execsql_test 2.2.1.6 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term BETWEEN 'brags' AND 'brain'
+} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)} }
+
+do_test 2.2.2.1 {
+ set cnt 0
+ execsql { SELECT * FROM terms WHERE rec('cnt', term) AND term>'brain' }
+ set cnt
+} {18}
+do_test 2.2.2.2 {
+ set cnt 0
+ execsql { SELECT * FROM terms WHERE rec('cnt', term) AND +term>'brain' }
+ set cnt
+} {38}
+do_execsql_test 2.2.2.3 {
+ SELECT term, documents, occurrences FROM terms_v WHERE term>'brain'
+} {
+ brainchild 1 1 brained 1 1 braining 1 1 brains 1 1
+ brainstem 1 1 brainstems 1 1 brainstorm 1 1 brainstorms 1 1
+}
+do_execsql_test 2.2.2.4 {
+ SELECT term, documents, occurrences FROM terms_v WHERE +term>'brain'
+} {
+ brainchild 1 1 brained 1 1 braining 1 1 brains 1 1
+ brainstem 1 1 brainstems 1 1 brainstorm 1 1 brainstorms 1 1
+}
+do_execsql_test 2.2.2.5 {
+ SELECT term, documents, occurrences FROM terms_v WHERE term>='brain'
+} {
+ brain 1 1
+ brainchild 1 1 brained 1 1 braining 1 1 brains 1 1
+ brainstem 1 1 brainstems 1 1 brainstorm 1 1 brainstorms 1 1
+}
+do_execsql_test 2.2.2.6 {
+ SELECT term, documents, occurrences FROM terms_v WHERE +term>='brain'
+} {
+ brain 1 1
+ brainchild 1 1 brained 1 1 braining 1 1 brains 1 1
+ brainstem 1 1 brainstems 1 1 brainstorm 1 1 brainstorms 1 1
+}
+
+do_execsql_test 2.2.2.7 {
+ SELECT term, documents, occurrences FROM terms_v WHERE term>='abc'
+} {
+ braes 1 1 brag 1 1 bragged 1 1 bragger 1 1
+ bragging 1 1 brags 1 1 braid 1 1 braided 1 1
+ braiding 1 1 braids 1 1 brain 1 1 brainchild 1 1
+ brained 1 1 braining 1 1 brains 1 1 brainstem 1 1
+ brainstems 1 1 brainstorm 1 1 brainstorms 1 1
+}
+do_execsql_test 2.2.2.8 {
+ SELECT term, documents, occurrences FROM terms_v WHERE +term>='abc'
+} {
+ braes 1 1 brag 1 1 bragged 1 1 bragger 1 1
+ bragging 1 1 brags 1 1 braid 1 1 braided 1 1
+ braiding 1 1 braids 1 1 brain 1 1 brainchild 1 1
+ brained 1 1 braining 1 1 brains 1 1 brainstem 1 1
+ brainstems 1 1 brainstorm 1 1 brainstorms 1 1
+}
+
+do_execsql_test 2.2.2.9 {
+ SELECT term, documents, occurrences FROM terms_v WHERE term>='brainstorms'
+} {brainstorms 1 1}
+do_execsql_test 2.2.2.10 {
+ SELECT term, documents, occurrences FROM terms_v WHERE term>='brainstorms'
+} {brainstorms 1 1}
+do_execsql_test 2.2.2.11 { SELECT * FROM terms_v WHERE term>'brainstorms' } {}
+do_execsql_test 2.2.2.12 { SELECT * FROM terms_v WHERE term>'brainstorms' } {}
+
+do_execsql_test 2.2.2.13 { SELECT * FROM terms_v WHERE term>'cba' } {}
+do_execsql_test 2.2.2.14 { SELECT * FROM terms_v WHERE term>'cba' } {}
+
+do_test 2.2.3.1 {
+ set cnt 0
+ execsql { SELECT * FROM terms WHERE rec('cnt', term) AND term<'brain' }
+ set cnt
+} {22}
+do_test 2.2.3.2 {
+ set cnt 0
+ execsql { SELECT * FROM terms WHERE rec('cnt', term) AND +term<'brain' }
+ set cnt
+} {38}
+do_execsql_test 2.2.3.3 {
+ SELECT term, documents, occurrences FROM terms_v WHERE term<'brain'
+} {
+ braes 1 1 brag 1 1 bragged 1 1 bragger 1 1 bragging 1 1
+ brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1
+}
+do_execsql_test 2.2.3.4 {
+ SELECT term, documents, occurrences FROM terms_v WHERE +term<'brain'
+} {
+ braes 1 1 brag 1 1 bragged 1 1 bragger 1 1 bragging 1 1
+ brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1
+}
+do_execsql_test 2.2.3.5 {
+ SELECT term, documents, occurrences FROM terms_v WHERE term<='brain'
+} {
+ braes 1 1 brag 1 1 bragged 1 1 bragger 1 1 bragging 1 1
+ brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1
+ brain 1 1
+}
+do_execsql_test 2.2.3.6 {
+ SELECT term, documents, occurrences FROM terms_v WHERE +term<='brain'
+} {
+ braes 1 1 brag 1 1 bragged 1 1 bragger 1 1 bragging 1 1
+ brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1
+ brain 1 1
+}
+
+do_test 2.2.4.1 {
+ set cnt 0
+ execsql {
+ SELECT term, documents, occurrences FROM terms
+ WHERE rec('cnt', term) AND term BETWEEN 'brags' AND 'brain'
+ }
+ set cnt
+} {12}
+do_test 2.2.4.2 {
+ set cnt 0
+ execsql {
+ SELECT term, documents, occurrences FROM terms
+ WHERE rec('cnt', term) AND +term BETWEEN 'brags' AND 'brain'
+ }
+ set cnt
+} {38}
+do_execsql_test 2.2.4.3 {
+ SELECT term, documents, occurrences FROM terms_v
+ WHERE rec('cnt', term) AND term BETWEEN 'brags' AND 'brain'
+} {
+ brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1 brain 1 1
+}
+do_execsql_test 2.2.4.4 {
+ SELECT term, documents, occurrences FROM terms_v
+ WHERE rec('cnt', term) AND +term BETWEEN 'brags' AND 'brain'
+} {
+ brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1 brain 1 1
+}
+do_execsql_test 2.2.4.5 {
+ SELECT term, documents, occurrences FROM terms_v
+ WHERE rec('cnt', term) AND term > 'brags' AND term < 'brain'
+} {
+ braid 1 1 braided 1 1 braiding 1 1 braids 1 1
+}
+do_execsql_test 2.2.4.6 {
+ SELECT term, documents, occurrences FROM terms_v
+ WHERE rec('cnt', term) AND +term > 'brags' AND +term < 'brain'
+} {
+ braid 1 1 braided 1 1 braiding 1 1 braids 1 1
+}
+
+# Check that "ORDER BY term ASC" and equivalents are sorted by the
+# virtual table implementation. Any other ORDER BY clause requires
+# SQLite to sort results using a temporary b-tree.
+#
+foreach {tn sort orderby} {
+ 1 0 "ORDER BY term ASC"
+ 2 0 "ORDER BY term"
+ 3 1 "ORDER BY term DESC"
+ 4 1 "ORDER BY documents ASC"
+ 5 1 "ORDER BY documents"
+ 6 1 "ORDER BY documents DESC"
+ 7 1 "ORDER BY occurrences ASC"
+ 8 1 "ORDER BY occurrences"
+ 9 1 "ORDER BY occurrences DESC"
+} {
+
+ set res [list 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)}]
+ if {$sort} { lappend res 0 0 0 {USE TEMP B-TREE FOR ORDER BY} }
+
+ set sql "SELECT * FROM terms $orderby"
+ do_execsql_test 2.3.1.$tn "EXPLAIN QUERY PLAN $sql" $res
+}
+
+#-------------------------------------------------------------------------
+# The next set of tests, fts3aux1-3.*, test error conditions in the
+# fts4aux module. Except, fault injection testing (OOM, IO error etc.) is
+# done in fts3fault2.test
+#
+
+do_execsql_test 3.1.1 {
+ CREATE VIRTUAL TABLE t2 USING fts4;
+}
+
+do_catchsql_test 3.1.2 {
+ CREATE VIRTUAL TABLE terms2 USING fts4aux;
+} {1 {wrong number of arguments to fts4aux constructor}}
+do_catchsql_test 3.1.3 {
+ CREATE VIRTUAL TABLE terms2 USING fts4aux(t2, t2);
+} {1 {wrong number of arguments to fts4aux constructor}}
+
+do_execsql_test 3.2.1 {
+ CREATE VIRTUAL TABLE terms3 USING fts4aux(does_not_exist)
+}
+do_catchsql_test 3.2.2 {
+ SELECT * FROM terms3
+} {1 {SQL logic error or missing database}}
+do_catchsql_test 3.2.3 {
+ SELECT * FROM terms3 WHERE term = 'abc'
+} {1 {SQL logic error or missing database}}
+
+do_catchsql_test 3.3.1 {
+ INSERT INTO terms VALUES(1,2,3);
+} {1 {table terms may not be modified}}
+do_catchsql_test 3.3.2 {
+ DELETE FROM terms
+} {1 {table terms may not be modified}}
+do_catchsql_test 3.3.3 {
+ UPDATE terms set documents = documents+1;
+} {1 {table terms may not be modified}}
+
+
+#-------------------------------------------------------------------------
+# The following tests - fts4aux-4.* - test that joins work with fts4aux
+# tables. And that fts4aux provides reasonably sane cost information via
+# xBestIndex to the query planner.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test 4.1 {
+ CREATE VIRTUAL TABLE x1 USING fts4(x);
+ CREATE VIRTUAL TABLE terms USING fts4aux(x1);
+ CREATE TABLE x2(y);
+ CREATE TABLE x3(y);
+ CREATE INDEX i1 ON x3(y);
+
+ INSERT INTO x1 VALUES('a b c d e');
+ INSERT INTO x1 VALUES('f g h i j');
+ INSERT INTO x1 VALUES('k k l l a');
+
+ INSERT INTO x2 SELECT term FROM terms WHERE col = '*';
+ INSERT INTO x3 SELECT term FROM terms WHERE col = '*';
+}
+
+proc do_plansql_test {tn sql r} {
+ uplevel do_execsql_test $tn [list "EXPLAIN QUERY PLAN $sql ; $sql"] [list $r]
+}
+
+do_plansql_test 4.2 {
+ SELECT y FROM x2, terms WHERE y = term AND col = '*'
+} {
+ 0 0 0 {SCAN TABLE x2 (~1000000 rows)}
+ 0 1 1 {SCAN TABLE terms VIRTUAL TABLE INDEX 1: (~0 rows)}
+ a b c d e f g h i j k l
+}
+
+do_plansql_test 4.3 {
+ SELECT y FROM terms, x2 WHERE y = term AND col = '*'
+} {
+ 0 0 1 {SCAN TABLE x2 (~1000000 rows)}
+ 0 1 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 1: (~0 rows)}
+ a b c d e f g h i j k l
+}
+
+do_plansql_test 4.4 {
+ SELECT y FROM x3, terms WHERE y = term AND col = '*'
+} {
+ 0 0 1 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)}
+ 0 1 0 {SEARCH TABLE x3 USING COVERING INDEX i1 (y=?) (~10 rows)}
+ a b c d e f g h i j k l
+}
+
+do_plansql_test 4.5 {
+ SELECT y FROM terms, x3 WHERE y = term AND occurrences>1 AND col = '*'
+} {
+ 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)}
+ 0 1 1 {SEARCH TABLE x3 USING COVERING INDEX i1 (y=?) (~10 rows)}
+ a k l
+}
+
+#-------------------------------------------------------------------------
+# The following tests check that fts4aux can handle an fts table with an
+# odd name (one that requires quoting for use in SQL statements). And that
+# the argument to the fts4aux constructor is properly dequoted before use.
+#
+#
+do_execsql_test 5.1 {
+ CREATE VIRTUAL TABLE "abc '!' def" USING fts4(x, y);
+ INSERT INTO "abc '!' def" VALUES('XX', 'YY');
+
+ CREATE VIRTUAL TABLE terms3 USING fts4aux("abc '!' def");
+ SELECT * FROM terms3;
+} {xx * 1 1 xx 0 1 1 yy * 1 1 yy 1 1 1}
+
+do_execsql_test 5.2 {
+ CREATE VIRTUAL TABLE "%%^^%%" USING fts4aux('abc ''!'' def');
+ SELECT * FROM "%%^^%%";
+} {xx * 1 1 xx 0 1 1 yy * 1 1 yy 1 1 1}
+
+
+finish_test
diff --git a/test/fts3b.test b/test/fts3b.test
new file mode 100644
index 0000000..9bde3a2
--- /dev/null
+++ b/test/fts3b.test
@@ -0,0 +1,230 @@
+# 2007 August 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. This
+# script tests for the fts2 rowid-versus-vacuum problem (ticket #2566).
+#
+# $Id: fts3b.test,v 1.3 2007/09/13 18:14:49 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (c) VALUES('this is a test');
+ INSERT INTO t1 (c) VALUES('that was a test');
+ INSERT INTO t1 (c) VALUES('this is fun');
+ DELETE FROM t1 WHERE c = 'that was a test';
+}
+
+# Baseline test.
+do_test fts3b-1.1 {
+ execsql {
+ SELECT rowid FROM t1 WHERE c MATCH 'this';
+ }
+} {1 3}
+
+db eval {VACUUM}
+
+# The VACUUM renumbered the t1_content table in fts2, which breaks
+# this.
+do_test fts3b-1.2 {
+ execsql {
+ SELECT rowid FROM t1 WHERE c MATCH 'this';
+ }
+} {1 3}
+
+# The t2 table is unfortunately pretty contrived. We need documents
+# that are bigger than ROOT_MAX (1024) to force segments out of the
+# segdir and into %_segments. We also need to force segment merging
+# to generate a hole in the %_segments table, which needs more than 16
+# docs. Beyond that, to test correct operation of BLOCK_SELECT_STMT,
+# we need to merge a mult-level tree, which is where the 10,000 comes
+# from. Which is slow, thus the set of transactions, with the 500
+# being a number such that 10,000/500 > 16.
+set text {
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
+ iaculis mollis ipsum. Praesent rhoncus placerat justo. Duis non quam
+ sed turpis posuere placerat. Curabitur et lorem in lorem porttitor
+ aliquet. Pellentesque bibendum tincidunt diam. Vestibulum blandit
+ ante nec elit. In sapien diam, facilisis eget, dictum sed, viverra
+ at, felis. Vestibulum magna. Sed magna dolor, vestibulum rhoncus,
+ ornare vel, vulputate sit amet, felis. Integer malesuada, tellus at
+ luctus gravida, diam nunc porta nibh, nec imperdiet massa metus eu
+ lectus. Aliquam nisi. Nunc fringilla nulla at lectus. Suspendisse
+ potenti. Cum sociis natoque penatibus et magnis dis parturient
+ montes, nascetur ridiculus mus. Pellentesque odio nulla, feugiat eu,
+ suscipit nec, consequat quis, risus.
+}
+append text $text
+
+db eval {CREATE VIRTUAL TABLE t2 USING fts3(c)}
+set res {}
+db eval {BEGIN}
+for {set ii 0} {$ii<10000} {incr ii} {
+ db eval {INSERT INTO t2 (c) VALUES ($text)}
+ lappend res [expr {$ii+1}]
+ if {($ii%500)==0} {
+ db eval {
+ COMMIT;
+ BEGIN;
+ }
+ }
+}
+db eval {COMMIT}
+
+do_test fts3b-2.1 {
+ execsql {
+ SELECT rowid FROM t2 WHERE c MATCH 'lorem';
+ }
+} $res
+
+db eval {VACUUM}
+
+# The VACUUM renumbered the t2_segment table in fts2, which would
+# break the following.
+do_test fts3b-2.2 {
+ execsql {
+ SELECT rowid FROM t2 WHERE c MATCH 'lorem';
+ }
+} $res
+
+# Since fts3 is already an API break, I've marked the table-named
+# column HIDDEN.
+
+db eval {
+ CREATE VIRTUAL TABLE t3 USING fts3(c);
+ INSERT INTO t3 (c) VALUES('this is a test');
+ INSERT INTO t3 (c) VALUES('that was a test');
+ INSERT INTO t3 (c) VALUES('this is fun');
+ DELETE FROM t3 WHERE c = 'that was a test';
+}
+
+# Test that the table-named column still works.
+do_test fts3b-3.1 {
+ execsql {
+ SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'test';
+ }
+} {{this is a <b>test</b>}}
+
+# Test that the column doesn't appear when selecting all columns.
+do_test fts3b-3.2 {
+ execsql {
+ SELECT * FROM t3 WHERE rowid = 1;
+ }
+} {{this is a test}}
+
+# Test that the column doesn't conflict with inserts that don't name
+# columns.
+do_test fts3b-3.3 {
+ execsql {
+ INSERT INTO t3 VALUES ('another test');
+ }
+} {}
+
+# fts3 adds a new implicit column, docid, which acts as an alias for
+# rowid.
+
+db eval {
+ CREATE VIRTUAL TABLE t4 USING fts3(c);
+ INSERT INTO t4 (c) VALUES('this is a test');
+ INSERT INTO t4 (c) VALUES('that was a test');
+ INSERT INTO t4 (c) VALUES('this is fun');
+ DELETE FROM t4 WHERE c = 'that was a test';
+}
+
+# Test that docid is present and identical to rowid.
+do_test fts3b-4.1 {
+ execsql {
+ SELECT rowid FROM t4 WHERE rowid <> docid;
+ }
+} {}
+
+# Test that docid is hidden.
+do_test fts3b-4.2 {
+ execsql {
+ SELECT * FROM t4 WHERE rowid = 1;
+ }
+} {{this is a test}}
+
+# Test that docid can be selected.
+do_test fts3b-4.3 {
+ execsql {
+ SELECT docid, * FROM t4 WHERE rowid = 1;
+ }
+} {1 {this is a test}}
+
+# Test that docid can be used in WHERE.
+do_test fts3b-4.4 {
+ execsql {
+ SELECT docid, * FROM t4 WHERE docid = 1;
+ }
+} {1 {this is a test}}
+
+# Test that the column doesn't conflict with inserts that don't name
+# columns. [Yes, this is the same as fts3b-3.3, here just in case the
+# goals of that test change.]
+do_test fts3b-4.5 {
+ execsql {
+ INSERT INTO t4 VALUES ('another test');
+ }
+} {}
+
+# Test that the docid can be forced on insert.
+do_test fts3b-4.6 {
+ execsql {
+ INSERT INTO t4 (docid, c) VALUES (10, 'yet another test');
+ SELECT * FROM t4 WHERE docid = 10;
+ }
+} {{yet another test}}
+
+# Test that rowid can also be forced.
+do_test fts3b-4.7 {
+ execsql {
+ INSERT INTO t4 (docid, c) VALUES (12, 'still testing');
+ SELECT * FROM t4 WHERE docid = 12;
+ }
+} {{still testing}}
+
+# If an insert tries to set both docid and rowid, require an error.
+do_test fts3b-4.8 {
+ catchsql {
+ INSERT INTO t4 (rowid, docid, c) VALUES (14, 15, 'bad test');
+ SELECT * FROM t4 WHERE docid = 14;
+ }
+} {1 {SQL logic error or missing database}}
+
+do_test fts3b-4.9 {
+ execsql { SELECT docid FROM t4 WHERE t4 MATCH 'testing' }
+} {12}
+do_test fts3b-4.10 {
+ execsql {
+ UPDATE t4 SET docid = 14 WHERE docid = 12;
+ SELECT docid FROM t4 WHERE t4 MATCH 'testing';
+ }
+} {14}
+do_test fts3b-4.11 {
+ execsql { SELECT * FROM t4 WHERE rowid = 14; }
+} {{still testing}}
+do_test fts3b-4.12 {
+ execsql { SELECT * FROM t4 WHERE rowid = 12; }
+} {}
+do_test fts3b-4.13 {
+ execsql { SELECT docid FROM t4 WHERE t4 MATCH 'still'; }
+} {14}
+
+finish_test
diff --git a/test/fts3c.test b/test/fts3c.test
new file mode 100644
index 0000000..6b63264
--- /dev/null
+++ b/test/fts3c.test
@@ -0,0 +1,255 @@
+# 2008 June 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file exercises some new testing functions in the FTS3 module,
+# and then uses them to do some basic tests that FTS3 is internally
+# working as expected.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+#*************************************************************************
+# Utility function to check for the expected terms in the segment
+# level/index. _all version does same but for entire index.
+proc check_terms {test level index terms} {
+ set where "level = $level AND idx = $index"
+ do_test $test.terms [list fts3_terms t1 $where] $terms
+}
+proc check_terms_all {test terms} {
+ do_test $test.terms [list fts3_terms t1 1] $terms
+}
+
+# Utility function to check for the expected doclist for the term in
+# segment level/index. _all version does same for entire index.
+proc check_doclist {test level index term doclist} {
+ set where "level = $level AND idx = $index"
+ do_test $test [list fts3_doclist t1 $term $where] $doclist
+}
+proc check_doclist_all {test term doclist} {
+ do_test $test [list fts3_doclist t1 $term 1] $doclist
+}
+
+#*************************************************************************
+# Test the segments resulting from straight-forward inserts.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');
+}
+
+# Check for expected segments and expected matches.
+do_test fts3c-1.0.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0 0 1 0 2}
+do_test fts3c-1.0.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;
+ }
+} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \
+ {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \
+ {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]
+
+# Check the specifics of the segments constructed.
+# Logical view of entire index.
+check_terms_all fts3c-1.0.1 {a is test that this was}
+check_doclist_all fts3c-1.0.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}
+check_doclist_all fts3c-1.0.1.2 is {[1 0[1]] [3 0[1]]}
+check_doclist_all fts3c-1.0.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]}
+check_doclist_all fts3c-1.0.1.4 that {[2 0[0]]}
+check_doclist_all fts3c-1.0.1.5 this {[1 0[0]] [3 0[0]]}
+check_doclist_all fts3c-1.0.1.6 was {[2 0[1]]}
+
+# Segment 0,0
+check_terms fts3c-1.0.2 0 0 {a is test this}
+check_doclist fts3c-1.0.2.1 0 0 a {[1 0[2]]}
+check_doclist fts3c-1.0.2.2 0 0 is {[1 0[1]]}
+check_doclist fts3c-1.0.2.3 0 0 test {[1 0[3]]}
+check_doclist fts3c-1.0.2.4 0 0 this {[1 0[0]]}
+
+# Segment 0,1
+check_terms fts3c-1.0.3 0 1 {a test that was}
+check_doclist fts3c-1.0.3.1 0 1 a {[2 0[2]]}
+check_doclist fts3c-1.0.3.2 0 1 test {[2 0[3]]}
+check_doclist fts3c-1.0.3.3 0 1 that {[2 0[0]]}
+check_doclist fts3c-1.0.3.4 0 1 was {[2 0[1]]}
+
+# Segment 0,2
+check_terms fts3c-1.0.4 0 2 {a is test this}
+check_doclist fts3c-1.0.4.1 0 2 a {[3 0[2]]}
+check_doclist fts3c-1.0.4.2 0 2 is {[3 0[1]]}
+check_doclist fts3c-1.0.4.3 0 2 test {[3 0[3]]}
+check_doclist fts3c-1.0.4.4 0 2 this {[3 0[0]]}
+
+#*************************************************************************
+# Test the segments resulting from inserts followed by a delete.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE docid = 1;
+}
+
+do_test fts3c-1.1.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0 0 1 0 2 0 3}
+do_test fts3c-1.1.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;
+ }
+} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}}
+
+check_terms_all fts3c-1.1.1 {a is test that this was}
+check_doclist_all fts3c-1.1.1.1 a {[2 0[2]] [3 0[2]]}
+check_doclist_all fts3c-1.1.1.2 is {[3 0[1]]}
+check_doclist_all fts3c-1.1.1.3 test {[2 0[3]] [3 0[3]]}
+check_doclist_all fts3c-1.1.1.4 that {[2 0[0]]}
+check_doclist_all fts3c-1.1.1.5 this {[3 0[0]]}
+check_doclist_all fts3c-1.1.1.6 was {[2 0[1]]}
+
+check_terms fts3c-1.1.2 0 0 {a is test this}
+check_doclist fts3c-1.1.2.1 0 0 a {[1 0[2]]}
+check_doclist fts3c-1.1.2.2 0 0 is {[1 0[1]]}
+check_doclist fts3c-1.1.2.3 0 0 test {[1 0[3]]}
+check_doclist fts3c-1.1.2.4 0 0 this {[1 0[0]]}
+
+check_terms fts3c-1.1.3 0 1 {a test that was}
+check_doclist fts3c-1.1.3.1 0 1 a {[2 0[2]]}
+check_doclist fts3c-1.1.3.2 0 1 test {[2 0[3]]}
+check_doclist fts3c-1.1.3.3 0 1 that {[2 0[0]]}
+check_doclist fts3c-1.1.3.4 0 1 was {[2 0[1]]}
+
+check_terms fts3c-1.1.4 0 2 {a is test this}
+check_doclist fts3c-1.1.4.1 0 2 a {[3 0[2]]}
+check_doclist fts3c-1.1.4.2 0 2 is {[3 0[1]]}
+check_doclist fts3c-1.1.4.3 0 2 test {[3 0[3]]}
+check_doclist fts3c-1.1.4.4 0 2 this {[3 0[0]]}
+
+check_terms fts3c-1.1.5 0 3 {a is test this}
+check_doclist fts3c-1.1.5.1 0 3 a {[1]}
+check_doclist fts3c-1.1.5.2 0 3 is {[1]}
+check_doclist fts3c-1.1.5.3 0 3 test {[1]}
+check_doclist fts3c-1.1.5.4 0 3 this {[1]}
+
+#*************************************************************************
+# Test results when all references to certain tokens are deleted.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE docid IN (1,3);
+}
+
+# Still 4 segments because 0,3 will contain deletes for docid 1 and 3.
+do_test fts3c-1.2.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0 0 1 0 2 0 3}
+do_test fts3c-1.2.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;
+ }
+} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
+
+check_terms_all fts3c-1.2.1 {a is test that this was}
+check_doclist_all fts3c-1.2.1.1 a {[2 0[2]]}
+check_doclist_all fts3c-1.2.1.2 is {}
+check_doclist_all fts3c-1.2.1.3 test {[2 0[3]]}
+check_doclist_all fts3c-1.2.1.4 that {[2 0[0]]}
+check_doclist_all fts3c-1.2.1.5 this {}
+check_doclist_all fts3c-1.2.1.6 was {[2 0[1]]}
+
+check_terms fts3c-1.2.2 0 0 {a is test this}
+check_doclist fts3c-1.2.2.1 0 0 a {[1 0[2]]}
+check_doclist fts3c-1.2.2.2 0 0 is {[1 0[1]]}
+check_doclist fts3c-1.2.2.3 0 0 test {[1 0[3]]}
+check_doclist fts3c-1.2.2.4 0 0 this {[1 0[0]]}
+
+check_terms fts3c-1.2.3 0 1 {a test that was}
+check_doclist fts3c-1.2.3.1 0 1 a {[2 0[2]]}
+check_doclist fts3c-1.2.3.2 0 1 test {[2 0[3]]}
+check_doclist fts3c-1.2.3.3 0 1 that {[2 0[0]]}
+check_doclist fts3c-1.2.3.4 0 1 was {[2 0[1]]}
+
+check_terms fts3c-1.2.4 0 2 {a is test this}
+check_doclist fts3c-1.2.4.1 0 2 a {[3 0[2]]}
+check_doclist fts3c-1.2.4.2 0 2 is {[3 0[1]]}
+check_doclist fts3c-1.2.4.3 0 2 test {[3 0[3]]}
+check_doclist fts3c-1.2.4.4 0 2 this {[3 0[0]]}
+
+check_terms fts3c-1.2.5 0 3 {a is test this}
+check_doclist fts3c-1.2.5.1 0 3 a {[1] [3]}
+check_doclist fts3c-1.2.5.2 0 3 is {[1] [3]}
+check_doclist fts3c-1.2.5.3 0 3 test {[1] [3]}
+check_doclist fts3c-1.2.5.4 0 3 this {[1] [3]}
+
+#*************************************************************************
+# Test results when everything is optimized manually.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE docid IN (1,3);
+ DROP TABLE IF EXISTS t1old;
+ ALTER TABLE t1 RENAME TO t1old;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (docid, c) SELECT docid, c FROM t1old;
+ DROP TABLE t1old;
+}
+
+# Should be a single optimal segment with the same logical results.
+do_test fts3c-1.3.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0}
+do_test fts3c-1.3.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;
+ }
+} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
+
+check_terms_all fts3c-1.3.1 {a test that was}
+check_doclist_all fts3c-1.3.1.1 a {[2 0[2]]}
+check_doclist_all fts3c-1.3.1.2 test {[2 0[3]]}
+check_doclist_all fts3c-1.3.1.3 that {[2 0[0]]}
+check_doclist_all fts3c-1.3.1.4 was {[2 0[1]]}
+
+check_terms fts3c-1.3.2 0 0 {a test that was}
+check_doclist fts3c-1.3.2.1 0 0 a {[2 0[2]]}
+check_doclist fts3c-1.3.2.2 0 0 test {[2 0[3]]}
+check_doclist fts3c-1.3.2.3 0 0 that {[2 0[0]]}
+check_doclist fts3c-1.3.2.4 0 0 was {[2 0[1]]}
+
+finish_test
diff --git a/test/fts3comp1.test b/test/fts3comp1.test
new file mode 100644
index 0000000..9f13aaa
--- /dev/null
+++ b/test/fts3comp1.test
@@ -0,0 +1,115 @@
+# 2011 January 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !fts3 { finish_test ; return }
+set ::testprefix fts3comp1
+
+# Create a pretend compression system.
+#
+# Each time the [zip] function is called, an entry is added to the ::strings
+# array mapping from an integer key to the string argument to zip. The key
+# is returned. Later on, when the key is passed to [unzip], the original
+# string is retrieved from the ::strings array and returned.
+#
+set next_x 0
+proc zip {x} {
+ incr ::next_x
+ set ::strings($::next_x) $x
+ return $::next_x
+}
+proc unzip {x} {
+ return $::strings($x)
+}
+
+foreach {tn zip unzip} {
+ 1 zip unzip
+ 2 {z.i.p!!} {un "zip"}
+} {
+
+ set next_x 0
+ catch {db close}
+ forcedelete test.db
+ sqlite3 db test.db
+ db func $zip zip
+ db func $unzip unzip
+
+ # Create a table that uses zip/unzip. Check that content inserted into
+ # the table can be read back (using a full-scan query). Check that the
+ # underlying %_content table contains the compressed (integer) values.
+ #
+ do_execsql_test 1.$tn.0 "
+ CREATE VIRTUAL TABLE t1 USING fts4(
+ a, b,
+ compress='$zip', uncompress='$unzip'
+ );
+ "
+ do_execsql_test 1.$tn.1 {
+ INSERT INTO t1 VALUES('one two three', 'two four six');
+ SELECT a, b FROM t1;
+ } {{one two three} {two four six}}
+ do_execsql_test 1.$tn.2 {
+ SELECT c0a, c1b FROM t1_content;
+ } {1 2}
+
+ # Insert another row and check that it can be read back. Also that the
+ # %_content table still contains all compressed content. This time, try
+ # full-text index and by-docid queries too.
+ #
+ do_execsql_test 1.$tn.3 {
+ INSERT INTO t1 VALUES('three six nine', 'four eight twelve');
+ SELECT a, b FROM t1;
+ } {{one two three} {two four six} {three six nine} {four eight twelve}}
+ do_execsql_test 1.$tn.4 {
+ SELECT c0a, c1b FROM t1_content;
+ } {1 2 3 4}
+
+ do_execsql_test 1.$tn.5 {
+ SELECT a, b FROM t1 WHERE docid = 2
+ } {{three six nine} {four eight twelve}}
+ do_execsql_test 1.$tn.6 {
+ SELECT a, b FROM t1 WHERE t1 MATCH 'two'
+ } {{one two three} {two four six}}
+
+ # Delete a row and check that the full-text index is correctly updated.
+ # Inspect the full-text index using an fts4aux table.
+ #
+ do_execsql_test 1.$tn.7 {
+ CREATE VIRTUAL TABLE terms USING fts4aux(t1);
+ SELECT term, documents, occurrences FROM terms WHERE col = '*';
+ } {
+ eight 1 1 four 2 2 nine 1 1 one 1 1
+ six 2 2 three 2 2 twelve 1 1 two 1 2
+ }
+ do_execsql_test 1.$tn.8 {
+ DELETE FROM t1 WHERE docid = 1;
+ SELECT term, documents, occurrences FROM terms WHERE col = '*';
+ } {
+ eight 1 1 four 1 1 nine 1 1
+ six 1 1 three 1 1 twelve 1 1
+ }
+ do_execsql_test 1.$tn.9 { SELECT c0a, c1b FROM t1_content } {3 4}
+}
+
+# Test that is an error to specify just one of compress and uncompress.
+#
+do_catchsql_test 2.1 {
+ CREATE VIRTUAL TABLE t2 USING fts4(x, compress=zip)
+} {1 {missing uncompress parameter in fts4 constructor}}
+do_catchsql_test 2.2 {
+ CREATE VIRTUAL TABLE t2 USING fts4(x, uncompress=unzip)
+} {1 {missing compress parameter in fts4 constructor}}
+
+finish_test
diff --git a/test/fts3conf.test b/test/fts3conf.test
new file mode 100644
index 0000000..ce41027
--- /dev/null
+++ b/test/fts3conf.test
@@ -0,0 +1,139 @@
+# 2011 April 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module.
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts3conf
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+
+proc fts3_integrity {tn db tbl} {
+
+ if {[sqlite3_get_autocommit $db]==0} {
+ error "fts3_integrity does not work with an open transaction"
+ }
+
+ set sql [db one {SELECT sql FROM sqlite_master WHERE name = $tbl}]
+ regexp -nocase {[^(]* using (.*)} $sql -> tail
+ set cols [list]
+ $db eval "PRAGMA table_info($tbl)" {
+ lappend cols $name
+ }
+ set cols [join [concat docid $cols] ,]
+
+ $db eval [subst {
+ CREATE VIRTUAL TABLE fts3check USING fts4term($tbl);
+ CREATE VIRTUAL TABLE temp.fts3check2 USING $tail;
+ INSERT INTO temp.fts3check2($cols) SELECT docid, * FROM $tbl;
+ CREATE VIRTUAL TABLE temp.fts3check3 USING fts4term(fts3check2);
+ }]
+
+ set m1 [$db one {SELECT md5sum(term, docid, col, pos) FROM fts3check}]
+ set m2 [$db one {SELECT md5sum(term, docid, col, pos) FROM fts3check3}]
+
+ $db eval {
+ DROP TABLE fts3check;
+ DROP TABLE temp.fts3check2;
+ DROP TABLE temp.fts3check3;
+ }
+
+ uplevel [list do_test $tn [list set {} $m1] $m2]
+}
+
+do_execsql_test 1.0.1 {
+ CREATE VIRTUAL TABLE t1 USING fts3(x);
+ INSERT INTO t1(rowid, x) VALUES(1, 'a b c d');
+ INSERT INTO t1(rowid, x) VALUES(2, 'e f g h');
+
+ CREATE TABLE source(a, b);
+ INSERT INTO source VALUES(4, 'z');
+ INSERT INTO source VALUES(2, 'y');
+}
+db_save_and_close
+
+set T1 "INTO t1(rowid, x) VALUES(1, 'x')"
+set T2 "INTO t1(rowid, x) SELECT * FROM source"
+
+set T3 "t1 SET docid = 2 WHERE docid = 1"
+set T4 "t1 SET docid = CASE WHEN docid = 1 THEN 4 ELSE 3 END WHERE docid <=2"
+
+foreach {tn sql uses constraint data} [subst {
+ 1 "INSERT OR ROLLBACK $T1" 0 1 {{a b c d} {e f g h}}
+ 2 "INSERT OR ABORT $T1" 0 1 {{a b c d} {e f g h} {i j k l}}
+ 3 "INSERT OR FAIL $T1" 0 1 {{a b c d} {e f g h} {i j k l}}
+ 4 "INSERT OR IGNORE $T1" 0 0 {{a b c d} {e f g h} {i j k l}}
+ 5 "INSERT OR REPLACE $T1" 0 0 {x {e f g h} {i j k l}}
+
+ 6 "INSERT OR ROLLBACK $T2" 1 1 {{a b c d} {e f g h}}
+ 7 "INSERT OR ABORT $T2" 1 1 {{a b c d} {e f g h} {i j k l}}
+ 8 "INSERT OR FAIL $T2" 1 1 {{a b c d} {e f g h} {i j k l} z}
+ 9 "INSERT OR IGNORE $T2" 1 0 {{a b c d} {e f g h} {i j k l} z}
+ 10 "INSERT OR REPLACE $T2" 1 0 {{a b c d} y {i j k l} z}
+
+ 11 "UPDATE OR ROLLBACK $T3" 1 1 {{a b c d} {e f g h}}
+ 12 "UPDATE OR ABORT $T3" 1 1 {{a b c d} {e f g h} {i j k l}}
+ 13 "UPDATE OR FAIL $T3" 1 1 {{a b c d} {e f g h} {i j k l}}
+ 14 "UPDATE OR IGNORE $T3" 1 0 {{a b c d} {e f g h} {i j k l}}
+ 15 "UPDATE OR REPLACE $T3" 1 0 {{a b c d} {i j k l}}
+
+ 16 "UPDATE OR ROLLBACK $T4" 1 1 {{a b c d} {e f g h}}
+ 17 "UPDATE OR ABORT $T4" 1 1 {{a b c d} {e f g h} {i j k l}}
+ 18 "UPDATE OR FAIL $T4" 1 1 {{e f g h} {i j k l} {a b c d}}
+ 19 "UPDATE OR IGNORE $T4" 1 0 {{e f g h} {i j k l} {a b c d}}
+ 20 "UPDATE OR REPLACE $T4" 1 0 {{e f g h} {a b c d}}
+}] {
+ db_restore_and_reopen
+ execsql {
+ BEGIN;
+ INSERT INTO t1(rowid, x) VALUES(3, 'i j k l');
+ }
+ set R(0) {0 {}}
+ set R(1) {1 {constraint failed}}
+ do_catchsql_test 1.$tn.1 $sql $R($constraint)
+ do_catchsql_test 1.$tn.2 { SELECT * FROM t1 } [list 0 $data]
+ catchsql COMMIT
+
+ fts3_integrity 1.$tn.3 db t1
+
+ do_test 1.$tn.4 [list sql_uses_stmt db $sql] $uses
+}
+
+do_execsql_test 2.1.1 {
+ DELETE FROM t1;
+ BEGIN;
+ INSERT INTO t1 VALUES('a b c');
+ SAVEPOINT a;
+ INSERT INTO t1 VALUES('x y z');
+ ROLLBACK TO a;
+ COMMIT;
+}
+fts3_integrity 2.1.2 db t1
+
+do_catchsql_test 2.2.1 {
+ DELETE FROM t1;
+ BEGIN;
+ INSERT INTO t1(docid, x) VALUES(0, 'a b c');
+ INSERT INTO t1(docid, x) VALUES(1, 'a b c');
+ REPLACE INTO t1(docid, x) VALUES('zero', 'd e f');
+} {1 {datatype mismatch}}
+do_execsql_test 2.2.2 { COMMIT }
+do_execsql_test 2.2.3 { SELECT * FROM t1 } {{a b c} {a b c}}
+fts3_integrity 2.2.4 db t1
+
+finish_test
diff --git a/test/fts3corrupt.test b/test/fts3corrupt.test
new file mode 100644
index 0000000..ea4c9a9
--- /dev/null
+++ b/test/fts3corrupt.test
@@ -0,0 +1,169 @@
+# 2010 October 27
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# Test that the FTS3 extension does not crash when it encounters a
+# corrupt data structure on disk.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 { finish_test ; return }
+
+set ::testprefix fts3corrupt
+
+
+# Test that a doclist with a length field that indicates that the doclist
+# extends past the end of the node on which it resides is correctly identified
+# as database corruption.
+#
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING fts3;
+ INSERT INTO t1 VALUES('hello');
+} {}
+do_test fts3corrupt-1.1 {
+ set blob [db one {SELECT root from t1_segdir}]
+ set blob [binary format a7ca* $blob 24 [string range $blob 8 end]]
+ execsql { UPDATE t1_segdir SET root = $blob }
+} {}
+do_test fts3corrupt-1.2 {
+ foreach w {a b c d e f g h i j k l m n o} {
+ execsql { INSERT INTO t1 VALUES($w) }
+ }
+} {}
+do_catchsql_test 1.3 {
+ INSERT INTO t1 VALUES('world');
+} {1 {database disk image is malformed}}
+do_test 1.3.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB
+do_execsql_test 1.4 {
+ DROP TABLE t1;
+}
+
+# This block of tests checks that corruption is correctly detected if the
+# length field of a term on a leaf node indicates that the term extends past
+# the end of the node on which it resides. There are two cases:
+#
+# 1. The first term on the node.
+# 2. The second or subsequent term on the node (prefix compressed term).
+#
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE t1 USING fts3;
+ BEGIN;
+ INSERT INTO t1 VALUES('hello');
+ INSERT INTO t1 VALUES('hello');
+ INSERT INTO t1 VALUES('hello');
+ INSERT INTO t1 VALUES('hello');
+ INSERT INTO t1 VALUES('hello');
+ COMMIT;
+} {}
+do_test fts3corrupt-2.1 {
+ set blob [db one {SELECT root from t1_segdir}]
+ set blob [binary format a*a* "\x00\x7F" [string range $blob 2 end]]
+ execsql { UPDATE t1_segdir SET root = $blob }
+} {}
+do_catchsql_test 2.2 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'hello'
+} {1 {database disk image is malformed}}
+do_test 2.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB
+
+do_execsql_test 3.0 {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts3;
+ BEGIN;
+ INSERT INTO t1 VALUES('hello');
+ INSERT INTO t1 VALUES('world');
+ COMMIT;
+} {}
+do_test fts3corrupt-3.1 {
+ set blob [db one {SELECT quote(root) from t1_segdir}]
+ set blob [binary format a11a*a* $blob "\x7F" [string range $blob 12 end]]
+ execsql { UPDATE t1_segdir SET root = $blob }
+} {}
+do_catchsql_test 3.2 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world'
+} {1 {database disk image is malformed}}
+do_test 3.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB
+
+
+do_execsql_test 4.0 {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts3;
+ INSERT INTO t1(t1) VALUES('nodesize=24');
+}
+do_test fts3corrupt-4.1 {
+ execsql BEGIN
+ foreach s {
+ "amxtvoo adqwroyhz auq aithtir avniqnuynvf axp ahibayfynig agbicpm"
+ "ajdtebs anteaxr aieynenwmd awpl alo akxcrwow aoxftge aoqvgul"
+ "amcfvdr auz apu aebelm ahuxyz aqc asyafdb agulvhvqu"
+ "apepwfyz azkhdvkw aenyelxzbk aslnitbyet aycdsdcpgr aqzzdbc agfi axnypydou"
+ "aaqrzzcm apcxdxo atumltzj aevvivo aodknoft aqoyytoz alobx apldt"
+ } {
+ execsql { INSERT INTO t1 VALUES($s) }
+ }
+ execsql COMMIT
+} {}
+
+do_catchsql_test 4.2 {
+ UPDATE t1_segdir SET root = X'FFFFFFFFFFFFFFFF';
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+} {1 {database disk image is malformed}}
+do_test 4.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB
+
+set blob [binary format cca*cca*cca*cca*cca*cca*cca*cca*cca*cca*a* \
+ 22 120 [string repeat a 120] \
+ 22 120 [string repeat b 120] \
+ 22 120 [string repeat c 120] \
+ 22 120 [string repeat d 120] \
+ 22 120 [string repeat e 120] \
+ 22 120 [string repeat f 120] \
+ 22 120 [string repeat g 120] \
+ 22 120 [string repeat h 120] \
+ 22 120 [string repeat i 120] \
+ 22 120 [string repeat j 120] \
+ "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+]
+
+do_catchsql_test 4.3 {
+ UPDATE t1_segdir SET root = $blob;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'world';
+} {1 {database disk image is malformed}}
+do_test 4.3.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB
+
+# Test a special kind of corruption, where the %_stat table contains
+# an invalid entry. At one point this could lead to a division-by-zero
+# error in fts4.
+#
+do_execsql_test 5.0 {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts4;
+}
+do_test 5.1 {
+ db func nn nn
+ execsql BEGIN
+ execsql { INSERT INTO t1 VALUES('one') }
+ execsql { INSERT INTO t1 VALUES('two') }
+ execsql { INSERT INTO t1 VALUES('three') }
+ execsql { INSERT INTO t1 VALUES('four') }
+ execsql COMMIT
+} {}
+do_catchsql_test 5.2 {
+ UPDATE t1_stat SET value = X'0000';
+ SELECT matchinfo(t1, 'nxa') FROM t1 WHERE t1 MATCH 't*';
+} {1 {database disk image is malformed}}
+do_test 5.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB
+do_catchsql_test 5.3 {
+ UPDATE t1_stat SET value = NULL;
+ SELECT matchinfo(t1, 'nxa') FROM t1 WHERE t1 MATCH 't*';
+} {1 {database disk image is malformed}}
+do_test 5.3.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB
+
+
+finish_test
+
diff --git a/test/fts3corrupt2.test b/test/fts3corrupt2.test
new file mode 100644
index 0000000..78c7677
--- /dev/null
+++ b/test/fts3corrupt2.test
@@ -0,0 +1,110 @@
+# 2010 October 30
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# Test that the FTS3 extension does not crash when it encounters a
+# corrupt data structure on disk.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 { finish_test ; return }
+
+set ::testprefix fts3corrupt2
+
+set data [list]
+lappend data {*}{
+ "amxtvoo adqwroyhz auq aithtir avniqnuynvf axp ahibayfynig agbicpm"
+ "ajdtebs anteaxr aieynenwmd awpl alo akxcrwow aoxftge aoqvgul"
+ "amcfvdr auz apu aebelm ahuxyz aqc asyafdb agulvhvqu"
+ "apepwfyz azkhdvkw aenyelxzbk aslnitbyet aycdsdcpgr aqzzdbc agfi axnypydou"
+ "aaqrzzcm apcxdxo atumltzj aevvivo aodknoft aqoyytoz alobx apldt"
+ "adjllxlhnmj aiuhvuj adwppceuht atvj azrsam ahkjqdhny audlqxr aotgcd"
+ "aira azflsceos awj auzbobfkc awmezplr aeh awec ahndxlmv"
+ "aydwnied alk auoap agihyqeix aymqxzajnl aydwnied aojkarx agbo"
+ "ahajsmcl anvx amdhjm aoptsj agugzjjm apkevm acnj acjg"
+ "amwtkw aogttbykvt aubwrfqnbjf ajow agsj aerkqzjdqst anenlvbalkn arfajzzgckx"
+ "adqqqofkmz amjpavjuhw aqgehgnb awvvxlbtqzn agstqko akmkzehyh atagzey agwja"
+ "amag ahe autkllywhr avnk atmt akn anvdh aixfrv"
+ "aqdyerbws avefykly awl azaduojgzo anxfsmw axpt abgbvk ati"
+ "attyqkwz aiweypiczul afy asitaqbczhh aitxisizpv auhviq aibql ajfqc"
+ "aylzprtmta aiuemihqrpi awluvgsw ampbuy axlifpzfqr aems aoaxwads apianfn"
+ "aodrkijelq acdb aaserrdxm aqyasgofqu aevvivo afi apmwu aeoqysl"
+ "amqnk ankaotm ayfy ajcupeeoc advcbukan aucahlwnyk adbfyo azqjpeant"
+ "afczpp asqrs ahslvda akhlf aiqgdp atyd aznuglxqbrg awirndrh"
+ "aqhiajp amxeazb asxuehg akod axvolvsp agcz asmovmohy acmqa"
+ "avvomv aafms ashuaec arevx audtq alrwqhjvao avgsgpg ajbrctpsel"
+ "atxoirr ayopboobqdu ajunntua arh aernimxid aipljda aglo aefk"
+ "aonxf acmnnkna abgviaswe aulvcbv axp apemgakpzo aibql acioaid"
+ "axo alrwqhjvao ayqounftdzl azmoakdyh apajze ajk artvy apxiamy"
+ "ayjafsraz addjj agsj asejtziqws acatvhegu aoxdjqblsvv aekdmmbs aaobe"
+ "abjjvzubkwt alczv ati awz auyxgcxeb aymjoym anqoukprtyt atwfhpmbooh"
+ "ajfqz aethlgir aclcx aowlyvetby aproqm afjlqtkv anebfy akzrcpfrrvw"
+ "aoledfotm aiwlfm aeejlaej anz abgbvk aktfn aayoh anpywgdvgz"
+ "acvmldguld asdvz aqb aeomsyzyu aggylhprbdz asrfkwz auipybpsn agsnszzfb"
+}
+
+do_test fts3corrupt2-1.0 {
+ execsql BEGIN
+ execsql { CREATE VIRTUAL TABLE t2 USING FTS3(a, b); }
+ execsql { INSERT INTO t2(t2) VALUES('nodesize=32') }
+ foreach d $data {
+ execsql { INSERT INTO t2 VALUES($d, $d) }
+ }
+ execsql COMMIT
+ execsql { SELECT count(*) FROM t2_segments }
+} {163}
+
+proc set_byte {blob byte val} {
+ binary format a*ca* \
+ [string range $blob 0 [expr $byte-1]] \
+ $val \
+ [string range $blob [expr $byte+1] end] \
+}
+
+set tn 0
+set c 256
+foreach {rowid sz blob} [
+ db eval {SELECT rowid, length(block), block FROM t2_segments}
+] {
+ incr tn
+ set c [expr (($c+255)%256)]
+ for {set i 0} {$i < $sz} {incr i} {
+ set b2 [set_byte $blob $i $c]
+ execsql { UPDATE t2_segments SET block = $b2 WHERE rowid = $rowid }
+ do_test fts3corrupt2-1.$tn.$i {
+ catchsql { SELECT * FROM t2 WHERE t2 MATCH 'a*' }
+ set {} {}
+ } {}
+ }
+ execsql { UPDATE t2_segments SET block = $blob WHERE rowid = $rowid }
+}
+
+foreach c {50 100 150 200 250} {
+ foreach {rowid sz blob} [
+ db eval {SELECT rowid, length(root), root FROM t2_segdir}
+ ] {
+ incr tn
+ for {set i 0} {$i < $sz} {incr i} {
+ set b2 [set_byte $blob $i $c]
+ execsql { UPDATE t2_segdir SET root = $b2 WHERE rowid = $rowid }
+ do_test fts3corrupt2-2.$c.$tn.$i {
+ catchsql { SELECT * FROM t2 WHERE t2 MATCH 'a*' }
+ set {} {}
+ } {}
+ }
+ execsql { UPDATE t2_segdir SET root = $blob WHERE rowid = $rowid }
+ }
+}
+
+
+
+
+
+
+finish_test
diff --git a/test/fts3cov.test b/test/fts3cov.test
new file mode 100644
index 0000000..c43999d
--- /dev/null
+++ b/test/fts3cov.test
@@ -0,0 +1,432 @@
+# 2009 December 03
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# The tests in this file are structural coverage tests for FTS3.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build does not include FTS3, skip the tests in this file.
+#
+ifcapable !fts3 { finish_test ; return }
+source $testdir/fts3_common.tcl
+source $testdir/malloc_common.tcl
+
+set DO_MALLOC_TEST 0
+set testprefix fts3cov
+
+#--------------------------------------------------------------------------
+# When it first needs to read a block from the %_segments table, the FTS3
+# module compiles an SQL statement for that purpose. The statement is
+# stored and reused each subsequent time a block is read. This test case
+# tests the effects of an OOM error occuring while compiling the statement.
+#
+# Similarly, when FTS3 first needs to scan through a set of segment leaves
+# to find a set of documents that matches a term, it allocates a string
+# containing the text of the required SQL, and compiles one or more
+# statements to traverse the leaves. This test case tests that OOM errors
+# that occur while allocating this string and statement are handled correctly
+# also.
+#
+do_test fts3cov-1.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts3(x);
+ INSERT INTO t1(t1) VALUES('nodesize=24');
+ BEGIN;
+ INSERT INTO t1 VALUES('Is the night chilly and dark?');
+ INSERT INTO t1 VALUES('The night is chilly, but not dark.');
+ INSERT INTO t1 VALUES('The thin gray cloud is spread on high,');
+ INSERT INTO t1 VALUES('It covers but not hides the sky.');
+ COMMIT;
+ SELECT count(*)>0 FROM t1_segments;
+ }
+} {1}
+
+set DO_MALLOC_TEST 1
+do_restart_select_test fts3cov-1.2 {
+ SELECT docid FROM t1 WHERE t1 MATCH 'chilly';
+} {1 2}
+set DO_MALLOC_TEST 0
+
+#--------------------------------------------------------------------------
+# When querying the full-text index, if an expected internal node block is
+# missing from the %_segments table, or if a NULL value is stored in the
+# %_segments table instead of a binary blob, database corruption should be
+# reported.
+#
+# Even with tiny 24 byte nodes, it takes a fair bit of data to produce a
+# segment b-tree that uses the %_segments table to store internal nodes.
+#
+do_test fts3cov-2.1 {
+ execsql {
+ INSERT INTO t1(t1) VALUES('nodesize=24');
+ BEGIN;
+ INSERT INTO t1 VALUES('The moon is behind, and at the full;');
+ INSERT INTO t1 VALUES('And yet she looks both small and dull.');
+ INSERT INTO t1 VALUES('The night is chill, the cloud is gray:');
+ INSERT INTO t1 VALUES('''T is a month before the month of May,');
+ INSERT INTO t1 VALUES('And the Spring comes slowly up this way.');
+ INSERT INTO t1 VALUES('The lovely lady, Christabel,');
+ INSERT INTO t1 VALUES('Whom her father loves so well,');
+ INSERT INTO t1 VALUES('What makes her in the wood so late,');
+ INSERT INTO t1 VALUES('A furlong from the castle gate?');
+ INSERT INTO t1 VALUES('She had dreams all yesternight');
+ INSERT INTO t1 VALUES('Of her own betrothed knight;');
+ INSERT INTO t1 VALUES('And she in the midnight wood will pray');
+ INSERT INTO t1 VALUES('For the weal of her lover that''s far away.');
+ COMMIT;
+ }
+ execsql {
+ INSERT INTO t1(t1) VALUES('optimize');
+ SELECT substr(hex(root), 1, 2) FROM t1_segdir;
+ }
+} {03}
+
+# Test the "missing entry" case:
+do_test fts3cov-2.2 {
+ set root [db one {SELECT root FROM t1_segdir}]
+ read_fts3varint [string range $root 1 end] left_child
+ execsql { DELETE FROM t1_segments WHERE blockid = $left_child }
+} {}
+do_error_test fts3cov-2.3 {
+ SELECT * FROM t1 WHERE t1 MATCH 'c*'
+} {SQL logic error or missing database}
+
+# Test the "replaced with NULL" case:
+do_test fts3cov-2.4 {
+ execsql { INSERT INTO t1_segments VALUES($left_child, NULL) }
+} {}
+do_error_test fts3cov-2.5 {
+ SELECT * FROM t1 WHERE t1 MATCH 'cloud'
+} {SQL logic error or missing database}
+
+#--------------------------------------------------------------------------
+# The following tests are to test the effects of OOM errors while storing
+# terms in the pending-hash table. Specifically, while creating doclist
+# blobs to store in the table. More specifically, to test OOM errors while
+# appending column numbers to doclists. For example, if a doclist consists
+# of:
+#
+# <docid> <column 0 offset-list> 0x01 <column N> <column N offset-list>
+#
+# The following tests check that malloc errors encountered while appending
+# the "0x01 <column N>" data to the dynamically growable blob used to
+# accumulate the doclist in memory are handled correctly.
+#
+do_test fts3cov-3.1 {
+ set cols [list]
+ set vals [list]
+ for {set i 0} {$i < 120} {incr i} {
+ lappend cols "col$i"
+ lappend vals "'word'"
+ }
+ execsql "CREATE VIRTUAL TABLE t2 USING fts3([join $cols ,])"
+} {}
+set DO_MALLOC_TEST 1
+do_write_test fts3cov-3.2 t2_content "
+ INSERT INTO t2(docid, [join $cols ,]) VALUES(1, [join $vals ,])
+"
+do_write_test fts3cov-3.3 t2_content "
+ INSERT INTO t2(docid, [join $cols ,]) VALUES(200, [join $vals ,])
+"
+do_write_test fts3cov-3.4 t2_content "
+ INSERT INTO t2(docid, [join $cols ,]) VALUES(60000, [join $vals ,])
+"
+
+#-------------------------------------------------------------------------
+# If too much data accumulates in the pending-terms hash table, it is
+# flushed to the database automatically, even if the transaction has not
+# finished. The following tests check the effects of encountering an OOM
+# while doing this.
+#
+do_test fts3cov-4.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t3 USING fts3(x);
+ INSERT INTO t3(t3) VALUES('nodesize=24');
+ INSERT INTO t3(t3) VALUES('maxpending=100');
+ }
+} {}
+set DO_MALLOC_TEST 1
+do_write_test fts3cov-4.2 t3_content {
+ INSERT INTO t3(docid, x)
+ SELECT 1, 'Then Christabel stretched forth her hand,' UNION ALL
+ SELECT 3, 'And comforted fair Geraldine:' UNION ALL
+ SELECT 4, '''O well, bright dame, may you command' UNION ALL
+ SELECT 5, 'The service of Sir Leoline;' UNION ALL
+ SELECT 2, 'And gladly our stout chivalry' UNION ALL
+ SELECT 7, 'Will he send forth, and friends withal,' UNION ALL
+ SELECT 8, 'To guide and guard you safe and free' UNION ALL
+ SELECT 6, 'Home to your noble father''s hall.'''
+}
+
+#-------------------------------------------------------------------------
+# When building the internal tree structure for each segment b-tree, FTS3
+# assumes that the content of each internal node will be less than
+# $nodesize bytes, where $nodesize is the advisory node size. If this turns
+# out to be untrue, then an extra buffer must be malloc'd for each term.
+# This test case tests these paths and the effects of said mallocs failing
+# by inserting insert a document with some fairly large terms into a
+# full-text table with a very small node-size.
+#
+# Test this handling of large terms in three contexts:
+#
+# 1. When flushing the pending-terms table.
+# 2. When optimizing the data structures using the INSERT syntax.
+# 2. When optimizing the data structures using the deprecated SELECT syntax.
+#
+do_test fts3cov-5.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t4 USING fts3(x);
+ INSERT INTO t4(t4) VALUES('nodesize=24');
+ }
+} {}
+set DO_MALLOC_TEST 1
+
+# Test when flushing pending-terms table.
+do_write_test fts3cov-5.2 t4_content {
+ INSERT INTO t4
+ SELECT 'ItisanancientMarinerAndhestoppethoneofthreeAA' UNION ALL
+ SELECT 'ItisanancientMarinerAndhestoppethoneofthreeBB' UNION ALL
+ SELECT 'ItisanancientMarinerAndhestoppethoneofthreeCC' UNION ALL
+ SELECT 'BythylonggreybeardandglitteringeyeNowwhereforestoppstAA' UNION ALL
+ SELECT 'BythylonggreybeardandglitteringeyeNowwhereforestoppstBB' UNION ALL
+ SELECT 'BythylonggreybeardandglitteringeyeNowwhereforestoppstCC'
+}
+
+# Test when optimizing via INSERT.
+do_test fts3cov-5.3 { execsql { INSERT INTO t4 VALUES('extra!') } } {}
+do_write_test fts3cov-5.2 t4_segments { INSERT INTO t4(t4) VALUES('optimize') }
+
+# Test when optimizing via SELECT.
+do_test fts3cov-5.5 { execsql { INSERT INTO t4 VALUES('more extra!') } } {}
+do_write_test fts3cov-5.6 t4_segments {
+ SELECT * FROM (SELECT optimize(t4) FROM t4 LIMIT 1)
+ EXCEPT SELECT 'Index optimized'
+}
+
+#-------------------------------------------------------------------------
+# When merging all segments at a given level to create a single segment
+# at level+1, FTS3 runs a query of the form:
+#
+# SELECT count(*) FROM %_segdir WHERE level = ?
+#
+# The query is compiled the first time this operation is required and
+# reused thereafter. This test aims to test the effects of an OOM while
+# preparing and executing this query for the first time.
+#
+# Then, keep inserting rows into the table so that the effects of an OOM
+# while re-executing the same query can also be tested.
+#
+do_test fts3cov-6.1 {
+ execsql { CREATE VIRTUAL TABLE t5 USING fts3(x) }
+ for {set i 0} {$i<16} {incr i} { execsql "INSERT INTO t5 VALUES('term$i')" }
+ execsql { SELECT count(*) FROM t5_segdir }
+} {16}
+
+# First time.
+db close
+sqlite3 db test.db
+do_write_test fts3cov-6.2 t5_content {
+ INSERT INTO t5 VALUES('segment number 16!');
+}
+
+# Second time.
+do_test fts3cov-6.3 {
+ for {set i 1} {$i<16} {incr i} { execsql "INSERT INTO t5 VALUES('term$i')" }
+ execsql { SELECT count(*) FROM t5_segdir }
+} {17}
+do_write_test fts3cov-6.4 t5_content {
+ INSERT INTO t5 VALUES('segment number 16!');
+}
+
+#-------------------------------------------------------------------------
+# Update the docid of a row. Test this in two scenarios:
+#
+# 1. When the row being updated is the only row in the table.
+# 2. When it is not.
+#
+# The two cases above take different paths because in case 1 all data
+# structures can simply be emptied before inserting the new row record.
+# In case 2, the data structures actually have to be updated.
+#
+do_test fts3cov-7.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t7 USING fts3(a, b, c);
+ INSERT INTO t7 VALUES('A', 'B', 'C');
+ UPDATE t7 SET docid = 5;
+ SELECT docid, * FROM t7;
+ }
+} {5 A B C}
+do_test fts3cov-7.2 {
+ execsql {
+ INSERT INTO t7 VALUES('D', 'E', 'F');
+ UPDATE t7 SET docid = 1 WHERE docid = 6;
+ SELECT docid, * FROM t7;
+ }
+} {1 D E F 5 A B C}
+
+#-------------------------------------------------------------------------
+# If a set of documents are modified within a transaction, the
+# pending-terms table must be flushed each time a document with a docid
+# less than or equal to the previous docid is modified.
+#
+# This test checks the effects of an OOM error occuring when the
+# pending-terms table is flushed for this reason as part of a DELETE
+# statement.
+#
+do_malloc_test fts3cov-8 -sqlprep {
+ BEGIN;
+ CREATE VIRTUAL TABLE t8 USING fts3;
+ INSERT INTO t8 VALUES('the output of each batch run');
+ INSERT INTO t8 VALUES('(possibly a day''s work)');
+ INSERT INTO t8 VALUES('was written to two separate disks');
+ COMMIT;
+} -sqlbody {
+ BEGIN;
+ DELETE FROM t8 WHERE rowid = 3;
+ DELETE FROM t8 WHERE rowid = 2;
+ DELETE FROM t8 WHERE rowid = 1;
+ COMMIT;
+}
+
+#-------------------------------------------------------------------------
+# Test some branches in the code that handles "special" inserts like:
+#
+# INSERT INTO t1(t1) VALUES('optimize');
+#
+# Also test that an optimize (INSERT method) works on an empty table.
+#
+set DO_MALLOC_TEST 0
+do_test fts3cov-9.1 {
+ execsql { CREATE VIRTUAL TABLE xx USING fts3 }
+} {}
+do_error_test fts3cov-9.2 {
+ INSERT INTO xx(xx) VALUES('optimise'); -- British spelling
+} {SQL logic error or missing database}
+do_error_test fts3cov-9.3 {
+ INSERT INTO xx(xx) VALUES('short');
+} {SQL logic error or missing database}
+do_error_test fts3cov-9.4 {
+ INSERT INTO xx(xx) VALUES('waytoolongtobecorrect');
+} {SQL logic error or missing database}
+do_test fts3cov-9.5 {
+ execsql { INSERT INTO xx(xx) VALUES('optimize') }
+} {}
+
+#-------------------------------------------------------------------------
+# Test that a table can be optimized in the middle of a transaction when
+# the pending-terms table is non-empty. This case involves some extra
+# branches because data must be read not only from the database, but
+# also from the pending-terms table.
+#
+do_malloc_test fts3cov-10 -sqlprep {
+ CREATE VIRTUAL TABLE t10 USING fts3;
+ INSERT INTO t10 VALUES('Optimising images for the web is a tricky business');
+ BEGIN;
+ INSERT INTO t10 VALUES('You have to get the right balance between');
+} -sqlbody {
+ INSERT INTO t10(t10) VALUES('optimize');
+}
+
+#-------------------------------------------------------------------------
+# Test a full-text query for a term that was once in the index, but is
+# no longer.
+#
+do_test fts3cov-11.1 {
+ execsql {
+ CREATE VIRTUAL TABLE xx USING fts3;
+ INSERT INTO xx VALUES('one two three');
+ INSERT INTO xx VALUES('four five six');
+ DELETE FROM xx WHERE docid = 1;
+ }
+ execsql { SELECT * FROM xx WHERE xx MATCH 'two' }
+} {}
+
+
+do_malloc_test fts3cov-12 -sqlprep {
+ CREATE VIRTUAL TABLE t12 USING fts3;
+ INSERT INTO t12 VALUES('is one of the two togther');
+ BEGIN;
+ INSERT INTO t12 VALUES('one which was appropriate at the time');
+} -sqlbody {
+ SELECT * FROM t12 WHERE t12 MATCH 'one'
+}
+
+do_malloc_test fts3cov-13 -sqlprep {
+ PRAGMA encoding = 'UTF-16';
+ CREATE VIRTUAL TABLE t13 USING fts3;
+ INSERT INTO t13 VALUES('two scalar functions');
+ INSERT INTO t13 VALUES('scalar two functions');
+ INSERT INTO t13 VALUES('functions scalar two');
+} -sqlbody {
+ SELECT snippet(t13, '%%', '%%', '#') FROM t13 WHERE t13 MATCH 'two';
+ SELECT snippet(t13, '%%', '%%') FROM t13 WHERE t13 MATCH 'two';
+ SELECT snippet(t13, '%%') FROM t13 WHERE t13 MATCH 'two';
+}
+
+do_execsql_test 14.0 {
+ CREATE VIRTUAL TABLE t14 USING fts4(a, b);
+ INSERT INTO t14 VALUES('one two three', 'one three four');
+ INSERT INTO t14 VALUES('a b c', 'd e a');
+}
+do_execsql_test 14.1 {
+ SELECT rowid FROM t14 WHERE t14 MATCH '"one two three"'
+} {1}
+do_execsql_test 14.2 {
+ SELECT rowid FROM t14 WHERE t14 MATCH '"one four"'
+} {}
+do_execsql_test 14.3 {
+ SELECT rowid FROM t14 WHERE t14 MATCH '"e a"'
+} {2}
+do_execsql_test 14.5 {
+ SELECT rowid FROM t14 WHERE t14 MATCH '"e b"'
+} {}
+do_catchsql_test 14.6 {
+ SELECT rowid FROM t14 WHERE rowid MATCH 'one'
+} {1 {unable to use function MATCH in the requested context}}
+do_catchsql_test 14.7 {
+ SELECT rowid FROM t14 WHERE docid MATCH 'one'
+} {1 {unable to use function MATCH in the requested context}}
+
+do_execsql_test 15.0 {
+ CREATE VIRTUAL TABLE t15 USING fts4(a, b, c);
+ INSERT INTO t15 VALUES('abc def ghi', 'abc2 def2 ghi2', 'abc3 def3 ghi3');
+ INSERT INTO t15 VALUES('abc2 def2 ghi2', 'abc2 def2 ghi2', 'abc def3 ghi3');
+}
+do_execsql_test 15.1 {
+ SELECT rowid FROM t15 WHERE t15 MATCH '"abc* def2"'
+} {1 2}
+
+# Test a corruption case.
+#
+do_execsql_test 16.1 {
+ CREATE VIRTUAL TABLE t16 USING fts4;
+ INSERT INTO t16 VALUES('theoretical work to examine the relationship');
+ INSERT INTO t16 VALUES('solution of our problems on the invisible');
+ DELETE FROM t16_content WHERE rowid = 2;
+}
+do_catchsql_test 16.2 {
+ SELECT * FROM t16 WHERE t16 MATCH 'invisible'
+} {1 {database disk image is malformed}}
+
+# And another corruption test case.
+#
+do_execsql_test 17.1 {
+ CREATE VIRTUAL TABLE t17 USING fts4;
+ INSERT INTO t17(content) VALUES('one one one');
+ UPDATE t17_segdir SET root = X'00036F6E65FFFFFFFFFFFFFFFFFFFFFF02030300'
+} {}
+do_catchsql_test 17.2 {
+ SELECT * FROM t17 WHERE t17 MATCH 'one'
+} {1 {database disk image is malformed}}
+
+
+
+
+finish_test
diff --git a/test/fts3d.test b/test/fts3d.test
new file mode 100644
index 0000000..1ae992b
--- /dev/null
+++ b/test/fts3d.test
@@ -0,0 +1,360 @@
+# 2008 June 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this script is testing the FTS3 module's optimize() function.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+#*************************************************************************
+# Utility function to check for the expected terms in the segment
+# level/index. _all version does same but for entire index.
+proc check_terms {test level index terms} {
+ set where "level = $level AND idx = $index"
+ do_test $test.terms [list fts3_terms t1 $where] $terms
+}
+proc check_terms_all {test terms} {
+ do_test $test.terms [list fts3_terms t1 1] $terms
+}
+
+# Utility function to check for the expected doclist for the term in
+# segment level/index. _all version does same for entire index.
+proc check_doclist {test level index term doclist} {
+ set where "level = $level AND idx = $index"
+ do_test $test.doclist [list fts3_doclist t1 $term $where] $doclist
+}
+proc check_doclist_all {test term doclist} {
+ do_test $test.doclist [list fts3_doclist t1 $term 1] $doclist
+}
+
+#*************************************************************************
+# Test results when all rows are deleted and one is added back.
+# Previously older segments would continue to exist, but now the index
+# should be dropped when the table is empty. The results should look
+# exactly like we never added the earlier rows in the first place.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE 1=1; -- Delete each row rather than dropping table.
+ INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');
+}
+
+# Should be a single initial segment.
+do_test fts3d-1.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0}
+do_test fts3d-1.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;
+ }
+} {{0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}}
+
+check_terms_all fts3d-1.1 {a is test this}
+check_doclist_all fts3d-1.1.1 a {[1 0[2]]}
+check_doclist_all fts3d-1.1.2 is {[1 0[1]]}
+check_doclist_all fts3d-1.1.3 test {[1 0[3]]}
+check_doclist_all fts3d-1.1.4 this {[1 0[0]]}
+
+check_terms fts3d-1.2 0 0 {a is test this}
+check_doclist fts3d-1.2.1 0 0 a {[1 0[2]]}
+check_doclist fts3d-1.2.2 0 0 is {[1 0[1]]}
+check_doclist fts3d-1.2.3 0 0 test {[1 0[3]]}
+check_doclist fts3d-1.2.4 0 0 this {[1 0[0]]}
+
+#*************************************************************************
+# Test results when everything is optimized manually.
+# NOTE(shess): This is a copy of fts3c-1.3. I've pulled a copy here
+# because fts3d-2 and fts3d-3 should have identical results.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE docid IN (1,3);
+ DROP TABLE IF EXISTS t1old;
+ ALTER TABLE t1 RENAME TO t1old;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (docid, c) SELECT docid, c FROM t1old;
+ DROP TABLE t1old;
+}
+
+# Should be a single optimal segment with the same logical results.
+do_test fts3d-2.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0}
+do_test fts3d-2.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;
+ }
+} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
+
+check_terms_all fts3d-2.1 {a test that was}
+check_doclist_all fts3d-2.1.1 a {[2 0[2]]}
+check_doclist_all fts3d-2.1.2 test {[2 0[3]]}
+check_doclist_all fts3d-2.1.3 that {[2 0[0]]}
+check_doclist_all fts3d-2.1.4 was {[2 0[1]]}
+
+check_terms fts3d-2.2 0 0 {a test that was}
+check_doclist fts3d-2.2.1 0 0 a {[2 0[2]]}
+check_doclist fts3d-2.2.2 0 0 test {[2 0[3]]}
+check_doclist fts3d-2.2.3 0 0 that {[2 0[0]]}
+check_doclist fts3d-2.2.4 0 0 was {[2 0[1]]}
+
+#*************************************************************************
+# Test results when everything is optimized via optimize().
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');
+ DELETE FROM t1 WHERE docid IN (1,3);
+ SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
+}
+
+# Should be a single optimal segment with the same logical results.
+do_test fts3d-3.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0}
+do_test fts3d-3.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;
+ }
+} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
+
+check_terms_all fts3d-3.1 {a test that was}
+check_doclist_all fts3d-3.1.1 a {[2 0[2]]}
+check_doclist_all fts3d-3.1.2 test {[2 0[3]]}
+check_doclist_all fts3d-3.1.3 that {[2 0[0]]}
+check_doclist_all fts3d-3.1.4 was {[2 0[1]]}
+
+check_terms fts3d-3.2 0 0 {a test that was}
+check_doclist fts3d-3.2.1 0 0 a {[2 0[2]]}
+check_doclist fts3d-3.2.2 0 0 test {[2 0[3]]}
+check_doclist fts3d-3.2.3 0 0 that {[2 0[0]]}
+check_doclist fts3d-3.2.4 0 0 was {[2 0[1]]}
+
+#*************************************************************************
+# Test optimize() against a table involving segment merges.
+# NOTE(shess): Since there's no transaction, each of the INSERT/UPDATE
+# statements generates a segment.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+
+ INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
+
+ UPDATE t1 SET c = 'This is a test one' WHERE rowid = 1;
+ UPDATE t1 SET c = 'That was a test one' WHERE rowid = 2;
+ UPDATE t1 SET c = 'This is a test one' WHERE rowid = 3;
+
+ UPDATE t1 SET c = 'This is a test two' WHERE rowid = 1;
+ UPDATE t1 SET c = 'That was a test two' WHERE rowid = 2;
+ UPDATE t1 SET c = 'This is a test two' WHERE rowid = 3;
+
+ UPDATE t1 SET c = 'This is a test three' WHERE rowid = 1;
+ UPDATE t1 SET c = 'That was a test three' WHERE rowid = 2;
+ UPDATE t1 SET c = 'This is a test three' WHERE rowid = 3;
+
+ UPDATE t1 SET c = 'This is a test four' WHERE rowid = 1;
+ UPDATE t1 SET c = 'That was a test four' WHERE rowid = 2;
+ UPDATE t1 SET c = 'This is a test four' WHERE rowid = 3;
+
+ UPDATE t1 SET c = 'This is a test' WHERE rowid = 1;
+ UPDATE t1 SET c = 'That was a test' WHERE rowid = 2;
+ UPDATE t1 SET c = 'This is a test' WHERE rowid = 3;
+}
+
+# 2 segments in level 0, 1 in level 1 (18 segments created, 16
+# merged).
+do_test fts3d-4.segments {
+ execsql {
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {0 0 0 1 1 0}
+
+do_test fts3d-4.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;
+ }
+} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \
+ {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \
+ {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]
+
+check_terms_all fts3d-4.1 {a four is one test that this three two was}
+check_doclist_all fts3d-4.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}
+check_doclist_all fts3d-4.1.2 four {}
+check_doclist_all fts3d-4.1.3 is {[1 0[1]] [3 0[1]]}
+check_doclist_all fts3d-4.1.4 one {}
+check_doclist_all fts3d-4.1.5 test {[1 0[3]] [2 0[3]] [3 0[3]]}
+check_doclist_all fts3d-4.1.6 that {[2 0[0]]}
+check_doclist_all fts3d-4.1.7 this {[1 0[0]] [3 0[0]]}
+check_doclist_all fts3d-4.1.8 three {}
+check_doclist_all fts3d-4.1.9 two {}
+check_doclist_all fts3d-4.1.10 was {[2 0[1]]}
+
+check_terms fts3d-4.2 0 0 {a four test that was}
+check_doclist fts3d-4.2.1 0 0 a {[2 0[2]]}
+check_doclist fts3d-4.2.2 0 0 four {[2]}
+check_doclist fts3d-4.2.3 0 0 test {[2 0[3]]}
+check_doclist fts3d-4.2.4 0 0 that {[2 0[0]]}
+check_doclist fts3d-4.2.5 0 0 was {[2 0[1]]}
+
+check_terms fts3d-4.3 0 1 {a four is test this}
+check_doclist fts3d-4.3.1 0 1 a {[3 0[2]]}
+check_doclist fts3d-4.3.2 0 1 four {[3]}
+check_doclist fts3d-4.3.3 0 1 is {[3 0[1]]}
+check_doclist fts3d-4.3.4 0 1 test {[3 0[3]]}
+check_doclist fts3d-4.3.5 0 1 this {[3 0[0]]}
+
+check_terms fts3d-4.4 1 0 {a four is one test that this three two was}
+check_doclist fts3d-4.4.1 1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]}
+check_doclist fts3d-4.4.2 1 0 four {[1] [2 0[4]] [3 0[4]]}
+check_doclist fts3d-4.4.3 1 0 is {[1 0[1]] [3 0[1]]}
+check_doclist fts3d-4.4.4 1 0 one {[1] [2] [3]}
+check_doclist fts3d-4.4.5 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}
+check_doclist fts3d-4.4.6 1 0 that {[2 0[0]]}
+check_doclist fts3d-4.4.7 1 0 this {[1 0[0]] [3 0[0]]}
+check_doclist fts3d-4.4.8 1 0 three {[1] [2] [3]}
+check_doclist fts3d-4.4.9 1 0 two {[1] [2] [3]}
+check_doclist fts3d-4.4.10 1 0 was {[2 0[1]]}
+
+# Optimize should leave the result in the level of the highest-level
+# prior segment.
+breakpoint
+do_test fts3d-4.5 {
+ execsql {
+ SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {{Index optimized} 1 0}
+
+# Identical to fts3d-4.matches.
+do_test fts3d-4.5.matches {
+ execsql {
+ SELECT OFFSETS(t1) FROM t1
+ WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;
+ }
+} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \
+ {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \
+ {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]
+
+check_terms_all fts3d-4.5.1 {a is test that this was}
+check_doclist_all fts3d-4.5.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}
+check_doclist_all fts3d-4.5.1.2 is {[1 0[1]] [3 0[1]]}
+check_doclist_all fts3d-4.5.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]}
+check_doclist_all fts3d-4.5.1.4 that {[2 0[0]]}
+check_doclist_all fts3d-4.5.1.5 this {[1 0[0]] [3 0[0]]}
+check_doclist_all fts3d-4.5.1.6 was {[2 0[1]]}
+
+check_terms fts3d-4.5.2 1 0 {a is test that this was}
+check_doclist fts3d-4.5.2.1 1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]}
+check_doclist fts3d-4.5.2.2 1 0 is {[1 0[1]] [3 0[1]]}
+check_doclist fts3d-4.5.2.3 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}
+check_doclist fts3d-4.5.2.4 1 0 that {[2 0[0]]}
+check_doclist fts3d-4.5.2.5 1 0 this {[1 0[0]] [3 0[0]]}
+check_doclist fts3d-4.5.2.6 1 0 was {[2 0[1]]}
+
+# Re-optimizing does nothing.
+do_test fts3d-5.0 {
+ execsql {
+ SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {{Index already optimal} 1 0}
+
+# Even if we move things around, still does nothing.
+do_test fts3d-5.1 {
+ execsql {
+ UPDATE t1_segdir SET level = 2 WHERE level = 1 AND idx = 0;
+ SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
+ SELECT level, idx FROM t1_segdir ORDER BY level, idx;
+ }
+} {{Index already optimal} 2 0}
+
+
+# ALTER TABLE RENAME should work regardless of the database encoding.
+#
+do_test fts3d-6.0 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA encoding=UTF8;
+ CREATE VIRTUAL TABLE fts USING fts3(a,b,c);
+ SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
+ }
+} {fts_content fts_segdir fts_segments}
+do_test fts3d-6.1 {
+ db eval {
+ ALTER TABLE fts RENAME TO xyz;
+ SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
+ }
+} {xyz_content xyz_segdir xyz_segments}
+do_test fts3d-6.2 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA encoding=UTF16le;
+ CREATE VIRTUAL TABLE fts USING fts3(a,b,c);
+ SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
+ }
+} {fts_content fts_segdir fts_segments}
+do_test fts3d-6.3 {
+ db eval {
+ ALTER TABLE fts RENAME TO xyz;
+ SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
+ }
+} {xyz_content xyz_segdir xyz_segments}
+do_test fts3d-6.4 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA encoding=UTF16be;
+ CREATE VIRTUAL TABLE fts USING fts3(a,b,c);
+ SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
+ }
+} {fts_content fts_segdir fts_segments}
+do_test fts3d-6.5 {
+ db eval {
+ ALTER TABLE fts RENAME TO xyz;
+ SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
+ }
+} {xyz_content xyz_segdir xyz_segments}
+
+
+finish_test
diff --git a/test/fts3defer.test b/test/fts3defer.test
new file mode 100644
index 0000000..bc50874
--- /dev/null
+++ b/test/fts3defer.test
@@ -0,0 +1,493 @@
+# 2010 October 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+set sqlite_fts3_enable_parentheses 1
+
+set fts3_simple_deferred_tokens_only 1
+
+set ::testprefix fts3defer
+
+#--------------------------------------------------------------------------
+# Test cases fts3defer-1.* are the "warm body" cases. The database contains
+# one row with 15000 instances of the token "a". This makes the doclist for
+# "a" so large that FTS3 will avoid loading it in most cases.
+#
+# To show this, test cases fts3defer-1.2.* execute a bunch of FTS3 queries
+# involving token "a". Then, fts3defer-1.3.* replaces the doclist for token
+# "a" with all zeroes and fts3defer-1.4.* repeats the tests from 1.2. If
+# the tests still work, we can conclude that the doclist for "a" was not
+# used.
+#
+
+set aaa [string repeat "a " 15000]
+
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4;
+ BEGIN;
+ INSERT INTO t1 VALUES('this is a dog');
+ INSERT INTO t1 VALUES('an instance of a phrase');
+ INSERT INTO t1 VALUES('an instance of a longer phrase');
+ INSERT INTO t1 VALUES($aaa);
+ COMMIT;
+} {}
+
+set tests {
+ 1 {SELECT rowid FROM t1 WHERE t1 MATCH '"a dog"'} {1}
+ 2 {SELECT rowid FROM t1 WHERE t1 MATCH '"is a dog"'} {1}
+ 3 {SELECT rowid FROM t1 WHERE t1 MATCH '"a longer phrase"'} {3}
+ 4 {SELECT snippet(t1) FROM t1 WHERE t1 MATCH '"a longer phrase"'}
+ {"an instance of <b>a</b> <b>longer</b> <b>phrase</b>"}
+ 5 {SELECT rowid FROM t1 WHERE t1 MATCH 'a dog'} {1}
+}
+
+do_select_tests 1.2 $tests
+
+do_execsql_test 1.3 {
+ SELECT count(*) FROM t1_segments WHERE length(block)>10000;
+ UPDATE t1_segments
+ SET block = zeroblob(length(block))
+ WHERE length(block)>10000;
+} {1}
+
+do_select_tests 1.4 $tests
+
+# Drop the table. It is corrupt now anyhow, so not useful for subsequent tests.
+#
+do_execsql_test 1.5 { DROP TABLE t1 }
+
+#--------------------------------------------------------------------------
+# These tests - fts3defer-2.* - are more rigorous. They test that for a
+# variety of queries, FTS3 and FTS4 return the same results. And that
+# zeroing the very large doclists that FTS4 does not load does not change
+# the results.
+#
+# They use the following pseudo-randomly generated document data. The
+# tokens "zm" and "jk" are especially common in this dataset. Additionally,
+# two documents are added to the pseudo-random data before it is loaded
+# into FTS4 containing 100,000 instances of the "zm" and "jk" tokens. This
+# makes the doclists for those tokens so large that FTS4 avoids loading them
+# into memory if possible.
+#
+set data [list]
+lappend data [string repeat "zm " 100000]
+lappend data [string repeat "jk " 100000]
+lappend data {*}{
+ "zm zm agmckuiu uhzq nsab jk rrkx duszemmzl hyq jk"
+ "jk uhzq zm zm rgpzmlnmd zm zk jk jk zm"
+ "duszemmzl zm jk xldlpy zm jk sbptoa xh jk xldlpy"
+ "zm xh zm xqf azavwm jk jk trqd rgpzmlnmd jk"
+ "zm vwq urvysbnykk ubwrfqnbjf zk lsz jk doiwavhwwo jk jk"
+ "jk xduvfhk orpfawpx zkhdvkw jk mjpavjuhw zm jk duszemmzl zm"
+ "jk igju jk jk zm hmjf xh zm gwdfhwurx zk"
+ "vgsld jk jk zm hrlipdm jn zm zsmhnf vgsld duszemmzl"
+ "gtuiexzsu aayxpmve zm zm zm drir scpgna xh azavwm uhzq"
+ "farlehdhq hkfoudzftq igju duszemmzl xnxhf ewle zm hrlipdm urvysbnykk kn"
+ "xnxhf jk jk agmckuiu duszemmzl jk zm zm jk vgsld"
+ "zm zm zm jk jk urvysbnykk ogttbykvt zm zm jk"
+ "iasrqgqv zm azavwm zidhxhbtv jk jk mjpavjuhw zm zm ajmvcydy"
+ "rgpzmlnmd tmt mjpavjuhw xh igju jk azavwm fibokdry vgsld ofm"
+ "zm jk vgsld jk xh jk csjqxhgj drir jk pmrb"
+ "xh jk jk zm rrkx duszemmzl mjpavjuhw xldlpy igju zm"
+ "jk hkfoudzftq zf rrkx wdmy jupk jk zm urvysbnykk npywgdvgz"
+ "zm jk zm zm zhbrzadb uenvbm aayxpmve urvysbnykk duszemmzl jk"
+ "uenvbm jk zm fxw xh bdilwmjw mjpavjuhw uv jk zm"
+ "nk jk bnhc pahlds jk igju dzadnqzprr jk jk jk"
+ "uhzq uv zm duszemmzl tlqix jk jk xh jk zm"
+ "jk zm agmckuiu urvysbnykk jk jk zm zm jk jk"
+ "azavwm mjpavjuhw lsgshn trqd xldlpy ogyavjvv agmckuiu ryvwwhlbc jk jk"
+ "tmt jk zk zm azavwm ofm acpgim bvgimjik iasrqgqv wuvajhwqz"
+ "igju ogyavjvv xrbdak rrkx fibokdry zf ujfhmrllq jk zm hxgwvib"
+ "zm pahlds jk uenvbm aayxpmve iaf hmjf xph vnlyvtkgx zm"
+ "jk xnxhf igju jk xh jk nvfasfh zm js jk"
+ "zm zm rwaj igju xr rrkx xnxhf nvfasfh skxbsqzvmt xatbxeqq"
+ "vgsld zm ujfhmrllq uhzq ogyavjvv nsab azavwm zm vgsld jmfiqhwnjg"
+ "ymjoym duszemmzl urvysbnykk azavwm jk jmfiqhwnjg bu qcdziqomqk vnlyvtkgx"
+ "zm nbilqcnz dzadnqzprr xh bkfgzsxn urvysbnykk xrujfzxqf zm zf agmckuiu"
+ "jk urvysbnykk nvfasfh zf xh zm zm qcdziqomqk qvxtclg wdmy"
+ "fibokdry jk urvysbnykk jk xr osff zm cvnnsl zm vgsld"
+ "jk mjpavjuhw hkfoudzftq jk zm xh xqf urvysbnykk jk iasrqgqv"
+ "jk csjqxhgj duszemmzl iasrqgqv aayxpmve zm brsuoqww jk qpmhtvl wluvgsw"
+ "jk mj azavwm jk zm jn dzadnqzprr zm jk uhzq"
+ "zk xqf jupk fxw nbilqcnz zm jk jcpiwj tznlvbfcv nvfasfh"
+ "jk jcpiwj zm xnxhf zm mjpavjuhw mj drir pa pvjrjlas"
+ "duszemmzl dzadnqzprr jk swc duszemmzl tmt jk jk pahlds jk"
+ "zk zm jk zm zm eczkjblu zm hi pmrb jk"
+ "azavwm zm iz agmckuiu jk sntk jk duszemmzl duszemmzl zm"
+ "jk zm jk eczkjblu urvysbnykk sk gnl jk ttvgf hmjf"
+ "jk bnhc jjrxpjkb mjpavjuhw fibokdry igju jk zm zm xh"
+ "wxe ogttbykvt uhzq xr iaf zf urvysbnykk aayxpmve oacaxgjoo mjpavjuhw"
+ "gazrt jk ephknonq myjp uenvbm wuvajhwqz jk zm xnxhf nvfasfh"
+ "zm aayxpmve csjqxhgj xnxhf xr jk aayxpmve xnxhf zm zm"
+ "sokcyf zm ogyavjvv jk zm fibokdry zm jk igju igju"
+ "vgsld bvgimjik xuprtlyle jk akmikrqyt jk aayxpmve hkfoudzftq ddjj ithtir"
+ "zm uhzq ovkyevlgv zk uenvbm csjqxhgj jk vgsld pgybs jk"
+ "zm agmckuiu zexh fibokdry jk uhzq bu tugflixoex xnxhf sk"
+ "zm zf uenvbm jk azavwm zm zm agmckuiu zm jk"
+ "rrkx jk zf jt zm oacaxgjoo fibokdry wdmy igju csjqxhgj"
+ "hi igju zm jk zidhxhbtv dzadnqzprr jk jk trqd duszemmzl"
+ "zm zm mjpavjuhw xrbdak qrvbjruc jk qzzqdxq guwq cvnnsl zm"
+ "ithtir jk jk qcdziqomqk zm farlehdhq zm zm xrbdak jk"
+ "ixfipk csjqxhgj azavwm sokcyf ttvgf vgsld jk sk xh zk"
+ "nvfasfh azavwm zm zm zm fxw nvfasfh zk gnl trqd"
+ "zm fibokdry csjqxhgj ofm dzadnqzprr jk akmikrqyt orpfawpx duszemmzl vwq"
+ "csjqxhgj jk jk vgsld urvysbnykk jk nxum jk jk nxum"
+ "zm hkfoudzftq jk ryvwwhlbc mjpavjuhw ephknonq jk zm ogyavjvv zm"
+ "lwa hi xnxhf qdyerbws zk njtc jk uhzq zm jk"
+ "trqd zm dzadnqzprr zm urvysbnykk jk lsz jk mjpavjuhw cmnnkna"
+ "duszemmzl zk jk jk fibokdry jseuhjnzo zm aayxpmve zk jk"
+ "fibokdry jk sviq qvxtclg wdmy jk doiwavhwwo zexh jk zm"
+ "jupk zm xh jk mjpavjuhw zm jk nsab npywgdvgz duszemmzl"
+ "zm igju zm zm nvfasfh eh hkfoudzftq fibokdry fxw xkblf"
+ "jk zm jk jk zm xh zk abthnzcv zf csjqxhgj"
+ "zm zm jk nkaotm urvysbnykk sbptoa bq jk ktxdty ubwrfqnbjf"
+ "nvfasfh aayxpmve xdcuz zm tugflixoex jcpiwj zm mjpavjuhw fibokdry doiwavhwwo"
+ "iaf jk mjpavjuhw zm duszemmzl jk jk uhzq pahlds fibokdry"
+ "ddjj zk azavwm jk swc zm gjtexkv jk xh jk"
+ "igju jk csjqxhgj zm jk dzadnqzprr duszemmzl ulvcbv jk jk"
+ "jk fibokdry zm csjqxhgj jn zm zm zm zf uhzq"
+ "duszemmzl jk xkblf zk hrlipdm aayxpmve uenvbm uhzq jk zf"
+ "dzadnqzprr jk zm zdu nvfasfh zm jk urvysbnykk hmjf jk"
+ "jk aayxpmve aserrdxm acpgim fibokdry jk drir wxe brsuoqww rrkx"
+ "uhzq csjqxhgj nvfasfh jk rrkx qbamok trqd uenvbm sntk zm"
+ "ps azavwm zkhdvkw jk zm jk jk zm csjqxhgj xedlrcfo"
+ "jk jk ogyavjvv jk zm farlehdhq duszemmzl jk agitgxamxe jk"
+ "qzzqdxq rwaj jk jk zm xqf jk uenvbm jk zk"
+ "zm hxgwvib akmikrqyt zf agmckuiu uenvbm bq npywgdvgz azavwm jk"
+ "zf jmfiqhwnjg js igju zm aayxpmve zm mbxnljomiv csjqxhgj nvfasfh"
+ "zm jk jk gazrt jk jk lkc jk nvfasfh jk"
+ "xldlpy orpfawpx zkhdvkw jk zm igju zm urvysbnykk dzadnqzprr mbxnljomiv"
+ "urvysbnykk jk zk igju zm uenvbm jk zm ithtir jk"
+ "zm zk zm zf ofm zm xdcuz dzadnqzprr zm vgsld"
+ "sbptoa jk tugflixoex jk zm zm vgsld zm xh zm"
+ "uhzq jk zk evvivo vgsld vniqnuynvf agmckuiu jk zm zm"
+ "zm nvfasfh zm zm zm abthnzcv uenvbm jk zk dzadnqzprr"
+ "zm azavwm igju qzzqdxq jk xnxhf abthnzcv jk nvfasfh zm"
+ "qbamok fxw vgsld igju cmnnkna xnxhf vniqnuynvf zk xh zm"
+ "nvfasfh zk zm mjpavjuhw dzadnqzprr jk jk duszemmzl xldlpy nvfasfh"
+ "xnxhf sviq nsab npywgdvgz osff vgsld farlehdhq fibokdry wjbkhzsa hhac"
+ "zm azavwm scpgna jk jk bq jk duszemmzl fibokdry ovkyevlgv"
+ "csjqxhgj zm jk jk duszemmzl zk xh zm jk zf"
+ "urvysbnykk dzadnqzprr csjqxhgj mjpavjuhw ubwrfqnbjf nkaotm jk jk zm drir"
+ "nvfasfh xh igju zm wluvgsw jk zm srwwnezqk ewle ovnq"
+ "jk nvfasfh eh ktxdty urvysbnykk vgsld zm jk eh uenvbm"
+ "orpfawpx pahlds jk uhzq hi zm zm zf jk dzadnqzprr"
+ "srwwnezqk csjqxhgj rbwzuf nvfasfh jcpiwj xldlpy nvfasfh jk vgsld wjybxmieki"
+}
+
+proc add_empty_records {n} {
+ execsql BEGIN
+ for {set i 0} {$i < $n} {incr i} {
+ execsql { INSERT INTO t1 VALUES('') }
+ }
+ execsql COMMIT
+}
+
+
+#set e [list]
+#foreach d $data {set e [concat $e $d]}
+#puts [lsort -unique $e]
+#exit
+
+set zero_long_doclists {
+ UPDATE t1_segments SET block=zeroblob(length(block)) WHERE length(block)>10000
+}
+
+foreach {tn setup} {
+ 1 {
+ set dmt_modes 0
+ execsql { CREATE VIRTUAL TABLE t1 USING FTS3 }
+ foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }
+ }
+ 2 {
+ set dmt_modes 0
+ execsql { CREATE VIRTUAL TABLE t1 USING FTS4 }
+ foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }
+ }
+ 3 {
+ set dmt_modes {0 1 2}
+ execsql { CREATE VIRTUAL TABLE t1 USING FTS4 }
+ foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }
+ add_empty_records 1000
+ execsql $zero_long_doclists
+ }
+ 4 {
+ set dmt_modes 0
+ execsql { CREATE VIRTUAL TABLE t1 USING FTS4 }
+ foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }
+ add_empty_records 1000
+ execsql "INSERT INTO t1(t1) VALUES('optimize')"
+ execsql $zero_long_doclists
+ }
+ 5 {
+ set dmt_modes 0
+ execsql { CREATE VIRTUAL TABLE t1 USING FTS4(matchinfo=fts3) }
+ foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }
+ add_empty_records 1000
+ execsql $zero_long_doclists
+ }
+} {
+
+ execsql { DROP TABLE IF EXISTS t1 }
+ eval $setup
+ set ::testprefix fts3defer-2.$tn
+ set DO_MALLOC_TEST 0
+
+ do_execsql_test 0 {
+ SELECT count(*) FROM t1_segments WHERE length(block)>10000
+ } {2}
+
+ do_select_test 1.1 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'jk xnxhf'
+ } {13 29 40 47 48 52 63 92}
+ do_select_test 1.2 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'jk eh'
+ } {100}
+ do_select_test 1.3 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'jk ubwrfqnbjf'
+ } {7 70 98}
+ do_select_test 1.4 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'duszemmzl jk'
+ } {3 5 8 10 13 18 20 23 32 37 41 43 55 60 65 67 72 74 76 81 94 96 97}
+ do_select_test 1.5 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'ubwrfqnbjf jk'
+ } {7 70 98}
+ do_select_test 1.6 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'jk ubwrfqnbjf jk jk jk jk'
+ } {7 70 98}
+ do_select_test 1.7 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'zm xnxhf'
+ } {12 13 29 30 40 47 48 52 63 92 93}
+ do_select_test 1.8 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'zm eh'
+ } {68 100}
+ do_select_test 1.9 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'zm ubwrfqnbjf'
+ } {7 70 98}
+ do_select_test 1.10 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'z* vgsld'
+ } {10 13 17 31 35 51 58 88 89 90 93 100}
+
+ if { $fts3_simple_deferred_tokens_only==0 } {
+ do_select_test 1.11 {
+ SELECT rowid FROM t1
+ WHERE t1 MATCH '(
+ zdu OR zexh OR zf OR zhbrzadb OR zidhxhbtv OR
+ zk OR zkhdvkw OR zm OR zsmhnf
+ ) vgsld'
+ } {10 13 17 31 35 51 58 88 89 90 93 100}
+ }
+
+ do_select_test 2.1 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"zm agmckuiu"'
+ } {3 24 52 53}
+ do_select_test 2.2 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"zm zf"'
+ } {33 53 75 88 101}
+ do_select_test 2.3 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"zm aayxpmve"'
+ } {48 65 84}
+ do_select_test 2.4 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"aayxpmve zm"'
+ } {11 37 84}
+ do_select_test 2.5 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"jk azavwm"'
+ } {16 53}
+ do_select_test 2.6 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"xh jk jk"'
+ } {18}
+ do_select_test 2.7 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"zm jk vgsld"'
+ } {13 17}
+ do_select_test 2.8 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"zm jk vgsld lkjlkjlkj"'
+ } {}
+
+ do_select_test 3.1 {
+ SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH '"zm agmckuiu"'
+ } {
+ {zm [zm] [agmckuiu] uhzq nsab jk rrkx duszemmzl hyq jk}
+ {jk [zm] [agmckuiu] urvysbnykk jk jk zm zm jk jk}
+ {[zm] [agmckuiu] zexh fibokdry jk uhzq bu tugflixoex xnxhf sk}
+ {zm zf uenvbm jk azavwm zm [zm] [agmckuiu] zm jk}
+ }
+
+ do_select_test 3.2 {
+ SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH 'xnxhf jk'
+ } {
+ {[xnxhf] [jk] [jk] agmckuiu duszemmzl [jk] zm zm [jk] vgsld}
+ {[jk] [xnxhf] igju [jk] xh [jk] nvfasfh zm js [jk]}
+ {[jk] jcpiwj zm [xnxhf] zm mjpavjuhw mj drir pa pvjrjlas}
+ {gazrt [jk] ephknonq myjp uenvbm wuvajhwqz [jk] zm [xnxhf] nvfasfh}
+ {zm aayxpmve csjqxhgj [xnxhf] xr [jk] aayxpmve [xnxhf] zm zm}
+ {zm agmckuiu zexh fibokdry [jk] uhzq bu tugflixoex [xnxhf] sk}
+ {lwa hi [xnxhf] qdyerbws zk njtc [jk] uhzq zm [jk]}
+ {zm azavwm igju qzzqdxq [jk] [xnxhf] abthnzcv [jk] nvfasfh zm}
+ }
+
+ do_select_test 4.1 {
+ SELECT offsets(t1) FROM t1 WHERE t1 MATCH '"jk uenvbm"'
+ } {
+ {0 0 10 2 0 1 13 6} {0 0 26 2 0 1 29 6}
+ }
+
+ do_select_test 4.2 {
+ SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'duszemmzl jk fibokdry'
+ } {
+ {0 2 3 8 0 1 36 2 0 0 58 9}
+ {0 0 0 9 0 1 13 2 0 1 16 2 0 2 19 8 0 1 53 2}
+ {0 1 4 2 0 0 20 9 0 1 30 2 0 1 33 2 0 2 48 8}
+ {0 1 17 2 0 1 20 2 0 1 26 2 0 0 29 9 0 2 39 8}
+ }
+
+ do_select_test 4.3 {
+ SELECT offsets(t1) FROM t1
+ WHERE t1 MATCH 'vgsld (hrlipdm OR (aapmve NEAR duszemmzl))'
+ } {{0 0 0 5 0 1 15 7 0 0 36 5}}
+
+ # The following block of tests runs normally with FTS3 or FTS4 without the
+ # long doclists zeroed. And with OOM-injection for FTS4 with long doclists
+ # zeroed. Change this by messing with the [set dmt_modes] commands above.
+ #
+ foreach DO_MALLOC_TEST $dmt_modes {
+
+ # Phrase search.
+ #
+ do_select_test 5.$DO_MALLOC_TEST.1 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"jk mjpavjuhw"'
+ } {8 15 36 64 67 72}
+
+ # Multiple tokens search.
+ do_select_test 5.$DO_MALLOC_TEST.2 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'duszemmzl zm'
+ } {3 5 8 10 12 13 18 20 23 37 43 55 60 65 67 72 74 81 94 96 97}
+
+ # snippet() function with phrase.
+ do_select_test 5.$DO_MALLOC_TEST.3 {
+ SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH '"zm aayxpmve"'
+ } {
+ {[zm] [aayxpmve] csjqxhgj xnxhf xr jk aayxpmve xnxhf zm zm}
+ {duszemmzl zk jk jk fibokdry jseuhjnzo [zm] [aayxpmve] zk jk}
+ {zf jmfiqhwnjg js igju [zm] [aayxpmve] zm mbxnljomiv csjqxhgj nvfasfh}
+ }
+
+ # snippet() function with multiple tokens.
+ do_select_test 5.$DO_MALLOC_TEST.4 {
+ SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH 'zm zhbrzadb'
+ } {
+ {[zm] jk [zm] [zm] [zhbrzadb] uenvbm aayxpmve urvysbnykk duszemmzl jk}
+ }
+
+ # snippet() function with phrase.
+ do_select_test 5.$DO_MALLOC_TEST.5 {
+ SELECT offsets(t1) FROM t1 WHERE t1 MATCH '"zm aayxpmve"'
+ } {
+ {0 0 0 2 0 1 3 8} {0 0 38 2 0 1 41 8} {0 0 22 2 0 1 25 8}
+ }
+
+ # snippet() function with multiple tokens.
+ do_select_test 5.$DO_MALLOC_TEST.6 {
+ SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'zm zhbrzadb'
+ } {
+ {0 0 0 2 0 0 6 2 0 0 9 2 0 1 12 8}
+ }
+
+ set DO_MALLOC_TEST 0
+ }
+
+ do_select_test 6.1 {
+ SELECT rowid FROM t1
+ WHERE t1 MATCH 'vgsld (hrlipdm OR (aayxpmve duszemmzl))'
+ } {10}
+ do_select_test 6.2.1 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"jk xduvfhk"'
+ } {8}
+ do_select_test 6.2.2 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"zm azavwm"'
+ } {15 26 92 96}
+ if {$fts3_simple_deferred_tokens_only==0} {
+ do_select_test 6.2.3 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '"jk xduvfhk" OR "zm azavwm"'
+ } {8 15 26 92 96}
+ }
+
+ if {$tn>1} {
+ # These tests will not work with $tn==1, as in this case table t1 is
+ # created using FTS3. The ^ syntax is only available with FTS4 tables.
+ #
+ do_select_test 7.1 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '^zm mjpavjuhw'
+ } {56 62}
+ do_select_test 7.2 {
+ SELECT rowid FROM t1 WHERE t1 MATCH '^azavwm zm'
+ } {43}
+ }
+}
+
+set testprefix fts3defer
+
+do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE x1 USING fts4(a, b);
+ INSERT INTO x1 VALUES('a b c', 'd e f');
+ INSERT INTO x1 SELECT * FROM x1;
+ INSERT INTO x1 SELECT * FROM x1;
+ INSERT INTO x1 SELECT * FROM x1;
+ INSERT INTO x1 SELECT * FROM x1;
+}
+do_execsql_test 3.2 "
+ INSERT INTO x1 VALUES(
+ '[string repeat {d } 3000]', '[string repeat {f } 30000]'
+ );
+ INSERT INTO x1(x1) VALUES('optimize');
+"
+
+do_execsql_test 3.3 {
+ SELECT count(*) FROM x1 WHERE x1 MATCH '"d e f"'
+} {16}
+
+# At one point the following was causing a floating-point exception.
+#
+do_execsql_test 4.1 {
+ CREATE VIRTUAL TABLE x2 USING FTS4(x);
+ BEGIN;
+ INSERT INTO x2 VALUES('m m m m m m m m m m m m m m m m m m m m m m m m m m');
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 SELECT * FROM x2;
+ INSERT INTO x2 VALUES('a b c d e f g h i j k l m n o p q r s t u v w x y m');
+ COMMIT;
+}
+do_execsql_test 4.2 {
+ SELECT * FROM x2 WHERE x2 MATCH 'a b c d e f g h i j k l m n o p q r s';
+} {{a b c d e f g h i j k l m n o p q r s t u v w x y m}}
+
+
+finish_test
diff --git a/test/fts3defer2.test b/test/fts3defer2.test
new file mode 100644
index 0000000..92a4491
--- /dev/null
+++ b/test/fts3defer2.test
@@ -0,0 +1,153 @@
+# 2010 October 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+ifcapable !fts3 { finish_test ; return }
+
+set testprefix fts3defer2
+
+proc mit {blob} {
+ set scan(littleEndian) i*
+ set scan(bigEndian) I*
+ binary scan $blob $scan($::tcl_platform(byteOrder)) r
+ return $r
+}
+db func mit mit
+
+#-----------------------------------------------------------------------------
+# This block of tests - fts3defer2-1.* - test the interaction of deferred NEAR
+# expressions and the snippet, offsets and matchinfo functions.
+#
+do_execsql_test 1.1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4;
+}
+do_execsql_test 1.1.2 "INSERT INTO t1 VALUES('[string repeat {a } 20000]')"
+do_execsql_test 1.1.3 "INSERT INTO t1 VALUES('[string repeat {z } 20000]')"
+do_execsql_test 1.1.4 {
+ INSERT INTO t1 VALUES('a b c d e f a x y');
+ INSERT INTO t1 VALUES('');
+ INSERT INTO t1 VALUES('');
+ INSERT INTO t1 VALUES('');
+ INSERT INTO t1 VALUES('');
+ INSERT INTO t1 VALUES('');
+ INSERT INTO t1(t1) VALUES('optimize');
+}
+do_execsql_test 1.1.4 {
+ SELECT count(*) FROM t1_segments WHERE length(block)>10000;
+ UPDATE t1_segments SET block = zeroblob(length(block)) WHERE length(block)>10000;
+} {2}
+
+do_execsql_test 1.2.0 {
+ SELECT content FROM t1 WHERE t1 MATCH 'f (e a)';
+} {{a b c d e f a x y}}
+
+do_execsql_test 1.2.1 {
+ SELECT content FROM t1 WHERE t1 MATCH 'f (e NEAR/2 a)';
+} {{a b c d e f a x y}}
+
+do_execsql_test 1.2.2 {
+ SELECT snippet(t1, '[', ']'), offsets(t1), mit(matchinfo(t1, 'pcxnal'))
+ FROM t1 WHERE t1 MATCH 'f (e NEAR/2 a)';
+} [list \
+ {a b c d [e] [f] [a] x y} \
+ {0 1 8 1 0 0 10 1 0 2 12 1} \
+ [list 3 1 1 1 1 1 1 1 1 1 1 8 5001 9]
+]
+
+do_execsql_test 1.2.3 {
+ SELECT snippet(t1, '[', ']'), offsets(t1), mit(matchinfo(t1, 'pcxnal'))
+ FROM t1 WHERE t1 MATCH 'f (e NEAR/3 a)';
+} [list \
+ {[a] b c d [e] [f] [a] x y} \
+ {0 2 0 1 0 1 8 1 0 0 10 1 0 2 12 1} \
+ [list 3 1 1 1 1 1 1 1 2 2 1 8 5001 9]
+]
+
+do_execsql_test 1.3.1 { DROP TABLE t1 }
+
+#-----------------------------------------------------------------------------
+# Test cases fts3defer2-2.* focus specifically on the matchinfo function.
+#
+do_execsql_test 2.1.1 "CREATE VIRTUAL TABLE t2 USING fts4"
+do_execsql_test 2.1.2 "INSERT INTO t2 VALUES('[string repeat {a } 10000]')"
+do_execsql_test 2.1.3 "INSERT INTO t2 VALUES('b [string repeat {z } 10000]')"
+do_execsql_test 2.1.4 [string repeat "INSERT INTO t2 VALUES('x');" 50]
+do_execsql_test 2.1.5 {
+ INSERT INTO t2 VALUES('a b c d e f g z');
+ INSERT INTO t2 VALUES('a b c d e f g');
+}
+foreach {tn sql} {
+ 1 {}
+ 2 { INSERT INTO t2(t2) VALUES('optimize') }
+ 3 { UPDATE t2_segments SET block = zeroblob(length(block))
+ WHERE length(block)>10000;
+ }
+} {
+ execsql $sql
+
+ do_execsql_test 2.2.$tn.1 {
+ SELECT mit(matchinfo(t2, 'pcxnal')) FROM t2 WHERE t2 MATCH 'a b';
+ } [list \
+ [list 2 1 1 54 54 1 3 3 54 372 8] \
+ [list 2 1 1 54 54 1 3 3 54 372 7] \
+ ]
+
+ do_execsql_test 2.2.$tn.2 {
+ SELECT mit(matchinfo(t2, 'x')) FROM t2 WHERE t2 MATCH 'g z';
+ } [list \
+ [list 1 2 2 1 54 54] \
+ ]
+
+ set sqlite_fts3_enable_parentheses 1
+ do_execsql_test 2.2.$tn.3 {
+ SELECT mit(matchinfo(t2, 'x')) FROM t2 WHERE t2 MATCH 'g OR (g z)';
+ } [list \
+ [list 1 2 2 1 2 2 1 54 54] \
+ [list 1 2 2 1 2 2 0 54 54] \
+ ]
+ set sqlite_fts3_enable_parentheses 0
+}
+
+do_execsql_test 2.3.1 {
+ CREATE VIRTUAL TABLE t3 USING fts4;
+ INSERT INTO t3 VALUES('a b c d e f');
+ INSERT INTO t3 VALUES('x b c d e f');
+ INSERT INTO t3 VALUES('d e f a b c');
+ INSERT INTO t3 VALUES('b c d e f');
+ INSERT INTO t3 VALUES('');
+ INSERT INTO t3 VALUES('');
+ INSERT INTO t3 VALUES('');
+ INSERT INTO t3 VALUES('');
+ INSERT INTO t3 VALUES('');
+ INSERT INTO t3 VALUES('');
+}
+do_execsql_test 2.3.2 "
+ INSERT INTO t3 VALUES('f e d c b [string repeat {a } 10000]')
+"
+foreach {tn sql} {
+ 1 {}
+ 2 { INSERT INTO t3(t3) VALUES('optimize') }
+ 3 { UPDATE t3_segments SET block = zeroblob(length(block))
+ WHERE length(block)>10000;
+ }
+} {
+ execsql $sql
+ do_execsql_test 2.4.$tn {
+ SELECT docid, mit(matchinfo(t3, 'pcxnal')) FROM t3 WHERE t3 MATCH '"a b c"';
+ } {1 {1 1 1 4 4 11 912 6} 3 {1 1 1 4 4 11 912 6}}
+}
+
+
+finish_test
+
diff --git a/test/fts3drop.test b/test/fts3drop.test
new file mode 100644
index 0000000..8b76eaf
--- /dev/null
+++ b/test/fts3drop.test
@@ -0,0 +1,61 @@
+# 2011 October 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module. More specifically,
+# that DROP TABLE commands can co-exist with savepoints inside transactions.
+# See ticket [48f299634a] for details.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts3drop
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE f1 USING fts3;
+ INSERT INTO f1 VALUES('a b c');
+}
+
+do_execsql_test 1.2 {
+ BEGIN;
+ INSERT INTO f1 VALUES('d e f');
+ SAVEPOINT one;
+ INSERT INTO f1 VALUES('g h i');
+ DROP TABLE f1;
+ ROLLBACK TO one;
+ COMMIT;
+}
+
+do_execsql_test 1.3 {
+ SELECT * FROM f1;
+} {{a b c} {d e f}}
+
+do_execsql_test 1.4 {
+ BEGIN;
+ INSERT INTO f1 VALUES('g h i');
+ SAVEPOINT one;
+ INSERT INTO f1 VALUES('j k l');
+ DROP TABLE f1;
+ RELEASE one;
+ ROLLBACK;
+}
+
+do_execsql_test 1.5 {
+ SELECT * FROM f1;
+} {{a b c} {d e f}}
+
+finish_test
diff --git a/test/fts3e.test b/test/fts3e.test
new file mode 100644
index 0000000..03caaf8
--- /dev/null
+++ b/test/fts3e.test
@@ -0,0 +1,125 @@
+# 2008 July 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# These tests exercise the various types of fts3 cursors.
+#
+# $Id: fts3e.test,v 1.1 2008/07/29 20:24:46 shess Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+#*************************************************************************
+# Test table scan (QUERY_GENERIC). This kind of query happens for
+# queries with no WHERE clause, or for WHERE clauses which cannot be
+# satisfied by an index.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');
+ INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');
+ INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');
+}
+
+do_test fts3e-1.1 {
+ execsql {
+ SELECT docid FROM t1 ORDER BY docid;
+ }
+} {1 2 3}
+
+do_test fts3e-1.2 {
+ execsql {
+ SELECT docid FROM t1 WHERE c LIKE '%test' ORDER BY docid;
+ }
+} {1 2 3}
+
+do_test fts3e-1.3 {
+ execsql {
+ SELECT docid FROM t1 WHERE c LIKE 'That%' ORDER BY docid;
+ }
+} {2}
+
+#*************************************************************************
+# Test lookup by docid (QUERY_DOCID). This kind of query happens for
+# queries which select by the docid/rowid implicit index.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE);
+ INSERT INTO t2 VALUES (null, 10);
+ INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test');
+ INSERT INTO t2 VALUES (null, 5);
+ INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'That was a test');
+ INSERT INTO t2 VALUES (null, 20);
+ INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test');
+}
+
+# TODO(shess): This actually is doing QUERY_GENERIC? I'd have
+# expected QUERY_DOCID in this case, as for a very large table the
+# full scan is less efficient.
+do_test fts3e-2.1 {
+ execsql {
+ SELECT docid FROM t1 WHERE docid in (1, 2, 10);
+ SELECT rowid FROM t1 WHERE rowid in (1, 2, 10);
+ }
+} {1 2 1 2}
+
+do_test fts3e-2.2 {
+ execsql {
+ SELECT docid, weight FROM t1, t2 WHERE t2.id = t1.docid ORDER BY weight;
+ SELECT t1.rowid, weight FROM t1, t2 WHERE t2.id = t1.rowid ORDER BY weight;
+ }
+} {2 5 1 10 3 20 2 5 1 10 3 20}
+
+do_test fts3e-2.3 {
+ execsql {
+ SELECT docid, weight FROM t1, t2
+ WHERE t2.weight>5 AND t2.id = t1.docid ORDER BY weight;
+ SELECT t1.rowid, weight FROM t1, t2
+ WHERE t2.weight>5 AND t2.id = t1.rowid ORDER BY weight;
+ }
+} {1 10 3 20 1 10 3 20}
+
+#*************************************************************************
+# Test lookup by MATCH (QUERY_FULLTEXT). This is the fulltext index.
+db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE VIRTUAL TABLE t1 USING fts3(c);
+ CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE);
+ INSERT INTO t2 VALUES (null, 10);
+ INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test');
+ INSERT INTO t2 VALUES (null, 5);
+ INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'That was a test');
+ INSERT INTO t2 VALUES (null, 20);
+ INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test');
+}
+
+do_test fts3e-3.1 {
+ execsql {
+ SELECT docid FROM t1 WHERE t1 MATCH 'this' ORDER BY docid;
+ }
+} {1 3}
+
+do_test fts3e-3.2 {
+ execsql {
+ SELECT docid, weight FROM t1, t2
+ WHERE t1 MATCH 'this' AND t1.docid = t2.id ORDER BY weight;
+ }
+} {1 10 3 20}
+
+finish_test
diff --git a/test/fts3expr.test b/test/fts3expr.test
new file mode 100644
index 0000000..e7c4f65
--- /dev/null
+++ b/test/fts3expr.test
@@ -0,0 +1,499 @@
+# 2006 September 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module.
+#
+# $Id: fts3expr.test,v 1.9 2009/07/28 16:44:26 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+set sqlite_fts3_enable_parentheses 1
+
+proc test_fts3expr {expr} {
+ db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')}
+}
+do_test fts3expr-1.0 {
+ test_fts3expr "abcd"
+} {PHRASE 3 0 abcd}
+do_test fts3expr-1.1 {
+ test_fts3expr " tag "
+} {PHRASE 3 0 tag}
+
+do_test fts3expr-1.2 {
+ test_fts3expr "ab AND cd"
+} {AND {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.2.1 {
+ test_fts3expr "ab cd"
+} {AND {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.3 {
+ test_fts3expr "ab OR cd"
+} {OR {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.4 {
+ test_fts3expr "ab NOT cd"
+} {NOT {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.5 {
+ test_fts3expr "ab NEAR cd"
+} {NEAR/10 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.6.1 {
+ test_fts3expr "ab NEAR/5 cd"
+} {NEAR/5 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.6.2 {
+ test_fts3expr "ab NEAR/87654321 cd"
+} {NEAR/87654321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.6.3 {
+ test_fts3expr "ab NEAR/7654321 cd"
+} {NEAR/7654321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.6.4 {
+ test_fts3expr "ab NEAR/654321 cd"
+} {NEAR/654321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.6.5 {
+ test_fts3expr "ab NEAR/54321 cd"
+} {NEAR/54321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.6.6 {
+ test_fts3expr "ab NEAR/4321 cd"
+} {NEAR/4321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.6.7 {
+ test_fts3expr "ab NEAR/321 cd"
+} {NEAR/321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+do_test fts3expr-1.6.8 {
+ test_fts3expr "ab NEAR/21 cd"
+} {NEAR/21 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
+
+do_test fts3expr-1.7 {
+ test_fts3expr {"one two three"}
+} {PHRASE 3 0 one two three}
+do_test fts3expr-1.8.1 {
+ test_fts3expr {zero "one two three" four}
+} {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}
+do_test fts3expr-1.8.2 {
+ test_fts3expr {zero AND "one two three" four}
+} {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}
+do_test fts3expr-1.8.3 {
+ test_fts3expr {zero "one two three" AND four}
+} {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}
+do_test fts3expr-1.8.4 {
+ test_fts3expr {zero AND "one two three" AND four}
+} {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}
+do_test fts3expr-1.9.1 {
+ test_fts3expr {"one* two three"}
+} {PHRASE 3 0 one+ two three}
+do_test fts3expr-1.9.2 {
+ test_fts3expr {"one two* three"}
+} {PHRASE 3 0 one two+ three}
+do_test fts3expr-1.9.3 {
+ test_fts3expr {"one* two* three"}
+} {PHRASE 3 0 one+ two+ three}
+do_test fts3expr-1.9.4 {
+ test_fts3expr {"one two three*"}
+} {PHRASE 3 0 one two three+}
+do_test fts3expr-1.9.5 {
+ test_fts3expr {"one* two three*"}
+} {PHRASE 3 0 one+ two three+}
+do_test fts3expr-1.9.6 {
+ test_fts3expr {"one two* three*"}
+} {PHRASE 3 0 one two+ three+}
+do_test fts3expr-1.9.7 {
+ test_fts3expr {"one* two* three*"}
+} {PHRASE 3 0 one+ two+ three+}
+
+do_test fts3expr-1.10 {
+ test_fts3expr {one* two}
+} {AND {PHRASE 3 0 one+} {PHRASE 3 0 two}}
+do_test fts3expr-1.11 {
+ test_fts3expr {one two*}
+} {AND {PHRASE 3 0 one} {PHRASE 3 0 two+}}
+
+do_test fts3expr-1.14 {
+ test_fts3expr {a:one two}
+} {AND {PHRASE 0 0 one} {PHRASE 3 0 two}}
+do_test fts3expr-1.15.1 {
+ test_fts3expr {one b:two}
+} {AND {PHRASE 3 0 one} {PHRASE 1 0 two}}
+do_test fts3expr-1.15.2 {
+ test_fts3expr {one B:two}
+} {AND {PHRASE 3 0 one} {PHRASE 1 0 two}}
+
+do_test fts3expr-1.16 {
+ test_fts3expr {one AND two AND three AND four AND five}
+} [list AND \
+ [list AND \
+ [list AND \
+ [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \
+ {PHRASE 3 0 three} \
+ ] \
+ {PHRASE 3 0 four} \
+ ] \
+ {PHRASE 3 0 five} \
+ ]
+do_test fts3expr-1.17 {
+ test_fts3expr {(one AND two) AND ((three AND four) AND five)}
+} [list AND \
+ [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \
+ [list AND \
+ [list AND {PHRASE 3 0 three} {PHRASE 3 0 four}] \
+ {PHRASE 3 0 five} \
+ ] \
+ ]
+do_test fts3expr-1.18 {
+ test_fts3expr {(one AND two) OR ((three AND four) AND five)}
+} [list OR \
+ [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \
+ [list AND \
+ [list AND {PHRASE 3 0 three} {PHRASE 3 0 four}] \
+ {PHRASE 3 0 five} \
+ ] \
+ ]
+do_test fts3expr-1.19 {
+ test_fts3expr {(one AND two) AND ((three AND four) OR five)}
+} [list AND \
+ [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \
+ [list OR \
+ [list AND {PHRASE 3 0 three} {PHRASE 3 0 four}] \
+ {PHRASE 3 0 five} \
+ ] \
+ ]
+do_test fts3expr-1.20 {
+ test_fts3expr {(one OR two) AND ((three OR four) AND five)}
+} [list AND \
+ [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \
+ [list AND \
+ [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \
+ {PHRASE 3 0 five} \
+ ] \
+ ]
+do_test fts3expr-1.21 {
+ test_fts3expr {(one OR two) AND ((three NOT four) AND five)}
+} [list AND \
+ [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \
+ [list AND \
+ [list NOT {PHRASE 3 0 three} {PHRASE 3 0 four}] \
+ {PHRASE 3 0 five} \
+ ] \
+ ]
+do_test fts3expr-1.22 {
+ test_fts3expr {(one OR two) NOT ((three OR four) AND five)}
+} [list NOT \
+ [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \
+ [list AND \
+ [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \
+ {PHRASE 3 0 five} \
+ ] \
+ ]
+do_test fts3expr-1.23 {
+ test_fts3expr {(((((one OR two))))) NOT (((((three OR four))) AND five))}
+} [list NOT \
+ [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \
+ [list AND \
+ [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \
+ {PHRASE 3 0 five} \
+ ] \
+ ]
+do_test fts3expr-1.24 {
+ test_fts3expr {one NEAR two}
+} [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}]
+do_test fts3expr-1.25 {
+ test_fts3expr {(one NEAR two)}
+} [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}]
+do_test fts3expr-1.26 {
+ test_fts3expr {((((((one NEAR two))))))}
+} [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}]
+do_test fts3expr-1.27 {
+ test_fts3expr {(one NEAR two) OR ((three OR four) AND five)}
+} [list OR \
+ [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}] \
+ [list AND \
+ [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \
+ {PHRASE 3 0 five} \
+ ] \
+ ]
+do_test fts3expr-1.28 {
+ test_fts3expr {(one NEAR/321 two) OR ((three OR four) AND five)}
+} [list OR \
+ [list NEAR/321 {PHRASE 3 0 one} {PHRASE 3 0 two}] \
+ [list AND \
+ [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \
+ {PHRASE 3 0 five} \
+ ] \
+ ]
+
+proc strip_phrase_data {L} {
+ if {[lindex $L 0] eq "PHRASE"} {
+ return [lrange $L 3 end]
+ }
+ return [list \
+ [lindex $L 0] \
+ [strip_phrase_data [lindex $L 1]] \
+ [strip_phrase_data [lindex $L 2]] \
+ ]
+}
+proc test_fts3expr2 {expr} {
+ strip_phrase_data [
+ db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')}
+ ]
+}
+do_test fts3expr-2.1 {
+ test_fts3expr2 "ab OR cd AND ef"
+} {OR ab {AND cd ef}}
+do_test fts3expr-2.2 {
+ test_fts3expr2 "cd AND ef OR ab"
+} {OR {AND cd ef} ab}
+do_test fts3expr-2.3 {
+ test_fts3expr2 "ab AND cd AND ef OR gh"
+} {OR {AND {AND ab cd} ef} gh}
+do_test fts3expr-2.4 {
+ test_fts3expr2 "ab AND cd OR ef AND gh"
+} {OR {AND ab cd} {AND ef gh}}
+do_test fts3expr-2.5 {
+ test_fts3expr2 "ab cd"
+} {AND ab cd}
+
+do_test fts3expr-3.1 {
+ test_fts3expr2 "(ab OR cd) AND ef"
+} {AND {OR ab cd} ef}
+do_test fts3expr-3.2 {
+ test_fts3expr2 "ef AND (ab OR cd)"
+} {AND ef {OR ab cd}}
+do_test fts3expr-3.3 {
+ test_fts3expr2 "(ab OR cd)"
+} {OR ab cd}
+do_test fts3expr-3.4 {
+ test_fts3expr2 "(((ab OR cd)))"
+} {OR ab cd}
+
+do_test fts3expr-3.5 {
+ test_fts3expr2 "one AND (two NEAR three)"
+} {AND one {NEAR/10 two three}}
+do_test fts3expr-3.6 {
+ test_fts3expr2 "one (two NEAR three)"
+} {AND one {NEAR/10 two three}}
+do_test fts3expr-3.7 {
+ test_fts3expr2 "(two NEAR three) one"
+} {AND {NEAR/10 two three} one}
+do_test fts3expr-3.8 {
+ test_fts3expr2 "(two NEAR three) AND one"
+} {AND {NEAR/10 two three} one}
+do_test fts3expr-3.9 {
+ test_fts3expr2 "(two NEAR three) (four five)"
+} {AND {NEAR/10 two three} {AND four five}}
+do_test fts3expr-3.10 {
+ test_fts3expr2 "(two NEAR three) AND (four five)"
+} {AND {NEAR/10 two three} {AND four five}}
+do_test fts3expr-3.11 {
+ test_fts3expr2 "(two NEAR three) (four NEAR five)"
+} {AND {NEAR/10 two three} {NEAR/10 four five}}
+do_test fts3expr-3.12 {
+ test_fts3expr2 "(two NEAR three) OR (four NEAR five)"
+} {OR {NEAR/10 two three} {NEAR/10 four five}}
+
+do_test fts3expr-3.13 {
+ test_fts3expr2 "(two NEAR/1a three)"
+} {AND {AND {AND two near} 1a} three}
+
+do_test fts3expr-3.14 {
+ test_fts3expr2 "(two NEAR// three)"
+} {AND {AND two near} three}
+do_test fts3expr-3.15 {
+ test_fts3expr2 "(two NEAR/: three)"
+} {AND {AND two near} three}
+
+do_test fts3expr-3.16 {
+ test_fts3expr2 "(two NEAR three)OR(four NEAR five)"
+} {OR {NEAR/10 two three} {NEAR/10 four five}}
+do_test fts3expr-3.17 {
+ test_fts3expr2 "(two NEAR three)OR\"four five\""
+} {OR {NEAR/10 two three} {four five}}
+do_test fts3expr-3.18 {
+ test_fts3expr2 "one \u0080wo"
+} "AND one \u0080wo"
+
+
+
+#------------------------------------------------------------------------
+# The following tests, fts3expr-4.*, test the parsers response to syntax
+# errors in query expressions. This is done using a real fts3 table and
+# MATCH clauses, not the parser test interface.
+#
+do_test fts3expr-4.1 {
+ execsql { CREATE VIRTUAL TABLE t1 USING fts3(a, b, c) }
+} {}
+
+# Mismatched parenthesis:
+do_test fts3expr-4.2.1 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example AND (hello OR world))' }
+} {1 {malformed MATCH expression: [example AND (hello OR world))]}}
+do_test fts3expr-4.2.2 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example AND (hello OR world' }
+} {1 {malformed MATCH expression: [example AND (hello OR world]}}
+do_test fts3expr-4.2.3 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH '(hello' }
+} {1 {malformed MATCH expression: [(hello]}}
+do_test fts3expr-4.2.4 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH '(' }
+} {1 {malformed MATCH expression: [(]}}
+do_test fts3expr-4.2.5 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH ')' }
+} {1 {malformed MATCH expression: [)]}}
+
+do_test fts3expr-4.2.6 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example (hello world' }
+} {1 {malformed MATCH expression: [example (hello world]}}
+
+# Unterminated quotation marks:
+do_test fts3expr-4.3.1 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example OR "hello world' }
+} {1 {malformed MATCH expression: [example OR "hello world]}}
+do_test fts3expr-4.3.2 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example OR hello world"' }
+} {1 {malformed MATCH expression: [example OR hello world"]}}
+
+# Binary operators without the required operands.
+do_test fts3expr-4.4.1 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'OR hello world' }
+} {1 {malformed MATCH expression: [OR hello world]}}
+do_test fts3expr-4.4.2 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'hello world OR' }
+} {1 {malformed MATCH expression: [hello world OR]}}
+do_test fts3expr-4.4.3 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one (hello world OR) two' }
+} {1 {malformed MATCH expression: [one (hello world OR) two]}}
+do_test fts3expr-4.4.4 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one (OR hello world) two' }
+} {1 {malformed MATCH expression: [one (OR hello world) two]}}
+
+# NEAR operators with something other than phrases as arguments.
+do_test fts3expr-4.5.1 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH '(hello OR world) NEAR one' }
+} {1 {malformed MATCH expression: [(hello OR world) NEAR one]}}
+do_test fts3expr-4.5.2 {
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one NEAR (hello OR world)' }
+} {1 {malformed MATCH expression: [one NEAR (hello OR world)]}}
+
+#------------------------------------------------------------------------
+# The following OOM tests are designed to cover cases in fts3_expr.c.
+#
+source $testdir/malloc_common.tcl
+do_malloc_test fts3expr-malloc-1 -sqlbody {
+ SELECT fts3_exprtest('simple', 'a b c "d e f"', 'a', 'b', 'c')
+}
+do_malloc_test fts3expr-malloc-2 -tclprep {
+ set sqlite_fts3_enable_parentheses 0
+} -sqlbody {
+ SELECT fts3_exprtest('simple', 'a -b', 'a', 'b', 'c')
+} -cleanup {
+ set sqlite_fts3_enable_parentheses 1
+}
+
+#------------------------------------------------------------------------
+# The following tests are not very important. They cover error handling
+# cases in the test code, which makes test coverage easier to measure.
+#
+do_test fts3expr-5.1 {
+ catchsql { SELECT fts3_exprtest('simple', 'a b') }
+} {1 {Usage: fts3_exprtest(tokenizer, expr, col1, ...}}
+do_test fts3expr-5.2 {
+ catchsql { SELECT fts3_exprtest('doesnotexist', 'a b', 'c') }
+} {1 {No such tokenizer module}}
+do_test fts3expr-5.3 {
+ catchsql { SELECT fts3_exprtest('simple', 'a b OR', 'c') }
+} {1 {Error parsing expression}}
+
+#------------------------------------------------------------------------
+# The next set of tests verifies that things actually work as they are
+# supposed to when using the new syntax.
+#
+do_test fts3expr-6.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts3(a);
+ }
+ for {set ii 1} {$ii < 32} {incr ii} {
+ set v [list]
+ if {$ii & 1} { lappend v one }
+ if {$ii & 2} { lappend v two }
+ if {$ii & 4} { lappend v three }
+ if {$ii & 8} { lappend v four }
+ if {$ii & 16} { lappend v five }
+ execsql { INSERT INTO t1 VALUES($v) }
+ }
+
+ execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'five four one' ORDER BY rowid}
+} {25 27 29 31}
+
+foreach {id expr res} {
+
+ 2 "five four NOT one" {24 26 28 30}
+
+ 3 "five AND four OR one"
+ {1 3 5 7 9 11 13 15 17 19 21 23 24 25 26 27 28 29 30 31}
+
+ 4 "five AND (four OR one)" {17 19 21 23 24 25 26 27 28 29 30 31}
+
+ 5 "five NOT (four OR one)" {16 18 20 22}
+
+ 6 "(five NOT (four OR one)) OR (five AND (four OR one))"
+ {16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
+
+ 7 "(five OR one) AND two AND three" {7 15 22 23 30 31}
+
+ 8 "five OR one AND two AND three"
+ {7 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
+
+ 9 "five OR one two three"
+ {7 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
+
+ 10 "five OR \"one two three\""
+ {7 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
+
+ 11 "one two OR four five NOT three" {3 7 11 15 19 23 24 25 26 27 31}
+
+ 12 "(one two OR four five) NOT three" {3 11 19 24 25 26 27}
+
+ 13 "((((((one two OR four five)))))) NOT three" {3 11 19 24 25 26 27}
+
+} {
+ do_test fts3expr-6.1.$id {
+ execsql { SELECT rowid FROM t1 WHERE t1 MATCH $expr ORDER BY rowid }
+ } $res
+}
+
+set sqlite_fts3_enable_parentheses 0
+foreach {id expr res} {
+ 1 "one -two three" {5 13 21 29}
+ 2 "-two one three" {5 13 21 29}
+ 3 "one three -two" {5 13 21 29}
+ 4 "-one -two three" {4 12 20 28}
+ 5 "three -one -two" {4 12 20 28}
+ 6 "-one three -two" {4 12 20 28}
+} {
+ do_test fts3expr-6.2.$id {
+ execsql { SELECT rowid FROM t1 WHERE t1 MATCH $expr ORDER BY rowid }
+ } $res
+}
+set sqlite_fts3_enable_parentheses 1
+
+do_test fts3expr-7.1 {
+ execsql {
+ CREATE VIRTUAL TABLE test USING fts3 (keyword);
+ INSERT INTO test VALUES ('abc');
+ SELECT * FROM test WHERE keyword MATCH '""';
+ }
+} {}
+
+
+set sqlite_fts3_enable_parentheses 0
+finish_test
diff --git a/test/fts3expr2.test b/test/fts3expr2.test
new file mode 100644
index 0000000..c3d1617
--- /dev/null
+++ b/test/fts3expr2.test
@@ -0,0 +1,166 @@
+# 2009 January 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module syntax parser.
+#
+# $Id: fts3expr2.test,v 1.2 2009/06/05 17:09:12 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Test overview:
+#
+# The tests in this file are pseudo-randomly generated. They test
+# the fts3 match expression parser via the test interface
+# SQL function "fts3_exprtest" (see comments in fts3_expr.c).
+#
+# Each test case works as follows:
+#
+# 1. A random expression tree is generated using proc [random_expr_tree].
+# 2. The expression tree is converted to the text of an equivalent
+# fts3 expression using proc [tree_to_expr].
+# 3. The test SQL function "fts3_exprtest" is used to parse the
+# expression text generated in step (2), returning a parsed expression
+# tree.
+# 4. Test that the tree returned in step (3) matches that generated in
+# step (1).
+#
+# In step (2), 4 different fts3 expressions are created from each
+# expression tree by varying the following boolean properties:
+#
+# * Whether or not superflous parenthesis are included. i.e. if
+# "a OR b AND (c OR d)" or "a OR (b AND (c OR d))" is generated.
+#
+# * Whether or not explict AND operators are used. i.e. if
+# "a OR b AND c" or "a OR b c" is generated.
+#
+
+set sqlite_fts3_enable_parentheses 1
+
+proc strip_phrase_data {L} {
+ if {[lindex $L 0] eq "PHRASE"} {
+ return [list P [lrange $L 3 end]]
+ }
+ return [list \
+ [lindex $L 0] \
+ [strip_phrase_data [lindex $L 1]] \
+ [strip_phrase_data [lindex $L 2]] \
+ ]
+}
+proc test_fts3expr2 {expr} {
+ strip_phrase_data [
+ db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')}
+ ]
+}
+
+proc rnd {nMax} { expr {int(rand()*$nMax)} }
+
+proc random_phrase {} {
+ set phrases [list one two three four "one two" "three four"]
+ list P [lindex $phrases [rnd [llength $phrases]]]
+}
+
+# Generate and return a pseudo-random expression tree. Using the same
+# format returned by the [test_fts3expr2] proc.
+#
+proc random_expr_tree {iHeight} {
+ if {$iHeight==0 || [rnd 3]==0} {
+ return [random_phrase]
+ }
+
+ set operators [list NEAR NOT AND OR]
+ set op [lindex $operators [rnd 4]]
+
+ if {$op eq "NEAR"} {
+ set iDistance [rnd 15]
+ return [list $op/$iDistance [random_phrase] [random_phrase]]
+ }
+
+ set iNH [expr {$iHeight - 1}]
+ return [list $op [random_expr_tree $iNH] [random_expr_tree $iNH]]
+}
+
+# Given an expression tree, generate a corresponding expression.
+#
+proc tree_to_expr {tree all_brackets implicit_and} {
+ set prec(NOT) 2
+ set prec(AND) 3
+ set prec() 3
+ set prec(OR) 4
+
+ set op [lindex $tree 0]
+
+ if {$op eq "P"} {
+ set phrase [lindex $tree 1]
+ if {[llength $phrase]>1} {
+ return "\"$phrase\""
+ } else {
+ return $phrase
+ }
+ }
+
+ if {$op eq "NEAR/10"} {
+ set op "NEAR"
+ }
+ if {$op eq "AND" && $implicit_and} {
+ set op ""
+ }
+
+ set lhs [lindex $tree 1]
+ set rhs [lindex $tree 2]
+ set zLeft [tree_to_expr $lhs $all_brackets $implicit_and]
+ set zRight [tree_to_expr $rhs $all_brackets $implicit_and]
+
+ set iPrec 5
+ set iLeftPrec 0
+ set iRightPrec 0
+
+ catch {set iPrec $prec($op)}
+ catch {set iLeftPrec $prec([lindex $lhs 0])}
+ catch {set iRightPrec $prec([lindex $rhs 0])}
+
+ if {$iLeftPrec > $iPrec || $all_brackets} {
+ set zLeft "($zLeft)"
+ }
+ if {$iRightPrec >= $iPrec || $all_brackets} {
+ set zRight "($zRight)"
+ }
+
+ return "$zLeft $op $zRight"
+}
+
+proc do_exprparse_test {name expr tree} {
+ uplevel do_test $name [list "test_fts3expr2 {$expr}"] [list $tree]
+}
+
+for {set iTest 1} {$iTest<500} {incr iTest} {
+ set t [random_expr_tree 4]
+
+ set e1 [tree_to_expr $t 0 0]
+ set e2 [tree_to_expr $t 0 1]
+ set e3 [tree_to_expr $t 1 0]
+ set e4 [tree_to_expr $t 1 1]
+
+ do_exprparse_test fts3expr2-$iTest.1 $e1 $t
+ do_exprparse_test fts3expr2-$iTest.2 $e2 $t
+ do_exprparse_test fts3expr2-$iTest.3 $e3 $t
+ do_exprparse_test fts3expr2-$iTest.4 $e4 $t
+}
+
+set sqlite_fts3_enable_parentheses 0
+finish_test
diff --git a/test/fts3fault.test b/test/fts3fault.test
new file mode 100644
index 0000000..ab82daa
--- /dev/null
+++ b/test/fts3fault.test
@@ -0,0 +1,231 @@
+# 2010 June 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set ::testprefix fts3fault
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 { finish_test ; return }
+
+# Test error handling in the sqlite3Fts3Init() function. This is the
+# function that registers the FTS3 module and various support functions
+# with SQLite.
+#
+do_faultsim_test 1 -body {
+ sqlite3 db test.db
+ expr 0
+} -test {
+ catch { db close }
+}
+
+# Test error handling in an "ALTER TABLE ... RENAME TO" statement on an
+# FTS3 table. Specifically, test renaming the table within a transaction
+# after it has been written to.
+#
+faultsim_delete_and_reopen
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE t1 USING fts3;
+ INSERT INTO t1 VALUES('test renaming the table');
+ INSERT INTO t1 VALUES(' after it has been written');
+}
+do_faultsim_test 2 -prep {
+ sqlite3 db test.db
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('registers the FTS3 module');
+ INSERT INTO t1 VALUES('various support functions');
+ }
+} -body {
+ execsql { ALTER TABLE t1 RENAME TO t2 }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+# Test error handling in the special case where a single prefix query
+# matches terms that reside on a large range of leaf nodes.
+#
+do_test fts3fault-3.0 {
+ sqlite3 db test.db
+ execsql { CREATE VIRTUAL TABLE t3 USING fts4; }
+ execsql { INSERT INTO t3(t3) VALUES('nodesize=50') }
+ execsql { BEGIN }
+ for {set i 0} {$i < 1000} {incr i} {
+ execsql { INSERT INTO t3 VALUES('aaa' || $i) }
+ }
+ execsql { COMMIT }
+} {}
+
+do_faultsim_test 3 -faults oom-transient -prep {
+ sqlite3 db test.db
+ execsql { SELECT * FROM t3 WHERE t3 MATCH 'x' }
+} -body {
+ execsql { SELECT count(rowid) FROM t3 WHERE t3 MATCH 'aa*' }
+} -test {
+ faultsim_test_result {0 1000}
+}
+
+do_test fts3fault-4.0 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE VIRTUAL TABLE t4 USING fts4;
+ INSERT INTO t4 VALUES('The British Government called on');
+ INSERT INTO t4 VALUES('as pesetas then became much');
+ }
+} {}
+faultsim_save_and_close
+do_faultsim_test 4 -prep {
+ faultsim_restore_and_reopen
+ execsql { SELECT content FROM t4 }
+} -body {
+ execsql { SELECT optimize(t4) FROM t4 LIMIT 1 }
+} -test {
+ faultsim_test_result {0 {{Index optimized}}}
+}
+
+do_test fts3fault-5.0 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE VIRTUAL TABLE t5 USING fts4;
+ INSERT INTO t5 VALUES('The British Government called on');
+ INSERT INTO t5 VALUES('as pesetas then became much');
+ }
+} {}
+faultsim_save_and_close
+do_faultsim_test 5 -prep {
+ faultsim_restore_and_reopen
+ execsql {
+ BEGIN;
+ INSERT INTO t5 VALUES('influential in shaping his future outlook');
+ INSERT INTO t5 VALUES('might be acceptable to the British electorate');
+ }
+} -body {
+ execsql { SELECT rowid FROM t5 WHERE t5 MATCH 'british' }
+} -test {
+ faultsim_test_result {0 {1 4}}
+}
+
+do_test fts3fault-6.0 {
+ faultsim_delete_and_reopen
+ execsql { CREATE VIRTUAL TABLE t6 USING fts4 }
+} {}
+faultsim_save_and_close
+do_faultsim_test 6 -prep {
+ faultsim_restore_and_reopen
+ execsql { SELECT rowid FROM t6 }
+} -body {
+ execsql { DROP TABLE t6 }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+# Test various malloc failures while processing FTS4 parameters.
+#
+do_faultsim_test 7.1 -prep {
+ faultsim_delete_and_reopen
+} -body {
+ execsql { CREATE VIRTUAL TABLE t1 USING fts4(a, b, matchinfo=fts3) }
+} -test {
+ faultsim_test_result {0 {}}
+}
+do_faultsim_test 7.2 -prep {
+ faultsim_delete_and_reopen
+} -body {
+ execsql { CREATE VIRTUAL TABLE t1 USING fts4(a, b, matchinfo=fs3) }
+} -test {
+ faultsim_test_result {1 {unrecognized matchinfo: fs3}} \
+ {1 {vtable constructor failed: t1}} \
+ {1 {SQL logic error or missing database}}
+}
+do_faultsim_test 7.3 -prep {
+ faultsim_delete_and_reopen
+} -body {
+ execsql { CREATE VIRTUAL TABLE t1 USING fts4(a, b, matchnfo=fts3) }
+} -test {
+ faultsim_test_result {1 {unrecognized parameter: matchnfo=fts3}} \
+ {1 {vtable constructor failed: t1}} \
+ {1 {SQL logic error or missing database}}
+}
+
+proc mit {blob} {
+ set scan(littleEndian) i*
+ set scan(bigEndian) I*
+ binary scan $blob $scan($::tcl_platform(byteOrder)) r
+ return $r
+}
+
+do_test 8.0 {
+ faultsim_delete_and_reopen
+ execsql { CREATE VIRTUAL TABLE t8 USING fts4 }
+ execsql "INSERT INTO t8 VALUES('a b c')"
+ execsql "INSERT INTO t8 VALUES('b b b')"
+ execsql "INSERT INTO t8 VALUES('[string repeat {c } 50000]')"
+ execsql "INSERT INTO t8 VALUES('d d d')"
+ execsql "INSERT INTO t8 VALUES('e e e')"
+ execsql "INSERT INTO t8(t8) VALUES('optimize')"
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test 8.1 -prep {
+ faultsim_restore_and_reopen
+ db func mit mit
+} -body {
+ execsql { SELECT mit(matchinfo(t8, 'x')) FROM t8 WHERE t8 MATCH 'a b c' }
+} -test {
+ faultsim_test_result {0 {{1 1 1 1 4 2 1 5 5}}}
+}
+do_faultsim_test 8.2 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+ db func mit mit
+} -body {
+ execsql { SELECT mit(matchinfo(t8, 's')) FROM t8 WHERE t8 MATCH 'a b c' }
+} -test {
+ faultsim_test_result {0 3}
+}
+do_faultsim_test 8.3 -prep {
+ faultsim_restore_and_reopen
+ db func mit mit
+} -body {
+ execsql { SELECT mit(matchinfo(t8, 'a')) FROM t8 WHERE t8 MATCH 'a b c' }
+} -test {
+ faultsim_test_result {0 10002}
+}
+do_faultsim_test 8.4 -prep {
+ faultsim_restore_and_reopen
+ db func mit mit
+} -body {
+ execsql { SELECT mit(matchinfo(t8, 'l')) FROM t8 WHERE t8 MATCH 'a b c' }
+} -test {
+ faultsim_test_result {0 3}
+}
+
+do_test 9.0 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE VIRTUAL TABLE t9 USING fts4(tokenize=porter);
+ INSERT INTO t9 VALUES(
+ 'this record is used toooooooooooooooooooooooooooooooooooooo try to'
+ );
+ SELECT offsets(t9) FROM t9 WHERE t9 MATCH 'to*';
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test 9.1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { SELECT offsets(t9) FROM t9 WHERE t9 MATCH 'to*' }
+} -test {
+ faultsim_test_result {0 {{0 0 20 39 0 0 64 2}}}
+}
+
+finish_test
diff --git a/test/fts3fault2.test b/test/fts3fault2.test
new file mode 100644
index 0000000..0178ed2
--- /dev/null
+++ b/test/fts3fault2.test
@@ -0,0 +1,134 @@
+# 2011 February 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix fts3fault2
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 { finish_test ; return }
+
+do_test 1.0 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts4(x);
+ INSERT INTO t1 VALUES('a b c');
+ INSERT INTO t1 VALUES('c d e');
+ CREATE VIRTUAL TABLE terms USING fts4aux(t1);
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test 1.1 -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ execsql "CREATE VIRTUAL TABLE terms2 USING fts4aux(t1)"
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 1.2 -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ execsql "SELECT * FROM terms"
+} -test {
+ faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 2 2 c 0 2 2 d * 1 1 d 0 1 1 e * 1 1 e 0 1 1}}
+}
+
+do_faultsim_test 1.3 -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ execsql "SELECT * FROM terms WHERE term>'a' AND TERM < 'd'"
+} -test {
+ faultsim_test_result {0 {b * 1 1 b 0 1 1 c * 2 2 c 0 2 2}}
+}
+
+do_faultsim_test 1.4 -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ execsql "SELECT * FROM terms WHERE term='c'"
+} -test {
+ faultsim_test_result {0 {c * 2 2 c 0 2 2}}
+}
+
+do_test 2.0 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE VIRTUAL TABLE tx USING fts4(a, b);
+ INSERT INTO tx VALUES('a b c', 'x y z');
+ CREATE VIRTUAL TABLE terms2 USING fts4aux(tx);
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test 2.1 -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ execsql "SELECT * FROM terms2"
+} -test {
+ faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 1 1 c 0 1 1 x * 1 1 x 1 1 1 y * 1 1 y 1 1 1 z * 1 1 z 1 1 1}}
+}
+
+do_faultsim_test 3.0 -faults oom* -prep {
+ faultsim_delete_and_reopen
+ db eval { CREATE TABLE 'xx yy'(a, b); }
+} -body {
+ execsql {
+ CREATE VIRTUAL TABLE tt USING fts4(content="xx yy");
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 3.1 -faults oom* -prep {
+ faultsim_delete_and_reopen
+ db func zip zip
+ db func unzip unzip
+} -body {
+ execsql {
+ CREATE VIRTUAL TABLE tt USING fts4(compress=zip, uncompress=unzip);
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_test 4.0 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE VIRTUAL TABLE ft USING fts4(a, b);
+ INSERT INTO ft VALUES('U U T C O', 'F N D E S');
+ INSERT INTO ft VALUES('P H X G B', 'I D M R U');
+ INSERT INTO ft VALUES('P P X D M', 'Y V N T C');
+ INSERT INTO ft VALUES('Z L Q O W', 'D F U N Q');
+ INSERT INTO ft VALUES('A J D U P', 'C H M Q E');
+ INSERT INTO ft VALUES('P S A O H', 'S Z C W D');
+ INSERT INTO ft VALUES('T B N L W', 'C A K T I');
+ INSERT INTO ft VALUES('K E Z L O', 'L L Y C E');
+ INSERT INTO ft VALUES('C R E S V', 'Q V F W P');
+ INSERT INTO ft VALUES('S K H G W', 'R W Q F G');
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test 4.1 -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ execsql { INSERT INTO ft(ft) VALUES('rebuild') }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
diff --git a/test/fts3first.test b/test/fts3first.test
new file mode 100644
index 0000000..673f818
--- /dev/null
+++ b/test/fts3first.test
@@ -0,0 +1,163 @@
+# 2011 October 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+set testprefix fts3first
+
+proc lreverse {L} {
+ set res [list]
+ for {set ii [expr [llength $L]-1]} {$ii>=0} {incr ii -1} {
+ lappend res [lindex $L $ii]
+ }
+ set res
+}
+
+proc mit {blob} {
+ set scan(littleEndian) i*
+ set scan(bigEndian) I*
+ binary scan $blob $scan($::tcl_platform(byteOrder)) r
+ return $r
+}
+db func mit mit
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE x1 USING FTS4(a, b, c);
+ INSERT INTO x1(docid,a,b,c) VALUES(0, 'K H D S T', 'V M N Y K', 'S Z N Q S');
+ INSERT INTO x1(docid,a,b,c) VALUES(1, 'K N J L W', 'S Z W J Q', 'D U W S E');
+ INSERT INTO x1(docid,a,b,c) VALUES(2, 'B P M O I', 'R P H W S', 'R J L L E');
+ INSERT INTO x1(docid,a,b,c) VALUES(3, 'U R Q M L', 'M J K A V', 'Q W J T J');
+ INSERT INTO x1(docid,a,b,c) VALUES(4, 'N J C Y N', 'R U D X V', 'B O U A Q');
+ INSERT INTO x1(docid,a,b,c) VALUES(5, 'Q L X L U', 'I F N X S', 'U Q A N Y');
+ INSERT INTO x1(docid,a,b,c) VALUES(6, 'M R G U T', 'U V I Q P', 'X Y D L S');
+ INSERT INTO x1(docid,a,b,c) VALUES(7, 'D Y P O I', 'X J P K R', 'V O T H V');
+ INSERT INTO x1(docid,a,b,c) VALUES(8, 'R Y D L R', 'U U E S J', 'N W L M R');
+ INSERT INTO x1(docid,a,b,c) VALUES(9, 'Z P F N P', 'W A X D U', 'V A E Q A');
+ INSERT INTO x1(docid,a,b,c) VALUES(10, 'Q I A Q M', 'N D K H C', 'A H T Q Z');
+ INSERT INTO x1(docid,a,b,c) VALUES(11, 'T E R Q B', 'C I B C B', 'F Z U W R');
+ INSERT INTO x1(docid,a,b,c) VALUES(12, 'E S V U W', 'T P F W H', 'A M D J Q');
+ INSERT INTO x1(docid,a,b,c) VALUES(13, 'X S B X Y', 'U D N D P', 'X Z Y G F');
+ INSERT INTO x1(docid,a,b,c) VALUES(14, 'K H A B L', 'S R C C Z', 'D W E H J');
+ INSERT INTO x1(docid,a,b,c) VALUES(15, 'C E U C C', 'W F M N M', 'T Z U X T');
+ INSERT INTO x1(docid,a,b,c) VALUES(16, 'Q G C G H', 'H N N B H', 'B Q I H Y');
+ INSERT INTO x1(docid,a,b,c) VALUES(17, 'Q T S K B', 'W B D Y N', 'V J P E C');
+ INSERT INTO x1(docid,a,b,c) VALUES(18, 'A J M O Q', 'L G Y Y A', 'G N M R N');
+ INSERT INTO x1(docid,a,b,c) VALUES(19, 'T R Y P Y', 'N V Y B X', 'L Z T N T');
+
+ CREATE VIRTUAL TABLE x2 USING FTS4(a, b, c, order=DESC);
+ INSERT INTO x2(docid, a, b, c) SELECT docid, a, b, c FROM x1;
+}
+
+
+# Test queries.
+#
+foreach x {1 2} {
+ foreach {tn match res} {
+ 1 "^K" {0 1 14}
+ 2 "^S" {0 1 14}
+ 3 "^W" {9 15 17}
+ 4 "^J" {}
+ 5 "^E" {12}
+ 6 "V ^-E" {0 3 4 6 7 9 17 19}
+ 7 "V -^E" {0 3 4 6 7 9 17 19}
+ 8 "^-E V" {0 3 4 6 7 9 17 19}
+ 9 "-^E V" {0 3 4 6 7 9 17 19}
+ 10 "V" {0 3 4 6 7 9 12 17 19}
+
+ 11 {"^K H"} {0 14}
+ 12 {"K H"} {0 10 14}
+ 13 {"K ^H"} {}
+ } {
+ set rev [lreverse $res]
+ do_execsql_test 1.$x.$tn.1 {SELECT docid FROM x1 WHERE x1 MATCH $match} $res
+ do_execsql_test 1.$x.$tn.2 {SELECT docid FROM x2 WHERE x2 MATCH $match} $rev
+ }
+
+ do_execsql_test 1.$x.[expr $tn+1] {
+ INSERT INTO x1(x1) VALUES('optimize');
+ INSERT INTO x2(x2) VALUES('optimize');
+ } {}
+}
+
+# Test the snippet() function.
+#
+foreach {tn match res} {
+ 1 {^K} {{[K] H D S T} {[K] N J L W} {[K] H A B L}}
+ 2 {^X} {{[X] Y D L S} {[X] J P K R} {[X] S B X Y}}
+ 3 {^X Y} {{[X] [Y] D L S} {D [Y] P O I...[X] J P K R} {[X] S B X [Y]}}
+} {
+ set rev [lreverse $res]
+
+ do_execsql_test 1.3.$tn.1 {
+ SELECT snippet(x1, '[', ']', '...') FROM x1 WHERE x1 MATCH $match
+ } $res
+
+ do_execsql_test 1.3.$tn.2 {
+ SELECT snippet(x2, '[', ']', '...') FROM x2 WHERE x2 MATCH $match
+ } $rev
+}
+
+# Test matchinfo().
+#
+foreach {tn match res} {
+ 1 {^K} {
+ {1 3 3 0 0 0 0 0 0}
+ {1 3 3 0 0 0 0 0 0}
+ {1 3 3 0 0 0 0 0 0}
+ }
+ 2 {^X} {
+ {0 1 1 0 1 1 1 2 2}
+ {0 1 1 1 1 1 0 2 2}
+ {1 1 1 0 1 1 1 2 2}
+ }
+ 3 {^X Y} {
+ {0 1 1 0 1 1 1 2 2 0 6 5 0 5 4 1 4 4}
+ {0 1 1 1 1 1 0 2 2 1 6 5 0 5 4 0 4 4}
+ {1 1 1 0 1 1 1 2 2 1 6 5 0 5 4 1 4 4}
+ }
+} {
+ set rev [lreverse $res]
+
+ do_execsql_test 1.3.$tn.1 {
+ SELECT mit(matchinfo(x1, 'x')) FROM x1 WHERE x1 MATCH $match
+ } $res
+ do_execsql_test 1.3.$tn.2 {
+ SELECT mit(matchinfo(x2, 'x')) FROM x2 WHERE x2 MATCH $match
+ } $rev
+}
+
+# Test that ^ is ignored for FTS3 tables.
+#
+do_execsql_test 2.1 {
+ CREATE VIRTUAL TABLE x3 USING fts3;
+ INSERT INTO x3 VALUES('A B C');
+ INSERT INTO x3 VALUES('B A C');
+
+ CREATE VIRTUAL TABLE x4 USING fts4;
+ INSERT INTO x4 VALUES('A B C');
+ INSERT INTO x4 VALUES('B A C');
+}
+
+do_execsql_test 2.2.1 {
+ SELECT * FROM x3 WHERE x3 MATCH '^A';
+} {{A B C} {B A C}}
+do_execsql_test 2.2.2 {
+ SELECT * FROM x4 WHERE x4 MATCH '^A';
+} {{A B C}}
+
+finish_test
diff --git a/test/fts3malloc.test b/test/fts3malloc.test
new file mode 100644
index 0000000..7eeee7f
--- /dev/null
+++ b/test/fts3malloc.test
@@ -0,0 +1,304 @@
+# 2009 October 22
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests to verify that malloc() errors that occur
+# within the FTS3 module code are handled correctly.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !fts3 { finish_test ; return }
+source $testdir/malloc_common.tcl
+source $testdir/fts3_common.tcl
+
+# Ensure the lookaside buffer is disabled for these tests.
+#
+sqlite3 db test.db
+sqlite3_db_config_lookaside db 0 0 0
+
+set sqlite_fts3_enable_parentheses 1
+set DO_MALLOC_TEST 1
+
+# Test organization:
+#
+# fts3_malloc-1.*: Test OOM during CREATE and DROP table statements.
+# fts3_malloc-2.*: Test OOM during SELECT operations.
+# fts3_malloc-3.*: Test OOM during SELECT operations with a larger database.
+# fts3_malloc-4.*: Test OOM during database write operations.
+# fts3_malloc-5.*: Test that a couple of memory leaks that could follow
+# OOM in tokenizer code have been fixed.
+#
+
+
+proc normal_list {l} {
+ set ret [list]
+ foreach elem $l {lappend ret $elem}
+ set ret
+}
+
+do_write_test fts3_malloc-1.1 sqlite_master {
+ CREATE VIRTUAL TABLE ft1 USING fts3(a, b)
+}
+do_write_test fts3_malloc-1.2 sqlite_master {
+ CREATE VIRTUAL TABLE ft2 USING fts3([a], [b]);
+}
+do_write_test fts3_malloc-1.3 sqlite_master {
+ CREATE VIRTUAL TABLE ft3 USING fts3('a', "b");
+}
+do_write_test fts3_malloc-1.4 sqlite_master {
+ CREATE VIRTUAL TABLE ft4 USING fts3(`a`, 'fred''s column');
+}
+do_error_test fts3_malloc-1.5 {
+ CREATE VIRTUAL TABLE ft5 USING fts3(a, b, tokenize unknown)
+} {unknown tokenizer: unknown}
+do_write_test fts3_malloc-1.6 sqlite_master {
+ CREATE VIRTUAL TABLE ft6 USING fts3(a, b, tokenize porter)
+}
+
+# Test the xConnect/xDisconnect methods:
+#db eval { ATTACH 'test2.db' AS aux }
+#do_write_test fts3_malloc-1.6 aux.sqlite_master {
+# CREATE VIRTUAL TABLE aux.ft7 USING fts3(a, b, c);
+#}
+#do_write_test fts3_malloc-1.6 aux.sqlite_master {
+# CREATE VIRTUAL TABLE aux.ft7 USING fts3(a, b, c);
+#}
+
+
+
+do_test fts3_malloc-2.0 {
+ execsql {
+ DROP TABLE ft1;
+ DROP TABLE ft2;
+ DROP TABLE ft3;
+ DROP TABLE ft4;
+ DROP TABLE ft6;
+ }
+ execsql { CREATE VIRTUAL TABLE ft USING fts3(a, b) }
+ for {set ii 1} {$ii < 32} {incr ii} {
+ set a [list]
+ set b [list]
+ if {$ii & 0x01} {lappend a one ; lappend b neung}
+ if {$ii & 0x02} {lappend a two ; lappend b song }
+ if {$ii & 0x04} {lappend a three ; lappend b sahm }
+ if {$ii & 0x08} {lappend a four ; lappend b see }
+ if {$ii & 0x10} {lappend a five ; lappend b hah }
+ execsql { INSERT INTO ft VALUES($a, $b) }
+ }
+} {}
+
+foreach {tn sql result} {
+ 1 "SELECT count(*) FROM sqlite_master" {5}
+ 2 "SELECT * FROM ft WHERE docid = 1" {one neung}
+ 3 "SELECT * FROM ft WHERE docid = 2" {two song}
+ 4 "SELECT * FROM ft WHERE docid = 3" {{one two} {neung song}}
+
+ 5 "SELECT a FROM ft" {
+ {one} {two} {one two}
+ {three} {one three} {two three}
+ {one two three} {four} {one four}
+ {two four} {one two four} {three four}
+ {one three four} {two three four} {one two three four}
+ {five} {one five} {two five}
+ {one two five} {three five} {one three five}
+ {two three five} {one two three five} {four five}
+ {one four five} {two four five} {one two four five}
+ {three four five} {one three four five} {two three four five}
+ {one two three four five}
+ }
+
+ 6 "SELECT a FROM ft WHERE a MATCH 'one'" {
+ {one} {one two} {one three} {one two three}
+ {one four} {one two four} {one three four} {one two three four}
+ {one five} {one two five} {one three five} {one two three five}
+ {one four five} {one two four five}
+ {one three four five} {one two three four five}
+ }
+
+ 7 "SELECT a FROM ft WHERE a MATCH 'o*'" {
+ {one} {one two} {one three} {one two three}
+ {one four} {one two four} {one three four} {one two three four}
+ {one five} {one two five} {one three five} {one two three five}
+ {one four five} {one two four five}
+ {one three four five} {one two three four five}
+ }
+
+ 8 "SELECT a FROM ft WHERE a MATCH 'o* t*'" {
+ {one two} {one three} {one two three}
+ {one two four} {one three four} {one two three four}
+ {one two five} {one three five} {one two three five}
+ {one two four five} {one three four five} {one two three four five}
+ }
+
+ 9 "SELECT a FROM ft WHERE a MATCH '\"o* t*\"'" {
+ {one two} {one three} {one two three}
+ {one two four} {one three four} {one two three four}
+ {one two five} {one three five} {one two three five}
+ {one two four five} {one three four five} {one two three four five}
+ }
+
+ 10 {SELECT a FROM ft WHERE a MATCH '"o* f*"'} {
+ {one four} {one five} {one four five}
+ }
+
+ 11 {SELECT a FROM ft WHERE a MATCH '"one two three"'} {
+ {one two three}
+ {one two three four}
+ {one two three five}
+ {one two three four five}
+ }
+
+ 12 {SELECT a FROM ft WHERE a MATCH '"two three four"'} {
+ {two three four}
+ {one two three four}
+ {two three four five}
+ {one two three four five}
+ }
+
+ 12 {SELECT a FROM ft WHERE a MATCH '"two three" five'} {
+ {two three five} {one two three five}
+ {two three four five} {one two three four five}
+ }
+
+ 13 {SELECT a FROM ft WHERE ft MATCH '"song sahm" hah'} {
+ {two three five} {one two three five}
+ {two three four five} {one two three four five}
+ }
+
+ 14 {SELECT a FROM ft WHERE b MATCH 'neung'} {
+ {one} {one two}
+ {one three} {one two three}
+ {one four} {one two four}
+ {one three four} {one two three four}
+ {one five} {one two five}
+ {one three five} {one two three five}
+ {one four five} {one two four five}
+ {one three four five} {one two three four five}
+ }
+
+ 15 {SELECT a FROM ft WHERE b MATCH '"neung song sahm"'} {
+ {one two three} {one two three four}
+ {one two three five} {one two three four five}
+ }
+
+ 16 {SELECT a FROM ft WHERE b MATCH 'hah "song sahm"'} {
+ {two three five} {one two three five}
+ {two three four five} {one two three four five}
+ }
+
+ 17 {SELECT a FROM ft WHERE b MATCH 'song OR sahm'} {
+ {two} {one two} {three}
+ {one three} {two three} {one two three}
+ {two four} {one two four} {three four}
+ {one three four} {two three four} {one two three four}
+ {two five} {one two five} {three five}
+ {one three five} {two three five} {one two three five}
+ {two four five} {one two four five} {three four five}
+ {one three four five} {two three four five} {one two three four five}
+ }
+
+ 18 {SELECT a FROM ft WHERE a MATCH 'three NOT two'} {
+ {three} {one three} {three four}
+ {one three four} {three five} {one three five}
+ {three four five} {one three four five}
+ }
+
+ 19 {SELECT a FROM ft WHERE b MATCH 'sahm NOT song'} {
+ {three} {one three} {three four}
+ {one three four} {three five} {one three five}
+ {three four five} {one three four five}
+ }
+
+ 20 {SELECT a FROM ft WHERE ft MATCH 'sahm NOT song'} {
+ {three} {one three} {three four}
+ {one three four} {three five} {one three five}
+ {three four five} {one three four five}
+ }
+
+ 21 {SELECT a FROM ft WHERE b MATCH 'neung NEAR song NEAR sahm'} {
+ {one two three} {one two three four}
+ {one two three five} {one two three four five}
+ }
+
+} {
+ set result [normal_list $result]
+ do_select_test fts3_malloc-2.$tn $sql $result
+}
+
+do_test fts3_malloc-3.0 {
+ execsql BEGIN
+ for {set ii 32} {$ii < 1024} {incr ii} {
+ set a [list]
+ set b [list]
+ if {$ii & 0x0001} {lappend a one ; lappend b neung }
+ if {$ii & 0x0002} {lappend a two ; lappend b song }
+ if {$ii & 0x0004} {lappend a three ; lappend b sahm }
+ if {$ii & 0x0008} {lappend a four ; lappend b see }
+ if {$ii & 0x0010} {lappend a five ; lappend b hah }
+ if {$ii & 0x0020} {lappend a six ; lappend b hok }
+ if {$ii & 0x0040} {lappend a seven ; lappend b jet }
+ if {$ii & 0x0080} {lappend a eight ; lappend b bairt }
+ if {$ii & 0x0100} {lappend a nine ; lappend b gow }
+ if {$ii & 0x0200} {lappend a ten ; lappend b sip }
+ execsql { INSERT INTO ft VALUES($a, $b) }
+ }
+ execsql COMMIT
+} {}
+foreach {tn sql result} {
+ 1 "SELECT count(*) FROM ft" {1023}
+
+ 2 "SELECT a FROM ft WHERE a MATCH 'one two three four five six seven eight'" {
+ {one two three four five six seven eight}
+ {one two three four five six seven eight nine}
+ {one two three four five six seven eight ten}
+ {one two three four five six seven eight nine ten}
+ }
+
+ 3 {SELECT count(*), sum(docid) FROM ft WHERE a MATCH 'o*'} {
+ 512 262144
+ }
+
+ 4 {SELECT count(*), sum(docid) FROM ft WHERE a MATCH '"two three four"'} {
+ 128 66368
+ }
+} {
+ set result [normal_list $result]
+ do_select_test fts3_malloc-3.$tn $sql $result
+}
+
+do_test fts3_malloc-4.0 {
+ execsql { DELETE FROM ft WHERE docid>=32 }
+} {}
+foreach {tn sql} {
+ 1 "DELETE FROM ft WHERE ft MATCH 'one'"
+ 2 "DELETE FROM ft WHERE ft MATCH 'three'"
+ 3 "DELETE FROM ft WHERE ft MATCH 'five'"
+} {
+ do_write_test fts3_malloc-4.1.$tn ft_content $sql
+}
+do_test fts3_malloc-4.2 {
+ execsql { SELECT a FROM ft }
+} {two four {two four}}
+
+do_write_test fts3_malloc-5.1 ft_content {
+ INSERT INTO ft VALUES('short alongertoken reallyquitealotlongerimeanit andthistokenisjustsolongthatonemightbeforgivenforimaginingthatitwasmerelyacontrivedexampleandnotarealtoken', 'cynics!')
+}
+do_test fts3_malloc-5.2 {
+ execsql { CREATE VIRTUAL TABLE ft8 USING fts3(x, tokenize porter) }
+} {}
+
+do_write_test fts3_malloc-5.3 ft_content {
+ INSERT INTO ft8 VALUES('short alongertoken reallyquitealotlongerimeanit andthistokenisjustsolongthatonemightbeforgivenforimaginingthatitwasmerelyacontrivedexampleandnotarealtoken')
+}
+
+
+finish_test
+
diff --git a/test/fts3matchinfo.test b/test/fts3matchinfo.test
new file mode 100644
index 0000000..0e88858
--- /dev/null
+++ b/test/fts3matchinfo.test
@@ -0,0 +1,408 @@
+# 2010 November 02
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for the FTS3 module. The focus
+# of this file is tables created with the "matchinfo=fts3" option.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 { finish_test ; return }
+
+set testprefix fts3matchinfo
+set sqlite_fts3_enable_parentheses 0
+
+proc mit {blob} {
+ set scan(littleEndian) i*
+ set scan(bigEndian) I*
+ binary scan $blob $scan($::tcl_platform(byteOrder)) r
+ return $r
+}
+db func mit mit
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING fts4(matchinfo=fts3);
+ SELECT name FROM sqlite_master WHERE type = 'table';
+} {t1 t1_content t1_segments t1_segdir t1_stat}
+
+do_execsql_test 1.1 {
+ INSERT INTO t1(content) VALUES('I wandered lonely as a cloud');
+ INSERT INTO t1(content) VALUES('That floats on high o''er vales and hills,');
+ INSERT INTO t1(content) VALUES('When all at once I saw a crowd,');
+ INSERT INTO t1(content) VALUES('A host, of golden daffodils,');
+ SELECT mit(matchinfo(t1)) FROM t1 WHERE t1 MATCH 'I';
+} {{1 1 1 2 2} {1 1 1 2 2}}
+
+# Now create an FTS4 table that does not specify matchinfo=fts3.
+#
+do_execsql_test 1.2 {
+ CREATE VIRTUAL TABLE t2 USING fts4;
+ INSERT INTO t2 SELECT * FROM t1;
+ SELECT mit(matchinfo(t2)) FROM t2 WHERE t2 MATCH 'I';
+} {{1 1 1 2 2} {1 1 1 2 2}}
+
+# Test some syntax-error handling.
+#
+do_catchsql_test 2.0 {
+ CREATE VIRTUAL TABLE x1 USING fts4(matchinfo=fs3);
+} {1 {unrecognized matchinfo: fs3}}
+do_catchsql_test 2.1 {
+ CREATE VIRTUAL TABLE x2 USING fts4(mtchinfo=fts3);
+} {1 {unrecognized parameter: mtchinfo=fts3}}
+do_catchsql_test 2.2 {
+ CREATE VIRTUAL TABLE x2 USING fts4(matchinfo=fts5);
+} {1 {unrecognized matchinfo: fts5}}
+
+# Check that with fts3, the "=" character is permitted in column definitions.
+#
+do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE t3 USING fts3(mtchinfo=fts3);
+ INSERT INTO t3(mtchinfo) VALUES('Beside the lake, beneath the trees');
+ SELECT mtchinfo FROM t3;
+} {{Beside the lake, beneath the trees}}
+
+do_execsql_test 3.2 {
+ CREATE VIRTUAL TABLE xx USING FTS4;
+}
+do_execsql_test 3.3 {
+ SELECT * FROM xx WHERE xx MATCH 'abc';
+}
+do_execsql_test 3.4 {
+ SELECT * FROM xx WHERE xx MATCH 'a b c';
+}
+
+
+#--------------------------------------------------------------------------
+# Proc [do_matchinfo_test] is used to test the FTSX matchinfo() function.
+#
+# The first argument - $tn - is a test identifier. This may be either a
+# full identifier (i.e. "fts3matchinfo-1.1") or, if global var $testprefix
+# is set, just the numeric component (i.e. "1.1").
+#
+# The second argument is the name of an FTSX table. The third is the
+# full text of a WHERE/MATCH expression to query the table for
+# (i.e. "t1 MATCH 'abc'"). The final argument - $results - should be a
+# key-value list (serialized array) with matchinfo() format specifiers
+# as keys, and the results of executing the statement:
+#
+# SELECT matchinfo($tbl, '$key') FROM $tbl WHERE $expr
+#
+# For example:
+#
+# CREATE VIRTUAL TABLE t1 USING fts4;
+# INSERT INTO t1 VALUES('abc');
+# INSERT INTO t1 VALUES('def');
+# INSERT INTO t1 VALUES('abc abc');
+#
+# do_matchinfo_test 1.1 t1 "t1 MATCH 'abc'" {
+# n {3 3}
+# p {1 1}
+# c {1 1}
+# x {{1 3 2} {2 3 2}}
+# }
+#
+# If the $results list contains keys mapped to "-" instead of a matchinfo()
+# result, then this command computes the expected results based on other
+# mappings to test the matchinfo() function. For example, the command above
+# could be changed to:
+#
+# do_matchinfo_test 1.1 t1 "t1 MATCH 'abc'" {
+# n {3 3} p {1 1} c {1 1} x {{1 3 2} {2 3 2}}
+# pcx -
+# }
+#
+# And this command would compute the expected results for matchinfo(t1, 'pcx')
+# based on the results of matchinfo(t1, 'p'), matchinfo(t1, 'c') and
+# matchinfo(t1, 'x') in order to test 'pcx'.
+#
+proc do_matchinfo_test {tn tbl expr results} {
+
+ foreach {fmt res} $results {
+ if {$res == "-"} continue
+ set resarray($fmt) $res
+ }
+
+ set nRow 0
+ foreach {fmt res} [array get resarray] {
+ if {[llength $res]>$nRow} { set nRow [llength $res] }
+ }
+
+ # Construct expected results for any formats for which the caller
+ # supplied result is "-".
+ #
+ foreach {fmt res} $results {
+ if {$res == "-"} {
+ set res [list]
+ for {set iRow 0} {$iRow<$nRow} {incr iRow} {
+ set rowres [list]
+ foreach c [split $fmt ""] {
+ set rowres [concat $rowres [lindex $resarray($c) $iRow]]
+ }
+ lappend res $rowres
+ }
+ set resarray($fmt) $res
+ }
+ }
+
+ # Test each matchinfo() request individually.
+ #
+ foreach {fmt res} [array get resarray] {
+ set sql "SELECT mit(matchinfo($tbl, '$fmt')) FROM $tbl WHERE $expr"
+ do_execsql_test $tn.$fmt $sql [normalize2 $res]
+ }
+
+ # Test them all executed together (multiple invocations of matchinfo()).
+ #
+ set exprlist [list]
+ foreach {format res} [array get resarray] {
+ lappend exprlist "mit(matchinfo($tbl, '$format'))"
+ }
+ set allres [list]
+ for {set iRow 0} {$iRow<$nRow} {incr iRow} {
+ foreach {format res} [array get resarray] {
+ lappend allres [lindex $res $iRow]
+ }
+ }
+ set sql "SELECT [join $exprlist ,] FROM $tbl WHERE $expr"
+ do_execsql_test $tn.multi $sql [normalize2 $allres]
+}
+proc normalize2 {list_of_lists} {
+ set res [list]
+ foreach elem $list_of_lists {
+ lappend res [list {*}$elem]
+ }
+ return $res
+}
+
+
+do_execsql_test 4.1.0 {
+ CREATE VIRTUAL TABLE t4 USING fts4(x, y);
+ INSERT INTO t4 VALUES('a b c d e', 'f g h i j');
+ INSERT INTO t4 VALUES('f g h i j', 'a b c d e');
+}
+
+do_matchinfo_test 4.1.1 t4 {t4 MATCH 'a b c'} {
+ p {3 3}
+ c {2 2}
+ x {
+ {1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1}
+ {0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1}
+ }
+ n {2 2}
+ l {{5 5} {5 5}}
+ a {{5 5} {5 5}}
+
+ s {{3 0} {0 3}}
+
+ xxxxxxxxxxxxxxxxxx - pcx - xpc - ccc - pppxpcpcx - laxnpc -
+ xpxsscplax -
+}
+
+do_matchinfo_test 4.1.2 t4 {t4 MATCH '"g h i"'} {
+ p {1 1}
+ c {2 2}
+ x {
+ {0 1 1 1 1 1}
+ {1 1 1 0 1 1}
+ }
+ n {2 2}
+ l {{5 5} {5 5}}
+ a {{5 5} {5 5}}
+
+ s {{0 1} {1 0}}
+
+ xxxxxxxxxxxxxxxxxx - pcx - xpc - ccc - pppxpcpcx - laxnpc -
+ sxsxs -
+}
+
+do_matchinfo_test 4.1.3 t4 {t4 MATCH 'a b'} { s {{2 0} {0 2}} }
+do_matchinfo_test 4.1.4 t4 {t4 MATCH '"a b" c'} { s {{2 0} {0 2}} }
+do_matchinfo_test 4.1.5 t4 {t4 MATCH 'a "b c"'} { s {{2 0} {0 2}} }
+do_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'} { s {{1 0} {0 1}} }
+do_matchinfo_test 4.1.7 t4 {t4 MATCH 'f OR abcd'} {
+ x {
+ {0 1 1 1 1 1 0 0 0 0 0 0}
+ {1 1 1 0 1 1 0 0 0 0 0 0}
+ }
+}
+do_matchinfo_test 4.1.8 t4 {t4 MATCH 'f -abcd'} {
+ x {
+ {0 1 1 1 1 1}
+ {1 1 1 0 1 1}
+ }
+}
+
+do_execsql_test 4.2.0 {
+ CREATE VIRTUAL TABLE t5 USING fts4;
+ INSERT INTO t5 VALUES('a a a a a');
+ INSERT INTO t5 VALUES('a b a b a');
+ INSERT INTO t5 VALUES('c b c b c');
+ INSERT INTO t5 VALUES('x x x x x');
+}
+do_matchinfo_test 4.2.1 t5 {t5 MATCH 'a a'} {
+ x {{5 8 2 5 8 2} {3 8 2 3 8 2}}
+ s {2 1}
+}
+do_matchinfo_test 4.2.2 t5 {t5 MATCH 'a b'} { s {2} }
+do_matchinfo_test 4.2.3 t5 {t5 MATCH 'a b a'} { s {3} }
+do_matchinfo_test 4.2.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
+do_matchinfo_test 4.2.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
+do_matchinfo_test 4.2.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1} }
+
+do_execsql_test 4.3.0 "INSERT INTO t5 VALUES('x y [string repeat {b } 50000]')";
+
+# It used to be that the second 'a' token would be deferred. That doesn't
+# work any longer.
+if 0 {
+ do_matchinfo_test 4.3.1 t5 {t5 MATCH 'a a'} {
+ x {{5 8 2 5 5 5} {3 8 2 3 5 5}}
+ s {2 1}
+ }
+}
+
+do_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'} { s {2} }
+do_matchinfo_test 4.3.3 t5 {t5 MATCH 'a b a'} { s {3} }
+do_matchinfo_test 4.3.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
+do_matchinfo_test 4.3.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
+do_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1 1} }
+
+do_execsql_test 4.4.0 {
+ INSERT INTO t5(t5) VALUES('optimize');
+ UPDATE t5_segments
+ SET block = zeroblob(length(block))
+ WHERE length(block)>10000;
+}
+
+do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} }
+do_matchinfo_test 4.4.1 t5 {t5 MATCH 'a a'} { s {2 1} }
+do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} }
+do_matchinfo_test 4.4.3 t5 {t5 MATCH 'a b a'} { s {3} }
+do_matchinfo_test 4.4.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
+do_matchinfo_test 4.4.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
+
+do_execsql_test 4.5.0 {
+ CREATE VIRTUAL TABLE t6 USING fts4(a, b, c);
+ INSERT INTO t6 VALUES('a', 'b', 'c');
+}
+do_matchinfo_test 4.5.1 t6 {t6 MATCH 'a b c'} { s {{1 1 1}} }
+
+
+#-------------------------------------------------------------------------
+# Check the following restrictions:
+#
+# + Matchinfo flags 'a', 'l' and 'n' can only be used with fts4, not fts3.
+# + Matchinfo flag 'l' cannot be used with matchinfo=fts3.
+#
+do_execsql_test 5.1 {
+ CREATE VIRTUAL TABLE t7 USING fts3(a, b);
+ INSERT INTO t7 VALUES('u v w', 'x y z');
+
+ CREATE VIRTUAL TABLE t8 USING fts4(a, b, matchinfo=fts3);
+ INSERT INTO t8 VALUES('u v w', 'x y z');
+}
+
+do_catchsql_test 5.2.1 {
+ SELECT matchinfo(t7, 'a') FROM t7 WHERE t7 MATCH 'x y'
+} {1 {unrecognized matchinfo request: a}}
+do_catchsql_test 5.2.2 {
+ SELECT matchinfo(t7, 'l') FROM t7 WHERE t7 MATCH 'x y'
+} {1 {unrecognized matchinfo request: l}}
+do_catchsql_test 5.2.3 {
+ SELECT matchinfo(t7, 'n') FROM t7 WHERE t7 MATCH 'x y'
+} {1 {unrecognized matchinfo request: n}}
+
+do_catchsql_test 5.3.1 {
+ SELECT matchinfo(t8, 'l') FROM t8 WHERE t8 MATCH 'x y'
+} {1 {unrecognized matchinfo request: l}}
+
+#-------------------------------------------------------------------------
+# Test that the offsets() function handles corruption in the %_content
+# table correctly.
+#
+do_execsql_test 6.1 {
+ CREATE VIRTUAL TABLE t9 USING fts4;
+ INSERT INTO t9 VALUES(
+ 'this record is used to try to dectect corruption'
+ );
+ SELECT offsets(t9) FROM t9 WHERE t9 MATCH 'to';
+} {{0 0 20 2 0 0 27 2}}
+
+do_catchsql_test 6.2 {
+ UPDATE t9_content SET c0content = 'this record is used to';
+ SELECT offsets(t9) FROM t9 WHERE t9 MATCH 'to';
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+# Test the outcome of matchinfo() when used within a query that does not
+# use the full-text index (i.e. lookup by rowid or full-table scan).
+#
+do_execsql_test 7.1 {
+ CREATE VIRTUAL TABLE t10 USING fts4;
+ INSERT INTO t10 VALUES('first record');
+ INSERT INTO t10 VALUES('second record');
+}
+do_execsql_test 7.2 {
+ SELECT typeof(matchinfo(t10)), length(matchinfo(t10)) FROM t10;
+} {blob 0 blob 0}
+do_execsql_test 7.3 {
+ SELECT typeof(matchinfo(t10)), length(matchinfo(t10)) FROM t10 WHERE docid=1;
+} {blob 0}
+do_execsql_test 7.4 {
+ SELECT typeof(matchinfo(t10)), length(matchinfo(t10))
+ FROM t10 WHERE t10 MATCH 'record'
+} {blob 20 blob 20}
+
+#-------------------------------------------------------------------------
+# Test a special case - matchinfo('nxa') with many zero length documents.
+# Special because "x" internally uses a statement used by both "n" and "a".
+# This was causing a problem at one point in the obscure case where the
+# total number of bytes of data stored in an fts3 table was greater than
+# the number of rows. i.e. when the following query returns true:
+#
+# SELECT sum(length(content)) < count(*) FROM fts4table;
+#
+do_execsql_test 8.1 {
+ CREATE VIRTUAL TABLE t11 USING fts4;
+ INSERT INTO t11(t11) VALUES('nodesize=24');
+ INSERT INTO t11 VALUES('quitealongstringoftext');
+ INSERT INTO t11 VALUES('anotherquitealongstringoftext');
+ INSERT INTO t11 VALUES('athirdlongstringoftext');
+ INSERT INTO t11 VALUES('andonemoreforgoodluck');
+}
+do_test 8.2 {
+ for {set i 0} {$i < 200} {incr i} {
+ execsql { INSERT INTO t11 VALUES('') }
+ }
+ execsql { INSERT INTO t11(t11) VALUES('optimize') }
+} {}
+do_execsql_test 8.3 {
+ SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'
+} {{204 1 3 3 0} {204 1 3 3 0} {204 1 3 3 0}}
+
+# Corruption related tests.
+do_execsql_test 8.4.1.1 { UPDATE t11_stat SET value = X'0000'; }
+do_catchsql_test 8.5.1.2 {
+ SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'
+} {1 {database disk image is malformed}}
+
+do_execsql_test 8.4.2.1 { UPDATE t11_stat SET value = X'00'; }
+do_catchsql_test 8.5.2.2 {
+ SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'
+} {1 {database disk image is malformed}}
+
+do_execsql_test 8.4.3.1 { UPDATE t11_stat SET value = NULL; }
+do_catchsql_test 8.5.3.2 {
+ SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'
+} {1 {database disk image is malformed}}
+
+finish_test
+
diff --git a/test/fts3near.test b/test/fts3near.test
new file mode 100644
index 0000000..9c4409e
--- /dev/null
+++ b/test/fts3near.test
@@ -0,0 +1,584 @@
+
+# 2007 October 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+#
+# $Id: fts3near.test,v 1.3 2009/01/02 17:33:46 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+db eval {
+ CREATE VIRTUAL TABLE t1 USING fts3(content);
+ INSERT INTO t1(content) VALUES('one three four five');
+ INSERT INTO t1(content) VALUES('two three four five');
+ INSERT INTO t1(content) VALUES('one two three four five');
+}
+
+do_test fts3near-1.1 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR/0 three'}
+} {1}
+do_test fts3near-1.2 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR/1 two'}
+} {3}
+do_test fts3near-1.3 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR/1 three'}
+} {1 3}
+do_test fts3near-1.4 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH 'three NEAR/1 one'}
+} {1 3}
+do_test fts3near-1.5 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH '"one two" NEAR/1 five'}
+} {}
+do_test fts3near-1.6 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH '"one two" NEAR/2 five'}
+} {3}
+do_test fts3near-1.7 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR four'}
+} {1 3}
+do_test fts3near-1.8 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH 'four NEAR three'}
+} {1 2 3}
+do_test fts3near-1.9 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH '"four five" NEAR/0 three'}
+} {1 2 3}
+do_test fts3near-1.10 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH '"four five" NEAR/2 one'}
+} {1 3}
+do_test fts3near-1.11 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH '"four five" NEAR/1 one'}
+} {1}
+do_test fts3near-1.12 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH 'five NEAR/1 "two three"'}
+} {2 3}
+do_test fts3near-1.13 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR five'}
+} {1 3}
+
+do_test fts3near-1.14 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH 'four NEAR four'}
+} {}
+do_test fts3near-1.15 {
+ execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR two NEAR one'}
+} {3}
+
+do_test fts3near-1.16 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH '"one three" NEAR/0 "four five"'
+ }
+} {1}
+do_test fts3near-1.17 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH '"four five" NEAR/0 "one three"'
+ }
+} {1}
+
+
+# Output format of the offsets() function:
+#
+# <column number> <term number> <starting offset> <number of bytes>
+#
+db eval {
+ INSERT INTO t1(content) VALUES('A X B C D A B');
+}
+do_test fts3near-2.1 {
+ execsql {
+ SELECT offsets(t1) FROM t1 WHERE content MATCH 'A NEAR/0 B'
+ }
+} {{0 0 10 1 0 1 12 1}}
+do_test fts3near-2.2 {
+ execsql {
+ SELECT offsets(t1) FROM t1 WHERE content MATCH 'B NEAR/0 A'
+ }
+} {{0 1 10 1 0 0 12 1}}
+do_test fts3near-2.3 {
+ execsql {
+ SELECT offsets(t1) FROM t1 WHERE content MATCH '"C D" NEAR/0 A'
+ }
+} {{0 0 6 1 0 1 8 1 0 2 10 1}}
+do_test fts3near-2.4 {
+ execsql {
+ SELECT offsets(t1) FROM t1 WHERE content MATCH 'A NEAR/0 "C D"'
+ }
+} {{0 1 6 1 0 2 8 1 0 0 10 1}}
+do_test fts3near-2.5 {
+ execsql {
+ SELECT offsets(t1) FROM t1 WHERE content MATCH 'A NEAR A'
+ }
+} {{0 0 0 1 0 1 0 1 0 0 10 1 0 1 10 1}}
+do_test fts3near-2.6 {
+ execsql {
+ INSERT INTO t1 VALUES('A A A');
+ SELECT offsets(t1) FROM t1 WHERE content MATCH 'A NEAR/2 A';
+ }
+} [list [list 0 0 0 1 0 1 0 1 0 0 2 1 0 1 2 1 0 0 4 1 0 1 4 1]]
+do_test fts3near-2.7 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('A A A A');
+ SELECT offsets(t1) FROM t1 WHERE content MATCH 'A NEAR A NEAR A';
+ }
+} [list [list \
+ 0 0 0 1 0 1 0 1 0 2 0 1 0 0 2 1 \
+ 0 1 2 1 0 2 2 1 0 0 4 1 0 1 4 1 \
+ 0 2 4 1 0 0 6 1 0 1 6 1 0 2 6 1 \
+]]
+
+db eval {
+ DELETE FROM t1;
+ INSERT INTO t1(content) VALUES(
+ 'one two three two four six three six nine four eight twelve'
+ );
+}
+
+do_test fts3near-3.1 {
+ execsql {SELECT offsets(t1) FROM t1 WHERE content MATCH 'three NEAR/1 one'}
+} {{0 1 0 3 0 0 8 5}}
+do_test fts3near-3.2 {
+ execsql {SELECT offsets(t1) FROM t1 WHERE content MATCH 'one NEAR/1 three'}
+} {{0 0 0 3 0 1 8 5}}
+do_test fts3near-3.3 {
+ execsql {SELECT offsets(t1) FROM t1 WHERE content MATCH 'three NEAR/1 two'}
+} {{0 1 4 3 0 0 8 5 0 1 14 3}}
+do_test fts3near-3.4 {
+ execsql {SELECT offsets(t1) FROM t1 WHERE content MATCH 'three NEAR/2 two'}
+} {{0 1 4 3 0 0 8 5 0 1 14 3 0 0 27 5}}
+do_test fts3near-3.5 {
+ execsql {SELECT offsets(t1) FROM t1 WHERE content MATCH 'two NEAR/2 three'}
+} {{0 0 4 3 0 1 8 5 0 0 14 3 0 1 27 5}}
+do_test fts3near-3.6 {
+ execsql {
+ SELECT offsets(t1) FROM t1 WHERE content MATCH 'three NEAR/0 "two four"'
+ }
+} {{0 0 8 5 0 1 14 3 0 2 18 4}}
+breakpoint
+do_test fts3near-3.7 {
+ execsql {
+ SELECT offsets(t1) FROM t1 WHERE content MATCH '"two four" NEAR/0 three'}
+} {{0 2 8 5 0 0 14 3 0 1 18 4}}
+
+db eval {
+ INSERT INTO t1(content) VALUES('
+ This specification defines Cascading Style Sheets, level 2 (CSS2). CSS2 is a style sheet language that allows authors and users to attach style (e.g., fonts, spacing, and aural cues) to structured documents (e.g., HTML documents and XML applications). By separating the presentation style of documents from the content of documents, CSS2 simplifies Web authoring and site maintenance.
+
+ CSS2 builds on CSS1 (see [CSS1]) and, with very few exceptions, all valid CSS1 style sheets are valid CSS2 style sheets. CSS2 supports media-specific style sheets so that authors may tailor the presentation of their documents to visual browsers, aural devices, printers, braille devices, handheld devices, etc. This specification also supports content positioning, downloadable fonts, table layout, features for internationalization, automatic counters and numbering, and some properties related to user interface.
+ ')
+}
+do_test fts3near-4.1 {
+ execsql {
+ SELECT snippet(t1) FROM t1 WHERE content MATCH 'specification NEAR supports'
+ }
+} {{<b>...</b>braille devices, handheld devices, etc. This <b>specification</b> also <b>supports</b> content positioning, downloadable fonts, table layout<b>...</b>}}
+
+do_test fts3near-5.1 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'specification attach'
+ }
+} {2}
+do_test fts3near-5.2 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'specification NEAR attach'
+ }
+} {}
+do_test fts3near-5.3 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'specification NEAR/18 attach'
+ }
+} {}
+do_test fts3near-5.4 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'specification NEAR/19 attach'
+ }
+} {2}
+do_test fts3near-5.5 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'specification NEAR/000018 attach'
+ }
+} {}
+do_test fts3near-5.6 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'specification NEAR/000019 attach'
+ }
+} {2}
+
+db eval {
+ INSERT INTO t1 VALUES('
+ abbrev aberrations abjurations aboding abr abscesses absolutistic
+ abstention abuses acanthuses acceptance acclaimers accomplish
+ accoutring accusation acetonic acid acolytes acquitting acrylonitrile
+ actives acyclic addicted adenoid adjacently adjusting admissible
+ adoption adulated advantaging advertisers aedes aerogramme aetiology
+ affiliative afforest afterclap agamogenesis aggrade agings agonize
+ agron ailurophile airfreight airspeed alarmists alchemizing
+ alexandrines alien aliped all allergenic allocator allowances almost
+ alphabetizes altho alvine amaurosis ambles ameliorate amicability amnio
+ amour ampicillin amusement anadromous analogues anarchy anchormen
+ anecdota aneurin angst animating anlage announcements anodized
+ answerable antemeridian anthracene antiabortionist anticlimaxes
+ antifriction antimitotic antiphon antiques antithetic anviled
+ apatosaurus aphrodisia apodal aposiopesis apparatus appendectomies
+ applications appraisingly appropriate apteryx arabinose
+ arboricultural archdeaconates archipelago ardently arguers armadillo
+ arnicas arrayed arrowy arthroscope artisans ascensive ashier
+ aspersorium assail assentor assignees assonants astereognosis
+ astringency astutest atheistical atomize attachment attenuates
+ attrahent audibility augite auricle auteurists autobus autolysis
+ autosome avenge avidest aw awl ayes babirusa backbeats backgrounder
+ backseat backswings baddie bagnios baked balefuller ballista balmily
+ bandbox bandylegged bankruptcy baptism barbering bargain barneys
+ barracuda barterer bashes bassists bathers batterer bavardage
+ beachfront beanstalk beauteous become bedim bedtimes beermats begat
+ begun belabors bellarmine belongings bending benthos bereavements
+ besieger bestialized betide bevels biases bicarbonates bidentate bigger
+ bile billow bine biodynamics biomedicine biotites birding bisection
+ bitingly bkg blackheads blaeberry blanking blatherer bleeper blindage
+ blithefulness blockish bloodstreams bloused blubbing bluestocking
+ blurted boatbill bobtailed boffo bold boltrope bondservant bonks
+ bookbinding bookworm booting borating boscages botchers bougainvillea
+ bounty bowlegged boyhood bracketed brainstorm brandishes
+ braunschweigers brazilin breakneck breathlessness brewage bridesmaids
+ brighter brisker broader brokerages bronziest browband brunets bryology
+ bucking budlike bugleweed bulkily bulling bummer bunglers bureau burgs
+ burrito bushfire buss butlery buttressing bylines cabdriver cached
+ cadaverousnesses cafeterias cakewalk calcifies calendula callboy calms
+ calyptra camisoles camps candelabrum caned cannolis canoodling cantors
+ cape caponize capsuling caracoled carbolics carcase carditis caretakers
+ carnallite carousel carrageenan cartels carves cashbook castanets
+ casuistry catalyzer catchers categorizations cathexis caucuses
+ causeway cavetto cede cella cementite centenary centrals ceramics ceria
+ cervixes chafferer chalcopyrites chamfers change chaotically
+ characteristically charivari chases chatterer cheats cheeks chef
+ chemurgy chetah chickaree chigoes chillies chinning chirp chive
+ chloroforms chokebore choplogic chorioids chromatic chronically
+ chubbiest chunder chutzpah cimetidine cinque circulated circumscribe
+ cirrose citrin claddagh clamorousness clapperboards classicalism
+ clauses cleanse clemency clicker clinchers cliquiest clods closeting
+ cloudscape clucking cnidarian coalfish coatrack coca cockfights coddled
+ coeducation coexistence cognitively coiffed colatitude collage
+ collections collinear colonelcy colorimetric columelliform combos
+ comforters commence commercialist commit commorancy communized compar
+ compendiously complainers compliance composition comprised comradery
+ concelebrants concerted conciliation concourses condensate
+ condonations confab confessionals confirmed conforming congeal
+ congregant conjectured conjurers connoisseurs conscripting
+ conservator consolable conspired constricting consuls contagious
+ contemporaneity contesters continuities contractors contrarian
+ contrive convalescents convents convexly convulsed cooncan coparcenary
+ coprolite copyreader cordially corklike cornflour coroner corralling
+ corrigible corsages cosies cosmonauts costumer cottontails counselings
+ counterclaim counterpane countertenors courageously couth coveting
+ coworker cozier cracklings crampon crappies craved cream credenzas
+ crematoriums cresol cricoid crinkle criterion crocodile crore crossover
+ crowded cruelest crunch cruzeiros cryptomeria cubism cuesta culprit
+ cumquat cupped curdle curly cursoring curvy customized cutting cyclamens
+ cylindrical cytaster dachshund daikon damages damselfly dangling
+ darkest databanks dauphine dazzling deadpanned deathday debauchers
+ debunking decameter decedents decibel decisions declinations
+ decomposition decoratively decretive deduct deescalated defecating
+ deferentially definiendum defluxion defrocks degrade deice dekaliters
+ deli delinquencies deludedly demarcates demineralizers demodulating
+ demonstrabilities demurred deniabilities denouncement denudation
+ departure deplorable deposing depredatory deputizes derivational
+ desalinization descriptors desexes desisted despising destitute
+ detectability determiner detoxifying devalued devilries devotions
+ dextrous diagenesis dialling diaphoresis diazonium dickeys diddums
+ differencing dig dignified dildo dimetric dineric dinosaurs diplodocus
+ directer dirty disagrees disassembler disburses disclosures
+ disconcerts discountability discrete disembarrass disenthrone
+ disgruntled dishpans disintegrators dislodged disobedient
+ dispassionate dispiritednesses dispraised disqualifying
+ dissatisfying dissidence dissolvers distich distracting distrusts
+ ditto diverse divineness dizzily dockyard dodgers doggish doited dom
+ dominium doohickey doozie dorsum doubleheaders dourer downbeats
+ downshifted doyennes draftsman dramatic drawling dredge drifter
+ drivelines droopier drowsed drunkards dubiosities duding dulcifying
+ dumpcart duodecillion durable duteous dyed dysgenic eagles earplugs
+ earwitness ebonite echoers economical ectothermous edibility educates
+ effected effigies eggbeaters egresses ejaculates elasticize elector
+ electrodynamometer electrophorus elem eligibly eloped emaciating
+ embarcaderos embezzlers embosses embryectomy emfs emotionalizing
+ empiricist emu enamels enchained encoded encrusts endeavored endogamous
+ endothelioma energizes engager engrosses enl enologist enrolls ensphere
+ enters entirety entrap entryways envies eosinophil epicentral
+ epigrammatized episodic epochs equestrian equitably erect ernes
+ errorless escalated eschatology espaliers essonite estop eternity
+ ethnologically eudemonics euphonious euthenist evangelizations
+ eventuality evilest evulsion examinee exceptionably exciter
+ excremental execrably exemplars exhalant exhorter exocrine exothermic
+ expected expends explainable exploratory expostulatory expunges
+ extends externals extorts extrapolative extrorse eyebolt eyra
+ facetiously factor faeries fairings fallacies falsities fancifulness
+ fantasticalness farmhouse fascinate fatalistically fattener fave
+ fearlessly featly federates feints fellowman fencers ferny
+ fertilenesses feta feudality fibers fictionalize fiefs fightback
+ filefish filmier finaglers fingerboards finochio firefly firmament
+ fishmeal fitted fjords flagitiousnesses flamen flaps flatfooting
+ flauntier fleapit fleshes flickertail flints floaty floorboards
+ floristic flow fluffily fluorescein flutes flyspecks foetal folderols
+ followable foolhardier footlockers foppish forceless foredo foreknows
+ foreseeing foretaste forgather forlorn formidableness fortalice
+ forwarding founding foxhunting fragmentarily frangipani fray freeform
+ freezable freshening fridges frilliest frizzed frontbench frottages
+ fruitcake fryable fugleman fulminated functionalists fungoid furfuran
+ furtive fussy fwd gadolinium galabias gallinaceous galvanism gamers
+ gangland gaoling garganey garrisoning gasp gate gauger gayety geed
+ geminately generalissimos genii gentled geochronology geomorphic
+ geriatricians gesellschaft ghat gibbeting giggles gimps girdlers
+ glabella glaive glassfuls gleefully glistered globetrotted glorifier
+ gloving glutathione glyptodont goaled gobsmacked goggliest golliwog
+ goobers gooseberries gormandizer gouramis grabbier gradually grampuses
+ grandmothers granulated graptolite gratuitously gravitates greaten
+ greenmailer greys grills grippers groan gropingly grounding groveling
+ grueled grunter guardroom guggle guineas gummed gunnysacks gushingly
+ gutturals gynecoid gyrostabilizer habitudes haemophilia hailer hairs
+ halest hallow halters hamsters handhelds handsaw hangup haranguer
+ hardheartedness harlotry harps hashing hated hauntingly hayrack
+ headcases headphone headword heartbreakers heaters hebephrenia
+ hedonist heightening heliozoan helots hemelytron hemorrhagic hent
+ herbicides hereunto heroines heteroclitics heterotrophs hexers
+ hidebound hies hightails hindmost hippopotomonstrosesquipedalian
+ histologist hittable hobbledehoys hogans holdings holocrine homegirls
+ homesteader homogeneousness homopolar honeys hoodwinks hoovered
+ horizontally horridness horseshoers hospitalization hotdogging houri
+ housemate howitzers huffier humanist humid humors huntress husbandmen
+ hyaenas hydride hydrokinetics hydroponically hygrothermograph
+ hyperbolically hypersensitiveness hypnogogic hypodermically
+ hypothermia iatrochemistry ichthyological idealist ideograms idling
+ igniting illegal illuminatingly ilmenite imbibing immateriality
+ immigrating immortalizes immures imparts impeder imperfection
+ impersonated implant implying imposition imprecating imprimis
+ improvising impv inanenesses inaugurate incapably incentivize
+ incineration incloses incomparableness inconsequential incorporate
+ incrementing incumbered indecorous indentation indicative indignities
+ indistinguishably indoors indulges ineducation inerrable
+ inexperienced infants infestations infirmnesses inflicting
+ infracostal ingathered ingressions inheritances iniquity
+ injuriousnesses innervated inoculates inquisitionist insectile
+ insiders insolate inspirers instatement instr insulates intactness
+ intellects intensifies intercalations intercontinental interferon
+ interlarded intermarrying internalizing interpersonally
+ interrelatednesses intersperse interviewees intolerance
+ intransigents introducing intubates invades inventing inveterate
+ invocate iodides irenicism ironsmith irreducibly irresistibility
+ irriguous isobarisms isometrically issuable itineracies jackdaws
+ jaggery jangling javelins jeeringly jeremiad jeweler jigsawing jitter
+ jocosity jokester jot jowls judicative juicy jungly jurists juxtaposed
+ kalpa karstify keddah kendo kermesses keynote kibbutznik kidnaper
+ kilogram kindred kingpins kissers klatch kneads knobbed knowingest
+ kookaburras kruller labefaction labyrinths lacquer laddered lagoons
+ lambency laminates lancinate landscapist lankiness lapse larked lasso
+ laterite laudableness laundrywomen lawgiver laypersons leafhoppers
+ leapfrogs leaven leeches legated legislature leitmotifs lenients
+ leprous letterheads levelling lexicographically liberalists
+ librettist licorice lifesaving lightheadedly likelier limekiln limped
+ lines linkers lipoma liquidator listeners litharge litmus
+ liverishnesses loamier lobeline locative locutionary loggier loiterer
+ longevity loomed loping lotion louts lowboys luaus lucrativeness lulus
+ lumpier lungi lush luthern lymphangial lythraceous machinists maculate
+ maggot magnetochemistry maharani maimers majored malaprops malignants
+ maloti mammary manchineel manfully manicotti manipulativenesses
+ mansards manufactories maraschino margin markdown marooning marshland
+ mascaraing massaging masticate matchmark matings mattes mausoleum
+ mayflies mealworm meataxe medevaced medievalist meetings megavitamin
+ melded melodramatic memorableness mendaciousnesses mensurable
+ mercenaries mere meronymous mesmerizes mestee metallurgical
+ metastasize meterages meticulosity mewed microbe microcrystalline
+ micromanager microsporophyll midiron miffed milder militiamen
+ millesimal milometer mincing mingily minims minstrelsy mires
+ misanthropic miscalculate miscomprehended misdefines misery mishears
+ misled mispickel misrepresent misspending mistranslate miswriting
+ mixologists mobilizers moderators modulate mojo mollies momentum monde
+ monied monocles monographs monophyletic monotonousness moocher
+ moorages morality morion mortally moseyed motherly motorboat mouldering
+ mousers moveables mucky mudslides mulatto multicellularity
+ multipartite multivalences mundanities murkiest mushed muskiness
+ mutability mutisms mycelia myosotis mythicist nacred namable napkin
+ narghile nastiness nattering nauseations nearliest necessitate
+ necrophobia neg negotiators neologizes nephrotomy netiquette
+ neurophysiology newbie newspaper niccolite nielsbohriums nightlong
+ nincompoops nitpicked nix noddling nomadize nonadhesive noncandidates
+ nonconducting nondigestible nones nongreasy nonjoinder nonoccurrence
+ nonporousness nonrestrictive nonstaining nonuniform nooses northwards
+ nostalgic notepaper nourishment noyades nuclides numberless numskulls
+ nutmegged nymphaea oatmeal obis objurgators oblivious obsequiousness
+ obsoletism obtruding occlusions ocher octettes odeums offcuts
+ officiation ogival oilstone olestras omikron oncogenesis onsetting
+ oomphs openly ophthalmoscope opposites optimum orangutans
+ orchestrations ordn organophosphates origin ornithosis orthognathous
+ oscillatory ossuaries ostracized ounce outbreaks outearning outgrows
+ outlived outpoints outrunning outspends outwearing overabound
+ overbalance overcautious overcrowds overdubbing overexpanding
+ overgraze overindustrialize overlearning overoptimism overproducing
+ overripe overshadowing overspreading overstuff overtones overwind ow
+ oxidizing pacer packs paganish painstakingly palate palette pally
+ palsying pandemic panhandled pantheism papaws papped parading
+ parallelize paranoia parasitically pardners parietal parodied pars
+ participator partridgeberry passerines password pastors
+ paterfamiliases patination patrolman paunch pawnshops peacekeeper
+ peatbog peculator pedestrianism peduncles pegboard pellucidnesses
+ pendency penitentiary penstock pentylenetetrazol peptidase perched
+ perennial performing perigynous peripheralize perjurer permissively
+ perpetuals persistency perspicuously perturbingly pesky petcock
+ petrologists pfennige pharmacies phenformin philanderers
+ philosophically phonecards phosgenes photocomposer photogenic photons
+ phototype phylloid physiotherapeutics picadores pickup pieces pigging
+ pilaster pillion pimples pinioned pinpricks pipers pirogi pit
+ pitifullest pizza placental plainly planing plasmin platforming
+ playacts playwrights plectra pleurisy plopped plug plumule plussed
+ poaches poetasters pointless polarize policyholder polkaed
+ polyadelphous polygraphing polyphonous pomace ponderers pooch poplar
+ porcelains portableness portly positioning postage posthumously
+ postponed potages potholed poulard powdering practised pranksters
+ preadapt preassigning precentors precipitous preconditions predefined
+ predictors preengage prefers prehumans premedical prenotification
+ preplanning prepuberty presbytery presentation presidia prestissimo
+ preterites prevailer prewarmed priding primitively principalships
+ prisage privileged probed prochurch proctoscope products proficients
+ prognathism prohibiting proletarianisms prominence promulgates
+ proofreading property proportions prorate proselytize prosthesis
+ proteins prototypic provenances provitamin prudish pseudonymities
+ psychoanalysts psychoneuroses psychrometer publishable pufferies
+ pullet pulses punchy punkins purchased purities pursers pushover
+ putridity pylons pyrogenous pzazz quadricepses quaff qualmish quarriers
+ quasilinear queerness questionnaires quieten quintals quislings quoits
+ rabidness racketeers radiative radioisotope radiotherapists ragingly
+ rainband rakishness rampagers rands raped rare raspy ratiocinator
+ rattlebrain ravening razz reactivation readoption realm reapportioning
+ reasoning reattempts rebidding rebuts recapitulatory receptiveness
+ recipes reckonings recognizee recommendatory reconciled reconnoiters
+ recontaminated recoupments recruits recumbently redact redefine
+ redheaded redistributable redraw redwing reeled reenlistment reexports
+ refiles reflate reflowing refortified refried refuses regelate
+ registrant regretting rehabilitative reigning reinduced reinstalled
+ reinvesting rejoining relations relegates religiosities reluctivity
+ remastered reminisce remodifying remounted rends renovate reordered
+ repartee repel rephrase replicate repossessing reprint reprogramed
+ repugnantly requiter rescheduling resegregate resettled residually
+ resold resourcefulness respondent restating restrainedly resubmission
+ resurveyed retaliating retiarius retorsion retreated retrofitting
+ returning revanchism reverberated reverted revitalization
+ revolutionize rewind rhapsodizing rhizogenic rhythms ricketinesses
+ ridicule righteous rilles rinks rippliest ritualize riyals roast rockery
+ roguish romanizations rookiest roquelaure rotation rotundity rounder
+ routinizing rubberize rubricated ruefully ruining rummaged runic
+ russets ruttish sackers sacrosanctly safeguarding said salaciousness
+ salinity salsas salutatorians sampan sandbag saned santonin
+ saprophagous sarnies satem saturant savaged sawbucks scablike scalp
+ scant scared scatter schedulers schizophrenics schnauzers schoolmarms
+ scintillae scleroses scoped scotched scram scratchiness screwball
+ scripting scrubwomen scrutinizing scumbled scuttled seals seasickness
+ seccos secretions secularizing seditiousnesses seeking segregators
+ seize selfish semeiology seminarian semitropical sensate sensors
+ sentimo septicemic sequentially serener serine serums
+ sesquicentennials seventeen sexiest sforzandos shadowing shallot
+ shampooing sharking shearer sheered shelters shifter shiner shipper
+ shitted shoaled shofroth shorebirds shortsightedly showboated shrank
+ shrines shucking shuttlecocks sickeningly sideling sidewise sigil
+ signifiers siliceous silty simony simulative singled sinkings sirrah
+ situps skateboarder sketchpad skim skirmished skulkers skywalk slander
+ slating sleaziest sleepyheads slicking slink slitting slot slub
+ slumlords smallest smattered smilier smokers smriti snailfish snatch
+ snides snitching snooze snowblowers snub soapboxing socialite sockeyes
+ softest sold solicitings solleret sombreros somnolencies sons sopor
+ sorites soubrette soupspoon southpaw spaces spandex sparkers spatially
+ speccing specking spectroscopists speedsters spermatics sphincter
+ spiffied spindlings spirals spitball splayfeet splitter spokeswomen
+ spooled sportily spousals sprightliness sprogs spurner squalene
+ squattered squelches squirms stablish staggerings stalactitic stamp
+ stands starflower starwort stations stayed steamroll steeplebush
+ stemmatics stepfathers stereos steroid sticks stillage stinker
+ stirringly stockpiling stomaching stopcock stormers strabismuses
+ strainer strappado strawberries streetwise striae strikeouts strives
+ stroppiest stubbed study stunting style suavity subchloride subdeb
+ subfields subjoin sublittoral subnotebooks subprograms subside
+ substantial subtenants subtreasuries succeeding sucked sufferers
+ sugarier sulfaguanidine sulphating summerhouse sunbonnets sunned
+ superagency supercontinent superheroes supernatural superscribing
+ superthin supplest suppositive surcease surfs surprise survey
+ suspiration svelte swamplands swashes sweatshop swellhead swindling
+ switching sworn syllabuses sympathetics synchrocyclotron syndic
+ synonymously syringed tablatures tabulation tackling taiga takas talker
+ tamarisks tangential tans taproom tarpapers taskmaster tattiest
+ tautologically taxied teacup tearjerkers technocracies teepee
+ telegenic telephony telexed temperaments temptress tenderizing tensed
+ tenuring tergal terned terror testatrices tetherball textile thatched
+ their theorem thereof thermometers thewy thimerosal thirsty
+ thoroughwort threateningly thrived through thumbnails thwacks
+ ticketing tie til timekeepers timorousness tinkers tippers tisane
+ titrating toastmaster toff toking tomb tongs toolmakings topes topple
+ torose tortilla totalizing touchlines tousling townsmen trachea
+ tradeable tragedienne traitorous trances transcendentalists
+ transferrable tranship translating transmogrifying transportable
+ transvestism traumatize treachery treed trenail tressing tribeswoman
+ trichromatism triennials trikes trims triplicate tristich trivializes
+ trombonist trots trouts trued trunnion tryster tubes tulle tundras turban
+ turgescence turnround tutelar tweedinesses twill twit tympanum typists
+ tzarists ulcered ultramodern umbles unaccountability unamended
+ unassertivenesses unbanned unblocked unbundled uncertified unclaimed
+ uncoated unconcerns unconvinced uncrossing undefined underbodice
+ underemphasize undergrowth underpayment undershirts understudy
+ underwritten undissolved unearthed unentered unexpended unfeeling
+ unforeseen unfussy unhair unhinges unifilar unimproved uninvitingly
+ universalization unknowns unlimbering unman unmet unnaturalness
+ unornament unperturbed unprecedentedly unproportionate unread
+ unreflecting unreproducible unripe unsatisfying unseaworthiness
+ unsharable unsociable unstacking unsubtly untactfully untied untruest
+ unveils unwilled unyokes upheave upraised upstart upwind urethrae
+ urtexts usurers uvula vacillators vailed validation valvule vanities
+ varia variously vassaled vav veggies velours venerator ventrals
+ verbalizes verification vernacularized verticality vestigially via
+ vicariously victoriousness viewpoint villainies vines violoncellist
+ virtual viscus vital vitrify viviparous vocalizers voidable volleys
+ volutes vouches vulcanology wackos waggery wainwrights waling wallowing
+ wanking wardroom warmup wartiest washwoman watchman watermarks waverer
+ wayzgoose weariest weatherstripped weediness weevil welcomed
+ wentletrap whackers wheatworm whelp whf whinged whirl whistles whithers
+ wholesomeness whosoever widows wikiup willowier windburned windsail
+ wingspread winterkilled wisecracking witchgrass witling wobbliest
+ womanliness woodcut woodworking woozy working worldwide worthiest
+ wrappings wretched writhe wynd xylophone yardarm yea yelped yippee yoni
+ yuks zealotry zigzagger zitherists zoologists zygosis');
+}
+
+do_test fts3near-6.1 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'abbrev zygosis'
+ }
+} {3}
+do_test fts3near-6.2 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'abbrev NEAR zygosis'
+ }
+} {}
+do_test fts3near-6.3 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'abbrev NEAR/100 zygosis'
+ }
+} {}
+do_test fts3near-6.4 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'abbrev NEAR/1000 zygosis'
+ }
+} {}
+do_test fts3near-6.5 {
+ execsql {
+ SELECT docid FROM t1 WHERE content MATCH 'abbrev NEAR/10000 zygosis'
+ }
+} {3}
+
+
+finish_test
diff --git a/test/fts3prefix.test b/test/fts3prefix.test
new file mode 100644
index 0000000..e7c197d
--- /dev/null
+++ b/test/fts3prefix.test
@@ -0,0 +1,213 @@
+# 2011 May 04
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts3prefix
+
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# This proc tests that the prefixes index appears to represent the same content
+# as the terms index.
+#
+proc fts3_terms_and_prefixes {db tbl prefixlengths} {
+
+ set iIndex 0
+ foreach len $prefixlengths {
+ incr iIndex
+ $db eval {
+ DROP TABLE IF EXISTS fts3check1;
+ DROP TABLE IF EXISTS fts3check2;
+ }
+ $db eval "CREATE VIRTUAL TABLE fts3check1 USING fts4term($tbl, 0);"
+ $db eval "CREATE VIRTUAL TABLE fts3check2 USING fts4term($tbl, $iIndex);"
+
+ $db eval {
+ DROP TABLE IF EXISTS temp.terms;
+ DROP TABLE IF EXISTS temp.prefixes;
+ CREATE TEMP TABLE terms AS SELECT * FROM fts3check1;
+ CREATE TEMP TABLE prefixes AS SELECT * FROM fts3check2;
+ CREATE INDEX temp.idx ON prefixes(term);
+ DROP TABLE fts3check1;
+ DROP TABLE fts3check2;
+ }
+
+ set nExpect 0
+ $db eval { SELECT term, docid, col, pos FROM temp.terms } a {
+ if {[string length $a(term)]<$len} continue
+ incr nExpect
+ set prefix [string range $a(term) 0 [expr $len-1]]
+ set r [$db one {
+ SELECT count(*) FROM temp.prefixes WHERE
+ term = $prefix AND docid = $a(docid) AND col = $a(col) AND pos = $a(pos)
+ }]
+ if {$r != 1} {
+ error "$t, $a(docid), $a(col), $a(pos)"
+ }
+ }
+
+ set nCount [$db one {SELECT count(*) FROM temp.prefixes}]
+ if {$nCount != $nExpect} {
+ error "prefixes.count(*) is $nCount expected $nExpect"
+ }
+
+ execsql { DROP TABLE temp.prefixes }
+ execsql { DROP TABLE temp.terms }
+
+ set list [list]
+ $db eval "
+ SELECT sum( 1 << (16*(level%1024)) ) AS total, (level/1024) AS tree
+ FROM ${tbl}_segdir GROUP BY tree
+ " {
+ lappend list [list $total $tree]
+ }
+
+ if { [lsort -integer -index 0 $list] != [lsort -integer -index 1 $list] } {
+ error "inconsistent tree structures: $list"
+ }
+ }
+
+ return ""
+}
+proc fts3_tap_test {tn db tbl lens} {
+ uplevel [list do_test $tn [list fts3_terms_and_prefixes $db $tbl $lens] ""]
+}
+
+#-------------------------------------------------------------------------
+# Test cases 1.* are a sanity check. They test that the prefixes index is
+# being constructed correctly for the simplest possible case.
+#
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(prefix='1,3,6');
+
+ CREATE VIRTUAL TABLE p1 USING fts4term(t1, 1);
+ CREATE VIRTUAL TABLE p2 USING fts4term(t1, 2);
+ CREATE VIRTUAL TABLE p3 USING fts4term(t1, 3);
+ CREATE VIRTUAL TABLE terms USING fts4term(t1);
+}
+do_execsql_test 1.2 {
+ INSERT INTO t1 VALUES('sqlite mysql firebird');
+}
+do_execsql_test 1.3.1 { SELECT term FROM p1 } {f m s}
+do_execsql_test 1.3.2 { SELECT term FROM p2 } {fir mys sql}
+do_execsql_test 1.3.3 { SELECT term FROM p3 } {firebi sqlite}
+do_execsql_test 1.4 {
+ SELECT term FROM terms;
+} {firebird mysql sqlite}
+
+fts3_tap_test 1.5 db t1 {1 3 6}
+
+#-------------------------------------------------------------------------
+# A slightly more complicated dataset. This test also verifies that DELETE
+# operations do not corrupt the prefixes index.
+#
+do_execsql_test 2.1 {
+ INSERT INTO t1 VALUES('FTS3 and FTS4 are an SQLite virtual table modules');
+ INSERT INTO t1 VALUES('that allows users to perform full-text searches on');
+ INSERT INTO t1 VALUES('a set of documents. The most common (and');
+ INSERT INTO t1 VALUES('effective) way to describe full-text searches is');
+ INSERT INTO t1 VALUES('"what Google, Yahoo and Altavista do with');
+ INSERT INTO t1 VALUES('documents placed on the World Wide Web". Users');
+ INSERT INTO t1 VALUES('input a term, or series of terms, perhaps');
+ INSERT INTO t1 VALUES('connected by a binary operator or grouped together');
+ INSERT INTO t1 VALUES('into a phrase, and the full-text query system');
+ INSERT INTO t1 VALUES('finds the set of documents that best matches those');
+ INSERT INTO t1 VALUES('terms considering the operators and groupings the');
+ INSERT INTO t1 VALUES('user has specified. This article describes the');
+ INSERT INTO t1 VALUES('deployment and usage of FTS3 and FTS4.');
+ INSERT INTO t1 VALUES('FTS1 and FTS2 are obsolete full-text search');
+ INSERT INTO t1 VALUES('modules for SQLite. There are known issues with');
+ INSERT INTO t1 VALUES('these older modules and their use should be');
+ INSERT INTO t1 VALUES('avoided. Portions of the original FTS3 code were');
+ INSERT INTO t1 VALUES('contributed to the SQLite project by Scott Hess of');
+ INSERT INTO t1 VALUES('Google. It is now developed and maintained as part');
+ INSERT INTO t1 VALUES('of SQLite. ');
+}
+fts3_tap_test 2.2 db t1 {1 3 6}
+do_execsql_test 2.3 { DELETE FROM t1 WHERE docid%2; }
+fts3_tap_test 2.4 db t1 {1 3 6}
+
+do_execsql_test 2.5 { INSERT INTO t1(t1) VALUES('optimize') }
+fts3_tap_test 2.6 db t1 {1 3 6}
+
+do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE t2 USING fts4(prefix='1,2,3');
+ INSERT INTO t2 VALUES('On 12 September the wind direction turned and');
+ INSERT INTO t2 VALUES('William''s fleet sailed. A storm blew up and the');
+ INSERT INTO t2 VALUES('fleet was forced to take shelter at');
+ INSERT INTO t2 VALUES('Saint-Valery-sur-Somme and again wait for the wind');
+ INSERT INTO t2 VALUES('to change. On 27 September the Norman fleet');
+ INSERT INTO t2 VALUES('finally set sail, landing in England at Pevensey');
+ INSERT INTO t2 VALUES('Bay (Sussex) on 28 September. William then moved');
+ INSERT INTO t2 VALUES('to Hastings, a few miles to the east, where he');
+ INSERT INTO t2 VALUES('built a prefabricated wooden castle for a base of');
+ INSERT INTO t2 VALUES('operations. From there, he ravaged the hinterland');
+ INSERT INTO t2 VALUES('and waited for Harold''s return from the north.');
+ INSERT INTO t2 VALUES('On 12 September the wind direction turned and');
+ INSERT INTO t2 VALUES('William''s fleet sailed. A storm blew up and the');
+ INSERT INTO t2 VALUES('fleet was forced to take shelter at');
+ INSERT INTO t2 VALUES('Saint-Valery-sur-Somme and again wait for the wind');
+ INSERT INTO t2 VALUES('to change. On 27 September the Norman fleet');
+ INSERT INTO t2 VALUES('finally set sail, landing in England at Pevensey');
+ INSERT INTO t2 VALUES('Bay (Sussex) on 28 September. William then moved');
+ INSERT INTO t2 VALUES('to Hastings, a few miles to the east, where he');
+ INSERT INTO t2 VALUES('built a prefabricated wooden castle for a base of');
+ INSERT INTO t2 VALUES('operations. From there, he ravaged the hinterland');
+ INSERT INTO t2 VALUES('and waited for Harold''s return from the north.');
+}
+
+fts3_tap_test 3.2 db t2 {1 2 3}
+do_execsql_test 3.3 { SELECT optimize(t2) FROM t2 LIMIT 1 } {{Index optimized}}
+fts3_tap_test 3.4 db t2 {1 2 3}
+
+
+#-------------------------------------------------------------------------
+# Simple tests for reading the prefix-index.
+#
+do_execsql_test 4.1 {
+ CREATE VIRTUAL TABLE t3 USING fts4(prefix="1,4");
+ INSERT INTO t3 VALUES('one two three');
+ INSERT INTO t3 VALUES('four five six');
+ INSERT INTO t3 VALUES('seven eight nine');
+}
+do_execsql_test 4.2 {
+ SELECT * FROM t3 WHERE t3 MATCH 'f*'
+} {{four five six}}
+do_execsql_test 4.3 {
+ SELECT * FROM t3 WHERE t3 MATCH 'four*'
+} {{four five six}}
+do_execsql_test 4.4 {
+ SELECT * FROM t3 WHERE t3 MATCH 's*'
+} {{four five six} {seven eight nine}}
+do_execsql_test 4.5 {
+ SELECT * FROM t3 WHERE t3 MATCH 'sev*'
+} {{seven eight nine}}
+do_execsql_test 4.6 {
+ SELECT * FROM t3 WHERE t3 MATCH 'one*'
+} {{one two three}}
+
+#-------------------------------------------------------------------------
+# Syntax tests.
+#
+do_catchsql_test 5.1 {
+ CREATE VIRTUAL TABLE t4 USING fts4(prefix="abc");
+} {1 {error parsing prefix parameter: abc}}
+do_catchsql_test 5.2 {
+ CREATE VIRTUAL TABLE t4 USING fts4(prefix="");
+} {0 {}}
+
+finish_test
diff --git a/test/fts3query.test b/test/fts3query.test
new file mode 100644
index 0000000..c8f8686
--- /dev/null
+++ b/test/fts3query.test
@@ -0,0 +1,213 @@
+# 2009 December 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests of fts3 queries that have been useful during
+# the development process as well as some that have been useful in tracking
+# down bugs. They are not focused on any particular functionality.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build does not include FTS3, skip the tests in this file.
+#
+ifcapable !fts3 { finish_test ; return }
+source $testdir/malloc_common.tcl
+source $testdir/fts3_common.tcl
+set DO_MALLOC_TEST 0
+
+set testprefix fts3query
+
+do_test fts3query-1.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts3(x);
+ BEGIN;
+ INSERT INTO t1 VALUES('The source code for SQLite is in the public');
+ }
+} {}
+
+do_select_test fts3query-1.2 {
+ SELECT * FROM t1;
+} {{The source code for SQLite is in the public}}
+do_select_test fts3query-1.3 {
+ SELECT * FROM t1 WHERE t1 MATCH 'sqlite'
+} {{The source code for SQLite is in the public}}
+
+do_test fts3query-1.4 { execsql {COMMIT} } {}
+
+do_select_test fts3query-1.5 {
+ SELECT * FROM t1;
+} {{The source code for SQLite is in the public}}
+do_select_test fts3query-1.6 {
+ SELECT * FROM t1 WHERE t1 MATCH 'sqlite'
+} {{The source code for SQLite is in the public}}
+
+
+set sqlite_fts3_enable_parentheses 1
+do_test fts3query-2.1 {
+ execsql {
+ CREATE VIRTUAL TABLE zoink USING fts3;
+ INSERT INTO zoink VALUES('The apple falls far from the tree');
+ }
+} {}
+do_test fts3query-2.2 {
+ execsql {
+ SELECT docid FROM zoink WHERE zoink MATCH '(apple oranges) AND apple'
+ }
+} {}
+do_test fts3query-2.3 {
+ execsql {
+ SELECT docid FROM zoink WHERE zoink MATCH 'apple AND (oranges apple)'
+ }
+} {}
+set sqlite_fts3_enable_parentheses 0
+
+do_test fts3query-3.1 {
+ execsql {
+ CREATE VIRTUAL TABLE foobar using FTS3(description, tokenize porter);
+ INSERT INTO foobar (description) values ('
+ Filed under: Emerging Technologies, EV/Plug-in, Hybrid, Chevrolet, GM,
+ ZENN 2011 Chevy Volt - Click above for high-res image gallery There are
+ 16 days left in the month of December. Besides being time for most
+ Americans to kick their Christmas shopping sessions into high gear and
+ start planning their resolutions for 2010, it also means that there''s
+ precious little time for EEStor to "deliver functional technology" to
+ Zenn Motors as promised. Still, the promises held out by the secretive
+ company are too great for us to forget about entirely. We''d love for
+ EEStor''s claims to be independently verified and proven accurate, as
+ would just about anyone else looking to break free of petroleum in fav
+ ');
+ }
+} {}
+
+do_test fts3query-3.2 {
+ execsql { SELECT docid FROM foobar WHERE description MATCH '"high sp d"' }
+} {}
+
+proc mit {blob} {
+ set scan(littleEndian) i*
+ set scan(bigEndian) I*
+ binary scan $blob $scan($::tcl_platform(byteOrder)) r
+ return $r
+}
+db func mit mit
+
+do_test fts3query-3.3 {
+ execsql { SELECT mit(matchinfo(foobar)) FROM foobar WHERE foobar MATCH 'the' }
+} {{1 1 3 3 1}}
+
+# The following tests check that ticket 775b39dd3c has been fixed.
+#
+do_test fts3query-4.1 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(number INTEGER PRIMARY KEY, date);
+ CREATE INDEX i1 ON t1(date);
+ CREATE VIRTUAL TABLE ft USING fts3(title);
+ CREATE TABLE bt(title);
+ }
+} {}
+do_eqp_test fts3query-4.2 {
+ SELECT t1.number FROM t1, ft WHERE t1.number=ft.rowid ORDER BY t1.date
+} {
+ 0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
+ 0 1 1 {SCAN TABLE ft VIRTUAL TABLE INDEX 1: (~0 rows)}
+}
+do_eqp_test fts3query-4.3 {
+ SELECT t1.number FROM ft, t1 WHERE t1.number=ft.rowid ORDER BY t1.date
+} {
+ 0 0 1 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
+ 0 1 0 {SCAN TABLE ft VIRTUAL TABLE INDEX 1: (~0 rows)}
+}
+do_eqp_test fts3query-4.4 {
+ SELECT t1.number FROM t1, bt WHERE t1.number=bt.rowid ORDER BY t1.date
+} {
+ 0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
+ 0 1 1 {SEARCH TABLE bt USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+}
+do_eqp_test fts3query-4.5 {
+ SELECT t1.number FROM bt, t1 WHERE t1.number=bt.rowid ORDER BY t1.date
+} {
+ 0 0 1 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
+ 0 1 0 {SEARCH TABLE bt USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+}
+
+
+# Test that calling matchinfo() with the wrong number of arguments, or with
+# an invalid argument returns an error.
+#
+do_execsql_test 5.1 {
+ CREATE VIRTUAL TABLE t2 USING FTS4;
+ INSERT INTO t2 VALUES('it was the first time in history');
+}
+do_select_tests 5.2 -errorformat {
+ wrong number of arguments to function %s()
+} {
+ 1 "SELECT matchinfo() FROM t2 WHERE t2 MATCH 'history'" matchinfo
+ 3 "SELECT snippet(t2, 1, 2, 3, 4, 5, 6) FROM t2 WHERE t2 MATCH 'history'"
+ snippet
+}
+do_select_tests 5.3 -errorformat {
+ illegal first argument to %s
+} {
+ 1 "SELECT matchinfo(content) FROM t2 WHERE t2 MATCH 'history'" matchinfo
+ 2 "SELECT offsets(content) FROM t2 WHERE t2 MATCH 'history'" offsets
+ 3 "SELECT snippet(content) FROM t2 WHERE t2 MATCH 'history'" snippet
+ 4 "SELECT optimize(content) FROM t2 WHERE t2 MATCH 'history'" optimize
+}
+do_execsql_test 5.4.0 { UPDATE t2_content SET c0content = X'1234' }
+do_select_tests 5.4 -errorformat {
+ illegal first argument to %s
+} {
+ 1 "SELECT matchinfo(content) FROM t2 WHERE t2 MATCH 'history'" matchinfo
+ 2 "SELECT offsets(content) FROM t2 WHERE t2 MATCH 'history'" offsets
+ 3 "SELECT snippet(content) FROM t2 WHERE t2 MATCH 'history'" snippet
+ 4 "SELECT optimize(content) FROM t2 WHERE t2 MATCH 'history'" optimize
+}
+do_catchsql_test 5.5.1 {
+ SELECT matchinfo(t2, 'abc') FROM t2 WHERE t2 MATCH 'history'
+} {1 {unrecognized matchinfo request: b}}
+
+do_execsql_test 5.5 { DROP TABLE t2 }
+
+
+# Test the snippet() function with 1 to 6 arguments.
+#
+do_execsql_test 6.1 {
+ CREATE VIRTUAL TABLE t3 USING FTS4(a, b);
+ INSERT INTO t3 VALUES('no gestures', 'another intriguing discovery by observing the hand gestures (called beats) people make while speaking. Research has shown that such gestures do more than add visual emphasis to our words (many people gesture while they''re on the telephone, for example); it seems they actually help our brains find words');
+}
+do_select_tests 6.2 {
+ 1 "SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'gestures'"
+ {{<b>...</b>hand <b>gestures</b> (called beats) people make while speaking. Research has shown that such <b>gestures</b> do<b>...</b>}}
+
+ 2 "SELECT snippet(t3, 'XXX') FROM t3 WHERE t3 MATCH 'gestures'"
+ {{<b>...</b>hand XXXgestures</b> (called beats) people make while speaking. Research has shown that such XXXgestures</b> do<b>...</b>}}
+
+ 3 "SELECT snippet(t3, 'XXX', 'YYY') FROM t3 WHERE t3 MATCH 'gestures'"
+ {{<b>...</b>hand XXXgesturesYYY (called beats) people make while speaking. Research has shown that such XXXgesturesYYY do<b>...</b>}}
+
+ 4 "SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ') FROM t3 WHERE t3 MATCH 'gestures'"
+ {{ZZZhand XXXgesturesYYY (called beats) people make while speaking. Research has shown that such XXXgesturesYYY doZZZ}}
+
+ 5 "SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ', 1) FROM t3 WHERE t3 MATCH 'gestures'"
+ {{ZZZhand XXXgesturesYYY (called beats) people make while speaking. Research has shown that such XXXgesturesYYY doZZZ}}
+
+ 6 "SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ', 0) FROM t3 WHERE t3 MATCH 'gestures'"
+ {{no XXXgesturesYYY}}
+
+ 7 "SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ', 1, 5) FROM t3 WHERE t3 MATCH 'gestures'"
+ {{ZZZthe hand XXXgesturesYYY (called beatsZZZ}}
+}
+
+
+finish_test
+
diff --git a/test/fts3rnd.test b/test/fts3rnd.test
new file mode 100644
index 0000000..97af549
--- /dev/null
+++ b/test/fts3rnd.test
@@ -0,0 +1,460 @@
+# 2009 December 03
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Brute force (random data) tests for FTS3.
+#
+
+#-------------------------------------------------------------------------
+#
+# The FTS3 tests implemented in this file focus on testing that FTS3
+# returns the correct set of documents for various types of full-text
+# query. This is done using pseudo-randomly generated data and queries.
+# The expected result of each query is calculated using Tcl code.
+#
+# 1. The database is initialized to contain a single table with three
+# columns. 100 rows are inserted into the table. Each of the three
+# values in each row is a document consisting of between 0 and 100
+# terms. Terms are selected from a vocabulary of $G(nVocab) terms.
+#
+# 2. The following is performed 100 times:
+#
+# a. A row is inserted into the database. The row contents are
+# generated as in step 1. The docid is a pseudo-randomly selected
+# value between 0 and 1000000.
+#
+# b. A psuedo-randomly selected row is updated. One of its columns is
+# set to contain a new document generated in the same way as the
+# documents in step 1.
+#
+# c. A psuedo-randomly selected row is deleted.
+#
+# d. For each of several types of fts3 queries, 10 SELECT queries
+# of the form:
+#
+# SELECT docid FROM <tbl> WHERE <tbl> MATCH '<query>'
+#
+# are evaluated. The results are compared to those calculated by
+# Tcl code in this file. The patterns used for the different query
+# types are:
+#
+# 1. query = <term>
+# 2. query = <prefix>
+# 3. query = "<term> <term>"
+# 4. query = "<term> <term> <term>"
+# 5. query = "<prefix> <prefix> <prefix>"
+# 6. query = <term> NEAR <term>
+# 7. query = <term> NEAR/11 <term> NEAR/11 <term>
+# 8. query = <term> OR <term>
+# 9. query = <term> NOT <term>
+# 10. query = <term> AND <term>
+# 11. query = <term> NEAR <term> OR <term> NEAR <term>
+# 12. query = <term> NEAR <term> NOT <term> NEAR <term>
+# 13. query = <term> NEAR <term> AND <term> NEAR <term>
+#
+# where <term> is a term psuedo-randomly selected from the vocabulary
+# and prefix is the first 2 characters of such a term followed by
+# a "*" character.
+#
+# Every second iteration, steps (a) through (d) above are performed
+# within a single transaction. This forces the queries in (d) to
+# read data from both the database and the in-memory hash table
+# that caches the full-text index entries created by steps (a), (b)
+# and (c) until the transaction is committed.
+#
+# The procedure above is run 5 times, using advisory fts3 node sizes of 50,
+# 500, 1000 and 2000 bytes.
+#
+# After the test using an advisory node-size of 50, an OOM test is run using
+# the database. This test is similar to step (d) above, except that it tests
+# the effects of transient and persistent OOM conditions encountered while
+# executing each query.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build does not include FTS3, skip the tests in this file.
+#
+ifcapable !fts3 { finish_test ; return }
+source $testdir/fts3_common.tcl
+source $testdir/malloc_common.tcl
+
+set G(nVocab) 100
+
+set nVocab 100
+set lVocab [list]
+
+expr srand(0)
+
+# Generate a vocabulary of nVocab words. Each word is 3 characters long.
+#
+set lChar {a b c d e f g h i j k l m n o p q r s t u v w x y z}
+for {set i 0} {$i < $nVocab} {incr i} {
+ set len [expr int(rand()*3)+2]
+ set word [lindex $lChar [expr int(rand()*26)]]
+ append word [lindex $lChar [expr int(rand()*26)]]
+ if {$len>2} { append word [lindex $lChar [expr int(rand()*26)]] }
+ if {$len>3} { append word [lindex $lChar [expr int(rand()*26)]] }
+ lappend lVocab $word
+}
+
+proc random_term {} {
+ lindex $::lVocab [expr {int(rand()*$::nVocab)}]
+}
+
+# Return a document consisting of $nWord arbitrarily selected terms
+# from the $::lVocab list.
+#
+proc generate_doc {nWord} {
+ set doc [list]
+ for {set i 0} {$i < $nWord} {incr i} {
+ lappend doc [random_term]
+ }
+ return $doc
+}
+
+
+
+# Primitives to update the table.
+#
+unset -nocomplain t1
+proc insert_row {rowid} {
+ set a [generate_doc [expr int((rand()*100))]]
+ set b [generate_doc [expr int((rand()*100))]]
+ set c [generate_doc [expr int((rand()*100))]]
+ execsql { INSERT INTO t1(docid, a, b, c) VALUES($rowid, $a, $b, $c) }
+ set ::t1($rowid) [list $a $b $c]
+}
+proc delete_row {rowid} {
+ execsql { DELETE FROM t1 WHERE rowid = $rowid }
+ catch {unset ::t1($rowid)}
+}
+proc update_row {rowid} {
+ set cols {a b c}
+ set iCol [expr int(rand()*3)]
+ set doc [generate_doc [expr int((rand()*100))]]
+ lset ::t1($rowid) $iCol $doc
+ execsql "UPDATE t1 SET [lindex $cols $iCol] = \$doc WHERE rowid = \$rowid"
+}
+
+proc simple_phrase {zPrefix} {
+ set ret [list]
+
+ set reg [string map {* {[^ ]*}} $zPrefix]
+ set reg " $reg "
+
+ foreach key [lsort -integer [array names ::t1]] {
+ set value $::t1($key)
+ set cnt [list]
+ foreach col $value {
+ if {[regexp $reg " $col "]} { lappend ret $key ; break }
+ }
+ }
+
+ #lsort -uniq -integer $ret
+ set ret
+}
+
+# This [proc] is used to test the FTS3 matchinfo() function.
+#
+proc simple_token_matchinfo {zToken bDesc} {
+
+ set nDoc(0) 0
+ set nDoc(1) 0
+ set nDoc(2) 0
+ set nHit(0) 0
+ set nHit(1) 0
+ set nHit(2) 0
+
+ set dir -inc
+ if {$bDesc} { set dir -dec }
+
+ foreach key [array names ::t1] {
+ set value $::t1($key)
+ set a($key) [list]
+ foreach i {0 1 2} col $value {
+ set hit [llength [lsearch -all $col $zToken]]
+ lappend a($key) $hit
+ incr nHit($i) $hit
+ if {$hit>0} { incr nDoc($i) }
+ }
+ }
+
+ set ret [list]
+ foreach docid [lsort -integer $dir [array names a]] {
+ if { [lindex [lsort -integer $a($docid)] end] } {
+ set matchinfo [list 1 3]
+ foreach i {0 1 2} hit $a($docid) {
+ lappend matchinfo $hit $nHit($i) $nDoc($i)
+ }
+ lappend ret $docid $matchinfo
+ }
+ }
+
+ set ret
+}
+
+proc simple_near {termlist nNear} {
+ set ret [list]
+
+ foreach {key value} [array get ::t1] {
+ foreach v $value {
+
+ set l [lsearch -exact -all $v [lindex $termlist 0]]
+ foreach T [lrange $termlist 1 end] {
+ set l2 [list]
+ foreach i $l {
+ set iStart [expr $i - $nNear - 1]
+ set iEnd [expr $i + $nNear + 1]
+ if {$iStart < 0} {set iStart 0}
+ foreach i2 [lsearch -exact -all [lrange $v $iStart $iEnd] $T] {
+ incr i2 $iStart
+ if {$i2 != $i} { lappend l2 $i2 }
+ }
+ }
+ set l [lsort -uniq -integer $l2]
+ }
+
+ if {[llength $l]} {
+#puts "MATCH($key): $v"
+ lappend ret $key
+ }
+ }
+ }
+
+ lsort -unique -integer $ret
+}
+
+# The following three procs:
+#
+# setup_not A B
+# setup_or A B
+# setup_and A B
+#
+# each take two arguments. Both arguments must be lists of integer values
+# sorted by value. The return value is the list produced by evaluating
+# the equivalent of "A op B", where op is the FTS3 operator NOT, OR or
+# AND.
+#
+proc setop_not {A B} {
+ foreach b $B { set n($b) {} }
+ set ret [list]
+ foreach a $A { if {![info exists n($a)]} {lappend ret $a} }
+ return $ret
+}
+proc setop_or {A B} {
+ lsort -integer -uniq [concat $A $B]
+}
+proc setop_and {A B} {
+ foreach b $B { set n($b) {} }
+ set ret [list]
+ foreach a $A { if {[info exists n($a)]} {lappend ret $a} }
+ return $ret
+}
+
+proc mit {blob} {
+ set scan(littleEndian) i*
+ set scan(bigEndian) I*
+ binary scan $blob $scan($::tcl_platform(byteOrder)) r
+ return $r
+}
+db func mit mit
+set sqlite_fts3_enable_parentheses 1
+
+proc do_orderbydocid_test {tn sql res} {
+ uplevel [list do_select_test $tn.asc "$sql ORDER BY docid ASC" $res]
+ uplevel [list do_select_test $tn.desc "$sql ORDER BY docid DESC" \
+ [lsort -int -dec $res]
+ ]
+}
+
+set NUM_TRIALS 100
+
+foreach {nodesize order} {
+ 50 DESC
+ 50 ASC
+ 500 ASC
+ 1000 DESC
+ 2000 ASC
+} {
+ catch { array unset ::t1 }
+ set testname "$nodesize/$order"
+
+ # Create the FTS3 table. Populate it (and the Tcl array) with 100 rows.
+ #
+ db transaction {
+ catchsql { DROP TABLE t1 }
+ execsql "CREATE VIRTUAL TABLE t1 USING fts4(a, b, c, order=$order)"
+ execsql "INSERT INTO t1(t1) VALUES('nodesize=$nodesize')"
+ for {set i 0} {$i < 100} {incr i} { insert_row $i }
+ }
+
+ for {set iTest 1} {$iTest <= $NUM_TRIALS} {incr iTest} {
+ catchsql COMMIT
+
+ set DO_MALLOC_TEST 0
+ set nRep 10
+ if {$iTest==100 && $nodesize==50} {
+ set DO_MALLOC_TEST 1
+ set nRep 2
+ }
+
+ set ::testprefix fts3rnd-1.$testname.$iTest
+
+ # Delete one row, update one row and insert one row.
+ #
+ set rows [array names ::t1]
+ set nRow [llength $rows]
+ set iUpdate [lindex $rows [expr {int(rand()*$nRow)}]]
+ set iDelete $iUpdate
+ while {$iDelete == $iUpdate} {
+ set iDelete [lindex $rows [expr {int(rand()*$nRow)}]]
+ }
+ set iInsert $iUpdate
+ while {[info exists ::t1($iInsert)]} {
+ set iInsert [expr {int(rand()*1000000)}]
+ }
+ execsql BEGIN
+ insert_row $iInsert
+ update_row $iUpdate
+ delete_row $iDelete
+ if {0==($iTest%2)} { execsql COMMIT }
+
+ if {0==($iTest%2)} {
+ #do_test 0 { fts3_integrity_check t1 } ok
+ }
+
+ # Pick 10 terms from the vocabulary. Check that the results of querying
+ # the database for the set of documents containing each of these terms
+ # is the same as the result obtained by scanning the contents of the Tcl
+ # array for each term.
+ #
+ for {set i 0} {$i < 10} {incr i} {
+ set term [random_term]
+ do_select_test 1.$i.asc {
+ SELECT docid, mit(matchinfo(t1)) FROM t1 WHERE t1 MATCH $term
+ ORDER BY docid ASC
+ } [simple_token_matchinfo $term 0]
+ do_select_test 1.$i.desc {
+ SELECT docid, mit(matchinfo(t1)) FROM t1 WHERE t1 MATCH $term
+ ORDER BY docid DESC
+ } [simple_token_matchinfo $term 1]
+ }
+
+ # This time, use the first two characters of each term as a term prefix
+ # to query for. Test that querying the Tcl array produces the same results
+ # as querying the FTS3 table for the prefix.
+ #
+ for {set i 0} {$i < $nRep} {incr i} {
+ set prefix [string range [random_term] 0 end-1]
+ set match "${prefix}*"
+ do_orderbydocid_test 2.$i {
+ SELECT docid FROM t1 WHERE t1 MATCH $match
+ } [simple_phrase $match]
+ }
+
+ # Similar to the above, except for phrase queries.
+ #
+ for {set i 0} {$i < $nRep} {incr i} {
+ set term [list [random_term] [random_term]]
+ set match "\"$term\""
+ do_orderbydocid_test 3.$i {
+ SELECT docid FROM t1 WHERE t1 MATCH $match
+ } [simple_phrase $term]
+ }
+
+ # Three word phrases.
+ #
+ for {set i 0} {$i < $nRep} {incr i} {
+ set term [list [random_term] [random_term] [random_term]]
+ set match "\"$term\""
+ do_orderbydocid_test 4.$i {
+ SELECT docid FROM t1 WHERE t1 MATCH $match
+ } [simple_phrase $term]
+ }
+
+ # Three word phrases made up of term-prefixes.
+ #
+ for {set i 0} {$i < $nRep} {incr i} {
+ set query "[string range [random_term] 0 end-1]* "
+ append query "[string range [random_term] 0 end-1]* "
+ append query "[string range [random_term] 0 end-1]*"
+
+ set match "\"$query\""
+ do_orderbydocid_test 5.$i {
+ SELECT docid FROM t1 WHERE t1 MATCH $match
+ } [simple_phrase $query]
+ }
+
+ # A NEAR query with terms as the arguments:
+ #
+ # ... MATCH '$term1 NEAR $term2' ...
+ #
+ for {set i 0} {$i < $nRep} {incr i} {
+ set terms [list [random_term] [random_term]]
+ set match [join $terms " NEAR "]
+ do_orderbydocid_test 6.$i {
+ SELECT docid FROM t1 WHERE t1 MATCH $match
+ } [simple_near $terms 10]
+ }
+
+ # A 3-way NEAR query with terms as the arguments.
+ #
+ for {set i 0} {$i < $nRep} {incr i} {
+ set terms [list [random_term] [random_term] [random_term]]
+ set nNear 11
+ set match [join $terms " NEAR/$nNear "]
+ do_orderbydocid_test 7.$i {
+ SELECT docid FROM t1 WHERE t1 MATCH $match
+ } [simple_near $terms $nNear]
+ }
+
+ # Set operations on simple term queries.
+ #
+ foreach {tn op proc} {
+ 8 OR setop_or
+ 9 NOT setop_not
+ 10 AND setop_and
+ } {
+ for {set i 0} {$i < $nRep} {incr i} {
+ set term1 [random_term]
+ set term2 [random_term]
+ set match "$term1 $op $term2"
+ do_orderbydocid_test $tn.$i {
+ SELECT docid FROM t1 WHERE t1 MATCH $match
+ } [$proc [simple_phrase $term1] [simple_phrase $term2]]
+ }
+ }
+
+ # Set operations on NEAR queries.
+ #
+ foreach {tn op proc} {
+ 11 OR setop_or
+ 12 NOT setop_not
+ 13 AND setop_and
+ } {
+ for {set i 0} {$i < $nRep} {incr i} {
+ set term1 [random_term]
+ set term2 [random_term]
+ set term3 [random_term]
+ set term4 [random_term]
+ set match "$term1 NEAR $term2 $op $term3 NEAR $term4"
+ do_orderbydocid_test $tn.$i {
+ SELECT docid FROM t1 WHERE t1 MATCH $match
+ } [$proc \
+ [simple_near [list $term1 $term2] 10] \
+ [simple_near [list $term3 $term4] 10]
+ ]
+ }
+ }
+
+ catchsql COMMIT
+ }
+}
+
+finish_test
diff --git a/test/fts3shared.test b/test/fts3shared.test
new file mode 100644
index 0000000..5f75bd5
--- /dev/null
+++ b/test/fts3shared.test
@@ -0,0 +1,72 @@
+# 2010 September 17
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !fts3||!shared_cache {
+ finish_test
+ return
+}
+
+db close
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+# Open two connections to the database in shared-cache mode.
+#
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+# Create a virtual FTS3 table. Populate it with some initial data.
+#
+do_execsql_test fts3shared-1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts3(x);
+ BEGIN;
+ INSERT INTO t1 VALUES('We listened and looked sideways up!');
+ INSERT INTO t1 VALUES('Fear at my heart, as at a cup,');
+ INSERT INTO t1 VALUES('My life-blood seemed to sip!');
+ INSERT INTO t1 VALUES('The stars were dim, and thick the night');
+ COMMIT;
+} {}
+
+# Open a write transaction and insert rows into the FTS3 table. This takes
+# a write-lock on the underlying t1_content table.
+#
+do_execsql_test fts3shared-1.2 {
+ BEGIN;
+ INSERT INTO t1 VALUES('The steersman''s face by his lamp gleamed white;');
+} {}
+
+# Now try a SELECT on the full-text table. This particular SELECT does not
+# read data from the %_content table. But it still attempts to obtain a lock
+# on that table and so the SELECT fails.
+#
+do_test fts3shared-1.3 {
+ catchsql {
+ BEGIN;
+ SELECT rowid FROM t1 WHERE t1 MATCH 'stars'
+ } db2
+} {1 {database table is locked}}
+
+# Verify that the first connection can commit its transaction.
+#
+do_test fts3shared-1.4 { sqlite3_get_autocommit db } 0
+do_execsql_test fts3shared-1.5 { COMMIT } {}
+do_test fts3shared-1.6 { sqlite3_get_autocommit db } 1
+
+# Verify that the second connection still has an open transaction.
+#
+do_test fts3shared-1.6 { sqlite3_get_autocommit db2 } 0
+
+db close
+db2 close
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
+
diff --git a/test/fts3snippet.test b/test/fts3snippet.test
new file mode 100644
index 0000000..b8646cd
--- /dev/null
+++ b/test/fts3snippet.test
@@ -0,0 +1,463 @@
+# 2010 January 07
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+#
+# The tests in this file test the FTS3 auxillary functions offsets(),
+# snippet() and matchinfo() work. At time of writing, running this file
+# provides full coverage of fts3_snippet.c.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
+ifcapable !fts3 { finish_test ; return }
+source $testdir/fts3_common.tcl
+
+set sqlite_fts3_enable_parentheses 1
+set DO_MALLOC_TEST 0
+
+# Transform the list $L to its "normal" form. So that it can be compared to
+# another list with the same set of elements using [string compare].
+#
+proc normalize {L} {
+ set ret [list]
+ foreach l $L {lappend ret $l}
+ return $ret
+}
+
+proc do_offsets_test {name expr args} {
+ set result [list]
+ foreach a $args {
+ lappend result [normalize $a]
+ }
+ do_select_test $name {
+ SELECT offsets(ft) FROM ft WHERE ft MATCH $expr
+ } $result
+}
+
+# Document text used by a few tests. Contains the English names of all
+# integers between 1 and 300.
+#
+set numbers [normalize {
+ one two three four five six seven eight nine ten eleven twelve thirteen
+ fourteen fifteen sixteen seventeen eighteen nineteen twenty twentyone
+ twentytwo twentythree twentyfour twentyfive twentysix twentyseven
+ twentyeight twentynine thirty thirtyone thirtytwo thirtythree thirtyfour
+ thirtyfive thirtysix thirtyseven thirtyeight thirtynine forty fortyone
+ fortytwo fortythree fortyfour fortyfive fortysix fortyseven fortyeight
+ fortynine fifty fiftyone fiftytwo fiftythree fiftyfour fiftyfive fiftysix
+ fiftyseven fiftyeight fiftynine sixty sixtyone sixtytwo sixtythree sixtyfour
+ sixtyfive sixtysix sixtyseven sixtyeight sixtynine seventy seventyone
+ seventytwo seventythree seventyfour seventyfive seventysix seventyseven
+ seventyeight seventynine eighty eightyone eightytwo eightythree eightyfour
+ eightyfive eightysix eightyseven eightyeight eightynine ninety ninetyone
+ ninetytwo ninetythree ninetyfour ninetyfive ninetysix ninetyseven
+ ninetyeight ninetynine onehundred onehundredone onehundredtwo
+ onehundredthree onehundredfour onehundredfive onehundredsix onehundredseven
+ onehundredeight onehundrednine onehundredten onehundredeleven
+ onehundredtwelve onehundredthirteen onehundredfourteen onehundredfifteen
+ onehundredsixteen onehundredseventeen onehundredeighteen onehundrednineteen
+ onehundredtwenty onehundredtwentyone onehundredtwentytwo
+ onehundredtwentythree onehundredtwentyfour onehundredtwentyfive
+ onehundredtwentysix onehundredtwentyseven onehundredtwentyeight
+ onehundredtwentynine onehundredthirty onehundredthirtyone
+ onehundredthirtytwo onehundredthirtythree onehundredthirtyfour
+ onehundredthirtyfive onehundredthirtysix onehundredthirtyseven
+ onehundredthirtyeight onehundredthirtynine onehundredforty
+ onehundredfortyone onehundredfortytwo onehundredfortythree
+ onehundredfortyfour onehundredfortyfive onehundredfortysix
+ onehundredfortyseven onehundredfortyeight onehundredfortynine
+ onehundredfifty onehundredfiftyone onehundredfiftytwo onehundredfiftythree
+ onehundredfiftyfour onehundredfiftyfive onehundredfiftysix
+ onehundredfiftyseven onehundredfiftyeight onehundredfiftynine
+ onehundredsixty onehundredsixtyone onehundredsixtytwo onehundredsixtythree
+ onehundredsixtyfour onehundredsixtyfive onehundredsixtysix
+ onehundredsixtyseven onehundredsixtyeight onehundredsixtynine
+ onehundredseventy onehundredseventyone onehundredseventytwo
+ onehundredseventythree onehundredseventyfour onehundredseventyfive
+ onehundredseventysix onehundredseventyseven onehundredseventyeight
+ onehundredseventynine onehundredeighty onehundredeightyone
+ onehundredeightytwo onehundredeightythree onehundredeightyfour
+ onehundredeightyfive onehundredeightysix onehundredeightyseven
+ onehundredeightyeight onehundredeightynine onehundredninety
+ onehundredninetyone onehundredninetytwo onehundredninetythree
+ onehundredninetyfour onehundredninetyfive onehundredninetysix
+ onehundredninetyseven onehundredninetyeight onehundredninetynine twohundred
+ twohundredone twohundredtwo twohundredthree twohundredfour twohundredfive
+ twohundredsix twohundredseven twohundredeight twohundrednine twohundredten
+ twohundredeleven twohundredtwelve twohundredthirteen twohundredfourteen
+ twohundredfifteen twohundredsixteen twohundredseventeen twohundredeighteen
+ twohundrednineteen twohundredtwenty twohundredtwentyone twohundredtwentytwo
+ twohundredtwentythree twohundredtwentyfour twohundredtwentyfive
+ twohundredtwentysix twohundredtwentyseven twohundredtwentyeight
+ twohundredtwentynine twohundredthirty twohundredthirtyone
+ twohundredthirtytwo twohundredthirtythree twohundredthirtyfour
+ twohundredthirtyfive twohundredthirtysix twohundredthirtyseven
+ twohundredthirtyeight twohundredthirtynine twohundredforty
+ twohundredfortyone twohundredfortytwo twohundredfortythree
+ twohundredfortyfour twohundredfortyfive twohundredfortysix
+ twohundredfortyseven twohundredfortyeight twohundredfortynine
+ twohundredfifty twohundredfiftyone twohundredfiftytwo twohundredfiftythree
+ twohundredfiftyfour twohundredfiftyfive twohundredfiftysix
+ twohundredfiftyseven twohundredfiftyeight twohundredfiftynine
+ twohundredsixty twohundredsixtyone twohundredsixtytwo twohundredsixtythree
+ twohundredsixtyfour twohundredsixtyfive twohundredsixtysix
+ twohundredsixtyseven twohundredsixtyeight twohundredsixtynine
+ twohundredseventy twohundredseventyone twohundredseventytwo
+ twohundredseventythree twohundredseventyfour twohundredseventyfive
+ twohundredseventysix twohundredseventyseven twohundredseventyeight
+ twohundredseventynine twohundredeighty twohundredeightyone
+ twohundredeightytwo twohundredeightythree twohundredeightyfour
+ twohundredeightyfive twohundredeightysix twohundredeightyseven
+ twohundredeightyeight twohundredeightynine twohundredninety
+ twohundredninetyone twohundredninetytwo twohundredninetythree
+ twohundredninetyfour twohundredninetyfive twohundredninetysix
+ twohundredninetyseven twohundredninetyeight twohundredninetynine
+ threehundred
+}]
+
+foreach {DO_MALLOC_TEST enc} {
+ 0 utf8
+ 1 utf8
+ 1 utf16
+} {
+
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3_db_config_lookaside db 0 0 0
+ db eval "PRAGMA encoding = \"$enc\""
+
+ # Set variable $T to the test name prefix for this iteration of the loop.
+ #
+ set T "fts3snippet-$enc"
+
+ ##########################################################################
+ # Test the offset function.
+ #
+ do_test $T.1.1 {
+ execsql {
+ CREATE VIRTUAL TABLE ft USING fts3;
+ INSERT INTO ft VALUES('xxx xxx xxx xxx');
+ }
+ } {}
+ do_offsets_test $T.1.2 {xxx} {0 0 0 3 0 0 4 3 0 0 8 3 0 0 12 3}
+ do_offsets_test $T.1.3 {"xxx xxx"} {
+ 0 0 0 3 0 0 4 3 0 1 4 3 0 0 8 3
+ 0 1 8 3 0 1 12 3
+ }
+ do_offsets_test $T.1.4 {"xxx xxx" xxx} {
+ 0 0 0 3 0 2 0 3 0 0 4 3 0 1 4 3
+ 0 2 4 3 0 0 8 3 0 1 8 3 0 2 8 3
+ 0 1 12 3 0 2 12 3
+ }
+ do_offsets_test $T.1.5 {xxx "xxx xxx"} {
+ 0 0 0 3 0 1 0 3 0 0 4 3 0 1 4 3
+ 0 2 4 3 0 0 8 3 0 1 8 3 0 2 8 3
+ 0 0 12 3 0 2 12 3
+ }
+
+ do_test $T.2.1 {
+ set v1 [lrange $numbers 0 99]
+ execsql {
+ DROP TABLE IF EXISTS ft;
+ CREATE VIRTUAL TABLE ft USING fts3(a, b);
+ INSERT INTO ft VALUES($v1, $numbers);
+ INSERT INTO ft VALUES($v1, NULL);
+ }
+ } {}
+
+ set off [string first "twohundred " $numbers]
+ do_offsets_test $T.2.1 {twohundred} [list 1 0 $off 10]
+
+ set off [string first "onehundred " $numbers]
+ do_offsets_test $T.2.2 {onehundred} \
+ [list 0 0 $off 10 1 0 $off 10] [list 0 0 $off 10]
+
+ # Test a corruption case:
+ execsql { UPDATE ft_content SET c1b = 'hello world' WHERE c1b = $numbers }
+ do_error_test $T.2.3 {
+ SELECT offsets(ft) FROM ft WHERE ft MATCH 'onehundred'
+ } {database disk image is malformed}
+
+ ##########################################################################
+ # Test the snippet function.
+ #
+ proc do_snippet_test {name expr iCol nTok args} {
+ set res [list]
+ foreach a $args { lappend res [string trim $a] }
+ do_select_test $name {
+ SELECT snippet(ft,'{','}','...',$iCol,$nTok) FROM ft WHERE ft MATCH $expr
+ } $res
+ }
+ do_test $T.3.1 {
+ execsql {
+ DROP TABLE IF EXISTS ft;
+ CREATE VIRTUAL TABLE ft USING fts3;
+ INSERT INTO ft VALUES('one two three four five six seven eight nine ten');
+ }
+ } {}
+ do_snippet_test $T.3.2 one 0 5 "{one} two three four five..."
+ do_snippet_test $T.3.3 two 0 5 "one {two} three four five..."
+ do_snippet_test $T.3.4 three 0 5 "one two {three} four five..."
+ do_snippet_test $T.3.5 four 0 5 "...two three {four} five six..."
+ do_snippet_test $T.3.6 five 0 5 "...three four {five} six seven..."
+ do_snippet_test $T.3.7 six 0 5 "...four five {six} seven eight..."
+ do_snippet_test $T.3.8 seven 0 5 "...five six {seven} eight nine..."
+ do_snippet_test $T.3.9 eight 0 5 "...six seven {eight} nine ten"
+ do_snippet_test $T.3.10 nine 0 5 "...six seven eight {nine} ten"
+ do_snippet_test $T.3.11 ten 0 5 "...six seven eight nine {ten}"
+
+ do_test $T.4.1 {
+ execsql {
+ INSERT INTO ft VALUES(
+ 'one two three four five '
+ || 'six seven eight nine ten '
+ || 'eleven twelve thirteen fourteen fifteen '
+ || 'sixteen seventeen eighteen nineteen twenty '
+ || 'one two three four five '
+ || 'six seven eight nine ten '
+ || 'eleven twelve thirteen fourteen fifteen '
+ || 'sixteen seventeen eighteen nineteen twenty'
+ );
+ }
+ } {}
+
+ do_snippet_test $T.4.2 {one nine} 0 5 {
+ {one} two three...eight {nine} ten
+ } {
+ {one} two three...eight {nine} ten...
+ }
+
+ do_snippet_test $T.4.3 {one nine} 0 -5 {
+ {one} two three four five...six seven eight {nine} ten
+ } {
+ {one} two three four five...seven eight {nine} ten eleven...
+ }
+ do_snippet_test $T.4.3 {one nineteen} 0 -5 {
+ ...eighteen {nineteen} twenty {one} two...
+ }
+ do_snippet_test $T.4.4 {two nineteen} 0 -5 {
+ ...eighteen {nineteen} twenty one {two}...
+ }
+ do_snippet_test $T.4.5 {three nineteen} 0 -5 {
+ ...{nineteen} twenty one two {three}...
+ }
+
+ do_snippet_test $T.4.6 {four nineteen} 0 -5 {
+ ...two three {four} five six...seventeen eighteen {nineteen} twenty one...
+ }
+ do_snippet_test $T.4.7 {four NEAR nineteen} 0 -5 {
+ ...seventeen eighteen {nineteen} twenty one...two three {four} five six...
+ }
+
+ do_snippet_test $T.4.8 {four nineteen} 0 5 {
+ ...three {four} five...eighteen {nineteen} twenty...
+ }
+ do_snippet_test $T.4.9 {four NEAR nineteen} 0 5 {
+ ...eighteen {nineteen} twenty...three {four} five...
+ }
+ do_snippet_test $T.4.10 {four NEAR nineteen} 0 -5 {
+ ...seventeen eighteen {nineteen} twenty one...two three {four} five six...
+ }
+ do_snippet_test $T.4.11 {four NOT (nineteen twentyone)} 0 5 {
+ ...two three {four} five six...
+ } {
+ ...two three {four} five six...
+ }
+ do_snippet_test $T.4.12 {four OR nineteen NEAR twentyone} 0 5 {
+ ...two three {four} five six...
+ } {
+ ...two three {four} five six...
+ }
+
+ do_test $T.5.1 {
+ execsql {
+ DROP TABLE IF EXISTS ft;
+ CREATE VIRTUAL TABLE ft USING fts3(a, b, c);
+ INSERT INTO ft VALUES(
+ 'one two three four five',
+ 'four five six seven eight',
+ 'seven eight nine ten eleven'
+ );
+ }
+ } {}
+
+ do_snippet_test $T.5.2 {five} -1 3 {...three four {five}}
+ do_snippet_test $T.5.3 {five} 0 3 {...three four {five}}
+ do_snippet_test $T.5.4 {five} 1 3 {four {five} six...}
+ do_snippet_test $T.5.5 {five} 2 3 {seven eight nine...}
+
+ do_test $T.5.6 {
+ execsql { UPDATE ft SET b = NULL }
+ } {}
+
+ do_snippet_test $T.5.7 {five} -1 3 {...three four {five}}
+ do_snippet_test $T.5.8 {five} 0 3 {...three four {five}}
+ do_snippet_test $T.5.9 {five} 1 3 {}
+ do_snippet_test $T.5.10 {five} 2 3 {seven eight nine...}
+
+ do_snippet_test $T.5.11 {one "seven eight nine"} -1 -3 {
+ {one} two three...{seven} {eight} {nine}...
+ }
+
+ do_test $T.6.1 {
+ execsql {
+ DROP TABLE IF EXISTS ft;
+ CREATE VIRTUAL TABLE ft USING fts3(x);
+ INSERT INTO ft VALUES($numbers);
+ }
+ } {}
+ do_snippet_test $T.6.2 {
+ one fifty onehundred onehundredfifty twohundredfifty threehundred
+ } -1 4 {
+ {one}...{fifty}...{onehundred}...{onehundredfifty}...
+ }
+ do_snippet_test $T.6.3 {
+ one fifty onehundred onehundredfifty twohundredfifty threehundred
+ } -1 -4 {
+ {one} two three four...fortyeight fortynine {fifty} fiftyone...ninetyeight ninetynine {onehundred} onehundredone...onehundredfortyeight onehundredfortynine {onehundredfifty} onehundredfiftyone...
+ }
+
+ do_test $T.7.1 {
+ execsql {
+ BEGIN;
+ DROP TABLE IF EXISTS ft;
+ CREATE VIRTUAL TABLE ft USING fts3(x);
+ }
+ set testresults [list]
+ for {set i 1} {$i < 150} {incr i} {
+ set commas [string repeat , $i]
+ execsql {INSERT INTO ft VALUES('one' || $commas || 'two')}
+ lappend testresults "{one}$commas{two}"
+ }
+ execsql COMMIT
+ } {}
+ eval [list do_snippet_test $T.7.2 {one two} -1 3] $testresults
+
+ ##########################################################################
+ # Test the matchinfo function.
+ #
+ proc mit {blob} {
+ set scan(littleEndian) i*
+ set scan(bigEndian) I*
+ binary scan $blob $scan($::tcl_platform(byteOrder)) r
+ return $r
+ }
+ db func mit mit
+ proc do_matchinfo_test {name expr args} {
+ set res [list]
+ foreach a $args { lappend res [normalize $a] }
+ do_select_test $name {
+ SELECT mit(matchinfo(ft)) FROM ft WHERE ft MATCH $expr
+ } $res
+ }
+ do_test $T.8.1 {
+ set ten {one two three four five six seven eight nine ten}
+ execsql {
+ DROP TABLE IF EXISTS ft;
+ CREATE VIRTUAL TABLE ft USING fts3;
+ INSERT INTO ft VALUES($ten);
+ INSERT INTO ft VALUES($ten || ' ' || $ten);
+ }
+ } {}
+
+ do_matchinfo_test $T.8.2 "one" {1 1 1 3 2} {1 1 2 3 2}
+ do_matchinfo_test $T.8.3 "one NEAR/3 ten" {2 1 1 1 1 1 1 1}
+ do_matchinfo_test $T.8.4 "five NEAR/4 ten" \
+ {2 1 1 3 2 1 3 2} {2 1 2 3 2 2 3 2}
+ do_matchinfo_test $T.8.5 "six NEAR/3 ten NEAR/3 two" \
+ {3 1 1 1 1 1 1 1 1 1 1}
+ do_matchinfo_test $T.8.6 "five NEAR/4 ten NEAR/3 two" \
+ {3 1 2 2 1 1 1 1 1 1 1}
+
+ do_test $T.9.1 {
+ execsql {
+ DROP TABLE IF EXISTS ft;
+ CREATE VIRTUAL TABLE ft USING fts3(x, y);
+ }
+ foreach n {1 2 3} {
+ set v1 [lrange $numbers 0 [expr $n*100]]
+ set v2 [string trim [string repeat "$numbers " $n]]
+ set docid [expr $n * 1000000]
+ execsql { INSERT INTO ft(docid, x, y) VALUES($docid, $v1, $v2) }
+ }
+ } {}
+ do_matchinfo_test $T.9.2 {two*} \
+ { 1 2 1 105 3 101 606 3} \
+ { 1 2 3 105 3 202 606 3} \
+ { 1 2 101 105 3 303 606 3}
+
+ do_matchinfo_test $T.9.4 {"one* two*"} \
+ { 1 2 1 5 3 2 12 3} \
+ { 1 2 2 5 3 4 12 3} \
+ { 1 2 2 5 3 6 12 3}
+
+ do_matchinfo_test $T.9.5 {twohundredfifty} \
+ { 1 2 0 1 1 1 6 3} \
+ { 1 2 0 1 1 2 6 3} \
+ { 1 2 1 1 1 3 6 3}
+
+ do_matchinfo_test $T.9.6 {"threehundred one"} \
+ { 1 2 0 0 0 1 3 2} \
+ { 1 2 0 0 0 2 3 2}
+
+ do_matchinfo_test $T.9.7 {one OR fivehundred} \
+ { 2 2 1 3 3 1 6 3 0 0 0 0 0 0 } \
+ { 2 2 1 3 3 2 6 3 0 0 0 0 0 0 } \
+ { 2 2 1 3 3 3 6 3 0 0 0 0 0 0 }
+
+ do_matchinfo_test $T.9.8 {two OR "threehundred one"} \
+ { 2 2 1 3 3 1 6 3 0 0 0 0 3 2 } \
+ { 2 2 1 3 3 2 6 3 0 0 0 1 3 2 } \
+ { 2 2 1 3 3 3 6 3 0 0 0 2 3 2 }
+
+ do_select_test $T.9.9 {
+ SELECT mit(matchinfo(ft)), mit(matchinfo(ft))
+ FROM ft WHERE ft MATCH 'two OR "threehundred one"'
+ } [normalize {
+ {2 2 1 3 3 1 6 3 0 0 0 0 3 2}
+ {2 2 1 3 3 1 6 3 0 0 0 0 3 2}
+ {2 2 1 3 3 2 6 3 0 0 0 1 3 2}
+ {2 2 1 3 3 2 6 3 0 0 0 1 3 2}
+ {2 2 1 3 3 3 6 3 0 0 0 2 3 2}
+ {2 2 1 3 3 3 6 3 0 0 0 2 3 2}
+ }]
+
+ # EVIDENCE-OF: R-40630-02268 If used within a SELECT that uses the
+ # "query by rowid" or "linear scan" strategies, then the snippet and
+ # offsets both return an empty string, and the matchinfo function
+ # returns a blob value zero bytes in size.
+ #
+ set r 1000000 ;# A rowid that exists in table ft
+ do_select_test $T.10.0 { SELECT rowid FROM ft WHERE rowid = $r } $r
+ do_select_test $T.10.1 {
+ SELECT length(offsets(ft)), typeof(offsets(ft)) FROM ft;
+ } {0 text 0 text 0 text}
+ do_select_test $T.10.2 {
+ SELECT length(offsets(ft)), typeof(offsets(ft)) FROM ft WHERE rowid = $r
+ } {0 text}
+ do_select_test $T.10.3 {
+ SELECT length(snippet(ft)), typeof(snippet(ft)) FROM ft;
+ } {0 text 0 text 0 text}
+ do_select_test $T.10.4 {
+ SELECT length(snippet(ft)), typeof(snippet(ft)) FROM ft WHERE rowid = $r;
+ } {0 text}
+ do_select_test $T.10.5 {
+ SELECT length(matchinfo(ft)), typeof(matchinfo(ft)) FROM ft;
+ } {0 blob 0 blob 0 blob}
+ do_select_test $T.10.6 {
+ SELECT length(matchinfo(ft)), typeof(matchinfo(ft)) FROM ft WHERE rowid = $r
+ } {0 blob}
+}
+
+set sqlite_fts3_enable_parentheses 0
+finish_test
diff --git a/test/fts3sort.test b/test/fts3sort.test
new file mode 100644
index 0000000..be75604
--- /dev/null
+++ b/test/fts3sort.test
@@ -0,0 +1,185 @@
+# 2011 May 04
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+
+proc build_database {nRow param} {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+
+ set vocab [list aa ab ac ba bb bc ca cb cc da]
+ expr srand(0)
+
+ execsql "CREATE VIRTUAL TABLE t1 USING fts4($param)"
+ for {set i 0} {$i < $nRow} {incr i} {
+ set v [expr int(rand()*1000000)]
+ set doc [list]
+ for {set div 1} {$div < 1000000} {set div [expr $div*10]} {
+ lappend doc [lindex $vocab [expr ($v/$div) % 10]]
+ }
+ execsql { INSERT INTO t1 VALUES($doc) }
+ }
+}
+
+set testprefix fts3sort
+
+unset -nocomplain CONTROL
+foreach {t param} {
+ 1 ""
+ 2 "order=asc"
+ 3 "order=desc"
+} {
+
+ set testprefix fts3sort-1.$t
+
+ set nRow 1000
+ do_test 1.0 {
+ build_database $nRow $param
+ execsql { SELECT count(*) FROM t1 }
+ } $nRow
+
+ foreach {tn query} {
+ 1 "SELECT docid, * FROM t1"
+ 2 "SELECT docid, * FROM t1 WHERE t1 MATCH 'aa'"
+ 3 "SELECT docid, * FROM t1 WHERE t1 MATCH 'a*'"
+ 4 "SELECT docid, quote(matchinfo(t1)) FROM t1 WHERE t1 MATCH 'a*'"
+ 5 "SELECT docid, quote(matchinfo(t1,'pcnxals')) FROM t1 WHERE t1 MATCH 'b*'"
+ 6 "SELECT docid, * FROM t1 WHERE t1 MATCH 'a* b* c*'"
+ 7 "SELECT docid, * FROM t1 WHERE t1 MATCH 'aa OR da'"
+ 8 "SELECT docid, * FROM t1 WHERE t1 MATCH 'nosuchtoken'"
+ 9 "SELECT docid, snippet(t1) FROM t1 WHERE t1 MATCH 'aa OR da'"
+ 10 "SELECT docid, snippet(t1) FROM t1 WHERE t1 MATCH 'aa OR nosuchtoken'"
+ 11 "SELECT docid, snippet(t1) FROM t1 WHERE t1 MATCH 'aa NEAR bb'"
+ 12 "SELECT docid, snippet(t1) FROM t1 WHERE t1 MATCH '\"aa bb\"'"
+ 13 "SELECT docid, content FROM t1 WHERE t1 MATCH 'aa NEAR/2 bb NEAR/3 cc'"
+ 14 "SELECT docid, content FROM t1 WHERE t1 MATCH '\"aa bb cc\"'"
+ } {
+
+ unset -nocomplain A B C D
+ set A_list [list]
+ set B_list [list]
+ set C_list [list]
+ set D_list [list]
+
+ unset -nocomplain X
+ db eval "$query ORDER BY rowid ASC" X {
+ set A($X(docid)) [array get X]
+ lappend A_list $X(docid)
+ }
+ unset -nocomplain X
+ db eval "$query ORDER BY rowid DESC" X {
+ set B($X(docid)) [array get X]
+ lappend B_list $X(docid)
+ }
+ unset -nocomplain X
+ db eval "$query ORDER BY docid ASC" X {
+ set C($X(docid)) [array get X]
+ lappend C_list $X(docid)
+ }
+ unset -nocomplain X
+ db eval "$query ORDER BY docid DESC" X {
+ set D($X(docid)) [array get X]
+ lappend D_list $X(docid)
+ }
+
+ do_test $tn.1 { set A_list } [lsort -integer -increasing $A_list]
+ do_test $tn.2 { set B_list } [lsort -integer -decreasing $B_list]
+ do_test $tn.3 { set C_list } [lsort -integer -increasing $C_list]
+ do_test $tn.4 { set D_list } [lsort -integer -decreasing $D_list]
+
+ unset -nocomplain DATA
+ unset -nocomplain X
+ db eval "$query" X {
+ set DATA($X(docid)) [array get X]
+ }
+
+ do_test $tn.5 { lsort [array get A] } [lsort [array get DATA]]
+ do_test $tn.6 { lsort [array get B] } [lsort [array get DATA]]
+ do_test $tn.7 { lsort [array get C] } [lsort [array get DATA]]
+ do_test $tn.8 { lsort [array get D] } [lsort [array get DATA]]
+
+ if {[info exists CONTROL($tn)]} {
+ do_test $tn.9 { set CONTROL($tn) } [lsort [array get DATA]]
+ } else {
+ set CONTROL($tn) [lsort [array get DATA]]
+ }
+ }
+}
+unset -nocomplain CONTROL
+
+set testprefix fts3sort
+
+#-------------------------------------------------------------------------
+# Tests for parsing the "order=asc" and "order=desc" directives.
+#
+foreach {tn param res} {
+ 1 "order=asc" {0 {}}
+ 2 "order=desc" {0 {}}
+ 3 "order=dec" {1 {unrecognized order: dec}}
+ 4 "order=xxx, order=asc" {1 {unrecognized order: xxx}}
+ 5 "order=desc, order=asc" {0 {}}
+ 6 "order=xxxx, order=asc" {1 {unrecognized order: xxxx}}
+ 7 "order=desk" {1 {unrecognized order: desk}}
+} {
+ execsql { DROP TABLE IF EXISTS t1 }
+ do_catchsql_test 2.1.$tn "
+ CREATE VIRTUAL TABLE t1 USING fts4(a, b, $param)
+ " $res
+}
+
+do_execsql_test 2.2 {
+ BEGIN;
+ CREATE VIRTUAL TABLE t2 USING fts4(order=desc);
+ INSERT INTO t2 VALUES('aa bb');
+ INSERT INTO t2 VALUES('bb cc');
+ INSERT INTO t2 VALUES('cc aa');
+ SELECT docid FROM t2 WHERE t2 MATCH 'aa';
+ END;
+} {3 1}
+do_execsql_test 2.3 {
+ SELECT docid FROM t2 WHERE t2 MATCH 'aa';
+} {3 1}
+do_execsql_test 2.4 {
+ SELECT docid FROM t2 WHERE t2 MATCH 'aa' ORDER BY content;
+} {1 3}
+
+#-------------------------------------------------------------------------
+# Test that ticket [56be976859] has been fixed.
+#
+do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE t3 USING fts4(x, order=DESC);
+ INSERT INTO t3(docid, x) VALUES(113382409004785664, 'aa');
+ INSERT INTO t3(docid, x) VALUES(1, 'ab');
+ SELECT rowid FROM t3 WHERE x MATCH 'a*' ORDER BY docid DESC;
+} {113382409004785664 1}
+do_execsql_test 3.2 {
+ CREATE VIRTUAL TABLE t4 USING fts4(x);
+ INSERT INTO t4(docid, x) VALUES(-113382409004785664, 'aa');
+ INSERT INTO t4(docid, x) VALUES(1, 'ab');
+ SELECT rowid FROM t4 WHERE x MATCH 'a*';
+} {-113382409004785664 1}
+
+
+
+finish_test
+
diff --git a/test/fts4aa.test b/test/fts4aa.test
new file mode 100644
index 0000000..c569331
--- /dev/null
+++ b/test/fts4aa.test
@@ -0,0 +1,1730 @@
+# 2010 February 02
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS4 module.
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# This procedure fills an existing FTS3/FTS4 table with many entries.
+# The table needs to have a single column (other than docid) named "words".
+#
+proc fts4aa_fill_table {} {
+db eval {
+BEGIN TRANSACTION;
+INSERT INTO t1(docid,words) VALUES(1001001,'In the beginning God created the heaven and the earth.');
+INSERT INTO t1(docid,words) VALUES(1001002,'And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.');
+INSERT INTO t1(docid,words) VALUES(1001003,'And God said, Let there be light: and there was light.');
+INSERT INTO t1(docid,words) VALUES(1001004,'And God saw the light, that it was good: and God divided the light from the darkness.');
+INSERT INTO t1(docid,words) VALUES(1001005,'And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.');
+INSERT INTO t1(docid,words) VALUES(1001006,'And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.');
+INSERT INTO t1(docid,words) VALUES(1001007,'And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.');
+INSERT INTO t1(docid,words) VALUES(1001008,'And God called the firmament Heaven. And the evening and the morning were the second day.');
+INSERT INTO t1(docid,words) VALUES(1001009,'And God said, Let the waters under the heaven be gathered together unto one place, and let the dry land appear: and it was so.');
+INSERT INTO t1(docid,words) VALUES(1001010,'And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good.');
+INSERT INTO t1(docid,words) VALUES(1001011,'And God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so.');
+INSERT INTO t1(docid,words) VALUES(1001012,'And the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good.');
+INSERT INTO t1(docid,words) VALUES(1001013,'And the evening and the morning were the third day.');
+INSERT INTO t1(docid,words) VALUES(1001014,'And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years:');
+INSERT INTO t1(docid,words) VALUES(1001015,'And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so.');
+INSERT INTO t1(docid,words) VALUES(1001016,'And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.');
+INSERT INTO t1(docid,words) VALUES(1001017,'And God set them in the firmament of the heaven to give light upon the earth,');
+INSERT INTO t1(docid,words) VALUES(1001018,'And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was good.');
+INSERT INTO t1(docid,words) VALUES(1001019,'And the evening and the morning were the fourth day.');
+INSERT INTO t1(docid,words) VALUES(1001020,'And God said, Let the waters bring forth abundantly the moving creature that hath life, and fowl that may fly above the earth in the open firmament of heaven.');
+INSERT INTO t1(docid,words) VALUES(1001021,'And God created great whales, and every living creature that moveth, which the waters brought forth abundantly, after their kind, and every winged fowl after his kind: and God saw that it was good.');
+INSERT INTO t1(docid,words) VALUES(1001022,'And God blessed them, saying, Be fruitful, and multiply, and fill the waters in the seas, and let fowl multiply in the earth.');
+INSERT INTO t1(docid,words) VALUES(1001023,'And the evening and the morning were the fifth day.');
+INSERT INTO t1(docid,words) VALUES(1001024,'And God said, Let the earth bring forth the living creature after his kind, cattle, and creeping thing, and beast of the earth after his kind: and it was so.');
+INSERT INTO t1(docid,words) VALUES(1001025,'And God made the beast of the earth after his kind, and cattle after their kind, and every thing that creepeth upon the earth after his kind: and God saw that it was good.');
+INSERT INTO t1(docid,words) VALUES(1001026,'And God said, Let us make man in our image, after our likeness: and let them have dominion over the fish of the sea, and over the fowl of the air, and over the cattle, and over all the earth, and over every creeping thing that creepeth upon the earth.');
+INSERT INTO t1(docid,words) VALUES(1001027,'So God created man in his own image, in the image of God created he him; male and female created he them.');
+INSERT INTO t1(docid,words) VALUES(1001028,'And God blessed them, and God said unto them, Be fruitful, and multiply, and replenish the earth, and subdue it: and have dominion over the fish of the sea, and over the fowl of the air, and over every living thing that moveth upon the earth.');
+INSERT INTO t1(docid,words) VALUES(1001029,'And God said, Behold, I have given you every herb bearing seed, which is upon the face of all the earth, and every tree, in the which is the fruit of a tree yielding seed; to you it shall be for meat.');
+INSERT INTO t1(docid,words) VALUES(1001030,'And to every beast of the earth, and to every fowl of the air, and to every thing that creepeth upon the earth, wherein there is life, I have given every green herb for meat: and it was so.');
+INSERT INTO t1(docid,words) VALUES(1001031,'And God saw every thing that he had made, and, behold, it was very good. And the evening and the morning were the sixth day.');
+INSERT INTO t1(docid,words) VALUES(1002001,'Thus the heavens and the earth were finished, and all the host of them.');
+INSERT INTO t1(docid,words) VALUES(1002002,'And on the seventh day God ended his work which he had made; and he rested on the seventh day from all his work which he had made.');
+INSERT INTO t1(docid,words) VALUES(1002003,'And God blessed the seventh day, and sanctified it: because that in it he had rested from all his work which God created and made.');
+INSERT INTO t1(docid,words) VALUES(1002004,'These are the generations of the heavens and of the earth when they were created, in the day that the LORD God made the earth and the heavens,');
+INSERT INTO t1(docid,words) VALUES(1002005,'And every plant of the field before it was in the earth, and every herb of the field before it grew: for the LORD God had not caused it to rain upon the earth, and there was not a man to till the ground.');
+INSERT INTO t1(docid,words) VALUES(1002006,'But there went up a mist from the earth, and watered the whole face of the ground.');
+INSERT INTO t1(docid,words) VALUES(1002007,'And the LORD God formed man of the dust of the ground, and breathed into his nostrils the breath of life; and man became a living soul.');
+INSERT INTO t1(docid,words) VALUES(1002008,'And the LORD God planted a garden eastward in Eden; and there he put the man whom he had formed.');
+INSERT INTO t1(docid,words) VALUES(1002009,'And out of the ground made the LORD God to grow every tree that is pleasant to the sight, and good for food; the tree of life also in the midst of the garden, and the tree of knowledge of good and evil.');
+INSERT INTO t1(docid,words) VALUES(1002010,'And a river went out of Eden to water the garden; and from thence it was parted, and became into four heads.');
+INSERT INTO t1(docid,words) VALUES(1002011,'The name of the first is Pison: that is it which compasseth the whole land of Havilah, where there is gold;');
+INSERT INTO t1(docid,words) VALUES(1002012,'And the gold of that land is good: there is bdellium and the onyx stone.');
+INSERT INTO t1(docid,words) VALUES(1002013,'And the name of the second river is Gihon: the same is it that compasseth the whole land of Ethiopia.');
+INSERT INTO t1(docid,words) VALUES(1002014,'And the name of the third river is Hiddekel: that is it which goeth toward the east of Assyria. And the fourth river is Euphrates.');
+INSERT INTO t1(docid,words) VALUES(1002015,'And the LORD God took the man, and put him into the garden of Eden to dress it and to keep it.');
+INSERT INTO t1(docid,words) VALUES(1002016,'And the LORD God commanded the man, saying, Of every tree of the garden thou mayest freely eat:');
+INSERT INTO t1(docid,words) VALUES(1002017,'But of the tree of the knowledge of good and evil, thou shalt not eat of it: for in the day that thou eatest thereof thou shalt surely die.');
+INSERT INTO t1(docid,words) VALUES(1002018,'And the LORD God said, It is not good that the man should be alone; I will make him an help meet for him.');
+INSERT INTO t1(docid,words) VALUES(1002019,'And out of the ground the LORD God formed every beast of the field, and every fowl of the air; and brought them unto Adam to see what he would call them: and whatsoever Adam called every living creature, that was the name thereof.');
+INSERT INTO t1(docid,words) VALUES(1002020,'And Adam gave names to all cattle, and to the fowl of the air, and to every beast of the field; but for Adam there was not found an help meet for him.');
+INSERT INTO t1(docid,words) VALUES(1002021,'And the LORD God caused a deep sleep to fall upon Adam, and he slept: and he took one of his ribs, and closed up the flesh instead thereof;');
+INSERT INTO t1(docid,words) VALUES(1002022,'And the rib, which the LORD God had taken from man, made he a woman, and brought her unto the man.');
+INSERT INTO t1(docid,words) VALUES(1002023,'And Adam said, This is now bone of my bones, and flesh of my flesh: she shall be called Woman, because she was taken out of Man.');
+INSERT INTO t1(docid,words) VALUES(1002024,'Therefore shall a man leave his father and his mother, and shall cleave unto his wife: and they shall be one flesh.');
+INSERT INTO t1(docid,words) VALUES(1002025,'And they were both naked, the man and his wife, and were not ashamed.');
+INSERT INTO t1(docid,words) VALUES(1003001,'Now the serpent was more subtil than any beast of the field which the LORD God had made. And he said unto the woman, Yea, hath God said, Ye shall not eat of every tree of the garden?');
+INSERT INTO t1(docid,words) VALUES(1003002,'And the woman said unto the serpent, We may eat of the fruit of the trees of the garden:');
+INSERT INTO t1(docid,words) VALUES(1003003,'But of the fruit of the tree which is in the midst of the garden, God hath said, Ye shall not eat of it, neither shall ye touch it, lest ye die.');
+INSERT INTO t1(docid,words) VALUES(1003004,'And the serpent said unto the woman, Ye shall not surely die:');
+INSERT INTO t1(docid,words) VALUES(1003005,'For God doth know that in the day ye eat thereof, then your eyes shall be opened, and ye shall be as gods, knowing good and evil.');
+INSERT INTO t1(docid,words) VALUES(1003006,'And when the woman saw that the tree was good for food, and that it was pleasant to the eyes, and a tree to be desired to make one wise, she took of the fruit thereof, and did eat, and gave also unto her husband with her; and he did eat.');
+INSERT INTO t1(docid,words) VALUES(1003007,'And the eyes of them both were opened, and they knew that they were naked; and they sewed fig leaves together, and made themselves aprons.');
+INSERT INTO t1(docid,words) VALUES(1003008,'And they heard the voice of the LORD God walking in the garden in the cool of the day: and Adam and his wife hid themselves from the presence of the LORD God amongst the trees of the garden.');
+INSERT INTO t1(docid,words) VALUES(1003009,'And the LORD God called unto Adam, and said unto him, Where art thou?');
+INSERT INTO t1(docid,words) VALUES(1003010,'And he said, I heard thy voice in the garden, and I was afraid, because I was naked; and I hid myself.');
+INSERT INTO t1(docid,words) VALUES(1003011,'And he said, Who told thee that thou wast naked? Hast thou eaten of the tree, whereof I commanded thee that thou shouldest not eat?');
+INSERT INTO t1(docid,words) VALUES(1003012,'And the man said, The woman whom thou gavest to be with me, she gave me of the tree, and I did eat.');
+INSERT INTO t1(docid,words) VALUES(1003013,'And the LORD God said unto the woman, What is this that thou hast done? And the woman said, The serpent beguiled me, and I did eat.');
+INSERT INTO t1(docid,words) VALUES(1003014,'And the LORD God said unto the serpent, Because thou hast done this, thou art cursed above all cattle, and above every beast of the field; upon thy belly shalt thou go, and dust shalt thou eat all the days of thy life:');
+INSERT INTO t1(docid,words) VALUES(1003015,'And I will put enmity between thee and the woman, and between thy seed and her seed; it shall bruise thy head, and thou shalt bruise his heel.');
+INSERT INTO t1(docid,words) VALUES(1003016,'Unto the woman he said, I will greatly multiply thy sorrow and thy conception; in sorrow thou shalt bring forth children; and thy desire shall be to thy husband, and he shall rule over thee.');
+INSERT INTO t1(docid,words) VALUES(1003017,'And unto Adam he said, Because thou hast hearkened unto the voice of thy wife, and hast eaten of the tree, of which I commanded thee, saying, Thou shalt not eat of it: cursed is the ground for thy sake; in sorrow shalt thou eat of it all the days of thy life;');
+INSERT INTO t1(docid,words) VALUES(1003018,'Thorns also and thistles shall it bring forth to thee; and thou shalt eat the herb of the field;');
+INSERT INTO t1(docid,words) VALUES(1003019,'In the sweat of thy face shalt thou eat bread, till thou return unto the ground; for out of it wast thou taken: for dust thou art, and unto dust shalt thou return.');
+INSERT INTO t1(docid,words) VALUES(1003020,'And Adam called his wife''s name Eve; because she was the mother of all living.');
+INSERT INTO t1(docid,words) VALUES(1003021,'Unto Adam also and to his wife did the LORD God make coats of skins, and clothed them.');
+INSERT INTO t1(docid,words) VALUES(1003022,'And the LORD God said, Behold, the man is become as one of us, to know good and evil: and now, lest he put forth his hand, and take also of the tree of life, and eat, and live for ever:');
+INSERT INTO t1(docid,words) VALUES(1003023,'Therefore the LORD God sent him forth from the garden of Eden, to till the ground from whence he was taken.');
+INSERT INTO t1(docid,words) VALUES(1003024,'So he drove out the man; and he placed at the east of the garden of Eden Cherubims, and a flaming sword which turned every way, to keep the way of the tree of life.');
+INSERT INTO t1(docid,words) VALUES(1004001,'And Adam knew Eve his wife; and she conceived, and bare Cain, and said, I have gotten a man from the LORD.');
+INSERT INTO t1(docid,words) VALUES(1004002,'And she again bare his brother Abel. And Abel was a keeper of sheep, but Cain was a tiller of the ground.');
+INSERT INTO t1(docid,words) VALUES(1004003,'And in process of time it came to pass, that Cain brought of the fruit of the ground an offering unto the LORD.');
+INSERT INTO t1(docid,words) VALUES(1004004,'And Abel, he also brought of the firstlings of his flock and of the fat thereof. And the LORD had respect unto Abel and to his offering:');
+INSERT INTO t1(docid,words) VALUES(1004005,'But unto Cain and to his offering he had not respect. And Cain was very wroth, and his countenance fell.');
+INSERT INTO t1(docid,words) VALUES(1004006,'And the LORD said unto Cain, Why art thou wroth? and why is thy countenance fallen?');
+INSERT INTO t1(docid,words) VALUES(1004007,'If thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth at the door. And unto thee shall be his desire, and thou shalt rule over him.');
+INSERT INTO t1(docid,words) VALUES(1004008,'And Cain talked with Abel his brother: and it came to pass, when they were in the field, that Cain rose up against Abel his brother, and slew him.');
+INSERT INTO t1(docid,words) VALUES(1004009,'And the LORD said unto Cain, Where is Abel thy brother? And he said, I know not: Am I my brother''s keeper?');
+INSERT INTO t1(docid,words) VALUES(1004010,'And he said, What hast thou done? the voice of thy brother''s blood crieth unto me from the ground.');
+INSERT INTO t1(docid,words) VALUES(1004011,'And now art thou cursed from the earth, which hath opened her mouth to receive thy brother''s blood from thy hand;');
+INSERT INTO t1(docid,words) VALUES(1004012,'When thou tillest the ground, it shall not henceforth yield unto thee her strength; a fugitive and a vagabond shalt thou be in the earth.');
+INSERT INTO t1(docid,words) VALUES(1004013,'And Cain said unto the LORD, My punishment is greater than I can bear.');
+INSERT INTO t1(docid,words) VALUES(1004014,'Behold, thou hast driven me out this day from the face of the earth; and from thy face shall I be hid; and I shall be a fugitive and a vagabond in the earth; and it shall come to pass, that every one that findeth me shall slay me.');
+INSERT INTO t1(docid,words) VALUES(1004015,'And the LORD said unto him, Therefore whosoever slayeth Cain, vengeance shall be taken on him sevenfold. And the LORD set a mark upon Cain, lest any finding him should kill him.');
+INSERT INTO t1(docid,words) VALUES(1004016,'And Cain went out from the presence of the LORD, and dwelt in the land of Nod, on the east of Eden.');
+INSERT INTO t1(docid,words) VALUES(1004017,'And Cain knew his wife; and she conceived, and bare Enoch: and he builded a city, and called the name of the city, after the name of his son, Enoch.');
+INSERT INTO t1(docid,words) VALUES(1004018,'And unto Enoch was born Irad: and Irad begat Mehujael: and Mehujael begat Methusael: and Methusael begat Lamech.');
+INSERT INTO t1(docid,words) VALUES(1004019,'And Lamech took unto him two wives: the name of the one was Adah, and the name of the other Zillah.');
+INSERT INTO t1(docid,words) VALUES(1004020,'And Adah bare Jabal: he was the father of such as dwell in tents, and of such as have cattle.');
+INSERT INTO t1(docid,words) VALUES(1004021,'And his brother''s name was Jubal: he was the father of all such as handle the harp and organ.');
+INSERT INTO t1(docid,words) VALUES(1004022,'And Zillah, she also bare Tubalcain, an instructer of every artificer in brass and iron: and the sister of Tubalcain was Naamah.');
+INSERT INTO t1(docid,words) VALUES(1004023,'And Lamech said unto his wives, Adah and Zillah, Hear my voice; ye wives of Lamech, hearken unto my speech: for I have slain a man to my wounding, and a young man to my hurt.');
+INSERT INTO t1(docid,words) VALUES(1004024,'If Cain shall be avenged sevenfold, truly Lamech seventy and sevenfold.');
+INSERT INTO t1(docid,words) VALUES(1004025,'And Adam knew his wife again; and she bare a son, and called his name Seth: For God, said she, hath appointed me another seed instead of Abel, whom Cain slew.');
+INSERT INTO t1(docid,words) VALUES(1004026,'And to Seth, to him also there was born a son; and he called his name Enos: then began men to call upon the name of the LORD.');
+INSERT INTO t1(docid,words) VALUES(1005001,'This is the book of the generations of Adam. In the day that God created man, in the likeness of God made he him;');
+INSERT INTO t1(docid,words) VALUES(1005002,'Male and female created he them; and blessed them, and called their name Adam, in the day when they were created.');
+INSERT INTO t1(docid,words) VALUES(1005003,'And Adam lived an hundred and thirty years, and begat a son in his own likeness, and after his image; and called his name Seth:');
+INSERT INTO t1(docid,words) VALUES(1005004,'And the days of Adam after he had begotten Seth were eight hundred years: and he begat sons and daughters:');
+INSERT INTO t1(docid,words) VALUES(1005005,'And all the days that Adam lived were nine hundred and thirty years: and he died.');
+INSERT INTO t1(docid,words) VALUES(1005006,'And Seth lived an hundred and five years, and begat Enos:');
+INSERT INTO t1(docid,words) VALUES(1005007,'And Seth lived after he begat Enos eight hundred and seven years, and begat sons and daughters:');
+INSERT INTO t1(docid,words) VALUES(1005008,'And all the days of Seth were nine hundred and twelve years: and he died.');
+INSERT INTO t1(docid,words) VALUES(1005009,'And Enos lived ninety years, and begat Cainan:');
+INSERT INTO t1(docid,words) VALUES(1005010,'And Enos lived after he begat Cainan eight hundred and fifteen years, and begat sons and daughters:');
+INSERT INTO t1(docid,words) VALUES(1005011,'And all the days of Enos were nine hundred and five years: and he died.');
+INSERT INTO t1(docid,words) VALUES(1005012,'And Cainan lived seventy years and begat Mahalaleel:');
+INSERT INTO t1(docid,words) VALUES(1005013,'And Cainan lived after he begat Mahalaleel eight hundred and forty years, and begat sons and daughters:');
+INSERT INTO t1(docid,words) VALUES(1005014,'And all the days of Cainan were nine hundred and ten years: and he died.');
+INSERT INTO t1(docid,words) VALUES(1005015,'And Mahalaleel lived sixty and five years, and begat Jared:');
+INSERT INTO t1(docid,words) VALUES(1005016,'And Mahalaleel lived after he begat Jared eight hundred and thirty years, and begat sons and daughters:');
+INSERT INTO t1(docid,words) VALUES(1005017,'And all the days of Mahalaleel were eight hundred ninety and five years: and he died.');
+INSERT INTO t1(docid,words) VALUES(1005018,'And Jared lived an hundred sixty and two years, and he begat Enoch:');
+INSERT INTO t1(docid,words) VALUES(1005019,'And Jared lived after he begat Enoch eight hundred years, and begat sons and daughters:');
+INSERT INTO t1(docid,words) VALUES(1005020,'And all the days of Jared were nine hundred sixty and two years: and he died.');
+INSERT INTO t1(docid,words) VALUES(1005021,'And Enoch lived sixty and five years, and begat Methuselah:');
+INSERT INTO t1(docid,words) VALUES(1005022,'And Enoch walked with God after he begat Methuselah three hundred years, and begat sons and daughters:');
+INSERT INTO t1(docid,words) VALUES(1005023,'And all the days of Enoch were three hundred sixty and five years:');
+INSERT INTO t1(docid,words) VALUES(1005024,'And Enoch walked with God: and he was not; for God took him.');
+INSERT INTO t1(docid,words) VALUES(1005025,'And Methuselah lived an hundred eighty and seven years, and begat Lamech.');
+INSERT INTO t1(docid,words) VALUES(1005026,'And Methuselah lived after he begat Lamech seven hundred eighty and two years, and begat sons and daughters:');
+INSERT INTO t1(docid,words) VALUES(1005027,'And all the days of Methuselah were nine hundred sixty and nine years: and he died.');
+INSERT INTO t1(docid,words) VALUES(1005028,'And Lamech lived an hundred eighty and two years, and begat a son:');
+INSERT INTO t1(docid,words) VALUES(1005029,'And he called his name Noah, saying, This same shall comfort us concerning our work and toil of our hands, because of the ground which the LORD hath cursed.');
+INSERT INTO t1(docid,words) VALUES(1005030,'And Lamech lived after he begat Noah five hundred ninety and five years, and begat sons and daughters:');
+INSERT INTO t1(docid,words) VALUES(1005031,'And all the days of Lamech were seven hundred seventy and seven years: and he died.');
+INSERT INTO t1(docid,words) VALUES(1005032,'And Noah was five hundred years old: and Noah begat Shem, Ham, and Japheth.');
+INSERT INTO t1(docid,words) VALUES(1006001,'And it came to pass, when men began to multiply on the face of the earth, and daughters were born unto them,');
+INSERT INTO t1(docid,words) VALUES(1006002,'That the sons of God saw the daughters of men that they were fair; and they took them wives of all which they chose.');
+INSERT INTO t1(docid,words) VALUES(1006003,'And the LORD said, My spirit shall not always strive with man, for that he also is flesh: yet his days shall be an hundred and twenty years.');
+INSERT INTO t1(docid,words) VALUES(1006004,'There were giants in the earth in those days; and also after that, when the sons of God came in unto the daughters of men, and they bare children to them, the same became mighty men which were of old, men of renown.');
+INSERT INTO t1(docid,words) VALUES(1006005,'And God saw that the wickedness of man was great in the earth, and that every imagination of the thoughts of his heart was only evil continually.');
+INSERT INTO t1(docid,words) VALUES(1006006,'And it repented the LORD that he had made man on the earth, and it grieved him at his heart.');
+INSERT INTO t1(docid,words) VALUES(1006007,'And the LORD said, I will destroy man whom I have created from the face of the earth; both man, and beast, and the creeping thing, and the fowls of the air; for it repenteth me that I have made them.');
+INSERT INTO t1(docid,words) VALUES(1006008,'But Noah found grace in the eyes of the LORD.');
+INSERT INTO t1(docid,words) VALUES(1006009,'These are the generations of Noah: Noah was a just man and perfect in his generations, and Noah walked with God.');
+INSERT INTO t1(docid,words) VALUES(1006010,'And Noah begat three sons, Shem, Ham, and Japheth.');
+INSERT INTO t1(docid,words) VALUES(1006011,'The earth also was corrupt before God, and the earth was filled with violence.');
+INSERT INTO t1(docid,words) VALUES(1006012,'And God looked upon the earth, and, behold, it was corrupt; for all flesh had corrupted his way upon the earth.');
+INSERT INTO t1(docid,words) VALUES(1006013,'And God said unto Noah, The end of all flesh is come before me; for the earth is filled with violence through them; and, behold, I will destroy them with the earth.');
+INSERT INTO t1(docid,words) VALUES(1006014,'Make thee an ark of gopher wood; rooms shalt thou make in the ark, and shalt pitch it within and without with pitch.');
+INSERT INTO t1(docid,words) VALUES(1006015,'And this is the fashion which thou shalt make it of: The length of the ark shall be three hundred cubits, the breadth of it fifty cubits, and the height of it thirty cubits.');
+INSERT INTO t1(docid,words) VALUES(1006016,'A window shalt thou make to the ark, and in a cubit shalt thou finish it above; and the door of the ark shalt thou set in the side thereof; with lower, second, and third stories shalt thou make it.');
+INSERT INTO t1(docid,words) VALUES(1006017,'And, behold, I, even I, do bring a flood of waters upon the earth, to destroy all flesh, wherein is the breath of life, from under heaven; and every thing that is in the earth shall die.');
+INSERT INTO t1(docid,words) VALUES(1006018,'But with thee will I establish my covenant; and thou shalt come into the ark, thou, and thy sons, and thy wife, and thy sons'' wives with thee.');
+INSERT INTO t1(docid,words) VALUES(1006019,'And of every living thing of all flesh, two of every sort shalt thou bring into the ark, to keep them alive with thee; they shall be male and female.');
+INSERT INTO t1(docid,words) VALUES(1006020,'Of fowls after their kind, and of cattle after their kind, of every creeping thing of the earth after his kind, two of every sort shall come unto thee, to keep them alive.');
+INSERT INTO t1(docid,words) VALUES(1006021,'And take thou unto thee of all food that is eaten, and thou shalt gather it to thee; and it shall be for food for thee, and for them.');
+INSERT INTO t1(docid,words) VALUES(1006022,'Thus did Noah; according to all that God commanded him, so did he.');
+INSERT INTO t1(docid,words) VALUES(1007001,'And the LORD said unto Noah, Come thou and all thy house into the ark; for thee have I seen righteous before me in this generation.');
+INSERT INTO t1(docid,words) VALUES(1007002,'Of every clean beast thou shalt take to thee by sevens, the male and his female: and of beasts that are not clean by two, the male and his female.');
+INSERT INTO t1(docid,words) VALUES(1007003,'Of fowls also of the air by sevens, the male and the female; to keep seed alive upon the face of all the earth.');
+INSERT INTO t1(docid,words) VALUES(1007004,'For yet seven days, and I will cause it to rain upon the earth forty days and forty nights; and every living substance that I have made will I destroy from off the face of the earth.');
+INSERT INTO t1(docid,words) VALUES(1007005,'And Noah did according unto all that the LORD commanded him.');
+INSERT INTO t1(docid,words) VALUES(1007006,'And Noah was six hundred years old when the flood of waters was upon the earth.');
+INSERT INTO t1(docid,words) VALUES(1007007,'And Noah went in, and his sons, and his wife, and his sons'' wives with him, into the ark, because of the waters of the flood.');
+INSERT INTO t1(docid,words) VALUES(1007008,'Of clean beasts, and of beasts that are not clean, and of fowls, and of every thing that creepeth upon the earth,');
+INSERT INTO t1(docid,words) VALUES(1007009,'There went in two and two unto Noah into the ark, the male and the female, as God had commanded Noah.');
+INSERT INTO t1(docid,words) VALUES(1007010,'And it came to pass after seven days, that the waters of the flood were upon the earth.');
+INSERT INTO t1(docid,words) VALUES(1007011,'In the six hundredth year of Noah''s life, in the second month, the seventeenth day of the month, the same day were all the fountains of the great deep broken up, and the windows of heaven were opened.');
+INSERT INTO t1(docid,words) VALUES(1007012,'And the rain was upon the earth forty days and forty nights.');
+INSERT INTO t1(docid,words) VALUES(1007013,'In the selfsame day entered Noah, and Shem, and Ham, and Japheth, the sons of Noah, and Noah''s wife, and the three wives of his sons with them, into the ark;');
+INSERT INTO t1(docid,words) VALUES(1007014,'They, and every beast after his kind, and all the cattle after their kind, and every creeping thing that creepeth upon the earth after his kind, and every fowl after his kind, every bird of every sort.');
+INSERT INTO t1(docid,words) VALUES(1007015,'And they went in unto Noah into the ark, two and two of all flesh, wherein is the breath of life.');
+INSERT INTO t1(docid,words) VALUES(1007016,'And they that went in, went in male and female of all flesh, as God had commanded him: and the LORD shut him in.');
+INSERT INTO t1(docid,words) VALUES(1007017,'And the flood was forty days upon the earth; and the waters increased, and bare up the ark, and it was lift up above the earth.');
+INSERT INTO t1(docid,words) VALUES(1007018,'And the waters prevailed, and were increased greatly upon the earth; and the ark went upon the face of the waters.');
+INSERT INTO t1(docid,words) VALUES(1007019,'And the waters prevailed exceedingly upon the earth; and all the high hills, that were under the whole heaven, were covered.');
+INSERT INTO t1(docid,words) VALUES(1007020,'Fifteen cubits upward did the waters prevail; and the mountains were covered.');
+INSERT INTO t1(docid,words) VALUES(1007021,'And all flesh died that moved upon the earth, both of fowl, and of cattle, and of beast, and of every creeping thing that creepeth upon the earth, and every man:');
+INSERT INTO t1(docid,words) VALUES(1007022,'All in whose nostrils was the breath of life, of all that was in the dry land, died.');
+INSERT INTO t1(docid,words) VALUES(1007023,'And every living substance was destroyed which was upon the face of the ground, both man, and cattle, and the creeping things, and the fowl of the heaven; and they were destroyed from the earth: and Noah only remained alive, and they that were with him in the ark.');
+INSERT INTO t1(docid,words) VALUES(1007024,'And the waters prevailed upon the earth an hundred and fifty days.');
+INSERT INTO t1(docid,words) VALUES(1008001,'And God remembered Noah, and every living thing, and all the cattle that was with him in the ark: and God made a wind to pass over the earth, and the waters asswaged;');
+INSERT INTO t1(docid,words) VALUES(1008002,'The fountains also of the deep and the windows of heaven were stopped, and the rain from heaven was restrained;');
+INSERT INTO t1(docid,words) VALUES(1008003,'And the waters returned from off the earth continually: and after the end of the hundred and fifty days the waters were abated.');
+INSERT INTO t1(docid,words) VALUES(1008004,'And the ark rested in the seventh month, on the seventeenth day of the month, upon the mountains of Ararat.');
+INSERT INTO t1(docid,words) VALUES(1008005,'And the waters decreased continually until the tenth month: in the tenth month, on the first day of the month, were the tops of the mountains seen.');
+INSERT INTO t1(docid,words) VALUES(1008006,'And it came to pass at the end of forty days, that Noah opened the window of the ark which he had made:');
+INSERT INTO t1(docid,words) VALUES(1008007,'And he sent forth a raven, which went forth to and fro, until the waters were dried up from off the earth.');
+INSERT INTO t1(docid,words) VALUES(1008008,'Also he sent forth a dove from him, to see if the waters were abated from off the face of the ground;');
+INSERT INTO t1(docid,words) VALUES(1008009,'But the dove found no rest for the sole of her foot, and she returned unto him into the ark, for the waters were on the face of the whole earth: then he put forth his hand, and took her, and pulled her in unto him into the ark.');
+INSERT INTO t1(docid,words) VALUES(1008010,'And he stayed yet other seven days; and again he sent forth the dove out of the ark;');
+INSERT INTO t1(docid,words) VALUES(1008011,'And the dove came in to him in the evening; and, lo, in her mouth was an olive leaf pluckt off: so Noah knew that the waters were abated from off the earth.');
+INSERT INTO t1(docid,words) VALUES(1008012,'And he stayed yet other seven days; and sent forth the dove; which returned not again unto him any more.');
+INSERT INTO t1(docid,words) VALUES(1008013,'And it came to pass in the six hundredth and first year, in the first month, the first day of the month, the waters were dried up from off the earth: and Noah removed the covering of the ark, and looked, and, behold, the face of the ground was dry.');
+INSERT INTO t1(docid,words) VALUES(1008014,'And in the second month, on the seven and twentieth day of the month, was the earth dried.');
+INSERT INTO t1(docid,words) VALUES(1008015,'And God spake unto Noah, saying,');
+INSERT INTO t1(docid,words) VALUES(1008016,'Go forth of the ark, thou, and thy wife, and thy sons, and thy sons'' wives with thee.');
+INSERT INTO t1(docid,words) VALUES(1008017,'Bring forth with thee every living thing that is with thee, of all flesh, both of fowl, and of cattle, and of every creeping thing that creepeth upon the earth; that they may breed abundantly in the earth, and be fruitful, and multiply upon the earth.');
+INSERT INTO t1(docid,words) VALUES(1008018,'And Noah went forth, and his sons, and his wife, and his sons'' wives with him:');
+INSERT INTO t1(docid,words) VALUES(1008019,'Every beast, every creeping thing, and every fowl, and whatsoever creepeth upon the earth, after their kinds, went forth out of the ark.');
+INSERT INTO t1(docid,words) VALUES(1008020,'And Noah builded an altar unto the LORD; and took of every clean beast, and of every clean fowl, and offered burnt offerings on the altar.');
+INSERT INTO t1(docid,words) VALUES(1008021,'And the LORD smelled a sweet savour; and the LORD said in his heart, I will not again curse the ground any more for man''s sake; for the imagination of man''s heart is evil from his youth; neither will I again smite any more every thing living, as I have done.');
+INSERT INTO t1(docid,words) VALUES(1008022,'While the earth remaineth, seedtime and harvest, and cold and heat, and summer and winter, and day and night shall not cease.');
+INSERT INTO t1(docid,words) VALUES(1009001,'And God blessed Noah and his sons, and said unto them, Be fruitful, and multiply, and replenish the earth.');
+INSERT INTO t1(docid,words) VALUES(1009002,'And the fear of you and the dread of you shall be upon every beast of the earth, and upon every fowl of the air, upon all that moveth upon the earth, and upon all the fishes of the sea; into your hand are they delivered.');
+INSERT INTO t1(docid,words) VALUES(1009003,'Every moving thing that liveth shall be meat for you; even as the green herb have I given you all things.');
+INSERT INTO t1(docid,words) VALUES(1009004,'But flesh with the life thereof, which is the blood thereof, shall ye not eat.');
+INSERT INTO t1(docid,words) VALUES(1009005,'And surely your blood of your lives will I require; at the hand of every beast will I require it, and at the hand of man; at the hand of every man''s brother will I require the life of man.');
+INSERT INTO t1(docid,words) VALUES(1009006,'Whoso sheddeth man''s blood, by man shall his blood be shed: for in the image of God made he man.');
+INSERT INTO t1(docid,words) VALUES(1009007,'And you, be ye fruitful, and multiply; bring forth abundantly in the earth, and multiply therein.');
+INSERT INTO t1(docid,words) VALUES(1009008,'And God spake unto Noah, and to his sons with him, saying,');
+INSERT INTO t1(docid,words) VALUES(1009009,'And I, behold, I establish my covenant with you, and with your seed after you;');
+INSERT INTO t1(docid,words) VALUES(1009010,'And with every living creature that is with you, of the fowl, of the cattle, and of every beast of the earth with you; from all that go out of the ark, to every beast of the earth.');
+INSERT INTO t1(docid,words) VALUES(1009011,'And I will establish my covenant with you, neither shall all flesh be cut off any more by the waters of a flood; neither shall there any more be a flood to destroy the earth.');
+INSERT INTO t1(docid,words) VALUES(1009012,'And God said, This is the token of the covenant which I make between me and you and every living creature that is with you, for perpetual generations:');
+INSERT INTO t1(docid,words) VALUES(1009013,'I do set my bow in the cloud, and it shall be for a token of a covenant between me and the earth.');
+INSERT INTO t1(docid,words) VALUES(1009014,'And it shall come to pass, when I bring a cloud over the earth, that the bow shall be seen in the cloud:');
+INSERT INTO t1(docid,words) VALUES(1009015,'And I will remember my covenant, which is between me and you and every living creature of all flesh; and the waters shall no more become a flood to destroy all flesh.');
+INSERT INTO t1(docid,words) VALUES(1009016,'And the bow shall be in the cloud; and I will look upon it, that I may remember the everlasting covenant between God and every living creature of all flesh that is upon the earth.');
+INSERT INTO t1(docid,words) VALUES(1009017,'And God said unto Noah, This is the token of the covenant, which I have established between me and all flesh that is upon the earth.');
+INSERT INTO t1(docid,words) VALUES(1009018,'And the sons of Noah, that went forth of the ark, were Shem, and Ham, and Japheth: and Ham is the father of Canaan.');
+INSERT INTO t1(docid,words) VALUES(1009019,'These are the three sons of Noah: and of them was the whole earth overspread.');
+INSERT INTO t1(docid,words) VALUES(1009020,'And Noah began to be an husbandman, and he planted a vineyard:');
+INSERT INTO t1(docid,words) VALUES(1009021,'And he drank of the wine, and was drunken; and he was uncovered within his tent.');
+INSERT INTO t1(docid,words) VALUES(1009022,'And Ham, the father of Canaan, saw the nakedness of his father, and told his two brethren without.');
+INSERT INTO t1(docid,words) VALUES(1009023,'And Shem and Japheth took a garment, and laid it upon both their shoulders, and went backward, and covered the nakedness of their father; and their faces were backward, and they saw not their father''s nakedness.');
+INSERT INTO t1(docid,words) VALUES(1009024,'And Noah awoke from his wine, and knew what his younger son had done unto him.');
+INSERT INTO t1(docid,words) VALUES(1009025,'And he said, Cursed be Canaan; a servant of servants shall he be unto his brethren.');
+INSERT INTO t1(docid,words) VALUES(1009026,'And he said, Blessed be the LORD God of Shem; and Canaan shall be his servant.');
+INSERT INTO t1(docid,words) VALUES(1009027,'God shall enlarge Japheth, and he shall dwell in the tents of Shem; and Canaan shall be his servant.');
+INSERT INTO t1(docid,words) VALUES(1009028,'And Noah lived after the flood three hundred and fifty years.');
+INSERT INTO t1(docid,words) VALUES(1009029,'And all the days of Noah were nine hundred and fifty years: and he died.');
+INSERT INTO t1(docid,words) VALUES(1010001,'Now these are the generations of the sons of Noah, Shem, Ham, and Japheth: and unto them were sons born after the flood.');
+INSERT INTO t1(docid,words) VALUES(1010002,'The sons of Japheth; Gomer, and Magog, and Madai, and Javan, and Tubal, and Meshech, and Tiras.');
+INSERT INTO t1(docid,words) VALUES(1010003,'And the sons of Gomer; Ashkenaz, and Riphath, and Togarmah.');
+INSERT INTO t1(docid,words) VALUES(1010004,'And the sons of Javan; Elishah, and Tarshish, Kittim, and Dodanim.');
+INSERT INTO t1(docid,words) VALUES(1010005,'By these were the isles of the Gentiles divided in their lands; every one after his tongue, after their families, in their nations.');
+INSERT INTO t1(docid,words) VALUES(1010006,'And the sons of Ham; Cush, and Mizraim, and Phut, and Canaan.');
+INSERT INTO t1(docid,words) VALUES(1010007,'And the sons of Cush; Seba, and Havilah, and Sabtah, and Raamah, and Sabtechah: and the sons of Raamah; Sheba, and Dedan.');
+INSERT INTO t1(docid,words) VALUES(1010008,'And Cush begat Nimrod: he began to be a mighty one in the earth.');
+INSERT INTO t1(docid,words) VALUES(1010009,'He was a mighty hunter before the LORD: wherefore it is said, Even as Nimrod the mighty hunter before the LORD.');
+INSERT INTO t1(docid,words) VALUES(1010010,'And the beginning of his kingdom was Babel, and Erech, and Accad, and Calneh, in the land of Shinar.');
+INSERT INTO t1(docid,words) VALUES(1010011,'Out of that land went forth Asshur, and builded Nineveh, and the city Rehoboth, and Calah,');
+INSERT INTO t1(docid,words) VALUES(1010012,'And Resen between Nineveh and Calah: the same is a great city.');
+INSERT INTO t1(docid,words) VALUES(1010013,'And Mizraim begat Ludim, and Anamim, and Lehabim, and Naphtuhim,');
+INSERT INTO t1(docid,words) VALUES(1010014,'And Pathrusim, and Casluhim, (out of whom came Philistim,) and Caphtorim.');
+INSERT INTO t1(docid,words) VALUES(1010015,'And Canaan begat Sidon his first born, and Heth,');
+INSERT INTO t1(docid,words) VALUES(1010016,'And the Jebusite, and the Amorite, and the Girgasite,');
+INSERT INTO t1(docid,words) VALUES(1010017,'And the Hivite, and the Arkite, and the Sinite,');
+INSERT INTO t1(docid,words) VALUES(1010018,'And the Arvadite, and the Zemarite, and the Hamathite: and afterward were the families of the Canaanites spread abroad.');
+INSERT INTO t1(docid,words) VALUES(1010019,'And the border of the Canaanites was from Sidon, as thou comest to Gerar, unto Gaza; as thou goest, unto Sodom, and Gomorrah, and Admah, and Zeboim, even unto Lasha.');
+INSERT INTO t1(docid,words) VALUES(1010020,'These are the sons of Ham, after their families, after their tongues, in their countries, and in their nations.');
+INSERT INTO t1(docid,words) VALUES(1010021,'Unto Shem also, the father of all the children of Eber, the brother of Japheth the elder, even to him were children born.');
+INSERT INTO t1(docid,words) VALUES(1010022,'The children of Shem; Elam, and Asshur, and Arphaxad, and Lud, and Aram.');
+INSERT INTO t1(docid,words) VALUES(1010023,'And the children of Aram; Uz, and Hul, and Gether, and Mash.');
+INSERT INTO t1(docid,words) VALUES(1010024,'And Arphaxad begat Salah; and Salah begat Eber.');
+INSERT INTO t1(docid,words) VALUES(1010025,'And unto Eber were born two sons: the name of one was Peleg; for in his days was the earth divided; and his brother''s name was Joktan.');
+INSERT INTO t1(docid,words) VALUES(1010026,'And Joktan begat Almodad, and Sheleph, and Hazarmaveth, and Jerah,');
+INSERT INTO t1(docid,words) VALUES(1010027,'And Hadoram, and Uzal, and Diklah,');
+INSERT INTO t1(docid,words) VALUES(1010028,'And Obal, and Abimael, and Sheba,');
+INSERT INTO t1(docid,words) VALUES(1010029,'And Ophir, and Havilah, and Jobab: all these were the sons of Joktan.');
+INSERT INTO t1(docid,words) VALUES(1010030,'And their dwelling was from Mesha, as thou goest unto Sephar a mount of the east.');
+INSERT INTO t1(docid,words) VALUES(1010031,'These are the sons of Shem, after their families, after their tongues, in their lands, after their nations.');
+INSERT INTO t1(docid,words) VALUES(1010032,'These are the families of the sons of Noah, after their generations, in their nations: and by these were the nations divided in the earth after the flood.');
+INSERT INTO t1(docid,words) VALUES(1011001,'And the whole earth was of one language, and of one speech.');
+INSERT INTO t1(docid,words) VALUES(1011002,'And it came to pass, as they journeyed from the east, that they found a plain in the land of Shinar; and they dwelt there.');
+INSERT INTO t1(docid,words) VALUES(1011003,'And they said one to another, Go to, let us make brick, and burn them thoroughly. And they had brick for stone, and slime had they for morter.');
+INSERT INTO t1(docid,words) VALUES(1011004,'And they said, Go to, let us build us a city and a tower, whose top may reach unto heaven; and let us make us a name, lest we be scattered abroad upon the face of the whole earth.');
+INSERT INTO t1(docid,words) VALUES(1011005,'And the LORD came down to see the city and the tower, which the children of men builded.');
+INSERT INTO t1(docid,words) VALUES(1011006,'And the LORD said, Behold, the people is one, and they have all one language; and this they begin to do: and now nothing will be restrained from them, which they have imagined to do.');
+INSERT INTO t1(docid,words) VALUES(1011007,'Go to, let us go down, and there confound their language, that they may not understand one another''s speech.');
+INSERT INTO t1(docid,words) VALUES(1011008,'So the LORD scattered them abroad from thence upon the face of all the earth: and they left off to build the city.');
+INSERT INTO t1(docid,words) VALUES(1011009,'Therefore is the name of it called Babel; because the LORD did there confound the language of all the earth: and from thence did the LORD scatter them abroad upon the face of all the earth.');
+INSERT INTO t1(docid,words) VALUES(1011010,'These are the generations of Shem: Shem was an hundred years old, and begat Arphaxad two years after the flood:');
+INSERT INTO t1(docid,words) VALUES(1011011,'And Shem lived after he begat Arphaxad five hundred years, and begat sons and daughters.');
+INSERT INTO t1(docid,words) VALUES(1011012,'And Arphaxad lived five and thirty years, and begat Salah:');
+INSERT INTO t1(docid,words) VALUES(1011013,'And Arphaxad lived after he begat Salah four hundred and three years, and begat sons and daughters.');
+INSERT INTO t1(docid,words) VALUES(1011014,'And Salah lived thirty years, and begat Eber:');
+INSERT INTO t1(docid,words) VALUES(1011015,'And Salah lived after he begat Eber four hundred and three years, and begat sons and daughters.');
+INSERT INTO t1(docid,words) VALUES(1011016,'And Eber lived four and thirty years, and begat Peleg:');
+INSERT INTO t1(docid,words) VALUES(1011017,'And Eber lived after he begat Peleg four hundred and thirty years, and begat sons and daughters.');
+INSERT INTO t1(docid,words) VALUES(1011018,'And Peleg lived thirty years, and begat Reu:');
+INSERT INTO t1(docid,words) VALUES(1011019,'And Peleg lived after he begat Reu two hundred and nine years, and begat sons and daughters.');
+INSERT INTO t1(docid,words) VALUES(1011020,'And Reu lived two and thirty years, and begat Serug:');
+INSERT INTO t1(docid,words) VALUES(1011021,'And Reu lived after he begat Serug two hundred and seven years, and begat sons and daughters.');
+INSERT INTO t1(docid,words) VALUES(1011022,'And Serug lived thirty years, and begat Nahor:');
+INSERT INTO t1(docid,words) VALUES(1011023,'And Serug lived after he begat Nahor two hundred years, and begat sons and daughters.');
+INSERT INTO t1(docid,words) VALUES(1011024,'And Nahor lived nine and twenty years, and begat Terah:');
+INSERT INTO t1(docid,words) VALUES(1011025,'And Nahor lived after he begat Terah an hundred and nineteen years, and begat sons and daughters.');
+INSERT INTO t1(docid,words) VALUES(1011026,'And Terah lived seventy years, and begat Abram, Nahor, and Haran.');
+INSERT INTO t1(docid,words) VALUES(1011027,'Now these are the generations of Terah: Terah begat Abram, Nahor, and Haran; and Haran begat Lot.');
+INSERT INTO t1(docid,words) VALUES(1011028,'And Haran died before his father Terah in the land of his nativity, in Ur of the Chaldees.');
+INSERT INTO t1(docid,words) VALUES(1011029,'And Abram and Nahor took them wives: the name of Abram''s wife was Sarai; and the name of Nahor''s wife, Milcah, the daughter of Haran, the father of Milcah, and the father of Iscah.');
+INSERT INTO t1(docid,words) VALUES(1011030,'But Sarai was barren; she had no child.');
+INSERT INTO t1(docid,words) VALUES(1011031,'And Terah took Abram his son, and Lot the son of Haran his son''s son, and Sarai his daughter in law, his son Abram''s wife; and they went forth with them from Ur of the Chaldees, to go into the land of Canaan; and they came unto Haran, and dwelt there.');
+INSERT INTO t1(docid,words) VALUES(1011032,'And the days of Terah were two hundred and five years: and Terah died in Haran.');
+INSERT INTO t1(docid,words) VALUES(1012001,'Now the LORD had said unto Abram, Get thee out of thy country, and from thy kindred, and from thy father''s house, unto a land that I will shew thee:');
+INSERT INTO t1(docid,words) VALUES(1012002,'And I will make of thee a great nation, and I will bless thee, and make thy name great; and thou shalt be a blessing:');
+INSERT INTO t1(docid,words) VALUES(1012003,'And I will bless them that bless thee, and curse him that curseth thee: and in thee shall all families of the earth be blessed.');
+INSERT INTO t1(docid,words) VALUES(1012004,'So Abram departed, as the LORD had spoken unto him; and Lot went with him: and Abram was seventy and five years old when he departed out of Haran.');
+INSERT INTO t1(docid,words) VALUES(1012005,'And Abram took Sarai his wife, and Lot his brother''s son, and all their substance that they had gathered, and the souls that they had gotten in Haran; and they went forth to go into the land of Canaan; and into the land of Canaan they came.');
+INSERT INTO t1(docid,words) VALUES(1012006,'And Abram passed through the land unto the place of Sichem, unto the plain of Moreh. And the Canaanite was then in the land.');
+INSERT INTO t1(docid,words) VALUES(1012007,'And the LORD appeared unto Abram, and said, Unto thy seed will I give this land: and there builded he an altar unto the LORD, who appeared unto him.');
+INSERT INTO t1(docid,words) VALUES(1012008,'And he removed from thence unto a mountain on the east of Bethel, and pitched his tent, having Bethel on the west, and Hai on the east: and there he builded an altar unto the LORD, and called upon the name of the LORD.');
+INSERT INTO t1(docid,words) VALUES(1012009,'And Abram journeyed, going on still toward the south.');
+INSERT INTO t1(docid,words) VALUES(1012010,'And there was a famine in the land: and Abram went down into Egypt to sojourn there; for the famine was grievous in the land.');
+INSERT INTO t1(docid,words) VALUES(1012011,'And it came to pass, when he was come near to enter into Egypt, that he said unto Sarai his wife, Behold now, I know that thou art a fair woman to look upon:');
+INSERT INTO t1(docid,words) VALUES(1012012,'Therefore it shall come to pass, when the Egyptians shall see thee, that they shall say, This is his wife: and they will kill me, but they will save thee alive.');
+INSERT INTO t1(docid,words) VALUES(1012013,'Say, I pray thee, thou art my sister: that it may be well with me for thy sake; and my soul shall live because of thee.');
+INSERT INTO t1(docid,words) VALUES(1012014,'And it came to pass, that, when Abram was come into Egypt, the Egyptians beheld the woman that she was very fair.');
+INSERT INTO t1(docid,words) VALUES(1012015,'The princes also of Pharaoh saw her, and commended her before Pharaoh: and the woman was taken into Pharaoh''s house.');
+INSERT INTO t1(docid,words) VALUES(1012016,'And he entreated Abram well for her sake: and he had sheep, and oxen, and he asses, and menservants, and maidservants, and she asses, and camels.');
+INSERT INTO t1(docid,words) VALUES(1012017,'And the LORD plagued Pharaoh and his house with great plagues because of Sarai Abram''s wife.');
+INSERT INTO t1(docid,words) VALUES(1012018,'And Pharaoh called Abram and said, What is this that thou hast done unto me? why didst thou not tell me that she was thy wife?');
+INSERT INTO t1(docid,words) VALUES(1012019,'Why saidst thou, She is my sister? so I might have taken her to me to wife: now therefore behold thy wife, take her, and go thy way.');
+INSERT INTO t1(docid,words) VALUES(1012020,'And Pharaoh commanded his men concerning him: and they sent him away, and his wife, and all that he had.');
+INSERT INTO t1(docid,words) VALUES(1013001,'And Abram went up out of Egypt, he, and his wife, and all that he had, and Lot with him, into the south.');
+INSERT INTO t1(docid,words) VALUES(1013002,'And Abram was very rich in cattle, in silver, and in gold.');
+INSERT INTO t1(docid,words) VALUES(1013003,'And he went on his journeys from the south even to Bethel, unto the place where his tent had been at the beginning, between Bethel and Hai;');
+INSERT INTO t1(docid,words) VALUES(1013004,'Unto the place of the altar, which he had make there at the first: and there Abram called on the name of the LORD.');
+INSERT INTO t1(docid,words) VALUES(1013005,'And Lot also, which went with Abram, had flocks, and herds, and tents.');
+INSERT INTO t1(docid,words) VALUES(1013006,'And the land was not able to bear them, that they might dwell together: for their substance was great, so that they could not dwell together.');
+INSERT INTO t1(docid,words) VALUES(1013007,'And there was a strife between the herdmen of Abram''s cattle and the herdmen of Lot''s cattle: and the Canaanite and the Perizzite dwelled then in the land.');
+INSERT INTO t1(docid,words) VALUES(1013008,'And Abram said unto Lot, Let there be no strife, I pray thee, between me and thee, and between my herdmen and thy herdmen; for we be brethren.');
+INSERT INTO t1(docid,words) VALUES(1013009,'Is not the whole land before thee? separate thyself, I pray thee, from me: if thou wilt take the left hand, then I will go to the right; or if thou depart to the right hand, then I will go to the left.');
+INSERT INTO t1(docid,words) VALUES(1013010,'And Lot lifted up his eyes, and beheld all the plain of Jordan, that it was well watered every where, before the LORD destroyed Sodom and Gomorrah, even as the garden of the LORD, like the land of Egypt, as thou comest unto Zoar.');
+INSERT INTO t1(docid,words) VALUES(1013011,'Then Lot chose him all the plain of Jordan; and Lot journeyed east: and they separated themselves the one from the other.');
+INSERT INTO t1(docid,words) VALUES(1013012,'Abram dwelled in the land of Canaan, and Lot dwelled in the cities of the plain, and pitched his tent toward Sodom.');
+INSERT INTO t1(docid,words) VALUES(1013013,'But the men of Sodom were wicked and sinners before the LORD exceedingly.');
+INSERT INTO t1(docid,words) VALUES(1013014,'And the LORD said unto Abram, after that Lot was separated from him, Lift up now thine eyes, and look from the place where thou art northward, and southward, and eastward, and westward:');
+INSERT INTO t1(docid,words) VALUES(1013015,'For all the land which thou seest, to thee will I give it, and to thy seed for ever.');
+INSERT INTO t1(docid,words) VALUES(1013016,'And I will make thy seed as the dust of the earth: so that if a man can number the dust of the earth, then shall thy seed also be numbered.');
+INSERT INTO t1(docid,words) VALUES(1013017,'Arise, walk through the land in the length of it and in the breadth of it; for I will give it unto thee.');
+INSERT INTO t1(docid,words) VALUES(1013018,'Then Abram removed his tent, and came and dwelt in the plain of Mamre, which is in Hebron, and built there an altar unto the LORD.');
+INSERT INTO t1(docid,words) VALUES(1014001,'And it came to pass in the days of Amraphel king of Shinar, Arioch king of Ellasar, Chedorlaomer king of Elam, and Tidal king of nations;');
+INSERT INTO t1(docid,words) VALUES(1014002,'That these made war with Bera king of Sodom, and with Birsha king of Gomorrah, Shinab king of Admah, and Shemeber king of Zeboiim, and the king of Bela, which is Zoar.');
+INSERT INTO t1(docid,words) VALUES(1014003,'All these were joined together in the vale of Siddim, which is the salt sea.');
+INSERT INTO t1(docid,words) VALUES(1014004,'Twelve years they served Chedorlaomer, and in the thirteenth year they rebelled.');
+INSERT INTO t1(docid,words) VALUES(1014005,'And in the fourteenth year came Chedorlaomer, and the kings that were with him, and smote the Rephaims in Ashteroth Karnaim, and the Zuzims in Ham, and the Emins in Shaveh Kiriathaim,');
+INSERT INTO t1(docid,words) VALUES(1014006,'And the Horites in their mount Seir, unto Elparan, which is by the wilderness.');
+INSERT INTO t1(docid,words) VALUES(1014007,'And they returned, and came to Enmishpat, which is Kadesh, and smote all the country of the Amalekites, and also the Amorites, that dwelt in Hazezontamar.');
+INSERT INTO t1(docid,words) VALUES(1014008,'And there went out the king of Sodom, and the king of Gomorrah, and the king of Admah, and the king of Zeboiim, and the king of Bela (the same is Zoar;) and they joined battle with them in the vale of Siddim;');
+INSERT INTO t1(docid,words) VALUES(1014009,'With Chedorlaomer the king of Elam, and with Tidal king of nations, and Amraphel king of Shinar, and Arioch king of Ellasar; four kings with five.');
+INSERT INTO t1(docid,words) VALUES(1014010,'And the vale of Siddim was full of slimepits; and the kings of Sodom and Gomorrah fled, and fell there; and they that remained fled to the mountain.');
+INSERT INTO t1(docid,words) VALUES(1014011,'And they took all the goods of Sodom and Gomorrah, and all their victuals, and went their way.');
+INSERT INTO t1(docid,words) VALUES(1014012,'And they took Lot, Abram''s brother''s son, who dwelt in Sodom, and his goods, and departed.');
+INSERT INTO t1(docid,words) VALUES(1014013,'And there came one that had escaped, and told Abram the Hebrew; for he dwelt in the plain of Mamre the Amorite, brother of Eshcol, and brother of Aner: and these were confederate with Abram.');
+INSERT INTO t1(docid,words) VALUES(1014014,'And when Abram heard that his brother was taken captive, he armed his trained servants, born in his own house, three hundred and eighteen, and pursued them unto Dan.');
+INSERT INTO t1(docid,words) VALUES(1014015,'And he divided himself against them, he and his servants, by night, and smote them, and pursued them unto Hobah, which is on the left hand of Damascus.');
+INSERT INTO t1(docid,words) VALUES(1014016,'And he brought back all the goods, and also brought again his brother Lot, and his goods, and the women also, and the people.');
+INSERT INTO t1(docid,words) VALUES(1014017,'And the king of Sodom went out to meet him after his return from the slaughter of Chedorlaomer, and of the kings that were with him, at the valley of Shaveh, which is the king''s dale.');
+INSERT INTO t1(docid,words) VALUES(1014018,'And Melchizedek king of Salem brought forth bread and wine: and he was the priest of the most high God.');
+INSERT INTO t1(docid,words) VALUES(1014019,'And he blessed him, and said, Blessed be Abram of the most high God, possessor of heaven and earth:');
+INSERT INTO t1(docid,words) VALUES(1014020,'And blessed be the most high God, which hath delivered thine enemies into thy hand. And he gave him tithes of all.');
+INSERT INTO t1(docid,words) VALUES(1014021,'And the king of Sodom said unto Abram, Give me the persons, and take the goods to thyself.');
+INSERT INTO t1(docid,words) VALUES(1014022,'And Abram said to the king of Sodom, I have lift up mine hand unto the LORD, the most high God, the possessor of heaven and earth,');
+INSERT INTO t1(docid,words) VALUES(1014023,'That I will not take from a thread even to a shoelatchet, and that I will not take any thing that is thine, lest thou shouldest say, I have made Abram rich:');
+INSERT INTO t1(docid,words) VALUES(1014024,'Save only that which the young men have eaten, and the portion of the men which went with me, Aner, Eshcol, and Mamre; let them take their portion.');
+INSERT INTO t1(docid,words) VALUES(1015001,'After these things the word of the LORD came unto Abram in a vision, saying, Fear not, Abram: I am thy shield, and thy exceeding great reward.');
+INSERT INTO t1(docid,words) VALUES(1015002,'And Abram said, LORD God, what wilt thou give me, seeing I go childless, and the steward of my house is this Eliezer of Damascus?');
+INSERT INTO t1(docid,words) VALUES(1015003,'And Abram said, Behold, to me thou hast given no seed: and, lo, one born in my house is mine heir.');
+INSERT INTO t1(docid,words) VALUES(1015004,'And, behold, the word of the LORD came unto him, saying, This shall not be thine heir; but he that shall come forth out of thine own bowels shall be thine heir.');
+INSERT INTO t1(docid,words) VALUES(1015005,'And he brought him forth abroad, and said, Look now toward heaven, and tell the stars, if thou be able to number them: and he said unto him, So shall thy seed be.');
+INSERT INTO t1(docid,words) VALUES(1015006,'And he believed in the LORD; and he counted it to him for righteousness.');
+INSERT INTO t1(docid,words) VALUES(1015007,'And he said unto him, I am the LORD that brought thee out of Ur of the Chaldees, to give thee this land to inherit it.');
+INSERT INTO t1(docid,words) VALUES(1015008,'And he said, LORD God, whereby shall I know that I shall inherit it?');
+INSERT INTO t1(docid,words) VALUES(1015009,'And he said unto him, Take me an heifer of three years old, and a she goat of three years old, and a ram of three years old, and a turtledove, and a young pigeon.');
+INSERT INTO t1(docid,words) VALUES(1015010,'And he took unto him all these, and divided them in the midst, and laid each piece one against another: but the birds divided he not.');
+INSERT INTO t1(docid,words) VALUES(1015011,'And when the fowls came down upon the carcases, Abram drove them away.');
+INSERT INTO t1(docid,words) VALUES(1015012,'And when the sun was going down, a deep sleep fell upon Abram; and, lo, an horror of great darkness fell upon him.');
+INSERT INTO t1(docid,words) VALUES(1015013,'And he said unto Abram, Know of a surety that thy seed shall be a stranger in a land that is not their''s, and shall serve them; and they shall afflict them four hundred years;');
+INSERT INTO t1(docid,words) VALUES(1015014,'And also that nation, whom they shall serve, will I judge: and afterward shall they come out with great substance.');
+INSERT INTO t1(docid,words) VALUES(1015015,'And thou shalt go to thy fathers in peace; thou shalt be buried in a good old age.');
+INSERT INTO t1(docid,words) VALUES(1015016,'But in the fourth generation they shall come hither again: for the iniquity of the Amorites is not yet full.');
+INSERT INTO t1(docid,words) VALUES(1015017,'And it came to pass, that, when the sun went down, and it was dark, behold a smoking furnace, and a burning lamp that passed between those pieces.');
+INSERT INTO t1(docid,words) VALUES(1015018,'In the same day the LORD made a covenant with Abram, saying, Unto thy seed have I given this land, from the river of Egypt unto the great river, the river Euphrates:');
+INSERT INTO t1(docid,words) VALUES(1015019,'The Kenites, and the Kenizzites, and the Kadmonites,');
+INSERT INTO t1(docid,words) VALUES(1015020,'And the Hittites, and the Perizzites, and the Rephaims,');
+INSERT INTO t1(docid,words) VALUES(1015021,'And the Amorites, and the Canaanites, and the Girgashites, and the Jebusites.');
+INSERT INTO t1(docid,words) VALUES(1016001,'Now Sarai Abram''s wife bare him no children: and she had an handmaid, an Egyptian, whose name was Hagar.');
+INSERT INTO t1(docid,words) VALUES(1016002,'And Sarai said unto Abram, Behold now, the LORD hath restrained me from bearing: I pray thee, go in unto my maid; it may be that I may obtain children by her. And Abram hearkened to the voice of Sarai.');
+INSERT INTO t1(docid,words) VALUES(1016003,'And Sarai Abram''s wife took Hagar her maid the Egyptian, after Abram had dwelt ten years in the land of Canaan, and gave her to her husband Abram to be his wife.');
+INSERT INTO t1(docid,words) VALUES(1016004,'And he went in unto Hagar, and she conceived: and when she saw that she had conceived, her mistress was despised in her eyes.');
+INSERT INTO t1(docid,words) VALUES(1016005,'And Sarai said unto Abram, My wrong be upon thee: I have given my maid into thy bosom; and when she saw that she had conceived, I was despised in her eyes: the LORD judge between me and thee.');
+INSERT INTO t1(docid,words) VALUES(1016006,'But Abram said unto Sarai, Behold, thy maid is in thine hand; do to her as it pleaseth thee. And when Sarai dealt hardly with her, she fled from her face.');
+INSERT INTO t1(docid,words) VALUES(1016007,'And the angel of the LORD found her by a fountain of water in the wilderness, by the fountain in the way to Shur.');
+INSERT INTO t1(docid,words) VALUES(1016008,'And he said, Hagar, Sarai''s maid, whence camest thou? and whither wilt thou go? And she said, I flee from the face of my mistress Sarai.');
+INSERT INTO t1(docid,words) VALUES(1016009,'And the angel of the LORD said unto her, Return to thy mistress, and submit thyself under her hands.');
+INSERT INTO t1(docid,words) VALUES(1016010,'And the angel of the LORD said unto her, I will multiply thy seed exceedingly, that it shall not be numbered for multitude.');
+INSERT INTO t1(docid,words) VALUES(1016011,'And the angel of the LORD said unto her, Behold, thou art with child and shalt bear a son, and shalt call his name Ishmael; because the LORD hath heard thy affliction.');
+INSERT INTO t1(docid,words) VALUES(1016012,'And he will be a wild man; his hand will be against every man, and every man''s hand against him; and he shall dwell in the presence of all his brethren.');
+INSERT INTO t1(docid,words) VALUES(1016013,'And she called the name of the LORD that spake unto her, Thou God seest me: for she said, Have I also here looked after him that seeth me?');
+INSERT INTO t1(docid,words) VALUES(1016014,'Wherefore the well was called Beerlahairoi; behold, it is between Kadesh and Bered.');
+INSERT INTO t1(docid,words) VALUES(1016015,'And Hagar bare Abram a son: and Abram called his son''s name, which Hagar bare, Ishmael.');
+INSERT INTO t1(docid,words) VALUES(1016016,'And Abram was fourscore and six years old, when Hagar bare Ishmael to Abram.');
+INSERT INTO t1(docid,words) VALUES(1017001,'And when Abram was ninety years old and nine, the LORD appeared to Abram, and said unto him, I am the Almighty God; walk before me, and be thou perfect.');
+INSERT INTO t1(docid,words) VALUES(1017002,'And I will make my covenant between me and thee, and will multiply thee exceedingly.');
+INSERT INTO t1(docid,words) VALUES(1017003,'And Abram fell on his face: and God talked with him, saying,');
+INSERT INTO t1(docid,words) VALUES(1017004,'As for me, behold, my covenant is with thee, and thou shalt be a father of many nations.');
+INSERT INTO t1(docid,words) VALUES(1017005,'Neither shall thy name any more be called Abram, but thy name shall be Abraham; for a father of many nations have I made thee.');
+INSERT INTO t1(docid,words) VALUES(1017006,'And I will make thee exceeding fruitful, and I will make nations of thee, and kings shall come out of thee.');
+INSERT INTO t1(docid,words) VALUES(1017007,'And I will establish my covenant between me and thee and thy seed after thee in their generations for an everlasting covenant, to be a God unto thee, and to thy seed after thee.');
+INSERT INTO t1(docid,words) VALUES(1017008,'And I will give unto thee, and to thy seed after thee, the land wherein thou art a stranger, all the land of Canaan, for an everlasting possession; and I will be their God.');
+INSERT INTO t1(docid,words) VALUES(1017009,'And God said unto Abraham, Thou shalt keep my covenant therefore, thou, and thy seed after thee in their generations.');
+INSERT INTO t1(docid,words) VALUES(1017010,'This is my covenant, which ye shall keep, between me and you and thy seed after thee; Every man child among you shall be circumcised.');
+INSERT INTO t1(docid,words) VALUES(1017011,'And ye shall circumcise the flesh of your foreskin; and it shall be a token of the covenant betwixt me and you.');
+INSERT INTO t1(docid,words) VALUES(1017012,'And he that is eight days old shall be circumcised among you, every man child in your generations, he that is born in the house, or bought with money of any stranger, which is not of thy seed.');
+INSERT INTO t1(docid,words) VALUES(1017013,'He that is born in thy house, and he that is bought with thy money, must needs be circumcised: and my covenant shall be in your flesh for an everlasting covenant.');
+INSERT INTO t1(docid,words) VALUES(1017014,'And the uncircumcised man child whose flesh of his foreskin is not circumcised, that soul shall be cut off from his people; he hath broken my covenant.');
+INSERT INTO t1(docid,words) VALUES(1017015,'And God said unto Abraham, As for Sarai thy wife, thou shalt not call her name Sarai, but Sarah shall her name be.');
+INSERT INTO t1(docid,words) VALUES(1017016,'And I will bless her, and give thee a son also of her: yea, I will bless her, and she shall be a mother of nations; kings of people shall be of her.');
+INSERT INTO t1(docid,words) VALUES(1017017,'Then Abraham fell upon his face, and laughed, and said in his heart, Shall a child be born unto him that is an hundred years old? and shall Sarah, that is ninety years old, bear?');
+INSERT INTO t1(docid,words) VALUES(1017018,'And Abraham said unto God, O that Ishmael might live before thee!');
+INSERT INTO t1(docid,words) VALUES(1017019,'And God said, Sarah thy wife shall bear thee a son indeed; and thou shalt call his name Isaac: and I will establish my covenant with him for an everlasting covenant, and with his seed after him.');
+INSERT INTO t1(docid,words) VALUES(1017020,'And as for Ishmael, I have heard thee: Behold, I have blessed him, and will make him fruitful, and will multiply him exceedingly; twelve princes shall he beget, and I will make him a great nation.');
+INSERT INTO t1(docid,words) VALUES(1017021,'But my covenant will I establish with Isaac, which Sarah shall bear unto thee at this set time in the next year.');
+INSERT INTO t1(docid,words) VALUES(1017022,'And he left off talking with him, and God went up from Abraham.');
+INSERT INTO t1(docid,words) VALUES(1017023,'And Abraham took Ishmael his son, and all that were born in his house, and all that were bought with his money, every male among the men of Abraham''s house; and circumcised the flesh of their foreskin in the selfsame day, as God had said unto him.');
+INSERT INTO t1(docid,words) VALUES(1017024,'And Abraham was ninety years old and nine, when he was circumcised in the flesh of his foreskin.');
+INSERT INTO t1(docid,words) VALUES(1017025,'And Ishmael his son was thirteen years old, when he was circumcised in the flesh of his foreskin.');
+INSERT INTO t1(docid,words) VALUES(1017026,'In the selfsame day was Abraham circumcised, and Ishmael his son.');
+INSERT INTO t1(docid,words) VALUES(1017027,'And all the men of his house, born in the house, and bought with money of the stranger, were circumcised with him.');
+INSERT INTO t1(docid,words) VALUES(1018001,'And the LORD appeared unto him in the plains of Mamre: and he sat in the tent door in the heat of the day;');
+INSERT INTO t1(docid,words) VALUES(1018002,'And he lift up his eyes and looked, and, lo, three men stood by him: and when he saw them, he ran to meet them from the tent door, and bowed himself toward the ground,');
+INSERT INTO t1(docid,words) VALUES(1018003,'And said, My LORD, if now I have found favour in thy sight, pass not away, I pray thee, from thy servant:');
+INSERT INTO t1(docid,words) VALUES(1018004,'Let a little water, I pray you, be fetched, and wash your feet, and rest yourselves under the tree:');
+INSERT INTO t1(docid,words) VALUES(1018005,'And I will fetch a morsel of bread, and comfort ye your hearts; after that ye shall pass on: for therefore are ye come to your servant. And they said, So do, as thou hast said.');
+INSERT INTO t1(docid,words) VALUES(1018006,'And Abraham hastened into the tent unto Sarah, and said, Make ready quickly three measures of fine meal, knead it, and make cakes upon the hearth.');
+INSERT INTO t1(docid,words) VALUES(1018007,'And Abraham ran unto the herd, and fetcht a calf tender and good, and gave it unto a young man; and he hasted to dress it.');
+INSERT INTO t1(docid,words) VALUES(1018008,'And he took butter, and milk, and the calf which he had dressed, and set it before them; and he stood by them under the tree, and they did eat.');
+INSERT INTO t1(docid,words) VALUES(1018009,'And they said unto him, Where is Sarah thy wife? And he said, Behold, in the tent.');
+INSERT INTO t1(docid,words) VALUES(1018010,'And he said, I will certainly return unto thee according to the time of life; and, lo, Sarah thy wife shall have a son. And Sarah heard it in the tent door, which was behind him.');
+INSERT INTO t1(docid,words) VALUES(1018011,'Now Abraham and Sarah were old and well stricken in age; and it ceased to be with Sarah after the manner of women.');
+INSERT INTO t1(docid,words) VALUES(1018012,'Therefore Sarah laughed within herself, saying, After I am waxed old shall I have pleasure, my lord being old also?');
+INSERT INTO t1(docid,words) VALUES(1018013,'And the LORD said unto Abraham, Wherefore did Sarah laugh, saying, Shall I of a surety bear a child, which am old?');
+INSERT INTO t1(docid,words) VALUES(1018014,'Is any thing too hard for the LORD? At the time appointed I will return unto thee, according to the time of life, and Sarah shall have a son.');
+INSERT INTO t1(docid,words) VALUES(1018015,'Then Sarah denied, saying, I laughed not; for she was afraid. And he said, Nay; but thou didst laugh.');
+INSERT INTO t1(docid,words) VALUES(1018016,'And the men rose up from thence, and looked toward Sodom: and Abraham went with them to bring them on the way.');
+INSERT INTO t1(docid,words) VALUES(1018017,'And the LORD said, Shall I hide from Abraham that thing which I do;');
+INSERT INTO t1(docid,words) VALUES(1018018,'Seeing that Abraham shall surely become a great and mighty nation, and all the nations of the earth shall be blessed in him?');
+INSERT INTO t1(docid,words) VALUES(1018019,'For I know him, that he will command his children and his household after him, and they shall keep the way of the LORD, to do justice and judgment; that the LORD may bring upon Abraham that which he hath spoken of him.');
+INSERT INTO t1(docid,words) VALUES(1018020,'And the LORD said, Because the cry of Sodom and Gomorrah is great, and because their sin is very grievous;');
+INSERT INTO t1(docid,words) VALUES(1018021,'I will go down now, and see whether they have done altogether according to the cry of it, which is come unto me; and if not, I will know.');
+INSERT INTO t1(docid,words) VALUES(1018022,'And the men turned their faces from thence, and went toward Sodom: but Abraham stood yet before the LORD.');
+INSERT INTO t1(docid,words) VALUES(1018023,'And Abraham drew near, and said, Wilt thou also destroy the righteous with the wicked?');
+INSERT INTO t1(docid,words) VALUES(1018024,'Peradventure there be fifty righteous within the city: wilt thou also destroy and not spare the place for the fifty righteous that are therein?');
+INSERT INTO t1(docid,words) VALUES(1018025,'That be far from thee to do after this manner, to slay the righteous with the wicked: and that the righteous should be as the wicked, that be far from thee: Shall not the Judge of all the earth do right?');
+INSERT INTO t1(docid,words) VALUES(1018026,'And the LORD said, If I find in Sodom fifty righteous within the city, then I will spare all the place for their sakes.');
+INSERT INTO t1(docid,words) VALUES(1018027,'And Abraham answered and said, Behold now, I have taken upon me to speak unto the LORD, which am but dust and ashes:');
+INSERT INTO t1(docid,words) VALUES(1018028,'Peradventure there shall lack five of the fifty righteous: wilt thou destroy all the city for lack of five? And he said, If I find there forty and five, I will not destroy it.');
+INSERT INTO t1(docid,words) VALUES(1018029,'And he spake unto him yet again, and said, Peradventure there shall be forty found there. And he said, I will not do it for forty''s sake.');
+INSERT INTO t1(docid,words) VALUES(1018030,'And he said unto him, Oh let not the LORD be angry, and I will speak: Peradventure there shall thirty be found there. And he said, I will not do it, if I find thirty there.');
+INSERT INTO t1(docid,words) VALUES(1018031,'And he said, Behold now, I have taken upon me to speak unto the LORD: Peradventure there shall be twenty found there. And he said, I will not destroy it for twenty''s sake.');
+INSERT INTO t1(docid,words) VALUES(1018032,'And he said, Oh let not the LORD be angry, and I will speak yet but this once: Peradventure ten shall be found there. And he said, I will not destroy it for ten''s sake.');
+INSERT INTO t1(docid,words) VALUES(1018033,'And the LORD went his way, as soon as he had left communing with Abraham: and Abraham returned unto his place.');
+INSERT INTO t1(docid,words) VALUES(1019001,'And there came two angels to Sodom at even; and Lot sat in the gate of Sodom: and Lot seeing them rose up to meet them; and he bowed himself with his face toward the ground;');
+INSERT INTO t1(docid,words) VALUES(1019002,'And he said, Behold now, my lords, turn in, I pray you, into your servant''s house, and tarry all night, and wash your feet, and ye shall rise up early, and go on your ways. And they said, Nay; but we will abide in the street all night.');
+INSERT INTO t1(docid,words) VALUES(1019003,'And he pressed upon them greatly; and they turned in unto him, and entered into his house; and he made them a feast, and did bake unleavened bread, and they did eat.');
+INSERT INTO t1(docid,words) VALUES(1019004,'But before they lay down, the men of the city, even the men of Sodom, compassed the house round, both old and young, all the people from every quarter:');
+INSERT INTO t1(docid,words) VALUES(1019005,'And they called unto Lot, and said unto him, Where are the men which came in to thee this night? bring them out unto us, that we may know them.');
+INSERT INTO t1(docid,words) VALUES(1019006,'And Lot went out at the door unto them, and shut the door after him,');
+INSERT INTO t1(docid,words) VALUES(1019007,'And said, I pray you, brethren, do not so wickedly.');
+INSERT INTO t1(docid,words) VALUES(1019008,'Behold now, I have two daughters which have not known man; let me, I pray you, bring them out unto you, and do ye to them as is good in your eyes: only unto these men do nothing; for therefore came they under the shadow of my roof.');
+INSERT INTO t1(docid,words) VALUES(1019009,'And they said, Stand back. And they said again, This one fellow came in to sojourn, and he will needs be a judge: now will we deal worse with thee, than with them. And they pressed sore upon the man, even Lot, and came near to break the door.');
+INSERT INTO t1(docid,words) VALUES(1019010,'But the men put forth their hand, and pulled Lot into the house to them, and shut to the door.');
+INSERT INTO t1(docid,words) VALUES(1019011,'And they smote the men that were at the door of the house with blindness, both small and great: so that they wearied themselves to find the door.');
+INSERT INTO t1(docid,words) VALUES(1019012,'And the men said unto Lot, Hast thou here any besides? son in law, and thy sons, and thy daughters, and whatsoever thou hast in the city, bring them out of this place:');
+INSERT INTO t1(docid,words) VALUES(1019013,'For we will destroy this place, because the cry of them is waxen great before the face of the LORD; and the LORD hath sent us to destroy it.');
+INSERT INTO t1(docid,words) VALUES(1019014,'And Lot went out, and spake unto his sons in law, which married his daughters, and said, Up, get you out of this place; for the LORD will destroy this city. But he seemed as one that mocked unto his sons in law.');
+INSERT INTO t1(docid,words) VALUES(1019015,'And when the morning arose, then the angels hastened Lot, saying, Arise, take thy wife, and thy two daughters, which are here; lest thou be consumed in the iniquity of the city.');
+INSERT INTO t1(docid,words) VALUES(1019016,'And while he lingered, the men laid hold upon his hand, and upon the hand of his wife, and upon the hand of his two daughters; the LORD being merciful unto him: and they brought him forth, and set him without the city.');
+INSERT INTO t1(docid,words) VALUES(1019017,'And it came to pass, when they had brought them forth abroad, that he said, Escape for thy life; look not behind thee, neither stay thou in all the plain; escape to the mountain, lest thou be consumed.');
+INSERT INTO t1(docid,words) VALUES(1019018,'And Lot said unto them, Oh, not so, my LORD:');
+INSERT INTO t1(docid,words) VALUES(1019019,'Behold now, thy servant hath found grace in thy sight, and thou hast magnified thy mercy, which thou hast shewed unto me in saving my life; and I cannot escape to the mountain, lest some evil take me, and I die:');
+INSERT INTO t1(docid,words) VALUES(1019020,'Behold now, this city is near to flee unto, and it is a little one: Oh, let me escape thither, (is it not a little one?) and my soul shall live.');
+INSERT INTO t1(docid,words) VALUES(1019021,'And he said unto him, See, I have accepted thee concerning this thing also, that I will not overthrow this city, for the which thou hast spoken.');
+INSERT INTO t1(docid,words) VALUES(1019022,'Haste thee, escape thither; for I cannot do anything till thou be come thither. Therefore the name of the city was called Zoar.');
+INSERT INTO t1(docid,words) VALUES(1019023,'The sun was risen upon the earth when Lot entered into Zoar.');
+INSERT INTO t1(docid,words) VALUES(1019024,'Then the LORD rained upon Sodom and upon Gomorrah brimstone and fire from the LORD out of heaven;');
+INSERT INTO t1(docid,words) VALUES(1019025,'And he overthrew those cities, and all the plain, and all the inhabitants of the cities, and that which grew upon the ground.');
+INSERT INTO t1(docid,words) VALUES(1019026,'But his wife looked back from behind him, and she became a pillar of salt.');
+INSERT INTO t1(docid,words) VALUES(1019027,'And Abraham gat up early in the morning to the place where he stood before the LORD:');
+INSERT INTO t1(docid,words) VALUES(1019028,'And he looked toward Sodom and Gomorrah, and toward all the land of the plain, and beheld, and, lo, the smoke of the country went up as the smoke of a furnace.');
+INSERT INTO t1(docid,words) VALUES(1019029,'And it came to pass, when God destroyed the cities of the plain, that God remembered Abraham, and sent Lot out of the midst of the overthrow, when he overthrew the cities in the which Lot dwelt.');
+INSERT INTO t1(docid,words) VALUES(1019030,'And Lot went up out of Zoar, and dwelt in the mountain, and his two daughters with him; for he feared to dwell in Zoar: and he dwelt in a cave, he and his two daughters.');
+INSERT INTO t1(docid,words) VALUES(1019031,'And the firstborn said unto the younger, Our father is old, and there is not a man in the earth to come in unto us after the manner of all the earth:');
+INSERT INTO t1(docid,words) VALUES(1019032,'Come, let us make our father drink wine, and we will lie with him, that we may preserve seed of our father.');
+INSERT INTO t1(docid,words) VALUES(1019033,'And they made their father drink wine that night: and the firstborn went in, and lay with her father; and he perceived not when she lay down, nor when she arose.');
+INSERT INTO t1(docid,words) VALUES(1019034,'And it came to pass on the morrow, that the firstborn said unto the younger, Behold, I lay yesternight with my father: let us make him drink wine this night also; and go thou in, and lie with him, that we may preserve seed of our father.');
+INSERT INTO t1(docid,words) VALUES(1019035,'And they made their father drink wine that night also: and the younger arose, and lay with him; and he perceived not when she lay down, nor when she arose.');
+INSERT INTO t1(docid,words) VALUES(1019036,'Thus were both the daughters of Lot with child by their father.');
+INSERT INTO t1(docid,words) VALUES(1019037,'And the first born bare a son, and called his name Moab: the same is the father of the Moabites unto this day.');
+INSERT INTO t1(docid,words) VALUES(1019038,'And the younger, she also bare a son, and called his name Benammi: the same is the father of the children of Ammon unto this day.');
+INSERT INTO t1(docid,words) VALUES(1020001,'And Abraham journeyed from thence toward the south country, and dwelled between Kadesh and Shur, and sojourned in Gerar.');
+INSERT INTO t1(docid,words) VALUES(1020002,'And Abraham said of Sarah his wife, She is my sister: and Abimelech king of Gerar sent, and took Sarah.');
+INSERT INTO t1(docid,words) VALUES(1020003,'But God came to Abimelech in a dream by night, and said to him, Behold, thou art but a dead man, for the woman which thou hast taken; for she is a man''s wife.');
+INSERT INTO t1(docid,words) VALUES(1020004,'But Abimelech had not come near her: and he said, LORD, wilt thou slay also a righteous nation?');
+INSERT INTO t1(docid,words) VALUES(1020005,'Said he not unto me, She is my sister? and she, even she herself said, He is my brother: in the integrity of my heart and innocency of my hands have I done this.');
+INSERT INTO t1(docid,words) VALUES(1020006,'And God said unto him in a dream, Yea, I know that thou didst this in the integrity of thy heart; for I also withheld thee from sinning against me: therefore suffered I thee not to touch her.');
+INSERT INTO t1(docid,words) VALUES(1020007,'Now therefore restore the man his wife; for he is a prophet, and he shall pray for thee, and thou shalt live: and if thou restore her not, know thou that thou shalt surely die, thou, and all that are thine.');
+INSERT INTO t1(docid,words) VALUES(1020008,'Therefore Abimelech rose early in the morning, and called all his servants, and told all these things in their ears: and the men were sore afraid.');
+INSERT INTO t1(docid,words) VALUES(1020009,'Then Abimelech called Abraham, and said unto him, What hast thou done unto us? and what have I offended thee, that thou hast brought on me and on my kingdom a great sin? thou hast done deeds unto me that ought not to be done.');
+INSERT INTO t1(docid,words) VALUES(1020010,'And Abimelech said unto Abraham, What sawest thou, that thou hast done this thing?');
+INSERT INTO t1(docid,words) VALUES(1020011,'And Abraham said, Because I thought, Surely the fear of God is not in this place; and they will slay me for my wife''s sake.');
+INSERT INTO t1(docid,words) VALUES(1020012,'And yet indeed she is my sister; she is the daughter of my father, but not the daughter of my mother; and she became my wife.');
+INSERT INTO t1(docid,words) VALUES(1020013,'And it came to pass, when God caused me to wander from my father''s house, that I said unto her, This is thy kindness which thou shalt shew unto me; at every place whither we shall come, say of me, He is my brother.');
+INSERT INTO t1(docid,words) VALUES(1020014,'And Abimelech took sheep, and oxen, and menservants, and womenservants, and gave them unto Abraham, and restored him Sarah his wife.');
+INSERT INTO t1(docid,words) VALUES(1020015,'And Abimelech said, Behold, my land is before thee: dwell where it pleaseth thee.');
+INSERT INTO t1(docid,words) VALUES(1020016,'And unto Sarah he said, Behold, I have given thy brother a thousand pieces of silver: behold, he is to thee a covering of the eyes, unto all that are with thee, and with all other: thus she was reproved.');
+INSERT INTO t1(docid,words) VALUES(1020017,'So Abraham prayed unto God: and God healed Abimelech, and his wife, and his maidservants; and they bare children.');
+INSERT INTO t1(docid,words) VALUES(1020018,'For the LORD had fast closed up all the wombs of the house of Abimelech, because of Sarah Abraham''s wife.');
+INSERT INTO t1(docid,words) VALUES(1021001,'And the LORD visited Sarah as he had said, and the LORD did unto Sarah as he had spoken.');
+INSERT INTO t1(docid,words) VALUES(1021002,'For Sarah conceived, and bare Abraham a son in his old age, at the set time of which God had spoken to him.');
+INSERT INTO t1(docid,words) VALUES(1021003,'And Abraham called the name of his son that was born unto him, whom Sarah bare to him, Isaac.');
+INSERT INTO t1(docid,words) VALUES(1021004,'And Abraham circumcised his son Isaac being eight days old, as God had commanded him.');
+INSERT INTO t1(docid,words) VALUES(1021005,'And Abraham was an hundred years old, when his son Isaac was born unto him.');
+INSERT INTO t1(docid,words) VALUES(1021006,'And Sarah said, God hath made me to laugh, so that all that hear will laugh with me.');
+INSERT INTO t1(docid,words) VALUES(1021007,'And she said, Who would have said unto Abraham, that Sarah should have given children suck? for I have born him a son in his old age.');
+INSERT INTO t1(docid,words) VALUES(1021008,'And the child grew, and was weaned: and Abraham made a great feast the same day that Isaac was weaned.');
+INSERT INTO t1(docid,words) VALUES(1021009,'And Sarah saw the son of Hagar the Egyptian, which she had born unto Abraham, mocking.');
+INSERT INTO t1(docid,words) VALUES(1021010,'Wherefore she said unto Abraham, Cast out this bondwoman and her son: for the son of this bondwoman shall not be heir with my son, even with Isaac.');
+INSERT INTO t1(docid,words) VALUES(1021011,'And the thing was very grievous in Abraham''s sight because of his son.');
+INSERT INTO t1(docid,words) VALUES(1021012,'And God said unto Abraham, Let it not be grievous in thy sight because of the lad, and because of thy bondwoman; in all that Sarah hath said unto thee, hearken unto her voice; for in Isaac shall thy seed be called.');
+INSERT INTO t1(docid,words) VALUES(1021013,'And also of the son of the bondwoman will I make a nation, because he is thy seed.');
+INSERT INTO t1(docid,words) VALUES(1021014,'And Abraham rose up early in the morning, and took bread, and a bottle of water, and gave it unto Hagar, putting it on her shoulder, and the child, and sent her away: and she departed, and wandered in the wilderness of Beersheba.');
+INSERT INTO t1(docid,words) VALUES(1021015,'And the water was spent in the bottle, and she cast the child under one of the shrubs.');
+INSERT INTO t1(docid,words) VALUES(1021016,'And she went, and sat her down over against him a good way off, as it were a bow shot: for she said, Let me not see the death of the child. And she sat over against him, and lift up her voice, and wept.');
+INSERT INTO t1(docid,words) VALUES(1021017,'And God heard the voice of the lad; and the angel of God called to Hagar out of heaven, and said unto her, What aileth thee, Hagar? fear not; for God hath heard the voice of the lad where he is.');
+INSERT INTO t1(docid,words) VALUES(1021018,'Arise, lift up the lad, and hold him in thine hand; for I will make him a great nation.');
+INSERT INTO t1(docid,words) VALUES(1021019,'And God opened her eyes, and she saw a well of water; and she went, and filled the bottle with water, and gave the lad drink.');
+INSERT INTO t1(docid,words) VALUES(1021020,'And God was with the lad; and he grew, and dwelt in the wilderness, and became an archer.');
+INSERT INTO t1(docid,words) VALUES(1021021,'And he dwelt in the wilderness of Paran: and his mother took him a wife out of the land of Egypt.');
+INSERT INTO t1(docid,words) VALUES(1021022,'And it came to pass at that time, that Abimelech and Phichol the chief captain of his host spake unto Abraham, saying, God is with thee in all that thou doest:');
+INSERT INTO t1(docid,words) VALUES(1021023,'Now therefore swear unto me here by God that thou wilt not deal falsely with me, nor with my son, nor with my son''s son: but according to the kindness that I have done unto thee, thou shalt do unto me, and to the land wherein thou hast sojourned.');
+INSERT INTO t1(docid,words) VALUES(1021024,'And Abraham said, I will swear.');
+INSERT INTO t1(docid,words) VALUES(1021025,'And Abraham reproved Abimelech because of a well of water, which Abimelech''s servants had violently taken away.');
+INSERT INTO t1(docid,words) VALUES(1021026,'And Abimelech said, I wot not who hath done this thing; neither didst thou tell me, neither yet heard I of it, but to day.');
+INSERT INTO t1(docid,words) VALUES(1021027,'And Abraham took sheep and oxen, and gave them unto Abimelech; and both of them made a covenant.');
+INSERT INTO t1(docid,words) VALUES(1021028,'And Abraham set seven ewe lambs of the flock by themselves.');
+INSERT INTO t1(docid,words) VALUES(1021029,'And Abimelech said unto Abraham, What mean these seven ewe lambs which thou hast set by themselves?');
+INSERT INTO t1(docid,words) VALUES(1021030,'And he said, For these seven ewe lambs shalt thou take of my hand, that they may be a witness unto me, that I have digged this well.');
+INSERT INTO t1(docid,words) VALUES(1021031,'Wherefore he called that place Beersheba; because there they sware both of them.');
+INSERT INTO t1(docid,words) VALUES(1021032,'Thus they made a covenant at Beersheba: then Abimelech rose up, and Phichol the chief captain of his host, and they returned into the land of the Philistines.');
+INSERT INTO t1(docid,words) VALUES(1021033,'And Abraham planted a grove in Beersheba, and called there on the name of the LORD, the everlasting God.');
+INSERT INTO t1(docid,words) VALUES(1021034,'And Abraham sojourned in the Philistines'' land many days.');
+INSERT INTO t1(docid,words) VALUES(1022001,'And it came to pass after these things, that God did tempt Abraham, and said unto him, Abraham: and he said, Behold, here I am.');
+INSERT INTO t1(docid,words) VALUES(1022002,'And he said, Take now thy son, thine only son Isaac, whom thou lovest, and get thee into the land of Moriah; and offer him there for a burnt offering upon one of the mountains which I will tell thee of.');
+INSERT INTO t1(docid,words) VALUES(1022003,'And Abraham rose up early in the morning, and saddled his ass, and took two of his young men with him, and Isaac his son, and clave the wood for the burnt offering, and rose up, and went unto the place of which God had told him.');
+INSERT INTO t1(docid,words) VALUES(1022004,'Then on the third day Abraham lifted up his eyes, and saw the place afar off.');
+INSERT INTO t1(docid,words) VALUES(1022005,'And Abraham said unto his young men, Abide ye here with the ass; and I and the lad will go yonder and worship, and come again to you.');
+INSERT INTO t1(docid,words) VALUES(1022006,'And Abraham took the wood of the burnt offering, and laid it upon Isaac his son; and he took the fire in his hand, and a knife; and they went both of them together.');
+INSERT INTO t1(docid,words) VALUES(1022007,'And Isaac spake unto Abraham his father, and said, My father: and he said, Here am I, my son. And he said, Behold the fire and the wood: but where is the lamb for a burnt offering?');
+INSERT INTO t1(docid,words) VALUES(1022008,'And Abraham said, My son, God will provide himself a lamb for a burnt offering: so they went both of them together.');
+INSERT INTO t1(docid,words) VALUES(1022009,'And they came to the place which God had told him of; and Abraham built an altar there, and laid the wood in order, and bound Isaac his son, and laid him on the altar upon the wood.');
+INSERT INTO t1(docid,words) VALUES(1022010,'And Abraham stretched forth his hand, and took the knife to slay his son.');
+INSERT INTO t1(docid,words) VALUES(1022011,'And the angel of the LORD called unto him out of heaven, and said, Abraham, Abraham: and he said, Here am I.');
+INSERT INTO t1(docid,words) VALUES(1022012,'And he said, Lay not thine hand upon the lad, neither do thou any thing unto him: for now I know that thou fearest God, seeing thou hast not withheld thy son, thine only son from me.');
+INSERT INTO t1(docid,words) VALUES(1022013,'And Abraham lifted up his eyes, and looked, and behold behind him a ram caught in a thicket by his horns: and Abraham went and took the ram, and offered him up for a burnt offering in the stead of his son.');
+INSERT INTO t1(docid,words) VALUES(1022014,'And Abraham called the name of that place Jehovahjireh: as it is said to this day, In the mount of the LORD it shall be seen.');
+INSERT INTO t1(docid,words) VALUES(1022015,'And the angel of the LORD called unto Abraham out of heaven the second time,');
+INSERT INTO t1(docid,words) VALUES(1022016,'And said, By myself have I sworn, saith the LORD, for because thou hast done this thing, and hast not withheld thy son, thine only son:');
+INSERT INTO t1(docid,words) VALUES(1022017,'That in blessing I will bless thee, and in multiplying I will multiply thy seed as the stars of the heaven, and as the sand which is upon the sea shore; and thy seed shall possess the gate of his enemies;');
+INSERT INTO t1(docid,words) VALUES(1022018,'And in thy seed shall all the nations of the earth be blessed; because thou hast obeyed my voice.');
+INSERT INTO t1(docid,words) VALUES(1022019,'So Abraham returned unto his young men, and they rose up and went together to Beersheba; and Abraham dwelt at Beersheba.');
+INSERT INTO t1(docid,words) VALUES(1022020,'And it came to pass after these things, that it was told Abraham, saying, Behold, Milcah, she hath also born children unto thy brother Nahor;');
+INSERT INTO t1(docid,words) VALUES(1022021,'Huz his firstborn, and Buz his brother, and Kemuel the father of Aram,');
+INSERT INTO t1(docid,words) VALUES(1022022,'And Chesed, and Hazo, and Pildash, and Jidlaph, and Bethuel.');
+INSERT INTO t1(docid,words) VALUES(1022023,'And Bethuel begat Rebekah: these eight Milcah did bear to Nahor, Abraham''s brother.');
+INSERT INTO t1(docid,words) VALUES(1022024,'And his concubine, whose name was Reumah, she bare also Tebah, and Gaham, and Thahash, and Maachah.');
+INSERT INTO t1(docid,words) VALUES(1023001,'And Sarah was an hundred and seven and twenty years old: these were the years of the life of Sarah.');
+INSERT INTO t1(docid,words) VALUES(1023002,'And Sarah died in Kirjatharba; the same is Hebron in the land of Canaan: and Abraham came to mourn for Sarah, and to weep for her.');
+INSERT INTO t1(docid,words) VALUES(1023003,'And Abraham stood up from before his dead, and spake unto the sons of Heth, saying,');
+INSERT INTO t1(docid,words) VALUES(1023004,'I am a stranger and a sojourner with you: give me a possession of a buryingplace with you, that I may bury my dead out of my sight.');
+INSERT INTO t1(docid,words) VALUES(1023005,'And the children of Heth answered Abraham, saying unto him,');
+INSERT INTO t1(docid,words) VALUES(1023006,'Hear us, my lord: thou art a mighty prince among us: in the choice of our sepulchres bury thy dead; none of us shall withhold from thee his sepulchre, but that thou mayest bury thy dead.');
+INSERT INTO t1(docid,words) VALUES(1023007,'And Abraham stood up, and bowed himself to the people of the land, even to the children of Heth.');
+INSERT INTO t1(docid,words) VALUES(1023008,'And he communed with them, saying, If it be your mind that I should bury my dead out of my sight; hear me, and intreat for me to Ephron the son of Zohar,');
+INSERT INTO t1(docid,words) VALUES(1023009,'That he may give me the cave of Machpelah, which he hath, which is in the end of his field; for as much money as it is worth he shall give it me for a possession of a buryingplace amongst you.');
+INSERT INTO t1(docid,words) VALUES(1023010,'And Ephron dwelt among the children of Heth: and Ephron the Hittite answered Abraham in the audience of the children of Heth, even of all that went in at the gate of his city, saying,');
+INSERT INTO t1(docid,words) VALUES(1023011,'Nay, my lord, hear me: the field give I thee, and the cave that is therein, I give it thee; in the presence of the sons of my people give I it thee: bury thy dead.');
+INSERT INTO t1(docid,words) VALUES(1023012,'And Abraham bowed down himself before the people of the land.');
+INSERT INTO t1(docid,words) VALUES(1023013,'And he spake unto Ephron in the audience of the people of the land, saying, But if thou wilt give it, I pray thee, hear me: I will give thee money for the field; take it of me, and I will bury my dead there.');
+INSERT INTO t1(docid,words) VALUES(1023014,'And Ephron answered Abraham, saying unto him,');
+INSERT INTO t1(docid,words) VALUES(1023015,'My lord, hearken unto me: the land is worth four hundred shekels of silver; what is that betwixt me and thee? bury therefore thy dead.');
+INSERT INTO t1(docid,words) VALUES(1023016,'And Abraham hearkened unto Ephron; and Abraham weighed to Ephron the silver, which he had named in the audience of the sons of Heth, four hundred shekels of silver, current money with the merchant.');
+INSERT INTO t1(docid,words) VALUES(1023017,'And the field of Ephron which was in Machpelah, which was before Mamre, the field, and the cave which was therein, and all the trees that were in the field, that were in all the borders round about, were made sure');
+INSERT INTO t1(docid,words) VALUES(1023018,'Unto Abraham for a possession in the presence of the children of Heth, before all that went in at the gate of his city.');
+INSERT INTO t1(docid,words) VALUES(1023019,'And after this, Abraham buried Sarah his wife in the cave of the field of Machpelah before Mamre: the same is Hebron in the land of Canaan.');
+INSERT INTO t1(docid,words) VALUES(1023020,'And the field, and the cave that is therein, were made sure unto Abraham for a possession of a buryingplace by the sons of Heth.');
+INSERT INTO t1(docid,words) VALUES(1024001,'And Abraham was old, and well stricken in age: and the LORD had blessed Abraham in all things.');
+INSERT INTO t1(docid,words) VALUES(1024002,'And Abraham said unto his eldest servant of his house, that ruled over all that he had, Put, I pray thee, thy hand under my thigh:');
+INSERT INTO t1(docid,words) VALUES(1024003,'And I will make thee swear by the LORD, the God of heaven, and the God of the earth, that thou shalt not take a wife unto my son of the daughters of the Canaanites, among whom I dwell:');
+INSERT INTO t1(docid,words) VALUES(1024004,'But thou shalt go unto my country, and to my kindred, and take a wife unto my son Isaac.');
+INSERT INTO t1(docid,words) VALUES(1024005,'And the servant said unto him, Peradventure the woman will not be willing to follow me unto this land: must I needs bring thy son again unto the land from whence thou camest?');
+INSERT INTO t1(docid,words) VALUES(1024006,'And Abraham said unto him, Beware thou that thou bring not my son thither again.');
+INSERT INTO t1(docid,words) VALUES(1024007,'The LORD God of heaven, which took me from my father''s house, and from the land of my kindred, and which spake unto me, and that sware unto me, saying, Unto thy seed will I give this land; he shall send his angel before thee, and thou shalt take a wife unto my son from thence.');
+INSERT INTO t1(docid,words) VALUES(1024008,'And if the woman will not be willing to follow thee, then thou shalt be clear from this my oath: only bring not my son thither again.');
+INSERT INTO t1(docid,words) VALUES(1024009,'And the servant put his hand under the thigh of Abraham his master, and sware to him concerning that matter.');
+INSERT INTO t1(docid,words) VALUES(1024010,'And the servant took ten camels of the camels of his master, and departed; for all the goods of his master were in his hand: and he arose, and went to Mesopotamia, unto the city of Nahor.');
+INSERT INTO t1(docid,words) VALUES(1024011,'And he made his camels to kneel down without the city by a well of water at the time of the evening, even the time that women go out to draw water.');
+INSERT INTO t1(docid,words) VALUES(1024012,'And he said O LORD God of my master Abraham, I pray thee, send me good speed this day, and shew kindness unto my master Abraham.');
+INSERT INTO t1(docid,words) VALUES(1024013,'Behold, I stand here by the well of water; and the daughters of the men of the city come out to draw water:');
+INSERT INTO t1(docid,words) VALUES(1024014,'And let it come to pass, that the damsel to whom I shall say, Let down thy pitcher, I pray thee, that I may drink; and she shall say, Drink, and I will give thy camels drink also: let the same be she that thou hast appointed for thy servant Isaac; and thereby shall I know that thou hast shewed kindness unto my master.');
+INSERT INTO t1(docid,words) VALUES(1024015,'And it came to pass, before he had done speaking, that, behold, Rebekah came out, who was born to Bethuel, son of Milcah, the wife of Nahor, Abraham''s brother, with her pitcher upon her shoulder.');
+INSERT INTO t1(docid,words) VALUES(1024016,'And the damsel was very fair to look upon, a virgin, neither had any man known her: and she went down to the well, and filled her pitcher, and came up.');
+INSERT INTO t1(docid,words) VALUES(1024017,'And the servant ran to meet her, and said, Let me, I pray thee, drink a little water of thy pitcher.');
+INSERT INTO t1(docid,words) VALUES(1024018,'And she said, Drink, my lord: and she hasted, and let down her pitcher upon her hand, and gave him drink.');
+INSERT INTO t1(docid,words) VALUES(1024019,'And when she had done giving him drink, she said, I will draw water for thy camels also, until they have done drinking.');
+INSERT INTO t1(docid,words) VALUES(1024020,'And she hasted, and emptied her pitcher into the trough, and ran again unto the well to draw water, and drew for all his camels.');
+INSERT INTO t1(docid,words) VALUES(1024021,'And the man wondering at her held his peace, to wit whether the LORD had made his journey prosperous or not.');
+INSERT INTO t1(docid,words) VALUES(1024022,'And it came to pass, as the camels had done drinking, that the man took a golden earring of half a shekel weight, and two bracelets for her hands of ten shekels weight of gold;');
+INSERT INTO t1(docid,words) VALUES(1024023,'And said, Whose daughter art thou? tell me, I pray thee: is there room in thy father''s house for us to lodge in?');
+INSERT INTO t1(docid,words) VALUES(1024024,'And she said unto him, I am the daughter of Bethuel the son of Milcah, which she bare unto Nahor.');
+INSERT INTO t1(docid,words) VALUES(1024025,'She said moreover unto him, We have both straw and provender enough, and room to lodge in.');
+INSERT INTO t1(docid,words) VALUES(1024026,'And the man bowed down his head, and worshipped the LORD.');
+INSERT INTO t1(docid,words) VALUES(1024027,'And he said, Blessed be the LORD God of my master Abraham, who hath not left destitute my master of his mercy and his truth: I being in the way, the LORD led me to the house of my master''s brethren.');
+INSERT INTO t1(docid,words) VALUES(1024028,'And the damsel ran, and told them of her mother''s house these things.');
+INSERT INTO t1(docid,words) VALUES(1024029,'And Rebekah had a brother, and his name was Laban: and Laban ran out unto the man, unto the well.');
+INSERT INTO t1(docid,words) VALUES(1024030,'And it came to pass, when he saw the earring and bracelets upon his sister''s hands, and when he heard the words of Rebekah his sister, saying, Thus spake the man unto me; that he came unto the man; and, behold, he stood by the camels at the well.');
+INSERT INTO t1(docid,words) VALUES(1024031,'And he said, Come in, thou blessed of the LORD; wherefore standest thou without? for I have prepared the house, and room for the camels.');
+INSERT INTO t1(docid,words) VALUES(1024032,'And the man came into the house: and he ungirded his camels, and gave straw and provender for the camels, and water to wash his feet, and the men''s feet that were with him.');
+INSERT INTO t1(docid,words) VALUES(1024033,'And there was set meat before him to eat: but he said, I will not eat, until I have told mine errand. And he said, Speak on.');
+INSERT INTO t1(docid,words) VALUES(1024034,'And he said, I am Abraham''s servant.');
+INSERT INTO t1(docid,words) VALUES(1024035,'And the LORD hath blessed my master greatly; and he is become great: and he hath given him flocks, and herds, and silver, and gold, and menservants, and maidservants, and camels, and asses.');
+INSERT INTO t1(docid,words) VALUES(1024036,'And Sarah my master''s wife bare a son to my master when she was old: and unto him hath he given all that he hath.');
+INSERT INTO t1(docid,words) VALUES(1024037,'And my master made me swear, saying, Thou shalt not take a wife to my son of the daughters of the Canaanites, in whose land I dwell:');
+INSERT INTO t1(docid,words) VALUES(1024038,'But thou shalt go unto my father''s house, and to my kindred, and take a wife unto my son.');
+INSERT INTO t1(docid,words) VALUES(1024039,'And I said unto my master, Peradventure the woman will not follow me.');
+INSERT INTO t1(docid,words) VALUES(1024040,'And he said unto me, The LORD, before whom I walk, will send his angel with thee, and prosper thy way; and thou shalt take a wife for my son of my kindred, and of my father''s house:');
+INSERT INTO t1(docid,words) VALUES(1024041,'Then shalt thou be clear from this my oath, when thou comest to my kindred; and if they give not thee one, thou shalt be clear from my oath.');
+INSERT INTO t1(docid,words) VALUES(1024042,'And I came this day unto the well, and said, O LORD God of my master Abraham, if now thou do prosper my way which I go:');
+INSERT INTO t1(docid,words) VALUES(1024043,'Behold, I stand by the well of water; and it shall come to pass, that when the virgin cometh forth to draw water, and I say to her, Give me, I pray thee, a little water of thy pitcher to drink;');
+INSERT INTO t1(docid,words) VALUES(1024044,'And she say to me, Both drink thou, and I will also draw for thy camels: let the same be the woman whom the LORD hath appointed out for my master''s son.');
+INSERT INTO t1(docid,words) VALUES(1024045,'And before I had done speaking in mine heart, behold, Rebekah came forth with her pitcher on her shoulder; and she went down unto the well, and drew water: and I said unto her, Let me drink, I pray thee.');
+INSERT INTO t1(docid,words) VALUES(1024046,'And she made haste, and let down her pitcher from her shoulder, and said, Drink, and I will give thy camels drink also: so I drank, and she made the camels drink also.');
+INSERT INTO t1(docid,words) VALUES(1024047,'And I asked her, and said, Whose daughter art thou? And she said, the daughter of Bethuel, Nahor''s son, whom Milcah bare unto him: and I put the earring upon her face, and the bracelets upon her hands.');
+INSERT INTO t1(docid,words) VALUES(1024048,'And I bowed down my head, and worshipped the LORD, and blessed the LORD God of my master Abraham, which had led me in the right way to take my master''s brother''s daughter unto his son.');
+INSERT INTO t1(docid,words) VALUES(1024049,'And now if ye will deal kindly and truly with my master, tell me: and if not, tell me; that I may turn to the right hand, or to the left.');
+INSERT INTO t1(docid,words) VALUES(1024050,'Then Laban and Bethuel answered and said, The thing proceedeth from the LORD: we cannot speak unto thee bad or good.');
+INSERT INTO t1(docid,words) VALUES(1024051,'Behold, Rebekah is before thee, take her, and go, and let her be thy master''s son''s wife, as the LORD hath spoken.');
+INSERT INTO t1(docid,words) VALUES(1024052,'And it came to pass, that, when Abraham''s servant heard their words, he worshipped the LORD, bowing himself to the earth.');
+INSERT INTO t1(docid,words) VALUES(1024053,'And the servant brought forth jewels of silver, and jewels of gold, and raiment, and gave them to Rebekah: he gave also to her brother and to her mother precious things.');
+INSERT INTO t1(docid,words) VALUES(1024054,'And they did eat and drink, he and the men that were with him, and tarried all night; and they rose up in the morning, and he said, Send me away unto my master.');
+INSERT INTO t1(docid,words) VALUES(1024055,'And her brother and her mother said, Let the damsel abide with us a few days, at the least ten; after that she shall go.');
+INSERT INTO t1(docid,words) VALUES(1024056,'And he said unto them, Hinder me not, seeing the LORD hath prospered my way; send me away that I may go to my master.');
+INSERT INTO t1(docid,words) VALUES(1024057,'And they said, We will call the damsel, and enquire at her mouth.');
+INSERT INTO t1(docid,words) VALUES(1024058,'And they called Rebekah, and said unto her, Wilt thou go with this man? And she said, I will go.');
+INSERT INTO t1(docid,words) VALUES(1024059,'And they sent away Rebekah their sister, and her nurse, and Abraham''s servant, and his men.');
+INSERT INTO t1(docid,words) VALUES(1024060,'And they blessed Rebekah, and said unto her, Thou art our sister, be thou the mother of thousands of millions, and let thy seed possess the gate of those which hate them.');
+INSERT INTO t1(docid,words) VALUES(1024061,'And Rebekah arose, and her damsels, and they rode upon the camels, and followed the man: and the servant took Rebekah, and went his way.');
+INSERT INTO t1(docid,words) VALUES(1024062,'And Isaac came from the way of the well Lahairoi; for he dwelt in the south country.');
+INSERT INTO t1(docid,words) VALUES(1024063,'And Isaac went out to meditate in the field at the eventide: and he lifted up his eyes, and saw, and, behold, the camels were coming.');
+INSERT INTO t1(docid,words) VALUES(1024064,'And Rebekah lifted up her eyes, and when she saw Isaac, she lighted off the camel.');
+INSERT INTO t1(docid,words) VALUES(1024065,'For she had said unto the servant, What man is this that walketh in the field to meet us? And the servant had said, It is my master: therefore she took a vail, and covered herself.');
+INSERT INTO t1(docid,words) VALUES(1024066,'And the servant told Isaac all things that he had done.');
+INSERT INTO t1(docid,words) VALUES(1024067,'And Isaac brought her into his mother Sarah''s tent, and took Rebekah, and she became his wife; and he loved her: and Isaac was comforted after his mother''s death.');
+INSERT INTO t1(docid,words) VALUES(1025001,'Then again Abraham took a wife, and her name was Keturah.');
+INSERT INTO t1(docid,words) VALUES(1025002,'And she bare him Zimran, and Jokshan, and Medan, and Midian, and Ishbak, and Shuah.');
+INSERT INTO t1(docid,words) VALUES(1025003,'And Jokshan begat Sheba, and Dedan. And the sons of Dedan were Asshurim, and Letushim, and Leummim.');
+INSERT INTO t1(docid,words) VALUES(1025004,'And the sons of Midian; Ephah, and Epher, and Hanoch, and Abidah, and Eldaah. All these were the children of Keturah.');
+INSERT INTO t1(docid,words) VALUES(1025005,'And Abraham gave all that he had unto Isaac.');
+INSERT INTO t1(docid,words) VALUES(1025006,'But unto the sons of the concubines, which Abraham had, Abraham gave gifts, and sent them away from Isaac his son, while he yet lived, eastward, unto the east country.');
+INSERT INTO t1(docid,words) VALUES(1025007,'And these are the days of the years of Abraham''s life which he lived, an hundred threescore and fifteen years.');
+INSERT INTO t1(docid,words) VALUES(1025008,'Then Abraham gave up the ghost, and died in a good old age, an old man, and full of years; and was gathered to his people.');
+INSERT INTO t1(docid,words) VALUES(1025009,'And his sons Isaac and Ishmael buried him in the cave of Machpelah, in the field of Ephron the son of Zohar the Hittite, which is before Mamre;');
+INSERT INTO t1(docid,words) VALUES(1025010,'The field which Abraham purchased of the sons of Heth: there was Abraham buried, and Sarah his wife.');
+INSERT INTO t1(docid,words) VALUES(1025011,'And it came to pass after the death of Abraham, that God blessed his son Isaac; and Isaac dwelt by the well Lahairoi.');
+INSERT INTO t1(docid,words) VALUES(1025012,'Now these are the generations of Ishmael, Abraham''s son, whom Hagar the Egyptian, Sarah''s handmaid, bare unto Abraham:');
+INSERT INTO t1(docid,words) VALUES(1025013,'And these are the names of the sons of Ishmael, by their names, according to their generations: the firstborn of Ishmael, Nebajoth; and Kedar, and Adbeel, and Mibsam,');
+INSERT INTO t1(docid,words) VALUES(1025014,'And Mishma, and Dumah, and Massa,');
+INSERT INTO t1(docid,words) VALUES(1025015,'Hadar, and Tema, Jetur, Naphish, and Kedemah:');
+INSERT INTO t1(docid,words) VALUES(1025016,'These are the sons of Ishmael, and these are their names, by their towns, and by their castles; twelve princes according to their nations.');
+INSERT INTO t1(docid,words) VALUES(1025017,'And these are the years of the life of Ishmael, an hundred and thirty and seven years: and he gave up the ghost and died; and was gathered unto his people.');
+INSERT INTO t1(docid,words) VALUES(1025018,'And they dwelt from Havilah unto Shur, that is before Egypt, as thou goest toward Assyria: and he died in the presence of all his brethren.');
+INSERT INTO t1(docid,words) VALUES(1025019,'And these are the generations of Isaac, Abraham''s son: Abraham begat Isaac:');
+INSERT INTO t1(docid,words) VALUES(1025020,'And Isaac was forty years old when he took Rebekah to wife, the daughter of Bethuel the Syrian of Padanaram, the sister to Laban the Syrian.');
+INSERT INTO t1(docid,words) VALUES(1025021,'And Isaac intreated the LORD for his wife, because she was barren: and the LORD was intreated of him, and Rebekah his wife conceived.');
+INSERT INTO t1(docid,words) VALUES(1025022,'And the children struggled together within her; and she said, If it be so, why am I thus? And she went to enquire of the LORD.');
+INSERT INTO t1(docid,words) VALUES(1025023,'And the LORD said unto her, Two nations are in thy womb, and two manner of people shall be separated from thy bowels; and the one people shall be stronger than the other people; and the elder shall serve the younger.');
+INSERT INTO t1(docid,words) VALUES(1025024,'And when her days to be delivered were fulfilled, behold, there were twins in her womb.');
+INSERT INTO t1(docid,words) VALUES(1025025,'And the first came out red, all over like an hairy garment; and they called his name Esau.');
+INSERT INTO t1(docid,words) VALUES(1025026,'And after that came his brother out, and his hand took hold on Esau''s heel; and his name was called Jacob: and Isaac was threescore years old when she bare them.');
+INSERT INTO t1(docid,words) VALUES(1025027,'And the boys grew: and Esau was a cunning hunter, a man of the field; and Jacob was a plain man, dwelling in tents.');
+INSERT INTO t1(docid,words) VALUES(1025028,'And Isaac loved Esau, because he did eat of his venison: but Rebekah loved Jacob.');
+INSERT INTO t1(docid,words) VALUES(1025029,'And Jacob sod pottage: and Esau came from the field, and he was faint:');
+INSERT INTO t1(docid,words) VALUES(1025030,'And Esau said to Jacob, Feed me, I pray thee, with that same red pottage; for I am faint: therefore was his name called Edom.');
+INSERT INTO t1(docid,words) VALUES(1025031,'And Jacob said, Sell me this day thy birthright.');
+INSERT INTO t1(docid,words) VALUES(1025032,'And Esau said, Behold, I am at the point to die: and what profit shall this birthright do to me?');
+INSERT INTO t1(docid,words) VALUES(1025033,'And Jacob said, Swear to me this day; and he sware unto him: and he sold his birthright unto Jacob.');
+INSERT INTO t1(docid,words) VALUES(1025034,'Then Jacob gave Esau bread and pottage of lentiles; and he did eat and drink, and rose up, and went his way: thus Esau despised his birthright.');
+INSERT INTO t1(docid,words) VALUES(1026001,'And there was a famine in the land, beside the first famine that was in the days of Abraham. And Isaac went unto Abimelech king of the Philistines unto Gerar.');
+INSERT INTO t1(docid,words) VALUES(1026002,'And the LORD appeared unto him, and said, Go not down into Egypt; dwell in the land which I shall tell thee of:');
+INSERT INTO t1(docid,words) VALUES(1026003,'Sojourn in this land, and I will be with thee, and will bless thee; for unto thee, and unto thy seed, I will give all these countries, and I will perform the oath which I sware unto Abraham thy father;');
+INSERT INTO t1(docid,words) VALUES(1026004,'And I will make thy seed to multiply as the stars of heaven, and will give unto thy seed all these countries; and in thy seed shall all the nations of the earth be blessed;');
+INSERT INTO t1(docid,words) VALUES(1026005,'Because that Abraham obeyed my voice, and kept my charge, my commandments, my statutes, and my laws.');
+INSERT INTO t1(docid,words) VALUES(1026006,'And Isaac dwelt in Gerar:');
+INSERT INTO t1(docid,words) VALUES(1026007,'And the men of the place asked him of his wife; and he said, She is my sister: for he feared to say, She is my wife; lest, said he, the men of the place should kill me for Rebekah; because she was fair to look upon.');
+INSERT INTO t1(docid,words) VALUES(1026008,'And it came to pass, when he had been there a long time, that Abimelech king of the Philistines looked out at a window, and saw, and, behold, Isaac was sporting with Rebekah his wife.');
+INSERT INTO t1(docid,words) VALUES(1026009,'And Abimelech called Isaac, and said, Behold, of a surety she is thy wife; and how saidst thou, She is my sister? And Isaac said unto him, Because I said, Lest I die for her.');
+INSERT INTO t1(docid,words) VALUES(1026010,'And Abimelech said, What is this thou hast done unto us? one of the people might lightly have lien with thy wife, and thou shouldest have brought guiltiness upon us.');
+INSERT INTO t1(docid,words) VALUES(1026011,'And Abimelech charged all his people, saying, He that toucheth this man or his wife shall surely be put to death.');
+INSERT INTO t1(docid,words) VALUES(1026012,'Then Isaac sowed in that land, and received in the same year an hundredfold: and the LORD blessed him.');
+INSERT INTO t1(docid,words) VALUES(1026013,'And the man waxed great, and went forward, and grew until he became very great:');
+INSERT INTO t1(docid,words) VALUES(1026014,'For he had possession of flocks, and possession of herds, and great store of servants: and the Philistines envied him.');
+INSERT INTO t1(docid,words) VALUES(1026015,'For all the wells which his father''s servants had digged in the days of Abraham his father, the Philistines had stopped them, and filled them with earth.');
+INSERT INTO t1(docid,words) VALUES(1026016,'And Abimelech said unto Isaac, Go from us; for thou art much mightier than we.');
+INSERT INTO t1(docid,words) VALUES(1026017,'And Isaac departed thence, and pitched his tent in the valley of Gerar, and dwelt there.');
+INSERT INTO t1(docid,words) VALUES(1026018,'And Isaac digged again the wells of water, which they had digged in the days of Abraham his father; for the Philistines had stopped them after the death of Abraham: and he called their names after the names by which his father had called them.');
+INSERT INTO t1(docid,words) VALUES(1026019,'And Isaac''s servants digged in the valley, and found there a well of springing water.');
+INSERT INTO t1(docid,words) VALUES(1026020,'And the herdmen of Gerar did strive with Isaac''s herdmen, saying, The water is ours: and he called the name of the well Esek; because they strove with him.');
+INSERT INTO t1(docid,words) VALUES(1026021,'And they digged another well, and strove for that also: and he called the name of it Sitnah.');
+INSERT INTO t1(docid,words) VALUES(1026022,'And he removed from thence, and digged another well; and for that they strove not: and he called the name of it Rehoboth; and he said, For now the LORD hath made room for us, and we shall be fruitful in the land.');
+INSERT INTO t1(docid,words) VALUES(1026023,'And he went up from thence to Beersheba.');
+INSERT INTO t1(docid,words) VALUES(1026024,'And the LORD appeared unto him the same night, and said, I am the God of Abraham thy father: fear not, for I am with thee, and will bless thee, and multiply thy seed for my servant Abraham''s sake.');
+INSERT INTO t1(docid,words) VALUES(1026025,'And he builded an altar there, and called upon the name of the LORD, and pitched his tent there: and there Isaac''s servants digged a well.');
+INSERT INTO t1(docid,words) VALUES(1026026,'Then Abimelech went to him from Gerar, and Ahuzzath one of his friends, and Phichol the chief captain of his army.');
+INSERT INTO t1(docid,words) VALUES(1026027,'And Isaac said unto them, Wherefore come ye to me, seeing ye hate me, and have sent me away from you?');
+INSERT INTO t1(docid,words) VALUES(1026028,'And they said, We saw certainly that the LORD was with thee: and we said, Let there be now an oath betwixt us, even betwixt us and thee, and let us make a covenant with thee;');
+INSERT INTO t1(docid,words) VALUES(1026029,'That thou wilt do us no hurt, as we have not touched thee, and as we have done unto thee nothing but good, and have sent thee away in peace: thou art now the blessed of the LORD.');
+INSERT INTO t1(docid,words) VALUES(1026030,'And he made them a feast, and they did eat and drink.');
+INSERT INTO t1(docid,words) VALUES(1026031,'And they rose up betimes in the morning, and sware one to another: and Isaac sent them away, and they departed from him in peace.');
+INSERT INTO t1(docid,words) VALUES(1026032,'And it came to pass the same day, that Isaac''s servants came, and told him concerning the well which they had digged, and said unto him, We have found water.');
+INSERT INTO t1(docid,words) VALUES(1026033,'And he called it Shebah: therefore the name of the city is Beersheba unto this day.');
+INSERT INTO t1(docid,words) VALUES(1026034,'And Esau was forty years old when he took to wife Judith the daughter of Beeri the Hittite, and Bashemath the daughter of Elon the Hittite:');
+INSERT INTO t1(docid,words) VALUES(1026035,'Which were a grief of mind unto Isaac and to Rebekah.');
+INSERT INTO t1(docid,words) VALUES(1027001,'And it came to pass, that when Isaac was old, and his eyes were dim, so that he could not see, he called Esau his eldest son, and said unto him, My son: and he said unto him, Behold, here am I.');
+INSERT INTO t1(docid,words) VALUES(1027002,'And he said, Behold now, I am old, I know not the day of my death:');
+INSERT INTO t1(docid,words) VALUES(1027003,'Now therefore take, I pray thee, thy weapons, thy quiver and thy bow, and go out to the field, and take me some venison;');
+INSERT INTO t1(docid,words) VALUES(1027004,'And make me savoury meat, such as I love, and bring it to me, that I may eat; that my soul may bless thee before I die.');
+INSERT INTO t1(docid,words) VALUES(1027005,'And Rebekah heard when Isaac spake to Esau his son. And Esau went to the field to hunt for venison, and to bring it.');
+INSERT INTO t1(docid,words) VALUES(1027006,'And Rebekah spake unto Jacob her son, saying, Behold, I heard thy father speak unto Esau thy brother, saying,');
+INSERT INTO t1(docid,words) VALUES(1027007,'Bring me venison, and make me savoury meat, that I may eat, and bless thee before the LORD before my death.');
+INSERT INTO t1(docid,words) VALUES(1027008,'Now therefore, my son, obey my voice according to that which I command thee.');
+INSERT INTO t1(docid,words) VALUES(1027009,'Go now to the flock, and fetch me from thence two good kids of the goats; and I will make them savoury meat for thy father, such as he loveth:');
+INSERT INTO t1(docid,words) VALUES(1027010,'And thou shalt bring it to thy father, that he may eat, and that he may bless thee before his death.');
+INSERT INTO t1(docid,words) VALUES(1027011,'And Jacob said to Rebekah his mother, Behold, Esau my brother is a hairy man, and I am a smooth man:');
+INSERT INTO t1(docid,words) VALUES(1027012,'My father peradventure will feel me, and I shall seem to him as a deceiver; and I shall bring a curse upon me, and not a blessing.');
+INSERT INTO t1(docid,words) VALUES(1027013,'And his mother said unto him, Upon me be thy curse, my son: only obey my voice, and go fetch me them.');
+INSERT INTO t1(docid,words) VALUES(1027014,'And he went, and fetched, and brought them to his mother: and his mother made savoury meat, such as his father loved.');
+INSERT INTO t1(docid,words) VALUES(1027015,'And Rebekah took goodly raiment of her eldest son Esau, which were with her in the house, and put them upon Jacob her younger son:');
+INSERT INTO t1(docid,words) VALUES(1027016,'And she put the skins of the kids of the goats upon his hands, and upon the smooth of his neck:');
+INSERT INTO t1(docid,words) VALUES(1027017,'And she gave the savoury meat and the bread, which she had prepared, into the hand of her son Jacob.');
+INSERT INTO t1(docid,words) VALUES(1027018,'And he came unto his father, and said, My father: and he said, Here am I; who art thou, my son?');
+INSERT INTO t1(docid,words) VALUES(1027019,'And Jacob said unto his father, I am Esau thy first born; I have done according as thou badest me: arise, I pray thee, sit and eat of my venison, that thy soul may bless me.');
+INSERT INTO t1(docid,words) VALUES(1027020,'And Isaac said unto his son, How is it that thou hast found it so quickly, my son? And he said, Because the LORD thy God brought it to me.');
+INSERT INTO t1(docid,words) VALUES(1027021,'And Isaac said unto Jacob, Come near, I pray thee, that I may feel thee, my son, whether thou be my very son Esau or not.');
+INSERT INTO t1(docid,words) VALUES(1027022,'And Jacob went near unto Isaac his father; and he felt him, and said, The voice is Jacob''s voice, but the hands are the hands of Esau.');
+INSERT INTO t1(docid,words) VALUES(1027023,'And he discerned him not, because his hands were hairy, as his brother Esau''s hands: so he blessed him.');
+INSERT INTO t1(docid,words) VALUES(1027024,'And he said, Art thou my very son Esau? And he said, I am.');
+INSERT INTO t1(docid,words) VALUES(1027025,'And he said, Bring it near to me, and I will eat of my son''s venison, that my soul may bless thee. And he brought it near to him, and he did eat: and he brought him wine and he drank.');
+INSERT INTO t1(docid,words) VALUES(1027026,'And his father Isaac said unto him, Come near now, and kiss me, my son.');
+INSERT INTO t1(docid,words) VALUES(1027027,'And he came near, and kissed him: and he smelled the smell of his raiment, and blessed him, and said, See, the smell of my son is as the smell of a field which the LORD hath blessed:');
+INSERT INTO t1(docid,words) VALUES(1027028,'Therefore God give thee of the dew of heaven, and the fatness of the earth, and plenty of corn and wine:');
+INSERT INTO t1(docid,words) VALUES(1027029,'Let people serve thee, and nations bow down to thee: be lord over thy brethren, and let thy mother''s sons bow down to thee: cursed be every one that curseth thee, and blessed be he that blesseth thee.');
+INSERT INTO t1(docid,words) VALUES(1027030,'And it came to pass, as soon as Isaac had made an end of blessing Jacob, and Jacob was yet scarce gone out from the presence of Isaac his father, that Esau his brother came in from his hunting.');
+INSERT INTO t1(docid,words) VALUES(1027031,'And he also had made savoury meat, and brought it unto his father, and said unto his father, Let my father arise, and eat of his son''s venison, that thy soul may bless me.');
+INSERT INTO t1(docid,words) VALUES(1027032,'And Isaac his father said unto him, Who art thou? And he said, I am thy son, thy firstborn Esau.');
+INSERT INTO t1(docid,words) VALUES(1027033,'And Isaac trembled very exceedingly, and said, Who? where is he that hath taken venison, and brought it me, and I have eaten of all before thou camest, and have blessed him? yea, and he shall be blessed.');
+INSERT INTO t1(docid,words) VALUES(1027034,'And when Esau heard the words of his father, he cried with a great and exceeding bitter cry, and said unto his father, Bless me, even me also, O my father.');
+INSERT INTO t1(docid,words) VALUES(1027035,'And he said, Thy brother came with subtilty, and hath taken away thy blessing.');
+INSERT INTO t1(docid,words) VALUES(1027036,'And he said, Is not he rightly named Jacob? for he hath supplanted me these two times: he took away my birthright; and, behold, now he hath taken away my blessing. And he said, Hast thou not reserved a blessing for me?');
+INSERT INTO t1(docid,words) VALUES(1027037,'And Isaac answered and said unto Esau, Behold, I have made him thy lord, and all his brethren have I given to him for servants; and with corn and wine have I sustained him: and what shall I do now unto thee, my son?');
+INSERT INTO t1(docid,words) VALUES(1027038,'And Esau said unto his father, Hast thou but one blessing, my father? bless me, even me also, O my father. And Esau lifted up his voice, and wept.');
+INSERT INTO t1(docid,words) VALUES(1027039,'And Isaac his father answered and said unto him, Behold, thy dwelling shall be the fatness of the earth, and of the dew of heaven from above;');
+INSERT INTO t1(docid,words) VALUES(1027040,'And by thy sword shalt thou live, and shalt serve thy brother; and it shall come to pass when thou shalt have the dominion, that thou shalt break his yoke from off thy neck.');
+INSERT INTO t1(docid,words) VALUES(1027041,'And Esau hated Jacob because of the blessing wherewith his father blessed him: and Esau said in his heart, The days of mourning for my father are at hand; then will I slay my brother Jacob.');
+INSERT INTO t1(docid,words) VALUES(1027042,'And these words of Esau her elder son were told to Rebekah: and she sent and called Jacob her younger son, and said unto him, Behold, thy brother Esau, as touching thee, doth comfort himself, purposing to kill thee.');
+INSERT INTO t1(docid,words) VALUES(1027043,'Now therefore, my son, obey my voice; arise, flee thou to Laban my brother to Haran;');
+INSERT INTO t1(docid,words) VALUES(1027044,'And tarry with him a few days, until thy brother''s fury turn away;');
+INSERT INTO t1(docid,words) VALUES(1027045,'Until thy brother''s anger turn away from thee, and he forget that which thou hast done to him: then I will send, and fetch thee from thence: why should I be deprived also of you both in one day?');
+INSERT INTO t1(docid,words) VALUES(1027046,'And Rebekah said to Isaac, I am weary of my life because of the daughters of Heth: if Jacob take a wife of the daughters of Heth, such as these which are of the daughters of the land, what good shall my life do me?');
+INSERT INTO t1(docid,words) VALUES(1028001,'And Isaac called Jacob, and blessed him, and charged him, and said unto him, Thou shalt not take a wife of the daughters of Canaan.');
+INSERT INTO t1(docid,words) VALUES(1028002,'Arise, go to Padanaram, to the house of Bethuel thy mother''s father; and take thee a wife from thence of the daughers of Laban thy mother''s brother.');
+INSERT INTO t1(docid,words) VALUES(1028003,'And God Almighty bless thee, and make thee fruitful, and multiply thee, that thou mayest be a multitude of people;');
+INSERT INTO t1(docid,words) VALUES(1028004,'And give thee the blessing of Abraham, to thee, and to thy seed with thee; that thou mayest inherit the land wherein thou art a stranger, which God gave unto Abraham.');
+INSERT INTO t1(docid,words) VALUES(1028005,'And Isaac sent away Jacob: and he went to Padanaram unto Laban, son of Bethuel the Syrian, the brother of Rebekah, Jacob''s and Esau''s mother.');
+INSERT INTO t1(docid,words) VALUES(1028006,'When Esau saw that Isaac had blessed Jacob, and sent him away to Padanaram, to take him a wife from thence; and that as he blessed him he gave him a charge, saying, Thou shalt not take a wife of the daughers of Canaan;');
+INSERT INTO t1(docid,words) VALUES(1028007,'And that Jacob obeyed his father and his mother, and was gone to Padanaram;');
+INSERT INTO t1(docid,words) VALUES(1028008,'And Esau seeing that the daughters of Canaan pleased not Isaac his father;');
+INSERT INTO t1(docid,words) VALUES(1028009,'Then went Esau unto Ishmael, and took unto the wives which he had Mahalath the daughter of Ishmael Abraham''s son, the sister of Nebajoth, to be his wife.');
+INSERT INTO t1(docid,words) VALUES(1028010,'And Jacob went out from Beersheba, and went toward Haran.');
+INSERT INTO t1(docid,words) VALUES(1028011,'And he lighted upon a certain place, and tarried there all night, because the sun was set; and he took of the stones of that place, and put them for his pillows, and lay down in that place to sleep.');
+INSERT INTO t1(docid,words) VALUES(1028012,'And he dreamed, and behold a ladder set up on the earth, and the top of it reached to heaven: and behold the angels of God ascending and descending on it.');
+INSERT INTO t1(docid,words) VALUES(1028013,'And, behold, the LORD stood above it, and said, I am the LORD God of Abraham thy father, and the God of Isaac: the land whereon thou liest, to thee will I give it, and to thy seed;');
+INSERT INTO t1(docid,words) VALUES(1028014,'And thy seed shall be as the dust of the earth, and thou shalt spread abroad to the west, and to the east, and to the north, and to the south: and in thee and in thy seed shall all the families of the earth be blessed.');
+INSERT INTO t1(docid,words) VALUES(1028015,'And, behold, I am with thee, and will keep thee in all places whither thou goest, and will bring thee again into this land; for I will not leave thee, until I have done that which I have spoken to thee of.');
+INSERT INTO t1(docid,words) VALUES(1028016,'And Jacob awaked out of his sleep, and he said, Surely the LORD is in this place; and I knew it not.');
+INSERT INTO t1(docid,words) VALUES(1028017,'And he was afraid, and said, How dreadful is this place! this is none other but the house of God, and this is the gate of heaven.');
+INSERT INTO t1(docid,words) VALUES(1028018,'And Jacob rose up early in the morning, and took the stone that he had put for his pillows, and set it up for a pillar, and poured oil upon the top of it.');
+INSERT INTO t1(docid,words) VALUES(1028019,'And he called the name of that place Bethel: but the name of that city was called Luz at the first.');
+INSERT INTO t1(docid,words) VALUES(1028020,'And Jacob vowed a vow, saying, If God will be with me, and will keep me in this way that I go, and will give me bread to eat, and raiment to put on,');
+INSERT INTO t1(docid,words) VALUES(1028021,'So that I come again to my father''s house in peace; then shall the LORD be my God:');
+INSERT INTO t1(docid,words) VALUES(1028022,'And this stone, which I have set for a pillar, shall be God''s house: and of all that thou shalt give me I will surely give the tenth unto thee.');
+INSERT INTO t1(docid,words) VALUES(1029001,'Then Jacob went on his journey, and came into the land of the people of the east.');
+INSERT INTO t1(docid,words) VALUES(1029002,'And he looked, and behold a well in the field, and, lo, there were three flocks of sheep lying by it; for out of that well they watered the flocks: and a great stone was upon the well''s mouth.');
+INSERT INTO t1(docid,words) VALUES(1029003,'And thither were all the flocks gathered: and they rolled the stone from the well''s mouth, and watered the sheep, and put the stone again upon the well''s mouth in his place.');
+INSERT INTO t1(docid,words) VALUES(1029004,'And Jacob said unto them, My brethren, whence be ye? And they said, Of Haran are we.');
+INSERT INTO t1(docid,words) VALUES(1029005,'And he said unto them, Know ye Laban the son of Nahor? And they said, We know him.');
+INSERT INTO t1(docid,words) VALUES(1029006,'And he said unto them, Is he well? And they said, He is well: and, behold, Rachel his daughter cometh with the sheep.');
+INSERT INTO t1(docid,words) VALUES(1029007,'And he said, Lo, it is yet high day, neither is it time that the cattle should be gathered together: water ye the sheep, and go and feed them.');
+INSERT INTO t1(docid,words) VALUES(1029008,'And they said, We cannot, until all the flocks be gathered together, and till they roll the stone from the well''s mouth; then we water the sheep.');
+INSERT INTO t1(docid,words) VALUES(1029009,'And while he yet spake with them, Rachel came with her father''s sheep; for she kept them.');
+INSERT INTO t1(docid,words) VALUES(1029010,'And it came to pass, when Jacob saw Rachel the daughter of Laban his mother''s brother, and the sheep of Laban his mother''s brother, that Jacob went near, and rolled the stone from the well''s mouth, and watered the flock of Laban his mother''s brother.');
+INSERT INTO t1(docid,words) VALUES(1029011,'And Jacob kissed Rachel, and lifted up his voice, and wept.');
+INSERT INTO t1(docid,words) VALUES(1029012,'And Jacob told Rachel that he was her father''s brother, and that he was Rebekah''s son: and she ran and told her father.');
+INSERT INTO t1(docid,words) VALUES(1029013,'And it came to pass, when Laban heard the tidings of Jacob his sister''s son, that he ran to meet him, and embraced him, and kissed him, and brought him to his house. And he told Laban all these things.');
+INSERT INTO t1(docid,words) VALUES(1029014,'And Laban said to him, Surely thou art my bone and my flesh. And he abode with him the space of a month.');
+INSERT INTO t1(docid,words) VALUES(1029015,'And Laban said unto Jacob, Because thou art my brother, shouldest thou therefore serve me for nought? tell me, what shall thy wages be?');
+INSERT INTO t1(docid,words) VALUES(1029016,'And Laban had two daughters: the name of the elder was Leah, and the name of the younger was Rachel.');
+INSERT INTO t1(docid,words) VALUES(1029017,'Leah was tender eyed; but Rachel was beautiful and well favoured.');
+INSERT INTO t1(docid,words) VALUES(1029018,'And Jacob loved Rachel; and said, I will serve thee seven years for Rachel thy younger daughter.');
+INSERT INTO t1(docid,words) VALUES(1029019,'And Laban said, It is better that I give her to thee, than that I should give her to another man: abide with me.');
+INSERT INTO t1(docid,words) VALUES(1029020,'And Jacob served seven years for Rachel; and they seemed unto him but a few days, for the love he had to her.');
+INSERT INTO t1(docid,words) VALUES(1029021,'And Jacob said unto Laban, Give me my wife, for my days are fulfilled, that I may go in unto her.');
+INSERT INTO t1(docid,words) VALUES(1029022,'And Laban gathered together all the men of the place, and made a feast.');
+INSERT INTO t1(docid,words) VALUES(1029023,'And it came to pass in the evening, that he took Leah his daughter, and brought her to him; and he went in unto her.');
+INSERT INTO t1(docid,words) VALUES(1029024,'And Laban gave unto his daughter Leah Zilpah his maid for an handmaid.');
+INSERT INTO t1(docid,words) VALUES(1029025,'And it came to pass, that in the morning, behold, it was Leah: and he said to Laban, What is this thou hast done unto me? did not I serve with thee for Rachel? wherefore then hast thou beguiled me?');
+INSERT INTO t1(docid,words) VALUES(1029026,'And Laban said, It must not be so done in our country, to give the younger before the firstborn.');
+INSERT INTO t1(docid,words) VALUES(1029027,'Fulfil her week, and we will give thee this also for the service which thou shalt serve with me yet seven other years.');
+INSERT INTO t1(docid,words) VALUES(1029028,'And Jacob did so, and fulfilled her week: and he gave him Rachel his daughter to wife also.');
+INSERT INTO t1(docid,words) VALUES(1029029,'And Laban gave to Rachel his daughter Bilhah his handmaid to be her maid.');
+INSERT INTO t1(docid,words) VALUES(1029030,'And he went in also unto Rachel, and he loved also Rachel more than Leah, and served with him yet seven other years.');
+INSERT INTO t1(docid,words) VALUES(1029031,'And when the LORD saw that Leah was hated, he opened her womb: but Rachel was barren.');
+INSERT INTO t1(docid,words) VALUES(1029032,'And Leah conceived, and bare a son, and she called his name Reuben: for she said, Surely the LORD hath looked upon my affliction; now therefore my husband will love me.');
+INSERT INTO t1(docid,words) VALUES(1029033,'And she conceived again, and bare a son; and said, Because the LORD hath heard I was hated, he hath therefore given me this son also: and she called his name Simeon.');
+INSERT INTO t1(docid,words) VALUES(1029034,'And she conceived again, and bare a son; and said, Now this time will my husband be joined unto me, because I have born him three sons: therefore was his name called Levi.');
+INSERT INTO t1(docid,words) VALUES(1029035,'And she conceived again, and bare a son: and she said, Now will I praise the LORD: therefore she called his name Judah; and left bearing.');
+INSERT INTO t1(docid,words) VALUES(1030001,'And when Rachel saw that she bare Jacob no children, Rachel envied her sister; and said unto Jacob, Give me children, or else I die.');
+INSERT INTO t1(docid,words) VALUES(1030002,'And Jacob''s anger was kindled against Rachel: and he said, Am I in God''s stead, who hath withheld from thee the fruit of the womb?');
+INSERT INTO t1(docid,words) VALUES(1030003,'And she said, Behold my maid Bilhah, go in unto her; and she shall bear upon my knees, that I may also have children by her.');
+INSERT INTO t1(docid,words) VALUES(1030004,'And she gave him Bilhah her handmaid to wife: and Jacob went in unto her.');
+INSERT INTO t1(docid,words) VALUES(1030005,'And Bilhah conceived, and bare Jacob a son.');
+INSERT INTO t1(docid,words) VALUES(1030006,'And Rachel said, God hath judged me, and hath also heard my voice, and hath given me a son: therefore called she his name Dan.');
+INSERT INTO t1(docid,words) VALUES(1030007,'And Bilhah Rachel''s maid conceived again, and bare Jacob a second son.');
+INSERT INTO t1(docid,words) VALUES(1030008,'And Rachel said, With great wrestlings have I wrestled with my sister, and I have prevailed: and she called his name Naphtali.');
+INSERT INTO t1(docid,words) VALUES(1030009,'When Leah saw that she had left bearing, she took Zilpah her maid, and gave her Jacob to wife.');
+INSERT INTO t1(docid,words) VALUES(1030010,'And Zilpah Leah''s maid bare Jacob a son.');
+INSERT INTO t1(docid,words) VALUES(1030011,'And Leah said, A troop cometh: and she called his name Gad.');
+INSERT INTO t1(docid,words) VALUES(1030012,'And Zilpah Leah''s maid bare Jacob a second son.');
+INSERT INTO t1(docid,words) VALUES(1030013,'And Leah said, Happy am I, for the daughters will call me blessed: and she called his name Asher.');
+INSERT INTO t1(docid,words) VALUES(1030014,'And Reuben went in the days of wheat harvest, and found mandrakes in the field, and brought them unto his mother Leah. Then Rachel said to Leah, Give me, I pray thee, of thy son''s mandrakes.');
+INSERT INTO t1(docid,words) VALUES(1030015,'And she said unto her, Is it a small matter that thou hast taken my husband? and wouldest thou take away my son''s mandrakes also? And Rachel said, Therefore he shall lie with thee to night for thy son''s mandrakes.');
+INSERT INTO t1(docid,words) VALUES(1030016,'And Jacob came out of the field in the evening, and Leah went out to meet him, and said, Thou must come in unto me; for surely I have hired thee with my son''s mandrakes. And he lay with her that night.');
+INSERT INTO t1(docid,words) VALUES(1030017,'And God hearkened unto Leah, and she conceived, and bare Jacob the fifth son.');
+INSERT INTO t1(docid,words) VALUES(1030018,'And Leah said, God hath given me my hire, because I have given my maiden to my husband: and she called his name Issachar.');
+INSERT INTO t1(docid,words) VALUES(1030019,'And Leah conceived again, and bare Jacob the sixth son.');
+INSERT INTO t1(docid,words) VALUES(1030020,'And Leah said, God hath endued me with a good dowry; now will my husband dwell with me, because I have born him six sons: and she called his name Zebulun.');
+INSERT INTO t1(docid,words) VALUES(1030021,'And afterwards she bare a daughter, and called her name Dinah.');
+INSERT INTO t1(docid,words) VALUES(1030022,'And God remembered Rachel, and God hearkened to her, and opened her womb.');
+INSERT INTO t1(docid,words) VALUES(1030023,'And she conceived, and bare a son; and said, God hath taken away my reproach:');
+INSERT INTO t1(docid,words) VALUES(1030024,'And she called his name Joseph; and said, The LORD shall add to me another son.');
+INSERT INTO t1(docid,words) VALUES(1030025,'And it came to pass, when Rachel had born Joseph, that Jacob said unto Laban, Send me away, that I may go unto mine own place, and to my country.');
+INSERT INTO t1(docid,words) VALUES(1030026,'Give me my wives and my children, for whom I have served thee, and let me go: for thou knowest my service which I have done thee.');
+INSERT INTO t1(docid,words) VALUES(1030027,'And Laban said unto him, I pray thee, if I have found favour in thine eyes, tarry: for I have learned by experience that the LORD hath blessed me for thy sake.');
+INSERT INTO t1(docid,words) VALUES(1030028,'And he said, Appoint me thy wages, and I will give it.');
+INSERT INTO t1(docid,words) VALUES(1030029,'And he said unto him, Thou knowest how I have served thee, and how thy cattle was with me.');
+INSERT INTO t1(docid,words) VALUES(1030030,'For it was little which thou hadst before I came, and it is now increased unto a multitude; and the LORD hath blessed thee since my coming: and now when shall I provide for mine own house also?');
+INSERT INTO t1(docid,words) VALUES(1030031,'And he said, What shall I give thee? And Jacob said, Thou shalt not give me any thing: if thou wilt do this thing for me, I will again feed and keep thy flock.');
+INSERT INTO t1(docid,words) VALUES(1030032,'I will pass through all thy flock to day, removing from thence all the speckled and spotted cattle, and all the brown cattle among the sheep, and the spotted and speckled among the goats: and of such shall be my hire.');
+INSERT INTO t1(docid,words) VALUES(1030033,'So shall my righteousness answer for me in time to come, when it shall come for my hire before thy face: every one that is not speckled and spotted among the goats, and brown among the sheep, that shall be counted stolen with me.');
+INSERT INTO t1(docid,words) VALUES(1030034,'And Laban said, Behold, I would it might be according to thy word.');
+INSERT INTO t1(docid,words) VALUES(1030035,'And he removed that day the he goats that were ringstraked and spotted, and all the she goats that were speckled and spotted, and every one that had some white in it, and all the brown among the sheep, and gave them into the hand of his sons.');
+INSERT INTO t1(docid,words) VALUES(1030036,'And he set three days'' journey betwixt himself and Jacob: and Jacob fed the rest of Laban''s flocks.');
+INSERT INTO t1(docid,words) VALUES(1030037,'And Jacob took him rods of green poplar, and of the hazel and chesnut tree; and pilled white strakes in them, and made the white appear which was in the rods.');
+INSERT INTO t1(docid,words) VALUES(1030038,'And he set the rods which he had pilled before the flocks in the gutters in the watering troughs when the flocks came to drink, that they should conceive when they came to drink.');
+INSERT INTO t1(docid,words) VALUES(1030039,'And the flocks conceived before the rods, and brought forth cattle ringstraked, speckled, and spotted.');
+INSERT INTO t1(docid,words) VALUES(1030040,'And Jacob did separate the lambs, and set the faces of the flocks toward the ringstraked, and all the brown in the flock of Laban; and he put his own flocks by themselves, and put them not unto Laban''s cattle.');
+INSERT INTO t1(docid,words) VALUES(1030041,'And it came to pass, whensoever the stronger cattle did conceive, that Jacob laid the rods before the eyes of the cattle in the gutters, that they might conceive among the rods.');
+INSERT INTO t1(docid,words) VALUES(1030042,'But when the cattle were feeble, he put them not in: so the feebler were Laban''s, and the stronger Jacob''s.');
+INSERT INTO t1(docid,words) VALUES(1030043,'And the man increased exceedingly, and had much cattle, and maidservants, and menservants, and camels, and asses.');
+INSERT INTO t1(docid,words) VALUES(1031001,'And he heard the words of Laban''s sons, saying, Jacob hath taken away all that was our father''s; and of that which was our father''s hath he gotten all this glory.');
+INSERT INTO t1(docid,words) VALUES(1031002,'And Jacob beheld the countenance of Laban, and, behold, it was not toward him as before.');
+INSERT INTO t1(docid,words) VALUES(1031003,'And the LORD said unto Jacob, Return unto the land of thy fathers, and to thy kindred; and I will be with thee.');
+INSERT INTO t1(docid,words) VALUES(1031004,'And Jacob sent and called Rachel and Leah to the field unto his flock,');
+INSERT INTO t1(docid,words) VALUES(1031005,'And said unto them, I see your father''s countenance, that it is not toward me as before; but the God of my father hath been with me.');
+INSERT INTO t1(docid,words) VALUES(1031006,'And ye know that with all my power I have served your father.');
+INSERT INTO t1(docid,words) VALUES(1031007,'And your father hath deceived me, and changed my wages ten times; but God suffered him not to hurt me.');
+INSERT INTO t1(docid,words) VALUES(1031008,'If he said thus, The speckled shall be thy wages; then all the cattle bare speckled: and if he said thus, The ringstraked shall be thy hire; then bare all the cattle ringstraked.');
+INSERT INTO t1(docid,words) VALUES(1031009,'Thus God hath taken away the cattle of your father, and given them to me.');
+INSERT INTO t1(docid,words) VALUES(1031010,'And it came to pass at the time that the cattle conceived, that I lifted up mine eyes, and saw in a dream, and, behold, the rams which leaped upon the cattle were ringstraked, speckled, and grisled.');
+INSERT INTO t1(docid,words) VALUES(1031011,'And the angel of God spake unto me in a dream, saying, Jacob: And I said, Here am I.');
+INSERT INTO t1(docid,words) VALUES(1031012,'And he said, Lift up now thine eyes, and see, all the rams which leap upon the cattle are ringstraked, speckled, and grisled: for I have seen all that Laban doeth unto thee.');
+INSERT INTO t1(docid,words) VALUES(1031013,'I am the God of Bethel, where thou anointedst the pillar, and where thou vowedst a vow unto me: now arise, get thee out from this land, and return unto the land of thy kindred.');
+INSERT INTO t1(docid,words) VALUES(1031014,'And Rachel and Leah answered and said unto him, Is there yet any portion or inheritance for us in our father''s house?');
+INSERT INTO t1(docid,words) VALUES(1031015,'Are we not counted of him strangers? for he hath sold us, and hath quite devoured also our money.');
+INSERT INTO t1(docid,words) VALUES(1031016,'For all the riches which God hath taken from our father, that is ours, and our children''s: now then, whatsoever God hath said unto thee, do.');
+INSERT INTO t1(docid,words) VALUES(1031017,'Then Jacob rose up, and set his sons and his wives upon camels;');
+INSERT INTO t1(docid,words) VALUES(1031018,'And he carried away all his cattle, and all his goods which he had gotten, the cattle of his getting, which he had gotten in Padanaram, for to go to Isaac his father in the land of Canaan.');
+INSERT INTO t1(docid,words) VALUES(1031019,'And Laban went to shear his sheep: and Rachel had stolen the images that were her father''s.');
+INSERT INTO t1(docid,words) VALUES(1031020,'And Jacob stole away unawares to Laban the Syrian, in that he told him not that he fled.');
+INSERT INTO t1(docid,words) VALUES(1031021,'So he fled with all that he had; and he rose up, and passed over the river, and set his face toward the mount Gilead.');
+INSERT INTO t1(docid,words) VALUES(1031022,'And it was told Laban on the third day that Jacob was fled.');
+INSERT INTO t1(docid,words) VALUES(1031023,'And he took his brethren with him, and pursued after him seven days'' journey; and they overtook him in the mount Gilead.');
+INSERT INTO t1(docid,words) VALUES(1031024,'And God came to Laban the Syrian in a dream by night, and said unto him, Take heed that thou speak not to Jacob either good or bad.');
+INSERT INTO t1(docid,words) VALUES(1031025,'Then Laban overtook Jacob. Now Jacob had pitched his tent in the mount: and Laban with his brethren pitched in the mount of Gilead.');
+INSERT INTO t1(docid,words) VALUES(1031026,'And Laban said to Jacob, What hast thou done, that thou hast stolen away unawares to me, and carried away my daughters, as captives taken with the sword?');
+INSERT INTO t1(docid,words) VALUES(1031027,'Wherefore didst thou flee away secretly, and steal away from me; and didst not tell me, that I might have sent thee away with mirth, and with songs, with tabret, and with harp?');
+INSERT INTO t1(docid,words) VALUES(1031028,'And hast not suffered me to kiss my sons and my daughters? thou hast now done foolishly in so doing.');
+INSERT INTO t1(docid,words) VALUES(1031029,'It is in the power of my hand to do you hurt: but the God of your father spake unto me yesternight, saying, Take thou heed that thou speak not to Jacob either good or bad.');
+INSERT INTO t1(docid,words) VALUES(1031030,'And now, though thou wouldest needs be gone, because thou sore longedst after thy father''s house, yet wherefore hast thou stolen my gods?');
+INSERT INTO t1(docid,words) VALUES(1031031,'And Jacob answered and said to Laban, Because I was afraid: for I said, Peradventure thou wouldest take by force thy daughters from me.');
+INSERT INTO t1(docid,words) VALUES(1031032,'With whomsoever thou findest thy gods, let him not live: before our brethren discern thou what is thine with me, and take it to thee. For Jacob knew not that Rachel had stolen them.');
+INSERT INTO t1(docid,words) VALUES(1031033,'And Laban went into Jacob''s tent, and into Leah''s tent, and into the two maidservants'' tents; but he found them not. Then went he out of Leah''s tent, and entered into Rachel''s tent.');
+INSERT INTO t1(docid,words) VALUES(1031034,'Now Rachel had taken the images, and put them in the camel''s furniture, and sat upon them. And Laban searched all the tent, but found them not.');
+INSERT INTO t1(docid,words) VALUES(1031035,'And she said to her father, Let it not displease my lord that I cannot rise up before thee; for the custom of women is upon me. And he searched but found not the images.');
+INSERT INTO t1(docid,words) VALUES(1031036,'And Jacob was wroth, and chode with Laban: and Jacob answered and said to Laban, What is my trespass? what is my sin, that thou hast so hotly pursued after me?');
+INSERT INTO t1(docid,words) VALUES(1031037,'Whereas thou hast searched all my stuff, what hast thou found of all thy household stuff? set it here before my brethren and thy brethren, that they may judge betwixt us both.');
+INSERT INTO t1(docid,words) VALUES(1031038,'This twenty years have I been with thee; thy ewes and thy she goats have not cast their young, and the rams of thy flock have I not eaten.');
+INSERT INTO t1(docid,words) VALUES(1031039,'That which was torn of beasts I brought not unto thee; I bare the loss of it; of my hand didst thou require it, whether stolen by day, or stolen by night.');
+INSERT INTO t1(docid,words) VALUES(1031040,'Thus I was; in the day the drought consumed me, and the frost by night; and my sleep departed from mine eyes.');
+INSERT INTO t1(docid,words) VALUES(1031041,'Thus have I been twenty years in thy house; I served thee fourteen years for thy two daughters, and six years for thy cattle: and thou hast changed my wages ten times.');
+INSERT INTO t1(docid,words) VALUES(1031042,'Except the God of my father, the God of Abraham, and the fear of Isaac, had been with me, surely thou hadst sent me away now empty. God hath seen mine affliction and the labour of my hands, and rebuked thee yesternight.');
+INSERT INTO t1(docid,words) VALUES(1031043,'And Laban answered and said unto Jacob, These daughters are my daughters, and these children are my children, and these cattle are my cattle, and all that thou seest is mine: and what can I do this day unto these my daughters, or unto their children which they have born?');
+INSERT INTO t1(docid,words) VALUES(1031044,'Now therefore come thou, let us make a covenant, I and thou; and let it be for a witness between me and thee.');
+INSERT INTO t1(docid,words) VALUES(1031045,'And Jacob took a stone, and set it up for a pillar.');
+INSERT INTO t1(docid,words) VALUES(1031046,'And Jacob said unto his brethren, Gather stones; and they took stones, and made an heap: and they did eat there upon the heap.');
+INSERT INTO t1(docid,words) VALUES(1031047,'And Laban called it Jegarsahadutha: but Jacob called it Galeed.');
+INSERT INTO t1(docid,words) VALUES(1031048,'And Laban said, This heap is a witness between me and thee this day. Therefore was the name of it called Galeed;');
+INSERT INTO t1(docid,words) VALUES(1031049,'And Mizpah; for he said, The LORD watch between me and thee, when we are absent one from another.');
+INSERT INTO t1(docid,words) VALUES(1031050,'If thou shalt afflict my daughters, or if thou shalt take other wives beside my daughters, no man is with us; see, God is witness betwixt me and thee.');
+INSERT INTO t1(docid,words) VALUES(1031051,'And Laban said to Jacob, Behold this heap, and behold this pillar, which I have cast betwixt me and thee:');
+INSERT INTO t1(docid,words) VALUES(1031052,'This heap be witness, and this pillar be witness, that I will not pass over this heap to thee, and that thou shalt not pass over this heap and this pillar unto me, for harm.');
+INSERT INTO t1(docid,words) VALUES(1031053,'The God of Abraham, and the God of Nahor, the God of their father, judge betwixt us. And Jacob sware by the fear of his father Isaac.');
+INSERT INTO t1(docid,words) VALUES(1031054,'Then Jacob offered sacrifice upon the mount, and called his brethren to eat bread: and they did eat bread, and tarried all night in the mount.');
+INSERT INTO t1(docid,words) VALUES(1031055,'And early in the morning Laban rose up, and kissed his sons and his daughters, and blessed them: and Laban departed, and returned unto his place.');
+INSERT INTO t1(docid,words) VALUES(1032001,'And Jacob went on his way, and the angels of God met him.');
+INSERT INTO t1(docid,words) VALUES(1032002,'And when Jacob saw them, he said, This is God''s host: and he called the name of that place Mahanaim.');
+INSERT INTO t1(docid,words) VALUES(1032003,'And Jacob sent messengers before him to Esau his brother unto the land of Seir, the country of Edom.');
+INSERT INTO t1(docid,words) VALUES(1032004,'And he commanded them, saying, Thus shall ye speak unto my lord Esau; Thy servant Jacob saith thus, I have sojourned with Laban, and stayed there until now:');
+INSERT INTO t1(docid,words) VALUES(1032005,'And I have oxen, and asses, flocks, and menservants, and womenservants: and I have sent to tell my lord, that I may find grace in thy sight.');
+INSERT INTO t1(docid,words) VALUES(1032006,'And the messengers returned to Jacob, saying, We came to thy brother Esau, and also he cometh to meet thee, and four hundred men with him.');
+INSERT INTO t1(docid,words) VALUES(1032007,'Then Jacob was greatly afraid and distressed: and he divided the people that was with him, and the flocks, and herds, and the camels, into two bands;');
+INSERT INTO t1(docid,words) VALUES(1032008,'And said, If Esau come to the one company, and smite it, then the other company which is left shall escape.');
+INSERT INTO t1(docid,words) VALUES(1032009,'And Jacob said, O God of my father Abraham, and God of my father Isaac, the LORD which saidst unto me, Return unto thy country, and to thy kindred, and I will deal well with thee:');
+INSERT INTO t1(docid,words) VALUES(1032010,'I am not worthy of the least of all the mercies, and of all the truth, which thou hast shewed unto thy servant; for with my staff I passed over this Jordan; and now I am become two bands.');
+INSERT INTO t1(docid,words) VALUES(1032011,'Deliver me, I pray thee, from the hand of my brother, from the hand of Esau: for I fear him, lest he will come and smite me, and the mother with the children.');
+INSERT INTO t1(docid,words) VALUES(1032012,'And thou saidst, I will surely do thee good, and make thy seed as the sand of the sea, which cannot be numbered for multitude.');
+INSERT INTO t1(docid,words) VALUES(1032013,'And he lodged there that same night; and took of that which came to his hand a present for Esau his brother;');
+INSERT INTO t1(docid,words) VALUES(1032014,'Two hundred she goats, and twenty he goats, two hundred ewes, and twenty rams,');
+INSERT INTO t1(docid,words) VALUES(1032015,'Thirty milch camels with their colts, forty kine, and ten bulls, twenty she asses, and ten foals.');
+INSERT INTO t1(docid,words) VALUES(1032016,'And he delivered them into the hand of his servants, every drove by themselves; and said unto his servants, Pass over before me, and put a space betwixt drove and drove.');
+INSERT INTO t1(docid,words) VALUES(1032017,'And he commanded the foremost, saying, When Esau my brother meeteth thee, and asketh thee, saying, Whose art thou? and whither goest thou? and whose are these before thee?');
+INSERT INTO t1(docid,words) VALUES(1032018,'Then thou shalt say, They be thy servant Jacob''s; it is a present sent unto my lord Esau: and, behold, also he is behind us.');
+INSERT INTO t1(docid,words) VALUES(1032019,'And so commanded he the second, and the third, and all that followed the droves, saying, On this manner shall ye speak unto Esau, when ye find him.');
+INSERT INTO t1(docid,words) VALUES(1032020,'And say ye moreover, Behold, thy servant Jacob is behind us. For he said, I will appease him with the present that goeth before me, and afterward I will see his face; peradventure he will accept of me.');
+INSERT INTO t1(docid,words) VALUES(1032021,'So went the present over before him: and himself lodged that night in the company.');
+INSERT INTO t1(docid,words) VALUES(1032022,'And he rose up that night, and took his two wives, and his two womenservants, and his eleven sons, and passed over the ford Jabbok.');
+INSERT INTO t1(docid,words) VALUES(1032023,'And he took them, and sent them over the brook, and sent over that he had.');
+INSERT INTO t1(docid,words) VALUES(1032024,'And Jacob was left alone; and there wrestled a man with him until the breaking of the day.');
+INSERT INTO t1(docid,words) VALUES(1032025,'And when he saw that he prevailed not against him, he touched the hollow of his thigh; and the hollow of Jacob''s thigh was out of joint, as he wrestled with him.');
+INSERT INTO t1(docid,words) VALUES(1032026,'And he said, Let me go, for the day breaketh. And he said, I will not let thee go, except thou bless me.');
+INSERT INTO t1(docid,words) VALUES(1032027,'And he said unto him, What is thy name? And he said, Jacob.');
+INSERT INTO t1(docid,words) VALUES(1032028,'And he said, Thy name shall be called no more Jacob, but Israel: for as a prince hast thou power with God and with men, and hast prevailed.');
+INSERT INTO t1(docid,words) VALUES(1032029,'And Jacob asked him, and said, Tell me, I pray thee, thy name. And he said, Wherefore is it that thou dost ask after my name? And he blessed him there.');
+INSERT INTO t1(docid,words) VALUES(1032030,'And Jacob called the name of the place Peniel: for I have seen God face to face, and my life is preserved.');
+INSERT INTO t1(docid,words) VALUES(1032031,'And as he passed over Penuel the sun rose upon him, and he halted upon his thigh.');
+INSERT INTO t1(docid,words) VALUES(1032032,'Therefore the children of Israel eat not of the sinew which shrank, which is upon the hollow of the thigh, unto this day: because he touched the hollow of Jacob''s thigh in the sinew that shrank.');
+INSERT INTO t1(docid,words) VALUES(1033001,'And Jacob lifted up his eyes, and looked, and, behold, Esau came, and with him four hundred men. And he divided the children unto Leah, and unto Rachel, and unto the two handmaids.');
+INSERT INTO t1(docid,words) VALUES(1033002,'And he put the handmaids and their children foremost, and Leah and her children after, and Rachel and Joseph hindermost.');
+INSERT INTO t1(docid,words) VALUES(1033003,'And he passed over before them, and bowed himself to the ground seven times, until he came near to his brother.');
+INSERT INTO t1(docid,words) VALUES(1033004,'And Esau ran to meet him, and embraced him, and fell on his neck, and kissed him: and they wept.');
+INSERT INTO t1(docid,words) VALUES(1033005,'And he lifted up his eyes, and saw the women and the children; and said, Who are those with thee? And he said, The children which God hath graciously given thy servant.');
+INSERT INTO t1(docid,words) VALUES(1033006,'Then the handmaidens came near, they and their children, and they bowed themselves.');
+INSERT INTO t1(docid,words) VALUES(1033007,'And Leah also with her children came near, and bowed themselves: and after came Joseph near and Rachel, and they bowed themselves.');
+INSERT INTO t1(docid,words) VALUES(1033008,'And he said, What meanest thou by all this drove which I met? And he said, These are to find grace in the sight of my lord.');
+INSERT INTO t1(docid,words) VALUES(1033009,'And Esau said, I have enough, my brother; keep that thou hast unto thyself.');
+INSERT INTO t1(docid,words) VALUES(1033010,'And Jacob said, Nay, I pray thee, if now I have found grace in thy sight, then receive my present at my hand: for therefore I have seen thy face, as though I had seen the face of God, and thou wast pleased with me.');
+INSERT INTO t1(docid,words) VALUES(1033011,'Take, I pray thee, my blessing that is brought to thee; because God hath dealt graciously with me, and because I have enough. And he urged him, and he took it.');
+INSERT INTO t1(docid,words) VALUES(1033012,'And he said, Let us take our journey, and let us go, and I will go before thee.');
+INSERT INTO t1(docid,words) VALUES(1033013,'And he said unto him, My lord knoweth that the children are tender, and the flocks and herds with young are with me: and if men should overdrive them one day, all the flock will die.');
+INSERT INTO t1(docid,words) VALUES(1033014,'Let my lord, I pray thee, pass over before his servant: and I will lead on softly, according as the cattle that goeth before me and the children be able to endure, until I come unto my lord unto Seir.');
+INSERT INTO t1(docid,words) VALUES(1033015,'And Esau said, Let me now leave with thee some of the folk that are with me. And he said, What needeth it? let me find grace in the sight of my lord.');
+INSERT INTO t1(docid,words) VALUES(1033016,'So Esau returned that day on his way unto Seir.');
+INSERT INTO t1(docid,words) VALUES(1033017,'And Jacob journeyed to Succoth, and built him an house, and made booths for his cattle: therefore the name of the place is called Succoth.');
+INSERT INTO t1(docid,words) VALUES(1033018,'And Jacob came to Shalem, a city of Shechem, which is in the land of Canaan, when he came from Padanaram; and pitched his tent before the city.');
+INSERT INTO t1(docid,words) VALUES(1033019,'And he bought a parcel of a field, where he had spread his tent, at the hand of the children of Hamor, Shechem''s father, for an hundred pieces of money.');
+INSERT INTO t1(docid,words) VALUES(1033020,'And he erected there an altar, and called it EleloheIsrael.');
+INSERT INTO t1(docid,words) VALUES(1034001,'And Dinah the daughter of Leah, which she bare unto Jacob, went out to see the daughters of the land.');
+INSERT INTO t1(docid,words) VALUES(1034002,'And when Shechem the son of Hamor the Hivite, prince of the country, saw her, he took her, and lay with her, and defiled her.');
+INSERT INTO t1(docid,words) VALUES(1034003,'And his soul clave unto Dinah the daughter of Jacob, and he loved the damsel, and spake kindly unto the damsel.');
+INSERT INTO t1(docid,words) VALUES(1034004,'And Shechem spake unto his father Hamor, saying, Get me this damsel to wife.');
+INSERT INTO t1(docid,words) VALUES(1034005,'And Jacob heard that he had defiled Dinah his daughter: now his sons were with his cattle in the field: and Jacob held his peace until they were come.');
+INSERT INTO t1(docid,words) VALUES(1034006,'And Hamor the father of Shechem went out unto Jacob to commune with him.');
+INSERT INTO t1(docid,words) VALUES(1034007,'And the sons of Jacob came out of the field when they heard it: and the men were grieved, and they were very wroth, because he had wrought folly in Israel in lying with Jacob''s daughter: which thing ought not to be done.');
+INSERT INTO t1(docid,words) VALUES(1034008,'And Hamor communed with them, saying, The soul of my son Shechem longeth for your daughter: I pray you give her him to wife.');
+INSERT INTO t1(docid,words) VALUES(1034009,'And make ye marriages with us, and give your daughters unto us, and take our daughters unto you.');
+INSERT INTO t1(docid,words) VALUES(1034010,'And ye shall dwell with us: and the land shall be before you; dwell and trade ye therein, and get you possessions therein.');
+INSERT INTO t1(docid,words) VALUES(1034011,'And Shechem said unto her father and unto her brethren, Let me find grace in your eyes, and what ye shall say unto me I will give.');
+INSERT INTO t1(docid,words) VALUES(1034012,'Ask me never so much dowry and gift, and I will give according as ye shall say unto me: but give me the damsel to wife.');
+INSERT INTO t1(docid,words) VALUES(1034013,'And the sons of Jacob answered Shechem and Hamor his father deceitfully, and said, because he had defiled Dinah their sister:');
+INSERT INTO t1(docid,words) VALUES(1034014,'And they said unto them, We cannot do this thing, to give our sister to one that is uncircumcised; for that were a reproach unto us:');
+INSERT INTO t1(docid,words) VALUES(1034015,'But in this will we consent unto you: If ye will be as we be, that every male of you be circumcised;');
+INSERT INTO t1(docid,words) VALUES(1034016,'Then will we give our daughters unto you, and we will take your daughters to us, and we will dwell with you, and we will become one people.');
+INSERT INTO t1(docid,words) VALUES(1034017,'But if ye will not hearken unto us, to be circumcised; then will we take our daughter, and we will be gone.');
+INSERT INTO t1(docid,words) VALUES(1034018,'And their words pleased Hamor, and Shechem Hamor''s son.');
+INSERT INTO t1(docid,words) VALUES(1034019,'And the young man deferred not to do the thing, because he had delight in Jacob''s daughter: and he was more honourable than all the house of his father.');
+INSERT INTO t1(docid,words) VALUES(1034020,'And Hamor and Shechem his son came unto the gate of their city, and communed with the men of their city, saying,');
+INSERT INTO t1(docid,words) VALUES(1034021,'These men are peaceable with us; therefore let them dwell in the land, and trade therein; for the land, behold, it is large enough for them; let us take their daughters to us for wives, and let us give them our daughters.');
+INSERT INTO t1(docid,words) VALUES(1034022,'Only herein will the men consent unto us for to dwell with us, to be one people, if every male among us be circumcised, as they are circumcised.');
+INSERT INTO t1(docid,words) VALUES(1034023,'Shall not their cattle and their substance and every beast of their''s be our''s? only let us consent unto them, and they will dwell with us.');
+INSERT INTO t1(docid,words) VALUES(1034024,'And unto Hamor and unto Shechem his son hearkened all that went out of the gate of his city; and every male was circumcised, all that went out of the gate of his city.');
+INSERT INTO t1(docid,words) VALUES(1034025,'And it came to pass on the third day, when they were sore, that two of the sons of Jacob, Simeon and Levi, Dinah''s brethren, took each man his sword, and came upon the city boldly, and slew all the males.');
+INSERT INTO t1(docid,words) VALUES(1034026,'And they slew Hamor and Shechem his son with the edge of the sword, and took Dinah out of Shechem''s house, and went out.');
+INSERT INTO t1(docid,words) VALUES(1034027,'The sons of Jacob came upon the slain, and spoiled the city, because they had defiled their sister.');
+INSERT INTO t1(docid,words) VALUES(1034028,'They took their sheep, and their oxen, and their asses, and that which was in the city, and that which was in the field,');
+INSERT INTO t1(docid,words) VALUES(1034029,'And all their wealth, and all their little ones, and their wives took they captive, and spoiled even all that was in the house.');
+INSERT INTO t1(docid,words) VALUES(1034030,'And Jacob said to Simeon and Levi, Ye have troubled me to make me to stink among the inhabitants of the land, among the Canaanites and the Perizzites: and I being few in number, they shall gather themselves together against me, and slay me; and I shall be destroyed, I and my house.');
+INSERT INTO t1(docid,words) VALUES(1034031,'And they said, Should he deal with our sister as with an harlot?');
+INSERT INTO t1(docid,words) VALUES(1035001,'And God said unto Jacob, Arise, go up to Bethel, and dwell there: and make there an altar unto God, that appeared unto thee when thou fleddest from the face of Esau thy brother.');
+INSERT INTO t1(docid,words) VALUES(1035002,'Then Jacob said unto his household, and to all that were with him, Put away the strange gods that are among you, and be clean, and change your garments:');
+INSERT INTO t1(docid,words) VALUES(1035003,'And let us arise, and go up to Bethel; and I will make there an altar unto God, who answered me in the day of my distress, and was with me in the way which I went.');
+INSERT INTO t1(docid,words) VALUES(1035004,'And they gave unto Jacob all the strange gods which were in their hand, and all their earrings which were in their ears; and Jacob hid them under the oak which was by Shechem.');
+INSERT INTO t1(docid,words) VALUES(1035005,'And they journeyed: and the terror of God was upon the cities that were round about them, and they did not pursue after the sons of Jacob.');
+INSERT INTO t1(docid,words) VALUES(1035006,'So Jacob came to Luz, which is in the land of Canaan, that is, Bethel, he and all the people that were with him.');
+INSERT INTO t1(docid,words) VALUES(1035007,'And he built there an altar, and called the place Elbethel: because there God appeared unto him, when he fled from the face of his brother.');
+INSERT INTO t1(docid,words) VALUES(1035008,'But Deborah Rebekah''s nurse died, and she was buried beneath Bethel under an oak: and the name of it was called Allonbachuth.');
+INSERT INTO t1(docid,words) VALUES(1035009,'And God appeared unto Jacob again, when he came out of Padanaram, and blessed him.');
+INSERT INTO t1(docid,words) VALUES(1035010,'And God said unto him, Thy name is Jacob: thy name shall not be called any more Jacob, but Israel shall be thy name: and he called his name Israel.');
+INSERT INTO t1(docid,words) VALUES(1035011,'And God said unto him, I am God Almighty: be fruitful and multiply; a nation and a company of nations shall be of thee, and kings shall come out of thy loins;');
+INSERT INTO t1(docid,words) VALUES(1035012,'And the land which I gave Abraham and Isaac, to thee I will give it, and to thy seed after thee will I give the land.');
+INSERT INTO t1(docid,words) VALUES(1035013,'And God went up from him in the place where he talked with him.');
+INSERT INTO t1(docid,words) VALUES(1035014,'And Jacob set up a pillar in the place where he talked with him, even a pillar of stone: and he poured a drink offering thereon, and he poured oil thereon.');
+INSERT INTO t1(docid,words) VALUES(1035015,'And Jacob called the name of the place where God spake with him, Bethel.');
+INSERT INTO t1(docid,words) VALUES(1035016,'And they journeyed from Bethel; and there was but a little way to come to Ephrath: and Rachel travailed, and she had hard labour.');
+INSERT INTO t1(docid,words) VALUES(1035017,'And it came to pass, when she was in hard labour, that the midwife said unto her, Fear not; thou shalt have this son also.');
+INSERT INTO t1(docid,words) VALUES(1035018,'And it came to pass, as her soul was in departing, (for she died) that she called his name Benoni: but his father called him Benjamin.');
+INSERT INTO t1(docid,words) VALUES(1035019,'And Rachel died, and was buried in the way to Ephrath, which is Bethlehem.');
+INSERT INTO t1(docid,words) VALUES(1035020,'And Jacob set a pillar upon her grave: that is the pillar of Rachel''s grave unto this day.');
+INSERT INTO t1(docid,words) VALUES(1035021,'And Israel journeyed, and spread his tent beyond the tower of Edar.');
+INSERT INTO t1(docid,words) VALUES(1035022,'And it came to pass, when Israel dwelt in that land, that Reuben went and lay with Bilhah his father''s concubine: and Israel heard it. Now the sons of Jacob were twelve:');
+INSERT INTO t1(docid,words) VALUES(1035023,'The sons of Leah; Reuben, Jacob''s firstborn, and Simeon, and Levi, and Judah, and Issachar, and Zebulun:');
+INSERT INTO t1(docid,words) VALUES(1035024,'The sons of Rachel; Joseph, and Benjamin:');
+INSERT INTO t1(docid,words) VALUES(1035025,'And the sons of Bilhah, Rachel''s handmaid; Dan, and Naphtali:');
+INSERT INTO t1(docid,words) VALUES(1035026,'And the sons of Zilpah, Leah''s handmaid: Gad, and Asher: these are the sons of Jacob, which were born to him in Padanaram.');
+INSERT INTO t1(docid,words) VALUES(1035027,'And Jacob came unto Isaac his father unto Mamre, unto the city of Arbah, which is Hebron, where Abraham and Isaac sojourned.');
+INSERT INTO t1(docid,words) VALUES(1035028,'And the days of Isaac were an hundred and fourscore years.');
+INSERT INTO t1(docid,words) VALUES(1035029,'And Isaac gave up the ghost, and died, and was gathered unto his people, being old and full of days: and his sons Esau and Jacob buried him.');
+INSERT INTO t1(docid,words) VALUES(1036001,'Now these are the generations of Esau, who is Edom.');
+INSERT INTO t1(docid,words) VALUES(1036002,'Esau took his wives of the daughters of Canaan; Adah the daughter of Elon the Hittite, and Aholibamah the daughter of Anah the daughter of Zibeon the Hivite;');
+INSERT INTO t1(docid,words) VALUES(1036003,'And Bashemath Ishmael''s daughter, sister of Nebajoth.');
+INSERT INTO t1(docid,words) VALUES(1036004,'And Adah bare to Esau Eliphaz; and Bashemath bare Reuel;');
+INSERT INTO t1(docid,words) VALUES(1036005,'And Aholibamah bare Jeush, and Jaalam, and Korah: these are the sons of Esau, which were born unto him in the land of Canaan.');
+INSERT INTO t1(docid,words) VALUES(1036006,'And Esau took his wives, and his sons, and his daughters, and all the persons of his house, and his cattle, and all his beasts, and all his substance, which he had got in the land of Canaan; and went into the country from the face of his brother Jacob.');
+INSERT INTO t1(docid,words) VALUES(1036007,'For their riches were more than that they might dwell together; and the land wherein they were strangers could not bear them because of their cattle.');
+INSERT INTO t1(docid,words) VALUES(1036008,'Thus dwelt Esau in mount Seir: Esau is Edom.');
+INSERT INTO t1(docid,words) VALUES(1036009,'And these are the generations of Esau the father of the Edomites in mount Seir:');
+INSERT INTO t1(docid,words) VALUES(1036010,'These are the names of Esau''s sons; Eliphaz the son of Adah the wife of Esau, Reuel the son of Bashemath the wife of Esau.');
+INSERT INTO t1(docid,words) VALUES(1036011,'And the sons of Eliphaz were Teman, Omar, Zepho, and Gatam, and Kenaz.');
+INSERT INTO t1(docid,words) VALUES(1036012,'And Timna was concubine to Eliphaz Esau''s son; and she bare to Eliphaz Amalek: these were the sons of Adah Esau''s wife.');
+INSERT INTO t1(docid,words) VALUES(1036013,'And these are the sons of Reuel; Nahath, and Zerah, Shammah, and Mizzah: these were the sons of Bashemath Esau''s wife.');
+INSERT INTO t1(docid,words) VALUES(1036014,'And these were the sons of Aholibamah, the daughter of Anah the daughter of Zibeon, Esau''s wife: and she bare to Esau Jeush, and Jaalam, and Korah.');
+INSERT INTO t1(docid,words) VALUES(1036015,'These were dukes of the sons of Esau: the sons of Eliphaz the firstborn son of Esau; duke Teman, duke Omar, duke Zepho, duke Kenaz,');
+INSERT INTO t1(docid,words) VALUES(1036016,'Duke Korah, duke Gatam, and duke Amalek: these are the dukes that came of Eliphaz in the land of Edom; these were the sons of Adah.');
+INSERT INTO t1(docid,words) VALUES(1036017,'And these are the sons of Reuel Esau''s son; duke Nahath, duke Zerah, duke Shammah, duke Mizzah: these are the dukes that came of Reuel in the land of Edom; these are the sons of Bashemath Esau''s wife.');
+INSERT INTO t1(docid,words) VALUES(1036018,'And these are the sons of Aholibamah Esau''s wife; duke Jeush, duke Jaalam, duke Korah: these were the dukes that came of Aholibamah the daughter of Anah, Esau''s wife.');
+INSERT INTO t1(docid,words) VALUES(1036019,'These are the sons of Esau, who is Edom, and these are their dukes.');
+INSERT INTO t1(docid,words) VALUES(1036020,'These are the sons of Seir the Horite, who inhabited the land; Lotan, and Shobal, and Zibeon, and Anah,');
+INSERT INTO t1(docid,words) VALUES(1036021,'And Dishon, and Ezer, and Dishan: these are the dukes of the Horites, the children of Seir in the land of Edom.');
+INSERT INTO t1(docid,words) VALUES(1036022,'And the children of Lotan were Hori and Hemam; and Lotan''s sister was Timna.');
+INSERT INTO t1(docid,words) VALUES(1036023,'And the children of Shobal were these; Alvan, and Manahath, and Ebal, Shepho, and Onam.');
+INSERT INTO t1(docid,words) VALUES(1036024,'And these are the children of Zibeon; both Ajah, and Anah: this was that Anah that found the mules in the wilderness, as he fed the asses of Zibeon his father.');
+INSERT INTO t1(docid,words) VALUES(1036025,'And the children of Anah were these; Dishon, and Aholibamah the daughter of Anah.');
+INSERT INTO t1(docid,words) VALUES(1036026,'And these are the children of Dishon; Hemdan, and Eshban, and Ithran, and Cheran.');
+INSERT INTO t1(docid,words) VALUES(1036027,'The children of Ezer are these; Bilhan, and Zaavan, and Akan.');
+INSERT INTO t1(docid,words) VALUES(1036028,'The children of Dishan are these; Uz, and Aran.');
+INSERT INTO t1(docid,words) VALUES(1036029,'These are the dukes that came of the Horites; duke Lotan, duke Shobal, duke Zibeon, duke Anah,');
+INSERT INTO t1(docid,words) VALUES(1036030,'Duke Dishon, duke Ezer, duke Dishan: these are the dukes that came of Hori, among their dukes in the land of Seir.');
+INSERT INTO t1(docid,words) VALUES(1036031,'And these are the kings that reigned in the land of Edom, before there reigned any king over the children of Israel.');
+INSERT INTO t1(docid,words) VALUES(1036032,'And Bela the son of Beor reigned in Edom: and the name of his city was Dinhabah.');
+INSERT INTO t1(docid,words) VALUES(1036033,'And Bela died, and Jobab the son of Zerah of Bozrah reigned in his stead.');
+INSERT INTO t1(docid,words) VALUES(1036034,'And Jobab died, and Husham of the land of Temani reigned in his stead.');
+INSERT INTO t1(docid,words) VALUES(1036035,'And Husham died, and Hadad the son of Bedad, who smote Midian in the field of Moab, reigned in his stead: and the name of his city was Avith.');
+INSERT INTO t1(docid,words) VALUES(1036036,'And Hadad died, and Samlah of Masrekah reigned in his stead.');
+INSERT INTO t1(docid,words) VALUES(1036037,'And Samlah died, and Saul of Rehoboth by the river reigned in his stead.');
+INSERT INTO t1(docid,words) VALUES(1036038,'And Saul died, and Baalhanan the son of Achbor reigned in his stead.');
+INSERT INTO t1(docid,words) VALUES(1036039,'And Baalhanan the son of Achbor died, and Hadar reigned in his stead: and the name of his city was Pau; and his wife''s name was Mehetabel, the daughter of Matred, the daughter of Mezahab.');
+INSERT INTO t1(docid,words) VALUES(1036040,'And these are the names of the dukes that came of Esau, according to their families, after their places, by their names; duke Timnah, duke Alvah, duke Jetheth,');
+INSERT INTO t1(docid,words) VALUES(1036041,'Duke Aholibamah, duke Elah, duke Pinon,');
+INSERT INTO t1(docid,words) VALUES(1036042,'Duke Kenaz, duke Teman, duke Mibzar,');
+INSERT INTO t1(docid,words) VALUES(1036043,'Duke Magdiel, duke Iram: these be the dukes of Edom, according to their habitations in the land of their possession: he is Esau the father of the Edomites.');
+INSERT INTO t1(docid,words) VALUES(1037001,'And Jacob dwelt in the land wherein his father was a stranger, in the land of Canaan.');
+INSERT INTO t1(docid,words) VALUES(1037002,'These are the generations of Jacob. Joseph, being seventeen years old, was feeding the flock with his brethren; and the lad was with the sons of Bilhah, and with the sons of Zilpah, his father''s wives: and Joseph brought unto his father their evil report.');
+INSERT INTO t1(docid,words) VALUES(1037003,'Now Israel loved Joseph more than all his children, because he was the son of his old age: and he made him a coat of many colours.');
+INSERT INTO t1(docid,words) VALUES(1037004,'And when his brethren saw that their father loved him more than all his brethren, they hated him, and could not speak peaceably unto him.');
+INSERT INTO t1(docid,words) VALUES(1037005,'And Joseph dreamed a dream, and he told it his brethren: and they hated him yet the more.');
+INSERT INTO t1(docid,words) VALUES(1037006,'And he said unto them, Hear, I pray you, this dream which I have dreamed:');
+INSERT INTO t1(docid,words) VALUES(1037007,'For, behold, we were binding sheaves in the field, and, lo, my sheaf arose, and also stood upright; and, behold, your sheaves stood round about, and made obeisance to my sheaf.');
+INSERT INTO t1(docid,words) VALUES(1037008,'And his brethren said to him, Shalt thou indeed reign over us? or shalt thou indeed have dominion over us? And they hated him yet the more for his dreams, and for his words.');
+INSERT INTO t1(docid,words) VALUES(1037009,'And he dreamed yet another dream, and told it his brethren, and said, Behold, I have dreamed a dream more; and, behold, the sun and the moon and the eleven stars made obeisance to me.');
+INSERT INTO t1(docid,words) VALUES(1037010,'And he told it to his father, and to his brethren: and his father rebuked him, and said unto him, What is this dream that thou hast dreamed? Shall I and thy mother and thy brethren indeed come to bow down ourselves to thee to the earth?');
+INSERT INTO t1(docid,words) VALUES(1037011,'And his brethren envied him; but his father observed the saying.');
+INSERT INTO t1(docid,words) VALUES(1037012,'And his brethren went to feed their father''s flock in Shechem.');
+INSERT INTO t1(docid,words) VALUES(1037013,'And Israel said unto Joseph, Do not thy brethren feed the flock in Shechem? come, and I will send thee unto them. And he said to him, Here am I.');
+INSERT INTO t1(docid,words) VALUES(1037014,'And he said to him, Go, I pray thee, see whether it be well with thy brethren, and well with the flocks; and bring me word again. So he sent him out of the vale of Hebron, and he came to Shechem.');
+INSERT INTO t1(docid,words) VALUES(1037015,'And a certain man found him, and, behold, he was wandering in the field: and the man asked him, saying, What seekest thou?');
+INSERT INTO t1(docid,words) VALUES(1037016,'And he said, I seek my brethren: tell me, I pray thee, where they feed their flocks.');
+INSERT INTO t1(docid,words) VALUES(1037017,'And the man said, They are departed hence; for I heard them say, Let us go to Dothan. And Joseph went after his brethren, and found them in Dothan.');
+INSERT INTO t1(docid,words) VALUES(1037018,'And when they saw him afar off, even before he came near unto them, they conspired against him to slay him.');
+INSERT INTO t1(docid,words) VALUES(1037019,'And they said one to another, Behold, this dreamer cometh.');
+INSERT INTO t1(docid,words) VALUES(1037020,'Come now therefore, and let us slay him, and cast him into some pit, and we will say, Some evil beast hath devoured him: and we shall see what will become of his dreams.');
+INSERT INTO t1(docid,words) VALUES(1037021,'And Reuben heard it, and he delivered him out of their hands; and said, Let us not kill him.');
+INSERT INTO t1(docid,words) VALUES(1037022,'And Reuben said unto them, Shed no blood, but cast him into this pit that is in the wilderness, and lay no hand upon him; that he might rid him out of their hands, to deliver him to his father again.');
+INSERT INTO t1(docid,words) VALUES(1037023,'And it came to pass, when Joseph was come unto his brethren, that they stript Joseph out of his coat, his coat of many colours that was on him;');
+INSERT INTO t1(docid,words) VALUES(1037024,'And they took him, and cast him into a pit: and the pit was empty, there was no water in it.');
+INSERT INTO t1(docid,words) VALUES(1037025,'And they sat down to eat bread: and they lifted up their eyes and looked, and, behold, a company of Ishmeelites came from Gilead with their camels bearing spicery and balm and myrrh, going to carry it down to Egypt.');
+INSERT INTO t1(docid,words) VALUES(1037026,'And Judah said unto his brethren, What profit is it if we slay our brother, and conceal his blood?');
+INSERT INTO t1(docid,words) VALUES(1037027,'Come, and let us sell him to the Ishmeelites, and let not our hand be upon him; for he is our brother and our flesh. And his brethren were content.');
+INSERT INTO t1(docid,words) VALUES(1037028,'Then there passed by Midianites merchantmen; and they drew and lifted up Joseph out of the pit, and sold Joseph to the Ishmeelites for twenty pieces of silver: and they brought Joseph into Egypt.');
+INSERT INTO t1(docid,words) VALUES(1037029,'And Reuben returned unto the pit; and, behold, Joseph was not in the pit; and he rent his clothes.');
+INSERT INTO t1(docid,words) VALUES(1037030,'And he returned unto his brethren, and said, The child is not; and I, whither shall I go?');
+INSERT INTO t1(docid,words) VALUES(1037031,'And they took Joseph''s coat, and killed a kid of the goats, and dipped the coat in the blood;');
+INSERT INTO t1(docid,words) VALUES(1037032,'And they sent the coat of many colours, and they brought it to their father; and said, This have we found: know now whether it be thy son''s coat or no.');
+INSERT INTO t1(docid,words) VALUES(1037033,'And he knew it, and said, It is my son''s coat; an evil beast hath devoured him; Joseph is without doubt rent in pieces.');
+INSERT INTO t1(docid,words) VALUES(1037034,'And Jacob rent his clothes, and put sackcloth upon his loins, and mourned for his son many days.');
+INSERT INTO t1(docid,words) VALUES(1037035,'And all his sons and all his daughters rose up to comfort him; but he refused to be comforted; and he said, For I will go down into the grave unto my son mourning. Thus his father wept for him.');
+INSERT INTO t1(docid,words) VALUES(1037036,'And the Midianites sold him into Egypt unto Potiphar, an officer of Pharaoh''s, and captain of the guard.');
+INSERT INTO t1(docid,words) VALUES(1038001,'And it came to pass at that time, that Judah went down from his brethren, and turned in to a certain Adullamite, whose name was Hirah.');
+INSERT INTO t1(docid,words) VALUES(1038002,'And Judah saw there a daughter of a certain Canaanite, whose name was Shuah; and he took her, and went in unto her.');
+INSERT INTO t1(docid,words) VALUES(1038003,'And she conceived, and bare a son; and he called his name Er.');
+INSERT INTO t1(docid,words) VALUES(1038004,'And she conceived again, and bare a son; and she called his name Onan.');
+INSERT INTO t1(docid,words) VALUES(1038005,'And she yet again conceived, and bare a son; and called his name Shelah: and he was at Chezib, when she bare him.');
+INSERT INTO t1(docid,words) VALUES(1038006,'And Judah took a wife for Er his firstborn, whose name was Tamar.');
+INSERT INTO t1(docid,words) VALUES(1038007,'And Er, Judah''s firstborn, was wicked in the sight of the LORD; and the LORD slew him.');
+INSERT INTO t1(docid,words) VALUES(1038008,'And Judah said unto Onan, Go in unto thy brother''s wife, and marry her, and raise up seed to thy brother.');
+INSERT INTO t1(docid,words) VALUES(1038009,'And Onan knew that the seed should not be his; and it came to pass, when he went in unto his brother''s wife, that he spilled it on the ground, lest that he should give seed to his brother.');
+INSERT INTO t1(docid,words) VALUES(1038010,'And the thing which he did displeased the LORD: wherefore he slew him also.');
+INSERT INTO t1(docid,words) VALUES(1038011,'Then said Judah to Tamar his daughter in law, Remain a widow at thy father''s house, till Shelah my son be grown: for he said, Lest peradventure he die also, as his brethren did. And Tamar went and dwelt in her father''s house.');
+INSERT INTO t1(docid,words) VALUES(1038012,'And in process of time the daughter of Shuah Judah''s wife died; and Judah was comforted, and went up unto his sheepshearers to Timnath, he and his friend Hirah the Adullamite.');
+INSERT INTO t1(docid,words) VALUES(1038013,'And it was told Tamar, saying, Behold thy father in law goeth up to Timnath to shear his sheep.');
+INSERT INTO t1(docid,words) VALUES(1038014,'And she put her widow''s garments off from her, and covered her with a vail, and wrapped herself, and sat in an open place, which is by the way to Timnath; for she saw that Shelah was grown, and she was not given unto him to wife.');
+INSERT INTO t1(docid,words) VALUES(1038015,'When Judah saw her, he thought her to be an harlot; because she had covered her face.');
+INSERT INTO t1(docid,words) VALUES(1038016,'And he turned unto her by the way, and said, Go to, I pray thee, let me come in unto thee; (for he knew not that she was his daughter in law.) And she said, What wilt thou give me, that thou mayest come in unto me?');
+INSERT INTO t1(docid,words) VALUES(1038017,'And he said, I will send thee a kid from the flock. And she said, Wilt thou give me a pledge, till thou send it?');
+INSERT INTO t1(docid,words) VALUES(1038018,'And he said, What pledge shall I give thee? And she said, Thy signet, and thy bracelets, and thy staff that is in thine hand. And he gave it her, and came in unto her, and she conceived by him.');
+INSERT INTO t1(docid,words) VALUES(1038019,'And she arose, and went away, and laid by her vail from her, and put on the garments of her widowhood.');
+INSERT INTO t1(docid,words) VALUES(1038020,'And Judah sent the kid by the hand of his friend the Adullamite, to receive his pledge from the woman''s hand: but he found her not.');
+INSERT INTO t1(docid,words) VALUES(1038021,'Then he asked the men of that place, saying, Where is the harlot, that was openly by the way side? And they said, There was no harlot in this place.');
+INSERT INTO t1(docid,words) VALUES(1038022,'And he returned to Judah, and said, I cannot find her; and also the men of the place said, that there was no harlot in this place.');
+INSERT INTO t1(docid,words) VALUES(1038023,'And Judah said, Let her take it to her, lest we be shamed: behold, I sent this kid, and thou hast not found her.');
+INSERT INTO t1(docid,words) VALUES(1038024,'And it came to pass about three months after, that it was told Judah, saying, Tamar thy daughter in law hath played the harlot; and also, behold, she is with child by whoredom. And Judah said, Bring her forth, and let her be burnt.');
+INSERT INTO t1(docid,words) VALUES(1038025,'When she was brought forth, she sent to her father in law, saying, By the man, whose these are, am I with child: and she said, Discern, I pray thee, whose are these, the signet, and bracelets, and staff.');
+INSERT INTO t1(docid,words) VALUES(1038026,'And Judah acknowledged them, and said, She hath been more righteous than I; because that I gave her not to Shelah my son. And he knew her again no more.');
+INSERT INTO t1(docid,words) VALUES(1038027,'And it came to pass in the time of her travail, that, behold, twins were in her womb.');
+INSERT INTO t1(docid,words) VALUES(1038028,'And it came to pass, when she travailed, that the one put out his hand: and the midwife took and bound upon his hand a scarlet thread, saying, This came out first.');
+INSERT INTO t1(docid,words) VALUES(1038029,'And it came to pass, as he drew back his hand, that, behold, his brother came out: and she said, How hast thou broken forth? this breach be upon thee: therefore his name was called Pharez.');
+INSERT INTO t1(docid,words) VALUES(1038030,'And afterward came out his brother, that had the scarlet thread upon his hand: and his name was called Zarah.');
+INSERT INTO t1(docid,words) VALUES(1039001,'And Joseph was brought down to Egypt; and Potiphar, an officer of Pharaoh, captain of the guard, an Egyptian, bought him of the hands of the Ishmeelites, which had brought him down thither.');
+INSERT INTO t1(docid,words) VALUES(1039002,'And the LORD was with Joseph, and he was a prosperous man; and he was in the house of his master the Egyptian.');
+INSERT INTO t1(docid,words) VALUES(1039003,'And his master saw that the LORD was with him, and that the LORD made all that he did to prosper in his hand.');
+INSERT INTO t1(docid,words) VALUES(1039004,'And Joseph found grace in his sight, and he served him: and he made him overseer over his house, and all that he had he put into his hand.');
+INSERT INTO t1(docid,words) VALUES(1039005,'And it came to pass from the time that he had made him overseer in his house, and over all that he had, that the LORD blessed the Egyptian''s house for Joseph''s sake; and the blessing of the LORD was upon all that he had in the house, and in the field.');
+INSERT INTO t1(docid,words) VALUES(1039006,'And he left all that he had in Joseph''s hand; and he knew not ought he had, save the bread which he did eat. And Joseph was a goodly person, and well favoured.');
+INSERT INTO t1(docid,words) VALUES(1039007,'And it came to pass after these things, that his master''s wife cast her eyes upon Joseph; and she said, Lie with me.');
+INSERT INTO t1(docid,words) VALUES(1039008,'But he refused, and said unto his master''s wife, Behold, my master wotteth not what is with me in the house, and he hath committed all that he hath to my hand;');
+INSERT INTO t1(docid,words) VALUES(1039009,'There is none greater in this house than I; neither hath he kept back any thing from me but thee, because thou art his wife: how then can I do this great wickedness, and sin against God?');
+INSERT INTO t1(docid,words) VALUES(1039010,'And it came to pass, as she spake to Joseph day by day, that he hearkened not unto her, to lie by her, or to be with her.');
+INSERT INTO t1(docid,words) VALUES(1039011,'And it came to pass about this time, that Joseph went into the house to do his business; and there was none of the men of the house there within.');
+INSERT INTO t1(docid,words) VALUES(1039012,'And she caught him by his garment, saying, Lie with me: and he left his garment in her hand, and fled, and got him out.');
+INSERT INTO t1(docid,words) VALUES(1039013,'And it came to pass, when she saw that he had left his garment in her hand, and was fled forth,');
+INSERT INTO t1(docid,words) VALUES(1039014,'That she called unto the men of her house, and spake unto them, saying, See, he hath brought in an Hebrew unto us to mock us; he came in unto me to lie with me, and I cried with a loud voice:');
+INSERT INTO t1(docid,words) VALUES(1039015,'And it came to pass, when he heard that I lifted up my voice and cried, that he left his garment with me, and fled, and got him out.');
+INSERT INTO t1(docid,words) VALUES(1039016,'And she laid up his garment by her, until his lord came home.');
+INSERT INTO t1(docid,words) VALUES(1039017,'And she spake unto him according to these words, saying, The Hebrew servant, which thou hast brought unto us, came in unto me to mock me:');
+INSERT INTO t1(docid,words) VALUES(1039018,'And it came to pass, as I lifted up my voice and cried, that he left his garment with me, and fled out.');
+INSERT INTO t1(docid,words) VALUES(1039019,'And it came to pass, when his master heard the words of his wife, which she spake unto him, saying, After this manner did thy servant to me; that his wrath was kindled.');
+INSERT INTO t1(docid,words) VALUES(1039020,'And Joseph''s master took him, and put him into the prison, a place where the king''s prisoners were bound: and he was there in the prison.');
+INSERT INTO t1(docid,words) VALUES(1039021,'But the LORD was with Joseph, and shewed him mercy, and gave him favour in the sight of the keeper of the prison.');
+INSERT INTO t1(docid,words) VALUES(1039022,'And the keeper of the prison committed to Joseph''s hand all the prisoners that were in the prison; and whatsoever they did there, he was the doer of it.');
+INSERT INTO t1(docid,words) VALUES(1039023,'The keeper of the prison looked not to any thing that was under his hand; because the LORD was with him, and that which he did, the LORD made it to prosper.');
+INSERT INTO t1(docid,words) VALUES(1040001,'And it came to pass after these things, that the butler of the king of Egypt and his baker had offended their lord the king of Egypt.');
+INSERT INTO t1(docid,words) VALUES(1040002,'And Pharaoh was wroth against two of his officers, against the chief of the butlers, and against the chief of the bakers.');
+INSERT INTO t1(docid,words) VALUES(1040003,'And he put them in ward in the house of the captain of the guard, into the prison, the place where Joseph was bound.');
+INSERT INTO t1(docid,words) VALUES(1040004,'And the captain of the guard charged Joseph with them, and he served them: and they continued a season in ward.');
+INSERT INTO t1(docid,words) VALUES(1040005,'And they dreamed a dream both of them, each man his dream in one night, each man according to the interpretation of his dream, the butler and the baker of the king of Egypt, which were bound in the prison.');
+INSERT INTO t1(docid,words) VALUES(1040006,'And Joseph came in unto them in the morning, and looked upon them, and, behold, they were sad.');
+INSERT INTO t1(docid,words) VALUES(1040007,'And he asked Pharaoh''s officers that were with him in the ward of his lord''s house, saying, Wherefore look ye so sadly to day?');
+INSERT INTO t1(docid,words) VALUES(1040008,'And they said unto him, We have dreamed a dream, and there is no interpreter of it. And Joseph said unto them, Do not interpretations belong to God? tell me them, I pray you.');
+INSERT INTO t1(docid,words) VALUES(1040009,'And the chief butler told his dream to Joseph, and said to him, In my dream, behold, a vine was before me;');
+INSERT INTO t1(docid,words) VALUES(1040010,'And in the vine were three branches: and it was as though it budded, and her blossoms shot forth; and the clusters thereof brought forth ripe grapes:');
+INSERT INTO t1(docid,words) VALUES(1040011,'And Pharaoh''s cup was in my hand: and I took the grapes, and pressed them into Pharaoh''s cup, and I gave the cup into Pharaoh''s hand.');
+INSERT INTO t1(docid,words) VALUES(1040012,'And Joseph said unto him, This is the interpretation of it: The three branches are three days:');
+INSERT INTO t1(docid,words) VALUES(1040013,'Yet within three days shall Pharaoh lift up thine head, and restore thee unto thy place: and thou shalt deliver Pharaoh''s cup into his hand, after the former manner when thou wast his butler.');
+INSERT INTO t1(docid,words) VALUES(1040014,'But think on me when it shall be well with thee, and shew kindness, I pray thee, unto me, and make mention of me unto Pharaoh, and bring me out of this house:');
+INSERT INTO t1(docid,words) VALUES(1040015,'For indeed I was stolen away out of the land of the Hebrews: and here also have I done nothing that they should put me into the dungeon.');
+INSERT INTO t1(docid,words) VALUES(1040016,'When the chief baker saw that the interpretation was good, he said unto Joseph, I also was in my dream, and, behold, I had three white baskets on my head:');
+INSERT INTO t1(docid,words) VALUES(1040017,'And in the uppermost basket there was of all manner of bakemeats for Pharaoh; and the birds did eat them out of the basket upon my head.');
+INSERT INTO t1(docid,words) VALUES(1040018,'And Joseph answered and said, This is the interpretation thereof: The three baskets are three days:');
+INSERT INTO t1(docid,words) VALUES(1040019,'Yet within three days shall Pharaoh lift up thy head from off thee, and shall hang thee on a tree; and the birds shall eat thy flesh from off thee.');
+INSERT INTO t1(docid,words) VALUES(1040020,'And it came to pass the third day, which was Pharaoh''s birthday, that he made a feast unto all his servants: and he lifted up the head of the chief butler and of the chief baker among his servants.');
+INSERT INTO t1(docid,words) VALUES(1040021,'And he restored the chief butler unto his butlership again; and he gave the cup into Pharaoh''s hand:');
+INSERT INTO t1(docid,words) VALUES(1040022,'But he hanged the chief baker: as Joseph had interpreted to them.');
+INSERT INTO t1(docid,words) VALUES(1040023,'Yet did not the chief butler remember Joseph, but forgat him.');
+INSERT INTO t1(docid,words) VALUES(1041001,'And it came to pass at the end of two full years, that Pharaoh dreamed: and, behold, he stood by the river.');
+INSERT INTO t1(docid,words) VALUES(1041002,'And, behold, there came up out of the river seven well favoured kine and fatfleshed; and they fed in a meadow.');
+INSERT INTO t1(docid,words) VALUES(1041003,'And, behold, seven other kine came up after them out of the river, ill favoured and leanfleshed; and stood by the other kine upon the brink of the river.');
+INSERT INTO t1(docid,words) VALUES(1041004,'And the ill favoured and leanfleshed kine did eat up the seven well favoured and fat kine. So Pharaoh awoke.');
+INSERT INTO t1(docid,words) VALUES(1041005,'And he slept and dreamed the second time: and, behold, seven ears of corn came up upon one stalk, rank and good.');
+INSERT INTO t1(docid,words) VALUES(1041006,'And, behold, seven thin ears and blasted with the east wind sprung up after them.');
+INSERT INTO t1(docid,words) VALUES(1041007,'And the seven thin ears devoured the seven rank and full ears. And Pharaoh awoke, and, behold, it was a dream.');
+INSERT INTO t1(docid,words) VALUES(1041008,'And it came to pass in the morning that his spirit was troubled; and he sent and called for all the magicians of Egypt, and all the wise men thereof: and Pharaoh told them his dream; but there was none that could interpret them unto Pharaoh.');
+INSERT INTO t1(docid,words) VALUES(1041009,'Then spake the chief butler unto Pharaoh, saying, I do remember my faults this day:');
+INSERT INTO t1(docid,words) VALUES(1041010,'Pharaoh was wroth with his servants, and put me in ward in the captain of the guard''s house, both me and the chief baker:');
+INSERT INTO t1(docid,words) VALUES(1041011,'And we dreamed a dream in one night, I and he; we dreamed each man according to the interpretation of his dream.');
+INSERT INTO t1(docid,words) VALUES(1041012,'And there was there with us a young man, an Hebrew, servant to the captain of the guard; and we told him, and he interpreted to us our dreams; to each man according to his dream he did interpret.');
+INSERT INTO t1(docid,words) VALUES(1041013,'And it came to pass, as he interpreted to us, so it was; me he restored unto mine office, and him he hanged.');
+INSERT INTO t1(docid,words) VALUES(1041014,'Then Pharaoh sent and called Joseph, and they brought him hastily out of the dungeon: and he shaved himself, and changed his raiment, and came in unto Pharaoh.');
+INSERT INTO t1(docid,words) VALUES(1041015,'And Pharaoh said unto Joseph, I have dreamed a dream, and there is none that can interpret it: and I have heard say of thee, that thou canst understand a dream to interpret it.');
+INSERT INTO t1(docid,words) VALUES(1041016,'And Joseph answered Pharaoh, saying, It is not in me: God shall give Pharaoh an answer of peace.');
+INSERT INTO t1(docid,words) VALUES(1041017,'And Pharaoh said unto Joseph, In my dream, behold, I stood upon the bank of the river:');
+INSERT INTO t1(docid,words) VALUES(1041018,'And, behold, there came up out of the river seven kine, fatfleshed and well favoured; and they fed in a meadow:');
+INSERT INTO t1(docid,words) VALUES(1041019,'And, behold, seven other kine came up after them, poor and very ill favoured and leanfleshed, such as I never saw in all the land of Egypt for badness:');
+INSERT INTO t1(docid,words) VALUES(1041020,'And the lean and the ill favoured kine did eat up the first seven fat kine:');
+INSERT INTO t1(docid,words) VALUES(1041021,'And when they had eaten them up, it could not be known that they had eaten them; but they were still ill favoured, as at the beginning. So I awoke.');
+INSERT INTO t1(docid,words) VALUES(1041022,'And I saw in my dream, and, behold, seven ears came up in one stalk, full and good:');
+INSERT INTO t1(docid,words) VALUES(1041023,'And, behold, seven ears, withered, thin, and blasted with the east wind, sprung up after them:');
+INSERT INTO t1(docid,words) VALUES(1041024,'And the thin ears devoured the seven good ears: and I told this unto the magicians; but there was none that could declare it to me.');
+INSERT INTO t1(docid,words) VALUES(1041025,'And Joseph said unto Pharaoh, The dream of Pharaoh is one: God hath shewed Pharaoh what he is about to do.');
+INSERT INTO t1(docid,words) VALUES(1041026,'The seven good kine are seven years; and the seven good ears are seven years: the dream is one.');
+INSERT INTO t1(docid,words) VALUES(1041027,'And the seven thin and ill favoured kine that came up after them are seven years; and the seven empty ears blasted with the east wind shall be seven years of famine.');
+INSERT INTO t1(docid,words) VALUES(1041028,'This is the thing which I have spoken unto Pharaoh: What God is about to do he sheweth unto Pharaoh.');
+INSERT INTO t1(docid,words) VALUES(1041029,'Behold, there come seven years of great plenty throughout all the land of Egypt:');
+INSERT INTO t1(docid,words) VALUES(1041030,'And there shall arise after them seven years of famine; and all the plenty shall be forgotten in the land of Egypt; and the famine shall consume the land;');
+INSERT INTO t1(docid,words) VALUES(1041031,'And the plenty shall not be known in the land by reason of that famine following; for it shall be very grievous.');
+INSERT INTO t1(docid,words) VALUES(1041032,'And for that the dream was doubled unto Pharaoh twice; it is because the thing is established by God, and God will shortly bring it to pass.');
+INSERT INTO t1(docid,words) VALUES(1041033,'Now therefore let Pharaoh look out a man discreet and wise, and set him over the land of Egypt.');
+INSERT INTO t1(docid,words) VALUES(1041034,'Let Pharaoh do this, and let him appoint officers over the land, and take up the fifth part of the land of Egypt in the seven plenteous years.');
+INSERT INTO t1(docid,words) VALUES(1041035,'And let them gather all the food of those good years that come, and lay up corn under the hand of Pharaoh, and let them keep food in the cities.');
+INSERT INTO t1(docid,words) VALUES(1041036,'And that food shall be for store to the land against the seven years of famine, which shall be in the land of Egypt; that the land perish not through the famine.');
+INSERT INTO t1(docid,words) VALUES(1041037,'And the thing was good in the eyes of Pharaoh, and in the eyes of all his servants.');
+INSERT INTO t1(docid,words) VALUES(1041038,'And Pharaoh said unto his servants, Can we find such a one as this is, a man in whom the Spirit of God is?');
+INSERT INTO t1(docid,words) VALUES(1041039,'And Pharaoh said unto Joseph, Forasmuch as God hath shewed thee all this, there is none so discreet and wise as thou art:');
+INSERT INTO t1(docid,words) VALUES(1041040,'Thou shalt be over my house, and according unto thy word shall all my people be ruled: only in the throne will I be greater than thou.');
+INSERT INTO t1(docid,words) VALUES(1041041,'And Pharaoh said unto Joseph, See, I have set thee over all the land of Egypt.');
+INSERT INTO t1(docid,words) VALUES(1041042,'And Pharaoh took off his ring from his hand, and put it upon Joseph''s hand, and arrayed him in vestures of fine linen, and put a gold chain about his neck;');
+INSERT INTO t1(docid,words) VALUES(1041043,'And he made him to ride in the second chariot which he had; and they cried before him, Bow the knee: and he made him ruler over all the land of Egypt.');
+INSERT INTO t1(docid,words) VALUES(1041044,'And Pharaoh said unto Joseph, I am Pharaoh, and without thee shall no man lift up his hand or foot in all the land of Egypt.');
+INSERT INTO t1(docid,words) VALUES(1041045,'And Pharaoh called Joseph''s name Zaphnathpaaneah; and he gave him to wife Asenath the daughter of Potipherah priest of On. And Joseph went out over all the land of Egypt.');
+INSERT INTO t1(docid,words) VALUES(1041046,'And Joseph was thirty years old when he stood before Pharaoh king of Egypt. And Joseph went out from the presence of Pharaoh, and went throughout all the land of Egypt.');
+INSERT INTO t1(docid,words) VALUES(1041047,'And in the seven plenteous years the earth brought forth by handfuls.');
+INSERT INTO t1(docid,words) VALUES(1041048,'And he gathered up all the food of the seven years, which were in the land of Egypt, and laid up the food in the cities: the food of the field, which was round about every city, laid he up in the same.');
+INSERT INTO t1(docid,words) VALUES(1041049,'And Joseph gathered corn as the sand of the sea, very much, until he left numbering; for it was without number.');
+INSERT INTO t1(docid,words) VALUES(1041050,'And unto Joseph were born two sons before the years of famine came, which Asenath the daughter of Potipherah priest of On bare unto him.');
+INSERT INTO t1(docid,words) VALUES(1041051,'And Joseph called the name of the firstborn Manasseh: For God, said he, hath made me forget all my toil, and all my father''s house.');
+INSERT INTO t1(docid,words) VALUES(1041052,'And the name of the second called he Ephraim: For God hath caused me to be fruitful in the land of my affliction.');
+INSERT INTO t1(docid,words) VALUES(1041053,'And the seven years of plenteousness, that was in the land of Egypt, were ended.');
+INSERT INTO t1(docid,words) VALUES(1041054,'And the seven years of dearth began to come, according as Joseph had said: and the dearth was in all lands; but in all the land of Egypt there was bread.');
+INSERT INTO t1(docid,words) VALUES(1041055,'And when all the land of Egypt was famished, the people cried to Pharaoh for bread: and Pharaoh said unto all the Egyptians, Go unto Joseph; what he saith to you, do.');
+INSERT INTO t1(docid,words) VALUES(1041056,'And the famine was over all the face of the earth: and Joseph opened all the storehouses, and sold unto the Egyptians; and the famine waxed sore in the land of Egypt.');
+INSERT INTO t1(docid,words) VALUES(1041057,'And all countries came into Egypt to Joseph for to buy corn; because that the famine was so sore in all lands.');
+INSERT INTO t1(docid,words) VALUES(1042001,'Now when Jacob saw that there was corn in Egypt, Jacob said unto his sons, Why do ye look one upon another?');
+INSERT INTO t1(docid,words) VALUES(1042002,'And he said, Behold, I have heard that there is corn in Egypt: get you down thither, and buy for us from thence; that we may live, and not die.');
+INSERT INTO t1(docid,words) VALUES(1042003,'And Joseph''s ten brethren went down to buy corn in Egypt.');
+INSERT INTO t1(docid,words) VALUES(1042004,'But Benjamin, Joseph''s brother, Jacob sent not with his brethren; for he said, Lest peradventure mischief befall him.');
+INSERT INTO t1(docid,words) VALUES(1042005,'And the sons of Israel came to buy corn among those that came: for the famine was in the land of Canaan.');
+INSERT INTO t1(docid,words) VALUES(1042006,'And Joseph was the governor over the land, and he it was that sold to all the people of the land: and Joseph''s brethren came, and bowed down themselves before him with their faces to the earth.');
+INSERT INTO t1(docid,words) VALUES(1042007,'And Joseph saw his brethren, and he knew them, but made himself strange unto them, and spake roughly unto them; and he said unto them, Whence come ye? And they said, From the land of Canaan to buy food.');
+INSERT INTO t1(docid,words) VALUES(1042008,'And Joseph knew his brethren, but they knew not him.');
+INSERT INTO t1(docid,words) VALUES(1042009,'And Joseph remembered the dreams which he dreamed of them, and said unto them, Ye are spies; to see the nakedness of the land ye are come.');
+INSERT INTO t1(docid,words) VALUES(1042010,'And they said unto him, Nay, my lord, but to buy food are thy servants come.');
+INSERT INTO t1(docid,words) VALUES(1042011,'We are all one man''s sons; we are true men, thy servants are no spies.');
+INSERT INTO t1(docid,words) VALUES(1042012,'And he said unto them, Nay, but to see the nakedness of the land ye are come.');
+INSERT INTO t1(docid,words) VALUES(1042013,'And they said, Thy servants are twelve brethren, the sons of one man in the land of Canaan; and, behold, the youngest is this day with our father, and one is not.');
+INSERT INTO t1(docid,words) VALUES(1042014,'And Joseph said unto them, That is it that I spake unto you, saying, Ye are spies:');
+INSERT INTO t1(docid,words) VALUES(1042015,'Hereby ye shall be proved: By the life of Pharaoh ye shall not go forth hence, except your youngest brother come hither.');
+INSERT INTO t1(docid,words) VALUES(1042016,'Send one of you, and let him fetch your brother, and ye shall be kept in prison, that your words may be proved, whether there be any truth in you: or else by the life of Pharaoh surely ye are spies.');
+INSERT INTO t1(docid,words) VALUES(1042017,'And he put them all together into ward three days.');
+INSERT INTO t1(docid,words) VALUES(1042018,'And Joseph said unto them the third day, This do, and live; for I fear God:');
+INSERT INTO t1(docid,words) VALUES(1042019,'If ye be true men, let one of your brethren be bound in the house of your prison: go ye, carry corn for the famine of your houses:');
+INSERT INTO t1(docid,words) VALUES(1042020,'But bring your youngest brother unto me; so shall your words be verified, and ye shall not die. And they did so.');
+INSERT INTO t1(docid,words) VALUES(1042021,'And they said one to another, We are verily guilty concerning our brother, in that we saw the anguish of his soul, when he besought us, and we would not hear; therefore is this distress come upon us.');
+INSERT INTO t1(docid,words) VALUES(1042022,'And Reuben answered them, saying, Spake I not unto you, saying, Do not sin against the child; and ye would not hear? therefore, behold, also his blood is required.');
+INSERT INTO t1(docid,words) VALUES(1042023,'And they knew not that Joseph understood them; for he spake unto them by an interpreter.');
+INSERT INTO t1(docid,words) VALUES(1042024,'And he turned himself about from them, and wept; and returned to them again, and communed with them, and took from them Simeon, and bound him before their eyes.');
+INSERT INTO t1(docid,words) VALUES(1042025,'Then Joseph commanded to fill their sacks with corn, and to restore every man''s money into his sack, and to give them provision for the way: and thus did he unto them.');
+INSERT INTO t1(docid,words) VALUES(1042026,'And they laded their asses with the corn, and departed thence.');
+INSERT INTO t1(docid,words) VALUES(1042027,'And as one of them opened his sack to give his ass provender in the inn, he espied his money; for, behold, it was in his sack''s mouth.');
+INSERT INTO t1(docid,words) VALUES(1042028,'And he said unto his brethren, My money is restored; and, lo, it is even in my sack: and their heart failed them, and they were afraid, saying one to another, What is this that God hath done unto us?');
+INSERT INTO t1(docid,words) VALUES(1042029,'And they came unto Jacob their father unto the land of Canaan, and told him all that befell unto them; saying,');
+INSERT INTO t1(docid,words) VALUES(1042030,'The man, who is the lord of the land, spake roughly to us, and took us for spies of the country.');
+INSERT INTO t1(docid,words) VALUES(1042031,'And we said unto him, We are true men; we are no spies:');
+INSERT INTO t1(docid,words) VALUES(1042032,'We be twelve brethren, sons of our father; one is not, and the youngest is this day with our father in the land of Canaan.');
+INSERT INTO t1(docid,words) VALUES(1042033,'And the man, the lord of the country, said unto us, Hereby shall I know that ye are true men; leave one of your brethren here with me, and take food for the famine of your households, and be gone:');
+INSERT INTO t1(docid,words) VALUES(1042034,'And bring your youngest brother unto me: then shall I know that ye are no spies, but that ye are true men: so will I deliver you your brother, and ye shall traffick in the land.');
+INSERT INTO t1(docid,words) VALUES(1042035,'And it came to pass as they emptied their sacks, that, behold, every man''s bundle of money was in his sack: and when both they and their father saw the bundles of money, they were afraid.');
+INSERT INTO t1(docid,words) VALUES(1042036,'And Jacob their father said unto them, Me have ye bereaved of my children: Joseph is not, and Simeon is not, and ye will take Benjamin away: all these things are against me.');
+INSERT INTO t1(docid,words) VALUES(1042037,'And Reuben spake unto his father, saying, Slay my two sons, if I bring him not to thee: deliver him into my hand, and I will bring him to thee again.');
+INSERT INTO t1(docid,words) VALUES(1042038,'And he said, My son shall not go down with you; for his brother is dead, and he is left alone: if mischief befall him by the way in the which ye go, then shall ye bring down my gray hairs with sorrow to the grave.');
+INSERT INTO t1(docid,words) VALUES(1043001,'And the famine was sore in the land.');
+INSERT INTO t1(docid,words) VALUES(1043002,'And it came to pass, when they had eaten up the corn which they had brought out of Egypt, their father said unto them, Go again, buy us a little food.');
+INSERT INTO t1(docid,words) VALUES(1043003,'And Judah spake unto him, saying, The man did solemnly protest unto us, saying, Ye shall not see my face, except your brother be with you.');
+INSERT INTO t1(docid,words) VALUES(1043004,'If thou wilt send our brother with us, we will go down and buy thee food:');
+INSERT INTO t1(docid,words) VALUES(1043005,'But if thou wilt not send him, we will not go down: for the man said unto us, Ye shall not see my face, except your brother be with you.');
+INSERT INTO t1(docid,words) VALUES(1043006,'And Israel said, Wherefore dealt ye so ill with me, as to tell the man whether ye had yet a brother?');
+INSERT INTO t1(docid,words) VALUES(1043007,'And they said, The man asked us straitly of our state, and of our kindred, saying, Is your father yet alive? have ye another brother? and we told him according to the tenor of these words: could we certainly know that he would say, Bring your brother down?');
+INSERT INTO t1(docid,words) VALUES(1043008,'And Judah said unto Israel his father, Send the lad with me, and we will arise and go; that we may live, and not die, both we, and thou, and also our little ones.');
+INSERT INTO t1(docid,words) VALUES(1043009,'I will be surety for him; of my hand shalt thou require him: if I bring him not unto thee, and set him before thee, then let me bear the blame for ever:');
+INSERT INTO t1(docid,words) VALUES(1043010,'For except we had lingered, surely now we had returned this second time.');
+INSERT INTO t1(docid,words) VALUES(1043011,'And their father Israel said unto them, If it must be so now, do this; take of the best fruits in the land in your vessels, and carry down the man a present, a little balm, and a little honey, spices, and myrrh, nuts, and almonds:');
+INSERT INTO t1(docid,words) VALUES(1043012,'And take double money in your hand; and the money that was brought again in the mouth of your sacks, carry it again in your hand; peradventure it was an oversight:');
+INSERT INTO t1(docid,words) VALUES(1043013,'Take also your brother, and arise, go again unto the man:');
+INSERT INTO t1(docid,words) VALUES(1043014,'And God Almighty give you mercy before the man, that he may send away your other brother, and Benjamin. If I be bereaved of my children, I am bereaved.');
+INSERT INTO t1(docid,words) VALUES(1043015,'And the men took that present, and they took double money in their hand and Benjamin; and rose up, and went down to Egypt, and stood before Joseph.');
+INSERT INTO t1(docid,words) VALUES(1043016,'And when Joseph saw Benjamin with them, he said to the ruler of his house, Bring these men home, and slay, and make ready; for these men shall dine with me at noon.');
+INSERT INTO t1(docid,words) VALUES(1043017,'And the man did as Joseph bade; and the man brought the men into Joseph''s house.');
+INSERT INTO t1(docid,words) VALUES(1043018,'And the men were afraid, because they were brought into Joseph''s house; and they said, Because of the money that was returned in our sacks at the first time are we brought in; that he may seek occasion against us, and fall upon us, and take us for bondmen, and our asses.');
+INSERT INTO t1(docid,words) VALUES(1043019,'And they came near to the steward of Joseph''s house, and they communed with him at the door of the house,');
+INSERT INTO t1(docid,words) VALUES(1043020,'And said, O sir, we came indeed down at the first time to buy food:');
+INSERT INTO t1(docid,words) VALUES(1043021,'And it came to pass, when we came to the inn, that we opened our sacks, and, behold, every man''s money was in the mouth of his sack, our money in full weight: and we have brought it again in our hand.');
+INSERT INTO t1(docid,words) VALUES(1043022,'And other money have we brought down in our hands to buy food: we cannot tell who put our money in our sacks.');
+INSERT INTO t1(docid,words) VALUES(1043023,'And he said, Peace be to you, fear not: your God, and the God of your father, hath given you treasure in your sacks: I had your money. And he brought Simeon out unto them.');
+INSERT INTO t1(docid,words) VALUES(1043024,'And the man brought the men into Joseph''s house, and gave them water, and they washed their feet; and he gave their asses provender.');
+INSERT INTO t1(docid,words) VALUES(1043025,'And they made ready the present against Joseph came at noon: for they heard that they should eat bread there.');
+INSERT INTO t1(docid,words) VALUES(1043026,'And when Joseph came home, they brought him the present which was in their hand into the house, and bowed themselves to him to the earth.');
+INSERT INTO t1(docid,words) VALUES(1043027,'And he asked them of their welfare, and said, Is your father well, the old man of whom ye spake? Is he yet alive?');
+INSERT INTO t1(docid,words) VALUES(1043028,'And they answered, Thy servant our father is in good health, he is yet alive. And they bowed down their heads, and made obeisance.');
+INSERT INTO t1(docid,words) VALUES(1043029,'And he lifted up his eyes, and saw his brother Benjamin, his mother''s son, and said, Is this your younger brother, of whom ye spake unto me? And he said, God be gracious unto thee, my son.');
+INSERT INTO t1(docid,words) VALUES(1043030,'And Joseph made haste; for his bowels did yearn upon his brother: and he sought where to weep; and he entered into his chamber, and wept there.');
+INSERT INTO t1(docid,words) VALUES(1043031,'And he washed his face, and went out, and refrained himself, and said, Set on bread.');
+INSERT INTO t1(docid,words) VALUES(1043032,'And they set on for him by himself, and for them by themselves, and for the Egyptians, which did eat with him, by themselves: because the Egyptians might not eat bread with the Hebrews; for that is an abomination unto the Egyptians.');
+INSERT INTO t1(docid,words) VALUES(1043033,'And they sat before him, the firstborn according to his birthright, and the youngest according to his youth: and the men marvelled one at another.');
+INSERT INTO t1(docid,words) VALUES(1043034,'And he took and sent messes unto them from before him: but Benjamin''s mess was five times so much as any of their''s. And they drank, and were merry with him.');
+INSERT INTO t1(docid,words) VALUES(1044001,'And he commanded the steward of his house, saying, Fill the men''s sacks with food, as much as they can carry, and put every man''s money in his sack''s mouth.');
+INSERT INTO t1(docid,words) VALUES(1044002,'And put my cup, the silver cup, in the sack''s mouth of the youngest, and his corn money. And he did according to the word that Joseph had spoken.');
+INSERT INTO t1(docid,words) VALUES(1044003,'As soon as the morning was light, the men were sent away, they and their asses.');
+INSERT INTO t1(docid,words) VALUES(1044004,'And when they were gone out of the city, and not yet far off, Joseph said unto his steward, Up, follow after the men; and when thou dost overtake them, say unto them, Wherefore have ye rewarded evil for good?');
+INSERT INTO t1(docid,words) VALUES(1044005,'Is not this it in which my lord drinketh, and whereby indeed he divineth? ye have done evil in so doing.');
+INSERT INTO t1(docid,words) VALUES(1044006,'And he overtook them, and he spake unto them these same words.');
+INSERT INTO t1(docid,words) VALUES(1044007,'And they said unto him, Wherefore saith my lord these words? God forbid that thy servants should do according to this thing:');
+INSERT INTO t1(docid,words) VALUES(1044008,'Behold, the money, which we found in our sacks'' mouths, we brought again unto thee out of the land of Canaan: how then should we steal out of thy lord''s house silver or gold?');
+INSERT INTO t1(docid,words) VALUES(1044009,'With whomsoever of thy servants it be found, both let him die, and we also will be my lord''s bondmen.');
+INSERT INTO t1(docid,words) VALUES(1044010,'And he said, Now also let it be according unto your words: he with whom it is found shall be my servant; and ye shall be blameless.');
+INSERT INTO t1(docid,words) VALUES(1044011,'Then they speedily took down every man his sack to the ground, and opened every man his sack.');
+INSERT INTO t1(docid,words) VALUES(1044012,'And he searched, and began at the eldest, and left at the youngest: and the cup was found in Benjamin''s sack.');
+INSERT INTO t1(docid,words) VALUES(1044013,'Then they rent their clothes, and laded every man his ass, and returned to the city.');
+INSERT INTO t1(docid,words) VALUES(1044014,'And Judah and his brethren came to Joseph''s house; for he was yet there: and they fell before him on the ground.');
+INSERT INTO t1(docid,words) VALUES(1044015,'And Joseph said unto them, What deed is this that ye have done? wot ye not that such a man as I can certainly divine?');
+INSERT INTO t1(docid,words) VALUES(1044016,'And Judah said, What shall we say unto my lord? what shall we speak? or how shall we clear ourselves? God hath found out the iniquity of thy servants: behold, we are my lord''s servants, both we, and he also with whom the cup is found.');
+INSERT INTO t1(docid,words) VALUES(1044017,'And he said, God forbid that I should do so: but the man in whose hand the cup is found, he shall be my servant; and as for you, get you up in peace unto your father.');
+INSERT INTO t1(docid,words) VALUES(1044018,'Then Judah came near unto him, and said, Oh my lord, let thy servant, I pray thee, speak a word in my lord''s ears, and let not thine anger burn against thy servant: for thou art even as Pharaoh.');
+INSERT INTO t1(docid,words) VALUES(1044019,'My lord asked his servants, saying, Have ye a father, or a brother?');
+INSERT INTO t1(docid,words) VALUES(1044020,'And we said unto my lord, We have a father, an old man, and a child of his old age, a little one; and his brother is dead, and he alone is left of his mother, and his father loveth him.');
+INSERT INTO t1(docid,words) VALUES(1044021,'And thou saidst unto thy servants, Bring him down unto me, that I may set mine eyes upon him.');
+INSERT INTO t1(docid,words) VALUES(1044022,'And we said unto my lord, The lad cannot leave his father: for if he should leave his father, his father would die.');
+INSERT INTO t1(docid,words) VALUES(1044023,'And thou saidst unto thy servants, Except your youngest brother come down with you, ye shall see my face no more.');
+INSERT INTO t1(docid,words) VALUES(1044024,'And it came to pass when we came up unto thy servant my father, we told him the words of my lord.');
+INSERT INTO t1(docid,words) VALUES(1044025,'And our father said, Go again, and buy us a little food.');
+INSERT INTO t1(docid,words) VALUES(1044026,'And we said, We cannot go down: if our youngest brother be with us, then will we go down: for we may not see the man''s face, except our youngest brother be with us.');
+INSERT INTO t1(docid,words) VALUES(1044027,'And thy servant my father said unto us, Ye know that my wife bare me two sons:');
+INSERT INTO t1(docid,words) VALUES(1044028,'And the one went out from me, and I said, Surely he is torn in pieces; and I saw him not since:');
+INSERT INTO t1(docid,words) VALUES(1044029,'And if ye take this also from me, and mischief befall him, ye shall bring down my gray hairs with sorrow to the grave.');
+INSERT INTO t1(docid,words) VALUES(1044030,'Now therefore when I come to thy servant my father, and the lad be not with us; seeing that his life is bound up in the lad''s life;');
+INSERT INTO t1(docid,words) VALUES(1044031,'It shall come to pass, when he seeth that the lad is not with us, that he will die: and thy servants shall bring down the gray hairs of thy servant our father with sorrow to the grave.');
+INSERT INTO t1(docid,words) VALUES(1044032,'For thy servant became surety for the lad unto my father, saying, If I bring him not unto thee, then I shall bear the blame to my father for ever.');
+INSERT INTO t1(docid,words) VALUES(1044033,'Now therefore, I pray thee, let thy servant abide instead of the lad a bondman to my lord; and let the lad go up with his brethren.');
+INSERT INTO t1(docid,words) VALUES(1044034,'For how shall I go up to my father, and the lad be not with me? lest peradventure I see the evil that shall come on my father.');
+INSERT INTO t1(docid,words) VALUES(1045001,'Then Joseph could not refrain himself before all them that stood by him; and he cried, Cause every man to go out from me. And there stood no man with him, while Joseph made himself known unto his brethren.');
+INSERT INTO t1(docid,words) VALUES(1045002,'And he wept aloud: and the Egyptians and the house of Pharaoh heard.');
+INSERT INTO t1(docid,words) VALUES(1045003,'And Joseph said unto his brethren, I am Joseph; doth my father yet live? And his brethren could not answer him; for they were troubled at his presence.');
+INSERT INTO t1(docid,words) VALUES(1045004,'And Joseph said unto his brethren, Come near to me, I pray you. And they came near. And he said, I am Joseph your brother, whom ye sold into Egypt.');
+INSERT INTO t1(docid,words) VALUES(1045005,'Now therefore be not grieved, nor angry with yourselves, that ye sold me hither: for God did send me before you to preserve life.');
+INSERT INTO t1(docid,words) VALUES(1045006,'For these two years hath the famine been in the land: and yet there are five years, in the which there shall neither be earing nor harvest.');
+INSERT INTO t1(docid,words) VALUES(1045007,'And God sent me before you to preserve you a posterity in the earth, and to save your lives by a great deliverance.');
+INSERT INTO t1(docid,words) VALUES(1045008,'So now it was not you that sent me hither, but God: and he hath made me a father to Pharaoh, and lord of all his house, and a ruler throughout all the land of Egypt.');
+INSERT INTO t1(docid,words) VALUES(1045009,'Haste ye, and go up to my father, and say unto him, Thus saith thy son Joseph, God hath made me lord of all Egypt: come down unto me, tarry not:');
+INSERT INTO t1(docid,words) VALUES(1045010,'And thou shalt dwell in the land of Goshen, and thou shalt be near unto me, thou, and thy children, and thy children''s children, and thy flocks, and thy herds, and all that thou hast:');
+INSERT INTO t1(docid,words) VALUES(1045011,'And there will I nourish thee; for yet there are five years of famine; lest thou, and thy household, and all that thou hast, come to poverty.');
+INSERT INTO t1(docid,words) VALUES(1045012,'And, behold, your eyes see, and the eyes of my brother Benjamin, that it is my mouth that speaketh unto you.');
+INSERT INTO t1(docid,words) VALUES(1045013,'And ye shall tell my father of all my glory in Egypt, and of all that ye have seen; and ye shall haste and bring down my father hither.');
+INSERT INTO t1(docid,words) VALUES(1045014,'And he fell upon his brother Benjamin''s neck, and wept; and Benjamin wept upon his neck.');
+INSERT INTO t1(docid,words) VALUES(1045015,'Moreover he kissed all his brethren, and wept upon them: and after that his brethren talked with him.');
+INSERT INTO t1(docid,words) VALUES(1045016,'And the fame thereof was heard in Pharaoh''s house, saying, Joseph''s brethren are come: and it pleased Pharaoh well, and his servants.');
+INSERT INTO t1(docid,words) VALUES(1045017,'And Pharaoh said unto Joseph, Say unto thy brethren, This do ye; lade your beasts, and go, get you unto the land of Canaan;');
+INSERT INTO t1(docid,words) VALUES(1045018,'And take your father and your households, and come unto me: and I will give you the good of the land of Egypt, and ye shall eat the fat of the land.');
+INSERT INTO t1(docid,words) VALUES(1045019,'Now thou art commanded, this do ye; take you wagons out of the land of Egypt for your little ones, and for your wives, and bring your father, and come.');
+INSERT INTO t1(docid,words) VALUES(1045020,'Also regard not your stuff; for the good of all the land of Egypt is your''s.');
+INSERT INTO t1(docid,words) VALUES(1045021,'And the children of Israel did so: and Joseph gave them wagons, according to the commandment of Pharaoh, and gave them provision for the way.');
+INSERT INTO t1(docid,words) VALUES(1045022,'To all of them he gave each man changes of raiment; but to Benjamin he gave three hundred pieces of silver, and five changes of raiment.');
+INSERT INTO t1(docid,words) VALUES(1045023,'And to his father he sent after this manner; ten asses laden with the good things of Egypt, and ten she asses laden with corn and bread and meat for his father by the way.');
+INSERT INTO t1(docid,words) VALUES(1045024,'So he sent his brethren away, and they departed: and he said unto them, See that ye fall not out by the way.');
+INSERT INTO t1(docid,words) VALUES(1045025,'And they went up out of Egypt, and came into the land of Canaan unto Jacob their father,');
+INSERT INTO t1(docid,words) VALUES(1045026,'And told him, saying, Joseph is yet alive, and he is governor over all the land of Egypt. And Jacob''s heart fainted, for he believed them not.');
+INSERT INTO t1(docid,words) VALUES(1045027,'And they told him all the words of Joseph, which he had said unto them: and when he saw the wagons which Joseph had sent to carry him, the spirit of Jacob their father revived:');
+INSERT INTO t1(docid,words) VALUES(1045028,'And Israel said, It is enough; Joseph my son is yet alive: I will go and see him before I die.');
+INSERT INTO t1(docid,words) VALUES(1046001,'And Israel took his journey with all that he had, and came to Beersheba, and offered sacrifices unto the God of his father Isaac.');
+INSERT INTO t1(docid,words) VALUES(1046002,'And God spake unto Israel in the visions of the night, and said, Jacob, Jacob. And he said, Here am I.');
+INSERT INTO t1(docid,words) VALUES(1046003,'And he said, I am God, the God of thy father: fear not to go down into Egypt; for I will there make of thee a great nation:');
+INSERT INTO t1(docid,words) VALUES(1046004,'I will go down with thee into Egypt; and I will also surely bring thee up again: and Joseph shall put his hand upon thine eyes.');
+INSERT INTO t1(docid,words) VALUES(1046005,'And Jacob rose up from Beersheba: and the sons of Israel carried Jacob their father, and their little ones, and their wives, in the wagons which Pharaoh had sent to carry him.');
+INSERT INTO t1(docid,words) VALUES(1046006,'And they took their cattle, and their goods, which they had gotten in the land of Canaan, and came into Egypt, Jacob, and all his seed with him:');
+INSERT INTO t1(docid,words) VALUES(1046007,'His sons, and his sons'' sons with him, his daughters, and his sons'' daughters, and all his seed brought he with him into Egypt.');
+INSERT INTO t1(docid,words) VALUES(1046008,'And these are the names of the children of Israel, which came into Egypt, Jacob and his sons: Reuben, Jacob''s firstborn.');
+INSERT INTO t1(docid,words) VALUES(1046009,'And the sons of Reuben; Hanoch, and Phallu, and Hezron, and Carmi.');
+INSERT INTO t1(docid,words) VALUES(1046010,'And the sons of Simeon; Jemuel, and Jamin, and Ohad, and Jachin, and Zohar, and Shaul the son of a Canaanitish woman.');
+INSERT INTO t1(docid,words) VALUES(1046011,'And the sons of Levi; Gershon, Kohath, and Merari.');
+INSERT INTO t1(docid,words) VALUES(1046012,'And the sons of Judah; Er, and Onan, and Shelah, and Pharez, and Zarah: but Er and Onan died in the land of Canaan. And the sons of Pharez were Hezron and Hamul.');
+INSERT INTO t1(docid,words) VALUES(1046013,'And the sons of Issachar; Tola, and Phuvah, and Job, and Shimron.');
+INSERT INTO t1(docid,words) VALUES(1046014,'And the sons of Zebulun; Sered, and Elon, and Jahleel.');
+INSERT INTO t1(docid,words) VALUES(1046015,'These be the sons of Leah, which she bare unto Jacob in Padanaram, with his daughter Dinah: all the souls of his sons and his daughters were thirty and three.');
+INSERT INTO t1(docid,words) VALUES(1046016,'And the sons of Gad; Ziphion, and Haggi, Shuni, and Ezbon, Eri, and Arodi, and Areli.');
+INSERT INTO t1(docid,words) VALUES(1046017,'And the sons of Asher; Jimnah, and Ishuah, and Isui, and Beriah, and Serah their sister: and the sons of Beriah; Heber, and Malchiel.');
+INSERT INTO t1(docid,words) VALUES(1046018,'These are the sons of Zilpah, whom Laban gave to Leah his daughter, and these she bare unto Jacob, even sixteen souls.');
+INSERT INTO t1(docid,words) VALUES(1046019,'The sons of Rachel Jacob''s wife; Joseph, and Benjamin.');
+INSERT INTO t1(docid,words) VALUES(1046020,'And unto Joseph in the land of Egypt were born Manasseh and Ephraim, which Asenath the daughter of Potipherah priest of On bare unto him.');
+INSERT INTO t1(docid,words) VALUES(1046021,'And the sons of Benjamin were Belah, and Becher, and Ashbel, Gera, and Naaman, Ehi, and Rosh, Muppim, and Huppim, and Ard.');
+INSERT INTO t1(docid,words) VALUES(1046022,'These are the sons of Rachel, which were born to Jacob: all the souls were fourteen.');
+INSERT INTO t1(docid,words) VALUES(1046023,'And the sons of Dan; Hushim.');
+INSERT INTO t1(docid,words) VALUES(1046024,'And the sons of Naphtali; Jahzeel, and Guni, and Jezer, and Shillem.');
+INSERT INTO t1(docid,words) VALUES(1046025,'These are the sons of Bilhah, which Laban gave unto Rachel his daughter, and she bare these unto Jacob: all the souls were seven.');
+INSERT INTO t1(docid,words) VALUES(1046026,'All the souls that came with Jacob into Egypt, which came out of his loins, besides Jacob''s sons'' wives, all the souls were threescore and six;');
+INSERT INTO t1(docid,words) VALUES(1046027,'And the sons of Joseph, which were born him in Egypt, were two souls: all the souls of the house of Jacob, which came into Egypt, were threescore and ten.');
+INSERT INTO t1(docid,words) VALUES(1046028,'And he sent Judah before him unto Joseph, to direct his face unto Goshen; and they came into the land of Goshen.');
+INSERT INTO t1(docid,words) VALUES(1046029,'And Joseph made ready his chariot, and went up to meet Israel his father, to Goshen, and presented himself unto him; and he fell on his neck, and wept on his neck a good while.');
+INSERT INTO t1(docid,words) VALUES(1046030,'And Israel said unto Joseph, Now let me die, since I have seen thy face, because thou art yet alive.');
+INSERT INTO t1(docid,words) VALUES(1046031,'And Joseph said unto his brethren, and unto his father''s house, I will go up, and shew Pharaoh, and say unto him, My brethren, and my father''s house, which were in the land of Canaan, are come unto me;');
+INSERT INTO t1(docid,words) VALUES(1046032,'And the men are shepherds, for their trade hath been to feed cattle; and they have brought their flocks, and their herds, and all that they have.');
+INSERT INTO t1(docid,words) VALUES(1046033,'And it shall come to pass, when Pharaoh shall call you, and shall say, What is your occupation?');
+INSERT INTO t1(docid,words) VALUES(1046034,'That ye shall say, Thy servants'' trade hath been about cattle from our youth even until now, both we, and also our fathers: that ye may dwell in the land of Goshen; for every shepherd is an abomination unto the Egyptians.');
+INSERT INTO t1(docid,words) VALUES(1047001,'Then Joseph came and told Pharaoh, and said, My father and my brethren, and their flocks, and their herds, and all that they have, are come out of the land of Canaan; and, behold, they are in the land of Goshen.');
+INSERT INTO t1(docid,words) VALUES(1047002,'And he took some of his brethren, even five men, and presented them unto Pharaoh.');
+INSERT INTO t1(docid,words) VALUES(1047003,'And Pharaoh said unto his brethren, What is your occupation? And they said unto Pharaoh, Thy servants are shepherds, both we, and also our fathers.');
+INSERT INTO t1(docid,words) VALUES(1047004,'They said morever unto Pharaoh, For to sojourn in the land are we come; for thy servants have no pasture for their flocks; for the famine is sore in the land of Canaan: now therefore, we pray thee, let thy servants dwell in the land of Goshen.');
+INSERT INTO t1(docid,words) VALUES(1047005,'And Pharaoh spake unto Joseph, saying, Thy father and thy brethren are come unto thee:');
+INSERT INTO t1(docid,words) VALUES(1047006,'The land of Egypt is before thee; in the best of the land make thy father and brethren to dwell; in the land of Goshen let them dwell: and if thou knowest any men of activity among them, then make them rulers over my cattle.');
+INSERT INTO t1(docid,words) VALUES(1047007,'And Joseph brought in Jacob his father, and set him before Pharaoh: and Jacob blessed Pharaoh.');
+INSERT INTO t1(docid,words) VALUES(1047008,'And Pharaoh said unto Jacob, How old art thou?');
+INSERT INTO t1(docid,words) VALUES(1047009,'And Jacob said unto Pharaoh, The days of the years of my pilgrimage are an hundred and thirty years: few and evil have the days of the years of my life been, and have not attained unto the days of the years of the life of my fathers in the days of their pilgrimage.');
+INSERT INTO t1(docid,words) VALUES(1047010,'And Jacob blessed Pharaoh, and went out from before Pharaoh.');
+INSERT INTO t1(docid,words) VALUES(1047011,'And Joseph placed his father and his brethren, and gave them a possession in the land of Egypt, in the best of the land, in the land of Rameses, as Pharaoh had commanded.');
+INSERT INTO t1(docid,words) VALUES(1047012,'And Joseph nourished his father, and his brethren, and all his father''s household, with bread, according to their families.');
+INSERT INTO t1(docid,words) VALUES(1047013,'And there was no bread in all the land; for the famine was very sore, so that the land of Egypt and all the land of Canaan fainted by reason of the famine.');
+INSERT INTO t1(docid,words) VALUES(1047014,'And Joseph gathered up all the money that was found in the land of Egypt, and in the land of Canaan, for the corn which they bought: and Joseph brought the money into Pharaoh''s house.');
+INSERT INTO t1(docid,words) VALUES(1047015,'And when money failed in the land of Egypt, and in the land of Canaan, all the Egyptians came unto Joseph, and said, Give us bread: for why should we die in thy presence? for the money faileth.');
+INSERT INTO t1(docid,words) VALUES(1047016,'And Joseph said, Give your cattle; and I will give you for your cattle, if money fail.');
+INSERT INTO t1(docid,words) VALUES(1047017,'And they brought their cattle unto Joseph: and Joseph gave them bread in exchange for horses, and for the flocks, and for the cattle of the herds, and for the asses: and he fed them with bread for all their cattle for that year.');
+INSERT INTO t1(docid,words) VALUES(1047018,'When that year was ended, they came unto him the second year, and said unto him, We will not hide it from my lord, how that our money is spent; my lord also hath our herds of cattle; there is not ought left in the sight of my lord, but our bodies, and our lands:');
+INSERT INTO t1(docid,words) VALUES(1047019,'Wherefore shall we die before thine eyes, both we and our land? buy us and our land for bread, and we and our land will be servants unto Pharaoh: and give us seed, that we may live, and not die, that the land be not desolate.');
+INSERT INTO t1(docid,words) VALUES(1047020,'And Joseph bought all the land of Egypt for Pharaoh; for the Egyptians sold every man his field, because the famine prevailed over them: so the land became Pharaoh''s.');
+INSERT INTO t1(docid,words) VALUES(1047021,'And as for the people, he removed them to cities from one end of the borders of Egypt even to the other end thereof.');
+INSERT INTO t1(docid,words) VALUES(1047022,'Only the land of the priests bought he not; for the priests had a portion assigned them of Pharaoh, and did eat their portion which Pharaoh gave them: wherefore they sold not their lands.');
+INSERT INTO t1(docid,words) VALUES(1047023,'Then Joseph said unto the people, Behold, I have bought you this day and your land for Pharaoh: lo, here is seed for you, and ye shall sow the land.');
+INSERT INTO t1(docid,words) VALUES(1047024,'And it shall come to pass in the increase, that ye shall give the fifth part unto Pharaoh, and four parts shall be your own, for seed of the field, and for your food, and for them of your households, and for food for your little ones.');
+INSERT INTO t1(docid,words) VALUES(1047025,'And they said, Thou hast saved our lives: let us find grace in the sight of my lord, and we will be Pharaoh''s servants.');
+INSERT INTO t1(docid,words) VALUES(1047026,'And Joseph made it a law over the land of Egypt unto this day, that Pharaoh should have the fifth part, except the land of the priests only, which became not Pharaoh''s.');
+INSERT INTO t1(docid,words) VALUES(1047027,'And Israel dwelt in the land of Egypt, in the country of Goshen; and they had possessions therein, and grew, and multiplied exceedingly.');
+INSERT INTO t1(docid,words) VALUES(1047028,'And Jacob lived in the land of Egypt seventeen years: so the whole age of Jacob was an hundred forty and seven years.');
+INSERT INTO t1(docid,words) VALUES(1047029,'And the time drew nigh that Israel must die: and he called his son Joseph, and said unto him, If now I have found grace in thy sight, put, I pray thee, thy hand under my thigh, and deal kindly and truly with me; bury me not, I pray thee, in Egypt:');
+INSERT INTO t1(docid,words) VALUES(1047030,'But I will lie with my fathers, and thou shalt carry me out of Egypt, and bury me in their buryingplace. And he said, I will do as thou hast said.');
+INSERT INTO t1(docid,words) VALUES(1047031,'And he said, Swear unto me. And he sware unto him. And Israel bowed himself upon the bed''s head.');
+INSERT INTO t1(docid,words) VALUES(1048001,'And it came to pass after these things, that one told Joseph, Behold, thy father is sick: and he took with him his two sons, Manasseh and Ephraim.');
+INSERT INTO t1(docid,words) VALUES(1048002,'And one told Jacob, and said, Behold, thy son Joseph cometh unto thee: and Israel strengthened himself, and sat upon the bed.');
+INSERT INTO t1(docid,words) VALUES(1048003,'And Jacob said unto Joseph, God Almighty appeared unto me at Luz in the land of Canaan, and blessed me,');
+INSERT INTO t1(docid,words) VALUES(1048004,'And said unto me, Behold, I will make thee fruitful, and multiply thee, and I will make of thee a multitude of people; and will give this land to thy seed after thee for an everlasting possession.');
+INSERT INTO t1(docid,words) VALUES(1048005,'And now thy two sons, Ephraim and Manasseh, which were born unto thee in the land of Egypt before I came unto thee into Egypt, are mine; as Reuben and Simeon, they shall be mine.');
+INSERT INTO t1(docid,words) VALUES(1048006,'And thy issue, which thou begettest after them, shall be thine, and shall be called after the name of their brethren in their inheritance.');
+INSERT INTO t1(docid,words) VALUES(1048007,'And as for me, when I came from Padan, Rachel died by me in the land of Canaan in the way, when yet there was but a little way to come unto Ephrath: and I buried her there in the way of Ephrath; the same is Bethlehem.');
+INSERT INTO t1(docid,words) VALUES(1048008,'And Israel beheld Joseph''s sons, and said, Who are these?');
+INSERT INTO t1(docid,words) VALUES(1048009,'And Joseph said unto his father, They are my sons, whom God hath given me in this place. And he said, Bring them, I pray thee, unto me, and I will bless them.');
+INSERT INTO t1(docid,words) VALUES(1048010,'Now the eyes of Israel were dim for age, so that he could not see. And he brought them near unto him; and he kissed them, and embraced them.');
+INSERT INTO t1(docid,words) VALUES(1048011,'And Israel said unto Joseph, I had not thought to see thy face: and, lo, God hath shewed me also thy seed.');
+INSERT INTO t1(docid,words) VALUES(1048012,'And Joseph brought them out from between his knees, and he bowed himself with his face to the earth.');
+INSERT INTO t1(docid,words) VALUES(1048013,'And Joseph took them both, Ephraim in his right hand toward Israel''s left hand, and Manasseh in his left hand toward Israel''s right hand, and brought them near unto him.');
+INSERT INTO t1(docid,words) VALUES(1048014,'And Israel stretched out his right hand, and laid it upon Ephraim''s head, who was the younger, and his left hand upon Manasseh''s head, guiding his hands wittingly; for Manasseh was the firstborn.');
+INSERT INTO t1(docid,words) VALUES(1048015,'And he blessed Joseph, and said, God, before whom my fathers Abraham and Isaac did walk, the God which fed me all my life long unto this day,');
+INSERT INTO t1(docid,words) VALUES(1048016,'The Angel which redeemed me from all evil, bless the lads; and let my name be named on them, and the name of my fathers Abraham and Isaac; and let them grow into a multitude in the midst of the earth.');
+INSERT INTO t1(docid,words) VALUES(1048017,'And when Joseph saw that his father laid his right hand upon the head of Ephraim, it displeased him: and he held up his father''s hand, to remove it from Ephraim''s head unto Manasseh''s head.');
+INSERT INTO t1(docid,words) VALUES(1048018,'And Joseph said unto his father, Not so, my father: for this is the firstborn; put thy right hand upon his head.');
+INSERT INTO t1(docid,words) VALUES(1048019,'And his father refused, and said, I know it, my son, I know it: he also shall become a people, and he also shall be great: but truly his younger brother shall be greater than he, and his seed shall become a multitude of nations.');
+INSERT INTO t1(docid,words) VALUES(1048020,'And he blessed them that day, saying, In thee shall Israel bless, saying, God make thee as Ephraim and as Manasseh: and he set Ephraim before Manasseh.');
+INSERT INTO t1(docid,words) VALUES(1048021,'And Israel said unto Joseph, Behold, I die: but God shall be with you, and bring you again unto the land of your fathers.');
+INSERT INTO t1(docid,words) VALUES(1048022,'Moreover I have given to thee one portion above thy brethren, which I took out of the hand of the Amorite with my sword and with my bow.');
+INSERT INTO t1(docid,words) VALUES(1049001,'And Jacob called unto his sons, and said, Gather yourselves together, that I may tell you that which shall befall you in the last days.');
+INSERT INTO t1(docid,words) VALUES(1049002,'Gather yourselves together, and hear, ye sons of Jacob; and hearken unto Israel your father.');
+INSERT INTO t1(docid,words) VALUES(1049003,'Reuben, thou art my firstborn, my might, and the beginning of my strength, the excellency of dignity, and the excellency of power:');
+INSERT INTO t1(docid,words) VALUES(1049004,'Unstable as water, thou shalt not excel; because thou wentest up to thy father''s bed; then defiledst thou it: he went up to my couch.');
+INSERT INTO t1(docid,words) VALUES(1049005,'Simeon and Levi are brethren; instruments of cruelty are in their habitations.');
+INSERT INTO t1(docid,words) VALUES(1049006,'O my soul, come not thou into their secret; unto their assembly, mine honour, be not thou united: for in their anger they slew a man, and in their selfwill they digged down a wall.');
+INSERT INTO t1(docid,words) VALUES(1049007,'Cursed be their anger, for it was fierce; and their wrath, for it was cruel: I will divide them in Jacob, and scatter them in Israel.');
+INSERT INTO t1(docid,words) VALUES(1049008,'Judah, thou art he whom thy brethren shall praise: thy hand shall be in the neck of thine enemies; thy father''s children shall bow down before thee.');
+INSERT INTO t1(docid,words) VALUES(1049009,'Judah is a lion''s whelp: from the prey, my son, thou art gone up: he stooped down, he couched as a lion, and as an old lion; who shall rouse him up?');
+INSERT INTO t1(docid,words) VALUES(1049010,'The sceptre shall not depart from Judah, nor a lawgiver from between his feet, until Shiloh come; and unto him shall the gathering of the people be.');
+INSERT INTO t1(docid,words) VALUES(1049011,'Binding his foal unto the vine, and his ass''s colt unto the choice vine; he washed his garments in wine, and his clothes in the blood of grapes:');
+INSERT INTO t1(docid,words) VALUES(1049012,'His eyes shall be red with wine, and his teeth white with milk.');
+INSERT INTO t1(docid,words) VALUES(1049013,'Zebulun shall dwell at the haven of the sea; and he shall be for an haven of ships; and his border shall be unto Zidon.');
+INSERT INTO t1(docid,words) VALUES(1049014,'Issachar is a strong ass couching down between two burdens:');
+INSERT INTO t1(docid,words) VALUES(1049015,'And he saw that rest was good, and the land that it was pleasant; and bowed his shoulder to bear, and became a servant unto tribute.');
+INSERT INTO t1(docid,words) VALUES(1049016,'Dan shall judge his people, as one of the tribes of Israel.');
+INSERT INTO t1(docid,words) VALUES(1049017,'Dan shall be a serpent by the way, an adder in the path, that biteth the horse heels, so that his rider shall fall backward.');
+INSERT INTO t1(docid,words) VALUES(1049018,'I have waited for thy salvation, O LORD.');
+INSERT INTO t1(docid,words) VALUES(1049019,'Gad, a troop shall overcome him: but he shall overcome at the last.');
+INSERT INTO t1(docid,words) VALUES(1049020,'Out of Asher his bread shall be fat, and he shall yield royal dainties.');
+INSERT INTO t1(docid,words) VALUES(1049021,'Naphtali is a hind let loose: he giveth goodly words.');
+INSERT INTO t1(docid,words) VALUES(1049022,'Joseph is a fruitful bough, even a fruitful bough by a well; whose branches run over the wall:');
+INSERT INTO t1(docid,words) VALUES(1049023,'The archers have sorely grieved him, and shot at him, and hated him:');
+INSERT INTO t1(docid,words) VALUES(1049024,'But his bow abode in strength, and the arms of his hands were made strong by the hands of the mighty God of Jacob; (from thence is the shepherd, the stone of Israel:)');
+INSERT INTO t1(docid,words) VALUES(1049025,'Even by the God of thy father, who shall help thee; and by the Almighty, who shall bless thee with blessings of heaven above, blessings of the deep that lieth under, blessings of the breasts, and of the womb:');
+INSERT INTO t1(docid,words) VALUES(1049026,'The blessings of thy father have prevailed above the blessings of my progenitors unto the utmost bound of the everlasting hills: they shall be on the head of Joseph, and on the crown of the head of him that was separate from his brethren.');
+INSERT INTO t1(docid,words) VALUES(1049027,'Benjamin shall ravin as a wolf: in the morning he shall devour the prey, and at night he shall divide the spoil.');
+INSERT INTO t1(docid,words) VALUES(1049028,'All these are the twelve tribes of Israel: and this is it that their father spake unto them, and blessed them; every one according to his blessing he blessed them.');
+INSERT INTO t1(docid,words) VALUES(1049029,'And he charged them, and said unto them, I am to be gathered unto my people: bury me with my fathers in the cave that is in the field of Ephron the Hittite,');
+INSERT INTO t1(docid,words) VALUES(1049030,'In the cave that is in the field of Machpelah, which is before Mamre, in the land of Canaan, which Abraham bought with the field of Ephron the Hittite for a possession of a buryingplace.');
+INSERT INTO t1(docid,words) VALUES(1049031,'There they buried Abraham and Sarah his wife; there they buried Isaac and Rebekah his wife; and there I buried Leah.');
+INSERT INTO t1(docid,words) VALUES(1049032,'The purchase of the field and of the cave that is therein was from the children of Heth.');
+INSERT INTO t1(docid,words) VALUES(1049033,'And when Jacob had made an end of commanding his sons, he gathered up his feet into the bed, and yielded up the ghost, and was gathered unto his people.');
+INSERT INTO t1(docid,words) VALUES(1050001,'And Joseph fell upon his father''s face, and wept upon him, and kissed him.');
+INSERT INTO t1(docid,words) VALUES(1050002,'And Joseph commanded his servants the physicians to embalm his father: and the physicians embalmed Israel.');
+INSERT INTO t1(docid,words) VALUES(1050003,'And forty days were fulfilled for him; for so are fulfilled the days of those which are embalmed: and the Egyptians mourned for him threescore and ten days.');
+INSERT INTO t1(docid,words) VALUES(1050004,'And when the days of his mourning were past, Joseph spake unto the house of Pharaoh, saying, If now I have found grace in your eyes, speak, I pray you, in the ears of Pharaoh, saying,');
+INSERT INTO t1(docid,words) VALUES(1050005,'My father made me swear, saying, Lo, I die: in my grave which I have digged for me in the land of Canaan, there shalt thou bury me. Now therefore let me go up, I pray thee, and bury my father, and I will come again.');
+INSERT INTO t1(docid,words) VALUES(1050006,'And Pharaoh said, Go up, and bury thy father, according as he made thee swear.');
+INSERT INTO t1(docid,words) VALUES(1050007,'And Joseph went up to bury his father: and with him went up all the servants of Pharaoh, the elders of his house, and all the elders of the land of Egypt,');
+INSERT INTO t1(docid,words) VALUES(1050008,'And all the house of Joseph, and his brethren, and his father''s house: only their little ones, and their flocks, and their herds, they left in the land of Goshen.');
+INSERT INTO t1(docid,words) VALUES(1050009,'And there went up with him both chariots and horsemen: and it was a very great company.');
+INSERT INTO t1(docid,words) VALUES(1050010,'And they came to the threshingfloor of Atad, which is beyond Jordan, and there they mourned with a great and very sore lamentation: and he made a mourning for his father seven days.');
+INSERT INTO t1(docid,words) VALUES(1050011,'And when the inhabitants of the land, the Canaanites, saw the mourning in the floor of Atad, they said, This is a grievous mourning to the Egyptians: wherefore the name of it was called Abelmizraim, which is beyond Jordan.');
+INSERT INTO t1(docid,words) VALUES(1050012,'And his sons did unto him according as he commanded them:');
+INSERT INTO t1(docid,words) VALUES(1050013,'For his sons carried him into the land of Canaan, and buried him in the cave of the field of Machpelah, which Abraham bought with the field for a possession of a buryingplace of Ephron the Hittite, before Mamre.');
+INSERT INTO t1(docid,words) VALUES(1050014,'And Joseph returned into Egypt, he, and his brethren, and all that went up with him to bury his father, after he had buried his father.');
+INSERT INTO t1(docid,words) VALUES(1050015,'And when Joseph''s brethren saw that their father was dead, they said, Joseph will peradventure hate us, and will certainly requite us all the evil which we did unto him.');
+INSERT INTO t1(docid,words) VALUES(1050016,'And they sent a messenger unto Joseph, saying, Thy father did command before he died, saying,');
+INSERT INTO t1(docid,words) VALUES(1050017,'So shall ye say unto Joseph, Forgive, I pray thee now, the trespass of thy brethren, and their sin; for they did unto thee evil: and now, we pray thee, forgive the trespass of the servants of the God of thy father. And Joseph wept when they spake unto him.');
+INSERT INTO t1(docid,words) VALUES(1050018,'And his brethren also went and fell down before his face; and they said, Behold, we be thy servants.');
+INSERT INTO t1(docid,words) VALUES(1050019,'And Joseph said unto them, Fear not: for am I in the place of God?');
+INSERT INTO t1(docid,words) VALUES(1050020,'But as for you, ye thought evil against me; but God meant it unto good, to bring to pass, as it is this day, to save much people alive.');
+INSERT INTO t1(docid,words) VALUES(1050021,'Now therefore fear ye not: I will nourish you, and your little ones. And he comforted them, and spake kindly unto them.');
+INSERT INTO t1(docid,words) VALUES(1050022,'And Joseph dwelt in Egypt, he, and his father''s house: and Joseph lived an hundred and ten years.');
+INSERT INTO t1(docid,words) VALUES(1050023,'And Joseph saw Ephraim''s children of the third generation: the children also of Machir the son of Manasseh were brought up upon Joseph''s knees.');
+INSERT INTO t1(docid,words) VALUES(1050024,'And Joseph said unto his brethren, I die: and God will surely visit you, and bring you out of this land unto the land which he sware to Abraham, to Isaac, and to Jacob.');
+INSERT INTO t1(docid,words) VALUES(1050025,'And Joseph took an oath of the children of Israel, saying, God will surely visit you, and ye shall carry up my bones from hence.');
+INSERT INTO t1(docid,words) VALUES(1050026,'So Joseph died, being an hundred and ten years old: and they embalmed him, and he was put in a coffin in Egypt.');
+COMMIT;
+}
+}
+
+# The following is a list of queries to perform against the above
+# FTS3/FTS4 database. We will be trying these queries in various
+# configurations to ensure that they always return the same answers.
+#
+set fts4aa_queries {
+ {abraham}
+ {the king}
+ {"the king"}
+ {abraham OR joseph}
+ {ab* OR jos*}
+ {lived t*}
+ {spake hebrew}
+ {melchizedek}
+ {t* melchizedek}
+ {melchizedek t*}
+}
+unset -nocomplain fts4aa_res
+
+# Set up the baseline results
+#
+do_test fts4aa-1.0 {
+ db eval {
+ CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
+ }
+ fts4aa_fill_table
+ foreach q $::fts4aa_queries {
+ set r [db eval {SELECT docid FROM t1 WHERE words MATCH $q ORDER BY docid}]
+ set ::fts4aa_res($q) $r
+ }
+} {}
+
+# Legacy test cases
+#
+do_test fts4aa-1.1 {
+ db eval {
+ SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
+ }
+} {}
+do_test fts4aa-1.2 {
+ db eval {
+ SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1
+ }
+} {}
+
+proc mit {blob} {
+ set scan(littleEndian) i*
+ set scan(bigEndian) I*
+ binary scan $blob $scan($::tcl_platform(byteOrder)) r
+ return $r
+}
+db func mit mit
+
+do_test fts4aa-1.3 {
+ db eval {
+ SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 WHERE t1 MATCH 'melchizedek';
+ }
+} {1014018 {1 1 1 1 1 1533 25 20}}
+do_test fts4aa-1.4 {
+ db eval {
+ SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
+ WHERE t1 MATCH 'spake hebrew'
+ ORDER BY docid;
+ }
+} {1039014 {2 1 1 40 40 1 6 6 1533 25 42} 1039017 {2 1 1 40 40 1 6 6 1533 25 26}}
+do_test fts4aa-1.5 {
+ db eval {
+ SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
+ WHERE t1 MATCH 'laban overtook jacob'
+ ORDER BY docid;
+ }
+} {1031025 {3 1 2 54 46 1 3 3 2 181 160 1533 25 24}}
+
+do_test fts4aa-1.6 {
+ db eval {
+ DELETE FROM t1 WHERE docid!=1050026;
+ SELECT hex(size) FROM t1_docsize;
+ SELECT hex(value) FROM t1_stat;
+ }
+} {17 01176F}
+
+do_test fts4aa-1.7 {
+ db eval {
+ SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
+ }
+} {}
+do_test fts4aa-1.8 {
+ db eval {
+ SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1
+ }
+} {}
+do_test fts4aa-1.9 {
+ # Note: Token 'in' is being deferred in the following query.
+ db eval {
+ SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
+ WHERE t1 MATCH 'joseph died in egypt'
+ ORDER BY docid;
+ }
+} {1050026 {4 1 1 1 1 1 1 1 2 1 1 1 1 1 1 23 23}}
+
+# Should get the same search results from FTS3
+#
+do_test fts4aa-2.0 {
+ db eval {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts3(words, tokenize porter);
+ }
+ fts4aa_fill_table
+} {}
+unset -nocomplain ii
+set ii 0
+foreach {q r} [array get fts4aa_res] {
+ incr ii
+ do_test fts4aa-2.$ii {
+ db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
+ } $r
+}
+
+# Should get the same search results when the page size is very large
+#
+do_test fts4aa-3.0 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA page_size=65536;
+ CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
+ }
+ fts4aa_fill_table
+} {}
+unset -nocomplain ii
+set ii 0
+foreach {q r} [array get fts4aa_res] {
+ incr ii
+ do_test fts4aa-3.$ii {
+ db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
+ } $r
+}
+
+# Should get the same search results when an authorizer prevents
+# all PRAGMA statements.
+#
+proc no_pragma_auth {code arg1 arg2 arg3 arg4} {
+ if {$code=="SQLITE_PRAGMA"} {return SQLITE_DENY}
+ return SQLITE_OK;
+}
+do_test fts4aa-4.0 {
+ db auth ::no_pragma_auth
+ db eval {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
+ }
+ fts4aa_fill_table
+} {}
+unset -nocomplain ii
+set ii 0
+foreach {q r} [array get fts4aa_res] {
+ incr ii
+ do_test fts4aa-4.$ii {
+ db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
+ } $r
+}
+
+finish_test
diff --git a/test/fts4content.test b/test/fts4content.test
new file mode 100644
index 0000000..025b600
--- /dev/null
+++ b/test/fts4content.test
@@ -0,0 +1,501 @@
+# 2011 October 03
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the content=xxx FTS4 option.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix fts4content
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Test organization:
+#
+# 1.* - Warm-body tests.
+#
+# 2.* - Querying a content=xxx FTS table.
+#
+# 3.* - Writing to a content=xxx FTS table.
+#
+# 4.* - The "INSERT INTO fts(fts) VALUES('rebuild')" command.
+#
+# 5.* - Check that CREATE TABLE, DROP TABLE and ALTER TABLE correctly
+# ignore any %_content table when used with the content=xxx option.
+#
+# 6.* - Test the effects of messing with the schema of table xxx after
+# creating a content=xxx FTS index.
+#
+# 7.* - Test that if content=xxx is specified and table xxx does not
+# exist, the FTS table can still be used for INSERT and some
+# SELECT statements.
+#
+
+do_execsql_test 1.1.1 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('w x', 'x y', 'y z');
+ CREATE VIRTUAL TABLE ft1 USING fts4(content=t1);
+}
+
+do_execsql_test 1.1.2 {
+ PRAGMA table_info(ft1);
+} {
+ 0 a {} 0 {} 0
+ 1 b {} 0 {} 0
+ 2 c {} 0 {} 0
+}
+
+do_execsql_test 1.1.3 { SELECT *, rowid FROM ft1 } {{w x} {x y} {y z} 1}
+do_execsql_test 1.1.4 { SELECT a, c FROM ft1 WHERE rowid=1 } {{w x} {y z}}
+
+do_execsql_test 1.1.5 { INSERT INTO ft1(ft1) VALUES('rebuild') } {}
+do_execsql_test 1.1.6 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'x' } {1}
+do_execsql_test 1.1.7 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'a' } {}
+
+do_execsql_test 1.2.1 {
+ DROP TABLE ft1;
+ CREATE VIRTUAL TABLE ft1 USING fts4(content=t1, b);
+ PRAGMA table_info(ft1);
+} {
+ 0 b {} 0 {} 0
+}
+do_execsql_test 1.2.2 {
+ SELECT *, rowid FROM ft1
+} {{x y} 1}
+
+#-------------------------------------------------------------------------
+# The following block of tests - 2.* - test that a content=xxx FTS table
+# can be queried. Also tested are cases where rows identified in the FTS
+# are missing from the content table, and cases where the index is
+# inconsistent with the content table.
+#
+do_execsql_test 2.0 {
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES('O S W W F U C R Q I C N P Z Y Y E Y Y E'); -- 1
+ INSERT INTO t2 VALUES('Y X U V L B E H Y J C Y A I A P V F V K'); -- 2
+ INSERT INTO t2 VALUES('P W I N J H I I N I F B K D U Q B Z S F'); -- 3
+ INSERT INTO t2 VALUES('N R O R H J R H G M D I U U B O M P A U'); -- 4
+ INSERT INTO t2 VALUES('Y O V O G T P N G T N F I V B U M J M G'); -- 5
+ INSERT INTO t2 VALUES('J O B N K N E C H Z R K J O U G M K L S'); -- 6
+ INSERT INTO t2 VALUES('S Z S R I Q U A P W R X H K C Z U L S P'); -- 7
+ INSERT INTO t2 VALUES('J C H N R C K R V N M O F Z M Z A I H W'); -- 8
+ INSERT INTO t2 VALUES('O Y G I S J U U W O D Z F J K N R P R L'); -- 9
+ INSERT INTO t2 VALUES('B G L K U R U P V X Z I H V R W C Q A S'); -- 10
+ INSERT INTO t2 VALUES('T F T J F F Y V F W N X K Q A Y L X W G'); -- 11
+ INSERT INTO t2 VALUES('C J U H B Q X L C M M Y E G V F W V Z C'); -- 12
+ INSERT INTO t2 VALUES('B W L T F S G X D P H N G M R I O A X I'); -- 13
+ INSERT INTO t2 VALUES('N G Y O K Q K Z N M H U J E D H U W R K'); -- 14
+ INSERT INTO t2 VALUES('U D T R U Y F J D S J X E H Q G V A S Z'); -- 15
+ INSERT INTO t2 VALUES('M I W P J S H R J D Q I C G P C T P H R'); -- 16
+ INSERT INTO t2 VALUES('J M N I S L X Q C A B F C B Y D H V R J'); -- 17
+ INSERT INTO t2 VALUES('F V Z W J Q L P X Y E W B U Q N H X K T'); -- 18
+ INSERT INTO t2 VALUES('R F S R Y O F Q E I E G H C B H R X Y N'); -- 19
+ INSERT INTO t2 VALUES('U Q Q Q T E P D M F X P J G H X C Q D L'); -- 20
+}
+
+do_execsql_test 2.1 {
+ CREATE VIRTUAL TABLE ft2 USING fts4(content=t2);
+ INSERT INTO ft2(ft2) VALUES('rebuild');
+
+ -- Modify the backing table a bit: Row 17 is missing and the contents
+ -- of row 20 do not match the FTS index contents.
+ DELETE FROM t2 WHERE rowid = 17;
+ UPDATE t2 SET x = 'a b c d e f g h i j' WHERE rowid = 20;
+}
+
+foreach {tn match rowidlist} {
+ 1 {S} {1 3 6 7 9 10 13 15 16 17 19}
+ 2 {"S R"} {7 19}
+ 3 {"N K N"} {6}
+ 4 {"Q Q"} {20}
+ 5 {"B Y D"} {17}
+} {
+ do_execsql_test 2.2.1.$tn {
+ SELECT rowid FROM ft2 WHERE ft2 MATCH $match
+ } $rowidlist
+
+ do_execsql_test 2.2.2.$tn {
+ SELECT docid FROM ft2 WHERE ft2 MATCH $match
+ } $rowidlist
+}
+
+foreach {tn match result} {
+ 1 {"N K N"} {{J O B N K N E C H Z R K J O U G M K L S}}
+ 2 {"Q Q"} {{a b c d e f g h i j}}
+ 3 {"B Y D"} {{}}
+} {
+ do_execsql_test 2.3.$tn {
+ SELECT * FROM ft2 WHERE ft2 MATCH $match
+ } $result
+}
+
+foreach {tn match result} {
+ 1 {"N K N"} {{..O B [N] [K] [N] E..}}
+ 2 {"B Y D"} {{}}
+ 3 {"Q Q"} {{a [b] [c] [d] e f..}}
+} {
+ do_execsql_test 2.4.$tn {
+ SELECT snippet(ft2, '[', ']', '..', -1, 6) FROM ft2 WHERE ft2 MATCH $match
+ } $result
+}
+
+foreach {tn match result} {
+ 1 {"N K N"} {{0 0 6 1 0 1 8 1 0 2 10 1}}
+ 2 {"B Y D"} {{}}
+ 3 {"Q Q"} {{0 0 2 1 0 0 4 1 0 1 4 1 0 1 6 1}}
+ 4 {"Q D L"} {{}}
+} {
+ do_execsql_test 2.5.$tn {
+ SELECT offsets(ft2) FROM ft2 WHERE ft2 MATCH $match
+ } $result
+}
+
+#-------------------------------------------------------------------------
+# The following block of tests - 3.* - test that the FTS index can be
+# modified by writing to the table. But that this has no effect on the
+# content table.
+#
+
+do_execsql_test 3.1 {
+ CREATE TABLE t3(x, y);
+ CREATE VIRTUAL TABLE ft3 USING fts4(content=t3);
+}
+
+do_catchsql_test 3.1.1 {
+ INSERT INTO ft3 VALUES('a b c', 'd e f');
+} {1 {constraint failed}}
+do_execsql_test 3.1.2 {
+ INSERT INTO ft3(docid, x, y) VALUES(21, 'a b c', 'd e f');
+ SELECT rowid FROM ft3 WHERE ft3 MATCH '"a b c"';
+} {21}
+do_execsql_test 3.1.3 { SELECT * FROM t3 } {}
+
+# This DELETE does not work, since there is no row in [t3] to base the
+# DELETE on. So the SELECT on [ft3] still returns rowid 21.
+do_execsql_test 3.1.4 {
+ DELETE FROM ft3;
+ SELECT rowid FROM ft3 WHERE ft3 MATCH '"a b c"';
+} {21}
+
+# If the row is added to [t3] before the DELETE on [ft3], it works.
+do_execsql_test 3.1.5 {
+ INSERT INTO t3(rowid, x, y) VALUES(21, 'a b c', 'd e f');
+ DELETE FROM ft3;
+ SELECT rowid FROM ft3 WHERE ft3 MATCH '"a b c"';
+} {}
+do_execsql_test 3.1.6 { SELECT rowid FROM t3 } {21}
+
+do_execsql_test 3.2.1 {
+ INSERT INTO ft3(rowid, x, y) VALUES(0, 'R T M S M', 'A F O K H');
+ INSERT INTO ft3(rowid, x, y) VALUES(1, 'C Z J O X', 'U S Q D K');
+ INSERT INTO ft3(rowid, x, y) VALUES(2, 'N G H P O', 'N O P O C');
+ INSERT INTO ft3(rowid, x, y) VALUES(3, 'V H S D R', 'K N G E C');
+ INSERT INTO ft3(rowid, x, y) VALUES(4, 'J T R V U', 'U X S L C');
+ INSERT INTO ft3(rowid, x, y) VALUES(5, 'N A Y N G', 'X D G P Y');
+ INSERT INTO ft3(rowid, x, y) VALUES(6, 'I Q I S P', 'D R O Q B');
+ INSERT INTO ft3(rowid, x, y) VALUES(7, 'T K T Z J', 'B W D G O');
+ INSERT INTO ft3(rowid, x, y) VALUES(8, 'Y K F X T', 'D F G V G');
+ INSERT INTO ft3(rowid, x, y) VALUES(9, 'E L E T L', 'P W N F Z');
+ INSERT INTO ft3(rowid, x, y) VALUES(10, 'O G J G X', 'G J F E P');
+ INSERT INTO ft3(rowid, x, y) VALUES(11, 'O L N N Z', 'K E Z F D');
+ INSERT INTO ft3(rowid, x, y) VALUES(12, 'R Z M R J', 'X G I M Z');
+ INSERT INTO ft3(rowid, x, y) VALUES(13, 'L X N N X', 'R R N S T');
+ INSERT INTO ft3(rowid, x, y) VALUES(14, 'F L B J H', 'K W F L C');
+ INSERT INTO ft3(rowid, x, y) VALUES(15, 'P E B M V', 'E A A B U');
+ INSERT INTO ft3(rowid, x, y) VALUES(16, 'V E C F P', 'L U T V K');
+ INSERT INTO ft3(rowid, x, y) VALUES(17, 'T N O Z N', 'T P Q X N');
+ INSERT INTO ft3(rowid, x, y) VALUES(18, 'V W U W R', 'H O A A V');
+ INSERT INTO ft3(rowid, x, y) VALUES(19, 'A H N L F', 'I G H B O');
+}
+
+foreach {tn match rowidlist} {
+ 1 "N A" {5 19}
+ 2 "x:O" {1 2 10 11 17}
+ 3 "y:O" {0 2 6 7 18 19}
+} {
+ set res [list]
+ foreach rowid $rowidlist { lappend res $rowid {} {} }
+
+ do_execsql_test 3.2.2.$tn {
+ SELECT rowid, * FROM ft3 WHERE ft3 MATCH $match
+ } $res
+ do_execsql_test 3.2.3.$tn {
+ SELECT docid, * FROM ft3 WHERE ft3 MATCH $match
+ } $res
+}
+
+do_execsql_test 3.3.1 {
+ INSERT INTO t3(rowid, x, y) VALUES(0, 'R T M S M', 'A F O K H');
+ INSERT INTO t3(rowid, x, y) VALUES(1, 'C Z J O X', 'U S Q D K');
+ INSERT INTO t3(rowid, x, y) VALUES(2, 'N G H P O', 'N O P O C');
+ INSERT INTO t3(rowid, x, y) VALUES(3, 'V H S D R', 'K N G E C');
+ INSERT INTO t3(rowid, x, y) VALUES(4, 'J T R V U', 'U X S L C');
+ INSERT INTO t3(rowid, x, y) VALUES(5, 'N A Y N G', 'X D G P Y');
+ UPDATE ft3 SET x = y, y = x;
+ DELETE FROM t3;
+}
+
+foreach {tn match rowidlist} {
+ 1 "N A" {5 19}
+ 2 "x:O" {0 2 10 11 17}
+ 3 "y:O" {1 2 6 7 18 19}
+} {
+ set res [list]
+ foreach rowid $rowidlist { lappend res $rowid {} {} }
+
+ do_execsql_test 3.3.2.$tn {
+ SELECT rowid, * FROM ft3 WHERE ft3 MATCH $match
+ } $res
+ do_execsql_test 3.3.3.$tn {
+ SELECT docid, * FROM ft3 WHERE ft3 MATCH $match
+ } $res
+}
+
+do_execsql_test 3.3.1 {
+ INSERT INTO t3(rowid, x, y) VALUES(15, 'P E B M V', 'E A A B U');
+ INSERT INTO t3(rowid, x, y) VALUES(16, 'V E C F P', 'L U T V K');
+ INSERT INTO t3(rowid, x, y) VALUES(17, 'T N O Z N', 'T P Q X N');
+ INSERT INTO t3(rowid, x, y) VALUES(18, 'V W U W R', 'H O A A V');
+ INSERT INTO t3(rowid, x, y) VALUES(19, 'A H N L F', 'I G H B O');
+ DELETE FROM ft3;
+}
+
+foreach {tn match rowidlist} {
+ 1 "N A" {5}
+ 2 "x:O" {0 2 10 11}
+ 3 "y:O" {1 2 6 7}
+} {
+ set res [list]
+ foreach rowid $rowidlist { lappend res $rowid {} {} }
+
+ do_execsql_test 3.3.2.$tn {
+ SELECT rowid, * FROM ft3 WHERE ft3 MATCH $match
+ } $res
+ do_execsql_test 3.3.3.$tn {
+ SELECT docid, * FROM ft3 WHERE ft3 MATCH $match
+ } $res
+}
+
+
+#-------------------------------------------------------------------------
+# Test cases 4.* test the 'rebuild' command. On content=xxx and regular
+# FTS tables.
+#
+do_execsql_test 4.0 {
+ CREATE TABLE t4(x);
+ CREATE VIRTUAL TABLE ft4 USING fts4(content=t4);
+ CREATE VIRTUAL TABLE ft4x USING fts4(x);
+}
+
+do_execsql_test 4.1.1 {
+ INSERT INTO ft4x(ft4x) VALUES('rebuild');
+ INSERT INTO ft4(ft4) VALUES('rebuild');
+} {}
+do_execsql_test 4.1.2 {
+ SELECT id, quote(value) FROM ft4_stat
+} {0 X'000000'}
+do_execsql_test 4.1.3 {
+ SELECT id, quote(value) FROM ft4x_stat
+} {0 X'000000'}
+
+do_execsql_test 4.2.1 {
+ INSERT INTO ft4x VALUES('M G M F T');
+ INSERT INTO ft4x VALUES('Z Q C A U');
+ INSERT INTO ft4x VALUES('N L L V');
+ INSERT INTO ft4x VALUES('T F D X D');
+ INSERT INTO ft4x VALUES('Z H I S D');
+
+ SELECT id, quote(value) FROM ft4x_stat
+} {0 X'05182B'}
+
+do_execsql_test 4.2.2 {
+ INSERT INTO ft4(rowid, x) SELECT rowid, * FROM ft4x;
+ SELECT id, quote(value) FROM ft4_stat
+} {0 X'05182B'}
+
+do_execsql_test 4.2.3 {
+ SELECT docid, quote(size) FROM ft4_docsize
+} {1 X'05' 2 X'05' 3 X'04' 4 X'05' 5 X'05'}
+
+do_execsql_test 4.2.4 {
+ INSERT INTO ft4x(ft4x) VALUES('rebuild');
+ SELECT id, quote(value) FROM ft4x_stat;
+ SELECT docid, quote(size) FROM ft4x_docsize
+} {0 X'05182B' 1 X'05' 2 X'05' 3 X'04' 4 X'05' 5 X'05'}
+
+do_execsql_test 4.2.5 {
+ INSERT INTO ft4(ft4) VALUES('rebuild');
+ SELECT id, quote(value) FROM ft4_stat;
+ SELECT docid, quote(size) FROM ft4_docsize
+} {0 X'000000'}
+
+do_execsql_test 4.2.6 {
+ INSERT INTO t4(rowid, x) SELECT rowid, x FROM ft4x;
+ INSERT INTO ft4(ft4) VALUES('rebuild');
+ SELECT id, quote(value) FROM ft4_stat;
+ SELECT docid, quote(size) FROM ft4_docsize
+} {0 X'05182B' 1 X'05' 2 X'05' 3 X'04' 4 X'05' 5 X'05'}
+
+
+#-------------------------------------------------------------------------
+# Test cases 5.* test that the following commands do not create/move or
+# delete a %_content table when used with a content=xxx FTS table.
+#
+do_execsql_test 5.1.1 {
+ CREATE TABLE t5(a, b, c, d);
+ CREATE VIRTUAL TABLE ft5 USING fts4(content=t5);
+ SELECT name FROM sqlite_master WHERE name LIKE '%t5%';
+} {
+ t5 ft5 ft5_segments ft5_segdir
+ sqlite_autoindex_ft5_segdir_1 ft5_docsize ft5_stat
+}
+do_execsql_test 5.1.2 {
+ ALTER TABLE ft5 RENAME TO ft6;
+ SELECT name FROM sqlite_master WHERE name LIKE '%t5%';
+} {
+ t5
+}
+do_execsql_test 5.1.3 {
+ SELECT name FROM sqlite_master WHERE name LIKE '%t6%';
+} {
+ ft6 ft6_segments ft6_segdir
+ sqlite_autoindex_ft6_segdir_1 ft6_docsize ft6_stat
+}
+do_execsql_test 5.1.4 {
+ INSERT INTO t5 VALUES('a', 'b', 'c', 'd');
+ INSERT INTO ft6(ft6) VALUES('rebuild');
+ SELECT rowid FROM ft6 WHERE ft6 MATCH 'b';
+} {1}
+do_execsql_test 5.1.5 {
+ DROP TABLE ft6;
+ SELECT * FROM t5;
+} {a b c d}
+do_execsql_test 5.1.6 {
+ SELECT name FROM sqlite_master WHERE name LIKE '%t6%';
+} {
+}
+do_execsql_test 5.1.7 {
+ CREATE VIRTUAL TABLE ft5 USING fts4(content=t5);
+ CREATE TABLE t5_content(a, b);
+ DROP TABLE ft5;
+ SELECT name FROM sqlite_master WHERE name LIKE '%t5%';
+} {
+ t5 t5_content
+}
+
+#-------------------------------------------------------------------------
+# Test cases 6.* test
+#
+do_catchsql_test 6.1.1 {
+ CREATE VIRTUAL TABLE ft7 USING fts4(content=t7);
+} {1 {vtable constructor failed: ft7}}
+
+do_execsql_test 6.2.1 {
+ CREATE TABLE t7(one, two);
+ CREATE VIRTUAL TABLE ft7 USING fts4(content=t7);
+ INSERT INTO t7 VALUES('A B', 'B A');
+ INSERT INTO t7 VALUES('C D', 'A A');
+ SELECT * FROM ft7;
+} {
+ {A B} {B A} {C D} {A A}
+}
+
+do_catchsql_test 6.2.2 {
+ DROP TABLE t7;
+ SELECT * FROM ft7;
+} {1 {SQL logic error or missing database}}
+
+db close
+sqlite3 db test.db
+do_execsql_test 6.2.3 {
+ SELECT name FROM sqlite_master WHERE name LIKE '%t7%'
+} {
+ ft7 ft7_segments ft7_segdir sqlite_autoindex_ft7_segdir_1
+ ft7_docsize ft7_stat
+}
+do_catchsql_test 6.2.4 {
+ SELECT * FROM ft7;
+} {1 {vtable constructor failed: ft7}}
+do_execsql_test 6.2.5 {
+ CREATE TABLE t7(x, y);
+ INSERT INTO t7 VALUES('A B', 'B A');
+ INSERT INTO t7 VALUES('C D', 'A A');
+ SELECT * FROM ft7;
+} {
+ {A B} {B A} {C D} {A A}
+}
+
+do_execsql_test 6.2.6 {
+ INSERT INTO ft7(ft7) VALUES('rebuild');
+ SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"';
+} {2}
+
+do_execsql_test 6.2.7 {
+ DROP TABLE t7;
+ CREATE TABLE t7(x);
+}
+do_catchsql_test 6.2.8 {
+ SELECT * FROM ft7 WHERE ft7 MATCH '"A A"';
+} {1 {SQL logic error or missing database}}
+do_catchsql_test 6.2.9 {
+ SELECT * FROM ft7 WHERE ft7 MATCH '"A A"';
+} {1 {SQL logic error or missing database}}
+
+db close
+sqlite3 db test.db
+do_catchsql_test 6.2.10 {
+ SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"';
+} {0 2}
+do_catchsql_test 6.2.11 {
+ SELECT rowid, * FROM ft7 WHERE ft7 MATCH '"A A"';
+} {0 {2 {}}}
+
+#-------------------------------------------------------------------------
+# Test cases 7.*
+#
+do_execsql_test 7.1.1 {
+ CREATE VIRTUAL TABLE ft8 USING fts4(content=nosuchtable, x);
+ INSERT INTO ft8(docid, x) VALUES(13, 'U O N X G');
+ INSERT INTO ft8(docid, x) VALUES(14, 'C J J U B');
+ INSERT INTO ft8(docid, x) VALUES(15, 'N J Y G X');
+ INSERT INTO ft8(docid, x) VALUES(16, 'R Y D O R');
+ INSERT INTO ft8(docid, x) VALUES(17, 'I Y T Q O');
+}
+
+do_execsql_test 7.1.2 {
+ SELECT docid FROM ft8 WHERE ft8 MATCH 'N';
+} {13 15}
+
+do_execsql_test 7.2.1 {
+ CREATE VIRTUAL TABLE ft9 USING fts4(content=, x);
+ INSERT INTO ft9(docid, x) VALUES(13, 'U O N X G');
+ INSERT INTO ft9(docid, x) VALUES(14, 'C J J U B');
+ INSERT INTO ft9(docid, x) VALUES(15, 'N J Y G X');
+ INSERT INTO ft9(docid, x) VALUES(16, 'R Y D O R');
+ INSERT INTO ft9(docid, x) VALUES(17, 'I Y T Q O');
+}
+do_execsql_test 7.2.2 {
+ SELECT docid FROM ft9 WHERE ft9 MATCH 'N';
+} {13 15}
+do_execsql_test 7.2.3 {
+ SELECT name FROM sqlite_master WHERE name LIKE 'ft9_%';
+} {ft9_segments ft9_segdir ft9_docsize ft9_stat}
+
+do_catchsql_test 7.2.4 {
+ SELECT * FROM ft9 WHERE ft9 MATCH 'N';
+} {1 {SQL logic error or missing database}}
+
+finish_test
diff --git a/test/func.test b/test/func.test
new file mode 100644
index 0000000..eef0543
--- /dev/null
+++ b/test/func.test
@@ -0,0 +1,1250 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing built-in functions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table to work with.
+#
+do_test func-0.0 {
+ execsql {CREATE TABLE tbl1(t1 text)}
+ foreach word {this program is free software} {
+ execsql "INSERT INTO tbl1 VALUES('$word')"
+ }
+ execsql {SELECT t1 FROM tbl1 ORDER BY t1}
+} {free is program software this}
+do_test func-0.1 {
+ execsql {
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(NULL);
+ INSERT INTO t2 VALUES(345);
+ INSERT INTO t2 VALUES(NULL);
+ INSERT INTO t2 VALUES(67890);
+ SELECT * FROM t2;
+ }
+} {1 {} 345 {} 67890}
+
+# Check out the length() function
+#
+do_test func-1.0 {
+ execsql {SELECT length(t1) FROM tbl1 ORDER BY t1}
+} {4 2 7 8 4}
+do_test func-1.1 {
+ set r [catch {execsql {SELECT length(*) FROM tbl1 ORDER BY t1}} msg]
+ lappend r $msg
+} {1 {wrong number of arguments to function length()}}
+do_test func-1.2 {
+ set r [catch {execsql {SELECT length(t1,5) FROM tbl1 ORDER BY t1}} msg]
+ lappend r $msg
+} {1 {wrong number of arguments to function length()}}
+do_test func-1.3 {
+ execsql {SELECT length(t1), count(*) FROM tbl1 GROUP BY length(t1)
+ ORDER BY length(t1)}
+} {2 1 4 2 7 1 8 1}
+do_test func-1.4 {
+ execsql {SELECT coalesce(length(a),-1) FROM t2}
+} {1 -1 3 -1 5}
+
+# Check out the substr() function
+#
+do_test func-2.0 {
+ execsql {SELECT substr(t1,1,2) FROM tbl1 ORDER BY t1}
+} {fr is pr so th}
+do_test func-2.1 {
+ execsql {SELECT substr(t1,2,1) FROM tbl1 ORDER BY t1}
+} {r s r o h}
+do_test func-2.2 {
+ execsql {SELECT substr(t1,3,3) FROM tbl1 ORDER BY t1}
+} {ee {} ogr ftw is}
+do_test func-2.3 {
+ execsql {SELECT substr(t1,-1,1) FROM tbl1 ORDER BY t1}
+} {e s m e s}
+do_test func-2.4 {
+ execsql {SELECT substr(t1,-1,2) FROM tbl1 ORDER BY t1}
+} {e s m e s}
+do_test func-2.5 {
+ execsql {SELECT substr(t1,-2,1) FROM tbl1 ORDER BY t1}
+} {e i a r i}
+do_test func-2.6 {
+ execsql {SELECT substr(t1,-2,2) FROM tbl1 ORDER BY t1}
+} {ee is am re is}
+do_test func-2.7 {
+ execsql {SELECT substr(t1,-4,2) FROM tbl1 ORDER BY t1}
+} {fr {} gr wa th}
+do_test func-2.8 {
+ execsql {SELECT t1 FROM tbl1 ORDER BY substr(t1,2,20)}
+} {this software free program is}
+do_test func-2.9 {
+ execsql {SELECT substr(a,1,1) FROM t2}
+} {1 {} 3 {} 6}
+do_test func-2.10 {
+ execsql {SELECT substr(a,2,2) FROM t2}
+} {{} {} 45 {} 78}
+
+# Only do the following tests if TCL has UTF-8 capabilities
+#
+if {"\u1234"!="u1234"} {
+
+# Put some UTF-8 characters in the database
+#
+do_test func-3.0 {
+ execsql {DELETE FROM tbl1}
+ foreach word "contains UTF-8 characters hi\u1234ho" {
+ execsql "INSERT INTO tbl1 VALUES('$word')"
+ }
+ execsql {SELECT t1 FROM tbl1 ORDER BY t1}
+} "UTF-8 characters contains hi\u1234ho"
+do_test func-3.1 {
+ execsql {SELECT length(t1) FROM tbl1 ORDER BY t1}
+} {5 10 8 5}
+do_test func-3.2 {
+ execsql {SELECT substr(t1,1,2) FROM tbl1 ORDER BY t1}
+} {UT ch co hi}
+do_test func-3.3 {
+ execsql {SELECT substr(t1,1,3) FROM tbl1 ORDER BY t1}
+} "UTF cha con hi\u1234"
+do_test func-3.4 {
+ execsql {SELECT substr(t1,2,2) FROM tbl1 ORDER BY t1}
+} "TF ha on i\u1234"
+do_test func-3.5 {
+ execsql {SELECT substr(t1,2,3) FROM tbl1 ORDER BY t1}
+} "TF- har ont i\u1234h"
+do_test func-3.6 {
+ execsql {SELECT substr(t1,3,2) FROM tbl1 ORDER BY t1}
+} "F- ar nt \u1234h"
+do_test func-3.7 {
+ execsql {SELECT substr(t1,4,2) FROM tbl1 ORDER BY t1}
+} "-8 ra ta ho"
+do_test func-3.8 {
+ execsql {SELECT substr(t1,-1,1) FROM tbl1 ORDER BY t1}
+} "8 s s o"
+do_test func-3.9 {
+ execsql {SELECT substr(t1,-3,2) FROM tbl1 ORDER BY t1}
+} "F- er in \u1234h"
+do_test func-3.10 {
+ execsql {SELECT substr(t1,-4,3) FROM tbl1 ORDER BY t1}
+} "TF- ter ain i\u1234h"
+do_test func-3.99 {
+ execsql {DELETE FROM tbl1}
+ foreach word {this program is free software} {
+ execsql "INSERT INTO tbl1 VALUES('$word')"
+ }
+ execsql {SELECT t1 FROM tbl1}
+} {this program is free software}
+
+} ;# End \u1234!=u1234
+
+# Test the abs() and round() functions.
+#
+ifcapable !floatingpoint {
+ do_test func-4.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(2,12345678901234,-1234567890);
+ INSERT INTO t1 VALUES(3,-2,-5);
+ }
+ catchsql {SELECT abs(a,b) FROM t1}
+ } {1 {wrong number of arguments to function abs()}}
+}
+ifcapable floatingpoint {
+ do_test func-4.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(2,1.2345678901234,-12345.67890);
+ INSERT INTO t1 VALUES(3,-2,-5);
+ }
+ catchsql {SELECT abs(a,b) FROM t1}
+ } {1 {wrong number of arguments to function abs()}}
+}
+do_test func-4.2 {
+ catchsql {SELECT abs() FROM t1}
+} {1 {wrong number of arguments to function abs()}}
+ifcapable floatingpoint {
+ do_test func-4.3 {
+ catchsql {SELECT abs(b) FROM t1 ORDER BY a}
+ } {0 {2 1.2345678901234 2}}
+ do_test func-4.4 {
+ catchsql {SELECT abs(c) FROM t1 ORDER BY a}
+ } {0 {3 12345.6789 5}}
+}
+ifcapable !floatingpoint {
+ if {[working_64bit_int]} {
+ do_test func-4.3 {
+ catchsql {SELECT abs(b) FROM t1 ORDER BY a}
+ } {0 {2 12345678901234 2}}
+ }
+ do_test func-4.4 {
+ catchsql {SELECT abs(c) FROM t1 ORDER BY a}
+ } {0 {3 1234567890 5}}
+}
+do_test func-4.4.1 {
+ execsql {SELECT abs(a) FROM t2}
+} {1 {} 345 {} 67890}
+do_test func-4.4.2 {
+ execsql {SELECT abs(t1) FROM tbl1}
+} {0.0 0.0 0.0 0.0 0.0}
+
+ifcapable floatingpoint {
+ do_test func-4.5 {
+ catchsql {SELECT round(a,b,c) FROM t1}
+ } {1 {wrong number of arguments to function round()}}
+ do_test func-4.6 {
+ catchsql {SELECT round(b,2) FROM t1 ORDER BY b}
+ } {0 {-2.0 1.23 2.0}}
+ do_test func-4.7 {
+ catchsql {SELECT round(b,0) FROM t1 ORDER BY a}
+ } {0 {2.0 1.0 -2.0}}
+ do_test func-4.8 {
+ catchsql {SELECT round(c) FROM t1 ORDER BY a}
+ } {0 {3.0 -12346.0 -5.0}}
+ do_test func-4.9 {
+ catchsql {SELECT round(c,a) FROM t1 ORDER BY a}
+ } {0 {3.0 -12345.68 -5.0}}
+ do_test func-4.10 {
+ catchsql {SELECT 'x' || round(c,a) || 'y' FROM t1 ORDER BY a}
+ } {0 {x3.0y x-12345.68y x-5.0y}}
+ do_test func-4.11 {
+ catchsql {SELECT round() FROM t1 ORDER BY a}
+ } {1 {wrong number of arguments to function round()}}
+ do_test func-4.12 {
+ execsql {SELECT coalesce(round(a,2),'nil') FROM t2}
+ } {1.0 nil 345.0 nil 67890.0}
+ do_test func-4.13 {
+ execsql {SELECT round(t1,2) FROM tbl1}
+ } {0.0 0.0 0.0 0.0 0.0}
+ do_test func-4.14 {
+ execsql {SELECT typeof(round(5.1,1));}
+ } {real}
+ do_test func-4.15 {
+ execsql {SELECT typeof(round(5.1));}
+ } {real}
+ do_test func-4.16 {
+ catchsql {SELECT round(b,2.0) FROM t1 ORDER BY b}
+ } {0 {-2.0 1.23 2.0}}
+ # Verify some values reported on the mailing list.
+ # Some of these fail on MSVC builds with 64-bit
+ # long doubles, but not on GCC builds with 80-bit
+ # long doubles.
+ for {set i 1} {$i<999} {incr i} {
+ set x1 [expr 40222.5 + $i]
+ set x2 [expr 40223.0 + $i]
+ do_test func-4.17.$i {
+ execsql {SELECT round($x1);}
+ } $x2
+ }
+ for {set i 1} {$i<999} {incr i} {
+ set x1 [expr 40222.05 + $i]
+ set x2 [expr 40222.10 + $i]
+ do_test func-4.18.$i {
+ execsql {SELECT round($x1,1);}
+ } $x2
+ }
+ do_test func-4.20 {
+ execsql {SELECT round(40223.4999999999);}
+ } {40223.0}
+ do_test func-4.21 {
+ execsql {SELECT round(40224.4999999999);}
+ } {40224.0}
+ do_test func-4.22 {
+ execsql {SELECT round(40225.4999999999);}
+ } {40225.0}
+ for {set i 1} {$i<10} {incr i} {
+ do_test func-4.23.$i {
+ execsql {SELECT round(40223.4999999999,$i);}
+ } {40223.5}
+ do_test func-4.24.$i {
+ execsql {SELECT round(40224.4999999999,$i);}
+ } {40224.5}
+ do_test func-4.25.$i {
+ execsql {SELECT round(40225.4999999999,$i);}
+ } {40225.5}
+ }
+ for {set i 10} {$i<32} {incr i} {
+ do_test func-4.26.$i {
+ execsql {SELECT round(40223.4999999999,$i);}
+ } {40223.4999999999}
+ do_test func-4.27.$i {
+ execsql {SELECT round(40224.4999999999,$i);}
+ } {40224.4999999999}
+ do_test func-4.28.$i {
+ execsql {SELECT round(40225.4999999999,$i);}
+ } {40225.4999999999}
+ }
+ do_test func-4.29 {
+ execsql {SELECT round(1234567890.5);}
+ } {1234567891.0}
+ do_test func-4.30 {
+ execsql {SELECT round(12345678901.5);}
+ } {12345678902.0}
+ do_test func-4.31 {
+ execsql {SELECT round(123456789012.5);}
+ } {123456789013.0}
+ do_test func-4.32 {
+ execsql {SELECT round(1234567890123.5);}
+ } {1234567890124.0}
+ do_test func-4.33 {
+ execsql {SELECT round(12345678901234.5);}
+ } {12345678901235.0}
+ do_test func-4.34 {
+ execsql {SELECT round(1234567890123.35,1);}
+ } {1234567890123.4}
+ do_test func-4.35 {
+ execsql {SELECT round(1234567890123.445,2);}
+ } {1234567890123.45}
+ do_test func-4.36 {
+ execsql {SELECT round(99999999999994.5);}
+ } {99999999999995.0}
+ do_test func-4.37 {
+ execsql {SELECT round(9999999999999.55,1);}
+ } {9999999999999.6}
+ do_test func-4.38 {
+ execsql {SELECT round(9999999999999.555,2);}
+ } {9999999999999.56}
+}
+
+# Test the upper() and lower() functions
+#
+do_test func-5.1 {
+ execsql {SELECT upper(t1) FROM tbl1}
+} {THIS PROGRAM IS FREE SOFTWARE}
+do_test func-5.2 {
+ execsql {SELECT lower(upper(t1)) FROM tbl1}
+} {this program is free software}
+do_test func-5.3 {
+ execsql {SELECT upper(a), lower(a) FROM t2}
+} {1 1 {} {} 345 345 {} {} 67890 67890}
+ifcapable !icu {
+ do_test func-5.4 {
+ catchsql {SELECT upper(a,5) FROM t2}
+ } {1 {wrong number of arguments to function upper()}}
+}
+do_test func-5.5 {
+ catchsql {SELECT upper(*) FROM t2}
+} {1 {wrong number of arguments to function upper()}}
+
+# Test the coalesce() and nullif() functions
+#
+do_test func-6.1 {
+ execsql {SELECT coalesce(a,'xyz') FROM t2}
+} {1 xyz 345 xyz 67890}
+do_test func-6.2 {
+ execsql {SELECT coalesce(upper(a),'nil') FROM t2}
+} {1 nil 345 nil 67890}
+do_test func-6.3 {
+ execsql {SELECT coalesce(nullif(1,1),'nil')}
+} {nil}
+do_test func-6.4 {
+ execsql {SELECT coalesce(nullif(1,2),'nil')}
+} {1}
+do_test func-6.5 {
+ execsql {SELECT coalesce(nullif(1,NULL),'nil')}
+} {1}
+
+
+# Test the last_insert_rowid() function
+#
+do_test func-7.1 {
+ execsql {SELECT last_insert_rowid()}
+} [db last_insert_rowid]
+
+# Tests for aggregate functions and how they handle NULLs.
+#
+ifcapable floatingpoint {
+ do_test func-8.1 {
+ ifcapable explain {
+ execsql {EXPLAIN SELECT sum(a) FROM t2;}
+ }
+ execsql {
+ SELECT sum(a), count(a), round(avg(a),2), min(a), max(a), count(*) FROM t2;
+ }
+ } {68236 3 22745.33 1 67890 5}
+}
+ifcapable !floatingpoint {
+ do_test func-8.1 {
+ ifcapable explain {
+ execsql {EXPLAIN SELECT sum(a) FROM t2;}
+ }
+ execsql {
+ SELECT sum(a), count(a), avg(a), min(a), max(a), count(*) FROM t2;
+ }
+ } {68236 3 22745.0 1 67890 5}
+}
+do_test func-8.2 {
+ execsql {
+ SELECT max('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t2;
+ }
+} {z+67890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}
+
+ifcapable tempdb {
+ do_test func-8.3 {
+ execsql {
+ CREATE TEMP TABLE t3 AS SELECT a FROM t2 ORDER BY a DESC;
+ SELECT min('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3;
+ }
+ } {z+1abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}
+} else {
+ do_test func-8.3 {
+ execsql {
+ CREATE TABLE t3 AS SELECT a FROM t2 ORDER BY a DESC;
+ SELECT min('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3;
+ }
+ } {z+1abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}
+}
+do_test func-8.4 {
+ execsql {
+ SELECT max('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3;
+ }
+} {z+67890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}
+ifcapable compound {
+ do_test func-8.5 {
+ execsql {
+ SELECT sum(x) FROM (SELECT '9223372036' || '854775807' AS x
+ UNION ALL SELECT -9223372036854775807)
+ }
+ } {0}
+ do_test func-8.6 {
+ execsql {
+ SELECT typeof(sum(x)) FROM (SELECT '9223372036' || '854775807' AS x
+ UNION ALL SELECT -9223372036854775807)
+ }
+ } {integer}
+ do_test func-8.7 {
+ execsql {
+ SELECT typeof(sum(x)) FROM (SELECT '9223372036' || '854775808' AS x
+ UNION ALL SELECT -9223372036854775807)
+ }
+ } {real}
+ifcapable floatingpoint {
+ do_test func-8.8 {
+ execsql {
+ SELECT sum(x)>0.0 FROM (SELECT '9223372036' || '854775808' AS x
+ UNION ALL SELECT -9223372036850000000)
+ }
+ } {1}
+}
+ifcapable !floatingpoint {
+ do_test func-8.8 {
+ execsql {
+ SELECT sum(x)>0 FROM (SELECT '9223372036' || '854775808' AS x
+ UNION ALL SELECT -9223372036850000000)
+ }
+ } {1}
+}
+}
+
+# How do you test the random() function in a meaningful, deterministic way?
+#
+do_test func-9.1 {
+ execsql {
+ SELECT random() is not null;
+ }
+} {1}
+do_test func-9.2 {
+ execsql {
+ SELECT typeof(random());
+ }
+} {integer}
+do_test func-9.3 {
+ execsql {
+ SELECT randomblob(32) is not null;
+ }
+} {1}
+do_test func-9.4 {
+ execsql {
+ SELECT typeof(randomblob(32));
+ }
+} {blob}
+do_test func-9.5 {
+ execsql {
+ SELECT length(randomblob(32)), length(randomblob(-5)),
+ length(randomblob(2000))
+ }
+} {32 1 2000}
+
+# The "hex()" function was added in order to be able to render blobs
+# generated by randomblob(). So this seems like a good place to test
+# hex().
+#
+ifcapable bloblit {
+ do_test func-9.10 {
+ execsql {SELECT hex(x'00112233445566778899aAbBcCdDeEfF')}
+ } {00112233445566778899AABBCCDDEEFF}
+}
+set encoding [db one {PRAGMA encoding}]
+if {$encoding=="UTF-16le"} {
+ do_test func-9.11-utf16le {
+ execsql {SELECT hex(replace('abcdefg','ef','12'))}
+ } {6100620063006400310032006700}
+ do_test func-9.12-utf16le {
+ execsql {SELECT hex(replace('abcdefg','','12'))}
+ } {6100620063006400650066006700}
+ do_test func-9.13-utf16le {
+ execsql {SELECT hex(replace('aabcdefg','a','aaa'))}
+ } {610061006100610061006100620063006400650066006700}
+} elseif {$encoding=="UTF-8"} {
+ do_test func-9.11-utf8 {
+ execsql {SELECT hex(replace('abcdefg','ef','12'))}
+ } {61626364313267}
+ do_test func-9.12-utf8 {
+ execsql {SELECT hex(replace('abcdefg','','12'))}
+ } {61626364656667}
+ do_test func-9.13-utf8 {
+ execsql {SELECT hex(replace('aabcdefg','a','aaa'))}
+ } {616161616161626364656667}
+}
+
+# Use the "sqlite_register_test_function" TCL command which is part of
+# the text fixture in order to verify correct operation of some of
+# the user-defined SQL function APIs that are not used by the built-in
+# functions.
+#
+set ::DB [sqlite3_connection_pointer db]
+sqlite_register_test_function $::DB testfunc
+do_test func-10.1 {
+ catchsql {
+ SELECT testfunc(NULL,NULL);
+ }
+} {1 {first argument should be one of: int int64 string double null value}}
+do_test func-10.2 {
+ execsql {
+ SELECT testfunc(
+ 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'int', 1234
+ );
+ }
+} {1234}
+do_test func-10.3 {
+ execsql {
+ SELECT testfunc(
+ 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'string', NULL
+ );
+ }
+} {{}}
+
+ifcapable floatingpoint {
+ do_test func-10.4 {
+ execsql {
+ SELECT testfunc(
+ 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'double', 1.234
+ );
+ }
+ } {1.234}
+ do_test func-10.5 {
+ execsql {
+ SELECT testfunc(
+ 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'int', 1234,
+ 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'string', NULL,
+ 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'double', 1.234,
+ 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'int', 1234,
+ 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'string', NULL,
+ 'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'double', 1.234
+ );
+ }
+ } {1.234}
+}
+
+# Test the built-in sqlite_version(*) SQL function.
+#
+do_test func-11.1 {
+ execsql {
+ SELECT sqlite_version(*);
+ }
+} [sqlite3 -version]
+
+# Test that destructors passed to sqlite3 by calls to sqlite3_result_text()
+# etc. are called. These tests use two special user-defined functions
+# (implemented in func.c) only available in test builds.
+#
+# Function test_destructor() takes one argument and returns a copy of the
+# text form of that argument. A destructor is associated with the return
+# value. Function test_destructor_count() returns the number of outstanding
+# destructor calls for values returned by test_destructor().
+#
+if {[db eval {PRAGMA encoding}]=="UTF-8"} {
+ do_test func-12.1-utf8 {
+ execsql {
+ SELECT test_destructor('hello world'), test_destructor_count();
+ }
+ } {{hello world} 1}
+} else {
+ ifcapable {utf16} {
+ do_test func-12.1-utf16 {
+ execsql {
+ SELECT test_destructor16('hello world'), test_destructor_count();
+ }
+ } {{hello world} 1}
+ }
+}
+do_test func-12.2 {
+ execsql {
+ SELECT test_destructor_count();
+ }
+} {0}
+do_test func-12.3 {
+ execsql {
+ SELECT test_destructor('hello')||' world'
+ }
+} {{hello world}}
+do_test func-12.4 {
+ execsql {
+ SELECT test_destructor_count();
+ }
+} {0}
+do_test func-12.5 {
+ execsql {
+ CREATE TABLE t4(x);
+ INSERT INTO t4 VALUES(test_destructor('hello'));
+ INSERT INTO t4 VALUES(test_destructor('world'));
+ SELECT min(test_destructor(x)), max(test_destructor(x)) FROM t4;
+ }
+} {hello world}
+do_test func-12.6 {
+ execsql {
+ SELECT test_destructor_count();
+ }
+} {0}
+do_test func-12.7 {
+ execsql {
+ DROP TABLE t4;
+ }
+} {}
+
+
+# Test that the auxdata API for scalar functions works. This test uses
+# a special user-defined function only available in test builds,
+# test_auxdata(). Function test_auxdata() takes any number of arguments.
+do_test func-13.1 {
+ execsql {
+ SELECT test_auxdata('hello world');
+ }
+} {0}
+
+do_test func-13.2 {
+ execsql {
+ CREATE TABLE t4(a, b);
+ INSERT INTO t4 VALUES('abc', 'def');
+ INSERT INTO t4 VALUES('ghi', 'jkl');
+ }
+} {}
+do_test func-13.3 {
+ execsql {
+ SELECT test_auxdata('hello world') FROM t4;
+ }
+} {0 1}
+do_test func-13.4 {
+ execsql {
+ SELECT test_auxdata('hello world', 123) FROM t4;
+ }
+} {{0 0} {1 1}}
+do_test func-13.5 {
+ execsql {
+ SELECT test_auxdata('hello world', a) FROM t4;
+ }
+} {{0 0} {1 0}}
+do_test func-13.6 {
+ execsql {
+ SELECT test_auxdata('hello'||'world', a) FROM t4;
+ }
+} {{0 0} {1 0}}
+
+# Test that auxilary data is preserved between calls for SQL variables.
+do_test func-13.7 {
+ set DB [sqlite3_connection_pointer db]
+ set sql "SELECT test_auxdata( ? , a ) FROM t4;"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_bind_text $STMT 1 hello\000 -1
+ set res [list]
+ while { "SQLITE_ROW"==[sqlite3_step $STMT] } {
+ lappend res [sqlite3_column_text $STMT 0]
+ }
+ lappend res [sqlite3_finalize $STMT]
+} {{0 0} {1 0} SQLITE_OK}
+
+# Make sure that a function with a very long name is rejected
+do_test func-14.1 {
+ catch {
+ db function [string repeat X 254] {return "hello"}
+ }
+} {0}
+do_test func-14.2 {
+ catch {
+ db function [string repeat X 256] {return "hello"}
+ }
+} {1}
+
+do_test func-15.1 {
+ catchsql {select test_error(NULL)}
+} {1 {}}
+do_test func-15.2 {
+ catchsql {select test_error('this is the error message')}
+} {1 {this is the error message}}
+do_test func-15.3 {
+ catchsql {select test_error('this is the error message',12)}
+} {1 {this is the error message}}
+do_test func-15.4 {
+ db errorcode
+} {12}
+
+# Test the quote function for BLOB and NULL values.
+do_test func-16.1 {
+ execsql {
+ CREATE TABLE tbl2(a, b);
+ }
+ set STMT [sqlite3_prepare $::DB "INSERT INTO tbl2 VALUES(?, ?)" -1 TAIL]
+ sqlite3_bind_blob $::STMT 1 abc 3
+ sqlite3_step $::STMT
+ sqlite3_finalize $::STMT
+ execsql {
+ SELECT quote(a), quote(b) FROM tbl2;
+ }
+} {X'616263' NULL}
+
+# Correctly handle function error messages that include %. Ticket #1354
+#
+do_test func-17.1 {
+ proc testfunc1 args {error "Error %d with %s percents %p"}
+ db function testfunc1 ::testfunc1
+ catchsql {
+ SELECT testfunc1(1,2,3);
+ }
+} {1 {Error %d with %s percents %p}}
+
+# The SUM function should return integer results when all inputs are integer.
+#
+do_test func-18.1 {
+ execsql {
+ CREATE TABLE t5(x);
+ INSERT INTO t5 VALUES(1);
+ INSERT INTO t5 VALUES(-99);
+ INSERT INTO t5 VALUES(10000);
+ SELECT sum(x) FROM t5;
+ }
+} {9902}
+ifcapable floatingpoint {
+ do_test func-18.2 {
+ execsql {
+ INSERT INTO t5 VALUES(0.0);
+ SELECT sum(x) FROM t5;
+ }
+ } {9902.0}
+}
+
+# The sum of nothing is NULL. But the sum of all NULLs is NULL.
+#
+# The TOTAL of nothing is 0.0.
+#
+do_test func-18.3 {
+ execsql {
+ DELETE FROM t5;
+ SELECT sum(x), total(x) FROM t5;
+ }
+} {{} 0.0}
+do_test func-18.4 {
+ execsql {
+ INSERT INTO t5 VALUES(NULL);
+ SELECT sum(x), total(x) FROM t5
+ }
+} {{} 0.0}
+do_test func-18.5 {
+ execsql {
+ INSERT INTO t5 VALUES(NULL);
+ SELECT sum(x), total(x) FROM t5
+ }
+} {{} 0.0}
+do_test func-18.6 {
+ execsql {
+ INSERT INTO t5 VALUES(123);
+ SELECT sum(x), total(x) FROM t5
+ }
+} {123 123.0}
+
+# Ticket #1664, #1669, #1670, #1674: An integer overflow on SUM causes
+# an error. The non-standard TOTAL() function continues to give a helpful
+# result.
+#
+do_test func-18.10 {
+ execsql {
+ CREATE TABLE t6(x INTEGER);
+ INSERT INTO t6 VALUES(1);
+ INSERT INTO t6 VALUES(1<<62);
+ SELECT sum(x) - ((1<<62)+1) from t6;
+ }
+} 0
+do_test func-18.11 {
+ execsql {
+ SELECT typeof(sum(x)) FROM t6
+ }
+} integer
+ifcapable floatingpoint {
+ do_test func-18.12 {
+ catchsql {
+ INSERT INTO t6 VALUES(1<<62);
+ SELECT sum(x) - ((1<<62)*2.0+1) from t6;
+ }
+ } {1 {integer overflow}}
+ do_test func-18.13 {
+ execsql {
+ SELECT total(x) - ((1<<62)*2.0+1) FROM t6
+ }
+ } 0.0
+}
+ifcapable !floatingpoint {
+ do_test func-18.12 {
+ catchsql {
+ INSERT INTO t6 VALUES(1<<62);
+ SELECT sum(x) - ((1<<62)*2+1) from t6;
+ }
+ } {1 {integer overflow}}
+ do_test func-18.13 {
+ execsql {
+ SELECT total(x) - ((1<<62)*2+1) FROM t6
+ }
+ } 0.0
+}
+if {[working_64bit_int]} {
+ do_test func-18.14 {
+ execsql {
+ SELECT sum(-9223372036854775805);
+ }
+ } -9223372036854775805
+}
+ifcapable compound&&subquery {
+
+do_test func-18.15 {
+ catchsql {
+ SELECT sum(x) FROM
+ (SELECT 9223372036854775807 AS x UNION ALL
+ SELECT 10 AS x);
+ }
+} {1 {integer overflow}}
+if {[working_64bit_int]} {
+ do_test func-18.16 {
+ catchsql {
+ SELECT sum(x) FROM
+ (SELECT 9223372036854775807 AS x UNION ALL
+ SELECT -10 AS x);
+ }
+ } {0 9223372036854775797}
+ do_test func-18.17 {
+ catchsql {
+ SELECT sum(x) FROM
+ (SELECT -9223372036854775807 AS x UNION ALL
+ SELECT 10 AS x);
+ }
+ } {0 -9223372036854775797}
+}
+do_test func-18.18 {
+ catchsql {
+ SELECT sum(x) FROM
+ (SELECT -9223372036854775807 AS x UNION ALL
+ SELECT -10 AS x);
+ }
+} {1 {integer overflow}}
+do_test func-18.19 {
+ catchsql {
+ SELECT sum(x) FROM (SELECT 9 AS x UNION ALL SELECT -10 AS x);
+ }
+} {0 -1}
+do_test func-18.20 {
+ catchsql {
+ SELECT sum(x) FROM (SELECT -9 AS x UNION ALL SELECT 10 AS x);
+ }
+} {0 1}
+do_test func-18.21 {
+ catchsql {
+ SELECT sum(x) FROM (SELECT -10 AS x UNION ALL SELECT 9 AS x);
+ }
+} {0 -1}
+do_test func-18.22 {
+ catchsql {
+ SELECT sum(x) FROM (SELECT 10 AS x UNION ALL SELECT -9 AS x);
+ }
+} {0 1}
+
+} ;# ifcapable compound&&subquery
+
+# Integer overflow on abs()
+#
+if {[working_64bit_int]} {
+ do_test func-18.31 {
+ catchsql {
+ SELECT abs(-9223372036854775807);
+ }
+ } {0 9223372036854775807}
+}
+do_test func-18.32 {
+ catchsql {
+ SELECT abs(-9223372036854775807-1);
+ }
+} {1 {integer overflow}}
+
+# The MATCH function exists but is only a stub and always throws an error.
+#
+do_test func-19.1 {
+ execsql {
+ SELECT match(a,b) FROM t1 WHERE 0;
+ }
+} {}
+do_test func-19.2 {
+ catchsql {
+ SELECT 'abc' MATCH 'xyz';
+ }
+} {1 {unable to use function MATCH in the requested context}}
+do_test func-19.3 {
+ catchsql {
+ SELECT 'abc' NOT MATCH 'xyz';
+ }
+} {1 {unable to use function MATCH in the requested context}}
+do_test func-19.4 {
+ catchsql {
+ SELECT match(1,2,3);
+ }
+} {1 {wrong number of arguments to function match()}}
+
+# Soundex tests.
+#
+if {![catch {db eval {SELECT soundex('hello')}}]} {
+ set i 0
+ foreach {name sdx} {
+ euler E460
+ EULER E460
+ Euler E460
+ ellery E460
+ gauss G200
+ ghosh G200
+ hilbert H416
+ Heilbronn H416
+ knuth K530
+ kant K530
+ Lloyd L300
+ LADD L300
+ Lukasiewicz L222
+ Lissajous L222
+ A A000
+ 12345 ?000
+ } {
+ incr i
+ do_test func-20.$i {
+ execsql {SELECT soundex($name)}
+ } $sdx
+ }
+}
+
+# Tests of the REPLACE function.
+#
+do_test func-21.1 {
+ catchsql {
+ SELECT replace(1,2);
+ }
+} {1 {wrong number of arguments to function replace()}}
+do_test func-21.2 {
+ catchsql {
+ SELECT replace(1,2,3,4);
+ }
+} {1 {wrong number of arguments to function replace()}}
+do_test func-21.3 {
+ execsql {
+ SELECT typeof(replace("This is the main test string", NULL, "ALT"));
+ }
+} {null}
+do_test func-21.4 {
+ execsql {
+ SELECT typeof(replace(NULL, "main", "ALT"));
+ }
+} {null}
+do_test func-21.5 {
+ execsql {
+ SELECT typeof(replace("This is the main test string", "main", NULL));
+ }
+} {null}
+do_test func-21.6 {
+ execsql {
+ SELECT replace("This is the main test string", "main", "ALT");
+ }
+} {{This is the ALT test string}}
+do_test func-21.7 {
+ execsql {
+ SELECT replace("This is the main test string", "main", "larger-main");
+ }
+} {{This is the larger-main test string}}
+do_test func-21.8 {
+ execsql {
+ SELECT replace("aaaaaaa", "a", "0123456789");
+ }
+} {0123456789012345678901234567890123456789012345678901234567890123456789}
+
+ifcapable tclvar {
+ do_test func-21.9 {
+ # Attempt to exploit a buffer-overflow that at one time existed
+ # in the REPLACE function.
+ set ::str "[string repeat A 29998]CC[string repeat A 35537]"
+ set ::rep [string repeat B 65536]
+ execsql {
+ SELECT LENGTH(REPLACE($::str, 'C', $::rep));
+ }
+ } [expr 29998 + 2*65536 + 35537]
+}
+
+# Tests for the TRIM, LTRIM and RTRIM functions.
+#
+do_test func-22.1 {
+ catchsql {SELECT trim(1,2,3)}
+} {1 {wrong number of arguments to function trim()}}
+do_test func-22.2 {
+ catchsql {SELECT ltrim(1,2,3)}
+} {1 {wrong number of arguments to function ltrim()}}
+do_test func-22.3 {
+ catchsql {SELECT rtrim(1,2,3)}
+} {1 {wrong number of arguments to function rtrim()}}
+do_test func-22.4 {
+ execsql {SELECT trim(' hi ');}
+} {hi}
+do_test func-22.5 {
+ execsql {SELECT ltrim(' hi ');}
+} {{hi }}
+do_test func-22.6 {
+ execsql {SELECT rtrim(' hi ');}
+} {{ hi}}
+do_test func-22.7 {
+ execsql {SELECT trim(' hi ','xyz');}
+} {{ hi }}
+do_test func-22.8 {
+ execsql {SELECT ltrim(' hi ','xyz');}
+} {{ hi }}
+do_test func-22.9 {
+ execsql {SELECT rtrim(' hi ','xyz');}
+} {{ hi }}
+do_test func-22.10 {
+ execsql {SELECT trim('xyxzy hi zzzy','xyz');}
+} {{ hi }}
+do_test func-22.11 {
+ execsql {SELECT ltrim('xyxzy hi zzzy','xyz');}
+} {{ hi zzzy}}
+do_test func-22.12 {
+ execsql {SELECT rtrim('xyxzy hi zzzy','xyz');}
+} {{xyxzy hi }}
+do_test func-22.13 {
+ execsql {SELECT trim(' hi ','');}
+} {{ hi }}
+if {[db one {PRAGMA encoding}]=="UTF-8"} {
+ do_test func-22.14 {
+ execsql {SELECT hex(trim(x'c280e1bfbff48fbfbf6869',x'6162e1bfbfc280'))}
+ } {F48FBFBF6869}
+ do_test func-22.15 {
+ execsql {SELECT hex(trim(x'6869c280e1bfbff48fbfbf61',
+ x'6162e1bfbfc280f48fbfbf'))}
+ } {6869}
+ do_test func-22.16 {
+ execsql {SELECT hex(trim(x'ceb1ceb2ceb3',x'ceb1'));}
+ } {CEB2CEB3}
+}
+do_test func-22.20 {
+ execsql {SELECT typeof(trim(NULL));}
+} {null}
+do_test func-22.21 {
+ execsql {SELECT typeof(trim(NULL,'xyz'));}
+} {null}
+do_test func-22.22 {
+ execsql {SELECT typeof(trim('hello',NULL));}
+} {null}
+
+# This is to test the deprecated sqlite3_aggregate_count() API.
+#
+ifcapable deprecated {
+ do_test func-23.1 {
+ sqlite3_create_aggregate db
+ execsql {
+ SELECT legacy_count() FROM t6;
+ }
+ } {3}
+}
+
+# The group_concat() function.
+#
+do_test func-24.1 {
+ execsql {
+ SELECT group_concat(t1) FROM tbl1
+ }
+} {this,program,is,free,software}
+do_test func-24.2 {
+ execsql {
+ SELECT group_concat(t1,' ') FROM tbl1
+ }
+} {{this program is free software}}
+do_test func-24.3 {
+ execsql {
+ SELECT group_concat(t1,' ' || rowid || ' ') FROM tbl1
+ }
+} {{this 2 program 3 is 4 free 5 software}}
+do_test func-24.4 {
+ execsql {
+ SELECT group_concat(NULL,t1) FROM tbl1
+ }
+} {{}}
+do_test func-24.5 {
+ execsql {
+ SELECT group_concat(t1,NULL) FROM tbl1
+ }
+} {thisprogramisfreesoftware}
+do_test func-24.6 {
+ execsql {
+ SELECT 'BEGIN-'||group_concat(t1) FROM tbl1
+ }
+} {BEGIN-this,program,is,free,software}
+
+# Ticket #3179: Make sure aggregate functions can take many arguments.
+# None of the built-in aggregates do this, so use the md5sum() from the
+# test extensions.
+#
+unset -nocomplain midargs
+set midargs {}
+unset -nocomplain midres
+set midres {}
+unset -nocomplain result
+for {set i 1} {$i<[sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG -1]} {incr i} {
+ append midargs ,'/$i'
+ append midres /$i
+ set result [md5 \
+ "this${midres}program${midres}is${midres}free${midres}software${midres}"]
+ set sql "SELECT md5sum(t1$midargs) FROM tbl1"
+ do_test func-24.7.$i {
+ db eval $::sql
+ } $result
+}
+
+# Ticket #3806. If the initial string in a group_concat is an empty
+# string, the separator that follows should still be present.
+#
+do_test func-24.8 {
+ execsql {
+ SELECT group_concat(CASE t1 WHEN 'this' THEN '' ELSE t1 END) FROM tbl1
+ }
+} {,program,is,free,software}
+do_test func-24.9 {
+ execsql {
+ SELECT group_concat(CASE WHEN t1!='software' THEN '' ELSE t1 END) FROM tbl1
+ }
+} {,,,,software}
+
+# Ticket #3923. Initial empty strings have a separator. But initial
+# NULLs do not.
+#
+do_test func-24.10 {
+ execsql {
+ SELECT group_concat(CASE t1 WHEN 'this' THEN null ELSE t1 END) FROM tbl1
+ }
+} {program,is,free,software}
+do_test func-24.11 {
+ execsql {
+ SELECT group_concat(CASE WHEN t1!='software' THEN null ELSE t1 END) FROM tbl1
+ }
+} {software}
+do_test func-24.12 {
+ execsql {
+ SELECT group_concat(CASE t1 WHEN 'this' THEN ''
+ WHEN 'program' THEN null ELSE t1 END) FROM tbl1
+ }
+} {,is,free,software}
+
+
+# Use the test_isolation function to make sure that type conversions
+# on function arguments do not effect subsequent arguments.
+#
+do_test func-25.1 {
+ execsql {SELECT test_isolation(t1,t1) FROM tbl1}
+} {this program is free software}
+
+# Try to misuse the sqlite3_create_function() interface. Verify that
+# errors are returned.
+#
+do_test func-26.1 {
+ abuse_create_function db
+} {}
+
+# The previous test (func-26.1) registered a function with a very long
+# function name that takes many arguments and always returns NULL. Verify
+# that this function works correctly.
+#
+do_test func-26.2 {
+ set a {}
+ for {set i 1} {$i<=$::SQLITE_MAX_FUNCTION_ARG} {incr i} {
+ lappend a $i
+ }
+ db eval "
+ SELECT nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789([join $a ,]);
+ "
+} {{}}
+do_test func-26.3 {
+ set a {}
+ for {set i 1} {$i<=$::SQLITE_MAX_FUNCTION_ARG+1} {incr i} {
+ lappend a $i
+ }
+ catchsql "
+ SELECT nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789([join $a ,]);
+ "
+} {1 {too many arguments on function nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789}}
+do_test func-26.4 {
+ set a {}
+ for {set i 1} {$i<=$::SQLITE_MAX_FUNCTION_ARG-1} {incr i} {
+ lappend a $i
+ }
+ catchsql "
+ SELECT nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789([join $a ,]);
+ "
+} {1 {wrong number of arguments to function nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789()}}
+do_test func-26.5 {
+ catchsql "
+ SELECT nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678a(0);
+ "
+} {1 {no such function: nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678a}}
+do_test func-26.6 {
+ catchsql "
+ SELECT nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789a(0);
+ "
+} {1 {no such function: nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789a}}
+
+do_test func-27.1 {
+ catchsql {SELECT coalesce()}
+} {1 {wrong number of arguments to function coalesce()}}
+do_test func-27.2 {
+ catchsql {SELECT coalesce(1)}
+} {1 {wrong number of arguments to function coalesce()}}
+do_test func-27.3 {
+ catchsql {SELECT coalesce(1,2)}
+} {0 1}
+
+# Ticket 2d401a94287b5
+# Unknown function in a DEFAULT expression causes a segfault.
+#
+do_test func-28.1 {
+ db eval {
+ CREATE TABLE t28(x, y DEFAULT(nosuchfunc(1)));
+ }
+ catchsql {
+ INSERT INTO t28(x) VALUES(1);
+ }
+} {1 {unknown function: nosuchfunc()}}
+
+finish_test
diff --git a/test/func2.test b/test/func2.test
new file mode 100644
index 0000000..08ad857
--- /dev/null
+++ b/test/func2.test
@@ -0,0 +1,511 @@
+# 2009 November 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing built-in functions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Test plan:
+#
+# func2-1.*: substr implementation (ascii)
+# func2-2.*: substr implementation (utf8)
+# func2-3.*: substr implementation (blob)
+#
+
+proc bin_to_hex {blob} {
+ set bytes {}
+ binary scan $blob \c* bytes
+ set bytes2 [list]
+ foreach b $bytes {lappend bytes2 [format %02X [expr $b & 0xFF]]}
+ join $bytes2 {}
+}
+
+#----------------------------------------------------------------------------
+# Test cases func2-1.*: substr implementation (ascii)
+#
+
+do_test func2-1.1 {
+ execsql {SELECT 'Supercalifragilisticexpialidocious'}
+} {Supercalifragilisticexpialidocious}
+
+# substr(x,y), substr(x,y,z)
+do_test func2-1.2.1 {
+ catchsql {SELECT SUBSTR()}
+} {1 {wrong number of arguments to function SUBSTR()}}
+do_test func2-1.2.2 {
+ catchsql {SELECT SUBSTR('Supercalifragilisticexpialidocious')}
+} {1 {wrong number of arguments to function SUBSTR()}}
+do_test func2-1.2.3 {
+ catchsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 1,1,1)}
+} {1 {wrong number of arguments to function SUBSTR()}}
+
+# p1 is 1-indexed
+do_test func2-1.3 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0)}
+} {Supercalifragilisticexpialidocious}
+do_test func2-1.4 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 1)}
+} {Supercalifragilisticexpialidocious}
+do_test func2-1.5 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2)}
+} {upercalifragilisticexpialidocious}
+do_test func2-1.6 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 30)}
+} {cious}
+do_test func2-1.7 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 34)}
+} {s}
+do_test func2-1.8 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 35)}
+} {{}}
+do_test func2-1.9 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 36)}
+} {{}}
+
+# if p1<0, start from right
+do_test func2-1.10 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -0)}
+} {Supercalifragilisticexpialidocious}
+do_test func2-1.11 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -1)}
+} {s}
+do_test func2-1.12 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -2)}
+} {us}
+do_test func2-1.13 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -30)}
+} {rcalifragilisticexpialidocious}
+do_test func2-1.14 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -34)}
+} {Supercalifragilisticexpialidocious}
+do_test func2-1.15 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -35)}
+} {Supercalifragilisticexpialidocious}
+do_test func2-1.16 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -36)}
+} {Supercalifragilisticexpialidocious}
+
+# p1 is 1-indexed, p2 length to return
+do_test func2-1.17.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0, 1)}
+} {{}}
+do_test func2-1.17.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0, 2)}
+} {S}
+do_test func2-1.18 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 1, 1)}
+} {S}
+do_test func2-1.19.0 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, 0)}
+} {{}}
+do_test func2-1.19.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, 1)}
+} {u}
+do_test func2-1.19.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, 2)}
+} {up}
+do_test func2-1.20 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 30, 1)}
+} {c}
+do_test func2-1.21 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 34, 1)}
+} {s}
+do_test func2-1.22 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 35, 1)}
+} {{}}
+do_test func2-1.23 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 36, 1)}
+} {{}}
+
+# if p1<0, start from right, p2 length to return
+do_test func2-1.24 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -0, 1)}
+} {{}}
+do_test func2-1.25.0 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -1, 0)}
+} {{}}
+do_test func2-1.25.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -1, 1)}
+} {s}
+do_test func2-1.25.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -1, 2)}
+} {s}
+do_test func2-1.26 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -2, 1)}
+} {u}
+do_test func2-1.27 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -30, 1)}
+} {r}
+do_test func2-1.28.0 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -34, 0)}
+} {{}}
+do_test func2-1.28.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -34, 1)}
+} {S}
+do_test func2-1.28.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -34, 2)}
+} {Su}
+do_test func2-1.29.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -35, 1)}
+} {{}}
+do_test func2-1.29.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -35, 2)}
+} {S}
+do_test func2-1.30.0 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -36, 0)}
+} {{}}
+do_test func2-1.30.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -36, 1)}
+} {{}}
+do_test func2-1.30.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -36, 2)}
+} {{}}
+do_test func2-1.30.3 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -36, 3)}
+} {S}
+
+# p1 is 1-indexed, p2 length to return, p2<0 return p2 chars before p1
+do_test func2-1.31.0 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0, 0)}
+} {{}}
+do_test func2-1.31.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0, -1)}
+} {{}}
+do_test func2-1.31.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0, -2)}
+} {{}}
+do_test func2-1.32.0 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 1, 0)}
+} {{}}
+do_test func2-1.32.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 1, -1)}
+} {{}}
+do_test func2-1.33.0 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, 0)}
+} {{}}
+do_test func2-1.33.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, -1)}
+} {S}
+do_test func2-1.33.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, -2)}
+} {S}
+do_test func2-1.34.0 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 3, 0)}
+} {{}}
+do_test func2-1.34.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 3, -1)}
+} {u}
+do_test func2-1.34.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 3, -2)}
+} {Su}
+do_test func2-1.35.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 30, -1)}
+} {o}
+do_test func2-1.35.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 30, -2)}
+} {do}
+do_test func2-1.36 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 34, -1)}
+} {u}
+do_test func2-1.37 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 35, -1)}
+} {s}
+do_test func2-1.38.0 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 36, 0)}
+} {{}}
+do_test func2-1.38.1 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 36, -1)}
+} {{}}
+do_test func2-1.38.2 {
+ execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 36, -2)}
+} {s}
+
+
+#----------------------------------------------------------------------------
+# Test cases func2-2.*: substr implementation (utf8)
+#
+
+# Only do the following tests if TCL has UTF-8 capabilities
+#
+if {"\u1234"!="u1234"} {
+
+do_test func2-2.1.1 {
+ execsql "SELECT 'hi\u1234ho'"
+} "hi\u1234ho"
+
+# substr(x,y), substr(x,y,z)
+do_test func2-2.1.2 {
+ catchsql "SELECT SUBSTR()"
+} {1 {wrong number of arguments to function SUBSTR()}}
+do_test func2-2.1.3 {
+ catchsql "SELECT SUBSTR('hi\u1234ho')"
+} {1 {wrong number of arguments to function SUBSTR()}}
+do_test func2-2.1.4 {
+ catchsql "SELECT SUBSTR('hi\u1234ho', 1,1,1)"
+} {1 {wrong number of arguments to function SUBSTR()}}
+
+do_test func2-2.2.0 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 0, 0)"
+} {{}}
+do_test func2-2.2.1 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 0, 1)"
+} {{}}
+do_test func2-2.2.2 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 0, 2)"
+} "h"
+do_test func2-2.2.3 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 0, 3)"
+} "hi"
+do_test func2-2.2.4 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 0, 4)"
+} "hi\u1234"
+do_test func2-2.2.5 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 0, 5)"
+} "hi\u1234h"
+do_test func2-2.2.6 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 0, 6)"
+} "hi\u1234ho"
+
+do_test func2-2.3.0 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 1, 0)"
+} {{}}
+do_test func2-2.3.1 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 1, 1)"
+} "h"
+do_test func2-2.3.2 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 1, 2)"
+} "hi"
+do_test func2-2.3.3 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 1, 3)"
+} "hi\u1234"
+do_test func2-2.3.4 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 1, 4)"
+} "hi\u1234h"
+do_test func2-2.3.5 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 1, 5)"
+} "hi\u1234ho"
+do_test func2-2.3.6 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 1, 6)"
+} "hi\u1234ho"
+
+do_test func2-2.4.0 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 3, 0)"
+} {{}}
+do_test func2-2.4.1 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 3, 1)"
+} "\u1234"
+do_test func2-2.4.2 {
+ execsql "SELECT SUBSTR('hi\u1234ho', 3, 2)"
+} "\u1234h"
+
+do_test func2-2.5.0 {
+ execsql "SELECT SUBSTR('\u1234', 0, 0)"
+} {{}}
+do_test func2-2.5.1 {
+ execsql "SELECT SUBSTR('\u1234', 0, 1)"
+} {{}}
+do_test func2-2.5.2 {
+ execsql "SELECT SUBSTR('\u1234', 0, 2)"
+} "\u1234"
+do_test func2-2.5.3 {
+ execsql "SELECT SUBSTR('\u1234', 0, 3)"
+} "\u1234"
+
+do_test func2-2.6.0 {
+ execsql "SELECT SUBSTR('\u1234', 1, 0)"
+} {{}}
+do_test func2-2.6.1 {
+ execsql "SELECT SUBSTR('\u1234', 1, 1)"
+} "\u1234"
+do_test func2-2.6.2 {
+ execsql "SELECT SUBSTR('\u1234', 1, 2)"
+} "\u1234"
+do_test func2-2.6.3 {
+ execsql "SELECT SUBSTR('\u1234', 1, 3)"
+} "\u1234"
+
+do_test func2-2.7.0 {
+ execsql "SELECT SUBSTR('\u1234', 2, 0)"
+} {{}}
+do_test func2-2.7.1 {
+ execsql "SELECT SUBSTR('\u1234', 2, 1)"
+} {{}}
+do_test func2-2.7.2 {
+ execsql "SELECT SUBSTR('\u1234', 2, 2)"
+} {{}}
+
+do_test func2-2.8.0 {
+ execsql "SELECT SUBSTR('\u1234', -1, 0)"
+} {{}}
+do_test func2-2.8.1 {
+ execsql "SELECT SUBSTR('\u1234', -1, 1)"
+} "\u1234"
+do_test func2-2.8.2 {
+ execsql "SELECT SUBSTR('\u1234', -1, 2)"
+} "\u1234"
+do_test func2-2.8.3 {
+ execsql "SELECT SUBSTR('\u1234', -1, 3)"
+} "\u1234"
+
+} ;# End \u1234!=u1234
+
+#----------------------------------------------------------------------------
+# Test cases func2-3.*: substr implementation (blob)
+#
+
+ifcapable {!bloblit} {
+ finish_test
+ return
+}
+
+do_test func2-3.1.1 {
+ set blob [execsql "SELECT x'1234'"]
+ bin_to_hex [lindex $blob 0]
+} "1234"
+
+# substr(x,y), substr(x,y,z)
+do_test func2-3.1.2 {
+ catchsql {SELECT SUBSTR()}
+} {1 {wrong number of arguments to function SUBSTR()}}
+do_test func2-3.1.3 {
+ catchsql {SELECT SUBSTR(x'1234')}
+} {1 {wrong number of arguments to function SUBSTR()}}
+do_test func2-3.1.4 {
+ catchsql {SELECT SUBSTR(x'1234', 1,1,1)}
+} {1 {wrong number of arguments to function SUBSTR()}}
+
+do_test func2-3.2.0 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 0, 0)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.2.1 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 0, 1)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.2.2 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 0, 2)"]
+ bin_to_hex [lindex $blob 0]
+} "12"
+do_test func2-3.2.3 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 0, 3)"]
+ bin_to_hex [lindex $blob 0]
+} "1234"
+
+do_test func2-3.3.0 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 1, 0)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.3.1 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 1, 1)"]
+ bin_to_hex [lindex $blob 0]
+} "12"
+do_test func2-3.3.2 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 1, 2)"]
+ bin_to_hex [lindex $blob 0]
+} "1234"
+do_test func2-3.3.3 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 1, 3)"]
+ bin_to_hex [lindex $blob 0]
+} "1234"
+
+do_test func2-3.4.0 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -1, 0)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.4.1 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -1, 1)"]
+ bin_to_hex [lindex $blob 0]
+} "34"
+do_test func2-3.4.2 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -1, 2)"]
+ bin_to_hex [lindex $blob 0]
+} "34"
+do_test func2-3.4.3 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -1, 3)"]
+ bin_to_hex [lindex $blob 0]
+} "34"
+
+do_test func2-3.5.0 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -2, 0)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.5.1 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -2, 1)"]
+ bin_to_hex [lindex $blob 0]
+} "12"
+do_test func2-3.5.2 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -2, 2)"]
+ bin_to_hex [lindex $blob 0]
+} "1234"
+do_test func2-3.5.3 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -2, 3)"]
+ bin_to_hex [lindex $blob 0]
+} "1234"
+
+do_test func2-3.6.0 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -1, 0)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.6.1 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -1, -1)"]
+ bin_to_hex [lindex $blob 0]
+} "12"
+do_test func2-3.6.2 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -1, -2)"]
+ bin_to_hex [lindex $blob 0]
+} "12"
+do_test func2-3.6.3 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -1, -3)"]
+ bin_to_hex [lindex $blob 0]
+} "12"
+
+do_test func2-3.7.0 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -2, 0)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.7.1 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -2, -1)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.7.2 {
+ set blob [execsql "SELECT SUBSTR(x'1234', -2, -2)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+
+do_test func2-3.8.0 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 1, 0)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.8.1 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 1, -1)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.8.2 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 1, -2)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+
+do_test func2-3.9.0 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 2, 0)"]
+ bin_to_hex [lindex $blob 0]
+} {}
+do_test func2-3.9.1 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 2, -1)"]
+ bin_to_hex [lindex $blob 0]
+} "12"
+do_test func2-3.9.2 {
+ set blob [execsql "SELECT SUBSTR(x'1234', 2, -2)"]
+ bin_to_hex [lindex $blob 0]
+} "12"
+
+finish_test
diff --git a/test/func3.test b/test/func3.test
new file mode 100644
index 0000000..d5a462f
--- /dev/null
+++ b/test/func3.test
@@ -0,0 +1,73 @@
+# 2010 August 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that destructor functions associated
+# with functions created using sqlite3_create_function_v2() is
+# correctly invoked.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+ifcapable utf16 {
+ do_test func3-1.1 {
+ set destroyed 0
+ proc destroy {} { set ::destroyed 1 }
+ sqlite3_create_function_v2 db f2 -1 any -func f2 -destroy destroy
+ set destroyed
+ } 0
+ do_test func3-1.2 {
+ sqlite3_create_function_v2 db f2 -1 utf8 -func f2
+ set destroyed
+ } 0
+ do_test func3-1.3 {
+ sqlite3_create_function_v2 db f2 -1 utf16le -func f2
+ set destroyed
+ } 0
+ do_test func3-1.4 {
+ sqlite3_create_function_v2 db f2 -1 utf16be -func f2
+ set destroyed
+ } 1
+}
+
+do_test func3-2.1 {
+ set destroyed 0
+ proc destroy {} { set ::destroyed 1 }
+ sqlite3_create_function_v2 db f3 -1 utf8 -func f3 -destroy destroy
+ set destroyed
+} 0
+do_test func3-2.2 {
+ sqlite3_create_function_v2 db f3 -1 utf8 -func f3
+ set destroyed
+} 1
+
+do_test func3-3.1 {
+ set destroyed 0
+ proc destroy {} { set ::destroyed 1 }
+ sqlite3_create_function_v2 db f3 -1 any -func f3 -destroy destroy
+ set destroyed
+} 0
+do_test func3-3.2 {
+ db close
+ set destroyed
+} 1
+
+sqlite3 db test.db
+do_test func3-4.1 {
+ set destroyed 0
+ set rc [catch {
+ sqlite3_create_function_v2 db f3 -1 any -func f3 -step f3 -destroy destroy
+ } msg]
+ list $rc $msg
+} {1 SQLITE_MISUSE}
+do_test func3-4.2 { set destroyed } 1
+
+finish_test
diff --git a/test/fuzz.test b/test/fuzz.test
new file mode 100644
index 0000000..e1b22ae
--- /dev/null
+++ b/test/fuzz.test
@@ -0,0 +1,379 @@
+# 2007 May 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is generating semi-random strings of SQL
+# (a.k.a. "fuzz") and sending it into the parser to try to
+# generate errors.
+#
+# The tests in this file are really about testing fuzzily generated
+# SQL parse-trees. The majority of the fuzzily generated SQL is
+# valid as far as the parser is concerned.
+#
+# The most complicated trees are for SELECT statements.
+#
+# $Id: fuzz.test,v 1.19 2009/04/28 11:10:39 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set ::REPEATS 5000
+
+# If running quick.test, don't do so many iterations.
+if {[info exists ::G(isquick)]} {
+ if {$::G(isquick)} { set ::REPEATS 20 }
+}
+
+source $testdir/fuzz_common.tcl
+expr srand(0)
+
+#----------------------------------------------------------------
+# These tests caused errors that were first caught by the tests
+# in this file. They are still here.
+do_test fuzz-1.1 {
+ execsql {
+ SELECT 'abc' LIKE X'ABCD';
+ }
+} {0}
+do_test fuzz-1.2 {
+ execsql {
+ SELECT 'abc' LIKE zeroblob(10);
+ }
+} {0}
+do_test fuzz-1.3 {
+ execsql {
+ SELECT zeroblob(10) LIKE 'abc';
+ }
+} {0}
+do_test fuzz-1.4 {
+ execsql {
+ SELECT (- -21) % NOT (456 LIKE zeroblob(10));
+ }
+} {0}
+do_test fuzz-1.5 {
+ execsql {
+ SELECT (SELECT (
+ SELECT (SELECT -2147483648) FROM (SELECT 1) ORDER BY 1
+ ))
+ }
+} {-2147483648}
+do_test fuzz-1.6 {
+ execsql {
+ SELECT 'abc', zeroblob(1) FROM (SELECT 1) ORDER BY 1
+ }
+} [execsql {SELECT 'abc', zeroblob(1)}]
+
+do_test fuzz-1.7 {
+ execsql {
+ SELECT ( SELECT zeroblob(1000) FROM (
+ SELECT * FROM (SELECT 'first') ORDER BY NOT 'in')
+ )
+ }
+} [execsql {SELECT zeroblob(1000)}]
+
+do_test fuzz-1.8 {
+ # Problems with opcode OP_ToText (did not account for MEM_Zero).
+ # Also MemExpandBlob() was marking expanded blobs as nul-terminated.
+ # They are not.
+ execsql {
+ SELECT CAST(zeroblob(1000) AS text);
+ }
+} {{}}
+
+do_test fuzz-1.9 {
+ # This was causing a NULL pointer dereference of Expr.pList.
+ execsql {
+ SELECT 1 FROM (SELECT * FROM sqlite_master WHERE random())
+ }
+} {}
+
+do_test fuzz-1.10 {
+ # Bug in calculation of Parse.ckOffset causing an assert()
+ # to fail. Probably harmless.
+ execsql {
+ SELECT coalesce(1, substr( 1, 2, length('in' IN (SELECT 1))))
+ }
+} {1}
+
+do_test fuzz-1.11 {
+ # The literals (A, B, C, D) are not important, they are just used
+ # to make the EXPLAIN output easier to read.
+ #
+ # The problem here is that the EXISTS(...) expression leaves an
+ # extra value on the VDBE stack. This is confusing the parent and
+ # leads to an assert() failure when OP_Insert encounters an integer
+ # when it expects a record blob.
+ #
+ # Update: Any query with (LIMIT 0) was leaking stack.
+ #
+ execsql {
+ SELECT 'A' FROM (SELECT 'B') ORDER BY EXISTS (
+ SELECT 'C' FROM (SELECT 'D' LIMIT 0)
+ )
+ }
+} {A}
+
+do_test fuzz-1.12.1 {
+ # Create a table with a single row.
+ execsql {
+ CREATE TABLE abc(b);
+ INSERT INTO abc VALUES('ABCDE');
+ }
+
+ # The following query was crashing. The later subquery (in the FROM)
+ # clause was flattened into the parent, but the code was not repairng
+ # the "b" reference in the other sub-query. When the query was executed,
+ # that "b" refered to a non-existant vdbe table-cursor.
+ #
+ execsql {
+ SELECT 1 IN ( SELECT b UNION SELECT 1 ) FROM (SELECT b FROM abc);
+ }
+} {1}
+do_test fuzz-1.12.2 {
+ # Clean up after the previous query.
+ execsql {
+ DROP TABLE abc;
+ }
+} {}
+
+
+do_test fuzz-1.13 {
+ # The problem here was that when there were more expressions in
+ # the ORDER BY list than the result-set list. The temporary b-tree
+ # used for sorting was being misconfigured in this case.
+ #
+ execsql {
+ SELECT 'abcd' UNION SELECT 'efgh' ORDER BY 1 ASC, 1 ASC;
+ }
+} {abcd efgh}
+
+do_test fuzz-1.14.1 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(123, 456, 789);
+ }
+
+ # The [a] reference in the sub-select was causing a problem. Because
+ # the internal walkSelectExpr() function was not considering compound
+ # SELECT operators.
+ execsql {
+ SELECT 1 FROM abc
+ GROUP BY c HAVING EXISTS (SELECT a UNION SELECT 123);
+ }
+} {1}
+do_test fuzz-1.14.2 {
+ execsql {
+ DROP TABLE abc;
+ }
+} {}
+
+# Making sure previously discovered errors have been fixed.
+#
+do_test fuzz-1.15 {
+ execsql {
+ SELECT hex(CAST(zeroblob(1000) AS integer))
+ }
+} {30}
+
+do_test fuzz-1.16.1 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ CREATE TABLE def(a, b, c);
+ CREATE TABLE ghi(a, b, c);
+ }
+} {}
+do_test fuzz-1.16.2 {
+ catchsql {
+ SELECT DISTINCT EXISTS(
+ SELECT 1
+ FROM (
+ SELECT C FROM (SELECT 1)
+ )
+ WHERE (SELECT c)
+ )
+ FROM abc
+ }
+} {0 {}}
+do_test fuzz-1.16.3 {
+ catchsql {
+ SELECT DISTINCT substr(-456 ISNULL,zeroblob(1000), EXISTS(
+ SELECT DISTINCT EXISTS(
+ SELECT DISTINCT b FROM abc
+ ORDER BY EXISTS (
+ SELECT DISTINCT 2147483647 UNION ALL SELECT -2147483648
+ ) ASC
+ )
+ FROM (
+ SELECT c, c FROM (
+ SELECT 456, 'injection' ORDER BY 56.1 ASC, -56.1 DESC
+ )
+ )
+ GROUP BY (SELECT ALL (SELECT DISTINCT 'hardware'))
+ HAVING (
+ SELECT DISTINCT c
+ FROM (
+ SELECT ALL -2147483648, 'experiments'
+ ORDER BY -56.1 ASC, -56.1 DESC
+ )
+ GROUP BY (SELECT DISTINCT 456) IN
+ (SELECT DISTINCT 'injection') NOT IN (SELECT ALL -456)
+ HAVING EXISTS (
+ SELECT ALL 'injection'
+ )
+ )
+ UNION ALL
+ SELECT a IN (
+ SELECT -2147483647
+ UNION ALL
+ SELECT ALL 'injection'
+ )
+ FROM sqlite_master
+ ) -- end EXISTS
+ ) /* end SUBSTR() */, c NOTNULL ISNULL
+ FROM abc
+ ORDER BY CAST(-56.1 AS blob) ASC
+ }
+} {0 {}}
+do_test fuzz-1.16.4 {
+ execsql {
+ DROP TABLE abc; DROP TABLE def; DROP TABLE ghi;
+ }
+} {}
+
+do_test fuzz-1.17 {
+ catchsql {
+ SELECT 'hardware', 56.1 NOTNULL, random()&0
+ FROM (
+ SELECT ALL lower(~ EXISTS (
+ SELECT 1 NOT IN (SELECT ALL 1)
+ )), CAST(456 AS integer), -2147483647
+ FROM (
+ SELECT DISTINCT -456, CAST(1 AS integer) ISNULL
+ FROM (SELECT ALL 2147483647, typeof(2147483649))
+ )
+ )
+ GROUP BY CAST(CAST('experiments' AS blob) AS blob)
+ HAVING random()
+ }
+} {0 {hardware 1 0}}
+
+do_test fuzz-1.18 {
+ catchsql {
+ SELECT -2147483649 << upper('fault' NOT IN (
+ SELECT ALL (
+ SELECT ALL -1
+ ORDER BY -2147483649
+ LIMIT (
+ SELECT ALL (
+ SELECT 0 EXCEPT SELECT DISTINCT 'experiments' ORDER BY 1 ASC
+ )
+ )
+ OFFSET EXISTS (
+ SELECT ALL
+ (SELECT ALL -2147483648) NOT IN (
+ SELECT ALL 123456789.1234567899
+ ) IN (SELECT 2147483649)
+ FROM sqlite_master
+ ) NOT IN (SELECT ALL 'The')
+ )
+ ))
+ }
+} {0 -4294967298}
+
+# At one point the following INSERT statement caused an assert() to fail.
+#
+do_test fuzz-1.19 {
+ execsql { CREATE TABLE t1(a) }
+ catchsql {
+ INSERT INTO t1 VALUES(
+ CASE WHEN NULL THEN NULL ELSE ( SELECT 0 ORDER BY 456 ) END
+ )
+ }
+} {1 {1st ORDER BY term out of range - should be between 1 and 1}}
+do_test fuzz-1.20 {
+ execsql { DROP TABLE t1 }
+} {}
+
+#----------------------------------------------------------------
+# Test some fuzzily generated expressions.
+#
+do_fuzzy_test fuzz-2 -template { SELECT [Expr] }
+
+do_test fuzz-3.1 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ CREATE TABLE def(a, b, c);
+ CREATE TABLE ghi(a, b, c);
+ }
+} {}
+set ::TableList [list abc def ghi]
+
+#----------------------------------------------------------------
+# Test some fuzzily generated SELECT statements.
+#
+do_fuzzy_test fuzz-3.2 -template {[Select]}
+
+#----------------------------------------------------------------
+# Insert a small amount of data into the database and then run
+# some more generated SELECT statements.
+#
+do_test fuzz-4.1 {
+ execsql {
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(4, 5, 6);
+ INSERT INTO abc VALUES(7, 8, 9);
+ INSERT INTO def VALUES(1, 2, 3);
+ INSERT INTO def VALUES(4, 5, 6);
+ INSERT INTO def VALUES(7, 8, 9);
+ INSERT INTO ghi VALUES(1, 2, 3);
+ INSERT INTO ghi VALUES(4, 5, 6);
+ INSERT INTO ghi VALUES(7, 8, 9);
+ CREATE INDEX abc_i ON abc(a, b, c);
+ CREATE INDEX def_i ON def(c, a, b);
+ CREATE INDEX ghi_i ON ghi(b, c, a);
+ }
+} {}
+do_fuzzy_test fuzz-4.2 -template {[Select]}
+
+#----------------------------------------------------------------
+# Test some fuzzy INSERT statements:
+#
+do_test fuzz-5.1 {execsql BEGIN} {}
+do_fuzzy_test fuzz-5.2 -template {[Insert]} -errorlist table
+integrity_check fuzz-5.2.integrity
+do_test fuzz-5.3 {execsql COMMIT} {}
+integrity_check fuzz-5.4.integrity
+
+#----------------------------------------------------------------
+# Now that there is data in the database, run some more SELECT
+# statements
+#
+set ::ColumnList [list a b c]
+set E {{no such col} {ambiguous column name}}
+do_fuzzy_test fuzz-6.1 -template {[Select]} -errorlist $E
+
+#----------------------------------------------------------------
+# Run some SELECTs, INSERTs, UPDATEs and DELETEs in a transaction.
+#
+set E {{no such col} {ambiguous column name} {table}}
+do_test fuzz-7.1 {execsql BEGIN} {}
+do_fuzzy_test fuzz-7.2 -template {[Statement]} -errorlist $E
+integrity_check fuzz-7.3.integrity
+do_test fuzz-7.4 {execsql COMMIT} {}
+integrity_check fuzz-7.5.integrity
+
+#----------------------------------------------------------------
+# Many CREATE and DROP TABLE statements:
+#
+set E [list table duplicate {no such col} {ambiguous column name} {use DROP}]
+do_fuzzy_test fuzz-8.1 -template {[CreateOrDropTableOrView]} -errorlist $E
+
+close $::log
+finish_test
diff --git a/test/fuzz2.test b/test/fuzz2.test
new file mode 100644
index 0000000..989b00f
--- /dev/null
+++ b/test/fuzz2.test
@@ -0,0 +1,108 @@
+# 2007 May 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file checks error recovery from malformed SQL strings.
+#
+# $Id: fuzz2.test,v 1.3 2007/05/15 16:51:37 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+proc fuzzcatch {sql} {
+ return [lindex [catchsql $sql] 0]
+}
+
+do_test fuzz2-1.1 {
+ fuzzcatch {SELECT ALL "AAAAAA" . * GROUP BY LIMIT round(1), #12}
+} {1}
+do_test fuzz2-2.0 {
+ fuzzcatch {SELECT + #100}
+} {1}
+do_test fuzz2-2.1 {
+ fuzzcatch {SELECT 1 WHERE ( #61 NOT MATCH ROUND( 1 ) )}
+} {1}
+do_test fuzz2-2.2 {
+ fuzzcatch {SELECT 1 LIMIT NOT #59 COLLATE AAAAAA NOT IN
+ ( "AAAAAA" NOTNULL <= x'414141414141' IS NULL , ( ROUND ( 1.0 ) ) )}
+} {1}
+do_test fuzz2-2.3 {
+ fuzzcatch {INSERT OR REPLACE INTO AAAAAA . "AAAAAA" ( "AAAAAA" ) SELECT DISTINCT * , ( SELECT #252 IN ( SELECT DISTINCT AAAAAA . * ) )}
+} {1}
+do_test fuzz2-2.4 {
+ fuzzcatch {SELECT 1 LIMIT NOT #59 COLLATE AAAAAA NOT IN round(1.0)}
+} {1}
+do_test fuzz2-2.5 {
+ fuzzcatch {SELECT( #239 )}
+} {1}
+do_test fuzz2-2.6 {
+ fuzzcatch {DELETE FROM AAAAAA WHERE #65 NOT NULL}
+} {1}
+do_test fuzz2-2.7 {
+ fuzzcatch {ATTACH ROUND( 1.0 ) in AAAAAA . "AAAAAA" AS #122 ISNULL}
+} {1}
+do_test fuzz2-2.8 {
+ fuzzcatch {SELECT 1 LIMIT #122 ISNULL}
+} {1}
+do_test fuzz2-2.9 {
+ fuzzcatch {CREATE VIEW AAAAAA . "AAAAAA" AS SELECT DISTINCT #162 IS NULL "AAAAAA"}
+} {1}
+do_test fuzz2-2.10 {
+ fuzzcatch {DELETE FROM AAAAAA WHERE #202 IS NOT NULL ISNULL}
+} {1}
+do_test fuzz2-2.11 {
+ fuzzcatch {UPDATE OR IGNORE "AAAAAA" . "AAAAAA" SET "AAAAAA" = NOT #96}
+} {1}
+do_test fuzz2-2.12 {
+ fuzzcatch {SELECT - #196}
+} {1}
+
+ifcapable {trigger} { # Only do the following tests if triggers are enabled
+
+do_test fuzz2-3.0 {
+ fuzzcatch {CREATE TRIGGER "AAAAAA" . "AAAAAA" AFTER UPDATE OF "AAAAAA" , "AAAAAA" ON "AAAAAA" . "AAAAAA" FOR EACH ROW BEGIN UPDATE AAAAAA SET "AAAAAA" = #162; END}
+} {1}
+do_test fuzz2-3.1 {
+ fuzzcatch {CREATE TRIGGER IF NOT EXISTS "AAAAAA" UPDATE ON "AAAAAA" . AAAAAA FOR EACH ROW BEGIN DELETE FROM "AAAAAA" ; INSERT INTO AAAAAA ( "AAAAAA" ) SELECT DISTINCT "AAAAAA" "AAAAAA" , #167 AAAAAA , "AAAAAA" . * ORDER BY "AAAAAA" ASC , x'414141414141' BETWEEN RAISE ( FAIL , "AAAAAA" ) AND AAAAAA ( * ) NOT NULL DESC LIMIT AAAAAA ; REPLACE INTO AAAAAA ( AAAAAA ) VALUES ( AAAAAA ( * ) ) ; END}
+} {1}
+do_test fuzz2-3.2 {
+ fuzzcatch {CREATE TEMP TRIGGER IF NOT EXISTS AAAAAA . "AAAAAA" BEFORE UPDATE OF "AAAAAA" ON AAAAAA . "AAAAAA" BEGIN SELECT ALL * , #175 "AAAAAA" FROM "AAAAAA" . AAAAAA; END}
+} {1}
+
+} ;# End of ifcapable {trigger}
+
+do_test fuzz2-4.0 {
+ fuzzcatch {ATTACH DATABASE #168 AS whatever}
+} {1}
+do_test fuzz2-4.1 {
+ fuzzcatch {DETACH #133}
+} {1}
+do_test fuzz2-5.0 {
+ fuzzcatch {SELECT 1 LIMIT ( SELECT DISTINCT * , AAAAAA , * , AAAAAA , "AAAAAA" . * FROM "AAAAAA" ON ROUND( 1 ) COLLATE AAAAAA OR "AAAAAA" USING ( AAAAAA , "AAAAAA" ) WHERE ROUND( 1 ) GROUP BY ORDER BY #84 ASC , #44 DESC , ( SELECT "AAAAAA" . * , "AAAAAA" . * FROM , ( ) "AAAAAA" USING ( )}
+} {1}
+do_test fuzz2-5.1 {
+ fuzzcatch {SELECT 1 WHERE 1 == AAAAAA ( * ) BETWEEN + - ~ + "AAAAAA" . AAAAAA | RAISE ( IGNORE ) COLLATE AAAAAA NOT IN ( SELECT DISTINCT "AAAAAA" . * , * , * WHERE ( SELECT ALL AAAAAA AS "AAAAAA" HAVING CAST ( "AAAAAA" . "AAAAAA" . "AAAAAA" AS AAAAAA ) ORDER BY , , IS NULL ASC , ~ AND DESC LIMIT ( ( "AAAAAA" ) NOT BETWEEN ( ) NOT IN ( ) AND AAAAAA ( ) IS NOT NULL ) OFFSET AAAAAA ( ALL , , ) ) GROUP BY ORDER BY "AAAAAA" . AAAAAA ASC , NULL IN ( SELECT UNION ALL SELECT ALL WHERE HAVING ORDER BY LIMIT UNION SELECT DISTINCT FROM ( ) WHERE + HAVING >> ORDER BY LIMIT . . , "AAAAAA" ) , CAST ( ~ "AAAAAA" . AAAAAA AS "AAAAAA" AAAAAA "AAAAAA" ( + 4294967295 , - 4294967296.0 ) ) ASC LIMIT AAAAAA INTERSECT SELECT ALL * GROUP BY , AAAAAA ( DISTINCT , ) != #241 NOT IN ( , , ) , , CTIME_KW HAVING AAAAAA ORDER BY #103 DESC , #81 ASC LIMIT AAAAAA OFFSET ~ AAAAAA ( ALL AAAAAA . AAAAAA >= AAAAAA . "AAAAAA" . "AAAAAA" ) ) NOTNULL NOT NULL}
+} {1}
+do_test fuzz2-5.2 {
+ fuzzcatch {SELECT 1 WHERE 1 == AAAAAA ( * ) BETWEEN + - ~ + "AAAAAA" . AAAAAA | RAISE ( IGNORE ) COLLATE AAAAAA NOT IN ( SELECT DISTINCT "AAAAAA" . * , * , * WHERE ( SELECT ALL AAAAAA AS "AAAAAA" HAVING CAST ( "AAAAAA" . "AAAAAA" . "AAAAAA" AS AAAAAA ) ORDER BY , , IS NULL ASC , ~ AND DESC LIMIT ( ( "AAAAAA" ) NOT BETWEEN ( ) NOT IN ( ) AND AAAAAA ( ) IS NOT NULL ) OFFSET AAAAAA ( ALL , , ) ) GROUP BY ORDER BY "AAAAAA" . AAAAAA ASC , NULL IN ( SELECT UNION ALL SELECT ALL WHERE HAVING ORDER BY LIMIT UNION SELECT DISTINCT FROM ( ) WHERE + HAVING >> ORDER BY LIMIT . . , "AAAAAA" ) , CAST ( ~ "AAAAAA" . AAAAAA AS "AAAAAA" AAAAAA "AAAAAA" ( + 4294967295 , - 4294967296.0 ) ) ASC LIMIT AAAAAA INTERSECT SELECT ALL * GROUP BY , AAAAAA ( DISTINCT , ) != #241 NOT IN ( , , ) , , CTIME_KW HAVING AAAAAA ORDER BY #103 DESC , #81 ASC LIMIT AAAAAA OFFSET ~ AAAAAA ( ALL AAAAAA . AAAAAA >= AAAAAA . "AAAAAA" . "AAAAAA" ) ) NOTNULL NOT NULL}
+} {1}
+do_test fuzz2-5.3 {
+ fuzzcatch {UPDATE "AAAAAA" SET "AAAAAA" = - EXISTS ( SELECT DISTINCT * , * ORDER BY #202 ASC , #147 , ~ AAAAAA . "AAAAAA" ASC LIMIT AAAAAA . "AAAAAA" , RAISE ( ABORT , AAAAAA ) UNION ALL SELECT DISTINCT AAAAAA . * , * FROM ( SELECT DISTINCT}
+} {1}
+do_test fuzz2-5.4 {
+ fuzzcatch {REPLACE INTO AAAAAA SELECT DISTINCT "AAAAAA" . * WHERE AAAAAA ( AAAAAA ( ) ) GROUP BY AAAAAA . AAAAAA . "AAAAAA" IN "AAAAAA" | AAAAAA ( ALL , ) ORDER BY #238, #92 DESC LIMIT 0 OFFSET - RAISE ( IGNORE ) NOT NULL > RAISE ( IGNORE ) IS NULL}
+} {1}
+do_test fuzz2-5.5 {
+ fuzzcatch {SELECT ALL * GROUP BY EXISTS ( SELECT "AAAAAA" . * , AAAAAA ( * ) AS AAAAAA FROM "AAAAAA" . "AAAAAA" AS "AAAAAA" USING ( AAAAAA , "AAAAAA" , "AAAAAA" ) WHERE AAAAAA ( DISTINCT ) - RAISE ( FAIL , "AAAAAA" ) HAVING "AAAAAA" . "AAAAAA" . AAAAAA ORDER BY #182 , #55 ) BETWEEN EXISTS ( SELECT ALL * FROM ( ( }
+} {1}
+
+finish_test
diff --git a/test/fuzz3.test b/test/fuzz3.test
new file mode 100644
index 0000000..d0efc52
--- /dev/null
+++ b/test/fuzz3.test
@@ -0,0 +1,169 @@
+# 2007 May 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this file is checking the libraries response to subtly corrupting
+# the database file by changing the values of pseudo-randomly selected
+# bytes.
+#
+# $Id: fuzz3.test,v 1.3 2009/01/05 17:19:03 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+expr srand(123)
+
+proc rstring {n} {
+ set str s
+ while {[string length $str] < $n} {
+ append str [expr rand()]
+ }
+ return [string range $str 0 $n]
+}
+
+# Return a randomly generated SQL literal.
+#
+proc rvalue {} {
+ switch -- [expr int(rand()*5)] {
+ 0 { # SQL NULL value.
+ return NULL
+ }
+ 1 { # Integer value.
+ return [expr int(rand()*1024)]
+ }
+ 2 { # Real value.
+ return [expr rand()]
+ }
+ 3 { # String value.
+ set n [expr int(rand()*2500)]
+ return "'[rstring $n]'"
+ }
+ 4 { # Blob value.
+ set n [expr int(rand()*2500)]
+ return "CAST('[rstring $n]' AS BLOB)"
+ }
+ }
+}
+
+proc db_checksum {} {
+ set cksum [execsql { SELECT md5sum(a, b, c) FROM t1 }]
+ append cksum [execsql { SELECT md5sum(d, e, f) FROM t2 }]
+ set cksum
+}
+
+# Modify a single byte in the file 'test.db' using tcl IO commands. The
+# argument value, which must be an integer, determines both the offset of
+# the byte that is modified, and the value that it is set to. The lower
+# 8 bits of iMod determine the new byte value. The offset of the byte
+# modified is the value of ($iMod >> 8).
+#
+# The return value is the iMod value required to restore the file
+# to its original state. The command:
+#
+# modify_database [modify_database $x]
+#
+# leaves the file in the same state as it was in at the start of the
+# command (assuming that the file is at least ($x>>8) bytes in size).
+#
+proc modify_database {iMod} {
+ set blob [binary format c [expr {$iMod&0xFF}]]
+ set offset [expr {$iMod>>8}]
+
+ set fd [open test.db r+]
+ fconfigure $fd -encoding binary -translation binary
+ seek $fd $offset
+ set old_blob [read $fd 1]
+ seek $fd $offset
+ puts -nonewline $fd $blob
+ close $fd
+
+ binary scan $old_blob c iOld
+ return [expr {($offset<<8) + ($iOld&0xFF)}]
+}
+
+proc purge_pcache {} {
+ ifcapable !memorymanage {
+ db close
+ sqlite3 db test.db
+ } else {
+ sqlite3_release_memory 10000000
+ }
+ if {[lindex [pcache_stats] 1] != 0} {
+ error "purge_pcache failed: [pcache_stats]"
+ }
+}
+
+# This block creates a database to work with.
+#
+do_test fuzz3-1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e, f);
+ CREATE INDEX i1 ON t1(a, b, c);
+ CREATE INDEX i2 ON t2(d, e, f);
+ }
+ for {set i 0} {$i < 50} {incr i} {
+ execsql "INSERT INTO t1 VALUES([rvalue], [rvalue], [rvalue])"
+ execsql "INSERT INTO t2 VALUES([rvalue], [rvalue], [rvalue])"
+ }
+ execsql COMMIT
+} {}
+
+set ::cksum [db_checksum]
+do_test fuzz3-2 {
+ db_checksum
+} $::cksum
+
+for {set ii 0} {$ii < 5000} {incr ii} {
+ purge_pcache
+
+ # Randomly modify a single byte of the database file somewhere within
+ # the first 100KB of the file.
+ set iNew [expr int(rand()*5*1024*256)]
+ set iOld [modify_database $iNew]
+
+ set iTest 0
+ foreach sql {
+ {SELECT * FROM t2 ORDER BY d}
+ {SELECT * FROM t1}
+ {SELECT * FROM t2}
+ {SELECT * FROM t1 ORDER BY a}
+ {SELECT * FROM t1 WHERE a = (SELECT a FROM t1 WHERE rowid=25)}
+ {SELECT * FROM t2 WHERE d = (SELECT d FROM t2 WHERE rowid=1)}
+ {SELECT * FROM t2 WHERE d = (SELECT d FROM t2 WHERE rowid=50)}
+ {PRAGMA integrity_check}
+ } {
+ do_test fuzz3-$ii.$iNew.[incr iTest] {
+ foreach {rc msg} [catchsql $sql] {}
+ if {$rc == 0
+ || $msg eq "database or disk is full"
+ || $msg eq "database disk image is malformed"
+ || $msg eq "file is encrypted or is not a database"
+ || [string match "malformed database schema*" $msg]
+ } {
+ set msg ok
+ }
+ set msg
+ } {ok}
+ }
+
+ # Restore the original database file content. Test that the correct
+ # checksum is now returned.
+ #
+ purge_pcache
+ modify_database $iOld
+ do_test fuzz3-$ii.$iNew.[incr iTest] {
+ db_checksum
+ } $::cksum
+}
+
+finish_test
diff --git a/test/fuzz_common.tcl b/test/fuzz_common.tcl
new file mode 100644
index 0000000..4ab7dff
--- /dev/null
+++ b/test/fuzz_common.tcl
@@ -0,0 +1,391 @@
+# 2007 May 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: fuzz_common.tcl,v 1.2 2009/01/05 19:36:30 drh Exp $
+
+proc fuzz {TemplateList} {
+ set n [llength $TemplateList]
+ set i [expr {int(rand()*$n)}]
+ set r [uplevel 1 subst -novar [list [lindex $TemplateList $i]]]
+
+ string map {"\n" " "} $r
+}
+
+# Fuzzy generation primitives:
+#
+# Literal
+# UnaryOp
+# BinaryOp
+# Expr
+# Table
+# Select
+# Insert
+#
+
+# Returns a string representing an SQL literal.
+#
+proc Literal {} {
+ set TemplateList {
+ 456 0 -456 1 -1
+ 2147483648 2147483647 2147483649 -2147483647 -2147483648 -2147483649
+ 'The' 'first' 'experiments' 'in' 'hardware' 'fault' 'injection'
+ zeroblob(1000)
+ NULL
+ 56.1 -56.1
+ 123456789.1234567899
+ }
+ fuzz $TemplateList
+}
+
+# Returns a string containing an SQL unary operator (e.g. "+" or "NOT").
+#
+proc UnaryOp {} {
+ set TemplateList {+ - NOT ~}
+ fuzz $TemplateList
+}
+
+# Returns a string containing an SQL binary operator (e.g. "*" or "/").
+#
+proc BinaryOp {} {
+ set TemplateList {
+ || * / % + - << >> & | < <= > >= = == != <> AND OR
+ LIKE GLOB {NOT LIKE}
+ }
+ fuzz $TemplateList
+}
+
+# Return the complete text of an SQL expression.
+#
+set ::ExprDepth 0
+proc Expr { {c {}} } {
+ incr ::ExprDepth
+
+ set TemplateList [concat $c $c $c {[Literal]}]
+ if {$::ExprDepth < 3} {
+ lappend TemplateList \
+ {[Expr $c] [BinaryOp] [Expr $c]} \
+ {[UnaryOp] [Expr $c]} \
+ {[Expr $c] ISNULL} \
+ {[Expr $c] NOTNULL} \
+ {CAST([Expr $c] AS blob)} \
+ {CAST([Expr $c] AS text)} \
+ {CAST([Expr $c] AS integer)} \
+ {CAST([Expr $c] AS real)} \
+ {abs([Expr])} \
+ {coalesce([Expr], [Expr])} \
+ {hex([Expr])} \
+ {length([Expr])} \
+ {lower([Expr])} \
+ {upper([Expr])} \
+ {quote([Expr])} \
+ {random()} \
+ {randomblob(min(max([Expr],1), 500))} \
+ {typeof([Expr])} \
+ {substr([Expr],[Expr],[Expr])} \
+ {CASE WHEN [Expr $c] THEN [Expr $c] ELSE [Expr $c] END} \
+ {[Literal]} {[Literal]} {[Literal]} \
+ {[Literal]} {[Literal]} {[Literal]} \
+ {[Literal]} {[Literal]} {[Literal]} \
+ {[Literal]} {[Literal]} {[Literal]}
+ }
+ if {$::SelectDepth < 4} {
+ lappend TemplateList \
+ {([Select 1])} \
+ {[Expr $c] IN ([Select 1])} \
+ {[Expr $c] NOT IN ([Select 1])} \
+ {EXISTS ([Select 1])} \
+ }
+ set res [fuzz $TemplateList]
+ incr ::ExprDepth -1
+ return $res
+}
+
+# Return a valid table name.
+#
+set ::TableList [list]
+proc Table {} {
+ set TemplateList [concat sqlite_master $::TableList]
+ fuzz $TemplateList
+}
+
+# Return one of:
+#
+# "SELECT DISTINCT", "SELECT ALL" or "SELECT"
+#
+proc SelectKw {} {
+ set TemplateList {
+ "SELECT DISTINCT"
+ "SELECT ALL"
+ "SELECT"
+ }
+ fuzz $TemplateList
+}
+
+# Return a result set for a SELECT statement.
+#
+proc ResultSet {{nRes 0} {c ""}} {
+ if {$nRes == 0} {
+ set nRes [expr {rand()*2 + 1}]
+ }
+
+ set aRes [list]
+ for {set ii 0} {$ii < $nRes} {incr ii} {
+ lappend aRes [Expr $c]
+ }
+
+ join $aRes ", "
+}
+
+set ::SelectDepth 0
+set ::ColumnList [list]
+proc SimpleSelect {{nRes 0}} {
+
+ set TemplateList {
+ {[SelectKw] [ResultSet $nRes]}
+ }
+
+ # The ::SelectDepth variable contains the number of ancestor SELECT
+ # statements (i.e. for a top level SELECT it is set to 0, for a
+ # sub-select 1, for a sub-select of a sub-select 2 etc.).
+ #
+ # If this is already greater than 3, do not generate a complicated
+ # SELECT statement. This tends to cause parser stack overflow (too
+ # boring to bother with).
+ #
+ if {$::SelectDepth < 4} {
+ lappend TemplateList \
+ {[SelectKw] [ResultSet $nRes $::ColumnList] FROM ([Select])} \
+ {[SelectKw] [ResultSet $nRes] FROM ([Select])} \
+ {[SelectKw] [ResultSet $nRes $::ColumnList] FROM [Table]} \
+ {
+ [SelectKw] [ResultSet $nRes $::ColumnList]
+ FROM ([Select])
+ GROUP BY [Expr]
+ HAVING [Expr]
+ } \
+
+ if {0 == $nRes} {
+ lappend TemplateList \
+ {[SelectKw] * FROM ([Select])} \
+ {[SelectKw] * FROM [Table]} \
+ {[SelectKw] * FROM [Table] WHERE [Expr $::ColumnList]} \
+ {
+ [SelectKw] *
+ FROM [Table],[Table] AS t2
+ WHERE [Expr $::ColumnList]
+ } {
+ [SelectKw] *
+ FROM [Table] LEFT OUTER JOIN [Table] AS t2
+ ON [Expr $::ColumnList]
+ WHERE [Expr $::ColumnList]
+ }
+ }
+ }
+
+ fuzz $TemplateList
+}
+
+# Return a SELECT statement.
+#
+# If boolean parameter $isExpr is set to true, make sure the
+# returned SELECT statement returns a single column of data.
+#
+proc Select {{nMulti 0}} {
+ set TemplateList {
+ {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]}
+ {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]}
+ {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]}
+ {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]}
+ {[SimpleSelect $nMulti] ORDER BY [Expr] DESC}
+ {[SimpleSelect $nMulti] ORDER BY [Expr] ASC}
+ {[SimpleSelect $nMulti] ORDER BY [Expr] ASC, [Expr] DESC}
+ {[SimpleSelect $nMulti] ORDER BY [Expr] LIMIT [Expr] OFFSET [Expr]}
+ }
+
+ if {$::SelectDepth < 4} {
+ if {$nMulti == 0} {
+ set nMulti [expr {(rand()*2)+1}]
+ }
+ lappend TemplateList \
+ {[SimpleSelect $nMulti] UNION [Select $nMulti]} \
+ {[SimpleSelect $nMulti] UNION ALL [Select $nMulti]} \
+ {[SimpleSelect $nMulti] EXCEPT [Select $nMulti]} \
+ {[SimpleSelect $nMulti] INTERSECT [Select $nMulti]}
+ }
+
+ incr ::SelectDepth
+ set res [fuzz $TemplateList]
+ incr ::SelectDepth -1
+ set res
+}
+
+# Generate and return a fuzzy INSERT statement.
+#
+proc Insert {} {
+ set TemplateList {
+ {INSERT INTO [Table] VALUES([Expr], [Expr], [Expr]);}
+ {INSERT INTO [Table] VALUES([Expr], [Expr], [Expr], [Expr]);}
+ {INSERT INTO [Table] VALUES([Expr], [Expr]);}
+ }
+ fuzz $TemplateList
+}
+
+proc Column {} {
+ fuzz $::ColumnList
+}
+
+# Generate and return a fuzzy UPDATE statement.
+#
+proc Update {} {
+ set TemplateList {
+ {UPDATE [Table]
+ SET [Column] = [Expr $::ColumnList]
+ WHERE [Expr $::ColumnList]}
+ }
+ fuzz $TemplateList
+}
+
+proc Delete {} {
+ set TemplateList {
+ {DELETE FROM [Table] WHERE [Expr $::ColumnList]}
+ }
+ fuzz $TemplateList
+}
+
+proc Statement {} {
+ set TemplateList {
+ {[Update]}
+ {[Insert]}
+ {[Select]}
+ {[Delete]}
+ }
+ fuzz $TemplateList
+}
+
+# Return an identifier. This just chooses randomly from a fixed set
+# of strings.
+proc Identifier {} {
+ set TemplateList {
+ This just chooses randomly a fixed
+ We would also thank the developers
+ for their analysis Samba
+ }
+ fuzz $TemplateList
+}
+
+proc Check {} {
+ # Use a large value for $::SelectDepth, because sub-selects are
+ # not allowed in expressions used by CHECK constraints.
+ #
+ set sd $::SelectDepth
+ set ::SelectDepth 500
+ set TemplateList {
+ {}
+ {CHECK ([Expr])}
+ }
+ set res [fuzz $TemplateList]
+ set ::SelectDepth $sd
+ set res
+}
+
+proc Coltype {} {
+ set TemplateList {
+ {INTEGER PRIMARY KEY}
+ {VARCHAR [Check]}
+ {PRIMARY KEY}
+ }
+ fuzz $TemplateList
+}
+
+proc DropTable {} {
+ set TemplateList {
+ {DROP TABLE IF EXISTS [Identifier]}
+ }
+ fuzz $TemplateList
+}
+
+proc CreateView {} {
+ set TemplateList {
+ {CREATE VIEW [Identifier] AS [Select]}
+ }
+ fuzz $TemplateList
+}
+proc DropView {} {
+ set TemplateList {
+ {DROP VIEW IF EXISTS [Identifier]}
+ }
+ fuzz $TemplateList
+}
+
+proc CreateTable {} {
+ set TemplateList {
+ {CREATE TABLE [Identifier]([Identifier] [Coltype], [Identifier] [Coltype])}
+ {CREATE TEMP TABLE [Identifier]([Identifier] [Coltype])}
+ }
+ fuzz $TemplateList
+}
+
+proc CreateOrDropTableOrView {} {
+ set TemplateList {
+ {[CreateTable]}
+ {[DropTable]}
+ {[CreateView]}
+ {[DropView]}
+ }
+ fuzz $TemplateList
+}
+
+########################################################################
+
+set ::log [open fuzzy.log w]
+
+#
+# Usage: do_fuzzy_test <testname> ?<options>?
+#
+# -template
+# -errorlist
+# -repeats
+#
+proc do_fuzzy_test {testname args} {
+ set ::fuzzyopts(-errorlist) [list]
+ set ::fuzzyopts(-repeats) $::REPEATS
+ array set ::fuzzyopts $args
+
+ lappend ::fuzzyopts(-errorlist) {parser stack overflow}
+ lappend ::fuzzyopts(-errorlist) {ORDER BY}
+ lappend ::fuzzyopts(-errorlist) {GROUP BY}
+ lappend ::fuzzyopts(-errorlist) {datatype mismatch}
+
+ for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} {
+ do_test ${testname}.$ii {
+ set ::sql [subst $::fuzzyopts(-template)]
+ puts $::log $::sql
+ flush $::log
+ set rc [catch {execsql $::sql} msg]
+ set e 1
+ if {$rc} {
+ set e 0
+ foreach error $::fuzzyopts(-errorlist) {
+ if {[string first $error $msg]>=0} {
+ set e 1
+ break
+ }
+ }
+ }
+ if {$e == 0} {
+ puts ""
+ puts $::sql
+ puts $msg
+ }
+ set e
+ } {1}
+ }
+}
diff --git a/test/fuzz_malloc.test b/test/fuzz_malloc.test
new file mode 100644
index 0000000..1e31bab
--- /dev/null
+++ b/test/fuzz_malloc.test
@@ -0,0 +1,94 @@
+#
+# 2007 May 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file tests malloc failures in concert with fuzzy SQL generation.
+#
+# $Id: fuzz_malloc.test,v 1.10 2008/08/20 16:35:10 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !memdebug {
+ finish_test
+ return
+}
+
+source $testdir/malloc_common.tcl
+source $testdir/fuzz_common.tcl
+
+if {[info exists G(isquick)]} {
+ set ::REPEATS 20
+} elseif {[info exists G(issoak)]} {
+ set ::REPEATS 100
+} else {
+ set ::REPEATS 40
+}
+
+#
+# Usage: do_fuzzy_malloc_test <testname> ?<options>?
+#
+# -template
+# -sqlprep
+# -repeats
+#
+proc do_fuzzy_malloc_test {testname args} {
+ set ::fuzzyopts(-repeats) $::REPEATS
+ set ::fuzzyopts(-sqlprep) {}
+ array set ::fuzzyopts $args
+
+ sqlite3_memdebug_fail -1
+ db close
+ delete_file test.db test.db-journal
+ sqlite3 db test.db
+ set ::prep $::fuzzyopts(-sqlprep)
+ execsql $::prep
+ set jj 0
+ for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} {
+ expr srand($jj)
+ incr jj
+ set ::sql [subst $::fuzzyopts(-template)]
+ # puts fuzyy-sql=\[$::sql\]; flush stdout
+ foreach {rc res} [catchsql "$::sql"] {}
+ if {$rc==0} {
+ do_malloc_test $testname-$ii -sqlbody $::sql -sqlprep $::prep
+ } else {
+ incr ii -1
+ }
+ }
+}
+
+#----------------------------------------------------------------
+# Test malloc failure during parsing (and execution) of a fuzzily
+# generated expressions.
+#
+do_fuzzy_malloc_test fuzzy_malloc-1 -template {Select [Expr]}
+do_fuzzy_malloc_test fuzzy_malloc-2 -template {[Select]}
+
+set ::SQLPREP {
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ CREATE TABLE def(a, b, c);
+ CREATE TABLE ghi(a, b, c);
+ INSERT INTO abc VALUES(1.5, 3, 'a short string');
+ INSERT INTO def VALUES(NULL, X'ABCDEF',
+ 'a longer string. Long enough that it doesn''t fit in Mem.zShort');
+ INSERT INTO ghi VALUES(zeroblob(1000), 'hello world', -1257900987654321);
+ COMMIT;
+}
+set ::TableList [list abc def ghi]
+set ::ColumnList [list a b c]
+
+do_fuzzy_malloc_test fuzzy_malloc-3 \
+ -template {[Select]} \
+ -sqlprep $::SQLPREP
+
+finish_test
diff --git a/test/fuzzer1.test b/test/fuzzer1.test
new file mode 100644
index 0000000..6c23211
--- /dev/null
+++ b/test/fuzzer1.test
@@ -0,0 +1,1382 @@
+# 2011 March 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for TCL interface to the
+# SQLite library.
+#
+# The focus of the tests is the word-fuzzer virtual table.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_fuzzer_module db
+do_test fuzzer1-1.0 {
+ catchsql {CREATE VIRTUAL TABLE fault1 USING fuzzer;}
+} {1 {fuzzer virtual tables must be TEMP}}
+do_test fuzzer1-1.1 {
+ db eval {CREATE VIRTUAL TABLE temp.f1 USING fuzzer;}
+} {}
+do_test fuzzer1-1.2 {
+ db eval {
+ INSERT INTO f1(cfrom, cto, cost) VALUES('e','a',1);
+ INSERT INTO f1(cfrom, cto, cost) VALUES('a','e',10);
+ INSERT INTO f1(cfrom, cto, cost) VALUES('e','o',100);
+ }
+} {}
+
+do_test fuzzer1-1.3 {
+ db eval {
+ SELECT word, distance FROM f1 WHERE word MATCH 'abcde'
+ }
+} {abcde 0 abcda 1 ebcde 10 ebcda 11 abcdo 100 ebcdo 110 obcde 110 obcda 111 obcdo 210}
+
+do_test fuzzer1-2.0 {
+ execsql {
+ CREATE VIRTUAL TABLE temp.f2 USING fuzzer;
+ -- costs based on English letter frequencies
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('a','e',24);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('a','o',47);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('a','u',50);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('e','a',23);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('e','i',33);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('e','o',37);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('i','e',33);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('i','y',33);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('o','a',41);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('o','e',46);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('o','u',57);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('u','o',58);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('y','i',33);
+
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('t','th',70);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('th','t',66);
+
+
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('a','',84);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','b',106);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('b','',106);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','c',94);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('c','',94);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','d',89);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('d','',89);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','e',83);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('e','',83);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','f',97);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('f','',97);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','g',99);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('g','',99);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','h',86);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('h','',86);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','i',85);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('i','',85);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','j',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('j','',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','k',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('k','',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','l',89);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('l','',89);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','m',96);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('m','',96);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','n',85);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('n','',85);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','o',85);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('o','',85);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','p',100);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('p','',100);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','q',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('q','',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','r',86);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('r','',86);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','s',86);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('s','',86);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','t',84);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('t','',84);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','u',94);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('u','',94);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','v',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('v','',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','w',96);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('w','',96);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','x',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('x','',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','y',100);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('y','',100);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('','z',120);
+ INSERT INTO f2(cFrom,cTo,cost) VALUES('z','',120);
+
+ -- Street names for the 28269 ZIPCODE.
+ --
+ CREATE TEMP TABLE streetname(n TEXT UNIQUE);
+ INSERT INTO streetname VALUES('abbotsinch');
+ INSERT INTO streetname VALUES('abbottsgate');
+ INSERT INTO streetname VALUES('abbywood');
+ INSERT INTO streetname VALUES('abner');
+ INSERT INTO streetname VALUES('acacia ridge');
+ INSERT INTO streetname VALUES('acorn creek');
+ INSERT INTO streetname VALUES('acorn forest');
+ INSERT INTO streetname VALUES('adel');
+ INSERT INTO streetname VALUES('ainslie');
+ INSERT INTO streetname VALUES('airways');
+ INSERT INTO streetname VALUES('alabaster');
+ INSERT INTO streetname VALUES('alba');
+ INSERT INTO streetname VALUES('albertine');
+ INSERT INTO streetname VALUES('alden glen');
+ INSERT INTO streetname VALUES('alderson');
+ INSERT INTO streetname VALUES('allen');
+ INSERT INTO streetname VALUES('allen a brown');
+ INSERT INTO streetname VALUES('allness glen');
+ INSERT INTO streetname VALUES('aloysia');
+ INSERT INTO streetname VALUES('alpine');
+ INSERT INTO streetname VALUES('alwyn');
+ INSERT INTO streetname VALUES('amaranthus');
+ INSERT INTO streetname VALUES('amber glen');
+ INSERT INTO streetname VALUES('amber leigh way');
+ INSERT INTO streetname VALUES('amber meadows');
+ INSERT INTO streetname VALUES('amberway');
+ INSERT INTO streetname VALUES('ame');
+ INSERT INTO streetname VALUES('amesbury hill');
+ INSERT INTO streetname VALUES('anderson');
+ INSERT INTO streetname VALUES('andrew thomas');
+ INSERT INTO streetname VALUES('anduin falls');
+ INSERT INTO streetname VALUES('ankeny');
+ INSERT INTO streetname VALUES('annandale');
+ INSERT INTO streetname VALUES('annbick');
+ INSERT INTO streetname VALUES('antelope');
+ INSERT INTO streetname VALUES('anzack');
+ INSERT INTO streetname VALUES('apple glen');
+ INSERT INTO streetname VALUES('applevalley');
+ INSERT INTO streetname VALUES('appley mead');
+ INSERT INTO streetname VALUES('aragorn');
+ INSERT INTO streetname VALUES('arbor creek');
+ INSERT INTO streetname VALUES('arbor day');
+ INSERT INTO streetname VALUES('arbor meadows');
+ INSERT INTO streetname VALUES('arbor spring');
+ INSERT INTO streetname VALUES('arborview');
+ INSERT INTO streetname VALUES('arklow');
+ INSERT INTO streetname VALUES('armitage');
+ INSERT INTO streetname VALUES('arvin');
+ INSERT INTO streetname VALUES('ash cove');
+ INSERT INTO streetname VALUES('ashford leigh');
+ INSERT INTO streetname VALUES('ashmont');
+ INSERT INTO streetname VALUES('atlas');
+ INSERT INTO streetname VALUES('atwater');
+ INSERT INTO streetname VALUES('auburn hill');
+ INSERT INTO streetname VALUES('aulton link');
+ INSERT INTO streetname VALUES('austin dekota');
+ INSERT INTO streetname VALUES('austin knoll');
+ INSERT INTO streetname VALUES('auten');
+ INSERT INTO streetname VALUES('autumn harvest');
+ INSERT INTO streetname VALUES('autumn oak');
+ INSERT INTO streetname VALUES('autumn ridge');
+ INSERT INTO streetname VALUES('avalon forest');
+ INSERT INTO streetname VALUES('avalon loop');
+ INSERT INTO streetname VALUES('avon farm');
+ INSERT INTO streetname VALUES('avonhurst');
+ INSERT INTO streetname VALUES('avonlea');
+ INSERT INTO streetname VALUES('aynrand');
+ INSERT INTO streetname VALUES('azure valley');
+ INSERT INTO streetname VALUES('baberton');
+ INSERT INTO streetname VALUES('baffin');
+ INSERT INTO streetname VALUES('baggins');
+ INSERT INTO streetname VALUES('balata');
+ INSERT INTO streetname VALUES('ballantray');
+ INSERT INTO streetname VALUES('ballston');
+ INSERT INTO streetname VALUES('balsam tree');
+ INSERT INTO streetname VALUES('bambi');
+ INSERT INTO streetname VALUES('banwell');
+ INSERT INTO streetname VALUES('barbee');
+ INSERT INTO streetname VALUES('barefoot forest');
+ INSERT INTO streetname VALUES('barnview');
+ INSERT INTO streetname VALUES('baroda');
+ INSERT INTO streetname VALUES('barson');
+ INSERT INTO streetname VALUES('baskerville');
+ INSERT INTO streetname VALUES('battle creek');
+ INSERT INTO streetname VALUES('baucom');
+ INSERT INTO streetname VALUES('bay pines');
+ INSERT INTO streetname VALUES('beaker');
+ INSERT INTO streetname VALUES('beard');
+ INSERT INTO streetname VALUES('beardsley');
+ INSERT INTO streetname VALUES('bearoak');
+ INSERT INTO streetname VALUES('beauvista');
+ INSERT INTO streetname VALUES('beaver creek');
+ INSERT INTO streetname VALUES('beaver hollow');
+ INSERT INTO streetname VALUES('bedlington');
+ INSERT INTO streetname VALUES('beech cove');
+ INSERT INTO streetname VALUES('beech crest');
+ INSERT INTO streetname VALUES('beith');
+ INSERT INTO streetname VALUES('bell glen');
+ INSERT INTO streetname VALUES('bellmore');
+ INSERT INTO streetname VALUES('bells mill');
+ INSERT INTO streetname VALUES('bellville');
+ INSERT INTO streetname VALUES('belmar place');
+ INSERT INTO streetname VALUES('bembridge');
+ INSERT INTO streetname VALUES('bennett neely');
+ INSERT INTO streetname VALUES('bentgrass run');
+ INSERT INTO streetname VALUES('benthaven');
+ INSERT INTO streetname VALUES('bernardy');
+ INSERT INTO streetname VALUES('bernbrook shadow');
+ INSERT INTO streetname VALUES('berrybrook');
+ INSERT INTO streetname VALUES('berrybush');
+ INSERT INTO streetname VALUES('berwick');
+ INSERT INTO streetname VALUES('betterton');
+ INSERT INTO streetname VALUES('bickham');
+ INSERT INTO streetname VALUES('billingham');
+ INSERT INTO streetname VALUES('birchcroft');
+ INSERT INTO streetname VALUES('birchstone');
+ INSERT INTO streetname VALUES('birdwell');
+ INSERT INTO streetname VALUES('bisaner');
+ INSERT INTO streetname VALUES('bitterbush');
+ INSERT INTO streetname VALUES('bitterroot');
+ INSERT INTO streetname VALUES('black fox');
+ INSERT INTO streetname VALUES('black maple');
+ INSERT INTO streetname VALUES('black trail');
+ INSERT INTO streetname VALUES('blackbird');
+ INSERT INTO streetname VALUES('blake a dare');
+ INSERT INTO streetname VALUES('blasdell');
+ INSERT INTO streetname VALUES('blue aster');
+ INSERT INTO streetname VALUES('blue finch');
+ INSERT INTO streetname VALUES('blue lilac');
+ INSERT INTO streetname VALUES('blue sky');
+ INSERT INTO streetname VALUES('blue tick');
+ INSERT INTO streetname VALUES('bob beatty');
+ INSERT INTO streetname VALUES('bobcat');
+ INSERT INTO streetname VALUES('bolton');
+ INSERT INTO streetname VALUES('boomerang');
+ INSERT INTO streetname VALUES('boulder');
+ INSERT INTO streetname VALUES('boxer');
+ INSERT INTO streetname VALUES('boxmeer');
+ INSERT INTO streetname VALUES('brachnell view');
+ INSERT INTO streetname VALUES('bradford lake');
+ INSERT INTO streetname VALUES('bradwell');
+ INSERT INTO streetname VALUES('brady');
+ INSERT INTO streetname VALUES('braids bend');
+ INSERT INTO streetname VALUES('bralers');
+ INSERT INTO streetname VALUES('brandie glen');
+ INSERT INTO streetname VALUES('brandy ridge');
+ INSERT INTO streetname VALUES('brandybuck');
+ INSERT INTO streetname VALUES('branthurst');
+ INSERT INTO streetname VALUES('brassy creek');
+ INSERT INTO streetname VALUES('brathay');
+ INSERT INTO streetname VALUES('brawer farm');
+ INSERT INTO streetname VALUES('breezy morn');
+ INSERT INTO streetname VALUES('brenda');
+ INSERT INTO streetname VALUES('brenly');
+ INSERT INTO streetname VALUES('brenock');
+ INSERT INTO streetname VALUES('brianwood');
+ INSERT INTO streetname VALUES('briar rose');
+ INSERT INTO streetname VALUES('briarcrest');
+ INSERT INTO streetname VALUES('briarthorne');
+ INSERT INTO streetname VALUES('brick dust');
+ INSERT INTO streetname VALUES('bridgepath');
+ INSERT INTO streetname VALUES('bridle ridge');
+ INSERT INTO streetname VALUES('briggs');
+ INSERT INTO streetname VALUES('brightleaf');
+ INSERT INTO streetname VALUES('brigstock');
+ INSERT INTO streetname VALUES('broad ridge');
+ INSERT INTO streetname VALUES('brock');
+ INSERT INTO streetname VALUES('brockhampton');
+ INSERT INTO streetname VALUES('broken pine');
+ INSERT INTO streetname VALUES('brompton');
+ INSERT INTO streetname VALUES('brook falls');
+ INSERT INTO streetname VALUES('brookings');
+ INSERT INTO streetname VALUES('browne');
+ INSERT INTO streetname VALUES('brownes creek');
+ INSERT INTO streetname VALUES('brownes ferry');
+ INSERT INTO streetname VALUES('brownestone view');
+ INSERT INTO streetname VALUES('brumit');
+ INSERT INTO streetname VALUES('bryn athyn');
+ INSERT INTO streetname VALUES('buck');
+ INSERT INTO streetname VALUES('bucklebury');
+ INSERT INTO streetname VALUES('buckminister');
+ INSERT INTO streetname VALUES('buckspring');
+ INSERT INTO streetname VALUES('burch');
+ INSERT INTO streetname VALUES('burch shire');
+ INSERT INTO streetname VALUES('burkston');
+ INSERT INTO streetname VALUES('burmith');
+ INSERT INTO streetname VALUES('burnaby');
+ INSERT INTO streetname VALUES('butterfly');
+ INSERT INTO streetname VALUES('cabin creek');
+ INSERT INTO streetname VALUES('cairns mill');
+ INSERT INTO streetname VALUES('callender');
+ INSERT INTO streetname VALUES('cambellton');
+ INSERT INTO streetname VALUES('cambridge bay');
+ INSERT INTO streetname VALUES('canary');
+ INSERT INTO streetname VALUES('canbury');
+ INSERT INTO streetname VALUES('candle leaf');
+ INSERT INTO streetname VALUES('canipe');
+ INSERT INTO streetname VALUES('canipe farm');
+ INSERT INTO streetname VALUES('cannon');
+ INSERT INTO streetname VALUES('canopy');
+ INSERT INTO streetname VALUES('canso');
+ INSERT INTO streetname VALUES('canterbrook');
+ INSERT INTO streetname VALUES('cardinal glen');
+ INSERT INTO streetname VALUES('cardinal point');
+ INSERT INTO streetname VALUES('cardinals nest');
+ INSERT INTO streetname VALUES('carlota');
+ INSERT INTO streetname VALUES('carmathen');
+ INSERT INTO streetname VALUES('carver');
+ INSERT INTO streetname VALUES('carver pond');
+ INSERT INTO streetname VALUES('casa loma');
+ INSERT INTO streetname VALUES('caselton');
+ INSERT INTO streetname VALUES('castello');
+ INSERT INTO streetname VALUES('castle ridge');
+ INSERT INTO streetname VALUES('castleglen');
+ INSERT INTO streetname VALUES('castlemaine');
+ INSERT INTO streetname VALUES('cavett');
+ INSERT INTO streetname VALUES('caymus');
+ INSERT INTO streetname VALUES('cedardale ridge');
+ INSERT INTO streetname VALUES('cedarhurst');
+ INSERT INTO streetname VALUES('cemkey way');
+ INSERT INTO streetname VALUES('cerise');
+ INSERT INTO streetname VALUES('chaceview');
+ INSERT INTO streetname VALUES('chadsworth');
+ INSERT INTO streetname VALUES('chadwell');
+ INSERT INTO streetname VALUES('champions crest');
+ INSERT INTO streetname VALUES('chandler haven');
+ INSERT INTO streetname VALUES('chapel crossing');
+ INSERT INTO streetname VALUES('chapel ridge');
+ INSERT INTO streetname VALUES('charles crawford');
+ INSERT INTO streetname VALUES('charminster');
+ INSERT INTO streetname VALUES('chasewind');
+ INSERT INTO streetname VALUES('chavel');
+ INSERT INTO streetname VALUES('chelsea jade');
+ INSERT INTO streetname VALUES('chestnut knoll');
+ INSERT INTO streetname VALUES('cheviot');
+ INSERT INTO streetname VALUES('chickadee');
+ INSERT INTO streetname VALUES('chidley');
+ INSERT INTO streetname VALUES('chimney ridge');
+ INSERT INTO streetname VALUES('chimney springs');
+ INSERT INTO streetname VALUES('chinaberry');
+ INSERT INTO streetname VALUES('chinemist');
+ INSERT INTO streetname VALUES('chinquapin');
+ INSERT INTO streetname VALUES('chiswell');
+ INSERT INTO streetname VALUES('christenbury');
+ INSERT INTO streetname VALUES('christenbury hills');
+ INSERT INTO streetname VALUES('churchill');
+ INSERT INTO streetname VALUES('cindy');
+ INSERT INTO streetname VALUES('cinnamon teal');
+ INSERT INTO streetname VALUES('citadel');
+ INSERT INTO streetname VALUES('clare olivia');
+ INSERT INTO streetname VALUES('clarke creek');
+ INSERT INTO streetname VALUES('clarke ridge');
+ INSERT INTO streetname VALUES('clear day');
+ INSERT INTO streetname VALUES('clear stream');
+ INSERT INTO streetname VALUES('cleve brown');
+ INSERT INTO streetname VALUES('cliff cameron');
+ INSERT INTO streetname VALUES('cliffvale');
+ INSERT INTO streetname VALUES('cloverside');
+ INSERT INTO streetname VALUES('clymer');
+ INSERT INTO streetname VALUES('coatbridge');
+ INSERT INTO streetname VALUES('cobble glen');
+ INSERT INTO streetname VALUES('cochran farm');
+ INSERT INTO streetname VALUES('cochrane');
+ INSERT INTO streetname VALUES('coleridge');
+ INSERT INTO streetname VALUES('coleshire');
+ INSERT INTO streetname VALUES('collins');
+ INSERT INTO streetname VALUES('colvard');
+ INSERT INTO streetname VALUES('colvard park');
+ INSERT INTO streetname VALUES('condor');
+ INSERT INTO streetname VALUES('conner ridge');
+ INSERT INTO streetname VALUES('connery');
+ INSERT INTO streetname VALUES('cooper run');
+ INSERT INTO streetname VALUES('coopers ridge');
+ INSERT INTO streetname VALUES('copper hill');
+ INSERT INTO streetname VALUES('coppermine');
+ INSERT INTO streetname VALUES('cornelia');
+ INSERT INTO streetname VALUES('corner');
+ INSERT INTO streetname VALUES('cornerstone');
+ INSERT INTO streetname VALUES('cottage oaks');
+ INSERT INTO streetname VALUES('cougar');
+ INSERT INTO streetname VALUES('coves end');
+ INSERT INTO streetname VALUES('cragland');
+ INSERT INTO streetname VALUES('crail');
+ INSERT INTO streetname VALUES('cranberry nook');
+ INSERT INTO streetname VALUES('crawford brook');
+ INSERT INTO streetname VALUES('crayton');
+ INSERT INTO streetname VALUES('creek breeze');
+ INSERT INTO streetname VALUES('crescent ridge');
+ INSERT INTO streetname VALUES('crescent view');
+ INSERT INTO streetname VALUES('cresta');
+ INSERT INTO streetname VALUES('crestfield');
+ INSERT INTO streetname VALUES('crestland');
+ INSERT INTO streetname VALUES('crestwick');
+ INSERT INTO streetname VALUES('crisfield');
+ INSERT INTO streetname VALUES('crisp wood');
+ INSERT INTO streetname VALUES('croft haven');
+ INSERT INTO streetname VALUES('crofton springs');
+ INSERT INTO streetname VALUES('cross');
+ INSERT INTO streetname VALUES('crosspoint center');
+ INSERT INTO streetname VALUES('crownvista');
+ INSERT INTO streetname VALUES('crystal arms');
+ INSERT INTO streetname VALUES('crystal crest');
+ INSERT INTO streetname VALUES('crystal leaf');
+ INSERT INTO streetname VALUES('cunningham park');
+ INSERT INTO streetname VALUES('cypress pond');
+ INSERT INTO streetname VALUES('daffodil');
+ INSERT INTO streetname VALUES('daisyfield');
+ INSERT INTO streetname VALUES('dalecrest');
+ INSERT INTO streetname VALUES('dannelly park');
+ INSERT INTO streetname VALUES('daphne');
+ INSERT INTO streetname VALUES('daria');
+ INSERT INTO streetname VALUES('dartmouth');
+ INSERT INTO streetname VALUES('datha');
+ INSERT INTO streetname VALUES('david cox');
+ INSERT INTO streetname VALUES('davis');
+ INSERT INTO streetname VALUES('davis crossing');
+ INSERT INTO streetname VALUES('davis lake');
+ INSERT INTO streetname VALUES('davis ridge');
+ INSERT INTO streetname VALUES('dawnmist');
+ INSERT INTO streetname VALUES('daybreak');
+ INSERT INTO streetname VALUES('dearmon');
+ INSERT INTO streetname VALUES('dearview');
+ INSERT INTO streetname VALUES('deaton hill');
+ INSERT INTO streetname VALUES('deer cross');
+ INSERT INTO streetname VALUES('deerton');
+ INSERT INTO streetname VALUES('degrasse');
+ INSERT INTO streetname VALUES('delamere');
+ INSERT INTO streetname VALUES('dellfield');
+ INSERT INTO streetname VALUES('dellinger');
+ INSERT INTO streetname VALUES('demington');
+ INSERT INTO streetname VALUES('denmeade');
+ INSERT INTO streetname VALUES('derita');
+ INSERT INTO streetname VALUES('derita woods');
+ INSERT INTO streetname VALUES('deruyter');
+ INSERT INTO streetname VALUES('dervish');
+ INSERT INTO streetname VALUES('devas');
+ INSERT INTO streetname VALUES('devon croft');
+ INSERT INTO streetname VALUES('devonbridge');
+ INSERT INTO streetname VALUES('devongate');
+ INSERT INTO streetname VALUES('devonhill');
+ INSERT INTO streetname VALUES('dewmorn');
+ INSERT INTO streetname VALUES('distribution center');
+ INSERT INTO streetname VALUES('dominion crest');
+ INSERT INTO streetname VALUES('dominion green');
+ INSERT INTO streetname VALUES('dominion village');
+ INSERT INTO streetname VALUES('dorshire');
+ INSERT INTO streetname VALUES('double creek crossing');
+ INSERT INTO streetname VALUES('dow');
+ INSERT INTO streetname VALUES('downfield wood');
+ INSERT INTO streetname VALUES('downing creek');
+ INSERT INTO streetname VALUES('driscol');
+ INSERT INTO streetname VALUES('driwood');
+ INSERT INTO streetname VALUES('dry brook');
+ INSERT INTO streetname VALUES('dumont');
+ INSERT INTO streetname VALUES('dunblane');
+ INSERT INTO streetname VALUES('dunfield');
+ INSERT INTO streetname VALUES('dunoon');
+ INSERT INTO streetname VALUES('dunslow');
+ INSERT INTO streetname VALUES('dunstaff');
+ INSERT INTO streetname VALUES('durham');
+ INSERT INTO streetname VALUES('durston');
+ INSERT INTO streetname VALUES('dusty cedar');
+ INSERT INTO streetname VALUES('dusty trail');
+ INSERT INTO streetname VALUES('dutchess');
+ INSERT INTO streetname VALUES('duxford');
+ INSERT INTO streetname VALUES('eagle creek');
+ INSERT INTO streetname VALUES('eagles field');
+ INSERT INTO streetname VALUES('eargle');
+ INSERT INTO streetname VALUES('earlswood');
+ INSERT INTO streetname VALUES('early mist');
+ INSERT INTO streetname VALUES('earthenware');
+ INSERT INTO streetname VALUES('eastfield park');
+ INSERT INTO streetname VALUES('eastfield village');
+ INSERT INTO streetname VALUES('easy');
+ INSERT INTO streetname VALUES('eben');
+ INSERT INTO streetname VALUES('edgepine');
+ INSERT INTO streetname VALUES('edgewier');
+ INSERT INTO streetname VALUES('edinburgh');
+ INSERT INTO streetname VALUES('edinmeadow');
+ INSERT INTO streetname VALUES('edmonton');
+ INSERT INTO streetname VALUES('edwin jones');
+ INSERT INTO streetname VALUES('elberon');
+ INSERT INTO streetname VALUES('elderslie');
+ INSERT INTO streetname VALUES('elementary view');
+ INSERT INTO streetname VALUES('elendil');
+ INSERT INTO streetname VALUES('elizabeth');
+ INSERT INTO streetname VALUES('elm cove');
+ INSERT INTO streetname VALUES('elrond');
+ INSERT INTO streetname VALUES('elsenham');
+ INSERT INTO streetname VALUES('elven');
+ INSERT INTO streetname VALUES('emma lynn');
+ INSERT INTO streetname VALUES('english setter');
+ INSERT INTO streetname VALUES('enoch');
+ INSERT INTO streetname VALUES('equipment');
+ INSERT INTO streetname VALUES('ernest russell');
+ INSERT INTO streetname VALUES('ernie');
+ INSERT INTO streetname VALUES('esmeralda');
+ INSERT INTO streetname VALUES('evergreen hollow');
+ INSERT INTO streetname VALUES('eversfield');
+ INSERT INTO streetname VALUES('ewen');
+ INSERT INTO streetname VALUES('ewert cut');
+ INSERT INTO streetname VALUES('exbury');
+ INSERT INTO streetname VALUES('fair grounds park');
+ INSERT INTO streetname VALUES('fairbourne');
+ INSERT INTO streetname VALUES('fairchase');
+ INSERT INTO streetname VALUES('faircreek');
+ INSERT INTO streetname VALUES('fairglen');
+ INSERT INTO streetname VALUES('fairlea');
+ INSERT INTO streetname VALUES('fairmead');
+ INSERT INTO streetname VALUES('fairmeadows');
+ INSERT INTO streetname VALUES('fairstone');
+ INSERT INTO streetname VALUES('fairvista');
+ INSERT INTO streetname VALUES('fairway point');
+ INSERT INTO streetname VALUES('falconcrest');
+ INSERT INTO streetname VALUES('falls ridge');
+ INSERT INTO streetname VALUES('falmouth');
+ INSERT INTO streetname VALUES('far west');
+ INSERT INTO streetname VALUES('farlow');
+ INSERT INTO streetname VALUES('farris wheel');
+ INSERT INTO streetname VALUES('fawndale');
+ INSERT INTO streetname VALUES('feather bend');
+ INSERT INTO streetname VALUES('fernledge');
+ INSERT INTO streetname VALUES('fernmoss');
+ INSERT INTO streetname VALUES('ferrell commons');
+ INSERT INTO streetname VALUES('fieldstone');
+ INSERT INTO streetname VALUES('fillian');
+ INSERT INTO streetname VALUES('fincher');
+ INSERT INTO streetname VALUES('foggy meadow');
+ INSERT INTO streetname VALUES('fordyce');
+ INSERT INTO streetname VALUES('forest grove');
+ INSERT INTO streetname VALUES('forest path');
+ INSERT INTO streetname VALUES('forestridge commons');
+ INSERT INTO streetname VALUES('forestrock');
+ INSERT INTO streetname VALUES('fortunes ridge');
+ INSERT INTO streetname VALUES('founders club');
+ INSERT INTO streetname VALUES('fountaingrass');
+ INSERT INTO streetname VALUES('fox chase');
+ INSERT INTO streetname VALUES('fox glen');
+ INSERT INTO streetname VALUES('fox hill');
+ INSERT INTO streetname VALUES('fox point');
+ INSERT INTO streetname VALUES('fox trot');
+ INSERT INTO streetname VALUES('foxbriar');
+ INSERT INTO streetname VALUES('frank little');
+ INSERT INTO streetname VALUES('franzia');
+ INSERT INTO streetname VALUES('french woods');
+ INSERT INTO streetname VALUES('frostmoor');
+ INSERT INTO streetname VALUES('frye');
+ INSERT INTO streetname VALUES('furlong');
+ INSERT INTO streetname VALUES('galena view');
+ INSERT INTO streetname VALUES('gallery pointe');
+ INSERT INTO streetname VALUES('gammon');
+ INSERT INTO streetname VALUES('garden grove');
+ INSERT INTO streetname VALUES('gardendale');
+ INSERT INTO streetname VALUES('garganey');
+ INSERT INTO streetname VALUES('garnet field');
+ INSERT INTO streetname VALUES('garrison');
+ INSERT INTO streetname VALUES('garvin');
+ INSERT INTO streetname VALUES('garvis');
+ INSERT INTO streetname VALUES('gaskill');
+ INSERT INTO streetname VALUES('gemstone');
+ INSERT INTO streetname VALUES('gibbon');
+ INSERT INTO streetname VALUES('gibbon terrace');
+ INSERT INTO streetname VALUES('gibbons link');
+ INSERT INTO streetname VALUES('gillman');
+ INSERT INTO streetname VALUES('gladwood');
+ INSERT INTO streetname VALUES('gladwyne');
+ INSERT INTO streetname VALUES('glamorgan');
+ INSERT INTO streetname VALUES('glaze');
+ INSERT INTO streetname VALUES('glen brook');
+ INSERT INTO streetname VALUES('glen cove');
+ INSERT INTO streetname VALUES('glen hope');
+ INSERT INTO streetname VALUES('glen manor');
+ INSERT INTO streetname VALUES('glen olden');
+ INSERT INTO streetname VALUES('glencairn');
+ INSERT INTO streetname VALUES('glendock');
+ INSERT INTO streetname VALUES('glenolden');
+ INSERT INTO streetname VALUES('glenover');
+ INSERT INTO streetname VALUES('glenshire');
+ INSERT INTO streetname VALUES('glenstone');
+ INSERT INTO streetname VALUES('gold dust');
+ INSERT INTO streetname VALUES('golden pond');
+ INSERT INTO streetname VALUES('goldenblush');
+ INSERT INTO streetname VALUES('goldenfield');
+ INSERT INTO streetname VALUES('goose landing');
+ INSERT INTO streetname VALUES('gorham gate');
+ INSERT INTO streetname VALUES('grabill');
+ INSERT INTO streetname VALUES('graburns ford');
+ INSERT INTO streetname VALUES('graham');
+ INSERT INTO streetname VALUES('grahamson');
+ INSERT INTO streetname VALUES('granard');
+ INSERT INTO streetname VALUES('grand teton');
+ INSERT INTO streetname VALUES('grande heights');
+ INSERT INTO streetname VALUES('grandeur');
+ INSERT INTO streetname VALUES('granite creek');
+ INSERT INTO streetname VALUES('grasset');
+ INSERT INTO streetname VALUES('graypark');
+ INSERT INTO streetname VALUES('grays ridge');
+ INSERT INTO streetname VALUES('great bear');
+ INSERT INTO streetname VALUES('green clover');
+ INSERT INTO streetname VALUES('green hedge');
+ INSERT INTO streetname VALUES('green meadow');
+ INSERT INTO streetname VALUES('green pasture');
+ INSERT INTO streetname VALUES('greene');
+ INSERT INTO streetname VALUES('greenloch');
+ INSERT INTO streetname VALUES('greenock ridge');
+ INSERT INTO streetname VALUES('greenware');
+ INSERT INTO streetname VALUES('greenway village');
+ INSERT INTO streetname VALUES('grenelefe village');
+ INSERT INTO streetname VALUES('grey dogwood');
+ INSERT INTO streetname VALUES('greyhound');
+ INSERT INTO streetname VALUES('greylock ridge');
+ INSERT INTO streetname VALUES('grosbeak');
+ INSERT INTO streetname VALUES('grove');
+ INSERT INTO streetname VALUES('groveton');
+ INSERT INTO streetname VALUES('groveview');
+ INSERT INTO streetname VALUES('hackberry creek');
+ INSERT INTO streetname VALUES('hackberry grove');
+ INSERT INTO streetname VALUES('hackett');
+ INSERT INTO streetname VALUES('haddington');
+ INSERT INTO streetname VALUES('hagler');
+ INSERT INTO streetname VALUES('halcott');
+ INSERT INTO streetname VALUES('half dome');
+ INSERT INTO streetname VALUES('hallam');
+ INSERT INTO streetname VALUES('hamilton russell');
+ INSERT INTO streetname VALUES('hampton place');
+ INSERT INTO streetname VALUES('hankins');
+ INSERT INTO streetname VALUES('harburn forest');
+ INSERT INTO streetname VALUES('harringham');
+ INSERT INTO streetname VALUES('harrington woods');
+ INSERT INTO streetname VALUES('harris corners');
+ INSERT INTO streetname VALUES('harris cove');
+ INSERT INTO streetname VALUES('harris glen');
+ INSERT INTO streetname VALUES('harris hill');
+ INSERT INTO streetname VALUES('harris oak');
+ INSERT INTO streetname VALUES('harris pointe');
+ INSERT INTO streetname VALUES('harris pond');
+ INSERT INTO streetname VALUES('harris ridge');
+ INSERT INTO streetname VALUES('harris technology');
+ INSERT INTO streetname VALUES('harris woods');
+ INSERT INTO streetname VALUES('hartfield downs');
+ INSERT INTO streetname VALUES('hattie little');
+ INSERT INTO streetname VALUES('hatwynn');
+ INSERT INTO streetname VALUES('hawkins');
+ INSERT INTO streetname VALUES('hawksnest');
+ INSERT INTO streetname VALUES('haybridge');
+ INSERT INTO streetname VALUES('hayden');
+ INSERT INTO streetname VALUES('hazelcroft');
+ INSERT INTO streetname VALUES('hazlitt');
+ INSERT INTO streetname VALUES('hazy valley');
+ INSERT INTO streetname VALUES('hearst');
+ INSERT INTO streetname VALUES('heathcrest');
+ INSERT INTO streetname VALUES('heathcroft');
+ INSERT INTO streetname VALUES('hedge maple');
+ INSERT INTO streetname VALUES('hedgecrest');
+ INSERT INTO streetname VALUES('hedingham');
+ INSERT INTO streetname VALUES('heman');
+ INSERT INTO streetname VALUES('henderson');
+ INSERT INTO streetname VALUES('henderson oaks');
+ INSERT INTO streetname VALUES('henderson valley');
+ INSERT INTO streetname VALUES('hendry');
+ INSERT INTO streetname VALUES('heritage hills');
+ INSERT INTO streetname VALUES('heritage woods');
+ INSERT INTO streetname VALUES('heron cove');
+ INSERT INTO streetname VALUES('heron glen');
+ INSERT INTO streetname VALUES('hewitt');
+ INSERT INTO streetname VALUES('hey rock');
+ INSERT INTO streetname VALUES('heysham');
+ INSERT INTO streetname VALUES('hickory cove');
+ INSERT INTO streetname VALUES('hidden meadow');
+ INSERT INTO streetname VALUES('high glen');
+ INSERT INTO streetname VALUES('high laurel');
+ INSERT INTO streetname VALUES('high valley');
+ INSERT INTO streetname VALUES('highcroft');
+ INSERT INTO streetname VALUES('highland');
+ INSERT INTO streetname VALUES('highland commons');
+ INSERT INTO streetname VALUES('highland creek');
+ INSERT INTO streetname VALUES('highland glen');
+ INSERT INTO streetname VALUES('highland park');
+ INSERT INTO streetname VALUES('highlander');
+ INSERT INTO streetname VALUES('highstream');
+ INSERT INTO streetname VALUES('hilltop');
+ INSERT INTO streetname VALUES('hobbitshire');
+ INSERT INTO streetname VALUES('hoffman');
+ INSERT INTO streetname VALUES('hogans way');
+ INSERT INTO streetname VALUES('holbert');
+ INSERT INTO streetname VALUES('hollow ridge');
+ INSERT INTO streetname VALUES('holly vista');
+ INSERT INTO streetname VALUES('hollywood');
+ INSERT INTO streetname VALUES('hoover');
+ INSERT INTO streetname VALUES('hopkins');
+ INSERT INTO streetname VALUES('horace mann');
+ INSERT INTO streetname VALUES('hornbeam');
+ INSERT INTO streetname VALUES('horse pasture');
+ INSERT INTO streetname VALUES('hosta');
+ INSERT INTO streetname VALUES('howard');
+ INSERT INTO streetname VALUES('hubbard');
+ INSERT INTO streetname VALUES('hubbard falls');
+ INSERT INTO streetname VALUES('hubbard woods');
+ INSERT INTO streetname VALUES('hucks');
+ INSERT INTO streetname VALUES('hunters creek');
+ INSERT INTO streetname VALUES('hunters pointe');
+ INSERT INTO streetname VALUES('hunters spring');
+ INSERT INTO streetname VALUES('hunters whip');
+ INSERT INTO streetname VALUES('huntmeadow');
+ INSERT INTO streetname VALUES('hutchison mcdonald');
+ INSERT INTO streetname VALUES('ingleton');
+ INSERT INTO streetname VALUES('insdale');
+ INSERT INTO streetname VALUES('interstate 85 service');
+ INSERT INTO streetname VALUES('iola');
+ INSERT INTO streetname VALUES('iredell');
+ INSERT INTO streetname VALUES('iron brigade');
+ INSERT INTO streetname VALUES('irwin valley');
+ INSERT INTO streetname VALUES('irwin wood');
+ INSERT INTO streetname VALUES('ivy brook');
+ INSERT INTO streetname VALUES('ivy ridge');
+ INSERT INTO streetname VALUES('jack russell');
+ INSERT INTO streetname VALUES('jackson');
+ INSERT INTO streetname VALUES('jacob martin');
+ INSERT INTO streetname VALUES('jamison');
+ INSERT INTO streetname VALUES('jane');
+ INSERT INTO streetname VALUES('jaspar crest');
+ INSERT INTO streetname VALUES('jessica');
+ INSERT INTO streetname VALUES('jimmy oehler');
+ INSERT INTO streetname VALUES('jocelyn');
+ INSERT INTO streetname VALUES('johnston mill');
+ INSERT INTO streetname VALUES('johnston oehler');
+ INSERT INTO streetname VALUES('judal');
+ INSERT INTO streetname VALUES('junipeous');
+ INSERT INTO streetname VALUES('juniper');
+ INSERT INTO streetname VALUES('juniperus');
+ INSERT INTO streetname VALUES('kalispell');
+ INSERT INTO streetname VALUES('karylsturn');
+ INSERT INTO streetname VALUES('katelyn');
+ INSERT INTO streetname VALUES('kayron');
+ INSERT INTO streetname VALUES('keaton');
+ INSERT INTO streetname VALUES('keble');
+ INSERT INTO streetname VALUES('keels');
+ INSERT INTO streetname VALUES('keith');
+ INSERT INTO streetname VALUES('keithwood');
+ INSERT INTO streetname VALUES('kelden walker');
+ INSERT INTO streetname VALUES('kelsey emma');
+ INSERT INTO streetname VALUES('kendrick');
+ INSERT INTO streetname VALUES('kenmont');
+ INSERT INTO streetname VALUES('kennerly cove');
+ INSERT INTO streetname VALUES('kenninghall');
+ INSERT INTO streetname VALUES('kent village');
+ INSERT INTO streetname VALUES('kestral ridge');
+ INSERT INTO streetname VALUES('kestrel');
+ INSERT INTO streetname VALUES('kilmartin');
+ INSERT INTO streetname VALUES('kilty');
+ INSERT INTO streetname VALUES('kinglet');
+ INSERT INTO streetname VALUES('kingsland');
+ INSERT INTO streetname VALUES('kingsnorth');
+ INSERT INTO streetname VALUES('kinsmore');
+ INSERT INTO streetname VALUES('kirkgard');
+ INSERT INTO streetname VALUES('kirkmont');
+ INSERT INTO streetname VALUES('knightsgate');
+ INSERT INTO streetname VALUES('kobuk');
+ INSERT INTO streetname VALUES('kotlik');
+ INSERT INTO streetname VALUES('kotz');
+ INSERT INTO streetname VALUES('kyndall walk');
+ INSERT INTO streetname VALUES('laborde');
+ INSERT INTO streetname VALUES('lady bank');
+ INSERT INTO streetname VALUES('lagrande');
+ INSERT INTO streetname VALUES('lake');
+ INSERT INTO streetname VALUES('lakeridge commons');
+ INSERT INTO streetname VALUES('lakeview');
+ INSERT INTO streetname VALUES('lakewood edge');
+ INSERT INTO streetname VALUES('lakota');
+ INSERT INTO streetname VALUES('lambrook');
+ INSERT INTO streetname VALUES('lampkin');
+ INSERT INTO streetname VALUES('lampkin park');
+ INSERT INTO streetname VALUES('langham');
+ INSERT INTO streetname VALUES('lanzerac manor');
+ INSERT INTO streetname VALUES('larkmead forest');
+ INSERT INTO streetname VALUES('lattice');
+ INSERT INTO streetname VALUES('laurel crest');
+ INSERT INTO streetname VALUES('laurel ridge');
+ INSERT INTO streetname VALUES('laurel run');
+ INSERT INTO streetname VALUES('laurenfield');
+ INSERT INTO streetname VALUES('laveta');
+ INSERT INTO streetname VALUES('lazy day');
+ INSERT INTO streetname VALUES('leawood run');
+ INSERT INTO streetname VALUES('lee marie');
+ INSERT INTO streetname VALUES('legacy lake');
+ INSERT INTO streetname VALUES('legacy park');
+ INSERT INTO streetname VALUES('legato');
+ INSERT INTO streetname VALUES('legolas');
+ INSERT INTO streetname VALUES('leigh glen');
+ INSERT INTO streetname VALUES('lence');
+ INSERT INTO streetname VALUES('lenox hill');
+ INSERT INTO streetname VALUES('leonine');
+ INSERT INTO streetname VALUES('leslie');
+ INSERT INTO streetname VALUES('lester hill');
+ INSERT INTO streetname VALUES('levisey');
+ INSERT INTO streetname VALUES('liberty bell');
+ INSERT INTO streetname VALUES('linden berry');
+ INSERT INTO streetname VALUES('lisbon');
+ INSERT INTO streetname VALUES('little stoney');
+ INSERT INTO streetname VALUES('livengood');
+ INSERT INTO streetname VALUES('lochway');
+ INSERT INTO streetname VALUES('lockman');
+ INSERT INTO streetname VALUES('loganville');
+ INSERT INTO streetname VALUES('lone tree');
+ INSERT INTO streetname VALUES('long creek park');
+ INSERT INTO streetname VALUES('long forest');
+ INSERT INTO streetname VALUES('looking glass');
+ INSERT INTO streetname VALUES('lookout point');
+ INSERT INTO streetname VALUES('lowen');
+ INSERT INTO streetname VALUES('lusby');
+ INSERT INTO streetname VALUES('lyleton');
+ INSERT INTO streetname VALUES('lynn lee');
+ INSERT INTO streetname VALUES('lynnewood glen');
+ INSERT INTO streetname VALUES('machrie');
+ INSERT INTO streetname VALUES('mackinac');
+ INSERT INTO streetname VALUES('maddox');
+ INSERT INTO streetname VALUES('madison park');
+ INSERT INTO streetname VALUES('mallard');
+ INSERT INTO streetname VALUES('mallard cove');
+ INSERT INTO streetname VALUES('mallard forest');
+ INSERT INTO streetname VALUES('mallard grove');
+ INSERT INTO streetname VALUES('mallard hill');
+ INSERT INTO streetname VALUES('mallard park');
+ INSERT INTO streetname VALUES('mallard ridge');
+ INSERT INTO streetname VALUES('mallard view');
+ INSERT INTO streetname VALUES('manbey');
+ INSERT INTO streetname VALUES('manning');
+ INSERT INTO streetname VALUES('mantario');
+ INSERT INTO streetname VALUES('maple');
+ INSERT INTO streetname VALUES('maple cove');
+ INSERT INTO streetname VALUES('maple park');
+ INSERT INTO streetname VALUES('marathon hill');
+ INSERT INTO streetname VALUES('marbury');
+ INSERT INTO streetname VALUES('marett');
+ INSERT INTO streetname VALUES('marigold');
+ INSERT INTO streetname VALUES('marionwood');
+ INSERT INTO streetname VALUES('marshbank');
+ INSERT INTO streetname VALUES('mason');
+ INSERT INTO streetname VALUES('mayapple');
+ INSERT INTO streetname VALUES('maylandia');
+ INSERT INTO streetname VALUES('mayspring');
+ INSERT INTO streetname VALUES('mcadam');
+ INSERT INTO streetname VALUES('mcchesney');
+ INSERT INTO streetname VALUES('mccurdy');
+ INSERT INTO streetname VALUES('mcgrath');
+ INSERT INTO streetname VALUES('mckendree');
+ INSERT INTO streetname VALUES('mclaughlin');
+ INSERT INTO streetname VALUES('mctaggart');
+ INSERT INTO streetname VALUES('meadow green');
+ INSERT INTO streetname VALUES('meadow knoll');
+ INSERT INTO streetname VALUES('meadow post');
+ INSERT INTO streetname VALUES('meadowmont');
+ INSERT INTO streetname VALUES('meadowmont view');
+ INSERT INTO streetname VALUES('meadowview hills');
+ INSERT INTO streetname VALUES('melshire');
+ INSERT INTO streetname VALUES('melstrand');
+ INSERT INTO streetname VALUES('mentone');
+ INSERT INTO streetname VALUES('meridale crossing');
+ INSERT INTO streetname VALUES('merion hills');
+ INSERT INTO streetname VALUES('merlot');
+ INSERT INTO streetname VALUES('mersham');
+ INSERT INTO streetname VALUES('metromont');
+ INSERT INTO streetname VALUES('metromont industrial');
+ INSERT INTO streetname VALUES('michaw');
+ INSERT INTO streetname VALUES('milhaven');
+ INSERT INTO streetname VALUES('milhof');
+ INSERT INTO streetname VALUES('millstream ridge');
+ INSERT INTO streetname VALUES('mineral ridge');
+ INSERT INTO streetname VALUES('mint thistle');
+ INSERT INTO streetname VALUES('mintleaf');
+ INSERT INTO streetname VALUES('mintvale');
+ INSERT INTO streetname VALUES('misty');
+ INSERT INTO streetname VALUES('misty arbor');
+ INSERT INTO streetname VALUES('misty creek');
+ INSERT INTO streetname VALUES('misty oaks');
+ INSERT INTO streetname VALUES('misty wood');
+ INSERT INTO streetname VALUES('mitzi deborah');
+ INSERT INTO streetname VALUES('mobile');
+ INSERT INTO streetname VALUES('molly elizabeth');
+ INSERT INTO streetname VALUES('monmouth');
+ INSERT INTO streetname VALUES('montrose');
+ INSERT INTO streetname VALUES('moonlight');
+ INSERT INTO streetname VALUES('moose');
+ INSERT INTO streetname VALUES('morning dew');
+ INSERT INTO streetname VALUES('morningsong');
+ INSERT INTO streetname VALUES('morningview');
+ INSERT INTO streetname VALUES('morsey');
+ INSERT INTO streetname VALUES('moss glen');
+ INSERT INTO streetname VALUES('mossy bank');
+ INSERT INTO streetname VALUES('motor sport');
+ INSERT INTO streetname VALUES('mountain laurel');
+ INSERT INTO streetname VALUES('mourning dove');
+ INSERT INTO streetname VALUES('mozart');
+ INSERT INTO streetname VALUES('munsing');
+ INSERT INTO streetname VALUES('murray');
+ INSERT INTO streetname VALUES('nathan');
+ INSERT INTO streetname VALUES('netherhall');
+ INSERT INTO streetname VALUES('netherton');
+ INSERT INTO streetname VALUES('neuhoff');
+ INSERT INTO streetname VALUES('nevin');
+ INSERT INTO streetname VALUES('nevin brook');
+ INSERT INTO streetname VALUES('nevin glen');
+ INSERT INTO streetname VALUES('nevin place');
+ INSERT INTO streetname VALUES('new england');
+ INSERT INTO streetname VALUES('new house');
+ INSERT INTO streetname VALUES('newbary');
+ INSERT INTO streetname VALUES('newchurch');
+ INSERT INTO streetname VALUES('newfane');
+ INSERT INTO streetname VALUES('newgard');
+ INSERT INTO streetname VALUES('nicholas');
+ INSERT INTO streetname VALUES('nicole');
+ INSERT INTO streetname VALUES('nobility');
+ INSERT INTO streetname VALUES('norcroft');
+ INSERT INTO streetname VALUES('northridge');
+ INSERT INTO streetname VALUES('northside');
+ INSERT INTO streetname VALUES('northwoods business');
+ INSERT INTO streetname VALUES('norway');
+ INSERT INTO streetname VALUES('nottinghill');
+ INSERT INTO streetname VALUES('numenore');
+ INSERT INTO streetname VALUES('nyewood');
+ INSERT INTO streetname VALUES('oak');
+ INSERT INTO streetname VALUES('oak cove');
+ INSERT INTO streetname VALUES('oak pasture');
+ INSERT INTO streetname VALUES('oakburn');
+ INSERT INTO streetname VALUES('oakwinds');
+ INSERT INTO streetname VALUES('oakwood');
+ INSERT INTO streetname VALUES('obrien');
+ INSERT INTO streetname VALUES('ocala');
+ INSERT INTO streetname VALUES('old bridge');
+ INSERT INTO streetname VALUES('old fox');
+ INSERT INTO streetname VALUES('old potters');
+ INSERT INTO streetname VALUES('old statesville');
+ INSERT INTO streetname VALUES('old steine');
+ INSERT INTO streetname VALUES('old stoney creek');
+ INSERT INTO streetname VALUES('old sugar creek');
+ INSERT INTO streetname VALUES('old timber');
+ INSERT INTO streetname VALUES('old wagon');
+ INSERT INTO streetname VALUES('old willow');
+ INSERT INTO streetname VALUES('oldenway');
+ INSERT INTO streetname VALUES('oneida');
+ INSERT INTO streetname VALUES('ontario');
+ INSERT INTO streetname VALUES('oriole');
+ INSERT INTO streetname VALUES('orofino');
+ INSERT INTO streetname VALUES('orr');
+ INSERT INTO streetname VALUES('osage');
+ INSERT INTO streetname VALUES('osceola');
+ INSERT INTO streetname VALUES('osprey knoll');
+ INSERT INTO streetname VALUES('oxford hill');
+ INSERT INTO streetname VALUES('painted fern');
+ INSERT INTO streetname VALUES('painted pony');
+ INSERT INTO streetname VALUES('paisley');
+ INSERT INTO streetname VALUES('pale moss');
+ INSERT INTO streetname VALUES('palladium');
+ INSERT INTO streetname VALUES('palmutum');
+ INSERT INTO streetname VALUES('palustris');
+ INSERT INTO streetname VALUES('panglemont');
+ INSERT INTO streetname VALUES('panther');
+ INSERT INTO streetname VALUES('panthersville');
+ INSERT INTO streetname VALUES('paper whites');
+ INSERT INTO streetname VALUES('park');
+ INSERT INTO streetname VALUES('parker green');
+ INSERT INTO streetname VALUES('parkhouse');
+ INSERT INTO streetname VALUES('passour ridge');
+ INSERT INTO streetname VALUES('pasture view');
+ INSERT INTO streetname VALUES('patricia ann');
+ INSERT INTO streetname VALUES('patton');
+ INSERT INTO streetname VALUES('patton ridge');
+ INSERT INTO streetname VALUES('pawpaw');
+ INSERT INTO streetname VALUES('peach');
+ INSERT INTO streetname VALUES('peakwood');
+ INSERT INTO streetname VALUES('pebble creek');
+ INSERT INTO streetname VALUES('pecan cove');
+ INSERT INTO streetname VALUES('pedigree');
+ INSERT INTO streetname VALUES('pelorus');
+ INSERT INTO streetname VALUES('penmore');
+ INSERT INTO streetname VALUES('pensfold');
+ INSERT INTO streetname VALUES('pepperstone');
+ INSERT INTO streetname VALUES('peregrine');
+ INSERT INTO streetname VALUES('periwinkle');
+ INSERT INTO streetname VALUES('perkins');
+ INSERT INTO streetname VALUES('pete brown');
+ INSERT INTO streetname VALUES('phillips');
+ INSERT INTO streetname VALUES('pickway');
+ INSERT INTO streetname VALUES('piercy woods');
+ INSERT INTO streetname VALUES('pierpoint');
+ INSERT INTO streetname VALUES('pine');
+ INSERT INTO streetname VALUES('pine branch');
+ INSERT INTO streetname VALUES('pine meadow');
+ INSERT INTO streetname VALUES('pineleaf');
+ INSERT INTO streetname VALUES('pinewood');
+ INSERT INTO streetname VALUES('pintail');
+ INSERT INTO streetname VALUES('pipestone');
+ INSERT INTO streetname VALUES('placer maple');
+ INSERT INTO streetname VALUES('plover');
+ INSERT INTO streetname VALUES('plum');
+ INSERT INTO streetname VALUES('po box');
+ INSERT INTO streetname VALUES('pochard');
+ INSERT INTO streetname VALUES('pointview');
+ INSERT INTO streetname VALUES('polk and white');
+ INSERT INTO streetname VALUES('pond valley');
+ INSERT INTO streetname VALUES('pondridge');
+ INSERT INTO streetname VALUES('pope farm');
+ INSERT INTO streetname VALUES('poplar grove');
+ INSERT INTO streetname VALUES('poplar springs');
+ INSERT INTO streetname VALUES('portola');
+ INSERT INTO streetname VALUES('potters glen');
+ INSERT INTO streetname VALUES('powatan');
+ INSERT INTO streetname VALUES('prairie valley');
+ INSERT INTO streetname VALUES('prescott');
+ INSERT INTO streetname VALUES('presmann');
+ INSERT INTO streetname VALUES('prestigious');
+ INSERT INTO streetname VALUES('princess');
+ INSERT INTO streetname VALUES('prosperity');
+ INSERT INTO streetname VALUES('prosperity church');
+ INSERT INTO streetname VALUES('prosperity commons');
+ INSERT INTO streetname VALUES('prosperity park');
+ INSERT INTO streetname VALUES('prosperity point');
+ INSERT INTO streetname VALUES('prosperity ridge');
+ INSERT INTO streetname VALUES('prosperity view');
+ INSERT INTO streetname VALUES('purple finch');
+ INSERT INTO streetname VALUES('quail');
+ INSERT INTO streetname VALUES('queensbury');
+ INSERT INTO streetname VALUES('quinn');
+ INSERT INTO streetname VALUES('racine');
+ INSERT INTO streetname VALUES('radbourne');
+ INSERT INTO streetname VALUES('raddington');
+ INSERT INTO streetname VALUES('raku');
+ INSERT INTO streetname VALUES('rancliffe');
+ INSERT INTO streetname VALUES('ravencrest');
+ INSERT INTO streetname VALUES('reames');
+ INSERT INTO streetname VALUES('rebecca run');
+ INSERT INTO streetname VALUES('red bluff');
+ INSERT INTO streetname VALUES('red clay');
+ INSERT INTO streetname VALUES('red clover');
+ INSERT INTO streetname VALUES('red rose');
+ INSERT INTO streetname VALUES('red shed');
+ INSERT INTO streetname VALUES('red tail');
+ INSERT INTO streetname VALUES('redbridge');
+ INSERT INTO streetname VALUES('redstart');
+ INSERT INTO streetname VALUES('redstone view');
+ INSERT INTO streetname VALUES('reedmont');
+ INSERT INTO streetname VALUES('reeves');
+ INSERT INTO streetname VALUES('regal');
+ INSERT INTO streetname VALUES('reinbeck');
+ INSERT INTO streetname VALUES('retriever');
+ INSERT INTO streetname VALUES('ribbonwalk');
+ INSERT INTO streetname VALUES('richardson park');
+ INSERT INTO streetname VALUES('richfield');
+ INSERT INTO streetname VALUES('riddings');
+ INSERT INTO streetname VALUES('ridge');
+ INSERT INTO streetname VALUES('ridge cliff');
+ INSERT INTO streetname VALUES('ridge path');
+ INSERT INTO streetname VALUES('ridge peak');
+ INSERT INTO streetname VALUES('ridgefield');
+ INSERT INTO streetname VALUES('ridgeline');
+ INSERT INTO streetname VALUES('ridgeview commons');
+ INSERT INTO streetname VALUES('riley');
+ INSERT INTO streetname VALUES('riley woods');
+ INSERT INTO streetname VALUES('rillet');
+ INSERT INTO streetname VALUES('rindle');
+ INSERT INTO streetname VALUES('rivendell');
+ INSERT INTO streetname VALUES('robin');
+ INSERT INTO streetname VALUES('robins nest');
+ INSERT INTO streetname VALUES('robur');
+ INSERT INTO streetname VALUES('robyns glen');
+ INSERT INTO streetname VALUES('rock stream');
+ INSERT INTO streetname VALUES('rockwell');
+ INSERT INTO streetname VALUES('rockwell church');
+ INSERT INTO streetname VALUES('rocky brook');
+ INSERT INTO streetname VALUES('rocky ford club');
+ INSERT INTO streetname VALUES('rotary');
+ INSERT INTO streetname VALUES('rouda');
+ INSERT INTO streetname VALUES('royal bluff');
+ INSERT INTO streetname VALUES('royal celadon');
+ INSERT INTO streetname VALUES('rubin lura');
+ INSERT INTO streetname VALUES('runswyck');
+ INSERT INTO streetname VALUES('ruth ferrell');
+ INSERT INTO streetname VALUES('ruth polk');
+ INSERT INTO streetname VALUES('ryan jay');
+ INSERT INTO streetname VALUES('sackett');
+ INSERT INTO streetname VALUES('saddle pace');
+ INSERT INTO streetname VALUES('saddle run');
+ INSERT INTO streetname VALUES('saddle trail');
+ INSERT INTO streetname VALUES('saguaro');
+ INSERT INTO streetname VALUES('saint audrey');
+ INSERT INTO streetname VALUES('saint bernard');
+ INSERT INTO streetname VALUES('saint frances');
+ INSERT INTO streetname VALUES('sam roper');
+ INSERT INTO streetname VALUES('samara');
+ INSERT INTO streetname VALUES('sanders creek');
+ INSERT INTO streetname VALUES('saquache');
+ INSERT INTO streetname VALUES('sarnia');
+ INSERT INTO streetname VALUES('savannah springs');
+ INSERT INTO streetname VALUES('sawgrass ridge');
+ INSERT INTO streetname VALUES('saxonbury');
+ INSERT INTO streetname VALUES('scotch moss');
+ INSERT INTO streetname VALUES('seasons');
+ INSERT INTO streetname VALUES('serenity');
+ INSERT INTO streetname VALUES('seths');
+ INSERT INTO streetname VALUES('shadow lawn');
+ INSERT INTO streetname VALUES('shadow oaks');
+ INSERT INTO streetname VALUES('shadow pine');
+ INSERT INTO streetname VALUES('shadyside');
+ INSERT INTO streetname VALUES('shallow oak');
+ INSERT INTO streetname VALUES('shelley');
+ INSERT INTO streetname VALUES('shining oak');
+ INSERT INTO streetname VALUES('ship');
+ INSERT INTO streetname VALUES('shore haven');
+ INSERT INTO streetname VALUES('shuman');
+ INSERT INTO streetname VALUES('sidney');
+ INSERT INTO streetname VALUES('silver birch');
+ INSERT INTO streetname VALUES('silvermere');
+ INSERT INTO streetname VALUES('simonton');
+ INSERT INTO streetname VALUES('singing hills');
+ INSERT INTO streetname VALUES('singing oak');
+ INSERT INTO streetname VALUES('sipes');
+ INSERT INTO streetname VALUES('six point');
+ INSERT INTO streetname VALUES('skycrest');
+ INSERT INTO streetname VALUES('skyline');
+ INSERT INTO streetname VALUES('small');
+ INSERT INTO streetname VALUES('smith corners');
+ INSERT INTO streetname VALUES('smithwood');
+ INSERT INTO streetname VALUES('snow hill');
+ INSERT INTO streetname VALUES('soapstone');
+ INSERT INTO streetname VALUES('sobeck');
+ INSERT INTO streetname VALUES('socata');
+ INSERT INTO streetname VALUES('solace');
+ INSERT INTO streetname VALUES('solway');
+ INSERT INTO streetname VALUES('song sparrow');
+ INSERT INTO streetname VALUES('sorrento');
+ INSERT INTO streetname VALUES('spector');
+ INSERT INTO streetname VALUES('spin drift');
+ INSERT INTO streetname VALUES('spring crest');
+ INSERT INTO streetname VALUES('spring lee');
+ INSERT INTO streetname VALUES('spring park');
+ INSERT INTO streetname VALUES('spring terrace');
+ INSERT INTO streetname VALUES('spring trace');
+ INSERT INTO streetname VALUES('springhaven');
+ INSERT INTO streetname VALUES('squirrel trail');
+ INSERT INTO streetname VALUES('stardust');
+ INSERT INTO streetname VALUES('stargaze');
+ INSERT INTO streetname VALUES('starita');
+ INSERT INTO streetname VALUES('starmount');
+ INSERT INTO streetname VALUES('statesville');
+ INSERT INTO streetname VALUES('steed');
+ INSERT INTO streetname VALUES('steelewood');
+ INSERT INTO streetname VALUES('steepleglen');
+ INSERT INTO streetname VALUES('stephens farm');
+ INSERT INTO streetname VALUES('stewarton');
+ INSERT INTO streetname VALUES('stone park');
+ INSERT INTO streetname VALUES('stonebrook');
+ INSERT INTO streetname VALUES('stonefield');
+ INSERT INTO streetname VALUES('stoneglen');
+ INSERT INTO streetname VALUES('stonemarsh');
+ INSERT INTO streetname VALUES('stoney garden');
+ INSERT INTO streetname VALUES('stoney run');
+ INSERT INTO streetname VALUES('stoney valley');
+ INSERT INTO streetname VALUES('stoneykirk');
+ INSERT INTO streetname VALUES('stream bank');
+ INSERT INTO streetname VALUES('stream ridge');
+ INSERT INTO streetname VALUES('suburban');
+ INSERT INTO streetname VALUES('suffield');
+ INSERT INTO streetname VALUES('sugar creek');
+ INSERT INTO streetname VALUES('sugarberry');
+ INSERT INTO streetname VALUES('sugarstone');
+ INSERT INTO streetname VALUES('summer creek');
+ INSERT INTO streetname VALUES('summer valley');
+ INSERT INTO streetname VALUES('summercrest');
+ INSERT INTO streetname VALUES('summercroft');
+ INSERT INTO streetname VALUES('summerford');
+ INSERT INTO streetname VALUES('summergold');
+ INSERT INTO streetname VALUES('sunbeam');
+ INSERT INTO streetname VALUES('sunbridge');
+ INSERT INTO streetname VALUES('sunpath');
+ INSERT INTO streetname VALUES('sunset');
+ INSERT INTO streetname VALUES('sunset ridge');
+ INSERT INTO streetname VALUES('sunstone');
+ INSERT INTO streetname VALUES('suntrace');
+ INSERT INTO streetname VALUES('sunwalk');
+ INSERT INTO streetname VALUES('sutters hill');
+ INSERT INTO streetname VALUES('suttonview');
+ INSERT INTO streetname VALUES('swallow tail');
+ INSERT INTO streetname VALUES('swanston');
+ INSERT INTO streetname VALUES('sweet grove');
+ INSERT INTO streetname VALUES('sweet rose');
+ INSERT INTO streetname VALUES('sweetbriar ridge');
+ INSERT INTO streetname VALUES('sweetfield');
+ INSERT INTO streetname VALUES('sydney overlook');
+ INSERT INTO streetname VALUES('sylvan');
+ INSERT INTO streetname VALUES('symphony woods');
+ INSERT INTO streetname VALUES('tallia');
+ INSERT INTO streetname VALUES('tallu');
+ INSERT INTO streetname VALUES('talwyn');
+ INSERT INTO streetname VALUES('tanager');
+ INSERT INTO streetname VALUES('tanager park');
+ INSERT INTO streetname VALUES('tangley');
+ INSERT INTO streetname VALUES('taranasay');
+ INSERT INTO streetname VALUES('tarby');
+ INSERT INTO streetname VALUES('tarland');
+ INSERT INTO streetname VALUES('tarpway');
+ INSERT INTO streetname VALUES('tauten');
+ INSERT INTO streetname VALUES('taymouth');
+ INSERT INTO streetname VALUES('ten trees');
+ INSERT INTO streetname VALUES('terrace view');
+ INSERT INTO streetname VALUES('terrier');
+ INSERT INTO streetname VALUES('tesh');
+ INSERT INTO streetname VALUES('teton');
+ INSERT INTO streetname VALUES('tewkesbury');
+ INSERT INTO streetname VALUES('thelema');
+ INSERT INTO streetname VALUES('thistle bloom');
+ INSERT INTO streetname VALUES('thistledown');
+ INSERT INTO streetname VALUES('thomas ridge');
+ INSERT INTO streetname VALUES('thornbrook');
+ INSERT INTO streetname VALUES('tifton grass');
+ INSERT INTO streetname VALUES('tigerton');
+ INSERT INTO streetname VALUES('tomsie efird');
+ INSERT INTO streetname VALUES('tor');
+ INSERT INTO streetname VALUES('torphin');
+ INSERT INTO streetname VALUES('torrence');
+ INSERT INTO streetname VALUES('towering pine');
+ INSERT INTO streetname VALUES('towhee');
+ INSERT INTO streetname VALUES('toxaway');
+ INSERT INTO streetname VALUES('tracy glenn');
+ INSERT INTO streetname VALUES('tradition view');
+ INSERT INTO streetname VALUES('trailer');
+ INSERT INTO streetname VALUES('transport');
+ INSERT INTO streetname VALUES('trehurst');
+ INSERT INTO streetname VALUES('trexler');
+ INSERT INTO streetname VALUES('trillium fields');
+ INSERT INTO streetname VALUES('trimbach');
+ INSERT INTO streetname VALUES('tucker');
+ INSERT INTO streetname VALUES('tullamore');
+ INSERT INTO streetname VALUES('tullock creek');
+ INSERT INTO streetname VALUES('tunston');
+ INSERT INTO streetname VALUES('tupelo');
+ INSERT INTO streetname VALUES('turnabout');
+ INSERT INTO streetname VALUES('turney');
+ INSERT INTO streetname VALUES('turtle cross');
+ INSERT INTO streetname VALUES('turtleback');
+ INSERT INTO streetname VALUES('twelvestone');
+ INSERT INTO streetname VALUES('twin');
+ INSERT INTO streetname VALUES('twin brook');
+ INSERT INTO streetname VALUES('twin lakes');
+ INSERT INTO streetname VALUES('twisted pine');
+ INSERT INTO streetname VALUES('tyler finley');
+ INSERT INTO streetname VALUES('university station');
+ INSERT INTO streetname VALUES('uphill');
+ INSERT INTO streetname VALUES('valeview');
+ INSERT INTO streetname VALUES('valhalla');
+ INSERT INTO streetname VALUES('van');
+ INSERT INTO streetname VALUES('vance davis');
+ INSERT INTO streetname VALUES('vanhoy');
+ INSERT INTO streetname VALUES('veckman');
+ INSERT INTO streetname VALUES('victoria');
+ INSERT INTO streetname VALUES('victory');
+ INSERT INTO streetname VALUES('village glen');
+ INSERT INTO streetname VALUES('vireo');
+ INSERT INTO streetname VALUES('viscount');
+ INSERT INTO streetname VALUES('voeltz');
+ INSERT INTO streetname VALUES('wade e morgan');
+ INSERT INTO streetname VALUES('wake');
+ INSERT INTO streetname VALUES('wales');
+ INSERT INTO streetname VALUES('wallace ridge');
+ INSERT INTO streetname VALUES('waltham');
+ INSERT INTO streetname VALUES('wanamassa');
+ INSERT INTO streetname VALUES('warbler wood');
+ INSERT INTO streetname VALUES('washington');
+ INSERT INTO streetname VALUES('water');
+ INSERT INTO streetname VALUES('waterelm');
+ INSERT INTO streetname VALUES('waterford hills');
+ INSERT INTO streetname VALUES('waterford valley');
+ INSERT INTO streetname VALUES('waterloo');
+ INSERT INTO streetname VALUES('waterton leas');
+ INSERT INTO streetname VALUES('waverly lynn');
+ INSERT INTO streetname VALUES('waverlyglen');
+ INSERT INTO streetname VALUES('wayside');
+ INSERT INTO streetname VALUES('westbury lake');
+ INSERT INTO streetname VALUES('westray');
+ INSERT INTO streetname VALUES('whistlers chase');
+ INSERT INTO streetname VALUES('whistley green');
+ INSERT INTO streetname VALUES('whistling oak');
+ INSERT INTO streetname VALUES('whitcomb');
+ INSERT INTO streetname VALUES('white aspen');
+ INSERT INTO streetname VALUES('white cascade');
+ INSERT INTO streetname VALUES('white mist');
+ INSERT INTO streetname VALUES('white rock');
+ INSERT INTO streetname VALUES('white stag');
+ INSERT INTO streetname VALUES('whitegate');
+ INSERT INTO streetname VALUES('whitehill');
+ INSERT INTO streetname VALUES('whitetail');
+ INSERT INTO streetname VALUES('whitewood');
+ INSERT INTO streetname VALUES('wilburn park');
+ INSERT INTO streetname VALUES('wild garden');
+ INSERT INTO streetname VALUES('wild rose');
+ INSERT INTO streetname VALUES('wilkins terrace');
+ INSERT INTO streetname VALUES('william ficklen');
+ INSERT INTO streetname VALUES('wiltshire ridge');
+ INSERT INTO streetname VALUES('windchase');
+ INSERT INTO streetname VALUES('winding jordan');
+ INSERT INTO streetname VALUES('windy meadow');
+ INSERT INTO streetname VALUES('winghaven');
+ INSERT INTO streetname VALUES('wingmont');
+ INSERT INTO streetname VALUES('winslow');
+ INSERT INTO streetname VALUES('winter pine');
+ INSERT INTO streetname VALUES('winter view');
+ INSERT INTO streetname VALUES('wolf creek');
+ INSERT INTO streetname VALUES('wondering oak');
+ INSERT INTO streetname VALUES('woodard');
+ INSERT INTO streetname VALUES('woodfire');
+ INSERT INTO streetname VALUES('woodland commons');
+ INSERT INTO streetname VALUES('woodland hills');
+ INSERT INTO streetname VALUES('woodnotch');
+ INSERT INTO streetname VALUES('woodstone');
+ INSERT INTO streetname VALUES('worsley');
+ INSERT INTO streetname VALUES('wren creek');
+ INSERT INTO streetname VALUES('wrens nest');
+ INSERT INTO streetname VALUES('wrexham');
+ INSERT INTO streetname VALUES('wt harris');
+ INSERT INTO streetname VALUES('wylie meadow');
+ INSERT INTO streetname VALUES('wynborough');
+ INSERT INTO streetname VALUES('wynbrook');
+ INSERT INTO streetname VALUES('wyndham hill');
+ INSERT INTO streetname VALUES('yandem');
+ INSERT INTO streetname VALUES('yellow rose');
+ INSERT INTO streetname VALUES('yellow spaniel');
+ INSERT INTO streetname VALUES('yorkford');
+ INSERT INTO streetname VALUES('ziegler');
+ INSERT INTO streetname VALUES('zion renaissance');
+
+ SELECT count(*) FROM streetname;
+ }
+} {1228}
+
+do_test fuzzer1-2.1 {
+ execsql {
+ SELECT n, distance FROM f2, streetname
+ WHERE f2.word MATCH 'wersley'
+ AND f2.distance<=150
+ AND f2.word=streetname.n
+ }
+} {worsley 37}
+do_test fuzzer1-2.2 {
+ execsql {
+ SELECT n, distance FROM f2, streetname
+ WHERE f2.word MATCH 'testledown'
+ AND f2.distance<=150
+ AND f2.word=streetname.n
+ }
+} {thistledown 103}
+do_test fuzzer1-2.3 {
+ execsql {
+ SELECT DISTINCT streetname.n FROM f2, streetname
+ WHERE f2.word MATCH 'tayle'
+ AND f2.distance<=200
+ AND streetname.n>=f2.word AND streetname.n<=(f2.word || x'F7BFBFBF')
+ }
+} {{tyler finley} trailer taymouth steelewood tallia tallu talwyn thelema}
+
+
+finish_test
diff --git a/test/hook.test b/test/hook.test
new file mode 100644
index 0000000..a195275
--- /dev/null
+++ b/test/hook.test
@@ -0,0 +1,392 @@
+# 2004 Jan 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for TCL interface to the
+# SQLite library.
+#
+# The focus of the tests in this file is the following interface:
+#
+# sqlite_commit_hook (tests hook-1..hook-3 inclusive)
+# sqlite_update_hook (tests hook-4-*)
+# sqlite_rollback_hook (tests hook-5.*)
+#
+# $Id: hook.test,v 1.15 2009/04/07 14:14:23 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test hook-1.2 {
+ db commit_hook
+} {}
+
+
+do_test hook-3.1 {
+ set commit_cnt 0
+ proc commit_hook {} {
+ incr ::commit_cnt
+ return 0
+ }
+ db commit_hook ::commit_hook
+ db commit_hook
+} {::commit_hook}
+do_test hook-3.2 {
+ set commit_cnt
+} {0}
+do_test hook-3.3 {
+ execsql {
+ CREATE TABLE t2(a,b);
+ }
+ set commit_cnt
+} {1}
+do_test hook-3.4 {
+ execsql {
+ INSERT INTO t2 VALUES(1,2);
+ INSERT INTO t2 SELECT a+1, b+1 FROM t2;
+ INSERT INTO t2 SELECT a+2, b+2 FROM t2;
+ }
+ set commit_cnt
+} {4}
+do_test hook-3.5 {
+ set commit_cnt {}
+ proc commit_hook {} {
+ set ::commit_cnt [execsql {SELECT * FROM t2}]
+ return 0
+ }
+ execsql {
+ INSERT INTO t2 VALUES(5,6);
+ }
+ set commit_cnt
+} {1 2 2 3 3 4 4 5 5 6}
+do_test hook-3.6 {
+ set commit_cnt {}
+ proc commit_hook {} {
+ set ::commit_cnt [execsql {SELECT * FROM t2}]
+ return 1
+ }
+ catchsql {
+ INSERT INTO t2 VALUES(6,7);
+ }
+} {1 {constraint failed}}
+do_test hook-3.7 {
+ set ::commit_cnt
+} {1 2 2 3 3 4 4 5 5 6 6 7}
+do_test hook-3.8 {
+ execsql {SELECT * FROM t2}
+} {1 2 2 3 3 4 4 5 5 6}
+
+# Test turnning off the commit hook
+#
+do_test hook-3.9 {
+ db commit_hook {}
+ set ::commit_cnt {}
+ execsql {
+ INSERT INTO t2 VALUES(7,8);
+ }
+ set ::commit_cnt
+} {}
+
+# Ticket #3564.
+#
+do_test hook-3.10 {
+ forcedelete test2.db test2.db-journal
+ sqlite3 db2 test2.db
+ proc commit_hook {} {
+ set y [db2 one {SELECT y FROM t3 WHERE y>10}]
+ return [expr {$y>10}]
+ }
+ db2 eval {CREATE TABLE t3(x,y)}
+ db2 commit_hook commit_hook
+ catchsql {INSERT INTO t3 VALUES(1,2)} db2
+ catchsql {INSERT INTO t3 VALUES(11,12)} db2
+ catchsql {INSERT INTO t3 VALUES(3,4)} db2
+ db2 eval {
+ SELECT * FROM t3 ORDER BY x;
+ }
+} {1 2 3 4}
+db2 close
+
+
+#----------------------------------------------------------------------------
+# Tests for the update-hook.
+#
+# 4.1.* - Very simple tests. Test that the update hook is invoked correctly
+# for INSERT, DELETE and UPDATE statements, including DELETE
+# statements with no WHERE clause.
+# 4.2.* - Check that the update-hook is invoked for rows modified by trigger
+# bodies. Also that the database name is correctly reported when
+# an attached database is modified.
+# 4.3.* - Do some sorting, grouping, compound queries, population and
+# depopulation of indices, to make sure the update-hook is not
+# invoked incorrectly.
+#
+
+# Simple tests
+do_test hook-4.1.1 {
+ catchsql {
+ DROP TABLE t1;
+ }
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+ }
+ db update_hook [list lappend ::update_hook]
+} {}
+do_test hook-4.1.2 {
+ execsql {
+ INSERT INTO t1 VALUES(4, 'four');
+ DELETE FROM t1 WHERE b = 'two';
+ UPDATE t1 SET b = '' WHERE a = 1 OR a = 3;
+ DELETE FROM t1 WHERE 1; -- Avoid the truncate optimization (for now)
+ }
+ set ::update_hook
+} [list \
+ INSERT main t1 4 \
+ DELETE main t1 2 \
+ UPDATE main t1 1 \
+ UPDATE main t1 3 \
+ DELETE main t1 1 \
+ DELETE main t1 3 \
+ DELETE main t1 4 \
+]
+
+ifcapable trigger {
+ # Update hook is not invoked for changes to sqlite_master
+ #
+ do_test hook-4.1.3 {
+ set ::update_hook {}
+ execsql {
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN SELECT RAISE(IGNORE); END;
+ }
+ set ::update_hook
+ } {}
+ do_test hook-4.1.4 {
+ set ::update_hook {}
+ execsql {
+ DROP TRIGGER r1;
+ }
+ set ::update_hook
+ } {}
+
+ set ::update_hook {}
+ do_test hook-4.2.1 {
+ catchsql {
+ DROP TABLE t2;
+ }
+ execsql {
+ CREATE TABLE t2(c INTEGER PRIMARY KEY, d);
+ CREATE TRIGGER t1_trigger AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(new.a, new.b);
+ UPDATE t2 SET d = d || ' via trigger' WHERE new.a = c;
+ DELETE FROM t2 WHERE new.a = c;
+ END;
+ }
+ } {}
+ do_test hook-4.2.2 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ }
+ set ::update_hook
+ } [list \
+ INSERT main t1 1 \
+ INSERT main t2 1 \
+ UPDATE main t2 1 \
+ DELETE main t2 1 \
+ INSERT main t1 2 \
+ INSERT main t2 2 \
+ UPDATE main t2 2 \
+ DELETE main t2 2 \
+ ]
+} else {
+ execsql {
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ }
+}
+
+# Update-hook + ATTACH
+set ::update_hook {}
+ifcapable attach {
+ do_test hook-4.2.3 {
+ forcedelete test2.db
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b);
+ INSERT INTO aux.t3 SELECT * FROM t1;
+ UPDATE t3 SET b = 'two or so' WHERE a = 2;
+ DELETE FROM t3 WHERE 1; -- Avoid the truncate optimization (for now)
+ }
+ set ::update_hook
+ } [list \
+ INSERT aux t3 1 \
+ INSERT aux t3 2 \
+ UPDATE aux t3 2 \
+ DELETE aux t3 1 \
+ DELETE aux t3 2 \
+ ]
+}
+
+ifcapable trigger {
+ execsql {
+ DROP TRIGGER t1_trigger;
+ }
+}
+
+# Test that other vdbe operations involving btree structures do not
+# incorrectly invoke the update-hook.
+set ::update_hook {}
+do_test hook-4.3.1 {
+ execsql {
+ CREATE INDEX t1_i ON t1(b);
+ INSERT INTO t1 VALUES(3, 'three');
+ UPDATE t1 SET b = '';
+ DELETE FROM t1 WHERE a > 1;
+ }
+ set ::update_hook
+} [list \
+ INSERT main t1 3 \
+ UPDATE main t1 1 \
+ UPDATE main t1 2 \
+ UPDATE main t1 3 \
+ DELETE main t1 2 \
+ DELETE main t1 3 \
+]
+set ::update_hook {}
+ifcapable compound&&attach {
+ do_test hook-4.3.2 {
+ execsql {
+ SELECT * FROM t1 UNION SELECT * FROM t3;
+ SELECT * FROM t1 UNION ALL SELECT * FROM t3;
+ SELECT * FROM t1 INTERSECT SELECT * FROM t3;
+ SELECT * FROM t1 EXCEPT SELECT * FROM t3;
+ SELECT * FROM t1 ORDER BY b;
+ SELECT * FROM t1 GROUP BY b;
+ }
+ set ::update_hook
+ } [list]
+}
+
+do_test hook-4.4 {
+ execsql {
+ CREATE TABLE t4(a UNIQUE, b);
+ INSERT INTO t4 VALUES(1, 'a');
+ INSERT INTO t4 VALUES(2, 'b');
+ }
+ set ::update_hook [list]
+ execsql {
+ REPLACE INTO t4 VALUES(1, 'c');
+ }
+ set ::update_hook
+} [list INSERT main t4 3 ]
+do_execsql_test hook-4.4.1 {
+ SELECT * FROM t4 ORDER BY a;
+} {1 c 2 b}
+do_test hook-4.4.2 {
+ set ::update_hook [list]
+ execsql {
+ PRAGMA recursive_triggers = on;
+ REPLACE INTO t4 VALUES(1, 'd');
+ }
+ set ::update_hook
+} [list INSERT main t4 4 ]
+do_execsql_test hook-4.4.3 {
+ SELECT * FROM t4 ORDER BY a;
+} {1 d 2 b}
+
+db update_hook {}
+#
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Test the rollback-hook. The rollback-hook is a bit more complicated than
+# either the commit or update hooks because a rollback can happen
+# explicitly (an sql ROLLBACK statement) or implicitly (a constraint or
+# error condition).
+#
+# hook-5.1.* - Test explicit rollbacks.
+# hook-5.2.* - Test implicit rollbacks caused by constraint failure.
+#
+# hook-5.3.* - Test implicit rollbacks caused by IO errors.
+# hook-5.4.* - Test implicit rollbacks caused by malloc() failure.
+# hook-5.5.* - Test hot-journal rollbacks. Or should the rollback hook
+# not be called for these?
+#
+
+do_test hook-5.0 {
+ # Configure the rollback hook to increment global variable
+ # $::rollback_hook each time it is invoked.
+ set ::rollback_hook 0
+ db rollback_hook [list incr ::rollback_hook]
+} {}
+
+# Test explicit rollbacks. Not much can really go wrong here.
+#
+do_test hook-5.1.1 {
+ set ::rollback_hook 0
+ execsql {
+ BEGIN;
+ ROLLBACK;
+ }
+ set ::rollback_hook
+} {1}
+
+# Test implicit rollbacks caused by constraints.
+#
+do_test hook-5.2.1 {
+ set ::rollback_hook 0
+ catchsql {
+ DROP TABLE t1;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES('one', 'I');
+ INSERT INTO t1 VALUES('one', 'I');
+ }
+ set ::rollback_hook
+} {1}
+do_test hook-5.2.2 {
+ # Check that the INSERT transaction above really was rolled back.
+ execsql {
+ SELECT count(*) FROM t1;
+ }
+} {1}
+
+#
+# End rollback-hook testing.
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Test that if a commit-hook returns non-zero (causing a rollback), the
+# rollback-hook is invoked.
+#
+proc commit_hook {} {
+ lappend ::hooks COMMIT
+ return 1
+}
+proc rollback_hook {} {
+ lappend ::hooks ROLLBACK
+}
+do_test hook-6.1 {
+ set ::hooks [list]
+ db commit_hook commit_hook
+ db rollback_hook rollback_hook
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('two', 'II');
+ COMMIT;
+ }
+ execsql { SELECT * FROM t1 }
+} {one I}
+do_test hook-6.2 {
+ set ::hooks
+} {COMMIT ROLLBACK}
+unset ::hooks
+
+finish_test
diff --git a/test/icu.test b/test/icu.test
new file mode 100644
index 0000000..73cb9b9
--- /dev/null
+++ b/test/icu.test
@@ -0,0 +1,136 @@
+# 2007 May 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: icu.test,v 1.2 2008/07/12 14:52:20 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !icu {
+ finish_test
+ return
+}
+
+# Create a table to work with.
+#
+execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
+execsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')}
+proc test_expr {name settings expr result} {
+ do_test $name [format {
+ lindex [db eval {
+ BEGIN;
+ UPDATE test1 SET %s;
+ SELECT %s FROM test1;
+ ROLLBACK;
+ }] 0
+ } $settings $expr] $result
+}
+
+# Tests of the REGEXP operator.
+#
+test_expr icu-1.1 {i1='hello'} {i1 REGEXP 'hello'} 1
+test_expr icu-1.2 {i1='hello'} {i1 REGEXP '.ello'} 1
+test_expr icu-1.3 {i1='hello'} {i1 REGEXP '.ell'} 0
+test_expr icu-1.4 {i1='hello'} {i1 REGEXP '.ell.*'} 1
+test_expr icu-1.5 {i1=NULL} {i1 REGEXP '.ell.*'} {}
+
+# Some non-ascii characters with defined case mappings
+#
+set ::EGRAVE "\xC8"
+set ::egrave "\xE8"
+
+set ::OGRAVE "\xD2"
+set ::ograve "\xF2"
+
+# That German letter that looks a bit like a B. The
+# upper-case version of which is "SS" (two characters).
+#
+set ::szlig "\xDF"
+
+# Tests of the upper()/lower() functions.
+#
+test_expr icu-2.1 {i1='HellO WorlD'} {upper(i1)} {HELLO WORLD}
+test_expr icu-2.2 {i1='HellO WorlD'} {lower(i1)} {hello world}
+test_expr icu-2.3 {i1=$::egrave} {lower(i1)} $::egrave
+test_expr icu-2.4 {i1=$::egrave} {upper(i1)} $::EGRAVE
+test_expr icu-2.5 {i1=$::ograve} {lower(i1)} $::ograve
+test_expr icu-2.6 {i1=$::ograve} {upper(i1)} $::OGRAVE
+test_expr icu-2.3 {i1=$::EGRAVE} {lower(i1)} $::egrave
+test_expr icu-2.4 {i1=$::EGRAVE} {upper(i1)} $::EGRAVE
+test_expr icu-2.5 {i1=$::OGRAVE} {lower(i1)} $::ograve
+test_expr icu-2.6 {i1=$::OGRAVE} {upper(i1)} $::OGRAVE
+
+test_expr icu-2.7 {i1=$::szlig} {upper(i1)} "SS"
+test_expr icu-2.8 {i1='SS'} {lower(i1)} "ss"
+
+# In turkish (locale="tr_TR"), the lower case version of I
+# is "small dotless i" (code point 0x131 (decimal 305)).
+#
+set ::small_dotless_i "\u0131"
+test_expr icu-3.1 {i1='I'} {lower(i1)} "i"
+test_expr icu-3.2 {i1='I'} {lower(i1, 'tr_tr')} $::small_dotless_i
+test_expr icu-3.3 {i1='I'} {lower(i1, 'en_AU')} "i"
+
+#--------------------------------------------------------------------
+# Test the collation sequence function.
+#
+do_test icu-4.1 {
+ execsql {
+ CREATE TABLE fruit(name);
+ INSERT INTO fruit VALUES('plum');
+ INSERT INTO fruit VALUES('cherry');
+ INSERT INTO fruit VALUES('apricot');
+ INSERT INTO fruit VALUES('peach');
+ INSERT INTO fruit VALUES('chokecherry');
+ INSERT INTO fruit VALUES('yamot');
+ }
+} {}
+do_test icu-4.2 {
+ execsql {
+ SELECT icu_load_collation('en_US', 'AmericanEnglish');
+ SELECT icu_load_collation('lt_LT', 'Lithuanian');
+ }
+ execsql {
+ SELECT name FROM fruit ORDER BY name COLLATE AmericanEnglish ASC;
+ }
+} {apricot cherry chokecherry peach plum yamot}
+
+
+# Test collation using Lithuanian rules. In the Lithuanian
+# alphabet, "y" comes right after "i".
+#
+do_test icu-4.3 {
+ execsql {
+ SELECT name FROM fruit ORDER BY name COLLATE Lithuanian ASC;
+ }
+} {apricot cherry chokecherry yamot peach plum}
+
+#-------------------------------------------------------------------------
+# Test that it is not possible to call the ICU regex() function with
+# anything other than exactly two arguments. See also:
+#
+# http://src.chromium.org/viewvc/chrome/trunk/src/third_party/sqlite/icu-regexp.patch?revision=34807&view=markup
+#
+do_catchsql_test icu-5.1 { SELECT regexp('a[abc]c.*', 'abc') } {0 1}
+do_catchsql_test icu-5.2 {
+ SELECT regexp('a[abc]c.*')
+} {1 {wrong number of arguments to function regexp()}}
+do_catchsql_test icu-5.3 {
+ SELECT regexp('a[abc]c.*', 'abc', 'c')
+} {1 {wrong number of arguments to function regexp()}}
+do_catchsql_test icu-5.4 {
+ SELECT 'abc' REGEXP 'a[abc]c.*'
+} {0 1}
+do_catchsql_test icu-5.4 { SELECT 'abc' REGEXP } {1 {near " ": syntax error}}
+do_catchsql_test icu-5.5 { SELECT 'abc' REGEXP, 1 } {1 {near ",": syntax error}}
+
+finish_test
diff --git a/test/in.test b/test/in.test
new file mode 100644
index 0000000..2c38a0f
--- /dev/null
+++ b/test/in.test
@@ -0,0 +1,609 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the IN and BETWEEN operator.
+#
+# $Id: in.test,v 1.22 2008/08/04 03:51:24 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Generate the test data we will need for the first squences of tests.
+#
+do_test in-1.0 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a int, b int);
+ }
+ for {set i 1} {$i<=10} {incr i} {
+ execsql "INSERT INTO t1 VALUES($i,[expr {1<<$i}])"
+ }
+ execsql {
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+} {10}
+
+# Do basic testing of BETWEEN.
+#
+do_test in-1.1 {
+ execsql {SELECT a FROM t1 WHERE b BETWEEN 10 AND 50 ORDER BY a}
+} {4 5}
+do_test in-1.2 {
+ execsql {SELECT a FROM t1 WHERE b NOT BETWEEN 10 AND 50 ORDER BY a}
+} {1 2 3 6 7 8 9 10}
+do_test in-1.3 {
+ execsql {SELECT a FROM t1 WHERE b BETWEEN a AND a*5 ORDER BY a}
+} {1 2 3 4}
+do_test in-1.4 {
+ execsql {SELECT a FROM t1 WHERE b NOT BETWEEN a AND a*5 ORDER BY a}
+} {5 6 7 8 9 10}
+do_test in-1.6 {
+ execsql {SELECT a FROM t1 WHERE b BETWEEN a AND a*5 OR b=512 ORDER BY a}
+} {1 2 3 4 9}
+do_test in-1.7 {
+ execsql {SELECT a+ 100*(a BETWEEN 1 and 3) FROM t1 ORDER BY b}
+} {101 102 103 4 5 6 7 8 9 10}
+
+# The rest of this file concentrates on testing the IN operator.
+# Skip this if the library is compiled with SQLITE_OMIT_SUBQUERY
+# (because the IN operator is unavailable).
+#
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+# Testing of the IN operator using static lists on the right-hand side.
+#
+do_test in-2.1 {
+ execsql {SELECT a FROM t1 WHERE b IN (8,12,16,24,32) ORDER BY a}
+} {3 4 5}
+do_test in-2.2 {
+ execsql {SELECT a FROM t1 WHERE b NOT IN (8,12,16,24,32) ORDER BY a}
+} {1 2 6 7 8 9 10}
+do_test in-2.3 {
+ execsql {SELECT a FROM t1 WHERE b IN (8,12,16,24,32) OR b=512 ORDER BY a}
+} {3 4 5 9}
+do_test in-2.4 {
+ execsql {SELECT a FROM t1 WHERE b NOT IN (8,12,16,24,32) OR b=512 ORDER BY a}
+} {1 2 6 7 8 9 10}
+do_test in-2.5 {
+ execsql {SELECT a+100*(b IN (8,16,24)) FROM t1 ORDER BY b}
+} {1 2 103 104 5 6 7 8 9 10}
+
+do_test in-2.6 {
+ execsql {SELECT a FROM t1 WHERE b IN (b+8,64)}
+} {6}
+do_test in-2.7 {
+ execsql {SELECT a FROM t1 WHERE b IN (max(5,10,b),20)}
+} {4 5 6 7 8 9 10}
+do_test in-2.8 {
+ execsql {SELECT a FROM t1 WHERE b IN (8*2,64/2) ORDER BY b}
+} {4 5}
+do_test in-2.9 {
+ execsql {SELECT a FROM t1 WHERE b IN (max(5,10),20)}
+} {}
+do_test in-2.10 {
+ execsql {SELECT a FROM t1 WHERE min(0,b IN (a,30))}
+} {}
+do_test in-2.11 {
+ set v [catch {execsql {SELECT a FROM t1 WHERE c IN (10,20)}} msg]
+ lappend v $msg
+} {1 {no such column: c}}
+
+# Testing the IN operator where the right-hand side is a SELECT
+#
+do_test in-3.1 {
+ execsql {
+ SELECT a FROM t1
+ WHERE b IN (SELECT b FROM t1 WHERE a<5)
+ ORDER BY a
+ }
+} {1 2 3 4}
+do_test in-3.2 {
+ execsql {
+ SELECT a FROM t1
+ WHERE b IN (SELECT b FROM t1 WHERE a<5) OR b==512
+ ORDER BY a
+ }
+} {1 2 3 4 9}
+do_test in-3.3 {
+ execsql {
+ SELECT a + 100*(b IN (SELECT b FROM t1 WHERE a<5)) FROM t1 ORDER BY b
+ }
+} {101 102 103 104 5 6 7 8 9 10}
+
+# Make sure the UPDATE and DELETE commands work with IN-SELECT
+#
+do_test in-4.1 {
+ execsql {
+ UPDATE t1 SET b=b*2
+ WHERE b IN (SELECT b FROM t1 WHERE a>8)
+ }
+ execsql {SELECT b FROM t1 ORDER BY b}
+} {2 4 8 16 32 64 128 256 1024 2048}
+do_test in-4.2 {
+ execsql {
+ DELETE FROM t1 WHERE b IN (SELECT b FROM t1 WHERE a>8)
+ }
+ execsql {SELECT a FROM t1 ORDER BY a}
+} {1 2 3 4 5 6 7 8}
+do_test in-4.3 {
+ execsql {
+ DELETE FROM t1 WHERE b NOT IN (SELECT b FROM t1 WHERE a>4)
+ }
+ execsql {SELECT a FROM t1 ORDER BY a}
+} {5 6 7 8}
+
+# Do an IN with a constant RHS but where the RHS has many, many
+# elements. We need to test that collisions in the hash table
+# are resolved properly.
+#
+do_test in-5.1 {
+ execsql {
+ INSERT INTO t1 VALUES('hello', 'world');
+ SELECT * FROM t1
+ WHERE a IN (
+ 'Do','an','IN','with','a','constant','RHS','but','where','the',
+ 'has','many','elements','We','need','to','test','that',
+ 'collisions','hash','table','are','resolved','properly',
+ 'This','in-set','contains','thirty','one','entries','hello');
+ }
+} {hello world}
+
+# Make sure the IN operator works with INTEGER PRIMARY KEY fields.
+#
+do_test in-6.1 {
+ execsql {
+ CREATE TABLE ta(a INTEGER PRIMARY KEY, b);
+ INSERT INTO ta VALUES(1,1);
+ INSERT INTO ta VALUES(2,2);
+ INSERT INTO ta VALUES(3,3);
+ INSERT INTO ta VALUES(4,4);
+ INSERT INTO ta VALUES(6,6);
+ INSERT INTO ta VALUES(8,8);
+ INSERT INTO ta VALUES(10,
+ 'This is a key that is long enough to require a malloc in the VDBE');
+ SELECT * FROM ta WHERE a<10;
+ }
+} {1 1 2 2 3 3 4 4 6 6 8 8}
+do_test in-6.2 {
+ execsql {
+ CREATE TABLE tb(a INTEGER PRIMARY KEY, b);
+ INSERT INTO tb VALUES(1,1);
+ INSERT INTO tb VALUES(2,2);
+ INSERT INTO tb VALUES(3,3);
+ INSERT INTO tb VALUES(5,5);
+ INSERT INTO tb VALUES(7,7);
+ INSERT INTO tb VALUES(9,9);
+ INSERT INTO tb VALUES(11,
+ 'This is a key that is long enough to require a malloc in the VDBE');
+ SELECT * FROM tb WHERE a<10;
+ }
+} {1 1 2 2 3 3 5 5 7 7 9 9}
+do_test in-6.3 {
+ execsql {
+ SELECT a FROM ta WHERE b IN (SELECT a FROM tb);
+ }
+} {1 2 3}
+do_test in-6.4 {
+ execsql {
+ SELECT a FROM ta WHERE b NOT IN (SELECT a FROM tb);
+ }
+} {4 6 8 10}
+do_test in-6.5 {
+ execsql {
+ SELECT a FROM ta WHERE b IN (SELECT b FROM tb);
+ }
+} {1 2 3 10}
+do_test in-6.6 {
+ execsql {
+ SELECT a FROM ta WHERE b NOT IN (SELECT b FROM tb);
+ }
+} {4 6 8}
+do_test in-6.7 {
+ execsql {
+ SELECT a FROM ta WHERE a IN (SELECT a FROM tb);
+ }
+} {1 2 3}
+do_test in-6.8 {
+ execsql {
+ SELECT a FROM ta WHERE a NOT IN (SELECT a FROM tb);
+ }
+} {4 6 8 10}
+do_test in-6.9 {
+ execsql {
+ SELECT a FROM ta WHERE a IN (SELECT b FROM tb);
+ }
+} {1 2 3}
+do_test in-6.10 {
+ execsql {
+ SELECT a FROM ta WHERE a NOT IN (SELECT b FROM tb);
+ }
+} {4 6 8 10}
+
+# Tests of IN operator against empty sets. (Ticket #185)
+#
+do_test in-7.1 {
+ execsql {
+ SELECT a FROM t1 WHERE a IN ();
+ }
+} {}
+do_test in-7.2 {
+ execsql {
+ SELECT a FROM t1 WHERE a IN (5);
+ }
+} {5}
+do_test in-7.3 {
+ execsql {
+ SELECT a FROM t1 WHERE a NOT IN () ORDER BY a;
+ }
+} {5 6 7 8 hello}
+do_test in-7.4 {
+ execsql {
+ SELECT a FROM t1 WHERE a IN (5) AND b IN ();
+ }
+} {}
+do_test in-7.5 {
+ execsql {
+ SELECT a FROM t1 WHERE a IN (5) AND b NOT IN ();
+ }
+} {5}
+do_test in-7.6 {
+ execsql {
+ SELECT a FROM ta WHERE a IN ();
+ }
+} {}
+do_test in-7.7 {
+ execsql {
+ SELECT a FROM ta WHERE a NOT IN ();
+ }
+} {1 2 3 4 6 8 10}
+
+do_test in-8.1 {
+ execsql {
+ SELECT b FROM t1 WHERE a IN ('hello','there')
+ }
+} {world}
+do_test in-8.2 {
+ execsql {
+ SELECT b FROM t1 WHERE a IN ("hello",'there')
+ }
+} {world}
+
+# Test constructs of the form: expr IN tablename
+#
+do_test in-9.1 {
+ execsql {
+ CREATE TABLE t4 AS SELECT a FROM tb;
+ SELECT * FROM t4;
+ }
+} {1 2 3 5 7 9 11}
+do_test in-9.2 {
+ execsql {
+ SELECT b FROM t1 WHERE a IN t4;
+ }
+} {32 128}
+do_test in-9.3 {
+ execsql {
+ SELECT b FROM t1 WHERE a NOT IN t4;
+ }
+} {64 256 world}
+do_test in-9.4 {
+ catchsql {
+ SELECT b FROM t1 WHERE a NOT IN tb;
+ }
+} {1 {only a single result allowed for a SELECT that is part of an expression}}
+
+# IN clauses in CHECK constraints. Ticket #1645
+#
+do_test in-10.1 {
+ execsql {
+ CREATE TABLE t5(
+ a INTEGER,
+ CHECK( a IN (111,222,333) )
+ );
+ INSERT INTO t5 VALUES(111);
+ SELECT * FROM t5;
+ }
+} {111}
+do_test in-10.2 {
+ catchsql {
+ INSERT INTO t5 VALUES(4);
+ }
+} {1 {constraint failed}}
+
+# Ticket #1821
+#
+# Type affinity applied to the right-hand side of an IN operator.
+#
+do_test in-11.1 {
+ execsql {
+ CREATE TABLE t6(a,b NUMERIC);
+ INSERT INTO t6 VALUES(1,2);
+ INSERT INTO t6 VALUES(2,3);
+ SELECT * FROM t6 WHERE b IN (2);
+ }
+} {1 2}
+do_test in-11.2 {
+ # The '2' should be coerced into 2 because t6.b is NUMERIC
+ execsql {
+ SELECT * FROM t6 WHERE b IN ('2');
+ }
+} {1 2}
+do_test in-11.3 {
+ # No coercion should occur here because of the unary + before b.
+ execsql {
+ SELECT * FROM t6 WHERE +b IN ('2');
+ }
+} {}
+do_test in-11.4 {
+ # No coercion because column a as affinity NONE
+ execsql {
+ SELECT * FROM t6 WHERE a IN ('2');
+ }
+} {}
+do_test in-11.5 {
+ execsql {
+ SELECT * FROM t6 WHERE a IN (2);
+ }
+} {2 3}
+do_test in-11.6 {
+ # No coercion because column a as affinity NONE
+ execsql {
+ SELECT * FROM t6 WHERE +a IN ('2');
+ }
+} {}
+
+# Test error conditions with expressions of the form IN(<compound select>).
+#
+ifcapable compound {
+do_test in-12.1 {
+ execsql {
+ CREATE TABLE t2(a, b, c);
+ CREATE TABLE t3(a, b, c);
+ }
+} {}
+do_test in-12.2 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 UNION ALL SELECT a, b FROM t2
+ );
+ }
+} {1 {only a single result allowed for a SELECT that is part of an expression}}
+do_test in-12.3 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 UNION SELECT a, b FROM t2
+ );
+ }
+} {1 {only a single result allowed for a SELECT that is part of an expression}}
+do_test in-12.4 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 EXCEPT SELECT a, b FROM t2
+ );
+ }
+} {1 {only a single result allowed for a SELECT that is part of an expression}}
+do_test in-12.5 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 INTERSECT SELECT a, b FROM t2
+ );
+ }
+} {1 {only a single result allowed for a SELECT that is part of an expression}}
+do_test in-12.6 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 UNION ALL SELECT a FROM t2
+ );
+ }
+} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}
+do_test in-12.7 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 UNION SELECT a FROM t2
+ );
+ }
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+do_test in-12.8 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 EXCEPT SELECT a FROM t2
+ );
+ }
+} {1 {SELECTs to the left and right of EXCEPT do not have the same number of result columns}}
+do_test in-12.9 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 INTERSECT SELECT a FROM t2
+ );
+ }
+} {1 {SELECTs to the left and right of INTERSECT do not have the same number of result columns}}
+}
+
+do_test in-12.10 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a FROM t3 UNION ALL SELECT a, b FROM t2
+ );
+ }
+} {1 {only a single result allowed for a SELECT that is part of an expression}}
+do_test in-12.11 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a FROM t3 UNION SELECT a, b FROM t2
+ );
+ }
+} {1 {only a single result allowed for a SELECT that is part of an expression}}
+do_test in-12.12 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a FROM t3 EXCEPT SELECT a, b FROM t2
+ );
+ }
+} {1 {only a single result allowed for a SELECT that is part of an expression}}
+do_test in-12.13 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a FROM t3 INTERSECT SELECT a, b FROM t2
+ );
+ }
+} {1 {only a single result allowed for a SELECT that is part of an expression}}
+
+
+#------------------------------------------------------------------------
+# The following tests check that NULL is handled correctly when it
+# appears as part of a set of values on the right-hand side of an
+# IN or NOT IN operator.
+#
+# When it appears in such a set, NULL is handled as an "unknown value".
+# If, because of the unknown value in the set, the result of the expression
+# cannot be determined, then it itself evaluates to NULL.
+#
+
+# Warm body test to demonstrate the principles being tested:
+#
+do_test in-13.1 {
+ db nullvalue "null"
+ execsql { SELECT
+ 1 IN (NULL, 1, 2), -- The value 1 is a member of the set, return true.
+ 3 IN (NULL, 1, 2), -- Ambiguous, return NULL.
+ 1 NOT IN (NULL, 1, 2), -- The value 1 is a member of the set, return false.
+ 3 NOT IN (NULL, 1, 2) -- Ambiguous, return NULL.
+ }
+} {1 null 0 null}
+
+do_test in-13.2 {
+ execsql {
+ CREATE TABLE t7(a, b, c NOT NULL);
+ INSERT INTO t7 VALUES(1, 1, 1);
+ INSERT INTO t7 VALUES(2, 2, 2);
+ INSERT INTO t7 VALUES(3, 3, 3);
+ INSERT INTO t7 VALUES(NULL, 4, 4);
+ INSERT INTO t7 VALUES(NULL, 5, 5);
+ }
+} {}
+
+do_test in-13.3 {
+ execsql { SELECT 2 IN (SELECT a FROM t7) }
+} {1}
+do_test in-13.4 {
+ execsql { SELECT 6 IN (SELECT a FROM t7) }
+} {null}
+
+do_test in-13.5 {
+ execsql { SELECT 2 IN (SELECT b FROM t7) }
+} {1}
+do_test in-13.6 {
+ execsql { SELECT 6 IN (SELECT b FROM t7) }
+} {0}
+
+do_test in-13.7 {
+ execsql { SELECT 2 IN (SELECT c FROM t7) }
+} {1}
+do_test in-13.8 {
+ execsql { SELECT 6 IN (SELECT c FROM t7) }
+} {0}
+
+do_test in-13.9 {
+ execsql {
+ SELECT
+ 2 NOT IN (SELECT a FROM t7),
+ 6 NOT IN (SELECT a FROM t7),
+ 2 NOT IN (SELECT b FROM t7),
+ 6 NOT IN (SELECT b FROM t7),
+ 2 NOT IN (SELECT c FROM t7),
+ 6 NOT IN (SELECT c FROM t7)
+ }
+} {0 null 0 1 0 1}
+
+do_test in-13.10 {
+ execsql {
+ SELECT b IN (
+ SELECT inside.a
+ FROM t7 AS inside
+ WHERE inside.b BETWEEN outside.b+1 AND outside.b+2
+ )
+ FROM t7 AS outside ORDER BY b;
+ }
+} {0 null null null 0}
+
+do_test in-13.11 {
+ execsql {
+ SELECT b NOT IN (
+ SELECT inside.a
+ FROM t7 AS inside
+ WHERE inside.b BETWEEN outside.b+1 AND outside.b+2
+ )
+ FROM t7 AS outside ORDER BY b;
+ }
+} {1 null null null 1}
+
+do_test in-13.12 {
+ execsql {
+ CREATE INDEX i1 ON t7(a);
+ CREATE INDEX i2 ON t7(b);
+ CREATE INDEX i3 ON t7(c);
+ }
+ execsql {
+ SELECT
+ 2 IN (SELECT a FROM t7),
+ 6 IN (SELECT a FROM t7),
+ 2 IN (SELECT b FROM t7),
+ 6 IN (SELECT b FROM t7),
+ 2 IN (SELECT c FROM t7),
+ 6 IN (SELECT c FROM t7)
+ }
+} {1 null 1 0 1 0}
+
+do_test in-13.13 {
+ execsql {
+ SELECT
+ 2 NOT IN (SELECT a FROM t7),
+ 6 NOT IN (SELECT a FROM t7),
+ 2 NOT IN (SELECT b FROM t7),
+ 6 NOT IN (SELECT b FROM t7),
+ 2 NOT IN (SELECT c FROM t7),
+ 6 NOT IN (SELECT c FROM t7)
+ }
+} {0 null 0 1 0 1}
+
+do_test in-13.14 {
+ execsql {
+ BEGIN TRANSACTION;
+ CREATE TABLE a(id INTEGER);
+ INSERT INTO a VALUES(1);
+ INSERT INTO a VALUES(2);
+ INSERT INTO a VALUES(3);
+ CREATE TABLE b(id INTEGER);
+ INSERT INTO b VALUES(NULL);
+ INSERT INTO b VALUES(3);
+ INSERT INTO b VALUES(4);
+ INSERT INTO b VALUES(5);
+ COMMIT;
+ SELECT * FROM a WHERE id NOT IN (SELECT id FROM b);
+ }
+} {}
+do_test in-13.14 {
+ execsql {
+ CREATE INDEX i5 ON b(id);
+ SELECT * FROM a WHERE id NOT IN (SELECT id FROM b);
+ }
+} {}
+
+
+do_test in-13.X {
+ db nullvalue ""
+} {}
+
+finish_test
diff --git a/test/in2.test b/test/in2.test
new file mode 100644
index 0000000..4324082
--- /dev/null
+++ b/test/in2.test
@@ -0,0 +1,67 @@
+# 2007 May 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file tests a special case in the b-tree code that can be
+# hit by the "IN" operator (or EXISTS, NOT IN, etc.).
+#
+# $Id: in2.test,v 1.3 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test in2-1 {
+ execsql {
+ CREATE TABLE a(i INTEGER PRIMARY KEY, a);
+ }
+} {}
+
+set ::N 2000
+
+do_test in2-2 {
+ db transaction {
+ for {set ::ii 0} {$::ii < $::N} {incr ::ii} {
+ execsql {INSERT INTO a VALUES($::ii, $::ii)}
+ }
+ execsql {INSERT INTO a VALUES(4000, '')}
+
+ for {set ::ii 0} {$::ii < $::N} {incr ::ii} {
+ set ::t [format "x%04d" $ii]
+ execsql {INSERT INTO a VALUES(NULL, $::t)}
+ }
+ }
+} {}
+
+# Each iteration of this loop builds a slightly different b-tree to
+# evaluate the "IN (...)" operator in the SQL statement. The contents
+# of the b-tree are (in sorted order):
+#
+# $::ii integers.
+# a string of zero length.
+# $::N short strings.
+#
+# Records are inserted in sorted order.
+#
+# The string of zero-length is stored in a b-tree cell with 3 bytes
+# of payload. Moving this cell from a leaf node to a internal node
+# during b-tree balancing was causing an assertion failure.
+#
+# This bug only applied to b-trees generated to evaluate IN (..)
+# clauses, as it is impossible for persistent b-trees (SQL tables +
+# indices) to contain cells smaller than 4 bytes.
+#
+for {set ::ii 3} {$::ii < $::N} {incr ::ii} {
+ do_test in2-$::ii {
+ execsql {
+ SELECT 1 IN (SELECT a FROM a WHERE (i < $::ii) OR (i >= $::N))
+ }
+ } {1}
+}
+
+finish_test
diff --git a/test/in3.test b/test/in3.test
new file mode 100644
index 0000000..012c9b4
--- /dev/null
+++ b/test/in3.test
@@ -0,0 +1,289 @@
+# 2007 November 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file tests the optimisations made in November 2007 of expressions
+# of the following form:
+#
+# <value> IN (SELECT <column> FROM <table>)
+#
+# $Id: in3.test,v 1.5 2008/08/04 03:51:24 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+# Return the number of OpenEphemeral instructions used in the
+# implementation of the sql statement passed as a an argument.
+#
+proc nEphemeral {sql} {
+ set nEph 0
+ foreach op [execsql "EXPLAIN $sql"] {
+ if {$op eq "OpenEphemeral"} {incr nEph}
+ }
+ set nEph
+}
+
+# This proc works the same way as execsql, except that the number
+# of OpenEphemeral instructions used in the implementation of the
+# statement is inserted into the start of the returned list.
+#
+proc exec_neph {sql} {
+ return [concat [nEphemeral $sql] [execsql $sql]]
+}
+
+do_test in3-1.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ }
+} {}
+
+# All of these queries should avoid using a temp-table:
+#
+do_test in3-1.2 {
+ exec_neph { SELECT rowid FROM t1 WHERE rowid IN (SELECT rowid FROM t1); }
+} {0 1 2 3}
+do_test in3-1.3 {
+ exec_neph { SELECT a FROM t1 WHERE a IN (SELECT a FROM t1); }
+} {0 1 3 5}
+do_test in3-1.4 {
+ exec_neph { SELECT rowid FROM t1 WHERE rowid+0 IN (SELECT rowid FROM t1); }
+} {0 1 2 3}
+do_test in3-1.5 {
+ exec_neph { SELECT a FROM t1 WHERE a+0 IN (SELECT a FROM t1); }
+} {0 1 3 5}
+
+# Because none of the sub-select queries in the following statements
+# match the pattern ("SELECT <column> FROM <table>"), the following do
+# require a temp table.
+#
+do_test in3-1.6 {
+ exec_neph { SELECT rowid FROM t1 WHERE rowid IN (SELECT rowid+0 FROM t1); }
+} {1 1 2 3}
+do_test in3-1.7 {
+ exec_neph { SELECT a FROM t1 WHERE a IN (SELECT a+0 FROM t1); }
+} {1 1 3 5}
+do_test in3-1.8 {
+ exec_neph { SELECT a FROM t1 WHERE a IN (SELECT a FROM t1 WHERE 1); }
+} {1 1 3 5}
+do_test in3-1.9 {
+ exec_neph { SELECT a FROM t1 WHERE a IN (SELECT a FROM t1 GROUP BY a); }
+} {1 1 3 5}
+
+# This should not use a temp-table. Even though the sub-select does
+# not exactly match the pattern "SELECT <column> FROM <table>", in
+# this case the ORDER BY is a no-op and can be ignored.
+do_test in3-1.10 {
+ exec_neph { SELECT a FROM t1 WHERE a IN (SELECT a FROM t1 ORDER BY a); }
+} {0 1 3 5}
+
+# These do use the temp-table. Adding the LIMIT clause means the
+# ORDER BY cannot be ignored.
+do_test in3-1.11 {
+ exec_neph {SELECT a FROM t1 WHERE a IN (SELECT a FROM t1 ORDER BY a LIMIT 1)}
+} {1 1}
+do_test in3-1.12 {
+ exec_neph {
+ SELECT a FROM t1 WHERE a IN (SELECT a FROM t1 ORDER BY a LIMIT 1 OFFSET 1)
+ }
+} {1 3}
+
+# Has to use a temp-table because of the compound sub-select.
+#
+ifcapable compound {
+ do_test in3-1.13 {
+ exec_neph {
+ SELECT a FROM t1 WHERE a IN (
+ SELECT a FROM t1 UNION ALL SELECT a FROM t1
+ )
+ }
+ } {1 1 3 5}
+}
+
+# The first of these queries has to use the temp-table, because the
+# collation sequence used for the index on "t1.a" does not match the
+# collation sequence used by the "IN" comparison. The second does not
+# require a temp-table, because the collation sequences match.
+#
+do_test in3-1.14 {
+ exec_neph { SELECT a FROM t1 WHERE a COLLATE nocase IN (SELECT a FROM t1) }
+} {1 1 3 5}
+do_test in3-1.15 {
+ exec_neph { SELECT a FROM t1 WHERE a COLLATE binary IN (SELECT a FROM t1) }
+} {0 1 3 5}
+
+# Neither of these queries require a temp-table. The collation sequence
+# makes no difference when using a rowid.
+#
+do_test in3-1.16 {
+ exec_neph {SELECT a FROM t1 WHERE a COLLATE nocase IN (SELECT rowid FROM t1)}
+} {0 1 3}
+do_test in3-1.17 {
+ exec_neph {SELECT a FROM t1 WHERE a COLLATE binary IN (SELECT rowid FROM t1)}
+} {0 1 3}
+
+# The following tests - in3.2.* - test a bug that was difficult to track
+# down during development. They are not particularly well focused.
+#
+do_test in3-2.1 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(w int, x int, y int);
+ CREATE TABLE t2(p int, q int, r int, s int);
+ }
+ for {set i 1} {$i<=100} {incr i} {
+ set w $i
+ set x [expr {int(log($i)/log(2))}]
+ set y [expr {$i*$i + 2*$i + 1}]
+ execsql "INSERT INTO t1 VALUES($w,$x,$y)"
+ }
+ set maxy [execsql {select max(y) from t1}]
+ db eval { INSERT INTO t2 SELECT 101-w, x, $maxy+1-y, y FROM t1 }
+} {}
+do_test in3-2.2 {
+ execsql {
+ SELECT rowid
+ FROM t1
+ WHERE rowid IN (SELECT rowid FROM t1 WHERE rowid IN (1, 2));
+ }
+} {1 2}
+do_test in3-2.3 {
+ execsql {
+ select rowid from t1 where rowid IN (-1,2,4)
+ }
+} {2 4}
+do_test in3-2.4 {
+ execsql {
+ SELECT rowid FROM t1 WHERE rowid IN
+ (select rowid from t1 where rowid IN (-1,2,4))
+ }
+} {2 4}
+
+#-------------------------------------------------------------------------
+# This next block of tests - in3-3.* - verify that column affinity is
+# correctly handled in cases where an index might be used to optimise
+# an IN (SELECT) expression.
+#
+do_test in3-3.1 {
+ catch {execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ }}
+
+ execsql {
+
+ CREATE TABLE t1(a BLOB, b NUMBER ,c TEXT);
+ CREATE UNIQUE INDEX t1_i1 ON t1(a); /* no affinity */
+ CREATE UNIQUE INDEX t1_i2 ON t1(b); /* numeric affinity */
+ CREATE UNIQUE INDEX t1_i3 ON t1(c); /* text affinity */
+
+ CREATE TABLE t2(x BLOB, y NUMBER, z TEXT);
+ CREATE UNIQUE INDEX t2_i1 ON t2(x); /* no affinity */
+ CREATE UNIQUE INDEX t2_i2 ON t2(y); /* numeric affinity */
+ CREATE UNIQUE INDEX t2_i3 ON t2(z); /* text affinity */
+
+ INSERT INTO t1 VALUES(1, 1, 1);
+ INSERT INTO t2 VALUES('1', '1', '1');
+ }
+} {}
+
+do_test in3-3.2 {
+ # No affinity is applied before comparing "x" and "a". Therefore
+ # the index can be used (the comparison is false, text!=number).
+ exec_neph { SELECT x IN (SELECT a FROM t1) FROM t2 }
+} {0 0}
+do_test in3-3.3 {
+ # Logically, numeric affinity is applied to both sides before
+ # the comparison. Therefore it is possible to use index t1_i2.
+ exec_neph { SELECT x IN (SELECT b FROM t1) FROM t2 }
+} {0 1}
+do_test in3-3.4 {
+ # No affinity is applied before the comparison takes place. Making
+ # it possible to use index t1_i3.
+ exec_neph { SELECT x IN (SELECT c FROM t1) FROM t2 }
+} {0 1}
+
+do_test in3-3.5 {
+ # Numeric affinity should be applied to each side before the comparison
+ # takes place. Therefore we cannot use index t1_i1, which has no affinity.
+ exec_neph { SELECT y IN (SELECT a FROM t1) FROM t2 }
+} {1 1}
+do_test in3-3.6 {
+ # Numeric affinity is applied to both sides before
+ # the comparison. Therefore it is possible to use index t1_i2.
+ exec_neph { SELECT y IN (SELECT b FROM t1) FROM t2 }
+} {0 1}
+do_test in3-3.7 {
+ # Numeric affinity is applied before the comparison takes place.
+ # Making it impossible to use index t1_i3.
+ exec_neph { SELECT y IN (SELECT c FROM t1) FROM t2 }
+} {1 1}
+
+#---------------------------------------------------------------------
+#
+# Test using a multi-column index.
+#
+do_test in3-4.1 {
+ execsql {
+ CREATE TABLE t3(a, b, c);
+ CREATE UNIQUE INDEX t3_i ON t3(b, a);
+ }
+
+ execsql {
+ INSERT INTO t3 VALUES(1, 'numeric', 2);
+ INSERT INTO t3 VALUES(2, 'text', 2);
+ INSERT INTO t3 VALUES(3, 'real', 2);
+ INSERT INTO t3 VALUES(4, 'none', 2);
+ }
+} {}
+do_test in3-4.2 {
+ exec_neph { SELECT 'text' IN (SELECT b FROM t3) }
+} {0 1}
+do_test in3-4.3 {
+ exec_neph { SELECT 'TEXT' COLLATE nocase IN (SELECT b FROM t3) }
+} {1 1}
+do_test in3-4.4 {
+ # A temp table must be used because t3_i.b is not guaranteed to be unique.
+ exec_neph { SELECT b FROM t3 WHERE b IN (SELECT b FROM t3) }
+} {1 none numeric real text}
+do_test in3-4.5 {
+ execsql { CREATE UNIQUE INDEX t3_i2 ON t3(b) }
+ exec_neph { SELECT b FROM t3 WHERE b IN (SELECT b FROM t3) }
+} {0 none numeric real text}
+do_test in3-4.6 {
+ execsql { DROP INDEX t3_i2 }
+} {}
+
+# The following two test cases verify that ticket #2991 has been fixed.
+#
+do_test in3-5.1 {
+ execsql {
+ CREATE TABLE Folders(
+ folderid INTEGER PRIMARY KEY,
+ parentid INTEGER,
+ rootid INTEGER,
+ path VARCHAR(255)
+ );
+ }
+} {}
+do_test in3-5.2 {
+ catchsql {
+ DELETE FROM Folders WHERE folderid IN
+ (SELECT folderid FROM Folder WHERE path LIKE 'C:\MP3\Albums\' || '%');
+ }
+} {1 {no such table: Folder}}
+
+finish_test
diff --git a/test/in4.test b/test/in4.test
new file mode 100644
index 0000000..470f4f0
--- /dev/null
+++ b/test/in4.test
@@ -0,0 +1,162 @@
+# 2008 September 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: in4.test,v 1.4 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test in4-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ }
+} {}
+do_test in4-1.2 {
+ execsql {
+ SELECT * FROM t1 WHERE a IN ('aaa', 'bbb', 'ccc');
+ }
+} {}
+do_test in4-1.3 {
+ execsql {
+ INSERT INTO t1 VALUES('aaa', 1);
+ INSERT INTO t1 VALUES('ddd', 2);
+ INSERT INTO t1 VALUES('ccc', 3);
+ INSERT INTO t1 VALUES('eee', 4);
+ SELECT b FROM t1 WHERE a IN ('aaa', 'bbb', 'ccc');
+ }
+} {1 3}
+do_test in4-1.4 {
+ execsql {
+ SELECT a FROM t1 WHERE rowid IN (1, 3);
+ }
+} {aaa ccc}
+do_test in4-1.5 {
+ execsql {
+ SELECT a FROM t1 WHERE rowid IN ();
+ }
+} {}
+do_test in4-1.6 {
+ execsql {
+ SELECT a FROM t1 WHERE a IN ('ddd');
+ }
+} {ddd}
+
+do_test in4-2.1 {
+ execsql {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t2 VALUES(-1, '-one');
+ INSERT INTO t2 VALUES(0, 'zero');
+ INSERT INTO t2 VALUES(1, 'one');
+ INSERT INTO t2 VALUES(2, 'two');
+ INSERT INTO t2 VALUES(3, 'three');
+ }
+} {}
+
+do_test in4-2.2 {
+ execsql { SELECT b FROM t2 WHERE a IN (0, 2) }
+} {zero two}
+
+do_test in4-2.3 {
+ execsql { SELECT b FROM t2 WHERE a IN (2, 0) }
+} {zero two}
+
+do_test in4-2.4 {
+ execsql { SELECT b FROM t2 WHERE a IN (2, -1) }
+} {-one two}
+
+do_test in4-2.5 {
+ execsql { SELECT b FROM t2 WHERE a IN (NULL, 3) }
+} {three}
+
+do_test in4-2.6 {
+ execsql { SELECT b FROM t2 WHERE a IN (1.0, 2.1) }
+} {one}
+
+do_test in4-2.7 {
+ execsql { SELECT b FROM t2 WHERE a IN ('1', '2') }
+} {one two}
+
+do_test in4-2.8 {
+ execsql { SELECT b FROM t2 WHERE a IN ('', '0.0.0', '2') }
+} {two}
+
+# The following block of tests test expressions of the form:
+#
+# <expr> IN ()
+#
+# i.e. IN expressions with a literal empty set.
+#
+# This has led to crashes on more than one occasion. Test case in4-3.2
+# was added in reponse to a bug reported on the mailing list on 11/7/2008.
+# See also tickets #3602 and #185.
+#
+do_test in4-3.1 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(x, id);
+ CREATE TABLE t2(x, id);
+ INSERT INTO t1 VALUES(NULL, NULL);
+ INSERT INTO t1 VALUES(0, NULL);
+ INSERT INTO t1 VALUES(1, 3);
+ INSERT INTO t1 VALUES(2, 4);
+ INSERT INTO t1 VALUES(3, 5);
+ INSERT INTO t1 VALUES(4, 6);
+ INSERT INTO t2 VALUES(0, NULL);
+ INSERT INTO t2 VALUES(4, 1);
+ INSERT INTO t2 VALUES(NULL, 1);
+ INSERT INTO t2 VALUES(NULL, NULL);
+ }
+} {}
+do_test in4-3.2 {
+ execsql {
+ SELECT x FROM t1 WHERE id IN () AND x IN (SELECT x FROM t2 WHERE id=1)
+ }
+} {}
+do_test in4-3.3 {
+ execsql {
+ CREATE TABLE t3(x, y, z);
+ CREATE INDEX t3i1 ON t3(x, y);
+ INSERT INTO t3 VALUES(1, 1, 1);
+ INSERT INTO t3 VALUES(10, 10, 10);
+ }
+ execsql { SELECT * FROM t3 WHERE x IN () }
+} {}
+do_test in4-3.4 {
+ execsql { SELECT * FROM t3 WHERE x = 10 AND y IN () }
+} {}
+do_test in4-3.5 {
+ execsql { SELECT * FROM t3 WHERE x IN () AND y = 10 }
+} {}
+do_test in4-3.6 {
+ execsql { SELECT * FROM t3 WHERE x IN () OR x = 10 }
+} {10 10 10}
+do_test in4-3.7 {
+ execsql { SELECT * FROM t3 WHERE y IN () }
+} {}
+do_test in4-3.8 {
+ execsql { SELECT x IN() AS a FROM t3 WHERE a }
+} {}
+do_test in4-3.9 {
+ execsql { SELECT x IN() AS a FROM t3 WHERE NOT a }
+} {0 0}
+do_test in4-3.10 {
+ execsql { SELECT * FROM t3 WHERE oid IN () }
+} {}
+do_test in4-3.11 {
+ execsql { SELECT * FROM t3 WHERE x IN (1, 2) OR y IN ()}
+} {1 1 1}
+do_test in4-3.12 {
+ execsql { SELECT * FROM t3 WHERE x IN (1, 2) AND y IN ()}
+} {}
+
+finish_test
diff --git a/test/incrblob.test b/test/incrblob.test
new file mode 100644
index 0000000..388c4ba
--- /dev/null
+++ b/test/incrblob.test
@@ -0,0 +1,690 @@
+# 2007 May 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: incrblob.test,v 1.24 2009/06/19 22:23:42 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!autovacuum || !pragma || !incrblob} {
+ finish_test
+ return
+}
+
+do_test incrblob-1.1 {
+ execsql {
+ CREATE TABLE blobs(k PRIMARY KEY, v BLOB);
+ INSERT INTO blobs VALUES('one', X'0102030405060708090A');
+ INSERT INTO blobs VALUES('two', X'0A090807060504030201');
+ }
+} {}
+
+do_test incrblob-1.2.1 {
+ set ::blob [db incrblob blobs v 1]
+ string match incrblob_* $::blob
+} {1}
+unset -nocomplain data
+do_test incrblob-1.2.2 {
+ binary scan [read $::blob] c* data
+ set data
+} {1 2 3 4 5 6 7 8 9 10}
+do_test incrblob-1.2.3 {
+ seek $::blob 0
+ puts -nonewline $::blob "1234567890"
+ flush $::blob
+} {}
+do_test incrblob-1.2.4 {
+ seek $::blob 0
+ binary scan [read $::blob] c* data
+ set data
+} {49 50 51 52 53 54 55 56 57 48}
+do_test incrblob-1.2.5 {
+ close $::blob
+} {}
+do_test incrblob-1.2.6 {
+ execsql {
+ SELECT v FROM blobs WHERE rowid = 1;
+ }
+} {1234567890}
+
+#--------------------------------------------------------------------
+# Test cases incrblob-1.3.X check that it is possible to read and write
+# regions of a blob that lie on overflow pages.
+#
+do_test incrblob-1.3.1 {
+ set ::str "[string repeat . 10000]"
+ execsql {
+ INSERT INTO blobs(rowid, k, v) VALUES(3, 'three', $::str);
+ }
+} {}
+
+do_test incrblob-1.3.2 {
+ set ::blob [db incrblob blobs v 3]
+ seek $::blob 8500
+ read $::blob 10
+} {..........}
+do_test incrblob-1.3.3 {
+ seek $::blob 8500
+ puts -nonewline $::blob 1234567890
+} {}
+do_test incrblob-1.3.4 {
+ seek $::blob 8496
+ read $::blob 10
+} {....123456}
+do_test incrblob-1.3.10 {
+ close $::blob
+} {}
+
+#------------------------------------------------------------------------
+# incrblob-2.*:
+#
+# Test that the following operations use ptrmap pages to reduce
+# unnecessary reads:
+#
+# * Reading near the end of a blob,
+# * Writing near the end of a blob, and
+# * SELECT a column value that is located on an overflow page.
+#
+proc nRead {db} {
+ set bt [btree_from_db $db]
+ db_enter $db
+ array set stats [btree_pager_stats $bt]
+ db_leave $db
+ return $stats(read)
+}
+proc nWrite {db} {
+ set bt [btree_from_db $db]
+ db_enter $db
+ array set stats [btree_pager_stats $bt]
+ db_leave $db
+ return $stats(write)
+}
+
+sqlite3_soft_heap_limit 0
+
+foreach AutoVacuumMode [list 0 1] {
+
+ if {$AutoVacuumMode>0} {
+ ifcapable !autovacuum {
+ break
+ }
+ }
+
+ db close
+ forcedelete test.db test.db-journal
+
+ sqlite3 db test.db
+ execsql "PRAGMA auto_vacuum = $AutoVacuumMode"
+
+ do_test incrblob-2.$AutoVacuumMode.1 {
+ set ::str [string repeat abcdefghij 2900]
+ execsql {
+ BEGIN;
+ CREATE TABLE blobs(k PRIMARY KEY, v BLOB, i INTEGER);
+ DELETE FROM blobs;
+ INSERT INTO blobs VALUES('one', $::str || randstr(500,500), 45);
+ COMMIT;
+ }
+ expr [file size test.db]/1024
+ } [expr 31 + $AutoVacuumMode]
+
+ ifcapable autovacuum {
+ do_test incrblob-2.$AutoVacuumMode.2 {
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+ } $AutoVacuumMode
+ }
+
+ do_test incrblob-2.$AutoVacuumMode.3 {
+ # Open and close the db to make sure the page cache is empty.
+ db close
+ sqlite3 db test.db
+
+ # Read the last 20 bytes of the blob via a blob handle.
+ set ::blob [db incrblob blobs v 1]
+ seek $::blob -20 end
+ set ::fragment [read $::blob]
+ close $::blob
+
+ # If the database is not in auto-vacuum mode, the whole of
+ # the overflow-chain must be scanned. In auto-vacuum mode,
+ # sqlite uses the ptrmap pages to avoid reading the other pages.
+ #
+ nRead db
+ } [expr $AutoVacuumMode ? 4 : 30]
+
+ do_test incrblob-2.$AutoVacuumMode.4 {
+ string range [db one {SELECT v FROM blobs}] end-19 end
+ } $::fragment
+
+ do_test incrblob-2.$AutoVacuumMode.5 {
+ # Open and close the db to make sure the page cache is empty.
+ db close
+ sqlite3 db test.db
+
+ # Write the second-to-last 20 bytes of the blob via a blob handle.
+ #
+ set ::blob [db incrblob blobs v 1]
+ seek $::blob -40 end
+ puts -nonewline $::blob "1234567890abcdefghij"
+ flush $::blob
+
+ # If the database is not in auto-vacuum mode, the whole of
+ # the overflow-chain must be scanned. In auto-vacuum mode,
+ # sqlite uses the ptrmap pages to avoid reading the other pages.
+ #
+ nRead db
+ } [expr $AutoVacuumMode ? 4 : 30]
+
+ # Pages 1 (the write-counter) and 32 (the blob data) were written.
+ do_test incrblob-2.$AutoVacuumMode.6 {
+ close $::blob
+ nWrite db
+ } 2
+
+ do_test incrblob-2.$AutoVacuumMode.7 {
+ string range [db one {SELECT v FROM blobs}] end-39 end-20
+ } "1234567890abcdefghij"
+
+ do_test incrblob-2.$AutoVacuumMode.8 {
+ # Open and close the db to make sure the page cache is empty.
+ db close
+ sqlite3 db test.db
+
+ execsql { SELECT i FROM blobs }
+ } {45}
+
+ do_test incrblob-2.$AutoVacuumMode.9 {
+ nRead db
+ } [expr $AutoVacuumMode ? 4 : 30]
+}
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+
+#------------------------------------------------------------------------
+# incrblob-3.*:
+#
+# Test the outcome of trying to write to a read-only blob handle.
+#
+do_test incrblob-3.1 {
+ set ::blob [db incrblob -readonly blobs v 1]
+ seek $::blob -40 end
+ read $::blob 20
+} "1234567890abcdefghij"
+do_test incrblob-3.2 {
+ seek $::blob 0
+ set rc [catch {
+ puts -nonewline $::blob "helloworld"
+ } msg]
+ close $::blob
+ list $rc $msg
+} "1 {channel \"$::blob\" wasn't opened for writing}"
+
+do_test incrblob-3.3 {
+ set ::blob [db incrblob -readonly blobs v 1]
+ seek $::blob -40 end
+ read $::blob 20
+} "1234567890abcdefghij"
+do_test incrblob-3.4 {
+ set rc [catch {
+ sqlite3_blob_write $::blob 20 "qwertyuioplkjhgfds"
+ } msg]
+ list $rc $msg
+} {1 SQLITE_READONLY}
+catch {close $::blob}
+
+#------------------------------------------------------------------------
+# incrblob-4.*:
+#
+# Try a couple of error conditions:
+#
+# 4.1 - Attempt to open a row that does not exist.
+# 4.2 - Attempt to open a column that does not exist.
+# 4.3 - Attempt to open a table that does not exist.
+# 4.4 - Attempt to open a database that does not exist.
+#
+# 4.5 - Attempt to open an integer
+# 4.6 - Attempt to open a real value
+# 4.7 - Attempt to open an SQL null
+#
+# 4.8 - Attempt to open an indexed column for writing
+# 4.9 - Attempt to open an indexed column for reading (this works)
+#
+# 4.11 - Attempt to open a column of a view.
+# 4.12 - Attempt to open a column of a virtual table.
+#
+do_test incrblob-4.1 {
+ set rc [catch {
+ set ::blob [db incrblob blobs v 2]
+ } msg ]
+ list $rc $msg
+} {1 {no such rowid: 2}}
+do_test incrblob-4.2 {
+ set rc [catch {
+ set ::blob [db incrblob blobs blue 1]
+ } msg ]
+ list $rc $msg
+} {1 {no such column: "blue"}}
+do_test incrblob-4.3 {
+ set rc [catch {
+ set ::blob [db incrblob nosuchtable blue 1]
+ } msg ]
+ list $rc $msg
+} {1 {no such table: main.nosuchtable}}
+do_test incrblob-4.4 {
+ set rc [catch {
+ set ::blob [db incrblob nosuchdb blobs v 1]
+ } msg ]
+ list $rc $msg
+} {1 {no such table: nosuchdb.blobs}}
+
+do_test incrblob-4.5 {
+ set rc [catch {
+ set ::blob [db incrblob blobs i 1]
+ } msg ]
+ list $rc $msg
+} {1 {cannot open value of type integer}}
+do_test incrblob-4.6 {
+ execsql {
+ INSERT INTO blobs(k, v, i) VALUES(123, 567.765, NULL);
+ }
+ set rc [catch {
+ set ::blob [db incrblob blobs v 2]
+ } msg ]
+ list $rc $msg
+} {1 {cannot open value of type real}}
+do_test incrblob-4.7 {
+ set rc [catch {
+ set ::blob [db incrblob blobs i 2]
+ } msg ]
+ list $rc $msg
+} {1 {cannot open value of type null}}
+
+do_test incrblob-4.8.1 {
+ execsql {
+ INSERT INTO blobs(k, v, i) VALUES(X'010203040506070809', 'hello', 'world');
+ }
+ set rc [catch {
+ set ::blob [db incrblob blobs k 3]
+ } msg ]
+ list $rc $msg
+} {1 {cannot open indexed column for writing}}
+do_test incrblob-4.8.2 {
+ execsql {
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t3 VALUES(1, 2);
+ }
+ set rc [catch {
+ set ::blob [db incrblob -readonly t3 a 1]
+ } msg ]
+ list $rc $msg
+} {1 {cannot open value of type null}}
+do_test incrblob-4.8.3 {
+ set rc [catch {
+ set ::blob [db incrblob -readonly t3 rowid 1]
+ } msg ]
+ list $rc $msg
+} {1 {no such column: "rowid"}}
+
+do_test incrblob-4.9.1 {
+ set rc [catch {
+ set ::blob [db incrblob -readonly blobs k 3]
+ } msg]
+} {0}
+do_test incrblob-4.9.2 {
+ binary scan [read $::blob] c* c
+ close $::blob
+ set c
+} {1 2 3 4 5 6 7 8 9}
+
+do_test incrblob-4.10 {
+ set ::blob [db incrblob -readonly blobs k 3]
+ set rc [catch { sqlite3_blob_read $::blob 10 100 } msg]
+ list $rc $msg
+} {1 SQLITE_ERROR}
+do_test incrblob-4.10.2 {
+ close $::blob
+} {}
+
+ifcapable view {
+ do_test incrblob-4.11 {
+ execsql { CREATE VIEW blobs_view AS SELECT k, v, i FROM blobs }
+ set rc [catch { db incrblob blobs_view v 3 } msg]
+ list $rc $msg
+ } {1 {cannot open view: blobs_view}}
+}
+ifcapable vtab {
+ register_echo_module [sqlite3_connection_pointer db]
+ do_test incrblob-4.12 {
+ execsql { CREATE VIRTUAL TABLE blobs_echo USING echo(blobs) }
+ set rc [catch { db incrblob blobs_echo v 3 } msg]
+ list $rc $msg
+ } {1 {cannot open virtual table: blobs_echo}}
+}
+
+
+#------------------------------------------------------------------------
+# incrblob-5.*:
+#
+# Test that opening a blob in an attached database works.
+#
+ifcapable attach {
+ do_test incrblob-5.1 {
+ forcedelete test2.db test2.db-journal
+ set ::size [expr [file size [info script]]]
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ CREATE TABLE aux.files(name, text);
+ INSERT INTO aux.files VALUES('this one', zeroblob($::size));
+ }
+ set fd [db incrblob aux files text 1]
+ fconfigure $fd -translation binary
+ set fd2 [open [info script]]
+ fconfigure $fd2 -translation binary
+ puts -nonewline $fd [read $fd2]
+ close $fd
+ close $fd2
+ set ::text [db one {select text from aux.files}]
+ string length $::text
+ } [file size [info script]]
+ do_test incrblob-5.2 {
+ set fd2 [open [info script]]
+ fconfigure $fd2 -translation binary
+ set ::data [read $fd2]
+ close $fd2
+ set ::data
+ } $::text
+}
+
+# free memory
+unset -nocomplain ::data
+unset -nocomplain ::text
+
+#------------------------------------------------------------------------
+# incrblob-6.*:
+#
+# Test that opening a blob for write-access is impossible if
+# another connection has the database RESERVED lock.
+#
+# Then test that blob writes that take place inside of a
+# transaction are not visible to external connections until
+# after the transaction is commited and the blob channel
+# closed.
+#
+# This test does not work with the "memsubsys1" configuration.
+# Permutation memsubsys1 configures a very small static allocation
+# for use as page-cache memory. This causes SQLite to upgrade
+# to an exclusive lock when writing earlier than usual, which
+# makes some of these tests fail.
+#
+sqlite3_soft_heap_limit 0
+if {[permutation] != "memsubsys1"} {
+ do_test incrblob-6.1 {
+ sqlite3 db2 test.db
+ execsql {
+ BEGIN;
+ INSERT INTO blobs(k, v, i) VALUES('a', 'different', 'connection');
+ } db2
+ } {}
+ do_test incrblob-6.2 {
+ execsql {
+ SELECT rowid FROM blobs
+ }
+ } {1 2 3}
+ do_test incrblob-6.3 {
+ set rc [catch {
+ db incrblob blobs v 1
+ } msg]
+ list $rc $msg
+ } {1 {database is locked}}
+ do_test incrblob-6.4 {
+ set rc [catch {
+ db incrblob blobs v 3
+ } msg]
+ list $rc $msg
+ } {1 {database is locked}}
+ do_test incrblob-6.5 {
+ set ::blob [db incrblob -readonly blobs v 3]
+ read $::blob
+ } {hello}
+ do_test incrblob-6.6 {
+ close $::blob
+ } {}
+
+ do_test incrblob-6.7 {
+ set ::blob [db2 incrblob blobs i 4]
+ gets $::blob
+ } {connection}
+ do_test incrblob-6.8 {
+ tell $::blob
+ } {10}
+ do_test incrblob-6.9 {
+ seek $::blob 0
+ puts -nonewline $::blob "invocation"
+ flush $::blob
+ } {}
+
+ # At this point rollback should be illegal (because
+ # there is an open blob channel). But commit is also illegal because
+ # the open blob is read-write.
+ #
+ do_test incrblob-6.10 {
+ catchsql {
+ ROLLBACK;
+ } db2
+ } {1 {cannot rollback transaction - SQL statements in progress}}
+ do_test incrblob-6.11 {
+ catchsql {
+ COMMIT;
+ } db2
+ } {1 {cannot commit transaction - SQL statements in progress}}
+
+ do_test incrblob-6.12 {
+ execsql {
+ SELECT * FROM blobs WHERE rowid = 4;
+ }
+ } {}
+ do_test incrblob-6.13 {
+ close $::blob
+ } {}
+ do_test incrblob-6.14 {
+ catchsql {
+ COMMIT;
+ } db2
+ } {0 {}}
+ do_test incrblob-6.15 {
+ execsql {
+ SELECT * FROM blobs WHERE rowid = 4;
+ }
+ } {a different invocation}
+ db2 close
+}
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+
+#-----------------------------------------------------------------------
+# The following tests verify the behaviour of the incremental IO
+# APIs in the following cases:
+#
+# 7.1 A row that containing an open blob is modified.
+#
+# 7.2 A CREATE TABLE requires that an overflow page that is part
+# of an open blob is moved.
+#
+# 7.3 An INCREMENTAL VACUUM moves an overflow page that is part
+# of an open blob.
+#
+# In the first case above, correct behaviour is for all subsequent
+# read/write operations on the blob-handle to return SQLITE_ABORT.
+# More accurately, blob-handles are invalidated whenever the table
+# they belong to is written to.
+#
+# The second two cases have no external effect. They are testing
+# that the internal cache of overflow page numbers is correctly
+# invalidated.
+#
+do_test incrblob-7.1.0 {
+ execsql {
+ BEGIN;
+ DROP TABLE blobs;
+ CREATE TABLE t1 (a, b, c, d BLOB);
+ INSERT INTO t1(a, b, c, d) VALUES(1, 2, 3, 4);
+ COMMIT;
+ }
+} {}
+
+foreach {tn arg} {1 "" 2 -readonly} {
+
+ execsql {
+ UPDATE t1 SET d = zeroblob(10000);
+ }
+
+ do_test incrblob-7.1.$tn.1 {
+ set ::b [eval db incrblob $arg t1 d 1]
+ binary scan [sqlite3_blob_read $::b 5000 5] c* c
+ set c
+ } {0 0 0 0 0}
+ do_test incrblob-7.1.$tn.2 {
+ execsql {
+ UPDATE t1 SET d = 15;
+ }
+ } {}
+ do_test incrblob-7.1.$tn.3 {
+ set rc [catch { sqlite3_blob_read $::b 5000 5 } msg]
+ list $rc $msg
+ } {1 SQLITE_ABORT}
+ do_test incrblob-7.1.$tn.4 {
+ execsql {
+ SELECT d FROM t1;
+ }
+ } {15}
+ do_test incrblob-7.1.$tn.5 {
+ set rc [catch { close $::b } msg]
+ list $rc $msg
+ } {0 {}}
+ do_test incrblob-7.1.$tn.6 {
+ execsql {
+ SELECT d FROM t1;
+ }
+ } {15}
+
+}
+
+set fd [open [info script]]
+fconfigure $fd -translation binary
+set ::data [read $fd 14000]
+close $fd
+
+db close
+forcedelete test.db test.db-journal
+sqlite3 db test.db
+
+do_test incrblob-7.2.1 {
+ execsql {
+ PRAGMA auto_vacuum = "incremental";
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b); -- root@page3
+ INSERT INTO t1 VALUES(123, $::data);
+ }
+ set ::b [db incrblob -readonly t1 b 123]
+ fconfigure $::b -translation binary
+ read $::b
+} $::data
+do_test incrblob-7.2.2 {
+ execsql {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b); -- root@page4
+ }
+ seek $::b 0
+ read $::b
+} $::data
+do_test incrblob-7.2.3 {
+ close $::b
+ execsql {
+ SELECT rootpage FROM sqlite_master;
+ }
+} {3 4}
+
+set ::otherdata "[string range $::data 0 1000][string range $::data 1001 end]"
+do_test incrblob-7.3.1 {
+ execsql {
+ INSERT INTO t2 VALUES(456, $::otherdata);
+ }
+ set ::b [db incrblob -readonly t2 b 456]
+ fconfigure $::b -translation binary
+ read $::b
+} $::otherdata
+do_test incrblob-7.3.2 {
+ expr [file size test.db]/1024
+} 30
+do_test incrblob-7.3.3 {
+ execsql {
+ DELETE FROM t1 WHERE a = 123;
+ PRAGMA INCREMENTAL_VACUUM(0);
+ }
+ seek $::b 0
+ read $::b
+} $::otherdata
+
+# Attempt to write on a read-only blob. Make sure the error code
+# gets set. Ticket #2464.
+#
+do_test incrblob-7.4 {
+ set rc [catch {sqlite3_blob_write $::b 10 HELLO} msg]
+ lappend rc $msg
+} {1 SQLITE_READONLY}
+do_test incrblob-7.5 {
+ sqlite3_errcode db
+} {SQLITE_READONLY}
+do_test incrblob-7.6 {
+ sqlite3_errmsg db
+} {attempt to write a readonly database}
+
+# Test that if either the "offset" or "amount" arguments to
+# sqlite3_blob_write() are less than zero, SQLITE_ERROR is returned.
+#
+do_test incrblob-8.1 {
+ execsql { INSERT INTO t1 VALUES(314159, 'sqlite') }
+ set ::b [db incrblob t1 b 314159]
+ fconfigure $::b -translation binary
+ set rc [catch {sqlite3_blob_write $::b 10 HELLO -1} msg]
+ lappend rc $msg
+} {1 SQLITE_ERROR}
+do_test incrblob-8.2 {
+ sqlite3_errcode db
+} {SQLITE_ERROR}
+do_test incrblob-8.3 {
+ set rc [catch {sqlite3_blob_write $::b -1 HELLO 5} msg]
+ lappend rc $msg
+} {1 SQLITE_ERROR}
+do_test incrblob-8.4 {
+ sqlite3_errcode db
+} {SQLITE_ERROR}
+do_test incrblob-8.5 {
+ execsql {SELECT b FROM t1 WHERE a = 314159}
+} {sqlite}
+do_test incrblob-8.6 {
+ set rc [catch {sqlite3_blob_write $::b 0 etilqs 6} msg]
+ lappend rc $msg
+} {0 {}}
+do_test incrblob-8.7 {
+ execsql {SELECT b FROM t1 WHERE a = 314159}
+} {etilqs}
+
+# The following test case exposes an instance in the blob code where
+# an error message was set using a call similar to sqlite3_mprintf(zErr),
+# where zErr is an arbitrary string. This is no good if the string contains
+# characters that can be mistaken for printf() formatting directives.
+#
+do_test incrblob-9.1 {
+ list [catch { db incrblob t1 "A tricky column name %s%s" 1 } msg] $msg
+} {1 {no such column: "A tricky column name %s%s"}}
+
+
+finish_test
diff --git a/test/incrblob2.test b/test/incrblob2.test
new file mode 100644
index 0000000..9046de2
--- /dev/null
+++ b/test/incrblob2.test
@@ -0,0 +1,418 @@
+# 2008 June 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test that it is possible to have two open blob handles on a single
+# blob object.
+#
+# $Id: incrblob2.test,v 1.11 2009/06/29 06:00:37 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!autovacuum || !pragma || !incrblob} {
+ finish_test
+ return
+}
+
+do_test incrblob2-1.0 {
+ execsql {
+ CREATE TABLE blobs(id INTEGER PRIMARY KEY, data BLOB);
+ INSERT INTO blobs VALUES(NULL, zeroblob(5000));
+ INSERT INTO blobs VALUES(NULL, zeroblob(5000));
+ INSERT INTO blobs VALUES(NULL, zeroblob(5000));
+ INSERT INTO blobs VALUES(NULL, zeroblob(5000));
+ }
+} {}
+
+foreach iOffset [list 0 256 4094] {
+ do_test incrblob2-1.$iOffset.1 {
+ set fd [db incrblob blobs data 1]
+ puts $fd "[string repeat x $iOffset]SQLite version 3.6.0"
+ close $fd
+ } {}
+
+ do_test incrblob2-1.$iOffset.2 {
+ set fd1 [db incrblob blobs data 1]
+ set fd2 [db incrblob blobs data 1]
+ fconfigure $fd1 -buffering none
+ fconfigure $fd2 -buffering none
+ if {$iOffset != 0} {
+ seek $fd2 $iOffset start
+ seek $fd1 $iOffset start
+ }
+ read $fd1 6
+ } {SQLite}
+
+ do_test incrblob2-1.$iOffset.3 {
+ read $fd2 6
+ } {SQLite}
+
+ do_test incrblob2-1.$iOffset.4 {
+ seek $fd2 $iOffset start
+ seek $fd1 $iOffset start
+ puts -nonewline $fd2 "etiLQS"
+ } {}
+
+
+ do_test incrblob2-1.$iOffset.5 {
+ seek $fd1 $iOffset start
+ read $fd1 6
+ } {etiLQS}
+
+ do_test incrblob2-1.$iOffset.6 {
+ seek $fd2 $iOffset start
+ read $fd2 6
+ } {etiLQS}
+
+ do_test incrblob2-1.$iOffset.7 {
+ seek $fd1 $iOffset start
+ read $fd1 6
+ } {etiLQS}
+
+ do_test incrblob2-1.$iOffset.8 {
+ close $fd1
+ close $fd2
+ } {}
+}
+
+#--------------------------------------------------------------------------
+
+foreach iOffset [list 0 256 4094] {
+
+ do_test incrblob2-2.$iOffset.1 {
+ set fd1 [db incrblob blobs data 1]
+ seek $fd1 [expr $iOffset - 5000] end
+ fconfigure $fd1 -buffering none
+
+ set fd2 [db incrblob blobs data 1]
+ seek $fd2 [expr $iOffset - 5000] end
+ fconfigure $fd2 -buffering none
+
+ puts -nonewline $fd1 "123456"
+ } {}
+
+ do_test incrblob2-2.$iOffset.2 {
+ read $fd2 6
+ } {123456}
+
+ do_test incrblob2-2.$iOffset.3 {
+ close $fd1
+ close $fd2
+ } {}
+}
+
+do_test incrblob2-3.1 {
+ set fd1 [db incrblob blobs data 1]
+ fconfigure $fd1 -buffering none
+} {}
+do_test incrblob2-3.2 {
+ execsql {
+ INSERT INTO blobs VALUES(5, zeroblob(10240));
+ }
+} {}
+do_test incrblob2-3.3 {
+ set rc [catch { read $fd1 6 } msg]
+ list $rc $msg
+} {0 123456}
+do_test incrblob2-3.4 {
+ close $fd1
+} {}
+
+#--------------------------------------------------------------------------
+# The following tests - incrblob2-4.* - test that blob handles are
+# invalidated at the correct times.
+#
+do_test incrblob2-4.1 {
+ unset -nocomplain data
+ db eval BEGIN
+ db eval { CREATE TABLE t1(id INTEGER PRIMARY KEY, data BLOB); }
+ for {set ii 1} {$ii < 100} {incr ii} {
+ set data [string repeat "blob$ii" 500]
+ db eval { INSERT INTO t1 VALUES($ii, $data) }
+ }
+ db eval COMMIT
+} {}
+
+proc aborted_handles {} {
+ global handles
+
+ set aborted {}
+ for {set ii 1} {$ii < 100} {incr ii} {
+ set str "blob$ii"
+ set nByte [string length $str]
+ set iOffset [expr $nByte * $ii * 2]
+
+ set rc [catch {sqlite3_blob_read $handles($ii) $iOffset $nByte} msg]
+ if {$rc && $msg eq "SQLITE_ABORT"} {
+ lappend aborted $ii
+ } else {
+ if {$rc || $msg ne $str} {
+ error "blob $ii: $msg"
+ }
+ }
+ }
+ set aborted
+}
+
+do_test incrblob2-4.2 {
+ for {set ii 1} {$ii < 100} {incr ii} {
+ set handles($ii) [db incrblob t1 data $ii]
+ }
+ aborted_handles
+} {}
+
+# Update row 3. This should abort handle 3 but leave all others untouched.
+#
+do_test incrblob2-4.3 {
+ db eval {UPDATE t1 SET data = data || '' WHERE id = 3}
+ aborted_handles
+} {3}
+
+# Test that a write to handle 3 also returns SQLITE_ABORT.
+#
+do_test incrblob2-4.3.1 {
+ set rc [catch {sqlite3_blob_write $::handles(3) 10 HELLO} msg]
+ list $rc $msg
+} {1 SQLITE_ABORT}
+
+# Delete row 14. This should abort handle 6 but leave all others untouched.
+#
+do_test incrblob2-4.4 {
+ db eval {DELETE FROM t1 WHERE id = 14}
+ aborted_handles
+} {3 14}
+
+# Change the rowid of row 15 to 102. Should abort handle 15.
+#
+do_test incrblob2-4.5 {
+ db eval {UPDATE t1 SET id = 102 WHERE id = 15}
+ aborted_handles
+} {3 14 15}
+
+# Clobber row 92 using INSERT OR REPLACE.
+#
+do_test incrblob2-4.6 {
+ db eval {INSERT OR REPLACE INTO t1 VALUES(92, zeroblob(1000))}
+ aborted_handles
+} {3 14 15 92}
+
+# Clobber row 65 using UPDATE OR REPLACE on row 35. This should abort
+# handles 35 and 65.
+#
+do_test incrblob2-4.7 {
+ db eval {UPDATE OR REPLACE t1 SET id = 65 WHERE id = 35}
+ aborted_handles
+} {3 14 15 35 65 92}
+
+# Insert a couple of new rows. This should not invalidate any handles.
+#
+do_test incrblob2-4.9 {
+ db eval {INSERT INTO t1 SELECT NULL, data FROM t1}
+ aborted_handles
+} {3 14 15 35 65 92}
+
+# Delete all rows from 1 to 25. This should abort all handles up to 25.
+#
+do_test incrblob2-4.9 {
+ db eval {DELETE FROM t1 WHERE id >=1 AND id <= 25}
+ aborted_handles
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 35 65 92}
+
+# Delete the whole table (this will use sqlite3BtreeClearTable()). All handles
+# should now be aborted.
+#
+do_test incrblob2-4.10 {
+ db eval {DELETE FROM t1}
+ aborted_handles
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99}
+
+do_test incrblob2-4.1.X {
+ for {set ii 1} {$ii < 100} {incr ii} {
+ close $handles($ii)
+ }
+} {}
+
+#--------------------------------------------------------------------------
+# The following tests - incrblob2-5.* - test that in shared cache an open
+# blob handle counts as a read-lock on its table.
+#
+ifcapable shared_cache {
+ db close
+ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+ do_test incrblob2-5.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+
+ execsql {
+ INSERT INTO t1 VALUES(1, 'abcde');
+ }
+ } {}
+
+ do_test incrblob2-5.2 {
+ catchsql { INSERT INTO t1 VALUES(2, 'fghij') } db2
+ } {0 {}}
+
+ do_test incrblob2-5.3 {
+ set blob [db incrblob t1 data 1]
+ catchsql { INSERT INTO t1 VALUES(3, 'klmno') } db2
+ } {1 {database table is locked}}
+
+ do_test incrblob2-5.4 {
+ close $blob
+ execsql BEGIN db2
+ catchsql { INSERT INTO t1 VALUES(4, 'pqrst') } db2
+ } {0 {}}
+
+ do_test incrblob2-5.5 {
+ set rc [catch { db incrblob -readonly t1 data 1 } msg]
+ list $rc $msg
+ } {1 {database table is locked: t1}}
+
+ do_test incrblob2-5.6 {
+ execsql { PRAGMA read_uncommitted=1 }
+ set blob [db incrblob -readonly t1 data 4]
+ read $blob
+ } {pqrst}
+
+ do_test incrblob2-5.7 {
+ catchsql { INSERT INTO t1 VALUES(3, 'klmno') } db2
+ } {0 {}}
+
+ do_test incrblob2-5.8 {
+ close $blob
+ } {}
+
+ db2 close
+ db close
+ sqlite3_enable_shared_cache $::enable_shared_cache
+}
+
+#--------------------------------------------------------------------------
+# The following tests - incrblob2-6.* - test a specific scenario that might
+# be causing an error.
+#
+sqlite3 db test.db
+do_test incrblob2-6.1 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1, zeroblob(100));
+ }
+
+ set rdHandle [db incrblob -readonly t1 data 1]
+ set wrHandle [db incrblob t1 data 1]
+
+ sqlite3_blob_read $rdHandle 0 100
+
+ sqlite3_blob_write $wrHandle 0 ABCDEF
+
+ close $wrHandle
+ close $rdHandle
+} {}
+
+do_test incrblob2-6.2 {
+ set rdHandle [db incrblob -readonly t1 data 1]
+ sqlite3_blob_read $rdHandle 0 2
+} {AB}
+
+do_test incrblob2-6.3 {
+ set wrHandle [db incrblob t1 data 1]
+ sqlite3_blob_write $wrHandle 0 ZZZZZZZZZZ
+ sqlite3_blob_read $rdHandle 2 4
+} {ZZZZ}
+
+do_test incrblob2-6.4 {
+ close $wrHandle
+ close $rdHandle
+} {}
+
+sqlite3_memory_highwater 1
+do_test incrblob2-7.1 {
+ db eval {
+ CREATE TABLE t2(B BLOB);
+ INSERT INTO t2 VALUES(zeroblob(10 * 1024 * 1024));
+ }
+ expr {[sqlite3_memory_highwater]<(5 * 1024 * 1024)}
+} {1}
+
+do_test incrblob2-7.2 {
+ set h [db incrblob t2 B 1]
+ expr {[sqlite3_memory_highwater]<(5 * 1024 * 1024)}
+} {1}
+
+do_test incrblob2-7.3 {
+ seek $h 0 end
+ tell $h
+} [expr 10 * 1024 * 1024]
+
+do_test incrblob2-7.4 {
+ expr {[sqlite3_memory_highwater]<(5 * 1024 * 1024)}
+} {1}
+
+do_test incrblob2-7.5 {
+ close $h
+} {}
+
+#---------------------------------------------------------------------------
+# The following tests, incrblob2-8.*, test that nothing terrible happens
+# when a statement transaction is rolled back while there are open
+# incremental-blob handles. At one point an assert() was failing when
+# this was attempted.
+#
+do_test incrblob2-8.1 {
+ execsql BEGIN
+ set h [db incrblob t2 B 1]
+ set rc [catch {
+ db eval {SELECT rowid FROM t2} { execsql "DROP TABLE t2" }
+ } msg]
+ list $rc $msg
+} {1 {database table is locked}}
+do_test incrblob2-8.2 {
+ close $h
+ execsql COMMIT
+} {}
+do_test incrblob2-8.3 {
+ execsql {
+ CREATE TABLE t3(a INTEGER UNIQUE, b TEXT);
+ INSERT INTO t3 VALUES(1, 'aaaaaaaaaaaaaaaaaaaa');
+ INSERT INTO t3 VALUES(2, 'bbbbbbbbbbbbbbbbbbbb');
+ INSERT INTO t3 VALUES(3, 'cccccccccccccccccccc');
+ INSERT INTO t3 VALUES(4, 'dddddddddddddddddddd');
+ INSERT INTO t3 VALUES(5, 'eeeeeeeeeeeeeeeeeeee');
+ }
+} {}
+do_test incrblob2-8.4 {
+ execsql BEGIN
+ set h [db incrblob t3 b 3]
+ sqlite3_blob_read $h 0 20
+} {cccccccccccccccccccc}
+do_test incrblob2-8.5 {
+ catchsql {UPDATE t3 SET a = 6 WHERE a > 3}
+} {1 {column a is not unique}}
+do_test incrblob2-8.6 {
+ catchsql {UPDATE t3 SET a = 6 WHERE a > 3}
+} {1 {column a is not unique}}
+do_test incrblob2-8.7 {
+ sqlite3_blob_read $h 0 20
+} {cccccccccccccccccccc}
+do_test incrblob2-8.8 {
+ catchsql {UPDATE t3 SET a = 6 WHERE a = 3 OR a = 5}
+} {1 {column a is not unique}}
+do_test incrblob2-8.9 {
+ set rc [catch {sqlite3_blob_read $h 0 20} msg]
+ list $rc $msg
+} {1 SQLITE_ABORT}
+do_test incrblob2-8.X {
+ close $h
+} {}
+
+finish_test
diff --git a/test/incrblob3.test b/test/incrblob3.test
new file mode 100644
index 0000000..4c49f15
--- /dev/null
+++ b/test/incrblob3.test
@@ -0,0 +1,272 @@
+# 2010 October 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+sqlite3 db test.db
+sqlite3_db_config_lookaside db 0 0 0
+
+do_execsql_test incrblob3-1.1 {
+ CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB);
+ INSERT INTO blobs VALUES(1, zeroblob(100));
+ INSERT INTO blobs VALUES(2, zeroblob(100));
+} {}
+
+# Test the sqlite3_blob_reopen()/read()/write() functions.
+#
+do_test incrblob3-1.2 {
+ set ::blob [db incrblob blobs v 1]
+ puts $::blob "hello world"
+} {}
+
+do_test incrblob3-1.3 {
+ sqlite3_blob_reopen $::blob 2
+ puts $::blob "world hello"
+} {}
+
+do_test incrblob3-1.4 {
+ sqlite3_blob_reopen $::blob 1
+ gets $::blob
+} {hello world}
+
+do_test incrblob3-1.5 {
+ sqlite3_blob_reopen $::blob 2
+ gets $::blob
+} {world hello}
+
+do_test incrblob3-1.6 { close $::blob } {}
+
+# Test some error conditions.
+#
+# incrblob3-2.1: Attempting to reopen a row that does not exist.
+# incrblob3-2.2: Attempting to reopen a row that does not contain a blob
+# or text value.
+#
+do_test incrblob3-2.1.1 {
+ set ::blob [db incrblob blobs v 1]
+ list [catch {sqlite3_blob_reopen $::blob 3} msg] $msg
+} {1 SQLITE_ERROR}
+do_test incrblob3-2.1.2 {
+ list [sqlite3_errcode db] [sqlite3_errmsg db]
+} {SQLITE_ERROR {no such rowid: 3}}
+do_test incrblob3-2.1.3 {
+ list [catch {sqlite3_blob_reopen $::blob 1} msg] $msg
+} {1 SQLITE_ABORT}
+do_test incrblob3-2.1.4 { close $::blob } {}
+
+do_execsql_test incrblob3-2.2.1 {
+ INSERT INTO blobs VALUES(3, 42);
+ INSERT INTO blobs VALUES(4, 54.4);
+ INSERT INTO blobs VALUES(5, NULL);
+}
+foreach {tn rowid type} {
+ 1 3 integer
+ 2 4 real
+ 3 5 null
+} {
+ do_test incrblob3-2.2.$tn.1 {
+ set ::blob [db incrblob blobs v 1]
+ list [catch {sqlite3_blob_reopen $::blob $rowid} msg] $msg
+ } {1 SQLITE_ERROR}
+ do_test incrblob3-2.2.$tn.2 {
+ list [sqlite3_errcode db] [sqlite3_errmsg db]
+ } "SQLITE_ERROR {cannot open value of type $type}"
+
+ do_test incrblob3-2.2.$tn.3 {
+ list [catch {sqlite3_blob_reopen $::blob 1} msg] $msg
+ } {1 SQLITE_ABORT}
+ do_test incrblob3-2.2.$tn.4 {
+ list [catch {sqlite3_blob_read $::blob 0 10} msg] $msg
+ } {1 SQLITE_ABORT}
+ do_test incrblob3-2.2.$tn.5 {
+ list [catch {sqlite3_blob_write $::blob 0 "abcd"} msg] $msg
+ } {1 SQLITE_ABORT}
+ do_test incrblob3-2.2.$tn.6 {
+ sqlite3_blob_bytes $::blob
+ } {0}
+
+ do_test incrblob3-2.2.$tn.7 { close $::blob } {}
+}
+
+# Test that passing NULL to sqlite3_blob_XXX() APIs returns SQLITE_MISUSE.
+#
+# incrblob3-3.1: sqlite3_blob_reopen()
+# incrblob3-3.2: sqlite3_blob_read()
+# incrblob3-3.3: sqlite3_blob_write()
+# incrblob3-3.4: sqlite3_blob_bytes()
+#
+do_test incrblob3-3.1 {
+ list [catch {sqlite3_blob_reopen {} 3} msg] $msg
+} {1 SQLITE_MISUSE}
+
+do_test incrblob3-3.2 {
+ list [catch {sqlite3_blob_read {} 0 10} msg] $msg
+} {1 SQLITE_MISUSE}
+
+do_test incrblob3-3.3 {
+ list [catch {sqlite3_blob_write {} 0 "abcd"} msg] $msg
+} {1 SQLITE_MISUSE}
+
+do_test incrblob3-3.4 { sqlite3_blob_bytes {} } {0}
+
+do_test incrblob3-3.5 { sqlite3_blob_close {} } {}
+
+# Test out-of-range reading and writing
+#
+do_test incrblob3-4.1 {
+ set ::blob [db incrblob blobs v 1]
+ sqlite3_blob_bytes $::blob
+} {100}
+do_test incrblob3-4.2 {
+ list [catch { sqlite3_blob_read $::blob -1 10 } msg] $msg
+} {1 SQLITE_ERROR}
+do_test incrblob3-4.3 {
+ list [catch { sqlite3_blob_read $::blob 0 -10 } msg] $msg
+} {1 SQLITE_ERROR}
+do_test incrblob3-4.4 {
+ list [catch { sqlite3_blob_read $::blob 95 10 } msg] $msg
+} {1 SQLITE_ERROR}
+do_test incrblob3-4.5 {
+ list [catch { sqlite3_blob_write $::blob -1 "abcdefghij" 10 } msg] $msg
+} {1 SQLITE_ERROR}
+do_test incrblob3-4.6 {
+ list [catch { sqlite3_blob_write $::blob 0 "abcdefghij" -10 } msg] $msg
+} {1 SQLITE_ERROR}
+do_test incrblob3-4.7 {
+ list [catch { sqlite3_blob_write $::blob 95 "abcdefghij" } msg] $msg
+} {1 SQLITE_ERROR}
+
+do_test incrblob3-4.8 { close $::blob } {}
+
+# Test that modifying the row a blob handle points to aborts the blob.
+#
+do_test incrblob3-5.1 {
+ set ::blob [db incrblob blobs v 1]
+ sqlite3_blob_bytes $::blob
+} {100}
+do_test incrblob3-5.2 {
+ execsql { UPDATE blobs SET v = '123456789012345678901234567890' WHERE k = 1 }
+ list [catch { sqlite3_blob_read $::blob 0 10 } msg] $msg
+} {1 SQLITE_ABORT}
+
+# Test various errors that can occur in sqlite3_blob_open():
+#
+# 1. Trying to open a virtual table column.
+# 2. Trying to open a view column.
+# 3. Trying to open a column that does not exist.
+# 4. Trying to open a read/write handle on an indexed column.
+# 5. Trying to open a read/write handle on the child key of an FK constraint.
+#
+ifcapable fts3 {
+ do_test incrblob3-6.1 {
+ execsql {
+ CREATE VIRTUAL TABLE ft USING fts3;
+ INSERT INTO ft VALUES('rules to open a column to which');
+ }
+
+ list [catch { db incrblob ft content 1 } msg] $msg
+ } {1 {cannot open virtual table: ft}}
+}
+ifcapable view {
+ do_test incrblob3-6.2 {
+ execsql { CREATE VIEW v1 AS SELECT * FROM blobs }
+ list [catch { db incrblob v1 content 1 } msg] $msg
+ } {1 {cannot open view: v1}}
+}
+
+do_test incrblob3-6.3 {
+ list [catch { db incrblob blobs content 1 } msg] $msg
+} {1 {no such column: "content"}}
+
+do_test incrblob3-6.4.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b);
+ INSERT INTO t1 VALUES(zeroblob(100), zeroblob(100));
+ }
+ list [catch { db incrblob t1 b 1 } msg] $msg
+} {1 {cannot open indexed column for writing}}
+do_test incrblob3-6.4.2 {
+ set ::blob [db incrblob t1 a 1]
+ close $::blob
+} {}
+do_test incrblob3-6.4.3 {
+ set ::blob [db incrblob -readonly t1 b 1]
+ close $::blob
+} {}
+
+do_test incrblob3-6.5.1 {
+ execsql {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(a, b REFERENCES p1);
+ PRAGMA foreign_keys = 1;
+ INSERT INTO p1 VALUES(zeroblob(100));
+ INSERT INTO c1 VALUES(zeroblob(100), zeroblob(100));
+ }
+ list [catch { db incrblob c1 b 1 } msg] $msg
+} {1 {cannot open foreign key column for writing}}
+
+do_test incrblob3-6.5.2 {
+ set ::blob [db incrblob c1 a 1]
+ close $::blob
+} {}
+do_test incrblob3-6.5.3 {
+ set ::blob [db incrblob -readonly c1 b 1]
+ close $::blob
+} {}
+do_test incrblob3-6.5.4 {
+ execsql { PRAGMA foreign_keys = 0 }
+ set ::blob [db incrblob c1 b 1]
+ close $::blob
+} {}
+
+
+# Test that sqlite3_blob_open() handles transient and persistent schema
+# errors correctly.
+#
+do_test incrblob3-7.1 {
+ sqlite3 db2 test.db
+ sqlite3_db_config_lookaside db2 0 0 0
+ execsql { CREATE TABLE t2(x) } db2
+ set ::blob [db incrblob blobs v 1]
+ close $::blob
+} {}
+db2 close
+
+testvfs tvfs -default 1
+tvfs filter xAccess
+tvfs script access_method
+
+proc access_method {args} {
+ set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
+ incr schemacookie
+ hexio_write test.db 40 [hexio_render_int32 $schemacookie]
+
+ set dbversion [hexio_get_int [hexio_read test.db 24 4]]
+ incr dbversion
+ hexio_write test.db 24 [hexio_render_int32 $dbversion]
+
+ return ""
+}
+
+do_test incrblob3-7.2 {
+ sqlite3 db test.db
+ sqlite3_db_config_lookaside db 0 0 0
+ list [catch {db incrblob blobs v 1} msg] $msg
+} {1 {database schema has changed}}
+db close
+tvfs delete
+
+finish_test
+
diff --git a/test/incrblob_err.test b/test/incrblob_err.test
new file mode 100644
index 0000000..35d37fe
--- /dev/null
+++ b/test/incrblob_err.test
@@ -0,0 +1,139 @@
+# 2007 May 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: incrblob_err.test,v 1.14 2008/07/18 17:16:27 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!incrblob || !memdebug || !tclvar} {
+ finish_test
+ return
+}
+
+source $testdir/malloc_common.tcl
+
+unset -nocomplain ::fd ::data
+set ::fd [open [info script]]
+set ::data [read $::fd]
+close $::fd
+
+do_malloc_test 1 -tclprep {
+ set bytes [file size [info script]]
+ execsql {
+ CREATE TABLE blobs(k, v BLOB);
+ INSERT INTO blobs VALUES(1, zeroblob($::bytes));
+ }
+} -tclbody {
+ set ::blob [db incrblob blobs v 1]
+ fconfigure $::blob -translation binary
+ set rc [catch {puts -nonewline $::blob $::data}]
+ if {$rc} { error "out of memory" }
+}
+
+do_malloc_test 2 -tclprep {
+ execsql {
+ CREATE TABLE blobs(k, v BLOB);
+ INSERT INTO blobs VALUES(1, $::data);
+ }
+} -tclbody {
+ set ::blob [db incrblob blobs v 1]
+ set rc [catch {set ::r [read $::blob]}]
+ if {$rc} {
+ error "out of memory"
+ } elseif {$::r ne $::data} {
+ error "Bad data read..."
+ }
+}
+
+do_malloc_test 3 -tclprep {
+ execsql {
+ CREATE TABLE blobs(k, v BLOB);
+ INSERT INTO blobs VALUES(1, $::data);
+ }
+} -tclbody {
+ set ::blob [db incrblob blobs v 1]
+ set rc [catch {set ::r [read $::blob]}]
+ if {$rc} {
+ error "out of memory"
+ } elseif {$::r ne $::data} {
+ error "Bad data read..."
+ }
+ set rc [catch {close $::blob}]
+ if {$rc} {
+ error "out of memory"
+ }
+}
+
+do_ioerr_test incrblob_err-4 -cksum 1 -sqlprep {
+ CREATE TABLE blobs(k, v BLOB);
+ INSERT INTO blobs VALUES(1, $::data);
+} -tclbody {
+ set ::blob [db incrblob blobs v 1]
+ read $::blob
+}
+
+do_ioerr_test incrblob_err-5 -cksum 1 -sqlprep {
+ CREATE TABLE blobs(k, v BLOB);
+ INSERT INTO blobs VALUES(1, zeroblob(length(CAST($::data AS BLOB))));
+} -tclbody {
+ set ::blob [db incrblob blobs v 1]
+ fconfigure $::blob -translation binary
+ puts -nonewline $::blob $::data
+ close $::blob
+}
+
+do_ioerr_test incrblob_err-6 -cksum 1 -sqlprep {
+ CREATE TABLE blobs(k, v BLOB);
+ INSERT INTO blobs VALUES(1, $::data || $::data || $::data);
+} -tclbody {
+ set ::blob [db incrblob blobs v 1]
+ fconfigure $::blob -translation binary
+ seek $::blob -20 end
+ puts -nonewline $::blob "12345678900987654321"
+ close $::blob
+}
+
+do_ioerr_test incrblob_err-7 -cksum 1 -sqlprep {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB);
+ INSERT INTO blobs VALUES(1, zeroblob(500 * 1020));
+} -tclbody {
+ # Read some data from the end of the large blob inserted into table
+ # "blobs". This forces the IO error to occur while reading a pointer
+ # map page for the purposes of seeking to the end of the blob.
+ #
+ sqlite3 db2 test.db
+ set ::blob [db2 incrblob blobs v 1]
+ sqlite3_blob_read $::blob [expr 500*1020-20] 20
+ close $::blob
+}
+catch {db2 close}
+
+do_ioerr_test incrblob_err-8 -cksum 1 -sqlprep {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB);
+ INSERT INTO blobs VALUES(1, zeroblob(500 * 1020));
+} -tclbody {
+ # Read some data from the end of the large blob inserted into table
+ # "blobs". This forces the IO error to occur while reading a pointer
+ # map page for the purposes of seeking to the end of the blob.
+ #
+ sqlite3 db2 test.db
+ set ::blob [db2 incrblob blobs v 1]
+ sqlite3_blob_write $::blob [expr 500*1020-20] 12345678900987654321
+ close $::blob
+}
+
+catch {db2 close}
+
+finish_test
diff --git a/test/incrblobfault.test b/test/incrblobfault.test
new file mode 100644
index 0000000..d125471
--- /dev/null
+++ b/test/incrblobfault.test
@@ -0,0 +1,70 @@
+# 2010 October 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix incrblobfault
+
+do_execsql_test 1.0 {
+ CREATE TABLE blob(x INTEGER PRIMARY KEY, v BLOB);
+ INSERT INTO blob VALUES(1, 'hello world');
+ INSERT INTO blob VALUES(2, 'world hello');
+ INSERT INTO blob SELECT NULL, v FROM blob;
+ INSERT INTO blob SELECT NULL, v FROM blob;
+ INSERT INTO blob SELECT NULL, v FROM blob;
+ INSERT INTO blob SELECT NULL, v FROM blob;
+ INSERT INTO blob SELECT NULL, v FROM blob;
+ INSERT INTO blob SELECT NULL, v FROM blob;
+ INSERT INTO blob SELECT NULL, v FROM blob;
+ INSERT INTO blob SELECT NULL, v FROM blob;
+ INSERT INTO blob SELECT NULL, v FROM blob;
+ INSERT INTO blob SELECT NULL, v FROM blob;
+}
+
+do_faultsim_test 1 -prep {
+ sqlite3 db test.db
+ set ::blob [db incrblob blob v 1]
+} -body {
+ if {[catch {sqlite3_blob_reopen $::blob 1000}]} {
+ error [sqlite3_errmsg db]
+ }
+} -test {
+ faultsim_test_result {0 {}}
+ close $::blob
+}
+
+do_faultsim_test 2 -prep {
+ sqlite3 db test.db
+ set ::blob [db incrblob blob v 1]
+} -body {
+ if {[catch {sqlite3_blob_reopen $::blob -1}]} {
+ error [sqlite3_errmsg db]
+ }
+} -test {
+ faultsim_test_result {1 {no such rowid: -1}}
+ close $::blob
+}
+
+do_faultsim_test 3 -prep {
+ sqlite3 db test.db
+} -body {
+ set ::blob [db incrblob blob v 1]
+ gets $::blob
+} -test {
+ faultsim_test_result {0 {hello world}}
+ catch { close $::blob }
+}
+
+finish_test
+
diff --git a/test/incrvacuum.test b/test/incrvacuum.test
new file mode 100644
index 0000000..91f5c8e
--- /dev/null
+++ b/test/incrvacuum.test
@@ -0,0 +1,786 @@
+# 2007 April 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the incremental vacuum feature.
+#
+# Note: There are also some tests for incremental vacuum and IO
+# errors in incrvacuum_ioerr.test.
+#
+# $Id: incrvacuum.test,v 1.23 2009/02/18 20:31:18 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build of the library does not support auto-vacuum, omit this
+# whole file.
+ifcapable {!autovacuum || !pragma} {
+ finish_test
+ return
+}
+
+#---------------------------------------------------------------------
+# Test the pragma on an empty database.
+#
+do_test incrvacuum-1.1 {
+ execsql {
+ pragma auto_vacuum;
+ }
+} $sqlite_options(default_autovacuum)
+do_test incrvacuum-1.2.0 {
+ # File size is sometimes 1 instead of 0 due to the hack we put in
+ # to work around ticket #3260. Search for comments on #3260 in
+ # os_unix.c.
+ expr {[file size test.db] > 1}
+} {0}
+do_test incrvacuum-1.2 {
+ # This command will create the database.
+ execsql {
+ pragma auto_vacuum = 'full';
+ pragma auto_vacuum;
+ }
+} {1}
+do_test incrvacuum-1.2.1 {
+ expr {[file size test.db] > 0}
+} {1}
+do_test incrvacuum-1.3 {
+ execsql {
+ pragma auto_vacuum = 'incremental';
+ pragma auto_vacuum;
+ }
+} {2}
+do_test incrvacuum-1.4 {
+ # In this case the invalid value is ignored and the auto_vacuum
+ # setting remains unchanged.
+ execsql {
+ pragma auto_vacuum = 'invalid';
+ pragma auto_vacuum;
+ }
+} {2}
+do_test incrvacuum-1.5 {
+ execsql {
+ pragma auto_vacuum = 1;
+ pragma auto_vacuum;
+ }
+} {1}
+do_test incrvacuum-1.6 {
+ execsql {
+ pragma auto_vacuum = '2';
+ pragma auto_vacuum;
+ }
+} {2}
+do_test incrvacuum-1.7 {
+ # Invalid value. auto_vacuum setting remains unchanged.
+ execsql {
+ pragma auto_vacuum = 5;
+ pragma auto_vacuum;
+ }
+} {2}
+
+#---------------------------------------------------------------------
+# Test the pragma on a non-empty database. It is possible to toggle
+# the connection between "full" and "incremental" mode, but not to
+# change from either of these to "none", or from "none" to "full" or
+# "incremental".
+#
+do_test incrvacuum-2.1 {
+ execsql {
+ pragma auto_vacuum = 1;
+ CREATE TABLE abc(a, b, c);
+ }
+} {}
+do_test incrvacuum-2.2 {
+ execsql {
+ pragma auto_vacuum = 'none';
+ pragma auto_vacuum;
+ }
+} {1}
+do_test incrvacuum-2.2.1 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ pragma auto_vacuum;
+ }
+} {1}
+do_test incrvacuum-2.3 {
+ execsql {
+ pragma auto_vacuum = 'incremental';
+ pragma auto_vacuum;
+ }
+} {2}
+do_test incrvacuum-2.4 {
+ execsql {
+ pragma auto_vacuum = 'full';
+ pragma auto_vacuum;
+ }
+} {1}
+
+#---------------------------------------------------------------------
+# Test that when the auto_vacuum mode is "incremental", the database
+# does not shrink when pages are removed from it. But it does if
+# the mode is set to "full".
+#
+do_test incrvacuum-3.1 {
+ execsql {
+ pragma auto_vacuum;
+ }
+} {1}
+do_test incrvacuum-3.2 {
+ set ::str [string repeat 1234567890 110]
+ execsql {
+ PRAGMA auto_vacuum = 2;
+ BEGIN;
+ CREATE TABLE tbl2(str);
+ INSERT INTO tbl2 VALUES($::str);
+ COMMIT;
+ }
+ # 5 pages:
+ #
+ # 1 -> database header
+ # 2 -> first back-pointer page
+ # 3 -> table abc
+ # 4 -> table tbl2
+ # 5 -> table tbl2 overflow page.
+ #
+ expr {[file size test.db] / 1024}
+} {5}
+do_test incrvacuum-3.3 {
+ execsql {
+ DROP TABLE abc;
+ DELETE FROM tbl2;
+ }
+ expr {[file size test.db] / 1024}
+} {5}
+do_test incrvacuum-3.4 {
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ INSERT INTO tbl2 VALUES('hello world');
+ }
+ expr {[file size test.db] / 1024}
+} {3}
+
+#---------------------------------------------------------------------
+# Try to run a very simple incremental vacuum. Also verify that
+# PRAGMA incremental_vacuum is a harmless no-op against a database that
+# does not support auto-vacuum.
+#
+do_test incrvacuum-4.1 {
+ set ::str [string repeat 1234567890 110]
+ execsql {
+ PRAGMA auto_vacuum = 2;
+ INSERT INTO tbl2 VALUES($::str);
+ CREATE TABLE tbl1(a, b, c);
+ }
+ expr {[file size test.db] / 1024}
+} {5}
+do_test incrvacuum-4.2 {
+ execsql {
+ DELETE FROM tbl2;
+ DROP TABLE tbl1;
+ }
+ expr {[file size test.db] / 1024}
+} {5}
+do_test incrvacuum-4.3 {
+ set ::nStep 0
+ db eval {pragma incremental_vacuum(10)} {
+ incr ::nStep
+ }
+ list [expr {[file size test.db] / 1024}] $::nStep
+} {3 2}
+
+#---------------------------------------------------------------------
+# The following tests - incrvacuum-5.* - test incremental vacuum
+# from within a transaction.
+#
+do_test incrvacuum-5.1.1 {
+ expr {[file size test.db] / 1024}
+} {3}
+do_test incrvacuum-5.1.2 {
+ execsql {
+ BEGIN;
+ DROP TABLE tbl2;
+ PRAGMA incremental_vacuum;
+ COMMIT;
+ }
+ expr {[file size test.db] / 1024}
+} {1}
+
+do_test incrvacuum-5.2.1 {
+ set ::str [string repeat abcdefghij 110]
+ execsql {
+ BEGIN;
+ CREATE TABLE tbl1(a);
+ INSERT INTO tbl1 VALUES($::str);
+ PRAGMA incremental_vacuum; -- this is a no-op.
+ COMMIT;
+ }
+ expr {[file size test.db] / 1024}
+} {4}
+do_test incrvacuum-5.2.2 {
+ set ::str [string repeat abcdefghij 110]
+ execsql {
+ BEGIN;
+ INSERT INTO tbl1 VALUES($::str);
+ INSERT INTO tbl1 SELECT * FROM tbl1;
+ DELETE FROM tbl1 WHERE oid%2; -- Put 2 overflow pages on free-list.
+ COMMIT;
+ }
+ expr {[file size test.db] / 1024}
+} {7}
+do_test incrvacuum-5.2.3 {
+ execsql {
+ BEGIN;
+ PRAGMA incremental_vacuum; -- Vacuum up the two pages.
+ CREATE TABLE tbl2(b); -- Use one free page as a table root.
+ INSERT INTO tbl2 VALUES('a nice string');
+ COMMIT;
+ }
+ expr {[file size test.db] / 1024}
+} {6}
+do_test incrvacuum-5.2.4 {
+ execsql {
+ SELECT * FROM tbl2;
+ }
+} {{a nice string}}
+do_test incrvacuum-5.2.5 {
+ execsql {
+ DROP TABLE tbl1;
+ DROP TABLE tbl2;
+ PRAGMA incremental_vacuum;
+ }
+ expr {[file size test.db] / 1024}
+} {1}
+
+
+# Test cases incrvacuum-5.3.* use the following list as input data.
+# Two new databases are opened, one with incremental vacuum enabled,
+# the other with no auto-vacuum completely disabled. After executing
+# each element of the following list on both databases, test that
+# the integrity-check passes and the contents of each are identical.
+#
+set TestScriptList [list {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ CREATE INDEX t1_i ON t1(a);
+ CREATE INDEX t2_i ON t2(a);
+} {
+ INSERT INTO t1 VALUES($::str1, $::str2);
+ INSERT INTO t1 VALUES($::str1||$::str2, $::str2||$::str1);
+ INSERT INTO t2 SELECT b, a FROM t1;
+ INSERT INTO t2 SELECT a, b FROM t1;
+ INSERT INTO t1 SELECT b, a FROM t2;
+ UPDATE t2 SET b = '';
+ PRAGMA incremental_vacuum;
+} {
+ UPDATE t2 SET b = (SELECT b FROM t1 WHERE t1.oid = t2.oid);
+ PRAGMA incremental_vacuum;
+} {
+ CREATE TABLE t3(a, b);
+ INSERT INTO t3 SELECT * FROM t2;
+ DROP TABLE t2;
+ PRAGMA incremental_vacuum;
+} {
+ CREATE INDEX t3_i ON t3(a);
+ COMMIT;
+} {
+ BEGIN;
+ DROP INDEX t3_i;
+ PRAGMA incremental_vacuum;
+ INSERT INTO t3 VALUES('hello', 'world');
+ ROLLBACK;
+} {
+ INSERT INTO t3 VALUES('hello', 'world');
+}
+]
+
+# If this build omits subqueries, step 2 in the above list will not
+# work. Replace it with "" in this case.
+#
+ifcapable !subquery { lset TestScriptList 2 "" }
+
+# Compare the contents of databases $A and $B.
+#
+proc compare_dbs {A B tname} {
+ set tbl_list [execsql {
+ SELECT tbl_name FROM sqlite_master WHERE type = 'table'
+ } $A]
+
+ do_test ${tname}.1 [subst {
+ execsql {
+ SELECT tbl_name FROM sqlite_master WHERE type = 'table'
+ } $B
+ }] $tbl_list
+
+ set tn 1
+ foreach tbl $tbl_list {
+ set control [execsql "SELECT * FROM $tbl" $A]
+ do_test ${tname}.[incr tn] [subst {
+ execsql "SELECT * FROM $tbl" $B
+ }] $control
+ }
+}
+
+set ::str1 [string repeat abcdefghij 130]
+set ::str2 [string repeat 1234567890 105]
+
+forcedelete test1.db test1.db-journal test2.db test2.db-journal
+sqlite3 db1 test1.db
+sqlite3 db2 test2.db
+execsql { PRAGMA auto_vacuum = 'none' } db1
+execsql { PRAGMA auto_vacuum = 'incremental' } db2
+
+set tn 1
+foreach sql $::TestScriptList {
+ execsql $sql db1
+ execsql $sql db2
+
+ compare_dbs db1 db2 incrvacuum-5.3.${tn}
+ do_test incrvacuum-5.3.${tn}.integrity1 {
+ execsql { PRAGMA integrity_check; } db1
+ } {ok}
+ do_test incrvacuum-5.3.${tn}.integrity2 {
+ execsql { PRAGMA integrity_check; } db2
+ } {ok}
+ incr tn
+}
+db1 close
+db2 close
+#
+# End of test cases 5.3.*
+
+#---------------------------------------------------------------------
+# The following tests - incrvacuum-6.* - test running incremental
+# vacuum while another statement (a read) is being executed.
+#
+for {set jj 0} {$jj < 10} {incr jj} {
+ # Build some test data. Two tables are created in an empty
+ # database. tbl1 data is a contiguous block starting at page 5 (pages
+ # 3 and 4 are the table roots). tbl2 is a contiguous block starting
+ # right after tbl1.
+ #
+ # Then drop tbl1 so that when an incr vacuum is run the pages
+ # of tbl2 have to be moved to fill the gap.
+ #
+ do_test incrvacuum-6.${jj}.1 {
+ execsql {
+ DROP TABLE IF EXISTS tbl1;
+ DROP TABLE IF EXISTS tbl2;
+ PRAGMA incremental_vacuum;
+ CREATE TABLE tbl1(a, b);
+ CREATE TABLE tbl2(a, b);
+ BEGIN;
+ }
+ for {set ii 0} {$ii < 1000} {incr ii} {
+ db eval {INSERT INTO tbl1 VALUES($ii, $ii || $ii)}
+ }
+ execsql {
+ INSERT INTO tbl2 SELECT * FROM tbl1;
+ COMMIT;
+ DROP TABLE tbl1;
+ }
+ expr {[file size test.db] / 1024}
+ } {36}
+
+ # Run a linear scan query on tbl2. After reading ($jj*100) rows,
+ # run the incremental vacuum to shrink the database.
+ #
+ do_test incrvacuum-6.${jj}.2 {
+ set ::nRow 0
+ db eval {SELECT a FROM tbl2} {} {
+ if {$a == [expr $jj*100]} {
+ db eval {PRAGMA incremental_vacuum}
+ }
+ incr ::nRow
+ }
+ list [expr {[file size test.db] / 1024}] $nRow
+ } {19 1000}
+}
+
+#---------------------------------------------------------------------
+# This test - incrvacuum-7.* - is to check that the database can be
+# written in the middle of an incremental vacuum.
+#
+set ::iWrite 1
+while 1 {
+ do_test incrvacuum-7.${::iWrite}.1 {
+ execsql {
+ DROP TABLE IF EXISTS tbl1;
+ DROP TABLE IF EXISTS tbl2;
+ PRAGMA incremental_vacuum;
+ CREATE TABLE tbl1(a, b);
+ CREATE TABLE tbl2(a, b);
+ BEGIN;
+ }
+ for {set ii 0} {$ii < 1000} {incr ii} {
+ db eval {INSERT INTO tbl1 VALUES($ii, $ii || $ii)}
+ }
+ execsql {
+ INSERT INTO tbl2 SELECT * FROM tbl1;
+ COMMIT;
+ DROP TABLE tbl1;
+ }
+ expr {[file size test.db] / 1024}
+ } {36}
+
+ do_test incrvacuum-7.${::iWrite}.2 {
+ set ::nRow 0
+ db eval {PRAGMA incremental_vacuum} {
+ incr ::nRow
+ if {$::nRow == $::iWrite} {
+ db eval {
+ CREATE TABLE tbl1(a, b);
+ INSERT INTO tbl1 VALUES('hello', 'world');
+ }
+ }
+ }
+ list [expr {[file size test.db] / 1024}]
+ } {20}
+
+ do_test incrvacuum-7.${::iWrite}.3 {
+ execsql {
+ SELECT * FROM tbl1;
+ }
+ } {hello world}
+
+ if {$::nRow == $::iWrite} break
+ incr ::iWrite
+}
+
+#---------------------------------------------------------------------
+# This test - incrvacuum-8.* - is to check that nothing goes wrong
+# with an incremental-vacuum if it is the first statement executed
+# after an existing database is opened.
+#
+# At one point, this would always return SQLITE_SCHEMA (which
+# causes an infinite loop in tclsqlite.c if using the Tcl interface).
+#
+do_test incrvacuum-8.1 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA incremental_vacuum(50);
+ }
+} {}
+
+#---------------------------------------------------------------------
+# At one point this test case was causing an assert() to fail.
+#
+do_test incrvacuum-9.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+
+ execsql {
+ PRAGMA auto_vacuum = 'incremental';
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+ INSERT INTO t2 VALUES(randstr(500,500),randstr(500,500),randstr(500,500));
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;
+ INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;
+ INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;
+ INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;
+ INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;
+ INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;
+ INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;
+ INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;
+ }
+} {}
+
+do_test incrvacuum-9.2 {
+ execsql {
+ PRAGMA synchronous = 'OFF';
+ BEGIN;
+ UPDATE t1 SET a = a, b = b, c = c;
+ DROP TABLE t2;
+ PRAGMA incremental_vacuum(10);
+ ROLLBACK;
+ }
+} {}
+
+do_test incrvacuum-9.3 {
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ UPDATE t1 SET a = a, b = b, c = c;
+ DROP TABLE t2;
+ PRAGMA incremental_vacuum(10);
+ ROLLBACK;
+ }
+} {}
+
+#---------------------------------------------------------------------
+# Test that the parameter to the incremental_vacuum pragma works. That
+# is, if the user executes "PRAGMA incremental_vacuum(N)", at most
+# N pages are vacuumed.
+#
+do_test incrvacuum-10.1 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ }
+ expr [file size test.db] / 1024
+} {29}
+
+do_test incrvacuum-10.2 {
+ execsql {
+ PRAGMA incremental_vacuum(1);
+ }
+ expr [file size test.db] / 1024
+} {28}
+
+do_test incrvacuum-10.3 {
+ execsql {
+ PRAGMA incremental_vacuum(5);
+ }
+ expr [file size test.db] / 1024
+} {23}
+
+do_test incrvacuum-10.4 {
+ execsql {
+ PRAGMA incremental_vacuum('1');
+ }
+ expr [file size test.db] / 1024
+} {22}
+
+do_test incrvacuum-10.5 {
+ execsql {
+ PRAGMA incremental_vacuum("+3");
+ }
+ expr [file size test.db] / 1024
+} {19}
+
+do_test incrvacuum-10.6 {
+ execsql {
+ PRAGMA incremental_vacuum = 1;
+ }
+ expr [file size test.db] / 1024
+} {18}
+
+do_test incrvacuum-10.7 {
+ # Use a really big number as an argument to incremetal_vacuum. Should
+ # be interpreted as "free all possible space".
+ execsql {
+ PRAGMA incremental_vacuum(2147483649);
+ }
+ expr [file size test.db] / 1024
+} {1}
+
+do_test incrvacuum-10.8 {
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(hex(randomblob(1000)));
+ DROP TABLE t1;
+ }
+ # A negative number means free all possible space.
+ execsql {
+ PRAGMA incremental_vacuum=-1;
+ }
+ expr [file size test.db] / 1024
+} {1}
+
+#----------------------------------------------------------------
+# Test that if we set the auto_vacuum mode to 'incremental', then
+# create a database, thereafter that database defaults to incremental
+# vacuum mode.
+#
+db close
+forcedelete test.db test.db-journal
+sqlite3 db test.db
+
+ifcapable default_autovacuum {
+ do_test incrvacuum-11.1-av-dflt-on {
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+ } $AUTOVACUUM
+} else {
+ do_test incrvacuum-11.1-av-dflt-off {
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+ } {0}
+}
+do_test incrvacuum-11.2 {
+ execsql {
+ PRAGMA auto_vacuum = incremental;
+ }
+} {}
+do_test incrvacuum-11.3 {
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+} {2}
+do_test incrvacuum-11.4 {
+ # The database has now been created.
+ expr {[file size test.db]>0}
+} {1}
+do_test incrvacuum-11.5 {
+ # Close and reopen the connection.
+ db close
+ sqlite3 db test.db
+
+ # Test we are still in incremental vacuum mode.
+ execsql { PRAGMA auto_vacuum; }
+} {2}
+do_test incrvacuum-11.6 {
+ execsql {
+ PRAGMA auto_vacuum = 'full';
+ PRAGMA auto_vacuum;
+ }
+} {1}
+do_test incrvacuum-11.7 {
+ # Close and reopen the connection.
+ db close
+ sqlite3 db test.db
+
+ # Test we are still in "full" auto-vacuum mode.
+ execsql { PRAGMA auto_vacuum; }
+} {1}
+
+#----------------------------------------------------------------------
+# Special case: What happens if the database is locked when a "PRAGMA
+# auto_vacuum = XXX" statement is executed.
+#
+db close
+forcedelete test.db test.db-journal
+sqlite3 db test.db
+
+do_test incrvacuum-12.1 {
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ }
+ expr {[file size test.db]>0}
+} {1}
+
+# Try to change the auto-vacuum from "full" to "incremental" while the
+# database is locked. Nothing should change.
+#
+do_test incrvacuum-12.2 {
+ sqlite3 db2 test.db
+ execsql { BEGIN EXCLUSIVE; } db2
+ catchsql { PRAGMA auto_vacuum = 2; }
+} {1 {database is locked}}
+
+do_test incrvacuum-12.3 {
+ execsql { ROLLBACK; } db2
+ execsql { PRAGMA auto_vacuum }
+} {2} ;# Still 2 because PRAGMA auto_vacuum setting held in case of vacuum
+do_test incrvacuum-12.4 {
+ db close
+ sqlite3 db test.db
+ execsql { PRAGMA auto_vacuum }
+} {1} ;# Revert to 1 because the database file did not change
+
+do_test incrvacuum-12.5 {
+ execsql { SELECT * FROM sqlite_master }
+ execsql { PRAGMA auto_vacuum }
+} {1}
+
+#----------------------------------------------------------------------
+# Special case #2: What if one process prepares a "PRAGMA auto_vacuum = XXX"
+# statement when the database is empty, but doesn't execute it until
+# after some other process has created the database.
+#
+db2 close
+db close
+forcedelete test.db test.db-journal
+sqlite3 db test.db ; set ::DB [sqlite3_connection_pointer db]
+sqlite3 db2 test.db
+
+do_test incrvacuum-13.1 {
+ # File size is sometimes 1 instead of 0 due to the hack we put in
+ # to work around ticket #3260. Search for comments on #3260 in
+ # os_unix.c.
+ expr {[file size test.db]>1}
+} {0}
+do_test incrvacuum-13.2 {
+ set ::STMT [sqlite3_prepare $::DB {PRAGMA auto_vacuum = 2} -1 DUMMY]
+ execsql {
+ PRAGMA auto_vacuum = none;
+ PRAGMA default_cache_size = 1024;
+ PRAGMA auto_vacuum;
+ } db2
+} {0}
+do_test incrvacuum-13.3 {
+ expr {[file size test.db]>0}
+} {1}
+do_test incrvacuum-13.4 {
+ set rc [sqlite3_step $::STMT]
+ list $rc [sqlite3_finalize $::STMT]
+} {SQLITE_DONE SQLITE_OK}
+do_test incrvacuum-13.5 {
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+} {0}
+
+
+# Verify that the incremental_vacuum pragma fails gracefully if it
+# is used against an invalid database file.
+#
+if {[permutation] == ""} {
+ do_test incrvacuum-14.1 {
+ set out [open invalid.db w]
+ puts $out "This is not an SQLite database file"
+ close $out
+ sqlite3 db3 invalid.db
+ catchsql {
+ PRAGMA incremental_vacuum(10);
+ } db3
+ } {1 {file is encrypted or is not a database}}
+ db3 close
+}
+
+do_test incrvacuum-15.1 {
+ db close
+ db2 close
+ forcedelete test.db
+ sqlite3 db test.db
+
+ set str [string repeat "abcdefghij" 500]
+
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA auto_vacuum = incremental;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES('a', $str);
+ INSERT INTO t1 VALUES('b', $str);
+ INSERT INTO t1 VALUES('c', $str);
+ INSERT INTO t1 VALUES('d', $str);
+ INSERT INTO t1 VALUES('e', $str);
+ INSERT INTO t1 VALUES('f', $str);
+ INSERT INTO t1 VALUES('g', $str);
+ INSERT INTO t1 VALUES('h', $str);
+ INSERT INTO t1 VALUES('i', $str);
+ INSERT INTO t1 VALUES('j', $str);
+ INSERT INTO t1 VALUES('j', $str);
+
+ CREATE TABLE t2(x PRIMARY KEY, y);
+ INSERT INTO t2 VALUES('a', $str);
+ INSERT INTO t2 VALUES('b', $str);
+ INSERT INTO t2 VALUES('c', $str);
+ INSERT INTO t2 VALUES('d', $str);
+
+ BEGIN;
+ DELETE FROM t2;
+ PRAGMA incremental_vacuum;
+ }
+
+ catchsql {INSERT INTO t2 SELECT * FROM t1}
+
+ execsql {
+ COMMIT;
+ PRAGMA integrity_check;
+ }
+} {ok}
+
+finish_test
diff --git a/test/incrvacuum2.test b/test/incrvacuum2.test
new file mode 100644
index 0000000..e67a086
--- /dev/null
+++ b/test/incrvacuum2.test
@@ -0,0 +1,211 @@
+# 2007 May 04
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the incremental vacuum feature.
+#
+# $Id: incrvacuum2.test,v 1.6 2009/07/25 13:42:50 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build of the library does not support auto-vacuum, omit this
+# whole file.
+ifcapable {!autovacuum || !pragma} {
+ finish_test
+ return
+}
+
+set testprefix incrvacuum2
+
+# Create a database in incremental vacuum mode that has many
+# pages on the freelist.
+#
+do_test incrvacuum2-1.1 {
+ execsql {
+ PRAGMA page_size=1024;
+ PRAGMA auto_vacuum=incremental;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(zeroblob(30000));
+ DELETE FROM t1;
+ }
+ file size test.db
+} {32768}
+
+# Vacuum off a single page.
+#
+do_test incrvacuum2-1.2 {
+ execsql {
+ PRAGMA incremental_vacuum(1);
+ }
+ file size test.db
+} {31744}
+
+# Vacuum off five pages
+#
+do_test incrvacuum2-1.3 {
+ execsql {
+ PRAGMA incremental_vacuum(5);
+ }
+ file size test.db
+} {26624}
+
+# Vacuum off all the rest
+#
+do_test incrvacuum2-1.4 {
+ execsql {
+ PRAGMA incremental_vacuum(1000);
+ }
+ file size test.db
+} {3072}
+
+# Make sure incremental vacuum works on attached databases.
+#
+ifcapable attach {
+ do_test incrvacuum2-2.1 {
+ forcedelete test2.db test2.db-journal
+ execsql {
+ ATTACH DATABASE 'test2.db' AS aux;
+ PRAGMA aux.auto_vacuum=incremental;
+ CREATE TABLE aux.t2(x);
+ INSERT INTO t2 VALUES(zeroblob(30000));
+ INSERT INTO t1 SELECT * FROM t2;
+ DELETE FROM t2;
+ DELETE FROM t1;
+ }
+ list [file size test.db] [file size test2.db]
+ } {32768 32768}
+ do_test incrvacuum2-2.2 {
+ execsql {
+ PRAGMA aux.incremental_vacuum(1)
+ }
+ list [file size test.db] [file size test2.db]
+ } {32768 31744}
+ do_test incrvacuum2-2.3 {
+ execsql {
+ PRAGMA aux.incremental_vacuum(5)
+ }
+ list [file size test.db] [file size test2.db]
+ } {32768 26624}
+ do_test incrvacuum2-2.4 {
+ execsql {
+ PRAGMA main.incremental_vacuum(5)
+ }
+ list [file size test.db] [file size test2.db]
+ } {27648 26624}
+ do_test incrvacuum2-2.5 {
+ execsql {
+ PRAGMA aux.incremental_vacuum
+ }
+ list [file size test.db] [file size test2.db]
+ } {27648 3072}
+ do_test incrvacuum2-2.6 {
+ execsql {
+ PRAGMA incremental_vacuum(1)
+ }
+ list [file size test.db] [file size test2.db]
+ } {26624 3072}
+}
+
+do_test incrvacuum2-3.1 {
+ execsql {
+ PRAGMA auto_vacuum = 'full';
+ BEGIN;
+ CREATE TABLE abc(a);
+ INSERT INTO abc VALUES(randstr(1500,1500));
+ COMMIT;
+ }
+} {}
+do_test incrvacuum2-3.2 {
+ execsql {
+ BEGIN;
+ DELETE FROM abc;
+ PRAGMA incremental_vacuum;
+ COMMIT;
+ }
+} {}
+
+integrity_check incrvacuum2-3.3
+
+ifcapable wal {
+ # At one point, when a specific page was being extracted from the b-tree
+ # free-list (e.g. during an incremental-vacuum), all trunk pages that
+ # occurred before the specific page in the free-list trunk were being
+ # written to the journal or wal file. This is not necessary. Only the
+ # extracted page and the page that contains the pointer to it need to
+ # be journalled.
+ #
+ # This problem was fixed by [d03d63d77e] (just before 3.7.6 release).
+ #
+ # This test case builds a database containing many free pages. Then runs
+ # "PRAGMA incremental_vacuum(1)" until the db contains zero free pages.
+ # Each "PRAGMA incremental_vacuum(1)" should modify at most 4 pages. The
+ # worst case is when a trunk page is removed from the end of the db file.
+ # In this case pages written are:
+ #
+ # 1. The previous trunk page (that contains a pointer to the recycled
+ # trunk page), and
+ # 2. The leaf page transformed into a trunk page to replace the recycled
+ # page, and
+ # 3. The trunk page that contained a pointer to the leaf page used
+ # in (2), and
+ # 4. Page 1. Page 1 is always updated, even in WAL mode, since it contains
+ # the "number of free-list pages" field.
+ #
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+
+ do_execsql_test 4.1 {
+ PRAGMA page_size = 512;
+ PRAGMA auto_vacuum = 2;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(400));
+ INSERT INTO t1 SELECT * FROM t1; -- 2
+ INSERT INTO t1 SELECT * FROM t1; -- 4
+ INSERT INTO t1 SELECT * FROM t1; -- 8
+ INSERT INTO t1 SELECT * FROM t1; -- 16
+ INSERT INTO t1 SELECT * FROM t1; -- 32
+ INSERT INTO t1 SELECT * FROM t1; -- 128
+ INSERT INTO t1 SELECT * FROM t1; -- 256
+ INSERT INTO t1 SELECT * FROM t1; -- 512
+ INSERT INTO t1 SELECT * FROM t1; -- 1024
+ INSERT INTO t1 SELECT * FROM t1; -- 2048
+ INSERT INTO t1 SELECT * FROM t1; -- 4096
+ INSERT INTO t1 SELECT * FROM t1; -- 8192
+ DELETE FROM t1 WHERE oid>512;
+ DELETE FROM t1;
+ }
+
+ do_test 4.2 {
+ execsql {
+ PRAGMA journal_mode = WAL;
+ PRAGMA incremental_vacuum(1);
+ PRAGMA wal_checkpoint;
+ }
+ file size test.db-wal
+ } {1640}
+
+ do_test 4.3 {
+ db close
+ sqlite3 db test.db
+ set maxsz 0
+ while {[file size test.db] > [expr 512*3]} {
+ execsql { PRAGMA journal_mode = WAL }
+ execsql { PRAGMA wal_checkpoint }
+ execsql { PRAGMA incremental_vacuum(1) }
+ set newsz [file size test.db-wal]
+ if {$newsz>$maxsz} {set maxsz $newsz}
+ }
+ set maxsz
+ } {2176}
+}
+
+finish_test
diff --git a/test/incrvacuum_ioerr.test b/test/incrvacuum_ioerr.test
new file mode 100644
index 0000000..946925d
--- /dev/null
+++ b/test/incrvacuum_ioerr.test
@@ -0,0 +1,181 @@
+# 2001 October 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing for correct handling of I/O errors
+# such as writes failing because the disk is full.
+#
+# The tests in this file use special facilities that are only
+# available in the SQLite test fixture.
+#
+# $Id: incrvacuum_ioerr.test,v 1.6 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build of the library does not support auto-vacuum, omit this
+# whole file.
+ifcapable {!autovacuum} {
+ finish_test
+ return
+}
+
+do_ioerr_test incrvacuum-ioerr-1 -cksum 1 -sqlprep {
+ PRAGMA auto_vacuum = 'incremental';
+ CREATE TABLE abc(a);
+ INSERT INTO abc VALUES(randstr(1500,1500));
+} -sqlbody {
+ BEGIN;
+ CREATE TABLE abc2(a);
+ DELETE FROM abc;
+ PRAGMA incremental_vacuum;
+ COMMIT;
+}
+
+# do_ioerr_test incrvacuum-ioerr-3 -start 1 -cksum 1 -tclprep {
+# db eval {
+# PRAGMA auto_vacuum = 'full';
+# PRAGMA cache_size = 10;
+# BEGIN;
+# CREATE TABLE abc(a, UNIQUE(a));
+# }
+# for {set ii 0} {$ii < 25} {incr ii} {
+# db eval {INSERT INTO abc VALUES(randstr(1500,1500))}
+# }
+# db eval COMMIT
+# } -sqlbody {
+# BEGIN;
+# DELETE FROM abc WHERE (oid%3)==0;
+# INSERT INTO abc SELECT a || '1234567890' FROM abc WHERE oid%2;
+# CREATE INDEX abc_i ON abc(a);
+# DELETE FROM abc WHERE (oid%2)==0;
+# DROP INDEX abc_i;
+# COMMIT;
+# }
+
+do_ioerr_test incrvacuum-ioerr-2 -start 1 -cksum 1 -tclprep {
+ db eval {
+ PRAGMA auto_vacuum = 'full';
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE abc(a, UNIQUE(a));
+ }
+ for {set ii 0} {$ii < 25} {incr ii} {
+ db eval {INSERT INTO abc VALUES(randstr(1500,1500))}
+ }
+ db eval COMMIT
+} -sqlbody {
+ BEGIN;
+ PRAGMA incremental_vacuum;
+ DELETE FROM abc WHERE (oid%3)==0;
+ PRAGMA incremental_vacuum;
+ INSERT INTO abc SELECT a || '1234567890' FROM abc WHERE oid%2;
+ PRAGMA incremental_vacuum;
+ CREATE INDEX abc_i ON abc(a);
+ DELETE FROM abc WHERE (oid%2)==0;
+ PRAGMA incremental_vacuum;
+ DROP INDEX abc_i;
+ PRAGMA incremental_vacuum;
+ COMMIT;
+}
+
+do_ioerr_test incrvacuum-ioerr-3 -start 1 -cksum 1 -tclprep {
+ db eval {
+ PRAGMA auto_vacuum = 'incremental';
+ BEGIN;
+ CREATE TABLE a(i integer, b blob);
+ INSERT INTO a VALUES(1, randstr(1500,1500));
+ INSERT INTO a VALUES(2, randstr(1500,1500));
+ }
+ db eval COMMIT
+ db eval {DELETE FROM a WHERE oid}
+} -sqlbody {
+ PRAGMA incremental_vacuum(5);
+} -cleanup {
+ sqlite3 db test.db
+ integrity_check incrvacuum-ioerr-2.$n.integritycheck
+ db close
+}
+
+
+ifcapable shared_cache {
+
+ catch { db close }
+ forcedelete test.db
+ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+ # Create two connections to a single shared-cache:
+ #
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+
+ # Create a database with around 20 free pages.
+ #
+ do_test incrvacuum-ioerr-4.0 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA locking_mode = exclusive;
+ PRAGMA auto_vacuum = 'incremental';
+ BEGIN;
+ CREATE TABLE a(i integer, b blob);
+ } db1
+ for {set ii 0} {$ii < 20} {incr ii} {
+ execsql { INSERT INTO a VALUES($ii, randstr(800,1500)); } db1
+ }
+ execsql COMMIT db1
+ execsql {DELETE FROM a WHERE oid} db1
+ } {}
+
+ set ::rc 1
+ for {set iTest 1} {$::rc && $iTest<2000} {incr iTest} {
+
+ # Figure out how big the database is and how many free pages it
+ # has before running incremental-vacuum.
+ #
+ set nPage [expr {[file size test.db]/1024}]
+ set nFree [execsql {pragma freelist_count} db1]
+
+ # Now run incremental-vacuum to vacuum 5 pages from the db file.
+ # The iTest'th I/O call is set to fail.
+ #
+ set ::sqlite_io_error_pending $iTest
+ set ::sqlite_io_error_persist 1
+ do_test incrvacuum-ioerr-4.$iTest.1 {
+ set ::rc [catch {execsql {pragma incremental_vacuum(5)} db1} msg]
+ expr {$::rc==0 || $msg eq "disk I/O error"}
+ } {1}
+
+ set ::sqlite_io_error_pending 0
+ set ::sqlite_io_error_persist 0
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_hardhit 0
+
+ set nFree2 [execsql {pragma freelist_count} db1]
+ set nPage2 [expr {[file size test.db]/1024}]
+
+ do_test incrvacuum-ioerr-4.$iTest.2 {
+ set shrink [expr {$nPage-$nPage2}]
+ expr {$shrink==0 || $shrink==5}
+ } {1}
+
+ do_test incrvacuum-ioerr-4.$iTest.3 {
+ expr {$nPage - $nPage2}
+ } [expr {$nFree - $nFree2}]
+ }
+
+ # Close the two database connections and restore the default
+ # shared-cache mode setting.
+ #
+ db1 close
+ db2 close
+ sqlite3_enable_shared_cache $::enable_shared_cache
+}
+
+finish_test
diff --git a/test/index.test b/test/index.test
new file mode 100644
index 0000000..790bed9
--- /dev/null
+++ b/test/index.test
@@ -0,0 +1,720 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the CREATE INDEX statement.
+#
+# $Id: index.test,v 1.43 2008/01/16 18:20:42 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a basic index and verify it is added to sqlite_master
+#
+do_test index-1.1 {
+ execsql {CREATE TABLE test1(f1 int, f2 int, f3 int)}
+ execsql {CREATE INDEX index1 ON test1(f1)}
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {index1 test1}
+do_test index-1.1b {
+ execsql {SELECT name, sql, tbl_name, type FROM sqlite_master
+ WHERE name='index1'}
+} {index1 {CREATE INDEX index1 ON test1(f1)} test1 index}
+do_test index-1.1c {
+ db close
+ sqlite3 db test.db
+ execsql {SELECT name, sql, tbl_name, type FROM sqlite_master
+ WHERE name='index1'}
+} {index1 {CREATE INDEX index1 ON test1(f1)} test1 index}
+do_test index-1.1d {
+ db close
+ sqlite3 db test.db
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {index1 test1}
+
+# Verify that the index dies with the table
+#
+do_test index-1.2 {
+ execsql {DROP TABLE test1}
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {}
+
+# Try adding an index to a table that does not exist
+#
+do_test index-2.1 {
+ set v [catch {execsql {CREATE INDEX index1 ON test1(f1)}} msg]
+ lappend v $msg
+} {1 {no such table: main.test1}}
+
+# Try adding an index on a column of a table where the table
+# exists but the column does not.
+#
+do_test index-2.1 {
+ execsql {CREATE TABLE test1(f1 int, f2 int, f3 int)}
+ set v [catch {execsql {CREATE INDEX index1 ON test1(f4)}} msg]
+ lappend v $msg
+} {1 {table test1 has no column named f4}}
+
+# Try an index with some columns that match and others that do now.
+#
+do_test index-2.2 {
+ set v [catch {execsql {CREATE INDEX index1 ON test1(f1, f2, f4, f3)}} msg]
+ execsql {DROP TABLE test1}
+ lappend v $msg
+} {1 {table test1 has no column named f4}}
+
+# Try creating a bunch of indices on the same table
+#
+set r {}
+for {set i 1} {$i<100} {incr i} {
+ lappend r [format index%02d $i]
+}
+do_test index-3.1 {
+ execsql {CREATE TABLE test1(f1 int, f2 int, f3 int, f4 int, f5 int)}
+ for {set i 1} {$i<100} {incr i} {
+ set sql "CREATE INDEX [format index%02d $i] ON test1(f[expr {($i%5)+1}])"
+ execsql $sql
+ }
+ execsql {SELECT name FROM sqlite_master
+ WHERE type='index' AND tbl_name='test1'
+ ORDER BY name}
+} $r
+integrity_check index-3.2.1
+ifcapable {reindex} {
+ do_test index-3.2.2 {
+ execsql REINDEX
+ } {}
+}
+integrity_check index-3.2.3
+
+
+# Verify that all the indices go away when we drop the table.
+#
+do_test index-3.3 {
+ execsql {DROP TABLE test1}
+ execsql {SELECT name FROM sqlite_master
+ WHERE type='index' AND tbl_name='test1'
+ ORDER BY name}
+} {}
+
+# Create a table and insert values into that table. Then create
+# an index on that table. Verify that we can select values
+# from the table correctly using the index.
+#
+# Note that the index names "index9" and "indext" are chosen because
+# they both have the same hash.
+#
+do_test index-4.1 {
+ execsql {CREATE TABLE test1(cnt int, power int)}
+ for {set i 1} {$i<20} {incr i} {
+ execsql "INSERT INTO test1 VALUES($i,[expr {1<<$i}])"
+ }
+ execsql {CREATE INDEX index9 ON test1(cnt)}
+ execsql {CREATE INDEX indext ON test1(power)}
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {index9 indext test1}
+do_test index-4.2 {
+ execsql {SELECT cnt FROM test1 WHERE power=4}
+} {2}
+do_test index-4.3 {
+ execsql {SELECT cnt FROM test1 WHERE power=1024}
+} {10}
+do_test index-4.4 {
+ execsql {SELECT power FROM test1 WHERE cnt=6}
+} {64}
+do_test index-4.5 {
+ execsql {DROP INDEX indext}
+ execsql {SELECT power FROM test1 WHERE cnt=6}
+} {64}
+do_test index-4.6 {
+ execsql {SELECT cnt FROM test1 WHERE power=1024}
+} {10}
+do_test index-4.7 {
+ execsql {CREATE INDEX indext ON test1(cnt)}
+ execsql {SELECT power FROM test1 WHERE cnt=6}
+} {64}
+do_test index-4.8 {
+ execsql {SELECT cnt FROM test1 WHERE power=1024}
+} {10}
+do_test index-4.9 {
+ execsql {DROP INDEX index9}
+ execsql {SELECT power FROM test1 WHERE cnt=6}
+} {64}
+do_test index-4.10 {
+ execsql {SELECT cnt FROM test1 WHERE power=1024}
+} {10}
+do_test index-4.11 {
+ execsql {DROP INDEX indext}
+ execsql {SELECT power FROM test1 WHERE cnt=6}
+} {64}
+do_test index-4.12 {
+ execsql {SELECT cnt FROM test1 WHERE power=1024}
+} {10}
+do_test index-4.13 {
+ execsql {DROP TABLE test1}
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {}
+integrity_check index-4.14
+
+# Do not allow indices to be added to sqlite_master
+#
+do_test index-5.1 {
+ set v [catch {execsql {CREATE INDEX index1 ON sqlite_master(name)}} msg]
+ lappend v $msg
+} {1 {table sqlite_master may not be indexed}}
+do_test index-5.2 {
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
+} {}
+
+# Do not allow indices with duplicate names to be added
+#
+do_test index-6.1 {
+ execsql {CREATE TABLE test1(f1 int, f2 int)}
+ execsql {CREATE TABLE test2(g1 real, g2 real)}
+ execsql {CREATE INDEX index1 ON test1(f1)}
+ set v [catch {execsql {CREATE INDEX index1 ON test2(g1)}} msg]
+ lappend v $msg
+} {1 {index index1 already exists}}
+do_test index-6.1.1 {
+ catchsql {CREATE INDEX [index1] ON test2(g1)}
+} {1 {index index1 already exists}}
+do_test index-6.1b {
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {index1 test1 test2}
+do_test index-6.1c {
+ catchsql {CREATE INDEX IF NOT EXISTS index1 ON test1(f1)}
+} {0 {}}
+do_test index-6.2 {
+ set v [catch {execsql {CREATE INDEX test1 ON test2(g1)}} msg]
+ lappend v $msg
+} {1 {there is already a table named test1}}
+do_test index-6.2b {
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {index1 test1 test2}
+do_test index-6.3 {
+ execsql {DROP TABLE test1}
+ execsql {DROP TABLE test2}
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {}
+do_test index-6.4 {
+ execsql {
+ CREATE TABLE test1(a,b);
+ CREATE INDEX index1 ON test1(a);
+ CREATE INDEX index2 ON test1(b);
+ CREATE INDEX index3 ON test1(a,b);
+ DROP TABLE test1;
+ SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name;
+ }
+} {}
+integrity_check index-6.5
+
+
+# Create a primary key
+#
+do_test index-7.1 {
+ execsql {CREATE TABLE test1(f1 int, f2 int primary key)}
+ for {set i 1} {$i<20} {incr i} {
+ execsql "INSERT INTO test1 VALUES($i,[expr {1<<$i}])"
+ }
+ execsql {SELECT count(*) FROM test1}
+} {19}
+do_test index-7.2 {
+ execsql {SELECT f1 FROM test1 WHERE f2=65536}
+} {16}
+do_test index-7.3 {
+ execsql {
+ SELECT name FROM sqlite_master
+ WHERE type='index' AND tbl_name='test1'
+ }
+} {sqlite_autoindex_test1_1}
+do_test index-7.4 {
+ execsql {DROP table test1}
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
+} {}
+integrity_check index-7.5
+
+# Make sure we cannot drop a non-existant index.
+#
+do_test index-8.1 {
+ set v [catch {execsql {DROP INDEX index1}} msg]
+ lappend v $msg
+} {1 {no such index: index1}}
+
+# Make sure we don't actually create an index when the EXPLAIN keyword
+# is used.
+#
+do_test index-9.1 {
+ execsql {CREATE TABLE tab1(a int)}
+ ifcapable {explain} {
+ execsql {EXPLAIN CREATE INDEX idx1 ON tab1(a)}
+ }
+ execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1'}
+} {tab1}
+do_test index-9.2 {
+ execsql {CREATE INDEX idx1 ON tab1(a)}
+ execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1' ORDER BY name}
+} {idx1 tab1}
+integrity_check index-9.3
+
+# Allow more than one entry with the same key.
+#
+do_test index-10.0 {
+ execsql {
+ CREATE TABLE t1(a int, b int);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(2,4);
+ INSERT INTO t1 VALUES(3,8);
+ INSERT INTO t1 VALUES(1,12);
+ SELECT b FROM t1 WHERE a=1 ORDER BY b;
+ }
+} {2 12}
+do_test index-10.1 {
+ execsql {
+ SELECT b FROM t1 WHERE a=2 ORDER BY b;
+ }
+} {4}
+do_test index-10.2 {
+ execsql {
+ DELETE FROM t1 WHERE b=12;
+ SELECT b FROM t1 WHERE a=1 ORDER BY b;
+ }
+} {2}
+do_test index-10.3 {
+ execsql {
+ DELETE FROM t1 WHERE b=2;
+ SELECT b FROM t1 WHERE a=1 ORDER BY b;
+ }
+} {}
+do_test index-10.4 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES (1,1);
+ INSERT INTO t1 VALUES (1,2);
+ INSERT INTO t1 VALUES (1,3);
+ INSERT INTO t1 VALUES (1,4);
+ INSERT INTO t1 VALUES (1,5);
+ INSERT INTO t1 VALUES (1,6);
+ INSERT INTO t1 VALUES (1,7);
+ INSERT INTO t1 VALUES (1,8);
+ INSERT INTO t1 VALUES (1,9);
+ INSERT INTO t1 VALUES (2,0);
+ SELECT b FROM t1 WHERE a=1 ORDER BY b;
+ }
+} {1 2 3 4 5 6 7 8 9}
+do_test index-10.5 {
+ ifcapable subquery {
+ execsql { DELETE FROM t1 WHERE b IN (2, 4, 6, 8); }
+ } else {
+ execsql { DELETE FROM t1 WHERE b = 2 OR b = 4 OR b = 6 OR b = 8; }
+ }
+ execsql {
+ SELECT b FROM t1 WHERE a=1 ORDER BY b;
+ }
+} {1 3 5 7 9}
+do_test index-10.6 {
+ execsql {
+ DELETE FROM t1 WHERE b>2;
+ SELECT b FROM t1 WHERE a=1 ORDER BY b;
+ }
+} {1}
+do_test index-10.7 {
+ execsql {
+ DELETE FROM t1 WHERE b=1;
+ SELECT b FROM t1 WHERE a=1 ORDER BY b;
+ }
+} {}
+do_test index-10.8 {
+ execsql {
+ SELECT b FROM t1 ORDER BY b;
+ }
+} {0}
+integrity_check index-10.9
+
+# Automatically create an index when we specify a primary key.
+#
+do_test index-11.1 {
+ execsql {
+ CREATE TABLE t3(
+ a text,
+ b int,
+ c float,
+ PRIMARY KEY(b)
+ );
+ }
+ for {set i 1} {$i<=50} {incr i} {
+ execsql "INSERT INTO t3 VALUES('x${i}x',$i,0.$i)"
+ }
+ set sqlite_search_count 0
+ concat [execsql {SELECT c FROM t3 WHERE b==10}] $sqlite_search_count
+} {0.1 2}
+integrity_check index-11.2
+
+
+# Numeric strings should compare as if they were numbers. So even if the
+# strings are not character-by-character the same, if they represent the
+# same number they should compare equal to one another. Verify that this
+# is true in indices.
+#
+# Updated for sqlite3 v3: SQLite will now store these values as numbers
+# (because the affinity of column a is NUMERIC) so the quirky
+# representations are not retained. i.e. '+1.0' becomes '1'.
+do_test index-12.1 {
+ execsql {
+ CREATE TABLE t4(a NUM,b);
+ INSERT INTO t4 VALUES('0.0',1);
+ INSERT INTO t4 VALUES('0.00',2);
+ INSERT INTO t4 VALUES('abc',3);
+ INSERT INTO t4 VALUES('-1.0',4);
+ INSERT INTO t4 VALUES('+1.0',5);
+ INSERT INTO t4 VALUES('0',6);
+ INSERT INTO t4 VALUES('00000',7);
+ SELECT a FROM t4 ORDER BY b;
+ }
+} {0 0 abc -1 1 0 0}
+do_test index-12.2 {
+ execsql {
+ SELECT a FROM t4 WHERE a==0 ORDER BY b
+ }
+} {0 0 0 0}
+do_test index-12.3 {
+ execsql {
+ SELECT a FROM t4 WHERE a<0.5 ORDER BY b
+ }
+} {0 0 -1 0 0}
+do_test index-12.4 {
+ execsql {
+ SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
+ }
+} {0 0 abc 1 0 0}
+do_test index-12.5 {
+ execsql {
+ CREATE INDEX t4i1 ON t4(a);
+ SELECT a FROM t4 WHERE a==0 ORDER BY b
+ }
+} {0 0 0 0}
+do_test index-12.6 {
+ execsql {
+ SELECT a FROM t4 WHERE a<0.5 ORDER BY b
+ }
+} {0 0 -1 0 0}
+do_test index-12.7 {
+ execsql {
+ SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
+ }
+} {0 0 abc 1 0 0}
+integrity_check index-12.8
+
+# Make sure we cannot drop an automatically created index.
+#
+do_test index-13.1 {
+ execsql {
+ CREATE TABLE t5(
+ a int UNIQUE,
+ b float PRIMARY KEY,
+ c varchar(10),
+ UNIQUE(a,c)
+ );
+ INSERT INTO t5 VALUES(1,2,3);
+ SELECT * FROM t5;
+ }
+} {1 2.0 3}
+do_test index-13.2 {
+ set ::idxlist [execsql {
+ SELECT name FROM sqlite_master WHERE type="index" AND tbl_name="t5";
+ }]
+ llength $::idxlist
+} {3}
+for {set i 0} {$i<[llength $::idxlist]} {incr i} {
+ do_test index-13.3.$i {
+ catchsql "
+ DROP INDEX '[lindex $::idxlist $i]';
+ "
+ } {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}}
+}
+do_test index-13.4 {
+ execsql {
+ INSERT INTO t5 VALUES('a','b','c');
+ SELECT * FROM t5;
+ }
+} {1 2.0 3 a b c}
+integrity_check index-13.5
+
+# Check the sort order of data in an index.
+#
+do_test index-14.1 {
+ execsql {
+ CREATE TABLE t6(a,b,c);
+ CREATE INDEX t6i1 ON t6(a,b);
+ INSERT INTO t6 VALUES('','',1);
+ INSERT INTO t6 VALUES('',NULL,2);
+ INSERT INTO t6 VALUES(NULL,'',3);
+ INSERT INTO t6 VALUES('abc',123,4);
+ INSERT INTO t6 VALUES(123,'abc',5);
+ SELECT c FROM t6 ORDER BY a,b;
+ }
+} {3 5 2 1 4}
+do_test index-14.2 {
+ execsql {
+ SELECT c FROM t6 WHERE a='';
+ }
+} {2 1}
+do_test index-14.3 {
+ execsql {
+ SELECT c FROM t6 WHERE b='';
+ }
+} {1 3}
+do_test index-14.4 {
+ execsql {
+ SELECT c FROM t6 WHERE a>'';
+ }
+} {4}
+do_test index-14.5 {
+ execsql {
+ SELECT c FROM t6 WHERE a>='';
+ }
+} {2 1 4}
+do_test index-14.6 {
+ execsql {
+ SELECT c FROM t6 WHERE a>123;
+ }
+} {2 1 4}
+do_test index-14.7 {
+ execsql {
+ SELECT c FROM t6 WHERE a>=123;
+ }
+} {5 2 1 4}
+do_test index-14.8 {
+ execsql {
+ SELECT c FROM t6 WHERE a<'abc';
+ }
+} {5 2 1}
+do_test index-14.9 {
+ execsql {
+ SELECT c FROM t6 WHERE a<='abc';
+ }
+} {5 2 1 4}
+do_test index-14.10 {
+ execsql {
+ SELECT c FROM t6 WHERE a<='';
+ }
+} {5 2 1}
+do_test index-14.11 {
+ execsql {
+ SELECT c FROM t6 WHERE a<'';
+ }
+} {5}
+integrity_check index-14.12
+
+do_test index-15.1 {
+ execsql {
+ DELETE FROM t1;
+ SELECT * FROM t1;
+ }
+} {}
+do_test index-15.2 {
+ execsql {
+ INSERT INTO t1 VALUES('1.234e5',1);
+ INSERT INTO t1 VALUES('12.33e04',2);
+ INSERT INTO t1 VALUES('12.35E4',3);
+ INSERT INTO t1 VALUES('12.34e',4);
+ INSERT INTO t1 VALUES('12.32e+4',5);
+ INSERT INTO t1 VALUES('12.36E+04',6);
+ INSERT INTO t1 VALUES('12.36E+',7);
+ INSERT INTO t1 VALUES('+123.10000E+0003',8);
+ INSERT INTO t1 VALUES('+',9);
+ INSERT INTO t1 VALUES('+12347.E+02',10);
+ INSERT INTO t1 VALUES('+12347E+02',11);
+ INSERT INTO t1 VALUES('+.125E+04',12);
+ INSERT INTO t1 VALUES('-.125E+04',13);
+ INSERT INTO t1 VALUES('.125E+0',14);
+ INSERT INTO t1 VALUES('.125',15);
+ SELECT b FROM t1 ORDER BY a, b;
+ }
+} {13 14 15 12 8 5 2 1 3 6 10 11 9 4 7}
+do_test index-15.3 {
+ execsql {
+ SELECT b FROM t1 WHERE typeof(a) IN ('integer','real') ORDER BY b;
+ }
+} {1 2 3 5 6 8 10 11 12 13 14 15}
+integrity_check index-15.4
+
+# The following tests - index-16.* - test that when a table definition
+# includes qualifications that specify the same constraint twice only a
+# single index is generated to enforce the constraint.
+#
+# For example: "CREATE TABLE abc( x PRIMARY KEY, UNIQUE(x) );"
+#
+do_test index-16.1 {
+ execsql {
+ CREATE TABLE t7(c UNIQUE PRIMARY KEY);
+ SELECT count(*) FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';
+ }
+} {1}
+do_test index-16.2 {
+ execsql {
+ DROP TABLE t7;
+ CREATE TABLE t7(c UNIQUE PRIMARY KEY);
+ SELECT count(*) FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';
+ }
+} {1}
+do_test index-16.3 {
+ execsql {
+ DROP TABLE t7;
+ CREATE TABLE t7(c PRIMARY KEY, UNIQUE(c) );
+ SELECT count(*) FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';
+ }
+} {1}
+do_test index-16.4 {
+ execsql {
+ DROP TABLE t7;
+ CREATE TABLE t7(c, d , UNIQUE(c, d), PRIMARY KEY(c, d) );
+ SELECT count(*) FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';
+ }
+} {1}
+do_test index-16.5 {
+ execsql {
+ DROP TABLE t7;
+ CREATE TABLE t7(c, d , UNIQUE(c), PRIMARY KEY(c, d) );
+ SELECT count(*) FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';
+ }
+} {2}
+
+# Test that automatically create indices are named correctly. The current
+# convention is: "sqlite_autoindex_<table name>_<integer>"
+#
+# Then check that it is an error to try to drop any automtically created
+# indices.
+do_test index-17.1 {
+ execsql {
+ DROP TABLE t7;
+ CREATE TABLE t7(c, d UNIQUE, UNIQUE(c), PRIMARY KEY(c, d) );
+ SELECT name FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';
+ }
+} {sqlite_autoindex_t7_1 sqlite_autoindex_t7_2 sqlite_autoindex_t7_3}
+do_test index-17.2 {
+ catchsql {
+ DROP INDEX sqlite_autoindex_t7_1;
+ }
+} {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}}
+do_test index-17.3 {
+ catchsql {
+ DROP INDEX IF EXISTS sqlite_autoindex_t7_1;
+ }
+} {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}}
+do_test index-17.4 {
+ catchsql {
+ DROP INDEX IF EXISTS no_such_index;
+ }
+} {0 {}}
+
+
+# The following tests ensure that it is not possible to explicitly name
+# a schema object with a name beginning with "sqlite_". Granted that is a
+# little outside the focus of this test scripts, but this has got to be
+# tested somewhere.
+do_test index-18.1 {
+ catchsql {
+ CREATE TABLE sqlite_t1(a, b, c);
+ }
+} {1 {object name reserved for internal use: sqlite_t1}}
+do_test index-18.2 {
+ catchsql {
+ CREATE INDEX sqlite_i1 ON t7(c);
+ }
+} {1 {object name reserved for internal use: sqlite_i1}}
+ifcapable view {
+do_test index-18.3 {
+ catchsql {
+ CREATE VIEW sqlite_v1 AS SELECT * FROM t7;
+ }
+} {1 {object name reserved for internal use: sqlite_v1}}
+} ;# ifcapable view
+ifcapable {trigger} {
+ do_test index-18.4 {
+ catchsql {
+ CREATE TRIGGER sqlite_tr1 BEFORE INSERT ON t7 BEGIN SELECT 1; END;
+ }
+ } {1 {object name reserved for internal use: sqlite_tr1}}
+}
+do_test index-18.5 {
+ execsql {
+ DROP TABLE t7;
+ }
+} {}
+
+# These tests ensure that if multiple table definition constraints are
+# implemented by a single indice, the correct ON CONFLICT policy applies.
+ifcapable conflict {
+ do_test index-19.1 {
+ execsql {
+ CREATE TABLE t7(a UNIQUE PRIMARY KEY);
+ CREATE TABLE t8(a UNIQUE PRIMARY KEY ON CONFLICT ROLLBACK);
+ INSERT INTO t7 VALUES(1);
+ INSERT INTO t8 VALUES(1);
+ }
+ } {}
+ do_test index-19.2 {
+ catchsql {
+ BEGIN;
+ INSERT INTO t7 VALUES(1);
+ }
+ } {1 {column a is not unique}}
+ do_test index-19.3 {
+ catchsql {
+ BEGIN;
+ }
+ } {1 {cannot start a transaction within a transaction}}
+ do_test index-19.4 {
+ catchsql {
+ INSERT INTO t8 VALUES(1);
+ }
+ } {1 {column a is not unique}}
+ do_test index-19.5 {
+ catchsql {
+ BEGIN;
+ COMMIT;
+ }
+ } {0 {}}
+ do_test index-19.6 {
+ catchsql {
+ DROP TABLE t7;
+ DROP TABLE t8;
+ CREATE TABLE t7(
+ a PRIMARY KEY ON CONFLICT FAIL,
+ UNIQUE(a) ON CONFLICT IGNORE
+ );
+ }
+ } {1 {conflicting ON CONFLICT clauses specified}}
+} ; # end of "ifcapable conflict" block
+
+ifcapable {reindex} {
+ do_test index-19.7 {
+ execsql REINDEX
+ } {}
+}
+integrity_check index-19.8
+
+# Drop index with a quoted name. Ticket #695.
+#
+do_test index-20.1 {
+ execsql {
+ CREATE INDEX "t6i2" ON t6(c);
+ DROP INDEX "t6i2";
+ }
+} {}
+do_test index-20.2 {
+ execsql {
+ DROP INDEX "t6i1";
+ }
+} {}
+
+
+finish_test
diff --git a/test/index2.test b/test/index2.test
new file mode 100644
index 0000000..48d0c38
--- /dev/null
+++ b/test/index2.test
@@ -0,0 +1,74 @@
+# 2005 January 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the CREATE INDEX statement.
+#
+# $Id: index2.test,v 1.3 2006/03/03 19:12:30 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table with a large number of columns
+#
+do_test index2-1.1 {
+ set sql {CREATE TABLE t1(}
+ for {set i 1} {$i<1000} {incr i} {
+ append sql "c$i,"
+ }
+ append sql "c1000);"
+ execsql $sql
+} {}
+do_test index2-1.2 {
+ set sql {INSERT INTO t1 VALUES(}
+ for {set i 1} {$i<1000} {incr i} {
+ append sql $i,
+ }
+ append sql {1000);}
+ execsql $sql
+} {}
+do_test index2-1.3 {
+ execsql {SELECT c123 FROM t1}
+} 123
+do_test index2-1.4 {
+ execsql BEGIN
+ for {set j 1} {$j<=100} {incr j} {
+ set sql {INSERT INTO t1 VALUES(}
+ for {set i 1} {$i<1000} {incr i} {
+ append sql [expr {$j*10000+$i}],
+ }
+ append sql "[expr {$j*10000+1000}]);"
+ execsql $sql
+ }
+ execsql COMMIT
+ execsql {SELECT count(*) FROM t1}
+} 101
+do_test index2-1.5 {
+ execsql {SELECT round(sum(c1000)) FROM t1}
+} {50601000.0}
+
+# Create indices with many columns
+#
+do_test index2-2.1 {
+ set sql "CREATE INDEX t1i1 ON t1("
+ for {set i 1} {$i<1000} {incr i} {
+ append sql c$i,
+ }
+ append sql c1000)
+ execsql $sql
+} {}
+do_test index2-2.2 {
+ ifcapable explain {
+ execsql {EXPLAIN SELECT c9 FROM t1 ORDER BY c1, c2, c3, c4, c5}
+ }
+ execsql {SELECT c9 FROM t1 ORDER BY c1, c2, c3, c4, c5, c6 LIMIT 5}
+} {9 10009 20009 30009 40009}
+
+finish_test
diff --git a/test/index3.test b/test/index3.test
new file mode 100644
index 0000000..161ddec
--- /dev/null
+++ b/test/index3.test
@@ -0,0 +1,56 @@
+# 2005 February 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the CREATE INDEX statement.
+#
+# $Id: index3.test,v 1.3 2008/03/19 13:03:34 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Ticket #1115. Make sure that when a UNIQUE index is created on a
+# non-unique column (or columns) that it fails and that it leaves no
+# residue behind.
+#
+do_test index3-1.1 {
+ execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(1);
+ SELECT * FROM t1;
+ }
+} {1 1}
+do_test index3-1.2 {
+ catchsql {
+ BEGIN;
+ CREATE UNIQUE INDEX i1 ON t1(a);
+ }
+} {1 {indexed columns are not unique}}
+do_test index3-1.3 {
+ catchsql COMMIT;
+} {0 {}}
+integrity_check index3-1.4
+
+# This test corrupts the database file so it must be the last test
+# in the series.
+#
+do_test index3-99.1 {
+ execsql {
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET sql='nonsense';
+ }
+ db close
+ catch { sqlite3 db test.db }
+ catchsql { DROP INDEX i1 }
+} {1 {malformed database schema (t1) - near "nonsense": syntax error}}
+
+finish_test
diff --git a/test/index4.test b/test/index4.test
new file mode 100644
index 0000000..018ed74
--- /dev/null
+++ b/test/index4.test
@@ -0,0 +1,126 @@
+# 2011 July 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the CREATE INDEX statement.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix index4
+
+do_execsql_test 1.1 {
+ BEGIN;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(102));
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 2
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 4
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 8
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 16
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 32
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 64
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 128
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 256
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 512
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 1024
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 2048
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 4096
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 8192
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 16384
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 32768
+ INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 65536
+ COMMIT;
+}
+
+do_execsql_test 1.2 {
+ CREATE INDEX i1 ON t1(x);
+}
+do_execsql_test 1.3 {
+ PRAGMA integrity_check
+} {ok}
+
+# The same test again - this time with limited memory.
+#
+ifcapable memorymanage {
+ set soft_limit [sqlite3_soft_heap_limit 50000]
+
+ db close
+ sqlite3 db test.db
+
+ do_execsql_test 1.4 {
+ PRAGMA cache_size = 10;
+ CREATE INDEX i2 ON t1(x);
+ }
+ do_execsql_test 1.5 {
+ PRAGMA integrity_check
+ } {ok}
+
+ sqlite3_soft_heap_limit $soft_limit
+}
+
+
+do_execsql_test 1.6 {
+ BEGIN;
+ DROP TABLE t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('a');
+ INSERT INTO t1 VALUES('b');
+ INSERT INTO t1 VALUES('c');
+ INSERT INTO t1 VALUES('d');
+ INSERT INTO t1 VALUES('e');
+ INSERT INTO t1 VALUES('f');
+ INSERT INTO t1 VALUES('g');
+ INSERT INTO t1 VALUES(NULL);
+ INSERT INTO t1 SELECT randomblob(1202) FROM t1; -- 16
+ INSERT INTO t1 SELECT randomblob(2202) FROM t1; -- 32
+ INSERT INTO t1 SELECT randomblob(3202) FROM t1; -- 64
+ INSERT INTO t1 SELECT randomblob(4202) FROM t1; -- 128
+ INSERT INTO t1 SELECT randomblob(5202) FROM t1; -- 256
+ COMMIT;
+ CREATE INDEX i1 ON t1(x);
+ PRAGMA integrity_check
+} {ok}
+
+do_execsql_test 1.7 {
+ BEGIN;
+ DROP TABLE t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('a');
+ COMMIT;
+ CREATE INDEX i1 ON t1(x);
+ PRAGMA integrity_check
+} {ok}
+
+do_execsql_test 1.8 {
+ BEGIN;
+ DROP TABLE t1;
+ CREATE TABLE t1(x);
+ COMMIT;
+ CREATE INDEX i1 ON t1(x);
+ PRAGMA integrity_check
+} {ok}
+
+do_execsql_test 2.1 {
+ BEGIN;
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES(14);
+ INSERT INTO t2 VALUES(35);
+ INSERT INTO t2 VALUES(15);
+ INSERT INTO t2 VALUES(35);
+ INSERT INTO t2 VALUES(16);
+ COMMIT;
+}
+do_catchsql_test 2.2 {
+ CREATE UNIQUE INDEX i3 ON t2(x);
+} {1 {indexed columns are not unique}}
+
+
+finish_test
diff --git a/test/indexedby.test b/test/indexedby.test
new file mode 100644
index 0000000..7ccc4de
--- /dev/null
+++ b/test/indexedby.test
@@ -0,0 +1,277 @@
+# 2008 October 4
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: indexedby.test,v 1.5 2009/03/22 20:36:19 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a schema with some indexes.
+#
+do_test indexedby-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+
+ CREATE TABLE t2(c, d);
+ CREATE INDEX i3 ON t2(c);
+ CREATE INDEX i4 ON t2(d);
+
+ CREATE TABLE t3(e PRIMARY KEY, f);
+
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ }
+} {}
+
+# Explain Query Plan
+#
+proc EQP {sql} {
+ uplevel "execsql {EXPLAIN QUERY PLAN $sql}"
+}
+
+# These tests are to check that "EXPLAIN QUERY PLAN" is working as expected.
+#
+do_execsql_test indexedby-1.2 {
+ EXPLAIN QUERY PLAN select * from t1 WHERE a = 10;
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)}}
+do_execsql_test indexedby-1.3 {
+ EXPLAIN QUERY PLAN select * from t1 ;
+} {0 0 0 {SCAN TABLE t1 (~1000000 rows)}}
+do_execsql_test indexedby-1.4 {
+ EXPLAIN QUERY PLAN select * from t1, t2 WHERE c = 10;
+} {
+ 0 0 1 {SEARCH TABLE t2 USING INDEX i3 (c=?) (~10 rows)}
+ 0 1 0 {SCAN TABLE t1 (~1000000 rows)}
+}
+
+# Parser tests. Test that an INDEXED BY or NOT INDEX clause can be
+# attached to a table in the FROM clause, but not to a sub-select or
+# SQL view. Also test that specifying an index that does not exist or
+# is attached to a different table is detected as an error.
+#
+do_test indexedby-2.1 {
+ execsql { SELECT * FROM t1 NOT INDEXED WHERE a = 'one' AND b = 'two'}
+} {}
+do_test indexedby-2.2 {
+ execsql { SELECT * FROM t1 INDEXED BY i1 WHERE a = 'one' AND b = 'two'}
+} {}
+do_test indexedby-2.3 {
+ execsql { SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' AND b = 'two'}
+} {}
+
+do_test indexedby-2.4 {
+ catchsql { SELECT * FROM t1 INDEXED BY i3 WHERE a = 'one' AND b = 'two'}
+} {1 {no such index: i3}}
+do_test indexedby-2.5 {
+ catchsql { SELECT * FROM t1 INDEXED BY i5 WHERE a = 'one' AND b = 'two'}
+} {1 {no such index: i5}}
+do_test indexedby-2.6 {
+ catchsql { SELECT * FROM t1 INDEXED BY WHERE a = 'one' AND b = 'two'}
+} {1 {near "WHERE": syntax error}}
+do_test indexedby-2.7 {
+ catchsql { SELECT * FROM v1 INDEXED BY i1 WHERE a = 'one' }
+} {1 {no such index: i1}}
+
+# Tests for single table cases.
+#
+do_execsql_test indexedby-3.1 {
+ EXPLAIN QUERY PLAN SELECT * FROM t1 NOT INDEXED WHERE a = 'one' AND b = 'two'
+} {0 0 0 {SCAN TABLE t1 (~10000 rows)}}
+do_execsql_test indexedby-3.2 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 INDEXED BY i1 WHERE a = 'one' AND b = 'two'
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~2 rows)}}
+do_execsql_test indexedby-3.3 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' AND b = 'two'
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~2 rows)}}
+do_test indexedby-3.4 {
+ catchsql { SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' }
+} {1 {cannot use index: i2}}
+do_test indexedby-3.5 {
+ catchsql { SELECT * FROM t1 INDEXED BY i2 ORDER BY a }
+} {1 {cannot use index: i2}}
+do_test indexedby-3.6 {
+ catchsql { SELECT * FROM t1 INDEXED BY i1 WHERE a = 'one' }
+} {0 {}}
+do_test indexedby-3.7 {
+ catchsql { SELECT * FROM t1 INDEXED BY i1 ORDER BY a }
+} {0 {}}
+
+do_execsql_test indexedby-3.8 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 ORDER BY e
+} {0 0 0 {SCAN TABLE t3 USING INDEX sqlite_autoindex_t3_1 (~1000000 rows)}}
+do_execsql_test indexedby-3.9 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 WHERE e = 10
+} {0 0 0 {SEARCH TABLE t3 USING INDEX sqlite_autoindex_t3_1 (e=?) (~1 rows)}}
+do_test indexedby-3.10 {
+ catchsql { SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 WHERE f = 10 }
+} {1 {cannot use index: sqlite_autoindex_t3_1}}
+do_test indexedby-3.11 {
+ catchsql { SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_2 WHERE f = 10 }
+} {1 {no such index: sqlite_autoindex_t3_2}}
+
+# Tests for multiple table cases.
+#
+do_execsql_test indexedby-4.1 {
+ EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE a = c
+} {
+ 0 0 0 {SCAN TABLE t1 (~1000000 rows)}
+ 0 1 1 {SEARCH TABLE t2 USING INDEX i3 (c=?) (~10 rows)}
+}
+do_execsql_test indexedby-4.2 {
+ EXPLAIN QUERY PLAN SELECT * FROM t1 INDEXED BY i1, t2 WHERE a = c
+} {
+ 0 0 1 {SCAN TABLE t2 (~1000000 rows)}
+ 0 1 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)}
+}
+do_test indexedby-4.3 {
+ catchsql {
+ SELECT * FROM t1 INDEXED BY i1, t2 INDEXED BY i3 WHERE a=c
+ }
+} {1 {cannot use index: i1}}
+do_test indexedby-4.4 {
+ catchsql {
+ SELECT * FROM t2 INDEXED BY i3, t1 INDEXED BY i1 WHERE a=c
+ }
+} {1 {cannot use index: i3}}
+
+# Test embedding an INDEXED BY in a CREATE VIEW statement. This block
+# also tests that nothing bad happens if an index refered to by
+# a CREATE VIEW statement is dropped and recreated.
+#
+do_execsql_test indexedby-5.1 {
+ CREATE VIEW v2 AS SELECT * FROM t1 INDEXED BY i1 WHERE a > 5;
+ EXPLAIN QUERY PLAN SELECT * FROM v2
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?) (~250000 rows)}}
+do_execsql_test indexedby-5.2 {
+ EXPLAIN QUERY PLAN SELECT * FROM v2 WHERE b = 10
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?) (~25000 rows)}}
+do_test indexedby-5.3 {
+ execsql { DROP INDEX i1 }
+ catchsql { SELECT * FROM v2 }
+} {1 {no such index: i1}}
+do_test indexedby-5.4 {
+ # Recreate index i1 in such a way as it cannot be used by the view query.
+ execsql { CREATE INDEX i1 ON t1(b) }
+ catchsql { SELECT * FROM v2 }
+} {1 {cannot use index: i1}}
+do_test indexedby-5.5 {
+ # Drop and recreate index i1 again. This time, create it so that it can
+ # be used by the query.
+ execsql { DROP INDEX i1 ; CREATE INDEX i1 ON t1(a) }
+ catchsql { SELECT * FROM v2 }
+} {0 {}}
+
+# Test that "NOT INDEXED" may use the rowid index, but not others.
+#
+do_execsql_test indexedby-6.1 {
+ EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b = 10 ORDER BY rowid
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~10 rows)}}
+do_execsql_test indexedby-6.2 {
+ EXPLAIN QUERY PLAN SELECT * FROM t1 NOT INDEXED WHERE b = 10 ORDER BY rowid
+} {0 0 0 {SCAN TABLE t1 USING INTEGER PRIMARY KEY (~100000 rows)}}
+
+# Test that "INDEXED BY" can be used in a DELETE statement.
+#
+do_execsql_test indexedby-7.1 {
+ EXPLAIN QUERY PLAN DELETE FROM t1 WHERE a = 5
+} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?) (~10 rows)}}
+do_execsql_test indexedby-7.2 {
+ EXPLAIN QUERY PLAN DELETE FROM t1 NOT INDEXED WHERE a = 5
+} {0 0 0 {SCAN TABLE t1 (~100000 rows)}}
+do_execsql_test indexedby-7.3 {
+ EXPLAIN QUERY PLAN DELETE FROM t1 INDEXED BY i1 WHERE a = 5
+} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?) (~10 rows)}}
+do_execsql_test indexedby-7.4 {
+ EXPLAIN QUERY PLAN DELETE FROM t1 INDEXED BY i1 WHERE a = 5 AND b = 10
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~2 rows)}}
+do_execsql_test indexedby-7.5 {
+ EXPLAIN QUERY PLAN DELETE FROM t1 INDEXED BY i2 WHERE a = 5 AND b = 10
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~2 rows)}}
+do_test indexedby-7.6 {
+ catchsql { DELETE FROM t1 INDEXED BY i2 WHERE a = 5}
+} {1 {cannot use index: i2}}
+
+# Test that "INDEXED BY" can be used in an UPDATE statement.
+#
+do_execsql_test indexedby-8.1 {
+ EXPLAIN QUERY PLAN UPDATE t1 SET rowid=rowid+1 WHERE a = 5
+} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?) (~10 rows)}}
+do_execsql_test indexedby-8.2 {
+ EXPLAIN QUERY PLAN UPDATE t1 NOT INDEXED SET rowid=rowid+1 WHERE a = 5
+} {0 0 0 {SCAN TABLE t1 (~100000 rows)}}
+do_execsql_test indexedby-8.3 {
+ EXPLAIN QUERY PLAN UPDATE t1 INDEXED BY i1 SET rowid=rowid+1 WHERE a = 5
+} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?) (~10 rows)}}
+do_execsql_test indexedby-8.4 {
+ EXPLAIN QUERY PLAN
+ UPDATE t1 INDEXED BY i1 SET rowid=rowid+1 WHERE a = 5 AND b = 10
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~2 rows)}}
+do_execsql_test indexedby-8.5 {
+ EXPLAIN QUERY PLAN
+ UPDATE t1 INDEXED BY i2 SET rowid=rowid+1 WHERE a = 5 AND b = 10
+} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~2 rows)}}
+do_test indexedby-8.6 {
+ catchsql { UPDATE t1 INDEXED BY i2 SET rowid=rowid+1 WHERE a = 5}
+} {1 {cannot use index: i2}}
+
+# Test that bug #3560 is fixed.
+#
+do_test indexedby-9.1 {
+ execsql {
+ CREATE TABLE maintable( id integer);
+ CREATE TABLE joinme(id_int integer, id_text text);
+ CREATE INDEX joinme_id_text_idx on joinme(id_text);
+ CREATE INDEX joinme_id_int_idx on joinme(id_int);
+ }
+} {}
+do_test indexedby-9.2 {
+ catchsql {
+ select * from maintable as m inner join
+ joinme as j indexed by joinme_id_text_idx
+ on ( m.id = j.id_int)
+ }
+} {1 {cannot use index: joinme_id_text_idx}}
+do_test indexedby-9.3 {
+ catchsql { select * from maintable, joinme INDEXED by joinme_id_text_idx }
+} {1 {cannot use index: joinme_id_text_idx}}
+
+# Make sure we can still create tables, indices, and columns whose name
+# is "indexed".
+#
+do_test indexedby-10.1 {
+ execsql {
+ CREATE TABLE indexed(x,y);
+ INSERT INTO indexed VALUES(1,2);
+ SELECT * FROM indexed;
+ }
+} {1 2}
+do_test indexedby-10.2 {
+ execsql {
+ CREATE INDEX i10 ON indexed(x);
+ SELECT * FROM indexed indexed by i10 where x>0;
+ }
+} {1 2}
+do_test indexedby-10.3 {
+ execsql {
+ DROP TABLE indexed;
+ CREATE TABLE t10(indexed INTEGER);
+ INSERT INTO t10 VALUES(1);
+ CREATE INDEX indexed ON t10(indexed);
+ SELECT * FROM t10 indexed by indexed WHERE indexed>0
+ }
+} {1}
+
+finish_test
diff --git a/test/indexfault.test b/test/indexfault.test
new file mode 100644
index 0000000..efe4932
--- /dev/null
+++ b/test/indexfault.test
@@ -0,0 +1,342 @@
+# 2011 August 08
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+ifcapable !mergesort {
+ finish_test
+ return
+}
+
+set testprefix indexfault
+
+# Set up the custom fault-injector. This is further configured by using
+# different values for $::custom_filter and different implementations
+# of Tcl proc [xCustom] for each test case.
+#
+proc install_custom_faultsim {} {
+ set ::FAULTSIM(custom) [list \
+ -injectinstall custom_injectinstall \
+ -injectstart custom_injectstart \
+ -injectstop custom_injectstop \
+ -injecterrlist {{1 {disk I/O error}}} \
+ -injectuninstall custom_injectuninstall \
+ ]
+ proc custom_injectinstall {} {
+ testvfs shmfault -default true
+ shmfault filter $::custom_filter
+ shmfault script xCustom
+ }
+ proc custom_injectuninstall {} {
+ catch {db close}
+ catch {db2 close}
+ shmfault delete
+ }
+ set ::custom_ifail -1
+ set ::custom_nfail -1
+ proc custom_injectstart {iFail} {
+ set ::custom_ifail $iFail
+ set ::custom_nfail 0
+ }
+ proc custom_injectstop {} {
+ set ::custom_ifail -1
+ return $::custom_nfail
+ }
+}
+proc uninstall_custom_faultsim {} {
+ unset -nocomplain ::FAULTSIM(custom)
+}
+
+
+#-------------------------------------------------------------------------
+# These tests - indexfault-1.* - Build an index on a smallish table with
+# all different kinds of fault-injection. The CREATE INDEX is run once
+# with default options and once with a 50KB soft-heap-limit.
+#
+do_execsql_test 1.0 {
+ BEGIN;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(202));
+ INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 2
+ INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 4
+ INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 8
+ INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 16
+ INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 32
+ INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 64
+ INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 128
+ INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 256
+ COMMIT;
+}
+faultsim_save_and_close
+
+do_faultsim_test 1.1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { CREATE INDEX i1 ON t1(x) }
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+ifcapable memorymanage {
+ set soft_limit [sqlite3_soft_heap_limit 50000]
+ do_faultsim_test 2.1 -prep {
+ faultsim_restore_and_reopen
+ } -body {
+ execsql { CREATE INDEX i1 ON t1(x) }
+ faultsim_test_result {0 {}}
+ }
+ sqlite3_soft_heap_limit $soft_limit
+}
+
+#-------------------------------------------------------------------------
+# These are similar to the indexfault-1.* tests, except they create an
+# index with more than one column.
+#
+sqlite3 db test.db
+do_execsql_test 2.0 {
+ BEGIN;
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(t,u,v,w,x,y,z);
+ INSERT INTO t1 VALUES(
+ randomblob(30), randomblob(30), randomblob(30), randomblob(30),
+ randomblob(30), randomblob(30), randomblob(30)
+ );
+ INSERT INTO t1 SELECT
+ randomblob(30), randomblob(30), randomblob(30), randomblob(30),
+ randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 2
+ INSERT INTO t1 SELECT
+ randomblob(30), randomblob(30), randomblob(30), randomblob(30),
+ randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 4
+ INSERT INTO t1 SELECT
+ randomblob(30), randomblob(30), randomblob(30), randomblob(30),
+ randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 8
+ INSERT INTO t1 SELECT
+ randomblob(30), randomblob(30), randomblob(30), randomblob(30),
+ randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 16
+ INSERT INTO t1 SELECT
+ randomblob(30), randomblob(30), randomblob(30), randomblob(30),
+ randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 32
+ INSERT INTO t1 SELECT
+ randomblob(30), randomblob(30), randomblob(30), randomblob(30),
+ randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 64
+ INSERT INTO t1 SELECT
+ randomblob(30), randomblob(30), randomblob(30), randomblob(30),
+ randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 128
+ COMMIT;
+}
+faultsim_save_and_close
+
+do_faultsim_test 2.1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { CREATE INDEX i1 ON t1(t,u,v,w,x,y,z) }
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+ifcapable memorymanage {
+ set soft_limit [sqlite3_soft_heap_limit 50000]
+ do_faultsim_test 2.2 -prep {
+ faultsim_restore_and_reopen
+ } -body {
+ execsql { CREATE INDEX i1 ON t1(t,u,v,w,x,y,z) }
+ faultsim_test_result {0 {}}
+ }
+ sqlite3_soft_heap_limit $soft_limit
+}
+
+#-------------------------------------------------------------------------
+# The following tests - indexfault-2.* - all attempt to build a index
+# on table t1 in the main database with injected IO errors. Individual
+# test cases work as follows:
+#
+# 3.1: IO errors injected into xOpen() calls.
+# 3.2: As 7.1, but with a low (50KB) soft-heap-limit.
+#
+# 3.3: IO errors injected into the first 200 write() calls made on the
+# second temporary file.
+# 3.4: As 7.3, but with a low (50KB) soft-heap-limit.
+#
+# 3.5: After a certain amount of data has been read from the main database
+# file (and written into the temporary b-tree), sqlite3_release_memory()
+# is called to free as much memory as possible. This causes the temp
+# b-tree to be flushed to disk. So that before its contents can be
+# transfered to a PMA they must be read back from disk - creating extra
+# opportunities for IO errors.
+#
+install_custom_faultsim
+
+# Set up a table to build indexes on. Save the setup using the
+# [faultsim_save_and_close] mechanism.
+#
+sqlite3 db test.db
+do_execsql_test 3.0 {
+ BEGIN;
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(11000));
+ INSERT INTO t1 SELECT randomblob(11001) FROM t1; -- 2
+ INSERT INTO t1 SELECT randomblob(11002) FROM t1; -- 4
+ INSERT INTO t1 SELECT randomblob(11003) FROM t1; -- 8
+ INSERT INTO t1 SELECT randomblob(11004) FROM t1; -- 16
+ INSERT INTO t1 SELECT randomblob(11005) FROM t1; -- 32
+ INSERT INTO t1 SELECT randomblob(11006) FROM t1; -- 64
+ INSERT INTO t1 SELECT randomblob(11007) FROM t1; -- 128
+ INSERT INTO t1 SELECT randomblob(11008) FROM t1; -- 256
+ INSERT INTO t1 SELECT randomblob(11009) FROM t1; -- 512
+ COMMIT;
+}
+faultsim_save_and_close
+
+set ::custom_filter xOpen
+proc xCustom {args} {
+ incr ::custom_ifail -1
+ if {$::custom_ifail==0} {
+ incr ::custom_nfail
+ return "SQLITE_IOERR"
+ }
+ return "SQLITE_OK"
+}
+do_faultsim_test 3.1 -faults custom -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { CREATE INDEX i1 ON t1(x) }
+ faultsim_test_result {0 {}}
+}
+ifcapable memorymanage {
+ set soft_limit [sqlite3_soft_heap_limit 50000]
+ do_faultsim_test 3.2 -faults custom -prep {
+ faultsim_restore_and_reopen
+ } -body {
+ execsql { CREATE INDEX i1 ON t1(x) }
+ faultsim_test_result {0 {}}
+ }
+ sqlite3_soft_heap_limit $soft_limit
+}
+
+set ::custom_filter {xOpen xWrite}
+proc xCustom {method args} {
+ if {$method == "xOpen"} {
+ if {[lindex $args 0] == ""} {
+ incr ::nTmpOpen 1
+ if {$::nTmpOpen == 3} { return "failme" }
+ }
+ return "SQLITE_OK"
+ }
+ if {$::custom_ifail<200 && [lindex $args 1] == "failme"} {
+ incr ::custom_ifail -1
+ if {$::custom_ifail==0} {
+ incr ::custom_nfail
+ return "SQLITE_IOERR"
+ }
+ }
+ return "SQLITE_OK"
+}
+
+do_faultsim_test 3.3 -faults custom -prep {
+ faultsim_restore_and_reopen
+ set ::nTmpOpen 0
+} -body {
+ execsql { CREATE INDEX i1 ON t1(x) }
+ faultsim_test_result {0 {}}
+}
+
+ifcapable memorymanage {
+ set soft_limit [sqlite3_soft_heap_limit 50000]
+ do_faultsim_test 3.4 -faults custom -prep {
+ faultsim_restore_and_reopen
+ set ::nTmpOpen 0
+ } -body {
+ execsql { CREATE INDEX i1 ON t1(x) }
+ faultsim_test_result {0 {}}
+ }
+ sqlite3_soft_heap_limit $soft_limit
+}
+
+uninstall_custom_faultsim
+
+#-------------------------------------------------------------------------
+# Test 4: After a certain amount of data has been read from the main database
+# file (and written into the temporary b-tree), sqlite3_release_memory() is
+# called to free as much memory as possible. This causes the temp b-tree to be
+# flushed to disk. So that before its contents can be transfered to a PMA they
+# must be read back from disk - creating extra opportunities for IO errors.
+#
+install_custom_faultsim
+
+catch { db close }
+forcedelete test.db
+sqlite3 db test.db
+
+do_execsql_test 4.0 {
+ BEGIN;
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(11000));
+ INSERT INTO t1 SELECT randomblob(11001) FROM t1; -- 2
+ INSERT INTO t1 SELECT randomblob(11002) FROM t1; -- 4
+ INSERT INTO t1 SELECT randomblob(11003) FROM t1; -- 8
+ INSERT INTO t1 SELECT randomblob(11004) FROM t1; -- 16
+ INSERT INTO t1 SELECT randomblob(11005) FROM t1; -- 32
+ INSERT INTO t1 SELECT randomblob(11005) FROM t1; -- 64
+ COMMIT;
+}
+faultsim_save_and_close
+
+testvfs tvfs
+tvfs script xRead
+tvfs filter xRead
+set ::nRead 0
+proc xRead {method file args} {
+ if {[file tail $file] == "test.db"} { incr ::nRead }
+}
+
+do_test 4.1 {
+ sqlite3 db test.db -vfs tvfs
+ execsql { CREATE INDEX i1 ON t1(x) }
+} {}
+
+db close
+tvfs delete
+
+set ::custom_filter xRead
+proc xCustom {method file args} {
+ incr ::nReadCall
+ if {$::nReadCall >= ($::nRead/5)} {
+ if {$::nReadCall == ($::nRead/5)} {
+ set nByte [sqlite3_release_memory [expr 64*1024*1024]]
+ sqlite3_soft_heap_limit 20000
+ }
+ if {$file == ""} {
+ incr ::custom_ifail -1
+ if {$::custom_ifail==0} {
+ incr ::custom_nfail
+ return "SQLITE_IOERR"
+ }
+ }
+ }
+ return "SQLITE_OK"
+}
+
+do_faultsim_test 4.2 -faults custom -prep {
+ faultsim_restore_and_reopen
+ set ::nReadCall 0
+ sqlite3_soft_heap_limit 0
+} -body {
+ execsql { CREATE INDEX i1 ON t1(x) }
+ faultsim_test_result {0 {}}
+}
+
+uninstall_custom_faultsim
+
+finish_test
diff --git a/test/init.test b/test/init.test
new file mode 100644
index 0000000..7cb18f4
--- /dev/null
+++ b/test/init.test
@@ -0,0 +1,82 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the effects of a failure in
+# sqlite3_initialize().
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+if {[db eval {SELECT sqlite_compileoption_used('THREADSAFE=0')}]} {
+ finish_test
+ return
+}
+
+db close
+
+foreach {t failed rc started} {
+ 1.1 {} SQLITE_OK {mutex mem pcache}
+ 1.2 {mutex} SQLITE_ERROR {}
+ 1.3 {mem} SQLITE_ERROR {mutex}
+ 1.4 {pcache} SQLITE_ERROR {mutex mem}
+} {
+ do_test init-$t.1 {
+ eval init_wrapper_install $failed
+ sqlite3_initialize
+ } $rc
+ do_test init-$t.2 {
+ init_wrapper_query
+ } $started
+ do_test init-$t.3 {
+ sqlite3_shutdown
+ init_wrapper_query
+ } {}
+ do_test init-$t.4 {
+ sqlite3_initialize
+ } $rc
+ do_test init-$t.5 {
+ init_wrapper_query
+ } $started
+ do_test init-$t.6 {
+ init_wrapper_clear
+ sqlite3_initialize
+ } SQLITE_OK
+ do_test init-$t.7 {
+ init_wrapper_query
+ } {mutex mem pcache}
+ do_test init-$t.8 {
+ init_wrapper_uninstall
+ } {}
+}
+
+source $testdir/malloc_common.tcl
+if {$MEMDEBUG} {
+ do_malloc_test init-2 -tclprep {
+ db close
+ init_wrapper_install
+ } -tclbody {
+ set rc [sqlite3_initialize]
+ if {[string match "SQLITE*NOMEM" $rc]} {error "out of memory"}
+ } -cleanup {
+ set zRepeat "transient"
+ if {$::iRepeat} {set zRepeat "persistent"}
+ do_test init-2.$zRepeat.$::n.x {
+ init_wrapper_clear
+ sqlite3_initialize
+ } SQLITE_OK
+ init_wrapper_uninstall
+ }
+}
+
+autoinstall_test_functions
+finish_test
diff --git a/test/insert.test b/test/insert.test
new file mode 100644
index 0000000..9ea9cd7
--- /dev/null
+++ b/test/insert.test
@@ -0,0 +1,391 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the INSERT statement.
+#
+# $Id: insert.test,v 1.31 2007/04/05 11:25:59 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Try to insert into a non-existant table.
+#
+do_test insert-1.1 {
+ set v [catch {execsql {INSERT INTO test1 VALUES(1,2,3)}} msg]
+ lappend v $msg
+} {1 {no such table: test1}}
+
+# Try to insert into sqlite_master
+#
+do_test insert-1.2 {
+ set v [catch {execsql {INSERT INTO sqlite_master VALUES(1,2,3,4)}} msg]
+ lappend v $msg
+} {1 {table sqlite_master may not be modified}}
+
+# Try to insert the wrong number of entries.
+#
+do_test insert-1.3 {
+ execsql {CREATE TABLE test1(one int, two int, three int)}
+ set v [catch {execsql {INSERT INTO test1 VALUES(1,2)}} msg]
+ lappend v $msg
+} {1 {table test1 has 3 columns but 2 values were supplied}}
+do_test insert-1.3b {
+ set v [catch {execsql {INSERT INTO test1 VALUES(1,2,3,4)}} msg]
+ lappend v $msg
+} {1 {table test1 has 3 columns but 4 values were supplied}}
+do_test insert-1.3c {
+ set v [catch {execsql {INSERT INTO test1(one,two) VALUES(1,2,3,4)}} msg]
+ lappend v $msg
+} {1 {4 values for 2 columns}}
+do_test insert-1.3d {
+ set v [catch {execsql {INSERT INTO test1(one,two) VALUES(1)}} msg]
+ lappend v $msg
+} {1 {1 values for 2 columns}}
+
+# Try to insert into a non-existant column of a table.
+#
+do_test insert-1.4 {
+ set v [catch {execsql {INSERT INTO test1(one,four) VALUES(1,2)}} msg]
+ lappend v $msg
+} {1 {table test1 has no column named four}}
+
+# Make sure the inserts actually happen
+#
+do_test insert-1.5 {
+ execsql {INSERT INTO test1 VALUES(1,2,3)}
+ execsql {SELECT * FROM test1}
+} {1 2 3}
+do_test insert-1.5b {
+ execsql {INSERT INTO test1 VALUES(4,5,6)}
+ execsql {SELECT * FROM test1 ORDER BY one}
+} {1 2 3 4 5 6}
+do_test insert-1.5c {
+ execsql {INSERT INTO test1 VALUES(7,8,9)}
+ execsql {SELECT * FROM test1 ORDER BY one}
+} {1 2 3 4 5 6 7 8 9}
+
+do_test insert-1.6 {
+ execsql {DELETE FROM test1}
+ execsql {INSERT INTO test1(one,two) VALUES(1,2)}
+ execsql {SELECT * FROM test1 ORDER BY one}
+} {1 2 {}}
+do_test insert-1.6b {
+ execsql {INSERT INTO test1(two,three) VALUES(5,6)}
+ execsql {SELECT * FROM test1 ORDER BY one}
+} {{} 5 6 1 2 {}}
+do_test insert-1.6c {
+ execsql {INSERT INTO test1(three,one) VALUES(7,8)}
+ execsql {SELECT * FROM test1 ORDER BY one}
+} {{} 5 6 1 2 {} 8 {} 7}
+
+# A table to use for testing default values
+#
+do_test insert-2.1 {
+ execsql {
+ CREATE TABLE test2(
+ f1 int default -111,
+ f2 real default +4.32,
+ f3 int default +222,
+ f4 int default 7.89
+ )
+ }
+ execsql {SELECT * from test2}
+} {}
+do_test insert-2.2 {
+ execsql {INSERT INTO test2(f1,f3) VALUES(+10,-10)}
+ execsql {SELECT * FROM test2}
+} {10 4.32 -10 7.89}
+do_test insert-2.3 {
+ execsql {INSERT INTO test2(f2,f4) VALUES(1.23,-3.45)}
+ execsql {SELECT * FROM test2 WHERE f1==-111}
+} {-111 1.23 222 -3.45}
+do_test insert-2.4 {
+ execsql {INSERT INTO test2(f1,f2,f4) VALUES(77,+1.23,3.45)}
+ execsql {SELECT * FROM test2 WHERE f1==77}
+} {77 1.23 222 3.45}
+do_test insert-2.10 {
+ execsql {
+ DROP TABLE test2;
+ CREATE TABLE test2(
+ f1 int default 111,
+ f2 real default -4.32,
+ f3 text default hi,
+ f4 text default 'abc-123',
+ f5 varchar(10)
+ )
+ }
+ execsql {SELECT * from test2}
+} {}
+do_test insert-2.11 {
+ execsql {INSERT INTO test2(f2,f4) VALUES(-2.22,'hi!')}
+ execsql {SELECT * FROM test2}
+} {111 -2.22 hi hi! {}}
+do_test insert-2.12 {
+ execsql {INSERT INTO test2(f1,f5) VALUES(1,'xyzzy')}
+ execsql {SELECT * FROM test2 ORDER BY f1}
+} {1 -4.32 hi abc-123 xyzzy 111 -2.22 hi hi! {}}
+
+# Do additional inserts with default values, but this time
+# on a table that has indices. In particular we want to verify
+# that the correct default values are inserted into the indices.
+#
+do_test insert-3.1 {
+ execsql {
+ DELETE FROM test2;
+ CREATE INDEX index9 ON test2(f1,f2);
+ CREATE INDEX indext ON test2(f4,f5);
+ SELECT * from test2;
+ }
+} {}
+
+# Update for sqlite3 v3:
+# Change the 111 to '111' in the following two test cases, because
+# the default value is being inserted as a string. TODO: It shouldn't be.
+do_test insert-3.2 {
+ execsql {INSERT INTO test2(f2,f4) VALUES(-3.33,'hum')}
+ execsql {SELECT * FROM test2 WHERE f1='111' AND f2=-3.33}
+} {111 -3.33 hi hum {}}
+do_test insert-3.3 {
+ execsql {INSERT INTO test2(f1,f2,f5) VALUES(22,-4.44,'wham')}
+ execsql {SELECT * FROM test2 WHERE f1='111' AND f2=-3.33}
+} {111 -3.33 hi hum {}}
+do_test insert-3.4 {
+ execsql {SELECT * FROM test2 WHERE f1=22 AND f2=-4.44}
+} {22 -4.44 hi abc-123 wham}
+ifcapable {reindex} {
+ do_test insert-3.5 {
+ execsql REINDEX
+ } {}
+}
+integrity_check insert-3.5
+
+# Test of expressions in the VALUES clause
+#
+do_test insert-4.1 {
+ execsql {
+ CREATE TABLE t3(a,b,c);
+ INSERT INTO t3 VALUES(1+2+3,4,5);
+ SELECT * FROM t3;
+ }
+} {6 4 5}
+do_test insert-4.2 {
+ ifcapable subquery {
+ execsql {INSERT INTO t3 VALUES((SELECT max(a) FROM t3)+1,5,6);}
+ } else {
+ set maxa [execsql {SELECT max(a) FROM t3}]
+ execsql "INSERT INTO t3 VALUES($maxa+1,5,6);"
+ }
+ execsql {
+ SELECT * FROM t3 ORDER BY a;
+ }
+} {6 4 5 7 5 6}
+ifcapable subquery {
+ do_test insert-4.3 {
+ catchsql {
+ INSERT INTO t3 VALUES((SELECT max(a) FROM t3)+1,t3.a,6);
+ SELECT * FROM t3 ORDER BY a;
+ }
+ } {1 {no such column: t3.a}}
+}
+do_test insert-4.4 {
+ ifcapable subquery {
+ execsql {INSERT INTO t3 VALUES((SELECT b FROM t3 WHERE a=0),6,7);}
+ } else {
+ set b [execsql {SELECT b FROM t3 WHERE a = 0}]
+ if {$b==""} {set b NULL}
+ execsql "INSERT INTO t3 VALUES($b,6,7);"
+ }
+ execsql {
+ SELECT * FROM t3 ORDER BY a;
+ }
+} {{} 6 7 6 4 5 7 5 6}
+do_test insert-4.5 {
+ execsql {
+ SELECT b,c FROM t3 WHERE a IS NULL;
+ }
+} {6 7}
+do_test insert-4.6 {
+ catchsql {
+ INSERT INTO t3 VALUES(notafunc(2,3),2,3);
+ }
+} {1 {no such function: notafunc}}
+do_test insert-4.7 {
+ execsql {
+ INSERT INTO t3 VALUES(min(1,2,3),max(1,2,3),99);
+ SELECT * FROM t3 WHERE c=99;
+ }
+} {1 3 99}
+
+# Test the ability to insert from a temporary table into itself.
+# Ticket #275.
+#
+ifcapable tempdb {
+ do_test insert-5.1 {
+ execsql {
+ CREATE TEMP TABLE t4(x);
+ INSERT INTO t4 VALUES(1);
+ SELECT * FROM t4;
+ }
+ } {1}
+ do_test insert-5.2 {
+ execsql {
+ INSERT INTO t4 SELECT x+1 FROM t4;
+ SELECT * FROM t4;
+ }
+ } {1 2}
+ ifcapable {explain} {
+ do_test insert-5.3 {
+ # verify that a temporary table is used to copy t4 to t4
+ set x [execsql {
+ EXPLAIN INSERT INTO t4 SELECT x+2 FROM t4;
+ }]
+ expr {[lsearch $x OpenEphemeral]>0}
+ } {1}
+ }
+
+ do_test insert-5.4 {
+ # Verify that table "test1" begins on page 3. This should be the same
+ # page number used by "t4" above.
+ #
+ # Update for v3 - the first table now begins on page 2 of each file, not 3.
+ execsql {
+ SELECT rootpage FROM sqlite_master WHERE name='test1';
+ }
+ } [expr $AUTOVACUUM?3:2]
+ do_test insert-5.5 {
+ # Verify that "t4" begins on page 3.
+ #
+ # Update for v3 - the first table now begins on page 2 of each file, not 3.
+ execsql {
+ SELECT rootpage FROM sqlite_temp_master WHERE name='t4';
+ }
+ } {2}
+ do_test insert-5.6 {
+ # This should not use an intermediate temporary table.
+ execsql {
+ INSERT INTO t4 SELECT one FROM test1 WHERE three=7;
+ SELECT * FROM t4
+ }
+ } {1 2 8}
+ ifcapable {explain} {
+ do_test insert-5.7 {
+ # verify that no temporary table is used to copy test1 to t4
+ set x [execsql {
+ EXPLAIN INSERT INTO t4 SELECT one FROM test1;
+ }]
+ expr {[lsearch $x OpenTemp]>0}
+ } {0}
+ }
+}
+
+# Ticket #334: REPLACE statement corrupting indices.
+#
+ifcapable conflict {
+ # The REPLACE command is not available if SQLITE_OMIT_CONFLICT is
+ # defined at compilation time.
+ do_test insert-6.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(2,3);
+ SELECT b FROM t1 WHERE b=2;
+ }
+ } {2}
+ do_test insert-6.2 {
+ execsql {
+ REPLACE INTO t1 VALUES(1,4);
+ SELECT b FROM t1 WHERE b=2;
+ }
+ } {}
+ do_test insert-6.3 {
+ execsql {
+ UPDATE OR REPLACE t1 SET a=2 WHERE b=4;
+ SELECT * FROM t1 WHERE b=4;
+ }
+ } {2 4}
+ do_test insert-6.4 {
+ execsql {
+ SELECT * FROM t1 WHERE b=3;
+ }
+ } {}
+ ifcapable {reindex} {
+ do_test insert-6.5 {
+ execsql REINDEX
+ } {}
+ }
+ do_test insert-6.6 {
+ execsql {
+ DROP TABLE t1;
+ }
+ } {}
+}
+
+# Test that the special optimization for queries of the form
+# "SELECT max(x) FROM tbl" where there is an index on tbl(x) works with
+# INSERT statments.
+do_test insert-7.1 {
+ execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ CREATE INDEX i1 ON t1(a);
+ }
+} {}
+do_test insert-7.2 {
+ execsql {
+ INSERT INTO t1 SELECT max(a) FROM t1;
+ }
+} {}
+do_test insert-7.3 {
+ execsql {
+ SELECT a FROM t1;
+ }
+} {1 2 2}
+
+# Ticket #1140: Check for an infinite loop in the algorithm that tests
+# to see if the right-hand side of an INSERT...SELECT references the left-hand
+# side.
+#
+ifcapable subquery&&compound {
+ do_test insert-8.1 {
+ execsql {
+ INSERT INTO t3 SELECT * FROM (SELECT * FROM t3 UNION ALL SELECT 1,2,3)
+ }
+ } {}
+}
+
+# Make sure the rowid cache in the VDBE is reset correctly when
+# an explicit rowid is given.
+#
+do_test insert-9.1 {
+ execsql {
+ CREATE TABLE t5(x);
+ INSERT INTO t5 VALUES(1);
+ INSERT INTO t5 VALUES(2);
+ INSERT INTO t5 VALUES(3);
+ INSERT INTO t5(rowid, x) SELECT nullif(x*2+10,14), x+100 FROM t5;
+ SELECT rowid, x FROM t5;
+ }
+} {1 1 2 2 3 3 12 101 13 102 16 103}
+do_test insert-9.2 {
+ execsql {
+ CREATE TABLE t6(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t6 VALUES(1,1);
+ INSERT INTO t6 VALUES(2,2);
+ INSERT INTO t6 VALUES(3,3);
+ INSERT INTO t6 SELECT nullif(y*2+10,14), y+100 FROM t6;
+ SELECT x, y FROM t6;
+ }
+} {1 1 2 2 3 3 12 101 13 102 16 103}
+
+integrity_check insert-99.0
+
+finish_test
diff --git a/test/insert2.test b/test/insert2.test
new file mode 100644
index 0000000..6876d53
--- /dev/null
+++ b/test/insert2.test
@@ -0,0 +1,278 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the INSERT statement that takes is
+# result from a SELECT.
+#
+# $Id: insert2.test,v 1.19 2008/01/16 18:20:42 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create some tables with data that we can select against
+#
+do_test insert2-1.0 {
+ execsql {CREATE TABLE d1(n int, log int);}
+ for {set i 1} {$i<=20} {incr i} {
+ for {set j 0} {(1<<$j)<$i} {incr j} {}
+ execsql "INSERT INTO d1 VALUES($i,$j)"
+ }
+ execsql {SELECT * FROM d1 ORDER BY n}
+} {1 0 2 1 3 2 4 2 5 3 6 3 7 3 8 3 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 5 18 5 19 5 20 5}
+
+# Insert into a new table from the old one.
+#
+do_test insert2-1.1.1 {
+ execsql {
+ CREATE TABLE t1(log int, cnt int);
+ PRAGMA count_changes=on;
+ }
+ ifcapable explain {
+ execsql {
+ EXPLAIN INSERT INTO t1 SELECT log, count(*) FROM d1 GROUP BY log;
+ }
+ }
+ execsql {
+ INSERT INTO t1 SELECT log, count(*) FROM d1 GROUP BY log;
+ }
+} {6}
+do_test insert2-1.1.2 {
+ db changes
+} {6}
+do_test insert2-1.1.3 {
+ execsql {SELECT * FROM t1 ORDER BY log}
+} {0 1 1 1 2 2 3 4 4 8 5 4}
+
+ifcapable compound {
+do_test insert2-1.2.1 {
+ catch {execsql {DROP TABLE t1}}
+ execsql {
+ CREATE TABLE t1(log int, cnt int);
+ INSERT INTO t1
+ SELECT log, count(*) FROM d1 GROUP BY log
+ EXCEPT SELECT n-1,log FROM d1;
+ }
+} {4}
+do_test insert2-1.2.2 {
+ execsql {
+ SELECT * FROM t1 ORDER BY log;
+ }
+} {0 1 3 4 4 8 5 4}
+do_test insert2-1.3.1 {
+ catch {execsql {DROP TABLE t1}}
+ execsql {
+ CREATE TABLE t1(log int, cnt int);
+ PRAGMA count_changes=off;
+ INSERT INTO t1
+ SELECT log, count(*) FROM d1 GROUP BY log
+ INTERSECT SELECT n-1,log FROM d1;
+ }
+} {}
+do_test insert2-1.3.2 {
+ execsql {
+ SELECT * FROM t1 ORDER BY log;
+ }
+} {1 1 2 2}
+} ;# ifcapable compound
+execsql {PRAGMA count_changes=off;}
+
+do_test insert2-1.4 {
+ catch {execsql {DROP TABLE t1}}
+ set r [execsql {
+ CREATE TABLE t1(log int, cnt int);
+ CREATE INDEX i1 ON t1(log);
+ CREATE INDEX i2 ON t1(cnt);
+ INSERT INTO t1 SELECT log, count() FROM d1 GROUP BY log;
+ SELECT * FROM t1 ORDER BY log;
+ }]
+ lappend r [execsql {SELECT cnt FROM t1 WHERE log=3}]
+ lappend r [execsql {SELECT log FROM t1 WHERE cnt=4 ORDER BY log}]
+} {0 1 1 1 2 2 3 4 4 8 5 4 4 {3 5}}
+
+do_test insert2-2.0 {
+ execsql {
+ CREATE TABLE t3(a,b,c);
+ CREATE TABLE t4(x,y);
+ INSERT INTO t4 VALUES(1,2);
+ SELECT * FROM t4;
+ }
+} {1 2}
+do_test insert2-2.1 {
+ execsql {
+ INSERT INTO t3(a,c) SELECT * FROM t4;
+ SELECT * FROM t3;
+ }
+} {1 {} 2}
+do_test insert2-2.2 {
+ execsql {
+ DELETE FROM t3;
+ INSERT INTO t3(c,b) SELECT * FROM t4;
+ SELECT * FROM t3;
+ }
+} {{} 2 1}
+do_test insert2-2.3 {
+ execsql {
+ DELETE FROM t3;
+ INSERT INTO t3(c,a,b) SELECT x, 'hi', y FROM t4;
+ SELECT * FROM t3;
+ }
+} {hi 2 1}
+
+integrity_check insert2-3.0
+
+# File table t4 with lots of data
+#
+do_test insert2-3.1 {
+ execsql {
+ SELECT * from t4;
+ }
+} {1 2}
+do_test insert2-3.2 {
+ set x [db total_changes]
+ execsql {
+ BEGIN;
+ INSERT INTO t4 VALUES(2,4);
+ INSERT INTO t4 VALUES(3,6);
+ INSERT INTO t4 VALUES(4,8);
+ INSERT INTO t4 VALUES(5,10);
+ INSERT INTO t4 VALUES(6,12);
+ INSERT INTO t4 VALUES(7,14);
+ INSERT INTO t4 VALUES(8,16);
+ INSERT INTO t4 VALUES(9,18);
+ INSERT INTO t4 VALUES(10,20);
+ COMMIT;
+ }
+ expr [db total_changes] - $x
+} {9}
+do_test insert2-3.2.1 {
+ execsql {
+ SELECT count(*) FROM t4;
+ }
+} {10}
+do_test insert2-3.3 {
+ ifcapable subquery {
+ execsql {
+ BEGIN;
+ INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;
+ INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;
+ INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;
+ INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;
+ COMMIT;
+ SELECT count(*) FROM t4;
+ }
+ } else {
+ db function max_x_t4 {execsql {SELECT max(x) FROM t4}}
+ execsql {
+ BEGIN;
+ INSERT INTO t4 SELECT x+max_x_t4() ,y FROM t4;
+ INSERT INTO t4 SELECT x+max_x_t4() ,y FROM t4;
+ INSERT INTO t4 SELECT x+max_x_t4() ,y FROM t4;
+ INSERT INTO t4 SELECT x+max_x_t4() ,y FROM t4;
+ COMMIT;
+ SELECT count(*) FROM t4;
+ }
+ }
+} {160}
+do_test insert2-3.4 {
+ execsql {
+ BEGIN;
+ UPDATE t4 SET y='lots of data for the row where x=' || x
+ || ' and y=' || y || ' - even more data to fill space';
+ COMMIT;
+ SELECT count(*) FROM t4;
+ }
+} {160}
+do_test insert2-3.5 {
+ ifcapable subquery {
+ execsql {
+ BEGIN;
+ INSERT INTO t4 SELECT x+(SELECT max(x)+1 FROM t4),y FROM t4;
+ SELECT count(*) from t4;
+ ROLLBACK;
+ }
+ } else {
+ execsql {
+ BEGIN;
+ INSERT INTO t4 SELECT x+max_x_t4()+1,y FROM t4;
+ SELECT count(*) from t4;
+ ROLLBACK;
+ }
+ }
+} {320}
+do_test insert2-3.6 {
+ execsql {
+ SELECT count(*) FROM t4;
+ }
+} {160}
+do_test insert2-3.7 {
+ execsql {
+ BEGIN;
+ DELETE FROM t4 WHERE x!=123;
+ SELECT count(*) FROM t4;
+ ROLLBACK;
+ }
+} {1}
+do_test insert2-3.8 {
+ db changes
+} {159}
+integrity_check insert2-3.9
+
+# Ticket #901
+#
+ifcapable tempdb {
+ do_test insert2-4.1 {
+ execsql {
+ CREATE TABLE Dependencies(depId integer primary key,
+ class integer, name str, flag str);
+ CREATE TEMPORARY TABLE DepCheck(troveId INT, depNum INT,
+ flagCount INT, isProvides BOOL, class INTEGER, name STRING,
+ flag STRING);
+ INSERT INTO DepCheck
+ VALUES(-1, 0, 1, 0, 2, 'libc.so.6', 'GLIBC_2.0');
+ INSERT INTO Dependencies
+ SELECT DISTINCT
+ NULL,
+ DepCheck.class,
+ DepCheck.name,
+ DepCheck.flag
+ FROM DepCheck LEFT OUTER JOIN Dependencies ON
+ DepCheck.class == Dependencies.class AND
+ DepCheck.name == Dependencies.name AND
+ DepCheck.flag == Dependencies.flag
+ WHERE
+ Dependencies.depId is NULL;
+ };
+ } {}
+}
+
+#--------------------------------------------------------------------
+# Test that the INSERT works when the SELECT statement (a) references
+# the table being inserted into and (b) is optimized to use an index
+# only.
+do_test insert2-5.1 {
+ execsql {
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES(1, 2);
+ CREATE INDEX t2i1 ON t2(a);
+ INSERT INTO t2 SELECT a, 3 FROM t2 WHERE a = 1;
+ SELECT * FROM t2;
+ }
+} {1 2 1 3}
+ifcapable subquery {
+ do_test insert2-5.2 {
+ execsql {
+ INSERT INTO t2 SELECT (SELECT a FROM t2), 4;
+ SELECT * FROM t2;
+ }
+ } {1 2 1 3 1 4}
+}
+
+finish_test
diff --git a/test/insert3.test b/test/insert3.test
new file mode 100644
index 0000000..6b253e0
--- /dev/null
+++ b/test/insert3.test
@@ -0,0 +1,205 @@
+# 2005 January 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing corner cases of the INSERT statement.
+#
+# $Id: insert3.test,v 1.9 2009/04/23 14:58:40 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# All the tests in this file require trigger support
+#
+ifcapable {trigger} {
+
+# Create a table and a corresponding insert trigger. Do a self-insert
+# into the table.
+#
+do_test insert3-1.0 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ CREATE TABLE log(x UNIQUE, y);
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ UPDATE log SET y=y+1 WHERE x=new.a;
+ INSERT OR IGNORE INTO log VALUES(new.a, 1);
+ END;
+ INSERT INTO t1 VALUES('hello','world');
+ INSERT INTO t1 VALUES(5,10);
+ SELECT * FROM log ORDER BY x;
+ }
+} {5 1 hello 1}
+do_test insert3-1.1 {
+ execsql {
+ INSERT INTO t1 SELECT a, b+10 FROM t1;
+ SELECT * FROM log ORDER BY x;
+ }
+} {5 2 hello 2}
+do_test insert3-1.2 {
+ execsql {
+ CREATE TABLE log2(x PRIMARY KEY,y);
+ CREATE TRIGGER r2 BEFORE INSERT ON t1 BEGIN
+ UPDATE log2 SET y=y+1 WHERE x=new.b;
+ INSERT OR IGNORE INTO log2 VALUES(new.b,1);
+ END;
+ INSERT INTO t1 VALUES(453,'hi');
+ SELECT * FROM log ORDER BY x;
+ }
+} {5 2 453 1 hello 2}
+do_test insert3-1.3 {
+ execsql {
+ SELECT * FROM log2 ORDER BY x;
+ }
+} {hi 1}
+ifcapable compound {
+ do_test insert3-1.4.1 {
+ execsql {
+ INSERT INTO t1 SELECT * FROM t1;
+ SELECT 'a:', x, y FROM log UNION ALL
+ SELECT 'b:', x, y FROM log2 ORDER BY x;
+ }
+ } {a: 5 4 b: 10 2 b: 20 1 a: 453 2 a: hello 4 b: hi 2 b: world 1}
+ do_test insert3-1.4.2 {
+ execsql {
+ SELECT 'a:', x, y FROM log UNION ALL
+ SELECT 'b:', x, y FROM log2 ORDER BY x, y;
+ }
+ } {a: 5 4 b: 10 2 b: 20 1 a: 453 2 a: hello 4 b: hi 2 b: world 1}
+ do_test insert3-1.5 {
+ execsql {
+ INSERT INTO t1(a) VALUES('xyz');
+ SELECT * FROM log ORDER BY x;
+ }
+ } {5 4 453 2 hello 4 xyz 1}
+}
+
+do_test insert3-2.1 {
+ execsql {
+ CREATE TABLE t2(
+ a INTEGER PRIMARY KEY,
+ b DEFAULT 'b',
+ c DEFAULT 'c'
+ );
+ CREATE TABLE t2dup(a,b,c);
+ CREATE TRIGGER t2r1 BEFORE INSERT ON t2 BEGIN
+ INSERT INTO t2dup(a,b,c) VALUES(new.a,new.b,new.c);
+ END;
+ INSERT INTO t2(a) VALUES(123);
+ INSERT INTO t2(b) VALUES(234);
+ INSERT INTO t2(c) VALUES(345);
+ SELECT * FROM t2dup;
+ }
+} {123 b c -1 234 c -1 b 345}
+do_test insert3-2.2 {
+ execsql {
+ DELETE FROM t2dup;
+ INSERT INTO t2(a) SELECT 1 FROM t1 LIMIT 1;
+ INSERT INTO t2(b) SELECT 987 FROM t1 LIMIT 1;
+ INSERT INTO t2(c) SELECT 876 FROM t1 LIMIT 1;
+ SELECT * FROM t2dup;
+ }
+} {1 b c -1 987 c -1 b 876}
+
+# Test for proper detection of malformed WHEN clauses on INSERT triggers.
+#
+do_test insert3-3.1 {
+ execsql {
+ CREATE TABLE t3(a,b,c);
+ CREATE TRIGGER t3r1 BEFORE INSERT on t3 WHEN nosuchcol BEGIN
+ SELECT 'illegal WHEN clause';
+ END;
+ }
+} {}
+do_test insert3-3.2 {
+ catchsql {
+ INSERT INTO t3 VALUES(1,2,3)
+ }
+} {1 {no such column: nosuchcol}}
+do_test insert3-3.3 {
+ execsql {
+ CREATE TABLE t4(a,b,c);
+ CREATE TRIGGER t4r1 AFTER INSERT on t4 WHEN nosuchcol BEGIN
+ SELECT 'illegal WHEN clause';
+ END;
+ }
+} {}
+do_test insert3-3.4 {
+ catchsql {
+ INSERT INTO t4 VALUES(1,2,3)
+ }
+} {1 {no such column: nosuchcol}}
+
+} ;# ifcapable {trigger}
+
+# Tests for the INSERT INTO ... DEFAULT VALUES construct
+#
+do_test insert3-3.5 {
+ execsql {
+ CREATE TABLE t5(
+ a INTEGER PRIMARY KEY,
+ b DEFAULT 'xyz'
+ );
+ INSERT INTO t5 DEFAULT VALUES;
+ SELECT * FROM t5;
+ }
+} {1 xyz}
+do_test insert3-3.6 {
+ execsql {
+ INSERT INTO t5 DEFAULT VALUES;
+ SELECT * FROM t5;
+ }
+} {1 xyz 2 xyz}
+
+ifcapable bloblit {
+ do_test insert3-3.7 {
+ execsql {
+ CREATE TABLE t6(x,y DEFAULT 4.3, z DEFAULT x'6869');
+ INSERT INTO t6 DEFAULT VALUES;
+ SELECT * FROM t6;
+ }
+ } {{} 4.3 hi}
+}
+
+foreach tab [db eval {SELECT name FROM sqlite_master WHERE type = 'table'}] {
+ db eval "DROP TABLE $tab"
+}
+db close
+sqlite3 db test.db
+
+#-------------------------------------------------------------------------
+# While developing tests for a different feature (savepoint) the following
+# sequence was found to cause an assert() in btree.c to fail. These
+# tests are included to ensure that that bug is fixed.
+#
+do_test insert3-4.1 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(a, b);
+ BEGIN;
+ INSERT INTO t1 VALUES(randstr(10,400),randstr(10,400),randstr(10,400));
+ }
+ set r "randstr(10,400)"
+ for {set ii 0} {$ii < 10} {incr ii} {
+ execsql "INSERT INTO t1 SELECT $r, $r, $r FROM t1"
+ }
+ execsql { COMMIT }
+} {}
+do_test insert3-4.2 {
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ UPDATE t1 SET a = randstr(10,10) WHERE (rowid%4)==0;
+ DELETE FROM t1 WHERE rowid%2;
+ INSERT INTO t1 SELECT randstr(10,400), randstr(10,400), c FROM t1;
+ COMMIT;
+ }
+} {}
+
+finish_test
diff --git a/test/insert4.test b/test/insert4.test
new file mode 100644
index 0000000..cb02b9d
--- /dev/null
+++ b/test/insert4.test
@@ -0,0 +1,389 @@
+# 2007 January 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the INSERT transfer optimization.
+#
+# $Id: insert4.test,v 1.10 2008/01/21 16:22:46 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !view||!subquery {
+ finish_test
+ return
+}
+
+# The sqlite3_xferopt_count variable is incremented whenever the
+# insert transfer optimization applies.
+#
+# This procedure runs a test to see if the sqlite3_xferopt_count is
+# set to N.
+#
+proc xferopt_test {testname N} {
+ do_test $testname {set ::sqlite3_xferopt_count} $N
+}
+
+# Create tables used for testing.
+#
+execsql {
+ PRAGMA legacy_file_format = 0;
+ CREATE TABLE t1(a int, b int, check(b>a));
+ CREATE TABLE t2(x int, y int);
+ CREATE VIEW v2 AS SELECT y, x FROM t2;
+ CREATE TABLE t3(a int, b int);
+}
+
+# Ticket #2252. Make sure the an INSERT from identical tables
+# does not violate constraints.
+#
+do_test insert4-1.1 {
+ set sqlite3_xferopt_count 0
+ execsql {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES(9,1);
+ }
+ catchsql {
+ INSERT INTO t1 SELECT * FROM t2;
+ }
+} {1 {constraint failed}}
+xferopt_test insert4-1.2 0
+do_test insert4-1.3 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {}
+
+# Tests to make sure that the transfer optimization is not occurring
+# when it is not a valid optimization.
+#
+# The SELECT must be against a real table.
+do_test insert4-2.1.1 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 SELECT 4, 8;
+ SELECT * FROM t1;
+ }
+} {4 8}
+xferopt_test insert4-2.1.2 0
+do_test insert4-2.2.1 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 SELECT * FROM v2;
+ SELECT * FROM t1;
+ }
+} {0 {1 9}}
+xferopt_test insert4-2.2.2 0
+
+# Do not run the transfer optimization if there is a LIMIT clause
+#
+do_test insert4-2.3.1 {
+ execsql {
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES(9,1);
+ INSERT INTO t2 SELECT y, x FROM t2;
+ INSERT INTO t3 SELECT * FROM t2 LIMIT 1;
+ SELECT * FROM t3;
+ }
+} {9 1}
+xferopt_test insert4-2.3.2 0
+do_test insert4-2.3.3 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
+ SELECT * FROM t1;
+ }
+} {1 {constraint failed}}
+xferopt_test insert4-2.3.4 0
+
+# Do not run the transfer optimization if there is a DISTINCT
+#
+do_test insert4-2.4.1 {
+ execsql {
+ DELETE FROM t3;
+ INSERT INTO t3 SELECT DISTINCT * FROM t2;
+ SELECT * FROM t3;
+ }
+} {9 1 1 9}
+xferopt_test insert4-2.4.2 0
+do_test insert4-2.4.3 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 SELECT DISTINCT * FROM t2;
+ }
+} {1 {constraint failed}}
+xferopt_test insert4-2.4.4 0
+
+# The following procedure constructs two tables then tries to transfer
+# data from one table to the other. Checks are made to make sure the
+# transfer is successful and that the transfer optimization was used or
+# not, as appropriate.
+#
+# xfer_check TESTID XFER-USED INIT-DATA DEST-SCHEMA SRC-SCHEMA
+#
+# The TESTID argument is the symbolic name for this test. The XFER-USED
+# argument is true if the transfer optimization should be employed and
+# false if not. INIT-DATA is a single row of data that is to be
+# transfered. DEST-SCHEMA and SRC-SCHEMA are table declarations for
+# the destination and source tables.
+#
+proc xfer_check {testid xferused initdata destschema srcschema} {
+ execsql "CREATE TABLE dest($destschema)"
+ execsql "CREATE TABLE src($srcschema)"
+ execsql "INSERT INTO src VALUES([join $initdata ,])"
+ set ::sqlite3_xferopt_count 0
+ do_test $testid.1 {
+ execsql {
+ INSERT INTO dest SELECT * FROM src;
+ SELECT * FROM dest;
+ }
+ } $initdata
+ do_test $testid.2 {
+ set ::sqlite3_xferopt_count
+ } $xferused
+ execsql {
+ DROP TABLE dest;
+ DROP TABLE src;
+ }
+}
+
+
+# Do run the transfer optimization if tables have identical
+# CHECK constraints.
+#
+xfer_check insert4-3.1 1 {1 9} \
+ {a int, b int CHECK(b>a)} \
+ {x int, y int CHECK(y>x)}
+xfer_check insert4-3.2 1 {1 9} \
+ {a int, b int CHECK(b>a)} \
+ {x int CHECK(y>x), y int}
+
+# Do run the transfer optimization if the destination table lacks
+# any CHECK constraints regardless of whether or not there are CHECK
+# constraints on the source table.
+#
+xfer_check insert4-3.3 1 {1 9} \
+ {a int, b int} \
+ {x int, y int CHECK(y>x)}
+
+# Do run the transfer optimization if the destination table omits
+# NOT NULL constraints that the source table has.
+#
+xfer_check insert4-3.4 0 {1 9} \
+ {a int, b int CHECK(b>a)} \
+ {x int, y int}
+
+# Do not run the optimization if the destination has NOT NULL
+# constraints that the source table lacks.
+#
+xfer_check insert4-3.5 0 {1 9} \
+ {a int, b int NOT NULL} \
+ {x int, y int}
+xfer_check insert4-3.6 0 {1 9} \
+ {a int, b int NOT NULL} \
+ {x int NOT NULL, y int}
+xfer_check insert4-3.7 0 {1 9} \
+ {a int NOT NULL, b int NOT NULL} \
+ {x int NOT NULL, y int}
+xfer_check insert4-3.8 0 {1 9} \
+ {a int NOT NULL, b int} \
+ {x int, y int}
+
+
+# Do run the transfer optimization if the destination table and
+# source table have the same NOT NULL constraints or if the
+# source table has extra NOT NULL constraints.
+#
+xfer_check insert4-3.9 1 {1 9} \
+ {a int, b int} \
+ {x int NOT NULL, y int}
+xfer_check insert4-3.10 1 {1 9} \
+ {a int, b int} \
+ {x int NOT NULL, y int NOT NULL}
+xfer_check insert4-3.11 1 {1 9} \
+ {a int NOT NULL, b int} \
+ {x int NOT NULL, y int NOT NULL}
+xfer_check insert4-3.12 1 {1 9} \
+ {a int, b int NOT NULL} \
+ {x int NOT NULL, y int NOT NULL}
+
+# Do not run the optimization if any corresponding table
+# columns have different affinities.
+#
+xfer_check insert4-3.20 0 {1 9} \
+ {a text, b int} \
+ {x int, b int}
+xfer_check insert4-3.21 0 {1 9} \
+ {a int, b int} \
+ {x text, b int}
+
+# "int" and "integer" are equivalent so the optimization should
+# run here.
+#
+xfer_check insert4-3.22 1 {1 9} \
+ {a int, b int} \
+ {x integer, b int}
+
+# Ticket #2291.
+#
+
+do_test insert4-4.1a {
+ execsql {CREATE TABLE t4(a, b, UNIQUE(a,b))}
+} {}
+ifcapable vacuum {
+ do_test insert4-4.1b {
+ execsql {
+ INSERT INTO t4 VALUES(NULL,0);
+ INSERT INTO t4 VALUES(NULL,1);
+ INSERT INTO t4 VALUES(NULL,1);
+ VACUUM;
+ }
+ } {}
+}
+
+# Check some error conditions:
+#
+do_test insert4-5.1 {
+ # Table does not exist.
+ catchsql { INSERT INTO t2 SELECT * FROM nosuchtable }
+} {1 {no such table: nosuchtable}}
+do_test insert4-5.2 {
+ # Number of columns does not match.
+ catchsql {
+ CREATE TABLE t5(a, b, c);
+ INSERT INTO t4 SELECT * FROM t5;
+ }
+} {1 {table t4 has 2 columns but 3 values were supplied}}
+
+do_test insert4-6.1 {
+ set ::sqlite3_xferopt_count 0
+ execsql {
+ CREATE INDEX t2_i2 ON t2(x, y COLLATE nocase);
+ CREATE INDEX t2_i1 ON t2(x ASC, y DESC);
+ CREATE INDEX t3_i1 ON t3(a, b);
+ INSERT INTO t2 SELECT * FROM t3;
+ }
+ set ::sqlite3_xferopt_count
+} {0}
+do_test insert4-6.2 {
+ set ::sqlite3_xferopt_count 0
+ execsql {
+ DROP INDEX t2_i2;
+ INSERT INTO t2 SELECT * FROM t3;
+ }
+ set ::sqlite3_xferopt_count
+} {0}
+do_test insert4-6.3 {
+ set ::sqlite3_xferopt_count 0
+ execsql {
+ DROP INDEX t2_i1;
+ CREATE INDEX t2_i1 ON t2(x ASC, y ASC);
+ INSERT INTO t2 SELECT * FROM t3;
+ }
+ set ::sqlite3_xferopt_count
+} {1}
+do_test insert4-6.4 {
+ set ::sqlite3_xferopt_count 0
+ execsql {
+ DROP INDEX t2_i1;
+ CREATE INDEX t2_i1 ON t2(x ASC, y COLLATE RTRIM);
+ INSERT INTO t2 SELECT * FROM t3;
+ }
+ set ::sqlite3_xferopt_count
+} {0}
+
+
+do_test insert4-6.5 {
+ execsql {
+ CREATE TABLE t6a(x CHECK( x<>'abc' ));
+ INSERT INTO t6a VALUES('ABC');
+ SELECT * FROM t6a;
+ }
+} {ABC}
+do_test insert4-6.6 {
+ execsql {
+ CREATE TABLE t6b(x CHECK( x<>'abc' COLLATE nocase ));
+ }
+ catchsql {
+ INSERT INTO t6b SELECT * FROM t6a;
+ }
+} {1 {constraint failed}}
+do_test insert4-6.7 {
+ execsql {
+ DROP TABLE t6b;
+ CREATE TABLE t6b(x CHECK( x COLLATE nocase <>'abc' ));
+ }
+ catchsql {
+ INSERT INTO t6b SELECT * FROM t6a;
+ }
+} {1 {constraint failed}}
+
+# Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
+# Disable the xfer optimization if the destination table contains
+# a foreign key constraint
+#
+ifcapable foreignkey {
+ do_test insert4-7.1 {
+ set ::sqlite3_xferopt_count 0
+ execsql {
+ CREATE TABLE t7a(x INTEGER PRIMARY KEY); INSERT INTO t7a VALUES(123);
+ CREATE TABLE t7b(y INTEGER REFERENCES t7a);
+ CREATE TABLE t7c(z INT); INSERT INTO t7c VALUES(234);
+ INSERT INTO t7b SELECT * FROM t7c;
+ SELECT * FROM t7b;
+ }
+ } {234}
+ do_test insert4-7.2 {
+ set ::sqlite3_xferopt_count
+ } {1}
+ do_test insert4-7.3 {
+ set ::sqlite3_xferopt_count 0
+ execsql {
+ DELETE FROM t7b;
+ PRAGMA foreign_keys=ON;
+ }
+ catchsql {
+ INSERT INTO t7b SELECT * FROM t7c;
+ }
+ } {1 {foreign key constraint failed}}
+ do_test insert4-7.4 {
+ execsql {SELECT * FROM t7b}
+ } {}
+ do_test insert4-7.5 {
+ set ::sqlite3_xferopt_count
+ } {0}
+ do_test insert4-7.6 {
+ set ::sqlite3_xferopt_count 0
+ execsql {
+ DELETE FROM t7b; DELETE FROM t7c;
+ INSERT INTO t7c VALUES(123);
+ INSERT INTO t7b SELECT * FROM t7c;
+ SELECT * FROM t7b;
+ }
+ } {123}
+ do_test insert4-7.7 {
+ set ::sqlite3_xferopt_count
+ } {0}
+ do_test insert4-7.7 {
+ set ::sqlite3_xferopt_count 0
+ execsql {
+ PRAGMA foreign_keys=OFF;
+ DELETE FROM t7b;
+ INSERT INTO t7b SELECT * FROM t7c;
+ SELECT * FROM t7b;
+ }
+ } {123}
+ do_test insert4-7.8 {
+ set ::sqlite3_xferopt_count
+ } {1}
+}
+
+finish_test
diff --git a/test/insert5.test b/test/insert5.test
new file mode 100644
index 0000000..1e58902
--- /dev/null
+++ b/test/insert5.test
@@ -0,0 +1,117 @@
+# 2007 November 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# The tests in this file ensure that a temporary table is used
+# when required by an "INSERT INTO ... SELECT ..." statement.
+#
+# $Id: insert5.test,v 1.5 2008/08/04 03:51:24 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+# Return true if the compilation of the sql passed as an argument
+# includes the opcode OpenEphemeral. An "INSERT INTO ... SELECT"
+# statement includes such an opcode if a temp-table is used
+# to store intermediate results.
+#
+proc uses_temp_table {sql} {
+ return [expr {[lsearch [execsql "EXPLAIN $sql"] OpenEphemeral]>=0}]
+}
+
+# Construct the sample database.
+#
+do_test insert5-1.0 {
+ forcedelete test2.db test2.db-journal
+ execsql {
+ CREATE TABLE MAIN(Id INTEGER, Id1 INTEGER);
+ CREATE TABLE B(Id INTEGER, Id1 INTEGER);
+ CREATE VIEW v1 AS SELECT * FROM B;
+ CREATE VIEW v2 AS SELECT * FROM MAIN;
+ INSERT INTO MAIN(Id,Id1) VALUES(2,3);
+ INSERT INTO B(Id,Id1) VALUES(2,3);
+ }
+} {}
+
+# Run the query.
+#
+ifcapable compound {
+ do_test insert5-1.1 {
+ execsql {
+ INSERT INTO B
+ SELECT * FROM B UNION ALL
+ SELECT * FROM MAIN WHERE exists (select * FROM B WHERE B.Id = MAIN.Id);
+ SELECT * FROM B;
+ }
+ } {2 3 2 3 2 3}
+} else {
+ do_test insert5-1.1 {
+ execsql {
+ INSERT INTO B SELECT * FROM B;
+ INSERT INTO B
+ SELECT * FROM MAIN WHERE exists (select * FROM B WHERE B.Id = MAIN.Id);
+ SELECT * FROM B;
+ }
+ } {2 3 2 3 2 3}
+}
+do_test insert5-2.1 {
+ uses_temp_table { INSERT INTO b SELECT * FROM main }
+} {0}
+do_test insert5-2.2 {
+ uses_temp_table { INSERT INTO b SELECT * FROM b }
+} {1}
+do_test insert5-2.3 {
+ uses_temp_table { INSERT INTO b SELECT (SELECT id FROM b), id1 FROM main }
+} {1}
+do_test insert5-2.4 {
+ uses_temp_table { INSERT INTO b SELECT id1, (SELECT id FROM b) FROM main }
+} {1}
+do_test insert5-2.5 {
+ uses_temp_table {
+ INSERT INTO b
+ SELECT * FROM main WHERE id = (SELECT id1 FROM b WHERE main.id = b.id) }
+} {1}
+do_test insert5-2.6 {
+ uses_temp_table { INSERT INTO b SELECT * FROM v1 }
+} {1}
+do_test insert5-2.7 {
+ uses_temp_table { INSERT INTO b SELECT * FROM v2 }
+} {0}
+do_test insert5-2.8 {
+ uses_temp_table {
+ INSERT INTO b
+ SELECT * FROM main WHERE id > 10 AND max(id1, (SELECT id FROM b)) > 10;
+ }
+} {1}
+
+# UPDATE: Using a column from the outer query (main.id) in the GROUP BY
+# or ORDER BY of a sub-query is no longer supported.
+#
+# do_test insert5-2.9 {
+# uses_temp_table {
+# INSERT INTO b
+# SELECT * FROM main
+# WHERE id > 10 AND (SELECT count(*) FROM v2 GROUP BY main.id)
+# }
+# } {}
+do_test insert5-2.9 {
+ catchsql {
+ INSERT INTO b
+ SELECT * FROM main
+ WHERE id > 10 AND (SELECT count(*) FROM v2 GROUP BY main.id)
+ }
+} {1 {no such column: main.id}}
+
+finish_test
diff --git a/test/intarray.test b/test/intarray.test
new file mode 100644
index 0000000..2aba080
--- /dev/null
+++ b/test/intarray.test
@@ -0,0 +1,109 @@
+# 2009 November 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the "intarray" object implemented
+# in test_intarray.c.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ return
+}
+
+do_test intarray-1.0 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ }
+ for {set i 1} {$i<=999} {incr i} {
+ set b [format {x%03d} $i]
+ db eval {INSERT INTO t1(a,b) VALUES($i,$b)}
+ }
+ db eval {
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t2 SELECT * FROM t1;
+ SELECT b FROM t1 WHERE a IN (12,34,56,78) ORDER BY a
+ }
+} {x012 x034 x056 x078}
+
+do_test intarray-1.1 {
+ set ia1 [sqlite3_intarray_create db ia1]
+ set ia2 [sqlite3_intarray_create db ia2]
+ set ia3 [sqlite3_intarray_create db ia3]
+ set ia4 [sqlite3_intarray_create db ia4]
+ db eval {
+ SELECT type, name FROM sqlite_temp_master
+ ORDER BY name
+ }
+} {table ia1 table ia2 table ia3 table ia4}
+
+do_test intarray-1.2 {
+ db eval {
+ SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
+ }
+} {}
+
+do_test intarray-1.3 {
+ sqlite3_intarray_bind $ia3 45 123 678
+ db eval {
+ SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
+ }
+} {x045 x123 x678}
+
+do_test intarray-1.4 {
+ db eval {
+ SELECT count(b) FROM t1 WHERE a NOT IN ia3 ORDER BY a
+ }
+} {996}
+
+#explain {SELECT b FROM t1 WHERE a NOT IN ia3}
+
+do_test intarray-1.5 {
+ set cmd sqlite3_intarray_bind
+ lappend cmd $ia1
+ for {set i 1} {$i<=999} {incr i} {
+ lappend cmd $i
+ lappend cmd [expr {$i+1000}]
+ lappend cmd [expr {$i+2000}]
+ }
+ eval $cmd
+ db eval {
+ REPLACE INTO t1 SELECT * FROM t2;
+ DELETE FROM t1 WHERE a NOT IN ia1;
+ SELECT count(*) FROM t1;
+ }
+} {999}
+
+do_test intarray-1.6 {
+ db eval {
+ DELETE FROM t1 WHERE a IN ia1;
+ SELECT count(*) FROM t1;
+ }
+} {0}
+
+do_test intarray-2.1 {
+ db eval {
+ CREATE TEMP TABLE t3(p,q);
+ INSERT INTO t3 SELECT * FROM t2;
+ SELECT count(*) FROM t3 WHERE p IN ia1;
+ }
+} {999}
+
+do_test intarray-2.2 {
+ set ia5 [sqlite3_intarray_create db ia5]
+ db eval {
+ SELECT count(*) FROM t3 WHERE p IN ia1;
+ }
+} {999}
+
+finish_test
diff --git a/test/interrupt.test b/test/interrupt.test
new file mode 100644
index 0000000..b311cbb
--- /dev/null
+++ b/test/interrupt.test
@@ -0,0 +1,183 @@
+# 2004 Feb 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is the sqlite_interrupt() API.
+#
+# $Id: interrupt.test,v 1.16 2008/01/16 17:46:38 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set DB [sqlite3_connection_pointer db]
+
+# This routine attempts to execute the sql in $sql. It triggers an
+# interrupt at progressively later and later points during the processing
+# and checks to make sure SQLITE_INTERRUPT is returned. Eventually,
+# the routine completes successfully.
+#
+proc interrupt_test {testid sql result {initcnt 0}} {
+ set orig_sum [cksum]
+ set i $initcnt
+ while 1 {
+ incr i
+ set ::sqlite_interrupt_count $i
+ do_test $testid.$i.1 [format {
+ set ::r [catchsql %s]
+ set ::code [db errorcode]
+ expr {$::code==0 || $::code==9}
+ } [list $sql]] 1
+ if {$::code==9} {
+ do_test $testid.$i.2 {
+ cksum
+ } $orig_sum
+ } else {
+ do_test $testid.$i.99 {
+ set ::r
+ } [list 0 $result]
+ break
+ }
+ }
+ set ::sqlite_interrupt_count 0
+}
+
+do_test interrupt-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ SELECT name FROM sqlite_master;
+ }
+} {t1}
+interrupt_test interrupt-1.2 {DROP TABLE t1} {}
+do_test interrupt-1.3 {
+ execsql {
+ SELECT name FROM sqlite_master;
+ }
+} {}
+integrity_check interrupt-1.4
+
+do_test interrrupt-2.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,randstr(300,400));
+ INSERT INTO t1 SELECT a+1, randstr(300,400) FROM t1;
+ INSERT INTO t1 SELECT a+2, a || '-' || b FROM t1;
+ INSERT INTO t1 SELECT a+4, a || '-' || b FROM t1;
+ INSERT INTO t1 SELECT a+8, a || '-' || b FROM t1;
+ INSERT INTO t1 SELECT a+16, a || '-' || b FROM t1;
+ INSERT INTO t1 SELECT a+32, a || '-' || b FROM t1;
+ COMMIT;
+ UPDATE t1 SET b=substr(b,-5,5);
+ SELECT count(*) from t1;
+ }
+} 64
+set origsize [file size test.db]
+set cksum [db eval {SELECT md5sum(a || b) FROM t1}]
+ifcapable {vacuum} {
+ interrupt_test interrupt-2.2 {VACUUM} {} 100
+}
+do_test interrupt-2.3 {
+ execsql {
+ SELECT md5sum(a || b) FROM t1;
+ }
+} $cksum
+ifcapable {vacuum && !default_autovacuum} {
+ do_test interrupt-2.4 {
+ expr {$::origsize>[file size test.db]}
+ } 1
+}
+ifcapable {explain} {
+ do_test interrupt-2.5 {
+ set sql {EXPLAIN SELECT max(a,b), a, b FROM t1}
+ execsql $sql
+ set rc [catch {db eval $sql {sqlite3_interrupt $DB}} msg]
+ lappend rc $msg
+ } {1 interrupted}
+}
+integrity_check interrupt-2.6
+
+# Ticket #594. If an interrupt occurs in the middle of a transaction
+# and that transaction is later rolled back, the internal schema tables do
+# not reset.
+#
+# UPDATE: Interrupting a DML statement in the middle of a transaction now
+# causes the transaction to roll back. Leaving the transaction open after
+# an SQL statement was interrupted halfway through risks database corruption.
+#
+ifcapable tempdb {
+ for {set i 1} {$i<50} {incr i 5} {
+ do_test interrupt-3.$i.1 {
+ execsql {
+ BEGIN;
+ CREATE TEMP TABLE t2(x,y);
+ SELECT name FROM sqlite_temp_master;
+ }
+ } {t2}
+ do_test interrupt-3.$i.2 {
+ set ::sqlite_interrupt_count $::i
+ catchsql {
+ INSERT INTO t2 SELECT * FROM t1;
+ }
+ } {1 interrupted}
+ do_test interrupt-3.$i.3 {
+ execsql {
+ SELECT name FROM sqlite_temp_master;
+ }
+ } {}
+ do_test interrupt-3.$i.4 {
+ catchsql {
+ ROLLBACK
+ }
+ } {1 {cannot rollback - no transaction is active}}
+ do_test interrupt-3.$i.5 {
+ catchsql {SELECT name FROM sqlite_temp_master};
+ execsql {
+ SELECT name FROM sqlite_temp_master;
+ }
+ } {}
+ }
+}
+
+# There are reports of a memory leak if an interrupt occurs during
+# the beginning of a complex query - before the first callback. We
+# will try to reproduce it here:
+#
+execsql {
+ CREATE TABLE t2(a,b,c);
+ INSERT INTO t2 SELECT round(a/10), randstr(50,80), randstr(50,60) FROM t1;
+}
+set sql {
+ SELECT max(min(b,c)), min(max(b,c)), a FROM t2 GROUP BY a ORDER BY a;
+}
+set sqlite_interrupt_count 1000000
+execsql $sql
+set max_count [expr {1000000-$sqlite_interrupt_count}]
+for {set i 1} {$i<$max_count-5} {incr i 1} {
+ do_test interrupt-4.$i.1 {
+ set ::sqlite_interrupt_count $::i
+ catchsql $sql
+ } {1 interrupted}
+}
+
+# Interrupt during parsing
+#
+do_test interrupt-5.1 {
+ proc fake_interrupt {args} {
+ db collate fake_collation no-op
+ sqlite3_interrupt db
+ return SQLITE_OK
+ }
+ db collation_needed fake_interrupt
+ catchsql {
+ CREATE INDEX fake ON fake1(a COLLATE fake_collation, b, c DESC);
+ }
+} {1 interrupt}
+
+finish_test
diff --git a/test/intpkey.test b/test/intpkey.test
new file mode 100644
index 0000000..05b6cdf
--- /dev/null
+++ b/test/intpkey.test
@@ -0,0 +1,605 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the special processing associated
+# with INTEGER PRIMARY KEY columns.
+#
+# $Id: intpkey.test,v 1.24 2007/11/29 17:43:28 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table with a primary key and a datatype other than
+# integer
+#
+do_test intpkey-1.0 {
+ execsql {
+ CREATE TABLE t1(a TEXT PRIMARY KEY, b, c);
+ }
+} {}
+
+# There should be an index associated with the primary key
+#
+do_test intpkey-1.1 {
+ execsql {
+ SELECT name FROM sqlite_master
+ WHERE type='index' AND tbl_name='t1';
+ }
+} {sqlite_autoindex_t1_1}
+
+# Now create a table with an integer primary key and verify that
+# there is no associated index.
+#
+do_test intpkey-1.2 {
+ execsql {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ SELECT name FROM sqlite_master
+ WHERE type='index' AND tbl_name='t1';
+ }
+} {}
+
+# Insert some records into the new table. Specify the primary key
+# and verify that the key is used as the record number.
+#
+do_test intpkey-1.3 {
+ execsql {
+ INSERT INTO t1 VALUES(5,'hello','world');
+ }
+ db last_insert_rowid
+} {5}
+do_test intpkey-1.4 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {5 hello world}
+do_test intpkey-1.5 {
+ execsql {
+ SELECT rowid, * FROM t1;
+ }
+} {5 5 hello world}
+
+# Attempting to insert a duplicate primary key should give a constraint
+# failure.
+#
+do_test intpkey-1.6 {
+ set r [catch {execsql {
+ INSERT INTO t1 VALUES(5,'second','entry');
+ }} msg]
+ lappend r $msg
+} {1 {PRIMARY KEY must be unique}}
+do_test intpkey-1.7 {
+ execsql {
+ SELECT rowid, * FROM t1;
+ }
+} {5 5 hello world}
+do_test intpkey-1.8 {
+ set r [catch {execsql {
+ INSERT INTO t1 VALUES(6,'second','entry');
+ }} msg]
+ lappend r $msg
+} {0 {}}
+do_test intpkey-1.8.1 {
+ db last_insert_rowid
+} {6}
+do_test intpkey-1.9 {
+ execsql {
+ SELECT rowid, * FROM t1;
+ }
+} {5 5 hello world 6 6 second entry}
+
+# A ROWID is automatically generated for new records that do not specify
+# the integer primary key.
+#
+do_test intpkey-1.10 {
+ execsql {
+ INSERT INTO t1(b,c) VALUES('one','two');
+ SELECT b FROM t1 ORDER BY b;
+ }
+} {hello one second}
+
+# Try to change the ROWID for the new entry.
+#
+do_test intpkey-1.11 {
+ execsql {
+ UPDATE t1 SET a=4 WHERE b='one';
+ SELECT * FROM t1;
+ }
+} {4 one two 5 hello world 6 second entry}
+
+# Make sure SELECT statements are able to use the primary key column
+# as an index.
+#
+do_test intpkey-1.12.1 {
+ execsql {
+ SELECT * FROM t1 WHERE a==4;
+ }
+} {4 one two}
+do_test intpkey-1.12.2 {
+ set sqlite_query_plan
+} {t1 *}
+
+# Try to insert a non-integer value into the primary key field. This
+# should result in a data type mismatch.
+#
+do_test intpkey-1.13.1 {
+ set r [catch {execsql {
+ INSERT INTO t1 VALUES('x','y','z');
+ }} msg]
+ lappend r $msg
+} {1 {datatype mismatch}}
+do_test intpkey-1.13.2 {
+ set r [catch {execsql {
+ INSERT INTO t1 VALUES('','y','z');
+ }} msg]
+ lappend r $msg
+} {1 {datatype mismatch}}
+do_test intpkey-1.14 {
+ set r [catch {execsql {
+ INSERT INTO t1 VALUES(3.4,'y','z');
+ }} msg]
+ lappend r $msg
+} {1 {datatype mismatch}}
+do_test intpkey-1.15 {
+ set r [catch {execsql {
+ INSERT INTO t1 VALUES(-3,'y','z');
+ }} msg]
+ lappend r $msg
+} {0 {}}
+do_test intpkey-1.16 {
+ execsql {SELECT * FROM t1}
+} {-3 y z 4 one two 5 hello world 6 second entry}
+
+#### INDICES
+# Check to make sure indices work correctly with integer primary keys
+#
+do_test intpkey-2.1 {
+ execsql {
+ CREATE INDEX i1 ON t1(b);
+ SELECT * FROM t1 WHERE b=='y'
+ }
+} {-3 y z}
+do_test intpkey-2.1.1 {
+ execsql {
+ SELECT * FROM t1 WHERE b=='y' AND rowid<0
+ }
+} {-3 y z}
+do_test intpkey-2.1.2 {
+ execsql {
+ SELECT * FROM t1 WHERE b=='y' AND rowid<0 AND rowid>=-20
+ }
+} {-3 y z}
+do_test intpkey-2.1.3 {
+ execsql {
+ SELECT * FROM t1 WHERE b>='y'
+ }
+} {-3 y z}
+do_test intpkey-2.1.4 {
+ execsql {
+ SELECT * FROM t1 WHERE b>='y' AND rowid<10
+ }
+} {-3 y z}
+
+do_test intpkey-2.2 {
+ execsql {
+ UPDATE t1 SET a=8 WHERE b=='y';
+ SELECT * FROM t1 WHERE b=='y';
+ }
+} {8 y z}
+do_test intpkey-2.3 {
+ execsql {
+ SELECT rowid, * FROM t1;
+ }
+} {4 4 one two 5 5 hello world 6 6 second entry 8 8 y z}
+do_test intpkey-2.4 {
+ execsql {
+ SELECT rowid, * FROM t1 WHERE b<'second'
+ }
+} {5 5 hello world 4 4 one two}
+do_test intpkey-2.4.1 {
+ execsql {
+ SELECT rowid, * FROM t1 WHERE 'second'>b
+ }
+} {5 5 hello world 4 4 one two}
+do_test intpkey-2.4.2 {
+ execsql {
+ SELECT rowid, * FROM t1 WHERE 8>rowid AND 'second'>b
+ }
+} {4 4 one two 5 5 hello world}
+do_test intpkey-2.4.3 {
+ execsql {
+ SELECT rowid, * FROM t1 WHERE 8>rowid AND 'second'>b AND 0<rowid
+ }
+} {4 4 one two 5 5 hello world}
+do_test intpkey-2.5 {
+ execsql {
+ SELECT rowid, * FROM t1 WHERE b>'a'
+ }
+} {5 5 hello world 4 4 one two 6 6 second entry 8 8 y z}
+do_test intpkey-2.6 {
+ execsql {
+ DELETE FROM t1 WHERE rowid=4;
+ SELECT * FROM t1 WHERE b>'a';
+ }
+} {5 hello world 6 second entry 8 y z}
+do_test intpkey-2.7 {
+ execsql {
+ UPDATE t1 SET a=-4 WHERE rowid=8;
+ SELECT * FROM t1 WHERE b>'a';
+ }
+} {5 hello world 6 second entry -4 y z}
+do_test intpkey-2.7 {
+ execsql {
+ SELECT * FROM t1
+ }
+} {-4 y z 5 hello world 6 second entry}
+
+# Do an SQL statement. Append the search count to the end of the result.
+#
+proc count sql {
+ set ::sqlite_search_count 0
+ return [concat [execsql $sql] $::sqlite_search_count]
+}
+
+# Create indices that include the integer primary key as one of their
+# columns.
+#
+do_test intpkey-3.1 {
+ execsql {
+ CREATE INDEX i2 ON t1(a);
+ }
+} {}
+do_test intpkey-3.2 {
+ count {
+ SELECT * FROM t1 WHERE a=5;
+ }
+} {5 hello world 0}
+do_test intpkey-3.3 {
+ count {
+ SELECT * FROM t1 WHERE a>4 AND a<6;
+ }
+} {5 hello world 2}
+do_test intpkey-3.4 {
+ count {
+ SELECT * FROM t1 WHERE b>='hello' AND b<'hello2';
+ }
+} {5 hello world 3}
+do_test intpkey-3.5 {
+ execsql {
+ CREATE INDEX i3 ON t1(c,a);
+ }
+} {}
+do_test intpkey-3.6 {
+ count {
+ SELECT * FROM t1 WHERE c=='world';
+ }
+} {5 hello world 3}
+do_test intpkey-3.7 {
+ execsql {INSERT INTO t1 VALUES(11,'hello','world')}
+ count {
+ SELECT * FROM t1 WHERE c=='world';
+ }
+} {5 hello world 11 hello world 5}
+do_test intpkey-3.8 {
+ count {
+ SELECT * FROM t1 WHERE c=='world' AND a>7;
+ }
+} {11 hello world 4}
+do_test intpkey-3.9 {
+ count {
+ SELECT * FROM t1 WHERE 7<a;
+ }
+} {11 hello world 1}
+
+# Test inequality constraints on integer primary keys and rowids
+#
+do_test intpkey-4.1 {
+ count {
+ SELECT * FROM t1 WHERE 11=rowid
+ }
+} {11 hello world 0}
+do_test intpkey-4.2 {
+ count {
+ SELECT * FROM t1 WHERE 11=rowid AND b=='hello'
+ }
+} {11 hello world 0}
+do_test intpkey-4.3 {
+ count {
+ SELECT * FROM t1 WHERE 11=rowid AND b=='hello' AND c IS NOT NULL;
+ }
+} {11 hello world 0}
+do_test intpkey-4.4 {
+ count {
+ SELECT * FROM t1 WHERE rowid==11
+ }
+} {11 hello world 0}
+do_test intpkey-4.5 {
+ count {
+ SELECT * FROM t1 WHERE oid==11 AND b=='hello'
+ }
+} {11 hello world 0}
+do_test intpkey-4.6 {
+ count {
+ SELECT * FROM t1 WHERE a==11 AND b=='hello' AND c IS NOT NULL;
+ }
+} {11 hello world 0}
+
+do_test intpkey-4.7 {
+ count {
+ SELECT * FROM t1 WHERE 8<rowid;
+ }
+} {11 hello world 1}
+do_test intpkey-4.8 {
+ count {
+ SELECT * FROM t1 WHERE 8<rowid AND 11>=oid;
+ }
+} {11 hello world 1}
+do_test intpkey-4.9 {
+ count {
+ SELECT * FROM t1 WHERE 11<=_rowid_ AND 12>=a;
+ }
+} {11 hello world 1}
+do_test intpkey-4.10 {
+ count {
+ SELECT * FROM t1 WHERE 0>=_rowid_;
+ }
+} {-4 y z 1}
+do_test intpkey-4.11 {
+ count {
+ SELECT * FROM t1 WHERE a<0;
+ }
+} {-4 y z 1}
+do_test intpkey-4.12 {
+ count {
+ SELECT * FROM t1 WHERE a<0 AND a>10;
+ }
+} {1}
+
+# Make sure it is OK to insert a rowid of 0
+#
+do_test intpkey-5.1 {
+ execsql {
+ INSERT INTO t1 VALUES(0,'zero','entry');
+ }
+ count {
+ SELECT * FROM t1 WHERE a=0;
+ }
+} {0 zero entry 0}
+do_test intpkey-5.2 {
+ execsql {
+ SELECT rowid, a FROM t1
+ }
+} {-4 -4 0 0 5 5 6 6 11 11}
+
+# Test the ability of the COPY command to put data into a
+# table that contains an integer primary key.
+#
+# COPY command has been removed. But we retain these tests so
+# that the tables will contain the right data for tests that follow.
+#
+do_test intpkey-6.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(20,'b-20','c-20');
+ INSERT INTO t1 VALUES(21,'b-21','c-21');
+ INSERT INTO t1 VALUES(22,'b-22','c-22');
+ COMMIT;
+ SELECT * FROM t1 WHERE a>=20;
+ }
+} {20 b-20 c-20 21 b-21 c-21 22 b-22 c-22}
+do_test intpkey-6.2 {
+ execsql {
+ SELECT * FROM t1 WHERE b=='hello'
+ }
+} {5 hello world 11 hello world}
+do_test intpkey-6.3 {
+ execsql {
+ DELETE FROM t1 WHERE b='b-21';
+ SELECT * FROM t1 WHERE b=='b-21';
+ }
+} {}
+do_test intpkey-6.4 {
+ execsql {
+ SELECT * FROM t1 WHERE a>=20
+ }
+} {20 b-20 c-20 22 b-22 c-22}
+
+# Do an insert of values with the columns specified out of order.
+#
+do_test intpkey-7.1 {
+ execsql {
+ INSERT INTO t1(c,b,a) VALUES('row','new',30);
+ SELECT * FROM t1 WHERE rowid>=30;
+ }
+} {30 new row}
+do_test intpkey-7.2 {
+ execsql {
+ SELECT * FROM t1 WHERE rowid>20;
+ }
+} {22 b-22 c-22 30 new row}
+
+# Do an insert from a select statement.
+#
+do_test intpkey-8.1 {
+ execsql {
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y, z);
+ INSERT INTO t2 SELECT * FROM t1;
+ SELECT rowid FROM t2;
+ }
+} {-4 0 5 6 11 20 22 30}
+do_test intpkey-8.2 {
+ execsql {
+ SELECT x FROM t2;
+ }
+} {-4 0 5 6 11 20 22 30}
+
+do_test intpkey-9.1 {
+ execsql {
+ UPDATE t1 SET c='www' WHERE c='world';
+ SELECT rowid, a, c FROM t1 WHERE c=='www';
+ }
+} {5 5 www 11 11 www}
+
+
+# Check insert of NULL for primary key
+#
+do_test intpkey-10.1 {
+ execsql {
+ DROP TABLE t2;
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y, z);
+ INSERT INTO t2 VALUES(NULL, 1, 2);
+ SELECT * from t2;
+ }
+} {1 1 2}
+do_test intpkey-10.2 {
+ execsql {
+ INSERT INTO t2 VALUES(NULL, 2, 3);
+ SELECT * from t2 WHERE x=2;
+ }
+} {2 2 3}
+do_test intpkey-10.3 {
+ execsql {
+ INSERT INTO t2 SELECT NULL, z, y FROM t2;
+ SELECT * FROM t2;
+ }
+} {1 1 2 2 2 3 3 2 1 4 3 2}
+
+# This tests checks to see if a floating point number can be used
+# to reference an integer primary key.
+#
+do_test intpkey-11.1 {
+ execsql {
+ SELECT b FROM t1 WHERE a=2.0+3.0;
+ }
+} {hello}
+do_test intpkey-11.1 {
+ execsql {
+ SELECT b FROM t1 WHERE a=2.0+3.5;
+ }
+} {}
+
+integrity_check intpkey-12.1
+
+# Try to use a string that looks like a floating point number as
+# an integer primary key. This should actually work when the floating
+# point value can be rounded to an integer without loss of data.
+#
+do_test intpkey-13.1 {
+ execsql {
+ SELECT * FROM t1 WHERE a=1;
+ }
+} {}
+do_test intpkey-13.2 {
+ execsql {
+ INSERT INTO t1 VALUES('1.0',2,3);
+ SELECT * FROM t1 WHERE a=1;
+ }
+} {1 2 3}
+do_test intpkey-13.3 {
+ catchsql {
+ INSERT INTO t1 VALUES('1.5',3,4);
+ }
+} {1 {datatype mismatch}}
+ifcapable {bloblit} {
+ do_test intpkey-13.4 {
+ catchsql {
+ INSERT INTO t1 VALUES(x'123456',3,4);
+ }
+ } {1 {datatype mismatch}}
+}
+do_test intpkey-13.5 {
+ catchsql {
+ INSERT INTO t1 VALUES('+1234567890',3,4);
+ }
+} {0 {}}
+
+# Compare an INTEGER PRIMARY KEY against a TEXT expression. The INTEGER
+# affinity should be applied to the text value before the comparison
+# takes place.
+#
+do_test intpkey-14.1 {
+ execsql {
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b INTEGER, c TEXT);
+ INSERT INTO t3 VALUES(1, 1, 'one');
+ INSERT INTO t3 VALUES(2, 2, '2');
+ INSERT INTO t3 VALUES(3, 3, 3);
+ }
+} {}
+do_test intpkey-14.2 {
+ execsql {
+ SELECT * FROM t3 WHERE a>2;
+ }
+} {3 3 3}
+do_test intpkey-14.3 {
+ execsql {
+ SELECT * FROM t3 WHERE a>'2';
+ }
+} {3 3 3}
+do_test intpkey-14.4 {
+ execsql {
+ SELECT * FROM t3 WHERE a<'2';
+ }
+} {1 1 one}
+do_test intpkey-14.5 {
+ execsql {
+ SELECT * FROM t3 WHERE a<c;
+ }
+} {1 1 one}
+do_test intpkey-14.6 {
+ execsql {
+ SELECT * FROM t3 WHERE a=c;
+ }
+} {2 2 2 3 3 3}
+
+# Check for proper handling of primary keys greater than 2^31.
+# Ticket #1188
+#
+do_test intpkey-15.1 {
+ execsql {
+ INSERT INTO t1 VALUES(2147483647, 'big-1', 123);
+ SELECT * FROM t1 WHERE a>2147483648;
+ }
+} {}
+do_test intpkey-15.2 {
+ execsql {
+ INSERT INTO t1 VALUES(NULL, 'big-2', 234);
+ SELECT b FROM t1 WHERE a>=2147483648;
+ }
+} {big-2}
+do_test intpkey-15.3 {
+ execsql {
+ SELECT b FROM t1 WHERE a>2147483648;
+ }
+} {}
+do_test intpkey-15.4 {
+ execsql {
+ SELECT b FROM t1 WHERE a>=2147483647;
+ }
+} {big-1 big-2}
+do_test intpkey-15.5 {
+ execsql {
+ SELECT b FROM t1 WHERE a<2147483648;
+ }
+} {y zero 2 hello second hello b-20 b-22 new 3 big-1}
+do_test intpkey-15.6 {
+ execsql {
+ SELECT b FROM t1 WHERE a<12345678901;
+ }
+} {y zero 2 hello second hello b-20 b-22 new 3 big-1 big-2}
+do_test intpkey-15.7 {
+ execsql {
+ SELECT b FROM t1 WHERE a>12345678901;
+ }
+} {}
+
+
+finish_test
diff --git a/test/io.test b/test/io.test
new file mode 100644
index 0000000..58caeee
--- /dev/null
+++ b/test/io.test
@@ -0,0 +1,565 @@
+# 2007 August 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# The focus of this file is testing some specific characteristics of the
+# IO traffic generated by SQLite (making sure SQLite is not writing out
+# more database pages than it has to, stuff like that).
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+db close
+sqlite3_simulate_device
+sqlite3 db test.db -vfs devsym
+
+# Test summary:
+#
+# io-1.* - Test that quick-balance does not journal pages unnecessarily.
+#
+# io-2.* - Test the "atomic-write optimization".
+#
+# io-3.* - Test the IO traffic enhancements triggered when the
+# IOCAP_SEQUENTIAL device capability flag is set (no
+# fsync() calls on the journal file).
+#
+# io-4.* - Test the IO traffic enhancements triggered when the
+# IOCAP_SAFE_APPEND device capability flag is set (fewer
+# fsync() calls on the journal file, no need to set nRec
+# field in the single journal header).
+#
+# io-5.* - Test that the default page size is selected and used
+# correctly.
+#
+
+set ::nWrite 0
+proc nWrite {db} {
+ set bt [btree_from_db $db]
+ db_enter $db
+ array set stats [btree_pager_stats $bt]
+ db_leave $db
+ set res [expr $stats(write) - $::nWrite]
+ set ::nWrite $stats(write)
+ set res
+}
+
+set ::nSync 0
+proc nSync {} {
+ set res [expr {$::sqlite_sync_count - $::nSync}]
+ set ::nSync $::sqlite_sync_count
+ set res
+}
+
+do_test io-1.1 {
+ execsql {
+ PRAGMA auto_vacuum = OFF;
+ PRAGMA page_size = 1024;
+ CREATE TABLE abc(a,b);
+ }
+ nWrite db
+} {2}
+
+# Insert into the table 4 records of aproximately 240 bytes each.
+# This should completely fill the root-page of the table. Each
+# INSERT causes 2 db pages to be written - the root-page of "abc"
+# and page 1 (db change-counter page).
+do_test io-1.2 {
+ set ret [list]
+ execsql { INSERT INTO abc VALUES(1,randstr(230,230)); }
+ lappend ret [nWrite db]
+ execsql { INSERT INTO abc VALUES(2,randstr(230,230)); }
+ lappend ret [nWrite db]
+ execsql { INSERT INTO abc VALUES(3,randstr(230,230)); }
+ lappend ret [nWrite db]
+ execsql { INSERT INTO abc VALUES(4,randstr(230,230)); }
+ lappend ret [nWrite db]
+} {2 2 2 2}
+
+# Insert another 240 byte record. This causes two leaf pages
+# to be added to the root page of abc. 4 pages in total
+# are written to the db file - the two leaf pages, the root
+# of abc and the change-counter page.
+do_test io-1.3 {
+ execsql { INSERT INTO abc VALUES(5,randstr(230,230)); }
+ nWrite db
+} {4}
+
+# Insert another 3 240 byte records. After this, the tree consists of
+# the root-node, which is close to empty, and two leaf pages, both of
+# which are full.
+do_test io-1.4 {
+ set ret [list]
+ execsql { INSERT INTO abc VALUES(6,randstr(230,230)); }
+ lappend ret [nWrite db]
+ execsql { INSERT INTO abc VALUES(7,randstr(230,230)); }
+ lappend ret [nWrite db]
+ execsql { INSERT INTO abc VALUES(8,randstr(230,230)); }
+ lappend ret [nWrite db]
+} {2 2 2}
+
+# This insert should use the quick-balance trick to add a third leaf
+# to the b-tree used to store table abc. It should only be necessary to
+# write to 3 pages to do this: the change-counter, the root-page and
+# the new leaf page.
+do_test io-1.5 {
+ execsql { INSERT INTO abc VALUES(9,randstr(230,230)); }
+ nWrite db
+} {3}
+
+ifcapable atomicwrite {
+
+#----------------------------------------------------------------------
+# Test cases io-2.* test the atomic-write optimization.
+#
+do_test io-2.1 {
+ execsql { DELETE FROM abc; VACUUM; }
+} {}
+
+# Clear the write and sync counts.
+nWrite db ; nSync
+
+# The following INSERT updates 2 pages and requires 4 calls to fsync():
+#
+# 1) The directory in which the journal file is created,
+# 2) The journal file (to sync the page data),
+# 3) The journal file (to sync the journal file header),
+# 4) The database file.
+#
+do_test io-2.2 {
+ execsql { INSERT INTO abc VALUES(1, 2) }
+ list [nWrite db] [nSync]
+} {2 4}
+
+# Set the device-characteristic mask to include the SQLITE_IOCAP_ATOMIC,
+# then do another INSERT similar to the one in io-2.2. This should
+# only write 1 page and require a single fsync().
+#
+# The single fsync() is the database file. Only one page is reported as
+# written because page 1 - the change-counter page - is written using
+# an out-of-band method that bypasses the write counter.
+#
+sqlite3_simulate_device -char atomic
+do_test io-2.3 {
+ execsql { INSERT INTO abc VALUES(3, 4) }
+ list [nWrite db] [nSync]
+} {1 1}
+
+# Test that the journal file is not created and the change-counter is
+# updated when the atomic-write optimization is used.
+#
+do_test io-2.4.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO abc VALUES(5, 6);
+ }
+ sqlite3 db2 test.db -vfs devsym
+ execsql { SELECT * FROM abc } db2
+} {1 2 3 4}
+do_test io-2.4.2 {
+ file exists test.db-journal
+} {0}
+do_test io-2.4.3 {
+ execsql { COMMIT }
+ execsql { SELECT * FROM abc } db2
+} {1 2 3 4 5 6}
+db2 close
+
+# Test that the journal file is created and sync()d if the transaction
+# modifies more than one database page, even if the IOCAP_ATOMIC flag
+# is set.
+#
+do_test io-2.5.1 {
+ execsql { CREATE TABLE def(d, e) }
+ nWrite db ; nSync
+ execsql {
+ BEGIN;
+ INSERT INTO abc VALUES(7, 8);
+ }
+ file exists test.db-journal
+} {0}
+do_test io-2.5.2 {
+ execsql { INSERT INTO def VALUES('a', 'b'); }
+ file exists test.db-journal
+} {1}
+do_test io-2.5.3 {
+ execsql { COMMIT }
+ list [nWrite db] [nSync]
+} {3 4}
+
+# Test that the journal file is created and sync()d if the transaction
+# modifies a single database page and also appends a page to the file.
+# Internally, this case is handled differently to the one above. The
+# journal file is not actually created until the 'COMMIT' statement
+# is executed.
+#
+# Changed 2010-03-27: The size of the database is now stored in
+# bytes 28..31 and so when a page is added to the database, page 1
+# is immediately modified and the journal file immediately comes into
+# existance. To fix this test, the BEGIN is changed into a a
+# BEGIN IMMEDIATE and the INSERT is omitted.
+#
+do_test io-2.6.1 {
+ execsql {
+ BEGIN IMMEDIATE;
+ -- INSERT INTO abc VALUES(9, randstr(1000,1000));
+ }
+ file exists test.db-journal
+} {0}
+do_test io-2.6.2 {
+ # Create a file at "test.db-journal". This will prevent SQLite from
+ # opening the journal for exclusive access. As a result, the COMMIT
+ # should fail with SQLITE_CANTOPEN and the transaction rolled back.
+ #
+ file mkdir test.db-journal
+ catchsql {
+ INSERT INTO abc VALUES(9, randstr(1000,1000));
+ COMMIT
+ }
+} {1 {unable to open database file}}
+do_test io-2.6.3 {
+ forcedelete test.db-journal
+ catchsql { COMMIT }
+} {0 {}}
+do_test io-2.6.4 {
+ execsql { SELECT * FROM abc }
+} {1 2 3 4 5 6 7 8}
+
+# Test that if the database modification is part of multi-file commit,
+# the journal file is always created. In this case, the journal file
+# is created during execution of the COMMIT statement, so we have to
+# use the same technique to check that it is created as in the above
+# block.
+forcedelete test2.db test2.db-journal
+ifcapable attach {
+ do_test io-2.7.1 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ PRAGMA aux.page_size = 1024;
+ CREATE TABLE aux.abc2(a, b);
+ BEGIN;
+ INSERT INTO abc VALUES(9, 10);
+ }
+ file exists test.db-journal
+ } {0}
+ do_test io-2.7.2 {
+ execsql { INSERT INTO abc2 SELECT * FROM abc }
+ file exists test2.db-journal
+ } {0}
+ do_test io-2.7.3 {
+ execsql { SELECT * FROM abc UNION ALL SELECT * FROM abc2 }
+ } {1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10}
+ do_test io-2.7.4 {
+ file mkdir test2.db-journal
+ catchsql { COMMIT }
+ } {1 {unable to open database file}}
+ do_test io-2.7.5 {
+ forcedelete test2.db-journal
+ catchsql { COMMIT }
+ } {1 {cannot commit - no transaction is active}}
+ do_test io-2.7.6 {
+ execsql { SELECT * FROM abc UNION ALL SELECT * FROM abc2 }
+ } {1 2 3 4 5 6 7 8}
+}
+
+# Try an explicit ROLLBACK before the journal file is created.
+#
+do_test io-2.8.1 {
+ execsql {
+ BEGIN;
+ DELETE FROM abc;
+ }
+ file exists test.db-journal
+} {0}
+do_test io-2.8.2 {
+ execsql { SELECT * FROM abc }
+} {}
+do_test io-2.8.3 {
+ execsql {
+ ROLLBACK;
+ SELECT * FROM abc;
+ }
+} {1 2 3 4 5 6 7 8}
+
+# Test that the atomic write optimisation is not enabled if the sector
+# size is larger than the page-size.
+#
+do_test io-2.9.1 {
+ db close
+ sqlite3 db test.db
+ sqlite3_simulate_device -char atomic -sectorsize 2048
+ execsql {
+ BEGIN;
+ INSERT INTO abc VALUES(9, 10);
+ }
+ file exists test.db-journal
+} {1}
+do_test io-2.9.2 {
+ execsql { ROLLBACK; }
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db -vfs devsym
+ execsql {
+ PRAGMA auto_vacuum = OFF;
+ PRAGMA page_size = 2048;
+ CREATE TABLE abc(a, b);
+ }
+ execsql {
+ BEGIN;
+ INSERT INTO abc VALUES(9, 10);
+ }
+ file exists test.db-journal
+} {0}
+do_test io-2.9.3 {
+ execsql { COMMIT }
+} {}
+
+# Test a couple of the more specific IOCAP_ATOMIC flags
+# (i.e IOCAP_ATOMIC2K etc.).
+#
+do_test io-2.10.1 {
+ sqlite3_simulate_device -char atomic1k
+ execsql {
+ BEGIN;
+ INSERT INTO abc VALUES(11, 12);
+ }
+ file exists test.db-journal
+} {1}
+do_test io-2.10.2 {
+ execsql { ROLLBACK }
+ sqlite3_simulate_device -char atomic2k
+ execsql {
+ BEGIN;
+ INSERT INTO abc VALUES(11, 12);
+ }
+ file exists test.db-journal
+} {0}
+do_test io-2.10.3 {
+ execsql { ROLLBACK }
+} {}
+
+do_test io-2.11.0 {
+ execsql {
+ PRAGMA locking_mode = exclusive;
+ PRAGMA locking_mode;
+ }
+} {exclusive exclusive}
+do_test io-2.11.1 {
+ execsql {
+ INSERT INTO abc VALUES(11, 12);
+ }
+ file exists test.db-journal
+} {0}
+
+do_test io-2.11.2 {
+ execsql {
+ PRAGMA locking_mode = normal;
+ INSERT INTO abc VALUES(13, 14);
+ }
+ file exists test.db-journal
+} {0}
+
+} ;# /* ifcapable atomicwrite */
+
+#----------------------------------------------------------------------
+# Test cases io-3.* test the IOCAP_SEQUENTIAL optimization.
+#
+sqlite3_simulate_device -char sequential -sectorsize 0
+ifcapable pager_pragmas {
+ do_test io-3.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db -vfs devsym
+ db eval {
+ PRAGMA auto_vacuum=OFF;
+ }
+ # File size might be 1 due to the hack to work around ticket #3260.
+ # Search for #3260 in os_unix.c for additional information.
+ expr {[file size test.db]>1}
+ } {0}
+ do_test io-3.2 {
+ execsql { CREATE TABLE abc(a, b) }
+ nSync
+ execsql {
+ PRAGMA temp_store = memory;
+ PRAGMA cache_size = 10;
+ BEGIN;
+ INSERT INTO abc VALUES('hello', 'world');
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ }
+ # File has grown - showing there was a cache-spill - but there
+ # have been no calls to fsync(). The file is probably about 30KB.
+ # But some VFS implementations (symbian) buffer writes so the actual
+ # size may be a little less than that. So this test case just tests
+ # that the file is now greater than 20000 bytes in size.
+ list [expr [file size test.db]>20000] [nSync]
+ } {1 0}
+ do_test io-3.3 {
+ # The COMMIT requires a single fsync() - to the database file.
+ execsql { COMMIT }
+ list [file size test.db] [nSync]
+ } {39936 1}
+}
+
+#----------------------------------------------------------------------
+# Test cases io-4.* test the IOCAP_SAFE_APPEND optimization.
+#
+sqlite3_simulate_device -char safe_append
+
+# With the SAFE_APPEND flag set, simple transactions require 3, rather
+# than 4, calls to fsync(). The fsync() calls are on:
+#
+# 1) The directory in which the journal file is created, (unix only)
+# 2) The journal file (to sync the page data),
+# 3) The database file.
+#
+# Normally, when the SAFE_APPEND flag is not set, there is another fsync()
+# on the journal file between steps (2) and (3) above.
+#
+set expected_sync_count 2
+if {$::tcl_platform(platform)=="unix"} {
+ ifcapable dirsync {
+ incr expected_sync_count
+ }
+}
+
+do_test io-4.1 {
+ execsql { DELETE FROM abc }
+ nSync
+ execsql { INSERT INTO abc VALUES('a', 'b') }
+ nSync
+} $expected_sync_count
+
+# With SAFE_APPEND set, the nRec field of the journal file header should
+# be set to 0xFFFFFFFF before the first journal sync. The nRec field
+# occupies bytes 8-11 of the journal file.
+#
+do_test io-4.2.1 {
+ execsql { BEGIN }
+ execsql { INSERT INTO abc VALUES('c', 'd') }
+ file exists test.db-journal
+} {1}
+if {$::tcl_platform(platform)=="unix"} {
+ do_test io-4.2.2 {
+ hexio_read test.db-journal 8 4
+ } {FFFFFFFF}
+}
+do_test io-4.2.3 {
+ execsql { COMMIT }
+ nSync
+} $expected_sync_count
+sqlite3_simulate_device -char safe_append
+
+# With SAFE_APPEND set, there should only ever be one journal-header
+# written to the database, even though the sync-mode is "full".
+#
+do_test io-4.3.1 {
+ execsql {
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ }
+ expr {[file size test.db]/1024}
+} {43}
+ifcapable pager_pragmas {
+ do_test io-4.3.2 {
+ execsql {
+ PRAGMA synchronous = full;
+ PRAGMA cache_size = 10;
+ PRAGMA synchronous;
+ }
+ } {2}
+}
+do_test io-4.3.3 {
+ execsql {
+ BEGIN;
+ UPDATE abc SET a = 'x';
+ }
+ file exists test.db-journal
+} {1}
+if {$tcl_platform(platform) != "symbian"} {
+ # This test is not run on symbian because the file-buffer makes it
+ # difficult to predict the exact size of the file as reported by
+ # [file size].
+ do_test io-4.3.4 {
+ # The UPDATE statement in the statement above modifies 41 pages
+ # (all pages in the database except page 1 and the root page of
+ # abc). Because the cache_size is set to 10, this must have required
+ # at least 4 cache-spills. If there were no journal headers written
+ # to the journal file after the cache-spill, then the size of the
+ # journal file is give by:
+ #
+ # <jrnl file size> = <jrnl header size> + nPage * (<page-size> + 8)
+ #
+ # If the journal file contains additional headers, this formula
+ # will not predict the size of the journal file.
+ #
+ file size test.db-journal
+ } [expr 512 + (1024+8)*41]
+}
+
+#----------------------------------------------------------------------
+# Test cases io-5.* test that the default page size is selected and
+# used correctly.
+#
+set tn 0
+foreach {char sectorsize pgsize} {
+ {} 512 1024
+ {} 1024 1024
+ {} 2048 2048
+ {} 8192 8192
+ {} 16384 8192
+ {atomic} 512 8192
+ {atomic512} 512 1024
+ {atomic2K} 512 2048
+ {atomic2K} 4096 4096
+ {atomic2K atomic} 512 8192
+ {atomic64K} 512 1024
+} {
+ incr tn
+ if {$pgsize>$::SQLITE_MAX_PAGE_SIZE} continue
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3_simulate_device -char $char -sectorsize $sectorsize
+ sqlite3 db test.db -vfs devsym
+ db eval {
+ PRAGMA auto_vacuum=OFF;
+ }
+ ifcapable !atomicwrite {
+ if {[regexp {^atomic} $char]} continue
+ }
+ do_test io-5.$tn {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ }
+ expr {[file size test.db]/2}
+ } $pgsize
+}
+
+sqlite3_simulate_device -char {} -sectorsize 0
+finish_test
diff --git a/test/ioerr.test b/test/ioerr.test
new file mode 100644
index 0000000..b237439
--- /dev/null
+++ b/test/ioerr.test
@@ -0,0 +1,465 @@
+# 2001 October 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing for correct handling of I/O errors
+# such as writes failing because the disk is full.
+#
+# The tests in this file use special facilities that are only
+# available in the SQLite test fixture.
+#
+# $Id: ioerr.test,v 1.43 2009/04/06 17:50:03 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_DEFAULT_AUTOVACUUM is set to true, then a simulated IO error
+# on the 8th IO operation in the SQL script below doesn't report an error.
+#
+# This is because the 8th IO call attempts to read page 2 of the database
+# file when the file on disk is only 1 page. The pager layer detects that
+# this has happened and suppresses the error returned by the OS layer.
+#
+do_ioerr_test ioerr-1 -erc 1 -ckrefcount 1 -sqlprep {
+ SELECT * FROM sqlite_master;
+} -sqlbody {
+ CREATE TABLE t1(a,b,c);
+ SELECT * FROM sqlite_master;
+ BEGIN TRANSACTION;
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(4,5,6);
+ ROLLBACK;
+ SELECT * FROM t1;
+ BEGIN TRANSACTION;
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(4,5,6);
+ COMMIT;
+ SELECT * FROM t1;
+ DELETE FROM t1 WHERE a<100;
+} -exclude [expr [string match [execsql {pragma auto_vacuum}] 1] ? 4 : 0]
+
+# Test for IO errors during a VACUUM.
+#
+# The first IO call is excluded from the test. This call attempts to read
+# the file-header of the temporary database used by VACUUM. Since the
+# database doesn't exist at that point, the IO error is not detected.
+#
+# Additionally, if auto-vacuum is enabled, the 12th IO error is not
+# detected. Same reason as the 8th in the test case above.
+#
+ifcapable vacuum {
+ do_ioerr_test ioerr-2 -cksum true -ckrefcount true -sqlprep {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, randstr(50,50), randstr(50,50));
+ INSERT INTO t1 SELECT a+2, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+4, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+8, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+16, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+32, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+64, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+128, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 VALUES(1, randstr(600,600), randstr(600,600));
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ CREATE TABLE t3 AS SELECT * FROM t1;
+ COMMIT;
+ DROP TABLE t2;
+ } -sqlbody {
+ VACUUM;
+ } -exclude [list \
+ 1 [expr [string match [execsql {pragma auto_vacuum}] 1]?9:-1]]
+}
+
+do_ioerr_test ioerr-3 -ckrefcount true -tclprep {
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE abc(a);
+ INSERT INTO abc VALUES(randstr(1500,1500)); -- Page 4 is overflow
+ }
+ for {set i 0} {$i<150} {incr i} {
+ execsql {
+ INSERT INTO abc VALUES(randstr(100,100));
+ }
+ }
+ execsql COMMIT
+} -sqlbody {
+ CREATE TABLE abc2(a);
+ BEGIN;
+ DELETE FROM abc WHERE length(a)>100;
+ UPDATE abc SET a = randstr(90,90);
+ COMMIT;
+ CREATE TABLE abc3(a);
+}
+
+# Test IO errors that can occur retrieving a record header that flows over
+# onto an overflow page.
+do_ioerr_test ioerr-4 -ckrefcount true -tclprep {
+ set sql "CREATE TABLE abc(a1"
+ for {set i 2} {$i<1300} {incr i} {
+ append sql ", a$i"
+ }
+ append sql ");"
+ execsql $sql
+ execsql {INSERT INTO abc (a1) VALUES(NULL)}
+} -sqlbody {
+ SELECT * FROM abc;
+}
+
+
+# Test IO errors that may occur during a multi-file commit.
+#
+# Tests 8 and 17 are excluded when auto-vacuum is enabled for the same
+# reason as in test cases ioerr-1.XXX
+ifcapable attach {
+ set ex ""
+ if {[string match [execsql {pragma auto_vacuum}] 1]} {
+ set ex [list 4 17]
+ }
+ do_ioerr_test ioerr-5 -restoreprng 0 -ckrefcount true -sqlprep {
+ ATTACH 'test2.db' AS test2;
+ } -sqlbody {
+ BEGIN;
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE test2.t2(a,b,c);
+ COMMIT;
+ } -exclude $ex
+}
+
+# Test IO errors when replaying two hot journals from a 2-file
+# transaction. This test only runs on UNIX.
+#
+# It cannot be run under the "exclusive" permutation. In that case, the
+# locks held by the connection in the local (this) process prevent a
+# second connection from attempting the multi-file transaction.
+#
+ifcapable crashtest&&attach {
+ if {![catch {sqlite3 -has-codec} r] && !$r && [permutation]!="exclusive"} {
+ do_ioerr_test ioerr-6 -ckrefcount true -tclprep {
+ execsql {
+ ATTACH 'test2.db' as aux;
+ CREATE TABLE tx(a, b);
+ CREATE TABLE aux.ty(a, b);
+ }
+ set rc [crashsql -delay 2 -file test2.db-journal {
+ ATTACH 'test2.db' as aux;
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE aux.t2(a, b, c);
+ CREATE TABLE t1(a, b, c);
+ COMMIT;
+ }]
+ if {$rc!="1 {child process exited abnormally}"} {
+ error "Wrong error message: $rc"
+ }
+ } -sqlbody {
+ SELECT * FROM sqlite_master;
+ SELECT * FROM aux.sqlite_master;
+ }
+ }
+}
+
+# Test handling of IO errors that occur while rolling back hot journal
+# files.
+#
+# These tests can't be run on windows because the windows version of
+# SQLite holds a mandatory exclusive lock on journal files it has open.
+#
+if {$tcl_platform(platform)!="windows"} {
+ do_ioerr_test ioerr-7 -tclprep {
+ db close
+ sqlite3 db2 test2.db
+ db2 eval {
+ PRAGMA synchronous = 0;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ forcecopy test2.db test.db
+ forcecopy test2.db-journal test.db-journal
+ db2 close
+ } -tclbody {
+ sqlite3 db test.db
+ db eval {
+ SELECT * FROM t1;
+ }
+ } -exclude 1
+}
+
+# For test coverage: Cause an I/O failure while trying to read a
+# short field (one that fits into a Mem buffer without mallocing
+# for space).
+#
+do_ioerr_test ioerr-8 -ckrefcount true -tclprep {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);
+ }
+ db close
+ sqlite3 db test.db
+} -sqlbody {
+ SELECT c FROM t1;
+}
+
+# For test coverage: Cause an IO error whilst reading the master-journal
+# name from a journal file.
+if {$tcl_platform(platform)=="unix"} {
+ do_ioerr_test ioerr-9 -ckrefcount true -tclprep {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);
+ BEGIN;
+ INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);
+ }
+ forcecopy test.db-journal test2.db-journal
+ execsql {
+ COMMIT;
+ }
+ forcecopy test2.db-journal test.db-journal
+ set f [open test.db-journal a]
+ fconfigure $f -encoding binary
+ puts -nonewline $f "hello"
+ puts -nonewline $f "\x00\x00\x00\x05\x01\x02\x03\x04"
+ puts -nonewline $f "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7"
+ close $f
+ } -sqlbody {
+ SELECT a FROM t1;
+ }
+}
+
+# For test coverage: Cause an IO error during statement playback (i.e.
+# a constraint).
+do_ioerr_test ioerr-10 -ckrefcount true -tclprep {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ }
+ for {set i 0} {$i < 500} {incr i} {
+ execsql {INSERT INTO t1 VALUES(:i, 'hello world');}
+ }
+ execsql {
+ COMMIT;
+ }
+} -tclbody {
+
+ catch {execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('abc', 123);
+ INSERT INTO t1 VALUES('def', 123);
+ INSERT INTO t1 VALUES('ghi', 123);
+ INSERT INTO t1 SELECT (a+500)%900, 'good string' FROM t1;
+ }} msg
+
+ if {$msg != "column a is not unique"} {
+ error $msg
+ }
+}
+
+# Assertion fault bug reported by alex dimitrov.
+#
+do_ioerr_test ioerr-11 -ckrefcount true -erc 1 -sqlprep {
+ CREATE TABLE A(Id INTEGER, Name TEXT);
+ INSERT INTO A(Id, Name) VALUES(1, 'Name');
+} -sqlbody {
+ UPDATE A SET Id = 2, Name = 'Name2' WHERE Id = 1;
+}
+
+# Test that an io error encountered in a sync() caused by a call to
+# sqlite3_release_memory() is handled Ok. Only try this if
+# memory-management is enabled.
+#
+ifcapable memorymanage {
+ do_ioerr_test memmanage-ioerr1 -ckrefcount true -sqlprep {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(randstr(50,50), randstr(100,100), randstr(10,10));
+ INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1;
+ } -tclbody {
+ sqlite3_release_memory
+ } -sqlbody {
+ COMMIT;
+ }
+}
+
+ifcapable pager_pragmas&&autovacuum {
+ do_ioerr_test ioerr-12 -ckrefcount true -erc 1 -sqlprep {
+ PRAGMA page_size = 512;
+ PRAGMA auto_vacuum = incremental;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES( randomblob(1 * (512-4)) );
+ INSERT INTO t1 VALUES( randomblob(110 * (512-4)) );
+ INSERT INTO t1 VALUES( randomblob(2 * (512-4)) );
+ INSERT INTO t1 VALUES( randomblob(110 * (512-4)) );
+ INSERT INTO t1 VALUES( randomblob(3 * (512-4)) );
+ DELETE FROM t1 WHERE rowid = 3;
+ PRAGMA incremental_vacuum = 2;
+ DELETE FROM t1 WHERE rowid = 1;
+ } -sqlbody {
+ PRAGMA incremental_vacuum = 1;
+ }
+}
+
+# Usually, after a new page is allocated from the end of the file, it does
+# not need to be written to the journal. The exception is when the new page
+# shares its sector with an existing page that does need to be journalled.
+# This test case provokes this condition to test for the sake of coverage
+# that an IO error while journalling the coresident page is handled correctly.
+#
+sqlite3_simulate_device -char {} -sectorsize 2048
+do_ioerr_test ioerr-12 -ckrefcount true -erc 1 -tclprep {
+ db close
+ sqlite3 db test.db -vfs devsym
+
+ # Create a test database. Page 2 is the root page of table t1. The only
+ # row inserted into t1 has an overflow page - page 3. Page 3 will be
+ # coresident on the 2048 byte sector with the next page to be allocated.
+ #
+ db eval { PRAGMA page_size = 1024 }
+ db eval { CREATE TABLE t1(x) }
+ db eval { INSERT INTO t1 VALUES(randomblob(1100)); }
+} -tclbody {
+ db eval { INSERT INTO t1 VALUES(randomblob(2000)); }
+}
+sqlite3_simulate_device -char {} -sectorsize 0
+catch {db close}
+
+do_ioerr_test ioerr-13 -ckrefcount true -erc 1 -sqlprep {
+ PRAGMA auto_vacuum = incremental;
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES(randomblob(1500));
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t1 VALUES(randomblob(20));
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1; /* 64 entries in t1 */
+ INSERT INTO t1 SELECT x FROM t1 LIMIT 14; /* 78 entries in t1 */
+ DELETE FROM t2 WHERE rowid = 3;
+} -sqlbody {
+ -- This statement uses the balance_quick() optimization. The new page
+ -- is appended to the database file. But the overflow page used by
+ -- the new record will be positioned near the start of the database
+ -- file, in the gap left by the "DELETE FROM t2 WHERE rowid=3" statement
+ -- above.
+ --
+ -- The point of this is that the statement wil need to update two pointer
+ -- map pages. Which introduces another opportunity for an IO error.
+ --
+ INSERT INTO t1 VALUES(randomblob(2000));
+}
+
+do_ioerr_test ioerr-14 -ckrefcount true -erc 1 -sqlprep {
+ PRAGMA auto_vacuum = incremental;
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES(randomblob(1500));
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+ INSERT INTO t2 SELECT randomblob(1500) FROM t2;
+
+ -- This statement inserts a row into t1 with an overflow page at the
+ -- end of the file. A long way from its parent (the root of t1).
+ INSERT INTO t1 VALUES(randomblob(1500));
+ DELETE FROM t2 WHERE rowid<10;
+} -sqlbody {
+ -- This transaction will cause the root-page of table t1 to divide
+ -- (by calling balance_deeper()). When it does, the "parent" page of the
+ -- overflow page inserted in the -sqlprep block above will change and
+ -- the corresponding pointer map page be updated. This test case attempts
+ -- to cause an IO error during the pointer map page update.
+ --
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ COMMIT;
+}
+
+do_ioerr_test ioerr-15 -tclprep {
+ db eval {
+ BEGIN;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a);
+ CREATE TABLE t2(a);
+ }
+ for {set ii 1} {$ii < 100} {incr ii} {
+ set v [string range [string repeat [format %.3d $ii] 200] 0 220]
+ db eval {INSERT INTO t1 VALUES($v)}
+ }
+ db eval {
+ DELETE FROM t1 WHERE oid > 85;
+ COMMIT;
+ }
+} -sqlbody {
+ BEGIN;
+ INSERT INTO t2 VALUES(randstr(22000,22000));
+ DELETE FROM t1 WHERE oid = 83;
+ COMMIT;
+}
+
+# This test verifies that IO errors that occur within the obscure branch
+# of code executed by tkt3762.test are correctly reported.
+#
+ifcapable vacuum&&autovacuum&&pragma {
+ do_ioerr_test ioerr-16 -erc 1 -ckrefcount 1 -sqlprep {
+ PRAGMA auto_vacuum=INCREMENTAL;
+ PRAGMA page_size=1024;
+ BEGIN;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(zeroblob(900));
+ INSERT INTO t1 VALUES(zeroblob(900));
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ DELETE FROM t1 WHERE rowid>202;
+ COMMIT;
+ VACUUM;
+ PRAGMA cache_size = 10;
+ BEGIN;
+ DELETE FROM t1 WHERE rowid IN (10,11,12) ;
+ } -sqlbody {
+ PRAGMA incremental_vacuum(10);
+ COMMIT;
+ }
+}
+
+finish_test
diff --git a/test/ioerr2.test b/test/ioerr2.test
new file mode 100644
index 0000000..325c0ba
--- /dev/null
+++ b/test/ioerr2.test
@@ -0,0 +1,170 @@
+# 2007 April 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing for correct handling of I/O errors
+# such as writes failing because the disk is full.
+#
+# The tests in this file use special facilities that are only
+# available in the SQLite test fixture.
+#
+# $Id: ioerr2.test,v 1.12 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !integrityck {
+ finish_test
+ return
+}
+
+do_test ioerr2-1.1 {
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA default_cache_size = 10;
+ CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
+ INSERT INTO t1 VALUES(randstr(400,400),randstr(400,400));
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 4
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 8
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 16
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 32
+ }
+} {}
+
+set ::cksum [execsql {SELECT md5sum(a, b) FROM t1}]
+proc check_db {testname} {
+
+ # Make sure no I/O errors are simulated in this proc.
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_persist 0
+ set ::sqlite_io_error_pending 0
+
+ # Run an integrity-check. If "disk I/O error" is returned, the
+ # pager must be in error state. In this case open a new database
+ # connection. Otherwise, try a ROLLBACK, in case a transaction
+ # is still active.
+ set rc [catch {execsql {PRAGMA integrity_check}} msg]
+ if {$rc && ($msg eq "disk I/O error" || $msg eq "database is locked")} {
+ db close
+ sqlite3 db test.db
+ set refcnt 0
+ } else {
+ if {$rc || $msg ne "ok"} {
+ error $msg
+ }
+ catch {execsql ROLLBACK}
+ }
+
+ # Check that the database checksum is still $::cksum, and that
+ # the integrity-check passes.
+ set ck [execsql {SELECT md5sum(a, b) FROM t1}]
+ do_test ${testname}.cksum [list set ck $ck] $::cksum
+ integrity_check ${testname}.integrity
+ do_test ${testname}.refcnt {
+ lindex [sqlite3_pager_refcounts db] 0
+ } 0
+}
+
+check_db ioerr2-2
+
+set sql {
+ PRAGMA cache_size = 10;
+ PRAGMA default_cache_size = 10;
+ BEGIN;
+ DELETE FROM t1 WHERE (oid%7)==0;
+ INSERT INTO t1 SELECT randstr(400,400), randstr(400,400)
+ WHERE (random()%7)==0;
+ UPDATE t1 SET a = randstr(400,400), b = randstr(400,400)
+ WHERE (random()%7)==0;
+ ROLLBACK;
+}
+
+foreach bPersist [list 0 1] {
+ set ::go 1
+ for {set ::N 1} {$::go} {incr ::N} {
+ db close
+ sqlite3 db test.db
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_persist $bPersist
+ set ::sqlite_io_error_pending $::N
+
+ foreach {::go res} [catchsql $sql] {}
+ check_db ioerr2-3.$bPersist.$::N
+ }
+}
+foreach bPersist [list 0 1] {
+ set ::go 1
+ for {set ::N 1} {$::go} {incr ::N} {
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_persist $bPersist
+ set ::sqlite_io_error_pending $::N
+
+ foreach {::go res} [catchsql $sql] {}
+ check_db ioerr2-4.[expr {$bPersist+2}].$::N
+ }
+}
+
+do_test ioerr2-5 {
+ execsql {
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ PRAGMA temp_store = memory;
+ }
+ set ::sqlite_io_error_persist 0
+ set ::go 1
+ set rc [catch {
+ for {set ::N 2} {$::N<200} {incr ::N} {
+ db eval {SELECT * FROM t1 WHERE rowid IN (1, 5, 10, 15, 20)} {
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_pending $::N
+ set sql {UPDATE t2 SET b = randstr(400,400)}
+ foreach {::go res} [catchsql $sql] {}
+ }
+ }
+ } msg]
+ list $rc $msg
+} {1 {callback requested query abort}}
+
+if {$::tcl_platform(platform) == "unix"} {
+ # Cause the call to xAccess used by [pragma temp_store_directory] to
+ # determine if the specified directory is writable to fail. This causes
+ # SQLite to report "not a writable directory", which is probably the
+ # right answer.
+ #
+ do_test ioerr2-6 {
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_pending 1
+ catchsql {PRAGMA temp_store_directory = '/tmp/'}
+ } {1 {not a writable directory}}
+}
+
+do_ioerr_test ioerr2-7 -persist 0 -sqlprep {
+ PRAGMA cache_size = 10;
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE ab(a, b);
+ CREATE TABLE de(d, e);
+ INSERT INTO ab VALUES(1, randstr(200,200));
+ INSERT INTO ab SELECT a+1, randstr(200,200) FROM ab;
+ INSERT INTO ab SELECT a+2, randstr(200,200) FROM ab;
+ INSERT INTO ab SELECT a+4, randstr(200,200) FROM ab;
+ INSERT INTO ab SELECT a+8, randstr(200,200) FROM ab;
+ INSERT INTO ab SELECT a+16, randstr(200,200) FROM ab;
+ INSERT INTO ab SELECT a+32, randstr(200,200) FROM ab;
+ INSERT INTO ab SELECT a+64, randstr(200,200) FROM ab;
+ INSERT INTO de SELECT * FROM ab;
+} -sqlbody {
+ BEGIN;
+ UPDATE ab SET b = randstr(200,200);
+ UPDATE de SET e = randstr(200,200) WHERE d = (SELECT max(d) FROM de);
+ DELETE FROM ab;
+ COMMIT;
+}
+
+finish_test
diff --git a/test/ioerr3.test b/test/ioerr3.test
new file mode 100644
index 0000000..4598cbf
--- /dev/null
+++ b/test/ioerr3.test
@@ -0,0 +1,42 @@
+# 2007 December 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing for correct handling of I/O errors
+# in conjunction with very small soft-heap-limit values.
+#
+# $Id: ioerr3.test,v 1.2 2008/01/19 23:50:26 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_ioerr_test ioerr3-1 -sqlprep {
+ CREATE TABLE t1(id INTEGER, name TEXT);
+} -tclbody {
+ sqlite3_soft_heap_limit 8192
+ db cache size 0
+ execsql BEGIN
+ for {set ii 0} {$ii < 100} {incr ii} {
+ execsql {
+ INSERT INTO t1(id, name) VALUES (1,
+'A1234567890B1234567890C1234567890D1234567890E1234567890F1234567890G1234567890H1234567890I1234567890J1234567890K1234567890L1234567890M1234567890N1234567890O1234567890P1234567890Q1234567890R1234567890'
+ );
+ }
+ }
+ execsql COMMIT
+}
+
+do_ioerr_test ioerr3-2 -sqlbody {
+ CREATE TEMP TABLE t1(x,y);
+}
+
+sqlite3_soft_heap_limit 0
+
+finish_test
diff --git a/test/ioerr4.test b/test/ioerr4.test
new file mode 100644
index 0000000..defa326
--- /dev/null
+++ b/test/ioerr4.test
@@ -0,0 +1,100 @@
+# 2007 December 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing for correct handling of I/O errors
+# during incremental vacuum with a shared cache.
+#
+# $Id: ioerr4.test,v 1.2 2008/05/08 01:11:42 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# This test requires both shared cache and incremental vacuum.
+#
+ifcapable {!shared_cache || !autovacuum} {
+ finish_test
+ return
+}
+
+# Enable shared cache mode and incremental vacuum.
+#
+do_test ioerr4-1.1 {
+ db close
+ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+} {0}
+do_test ioerr4-1.2 {
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ db eval {
+ PRAGMA auto_vacuum=INCREMENTAL;
+ CREATE TABLE a(i INTEGER, b BLOB);
+ }
+ db2 eval {
+ SELECT name FROM sqlite_master
+ }
+} {a}
+do_test ioerr4-1.3 {
+ db eval {
+ PRAGMA auto_vacuum;
+ }
+} {2}
+
+# Insert and delete many records in order to put lots of pages
+# on the freelist.
+#
+do_test ioerr4-1.4 {
+ db eval {
+ INSERT INTO a VALUES(1, zeroblob(2000));
+ INSERT INTO a VALUES(2, zeroblob(2000));
+ INSERT INTO a SELECT i+2, zeroblob(2000) FROM a;
+ INSERT INTO a SELECT i+4, zeroblob(2000) FROM a;
+ INSERT INTO a SELECT i+8, zeroblob(2000) FROM a;
+ INSERT INTO a SELECT i+16, zeroblob(2000) FROM a;
+ SELECT count(*) FROM a;
+ }
+} {32}
+do_test ioerr4-1.5 {
+ db eval {
+ PRAGMA freelist_count
+ }
+} {0}
+do_test ioerr4-1.6 {
+ db eval {
+ DELETE FROM a;
+ PRAGMA freelist_count;
+ }
+} {64}
+
+# Set up for an I/O error on incremental vacuum
+# with two connections on shared cache.
+#
+db close
+db2 close
+forcecopy test.db test.db-bu
+do_ioerr_test ioerr4-2 -tclprep {
+ catch {db2 close}
+ db close
+ forcedelete test.db test.db-journal
+ forcecopy test.db-bu test.db
+ sqlite3_enable_shared_cache 1
+ set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
+ db eval {PRAGMA auto_vacuum=INCREMENTAL}
+ sqlite3 db2 test.db
+} -tclbody {
+ db eval {PRAGMA incremental_vacuum(5)}
+}
+
+db2 close
+forcedelete test.db-bu
+sqlite3_enable_shared_cache $::enable_shared_cache
+
+finish_test
diff --git a/test/ioerr5.test b/test/ioerr5.test
new file mode 100644
index 0000000..a430f53
--- /dev/null
+++ b/test/ioerr5.test
@@ -0,0 +1,216 @@
+# 2008 May 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file tests that if sqlite3_release_memory() is called to reclaim
+# memory from a pager that is in the error-state, SQLite does not
+# incorrectly write dirty pages out to the database (not safe to do
+# once the pager is in error state).
+#
+# $Id: ioerr5.test,v 1.5 2008/08/28 18:35:34 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !memorymanage||!shared_cache {
+ finish_test
+ return
+}
+
+db close
+
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+set ::soft_limit [sqlite3_soft_heap_limit 1048576]
+
+# This procedure prepares, steps and finalizes an SQL statement via the
+# UTF-16 APIs. The text representation of an SQLite error code is returned
+# ("SQLITE_OK", "SQLITE_IOERR" etc.). The actual results returned by the
+# SQL statement, if it is a SELECT, are not available.
+#
+# This can be useful for testing because it forces SQLite to make an extra
+# call to sqlite3_malloc() when translating from the supplied UTF-16 to
+# the UTF-8 encoding used internally.
+#
+proc dosql16 {zSql {db db}} {
+ set sql [encoding convertto unicode $zSql]
+ append sql "\00\00"
+ set stmt [sqlite3_prepare16 $db $sql -1 {}]
+ sqlite3_step $stmt
+ set rc [sqlite3_finalize $stmt]
+}
+
+proc compilesql16 {zSql {db db}} {
+ set sql [encoding convertto unicode $zSql]
+ append sql "\00\00"
+ set stmt [sqlite3_prepare16 $db $sql -1 {}]
+ set rc [sqlite3_finalize $stmt]
+}
+
+# Open two database connections (handle db and db2) to database "test.db".
+#
+proc opendatabases {} {
+ catch {db close}
+ catch {db2 close}
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ db2 cache size 0
+ db cache size 0
+ execsql {
+ pragma page_size=512;
+ pragma auto_vacuum=2;
+ pragma cache_size=16;
+ }
+}
+
+# Open two database connections and create a single table in the db.
+#
+do_test ioerr5-1.0 {
+ opendatabases
+ execsql { CREATE TABLE A(Id INTEGER, Name TEXT) }
+} {}
+
+foreach locking_mode {normal exclusive} {
+ set nPage 2
+ for {set iFail 1} {$iFail<200} {incr iFail} {
+ sqlite3_soft_heap_limit 1048576
+ opendatabases
+ execsql { pragma locking_mode=exclusive }
+ set nRow [db one {SELECT count(*) FROM a}]
+
+ # Dirty (at least) one of the pages in the cache.
+ do_test ioerr5-1.$locking_mode-$iFail.1 {
+ execsql {
+ BEGIN EXCLUSIVE;
+ INSERT INTO a VALUES(1, 'ABCDEFGHIJKLMNOP');
+ }
+ } {}
+
+ # Open a read-only cursor on table "a". If the COMMIT below is
+ # interrupted by a persistent IO error, the pager will transition to
+ # PAGER_ERROR state. If there are no other read-only cursors open,
+ # from there the pager immediately discards all cached data and
+ # switches to PAGER_OPEN state. This read-only cursor stops that
+ # from happening, leaving the pager stuck in PAGER_ERROR state.
+ #
+ set channel [db incrblob -readonly a Name [db last_insert_rowid]]
+
+ # Now try to commit the transaction. Cause an IO error to occur
+ # within this operation, which moves the pager into the error state.
+ #
+ set ::sqlite_io_error_persist 1
+ set ::sqlite_io_error_pending $iFail
+ do_test ioerr5-1.$locking_mode-$iFail.2 {
+ set rc [catchsql {COMMIT}]
+ list
+ } {}
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_persist 0
+ set ::sqlite_io_error_pending 0
+
+ # Read the contents of the database file into a Tcl variable.
+ #
+ set fd [open test.db]
+ fconfigure $fd -translation binary -encoding binary
+ set zDatabase [read $fd]
+ close $fd
+
+ # Set a very low soft-limit and then try to compile an SQL statement
+ # from UTF-16 text. To do this, SQLite will need to reclaim memory
+ # from the pager that is in error state. Including that associated
+ # with the dirty page.
+ #
+ do_test ioerr5-1.$locking_mode-$iFail.3 {
+ sqlite3_soft_heap_limit 1024
+ compilesql16 "SELECT 10"
+ } {SQLITE_OK}
+
+ close $channel
+
+ # Ensure that nothing was written to the database while reclaiming
+ # memory from the pager in error state.
+ #
+ do_test ioerr5-1.$locking_mode-$iFail.4 {
+ set fd [open test.db]
+ fconfigure $fd -translation binary -encoding binary
+ set zDatabase2 [read $fd]
+ close $fd
+ expr {$zDatabase eq $zDatabase2}
+ } {1}
+
+ if {$rc eq [list 0 {}]} {
+ do_test ioerr5.1-$locking_mode-$iFail.3 {
+ execsql { SELECT count(*) FROM a }
+ } [expr $nRow+1]
+ break
+ }
+ }
+}
+
+# Make sure this test script doesn't leave any files open.
+#
+do_test ioerr5-1.X {
+ catch { db close }
+ catch { db2 close }
+ set sqlite_open_file_count
+} 0
+
+do_test ioerr5-2.0 {
+ sqlite3 db test.db
+ execsql { CREATE INDEX i1 ON a(id, name); }
+} {}
+
+foreach locking_mode {exclusive normal} {
+ for {set iFail 1} {$iFail<200} {incr iFail} {
+ sqlite3_soft_heap_limit 1048576
+ opendatabases
+ execsql { pragma locking_mode=exclusive }
+ set nRow [db one {SELECT count(*) FROM a}]
+
+ do_test ioerr5-2.$locking_mode-$iFail.1 {
+ execsql {
+ BEGIN EXCLUSIVE;
+ INSERT INTO a VALUES(1, 'ABCDEFGHIJKLMNOP');
+ }
+ } {}
+
+ set ::sqlite_io_error_persist 1
+ set ::sqlite_io_error_pending $iFail
+
+ sqlite3_release_memory 10000
+
+ set error_hit $::sqlite_io_error_hit
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_persist 0
+ set ::sqlite_io_error_pending 0
+ if {$error_hit} {
+ do_test ioerr5-2.$locking_mode-$iFail.3a {
+ catchsql COMMIT
+ } {1 {disk I/O error}}
+ } else {
+ do_test ioerr5-2.$locking_mode-$iFail.3b {
+ execsql COMMIT
+ } {}
+ break
+ }
+ }
+}
+
+# Make sure this test script doesn't leave any files open.
+#
+do_test ioerr5-2.X {
+ catch { db close }
+ catch { db2 close }
+ set sqlite_open_file_count
+} 0
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+sqlite3_soft_heap_limit $::soft_limit
+
+finish_test
diff --git a/test/join.test b/test/join.test
new file mode 100644
index 0000000..88ac04f
--- /dev/null
+++ b/test/join.test
@@ -0,0 +1,644 @@
+# 2002 May 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for joins, including outer joins.
+#
+# $Id: join.test,v 1.27 2009/07/01 16:12:08 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test join-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(2,3,4);
+ INSERT INTO t1 VALUES(3,4,5);
+ SELECT * FROM t1;
+ }
+} {1 2 3 2 3 4 3 4 5}
+do_test join-1.2 {
+ execsql {
+ CREATE TABLE t2(b,c,d);
+ INSERT INTO t2 VALUES(1,2,3);
+ INSERT INTO t2 VALUES(2,3,4);
+ INSERT INTO t2 VALUES(3,4,5);
+ SELECT * FROM t2;
+ }
+} {1 2 3 2 3 4 3 4 5}
+
+do_test join-1.3 {
+ execsql2 {
+ SELECT * FROM t1 NATURAL JOIN t2;
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+do_test join-1.3.1 {
+ execsql2 {
+ SELECT * FROM t2 NATURAL JOIN t1;
+ }
+} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}
+do_test join-1.3.2 {
+ execsql2 {
+ SELECT * FROM t2 AS x NATURAL JOIN t1;
+ }
+} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}
+do_test join-1.3.3 {
+ execsql2 {
+ SELECT * FROM t2 NATURAL JOIN t1 AS y;
+ }
+} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}
+do_test join-1.3.4 {
+ execsql {
+ SELECT b FROM t1 NATURAL JOIN t2;
+ }
+} {2 3}
+
+# ticket #3522
+do_test join-1.3.5 {
+ execsql2 {
+ SELECT t2.* FROM t2 NATURAL JOIN t1
+ }
+} {b 2 c 3 d 4 b 3 c 4 d 5}
+do_test join-1.3.6 {
+ execsql2 {
+ SELECT xyzzy.* FROM t2 AS xyzzy NATURAL JOIN t1
+ }
+} {b 2 c 3 d 4 b 3 c 4 d 5}
+do_test join-1.3.7 {
+ execsql2 {
+ SELECT t1.* FROM t2 NATURAL JOIN t1
+ }
+} {a 1 b 2 c 3 a 2 b 3 c 4}
+do_test join-1.3.8 {
+ execsql2 {
+ SELECT xyzzy.* FROM t2 NATURAL JOIN t1 AS xyzzy
+ }
+} {a 1 b 2 c 3 a 2 b 3 c 4}
+do_test join-1.3.9 {
+ execsql2 {
+ SELECT aaa.*, bbb.* FROM t2 AS aaa NATURAL JOIN t1 AS bbb
+ }
+} {b 2 c 3 d 4 a 1 b 2 c 3 b 3 c 4 d 5 a 2 b 3 c 4}
+do_test join-1.3.10 {
+ execsql2 {
+ SELECT t1.*, t2.* FROM t2 NATURAL JOIN t1
+ }
+} {a 1 b 2 c 3 b 2 c 3 d 4 a 2 b 3 c 4 b 3 c 4 d 5}
+
+
+do_test join-1.4.1 {
+ execsql2 {
+ SELECT * FROM t1 INNER JOIN t2 USING(b,c);
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+do_test join-1.4.2 {
+ execsql2 {
+ SELECT * FROM t1 AS x INNER JOIN t2 USING(b,c);
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+do_test join-1.4.3 {
+ execsql2 {
+ SELECT * FROM t1 INNER JOIN t2 AS y USING(b,c);
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+do_test join-1.4.4 {
+ execsql2 {
+ SELECT * FROM t1 AS x INNER JOIN t2 AS y USING(b,c);
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+do_test join-1.4.5 {
+ execsql {
+ SELECT b FROM t1 JOIN t2 USING(b);
+ }
+} {2 3}
+
+# Ticket #3522
+do_test join-1.4.6 {
+ execsql2 {
+ SELECT t1.* FROM t1 JOIN t2 USING(b);
+ }
+} {a 1 b 2 c 3 a 2 b 3 c 4}
+do_test join-1.4.7 {
+ execsql2 {
+ SELECT t2.* FROM t1 JOIN t2 USING(b);
+ }
+} {b 2 c 3 d 4 b 3 c 4 d 5}
+
+do_test join-1.5 {
+ execsql2 {
+ SELECT * FROM t1 INNER JOIN t2 USING(b);
+ }
+} {a 1 b 2 c 3 c 3 d 4 a 2 b 3 c 4 c 4 d 5}
+do_test join-1.6 {
+ execsql2 {
+ SELECT * FROM t1 INNER JOIN t2 USING(c);
+ }
+} {a 1 b 2 c 3 b 2 d 4 a 2 b 3 c 4 b 3 d 5}
+do_test join-1.7 {
+ execsql2 {
+ SELECT * FROM t1 INNER JOIN t2 USING(c,b);
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+
+do_test join-1.8 {
+ execsql {
+ SELECT * FROM t1 NATURAL CROSS JOIN t2;
+ }
+} {1 2 3 4 2 3 4 5}
+do_test join-1.9 {
+ execsql {
+ SELECT * FROM t1 CROSS JOIN t2 USING(b,c);
+ }
+} {1 2 3 4 2 3 4 5}
+do_test join-1.10 {
+ execsql {
+ SELECT * FROM t1 NATURAL INNER JOIN t2;
+ }
+} {1 2 3 4 2 3 4 5}
+do_test join-1.11 {
+ execsql {
+ SELECT * FROM t1 INNER JOIN t2 USING(b,c);
+ }
+} {1 2 3 4 2 3 4 5}
+do_test join-1.12 {
+ execsql {
+ SELECT * FROM t1 natural inner join t2;
+ }
+} {1 2 3 4 2 3 4 5}
+
+ifcapable subquery {
+ do_test join-1.13 {
+ execsql2 {
+ SELECT * FROM t1 NATURAL JOIN
+ (SELECT b as 'c', c as 'd', d as 'e' FROM t2) as t3
+ }
+ } {a 1 b 2 c 3 d 4 e 5}
+ do_test join-1.14 {
+ execsql2 {
+ SELECT * FROM (SELECT b as 'c', c as 'd', d as 'e' FROM t2) as 'tx'
+ NATURAL JOIN t1
+ }
+ } {c 3 d 4 e 5 a 1 b 2}
+}
+
+do_test join-1.15 {
+ execsql {
+ CREATE TABLE t3(c,d,e);
+ INSERT INTO t3 VALUES(2,3,4);
+ INSERT INTO t3 VALUES(3,4,5);
+ INSERT INTO t3 VALUES(4,5,6);
+ SELECT * FROM t3;
+ }
+} {2 3 4 3 4 5 4 5 6}
+do_test join-1.16 {
+ execsql {
+ SELECT * FROM t1 natural join t2 natural join t3;
+ }
+} {1 2 3 4 5 2 3 4 5 6}
+do_test join-1.17 {
+ execsql2 {
+ SELECT * FROM t1 natural join t2 natural join t3;
+ }
+} {a 1 b 2 c 3 d 4 e 5 a 2 b 3 c 4 d 5 e 6}
+do_test join-1.18 {
+ execsql {
+ CREATE TABLE t4(d,e,f);
+ INSERT INTO t4 VALUES(2,3,4);
+ INSERT INTO t4 VALUES(3,4,5);
+ INSERT INTO t4 VALUES(4,5,6);
+ SELECT * FROM t4;
+ }
+} {2 3 4 3 4 5 4 5 6}
+do_test join-1.19.1 {
+ execsql {
+ SELECT * FROM t1 natural join t2 natural join t4;
+ }
+} {1 2 3 4 5 6}
+do_test join-1.19.2 {
+ execsql2 {
+ SELECT * FROM t1 natural join t2 natural join t4;
+ }
+} {a 1 b 2 c 3 d 4 e 5 f 6}
+do_test join-1.20 {
+ execsql {
+ SELECT * FROM t1 natural join t2 natural join t3 WHERE t1.a=1
+ }
+} {1 2 3 4 5}
+
+do_test join-2.1 {
+ execsql {
+ SELECT * FROM t1 NATURAL LEFT JOIN t2;
+ }
+} {1 2 3 4 2 3 4 5 3 4 5 {}}
+
+# ticket #3522
+do_test join-2.1.1 {
+ execsql2 {
+ SELECT * FROM t1 NATURAL LEFT JOIN t2;
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5 a 3 b 4 c 5 d {}}
+do_test join-2.1.2 {
+ execsql2 {
+ SELECT t1.* FROM t1 NATURAL LEFT JOIN t2;
+ }
+} {a 1 b 2 c 3 a 2 b 3 c 4 a 3 b 4 c 5}
+do_test join-2.1.3 {
+ execsql2 {
+ SELECT t2.* FROM t1 NATURAL LEFT JOIN t2;
+ }
+} {b 2 c 3 d 4 b 3 c 4 d 5 b {} c {} d {}}
+
+do_test join-2.2 {
+ execsql {
+ SELECT * FROM t2 NATURAL LEFT OUTER JOIN t1;
+ }
+} {1 2 3 {} 2 3 4 1 3 4 5 2}
+do_test join-2.3 {
+ catchsql {
+ SELECT * FROM t1 NATURAL RIGHT OUTER JOIN t2;
+ }
+} {1 {RIGHT and FULL OUTER JOINs are not currently supported}}
+do_test join-2.4 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d
+ }
+} {1 2 3 {} {} {} 2 3 4 {} {} {} 3 4 5 1 2 3}
+do_test join-2.5 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d WHERE t1.a>1
+ }
+} {2 3 4 {} {} {} 3 4 5 1 2 3}
+do_test join-2.6 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d WHERE t2.b IS NULL OR t2.b>1
+ }
+} {1 2 3 {} {} {} 2 3 4 {} {} {}}
+
+do_test join-3.1 {
+ catchsql {
+ SELECT * FROM t1 NATURAL JOIN t2 ON t1.a=t2.b;
+ }
+} {1 {a NATURAL join may not have an ON or USING clause}}
+do_test join-3.2 {
+ catchsql {
+ SELECT * FROM t1 NATURAL JOIN t2 USING(b);
+ }
+} {1 {a NATURAL join may not have an ON or USING clause}}
+do_test join-3.3 {
+ catchsql {
+ SELECT * FROM t1 JOIN t2 ON t1.a=t2.b USING(b);
+ }
+} {1 {cannot have both ON and USING clauses in the same join}}
+do_test join-3.4.1 {
+ catchsql {
+ SELECT * FROM t1 JOIN t2 USING(a);
+ }
+} {1 {cannot join using column a - column not present in both tables}}
+do_test join-3.4.2 {
+ catchsql {
+ SELECT * FROM t1 JOIN t2 USING(d);
+ }
+} {1 {cannot join using column d - column not present in both tables}}
+do_test join-3.5 {
+ catchsql { SELECT * FROM t1 USING(a) }
+} {1 {a JOIN clause is required before USING}}
+do_test join-3.6 {
+ catchsql {
+ SELECT * FROM t1 JOIN t2 ON t3.a=t2.b;
+ }
+} {1 {no such column: t3.a}}
+do_test join-3.7 {
+ catchsql {
+ SELECT * FROM t1 INNER OUTER JOIN t2;
+ }
+} {1 {unknown or unsupported join type: INNER OUTER}}
+do_test join-3.8 {
+ catchsql {
+ SELECT * FROM t1 INNER OUTER CROSS JOIN t2;
+ }
+} {1 {unknown or unsupported join type: INNER OUTER CROSS}}
+do_test join-3.9 {
+ catchsql {
+ SELECT * FROM t1 OUTER NATURAL INNER JOIN t2;
+ }
+} {1 {unknown or unsupported join type: OUTER NATURAL INNER}}
+do_test join-3.10 {
+ catchsql {
+ SELECT * FROM t1 LEFT BOGUS JOIN t2;
+ }
+} {1 {unknown or unsupported join type: LEFT BOGUS}}
+do_test join-3.11 {
+ catchsql {
+ SELECT * FROM t1 INNER BOGUS CROSS JOIN t2;
+ }
+} {1 {unknown or unsupported join type: INNER BOGUS CROSS}}
+do_test join-3.12 {
+ catchsql {
+ SELECT * FROM t1 NATURAL AWK SED JOIN t2;
+ }
+} {1 {unknown or unsupported join type: NATURAL AWK SED}}
+
+do_test join-4.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t5(a INTEGER PRIMARY KEY);
+ CREATE TABLE t6(a INTEGER);
+ INSERT INTO t6 VALUES(NULL);
+ INSERT INTO t6 VALUES(NULL);
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ COMMIT;
+ }
+ execsql {
+ SELECT * FROM t6 NATURAL JOIN t5;
+ }
+} {}
+do_test join-4.2 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a<t5.a;
+ }
+} {}
+do_test join-4.3 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a>t5.a;
+ }
+} {}
+do_test join-4.4 {
+ execsql {
+ UPDATE t6 SET a='xyz';
+ SELECT * FROM t6 NATURAL JOIN t5;
+ }
+} {}
+do_test join-4.6 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a<t5.a;
+ }
+} {}
+do_test join-4.7 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a>t5.a;
+ }
+} {}
+do_test join-4.8 {
+ execsql {
+ UPDATE t6 SET a=1;
+ SELECT * FROM t6 NATURAL JOIN t5;
+ }
+} {}
+do_test join-4.9 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a<t5.a;
+ }
+} {}
+do_test join-4.10 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a>t5.a;
+ }
+} {}
+
+do_test join-5.1 {
+ execsql {
+ BEGIN;
+ create table centros (id integer primary key, centro);
+ INSERT INTO centros VALUES(1,'xxx');
+ create table usuarios (id integer primary key, nombre, apellidos,
+ idcentro integer);
+ INSERT INTO usuarios VALUES(1,'a','aa',1);
+ INSERT INTO usuarios VALUES(2,'b','bb',1);
+ INSERT INTO usuarios VALUES(3,'c','cc',NULL);
+ create index idcentro on usuarios (idcentro);
+ END;
+ select usuarios.id, usuarios.nombre, centros.centro from
+ usuarios left outer join centros on usuarios.idcentro = centros.id;
+ }
+} {1 a xxx 2 b xxx 3 c {}}
+
+# A test for ticket #247.
+#
+do_test join-7.1 {
+ execsql {
+ CREATE TABLE t7 (x, y);
+ INSERT INTO t7 VALUES ("pa1", 1);
+ INSERT INTO t7 VALUES ("pa2", NULL);
+ INSERT INTO t7 VALUES ("pa3", NULL);
+ INSERT INTO t7 VALUES ("pa4", 2);
+ INSERT INTO t7 VALUES ("pa30", 131);
+ INSERT INTO t7 VALUES ("pa31", 130);
+ INSERT INTO t7 VALUES ("pa28", NULL);
+
+ CREATE TABLE t8 (a integer primary key, b);
+ INSERT INTO t8 VALUES (1, "pa1");
+ INSERT INTO t8 VALUES (2, "pa4");
+ INSERT INTO t8 VALUES (3, NULL);
+ INSERT INTO t8 VALUES (4, NULL);
+ INSERT INTO t8 VALUES (130, "pa31");
+ INSERT INTO t8 VALUES (131, "pa30");
+
+ SELECT coalesce(t8.a,999) from t7 LEFT JOIN t8 on y=a;
+ }
+} {1 999 999 2 131 130 999}
+
+# Make sure a left join where the right table is really a view that
+# is itself a join works right. Ticket #306.
+#
+ifcapable view {
+do_test join-8.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t9(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t9 VALUES(1,11);
+ INSERT INTO t9 VALUES(2,22);
+ CREATE TABLE t10(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t10 VALUES(1,2);
+ INSERT INTO t10 VALUES(3,3);
+ CREATE TABLE t11(p INTEGER PRIMARY KEY, q);
+ INSERT INTO t11 VALUES(2,111);
+ INSERT INTO t11 VALUES(3,333);
+ CREATE VIEW v10_11 AS SELECT x, q FROM t10, t11 WHERE t10.y=t11.p;
+ COMMIT;
+ SELECT * FROM t9 LEFT JOIN v10_11 ON( a=x );
+ }
+} {1 11 1 111 2 22 {} {}}
+ifcapable subquery {
+ do_test join-8.2 {
+ execsql {
+ SELECT * FROM t9 LEFT JOIN (SELECT x, q FROM t10, t11 WHERE t10.y=t11.p)
+ ON( a=x);
+ }
+ } {1 11 1 111 2 22 {} {}}
+}
+do_test join-8.3 {
+ execsql {
+ SELECT * FROM v10_11 LEFT JOIN t9 ON( a=x );
+ }
+} {1 111 1 11 3 333 {} {}}
+ifcapable subquery {
+ # Constant expressions in a subquery that is the right element of a
+ # LEFT JOIN evaluate to NULL for rows where the LEFT JOIN does not
+ # match. Ticket #3300
+ do_test join-8.4 {
+ execsql {
+ SELECT * FROM t9 LEFT JOIN (SELECT 44, p, q FROM t11) AS sub1 ON p=a
+ }
+ } {1 11 {} {} {} 2 22 44 2 111}
+}
+} ;# ifcapable view
+
+# Ticket #350 describes a scenario where LEFT OUTER JOIN does not
+# function correctly if the right table in the join is really
+# subquery.
+#
+# To test the problem, we generate the same LEFT OUTER JOIN in two
+# separate selects but with on using a subquery and the other calling
+# the table directly. Then connect the two SELECTs using an EXCEPT.
+# Both queries should generate the same results so the answer should
+# be an empty set.
+#
+ifcapable compound {
+do_test join-9.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t12(a,b);
+ INSERT INTO t12 VALUES(1,11);
+ INSERT INTO t12 VALUES(2,22);
+ CREATE TABLE t13(b,c);
+ INSERT INTO t13 VALUES(22,222);
+ COMMIT;
+ }
+} {}
+
+ifcapable subquery {
+ do_test join-9.1.1 {
+ execsql {
+ SELECT * FROM t12 NATURAL LEFT JOIN t13
+ EXCEPT
+ SELECT * FROM t12 NATURAL LEFT JOIN (SELECT * FROM t13 WHERE b>0);
+ }
+ } {}
+}
+ifcapable view {
+ do_test join-9.2 {
+ execsql {
+ CREATE VIEW v13 AS SELECT * FROM t13 WHERE b>0;
+ SELECT * FROM t12 NATURAL LEFT JOIN t13
+ EXCEPT
+ SELECT * FROM t12 NATURAL LEFT JOIN v13;
+ }
+ } {}
+} ;# ifcapable view
+} ;# ifcapable compound
+
+ifcapable subquery {
+ # Ticket #1697: Left Join WHERE clause terms that contain an
+ # aggregate subquery.
+ #
+ do_test join-10.1 {
+ execsql {
+ CREATE TABLE t21(a,b,c);
+ CREATE TABLE t22(p,q);
+ CREATE INDEX i22 ON t22(q);
+ SELECT a FROM t21 LEFT JOIN t22 ON b=p WHERE q=
+ (SELECT max(m.q) FROM t22 m JOIN t21 n ON n.b=m.p WHERE n.c=1);
+ }
+ } {}
+
+ # Test a LEFT JOIN when the right-hand side of hte join is an empty
+ # sub-query. Seems fine.
+ #
+ do_test join-10.2 {
+ execsql {
+ CREATE TABLE t23(a, b, c);
+ CREATE TABLE t24(a, b, c);
+ INSERT INTO t23 VALUES(1, 2, 3);
+ }
+ execsql {
+ SELECT * FROM t23 LEFT JOIN t24;
+ }
+ } {1 2 3 {} {} {}}
+ do_test join-10.3 {
+ execsql {
+ SELECT * FROM t23 LEFT JOIN (SELECT * FROM t24);
+ }
+ } {1 2 3 {} {} {}}
+
+} ;# ifcapable subquery
+
+#-------------------------------------------------------------------------
+# The following tests are to ensure that bug b73fb0bd64 is fixed.
+#
+do_test join-11.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t1 VALUES(1,'abc');
+ INSERT INTO t1 VALUES(2,'def');
+ INSERT INTO t2 VALUES(1,'abc');
+ INSERT INTO t2 VALUES(2,'def');
+ SELECT * FROM t1 NATURAL JOIN t2;
+ }
+} {1 abc 2 def}
+
+do_test join-11.2 {
+ execsql { SELECT a FROM t1 JOIN t1 USING (a)}
+} {1 2}
+do_test join-11.3 {
+ execsql { SELECT a FROM t1 JOIN t1 AS t2 USING (a)}
+} {1 2}
+do_test join-11.3 {
+ execsql { SELECT * FROM t1 NATURAL JOIN t1 AS t2}
+} {1 abc 2 def}
+do_test join-11.4 {
+ execsql { SELECT * FROM t1 NATURAL JOIN t1 }
+} {1 abc 2 def}
+
+do_test join-11.5 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE t1(a COLLATE nocase, b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t1 VALUES('ONE', 1);
+ INSERT INTO t1 VALUES('two', 2);
+ INSERT INTO t2 VALUES('one', 1);
+ INSERT INTO t2 VALUES('two', 2);
+ }
+} {}
+do_test join-11.6 {
+ execsql { SELECT * FROM t1 NATURAL JOIN t2 }
+} {ONE 1 two 2}
+do_test join-11.7 {
+ execsql { SELECT * FROM t2 NATURAL JOIN t1 }
+} {two 2}
+
+do_test join-11.8 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE t1(a, b TEXT);
+ CREATE TABLE t2(b INTEGER, a);
+ INSERT INTO t1 VALUES('one', '1.0');
+ INSERT INTO t1 VALUES('two', '2');
+ INSERT INTO t2 VALUES(1, 'one');
+ INSERT INTO t2 VALUES(2, 'two');
+ }
+} {}
+do_test join-11.9 {
+ execsql { SELECT * FROM t1 NATURAL JOIN t2 }
+} {one 1.0 two 2}
+do_test join-11.10 {
+ execsql { SELECT * FROM t2 NATURAL JOIN t1 }
+} {1 one 2 two}
+
+finish_test
diff --git a/test/join2.test b/test/join2.test
new file mode 100644
index 0000000..0f558c5
--- /dev/null
+++ b/test/join2.test
@@ -0,0 +1,75 @@
+# 2002 May 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for joins, including outer joins.
+#
+# $Id: join2.test,v 1.2 2005/01/21 03:12:16 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test join2-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,11);
+ INSERT INTO t1 VALUES(2,22);
+ INSERT INTO t1 VALUES(3,33);
+ SELECT * FROM t1;
+ }
+} {1 11 2 22 3 33}
+do_test join2-1.2 {
+ execsql {
+ CREATE TABLE t2(b,c);
+ INSERT INTO t2 VALUES(11,111);
+ INSERT INTO t2 VALUES(33,333);
+ INSERT INTO t2 VALUES(44,444);
+ SELECT * FROM t2;
+ }
+} {11 111 33 333 44 444};
+do_test join2-1.3 {
+ execsql {
+ CREATE TABLE t3(c,d);
+ INSERT INTO t3 VALUES(111,1111);
+ INSERT INTO t3 VALUES(444,4444);
+ INSERT INTO t3 VALUES(555,5555);
+ SELECT * FROM t3;
+ }
+} {111 1111 444 4444 555 5555}
+
+do_test join2-1.4 {
+ execsql {
+ SELECT * FROM
+ t1 NATURAL JOIN t2 NATURAL JOIN t3
+ }
+} {1 11 111 1111}
+do_test join2-1.5 {
+ execsql {
+ SELECT * FROM
+ t1 NATURAL JOIN t2 NATURAL LEFT OUTER JOIN t3
+ }
+} {1 11 111 1111 3 33 333 {}}
+do_test join2-1.6 {
+ execsql {
+ SELECT * FROM
+ t1 NATURAL LEFT OUTER JOIN t2 NATURAL JOIN t3
+ }
+} {1 11 111 1111}
+ifcapable subquery {
+ do_test join2-1.7 {
+ execsql {
+ SELECT * FROM
+ t1 NATURAL LEFT OUTER JOIN (t2 NATURAL JOIN t3)
+ }
+ } {1 11 111 1111 2 22 {} {} 3 33 {} {}}
+}
+
+finish_test
diff --git a/test/join3.test b/test/join3.test
new file mode 100644
index 0000000..f1c273d
--- /dev/null
+++ b/test/join3.test
@@ -0,0 +1,62 @@
+# 2002 May 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for joins, including outer joins, where
+# there are a large number of tables involved in the join.
+#
+# $Id: join3.test,v 1.4 2005/01/19 23:24:51 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# An unrestricted join
+#
+catch {unset ::result}
+set result {}
+for {set N 1} {$N<=$bitmask_size} {incr N} {
+ lappend result $N
+ do_test join3-1.$N {
+ execsql "CREATE TABLE t${N}(x);"
+ execsql "INSERT INTO t$N VALUES($N)"
+ set sql "SELECT * FROM t1"
+ for {set i 2} {$i<=$N} {incr i} {append sql ", t$i"}
+ execsql $sql
+ } $result
+}
+
+# Joins with a comparison
+#
+set result {}
+for {set N 1} {$N<=$bitmask_size} {incr N} {
+ lappend result $N
+ do_test join3-2.$N {
+ set sql "SELECT * FROM t1"
+ for {set i 2} {$i<=$N} {incr i} {append sql ", t$i"}
+ set sep WHERE
+ for {set i 1} {$i<$N} {incr i} {
+ append sql " $sep t[expr {$i+1}].x==t$i.x+1"
+ set sep AND
+ }
+ execsql $sql
+ } $result
+}
+
+# Error of too many tables in the join
+#
+do_test join3-3.1 {
+ set sql "SELECT * FROM t1 AS t0, t1"
+ for {set i 2} {$i<=$bitmask_size} {incr i} {append sql ", t$i"}
+ catchsql $sql
+} [list 1 "at most $bitmask_size tables in a join"]
+
+
+finish_test
diff --git a/test/join4.test b/test/join4.test
new file mode 100644
index 0000000..77db25f
--- /dev/null
+++ b/test/join4.test
@@ -0,0 +1,98 @@
+# 2002 May 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for left outer joins containing WHERE
+# clauses that restrict the scope of the left term of the join.
+#
+# $Id: join4.test,v 1.4 2005/03/29 03:11:00 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable tempdb {
+ do_test join4-1.1 {
+ execsql {
+ create temp table t1(a integer, b varchar(10));
+ insert into t1 values(1,'one');
+ insert into t1 values(2,'two');
+ insert into t1 values(3,'three');
+ insert into t1 values(4,'four');
+
+ create temp table t2(x integer, y varchar(10), z varchar(10));
+ insert into t2 values(2,'niban','ok');
+ insert into t2 values(4,'yonban','err');
+ }
+ execsql {
+ select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
+ }
+ } {2 two 2 niban ok}
+} else {
+ do_test join4-1.1 {
+ execsql {
+ create table t1(a integer, b varchar(10));
+ insert into t1 values(1,'one');
+ insert into t1 values(2,'two');
+ insert into t1 values(3,'three');
+ insert into t1 values(4,'four');
+
+ create table t2(x integer, y varchar(10), z varchar(10));
+ insert into t2 values(2,'niban','ok');
+ insert into t2 values(4,'yonban','err');
+ }
+ execsql {
+ select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
+ }
+ } {2 two 2 niban ok}
+}
+do_test join4-1.2 {
+ execsql {
+ select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'
+ }
+} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
+do_test join4-1.3 {
+ execsql {
+ create index i2 on t2(z);
+ }
+ execsql {
+ select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
+ }
+} {2 two 2 niban ok}
+do_test join4-1.4 {
+ execsql {
+ select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'
+ }
+} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
+do_test join4-1.5 {
+ execsql {
+ select * from t1 left outer join t2 on t1.a=t2.x where t2.z>='ok'
+ }
+} {2 two 2 niban ok}
+do_test join4-1.4 {
+ execsql {
+ select * from t1 left outer join t2 on t1.a=t2.x and t2.z>='ok'
+ }
+} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
+ifcapable subquery {
+ do_test join4-1.6 {
+ execsql {
+ select * from t1 left outer join t2 on t1.a=t2.x where t2.z IN ('ok')
+ }
+ } {2 two 2 niban ok}
+ do_test join4-1.7 {
+ execsql {
+ select * from t1 left outer join t2 on t1.a=t2.x and t2.z IN ('ok')
+ }
+ } {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
+}
+
+
+finish_test
diff --git a/test/join5.test b/test/join5.test
new file mode 100644
index 0000000..45d8a31
--- /dev/null
+++ b/test/join5.test
@@ -0,0 +1,110 @@
+# 2005 September 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for left outer joins containing ON
+# clauses that restrict the scope of the left term of the join.
+#
+# $Id: join5.test,v 1.2 2007/06/08 00:20:48 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+do_test join5-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a integer primary key, b integer, c integer);
+ CREATE TABLE t2(x integer primary key, y);
+ CREATE TABLE t3(p integer primary key, q);
+ INSERT INTO t3 VALUES(11,'t3-11');
+ INSERT INTO t3 VALUES(12,'t3-12');
+ INSERT INTO t2 VALUES(11,'t2-11');
+ INSERT INTO t2 VALUES(12,'t2-12');
+ INSERT INTO t1 VALUES(1, 5, 0);
+ INSERT INTO t1 VALUES(2, 11, 2);
+ INSERT INTO t1 VALUES(3, 12, 1);
+ COMMIT;
+ }
+} {}
+do_test join5-1.2 {
+ execsql {
+ select * from t1 left join t2 on t1.b=t2.x and t1.c=1
+ }
+} {1 5 0 {} {} 2 11 2 {} {} 3 12 1 12 t2-12}
+do_test join5-1.3 {
+ execsql {
+ select * from t1 left join t2 on t1.b=t2.x where t1.c=1
+ }
+} {3 12 1 12 t2-12}
+do_test join5-1.4 {
+ execsql {
+ select * from t1 left join t2 on t1.b=t2.x and t1.c=1
+ left join t3 on t1.b=t3.p and t1.c=2
+ }
+} {1 5 0 {} {} {} {} 2 11 2 {} {} 11 t3-11 3 12 1 12 t2-12 {} {}}
+do_test join5-1.5 {
+ execsql {
+ select * from t1 left join t2 on t1.b=t2.x and t1.c=1
+ left join t3 on t1.b=t3.p where t1.c=2
+ }
+} {2 11 2 {} {} 11 t3-11}
+
+# Ticket #2403
+#
+do_test join5-2.1 {
+ execsql {
+ CREATE TABLE ab(a,b);
+ INSERT INTO "ab" VALUES(1,2);
+ INSERT INTO "ab" VALUES(3,NULL);
+
+ CREATE TABLE xy(x,y);
+ INSERT INTO "xy" VALUES(2,3);
+ INSERT INTO "xy" VALUES(NULL,1);
+ }
+ execsql {SELECT * FROM xy LEFT JOIN ab ON 0}
+} {2 3 {} {} {} 1 {} {}}
+do_test join5-2.2 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON 1}
+} {2 3 1 2 2 3 3 {} {} 1 1 2 {} 1 3 {}}
+do_test join5-2.3 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON NULL}
+} {2 3 {} {} {} 1 {} {}}
+do_test join5-2.4 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON 0 WHERE 0}
+} {}
+do_test join5-2.5 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON 1 WHERE 0}
+} {}
+do_test join5-2.6 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON NULL WHERE 0}
+} {}
+do_test join5-2.7 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON 0 WHERE 1}
+} {2 3 {} {} {} 1 {} {}}
+do_test join5-2.8 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON 1 WHERE 1}
+} {2 3 1 2 2 3 3 {} {} 1 1 2 {} 1 3 {}}
+do_test join5-2.9 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON NULL WHERE 1}
+} {2 3 {} {} {} 1 {} {}}
+do_test join5-2.10 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON 0 WHERE NULL}
+} {}
+do_test join5-2.11 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON 1 WHERE NULL}
+} {}
+do_test join5-2.12 {
+ execsql {SELECT * FROM xy LEFT JOIN ab ON NULL WHERE NULL}
+} {}
+
+
+finish_test
diff --git a/test/join6.test b/test/join6.test
new file mode 100644
index 0000000..4f65dcb
--- /dev/null
+++ b/test/join6.test
@@ -0,0 +1,158 @@
+# 2009 December 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for N-way joins (N>2) which make
+# use of USING or NATURAL JOIN. For such joins, the USING and
+# NATURAL JOIN processing needs to search all tables to the left
+# of the join looking for a match. See ticket [f74beaabde]
+# for additional information.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+# The problem as initially reported on the mailing list:
+#
+do_test join6-1.1 {
+ execsql {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(a);
+ CREATE TABLE t3(a,b);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t3 VALUES(1,2);
+
+ SELECT * FROM t1 LEFT JOIN t2 USING(a) LEFT JOIN t3 USING(a);
+ }
+} {1 2}
+do_test join6-1.2 {
+ execsql {
+ SELECT t1.a, t3.b
+ FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.a=t3.a;
+ }
+} {1 {}}
+do_test join6-1.3 {
+ execsql {
+ SELECT t1.a, t3.b
+ FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t1.a=t3.a;
+ }
+} {1 2}
+
+
+do_test join6-2.1 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ DROP TABLE t3;
+
+ CREATE TABLE t1(x,y);
+ CREATE TABLE t2(y,z);
+ CREATE TABLE t3(x,z);
+
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+
+ INSERT INTO t2 VALUES(2,3);
+ INSERT INTO t2 VALUES(4,5);
+
+ INSERT INTO t3 VALUES(1,3);
+ INSERT INTO t3 VALUES(3,5);
+
+ SELECT * FROM t1 JOIN t2 USING (y) JOIN t3 USING(x);
+ }
+} {1 2 3 3 3 4 5 5}
+do_test join6-2.2 {
+ execsql {
+ SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3;
+ }
+} {1 2 3 3 4 5}
+
+
+do_test join6-3.1 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ DROP TABLE t3;
+
+ CREATE TABLE t1(a,x,y);
+ INSERT INTO t1 VALUES(1,91,92);
+ INSERT INTO t1 VALUES(2,93,94);
+
+ CREATE TABLE t2(b,y,z);
+ INSERT INTO t2 VALUES(3,92,93);
+ INSERT INTO t2 VALUES(4,94,95);
+
+ CREATE TABLE t3(c,x,z);
+ INSERT INTO t3 VALUES(5,91,93);
+ INSERT INTO t3 VALUES(6,99,95);
+
+ SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3;
+ }
+} {1 91 92 3 93 5}
+do_test join6-3.2 {
+ execsql {
+ SELECT * FROM t1 JOIN t2 NATURAL JOIN t3;
+ }
+} {1 91 92 3 92 93 5}
+do_test join6-3.3 {
+ execsql {
+ SELECT * FROM t1 JOIN t2 USING(y) NATURAL JOIN t3;
+ }
+} {1 91 92 3 93 5}
+do_test join6-3.4 {
+ execsql {
+ SELECT * FROM t1 NATURAL JOIN t2 JOIN t3 USING(x,z);
+ }
+} {1 91 92 3 93 5}
+do_test join6-3.5 {
+ execsql {
+ SELECT * FROM t1 NATURAL JOIN t2 JOIN t3 USING(x);
+ }
+} {1 91 92 3 93 5 93}
+do_test join6-3.6 {
+ execsql {
+ SELECT * FROM t1 NATURAL JOIN t2 JOIN t3 USING(z);
+ }
+} {1 91 92 3 93 5 91 2 93 94 4 95 6 99}
+
+do_test join6-4.1 {
+ execsql {
+ SELECT * FROM
+ (SELECT 1 AS a, 91 AS x, 92 AS y UNION SELECT 2, 93, 94)
+ NATURAL JOIN t2 NATURAL JOIN t3
+ }
+} {1 91 92 3 93 5}
+do_test join6-4.2 {
+ execsql {
+ SELECT * FROM t1 NATURAL JOIN
+ (SELECT 3 AS b, 92 AS y, 93 AS z UNION SELECT 4, 94, 95)
+ NATURAL JOIN t3
+ }
+} {1 91 92 3 93 5}
+do_test join6-4.3 {
+ execsql {
+ SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN
+ (SELECT 5 AS c, 91 AS x, 93 AS z UNION SELECT 6, 99, 95)
+ }
+} {1 91 92 3 93 5}
+
+
+
+
+
+
+
+
+
+
+
+finish_test
diff --git a/test/journal1.test b/test/journal1.test
new file mode 100644
index 0000000..2fdadfd
--- /dev/null
+++ b/test/journal1.test
@@ -0,0 +1,67 @@
+# 2005 March 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure that leftover journals from
+# prior databases do not try to rollback into new databases.
+#
+# $Id: journal1.test,v 1.2 2005/03/20 22:54:56 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# These tests will not work on windows because windows uses
+# manditory file locking which breaks the copy_file command.
+#
+if {$tcl_platform(platform)=="windows"} {
+ finish_test
+ return
+}
+
+# Create a smaple database
+#
+do_test journal1-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,randstr(10,400));
+ INSERT INTO t1 VALUES(2,randstr(10,400));
+ INSERT INTO t1 SELECT a+2, a||b FROM t1;
+ INSERT INTO t1 SELECT a+4, a||b FROM t1;
+ SELECT count(*) FROM t1;
+ }
+} 8
+
+# Make changes to the database and save the journal file.
+# Then delete the database. Replace the the journal file
+# and try to create a new database with the same name. The
+# old journal should not attempt to rollback into the new
+# database.
+#
+do_test journal1-1.2 {
+ execsql {
+ BEGIN;
+ DELETE FROM t1;
+ }
+ forcecopy test.db-journal test.db-journal-bu
+ execsql {
+ ROLLBACK;
+ }
+ db close
+ delete_file test.db
+ copy_file test.db-journal-bu test.db-journal
+ sqlite3 db test.db
+ catchsql {
+ SELECT * FROM sqlite_master
+ }
+} {0 {}}
+
+finish_test
diff --git a/test/journal2.test b/test/journal2.test
new file mode 100644
index 0000000..25ce941
--- /dev/null
+++ b/test/journal2.test
@@ -0,0 +1,234 @@
+# 2010 June 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests SQLite when using a VFS that claims the SAFE_DELETE property.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+db close
+
+if {[permutation] == "inmemory_journal"} {
+ finish_test
+ return
+}
+
+set a_string_counter 1
+proc a_string {n} {
+ global a_string_counter
+ incr a_string_counter
+ string range [string repeat "${a_string_counter}." $n] 1 $n
+}
+
+# Create a [testvfs] and install it as the default VFS. Set the device
+# characteristics flags to "SAFE_DELETE".
+#
+testvfs tvfs -default 1
+tvfs devchar undeletable_when_open
+
+# Set up a hook so that each time a journal file is opened, closed or
+# deleted, the method name ("xOpen", "xClose" or "xDelete") and the final
+# segment of the journal file-name (i.e. "test.db-journal") are appended to
+# global list variable $::oplog.
+#
+tvfs filter {xOpen xClose xDelete}
+tvfs script journal_op_catcher
+proc journal_op_catcher {method filename args} {
+
+ # If global variable ::tvfs_error_on_write is defined, then return an
+ # IO error to every attempt to modify the file-system. Otherwise, return
+ # SQLITE_OK.
+ #
+ if {[info exists ::tvfs_error_on_write]} {
+ if {[lsearch {xDelete xWrite xTruncate} $method]>=0} {
+ return SQLITE_IOERR
+ }
+ }
+
+ # The rest of this command only deals with xOpen(), xClose() and xDelete()
+ # operations on journal files. If this invocation does not represent such
+ # an operation, return with no further ado.
+ #
+ set f [file tail $filename]
+ if {[string match *journal $f]==0} return
+ if {[lsearch {xOpen xDelete xClose} $method]<0} return
+
+ # Append a record of this operation to global list variable $::oplog.
+ #
+ lappend ::oplog $method $f
+
+ # If this is an attempt to delete a journal file for which there exists
+ # one ore more open handles, return an error. The code in test_vfs.c
+ # will not invoke the xDelete method of the "real" VFS in this case.
+ #
+ if {[info exists ::open_journals($f)]==0} { set ::open_journals($f) 0 }
+ switch -- $method {
+ xOpen { incr ::open_journals($f) +1 }
+ xClose { incr ::open_journals($f) -1 }
+ xDelete { if {$::open_journals($f)>0} { return SQLITE_IOERR } }
+ }
+
+ return ""
+}
+
+
+do_test journal2-1.1 {
+ set ::oplog [list]
+ sqlite3 db test.db
+ execsql { CREATE TABLE t1(a, b) }
+ set ::oplog
+} {xOpen test.db-journal xClose test.db-journal xDelete test.db-journal}
+do_test journal2-1.2 {
+ set ::oplog [list]
+ execsql {
+ PRAGMA journal_mode = truncate;
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ set ::oplog
+} {xOpen test.db-journal}
+do_test journal2-1.3 {
+ set ::oplog [list]
+ execsql { INSERT INTO t1 VALUES(3, 4) }
+ set ::oplog
+} {}
+do_test journal2-1.4 { execsql { SELECT * FROM t1 } } {1 2 3 4}
+
+# Add a second connection. This connection attempts to commit data in
+# journal_mode=DELETE mode. When it tries to delete the journal file,
+# the VFS layer returns an IO error.
+#
+do_test journal2-1.5 {
+ set ::oplog [list]
+ sqlite3 db2 test.db
+ execsql { PRAGMA journal_mode = delete } db2
+ catchsql { INSERT INTO t1 VALUES(5, 6) } db2
+} {1 {disk I/O error}}
+do_test journal2-1.6 { file exists test.db-journal } 1
+do_test journal2-1.7 { execsql { SELECT * FROM t1 } } {1 2 3 4}
+do_test journal2-1.8 {
+ execsql { PRAGMA journal_mode = truncate } db2
+ execsql { INSERT INTO t1 VALUES(5, 6) } db2
+} {}
+do_test journal2-1.9 { execsql { SELECT * FROM t1 } } {1 2 3 4 5 6}
+
+# Grow the database until it is reasonably large.
+#
+do_test journal2-1.10 {
+ db2 close
+ db func a_string a_string
+ execsql {
+ CREATE TABLE t2(a UNIQUE, b UNIQUE);
+ INSERT INTO t2 VALUES(a_string(200), a_string(300));
+ INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2; -- 2
+ INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2; -- 4
+ INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2; -- 8
+ INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2; -- 16
+ INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2; -- 32
+ INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2; -- 64
+ }
+ file size test.db-journal
+} {0}
+do_test journal2-1.11 {
+ set sz [expr [file size test.db] / 1024]
+ expr {$sz>120 && $sz<200}
+} 1
+
+# Using new connection [db2] (with journal_mode=DELETE), write a lot of
+# data to the database. So that many pages within the database file are
+# modified before the transaction is committed.
+#
+# Then, enable simulated IO errors in all calls to xDelete, xWrite
+# and xTruncate before committing the transaction and closing the
+# database file. From the point of view of other file-system users, it
+# appears as if the process hosting [db2] unexpectedly exited.
+#
+do_test journal2-1.12 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ INSERT INTO t2 SELECT randomblob(200), randomblob(300) FROM t2; -- 128
+ } db2
+} {}
+do_test journal2-1.13 {
+ tvfs filter {xOpen xClose xDelete xWrite xTruncate}
+ set ::tvfs_error_on_write 1
+ catchsql { COMMIT } db2
+} {1 {disk I/O error}}
+db2 close
+unset ::tvfs_error_on_write
+forcecopy test.db testX.db
+
+do_test journal2-1.14 { file exists test.db-journal } 1
+do_test journal2-1.15 {
+ execsql {
+ SELECT count(*) FROM t2;
+ PRAGMA integrity_check;
+ }
+} {64 ok}
+
+# This block checks that in the test case above, connection [db2] really
+# did begin writing to the database file before it hit IO errors. If
+# this is true, then the copy of the database file made before [db]
+# rolled back the hot journal should fail the integrity-check.
+#
+do_test journal2-1.16 {
+ set sz [expr [file size testX.db] / 1024]
+ expr {$sz>240 && $sz<400}
+} 1
+do_test journal2-1.17 {
+ expr {[catchsql { PRAGMA integrity_check } db] == "0 ok"}
+} {1}
+do_test journal2-1.20 {
+ sqlite3 db2 testX.db
+ expr {[catchsql { PRAGMA integrity_check } db2] == "0 ok"}
+} {0}
+do_test journal2-1.21 {
+ db2 close
+} {}
+db close
+
+#-------------------------------------------------------------------------
+# Test that it is possible to switch from journal_mode=truncate to
+# journal_mode=WAL on a SAFE_DELETE file-system. SQLite should close and
+# delete the journal file when committing the transaction that switches
+# the system to WAL mode.
+#
+ifcapable wal {
+ do_test journal2-2.1 {
+ faultsim_delete_and_reopen
+ set ::oplog [list]
+ execsql { PRAGMA journal_mode = persist }
+ set ::oplog
+ } {}
+ do_test journal2-2.2 {
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(3.14159);
+ }
+ set ::oplog
+ } {xOpen test.db-journal}
+ do_test journal2-2.3 {
+ expr {[file size test.db-journal] > 512}
+ } {1}
+ do_test journal2-2.4 {
+ set ::oplog [list]
+ execsql { PRAGMA journal_mode = WAL }
+ set ::oplog
+ } {xClose test.db-journal xDelete test.db-journal}
+ db close
+}
+
+tvfs delete
+finish_test
+
diff --git a/test/journal3.test b/test/journal3.test
new file mode 100644
index 0000000..f1bf89f
--- /dev/null
+++ b/test/journal3.test
@@ -0,0 +1,60 @@
+# 2010 July 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+#-------------------------------------------------------------------------
+# If a connection is required to create a journal file, it creates it with
+# the same file-system permissions as the database file itself. Test this.
+#
+if {$::tcl_platform(platform) == "unix"} {
+
+ set umask [exec /bin/sh -c umask]
+ faultsim_delete_and_reopen
+ do_test journal3-1.1 { execsql { CREATE TABLE tx(y, z) } } {}
+
+ foreach {tn permissions} {
+ 1 00644
+ 2 00666
+ 3 00600
+ 4 00755
+ } {
+ db close
+ set effective [format %.5o [expr $permissions & ~$umask]]
+ do_test journal3-1.2.$tn.1 {
+ catch { forcedelete test.db-journal }
+ file attributes test.db -permissions $permissions
+ file attributes test.db -permissions
+ } $permissions
+ do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0}
+ do_test journal3-1.2.$tn.3 {
+ sqlite3 db test.db
+ execsql {
+ BEGIN;
+ INSERT INTO tx DEFAULT VALUES;
+ }
+ file exists test.db-journal
+ } {1}
+ do_test journal3-1.2.$tn.4 {
+ file attr test.db-journal -perm
+ } $effective
+ do_execsql_test journal3-1.2.$tn.5 { ROLLBACK } {}
+ }
+
+
+}
+
+finish_test
diff --git a/test/jrnlmode.test b/test/jrnlmode.test
new file mode 100644
index 0000000..b1007c4
--- /dev/null
+++ b/test/jrnlmode.test
@@ -0,0 +1,558 @@
+# 2008 April 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of these tests is the journal mode pragma.
+#
+# $Id: jrnlmode.test,v 1.16 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!pager_pragmas} {
+ finish_test
+ return
+}
+
+if {[info exists TEMP_STORE] && $TEMP_STORE>=2} {
+ set temp_persist memory
+ set temp_delete memory
+ set temp_truncate memory
+ set temp_off off
+} else {
+ set temp_persist persist
+ set temp_delete delete
+ set temp_truncate truncate
+ set temp_off off
+}
+
+proc temp_journal_mode {newmode} {
+ if {[info exists ::TEMP_STORE] && $::TEMP_STORE>=2} {
+ if {$newmode ne "off" && $newmode ne "memory"} {
+ execsql {PRAGMA temp.journal_mode}
+ set newmode [db one {PRAGMA temp.journal_mode}]
+ }
+ }
+ set newmode
+}
+
+#----------------------------------------------------------------------
+# Test cases jrnlmode-1.X test the PRAGMA logic.
+#
+do_test jrnlmode-1.0 {
+ execsql {
+ PRAGMA journal_mode;
+ PRAGMA main.journal_mode;
+ PRAGMA temp.journal_mode;
+ }
+} [list delete delete [temp_journal_mode delete]]
+do_test jrnlmode-1.1 {
+ execsql {
+ PRAGMA journal_mode = persist;
+ }
+} {persist}
+do_test jrnlmode-1.2 {
+ execsql {
+ PRAGMA journal_mode;
+ PRAGMA main.journal_mode;
+ PRAGMA temp.journal_mode;
+ }
+} [list persist persist [temp_journal_mode persist]]
+do_test jrnlmode-1.4 {
+ execsql {
+ PRAGMA journal_mode = off;
+ }
+} {off}
+do_test jrnlmode-1.5 {
+ execsql {
+ PRAGMA journal_mode;
+ PRAGMA main.journal_mode;
+ PRAGMA temp.journal_mode;
+ }
+} [list off off [temp_journal_mode off]]
+do_test jrnlmode-1.6 {
+ execsql {
+ PRAGMA journal_mode = delete;
+ }
+} {delete}
+do_test jrnlmode-1.7 {
+ execsql {
+ PRAGMA journal_mode;
+ PRAGMA main.journal_mode;
+ PRAGMA Temp.journal_mode;
+ }
+} [list delete delete [temp_journal_mode delete]]
+do_test jrnlmode-1.7.1 {
+ execsql {
+ PRAGMA journal_mode = truncate;
+ }
+} {truncate}
+do_test jrnlmode-1.7.2 {
+ execsql {
+ PRAGMA journal_mode;
+ PRAGMA main.journal_mode;
+ PRAGMA temp.journal_mode;
+ }
+} [list truncate truncate [temp_journal_mode truncate]]
+do_test jrnlmode-1.8 {
+ execsql {
+ PRAGMA journal_mode = off;
+ PRAGMA journal_mode = invalid;
+ }
+} {off off}
+ifcapable attach {
+ do_test jrnlmode-1.9 {
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ ATTACH ':memory:' as aux1;
+ }
+ execsql {
+ PRAGMA main.journal_mode;
+ PRAGMA aux1.journal_mode;
+ }
+ } {persist memory}
+ do_test jrnlmode-1.10 {
+ execsql {
+ PRAGMA main.journal_mode = OFF;
+ }
+ execsql {
+ PRAGMA main.journal_mode;
+ PRAGMA temp.journal_mode;
+ PRAGMA aux1.journal_mode;
+ }
+ } [list off [temp_journal_mode persist] memory]
+ do_test jrnlmode-1.11 {
+ execsql {
+ PRAGMA journal_mode;
+ }
+ } {off}
+ do_test jrnlmode-1.12 {
+ execsql {
+ ATTACH ':memory:' as aux2;
+ }
+ execsql {
+ PRAGMA main.journal_mode;
+ PRAGMA aux1.journal_mode;
+ PRAGMA aux2.journal_mode;
+ }
+ } {off memory memory}
+ do_test jrnlmode-1.13 {
+ # The journal-mode used by in-memory databases cannot be changed.
+ execsql {
+ PRAGMA aux1.journal_mode = DELETE;
+ }
+ execsql {
+ PRAGMA main.journal_mode;
+ PRAGMA aux1.journal_mode;
+ PRAGMA aux2.journal_mode;
+ }
+ } {off memory memory}
+ do_test jrnlmode-1.14 {
+ execsql {
+ PRAGMA journal_mode = delete;
+ }
+ execsql {
+ PRAGMA main.journal_mode;
+ PRAGMA temp.journal_mode;
+ PRAGMA aux1.journal_mode;
+ PRAGMA aux2.journal_mode;
+ }
+ } [list delete [temp_journal_mode delete] memory memory]
+ do_test jrnlmode-1.15 {
+ execsql {
+ ATTACH ':memory:' as aux3;
+ }
+ execsql {
+ PRAGMA main.journal_mode;
+ PRAGMA temp.journal_mode;
+ PRAGMA aux1.journal_mode;
+ PRAGMA aux2.journal_mode;
+ PRAGMA aux3.journal_mode;
+ }
+ } [list delete [temp_journal_mode delete] memory memory memory]
+ do_test jrnlmode-1.16 {
+ execsql {
+ PRAGMA journal_mode = TRUNCATE;
+ }
+ execsql {
+ PRAGMA main.journal_mode;
+ PRAGMA temp.journal_mode;
+ PRAGMA aux1.journal_mode;
+ PRAGMA aux2.journal_mode;
+ PRAGMA aux3.journal_mode;
+ }
+ } [list truncate [temp_journal_mode truncate] memory memory memory]
+
+ do_test jrnlmode-1.99 {
+ execsql {
+ DETACH aux1;
+ DETACH aux2;
+ DETACH aux3;
+ }
+ } {}
+}
+
+ifcapable attach {
+ forcedelete test2.db
+ do_test jrnlmode-2.1 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ PRAGMA main.journal_mode = persist;
+ PRAGMA aux.journal_mode = persist;
+ CREATE TABLE abc(a, b, c);
+ CREATE TABLE aux.def(d, e, f);
+ }
+ execsql {
+ BEGIN;
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO def VALUES(4, 5, 6);
+ COMMIT;
+ }
+ list [file exists test.db-journal] [file exists test2.db-journal]
+ } {1 1}
+
+ do_test jrnlmode-2.2 {
+ file size test.db-journal
+ } {0}
+
+ do_test jrnlmode-2.3 {
+ execsql {
+ SELECT * FROM abc;
+ }
+ } {1 2 3}
+
+ do_test jrnlmode-2.4 {
+ file size test.db-journal
+ } {0}
+
+ do_test jrnlmode-2.5 {
+ execsql {
+ SELECT * FROM def;
+ }
+ } {4 5 6}
+
+#----------------------------------------------------------------------
+# Test caes jrnlmode-3.X verify that ticket #3127 has been fixed.
+#
+ db close
+ forcedelete test2.db
+ forcedelete test.db
+ sqlite3 db test.db
+
+ do_test jrnlmode-3.1 {
+ execsql {
+ CREATE TABLE x(n INTEGER);
+ ATTACH 'test2.db' AS a;
+ create table a.x ( n integer );
+ insert into a.x values(1);
+ insert into a.x values (2);
+ insert into a.x values (3);
+ insert into a.x values (4);
+ }
+ } {}
+
+ do_test jrnlmode-3.2 {
+ execsql { PRAGMA journal_mode=off; }
+ execsql {
+ BEGIN IMMEDIATE;
+ INSERT OR IGNORE INTO main.x SELECT * FROM a.x;
+ COMMIT;
+ }
+ } {}
+}
+
+ifcapable autovacuum&&pragma {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ do_test jrnlmode-4.1 {
+ execsql {
+ PRAGMA cache_size = 1;
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE abc(a, b, c);
+ }
+ execsql { PRAGMA page_count }
+ } {3}
+
+ do_test jrnlmode-4.2 {
+ execsql { PRAGMA journal_mode = off }
+ } {off}
+
+ do_test jrnlmode-4.3 {
+ execsql { INSERT INTO abc VALUES(1, 2, randomblob(2000)) }
+ } {}
+
+ # This will attempt to truncate the database file. Check that this
+ # is not a problem when journal_mode=off.
+ do_test jrnlmode-4.4 {
+ execsql { DELETE FROM abc }
+ } {}
+
+ integrity_check jrnlmode-4.5
+}
+
+#------------------------------------------------------------------------
+# The following test caes, jrnlmode-5.*, test the journal_size_limit
+# pragma.
+ifcapable pragma {
+ db close
+ forcedelete test.db test2.db test3.db
+ sqlite3 db test.db
+
+ do_test jrnlmode-5.1 {
+ execsql {pragma page_size=1024}
+ execsql {pragma journal_mode=persist}
+ } {persist}
+
+ do_test jrnlmode-5.2 {
+ execsql { PRAGMA journal_size_limit }
+ } {-1}
+ do_test jrnlmode-5.3 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ PRAGMA aux.journal_mode=persist;
+ PRAGMA aux.journal_size_limit;
+ }
+ } {persist -1}
+ do_test jrnlmode-5.4.1 {
+ execsql { PRAGMA aux.journal_size_limit = 999999999999 }
+ } {999999999999}
+ do_test jrnlmode-5.4.2 {
+ execsql { PRAGMA aux.journal_size_limit = 10240 }
+ } {10240}
+ do_test jrnlmode-5.5 {
+ execsql { PRAGMA main.journal_size_limit = 20480 }
+ } {20480}
+ do_test jrnlmode-5.6 {
+ execsql { PRAGMA journal_size_limit }
+ } {20480}
+ do_test jrnlmode-5.7 {
+ execsql { PRAGMA aux.journal_size_limit }
+ } {10240}
+
+ do_test jrnlmode-5.8 {
+ execsql {
+ ATTACH 'test3.db' AS aux2;
+ PRAGMA aux2.journal_mode=persist;
+ }
+ } {persist}
+
+ do_test jrnlmode-5.9 {
+ execsql {
+ CREATE TABLE main.t1(a, b, c);
+ CREATE TABLE aux.t2(a, b, c);
+ CREATE TABLE aux2.t3(a, b, c);
+ }
+ } {}
+ do_test jrnlmode-5.10 {
+ list \
+ [file exists test.db-journal] \
+ [file exists test2.db-journal] \
+ [file exists test3.db-journal]
+ } {1 1 1}
+ do_test jrnlmode-5.11 {
+ execsql {
+ BEGIN;
+ INSERT INTO t3 VALUES(randomblob(1000),randomblob(1000),randomblob(1000));
+ INSERT INTO t3
+ SELECT randomblob(1000),randomblob(1000),randomblob(1000) FROM t3;
+ INSERT INTO t3
+ SELECT randomblob(1000),randomblob(1000),randomblob(1000) FROM t3;
+ INSERT INTO t3
+ SELECT randomblob(1000),randomblob(1000),randomblob(1000) FROM t3;
+ INSERT INTO t3
+ SELECT randomblob(1000),randomblob(1000),randomblob(1000) FROM t3;
+ INSERT INTO t3
+ SELECT randomblob(1000),randomblob(1000),randomblob(1000) FROM t3;
+ INSERT INTO t2 SELECT * FROM t3;
+ INSERT INTO t1 SELECT * FROM t2;
+ COMMIT;
+ }
+ list \
+ [file exists test.db-journal] \
+ [file exists test2.db-journal] \
+ [file exists test3.db-journal] \
+ [file size test.db-journal] \
+ [file size test2.db-journal] \
+ [file size test3.db-journal]
+ } {1 1 1 0 0 0}
+
+ do_test jrnlmode-5.12 {
+ execsql {
+ BEGIN;
+ UPDATE t1 SET a = randomblob(1000);
+ }
+ expr {[file size test.db-journal]>30000}
+ } {1}
+ do_test jrnlmode-5.13 {
+ execsql COMMIT
+ file size test.db-journal
+ } {20480}
+
+ do_test jrnlmode-5.14 {
+ execsql {
+ BEGIN;
+ UPDATE t2 SET a = randomblob(1000);
+ }
+ expr {[file size test2.db-journal]>30000}
+ } {1}
+ do_test jrnlmode-5.15 {
+ execsql COMMIT
+ file size test2.db-journal
+ } {10240}
+
+ do_test jrnlmode-5.16 {
+ execsql {
+ BEGIN;
+ UPDATE t3 SET a = randomblob(1000);
+ }
+ set journalsize [file size test3.db-journal]
+ expr {$journalsize>30000}
+ } {1}
+ do_test jrnlmode-5.17 {
+ execsql COMMIT
+ set sz [file size test3.db-journal]
+ expr {$sz>=$journalsize}
+ } {1}
+
+ do_test jrnlmode-5.18 {
+ execsql {
+ PRAGMA journal_size_limit = -4;
+ BEGIN;
+ UPDATE t1 SET a = randomblob(1000);
+ }
+ set journalsize [file size test.db-journal]
+ expr {$journalsize>30000}
+ } {1}
+ do_test jrnlmode-5.19 {
+ execsql COMMIT
+ set sz [file size test.db-journal]
+ expr {$sz>=$journalsize}
+ } {1}
+
+ # Test a size-limit of 0.
+ #
+ do_test jrnlmode-5.20 {
+ execsql {
+ PRAGMA journal_size_limit = 0;
+ BEGIN;
+ UPDATE t1 SET a = randomblob(1000);
+ }
+ } {0}
+ do_test jrnlmode-5.21 {
+ expr {[file size test.db-journal] > 1024}
+ } {1}
+ do_test jrnlmode-5.22 {
+ execsql COMMIT
+ list [file exists test.db-journal] [file size test.db-journal]
+ } {1 0}
+}
+
+ifcapable pragma {
+ # These tests are not run as part of the "journaltest" permutation,
+ # as the test_journal.c layer is incompatible with in-memory journaling.
+ if {[permutation] ne "journaltest"} {
+
+ do_test jrnlmode-6.1 {
+ execsql {
+ PRAGMA journal_mode = truncate;
+ CREATE TABLE t4(a, b);
+ BEGIN;
+ INSERT INTO t4 VALUES(1, 2);
+ PRAGMA journal_mode = memory;
+ }
+ } {truncate truncate}
+ do_test jrnlmode-6.2 {
+ file exists test.db-journal
+ } {1}
+ do_test jrnlmode-6.3 {
+ execsql {
+ COMMIT;
+ SELECT * FROM t4;
+ }
+ } {1 2}
+ do_test jrnlmode-6.4 {
+ file exists test.db-journal
+ } {1}
+ do_test jrnlmode-6.5 {
+ execsql {
+ PRAGMA journal_mode = MEMORY;
+ BEGIN;
+ INSERT INTO t4 VALUES(3, 4);
+ }
+ file exists test.db-journal
+ } {0}
+ do_test jrnlmode-6.7 {
+ execsql {
+ COMMIT;
+ SELECT * FROM t4;
+ }
+ } {1 2 3 4}
+ do_test jrnlmode-6.8 {
+ file exists test.db-journal
+ } {0}
+ do_test jrnlmode-6.9 {
+ execsql {
+ PRAGMA journal_mode = DELETE;
+ BEGIN IMMEDIATE; INSERT INTO t4 VALUES(1,2); COMMIT;
+ }
+ file exists test.db-journal
+ } {0}
+ }
+}
+
+ifcapable pragma {
+ catch { db close }
+ do_test jrnlmode-7.1 {
+ foreach f [glob -nocomplain test.db*] { forcedelete $f }
+ sqlite3 db test.db
+ execsql {
+ PRAGMA journal_mode = memory;
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ PRAGMA user_version = 5;
+ PRAGMA user_version;
+ }
+ } {memory 5}
+ do_test jrnlmode-7.2 { file size test.db } {1024}
+}
+
+do_execsql_test jrnlmode-8.1 { PRAGMA locking_mode=EXCLUSIVE } {exclusive}
+do_execsql_test jrnlmode-8.2 { CREATE TABLE t1(x) } {}
+do_execsql_test jrnlmode-8.3 { INSERT INTO t1 VALUES(123) } {}
+do_execsql_test jrnlmode-8.4 { SELECT * FROM t1 } {123}
+do_execsql_test jrnlmode-8.5 { PRAGMA journal_mode=PERSIST } {persist}
+do_execsql_test jrnlmode-8.6 { PRAGMA journal_mode=DELETE } {delete}
+do_execsql_test jrnlmode-8.7 { PRAGMA journal_mode=TRUNCATE } {truncate}
+do_execsql_test jrnlmode-8.8 { PRAGMA journal_mode=DELETE } {delete}
+do_execsql_test jrnlmode-8.9 { CREATE TABLE t2(y) } {}
+do_execsql_test jrnlmode-8.10 { INSERT INTO t2 VALUES(456) } {}
+do_execsql_test jrnlmode-8.11 { SELECT * FROM t1, t2 } {123 456}
+do_execsql_test jrnlmode-8.12 { PRAGMA locking_mode=NORMAL } {normal}
+do_execsql_test jrnlmode-8.13 { PRAGMA journal_mode=PERSIST } {persist}
+do_execsql_test jrnlmode-8.14 { PRAGMA journal_mode=TRUNCATE } {truncate}
+do_execsql_test jrnlmode-8.15 { PRAGMA journal_mode=PERSIST } {persist}
+do_execsql_test jrnlmode-8.16 { PRAGMA journal_mode=DELETE } {delete}
+do_execsql_test jrnlmode-8.17 { PRAGMA journal_mode=TRUNCATE } {truncate}
+do_execsql_test jrnlmode-8.18 { PRAGMA locking_mode=EXCLUSIVE } {exclusive}
+do_execsql_test jrnlmode-8.19 { CREATE TABLE t3(z) } {}
+do_execsql_test jrnlmode-8.20 { BEGIN IMMEDIATE } {}
+do_execsql_test jrnlmode-8.21 { PRAGMA journal_mode=DELETE } {delete}
+do_execsql_test jrnlmode-8.22 { COMMIT } {}
+do_execsql_test jrnlmode-8.23 { PRAGMA journal_mode=DELETE } {delete}
+do_execsql_test jrnlmode-8.24 { PRAGMA journal_mode=TRUNCATE } {truncate}
+do_execsql_test jrnlmode-8.25 { PRAGMA locking_mode=NORMAL } {normal}
+do_execsql_test jrnlmode-8.26 { CREATE TABLE t4(w) } {}
+do_execsql_test jrnlmode-8.27 { BEGIN IMMEDIATE } {}
+do_execsql_test jrnlmode-8.28 { PRAGMA journal_mode=DELETE } {delete}
+do_execsql_test jrnlmode-8.29 { COMMIT } {}
+do_execsql_test jrnlmode-8.30 { PRAGMA journal_mode=DELETE } {delete}
+
+finish_test
diff --git a/test/jrnlmode2.test b/test/jrnlmode2.test
new file mode 100644
index 0000000..6ea87d7
--- /dev/null
+++ b/test/jrnlmode2.test
@@ -0,0 +1,123 @@
+# 2009 March 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!pager_pragmas} {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# The tests in this file check that the following two bugs (both now fixed)
+# do not reappear.
+#
+# jrnlmode2-1.*: Demonstrate bug #3745:
+#
+# In persistent journal mode, if:
+#
+# * There is a persistent journal in the file-system, AND
+# * there exists a connection with a shared lock on the db file,
+#
+# then a second connection cannot open a read-transaction on the database.
+# The reason is because while determining that the persistent-journal is
+# not a hot-journal, SQLite currently grabs an exclusive lock on the
+# database file. If this fails because another connection has a shared
+# lock, then SQLITE_BUSY is returned to the user.
+#
+# jrnlmode2-2.*: Demonstrate bug #3751:
+#
+# If a connection is opened in SQLITE_OPEN_READONLY mode, the underlying
+# unix file descriptor on the database file is opened in O_RDONLY mode.
+#
+# When SQLite queries the database file for the schema in order to compile
+# the SELECT statement, it sees the empty journal in the file system, it
+# attempts to obtain an exclusive lock on the database file (this is a
+# bug). The attempt to obtain an exclusive (write) lock on a read-only file
+# fails at the OS level. Under unix, fcntl() reports an EBADF - "Bad file
+# descriptor" - error.
+#
+
+do_test jrnlmode2-1.1 {
+ execsql {
+ PRAGMA journal_mode = persist;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+} {persist}
+
+do_test jrnlmode2-1.2 {
+ file exists test.db-journal
+} {1}
+
+do_test jrnlmode2-1.3 {
+ sqlite3 db2 test.db
+ execsql { SELECT * FROM t1 } db2
+} {1 2}
+
+do_test jrnlmode2-1.4 {
+ execsql {
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ execsql { PRAGMA lock_status }
+} {main shared temp closed}
+
+do_test jrnlmode2-1.5 {
+ file exists test.db-journal
+} {1}
+
+do_test jrnlmode2-1.6 {
+ catchsql { SELECT * FROM t1 } db2
+} {0 {1 2 3 4}}
+
+do_test jrnlmode2-1.7 {
+ execsql { COMMIT }
+ catchsql { SELECT * FROM t1 } db2
+} {0 {1 2 3 4}}
+
+
+
+do_test jrnlmode2-2.1 {
+ db2 close
+ execsql { PRAGMA journal_mode = truncate }
+ execsql { INSERT INTO t1 VALUES(5, 6) }
+} {}
+
+do_test jrnlmode2-2.2 {
+ file exists test.db-journal
+} {1}
+
+do_test jrnlmode2-2.3 {
+ file size test.db-journal
+} {0}
+
+do_test jrnlmode2-2.4 {
+ sqlite3 db2 test.db -readonly 1
+ catchsql { SELECT * FROM t1 } db2
+} {0 {1 2 3 4 5 6}}
+
+do_test jrnlmode2-2.5 {
+ db close
+ delete_file test.db-journal
+} {}
+do_test jrnlmode2-2.6 {
+ sqlite3 db2 test.db -readonly 1
+ catchsql { SELECT * FROM t1 } db2
+} {0 {1 2 3 4 5 6}}
+
+catch { db2 close }
+finish_test
diff --git a/test/jrnlmode3.test b/test/jrnlmode3.test
new file mode 100644
index 0000000..43da657
--- /dev/null
+++ b/test/jrnlmode3.test
@@ -0,0 +1,149 @@
+# 2009 April 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test cases inspired by ticket #3811. Tests to make sure that
+# the journal_mode can only be changed at appropriate times and that
+# all reported changes are effective.
+#
+# $Id: jrnlmode3.test,v 1.5 2009/04/20 17:43:03 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!pager_pragmas} {
+ finish_test
+ return
+}
+
+#
+# Verify that journal_mode=OFF works as long as it occurs before the first
+# transaction, even if locking_mode=EXCLUSIVE is enabled. The behavior if
+# journal_mode is changed after the first transaction is undefined and hence
+# untested.
+#
+do_test jrnlmode3-1.1 {
+ db eval {
+ PRAGMA journal_mode=OFF;
+ PRAGMA locking_mode=EXCLUSIVE;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ SELECT * FROM t1;
+ }
+} {off exclusive 1}
+do_test jrnlmode3-1.2 {
+ db eval {
+ BEGIN;
+ INSERT INTO t1 VALUES(2);
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {1}
+
+db close
+forcedelete test.db test.db-journal
+sqlite3 db test.db
+
+do_test jrnlmode3-2.1 {
+ db eval {
+ PRAGMA locking_mode=EXCLUSIVE;
+ PRAGMA journal_mode=OFF;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ SELECT * FROM t1;
+ }
+} {exclusive off 1}
+do_test jrnlmode3-2.2 {
+ db eval {
+ BEGIN;
+ INSERT INTO t1 VALUES(2);
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {1}
+
+# Test cases to verify that we can move from any journal_mode
+# to any other, as long as we are not in a transaction. Verify
+# that we cannot change journal_mode while a transaction is active.
+#
+set all_journal_modes {delete persist truncate memory off}
+set cnt 0
+foreach fromjmode $all_journal_modes {
+ foreach tojmode $all_journal_modes {
+
+ # Skip the no-change cases
+ if {$fromjmode==$tojmode} continue
+ incr cnt
+
+ # Start with a fresh database connection an empty database file.
+ #
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+
+ # Initialize the journal mode.
+ #
+ do_test jrnlmode3-3.$cnt.1-($fromjmode-to-$tojmode) {
+ db eval "PRAGMA journal_mode = $fromjmode;"
+ } $fromjmode
+
+ # Verify that the initial journal mode takes.
+ #
+ do_test jrnlmode3-3.$cnt.2 {
+ db eval {PRAGMA main.journal_mode}
+ } $fromjmode
+
+ # Start a transaction and try to change the journal mode within
+ # the transaction. This should fail.
+ #
+ do_test jrnlmode3-3.$cnt.3 {
+ db eval {
+ CREATE TABLE t1(x);
+ BEGIN;
+ INSERT INTO t1 VALUES($cnt);
+ }
+ db eval "PRAGMA journal_mode=$tojmode"
+ } $fromjmode
+
+ # Rollback the transaction.
+ #
+ do_test jrnlmode3-3.$cnt.4 {
+ db eval {
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+ } {}
+
+ # Now change the journal mode again. This time the new mode
+ # should take.
+ #
+ do_test jrnlmode3-3.$cnt.5 {
+ db eval "PRAGMA journal_mode=$tojmode"
+ } $tojmode
+
+ # Do a the transaction. Verify that the rollback occurred
+ # if journal_mode!=OFF.
+ #
+ do_test jrnlmode3-3.$cnt.6 {
+ db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ BEGIN;
+ INSERT INTO t1 VALUES(1);
+ }
+ db eval ROLLBACK
+ db eval {
+ SELECT * FROM t1;
+ }
+ } {}
+ }
+}
+
+finish_test
diff --git a/test/keyword1.test b/test/keyword1.test
new file mode 100644
index 0000000..9483120
--- /dev/null
+++ b/test/keyword1.test
@@ -0,0 +1,118 @@
+# 2009 January 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Verify that certain keywords can be used as identifiers.
+#
+# $Id: keyword1.test,v 1.1 2009/01/29 19:27:47 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+db eval {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+}
+
+set kwlist {
+ abort
+ after
+ analyze
+ asc
+ attach
+ before
+ begin
+ by
+ cascade
+ cast
+ column
+ conflict
+ current_date
+ current_time
+ current_timestamp
+ database
+ deferred
+ desc
+ detach
+ end
+ each
+ exclusive
+ explain
+ fail
+ for
+ glob
+ if
+ ignore
+ immediate
+ initially
+ instead
+ key
+ like
+ match
+ of
+ offset
+ plan
+ pragma
+ query
+ raise
+ regexp
+ reindex
+ release
+ rename
+ replace
+ restrict
+ rollback
+ row
+ savepoint
+ temp
+ temporary
+ trigger
+ vacuum
+ view
+ virtual
+};
+set exprkw {
+ cast
+ current_date
+ current_time
+ current_timestamp
+ raise
+}
+foreach kw $kwlist {
+ do_test keyword1-$kw.1 {
+ if {$kw=="if"} {
+ db eval "CREATE TABLE \"$kw\"($kw $kw)"
+ } else {
+ db eval "CREATE TABLE ${kw}($kw $kw)"
+ }
+ db eval "INSERT INTO $kw VALUES(99)"
+ db eval "INSERT INTO $kw SELECT a FROM t1"
+ if {[lsearch $exprkw $kw]<0} {
+ db eval "SELECT * FROM $kw ORDER BY $kw ASC"
+ } else {
+ db eval "SELECT * FROM $kw ORDER BY \"$kw\" ASC"
+ }
+ } {1 2 3 99}
+ do_test keyword1-$kw.2 {
+ if {$kw=="if"} {
+ db eval "DROP TABLE \"$kw\""
+ db eval "CREATE INDEX \"$kw\" ON t1(a)"
+ } else {
+ db eval "DROP TABLE $kw"
+ db eval "CREATE INDEX $kw ON t1(a)"
+ }
+ db eval "SELECT b FROM t1 INDEXED BY $kw WHERE a=2"
+ } {two}
+}
+
+finish_test
diff --git a/test/lastinsert.test b/test/lastinsert.test
new file mode 100644
index 0000000..adeb798
--- /dev/null
+++ b/test/lastinsert.test
@@ -0,0 +1,366 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests to make sure that value returned by last_insert_rowid() (LIRID)
+# is updated properly, especially inside triggers
+#
+# Note 1: insert into table is now the only statement which changes LIRID
+# Note 2: upon entry into before or instead of triggers,
+# LIRID is unchanged (rather than -1)
+# Note 3: LIRID is changed within the context of a trigger,
+# but is restored once the trigger exits
+# Note 4: LIRID is not changed by an insert into a view (since everything
+# is done within instead of trigger context)
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# ----------------------------------------------------------------------------
+# 1.x - basic tests (no triggers)
+
+# LIRID changed properly after an insert into a table
+do_test lastinsert-1.1 {
+ catchsql {
+ create table t1 (k integer primary key);
+ insert into t1 values (1);
+ insert into t1 values (NULL);
+ insert into t1 values (NULL);
+ select last_insert_rowid();
+ }
+} {0 3}
+
+# LIRID unchanged after an update on a table
+do_test lastinsert-1.2 {
+ catchsql {
+ update t1 set k=4 where k=2;
+ select last_insert_rowid();
+ }
+} {0 3}
+
+# LIRID unchanged after a delete from a table
+do_test lastinsert-1.3 {
+ catchsql {
+ delete from t1 where k=4;
+ select last_insert_rowid();
+ }
+} {0 3}
+
+# LIRID unchanged after create table/view statements
+do_test lastinsert-1.4.1 {
+ catchsql {
+ create table t2 (k integer primary key, val1, val2, val3);
+ select last_insert_rowid();
+ }
+} {0 3}
+ifcapable view {
+do_test lastinsert-1.4.2 {
+ catchsql {
+ create view v as select * from t1;
+ select last_insert_rowid();
+ }
+} {0 3}
+} ;# ifcapable view
+
+# All remaining tests involve triggers. Skip them if triggers are not
+# supported in this build.
+#
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# ----------------------------------------------------------------------------
+# 2.x - tests with after insert trigger
+
+# LIRID changed properly after an insert into table containing an after trigger
+do_test lastinsert-2.1 {
+ catchsql {
+ delete from t2;
+ create trigger r1 after insert on t1 for each row begin
+ insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL);
+ update t2 set k=k+10, val2=100+last_insert_rowid();
+ update t2 set val3=1000+last_insert_rowid();
+ end;
+ insert into t1 values (13);
+ select last_insert_rowid();
+ }
+} {0 13}
+
+# LIRID equals NEW.k upon entry into after insert trigger
+do_test lastinsert-2.2 {
+ catchsql {
+ select val1 from t2;
+ }
+} {0 13}
+
+# LIRID changed properly by insert within context of after insert trigger
+do_test lastinsert-2.3 {
+ catchsql {
+ select val2 from t2;
+ }
+} {0 126}
+
+# LIRID unchanged by update within context of after insert trigger
+do_test lastinsert-2.4 {
+ catchsql {
+ select val3 from t2;
+ }
+} {0 1026}
+
+# ----------------------------------------------------------------------------
+# 3.x - tests with after update trigger
+
+# LIRID not changed after an update onto a table containing an after trigger
+do_test lastinsert-3.1 {
+ catchsql {
+ delete from t2;
+ drop trigger r1;
+ create trigger r1 after update on t1 for each row begin
+ insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL);
+ update t2 set k=k+10, val2=100+last_insert_rowid();
+ update t2 set val3=1000+last_insert_rowid();
+ end;
+ update t1 set k=14 where k=3;
+ select last_insert_rowid();
+ }
+} {0 13}
+
+# LIRID unchanged upon entry into after update trigger
+do_test lastinsert-3.2 {
+ catchsql {
+ select val1 from t2;
+ }
+} {0 13}
+
+# LIRID changed properly by insert within context of after update trigger
+do_test lastinsert-3.3 {
+ catchsql {
+ select val2 from t2;
+ }
+} {0 128}
+
+# LIRID unchanged by update within context of after update trigger
+do_test lastinsert-3.4 {
+ catchsql {
+ select val3 from t2;
+ }
+} {0 1028}
+
+# ----------------------------------------------------------------------------
+# 4.x - tests with instead of insert trigger
+# These may not be run if either views or triggers were disabled at
+# compile-time
+
+ifcapable {view && trigger} {
+# LIRID not changed after an insert into view containing an instead of trigger
+do_test lastinsert-4.1 {
+ catchsql {
+ delete from t2;
+ drop trigger r1;
+ create trigger r1 instead of insert on v for each row begin
+ insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL);
+ update t2 set k=k+10, val2=100+last_insert_rowid();
+ update t2 set val3=1000+last_insert_rowid();
+ end;
+ insert into v values (15);
+ select last_insert_rowid();
+ }
+} {0 13}
+
+# LIRID unchanged upon entry into instead of trigger
+do_test lastinsert-4.2 {
+ catchsql {
+ select val1 from t2;
+ }
+} {0 13}
+
+# LIRID changed properly by insert within context of instead of trigger
+do_test lastinsert-4.3 {
+ catchsql {
+ select val2 from t2;
+ }
+} {0 130}
+
+# LIRID unchanged by update within context of instead of trigger
+do_test lastinsert-4.4 {
+ catchsql {
+ select val3 from t2;
+ }
+} {0 1030}
+} ;# ifcapable (view && trigger)
+
+# ----------------------------------------------------------------------------
+# 5.x - tests with before delete trigger
+
+# LIRID not changed after a delete on a table containing a before trigger
+do_test lastinsert-5.1 {
+ catchsql {
+ drop trigger r1; -- This was not created if views are disabled.
+ }
+ catchsql {
+ delete from t2;
+ create trigger r1 before delete on t1 for each row begin
+ insert into t2 values (77, last_insert_rowid(), NULL, NULL);
+ update t2 set k=k+10, val2=100+last_insert_rowid();
+ update t2 set val3=1000+last_insert_rowid();
+ end;
+ delete from t1 where k=1;
+ select last_insert_rowid();
+ }
+} {0 13}
+
+# LIRID unchanged upon entry into delete trigger
+do_test lastinsert-5.2 {
+ catchsql {
+ select val1 from t2;
+ }
+} {0 13}
+
+# LIRID changed properly by insert within context of delete trigger
+do_test lastinsert-5.3 {
+ catchsql {
+ select val2 from t2;
+ }
+} {0 177}
+
+# LIRID unchanged by update within context of delete trigger
+do_test lastinsert-5.4 {
+ catchsql {
+ select val3 from t2;
+ }
+} {0 1077}
+
+# ----------------------------------------------------------------------------
+# 6.x - tests with instead of update trigger
+# These tests may not run if either views or triggers are disabled.
+
+ifcapable {view && trigger} {
+# LIRID not changed after an update on a view containing an instead of trigger
+do_test lastinsert-6.1 {
+ catchsql {
+ delete from t2;
+ drop trigger r1;
+ create trigger r1 instead of update on v for each row begin
+ insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL);
+ update t2 set k=k+10, val2=100+last_insert_rowid();
+ update t2 set val3=1000+last_insert_rowid();
+ end;
+ update v set k=16 where k=14;
+ select last_insert_rowid();
+ }
+} {0 13}
+
+# LIRID unchanged upon entry into instead of trigger
+do_test lastinsert-6.2 {
+ catchsql {
+ select val1 from t2;
+ }
+} {0 13}
+
+# LIRID changed properly by insert within context of instead of trigger
+do_test lastinsert-6.3 {
+ catchsql {
+ select val2 from t2;
+ }
+} {0 132}
+
+# LIRID unchanged by update within context of instead of trigger
+do_test lastinsert-6.4 {
+ catchsql {
+ select val3 from t2;
+ }
+} {0 1032}
+} ;# ifcapable (view && trigger)
+
+# ----------------------------------------------------------------------------
+# 7.x - complex tests with temporary tables and nested instead of triggers
+# These do not run if views or triggers are disabled.
+
+ifcapable {trigger && view && tempdb} {
+do_test lastinsert-7.1 {
+ catchsql {
+ drop table t1; drop table t2; drop trigger r1;
+ create temp table t1 (k integer primary key);
+ create temp table t2 (k integer primary key);
+ create temp view v1 as select * from t1;
+ create temp view v2 as select * from t2;
+ create temp table rid (k integer primary key, rin, rout);
+ insert into rid values (1, NULL, NULL);
+ insert into rid values (2, NULL, NULL);
+ create temp trigger r1 instead of insert on v1 for each row begin
+ update rid set rin=last_insert_rowid() where k=1;
+ insert into t1 values (100+NEW.k);
+ insert into v2 values (100+last_insert_rowid());
+ update rid set rout=last_insert_rowid() where k=1;
+ end;
+ create temp trigger r2 instead of insert on v2 for each row begin
+ update rid set rin=last_insert_rowid() where k=2;
+ insert into t2 values (1000+NEW.k);
+ update rid set rout=last_insert_rowid() where k=2;
+ end;
+ insert into t1 values (77);
+ select last_insert_rowid();
+ }
+} {0 77}
+
+do_test lastinsert-7.2 {
+ catchsql {
+ insert into v1 values (5);
+ select last_insert_rowid();
+ }
+} {0 77}
+
+do_test lastinsert-7.3 {
+ catchsql {
+ select rin from rid where k=1;
+ }
+} {0 77}
+
+do_test lastinsert-7.4 {
+ catchsql {
+ select rout from rid where k=1;
+ }
+} {0 105}
+
+do_test lastinsert-7.5 {
+ catchsql {
+ select rin from rid where k=2;
+ }
+} {0 105}
+
+do_test lastinsert-7.6 {
+ catchsql {
+ select rout from rid where k=2;
+ }
+} {0 1205}
+
+do_test lastinsert-8.1 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y);
+ CREATE TABLE t3(a, b);
+ CREATE TRIGGER after_t2 AFTER INSERT ON t2 BEGIN
+ INSERT INTO t3 VALUES(new.x, new.y);
+ END;
+ INSERT INTO t2 VALUES(5000000000, 1);
+ SELECT last_insert_rowid();
+ }
+} 5000000000
+
+do_test lastinsert-9.1 {
+ db eval {INSERT INTO t2 VALUES(123456789012345,0)}
+ db last_insert_rowid
+} {123456789012345}
+
+
+} ;# ifcapable (view && trigger)
+
+finish_test
diff --git a/test/laststmtchanges.test b/test/laststmtchanges.test
new file mode 100644
index 0000000..ea4c389
--- /dev/null
+++ b/test/laststmtchanges.test
@@ -0,0 +1,331 @@
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests to make sure that values returned by changes() and total_changes()
+# are updated properly, especially inside triggers
+#
+# Note 1: changes() remains constant within a statement and only updates
+# once the statement is finished (triggers count as part of
+# statement).
+# Note 2: changes() is changed within the context of a trigger much like
+# last_insert_rowid() (see lastinsert.test), but is restored once
+# the trigger exits.
+# Note 3: changes() is not changed by a change to a view (since everything
+# is done within instead of trigger context).
+#
+# $Id: laststmtchanges.test,v 1.7 2008/10/27 13:59:34 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# ----------------------------------------------------------------------------
+# 1.x - basic tests (no triggers)
+
+# changes() set properly after insert
+do_test laststmtchanges-1.1 {
+ catchsql {
+ create table t0 (x);
+ insert into t0 values (1);
+ insert into t0 values (1);
+ insert into t0 values (2);
+ insert into t0 values (2);
+ insert into t0 values (1);
+ insert into t0 values (1);
+ insert into t0 values (1);
+ insert into t0 values (2);
+ select changes(), total_changes();
+ }
+} {0 {1 8}}
+
+# changes() set properly after update
+do_test laststmtchanges-1.2 {
+ catchsql {
+ update t0 set x=3 where x=1;
+ select changes(), total_changes();
+ }
+} {0 {5 13}}
+
+# There was some goofy change-counting logic in sqlite3_exec() that
+# appears to have been left over from SQLite version 2. This test
+# makes sure it has been removed.
+#
+do_test laststmtchanges-1.2.1 {
+ db cache flush
+ sqlite3_exec_printf db {update t0 set x=4 where x=3; select 1;} {}
+ execsql {select changes()}
+} {5}
+
+# changes() unchanged within an update statement
+do_test laststmtchanges-1.3 {
+ execsql {update t0 set x=3 where x=4}
+ catchsql {
+ update t0 set x=x+changes() where x=3;
+ select count() from t0 where x=8;
+ }
+} {0 5}
+
+# changes() set properly after update on table where no rows changed
+do_test laststmtchanges-1.4 {
+ catchsql {
+ update t0 set x=77 where x=88;
+ select changes();
+ }
+} {0 0}
+
+# changes() set properly after delete from table
+do_test laststmtchanges-1.5 {
+ catchsql {
+ delete from t0 where x=2;
+ select changes();
+ }
+} {0 3}
+
+# All remaining tests involve triggers. Skip them if triggers are not
+# supported in this build.
+#
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+
+# ----------------------------------------------------------------------------
+# 2.x - tests with after insert trigger
+
+# changes() changed properly after insert into table containing after trigger
+do_test laststmtchanges-2.1 {
+ set ::tc [db total_changes]
+ catchsql {
+ create table t1 (k integer primary key);
+ create table t2 (k integer primary key, v1, v2);
+ create trigger r1 after insert on t1 for each row begin
+ insert into t2 values (NULL, changes(), NULL);
+ update t0 set x=x;
+ update t2 set v2=changes();
+ end;
+ insert into t1 values (77);
+ select changes();
+ }
+} {0 1}
+
+# changes() unchanged upon entry into after insert trigger
+do_test laststmtchanges-2.2 {
+ catchsql {
+ select v1 from t2;
+ }
+} {0 3}
+
+# changes() changed properly by update within context of after insert trigger
+do_test laststmtchanges-2.3 {
+ catchsql {
+ select v2 from t2;
+ }
+} {0 5}
+
+# Total changes caused by firing the trigger above:
+#
+# 1 from "insert into t1 values(77)" +
+# 1 from "insert into t2 values (NULL, changes(), NULL);" +
+# 5 from "update t0 set x=x;" +
+# 1 from "update t2 set v2=changes();"
+#
+do_test laststmtchanges-2.4 {
+ expr [db total_changes] - $::tc
+} {8}
+
+# ----------------------------------------------------------------------------
+# 3.x - tests with after update trigger
+
+# changes() changed properly after update into table containing after trigger
+do_test laststmtchanges-3.1 {
+ catchsql {
+ drop trigger r1;
+ delete from t2; delete from t2;
+ create trigger r1 after update on t1 for each row begin
+ insert into t2 values (NULL, changes(), NULL);
+ delete from t0 where oid=1 or oid=2;
+ update t2 set v2=changes();
+ end;
+ update t1 set k=k;
+ select changes();
+ }
+} {0 1}
+
+# changes() unchanged upon entry into after update trigger
+do_test laststmtchanges-3.2 {
+ catchsql {
+ select v1 from t2;
+ }
+} {0 0}
+
+# changes() changed properly by delete within context of after update trigger
+do_test laststmtchanges-3.3 {
+ catchsql {
+ select v2 from t2;
+ }
+} {0 2}
+
+# ----------------------------------------------------------------------------
+# 4.x - tests with before delete trigger
+
+# changes() changed properly on delete from table containing before trigger
+do_test laststmtchanges-4.1 {
+ catchsql {
+ drop trigger r1;
+ delete from t2; delete from t2;
+ create trigger r1 before delete on t1 for each row begin
+ insert into t2 values (NULL, changes(), NULL);
+ insert into t0 values (5);
+ update t2 set v2=changes();
+ end;
+ delete from t1;
+ select changes();
+ }
+} {0 1}
+
+# changes() unchanged upon entry into before delete trigger
+do_test laststmtchanges-4.2 {
+ catchsql {
+ select v1 from t2;
+ }
+} {0 0}
+
+# changes() changed properly by insert within context of before delete trigger
+do_test laststmtchanges-4.3 {
+ catchsql {
+ select v2 from t2;
+ }
+} {0 1}
+
+# ----------------------------------------------------------------------------
+# 5.x - complex tests with temporary tables and nested instead of triggers
+# These tests cannot run if the library does not have view support enabled.
+
+ifcapable view&&tempdb {
+
+do_test laststmtchanges-5.1 {
+ catchsql {
+ drop table t0; drop table t1; drop table t2;
+ create temp table t0(x);
+ create temp table t1 (k integer primary key);
+ create temp table t2 (k integer primary key);
+ create temp view v1 as select * from t1;
+ create temp view v2 as select * from t2;
+ create temp table n1 (k integer primary key, n);
+ create temp table n2 (k integer primary key, n);
+ insert into t0 values (1);
+ insert into t0 values (2);
+ insert into t0 values (1);
+ insert into t0 values (1);
+ insert into t0 values (1);
+ insert into t0 values (2);
+ insert into t0 values (2);
+ insert into t0 values (1);
+ create temp trigger r1 instead of insert on v1 for each row begin
+ insert into n1 values (NULL, changes());
+ update t0 set x=x*10 where x=1;
+ insert into n1 values (NULL, changes());
+ insert into t1 values (NEW.k);
+ insert into n1 values (NULL, changes());
+ update t0 set x=x*10 where x=0;
+ insert into v2 values (100+NEW.k);
+ insert into n1 values (NULL, changes());
+ end;
+ create temp trigger r2 instead of insert on v2 for each row begin
+ insert into n2 values (NULL, changes());
+ insert into t2 values (1000+NEW.k);
+ insert into n2 values (NULL, changes());
+ update t0 set x=x*100 where x=0;
+ insert into n2 values (NULL, changes());
+ delete from t0 where x=2;
+ insert into n2 values (NULL, changes());
+ end;
+ insert into t1 values (77);
+ select changes();
+ }
+} {0 1}
+
+do_test laststmtchanges-5.2 {
+ catchsql {
+ delete from t1 where k=88;
+ select changes();
+ }
+} {0 0}
+
+do_test laststmtchanges-5.3 {
+ catchsql {
+ insert into v1 values (5);
+ select changes();
+ }
+} {0 0}
+
+do_test laststmtchanges-5.4 {
+ catchsql {
+ select n from n1;
+ }
+} {0 {0 5 1 0}}
+
+do_test laststmtchanges-5.5 {
+ catchsql {
+ select n from n2;
+ }
+} {0 {0 1 0 3}}
+
+} ;# ifcapable view
+
+
+# ----------------------------------------------------------------------------
+# 6.x - Test "DELETE FROM <table>" in the absence of triggers
+#
+do_test laststmtchanges-6.1 {
+ execsql {
+ CREATE TABLE t3(a, b, c);
+ INSERT INTO t3 VALUES(1, 2, 3);
+ INSERT INTO t3 VALUES(4, 5, 6);
+ }
+} {}
+do_test laststmtchanges-6.2 {
+ execsql {
+ BEGIN;
+ DELETE FROM t3;
+ SELECT changes();
+ }
+} {2}
+do_test laststmtchanges-6.3 {
+ execsql {
+ ROLLBACK;
+ BEGIN;
+ DELETE FROM t3 WHERE a IS NOT NULL;
+ SELECT changes();
+ }
+} {2}
+do_test laststmtchanges-6.4 {
+ execsql {
+ ROLLBACK;
+ CREATE INDEX t3_i1 ON t3(a);
+ BEGIN;
+ DELETE FROM t3;
+ SELECT changes();
+ }
+} {2}
+do_test laststmtchanges-6.5 {
+ execsql { ROLLBACK }
+ set nTotalChange [execsql {SELECT total_changes()}]
+ expr 0
+} {0}
+do_test laststmtchanges-6.6 {
+ execsql {
+ SELECT total_changes();
+ DELETE FROM t3;
+ SELECT total_changes();
+ }
+} [list $nTotalChange [expr $nTotalChange+2]]
+
+finish_test
diff --git a/test/like.test b/test/like.test
new file mode 100644
index 0000000..767efd5
--- /dev/null
+++ b/test/like.test
@@ -0,0 +1,876 @@
+# 2005 August 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the LIKE and GLOB operators and
+# in particular the optimizations that occur to help those operators
+# run faster.
+#
+# $Id: like.test,v 1.13 2009/06/07 23:45:11 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create some sample data to work with.
+#
+do_test like-1.0 {
+ execsql {
+ CREATE TABLE t1(x TEXT);
+ }
+ foreach str {
+ a
+ ab
+ abc
+ abcd
+
+ acd
+ abd
+ bc
+ bcd
+
+ xyz
+ ABC
+ CDE
+ {ABC abc xyz}
+ } {
+ db eval {INSERT INTO t1 VALUES(:str)}
+ }
+ execsql {
+ SELECT count(*) FROM t1;
+ }
+} {12}
+
+# Test that both case sensitive and insensitive version of LIKE work.
+#
+do_test like-1.1 {
+ execsql {
+ SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
+ }
+} {ABC abc}
+do_test like-1.2 {
+ execsql {
+ SELECT x FROM t1 WHERE x GLOB 'abc' ORDER BY 1;
+ }
+} {abc}
+do_test like-1.3 {
+ execsql {
+ SELECT x FROM t1 WHERE x LIKE 'ABC' ORDER BY 1;
+ }
+} {ABC abc}
+do_test like-1.4 {
+ execsql {
+ SELECT x FROM t1 WHERE x LIKE 'aBc' ORDER BY 1;
+ }
+} {ABC abc}
+do_test like-1.5.1 {
+ # Use sqlite3_exec() to verify fix for ticket [25ee81271091] 2011-06-26
+ sqlite3_exec db {PRAGMA case_sensitive_like=on}
+} {0 {}}
+do_test like-1.5.2 {
+ execsql {
+ SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
+ }
+} {abc}
+do_test like-1.5.3 {
+ execsql {
+ PRAGMA case_sensitive_like; -- no argument; does not change setting
+ SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
+ }
+} {abc}
+do_test like-1.6 {
+ execsql {
+ SELECT x FROM t1 WHERE x GLOB 'abc' ORDER BY 1;
+ }
+} {abc}
+do_test like-1.7 {
+ execsql {
+ SELECT x FROM t1 WHERE x LIKE 'ABC' ORDER BY 1;
+ }
+} {ABC}
+do_test like-1.8 {
+ execsql {
+ SELECT x FROM t1 WHERE x LIKE 'aBc' ORDER BY 1;
+ }
+} {}
+do_test like-1.9 {
+ execsql {
+ PRAGMA case_sensitive_like=off;
+ SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
+ }
+} {ABC abc}
+do_test like-1.10 {
+ execsql {
+ PRAGMA case_sensitive_like; -- No argument, does not change setting.
+ SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
+ }
+} {ABC abc}
+
+# Tests of the REGEXP operator
+#
+do_test like-2.1 {
+ proc test_regexp {a b} {
+ return [regexp $a $b]
+ }
+ db function regexp -argcount 2 test_regexp
+ execsql {
+ SELECT x FROM t1 WHERE x REGEXP 'abc' ORDER BY 1;
+ }
+} {{ABC abc xyz} abc abcd}
+do_test like-2.2 {
+ execsql {
+ SELECT x FROM t1 WHERE x REGEXP '^abc' ORDER BY 1;
+ }
+} {abc abcd}
+
+# Tests of the MATCH operator
+#
+do_test like-2.3 {
+ proc test_match {a b} {
+ return [string match $a $b]
+ }
+ db function match -argcount 2 test_match
+ execsql {
+ SELECT x FROM t1 WHERE x MATCH '*abc*' ORDER BY 1;
+ }
+} {{ABC abc xyz} abc abcd}
+do_test like-2.4 {
+ execsql {
+ SELECT x FROM t1 WHERE x MATCH 'abc*' ORDER BY 1;
+ }
+} {abc abcd}
+
+# For the remaining tests, we need to have the like optimizations
+# enabled.
+#
+ifcapable !like_opt {
+ finish_test
+ return
+}
+
+# This procedure executes the SQL. Then it appends to the result the
+# "sort" or "nosort" keyword (as in the cksort procedure above) then
+# it appends the ::sqlite_query_plan variable.
+#
+proc queryplan {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ if {$::sqlite_sort_count} {set x sort} {set x nosort}
+ lappend data $x
+ return [concat $data $::sqlite_query_plan]
+}
+
+# Perform tests on the like optimization.
+#
+# With no index on t1.x and with case sensitivity turned off, no optimization
+# is performed.
+#
+do_test like-3.1 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
+ }
+} {ABC {ABC abc xyz} abc abcd sort t1 {}}
+do_test like-3.2 {
+ set sqlite_like_count
+} {12}
+
+# With an index on t1.x and case sensitivity on, optimize completely.
+#
+do_test like-3.3 {
+ set sqlite_like_count 0
+ execsql {
+ PRAGMA case_sensitive_like=on;
+ CREATE INDEX i1 ON t1(x);
+ }
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
+ }
+} {abc abcd nosort {} i1}
+do_test like-3.4 {
+ set sqlite_like_count
+} 0
+
+# The LIKE optimization still works when the RHS is a string with no
+# wildcard. Ticket [e090183531fc2747]
+#
+do_test like-3.4.2 {
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'a' ORDER BY 1;
+ }
+} {a nosort {} i1}
+do_test like-3.4.3 {
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'ab' ORDER BY 1;
+ }
+} {ab nosort {} i1}
+do_test like-3.4.4 {
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'abcd' ORDER BY 1;
+ }
+} {abcd nosort {} i1}
+do_test like-3.4.5 {
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'abcde' ORDER BY 1;
+ }
+} {nosort {} i1}
+
+
+# Partial optimization when the pattern does not end in '%'
+#
+do_test like-3.5 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'a_c' ORDER BY 1;
+ }
+} {abc nosort {} i1}
+do_test like-3.6 {
+ set sqlite_like_count
+} 6
+do_test like-3.7 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'ab%d' ORDER BY 1;
+ }
+} {abcd abd nosort {} i1}
+do_test like-3.8 {
+ set sqlite_like_count
+} 4
+do_test like-3.9 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'a_c%' ORDER BY 1;
+ }
+} {abc abcd nosort {} i1}
+do_test like-3.10 {
+ set sqlite_like_count
+} 6
+
+# No optimization when the pattern begins with a wildcard.
+# Note that the index is still used but only for sorting.
+#
+do_test like-3.11 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE '%bcd' ORDER BY 1;
+ }
+} {abcd bcd nosort {} i1}
+do_test like-3.12 {
+ set sqlite_like_count
+} 12
+
+# No optimization for case insensitive LIKE
+#
+do_test like-3.13 {
+ set sqlite_like_count 0
+ queryplan {
+ PRAGMA case_sensitive_like=off;
+ SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
+ }
+} {ABC {ABC abc xyz} abc abcd nosort {} i1}
+do_test like-3.14 {
+ set sqlite_like_count
+} 12
+
+# No optimization without an index.
+#
+do_test like-3.15 {
+ set sqlite_like_count 0
+ queryplan {
+ PRAGMA case_sensitive_like=on;
+ DROP INDEX i1;
+ SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
+ }
+} {abc abcd sort t1 {}}
+do_test like-3.16 {
+ set sqlite_like_count
+} 12
+
+# No GLOB optimization without an index.
+#
+do_test like-3.17 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;
+ }
+} {abc abcd sort t1 {}}
+do_test like-3.18 {
+ set sqlite_like_count
+} 12
+
+# GLOB is optimized regardless of the case_sensitive_like setting.
+#
+do_test like-3.19 {
+ set sqlite_like_count 0
+ db eval {CREATE INDEX i1 ON t1(x);}
+ queryplan {
+ SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;
+ }
+} {abc abcd nosort {} i1}
+do_test like-3.20 {
+ set sqlite_like_count
+} 0
+do_test like-3.21 {
+ set sqlite_like_count 0
+ queryplan {
+ PRAGMA case_sensitive_like=on;
+ SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;
+ }
+} {abc abcd nosort {} i1}
+do_test like-3.22 {
+ set sqlite_like_count
+} 0
+do_test like-3.23 {
+ set sqlite_like_count 0
+ queryplan {
+ PRAGMA case_sensitive_like=off;
+ SELECT x FROM t1 WHERE x GLOB 'a[bc]d' ORDER BY 1;
+ }
+} {abd acd nosort {} i1}
+do_test like-3.24 {
+ set sqlite_like_count
+} 6
+
+# GLOB optimization when there is no wildcard. Ticket [e090183531fc2747]
+#
+do_test like-3.25 {
+ queryplan {
+ SELECT x FROM t1 WHERE x GLOB 'a' ORDER BY 1;
+ }
+} {a nosort {} i1}
+do_test like-3.26 {
+ queryplan {
+ SELECT x FROM t1 WHERE x GLOB 'abcd' ORDER BY 1;
+ }
+} {abcd nosort {} i1}
+do_test like-3.27 {
+ queryplan {
+ SELECT x FROM t1 WHERE x GLOB 'abcde' ORDER BY 1;
+ }
+} {nosort {} i1}
+
+
+
+# No optimization if the LHS of the LIKE is not a column name or
+# if the RHS is not a string.
+#
+do_test like-4.1 {
+ execsql {PRAGMA case_sensitive_like=on}
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1
+ }
+} {abc abcd nosort {} i1}
+do_test like-4.2 {
+ set sqlite_like_count
+} 0
+do_test like-4.3 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE +x LIKE 'abc%' ORDER BY 1
+ }
+} {abc abcd nosort {} i1}
+do_test like-4.4 {
+ set sqlite_like_count
+} 12
+do_test like-4.5 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE ('ab' || 'c%') ORDER BY 1
+ }
+} {abc abcd nosort {} i1}
+do_test like-4.6 {
+ set sqlite_like_count
+} 12
+
+# Collating sequences on the index disable the LIKE optimization.
+# Or if the NOCASE collating sequence is used, the LIKE optimization
+# is enabled when case_sensitive_like is OFF.
+#
+do_test like-5.1 {
+ execsql {PRAGMA case_sensitive_like=off}
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1
+ }
+} {ABC {ABC abc xyz} abc abcd nosort {} i1}
+do_test like-5.2 {
+ set sqlite_like_count
+} 12
+do_test like-5.3 {
+ execsql {
+ CREATE TABLE t2(x TEXT COLLATE NOCASE);
+ INSERT INTO t2 SELECT * FROM t1;
+ CREATE INDEX i2 ON t2(x COLLATE NOCASE);
+ }
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t2 WHERE x LIKE 'abc%' ORDER BY 1
+ }
+} {abc ABC {ABC abc xyz} abcd nosort {} i2}
+do_test like-5.4 {
+ set sqlite_like_count
+} 0
+do_test like-5.5 {
+ execsql {
+ PRAGMA case_sensitive_like=on;
+ }
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t2 WHERE x LIKE 'abc%' ORDER BY 1
+ }
+} {abc abcd nosort {} i2}
+do_test like-5.6 {
+ set sqlite_like_count
+} 12
+do_test like-5.7 {
+ execsql {
+ PRAGMA case_sensitive_like=off;
+ }
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t2 WHERE x GLOB 'abc*' ORDER BY 1
+ }
+} {abc abcd nosort {} i2}
+do_test like-5.8 {
+ set sqlite_like_count
+} 12
+do_test like-5.11 {
+ execsql {PRAGMA case_sensitive_like=off}
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'ABC%' ORDER BY 1
+ }
+} {ABC {ABC abc xyz} abc abcd nosort {} i1}
+do_test like-5.12 {
+ set sqlite_like_count
+} 12
+do_test like-5.13 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t2 WHERE x LIKE 'ABC%' ORDER BY 1
+ }
+} {abc ABC {ABC abc xyz} abcd nosort {} i2}
+do_test like-5.14 {
+ set sqlite_like_count
+} 0
+do_test like-5.15 {
+ execsql {
+ PRAGMA case_sensitive_like=on;
+ }
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t2 WHERE x LIKE 'ABC%' ORDER BY 1
+ }
+} {ABC {ABC abc xyz} nosort {} i2}
+do_test like-5.16 {
+ set sqlite_like_count
+} 12
+do_test like-5.17 {
+ execsql {
+ PRAGMA case_sensitive_like=off;
+ }
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t2 WHERE x GLOB 'ABC*' ORDER BY 1
+ }
+} {ABC {ABC abc xyz} nosort {} i2}
+do_test like-5.18 {
+ set sqlite_like_count
+} 12
+
+# Boundary case. The prefix for a LIKE comparison is rounded up
+# when constructing the comparison. Example: "ab" becomes "ac".
+# In other words, the last character is increased by one.
+#
+# Make sure this happens correctly when the last character is a
+# "z" and we are doing case-insensitive comparisons.
+#
+# Ticket #2959
+#
+do_test like-5.21 {
+ execsql {
+ PRAGMA case_sensitive_like=off;
+ INSERT INTO t2 VALUES('ZZ-upper-upper');
+ INSERT INTO t2 VALUES('zZ-lower-upper');
+ INSERT INTO t2 VALUES('Zz-upper-lower');
+ INSERT INTO t2 VALUES('zz-lower-lower');
+ }
+ queryplan {
+ SELECT x FROM t2 WHERE x LIKE 'zz%';
+ }
+} {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}
+do_test like-5.22 {
+ queryplan {
+ SELECT x FROM t2 WHERE x LIKE 'zZ%';
+ }
+} {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}
+do_test like-5.23 {
+ queryplan {
+ SELECT x FROM t2 WHERE x LIKE 'Zz%';
+ }
+} {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}
+do_test like-5.24 {
+ queryplan {
+ SELECT x FROM t2 WHERE x LIKE 'ZZ%';
+ }
+} {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}
+do_test like-5.25 {
+ db eval {
+ PRAGMA case_sensitive_like=on;
+ CREATE TABLE t3(x TEXT);
+ CREATE INDEX i3 ON t3(x);
+ INSERT INTO t3 VALUES('ZZ-upper-upper');
+ INSERT INTO t3 VALUES('zZ-lower-upper');
+ INSERT INTO t3 VALUES('Zz-upper-lower');
+ INSERT INTO t3 VALUES('zz-lower-lower');
+ }
+ queryplan {
+ SELECT x FROM t3 WHERE x LIKE 'zz%';
+ }
+} {zz-lower-lower nosort {} i3}
+do_test like-5.26 {
+ queryplan {
+ SELECT x FROM t3 WHERE x LIKE 'zZ%';
+ }
+} {zZ-lower-upper nosort {} i3}
+do_test like-5.27 {
+ queryplan {
+ SELECT x FROM t3 WHERE x LIKE 'Zz%';
+ }
+} {Zz-upper-lower nosort {} i3}
+do_test like-5.28 {
+ queryplan {
+ SELECT x FROM t3 WHERE x LIKE 'ZZ%';
+ }
+} {ZZ-upper-upper nosort {} i3}
+
+
+# ticket #2407
+#
+# Make sure the LIKE prefix optimization does not strip off leading
+# characters of the like pattern that happen to be quote characters.
+#
+do_test like-6.1 {
+ foreach x { 'abc 'bcd 'def 'ax } {
+ set x2 '[string map {' ''} $x]'
+ db eval "INSERT INTO t2 VALUES($x2)"
+ }
+ execsql {
+ SELECT * FROM t2 WHERE x LIKE '''a%'
+ }
+} {'abc 'ax}
+
+do_test like-7.1 {
+ execsql {
+ SELECT rowid, * FROM t1 WHERE rowid GLOB '1*' ORDER BY rowid;
+ }
+} {1 a 10 ABC 11 CDE 12 {ABC abc xyz}}
+
+# ticket #3345.
+#
+# Overloading the LIKE function with -1 for the number of arguments
+# will overload both the 2-argument and the 3-argument LIKE.
+#
+do_test like-8.1 {
+ db eval {
+ CREATE TABLE t8(x);
+ INSERT INTO t8 VALUES('abcdef');
+ INSERT INTO t8 VALUES('ghijkl');
+ INSERT INTO t8 VALUES('mnopqr');
+ SELECT 1, x FROM t8 WHERE x LIKE '%h%';
+ SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';
+ }
+} {1 ghijkl 2 ghijkl}
+do_test like-8.2 {
+ proc newlike {args} {return 1} ;# Alternative LIKE is always return TRUE
+ db function like newlike ;# Uses -1 for nArg in sqlite3_create_function
+ db cache flush
+ db eval {
+ SELECT 1, x FROM t8 WHERE x LIKE '%h%';
+ SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';
+ }
+} {1 ghijkl 2 ghijkl}
+do_test like-8.3 {
+ db function like -argcount 2 newlike
+ db eval {
+ SELECT 1, x FROM t8 WHERE x LIKE '%h%';
+ SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';
+ }
+} {1 abcdef 1 ghijkl 1 mnopqr 2 ghijkl}
+do_test like-8.4 {
+ db function like -argcount 3 newlike
+ db eval {
+ SELECT 1, x FROM t8 WHERE x LIKE '%h%';
+ SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';
+ }
+} {1 abcdef 1 ghijkl 1 mnopqr 2 abcdef 2 ghijkl 2 mnopqr}
+
+
+ifcapable like_opt&&!icu {
+ # Evaluate SQL. Return the result set followed by the
+ # and the number of full-scan steps.
+ #
+ db close
+ sqlite3 db test.db
+ proc count_steps {sql} {
+ set r [db eval $sql]
+ lappend r scan [db status step] sort [db status sort]
+ }
+ do_test like-9.1 {
+ count_steps {
+ SELECT x FROM t2 WHERE x LIKE 'x%'
+ }
+ } {xyz scan 0 sort 0}
+ do_test like-9.2 {
+ count_steps {
+ SELECT x FROM t2 WHERE x LIKE '_y%'
+ }
+ } {xyz scan 19 sort 0}
+ do_test like-9.3.1 {
+ set res [sqlite3_exec_hex db {
+ SELECT x FROM t2 WHERE x LIKE '%78%25'
+ }]
+ } {0 {x xyz}}
+ ifcapable explain {
+ do_test like-9.3.2 {
+ set res [sqlite3_exec_hex db {
+ EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%78%25'
+ }]
+ regexp {INDEX i2} $res
+ } {1}
+ }
+ do_test like-9.4.1 {
+ sqlite3_exec_hex db {INSERT INTO t2 VALUES('%ffhello')}
+ set res [sqlite3_exec_hex db {
+ SELECT substr(x,2) AS x FROM t2 WHERE +x LIKE '%ff%25'
+ }]
+ } {0 {x hello}}
+ do_test like-9.4.2 {
+ set res [sqlite3_exec_hex db {
+ SELECT substr(x,2) AS x FROM t2 WHERE x LIKE '%ff%25'
+ }]
+ } {0 {x hello}}
+ ifcapable explain {
+ do_test like-9.4.3 {
+ set res [sqlite3_exec_hex db {
+ EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%ff%25'
+ }]
+ regexp {INDEX i2} $res
+ } {0}
+ }
+ do_test like-9.5.1 {
+ set res [sqlite3_exec_hex db {
+ SELECT x FROM t2 WHERE x LIKE '%fe%25'
+ }]
+ } {0 {}}
+ ifcapable explain {
+ do_test like-9.5.2 {
+ set res [sqlite3_exec_hex db {
+ EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%fe%25'
+ }]
+ regexp {INDEX i2} $res
+ } {1}
+ }
+
+ # Do an SQL statement. Append the search count to the end of the result.
+ #
+ proc count sql {
+ set ::sqlite_search_count 0
+ set ::sqlite_like_count 0
+ return [concat [execsql $sql] scan $::sqlite_search_count \
+ like $::sqlite_like_count]
+ }
+
+ # The LIKE and GLOB optimizations do not work on columns with
+ # affinity other than TEXT.
+ # Ticket #3901
+ #
+ do_test like-10.1 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t10(
+ a INTEGER PRIMARY KEY,
+ b INTEGER COLLATE nocase UNIQUE,
+ c NUMBER COLLATE nocase UNIQUE,
+ d BLOB COLLATE nocase UNIQUE,
+ e COLLATE nocase UNIQUE,
+ f TEXT COLLATE nocase UNIQUE
+ );
+ INSERT INTO t10 VALUES(1,1,1,1,1,1);
+ INSERT INTO t10 VALUES(12,12,12,12,12,12);
+ INSERT INTO t10 VALUES(123,123,123,123,123,123);
+ INSERT INTO t10 VALUES(234,234,234,234,234,234);
+ INSERT INTO t10 VALUES(345,345,345,345,345,345);
+ INSERT INTO t10 VALUES(45,45,45,45,45,45);
+ }
+ count {
+ SELECT a FROM t10 WHERE b LIKE '12%' ORDER BY +a;
+ }
+ } {12 123 scan 5 like 6}
+ do_test like-10.2 {
+ count {
+ SELECT a FROM t10 WHERE c LIKE '12%' ORDER BY +a;
+ }
+ } {12 123 scan 5 like 6}
+ do_test like-10.3 {
+ count {
+ SELECT a FROM t10 WHERE d LIKE '12%' ORDER BY +a;
+ }
+ } {12 123 scan 5 like 6}
+ do_test like-10.4 {
+ count {
+ SELECT a FROM t10 WHERE e LIKE '12%' ORDER BY +a;
+ }
+ } {12 123 scan 5 like 6}
+ do_test like-10.5 {
+ count {
+ SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY +a;
+ }
+ } {12 123 scan 3 like 0}
+ do_test like-10.6 {
+ count {
+ SELECT a FROM t10 WHERE a LIKE '12%' ORDER BY +a;
+ }
+ } {12 123 scan 5 like 6}
+ do_test like-10.10 {
+ execsql {
+ CREATE TABLE t10b(
+ a INTEGER PRIMARY KEY,
+ b INTEGER UNIQUE,
+ c NUMBER UNIQUE,
+ d BLOB UNIQUE,
+ e UNIQUE,
+ f TEXT UNIQUE
+ );
+ INSERT INTO t10b SELECT * FROM t10;
+ }
+ count {
+ SELECT a FROM t10b WHERE b GLOB '12*' ORDER BY +a;
+ }
+ } {12 123 scan 5 like 6}
+ do_test like-10.11 {
+ count {
+ SELECT a FROM t10b WHERE c GLOB '12*' ORDER BY +a;
+ }
+ } {12 123 scan 5 like 6}
+ do_test like-10.12 {
+ count {
+ SELECT a FROM t10b WHERE d GLOB '12*' ORDER BY +a;
+ }
+ } {12 123 scan 5 like 6}
+ do_test like-10.13 {
+ count {
+ SELECT a FROM t10b WHERE e GLOB '12*' ORDER BY +a;
+ }
+ } {12 123 scan 5 like 6}
+ do_test like-10.14 {
+ count {
+ SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY +a;
+ }
+ } {12 123 scan 3 like 0}
+ do_test like-10.15 {
+ count {
+ SELECT a FROM t10b WHERE a GLOB '12*' ORDER BY +a;
+ }
+ } {12 123 scan 5 like 6}
+}
+
+# LIKE and GLOB where the default collating sequence is not appropriate
+# but an index with the appropriate collating sequence exists.
+#
+do_test like-11.0 {
+ execsql {
+ CREATE TABLE t11(
+ a INTEGER PRIMARY KEY,
+ b TEXT COLLATE nocase,
+ c TEXT COLLATE binary
+ );
+ INSERT INTO t11 VALUES(1, 'a','a');
+ INSERT INTO t11 VALUES(2, 'ab','ab');
+ INSERT INTO t11 VALUES(3, 'abc','abc');
+ INSERT INTO t11 VALUES(4, 'abcd','abcd');
+ INSERT INTO t11 VALUES(5, 'A','A');
+ INSERT INTO t11 VALUES(6, 'AB','AB');
+ INSERT INTO t11 VALUES(7, 'ABC','ABC');
+ INSERT INTO t11 VALUES(8, 'ABCD','ABCD');
+ INSERT INTO t11 VALUES(9, 'x','x');
+ INSERT INTO t11 VALUES(10, 'yz','yz');
+ INSERT INTO t11 VALUES(11, 'X','X');
+ INSERT INTO t11 VALUES(12, 'YZ','YZ');
+ SELECT count(*) FROM t11;
+ }
+} {12}
+do_test like-11.1 {
+ queryplan {
+ PRAGMA case_sensitive_like=OFF;
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
+ }
+} {abc abcd ABC ABCD nosort t11 *}
+do_test like-11.2 {
+ queryplan {
+ PRAGMA case_sensitive_like=ON;
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
+ }
+} {abc abcd nosort t11 *}
+do_test like-11.3 {
+ queryplan {
+ PRAGMA case_sensitive_like=OFF;
+ CREATE INDEX t11b ON t11(b);
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
+ }
+} {abc abcd ABC ABCD sort {} t11b}
+do_test like-11.4 {
+ queryplan {
+ PRAGMA case_sensitive_like=ON;
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
+ }
+} {abc abcd nosort t11 *}
+do_test like-11.5 {
+ queryplan {
+ PRAGMA case_sensitive_like=OFF;
+ DROP INDEX t11b;
+ CREATE INDEX t11bnc ON t11(b COLLATE nocase);
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
+ }
+} {abc abcd ABC ABCD sort {} t11bnc}
+do_test like-11.6 {
+ queryplan {
+ CREATE INDEX t11bb ON t11(b COLLATE binary);
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
+ }
+} {abc abcd ABC ABCD sort {} t11bnc}
+do_test like-11.7 {
+ queryplan {
+ PRAGMA case_sensitive_like=ON;
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
+ }
+} {abc abcd sort {} t11bb}
+do_test like-11.8 {
+ queryplan {
+ PRAGMA case_sensitive_like=OFF;
+ SELECT b FROM t11 WHERE b GLOB 'abc*' ORDER BY +a;
+ }
+} {abc abcd sort {} t11bb}
+do_test like-11.9 {
+ queryplan {
+ CREATE INDEX t11cnc ON t11(c COLLATE nocase);
+ CREATE INDEX t11cb ON t11(c COLLATE binary);
+ SELECT c FROM t11 WHERE c LIKE 'abc%' ORDER BY +a;
+ }
+} {abc abcd ABC ABCD sort {} t11cnc}
+do_test like-11.10 {
+ queryplan {
+ SELECT c FROM t11 WHERE c GLOB 'abc*' ORDER BY +a;
+ }
+} {abc abcd sort {} t11cb}
+
+
+finish_test
diff --git a/test/like2.test b/test/like2.test
new file mode 100644
index 0000000..4fd1642
--- /dev/null
+++ b/test/like2.test
@@ -0,0 +1,1009 @@
+# 2008 May 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the LIKE and GLOB operators and
+# in particular the optimizations that occur to help those operators
+# run faster.
+#
+# $Id: like2.test,v 1.1 2008/05/26 18:33:41 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test like2-1.1 {
+ db eval {
+ CREATE TABLE t1(x INT, y COLLATE NOCASE);
+ INSERT INTO t1(x,y) VALUES(1,CAST(x'01' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(2,CAST(x'02' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(3,CAST(x'03' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(4,CAST(x'04' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(5,CAST(x'05' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(6,CAST(x'06' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(7,CAST(x'07' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(8,CAST(x'08' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(9,CAST(x'09' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(10,CAST(x'0a' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(11,CAST(x'0b' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(12,CAST(x'0c' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(13,CAST(x'0d' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(14,CAST(x'0e' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(15,CAST(x'0f' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(16,CAST(x'10' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(17,CAST(x'11' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(18,CAST(x'12' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(19,CAST(x'13' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(20,CAST(x'14' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(21,CAST(x'15' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(22,CAST(x'16' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(23,CAST(x'17' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(24,CAST(x'18' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(25,CAST(x'19' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(26,CAST(x'1a' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(27,CAST(x'1b' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(28,CAST(x'1c' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(29,CAST(x'1d' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(30,CAST(x'1e' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(31,CAST(x'1f' AS TEXT));
+ INSERT INTO t1(x,y) VALUES(32,' ');
+ INSERT INTO t1(x,y) VALUES(33,'!');
+ INSERT INTO t1(x,y) VALUES(34,'"');
+ INSERT INTO t1(x,y) VALUES(35,'#');
+ INSERT INTO t1(x,y) VALUES(36,'$');
+ INSERT INTO t1(x,y) VALUES(37,'%');
+ INSERT INTO t1(x,y) VALUES(38,'&');
+ INSERT INTO t1(x,y) VALUES(39,'''');
+ INSERT INTO t1(x,y) VALUES(40,'(');
+ INSERT INTO t1(x,y) VALUES(41,')');
+ INSERT INTO t1(x,y) VALUES(42,'*');
+ INSERT INTO t1(x,y) VALUES(43,'+');
+ INSERT INTO t1(x,y) VALUES(44,',');
+ INSERT INTO t1(x,y) VALUES(45,'-');
+ INSERT INTO t1(x,y) VALUES(46,'.');
+ INSERT INTO t1(x,y) VALUES(47,'/');
+ INSERT INTO t1(x,y) VALUES(48,'0');
+ INSERT INTO t1(x,y) VALUES(49,'1');
+ INSERT INTO t1(x,y) VALUES(50,'2');
+ INSERT INTO t1(x,y) VALUES(51,'3');
+ INSERT INTO t1(x,y) VALUES(52,'4');
+ INSERT INTO t1(x,y) VALUES(53,'5');
+ INSERT INTO t1(x,y) VALUES(54,'6');
+ INSERT INTO t1(x,y) VALUES(55,'7');
+ INSERT INTO t1(x,y) VALUES(56,'8');
+ INSERT INTO t1(x,y) VALUES(57,'9');
+ INSERT INTO t1(x,y) VALUES(58,':');
+ INSERT INTO t1(x,y) VALUES(59,';');
+ INSERT INTO t1(x,y) VALUES(60,'<');
+ INSERT INTO t1(x,y) VALUES(61,'=');
+ INSERT INTO t1(x,y) VALUES(62,'>');
+ INSERT INTO t1(x,y) VALUES(63,'?');
+ INSERT INTO t1(x,y) VALUES(64,'@');
+ INSERT INTO t1(x,y) VALUES(65,'A');
+ INSERT INTO t1(x,y) VALUES(66,'B');
+ INSERT INTO t1(x,y) VALUES(67,'C');
+ INSERT INTO t1(x,y) VALUES(68,'D');
+ INSERT INTO t1(x,y) VALUES(69,'E');
+ INSERT INTO t1(x,y) VALUES(70,'F');
+ INSERT INTO t1(x,y) VALUES(71,'G');
+ INSERT INTO t1(x,y) VALUES(72,'H');
+ INSERT INTO t1(x,y) VALUES(73,'I');
+ INSERT INTO t1(x,y) VALUES(74,'J');
+ INSERT INTO t1(x,y) VALUES(75,'K');
+ INSERT INTO t1(x,y) VALUES(76,'L');
+ INSERT INTO t1(x,y) VALUES(77,'M');
+ INSERT INTO t1(x,y) VALUES(78,'N');
+ INSERT INTO t1(x,y) VALUES(79,'O');
+ INSERT INTO t1(x,y) VALUES(80,'P');
+ INSERT INTO t1(x,y) VALUES(81,'Q');
+ INSERT INTO t1(x,y) VALUES(82,'R');
+ INSERT INTO t1(x,y) VALUES(83,'S');
+ INSERT INTO t1(x,y) VALUES(84,'T');
+ INSERT INTO t1(x,y) VALUES(85,'U');
+ INSERT INTO t1(x,y) VALUES(86,'V');
+ INSERT INTO t1(x,y) VALUES(87,'W');
+ INSERT INTO t1(x,y) VALUES(88,'X');
+ INSERT INTO t1(x,y) VALUES(89,'Y');
+ INSERT INTO t1(x,y) VALUES(90,'Z');
+ INSERT INTO t1(x,y) VALUES(91,'[');
+ INSERT INTO t1(x,y) VALUES(92,'\');
+ INSERT INTO t1(x,y) VALUES(93,']');
+ INSERT INTO t1(x,y) VALUES(94,'^');
+ INSERT INTO t1(x,y) VALUES(95,'_');
+ INSERT INTO t1(x,y) VALUES(96,'`');
+ INSERT INTO t1(x,y) VALUES(97,'a');
+ INSERT INTO t1(x,y) VALUES(98,'b');
+ INSERT INTO t1(x,y) VALUES(99,'c');
+ INSERT INTO t1(x,y) VALUES(100,'d');
+ INSERT INTO t1(x,y) VALUES(101,'e');
+ INSERT INTO t1(x,y) VALUES(102,'f');
+ INSERT INTO t1(x,y) VALUES(103,'g');
+ INSERT INTO t1(x,y) VALUES(104,'h');
+ INSERT INTO t1(x,y) VALUES(105,'i');
+ INSERT INTO t1(x,y) VALUES(106,'j');
+ INSERT INTO t1(x,y) VALUES(107,'k');
+ INSERT INTO t1(x,y) VALUES(108,'l');
+ INSERT INTO t1(x,y) VALUES(109,'m');
+ INSERT INTO t1(x,y) VALUES(110,'n');
+ INSERT INTO t1(x,y) VALUES(111,'o');
+ INSERT INTO t1(x,y) VALUES(112,'p');
+ INSERT INTO t1(x,y) VALUES(113,'q');
+ INSERT INTO t1(x,y) VALUES(114,'r');
+ INSERT INTO t1(x,y) VALUES(115,'s');
+ INSERT INTO t1(x,y) VALUES(116,'t');
+ INSERT INTO t1(x,y) VALUES(117,'u');
+ INSERT INTO t1(x,y) VALUES(118,'v');
+ INSERT INTO t1(x,y) VALUES(119,'w');
+ INSERT INTO t1(x,y) VALUES(120,'x');
+ INSERT INTO t1(x,y) VALUES(121,'y');
+ INSERT INTO t1(x,y) VALUES(122,'z');
+ INSERT INTO t1(x,y) VALUES(123,'{');
+ INSERT INTO t1(x,y) VALUES(124,'|');
+ INSERT INTO t1(x,y) VALUES(125,'}');
+ INSERT INTO t1(x,y) VALUES(126,'~');
+ INSERT INTO t1(x,y) VALUES(127,CAST(x'7f' AS TEXT));
+ SELECT count(*) FROM t1;
+ }
+} {127}
+do_test like2-1.2 {
+ db eval {
+ CREATE TABLE t2(x INT, y COLLATE NOCASE);
+ INSERT INTO t2 SELECT * FROM t1;
+ CREATE INDEX i2 ON t2(y);
+ SELECT count(*) FROM t2;
+ }
+} {127}
+do_test like2-1.3 {
+ db eval {
+ CREATE TABLE t3(x INT, y COLLATE NOCASE);
+ INSERT INTO t3 SELECT x, 'abc' || y || 'xyz' FROM t1;
+ CREATE INDEX i3 ON t3(y);
+ SELECT count(*) FROM t2;
+ }
+} {127}
+do_test like-2.32.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE ' %'"
+} {32}
+do_test like-2.32.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE ' %'"
+} {32}
+do_test like-2.32.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc %'"
+} {32}
+do_test like-2.33.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '!%'"
+} {33}
+do_test like-2.33.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '!%'"
+} {33}
+do_test like-2.33.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc!%'"
+} {33}
+do_test like-2.34.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '\"%'"
+} {34}
+do_test like-2.34.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '\"%'"
+} {34}
+do_test like-2.34.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc\"%'"
+} {34}
+do_test like-2.35.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '#%'"
+} {35}
+do_test like-2.35.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '#%'"
+} {35}
+do_test like-2.35.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc#%'"
+} {35}
+do_test like-2.36.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '\$%'"
+} {36}
+do_test like-2.36.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '\$%'"
+} {36}
+do_test like-2.36.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc\$%'"
+} {36}
+do_test like-2.38.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '&%'"
+} {38}
+do_test like-2.38.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '&%'"
+} {38}
+do_test like-2.38.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc&%'"
+} {38}
+do_test like-2.39.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '''%'"
+} {39}
+do_test like-2.39.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '''%'"
+} {39}
+do_test like-2.39.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc''%'"
+} {39}
+do_test like-2.40.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '(%'"
+} {40}
+do_test like-2.40.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '(%'"
+} {40}
+do_test like-2.40.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc(%'"
+} {40}
+do_test like-2.41.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE ')%'"
+} {41}
+do_test like-2.41.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE ')%'"
+} {41}
+do_test like-2.41.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc)%'"
+} {41}
+do_test like-2.42.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '*%'"
+} {42}
+do_test like-2.42.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '*%'"
+} {42}
+do_test like-2.42.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc*%'"
+} {42}
+do_test like-2.43.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '+%'"
+} {43}
+do_test like-2.43.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '+%'"
+} {43}
+do_test like-2.43.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc+%'"
+} {43}
+do_test like-2.44.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE ',%'"
+} {44}
+do_test like-2.44.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE ',%'"
+} {44}
+do_test like-2.44.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc,%'"
+} {44}
+do_test like-2.45.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '-%'"
+} {45}
+do_test like-2.45.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '-%'"
+} {45}
+do_test like-2.45.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc-%'"
+} {45}
+do_test like-2.46.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '.%'"
+} {46}
+do_test like-2.46.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '.%'"
+} {46}
+do_test like-2.46.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc.%'"
+} {46}
+do_test like-2.47.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '/%'"
+} {47}
+do_test like-2.47.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '/%'"
+} {47}
+do_test like-2.47.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc/%'"
+} {47}
+do_test like-2.48.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '0%'"
+} {48}
+do_test like-2.48.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '0%'"
+} {48}
+do_test like-2.48.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc0%'"
+} {48}
+do_test like-2.49.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '1%'"
+} {49}
+do_test like-2.49.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '1%'"
+} {49}
+do_test like-2.49.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc1%'"
+} {49}
+do_test like-2.50.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '2%'"
+} {50}
+do_test like-2.50.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '2%'"
+} {50}
+do_test like-2.50.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc2%'"
+} {50}
+do_test like-2.51.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '3%'"
+} {51}
+do_test like-2.51.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '3%'"
+} {51}
+do_test like-2.51.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc3%'"
+} {51}
+do_test like-2.52.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '4%'"
+} {52}
+do_test like-2.52.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '4%'"
+} {52}
+do_test like-2.52.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc4%'"
+} {52}
+do_test like-2.53.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '5%'"
+} {53}
+do_test like-2.53.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '5%'"
+} {53}
+do_test like-2.53.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc5%'"
+} {53}
+do_test like-2.54.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '6%'"
+} {54}
+do_test like-2.54.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '6%'"
+} {54}
+do_test like-2.54.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc6%'"
+} {54}
+do_test like-2.55.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '7%'"
+} {55}
+do_test like-2.55.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '7%'"
+} {55}
+do_test like-2.55.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc7%'"
+} {55}
+do_test like-2.56.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '8%'"
+} {56}
+do_test like-2.56.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '8%'"
+} {56}
+do_test like-2.56.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc8%'"
+} {56}
+do_test like-2.57.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '9%'"
+} {57}
+do_test like-2.57.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '9%'"
+} {57}
+do_test like-2.57.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc9%'"
+} {57}
+do_test like-2.58.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE ':%'"
+} {58}
+do_test like-2.58.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE ':%'"
+} {58}
+do_test like-2.58.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc:%'"
+} {58}
+do_test like-2.59.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE ';%'"
+} {59}
+do_test like-2.59.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE ';%'"
+} {59}
+do_test like-2.59.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc;%'"
+} {59}
+do_test like-2.60.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '<%'"
+} {60}
+do_test like-2.60.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '<%'"
+} {60}
+do_test like-2.60.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc<%'"
+} {60}
+do_test like-2.61.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '=%'"
+} {61}
+do_test like-2.61.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '=%'"
+} {61}
+do_test like-2.61.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc=%'"
+} {61}
+do_test like-2.62.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '>%'"
+} {62}
+do_test like-2.62.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '>%'"
+} {62}
+do_test like-2.62.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc>%'"
+} {62}
+do_test like-2.63.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '?%'"
+} {63}
+do_test like-2.63.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '?%'"
+} {63}
+do_test like-2.63.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc?%'"
+} {63}
+do_test like-2.64.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '@%'"
+} {64}
+do_test like-2.64.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '@%'"
+} {64}
+do_test like-2.64.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc@%'"
+} {64}
+do_test like-2.65.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'A%'"
+} {65 97}
+do_test like-2.65.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'A%'"
+} {65 97}
+do_test like-2.65.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcA%'"
+} {65 97}
+do_test like-2.66.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'B%'"
+} {66 98}
+do_test like-2.66.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'B%'"
+} {66 98}
+do_test like-2.66.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcB%'"
+} {66 98}
+do_test like-2.67.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'C%'"
+} {67 99}
+do_test like-2.67.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'C%'"
+} {67 99}
+do_test like-2.67.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcC%'"
+} {67 99}
+do_test like-2.68.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'D%'"
+} {68 100}
+do_test like-2.68.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'D%'"
+} {68 100}
+do_test like-2.68.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcD%'"
+} {68 100}
+do_test like-2.69.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'E%'"
+} {69 101}
+do_test like-2.69.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'E%'"
+} {69 101}
+do_test like-2.69.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcE%'"
+} {69 101}
+do_test like-2.70.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'F%'"
+} {70 102}
+do_test like-2.70.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'F%'"
+} {70 102}
+do_test like-2.70.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcF%'"
+} {70 102}
+do_test like-2.71.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'G%'"
+} {71 103}
+do_test like-2.71.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'G%'"
+} {71 103}
+do_test like-2.71.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcG%'"
+} {71 103}
+do_test like-2.72.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'H%'"
+} {72 104}
+do_test like-2.72.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'H%'"
+} {72 104}
+do_test like-2.72.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcH%'"
+} {72 104}
+do_test like-2.73.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'I%'"
+} {73 105}
+do_test like-2.73.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'I%'"
+} {73 105}
+do_test like-2.73.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcI%'"
+} {73 105}
+do_test like-2.74.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'J%'"
+} {74 106}
+do_test like-2.74.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'J%'"
+} {74 106}
+do_test like-2.74.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcJ%'"
+} {74 106}
+do_test like-2.75.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'K%'"
+} {75 107}
+do_test like-2.75.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'K%'"
+} {75 107}
+do_test like-2.75.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcK%'"
+} {75 107}
+do_test like-2.76.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'L%'"
+} {76 108}
+do_test like-2.76.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'L%'"
+} {76 108}
+do_test like-2.76.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcL%'"
+} {76 108}
+do_test like-2.77.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'M%'"
+} {77 109}
+do_test like-2.77.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'M%'"
+} {77 109}
+do_test like-2.77.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcM%'"
+} {77 109}
+do_test like-2.78.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'N%'"
+} {78 110}
+do_test like-2.78.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'N%'"
+} {78 110}
+do_test like-2.78.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcN%'"
+} {78 110}
+do_test like-2.79.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'O%'"
+} {79 111}
+do_test like-2.79.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'O%'"
+} {79 111}
+do_test like-2.79.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcO%'"
+} {79 111}
+do_test like-2.80.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'P%'"
+} {80 112}
+do_test like-2.80.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'P%'"
+} {80 112}
+do_test like-2.80.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcP%'"
+} {80 112}
+do_test like-2.81.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'Q%'"
+} {81 113}
+do_test like-2.81.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'Q%'"
+} {81 113}
+do_test like-2.81.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcQ%'"
+} {81 113}
+do_test like-2.82.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'R%'"
+} {82 114}
+do_test like-2.82.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'R%'"
+} {82 114}
+do_test like-2.82.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcR%'"
+} {82 114}
+do_test like-2.83.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'S%'"
+} {83 115}
+do_test like-2.83.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'S%'"
+} {83 115}
+do_test like-2.83.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcS%'"
+} {83 115}
+do_test like-2.84.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'T%'"
+} {84 116}
+do_test like-2.84.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'T%'"
+} {84 116}
+do_test like-2.84.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcT%'"
+} {84 116}
+do_test like-2.85.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'U%'"
+} {85 117}
+do_test like-2.85.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'U%'"
+} {85 117}
+do_test like-2.85.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcU%'"
+} {85 117}
+do_test like-2.86.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'V%'"
+} {86 118}
+do_test like-2.86.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'V%'"
+} {86 118}
+do_test like-2.86.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcV%'"
+} {86 118}
+do_test like-2.87.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'W%'"
+} {87 119}
+do_test like-2.87.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'W%'"
+} {87 119}
+do_test like-2.87.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcW%'"
+} {87 119}
+do_test like-2.88.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'X%'"
+} {88 120}
+do_test like-2.88.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'X%'"
+} {88 120}
+do_test like-2.88.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcX%'"
+} {88 120}
+do_test like-2.89.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'Y%'"
+} {89 121}
+do_test like-2.89.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'Y%'"
+} {89 121}
+do_test like-2.89.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcY%'"
+} {89 121}
+do_test like-2.90.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'Z%'"
+} {90 122}
+do_test like-2.90.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'Z%'"
+} {90 122}
+do_test like-2.90.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcZ%'"
+} {90 122}
+do_test like-2.91.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '\[%'"
+} {91}
+do_test like-2.91.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '\[%'"
+} {91}
+do_test like-2.91.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc\[%'"
+} {91}
+do_test like-2.92.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '\\%'"
+} {92}
+do_test like-2.92.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '\\%'"
+} {92}
+do_test like-2.92.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc\\%'"
+} {92}
+do_test like-2.93.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '\]%'"
+} {93}
+do_test like-2.93.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '\]%'"
+} {93}
+do_test like-2.93.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc\]%'"
+} {93}
+do_test like-2.94.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '^%'"
+} {94}
+do_test like-2.94.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '^%'"
+} {94}
+do_test like-2.94.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc^%'"
+} {94}
+do_test like-2.96.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '`%'"
+} {96}
+do_test like-2.96.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '`%'"
+} {96}
+do_test like-2.96.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc`%'"
+} {96}
+do_test like-2.97.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'a%'"
+} {65 97}
+do_test like-2.97.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'a%'"
+} {65 97}
+do_test like-2.97.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abca%'"
+} {65 97}
+do_test like-2.98.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'b%'"
+} {66 98}
+do_test like-2.98.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'b%'"
+} {66 98}
+do_test like-2.98.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcb%'"
+} {66 98}
+do_test like-2.99.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'c%'"
+} {67 99}
+do_test like-2.99.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'c%'"
+} {67 99}
+do_test like-2.99.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcc%'"
+} {67 99}
+do_test like-2.100.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'd%'"
+} {68 100}
+do_test like-2.100.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'd%'"
+} {68 100}
+do_test like-2.100.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcd%'"
+} {68 100}
+do_test like-2.101.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'e%'"
+} {69 101}
+do_test like-2.101.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'e%'"
+} {69 101}
+do_test like-2.101.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abce%'"
+} {69 101}
+do_test like-2.102.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'f%'"
+} {70 102}
+do_test like-2.102.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'f%'"
+} {70 102}
+do_test like-2.102.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcf%'"
+} {70 102}
+do_test like-2.103.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'g%'"
+} {71 103}
+do_test like-2.103.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'g%'"
+} {71 103}
+do_test like-2.103.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcg%'"
+} {71 103}
+do_test like-2.104.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'h%'"
+} {72 104}
+do_test like-2.104.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'h%'"
+} {72 104}
+do_test like-2.104.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abch%'"
+} {72 104}
+do_test like-2.105.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'i%'"
+} {73 105}
+do_test like-2.105.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'i%'"
+} {73 105}
+do_test like-2.105.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abci%'"
+} {73 105}
+do_test like-2.106.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'j%'"
+} {74 106}
+do_test like-2.106.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'j%'"
+} {74 106}
+do_test like-2.106.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcj%'"
+} {74 106}
+do_test like-2.107.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'k%'"
+} {75 107}
+do_test like-2.107.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'k%'"
+} {75 107}
+do_test like-2.107.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abck%'"
+} {75 107}
+do_test like-2.108.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'l%'"
+} {76 108}
+do_test like-2.108.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'l%'"
+} {76 108}
+do_test like-2.108.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcl%'"
+} {76 108}
+do_test like-2.109.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'm%'"
+} {77 109}
+do_test like-2.109.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'm%'"
+} {77 109}
+do_test like-2.109.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcm%'"
+} {77 109}
+do_test like-2.110.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'n%'"
+} {78 110}
+do_test like-2.110.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'n%'"
+} {78 110}
+do_test like-2.110.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcn%'"
+} {78 110}
+do_test like-2.111.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'o%'"
+} {79 111}
+do_test like-2.111.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'o%'"
+} {79 111}
+do_test like-2.111.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abco%'"
+} {79 111}
+do_test like-2.112.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'p%'"
+} {80 112}
+do_test like-2.112.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'p%'"
+} {80 112}
+do_test like-2.112.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcp%'"
+} {80 112}
+do_test like-2.113.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'q%'"
+} {81 113}
+do_test like-2.113.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'q%'"
+} {81 113}
+do_test like-2.113.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcq%'"
+} {81 113}
+do_test like-2.114.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'r%'"
+} {82 114}
+do_test like-2.114.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'r%'"
+} {82 114}
+do_test like-2.114.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcr%'"
+} {82 114}
+do_test like-2.115.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 's%'"
+} {83 115}
+do_test like-2.115.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 's%'"
+} {83 115}
+do_test like-2.115.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcs%'"
+} {83 115}
+do_test like-2.116.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 't%'"
+} {84 116}
+do_test like-2.116.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 't%'"
+} {84 116}
+do_test like-2.116.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abct%'"
+} {84 116}
+do_test like-2.117.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'u%'"
+} {85 117}
+do_test like-2.117.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'u%'"
+} {85 117}
+do_test like-2.117.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcu%'"
+} {85 117}
+do_test like-2.118.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'v%'"
+} {86 118}
+do_test like-2.118.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'v%'"
+} {86 118}
+do_test like-2.118.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcv%'"
+} {86 118}
+do_test like-2.119.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'w%'"
+} {87 119}
+do_test like-2.119.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'w%'"
+} {87 119}
+do_test like-2.119.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcw%'"
+} {87 119}
+do_test like-2.120.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'x%'"
+} {88 120}
+do_test like-2.120.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'x%'"
+} {88 120}
+do_test like-2.120.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcx%'"
+} {88 120}
+do_test like-2.121.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'y%'"
+} {89 121}
+do_test like-2.121.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'y%'"
+} {89 121}
+do_test like-2.121.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcy%'"
+} {89 121}
+do_test like-2.122.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE 'z%'"
+} {90 122}
+do_test like-2.122.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE 'z%'"
+} {90 122}
+do_test like-2.122.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abcz%'"
+} {90 122}
+do_test like-2.123.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '\173%'"
+} {123}
+do_test like-2.123.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '\173%'"
+} {123}
+do_test like-2.123.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc\173%'"
+} {123}
+do_test like-2.124.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '|%'"
+} {124}
+do_test like-2.124.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '|%'"
+} {124}
+do_test like-2.124.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc|%'"
+} {124}
+do_test like-2.125.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '\175%'"
+} {125}
+do_test like-2.125.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '\175%'"
+} {125}
+do_test like-2.125.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc\175%'"
+} {125}
+do_test like-2.126.1 {
+ db eval "SELECT x FROM t1 WHERE y LIKE '~%'"
+} {126}
+do_test like-2.126.2 {
+ db eval "SELECT x FROM t2 WHERE y LIKE '~%'"
+} {126}
+do_test like-2.126.3 {
+ db eval "SELECT x FROM t3 WHERE y LIKE 'abc~%'"
+} {126}
+
+
+finish_test
diff --git a/test/limit.test b/test/limit.test
new file mode 100644
index 0000000..e5aac70
--- /dev/null
+++ b/test/limit.test
@@ -0,0 +1,472 @@
+# 2001 November 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the LIMIT ... OFFSET ... clause
+# of SELECT statements.
+#
+# $Id: limit.test,v 1.32 2008/08/02 03:50:39 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+execsql {
+ CREATE TABLE t1(x int, y int);
+ BEGIN;
+}
+for {set i 1} {$i<=32} {incr i} {
+ for {set j 0} {(1<<$j)<$i} {incr j} {}
+ execsql "INSERT INTO t1 VALUES([expr {32-$i}],[expr {10-$j}])"
+}
+execsql {
+ COMMIT;
+}
+
+do_test limit-1.0 {
+ execsql {SELECT count(*) FROM t1}
+} {32}
+do_test limit-1.1 {
+ execsql {SELECT count(*) FROM t1 LIMIT 5}
+} {32}
+do_test limit-1.2.1 {
+ execsql {SELECT x FROM t1 ORDER BY x LIMIT 5}
+} {0 1 2 3 4}
+do_test limit-1.2.2 {
+ execsql {SELECT x FROM t1 ORDER BY x LIMIT 5 OFFSET 2}
+} {2 3 4 5 6}
+do_test limit-1.2.3 {
+ execsql {SELECT x FROM t1 ORDER BY x+1 LIMIT 5 OFFSET -2}
+} {0 1 2 3 4}
+do_test limit-1.2.4 {
+ execsql {SELECT x FROM t1 ORDER BY x+1 LIMIT 2, -5}
+} {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
+do_test limit-1.2.5 {
+ execsql {SELECT x FROM t1 ORDER BY x+1 LIMIT -2, 5}
+} {0 1 2 3 4}
+do_test limit-1.2.6 {
+ execsql {SELECT x FROM t1 ORDER BY x+1 LIMIT -2, -5}
+} {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
+do_test limit-1.2.7 {
+ execsql {SELECT x FROM t1 ORDER BY x LIMIT 2, 5}
+} {2 3 4 5 6}
+do_test limit-1.3 {
+ execsql {SELECT x FROM t1 ORDER BY x LIMIT 5 OFFSET 5}
+} {5 6 7 8 9}
+do_test limit-1.4.1 {
+ execsql {SELECT x FROM t1 ORDER BY x LIMIT 50 OFFSET 30}
+} {30 31}
+do_test limit-1.4.2 {
+ execsql {SELECT x FROM t1 ORDER BY x LIMIT 30, 50}
+} {30 31}
+do_test limit-1.5 {
+ execsql {SELECT x FROM t1 ORDER BY x LIMIT 50 OFFSET 50}
+} {}
+do_test limit-1.6 {
+ execsql {SELECT * FROM t1 AS a, t1 AS b ORDER BY a.x, b.x LIMIT 5}
+} {0 5 0 5 0 5 1 5 0 5 2 5 0 5 3 5 0 5 4 5}
+do_test limit-1.7 {
+ execsql {SELECT * FROM t1 AS a, t1 AS b ORDER BY a.x, b.x LIMIT 5 OFFSET 32}
+} {1 5 0 5 1 5 1 5 1 5 2 5 1 5 3 5 1 5 4 5}
+
+ifcapable {view && subquery} {
+ do_test limit-2.1 {
+ execsql {
+ CREATE VIEW v1 AS SELECT * FROM t1 LIMIT 2;
+ SELECT count(*) FROM (SELECT * FROM v1);
+ }
+ } 2
+} ;# ifcapable view
+do_test limit-2.2 {
+ execsql {
+ CREATE TABLE t2 AS SELECT * FROM t1 LIMIT 2;
+ SELECT count(*) FROM t2;
+ }
+} 2
+ifcapable subquery {
+ do_test limit-2.3 {
+ execsql {
+ SELECT count(*) FROM t1 WHERE rowid IN (SELECT rowid FROM t1 LIMIT 2);
+ }
+ } 2
+}
+
+ifcapable subquery {
+ do_test limit-3.1 {
+ execsql {
+ SELECT z FROM (SELECT y*10+x AS z FROM t1 ORDER BY x LIMIT 10)
+ ORDER BY z LIMIT 5;
+ }
+ } {50 51 52 53 54}
+}
+
+do_test limit-4.1 {
+ ifcapable subquery {
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(x);
+ INSERT INTO t3 SELECT x FROM t1 ORDER BY x LIMIT 10 OFFSET 1;
+ INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
+ INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
+ INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
+ INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
+ INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
+ INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
+ INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
+ INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
+ INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
+ INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
+ END;
+ SELECT count(*) FROM t3;
+ }
+ } else {
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(x);
+ INSERT INTO t3 SELECT x FROM t1 ORDER BY x LIMIT 10 OFFSET 1;
+ }
+ for {set i 0} {$i<10} {incr i} {
+ set max_x_t3 [execsql {SELECT max(x) FROM t3}]
+ execsql "INSERT INTO t3 SELECT x+$max_x_t3 FROM t3;"
+ }
+ execsql {
+ END;
+ SELECT count(*) FROM t3;
+ }
+ }
+} {10240}
+do_test limit-4.2 {
+ execsql {
+ SELECT x FROM t3 LIMIT 2 OFFSET 10000
+ }
+} {10001 10002}
+do_test limit-4.3 {
+ execsql {
+ CREATE TABLE t4 AS SELECT x,
+ 'abcdefghijklmnopqrstuvwyxz ABCDEFGHIJKLMNOPQRSTUVWYXZ' || x ||
+ 'abcdefghijklmnopqrstuvwyxz ABCDEFGHIJKLMNOPQRSTUVWYXZ' || x ||
+ 'abcdefghijklmnopqrstuvwyxz ABCDEFGHIJKLMNOPQRSTUVWYXZ' || x ||
+ 'abcdefghijklmnopqrstuvwyxz ABCDEFGHIJKLMNOPQRSTUVWYXZ' || x ||
+ 'abcdefghijklmnopqrstuvwyxz ABCDEFGHIJKLMNOPQRSTUVWYXZ' || x AS y
+ FROM t3 LIMIT 1000;
+ SELECT x FROM t4 ORDER BY y DESC LIMIT 1 OFFSET 999;
+ }
+} {1000}
+
+do_test limit-5.1 {
+ execsql {
+ CREATE TABLE t5(x,y);
+ INSERT INTO t5 SELECT x-y, x+y FROM t1 WHERE x BETWEEN 10 AND 15
+ ORDER BY x LIMIT 2;
+ SELECT * FROM t5 ORDER BY x;
+ }
+} {5 15 6 16}
+do_test limit-5.2 {
+ execsql {
+ DELETE FROM t5;
+ INSERT INTO t5 SELECT x-y, x+y FROM t1 WHERE x BETWEEN 10 AND 15
+ ORDER BY x DESC LIMIT 2;
+ SELECT * FROM t5 ORDER BY x;
+ }
+} {9 19 10 20}
+do_test limit-5.3 {
+ execsql {
+ DELETE FROM t5;
+ INSERT INTO t5 SELECT x-y, x+y FROM t1 WHERE x ORDER BY x DESC LIMIT 31;
+ SELECT * FROM t5 ORDER BY x LIMIT 2;
+ }
+} {-4 6 -3 7}
+do_test limit-5.4 {
+ execsql {
+ SELECT * FROM t5 ORDER BY x DESC, y DESC LIMIT 2;
+ }
+} {21 41 21 39}
+do_test limit-5.5 {
+ execsql {
+ DELETE FROM t5;
+ INSERT INTO t5 SELECT a.x*100+b.x, a.y*100+b.y FROM t1 AS a, t1 AS b
+ ORDER BY 1, 2 LIMIT 1000;
+ SELECT count(*), sum(x), sum(y), min(x), max(x), min(y), max(y) FROM t5;
+ }
+} {1000 1528204 593161 0 3107 505 1005}
+
+# There is some contraversy about whether LIMIT 0 should be the same as
+# no limit at all or if LIMIT 0 should result in zero output rows.
+#
+do_test limit-6.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t6(a);
+ INSERT INTO t6 VALUES(1);
+ INSERT INTO t6 VALUES(2);
+ INSERT INTO t6 SELECT a+2 FROM t6;
+ COMMIT;
+ SELECT * FROM t6;
+ }
+} {1 2 3 4}
+do_test limit-6.2 {
+ execsql {
+ SELECT * FROM t6 LIMIT -1 OFFSET -1;
+ }
+} {1 2 3 4}
+do_test limit-6.3 {
+ execsql {
+ SELECT * FROM t6 LIMIT 2 OFFSET -123;
+ }
+} {1 2}
+do_test limit-6.4 {
+ execsql {
+ SELECT * FROM t6 LIMIT -432 OFFSET 2;
+ }
+} {3 4}
+do_test limit-6.5 {
+ execsql {
+ SELECT * FROM t6 LIMIT -1
+ }
+} {1 2 3 4}
+do_test limit-6.6 {
+ execsql {
+ SELECT * FROM t6 LIMIT -1 OFFSET 1
+ }
+} {2 3 4}
+do_test limit-6.7 {
+ execsql {
+ SELECT * FROM t6 LIMIT 0
+ }
+} {}
+do_test limit-6.8 {
+ execsql {
+ SELECT * FROM t6 LIMIT 0 OFFSET 1
+ }
+} {}
+
+# Make sure LIMIT works well with compound SELECT statements.
+# Ticket #393
+#
+ifcapable compound {
+do_test limit-7.1.1 {
+ catchsql {
+ SELECT x FROM t2 LIMIT 5 UNION ALL SELECT a FROM t6;
+ }
+} {1 {LIMIT clause should come after UNION ALL not before}}
+do_test limit-7.1.2 {
+ catchsql {
+ SELECT x FROM t2 LIMIT 5 UNION SELECT a FROM t6;
+ }
+} {1 {LIMIT clause should come after UNION not before}}
+do_test limit-7.1.3 {
+ catchsql {
+ SELECT x FROM t2 LIMIT 5 EXCEPT SELECT a FROM t6 LIMIT 3;
+ }
+} {1 {LIMIT clause should come after EXCEPT not before}}
+do_test limit-7.1.4 {
+ catchsql {
+ SELECT x FROM t2 LIMIT 0,5 INTERSECT SELECT a FROM t6;
+ }
+} {1 {LIMIT clause should come after INTERSECT not before}}
+do_test limit-7.2 {
+ execsql {
+ SELECT x FROM t2 UNION ALL SELECT a FROM t6 LIMIT 5;
+ }
+} {31 30 1 2 3}
+do_test limit-7.3 {
+ execsql {
+ SELECT x FROM t2 UNION ALL SELECT a FROM t6 LIMIT 3 OFFSET 1;
+ }
+} {30 1 2}
+do_test limit-7.4 {
+ execsql {
+ SELECT x FROM t2 UNION ALL SELECT a FROM t6 ORDER BY 1 LIMIT 3 OFFSET 1;
+ }
+} {2 3 4}
+do_test limit-7.5 {
+ execsql {
+ SELECT x FROM t2 UNION SELECT x+2 FROM t2 LIMIT 2 OFFSET 1;
+ }
+} {31 32}
+do_test limit-7.6 {
+ execsql {
+ SELECT x FROM t2 UNION SELECT x+2 FROM t2 ORDER BY 1 DESC LIMIT 2 OFFSET 1;
+ }
+} {32 31}
+do_test limit-7.7 {
+ execsql {
+ SELECT a+9 FROM t6 EXCEPT SELECT y FROM t2 LIMIT 2;
+ }
+} {11 12}
+do_test limit-7.8 {
+ execsql {
+ SELECT a+9 FROM t6 EXCEPT SELECT y FROM t2 ORDER BY 1 DESC LIMIT 2;
+ }
+} {13 12}
+do_test limit-7.9 {
+ execsql {
+ SELECT a+26 FROM t6 INTERSECT SELECT x FROM t2 LIMIT 1;
+ }
+} {30}
+do_test limit-7.10 {
+ execsql {
+ SELECT a+27 FROM t6 INTERSECT SELECT x FROM t2 LIMIT 1;
+ }
+} {30}
+do_test limit-7.11 {
+ execsql {
+ SELECT a+27 FROM t6 INTERSECT SELECT x FROM t2 LIMIT 1 OFFSET 1;
+ }
+} {31}
+do_test limit-7.12 {
+ execsql {
+ SELECT a+27 FROM t6 INTERSECT SELECT x FROM t2
+ ORDER BY 1 DESC LIMIT 1 OFFSET 1;
+ }
+} {30}
+} ;# ifcapable compound
+
+# Tests for limit in conjunction with distinct. The distinct should
+# occur before both the limit and the offset. Ticket #749.
+#
+do_test limit-8.1 {
+ execsql {
+ SELECT DISTINCT cast(round(x/100) as integer) FROM t3 LIMIT 5;
+ }
+} {0 1 2 3 4}
+do_test limit-8.2 {
+ execsql {
+ SELECT DISTINCT cast(round(x/100) as integer) FROM t3 LIMIT 5 OFFSET 5;
+ }
+} {5 6 7 8 9}
+do_test limit-8.3 {
+ execsql {
+ SELECT DISTINCT cast(round(x/100) as integer) FROM t3 LIMIT 5 OFFSET 25;
+ }
+} {25 26 27 28 29}
+
+# Make sure limits on multiple subqueries work correctly.
+# Ticket #1035
+#
+ifcapable subquery {
+ do_test limit-9.1 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t6 LIMIT 3);
+ }
+ } {1 2 3}
+}
+do_test limit-9.2.1 {
+ execsql {
+ CREATE TABLE t7 AS SELECT * FROM t6;
+ }
+} {}
+ifcapable subquery {
+ do_test limit-9.2.2 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t7 LIMIT 3);
+ }
+ } {1 2 3}
+}
+ifcapable compound {
+ ifcapable subquery {
+ do_test limit-9.3 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t6 LIMIT 3)
+ UNION
+ SELECT * FROM (SELECT * FROM t7 LIMIT 3)
+ ORDER BY 1
+ }
+ } {1 2 3}
+ do_test limit-9.4 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t6 LIMIT 3)
+ UNION
+ SELECT * FROM (SELECT * FROM t7 LIMIT 3)
+ ORDER BY 1
+ LIMIT 2
+ }
+ } {1 2}
+ }
+ do_test limit-9.5 {
+ catchsql {
+ SELECT * FROM t6 LIMIT 3
+ UNION
+ SELECT * FROM t7 LIMIT 3
+ }
+ } {1 {LIMIT clause should come after UNION not before}}
+}
+
+# Test LIMIT and OFFSET using SQL variables.
+do_test limit-10.1 {
+ set limit 10
+ db eval {
+ SELECT x FROM t1 LIMIT :limit;
+ }
+} {31 30 29 28 27 26 25 24 23 22}
+do_test limit-10.2 {
+ set limit 5
+ set offset 5
+ db eval {
+ SELECT x FROM t1 LIMIT :limit OFFSET :offset;
+ }
+} {26 25 24 23 22}
+do_test limit-10.3 {
+ set limit -1
+ db eval {
+ SELECT x FROM t1 WHERE x<10 LIMIT :limit;
+ }
+} {9 8 7 6 5 4 3 2 1 0}
+do_test limit-10.4 {
+ set limit 1.5
+ set rc [catch {
+ db eval {
+ SELECT x FROM t1 WHERE x<10 LIMIT :limit;
+ } } msg]
+ list $rc $msg
+} {1 {datatype mismatch}}
+do_test limit-10.5 {
+ set limit "hello world"
+ set rc [catch {
+ db eval {
+ SELECT x FROM t1 WHERE x<10 LIMIT :limit;
+ } } msg]
+ list $rc $msg
+} {1 {datatype mismatch}}
+
+ifcapable subquery {
+do_test limit-11.1 {
+ db eval {
+ SELECT x FROM (SELECT x FROM t1 ORDER BY x LIMIT 0) ORDER BY x
+ }
+} {}
+} ;# ifcapable subquery
+
+# Test error processing.
+#
+do_test limit-12.1 {
+ catchsql {
+ SELECT * FROM t1 LIMIT replace(1)
+ }
+} {1 {wrong number of arguments to function replace()}}
+do_test limit-12.2 {
+ catchsql {
+ SELECT * FROM t1 LIMIT 5 OFFSET replace(1)
+ }
+} {1 {wrong number of arguments to function replace()}}
+do_test limit-12.3 {
+ catchsql {
+ SELECT * FROM t1 LIMIT x
+ }
+} {1 {no such column: x}}
+do_test limit-12.4 {
+ catchsql {
+ SELECT * FROM t1 LIMIT 1 OFFSET x
+ }
+} {1 {no such column: x}}
+
+
+finish_test
diff --git a/test/loadext.test b/test/loadext.test
new file mode 100644
index 0000000..8f8339e
--- /dev/null
+++ b/test/loadext.test
@@ -0,0 +1,274 @@
+# 2006 July 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is extension loading.
+#
+# $Id: loadext.test,v 1.17 2009/03/20 09:09:37 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !load_ext {
+ finish_test
+ return
+}
+
+# The name of the test extension varies by operating system.
+#
+if {$::tcl_platform(platform) eq "windows" || $::tcl_platform(platform) eq "os2"} {
+ set testextension ./testloadext.dll
+} else {
+ set testextension ./libtestloadext.so
+}
+set gcc_shared "-shared -fPIC"
+if {$::tcl_platform(os) eq "Darwin"} {
+ set gcc_shared -dynamiclib
+}
+
+# The error messages tested by this file are operating system dependent
+# (because they are returned by sqlite3OsDlError()). For now, they only
+# work with UNIX (and probably only certain kinds of UNIX).
+#
+# When a shared-object cannot be opened because it does not exist, the
+# format of the message returned is:
+#
+# [format $dlerror_nosuchfile <shared-object-name>]
+#
+# When a shared-object cannot be opened because it consists of the 4
+# characters "blah" only, we expect the error message to be:
+#
+# [format $dlerror_notadll <shared-object-name>]
+#
+# When a symbol cannot be found within an open shared-object, the error
+# message should be:
+#
+# [format $dlerror_nosymbol <shared-object-name> <symbol-name>]
+#
+# The exact error messages are not important. The important bit is
+# that SQLite is correctly copying the message from xDlError().
+#
+set dlerror_nosuchfile \
+ {%s: cannot open shared object file: No such file or directory}
+set dlerror_notadll {%s: file too short}
+set dlerror_nosymbol {%s: undefined symbol: %s}
+
+if {$::tcl_platform(os) eq "Darwin"} {
+ set dlerror_nosuchfile {dlopen(%s, 10): image not found}
+ set dlerror_notadll {dlopen(%1$s, 10): no suitable image found.*}
+ set dlerror_nosymbol {dlsym(XXX, %2$s): symbol not found}
+}
+
+# Make sure the test extension actually exists. If it does not
+# exist, try to create it. If unable to create it, then skip this
+# test file.
+#
+if {![file exists $testextension]} {
+ set srcdir [file dir $testdir]/src
+ set testextsrc $srcdir/test_loadext.c
+
+ set cmdline [concat exec gcc $gcc_shared]
+ lappend cmdline -Wall -I$srcdir -I. -g $testextsrc -o $testextension
+
+ if {[catch $cmdline msg]} {
+ puts "Skipping loadext tests: Test extension not built..."
+ puts $msg
+ finish_test
+ return
+ }
+}
+
+# Test that loading the extension produces the expected results - adding
+# the half() function to the specified database handle.
+#
+do_test loadext-1.1 {
+ catchsql {
+ SELECT half(1.0);
+ }
+} {1 {no such function: half}}
+do_test loadext-1.2 {
+ db enable_load_extension 1
+ sqlite3_load_extension db $testextension testloadext_init
+ catchsql {
+ SELECT half(1.0);
+ }
+} {0 0.5}
+
+# Test that a second database connection (db2) can load the extension also.
+#
+do_test loadext-1.3 {
+ sqlite3 db2 test.db
+ sqlite3_enable_load_extension db2 1
+ catchsql {
+ SELECT half(1.0);
+ } db2
+} {1 {no such function: half}}
+do_test loadext-1.4 {
+ sqlite3_load_extension db2 $testextension testloadext_init
+ catchsql {
+ SELECT half(1.0);
+ } db2
+} {0 0.5}
+
+# Close the first database connection. Then check that the second database
+# can still use the half() function without a problem.
+#
+do_test loadext-1.5 {
+ db close
+ catchsql {
+ SELECT half(1.0);
+ } db2
+} {0 0.5}
+
+db2 close
+sqlite3 db test.db
+sqlite3_enable_load_extension db 1
+
+# Try to load an extension for which the file does not exist.
+#
+do_test loadext-2.1 {
+ forcedelete ${testextension}xx
+ set rc [catch {
+ sqlite3_load_extension db "${testextension}xx"
+ } msg]
+ list $rc $msg
+} [list 1 [format $dlerror_nosuchfile ${testextension}xx]]
+
+# Try to load an extension for which the file is not a shared object
+#
+do_test loadext-2.2 {
+ set fd [open "${testextension}xx" w]
+ puts $fd blah
+ close $fd
+ set rc [catch {
+ sqlite3_load_extension db "${testextension}xx"
+ } msg]
+ set expected_error_pattern [format $dlerror_notadll ${testextension}xx]
+ list $rc [string match $expected_error_pattern $msg]
+} [list 1 1]
+
+# Try to load an extension for which the file is present but the
+# entry point is not.
+#
+do_test loadext-2.3 {
+ set rc [catch {
+ sqlite3_load_extension db $testextension icecream
+ } msg]
+ if {$::tcl_platform(os) eq "Darwin"} {
+ regsub {0x[1234567890abcdefABCDEF]*} $msg XXX msg
+ }
+ list $rc $msg
+} [list 1 [format $dlerror_nosymbol $testextension icecream]]
+
+# Try to load an extension for which the entry point fails (returns non-zero)
+#
+do_test loadext-2.4 {
+ set rc [catch {
+ sqlite3_load_extension db $testextension testbrokenext_init
+ } msg]
+ list $rc $msg
+} {1 {error during initialization: broken!}}
+
+############################################################################
+# Tests for the load_extension() SQL function
+#
+
+db close
+sqlite3 db test.db
+sqlite3_enable_load_extension db 1
+do_test loadext-3.1 {
+ catchsql {
+ SELECT half(5);
+ }
+} {1 {no such function: half}}
+do_test loadext-3.2 {
+ set res [catchsql {
+ SELECT load_extension($::testextension)
+ }]
+ if {$::tcl_platform(os) eq "Darwin"} {
+ regsub {0x[1234567890abcdefABCDEF]*} $res XXX res
+ }
+ set res
+} [list 1 [format $dlerror_nosymbol $testextension sqlite3_extension_init]]
+do_test loadext-3.3 {
+ catchsql {
+ SELECT load_extension($::testextension,'testloadext_init')
+ }
+} {0 {{}}}
+do_test loadext-3.4 {
+ catchsql {
+ SELECT half(5);
+ }
+} {0 2.5}
+do_test loadext-3.5 {
+ db eval {
+ SELECT sqlite3_status('MEMORY_USED') AS mused
+ } break
+ puts -nonewline " (memory_used=$mused) "
+ expr {$mused>0}
+} {1}
+do_test loadext-3.6 {
+ catchsql {
+ SELECT sqlite3_status('MEMORY_USED_X') AS mused
+ }
+} {1 {unknown status property: MEMORY_USED_X}}
+do_test loadext-3.7 {
+ catchsql {
+ SELECT sqlite3_status(4.53) AS mused
+ }
+} {1 {unknown status type}}
+do_test loadext-3.8 {
+ catchsql {
+ SELECT sqlite3_status(23) AS mused
+ }
+} {1 {sqlite3_status(23,...) returns 21}}
+
+# Ticket #1863
+# Make sure the extension loading mechanism will not work unless it
+# is explicitly enabled.
+#
+db close
+sqlite3 db test.db
+do_test loadext-4.1 {
+ catchsql {
+ SELECT load_extension($::testextension,'testloadext_init')
+ }
+} {1 {not authorized}}
+do_test loadext-4.2 {
+ sqlite3_enable_load_extension db 1
+ catchsql {
+ SELECT load_extension($::testextension,'testloadext_init')
+ }
+} {0 {{}}}
+
+do_test loadext-4.3 {
+ sqlite3_enable_load_extension db 0
+ catchsql {
+ SELECT load_extension($::testextension,'testloadext_init')
+ }
+} {1 {not authorized}}
+
+source $testdir/malloc_common.tcl
+
+
+# Malloc failure in sqlite3_auto_extension and sqlite3_load_extension
+#
+do_malloc_test loadext-5 -tclprep {
+ sqlite3_reset_auto_extension
+} -tclbody {
+ if {[autoinstall_test_functions]==7} {error "out of memory"}
+}
+do_malloc_test loadext-6 -tclbody {
+ db enable_load_extension 1
+ sqlite3_load_extension db $::testextension testloadext_init
+}
+autoinstall_test_functions
+
+finish_test
diff --git a/test/loadext2.test b/test/loadext2.test
new file mode 100644
index 0000000..3d01539
--- /dev/null
+++ b/test/loadext2.test
@@ -0,0 +1,144 @@
+# 2006 August 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is automatic extension loading and the
+# sqlite3_auto_extension() API.
+#
+# $Id: loadext2.test,v 1.3 2008/03/19 16:08:54 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Only run these tests if the approriate APIs are defined
+# in the system under test.
+#
+ifcapable !load_ext {
+ finish_test
+ return
+}
+if {[info command sqlite3_auto_extension_sqr]==""} {
+ finish_test
+ return
+}
+
+
+# None of the extension are loaded by default.
+#
+do_test loadext2-1.1 {
+ catchsql {
+ SELECT sqr(2)
+ }
+} {1 {no such function: sqr}}
+do_test loadext2-1.2 {
+ catchsql {
+ SELECT cube(2)
+ }
+} {1 {no such function: cube}}
+
+# Register auto-loaders. Still functions do not exist.
+#
+do_test loadext2-1.3 {
+ sqlite3_auto_extension_sqr
+ sqlite3_auto_extension_cube
+ catchsql {
+ SELECT sqr(2)
+ }
+} {1 {no such function: sqr}}
+do_test loadext2-1.4 {
+ catchsql {
+ SELECT cube(2)
+ }
+} {1 {no such function: cube}}
+
+
+# Functions do exist in a new database connection
+#
+do_test loadext2-1.5 {
+ sqlite3 db test.db
+ catchsql {
+ SELECT sqr(2)
+ }
+} {0 4.0}
+do_test loadext2-1.6 {
+ catchsql {
+ SELECT cube(2)
+ }
+} {0 8.0}
+
+
+# Reset extension auto loading. Existing extensions still exist.
+#
+do_test loadext2-1.7 {
+ sqlite3_reset_auto_extension
+ catchsql {
+ SELECT sqr(2)
+ }
+} {0 4.0}
+do_test loadext2-1.8 {
+ catchsql {
+ SELECT cube(2)
+ }
+} {0 8.0}
+
+
+# Register only the sqr() function.
+#
+do_test loadext2-1.9 {
+ sqlite3_auto_extension_sqr
+ sqlite3 db test.db
+ catchsql {
+ SELECT sqr(2)
+ }
+} {0 4.0}
+do_test loadext2-1.10 {
+ catchsql {
+ SELECT cube(2)
+ }
+} {1 {no such function: cube}}
+
+# Register only the cube() function.
+#
+do_test loadext2-1.11 {
+ sqlite3_reset_auto_extension
+ sqlite3_auto_extension_cube
+ sqlite3 db test.db
+ catchsql {
+ SELECT sqr(2)
+ }
+} {1 {no such function: sqr}}
+do_test loadext2-1.12 {
+ catchsql {
+ SELECT cube(2)
+ }
+} {0 8.0}
+
+# Register a broken entry point.
+#
+do_test loadext2-1.13 {
+ sqlite3_auto_extension_broken
+ set rc [catch {sqlite3 db test.db} errmsg]
+ lappend rc $errmsg
+} {1 {automatic extension loading failed: broken autoext!}}
+do_test loadext2-1.14 {
+ catchsql {
+ SELECT sqr(2)
+ }
+} {1 {no such function: sqr}}
+do_test loadext2-1.15 {
+ catchsql {
+ SELECT cube(2)
+ }
+} {0 8.0}
+
+
+sqlite3_reset_auto_extension
+autoinstall_test_functions
+finish_test
diff --git a/test/lock.test b/test/lock.test
new file mode 100644
index 0000000..22f359c
--- /dev/null
+++ b/test/lock.test
@@ -0,0 +1,426 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is database locks.
+#
+# $Id: lock.test,v 1.40 2009/06/16 17:49:36 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create an alternative connection to the database
+#
+do_test lock-1.0 {
+ # Give a complex pathname to stress the path simplification logic in
+ # the vxworks driver and in test_async.
+ file mkdir tempdir/t1/t2
+ sqlite3 db2 ./tempdir/../tempdir/t1/.//t2/../../..//test.db
+ set dummy {}
+} {}
+do_test lock-1.1 {
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
+} {}
+do_test lock-1.2 {
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name} db2
+} {}
+do_test lock-1.3 {
+ execsql {CREATE TABLE t1(a int, b int)}
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
+} {t1}
+do_test lock-1.5 {
+ catchsql {
+ SELECT name FROM sqlite_master WHERE type='table' ORDER BY name
+ } db2
+} {0 t1}
+
+do_test lock-1.6 {
+ execsql {INSERT INTO t1 VALUES(1,2)}
+ execsql {SELECT * FROM t1}
+} {1 2}
+# Update: The schema is now brought up to date by test lock-1.5.
+# do_test lock-1.7.1 {
+# catchsql {SELECT * FROM t1} db2
+# } {1 {no such table: t1}}
+do_test lock-1.7.2 {
+ catchsql {SELECT * FROM t1} db2
+} {0 {1 2}}
+do_test lock-1.8 {
+ execsql {UPDATE t1 SET a=b, b=a} db2
+ execsql {SELECT * FROM t1} db2
+} {2 1}
+do_test lock-1.9 {
+ execsql {SELECT * FROM t1}
+} {2 1}
+do_test lock-1.10 {
+ execsql {BEGIN TRANSACTION}
+ execsql {UPDATE t1 SET a = 0 WHERE 0}
+ execsql {SELECT * FROM t1}
+} {2 1}
+do_test lock-1.11 {
+ catchsql {SELECT * FROM t1} db2
+} {0 {2 1}}
+do_test lock-1.12 {
+ execsql {ROLLBACK}
+ catchsql {SELECT * FROM t1}
+} {0 {2 1}}
+
+do_test lock-1.13 {
+ execsql {CREATE TABLE t2(x int, y int)}
+ execsql {INSERT INTO t2 VALUES(8,9)}
+ execsql {SELECT * FROM t2}
+} {8 9}
+do_test lock-1.14.1 {
+ catchsql {SELECT * FROM t2} db2
+} {0 {8 9}}
+do_test lock-1.14.2 {
+ catchsql {SELECT * FROM t1} db2
+} {0 {2 1}}
+do_test lock-1.15 {
+ catchsql {SELECT * FROM t2} db2
+} {0 {8 9}}
+
+do_test lock-1.16 {
+ db eval {SELECT * FROM t1} qv {
+ set x [db eval {SELECT * FROM t1}]
+ }
+ set x
+} {2 1}
+do_test lock-1.17 {
+ db eval {SELECT * FROM t1} qv {
+ set x [db eval {SELECT * FROM t2}]
+ }
+ set x
+} {8 9}
+
+# You cannot UPDATE a table from within the callback of a SELECT
+# on that same table because the SELECT has the table locked.
+#
+# 2006-08-16: Reads no longer block writes within the same
+# database connection.
+#
+#do_test lock-1.18 {
+# db eval {SELECT * FROM t1} qv {
+# set r [catch {db eval {UPDATE t1 SET a=b, b=a}} msg]
+# lappend r $msg
+# }
+# set r
+#} {1 {database table is locked}}
+
+# But you can UPDATE a different table from the one that is used in
+# the SELECT.
+#
+do_test lock-1.19 {
+ db eval {SELECT * FROM t1} qv {
+ set r [catch {db eval {UPDATE t2 SET x=y, y=x}} msg]
+ lappend r $msg
+ }
+ set r
+} {0 {}}
+do_test lock-1.20 {
+ execsql {SELECT * FROM t2}
+} {9 8}
+
+# It is possible to do a SELECT of the same table within the
+# callback of another SELECT on that same table because two
+# or more read-only cursors can be open at once.
+#
+do_test lock-1.21 {
+ db eval {SELECT * FROM t1} qv {
+ set r [catch {db eval {SELECT a FROM t1}} msg]
+ lappend r $msg
+ }
+ set r
+} {0 2}
+
+# Under UNIX you can do two SELECTs at once with different database
+# connections, because UNIX supports reader/writer locks. Under windows,
+# this is not possible.
+#
+if {$::tcl_platform(platform)=="unix"} {
+ do_test lock-1.22 {
+ db eval {SELECT * FROM t1} qv {
+ set r [catch {db2 eval {SELECT a FROM t1}} msg]
+ lappend r $msg
+ }
+ set r
+ } {0 2}
+}
+integrity_check lock-1.23
+
+# If one thread has a transaction another thread cannot start
+# a transaction. -> Not true in version 3.0. But if one thread
+# as a RESERVED lock another thread cannot acquire one.
+#
+do_test lock-2.1 {
+ execsql {BEGIN TRANSACTION}
+ execsql {UPDATE t1 SET a = 0 WHERE 0}
+ execsql {BEGIN TRANSACTION} db2
+ set r [catch {execsql {UPDATE t1 SET a = 0 WHERE 0} db2} msg]
+ execsql {ROLLBACK} db2
+ lappend r $msg
+} {1 {database is locked}}
+
+# A thread can read when another has a RESERVED lock.
+#
+do_test lock-2.2 {
+ catchsql {SELECT * FROM t2} db2
+} {0 {9 8}}
+
+# If the other thread (the one that does not hold the transaction with
+# a RESERVED lock) tries to get a RESERVED lock, we do get a busy callback
+# as long as we were not orginally holding a READ lock.
+#
+do_test lock-2.3.1 {
+ proc callback {count} {
+ set ::callback_value $count
+ break
+ }
+ set ::callback_value {}
+ db2 busy callback
+ # db2 does not hold a lock so we should get a busy callback here
+ set r [catch {execsql {UPDATE t1 SET a=b, b=a} db2} msg]
+ lappend r $msg
+ lappend r $::callback_value
+} {1 {database is locked} 0}
+do_test lock-2.3.2 {
+ set ::callback_value {}
+ execsql {BEGIN; SELECT rowid FROM sqlite_master LIMIT 1} db2
+ # This time db2 does hold a read lock. No busy callback this time.
+ set r [catch {execsql {UPDATE t1 SET a=b, b=a} db2} msg]
+ lappend r $msg
+ lappend r $::callback_value
+} {1 {database is locked} {}}
+catch {execsql {ROLLBACK} db2}
+do_test lock-2.4.1 {
+ proc callback {count} {
+ lappend ::callback_value $count
+ if {$count>4} break
+ }
+ set ::callback_value {}
+ db2 busy callback
+ # We get a busy callback because db2 is not holding a lock
+ set r [catch {execsql {UPDATE t1 SET a=b, b=a} db2} msg]
+ lappend r $msg
+ lappend r $::callback_value
+} {1 {database is locked} {0 1 2 3 4 5}}
+do_test lock-2.4.2 {
+ proc callback {count} {
+ lappend ::callback_value $count
+ if {$count>4} break
+ }
+ set ::callback_value {}
+ db2 busy callback
+ execsql {BEGIN; SELECT rowid FROM sqlite_master LIMIT 1} db2
+ # No busy callback this time because we are holding a lock
+ set r [catch {execsql {UPDATE t1 SET a=b, b=a} db2} msg]
+ lappend r $msg
+ lappend r $::callback_value
+} {1 {database is locked} {}}
+catch {execsql {ROLLBACK} db2}
+do_test lock-2.5 {
+ proc callback {count} {
+ lappend ::callback_value $count
+ if {$count>4} break
+ }
+ set ::callback_value {}
+ db2 busy callback
+ set r [catch {execsql {SELECT * FROM t1} db2} msg]
+ lappend r $msg
+ lappend r $::callback_value
+} {0 {2 1} {}}
+execsql {ROLLBACK}
+
+# Test the built-in busy timeout handler
+#
+do_test lock-2.8 {
+ db2 timeout 400
+ execsql BEGIN
+ execsql {UPDATE t1 SET a = 0 WHERE 0}
+ catchsql {BEGIN EXCLUSIVE;} db2
+} {1 {database is locked}}
+do_test lock-2.9 {
+ db2 timeout 0
+ execsql COMMIT
+} {}
+integrity_check lock-2.10
+
+# Try to start two transactions in a row
+#
+do_test lock-3.1 {
+ execsql {BEGIN TRANSACTION}
+ set r [catch {execsql {BEGIN TRANSACTION}} msg]
+ execsql {ROLLBACK}
+ lappend r $msg
+} {1 {cannot start a transaction within a transaction}}
+integrity_check lock-3.2
+
+# Make sure the busy handler and error messages work when
+# opening a new pointer to the database while another pointer
+# has the database locked.
+#
+do_test lock-4.1 {
+ db2 close
+ catch {db eval ROLLBACK}
+ db eval BEGIN
+ db eval {UPDATE t1 SET a=0 WHERE 0}
+ sqlite3 db2 ./test.db
+ catchsql {UPDATE t1 SET a=0} db2
+} {1 {database is locked}}
+do_test lock-4.2 {
+ set ::callback_value {}
+ set rc [catch {db2 eval {UPDATE t1 SET a=0}} msg]
+ lappend rc $msg $::callback_value
+} {1 {database is locked} {}}
+do_test lock-4.3 {
+ proc callback {count} {
+ lappend ::callback_value $count
+ if {$count>4} break
+ }
+ db2 busy callback
+ set rc [catch {db2 eval {UPDATE t1 SET a=0}} msg]
+ lappend rc $msg $::callback_value
+} {1 {database is locked} {0 1 2 3 4 5}}
+execsql {ROLLBACK}
+
+# When one thread is writing, other threads cannot read. Except if the
+# writing thread is writing to its temporary tables, the other threads
+# can still read. -> Not so in 3.0. One thread can read while another
+# holds a RESERVED lock.
+#
+proc tx_exec {sql} {
+ db2 eval $sql
+}
+do_test lock-5.1 {
+ execsql {
+ SELECT * FROM t1
+ }
+} {2 1}
+do_test lock-5.2 {
+ db function tx_exec tx_exec
+ catchsql {
+ INSERT INTO t1(a,b) SELECT 3, tx_exec('SELECT y FROM t2 LIMIT 1');
+ }
+} {0 {}}
+
+ifcapable tempdb {
+ do_test lock-5.3 {
+ execsql {
+ CREATE TEMP TABLE t3(x);
+ SELECT * FROM t3;
+ }
+ } {}
+ do_test lock-5.4 {
+ catchsql {
+ INSERT INTO t3 SELECT tx_exec('SELECT y FROM t2 LIMIT 1');
+ }
+ } {0 {}}
+ do_test lock-5.5 {
+ execsql {
+ SELECT * FROM t3;
+ }
+ } {8}
+ do_test lock-5.6 {
+ catchsql {
+ UPDATE t1 SET a=tx_exec('SELECT x FROM t2');
+ }
+ } {0 {}}
+ do_test lock-5.7 {
+ execsql {
+ SELECT * FROM t1;
+ }
+ } {9 1 9 8}
+ do_test lock-5.8 {
+ catchsql {
+ UPDATE t3 SET x=tx_exec('SELECT x FROM t2');
+ }
+ } {0 {}}
+ do_test lock-5.9 {
+ execsql {
+ SELECT * FROM t3;
+ }
+ } {9}
+}
+
+do_test lock-6.1 {
+ execsql {
+ CREATE TABLE t4(a PRIMARY KEY, b);
+ INSERT INTO t4 VALUES(1, 'one');
+ INSERT INTO t4 VALUES(2, 'two');
+ INSERT INTO t4 VALUES(3, 'three');
+ }
+
+ set STMT [sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 TAIL]
+ sqlite3_step $STMT
+
+ execsql { DELETE FROM t4 }
+ execsql { SELECT * FROM sqlite_master } db2
+ execsql { SELECT * FROM t4 } db2
+} {}
+
+do_test lock-6.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO t4 VALUES(1, 'one');
+ INSERT INTO t4 VALUES(2, 'two');
+ INSERT INTO t4 VALUES(3, 'three');
+ COMMIT;
+ }
+
+ execsql { SELECT * FROM t4 } db2
+} {1 one 2 two 3 three}
+
+do_test lock-6.3 {
+ execsql { SELECT a FROM t4 ORDER BY a } db2
+} {1 2 3}
+
+do_test lock-6.4 {
+ execsql { PRAGMA integrity_check } db2
+} {ok}
+
+do_test lock-6.5 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+# At one point the following set of conditions would cause SQLite to
+# retain a RESERVED or EXCLUSIVE lock after the transaction was committed:
+#
+# * The journal-mode is set to something other than 'delete', and
+# * there exists one or more active read-only statements, and
+# * a transaction that modified zero database pages is committed.
+#
+set temp_status unlocked
+if {$TEMP_STORE>=2} {set temp_status unknown}
+do_test lock-7.1 {
+ set STMT [sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test lock-7.2 {
+ execsql { PRAGMA lock_status }
+} [list main shared temp $temp_status]
+do_test lock-7.3 {
+ execsql {
+ PRAGMA journal_mode = truncate;
+ BEGIN;
+ UPDATE t4 SET a = 10 WHERE 0;
+ COMMIT;
+ }
+ execsql { PRAGMA lock_status }
+} [list main shared temp $temp_status]
+do_test lock-7.4 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+do_test lock-999.1 {
+ rename db2 {}
+} {}
+
+finish_test
diff --git a/test/lock2.test b/test/lock2.test
new file mode 100644
index 0000000..ea2e557
--- /dev/null
+++ b/test/lock2.test
@@ -0,0 +1,111 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is database locks between competing processes.
+#
+# $Id: lock2.test,v 1.11 2009/05/01 10:55:34 danielk1977 Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+
+
+# Simple locking test case:
+#
+# lock2-1.1: Connect a second process to the database.
+# lock2-1.2: Establish a RESERVED lock with this process.
+# lock2-1.3: Get a SHARED lock with the second process.
+# lock2-1.4: Try for a RESERVED lock with process 2. This fails.
+# lock2-1.5: Try to upgrade the first process to EXCLUSIVE, this fails so
+# it gets PENDING.
+# lock2-1.6: Release the SHARED lock held by the second process.
+# lock2-1.7: Attempt to reaquire a SHARED lock with the second process.
+# this fails due to the PENDING lock.
+# lock2-1.8: Ensure the first process can now upgrade to EXCLUSIVE.
+#
+do_test lock2-1.1 {
+ set ::tf1 [launch_testfixture]
+ testfixture $::tf1 {
+ sqlite3 db test.db -key xyzzy
+ db eval {select * from sqlite_master}
+ }
+} {}
+do_test lock2-1.1.1 {
+ execsql {pragma lock_status}
+} {main unlocked temp closed}
+sqlite3_soft_heap_limit 0
+do_test lock2-1.2 {
+ execsql {
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ }
+} {}
+do_test lock2-1.3 {
+ testfixture $::tf1 {
+ db eval {
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ }
+ }
+} {}
+do_test lock2-1.4 {
+ testfixture $::tf1 {
+ catch { db eval { CREATE TABLE def(d, e, f) } } msg
+ set msg
+ }
+} {database is locked}
+do_test lock2-1.5 {
+ catchsql {
+ COMMIT;
+ }
+} {1 {database is locked}}
+do_test lock2-1.6 {
+ testfixture $::tf1 {
+ db eval {
+ SELECT * FROM sqlite_master;
+ COMMIT;
+ }
+ }
+} {}
+do_test lock2-1.7 {
+ testfixture $::tf1 {
+ catch { db eval {
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ } } msg
+ set msg
+ }
+} {database is locked}
+do_test lock2-1.8 {
+ catchsql {
+ COMMIT;
+ }
+} {0 {}}
+do_test lock2-1.9 {
+ execsql {
+ SELECT * FROM sqlite_master;
+ }
+} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}"
+catch flush_async_queue
+do_test lock2-1.10 {
+ testfixture $::tf1 {
+ db eval {
+ SELECT * FROM sqlite_master;
+ }
+ }
+} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}"
+
+catch {testfixture $::tf1 {db close}}
+catch {close $::tf1}
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+
+finish_test
diff --git a/test/lock3.test b/test/lock3.test
new file mode 100644
index 0000000..f771a19
--- /dev/null
+++ b/test/lock3.test
@@ -0,0 +1,79 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is database locks and the operation of the
+# DEFERRED, IMMEDIATE, and EXCLUSIVE keywords as modifiers to the
+# BEGIN command.
+#
+# $Id: lock3.test,v 1.4 2009/03/28 15:04:24 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Establish two connections to the same database. Put some
+# sample data into the database.
+#
+do_test lock3-1.1 {
+ file mkdir tempdir/t1/t2/t3
+ sqlite3 db2 ./tempdir/t1//t2/./t3//./../..//./../../tempdir/..//test.db//
+ execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ }
+ execsql {
+ SELECT * FROM t1
+ } db2
+} 1
+
+# Get a deferred lock on the database using one connection. The
+# other connection should still be able to write.
+#
+do_test lock3-2.1 {
+ execsql {BEGIN DEFERRED TRANSACTION}
+ execsql {INSERT INTO t1 VALUES(2)} db2
+ execsql {END TRANSACTION}
+ execsql {SELECT * FROM t1}
+} {1 2}
+
+# Get an immediate lock on the database using one connection. The
+# other connection should be able to read the database but not write
+# it.
+#
+do_test lock3-3.1 {
+ execsql {BEGIN IMMEDIATE TRANSACTION}
+ catchsql {SELECT * FROM t1} db2
+} {0 {1 2}}
+do_test lock3-3.2 {
+ catchsql {INSERT INTO t1 VALUES(3)} db2
+} {1 {database is locked}}
+do_test lock3-3.3 {
+ execsql {END TRANSACTION}
+} {}
+
+
+# Get an exclusive lock on the database using one connection. The
+# other connection should be unable to read or write the database.
+#
+do_test lock3-4.1 {
+ execsql {BEGIN EXCLUSIVE TRANSACTION}
+ catchsql {SELECT * FROM t1} db2
+} {1 {database is locked}}
+do_test lock3-4.2 {
+ catchsql {INSERT INTO t1 VALUES(3)} db2
+} {1 {database is locked}}
+do_test lock3-4.3 {
+ execsql {END TRANSACTION}
+} {}
+
+catch {db2 close}
+
+finish_test
diff --git a/test/lock4.test b/test/lock4.test
new file mode 100644
index 0000000..b0b1c74
--- /dev/null
+++ b/test/lock4.test
@@ -0,0 +1,118 @@
+# 2007 April 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is database locks.
+#
+# $Id: lock4.test,v 1.10 2009/05/06 00:52:41 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_not_use_codec
+
+# Initialize the test.db database so that it is non-empty
+#
+do_test lock4-1.1 {
+ db eval {
+ PRAGMA auto_vacuum=OFF;
+ CREATE TABLE t1(x);
+ }
+ forcedelete test2.db test2.db-journal
+ sqlite3 db2 test2.db
+ db2 eval {
+ PRAGMA auto_vacuum=OFF;
+ CREATE TABLE t2(x)
+ }
+ db2 close
+ list [file size test.db] [file size test2.db]
+} {2048 2048}
+
+# Create a script to drive a separate process that will
+#
+# 1. Create a second database test2.db
+# 2. Get an exclusive lock on test2.db
+# 3. Add an entry to test.db in table t1, waiting as necessary.
+# 4. Commit the change to test2.db.
+#
+# Meanwhile, this process will:
+#
+# A. Get an exclusive lock on test.db
+# B. Attempt to read from test2.db but get an SQLITE_BUSY error.
+# C. Commit the changes to test.db thus alloing the other process
+# to continue.
+#
+do_test lock4-1.2 {
+
+ # Create a script for the second process to run.
+ #
+ set out [open test2-script.tcl w]
+ puts $out "sqlite3_test_control_pending_byte [set sqlite_pending_byte]"
+ puts $out {
+ sqlite3 db2 test2.db
+ db2 eval {
+ BEGIN;
+ INSERT INTO t2 VALUES(2);
+ }
+ sqlite3 db test.db
+ db timeout 1000000
+ db eval {
+ INSERT INTO t1 VALUES(2);
+ }
+ db close
+ db2 eval COMMIT
+ exit
+ }
+ close $out
+
+ # Begin a transaction on test.db.
+ db eval {
+ BEGIN EXCLUSIVE;
+ INSERT INTO t1 VALUES(1);
+ }
+
+ # Kick off the second process.
+ exec [info nameofexec] ./test2-script.tcl &
+
+ # Wait until the second process has started its transaction on test2.db.
+ while {![file exists test2.db-journal]} {
+ after 10
+ }
+
+ # Try to write to test2.db. We are locked out.
+ sqlite3 db2 test2.db
+ catchsql {
+ INSERT INTO t2 VALUES(1)
+ } db2
+} {1 {database is locked}}
+do_test lock4-1.3 {
+ db eval {
+ COMMIT;
+ }
+ while {[file exists test2.db-journal]} {
+ after 10
+ }
+ # The other process has committed its transaction on test2.db by
+ # deleting the journal file. But it might retain the lock for a
+ # fraction longer
+ #
+ after 25
+ db2 eval {
+ SELECT * FROM t2
+ }
+} {2}
+
+
+do_test lock4-999.1 {
+ rename db2 {}
+} {}
+
+finish_test
diff --git a/test/lock5.test b/test/lock5.test
new file mode 100644
index 0000000..f0d4955
--- /dev/null
+++ b/test/lock5.test
@@ -0,0 +1,195 @@
+# 2008 June 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is database locks.
+#
+# $Id: lock5.test,v 1.6 2008/12/04 12:34:16 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# This file is only run if using the unix backend compiled with the
+# SQLITE_ENABLE_LOCKING_STYLE macro.
+db close
+if {[catch {sqlite3 db test.db -vfs unix-none} msg]} {
+ finish_test
+ return
+}
+db close
+forcedelete test.db.lock
+
+ifcapable lock_proxy_pragmas {
+ set ::using_proxy 0
+ foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
+ set ::using_proxy $value
+ }
+ # Disable the proxy locking for these tests
+ set env(SQLITE_FORCE_PROXY_LOCKING) "0"
+}
+
+
+do_test lock5-dotfile.1 {
+ sqlite3 db test.db -vfs unix-dotfile
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ }
+} {}
+
+do_test lock5-dotfile.2 {
+ file exists test.db.lock
+} {1}
+
+do_test lock5-dotfile.3 {
+ execsql COMMIT
+ file exists test.db.lock
+} {0}
+
+do_test lock5-dotfile.4 {
+ sqlite3 db2 test.db -vfs unix-dotfile
+ execsql {
+ INSERT INTO t1 VALUES('a', 'b');
+ SELECT * FROM t1;
+ } db2
+} {a b}
+
+do_test lock5-dotfile.5 {
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ } db2
+} {a b}
+
+do_test lock5-dotfile.6 {
+ file exists test.db.lock
+} {1}
+
+do_test lock5-dotfile.7 {
+ catchsql { SELECT * FROM t1; }
+} {1 {database is locked}}
+
+do_test lock5-dotfile.8 {
+ execsql {
+ SELECT * FROM t1;
+ ROLLBACK;
+ } db2
+} {a b}
+
+do_test lock5-dotfile.9 {
+ catchsql { SELECT * FROM t1; }
+} {0 {a b}}
+
+do_test lock5-dotfile.10 {
+ file exists test.db.lock
+} {0}
+
+do_test lock5-dotfile.X {
+ db2 close
+ execsql {BEGIN EXCLUSIVE}
+ db close
+ file exists test.db.lock
+} {0}
+
+#####################################################################
+
+forcedelete test.db
+if {[catch {sqlite3 db test.db -vfs unix-flock} msg]} {
+ finish_test
+ return
+}
+
+do_test lock5-flock.1 {
+ sqlite3 db test.db -vfs unix-flock
+ execsql {
+ CREATE TABLE t1(a, b);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ }
+} {}
+
+# Make sure we are not accidentally using the dotfile locking scheme.
+do_test lock5-flock.2 {
+ file exists test.db.lock
+} {0}
+
+do_test lock5-flock.3 {
+ catch { sqlite3 db2 test.db -vfs unix-flock }
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database is locked}}
+
+do_test lock5-flock.4 {
+ execsql COMMIT
+ catchsql { SELECT * FROM t1 } db2
+} {0 {1 2}}
+
+do_test lock5-flock.5 {
+ execsql BEGIN
+ catchsql { SELECT * FROM t1 } db2
+} {0 {1 2}}
+
+do_test lock5-flock.6 {
+ execsql {SELECT * FROM t1}
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database is locked}}
+
+do_test lock5-flock.7 {
+ db close
+ catchsql { SELECT * FROM t1 } db2
+} {0 {1 2}}
+
+do_test lock5-flock.8 {
+ db2 close
+} {}
+
+#####################################################################
+
+do_test lock5-none.1 {
+ sqlite3 db test.db -vfs unix-none
+ sqlite3 db2 test.db -vfs unix-none
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+} {}
+do_test lock5-none.2 {
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+do_test lock5-flock.3 {
+ execsql { SELECT * FROM t1 } db2
+} {1 2}
+do_test lock5-none.4 {
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ } db2
+} {1 2}
+do_test lock5-none.5 {
+ execsql COMMIT
+ execsql {SELECT * FROM t1} db2
+} {1 2}
+
+ifcapable memorymanage {
+ do_test lock5-none.6 {
+ sqlite3_release_memory 1000000
+ execsql {SELECT * FROM t1} db2
+ } {1 2 3 4}
+}
+
+do_test lock5-flock.X {
+ db close
+ db2 close
+} {}
+
+ifcapable lock_proxy_pragmas {
+ set env(SQLITE_FORCE_PROXY_LOCKING) $::using_proxy
+}
+
+finish_test
diff --git a/test/lock6.test b/test/lock6.test
new file mode 100644
index 0000000..b47d18f
--- /dev/null
+++ b/test/lock6.test
@@ -0,0 +1,167 @@
+# 2008 October 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is database locks.
+#
+# $Id: lock6.test,v 1.3 2009/02/05 16:31:46 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Launch another testfixture process to be controlled by this one. A
+# channel name is returned that may be passed as the first argument to proc
+# 'testfixture' to execute a command. The child testfixture process is shut
+# down by closing the channel.
+proc launch_testfixture {} {
+ set prg [info nameofexec]
+ if {$prg eq ""} {
+ set prg [file join . testfixture]
+ }
+ set chan [open "|$prg tf_main2.tcl" r+]
+ fconfigure $chan -buffering line
+ return $chan
+}
+
+# Execute a command in a child testfixture process, connected by two-way
+# channel $chan. Return the result of the command, or an error message.
+proc testfixture {chan cmd} {
+ puts $chan $cmd
+ puts $chan OVER
+ set r ""
+ while { 1 } {
+ set line [gets $chan]
+ if { $line == "OVER" } {
+ return $r
+ }
+ append r $line
+ }
+}
+
+# Write the main loop for the child testfixture processes into file
+# tf_main2.tcl. The parent (this script) interacts with the child processes
+# via a two way pipe. The parent writes a script to the stdin of the child
+# process, followed by the word "OVER" on a line of its own. The child
+# process evaluates the script and writes the results to stdout, followed
+# by an "OVER" of its own.
+set f [open tf_main2.tcl w]
+puts $f {
+ set l [open log w]
+ set script ""
+ while {![eof stdin]} {
+ flush stdout
+ set line [gets stdin]
+ puts $l "READ $line"
+ if { $line == "OVER" } {
+ catch {eval $script} result
+ puts $result
+ puts $l "WRITE $result"
+ puts OVER
+ puts $l "WRITE OVER"
+ flush stdout
+ set script ""
+ } else {
+ append script $line
+ append script " ; "
+ }
+ }
+ close $l
+}
+close $f
+
+
+ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
+ set sqlite_hostid_num 1
+
+ set using_proxy 0
+ foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
+ set using_proxy $value
+ }
+
+ # Test the lock_proxy_file pragmas.
+ #
+ set env(SQLITE_FORCE_PROXY_LOCKING) "1"
+
+ do_test lock6-1.1 {
+ set ::tf1 [launch_testfixture]
+ testfixture $::tf1 "sqlite3_test_control_pending_byte $::sqlite_pending_byte"
+ testfixture $::tf1 {
+ set sqlite_hostid_num 2
+ sqlite3 db test.db -key xyzzy
+ set lockpath [db eval {
+ PRAGMA lock_proxy_file=":auto:";
+ select * from sqlite_master;
+ PRAGMA lock_proxy_file;
+ }]
+ string match "*test.db:auto:" $lockpath
+ }
+ } {1}
+
+ set sqlite_hostid_num 3
+ do_test lock6-1.2 {
+ execsql {pragma lock_status}
+ } {main unlocked temp closed}
+
+ sqlite3_soft_heap_limit 0
+ do_test lock6-1.3 {
+ list [catch {
+ sqlite3 db test.db
+ execsql { select * from sqlite_master }
+ } msg] $msg
+ } {1 {database is locked}}
+
+ do_test lock6-1.4 {
+ set lockpath [execsql {
+ PRAGMA lock_proxy_file=":auto:";
+ PRAGMA lock_proxy_file;
+ } db]
+ set lockpath
+ } {{:auto: (not held)}}
+
+ do_test lock6-1.4.1 {
+ catchsql {
+ PRAGMA lock_proxy_file="notmine";
+ select * from sqlite_master;
+ } db
+ } {1 {database is locked}}
+
+ do_test lock6-1.4.2 {
+ execsql {
+ PRAGMA lock_proxy_file;
+ } db
+ } {notmine}
+
+ do_test lock6-1.5 {
+ testfixture $::tf1 {
+ db eval {
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ }
+ }
+ } {}
+
+ catch {testfixture $::tf1 {db close}}
+
+ do_test lock6-1.6 {
+ execsql {
+ PRAGMA lock_proxy_file="mine";
+ select * from sqlite_master;
+ } db
+ } {}
+
+ catch {close $::tf1}
+ set env(SQLITE_FORCE_PROXY_LOCKING) $using_proxy
+ set sqlite_hostid_num 0
+
+ sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+}
+
+finish_test
diff --git a/test/lock7.test b/test/lock7.test
new file mode 100644
index 0000000..49bc147
--- /dev/null
+++ b/test/lock7.test
@@ -0,0 +1,61 @@
+# 2009 August 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Check that reading the database schema from within an active transaction
+# does not establish a SHARED lock on the database file if one is not
+# already held (or, more accurately, that the SHARED lock is released after
+# reading the database schema).
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test lock7-1.1 {
+ execsql { CREATE TABLE t1(a, b) }
+ db close
+
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+
+ db1 eval {BEGIN}
+ db2 eval {BEGIN}
+} {}
+
+do_test lock7-1.2 {
+ execsql { PRAGMA lock_status } db1
+} {main unlocked temp closed}
+do_test lock7-1.3 {
+ execsql { PRAGMA lock_status } db2
+} {main unlocked temp closed}
+
+do_test lock7-1.4 {
+ catchsql { INSERT INTO t1 VALUES(1, 1) } db1
+} {0 {}}
+do_test lock7-1.5 {
+ catchsql { INSERT INTO t1 VALUES(2, 2) } db2
+} {1 {database is locked}}
+
+do_test lock7-1.6 {
+ execsql { PRAGMA lock_status } db1
+} {main reserved temp closed}
+do_test lock7-1.7 {
+ execsql { PRAGMA lock_status } db2
+} {main unlocked temp closed}
+
+do_test lock7-1.8 {
+ execsql { COMMIT } db1
+} {}
+
+db1 close
+db2 close
+
+finish_test
+
diff --git a/test/lock_common.tcl b/test/lock_common.tcl
new file mode 100644
index 0000000..bc1eb86
--- /dev/null
+++ b/test/lock_common.tcl
@@ -0,0 +1,174 @@
+# 2010 April 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file contains code used by several different test scripts. The
+# code in this file allows testfixture to control another process (or
+# processes) to test locking.
+#
+
+proc do_multiclient_test {varname script} {
+
+ foreach code [list {
+ if {[info exists ::G(valgrind)]} { db close ; continue }
+ set ::code2_chan [launch_testfixture]
+ set ::code3_chan [launch_testfixture]
+ proc code2 {tcl} { testfixture $::code2_chan $tcl }
+ proc code3 {tcl} { testfixture $::code3_chan $tcl }
+ set tn 1
+ } {
+ proc code2 {tcl} { uplevel #0 $tcl }
+ proc code3 {tcl} { uplevel #0 $tcl }
+ set tn 2
+ }] {
+ faultsim_delete_and_reopen
+
+ proc code1 {tcl} { uplevel #0 $tcl }
+
+ # Open connections [db2] and [db3]. Depending on which iteration this
+ # is, the connections may be created in this interpreter, or in
+ # interpreters running in other OS processes. As such, the [db2] and [db3]
+ # commands should only be accessed within [code2] and [code3] blocks,
+ # respectively.
+ #
+ eval $code
+ code2 { sqlite3 db2 test.db }
+ code3 { sqlite3 db3 test.db }
+
+ # Shorthand commands. Execute SQL using database connection [db2] or
+ # [db3]. Return the results.
+ #
+ proc sql1 {sql} { db eval $sql }
+ proc sql2 {sql} { code2 [list db2 eval $sql] }
+ proc sql3 {sql} { code3 [list db3 eval $sql] }
+
+ proc csql1 {sql} { list [catch { sql1 $sql } msg] $msg }
+ proc csql2 {sql} { list [catch { sql2 $sql } msg] $msg }
+ proc csql3 {sql} { list [catch { sql3 $sql } msg] $msg }
+
+ uplevel set $varname $tn
+ uplevel $script
+
+ catch { code2 { db2 close } }
+ catch { code3 { db3 close } }
+ catch { close $::code2_chan }
+ catch { close $::code3_chan }
+ catch { db close }
+ }
+}
+
+# Launch another testfixture process to be controlled by this one. A
+# channel name is returned that may be passed as the first argument to proc
+# 'testfixture' to execute a command. The child testfixture process is shut
+# down by closing the channel.
+proc launch_testfixture {{prg ""}} {
+ write_main_loop
+ if {$prg eq ""} { set prg [info nameofexec] }
+ if {$prg eq ""} { set prg testfixture }
+ if {[file tail $prg]==$prg} { set prg [file join . $prg] }
+ set chan [open "|$prg tf_main.tcl" r+]
+ fconfigure $chan -buffering line
+ set rc [catch {
+ testfixture $chan "sqlite3_test_control_pending_byte $::sqlite_pending_byte"
+ }]
+ if {$rc} {
+ testfixture $chan "set ::sqlite_pending_byte $::sqlite_pending_byte"
+ }
+ return $chan
+}
+
+# Execute a command in a child testfixture process, connected by two-way
+# channel $chan. Return the result of the command, or an error message.
+#
+proc testfixture {chan cmd} {
+ puts $chan $cmd
+ puts $chan OVER
+ set r ""
+ while { 1 } {
+ set line [gets $chan]
+ if { $line == "OVER" } {
+ set res [lindex $r 1]
+ if { [lindex $r 0] } { error $res }
+ return $res
+ }
+ if {[eof $chan]} {
+ return "ERROR: Child process hung up"
+ }
+ append r $line
+ }
+}
+
+proc testfixture_nb_cb {varname chan} {
+ if {[eof $chan]} {
+ append ::tfnb($chan) "ERROR: Child process hung up"
+ set line "OVER"
+ } else {
+ set line [gets $chan]
+ }
+
+ if { $line == "OVER" } {
+ set $varname [lindex $::tfnb($chan) 1]
+ unset ::tfnb($chan)
+ close $chan
+ } else {
+ append ::tfnb($chan) $line
+ }
+}
+
+proc testfixture_nb {varname cmd} {
+ set chan [launch_testfixture]
+ set ::tfnb($chan) ""
+ fconfigure $chan -blocking 0 -buffering none
+ puts $chan $cmd
+ puts $chan OVER
+ fileevent $chan readable [list testfixture_nb_cb $varname $chan]
+ return ""
+}
+
+# Write the main loop for the child testfixture processes into file
+# tf_main.tcl. The parent (this script) interacts with the child processes
+# via a two way pipe. The parent writes a script to the stdin of the child
+# process, followed by the word "OVER" on a line of its own. The child
+# process evaluates the script and writes the results to stdout, followed
+# by an "OVER" of its own.
+#
+set main_loop_written 0
+proc write_main_loop {} {
+ if {$::main_loop_written} return
+ set wrapper ""
+ if {[sqlite3 -has-codec] && [info exists ::do_not_use_codec]==0} {
+ set wrapper "
+ rename sqlite3 sqlite_orig
+ proc sqlite3 {args} {[info body sqlite3]}
+ "
+ }
+
+ set fd [open tf_main.tcl w]
+ puts $fd [string map [list %WRAPPER% $wrapper] {
+ %WRAPPER%
+ set script ""
+ while {![eof stdin]} {
+ flush stdout
+ set line [gets stdin]
+ if { $line == "OVER" } {
+ set rc [catch {eval $script} result]
+ puts [list $rc $result]
+ puts OVER
+ flush stdout
+ set script ""
+ } else {
+ append script $line
+ append script "\n"
+ }
+ }
+ }]
+ close $fd
+ set main_loop_written 1
+}
+
diff --git a/test/lookaside.test b/test/lookaside.test
new file mode 100644
index 0000000..0b239a0
--- /dev/null
+++ b/test/lookaside.test
@@ -0,0 +1,132 @@
+# 2008 August 01
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests for the lookaside memory allocator.
+#
+# $Id: lookaside.test,v 1.10 2009/04/09 01:23:49 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !lookaside {
+ finish_test
+ return
+}
+
+# The tests in this file configure the lookaside allocator after a
+# connection is opened. This will not work if there is any "presql"
+# configured (SQL run within the [sqlite3] wrapper in tester.tcl).
+if {[info exists ::G(perm:presql)]} {
+ finish_test
+ return
+}
+
+catch {db close}
+sqlite3_shutdown
+sqlite3_config_pagecache 0 0
+sqlite3_config_scratch 0 0
+sqlite3_initialize
+autoinstall_test_functions
+sqlite3 db test.db
+
+# Make sure sqlite3_db_config() and sqlite3_db_status are working.
+#
+do_test lookaside-1.1 {
+ catch {sqlite3_config_error db}
+} {0}
+
+do_test lookaside-1.2 {
+ sqlite3_db_config_lookaside db 1 18 18
+} {0}
+do_test lookaside-1.3.1 {
+ sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0
+} {0 0 0}
+do_test lookaside-1.3.2 {
+ sqlite3_db_status db DBSTATUS_LOOKASIDE_HIT 0
+} {0 0 0}
+do_test lookaside-1.3.3 {
+ sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_SIZE 0
+} {0 0 0}
+do_test lookaside-1.3.4 {
+ sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_FULL 0
+} {0 0 0}
+
+do_test lookaside-1.4 {
+ db eval {CREATE TABLE t1(w,x,y,z);}
+ foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break
+ set p [lindex [sqlite3_db_status db DBSTATUS_LOOKASIDE_HIT 0] 2]
+ set q [lindex [sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_SIZE 0] 2]
+ set r [lindex [sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_FULL 0] 2]
+ expr {$x==0 && $y<$z && $z==18 && $p>0 && $q>0 && $r>0}
+} {0}
+do_test lookaside-1.5 {
+ foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 1] break
+ expr {$x==0 && $y<$z && $z==18}
+} {0}
+do_test lookaside-1.6 {
+ foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break
+ expr {$x==0 && $y==$z && $y<18}
+} {1}
+do_test lookaside-1.7 {
+ db cache flush
+ foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break
+ expr {$x==0 && $y==0 && $z<18}
+} {1}
+do_test lookaside-1.8 {
+ db cache flush
+ foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 1] break
+ expr {$x==0 && $y==0 && $z<18}
+} {1}
+do_test lookaside-1.9 {
+ db cache flush
+ sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0
+} {0 0 0}
+
+do_test lookaside-2.1 {
+ sqlite3_db_config_lookaside db 0 100 1000
+} {0}
+do_test lookaside-2.2 {
+ db eval {CREATE TABLE t2(x);}
+ foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break
+ expr {$x==0 && $y<$z && $z>10 && $z<100}
+} {1}
+do_test lookaside-2.3 {
+ sqlite3_db_config_lookaside db 0 50 50
+} {5} ;# SQLITE_BUSY
+do_test lookaside-2.4 {
+ db cache flush
+ sqlite3_db_config_lookaside db 0 50 50
+} {0} ;# SQLITE_OK
+do_test lookaside-2.5 {
+ sqlite3_db_config_lookaside db 0 -1 50
+} {0} ;# SQLITE_OK
+do_test lookaside-2.6 {
+ sqlite3_db_config_lookaside db 0 50 -1
+} {0} ;# SQLITE_OK
+
+# sqlite3_db_status() with an invalid verb returns an error.
+#
+do_test lookaside-3.1 {
+ sqlite3_db_status db 99999 0
+} {1 0 0}
+
+# Test that an invalid verb on sqlite3_config() is detected and
+# reported as an error.
+#
+do_test lookaside-4.1 {
+ db close
+ sqlite3_shutdown
+ catch sqlite3_config_error
+} {0}
+sqlite3_initialize
+autoinstall_test_functions
+
+finish_test
diff --git a/test/main.test b/test/main.test
new file mode 100644
index 0000000..5bbc52b
--- /dev/null
+++ b/test/main.test
@@ -0,0 +1,518 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is exercising the code in main.c.
+#
+# $Id: main.test,v 1.32 2009/04/28 04:51:29 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Only do the next group of tests if the sqlite3_complete API is available
+#
+ifcapable {complete} {
+
+# Tests of the sqlite_complete() function.
+#
+do_test main-1.1 {
+ db complete {This is a test}
+} {0}
+do_test main-1.2.0 {
+ db complete {
+ }
+} {0}
+do_test main-1.2.1 {
+ db complete {}
+} {0}
+do_test main-1.3.0 {
+ db complete {
+ -- a comment ;
+ }
+} {0}
+do_test main-1.3.1 {
+ db complete {
+ /* a comment ; */
+ }
+} {0}
+do_test main-1.4.0 {
+ db complete {
+ -- a comment ;
+ ;
+ }
+} {1}
+do_test main-1.4.1 {
+ db complete {
+ /* a comment ; */
+ ;
+ }
+} {1}
+do_test main-1.4.2 {
+ db complete {
+ /* a comment ; */ ;
+ }
+} {1}
+do_test main-1.5 {
+ db complete {DROP TABLE 'xyz;}
+} {0}
+do_test main-1.6 {
+ db complete {DROP TABLE 'xyz';}
+} {1}
+do_test main-1.7 {
+ db complete {DROP TABLE "xyz;}
+} {0}
+do_test main-1.8 {
+ db complete {DROP TABLE "xyz';}
+} {0}
+do_test main-1.9 {
+ db complete {DROP TABLE "xyz";}
+} {1}
+do_test main-1.10 {
+ db complete {DROP TABLE xyz; hi}
+} {0}
+do_test main-1.11 {
+ db complete {DROP TABLE xyz; }
+} {1}
+do_test main-1.12 {
+ db complete {DROP TABLE xyz; -- hi }
+} {1}
+do_test main-1.13 {
+ db complete {DROP TABLE xyz; -- hi
+ }
+} {1}
+do_test main-1.14 {
+ db complete {SELECT a-b FROM t1; }
+} {1}
+do_test main-1.15 {
+ db complete {SELECT a/e FROM t1 }
+} {0}
+do_test main-1.16 {
+ db complete {
+ CREATE TABLE abc(x,y);
+ }
+} {1}
+ifcapable {trigger} {
+ do_test main-1.17 {
+ db complete {
+ CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr;
+ }
+ } {0}
+ do_test main-1.17.2 {
+ db complete {
+ EXPLAIN CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr;
+ }
+ } {0}
+ do_test main-1.17.3 {
+ db complete {
+ EXPLAIN QUERY PLAN CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr;
+ }
+ } {0}
+ do_test main-1.18 {
+ db complete {
+ CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr; END;
+ }
+ } {1}
+ do_test main-1.19 {
+ db complete {
+ CREATE TRIGGER xyz AFTER DELETE abc BEGIN
+ UPDATE pqr;
+ unknown command;
+ }
+ } {0}
+ do_test main-1.20 {
+ db complete {
+ CREATE TRIGGER xyz AFTER DELETE backend BEGIN
+ UPDATE pqr;
+ }
+ } {0}
+ do_test main-1.21 {
+ db complete {
+ CREATE TRIGGER xyz AFTER DELETE end BEGIN
+ SELECT a, b FROM end;
+ }
+ } {0}
+ do_test main-1.22 {
+ db complete {
+ CREATE TRIGGER xyz AFTER DELETE end BEGIN
+ SELECT a, b FROM end;
+ END;
+ }
+ } {1}
+ do_test main-1.23 {
+ db complete {
+ CREATE TRIGGER xyz AFTER DELETE end BEGIN
+ SELECT a, b FROM end;
+ END;
+ SELECT a, b FROM end;
+ }
+ } {1}
+ do_test main-1.24 {
+ db complete {
+ CREATE TRIGGER xyz AFTER DELETE [;end;] BEGIN
+ UPDATE pqr;
+ }
+ } {0}
+ do_test main-1.25 {
+ db complete {
+ CREATE TRIGGER xyz AFTER DELETE backend BEGIN
+ UPDATE cantor SET a=[;end;];;;
+ }
+ } {0}
+ do_test main-1.26 {
+ db complete {
+ CREATE -- a comment
+ TRIGGER exy AFTER DELETE backend BEGIN
+ UPDATE pqr SET a=5;
+ }
+ } {0}
+ do_test main-1.27.1 {
+ db complete {
+ CREATE -- a comment
+ TRIGGERX tangentxx AFTER DELETE backend BEGIN
+ UPDATE pqr SET a=5;
+ }
+ } {1}
+ do_test main-1.27.2 {
+ db complete {
+ CREATE/**/TRIGGER tiger00 AFTER DELETE backend BEGIN
+ UPDATE pqr SET a=5;
+ }
+ } {0}
+ ifcapable {explain} {
+ do_test main-1.27.3 {
+ db complete {
+ /* */ EXPLAIN -- A comment
+ CREATE/**/TRIGGER ezxyz12 AFTER DELETE backend BEGIN
+ UPDATE pqr SET a=5;
+ }
+ } {0}
+ }
+ do_test main-1.27.4 {
+ db complete {
+ BOGUS token
+ CREATE TRIGGER xyz AFTER DELETE backend BEGIN
+ UPDATE pqr SET a=5;
+ }
+ } {1}
+ ifcapable {explain} {
+ do_test main-1.27.5 {
+ db complete {
+ EXPLAIN
+ CREATE TEMP TRIGGER xyz AFTER DELETE backend BEGIN
+ UPDATE pqr SET a=5;
+ }
+ } {0}
+ }
+ do_test main-1.28 {
+ db complete {
+ CREATE TEMPORARY TRIGGER xyz AFTER DELETE backend BEGIN
+ UPDATE pqr SET a=5;
+ }
+ } {0}
+ do_test main-1.29 {
+ db complete {
+ CREATE TRIGGER xyz AFTER DELETE backend BEGIN
+ UPDATE pqr SET a=5;
+ EXPLAIN select * from xyz;
+ }
+ } {0}
+
+} ;# end ifcapable {complete}
+
+}
+do_test main-1.30 {
+ db complete {
+ CREATE TABLE /* In comment ; */
+ }
+} {0}
+do_test main-1.31 {
+ db complete {
+ CREATE TABLE /* In comment ; */ hi;
+ }
+} {1}
+do_test main-1.31 {
+ db complete {
+ CREATE TABLE /* In comment ; */;
+ }
+} {1}
+do_test main-1.32 {
+ db complete {
+ stuff;
+ /*
+ CREATE TABLE
+ multiple lines
+ of text
+ */
+ }
+} {1}
+do_test main-1.33 {
+ db complete {
+ /*
+ CREATE TABLE
+ multiple lines
+ of text;
+ }
+} {0}
+do_test main-1.34 {
+ db complete {
+ /*
+ CREATE TABLE
+ multiple lines "*/
+ of text;
+ }
+} {1}
+do_test main-1.35 {
+ db complete {hi /**/ there;}
+} {1}
+do_test main-1.36 {
+ db complete {hi there/***/;}
+} {1}
+do_test main-1.37 {
+ db complete {hi there/**}
+} {0}
+do_test main-1.38 {
+ db complete {hi [there}
+} {0}
+
+ifcapable {trigger} {
+ # Characters less than \040 can never be part of an identifier.
+ # Characters greater than \u177 are always identifier characters.
+ do_test main-1.100 {
+ db complete "create \037\036\035\034trigger\001\002;"
+ } {1}
+ do_test main-1.101 {
+ db complete "create trigger\200;"
+ } {1}
+ do_test main-1.102 {
+ db complete "create \200trigger;"
+ } {1}
+}
+
+
+# Try to open a database with a corrupt database file.
+#
+if {[permutation] == ""} {
+ do_test main-2.0 {
+ catch {db close}
+ forcedelete test.db
+ set fd [open test.db w]
+ puts $fd hi!
+ close $fd
+ set v [catch {sqlite3 db test.db} msg]
+ if {$v} {lappend v $msg} {lappend v {}}
+ } {0 {}}
+}
+
+# Here are some tests for tokenize.c.
+#
+do_test main-3.1 {
+ catch {db close}
+ foreach f [glob -nocomplain testdb/*] {forcedelete $f}
+ forcedelete testdb
+ sqlite3 db testdb
+ set v [catch {execsql {SELECT * from T1 where x!!5}} msg]
+ lappend v $msg
+} {1 {unrecognized token: "!!"}}
+do_test main-3.2 {
+ catch {db close}
+ foreach f [glob -nocomplain testdb/*] {forcedelete $f}
+ forcedelete testdb
+ sqlite3 db testdb
+ set v [catch {execsql {SELECT * from T1 where ^x}} msg]
+ lappend v $msg
+} {1 {unrecognized token: "^"}}
+do_test main-3.2.2 {
+ catchsql {select 'abc}
+} {1 {unrecognized token: "'abc"}}
+do_test main-3.2.3 {
+ catchsql {select "abc}
+} {1 {unrecognized token: ""abc"}}
+do_test main-3.2.4 {
+ catchsql {select [abc}
+} {1 {unrecognized token: "[abc"}}
+do_test main-3.2.5 {
+ catchsql {select x'4869}
+} {1 {unrecognized token: "x'4869"}}
+do_test main-3.2.6 {
+ catchsql {select x'4869'}
+} {0 Hi}
+do_test main-3.2.7 {
+ catchsql {select x'48695'}
+} {1 {unrecognized token: "x'48695'"}}
+do_test main-3.2.8 {
+ catchsql {select x'486x'}
+} {1 {unrecognized token: "x'486x'"}}
+do_test main-3.2.9 {
+ catchsql {select $abc(}
+} {1 {unrecognized token: "$abc("}}
+do_test main-3.2.10 {
+ catchsql {select $abc(x}
+} {1 {unrecognized token: "$abc(x"}}
+set xyz 123
+do_test main-3.2.11 {
+ catchsql {select $::xyz}
+} {0 123}
+namespace eval ::testnamespace {
+ variable xyz 321
+}
+do_test main-3.2.12 {
+ catchsql {select $testnamespace::xyz}
+} {0 321}
+do_test main-3.2.13 {
+ catchsql {select $(abc)}
+} {1 {unrecognized token: "$"}}
+do_test main-3.2.14 {
+ set hi\u1234x 987
+ db eval "select \$hi\u1234x"
+} {987}
+do_test main-3.2.15 {
+ catchsql "select 456\u1234"
+} [list 1 "unrecognized token: \"456\u1234\""]
+do_test main-3.2.16 {
+ catchsql {select cast(3.14e+4 AS integer)}
+} {0 31400}
+do_test main-3.2.17 {
+ catchsql {select cast(3.14e+04 AS integer)}
+} {0 31400}
+do_test main-3.2.18 {
+ catchsql {select cast(3.14e+004 AS integer)}
+} {0 31400}
+do_test main-3.2.19 {
+ catchsql {select cast(3.14e4 AS integer)}
+} {0 31400}
+do_test main-3.2.20 {
+ catchsql {select cast(3.14e04 AS integer)}
+} {0 31400}
+do_test main-3.2.21 {
+ catchsql {select cast(3.14e004 AS integer)}
+} {0 31400}
+do_test main-3.2.16 {
+ catchsql {select cast(3.14E+4 AS integer)}
+} {0 31400}
+do_test main-3.2.17 {
+ catchsql {select cast(3.14E+04 AS integer)}
+} {0 31400}
+do_test main-3.2.18 {
+ catchsql {select cast(3.14E+004 AS integer)}
+} {0 31400}
+do_test main-3.2.19 {
+ catchsql {select cast(3.14E4 AS integer)}
+} {0 31400}
+do_test main-3.2.20 {
+ catchsql {select cast(3.14E04 AS integer)}
+} {0 31400}
+do_test main-3.2.21 {
+ catchsql {select cast(3.14E004 AS integer)}
+} {0 31400}
+do_test main-3.2.22 {
+ catchsql {select cast(3.14e-4 * 1e8 AS integer)}
+} {0 31400}
+do_test main-3.2.23 {
+ catchsql {select cast(3.14E-04 * 1E08 AS integer)}
+} {0 31400}
+do_test main-3.2.24 {
+ catchsql {select cast(3.14e-004 * 01.0E+8 AS integer)}
+} {0 31400}
+do_test main-3.2.25 {
+ catchsql {select 123/*abc}
+} {0 123}
+do_test main-3.2.26 {
+ catchsql {select 123/***abc}
+} {0 123}
+do_test main-3.2.27 {
+ catchsql {select 123/*/*2}
+} {0 123}
+do_test main-3.2.28 {
+ catchsql {select 123/**/*2}
+} {0 246}
+do_test main-3.2.29 {
+ catchsql {select 123/}
+} {1 {near "/": syntax error}}
+do_test main-3.2.30 {
+ catchsql {select 123--5}
+} {0 123}
+
+
+do_test main-3.3 {
+ catch {db close}
+ foreach f [glob -nocomplain testdb/*] {forcedelete $f}
+ forcedelete testdb
+ sqlite3 db testdb
+ execsql {
+ create table T1(X REAL); /* C-style comments allowed */
+ insert into T1 values(0.5);
+ insert into T1 values(0.5e2);
+ insert into T1 values(0.5e-002);
+ insert into T1 values(5e-002);
+ insert into T1 values(-5.0e-2);
+ insert into T1 values(-5.1e-2);
+ insert into T1 values(0.5e2);
+ insert into T1 values(0.5E+02);
+ insert into T1 values(5E+02);
+ insert into T1 values(5.0E+03);
+ select x*10 from T1 order by x*5;
+ }
+} {-0.51 -0.5 0.05 0.5 5.0 500.0 500.0 500.0 5000.0 50000.0}
+do_test main-3.4 {
+ set v [catch {execsql {create bogus}} msg]
+ lappend v $msg
+} {1 {near "bogus": syntax error}}
+do_test main-3.5 {
+ set v [catch {execsql {create}} msg]
+ lappend v $msg
+} {1 {near "create": syntax error}}
+do_test main-3.6 {
+ catchsql {SELECT 'abc' + #9}
+} {1 {near "#9": syntax error}}
+
+# The following test-case tests the linked list code used to manage
+# sqlite3_vfs structures.
+if {$::tcl_platform(platform)=="unix"
+ && [info command sqlite3async_initialize]!=""} {
+ ifcapable threadsafe {
+ do_test main-4.1 {
+ sqlite3_crash_enable 1
+ sqlite3_crash_enable 0
+
+ sqlite3async_initialize "" 1
+ sqlite3async_shutdown
+
+ sqlite3_crash_enable 1
+ sqlite3async_initialize "" 1
+ sqlite3_crash_enable 0
+ sqlite3async_shutdown
+
+ sqlite3_crash_enable 1
+ sqlite3async_initialize "" 1
+ sqlite3async_shutdown
+ sqlite3_crash_enable 0
+
+ sqlite3async_initialize "" 1
+ sqlite3_crash_enable 1
+ sqlite3_crash_enable 0
+ sqlite3async_shutdown
+
+ sqlite3async_initialize "" 1
+ sqlite3_crash_enable 1
+ sqlite3async_shutdown
+ sqlite3_crash_enable 0
+ } {}
+ do_test main-4.2 {
+ set rc [catch {sqlite3 db test.db -vfs crash} msg]
+ list $rc $msg
+ } {1 {no such vfs: crash}}
+ do_test main-4.3 {
+ set rc [catch {sqlite3 db test.db -vfs async} msg]
+ list $rc $msg
+ } {1 {no such vfs: async}}
+ }
+}
+
+finish_test
diff --git a/test/make-where7.tcl b/test/make-where7.tcl
new file mode 100644
index 0000000..706f184
--- /dev/null
+++ b/test/make-where7.tcl
@@ -0,0 +1,120 @@
+#!/usr/bin/tclsh
+#
+# Run this script to generate randomized test cases for the where7.test
+# script. The output will need to be manually copied and pasted into
+# the where7.test script.
+#
+puts "do_test where7-2.1 \173"
+puts " db eval \173"
+puts " CREATE TABLE t2(a INTEGER PRIMARY KEY,b,c,d,e,f,g);"
+set NA 100
+for {set a 1} {$a<=$NA} {incr a} {
+ set b [expr {$a*11}]
+ set div3 [expr {int(($a+2)/3)}]
+ set c [expr {$div3*1001}]
+ set d [expr {$a*1.001}]
+ set e [expr {$div3*100.1}]
+ set x [expr {$a%26}]
+ set f [string range {abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz} \
+ $x [expr {$x+8}]]
+ set div5 [expr {int(($a+7)/5)}]
+ set x [expr {$div5%26}]
+ set g [string range {zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba} \
+ $x [expr {$x+6}]]
+ puts " INSERT INTO t2 VALUES($a,$b,$c,$d,$e,'$f','$g');"
+ lappend fidx($f) $a
+ lappend gidx($g) $a
+ set gof($a) $g
+ set fof($a) $f
+
+ set expr "a=$a"
+ set term($expr) $a
+ set expr "((a BETWEEN [expr {$a-1}] AND [expr {$a+1}]) AND a!=$a)"
+ set x {}
+ if {$a>1} {set x [expr {$a-1}]}
+ if {$a<$NA} {lappend x [expr {$a+1}]}
+ set term($expr) $x
+ set expr "b=$b"
+ set term($expr) $a
+ set expr "b=[expr {$a*11+3}]"
+ set term($expr) {}
+ set expr "c=$c"
+ lappend term($expr) $a
+ set expr "(d>=$a.0 AND d<[expr {$a+1.0}] AND d NOT NULL)"
+ lappend term($expr) $a
+ set expr "f='$f'"
+ lappend term($expr) $a
+ set expr \
+ "(f GLOB '?[string range $f 1 4]*' AND f GLOB '[string range $f 0 3]*')"
+ lappend term($expr) $a
+ set expr "(g='$g' AND f GLOB '[string range $f 0 4]*')"
+ lappend term($expr) $a
+}
+puts " CREATE INDEX t2b ON t2(b);"
+puts " CREATE INDEX t2c ON t2(c);"
+puts " CREATE INDEX t2d ON t2(d);"
+puts " CREATE INDEX t2e ON t2(e);"
+puts " CREATE INDEX t2f ON t2(f);"
+puts " CREATE INDEX t2g ON t2(g);"
+puts " CREATE TABLE t3(a INTEGER PRIMARY KEY,b,c,d,e,f,g);"
+puts " INSERT INTO t3 SELECT * FROM t2;"
+puts " CREATE INDEX t3b ON t3(b,c);"
+puts " CREATE INDEX t3c ON t3(c,e);"
+puts " CREATE INDEX t3d ON t3(d,g);"
+puts " CREATE INDEX t3e ON t3(e,f,g);"
+puts " CREATE INDEX t3f ON t3(f,b,d,c);"
+puts " CREATE INDEX t3g ON t3(g,f);"
+
+puts " \175"
+puts "\175 {}"
+
+set term(b<0) {}
+set term(1000000<b) {}
+set term(c<=10) {}
+set term(c>=[expr {int(($NA+2)/3)*1001+1}]) {}
+set term(d<0.0) {}
+set term(d>1e10) {}
+set expr {e IS NULL}
+set term($expr) {}
+set expr {f IS NULL}
+set term($expr) {}
+set expr {g IS NULL}
+set term($expr) {}
+
+set NT 1000
+set termlist [array names term]
+set nterm [llength $termlist]
+for {set i 2} {$i<=$NT+1} {incr i} {
+ set n [expr {int(rand()*10)+2}]
+ set w {}
+ unset -nocomplain r
+ for {set j 0} {$j<$n} {incr j} {
+ set k [expr {int(rand()*$nterm)}]
+ set t [lindex $termlist $k]
+ lappend w $t
+ foreach a $term($t) {
+ set r($a) 1
+ }
+ }
+ if {[info exists seen($w)]} {
+ incr i -1
+ continue
+ }
+ set seen($w) 1
+ set result [lsort -int [array names r]]
+ puts "do_test where7-2.$i.1 \173"
+ puts " count_steps_sort \173"
+ puts " SELECT a FROM t2"
+ set wc [join $w "\n OR "]
+ puts " WHERE $wc"
+ puts " \175"
+ puts "\175 {$result scan 0 sort 0}"
+ puts "do_test where7-2.$i.2 \173"
+ puts " count_steps_sort \173"
+ puts " SELECT a FROM t3"
+ set wc [join $w "\n OR "]
+ puts " WHERE $wc"
+ puts " \175"
+ puts "\175 {$result scan 0 sort 0}"
+}
+puts "finish_test"
diff --git a/test/malloc.test b/test/malloc.test
new file mode 100644
index 0000000..0d213d7
--- /dev/null
+++ b/test/malloc.test
@@ -0,0 +1,890 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file attempts to check the behavior of the SQLite library in
+# an out-of-memory situation. When compiled with -DSQLITE_DEBUG=1,
+# the SQLite library accepts a special command (sqlite3_memdebug_fail N C)
+# which causes the N-th malloc to fail. This special feature is used
+# to see what happens in the library if a malloc were to really fail
+# due to an out-of-memory situation.
+#
+# $Id: malloc.test,v 1.81 2009/06/24 13:13:45 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+# Only run these tests if memory debugging is turned on.
+#
+source $testdir/malloc_common.tcl
+if {!$MEMDEBUG} {
+ puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+# Do a couple of memory dumps just to exercise the memory dump logic
+# that that we can say that we have.
+#
+puts stderr "This is a test. Ignore the error that follows:"
+sqlite3_memdebug_dump $testdir
+puts "Memory dump to file memdump.txt..."
+sqlite3_memdebug_dump memdump.txt
+
+ifcapable bloblit&&subquery {
+ do_malloc_test 1 -tclprep {
+ db close
+ } -tclbody {
+ if {[catch {sqlite3 db test.db}]} {
+ error "out of memory"
+ }
+ sqlite3_extended_result_codes db 1
+ } -sqlbody {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(
+ a int, b float, c double, d text, e varchar(20),
+ primary key(a,b,c)
+ );
+ CREATE INDEX i1 ON t1(a,b);
+ INSERT INTO t1 VALUES(1,2.3,4.5,'hi',x'746865726500');
+ INSERT INTO t1 VALUES(6,7.0,0.8,'hello','out yonder');
+ SELECT * FROM t1;
+ SELECT avg(b) FROM t1 GROUP BY a HAVING b>20.0;
+ DELETE FROM t1 WHERE a IN (SELECT min(a) FROM t1);
+ SELECT count(*), group_concat(e) FROM t1;
+ SELECT b FROM t1 ORDER BY 1 COLLATE nocase;
+ }
+}
+
+# Ensure that no file descriptors were leaked.
+do_test malloc-1.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+ifcapable subquery {
+ do_malloc_test 2 -sqlbody {
+ CREATE TABLE t1(a int, b int default 'abc', c int default 1);
+ CREATE INDEX i1 ON t1(a,b);
+ INSERT INTO t1 VALUES(1,1,'99 abcdefghijklmnopqrstuvwxyz');
+ INSERT INTO t1 VALUES(2,4,'98 abcdefghijklmnopqrstuvwxyz');
+ INSERT INTO t1 VALUES(3,9,'97 abcdefghijklmnopqrstuvwxyz');
+ INSERT INTO t1 VALUES(4,16,'96 abcdefghijklmnopqrstuvwxyz');
+ INSERT INTO t1 VALUES(5,25,'95 abcdefghijklmnopqrstuvwxyz');
+ INSERT INTO t1 VALUES(6,36,'94 abcdefghijklmnopqrstuvwxyz');
+ SELECT 'stuff', count(*) as 'other stuff', max(a+10) FROM t1;
+ UPDATE t1 SET b=b||b||b||b;
+ UPDATE t1 SET b=a WHERE a in (10,12,22);
+ INSERT INTO t1(c,b,a) VALUES(20,10,5);
+ INSERT INTO t1 SELECT * FROM t1
+ WHERE a IN (SELECT a FROM t1 WHERE a<10);
+ DELETE FROM t1 WHERE a>=10;
+ DROP INDEX i1;
+ DELETE FROM t1;
+ }
+}
+
+# Ensure that no file descriptors were leaked.
+do_test malloc-2.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+do_malloc_test 3 -sqlbody {
+ BEGIN TRANSACTION;
+ CREATE TABLE t1(a int, b int, c int);
+ CREATE INDEX i1 ON t1(a,b);
+ INSERT INTO t1 VALUES(1,1,99);
+ INSERT INTO t1 VALUES(2,4,98);
+ INSERT INTO t1 VALUES(3,9,97);
+ INSERT INTO t1 VALUES(4,16,96);
+ INSERT INTO t1 VALUES(5,25,95);
+ INSERT INTO t1 VALUES(6,36,94);
+ INSERT INTO t1(c,b,a) VALUES(20,10,5);
+ DELETE FROM t1 WHERE a>=10;
+ DROP INDEX i1;
+ DELETE FROM t1;
+ ROLLBACK;
+}
+
+
+# Ensure that no file descriptors were leaked.
+do_test malloc-3.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+ifcapable subquery {
+ do_malloc_test 4 -sqlbody {
+ BEGIN TRANSACTION;
+ CREATE TABLE t1(a int, b int, c int);
+ CREATE INDEX i1 ON t1(a,b);
+ INSERT INTO t1 VALUES(1,1,99);
+ INSERT INTO t1 VALUES(2,4,98);
+ INSERT INTO t1 VALUES(3,9,97);
+ INSERT INTO t1 VALUES(4,16,96);
+ INSERT INTO t1 VALUES(5,25,95);
+ INSERT INTO t1 VALUES(6,36,94);
+ UPDATE t1 SET b=a WHERE a in (10,12,22);
+ INSERT INTO t1 SELECT * FROM t1
+ WHERE a IN (SELECT a FROM t1 WHERE a<10);
+ DROP INDEX i1;
+ DELETE FROM t1;
+ COMMIT;
+ }
+}
+
+# Ensure that no file descriptors were leaked.
+do_test malloc-4.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+ifcapable trigger {
+ do_malloc_test 5 -sqlbody {
+ BEGIN TRANSACTION;
+ CREATE TABLE t1(a,b);
+ CREATE TABLE t2(x,y);
+ CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.a = 2 BEGIN
+ INSERT INTO t2(x,y) VALUES(new.rowid,1);
+ INSERT INTO t2(x,y) SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t2;
+ UPDATE t2 SET y=y+1 WHERE x=new.rowid;
+ SELECT 123;
+ DELETE FROM t2 WHERE x=new.rowid;
+ END;
+ INSERT INTO t1(a,b) VALUES(2,3);
+ COMMIT;
+ }
+}
+
+# Ensure that no file descriptors were leaked.
+do_test malloc-5.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+ifcapable vacuum {
+ do_malloc_test 6 -sqlprep {
+ BEGIN TRANSACTION;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 SELECT a*2 FROM t1;
+ INSERT INTO t1 SELECT a*2 FROM t1;
+ INSERT INTO t1 SELECT a*2 FROM t1;
+ INSERT INTO t1 SELECT a*2 FROM t1;
+ INSERT INTO t1 SELECT a*2 FROM t1;
+ INSERT INTO t1 SELECT a*2 FROM t1;
+ INSERT INTO t1 SELECT a*2 FROM t1;
+ INSERT INTO t1 SELECT a*2 FROM t1;
+ INSERT INTO t1 SELECT a*2 FROM t1;
+ INSERT INTO t1 SELECT a*2 FROM t1;
+ DELETE FROM t1 where rowid%5 = 0;
+ COMMIT;
+ } -sqlbody {
+ VACUUM;
+ }
+}
+
+autoinstall_test_functions
+do_malloc_test 7 -sqlprep {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ INSERT INTO t1 VALUES(7, randstr(1200,1200));
+} -sqlbody {
+ SELECT min(a) FROM t1 WHERE a<6 GROUP BY b;
+ SELECT a FROM t1 WHERE a<6 ORDER BY a;
+ SELECT b FROM t1 WHERE a>6;
+}
+
+# This block is designed to test that some malloc failures that may
+# occur in vdbeapi.c. Specifically, if a malloc failure that occurs
+# when converting UTF-16 text to integers and real numbers is handled
+# correctly.
+#
+# This is done by retrieving a string from the database engine and
+# manipulating it using the sqlite3_column_*** APIs. This doesn't
+# actually return an error to the user when a malloc() fails.. That
+# could be viewed as a bug.
+#
+# These tests only run if UTF-16 support is compiled in.
+#
+ifcapable utf16 {
+ set ::STMT {}
+ do_malloc_test 8 -tclprep {
+ set sql "SELECT '[string repeat abc 20]', '[string repeat def 20]', ?"
+ set ::STMT [sqlite3_prepare db $sql -1 X]
+ sqlite3_step $::STMT
+ if { $::tcl_platform(byteOrder)=="littleEndian" } {
+ set ::bomstr "\xFF\xFE"
+ } else {
+ set ::bomstr "\xFE\xFF"
+ }
+ append ::bomstr [encoding convertto unicode "123456789_123456789_123456789"]
+ } -tclbody {
+ sqlite3_column_text16 $::STMT 0
+ sqlite3_column_int $::STMT 0
+ sqlite3_column_text16 $::STMT 1
+ sqlite3_column_double $::STMT 1
+ set rc [sqlite3_reset $::STMT]
+ if {$rc eq "SQLITE_NOMEM"} {error "out of memory"}
+ sqlite3_bind_text16 $::STMT 1 $::bomstr 60
+ #catch {sqlite3_finalize $::STMT}
+ #if {[lindex [sqlite_malloc_stat] 2]<=0} {
+ # error "out of memory"
+ #}
+ } -cleanup {
+ if {$::STMT!=""} {
+ sqlite3_finalize $::STMT
+ set ::STMT {}
+ }
+ }
+}
+
+# This block tests that malloc() failures that occur whilst commiting
+# a multi-file transaction are handled correctly.
+#
+do_malloc_test 9 -sqlprep {
+ ATTACH 'test2.db' as test2;
+ CREATE TABLE abc1(a, b, c);
+ CREATE TABLE test2.abc2(a, b, c);
+} -sqlbody {
+ BEGIN;
+ INSERT INTO abc1 VALUES(1, 2, 3);
+ INSERT INTO abc2 VALUES(1, 2, 3);
+ COMMIT;
+}
+
+# This block tests malloc() failures that occur while opening a
+# connection to a database.
+do_malloc_test 10 -tclprep {
+ catch {db2 close}
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ sqlite3_extended_result_codes db 1
+ db eval {CREATE TABLE abc(a, b, c)}
+} -tclbody {
+ db close
+ sqlite3 db2 test.db
+ sqlite3_extended_result_codes db2 1
+ db2 eval {SELECT * FROM sqlite_master}
+ db2 close
+}
+
+# This block tests malloc() failures that occur within calls to
+# sqlite3_create_function().
+do_malloc_test 11 -tclbody {
+ set rc [sqlite3_create_function db]
+ if {[string match $rc SQLITE_OK]} {
+ set rc [sqlite3_create_aggregate db]
+ }
+ if {[string match $rc SQLITE_NOMEM]} {
+ error "out of memory"
+ }
+}
+
+do_malloc_test 12 -tclbody {
+ set sql16 [encoding convertto unicode "SELECT * FROM sqlite_master"]
+ append sql16 "\00\00"
+ set ::STMT [sqlite3_prepare16 db $sql16 -1 DUMMY]
+ sqlite3_finalize $::STMT
+}
+
+# Test malloc errors when replaying two hot journals from a 2-file
+# transaction.
+ifcapable crashtest&&attach {
+ do_malloc_test 13 -tclprep {
+ set rc [crashsql -delay 1 -file test2.db {
+ ATTACH 'test2.db' as aux;
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE aux.t2(a, b, c);
+ CREATE TABLE t1(a, b, c);
+ COMMIT;
+ }]
+ if {$rc!="1 {child process exited abnormally}"} {
+ error "Wrong error message: $rc"
+ }
+ } -tclbody {
+ db eval {ATTACH 'test2.db' as aux;}
+ set rc [catch {db eval {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }} err]
+ if {$rc && $err!="no such table: t1"} {
+ error $err
+ }
+ }
+}
+
+if {$tcl_platform(platform)!="windows"} {
+ do_malloc_test 14 -tclprep {
+ catch {db close}
+ sqlite3 db2 test2.db
+ sqlite3_extended_result_codes db2 1
+ db2 eval {
+ PRAGMA journal_mode = DELETE; /* For inmemory_journal permutation */
+ PRAGMA synchronous = 0;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ forcecopy test2.db test.db
+ forcecopy test2.db-journal test.db-journal
+ db2 close
+ } -tclbody {
+ sqlite3 db test.db
+ sqlite3_extended_result_codes db 1
+
+ # If an out-of-memory occurs within a call to a VFS layer function during
+ # hot-journal rollback, sqlite will report SQLITE_CORRUPT. See commit
+ # [5668] for details.
+ set rc [catch {db eval { SELECT * FROM t1 }} msg]
+ if {$msg eq "database disk image is malformed"} { set msg "out of memory" }
+ if {$rc} { error $msg }
+ set msg
+ }
+}
+
+proc string_compare {a b} {
+ return [string compare $a $b]
+}
+
+# Test for malloc() failures in sqlite3_create_collation() and
+# sqlite3_create_collation16().
+#
+ifcapable utf16 {
+ do_malloc_test 15 -start 4 -tclbody {
+ db collate string_compare string_compare
+ if {[catch {add_test_collate db 1 1 1} msg]} {
+ if {$msg=="SQLITE_NOMEM"} {set msg "out of memory"}
+ error $msg
+ }
+
+ db complete {SELECT "hello """||'world"' [microsoft], * FROM anicetable;}
+ db complete {-- Useful comment}
+
+ execsql {
+ CREATE TABLE t1(a, b COLLATE string_compare);
+ INSERT INTO t1 VALUES(10, 'string');
+ INSERT INTO t1 VALUES(10, 'string2');
+ }
+ }
+}
+
+# Also test sqlite3_complete(). There are (currently) no malloc()
+# calls in this function, but test anyway against future changes.
+#
+do_malloc_test 16 -tclbody {
+ db complete {SELECT "hello """||'world"' [microsoft], * FROM anicetable;}
+ db complete {-- Useful comment}
+ db eval {
+ SELECT * FROM sqlite_master;
+ }
+}
+
+# Test handling of malloc() failures in sqlite3_open16().
+#
+ifcapable utf16 {
+ do_malloc_test 17 -tclbody {
+ set DB2 0
+ set STMT 0
+
+ # open database using sqlite3_open16()
+ set filename [encoding convertto unicode test.db]
+ append filename "\x00\x00"
+ set DB2 [sqlite3_open16 $filename -unused]
+ if {0==$DB2} {
+ error "out of memory"
+ }
+ sqlite3_extended_result_codes $DB2 1
+
+ # Prepare statement
+ set rc [catch {sqlite3_prepare $DB2 {SELECT * FROM sqlite_master} -1 X} msg]
+ if {[sqlite3_errcode $DB2] eq "SQLITE_IOERR+12"} {
+ error "out of memory"
+ }
+ if {[regexp ".*automatic extension loading.*" [sqlite3_errmsg $DB2]]} {
+ error "out of memory"
+ }
+ if {$rc} {
+ error [string range $msg 4 end]
+ }
+ set STMT $msg
+
+ # Finalize statement
+ set rc [sqlite3_finalize $STMT]
+ if {$rc!="SQLITE_OK"} {
+ error [sqlite3_errmsg $DB2]
+ }
+ set STMT 0
+
+ # Close database
+ set rc [sqlite3_close $DB2]
+ if {$rc!="SQLITE_OK"} {
+ error [sqlite3_errmsg $DB2]
+ }
+ set DB2 0
+ } -cleanup {
+ if {$STMT!="0"} {
+ sqlite3_finalize $STMT
+ }
+ if {$DB2!="0"} {
+ set rc [sqlite3_close $DB2]
+ }
+ }
+}
+
+# Test handling of malloc() failures in sqlite3_errmsg16().
+#
+ifcapable utf16 {
+ do_malloc_test 18 -tclprep {
+ catch {
+ db eval "SELECT [string repeat longcolumnname 10] FROM sqlite_master"
+ }
+ } -tclbody {
+ set utf16 [sqlite3_errmsg16 [sqlite3_connection_pointer db]]
+ binary scan $utf16 c* bytes
+ if {[llength $bytes]==0} {
+ error "out of memory"
+ }
+ }
+}
+
+# This test is aimed at coverage testing. Specificly, it is supposed to
+# cause a malloc() only used when converting between the two utf-16
+# encodings to fail (i.e. little-endian->big-endian). It only actually
+# hits this malloc() on little-endian hosts.
+#
+set static_string "\x00h\x00e\x00l\x00l\x00o"
+for {set l 0} {$l<10} {incr l} {
+ append static_string $static_string
+}
+append static_string "\x00\x00"
+do_malloc_test 19 -tclprep {
+ execsql {
+ PRAGMA encoding = "UTF16be";
+ CREATE TABLE abc(a, b, c);
+ }
+} -tclbody {
+ unset -nocomplain ::STMT
+ set r [catch {
+ set ::STMT [sqlite3_prepare db {SELECT ?} -1 DUMMY]
+ sqlite3_bind_text16 -static $::STMT 1 $static_string 112
+ } msg]
+ if {$r} {error [string range $msg 4 end]}
+ set msg
+} -cleanup {
+ if {[info exists ::STMT]} {
+ sqlite3_finalize $::STMT
+ }
+}
+unset static_string
+
+# Make sure SQLITE_NOMEM is reported out on an ATTACH failure even
+# when the malloc failure occurs within the nested parse.
+#
+ifcapable attach {
+ do_malloc_test 20 -tclprep {
+ db close
+ forcedelete test2.db test2.db-journal
+ sqlite3 db test2.db
+ sqlite3_extended_result_codes db 1
+ db eval {CREATE TABLE t1(x);}
+ db close
+ } -tclbody {
+ if {[catch {sqlite3 db test.db}]} {
+ error "out of memory"
+ }
+ sqlite3_extended_result_codes db 1
+ } -sqlbody {
+ ATTACH DATABASE 'test2.db' AS t2;
+ SELECT * FROM t1;
+ DETACH DATABASE t2;
+ }
+}
+
+# Test malloc failure whilst installing a foreign key.
+#
+ifcapable foreignkey {
+ do_malloc_test 21 -sqlbody {
+ CREATE TABLE abc(a, b, c, FOREIGN KEY(a) REFERENCES abc(b))
+ }
+}
+
+# Test malloc failure in an sqlite3_prepare_v2() call.
+#
+do_malloc_test 22 -tclbody {
+ set ::STMT ""
+ set r [catch {
+ set ::STMT [
+ sqlite3_prepare_v2 db "SELECT * FROM sqlite_master" -1 DUMMY
+ ]
+ } msg]
+ if {$r} {error [string range $msg 4 end]}
+} -cleanup {
+ if {$::STMT ne ""} {
+ sqlite3_finalize $::STMT
+ set ::STMT ""
+ }
+}
+
+ifcapable {pager_pragmas} {
+ # This tests a special case - that an error that occurs while the pager
+ # is trying to recover from error-state in exclusive-access mode works.
+ #
+ do_malloc_test 23 -tclprep {
+ db eval {
+ PRAGMA cache_size = 10;
+ PRAGMA locking_mode = exclusive;
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ CREATE INDEX abc_i ON abc(a, b, c);
+ INSERT INTO abc
+ VALUES(randstr(100,100), randstr(100,100), randstr(100,100));
+ INSERT INTO abc
+ SELECT randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ COMMIT;
+ }
+
+ # This puts the pager into error state.
+ #
+ db eval BEGIN
+ db eval {UPDATE abc SET a = 0 WHERE oid%2}
+ set ::sqlite_io_error_pending 10
+ catch {db eval {ROLLBACK}} msg
+
+ } -tclbody {
+ # If an out-of-memory occurs within a call to a VFS layer function during
+ # hot-journal rollback, sqlite will report SQLITE_CORRUPT. See commit
+ # [5668] for details.
+ set rc [catch {db eval { SELECT * FROM abc LIMIT 10 }} msg]
+ if {$msg eq "database disk image is malformed"} { set msg "out of memory" }
+ if {$rc} { error $msg }
+ set msg
+ } -cleanup {
+ set e [db eval {PRAGMA integrity_check}]
+ if {$e ne "ok"} {error $e}
+ }
+}
+
+ifcapable compound {
+ do_malloc_test 24 -sqlprep {
+ CREATE TABLE t1(a, b, c)
+ } -sqlbody {
+ SELECT 1 FROM t1 UNION SELECT 2 FROM t1 ORDER BY 1
+ }
+}
+
+ifcapable view&&trigger {
+ do_malloc_test 25 -sqlprep {
+ CREATE TABLE t1(a, b, c);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE TRIGGER v1t1 INSTEAD OF DELETE ON v1 BEGIN SELECT 1; END;
+ CREATE TRIGGER v1t2 INSTEAD OF INSERT ON v1 BEGIN SELECT 1; END;
+ CREATE TRIGGER v1t3 INSTEAD OF UPDATE ON v1 BEGIN SELECT 1; END;
+ } -sqlbody {
+ DELETE FROM v1 WHERE a = 1;
+ INSERT INTO v1 VALUES(1, 2, 3);
+ UPDATE v1 SET a = 1 WHERE b = 2;
+ }
+}
+
+do_malloc_test 25 -sqlprep {
+ CREATE TABLE abc(a, b, c);
+ CREATE INDEX i1 ON abc(a, b);
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(4, 5, 6);
+} -tclbody {
+ # For each UPDATE executed, the cursor used for the SELECT statement
+ # must be "saved". Because the cursor is open on an index, this requires
+ # a malloc() to allocate space to save the index key. This test case is
+ # aimed at testing the response of the library to a failure in that
+ # particular malloc() call.
+ db eval {SELECT a FROM abc ORDER BY a} {
+ db eval {UPDATE abc SET b = b - 1 WHERE a = $a}
+ }
+}
+
+# This test is designed to test a specific juncture in the sqlite code.
+# The database set up by -sqlprep script contains a single table B-Tree
+# of height 2. In the -tclbody script, the existing database connection
+# is closed and a new one opened and used to insert a new row into the
+# table B-Tree. By using a new connection, the outcome of a malloc()
+# failure while seeking to the right-hand side of the B-Tree to insert
+# a new record can be tested.
+#
+do_malloc_test 26 -sqlprep {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, randomblob(210));
+ INSERT INTO t1 VALUES(1, randomblob(210));
+ INSERT INTO t1 VALUES(1, randomblob(210));
+ INSERT INTO t1 VALUES(1, randomblob(210));
+ INSERT INTO t1 VALUES(1, randomblob(210));
+ COMMIT;
+} -tclbody {
+ db close
+ sqlite3 db test.db
+ db eval { INSERT INTO t1 VALUES(1, randomblob(210)) }
+}
+
+# Test that no memory is leaked following a malloc() failure in
+# sqlite3_initialize().
+#
+do_malloc_test 27 -tclprep {
+ db close
+ sqlite3_shutdown
+} -tclbody {
+ set rc [sqlite3_initialize]
+ if {$rc == "SQLITE_NOMEM"} {
+ error "out of memory"
+ }
+}
+autoinstall_test_functions
+
+# Test that malloc failures that occur while processing INDEXED BY
+# clauses are handled correctly.
+do_malloc_test 28 -sqlprep {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ CREATE VIEW v1 AS SELECT * FROM t1 INDEXED BY i1 WHERE a = 10;
+} -sqlbody {
+ SELECT * FROM t1 INDEXED BY i1 ORDER BY a;
+ SELECT * FROM v1;
+}
+
+do_malloc_test 29 -sqlprep {
+ CREATE TABLE t1(a TEXT, b TEXT);
+} -sqlbody {
+ INSERT INTO t1 VALUES(1, -234);
+ INSERT INTO t1 SELECT * FROM t1 UNION ALL SELECT * FROM t1;
+}
+
+do_malloc_test 30 -tclprep {
+ db eval {
+ CREATE TABLE t1(x PRIMARY KEY);
+ INSERT INTO t1 VALUES(randstr(500,500));
+ INSERT INTO t1 VALUES(randstr(500,500));
+ INSERT INTO t1 VALUES(randstr(500,500));
+ }
+ db close
+ sqlite3 db test.db
+
+ # The DELETE command in the following block moves the overflow pages that
+ # are part of the primary key index to the free-list. But it does not
+ # actually load the content of the pages. This leads to the peculiar
+ # situation where cache entries exist, but are not populated with data.
+ # They are populated next time they are requested by the b-tree layer.
+ #
+ db eval {
+ BEGIN;
+ DELETE FROM t1;
+ ROLLBACK;
+ }
+} -sqlbody {
+ -- This statement requires the 'no-content' pages loaded by the DELETE
+ -- statement above. When requesting the pages, the content is loaded
+ -- from the database file. The point of this test case is to test handling
+ -- of malloc errors (including SQLITE_IOERR_NOMEM errors) when loading
+ -- the content.
+ SELECT * FROM t1 ORDER BY x;
+}
+
+# After committing a transaction in persistent-journal mode, if a journal
+# size limit is configured SQLite may attempt to truncate the journal file.
+# This test verifies the libraries response to a malloc() failure during
+# this operation.
+#
+do_malloc_test 31 -sqlprep {
+ PRAGMA journal_mode = persist;
+ PRAGMA journal_size_limit = 1024;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+} -sqlbody {
+ INSERT INTO t1 VALUES(1, 2);
+}
+
+# When written, this test provoked an obscure change-counter bug.
+#
+# If, when running in exclusive mode, a malloc() failure occurs
+# after the database file change-counter has been written but
+# before the transaction has been committed, then the transaction
+# is automatically rolled back. However, internally the
+# Pager.changeCounterDone flag was being left set. This means
+# that if the same connection attempts another transaction following
+# the malloc failure and rollback, the change counter will not
+# be updated. This could corrupt another processes cache.
+#
+do_malloc_test 32 -tclprep {
+ # Build a small database containing an indexed table.
+ #
+ db eval {
+ PRAGMA locking_mode = normal;
+ BEGIN;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+ COMMIT;
+ PRAGMA locking_mode = exclusive;
+ }
+
+ # Open a second database connection. Load the table (but not index)
+ # into the second connections pager cache.
+ #
+ sqlite3 db2 test.db
+ db2 eval {
+ PRAGMA locking_mode = normal;
+ SELECT b FROM t1;
+ }
+
+} -tclbody {
+ # Running in exclusive mode, perform a database transaction that
+ # modifies both the database table and index. For iterations where
+ # the malloc failure occurs after updating the change counter but
+ # before committing the transaction, this should result in the
+ # transaction being rolled back but the changeCounterDone flag
+ # left set.
+ #
+ db eval { UPDATE t1 SET a = a + 3 }
+} -cleanup {
+
+ # Perform another transaction using the first connection. Unlock
+ # the database after doing so. If this is one of the right iterations,
+ # then this should result in the database contents being updated but
+ # the change-counter left as it is.
+ #
+ db eval {
+ PRAGMA locking_mode = normal;
+ UPDATE t1 SET a = a + 3;
+ }
+
+ # Now do an integrity check with the second connection. The second
+ # connection still has the database table in its cache. If this is
+ # one of the magic iterations and the change counter was not modified,
+ # then it won't realize that the cached data is out of date. Since
+ # the cached data won't match the up to date index data read from
+ # the database file, the integrity check should fail.
+ #
+ set zRepeat "transient"
+ if {$::iRepeat} {set zRepeat "persistent"}
+ do_test malloc-32.$zRepeat.${::n}.integrity {
+ execsql {PRAGMA integrity_check} db2
+ } {ok}
+ db2 close
+}
+
+# The following two OOM tests verify that OOM handling works in the
+# code used to optimize "SELECT count(*) FROM <tbl>".
+#
+do_malloc_test 33 -tclprep {
+ db eval { PRAGMA cache_size = 10 }
+ db transaction {
+ db eval { CREATE TABLE abc(a, b) }
+ for {set i 0} {$i<500} {incr i} {
+ db eval {INSERT INTO abc VALUES(randstr(100,100), randstr(1000,1000))}
+ }
+ }
+} -sqlbody {
+ SELECT count(*) FROM abc;
+}
+do_malloc_test 34 -tclprep {
+ db eval { PRAGMA cache_size = 10 }
+ db transaction {
+ db eval { CREATE TABLE abc(a PRIMARY KEY, b) }
+ for {set i 0} {$i<500} {incr i} {
+ db eval {INSERT INTO abc VALUES(randstr(100,100), randstr(1000,1000))}
+ }
+ }
+} -sqlbody {
+ SELECT count(*) FROM abc;
+}
+
+proc f {args} { error "Quite a long error!" }
+do_malloc_test 35 -tclprep {
+ db func f f
+ set ::STMT [sqlite3_prepare db "SELECT f()" -1 DUMMY]
+ sqlite3_step $::STMT
+} -tclbody {
+ sqlite3_finalize $::STMT
+} -cleanup {
+ # At one point an assert( !db->mallocFailed ) could fail in the following
+ # call to sqlite3_errmsg(). Because sqlite3_finalize() had failed to clear
+ # the flag before returning.
+ sqlite3_errmsg16 db
+}
+
+do_malloc_test 36 -sqlprep {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+} -sqlbody {
+ SELECT test_agg_errmsg16(), group_concat(a) FROM t1
+}
+
+# At one point, if an OOM occured immediately after obtaining a shared lock
+# on the database file, the file remained locked. This test case ensures
+# that bug has been fixed.i
+if {[db eval {PRAGMA locking_mode}]!="exclusive"} {
+ do_malloc_test 37 -tclprep {
+ sqlite3 db2 test.db
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ } db2
+ } -sqlbody {
+ SELECT * FROM t1;
+ } -cleanup {
+ # Try to write to the database using connection [db2]. If connection [db]
+ # has correctly released the shared lock, this write attempt should
+ # succeed. If [db] has not released the lock, this should hit an
+ # SQLITE_BUSY error.
+ do_test malloc-36.$zRepeat.${::n}.unlocked {
+ execsql {INSERT INTO t1 VALUES(3, 4)} db2
+ } {}
+ db2 close
+ }
+ catch { db2 close }
+}
+
+
+# Test that if an OOM error occurs, aux-data is still correctly destroyed.
+# This test case was causing either a memory-leak or an assert() failure
+# at one point, depending on the configuration.
+#
+do_malloc_test 39 -tclprep {
+ sqlite3 db test.db
+} -sqlbody {
+ SELECT test_auxdata('abc', 'def');
+} -cleanup {
+ db close
+}
+
+# Ensure that no file descriptors were leaked.
+do_test malloc-99.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+puts open-file-count=$sqlite_open_file_count
+finish_test
diff --git a/test/malloc3.test b/test/malloc3.test
new file mode 100644
index 0000000..2dfde46
--- /dev/null
+++ b/test/malloc3.test
@@ -0,0 +1,664 @@
+# 2005 November 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests to ensure that the library handles malloc() failures
+# correctly. The emphasis of these tests are the _prepare(), _step() and
+# _finalize() calls.
+#
+# $Id: malloc3.test,v 1.24 2008/10/14 15:54:08 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping malloc3 tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+#--------------------------------------------------------------------------
+# NOTES ON RECOVERING FROM A MALLOC FAILURE
+#
+# The tests in this file test the behaviours described in the following
+# paragraphs. These tests test the behaviour of the system when malloc() fails
+# inside of a call to _prepare(), _step(), _finalize() or _reset(). The
+# handling of malloc() failures within ancillary procedures is tested
+# elsewhere.
+#
+# Overview:
+#
+# Executing a statement is done in three stages (prepare, step and finalize). A
+# malloc() failure may occur within any stage. If a memory allocation fails
+# during statement preparation, no statement handle is returned. From the users
+# point of view the system state is as if _prepare() had never been called.
+#
+# If the memory allocation fails during the _step() or _finalize() calls, then
+# the database may be left in one of two states (after finalize() has been
+# called):
+#
+# * As if the neither _step() nor _finalize() had ever been called on
+# the statement handle (i.e. any changes made by the statement are
+# rolled back).
+# * The current transaction may be rolled back. In this case a hot-journal
+# may or may not actually be present in the filesystem.
+#
+# The caller can tell the difference between these two scenarios by invoking
+# _get_autocommit().
+#
+#
+# Handling of sqlite3_reset():
+#
+# If a malloc() fails while executing an sqlite3_reset() call, this is handled
+# in the same way as a failure within _finalize(). The statement handle
+# is not deleted and must be passed to _finalize() for resource deallocation.
+# Attempting to _step() or _reset() the statement after a failed _reset() will
+# always return SQLITE_NOMEM.
+#
+#
+# Other active SQL statements:
+#
+# The effect of a malloc failure on concurrently executing SQL statements,
+# particularly when the statement is executing with READ_UNCOMMITTED set and
+# the malloc() failure mandates statement rollback only. Currently, if
+# transaction rollback is required, all other vdbe's are aborted.
+#
+# Non-transient mallocs in btree.c:
+# * The Btree structure itself
+# * Each BtCursor structure
+#
+# Mallocs in pager.c:
+# readMasterJournal() - Space to read the master journal name
+# pager_delmaster() - Space for the entire master journal file
+#
+# sqlite3pager_open() - The pager structure itself
+# sqlite3_pagerget() - Space for a new page
+# pager_open_journal() - Pager.aInJournal[] bitmap
+# sqlite3pager_write() - For in-memory databases only: history page and
+# statement history page.
+# pager_stmt_begin() - Pager.aInStmt[] bitmap
+#
+# None of the above are a huge problem. The most troublesome failures are the
+# transient malloc() calls in btree.c, which can occur during the tree-balance
+# operation. This means the tree being balanced will be internally inconsistent
+# after the malloc() fails. To avoid the corrupt tree being read by a
+# READ_UNCOMMITTED query, we have to make sure the transaction or statement
+# rollback occurs before sqlite3_step() returns, not during a subsequent
+# sqlite3_finalize().
+#--------------------------------------------------------------------------
+
+#--------------------------------------------------------------------------
+# NOTES ON TEST IMPLEMENTATION
+#
+# The tests in this file are implemented differently from those in other
+# files. Instead, tests are specified using three primitives: SQL, PREP and
+# TEST. Each primitive has a single argument. Primitives are processed in
+# the order they are specified in the file.
+#
+# A TEST primitive specifies a TCL script as its argument. When a TEST
+# directive is encountered the Tcl script is evaluated. Usually, this Tcl
+# script contains one or more calls to [do_test].
+#
+# A PREP primitive specifies an SQL script as its argument. When a PREP
+# directive is encountered the SQL is evaluated using database connection
+# [db].
+#
+# The SQL primitives are where the action happens. An SQL primitive must
+# contain a single, valid SQL statement as its argument. When an SQL
+# primitive is encountered, it is evaluated one or more times to test the
+# behaviour of the system when malloc() fails during preparation or
+# execution of said statement. The Nth time the statement is executed,
+# the Nth malloc is said to fail. The statement is executed until it
+# succeeds, i.e. (M+1) times, where M is the number of mallocs() required
+# to prepare and execute the statement.
+#
+# Each time an SQL statement fails, the driver program (see proc [run_test]
+# below) figures out if a transaction has been automatically rolled back.
+# If not, it executes any TEST block immediately proceeding the SQL
+# statement, then reexecutes the SQL statement with the next value of N.
+#
+# If a transaction has been automatically rolled back, then the driver
+# program executes all the SQL specified as part of SQL or PREP primitives
+# between the current SQL statement and the most recent "BEGIN". Any
+# TEST block immediately proceeding the SQL statement is evaluated, and
+# then the SQL statement reexecuted with the incremented N value.
+#
+# That make any sense? If not, read the code in [run_test] and it might.
+#
+# Extra restriction imposed by the implementation:
+#
+# * If a PREP block starts a transaction, it must finish it.
+# * A PREP block may not close a transaction it did not start.
+#
+#--------------------------------------------------------------------------
+
+
+# These procs are used to build up a "program" in global variable
+# ::run_test_script. At the end of this file, the proc [run_test] is used
+# to execute the program (and all test cases contained therein).
+#
+set ::run_test_script [list]
+proc TEST {id t} {lappend ::run_test_script -test [list $id $t]}
+proc PREP {p} {lappend ::run_test_script -prep [string trim $p]}
+proc DEBUG {s} {lappend ::run_test_script -debug $s}
+
+# SQL --
+#
+# SQL ?-norollback? <sql-text>
+#
+# Add an 'SQL' primitive to the program (see notes above). If the -norollback
+# switch is present, then the statement is not allowed to automatically roll
+# back any active transaction if malloc() fails. It must rollback the statement
+# transaction only.
+#
+proc SQL {a1 {a2 ""}} {
+ # An SQL primitive parameter is a list of two elements, a boolean value
+ # indicating if the statement may cause transaction rollback when malloc()
+ # fails, and the sql statement itself.
+ if {$a2 == ""} {
+ lappend ::run_test_script -sql [list true [string trim $a1]]
+ } else {
+ lappend ::run_test_script -sql [list false [string trim $a2]]
+ }
+}
+
+# TEST_AUTOCOMMIT --
+#
+# A shorthand test to see if a transaction is active or not. The first
+# argument - $id - is the integer number of the test case. The second
+# argument is either 1 or 0, the expected value of the auto-commit flag.
+#
+proc TEST_AUTOCOMMIT {id a} {
+ TEST $id "do_test \$testid { sqlite3_get_autocommit \$::DB } {$a}"
+}
+
+#--------------------------------------------------------------------------
+# Start of test program declaration
+#
+
+
+# Warm body test. A malloc() fails in the middle of a CREATE TABLE statement
+# in a single-statement transaction on an empty database. Not too much can go
+# wrong here.
+#
+TEST 1 {
+ do_test $testid {
+ execsql {SELECT tbl_name FROM sqlite_master;}
+ } {}
+}
+SQL {
+ CREATE TABLE IF NOT EXISTS abc(a, b, c);
+}
+TEST 2 {
+ do_test $testid.1 {
+ execsql {SELECT tbl_name FROM sqlite_master;}
+ } {abc}
+}
+
+# Insert a couple of rows into the table. each insert is in its own
+# transaction. test that the table is unpopulated before running the inserts
+# (and hence after each failure of the first insert), and that it has been
+# populated correctly after the final insert succeeds.
+#
+TEST 3 {
+ do_test $testid.2 {
+ execsql {SELECT * FROM abc}
+ } {}
+}
+SQL {INSERT INTO abc VALUES(1, 2, 3);}
+SQL {INSERT INTO abc VALUES(4, 5, 6);}
+SQL {INSERT INTO abc VALUES(7, 8, 9);}
+TEST 4 {
+ do_test $testid {
+ execsql {SELECT * FROM abc}
+ } {1 2 3 4 5 6 7 8 9}
+}
+
+# Test a CREATE INDEX statement. Because the table 'abc' is so small, the index
+# will all fit on a single page, so this doesn't test too much that the CREATE
+# TABLE statement didn't test. A few of the transient malloc()s in btree.c
+# perhaps.
+#
+SQL {CREATE INDEX abc_i ON abc(a, b, c);}
+TEST 4 {
+ do_test $testid {
+ execsql {
+ SELECT * FROM abc ORDER BY a DESC;
+ }
+ } {7 8 9 4 5 6 1 2 3}
+}
+
+# Test a DELETE statement. Also create a trigger and a view, just to make sure
+# these statements don't have any obvious malloc() related bugs in them. Note
+# that the test above will be executed each time the DELETE fails, so we're
+# also testing rollback of a DELETE from a table with an index on it.
+#
+SQL {DELETE FROM abc WHERE a > 2;}
+SQL {CREATE TRIGGER abc_t AFTER INSERT ON abc BEGIN SELECT 'trigger!'; END;}
+SQL {CREATE VIEW abc_v AS SELECT * FROM abc;}
+TEST 5 {
+ do_test $testid {
+ execsql {
+ SELECT name, tbl_name FROM sqlite_master ORDER BY name;
+ SELECT * FROM abc;
+ }
+ } {abc abc abc_i abc abc_t abc abc_v abc_v 1 2 3}
+}
+
+set sql {
+ BEGIN;DELETE FROM abc;
+}
+for {set i 1} {$i < 15} {incr i} {
+ set a $i
+ set b "String value $i"
+ set c [string repeat X $i]
+ append sql "INSERT INTO abc VALUES ($a, '$b', '$c');"
+}
+append sql {COMMIT;}
+PREP $sql
+
+SQL {
+ DELETE FROM abc WHERE oid IN (SELECT oid FROM abc ORDER BY random() LIMIT 5);
+}
+TEST 6 {
+ do_test $testid.1 {
+ execsql {SELECT count(*) FROM abc}
+ } {94}
+ do_test $testid.2 {
+ execsql {
+ SELECT min(
+ (oid == a) AND 'String value ' || a == b AND a == length(c)
+ ) FROM abc;
+ }
+ } {1}
+}
+SQL {
+ DELETE FROM abc WHERE oid IN (SELECT oid FROM abc ORDER BY random() LIMIT 5);
+}
+TEST 7 {
+ do_test $testid {
+ execsql {SELECT count(*) FROM abc}
+ } {89}
+ do_test $testid {
+ execsql {
+ SELECT min(
+ (oid == a) AND 'String value ' || a == b AND a == length(c)
+ ) FROM abc;
+ }
+ } {1}
+}
+SQL {
+ DELETE FROM abc WHERE oid IN (SELECT oid FROM abc ORDER BY random() LIMIT 5);
+}
+TEST 9 {
+ do_test $testid {
+ execsql {SELECT count(*) FROM abc}
+ } {84}
+ do_test $testid {
+ execsql {
+ SELECT min(
+ (oid == a) AND 'String value ' || a == b AND a == length(c)
+ ) FROM abc;
+ }
+ } {1}
+}
+
+set padding [string repeat X 500]
+PREP [subst {
+ DROP TABLE abc;
+ CREATE TABLE abc(a PRIMARY KEY, padding, b, c);
+ INSERT INTO abc VALUES(0, '$padding', 2, 2);
+ INSERT INTO abc VALUES(3, '$padding', 5, 5);
+ INSERT INTO abc VALUES(6, '$padding', 8, 8);
+}]
+
+TEST 10 {
+ do_test $testid {
+ execsql {SELECT a, b, c FROM abc}
+ } {0 2 2 3 5 5 6 8 8}
+}
+
+SQL {BEGIN;}
+SQL {INSERT INTO abc VALUES(9, 'XXXXX', 11, 12);}
+TEST_AUTOCOMMIT 11 0
+SQL -norollback {UPDATE abc SET a = a + 1, c = c + 1;}
+TEST_AUTOCOMMIT 12 0
+SQL {DELETE FROM abc WHERE a = 10;}
+TEST_AUTOCOMMIT 13 0
+SQL {COMMIT;}
+
+TEST 14 {
+ do_test $testid.1 {
+ sqlite3_get_autocommit $::DB
+ } {1}
+ do_test $testid.2 {
+ execsql {SELECT a, b, c FROM abc}
+ } {1 2 3 4 5 6 7 8 9}
+}
+
+PREP [subst {
+ DROP TABLE abc;
+ CREATE TABLE abc(a, padding, b, c);
+ INSERT INTO abc VALUES(1, '$padding', 2, 3);
+ INSERT INTO abc VALUES(4, '$padding', 5, 6);
+ INSERT INTO abc VALUES(7, '$padding', 8, 9);
+ CREATE INDEX abc_i ON abc(a, padding, b, c);
+}]
+
+TEST 15 {
+ db eval {PRAGMA cache_size = 10}
+}
+
+SQL {BEGIN;}
+SQL -norllbck {INSERT INTO abc (oid, a, padding, b, c) SELECT NULL, * FROM abc}
+TEST 16 {
+ do_test $testid {
+ execsql {SELECT a, count(*) FROM abc GROUP BY a;}
+ } {1 2 4 2 7 2}
+}
+SQL -norllbck {INSERT INTO abc (oid, a, padding, b, c) SELECT NULL, * FROM abc}
+TEST 17 {
+ do_test $testid {
+ execsql {SELECT a, count(*) FROM abc GROUP BY a;}
+ } {1 4 4 4 7 4}
+}
+SQL -norllbck {INSERT INTO abc (oid, a, padding, b, c) SELECT NULL, * FROM abc}
+TEST 18 {
+ do_test $testid {
+ execsql {SELECT a, count(*) FROM abc GROUP BY a;}
+ } {1 8 4 8 7 8}
+}
+SQL -norllbck {INSERT INTO abc (oid, a, padding, b, c) SELECT NULL, * FROM abc}
+TEST 19 {
+ do_test $testid {
+ execsql {SELECT a, count(*) FROM abc GROUP BY a;}
+ } {1 16 4 16 7 16}
+}
+SQL {COMMIT;}
+TEST 21 {
+ do_test $testid {
+ execsql {SELECT a, count(*) FROM abc GROUP BY a;}
+ } {1 16 4 16 7 16}
+}
+
+SQL {BEGIN;}
+SQL {DELETE FROM abc WHERE oid %2}
+TEST 22 {
+ do_test $testid {
+ execsql {SELECT a, count(*) FROM abc GROUP BY a;}
+ } {1 8 4 8 7 8}
+}
+SQL {DELETE FROM abc}
+TEST 23 {
+ do_test $testid {
+ execsql {SELECT * FROM abc}
+ } {}
+}
+SQL {ROLLBACK;}
+TEST 24 {
+ do_test $testid {
+ execsql {SELECT a, count(*) FROM abc GROUP BY a;}
+ } {1 16 4 16 7 16}
+}
+
+# Test some schema modifications inside of a transaction. These should all
+# cause transaction rollback if they fail. Also query a view, to cover a bit
+# more code.
+#
+PREP {DROP VIEW abc_v;}
+TEST 25 {
+ do_test $testid {
+ execsql {
+ SELECT name, tbl_name FROM sqlite_master;
+ }
+ } {abc abc abc_i abc}
+}
+SQL {BEGIN;}
+SQL {CREATE TABLE def(d, e, f);}
+SQL {CREATE TABLE ghi(g, h, i);}
+TEST 26 {
+ do_test $testid {
+ execsql {
+ SELECT name, tbl_name FROM sqlite_master;
+ }
+ } {abc abc abc_i abc def def ghi ghi}
+}
+SQL {CREATE VIEW v1 AS SELECT * FROM def, ghi}
+SQL {CREATE UNIQUE INDEX ghi_i1 ON ghi(g);}
+TEST 27 {
+ do_test $testid {
+ execsql {
+ SELECT name, tbl_name FROM sqlite_master;
+ }
+ } {abc abc abc_i abc def def ghi ghi v1 v1 ghi_i1 ghi}
+}
+SQL {INSERT INTO def VALUES('a', 'b', 'c')}
+SQL {INSERT INTO def VALUES(1, 2, 3)}
+SQL -norollback {INSERT INTO ghi SELECT * FROM def}
+TEST 28 {
+ do_test $testid {
+ execsql {
+ SELECT * FROM def, ghi WHERE d = g;
+ }
+ } {a b c a b c 1 2 3 1 2 3}
+}
+SQL {COMMIT}
+TEST 29 {
+ do_test $testid {
+ execsql {
+ SELECT * FROM v1 WHERE d = g;
+ }
+ } {a b c a b c 1 2 3 1 2 3}
+}
+
+# Test a simple multi-file transaction
+#
+forcedelete test2.db
+ifcapable attach {
+ SQL {ATTACH 'test2.db' AS aux;}
+ SQL {BEGIN}
+ SQL {CREATE TABLE aux.tbl2(x, y, z)}
+ SQL {INSERT INTO tbl2 VALUES(1, 2, 3)}
+ SQL {INSERT INTO def VALUES(4, 5, 6)}
+ TEST 30 {
+ do_test $testid {
+ execsql {
+ SELECT * FROM tbl2, def WHERE d = x;
+ }
+ } {1 2 3 1 2 3}
+ }
+ SQL {COMMIT}
+ TEST 31 {
+ do_test $testid {
+ execsql {
+ SELECT * FROM tbl2, def WHERE d = x;
+ }
+ } {1 2 3 1 2 3}
+ }
+}
+
+# Test what happens when a malloc() fails while there are other active
+# statements. This changes the way sqlite3VdbeHalt() works.
+TEST 32 {
+ if {![info exists ::STMT32]} {
+ set sql "SELECT name FROM sqlite_master"
+ set ::STMT32 [sqlite3_prepare $::DB $sql -1 DUMMY]
+ do_test $testid {
+ sqlite3_step $::STMT32
+ } {SQLITE_ROW}
+ }
+}
+SQL BEGIN
+TEST 33 {
+ do_test $testid {
+ execsql {SELECT * FROM ghi}
+ } {a b c 1 2 3}
+}
+SQL -norollback {
+ -- There is a unique index on ghi(g), so this statement may not cause
+ -- an automatic ROLLBACK. Hence the "-norollback" switch.
+ INSERT INTO ghi SELECT '2'||g, h, i FROM ghi;
+}
+TEST 34 {
+ if {[info exists ::STMT32]} {
+ do_test $testid {
+ sqlite3_finalize $::STMT32
+ } {SQLITE_OK}
+ unset ::STMT32
+ }
+}
+SQL COMMIT
+
+#
+# End of test program declaration
+#--------------------------------------------------------------------------
+
+proc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} {
+ if {[llength $arglist] %2} {
+ error "Uneven number of arguments to TEST"
+ }
+
+ for {set i 0} {$i < $pcstart} {incr i} {
+ set k2 [lindex $arglist [expr 2 * $i]]
+ set v2 [lindex $arglist [expr 2 * $i + 1]]
+ set ac [sqlite3_get_autocommit $::DB] ;# Auto-Commit
+ switch -- $k2 {
+ -sql {db eval [lindex $v2 1]}
+ -prep {db eval $v2}
+ }
+ set nac [sqlite3_get_autocommit $::DB] ;# New Auto-Commit
+ if {$ac && !$nac} {set begin_pc $i}
+ }
+
+ db rollback_hook [list incr ::rollback_hook_count]
+
+ set iFail $iFailStart
+ set pc $pcstart
+ while {$pc*2 < [llength $arglist]} {
+
+ # Id of this iteration:
+ set k [lindex $arglist [expr 2 * $pc]]
+ set iterid "pc=$pc.iFail=$iFail$k"
+ set v [lindex $arglist [expr 2 * $pc + 1]]
+
+ switch -- $k {
+
+ -test {
+ foreach {id script} $v {}
+ incr pc
+ }
+
+ -sql {
+ set ::rollback_hook_count 0
+
+ set ac [sqlite3_get_autocommit $::DB] ;# Auto-Commit
+ sqlite3_memdebug_fail $iFail -repeat 0
+ set rc [catch {db eval [lindex $v 1]} msg] ;# True error occurs
+ set nac [sqlite3_get_autocommit $::DB] ;# New Auto-Commit
+
+ if {$rc != 0 && $nac && !$ac} {
+ # Before [db eval] the auto-commit flag was clear. Now it
+ # is set. Since an error occured we assume this was not a
+ # commit - therefore a rollback occured. Check that the
+ # rollback-hook was invoked.
+ do_test malloc3-rollback_hook.$iterid {
+ set ::rollback_hook_count
+ } {1}
+ }
+
+ set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]
+ if {$rc == 0} {
+ # Successful execution of sql. The number of failed malloc()
+ # calls should be equal to the number of benign failures.
+ # Otherwise a malloc() failed and the error was not reported.
+ #
+ if {$nFail!=$nBenign} {
+ error "Unreported malloc() failure"
+ }
+
+ if {$ac && !$nac} {
+ # Before the [db eval] the auto-commit flag was set, now it
+ # is clear. We can deduce that a "BEGIN" statement has just
+ # been successfully executed.
+ set begin_pc $pc
+ }
+
+ incr pc
+ set iFail 1
+ integrity_check "malloc3-(integrity).$iterid"
+ } elseif {[regexp {.*out of memory} $msg] || [db errorcode] == 3082} {
+ # Out of memory error, as expected.
+ #
+ integrity_check "malloc3-(integrity).$iterid"
+ incr iFail
+ if {$nac && !$ac} {
+
+ if {![lindex $v 0] && [db errorcode] != 3082} {
+ # error "Statement \"[lindex $v 1]\" caused a rollback"
+ }
+
+ for {set i $begin_pc} {$i < $pc} {incr i} {
+ set k2 [lindex $arglist [expr 2 * $i]]
+ set v2 [lindex $arglist [expr 2 * $i + 1]]
+ set catchupsql ""
+ switch -- $k2 {
+ -sql {set catchupsql [lindex $v2 1]}
+ -prep {set catchupsql $v2}
+ }
+ db eval $catchupsql
+ }
+ }
+ } else {
+ error $msg
+ }
+
+ while {[lindex $arglist [expr 2 * ($pc -1)]] == "-test"} {
+ incr pc -1
+ }
+ }
+
+ -prep {
+ db eval $v
+ incr pc
+ }
+
+ -debug {
+ eval $v
+ incr pc
+ }
+
+ default { error "Unknown switch: $k" }
+ }
+ }
+}
+
+# Turn of the Tcl interface's prepared statement caching facility. Then
+# run the tests with "persistent" malloc failures.
+sqlite3_extended_result_codes db 1
+db cache size 0
+run_test $::run_test_script 1
+
+# Close and reopen the db.
+db close
+forcedelete test.db test.db-journal test2.db test2.db-journal
+sqlite3 db test.db
+sqlite3_extended_result_codes db 1
+set ::DB [sqlite3_connection_pointer db]
+
+# Turn off the Tcl interface's prepared statement caching facility in
+# the new connnection. Then run the tests with "transient" malloc failures.
+db cache size 0
+run_test $::run_test_script 0
+
+sqlite3_memdebug_fail -1
+finish_test
diff --git a/test/malloc4.test b/test/malloc4.test
new file mode 100644
index 0000000..e2a616a
--- /dev/null
+++ b/test/malloc4.test
@@ -0,0 +1,194 @@
+# 2005 November 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests to ensure that the library handles malloc() failures
+# correctly. The emphasis in this file is on sqlite3_column_XXX() APIs.
+#
+# $Id: malloc4.test,v 1.10 2008/02/18 22:24:58 drh Exp $
+
+#---------------------------------------------------------------------------
+# NOTES ON EXPECTED BEHAVIOUR
+#
+# [193] When a memory allocation failure occurs during sqlite3_column_name(),
+# sqlite3_column_name16(), sqlite3_column_decltype(), or
+# sqlite3_column_decltype16() the function shall return NULL.
+#
+#---------------------------------------------------------------------------
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+if {!$MEMDEBUG} {
+ puts "Skipping malloc4 tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+ifcapable !utf16 {
+ finish_test
+ return
+}
+
+proc do_stmt_test {id sql} {
+ set ::sql $sql
+ set go 1
+ for {set n 0} {$go} {incr n} {
+ set testid "malloc4-$id.$n"
+
+ # Prepare the statement
+ do_test ${testid}.1 {
+ set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]
+ expr [string length $::STMT] > 0
+ } {1}
+
+ # Set the Nth malloc() to fail.
+ sqlite3_memdebug_fail $n -repeat 0
+
+ # Test malloc failure in the _name(), _name16(), decltype() and
+ # decltype16() APIs. Calls that occur after the malloc() failure should
+ # return NULL. No error is raised though.
+ #
+ # ${testid}.2.1 - Call _name()
+ # ${testid}.2.2 - Call _name16()
+ # ${testid}.2.3 - Call _name()
+ # ${testid}.2.4 - Check that the return values of the above three calls are
+ # consistent with each other and with the simulated
+ # malloc() failures.
+ #
+ # Because the code that implements the _decltype() and _decltype16() APIs
+ # is the same as the _name() and _name16() implementations, we don't worry
+ # about explicitly testing them.
+ #
+ do_test ${testid}.2.1 {
+ set mf1 [expr [sqlite3_memdebug_pending] < 0]
+ set ::name8 [sqlite3_column_name $::STMT 0]
+ set mf2 [expr [sqlite3_memdebug_pending] < 0]
+ expr {$mf1 == $mf2 || $::name8 == ""}
+ } {1}
+ do_test ${testid}.2.2 {
+ set mf1 [expr [sqlite3_memdebug_pending] < 0]
+ set ::name16 [sqlite3_column_name16 $::STMT 0]
+ set ::name16 [encoding convertfrom unicode $::name16]
+ set ::name16 [string range $::name16 0 end-1]
+ set mf2 [expr [sqlite3_memdebug_pending] < 0]
+ expr {$mf1 == $mf2 || $::name16 == ""}
+ } {1}
+ do_test ${testid}.2.3 {
+ set mf1 [expr [sqlite3_memdebug_pending] < 0]
+ set ::name8_2 [sqlite3_column_name $::STMT 0]
+ set mf2 [expr [sqlite3_memdebug_pending] < 0]
+ expr {$mf1 == $mf2 || $::name8_2 == ""}
+ } {1}
+ set ::mallocFailed [expr [sqlite3_memdebug_pending] < 0]
+ do_test ${testid}.2.4 {
+ expr {
+ $::name8 == $::name8_2 && $::name16 == $::name8 && !$::mallocFailed ||
+ $::name8 == $::name8_2 && $::name16 == "" && $::mallocFailed ||
+ $::name8 == $::name16 && $::name8_2 == "" && $::mallocFailed ||
+ $::name8_2 == $::name16 && $::name8 == "" && $::mallocFailed
+ }
+ } {1}
+
+ # Step the statement so that we can call _text() and _text16(). Before
+ # running sqlite3_step(), make sure that malloc() is not about to fail.
+ # Memory allocation failures that occur within sqlite3_step() are tested
+ # elsewhere.
+ set mf [sqlite3_memdebug_pending]
+ sqlite3_memdebug_fail -1
+ do_test ${testid}.3 {
+ sqlite3_step $::STMT
+ } {SQLITE_ROW}
+ sqlite3_memdebug_fail $mf
+
+ # Test for malloc() failures within _text() and _text16().
+ #
+ do_test ${testid}.4.1 {
+ set ::text8 [sqlite3_column_text $::STMT 0]
+ set mf [expr [sqlite3_memdebug_pending] < 0 && !$::mallocFailed]
+ expr {$mf==0 || $::text8 == ""}
+ } {1}
+ do_test ${testid}.4.2 {
+ set ::text16 [sqlite3_column_text16 $::STMT 0]
+ set ::text16 [encoding convertfrom unicode $::text16]
+ set ::text16 [string range $::text16 0 end-1]
+ set mf [expr [sqlite3_memdebug_pending] < 0 && !$::mallocFailed]
+ expr {$mf==0 || $::text16 == ""}
+ } {1}
+ do_test ${testid}.4.3 {
+ set ::text8_2 [sqlite3_column_text $::STMT 0]
+ set mf [expr [sqlite3_memdebug_pending] < 0 && !$::mallocFailed]
+ expr {$mf==0 || $::text8_2 == "" || ($::text16 == "" && $::text8 != "")}
+ } {1}
+
+ # Test for malloc() failures within _int(), _int64() and _real(). The only
+ # way this can occur is if the string has to be translated from UTF-16 to
+ # UTF-8 before being converted to a numeric value.
+ do_test ${testid}.4.4.1 {
+ set mf [sqlite3_memdebug_pending]
+ sqlite3_memdebug_fail -1
+ sqlite3_column_text16 $::STMT 0
+ sqlite3_memdebug_fail $mf
+ sqlite3_column_int $::STMT 0
+ } {0}
+ do_test ${testid}.4.5 {
+ set mf [sqlite3_memdebug_pending]
+ sqlite3_memdebug_fail -1
+ sqlite3_column_text16 $::STMT 0
+ sqlite3_memdebug_fail $mf
+ sqlite3_column_int64 $::STMT 0
+ } {0}
+
+ do_test ${testid}.4.6 {
+ set mf [sqlite3_memdebug_pending]
+ sqlite3_memdebug_fail -1
+ sqlite3_column_text16 $::STMT 0
+ sqlite3_memdebug_fail $mf
+ sqlite3_column_double $::STMT 0
+ } {0.0}
+
+ set mallocFailedAfterStep [expr \
+ [sqlite3_memdebug_pending] < 0 && !$::mallocFailed
+ ]
+
+ sqlite3_memdebug_fail -1
+ # Test that if a malloc() failed the next call to sqlite3_step() returns
+ # SQLITE_ERROR. If malloc() did not fail, it should return SQLITE_DONE.
+ #
+ do_test ${testid}.5 {
+ sqlite3_step $::STMT
+ } [expr {$mallocFailedAfterStep ? "SQLITE_ERROR" : "SQLITE_DONE"}]
+
+ do_test ${testid}.6 {
+ sqlite3_finalize $::STMT
+ } [expr {$mallocFailedAfterStep ? "SQLITE_NOMEM" : "SQLITE_OK"}]
+
+ if {$::mallocFailed == 0 && $mallocFailedAfterStep == 0} {
+ sqlite3_memdebug_fail -1
+ set go 0
+ }
+ }
+}
+
+execsql {
+ CREATE TABLE tbl(
+ the_first_reasonably_long_column_name that_also_has_quite_a_lengthy_type
+ );
+ INSERT INTO tbl VALUES(
+ 'An extra long string. Far too long to be stored in NBFS bytes.'
+ );
+}
+
+do_stmt_test 1 "SELECT * FROM tbl"
+
+sqlite3_memdebug_fail -1
+finish_test
diff --git a/test/malloc5.test b/test/malloc5.test
new file mode 100644
index 0000000..71f56bb
--- /dev/null
+++ b/test/malloc5.test
@@ -0,0 +1,393 @@
+# 2005 November 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains test cases focused on the two memory-management APIs,
+# sqlite3_soft_heap_limit() and sqlite3_release_memory().
+#
+# Prior to version 3.6.2, calling sqlite3_release_memory() or exceeding
+# the configured soft heap limit could cause sqlite to upgrade database
+# locks and flush dirty pages to the file system. As of 3.6.2, this is
+# no longer the case. In version 3.6.2, sqlite3_release_memory() only
+# reclaims clean pages. This test file has been updated accordingly.
+#
+# $Id: malloc5.test,v 1.22 2009/04/11 19:09:54 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+db close
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping malloc5 tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+# Skip these tests if OMIT_MEMORY_MANAGEMENT was defined at compile time.
+ifcapable !memorymanage {
+ finish_test
+ return
+}
+
+sqlite3_soft_heap_limit 0
+sqlite3 db test.db
+
+do_test malloc5-1.1 {
+ # Simplest possible test. Call sqlite3_release_memory when there is exactly
+ # one unused page in a single pager cache. The page cannot be freed, as
+ # it is dirty. So sqlite3_release_memory() returns 0.
+ #
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ }
+ sqlite3_release_memory
+} {0}
+
+do_test malloc5-1.2 {
+ # Test that the transaction started in the above test is still active.
+ # The lock on the database file should not have been upgraded (this was
+ # not the case before version 3.6.2).
+ #
+ sqlite3 db2 test.db
+ execsql { SELECT * FROM sqlite_master } db2
+} {}
+do_test malloc5-1.3 {
+ # Call [sqlite3_release_memory] when there is exactly one unused page
+ # in the cache belonging to db2.
+ #
+ set ::pgalloc [sqlite3_release_memory]
+ expr $::pgalloc > 0
+} {1}
+
+do_test malloc5-1.4 {
+ # Commit the transaction and open a new one. Read 1 page into the cache.
+ # Because the page is not dirty, it is eligible for collection even
+ # before the transaction is concluded.
+ #
+ execsql {
+ COMMIT;
+ BEGIN;
+ SELECT * FROM abc;
+ }
+ sqlite3_release_memory
+} $::pgalloc
+
+do_test malloc5-1.5 {
+ # Conclude the transaction opened in the previous [do_test] block. This
+ # causes another page (page 1) to become eligible for recycling.
+ #
+ execsql { COMMIT }
+ sqlite3_release_memory
+} $::pgalloc
+
+do_test malloc5-1.6 {
+ # Manipulate the cache so that it contains two unused pages. One requires
+ # a journal-sync to free, the other does not.
+ db2 close
+ execsql {
+ BEGIN;
+ SELECT * FROM abc;
+ CREATE TABLE def(d, e, f);
+ }
+ sqlite3_release_memory 500
+} $::pgalloc
+
+do_test malloc5-1.7 {
+ # Database should not be locked this time.
+ sqlite3 db2 test.db
+ catchsql { SELECT * FROM abc } db2
+} {0 {}}
+do_test malloc5-1.8 {
+ # Try to release another block of memory. This will fail as the only
+ # pages currently in the cache are dirty (page 3) or pinned (page 1).
+ db2 close
+ sqlite3_release_memory 500
+} 0
+do_test malloc5-1.8 {
+ # Database is still not locked.
+ #
+ sqlite3 db2 test.db
+ catchsql { SELECT * FROM abc } db2
+} {0 {}}
+do_test malloc5-1.9 {
+ execsql {
+ COMMIT;
+ }
+} {}
+
+do_test malloc5-2.1 {
+ # Put some data in tables abc and def. Both tables are still wholly
+ # contained within their root pages.
+ execsql {
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(4, 5, 6);
+ INSERT INTO def VALUES(7, 8, 9);
+ INSERT INTO def VALUES(10,11,12);
+ }
+} {}
+do_test malloc5-2.2 {
+ # Load the root-page for table def into the cache. Then query table abc.
+ # Halfway through the query call sqlite3_release_memory(). The goal of this
+ # test is to make sure we don't free pages that are in use (specifically,
+ # the root of table abc).
+ sqlite3_release_memory
+ set nRelease 0
+ execsql {
+ BEGIN;
+ SELECT * FROM def;
+ }
+ set data [list]
+ db eval {SELECT * FROM abc} {
+ incr nRelease [sqlite3_release_memory]
+ lappend data $a $b $c
+ }
+ execsql {
+ COMMIT;
+ }
+ list $nRelease $data
+} [list $pgalloc [list 1 2 3 4 5 6]]
+
+do_test malloc5-3.1 {
+ # Simple test to show that if two pagers are opened from within this
+ # thread, memory is freed from both when sqlite3_release_memory() is
+ # called.
+ execsql {
+ BEGIN;
+ SELECT * FROM abc;
+ }
+ execsql {
+ SELECT * FROM sqlite_master;
+ BEGIN;
+ SELECT * FROM def;
+ } db2
+ sqlite3_release_memory
+} [expr $::pgalloc * 2]
+do_test malloc5-3.2 {
+ concat \
+ [execsql {SELECT * FROM abc; COMMIT}] \
+ [execsql {SELECT * FROM def; COMMIT} db2]
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+
+db2 close
+puts "Highwater mark: [sqlite3_memory_highwater]"
+
+# The following two test cases each execute a transaction in which
+# 10000 rows are inserted into table abc. The first test case is used
+# to ensure that more than 1MB of dynamic memory is used to perform
+# the transaction.
+#
+# The second test case sets the "soft-heap-limit" to 100,000 bytes (0.1 MB)
+# and tests to see that this limit is not exceeded at any point during
+# transaction execution.
+#
+# Before executing malloc5-4.* we save the value of the current soft heap
+# limit in variable ::soft_limit. The original value is restored after
+# running the tests.
+#
+set ::soft_limit [sqlite3_soft_heap_limit -1]
+execsql {PRAGMA cache_size=2000}
+do_test malloc5-4.1 {
+ execsql {BEGIN;}
+ execsql {DELETE FROM abc;}
+ for {set i 0} {$i < 10000} {incr i} {
+ execsql "INSERT INTO abc VALUES($i, $i, '[string repeat X 100]');"
+ }
+ execsql {COMMIT;}
+ sqlite3_release_memory
+ sqlite3_memory_highwater 1
+ execsql {SELECT * FROM abc}
+ set nMaxBytes [sqlite3_memory_highwater 1]
+ puts -nonewline " (Highwater mark: $nMaxBytes) "
+ expr $nMaxBytes > 1000000
+} {1}
+do_test malloc5-4.2 {
+ sqlite3_release_memory
+ sqlite3_soft_heap_limit 100000
+ sqlite3_memory_highwater 1
+ execsql {SELECT * FROM abc}
+ set nMaxBytes [sqlite3_memory_highwater 1]
+ puts -nonewline " (Highwater mark: $nMaxBytes) "
+ expr $nMaxBytes <= 110000
+} {1}
+do_test malloc5-4.3 {
+ # Check that the content of table abc is at least roughly as expected.
+ execsql {
+ SELECT count(*), sum(a), sum(b) FROM abc;
+ }
+} [list 10000 [expr int(10000.0 * 4999.5)] [expr int(10000.0 * 4999.5)]]
+
+# Restore the soft heap limit.
+sqlite3_soft_heap_limit $::soft_limit
+
+# Test that there are no problems calling sqlite3_release_memory when
+# there are open in-memory databases.
+#
+# At one point these tests would cause a seg-fault.
+#
+do_test malloc5-5.1 {
+ db close
+ sqlite3 db :memory:
+ execsql {
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES('abcdefghi', 1234567890, NULL);
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ INSERT INTO abc SELECT * FROM abc;
+ }
+ sqlite3_release_memory
+} 0
+do_test malloc5-5.2 {
+ sqlite3_soft_heap_limit 5000
+ execsql {
+ COMMIT;
+ PRAGMA temp_store = memory;
+ SELECT * FROM abc ORDER BY a;
+ }
+ expr 1
+} {1}
+sqlite3_soft_heap_limit $::soft_limit
+
+#-------------------------------------------------------------------------
+# The following test cases (malloc5-6.*) test the new global LRU list
+# used to determine the pages to recycle when sqlite3_release_memory is
+# called and there is more than one pager open.
+#
+proc nPage {db} {
+ set bt [btree_from_db $db]
+ array set stats [btree_pager_stats $bt]
+ set stats(page)
+}
+db close
+forcedelete test.db test.db-journal test2.db test2.db-journal
+
+# This block of test-cases (malloc5-6.1.*) prepares two database files
+# for the subsequent tests.
+do_test malloc5-6.1.1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size=1024;
+ PRAGMA default_cache_size=10;
+ }
+ execsql {
+ PRAGMA temp_store = memory;
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY, b, c);
+ INSERT INTO abc VALUES(randstr(50,50), randstr(75,75), randstr(100,100));
+ INSERT INTO abc
+ SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;
+ INSERT INTO abc
+ SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;
+ COMMIT;
+ }
+ forcecopy test.db test2.db
+ sqlite3 db2 test2.db
+ list \
+ [expr ([file size test.db]/1024)>20] [expr ([file size test2.db]/1024)>20]
+} {1 1}
+do_test malloc5-6.1.2 {
+ list [execsql {PRAGMA cache_size}] [execsql {PRAGMA cache_size} db2]
+} {10 10}
+
+do_test malloc5-6.2.1 {
+ execsql {SELECT * FROM abc} db2
+ execsql {SELECT * FROM abc} db
+ expr [nPage db] + [nPage db2]
+} {20}
+
+do_test malloc5-6.2.2 {
+ # If we now try to reclaim some memory, it should come from the db2 cache.
+ sqlite3_release_memory 3000
+ expr [nPage db] + [nPage db2]
+} {17}
+do_test malloc5-6.2.3 {
+ # Access the db2 cache again, so that all the db2 pages have been used
+ # more recently than all the db pages. Then try to reclaim 3000 bytes.
+ # This time, 3 pages should be pulled from the db cache.
+ execsql { SELECT * FROM abc } db2
+ sqlite3_release_memory 3000
+ expr [nPage db] + [nPage db2]
+} {17}
+
+do_test malloc5-6.3.1 {
+ # Now open a transaction and update 2 pages in the db2 cache. Then
+ # do a SELECT on the db cache so that all the db pages are more recently
+ # used than the db2 pages. When we try to free memory, SQLite should
+ # free the non-dirty db2 pages, then the db pages, then finally use
+ # sync() to free up the dirty db2 pages. The only page that cannot be
+ # freed is page1 of db2. Because there is an open transaction, the
+ # btree layer holds a reference to page 1 in the db2 cache.
+ execsql {
+ BEGIN;
+ UPDATE abc SET c = randstr(100,100)
+ WHERE rowid = 1 OR rowid = (SELECT max(rowid) FROM abc);
+ } db2
+ execsql { SELECT * FROM abc } db
+ expr [nPage db] + [nPage db2]
+} {20}
+do_test malloc5-6.3.2 {
+ # Try to release 7700 bytes. This should release all the
+ # non-dirty pages held by db2.
+ sqlite3_release_memory [expr 7*1100]
+ list [nPage db] [nPage db2]
+} {10 3}
+do_test malloc5-6.3.3 {
+ # Try to release another 1000 bytes. This should come fromt the db
+ # cache, since all three pages held by db2 are either in-use or diry.
+ sqlite3_release_memory 1000
+ list [nPage db] [nPage db2]
+} {9 3}
+do_test malloc5-6.3.4 {
+ # Now release 9900 more (about 9 pages worth). This should expunge
+ # the rest of the db cache. But the db2 cache remains intact, because
+ # SQLite tries to avoid calling sync().
+ if {$::tcl_platform(wordSize)==8} {
+ sqlite3_release_memory 10177
+ } else {
+ sqlite3_release_memory 9900
+ }
+ list [nPage db] [nPage db2]
+} {0 3}
+do_test malloc5-6.3.5 {
+ # But if we are really insistent, SQLite will consent to call sync()
+ # if there is no other option. UPDATE: As of 3.6.2, SQLite will not
+ # call sync() in this scenario. So no further memory can be reclaimed.
+ sqlite3_release_memory 1000
+ list [nPage db] [nPage db2]
+} {0 3}
+do_test malloc5-6.3.6 {
+ # The referenced page (page 1 of the db2 cache) will not be freed no
+ # matter how much memory we ask for:
+ sqlite3_release_memory 31459
+ list [nPage db] [nPage db2]
+} {0 3}
+
+db2 close
+
+sqlite3_soft_heap_limit $::soft_limit
+finish_test
+catch {db close}
diff --git a/test/malloc6.test b/test/malloc6.test
new file mode 100644
index 0000000..ded3d1e
--- /dev/null
+++ b/test/malloc6.test
@@ -0,0 +1,55 @@
+# 2006 June 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file attempts to check the library in an out-of-memory situation.
+#
+# $Id: malloc6.test,v 1.5 2008/02/18 22:24:58 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping malloc6 tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+
+set sqlite_os_trace 0
+do_malloc_test malloc6-1 -tclprep {
+ db close
+} -tclbody {
+ if {[catch {sqlite3 db test.db}]} {
+ error "out of memory"
+ }
+ sqlite3_extended_result_codes db 1
+} -sqlbody {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE IF NOT EXISTS t1(
+ a int, b float, c double, d text, e varchar(20),
+ primary key(a,b,c)
+ );
+ CREATE TABLE IF NOT EXISTS t1(
+ a int, b float, c double, d text, e varchar(20),
+ primary key(a,b,c)
+ );
+ DROP TABLE IF EXISTS t1;
+}
+
+# Ensure that no file descriptors were leaked.
+do_test malloc6-1.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+finish_test
diff --git a/test/malloc7.test b/test/malloc7.test
new file mode 100644
index 0000000..3e301c8
--- /dev/null
+++ b/test/malloc7.test
@@ -0,0 +1,48 @@
+# 2006 July 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file contains additional out-of-memory checks (see malloc.tcl)
+# added to expose a bug in out-of-memory handling for sqlite3_prepare16().
+#
+# $Id: malloc7.test,v 1.5 2008/02/18 22:24:58 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping malloc7 tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+
+do_malloc_test malloc7-1 -sqlprep {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE INDEX i1 ON t1(b,c);
+} -tclbody {
+ set sql16 [encoding convertto unicode "SELECT * FROM sqlite_master"]
+ append sql16 "\00\00"
+ set nbyte [string length $sql16]
+ set ::STMT [sqlite3_prepare16 db $sql16 $nbyte DUMMY]
+ sqlite3_finalize $::STMT
+}
+
+
+# Ensure that no file descriptors were leaked.
+do_test malloc-99.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+puts open-file-count=$sqlite_open_file_count
+finish_test
diff --git a/test/malloc8.test b/test/malloc8.test
new file mode 100644
index 0000000..9192eaf
--- /dev/null
+++ b/test/malloc8.test
@@ -0,0 +1,95 @@
+# 2007 April 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file contains additional out-of-memory checks (see malloc.tcl)
+# added to expose a bug in out-of-memory handling for sqlite3_value_text()
+#
+# $Id: malloc8.test,v 1.7 2008/02/18 22:24:58 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping malloc8 tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+
+# The setup is a database with UTF-16 encoding that contains a single
+# large string. We will be running lots of queries against this
+# database. Because we will be extracting the string as UTF-8, there
+# is a type conversion that occurs and thus an opportunity for malloc()
+# to fail and for sqlite3_value_text() to return 0 even though
+# sqlite3_value_type() returns SQLITE_TEXT.
+#
+
+do_malloc_test malloc8-1 -sqlprep {
+ PRAGMA encoding='UTF-16';
+ CREATE TABLE t1(a);
+ INSERT INTO t1
+ VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');
+} -sqlbody {
+ SELECT lower(a), upper(a), quote(a), trim(a), trim('x',a) FROM t1;
+}
+do_malloc_test malloc8-2 -sqlprep {
+ PRAGMA encoding='UTF-16';
+ CREATE TABLE t1(a);
+ INSERT INTO t1
+ VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');
+} -sqlbody {
+ SELECT replace(a,'x','y'), replace('x',a,'y'), replace('x','y',a)
+ FROM t1;
+}
+do_malloc_test malloc8-3 -sqlprep {
+ PRAGMA encoding='UTF-16';
+ CREATE TABLE t1(a);
+ INSERT INTO t1
+ VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');
+} -sqlbody {
+ SELECT length(a), substr(a, 4, 4) FROM t1;
+}
+ifcapable datetime {
+ do_malloc_test malloc8-4 -sqlprep {
+ PRAGMA encoding='UTF-16';
+ CREATE TABLE t1(a);
+ INSERT INTO t1
+ VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');
+ } -sqlbody {
+ SELECT julianday(a,a) FROM t1;
+ }
+}
+do_malloc_test malloc8-5 -sqlprep {
+ PRAGMA encoding='UTF-16';
+ CREATE TABLE t1(a);
+ INSERT INTO t1
+ VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');
+} -sqlbody {
+ SELECT 1 FROM t1 WHERE a LIKE 'hello' ESCAPE NULL;
+}
+do_malloc_test malloc8-6 -sqlprep {
+ PRAGMA encoding='UTF-16';
+ CREATE TABLE t1(a);
+ INSERT INTO t1
+ VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');
+} -sqlbody {
+ SELECT hex(randomblob(100));
+}
+
+# Ensure that no file descriptors were leaked.
+do_test malloc-99.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+finish_test
diff --git a/test/malloc9.test b/test/malloc9.test
new file mode 100644
index 0000000..e142345
--- /dev/null
+++ b/test/malloc9.test
@@ -0,0 +1,51 @@
+# 2007 April 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file contains additional out-of-memory checks (see malloc.tcl)
+# added to expose a bug in out-of-memory handling for sqlite3_prepare().
+#
+# $Id: malloc9.test,v 1.5 2008/04/04 12:21:26 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping malloc9 tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+
+do_malloc_test malloc-9.1 -tclprep {
+ set sql {CREATE TABLE t1(x)}
+ set sqlbytes [string length $sql]
+ append sql {; INSERT INTO t1 VALUES(1)}
+} -tclbody {
+ if {[catch {sqlite3_prepare db $sql $sqlbytes TAIL} STMT]} {
+ set msg $STMT
+ set STMT {}
+ error $msg
+ }
+} -cleanup {
+ if {$STMT!=""} {
+ sqlite3_finalize $STMT
+ }
+}
+
+# Ensure that no file descriptors were leaked.
+do_test malloc9-99.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+finish_test
diff --git a/test/mallocA.test b/test/mallocA.test
new file mode 100644
index 0000000..8995127
--- /dev/null
+++ b/test/mallocA.test
@@ -0,0 +1,78 @@
+# 2007 April 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file contains additional out-of-memory checks (see malloc.tcl).
+#
+# $Id: mallocA.test,v 1.8 2008/02/18 22:24:58 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping mallocA tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+
+# Construct a test database
+#
+forcedelete test.db.bu
+db eval {
+ CREATE TABLE t1(a COLLATE NOCASE,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(1,2,4);
+ INSERT INTO t1 VALUES(2,3,4);
+ CREATE INDEX t1i1 ON t1(a);
+ CREATE INDEX t1i2 ON t1(b,c);
+ CREATE TABLE t2(x,y,z);
+}
+db close
+copy_file test.db test.db.bu
+
+
+do_malloc_test mallocA-1 -testdb test.db.bu -sqlbody {
+ ANALYZE
+}
+do_malloc_test mallocA-1.1 -testdb test.db.bu -sqlbody {
+ ANALYZE t1
+}
+do_malloc_test mallocA-1.2 -testdb test.db.bu -sqlbody {
+ ANALYZE main
+}
+do_malloc_test mallocA-1.3 -testdb test.db.bu -sqlbody {
+ ANALYZE main.t1
+}
+ifcapable reindex {
+ do_malloc_test mallocA-2 -testdb test.db.bu -sqlbody {
+ REINDEX;
+ }
+ do_malloc_test mallocA-3 -testdb test.db.bu -sqlbody {
+ REINDEX t1;
+ }
+ do_malloc_test mallocA-4 -testdb test.db.bu -sqlbody {
+ REINDEX main.t1;
+ }
+ do_malloc_test mallocA-5 -testdb test.db.bu -sqlbody {
+ REINDEX nocase;
+ }
+}
+
+# Ensure that no file descriptors were leaked.
+do_test malloc-99.X {
+ catch {db close}
+ set sqlite_open_file_count
+} {0}
+
+forcedelete test.db.bu
+finish_test
diff --git a/test/mallocAll.test b/test/mallocAll.test
new file mode 100644
index 0000000..b1c94ea
--- /dev/null
+++ b/test/mallocAll.test
@@ -0,0 +1,66 @@
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file runs all out-of-memory tests.
+#
+# $Id: mallocAll.test,v 1.1 2007/11/26 13:36:00 drh Exp $
+
+proc lshift {lvar} {
+ upvar $lvar l
+ set ret [lindex $l 0]
+ set l [lrange $l 1 end]
+ return $ret
+}
+while {[set arg [lshift argv]] != ""} {
+ switch -- $arg {
+ -sharedpagercache {
+ sqlite3_enable_shared_cache 1
+ }
+ default {
+ set argv [linsert $argv 0 $arg]
+ break
+ }
+ }
+}
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+rename finish_test really_finish_test
+proc finish_test {} {}
+set G(isquick) 1
+
+set EXCLUDE {
+ mallocAll.test
+}
+
+if {[sqlite3 -has-codec]} {
+ # lappend EXCLUDE \
+ # conflict.test
+}
+
+
+# Files to include in the test. If this list is empty then everything
+# that is not in the EXCLUDE list is run.
+#
+set INCLUDE {
+}
+
+foreach testfile [lsort -dictionary [glob $testdir/*malloc*.test]] {
+ set tail [file tail $testfile]
+ if {[lsearch -exact $EXCLUDE $tail]>=0} continue
+ if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
+ source $testfile
+ catch {db close}
+ if {$sqlite_open_file_count>0} {
+ puts "$tail did not close all files: $sqlite_open_file_count"
+ fail_test $tail
+ set sqlite_open_file_count 0
+ }
+}
+source $testdir/misuse.test
+
+set sqlite_open_file_count 0
+really_finish_test
diff --git a/test/mallocB.test b/test/mallocB.test
new file mode 100644
index 0000000..73468b5
--- /dev/null
+++ b/test/mallocB.test
@@ -0,0 +1,51 @@
+# 2007 May 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file contains additional out-of-memory checks (see malloc.tcl).
+# These were all discovered by fuzzy generation of SQL. Apart from
+# that they have little in common.
+#
+#
+# $Id: mallocB.test,v 1.9 2008/02/18 22:24:58 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping mallocB tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+source $testdir/malloc_common.tcl
+
+do_malloc_test mallocB-1 -sqlbody {SELECT - 456}
+do_malloc_test mallocB-2 -sqlbody {SELECT - 456.1}
+do_malloc_test mallocB-3 -sqlbody {SELECT random()}
+do_malloc_test mallocB-4 -sqlbody {SELECT length(zeroblob(1000))}
+ifcapable subquery {
+ do_malloc_test mallocB-5 -sqlbody {SELECT * FROM (SELECT 1) GROUP BY 1;}
+}
+
+# The following test checks that there are no resource leaks following a
+# malloc() failure in sqlite3_set_auxdata().
+#
+# Note: This problem was not discovered by fuzzy generation of SQL. Not
+# that it really matters.
+#
+do_malloc_test mallocB-6 -sqlbody { SELECT test_auxdata('hello world'); }
+
+do_malloc_test mallocB-7 -sqlbody {
+ SELECT strftime(hex(randomblob(50)) || '%Y', 'now')
+}
+
+finish_test
diff --git a/test/mallocC.test b/test/mallocC.test
new file mode 100644
index 0000000..7943353
--- /dev/null
+++ b/test/mallocC.test
@@ -0,0 +1,122 @@
+# 2007 Aug 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file tests aspects of the malloc failure while parsing
+# CREATE TABLE statements in auto_vacuum mode.
+#
+# $Id: mallocC.test,v 1.10 2009/04/11 16:27:50 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping mallocC tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+proc do_mallocC_test {tn args} {
+ array set ::mallocopts $args
+ #set sum [allcksum db]
+
+ for {set ::n 1} {true} {incr ::n} {
+
+ # Run the SQL. Malloc number $::n is set to fail. A malloc() failure
+ # may or may not be reported.
+ sqlite3_memdebug_fail $::n -repeat 1
+ do_test mallocC-$tn.$::n.1 {
+ set res [catchsql [string trim $::mallocopts(-sql)]]
+ set rc [expr {
+ 0==[string compare $res {1 {out of memory}}] ||
+ [db errorcode] == 3082 ||
+ 0==[lindex $res 0]
+ }]
+ if {$rc!=1} {
+ puts "Error: $res"
+ }
+ set rc
+ } {1}
+
+ # If $::n is greater than the number of malloc() calls required to
+ # execute the SQL, then this test is finished. Break out of the loop.
+ set nFail [sqlite3_memdebug_fail -1]
+ if {$nFail==0} {
+ break
+ }
+
+ # Recover from the malloc failure.
+ #
+ # Update: The new malloc() failure handling means that a transaction may
+ # still be active even if a malloc() has failed. But when these tests were
+ # written this was not the case. So do a manual ROLLBACK here so that the
+ # tests pass.
+ do_test mallocC-$tn.$::n.2 {
+ catch {
+ execsql {
+ ROLLBACK;
+ }
+ }
+ expr 0
+ } {0}
+
+ # Checksum the database.
+ #do_test mallocC-$tn.$::n.3 {
+ # allcksum db
+ #} $sum
+
+ #integrity_check mallocC-$tn.$::n.4
+ }
+ unset ::mallocopts
+}
+
+sqlite3_extended_result_codes db 1
+
+execsql {
+ PRAGMA auto_vacuum=1;
+ CREATE TABLE t0(a, b, c);
+}
+
+# The number of memory allocation failures is different on 64-bit
+# and 32-bit systems due to larger structures on 64-bit systems
+# overflowing the lookaside more often. To debug problems, it is
+# sometimes helpful to reduce the size of the lookaside allocation
+# blocks. But this is normally disabled.
+#
+if {0} {
+ db close
+ sqlite3_shutdown
+ sqlite3_config_lookaside 50 500
+ sqlite3_initialize
+ autoinstall_test_functions
+ sqlite3 db test.db
+}
+
+do_mallocC_test 1 -sql {
+ BEGIN;
+ -- Allocate 32 new root pages. This will exercise the 'extract specific
+ -- page from the freelist' code when in auto-vacuum mode (see the
+ -- allocatePage() routine in btree.c).
+ CREATE TABLE t1(a UNIQUE, b UNIQUE, c UNIQUE);
+ CREATE TABLE t2(a UNIQUE, b UNIQUE, c UNIQUE);
+ CREATE TABLE t3(a UNIQUE, b UNIQUE, c UNIQUE);
+ CREATE TABLE t4(a UNIQUE, b UNIQUE, c UNIQUE);
+ CREATE TABLE t5(a UNIQUE, b UNIQUE, c UNIQUE);
+ CREATE TABLE t6(a UNIQUE, b UNIQUE, c UNIQUE);
+ CREATE TABLE t7(a UNIQUE, b UNIQUE, c UNIQUE);
+ CREATE TABLE t8(a UNIQUE, b UNIQUE, c UNIQUE);
+
+ ROLLBACK;
+}
+
+finish_test
diff --git a/test/mallocD.test b/test/mallocD.test
new file mode 100644
index 0000000..08a2ba4
--- /dev/null
+++ b/test/mallocD.test
@@ -0,0 +1,65 @@
+# 2007 Aug 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: mallocD.test,v 1.6 2008/02/18 22:24:58 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping mallocD tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+db close
+sqlite3_simulate_device -char atomic
+sqlite3 db test.db -vfs devsym
+
+set PREP {
+ PRAGMA page_size = 1024;
+ CREATE TABLE abc(a, b, c);
+}
+
+do_malloc_test mallocD-1 -sqlprep $PREP -sqlbody {
+ INSERT INTO abc VALUES(1, 2, 3);
+}
+
+do_malloc_test mallocD-2 -sqlprep $PREP -sqlbody {
+ BEGIN;
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(4, 5, 6);
+ ROLLBACK;
+}
+
+do_malloc_test mallocD-3 -sqlprep $PREP -sqlbody {
+ BEGIN;
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(4, 5, randstr(1500,1500));
+ COMMIT;
+}
+
+ifcapable attach {
+ do_malloc_test mallocD-4 -sqlprep $PREP -sqlbody {
+ ATTACH 'test2.db' AS aux;
+ BEGIN;
+ CREATE TABLE aux.def(d, e, f);
+ INSERT INTO abc VALUES(4, 5, 6);
+ COMMIT;
+ }
+}
+
+sqlite3_simulate_device -char {}
+
+finish_test
diff --git a/test/mallocE.test b/test/mallocE.test
new file mode 100644
index 0000000..e87bc8b
--- /dev/null
+++ b/test/mallocE.test
@@ -0,0 +1,48 @@
+# 2007 Aug 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test script checks that tickets #2784 and #2789 have been fixed.
+#
+# $Id: mallocE.test,v 1.3 2008/02/18 22:24:58 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping mallocE tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+# ticket #2784
+#
+set PREP {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(x, y, z);
+}
+do_malloc_test mallocE-1 -sqlprep $PREP -sqlbody {
+ SELECT p, q FROM (SELECT a+b AS p, b+c AS q FROM t1, t2 WHERE c>5)
+ LEFT JOIN t2 ON p=x;
+}
+
+# Ticket #2789
+#
+do_malloc_test mallocE-2 -sqlprep $PREP -sqlbody {
+ SELECT x, y2 FROM (SELECT a+b AS x, b+c AS y2 FROM t1, t2 WHERE c>5)
+ LEFT JOIN t2 USING(x) WHERE y2>11;
+}
+
+
+finish_test
diff --git a/test/mallocF.test b/test/mallocF.test
new file mode 100644
index 0000000..0015005
--- /dev/null
+++ b/test/mallocF.test
@@ -0,0 +1,76 @@
+# 2007 Aug 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test script checks that tickets #2794, #2795, #2796, and #2797
+# have been fixed.
+#
+# $Id: mallocF.test,v 1.4 2008/02/18 22:24:58 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping mallocF tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+# tickets #2794 and #2795 and #2797
+#
+set PREP {
+ CREATE TABLE t1(x,y);
+ INSERT INTO t1 VALUES('abc123', 5);
+ INSERT INTO t1 VALUES('xyz987', 42);
+}
+do_malloc_test malloeF-1 -sqlprep $PREP -sqlbody {
+ SELECT * FROM t1 WHERE x GLOB 'abc*'
+}
+
+# ticket #2796
+#
+set PREP {
+ CREATE TABLE t1(x PRIMARY KEY,y UNIQUE);
+ INSERT INTO t1 VALUES('abc123', 5);
+ INSERT INTO t1 VALUES('xyz987', 42);
+}
+do_malloc_test malloeF-2 -sqlprep $PREP -sqlbody {
+ SELECT x FROM t1
+ WHERE y=1 OR y=2 OR y=3 OR y=4 OR y=5
+ OR y=6 OR y=7 OR y=8 OR y=9 OR y=10
+ OR y=11 OR y=12 OR y=13 OR y=14 OR y=15
+ OR y=x
+}
+
+set PREP {
+ CREATE TABLE t1(x PRIMARY KEY,y UNIQUE);
+ INSERT INTO t1 VALUES('abc123', 5);
+ INSERT INTO t1 VALUES('xyz987', 42);
+}
+do_malloc_test malloeF-3 -sqlprep $PREP -sqlbody {
+ SELECT x FROM t1 WHERE y BETWEEN 10 AND 29
+}
+
+# Ticket #2843
+#
+set PREP {
+ CREATE TABLE t1(x);
+ CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN
+ SELECT 'hello';
+ END;
+}
+do_malloc_test mallocF-4 -sqlprep $PREP -sqlbody {
+ INSERT INTO t1 VALUES(random());
+}
+
+finish_test
diff --git a/test/mallocG.test b/test/mallocG.test
new file mode 100644
index 0000000..eab533b
--- /dev/null
+++ b/test/mallocG.test
@@ -0,0 +1,68 @@
+# 2007 Aug 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test script checks malloc failures in various obscure operations.
+#
+# $Id: mallocG.test,v 1.5 2008/08/01 18:47:02 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Only run these tests if memory debugging is turned on.
+#
+if {!$MEMDEBUG} {
+ puts "Skipping mallocG tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+
+# Malloc failures while opening a database connection.
+#
+do_malloc_test mallocG-1 -tclbody {
+ db close
+ sqlite3 db test.db
+}
+
+do_malloc_test mallocG-2 -sqlprep {
+ CREATE TABLE t1(x, y);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY);
+} -sqlbody {
+ SELECT y FROM t1 WHERE x IN t2;
+}
+
+do_malloc_test mallocG-3 -sqlprep {
+ CREATE TABLE t1(x UNIQUE);
+ INSERT INTO t1 VALUES ('hello');
+ INSERT INTO t1 VALUES ('out there');
+} -sqlbody {
+ SELECT * FROM t1
+ WHERE x BETWEEN 'a' AND 'z'
+ AND x BETWEEN 'c' AND 'w'
+ AND x BETWEEN 'e' AND 'u'
+ AND x BETWEEN 'g' AND 'r'
+ AND x BETWEEN 'i' AND 'q'
+ AND x BETWEEN 'i' AND 'm'
+}
+
+proc utf16 {utf8} {
+ set utf16 [encoding convertto unicode $utf8]
+ append utf16 "\x00\x00"
+ return $utf16
+}
+
+do_malloc_test mallocG-4 -tclbody {
+ set rc [sqlite3_complete16 [utf16 "SELECT * FROM t1;"]]
+ if {$rc==1} {set rc 0} {error "out of memory"}
+ set rc
+}
+
+finish_test
diff --git a/test/mallocH.test b/test/mallocH.test
new file mode 100644
index 0000000..7017b38
--- /dev/null
+++ b/test/mallocH.test
@@ -0,0 +1,73 @@
+# 2008 August 01
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test script checks malloc failures in various obscure operations.
+#
+# $Id: mallocH.test,v 1.2 2008/08/01 20:10:09 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Malloc failures in journaling of in-memory databases.
+#
+do_malloc_test mallocH-1 -tclprep {
+ db close
+ sqlite3 db :memory:
+ db eval {
+ CREATE TABLE t1(x UNIQUE, y);
+ INSERT INTO t1 VALUES(1,2);
+ }
+} -sqlbody {
+ INSERT INTO t1 SELECT x+1, y+100 FROM t1;
+}
+
+# Malloc failures while parsing a CASE expression.
+#
+do_malloc_test mallocH-2 -sqlbody {
+ SELECT CASE WHEN 1 THEN 1 END;
+}
+
+# Malloc failures while parsing a EXISTS(SELECT ...)
+#
+do_malloc_test mallocH-3 -sqlbody {
+ SELECT 3+EXISTS(SELECT * FROM sqlite_master);
+}
+
+# Malloc failures within the replace() function.
+#
+do_malloc_test mallocH-3 -sqlbody {
+ SELECT replace('ababa','a','xyzzy');
+}
+
+# Malloc failures during EXPLAIN.
+#
+ifcapable explain {
+ do_malloc_test mallocH-4 -sqlprep {
+ CREATE TABLE abc(a PRIMARY KEY, b, c);
+ } -sqlbody {
+ EXPLAIN SELECT * FROM abc AS t2 WHERE rowid=1;
+ EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid=1;
+ }
+}
+
+# Malloc failure during integrity_check pragma.
+#
+do_malloc_test mallocH-5 -sqlprep {
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ CREATE TABLE t2(x,y);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 SELECT * FROM t1;
+} -sqlbody {
+ PRAGMA integrity_check;
+}
+
+finish_test
diff --git a/test/mallocI.test b/test/mallocI.test
new file mode 100644
index 0000000..1229455
--- /dev/null
+++ b/test/mallocI.test
@@ -0,0 +1,64 @@
+# 2008 August 01
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test script checks malloc failures in various obscure operations.
+#
+# $Id: mallocI.test,v 1.3 2009/08/10 04:26:39 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# Malloc failures in a view.
+#
+do_malloc_test mallocI-1 -sqlprep {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE VIEW v1 AS SELECT a*b, c*d FROM t1 ORDER BY b-d;
+} -sqlbody {
+ SELECT * FROM v1
+}
+
+# Malloc failure while trying to service a pragma on a TEMP database.
+#
+do_malloc_test mallocI-2 -sqlbody {
+ PRAGMA temp.page_size
+}
+
+# Malloc failure while creating a table from a SELECT statement.
+#
+do_malloc_test mallocI-3 -sqlprep {
+ CREATE TABLE t1(a,b,c);
+} -sqlbody {
+ CREATE TABLE t2 AS SELECT b,c FROM t1;
+}
+
+# This tests that a malloc failure that occurs while passing the schema
+# does not result in a SHARED lock being left on the database file.
+#
+do_malloc_test mallocI-4 -tclprep {
+ sqlite3 db2 test.db
+ db2 eval {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+ }
+} -sqlbody {
+ SELECT * FROM t1
+} -cleanup {
+ do_test mallocI-4.$::n.2 {
+ # If this INSERT is possible then [db] does not hold a shared lock
+ # on the database file.
+ catchsql { INSERT INTO t1 VALUES(1, 2, 3) } db2
+ } {0 {}}
+ catch {db2 close}
+}
+catch { db2 close }
+
+finish_test
diff --git a/test/mallocJ.test b/test/mallocJ.test
new file mode 100644
index 0000000..e63f6b7
--- /dev/null
+++ b/test/mallocJ.test
@@ -0,0 +1,73 @@
+# 2008 August 01
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test script checks malloc failures in LIMIT operations for
+# UPDATE/DELETE statements.
+#
+# $Id: mallocJ.test,v 1.6 2009/01/09 02:49:32 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+ifcapable {update_delete_limit} {
+
+ do_malloc_test mallocJ-1 -sqlprep {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x int, y int);
+ INSERT INTO t1 VALUES(1,1);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(2,1);
+ INSERT INTO t1 VALUES(2,2);
+ INSERT INTO t1 VALUES(2,3);
+ } -sqlbody {
+ UPDATE t1 SET x=1 ORDER BY y LIMIT 2 OFFSET 2;
+ UPDATE t1 SET x=2 WHERE y=1 ORDER BY y LIMIT 2 OFFSET 2;
+ DELETE FROM t1 WHERE x=1 ORDER BY y LIMIT 2 OFFSET 2;
+ DELETE FROM t1 ORDER BY y LIMIT 2 OFFSET 2;
+ }
+
+}
+
+# ticket #3467
+do_malloc_test mallocJ-2 -sqlprep {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ PRAGMA vdbe_trace=ON;
+} -sqlbody {
+ SELECT a, b, 'abc' FROM t1
+ UNION
+ SELECT b, a, 'xyz' FROM t1
+ ORDER BY 2, 3;
+}
+
+# ticket #3478
+do_malloc_test mallocJ-3 -sqlbody {
+ EXPLAIN COMMIT
+}
+
+# ticket #3485
+do_malloc_test mallocJ-4 -sqlprep {
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE t2(x,y,z);
+} -sqlbody {
+ SELECT * FROM (SELECT a,b FROM t1 UNION ALL SELECT x, y FROM t2) ORDER BY 1
+}
+
+# coverage testing
+do_malloc_test mallocJ-5 -sqlprep {
+ CREATE TABLE t1(["a"]);
+} -sqlbody {
+ SELECT * FROM t1
+}
+
+finish_test
diff --git a/test/mallocK.test b/test/mallocK.test
new file mode 100644
index 0000000..971bd56
--- /dev/null
+++ b/test/mallocK.test
@@ -0,0 +1,72 @@
+# 2008 August 01
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test script checks malloc failures in WHERE clause analysis.
+#
+# $Id: mallocK.test,v 1.3 2009/01/08 21:00:03 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+set sql {SELECT * FROM t1, t2 WHERE (a=1 OR a=2)}
+for {set x 1} {$x<5} {incr x} {
+ append sql " AND b=y"
+ do_malloc_test mallocK-1.$x -sqlbody $sql -sqlprep {
+ CREATE TABLE t1(a,b);
+ CREATE TABLE t2(x,y);
+ }
+}
+
+set sql {SELECT * FROM t1 WHERE a GLOB 'xyz*' AND (a=1 OR a=2)}
+for {set x 1} {$x<5} {incr x} {
+ append sql " AND b!=$x"
+ do_malloc_test mallocK-2.$x -sqlbody $sql -sqlprep {
+ CREATE TABLE t1(a,b);
+ }
+}
+
+set sql {SELECT * FROM t1 WHERE a BETWEEN 5 AND 10}
+for {set x 1} {$x<5} {incr x} {
+ append sql " AND b=$x"
+ do_malloc_test mallocK-3.$x -sqlbody $sql -sqlprep {
+ CREATE TABLE t1(a,b);
+ }
+}
+
+set sql {SELECT * FROM t1 WHERE b=0}
+for {set x 1} {$x<5} {incr x} {
+ set term "(b=$x"
+ for {set y 0} {$y<$x} {incr y} {
+ append term " AND a!=$y"
+ }
+ append sql " OR $term)"
+ do_malloc_test mallocK-4.$x -sqlbody $sql -sqlprep {
+ CREATE TABLE t1(a,b);
+ }
+}
+
+ifcapable vtab {
+ set sql {SELECT * FROM t2 WHERE a MATCH 'xyz'}
+ for {set x 1} {$x<5} {incr x} {
+ append sql " AND b!=$x"
+ do_malloc_test mallocK-5.$x -sqlbody $sql -tclprep {
+ register_echo_module [sqlite3_connection_pointer db]
+ db eval {
+ CREATE TABLE t1(a,b);
+ CREATE VIRTUAL TABLE t2 USING echo(t1);
+ }
+ }
+ }
+}
+
+
+finish_test
diff --git a/test/malloc_common.tcl b/test/malloc_common.tcl
new file mode 100644
index 0000000..5937b95
--- /dev/null
+++ b/test/malloc_common.tcl
@@ -0,0 +1,660 @@
+# 2007 May 05
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains common code used by many different malloc tests
+# within the test suite.
+#
+# $Id: malloc_common.tcl,v 1.22 2008/09/23 16:41:30 danielk1977 Exp $
+
+# If we did not compile with malloc testing enabled, then do nothing.
+#
+ifcapable builtin_test {
+ set MEMDEBUG 1
+} else {
+ set MEMDEBUG 0
+ return 0
+}
+
+# Transient and persistent OOM errors:
+#
+set FAULTSIM(oom-transient) [list \
+ -injectstart {oom_injectstart 0} \
+ -injectstop oom_injectstop \
+ -injecterrlist {{1 {out of memory}}} \
+]
+set FAULTSIM(oom-persistent) [list \
+ -injectstart {oom_injectstart 1000000} \
+ -injectstop oom_injectstop \
+ -injecterrlist {{1 {out of memory}}} \
+]
+
+# Transient and persistent IO errors:
+#
+set FAULTSIM(ioerr-transient) [list \
+ -injectstart {ioerr_injectstart 0} \
+ -injectstop ioerr_injectstop \
+ -injecterrlist {{1 {disk I/O error}}} \
+]
+set FAULTSIM(ioerr-persistent) [list \
+ -injectstart {ioerr_injectstart 1} \
+ -injectstop ioerr_injectstop \
+ -injecterrlist {{1 {disk I/O error}}} \
+]
+
+# SQLITE_FULL errors (always persistent):
+#
+set FAULTSIM(full) [list \
+ -injectinstall fullerr_injectinstall \
+ -injectstart fullerr_injectstart \
+ -injectstop fullerr_injectstop \
+ -injecterrlist {{1 {database or disk is full}}} \
+ -injectuninstall fullerr_injectuninstall \
+]
+
+# Transient and persistent SHM errors:
+#
+set FAULTSIM(shmerr-transient) [list \
+ -injectinstall shmerr_injectinstall \
+ -injectstart {shmerr_injectstart 0} \
+ -injectstop shmerr_injectstop \
+ -injecterrlist {{1 {disk I/O error}}} \
+ -injectuninstall shmerr_injectuninstall \
+]
+set FAULTSIM(shmerr-persistent) [list \
+ -injectinstall shmerr_injectinstall \
+ -injectstart {shmerr_injectstart 1} \
+ -injectstop shmerr_injectstop \
+ -injecterrlist {{1 {disk I/O error}}} \
+ -injectuninstall shmerr_injectuninstall \
+]
+
+# Transient and persistent CANTOPEN errors:
+#
+set FAULTSIM(cantopen-transient) [list \
+ -injectinstall cantopen_injectinstall \
+ -injectstart {cantopen_injectstart 0} \
+ -injectstop cantopen_injectstop \
+ -injecterrlist {{1 {unable to open database file}}} \
+ -injectuninstall cantopen_injectuninstall \
+]
+set FAULTSIM(cantopen-persistent) [list \
+ -injectinstall cantopen_injectinstall \
+ -injectstart {cantopen_injectstart 1} \
+ -injectstop cantopen_injectstop \
+ -injecterrlist {{1 {unable to open database file}}} \
+ -injectuninstall cantopen_injectuninstall \
+]
+
+
+
+#--------------------------------------------------------------------------
+# Usage do_faultsim_test NAME ?OPTIONS...?
+#
+# -faults List of fault types to simulate.
+#
+# -prep Script to execute before -body.
+#
+# -body Script to execute (with fault injection).
+#
+# -test Script to execute after -body.
+#
+# -install Script to execute after faultsim -injectinstall
+#
+# -uninstall Script to execute after faultsim -uninjectinstall
+#
+proc do_faultsim_test {name args} {
+ global FAULTSIM
+
+ set DEFAULT(-faults) [array names FAULTSIM]
+ set DEFAULT(-prep) ""
+ set DEFAULT(-body) ""
+ set DEFAULT(-test) ""
+ set DEFAULT(-install) ""
+ set DEFAULT(-uninstall) ""
+
+ fix_testname name
+
+ array set O [array get DEFAULT]
+ array set O $args
+ foreach o [array names O] {
+ if {[info exists DEFAULT($o)]==0} { error "unknown option: $o" }
+ }
+
+ set faultlist [list]
+ foreach f $O(-faults) {
+ set flist [array names FAULTSIM $f]
+ if {[llength $flist]==0} { error "unknown fault: $f" }
+ set faultlist [concat $faultlist $flist]
+ }
+
+ set testspec [list -prep $O(-prep) -body $O(-body) \
+ -test $O(-test) -install $O(-install) -uninstall $O(-uninstall)
+ ]
+ foreach f [lsort -unique $faultlist] {
+ eval do_one_faultsim_test "$name-$f" $FAULTSIM($f) $testspec
+ }
+}
+
+
+#-------------------------------------------------------------------------
+# Procedures to save and restore the current file-system state:
+#
+# faultsim_save
+# faultsim_restore
+# faultsim_save_and_close
+# faultsim_restore_and_reopen
+# faultsim_delete_and_reopen
+#
+proc faultsim_save {args} { uplevel db_save $args }
+proc faultsim_save_and_close {args} { uplevel db_save_and_close $args }
+proc faultsim_restore {args} { uplevel db_restore $args }
+proc faultsim_restore_and_reopen {args} {
+ uplevel db_restore_and_reopen $args
+ sqlite3_extended_result_codes db 1
+ sqlite3_db_config_lookaside db 0 0 0
+}
+proc faultsim_delete_and_reopen {args} {
+ uplevel db_delete_and_reopen $args
+ sqlite3_extended_result_codes db 1
+ sqlite3_db_config_lookaside db 0 0 0
+}
+
+proc faultsim_integrity_check {{db db}} {
+ set ic [$db eval { PRAGMA integrity_check }]
+ if {$ic != "ok"} { error "Integrity check: $ic" }
+}
+
+
+# The following procs are used as [do_one_faultsim_test] callbacks when
+# injecting OOM faults into test cases.
+#
+proc oom_injectstart {nRepeat iFail} {
+ sqlite3_memdebug_fail [expr $iFail-1] -repeat $nRepeat
+}
+proc oom_injectstop {} {
+ sqlite3_memdebug_fail -1
+}
+
+# The following procs are used as [do_one_faultsim_test] callbacks when
+# injecting IO error faults into test cases.
+#
+proc ioerr_injectstart {persist iFail} {
+ set ::sqlite_io_error_persist $persist
+ set ::sqlite_io_error_pending $iFail
+}
+proc ioerr_injectstop {} {
+ set sv $::sqlite_io_error_hit
+ set ::sqlite_io_error_persist 0
+ set ::sqlite_io_error_pending 0
+ set ::sqlite_io_error_hardhit 0
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_pending 0
+ return $sv
+}
+
+# The following procs are used as [do_one_faultsim_test] callbacks when
+# injecting shared-memory related error faults into test cases.
+#
+proc shmerr_injectinstall {} {
+ testvfs shmfault -default true
+ shmfault filter {xShmOpen xShmMap xShmLock}
+}
+proc shmerr_injectuninstall {} {
+ catch {db close}
+ catch {db2 close}
+ shmfault delete
+}
+proc shmerr_injectstart {persist iFail} {
+ shmfault ioerr $iFail $persist
+}
+proc shmerr_injectstop {} {
+ shmfault ioerr
+}
+
+# The following procs are used as [do_one_faultsim_test] callbacks when
+# injecting SQLITE_FULL error faults into test cases.
+#
+proc fullerr_injectinstall {} {
+ testvfs shmfault -default true
+}
+proc fullerr_injectuninstall {} {
+ catch {db close}
+ catch {db2 close}
+ shmfault delete
+}
+proc fullerr_injectstart {iFail} {
+ shmfault full $iFail 1
+}
+proc fullerr_injectstop {} {
+ shmfault full
+}
+
+# The following procs are used as [do_one_faultsim_test] callbacks when
+# injecting SQLITE_CANTOPEN error faults into test cases.
+#
+proc cantopen_injectinstall {} {
+ testvfs shmfault -default true
+}
+proc cantopen_injectuninstall {} {
+ catch {db close}
+ catch {db2 close}
+ shmfault delete
+}
+proc cantopen_injectstart {persist iFail} {
+ shmfault cantopen $iFail $persist
+}
+proc cantopen_injectstop {} {
+ shmfault cantopen
+}
+
+# This command is not called directly. It is used by the
+# [faultsim_test_result] command created by [do_faultsim_test] and used
+# by -test scripts.
+#
+proc faultsim_test_result_int {args} {
+ upvar testrc testrc testresult testresult testnfail testnfail
+ set t [list $testrc $testresult]
+ set r $args
+ if { ($testnfail==0 && $t != [lindex $r 0]) || [lsearch $r $t]<0 } {
+ error "nfail=$testnfail rc=$testrc result=$testresult"
+ }
+}
+
+#--------------------------------------------------------------------------
+# Usage do_one_faultsim_test NAME ?OPTIONS...?
+#
+# The first argument, <test number>, is used as a prefix of the test names
+# taken by tests executed by this command. Options are as follows. All
+# options take a single argument.
+#
+# -injectstart Script to enable fault-injection.
+#
+# -injectstop Script to disable fault-injection.
+#
+# -injecterrlist List of generally acceptable test results (i.e. error
+# messages). Example: [list {1 {out of memory}}]
+#
+# -injectinstall
+#
+# -injectuninstall
+#
+# -prep Script to execute before -body.
+#
+# -body Script to execute (with fault injection).
+#
+# -test Script to execute after -body.
+#
+proc do_one_faultsim_test {testname args} {
+
+ set DEFAULT(-injectstart) "expr"
+ set DEFAULT(-injectstop) "expr 0"
+ set DEFAULT(-injecterrlist) [list]
+ set DEFAULT(-injectinstall) ""
+ set DEFAULT(-injectuninstall) ""
+ set DEFAULT(-prep) ""
+ set DEFAULT(-body) ""
+ set DEFAULT(-test) ""
+ set DEFAULT(-install) ""
+ set DEFAULT(-uninstall) ""
+
+ array set O [array get DEFAULT]
+ array set O $args
+ foreach o [array names O] {
+ if {[info exists DEFAULT($o)]==0} { error "unknown option: $o" }
+ }
+
+ proc faultsim_test_proc {testrc testresult testnfail} $O(-test)
+ proc faultsim_test_result {args} "
+ uplevel faultsim_test_result_int \$args [list $O(-injecterrlist)]
+ "
+
+ eval $O(-injectinstall)
+ eval $O(-install)
+
+ set stop 0
+ for {set iFail 1} {!$stop} {incr iFail} {
+
+ # Evaluate the -prep script.
+ #
+ eval $O(-prep)
+
+ # Start the fault-injection. Run the -body script. Stop the fault
+ # injection. Local var $nfail is set to the total number of faults
+ # injected into the system this trial.
+ #
+ eval $O(-injectstart) $iFail
+ set rc [catch $O(-body) res]
+ set nfail [eval $O(-injectstop)]
+
+ # Run the -test script. If it throws no error, consider this trial
+ # sucessful. If it does throw an error, cause a [do_test] test to
+ # fail (and print out the unexpected exception thrown by the -test
+ # script at the same time).
+ #
+ set rc [catch [list faultsim_test_proc $rc $res $nfail] res]
+ if {$rc == 0} {set res ok}
+ do_test $testname.$iFail [list list $rc $res] {0 ok}
+
+ # If no faults where injected this trial, don't bother running
+ # any more. This test is finished.
+ #
+ if {$nfail==0} { set stop 1 }
+ }
+
+ eval $O(-uninstall)
+ eval $O(-injectuninstall)
+}
+
+# Usage: do_malloc_test <test number> <options...>
+#
+# The first argument, <test number>, is an integer used to name the
+# tests executed by this proc. Options are as follows:
+#
+# -tclprep TCL script to run to prepare test.
+# -sqlprep SQL script to run to prepare test.
+# -tclbody TCL script to run with malloc failure simulation.
+# -sqlbody TCL script to run with malloc failure simulation.
+# -cleanup TCL script to run after the test.
+#
+# This command runs a series of tests to verify SQLite's ability
+# to handle an out-of-memory condition gracefully. It is assumed
+# that if this condition occurs a malloc() call will return a
+# NULL pointer. Linux, for example, doesn't do that by default. See
+# the "BUGS" section of malloc(3).
+#
+# Each iteration of a loop, the TCL commands in any argument passed
+# to the -tclbody switch, followed by the SQL commands in any argument
+# passed to the -sqlbody switch are executed. Each iteration the
+# Nth call to sqliteMalloc() is made to fail, where N is increased
+# each time the loop runs starting from 1. When all commands execute
+# successfully, the loop ends.
+#
+proc do_malloc_test {tn args} {
+ array unset ::mallocopts
+ array set ::mallocopts $args
+
+ if {[string is integer $tn]} {
+ set tn malloc-$tn
+ }
+ if {[info exists ::mallocopts(-start)]} {
+ set start $::mallocopts(-start)
+ } else {
+ set start 0
+ }
+ if {[info exists ::mallocopts(-end)]} {
+ set end $::mallocopts(-end)
+ } else {
+ set end 50000
+ }
+ save_prng_state
+
+ foreach ::iRepeat {0 10000000} {
+ set ::go 1
+ for {set ::n $start} {$::go && $::n <= $end} {incr ::n} {
+
+ # If $::iRepeat is 0, then the malloc() failure is transient - it
+ # fails and then subsequent calls succeed. If $::iRepeat is 1,
+ # then the failure is persistent - once malloc() fails it keeps
+ # failing.
+ #
+ set zRepeat "transient"
+ if {$::iRepeat} {set zRepeat "persistent"}
+ restore_prng_state
+ foreach file [glob -nocomplain test.db-mj*] {forcedelete $file}
+
+ do_test ${tn}.${zRepeat}.${::n} {
+
+ # Remove all traces of database files test.db and test2.db
+ # from the file-system. Then open (empty database) "test.db"
+ # with the handle [db].
+ #
+ catch {db close}
+ catch {db2 close}
+ forcedelete test.db
+ forcedelete test.db-journal
+ forcedelete test.db-wal
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ forcedelete test2.db-wal
+ if {[info exists ::mallocopts(-testdb)]} {
+ copy_file $::mallocopts(-testdb) test.db
+ }
+ catch { sqlite3 db test.db }
+ if {[info commands db] ne ""} {
+ sqlite3_extended_result_codes db 1
+ }
+ sqlite3_db_config_lookaside db 0 0 0
+
+ # Execute any -tclprep and -sqlprep scripts.
+ #
+ if {[info exists ::mallocopts(-tclprep)]} {
+ eval $::mallocopts(-tclprep)
+ }
+ if {[info exists ::mallocopts(-sqlprep)]} {
+ execsql $::mallocopts(-sqlprep)
+ }
+
+ # Now set the ${::n}th malloc() to fail and execute the -tclbody
+ # and -sqlbody scripts.
+ #
+ sqlite3_memdebug_fail $::n -repeat $::iRepeat
+ set ::mallocbody {}
+ if {[info exists ::mallocopts(-tclbody)]} {
+ append ::mallocbody "$::mallocopts(-tclbody)\n"
+ }
+ if {[info exists ::mallocopts(-sqlbody)]} {
+ append ::mallocbody "db eval {$::mallocopts(-sqlbody)}"
+ }
+
+ # The following block sets local variables as follows:
+ #
+ # isFail - True if an error (any error) was reported by sqlite.
+ # nFail - The total number of simulated malloc() failures.
+ # nBenign - The number of benign simulated malloc() failures.
+ #
+ set isFail [catch $::mallocbody msg]
+ set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]
+ # puts -nonewline " (isFail=$isFail nFail=$nFail nBenign=$nBenign) "
+
+ # If one or more mallocs failed, run this loop body again.
+ #
+ set go [expr {$nFail>0}]
+
+ if {($nFail-$nBenign)==0} {
+ if {$isFail} {
+ set v2 $msg
+ } else {
+ set isFail 1
+ set v2 1
+ }
+ } elseif {!$isFail} {
+ set v2 $msg
+ } elseif {
+ [info command db]=="" ||
+ [db errorcode]==7 ||
+ $msg=="out of memory"
+ } {
+ set v2 1
+ } else {
+ set v2 $msg
+ puts [db errorcode]
+ }
+ lappend isFail $v2
+ } {1 1}
+
+ if {[info exists ::mallocopts(-cleanup)]} {
+ catch [list uplevel #0 $::mallocopts(-cleanup)] msg
+ }
+ }
+ }
+ unset ::mallocopts
+ sqlite3_memdebug_fail -1
+}
+
+
+#-------------------------------------------------------------------------
+# This proc is used to test a single SELECT statement. Parameter $name is
+# passed a name for the test case (i.e. "fts3_malloc-1.4.1") and parameter
+# $sql is passed the text of the SELECT statement. Parameter $result is
+# set to the expected output if the SELECT statement is successfully
+# executed using [db eval].
+#
+# Example:
+#
+# do_select_test testcase-1.1 "SELECT 1+1, 1+2" {1 2}
+#
+# If global variable DO_MALLOC_TEST is set to a non-zero value, or if
+# it is not defined at all, then OOM testing is performed on the SELECT
+# statement. Each OOM test case is said to pass if either (a) executing
+# the SELECT statement succeeds and the results match those specified
+# by parameter $result, or (b) TCL throws an "out of memory" error.
+#
+# If DO_MALLOC_TEST is defined and set to zero, then the SELECT statement
+# is executed just once. In this case the test case passes if the results
+# match the expected results passed via parameter $result.
+#
+proc do_select_test {name sql result} {
+ uplevel [list doPassiveTest 0 $name $sql [list 0 [list {*}$result]]]
+}
+
+proc do_restart_select_test {name sql result} {
+ uplevel [list doPassiveTest 1 $name $sql [list 0 $result]]
+}
+
+proc do_error_test {name sql error} {
+ uplevel [list doPassiveTest 0 $name $sql [list 1 $error]]
+}
+
+proc doPassiveTest {isRestart name sql catchres} {
+ if {![info exists ::DO_MALLOC_TEST]} { set ::DO_MALLOC_TEST 1 }
+
+ if {[info exists ::testprefix]
+ && [string is integer [string range $name 0 0]]
+ } {
+ set name $::testprefix.$name
+ }
+
+ switch $::DO_MALLOC_TEST {
+ 0 { # No malloc failures.
+ do_test $name [list set {} [uplevel [list catchsql $sql]]] $catchres
+ return
+ }
+ 1 { # Simulate transient failures.
+ set nRepeat 1
+ set zName "transient"
+ set nStartLimit 100000
+ set nBackup 1
+ }
+ 2 { # Simulate persistent failures.
+ set nRepeat 1
+ set zName "persistent"
+ set nStartLimit 100000
+ set nBackup 1
+ }
+ 3 { # Simulate transient failures with extra brute force.
+ set nRepeat 100000
+ set zName "ridiculous"
+ set nStartLimit 1
+ set nBackup 10
+ }
+ }
+
+ # The set of acceptable results from running [catchsql $sql].
+ #
+ set answers [list {1 {out of memory}} $catchres]
+ set str [join $answers " OR "]
+
+ set nFail 1
+ for {set iLimit $nStartLimit} {$nFail} {incr iLimit} {
+ for {set iFail 1} {$nFail && $iFail<=$iLimit} {incr iFail} {
+ for {set iTest 0} {$iTest<$nBackup && ($iFail-$iTest)>0} {incr iTest} {
+
+ if {$isRestart} { sqlite3 db test.db }
+
+ sqlite3_memdebug_fail [expr $iFail-$iTest] -repeat $nRepeat
+ set res [uplevel [list catchsql $sql]]
+ if {[lsearch -exact $answers $res]>=0} { set res $str }
+ set testname "$name.$zName.$iFail"
+ do_test "$name.$zName.$iLimit.$iFail" [list set {} $res] $str
+
+ set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]
+ }
+ }
+ }
+}
+
+
+#-------------------------------------------------------------------------
+# Test a single write to the database. In this case a "write" is a
+# DELETE, UPDATE or INSERT statement.
+#
+# If OOM testing is performed, there are several acceptable outcomes:
+#
+# 1) The write succeeds. No error is returned.
+#
+# 2) An "out of memory" exception is thrown and:
+#
+# a) The statement has no effect, OR
+# b) The current transaction is rolled back, OR
+# c) The statement succeeds. This can only happen if the connection
+# is in auto-commit mode (after the statement is executed, so this
+# includes COMMIT statements).
+#
+# If the write operation eventually succeeds, zero is returned. If a
+# transaction is rolled back, non-zero is returned.
+#
+# Parameter $name is the name to use for the test case (or test cases).
+# The second parameter, $tbl, should be the name of the database table
+# being modified. Parameter $sql contains the SQL statement to test.
+#
+proc do_write_test {name tbl sql} {
+ if {![info exists ::DO_MALLOC_TEST]} { set ::DO_MALLOC_TEST 1 }
+
+ # Figure out an statement to get a checksum for table $tbl.
+ db eval "SELECT * FROM $tbl" V break
+ set cksumsql "SELECT md5sum([join [concat rowid $V(*)] ,]) FROM $tbl"
+
+ # Calculate the initial table checksum.
+ set cksum1 [db one $cksumsql]
+
+ if {$::DO_MALLOC_TEST } {
+ set answers [list {1 {out of memory}} {0 {}}]
+ if {$::DO_MALLOC_TEST==1} {
+ set modes {100000 persistent}
+ } else {
+ set modes {1 transient}
+ }
+ } else {
+ set answers [list {0 {}}]
+ set modes [list 0 nofail]
+ }
+ set str [join $answers " OR "]
+
+ foreach {nRepeat zName} $modes {
+ for {set iFail 1} 1 {incr iFail} {
+ if {$::DO_MALLOC_TEST} {sqlite3_memdebug_fail $iFail -repeat $nRepeat}
+
+ set res [uplevel [list catchsql $sql]]
+ set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]
+ if {$nFail==0} {
+ do_test $name.$zName.$iFail [list set {} $res] {0 {}}
+ return
+ } else {
+ if {[lsearch $answers $res]>=0} {
+ set res $str
+ }
+ do_test $name.$zName.$iFail [list set {} $res] $str
+ set cksum2 [db one $cksumsql]
+ if {$cksum1 != $cksum2} return
+ }
+ }
+ }
+}
diff --git a/test/manydb.test b/test/manydb.test
new file mode 100644
index 0000000..974a5b8
--- /dev/null
+++ b/test/manydb.test
@@ -0,0 +1,102 @@
+# 2005 October 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests the ability of the library to open
+# many different databases at the same time without leaking memory.
+#
+# $Id: manydb.test,v 1.4 2008/11/21 00:10:35 aswift Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set N 300
+# if we're using proxy locks, we use 5 filedescriptors for a db
+# that is open and in the middle of writing changes, normally
+# sqlite uses 3 (proxy locking adds the conch and the local lock)
+set using_proxy 0
+foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
+ set using_proxy value
+}
+set num_fd_per_openwrite_db 3
+if {$using_proxy>0} {
+ set num_fd_per_openwrite_db 5
+}
+
+# First test how many file descriptors are available for use. To open a
+# database for writing SQLite requires 3 file descriptors (the database, the
+# journal and the directory).
+set filehandles {}
+catch {
+ for {set i 0} {$i<($N * 3)} {incr i} {
+ lappend filehandles [open testfile.1 w]
+ }
+}
+foreach fd $filehandles {
+ close $fd
+}
+catch {
+ forcedelete testfile.1
+}
+set N [expr $i / $num_fd_per_openwrite_db]
+
+# Create a bunch of random database names
+#
+unset -nocomplain dbname
+unset -nocomplain used
+for {set i 0} {$i<$N} {incr i} {
+ while 1 {
+ set name test-[format %08x [expr {int(rand()*0x7fffffff)}]].db
+ if {[info exists used($name)]} continue
+ set dbname($i) $name
+ set used($name) $i
+ break
+ }
+}
+
+# Create a bunch of databases
+#
+for {set i 0} {$i<$N} {incr i} {
+ do_test manydb-1.$i {
+ sqlite3 db$i $dbname($i)
+ execsql {
+ CREATE TABLE t1(a,b);
+ BEGIN;
+ INSERT INTO t1 VALUES(1,2);
+ } db$i
+ } {}
+}
+
+# Finish the transactions
+#
+for {set i 0} {$i<$N} {incr i} {
+ do_test manydb-2.$i {
+ execsql {
+ COMMIT;
+ SELECT * FROM t1;
+ } db$i
+ } {1 2}
+}
+
+
+# Close the databases and erase the files.
+#
+for {set i 0} {$i<$N} {incr i} {
+ do_test manydb-3.$i {
+ db$i close
+ forcedelete $dbname($i)
+ } {}
+}
+
+
+
+
+finish_test
diff --git a/test/mem5.test b/test/mem5.test
new file mode 100644
index 0000000..6365f1c
--- /dev/null
+++ b/test/mem5.test
@@ -0,0 +1,66 @@
+# 2011 March 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests of the mem5 allocation subsystem.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !mem5 {
+ finish_test
+ return
+}
+
+# The tests in this file configure the lookaside allocator after a
+# connection is opened. This will not work if there is any "presql"
+# configured (SQL run within the [sqlite3] wrapper in tester.tcl).
+if {[info exists ::G(perm:presql)]} {
+ finish_test
+ return
+}
+
+do_test mem5-1.1 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 25000000 0
+ sqlite3_config_lookaside 0 0
+ sqlite3_initialize
+} {SQLITE_OK}
+
+# try with min request size = 2^30
+do_test mem5-1.2 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 1 1073741824
+ sqlite3_config_lookaside 0 0
+ sqlite3_initialize
+} {SQLITE_NOMEM}
+
+# try with min request size = 2^30+1
+# previously this was causing the memsys5Log() func to infinitely loop.
+do_test mem5-1.3 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 1 1073741825
+ sqlite3_config_lookaside 0 0
+ sqlite3_initialize
+} {SQLITE_NOMEM}
+
+do_test mem5-1.4 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 0 0
+ sqlite3_config_lookaside 0 0
+ sqlite3_initialize
+} {SQLITE_OK}
+
+finish_test
diff --git a/test/memdb.test b/test/memdb.test
new file mode 100644
index 0000000..1da3d7c
--- /dev/null
+++ b/test/memdb.test
@@ -0,0 +1,432 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is in-memory database backend.
+#
+# $Id: memdb.test,v 1.19 2009/05/18 16:04:38 danielk1977 Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable memorydb {
+
+# In the following sequence of tests, compute the MD5 sum of the content
+# of a table, make lots of modifications to that table, then do a rollback.
+# Verify that after the rollback, the MD5 checksum is unchanged.
+#
+# These tests were browed from trans.tcl.
+#
+do_test memdb-1.1 {
+ db close
+ sqlite3 db :memory:
+ # sqlite3 db test.db
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(x TEXT);
+ INSERT INTO t3 VALUES(randstr(10,400));
+ INSERT INTO t3 VALUES(randstr(10,400));
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ COMMIT;
+ SELECT count(*) FROM t3;
+ }
+} {1024}
+
+# The following procedure computes a "signature" for table "t3". If
+# T3 changes in any way, the signature should change.
+#
+# This is used to test ROLLBACK. We gather a signature for t3, then
+# make lots of changes to t3, then rollback and take another signature.
+# The two signatures should be the same.
+#
+proc signature {{fn {}}} {
+ set rx [db eval {SELECT x FROM t3}]
+ # set r1 [md5 $rx\n]
+ if {$fn!=""} {
+ # set fd [open $fn w]
+ # puts $fd $rx
+ # close $fd
+ }
+ # set r [db eval {SELECT count(*), md5sum(x) FROM t3}]
+ # puts "SIG($fn)=$r1"
+ return [list [string length $rx] $rx]
+}
+
+# Do rollbacks. Make sure the signature does not change.
+#
+set limit 10
+for {set i 2} {$i<=$limit} {incr i} {
+ set ::sig [signature one]
+ # puts "sig=$sig"
+ set cnt [lindex $::sig 0]
+ if {$i%2==0} {
+ execsql {PRAGMA synchronous=FULL}
+ } else {
+ execsql {PRAGMA synchronous=NORMAL}
+ }
+ do_test memdb-1.$i.1-$cnt {
+ execsql {
+ BEGIN;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ ROLLBACK;
+ }
+ set sig2 [signature two]
+ } $sig
+ # puts "sig2=$sig2"
+ # if {$sig2!=$sig} exit
+ do_test memdb-1.$i.2-$cnt {
+ execsql {
+ BEGIN;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ ROLLBACK;
+ }
+ signature
+ } $sig
+ if {$i<$limit} {
+ do_test memdb-1.$i.9-$cnt {
+ execsql {
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE random()%10==0;
+ }
+ } {}
+ }
+ set ::pager_old_format 0
+}
+
+integrity_check memdb-2.1
+
+do_test memdb-3.1 {
+ execsql {
+ CREATE TABLE t4(a,b,c,d);
+ BEGIN;
+ INSERT INTO t4 VALUES(1,2,3,4);
+ SELECT * FROM t4;
+ }
+} {1 2 3 4}
+do_test memdb-3.2 {
+ execsql {
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {t3 t4}
+do_test memdb-3.3 {
+ execsql {
+ DROP TABLE t4;
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {t3}
+do_test memdb-3.4 {
+ execsql {
+ ROLLBACK;
+ SELECT name FROM sqlite_master WHERE type='table';
+ }
+} {t3 t4}
+
+# Create tables for the first group of tests.
+#
+do_test memdb-4.0 {
+ execsql {
+ CREATE TABLE t1(a, b, c, UNIQUE(a,b));
+ CREATE TABLE t2(x);
+ SELECT c FROM t1 ORDER BY c;
+ }
+} {}
+
+# Six columns of configuration data as follows:
+#
+# i The reference number of the test
+# conf The conflict resolution algorithm on the BEGIN statement
+# cmd An INSERT or REPLACE command to execute against table t1
+# t0 True if there is an error from $cmd
+# t1 Content of "c" column of t1 assuming no error in $cmd
+# t2 Content of "x" column of t2
+#
+foreach {i conf cmd t0 t1 t2} {
+ 1 {} INSERT 1 {} 1
+ 2 {} {INSERT OR IGNORE} 0 3 1
+ 3 {} {INSERT OR REPLACE} 0 4 1
+ 4 {} REPLACE 0 4 1
+ 5 {} {INSERT OR FAIL} 1 {} 1
+ 6 {} {INSERT OR ABORT} 1 {} 1
+ 7 {} {INSERT OR ROLLBACK} 1 {} {}
+} {
+
+ # All tests after test 1 depend on conflict resolution. So end the
+ # loop if that is not available in this build.
+ ifcapable !conflict {if {$i>1} break}
+
+ do_test memdb-4.$i {
+ if {$conf!=""} {set conf "ON CONFLICT $conf"}
+ set r0 [catch {execsql [subst {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN $conf;
+ INSERT INTO t2 VALUES(1);
+ $cmd INTO t1 VALUES(1,2,4);
+ }]} r1]
+ catch {execsql {COMMIT}}
+ if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
+ set r2 [execsql {SELECT x FROM t2}]
+ list $r0 $r1 $r2
+ } [list $t0 $t1 $t2]
+}
+
+do_test memdb-5.0 {
+ execsql {
+ DROP TABLE t2;
+ DROP TABLE t3;
+ CREATE TABLE t2(a,b,c);
+ INSERT INTO t2 VALUES(1,2,1);
+ INSERT INTO t2 VALUES(2,3,2);
+ INSERT INTO t2 VALUES(3,4,1);
+ INSERT INTO t2 VALUES(4,5,4);
+ SELECT c FROM t2 ORDER BY b;
+ CREATE TABLE t3(x);
+ INSERT INTO t3 VALUES(1);
+ }
+} {1 2 1 4}
+
+# Six columns of configuration data as follows:
+#
+# i The reference number of the test
+# conf1 The conflict resolution algorithm on the UNIQUE constraint
+# conf2 The conflict resolution algorithm on the BEGIN statement
+# cmd An UPDATE command to execute against table t1
+# t0 True if there is an error from $cmd
+# t1 Content of "b" column of t1 assuming no error in $cmd
+# t2 Content of "x" column of t3
+#
+foreach {i conf1 conf2 cmd t0 t1 t2} {
+ 1 {} {} UPDATE 1 {6 7 8 9} 1
+ 2 REPLACE {} UPDATE 0 {7 6 9} 1
+ 3 IGNORE {} UPDATE 0 {6 7 3 9} 1
+ 4 FAIL {} UPDATE 1 {6 7 3 4} 1
+ 5 ABORT {} UPDATE 1 {1 2 3 4} 1
+ 6 ROLLBACK {} UPDATE 1 {1 2 3 4} 0
+ 7 REPLACE {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
+ 8 IGNORE {} {UPDATE OR REPLACE} 0 {7 6 9} 1
+ 9 FAIL {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
+ 10 ABORT {} {UPDATE OR REPLACE} 0 {7 6 9} 1
+ 11 ROLLBACK {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
+ 12 {} {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
+ 13 {} {} {UPDATE OR REPLACE} 0 {7 6 9} 1
+ 14 {} {} {UPDATE OR FAIL} 1 {6 7 3 4} 1
+ 15 {} {} {UPDATE OR ABORT} 1 {1 2 3 4} 1
+ 16 {} {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0
+} {
+ # All tests after test 1 depend on conflict resolution. So end the
+ # loop if that is not available in this build.
+ ifcapable !conflict {
+ if {$i>1} break
+ }
+
+ if {$t0} {set t1 {column a is not unique}}
+ do_test memdb-5.$i {
+ if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
+ if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
+ set r0 [catch {execsql "
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1);
+ INSERT INTO t1 SELECT * FROM t2;
+ UPDATE t3 SET x=0;
+ BEGIN $conf2;
+ $cmd t3 SET x=1;
+ $cmd t1 SET b=b*2;
+ $cmd t1 SET a=c+5;
+ "} r1]
+ catch {execsql {COMMIT}}
+ if {!$r0} {set r1 [execsql {SELECT a FROM t1 ORDER BY b}]}
+ set r2 [execsql {SELECT x FROM t3}]
+ list $r0 $r1 $r2
+ } [list $t0 $t1 $t2]
+}
+
+do_test memdb-6.1 {
+ execsql {
+ SELECT * FROM t2;
+ }
+} {1 2 1 2 3 2 3 4 1 4 5 4}
+do_test memdb-6.2 {
+ execsql {
+ BEGIN;
+ DROP TABLE t2;
+ SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
+ }
+} {t1 t3 t4}
+do_test memdb-6.3 {
+ execsql {
+ ROLLBACK;
+ SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
+ }
+} {t1 t2 t3 t4}
+do_test memdb-6.4 {
+ execsql {
+ SELECT * FROM t2;
+ }
+} {1 2 1 2 3 2 3 4 1 4 5 4}
+ifcapable compound {
+do_test memdb-6.5 {
+ execsql {
+ SELECT a FROM t2 UNION SELECT b FROM t2 ORDER BY 1;
+ }
+} {1 2 3 4 5}
+} ;# ifcapable compound
+do_test memdb-6.6 {
+ execsql {
+ CREATE INDEX i2 ON t2(c);
+ SELECT a FROM t2 ORDER BY c;
+ }
+} {1 3 2 4}
+do_test memdb-6.6 {
+ execsql {
+ SELECT a FROM t2 ORDER BY c DESC;
+ }
+} {4 2 3 1}
+do_test memdb-6.7 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t5(x,y);
+ INSERT INTO t5 VALUES(1,2);
+ SELECT * FROM t5;
+ }
+} {1 2}
+do_test memdb-6.8 {
+ execsql {
+ SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
+ }
+} {t1 t2 t3 t4 t5}
+do_test memdb-6.9 {
+ execsql {
+ ROLLBACK;
+ SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
+ }
+} {t1 t2 t3 t4}
+do_test memdb-6.10 {
+ execsql {
+ CREATE TABLE t5(x PRIMARY KEY, y UNIQUE);
+ SELECT * FROM t5;
+ }
+} {}
+do_test memdb-6.11 {
+ execsql {
+ SELECT * FROM t5 ORDER BY y DESC;
+ }
+} {}
+
+ifcapable conflict {
+ do_test memdb-6.12 {
+ execsql {
+ INSERT INTO t5 VALUES(1,2);
+ INSERT INTO t5 VALUES(3,4);
+ REPLACE INTO t5 VALUES(1,4);
+ SELECT rowid,* FROM t5;
+ }
+ } {3 1 4}
+ do_test memdb-6.13 {
+ execsql {
+ DELETE FROM t5 WHERE x>5;
+ SELECT * FROM t5;
+ }
+ } {1 4}
+ do_test memdb-6.14 {
+ execsql {
+ DELETE FROM t5 WHERE y<3;
+ SELECT * FROM t5;
+ }
+ } {1 4}
+}
+
+do_test memdb-6.15 {
+ execsql {
+ DELETE FROM t5 WHERE x>0;
+ SELECT * FROM t5;
+ }
+} {}
+
+ifcapable subquery&&vtab {
+ do_test memdb-7.1 {
+ register_wholenumber_module db
+ execsql {
+ CREATE TABLE t6(x);
+ CREATE VIRTUAL TABLE nums USING wholenumber;
+ INSERT INTO t6 SELECT value FROM nums WHERE value BETWEEN 1 AND 256;
+ SELECT count(*) FROM (SELECT DISTINCT x FROM t6);
+ }
+ } {256}
+ for {set i 1} {$i<=256} {incr i} {
+ do_test memdb-7.2.$i {
+ execsql "DELETE FROM t6 WHERE x=\
+ (SELECT x FROM t6 ORDER BY random() LIMIT 1)"
+ execsql {SELECT count(*) FROM t6}
+ } [expr {256-$i}]
+ }
+}
+
+# Ticket #1524
+#
+do_test memdb-8.1 {
+ db close
+ sqlite3 db {:memory:}
+ execsql {
+ PRAGMA auto_vacuum=TRUE;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(randstr(5000,6000));
+ INSERT INTO t1 VALUES(randstr(5000,6000));
+ INSERT INTO t1 VALUES(randstr(5000,6000));
+ INSERT INTO t1 VALUES(randstr(5000,6000));
+ INSERT INTO t1 VALUES(randstr(5000,6000));
+ SELECT count(*) FROM t1;
+ }
+} 5
+do_test memdb-8.2 {
+ execsql {
+ DELETE FROM t1;
+ SELECT count(*) FROM t1;
+ }
+} 0
+
+# Test that auto-vacuum works with in-memory databases.
+#
+ifcapable autovacuum {
+ do_test memdb-9.1 {
+ db close
+ sqlite3 db test.db
+ db cache size 0
+ execsql {
+ PRAGMA auto_vacuum = full;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(randstr(1000,1000));
+ INSERT INTO t1 VALUES(randstr(1000,1000));
+ INSERT INTO t1 VALUES(randstr(1000,1000));
+ }
+ set memused [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
+ set pgovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 1]
+ execsql { DELETE FROM t1 }
+ set memused2 [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]
+ expr {($memused2 + 2048 < $memused) || $pgovfl==0}
+ } {1}
+}
+
+} ;# ifcapable memorydb
+
+finish_test
diff --git a/test/memleak.test b/test/memleak.test
new file mode 100644
index 0000000..a24a901
--- /dev/null
+++ b/test/memleak.test
@@ -0,0 +1,97 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file runs all tests.
+#
+# $Id: memleak.test,v 1.10 2007/03/30 17:17:52 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+rename finish_test memleak_finish_test
+proc finish_test {} {
+ catch {db close}
+ memleak_check
+}
+
+if {[file exists ./sqlite_test_count]} {
+ set COUNT [exec cat ./sqlite_test_count]
+} else {
+ set COUNT 3
+}
+
+# LeakList will hold a list of the number of unfreed mallocs after
+# each round of the test. This number should be constant. If it
+# grows, it may mean there is a memory leak in the library.
+#
+set LeakList {}
+
+set EXCLUDE {
+ all.test
+ quick.test
+ misuse.test
+ memleak.test
+ btree2.test
+ async.test
+ async2.test
+ trans.test
+ crash.test
+ autovacuum_crash.test
+}
+# Test files btree2.test and btree4.test don't work if the
+# SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend
+# on tables being allocated starting at page 2).
+#
+ifcapable default_autovacuum {
+ lappend EXCLUDE btree2.test
+ lappend EXCLUDE btree4.test
+}
+
+if {[sqlite3 -has-codec]} {
+ # lappend EXCLUDE
+}
+if {[llength $argv]>0} {
+ set FILELIST $argv
+ set argv {}
+} else {
+ set FILELIST [lsort -dictionary [glob $testdir/*.test]]
+}
+
+foreach testfile $FILELIST {
+ set tail [file tail $testfile]
+ if {[lsearch -exact $EXCLUDE $tail]>=0} continue
+ set LeakList {}
+ for {set COUNTER 0} {$COUNTER<$COUNT} {incr COUNTER} {
+ source $testfile
+ if {[info exists Leak]} {
+ lappend LeakList $Leak
+ }
+ }
+ if {$LeakList!=""} {
+ puts -nonewline memory-leak-test-$tail...
+ incr_ntest
+ foreach x $LeakList {
+ if {$x!=[lindex $LeakList 0]} {
+ puts " failed! ($LeakList)"
+ fail_test memory-leak-test-$tail
+ break
+ }
+ }
+ puts " Ok"
+ }
+}
+memleak_finish_test
+
+# Run the malloc tests and the misuse test after memory leak detection.
+# Both tests leak memory.
+#
+#catch {source $testdir/misuse.test}
+#catch {source $testdir/malloc.test}
+
+memleak_finish_test
diff --git a/test/memsubsys1.test b/test/memsubsys1.test
new file mode 100644
index 0000000..7eecf08
--- /dev/null
+++ b/test/memsubsys1.test
@@ -0,0 +1,309 @@
+# 2008 June 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests of the memory allocation subsystem
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+sqlite3_reset_auto_extension
+
+# This test assumes that no page-cache or scratch buffers are installed
+# by default when a new database connection is opened. As a result, it
+# will not work with the "memsubsys1" permutation.
+#
+if {[permutation] == "memsubsys1"} {
+ finish_test
+ return
+}
+
+# This procedure constructs a new database in test.db. It fills
+# this database with many small records (enough to force multiple
+# rebalance operations in the btree-layer and to require a large
+# page cache), verifies correct results, then returns.
+#
+proc build_test_db {testname pragmas} {
+ catch {db close}
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ sqlite3_db_config_lookaside db 0 0 0
+ db eval $pragmas
+ db eval {
+ CREATE TABLE t1(x, y);
+ CREATE TABLE t2(a, b);
+ CREATE INDEX i1 ON t1(x,y);
+ INSERT INTO t1 VALUES(1, 100);
+ INSERT INTO t1 VALUES(2, 200);
+ }
+ for {set i 2} {$i<5000} {incr i $i} {
+ db eval {INSERT INTO t2 SELECT * FROM t1}
+ db eval {INSERT INTO t1 SELECT a+$i, a+b*100 FROM t2}
+ db eval {DELETE FROM t2}
+ }
+ do_test $testname.1 {
+ db eval {SELECT count(*) FROM t1}
+ } 8192
+ integrity_check $testname.2
+}
+
+# Reset all of the highwater marks.
+#
+proc reset_highwater_marks {} {
+ sqlite3_status SQLITE_STATUS_MEMORY_USED 1
+ sqlite3_status SQLITE_STATUS_MALLOC_SIZE 1
+ sqlite3_status SQLITE_STATUS_PAGECACHE_USED 1
+ sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 1
+ sqlite3_status SQLITE_STATUS_PAGECACHE_SIZE 1
+ sqlite3_status SQLITE_STATUS_SCRATCH_USED 1
+ sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 1
+ sqlite3_status SQLITE_STATUS_SCRATCH_SIZE 1
+ sqlite3_status SQLITE_STATUS_PARSER_STACK 1
+}
+
+set xtra_size 256
+
+# Test 1: Both PAGECACHE and SCRATCH are shut down.
+#
+db close
+sqlite3_shutdown
+sqlite3_config_lookaside 0 0
+sqlite3_initialize
+reset_highwater_marks
+build_test_db memsubsys1-1 {PRAGMA page_size=1024}
+do_test memsubsys1-1.3 {
+ set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
+} 0
+do_test memsubsys1-1.4 {
+ set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
+} 0
+set max_pagecache [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
+#show_memstats
+
+# Test 2: Activate PAGECACHE with 20 pages
+#
+db close
+sqlite3_shutdown
+sqlite3_config_pagecache [expr 1024+$xtra_size] 20
+sqlite3_initialize
+reset_highwater_marks
+build_test_db memsubsys1-2 {PRAGMA page_size=1024}
+#show_memstats
+set MEMORY_MANAGEMENT $sqlite_options(memorymanage)
+do_test memsubsys1-2.3 {
+ set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
+} [expr ($TEMP_STORE>1 || $MEMORY_MANAGEMENT==0)*1024]
+do_test memsubsys1-2.4 {
+ set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
+} 20
+do_test memsubsys1-2.5 {
+ set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
+} 0
+
+# Test 3: Activate PAGECACHE with 20 pages but use the wrong page size
+# so that PAGECACHE is not used.
+#
+db close
+sqlite3_shutdown
+sqlite3_config_pagecache [expr 512+$xtra_size] 20
+sqlite3_initialize
+reset_highwater_marks
+build_test_db memsubsys1-3.1 {PRAGMA page_size=1024}
+#show_memstats
+do_test memsubsys1-3.1.3 {
+ set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
+} 0
+do_test memsubsys1-3.1.4 {
+ set overflow [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
+} $max_pagecache
+do_test memsubsys1-3.1.5 {
+ set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
+} 0
+db close
+sqlite3_shutdown
+sqlite3_config_pagecache [expr 2048+$xtra_size] 20
+sqlite3_initialize
+reset_highwater_marks
+build_test_db memsubsys1-3.2 {PRAGMA page_size=2048}
+#show_memstats
+do_test memsubsys1-3.2.3 {
+ db eval {PRAGMA page_size}
+} 2048
+do_test memsubsys1-3.2.4 {
+ set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
+} 20
+do_test memsubsys1-3.2.5 {
+ set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
+} 0
+
+# Test 4: Activate both PAGECACHE and SCRATCH.
+#
+db close
+sqlite3_shutdown
+sqlite3_config_pagecache [expr 1024+$xtra_size] 50
+sqlite3_config_scratch 6000 2
+sqlite3_initialize
+reset_highwater_marks
+build_test_db memsubsys1-4 {PRAGMA page_size=1024}
+#show_memstats
+do_test memsubsys1-4.3 {
+ set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
+ expr {$pg_used>=45 && $pg_used<=50}
+} 1
+do_test memsubsys1-4.4 {
+ set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
+} 0
+do_test memsubsys1-4.5 {
+ set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
+ expr {$maxreq<7000}
+} 1
+do_test memsubsys1-4.6 {
+ set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
+} 1
+
+# Test 5: Activate both PAGECACHE and SCRATCH. But make the page size
+# such that the SCRATCH allocations are too small.
+#
+db close
+sqlite3_shutdown
+sqlite3_config_pagecache [expr 4096+$xtra_size] 24
+sqlite3_config_scratch 6000 2
+sqlite3_initialize
+reset_highwater_marks
+build_test_db memsubsys1-5 {PRAGMA page_size=4096}
+#show_memstats
+do_test memsubsys1-5.3 {
+ set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
+} 24
+do_test memsubsys1-5.4 {
+ set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
+ expr {$maxreq>4096}
+} 1
+do_test memsubsys1-5.5 {
+ set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
+} 0
+do_test memsubsys1-5.6 {
+ set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
+ expr {$s_ovfl>6000}
+} 1
+
+# Test 6: Activate both PAGECACHE and SCRATCH with a 4k page size.
+# Make it so that SCRATCH is large enough
+#
+db close
+sqlite3_shutdown
+sqlite3_config_pagecache [expr 4096+$xtra_size] 24
+sqlite3_config_scratch 25300 1
+sqlite3_initialize
+reset_highwater_marks
+build_test_db memsubsys1-6 {PRAGMA page_size=4096}
+#show_memstats
+do_test memsubsys1-6.3 {
+ set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
+} 24
+#do_test memsubsys1-6.4 {
+# set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
+# expr {$maxreq>4096 && $maxreq<=(4096+$xtra_size)}
+#} 1
+do_test memsubsys1-6.5 {
+ set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
+} 1
+do_test memsubsys1-6.6 {
+ set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
+} 0
+
+# Test 7: Activate both PAGECACHE and SCRATCH with a 4k page size.
+# Set cache_size small so that no PAGECACHE overflow occurs. Verify
+# that maximum allocation size is small.
+#
+db close
+sqlite3_shutdown
+sqlite3_config_pagecache [expr 4096+$xtra_size] 24
+sqlite3_config_scratch 25300 1
+sqlite3_initialize
+reset_highwater_marks
+build_test_db memsubsys1-7 {
+ PRAGMA page_size=4096;
+ PRAGMA cache_size=10;
+ PRAGMA temp_store=memory;
+}
+#show_memstats
+do_test memsubsys1-7.3 {
+ set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
+ expr {$pg_used<24}
+} 1
+do_test memsubsys1-7.4 {
+ set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
+} 0
+do_test memsubsys1-7.5 {
+ set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
+ expr {$maxreq<4100}
+} 1
+do_test memsubsys1-7.6 {
+ set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
+} 1
+do_test memsubsys1-7.7 {
+ set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
+} 0
+
+# Test 8: Disable PAGECACHE. Make available SCRATCH zero. Verify that
+# the SCRATCH overflow logic works.
+#
+db close
+sqlite3_shutdown
+sqlite3_config_pagecache 0 0
+sqlite3_config_scratch 25000 0
+sqlite3_initialize
+reset_highwater_marks
+do_test memsubsys1-8.1 {
+ set pg_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
+} 0
+do_test memsubsys1-8.2 {
+ set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
+} 0
+do_test memsubsys1-8.3 {
+ sqlite3 db :memory:
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(zeroblob(400));
+ INSERT INTO t1 VALUES(zeroblob(400));
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ }
+ expr {[lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]>0}
+} 1
+db close
+sqlite3_shutdown
+sqlite3_config_memstatus 0
+sqlite3_initialize
+do_test memsubsys1-8.4 {
+ sqlite3 db :memory:
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(zeroblob(400));
+ INSERT INTO t1 VALUES(zeroblob(400));
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ SELECT rowid FROM t1;
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}
+
+
+db close
+sqlite3_shutdown
+sqlite3_config_memstatus 1
+sqlite3_config_pagecache 0 0
+sqlite3_config_scratch 0 0
+sqlite3_config_lookaside 100 500
+sqlite3_initialize
+autoinstall_test_functions
+finish_test
diff --git a/test/memsubsys2.test b/test/memsubsys2.test
new file mode 100644
index 0000000..a40f4e4
--- /dev/null
+++ b/test/memsubsys2.test
@@ -0,0 +1,173 @@
+# 2008 June 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests of the memory allocation subsystem.
+#
+# $Id: memsubsys2.test,v 1.2 2008/08/12 15:21:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+sqlite3_reset_auto_extension
+
+# This procedure constructs a new database in test.db. It fills
+# this database with many small records (enough to force multiple
+# rebalance operations in the btree-layer and to require a large
+# page cache), verifies correct results, then returns.
+#
+proc build_test_db {testname pragmas} {
+ catch {db close}
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ db eval $pragmas
+ db eval {
+ CREATE TABLE t1(x, y);
+ CREATE TABLE t2(a, b);
+ CREATE INDEX i1 ON t1(x,y);
+ INSERT INTO t1 VALUES(1, 100);
+ INSERT INTO t1 VALUES(2, 200);
+ }
+ for {set i 2} {$i<5000} {incr i $i} {
+ db eval {INSERT INTO t2 SELECT * FROM t1}
+ db eval {INSERT INTO t1 SELECT a+$i, a+b*100 FROM t2}
+ db eval {DELETE FROM t2}
+ }
+ do_test $testname.1 {
+ db eval {SELECT count(*) FROM t1}
+ } 8192
+ integrity_check $testname.2
+}
+
+# Reset all of the highwater marks.
+#
+proc reset_highwater_marks {} {
+ sqlite3_status SQLITE_STATUS_MEMORY_USED 1
+ sqlite3_status SQLITE_STATUS_MALLOC_SIZE 1
+ sqlite3_status SQLITE_STATUS_PAGECACHE_USED 1
+ sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 1
+ sqlite3_status SQLITE_STATUS_PAGECACHE_SIZE 1
+ sqlite3_status SQLITE_STATUS_SCRATCH_USED 1
+ sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 1
+ sqlite3_status SQLITE_STATUS_SCRATCH_SIZE 1
+ sqlite3_status SQLITE_STATUS_PARSER_STACK 1
+}
+
+# Test 1: Verify that calling sqlite3_malloc(0) returns a NULL
+# pointer.
+#
+set highwater [sqlite3_memory_highwater 0]
+do_test memsubsys2-1.1 {
+ sqlite3_malloc 0
+} {0}
+do_test memsubsys2-1.2 {
+ sqlite3_memory_highwater 0
+} $highwater
+
+
+# Test 2: Verify that the highwater mark increases after a large
+# allocation.
+#
+sqlite3_memory_highwater 1
+set highwater [sqlite3_memory_highwater 0]
+do_test memsubsys2-2.1 {
+ sqlite3_free [set x [sqlite3_malloc 100000]]
+ expr {$x!="0"}
+} {1}
+do_test memsubsys2-2.2 {
+ expr {[sqlite3_memory_highwater 0]>=[sqlite3_memory_used]+$highwater}
+} {1}
+
+# Test 3: Verify that turning of memstatus disables the statistics
+# tracking.
+#
+db close
+sqlite3_shutdown
+sqlite3_config_memstatus 0
+sqlite3_initialize
+reset_highwater_marks
+set highwater [sqlite3_memory_highwater 0]
+do_test memsubsys2-3.1 {
+ set highwater
+} {0}
+do_test memsubsys2-3.2 {
+ sqlite3_malloc 0
+} {0}
+do_test memsubsys2-3.3 {
+ sqlite3_memory_highwater 0
+} {0}
+do_test memsubsys2-3.4 {
+ sqlite3_memory_used
+} {0}
+do_test memsubsys2-3.5 {
+ set ::allocation [sqlite3_malloc 100000]
+ expr {$::allocation!="0"}
+} {1}
+do_test memsubsys2-3.6 {
+ sqlite3_memory_highwater 0
+} {0}
+do_test memsubsys2-3.7 {
+ sqlite3_memory_used
+} {0}
+do_test memsubsys2-3.8 {
+ sqlite3_free $::allocation
+} {}
+do_test memsubsys2-3.9 {
+ sqlite3_free 0
+} {}
+
+
+# Test 4: Verify that turning on memstatus reenables the statistics
+# tracking.
+#
+sqlite3_shutdown
+sqlite3_config_memstatus 1
+sqlite3_initialize
+reset_highwater_marks
+set highwater [sqlite3_memory_highwater 0]
+do_test memsubsys2-4.1 {
+ set highwater
+} {0}
+do_test memsubsys2-4.2 {
+ sqlite3_malloc 0
+} {0}
+do_test memsubsys2-4.3 {
+ sqlite3_memory_highwater 0
+} {0}
+do_test memsubsys2-4.4 {
+ sqlite3_memory_used
+} {0}
+do_test memsubsys2-4.5 {
+ set ::allocation [sqlite3_malloc 100000]
+ expr {$::allocation!="0"}
+} {1}
+do_test memsubsys2-4.6 {
+ expr {[sqlite3_memory_highwater 0]>=100000}
+} {1}
+do_test memsubsys2-4.7 {
+ expr {[sqlite3_memory_used]>=100000}
+} {1}
+do_test memsubsys2-4.8 {
+ sqlite3_free $::allocation
+} {}
+do_test memsubsys2-4.9 {
+ sqlite3_free 0
+} {}
+do_test memsubsys2-4.10 {
+ expr {[sqlite3_memory_highwater 0]>=100000}
+} {1}
+do_test memsubsys2-4.11 {
+ sqlite3_memory_used
+} {0}
+
+
+
+
+autoinstall_test_functions
+finish_test
diff --git a/test/minmax.test b/test/minmax.test
new file mode 100644
index 0000000..5990245
--- /dev/null
+++ b/test/minmax.test
@@ -0,0 +1,542 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing SELECT statements that contain
+# aggregate min() and max() functions and which are handled as
+# as a special case.
+#
+# $Id: minmax.test,v 1.21 2008/07/08 18:05:26 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test minmax-1.0 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1,1);
+ INSERT INTO t1 VALUES(2,2);
+ INSERT INTO t1 VALUES(3,2);
+ INSERT INTO t1 VALUES(4,3);
+ INSERT INTO t1 VALUES(5,3);
+ INSERT INTO t1 VALUES(6,3);
+ INSERT INTO t1 VALUES(7,3);
+ INSERT INTO t1 VALUES(8,4);
+ INSERT INTO t1 VALUES(9,4);
+ INSERT INTO t1 VALUES(10,4);
+ INSERT INTO t1 VALUES(11,4);
+ INSERT INTO t1 VALUES(12,4);
+ INSERT INTO t1 VALUES(13,4);
+ INSERT INTO t1 VALUES(14,4);
+ INSERT INTO t1 VALUES(15,4);
+ INSERT INTO t1 VALUES(16,5);
+ INSERT INTO t1 VALUES(17,5);
+ INSERT INTO t1 VALUES(18,5);
+ INSERT INTO t1 VALUES(19,5);
+ INSERT INTO t1 VALUES(20,5);
+ COMMIT;
+ SELECT DISTINCT y FROM t1 ORDER BY y;
+ }
+} {1 2 3 4 5}
+
+do_test minmax-1.1 {
+ set sqlite_search_count 0
+ execsql {SELECT min(x) FROM t1}
+} {1}
+do_test minmax-1.2 {
+ set sqlite_search_count
+} {19}
+do_test minmax-1.3 {
+ set sqlite_search_count 0
+ execsql {SELECT max(x) FROM t1}
+} {20}
+do_test minmax-1.4 {
+ set sqlite_search_count
+} {19}
+do_test minmax-1.5 {
+ execsql {CREATE INDEX t1i1 ON t1(x)}
+ set sqlite_search_count 0
+ execsql {SELECT min(x) FROM t1}
+} {1}
+do_test minmax-1.6 {
+ set sqlite_search_count
+} {1}
+do_test minmax-1.7 {
+ set sqlite_search_count 0
+ execsql {SELECT max(x) FROM t1}
+} {20}
+do_test minmax-1.8 {
+ set sqlite_search_count
+} {0}
+do_test minmax-1.9 {
+ set sqlite_search_count 0
+ execsql {SELECT max(y) FROM t1}
+} {5}
+do_test minmax-1.10 {
+ set sqlite_search_count
+} {19}
+
+do_test minmax-1.21 {
+ execsql {SELECT min(x) FROM t1 WHERE x=5}
+} {5}
+do_test minmax-1.22 {
+ execsql {SELECT min(x) FROM t1 WHERE x>=5}
+} {5}
+do_test minmax-1.23 {
+ execsql {SELECT min(x) FROM t1 WHERE x>=4.5}
+} {5}
+do_test minmax-1.24 {
+ execsql {SELECT min(x) FROM t1 WHERE x<4.5}
+} {1}
+
+do_test minmax-2.0 {
+ execsql {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t2 SELECT * FROM t1;
+ }
+ set sqlite_search_count 0
+ execsql {SELECT min(a) FROM t2}
+} {1}
+do_test minmax-2.1 {
+ set sqlite_search_count
+} {0}
+do_test minmax-2.2 {
+ set sqlite_search_count 0
+ execsql {SELECT max(a) FROM t2}
+} {20}
+do_test minmax-2.3 {
+ set sqlite_search_count
+} {0}
+
+do_test minmax-3.0 {
+ ifcapable subquery {
+ execsql {INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)}
+ } else {
+ db function max_a_t2 {execsql {SELECT max(a) FROM t2}}
+ execsql {INSERT INTO t2 VALUES(max_a_t2()+1,999)}
+ }
+ set sqlite_search_count 0
+ execsql {SELECT max(a) FROM t2}
+} {21}
+do_test minmax-3.1 {
+ set sqlite_search_count
+} {0}
+do_test minmax-3.2 {
+ ifcapable subquery {
+ execsql {INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)}
+ } else {
+ db function max_a_t2 {execsql {SELECT max(a) FROM t2}}
+ execsql {INSERT INTO t2 VALUES(max_a_t2()+1,999)}
+ }
+ set sqlite_search_count 0
+ ifcapable subquery {
+ execsql { SELECT b FROM t2 WHERE a=(SELECT max(a) FROM t2) }
+ } else {
+ execsql { SELECT b FROM t2 WHERE a=max_a_t2() }
+ }
+} {999}
+do_test minmax-3.3 {
+ set sqlite_search_count
+} {0}
+
+ifcapable {compound && subquery} {
+ do_test minmax-4.1 {
+ execsql {
+ SELECT coalesce(min(x+0),-1), coalesce(max(x+0),-1) FROM
+ (SELECT * FROM t1 UNION SELECT NULL as 'x', NULL as 'y')
+ }
+ } {1 20}
+ do_test minmax-4.2 {
+ execsql {
+ SELECT y, coalesce(sum(x),0) FROM
+ (SELECT null AS x, y+1 AS y FROM t1 UNION SELECT * FROM t1)
+ GROUP BY y ORDER BY y;
+ }
+ } {1 1 2 5 3 22 4 92 5 90 6 0}
+ do_test minmax-4.3 {
+ execsql {
+ SELECT y, count(x), count(*) FROM
+ (SELECT null AS x, y+1 AS y FROM t1 UNION SELECT * FROM t1)
+ GROUP BY y ORDER BY y;
+ }
+ } {1 1 1 2 2 3 3 4 5 4 8 9 5 5 6 6 0 1}
+} ;# ifcapable compound
+
+# Make sure the min(x) and max(x) optimizations work on empty tables
+# including empty tables with indices. Ticket #296.
+#
+do_test minmax-5.1 {
+ execsql {
+ CREATE TABLE t3(x INTEGER UNIQUE NOT NULL);
+ SELECT coalesce(min(x),999) FROM t3;
+ }
+} {999}
+do_test minmax-5.2 {
+ execsql {
+ SELECT coalesce(min(rowid),999) FROM t3;
+ }
+} {999}
+do_test minmax-5.3 {
+ execsql {
+ SELECT coalesce(max(x),999) FROM t3;
+ }
+} {999}
+do_test minmax-5.4 {
+ execsql {
+ SELECT coalesce(max(rowid),999) FROM t3;
+ }
+} {999}
+do_test minmax-5.5 {
+ execsql {
+ SELECT coalesce(max(rowid),999) FROM t3 WHERE rowid<25;
+ }
+} {999}
+
+# Make sure the min(x) and max(x) optimizations work when there
+# is a LIMIT clause. Ticket #396.
+#
+do_test minmax-6.1 {
+ execsql {
+ SELECT min(a) FROM t2 LIMIT 1
+ }
+} {1}
+do_test minmax-6.2 {
+ execsql {
+ SELECT max(a) FROM t2 LIMIT 3
+ }
+} {22}
+do_test minmax-6.3 {
+ execsql {
+ SELECT min(a) FROM t2 LIMIT 0,100
+ }
+} {1}
+do_test minmax-6.4 {
+ execsql {
+ SELECT max(a) FROM t2 LIMIT 1,100
+ }
+} {}
+do_test minmax-6.5 {
+ execsql {
+ SELECT min(x) FROM t3 LIMIT 1
+ }
+} {{}}
+do_test minmax-6.6 {
+ execsql {
+ SELECT max(x) FROM t3 LIMIT 0
+ }
+} {}
+do_test minmax-6.7 {
+ execsql {
+ SELECT max(a) FROM t2 LIMIT 0
+ }
+} {}
+
+# Make sure the max(x) and min(x) optimizations work for nested
+# queries. Ticket #587.
+#
+do_test minmax-7.1 {
+ execsql {
+ SELECT max(x) FROM t1;
+ }
+} 20
+ifcapable subquery {
+ do_test minmax-7.2 {
+ execsql {
+ SELECT * FROM (SELECT max(x) FROM t1);
+ }
+ } 20
+}
+do_test minmax-7.3 {
+ execsql {
+ SELECT min(x) FROM t1;
+ }
+} 1
+ifcapable subquery {
+ do_test minmax-7.4 {
+ execsql {
+ SELECT * FROM (SELECT min(x) FROM t1);
+ }
+ } 1
+}
+
+# Make sure min(x) and max(x) work correctly when the datatype is
+# TEXT instead of NUMERIC. Ticket #623.
+#
+do_test minmax-8.1 {
+ execsql {
+ CREATE TABLE t4(a TEXT);
+ INSERT INTO t4 VALUES('1234');
+ INSERT INTO t4 VALUES('234');
+ INSERT INTO t4 VALUES('34');
+ SELECT min(a), max(a) FROM t4;
+ }
+} {1234 34}
+do_test minmax-8.2 {
+ execsql {
+ CREATE TABLE t5(a INTEGER);
+ INSERT INTO t5 VALUES('1234');
+ INSERT INTO t5 VALUES('234');
+ INSERT INTO t5 VALUES('34');
+ SELECT min(a), max(a) FROM t5;
+ }
+} {34 1234}
+
+# Ticket #658: Test the min()/max() optimization when the FROM clause
+# is a subquery.
+#
+ifcapable {compound && subquery} {
+ do_test minmax-9.1 {
+ execsql {
+ SELECT max(rowid) FROM (
+ SELECT max(rowid) FROM t4 UNION SELECT max(rowid) FROM t5
+ )
+ }
+ } {1}
+ do_test minmax-9.2 {
+ execsql {
+ SELECT max(rowid) FROM (
+ SELECT max(rowid) FROM t4 EXCEPT SELECT max(rowid) FROM t5
+ )
+ }
+ } {{}}
+} ;# ifcapable compound&&subquery
+
+# If there is a NULL in an aggregate max() or min(), ignore it. An
+# aggregate min() or max() will only return NULL if all values are NULL.
+#
+do_test minmax-10.1 {
+ execsql {
+ CREATE TABLE t6(x);
+ INSERT INTO t6 VALUES(1);
+ INSERT INTO t6 VALUES(2);
+ INSERT INTO t6 VALUES(NULL);
+ SELECT coalesce(min(x),-1) FROM t6;
+ }
+} {1}
+do_test minmax-10.2 {
+ execsql {
+ SELECT max(x) FROM t6;
+ }
+} {2}
+do_test minmax-10.3 {
+ execsql {
+ CREATE INDEX i6 ON t6(x);
+ SELECT coalesce(min(x),-1) FROM t6;
+ }
+} {1}
+do_test minmax-10.4 {
+ execsql {
+ SELECT max(x) FROM t6;
+ }
+} {2}
+do_test minmax-10.5 {
+ execsql {
+ DELETE FROM t6 WHERE x NOT NULL;
+ SELECT count(*) FROM t6;
+ }
+} 1
+do_test minmax-10.6 {
+ execsql {
+ SELECT count(x) FROM t6;
+ }
+} 0
+ifcapable subquery {
+ do_test minmax-10.7 {
+ execsql {
+ SELECT (SELECT min(x) FROM t6), (SELECT max(x) FROM t6);
+ }
+ } {{} {}}
+}
+do_test minmax-10.8 {
+ execsql {
+ SELECT min(x), max(x) FROM t6;
+ }
+} {{} {}}
+do_test minmax-10.9 {
+ execsql {
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ SELECT count(*) FROM t6;
+ }
+} 1024
+do_test minmax-10.10 {
+ execsql {
+ SELECT count(x) FROM t6;
+ }
+} 0
+ifcapable subquery {
+ do_test minmax-10.11 {
+ execsql {
+ SELECT (SELECT min(x) FROM t6), (SELECT max(x) FROM t6);
+ }
+ } {{} {}}
+}
+do_test minmax-10.12 {
+ execsql {
+ SELECT min(x), max(x) FROM t6;
+ }
+} {{} {}}
+
+
+do_test minmax-11.1 {
+ execsql {
+ CREATE INDEX t1i2 ON t1(y,x);
+ SELECT min(x) FROM t1 WHERE y=5;
+ }
+} {16}
+do_test minmax-11.2 {
+ execsql {
+ SELECT max(x) FROM t1 WHERE y=5;
+ }
+} {20}
+do_test minmax-11.3 {
+ execsql {
+ SELECT min(x) FROM t1 WHERE y=6;
+ }
+} {{}}
+do_test minmax-11.4 {
+ execsql {
+ SELECT max(x) FROM t1 WHERE y=6;
+ }
+} {{}}
+do_test minmax-11.5 {
+ execsql {
+ SELECT min(x) FROM t1 WHERE y=1;
+ }
+} {1}
+do_test minmax-11.6 {
+ execsql {
+ SELECT max(x) FROM t1 WHERE y=1;
+ }
+} {1}
+do_test minmax-11.7 {
+ execsql {
+ SELECT min(x) FROM t1 WHERE y=0;
+ }
+} {{}}
+do_test minmax-11.8 {
+ execsql {
+ SELECT max(x) FROM t1 WHERE y=0;
+ }
+} {{}}
+do_test minmax-11.9 {
+ execsql {
+ SELECT min(x) FROM t1 WHERE y=5 AND x>=17.5;
+ }
+} {18}
+do_test minmax-11.10 {
+ execsql {
+ SELECT max(x) FROM t1 WHERE y=5 AND x>=17.5;
+ }
+} {20}
+
+do_test minmax-12.1 {
+ execsql {
+ CREATE TABLE t7(a,b,c);
+ INSERT INTO t7 SELECT y, x, x*y FROM t1;
+ INSERT INTO t7 SELECT y, x, x*y+1000 FROM t1;
+ CREATE INDEX t7i1 ON t7(a,b,c);
+ SELECT min(a) FROM t7;
+ }
+} {1}
+do_test minmax-12.2 {
+ execsql {
+ SELECT max(a) FROM t7;
+ }
+} {5}
+do_test minmax-12.3 {
+ execsql {
+ SELECT max(a) FROM t7 WHERE a=5;
+ }
+} {5}
+do_test minmax-12.4 {
+ execsql {
+ SELECT min(b) FROM t7 WHERE a=5;
+ }
+} {16}
+do_test minmax-12.5 {
+ execsql {
+ SELECT max(b) FROM t7 WHERE a=5;
+ }
+} {20}
+do_test minmax-12.6 {
+ execsql {
+ SELECT min(b) FROM t7 WHERE a=4;
+ }
+} {8}
+do_test minmax-12.7 {
+ execsql {
+ SELECT max(b) FROM t7 WHERE a=4;
+ }
+} {15}
+do_test minmax-12.8 {
+ execsql {
+ SELECT min(c) FROM t7 WHERE a=4 AND b=10;
+ }
+} {40}
+do_test minmax-12.9 {
+ execsql {
+ SELECT max(c) FROM t7 WHERE a=4 AND b=10;
+ }
+} {1040}
+do_test minmax-12.10 {
+ execsql {
+ SELECT min(rowid) FROM t7;
+ }
+} {1}
+do_test minmax-12.11 {
+ execsql {
+ SELECT max(rowid) FROM t7;
+ }
+} {40}
+do_test minmax-12.12 {
+ execsql {
+ SELECT min(rowid) FROM t7 WHERE a=3;
+ }
+} {4}
+do_test minmax-12.13 {
+ execsql {
+ SELECT max(rowid) FROM t7 WHERE a=3;
+ }
+} {27}
+do_test minmax-12.14 {
+ execsql {
+ SELECT min(rowid) FROM t7 WHERE a=3 AND b=5;
+ }
+} {5}
+do_test minmax-12.15 {
+ execsql {
+ SELECT max(rowid) FROM t7 WHERE a=3 AND b=5;
+ }
+} {25}
+do_test minmax-12.16 {
+ execsql {
+ SELECT min(rowid) FROM t7 WHERE a=3 AND b=5 AND c=1015;
+ }
+} {25}
+do_test minmax-12.17 {
+ execsql {
+ SELECT max(rowid) FROM t7 WHERE a=3 AND b=5 AND c=15;
+ }
+} {5}
+
+
+
+
+finish_test
diff --git a/test/minmax2.test b/test/minmax2.test
new file mode 100644
index 0000000..2f504d4
--- /dev/null
+++ b/test/minmax2.test
@@ -0,0 +1,387 @@
+# 2007 July 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing SELECT statements that contain
+# aggregate min() and max() functions and which are handled as
+# as a special case. This file makes sure that the min/max
+# optimization works right in the presence of descending
+# indices. Ticket #2514.
+#
+# $Id: minmax2.test,v 1.2 2008/01/05 17:39:30 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test minmax2-1.0 {
+ execsql {
+ PRAGMA legacy_file_format=0;
+ BEGIN;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1,1);
+ INSERT INTO t1 VALUES(2,2);
+ INSERT INTO t1 VALUES(3,2);
+ INSERT INTO t1 VALUES(4,3);
+ INSERT INTO t1 VALUES(5,3);
+ INSERT INTO t1 VALUES(6,3);
+ INSERT INTO t1 VALUES(7,3);
+ INSERT INTO t1 VALUES(8,4);
+ INSERT INTO t1 VALUES(9,4);
+ INSERT INTO t1 VALUES(10,4);
+ INSERT INTO t1 VALUES(11,4);
+ INSERT INTO t1 VALUES(12,4);
+ INSERT INTO t1 VALUES(13,4);
+ INSERT INTO t1 VALUES(14,4);
+ INSERT INTO t1 VALUES(15,4);
+ INSERT INTO t1 VALUES(16,5);
+ INSERT INTO t1 VALUES(17,5);
+ INSERT INTO t1 VALUES(18,5);
+ INSERT INTO t1 VALUES(19,5);
+ INSERT INTO t1 VALUES(20,5);
+ COMMIT;
+ SELECT DISTINCT y FROM t1 ORDER BY y;
+ }
+} {1 2 3 4 5}
+
+do_test minmax2-1.1 {
+ set sqlite_search_count 0
+ execsql {SELECT min(x) FROM t1}
+} {1}
+do_test minmax2-1.2 {
+ set sqlite_search_count
+} {19}
+do_test minmax2-1.3 {
+ set sqlite_search_count 0
+ execsql {SELECT max(x) FROM t1}
+} {20}
+do_test minmax2-1.4 {
+ set sqlite_search_count
+} {19}
+do_test minmax2-1.5 {
+ execsql {CREATE INDEX t1i1 ON t1(x DESC)}
+ set sqlite_search_count 0
+ execsql {SELECT min(x) FROM t1}
+} {1}
+do_test minmax2-1.6 {
+ set sqlite_search_count
+} {1}
+do_test minmax2-1.7 {
+ set sqlite_search_count 0
+ execsql {SELECT max(x) FROM t1}
+} {20}
+do_test minmax2-1.8 {
+ set sqlite_search_count
+} {0}
+do_test minmax2-1.9 {
+ set sqlite_search_count 0
+ execsql {SELECT max(y) FROM t1}
+} {5}
+do_test minmax2-1.10 {
+ set sqlite_search_count
+} {19}
+
+do_test minmax2-2.0 {
+ execsql {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t2 SELECT * FROM t1;
+ }
+ set sqlite_search_count 0
+ execsql {SELECT min(a) FROM t2}
+} {1}
+do_test minmax2-2.1 {
+ set sqlite_search_count
+} {0}
+do_test minmax2-2.2 {
+ set sqlite_search_count 0
+ execsql {SELECT max(a) FROM t2}
+} {20}
+do_test minmax2-2.3 {
+ set sqlite_search_count
+} {0}
+
+do_test minmax2-3.0 {
+ ifcapable subquery {
+ execsql {INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)}
+ } else {
+ db function max_a_t2 {execsql {SELECT max(a) FROM t2}}
+ execsql {INSERT INTO t2 VALUES(max_a_t2()+1,999)}
+ }
+ set sqlite_search_count 0
+ execsql {SELECT max(a) FROM t2}
+} {21}
+do_test minmax2-3.1 {
+ set sqlite_search_count
+} {0}
+do_test minmax2-3.2 {
+ ifcapable subquery {
+ execsql {INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)}
+ } else {
+ db function max_a_t2 {execsql {SELECT max(a) FROM t2}}
+ execsql {INSERT INTO t2 VALUES(max_a_t2()+1,999)}
+ }
+ set sqlite_search_count 0
+ ifcapable subquery {
+ execsql { SELECT b FROM t2 WHERE a=(SELECT max(a) FROM t2) }
+ } else {
+ execsql { SELECT b FROM t2 WHERE a=max_a_t2() }
+ }
+} {999}
+do_test minmax2-3.3 {
+ set sqlite_search_count
+} {0}
+
+ifcapable {compound && subquery} {
+ do_test minmax2-4.1 {
+ execsql {
+ SELECT coalesce(min(x+0),-1), coalesce(max(x+0),-1) FROM
+ (SELECT * FROM t1 UNION SELECT NULL as 'x', NULL as 'y')
+ }
+ } {1 20}
+ do_test minmax2-4.2 {
+ execsql {
+ SELECT y, coalesce(sum(x),0) FROM
+ (SELECT null AS x, y+1 AS y FROM t1 UNION SELECT * FROM t1)
+ GROUP BY y ORDER BY y;
+ }
+ } {1 1 2 5 3 22 4 92 5 90 6 0}
+ do_test minmax2-4.3 {
+ execsql {
+ SELECT y, count(x), count(*) FROM
+ (SELECT null AS x, y+1 AS y FROM t1 UNION SELECT * FROM t1)
+ GROUP BY y ORDER BY y;
+ }
+ } {1 1 1 2 2 3 3 4 5 4 8 9 5 5 6 6 0 1}
+} ;# ifcapable compound
+
+# Make sure the min(x) and max(x) optimizations work on empty tables
+# including empty tables with indices. Ticket #296.
+#
+do_test minmax2-5.1 {
+ execsql {
+ CREATE TABLE t3(x INTEGER UNIQUE NOT NULL);
+ SELECT coalesce(min(x),999) FROM t3;
+ }
+} {999}
+do_test minmax2-5.2 {
+ execsql {
+ SELECT coalesce(min(rowid),999) FROM t3;
+ }
+} {999}
+do_test minmax2-5.3 {
+ execsql {
+ SELECT coalesce(max(x),999) FROM t3;
+ }
+} {999}
+do_test minmax2-5.4 {
+ execsql {
+ SELECT coalesce(max(rowid),999) FROM t3;
+ }
+} {999}
+do_test minmax2-5.5 {
+ execsql {
+ SELECT coalesce(max(rowid),999) FROM t3 WHERE rowid<25;
+ }
+} {999}
+
+# Make sure the min(x) and max(x) optimizations work when there
+# is a LIMIT clause. Ticket #396.
+#
+do_test minmax2-6.1 {
+ execsql {
+ SELECT min(a) FROM t2 LIMIT 1
+ }
+} {1}
+do_test minmax2-6.2 {
+ execsql {
+ SELECT max(a) FROM t2 LIMIT 3
+ }
+} {22}
+do_test minmax2-6.3 {
+ execsql {
+ SELECT min(a) FROM t2 LIMIT 0,100
+ }
+} {1}
+do_test minmax2-6.4 {
+ execsql {
+ SELECT max(a) FROM t2 LIMIT 1,100
+ }
+} {}
+do_test minmax2-6.5 {
+ execsql {
+ SELECT min(x) FROM t3 LIMIT 1
+ }
+} {{}}
+do_test minmax2-6.6 {
+ execsql {
+ SELECT max(x) FROM t3 LIMIT 0
+ }
+} {}
+do_test minmax2-6.7 {
+ execsql {
+ SELECT max(a) FROM t2 LIMIT 0
+ }
+} {}
+
+# Make sure the max(x) and min(x) optimizations work for nested
+# queries. Ticket #587.
+#
+do_test minmax2-7.1 {
+ execsql {
+ SELECT max(x) FROM t1;
+ }
+} 20
+ifcapable subquery {
+ do_test minmax2-7.2 {
+ execsql {
+ SELECT * FROM (SELECT max(x) FROM t1);
+ }
+ } 20
+}
+do_test minmax2-7.3 {
+ execsql {
+ SELECT min(x) FROM t1;
+ }
+} 1
+ifcapable subquery {
+ do_test minmax2-7.4 {
+ execsql {
+ SELECT * FROM (SELECT min(x) FROM t1);
+ }
+ } 1
+}
+
+# Make sure min(x) and max(x) work correctly when the datatype is
+# TEXT instead of NUMERIC. Ticket #623.
+#
+do_test minmax2-8.1 {
+ execsql {
+ CREATE TABLE t4(a TEXT);
+ INSERT INTO t4 VALUES('1234');
+ INSERT INTO t4 VALUES('234');
+ INSERT INTO t4 VALUES('34');
+ SELECT min(a), max(a) FROM t4;
+ }
+} {1234 34}
+do_test minmax2-8.2 {
+ execsql {
+ CREATE TABLE t5(a INTEGER);
+ INSERT INTO t5 VALUES('1234');
+ INSERT INTO t5 VALUES('234');
+ INSERT INTO t5 VALUES('34');
+ SELECT min(a), max(a) FROM t5;
+ }
+} {34 1234}
+
+# Ticket #658: Test the min()/max() optimization when the FROM clause
+# is a subquery.
+#
+ifcapable {compound && subquery} {
+ do_test minmax2-9.1 {
+ execsql {
+ SELECT max(rowid) FROM (
+ SELECT max(rowid) FROM t4 UNION SELECT max(rowid) FROM t5
+ )
+ }
+ } {1}
+ do_test minmax2-9.2 {
+ execsql {
+ SELECT max(rowid) FROM (
+ SELECT max(rowid) FROM t4 EXCEPT SELECT max(rowid) FROM t5
+ )
+ }
+ } {{}}
+} ;# ifcapable compound&&subquery
+
+# If there is a NULL in an aggregate max() or min(), ignore it. An
+# aggregate min() or max() will only return NULL if all values are NULL.
+#
+do_test minmax2-10.1 {
+ execsql {
+ CREATE TABLE t6(x);
+ INSERT INTO t6 VALUES(1);
+ INSERT INTO t6 VALUES(2);
+ INSERT INTO t6 VALUES(NULL);
+ SELECT coalesce(min(x),-1) FROM t6;
+ }
+} {1}
+do_test minmax2-10.2 {
+ execsql {
+ SELECT max(x) FROM t6;
+ }
+} {2}
+do_test minmax2-10.3 {
+ execsql {
+ CREATE INDEX i6 ON t6(x DESC);
+ SELECT coalesce(min(x),-1) FROM t6;
+ }
+} {1}
+do_test minmax2-10.4 {
+ execsql {
+ SELECT max(x) FROM t6;
+ }
+} {2}
+do_test minmax2-10.5 {
+ execsql {
+ DELETE FROM t6 WHERE x NOT NULL;
+ SELECT count(*) FROM t6;
+ }
+} 1
+do_test minmax2-10.6 {
+ execsql {
+ SELECT count(x) FROM t6;
+ }
+} 0
+ifcapable subquery {
+ do_test minmax2-10.7 {
+ execsql {
+ SELECT (SELECT min(x) FROM t6), (SELECT max(x) FROM t6);
+ }
+ } {{} {}}
+}
+do_test minmax2-10.8 {
+ execsql {
+ SELECT min(x), max(x) FROM t6;
+ }
+} {{} {}}
+do_test minmax2-10.9 {
+ execsql {
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ SELECT count(*) FROM t6;
+ }
+} 1024
+do_test minmax2-10.10 {
+ execsql {
+ SELECT count(x) FROM t6;
+ }
+} 0
+ifcapable subquery {
+ do_test minmax2-10.11 {
+ execsql {
+ SELECT (SELECT min(x) FROM t6), (SELECT max(x) FROM t6);
+ }
+ } {{} {}}
+}
+do_test minmax2-10.12 {
+ execsql {
+ SELECT min(x), max(x) FROM t6;
+ }
+} {{} {}}
+
+
+finish_test
diff --git a/test/minmax3.test b/test/minmax3.test
new file mode 100644
index 0000000..483fa61
--- /dev/null
+++ b/test/minmax3.test
@@ -0,0 +1,288 @@
+# 2008 January 5
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# $Id: minmax3.test,v 1.5 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Do an SQL statement. Append the search count to the end of the result.
+#
+proc count sql {
+ set ::sqlite_search_count 0
+ return [concat [execsql $sql] $::sqlite_search_count]
+}
+
+# This procedure sets the value of the file-format in file 'test.db'
+# to $newval. Also, the schema cookie is incremented.
+#
+proc set_file_format {newval} {
+ hexio_write test.db 44 [hexio_render_int32 $newval]
+ set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
+ incr schemacookie
+ hexio_write test.db 40 [hexio_render_int32 $schemacookie]
+ return {}
+}
+
+do_test minmax3-1.0 {
+ execsql {
+ CREATE TABLE t1(x, y, z);
+ }
+ db close
+ set_file_format 4
+ sqlite3 db test.db
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('1', 'I', 'one');
+ INSERT INTO t1 VALUES('2', 'IV', 'four');
+ INSERT INTO t1 VALUES('2', NULL, 'three');
+ INSERT INTO t1 VALUES('2', 'II', 'two');
+ INSERT INTO t1 VALUES('2', 'V', 'five');
+ INSERT INTO t1 VALUES('3', 'VI', 'six');
+ COMMIT;
+ PRAGMA automatic_index=OFF;
+ }
+} {}
+do_test minmax3-1.1.1 {
+ # Linear scan.
+ count { SELECT max(y) FROM t1 WHERE x = '2'; }
+} {V 5}
+do_test minmax3-1.1.2 {
+ # Index optimizes the WHERE x='2' constraint.
+ execsql { CREATE INDEX i1 ON t1(x) }
+ count { SELECT max(y) FROM t1 WHERE x = '2'; }
+} {V 9}
+do_test minmax3-1.1.3 {
+ # Index optimizes the WHERE x='2' constraint and the MAX(y).
+ execsql { CREATE INDEX i2 ON t1(x,y) }
+ count { SELECT max(y) FROM t1 WHERE x = '2'; }
+} {V 1}
+do_test minmax3-1.1.4 {
+ # Index optimizes the WHERE x='2' constraint and the MAX(y).
+ execsql { DROP INDEX i2 ; CREATE INDEX i2 ON t1(x, y DESC) }
+ count { SELECT max(y) FROM t1 WHERE x = '2'; }
+} {V 1}
+do_test minmax3-1.1.5 {
+ count { SELECT max(y) FROM t1 WHERE x = '2' AND y != 'V'; }
+} {IV 2}
+do_test minmax3-1.1.6 {
+ count { SELECT max(y) FROM t1 WHERE x = '2' AND y < 'V'; }
+} {IV 1}
+do_test minmax3-1.1.6 {
+ count { SELECT max(y) FROM t1 WHERE x = '2' AND z != 'five'; }
+} {IV 4}
+
+do_test minmax3-1.2.1 {
+ # Linear scan of t1.
+ execsql { DROP INDEX i1 ; DROP INDEX i2 }
+ count { SELECT min(y) FROM t1 WHERE x = '2'; }
+} {II 5}
+do_test minmax3-1.2.2 {
+ # Index i1 optimizes the WHERE x='2' constraint.
+ execsql { CREATE INDEX i1 ON t1(x) }
+ count { SELECT min(y) FROM t1 WHERE x = '2'; }
+} {II 9}
+do_test minmax3-1.2.3 {
+ # Index i2 optimizes the WHERE x='2' constraint and the min(y).
+ execsql { CREATE INDEX i2 ON t1(x,y) }
+ count { SELECT min(y) FROM t1 WHERE x = '2'; }
+} {II 1}
+do_test minmax3-1.2.4 {
+ # Index optimizes the WHERE x='2' constraint and the MAX(y).
+ execsql { DROP INDEX i2 ; CREATE INDEX i2 ON t1(x, y DESC) }
+ count { SELECT min(y) FROM t1 WHERE x = '2'; }
+} {II 1}
+
+do_test minmax3-1.3.1 {
+ # Linear scan
+ execsql { DROP INDEX i1 ; DROP INDEX i2 }
+ count { SELECT min(y) FROM t1; }
+} {I 5}
+do_test minmax3-1.3.2 {
+ # Index i1 optimizes the min(y)
+ execsql { CREATE INDEX i1 ON t1(y) }
+ count { SELECT min(y) FROM t1; }
+} {I 1}
+do_test minmax3-1.3.3 {
+ # Index i1 optimizes the min(y)
+ execsql { DROP INDEX i1 ; CREATE INDEX i1 ON t1(y DESC) }
+ count { SELECT min(y) FROM t1; }
+} {I 1}
+
+do_test minmax3-1.4.1 {
+ # Linear scan
+ execsql { DROP INDEX i1 }
+ count { SELECT max(y) FROM t1; }
+} {VI 5}
+do_test minmax3-1.4.2 {
+ # Index i1 optimizes the max(y)
+ execsql { CREATE INDEX i1 ON t1(y) }
+ count { SELECT max(y) FROM t1; }
+} {VI 0}
+do_test minmax3-1.4.3 {
+ # Index i1 optimizes the max(y)
+ execsql { DROP INDEX i1 ; CREATE INDEX i1 ON t1(y DESC) }
+ execsql { SELECT y from t1}
+ count { SELECT max(y) FROM t1; }
+} {VI 0}
+do_test minmax3-1.4.4 {
+ execsql { DROP INDEX i1 }
+} {}
+
+do_test minmax3-2.1 {
+ execsql {
+ CREATE TABLE t2(a, b);
+ CREATE INDEX i3 ON t2(a, b);
+ INSERT INTO t2 VALUES(1, NULL);
+ INSERT INTO t2 VALUES(1, 1);
+ INSERT INTO t2 VALUES(1, 2);
+ INSERT INTO t2 VALUES(1, 3);
+ INSERT INTO t2 VALUES(2, NULL);
+ INSERT INTO t2 VALUES(2, 1);
+ INSERT INTO t2 VALUES(2, 2);
+ INSERT INTO t2 VALUES(2, 3);
+ INSERT INTO t2 VALUES(3, 1);
+ INSERT INTO t2 VALUES(3, 2);
+ INSERT INTO t2 VALUES(3, 3);
+ }
+} {}
+do_test minmax3-2.2 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1; }
+} {1}
+do_test minmax3-2.3 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b>1; }
+} {2}
+do_test minmax3-2.4 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b>-1; }
+} {1}
+do_test minmax3-2.5 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1; }
+} {1}
+do_test minmax3-2.6 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b<2; }
+} {1}
+do_test minmax3-2.7 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b<1; }
+} {{}}
+do_test minmax3-2.8 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 3 AND b<1; }
+} {{}}
+
+do_test minmax3-3.1 {
+ execsql {
+ DROP TABLE t2;
+ CREATE TABLE t2(a, b);
+ CREATE INDEX i3 ON t2(a, b DESC);
+ INSERT INTO t2 VALUES(1, NULL);
+ INSERT INTO t2 VALUES(1, 1);
+ INSERT INTO t2 VALUES(1, 2);
+ INSERT INTO t2 VALUES(1, 3);
+ INSERT INTO t2 VALUES(2, NULL);
+ INSERT INTO t2 VALUES(2, 1);
+ INSERT INTO t2 VALUES(2, 2);
+ INSERT INTO t2 VALUES(2, 3);
+ INSERT INTO t2 VALUES(3, 1);
+ INSERT INTO t2 VALUES(3, 2);
+ INSERT INTO t2 VALUES(3, 3);
+ }
+} {}
+do_test minmax3-3.2 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1; }
+} {1}
+do_test minmax3-3.3 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b>1; }
+} {2}
+do_test minmax3-3.4 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b>-1; }
+} {1}
+do_test minmax3-3.5 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1; }
+} {1}
+do_test minmax3-3.6 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b<2; }
+} {1}
+do_test minmax3-3.7 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b<1; }
+} {{}}
+do_test minmax3-3.8 {
+ execsql { SELECT min(b) FROM t2 WHERE a = 3 AND b<1; }
+} {{}}
+
+do_test minmax3-4.1 {
+ execsql {
+ CREATE TABLE t4(x);
+ INSERT INTO t4 VALUES('abc');
+ INSERT INTO t4 VALUES('BCD');
+ SELECT max(x) FROM t4;
+ }
+} {abc}
+do_test minmax3-4.2 {
+ execsql {
+ SELECT max(x COLLATE nocase) FROM t4;
+ }
+} {BCD}
+do_test minmax3-4.3 {
+ execsql {
+ SELECT max(x), max(x COLLATE nocase) FROM t4;
+ }
+} {abc BCD}
+do_test minmax3-4.4 {
+ execsql {
+ SELECT max(x COLLATE binary), max(x COLLATE nocase) FROM t4;
+ }
+} {abc BCD}
+do_test minmax3-4.5 {
+ execsql {
+ SELECT max(x COLLATE nocase), max(x COLLATE rtrim) FROM t4;
+ }
+} {BCD abc}
+do_test minmax3-4.6 {
+ execsql {
+ SELECT max(x COLLATE nocase), max(x) FROM t4;
+ }
+} {BCD abc}
+do_test minmax3-4.10 {
+ execsql {
+ SELECT min(x) FROM t4;
+ }
+} {BCD}
+do_test minmax3-4.11 {
+ execsql {
+ SELECT min(x COLLATE nocase) FROM t4;
+ }
+} {abc}
+do_test minmax3-4.12 {
+ execsql {
+ SELECT min(x), min(x COLLATE nocase) FROM t4;
+ }
+} {BCD abc}
+do_test minmax3-4.13 {
+ execsql {
+ SELECT min(x COLLATE binary), min(x COLLATE nocase) FROM t4;
+ }
+} {BCD abc}
+do_test minmax3-4.14 {
+ execsql {
+ SELECT min(x COLLATE nocase), min(x COLLATE rtrim) FROM t4;
+ }
+} {abc BCD}
+do_test minmax3-4.15 {
+ execsql {
+ SELECT min(x COLLATE nocase), min(x) FROM t4;
+ }
+} {abc BCD}
+
+
+finish_test
diff --git a/test/misc1.test b/test/misc1.test
new file mode 100644
index 0000000..e3f1b95
--- /dev/null
+++ b/test/misc1.test
@@ -0,0 +1,589 @@
+# 2001 September 15.
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for miscellanous features that were
+# left out of other test files.
+#
+# $Id: misc1.test,v 1.42 2007/11/05 14:58:23 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Mimic the SQLite 2 collation type NUMERIC.
+db collate numeric numeric_collate
+proc numeric_collate {lhs rhs} {
+ if {$lhs == $rhs} {return 0}
+ return [expr ($lhs>$rhs)?1:-1]
+}
+
+# Mimic the SQLite 2 collation type TEXT.
+db collate text text_collate
+proc numeric_collate {lhs rhs} {
+ return [string compare $lhs $rhs]
+}
+
+# Test the creation and use of tables that have a large number
+# of columns.
+#
+do_test misc1-1.1 {
+ set cmd "CREATE TABLE manycol(x0 text"
+ for {set i 1} {$i<=99} {incr i} {
+ append cmd ",x$i text"
+ }
+ append cmd ")";
+ execsql $cmd
+ set cmd "INSERT INTO manycol VALUES(0"
+ for {set i 1} {$i<=99} {incr i} {
+ append cmd ",$i"
+ }
+ append cmd ")";
+ execsql $cmd
+ execsql "SELECT x99 FROM manycol"
+} 99
+do_test misc1-1.2 {
+ execsql {SELECT x0, x10, x25, x50, x75 FROM manycol}
+} {0 10 25 50 75}
+do_test misc1-1.3.1 {
+ for {set j 100} {$j<=1000} {incr j 100} {
+ set cmd "INSERT INTO manycol VALUES($j"
+ for {set i 1} {$i<=99} {incr i} {
+ append cmd ",[expr {$i+$j}]"
+ }
+ append cmd ")"
+ execsql $cmd
+ }
+ execsql {SELECT x50 FROM manycol ORDER BY x80+0}
+} {50 150 250 350 450 550 650 750 850 950 1050}
+do_test misc1-1.3.2 {
+ execsql {SELECT x50 FROM manycol ORDER BY x80}
+} {1050 150 250 350 450 550 650 750 50 850 950}
+do_test misc1-1.4 {
+ execsql {SELECT x75 FROM manycol WHERE x50=350}
+} 375
+do_test misc1-1.5 {
+ execsql {SELECT x50 FROM manycol WHERE x99=599}
+} 550
+do_test misc1-1.6 {
+ execsql {CREATE INDEX manycol_idx1 ON manycol(x99)}
+ execsql {SELECT x50 FROM manycol WHERE x99=899}
+} 850
+do_test misc1-1.7 {
+ execsql {SELECT count(*) FROM manycol}
+} 11
+do_test misc1-1.8 {
+ execsql {DELETE FROM manycol WHERE x98=1234}
+ execsql {SELECT count(*) FROM manycol}
+} 11
+do_test misc1-1.9 {
+ execsql {DELETE FROM manycol WHERE x98=998}
+ execsql {SELECT count(*) FROM manycol}
+} 10
+do_test misc1-1.10 {
+ execsql {DELETE FROM manycol WHERE x99=500}
+ execsql {SELECT count(*) FROM manycol}
+} 10
+do_test misc1-1.11 {
+ execsql {DELETE FROM manycol WHERE x99=599}
+ execsql {SELECT count(*) FROM manycol}
+} 9
+
+# Check GROUP BY expressions that name two or more columns.
+#
+do_test misc1-2.1 {
+ execsql {
+ BEGIN TRANSACTION;
+ CREATE TABLE agger(one text, two text, three text, four text);
+ INSERT INTO agger VALUES(1, 'one', 'hello', 'yes');
+ INSERT INTO agger VALUES(2, 'two', 'howdy', 'no');
+ INSERT INTO agger VALUES(3, 'thr', 'howareya', 'yes');
+ INSERT INTO agger VALUES(4, 'two', 'lothere', 'yes');
+ INSERT INTO agger VALUES(5, 'one', 'atcha', 'yes');
+ INSERT INTO agger VALUES(6, 'two', 'hello', 'no');
+ COMMIT
+ }
+ execsql {SELECT count(*) FROM agger}
+} 6
+do_test misc1-2.2 {
+ execsql {SELECT sum(one), two, four FROM agger
+ GROUP BY two, four ORDER BY sum(one) desc}
+} {8 two no 6 one yes 4 two yes 3 thr yes}
+do_test misc1-2.3 {
+ execsql {SELECT sum((one)), (two), (four) FROM agger
+ GROUP BY (two), (four) ORDER BY sum(one) desc}
+} {8 two no 6 one yes 4 two yes 3 thr yes}
+
+# Here's a test for a bug found by Joel Lucsy. The code below
+# was causing an assertion failure.
+#
+do_test misc1-3.1 {
+ set r [execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES('hi');
+ PRAGMA full_column_names=on;
+ SELECT rowid, * FROM t1;
+ }]
+ lindex $r 1
+} {hi}
+
+# Here's a test for yet another bug found by Joel Lucsy. The code
+# below was causing an assertion failure.
+#
+do_test misc1-4.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES('This is a long string to use up a lot of disk -');
+ UPDATE t2 SET a=a||a||a||a;
+ INSERT INTO t2 SELECT '1 - ' || a FROM t2;
+ INSERT INTO t2 SELECT '2 - ' || a FROM t2;
+ INSERT INTO t2 SELECT '3 - ' || a FROM t2;
+ INSERT INTO t2 SELECT '4 - ' || a FROM t2;
+ INSERT INTO t2 SELECT '5 - ' || a FROM t2;
+ INSERT INTO t2 SELECT '6 - ' || a FROM t2;
+ COMMIT;
+ SELECT count(*) FROM t2;
+ }
+} {64}
+
+# Make sure we actually see a semicolon or end-of-file in the SQL input
+# before executing a command. Thus if "WHERE" is misspelled on an UPDATE,
+# the user won't accidently update every record.
+#
+do_test misc1-5.1 {
+ catchsql {
+ CREATE TABLE t3(a,b);
+ INSERT INTO t3 VALUES(1,2);
+ INSERT INTO t3 VALUES(3,4);
+ UPDATE t3 SET a=0 WHEREwww b=2;
+ }
+} {1 {near "WHEREwww": syntax error}}
+do_test misc1-5.2 {
+ execsql {
+ SELECT * FROM t3 ORDER BY a;
+ }
+} {1 2 3 4}
+
+# Certain keywords (especially non-standard keywords like "REPLACE") can
+# also be used as identifiers. The way this works in the parser is that
+# the parser first detects a syntax error, the error handling routine
+# sees that the special keyword caused the error, then replaces the keyword
+# with "ID" and tries again.
+#
+# Check the operation of this logic.
+#
+do_test misc1-6.1 {
+ catchsql {
+ CREATE TABLE t4(
+ abort, asc, begin, cluster, conflict, copy, delimiters, desc, end,
+ explain, fail, ignore, key, offset, pragma, replace, temp,
+ vacuum, view
+ );
+ }
+} {0 {}}
+do_test misc1-6.2 {
+ catchsql {
+ INSERT INTO t4
+ VALUES(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
+ }
+} {0 {}}
+do_test misc1-6.3 {
+ execsql {
+ SELECT * FROM t4
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19}
+do_test misc1-6.4 {
+ execsql {
+ SELECT abort+asc,max(key,pragma,temp) FROM t4
+ }
+} {3 17}
+
+# Test for multi-column primary keys, and for multiple primary keys.
+#
+do_test misc1-7.1 {
+ catchsql {
+ CREATE TABLE error1(
+ a TYPE PRIMARY KEY,
+ b TYPE PRIMARY KEY
+ );
+ }
+} {1 {table "error1" has more than one primary key}}
+do_test misc1-7.2 {
+ catchsql {
+ CREATE TABLE error1(
+ a INTEGER PRIMARY KEY,
+ b TYPE PRIMARY KEY
+ );
+ }
+} {1 {table "error1" has more than one primary key}}
+do_test misc1-7.3 {
+ execsql {
+ CREATE TABLE t5(a,b,c,PRIMARY KEY(a,b));
+ INSERT INTO t5 VALUES(1,2,3);
+ SELECT * FROM t5 ORDER BY a;
+ }
+} {1 2 3}
+do_test misc1-7.4 {
+ catchsql {
+ INSERT INTO t5 VALUES(1,2,4);
+ }
+} {1 {columns a, b are not unique}}
+do_test misc1-7.5 {
+ catchsql {
+ INSERT INTO t5 VALUES(0,2,4);
+ }
+} {0 {}}
+do_test misc1-7.6 {
+ execsql {
+ SELECT * FROM t5 ORDER BY a;
+ }
+} {0 2 4 1 2 3}
+
+do_test misc1-8.1 {
+ catchsql {
+ SELECT *;
+ }
+} {1 {no tables specified}}
+do_test misc1-8.2 {
+ catchsql {
+ SELECT t1.*;
+ }
+} {1 {no such table: t1}}
+
+execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ DROP TABLE t3;
+ DROP TABLE t4;
+}
+
+# 64-bit integers are represented exactly.
+#
+do_test misc1-9.1 {
+ catchsql {
+ CREATE TABLE t1(a unique not null, b unique not null);
+ INSERT INTO t1 VALUES('a',1234567890123456789);
+ INSERT INTO t1 VALUES('b',1234567891123456789);
+ INSERT INTO t1 VALUES('c',1234567892123456789);
+ SELECT * FROM t1;
+ }
+} {0 {a 1234567890123456789 b 1234567891123456789 c 1234567892123456789}}
+
+# A WHERE clause is not allowed to contain more than 99 terms. Check to
+# make sure this limit is enforced.
+#
+# 2005-07-16: There is no longer a limit on the number of terms in a
+# WHERE clause. But keep these tests just so that we have some tests
+# that use a large number of terms in the WHERE clause.
+#
+do_test misc1-10.0 {
+ execsql {SELECT count(*) FROM manycol}
+} {9}
+do_test misc1-10.1 {
+ set ::where {WHERE x0>=0}
+ for {set i 1} {$i<=99} {incr i} {
+ append ::where " AND x$i<>0"
+ }
+ catchsql "SELECT count(*) FROM manycol $::where"
+} {0 9}
+do_test misc1-10.2 {
+ catchsql "SELECT count(*) FROM manycol $::where AND rowid>0"
+} {0 9}
+do_test misc1-10.3 {
+ regsub "x0>=0" $::where "x0=0" ::where
+ catchsql "DELETE FROM manycol $::where"
+} {0 {}}
+do_test misc1-10.4 {
+ execsql {SELECT count(*) FROM manycol}
+} {8}
+do_test misc1-10.5 {
+ catchsql "DELETE FROM manycol $::where AND rowid>0"
+} {0 {}}
+do_test misc1-10.6 {
+ execsql {SELECT x1 FROM manycol WHERE x0=100}
+} {101}
+do_test misc1-10.7 {
+ regsub "x0=0" $::where "x0=100" ::where
+ catchsql "UPDATE manycol SET x1=x1+1 $::where"
+} {0 {}}
+do_test misc1-10.8 {
+ execsql {SELECT x1 FROM manycol WHERE x0=100}
+} {102}
+do_test misc1-10.9 {
+ catchsql "UPDATE manycol SET x1=x1+1 $::where AND rowid>0"
+} {0 {}}
+do_test misc1-10.10 {
+ execsql {SELECT x1 FROM manycol WHERE x0=100}
+} {103}
+
+# Make sure the initialization works even if a database is opened while
+# another process has the database locked.
+#
+# Update for v3: The BEGIN doesn't lock the database so the schema is read
+# and the SELECT returns successfully.
+do_test misc1-11.1 {
+ execsql {BEGIN}
+ execsql {UPDATE t1 SET a=0 WHERE 0}
+ sqlite3 db2 test.db
+ set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]
+ lappend rc $msg
+# v2 result: {1 {database is locked}}
+} {0 3}
+do_test misc1-11.2 {
+ execsql {COMMIT}
+ set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]
+ db2 close
+ lappend rc $msg
+} {0 3}
+
+# Make sure string comparisons really do compare strings in format4+.
+# Similar tests in the format3.test file show that for format3 and earlier
+# all comparisions where numeric if either operand looked like a number.
+#
+do_test misc1-12.1 {
+ execsql {SELECT '0'=='0.0'}
+} {0}
+do_test misc1-12.2 {
+ execsql {SELECT '0'==0.0}
+} {0}
+do_test misc1-12.3 {
+ execsql {SELECT '12345678901234567890'=='12345678901234567891'}
+} {0}
+do_test misc1-12.4 {
+ execsql {
+ CREATE TABLE t6(a INT UNIQUE, b TEXT UNIQUE);
+ INSERT INTO t6 VALUES('0','0.0');
+ SELECT * FROM t6;
+ }
+} {0 0.0}
+ifcapable conflict {
+ do_test misc1-12.5 {
+ execsql {
+ INSERT OR IGNORE INTO t6 VALUES(0.0,'x');
+ SELECT * FROM t6;
+ }
+ } {0 0.0}
+ do_test misc1-12.6 {
+ execsql {
+ INSERT OR IGNORE INTO t6 VALUES('y',0);
+ SELECT * FROM t6;
+ }
+ } {0 0.0 y 0}
+}
+do_test misc1-12.7 {
+ execsql {
+ CREATE TABLE t7(x INTEGER, y TEXT, z);
+ INSERT INTO t7 VALUES(0,0,1);
+ INSERT INTO t7 VALUES(0.0,0,2);
+ INSERT INTO t7 VALUES(0,0.0,3);
+ INSERT INTO t7 VALUES(0.0,0.0,4);
+ SELECT DISTINCT x, y FROM t7 ORDER BY z;
+ }
+} {0 0 0 0.0}
+do_test misc1-12.8 {
+ execsql {
+ SELECT min(z), max(z), count(z) FROM t7 GROUP BY x ORDER BY 1;
+ }
+} {1 4 4}
+do_test misc1-12.9 {
+ execsql {
+ SELECT min(z), max(z), count(z) FROM t7 GROUP BY y ORDER BY 1;
+ }
+} {1 2 2 3 4 2}
+
+# This used to be an error. But we changed the code so that arbitrary
+# identifiers can be used as a collating sequence. Collation is by text
+# if the identifier contains "text", "blob", or "clob" and is numeric
+# otherwise.
+#
+# Update: In v3, it is an error again.
+#
+#do_test misc1-12.10 {
+# catchsql {
+# SELECT * FROM t6 ORDER BY a COLLATE unknown;
+# }
+#} {0 {0 0 y 0}}
+do_test misc1-12.11 {
+ execsql {
+ CREATE TABLE t8(x TEXT COLLATE numeric, y INTEGER COLLATE text, z);
+ INSERT INTO t8 VALUES(0,0,1);
+ INSERT INTO t8 VALUES(0.0,0,2);
+ INSERT INTO t8 VALUES(0,0.0,3);
+ INSERT INTO t8 VALUES(0.0,0.0,4);
+ SELECT DISTINCT x, y FROM t8 ORDER BY z;
+ }
+} {0 0 0.0 0}
+do_test misc1-12.12 {
+ execsql {
+ SELECT min(z), max(z), count(z) FROM t8 GROUP BY x ORDER BY 1;
+ }
+} {1 3 2 2 4 2}
+do_test misc1-12.13 {
+ execsql {
+ SELECT min(z), max(z), count(z) FROM t8 GROUP BY y ORDER BY 1;
+ }
+} {1 4 4}
+
+# There was a problem with realloc() in the OP_MemStore operation of
+# the VDBE. A buffer was being reallocated but some pointers into
+# the old copy of the buffer were not being moved over to the new copy.
+# The following code tests for the problem.
+#
+ifcapable subquery {
+ do_test misc1-13.1 {
+ execsql {
+ CREATE TABLE t9(x,y);
+ INSERT INTO t9 VALUES('one',1);
+ INSERT INTO t9 VALUES('two',2);
+ INSERT INTO t9 VALUES('three',3);
+ INSERT INTO t9 VALUES('four',4);
+ INSERT INTO t9 VALUES('five',5);
+ INSERT INTO t9 VALUES('six',6);
+ INSERT INTO t9 VALUES('seven',7);
+ INSERT INTO t9 VALUES('eight',8);
+ INSERT INTO t9 VALUES('nine',9);
+ INSERT INTO t9 VALUES('ten',10);
+ INSERT INTO t9 VALUES('eleven',11);
+ SELECT y FROM t9
+ WHERE x=(SELECT x FROM t9 WHERE y=1)
+ OR x=(SELECT x FROM t9 WHERE y=2)
+ OR x=(SELECT x FROM t9 WHERE y=3)
+ OR x=(SELECT x FROM t9 WHERE y=4)
+ OR x=(SELECT x FROM t9 WHERE y=5)
+ OR x=(SELECT x FROM t9 WHERE y=6)
+ OR x=(SELECT x FROM t9 WHERE y=7)
+ OR x=(SELECT x FROM t9 WHERE y=8)
+ OR x=(SELECT x FROM t9 WHERE y=9)
+ OR x=(SELECT x FROM t9 WHERE y=10)
+ OR x=(SELECT x FROM t9 WHERE y=11)
+ OR x=(SELECT x FROM t9 WHERE y=12)
+ OR x=(SELECT x FROM t9 WHERE y=13)
+ OR x=(SELECT x FROM t9 WHERE y=14)
+ ;
+ }
+ } {1 2 3 4 5 6 7 8 9 10 11}
+}
+
+# Make sure a database connection still works after changing the
+# working directory.
+#
+do_test misc1-14.1 {
+ file mkdir tempdir
+ cd tempdir
+ execsql {BEGIN}
+ file exists ./test.db-journal
+} {0}
+do_test misc1-14.2a {
+ execsql {UPDATE t1 SET a=a||'x' WHERE 0}
+ file exists ../test.db-journal
+} {0}
+do_test misc1-14.2b {
+ execsql {UPDATE t1 SET a=a||'y' WHERE 1}
+ file exists ../test.db-journal
+} {1}
+do_test misc1-14.3 {
+ cd ..
+ forcedelete tempdir
+ execsql {COMMIT}
+ file exists ./test.db-journal
+} {0}
+
+# A failed create table should not leave the table in the internal
+# data structures. Ticket #238.
+#
+do_test misc1-15.1.1 {
+ catchsql {
+ CREATE TABLE t10 AS SELECT c1;
+ }
+} {1 {no such column: c1}}
+do_test misc1-15.1.2 {
+ catchsql {
+ CREATE TABLE t10 AS SELECT t9.c1;
+ }
+} {1 {no such column: t9.c1}}
+do_test misc1-15.1.3 {
+ catchsql {
+ CREATE TABLE t10 AS SELECT main.t9.c1;
+ }
+} {1 {no such column: main.t9.c1}}
+do_test misc1-15.2 {
+ catchsql {
+ CREATE TABLE t10 AS SELECT 1;
+ }
+ # The bug in ticket #238 causes the statement above to fail with
+ # the error "table t10 alread exists"
+} {0 {}}
+
+# Test for memory leaks when a CREATE TABLE containing a primary key
+# fails. Ticket #249.
+#
+do_test misc1-16.1 {
+ catchsql {SELECT name FROM sqlite_master LIMIT 1}
+ catchsql {
+ CREATE TABLE test(a integer, primary key(a));
+ }
+} {0 {}}
+do_test misc1-16.2 {
+ catchsql {
+ CREATE TABLE test(a integer, primary key(a));
+ }
+} {1 {table test already exists}}
+do_test misc1-16.3 {
+ catchsql {
+ CREATE TABLE test2(a text primary key, b text, primary key(a,b));
+ }
+} {1 {table "test2" has more than one primary key}}
+do_test misc1-16.4 {
+ execsql {
+ INSERT INTO test VALUES(1);
+ SELECT rowid, a FROM test;
+ }
+} {1 1}
+do_test misc1-16.5 {
+ execsql {
+ INSERT INTO test VALUES(5);
+ SELECT rowid, a FROM test;
+ }
+} {1 1 5 5}
+do_test misc1-16.6 {
+ execsql {
+ INSERT INTO test VALUES(NULL);
+ SELECT rowid, a FROM test;
+ }
+} {1 1 5 5 6 6}
+
+ifcapable trigger&&tempdb {
+# Ticket #333: Temp triggers that modify persistent tables.
+#
+do_test misc1-17.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE RealTable(TestID INTEGER PRIMARY KEY, TestString TEXT);
+ CREATE TEMP TABLE TempTable(TestID INTEGER PRIMARY KEY, TestString TEXT);
+ CREATE TEMP TRIGGER trigTest_1 AFTER UPDATE ON TempTable BEGIN
+ INSERT INTO RealTable(TestString)
+ SELECT new.TestString FROM TempTable LIMIT 1;
+ END;
+ INSERT INTO TempTable(TestString) VALUES ('1');
+ INSERT INTO TempTable(TestString) VALUES ('2');
+ UPDATE TempTable SET TestString = TestString + 1 WHERE TestID=1 OR TestId=2;
+ COMMIT;
+ SELECT TestString FROM RealTable ORDER BY 1;
+ }
+} {2 3}
+}
+
+do_test misc1-18.1 {
+ set n [sqlite3_sleep 100]
+ expr {$n>=100}
+} {1}
+
+finish_test
diff --git a/test/misc2.test b/test/misc2.test
new file mode 100644
index 0000000..bb544c5
--- /dev/null
+++ b/test/misc2.test
@@ -0,0 +1,441 @@
+# 2003 June 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for miscellanous features that were
+# left out of other test files.
+#
+# $Id: misc2.test,v 1.28 2007/09/12 17:01:45 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# The tests in this file were written before SQLite supported recursive
+# trigger invocation, and some tests depend on that to pass. So disable
+# recursive triggers for this file.
+catchsql { pragma recursive_triggers = off }
+
+ifcapable {trigger} {
+# Test for ticket #360
+#
+do_test misc2-1.1 {
+ catchsql {
+ CREATE TABLE FOO(bar integer);
+ CREATE TRIGGER foo_insert BEFORE INSERT ON foo BEGIN
+ SELECT CASE WHEN (NOT new.bar BETWEEN 0 AND 20)
+ THEN raise(rollback, 'aiieee') END;
+ END;
+ INSERT INTO foo(bar) VALUES (1);
+ }
+} {0 {}}
+do_test misc2-1.2 {
+ catchsql {
+ INSERT INTO foo(bar) VALUES (111);
+ }
+} {1 aiieee}
+} ;# endif trigger
+
+# Make sure ROWID works on a view and a subquery. Ticket #364
+#
+do_test misc2-2.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ CREATE TABLE t2(a,b,c);
+ INSERT INTO t2 VALUES(7,8,9);
+ }
+} {}
+ifcapable subquery {
+ do_test misc2-2.2 {
+ execsql {
+ SELECT rowid, * FROM (SELECT * FROM t1, t2);
+ }
+ } {{} 1 2 3 7 8 9}
+}
+ifcapable view {
+ do_test misc2-2.3 {
+ execsql {
+ CREATE VIEW v1 AS SELECT * FROM t1, t2;
+ SELECT rowid, * FROM v1;
+ }
+ } {{} 1 2 3 7 8 9}
+} ;# ifcapable view
+
+# Ticket #2002 and #1952.
+ifcapable subquery {
+ do_test misc2-2.4 {
+ execsql2 {
+ SELECT * FROM (SELECT a, b AS 'a', c AS 'a', 4 AS 'a' FROM t1)
+ }
+ } {a 1 a:1 2 a:2 3 a:3 4}
+}
+
+# Check name binding precedence. Ticket #387
+#
+do_test misc2-3.1 {
+ catchsql {
+ SELECT t1.b+t2.b AS a, t1.a, t2.a FROM t1, t2 WHERE a==10
+ }
+} {1 {ambiguous column name: a}}
+
+# Make sure 32-bit integer overflow is handled properly in queries.
+# ticket #408
+#
+do_test misc2-4.1 {
+ execsql {
+ INSERT INTO t1 VALUES(4000000000,'a','b');
+ SELECT a FROM t1 WHERE a>1;
+ }
+} {4000000000}
+do_test misc2-4.2 {
+ execsql {
+ INSERT INTO t1 VALUES(2147483648,'b2','c2');
+ INSERT INTO t1 VALUES(2147483647,'b3','c3');
+ SELECT a FROM t1 WHERE a>2147483647;
+ }
+} {4000000000 2147483648}
+do_test misc2-4.3 {
+ execsql {
+ SELECT a FROM t1 WHERE a<2147483648;
+ }
+} {1 2147483647}
+do_test misc2-4.4 {
+ execsql {
+ SELECT a FROM t1 WHERE a<=2147483648;
+ }
+} {1 2147483648 2147483647}
+do_test misc2-4.5 {
+ execsql {
+ SELECT a FROM t1 WHERE a<10000000000;
+ }
+} {1 4000000000 2147483648 2147483647}
+do_test misc2-4.6 {
+ execsql {
+ SELECT a FROM t1 WHERE a<1000000000000 ORDER BY 1;
+ }
+} {1 2147483647 2147483648 4000000000}
+
+# There were some issues with expanding a SrcList object using a call
+# to sqliteSrcListAppend() if the SrcList had previously been duplicated
+# using a call to sqliteSrcListDup(). Ticket #416. The following test
+# makes sure the problem has been fixed.
+#
+ifcapable view {
+do_test misc2-5.1 {
+ execsql {
+ CREATE TABLE x(a,b);
+ CREATE VIEW y AS
+ SELECT x1.b AS p, x2.b AS q FROM x AS x1, x AS x2 WHERE x1.a=x2.a;
+ CREATE VIEW z AS
+ SELECT y1.p, y2.p FROM y AS y1, y AS y2 WHERE y1.q=y2.q;
+ SELECT * from z;
+ }
+} {}
+}
+
+# Make sure we can open a database with an empty filename. What this
+# does is store the database in a temporary file that is deleted when
+# the database is closed. Ticket #432.
+#
+do_test misc2-6.1 {
+ db close
+ sqlite3 db {}
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t1;
+ }
+} {1 2}
+
+# Make sure we get an error message (not a segfault) on an attempt to
+# update a table from within the callback of a select on that same
+# table.
+#
+# 2006-08-16: This has changed. It is now permitted to update
+# the table being SELECTed from within the callback of the query.
+#
+ifcapable tclvar {
+ do_test misc2-7.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ SELECT * FROM t1;
+ }
+ } {1 2 3}
+ do_test misc2-7.2 {
+ set rc [catch {
+ db eval {SELECT rowid FROM t1} {} {
+ db eval "DELETE FROM t1 WHERE rowid=$rowid"
+ }
+ } msg]
+ lappend rc $msg
+ } {0 {}}
+ do_test misc2-7.3 {
+ execsql {SELECT * FROM t1}
+ } {}
+ do_test misc2-7.4 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ }
+ db eval {SELECT rowid, x FROM t1} {
+ if {$x & 1} {
+ db eval {DELETE FROM t1 WHERE rowid=$rowid}
+ }
+ }
+ execsql {SELECT * FROM t1}
+ } {2 4}
+ do_test misc2-7.5 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ }
+ db eval {SELECT rowid, x FROM t1} {
+ if {$x & 1} {
+ db eval {DELETE FROM t1 WHERE rowid=$rowid+1}
+ }
+ }
+ execsql {SELECT * FROM t1}
+ } {1 3}
+ do_test misc2-7.6 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ }
+ db eval {SELECT rowid, x FROM t1} {
+ if {$x & 1} {
+ db eval {DELETE FROM t1}
+ }
+ }
+ execsql {SELECT * FROM t1}
+ } {}
+ do_test misc2-7.7 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ }
+ db eval {SELECT rowid, x FROM t1} {
+ if {$x & 1} {
+ db eval {UPDATE t1 SET x=x+100 WHERE rowid=$rowid}
+ }
+ }
+ execsql {SELECT * FROM t1}
+ } {101 2 103 4}
+ do_test misc2-7.8 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1);
+ }
+ db eval {SELECT rowid, x FROM t1} {
+ if {$x<10} {
+ db eval {INSERT INTO t1 VALUES($x+1)}
+ }
+ }
+ execsql {SELECT * FROM t1}
+ } {1 2 3 4 5 6 7 8 9 10}
+
+ # Repeat the tests 7.1 through 7.8 about but this time do the SELECTs
+ # in reverse order so that we exercise the sqlite3BtreePrev() routine
+ # instead of sqlite3BtreeNext()
+ #
+ do_test misc2-7.11 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ SELECT * FROM t1;
+ }
+ } {1 2 3}
+ do_test misc2-7.12 {
+ set rc [catch {
+ db eval {SELECT rowid FROM t1 ORDER BY rowid DESC} {} {
+ db eval "DELETE FROM t1 WHERE rowid=$rowid"
+ }
+ } msg]
+ lappend rc $msg
+ } {0 {}}
+ do_test misc2-7.13 {
+ execsql {SELECT * FROM t1}
+ } {}
+ do_test misc2-7.14 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ }
+ db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
+ if {$x & 1} {
+ db eval {DELETE FROM t1 WHERE rowid=$rowid}
+ }
+ }
+ execsql {SELECT * FROM t1}
+ } {2 4}
+ do_test misc2-7.15 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ }
+ db eval {SELECT rowid, x FROM t1} {
+ if {$x & 1} {
+ db eval {DELETE FROM t1 WHERE rowid=$rowid+1}
+ }
+ }
+ execsql {SELECT * FROM t1}
+ } {1 3}
+ do_test misc2-7.16 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ }
+ db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
+ if {$x & 1} {
+ db eval {DELETE FROM t1}
+ }
+ }
+ execsql {SELECT * FROM t1}
+ } {}
+ do_test misc2-7.17 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ }
+ db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
+ if {$x & 1} {
+ db eval {UPDATE t1 SET x=x+100 WHERE rowid=$rowid}
+ }
+ }
+ execsql {SELECT * FROM t1}
+ } {101 2 103 4}
+ do_test misc2-7.18 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1(rowid,x) VALUES(10,10);
+ }
+ db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {
+ if {$x>1} {
+ db eval {INSERT INTO t1(rowid,x) VALUES($x-1,$x-1)}
+ }
+ }
+ execsql {SELECT * FROM t1}
+ } {1 2 3 4 5 6 7 8 9 10}
+}
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+catchsql { pragma recursive_triggers = off }
+
+# Ticket #453. If the SQL ended with "-", the tokenizer was calling that
+# an incomplete token, which caused problem. The solution was to just call
+# it a minus sign.
+#
+do_test misc2-8.1 {
+ catchsql {-}
+} {1 {near "-": syntax error}}
+
+# Ticket #513. Make sure the VDBE stack does not grow on a 3-way join.
+#
+ifcapable tempdb {
+ do_test misc2-9.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE counts(n INTEGER PRIMARY KEY);
+ INSERT INTO counts VALUES(0);
+ INSERT INTO counts VALUES(1);
+ INSERT INTO counts SELECT n+2 FROM counts;
+ INSERT INTO counts SELECT n+4 FROM counts;
+ INSERT INTO counts SELECT n+8 FROM counts;
+ COMMIT;
+
+ CREATE TEMP TABLE x AS
+ SELECT dim1.n, dim2.n, dim3.n
+ FROM counts AS dim1, counts AS dim2, counts AS dim3
+ WHERE dim1.n<10 AND dim2.n<10 AND dim3.n<10;
+
+ SELECT count(*) FROM x;
+ }
+ } {1000}
+ do_test misc2-9.2 {
+ execsql {
+ DROP TABLE x;
+ CREATE TEMP TABLE x AS
+ SELECT dim1.n, dim2.n, dim3.n
+ FROM counts AS dim1, counts AS dim2, counts AS dim3
+ WHERE dim1.n>=6 AND dim2.n>=6 AND dim3.n>=6;
+
+ SELECT count(*) FROM x;
+ }
+ } {1000}
+ do_test misc2-9.3 {
+ execsql {
+ DROP TABLE x;
+ CREATE TEMP TABLE x AS
+ SELECT dim1.n, dim2.n, dim3.n, dim4.n
+ FROM counts AS dim1, counts AS dim2, counts AS dim3, counts AS dim4
+ WHERE dim1.n<5 AND dim2.n<5 AND dim3.n<5 AND dim4.n<5;
+
+ SELECT count(*) FROM x;
+ }
+ } [expr 5*5*5*5]
+}
+
+# Ticket #1229. Sometimes when a "NEW.X" appears in a SELECT without
+# a FROM clause deep within a trigger, the code generator is unable to
+# trace the NEW.X back to an original table and thus figure out its
+# declared datatype.
+#
+# The SQL code below was causing a segfault.
+#
+ifcapable subquery&&trigger {
+ do_test misc2-10.1 {
+ execsql {
+ CREATE TABLE t1229(x);
+ CREATE TRIGGER r1229 BEFORE INSERT ON t1229 BEGIN
+ INSERT INTO t1229 SELECT y FROM (SELECT new.x y);
+ END;
+ INSERT INTO t1229 VALUES(1);
+ }
+ } {}
+}
+
+finish_test
diff --git a/test/misc3.test b/test/misc3.test
new file mode 100644
index 0000000..81a8266
--- /dev/null
+++ b/test/misc3.test
@@ -0,0 +1,355 @@
+# 2003 December 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for miscellanous features that were
+# left out of other test files.
+#
+# $Id: misc3.test,v 1.20 2009/05/06 00:49:01 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {integrityck} {
+ # Ticket #529. Make sure an ABORT does not damage the in-memory cache
+ # that will be used by subsequent statements in the same transaction.
+ #
+ do_test misc3-1.1 {
+ execsql {
+ CREATE TABLE t1(a UNIQUE,b);
+ INSERT INTO t1
+ VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_');
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ UPDATE t1 SET b=b||b;
+ INSERT INTO t1 VALUES(2,'x');
+ UPDATE t1 SET b=substr(b,1,500);
+ BEGIN;
+ }
+ catchsql {UPDATE t1 SET a=CASE a WHEN 2 THEN 1 ELSE a END, b='y';}
+ execsql {
+ CREATE TABLE t2(x,y);
+ COMMIT;
+ PRAGMA integrity_check;
+ }
+ } ok
+}
+ifcapable {integrityck} {
+ do_test misc3-1.2 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ }
+ ifcapable {vacuum} {execsql VACUUM}
+ execsql {
+ CREATE TABLE t1(a UNIQUE,b);
+ INSERT INTO t1
+ VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_');
+ INSERT INTO t1 SELECT a+1, b||b FROM t1;
+ INSERT INTO t1 SELECT a+2, b||b FROM t1;
+ INSERT INTO t1 SELECT a+4, b FROM t1;
+ INSERT INTO t1 SELECT a+8, b FROM t1;
+ INSERT INTO t1 SELECT a+16, b FROM t1;
+ INSERT INTO t1 SELECT a+32, b FROM t1;
+ INSERT INTO t1 SELECT a+64, b FROM t1;
+ BEGIN;
+ }
+ catchsql {UPDATE t1 SET a=CASE a WHEN 128 THEN 127 ELSE a END, b='';}
+ execsql {
+ INSERT INTO t1 VALUES(200,'hello out there');
+ COMMIT;
+ PRAGMA integrity_check;
+ }
+ } ok
+}
+
+# Tests of the sqliteAtoF() function in util.c
+#
+do_test misc3-2.1 {
+ execsql {SELECT 2e-25*0.5e25}
+} 1.0
+do_test misc3-2.2 {
+ execsql {SELECT 2.0e-25*000000.500000000000000000000000000000e+00025}
+} 1.0
+do_test misc3-2.3 {
+ execsql {SELECT 000000000002e-0000000025*0.5e25}
+} 1.0
+do_test misc3-2.4 {
+ execsql {SELECT 2e-25*0.5e250}
+} 1e+225
+do_test misc3-2.5 {
+ execsql {SELECT 2.0e-250*0.5e25}
+} 1e-225
+do_test misc3-2.6 {
+ execsql {SELECT '-2.0e-127' * '-0.5e27'}
+} 1e-100
+do_test misc3-2.7 {
+ execsql {SELECT '+2.0e-127' * '-0.5e27'}
+} -1e-100
+do_test misc3-2.8 {
+ execsql {SELECT 2.0e-27 * '+0.5e+127'}
+} 1e+100
+do_test misc3-2.9 {
+ execsql {SELECT 2.0e-27 * '+0.000005e+132'}
+} 1e+100
+
+# Ticket #522. Make sure integer overflow is handled properly in
+# indices.
+#
+integrity_check misc3-3.1
+do_test misc3-3.2 {
+ execsql {
+ CREATE TABLE t2(a INT UNIQUE);
+ }
+} {}
+integrity_check misc3-3.2.1
+do_test misc3-3.3 {
+ execsql {
+ INSERT INTO t2 VALUES(2147483648);
+ }
+} {}
+integrity_check misc3-3.3.1
+do_test misc3-3.4 {
+ execsql {
+ INSERT INTO t2 VALUES(-2147483649);
+ }
+} {}
+integrity_check misc3-3.4.1
+do_test misc3-3.5 {
+ execsql {
+ INSERT INTO t2 VALUES(+2147483649);
+ }
+} {}
+integrity_check misc3-3.5.1
+do_test misc3-3.6 {
+ execsql {
+ INSERT INTO t2 VALUES(+2147483647);
+ INSERT INTO t2 VALUES(-2147483648);
+ INSERT INTO t2 VALUES(-2147483647);
+ INSERT INTO t2 VALUES(2147483646);
+ SELECT * FROM t2 ORDER BY a;
+ }
+} {-2147483649 -2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}
+do_test misc3-3.7 {
+ execsql {
+ SELECT * FROM t2 WHERE a>=-2147483648 ORDER BY a;
+ }
+} {-2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}
+do_test misc3-3.8 {
+ execsql {
+ SELECT * FROM t2 WHERE a>-2147483648 ORDER BY a;
+ }
+} {-2147483647 2147483646 2147483647 2147483648 2147483649}
+do_test misc3-3.9 {
+ execsql {
+ SELECT * FROM t2 WHERE a>-2147483649 ORDER BY a;
+ }
+} {-2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}
+do_test misc3-3.10 {
+ execsql {
+ SELECT * FROM t2 WHERE a>=0 AND a<2147483649 ORDER BY a DESC;
+ }
+} {2147483648 2147483647 2147483646}
+do_test misc3-3.11 {
+ execsql {
+ SELECT * FROM t2 WHERE a>=0 AND a<=2147483648 ORDER BY a DESC;
+ }
+} {2147483648 2147483647 2147483646}
+do_test misc3-3.12 {
+ execsql {
+ SELECT * FROM t2 WHERE a>=0 AND a<2147483648 ORDER BY a DESC;
+ }
+} {2147483647 2147483646}
+do_test misc3-3.13 {
+ execsql {
+ SELECT * FROM t2 WHERE a>=0 AND a<=2147483647 ORDER BY a DESC;
+ }
+} {2147483647 2147483646}
+do_test misc3-3.14 {
+ execsql {
+ SELECT * FROM t2 WHERE a>=0 AND a<2147483647 ORDER BY a DESC;
+ }
+} {2147483646}
+
+# Ticket #565. A stack overflow is occurring when the subquery to the
+# right of an IN operator contains many NULLs
+#
+do_test misc3-4.1 {
+ execsql {
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t3(b) VALUES('abc');
+ INSERT INTO t3(b) VALUES('xyz');
+ INSERT INTO t3(b) VALUES(NULL);
+ INSERT INTO t3(b) VALUES(NULL);
+ INSERT INTO t3(b) SELECT b||'d' FROM t3;
+ INSERT INTO t3(b) SELECT b||'e' FROM t3;
+ INSERT INTO t3(b) SELECT b||'f' FROM t3;
+ INSERT INTO t3(b) SELECT b||'g' FROM t3;
+ INSERT INTO t3(b) SELECT b||'h' FROM t3;
+ SELECT count(a), count(b) FROM t3;
+ }
+} {128 64}
+ifcapable subquery {
+do_test misc3-4.2 {
+ execsql {
+ SELECT count(a) FROM t3 WHERE b IN (SELECT b FROM t3);
+ }
+ } {64}
+ do_test misc3-4.3 {
+ execsql {
+ SELECT count(a) FROM t3 WHERE b IN (SELECT b FROM t3 ORDER BY a+1);
+ }
+ } {64}
+}
+
+# Ticket #601: Putting a left join inside "SELECT * FROM (<join-here>)"
+# gives different results that if the outer "SELECT * FROM ..." is omitted.
+#
+ifcapable subquery {
+ do_test misc3-5.1 {
+ execsql {
+ CREATE TABLE x1 (b, c);
+ INSERT INTO x1 VALUES('dog',3);
+ INSERT INTO x1 VALUES('cat',1);
+ INSERT INTO x1 VALUES('dog',4);
+ CREATE TABLE x2 (c, e);
+ INSERT INTO x2 VALUES(1,'one');
+ INSERT INTO x2 VALUES(2,'two');
+ INSERT INTO x2 VALUES(3,'three');
+ INSERT INTO x2 VALUES(4,'four');
+ SELECT x2.c AS c, e, b FROM x2 LEFT JOIN
+ (SELECT b, max(c)+0 AS c FROM x1 GROUP BY b)
+ USING(c);
+ }
+ } {1 one cat 2 two {} 3 three {} 4 four dog}
+ do_test misc3-5.2 {
+ execsql {
+ SELECT * FROM (
+ SELECT x2.c AS c, e, b FROM x2 LEFT JOIN
+ (SELECT b, max(c)+0 AS c FROM x1 GROUP BY b)
+ USING(c)
+ );
+ }
+ } {1 one cat 2 two {} 3 three {} 4 four dog}
+}
+
+ifcapable {explain} {
+ # Ticket #626: make sure EXPLAIN prevents BEGIN and COMMIT from working.
+ #
+ do_test misc3-6.1 {
+ execsql {EXPLAIN BEGIN}
+ catchsql {BEGIN}
+ } {0 {}}
+ do_test misc3-6.2 {
+ execsql {EXPLAIN COMMIT}
+ catchsql {COMMIT}
+ } {0 {}}
+ do_test misc3-6.3 {
+ execsql {BEGIN; EXPLAIN ROLLBACK}
+ catchsql {ROLLBACK}
+ } {0 {}}
+
+ # Do some additional EXPLAIN operations to exercise the displayP4 logic.
+ do_test misc3-6.10 {
+ set x [execsql {
+ CREATE TABLE ex1(
+ a INTEGER DEFAULT 54321,
+ b TEXT DEFAULT "hello",
+ c REAL DEFAULT 3.1415926
+ );
+ CREATE UNIQUE INDEX ex1i1 ON ex1(a);
+ EXPLAIN REINDEX;
+ }]
+ ifcapable mergesort {
+ regexp { SorterCompare \d+ \d+ \d+ } $x
+ } else {
+ regexp { IsUnique \d+ \d+ \d+ \d+ } $x
+ }
+ } {1}
+ if {[regexp {16} [db one {PRAGMA encoding}]]} {
+ do_test misc3-6.11-utf16 {
+ set x [execsql {
+ EXPLAIN SELECT a+123456789012, b*4.5678, c FROM ex1 ORDER BY +a, b DESC
+ }]
+ set y [regexp { 123456789012 } $x]
+ lappend y [regexp { 4.5678 } $x]
+ lappend y [regexp {,-BINARY} $x]
+ } {1 1 1}
+ } else {
+ do_test misc3-6.11-utf8 {
+ set x [execsql {
+ EXPLAIN SELECT a+123456789012, b*4.5678, c FROM ex1 ORDER BY +a, b DESC
+ }]
+ set y [regexp { 123456789012 } $x]
+ lappend y [regexp { 4.5678 } $x]
+ lappend y [regexp { hello } $x]
+ lappend y [regexp {,-BINARY} $x]
+ } {1 1 1 1}
+ }
+}
+
+ifcapable {trigger} {
+# Ticket #640: vdbe stack overflow with a LIMIT clause on a SELECT inside
+# of a trigger.
+#
+do_test misc3-7.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE y1(a);
+ CREATE TABLE y2(b);
+ CREATE TABLE y3(c);
+ CREATE TRIGGER r1 AFTER DELETE ON y1 FOR EACH ROW BEGIN
+ INSERT INTO y3(c) SELECT b FROM y2 ORDER BY b LIMIT 1;
+ END;
+ INSERT INTO y1 VALUES(1);
+ INSERT INTO y1 VALUES(2);
+ INSERT INTO y1 SELECT a+2 FROM y1;
+ INSERT INTO y1 SELECT a+4 FROM y1;
+ INSERT INTO y1 SELECT a+8 FROM y1;
+ INSERT INTO y1 SELECT a+16 FROM y1;
+ INSERT INTO y2 SELECT a FROM y1;
+ COMMIT;
+ SELECT count(*) FROM y1;
+ }
+} 32
+do_test misc3-7.2 {
+ execsql {
+ DELETE FROM y1;
+ SELECT count(*) FROM y1;
+ }
+} 0
+do_test misc3-7.3 {
+ execsql {
+ SELECT count(*) FROM y3;
+ }
+} 32
+} ;# endif trigger
+
+# Ticket #668: VDBE stack overflow occurs when the left-hand side
+# of an IN expression is NULL and the result is used as an integer, not
+# as a jump.
+#
+ifcapable subquery {
+ do_test misc-8.1 {
+ execsql {
+ SELECT count(CASE WHEN b IN ('abc','xyz') THEN 'x' END) FROM t3
+ }
+ } {2}
+ do_test misc-8.2 {
+ execsql {
+ SELECT count(*) FROM t3 WHERE 1+(b IN ('abc','xyz'))==2
+ }
+ } {2}
+}
+
+finish_test
diff --git a/test/misc4.test b/test/misc4.test
new file mode 100644
index 0000000..59c1d11
--- /dev/null
+++ b/test/misc4.test
@@ -0,0 +1,211 @@
+# 2004 Jun 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for miscellanous features that were
+# left out of other test files.
+#
+# $Id: misc4.test,v 1.23 2007/12/08 18:01:31 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Prepare a statement that will create a temporary table. Then do
+# a rollback. Then try to execute the prepared statement.
+#
+do_test misc4-1.1 {
+ set DB [sqlite3_connection_pointer db]
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ }
+} {}
+
+ifcapable tempdb {
+ do_test misc4-1.2 {
+ set sql {CREATE TEMP TABLE t2 AS SELECT * FROM t1}
+ set stmt [sqlite3_prepare $DB $sql -1 TAIL]
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(a,b,c);
+ INSERT INTO t1 SELECT * FROM t1;
+ ROLLBACK;
+ }
+ } {}
+
+ # Because the previous transaction included a DDL statement and
+ # was rolled back, statement $stmt was marked as expired. Executing it
+ # now returns SQLITE_SCHEMA.
+ do_test misc4-1.2.1 {
+ list [sqlite3_step $stmt] [sqlite3_finalize $stmt]
+ } {SQLITE_ERROR SQLITE_SCHEMA}
+ do_test misc4-1.2.2 {
+ set stmt [sqlite3_prepare $DB $sql -1 TAIL]
+ set TAIL
+ } {}
+
+ do_test misc4-1.3 {
+ sqlite3_step $stmt
+ } SQLITE_DONE
+ do_test misc4-1.4 {
+ execsql {
+ SELECT * FROM temp.t2;
+ }
+ } {1}
+
+ # Drop the temporary table, then rerun the prepared statement to
+ # recreate it again. This recreates ticket #807.
+ #
+ do_test misc4-1.5 {
+ execsql {DROP TABLE t2}
+ sqlite3_reset $stmt
+ sqlite3_step $stmt
+ } {SQLITE_ERROR}
+ do_test misc4-1.6 {
+ sqlite3_finalize $stmt
+ } {SQLITE_SCHEMA}
+}
+
+# Prepare but do not execute various CREATE statements. Then before
+# those statements are executed, try to use the tables, indices, views,
+# are triggers that were created.
+#
+do_test misc4-2.1 {
+ set stmt [sqlite3_prepare $DB {CREATE TABLE t3(x);} -1 TAIL]
+ catchsql {
+ INSERT INTO t3 VALUES(1);
+ }
+} {1 {no such table: t3}}
+do_test misc4-2.2 {
+ sqlite3_step $stmt
+} SQLITE_DONE
+do_test misc4-2.3 {
+ sqlite3_finalize $stmt
+} SQLITE_OK
+do_test misc4-2.4 {
+ catchsql {
+ INSERT INTO t3 VALUES(1);
+ }
+} {0 {}}
+
+# Ticket #966
+#
+do_test misc4-3.1 {
+ execsql {
+ CREATE TABLE Table1(ID integer primary key, Value TEXT);
+ INSERT INTO Table1 VALUES(1, 'x');
+ CREATE TABLE Table2(ID integer NOT NULL, Value TEXT);
+ INSERT INTO Table2 VALUES(1, 'z');
+ INSERT INTO Table2 VALUES (1, 'a');
+ }
+ catchsql {
+ SELECT ID, max(Value) FROM Table2 GROUP BY 1, 2 ORDER BY 1, 2;
+ }
+} {1 {aggregate functions are not allowed in the GROUP BY clause}}
+ifcapable compound {
+ do_test misc4-3.2 {
+ execsql {
+ SELECT ID, Value FROM Table1
+ UNION SELECT ID, max(Value) FROM Table2 GROUP BY 1
+ ORDER BY 1, 2;
+ }
+ } {1 x 1 z}
+ do_test misc4-3.3 {
+ catchsql {
+ SELECT ID, Value FROM Table1
+ UNION SELECT ID, max(Value) FROM Table2 GROUP BY 1, 2
+ ORDER BY 1, 2;
+ }
+ } {1 {aggregate functions are not allowed in the GROUP BY clause}}
+ do_test misc4-3.4 {
+ catchsql {
+ SELECT ID, max(Value) FROM Table2 GROUP BY 1, 2
+ UNION SELECT ID, Value FROM Table1
+ ORDER BY 1, 2;
+ }
+ } {1 {aggregate functions are not allowed in the GROUP BY clause}}
+} ;# ifcapable compound
+
+# Ticket #1047. Make sure column types are preserved in subqueries.
+#
+ifcapable subquery {
+ do_test misc4-4.1 {
+ execsql {
+ create table a(key varchar, data varchar);
+ create table b(key varchar, period integer);
+ insert into a values('01','data01');
+ insert into a values('+1','data+1');
+
+ insert into b values ('01',1);
+ insert into b values ('01',2);
+ insert into b values ('+1',3);
+ insert into b values ('+1',4);
+
+ select a.*, x.*
+ from a, (select key,sum(period) from b group by key) as x
+ where a.key=x.key order by 1 desc;
+ }
+ } {01 data01 01 3 +1 data+1 +1 7}
+
+ # This test case tests the same property as misc4-4.1, but it is
+ # a bit smaller which makes it easier to work with while debugging.
+ do_test misc4-4.2 {
+ execsql {
+ CREATE TABLE ab(a TEXT, b TEXT);
+ INSERT INTO ab VALUES('01', '1');
+ }
+ execsql {
+ select * from ab, (select b from ab) as x where x.b = ab.a;
+ }
+ } {}
+}
+
+
+# Ticket #1036. When creating tables from a SELECT on a view, use the
+# short names of columns.
+#
+ifcapable view {
+ do_test misc4-5.1 {
+ execsql {
+ create table t4(a,b);
+ create table t5(a,c);
+ insert into t4 values (1,2);
+ insert into t5 values (1,3);
+ create view myview as select t4.a a from t4 inner join t5 on t4.a=t5.a;
+ create table problem as select * from myview;
+ }
+ execsql2 {
+ select * FROM problem;
+ }
+ } {a 1}
+ do_test misc4-5.2 {
+ execsql2 {
+ create table t6 as select * from t4, t5;
+ select * from t6;
+ }
+ } {a 1 b 2 a:1 1 c 3}
+}
+
+# Ticket #1086
+do_test misc4-6.1 {
+ execsql {
+ CREATE TABLE abc(a);
+ INSERT INTO abc VALUES(1);
+ CREATE TABLE def(d, e, f, PRIMARY KEY(d, e));
+ }
+} {}
+do_test misc4-6.2 {
+ execsql {
+ SELECT a FROM abc LEFT JOIN def ON (abc.a=def.d);
+ }
+} {1}
+
+finish_test
diff --git a/test/misc5.test b/test/misc5.test
new file mode 100644
index 0000000..14ba44e
--- /dev/null
+++ b/test/misc5.test
@@ -0,0 +1,1874 @@
+# 2005 Mar 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for miscellanous features that were
+# left out of other test files.
+#
+# $Id: misc5.test,v 1.22 2008/07/29 10:26:45 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build records using the MakeRecord opcode such that the size of the
+# header is at the transition point in the size of a varint.
+#
+# This test causes an assertion failure or a buffer overrun in version
+# 3.1.5 and earlier.
+#
+for {set i 120} {$i<140} {incr i} {
+ do_test misc5-1.$i {
+ catchsql {DROP TABLE t1}
+ set sql1 {CREATE TABLE t1}
+ set sql2 {INSERT INTO t1 VALUES}
+ set sep (
+ for {set j 0} {$j<$i} {incr j} {
+ append sql1 ${sep}a$j
+ append sql2 ${sep}$j
+ set sep ,
+ }
+ append sql1 {);}
+ append sql2 {);}
+ execsql $sql1$sql2
+ } {}
+}
+
+# Make sure large integers are stored correctly.
+#
+ifcapable conflict {
+ do_test misc5-2.1 {
+ execsql {
+ create table t2(x unique);
+ insert into t2 values(1);
+ insert or ignore into t2 select x*2 from t2;
+ insert or ignore into t2 select x*4 from t2;
+ insert or ignore into t2 select x*16 from t2;
+ insert or ignore into t2 select x*256 from t2;
+ insert or ignore into t2 select x*65536 from t2;
+ insert or ignore into t2 select x*2147483648 from t2;
+ insert or ignore into t2 select x-1 from t2;
+ insert or ignore into t2 select x+1 from t2;
+ insert or ignore into t2 select -x from t2;
+ select count(*) from t2;
+ }
+ } 371
+} else {
+ do_test misc5-2.1 {
+ execsql {
+ BEGIN;
+ create table t2(x unique);
+ create table t2_temp(x);
+ insert into t2_temp values(1);
+ insert into t2_temp select x*2 from t2_temp;
+ insert into t2_temp select x*4 from t2_temp;
+ insert into t2_temp select x*16 from t2_temp;
+ insert into t2_temp select x*256 from t2_temp;
+ insert into t2_temp select x*65536 from t2_temp;
+ insert into t2_temp select x*2147483648 from t2_temp;
+ insert into t2_temp select x-1 from t2_temp;
+ insert into t2_temp select x+1 from t2_temp;
+ insert into t2_temp select -x from t2_temp;
+ INSERT INTO t2 SELECT DISTINCT(x) FROM t2_temp;
+ DROP TABLE t2_temp;
+ COMMIT;
+ select count(*) from t2;
+ }
+ } 371
+}
+do_test misc5-2.2 {
+ execsql {
+ select x from t2 order by x;
+ }
+} \
+"-4611686018427387905\
+-4611686018427387904\
+-4611686018427387903\
+-2305843009213693953\
+-2305843009213693952\
+-2305843009213693951\
+-1152921504606846977\
+-1152921504606846976\
+-1152921504606846975\
+-576460752303423489\
+-576460752303423488\
+-576460752303423487\
+-288230376151711745\
+-288230376151711744\
+-288230376151711743\
+-144115188075855873\
+-144115188075855872\
+-144115188075855871\
+-72057594037927937\
+-72057594037927936\
+-72057594037927935\
+-36028797018963969\
+-36028797018963968\
+-36028797018963967\
+-18014398509481985\
+-18014398509481984\
+-18014398509481983\
+-9007199254740993\
+-9007199254740992\
+-9007199254740991\
+-4503599627370497\
+-4503599627370496\
+-4503599627370495\
+-2251799813685249\
+-2251799813685248\
+-2251799813685247\
+-1125899906842625\
+-1125899906842624\
+-1125899906842623\
+-562949953421313\
+-562949953421312\
+-562949953421311\
+-281474976710657\
+-281474976710656\
+-281474976710655\
+-140737488355329\
+-140737488355328\
+-140737488355327\
+-70368744177665\
+-70368744177664\
+-70368744177663\
+-35184372088833\
+-35184372088832\
+-35184372088831\
+-17592186044417\
+-17592186044416\
+-17592186044415\
+-8796093022209\
+-8796093022208\
+-8796093022207\
+-4398046511105\
+-4398046511104\
+-4398046511103\
+-2199023255553\
+-2199023255552\
+-2199023255551\
+-1099511627777\
+-1099511627776\
+-1099511627775\
+-549755813889\
+-549755813888\
+-549755813887\
+-274877906945\
+-274877906944\
+-274877906943\
+-137438953473\
+-137438953472\
+-137438953471\
+-68719476737\
+-68719476736\
+-68719476735\
+-34359738369\
+-34359738368\
+-34359738367\
+-17179869185\
+-17179869184\
+-17179869183\
+-8589934593\
+-8589934592\
+-8589934591\
+-4294967297\
+-4294967296\
+-4294967295\
+-2147483649\
+-2147483648\
+-2147483647\
+-1073741825\
+-1073741824\
+-1073741823\
+-536870913\
+-536870912\
+-536870911\
+-268435457\
+-268435456\
+-268435455\
+-134217729\
+-134217728\
+-134217727\
+-67108865\
+-67108864\
+-67108863\
+-33554433\
+-33554432\
+-33554431\
+-16777217\
+-16777216\
+-16777215\
+-8388609\
+-8388608\
+-8388607\
+-4194305\
+-4194304\
+-4194303\
+-2097153\
+-2097152\
+-2097151\
+-1048577\
+-1048576\
+-1048575\
+-524289\
+-524288\
+-524287\
+-262145\
+-262144\
+-262143\
+-131073\
+-131072\
+-131071\
+-65537\
+-65536\
+-65535\
+-32769\
+-32768\
+-32767\
+-16385\
+-16384\
+-16383\
+-8193\
+-8192\
+-8191\
+-4097\
+-4096\
+-4095\
+-2049\
+-2048\
+-2047\
+-1025\
+-1024\
+-1023\
+-513\
+-512\
+-511\
+-257\
+-256\
+-255\
+-129\
+-128\
+-127\
+-65\
+-64\
+-63\
+-33\
+-32\
+-31\
+-17\
+-16\
+-15\
+-9\
+-8\
+-7\
+-5\
+-4\
+-3\
+-2\
+-1\
+0\
+1\
+2\
+3\
+4\
+5\
+7\
+8\
+9\
+15\
+16\
+17\
+31\
+32\
+33\
+63\
+64\
+65\
+127\
+128\
+129\
+255\
+256\
+257\
+511\
+512\
+513\
+1023\
+1024\
+1025\
+2047\
+2048\
+2049\
+4095\
+4096\
+4097\
+8191\
+8192\
+8193\
+16383\
+16384\
+16385\
+32767\
+32768\
+32769\
+65535\
+65536\
+65537\
+131071\
+131072\
+131073\
+262143\
+262144\
+262145\
+524287\
+524288\
+524289\
+1048575\
+1048576\
+1048577\
+2097151\
+2097152\
+2097153\
+4194303\
+4194304\
+4194305\
+8388607\
+8388608\
+8388609\
+16777215\
+16777216\
+16777217\
+33554431\
+33554432\
+33554433\
+67108863\
+67108864\
+67108865\
+134217727\
+134217728\
+134217729\
+268435455\
+268435456\
+268435457\
+536870911\
+536870912\
+536870913\
+1073741823\
+1073741824\
+1073741825\
+2147483647\
+2147483648\
+2147483649\
+4294967295\
+4294967296\
+4294967297\
+8589934591\
+8589934592\
+8589934593\
+17179869183\
+17179869184\
+17179869185\
+34359738367\
+34359738368\
+34359738369\
+68719476735\
+68719476736\
+68719476737\
+137438953471\
+137438953472\
+137438953473\
+274877906943\
+274877906944\
+274877906945\
+549755813887\
+549755813888\
+549755813889\
+1099511627775\
+1099511627776\
+1099511627777\
+2199023255551\
+2199023255552\
+2199023255553\
+4398046511103\
+4398046511104\
+4398046511105\
+8796093022207\
+8796093022208\
+8796093022209\
+17592186044415\
+17592186044416\
+17592186044417\
+35184372088831\
+35184372088832\
+35184372088833\
+70368744177663\
+70368744177664\
+70368744177665\
+140737488355327\
+140737488355328\
+140737488355329\
+281474976710655\
+281474976710656\
+281474976710657\
+562949953421311\
+562949953421312\
+562949953421313\
+1125899906842623\
+1125899906842624\
+1125899906842625\
+2251799813685247\
+2251799813685248\
+2251799813685249\
+4503599627370495\
+4503599627370496\
+4503599627370497\
+9007199254740991\
+9007199254740992\
+9007199254740993\
+18014398509481983\
+18014398509481984\
+18014398509481985\
+36028797018963967\
+36028797018963968\
+36028797018963969\
+72057594037927935\
+72057594037927936\
+72057594037927937\
+144115188075855871\
+144115188075855872\
+144115188075855873\
+288230376151711743\
+288230376151711744\
+288230376151711745\
+576460752303423487\
+576460752303423488\
+576460752303423489\
+1152921504606846975\
+1152921504606846976\
+1152921504606846977\
+2305843009213693951\
+2305843009213693952\
+2305843009213693953\
+4611686018427387903\
+4611686018427387904\
+4611686018427387905"
+
+# Ticket #1210. Do proper reference counting of Table structures
+# so that deeply nested SELECT statements can be flattened correctly.
+#
+ifcapable subquery {
+ do_test misc5-3.1 {
+ execsql {
+ CREATE TABLE songs(songid, artist, timesplayed);
+ INSERT INTO songs VALUES(1,'one',1);
+ INSERT INTO songs VALUES(2,'one',2);
+ INSERT INTO songs VALUES(3,'two',3);
+ INSERT INTO songs VALUES(4,'three',5);
+ INSERT INTO songs VALUES(5,'one',7);
+ INSERT INTO songs VALUES(6,'two',11);
+ SELECT DISTINCT artist
+ FROM (
+ SELECT DISTINCT artist
+ FROM songs
+ WHERE songid IN (
+ SELECT songid
+ FROM songs
+ WHERE LOWER(artist) = (
+ -- This sub-query is indeterminate. Because there is no ORDER BY,
+ -- it may return 'one', 'two' or 'three'. Because of this, the
+ -- outermost parent query may correctly return any of 'one', 'two'
+ -- or 'three' as well.
+ SELECT DISTINCT LOWER(artist)
+ FROM (
+ -- This sub-query returns the table:
+ --
+ -- two 14
+ -- one 10
+ -- three 5
+ --
+ SELECT DISTINCT artist,sum(timesplayed) AS total
+ FROM songs
+ GROUP BY LOWER(artist)
+ ORDER BY total DESC
+ LIMIT 10
+ )
+ WHERE artist <> ''
+ )
+ )
+ )
+ ORDER BY LOWER(artist) ASC;
+ }
+ } {two}
+}
+
+# Ticket #1370. Do not overwrite small files (less than 1024 bytes)
+# when trying to open them as a database.
+#
+if {[permutation] == ""} {
+ do_test misc5-4.1 {
+ db close
+ forcedelete test.db
+ set fd [open test.db w]
+ puts $fd "This is not really a database"
+ close $fd
+ sqlite3 db test.db
+ catchsql {
+ CREATE TABLE t1(a,b,c);
+ }
+ } {1 {file is encrypted or is not a database}}
+}
+
+# Ticket #1371. Allow floating point numbers of the form .N or N.
+#
+do_test misc5-5.1 {
+ execsql {SELECT .1 }
+} 0.1
+do_test misc5-5.2 {
+ execsql {SELECT 2. }
+} 2.0
+do_test misc5-5.3 {
+ execsql {SELECT 3.e0 }
+} 3.0
+do_test misc5-5.4 {
+ execsql {SELECT .4e+1}
+} 4.0
+
+# Ticket #1582. Ensure that an unknown table in a LIMIT clause applied to
+# a UNION ALL query causes an error, not a crash.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+ifcapable subquery&&compound {
+ do_test misc5-6.1 {
+ catchsql {
+ SELECT * FROM sqlite_master
+ UNION ALL
+ SELECT * FROM sqlite_master
+ LIMIT (SELECT count(*) FROM blah);
+ }
+ } {1 {no such table: blah}}
+ do_test misc5-6.2 {
+ execsql {
+ CREATE TABLE logs(msg TEXT, timestamp INTEGER, dbtime TEXT);
+ }
+ catchsql {
+ SELECT * FROM logs WHERE logs.oid >= (SELECT head FROM logs_base)
+ UNION ALL
+ SELECT * FROM logs
+ LIMIT (SELECT lmt FROM logs_base) ;
+ }
+ } {1 {no such table: logs_base}}
+}
+
+# Overflow the lemon parser stack by providing an overly complex
+# expression. Make sure that the overflow is detected and reported.
+#
+do_test misc5-7.1 {
+ execsql {CREATE TABLE t1(x)}
+ set sql "INSERT INTO t1 VALUES("
+ set tail ""
+ for {set i 0} {$i<200} {incr i} {
+ append sql "(1+"
+ append tail ")"
+ }
+ append sql 2$tail
+ catchsql $sql
+} {1 {parser stack overflow}}
+
+# Ticket #1911
+#
+ifcapable compound {
+ do_test misc5-9.1 {
+ execsql {
+ SELECT name, type FROM sqlite_master WHERE name IS NULL
+ UNION
+ SELECT type, name FROM sqlite_master WHERE type IS NULL
+ ORDER BY 1, 2, 1, 2, 1, 2
+ }
+ } {}
+ do_test misc5-9.2 {
+ execsql {
+ SELECT name, type FROM sqlite_master WHERE name IS NULL
+ UNION
+ SELECT type, name FROM sqlite_master WHERE type IS NULL
+ ORDER BY 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2
+ }
+ } {}
+}
+
+# Ticket #1912. Make the tokenizer require a space after a numeric
+# literal.
+#
+do_test misc5-10.1 {
+ catchsql {
+ SELECT 123abc
+ }
+} {1 {unrecognized token: "123abc"}}
+do_test misc5-10.2 {
+ catchsql {
+ SELECT 1*123.4e5ghi;
+ }
+} {1 {unrecognized token: "123.4e5ghi"}}
+
+
+# Additional integer encoding tests.
+#
+do_test misc5-11.1 {
+ db eval {
+ CREATE TABLE t3(x);
+ INSERT INTO t3 VALUES(-18);
+ INSERT INTO t3 VALUES(-17);
+ INSERT INTO t3 VALUES(-16);
+ INSERT INTO t3 VALUES(-15);
+ INSERT INTO t3 VALUES(-14);
+ INSERT INTO t3 VALUES(-13);
+ INSERT INTO t3 VALUES(-12);
+ INSERT INTO t3 VALUES(-11);
+ INSERT INTO t3 VALUES(-10);
+ INSERT INTO t3 VALUES(-9);
+ INSERT INTO t3 VALUES(-8);
+ INSERT INTO t3 VALUES(-7);
+ INSERT INTO t3 VALUES(-6);
+ INSERT INTO t3 VALUES(-5);
+ INSERT INTO t3 VALUES(-4);
+ INSERT INTO t3 VALUES(-3);
+ INSERT INTO t3 VALUES(-2);
+ INSERT INTO t3 VALUES(-1);
+ INSERT INTO t3 VALUES(0);
+ INSERT INTO t3 VALUES(1);
+ INSERT INTO t3 VALUES(2);
+ INSERT INTO t3 VALUES(3);
+ INSERT INTO t3 VALUES(4);
+ INSERT INTO t3 VALUES(5);
+ INSERT INTO t3 VALUES(6);
+ INSERT INTO t3 VALUES(7);
+ INSERT INTO t3 VALUES(8);
+ INSERT INTO t3 VALUES(9);
+ INSERT INTO t3 VALUES(10);
+ INSERT INTO t3 VALUES(11);
+ INSERT INTO t3 VALUES(12);
+ INSERT INTO t3 VALUES(13);
+ INSERT INTO t3 VALUES(14);
+ INSERT INTO t3 VALUES(15);
+ INSERT INTO t3 VALUES(16);
+ INSERT INTO t3 VALUES(17);
+ INSERT INTO t3 VALUES(18);
+ INSERT INTO t3 VALUES(30);
+ INSERT INTO t3 VALUES(31);
+ INSERT INTO t3 VALUES(32);
+ INSERT INTO t3 VALUES(33);
+ INSERT INTO t3 VALUES(34);
+ INSERT INTO t3 VALUES(-30);
+ INSERT INTO t3 VALUES(-31);
+ INSERT INTO t3 VALUES(-32);
+ INSERT INTO t3 VALUES(-33);
+ INSERT INTO t3 VALUES(-34);
+ INSERT INTO t3 VALUES(62);
+ INSERT INTO t3 VALUES(63);
+ INSERT INTO t3 VALUES(64);
+ INSERT INTO t3 VALUES(65);
+ INSERT INTO t3 VALUES(66);
+ INSERT INTO t3 VALUES(-62);
+ INSERT INTO t3 VALUES(-63);
+ INSERT INTO t3 VALUES(-64);
+ INSERT INTO t3 VALUES(-65);
+ INSERT INTO t3 VALUES(-66);
+ INSERT INTO t3 VALUES(126);
+ INSERT INTO t3 VALUES(127);
+ INSERT INTO t3 VALUES(128);
+ INSERT INTO t3 VALUES(129);
+ INSERT INTO t3 VALUES(130);
+ INSERT INTO t3 VALUES(-126);
+ INSERT INTO t3 VALUES(-127);
+ INSERT INTO t3 VALUES(-128);
+ INSERT INTO t3 VALUES(-129);
+ INSERT INTO t3 VALUES(-130);
+ INSERT INTO t3 VALUES(254);
+ INSERT INTO t3 VALUES(255);
+ INSERT INTO t3 VALUES(256);
+ INSERT INTO t3 VALUES(257);
+ INSERT INTO t3 VALUES(258);
+ INSERT INTO t3 VALUES(-254);
+ INSERT INTO t3 VALUES(-255);
+ INSERT INTO t3 VALUES(-256);
+ INSERT INTO t3 VALUES(-257);
+ INSERT INTO t3 VALUES(-258);
+ INSERT INTO t3 VALUES(510);
+ INSERT INTO t3 VALUES(511);
+ INSERT INTO t3 VALUES(512);
+ INSERT INTO t3 VALUES(513);
+ INSERT INTO t3 VALUES(514);
+ INSERT INTO t3 VALUES(-510);
+ INSERT INTO t3 VALUES(-511);
+ INSERT INTO t3 VALUES(-512);
+ INSERT INTO t3 VALUES(-513);
+ INSERT INTO t3 VALUES(-514);
+ INSERT INTO t3 VALUES(1022);
+ INSERT INTO t3 VALUES(1023);
+ INSERT INTO t3 VALUES(1024);
+ INSERT INTO t3 VALUES(1025);
+ INSERT INTO t3 VALUES(1026);
+ INSERT INTO t3 VALUES(-1022);
+ INSERT INTO t3 VALUES(-1023);
+ INSERT INTO t3 VALUES(-1024);
+ INSERT INTO t3 VALUES(-1025);
+ INSERT INTO t3 VALUES(-1026);
+ INSERT INTO t3 VALUES(2046);
+ INSERT INTO t3 VALUES(2047);
+ INSERT INTO t3 VALUES(2048);
+ INSERT INTO t3 VALUES(2049);
+ INSERT INTO t3 VALUES(2050);
+ INSERT INTO t3 VALUES(-2046);
+ INSERT INTO t3 VALUES(-2047);
+ INSERT INTO t3 VALUES(-2048);
+ INSERT INTO t3 VALUES(-2049);
+ INSERT INTO t3 VALUES(-2050);
+ INSERT INTO t3 VALUES(4094);
+ INSERT INTO t3 VALUES(4095);
+ INSERT INTO t3 VALUES(4096);
+ INSERT INTO t3 VALUES(4097);
+ INSERT INTO t3 VALUES(4098);
+ INSERT INTO t3 VALUES(-4094);
+ INSERT INTO t3 VALUES(-4095);
+ INSERT INTO t3 VALUES(-4096);
+ INSERT INTO t3 VALUES(-4097);
+ INSERT INTO t3 VALUES(-4098);
+ INSERT INTO t3 VALUES(8190);
+ INSERT INTO t3 VALUES(8191);
+ INSERT INTO t3 VALUES(8192);
+ INSERT INTO t3 VALUES(8193);
+ INSERT INTO t3 VALUES(8194);
+ INSERT INTO t3 VALUES(-8190);
+ INSERT INTO t3 VALUES(-8191);
+ INSERT INTO t3 VALUES(-8192);
+ INSERT INTO t3 VALUES(-8193);
+ INSERT INTO t3 VALUES(-8194);
+ INSERT INTO t3 VALUES(16382);
+ INSERT INTO t3 VALUES(16383);
+ INSERT INTO t3 VALUES(16384);
+ INSERT INTO t3 VALUES(16385);
+ INSERT INTO t3 VALUES(16386);
+ INSERT INTO t3 VALUES(-16382);
+ INSERT INTO t3 VALUES(-16383);
+ INSERT INTO t3 VALUES(-16384);
+ INSERT INTO t3 VALUES(-16385);
+ INSERT INTO t3 VALUES(-16386);
+ INSERT INTO t3 VALUES(32766);
+ INSERT INTO t3 VALUES(32767);
+ INSERT INTO t3 VALUES(32768);
+ INSERT INTO t3 VALUES(32769);
+ INSERT INTO t3 VALUES(32770);
+ INSERT INTO t3 VALUES(-32766);
+ INSERT INTO t3 VALUES(-32767);
+ INSERT INTO t3 VALUES(-32768);
+ INSERT INTO t3 VALUES(-32769);
+ INSERT INTO t3 VALUES(-32770);
+ INSERT INTO t3 VALUES(65534);
+ INSERT INTO t3 VALUES(65535);
+ INSERT INTO t3 VALUES(65536);
+ INSERT INTO t3 VALUES(65537);
+ INSERT INTO t3 VALUES(65538);
+ INSERT INTO t3 VALUES(-65534);
+ INSERT INTO t3 VALUES(-65535);
+ INSERT INTO t3 VALUES(-65536);
+ INSERT INTO t3 VALUES(-65537);
+ INSERT INTO t3 VALUES(-65538);
+ INSERT INTO t3 VALUES(131070);
+ INSERT INTO t3 VALUES(131071);
+ INSERT INTO t3 VALUES(131072);
+ INSERT INTO t3 VALUES(131073);
+ INSERT INTO t3 VALUES(131074);
+ INSERT INTO t3 VALUES(-131070);
+ INSERT INTO t3 VALUES(-131071);
+ INSERT INTO t3 VALUES(-131072);
+ INSERT INTO t3 VALUES(-131073);
+ INSERT INTO t3 VALUES(-131074);
+ INSERT INTO t3 VALUES(262142);
+ INSERT INTO t3 VALUES(262143);
+ INSERT INTO t3 VALUES(262144);
+ INSERT INTO t3 VALUES(262145);
+ INSERT INTO t3 VALUES(262146);
+ INSERT INTO t3 VALUES(-262142);
+ INSERT INTO t3 VALUES(-262143);
+ INSERT INTO t3 VALUES(-262144);
+ INSERT INTO t3 VALUES(-262145);
+ INSERT INTO t3 VALUES(-262146);
+ INSERT INTO t3 VALUES(524286);
+ INSERT INTO t3 VALUES(524287);
+ INSERT INTO t3 VALUES(524288);
+ INSERT INTO t3 VALUES(524289);
+ INSERT INTO t3 VALUES(524290);
+ INSERT INTO t3 VALUES(-524286);
+ INSERT INTO t3 VALUES(-524287);
+ INSERT INTO t3 VALUES(-524288);
+ INSERT INTO t3 VALUES(-524289);
+ INSERT INTO t3 VALUES(-524290);
+ INSERT INTO t3 VALUES(1048574);
+ INSERT INTO t3 VALUES(1048575);
+ INSERT INTO t3 VALUES(1048576);
+ INSERT INTO t3 VALUES(1048577);
+ INSERT INTO t3 VALUES(1048578);
+ INSERT INTO t3 VALUES(-1048574);
+ INSERT INTO t3 VALUES(-1048575);
+ INSERT INTO t3 VALUES(-1048576);
+ INSERT INTO t3 VALUES(-1048577);
+ INSERT INTO t3 VALUES(-1048578);
+ INSERT INTO t3 VALUES(2097150);
+ INSERT INTO t3 VALUES(2097151);
+ INSERT INTO t3 VALUES(2097152);
+ INSERT INTO t3 VALUES(2097153);
+ INSERT INTO t3 VALUES(2097154);
+ INSERT INTO t3 VALUES(-2097150);
+ INSERT INTO t3 VALUES(-2097151);
+ INSERT INTO t3 VALUES(-2097152);
+ INSERT INTO t3 VALUES(-2097153);
+ INSERT INTO t3 VALUES(-2097154);
+ INSERT INTO t3 VALUES(4194302);
+ INSERT INTO t3 VALUES(4194303);
+ INSERT INTO t3 VALUES(4194304);
+ INSERT INTO t3 VALUES(4194305);
+ INSERT INTO t3 VALUES(4194306);
+ INSERT INTO t3 VALUES(-4194302);
+ INSERT INTO t3 VALUES(-4194303);
+ INSERT INTO t3 VALUES(-4194304);
+ INSERT INTO t3 VALUES(-4194305);
+ INSERT INTO t3 VALUES(-4194306);
+ INSERT INTO t3 VALUES(8388606);
+ INSERT INTO t3 VALUES(8388607);
+ INSERT INTO t3 VALUES(8388608);
+ INSERT INTO t3 VALUES(8388609);
+ INSERT INTO t3 VALUES(8388610);
+ INSERT INTO t3 VALUES(-8388606);
+ INSERT INTO t3 VALUES(-8388607);
+ INSERT INTO t3 VALUES(-8388608);
+ INSERT INTO t3 VALUES(-8388609);
+ INSERT INTO t3 VALUES(-8388610);
+ INSERT INTO t3 VALUES(16777214);
+ INSERT INTO t3 VALUES(16777215);
+ INSERT INTO t3 VALUES(16777216);
+ INSERT INTO t3 VALUES(16777217);
+ INSERT INTO t3 VALUES(16777218);
+ INSERT INTO t3 VALUES(-16777214);
+ INSERT INTO t3 VALUES(-16777215);
+ INSERT INTO t3 VALUES(-16777216);
+ INSERT INTO t3 VALUES(-16777217);
+ INSERT INTO t3 VALUES(-16777218);
+ INSERT INTO t3 VALUES(33554430);
+ INSERT INTO t3 VALUES(33554431);
+ INSERT INTO t3 VALUES(33554432);
+ INSERT INTO t3 VALUES(33554433);
+ INSERT INTO t3 VALUES(33554434);
+ INSERT INTO t3 VALUES(-33554430);
+ INSERT INTO t3 VALUES(-33554431);
+ INSERT INTO t3 VALUES(-33554432);
+ INSERT INTO t3 VALUES(-33554433);
+ INSERT INTO t3 VALUES(-33554434);
+ INSERT INTO t3 VALUES(67108862);
+ INSERT INTO t3 VALUES(67108863);
+ INSERT INTO t3 VALUES(67108864);
+ INSERT INTO t3 VALUES(67108865);
+ INSERT INTO t3 VALUES(67108866);
+ INSERT INTO t3 VALUES(-67108862);
+ INSERT INTO t3 VALUES(-67108863);
+ INSERT INTO t3 VALUES(-67108864);
+ INSERT INTO t3 VALUES(-67108865);
+ INSERT INTO t3 VALUES(-67108866);
+ INSERT INTO t3 VALUES(134217726);
+ INSERT INTO t3 VALUES(134217727);
+ INSERT INTO t3 VALUES(134217728);
+ INSERT INTO t3 VALUES(134217729);
+ INSERT INTO t3 VALUES(134217730);
+ INSERT INTO t3 VALUES(-134217726);
+ INSERT INTO t3 VALUES(-134217727);
+ INSERT INTO t3 VALUES(-134217728);
+ INSERT INTO t3 VALUES(-134217729);
+ INSERT INTO t3 VALUES(-134217730);
+ INSERT INTO t3 VALUES(268435454);
+ INSERT INTO t3 VALUES(268435455);
+ INSERT INTO t3 VALUES(268435456);
+ INSERT INTO t3 VALUES(268435457);
+ INSERT INTO t3 VALUES(268435458);
+ INSERT INTO t3 VALUES(-268435454);
+ INSERT INTO t3 VALUES(-268435455);
+ INSERT INTO t3 VALUES(-268435456);
+ INSERT INTO t3 VALUES(-268435457);
+ INSERT INTO t3 VALUES(-268435458);
+ INSERT INTO t3 VALUES(536870910);
+ INSERT INTO t3 VALUES(536870911);
+ INSERT INTO t3 VALUES(536870912);
+ INSERT INTO t3 VALUES(536870913);
+ INSERT INTO t3 VALUES(536870914);
+ INSERT INTO t3 VALUES(-536870910);
+ INSERT INTO t3 VALUES(-536870911);
+ INSERT INTO t3 VALUES(-536870912);
+ INSERT INTO t3 VALUES(-536870913);
+ INSERT INTO t3 VALUES(-536870914);
+ INSERT INTO t3 VALUES(1073741822);
+ INSERT INTO t3 VALUES(1073741823);
+ INSERT INTO t3 VALUES(1073741824);
+ INSERT INTO t3 VALUES(1073741825);
+ INSERT INTO t3 VALUES(1073741826);
+ INSERT INTO t3 VALUES(-1073741822);
+ INSERT INTO t3 VALUES(-1073741823);
+ INSERT INTO t3 VALUES(-1073741824);
+ INSERT INTO t3 VALUES(-1073741825);
+ INSERT INTO t3 VALUES(-1073741826);
+ INSERT INTO t3 VALUES(2147483646);
+ INSERT INTO t3 VALUES(2147483647);
+ INSERT INTO t3 VALUES(2147483648);
+ INSERT INTO t3 VALUES(2147483649);
+ INSERT INTO t3 VALUES(2147483650);
+ INSERT INTO t3 VALUES(-2147483646);
+ INSERT INTO t3 VALUES(-2147483647);
+ INSERT INTO t3 VALUES(-2147483648);
+ INSERT INTO t3 VALUES(-2147483649);
+ INSERT INTO t3 VALUES(-2147483650);
+ INSERT INTO t3 VALUES(4294967294);
+ INSERT INTO t3 VALUES(4294967295);
+ INSERT INTO t3 VALUES(4294967296);
+ INSERT INTO t3 VALUES(4294967297);
+ INSERT INTO t3 VALUES(4294967298);
+ INSERT INTO t3 VALUES(-4294967294);
+ INSERT INTO t3 VALUES(-4294967295);
+ INSERT INTO t3 VALUES(-4294967296);
+ INSERT INTO t3 VALUES(-4294967297);
+ INSERT INTO t3 VALUES(-4294967298);
+ INSERT INTO t3 VALUES(8589934590);
+ INSERT INTO t3 VALUES(8589934591);
+ INSERT INTO t3 VALUES(8589934592);
+ INSERT INTO t3 VALUES(8589934593);
+ INSERT INTO t3 VALUES(8589934594);
+ INSERT INTO t3 VALUES(-8589934590);
+ INSERT INTO t3 VALUES(-8589934591);
+ INSERT INTO t3 VALUES(-8589934592);
+ INSERT INTO t3 VALUES(-8589934593);
+ INSERT INTO t3 VALUES(-8589934594);
+ INSERT INTO t3 VALUES(17179869182);
+ INSERT INTO t3 VALUES(17179869183);
+ INSERT INTO t3 VALUES(17179869184);
+ INSERT INTO t3 VALUES(17179869185);
+ INSERT INTO t3 VALUES(17179869186);
+ INSERT INTO t3 VALUES(-17179869182);
+ INSERT INTO t3 VALUES(-17179869183);
+ INSERT INTO t3 VALUES(-17179869184);
+ INSERT INTO t3 VALUES(-17179869185);
+ INSERT INTO t3 VALUES(-17179869186);
+ INSERT INTO t3 VALUES(34359738366);
+ INSERT INTO t3 VALUES(34359738367);
+ INSERT INTO t3 VALUES(34359738368);
+ INSERT INTO t3 VALUES(34359738369);
+ INSERT INTO t3 VALUES(34359738370);
+ INSERT INTO t3 VALUES(-34359738366);
+ INSERT INTO t3 VALUES(-34359738367);
+ INSERT INTO t3 VALUES(-34359738368);
+ INSERT INTO t3 VALUES(-34359738369);
+ INSERT INTO t3 VALUES(-34359738370);
+ INSERT INTO t3 VALUES(68719476734);
+ INSERT INTO t3 VALUES(68719476735);
+ INSERT INTO t3 VALUES(68719476736);
+ INSERT INTO t3 VALUES(68719476737);
+ INSERT INTO t3 VALUES(68719476738);
+ INSERT INTO t3 VALUES(-68719476734);
+ INSERT INTO t3 VALUES(-68719476735);
+ INSERT INTO t3 VALUES(-68719476736);
+ INSERT INTO t3 VALUES(-68719476737);
+ INSERT INTO t3 VALUES(-68719476738);
+ INSERT INTO t3 VALUES(137438953470);
+ INSERT INTO t3 VALUES(137438953471);
+ INSERT INTO t3 VALUES(137438953472);
+ INSERT INTO t3 VALUES(137438953473);
+ INSERT INTO t3 VALUES(137438953474);
+ INSERT INTO t3 VALUES(-137438953470);
+ INSERT INTO t3 VALUES(-137438953471);
+ INSERT INTO t3 VALUES(-137438953472);
+ INSERT INTO t3 VALUES(-137438953473);
+ INSERT INTO t3 VALUES(-137438953474);
+ INSERT INTO t3 VALUES(274877906942);
+ INSERT INTO t3 VALUES(274877906943);
+ INSERT INTO t3 VALUES(274877906944);
+ INSERT INTO t3 VALUES(274877906945);
+ INSERT INTO t3 VALUES(274877906946);
+ INSERT INTO t3 VALUES(-274877906942);
+ INSERT INTO t3 VALUES(-274877906943);
+ INSERT INTO t3 VALUES(-274877906944);
+ INSERT INTO t3 VALUES(-274877906945);
+ INSERT INTO t3 VALUES(-274877906946);
+ INSERT INTO t3 VALUES(549755813886);
+ INSERT INTO t3 VALUES(549755813887);
+ INSERT INTO t3 VALUES(549755813888);
+ INSERT INTO t3 VALUES(549755813889);
+ INSERT INTO t3 VALUES(549755813890);
+ INSERT INTO t3 VALUES(-549755813886);
+ INSERT INTO t3 VALUES(-549755813887);
+ INSERT INTO t3 VALUES(-549755813888);
+ INSERT INTO t3 VALUES(-549755813889);
+ INSERT INTO t3 VALUES(-549755813890);
+ INSERT INTO t3 VALUES(1099511627774);
+ INSERT INTO t3 VALUES(1099511627775);
+ INSERT INTO t3 VALUES(1099511627776);
+ INSERT INTO t3 VALUES(1099511627777);
+ INSERT INTO t3 VALUES(1099511627778);
+ INSERT INTO t3 VALUES(-1099511627774);
+ INSERT INTO t3 VALUES(-1099511627775);
+ INSERT INTO t3 VALUES(-1099511627776);
+ INSERT INTO t3 VALUES(-1099511627777);
+ INSERT INTO t3 VALUES(-1099511627778);
+ INSERT INTO t3 VALUES(2199023255550);
+ INSERT INTO t3 VALUES(2199023255551);
+ INSERT INTO t3 VALUES(2199023255552);
+ INSERT INTO t3 VALUES(2199023255553);
+ INSERT INTO t3 VALUES(2199023255554);
+ INSERT INTO t3 VALUES(-2199023255550);
+ INSERT INTO t3 VALUES(-2199023255551);
+ INSERT INTO t3 VALUES(-2199023255552);
+ INSERT INTO t3 VALUES(-2199023255553);
+ INSERT INTO t3 VALUES(-2199023255554);
+ INSERT INTO t3 VALUES(4398046511102);
+ INSERT INTO t3 VALUES(4398046511103);
+ INSERT INTO t3 VALUES(4398046511104);
+ INSERT INTO t3 VALUES(4398046511105);
+ INSERT INTO t3 VALUES(4398046511106);
+ INSERT INTO t3 VALUES(-4398046511102);
+ INSERT INTO t3 VALUES(-4398046511103);
+ INSERT INTO t3 VALUES(-4398046511104);
+ INSERT INTO t3 VALUES(-4398046511105);
+ INSERT INTO t3 VALUES(-4398046511106);
+ INSERT INTO t3 VALUES(8796093022206);
+ INSERT INTO t3 VALUES(8796093022207);
+ INSERT INTO t3 VALUES(8796093022208);
+ INSERT INTO t3 VALUES(8796093022209);
+ INSERT INTO t3 VALUES(8796093022210);
+ INSERT INTO t3 VALUES(-8796093022206);
+ INSERT INTO t3 VALUES(-8796093022207);
+ INSERT INTO t3 VALUES(-8796093022208);
+ INSERT INTO t3 VALUES(-8796093022209);
+ INSERT INTO t3 VALUES(-8796093022210);
+ INSERT INTO t3 VALUES(17592186044414);
+ INSERT INTO t3 VALUES(17592186044415);
+ INSERT INTO t3 VALUES(17592186044416);
+ INSERT INTO t3 VALUES(17592186044417);
+ INSERT INTO t3 VALUES(17592186044418);
+ INSERT INTO t3 VALUES(-17592186044414);
+ INSERT INTO t3 VALUES(-17592186044415);
+ INSERT INTO t3 VALUES(-17592186044416);
+ INSERT INTO t3 VALUES(-17592186044417);
+ INSERT INTO t3 VALUES(-17592186044418);
+ INSERT INTO t3 VALUES(35184372088830);
+ INSERT INTO t3 VALUES(35184372088831);
+ INSERT INTO t3 VALUES(35184372088832);
+ INSERT INTO t3 VALUES(35184372088833);
+ INSERT INTO t3 VALUES(35184372088834);
+ INSERT INTO t3 VALUES(-35184372088830);
+ INSERT INTO t3 VALUES(-35184372088831);
+ INSERT INTO t3 VALUES(-35184372088832);
+ INSERT INTO t3 VALUES(-35184372088833);
+ INSERT INTO t3 VALUES(-35184372088834);
+ INSERT INTO t3 VALUES(70368744177662);
+ INSERT INTO t3 VALUES(70368744177663);
+ INSERT INTO t3 VALUES(70368744177664);
+ INSERT INTO t3 VALUES(70368744177665);
+ INSERT INTO t3 VALUES(70368744177666);
+ INSERT INTO t3 VALUES(-70368744177662);
+ INSERT INTO t3 VALUES(-70368744177663);
+ INSERT INTO t3 VALUES(-70368744177664);
+ INSERT INTO t3 VALUES(-70368744177665);
+ INSERT INTO t3 VALUES(-70368744177666);
+ INSERT INTO t3 VALUES(140737488355326);
+ INSERT INTO t3 VALUES(140737488355327);
+ INSERT INTO t3 VALUES(140737488355328);
+ INSERT INTO t3 VALUES(140737488355329);
+ INSERT INTO t3 VALUES(140737488355330);
+ INSERT INTO t3 VALUES(-140737488355326);
+ INSERT INTO t3 VALUES(-140737488355327);
+ INSERT INTO t3 VALUES(-140737488355328);
+ INSERT INTO t3 VALUES(-140737488355329);
+ INSERT INTO t3 VALUES(-140737488355330);
+ INSERT INTO t3 VALUES(281474976710654);
+ INSERT INTO t3 VALUES(281474976710655);
+ INSERT INTO t3 VALUES(281474976710656);
+ INSERT INTO t3 VALUES(281474976710657);
+ INSERT INTO t3 VALUES(281474976710658);
+ INSERT INTO t3 VALUES(-281474976710654);
+ INSERT INTO t3 VALUES(-281474976710655);
+ INSERT INTO t3 VALUES(-281474976710656);
+ INSERT INTO t3 VALUES(-281474976710657);
+ INSERT INTO t3 VALUES(-281474976710658);
+ INSERT INTO t3 VALUES(562949953421310);
+ INSERT INTO t3 VALUES(562949953421311);
+ INSERT INTO t3 VALUES(562949953421312);
+ INSERT INTO t3 VALUES(562949953421313);
+ INSERT INTO t3 VALUES(562949953421314);
+ INSERT INTO t3 VALUES(-562949953421310);
+ INSERT INTO t3 VALUES(-562949953421311);
+ INSERT INTO t3 VALUES(-562949953421312);
+ INSERT INTO t3 VALUES(-562949953421313);
+ INSERT INTO t3 VALUES(-562949953421314);
+ INSERT INTO t3 VALUES(1125899906842622);
+ INSERT INTO t3 VALUES(1125899906842623);
+ INSERT INTO t3 VALUES(1125899906842624);
+ INSERT INTO t3 VALUES(1125899906842625);
+ INSERT INTO t3 VALUES(1125899906842626);
+ INSERT INTO t3 VALUES(-1125899906842622);
+ INSERT INTO t3 VALUES(-1125899906842623);
+ INSERT INTO t3 VALUES(-1125899906842624);
+ INSERT INTO t3 VALUES(-1125899906842625);
+ INSERT INTO t3 VALUES(-1125899906842626);
+ INSERT INTO t3 VALUES(2251799813685246);
+ INSERT INTO t3 VALUES(2251799813685247);
+ INSERT INTO t3 VALUES(2251799813685248);
+ INSERT INTO t3 VALUES(2251799813685249);
+ INSERT INTO t3 VALUES(2251799813685250);
+ INSERT INTO t3 VALUES(-2251799813685246);
+ INSERT INTO t3 VALUES(-2251799813685247);
+ INSERT INTO t3 VALUES(-2251799813685248);
+ INSERT INTO t3 VALUES(-2251799813685249);
+ INSERT INTO t3 VALUES(-2251799813685250);
+ INSERT INTO t3 VALUES(4503599627370494);
+ INSERT INTO t3 VALUES(4503599627370495);
+ INSERT INTO t3 VALUES(4503599627370496);
+ INSERT INTO t3 VALUES(4503599627370497);
+ INSERT INTO t3 VALUES(4503599627370498);
+ INSERT INTO t3 VALUES(-4503599627370494);
+ INSERT INTO t3 VALUES(-4503599627370495);
+ INSERT INTO t3 VALUES(-4503599627370496);
+ INSERT INTO t3 VALUES(-4503599627370497);
+ INSERT INTO t3 VALUES(-4503599627370498);
+ INSERT INTO t3 VALUES(9007199254740990);
+ INSERT INTO t3 VALUES(9007199254740991);
+ INSERT INTO t3 VALUES(9007199254740992);
+ INSERT INTO t3 VALUES(9007199254740993);
+ INSERT INTO t3 VALUES(9007199254740994);
+ INSERT INTO t3 VALUES(-9007199254740990);
+ INSERT INTO t3 VALUES(-9007199254740991);
+ INSERT INTO t3 VALUES(-9007199254740992);
+ INSERT INTO t3 VALUES(-9007199254740993);
+ INSERT INTO t3 VALUES(-9007199254740994);
+ INSERT INTO t3 VALUES(18014398509481982);
+ INSERT INTO t3 VALUES(18014398509481983);
+ INSERT INTO t3 VALUES(18014398509481984);
+ INSERT INTO t3 VALUES(18014398509481985);
+ INSERT INTO t3 VALUES(18014398509481986);
+ INSERT INTO t3 VALUES(-18014398509481982);
+ INSERT INTO t3 VALUES(-18014398509481983);
+ INSERT INTO t3 VALUES(-18014398509481984);
+ INSERT INTO t3 VALUES(-18014398509481985);
+ INSERT INTO t3 VALUES(-18014398509481986);
+ INSERT INTO t3 VALUES(36028797018963966);
+ INSERT INTO t3 VALUES(36028797018963967);
+ INSERT INTO t3 VALUES(36028797018963968);
+ INSERT INTO t3 VALUES(36028797018963969);
+ INSERT INTO t3 VALUES(36028797018963970);
+ INSERT INTO t3 VALUES(-36028797018963966);
+ INSERT INTO t3 VALUES(-36028797018963967);
+ INSERT INTO t3 VALUES(-36028797018963968);
+ INSERT INTO t3 VALUES(-36028797018963969);
+ INSERT INTO t3 VALUES(-36028797018963970);
+ INSERT INTO t3 VALUES(72057594037927934);
+ INSERT INTO t3 VALUES(72057594037927935);
+ INSERT INTO t3 VALUES(72057594037927936);
+ INSERT INTO t3 VALUES(72057594037927937);
+ INSERT INTO t3 VALUES(72057594037927938);
+ INSERT INTO t3 VALUES(-72057594037927934);
+ INSERT INTO t3 VALUES(-72057594037927935);
+ INSERT INTO t3 VALUES(-72057594037927936);
+ INSERT INTO t3 VALUES(-72057594037927937);
+ INSERT INTO t3 VALUES(-72057594037927938);
+ INSERT INTO t3 VALUES(144115188075855870);
+ INSERT INTO t3 VALUES(144115188075855871);
+ INSERT INTO t3 VALUES(144115188075855872);
+ INSERT INTO t3 VALUES(144115188075855873);
+ INSERT INTO t3 VALUES(144115188075855874);
+ INSERT INTO t3 VALUES(-144115188075855870);
+ INSERT INTO t3 VALUES(-144115188075855871);
+ INSERT INTO t3 VALUES(-144115188075855872);
+ INSERT INTO t3 VALUES(-144115188075855873);
+ INSERT INTO t3 VALUES(-144115188075855874);
+ INSERT INTO t3 VALUES(288230376151711742);
+ INSERT INTO t3 VALUES(288230376151711743);
+ INSERT INTO t3 VALUES(288230376151711744);
+ INSERT INTO t3 VALUES(288230376151711745);
+ INSERT INTO t3 VALUES(288230376151711746);
+ INSERT INTO t3 VALUES(-288230376151711742);
+ INSERT INTO t3 VALUES(-288230376151711743);
+ INSERT INTO t3 VALUES(-288230376151711744);
+ INSERT INTO t3 VALUES(-288230376151711745);
+ INSERT INTO t3 VALUES(-288230376151711746);
+ INSERT INTO t3 VALUES(576460752303423486);
+ INSERT INTO t3 VALUES(576460752303423487);
+ INSERT INTO t3 VALUES(576460752303423488);
+ INSERT INTO t3 VALUES(576460752303423489);
+ INSERT INTO t3 VALUES(576460752303423490);
+ INSERT INTO t3 VALUES(-576460752303423486);
+ INSERT INTO t3 VALUES(-576460752303423487);
+ INSERT INTO t3 VALUES(-576460752303423488);
+ INSERT INTO t3 VALUES(-576460752303423489);
+ INSERT INTO t3 VALUES(-576460752303423490);
+ INSERT INTO t3 VALUES(1152921504606846974);
+ INSERT INTO t3 VALUES(1152921504606846975);
+ INSERT INTO t3 VALUES(1152921504606846976);
+ INSERT INTO t3 VALUES(1152921504606846977);
+ INSERT INTO t3 VALUES(1152921504606846978);
+ INSERT INTO t3 VALUES(-1152921504606846974);
+ INSERT INTO t3 VALUES(-1152921504606846975);
+ INSERT INTO t3 VALUES(-1152921504606846976);
+ INSERT INTO t3 VALUES(-1152921504606846977);
+ INSERT INTO t3 VALUES(-1152921504606846978);
+ INSERT INTO t3 VALUES(2305843009213693950);
+ INSERT INTO t3 VALUES(2305843009213693951);
+ INSERT INTO t3 VALUES(2305843009213693952);
+ INSERT INTO t3 VALUES(2305843009213693953);
+ INSERT INTO t3 VALUES(2305843009213693954);
+ INSERT INTO t3 VALUES(-2305843009213693950);
+ INSERT INTO t3 VALUES(-2305843009213693951);
+ INSERT INTO t3 VALUES(-2305843009213693952);
+ INSERT INTO t3 VALUES(-2305843009213693953);
+ INSERT INTO t3 VALUES(-2305843009213693954);
+ INSERT INTO t3 VALUES(4611686018427387902);
+ INSERT INTO t3 VALUES(4611686018427387903);
+ INSERT INTO t3 VALUES(4611686018427387904);
+ INSERT INTO t3 VALUES(4611686018427387905);
+ INSERT INTO t3 VALUES(4611686018427387906);
+ INSERT INTO t3 VALUES(-4611686018427387902);
+ INSERT INTO t3 VALUES(-4611686018427387903);
+ INSERT INTO t3 VALUES(-4611686018427387904);
+ INSERT INTO t3 VALUES(-4611686018427387905);
+ INSERT INTO t3 VALUES(-4611686018427387906);
+ INSERT INTO t3 VALUES(9223372036854775806);
+ INSERT INTO t3 VALUES(9223372036854775807);
+ INSERT INTO t3 VALUES(-9223372036854775806);
+ INSERT INTO t3 VALUES(-9223372036854775807);
+ INSERT INTO t3 VALUES(-9223372036854775808);
+ SELECT x FROM t3 ORDER BY x;
+ }
+} {-9223372036854775808\
+-9223372036854775807\
+-9223372036854775806\
+-4611686018427387906\
+-4611686018427387905\
+-4611686018427387904\
+-4611686018427387903\
+-4611686018427387902\
+-2305843009213693954\
+-2305843009213693953\
+-2305843009213693952\
+-2305843009213693951\
+-2305843009213693950\
+-1152921504606846978\
+-1152921504606846977\
+-1152921504606846976\
+-1152921504606846975\
+-1152921504606846974\
+-576460752303423490\
+-576460752303423489\
+-576460752303423488\
+-576460752303423487\
+-576460752303423486\
+-288230376151711746\
+-288230376151711745\
+-288230376151711744\
+-288230376151711743\
+-288230376151711742\
+-144115188075855874\
+-144115188075855873\
+-144115188075855872\
+-144115188075855871\
+-144115188075855870\
+-72057594037927938\
+-72057594037927937\
+-72057594037927936\
+-72057594037927935\
+-72057594037927934\
+-36028797018963970\
+-36028797018963969\
+-36028797018963968\
+-36028797018963967\
+-36028797018963966\
+-18014398509481986\
+-18014398509481985\
+-18014398509481984\
+-18014398509481983\
+-18014398509481982\
+-9007199254740994\
+-9007199254740993\
+-9007199254740992\
+-9007199254740991\
+-9007199254740990\
+-4503599627370498\
+-4503599627370497\
+-4503599627370496\
+-4503599627370495\
+-4503599627370494\
+-2251799813685250\
+-2251799813685249\
+-2251799813685248\
+-2251799813685247\
+-2251799813685246\
+-1125899906842626\
+-1125899906842625\
+-1125899906842624\
+-1125899906842623\
+-1125899906842622\
+-562949953421314\
+-562949953421313\
+-562949953421312\
+-562949953421311\
+-562949953421310\
+-281474976710658\
+-281474976710657\
+-281474976710656\
+-281474976710655\
+-281474976710654\
+-140737488355330\
+-140737488355329\
+-140737488355328\
+-140737488355327\
+-140737488355326\
+-70368744177666\
+-70368744177665\
+-70368744177664\
+-70368744177663\
+-70368744177662\
+-35184372088834\
+-35184372088833\
+-35184372088832\
+-35184372088831\
+-35184372088830\
+-17592186044418\
+-17592186044417\
+-17592186044416\
+-17592186044415\
+-17592186044414\
+-8796093022210\
+-8796093022209\
+-8796093022208\
+-8796093022207\
+-8796093022206\
+-4398046511106\
+-4398046511105\
+-4398046511104\
+-4398046511103\
+-4398046511102\
+-2199023255554\
+-2199023255553\
+-2199023255552\
+-2199023255551\
+-2199023255550\
+-1099511627778\
+-1099511627777\
+-1099511627776\
+-1099511627775\
+-1099511627774\
+-549755813890\
+-549755813889\
+-549755813888\
+-549755813887\
+-549755813886\
+-274877906946\
+-274877906945\
+-274877906944\
+-274877906943\
+-274877906942\
+-137438953474\
+-137438953473\
+-137438953472\
+-137438953471\
+-137438953470\
+-68719476738\
+-68719476737\
+-68719476736\
+-68719476735\
+-68719476734\
+-34359738370\
+-34359738369\
+-34359738368\
+-34359738367\
+-34359738366\
+-17179869186\
+-17179869185\
+-17179869184\
+-17179869183\
+-17179869182\
+-8589934594\
+-8589934593\
+-8589934592\
+-8589934591\
+-8589934590\
+-4294967298\
+-4294967297\
+-4294967296\
+-4294967295\
+-4294967294\
+-2147483650\
+-2147483649\
+-2147483648\
+-2147483647\
+-2147483646\
+-1073741826\
+-1073741825\
+-1073741824\
+-1073741823\
+-1073741822\
+-536870914\
+-536870913\
+-536870912\
+-536870911\
+-536870910\
+-268435458\
+-268435457\
+-268435456\
+-268435455\
+-268435454\
+-134217730\
+-134217729\
+-134217728\
+-134217727\
+-134217726\
+-67108866\
+-67108865\
+-67108864\
+-67108863\
+-67108862\
+-33554434\
+-33554433\
+-33554432\
+-33554431\
+-33554430\
+-16777218\
+-16777217\
+-16777216\
+-16777215\
+-16777214\
+-8388610\
+-8388609\
+-8388608\
+-8388607\
+-8388606\
+-4194306\
+-4194305\
+-4194304\
+-4194303\
+-4194302\
+-2097154\
+-2097153\
+-2097152\
+-2097151\
+-2097150\
+-1048578\
+-1048577\
+-1048576\
+-1048575\
+-1048574\
+-524290\
+-524289\
+-524288\
+-524287\
+-524286\
+-262146\
+-262145\
+-262144\
+-262143\
+-262142\
+-131074\
+-131073\
+-131072\
+-131071\
+-131070\
+-65538\
+-65537\
+-65536\
+-65535\
+-65534\
+-32770\
+-32769\
+-32768\
+-32767\
+-32766\
+-16386\
+-16385\
+-16384\
+-16383\
+-16382\
+-8194\
+-8193\
+-8192\
+-8191\
+-8190\
+-4098\
+-4097\
+-4096\
+-4095\
+-4094\
+-2050\
+-2049\
+-2048\
+-2047\
+-2046\
+-1026\
+-1025\
+-1024\
+-1023\
+-1022\
+-514\
+-513\
+-512\
+-511\
+-510\
+-258\
+-257\
+-256\
+-255\
+-254\
+-130\
+-129\
+-128\
+-127\
+-126\
+-66\
+-65\
+-64\
+-63\
+-62\
+-34\
+-33\
+-32\
+-31\
+-30\
+-18\
+-17\
+-16\
+-15\
+-14\
+-13\
+-12\
+-11\
+-10\
+-9\
+-8\
+-7\
+-6\
+-5\
+-4\
+-3\
+-2\
+-1\
+0\
+1\
+2\
+3\
+4\
+5\
+6\
+7\
+8\
+9\
+10\
+11\
+12\
+13\
+14\
+15\
+16\
+17\
+18\
+30\
+31\
+32\
+33\
+34\
+62\
+63\
+64\
+65\
+66\
+126\
+127\
+128\
+129\
+130\
+254\
+255\
+256\
+257\
+258\
+510\
+511\
+512\
+513\
+514\
+1022\
+1023\
+1024\
+1025\
+1026\
+2046\
+2047\
+2048\
+2049\
+2050\
+4094\
+4095\
+4096\
+4097\
+4098\
+8190\
+8191\
+8192\
+8193\
+8194\
+16382\
+16383\
+16384\
+16385\
+16386\
+32766\
+32767\
+32768\
+32769\
+32770\
+65534\
+65535\
+65536\
+65537\
+65538\
+131070\
+131071\
+131072\
+131073\
+131074\
+262142\
+262143\
+262144\
+262145\
+262146\
+524286\
+524287\
+524288\
+524289\
+524290\
+1048574\
+1048575\
+1048576\
+1048577\
+1048578\
+2097150\
+2097151\
+2097152\
+2097153\
+2097154\
+4194302\
+4194303\
+4194304\
+4194305\
+4194306\
+8388606\
+8388607\
+8388608\
+8388609\
+8388610\
+16777214\
+16777215\
+16777216\
+16777217\
+16777218\
+33554430\
+33554431\
+33554432\
+33554433\
+33554434\
+67108862\
+67108863\
+67108864\
+67108865\
+67108866\
+134217726\
+134217727\
+134217728\
+134217729\
+134217730\
+268435454\
+268435455\
+268435456\
+268435457\
+268435458\
+536870910\
+536870911\
+536870912\
+536870913\
+536870914\
+1073741822\
+1073741823\
+1073741824\
+1073741825\
+1073741826\
+2147483646\
+2147483647\
+2147483648\
+2147483649\
+2147483650\
+4294967294\
+4294967295\
+4294967296\
+4294967297\
+4294967298\
+8589934590\
+8589934591\
+8589934592\
+8589934593\
+8589934594\
+17179869182\
+17179869183\
+17179869184\
+17179869185\
+17179869186\
+34359738366\
+34359738367\
+34359738368\
+34359738369\
+34359738370\
+68719476734\
+68719476735\
+68719476736\
+68719476737\
+68719476738\
+137438953470\
+137438953471\
+137438953472\
+137438953473\
+137438953474\
+274877906942\
+274877906943\
+274877906944\
+274877906945\
+274877906946\
+549755813886\
+549755813887\
+549755813888\
+549755813889\
+549755813890\
+1099511627774\
+1099511627775\
+1099511627776\
+1099511627777\
+1099511627778\
+2199023255550\
+2199023255551\
+2199023255552\
+2199023255553\
+2199023255554\
+4398046511102\
+4398046511103\
+4398046511104\
+4398046511105\
+4398046511106\
+8796093022206\
+8796093022207\
+8796093022208\
+8796093022209\
+8796093022210\
+17592186044414\
+17592186044415\
+17592186044416\
+17592186044417\
+17592186044418\
+35184372088830\
+35184372088831\
+35184372088832\
+35184372088833\
+35184372088834\
+70368744177662\
+70368744177663\
+70368744177664\
+70368744177665\
+70368744177666\
+140737488355326\
+140737488355327\
+140737488355328\
+140737488355329\
+140737488355330\
+281474976710654\
+281474976710655\
+281474976710656\
+281474976710657\
+281474976710658\
+562949953421310\
+562949953421311\
+562949953421312\
+562949953421313\
+562949953421314\
+1125899906842622\
+1125899906842623\
+1125899906842624\
+1125899906842625\
+1125899906842626\
+2251799813685246\
+2251799813685247\
+2251799813685248\
+2251799813685249\
+2251799813685250\
+4503599627370494\
+4503599627370495\
+4503599627370496\
+4503599627370497\
+4503599627370498\
+9007199254740990\
+9007199254740991\
+9007199254740992\
+9007199254740993\
+9007199254740994\
+18014398509481982\
+18014398509481983\
+18014398509481984\
+18014398509481985\
+18014398509481986\
+36028797018963966\
+36028797018963967\
+36028797018963968\
+36028797018963969\
+36028797018963970\
+72057594037927934\
+72057594037927935\
+72057594037927936\
+72057594037927937\
+72057594037927938\
+144115188075855870\
+144115188075855871\
+144115188075855872\
+144115188075855873\
+144115188075855874\
+288230376151711742\
+288230376151711743\
+288230376151711744\
+288230376151711745\
+288230376151711746\
+576460752303423486\
+576460752303423487\
+576460752303423488\
+576460752303423489\
+576460752303423490\
+1152921504606846974\
+1152921504606846975\
+1152921504606846976\
+1152921504606846977\
+1152921504606846978\
+2305843009213693950\
+2305843009213693951\
+2305843009213693952\
+2305843009213693953\
+2305843009213693954\
+4611686018427387902\
+4611686018427387903\
+4611686018427387904\
+4611686018427387905\
+4611686018427387906\
+9223372036854775806\
+9223372036854775807}
+
+finish_test
diff --git a/test/misc6.test b/test/misc6.test
new file mode 100644
index 0000000..9840dd9
--- /dev/null
+++ b/test/misc6.test
@@ -0,0 +1,48 @@
+# 2006 September 4
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure sqlite3_value_text()
+# always returns a null-terminated string.
+#
+# $Id: misc6.test,v 1.3 2007/04/23 23:56:32 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test misc6-1.1 {
+ set DB [sqlite3_connection_pointer db]
+ sqlite3_create_function $DB
+ set STMT [sqlite3_prepare $DB {SELECT hex8(?)} -1 DUMMY]
+ set sqlite_static_bind_value {0123456789}
+ set sqlite_static_bind_nbyte 5
+ sqlite_bind $STMT 1 {} static-nbytes
+ sqlite3_step $STMT
+} SQLITE_ROW
+do_test misc6-1.2 {
+ sqlite3_column_text $STMT 0
+} {3031323334}
+ifcapable utf16 {
+ do_test misc6-1.3 {
+ sqlite3_finalize $STMT
+ set STMT [sqlite3_prepare $DB {SELECT hex16(?)} -1 DUMMY]
+ set sqlite_static_bind_value {0123456789}
+ set sqlite_static_bind_nbyte 5
+ sqlite_bind $STMT 1 {} static-nbytes
+ sqlite3_step $STMT
+ } SQLITE_ROW
+ do_test misc6-1.4 {
+ sqlite3_column_text $STMT 0
+ } {00300031003200330034}
+}
+sqlite3_finalize $STMT
+
+finish_test
diff --git a/test/misc7.test b/test/misc7.test
new file mode 100644
index 0000000..9dee327
--- /dev/null
+++ b/test/misc7.test
@@ -0,0 +1,489 @@
+# 2006 September 4
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# $Id: misc7.test,v 1.29 2009/07/16 18:21:18 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test misc7-1-misuse {
+ c_misuse_test
+} {}
+
+do_test misc7-2 {
+ c_realloc_test
+} {}
+
+do_test misc7-3 {
+ c_collation_test
+} {}
+
+# Try to open a directory:
+#
+do_test misc7-4 {
+ delete_file mydir
+ file mkdir mydir
+ set rc [catch {
+ sqlite3 db2 ./mydir
+ } msg]
+ list $rc $msg
+} {1 {unable to open database file}}
+
+# Try to open a file with a directory where its journal file should be.
+#
+do_test misc7-5 {
+ delete_file mydir
+ file mkdir mydir-journal
+ sqlite3 db2 ./mydir
+ catchsql {
+ CREATE TABLE abc(a, b, c);
+ } db2
+} {1 {unable to open database file}}
+db2 close
+
+#--------------------------------------------------------------------
+# The following tests, misc7-6.* test the libraries behaviour when
+# it cannot open a file. To force this condition, we use up all the
+# file-descriptors before running sqlite. This probably only works
+# on unix.
+#
+
+proc use_up_files {} {
+ set ret [list]
+ catch {
+ while 1 { lappend ret [open test.db] }
+ }
+ return $ret
+}
+
+proc do_fileopen_test {prefix sql} {
+ set fd_list [use_up_files]
+ set ::go 1
+ set ::n 1
+ set ::sql $sql
+ while {$::go} {
+ catch {db close}
+ do_test ${prefix}.${::n} {
+ set rc [catch {
+ sqlite db test.db
+ db eval $::sql
+ } msg]
+ if {$rc == 0} {set ::go 0}
+
+ expr {$rc == 0 || ($rc == 1 && [string first unable $msg]==0)}
+ } 1
+
+ close [lindex $fd_list 0]
+ set fd_list [lrange $fd_list 1 end]
+ incr ::n
+ }
+ foreach fd $fd_list {
+ close $fd
+ }
+ db close
+}
+
+execsql { CREATE TABLE abc(a PRIMARY KEY, b, c); }
+db close
+
+if {$tcl_platform(platform)!="windows"} {
+ do_fileopen_test misc7-6.1 {
+ BEGIN;
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(2, 3, 4);
+ INSERT INTO abc SELECT a+2, b, c FROM abc;
+ COMMIT;
+ }
+
+ do_fileopen_test misc7-6.2 {
+ PRAGMA temp.cache_size = 1000;
+ }
+}
+
+#
+# End of tests for out-of-file-descriptors condition.
+#--------------------------------------------------------------------
+
+sqlite3 db test.db
+execsql {
+ DELETE FROM abc;
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(2, 3, 4);
+ INSERT INTO abc SELECT a+2, b, c FROM abc;
+}
+
+
+#--------------------------------------------------------------------
+# Test that the sqlite3_busy_timeout call seems to delay approximately
+# the right amount of time.
+#
+do_test misc7-7.0 {
+ sqlite3 db2 test.db
+ sqlite3_busy_timeout [sqlite3_connection_pointer db] 2000
+ execsql {
+ BEGIN EXCLUSIVE;
+ } db2
+
+ # Now db2 has an exclusive lock on the database file, and db has
+ # a busy-timeout of 2000 milliseconds. So check that trying to
+ # access the database using connection db delays for at least 1500 ms.
+ #
+ set tm [time {
+ set result [catchsql {
+ SELECT * FROM sqlite_master;
+ } db]
+ }]
+ set delay [lindex $tm 0] ;# In microseconds
+ lappend result [expr {$delay>1500000 && $delay<4000000}]
+} {1 {database is locked} 1}
+db2 close
+
+#--------------------------------------------------------------------
+# Test that nothing goes horribly wrong when attaching a database
+# after the omit_readlock pragma has been exercised.
+#
+do_test misc7-7.1 {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ execsql {
+ PRAGMA omit_readlock = 1;
+ ATTACH 'test2.db' AS aux;
+ CREATE TABLE aux.hello(world);
+ SELECT name FROM aux.sqlite_master;
+ }
+} {hello}
+do_test misc7-7.2 {
+ execsql {
+ DETACH aux;
+ }
+} {}
+do_test misc7-7.3 {
+ db close
+ sqlite3 db test.db -readonly 1
+ execsql {
+ PRAGMA omit_readlock = 1;
+ ATTACH 'test2.db' AS aux;
+ SELECT name FROM aux.sqlite_master;
+ SELECT name FROM aux.sqlite_master;
+ }
+} {hello hello}
+do_test misc7-7.3 {
+ db close
+ sqlite3 db test.db
+ set ::DB [sqlite3_connection_pointer db]
+ list
+} {}
+
+# Test the UTF-16 version of the "out of memory" message (used when
+# malloc fails during sqlite3_open() ).
+#
+ifcapable utf16 {
+ do_test misc7-8 {
+ encoding convertfrom unicode [sqlite3_errmsg16 0x00000000]
+ } {out of memory}
+}
+
+do_test misc7-9 {
+ execsql {
+ SELECT *
+ FROM (SELECT name+1 AS one FROM sqlite_master LIMIT 1 OFFSET 1)
+ WHERE one LIKE 'hello%';
+ }
+} {}
+
+#--------------------------------------------------------------------
+# Improve coverage for vtab code.
+#
+ifcapable vtab {
+ # Run some debug code to improve reported coverage
+ #
+
+ # set sqlite_where_trace 1
+ do_test misc7-10 {
+ register_echo_module [sqlite3_connection_pointer db]
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING echo(abc);
+ SELECT a FROM t1 WHERE a = 1 ORDER BY b;
+ }
+ } {1}
+ set sqlite_where_trace 0
+
+ # Specify an ORDER BY clause that cannot be indexed.
+ do_test misc7-11 {
+ execsql {
+ SELECT t1.a, t2.a FROM t1, t1 AS t2 ORDER BY 2 LIMIT 1;
+ }
+ } {1 1}
+
+ # The whole point of this is to test an error code other than
+ # SQLITE_NOMEM from the vtab xBestIndex callback.
+ #
+ do_ioerr_test misc7-12 -tclprep {
+ sqlite3 db2 test.db
+ register_echo_module [sqlite3_connection_pointer db2]
+ db2 eval {
+ CREATE TABLE abc(a PRIMARY KEY, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ CREATE VIRTUAL TABLE t1 USING echo(abc);
+ }
+ db2 close
+ } -tclbody {
+ register_echo_module [sqlite3_connection_pointer db]
+ execsql {SELECT * FROM t1 WHERE a = 1;}
+ }
+
+ # The case where the virtual table module returns a very large number
+ # as the cost of a scan (greater than SQLITE_BIG_DOUBLE in the code).
+ #
+ do_test misc7-13 {
+ sqlite3 db test.db
+ register_echo_module [sqlite3_connection_pointer db]
+ set ::echo_module_cost 2.0e+99
+ execsql {SELECT * FROM t1 WHERE a = 1;}
+ } {1 2 3}
+ unset ::echo_module_cost
+}
+
+db close
+forcedelete test.db
+forcedelete test.db-journal
+sqlite3 db test.db
+
+ifcapable explain {
+ do_execsql_test misc7-14.1 {
+ CREATE TABLE abc(a PRIMARY KEY, b, c);
+ EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid = 1;
+ } {
+ 0 0 0 {SEARCH TABLE abc AS t2 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+ }
+ do_execsql_test misc7-14.2 {
+ EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE a = 1;
+ } {0 0 0
+ {SEARCH TABLE abc AS t2 USING INDEX sqlite_autoindex_abc_1 (a=?) (~1 rows)}
+ }
+ do_execsql_test misc7-14.3 {
+ EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 ORDER BY a;
+ } {0 0 0
+ {SCAN TABLE abc AS t2 USING INDEX sqlite_autoindex_abc_1 (~1000000 rows)}
+ }
+}
+
+db close
+forcedelete test.db
+forcedelete test.db-journal
+sqlite3 db test.db
+
+#--------------------------------------------------------------------
+# This is all to force the pager_remove_from_stmt_list() function
+# (inside pager.c) to remove a pager from the middle of the
+# statement-list.
+#
+do_test misc7-15.1 {
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY, b, c);
+ INSERT INTO abc
+ VALUES(randstr(100,100), randstr(100,100), randstr(100,100));
+ INSERT INTO abc SELECT
+ randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc SELECT
+ randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc SELECT
+ randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc SELECT
+ randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc SELECT
+ randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc SELECT
+ randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc SELECT
+ randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ INSERT INTO abc SELECT
+ randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ COMMIT;
+ }
+ expr {[file size test.db]>10240}
+} {1}
+do_test misc7-15.2 {
+ execsql {
+ DELETE FROM abc WHERE rowid > 12;
+ INSERT INTO abc SELECT
+ randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
+ }
+} {}
+
+db close
+forcedelete test.db
+forcedelete test.db-journal
+sqlite3 db test.db
+
+do_ioerr_test misc7-16 -sqlprep {
+ PRAGMA cache_size = 10;
+ PRAGMA default_cache_size = 10;
+ CREATE TABLE t3(a, b, UNIQUE(a, b));
+ INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
+ INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+ INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+ INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+ INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+ INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
+ UPDATE t3
+ SET b = 'hello world'
+ WHERE rowid >= (SELECT max(rowid)-1 FROM t3);
+} -tclbody {
+ set rc [catch {db eval {
+ BEGIN;
+ PRAGMA cache_size = 10;
+ INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
+ UPDATE t3 SET a = b;
+ COMMIT;
+ }} msg]
+
+ if {!$rc || ($rc && [string first "columns" $msg]==0)} {
+ set msg
+ } else {
+ error $msg
+ }
+}
+
+sqlite3 db test.db
+
+do_test misc7-16.X {
+ execsql {
+ SELECT count(*) FROM t3;
+ }
+} {32}
+
+#----------------------------------------------------------------------
+# Test the situation where a hot-journal is discovered but write-access
+# to it is denied. This should return SQLITE_BUSY.
+#
+# These tests do not work on windows due to restrictions in the
+# windows file system.
+#
+if {$tcl_platform(platform)!="windows" && $tcl_platform(platform)!="os2"} {
+
+ # Some network filesystems (ex: AFP) do not support setting read-only
+ # permissions. Only run these tests if full unix permission setting
+ # capabilities are supported.
+ #
+ file attributes test.db -permissions rw-r--r--
+ if {[file attributes test.db -permissions]==0644} {
+
+ do_test misc7-17.1 {
+ execsql {
+ BEGIN;
+ DELETE FROM t3 WHERE (oid%3)==0;
+ }
+ forcecopy test.db bak.db
+ forcecopy test.db-journal bak.db-journal
+ execsql {
+ COMMIT;
+ }
+
+ db close
+ forcecopy bak.db test.db
+ forcecopy bak.db-journal test.db-journal
+ sqlite3 db test.db
+
+ catch {file attributes test.db-journal -permissions r--------}
+ catch {file attributes test.db-journal -readonly 1}
+ catchsql {
+ SELECT count(*) FROM t3;
+ }
+ } {1 {unable to open database file}}
+ do_test misc7-17.2 {
+ # Note that the -readonly flag must be cleared before the -permissions
+ # are set. Otherwise, when using tcl 8.5 on mac, the fact that the
+ # -readonly flag is set causes the attempt to set the permissions
+ # to fail.
+ catch {file attributes test.db-journal -readonly 0}
+ catch {file attributes test.db-journal -permissions rw-------}
+ catchsql {
+ SELECT count(*) FROM t3;
+ }
+ } {0 32}
+
+ # sqlite3_test_control_pending_page [expr ($::sqlite_pending_byte / 1024) + 1]
+ set ::pending_byte_page [expr ($::sqlite_pending_byte / 1024) + 1]
+ sqlite3_test_control_pending_byte $::sqlite_pending_byte
+ do_test misc7-17.3 {
+ db eval {
+ pragma writable_schema = true;
+ UPDATE sqlite_master
+ SET rootpage = $pending_byte_page
+ WHERE type = 'table' AND name = 't3';
+ }
+ execsql {
+ SELECT rootpage FROM sqlite_master WHERE type = 'table' AND name = 't3';
+ }
+ } $::pending_byte_page
+
+ do_test misc7-17.4 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT count(*) FROM t3;
+ }
+ } {1 {database disk image is malformed}}
+ }
+}
+
+# Ticket #2470
+#
+do_test misc7-18.1 {
+ execsql {
+ CREATE TABLE table_1 (col_10);
+ CREATE TABLE table_2 (
+ col_1, col_2, col_3, col_4, col_5,
+ col_6, col_7, col_8, col_9, col_10
+ );
+ SELECT a.col_10
+ FROM
+ (SELECT table_1.col_10 AS col_10 FROM table_1) a,
+ (SELECT table_1.col_10, table_2.col_9 AS qcol_9
+ FROM table_1, table_2
+ GROUP BY table_1.col_10, qcol_9);
+ }
+} {}
+
+# Testing boundary conditions on sqlite3_status()
+#
+do_test misc7-19.1 {
+ sqlite3_status -1 0
+} {21 0 0}
+do_test misc7-19.2 {
+ sqlite3_status 1000 0
+} {21 0 0}
+
+
+# sqlite3_global_recover() is a no-op. But we might as well test it
+# if only to get the test coverage.
+#
+do_test misc7-20.1 {
+ sqlite3_global_recover
+} {SQLITE_OK}
+
+# Try to open a really long file name.
+#
+do_test misc7-21.1 {
+ set zFile [file join [pwd] "[string repeat abcde 104].db"]
+ set rc [catch {sqlite3 db2 $zFile} msg]
+ list $rc $msg
+} {1 {unable to open database file}}
+
+
+db close
+forcedelete test.db
+
+finish_test
diff --git a/test/misuse.test b/test/misuse.test
new file mode 100644
index 0000000..71ee011
--- /dev/null
+++ b/test/misuse.test
@@ -0,0 +1,207 @@
+# 2002 May 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the SQLITE_MISUSE detection logic.
+# This test file leaks memory and file descriptors.
+#
+# $Id: misuse.test,v 1.11 2006/01/03 00:33:50 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc catchsql2 {sql} {
+ set r [
+ catch {
+ set res [list]
+ db eval $sql data {
+ if { $res==[list] } {
+ foreach f $data(*) {lappend res $f}
+ }
+ foreach f $data(*) {lappend res $data($f)}
+ }
+ set res
+ } msg
+ ]
+ lappend r $msg
+}
+
+
+# Make sure the test logic works
+#
+do_test misuse-1.1 {
+ db close
+ catch {forcedelete test2.db}
+ catch {forcedelete test2.db-journal}
+ sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ }
+ catchsql2 {
+ SELECT * FROM t1
+ }
+} {0 {a b 1 2}}
+do_test misuse-1.2 {
+ catchsql2 {
+ SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1
+ }
+} {1 {no such function: x_coalesce}}
+do_test misuse-1.3 {
+ sqlite3_create_function $::DB
+ catchsql2 {
+ SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1
+ }
+} {0 {xyz 1}}
+
+# Use the x_sqlite_exec() SQL function to simulate the effect of two
+# threads trying to use the same database at the same time.
+#
+# It used to be prohibited to invoke sqlite_exec() from within a function,
+# but that has changed. The following tests used to cause errors but now
+# they do not.
+#
+ifcapable {utf16} {
+ do_test misuse-1.4 {
+ catchsql2 {
+ SELECT x_sqlite_exec('SELECT * FROM t1') AS xyz;
+ }
+ } {0 {xyz {1 2}}}
+}
+do_test misuse-1.5 {
+ catchsql2 {SELECT * FROM t1}
+} {0 {a b 1 2}}
+do_test misuse-1.6 {
+ catchsql {
+ SELECT * FROM t1
+ }
+} {0 {1 2}}
+
+# Attempt to register a new SQL function while an sqlite_exec() is active.
+#
+do_test misuse-2.1 {
+ db close
+ sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]
+ execsql {
+ SELECT * FROM t1
+ }
+} {1 2}
+do_test misuse-2.2 {
+ catchsql2 {SELECT * FROM t1}
+} {0 {a b 1 2}}
+
+# We used to disallow creating new function from within an exec().
+# But now this is acceptable.
+do_test misuse-2.3 {
+ set v [catch {
+ db eval {SELECT * FROM t1} {} {
+ sqlite3_create_function $::DB
+ }
+ } msg]
+ lappend v $msg
+} {0 {}}
+do_test misuse-2.4 {
+ catchsql2 {SELECT * FROM t1}
+} {0 {a b 1 2}}
+do_test misuse-2.5 {
+ catchsql {
+ SELECT * FROM t1
+ }
+} {0 {1 2}}
+
+# Attempt to register a new SQL aggregate while an sqlite_exec() is active.
+#
+do_test misuse-3.1 {
+ db close
+ sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]
+ execsql {
+ SELECT * FROM t1
+ }
+} {1 2}
+do_test misuse-3.2 {
+ catchsql2 {SELECT * FROM t1}
+} {0 {a b 1 2}}
+
+# We used to disallow creating new function from within an exec().
+# But now this is acceptable.
+do_test misuse-3.3 {
+ set v [catch {
+ db eval {SELECT * FROM t1} {} {
+ sqlite3_create_aggregate $::DB
+ }
+ } msg]
+ lappend v $msg
+} {0 {}}
+do_test misuse-3.4 {
+ catchsql2 {SELECT * FROM t1}
+} {0 {a b 1 2}}
+do_test misuse-3.5 {
+ catchsql {
+ SELECT * FROM t1
+ }
+} {0 {1 2}}
+
+# Attempt to close the database from an sqlite_exec callback.
+#
+# Update for v3: The db cannot be closed because there are active
+# VMs. The sqlite3_close call would return SQLITE_BUSY.
+do_test misuse-4.1 {
+ db close
+ sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]
+ execsql {
+ SELECT * FROM t1
+ }
+} {1 2}
+do_test misuse-4.2 {
+ catchsql2 {SELECT * FROM t1}
+} {0 {a b 1 2}}
+do_test misuse-4.3 {
+ set v [catch {
+ db eval {SELECT * FROM t1} {} {
+ set r [sqlite3_close $::DB]
+ }
+ } msg]
+ lappend v $msg $r
+} {0 {} SQLITE_BUSY}
+do_test misuse-4.4 {
+ # Flush the TCL statement cache here, otherwise the sqlite3_close() will
+ # fail because there are still un-finalized() VDBEs.
+ db cache flush
+ sqlite3_close $::DB
+ catchsql2 {SELECT * FROM t1}
+} {1 {library routine called out of sequence}}
+do_test misuse-4.5 {
+ catchsql {
+ SELECT * FROM t1
+ }
+} {1 {library routine called out of sequence}}
+
+# Attempt to use a database after it has been closed.
+#
+do_test misuse-5.1 {
+ db close
+ sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]
+ execsql {
+ SELECT * FROM t1
+ }
+} {1 2}
+do_test misuse-5.2 {
+ catchsql2 {SELECT * FROM t1}
+} {0 {a b 1 2}}
+do_test misuse-5.3 {
+ db close
+ set r [catch {
+ sqlite3_prepare $::DB {SELECT * FROM t1} -1 TAIL
+ } msg]
+ lappend r $msg
+} {1 {(21) library routine called out of sequence}}
+
+finish_test
diff --git a/test/multiplex.test b/test/multiplex.test
new file mode 100644
index 0000000..3abdcf4
--- /dev/null
+++ b/test/multiplex.test
@@ -0,0 +1,569 @@
+# 2010 October 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+set g_chunk_size [ expr ($::SQLITE_MAX_PAGE_SIZE*16384) ]
+set g_max_chunks 32
+
+# This handles appending the chunk number
+# to the end of the filename. if
+# SQLITE_MULTIPLEX_EXT_OVWR is defined, then
+# it overwrites the last 2 bytes of the
+# file name with the chunk number.
+proc multiplex_name {name chunk} {
+ if {$chunk==0} { return $name }
+ set num [format "%02d" $chunk]
+ ifcapable {multiplex_ext_overwrite} {
+ set name [string range $name 0 [expr [string length $name]-2-1]]
+ }
+ return $name$num
+}
+
+# This saves off the parameters and calls the
+# underlying sqlite3_multiplex_control() API.
+proc multiplex_set {db name chunk_size max_chunks} {
+ global g_chunk_size
+ global g_max_chunks
+ set g_chunk_size [ expr (($chunk_size+($::SQLITE_MAX_PAGE_SIZE-1)) & ~($::SQLITE_MAX_PAGE_SIZE-1)) ]
+ set g_max_chunks $max_chunks
+ set rc [catch {sqlite3_multiplex_control $db $name chunk_size $chunk_size} msg]
+ if { $rc==0 } {
+ set rc [catch {sqlite3_multiplex_control $db $name max_chunks $max_chunks} msg]
+ }
+ list $msg
+}
+
+# This attempts to delete the base file and
+# and files with the chunk extension.
+proc multiplex_delete {name} {
+ global g_max_chunks
+ forcedelete $name
+ for {set i 0} {$i<$g_max_chunks} {incr i} {
+ forcedelete [multiplex_name $name $i]
+ forcedelete [multiplex_name $name-journal $i]
+ forcedelete [multiplex_name $name-wal $i]
+ }
+}
+
+db close
+
+multiplex_delete test.db
+multiplex_delete test2.db
+
+#-------------------------------------------------------------------------
+# multiplex-1.1.*: Test initialize and shutdown.
+
+do_test multiplex-1.1 { sqlite3_multiplex_initialize nosuchvfs 1 } {SQLITE_ERROR}
+do_test multiplex-1.2 { sqlite3_multiplex_initialize "" 1 } {SQLITE_OK}
+do_test multiplex-1.3 { sqlite3_multiplex_initialize "" 1 } {SQLITE_MISUSE}
+do_test multiplex-1.4 { sqlite3_multiplex_shutdown } {SQLITE_OK}
+
+do_test multiplex-1.5 { sqlite3_multiplex_initialize "" 0 } {SQLITE_OK}
+do_test multiplex-1.6 { sqlite3_multiplex_shutdown } {SQLITE_OK}
+do_test multiplex-1.7 { sqlite3_multiplex_initialize "" 1 } {SQLITE_OK}
+do_test multiplex-1.8 { sqlite3_multiplex_shutdown } {SQLITE_OK}
+
+
+do_test multiplex-1.9.1 { sqlite3_multiplex_initialize "" 1 } {SQLITE_OK}
+do_test multiplex-1.9.2 { sqlite3 db test.db } {}
+do_test multiplex-1.9.3 { multiplex_set db main 32768 16 } {SQLITE_OK}
+do_test multiplex-1.9.4 { multiplex_set db main 32768 -1 } {SQLITE_OK}
+do_test multiplex-1.9.6 { multiplex_set db main 31 16 } {SQLITE_OK}
+do_test multiplex-1.9.7 { multiplex_set db main 32768 100 } {SQLITE_OK}
+do_test multiplex-1.9.8 { multiplex_set db main 1073741824 1 } {SQLITE_OK}
+do_test multiplex-1.9.9 { db close } {}
+do_test multiplex-1.9.10 { sqlite3_multiplex_shutdown } {SQLITE_OK}
+
+do_test multiplex-1.10.1 { sqlite3_multiplex_initialize "" 1 } {SQLITE_OK}
+do_test multiplex-1.10.2 { sqlite3 db test.db } {}
+do_test multiplex-1.10.3 { lindex [ catchsql { SELECT multiplex_control(2, 32768); } ] 0 } {0}
+do_test multiplex-1.10.4 { lindex [ catchsql { SELECT multiplex_control(3, -1); } ] 0 } {0}
+do_test multiplex-1.10.6 { lindex [ catchsql { SELECT multiplex_control(2, 31); } ] 0 } {0}
+do_test multiplex-1.10.7 { lindex [ catchsql { SELECT multiplex_control(3, 100); } ] 0 } {0}
+do_test multiplex-1.10.8 { lindex [ catchsql { SELECT multiplex_control(2, 1073741824); } ] 0 } {0}
+do_test multiplex-1.10.9 { db close } {}
+do_test multiplex-1.10.10 { sqlite3_multiplex_shutdown } {SQLITE_OK}
+
+do_test multiplex-1.11.1 { sqlite3_multiplex_initialize "" 1 } {SQLITE_OK}
+do_test multiplex-1.11.2 { sqlite3 db test.db } {}
+do_test multiplex-1.11.3 { sqlite3_multiplex_control db main enable 0 } {SQLITE_OK}
+do_test multiplex-1.11.4 { sqlite3_multiplex_control db main enable 1 } {SQLITE_OK}
+do_test multiplex-1.11.5 { sqlite3_multiplex_control db main enable -1 } {SQLITE_OK}
+do_test multiplex-1.11.6 { db close } {}
+do_test multiplex-1.11.7 { sqlite3_multiplex_shutdown } {SQLITE_OK}
+
+do_test multiplex-1.12.1 { sqlite3_multiplex_initialize "" 1 } {SQLITE_OK}
+do_test multiplex-1.12.2 { sqlite3 db test.db } {}
+do_test multiplex-1.12.3 { lindex [ catchsql { SELECT multiplex_control(1, 0); } ] 0 } {0}
+do_test multiplex-1.12.4 { lindex [ catchsql { SELECT multiplex_control(1, 1); } ] 0 } {0}
+do_test multiplex-1.12.5 { lindex [ catchsql { SELECT multiplex_control(1, -1); } ] 0 } {0}
+do_test multiplex-1.12.6 { db close } {}
+do_test multiplex-1.12.7 { sqlite3_multiplex_shutdown } {SQLITE_OK}
+
+do_test multiplex-1.13.1 { sqlite3_multiplex_initialize "" 1 } {SQLITE_OK}
+do_test multiplex-1.13.2 { sqlite3 db test.db } {}
+do_test multiplex-1.13.3 { lindex [ catchsql { SELECT multiplex_control(-1, 0); } ] 0 } {1}
+do_test multiplex-1.13.4 { lindex [ catchsql { SELECT multiplex_control(4, 1); } ] 0 } {1}
+do_test multiplex-1.13.6 { db close } {}
+do_test multiplex-1.13.7 { sqlite3_multiplex_shutdown } {SQLITE_OK}
+
+#-------------------------------------------------------------------------
+# Some simple warm-body tests with a single database file in rollback
+# mode:
+#
+# multiplex-2.1.*: Test simple writing to a multiplex file.
+#
+# multiplex-2.2.*: More writing.
+#
+# multiplex-2.3.*: Open and close a second db.
+#
+# multiplex-2.4.*: Try to shutdown the multiplex system before closing the db
+# file. Check that this fails and the multiplex system still works
+# afterwards. Then close the database and successfully shut
+# down the multiplex system.
+#
+# multiplex-2.5.*: More reading/writing.
+#
+# multiplex-2.6.*: More reading/writing with varying small chunk sizes, as
+# well as varying journal mode.
+#
+# multiplex-2.7.*: Disable/enable tests.
+#
+
+sqlite3_multiplex_initialize "" 1
+multiplex_set db main 32768 16
+
+forcedelete test.x
+do_test multiplex-2.1.2 {
+ sqlite3 db test.x
+ execsql {
+ PRAGMA page_size=1024;
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA journal_mode=DELETE;
+ }
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, randomblob(1100));
+ INSERT INTO t1 VALUES(2, randomblob(1100));
+ }
+} {}
+do_test multiplex-2.1.3 { file size [multiplex_name test.x 0] } {4096}
+do_test multiplex-2.1.4 {
+ execsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }
+} {}
+
+do_test multiplex-2.2.1 {
+ execsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }
+} {}
+do_test multiplex-2.2.3 { file size [multiplex_name test.x 0] } {6144}
+
+do_test multiplex-2.3.1 {
+ sqlite3 db2 test2.x
+ db2 close
+} {}
+
+
+do_test multiplex-2.4.1 {
+ sqlite3_multiplex_shutdown
+} {SQLITE_MISUSE}
+do_test multiplex-2.4.2 {
+ execsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }
+} {}
+do_test multiplex-2.4.4 { file size [multiplex_name test.x 0] } {7168}
+do_test multiplex-2.4.99 {
+ db close
+ sqlite3_multiplex_shutdown
+} {SQLITE_OK}
+
+
+do_test multiplex-2.5.1 {
+ multiplex_delete test.x
+ sqlite3_multiplex_initialize "" 1
+ sqlite3 db test.x
+ multiplex_set db main 4096 16
+} {SQLITE_OK}
+
+do_test multiplex-2.5.2 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = delete;
+ PRAGMA auto_vacuum = off;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ }
+} {delete}
+
+do_test multiplex-2.5.3 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, randomblob(4000));
+ INSERT INTO t1 VALUES(3, 'three');
+ INSERT INTO t1 VALUES(4, randomblob(4000));
+ INSERT INTO t1 VALUES(5, 'five');
+ INSERT INTO t1 VALUES(6, randomblob($g_chunk_size));
+ INSERT INTO t1 VALUES(7, randomblob($g_chunk_size));
+ }
+} {}
+
+do_test multiplex-2.5.4 {
+ db eval {SELECT * FROM t1 WHERE a=1}
+} {1 one}
+
+do_test multiplex-2.5.5 {
+ db eval {SELECT * FROM t1 WHERE a=3}
+} {3 three}
+
+do_test multiplex-2.5.6 {
+ db eval {SELECT * FROM t1 WHERE a=5}
+} {5 five}
+
+do_test multiplex-2.5.7 {
+ db eval {SELECT a,length(b) FROM t1 WHERE a=2}
+} {2 4000}
+
+do_test multiplex-2.5.8 {
+ db eval {SELECT a,length(b) FROM t1 WHERE a=4}
+} {4 4000}
+
+do_test multiplex-2.5.9 { file size [multiplex_name test.x 0] } [list $g_chunk_size]
+do_test multiplex-2.5.10 { file size [multiplex_name test.x 1] } [list $g_chunk_size]
+
+do_test multiplex-2.5.99 {
+ db close
+ sqlite3_multiplex_shutdown
+} {SQLITE_OK}
+
+
+set all_journal_modes {delete persist truncate memory off}
+foreach jmode $all_journal_modes {
+ for {set sz 151} {$sz<8000} {set sz [expr $sz+419]} {
+
+ do_test multiplex-2.6.1.$sz.$jmode {
+ multiplex_delete test.db
+ sqlite3_multiplex_initialize "" 1
+ sqlite3 db test.db
+ multiplex_set db main $sz 32
+ } {SQLITE_OK}
+
+ do_test multiplex-2.6.2.$sz.$jmode {
+ db eval {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = off;
+ }
+ db eval "PRAGMA journal_mode = $jmode;"
+ } $jmode
+
+ do_test multiplex-2.6.3.$sz.$jmode {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, randomblob($g_chunk_size));
+ }
+ } {}
+
+ do_test multiplex-2.6.4.$sz.$jmode {
+ db eval {SELECT b FROM t1 WHERE a=1}
+ } {one}
+
+ do_test multiplex-2.6.5.$sz.$jmode {
+ db eval {SELECT length(b) FROM t1 WHERE a=2}
+ } [list $g_chunk_size]
+
+ do_test multiplex-2.6.6.$sz.$jmode { file size [multiplex_name test.db 0] } [list $g_chunk_size]
+
+ do_test multiplex-2.6.99.$sz.$jmode {
+ db close
+ sqlite3_multiplex_shutdown
+ } {SQLITE_OK}
+
+ }
+}
+
+do_test multiplex-2.7.1 { multiplex_delete test.db } {}
+do_test multiplex-2.7.2 { sqlite3_multiplex_initialize "" 1 } {SQLITE_OK}
+do_test multiplex-2.7.3 { sqlite3 db test.db } {}
+do_test multiplex-2.7.4 { lindex [ catchsql { SELECT multiplex_control(2, 65536); } ] 0 } {0}
+do_test multiplex-2.7.5 { lindex [ catchsql { SELECT multiplex_control(1, 0); } ] 0 } {0}
+do_test multiplex-2.7.6 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, randomblob(1000));
+ }
+} {}
+# verify only one file, and file size is less than chunks size
+do_test multiplex-2.7.7 { expr ([file size [multiplex_name test.db 0]] < 65536) } {1}
+do_test multiplex-2.7.8 { file exists [multiplex_name test.db 1] } {0}
+do_test multiplex-2.7.9 {
+ execsql {
+ INSERT INTO t1 VALUES(2, randomblob(65536));
+ }
+} {}
+# verify only one file, and file size exceeds chunks size
+do_test multiplex-2.7.10 { expr ([file size [multiplex_name test.db 0]] > 65536) } {1}
+do_test multiplex-2.7.11 { file exists [multiplex_name test.db 1] } {0}
+do_test multiplex-2.7.12 { db close } {}
+do_test multiplex-2.7.13 { sqlite3_multiplex_shutdown } {SQLITE_OK}
+
+#-------------------------------------------------------------------------
+# Try some tests with more than one connection to a database file. Still
+# in rollback mode.
+#
+# multiplex-3.1.*: Two connections to a single database file.
+#
+# multiplex-3.2.*: Two connections to each of several database files (that
+# are in the same multiplex group).
+#
+do_test multiplex-3.1.1 {
+ multiplex_delete test.db
+ sqlite3_multiplex_initialize "" 1
+ sqlite3 db test.db
+ multiplex_set db main 32768 16
+} {SQLITE_OK}
+do_test multiplex-3.1.2 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = delete;
+ PRAGMA auto_vacuum = off;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ }
+ file size [multiplex_name test.db 0]
+} {3072}
+do_test multiplex-3.1.3 {
+ sqlite3 db2 test.db
+ execsql { CREATE TABLE t2(a, b) } db2
+} {}
+do_test multiplex-3.1.4 {
+ execsql { CREATE TABLE t3(a, b) }
+} {}
+do_test multiplex-3.1.5 {
+ catchsql { CREATE TABLE t3(a, b) }
+} {1 {table t3 already exists}}
+do_test multiplex-3.1.6 {
+ db close
+ db2 close
+} {}
+
+do_test multiplex-3.2.1a {
+
+ multiplex_delete test.db
+ multiplex_delete test2.db
+
+ sqlite3 db1a test.db
+ sqlite3 db2a test2.db
+
+ foreach db {db1a db2a} {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = delete;
+ PRAGMA auto_vacuum = off;
+ CREATE TABLE t1(a, b);
+ } $db
+ }
+
+ list [file size [multiplex_name test.db 0]] [file size [multiplex_name test2.db 0]]
+} {2048 2048}
+
+do_test multiplex-3.2.1b {
+ sqlite3 db1b test.db
+ sqlite3 db2b test2.db
+} {}
+
+do_test multiplex-3.2.2 { execsql { INSERT INTO t1 VALUES('x', 'y') } db1a } {}
+do_test multiplex-3.2.3 { execsql { INSERT INTO t1 VALUES('v', 'w') } db1b } {}
+do_test multiplex-3.2.4 { execsql { INSERT INTO t1 VALUES('t', 'u') } db2a } {}
+do_test multiplex-3.2.5 { execsql { INSERT INTO t1 VALUES('r', 's') } db2b } {}
+
+do_test multiplex-3.2.6 {
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1a
+} {}
+do_test multiplex-3.2.7 {
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1b
+} {}
+do_test multiplex-3.2.8 {
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a
+} {}
+do_test multiplex-3.2.9 {
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b
+} {}
+
+do_test multiplex-3.3.1 {
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1a
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1b
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b
+} {}
+
+do_test multiplex-3.2.X {
+ foreach db {db1a db2a db2b db1b} { catch { $db close } }
+} {}
+
+#-------------------------------------------------------------------------
+#
+
+sqlite3_multiplex_initialize "" 1
+multiplex_set db main 32768 16
+
+# Return a list of all currently defined multiplexs.
+proc multiplex_list {} {
+ set allq {}
+ foreach q [sqlite3_multiplex_dump] {
+ lappend allq [lindex $q 0]
+ }
+ return [lsort $allq]
+}
+
+do_test multiplex-4.1.6 {
+ multiplex_delete test2.db
+ sqlite3 db test2.db
+ db eval {CREATE TABLE t2(x); INSERT INTO t2 VALUES('tab-t2');}
+ set res [multiplex_list]
+ list [regexp {test2.db} $res]
+} {1}
+do_test multiplex-4.1.6a {
+ sqlite3 db2 test2.db
+ db2 eval {SELECT * FROM t2}
+} {tab-t2}
+do_test multiplex-4.1.7 {
+ execsql {INSERT INTO t2 VALUES(zeroblob(200000))}
+} {}
+do_test multiplex-4.1.8 {
+ sqlite3 db2 test2.db
+ db2 eval {SELECT count(*) FROM t2}
+} {2}
+do_test multiplex-4.1.8a {
+ db2 eval { DELETE FROM t2 WHERE x = 'tab-t2' }
+} {}
+do_test multiplex-4.1.8b {
+ sqlite3 db2 test2.db
+ db2 eval {SELECT count(*) FROM t2}
+} {1}
+
+
+do_test multiplex-4.1.9 {
+ execsql {INSERT INTO t2 VALUES(zeroblob(200000))}
+} {}
+do_test multiplex-4.1.10 {
+ set res [multiplex_list]
+ list [regexp {test2.db} $res]
+} {1}
+do_test multiplex-4.1.11 {
+ db2 close
+ set res [multiplex_list]
+ list [regexp {test2.db} $res]
+} {1}
+do_test multiplex-4.1.12 {
+ db close
+ multiplex_list
+} {}
+
+
+#-------------------------------------------------------------------------
+# The following tests test that the multiplex VFS handles malloc and IO
+# errors.
+#
+
+sqlite3_multiplex_initialize "" 1
+multiplex_set db main 32768 16
+
+do_faultsim_test multiplex-5.1 -prep {
+ catch {db close}
+} -body {
+ sqlite3 db test2.db
+}
+do_faultsim_test multiplex-5.2 -prep {
+ catch {db close}
+} -body {
+ sqlite3 db test.db
+}
+
+catch { db close }
+multiplex_delete test.db
+multiplex_delete test2.db
+
+do_test multiplex-5.3.prep {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(10, zeroblob(1200));
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test multiplex-5.3 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { DELETE FROM t1 }
+}
+
+do_test multiplex-5.4.1 {
+ catch { db close }
+ multiplex_delete test.db
+ file mkdir test.db
+ list [catch { sqlite3 db test.db } msg] $msg
+} {1 {unable to open database file}}
+catch { delete_file test.db }
+
+do_faultsim_test multiplex-5.5 -prep {
+ catch { sqlite3_multiplex_shutdown }
+} -body {
+ sqlite3_multiplex_initialize "" 1
+ multiplex_set db main 32768 16
+}
+
+#-------------------------------------------------------------------------
+# Test that you can vacuum a multiplex'ed DB.
+
+ifcapable vacuum {
+
+sqlite3_multiplex_shutdown
+do_test multiplex-6.0.0 {
+ multiplex_delete test.db
+ multiplex_delete test.x
+ sqlite3_multiplex_initialize "" 1
+ sqlite3 db test.x
+ multiplex_set db main 4096 16
+} {SQLITE_OK}
+
+do_test multiplex-6.1.0 {
+ execsql {
+ PRAGMA page_size=1024;
+ PRAGMA journal_mode=DELETE;
+ PRAGMA auto_vacuum=OFF;
+ }
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, randomblob($g_chunk_size));
+ INSERT INTO t1 VALUES(2, randomblob($g_chunk_size));
+ }
+} {}
+do_test multiplex-6.2.1 { file size [multiplex_name test.x 0] } [list $g_chunk_size]
+do_test multiplex-6.2.2 { file size [multiplex_name test.x 1] } [list $g_chunk_size]
+
+do_test multiplex-6.3.0 {
+ execsql { VACUUM }
+} {}
+
+do_test multiplex-6.99 {
+ db close
+ multiplex_delete test.x
+ sqlite3_multiplex_shutdown
+} {SQLITE_OK}
+
+}
+
+
+catch { sqlite3_multiplex_shutdown }
+finish_test
diff --git a/test/mutex1.test b/test/mutex1.test
new file mode 100644
index 0000000..4bdf769
--- /dev/null
+++ b/test/mutex1.test
@@ -0,0 +1,192 @@
+# 2008 June 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: mutex1.test,v 1.20 2009/04/23 14:58:40 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !mutex {
+ finish_test
+ return
+}
+if {[info exists tester_do_binarylog]} {
+ finish_test
+ return
+}
+
+sqlite3_reset_auto_extension
+clear_mutex_counters
+
+proc mutex_counters {varname} {
+ upvar $varname var
+ set var(total) 0
+ foreach {name value} [read_mutex_counters] {
+ set var($name) $value
+ incr var(total) $value
+ }
+}
+
+#-------------------------------------------------------------------------
+# Tests mutex1-1.* test that sqlite3_config() returns SQLITE_MISUSE if
+# is called at the wrong time. And that the first time sqlite3_initialize
+# is called it obtains the 'static_master' mutex 3 times and a recursive
+# mutex (sqlite3Config.pInitMutex) twice. Subsequent calls are no-ops
+# that do not require any mutexes.
+#
+do_test mutex1-1.0 {
+ install_mutex_counters 1
+} {SQLITE_MISUSE}
+
+do_test mutex1-1.1 {
+ db close
+ install_mutex_counters 1
+} {SQLITE_MISUSE}
+
+do_test mutex1-1.2 {
+ sqlite3_shutdown
+ install_mutex_counters 1
+} {SQLITE_OK}
+
+do_test mutex1-1.3 {
+ install_mutex_counters 0
+} {SQLITE_OK}
+
+do_test mutex1-1.4 {
+ install_mutex_counters 1
+} {SQLITE_OK}
+
+do_test mutex1-1.5 {
+ mutex_counters counters
+ set counters(total)
+} {0}
+
+do_test mutex1-1.6 {
+ sqlite3_initialize
+} {SQLITE_OK}
+
+do_test mutex1-1.7 {
+ mutex_counters counters
+ # list $counters(total) $counters(static_master)
+ expr {$counters(total)>0}
+} {1}
+
+do_test mutex1-1.8 {
+ clear_mutex_counters
+ sqlite3_initialize
+} {SQLITE_OK}
+
+do_test mutex1-1.9 {
+ mutex_counters counters
+ list $counters(total) $counters(static_master)
+} {0 0}
+
+#-------------------------------------------------------------------------
+# Tests mutex1-2.* test the three thread-safety related modes that
+# can be selected using sqlite3_config:
+#
+# * Serialized mode,
+# * Multi-threaded mode,
+# * Single-threaded mode.
+#
+ifcapable threadsafe&&shared_cache {
+ set enable_shared_cache [sqlite3_enable_shared_cache 1]
+ foreach {mode mutexes} {
+ singlethread {}
+ multithread {
+ fast static_lru static_master static_mem static_open static_prng
+ static_pmem
+ }
+ serialized {
+ fast recursive static_lru static_master static_mem static_open
+ static_prng static_pmem
+ }
+ } {
+
+ do_test mutex1.2.$mode.1 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config $mode
+ } SQLITE_OK
+
+ do_test mutex1.2.$mode.2 {
+ sqlite3_initialize
+ clear_mutex_counters
+ sqlite3 db test.db -nomutex 0 -fullmutex 0
+ catchsql { CREATE TABLE abc(a, b, c) }
+ db eval {
+ INSERT INTO abc VALUES(1, 2, 3);
+ }
+ } {}
+ ifcapable !memorymanage {
+ regsub { static_lru} $mutexes {} mutexes
+ }
+ do_test mutex1.2.$mode.3 {
+ mutex_counters counters
+
+ set res [list]
+ foreach {key value} [array get counters] {
+ if {$key ne "total" && $value > 0} {
+ lappend res $key
+ }
+ }
+ lsort $res
+ } [lsort $mutexes]
+ }
+ sqlite3_enable_shared_cache $enable_shared_cache
+
+ # Open and use a connection in "nomutex" mode. Test that no recursive
+ # mutexes are obtained.
+ do_test mutex1.3.1 {
+ catch {db close}
+ clear_mutex_counters
+ sqlite3 db test.db -nomutex 1
+ execsql { SELECT * FROM abc }
+ } {1 2 3 1 2 3 1 2 3}
+ do_test mutex1.3.2 {
+ mutex_counters counters
+ set counters(recursive)
+ } {0}
+}
+
+# Test the sqlite3_db_mutex() function.
+#
+do_test mutex1.4.1 {
+ catch {db close}
+ sqlite3 db test.db
+ enter_db_mutex db
+ db eval {SELECT 1, 2, 3}
+} {1 2 3}
+do_test mutex1.4.2 {
+ leave_db_mutex db
+ db eval {SELECT 1, 2, 3}
+} {1 2 3}
+do_test mutex1.4.3 {
+ catch {db close}
+ sqlite3 db test.db -nomutex 1
+ enter_db_mutex db
+ db eval {SELECT 1, 2, 3}
+} {1 2 3}
+do_test mutex1.4.4 {
+ leave_db_mutex db
+ db eval {SELECT 1, 2, 3}
+} {1 2 3}
+
+do_test mutex1-X {
+ catch {db close}
+ sqlite3_shutdown
+ clear_mutex_counters
+ install_mutex_counters 0
+ sqlite3_initialize
+} {SQLITE_OK}
+
+autoinstall_test_functions
+finish_test
diff --git a/test/mutex2.test b/test/mutex2.test
new file mode 100644
index 0000000..9dfb03e
--- /dev/null
+++ b/test/mutex2.test
@@ -0,0 +1,105 @@
+# 2008 July 7
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test scripts for deliberate failures of mutex routines.
+#
+# $Id: mutex2.test,v 1.9 2008/10/07 15:25:49 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !mutex {
+ finish_test
+ return
+}
+
+# deinitialize
+#
+catch {db close}
+sqlite3_reset_auto_extension
+sqlite3_shutdown
+install_mutex_counters 1
+
+# Fix the mutex subsystem so that it will not initialize. In other words,
+# make it so that sqlite3_initialize() always fails.
+#
+do_test mutex2-1.1 {
+ set ::disable_mutex_init 10
+ sqlite3_initialize
+} {SQLITE_IOERR}
+do_test mutex2-1.1 {
+ set ::disable_mutex_init 7
+ sqlite3_initialize
+} {SQLITE_NOMEM}
+
+proc utf16 {str} {
+ set r [encoding convertto unicode $str]
+ append r "\x00\x00"
+ return $r
+}
+
+# Now that sqlite3_initialize() is failing, try to run various APIs that
+# require that SQLite be initialized. Verify that they fail.
+#
+do_test mutex2-2.1 {
+ set ::disable_mutex_init 7
+ set rc [catch {sqlite db test.db} msg]
+ lappend rc $msg
+} {1 {}}
+ifcapable utf16 {
+ do_test mutex2-2.2 {
+ set db2 [sqlite3_open16 [utf16 test.db] {}]
+ } {0}
+ do_test mutex2-2.3 {
+ sqlite3_complete16 [utf16 {SELECT * FROM t1;}]
+ } {7}
+}
+do_test mutex2-2.4 {
+ sqlite3_mprintf_int {This is a test %d,%d,%d} 1 2 3
+} {}
+ifcapable load_ext {
+ do_test mutex2-2.5 {
+ sqlite3_auto_extension_sqr
+ } {7}
+}
+do_test mutex2-2.6 {
+ sqlite3_reset_auto_extension
+} {}
+do_test mutex2-2.7 {
+ sqlite3_malloc 10000
+} {0}
+do_test mutex2-2.8 {
+ sqlite3_realloc 0 10000
+} {0}
+ifcapable threadsafe {
+ do_test mutex2-2.9 {
+ alloc_dealloc_mutex
+ } {0}
+}
+do_test mutex2-2.10 {
+ vfs_initfail_test
+} {}
+
+# Restore the system to a functional state
+#
+install_mutex_counters 0
+set disable_mutex_init 0
+autoinstall_test_functions
+
+# Mutex allocation works now.
+#
+
+do_test mutex2-3.1 {
+ set ptr [alloc_dealloc_mutex]
+ expr {$ptr!=0}
+} {1}
+
+
+finish_test
diff --git a/test/nan.test b/test/nan.test
new file mode 100644
index 0000000..df3f65b
--- /dev/null
+++ b/test/nan.test
@@ -0,0 +1,371 @@
+# 2008 April 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3060
+#
+# Make sure IEEE floating point NaN values are handled properly.
+# SQLite should always convert NaN into NULL.
+#
+# Also verify that the decimal to IEEE754 binary conversion routines
+# correctly generate 0.0, +Inf, and -Inf as appropriate for numbers
+# out of range.
+#
+# $Id: nan.test,v 1.5 2008/09/18 11:30:13 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+do_test nan-1.1.1 {
+ db eval {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(x FLOAT);
+ }
+ set ::STMT [sqlite3_prepare db "INSERT INTO t1 VALUES(?)" -1 TAIL]
+ sqlite3_bind_double $::STMT 1 NaN
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT x, typeof(x) FROM t1}
+} {{} null}
+if {$tcl_platform(platform) != "symbian"} {
+ do_realnum_test nan-1.1.2 {
+ sqlite3_bind_double $::STMT 1 +Inf
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {{} null inf real}
+ do_realnum_test nan-1.1.3 {
+ sqlite3_bind_double $::STMT 1 -Inf
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {{} null inf real -inf real}
+ do_realnum_test nan-1.1.4 {
+ sqlite3_bind_double $::STMT 1 -NaN
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {{} null inf real -inf real {} null}
+ do_realnum_test nan-1.1.5 {
+ sqlite3_bind_double $::STMT 1 NaN0
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {{} null inf real -inf real {} null {} null}
+ do_realnum_test nan-1.1.6 {
+ sqlite3_bind_double $::STMT 1 -NaN0
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {{} null inf real -inf real {} null {} null {} null}
+ do_test nan-1.1.7 {
+ db eval {
+ UPDATE t1 SET x=x-x;
+ SELECT x, typeof(x) FROM t1;
+ }
+ } {{} null {} null {} null {} null {} null {} null}
+}
+
+# The following block of tests, nan-1.2.*, are the same as the nan-1.1.*
+# tests above, except that the SELECT queries used to validate data
+# convert floating point values to text internally before returning them
+# to Tcl. This allows the tests to be run on platforms where Tcl has
+# problems converting "inf" and "-inf" from floating point to text format.
+# It also tests the internal float->text conversion routines a bit.
+#
+do_test nan-1.2.1 {
+ db eval {
+ DELETE FROM T1;
+ }
+ sqlite3_bind_double $::STMT 1 NaN
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
+} {{} null}
+do_test nan-1.2.2 {
+ sqlite3_bind_double $::STMT 1 +Inf
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
+} {{} null Inf real}
+do_test nan-1.2.3 {
+ sqlite3_bind_double $::STMT 1 -Inf
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
+} {{} null Inf real -Inf real}
+do_test nan-1.2.4 {
+ sqlite3_bind_double $::STMT 1 -NaN
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
+} {{} null Inf real -Inf real {} null}
+do_test nan-1.2.5 {
+ sqlite3_bind_double $::STMT 1 NaN0
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
+} {{} null Inf real -Inf real {} null {} null}
+do_test nan-1.2.6 {
+ sqlite3_bind_double $::STMT 1 -NaN0
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
+} {{} null Inf real -Inf real {} null {} null {} null}
+do_test nan-1.2.7 {
+ db eval {
+ UPDATE t1 SET x=x-x;
+ SELECT CAST(x AS text), typeof(x) FROM t1;
+ }
+} {{} null {} null {} null {} null {} null {} null}
+
+do_test nan-2.1 {
+ db eval {
+ DELETE FROM T1;
+ }
+ sqlite3_bind_double $::STMT 1 NaN
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ db eval {SELECT x, typeof(x) FROM t1}
+} {{} null}
+sqlite3_finalize $::STMT
+
+# SQLite always converts NaN into NULL so it is not possible to write
+# a NaN value into the database file using SQLite. The following series
+# of tests writes a normal floating point value (0.5) into the database,
+# then writes directly into the database file to change the 0.5 into NaN.
+# Then it reads the value of the database to verify it is converted into
+# NULL.
+#
+do_test nan-3.1 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(0.5);
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=1024;
+ VACUUM;
+ }
+ hexio_read test.db 2040 8
+} {3FE0000000000000}
+do_test nan-3.2 {
+ db eval {
+ SELECT x, typeof(x) FROM t1
+ }
+} {0.5 real}
+do_test nan-3.3 {
+ db close
+ hexio_write test.db 2040 FFF8000000000000
+ sqlite3 db test.db
+ db eval {SELECT x, typeof(x) FROM t1}
+} {{} null}
+do_test nan-3.4 {
+ db close
+ hexio_write test.db 2040 7FF8000000000000
+ sqlite3 db test.db
+ db eval {SELECT x, typeof(x) FROM t1}
+} {{} null}
+do_test nan-3.5 {
+ db close
+ hexio_write test.db 2040 FFFFFFFFFFFFFFFF
+ sqlite3 db test.db
+ db eval {SELECT x, typeof(x) FROM t1}
+} {{} null}
+do_test nan-3.6 {
+ db close
+ hexio_write test.db 2040 7FFFFFFFFFFFFFFF
+ sqlite3 db test.db
+ db eval {SELECT x, typeof(x) FROM t1}
+} {{} null}
+
+# Verify that the sqlite3AtoF routine is able to handle extreme
+# numbers.
+#
+do_test nan-4.1 {
+ db eval {DELETE FROM t1}
+ db eval "INSERT INTO t1 VALUES([string repeat 9 307].0)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {1e+307 real}
+do_test nan-4.2 {
+ db eval {DELETE FROM t1}
+ db eval "INSERT INTO t1 VALUES([string repeat 9 308].0)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {1e+308 real}
+do_test nan-4.3 {
+ db eval {DELETE FROM t1}
+ db eval "INSERT INTO t1 VALUES(-[string repeat 9 307].0)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {-1e+307 real}
+do_test nan-4.4 {
+ db eval {DELETE FROM t1}
+ db eval "INSERT INTO t1 VALUES(-[string repeat 9 308].0)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {-1e+308 real}
+do_test nan-4.5 {
+ db eval {DELETE FROM t1}
+ set big -[string repeat 0 10000][string repeat 9 308].[string repeat 0 10000]
+ db eval "INSERT INTO t1 VALUES($big)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {-1e+308 real}
+do_test nan-4.6 {
+ db eval {DELETE FROM t1}
+ set big [string repeat 0 10000][string repeat 9 308].[string repeat 0 10000]
+ db eval "INSERT INTO t1 VALUES($big)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {1e+308 real}
+
+if {$tcl_platform(platform) != "symbian"} {
+ # Do not run these tests on Symbian, as the Tcl port doesn't like to
+ # convert from floating point value "-inf" to a string.
+ #
+ do_realnum_test nan-4.7 {
+ db eval {DELETE FROM t1}
+ db eval "INSERT INTO t1 VALUES([string repeat 9 309].0)"
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {inf real}
+ do_realnum_test nan-4.8 {
+ db eval {DELETE FROM t1}
+ db eval "INSERT INTO t1 VALUES(-[string repeat 9 309].0)"
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {-inf real}
+}
+do_test nan-4.9 {
+ db eval {DELETE FROM t1}
+ db eval "INSERT INTO t1 VALUES([string repeat 9 309].0)"
+ db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
+} {Inf real}
+do_test nan-4.10 {
+ db eval {DELETE FROM t1}
+ db eval "INSERT INTO t1 VALUES(-[string repeat 9 309].0)"
+ db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
+} {-Inf real}
+
+do_test nan-4.11 {
+ db eval {DELETE FROM t1}
+ db eval "INSERT INTO t1 VALUES(1234.5[string repeat 0 10000]12345)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {1234.5 real}
+do_test nan-4.12 {
+ db eval {DELETE FROM t1}
+ db eval "INSERT INTO t1 VALUES(-1234.5[string repeat 0 10000]12345)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {-1234.5 real}
+do_test nan-4.13 {
+ db eval {DELETE FROM t1}
+ set small [string repeat 0 10000].[string repeat 0 324][string repeat 9 10000]
+ db eval "INSERT INTO t1 VALUES($small)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {0.0 real}
+do_test nan-4.14 {
+ db eval {DELETE FROM t1}
+ set small \
+ -[string repeat 0 10000].[string repeat 0 324][string repeat 9 10000]
+ db eval "INSERT INTO t1 VALUES($small)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {0.0 real}
+
+# These tests test some really, really small floating point numbers.
+#
+if {$tcl_platform(platform) != "symbian"} {
+ # These two are not run on symbian because tcl has trouble converting
+ # the very small numbers back to text form (probably due to a difference
+ # in the sprintf() implementation).
+ #
+ do_test nan-4.15 {
+ db eval {DELETE FROM t1}
+ set small \
+ [string repeat 0 10000].[string repeat 0 323][string repeat 9 10000]
+ db eval "INSERT INTO t1 VALUES($small)"
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {9.88131291682493e-324 real}
+ do_test nan-4.16 {
+ db eval {DELETE FROM t1}
+ set small \
+ -[string repeat 0 10000].[string repeat 0 323][string repeat 9 10000]
+ db eval "INSERT INTO t1 VALUES($small)"
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {-9.88131291682493e-324 real}
+}
+do_test nan-4.17 {
+ db eval {DELETE FROM t1}
+ set small [string repeat 0 10000].[string repeat 0 323][string repeat 9 10000]
+ db eval "INSERT INTO t1 VALUES($small)"
+ db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
+} {9.88131291682493e-324 real}
+do_test nan-4.18 {
+ db eval {DELETE FROM t1}
+ set small \
+ -[string repeat 0 10000].[string repeat 0 323][string repeat 9 10000]
+ db eval "INSERT INTO t1 VALUES($small)"
+ db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
+} {-9.88131291682493e-324 real}
+
+do_realnum_test nan-4.20 {
+ db eval {DELETE FROM t1}
+ set big [string repeat 9 10000].0e-9000
+ db eval "INSERT INTO t1 VALUES($big)"
+ db eval {SELECT x, typeof(x) FROM t1}
+} {inf real}
+
+do_realnum_test nan-4.30 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('2.5e+9999');
+ SELECT x, typeof(x) FROM t1;
+ }
+} {inf real}
+do_realnum_test nan-4.31 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('2.5e+10000');
+ SELECT x, typeof(x) FROM t1;
+ }
+} {inf real}
+
+do_realnum_test nan-4.32 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('2.5e-9999');
+ SELECT x, typeof(x) FROM t1;
+ }
+} {0.0 real}
+do_realnum_test nan-4.33 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('2.5e-10000');
+ SELECT x, typeof(x) FROM t1;
+ }
+} {0.0 real}
+do_realnum_test nan-4.34 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('2.5e2147483650');
+ SELECT x, typeof(x) FROM t1;
+ }
+} {inf real}
+do_realnum_test nan-4.35 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('2.5e-2147483650');
+ SELECT x, typeof(x) FROM t1;
+ }
+} {0.0 real}
+
+
+
+
+
+finish_test
diff --git a/test/notify1.test b/test/notify1.test
new file mode 100644
index 0000000..be6a122
--- /dev/null
+++ b/test/notify1.test
@@ -0,0 +1,500 @@
+# 2009 March 04
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the sqlite3_unlock_notify() API.
+#
+# $Id: notify1.test,v 1.4 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !unlock_notify||!shared_cache {
+ finish_test
+ return
+}
+db close
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+#-------------------------------------------------------------------------
+# Warm body test. Test that an unlock-notify callback can be registered
+# and that it is invoked.
+#
+do_test notify1-1.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql { CREATE TABLE t1(a, b) }
+} {}
+do_test notify1-1.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ catchsql { INSERT INTO t1 VALUES(3, 4) } db2
+} {1 {database table is locked}}
+do_test notify1-1.3 {
+ set zScript ""
+ db2 unlock_notify {
+ set zScript "db2 eval { INSERT INTO t1 VALUES(3, 4) }"
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2}
+do_test notify1-1.4 {
+ set zScript
+} {}
+do_test notify1-1.5 {
+ execsql { COMMIT }
+ eval $zScript
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+
+#-------------------------------------------------------------------------
+# Verify that invoking the "unlock_notify" method with no arguments
+# (which is the equivalent of invoking sqlite3_unlock_notify() with
+# a NULL xNotify argument) cancels a pending notify callback.
+#
+do_test notify1-1.11 {
+ execsql { DROP TABLE t1; CREATE TABLE t1(a, b) }
+} {}
+do_test notify1-1.12 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ catchsql { INSERT INTO t1 VALUES(3, 4) } db2
+} {1 {database table is locked}}
+do_test notify1-1.13 {
+ set zScript ""
+ db2 unlock_notify {
+ set zScript "db2 eval { INSERT INTO t1 VALUES(3, 4) }"
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2}
+do_test notify1-1.14 {
+ set zScript
+} {}
+do_test notify1-1.15 {
+ db2 unlock_notify
+ execsql { COMMIT }
+ eval $zScript
+ execsql { SELECT * FROM t1 }
+} {1 2}
+
+#-------------------------------------------------------------------------
+# The following tests, notify1-2.*, test that deadlock is detected
+# correctly.
+#
+do_test notify1-2.1 {
+ execsql {
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES('I', 'II');
+ }
+} {}
+
+#
+# Test for simple deadlock involving two database connections.
+#
+# 1. Grab a write-lock on t1 with [db]. Then grab a read-lock on t2 with [db2].
+# 2. Try to grab a read-lock on t1 with [db2] (fails).
+# 3. Have [db2] wait on the read-lock it failed to obtain in step 2.
+# 4. Try to grab a write-lock on t2 with [db] (fails).
+# 5. Try to have [db] wait on the lock from step 4. Fails, as the system
+# would be deadlocked (since [db2] is already waiting on [db], and this
+# operation would have [db] wait on [db2]).
+#
+do_test notify1-2.2.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(5, 6);
+ }
+ execsql {
+ BEGIN;
+ SELECT * FROM t2;
+ } db2
+} {I II}
+do_test notify1-2.2.2 {
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database table is locked: t1}}
+do_test notify1-2.2.3 {
+ db2 unlock_notify {lappend unlock_notify db2}
+} {}
+do_test notify1-2.2.4 {
+ catchsql { INSERT INTO t2 VALUES('III', 'IV') }
+} {1 {database table is locked: t2}}
+do_test notify1-2.2.5 {
+ set rc [catch { db unlock_notify {lappend unlock_notify db} } msg]
+ list $rc $msg
+} {1 {database is deadlocked}}
+
+#
+# Test for slightly more complex deadlock involving three database
+# connections: db, db2 and db3.
+#
+do_test notify1-2.3.1 {
+ db close
+ db2 close
+ forcedelete test.db test2.db test3.db
+ foreach con {db db2 db3} {
+ sqlite3 $con test.db
+ $con eval { ATTACH 'test2.db' AS aux2 }
+ $con eval { ATTACH 'test3.db' AS aux3 }
+ }
+ execsql {
+ CREATE TABLE main.t1(a, b);
+ CREATE TABLE aux2.t2(a, b);
+ CREATE TABLE aux3.t3(a, b);
+ }
+} {}
+do_test notify1-2.3.2 {
+ execsql { BEGIN ; INSERT INTO t1 VALUES(1, 2) } db
+ execsql { BEGIN ; INSERT INTO t2 VALUES(1, 2) } db2
+ execsql { BEGIN ; INSERT INTO t3 VALUES(1, 2) } db3
+} {}
+do_test notify1-2.3.3 {
+ catchsql { SELECT * FROM t2 } db
+} {1 {database table is locked: t2}}
+do_test notify1-2.3.4 {
+ catchsql { SELECT * FROM t3 } db2
+} {1 {database table is locked: t3}}
+do_test notify1-2.3.5 {
+ catchsql { SELECT * FROM t1 } db3
+} {1 {database table is locked: t1}}
+do_test notify1-2.3.6 {
+ set lUnlock [list]
+ db unlock_notify {lappend lUnlock db}
+ db2 unlock_notify {lappend lUnlock db2}
+} {}
+do_test notify1-2.3.7 {
+ set rc [catch { db3 unlock_notify {lappend lUnlock db3} } msg]
+ list $rc $msg
+} {1 {database is deadlocked}}
+do_test notify1-2.3.8 {
+ execsql { COMMIT }
+ set lUnlock
+} {}
+do_test notify1-2.3.9 {
+ db3 unlock_notify {lappend lUnlock db3}
+ set lUnlock
+} {db3}
+do_test notify1-2.3.10 {
+ execsql { COMMIT } db2
+ set lUnlock
+} {db3 db}
+do_test notify1-2.3.11 {
+ execsql { COMMIT } db3
+ set lUnlock
+} {db3 db db2}
+catch { db3 close }
+catch { db2 close }
+catch { db close }
+
+#-------------------------------------------------------------------------
+# The following tests, notify1-3.* and notify1-4.*, test that callbacks
+# can be issued when there are many (>16) connections waiting on a single
+# unlock event.
+#
+foreach {tn nConn} {3 20 4 76} {
+ do_test notify1-$tn.1 {
+ sqlite3 db test.db
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('a', 'b');
+ }
+ } {}
+ set lUnlock [list]
+ set lUnlockFinal [list]
+ for {set ii 1} {$ii <= $nConn} {incr ii} {
+ do_test notify1-$tn.2.$ii.1 {
+ set cmd "db$ii"
+ sqlite3 $cmd test.db
+ catchsql { SELECT * FROM t1 } $cmd
+ } {1 {database table is locked: t1}}
+ do_test notify1-$tn.2.$ii.2 {
+ $cmd unlock_notify "lappend lUnlock $ii"
+ } {}
+ lappend lUnlockFinal $ii
+ }
+ do_test notify1-$tn.3 {
+ set lUnlock
+ } {}
+ do_test notify1-$tn.4 {
+ execsql {COMMIT}
+ lsort -integer $lUnlock
+ } $lUnlockFinal
+ do_test notify1-$tn.5 {
+ for {set ii 1} {$ii <= $nConn} {incr ii} {
+ "db$ii" close
+ }
+ } {}
+}
+db close
+
+#-------------------------------------------------------------------------
+# These tests, notify1-5.*, test that a malloc() failure that occurs while
+# allocating an array to use as an argument to an unlock-notify callback
+# is handled correctly.
+#
+source $testdir/malloc_common.tcl
+do_malloc_test notify1-5 -tclprep {
+ set ::lUnlock [list]
+ execsql {
+ CREATE TABLE t1(a, b);
+ BEGIN;
+ INSERT INTO t1 VALUES('a', 'b');
+ }
+ for {set ii 1} {$ii <= 60} {incr ii} {
+ set cmd "db$ii"
+ sqlite3 $cmd test.db
+ catchsql { SELECT * FROM t1 } $cmd
+ $cmd unlock_notify "lappend ::lUnlock $ii"
+ }
+} -sqlbody {
+ COMMIT;
+} -cleanup {
+ # One of two things should have happened:
+ #
+ # 1) The transaction opened by [db] was not committed. No unlock-notify
+ # callbacks were invoked, OR
+ # 2) The transaction opened by [db] was committed and 60 unlock-notify
+ # callbacks were invoked.
+ #
+ do_test notify1-5.systemstate {
+ expr { ([llength $::lUnlock]==0 && [sqlite3_get_autocommit db]==0)
+ || ([llength $::lUnlock]==60 && [sqlite3_get_autocommit db]==1)
+ }
+ } {1}
+ for {set ii 1} {$ii <= 60} {incr ii} { "db$ii" close }
+}
+
+#-------------------------------------------------------------------------
+# Test cases notify1-6.* test cases where the following occur:
+#
+# notify1-6.1.*: Test encountering an SQLITE_LOCKED error when the
+# "blocking connection" has already been set by a previous
+# SQLITE_LOCKED.
+#
+# notify1-6.2.*: Test encountering an SQLITE_LOCKED error when already
+# waiting on an unlock-notify callback.
+#
+# notify1-6.3.*: Test that if an SQLITE_LOCKED error is encountered while
+# already waiting on an unlock-notify callback, and then
+# the blocker that caused the SQLITE_LOCKED commits its
+# transaction, the unlock-notify callback is not invoked.
+#
+# notify1-6.4.*: Like 6.3.*, except that instead of the second blocker
+# committing its transaction, the first does. The
+# unlock-notify callback is therefore invoked.
+#
+db close
+do_test notify1-6.1.1 {
+ forcedelete test.db test2.db
+ foreach conn {db db2 db3} {
+ sqlite3 $conn test.db
+ execsql { ATTACH 'test2.db' AS two } $conn
+ }
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE two.t2(a, b);
+ }
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ } db2
+ execsql {
+ BEGIN;
+ INSERT INTO t2 VALUES(1, 2);
+ } db3
+} {}
+do_test notify1-6.1.2 {
+ catchsql { SELECT * FROM t2 }
+} {1 {database table is locked: t2}}
+do_test notify1-6.1.3 {
+ catchsql { SELECT * FROM t1 }
+} {1 {database table is locked: t1}}
+
+do_test notify1-6.2.1 {
+ set unlocked 0
+ db unlock_notify {set unlocked 1}
+ set unlocked
+} {0}
+do_test notify1-6.2.2 {
+ catchsql { SELECT * FROM t2 }
+} {1 {database table is locked: t2}}
+do_test notify1-6.2.3 {
+ execsql { COMMIT } db2
+ set unlocked
+} {1}
+
+do_test notify1-6.3.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ } db2
+} {}
+do_test notify1-6.3.2 {
+ catchsql { SELECT * FROM t1 }
+} {1 {database table is locked: t1}}
+do_test notify1-6.3.3 {
+ set unlocked 0
+ db unlock_notify {set unlocked 1}
+ set unlocked
+} {0}
+do_test notify1-6.3.4 {
+ catchsql { SELECT * FROM t2 }
+} {1 {database table is locked: t2}}
+do_test notify1-6.3.5 {
+ execsql { COMMIT } db3
+ set unlocked
+} {0}
+
+do_test notify1-6.4.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t2 VALUES(3, 4);
+ } db3
+ catchsql { SELECT * FROM t2 }
+} {1 {database table is locked: t2}}
+do_test notify1-6.4.2 {
+ execsql { COMMIT } db2
+ set unlocked
+} {1}
+do_test notify1-6.4.3 {
+ execsql { COMMIT } db3
+} {}
+db close
+db2 close
+db3 close
+
+#-------------------------------------------------------------------------
+# Test cases notify1-7.* tests that when more than one distinct
+# unlock-notify function is registered, all are invoked correctly.
+#
+proc unlock_notify {} {
+ incr ::unlock_notify
+}
+do_test notify1-7.1 {
+ foreach conn {db db2 db3} {
+ sqlite3 $conn test.db
+ }
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(5, 6);
+ }
+} {}
+do_test notify1-7.2 {
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database table is locked: t1}}
+do_test notify1-7.3 {
+ catchsql { SELECT * FROM t1 } db3
+} {1 {database table is locked: t1}}
+do_test notify1-7.4 {
+ set unlock_notify 0
+ db2 unlock_notify unlock_notify
+ sqlite3_unlock_notify db3
+} {SQLITE_OK}
+do_test notify1-7.5 {
+ set unlock_notify
+} {0}
+do_test notify1-7.6 {
+ execsql { COMMIT }
+ set unlock_notify
+} {2}
+
+#-------------------------------------------------------------------------
+# Test cases notify1-8.* tests that the correct SQLITE_LOCKED extended
+# error code is returned in various scenarios.
+#
+do_test notify1-8.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(7, 8);
+ }
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database table is locked: t1}}
+do_test notify1-8.2 {
+ sqlite3_extended_errcode db2
+} {SQLITE_LOCKED_SHAREDCACHE}
+
+do_test notify1-8.3 {
+ execsql {
+ COMMIT;
+ BEGIN EXCLUSIVE;
+ }
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database schema is locked: main}}
+do_test notify1-8.4 {
+ sqlite3_extended_errcode db2
+} {SQLITE_LOCKED_SHAREDCACHE}
+
+do_test notify1-8.X {
+ execsql { COMMIT }
+} {}
+
+#-------------------------------------------------------------------------
+# Test cases notify1-9.* test the shared-cache 'pending-lock' feature.
+#
+do_test notify1-9.1 {
+ execsql {
+ CREATE TABLE t2(a, b);
+ BEGIN;
+ SELECT * FROM t1;
+ } db2
+} {1 2 3 4 5 6 7 8}
+do_test notify1-9.2 {
+ execsql { SELECT * FROM t1 } db3
+} {1 2 3 4 5 6 7 8}
+do_test notify1-9.3 {
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(9, 10);
+ }
+} {1 {database table is locked: t1}}
+do_test notify1-9.4 {
+ catchsql { SELECT * FROM t2 } db3
+} {1 {database table is locked}}
+do_test notify1-9.5 {
+ execsql { COMMIT } db2
+ execsql { SELECT * FROM t2 } db3
+} {}
+do_test notify1-9.6 {
+ execsql { COMMIT }
+} {}
+
+do_test notify1-9.7 {
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ } db2
+} {1 2 3 4 5 6 7 8}
+do_test notify1-9.8 {
+ execsql { SELECT * FROM t1 } db3
+} {1 2 3 4 5 6 7 8}
+do_test notify1-9.9 {
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(9, 10);
+ }
+} {1 {database table is locked: t1}}
+do_test notify1-9.10 {
+ catchsql { SELECT * FROM t2 } db3
+} {1 {database table is locked}}
+do_test notify1-9.11 {
+ execsql { COMMIT }
+ execsql { SELECT * FROM t2 } db3
+} {}
+do_test notify1-9.12 {
+ execsql { COMMIT } db2
+} {}
+
+db close
+db2 close
+db3 close
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/notify2.test b/test/notify2.test
new file mode 100644
index 0000000..4016b6d
--- /dev/null
+++ b/test/notify2.test
@@ -0,0 +1,242 @@
+# 2009 March 04
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: notify2.test,v 1.7 2009/03/30 11:59:31 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+if {[run_thread_tests]==0} { finish_test ; return }
+ifcapable !unlock_notify||!shared_cache { finish_test ; return }
+
+# The tests in this file test the sqlite3_blocking_step() function in
+# test_thread.c. sqlite3_blocking_step() is not an SQLite API function,
+# it is just a demonstration of how the sqlite3_unlock_notify() function
+# can be used to synchronize multi-threaded access to SQLite databases
+# in shared-cache mode.
+#
+# Since the implementation of sqlite3_blocking_step() is included on the
+# website as example code, it is important to test that it works.
+#
+# notify2-1.*:
+#
+# This test uses $nThread threads. Each thread opens the main database
+# and attaches two other databases. Each database contains a single table.
+#
+# Each thread repeats transactions over and over for 20 seconds. Each
+# transaction consists of 3 operations. Each operation is either a read
+# or a write of one of the tables. The read operations verify an invariant
+# to make sure that things are working as expected. If an SQLITE_LOCKED
+# error is returned the current transaction is rolled back immediately.
+#
+# This exercise is repeated twice, once using sqlite3_step(), and the
+# other using sqlite3_blocking_step(). The results are compared to ensure
+# that sqlite3_blocking_step() resulted in higher transaction throughput.
+#
+
+db close
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+# Number of threads to run simultaneously.
+#
+set nThread 6
+set nSecond 5
+
+# The Tcl script executed by each of the $nThread threads used by this test.
+#
+set ThreadProgram {
+
+ # Proc used by threads to execute SQL.
+ #
+ proc execsql_blocking {db zSql} {
+ set lRes [list]
+ set rc SQLITE_OK
+
+set sql $zSql
+
+ while {$rc=="SQLITE_OK" && $zSql ne ""} {
+ set STMT [$::xPrepare $db $zSql -1 zSql]
+ while {[set rc [$::xStep $STMT]] eq "SQLITE_ROW"} {
+ for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {
+ lappend lRes [sqlite3_column_text $STMT 0]
+ }
+ }
+ set rc [sqlite3_finalize $STMT]
+ }
+
+ if {$rc != "SQLITE_OK"} { error "$rc $sql [sqlite3_errmsg $db]" }
+ return $lRes
+ }
+
+ proc execsql_retry {db sql} {
+ set msg "SQLITE_LOCKED blah..."
+ while { [string match SQLITE_LOCKED* $msg] } {
+ catch { execsql_blocking $db $sql } msg
+ }
+ }
+
+ proc select_one {args} {
+ set n [llength $args]
+ lindex $args [expr int($n*rand())]
+ }
+
+ proc opendb {} {
+ # Open a database connection. Attach the two auxillary databases.
+ set ::DB [sqlite3_open test.db]
+ execsql_retry $::DB { ATTACH 'test2.db' AS aux2; }
+ execsql_retry $::DB { ATTACH 'test3.db' AS aux3; }
+ }
+
+ opendb
+
+ #after 2000
+
+ # This loop runs for ~20 seconds.
+ #
+ set iStart [clock_seconds]
+ while { ([clock_seconds]-$iStart) < $nSecond } {
+
+ # Each transaction does 3 operations. Each operation is either a read
+ # or write of a randomly selected table (t1, t2 or t3). Set the variables
+ # $SQL(1), $SQL(2) and $SQL(3) to the SQL commands used to implement
+ # each operation.
+ #
+ for {set ii 1} {$ii <= 3} {incr ii} {
+ foreach {tbl database} [select_one {t1 main} {t2 aux2} {t3 aux3}] {}
+
+ set SQL($ii) [string map [list xxx $tbl yyy $database] [select_one {
+ SELECT
+ (SELECT b FROM xxx WHERE a=(SELECT max(a) FROM xxx))==total(a)
+ FROM xxx WHERE a!=(SELECT max(a) FROM xxx);
+ } {
+ DELETE FROM xxx WHERE a<(SELECT max(a)-100 FROM xxx);
+ INSERT INTO xxx SELECT NULL, total(a) FROM xxx;
+ } {
+ CREATE INDEX IF NOT EXISTS yyy.xxx_i ON xxx(b);
+ } {
+ DROP INDEX IF EXISTS yyy.xxx_i;
+ }
+ ]]
+ }
+
+ # Execute the SQL transaction.
+ #
+ set rc [catch { execsql_blocking $::DB "
+ BEGIN;
+ $SQL(1);
+ $SQL(2);
+ $SQL(3);
+ COMMIT;
+ "
+ } msg]
+
+ if {$rc && [string match "SQLITE_LOCKED*" $msg]
+ || [string match "SQLITE_SCHEMA*" $msg]
+ } {
+ # Hit an SQLITE_LOCKED error. Rollback the current transaction.
+ set rc [catch { execsql_blocking $::DB ROLLBACK } msg]
+ if {$rc && [string match "SQLITE_LOCKED*" $msg]} {
+ sqlite3_close $::DB
+ opendb
+ }
+ } elseif {$rc} {
+ # Hit some other kind of error. This is a malfunction.
+ error $msg
+ } else {
+ # No error occured. Check that any SELECT statements in the transaction
+ # returned "1". Otherwise, the invariant was false, indicating that
+ # some malfunction has occured.
+ foreach r $msg { if {$r != 1} { puts "Invariant check failed: $msg" } }
+ }
+ }
+
+ # Close the database connection and return 0.
+ #
+ sqlite3_close $::DB
+ expr 0
+}
+
+foreach {iTest xStep xPrepare} {
+ 1 sqlite3_blocking_step sqlite3_blocking_prepare_v2
+ 2 sqlite3_step sqlite3_nonblocking_prepare_v2
+} {
+ forcedelete test.db test2.db test3.db
+
+ set ThreadSetup "set xStep $xStep;set xPrepare $xPrepare;set nSecond $nSecond"
+
+ # Set up the database schema used by this test. Each thread opens file
+ # test.db as the main database, then attaches files test2.db and test3.db
+ # as auxillary databases. Each file contains a single table (t1, t2 and t3, in
+ # files test.db, test2.db and test3.db, respectively).
+ #
+ do_test notify2-$iTest.1.1 {
+ sqlite3 db test.db
+ execsql {
+ ATTACH 'test2.db' AS aux2;
+ ATTACH 'test3.db' AS aux3;
+ CREATE TABLE main.t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE aux2.t2(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE aux3.t3(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 SELECT NULL, 0;
+ INSERT INTO t2 SELECT NULL, 0;
+ INSERT INTO t3 SELECT NULL, 0;
+ }
+ } {}
+ do_test notify2-$iTest.1.2 {
+ db close
+ } {}
+
+
+ # Launch $nThread threads. Then wait for them to finish.
+ #
+ puts "Running $xStep test for $nSecond seconds"
+ unset -nocomplain finished
+ for {set ii 0} {$ii < $nThread} {incr ii} {
+ thread_spawn finished($ii) $ThreadSetup $ThreadProgram
+ }
+ for {set ii 0} {$ii < $nThread} {incr ii} {
+ do_test notify2-$iTest.2.$ii {
+ if {![info exists finished($ii)]} { vwait finished($ii) }
+ set finished($ii)
+ } {0}
+ }
+
+ # Count the total number of succesful writes.
+ do_test notify2-$iTest.3.1 {
+ sqlite3 db test.db
+ execsql {
+ ATTACH 'test2.db' AS aux2;
+ ATTACH 'test3.db' AS aux3;
+ }
+ set anWrite($xStep) [execsql {
+ SELECT (SELECT max(a) FROM t1)
+ + (SELECT max(a) FROM t2)
+ + (SELECT max(a) FROM t3)
+ }]
+ db close
+ } {}
+}
+
+# The following tests checks to make sure sqlite3_blocking_step() is
+# faster than sqlite3_step(). blocking_step() is always faster on
+# multi-core and is usually faster on single-core. But sometimes, by
+# chance, step() will be faster on a single core, in which case the
+# following test will fail.
+#
+puts "The following test seeks to demonstrate that the sqlite3_unlock_notify()"
+puts "interface helps multi-core systems to run faster. This test sometimes"
+puts "fails on single-core machines."
+puts [array get anWrite]
+do_test notify2-3 {
+ expr {$anWrite(sqlite3_blocking_step) > $anWrite(sqlite3_step)}
+} {1}
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/notify3.test b/test/notify3.test
new file mode 100644
index 0000000..446f010
--- /dev/null
+++ b/test/notify3.test
@@ -0,0 +1,153 @@
+# 2010 June 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the sqlite3_unlock_notify() API.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# This script only runs if shared-cache and unlock-notify are available.
+#
+ifcapable !unlock_notify||!shared_cache {
+ finish_test
+ return
+}
+
+set esc [sqlite3_enable_shared_cache 1]
+
+sqlite3 db test.db
+forcedelete test.db2 test.db2-journal test.db2-wal
+sqlite3 db2 test.db2
+
+do_test notify3-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('t1 A', 't1 B');
+ }
+} {}
+do_test notify3-1.2 {
+ execsql {
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES('t2 A', 't2 B');
+ } db2
+} {}
+
+do_test notify3-1.3 {
+ execsql {
+ BEGIN EXCLUSIVE;
+ INSERT INTO t2 VALUES('t2 C', 't2 D');
+ } db2
+} {}
+do_test notify3-1.4 {
+ catchsql { ATTACH 'test.db2' AS aux }
+} {0 {}}
+
+do_test notify3-1.5 {
+ catchsql { SELECT * FROM t2 }
+} {1 {database schema is locked: aux}}
+
+do_test notify3-1.6 {
+ list [sqlite3_errcode db] [sqlite3_extended_errcode db]
+} {SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE}
+
+do_test notify3-1.7 {
+ sqlite3_extended_result_codes db 1
+ catch { set ::stmt [sqlite3_prepare_v2 db "SELECT * FROM t2" -1 tail] } msg
+ set msg
+} {(262) database schema is locked: aux}
+
+do_test notify3-1.8 {
+ set ::when 1
+ db unlock_notify { set ::res $::when }
+ set ::when 2
+ execsql { COMMIT } db2
+ set ::res
+} {2}
+do_test notify3-1.9 {
+ catchsql { SELECT * FROM t2 }
+} {0 {{t2 A} {t2 B} {t2 C} {t2 D}}}
+db close
+
+
+set err {{1 {unable to open database: test.db2}}}
+set noerr {{0 {}}}
+
+# When a new database is attached, the connection doing the attaching
+# tries to load any unloaded schemas for both the new database and any
+# already attached databases (including the main database). If it is
+# unable to load any such schemas, then the ATTACH statement fails.
+#
+# This block tests that if the loading of schemas as a result of an
+# ATTACH fails due to locks on the schema table held by other shared-cache
+# connections the extended error code is SQLITE_LOCKED_SHAREDCACHE and
+# it is possible to use the unlock-notify mechanism to determine when
+# the ATTACH might succeed.
+#
+# This test does not work for test-permutations that specify SQL to
+# be executed as part of the [sqlite3] command that opens the database.
+# Executing such SQL causes SQLite to load the database schema into memory
+# earlier than expected, causing test cases to fail.
+#
+if {[presql] == ""} {
+ foreach {
+ tn
+ db1_loaded
+ db2_loaded
+ enable_extended_errors
+ result
+ error1 error2
+ } "
+ 0 0 0 0 $err SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE
+ 1 0 0 1 $err SQLITE_LOCKED_SHAREDCACHE SQLITE_LOCKED_SHAREDCACHE
+ 2 0 1 0 $err SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE
+ 3 0 1 1 $err SQLITE_LOCKED_SHAREDCACHE SQLITE_LOCKED_SHAREDCACHE
+ 4 1 0 0 $err SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE
+ 5 1 0 1 $err SQLITE_LOCKED_SHAREDCACHE SQLITE_LOCKED_SHAREDCACHE
+ 6 1 1 0 $noerr SQLITE_OK SQLITE_OK
+ 7 1 1 1 $noerr SQLITE_OK SQLITE_OK
+ " {
+
+ do_test notify3-2.$tn.1 {
+ catch { db1 close }
+ catch { db2 close }
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db2
+
+ sqlite3_extended_result_codes db1 $enable_extended_errors
+ sqlite3_extended_result_codes db2 $enable_extended_errors
+
+ if { $db1_loaded } { db1 eval "SELECT * FROM sqlite_master" }
+ if { $db2_loaded } { db2 eval "SELECT * FROM sqlite_master" }
+
+ db2 eval "BEGIN EXCLUSIVE"
+ catchsql "ATTACH 'test.db2' AS two" db1
+ } $result
+
+ do_test notify3-2.$tn.2 {
+ list [sqlite3_errcode db1] [sqlite3_extended_errcode db1]
+ } [list $error1 $error2]
+
+ do_test notify3-2.$tn.3 {
+ db1 unlock_notify {set invoked 1}
+ set invoked 0
+ db2 eval commit
+ set invoked
+ } [lindex $result 0]
+ }
+}
+catch { db1 close }
+catch { db2 close }
+
+
+sqlite3_enable_shared_cache $esc
+finish_test
+
diff --git a/test/notnull.test b/test/notnull.test
new file mode 100644
index 0000000..240aaba
--- /dev/null
+++ b/test/notnull.test
@@ -0,0 +1,539 @@
+# 2002 January 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the NOT NULL constraint.
+#
+# $Id: notnull.test,v 1.4 2006/01/17 09:35:02 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !conflict {
+ finish_test
+ return
+}
+
+do_test notnull-1.0 {
+ execsql {
+ CREATE TABLE t1 (
+ a NOT NULL,
+ b NOT NULL DEFAULT 5,
+ c NOT NULL ON CONFLICT REPLACE DEFAULT 6,
+ d NOT NULL ON CONFLICT IGNORE DEFAULT 7,
+ e NOT NULL ON CONFLICT ABORT DEFAULT 8
+ );
+ SELECT * FROM t1;
+ }
+} {}
+do_test notnull-1.1 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 2 3 4 5}}
+do_test notnull-1.2 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-1.3 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {}}
+do_test notnull-1.4 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-1.5 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-1.6 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 5 3 4 5}}
+do_test notnull-1.7 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR IGNORE INTO t1(a,c,d,e) VALUES(1,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 5 3 4 5}}
+do_test notnull-1.8 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR REPLACE INTO t1(a,c,d,e) VALUES(1,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 5 3 4 5}}
+do_test notnull-1.9 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR ABORT INTO t1(a,c,d,e) VALUES(1,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 5 3 4 5}}
+do_test notnull-1.10 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.b may not be NULL}}
+do_test notnull-1.11 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {}}
+do_test notnull-1.12 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 5 3 4 5}}
+do_test notnull-1.13 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 2 6 4 5}}
+do_test notnull-1.14 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {}}
+do_test notnull-1.15 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 2 6 4 5}}
+do_test notnull-1.16 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.c may not be NULL}}
+do_test notnull-1.17 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.d may not be NULL}}
+do_test notnull-1.18 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 2 3 7 5}}
+do_test notnull-1.19 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 2 3 4 8}}
+do_test notnull-1.20 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.e may not be NULL}}
+do_test notnull-1.21 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {5 5 3 2 1}}
+
+do_test notnull-2.1 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE t1 SET a=null;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-2.2 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE OR REPLACE t1 SET a=null;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-2.3 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE OR IGNORE t1 SET a=null;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {0 {1 2 3 4 5}}
+do_test notnull-2.4 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE OR ABORT t1 SET a=null;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-2.5 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE t1 SET b=null;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 {t1.b may not be NULL}}
+do_test notnull-2.6 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE OR REPLACE t1 SET b=null, d=e, e=d;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {0 {1 5 3 5 4}}
+do_test notnull-2.7 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE OR IGNORE t1 SET b=null, d=e, e=d;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {0 {1 2 3 4 5}}
+do_test notnull-2.8 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE t1 SET c=null, d=e, e=d;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {0 {1 2 6 5 4}}
+do_test notnull-2.9 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE t1 SET d=null, a=b, b=a;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {0 {1 2 3 4 5}}
+do_test notnull-2.10 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE t1 SET e=null, a=b, b=a;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 {t1.e may not be NULL}}
+
+do_test notnull-3.0 {
+ execsql {
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ CREATE INDEX t1c ON t1(c);
+ CREATE INDEX t1d ON t1(d);
+ CREATE INDEX t1e ON t1(e);
+ CREATE INDEX t1abc ON t1(a,b,c);
+ }
+} {}
+do_test notnull-3.1 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 2 3 4 5}}
+do_test notnull-3.2 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-3.3 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {}}
+do_test notnull-3.4 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-3.5 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-3.6 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 5 3 4 5}}
+do_test notnull-3.7 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR IGNORE INTO t1(a,c,d,e) VALUES(1,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 5 3 4 5}}
+do_test notnull-3.8 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR REPLACE INTO t1(a,c,d,e) VALUES(1,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 5 3 4 5}}
+do_test notnull-3.9 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR ABORT INTO t1(a,c,d,e) VALUES(1,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 5 3 4 5}}
+do_test notnull-3.10 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.b may not be NULL}}
+do_test notnull-3.11 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {}}
+do_test notnull-3.12 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 5 3 4 5}}
+do_test notnull-3.13 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 2 6 4 5}}
+do_test notnull-3.14 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {}}
+do_test notnull-3.15 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 2 6 4 5}}
+do_test notnull-3.16 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.c may not be NULL}}
+do_test notnull-3.17 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.d may not be NULL}}
+do_test notnull-3.18 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 2 3 7 5}}
+do_test notnull-3.19 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {1 2 3 4 8}}
+do_test notnull-3.20 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
+ SELECT * FROM t1 order by a;
+ }
+} {1 {t1.e may not be NULL}}
+do_test notnull-3.21 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);
+ SELECT * FROM t1 order by a;
+ }
+} {0 {5 5 3 2 1}}
+
+do_test notnull-4.1 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE t1 SET a=null;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-4.2 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE OR REPLACE t1 SET a=null;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-4.3 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE OR IGNORE t1 SET a=null;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {0 {1 2 3 4 5}}
+do_test notnull-4.4 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE OR ABORT t1 SET a=null;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 {t1.a may not be NULL}}
+do_test notnull-4.5 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE t1 SET b=null;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 {t1.b may not be NULL}}
+do_test notnull-4.6 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE OR REPLACE t1 SET b=null, d=e, e=d;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {0 {1 5 3 5 4}}
+do_test notnull-4.7 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE OR IGNORE t1 SET b=null, d=e, e=d;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {0 {1 2 3 4 5}}
+do_test notnull-4.8 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE t1 SET c=null, d=e, e=d;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {0 {1 2 6 5 4}}
+do_test notnull-4.9 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE t1 SET d=null, a=b, b=a;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {0 {1 2 3 4 5}}
+do_test notnull-4.10 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ UPDATE t1 SET e=null, a=b, b=a;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 {t1.e may not be NULL}}
+
+# Test that bug 29ab7be99f is fixed.
+#
+do_test notnull-5.1 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a, b NOT NULL);
+ CREATE TABLE t2(c, d);
+ INSERT INTO t2 VALUES(3, 4);
+ INSERT INTO t2 VALUES(5, NULL);
+ }
+} {}
+do_test notnull-5.2 {
+ catchsql {
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 SELECT * FROM t2;
+ }
+} {1 {t1.b may not be NULL}}
+do_test notnull-5.3 {
+ execsql { SELECT * FROM t1 }
+} {1 2}
+do_test notnull-5.4 {
+ catchsql {
+ DELETE FROM t1;
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 SELECT * FROM t2;
+ COMMIT;
+ }
+} {1 {t1.b may not be NULL}}
+do_test notnull-5.5 {
+ execsql { SELECT * FROM t1 }
+} {1 2}
+
+finish_test
+
diff --git a/test/null.test b/test/null.test
new file mode 100644
index 0000000..f3782a7
--- /dev/null
+++ b/test/null.test
@@ -0,0 +1,283 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for proper treatment of the special
+# value NULL.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table and some data to work with.
+#
+do_test null-1.0 {
+ execsql {
+ begin;
+ create table t1(a,b,c);
+ insert into t1 values(1,0,0);
+ insert into t1 values(2,0,1);
+ insert into t1 values(3,1,0);
+ insert into t1 values(4,1,1);
+ insert into t1 values(5,null,0);
+ insert into t1 values(6,null,1);
+ insert into t1 values(7,null,null);
+ commit;
+ select * from t1;
+ }
+} {1 0 0 2 0 1 3 1 0 4 1 1 5 {} 0 6 {} 1 7 {} {}}
+
+# Check for how arithmetic expressions handle NULL
+#
+do_test null-1.1 {
+ execsql {
+ select ifnull(a+b,99) from t1;
+ }
+} {1 2 4 5 99 99 99}
+do_test null-1.2 {
+ execsql {
+ select ifnull(b*c,99) from t1;
+ }
+} {0 0 0 1 99 99 99}
+
+# Check to see how the CASE expression handles NULL values. The
+# first WHEN for which the test expression is TRUE is selected.
+# FALSE and UNKNOWN test expressions are skipped.
+#
+do_test null-2.1 {
+ execsql {
+ select ifnull(case when b<>0 then 1 else 0 end, 99) from t1;
+ }
+} {0 0 1 1 0 0 0}
+do_test null-2.2 {
+ execsql {
+ select ifnull(case when not b<>0 then 1 else 0 end, 99) from t1;
+ }
+} {1 1 0 0 0 0 0}
+do_test null-2.3 {
+ execsql {
+ select ifnull(case when b<>0 and c<>0 then 1 else 0 end, 99) from t1;
+ }
+} {0 0 0 1 0 0 0}
+do_test null-2.4 {
+ execsql {
+ select ifnull(case when not (b<>0 and c<>0) then 1 else 0 end, 99) from t1;
+ }
+} {1 1 1 0 1 0 0}
+do_test null-2.5 {
+ execsql {
+ select ifnull(case when b<>0 or c<>0 then 1 else 0 end, 99) from t1;
+ }
+} {0 1 1 1 0 1 0}
+do_test null-2.6 {
+ execsql {
+ select ifnull(case when not (b<>0 or c<>0) then 1 else 0 end, 99) from t1;
+ }
+} {1 0 0 0 0 0 0}
+do_test null-2.7 {
+ execsql {
+ select ifnull(case b when c then 1 else 0 end, 99) from t1;
+ }
+} {1 0 0 1 0 0 0}
+do_test null-2.8 {
+ execsql {
+ select ifnull(case c when b then 1 else 0 end, 99) from t1;
+ }
+} {1 0 0 1 0 0 0}
+
+# Check to see that NULL values are ignored in aggregate functions.
+#
+do_test null-3.1 {
+ execsql {
+ select count(*), count(b), count(c), sum(b), sum(c),
+ avg(b), avg(c), min(b), max(b) from t1;
+ }
+} {7 4 6 2 3 0.5 0.5 0 1}
+
+# The sum of zero entries is a NULL, but the total of zero entries is 0.
+#
+do_test null-3.2 {
+ execsql {
+ SELECT sum(b), total(b) FROM t1 WHERE b<0
+ }
+} {{} 0.0}
+
+# Check to see how WHERE clauses handle NULL values. A NULL value
+# is the same as UNKNOWN. The WHERE clause should only select those
+# rows that are TRUE. FALSE and UNKNOWN rows are rejected.
+#
+do_test null-4.1 {
+ execsql {
+ select a from t1 where b<10
+ }
+} {1 2 3 4}
+do_test null-4.2 {
+ execsql {
+ select a from t1 where not b>10
+ }
+} {1 2 3 4}
+do_test null-4.3 {
+ execsql {
+ select a from t1 where b<10 or c=1;
+ }
+} {1 2 3 4 6}
+do_test null-4.4 {
+ execsql {
+ select a from t1 where b<10 and c=1;
+ }
+} {2 4}
+do_test null-4.5 {
+ execsql {
+ select a from t1 where not (b<10 and c=1);
+ }
+} {1 3 5}
+
+# The DISTINCT keyword on a SELECT statement should treat NULL values
+# as distinct
+#
+do_test null-5.1 {
+ execsql {
+ select distinct b from t1 order by b;
+ }
+} {{} 0 1}
+
+# A UNION to two queries should treat NULL values
+# as distinct.
+#
+# (Later:) We also take this opportunity to test the ability
+# of an ORDER BY clause to bind to either SELECT of a UNION.
+# The left-most SELECT is preferred. In standard SQL, only
+# the left SELECT can be used. The ability to match an ORDER
+# BY term to the right SELECT is an SQLite extension.
+#
+ifcapable compound {
+ do_test null-6.1 {
+ execsql {
+ select b from t1 union select c from t1 order by b;
+ }
+ } {{} 0 1}
+ do_test null-6.2 {
+ execsql {
+ select b from t1 union select c from t1 order by 1;
+ }
+ } {{} 0 1}
+ do_test null-6.3 {
+ execsql {
+ select b from t1 union select c from t1 order by t1.b;
+ }
+ } {{} 0 1}
+ do_test null-6.4 {
+ execsql {
+ select b from t1 union select c from t1 order by main.t1.b;
+ }
+ } {{} 0 1}
+ do_test null-6.5 {
+ catchsql {
+ select b from t1 union select c from t1 order by t1.a;
+ }
+ } {1 {1st ORDER BY term does not match any column in the result set}}
+ do_test null-6.6 {
+ catchsql {
+ select b from t1 union select c from t1 order by main.t1.a;
+ }
+ } {1 {1st ORDER BY term does not match any column in the result set}}
+} ;# ifcapable compound
+
+# The UNIQUE constraint only applies to non-null values
+#
+ifcapable conflict {
+do_test null-7.1 {
+ execsql {
+ create table t2(a, b unique on conflict ignore);
+ insert into t2 values(1,1);
+ insert into t2 values(2,null);
+ insert into t2 values(3,null);
+ insert into t2 values(4,1);
+ select a from t2;
+ }
+ } {1 2 3}
+ do_test null-7.2 {
+ execsql {
+ create table t3(a, b, c, unique(b,c) on conflict ignore);
+ insert into t3 values(1,1,1);
+ insert into t3 values(2,null,1);
+ insert into t3 values(3,null,1);
+ insert into t3 values(4,1,1);
+ select a from t3;
+ }
+ } {1 2 3}
+}
+
+# Ticket #461 - Make sure nulls are handled correctly when doing a
+# lookup using an index.
+#
+do_test null-8.1 {
+ execsql {
+ CREATE TABLE t4(x,y);
+ INSERT INTO t4 VALUES(1,11);
+ INSERT INTO t4 VALUES(2,NULL);
+ SELECT x FROM t4 WHERE y=NULL;
+ }
+} {}
+ifcapable subquery {
+ do_test null-8.2 {
+ execsql {
+ SELECT x FROM t4 WHERE y IN (33,NULL);
+ }
+ } {}
+}
+do_test null-8.3 {
+ execsql {
+ SELECT x FROM t4 WHERE y<33 ORDER BY x;
+ }
+} {1}
+do_test null-8.4 {
+ execsql {
+ SELECT x FROM t4 WHERE y>6 ORDER BY x;
+ }
+} {1}
+do_test null-8.5 {
+ execsql {
+ SELECT x FROM t4 WHERE y!=33 ORDER BY x;
+ }
+} {1}
+do_test null-8.11 {
+ execsql {
+ CREATE INDEX t4i1 ON t4(y);
+ SELECT x FROM t4 WHERE y=NULL;
+ }
+} {}
+ifcapable subquery {
+ do_test null-8.12 {
+ execsql {
+ SELECT x FROM t4 WHERE y IN (33,NULL);
+ }
+ } {}
+}
+do_test null-8.13 {
+ execsql {
+ SELECT x FROM t4 WHERE y<33 ORDER BY x;
+ }
+} {1}
+do_test null-8.14 {
+ execsql {
+ SELECT x FROM t4 WHERE y>6 ORDER BY x;
+ }
+} {1}
+do_test null-8.15 {
+ execsql {
+ SELECT x FROM t4 WHERE y!=33 ORDER BY x;
+ }
+} {1}
+
+
+
+finish_test
diff --git a/test/openv2.test b/test/openv2.test
new file mode 100644
index 0000000..2a9e22d
--- /dev/null
+++ b/test/openv2.test
@@ -0,0 +1,55 @@
+# 2007 Sep 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests on the sqlite3_open_v2() interface.
+#
+# $Id: openv2.test,v 1.2 2009/06/11 17:32:45 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+db close
+forcedelete test.db test.db-journal
+do_test openv2-1.1 {
+ set rc [catch {sqlite3 db test.db -create 0} msg]
+ lappend rc $msg
+} {1 {unable to open database file}}
+do_test openv2-1.2 {
+ info commands db
+} {}
+do_test openv2-1.3 {
+ sqlite3 db test.db
+ db eval {CREATE TABLE t1(x)}
+ db close
+ sqlite3 db test.db -readonly 1
+ db eval {SELECT name FROM sqlite_master}
+} {t1}
+do_test openv2-1.4 {
+ catchsql {
+ INSERT INTO t1 VALUES(123)
+ }
+} {1 {attempt to write a readonly database}}
+
+# Ticket #3908
+# Honor SQLITE_OPEN_READONLY even on an in-memory database, even though
+# this is pointless.
+#
+do_test openv2-2.1 {
+ db close
+ sqlite3 db :memory: -readonly 1
+ db eval {SELECT * FROM sqlite_master}
+} {}
+do_test openv2-2.2 {
+ catchsql {CREATE TABLE t1(x)}
+} {1 {attempt to write a readonly database}}
+
+
+finish_test
diff --git a/test/oserror.test b/test/oserror.test
new file mode 100644
index 0000000..40d2966
--- /dev/null
+++ b/test/oserror.test
@@ -0,0 +1,125 @@
+# 2011 February 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that error messages are logged via the
+# sqlite3_log() mechanism when certain errors are encountered in the
+# default unix or windows VFS modules.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+if {$::tcl_platform(platform)!="unix"} { finish_test ; return }
+set ::testprefix oserror
+
+db close
+sqlite3_shutdown
+test_sqlite3_log xLog
+proc xLog {error_code msg} {
+ if {[string match os_* $msg]} {
+ lappend ::log $msg
+ }
+}
+
+proc do_re_test {tn script expression} {
+ uplevel do_test $tn [list [subst -nocommands {
+ set res [eval { $script }]
+ if {[regexp {$expression} [set res]]} {
+ set {} {$expression}
+ } else {
+ set res
+ }
+ }]] [list $expression]
+
+}
+
+#--------------------------------------------------------------------------
+# Tests oserror-1.* test failures in the open() system call.
+#
+
+# Test a failure in open() due to too many files.
+#
+# The xOpen() method of the unix VFS calls getcwd() as well as open().
+# Although this does not appear to be documented in the man page, on OSX
+# a call to getcwd() may fail if there are no free file descriptors. So
+# an error may be reported for either open() or getcwd() here.
+#
+puts "Possible valgrind error about invalid file descriptor follows:"
+do_test 1.1.1 {
+ set ::log [list]
+ list [catch {
+ for {set i 0} {$i < 2000} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }
+ } msg] $msg
+} {1 {unable to open database file}}
+do_test 1.1.2 {
+ catch { for {set i 0} {$i < 2000} {incr i} { dbh_$i close } }
+} {1}
+do_re_test 1.1.3 {
+ lindex $::log 0
+} {^os_unix.c:\d+: \(\d+\) (open|getcwd)\(.*test.db\) - }
+
+
+# Test a failure in open() due to the path being a directory.
+#
+do_test 1.2.1 {
+ file mkdir dir.db
+ set ::log [list]
+ list [catch { sqlite3 dbh dir.db } msg] $msg
+} {1 {unable to open database file}}
+
+do_re_test 1.2.2 { lindex $::log 0 } {^os_unix.c:\d+: \(\d+\) open\(.*dir.db\) - }
+
+# Test a failure in open() due to the path not existing.
+#
+do_test 1.3.1 {
+ set ::log [list]
+ list [catch { sqlite3 dbh /x/y/z/test.db } msg] $msg
+} {1 {unable to open database file}}
+
+do_re_test 1.3.2 { lindex $::log 0 } {^os_unix.c:\d+: \(\d+\) open\(.*test.db\) - }
+
+# Test a failure in open() due to the path not existing.
+#
+do_test 1.4.1 {
+ set ::log [list]
+ list [catch { sqlite3 dbh /root/test.db } msg] $msg
+} {1 {unable to open database file}}
+
+do_re_test 1.4.2 { lindex $::log 0 } {^os_unix.c:\d*: \(\d+\) open\(.*test.db\) - }
+
+#--------------------------------------------------------------------------
+# Tests oserror-1.* test failures in the unlink() system call.
+#
+ifcapable wal {
+ do_test 2.1.1 {
+ set ::log [list]
+ file mkdir test.db-wal
+ forcedelete test.db
+ list [catch {
+ sqlite3 dbh test.db
+ execsql { SELECT * FROM sqlite_master } dbh
+ } msg] $msg
+ } {1 {disk I/O error}}
+
+ do_re_test 2.1.2 {
+ lindex $::log 0
+ } {^os_unix.c:\d+: \(\d+\) unlink\(.*test.db-wal\) - }
+ do_test 2.1.3 {
+ catch { dbh close }
+ forcedelete test.db-wal
+ } {}
+}
+
+
+test_syscall reset
+sqlite3_shutdown
+test_sqlite3_log
+sqlite3_initialize
+finish_test
diff --git a/test/pager1.test b/test/pager1.test
new file mode 100644
index 0000000..0226fe4
--- /dev/null
+++ b/test/pager1.test
@@ -0,0 +1,2467 @@
+# 2010 June 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+source $testdir/wal_common.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+#
+# pager1-1.*: Test inter-process locking (clients in multiple processes).
+#
+# pager1-2.*: Test intra-process locking (multiple clients in this process).
+#
+# pager1-3.*: Savepoint related tests.
+#
+# pager1-4.*: Hot-journal related tests.
+#
+# pager1-5.*: Cases related to multi-file commits.
+#
+# pager1-6.*: Cases related to "PRAGMA max_page_count"
+#
+# pager1-7.*: Cases specific to "PRAGMA journal_mode=TRUNCATE"
+#
+# pager1-8.*: Cases using temporary and in-memory databases.
+#
+# pager1-9.*: Tests related to the backup API.
+#
+# pager1-10.*: Test that the assumed file-system sector-size is limited to
+# 64KB.
+#
+# pager1-12.*: Tests involving "PRAGMA page_size"
+#
+# pager1-13.*: Cases specific to "PRAGMA journal_mode=PERSIST"
+#
+# pager1-14.*: Cases specific to "PRAGMA journal_mode=OFF"
+#
+# pager1-15.*: Varying sqlite3_vfs.szOsFile
+#
+# pager1-16.*: Varying sqlite3_vfs.mxPathname
+#
+# pager1-17.*: Tests related to "PRAGMA omit_readlock"
+#
+# pager1-18.*: Test that the pager layer responds correctly if the b-tree
+# requests an invalid page number (due to db corruption).
+#
+
+proc recursive_select {id table {script {}}} {
+ set cnt 0
+ db eval "SELECT rowid, * FROM $table WHERE rowid = ($id-1)" {
+ recursive_select $rowid $table $script
+ incr cnt
+ }
+ if {$cnt==0} { eval $script }
+}
+
+set a_string_counter 1
+proc a_string {n} {
+ global a_string_counter
+ incr a_string_counter
+ string range [string repeat "${a_string_counter}." $n] 1 $n
+}
+db func a_string a_string
+
+do_multiclient_test tn {
+
+ # Create and populate a database table using connection [db]. Check
+ # that connections [db2] and [db3] can see the schema and content.
+ #
+ do_test pager1-$tn.1 {
+ sql1 {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE INDEX i1 ON t1(b);
+ INSERT INTO t1 VALUES(1, 'one'); INSERT INTO t1 VALUES(2, 'two');
+ }
+ } {}
+ do_test pager1-$tn.2 { sql2 { SELECT * FROM t1 } } {1 one 2 two}
+ do_test pager1-$tn.3 { sql3 { SELECT * FROM t1 } } {1 one 2 two}
+
+ # Open a transaction and add a row using [db]. This puts [db] in
+ # RESERVED state. Check that connections [db2] and [db3] can still
+ # read the database content as it was before the transaction was
+ # opened. [db] should see the inserted row.
+ #
+ do_test pager1-$tn.4 {
+ sql1 {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 'three');
+ }
+ } {}
+ do_test pager1-$tn.5 { sql2 { SELECT * FROM t1 } } {1 one 2 two}
+ do_test pager1-$tn.7 { sql1 { SELECT * FROM t1 } } {1 one 2 two 3 three}
+
+ # [db] still has an open write transaction. Check that this prevents
+ # other connections (specifically [db2]) from writing to the database.
+ #
+ # Even if [db2] opens a transaction first, it may not write to the
+ # database. After the attempt to write the db within a transaction,
+ # [db2] is left with an open transaction, but not a read-lock on
+ # the main database. So it does not prevent [db] from committing.
+ #
+ do_test pager1-$tn.8 {
+ csql2 { UPDATE t1 SET a = a + 10 }
+ } {1 {database is locked}}
+ do_test pager1-$tn.9 {
+ csql2 {
+ BEGIN;
+ UPDATE t1 SET a = a + 10;
+ }
+ } {1 {database is locked}}
+
+ # Have [db] commit its transactions. Check the other connections can
+ # now see the new database content.
+ #
+ do_test pager1-$tn.10 { sql1 { COMMIT } } {}
+ do_test pager1-$tn.11 { sql1 { SELECT * FROM t1 } } {1 one 2 two 3 three}
+ do_test pager1-$tn.12 { sql2 { SELECT * FROM t1 } } {1 one 2 two 3 three}
+ do_test pager1-$tn.13 { sql3 { SELECT * FROM t1 } } {1 one 2 two 3 three}
+
+ # Check that, as noted above, [db2] really did keep an open transaction
+ # after the attempt to write the database failed.
+ #
+ do_test pager1-$tn.14 {
+ csql2 { BEGIN }
+ } {1 {cannot start a transaction within a transaction}}
+ do_test pager1-$tn.15 { sql2 { ROLLBACK } } {}
+
+ # Have [db2] open a transaction and take a read-lock on the database.
+ # Check that this prevents [db] from writing to the database (outside
+ # of any transaction). After this fails, check that [db3] can read
+ # the db (showing that [db] did not take a PENDING lock etc.)
+ #
+ do_test pager1-$tn.15 {
+ sql2 { BEGIN; SELECT * FROM t1; }
+ } {1 one 2 two 3 three}
+ do_test pager1-$tn.16 {
+ csql1 { UPDATE t1 SET a = a + 10 }
+ } {1 {database is locked}}
+ do_test pager1-$tn.17 { sql3 { SELECT * FROM t1 } } {1 one 2 two 3 three}
+
+ # This time, have [db] open a transaction before writing the database.
+ # This works - [db] gets a RESERVED lock which does not conflict with
+ # the SHARED lock [db2] is holding.
+ #
+ do_test pager1-$tn.18 {
+ sql1 {
+ BEGIN;
+ UPDATE t1 SET a = a + 10;
+ }
+ } {}
+ do_test pager1-$tn-19 {
+ sql1 { PRAGMA lock_status }
+ } {main reserved temp closed}
+ do_test pager1-$tn-20 {
+ sql2 { PRAGMA lock_status }
+ } {main shared temp closed}
+
+ # Check that all connections can still read the database. Only [db] sees
+ # the updated content (as the transaction has not been committed yet).
+ #
+ do_test pager1-$tn.21 { sql1 { SELECT * FROM t1 } } {11 one 12 two 13 three}
+ do_test pager1-$tn.22 { sql2 { SELECT * FROM t1 } } {1 one 2 two 3 three}
+ do_test pager1-$tn.23 { sql3 { SELECT * FROM t1 } } {1 one 2 two 3 three}
+
+ # Because [db2] still has the SHARED lock, [db] is unable to commit the
+ # transaction. If it tries, an error is returned and the connection
+ # upgrades to a PENDING lock.
+ #
+ # Once this happens, [db] can read the database and see the new content,
+ # [db2] (still holding SHARED) can still read the old content, but [db3]
+ # (not holding any lock) is prevented by [db]'s PENDING from reading
+ # the database.
+ #
+ do_test pager1-$tn.24 { csql1 { COMMIT } } {1 {database is locked}}
+ do_test pager1-$tn-25 {
+ sql1 { PRAGMA lock_status }
+ } {main pending temp closed}
+ do_test pager1-$tn.26 { sql1 { SELECT * FROM t1 } } {11 one 12 two 13 three}
+ do_test pager1-$tn.27 { sql2 { SELECT * FROM t1 } } {1 one 2 two 3 three}
+ do_test pager1-$tn.28 { csql3 { SELECT * FROM t1 } } {1 {database is locked}}
+
+ # Have [db2] commit its read transaction, releasing the SHARED lock it
+ # is holding. Now, neither [db2] nor [db3] may read the database (as [db]
+ # is still holding a PENDING).
+ #
+ do_test pager1-$tn.29 { sql2 { COMMIT } } {}
+ do_test pager1-$tn.30 { csql2 { SELECT * FROM t1 } } {1 {database is locked}}
+ do_test pager1-$tn.31 { csql3 { SELECT * FROM t1 } } {1 {database is locked}}
+
+ # [db] is now able to commit the transaction. Once the transaction is
+ # committed, all three connections can read the new content.
+ #
+ do_test pager1-$tn.25 { sql1 { UPDATE t1 SET a = a+10 } } {}
+ do_test pager1-$tn.26 { sql1 { COMMIT } } {}
+ do_test pager1-$tn.27 { sql1 { SELECT * FROM t1 } } {21 one 22 two 23 three}
+ do_test pager1-$tn.27 { sql2 { SELECT * FROM t1 } } {21 one 22 two 23 three}
+ do_test pager1-$tn.28 { sql3 { SELECT * FROM t1 } } {21 one 22 two 23 three}
+
+ # Install a busy-handler for connection [db].
+ #
+ set ::nbusy [list]
+ proc busy {n} {
+ lappend ::nbusy $n
+ if {$n>5} { sql2 COMMIT }
+ return 0
+ }
+ db busy busy
+
+ do_test pager1-$tn.29 {
+ sql1 { BEGIN ; INSERT INTO t1 VALUES('x', 'y') }
+ } {}
+ do_test pager1-$tn.30 {
+ sql2 { BEGIN ; SELECT * FROM t1 }
+ } {21 one 22 two 23 three}
+ do_test pager1-$tn.31 { sql1 COMMIT } {}
+ do_test pager1-$tn.32 { set ::nbusy } {0 1 2 3 4 5 6}
+}
+
+#-------------------------------------------------------------------------
+# Savepoint related test cases.
+#
+# pager1-3.1.2.*: Force a savepoint rollback to cause the database file
+# to grow.
+#
+# pager1-3.1.3.*: Use a journal created in synchronous=off mode as part
+# of a savepoint rollback.
+#
+do_test pager1-3.1.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TABLE counter(
+ i CHECK (i<5),
+ u CHECK (u<10)
+ );
+ INSERT INTO counter VALUES(0, 0);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ UPDATE counter SET i = i+1;
+ END;
+ CREATE TRIGGER tr2 AFTER UPDATE ON t1 BEGIN
+ UPDATE counter SET u = u+1;
+ END;
+ }
+ execsql { SELECT * FROM counter }
+} {0 0}
+
+do_execsql_test pager1-3.1.2 {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ INSERT INTO t1 VALUES(1, randomblob(1500));
+ INSERT INTO t1 VALUES(2, randomblob(1500));
+ INSERT INTO t1 VALUES(3, randomblob(1500));
+ SELECT * FROM counter;
+} {3 0}
+do_catchsql_test pager1-3.1.3 {
+ INSERT INTO t1 SELECT a+3, randomblob(1500) FROM t1
+} {1 {constraint failed}}
+do_execsql_test pager1-3.4 { SELECT * FROM counter } {3 0}
+do_execsql_test pager1-3.5 { SELECT a FROM t1 } {1 2 3}
+do_execsql_test pager1-3.6 { COMMIT } {}
+
+foreach {tn sql tcl} {
+ 7 { PRAGMA synchronous = NORMAL ; PRAGMA temp_store = 0 } {
+ testvfs tv -default 1
+ tv devchar safe_append
+ }
+ 8 { PRAGMA synchronous = NORMAL ; PRAGMA temp_store = 2 } {
+ testvfs tv -default 1
+ tv devchar sequential
+ }
+ 9 { PRAGMA synchronous = FULL } { }
+ 10 { PRAGMA synchronous = NORMAL } { }
+ 11 { PRAGMA synchronous = OFF } { }
+ 12 { PRAGMA synchronous = FULL ; PRAGMA fullfsync = 1 } { }
+ 13 { PRAGMA synchronous = FULL } {
+ testvfs tv -default 1
+ tv devchar sequential
+ }
+ 14 { PRAGMA locking_mode = EXCLUSIVE } {
+ }
+} {
+ do_test pager1-3.$tn.1 {
+ eval $tcl
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql $sql
+ execsql {
+ PRAGMA auto_vacuum = 2;
+ PRAGMA cache_size = 10;
+ CREATE TABLE z(x INTEGER PRIMARY KEY, y);
+ BEGIN;
+ INSERT INTO z VALUES(NULL, a_string(800));
+ INSERT INTO z SELECT NULL, a_string(800) FROM z; -- 2
+ INSERT INTO z SELECT NULL, a_string(800) FROM z; -- 4
+ INSERT INTO z SELECT NULL, a_string(800) FROM z; -- 8
+ INSERT INTO z SELECT NULL, a_string(800) FROM z; -- 16
+ INSERT INTO z SELECT NULL, a_string(800) FROM z; -- 32
+ INSERT INTO z SELECT NULL, a_string(800) FROM z; -- 64
+ INSERT INTO z SELECT NULL, a_string(800) FROM z; -- 128
+ INSERT INTO z SELECT NULL, a_string(800) FROM z; -- 256
+ COMMIT;
+ }
+ execsql { PRAGMA auto_vacuum }
+ } {2}
+ do_execsql_test pager1-3.$tn.2 {
+ BEGIN;
+ INSERT INTO z VALUES(NULL, a_string(800));
+ INSERT INTO z VALUES(NULL, a_string(800));
+ SAVEPOINT one;
+ UPDATE z SET y = NULL WHERE x>256;
+ PRAGMA incremental_vacuum;
+ SELECT count(*) FROM z WHERE x < 100;
+ ROLLBACK TO one;
+ COMMIT;
+ } {99}
+
+ do_execsql_test pager1-3.$tn.3 {
+ BEGIN;
+ SAVEPOINT one;
+ UPDATE z SET y = y||x;
+ ROLLBACK TO one;
+ COMMIT;
+ SELECT count(*) FROM z;
+ } {258}
+
+ do_execsql_test pager1-3.$tn.4 {
+ SAVEPOINT one;
+ UPDATE z SET y = y||x;
+ ROLLBACK TO one;
+ } {}
+ do_execsql_test pager1-3.$tn.5 {
+ SELECT count(*) FROM z;
+ RELEASE one;
+ PRAGMA integrity_check;
+ } {258 ok}
+
+ do_execsql_test pager1-3.$tn.6 {
+ SAVEPOINT one;
+ RELEASE one;
+ } {}
+
+ db close
+ catch { tv delete }
+}
+
+#-------------------------------------------------------------------------
+# Hot journal rollback related test cases.
+#
+# pager1.4.1.*: Test that the pager module deletes very small invalid
+# journal files.
+#
+# pager1.4.2.*: Test that if the master journal pointer at the end of a
+# hot-journal file appears to be corrupt (checksum does not
+# compute) the associated journal is rolled back (and no
+# xAccess() call to check for the presence of any master
+# journal file is made).
+#
+# pager1.4.3.*: Test that the contents of a hot-journal are ignored if the
+# page-size or sector-size in the journal header appear to
+# be invalid (too large, too small or not a power of 2).
+#
+# pager1.4.4.*: Test hot-journal rollback of journal file with a master
+# journal pointer generated in various "PRAGMA synchronous"
+# modes.
+#
+# pager1.4.5.*: Test that hot-journal rollback stops if it encounters a
+# journal-record for which the checksum fails.
+#
+# pager1.4.6.*: Test that when rolling back a hot-journal that contains a
+# master journal pointer, the master journal file is deleted
+# after all the hot-journals that refer to it are deleted.
+#
+# pager1.4.7.*: Test that if a hot-journal file exists but a client can
+# open it for reading only, the database cannot be accessed and
+# SQLITE_CANTOPEN is returned.
+#
+do_test pager1.4.1.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE x(y, z);
+ INSERT INTO x VALUES(1, 2);
+ }
+ set fd [open test.db-journal w]
+ puts -nonewline $fd "helloworld"
+ close $fd
+ file exists test.db-journal
+} {1}
+do_test pager1.4.1.2 { execsql { SELECT * FROM x } } {1 2}
+do_test pager1.4.1.3 { file exists test.db-journal } {0}
+
+# Set up a [testvfs] to snapshot the file-system just before SQLite
+# deletes the master-journal to commit a multi-file transaction.
+#
+# In subsequent test cases, invoking [faultsim_restore_and_reopen] sets
+# up the file system to contain two databases, two hot-journal files and
+# a master-journal.
+#
+do_test pager1.4.2.1 {
+ testvfs tstvfs -default 1
+ tstvfs filter xDelete
+ tstvfs script xDeleteCallback
+ proc xDeleteCallback {method file args} {
+ set file [file tail $file]
+ if { [string match *mj* $file] } { faultsim_save }
+ }
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ PRAGMA journal_mode = DELETE;
+ PRAGMA main.cache_size = 10;
+ PRAGMA aux.cache_size = 10;
+ CREATE TABLE t1(a UNIQUE, b UNIQUE);
+ CREATE TABLE aux.t2(a UNIQUE, b UNIQUE);
+ INSERT INTO t1 VALUES(a_string(200), a_string(300));
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t2 SELECT * FROM t1;
+ BEGIN;
+ INSERT INTO t1 SELECT a_string(201), a_string(301) FROM t1;
+ INSERT INTO t1 SELECT a_string(202), a_string(302) FROM t1;
+ INSERT INTO t1 SELECT a_string(203), a_string(303) FROM t1;
+ INSERT INTO t1 SELECT a_string(204), a_string(304) FROM t1;
+ REPLACE INTO t2 SELECT * FROM t1;
+ COMMIT;
+ }
+ db close
+ tstvfs delete
+} {}
+
+if {$::tcl_platform(platform)!="windows"} {
+do_test pager1.4.2.2 {
+ faultsim_restore_and_reopen
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+ }
+} {4 ok}
+do_test pager1.4.2.3 {
+ faultsim_restore_and_reopen
+ foreach f [glob test.db-mj*] { forcedelete $f }
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+ }
+} {64 ok}
+do_test pager1.4.2.4 {
+ faultsim_restore_and_reopen
+ hexio_write test.db-journal [expr [file size test.db-journal]-20] 123456
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+ }
+} {4 ok}
+do_test pager1.4.2.5 {
+ faultsim_restore_and_reopen
+ hexio_write test.db-journal [expr [file size test.db-journal]-20] 123456
+ foreach f [glob test.db-mj*] { forcedelete $f }
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+ }
+} {4 ok}
+}
+
+do_test pager1.4.3.1 {
+ testvfs tstvfs -default 1
+ tstvfs filter xSync
+ tstvfs script xSyncCallback
+ proc xSyncCallback {method file args} {
+ set file [file tail $file]
+ if { 0==[string match *journal $file] } { faultsim_save }
+ }
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = DELETE;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ db close
+ tstvfs delete
+} {}
+
+foreach {tn ofst value result} {
+ 2 20 31 {1 2 3 4}
+ 3 20 32 {1 2 3 4}
+ 4 20 33 {1 2 3 4}
+ 5 20 65536 {1 2 3 4}
+ 6 20 131072 {1 2 3 4}
+
+ 7 24 511 {1 2 3 4}
+ 8 24 513 {1 2 3 4}
+ 9 24 131072 {1 2 3 4}
+
+ 10 32 65536 {1 2}
+} {
+ do_test pager1.4.3.$tn {
+ faultsim_restore_and_reopen
+ hexio_write test.db-journal $ofst [format %.8x $value]
+ execsql { SELECT * FROM t1 }
+ } $result
+}
+db close
+
+# Set up a VFS that snapshots the file-system just before a master journal
+# file is deleted to commit a multi-file transaction. Specifically, the
+# file-system is saved just before the xDelete() call to remove the
+# master journal file from the file-system.
+#
+testvfs tv -default 1
+tv script copy_on_mj_delete
+set ::mj_filename_length 0
+proc copy_on_mj_delete {method filename args} {
+ if {[string match *mj* [file tail $filename]]} {
+ set ::mj_filename_length [string length $filename]
+ faultsim_save
+ }
+ return SQLITE_OK
+}
+
+set pwd [pwd]
+foreach {tn1 tcl} {
+ 1 { set prefix "test.db" }
+ 2 {
+ # This test depends on the underlying VFS being able to open paths
+ # 512 bytes in length. The idea is to create a hot-journal file that
+ # contains a master-journal pointer so large that it could contain
+ # a valid page record (if the file page-size is 512 bytes). So as to
+ # make sure SQLite doesn't get confused by this.
+ #
+ set nPadding [expr 511 - $::mj_filename_length]
+ if {$tcl_platform(platform)=="windows"} {
+ # TBD need to figure out how to do this correctly for Windows!!!
+ set nPadding [expr 255 - $::mj_filename_length]
+ }
+
+ # We cannot just create a really long database file name to open, as
+ # Linux limits a single component of a path to 255 bytes by default
+ # (and presumably other systems have limits too). So create a directory
+ # hierarchy to work in.
+ #
+ set dirname "d123456789012345678901234567890/"
+ set nDir [expr $nPadding / 32]
+ if { $nDir } {
+ set p [string repeat $dirname $nDir]
+ file mkdir $p
+ cd $p
+ }
+
+ set padding [string repeat x [expr $nPadding %32]]
+ set prefix "test.db${padding}"
+ }
+} {
+ eval $tcl
+ foreach {tn2 sql} {
+ o {
+ PRAGMA main.synchronous=OFF;
+ PRAGMA aux.synchronous=OFF;
+ PRAGMA journal_mode = DELETE;
+ }
+ o512 {
+ PRAGMA main.synchronous=OFF;
+ PRAGMA aux.synchronous=OFF;
+ PRAGMA main.page_size = 512;
+ PRAGMA aux.page_size = 512;
+ PRAGMA journal_mode = DELETE;
+ }
+ n {
+ PRAGMA main.synchronous=NORMAL;
+ PRAGMA aux.synchronous=NORMAL;
+ PRAGMA journal_mode = DELETE;
+ }
+ f {
+ PRAGMA main.synchronous=FULL;
+ PRAGMA aux.synchronous=FULL;
+ PRAGMA journal_mode = DELETE;
+ }
+ } {
+
+ set tn "${tn1}.${tn2}"
+
+ # Set up a connection to have two databases, test.db (main) and
+ # test.db2 (aux). Then run a multi-file transaction on them. The
+ # VFS will snapshot the file-system just before the master-journal
+ # file is deleted to commit the transaction.
+ #
+ tv filter xDelete
+ do_test pager1-4.4.$tn.1 {
+ faultsim_delete_and_reopen $prefix
+ execsql "
+ ATTACH '${prefix}2' AS aux;
+ $sql
+ CREATE TABLE a(x);
+ CREATE TABLE aux.b(x);
+ INSERT INTO a VALUES('double-you');
+ INSERT INTO a VALUES('why');
+ INSERT INTO a VALUES('zed');
+ INSERT INTO b VALUES('won');
+ INSERT INTO b VALUES('too');
+ INSERT INTO b VALUES('free');
+ "
+ execsql {
+ BEGIN;
+ INSERT INTO a SELECT * FROM b WHERE rowid<=3;
+ INSERT INTO b SELECT * FROM a WHERE rowid<=3;
+ COMMIT;
+ }
+ } {}
+ tv filter {}
+
+ # Check that the transaction was committed successfully.
+ #
+ do_execsql_test pager1-4.4.$tn.2 {
+ SELECT * FROM a
+ } {double-you why zed won too free}
+ do_execsql_test pager1-4.4.$tn.3 {
+ SELECT * FROM b
+ } {won too free double-you why zed}
+
+ # Restore the file-system and reopen the databases. Check that it now
+ # appears that the transaction was not committed (because the file-system
+ # was restored to the state where it had not been).
+ #
+ do_test pager1-4.4.$tn.4 {
+ faultsim_restore_and_reopen $prefix
+ execsql "ATTACH '${prefix}2' AS aux"
+ } {}
+ do_execsql_test pager1-4.4.$tn.5 {SELECT * FROM a} {double-you why zed}
+ do_execsql_test pager1-4.4.$tn.6 {SELECT * FROM b} {won too free}
+
+ # Restore the file-system again. This time, before reopening the databases,
+ # delete the master-journal file from the file-system. It now appears that
+ # the transaction was committed (no master-journal file == no rollback).
+ #
+ do_test pager1-4.4.$tn.7 {
+ faultsim_restore_and_reopen $prefix
+ foreach f [glob ${prefix}-mj*] { forcedelete $f }
+ execsql "ATTACH '${prefix}2' AS aux"
+ } {}
+ do_execsql_test pager1-4.4.$tn.8 {
+ SELECT * FROM a
+ } {double-you why zed won too free}
+ do_execsql_test pager1-4.4.$tn.9 {
+ SELECT * FROM b
+ } {won too free double-you why zed}
+ }
+
+ cd $pwd
+}
+db close
+tv delete
+forcedelete $dirname
+
+
+# Set up a VFS to make a copy of the file-system just before deleting a
+# journal file to commit a transaction. The transaction modifies exactly
+# two database pages (and page 1 - the change counter).
+#
+testvfs tv -default 1
+tv sectorsize 512
+tv script copy_on_journal_delete
+tv filter xDelete
+proc copy_on_journal_delete {method filename args} {
+ if {[string match *journal $filename]} faultsim_save
+ return SQLITE_OK
+}
+faultsim_delete_and_reopen
+do_execsql_test pager1.4.5.1 {
+ PRAGMA journal_mode = DELETE;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t1 VALUES('I', 'II');
+ INSERT INTO t2 VALUES('III', 'IV');
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ COMMIT;
+} {delete}
+tv filter {}
+
+# Check the transaction was committed:
+#
+do_execsql_test pager1.4.5.2 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {I II 1 2 III IV 3 4}
+
+# Now try four tests:
+#
+# pager1-4.5.3: Restore the file-system. Check that the whole transaction
+# is rolled back.
+#
+# pager1-4.5.4: Restore the file-system. Corrupt the first record in the
+# journal. Check the transaction is not rolled back.
+#
+# pager1-4.5.5: Restore the file-system. Corrupt the second record in the
+# journal. Check that the first record in the transaction is
+# played back, but not the second.
+#
+# pager1-4.5.6: Restore the file-system. Try to open the database with a
+# readonly connection. This should fail, as a read-only
+# connection cannot roll back the database file.
+#
+faultsim_restore_and_reopen
+do_execsql_test pager1.4.5.3 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {I II III IV}
+faultsim_restore_and_reopen
+hexio_write test.db-journal [expr 512+4+1024 - 202] 0123456789ABCDEF
+do_execsql_test pager1.4.5.4 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {I II 1 2 III IV 3 4}
+faultsim_restore_and_reopen
+hexio_write test.db-journal [expr 512+4+1024+4+4+1024 - 202] 0123456789ABCDEF
+do_execsql_test pager1.4.5.5 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {I II III IV 3 4}
+
+faultsim_restore_and_reopen
+db close
+sqlite3 db test.db -readonly 1
+do_catchsql_test pager1.4.5.6 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {1 {disk I/O error}}
+db close
+
+# Snapshot the file-system just before multi-file commit. Save the name
+# of the master journal file in $::mj_filename.
+#
+tv script copy_on_mj_delete
+tv filter xDelete
+proc copy_on_mj_delete {method filename args} {
+ if {[string match *mj* [file tail $filename]]} {
+ set ::mj_filename $filename
+ faultsim_save
+ }
+ return SQLITE_OK
+}
+do_test pager1.4.6.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = DELETE;
+ ATTACH 'test.db2' AS two;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE two.t2(a, b);
+ INSERT INTO t1 VALUES(1, 't1.1');
+ INSERT INTO t2 VALUES(1, 't2.1');
+ BEGIN;
+ UPDATE t1 SET b = 't1.2';
+ UPDATE t2 SET b = 't2.2';
+ COMMIT;
+ }
+ tv filter {}
+ db close
+} {}
+
+faultsim_restore_and_reopen
+do_execsql_test pager1.4.6.2 { SELECT * FROM t1 } {1 t1.1}
+do_test pager1.4.6.3 { file exists $::mj_filename } {1}
+do_execsql_test pager1.4.6.4 {
+ ATTACH 'test.db2' AS two;
+ SELECT * FROM t2;
+} {1 t2.1}
+do_test pager1.4.6.5 { file exists $::mj_filename } {0}
+
+faultsim_restore_and_reopen
+db close
+do_test pager1.4.6.8 {
+ set ::mj_filename1 $::mj_filename
+ tv filter xDelete
+ sqlite3 db test.db2
+ execsql {
+ PRAGMA journal_mode = DELETE;
+ ATTACH 'test.db3' AS three;
+ CREATE TABLE three.t3(a, b);
+ INSERT INTO t3 VALUES(1, 't3.1');
+ BEGIN;
+ UPDATE t2 SET b = 't2.3';
+ UPDATE t3 SET b = 't3.3';
+ COMMIT;
+ }
+ expr {$::mj_filename1 != $::mj_filename}
+} {1}
+faultsim_restore_and_reopen
+tv filter {}
+
+# The file-system now contains:
+#
+# * three databases
+# * three hot-journal files
+# * two master-journal files.
+#
+# The hot-journals associated with test.db2 and test.db3 point to
+# master journal $::mj_filename. The hot-journal file associated with
+# test.db points to master journal $::mj_filename1. So reading from
+# test.db should delete $::mj_filename1.
+#
+do_test pager1.4.6.9 {
+ lsort [glob test.db*]
+} [lsort [list \
+ test.db test.db2 test.db3 \
+ test.db-journal test.db2-journal test.db3-journal \
+ [file tail $::mj_filename] [file tail $::mj_filename1]
+]]
+
+# The master-journal $::mj_filename1 contains pointers to test.db and
+# test.db2. However the hot-journal associated with test.db2 points to
+# a different master-journal. Therefore, reading from test.db only should
+# be enough to cause SQLite to delete $::mj_filename1.
+#
+do_test pager1.4.6.10 { file exists $::mj_filename } {1}
+do_test pager1.4.6.11 { file exists $::mj_filename1 } {1}
+do_execsql_test pager1.4.6.12 { SELECT * FROM t1 } {1 t1.1}
+do_test pager1.4.6.13 { file exists $::mj_filename } {1}
+do_test pager1.4.6.14 { file exists $::mj_filename1 } {0}
+
+do_execsql_test pager1.4.6.12 {
+ ATTACH 'test.db2' AS two;
+ SELECT * FROM t2;
+} {1 t2.1}
+do_test pager1.4.6.13 { file exists $::mj_filename } {1}
+do_execsql_test pager1.4.6.14 {
+ ATTACH 'test.db3' AS three;
+ SELECT * FROM t3;
+} {1 t3.1}
+do_test pager1.4.6.15 { file exists $::mj_filename } {0}
+
+db close
+tv delete
+
+testvfs tv -default 1
+tv sectorsize 512
+tv script copy_on_journal_delete
+tv filter xDelete
+proc copy_on_journal_delete {method filename args} {
+ if {[string match *journal $filename]} faultsim_save
+ return SQLITE_OK
+}
+faultsim_delete_and_reopen
+do_execsql_test pager1.4.7.1 {
+ PRAGMA journal_mode = DELETE;
+ CREATE TABLE t1(x PRIMARY KEY, y);
+ CREATE INDEX i1 ON t1(y);
+ INSERT INTO t1 VALUES('I', 'one');
+ INSERT INTO t1 VALUES('II', 'four');
+ INSERT INTO t1 VALUES('III', 'nine');
+ BEGIN;
+ INSERT INTO t1 VALUES('IV', 'sixteen');
+ INSERT INTO t1 VALUES('V' , 'twentyfive');
+ COMMIT;
+} {delete}
+tv filter {}
+db close
+tv delete
+do_test pager1.4.7.2 {
+ faultsim_restore_and_reopen
+ catch {file attributes test.db-journal -permissions r--------}
+ catch {file attributes test.db-journal -readonly 1}
+ catchsql { SELECT * FROM t1 }
+} {1 {unable to open database file}}
+do_test pager1.4.7.3 {
+ db close
+ catch {file attributes test.db-journal -permissions rw-rw-rw-}
+ catch {file attributes test.db-journal -readonly 0}
+ delete_file test.db-journal
+ file exists test.db-journal
+} {0}
+
+#-------------------------------------------------------------------------
+# The following tests deal with multi-file commits.
+#
+# pager1-5.1.*: The case where a multi-file cannot be committed because
+# another connection is holding a SHARED lock on one of the
+# files. After the SHARED lock is removed, the COMMIT succeeds.
+#
+# pager1-5.2.*: Multi-file commits with journal_mode=memory.
+#
+# pager1-5.3.*: Multi-file commits with journal_mode=memory.
+#
+# pager1-5.4.*: Check that with synchronous=normal, the master-journal file
+# name is added to a journal file immediately after the last
+# journal record. But with synchronous=full, extra unused space
+# is allocated between the last journal record and the
+# master-journal file name so that the master-journal file
+# name does not lie on the same sector as the last journal file
+# record.
+#
+# pager1-5.5.*: Check that in journal_mode=PERSIST mode, a journal file is
+# truncated to zero bytes when a multi-file transaction is
+# committed (instead of the first couple of bytes being zeroed).
+#
+#
+do_test pager1-5.1.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE aux.t2(a, b);
+ INSERT INTO t1 VALUES(17, 'Lenin');
+ INSERT INTO t1 VALUES(22, 'Stalin');
+ INSERT INTO t1 VALUES(53, 'Khrushchev');
+ }
+} {}
+do_test pager1-5.1.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(64, 'Brezhnev');
+ INSERT INTO t2 SELECT * FROM t1;
+ }
+ sqlite3 db2 test.db2
+ execsql {
+ BEGIN;
+ SELECT * FROM t2;
+ } db2
+} {}
+do_test pager1-5.1.3 {
+ catchsql COMMIT
+} {1 {database is locked}}
+do_test pager1-5.1.4 {
+ execsql COMMIT db2
+ execsql COMMIT
+ execsql { SELECT * FROM t2 } db2
+} {17 Lenin 22 Stalin 53 Khrushchev 64 Brezhnev}
+do_test pager1-5.1.5 {
+ db2 close
+} {}
+
+do_test pager1-5.2.1 {
+ execsql {
+ PRAGMA journal_mode = memory;
+ BEGIN;
+ INSERT INTO t1 VALUES(84, 'Andropov');
+ INSERT INTO t2 VALUES(84, 'Andropov');
+ COMMIT;
+ }
+} {memory}
+do_test pager1-5.3.1 {
+ execsql {
+ PRAGMA journal_mode = off;
+ BEGIN;
+ INSERT INTO t1 VALUES(85, 'Gorbachev');
+ INSERT INTO t2 VALUES(85, 'Gorbachev');
+ COMMIT;
+ }
+} {off}
+
+do_test pager1-5.4.1 {
+ db close
+ testvfs tv
+ sqlite3 db test.db -vfs tv
+ execsql { ATTACH 'test.db2' AS aux }
+
+ tv filter xDelete
+ tv script max_journal_size
+ tv sectorsize 512
+ set ::max_journal 0
+ proc max_journal_size {method args} {
+ set sz 0
+ catch { set sz [file size test.db-journal] }
+ if {$sz > $::max_journal} {
+ set ::max_journal $sz
+ }
+ return SQLITE_OK
+ }
+ execsql {
+ PRAGMA journal_mode = DELETE;
+ PRAGMA synchronous = NORMAL;
+ BEGIN;
+ INSERT INTO t1 VALUES(85, 'Gorbachev');
+ INSERT INTO t2 VALUES(85, 'Gorbachev');
+ COMMIT;
+ }
+ set ::max_journal
+} [expr 2615+[string length [pwd]]]
+do_test pager1-5.4.2 {
+ set ::max_journal 0
+ execsql {
+ PRAGMA synchronous = full;
+ BEGIN;
+ DELETE FROM t1 WHERE b = 'Lenin';
+ DELETE FROM t2 WHERE b = 'Lenin';
+ COMMIT;
+ }
+ set ::max_journal
+} [expr 3111+[string length [pwd]]]
+db close
+tv delete
+
+do_test pager1-5.5.1 {
+ sqlite3 db test.db
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ PRAGMA journal_mode = PERSIST;
+ CREATE TABLE t3(a, b);
+ INSERT INTO t3 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ UPDATE t3 SET b = randomblob(1500);
+ }
+ expr [file size test.db-journal] > 15000
+} {1}
+do_test pager1-5.5.2 {
+ execsql {
+ PRAGMA synchronous = full;
+ BEGIN;
+ DELETE FROM t1 WHERE b = 'Stalin';
+ DELETE FROM t2 WHERE b = 'Stalin';
+ COMMIT;
+ }
+ file size test.db-journal
+} {0}
+
+
+#-------------------------------------------------------------------------
+# The following tests work with "PRAGMA max_page_count"
+#
+do_test pager1-6.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA auto_vacuum = none;
+ PRAGMA max_page_count = 10;
+ CREATE TABLE t2(a, b);
+ CREATE TABLE t3(a, b);
+ CREATE TABLE t4(a, b);
+ CREATE TABLE t5(a, b);
+ CREATE TABLE t6(a, b);
+ CREATE TABLE t7(a, b);
+ CREATE TABLE t8(a, b);
+ CREATE TABLE t9(a, b);
+ CREATE TABLE t10(a, b);
+ }
+} {10}
+do_catchsql_test pager1-6.2 {
+ CREATE TABLE t11(a, b)
+} {1 {database or disk is full}}
+do_execsql_test pager1-6.4 { PRAGMA max_page_count } {10}
+do_execsql_test pager1-6.5 { PRAGMA max_page_count = 15 } {15}
+do_execsql_test pager1-6.6 { CREATE TABLE t11(a, b) } {}
+do_execsql_test pager1-6.7 {
+ BEGIN;
+ INSERT INTO t11 VALUES(1, 2);
+ PRAGMA max_page_count = 13;
+} {13}
+do_execsql_test pager1-6.8 {
+ INSERT INTO t11 VALUES(3, 4);
+ PRAGMA max_page_count = 10;
+} {11}
+do_execsql_test pager1-6.9 { COMMIT } {}
+
+do_execsql_test pager1-6.10 { PRAGMA max_page_count = 10 } {11}
+do_execsql_test pager1-6.11 { SELECT * FROM t11 } {1 2 3 4}
+do_execsql_test pager1-6.12 { PRAGMA max_page_count } {11}
+
+
+#-------------------------------------------------------------------------
+# The following tests work with "PRAGMA journal_mode=TRUNCATE" and
+# "PRAGMA locking_mode=EXCLUSIVE".
+#
+# Each test is specified with 5 variables. As follows:
+#
+# $tn: Test Number. Used as part of the [do_test] test names.
+# $sql: SQL to execute.
+# $res: Expected result of executing $sql.
+# $js: The expected size of the journal file, in bytes, after executing
+# the SQL script. Or -1 if the journal is not expected to exist.
+# $ws: The expected size of the WAL file, in bytes, after executing
+# the SQL script. Or -1 if the WAL is not expected to exist.
+#
+ifcapable wal {
+ faultsim_delete_and_reopen
+ foreach {tn sql res js ws} [subst {
+
+ 1 {
+ CREATE TABLE t1(a, b);
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA synchronous=NORMAL;
+ PRAGMA page_size=1024;
+ PRAGMA locking_mode=EXCLUSIVE;
+ PRAGMA journal_mode=TRUNCATE;
+ INSERT INTO t1 VALUES(1, 2);
+ } {exclusive truncate} 0 -1
+
+ 2 {
+ BEGIN IMMEDIATE;
+ SELECT * FROM t1;
+ COMMIT;
+ } {1 2} 0 -1
+
+ 3 {
+ BEGIN;
+ SELECT * FROM t1;
+ COMMIT;
+ } {1 2} 0 -1
+
+ 4 { PRAGMA journal_mode = WAL } wal -1 -1
+ 5 { INSERT INTO t1 VALUES(3, 4) } {} -1 [wal_file_size 1 1024]
+ 6 { PRAGMA locking_mode = NORMAL } exclusive -1 [wal_file_size 1 1024]
+ 7 { INSERT INTO t1 VALUES(5, 6); } {} -1 [wal_file_size 2 1024]
+
+ 8 { PRAGMA journal_mode = TRUNCATE } truncate 0 -1
+ 9 { INSERT INTO t1 VALUES(7, 8) } {} 0 -1
+ 10 { SELECT * FROM t1 } {1 2 3 4 5 6 7 8} 0 -1
+
+ }] {
+ do_execsql_test pager1-7.1.$tn.1 $sql $res
+ catch { set J -1 ; set J [file size test.db-journal] }
+ catch { set W -1 ; set W [file size test.db-wal] }
+ do_test pager1-7.1.$tn.2 { list $J $W } [list $js $ws]
+ }
+}
+
+do_test pager1-7.2.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA locking_mode = EXCLUSIVE;
+ CREATE TABLE t1(a, b);
+ BEGIN;
+ PRAGMA journal_mode = delete;
+ PRAGMA journal_mode = truncate;
+ }
+} {exclusive delete truncate}
+do_test pager1-7.2.2 {
+ execsql { INSERT INTO t1 VALUES(1, 2) }
+ execsql { PRAGMA journal_mode = persist }
+} {truncate}
+do_test pager1-7.2.3 {
+ execsql { COMMIT }
+ execsql {
+ PRAGMA journal_mode = persist;
+ PRAGMA journal_size_limit;
+ }
+} {persist -1}
+
+#-------------------------------------------------------------------------
+# The following tests, pager1-8.*, test that the special filenames
+# ":memory:" and "" open temporary databases.
+#
+foreach {tn filename} {
+ 1 :memory:
+ 2 ""
+} {
+ do_test pager1-8.$tn.1 {
+ faultsim_delete_and_reopen
+ db close
+ sqlite3 db $filename
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE x1(x);
+ INSERT INTO x1 VALUES('Charles');
+ INSERT INTO x1 VALUES('James');
+ INSERT INTO x1 VALUES('Mary');
+ SELECT * FROM x1;
+ }
+ } {Charles James Mary}
+
+ do_test pager1-8.$tn.2 {
+ sqlite3 db2 $filename
+ catchsql { SELECT * FROM x1 } db2
+ } {1 {no such table: x1}}
+
+ do_execsql_test pager1-8.$tn.3 {
+ BEGIN;
+ INSERT INTO x1 VALUES('William');
+ INSERT INTO x1 VALUES('Anne');
+ ROLLBACK;
+ } {}
+}
+
+#-------------------------------------------------------------------------
+# The next block of tests - pager1-9.* - deal with interactions between
+# the pager and the backup API. Test cases:
+#
+# pager1-9.1.*: Test that a backup completes successfully even if the
+# source db is written to during the backup op.
+#
+# pager1-9.2.*: Test that a backup completes successfully even if the
+# source db is written to and then rolled back during a
+# backup operation.
+#
+do_test pager1-9.0.1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE ab(a, b, UNIQUE(a, b));
+ INSERT INTO ab VALUES( a_string(200), a_string(300) );
+ INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;
+ INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;
+ INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;
+ INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;
+ INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;
+ INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;
+ INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;
+ COMMIT;
+ }
+} {}
+do_test pager1-9.0.2 {
+ sqlite3 db2 test.db2
+ db2 eval { PRAGMA cache_size = 10 }
+ sqlite3_backup B db2 main db main
+ list [B step 10000] [B finish]
+} {SQLITE_DONE SQLITE_OK}
+do_test pager1-9.0.3 {
+ db one {SELECT md5sum(a, b) FROM ab}
+} [db2 one {SELECT md5sum(a, b) FROM ab}]
+
+do_test pager1-9.1.1 {
+ execsql { UPDATE ab SET a = a_string(201) }
+ sqlite3_backup B db2 main db main
+ B step 30
+} {SQLITE_OK}
+do_test pager1-9.1.2 {
+ execsql { UPDATE ab SET b = a_string(301) }
+ list [B step 10000] [B finish]
+} {SQLITE_DONE SQLITE_OK}
+do_test pager1-9.1.3 {
+ db one {SELECT md5sum(a, b) FROM ab}
+} [db2 one {SELECT md5sum(a, b) FROM ab}]
+do_test pager1-9.1.4 { execsql { SELECT count(*) FROM ab } } {128}
+
+do_test pager1-9.2.1 {
+ execsql { UPDATE ab SET a = a_string(202) }
+ sqlite3_backup B db2 main db main
+ B step 30
+} {SQLITE_OK}
+do_test pager1-9.2.2 {
+ execsql {
+ BEGIN;
+ UPDATE ab SET b = a_string(301);
+ ROLLBACK;
+ }
+ list [B step 10000] [B finish]
+} {SQLITE_DONE SQLITE_OK}
+do_test pager1-9.2.3 {
+ db one {SELECT md5sum(a, b) FROM ab}
+} [db2 one {SELECT md5sum(a, b) FROM ab}]
+do_test pager1-9.2.4 { execsql { SELECT count(*) FROM ab } } {128}
+db close
+db2 close
+
+do_test pager1-9.3.1 {
+ testvfs tv -default 1
+ tv sectorsize 4096
+ faultsim_delete_and_reopen
+
+ execsql { PRAGMA page_size = 1024 }
+ for {set ii 0} {$ii < 4} {incr ii} { execsql "CREATE TABLE t${ii}(a, b)" }
+} {}
+do_test pager1-9.3.2 {
+ sqlite3 db2 test.db2
+
+ execsql {
+ PRAGMA page_size = 4096;
+ PRAGMA synchronous = OFF;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ } db2
+
+ sqlite3_backup B db2 main db main
+ B step 30
+ list [B step 10000] [B finish]
+} {SQLITE_DONE SQLITE_OK}
+do_test pager1-9.3.3 {
+ db2 close
+ db close
+ tv delete
+ file size test.db2
+} [file size test.db]
+
+do_test pager1-9.4.1 {
+ faultsim_delete_and_reopen
+ sqlite3 db2 test.db2
+ execsql {
+ PRAGMA page_size = 4096;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ } db2
+ sqlite3_backup B db2 main db main
+ list [B step 10000] [B finish]
+} {SQLITE_DONE SQLITE_OK}
+do_test pager1-9.4.2 {
+ list [file size test.db2] [file size test.db]
+} {0 0}
+db2 close
+
+#-------------------------------------------------------------------------
+# Test that regardless of the value returned by xSectorSize(), the
+# minimum effective sector-size is 512 and the maximum 65536 bytes.
+#
+testvfs tv -default 1
+foreach sectorsize {
+ 32 64 128 256 512 1024 2048
+ 4096 8192 16384 32768 65536 131072 262144
+} {
+ tv sectorsize $sectorsize
+ set eff $sectorsize
+ if {$sectorsize < 512} { set eff 512 }
+ if {$sectorsize > 65536} { set eff 65536 }
+
+ do_test pager1-10.$sectorsize.1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ PRAGMA page_size = 1024;
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ CREATE TABLE t3(a, b);
+ COMMIT;
+ }
+ file size test.db-journal
+ } [expr $sectorsize > 65536 ? 65536 : $sectorsize]
+
+ do_test pager1-10.$sectorsize.2 {
+ execsql {
+ INSERT INTO t3 VALUES(a_string(300), a_string(300));
+ INSERT INTO t3 SELECT * FROM t3; /* 2 */
+ INSERT INTO t3 SELECT * FROM t3; /* 4 */
+ INSERT INTO t3 SELECT * FROM t3; /* 8 */
+ INSERT INTO t3 SELECT * FROM t3; /* 16 */
+ INSERT INTO t3 SELECT * FROM t3; /* 32 */
+ }
+ } {}
+
+ do_test pager1-10.$sectorsize.3 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ }
+ recursive_select 32 t3 {db eval "INSERT INTO t2 VALUES(1, 2)"}
+ execsql {
+ COMMIT;
+ SELECT * FROM t2;
+ }
+ } {1 2}
+
+ do_test pager1-10.$sectorsize.4 {
+ execsql {
+ CREATE TABLE t6(a, b);
+ CREATE TABLE t7(a, b);
+ CREATE TABLE t5(a, b);
+ DROP TABLE t6;
+ DROP TABLE t7;
+ }
+ execsql {
+ BEGIN;
+ CREATE TABLE t6(a, b);
+ }
+ recursive_select 32 t3 {db eval "INSERT INTO t5 VALUES(1, 2)"}
+ execsql {
+ COMMIT;
+ SELECT * FROM t5;
+ }
+ } {1 2}
+
+}
+db close
+
+tv sectorsize 4096
+do_test pager1.10.x.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA auto_vacuum = none;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ }
+ for {set i 0} {$i<30} {incr i} {
+ execsql { INSERT INTO t1 VALUES(zeroblob(900)) }
+ }
+ file size test.db
+} {32768}
+do_test pager1.10.x.2 {
+ execsql {
+ CREATE TABLE t2(x);
+ DROP TABLE t2;
+ }
+ file size test.db
+} {33792}
+do_test pager1.10.x.3 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t2(x);
+ }
+ recursive_select 30 t1
+ execsql {
+ CREATE TABLE t3(x);
+ COMMIT;
+ }
+} {}
+
+db close
+tv delete
+
+testvfs tv -default 1
+faultsim_delete_and_reopen
+db func a_string a_string
+do_execsql_test pager1-11.1 {
+ PRAGMA journal_mode = DELETE;
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE zz(top PRIMARY KEY);
+ INSERT INTO zz VALUES(a_string(222));
+ INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
+ INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
+ INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
+ INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
+ INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
+ COMMIT;
+ BEGIN;
+ UPDATE zz SET top = a_string(345);
+} {delete}
+
+proc lockout {method args} { return SQLITE_IOERR }
+tv script lockout
+tv filter {xWrite xTruncate xSync}
+do_catchsql_test pager1-11.2 { COMMIT } {1 {disk I/O error}}
+
+tv script {}
+do_test pager1-11.3 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA journal_mode = TRUNCATE;
+ PRAGMA integrity_check;
+ } db2
+} {truncate ok}
+do_test pager1-11.4 {
+ db2 close
+ file exists test.db-journal
+} {0}
+do_execsql_test pager1-11.5 { SELECT count(*) FROM zz } {32}
+db close
+tv delete
+
+#-------------------------------------------------------------------------
+# Test "PRAGMA page_size"
+#
+testvfs tv -default 1
+tv sectorsize 1024
+foreach pagesize {
+ 512 1024 2048 4096 8192 16384 32768
+} {
+ faultsim_delete_and_reopen
+
+ # The sector-size (according to the VFS) is 1024 bytes. So if the
+ # page-size requested using "PRAGMA page_size" is greater than the
+ # compile time value of SQLITE_MAX_PAGE_SIZE, then the effective
+ # page-size remains 1024 bytes.
+ #
+ set eff $pagesize
+ if {$eff > $::SQLITE_MAX_PAGE_SIZE} { set eff 1024 }
+
+ do_test pager1-12.$pagesize.1 {
+ sqlite3 db2 test.db
+ execsql "
+ PRAGMA page_size = $pagesize;
+ CREATE VIEW v AS SELECT * FROM sqlite_master;
+ " db2
+ file size test.db
+ } $eff
+ do_test pager1-12.$pagesize.2 {
+ sqlite3 db2 test.db
+ execsql {
+ SELECT count(*) FROM v;
+ PRAGMA main.page_size;
+ } db2
+ } [list 1 $eff]
+ do_test pager1-12.$pagesize.3 {
+ execsql {
+ SELECT count(*) FROM v;
+ PRAGMA main.page_size;
+ }
+ } [list 1 $eff]
+ db2 close
+}
+db close
+tv delete
+
+#-------------------------------------------------------------------------
+# Test specal "PRAGMA journal_mode=PERSIST" test cases.
+#
+# pager1-13.1.*: This tests a special case encountered in persistent
+# journal mode: If the journal associated with a transaction
+# is smaller than the journal file (because a previous
+# transaction left a very large non-hot journal file in the
+# file-system), then SQLite has to be careful that there is
+# not a journal-header left over from a previous transaction
+# immediately following the journal content just written.
+# If there is, and the process crashes so that the journal
+# becomes a hot-journal and must be rolled back by another
+# process, there is a danger that the other process may roll
+# back the aborted transaction, then continue copying data
+# from an older transaction from the remainder of the journal.
+# See the syncJournal() function for details.
+#
+# pager1-13.2.*: Same test as the previous. This time, throw an index into
+# the mix to make the integrity-check more likely to catch
+# errors.
+#
+testvfs tv -default 1
+tv script xSyncCb
+tv filter xSync
+proc xSyncCb {method filename args} {
+ set t [file tail $filename]
+ if {$t == "test.db"} faultsim_save
+ return SQLITE_OK
+}
+faultsim_delete_and_reopen
+db func a_string a_string
+
+# The UPDATE statement at the end of this test case creates a really big
+# journal. Since the cache-size is only 10 pages, the journal contains
+# frequent journal headers.
+#
+do_execsql_test pager1-13.1.1 {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = PERSIST;
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);
+ INSERT INTO t1 VALUES(NULL, a_string(400));
+ INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 64 */
+ INSERT INTO t1 SELECT NULL, a_string(400) FROM t1; /* 128 */
+ COMMIT;
+ UPDATE t1 SET b = a_string(400);
+} {persist}
+
+if {$::tcl_platform(platform)!="windows"} {
+# Run transactions of increasing sizes. Eventually, one (or more than one)
+# of these will write just enough content that one of the old headers created
+# by the transaction in the block above lies immediately after the content
+# journalled by the current transaction.
+#
+for {set nUp 1} {$nUp<64} {incr nUp} {
+ do_execsql_test pager1-13.1.2.$nUp.1 {
+ UPDATE t1 SET b = a_string(399) WHERE a <= $nUp
+ } {}
+ do_execsql_test pager1-13.1.2.$nUp.2 { PRAGMA integrity_check } {ok}
+
+ # Try to access the snapshot of the file-system.
+ #
+ sqlite3 db2 sv_test.db
+ do_test pager1-13.1.2.$nUp.3 {
+ execsql { SELECT sum(length(b)) FROM t1 } db2
+ } [expr {128*400 - ($nUp-1)}]
+ do_test pager1-13.1.2.$nUp.4 {
+ execsql { PRAGMA integrity_check } db2
+ } {ok}
+ db2 close
+}
+}
+
+if {$::tcl_platform(platform)!="windows"} {
+# Same test as above. But this time with an index on the table.
+#
+do_execsql_test pager1-13.2.1 {
+ CREATE INDEX i1 ON t1(b);
+ UPDATE t1 SET b = a_string(400);
+} {}
+for {set nUp 1} {$nUp<64} {incr nUp} {
+ do_execsql_test pager1-13.2.2.$nUp.1 {
+ UPDATE t1 SET b = a_string(399) WHERE a <= $nUp
+ } {}
+ do_execsql_test pager1-13.2.2.$nUp.2 { PRAGMA integrity_check } {ok}
+ sqlite3 db2 sv_test.db
+ do_test pager1-13.2.2.$nUp.3 {
+ execsql { SELECT sum(length(b)) FROM t1 } db2
+ } [expr {128*400 - ($nUp-1)}]
+ do_test pager1-13.2.2.$nUp.4 {
+ execsql { PRAGMA integrity_check } db2
+ } {ok}
+ db2 close
+}
+}
+
+db close
+tv delete
+
+#-------------------------------------------------------------------------
+# Test specal "PRAGMA journal_mode=OFF" test cases.
+#
+faultsim_delete_and_reopen
+do_execsql_test pager1-14.1.1 {
+ PRAGMA journal_mode = OFF;
+ CREATE TABLE t1(a, b);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ COMMIT;
+ SELECT * FROM t1;
+} {off 1 2}
+do_catchsql_test pager1-14.1.2 {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ ROLLBACK;
+} {0 {}}
+do_execsql_test pager1-14.1.3 {
+ SELECT * FROM t1;
+} {1 2}
+do_catchsql_test pager1-14.1.4 {
+ BEGIN;
+ INSERT INTO t1(rowid, a, b) SELECT a+3, b, b FROM t1;
+ INSERT INTO t1(rowid, a, b) SELECT a+3, b, b FROM t1;
+} {1 {PRIMARY KEY must be unique}}
+do_execsql_test pager1-14.1.5 {
+ COMMIT;
+ SELECT * FROM t1;
+} {1 2 2 2}
+
+#-------------------------------------------------------------------------
+# Test opening and closing the pager sub-system with different values
+# for the sqlite3_vfs.szOsFile variable.
+#
+faultsim_delete_and_reopen
+do_execsql_test pager1-15.0 {
+ CREATE TABLE tx(y, z);
+ INSERT INTO tx VALUES('Ayutthaya', 'Beijing');
+ INSERT INTO tx VALUES('London', 'Tokyo');
+} {}
+db close
+for {set i 0} {$i<513} {incr i 3} {
+ testvfs tv -default 1 -szosfile $i
+ sqlite3 db test.db
+ do_execsql_test pager1-15.$i.1 {
+ SELECT * FROM tx;
+ } {Ayutthaya Beijing London Tokyo}
+ db close
+ tv delete
+}
+
+#-------------------------------------------------------------------------
+# Check that it is not possible to open a database file if the full path
+# to the associated journal file will be longer than sqlite3_vfs.mxPathname.
+#
+testvfs tv -default 1
+tv script xOpenCb
+tv filter xOpen
+proc xOpenCb {method filename args} {
+ set ::file_len [string length $filename]
+}
+sqlite3 db test.db
+db close
+tv delete
+
+for {set ii [expr $::file_len-5]} {$ii < [expr $::file_len+20]} {incr ii} {
+ testvfs tv -default 1 -mxpathname $ii
+
+ # The length of the full path to file "test.db-journal" is ($::file_len+8).
+ # If the configured sqlite3_vfs.mxPathname value greater than or equal to
+ # this, then the file can be opened. Otherwise, it cannot.
+ #
+ if {$ii >= [expr $::file_len+8]} {
+ set res {0 {}}
+ } else {
+ set res {1 {unable to open database file}}
+ }
+
+ do_test pager1-16.1.$ii {
+ list [catch { sqlite3 db test.db } msg] $msg
+ } $res
+
+ catch {db close}
+ tv delete
+}
+
+#-------------------------------------------------------------------------
+# Test "PRAGMA omit_readlock".
+#
+# pager1-17.$tn.1.*: Test that if a second connection has an open
+# read-transaction, it is not usually possible to write
+# the database.
+#
+# pager1-17.$tn.2.*: Test that if the second connection was opened with
+# the SQLITE_OPEN_READONLY flag, and
+# "PRAGMA omit_readlock = 1" is executed before attaching
+# the database and opening a read-transaction on it, it is
+# possible to write the db.
+#
+# pager1-17.$tn.3.*: Test that if the second connection was *not* opened with
+# the SQLITE_OPEN_READONLY flag, executing
+# "PRAGMA omit_readlock = 1" has no effect.
+#
+do_multiclient_test tn {
+ do_test pager1-17.$tn.1.1 {
+ sql1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ sql2 {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ } {1 2}
+ do_test pager1-17.$tn.1.2 {
+ csql1 { INSERT INTO t1 VALUES(3, 4) }
+ } {1 {database is locked}}
+ do_test pager1-17.$tn.1.3 {
+ sql2 { COMMIT }
+ sql1 { INSERT INTO t1 VALUES(3, 4) }
+ } {}
+
+ do_test pager1-17.$tn.2.1 {
+ code2 {
+ db2 close
+ sqlite3 db2 :memory: -readonly 1
+ }
+ sql2 {
+ PRAGMA omit_readlock = 1;
+ ATTACH 'test.db' AS two;
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4}
+ do_test pager1-17.$tn.2.2 { sql1 "INSERT INTO t1 VALUES(5, 6)" } {}
+ do_test pager1-17.$tn.2.3 { sql2 "SELECT * FROM t1" } {1 2 3 4}
+ do_test pager1-17.$tn.2.4 { sql2 "COMMIT ; SELECT * FROM t1" } {1 2 3 4 5 6}
+
+ do_test pager1-17.$tn.3.1 {
+ code2 {
+ db2 close
+ sqlite3 db2 :memory:
+ }
+ sql2 {
+ PRAGMA omit_readlock = 1;
+ ATTACH 'test.db' AS two;
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4 5 6}
+ do_test pager1-17.$tn.3.2 {
+ csql1 { INSERT INTO t1 VALUES(3, 4) }
+ } {1 {database is locked}}
+ do_test pager1-17.$tn.3.3 { sql2 COMMIT } {}
+}
+
+#-------------------------------------------------------------------------
+# Test the pagers response to the b-tree layer requesting illegal page
+# numbers:
+#
+# + The locking page,
+# + Page 0,
+# + A page with a page number greater than (2^31-1).
+#
+# These tests will not work if SQLITE_DIRECT_OVERFLOW_READ is defined. In
+# that case IO errors are sometimes reported instead of SQLITE_CORRUPT.
+#
+ifcapable !direct_read {
+do_test pager1-18.1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(a_string(500), a_string(200));
+ INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;
+ INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;
+ INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;
+ INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;
+ INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;
+ INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;
+ INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;
+ }
+} {}
+do_test pager1-18.2 {
+ set root [db one "SELECT rootpage FROM sqlite_master"]
+ set lockingpage [expr (0x10000/1024) + 1]
+ execsql {
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master SET rootpage = $lockingpage;
+ }
+ sqlite3 db2 test.db
+ catchsql { SELECT count(*) FROM t1 } db2
+} {1 {database disk image is malformed}}
+db2 close
+do_test pager1-18.3 {
+ execsql {
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES(a_string(5000));
+ }
+ set pgno [expr ([file size test.db] / 1024)-2]
+ hexio_write test.db [expr ($pgno-1)*1024] 00000000
+ sqlite3 db2 test.db
+ catchsql { SELECT length(x) FROM t2 } db2
+} {1 {database disk image is malformed}}
+db2 close
+do_test pager1-18.4 {
+ hexio_write test.db [expr ($pgno-1)*1024] 90000000
+ sqlite3 db2 test.db
+ catchsql { SELECT length(x) FROM t2 } db2
+} {1 {database disk image is malformed}}
+db2 close
+do_test pager1-18.5 {
+ sqlite3 db ""
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master SET rootpage=5 WHERE tbl_name = 't1';
+ PRAGMA writable_schema = 0;
+ ALTER TABLE t1 RENAME TO x1;
+ }
+ catchsql { SELECT * FROM x1 }
+} {1 {database disk image is malformed}}
+db close
+
+do_test pager1-18.6 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(a_string(800));
+ INSERT INTO t1 VALUES(a_string(800));
+ }
+
+ set root [db one "SELECT rootpage FROM sqlite_master"]
+ db close
+
+ hexio_write test.db [expr ($root-1)*1024 + 8] 00000000
+ sqlite3 db test.db
+ catchsql { SELECT length(x) FROM t1 }
+} {1 {database disk image is malformed}}
+}
+
+do_test pager1-19.1 {
+ sqlite3 db ""
+ db func a_string a_string
+ execsql {
+ PRAGMA page_size = 512;
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an,
+ ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm, bn,
+ ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm, cn,
+ da, db, dc, dd, de, df, dg, dh, di, dj, dk, dl, dm, dn,
+ ea, eb, ec, ed, ee, ef, eg, eh, ei, ej, ek, el, em, en,
+ fa, fb, fc, fd, fe, ff, fg, fh, fi, fj, fk, fl, fm, fn,
+ ga, gb, gc, gd, ge, gf, gg, gh, gi, gj, gk, gl, gm, gn,
+ ha, hb, hc, hd, he, hf, hg, hh, hi, hj, hk, hl, hm, hn,
+ ia, ib, ic, id, ie, if, ig, ih, ii, ij, ik, il, im, ix,
+ ja, jb, jc, jd, je, jf, jg, jh, ji, jj, jk, jl, jm, jn,
+ ka, kb, kc, kd, ke, kf, kg, kh, ki, kj, kk, kl, km, kn,
+ la, lb, lc, ld, le, lf, lg, lh, li, lj, lk, ll, lm, ln,
+ ma, mb, mc, md, me, mf, mg, mh, mi, mj, mk, ml, mm, mn
+ );
+ CREATE TABLE t2(aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an,
+ ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm, bn,
+ ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm, cn,
+ da, db, dc, dd, de, df, dg, dh, di, dj, dk, dl, dm, dn,
+ ea, eb, ec, ed, ee, ef, eg, eh, ei, ej, ek, el, em, en,
+ fa, fb, fc, fd, fe, ff, fg, fh, fi, fj, fk, fl, fm, fn,
+ ga, gb, gc, gd, ge, gf, gg, gh, gi, gj, gk, gl, gm, gn,
+ ha, hb, hc, hd, he, hf, hg, hh, hi, hj, hk, hl, hm, hn,
+ ia, ib, ic, id, ie, if, ig, ih, ii, ij, ik, il, im, ix,
+ ja, jb, jc, jd, je, jf, jg, jh, ji, jj, jk, jl, jm, jn,
+ ka, kb, kc, kd, ke, kf, kg, kh, ki, kj, kk, kl, km, kn,
+ la, lb, lc, ld, le, lf, lg, lh, li, lj, lk, ll, lm, ln,
+ ma, mb, mc, md, me, mf, mg, mh, mi, mj, mk, ml, mm, mn
+ );
+ INSERT INTO t1(aa) VALUES( a_string(100000) );
+ INSERT INTO t2(aa) VALUES( a_string(100000) );
+ VACUUM;
+ }
+} {}
+
+#-------------------------------------------------------------------------
+# Test a couple of special cases that come up while committing
+# transactions:
+#
+# pager1-20.1.*: Committing an in-memory database transaction when the
+# database has not been modified at all.
+#
+# pager1-20.2.*: As above, but with a normal db in exclusive-locking mode.
+#
+# pager1-20.3.*: Committing a transaction in WAL mode where the database has
+# been modified, but all dirty pages have been flushed to
+# disk before the commit.
+#
+do_test pager1-20.1.1 {
+ catch {db close}
+ sqlite3 db :memory:
+ execsql {
+ CREATE TABLE one(two, three);
+ INSERT INTO one VALUES('a', 'b');
+ }
+} {}
+do_test pager1-20.1.2 {
+ execsql {
+ BEGIN EXCLUSIVE;
+ COMMIT;
+ }
+} {}
+
+do_test pager1-20.2.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA locking_mode = exclusive;
+ PRAGMA journal_mode = persist;
+ CREATE TABLE one(two, three);
+ INSERT INTO one VALUES('a', 'b');
+ }
+} {exclusive persist}
+do_test pager1-20.2.2 {
+ execsql {
+ BEGIN EXCLUSIVE;
+ COMMIT;
+ }
+} {}
+
+ifcapable wal {
+ do_test pager1-20.3.1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA journal_mode = wal;
+ BEGIN;
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(y);
+ INSERT INTO t1 VALUES(a_string(800));
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 32 */
+ COMMIT;
+ }
+ } {wal}
+ do_test pager1-20.3.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO t2 VALUES('xxxx');
+ }
+ recursive_select 32 t1
+ execsql COMMIT
+ } {}
+}
+
+#-------------------------------------------------------------------------
+# Test that a WAL database may not be opened if:
+#
+# pager1-21.1.*: The VFS has an iVersion less than 2, or
+# pager1-21.2.*: The VFS does not provide xShmXXX() methods.
+#
+ifcapable wal {
+ do_test pager1-21.0 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE ko(c DEFAULT 'abc', b DEFAULT 'def');
+ INSERT INTO ko DEFAULT VALUES;
+ }
+ } {wal}
+ do_test pager1-21.1 {
+ testvfs tv -noshm 1
+ sqlite3 db2 test.db -vfs tv
+ catchsql { SELECT * FROM ko } db2
+ } {1 {unable to open database file}}
+ db2 close
+ tv delete
+ do_test pager1-21.2 {
+ testvfs tv -iversion 1
+ sqlite3 db2 test.db -vfs tv
+ catchsql { SELECT * FROM ko } db2
+ } {1 {unable to open database file}}
+ db2 close
+ tv delete
+}
+
+#-------------------------------------------------------------------------
+# Test that a "PRAGMA wal_checkpoint":
+#
+# pager1-22.1.*: is a no-op on a non-WAL db, and
+# pager1-22.2.*: does not cause xSync calls with a synchronous=off db.
+#
+ifcapable wal {
+ do_test pager1-22.1.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE ko(c DEFAULT 'abc', b DEFAULT 'def');
+ INSERT INTO ko DEFAULT VALUES;
+ }
+ execsql { PRAGMA wal_checkpoint }
+ } {0 -1 -1}
+ do_test pager1-22.2.1 {
+ testvfs tv -default 1
+ tv filter xSync
+ tv script xSyncCb
+ proc xSyncCb {args} {incr ::synccount}
+ set ::synccount 0
+ sqlite3 db test.db
+ execsql {
+ PRAGMA synchronous = off;
+ PRAGMA journal_mode = WAL;
+ INSERT INTO ko DEFAULT VALUES;
+ }
+ execsql { PRAGMA wal_checkpoint }
+ set synccount
+ } {0}
+ db close
+ tv delete
+}
+
+#-------------------------------------------------------------------------
+# Tests for changing journal mode.
+#
+# pager1-23.1.*: Test that when changing from PERSIST to DELETE mode,
+# the journal file is deleted.
+#
+# pager1-23.2.*: Same test as above, but while a shared lock is held
+# on the database file.
+#
+# pager1-23.3.*: Same test as above, but while a reserved lock is held
+# on the database file.
+#
+# pager1-23.4.*: And, for fun, while holding an exclusive lock.
+#
+# pager1-23.5.*: Try to set various different journal modes with an
+# in-memory database (only MEMORY and OFF should work).
+#
+# pager1-23.6.*: Try to set locking_mode=normal on an in-memory database
+# (doesn't work - in-memory databases always use
+# locking_mode=exclusive).
+#
+do_test pager1-23.1.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ CREATE TABLE t1(a, b);
+ }
+ file exists test.db-journal
+} {1}
+do_test pager1-23.1.2 {
+ execsql { PRAGMA journal_mode = DELETE }
+ file exists test.db-journal
+} {0}
+
+do_test pager1-23.2.1 {
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ INSERT INTO t1 VALUES('Canberra', 'ACT');
+ }
+ db eval { SELECT * FROM t1 } {
+ db eval { PRAGMA journal_mode = DELETE }
+ }
+ execsql { PRAGMA journal_mode }
+} {delete}
+do_test pager1-23.2.2 {
+ file exists test.db-journal
+} {0}
+
+do_test pager1-23.3.1 {
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ INSERT INTO t1 VALUES('Darwin', 'NT');
+ BEGIN IMMEDIATE;
+ }
+ db eval { PRAGMA journal_mode = DELETE }
+ execsql { PRAGMA journal_mode }
+} {delete}
+do_test pager1-23.3.2 {
+ file exists test.db-journal
+} {0}
+do_test pager1-23.3.3 {
+ execsql COMMIT
+} {}
+
+do_test pager1-23.4.1 {
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ INSERT INTO t1 VALUES('Adelaide', 'SA');
+ BEGIN EXCLUSIVE;
+ }
+ db eval { PRAGMA journal_mode = DELETE }
+ execsql { PRAGMA journal_mode }
+} {delete}
+do_test pager1-23.4.2 {
+ file exists test.db-journal
+} {0}
+do_test pager1-23.4.3 {
+ execsql COMMIT
+} {}
+
+do_test pager1-23.5.1 {
+ faultsim_delete_and_reopen
+ sqlite3 db :memory:
+} {}
+foreach {tn mode possible} {
+ 2 off 1
+ 3 memory 1
+ 4 persist 0
+ 5 delete 0
+ 6 wal 0
+ 7 truncate 0
+} {
+ do_test pager1-23.5.$tn.1 {
+ execsql "PRAGMA journal_mode = off"
+ execsql "PRAGMA journal_mode = $mode"
+ } [if $possible {list $mode} {list off}]
+ do_test pager1-23.5.$tn.2 {
+ execsql "PRAGMA journal_mode = memory"
+ execsql "PRAGMA journal_mode = $mode"
+ } [if $possible {list $mode} {list memory}]
+}
+do_test pager1-23.6.1 {
+ execsql {PRAGMA locking_mode = normal}
+} {exclusive}
+do_test pager1-23.6.2 {
+ execsql {PRAGMA locking_mode = exclusive}
+} {exclusive}
+do_test pager1-23.6.3 {
+ execsql {PRAGMA locking_mode}
+} {exclusive}
+do_test pager1-23.6.4 {
+ execsql {PRAGMA main.locking_mode}
+} {exclusive}
+
+#-------------------------------------------------------------------------
+#
+do_test pager1-24.1.1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA auto_vacuum = FULL;
+ CREATE TABLE x1(x, y, z, PRIMARY KEY(y, z));
+ CREATE TABLE x2(x, y, z, PRIMARY KEY(y, z));
+ INSERT INTO x2 VALUES(a_string(400), a_string(500), a_string(600));
+ INSERT INTO x2 SELECT a_string(600), a_string(400), a_string(500) FROM x2;
+ INSERT INTO x2 SELECT a_string(500), a_string(600), a_string(400) FROM x2;
+ INSERT INTO x2 SELECT a_string(400), a_string(500), a_string(600) FROM x2;
+ INSERT INTO x2 SELECT a_string(600), a_string(400), a_string(500) FROM x2;
+ INSERT INTO x2 SELECT a_string(500), a_string(600), a_string(400) FROM x2;
+ INSERT INTO x2 SELECT a_string(400), a_string(500), a_string(600) FROM x2;
+ INSERT INTO x1 SELECT * FROM x2;
+ }
+} {}
+do_test pager1-24.1.2 {
+ execsql {
+ BEGIN;
+ DELETE FROM x1 WHERE rowid<32;
+ }
+ recursive_select 64 x2
+} {}
+do_test pager1-24.1.3 {
+ execsql {
+ UPDATE x1 SET z = a_string(300) WHERE rowid>40;
+ COMMIT;
+ PRAGMA integrity_check;
+ SELECT count(*) FROM x1;
+ }
+} {ok 33}
+
+do_test pager1-24.1.4 {
+ execsql {
+ DELETE FROM x1;
+ INSERT INTO x1 SELECT * FROM x2;
+ BEGIN;
+ DELETE FROM x1 WHERE rowid<32;
+ UPDATE x1 SET z = a_string(299) WHERE rowid>40;
+ }
+ recursive_select 64 x2 {db eval COMMIT}
+ execsql {
+ PRAGMA integrity_check;
+ SELECT count(*) FROM x1;
+ }
+} {ok 33}
+
+do_test pager1-24.1.5 {
+ execsql {
+ DELETE FROM x1;
+ INSERT INTO x1 SELECT * FROM x2;
+ }
+ recursive_select 64 x2 { db eval {CREATE TABLE x3(x, y, z)} }
+ execsql { SELECT * FROM x3 }
+} {}
+
+#-------------------------------------------------------------------------
+#
+do_test pager1-25-1 {
+ faultsim_delete_and_reopen
+ execsql {
+ BEGIN;
+ SAVEPOINT abc;
+ CREATE TABLE t1(a, b);
+ ROLLBACK TO abc;
+ COMMIT;
+ }
+ db close
+} {}
+breakpoint
+do_test pager1-25-2 {
+ faultsim_delete_and_reopen
+ execsql {
+ SAVEPOINT abc;
+ CREATE TABLE t1(a, b);
+ ROLLBACK TO abc;
+ COMMIT;
+ }
+ db close
+} {}
+
+#-------------------------------------------------------------------------
+# Sector-size tests.
+#
+do_test pager1-26.1 {
+ testvfs tv -default 1
+ tv sectorsize 4096
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA page_size = 512;
+ CREATE TABLE tbl(a PRIMARY KEY, b UNIQUE);
+ BEGIN;
+ INSERT INTO tbl VALUES(a_string(25), a_string(600));
+ INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
+ INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
+ INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
+ INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
+ INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
+ INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
+ INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
+ COMMIT;
+ }
+} {}
+do_execsql_test pager1-26.1 {
+ UPDATE tbl SET b = a_string(550);
+} {}
+db close
+tv delete
+
+#-------------------------------------------------------------------------
+#
+do_test pager1.27.1 {
+ faultsim_delete_and_reopen
+ sqlite3_pager_refcounts db
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ }
+ sqlite3_pager_refcounts db
+ execsql COMMIT
+} {}
+
+#-------------------------------------------------------------------------
+# Test that attempting to open a write-transaction with
+# locking_mode=exclusive in WAL mode fails if there are other clients on
+# the same database.
+#
+catch { db close }
+ifcapable wal {
+ do_multiclient_test tn {
+ do_test pager1-28.$tn.1 {
+ sql1 {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('a', 'b');
+ }
+ } {wal}
+ do_test pager1-28.$tn.2 { sql2 { SELECT * FROM t1 } } {a b}
+
+ do_test pager1-28.$tn.3 { sql1 { PRAGMA locking_mode=exclusive } } {exclusive}
+ do_test pager1-28.$tn.4 {
+ csql1 { BEGIN; INSERT INTO t1 VALUES('c', 'd'); }
+ } {1 {database is locked}}
+ code2 { db2 close ; sqlite3 db2 test.db }
+ do_test pager1-28.$tn.4 {
+ sql1 { INSERT INTO t1 VALUES('c', 'd'); COMMIT }
+ } {}
+ }
+}
+
+#-------------------------------------------------------------------------
+# Normally, when changing from journal_mode=PERSIST to DELETE the pager
+# attempts to delete the journal file. However, if it cannot obtain a
+# RESERVED lock on the database file, this step is skipped.
+#
+do_multiclient_test tn {
+ do_test pager1-28.$tn.1 {
+ sql1 {
+ PRAGMA journal_mode = PERSIST;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('a', 'b');
+ }
+ } {persist}
+ do_test pager1-28.$tn.2 { file exists test.db-journal } 1
+ do_test pager1-28.$tn.3 { sql1 { PRAGMA journal_mode = DELETE } } delete
+ do_test pager1-28.$tn.4 { file exists test.db-journal } 0
+
+ do_test pager1-28.$tn.5 {
+ sql1 {
+ PRAGMA journal_mode = PERSIST;
+ INSERT INTO t1 VALUES('c', 'd');
+ }
+ } {persist}
+ do_test pager1-28.$tn.6 { file exists test.db-journal } 1
+ do_test pager1-28.$tn.7 {
+ sql2 { BEGIN; INSERT INTO t1 VALUES('e', 'f'); }
+ } {}
+ do_test pager1-28.$tn.8 { file exists test.db-journal } 1
+ do_test pager1-28.$tn.9 { sql1 { PRAGMA journal_mode = DELETE } } delete
+ do_test pager1-28.$tn.10 { file exists test.db-journal } 1
+
+ do_test pager1-28.$tn.11 { sql2 COMMIT } {}
+ do_test pager1-28.$tn.12 { file exists test.db-journal } 0
+
+ do_test pager1-28-$tn.13 {
+ code1 { set channel [db incrblob -readonly t1 a 2] }
+ sql1 {
+ PRAGMA journal_mode = PERSIST;
+ INSERT INTO t1 VALUES('g', 'h');
+ }
+ } {persist}
+ do_test pager1-28.$tn.14 { file exists test.db-journal } 1
+ do_test pager1-28.$tn.15 {
+ sql2 { BEGIN; INSERT INTO t1 VALUES('e', 'f'); }
+ } {}
+ do_test pager1-28.$tn.16 { sql1 { PRAGMA journal_mode = DELETE } } delete
+ do_test pager1-28.$tn.17 { file exists test.db-journal } 1
+
+ do_test pager1-28.$tn.17 { csql2 { COMMIT } } {1 {database is locked}}
+ do_test pager1-28-$tn.18 { code1 { read $channel } } c
+ do_test pager1-28-$tn.19 { code1 { close $channel } } {}
+ do_test pager1-28.$tn.20 { sql2 { COMMIT } } {}
+}
+
+do_test pager1-29.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = full;
+ PRAGMA locking_mode=exclusive;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ file size test.db
+} [expr 1024*3]
+do_test pager1-29.2 {
+ execsql {
+ PRAGMA page_size = 4096;
+ VACUUM;
+ }
+ file size test.db
+} [expr 4096*3]
+
+#-------------------------------------------------------------------------
+# Test that if an empty database file (size 0 bytes) is opened in
+# exclusive-locking mode, any journal file is deleted from the file-system
+# without being rolled back. And that the RESERVED lock obtained while
+# doing this is not released.
+#
+do_test pager1-30.1 {
+ db close
+ delete_file test.db
+ delete_file test.db-journal
+ set fd [open test.db-journal w]
+ seek $fd [expr 512+1032*2]
+ puts -nonewline $fd x
+ close $fd
+
+ sqlite3 db test.db
+ execsql {
+ PRAGMA locking_mode=EXCLUSIVE;
+ SELECT count(*) FROM sqlite_master;
+ PRAGMA lock_status;
+ }
+} {exclusive 0 main reserved temp closed}
+
+#-------------------------------------------------------------------------
+# Test that if the "page-size" field in a journal-header is 0, the journal
+# file can still be rolled back. This is required for backward compatibility -
+# versions of SQLite prior to 3.5.8 always set this field to zero.
+#
+if {$tcl_platform(platform)=="unix"} {
+do_test pager1-31.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x, y, UNIQUE(x, y));
+ INSERT INTO t1 VALUES(randomblob(1500), randomblob(1500));
+ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
+ BEGIN;
+ UPDATE t1 SET y = randomblob(1499);
+ }
+ copy_file test.db test.db2
+ copy_file test.db-journal test.db2-journal
+
+ hexio_write test.db2-journal 24 00000000
+ sqlite3 db2 test.db2
+ execsql { PRAGMA integrity_check } db2
+} {ok}
+}
+
+#-------------------------------------------------------------------------
+# Test that a database file can be "pre-hinted" to a certain size and that
+# subsequent spilling of the pager cache does not result in the database
+# file being shrunk.
+#
+catch {db close}
+forcedelete test.db
+
+do_test pager1-32.1 {
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(x, y);
+ }
+ db close
+ sqlite3 db test.db
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1, randomblob(10000));
+ }
+ file_control_chunksize_test db main 1024
+ file_control_sizehint_test db main 20971520; # 20MB
+ execsql {
+ PRAGMA cache_size = 10;
+ INSERT INTO t1 VALUES(1, randomblob(10000));
+ INSERT INTO t1 VALUES(2, randomblob(10000));
+ INSERT INTO t1 SELECT x+2, randomblob(10000) from t1;
+ INSERT INTO t1 SELECT x+4, randomblob(10000) from t1;
+ INSERT INTO t1 SELECT x+8, randomblob(10000) from t1;
+ INSERT INTO t1 SELECT x+16, randomblob(10000) from t1;
+ SELECT count(*) FROM t1;
+ COMMIT;
+ }
+ db close
+ file size test.db
+} {20971520}
+
+# Cleanup 20MB file left by the previous test.
+forcedelete test.db
+
+finish_test
diff --git a/test/pager2.test b/test/pager2.test
new file mode 100644
index 0000000..fa5f7b9
--- /dev/null
+++ b/test/pager2.test
@@ -0,0 +1,151 @@
+# 2010 June 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+set otn 0
+testvfs tv -default 1
+foreach code [list {
+ set s 512
+} {
+ set s 1024
+ set sql { PRAGMA journal_mode = memory }
+} {
+ set s 1024
+ set sql {
+ PRAGMA journal_mode = memory;
+ PRAGMA locking_mode = exclusive;
+ }
+} {
+ set s 2048
+ tv devchar safe_append
+} {
+ set s 4096
+} {
+ set s 4096
+ set sql { PRAGMA journal_mode = WAL }
+} {
+ set s 4096
+ set sql { PRAGMA auto_vacuum = 1 }
+} {
+ set s 8192
+ set sql { PRAGMA synchronous = off }
+}] {
+
+ incr otn
+ set sql ""
+ tv devchar {}
+ eval $code
+ tv sectorsize $s
+
+ do_test pager2-1.$otn.0 {
+ faultsim_delete_and_reopen
+ execsql $sql
+ execsql {
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(i INTEGER PRIMARY KEY, j blob);
+ }
+ } {}
+
+ set tn 0
+ set lowpoint 0
+ foreach x {
+ 100 x 0 100
+ x
+ 70 22 96 59 96 50 22 56 21 16 37 64 43 40 0 38 22 38 55 0 6
+ 43 62 32 93 54 18 13 29 45 66 29 25 61 31 53 82 75 25 96 86 10 69
+ 2 29 6 60 80 95 42 82 85 50 68 96 90 39 78 69 87 97 48 74 65 43
+ x
+ 86 34 26 50 41 85 58 44 89 22 6 51 45 46 58 32 97 6 1 12 32 2
+ 69 39 48 71 33 31 5 58 90 43 24 54 12 9 18 57 4 38 91 42 27 45
+ 50 38 56 29 10 0 26 37 83 1 78 15 47 30 75 62 46 29 68 5 30 4
+ 27 96 33 95 79 75 56 10 29 70 32 75 52 88 5 36 50 57 46 63 88 65
+ x
+ 44 95 64 20 24 35 69 61 61 2 35 92 42 46 23 98 78 1 38 72 79 35
+ 94 37 13 59 5 93 27 58 80 75 58 7 67 13 10 76 84 4 8 70 81 45
+ 8 41 98 5 60 26 92 29 91 90 2 62 40 4 5 22 80 15 83 76 52 88
+ 29 5 68 73 72 7 54 17 89 32 81 94 51 28 53 71 8 42 54 59 70 79
+ x
+ } {
+ incr tn
+ set now [db one {SELECT count(i) FROM t1}]
+ if {$x == "x"} {
+ execsql { COMMIT ; BEGIN }
+ set lowpoint $now
+ do_test pager2.1.$otn.$tn {
+ sqlite3 db2 test.db
+ execsql {
+ SELECT COALESCE(max(i), 0) FROM t1;
+ PRAGMA integrity_check;
+ }
+ } [list $lowpoint ok]
+ db2 close
+ } else {
+ if {$now > $x } {
+ if { $x>=$lowpoint } {
+ execsql "ROLLBACK TO sp_$x"
+ } else {
+ execsql "DELETE FROM t1 WHERE i>$x"
+ set lowpoint $x
+ }
+ } elseif {$now < $x} {
+ for {set k $now} {$k < $x} {incr k} {
+ execsql "SAVEPOINT sp_$k"
+ execsql { INSERT INTO t1(j) VALUES(randomblob(1500)) }
+ }
+ }
+ do_execsql_test pager2.1.$otn.$tn {
+ SELECT COALESCE(max(i), 0) FROM t1;
+ PRAGMA integrity_check;
+ } [list $x ok]
+ }
+ }
+}
+db close
+tv delete
+
+
+#-------------------------------------------------------------------------
+#
+# pager2-2.1: Test a ROLLBACK with journal_mode=off.
+# pager2-2.2: Test shrinking the database (auto-vacuum) with
+# journal_mode=off
+#
+do_test pager2-2.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE t1(a, b);
+ PRAGMA journal_mode = off;
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {off}
+do_test pager2-2.2 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA auto_vacuum = incremental;
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = off;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(zeroblob(5000), zeroblob(5000));
+ DELETE FROM t1;
+ PRAGMA incremental_vacuum;
+ }
+ file size test.db
+} {3072}
+
+finish_test
diff --git a/test/pager3.test b/test/pager3.test
new file mode 100644
index 0000000..23435a7
--- /dev/null
+++ b/test/pager3.test
@@ -0,0 +1,33 @@
+# 2010 June 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+source $testdir/wal_common.tcl
+
+
+foreach {tn sql res j} {
+ 1 "PRAGMA journal_mode = DELETE" delete 0
+ 2 "CREATE TABLE t1(a, b)" {} 0
+ 3 "PRAGMA locking_mode=EXCLUSIVE" {exclusive} 0
+ 4 "INSERT INTO t1 VALUES(1, 2)" {} 1
+ 5 "PRAGMA locking_mode=NORMAL" {normal} 1
+ 6 "SELECT * FROM t1" {1 2} 0
+} {
+ do_execsql_test pager3-1.$tn.1 $sql $res
+ do_test pager3-1.$tn.2 { file exists test.db-journal } $j
+}
+
+
+finish_test
diff --git a/test/pagerfault.test b/test/pagerfault.test
new file mode 100644
index 0000000..e04e97e
--- /dev/null
+++ b/test/pagerfault.test
@@ -0,0 +1,1250 @@
+# 2010 June 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+if {[permutation] == "inmemory_journal"} {
+ finish_test
+ return
+}
+
+if {$::tcl_platform(platform)=="windows"} {
+ finish_test
+ return
+}
+
+set a_string_counter 1
+proc a_string {n} {
+ global a_string_counter
+ incr a_string_counter
+ string range [string repeat "${a_string_counter}." $n] 1 $n
+}
+db func a_string a_string
+
+#-------------------------------------------------------------------------
+# Test fault-injection while rolling back a hot-journal file.
+#
+do_test pagerfault-1-pre1 {
+ execsql {
+ PRAGMA journal_mode = DELETE;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a UNIQUE, b UNIQUE);
+ INSERT INTO t1 VALUES(a_string(200), a_string(300));
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ BEGIN;
+ INSERT INTO t1 SELECT a_string(201), a_string(301) FROM t1;
+ INSERT INTO t1 SELECT a_string(202), a_string(302) FROM t1;
+ INSERT INTO t1 SELECT a_string(203), a_string(303) FROM t1;
+ INSERT INTO t1 SELECT a_string(204), a_string(304) FROM t1;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { SELECT count(*) FROM t1 }
+} -test {
+ faultsim_test_result {0 4}
+ faultsim_integrity_check
+ if {[db one { SELECT count(*) FROM t1 }] != 4} {
+ error "Database content appears incorrect"
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test fault-injection while rolling back a hot-journal file with a
+# page-size different from the current value stored on page 1 of the
+# database file.
+#
+do_test pagerfault-2-pre1 {
+ testvfs tv -default 1
+ tv filter xSync
+ tv script xSyncCb
+ proc xSyncCb {filename args} {
+ if {[string match *journal filename]==0} faultsim_save
+ }
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA page_size = 4096;
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES('o', 't', 't');
+ INSERT INTO abc VALUES('f', 'f', 's');
+ INSERT INTO abc SELECT * FROM abc; -- 4
+ INSERT INTO abc SELECT * FROM abc; -- 8
+ INSERT INTO abc SELECT * FROM abc; -- 16
+ INSERT INTO abc SELECT * FROM abc; -- 32
+ INSERT INTO abc SELECT * FROM abc; -- 64
+ INSERT INTO abc SELECT * FROM abc; -- 128
+ INSERT INTO abc SELECT * FROM abc; -- 256
+ COMMIT;
+ PRAGMA page_size = 1024;
+ VACUUM;
+ }
+ db close
+ tv delete
+} {}
+do_faultsim_test pagerfault-2 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { SELECT * FROM abc }
+} -test {
+ set answer [split [string repeat "ottffs" 128] ""]
+ faultsim_test_result [list 0 $answer]
+ faultsim_integrity_check
+ set res [db eval { SELECT * FROM abc }]
+ if {$res != $answer} { error "Database content appears incorrect ($res)" }
+}
+
+#-------------------------------------------------------------------------
+# Test fault-injection while rolling back hot-journals that were created
+# as part of a multi-file transaction.
+#
+do_test pagerfault-3-pre1 {
+ testvfs tstvfs -default 1
+ tstvfs filter xDelete
+ tstvfs script xDeleteCallback
+
+ proc xDeleteCallback {method file args} {
+ set file [file tail $file]
+ if { [string match *mj* $file] } { faultsim_save }
+ }
+
+ faultsim_delete_and_reopen
+ db func a_string a_string
+
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ PRAGMA journal_mode = DELETE;
+ PRAGMA main.cache_size = 10;
+ PRAGMA aux.cache_size = 10;
+
+ CREATE TABLE t1(a UNIQUE, b UNIQUE);
+ CREATE TABLE aux.t2(a UNIQUE, b UNIQUE);
+ INSERT INTO t1 VALUES(a_string(200), a_string(300));
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t2 SELECT * FROM t1;
+
+ BEGIN;
+ INSERT INTO t1 SELECT a_string(201), a_string(301) FROM t1;
+ INSERT INTO t1 SELECT a_string(202), a_string(302) FROM t1;
+ INSERT INTO t1 SELECT a_string(203), a_string(303) FROM t1;
+ INSERT INTO t1 SELECT a_string(204), a_string(304) FROM t1;
+ REPLACE INTO t2 SELECT * FROM t1;
+ COMMIT;
+ }
+
+ db close
+ tstvfs delete
+} {}
+do_faultsim_test pagerfault-3 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ SELECT count(*) FROM t2;
+ SELECT count(*) FROM t1;
+ }
+} -test {
+ faultsim_test_result {0 {4 4}} {1 {unable to open database: test.db2}}
+ faultsim_integrity_check
+ catchsql { ATTACH 'test.db2' AS aux }
+ if {[db one { SELECT count(*) FROM t1 }] != 4
+ || [db one { SELECT count(*) FROM t2 }] != 4
+ } {
+ error "Database content appears incorrect"
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test fault-injection as part of a vanilla, no-transaction, INSERT
+# statement.
+#
+do_faultsim_test pagerfault-4 -prep {
+ faultsim_delete_and_reopen
+} -body {
+ execsql {
+ CREATE TABLE x(y);
+ INSERT INTO x VALUES('z');
+ SELECT * FROM x;
+ }
+} -test {
+ faultsim_test_result {0 z}
+ faultsim_integrity_check
+}
+
+#-------------------------------------------------------------------------
+# Test fault-injection as part of a commit when using journal_mode=PERSIST.
+# Three different cases:
+#
+# pagerfault-5.1: With no journal_size_limit configured.
+# pagerfault-5.2: With a journal_size_limit configured.
+# pagerfault-5.4: Multi-file transaction. One connection has a
+# journal_size_limit of 0, the other has no limit.
+#
+do_test pagerfault-5-pre1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ CREATE TABLE t1(a UNIQUE, b UNIQUE);
+ INSERT INTO t1 VALUES(a_string(200), a_string(300));
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-5.1 -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string
+ execsql { PRAGMA journal_mode = PERSIST }
+} -body {
+ execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+do_faultsim_test pagerfault-5.2 -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ PRAGMA journal_size_limit = 2048;
+ }
+} -body {
+ execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+do_faultsim_test pagerfault-5.3 -faults oom-transient -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string
+ forcedelete test2.db test2.db-journal test2.db-wal
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ ATTACH 'test2.db' AS aux;
+ PRAGMA aux.journal_mode = PERSIST;
+ PRAGMA aux.journal_size_limit = 0;
+ }
+} -body {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ CREATE TABLE aux.t2 AS SELECT * FROM t1;
+ COMMIT;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+
+ catchsql { COMMIT }
+ catchsql { ROLLBACK }
+
+ faultsim_integrity_check
+ set res ""
+ set rc [catch { set res [db one { PRAGMA aux.integrity_check }] }]
+ if {$rc!=0 || $res != "ok"} {error "integrity-check problem:$rc $res"}
+}
+
+#-------------------------------------------------------------------------
+# Test fault-injection as part of a commit when using
+# journal_mode=TRUNCATE.
+#
+do_test pagerfault-6-pre1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ CREATE TABLE t1(a UNIQUE, b UNIQUE);
+ INSERT INTO t1 VALUES(a_string(200), a_string(300));
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test pagerfault-6.1 -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string
+ execsql { PRAGMA journal_mode = TRUNCATE }
+} -body {
+ execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }
+ execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+# The unix vfs xAccess() method considers a file zero bytes in size to
+# "not exist". This proc overrides that behaviour so that a zero length
+# file is considered to exist.
+#
+proc xAccess {method filename op args} {
+ if {$op != "SQLITE_ACCESS_EXISTS"} { return "" }
+ return [file exists $filename]
+}
+do_faultsim_test pagerfault-6.2 -faults cantopen-* -prep {
+ shmfault filter xAccess
+ shmfault script xAccess
+
+ faultsim_restore_and_reopen
+ db func a_string a_string
+ execsql { PRAGMA journal_mode = TRUNCATE }
+} -body {
+ execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }
+ execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+# The following was an attempt to get a bitvec malloc to fail. Didn't work.
+#
+# do_test pagerfault-6-pre1 {
+# faultsim_delete_and_reopen
+# execsql {
+# CREATE TABLE t1(x, y, UNIQUE(x, y));
+# INSERT INTO t1 VALUES(1, randomblob(1501));
+# INSERT INTO t1 VALUES(2, randomblob(1502));
+# INSERT INTO t1 VALUES(3, randomblob(1503));
+# INSERT INTO t1 VALUES(4, randomblob(1504));
+# INSERT INTO t1
+# SELECT x, randomblob(1500+oid+(SELECT max(oid) FROM t1)) FROM t1;
+# INSERT INTO t1
+# SELECT x, randomblob(1500+oid+(SELECT max(oid) FROM t1)) FROM t1;
+# INSERT INTO t1
+# SELECT x, randomblob(1500+oid+(SELECT max(oid) FROM t1)) FROM t1;
+# INSERT INTO t1
+# SELECT x, randomblob(1500+oid+(SELECT max(oid) FROM t1)) FROM t1;
+# }
+# faultsim_save_and_close
+# } {}
+# do_faultsim_test pagerfault-6 -prep {
+# faultsim_restore_and_reopen
+# } -body {
+# execsql {
+# BEGIN;
+# UPDATE t1 SET x=x+4 WHERE x=1;
+# SAVEPOINT one;
+# UPDATE t1 SET x=x+4 WHERE x=2;
+# SAVEPOINT three;
+# UPDATE t1 SET x=x+4 WHERE x=3;
+# SAVEPOINT four;
+# UPDATE t1 SET x=x+4 WHERE x=4;
+# RELEASE three;
+# COMMIT;
+# SELECT DISTINCT x FROM t1;
+# }
+# } -test {
+# faultsim_test_result {0 {5 6 7 8}}
+# faultsim_integrity_check
+# }
+#
+
+# This is designed to provoke a special case in the pager code:
+#
+# If an error (specifically, a FULL or IOERR error) occurs while writing a
+# dirty page to the file-system in order to free up memory, the pager enters
+# the "error state". An IO error causes SQLite to roll back the current
+# transaction (exiting the error state). A FULL error, however, may only
+# rollback the current statement.
+#
+# This block tests that nothing goes wrong if a FULL error occurs while
+# writing a dirty page out to free memory from within a statement that has
+# opened a statement transaction.
+#
+do_test pagerfault-7-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ BEGIN;
+ INSERT INTO t2 VALUES(NULL, randomblob(1500));
+ INSERT INTO t2 VALUES(NULL, randomblob(1500));
+ INSERT INTO t2 SELECT NULL, randomblob(1500) FROM t2; -- 4
+ INSERT INTO t2 SELECT NULL, randomblob(1500) FROM t2; -- 8
+ INSERT INTO t2 SELECT NULL, randomblob(1500) FROM t2; -- 16
+ INSERT INTO t2 SELECT NULL, randomblob(1500) FROM t2; -- 32
+ INSERT INTO t2 SELECT NULL, randomblob(1500) FROM t2; -- 64
+ COMMIT;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 SELECT * FROM t2;
+ DROP TABLE t2;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-7 -prep {
+ faultsim_restore_and_reopen
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ UPDATE t1 SET b = randomblob(1500);
+ }
+} -body {
+ execsql { UPDATE t1 SET a = 65, b = randomblob(1500) WHERE (a+1)>200 }
+ execsql COMMIT
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+do_test pagerfault-8-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ BEGIN;
+ INSERT INTO t1 VALUES(NULL, randomblob(1500));
+ INSERT INTO t1 VALUES(NULL, randomblob(1500));
+ INSERT INTO t1 SELECT NULL, randomblob(1500) FROM t1; -- 4
+ INSERT INTO t1 SELECT NULL, randomblob(1500) FROM t1; -- 8
+ INSERT INTO t1 SELECT NULL, randomblob(1500) FROM t1; -- 16
+ INSERT INTO t1 SELECT NULL, randomblob(1500) FROM t1; -- 32
+ INSERT INTO t1 SELECT NULL, randomblob(1500) FROM t1; -- 64
+ COMMIT;
+ }
+ faultsim_save_and_close
+ set filesize [file size test.db]
+ set {} {}
+} {}
+do_test pagerfault-8-pre2 {
+ faultsim_restore_and_reopen
+ execsql { DELETE FROM t1 WHERE a>32 }
+ expr {[file size test.db] < $filesize}
+} {1}
+do_faultsim_test pagerfault-8 -prep {
+ faultsim_restore_and_reopen
+ execsql {
+ BEGIN;
+ DELETE FROM t1 WHERE a>32;
+ }
+} -body {
+ execsql COMMIT
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+#-------------------------------------------------------------------------
+# This test case is specially designed so that during a savepoint
+# rollback, a new cache entry must be allocated (see comments surrounding
+# the call to sqlite3PagerAcquire() from within pager_playback_one_page()
+# for details). Test the effects of injecting an OOM at this point.
+#
+do_test pagerfault-9-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA auto_vacuum = incremental;
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(y);
+ CREATE TABLE t3(z);
+
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 VALUES(randomblob(900));
+ DELETE FROM t1;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-9.1 -prep {
+ faultsim_restore_and_reopen
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 VALUES(randomblob(900));
+ DROP TABLE t3;
+ DROP TABLE t2;
+ SAVEPOINT abc;
+ PRAGMA incremental_vacuum;
+ }
+} -body {
+ execsql {
+ ROLLBACK TO abc;
+ COMMIT;
+ PRAGMA freelist_count
+ }
+} -test {
+ faultsim_test_result {0 2}
+ faultsim_integrity_check
+
+ set sl [db one { SELECT COALESCE(sum(length(x)), 'null') FROM t1 }]
+ if {$sl!="null" && $sl!=1800} {
+ error "Content looks no good... ($sl)"
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test fault injection with a temporary database file.
+#
+foreach v {a b} {
+ do_faultsim_test pagerfault-10$v -prep {
+ sqlite3 db ""
+ db func a_string a_string;
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE xx(a, b, UNIQUE(a, b));
+ INSERT INTO xx VALUES(a_string(200), a_string(200));
+ INSERT INTO xx SELECT a_string(200), a_string(200) FROM xx;
+ INSERT INTO xx SELECT a_string(200), a_string(200) FROM xx;
+ INSERT INTO xx SELECT a_string(200), a_string(200) FROM xx;
+ INSERT INTO xx SELECT a_string(200), a_string(200) FROM xx;
+ COMMIT;
+ }
+ } -body {
+ execsql { UPDATE xx SET a = a_string(300) }
+ } -test {
+ faultsim_test_result {0 {}}
+ if {$::v == "b"} { execsql { PRAGMA journal_mode = TRUNCATE } }
+ faultsim_integrity_check
+ faultsim_integrity_check
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test fault injection with transaction savepoints (savepoints created
+# when a SAVEPOINT command is executed outside of any other savepoint
+# or transaction context).
+#
+do_test pagerfault-9-pre1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string;
+ execsql {
+ PRAGMA auto_vacuum = on;
+ CREATE TABLE t1(x UNIQUE);
+ CREATE TABLE t2(y UNIQUE);
+ CREATE TABLE t3(z UNIQUE);
+ BEGIN;
+ INSERT INTO t1 VALUES(a_string(202));
+ INSERT INTO t2 VALUES(a_string(203));
+ INSERT INTO t3 VALUES(a_string(204));
+ INSERT INTO t1 SELECT a_string(202) FROM t1;
+ INSERT INTO t1 SELECT a_string(203) FROM t1;
+ INSERT INTO t1 SELECT a_string(204) FROM t1;
+ INSERT INTO t1 SELECT a_string(205) FROM t1;
+ INSERT INTO t2 SELECT a_string(length(x)) FROM t1;
+ INSERT INTO t3 SELECT a_string(length(x)) FROM t1;
+ COMMIT;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-11 -prep {
+ faultsim_restore_and_reopen
+ execsql { PRAGMA cache_size = 10 }
+} -body {
+ execsql {
+ SAVEPOINT trans;
+ UPDATE t2 SET y = y||'2';
+ INSERT INTO t3 SELECT * FROM t2;
+ DELETE FROM t1;
+ ROLLBACK TO trans;
+ UPDATE t1 SET x = x||'3';
+ INSERT INTO t2 SELECT * FROM t1;
+ DELETE FROM t3;
+ RELEASE trans;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+
+#-------------------------------------------------------------------------
+# Test fault injection when writing to a database file that resides on
+# a file-system with a sector-size larger than the database page-size.
+#
+do_test pagerfault-12-pre1 {
+ testvfs ss_layer -default 1
+ ss_layer sectorsize 4096
+ faultsim_delete_and_reopen
+ db func a_string a_string;
+
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = PERSIST;
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE t1(x, y UNIQUE);
+ INSERT INTO t1 VALUES(a_string(333), a_string(444));
+ INSERT INTO t1 SELECT a_string(333+rowid), a_string(444+rowid) FROM t1;
+ INSERT INTO t1 SELECT a_string(333+rowid), a_string(444+rowid) FROM t1;
+ INSERT INTO t1 SELECT a_string(333+rowid), a_string(444+rowid) FROM t1;
+ INSERT INTO t1 SELECT a_string(333+rowid), a_string(444+rowid) FROM t1;
+ INSERT INTO t1 SELECT a_string(44), a_string(55) FROM t1 LIMIT 13;
+ COMMIT;
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test pagerfault-12a -prep {
+ faultsim_restore_and_reopen
+ execsql { PRAGMA cache_size = 10 }
+ db func a_string a_string;
+} -body {
+ execsql {
+ UPDATE t1 SET x = a_string(length(x)), y = a_string(length(y));
+ }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+do_test pagerfault-12-pre2 {
+ faultsim_restore_and_reopen
+ execsql {
+ CREATE TABLE t2 AS SELECT * FROM t1 LIMIT 10;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-12b -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string;
+ execsql { SELECT * FROM t1 }
+} -body {
+ set sql(1) { UPDATE t2 SET x = a_string(280) }
+ set sql(2) { UPDATE t1 SET x = a_string(280) WHERE rowid = 5 }
+
+ db eval { SELECT rowid FROM t1 LIMIT 2 } { db eval $sql($rowid) }
+
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+catch { db close }
+ss_layer delete
+
+
+#-------------------------------------------------------------------------
+# Test fault injection when SQLite opens a database where the size of the
+# database file is zero bytes but the accompanying journal file is larger
+# than that. In this scenario SQLite should delete the journal file
+# without rolling it back, even if it is in all other respects a valid
+# hot-journal file.
+#
+do_test pagerfault-13-pre1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string;
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ BEGIN;
+ CREATE TABLE t1(x, y UNIQUE);
+ INSERT INTO t1 VALUES(a_string(333), a_string(444));
+ COMMIT;
+ }
+ db close
+ forcedelete test.db
+ faultsim_save
+} {}
+do_faultsim_test pagerfault-13 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { CREATE TABLE xx(a, b) }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#---------------------------------------------------------------------------
+# Test fault injection into a small backup operation.
+#
+do_test pagerfault-14-pre1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string;
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ ATTACH 'test.db2' AS two;
+ BEGIN;
+ CREATE TABLE t1(x, y UNIQUE);
+ CREATE TABLE two.t2(x, y UNIQUE);
+ INSERT INTO t1 VALUES(a_string(333), a_string(444));
+ INSERT INTO t2 VALUES(a_string(333), a_string(444));
+ COMMIT;
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test pagerfault-14a -prep {
+ faultsim_restore_and_reopen
+} -body {
+ if {[catch {db backup test.db2} msg]} { error [regsub {.*: } $msg {}] }
+} -test {
+ faultsim_test_result {0 {}} {1 {}} {1 {SQL logic error or missing database}}
+}
+
+# If TEMP_STORE is 2 or greater, then the database [db2] will be created
+# as an in-memory database. This test will not work in that case, as it
+# is not possible to change the page-size of an in-memory database. Even
+# using the backup API.
+#
+if {$TEMP_STORE<2} {
+ do_faultsim_test pagerfault-14b -prep {
+ catch { db2 close }
+ faultsim_restore_and_reopen
+ sqlite3 db2 ""
+ db2 eval { PRAGMA page_size = 4096; CREATE TABLE xx(a) }
+ } -body {
+ sqlite3_backup B db2 main db main
+ B step 200
+ set rc [B finish]
+ if {[string match SQLITE_IOERR_* $rc]} {set rc SQLITE_IOERR}
+ if {$rc != "SQLITE_OK"} { error [sqlite3_test_errstr $rc] }
+ set {} {}
+ } -test {
+ faultsim_test_result {0 {}} {1 {sqlite3_backup_init() failed}}
+ }
+}
+
+do_faultsim_test pagerfault-14c -prep {
+ catch { db2 close }
+ faultsim_restore_and_reopen
+ sqlite3 db2 test.db2
+ db2 eval {
+ PRAGMA synchronous = off;
+ PRAGMA page_size = 4096;
+ CREATE TABLE xx(a);
+ }
+} -body {
+ sqlite3_backup B db2 main db main
+ B step 200
+ set rc [B finish]
+ if {[string match SQLITE_IOERR_* $rc]} {set rc SQLITE_IOERR}
+ if {$rc != "SQLITE_OK"} { error [sqlite3_test_errstr $rc] }
+ set {} {}
+} -test {
+ faultsim_test_result {0 {}} {1 {sqlite3_backup_init() failed}}
+}
+
+do_test pagerfault-15-pre1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string;
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(x, y UNIQUE);
+ INSERT INTO t1 VALUES(a_string(11), a_string(22));
+ INSERT INTO t1 VALUES(a_string(11), a_string(22));
+ COMMIT;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-15 -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string;
+} -body {
+ db eval { SELECT * FROM t1 LIMIT 1 } {
+ execsql {
+ BEGIN; INSERT INTO t1 VALUES(a_string(333), a_string(555)); COMMIT;
+ BEGIN; INSERT INTO t1 VALUES(a_string(333), a_string(555)); COMMIT;
+ }
+ }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+
+do_test pagerfault-16-pre1 {
+ faultsim_delete_and_reopen
+ execsql { CREATE TABLE t1(x, y UNIQUE) }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-16 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ PRAGMA locking_mode = exclusive;
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ PRAGMA journal_mode = delete;
+ INSERT INTO t1 VALUES(4, 5);
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(6, 7);
+ PRAGMA journal_mode = persist;
+ INSERT INTO t1 VALUES(8, 9);
+ }
+} -test {
+ faultsim_test_result {0 {exclusive wal delete wal persist}}
+ faultsim_integrity_check
+}
+
+
+#-------------------------------------------------------------------------
+# Test fault injection while changing into and out of WAL mode.
+#
+do_test pagerfault-17-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1862, 'Botha');
+ INSERT INTO t1 VALUES(1870, 'Smuts');
+ INSERT INTO t1 VALUES(1866, 'Hertzog');
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-17a -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ PRAGMA journal_mode = wal;
+ PRAGMA journal_mode = delete;
+ }
+} -test {
+ faultsim_test_result {0 {wal delete}}
+ faultsim_integrity_check
+}
+do_faultsim_test pagerfault-17b -prep {
+ faultsim_restore_and_reopen
+ execsql { PRAGMA synchronous = OFF }
+} -body {
+ execsql {
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(22, 'Clarke');
+ PRAGMA journal_mode = delete;
+ }
+} -test {
+ faultsim_test_result {0 {wal delete}}
+ faultsim_integrity_check
+}
+do_faultsim_test pagerfault-17c -prep {
+ faultsim_restore_and_reopen
+ execsql {
+ PRAGMA locking_mode = exclusive;
+ PRAGMA journal_mode = wal;
+ }
+} -body {
+ execsql { PRAGMA journal_mode = delete }
+} -test {
+ faultsim_test_result {0 delete}
+ faultsim_integrity_check
+}
+do_faultsim_test pagerfault-17d -prep {
+ catch { db2 close }
+ faultsim_restore_and_reopen
+ sqlite3 db2 test.db
+ execsql { PRAGMA journal_mode = delete }
+ execsql { PRAGMA journal_mode = wal }
+ execsql { INSERT INTO t1 VALUES(99, 'Bradman') } db2
+} -body {
+ execsql { PRAGMA journal_mode = delete }
+} -test {
+ faultsim_test_result {1 {database is locked}}
+ faultsim_integrity_check
+}
+do_faultsim_test pagerfault-17e -prep {
+ catch { db2 close }
+ faultsim_restore_and_reopen
+ sqlite3 db2 test.db
+ execsql { PRAGMA journal_mode = delete }
+ execsql { PRAGMA journal_mode = wal }
+ set ::chan [launch_testfixture]
+ testfixture $::chan {
+ sqlite3 db test.db
+ db eval { INSERT INTO t1 VALUES(101, 'Latham') }
+ }
+ catch { testfixture $::chan sqlite_abort }
+ catch { close $::chan }
+} -body {
+ execsql { PRAGMA journal_mode = delete }
+} -test {
+ faultsim_test_result {0 delete}
+ faultsim_integrity_check
+}
+
+#-------------------------------------------------------------------------
+# Test fault-injection when changing from journal_mode=persist to
+# journal_mode=delete (this involves deleting the journal file).
+#
+do_test pagerfault-18-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE qq(x);
+ INSERT INTO qq VALUES('Herbert');
+ INSERT INTO qq VALUES('Macalister');
+ INSERT INTO qq VALUES('Mackenzie');
+ INSERT INTO qq VALUES('Lilley');
+ INSERT INTO qq VALUES('Palmer');
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-18 -prep {
+ faultsim_restore_and_reopen
+ execsql {
+ PRAGMA journal_mode = PERSIST;
+ INSERT INTO qq VALUES('Beatty');
+ }
+} -body {
+ execsql { PRAGMA journal_mode = delete }
+} -test {
+ faultsim_test_result {0 delete}
+ faultsim_integrity_check
+}
+
+do_faultsim_test pagerfault-19a -prep {
+ sqlite3 db :memory:
+ db func a_string a_string
+ execsql {
+ PRAGMA auto_vacuum = FULL;
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(a_string(5000), a_string(6000));
+ COMMIT;
+ }
+} -body {
+ execsql {
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 SELECT * FROM t1;
+ DELETE FROM t1;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_test pagerfault-19-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA auto_vacuum = FULL;
+ CREATE TABLE t1(x); INSERT INTO t1 VALUES(1);
+ CREATE TABLE t2(x); INSERT INTO t2 VALUES(2);
+ CREATE TABLE t3(x); INSERT INTO t3 VALUES(3);
+ CREATE TABLE t4(x); INSERT INTO t4 VALUES(4);
+ CREATE TABLE t5(x); INSERT INTO t5 VALUES(5);
+ CREATE TABLE t6(x); INSERT INTO t6 VALUES(6);
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-19b -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ BEGIN;
+ UPDATE t4 SET x = x+1;
+ UPDATE t6 SET x = x+1;
+ SAVEPOINT one;
+ UPDATE t3 SET x = x+1;
+ SAVEPOINT two;
+ DROP TABLE t2;
+ ROLLBACK TO one;
+ COMMIT;
+ SELECT * FROM t3;
+ SELECT * FROM t4;
+ SELECT * FROM t6;
+ }
+} -test {
+ faultsim_test_result {0 {3 5 7}}
+}
+
+#-------------------------------------------------------------------------
+# This tests fault-injection in a special case in the auto-vacuum code.
+#
+do_test pagerfault-20-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA auto_vacuum = FULL;
+ CREATE TABLE t0(a, b);
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-20 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ DROP TABLE t1;
+ COMMIT;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_test pagerfault-21-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA cache_size = 10;
+ CREATE TABLE t0(a PRIMARY KEY, b);
+ INSERT INTO t0 VALUES(1, 2);
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-21 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ db eval { SELECT * FROM t0 LIMIT 1 } {
+ db eval { INSERT INTO t0 SELECT a+1, b FROM t0 }
+ db eval { INSERT INTO t0 SELECT a+2, b FROM t0 }
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+
+#-------------------------------------------------------------------------
+# Test fault-injection and rollback when the nReserve header value
+# is non-zero.
+#
+do_test pagerfault-21-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ PRAGMA journal_mode = DELETE;
+ }
+ db close
+ hexio_write test.db 20 10
+ hexio_write test.db 105 03F0
+ sqlite3 db test.db
+ db func a_string a_string
+ execsql {
+ CREATE TABLE t0(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t0 VALUES(a_string(222), a_string(333));
+ INSERT INTO t0 VALUES(a_string(223), a_string(334));
+ INSERT INTO t0 VALUES(a_string(224), a_string(335));
+ INSERT INTO t0 VALUES(a_string(225), a_string(336));
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test pagerfault-21 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { INSERT INTO t0 SELECT a||'x', b||'x' FROM t0 }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+ifcapable crashtest {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ PRAGMA journal_mode = DELETE;
+ }
+ db close
+ hexio_write test.db 20 10
+ hexio_write test.db 105 03F0
+
+ sqlite3 db test.db
+ db func a_string a_string
+ execsql {
+ CREATE TABLE t0(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t0 VALUES(a_string(222), a_string(333));
+ INSERT INTO t0 VALUES(a_string(223), a_string(334));
+ }
+ faultsim_save_and_close
+
+ for {set iTest 1} {$iTest<50} {incr iTest} {
+ do_test pagerfault-21.crash.$iTest.1 {
+ crashsql -delay 1 -file test.db -seed $iTest {
+ BEGIN;
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 SELECT a, b FROM t0;
+ COMMIT;
+ }
+ } {1 {child process exited abnormally}}
+ do_test pagerfault-22.$iTest.2 {
+ sqlite3 db test.db
+ execsql { PRAGMA integrity_check }
+ } {ok}
+ db close
+ }
+}
+
+
+#-------------------------------------------------------------------------
+# When a 3.7.0 client opens a write-transaction on a database file that
+# has been appended to or truncated by a pre-370 client, it updates
+# the db-size in the file header immediately. This test case provokes
+# errors during that operation.
+#
+do_test pagerfault-22-pre1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1 VALUES(a_string(3000));
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(1);
+ }
+ db close
+ sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-22 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { INSERT INTO t2 VALUES(2) }
+ execsql { SELECT * FROM t2 }
+} -test {
+ faultsim_test_result {0 {1 2}}
+ faultsim_integrity_check
+}
+
+#-------------------------------------------------------------------------
+# Provoke an OOM error during a commit of multi-file transaction. One of
+# the databases written during the transaction is an in-memory database.
+# This test causes rollback of the in-memory database after CommitPhaseOne()
+# has successfully returned. i.e. the series of calls for the aborted commit
+# is:
+#
+# PagerCommitPhaseOne(<in-memory-db>) -> SQLITE_OK
+# PagerCommitPhaseOne(<file-db>) -> SQLITE_IOERR
+# PagerRollback(<in-memory-db>)
+# PagerRollback(<file-db>)
+#
+do_faultsim_test pagerfault-23 -prep {
+ sqlite3 db :memory:
+ foreach f [glob -nocomplain test.db*] { forcedelete $f }
+ db eval {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE aux.t2(a, b);
+ }
+} -body {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(3,4);
+ COMMIT;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+do_faultsim_test pagerfault-24 -prep {
+ faultsim_delete_and_reopen
+ db eval { PRAGMA temp_store = file }
+ execsql { CREATE TABLE x(a, b) }
+} -body {
+ execsql { CREATE TEMP TABLE t1(a, b) }
+} -test {
+ faultsim_test_result {0 {}} \
+ {1 {unable to open a temporary database file for storing temporary tables}}
+ set ic [db eval { PRAGMA temp.integrity_check }]
+ if {$ic != "ok"} { error "Integrity check: $ic" }
+}
+
+proc lockrows {n} {
+ if {$n==0} { return "" }
+ db eval { SELECT * FROM t1 WHERE oid = $n } {
+ return [lockrows [expr {$n-1}]]
+ }
+}
+
+
+do_test pagerfault-25-pre1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(a_string(500));
+ INSERT INTO t1 SELECT a_string(500) FROM t1;
+ INSERT INTO t1 SELECT a_string(500) FROM t1;
+ INSERT INTO t1 SELECT a_string(500) FROM t1;
+ INSERT INTO t1 SELECT a_string(500) FROM t1;
+ INSERT INTO t1 SELECT a_string(500) FROM t1;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-25 -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string
+ set ::channel [db incrblob -readonly t1 a 1]
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ INSERT INTO t1 VALUES(a_string(3000));
+ INSERT INTO t1 VALUES(a_string(3000));
+ }
+} -body {
+ lockrows 30
+} -test {
+ catch { lockrows 30 }
+ catch { db eval COMMIT }
+ close $::channel
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test pagerfault-26 -prep {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = truncate;
+ PRAGMA auto_vacuum = full;
+ PRAGMA locking_mode=exclusive;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ PRAGMA page_size = 4096;
+ }
+} -body {
+ execsql {
+ VACUUM;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+
+ set contents [db eval {SELECT * FROM t1}]
+ if {$contents != "1 2"} { error "Bad database contents ($contents)" }
+
+ set sz [file size test.db]
+ if {$testrc!=0 && $sz!=1024*3 && $sz!=4096*3} {
+ error "Expected file size to be 3072 or 12288 bytes - actual size $sz bytes"
+ }
+ if {$testrc==0 && $sz!=4096*3} {
+ error "Expected file size to be 12288 bytes - actual size $sz bytes"
+ }
+}
+
+do_test pagerfault-27-pre {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a UNIQUE, b UNIQUE);
+ INSERT INTO t2 VALUES( a_string(800), a_string(800) );
+ INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
+ INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
+ INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
+ INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
+ INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
+ INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
+ INSERT INTO t1 VALUES (a_string(20000), a_string(20000));
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-27 -faults ioerr-persistent -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN EXCLUSIVE;
+ }
+ set ::channel [db incrblob t1 a 1]
+} -body {
+ puts $::channel [string repeat abc 6000]
+ flush $::channel
+} -test {
+ catchsql { UPDATE t2 SET a = a_string(800), b = a_string(800) }
+ catch { close $::channel }
+ catchsql { ROLLBACK }
+ faultsim_integrity_check
+}
+
+finish_test
+
diff --git a/test/pagerfault2.test b/test/pagerfault2.test
new file mode 100644
index 0000000..6cdb99a
--- /dev/null
+++ b/test/pagerfault2.test
@@ -0,0 +1,99 @@
+# 2010 June 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# The tests in this file test the pager modules response to various
+# fault conditions (OOM, IO error, disk full etc.). They are similar
+# to those in file pagerfault1.test.
+#
+# More specifically, the tests in this file are those deemed too slow to
+# run as part of pagerfault1.test.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+if {[permutation] == "inmemory_journal"} {
+ finish_test
+ return
+}
+
+sqlite3_memdebug_vfs_oom_test 0
+
+set a_string_counter 1
+proc a_string {n} {
+ global a_string_counter
+ incr a_string_counter
+ string range [string repeat "${a_string_counter}." $n] 1 $n
+}
+db func a_string a_string
+
+do_test pagerfault2-1-pre1 {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = DELETE;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(a_string(401), a_string(402));
+ }
+ for {set ii 0} {$ii < 13} {incr ii} {
+ execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 }
+ }
+ faultsim_save_and_close
+ file size test.db
+} [expr 1024 * 8268]
+
+do_faultsim_test pagerfault2-1 -faults oom-transient -prep {
+ faultsim_restore_and_reopen
+ sqlite3_db_config_lookaside db 0 256 4096
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ INSERT INTO t1 VALUES(5, 6);
+ SAVEPOINT abc;
+ UPDATE t1 SET a = a||'x' WHERE rowid<3700;
+ }
+} -body {
+ execsql { UPDATE t1 SET a = a||'x' WHERE rowid>=3700 AND rowid<=4200 }
+ execsql { ROLLBACK TO abc }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_test pagerfault2-2-pre1 {
+ faultsim_restore_and_reopen
+ execsql { DELETE FROM t1 }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test pagerfault2-2 -faults oom-transient -prep {
+ faultsim_restore_and_reopen
+ sqlite3_db_config_lookaside db 0 256 4096
+ db func a_string a_string
+
+ execsql {
+ PRAGMA cache_size = 20;
+ BEGIN;
+ INSERT INTO t1 VALUES(a_string(401), a_string(402));
+ SAVEPOINT abc;
+ }
+} -body {
+ execsql { INSERT INTO t1 VALUES (a_string(2000000), a_string(2500000)) }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+sqlite3_memdebug_vfs_oom_test 1
+finish_test
+
diff --git a/test/pagerfault3.test b/test/pagerfault3.test
new file mode 100644
index 0000000..3d192e6
--- /dev/null
+++ b/test/pagerfault3.test
@@ -0,0 +1,64 @@
+# 2011 January 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+if {[permutation] == "inmemory_journal"} {
+ finish_test
+ return
+}
+
+# Create a database with page-size 2048 bytes that uses 2 pages. Populate
+# it so that if the page-size is changed to 1024 bytes and the db vacuumed,
+# the new db size is 3 pages.
+#
+do_test pagerfault3-pre1 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 2048;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(1200));
+ PRAGMA page_count;
+ }
+} {2}
+do_test pagerfault3-pre2 {
+ faultsim_save_and_close
+ faultsim_restore_and_reopen
+ execsql {
+ PRAGMA page_size = 1024;
+ VACUUM;
+ PRAGMA page_count;
+ }
+} {3}
+
+# Now do the page-size change and VACUUM with IO error injection. When
+# an IO error is injected into the final xSync() of the commit, the pager
+# will have to extend the db file from 3072 to 4096 byts when rolling
+# back the hot-journal file. This is a special case in pager_truncate().
+#
+do_faultsim_test pagerfault3-1 -faults ioerr-transient -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ PRAGMA page_size = 1024;
+ VACUUM;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+finish_test
+
diff --git a/test/pageropt.test b/test/pageropt.test
new file mode 100644
index 0000000..8231196
--- /dev/null
+++ b/test/pageropt.test
@@ -0,0 +1,199 @@
+# 2007 April 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+# The focus of the tests in this file are to verify that the
+# pager optimizations implemented in version 3.3.14 work.
+#
+# $Id: pageropt.test,v 1.5 2008/08/20 14:49:25 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!pager_pragmas||secure_delete||direct_read} {
+ finish_test
+ return
+}
+
+# Run the SQL statement supplied by the argument and return
+# the results. Prepend four integers to the beginning of the
+# result which are
+#
+# (1) The number of page reads from the database
+# (2) The number of page writes to the database
+# (3) The number of page writes to the journal
+# (4) The number of cache pages freed
+#
+proc pagercount_sql {sql {db db}} {
+ global sqlite3_pager_readdb_count
+ global sqlite3_pager_writedb_count
+ global sqlite3_pager_writej_count
+ global sqlite3_pager_pgfree_count
+ set sqlite3_pager_readdb_count 0
+ set sqlite3_pager_writedb_count 0
+ set sqlite3_pager_writej_count 0
+ set r [$db eval $sql]
+ set cnt [list $sqlite3_pager_readdb_count \
+ $sqlite3_pager_writedb_count \
+ $sqlite3_pager_writej_count ]
+ return [concat $cnt $r]
+}
+
+# Setup the test database
+#
+do_test pageropt-1.1 {
+ sqlite3_soft_heap_limit 0
+ execsql {
+ PRAGMA auto_vacuum = OFF;
+ PRAGMA page_size = 1024;
+ }
+ pagercount_sql {
+ CREATE TABLE t1(x);
+ }
+} {0 2 0}
+do_test pageropt-1.2 {
+ pagercount_sql {
+ INSERT INTO t1 VALUES(randomblob(5000));
+ }
+} {0 6 2}
+
+# Verify that values remain in cache on for subsequent reads.
+# We should not have to go back to disk.
+#
+do_test pageropt-1.3 {
+ pagercount_sql {
+ SELECT length(x) FROM t1
+ }
+} {0 0 0 5000}
+
+# If another thread reads the database, the original cache
+# remains valid.
+#
+sqlite3 db2 test.db
+set blobcontent [db2 one {SELECT hex(x) FROM t1}]
+do_test pageropt-1.4 {
+ pagercount_sql {
+ SELECT hex(x) FROM t1
+ }
+} [list 0 0 0 $blobcontent]
+
+# But if the other thread modifies the database, then the cache
+# must refill.
+#
+do_test pageropt-1.5 {
+ db2 eval {CREATE TABLE t2(y)}
+ pagercount_sql {
+ SELECT hex(x) FROM t1
+ }
+} [list 6 0 0 $blobcontent]
+do_test pageropt-1.6 {
+ pagercount_sql {
+ SELECT hex(x) FROM t1
+ }
+} [list 0 0 0 $blobcontent]
+
+# Verify that the last page of an overflow chain is not read from
+# disk when deleting a row. The one row of t1(x) has four pages
+# of overflow. So deleting that row from t1 should involve reading
+# the sqlite_master table (1 page) the main page of t1 (1 page) and
+# the three overflow pages of t1 for a total of 5 pages.
+#
+# Pages written are page 1 (for the freelist pointer), the root page
+# of the table, and one of the overflow chain pointers because it
+# becomes the trunk of the freelist. Total 3.
+#
+do_test pageropt-2.1 {
+ db close
+ sqlite3 db test.db
+ pagercount_sql {
+ DELETE FROM t1 WHERE rowid=1
+ }
+} {5 3 3}
+
+# When pulling pages off of the freelist, there is no reason
+# to actually bring in the old content.
+#
+do_test pageropt-2.2 {
+ db close
+ sqlite3 db test.db
+ pagercount_sql {
+ INSERT INTO t1 VALUES(randomblob(1500));
+ }
+} {3 4 3}
+do_test pageropt-2.3 {
+ pagercount_sql {
+ INSERT INTO t1 VALUES(randomblob(1500));
+ }
+} {0 4 3}
+
+# Note the new optimization that when pulling the very last page off of the
+# freelist we do not read the content of that page.
+#
+do_test pageropt-2.4 {
+ pagercount_sql {
+ INSERT INTO t1 VALUES(randomblob(1500));
+ }
+} {0 5 3}
+
+# Appending a large quantity of data does not involve writing much
+# to the journal file.
+#
+do_test pageropt-3.1 {
+ pagercount_sql {
+ INSERT INTO t2 SELECT * FROM t1;
+ }
+} {1 7 2}
+
+# Once again, we do not need to read the last page of an overflow chain
+# while deleting.
+#
+do_test pageropt-3.2 {
+ pagercount_sql {
+ DROP TABLE t2;
+ }
+} {0 2 3}
+do_test pageropt-3.3 {
+ pagercount_sql {
+ DELETE FROM t1;
+ }
+} {0 3 3}
+
+# There are now 11 pages on the freelist. Move them all into an
+# overflow chain by inserting a single large record. Starting from
+# a cold cache, only page 1, the root page of table t1, and the trunk
+# of the freelist need to be read (3 pages). And only those three
+# pages need to be journalled. But 13 pages need to be written:
+# page1, the root page of table t1, and an 11 page overflow chain.
+#
+do_test pageropt-4.1 {
+ db close
+ sqlite3 db test.db
+ pagercount_sql {
+ INSERT INTO t1 VALUES(randomblob(11300))
+ }
+} {3 13 3}
+
+# Now we delete that big entries starting from a cold cache and an
+# empty freelist. The first 10 of the 11 pages overflow chain have
+# to be read, together with page1 and the root of the t1 table. 12
+# reads total. But only page1, the t1 root, and the trunk of the
+# freelist need to be journalled and written back.
+#
+do_test pageropt-4.2 {
+ db close
+ sqlite3 db test.db
+ pagercount_sql {
+ DELETE FROM t1
+ }
+} {12 3 3}
+
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+catch {db2 close}
+finish_test
diff --git a/test/pagesize.test b/test/pagesize.test
new file mode 100644
index 0000000..0eebbbb
--- /dev/null
+++ b/test/pagesize.test
@@ -0,0 +1,219 @@
+# 2004 September 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+# This file implements tests for the page_size PRAGMA.
+#
+# $Id: pagesize.test,v 1.13 2008/08/26 21:07:27 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# This test script depends entirely on "PRAGMA page_size". So if this
+# pragma is not available, omit the whole file.
+ifcapable !pager_pragmas {
+ finish_test
+ return
+}
+
+do_test pagesize-1.1 {
+ execsql {PRAGMA page_size}
+} 1024
+ifcapable {explain} {
+ do_test pagesize-1.2 {
+ catch {execsql {EXPLAIN PRAGMA page_size}}
+ } 0
+}
+do_test pagesize-1.3 {
+ execsql {
+ CREATE TABLE t1(a);
+ PRAGMA page_size=2048;
+ PRAGMA page_size;
+ }
+} 1024
+
+do_test pagesize-1.4 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size=511;
+ PRAGMA page_size;
+ }
+} 1024
+do_test pagesize-1.5 {
+ execsql {
+ PRAGMA page_size=512;
+ PRAGMA page_size;
+ }
+} 512
+if {![info exists SQLITE_MAX_PAGE_SIZE] || $SQLITE_MAX_PAGE_SIZE>=8192} {
+ do_test pagesize-1.6 {
+ execsql {
+ PRAGMA page_size=8192;
+ PRAGMA page_size;
+ }
+ } 8192
+ do_test pagesize-1.7 {
+ execsql {
+ PRAGMA page_size=65537;
+ PRAGMA page_size;
+ }
+ } 8192
+ do_test pagesize-1.8 {
+ execsql {
+ PRAGMA page_size=1234;
+ PRAGMA page_size
+ }
+ } 8192
+}
+foreach PGSZ {512 2048 4096 8192} {
+ if {[info exists SQLITE_MAX_PAGE_SIZE]
+ && $SQLITE_MAX_PAGE_SIZE<$PGSZ} continue
+ ifcapable memorydb {
+ do_test pagesize-2.$PGSZ.0.1 {
+ db close
+ sqlite3 db :memory:
+ execsql "PRAGMA page_size=$PGSZ;"
+ execsql {PRAGMA page_size}
+ } $PGSZ
+ do_test pagesize-2.$PGSZ.0.2 {
+ execsql {CREATE TABLE t1(x UNIQUE, y UNIQUE, z UNIQUE)}
+ execsql {PRAGMA page_size}
+ } $PGSZ
+ do_test pagesize-2.$PGSZ.0.3 {
+ execsql {
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(2,3,4);
+ SELECT * FROM t1;
+ }
+ } {1 2 3 2 3 4}
+ }
+ do_test pagesize-2.$PGSZ.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql "PRAGMA page_size=$PGSZ"
+ execsql {
+ CREATE TABLE t1(x);
+ PRAGMA page_size;
+ }
+ } $PGSZ
+ do_test pagesize-2.$PGSZ.2 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size
+ }
+ } $PGSZ
+ do_test pagesize-2.$PGSZ.3 {
+ file size test.db
+ } [expr {$PGSZ*($AUTOVACUUM?3:2)}]
+ ifcapable {vacuum} {
+ do_test pagesize-2.$PGSZ.4 {
+ execsql {VACUUM}
+ } {}
+ }
+ integrity_check pagesize-2.$PGSZ.5
+ do_test pagesize-2.$PGSZ.6 {
+ db close
+ sqlite3 db test.db
+ execsql {PRAGMA page_size}
+ } $PGSZ
+ do_test pagesize-2.$PGSZ.7 {
+ execsql {
+ INSERT INTO t1 VALUES(randstr(10,9000));
+ INSERT INTO t1 VALUES(randstr(10,9000));
+ INSERT INTO t1 VALUES(randstr(10,9000));
+ BEGIN;
+ INSERT INTO t1 SELECT x||x FROM t1;
+ INSERT INTO t1 SELECT x||x FROM t1;
+ INSERT INTO t1 SELECT x||x FROM t1;
+ INSERT INTO t1 SELECT x||x FROM t1;
+ SELECT count(*) FROM t1;
+ }
+ } 48
+ do_test pagesize-2.$PGSZ.8 {
+ execsql {
+ ROLLBACK;
+ SELECT count(*) FROM t1;
+ }
+ } 3
+ integrity_check pagesize-2.$PGSZ.9
+ do_test pagesize-2.$PGSZ.10 {
+ db close
+ sqlite3 db test.db
+ execsql {PRAGMA page_size}
+ } $PGSZ
+ do_test pagesize-2.$PGSZ.11 {
+ execsql {
+ INSERT INTO t1 SELECT x||x FROM t1;
+ INSERT INTO t1 SELECT x||x FROM t1;
+ INSERT INTO t1 SELECT x||x FROM t1;
+ INSERT INTO t1 SELECT x||x FROM t1;
+ INSERT INTO t1 SELECT x||x FROM t1;
+ INSERT INTO t1 SELECT x||x FROM t1;
+ SELECT count(*) FROM t1;
+ }
+ } 192
+ do_test pagesize-2.$PGSZ.12 {
+ execsql {
+ BEGIN;
+ DELETE FROM t1 WHERE rowid%5!=0;
+ SELECT count(*) FROM t1;
+ }
+ } 38
+ do_test pagesize-2.$PGSZ.13 {
+ execsql {
+ ROLLBACK;
+ SELECT count(*) FROM t1;
+ }
+ } 192
+ integrity_check pagesize-2.$PGSZ.14
+ do_test pagesize-2.$PGSZ.15 {
+ execsql {DELETE FROM t1 WHERE rowid%5!=0}
+ ifcapable {vacuum} {execsql VACUUM}
+ execsql {SELECT count(*) FROM t1}
+ } 38
+ do_test pagesize-2.$PGSZ.16 {
+ execsql {DROP TABLE t1}
+ ifcapable {vacuum} {execsql VACUUM}
+ } {}
+ integrity_check pagesize-2.$PGSZ.17
+
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ do_test pagesize-2.$PGSZ.30 {
+ execsql "
+ CREATE TABLE t1(x);
+ PRAGMA temp.page_size=$PGSZ;
+ CREATE TEMP TABLE t2(y);
+ PRAGMA main.page_size;
+ PRAGMA temp.page_size;
+ "
+ } [list 1024 $PGSZ]
+
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ do_test pagesize-2.$PGSZ.40 {
+ execsql "
+ PRAGMA page_size=$PGSZ;
+ CREATE TABLE t1(x);
+ CREATE TEMP TABLE t2(y);
+ PRAGMA main.page_size;
+ PRAGMA temp.page_size;
+ "
+ } [list $PGSZ $PGSZ]
+}
+
+finish_test
diff --git a/test/pcache.test b/test/pcache.test
new file mode 100644
index 0000000..5dc3059
--- /dev/null
+++ b/test/pcache.test
@@ -0,0 +1,181 @@
+# 2008 August 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is focused on testing the pcache module.
+#
+# $Id: pcache.test,v 1.5 2009/05/08 06:52:48 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Only works with a mode-2 pcache where all pcaches share a single set
+# of pages.
+#
+ifcapable {!memorymanage && threadsafe} {
+ finish_test
+ return
+}
+
+# The pcache module limits the number of pages available to purgeable
+# caches to the sum of the 'cache_size' values for the set of open
+# caches. This block of tests, pcache-1.*, test that the library behaves
+# corrctly when it is forced to exceed this limit.
+#
+do_test pcache-1.1 {
+ db close
+ pcache_stats
+} {current 0 max 0 min 0 recyclable 0}
+
+do_test pcache-1.2 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA cache_size=12;
+ PRAGMA auto_vacuum=0;
+ }
+ pcache_stats
+} {current 1 max 12 min 10 recyclable 1}
+
+do_test pcache-1.3 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+ CREATE TABLE t3(a, b, c);
+ CREATE TABLE t4(a, b, c);
+ CREATE TABLE t5(a, b, c);
+ }
+ pcache_stats
+} {current 6 max 12 min 10 recyclable 0}
+
+do_test pcache-1.4 {
+ execsql {
+ CREATE TABLE t6(a, b, c);
+ CREATE TABLE t7(a, b, c);
+ CREATE TABLE t8(a, b, c);
+ CREATE TABLE t9(a, b, c);
+ }
+ pcache_stats
+} {current 10 max 12 min 10 recyclable 0}
+
+do_test pcache-1.5 {
+ sqlite3 db2 test.db
+ execsql "PRAGMA cache_size=10" db2
+ pcache_stats
+} {current 11 max 22 min 20 recyclable 1}
+
+do_test pcache-1.6.1 {
+ execsql {
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ } db2
+ pcache_stats
+} {current 11 max 22 min 20 recyclable 0}
+
+# At this point connection db2 has a read lock on the database file and a
+# single pinned page in its cache. Connection [db] is holding 10 dirty
+# pages. It cannot recycle them because of the read lock held by db2.
+#
+do_test pcache-1.6.2 {
+ execsql {
+ CREATE INDEX i1 ON t1(a, b);
+ CREATE INDEX i2 ON t2(a, b);
+ CREATE INDEX i3 ON t3(a, b);
+ CREATE INDEX i4 ON t4(a, b);
+ CREATE INDEX i5 ON t5(a, b);
+ CREATE INDEX i6 ON t6(a, b);
+ CREATE INDEX i7 ON t7(a, b);
+ CREATE INDEX i8 ON t8(a, b);
+ CREATE INDEX i9 ON t9(a, b);
+ CREATE INDEX i10 ON t9(a, b);
+ CREATE INDEX i11 ON t9(a, b);
+ }
+ pcache_stats
+} {current 23 max 22 min 20 recyclable 0}
+
+do_test pcache-1.7 {
+ execsql {
+ CREATE TABLE t10(a, b, c);
+ }
+ pcache_stats
+} {current 24 max 22 min 20 recyclable 0}
+
+# Rolling back the transaction held by db2 at this point releases a pinned
+# page. Because the number of allocated pages is greater than the
+# configured maximum, this page should be freed immediately instead of
+# recycled.
+#
+do_test pcache-1.8 {
+ execsql {ROLLBACK} db2
+ pcache_stats
+} {current 23 max 22 min 20 recyclable 0}
+
+do_test pcache-1.9 {
+ execsql COMMIT
+ pcache_stats
+} {current 22 max 22 min 20 recyclable 22}
+
+do_test pcache-1.10 {
+ db2 close
+ pcache_stats
+} {current 12 max 12 min 10 recyclable 12}
+
+do_test pcache-1.11 {
+ execsql { PRAGMA cache_size = 20 }
+ pcache_stats
+} {current 12 max 20 min 10 recyclable 12}
+
+do_test pcache-1.12 {
+ execsql {
+ SELECT * FROM t1 ORDER BY a; SELECT * FROM t1;
+ SELECT * FROM t2 ORDER BY a; SELECT * FROM t2;
+ SELECT * FROM t3 ORDER BY a; SELECT * FROM t3;
+ SELECT * FROM t4 ORDER BY a; SELECT * FROM t4;
+ SELECT * FROM t5 ORDER BY a; SELECT * FROM t5;
+ SELECT * FROM t6 ORDER BY a; SELECT * FROM t6;
+ SELECT * FROM t7 ORDER BY a; SELECT * FROM t7;
+ SELECT * FROM t8 ORDER BY a; SELECT * FROM t8;
+ SELECT * FROM t9 ORDER BY a; SELECT * FROM t9;
+ }
+ pcache_stats
+} {current 19 max 20 min 10 recyclable 19}
+
+do_test pcache-1.13 {
+ execsql { PRAGMA cache_size = 15 }
+ pcache_stats
+} {current 15 max 15 min 10 recyclable 15}
+
+do_test pcache-1.14 {
+ hexio_write test.db 24 [hexio_render_int32 1000]
+ execsql { SELECT * FROM sqlite_master }
+ pcache_stats
+} {current 2 max 15 min 10 recyclable 2}
+
+do_test pcache-1.15 {
+ execsql {
+ SELECT * FROM t1 ORDER BY a; SELECT * FROM t1;
+ SELECT * FROM t2 ORDER BY a; SELECT * FROM t2;
+ SELECT * FROM t3 ORDER BY a; SELECT * FROM t3;
+ SELECT * FROM t4 ORDER BY a; SELECT * FROM t4;
+ SELECT * FROM t5 ORDER BY a; SELECT * FROM t5;
+ SELECT * FROM t6 ORDER BY a; SELECT * FROM t6;
+ SELECT * FROM t7 ORDER BY a; SELECT * FROM t7;
+ SELECT * FROM t8 ORDER BY a; SELECT * FROM t8;
+ SELECT * FROM t9 ORDER BY a; SELECT * FROM t9;
+ }
+ pcache_stats
+} {current 14 max 15 min 10 recyclable 14}
+
+finish_test
diff --git a/test/pcache2.test b/test/pcache2.test
new file mode 100644
index 0000000..77e7a26
--- /dev/null
+++ b/test/pcache2.test
@@ -0,0 +1,79 @@
+# 2008 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is focused on testing the pcache module.
+#
+# $Id: pcache2.test,v 1.5 2009/07/18 14:36:24 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Set up a pcache memory pool so that we can easily track how many
+# pages are being used for cache.
+#
+do_test pcache2-1.1 {
+ db close
+ sqlite3_reset_auto_extension
+ sqlite3_shutdown
+ sqlite3_config_pagecache 6000 100
+ sqlite3_initialize
+ autoinstall_test_functions
+ sqlite3_status SQLITE_STATUS_PAGECACHE_USED 1
+ sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0
+} {0 0 0}
+
+# Open up two database connections to separate files.
+#
+do_test pcache2-1.2 {
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ db eval {PRAGMA cache_size=10}
+ lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
+} {2}
+do_test pcache2-1.3 {
+ forcedelete test2.db test2.db-journal
+ sqlite3 db2 test2.db
+ db2 eval {PRAGMA cache_size=50}
+ lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
+} {4}
+
+
+# Make lots of changes on the first connection. Verify that the
+# page cache usage does not grow to consume the page space set aside
+# for the second connection.
+#
+do_test pcache2-1.4 {
+ db eval {
+ CREATE TABLE t1(a,b);
+ CREATE TABLE t2(x,y);
+ INSERT INTO t1 VALUES(1, zeroblob(800));
+ INSERT INTO t1 VALUES(2, zeroblob(800));
+ INSERT INTO t2 SELECT * FROM t1;
+ INSERT INTO t1 SELECT x+2, y FROM t2;
+ INSERT INTO t2 SELECT a+10, b FROM t1;
+ INSERT INTO t1 SELECT x+10, y FROM t2;
+ INSERT INTO t2 SELECT a+100, b FROM t1;
+ INSERT INTO t1 SELECT x+100, y FROM t2;
+ INSERT INTO t2 SELECT a+1000, b FROM t1;
+ INSERT INTO t1 SELECT x+1000, y FROM t2;
+ }
+ sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0
+} {0 13 13}
+
+db close
+catch {db2 close}
+sqlite3_reset_auto_extension
+sqlite3_shutdown
+sqlite3_config_pagecache 0 0
+sqlite3_initialize
+autoinstall_test_functions
+
+finish_test
diff --git a/test/permutations.test b/test/permutations.test
new file mode 100644
index 0000000..7c3b026
--- /dev/null
+++ b/test/permutations.test
@@ -0,0 +1,869 @@
+# 2008 June 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db close
+
+#-------------------------------------------------------------------------
+# test_suite NAME OPTIONS
+#
+# where available options are:
+#
+# -description TITLE (default "")
+# -initialize SCRIPT (default "")
+# -shutdown SCRIPT (default "")
+# -presql SQL (default "")
+# -files LIST-OF-FILES (default $::ALLTESTS)
+# -prefix NAME (default "$::NAME.")
+# -dbconfig SCRIPT (default "")
+#
+proc test_suite {name args} {
+
+ set default(-shutdown) ""
+ set default(-initialize) ""
+ set default(-presql) ""
+ set default(-description) "no description supplied (fixme)"
+ set default(-files) ""
+ set default(-prefix) "${name}."
+ set default(-dbconfig) ""
+
+ array set options [array get default]
+ if {[llength $args]%2} {
+ error "uneven number of options/switches passed to test_suite"
+ }
+ foreach {k v} $args {
+ set o [array names options ${k}*]
+ if {[llength $o]>1} { error "ambiguous option: $k" }
+ if {[llength $o]==0} { error "unknown option: $k" }
+ set options([lindex $o 0]) $v
+ }
+
+ set ::testspec($name) [array get options]
+ lappend ::testsuitelist $name
+}
+
+#-------------------------------------------------------------------------
+# test_set ARGS...
+#
+proc test_set {args} {
+ set isExclude 0
+ foreach a $args {
+ if {[string match -* $a]} {
+ switch -- $a {
+ -include { set isExclude 0 }
+ -exclude { set isExclude 1 }
+ default {
+ error "Unknown switch: $a"
+ }
+ }
+ } elseif {$isExclude == 0} {
+ foreach f $a { set t($f) 1 }
+ } else {
+ foreach f $a { array unset t $f }
+ foreach f $a { array unset t */$f }
+ }
+ }
+
+ return [array names t]
+}
+
+#-------------------------------------------------------------------------
+# Set up the following global list variables containing the names of
+# various test scripts:
+#
+# $alltests
+# $allquicktests
+#
+set alltests [list]
+foreach f [glob $testdir/*.test] { lappend alltests [file tail $f] }
+foreach f [glob -nocomplain $testdir/../ext/rtree/*.test] {
+ lappend alltests $f
+}
+
+if {$::tcl_platform(platform)!="unix"} {
+ set alltests [test_set $alltests -exclude crash.test crash2.test]
+}
+set alltests [test_set $alltests -exclude {
+ all.test async.test quick.test veryquick.test
+ memleak.test permutations.test soak.test fts3.test
+ mallocAll.test rtree.test
+}]
+
+set allquicktests [test_set $alltests -exclude {
+ async2.test async3.test backup_ioerr.test corrupt.test
+ corruptC.test crash.test crash2.test crash3.test crash4.test crash5.test
+ crash6.test crash7.test delete3.test e_fts3.test fts3rnd.test
+ fkey_malloc.test fuzz.test fuzz3.test fuzz_malloc.test in2.test loadext.test
+ misc7.test mutex2.test notify2.test onefile.test pagerfault2.test
+ savepoint4.test savepoint6.test select9.test
+ speed1.test speed1p.test speed2.test speed3.test speed4.test
+ speed4p.test sqllimits1.test tkt2686.test thread001.test thread002.test
+ thread003.test thread004.test thread005.test trans2.test vacuum3.test
+ incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test
+ vtab_err.test walslow.test walcrash.test
+ walthread.test rtree3.test indexfault.test
+}]
+if {[info exists ::env(QUICKTEST_INCLUDE)]} {
+ set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
+}
+
+#############################################################################
+# Start of tests
+#
+
+#-------------------------------------------------------------------------
+# Define the generic test suites:
+#
+# veryquick
+# quick
+# full
+#
+lappend ::testsuitelist xxx
+
+test_suite "veryquick" -prefix "" -description {
+ "Very" quick test suite. Runs in less than 5 minutes on a workstation.
+ This test suite is the same as the "quick" tests, except that some files
+ that test malloc and IO errors are omitted.
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault*
+]
+
+test_suite "valgrind" -prefix "" -description {
+ Run the "veryquick" test suite with a couple of multi-process tests (that
+ fail under valgrind) omitted.
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault*
+] -initialize {
+ set ::G(valgrind) 1
+} -shutdown {
+ unset -nocomplain ::G(valgrind)
+}
+
+test_suite "quick" -prefix "" -description {
+ Quick test suite. Runs in around 10 minutes on a workstation.
+} -files [
+ test_set $allquicktests
+]
+
+test_suite "full" -prefix "" -description {
+ Full test suite. Takes a long time.
+} -files [
+ test_set $alltests
+] -initialize {
+ unset -nocomplain ::G(isquick)
+}
+
+test_suite "threads" -prefix "" -description {
+ All multi-threaded tests.
+} -files {
+ notify2.test thread001.test thread002.test thread003.test
+ thread004.test thread005.test walthread.test
+}
+
+test_suite "fts3" -prefix "" -description {
+ All FTS3 tests except fts3rnd.test.
+} -files {
+ fts3aa.test fts3ab.test fts3ac.test fts3ad.test fts3ae.test
+ fts3af.test fts3ag.test fts3ah.test fts3ai.test fts3aj.test
+ fts3ak.test fts3al.test fts3am.test fts3an.test fts3ao.test
+ fts3atoken.test fts3b.test fts3c.test fts3cov.test fts3d.test
+ fts3defer.test fts3defer2.test fts3e.test fts3expr.test fts3expr2.test
+ fts3near.test fts3query.test fts3shared.test fts3snippet.test
+ fts3sort.test
+ fts3fault.test fts3malloc.test fts3matchinfo.test
+ fts3aux1.test fts3comp1.test fts3auto.test
+ fts4aa.test fts4content.test
+ fts3conf.test fts3prefix.test fts3fault2.test fts3corrupt.test
+ fts3corrupt2.test
+ fts3first.test
+}
+
+
+lappend ::testsuitelist xxx
+#-------------------------------------------------------------------------
+# Define the coverage related test suites:
+#
+# coverage-wal
+#
+test_suite "coverage-wal" -description {
+ Coverage tests for file wal.c.
+} -files {
+ wal.test wal2.test wal3.test walmode.test
+ walbak.test walhook.test walcrash2.test walcksum.test
+ walfault.test walbig.test walnoshm.test
+ wal5.test
+}
+
+test_suite "coverage-pager" -description {
+ Coverage tests for file pager.c.
+} -files {
+ pager1.test pager2.test pagerfault.test pagerfault2.test
+ walfault.test walbak.test journal2.test tkt-9d68c883.test
+}
+
+
+lappend ::testsuitelist xxx
+#-------------------------------------------------------------------------
+# Define the permutation test suites:
+#
+
+# Run some tests using pre-allocated page and scratch blocks.
+#
+test_suite "memsubsys1" -description {
+ Tests using pre-allocated page and scratch blocks
+} -files [
+ test_set $::allquicktests -exclude ioerr5.test malloc5.test
+] -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_pagecache 4096 24
+ sqlite3_config_scratch 25000 1
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_pagecache 0 0
+ sqlite3_config_scratch 0 0
+ sqlite3_initialize
+ autoinstall_test_functions
+}
+
+# Run some tests using pre-allocated page and scratch blocks. This time
+# the allocations are too small to use in most cases.
+#
+# Both ioerr5.test and malloc5.test are excluded because they test the
+# sqlite3_soft_heap_limit() and sqlite3_release_memory() functionality.
+# This functionality is disabled if a pre-allocated page block is provided.
+#
+test_suite "memsubsys2" -description {
+ Tests using small pre-allocated page and scratch blocks
+} -files [
+ test_set $::allquicktests -exclude ioerr5.test malloc5.test
+] -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_pagecache 512 5
+ sqlite3_config_scratch 1000 1
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_pagecache 0 0
+ sqlite3_config_scratch 0 0
+ sqlite3_initialize
+ autoinstall_test_functions
+}
+
+# Run all tests with the lookaside allocator disabled.
+#
+test_suite "nolookaside" -description {
+ OOM tests with lookaside disabled
+} -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_lookaside 0 0
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_lookaside 100 500
+ sqlite3_initialize
+ autoinstall_test_functions
+} -files $::allquicktests
+
+# Run some tests in SQLITE_CONFIG_SINGLETHREAD mode.
+#
+test_suite "singlethread" -description {
+ Tests run in SQLITE_CONFIG_SINGLETHREAD mode
+} -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ catch {sqlite3_config singlethread}
+ sqlite3_initialize
+ autoinstall_test_functions
+} -files {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test trans.test update.test vacuum.test types.test
+ types2.test types3.test
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ catch {sqlite3_config serialized}
+ sqlite3_initialize
+ autoinstall_test_functions
+}
+
+test_suite "nomutex" -description {
+ Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open().
+} -initialize {
+ rename sqlite3 sqlite3_nomutex
+ proc sqlite3 {args} {
+ if {[string range [lindex $args 0] 0 0] ne "-"} {
+ lappend args -fullmutex 0 -nomutex 1
+ }
+ uplevel [concat sqlite3_nomutex $args]
+ }
+} -files {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test trans.test update.test vacuum.test types.test
+ types2.test types3.test
+} -shutdown {
+ rename sqlite3 {}
+ rename sqlite3_nomutex sqlite3
+}
+
+# Run some tests in SQLITE_CONFIG_MULTITHREAD mode.
+#
+test_suite "multithread" -description {
+ Tests run in SQLITE_CONFIG_MULTITHREAD mode
+} -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ catch {sqlite3_config multithread}
+ sqlite3_initialize
+ autoinstall_test_functions
+} -files {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test trans.test update.test vacuum.test types.test
+ types2.test types3.test
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ catch {sqlite3_config serialized}
+ sqlite3_initialize
+ autoinstall_test_functions
+}
+
+# Run some tests in SQLITE_OPEN_FULLMUTEX mode.
+#
+test_suite "fullmutex" -description {
+ Tests run in SQLITE_OPEN_FULLMUTEX mode
+} -initialize {
+ rename sqlite3 sqlite3_fullmutex
+ proc sqlite3 {args} {
+ if {[string range [lindex $args 0] 0 0] ne "-"} {
+ lappend args -nomutex 0 -fullmutex 1
+ }
+ uplevel [concat sqlite3_fullmutex $args]
+ }
+} -files {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test trans.test update.test vacuum.test types.test
+ types2.test types3.test
+} -shutdown {
+ rename sqlite3 {}
+ rename sqlite3_fullmutex sqlite3
+}
+
+# Run some tests using the "onefile" demo.
+#
+test_suite "onefile" -description {
+ Run some tests using the "test_onefile.c" demo
+} -initialize {
+ rename sqlite3 sqlite3_onefile
+ proc sqlite3 {args} {
+ if {[string range [lindex $args 0] 0 0] ne "-"} {
+ lappend args -vfs fs
+ }
+ uplevel [concat sqlite3_onefile $args]
+ }
+} -files {
+ conflict.test insert.test insert2.test insert3.test
+ rollback.test select1.test select2.test select3.test
+} -shutdown {
+ rename sqlite3 {}
+ rename sqlite3_onefile sqlite3
+}
+
+# Run some tests using UTF-16 databases.
+#
+test_suite "utf16" -description {
+ Run tests using UTF-16 databases
+} -presql {
+ pragma encoding = 'UTF-16'
+} -files {
+ alter.test alter3.test
+ auth.test bind.test blob.test capi2.test capi3.test collate1.test
+ collate2.test collate3.test collate4.test collate5.test collate6.test
+ conflict.test date.test delete.test expr.test fkey1.test func.test
+ hook.test index.test insert2.test insert.test interrupt.test in.test
+ intpkey.test ioerr.test join2.test join.test lastinsert.test
+ laststmtchanges.test limit.test lock2.test lock.test main.test
+ memdb.test minmax.test misc1.test misc2.test misc3.test notnull.test
+ null.test progress.test quote.test rowid.test select1.test select2.test
+ select3.test select4.test select5.test select6.test sort.test
+ subselect.test tableapi.test table.test temptable.test
+ trace.test trigger1.test trigger2.test trigger3.test
+ trigger4.test types2.test types.test unique.test update.test
+ vacuum.test view.test where.test
+}
+
+# Run some tests in exclusive locking mode.
+#
+test_suite "exclusive" -description {
+ Run tests in exclusive locking mode.
+} -presql {
+ pragma locking_mode = 'exclusive'
+} -files {
+ rollback.test select1.test select2.test
+ malloc.test ioerr.test
+}
+
+# Run some tests in exclusive locking mode with truncated journals.
+#
+test_suite "exclusive-truncate" -description {
+ Run tests in exclusive locking mode and truncate journal mode.
+} -presql {
+ pragma locking_mode = 'exclusive';
+ pragma journal_mode = TRUNCATE;
+} -files {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test update.test malloc.test ioerr.test
+}
+
+# Run some tests in persistent journal mode.
+#
+test_suite "persistent_journal" -description {
+ Run tests in persistent-journal mode.
+} -presql {
+ pragma journal_mode = persist
+} -files {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test trans.test update.test vacuum.test
+}
+
+# Run some tests in truncating journal mode.
+#
+test_suite "truncate_journal" -description {
+ Run tests in persistent-journal mode.
+} -presql {
+ pragma journal_mode = truncate
+} -files {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test trans.test update.test vacuum.test
+ malloc.test ioerr.test
+}
+
+# Run some error tests in persistent journal mode.
+#
+test_suite "persistent_journal_error" -description {
+ Run malloc.test and ioerr.test in persistent-journal mode.
+} -presql {
+ pragma journal_mode = persist
+} -files {
+ malloc.test ioerr.test
+}
+
+# Run some tests in no journal mode.
+#
+test_suite "no_journal" -description {
+ Run tests in no-journal mode.
+} -presql {
+ pragma journal_mode = persist
+} -files {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test trans.test update.test vacuum.test
+}
+
+# Run some error tests in no journal mode.
+#
+test_suite "no_journal_error" -description {
+ Run malloc.test and ioerr.test in no-journal mode.
+} -presql {
+ pragma journal_mode = persist
+} -files {
+ malloc.test ioerr.test
+}
+
+# Run some crash-tests in autovacuum mode.
+#
+test_suite "autovacuum_crash" -description {
+ Run crash.test in autovacuum mode.
+} -presql {
+ pragma auto_vacuum = 1
+} -files crash.test
+
+# Run some ioerr-tests in autovacuum mode.
+#
+test_suite "autovacuum_ioerr" -description {
+ Run ioerr.test in autovacuum mode.
+} -presql {
+ pragma auto_vacuum = 1
+} -files ioerr.test
+
+# Run tests with an in-memory journal.
+#
+test_suite "inmemory_journal" -description {
+ Run tests with an in-memory journal file.
+} -presql {
+ pragma journal_mode = 'memory'
+} -files [test_set $::allquicktests -exclude {
+ # Exclude all tests that simulate IO errors.
+ autovacuum_ioerr2.test incrvacuum_ioerr.test ioerr.test
+ ioerr.test ioerr2.test ioerr3.test ioerr4.test ioerr5.test
+ vacuum3.test incrblob_err.test diskfull.test backup_ioerr.test
+ e_fts3.test fts3cov.test fts3malloc.test fts3rnd.test
+ fts3snippet.test
+
+ # Exclude test scripts that use tcl IO to access journal files or count
+ # the number of fsync() calls.
+ pager.test exclusive.test jrnlmode.test sync.test misc1.test
+ journal1.test conflict.test crash8.test tkt3457.test io.test
+ journal3.test 8_3_names.test
+
+ pager1.test async4.test corrupt.test filefmt.test pager2.test
+ corrupt5.test corruptA.test pageropt.test
+
+ # Exclude stmt.test, which expects sub-journals to use temporary files.
+ stmt.test
+
+ # WAL mode is different.
+ wal* tkt-2d1a5c67d.test backcompat.test
+}]
+
+ifcapable mem3 {
+ test_suite "memsys3" -description {
+ Run tests using the allocator in mem3.c.
+ } -files [test_set $::allquicktests -exclude {
+ autovacuum.test delete3.test manydb.test
+ bigrow.test incrblob2.test memdb.test
+ bitvec.test index2.test memsubsys1.test
+ capi3c.test ioerr.test memsubsys2.test
+ capi3.test join3.test pagesize.test
+ collate5.test limit.test backup_ioerr.test
+ backup_malloc.test
+ }] -initialize {
+ catch {db close}
+ sqlite3_reset_auto_extension
+ sqlite3_shutdown
+ sqlite3_config_heap 25000000 0
+ sqlite3_config_lookaside 0 0
+ ifcapable mem5 {
+ # If both memsys3 and memsys5 are enabled in the build, the call to
+ # [sqlite3_config_heap] will initialize the system to use memsys5.
+ # The following overrides this preference and installs the memsys3
+ # allocator.
+ sqlite3_install_memsys3
+ }
+ install_malloc_faultsim 1
+ sqlite3_initialize
+ autoinstall_test_functions
+ } -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 0 0
+ sqlite3_config_lookaside 100 500
+ install_malloc_faultsim 1
+ sqlite3_initialize
+ autoinstall_test_functions
+ }
+}
+
+ifcapable mem5 {
+ test_suite "memsys5" -description {
+ Run tests using the allocator in mem5.c.
+ } -files [test_set $::allquicktests -exclude {
+ autovacuum.test delete3.test manydb.test
+ bigrow.test incrblob2.test memdb.test
+ bitvec.test index2.test memsubsys1.test
+ capi3c.test ioerr.test memsubsys2.test
+ capi3.test join3.test pagesize.test
+ collate5.test limit.test zeroblob.test
+ }] -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 25000000 64
+ sqlite3_config_lookaside 0 0
+ install_malloc_faultsim 1
+ sqlite3_initialize
+ autoinstall_test_functions
+ } -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 0 0
+ sqlite3_config_lookaside 100 500
+ install_malloc_faultsim 1
+ sqlite3_initialize
+ autoinstall_test_functions
+ }
+
+ test_suite "memsys5-2" -description {
+ Run tests using the allocator in mem5.c in a different configuration.
+ } -files {
+ select1.test
+ } -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_memstatus 0
+ sqlite3_config_heap 40000000 16
+ sqlite3_config_lookaside 0 0
+ install_malloc_faultsim 1
+ sqlite3_initialize
+ autoinstall_test_functions
+ } -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 0 0
+ sqlite3_config_lookaside 100 500
+ install_malloc_faultsim 1
+ sqlite3_initialize
+ autoinstall_test_functions
+ }
+}
+
+ifcapable threadsafe {
+ test_suite "no_mutex_try" -description {
+ The sqlite3_mutex_try() interface always fails
+ } -files [
+ test_set $::allquicktests -exclude mutex1.test mutex2.test
+ ] -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ install_mutex_counters 1
+ set ::disable_mutex_try 1
+ sqlite3_initialize
+ autoinstall_test_functions
+ } -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ install_mutex_counters 0
+ sqlite3_initialize
+ autoinstall_test_functions
+ }
+}
+
+# run_tests "crash_safe_append" -description {
+# Run crash.test with persistent journals on a SAFE_APPEND file-system.
+# } -initialize {
+# rename crashsql sa_crashsql
+# proc crashsql {args} {
+# set options [lrange $args 0 [expr {[llength $args]-2}]]
+# lappend options -char safe_append
+# set sql [lindex $args end]
+# lappend options "
+# PRAGMA journal_mode=persistent;
+# $sql
+# "
+# set fd [open test.db-journal w]
+# puts $fd [string repeat 1234567890 100000]
+# close $fd
+# eval sa_crashsql $options
+# }
+# } -shutdown {
+# rename crashsql {}
+# rename sa_crashsql crashsql
+# } -files crash.test
+
+test_suite "safe_append" -description {
+ Run some tests on a SAFE_APPEND file-system.
+} -initialize {
+ rename sqlite3 sqlite3_safeappend
+ proc sqlite3 {args} {
+ if {[string range [lindex $args 0] 0 0] ne "-"} {
+ lappend args -vfs devsym
+ }
+ uplevel [concat sqlite3_safeappend $args]
+ }
+ sqlite3_simulate_device -char safe_append
+} -shutdown {
+ rename sqlite3 {}
+ rename sqlite3_shutdown sqlite3
+} -files [
+ test_set $::allquicktests shared_err.test -exclude async3.test
+]
+
+# The set of tests to run on the alternative-pcache
+set perm-alt-pcache-testset {
+ async.test
+ attach.test
+ delete.test delete2.test
+ index.test
+ insert.test insert2.test
+ join.test join2.test
+ rollback.test
+ select1.test select2.test
+ trans.test
+ update.test
+}
+
+foreach discard_rate {0 10 50 90 100} {
+ test_suite "pcache${discard_rate}" -description "
+ Alternative pcache implementation with ${discard_rate}% random discard
+ " -initialize "
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 1 $discard_rate 1
+ sqlite3_initialize
+ autoinstall_test_functions
+ " -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 0 0 0
+ sqlite3_config_lookaside 100 500
+ install_malloc_faultsim 1
+ sqlite3_initialize
+ autoinstall_test_functions
+ } -files ${perm-alt-pcache-testset}
+}
+
+test_suite "journaltest" -description {
+ Check that pages are synced before being written (test_journal.c).
+} -initialize {
+ catch {db close}
+ register_jt_vfs -default ""
+} -shutdown {
+ unregister_jt_vfs
+} -files [test_set $::allquicktests -exclude {
+ wal* incrvacuum.test ioerr.test corrupt4.test io.test crash8.test
+ async4.test bigfile.test backcompat.test
+}]
+
+if {[info commands register_demovfs] != ""} {
+ test_suite "demovfs" -description {
+ Check that the demovfs (code in test_demovfs.c) more or less works.
+ } -initialize {
+ register_demovfs
+ } -shutdown {
+ unregister_demovfs
+ } -files {
+ insert.test insert2.test insert3.test rollback.test
+ select1.test select2.test select3.test
+ }
+}
+
+test_suite "wal" -description {
+ Run tests with journal_mode=WAL
+} -initialize {
+ set ::G(savepoint6_iterations) 100
+} -shutdown {
+ unset -nocomplain ::G(savepoint6_iterations)
+} -files {
+ savepoint.test savepoint2.test savepoint6.test
+ trans.test avtrans.test
+
+ fts3aa.test fts3ab.test fts3ac.test fts3ad.test
+ fts3ae.test fts3af.test fts3ag.test fts3ah.test
+ fts3ai.test fts3aj.test fts3ak.test fts3al.test
+ fts3am.test fts3an.test fts3ao.test fts3b.test
+ fts3c.test fts3d.test fts3e.test fts3query.test
+}
+
+test_suite "rtree" -description {
+ All R-tree related tests. Provides coverage of source file rtree.c.
+} -files [glob -nocomplain $::testdir/../ext/rtree/*.test]
+
+test_suite "no_optimization" -description {
+ Run test scripts with optimizations disabled using the
+ sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) interface.
+} -files {
+ where.test where2.test where3.test where4.test where5.test
+ where6.test where7.test where8.test where9.test
+ whereA.test whereB.test wherelimit.test
+ select1.test select2.test select3.test select4.test select5.test
+ select7.test select8.test selectA.test selectC.test
+} -dbconfig {
+ optimization_control $::dbhandle all 0
+}
+
+test_suite "prepare" -description {
+ Run tests with the db connection using sqlite3_prepare() instead of _v2().
+} -dbconfig {
+ db_use_legacy_prepare $::dbhandle 1
+ #$::dbhandle cache size 0
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault*
+]
+
+# End of tests
+#############################################################################
+
+# run_tests NAME OPTIONS
+#
+# where available options are:
+#
+# -description TITLE
+# -initialize SCRIPT
+# -shutdown SCRIPT
+# -presql SQL
+# -files LIST-OF-FILES
+# -prefix NAME
+#
+proc run_tests {name args} {
+ array set options $args
+
+ set ::G(perm:name) $name
+ set ::G(perm:prefix) $options(-prefix)
+ set ::G(perm:presql) $options(-presql)
+ set ::G(isquick) 1
+ set ::G(perm:dbconfig) $options(-dbconfig)
+
+ uplevel $options(-initialize)
+
+ foreach file [lsort $options(-files)] {
+ if {[file tail $file] == $file} { set file [file join $::testdir $file] }
+ slave_test_file $file
+ }
+
+ uplevel $options(-shutdown)
+
+ unset ::G(perm:name)
+ unset ::G(perm:prefix)
+ unset ::G(perm:presql)
+ unset ::G(perm:dbconfig)
+}
+
+proc run_test_suite {name} {
+ if {[info exists ::testspec($name)]==0} {
+ error "No such test suite: $name"
+ }
+ uplevel run_tests $name $::testspec($name)
+}
+
+proc help {} {
+ puts "Usage: $::argv0 TESTSUITE ?TESTFILE?"
+ puts ""
+ puts "Available test-suites are:"
+ foreach k $::testsuitelist {
+ if {[info exists ::testspec($k)]==0} {
+ puts " ----------------------------------------"
+ puts ""
+ } else {
+ array set o $::testspec($k)
+ puts "Test suite: \"$k\""
+ set d [string trim $o(-description)]
+ set d [regsub {\n *} $d "\n "]
+ puts " $d"
+ puts ""
+ }
+ }
+ exit -1
+}
+
+if {[info script] == $argv0} {
+ proc main {argv} {
+ if {[llength $argv]==0} {
+ help
+ } else {
+ set suite [lindex $argv 0]
+ if {[info exists ::testspec($suite)]==0} help
+ set extra ""
+ if {[llength $argv]>1} { set extra [list -files [lrange $argv 1 end]] }
+ eval run_tests $suite $::testspec($suite) $extra
+ }
+ }
+ main $argv
+ finish_test
+}
diff --git a/test/pragma.test b/test/pragma.test
new file mode 100644
index 0000000..0cad25a
--- /dev/null
+++ b/test/pragma.test
@@ -0,0 +1,1492 @@
+# 2002 March 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the PRAGMA command.
+#
+# $Id: pragma.test,v 1.73 2009/01/12 14:01:45 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Test organization:
+#
+# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
+# pragma-2.*: Test synchronous on attached db.
+# pragma-3.*: Test detection of table/index inconsistency by integrity_check.
+# pragma-4.*: Test cache_size and default_cache_size on attached db.
+# pragma-5.*: Test that pragma synchronous may not be used inside of a
+# transaction.
+# pragma-6.*: Test schema-query pragmas.
+# pragma-7.*: Miscellaneous tests.
+# pragma-8.*: Test user_version and schema_version pragmas.
+# pragma-9.*: Test temp_store and temp_store_directory.
+# pragma-10.*: Test the count_changes pragma in the presence of triggers.
+# pragma-11.*: Test the collation_list pragma.
+# pragma-14.*: Test the page_count pragma.
+# pragma-15.*: Test that the value set using the cache_size pragma is not
+# reset when the schema is reloaded.
+# pragma-16.*: Test proxy locking
+#
+
+ifcapable !pragma {
+ finish_test
+ return
+}
+
+# Delete the preexisting database to avoid the special setup
+# that the "all.test" script does.
+#
+db close
+delete_file test.db test.db-journal
+delete_file test3.db test3.db-journal
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+
+
+ifcapable pager_pragmas {
+set DFLT_CACHE_SZ [db one {PRAGMA default_cache_size}]
+set TEMP_CACHE_SZ [db one {PRAGMA temp.default_cache_size}]
+do_test pragma-1.1 {
+ execsql {
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]
+do_test pragma-1.2 {
+ execsql {
+ PRAGMA synchronous=OFF;
+ PRAGMA cache_size=1234;
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} [list 1234 $DFLT_CACHE_SZ 0]
+do_test pragma-1.3 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]
+do_test pragma-1.4 {
+ execsql {
+ PRAGMA synchronous=OFF;
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 0]
+do_test pragma-1.5 {
+ execsql {
+ PRAGMA cache_size=-4321;
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} [list 4321 $DFLT_CACHE_SZ 0]
+do_test pragma-1.6 {
+ execsql {
+ PRAGMA synchronous=ON;
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} [list 4321 $DFLT_CACHE_SZ 1]
+do_test pragma-1.7 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]
+do_test pragma-1.8 {
+ execsql {
+ PRAGMA default_cache_size=-123;
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} {123 123 2}
+do_test pragma-1.9.1 {
+ db close
+ sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db]
+ execsql {
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} {123 123 2}
+ifcapable vacuum {
+ do_test pragma-1.9.2 {
+ execsql {
+ VACUUM;
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+ } {123 123 2}
+}
+do_test pragma-1.10 {
+ execsql {
+ PRAGMA synchronous=NORMAL;
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} {123 123 1}
+do_test pragma-1.11 {
+ execsql {
+ PRAGMA synchronous=FULL;
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} {123 123 2}
+do_test pragma-1.12 {
+ db close
+ sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db]
+ execsql {
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} {123 123 2}
+
+# Make sure the pragma handler understands numeric values in addition
+# to keywords like "off" and "full".
+#
+do_test pragma-1.13 {
+ execsql {
+ PRAGMA synchronous=0;
+ PRAGMA synchronous;
+ }
+} {0}
+do_test pragma-1.14 {
+ execsql {
+ PRAGMA synchronous=2;
+ PRAGMA synchronous;
+ }
+} {2}
+} ;# ifcapable pager_pragmas
+
+# Test turning "flag" pragmas on and off.
+#
+ifcapable debug {
+ # Pragma "vdbe_listing" is only available if compiled with SQLITE_DEBUG
+ #
+ do_test pragma-1.15 {
+ execsql {
+ PRAGMA vdbe_listing=YES;
+ PRAGMA vdbe_listing;
+ }
+ } {1}
+ do_test pragma-1.16 {
+ execsql {
+ PRAGMA vdbe_listing=NO;
+ PRAGMA vdbe_listing;
+ }
+ } {0}
+}
+
+do_test pragma-1.17 {
+ execsql {
+ PRAGMA parser_trace=ON;
+ PRAGMA parser_trace=OFF;
+ }
+} {}
+do_test pragma-1.18 {
+ execsql {
+ PRAGMA bogus = -1234; -- Parsing of negative values
+ }
+} {}
+
+# Test modifying the safety_level of an attached database.
+ifcapable pager_pragmas&&attach {
+ do_test pragma-2.1 {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ }
+ } {}
+ do_test pragma-2.2 {
+ execsql {
+ pragma aux.synchronous;
+ }
+ } {2}
+ do_test pragma-2.3 {
+ execsql {
+ pragma aux.synchronous = OFF;
+ pragma aux.synchronous;
+ pragma synchronous;
+ }
+ } {0 2}
+ do_test pragma-2.4 {
+ execsql {
+ pragma aux.synchronous = ON;
+ pragma synchronous;
+ pragma aux.synchronous;
+ }
+ } {2 1}
+} ;# ifcapable pager_pragmas
+
+# Construct a corrupted index and make sure the integrity_check
+# pragma finds it.
+#
+# These tests won't work if the database is encrypted
+#
+do_test pragma-3.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ BEGIN;
+ CREATE TABLE t2(a,b,c);
+ CREATE INDEX i2 ON t2(a);
+ INSERT INTO t2 VALUES(11,2,3);
+ INSERT INTO t2 VALUES(22,3,4);
+ COMMIT;
+ SELECT rowid, * from t2;
+ }
+} {1 11 2 3 2 22 3 4}
+ifcapable attach {
+ if {![sqlite3 -has-codec] && $sqlite_options(integrityck)} {
+ do_test pragma-3.2 {
+ db eval {SELECT rootpage FROM sqlite_master WHERE name='i2'} break
+ set pgsz [db eval {PRAGMA page_size}]
+ # overwrite the header on the rootpage of the index in order to
+ # make the index appear to be empty.
+ #
+ set offset [expr {$pgsz*($rootpage-1)}]
+ hexio_write test.db $offset 0a00000000040000000000
+ db close
+ sqlite3 db test.db
+ execsql {PRAGMA integrity_check}
+ } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
+ do_test pragma-3.3 {
+ execsql {PRAGMA integrity_check=1}
+ } {{rowid 1 missing from index i2}}
+ do_test pragma-3.4 {
+ execsql {
+ ATTACH DATABASE 'test.db' AS t2;
+ PRAGMA integrity_check
+ }
+ } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
+ do_test pragma-3.5 {
+ execsql {
+ PRAGMA integrity_check=4
+ }
+ } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2}}
+ do_test pragma-3.6 {
+ execsql {
+ PRAGMA integrity_check=xyz
+ }
+ } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
+ do_test pragma-3.7 {
+ execsql {
+ PRAGMA integrity_check=0
+ }
+ } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
+
+ # Add additional corruption by appending unused pages to the end of
+ # the database file testerr.db
+ #
+ do_test pragma-3.8 {
+ execsql {DETACH t2}
+ forcedelete testerr.db testerr.db-journal
+ set out [open testerr.db w]
+ fconfigure $out -translation binary
+ set in [open test.db r]
+ fconfigure $in -translation binary
+ puts -nonewline $out [read $in]
+ seek $in 0
+ puts -nonewline $out [read $in]
+ close $in
+ close $out
+ hexio_write testerr.db 28 00000000
+ execsql {REINDEX t2}
+ execsql {PRAGMA integrity_check}
+ } {ok}
+ do_test pragma-3.8.1 {
+ execsql {PRAGMA quick_check}
+ } {ok}
+ do_test pragma-3.8.2 {
+ execsql {PRAGMA QUICK_CHECK}
+ } {ok}
+ do_test pragma-3.9 {
+ execsql {
+ ATTACH 'testerr.db' AS t2;
+ PRAGMA integrity_check
+ }
+ } {{*** in database t2 ***
+Page 4 is never used
+Page 5 is never used
+Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
+ do_test pragma-3.10 {
+ execsql {
+ PRAGMA integrity_check=1
+ }
+ } {{*** in database t2 ***
+Page 4 is never used}}
+ do_test pragma-3.11 {
+ execsql {
+ PRAGMA integrity_check=5
+ }
+ } {{*** in database t2 ***
+Page 4 is never used
+Page 5 is never used
+Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2}}
+ do_test pragma-3.12 {
+ execsql {
+ PRAGMA integrity_check=4
+ }
+ } {{*** in database t2 ***
+Page 4 is never used
+Page 5 is never used
+Page 6 is never used} {rowid 1 missing from index i2}}
+ do_test pragma-3.13 {
+ execsql {
+ PRAGMA integrity_check=3
+ }
+ } {{*** in database t2 ***
+Page 4 is never used
+Page 5 is never used
+Page 6 is never used}}
+ do_test pragma-3.14 {
+ execsql {
+ PRAGMA integrity_check(2)
+ }
+ } {{*** in database t2 ***
+Page 4 is never used
+Page 5 is never used}}
+ do_test pragma-3.15 {
+ execsql {
+ ATTACH 'testerr.db' AS t3;
+ PRAGMA integrity_check
+ }
+ } {{*** in database t2 ***
+Page 4 is never used
+Page 5 is never used
+Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 ***
+Page 4 is never used
+Page 5 is never used
+Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
+ do_test pragma-3.16 {
+ execsql {
+ PRAGMA integrity_check(10)
+ }
+ } {{*** in database t2 ***
+Page 4 is never used
+Page 5 is never used
+Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 ***
+Page 4 is never used
+Page 5 is never used
+Page 6 is never used} {rowid 1 missing from index i2}}
+ do_test pragma-3.17 {
+ execsql {
+ PRAGMA integrity_check=8
+ }
+ } {{*** in database t2 ***
+Page 4 is never used
+Page 5 is never used
+Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 ***
+Page 4 is never used
+Page 5 is never used}}
+ do_test pragma-3.18 {
+ execsql {
+ PRAGMA integrity_check=4
+ }
+ } {{*** in database t2 ***
+Page 4 is never used
+Page 5 is never used
+Page 6 is never used} {rowid 1 missing from index i2}}
+ }
+ do_test pragma-3.19 {
+ catch {db close}
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ db eval {PRAGMA integrity_check}
+ } {ok}
+}
+#exit
+
+# Test modifying the cache_size of an attached database.
+ifcapable pager_pragmas&&attach {
+do_test pragma-4.1 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ pragma aux.cache_size;
+ pragma aux.default_cache_size;
+ }
+} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ]
+do_test pragma-4.2 {
+ execsql {
+ pragma aux.cache_size = 50;
+ pragma aux.cache_size;
+ pragma aux.default_cache_size;
+ }
+} [list 50 $DFLT_CACHE_SZ]
+do_test pragma-4.3 {
+ execsql {
+ pragma aux.default_cache_size = 456;
+ pragma aux.cache_size;
+ pragma aux.default_cache_size;
+ }
+} {456 456}
+do_test pragma-4.4 {
+ execsql {
+ pragma cache_size;
+ pragma default_cache_size;
+ }
+} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ]
+do_test pragma-4.5 {
+ execsql {
+ DETACH aux;
+ ATTACH 'test3.db' AS aux;
+ pragma aux.cache_size;
+ pragma aux.default_cache_size;
+ }
+} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ]
+do_test pragma-4.6 {
+ execsql {
+ DETACH aux;
+ ATTACH 'test2.db' AS aux;
+ pragma aux.cache_size;
+ pragma aux.default_cache_size;
+ }
+} {456 456}
+} ;# ifcapable pager_pragmas
+
+# Test that modifying the sync-level in the middle of a transaction is
+# disallowed.
+ifcapable pager_pragmas {
+do_test pragma-5.0 {
+ execsql {
+ pragma synchronous;
+ }
+} {2}
+do_test pragma-5.1 {
+ catchsql {
+ BEGIN;
+ pragma synchronous = OFF;
+ }
+} {1 {Safety level may not be changed inside a transaction}}
+do_test pragma-5.2 {
+ execsql {
+ pragma synchronous;
+ }
+} {2}
+catchsql {COMMIT;}
+} ;# ifcapable pager_pragmas
+
+# Test schema-query pragmas
+#
+ifcapable schema_pragmas {
+ifcapable tempdb&&attach {
+ do_test pragma-6.1 {
+ set res {}
+ execsql {SELECT * FROM sqlite_temp_master}
+ foreach {idx name file} [execsql {pragma database_list}] {
+ lappend res $idx $name
+ }
+ set res
+ } {0 main 1 temp 2 aux}
+}
+do_test pragma-6.2 {
+ execsql {
+ CREATE TABLE t2(a,b,c);
+ pragma table_info(t2)
+ }
+} {0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0}
+do_test pragma-6.2.1 {
+ execsql {
+ pragma table_info;
+ }
+} {}
+db nullvalue <<NULL>>
+do_test pragma-6.2.2 {
+ execsql {
+ CREATE TABLE t5(
+ a TEXT DEFAULT CURRENT_TIMESTAMP,
+ b DEFAULT (5+3),
+ c TEXT,
+ d INTEGER DEFAULT NULL,
+ e TEXT DEFAULT ''
+ );
+ PRAGMA table_info(t5);
+ }
+} {0 a TEXT 0 CURRENT_TIMESTAMP 0 1 b {} 0 5+3 0 2 c TEXT 0 <<NULL>> 0 3 d INTEGER 0 NULL 0 4 e TEXT 0 '' 0}
+db nullvalue {}
+ifcapable {foreignkey} {
+ do_test pragma-6.3.1 {
+ execsql {
+ CREATE TABLE t3(a int references t2(b), b UNIQUE);
+ pragma foreign_key_list(t3);
+ }
+ } {0 0 t2 a b {NO ACTION} {NO ACTION} NONE}
+ do_test pragma-6.3.2 {
+ execsql {
+ pragma foreign_key_list;
+ }
+ } {}
+ do_test pragma-6.3.3 {
+ execsql {
+ pragma foreign_key_list(t3_bogus);
+ }
+ } {}
+ do_test pragma-6.3.4 {
+ execsql {
+ pragma foreign_key_list(t5);
+ }
+ } {}
+ do_test pragma-6.4 {
+ execsql {
+ pragma index_list(t3);
+ }
+ } {0 sqlite_autoindex_t3_1 1}
+}
+ifcapable {!foreignkey} {
+ execsql {CREATE TABLE t3(a,b UNIQUE)}
+}
+do_test pragma-6.5.1 {
+ execsql {
+ CREATE INDEX t3i1 ON t3(a,b);
+ pragma index_info(t3i1);
+ }
+} {0 0 a 1 1 b}
+do_test pragma-6.5.2 {
+ execsql {
+ pragma index_info(t3i1_bogus);
+ }
+} {}
+
+ifcapable tempdb {
+ # Test for ticket #3320. When a temp table of the same name exists, make
+ # sure the schema of the main table can still be queried using
+ # "pragma table_info":
+ do_test pragma-6.6.1 {
+ execsql {
+ CREATE TABLE trial(col_main);
+ CREATE TEMP TABLE trial(col_temp);
+ }
+ } {}
+ do_test pragma-6.6.2 {
+ execsql {
+ PRAGMA table_info(trial);
+ }
+ } {0 col_temp {} 0 {} 0}
+ do_test pragma-6.6.3 {
+ execsql {
+ PRAGMA temp.table_info(trial);
+ }
+ } {0 col_temp {} 0 {} 0}
+ do_test pragma-6.6.4 {
+ execsql {
+ PRAGMA main.table_info(trial);
+ }
+ } {0 col_main {} 0 {} 0}
+}
+
+do_test pragma-6.7 {
+ execsql {
+ CREATE TABLE test_table(
+ one INT NOT NULL DEFAULT -1,
+ two text,
+ three VARCHAR(45, 65) DEFAULT 'abcde',
+ four REAL DEFAULT X'abcdef',
+ five DEFAULT CURRENT_TIME
+ );
+ PRAGMA table_info(test_table);
+ }
+} [concat \
+ {0 one INT 1 -1 0} \
+ {1 two text 0 {} 0} \
+ {2 three {VARCHAR(45, 65)} 0 'abcde' 0} \
+ {3 four REAL 0 X'abcdef' 0} \
+ {4 five {} 0 CURRENT_TIME 0} \
+]
+} ;# ifcapable schema_pragmas
+# Miscellaneous tests
+#
+ifcapable schema_pragmas {
+do_test pragma-7.1.1 {
+ # Make sure a pragma knows to read the schema if it needs to
+ db close
+ sqlite3 db test.db
+ execsql {
+ pragma index_list(t3);
+ }
+} {0 t3i1 0 1 sqlite_autoindex_t3_1 1}
+do_test pragma-7.1.2 {
+ execsql {
+ pragma index_list(t3_bogus);
+ }
+} {}
+} ;# ifcapable schema_pragmas
+ifcapable {utf16} {
+ if {[permutation] == ""} {
+ do_test pragma-7.2 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ pragma encoding=bogus;
+ }
+ } {1 {unsupported encoding: bogus}}
+ }
+}
+ifcapable tempdb {
+ do_test pragma-7.3 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ pragma lock_status;
+ }
+ } {main unlocked temp closed}
+} else {
+ do_test pragma-7.3 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ pragma lock_status;
+ }
+ } {main unlocked}
+}
+
+
+#----------------------------------------------------------------------
+# Test cases pragma-8.* test the "PRAGMA schema_version" and "PRAGMA
+# user_version" statements.
+#
+# pragma-8.1: PRAGMA schema_version
+# pragma-8.2: PRAGMA user_version
+#
+
+ifcapable schema_version {
+
+# First check that we can set the schema version and then retrieve the
+# same value.
+do_test pragma-8.1.1 {
+ execsql {
+ PRAGMA schema_version = 105;
+ }
+} {}
+do_test pragma-8.1.2 {
+ execsql2 {
+ PRAGMA schema_version;
+ }
+} {schema_version 105}
+do_test pragma-8.1.3 {
+ execsql {
+ PRAGMA schema_version = 106;
+ }
+} {}
+do_test pragma-8.1.4 {
+ execsql {
+ PRAGMA schema_version;
+ }
+} 106
+
+# Check that creating a table modifies the schema-version (this is really
+# to verify that the value being read is in fact the schema version).
+do_test pragma-8.1.5 {
+ execsql {
+ CREATE TABLE t4(a, b, c);
+ INSERT INTO t4 VALUES(1, 2, 3);
+ SELECT * FROM t4;
+ }
+} {1 2 3}
+do_test pragma-8.1.6 {
+ execsql {
+ PRAGMA schema_version;
+ }
+} 107
+
+# Now open a second connection to the database. Ensure that changing the
+# schema-version using the first connection forces the second connection
+# to reload the schema. This has to be done using the C-API test functions,
+# because the TCL API accounts for SCHEMA_ERROR and retries the query.
+do_test pragma-8.1.7 {
+ sqlite3 db2 test.db; set ::DB2 [sqlite3_connection_pointer db2]
+ execsql {
+ SELECT * FROM t4;
+ } db2
+} {1 2 3}
+do_test pragma-8.1.8 {
+ execsql {
+ PRAGMA schema_version = 108;
+ }
+} {}
+do_test pragma-8.1.9 {
+ set ::STMT [sqlite3_prepare $::DB2 "SELECT * FROM t4" -1 DUMMY]
+ sqlite3_step $::STMT
+} SQLITE_ERROR
+do_test pragma-8.1.10 {
+ sqlite3_finalize $::STMT
+} SQLITE_SCHEMA
+
+# Make sure the schema-version can be manipulated in an attached database.
+forcedelete test2.db
+forcedelete test2.db-journal
+ifcapable attach {
+ do_test pragma-8.1.11 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ CREATE TABLE aux.t1(a, b, c);
+ PRAGMA aux.schema_version = 205;
+ }
+ } {}
+ do_test pragma-8.1.12 {
+ execsql {
+ PRAGMA aux.schema_version;
+ }
+ } 205
+}
+do_test pragma-8.1.13 {
+ execsql {
+ PRAGMA schema_version;
+ }
+} 108
+
+# And check that modifying the schema-version in an attached database
+# forces the second connection to reload the schema.
+ifcapable attach {
+ do_test pragma-8.1.14 {
+ sqlite3 db2 test.db; set ::DB2 [sqlite3_connection_pointer db2]
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ SELECT * FROM aux.t1;
+ } db2
+ } {}
+ do_test pragma-8.1.15 {
+ execsql {
+ PRAGMA aux.schema_version = 206;
+ }
+ } {}
+ do_test pragma-8.1.16 {
+ set ::STMT [sqlite3_prepare $::DB2 "SELECT * FROM aux.t1" -1 DUMMY]
+ sqlite3_step $::STMT
+ } SQLITE_ERROR
+ do_test pragma-8.1.17 {
+ sqlite3_finalize $::STMT
+ } SQLITE_SCHEMA
+ do_test pragma-8.1.18 {
+ db2 close
+ } {}
+}
+
+# Now test that the user-version can be read and written (and that we aren't
+# accidentally manipulating the schema-version instead).
+do_test pragma-8.2.1 {
+ execsql2 {
+ PRAGMA user_version;
+ }
+} {user_version 0}
+do_test pragma-8.2.2 {
+ execsql {
+ PRAGMA user_version = 2;
+ }
+} {}
+do_test pragma-8.2.3.1 {
+ execsql2 {
+ PRAGMA user_version;
+ }
+} {user_version 2}
+do_test pragma-8.2.3.2 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA user_version;
+ }
+} {2}
+do_test pragma-8.2.4.1 {
+ execsql {
+ PRAGMA schema_version;
+ }
+} {108}
+ifcapable vacuum {
+ do_test pragma-8.2.4.2 {
+ execsql {
+ VACUUM;
+ PRAGMA user_version;
+ }
+ } {2}
+ do_test pragma-8.2.4.3 {
+ execsql {
+ PRAGMA schema_version;
+ }
+ } {109}
+}
+
+ifcapable attach {
+ db eval {ATTACH 'test2.db' AS aux}
+
+ # Check that the user-version in the auxilary database can be manipulated (
+ # and that we aren't accidentally manipulating the same in the main db).
+ do_test pragma-8.2.5 {
+ execsql {
+ PRAGMA aux.user_version;
+ }
+ } {0}
+ do_test pragma-8.2.6 {
+ execsql {
+ PRAGMA aux.user_version = 3;
+ }
+ } {}
+ do_test pragma-8.2.7 {
+ execsql {
+ PRAGMA aux.user_version;
+ }
+ } {3}
+ do_test pragma-8.2.8 {
+ execsql {
+ PRAGMA main.user_version;
+ }
+ } {2}
+
+ # Now check that a ROLLBACK resets the user-version if it has been modified
+ # within a transaction.
+ do_test pragma-8.2.9 {
+ execsql {
+ BEGIN;
+ PRAGMA aux.user_version = 10;
+ PRAGMA user_version = 11;
+ }
+ } {}
+ do_test pragma-8.2.10 {
+ execsql {
+ PRAGMA aux.user_version;
+ }
+ } {10}
+ do_test pragma-8.2.11 {
+ execsql {
+ PRAGMA main.user_version;
+ }
+ } {11}
+ do_test pragma-8.2.12 {
+ execsql {
+ ROLLBACK;
+ PRAGMA aux.user_version;
+ }
+ } {3}
+ do_test pragma-8.2.13 {
+ execsql {
+ PRAGMA main.user_version;
+ }
+ } {2}
+}
+
+# Try a negative value for the user-version
+do_test pragma-8.2.14 {
+ execsql {
+ PRAGMA user_version = -450;
+ }
+} {}
+do_test pragma-8.2.15 {
+ execsql {
+ PRAGMA user_version;
+ }
+} {-450}
+} ; # ifcapable schema_version
+
+# Check to see if TEMP_STORE is memory or disk. Return strings
+# "memory" or "disk" as appropriate.
+#
+proc check_temp_store {} {
+ db eval {CREATE TEMP TABLE IF NOT EXISTS a(b)}
+ db eval {PRAGMA database_list} {
+ if {$name=="temp"} {
+ set bt [btree_from_db db 1]
+ if {[btree_ismemdb $bt]} {
+ return "memory"
+ }
+ return "disk"
+ }
+ }
+ return "unknown"
+}
+
+
+# Test temp_store and temp_store_directory pragmas
+#
+ifcapable pager_pragmas {
+do_test pragma-9.1 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA temp_store;
+ }
+} {0}
+if {$TEMP_STORE<=1} {
+ do_test pragma-9.1.1 {
+ check_temp_store
+ } {disk}
+} else {
+ do_test pragma-9.1.1 {
+ check_temp_store
+ } {memory}
+}
+
+do_test pragma-9.2 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA temp_store=file;
+ PRAGMA temp_store;
+ }
+} {1}
+if {$TEMP_STORE==3} {
+ # When TEMP_STORE is 3, always use memory regardless of pragma settings.
+ do_test pragma-9.2.1 {
+ check_temp_store
+ } {memory}
+} else {
+ do_test pragma-9.2.1 {
+ check_temp_store
+ } {disk}
+}
+
+do_test pragma-9.3 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA temp_store=memory;
+ PRAGMA temp_store;
+ }
+} {2}
+if {$TEMP_STORE==0} {
+ # When TEMP_STORE is 0, always use the disk regardless of pragma settings.
+ do_test pragma-9.3.1 {
+ check_temp_store
+ } {disk}
+} else {
+ do_test pragma-9.3.1 {
+ check_temp_store
+ } {memory}
+}
+
+do_test pragma-9.4 {
+ execsql {
+ PRAGMA temp_store_directory;
+ }
+} {}
+ifcapable wsd {
+ do_test pragma-9.5 {
+ set pwd [string map {' ''} [file nativename [pwd]]]
+ execsql "
+ PRAGMA temp_store_directory='$pwd';
+ "
+ } {}
+ do_test pragma-9.6 {
+ execsql {
+ PRAGMA temp_store_directory;
+ }
+ } [list [file nativename [pwd]]]
+ do_test pragma-9.7 {
+ catchsql {
+ PRAGMA temp_store_directory='/NON/EXISTENT/PATH/FOOBAR';
+ }
+ } {1 {not a writable directory}}
+ do_test pragma-9.8 {
+ execsql {
+ PRAGMA temp_store_directory='';
+ }
+ } {}
+ if {![info exists TEMP_STORE] || $TEMP_STORE<=1} {
+ ifcapable tempdb {
+ do_test pragma-9.9 {
+ execsql {
+ PRAGMA temp_store_directory;
+ PRAGMA temp_store=FILE;
+ CREATE TEMP TABLE temp_store_directory_test(a integer);
+ INSERT INTO temp_store_directory_test values (2);
+ SELECT * FROM temp_store_directory_test;
+ }
+ } {2}
+ do_test pragma-9.10 {
+ catchsql "
+ PRAGMA temp_store_directory='$pwd';
+ SELECT * FROM temp_store_directory_test;
+ "
+ } {1 {no such table: temp_store_directory_test}}
+ }
+ }
+}
+do_test pragma-9.11 {
+ execsql {
+ PRAGMA temp_store = 0;
+ PRAGMA temp_store;
+ }
+} {0}
+do_test pragma-9.12 {
+ execsql {
+ PRAGMA temp_store = 1;
+ PRAGMA temp_store;
+ }
+} {1}
+do_test pragma-9.13 {
+ execsql {
+ PRAGMA temp_store = 2;
+ PRAGMA temp_store;
+ }
+} {2}
+do_test pragma-9.14 {
+ execsql {
+ PRAGMA temp_store = 3;
+ PRAGMA temp_store;
+ }
+} {0}
+do_test pragma-9.15 {
+ catchsql {
+ BEGIN EXCLUSIVE;
+ CREATE TEMP TABLE temp_table(t);
+ INSERT INTO temp_table VALUES('valuable data');
+ PRAGMA temp_store = 1;
+ }
+} {1 {temporary storage cannot be changed from within a transaction}}
+do_test pragma-9.16 {
+ execsql {
+ SELECT * FROM temp_table;
+ COMMIT;
+ }
+} {{valuable data}}
+
+do_test pragma-9.17 {
+ execsql {
+ INSERT INTO temp_table VALUES('valuable data II');
+ SELECT * FROM temp_table;
+ }
+} {{valuable data} {valuable data II}}
+
+do_test pragma-9.18 {
+ set rc [catch {
+ db eval {SELECT t FROM temp_table} {
+ execsql {pragma temp_store = 1}
+ }
+ } msg]
+ list $rc $msg
+} {1 {temporary storage cannot be changed from within a transaction}}
+
+} ;# ifcapable pager_pragmas
+
+ifcapable trigger {
+
+do_test pragma-10.0 {
+ catchsql {
+ DROP TABLE main.t1;
+ }
+ execsql {
+ PRAGMA count_changes = 1;
+
+ CREATE TABLE t1(a PRIMARY KEY);
+ CREATE TABLE t1_mirror(a);
+ CREATE TABLE t1_mirror2(a);
+ CREATE TRIGGER t1_bi BEFORE INSERT ON t1 BEGIN
+ INSERT INTO t1_mirror VALUES(new.a);
+ END;
+ CREATE TRIGGER t1_ai AFTER INSERT ON t1 BEGIN
+ INSERT INTO t1_mirror2 VALUES(new.a);
+ END;
+ CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 BEGIN
+ UPDATE t1_mirror SET a = new.a WHERE a = old.a;
+ END;
+ CREATE TRIGGER t1_au AFTER UPDATE ON t1 BEGIN
+ UPDATE t1_mirror2 SET a = new.a WHERE a = old.a;
+ END;
+ CREATE TRIGGER t1_bd BEFORE DELETE ON t1 BEGIN
+ DELETE FROM t1_mirror WHERE a = old.a;
+ END;
+ CREATE TRIGGER t1_ad AFTER DELETE ON t1 BEGIN
+ DELETE FROM t1_mirror2 WHERE a = old.a;
+ END;
+ }
+} {}
+
+do_test pragma-10.1 {
+ execsql {
+ INSERT INTO t1 VALUES(randstr(10,10));
+ }
+} {1}
+do_test pragma-10.2 {
+ execsql {
+ UPDATE t1 SET a = randstr(10,10);
+ }
+} {1}
+do_test pragma-10.3 {
+ execsql {
+ DELETE FROM t1;
+ }
+} {1}
+
+} ;# ifcapable trigger
+
+ifcapable schema_pragmas {
+ do_test pragma-11.1 {
+ execsql2 {
+ pragma collation_list;
+ }
+ } {seq 0 name NOCASE seq 1 name RTRIM seq 2 name BINARY}
+ do_test pragma-11.2 {
+ db collate New_Collation blah...
+ execsql {
+ pragma collation_list;
+ }
+ } {0 New_Collation 1 NOCASE 2 RTRIM 3 BINARY}
+}
+
+ifcapable schema_pragmas&&tempdb {
+ do_test pragma-12.1 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA temp.table_info('abc');
+ } db2
+ } {}
+ db2 close
+
+ do_test pragma-12.2 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA temp.default_cache_size = 200;
+ PRAGMA temp.default_cache_size;
+ } db2
+ } {200}
+ db2 close
+
+ do_test pragma-12.3 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA temp.cache_size = 400;
+ PRAGMA temp.cache_size;
+ } db2
+ } {400}
+ db2 close
+}
+
+ifcapable bloblit {
+
+do_test pragma-13.1 {
+ execsql {
+ DROP TABLE IF EXISTS t4;
+ PRAGMA vdbe_trace=on;
+ PRAGMA vdbe_listing=on;
+ PRAGMA sql_trace=on;
+ CREATE TABLE t4(a INTEGER PRIMARY KEY,b);
+ INSERT INTO t4(b) VALUES(x'0123456789abcdef0123456789abcdef0123456789');
+ INSERT INTO t4(b) VALUES(randstr(30,30));
+ INSERT INTO t4(b) VALUES(1.23456);
+ INSERT INTO t4(b) VALUES(NULL);
+ INSERT INTO t4(b) VALUES(0);
+ INSERT INTO t4(b) SELECT b||b||b||b FROM t4;
+ SELECT * FROM t4;
+ }
+ execsql {
+ PRAGMA vdbe_trace=off;
+ PRAGMA vdbe_listing=off;
+ PRAGMA sql_trace=off;
+ }
+} {}
+
+} ;# ifcapable bloblit
+
+ifcapable pager_pragmas {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+
+ do_test pragma-14.1 {
+ execsql { pragma auto_vacuum = 0 }
+ execsql { pragma page_count }
+ } {0}
+
+ do_test pragma-14.2 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ PRAGMA page_count;
+ }
+ } {2}
+ do_test pragma-14.2uc {
+ execsql {pragma PAGE_COUNT}
+ } {2}
+
+ do_test pragma-14.3 {
+ execsql {
+ BEGIN;
+ CREATE TABLE def(a, b, c);
+ PRAGMA page_count;
+ }
+ } {3}
+ do_test pragma-14.3uc {
+ execsql {pragma PAGE_COUNT}
+ } {3}
+
+ do_test pragma-14.4 {
+ set page_size [db one {pragma page_size}]
+ expr [file size test.db] / $page_size
+ } {2}
+
+ do_test pragma-14.5 {
+ execsql {
+ ROLLBACK;
+ PRAGMA page_count;
+ }
+ } {2}
+
+ do_test pragma-14.6 {
+ forcedelete test2.db
+ sqlite3 db2 test2.db
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+ CREATE TABLE t3(a, b, c);
+ CREATE TABLE t4(a, b, c);
+ } db2
+ db2 close
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ PRAGMA aux.page_count;
+ }
+ } {5}
+ do_test pragma-14.6uc {
+ execsql {pragma AUX.PAGE_COUNT}
+ } {5}
+}
+
+# Test that the value set using the cache_size pragma is not reset when the
+# schema is reloaded.
+#
+ifcapable pager_pragmas {
+ db close
+ sqlite3 db test.db
+ do_test pragma-15.1 {
+ execsql {
+ PRAGMA cache_size=59;
+ PRAGMA cache_size;
+ }
+ } {59}
+ do_test pragma-15.2 {
+ sqlite3 db2 test.db
+ execsql {
+ CREATE TABLE newtable(a, b, c);
+ } db2
+ db2 close
+ } {}
+ do_test pragma-15.3 {
+ # Evaluating this statement will cause the schema to be reloaded (because
+ # the schema was changed by another connection in pragma-15.2). At one
+ # point there was a bug that reset the cache_size to its default value
+ # when this happened.
+ execsql { SELECT * FROM sqlite_master }
+ execsql { PRAGMA cache_size }
+ } {59}
+}
+
+# Reset the sqlite3_temp_directory variable for the next run of tests:
+sqlite3 dbX :memory:
+dbX eval {PRAGMA temp_store_directory = ""}
+dbX close
+
+ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
+ set sqlite_hostid_num 1
+
+ set using_proxy 0
+ foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
+ set using_proxy $value
+ }
+
+ # Test the lock_proxy_file pragmas.
+ #
+ db close
+ set env(SQLITE_FORCE_PROXY_LOCKING) "0"
+
+ sqlite3 db test.db
+ do_test pragma-16.1 {
+ execsql {
+ PRAGMA lock_proxy_file="mylittleproxy";
+ select * from sqlite_master;
+ }
+ execsql {
+ PRAGMA lock_proxy_file;
+ }
+ } {mylittleproxy}
+
+ do_test pragma-16.2 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA lock_proxy_file="mylittleproxy";
+ } db2
+ } {}
+
+ db2 close
+ do_test pragma-16.2.1 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA lock_proxy_file=":auto:";
+ select * from sqlite_master;
+ } db2
+ execsql {
+ PRAGMA lock_proxy_file;
+ } db2
+ } {mylittleproxy}
+
+ db2 close
+ do_test pragma-16.3 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA lock_proxy_file="myotherproxy";
+ } db2
+ catchsql {
+ select * from sqlite_master;
+ } db2
+ } {1 {database is locked}}
+
+ do_test pragma-16.4 {
+ db2 close
+ db close
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA lock_proxy_file="myoriginalproxy";
+ PRAGMA lock_proxy_file="myotherproxy";
+ PRAGMA lock_proxy_file;
+ } db2
+ } {myotherproxy}
+
+ db2 close
+ set env(SQLITE_FORCE_PROXY_LOCKING) "1"
+ do_test pragma-16.5 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA lock_proxy_file=":auto:";
+ PRAGMA lock_proxy_file;
+ } db2
+ } {myotherproxy}
+
+ do_test pragma-16.6 {
+ db2 close
+ sqlite3 db2 test2.db
+ set lockpath [execsql {
+ PRAGMA lock_proxy_file=":auto:";
+ PRAGMA lock_proxy_file;
+ } db2]
+ string match "*test2.db:auto:" $lockpath
+ } {1}
+
+ set sqlite_hostid_num 2
+ do_test pragma-16.7 {
+ list [catch {
+ sqlite3 db test2.db
+ execsql {
+ PRAGMA lock_proxy_file=":auto:";
+ select * from sqlite_master;
+ }
+ } msg] $msg
+ } {1 {database is locked}}
+ db close
+
+ do_test pragma-16.8 {
+ list [catch {
+ sqlite3 db test2.db
+ execsql { select * from sqlite_master }
+ } msg] $msg
+ } {1 {database is locked}}
+
+ db2 close
+ do_test pragma-16.8.1 {
+ execsql {
+ PRAGMA lock_proxy_file="yetanotherproxy";
+ PRAGMA lock_proxy_file;
+ }
+ } {yetanotherproxy}
+ do_test pragma-16.8.2 {
+ execsql {
+ create table mine(x);
+ }
+ } {}
+
+ db close
+ do_test pragma-16.9 {
+ sqlite3 db proxytest.db
+ set lockpath2 [execsql {
+ PRAGMA lock_proxy_file=":auto:";
+ PRAGMA lock_proxy_file;
+ } db]
+ string match "*proxytest.db:auto:" $lockpath2
+ } {1}
+
+ set env(SQLITE_FORCE_PROXY_LOCKING) $using_proxy
+ set sqlite_hostid_num 0
+}
+
+# Parsing of auto_vacuum settings.
+#
+foreach {autovac_setting val} {
+ 0 0
+ 1 1
+ 2 2
+ 3 0
+ -1 0
+ none 0
+ NONE 0
+ NoNe 0
+ full 1
+ FULL 1
+ incremental 2
+ INCREMENTAL 2
+ -1234 0
+ 1234 0
+} {
+ do_test pragma-17.1.$autovac_setting {
+ catch {db close}
+ sqlite3 db :memory:
+ execsql "
+ PRAGMA auto_vacuum=$::autovac_setting;
+ PRAGMA auto_vacuum;
+ "
+ } $val
+}
+
+# Parsing of temp_store settings.
+#
+foreach {temp_setting val} {
+ 0 0
+ 1 1
+ 2 2
+ 3 0
+ -1 0
+ file 1
+ FILE 1
+ fIlE 1
+ memory 2
+ MEMORY 2
+ MeMoRy 2
+} {
+ do_test pragma-18.1.$temp_setting {
+ catch {db close}
+ sqlite3 db :memory:
+ execsql "
+ PRAGMA temp_store=$::temp_setting;
+ PRAGMA temp_store=$::temp_setting;
+ PRAGMA temp_store;
+ "
+ } $val
+}
+
+finish_test
diff --git a/test/pragma2.test b/test/pragma2.test
new file mode 100644
index 0000000..1111a98
--- /dev/null
+++ b/test/pragma2.test
@@ -0,0 +1,119 @@
+# 2002 March 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the PRAGMA command.
+#
+# $Id: pragma2.test,v 1.4 2007/10/09 08:29:33 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Test organization:
+#
+# pragma2-1.*: Test freelist_count pragma on the main database.
+# pragma2-2.*: Test freelist_count pragma on an attached database.
+# pragma2-3.*: Test trying to write to the freelist_count is a no-op.
+#
+
+ifcapable !pragma||!schema_pragmas {
+ finish_test
+ return
+}
+
+# Delete the preexisting database to avoid the special setup
+# that the "all.test" script does.
+#
+db close
+delete_file test.db test.db-journal
+delete_file test3.db test3.db-journal
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+db eval {PRAGMA auto_vacuum=0}
+
+do_test pragma2-1.1 {
+ execsql {
+ PRAGMA freelist_count;
+ }
+} {0}
+do_test pragma2-1.2 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ PRAGMA freelist_count;
+ }
+} {0}
+do_test pragma2-1.3 {
+ execsql {
+ DROP TABLE abc;
+ PRAGMA freelist_count;
+ }
+} {1}
+do_test pragma2-1.4 {
+ execsql {
+ PRAGMA main.freelist_count;
+ }
+} {1}
+
+forcedelete test2.db
+forcedelete test2.db-journal
+
+ifcapable attach {
+ do_test pragma2-2.1 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ PRAGMA aux.auto_vacuum=OFF;
+ PRAGMA aux.freelist_count;
+ }
+ } {0}
+ do_test pragma2-2.2 {
+ execsql {
+ CREATE TABLE aux.abc(a, b, c);
+ PRAGMA aux.freelist_count;
+ }
+ } {0}
+ do_test pragma2-2.3 {
+ set ::val [string repeat 0123456789 1000]
+ execsql {
+ INSERT INTO aux.abc VALUES(1, 2, $::val);
+ PRAGMA aux.freelist_count;
+ }
+ } {0}
+ do_test pragma2-2.4 {
+ expr {[file size test2.db] / 1024}
+ } {11}
+ do_test pragma2-2.5 {
+ execsql {
+ DELETE FROM aux.abc;
+ PRAGMA aux.freelist_count;
+ }
+ } {9}
+
+ do_test pragma2-3.1 {
+ execsql {
+ PRAGMA aux.freelist_count;
+ PRAGMA main.freelist_count;
+ PRAGMA freelist_count;
+ }
+ } {9 1 1}
+ do_test pragma2-3.2 {
+ execsql {
+ PRAGMA freelist_count = 500;
+ PRAGMA freelist_count;
+ }
+ } {1 1}
+ do_test pragma2-3.3 {
+ execsql {
+ PRAGMA aux.freelist_count = 500;
+ PRAGMA aux.freelist_count;
+ }
+ } {9 9}
+}
+
+finish_test
diff --git a/test/printf.test b/test/printf.test
new file mode 100644
index 0000000..7322272
--- /dev/null
+++ b/test/printf.test
@@ -0,0 +1,3755 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the sqlite_*_printf() interface.
+#
+# $Id: printf.test,v 1.31 2009/02/01 00:21:10 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+do_test printf-1.1.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 1 1 1
+} {abc: 1 1 1 :xyz}
+do_test printf-1.1.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 1 1 1
+} {abc: ( 1) ( 1) ( 1) :xyz}
+do_test printf-1.1.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 1 1 1
+} {abc: (1 ) (1 ) (1 ) :xyz}
+do_test printf-1.1.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 1 1 1
+} {abc: ( +1) ( 1) ( 1) :xyz}
+do_test printf-1.1.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 1 1 1
+} {abc: (000001) (000001) (000001) :xyz}
+do_test printf-1.1.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 1 1 1
+} {abc: ( 1) ( 1) ( 1) :xyz}
+do_test printf-1.1.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 1 1 1
+} {abc: ( 1) ( 0x1) ( 01) :xyz}
+do_test printf-1.2.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 2 2 2
+} {abc: 2 2 2 :xyz}
+do_test printf-1.2.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 2 2 2
+} {abc: ( 2) ( 2) ( 2) :xyz}
+do_test printf-1.2.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 2 2 2
+} {abc: (2 ) (2 ) (2 ) :xyz}
+do_test printf-1.2.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 2 2 2
+} {abc: ( +2) ( 2) ( 2) :xyz}
+do_test printf-1.2.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 2 2 2
+} {abc: (000002) (000002) (000002) :xyz}
+do_test printf-1.2.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 2 2 2
+} {abc: ( 2) ( 2) ( 2) :xyz}
+do_test printf-1.2.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 2 2 2
+} {abc: ( 2) ( 0x2) ( 02) :xyz}
+do_test printf-1.3.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 5 5 5
+} {abc: 5 5 5 :xyz}
+do_test printf-1.3.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 5 5 5
+} {abc: ( 5) ( 5) ( 5) :xyz}
+do_test printf-1.3.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 5 5 5
+} {abc: (5 ) (5 ) (5 ) :xyz}
+do_test printf-1.3.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 5 5 5
+} {abc: ( +5) ( 5) ( 5) :xyz}
+do_test printf-1.3.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 5 5 5
+} {abc: (000005) (000005) (000005) :xyz}
+do_test printf-1.3.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 5 5 5
+} {abc: ( 5) ( 5) ( 5) :xyz}
+do_test printf-1.3.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 5 5 5
+} {abc: ( 5) ( 0x5) ( 05) :xyz}
+do_test printf-1.4.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 10 10 10
+} {abc: 10 a 12 :xyz}
+do_test printf-1.4.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 10 10 10
+} {abc: ( 10) ( a) ( 12) :xyz}
+do_test printf-1.4.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 10 10 10
+} {abc: (10 ) (a ) (12 ) :xyz}
+do_test printf-1.4.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 10 10 10
+} {abc: ( +10) ( a) ( 12) :xyz}
+do_test printf-1.4.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 10 10 10
+} {abc: (000010) (00000a) (000012) :xyz}
+do_test printf-1.4.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 10 10 10
+} {abc: ( 10) ( a) ( 12) :xyz}
+do_test printf-1.4.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 10 10 10
+} {abc: ( 10) ( 0xa) ( 012) :xyz}
+do_test printf-1.5.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 99 99 99
+} {abc: 99 63 143 :xyz}
+do_test printf-1.5.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 99 99 99
+} {abc: ( 99) ( 63) ( 143) :xyz}
+do_test printf-1.5.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 99 99 99
+} {abc: (99 ) (63 ) (143 ) :xyz}
+do_test printf-1.5.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 99 99 99
+} {abc: ( +99) ( 63) ( 143) :xyz}
+do_test printf-1.5.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 99 99 99
+} {abc: (000099) (000063) (000143) :xyz}
+do_test printf-1.5.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 99 99 99
+} {abc: ( 99) ( 63) ( 143) :xyz}
+do_test printf-1.5.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 99 99 99
+} {abc: ( 99) ( 0x63) ( 0143) :xyz}
+do_test printf-1.6.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 100 100 100
+} {abc: 100 64 144 :xyz}
+do_test printf-1.6.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 100 100 100
+} {abc: ( 100) ( 64) ( 144) :xyz}
+do_test printf-1.6.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 100 100 100
+} {abc: (100 ) (64 ) (144 ) :xyz}
+do_test printf-1.6.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 100 100 100
+} {abc: ( +100) ( 64) ( 144) :xyz}
+do_test printf-1.6.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 100 100 100
+} {abc: (000100) (000064) (000144) :xyz}
+do_test printf-1.6.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 100 100 100
+} {abc: ( 100) ( 64) ( 144) :xyz}
+do_test printf-1.6.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 100 100 100
+} {abc: ( 100) ( 0x64) ( 0144) :xyz}
+do_test printf-1.7.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 1000000 1000000 1000000
+} {abc: 1000000 f4240 3641100 :xyz}
+do_test printf-1.7.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 1000000 1000000 1000000
+} {abc: (1000000) ( f4240) (3641100) :xyz}
+do_test printf-1.7.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 1000000 1000000 1000000
+} {abc: (1000000) (f4240 ) (3641100) :xyz}
+do_test printf-1.7.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 1000000 1000000 1000000
+} {abc: (+1000000) ( f4240) (3641100) :xyz}
+do_test printf-1.7.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 1000000 1000000 1000000
+} {abc: (1000000) (0f4240) (3641100) :xyz}
+do_test printf-1.7.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 1000000 1000000 1000000
+} {abc: ( 1000000) ( f4240) (3641100) :xyz}
+do_test printf-1.7.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 1000000 1000000 1000000
+} {abc: (1000000) (0xf4240) (03641100) :xyz}
+do_test printf-1.8.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 999999999 999999999 999999999
+} {abc: 999999999 3b9ac9ff 7346544777 :xyz}
+do_test printf-1.8.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 999999999 999999999 999999999
+} {abc: (999999999) (3b9ac9ff) (7346544777) :xyz}
+do_test printf-1.8.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 999999999 999999999 999999999
+} {abc: (999999999) (3b9ac9ff) (7346544777) :xyz}
+do_test printf-1.8.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 999999999 999999999 999999999
+} {abc: (+999999999) (3b9ac9ff) (7346544777) :xyz}
+do_test printf-1.8.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 999999999 999999999 999999999
+} {abc: (999999999) (3b9ac9ff) (7346544777) :xyz}
+do_test printf-1.8.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 999999999 999999999 999999999
+} {abc: ( 999999999) (3b9ac9ff) (7346544777) :xyz}
+do_test printf-1.8.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 999999999 999999999 999999999
+} {abc: (999999999) (0x3b9ac9ff) (07346544777) :xyz}
+do_test printf-1.9.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 0 0 0
+} {abc: 0 0 0 :xyz}
+do_test printf-1.9.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 0 0 0
+} {abc: ( 0) ( 0) ( 0) :xyz}
+do_test printf-1.9.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 0 0 0
+} {abc: (0 ) (0 ) (0 ) :xyz}
+do_test printf-1.9.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 0 0 0
+} {abc: ( +0) ( 0) ( 0) :xyz}
+do_test printf-1.9.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 0 0 0
+} {abc: (000000) (000000) (000000) :xyz}
+do_test printf-1.9.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 0 0 0
+} {abc: ( 0) ( 0) ( 0) :xyz}
+do_test printf-1.9.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 0 0 0
+} {abc: ( 0) ( 0) ( 0) :xyz}
+# 0xffffffff == -1
+do_test printf-1.10.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 0xffffffff 0xffffffff 0xffffffff
+} {abc: -1 ffffffff 37777777777 :xyz}
+do_test printf-1.10.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 0xffffffff 0xffffffff 0xffffffff
+} {abc: ( -1) (ffffffff) (37777777777) :xyz}
+do_test printf-1.10.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 0xffffffff 0xffffffff 0xffffffff
+} {abc: (-1 ) (ffffffff) (37777777777) :xyz}
+do_test printf-1.10.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 0xffffffff 0xffffffff 0xffffffff
+} {abc: ( -1) (ffffffff) (37777777777) :xyz}
+do_test printf-1.10.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 0xffffffff 0xffffffff 0xffffffff
+} {abc: (-00001) (ffffffff) (37777777777) :xyz}
+do_test printf-1.10.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 0xffffffff 0xffffffff 0xffffffff
+} {abc: ( -1) (ffffffff) (37777777777) :xyz}
+do_test printf-1.10.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 0xffffffff 0xffffffff 0xffffffff
+} {abc: ( -1) (0xffffffff) (037777777777) :xyz}
+# 0xfffffffe == -2
+do_test printf-1.11.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 0xfffffffe 0xfffffffe 0xfffffffe
+} {abc: -2 fffffffe 37777777776 :xyz}
+do_test printf-1.11.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 0xfffffffe 0xfffffffe 0xfffffffe
+} {abc: ( -2) (fffffffe) (37777777776) :xyz}
+do_test printf-1.11.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 0xfffffffe 0xfffffffe 0xfffffffe
+} {abc: (-2 ) (fffffffe) (37777777776) :xyz}
+do_test printf-1.11.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 0xfffffffe 0xfffffffe 0xfffffffe
+} {abc: ( -2) (fffffffe) (37777777776) :xyz}
+do_test printf-1.11.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 0xfffffffe 0xfffffffe 0xfffffffe
+} {abc: (-00002) (fffffffe) (37777777776) :xyz}
+do_test printf-1.11.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 0xfffffffe 0xfffffffe 0xfffffffe
+} {abc: ( -2) (fffffffe) (37777777776) :xyz}
+do_test printf-1.11.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 0xfffffffe 0xfffffffe 0xfffffffe
+} {abc: ( -2) (0xfffffffe) (037777777776) :xyz}
+# 0xfffffffb == -5
+do_test printf-1.12.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 0xfffffffb 0xfffffffb 0xfffffffb
+} {abc: -5 fffffffb 37777777773 :xyz}
+do_test printf-1.12.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 0xfffffffb 0xfffffffb 0xfffffffb
+} {abc: ( -5) (fffffffb) (37777777773) :xyz}
+do_test printf-1.12.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 0xfffffffb 0xfffffffb 0xfffffffb
+} {abc: (-5 ) (fffffffb) (37777777773) :xyz}
+do_test printf-1.12.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 0xfffffffb 0xfffffffb 0xfffffffb
+} {abc: ( -5) (fffffffb) (37777777773) :xyz}
+do_test printf-1.12.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 0xfffffffb 0xfffffffb 0xfffffffb
+} {abc: (-00005) (fffffffb) (37777777773) :xyz}
+do_test printf-1.12.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 0xfffffffb 0xfffffffb 0xfffffffb
+} {abc: ( -5) (fffffffb) (37777777773) :xyz}
+do_test printf-1.12.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 0xfffffffb 0xfffffffb 0xfffffffb
+} {abc: ( -5) (0xfffffffb) (037777777773) :xyz}
+# 0xfffffff6 == -10
+do_test printf-1.13.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 0xfffffff6 0xfffffff6 0xfffffff6
+} {abc: -10 fffffff6 37777777766 :xyz}
+do_test printf-1.13.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 0xfffffff6 0xfffffff6 0xfffffff6
+} {abc: ( -10) (fffffff6) (37777777766) :xyz}
+do_test printf-1.13.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 0xfffffff6 0xfffffff6 0xfffffff6
+} {abc: (-10 ) (fffffff6) (37777777766) :xyz}
+do_test printf-1.13.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 0xfffffff6 0xfffffff6 0xfffffff6
+} {abc: ( -10) (fffffff6) (37777777766) :xyz}
+do_test printf-1.13.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 0xfffffff6 0xfffffff6 0xfffffff6
+} {abc: (-00010) (fffffff6) (37777777766) :xyz}
+do_test printf-1.13.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 0xfffffff6 0xfffffff6 0xfffffff6
+} {abc: ( -10) (fffffff6) (37777777766) :xyz}
+do_test printf-1.13.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 0xfffffff6 0xfffffff6 0xfffffff6
+} {abc: ( -10) (0xfffffff6) (037777777766) :xyz}
+# 0xffffff9d == -99
+do_test printf-1.14.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 0xffffff9d 0xffffff9d 0xffffff9d
+} {abc: -99 ffffff9d 37777777635 :xyz}
+do_test printf-1.14.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 0xffffff9d 0xffffff9d 0xffffff9d
+} {abc: ( -99) (ffffff9d) (37777777635) :xyz}
+do_test printf-1.14.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 0xffffff9d 0xffffff9d 0xffffff9d
+} {abc: (-99 ) (ffffff9d) (37777777635) :xyz}
+do_test printf-1.14.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 0xffffff9d 0xffffff9d 0xffffff9d
+} {abc: ( -99) (ffffff9d) (37777777635) :xyz}
+do_test printf-1.14.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 0xffffff9d 0xffffff9d 0xffffff9d
+} {abc: (-00099) (ffffff9d) (37777777635) :xyz}
+do_test printf-1.14.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 0xffffff9d 0xffffff9d 0xffffff9d
+} {abc: ( -99) (ffffff9d) (37777777635) :xyz}
+do_test printf-1.14.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 0xffffff9d 0xffffff9d 0xffffff9d
+} {abc: ( -99) (0xffffff9d) (037777777635) :xyz}
+# 0xffffff9c == -100
+do_test printf-1.15.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 0xffffff9c 0xffffff9c 0xffffff9c
+} {abc: -100 ffffff9c 37777777634 :xyz}
+do_test printf-1.15.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 0xffffff9c 0xffffff9c 0xffffff9c
+} {abc: ( -100) (ffffff9c) (37777777634) :xyz}
+do_test printf-1.15.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 0xffffff9c 0xffffff9c 0xffffff9c
+} {abc: (-100 ) (ffffff9c) (37777777634) :xyz}
+do_test printf-1.15.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 0xffffff9c 0xffffff9c 0xffffff9c
+} {abc: ( -100) (ffffff9c) (37777777634) :xyz}
+do_test printf-1.15.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 0xffffff9c 0xffffff9c 0xffffff9c
+} {abc: (-00100) (ffffff9c) (37777777634) :xyz}
+do_test printf-1.15.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 0xffffff9c 0xffffff9c 0xffffff9c
+} {abc: ( -100) (ffffff9c) (37777777634) :xyz}
+do_test printf-1.15.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 0xffffff9c 0xffffff9c 0xffffff9c
+} {abc: ( -100) (0xffffff9c) (037777777634) :xyz}
+# 0xff676981 == -9999999
+do_test printf-1.16.1 {
+ sqlite3_mprintf_int {abc: %d %x %o :xyz}\
+ 0xff676981 0xff676981 0xff676981
+} {abc: -9999999 ff676981 37731664601 :xyz}
+do_test printf-1.16.2 {
+ sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\
+ 0xff676981 0xff676981 0xff676981
+} {abc: (-9999999) (ff676981) (37731664601) :xyz}
+do_test printf-1.16.3 {
+ sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\
+ 0xff676981 0xff676981 0xff676981
+} {abc: (-9999999) (ff676981) (37731664601) :xyz}
+do_test printf-1.16.4 {
+ sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\
+ 0xff676981 0xff676981 0xff676981
+} {abc: (-9999999) (ff676981) (37731664601) :xyz}
+do_test printf-1.16.5 {
+ sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\
+ 0xff676981 0xff676981 0xff676981
+} {abc: (-9999999) (ff676981) (37731664601) :xyz}
+do_test printf-1.16.6 {
+ sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\
+ 0xff676981 0xff676981 0xff676981
+} {abc: (-9999999) (ff676981) (37731664601) :xyz}
+do_test printf-1.16.7 {
+ sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
+ 0xff676981 0xff676981 0xff676981
+} {abc: (-9999999) (0xff676981) (037731664601) :xyz}
+do_test printf-2.1.1.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 0.001
+} {abc: (0.0) :xyz}
+do_test printf-2.1.1.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 0.001
+} {abc: (1.0e-03) :xyz}
+do_test printf-2.1.1.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 0.001
+} {abc: (0.001) :xyz}
+do_test printf-2.1.1.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 0.001
+} {abc: 1 1 (0.001) :xyz}
+do_test printf-2.1.1.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 0.001
+} {abc: 1 1 (0.00100000) :xyz}
+do_test printf-2.1.1.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 0.001
+} {abc: 1 1 (000000.001) :xyz}
+do_test printf-2.1.1.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 0.001
+} {abc: 1 1 (0.0) :xyz}
+do_test printf-2.1.1.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 0.001
+} {abc: 1 1 (1.0e-03) :xyz}
+do_test printf-2.1.1.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 0.001
+} {abc: 1 1 (0.001) :xyz}
+do_test printf-2.1.2.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 1.0e-20
+} {abc: (0.0) :xyz}
+do_test printf-2.1.2.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 1.0e-20
+} {abc: (1.0e-20) :xyz}
+do_test printf-2.1.2.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 1.0e-20
+} {abc: (1e-20) :xyz}
+do_test printf-2.1.2.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 1.0e-20
+} {abc: 1 1 (1e-20) :xyz}
+do_test printf-2.1.2.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 1.0e-20
+} {abc: 1 1 (1.00000e-20) :xyz}
+do_test printf-2.1.2.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 1.0e-20
+} {abc: 1 1 (000001e-20) :xyz}
+do_test printf-2.1.2.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 1.0e-20
+} {abc: 1 1 (0.0) :xyz}
+do_test printf-2.1.2.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 1.0e-20
+} {abc: 1 1 (1.0e-20) :xyz}
+do_test printf-2.1.2.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 1.0e-20
+} {abc: 1 1 (1e-20) :xyz}
+do_test printf-2.1.3.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 1.0
+} {abc: (1.0) :xyz}
+do_test printf-2.1.3.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 1.0
+} {abc: (1.0e+00) :xyz}
+do_test printf-2.1.3.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 1.0
+} {abc: (1) :xyz}
+do_test printf-2.1.3.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 1.0
+} {abc: 1 1 (1) :xyz}
+do_test printf-2.1.3.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 1.0
+} {abc: 1 1 (1.00000) :xyz}
+do_test printf-2.1.3.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 1.0
+} {abc: 1 1 (0000000001) :xyz}
+do_test printf-2.1.3.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 1.0
+} {abc: 1 1 (1.0) :xyz}
+do_test printf-2.1.3.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 1.0
+} {abc: 1 1 (1.0e+00) :xyz}
+do_test printf-2.1.3.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 1.0
+} {abc: 1 1 (1) :xyz}
+do_test printf-2.1.4.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 0.0
+} {abc: (0.0) :xyz}
+do_test printf-2.1.4.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 0.0
+} {abc: (0.0e+00) :xyz}
+do_test printf-2.1.4.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 0.0
+} {abc: (0) :xyz}
+do_test printf-2.1.4.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 0.0
+} {abc: 1 1 (0) :xyz}
+do_test printf-2.1.4.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 0.0
+} {abc: 1 1 (0.00000) :xyz}
+do_test printf-2.1.4.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 0.0
+} {abc: 1 1 (0000000000) :xyz}
+do_test printf-2.1.4.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 0.0
+} {abc: 1 1 (0.0) :xyz}
+do_test printf-2.1.4.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 0.0
+} {abc: 1 1 (0.0e+00) :xyz}
+do_test printf-2.1.4.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 0.0
+} {abc: 1 1 (0) :xyz}
+do_test printf-2.1.5.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 100.0
+} {abc: (100.0) :xyz}
+do_test printf-2.1.5.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 100.0
+} {abc: (1.0e+02) :xyz}
+do_test printf-2.1.5.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 100.0
+} {abc: (1e+02) :xyz}
+do_test printf-2.1.5.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 100.0
+} {abc: 1 1 (100) :xyz}
+do_test printf-2.1.5.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 100.0
+} {abc: 1 1 (100.000) :xyz}
+do_test printf-2.1.5.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 100.0
+} {abc: 1 1 (0000000100) :xyz}
+do_test printf-2.1.5.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 100.0
+} {abc: 1 1 (100.0) :xyz}
+do_test printf-2.1.5.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 100.0
+} {abc: 1 1 (1.0e+02) :xyz}
+do_test printf-2.1.5.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 100.0
+} {abc: 1 1 (1e+02) :xyz}
+do_test printf-2.1.6.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 9.99999
+} {abc: (10.0) :xyz}
+do_test printf-2.1.6.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 9.99999
+} {abc: (1.0e+01) :xyz}
+do_test printf-2.1.6.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 9.99999
+} {abc: (1e+01) :xyz}
+do_test printf-2.1.6.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 9.99999
+} {abc: 1 1 (9.99999) :xyz}
+do_test printf-2.1.6.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 9.99999
+} {abc: 1 1 (9.99999) :xyz}
+do_test printf-2.1.6.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 9.99999
+} {abc: 1 1 (0009.99999) :xyz}
+do_test printf-2.1.6.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 9.99999
+} {abc: 1 1 (10.0) :xyz}
+do_test printf-2.1.6.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 9.99999
+} {abc: 1 1 (1.0e+01) :xyz}
+do_test printf-2.1.6.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 9.99999
+} {abc: 1 1 (1e+01) :xyz}
+do_test printf-2.1.7.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 -0.00543
+} {abc: (-0.0) :xyz}
+do_test printf-2.1.7.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 -0.00543
+} {abc: (-5.4e-03) :xyz}
+do_test printf-2.1.7.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 -0.00543
+} {abc: (-0.005) :xyz}
+do_test printf-2.1.7.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 -0.00543
+} {abc: 1 1 (-0.00543) :xyz}
+do_test printf-2.1.7.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 -0.00543
+} {abc: 1 1 (-0.00543000) :xyz}
+do_test printf-2.1.7.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 -0.00543
+} {abc: 1 1 (-000.00543) :xyz}
+do_test printf-2.1.7.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 -0.00543
+} {abc: 1 1 (-0.0) :xyz}
+do_test printf-2.1.7.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 -0.00543
+} {abc: 1 1 (-5.4e-03) :xyz}
+do_test printf-2.1.7.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 -0.00543
+} {abc: 1 1 (-0.005) :xyz}
+do_test printf-2.1.8.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 -1.0
+} {abc: (-1.0) :xyz}
+do_test printf-2.1.8.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 -1.0
+} {abc: (-1.0e+00) :xyz}
+do_test printf-2.1.8.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 -1.0
+} {abc: (-1) :xyz}
+do_test printf-2.1.8.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 -1.0
+} {abc: 1 1 (-1) :xyz}
+do_test printf-2.1.8.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 -1.0
+} {abc: 1 1 (-1.00000) :xyz}
+do_test printf-2.1.8.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 -1.0
+} {abc: 1 1 (-000000001) :xyz}
+do_test printf-2.1.8.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 -1.0
+} {abc: 1 1 (-1.0) :xyz}
+do_test printf-2.1.8.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 -1.0
+} {abc: 1 1 (-1.0e+00) :xyz}
+do_test printf-2.1.8.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 -1.0
+} {abc: 1 1 (-1) :xyz}
+do_test printf-2.1.9.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 -99.99999
+} {abc: (-100.0) :xyz}
+do_test printf-2.1.9.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 -99.99999
+} {abc: (-1.0e+02) :xyz}
+do_test printf-2.1.9.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 -99.99999
+} {abc: (-1e+02) :xyz}
+do_test printf-2.1.9.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 -99.99999
+} {abc: 1 1 (-100) :xyz}
+do_test printf-2.1.9.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 -99.99999
+} {abc: 1 1 (-100.000) :xyz}
+do_test printf-2.1.9.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 -99.99999
+} {abc: 1 1 (-000000100) :xyz}
+do_test printf-2.1.9.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 -99.99999
+} {abc: 1 1 (-100.0) :xyz}
+do_test printf-2.1.9.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 -99.99999
+} {abc: 1 1 (-1.0e+02) :xyz}
+do_test printf-2.1.9.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 -99.99999
+} {abc: 1 1 (-1e+02) :xyz}
+do_test printf-2.1.10.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 3.14e+9
+} {abc: (3140000000.0) :xyz}
+do_test printf-2.1.10.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 3.14e+9
+} {abc: (3.1e+09) :xyz}
+do_test printf-2.1.10.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 3.14e+9
+} {abc: (3e+09) :xyz}
+do_test printf-2.1.10.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 3.14e+9
+} {abc: 1 1 (3.14e+09) :xyz}
+do_test printf-2.1.10.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 3.14e+9
+} {abc: 1 1 (3.14000e+09) :xyz}
+do_test printf-2.1.10.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 3.14e+9
+} {abc: 1 1 (003.14e+09) :xyz}
+do_test printf-2.1.10.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 3.14e+9
+} {abc: 1 1 (3140000000.0) :xyz}
+do_test printf-2.1.10.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 3.14e+9
+} {abc: 1 1 (3.1e+09) :xyz}
+do_test printf-2.1.10.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 3.14e+9
+} {abc: 1 1 (3e+09) :xyz}
+do_test printf-2.1.11.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 -4.72732e+88
+} {abc: (-4.7e+88) :xyz}
+do_test printf-2.1.11.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 -4.72732e+88
+} {abc: (-5e+88) :xyz}
+do_test printf-2.1.11.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 -4.72732e+88
+} {abc: 1 1 (-4.72732e+88) :xyz}
+do_test printf-2.1.11.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 -4.72732e+88
+} {abc: 1 1 (-4.72732e+88) :xyz}
+do_test printf-2.1.11.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 -4.72732e+88
+} {abc: 1 1 (-4.72732e+88) :xyz}
+do_test printf-2.1.11.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 -4.72732e+88
+} {abc: 1 1 (-4.7e+88) :xyz}
+do_test printf-2.1.11.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 -4.72732e+88
+} {abc: 1 1 (-5e+88) :xyz}
+do_test printf-2.1.12.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 9.87991e+143
+} {abc: (9.9e+143) :xyz}
+do_test printf-2.1.12.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 9.87991e+143
+} {abc: (1e+144) :xyz}
+do_test printf-2.1.12.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 9.87991e+143
+} {abc: 1 1 (9.87991e+143) :xyz}
+do_test printf-2.1.12.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 9.87991e+143
+} {abc: 1 1 (9.87991e+143) :xyz}
+do_test printf-2.1.12.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 9.87991e+143
+} {abc: 1 1 (9.87991e+143) :xyz}
+do_test printf-2.1.12.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 9.87991e+143
+} {abc: 1 1 (9.9e+143) :xyz}
+do_test printf-2.1.12.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 9.87991e+143
+} {abc: 1 1 (1e+144) :xyz}
+do_test printf-2.1.13.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 -6.287291e-9
+} {abc: (-0.0) :xyz}
+do_test printf-2.1.13.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 -6.287291e-9
+} {abc: (-6.3e-09) :xyz}
+do_test printf-2.1.13.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 -6.287291e-9
+} {abc: (-6e-09) :xyz}
+do_test printf-2.1.13.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 -6.287291e-9
+} {abc: 1 1 (-6.28729e-09) :xyz}
+do_test printf-2.1.13.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 -6.287291e-9
+} {abc: 1 1 (-6.28729e-09) :xyz}
+do_test printf-2.1.13.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 -6.287291e-9
+} {abc: 1 1 (-6.28729e-09) :xyz}
+do_test printf-2.1.13.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 -6.287291e-9
+} {abc: 1 1 (-0.0) :xyz}
+do_test printf-2.1.13.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 -6.287291e-9
+} {abc: 1 1 (-6.3e-09) :xyz}
+do_test printf-2.1.13.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 -6.287291e-9
+} {abc: 1 1 (-6e-09) :xyz}
+do_test printf-2.1.14.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 3.38826392e-110
+} {abc: (0.0) :xyz}
+do_test printf-2.1.14.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 3.38826392e-110
+} {abc: (3.4e-110) :xyz}
+do_test printf-2.1.14.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 3.38826392e-110
+} {abc: (3e-110) :xyz}
+do_test printf-2.1.14.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 3.38826392e-110
+} {abc: 1 1 (3.38826e-110) :xyz}
+do_test printf-2.1.14.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 3.38826392e-110
+} {abc: 1 1 (3.38826e-110) :xyz}
+do_test printf-2.1.14.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 3.38826392e-110
+} {abc: 1 1 (3.38826e-110) :xyz}
+do_test printf-2.1.14.7 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 3.38826392e-110
+} {abc: 1 1 (0.0) :xyz}
+do_test printf-2.1.14.8 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 3.38826392e-110
+} {abc: 1 1 (3.4e-110) :xyz}
+do_test printf-2.1.14.9 {
+ sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 3.38826392e-110
+} {abc: 1 1 (3e-110) :xyz}
+do_test printf-2.2.1.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 0.001
+} {abc: (0.00100) :xyz}
+do_test printf-2.2.1.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 0.001
+} {abc: (1.00000e-03) :xyz}
+do_test printf-2.2.1.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 0.001
+} {abc: (0.001) :xyz}
+do_test printf-2.2.1.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 0.001
+} {abc: 5 5 (0.001) :xyz}
+do_test printf-2.2.1.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 0.001
+} {abc: 5 5 (0.00100000) :xyz}
+do_test printf-2.2.1.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 0.001
+} {abc: 5 5 (000000.001) :xyz}
+do_test printf-2.2.1.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 0.001
+} {abc: 5 5 (0.00100) :xyz}
+do_test printf-2.2.1.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 0.001
+} {abc: 5 5 (1.00000e-03) :xyz}
+do_test printf-2.2.1.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 0.001
+} {abc: 5 5 (0.001) :xyz}
+do_test printf-2.2.2.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 1.0e-20
+} {abc: (0.00000) :xyz}
+do_test printf-2.2.2.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 1.0e-20
+} {abc: (1.00000e-20) :xyz}
+do_test printf-2.2.2.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 1.0e-20
+} {abc: (1e-20) :xyz}
+do_test printf-2.2.2.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 1.0e-20
+} {abc: 5 5 (1e-20) :xyz}
+do_test printf-2.2.2.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 1.0e-20
+} {abc: 5 5 (1.00000e-20) :xyz}
+do_test printf-2.2.2.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 1.0e-20
+} {abc: 5 5 (000001e-20) :xyz}
+do_test printf-2.2.2.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 1.0e-20
+} {abc: 5 5 (0.00000) :xyz}
+do_test printf-2.2.2.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 1.0e-20
+} {abc: 5 5 (1.00000e-20) :xyz}
+do_test printf-2.2.2.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 1.0e-20
+} {abc: 5 5 (1e-20) :xyz}
+do_test printf-2.2.3.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 1.0
+} {abc: (1.00000) :xyz}
+do_test printf-2.2.3.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 1.0
+} {abc: (1.00000e+00) :xyz}
+do_test printf-2.2.3.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 1.0
+} {abc: ( 1) :xyz}
+do_test printf-2.2.3.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 1.0
+} {abc: 5 5 (1) :xyz}
+do_test printf-2.2.3.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 1.0
+} {abc: 5 5 (1.00000) :xyz}
+do_test printf-2.2.3.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 1.0
+} {abc: 5 5 (0000000001) :xyz}
+do_test printf-2.2.3.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 1.0
+} {abc: 5 5 (1.00000) :xyz}
+do_test printf-2.2.3.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 1.0
+} {abc: 5 5 (1.00000e+00) :xyz}
+do_test printf-2.2.3.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 1.0
+} {abc: 5 5 ( 1) :xyz}
+do_test printf-2.2.4.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 0.0
+} {abc: (0.00000) :xyz}
+do_test printf-2.2.4.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 0.0
+} {abc: (0.00000e+00) :xyz}
+do_test printf-2.2.4.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 0.0
+} {abc: ( 0) :xyz}
+do_test printf-2.2.4.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 0.0
+} {abc: 5 5 (0) :xyz}
+do_test printf-2.2.4.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 0.0
+} {abc: 5 5 (0.00000) :xyz}
+do_test printf-2.2.4.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 0.0
+} {abc: 5 5 (0000000000) :xyz}
+do_test printf-2.2.4.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 0.0
+} {abc: 5 5 (0.00000) :xyz}
+do_test printf-2.2.4.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 0.0
+} {abc: 5 5 (0.00000e+00) :xyz}
+do_test printf-2.2.4.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 0.0
+} {abc: 5 5 ( 0) :xyz}
+do_test printf-2.2.5.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 100.0
+} {abc: (100.00000) :xyz}
+do_test printf-2.2.5.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 100.0
+} {abc: (1.00000e+02) :xyz}
+do_test printf-2.2.5.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 100.0
+} {abc: ( 100) :xyz}
+do_test printf-2.2.5.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 100.0
+} {abc: 5 5 (100) :xyz}
+do_test printf-2.2.5.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 100.0
+} {abc: 5 5 (100.000) :xyz}
+do_test printf-2.2.5.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 100.0
+} {abc: 5 5 (0000000100) :xyz}
+do_test printf-2.2.5.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 100.0
+} {abc: 5 5 (100.00000) :xyz}
+do_test printf-2.2.5.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 100.0
+} {abc: 5 5 (1.00000e+02) :xyz}
+do_test printf-2.2.5.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 100.0
+} {abc: 5 5 ( 100) :xyz}
+do_test printf-2.2.6.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 9.99999
+} {abc: (9.99999) :xyz}
+do_test printf-2.2.6.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 9.99999
+} {abc: (9.99999e+00) :xyz}
+do_test printf-2.2.6.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 9.99999
+} {abc: ( 10) :xyz}
+do_test printf-2.2.6.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 9.99999
+} {abc: 5 5 (9.99999) :xyz}
+do_test printf-2.2.6.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 9.99999
+} {abc: 5 5 (9.99999) :xyz}
+do_test printf-2.2.6.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 9.99999
+} {abc: 5 5 (0009.99999) :xyz}
+do_test printf-2.2.6.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 9.99999
+} {abc: 5 5 (9.99999) :xyz}
+do_test printf-2.2.6.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 9.99999
+} {abc: 5 5 (9.99999e+00) :xyz}
+do_test printf-2.2.6.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 9.99999
+} {abc: 5 5 ( 10) :xyz}
+do_test printf-2.2.7.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 -0.00543
+} {abc: (-0.00543) :xyz}
+do_test printf-2.2.7.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 -0.00543
+} {abc: (-5.43000e-03) :xyz}
+do_test printf-2.2.7.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 -0.00543
+} {abc: (-0.00543) :xyz}
+do_test printf-2.2.7.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 -0.00543
+} {abc: 5 5 (-0.00543) :xyz}
+do_test printf-2.2.7.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 -0.00543
+} {abc: 5 5 (-0.00543000) :xyz}
+do_test printf-2.2.7.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 -0.00543
+} {abc: 5 5 (-000.00543) :xyz}
+do_test printf-2.2.7.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 -0.00543
+} {abc: 5 5 (-0.00543) :xyz}
+do_test printf-2.2.7.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 -0.00543
+} {abc: 5 5 (-5.43000e-03) :xyz}
+do_test printf-2.2.7.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 -0.00543
+} {abc: 5 5 (-0.00543) :xyz}
+do_test printf-2.2.8.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 -1.0
+} {abc: (-1.00000) :xyz}
+do_test printf-2.2.8.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 -1.0
+} {abc: (-1.00000e+00) :xyz}
+do_test printf-2.2.8.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 -1.0
+} {abc: ( -1) :xyz}
+do_test printf-2.2.8.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 -1.0
+} {abc: 5 5 (-1) :xyz}
+do_test printf-2.2.8.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 -1.0
+} {abc: 5 5 (-1.00000) :xyz}
+do_test printf-2.2.8.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 -1.0
+} {abc: 5 5 (-000000001) :xyz}
+do_test printf-2.2.8.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 -1.0
+} {abc: 5 5 (-1.00000) :xyz}
+do_test printf-2.2.8.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 -1.0
+} {abc: 5 5 (-1.00000e+00) :xyz}
+do_test printf-2.2.8.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 -1.0
+} {abc: 5 5 ( -1) :xyz}
+do_test printf-2.2.9.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 -99.99999
+} {abc: (-99.99999) :xyz}
+do_test printf-2.2.9.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 -99.99999
+} {abc: (-1.00000e+02) :xyz}
+do_test printf-2.2.9.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 -99.99999
+} {abc: ( -100) :xyz}
+do_test printf-2.2.9.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 -99.99999
+} {abc: 5 5 (-100) :xyz}
+do_test printf-2.2.9.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 -99.99999
+} {abc: 5 5 (-100.000) :xyz}
+do_test printf-2.2.9.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 -99.99999
+} {abc: 5 5 (-000000100) :xyz}
+do_test printf-2.2.9.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 -99.99999
+} {abc: 5 5 (-99.99999) :xyz}
+do_test printf-2.2.9.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 -99.99999
+} {abc: 5 5 (-1.00000e+02) :xyz}
+do_test printf-2.2.9.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 -99.99999
+} {abc: 5 5 ( -100) :xyz}
+do_test printf-2.2.10.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 3.14e+9
+} {abc: (3140000000.00000) :xyz}
+do_test printf-2.2.10.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 3.14e+9
+} {abc: (3.14000e+09) :xyz}
+do_test printf-2.2.10.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 3.14e+9
+} {abc: (3.14e+09) :xyz}
+do_test printf-2.2.10.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 3.14e+9
+} {abc: 5 5 (3.14e+09) :xyz}
+do_test printf-2.2.10.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 3.14e+9
+} {abc: 5 5 (3.14000e+09) :xyz}
+do_test printf-2.2.10.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 3.14e+9
+} {abc: 5 5 (003.14e+09) :xyz}
+do_test printf-2.2.10.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 3.14e+9
+} {abc: 5 5 (3140000000.00000) :xyz}
+do_test printf-2.2.10.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 3.14e+9
+} {abc: 5 5 (3.14000e+09) :xyz}
+do_test printf-2.2.10.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 3.14e+9
+} {abc: 5 5 (3.14e+09) :xyz}
+do_test printf-2.2.11.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 -4.72732e+88
+} {abc: (-4.72732e+88) :xyz}
+do_test printf-2.2.11.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 -4.72732e+88
+} {abc: (-4.7273e+88) :xyz}
+do_test printf-2.2.11.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 -4.72732e+88
+} {abc: 5 5 (-4.72732e+88) :xyz}
+do_test printf-2.2.11.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 -4.72732e+88
+} {abc: 5 5 (-4.72732e+88) :xyz}
+do_test printf-2.2.11.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 -4.72732e+88
+} {abc: 5 5 (-4.72732e+88) :xyz}
+do_test printf-2.2.11.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 -4.72732e+88
+} {abc: 5 5 (-4.72732e+88) :xyz}
+do_test printf-2.2.11.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 -4.72732e+88
+} {abc: 5 5 (-4.7273e+88) :xyz}
+do_test printf-2.2.12.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 9.87991e+143
+} {abc: (9.87991e+143) :xyz}
+do_test printf-2.2.12.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 9.87991e+143
+} {abc: (9.8799e+143) :xyz}
+do_test printf-2.2.12.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 9.87991e+143
+} {abc: 5 5 (9.87991e+143) :xyz}
+do_test printf-2.2.12.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 9.87991e+143
+} {abc: 5 5 (9.87991e+143) :xyz}
+do_test printf-2.2.12.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 9.87991e+143
+} {abc: 5 5 (9.87991e+143) :xyz}
+do_test printf-2.2.12.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 9.87991e+143
+} {abc: 5 5 (9.87991e+143) :xyz}
+do_test printf-2.2.12.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 9.87991e+143
+} {abc: 5 5 (9.8799e+143) :xyz}
+do_test printf-2.2.13.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 -6.287291e-9
+} {abc: (-0.00000) :xyz}
+do_test printf-2.2.13.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 -6.287291e-9
+} {abc: (-6.28729e-09) :xyz}
+do_test printf-2.2.13.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 -6.287291e-9
+} {abc: (-6.2873e-09) :xyz}
+do_test printf-2.2.13.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 -6.287291e-9
+} {abc: 5 5 (-6.28729e-09) :xyz}
+do_test printf-2.2.13.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 -6.287291e-9
+} {abc: 5 5 (-6.28729e-09) :xyz}
+do_test printf-2.2.13.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 -6.287291e-9
+} {abc: 5 5 (-6.28729e-09) :xyz}
+do_test printf-2.2.13.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 -6.287291e-9
+} {abc: 5 5 (-0.00000) :xyz}
+do_test printf-2.2.13.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 -6.287291e-9
+} {abc: 5 5 (-6.28729e-09) :xyz}
+do_test printf-2.2.13.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 -6.287291e-9
+} {abc: 5 5 (-6.2873e-09) :xyz}
+do_test printf-2.2.14.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 3.38826392e-110
+} {abc: (0.00000) :xyz}
+do_test printf-2.2.14.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 3.38826392e-110
+} {abc: (3.38826e-110) :xyz}
+do_test printf-2.2.14.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 3.38826392e-110
+} {abc: (3.3883e-110) :xyz}
+do_test printf-2.2.14.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 3.38826392e-110
+} {abc: 5 5 (3.38826e-110) :xyz}
+do_test printf-2.2.14.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 3.38826392e-110
+} {abc: 5 5 (3.38826e-110) :xyz}
+do_test printf-2.2.14.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 3.38826392e-110
+} {abc: 5 5 (3.38826e-110) :xyz}
+do_test printf-2.2.14.7 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 3.38826392e-110
+} {abc: 5 5 (0.00000) :xyz}
+do_test printf-2.2.14.8 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 3.38826392e-110
+} {abc: 5 5 (3.38826e-110) :xyz}
+do_test printf-2.2.14.9 {
+ sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 3.38826392e-110
+} {abc: 5 5 (3.3883e-110) :xyz}
+do_test printf-2.3.1.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 0.001
+} {abc: (0.0010000000) :xyz}
+do_test printf-2.3.1.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 0.001
+} {abc: (1.0000000000e-03) :xyz}
+do_test printf-2.3.1.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 0.001
+} {abc: ( 0.001) :xyz}
+do_test printf-2.3.1.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 0.001
+} {abc: 10 10 (0.001) :xyz}
+do_test printf-2.3.1.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 0.001
+} {abc: 10 10 (0.00100000) :xyz}
+do_test printf-2.3.1.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 0.001
+} {abc: 10 10 (000000.001) :xyz}
+do_test printf-2.3.1.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 0.001
+} {abc: 10 10 (0.0010000000) :xyz}
+do_test printf-2.3.1.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 0.001
+} {abc: 10 10 (1.0000000000e-03) :xyz}
+do_test printf-2.3.1.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 0.001
+} {abc: 10 10 ( 0.001) :xyz}
+do_test printf-2.3.2.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 1.0e-20
+} {abc: (0.0000000000) :xyz}
+do_test printf-2.3.2.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 1.0e-20
+} {abc: (1.0000000000e-20) :xyz}
+do_test printf-2.3.2.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 1.0e-20
+} {abc: ( 1e-20) :xyz}
+do_test printf-2.3.2.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 1.0e-20
+} {abc: 10 10 (1e-20) :xyz}
+do_test printf-2.3.2.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 1.0e-20
+} {abc: 10 10 (1.00000e-20) :xyz}
+do_test printf-2.3.2.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 1.0e-20
+} {abc: 10 10 (000001e-20) :xyz}
+do_test printf-2.3.2.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 1.0e-20
+} {abc: 10 10 (0.0000000000) :xyz}
+do_test printf-2.3.2.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 1.0e-20
+} {abc: 10 10 (1.0000000000e-20) :xyz}
+do_test printf-2.3.2.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 1.0e-20
+} {abc: 10 10 ( 1e-20) :xyz}
+do_test printf-2.3.3.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 1.0
+} {abc: (1.0000000000) :xyz}
+do_test printf-2.3.3.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 1.0
+} {abc: (1.0000000000e+00) :xyz}
+do_test printf-2.3.3.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 1.0
+} {abc: ( 1) :xyz}
+do_test printf-2.3.3.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 1.0
+} {abc: 10 10 (1) :xyz}
+do_test printf-2.3.3.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 1.0
+} {abc: 10 10 (1.00000) :xyz}
+do_test printf-2.3.3.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 1.0
+} {abc: 10 10 (0000000001) :xyz}
+do_test printf-2.3.3.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 1.0
+} {abc: 10 10 (1.0000000000) :xyz}
+do_test printf-2.3.3.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 1.0
+} {abc: 10 10 (1.0000000000e+00) :xyz}
+do_test printf-2.3.3.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 1.0
+} {abc: 10 10 ( 1) :xyz}
+do_test printf-2.3.4.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 0.0
+} {abc: (0.0000000000) :xyz}
+do_test printf-2.3.4.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 0.0
+} {abc: (0.0000000000e+00) :xyz}
+do_test printf-2.3.4.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 0.0
+} {abc: ( 0) :xyz}
+do_test printf-2.3.4.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 0.0
+} {abc: 10 10 (0) :xyz}
+do_test printf-2.3.4.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 0.0
+} {abc: 10 10 (0.00000) :xyz}
+do_test printf-2.3.4.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 0.0
+} {abc: 10 10 (0000000000) :xyz}
+do_test printf-2.3.4.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 0.0
+} {abc: 10 10 (0.0000000000) :xyz}
+do_test printf-2.3.4.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 0.0
+} {abc: 10 10 (0.0000000000e+00) :xyz}
+do_test printf-2.3.4.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 0.0
+} {abc: 10 10 ( 0) :xyz}
+do_test printf-2.3.5.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 100.0
+} {abc: (100.0000000000) :xyz}
+do_test printf-2.3.5.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 100.0
+} {abc: (1.0000000000e+02) :xyz}
+do_test printf-2.3.5.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 100.0
+} {abc: ( 100) :xyz}
+do_test printf-2.3.5.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 100.0
+} {abc: 10 10 (100) :xyz}
+do_test printf-2.3.5.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 100.0
+} {abc: 10 10 (100.000) :xyz}
+do_test printf-2.3.5.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 100.0
+} {abc: 10 10 (0000000100) :xyz}
+do_test printf-2.3.5.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 100.0
+} {abc: 10 10 (100.0000000000) :xyz}
+do_test printf-2.3.5.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 100.0
+} {abc: 10 10 (1.0000000000e+02) :xyz}
+do_test printf-2.3.5.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 100.0
+} {abc: 10 10 ( 100) :xyz}
+do_test printf-2.3.6.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 9.99999
+} {abc: (9.9999900000) :xyz}
+do_test printf-2.3.6.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 9.99999
+} {abc: (9.9999900000e+00) :xyz}
+do_test printf-2.3.6.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 9.99999
+} {abc: ( 9.99999) :xyz}
+do_test printf-2.3.6.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 9.99999
+} {abc: 10 10 (9.99999) :xyz}
+do_test printf-2.3.6.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 9.99999
+} {abc: 10 10 (9.99999) :xyz}
+do_test printf-2.3.6.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 9.99999
+} {abc: 10 10 (0009.99999) :xyz}
+do_test printf-2.3.6.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 9.99999
+} {abc: 10 10 (9.9999900000) :xyz}
+do_test printf-2.3.6.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 9.99999
+} {abc: 10 10 (9.9999900000e+00) :xyz}
+do_test printf-2.3.6.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 9.99999
+} {abc: 10 10 ( 9.99999) :xyz}
+do_test printf-2.3.7.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 -0.00543
+} {abc: (-0.0054300000) :xyz}
+do_test printf-2.3.7.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 -0.00543
+} {abc: (-5.4300000000e-03) :xyz}
+do_test printf-2.3.7.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 -0.00543
+} {abc: ( -0.00543) :xyz}
+do_test printf-2.3.7.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 -0.00543
+} {abc: 10 10 (-0.00543) :xyz}
+do_test printf-2.3.7.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 -0.00543
+} {abc: 10 10 (-0.00543000) :xyz}
+do_test printf-2.3.7.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 -0.00543
+} {abc: 10 10 (-000.00543) :xyz}
+do_test printf-2.3.7.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 -0.00543
+} {abc: 10 10 (-0.0054300000) :xyz}
+do_test printf-2.3.7.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 -0.00543
+} {abc: 10 10 (-5.4300000000e-03) :xyz}
+do_test printf-2.3.7.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 -0.00543
+} {abc: 10 10 ( -0.00543) :xyz}
+do_test printf-2.3.8.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 -1.0
+} {abc: (-1.0000000000) :xyz}
+do_test printf-2.3.8.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 -1.0
+} {abc: (-1.0000000000e+00) :xyz}
+do_test printf-2.3.8.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 -1.0
+} {abc: ( -1) :xyz}
+do_test printf-2.3.8.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 -1.0
+} {abc: 10 10 (-1) :xyz}
+do_test printf-2.3.8.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 -1.0
+} {abc: 10 10 (-1.00000) :xyz}
+do_test printf-2.3.8.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 -1.0
+} {abc: 10 10 (-000000001) :xyz}
+do_test printf-2.3.8.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 -1.0
+} {abc: 10 10 (-1.0000000000) :xyz}
+do_test printf-2.3.8.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 -1.0
+} {abc: 10 10 (-1.0000000000e+00) :xyz}
+do_test printf-2.3.8.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 -1.0
+} {abc: 10 10 ( -1) :xyz}
+do_test printf-2.3.9.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 -99.99999
+} {abc: (-99.9999900000) :xyz}
+do_test printf-2.3.9.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 -99.99999
+} {abc: (-9.9999990000e+01) :xyz}
+do_test printf-2.3.9.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 -99.99999
+} {abc: ( -99.99999) :xyz}
+do_test printf-2.3.9.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 -99.99999
+} {abc: 10 10 (-100) :xyz}
+do_test printf-2.3.9.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 -99.99999
+} {abc: 10 10 (-100.000) :xyz}
+do_test printf-2.3.9.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 -99.99999
+} {abc: 10 10 (-000000100) :xyz}
+do_test printf-2.3.9.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 -99.99999
+} {abc: 10 10 (-99.9999900000) :xyz}
+do_test printf-2.3.9.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 -99.99999
+} {abc: 10 10 (-9.9999990000e+01) :xyz}
+do_test printf-2.3.9.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 -99.99999
+} {abc: 10 10 ( -99.99999) :xyz}
+do_test printf-2.3.10.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 3.14e+9
+} {abc: (3140000000.0000000000) :xyz}
+do_test printf-2.3.10.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 3.14e+9
+} {abc: (3.1400000000e+09) :xyz}
+do_test printf-2.3.10.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 3.14e+9
+} {abc: (3140000000) :xyz}
+do_test printf-2.3.10.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 3.14e+9
+} {abc: 10 10 (3.14e+09) :xyz}
+do_test printf-2.3.10.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 3.14e+9
+} {abc: 10 10 (3.14000e+09) :xyz}
+do_test printf-2.3.10.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 3.14e+9
+} {abc: 10 10 (003.14e+09) :xyz}
+do_test printf-2.3.10.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 3.14e+9
+} {abc: 10 10 (3140000000.0000000000) :xyz}
+do_test printf-2.3.10.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 3.14e+9
+} {abc: 10 10 (3.1400000000e+09) :xyz}
+do_test printf-2.3.10.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 3.14e+9
+} {abc: 10 10 (3140000000) :xyz}
+do_test printf-2.3.11.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 -4.72732e+88
+} {abc: (-4.7273200000e+88) :xyz}
+do_test printf-2.3.11.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 -4.72732e+88
+} {abc: (-4.72732e+88) :xyz}
+do_test printf-2.3.11.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 -4.72732e+88
+} {abc: 10 10 (-4.72732e+88) :xyz}
+do_test printf-2.3.11.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 -4.72732e+88
+} {abc: 10 10 (-4.72732e+88) :xyz}
+do_test printf-2.3.11.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 -4.72732e+88
+} {abc: 10 10 (-4.72732e+88) :xyz}
+do_test printf-2.3.11.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 -4.72732e+88
+} {abc: 10 10 (-4.7273200000e+88) :xyz}
+do_test printf-2.3.11.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 -4.72732e+88
+} {abc: 10 10 (-4.72732e+88) :xyz}
+do_test printf-2.3.12.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 9.87991e+143
+} {abc: (9.8799100000e+143) :xyz}
+do_test printf-2.3.12.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 9.87991e+143
+} {abc: (9.87991e+143) :xyz}
+do_test printf-2.3.12.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 9.87991e+143
+} {abc: 10 10 (9.87991e+143) :xyz}
+do_test printf-2.3.12.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 9.87991e+143
+} {abc: 10 10 (9.87991e+143) :xyz}
+do_test printf-2.3.12.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 9.87991e+143
+} {abc: 10 10 (9.87991e+143) :xyz}
+do_test printf-2.3.12.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 9.87991e+143
+} {abc: 10 10 (9.8799100000e+143) :xyz}
+do_test printf-2.3.12.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 9.87991e+143
+} {abc: 10 10 (9.87991e+143) :xyz}
+do_test printf-2.3.13.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 -6.287291e-9
+} {abc: (-0.0000000063) :xyz}
+do_test printf-2.3.13.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 -6.287291e-9
+} {abc: (-6.2872910000e-09) :xyz}
+do_test printf-2.3.13.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 -6.287291e-9
+} {abc: (-6.287291e-09) :xyz}
+do_test printf-2.3.13.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 -6.287291e-9
+} {abc: 10 10 (-6.28729e-09) :xyz}
+do_test printf-2.3.13.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 -6.287291e-9
+} {abc: 10 10 (-6.28729e-09) :xyz}
+do_test printf-2.3.13.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 -6.287291e-9
+} {abc: 10 10 (-6.28729e-09) :xyz}
+do_test printf-2.3.13.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 -6.287291e-9
+} {abc: 10 10 (-0.0000000063) :xyz}
+do_test printf-2.3.13.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 -6.287291e-9
+} {abc: 10 10 (-6.2872910000e-09) :xyz}
+do_test printf-2.3.13.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 -6.287291e-9
+} {abc: 10 10 (-6.287291e-09) :xyz}
+do_test printf-2.3.14.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 3.38826392e-110
+} {abc: (0.0000000000) :xyz}
+do_test printf-2.3.14.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 3.38826392e-110
+} {abc: (3.3882639200e-110) :xyz}
+do_test printf-2.3.14.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 3.38826392e-110
+} {abc: (3.38826392e-110) :xyz}
+do_test printf-2.3.14.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 3.38826392e-110
+} {abc: 10 10 (3.38826e-110) :xyz}
+do_test printf-2.3.14.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 3.38826392e-110
+} {abc: 10 10 (3.38826e-110) :xyz}
+do_test printf-2.3.14.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 3.38826392e-110
+} {abc: 10 10 (3.38826e-110) :xyz}
+do_test printf-2.3.14.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 3.38826392e-110
+} {abc: 10 10 (0.0000000000) :xyz}
+do_test printf-2.3.14.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 3.38826392e-110
+} {abc: 10 10 (3.3882639200e-110) :xyz}
+do_test printf-2.3.14.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 3.38826392e-110
+} {abc: 10 10 (3.38826392e-110) :xyz}
+do_test printf-2.4.1.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 0.001
+} {abc: ( 0.00100) :xyz}
+do_test printf-2.4.1.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 0.001
+} {abc: (1.00000e-03) :xyz}
+do_test printf-2.4.1.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 0.001
+} {abc: ( 0.001) :xyz}
+do_test printf-2.4.1.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 0.001
+} {abc: 10 5 (0.001) :xyz}
+do_test printf-2.4.1.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 0.001
+} {abc: 10 5 (0.00100000) :xyz}
+do_test printf-2.4.1.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 0.001
+} {abc: 10 5 (000000.001) :xyz}
+do_test printf-2.4.1.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 0.001
+} {abc: 10 5 ( 0.00100) :xyz}
+do_test printf-2.4.1.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 0.001
+} {abc: 10 5 (1.00000e-03) :xyz}
+do_test printf-2.4.1.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 0.001
+} {abc: 10 5 ( 0.001) :xyz}
+do_test printf-2.4.2.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 1.0e-20
+} {abc: ( 0.00000) :xyz}
+do_test printf-2.4.2.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 1.0e-20
+} {abc: (1.00000e-20) :xyz}
+do_test printf-2.4.2.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 1.0e-20
+} {abc: ( 1e-20) :xyz}
+do_test printf-2.4.2.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 1.0e-20
+} {abc: 10 5 (1e-20) :xyz}
+do_test printf-2.4.2.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 1.0e-20
+} {abc: 10 5 (1.00000e-20) :xyz}
+do_test printf-2.4.2.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 1.0e-20
+} {abc: 10 5 (000001e-20) :xyz}
+do_test printf-2.4.2.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 1.0e-20
+} {abc: 10 5 ( 0.00000) :xyz}
+do_test printf-2.4.2.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 1.0e-20
+} {abc: 10 5 (1.00000e-20) :xyz}
+do_test printf-2.4.2.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 1.0e-20
+} {abc: 10 5 ( 1e-20) :xyz}
+do_test printf-2.4.3.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 1.0
+} {abc: ( 1.00000) :xyz}
+do_test printf-2.4.3.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 1.0
+} {abc: (1.00000e+00) :xyz}
+do_test printf-2.4.3.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 1.0
+} {abc: ( 1) :xyz}
+do_test printf-2.4.3.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 1.0
+} {abc: 10 5 (1) :xyz}
+do_test printf-2.4.3.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 1.0
+} {abc: 10 5 (1.00000) :xyz}
+do_test printf-2.4.3.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 1.0
+} {abc: 10 5 (0000000001) :xyz}
+do_test printf-2.4.3.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 1.0
+} {abc: 10 5 ( 1.00000) :xyz}
+do_test printf-2.4.3.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 1.0
+} {abc: 10 5 (1.00000e+00) :xyz}
+do_test printf-2.4.3.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 1.0
+} {abc: 10 5 ( 1) :xyz}
+do_test printf-2.4.4.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 0.0
+} {abc: ( 0.00000) :xyz}
+do_test printf-2.4.4.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 0.0
+} {abc: (0.00000e+00) :xyz}
+do_test printf-2.4.4.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 0.0
+} {abc: ( 0) :xyz}
+do_test printf-2.4.4.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 0.0
+} {abc: 10 5 (0) :xyz}
+do_test printf-2.4.4.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 0.0
+} {abc: 10 5 (0.00000) :xyz}
+do_test printf-2.4.4.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 0.0
+} {abc: 10 5 (0000000000) :xyz}
+do_test printf-2.4.4.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 0.0
+} {abc: 10 5 ( 0.00000) :xyz}
+do_test printf-2.4.4.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 0.0
+} {abc: 10 5 (0.00000e+00) :xyz}
+do_test printf-2.4.4.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 0.0
+} {abc: 10 5 ( 0) :xyz}
+do_test printf-2.4.5.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 100.0
+} {abc: ( 100.00000) :xyz}
+do_test printf-2.4.5.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 100.0
+} {abc: (1.00000e+02) :xyz}
+do_test printf-2.4.5.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 100.0
+} {abc: ( 100) :xyz}
+do_test printf-2.4.5.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 100.0
+} {abc: 10 5 (100) :xyz}
+do_test printf-2.4.5.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 100.0
+} {abc: 10 5 (100.000) :xyz}
+do_test printf-2.4.5.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 100.0
+} {abc: 10 5 (0000000100) :xyz}
+do_test printf-2.4.5.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 100.0
+} {abc: 10 5 ( 100.00000) :xyz}
+do_test printf-2.4.5.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 100.0
+} {abc: 10 5 (1.00000e+02) :xyz}
+do_test printf-2.4.5.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 100.0
+} {abc: 10 5 ( 100) :xyz}
+do_test printf-2.4.6.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 9.99999
+} {abc: ( 9.99999) :xyz}
+do_test printf-2.4.6.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 9.99999
+} {abc: (9.99999e+00) :xyz}
+do_test printf-2.4.6.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 9.99999
+} {abc: ( 10) :xyz}
+do_test printf-2.4.6.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 9.99999
+} {abc: 10 5 (9.99999) :xyz}
+do_test printf-2.4.6.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 9.99999
+} {abc: 10 5 (9.99999) :xyz}
+do_test printf-2.4.6.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 9.99999
+} {abc: 10 5 (0009.99999) :xyz}
+do_test printf-2.4.6.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 9.99999
+} {abc: 10 5 ( 9.99999) :xyz}
+do_test printf-2.4.6.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 9.99999
+} {abc: 10 5 (9.99999e+00) :xyz}
+do_test printf-2.4.6.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 9.99999
+} {abc: 10 5 ( 10) :xyz}
+do_test printf-2.4.7.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 -0.00543
+} {abc: ( -0.00543) :xyz}
+do_test printf-2.4.7.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 -0.00543
+} {abc: (-5.43000e-03) :xyz}
+do_test printf-2.4.7.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 -0.00543
+} {abc: ( -0.00543) :xyz}
+do_test printf-2.4.7.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 -0.00543
+} {abc: 10 5 (-0.00543) :xyz}
+do_test printf-2.4.7.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 -0.00543
+} {abc: 10 5 (-0.00543000) :xyz}
+do_test printf-2.4.7.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 -0.00543
+} {abc: 10 5 (-000.00543) :xyz}
+do_test printf-2.4.7.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 -0.00543
+} {abc: 10 5 ( -0.00543) :xyz}
+do_test printf-2.4.7.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 -0.00543
+} {abc: 10 5 (-5.43000e-03) :xyz}
+do_test printf-2.4.7.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 -0.00543
+} {abc: 10 5 ( -0.00543) :xyz}
+do_test printf-2.4.8.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 -1.0
+} {abc: ( -1.00000) :xyz}
+do_test printf-2.4.8.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 -1.0
+} {abc: (-1.00000e+00) :xyz}
+do_test printf-2.4.8.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 -1.0
+} {abc: ( -1) :xyz}
+do_test printf-2.4.8.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 -1.0
+} {abc: 10 5 (-1) :xyz}
+do_test printf-2.4.8.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 -1.0
+} {abc: 10 5 (-1.00000) :xyz}
+do_test printf-2.4.8.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 -1.0
+} {abc: 10 5 (-000000001) :xyz}
+do_test printf-2.4.8.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 -1.0
+} {abc: 10 5 ( -1.00000) :xyz}
+do_test printf-2.4.8.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 -1.0
+} {abc: 10 5 (-1.00000e+00) :xyz}
+do_test printf-2.4.8.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 -1.0
+} {abc: 10 5 ( -1) :xyz}
+do_test printf-2.4.9.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 -99.99999
+} {abc: ( -99.99999) :xyz}
+do_test printf-2.4.9.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 -99.99999
+} {abc: (-1.00000e+02) :xyz}
+do_test printf-2.4.9.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 -99.99999
+} {abc: ( -100) :xyz}
+do_test printf-2.4.9.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 -99.99999
+} {abc: 10 5 (-100) :xyz}
+do_test printf-2.4.9.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 -99.99999
+} {abc: 10 5 (-100.000) :xyz}
+do_test printf-2.4.9.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 -99.99999
+} {abc: 10 5 (-000000100) :xyz}
+do_test printf-2.4.9.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 -99.99999
+} {abc: 10 5 ( -99.99999) :xyz}
+do_test printf-2.4.9.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 -99.99999
+} {abc: 10 5 (-1.00000e+02) :xyz}
+do_test printf-2.4.9.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 -99.99999
+} {abc: 10 5 ( -100) :xyz}
+do_test printf-2.4.10.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 3.14e+9
+} {abc: (3140000000.00000) :xyz}
+do_test printf-2.4.10.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 3.14e+9
+} {abc: (3.14000e+09) :xyz}
+do_test printf-2.4.10.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 3.14e+9
+} {abc: ( 3.14e+09) :xyz}
+do_test printf-2.4.10.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 3.14e+9
+} {abc: 10 5 (3.14e+09) :xyz}
+do_test printf-2.4.10.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 3.14e+9
+} {abc: 10 5 (3.14000e+09) :xyz}
+do_test printf-2.4.10.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 3.14e+9
+} {abc: 10 5 (003.14e+09) :xyz}
+do_test printf-2.4.10.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 3.14e+9
+} {abc: 10 5 (3140000000.00000) :xyz}
+do_test printf-2.4.10.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 3.14e+9
+} {abc: 10 5 (3.14000e+09) :xyz}
+do_test printf-2.4.10.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 3.14e+9
+} {abc: 10 5 ( 3.14e+09) :xyz}
+do_test printf-2.4.11.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 -4.72732e+88
+} {abc: (-4.72732e+88) :xyz}
+do_test printf-2.4.11.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 -4.72732e+88
+} {abc: (-4.7273e+88) :xyz}
+do_test printf-2.4.11.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 -4.72732e+88
+} {abc: 10 5 (-4.72732e+88) :xyz}
+do_test printf-2.4.11.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 -4.72732e+88
+} {abc: 10 5 (-4.72732e+88) :xyz}
+do_test printf-2.4.11.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 -4.72732e+88
+} {abc: 10 5 (-4.72732e+88) :xyz}
+do_test printf-2.4.11.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 -4.72732e+88
+} {abc: 10 5 (-4.72732e+88) :xyz}
+do_test printf-2.4.11.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 -4.72732e+88
+} {abc: 10 5 (-4.7273e+88) :xyz}
+do_test printf-2.4.12.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 9.87991e+143
+} {abc: (9.87991e+143) :xyz}
+do_test printf-2.4.12.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 9.87991e+143
+} {abc: (9.8799e+143) :xyz}
+do_test printf-2.4.12.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 9.87991e+143
+} {abc: 10 5 (9.87991e+143) :xyz}
+do_test printf-2.4.12.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 9.87991e+143
+} {abc: 10 5 (9.87991e+143) :xyz}
+do_test printf-2.4.12.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 9.87991e+143
+} {abc: 10 5 (9.87991e+143) :xyz}
+do_test printf-2.4.12.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 9.87991e+143
+} {abc: 10 5 (9.87991e+143) :xyz}
+do_test printf-2.4.12.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 9.87991e+143
+} {abc: 10 5 (9.8799e+143) :xyz}
+do_test printf-2.4.13.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 -6.287291e-9
+} {abc: ( -0.00000) :xyz}
+do_test printf-2.4.13.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 -6.287291e-9
+} {abc: (-6.28729e-09) :xyz}
+do_test printf-2.4.13.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 -6.287291e-9
+} {abc: (-6.2873e-09) :xyz}
+do_test printf-2.4.13.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 -6.287291e-9
+} {abc: 10 5 (-6.28729e-09) :xyz}
+do_test printf-2.4.13.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 -6.287291e-9
+} {abc: 10 5 (-6.28729e-09) :xyz}
+do_test printf-2.4.13.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 -6.287291e-9
+} {abc: 10 5 (-6.28729e-09) :xyz}
+do_test printf-2.4.13.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 -6.287291e-9
+} {abc: 10 5 ( -0.00000) :xyz}
+do_test printf-2.4.13.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 -6.287291e-9
+} {abc: 10 5 (-6.28729e-09) :xyz}
+do_test printf-2.4.13.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 -6.287291e-9
+} {abc: 10 5 (-6.2873e-09) :xyz}
+do_test printf-2.4.14.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 3.38826392e-110
+} {abc: ( 0.00000) :xyz}
+do_test printf-2.4.14.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 3.38826392e-110
+} {abc: (3.38826e-110) :xyz}
+do_test printf-2.4.14.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 3.38826392e-110
+} {abc: (3.3883e-110) :xyz}
+do_test printf-2.4.14.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 3.38826392e-110
+} {abc: 10 5 (3.38826e-110) :xyz}
+do_test printf-2.4.14.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 3.38826392e-110
+} {abc: 10 5 (3.38826e-110) :xyz}
+do_test printf-2.4.14.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 3.38826392e-110
+} {abc: 10 5 (3.38826e-110) :xyz}
+do_test printf-2.4.14.7 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 3.38826392e-110
+} {abc: 10 5 ( 0.00000) :xyz}
+do_test printf-2.4.14.8 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 3.38826392e-110
+} {abc: 10 5 (3.38826e-110) :xyz}
+do_test printf-2.4.14.9 {
+ sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 3.38826392e-110
+} {abc: 10 5 (3.3883e-110) :xyz}
+do_test printf-2.5.1.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 0.001
+} {abc: (0.00) :xyz}
+do_test printf-2.5.1.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 0.001
+} {abc: (1.00e-03) :xyz}
+do_test printf-2.5.1.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 0.001
+} {abc: (0.001) :xyz}
+do_test printf-2.5.1.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 0.001
+} {abc: 2 2 (0.001) :xyz}
+do_test printf-2.5.1.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 0.001
+} {abc: 2 2 (0.00100000) :xyz}
+do_test printf-2.5.1.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 0.001
+} {abc: 2 2 (000000.001) :xyz}
+do_test printf-2.5.1.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 0.001
+} {abc: 2 2 (0.00) :xyz}
+do_test printf-2.5.1.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 0.001
+} {abc: 2 2 (1.00e-03) :xyz}
+do_test printf-2.5.1.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 0.001
+} {abc: 2 2 (0.001) :xyz}
+do_test printf-2.5.2.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 1.0e-20
+} {abc: (0.00) :xyz}
+do_test printf-2.5.2.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 1.0e-20
+} {abc: (1.00e-20) :xyz}
+do_test printf-2.5.2.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 1.0e-20
+} {abc: (1e-20) :xyz}
+do_test printf-2.5.2.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 1.0e-20
+} {abc: 2 2 (1e-20) :xyz}
+do_test printf-2.5.2.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 1.0e-20
+} {abc: 2 2 (1.00000e-20) :xyz}
+do_test printf-2.5.2.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 1.0e-20
+} {abc: 2 2 (000001e-20) :xyz}
+do_test printf-2.5.2.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 1.0e-20
+} {abc: 2 2 (0.00) :xyz}
+do_test printf-2.5.2.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 1.0e-20
+} {abc: 2 2 (1.00e-20) :xyz}
+do_test printf-2.5.2.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 1.0e-20
+} {abc: 2 2 (1e-20) :xyz}
+do_test printf-2.5.3.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 1.0
+} {abc: (1.00) :xyz}
+do_test printf-2.5.3.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 1.0
+} {abc: (1.00e+00) :xyz}
+do_test printf-2.5.3.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 1.0
+} {abc: ( 1) :xyz}
+do_test printf-2.5.3.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 1.0
+} {abc: 2 2 (1) :xyz}
+do_test printf-2.5.3.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 1.0
+} {abc: 2 2 (1.00000) :xyz}
+do_test printf-2.5.3.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 1.0
+} {abc: 2 2 (0000000001) :xyz}
+do_test printf-2.5.3.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 1.0
+} {abc: 2 2 (1.00) :xyz}
+do_test printf-2.5.3.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 1.0
+} {abc: 2 2 (1.00e+00) :xyz}
+do_test printf-2.5.3.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 1.0
+} {abc: 2 2 ( 1) :xyz}
+do_test printf-2.5.4.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 0.0
+} {abc: (0.00) :xyz}
+do_test printf-2.5.4.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 0.0
+} {abc: (0.00e+00) :xyz}
+do_test printf-2.5.4.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 0.0
+} {abc: ( 0) :xyz}
+do_test printf-2.5.4.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 0.0
+} {abc: 2 2 (0) :xyz}
+do_test printf-2.5.4.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 0.0
+} {abc: 2 2 (0.00000) :xyz}
+do_test printf-2.5.4.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 0.0
+} {abc: 2 2 (0000000000) :xyz}
+do_test printf-2.5.4.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 0.0
+} {abc: 2 2 (0.00) :xyz}
+do_test printf-2.5.4.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 0.0
+} {abc: 2 2 (0.00e+00) :xyz}
+do_test printf-2.5.4.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 0.0
+} {abc: 2 2 ( 0) :xyz}
+do_test printf-2.5.5.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 100.0
+} {abc: (100.00) :xyz}
+do_test printf-2.5.5.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 100.0
+} {abc: (1.00e+02) :xyz}
+do_test printf-2.5.5.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 100.0
+} {abc: (1e+02) :xyz}
+do_test printf-2.5.5.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 100.0
+} {abc: 2 2 (100) :xyz}
+do_test printf-2.5.5.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 100.0
+} {abc: 2 2 (100.000) :xyz}
+do_test printf-2.5.5.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 100.0
+} {abc: 2 2 (0000000100) :xyz}
+do_test printf-2.5.5.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 100.0
+} {abc: 2 2 (100.00) :xyz}
+do_test printf-2.5.5.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 100.0
+} {abc: 2 2 (1.00e+02) :xyz}
+do_test printf-2.5.5.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 100.0
+} {abc: 2 2 (1e+02) :xyz}
+do_test printf-2.5.6.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 9.99999
+} {abc: (10.00) :xyz}
+do_test printf-2.5.6.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 9.99999
+} {abc: (1.00e+01) :xyz}
+do_test printf-2.5.6.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 9.99999
+} {abc: (10) :xyz}
+do_test printf-2.5.6.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 9.99999
+} {abc: 2 2 (9.99999) :xyz}
+do_test printf-2.5.6.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 9.99999
+} {abc: 2 2 (9.99999) :xyz}
+do_test printf-2.5.6.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 9.99999
+} {abc: 2 2 (0009.99999) :xyz}
+do_test printf-2.5.6.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 9.99999
+} {abc: 2 2 (10.00) :xyz}
+do_test printf-2.5.6.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 9.99999
+} {abc: 2 2 (1.00e+01) :xyz}
+do_test printf-2.5.6.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 9.99999
+} {abc: 2 2 (10) :xyz}
+do_test printf-2.5.7.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 -0.00543
+} {abc: (-0.01) :xyz}
+do_test printf-2.5.7.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 -0.00543
+} {abc: (-5.43e-03) :xyz}
+do_test printf-2.5.7.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 -0.00543
+} {abc: (-0.0054) :xyz}
+do_test printf-2.5.7.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 -0.00543
+} {abc: 2 2 (-0.00543) :xyz}
+do_test printf-2.5.7.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 -0.00543
+} {abc: 2 2 (-0.00543000) :xyz}
+do_test printf-2.5.7.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 -0.00543
+} {abc: 2 2 (-000.00543) :xyz}
+do_test printf-2.5.7.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 -0.00543
+} {abc: 2 2 (-0.01) :xyz}
+do_test printf-2.5.7.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 -0.00543
+} {abc: 2 2 (-5.43e-03) :xyz}
+do_test printf-2.5.7.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 -0.00543
+} {abc: 2 2 (-0.0054) :xyz}
+do_test printf-2.5.8.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 -1.0
+} {abc: (-1.00) :xyz}
+do_test printf-2.5.8.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 -1.0
+} {abc: (-1.00e+00) :xyz}
+do_test printf-2.5.8.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 -1.0
+} {abc: (-1) :xyz}
+do_test printf-2.5.8.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 -1.0
+} {abc: 2 2 (-1) :xyz}
+do_test printf-2.5.8.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 -1.0
+} {abc: 2 2 (-1.00000) :xyz}
+do_test printf-2.5.8.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 -1.0
+} {abc: 2 2 (-000000001) :xyz}
+do_test printf-2.5.8.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 -1.0
+} {abc: 2 2 (-1.00) :xyz}
+do_test printf-2.5.8.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 -1.0
+} {abc: 2 2 (-1.00e+00) :xyz}
+do_test printf-2.5.8.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 -1.0
+} {abc: 2 2 (-1) :xyz}
+do_test printf-2.5.9.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 -99.99999
+} {abc: (-100.00) :xyz}
+do_test printf-2.5.9.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 -99.99999
+} {abc: (-1.00e+02) :xyz}
+do_test printf-2.5.9.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 -99.99999
+} {abc: (-1e+02) :xyz}
+do_test printf-2.5.9.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 -99.99999
+} {abc: 2 2 (-100) :xyz}
+do_test printf-2.5.9.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 -99.99999
+} {abc: 2 2 (-100.000) :xyz}
+do_test printf-2.5.9.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 -99.99999
+} {abc: 2 2 (-000000100) :xyz}
+do_test printf-2.5.9.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 -99.99999
+} {abc: 2 2 (-100.00) :xyz}
+do_test printf-2.5.9.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 -99.99999
+} {abc: 2 2 (-1.00e+02) :xyz}
+do_test printf-2.5.9.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 -99.99999
+} {abc: 2 2 (-1e+02) :xyz}
+do_test printf-2.5.10.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 3.14e+9
+} {abc: (3140000000.00) :xyz}
+do_test printf-2.5.10.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 3.14e+9
+} {abc: (3.14e+09) :xyz}
+do_test printf-2.5.10.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 3.14e+9
+} {abc: (3.1e+09) :xyz}
+do_test printf-2.5.10.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 3.14e+9
+} {abc: 2 2 (3.14e+09) :xyz}
+do_test printf-2.5.10.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 3.14e+9
+} {abc: 2 2 (3.14000e+09) :xyz}
+do_test printf-2.5.10.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 3.14e+9
+} {abc: 2 2 (003.14e+09) :xyz}
+do_test printf-2.5.10.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 3.14e+9
+} {abc: 2 2 (3140000000.00) :xyz}
+do_test printf-2.5.10.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 3.14e+9
+} {abc: 2 2 (3.14e+09) :xyz}
+do_test printf-2.5.10.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 3.14e+9
+} {abc: 2 2 (3.1e+09) :xyz}
+do_test printf-2.5.11.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 -4.72732e+88
+} {abc: (-4.73e+88) :xyz}
+do_test printf-2.5.11.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 -4.72732e+88
+} {abc: (-4.7e+88) :xyz}
+do_test printf-2.5.11.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 -4.72732e+88
+} {abc: 2 2 (-4.72732e+88) :xyz}
+do_test printf-2.5.11.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 -4.72732e+88
+} {abc: 2 2 (-4.72732e+88) :xyz}
+do_test printf-2.5.11.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 -4.72732e+88
+} {abc: 2 2 (-4.72732e+88) :xyz}
+do_test printf-2.5.11.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 -4.72732e+88
+} {abc: 2 2 (-4.73e+88) :xyz}
+do_test printf-2.5.11.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 -4.72732e+88
+} {abc: 2 2 (-4.7e+88) :xyz}
+do_test printf-2.5.12.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 9.87991e+143
+} {abc: (9.88e+143) :xyz}
+do_test printf-2.5.12.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 9.87991e+143
+} {abc: (9.9e+143) :xyz}
+do_test printf-2.5.12.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 9.87991e+143
+} {abc: 2 2 (9.87991e+143) :xyz}
+do_test printf-2.5.12.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 9.87991e+143
+} {abc: 2 2 (9.87991e+143) :xyz}
+do_test printf-2.5.12.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 9.87991e+143
+} {abc: 2 2 (9.87991e+143) :xyz}
+do_test printf-2.5.12.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 9.87991e+143
+} {abc: 2 2 (9.88e+143) :xyz}
+do_test printf-2.5.12.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 9.87991e+143
+} {abc: 2 2 (9.9e+143) :xyz}
+do_test printf-2.5.13.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 -6.287291e-9
+} {abc: (-0.00) :xyz}
+do_test printf-2.5.13.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 -6.287291e-9
+} {abc: (-6.29e-09) :xyz}
+do_test printf-2.5.13.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 -6.287291e-9
+} {abc: (-6.3e-09) :xyz}
+do_test printf-2.5.13.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 -6.287291e-9
+} {abc: 2 2 (-6.28729e-09) :xyz}
+do_test printf-2.5.13.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 -6.287291e-9
+} {abc: 2 2 (-6.28729e-09) :xyz}
+do_test printf-2.5.13.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 -6.287291e-9
+} {abc: 2 2 (-6.28729e-09) :xyz}
+do_test printf-2.5.13.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 -6.287291e-9
+} {abc: 2 2 (-0.00) :xyz}
+do_test printf-2.5.13.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 -6.287291e-9
+} {abc: 2 2 (-6.29e-09) :xyz}
+do_test printf-2.5.13.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 -6.287291e-9
+} {abc: 2 2 (-6.3e-09) :xyz}
+do_test printf-2.5.14.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 3.38826392e-110
+} {abc: (0.00) :xyz}
+do_test printf-2.5.14.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 3.38826392e-110
+} {abc: (3.39e-110) :xyz}
+do_test printf-2.5.14.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 3.38826392e-110
+} {abc: (3.4e-110) :xyz}
+do_test printf-2.5.14.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 3.38826392e-110
+} {abc: 2 2 (3.38826e-110) :xyz}
+do_test printf-2.5.14.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 3.38826392e-110
+} {abc: 2 2 (3.38826e-110) :xyz}
+do_test printf-2.5.14.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 3.38826392e-110
+} {abc: 2 2 (3.38826e-110) :xyz}
+do_test printf-2.5.14.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 3.38826392e-110
+} {abc: 2 2 (0.00) :xyz}
+do_test printf-2.5.14.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 3.38826392e-110
+} {abc: 2 2 (3.39e-110) :xyz}
+do_test printf-2.5.14.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 3.38826392e-110
+} {abc: 2 2 (3.4e-110) :xyz}
+do_test printf-2.6.1.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 0.001
+} {abc: (0.001) :xyz}
+do_test printf-2.6.1.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 0.001
+} {abc: (1.000e-03) :xyz}
+do_test printf-2.6.1.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 0.001
+} {abc: (0.001) :xyz}
+do_test printf-2.6.1.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 0.001
+} {abc: 2 3 (0.001) :xyz}
+do_test printf-2.6.1.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 0.001
+} {abc: 2 3 (0.00100000) :xyz}
+do_test printf-2.6.1.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 0.001
+} {abc: 2 3 (000000.001) :xyz}
+do_test printf-2.6.1.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 0.001
+} {abc: 2 3 (0.001) :xyz}
+do_test printf-2.6.1.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 0.001
+} {abc: 2 3 (1.000e-03) :xyz}
+do_test printf-2.6.1.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 0.001
+} {abc: 2 3 (0.001) :xyz}
+do_test printf-2.6.2.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 1.0e-20
+} {abc: (0.000) :xyz}
+do_test printf-2.6.2.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 1.0e-20
+} {abc: (1.000e-20) :xyz}
+do_test printf-2.6.2.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 1.0e-20
+} {abc: (1e-20) :xyz}
+do_test printf-2.6.2.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 1.0e-20
+} {abc: 2 3 (1e-20) :xyz}
+do_test printf-2.6.2.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 1.0e-20
+} {abc: 2 3 (1.00000e-20) :xyz}
+do_test printf-2.6.2.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 1.0e-20
+} {abc: 2 3 (000001e-20) :xyz}
+do_test printf-2.6.2.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 1.0e-20
+} {abc: 2 3 (0.000) :xyz}
+do_test printf-2.6.2.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 1.0e-20
+} {abc: 2 3 (1.000e-20) :xyz}
+do_test printf-2.6.2.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 1.0e-20
+} {abc: 2 3 (1e-20) :xyz}
+do_test printf-2.6.3.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 1.0
+} {abc: (1.000) :xyz}
+do_test printf-2.6.3.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 1.0
+} {abc: (1.000e+00) :xyz}
+do_test printf-2.6.3.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 1.0
+} {abc: ( 1) :xyz}
+do_test printf-2.6.3.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 1.0
+} {abc: 2 3 (1) :xyz}
+do_test printf-2.6.3.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 1.0
+} {abc: 2 3 (1.00000) :xyz}
+do_test printf-2.6.3.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 1.0
+} {abc: 2 3 (0000000001) :xyz}
+do_test printf-2.6.3.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 1.0
+} {abc: 2 3 (1.000) :xyz}
+do_test printf-2.6.3.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 1.0
+} {abc: 2 3 (1.000e+00) :xyz}
+do_test printf-2.6.3.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 1.0
+} {abc: 2 3 ( 1) :xyz}
+do_test printf-2.6.4.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 0.0
+} {abc: (0.000) :xyz}
+do_test printf-2.6.4.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 0.0
+} {abc: (0.000e+00) :xyz}
+do_test printf-2.6.4.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 0.0
+} {abc: ( 0) :xyz}
+do_test printf-2.6.4.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 0.0
+} {abc: 2 3 (0) :xyz}
+do_test printf-2.6.4.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 0.0
+} {abc: 2 3 (0.00000) :xyz}
+do_test printf-2.6.4.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 0.0
+} {abc: 2 3 (0000000000) :xyz}
+do_test printf-2.6.4.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 0.0
+} {abc: 2 3 (0.000) :xyz}
+do_test printf-2.6.4.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 0.0
+} {abc: 2 3 (0.000e+00) :xyz}
+do_test printf-2.6.4.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 0.0
+} {abc: 2 3 ( 0) :xyz}
+do_test printf-2.6.5.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 100.0
+} {abc: (100.000) :xyz}
+do_test printf-2.6.5.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 100.0
+} {abc: (1.000e+02) :xyz}
+do_test printf-2.6.5.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 100.0
+} {abc: (100) :xyz}
+do_test printf-2.6.5.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 100.0
+} {abc: 2 3 (100) :xyz}
+do_test printf-2.6.5.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 100.0
+} {abc: 2 3 (100.000) :xyz}
+do_test printf-2.6.5.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 100.0
+} {abc: 2 3 (0000000100) :xyz}
+do_test printf-2.6.5.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 100.0
+} {abc: 2 3 (100.000) :xyz}
+do_test printf-2.6.5.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 100.0
+} {abc: 2 3 (1.000e+02) :xyz}
+do_test printf-2.6.5.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 100.0
+} {abc: 2 3 (100) :xyz}
+do_test printf-2.6.6.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 9.99999
+} {abc: (10.000) :xyz}
+do_test printf-2.6.6.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 9.99999
+} {abc: (1.000e+01) :xyz}
+do_test printf-2.6.6.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 9.99999
+} {abc: (10) :xyz}
+do_test printf-2.6.6.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 9.99999
+} {abc: 2 3 (9.99999) :xyz}
+do_test printf-2.6.6.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 9.99999
+} {abc: 2 3 (9.99999) :xyz}
+do_test printf-2.6.6.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 9.99999
+} {abc: 2 3 (0009.99999) :xyz}
+do_test printf-2.6.6.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 9.99999
+} {abc: 2 3 (10.000) :xyz}
+do_test printf-2.6.6.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 9.99999
+} {abc: 2 3 (1.000e+01) :xyz}
+do_test printf-2.6.6.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 9.99999
+} {abc: 2 3 (10) :xyz}
+do_test printf-2.6.7.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 -0.00543
+} {abc: (-0.005) :xyz}
+do_test printf-2.6.7.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 -0.00543
+} {abc: (-5.430e-03) :xyz}
+do_test printf-2.6.7.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 -0.00543
+} {abc: (-0.00543) :xyz}
+do_test printf-2.6.7.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 -0.00543
+} {abc: 2 3 (-0.00543) :xyz}
+do_test printf-2.6.7.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 -0.00543
+} {abc: 2 3 (-0.00543000) :xyz}
+do_test printf-2.6.7.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 -0.00543
+} {abc: 2 3 (-000.00543) :xyz}
+do_test printf-2.6.7.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 -0.00543
+} {abc: 2 3 (-0.005) :xyz}
+do_test printf-2.6.7.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 -0.00543
+} {abc: 2 3 (-5.430e-03) :xyz}
+do_test printf-2.6.7.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 -0.00543
+} {abc: 2 3 (-0.00543) :xyz}
+do_test printf-2.6.8.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 -1.0
+} {abc: (-1.000) :xyz}
+do_test printf-2.6.8.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 -1.0
+} {abc: (-1.000e+00) :xyz}
+do_test printf-2.6.8.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 -1.0
+} {abc: (-1) :xyz}
+do_test printf-2.6.8.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 -1.0
+} {abc: 2 3 (-1) :xyz}
+do_test printf-2.6.8.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 -1.0
+} {abc: 2 3 (-1.00000) :xyz}
+do_test printf-2.6.8.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 -1.0
+} {abc: 2 3 (-000000001) :xyz}
+do_test printf-2.6.8.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 -1.0
+} {abc: 2 3 (-1.000) :xyz}
+do_test printf-2.6.8.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 -1.0
+} {abc: 2 3 (-1.000e+00) :xyz}
+do_test printf-2.6.8.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 -1.0
+} {abc: 2 3 (-1) :xyz}
+do_test printf-2.6.9.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 -99.99999
+} {abc: (-100.000) :xyz}
+do_test printf-2.6.9.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 -99.99999
+} {abc: (-1.000e+02) :xyz}
+do_test printf-2.6.9.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 -99.99999
+} {abc: (-100) :xyz}
+do_test printf-2.6.9.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 -99.99999
+} {abc: 2 3 (-100) :xyz}
+do_test printf-2.6.9.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 -99.99999
+} {abc: 2 3 (-100.000) :xyz}
+do_test printf-2.6.9.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 -99.99999
+} {abc: 2 3 (-000000100) :xyz}
+do_test printf-2.6.9.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 -99.99999
+} {abc: 2 3 (-100.000) :xyz}
+do_test printf-2.6.9.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 -99.99999
+} {abc: 2 3 (-1.000e+02) :xyz}
+do_test printf-2.6.9.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 -99.99999
+} {abc: 2 3 (-100) :xyz}
+do_test printf-2.6.10.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 3.14e+9
+} {abc: (3140000000.000) :xyz}
+do_test printf-2.6.10.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 3.14e+9
+} {abc: (3.140e+09) :xyz}
+do_test printf-2.6.10.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 3.14e+9
+} {abc: (3.14e+09) :xyz}
+do_test printf-2.6.10.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 3.14e+9
+} {abc: 2 3 (3.14e+09) :xyz}
+do_test printf-2.6.10.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 3.14e+9
+} {abc: 2 3 (3.14000e+09) :xyz}
+do_test printf-2.6.10.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 3.14e+9
+} {abc: 2 3 (003.14e+09) :xyz}
+do_test printf-2.6.10.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 3.14e+9
+} {abc: 2 3 (3140000000.000) :xyz}
+do_test printf-2.6.10.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 3.14e+9
+} {abc: 2 3 (3.140e+09) :xyz}
+do_test printf-2.6.10.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 3.14e+9
+} {abc: 2 3 (3.14e+09) :xyz}
+do_test printf-2.6.11.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 -4.72732e+88
+} {abc: (-4.727e+88) :xyz}
+do_test printf-2.6.11.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 -4.72732e+88
+} {abc: (-4.73e+88) :xyz}
+do_test printf-2.6.11.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 -4.72732e+88
+} {abc: 2 3 (-4.72732e+88) :xyz}
+do_test printf-2.6.11.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 -4.72732e+88
+} {abc: 2 3 (-4.72732e+88) :xyz}
+do_test printf-2.6.11.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 -4.72732e+88
+} {abc: 2 3 (-4.72732e+88) :xyz}
+do_test printf-2.6.11.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 -4.72732e+88
+} {abc: 2 3 (-4.727e+88) :xyz}
+do_test printf-2.6.11.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 -4.72732e+88
+} {abc: 2 3 (-4.73e+88) :xyz}
+do_test printf-2.6.12.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 9.87991e+143
+} {abc: (9.880e+143) :xyz}
+do_test printf-2.6.12.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 9.87991e+143
+} {abc: (9.88e+143) :xyz}
+do_test printf-2.6.12.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 9.87991e+143
+} {abc: 2 3 (9.87991e+143) :xyz}
+do_test printf-2.6.12.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 9.87991e+143
+} {abc: 2 3 (9.87991e+143) :xyz}
+do_test printf-2.6.12.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 9.87991e+143
+} {abc: 2 3 (9.87991e+143) :xyz}
+do_test printf-2.6.12.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 9.87991e+143
+} {abc: 2 3 (9.880e+143) :xyz}
+do_test printf-2.6.12.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 9.87991e+143
+} {abc: 2 3 (9.88e+143) :xyz}
+do_test printf-2.6.13.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 -6.287291e-9
+} {abc: (-0.000) :xyz}
+do_test printf-2.6.13.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 -6.287291e-9
+} {abc: (-6.287e-09) :xyz}
+do_test printf-2.6.13.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 -6.287291e-9
+} {abc: (-6.29e-09) :xyz}
+do_test printf-2.6.13.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 -6.287291e-9
+} {abc: 2 3 (-6.28729e-09) :xyz}
+do_test printf-2.6.13.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 -6.287291e-9
+} {abc: 2 3 (-6.28729e-09) :xyz}
+do_test printf-2.6.13.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 -6.287291e-9
+} {abc: 2 3 (-6.28729e-09) :xyz}
+do_test printf-2.6.13.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 -6.287291e-9
+} {abc: 2 3 (-0.000) :xyz}
+do_test printf-2.6.13.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 -6.287291e-9
+} {abc: 2 3 (-6.287e-09) :xyz}
+do_test printf-2.6.13.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 -6.287291e-9
+} {abc: 2 3 (-6.29e-09) :xyz}
+do_test printf-2.6.14.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 3.38826392e-110
+} {abc: (0.000) :xyz}
+do_test printf-2.6.14.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 3.38826392e-110
+} {abc: (3.388e-110) :xyz}
+do_test printf-2.6.14.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 3.38826392e-110
+} {abc: (3.39e-110) :xyz}
+do_test printf-2.6.14.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 3.38826392e-110
+} {abc: 2 3 (3.38826e-110) :xyz}
+do_test printf-2.6.14.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 3.38826392e-110
+} {abc: 2 3 (3.38826e-110) :xyz}
+do_test printf-2.6.14.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 3.38826392e-110
+} {abc: 2 3 (3.38826e-110) :xyz}
+do_test printf-2.6.14.7 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 3.38826392e-110
+} {abc: 2 3 (0.000) :xyz}
+do_test printf-2.6.14.8 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 3.38826392e-110
+} {abc: 2 3 (3.388e-110) :xyz}
+do_test printf-2.6.14.9 {
+ sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 3.38826392e-110
+} {abc: 2 3 (3.39e-110) :xyz}
+do_test printf-2.7.1.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 0.001
+} {abc: (0.001) :xyz}
+do_test printf-2.7.1.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 0.001
+} {abc: (1.000e-03) :xyz}
+do_test printf-2.7.1.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 0.001
+} {abc: (0.001) :xyz}
+do_test printf-2.7.1.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 0.001
+} {abc: 3 3 (0.001) :xyz}
+do_test printf-2.7.1.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 0.001
+} {abc: 3 3 (0.00100000) :xyz}
+do_test printf-2.7.1.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 0.001
+} {abc: 3 3 (000000.001) :xyz}
+do_test printf-2.7.1.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 0.001
+} {abc: 3 3 (0.001) :xyz}
+do_test printf-2.7.1.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 0.001
+} {abc: 3 3 (1.000e-03) :xyz}
+do_test printf-2.7.1.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 0.001
+} {abc: 3 3 (0.001) :xyz}
+do_test printf-2.7.2.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 1.0e-20
+} {abc: (0.000) :xyz}
+do_test printf-2.7.2.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 1.0e-20
+} {abc: (1.000e-20) :xyz}
+do_test printf-2.7.2.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 1.0e-20
+} {abc: (1e-20) :xyz}
+do_test printf-2.7.2.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 1.0e-20
+} {abc: 3 3 (1e-20) :xyz}
+do_test printf-2.7.2.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 1.0e-20
+} {abc: 3 3 (1.00000e-20) :xyz}
+do_test printf-2.7.2.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 1.0e-20
+} {abc: 3 3 (000001e-20) :xyz}
+do_test printf-2.7.2.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 1.0e-20
+} {abc: 3 3 (0.000) :xyz}
+do_test printf-2.7.2.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 1.0e-20
+} {abc: 3 3 (1.000e-20) :xyz}
+do_test printf-2.7.2.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 1.0e-20
+} {abc: 3 3 (1e-20) :xyz}
+do_test printf-2.7.3.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 1.0
+} {abc: (1.000) :xyz}
+do_test printf-2.7.3.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 1.0
+} {abc: (1.000e+00) :xyz}
+do_test printf-2.7.3.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 1.0
+} {abc: ( 1) :xyz}
+do_test printf-2.7.3.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 1.0
+} {abc: 3 3 (1) :xyz}
+do_test printf-2.7.3.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 1.0
+} {abc: 3 3 (1.00000) :xyz}
+do_test printf-2.7.3.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 1.0
+} {abc: 3 3 (0000000001) :xyz}
+do_test printf-2.7.3.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 1.0
+} {abc: 3 3 (1.000) :xyz}
+do_test printf-2.7.3.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 1.0
+} {abc: 3 3 (1.000e+00) :xyz}
+do_test printf-2.7.3.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 1.0
+} {abc: 3 3 ( 1) :xyz}
+do_test printf-2.7.4.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 0.0
+} {abc: (0.000) :xyz}
+do_test printf-2.7.4.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 0.0
+} {abc: (0.000e+00) :xyz}
+do_test printf-2.7.4.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 0.0
+} {abc: ( 0) :xyz}
+do_test printf-2.7.4.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 0.0
+} {abc: 3 3 (0) :xyz}
+do_test printf-2.7.4.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 0.0
+} {abc: 3 3 (0.00000) :xyz}
+do_test printf-2.7.4.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 0.0
+} {abc: 3 3 (0000000000) :xyz}
+do_test printf-2.7.4.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 0.0
+} {abc: 3 3 (0.000) :xyz}
+do_test printf-2.7.4.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 0.0
+} {abc: 3 3 (0.000e+00) :xyz}
+do_test printf-2.7.4.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 0.0
+} {abc: 3 3 ( 0) :xyz}
+do_test printf-2.7.5.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 100.0
+} {abc: (100.000) :xyz}
+do_test printf-2.7.5.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 100.0
+} {abc: (1.000e+02) :xyz}
+do_test printf-2.7.5.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 100.0
+} {abc: (100) :xyz}
+do_test printf-2.7.5.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 100.0
+} {abc: 3 3 (100) :xyz}
+do_test printf-2.7.5.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 100.0
+} {abc: 3 3 (100.000) :xyz}
+do_test printf-2.7.5.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 100.0
+} {abc: 3 3 (0000000100) :xyz}
+do_test printf-2.7.5.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 100.0
+} {abc: 3 3 (100.000) :xyz}
+do_test printf-2.7.5.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 100.0
+} {abc: 3 3 (1.000e+02) :xyz}
+do_test printf-2.7.5.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 100.0
+} {abc: 3 3 (100) :xyz}
+do_test printf-2.7.6.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 9.99999
+} {abc: (10.000) :xyz}
+do_test printf-2.7.6.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 9.99999
+} {abc: (1.000e+01) :xyz}
+do_test printf-2.7.6.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 9.99999
+} {abc: ( 10) :xyz}
+do_test printf-2.7.6.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 9.99999
+} {abc: 3 3 (9.99999) :xyz}
+do_test printf-2.7.6.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 9.99999
+} {abc: 3 3 (9.99999) :xyz}
+do_test printf-2.7.6.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 9.99999
+} {abc: 3 3 (0009.99999) :xyz}
+do_test printf-2.7.6.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 9.99999
+} {abc: 3 3 (10.000) :xyz}
+do_test printf-2.7.6.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 9.99999
+} {abc: 3 3 (1.000e+01) :xyz}
+do_test printf-2.7.6.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 9.99999
+} {abc: 3 3 ( 10) :xyz}
+do_test printf-2.7.7.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 -0.00543
+} {abc: (-0.005) :xyz}
+do_test printf-2.7.7.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 -0.00543
+} {abc: (-5.430e-03) :xyz}
+do_test printf-2.7.7.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 -0.00543
+} {abc: (-0.00543) :xyz}
+do_test printf-2.7.7.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 -0.00543
+} {abc: 3 3 (-0.00543) :xyz}
+do_test printf-2.7.7.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 -0.00543
+} {abc: 3 3 (-0.00543000) :xyz}
+do_test printf-2.7.7.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 -0.00543
+} {abc: 3 3 (-000.00543) :xyz}
+do_test printf-2.7.7.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 -0.00543
+} {abc: 3 3 (-0.005) :xyz}
+do_test printf-2.7.7.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 -0.00543
+} {abc: 3 3 (-5.430e-03) :xyz}
+do_test printf-2.7.7.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 -0.00543
+} {abc: 3 3 (-0.00543) :xyz}
+do_test printf-2.7.8.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 -1.0
+} {abc: (-1.000) :xyz}
+do_test printf-2.7.8.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 -1.0
+} {abc: (-1.000e+00) :xyz}
+do_test printf-2.7.8.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 -1.0
+} {abc: ( -1) :xyz}
+do_test printf-2.7.8.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 -1.0
+} {abc: 3 3 (-1) :xyz}
+do_test printf-2.7.8.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 -1.0
+} {abc: 3 3 (-1.00000) :xyz}
+do_test printf-2.7.8.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 -1.0
+} {abc: 3 3 (-000000001) :xyz}
+do_test printf-2.7.8.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 -1.0
+} {abc: 3 3 (-1.000) :xyz}
+do_test printf-2.7.8.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 -1.0
+} {abc: 3 3 (-1.000e+00) :xyz}
+do_test printf-2.7.8.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 -1.0
+} {abc: 3 3 ( -1) :xyz}
+do_test printf-2.7.9.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 -99.99999
+} {abc: (-100.000) :xyz}
+do_test printf-2.7.9.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 -99.99999
+} {abc: (-1.000e+02) :xyz}
+do_test printf-2.7.9.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 -99.99999
+} {abc: (-100) :xyz}
+do_test printf-2.7.9.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 -99.99999
+} {abc: 3 3 (-100) :xyz}
+do_test printf-2.7.9.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 -99.99999
+} {abc: 3 3 (-100.000) :xyz}
+do_test printf-2.7.9.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 -99.99999
+} {abc: 3 3 (-000000100) :xyz}
+do_test printf-2.7.9.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 -99.99999
+} {abc: 3 3 (-100.000) :xyz}
+do_test printf-2.7.9.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 -99.99999
+} {abc: 3 3 (-1.000e+02) :xyz}
+do_test printf-2.7.9.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 -99.99999
+} {abc: 3 3 (-100) :xyz}
+do_test printf-2.7.10.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 3.14e+9
+} {abc: (3140000000.000) :xyz}
+do_test printf-2.7.10.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 3.14e+9
+} {abc: (3.140e+09) :xyz}
+do_test printf-2.7.10.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 3.14e+9
+} {abc: (3.14e+09) :xyz}
+do_test printf-2.7.10.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 3.14e+9
+} {abc: 3 3 (3.14e+09) :xyz}
+do_test printf-2.7.10.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 3.14e+9
+} {abc: 3 3 (3.14000e+09) :xyz}
+do_test printf-2.7.10.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 3.14e+9
+} {abc: 3 3 (003.14e+09) :xyz}
+do_test printf-2.7.10.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 3.14e+9
+} {abc: 3 3 (3140000000.000) :xyz}
+do_test printf-2.7.10.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 3.14e+9
+} {abc: 3 3 (3.140e+09) :xyz}
+do_test printf-2.7.10.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 3.14e+9
+} {abc: 3 3 (3.14e+09) :xyz}
+do_test printf-2.7.11.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 -4.72732e+88
+} {abc: (-4.727e+88) :xyz}
+do_test printf-2.7.11.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 -4.72732e+88
+} {abc: (-4.73e+88) :xyz}
+do_test printf-2.7.11.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 -4.72732e+88
+} {abc: 3 3 (-4.72732e+88) :xyz}
+do_test printf-2.7.11.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 -4.72732e+88
+} {abc: 3 3 (-4.72732e+88) :xyz}
+do_test printf-2.7.11.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 -4.72732e+88
+} {abc: 3 3 (-4.72732e+88) :xyz}
+do_test printf-2.7.11.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 -4.72732e+88
+} {abc: 3 3 (-4.727e+88) :xyz}
+do_test printf-2.7.11.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 -4.72732e+88
+} {abc: 3 3 (-4.73e+88) :xyz}
+do_test printf-2.7.12.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 9.87991e+143
+} {abc: (9.880e+143) :xyz}
+do_test printf-2.7.12.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 9.87991e+143
+} {abc: (9.88e+143) :xyz}
+do_test printf-2.7.12.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 9.87991e+143
+} {abc: 3 3 (9.87991e+143) :xyz}
+do_test printf-2.7.12.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 9.87991e+143
+} {abc: 3 3 (9.87991e+143) :xyz}
+do_test printf-2.7.12.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 9.87991e+143
+} {abc: 3 3 (9.87991e+143) :xyz}
+do_test printf-2.7.12.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 9.87991e+143
+} {abc: 3 3 (9.880e+143) :xyz}
+do_test printf-2.7.12.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 9.87991e+143
+} {abc: 3 3 (9.88e+143) :xyz}
+do_test printf-2.7.13.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 -6.287291e-9
+} {abc: (-0.000) :xyz}
+do_test printf-2.7.13.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 -6.287291e-9
+} {abc: (-6.287e-09) :xyz}
+do_test printf-2.7.13.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 -6.287291e-9
+} {abc: (-6.29e-09) :xyz}
+do_test printf-2.7.13.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 -6.287291e-9
+} {abc: 3 3 (-6.28729e-09) :xyz}
+do_test printf-2.7.13.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 -6.287291e-9
+} {abc: 3 3 (-6.28729e-09) :xyz}
+do_test printf-2.7.13.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 -6.287291e-9
+} {abc: 3 3 (-6.28729e-09) :xyz}
+do_test printf-2.7.13.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 -6.287291e-9
+} {abc: 3 3 (-0.000) :xyz}
+do_test printf-2.7.13.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 -6.287291e-9
+} {abc: 3 3 (-6.287e-09) :xyz}
+do_test printf-2.7.13.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 -6.287291e-9
+} {abc: 3 3 (-6.29e-09) :xyz}
+do_test printf-2.7.14.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 3.38826392e-110
+} {abc: (0.000) :xyz}
+do_test printf-2.7.14.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 3.38826392e-110
+} {abc: (3.388e-110) :xyz}
+do_test printf-2.7.14.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 3.38826392e-110
+} {abc: (3.39e-110) :xyz}
+do_test printf-2.7.14.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 3.38826392e-110
+} {abc: 3 3 (3.38826e-110) :xyz}
+do_test printf-2.7.14.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 3.38826392e-110
+} {abc: 3 3 (3.38826e-110) :xyz}
+do_test printf-2.7.14.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 3.38826392e-110
+} {abc: 3 3 (3.38826e-110) :xyz}
+do_test printf-2.7.14.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 3.38826392e-110
+} {abc: 3 3 (0.000) :xyz}
+do_test printf-2.7.14.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 3.38826392e-110
+} {abc: 3 3 (3.388e-110) :xyz}
+do_test printf-2.7.14.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 3.38826392e-110
+} {abc: 3 3 (3.39e-110) :xyz}
+do_test printf-2.8.1.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 0.001
+} {abc: (0.00) :xyz}
+do_test printf-2.8.1.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 0.001
+} {abc: (1.00e-03) :xyz}
+do_test printf-2.8.1.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 0.001
+} {abc: (0.001) :xyz}
+do_test printf-2.8.1.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 0.001
+} {abc: 3 2 (0.001) :xyz}
+do_test printf-2.8.1.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 0.001
+} {abc: 3 2 (0.00100000) :xyz}
+do_test printf-2.8.1.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 0.001
+} {abc: 3 2 (000000.001) :xyz}
+do_test printf-2.8.1.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 0.001
+} {abc: 3 2 (0.00) :xyz}
+do_test printf-2.8.1.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 0.001
+} {abc: 3 2 (1.00e-03) :xyz}
+do_test printf-2.8.1.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 0.001
+} {abc: 3 2 (0.001) :xyz}
+do_test printf-2.8.2.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 1.0e-20
+} {abc: (0.00) :xyz}
+do_test printf-2.8.2.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 1.0e-20
+} {abc: (1.00e-20) :xyz}
+do_test printf-2.8.2.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 1.0e-20
+} {abc: (1e-20) :xyz}
+do_test printf-2.8.2.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 1.0e-20
+} {abc: 3 2 (1e-20) :xyz}
+do_test printf-2.8.2.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 1.0e-20
+} {abc: 3 2 (1.00000e-20) :xyz}
+do_test printf-2.8.2.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 1.0e-20
+} {abc: 3 2 (000001e-20) :xyz}
+do_test printf-2.8.2.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 1.0e-20
+} {abc: 3 2 (0.00) :xyz}
+do_test printf-2.8.2.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 1.0e-20
+} {abc: 3 2 (1.00e-20) :xyz}
+do_test printf-2.8.2.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 1.0e-20
+} {abc: 3 2 (1e-20) :xyz}
+do_test printf-2.8.3.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 1.0
+} {abc: (1.00) :xyz}
+do_test printf-2.8.3.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 1.0
+} {abc: (1.00e+00) :xyz}
+do_test printf-2.8.3.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 1.0
+} {abc: ( 1) :xyz}
+do_test printf-2.8.3.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 1.0
+} {abc: 3 2 (1) :xyz}
+do_test printf-2.8.3.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 1.0
+} {abc: 3 2 (1.00000) :xyz}
+do_test printf-2.8.3.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 1.0
+} {abc: 3 2 (0000000001) :xyz}
+do_test printf-2.8.3.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 1.0
+} {abc: 3 2 (1.00) :xyz}
+do_test printf-2.8.3.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 1.0
+} {abc: 3 2 (1.00e+00) :xyz}
+do_test printf-2.8.3.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 1.0
+} {abc: 3 2 ( 1) :xyz}
+do_test printf-2.8.4.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 0.0
+} {abc: (0.00) :xyz}
+do_test printf-2.8.4.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 0.0
+} {abc: (0.00e+00) :xyz}
+do_test printf-2.8.4.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 0.0
+} {abc: ( 0) :xyz}
+do_test printf-2.8.4.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 0.0
+} {abc: 3 2 (0) :xyz}
+do_test printf-2.8.4.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 0.0
+} {abc: 3 2 (0.00000) :xyz}
+do_test printf-2.8.4.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 0.0
+} {abc: 3 2 (0000000000) :xyz}
+do_test printf-2.8.4.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 0.0
+} {abc: 3 2 (0.00) :xyz}
+do_test printf-2.8.4.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 0.0
+} {abc: 3 2 (0.00e+00) :xyz}
+do_test printf-2.8.4.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 0.0
+} {abc: 3 2 ( 0) :xyz}
+do_test printf-2.8.5.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 100.0
+} {abc: (100.00) :xyz}
+do_test printf-2.8.5.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 100.0
+} {abc: (1.00e+02) :xyz}
+do_test printf-2.8.5.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 100.0
+} {abc: (1e+02) :xyz}
+do_test printf-2.8.5.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 100.0
+} {abc: 3 2 (100) :xyz}
+do_test printf-2.8.5.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 100.0
+} {abc: 3 2 (100.000) :xyz}
+do_test printf-2.8.5.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 100.0
+} {abc: 3 2 (0000000100) :xyz}
+do_test printf-2.8.5.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 100.0
+} {abc: 3 2 (100.00) :xyz}
+do_test printf-2.8.5.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 100.0
+} {abc: 3 2 (1.00e+02) :xyz}
+do_test printf-2.8.5.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 100.0
+} {abc: 3 2 (1e+02) :xyz}
+do_test printf-2.8.6.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 9.99999
+} {abc: (10.00) :xyz}
+do_test printf-2.8.6.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 9.99999
+} {abc: (1.00e+01) :xyz}
+do_test printf-2.8.6.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 9.99999
+} {abc: ( 10) :xyz}
+do_test printf-2.8.6.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 9.99999
+} {abc: 3 2 (9.99999) :xyz}
+do_test printf-2.8.6.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 9.99999
+} {abc: 3 2 (9.99999) :xyz}
+do_test printf-2.8.6.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 9.99999
+} {abc: 3 2 (0009.99999) :xyz}
+do_test printf-2.8.6.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 9.99999
+} {abc: 3 2 (10.00) :xyz}
+do_test printf-2.8.6.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 9.99999
+} {abc: 3 2 (1.00e+01) :xyz}
+do_test printf-2.8.6.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 9.99999
+} {abc: 3 2 ( 10) :xyz}
+do_test printf-2.8.7.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 -0.00543
+} {abc: (-0.01) :xyz}
+do_test printf-2.8.7.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 -0.00543
+} {abc: (-5.43e-03) :xyz}
+do_test printf-2.8.7.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 -0.00543
+} {abc: (-0.0054) :xyz}
+do_test printf-2.8.7.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 -0.00543
+} {abc: 3 2 (-0.00543) :xyz}
+do_test printf-2.8.7.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 -0.00543
+} {abc: 3 2 (-0.00543000) :xyz}
+do_test printf-2.8.7.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 -0.00543
+} {abc: 3 2 (-000.00543) :xyz}
+do_test printf-2.8.7.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 -0.00543
+} {abc: 3 2 (-0.01) :xyz}
+do_test printf-2.8.7.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 -0.00543
+} {abc: 3 2 (-5.43e-03) :xyz}
+do_test printf-2.8.7.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 -0.00543
+} {abc: 3 2 (-0.0054) :xyz}
+do_test printf-2.8.8.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 -1.0
+} {abc: (-1.00) :xyz}
+do_test printf-2.8.8.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 -1.0
+} {abc: (-1.00e+00) :xyz}
+do_test printf-2.8.8.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 -1.0
+} {abc: ( -1) :xyz}
+do_test printf-2.8.8.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 -1.0
+} {abc: 3 2 (-1) :xyz}
+do_test printf-2.8.8.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 -1.0
+} {abc: 3 2 (-1.00000) :xyz}
+do_test printf-2.8.8.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 -1.0
+} {abc: 3 2 (-000000001) :xyz}
+do_test printf-2.8.8.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 -1.0
+} {abc: 3 2 (-1.00) :xyz}
+do_test printf-2.8.8.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 -1.0
+} {abc: 3 2 (-1.00e+00) :xyz}
+do_test printf-2.8.8.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 -1.0
+} {abc: 3 2 ( -1) :xyz}
+do_test printf-2.8.9.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 -99.99999
+} {abc: (-100.00) :xyz}
+do_test printf-2.8.9.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 -99.99999
+} {abc: (-1.00e+02) :xyz}
+do_test printf-2.8.9.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 -99.99999
+} {abc: (-1e+02) :xyz}
+do_test printf-2.8.9.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 -99.99999
+} {abc: 3 2 (-100) :xyz}
+do_test printf-2.8.9.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 -99.99999
+} {abc: 3 2 (-100.000) :xyz}
+do_test printf-2.8.9.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 -99.99999
+} {abc: 3 2 (-000000100) :xyz}
+do_test printf-2.8.9.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 -99.99999
+} {abc: 3 2 (-100.00) :xyz}
+do_test printf-2.8.9.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 -99.99999
+} {abc: 3 2 (-1.00e+02) :xyz}
+do_test printf-2.8.9.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 -99.99999
+} {abc: 3 2 (-1e+02) :xyz}
+do_test printf-2.8.10.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 3.14e+9
+} {abc: (3140000000.00) :xyz}
+do_test printf-2.8.10.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 3.14e+9
+} {abc: (3.14e+09) :xyz}
+do_test printf-2.8.10.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 3.14e+9
+} {abc: (3.1e+09) :xyz}
+do_test printf-2.8.10.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 3.14e+9
+} {abc: 3 2 (3.14e+09) :xyz}
+do_test printf-2.8.10.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 3.14e+9
+} {abc: 3 2 (3.14000e+09) :xyz}
+do_test printf-2.8.10.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 3.14e+9
+} {abc: 3 2 (003.14e+09) :xyz}
+do_test printf-2.8.10.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 3.14e+9
+} {abc: 3 2 (3140000000.00) :xyz}
+do_test printf-2.8.10.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 3.14e+9
+} {abc: 3 2 (3.14e+09) :xyz}
+do_test printf-2.8.10.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 3.14e+9
+} {abc: 3 2 (3.1e+09) :xyz}
+do_test printf-2.8.11.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 -4.72732e+88
+} {abc: (-4.73e+88) :xyz}
+do_test printf-2.8.11.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 -4.72732e+88
+} {abc: (-4.7e+88) :xyz}
+do_test printf-2.8.11.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 -4.72732e+88
+} {abc: 3 2 (-4.72732e+88) :xyz}
+do_test printf-2.8.11.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 -4.72732e+88
+} {abc: 3 2 (-4.72732e+88) :xyz}
+do_test printf-2.8.11.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 -4.72732e+88
+} {abc: 3 2 (-4.72732e+88) :xyz}
+do_test printf-2.8.11.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 -4.72732e+88
+} {abc: 3 2 (-4.73e+88) :xyz}
+do_test printf-2.8.11.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 -4.72732e+88
+} {abc: 3 2 (-4.7e+88) :xyz}
+do_test printf-2.8.12.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 9.87991e+143
+} {abc: (9.88e+143) :xyz}
+do_test printf-2.8.12.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 9.87991e+143
+} {abc: (9.9e+143) :xyz}
+do_test printf-2.8.12.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 9.87991e+143
+} {abc: 3 2 (9.87991e+143) :xyz}
+do_test printf-2.8.12.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 9.87991e+143
+} {abc: 3 2 (9.87991e+143) :xyz}
+do_test printf-2.8.12.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 9.87991e+143
+} {abc: 3 2 (9.87991e+143) :xyz}
+do_test printf-2.8.12.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 9.87991e+143
+} {abc: 3 2 (9.88e+143) :xyz}
+do_test printf-2.8.12.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 9.87991e+143
+} {abc: 3 2 (9.9e+143) :xyz}
+do_test printf-2.8.13.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 -6.287291e-9
+} {abc: (-0.00) :xyz}
+do_test printf-2.8.13.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 -6.287291e-9
+} {abc: (-6.29e-09) :xyz}
+do_test printf-2.8.13.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 -6.287291e-9
+} {abc: (-6.3e-09) :xyz}
+do_test printf-2.8.13.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 -6.287291e-9
+} {abc: 3 2 (-6.28729e-09) :xyz}
+do_test printf-2.8.13.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 -6.287291e-9
+} {abc: 3 2 (-6.28729e-09) :xyz}
+do_test printf-2.8.13.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 -6.287291e-9
+} {abc: 3 2 (-6.28729e-09) :xyz}
+do_test printf-2.8.13.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 -6.287291e-9
+} {abc: 3 2 (-0.00) :xyz}
+do_test printf-2.8.13.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 -6.287291e-9
+} {abc: 3 2 (-6.29e-09) :xyz}
+do_test printf-2.8.13.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 -6.287291e-9
+} {abc: 3 2 (-6.3e-09) :xyz}
+do_test printf-2.8.14.1 {
+ sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 3.38826392e-110
+} {abc: (0.00) :xyz}
+do_test printf-2.8.14.2 {
+ sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 3.38826392e-110
+} {abc: (3.39e-110) :xyz}
+do_test printf-2.8.14.3 {
+ sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 3.38826392e-110
+} {abc: (3.4e-110) :xyz}
+do_test printf-2.8.14.4 {
+ sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 (3.38826e-110) :xyz}
+do_test printf-2.8.14.5 {
+ sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 (3.38826e-110) :xyz}
+do_test printf-2.8.14.6 {
+ sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 (3.38826e-110) :xyz}
+do_test printf-2.8.14.7 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 (0.00) :xyz}
+do_test printf-2.8.14.8 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 (3.39e-110) :xyz}
+do_test printf-2.8.14.9 {
+ sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 (3.4e-110) :xyz}
+do_test printf-2.8.15.1 {
+ sqlite3_mprintf_double {abc: (% *.*f) :xyz} 3 2 3.38826392e-110
+} {abc: ( 0.00) :xyz}
+do_test printf-2.8.15.2 {
+ sqlite3_mprintf_double {abc: (% *.*e) :xyz} 3 2 3.38826392e-110
+} {abc: ( 3.39e-110) :xyz}
+do_test printf-2.8.15.3 {
+ sqlite3_mprintf_double {abc: (% *.*g) :xyz} 3 2 3.38826392e-110
+} {abc: ( 3.4e-110) :xyz}
+do_test printf-2.8.15.4 {
+ sqlite3_mprintf_double {abc: %d %d (% g) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 ( 3.38826e-110) :xyz}
+do_test printf-2.8.15.5 {
+ sqlite3_mprintf_double {abc: %d %d (% #g) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 ( 3.38826e-110) :xyz}
+do_test printf-2.8.15.6 {
+ sqlite3_mprintf_double {abc: %d %d (%0 10g) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 ( 3.38826e-110) :xyz}
+do_test printf-2.8.15.7 {
+ sqlite3_mprintf_double {abc: %d %d (% 3.2f) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 ( 0.00) :xyz}
+do_test printf-2.8.15.8 {
+ sqlite3_mprintf_double {abc: %d %d (% 3.2e) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 ( 3.39e-110) :xyz}
+do_test printf-2.8.15.9 {
+ sqlite3_mprintf_double {abc: %d %d (% 3.2g) :xyz} 3 2 3.38826392e-110
+} {abc: 3 2 ( 3.4e-110) :xyz}
+
+do_test printf-2.9.1 {
+ sqlite3_mprintf_double {abc: %d %d (%5.0g) :xyz} 0 0 1.234
+} {abc: 0 0 ( 1) :xyz}
+do_test printf-2.9.2 {
+ sqlite3_mprintf_double {abc: %d %d (%+5.0g) :xyz} 0 0 1.234
+} {abc: 0 0 ( +1) :xyz}
+do_test printf-2.9.3 {
+ sqlite3_mprintf_double {abc: %d %d (%+-5.0g) :xyz} 0 0 1.234
+} {abc: 0 0 (+1 ) :xyz}
+
+do_test printf-2.10.1 {
+ sqlite3_mprintf_double {abc: %d %d (%-010.5f) :xyz} 0 0 1.234
+} {abc: 0 0 (1.23400 ) :xyz}
+do_test printf-2.10.2 {
+ sqlite3_mprintf_double {abc: %d %d (%010.5f) :xyz} 0 0 1.234
+} {abc: 0 0 (0001.23400) :xyz}
+do_test printf-2.10.3 {
+ sqlite3_mprintf_double {abc: %d %d (%+010.5f) :xyz} 0 0 1.234
+} {abc: 0 0 (+001.23400) :xyz}
+
+do_test printf-3.1 {
+ sqlite3_mprintf_str {A String: (%*.*s)} 10 10 {This is the string}
+} [format {A String: (%*.*s)} 10 10 {This is the string}]
+do_test printf-3.2 {
+ sqlite3_mprintf_str {A String: (%*.*s)} 10 5 {This is the string}
+} [format {A String: (%*.*s)} 10 5 {This is the string}]
+do_test printf-3.3 {
+ sqlite3_mprintf_str {A String: (%*.*s)} -10 5 {This is the string}
+} [format {A String: (%*.*s)} -10 5 {This is the string}]
+do_test printf-3.4 {
+ sqlite3_mprintf_str {%d %d A String: (%s)} 1 2 {This is the string}
+} [format {%d %d A String: (%s)} 1 2 {This is the string}]
+do_test printf-3.5 {
+ sqlite3_mprintf_str {%d %d A String: (%30s)} 1 2 {This is the string}
+} [format {%d %d A String: (%30s)} 1 2 {This is the string}]
+do_test printf-3.6 {
+ sqlite3_mprintf_str {%d %d A String: (%-30s)} 1 2 {This is the string}
+} [format {%d %d A String: (%-30s)} 1 2 {This is the string}]
+do_test snprintf-3.11 {
+ sqlite3_snprintf_str 2 {x%d %d %s} 10 10 {This is the string}
+} {x}
+do_test snprintf-3.12 {
+ sqlite3_snprintf_str 3 {x%d %d %s} 10 10 {This is the string}
+} {x1}
+do_test snprintf-3.13 {
+ sqlite3_snprintf_str 4 {x%d %d %s} 10 10 {This is the string}
+} {x10}
+do_test snprintf-3.14 {
+ sqlite3_snprintf_str 5 {x%d %d %s} 10 10 {This is the string}
+} {x10 }
+do_test snprintf-3.15 {
+ sqlite3_snprintf_str 6 {x%d %d %s} 10 10 {This is the string}
+} {x10 1}
+do_test snprintf-3.16 {
+ sqlite3_snprintf_str 7 {x%d %d %s} 10 10 {This is the string}
+} {x10 10}
+do_test snprintf-3.17 {
+ sqlite3_snprintf_str 8 {x%d %d %s} 10 10 {This is the string}
+} {x10 10 }
+do_test snprintf-3.18 {
+ sqlite3_snprintf_str 9 {x%d %d %s} 10 10 {This is the string}
+} {x10 10 T}
+do_test snprintf-3.19 {
+ sqlite3_snprintf_str 100 {x%d %d %s} 10 10 {This is the string}
+} {x10 10 This is the string}
+
+do_test printf-4.1 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi Y''all'}
+do_test printf-4.2 {
+ sqlite3_mprintf_str {%d %d A NULL pointer in %%q: '%q'} 1 2
+} {1 2 A NULL pointer in %q: '(NULL)'}
+do_test printf-4.3 {
+ sqlite3_mprintf_str {%d %d A quoted string: %Q} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi Y''all'}
+do_test printf-4.4 {
+ sqlite3_mprintf_str {%d %d A NULL pointer in %%Q: %Q} 1 2
+} {1 2 A NULL pointer in %Q: NULL}
+do_test printf-4.5 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.10q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi Y''all'}
+do_test printf-4.6 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.9q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi Y''all'}
+do_test printf-4.7 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.8q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi Y''all'}
+do_test printf-4.8 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.7q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi Y''al'}
+do_test printf-4.9 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.6q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi Y''a'}
+do_test printf-4.10 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.5q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi Y'''}
+do_test printf-4.11 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.4q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi Y'}
+do_test printf-4.12 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.3q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi '}
+do_test printf-4.13 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.2q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'Hi'}
+do_test printf-4.14 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.1q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: 'H'}
+do_test printf-4.15 {
+ sqlite3_mprintf_str {%d %d A quoted string: '%.0q'} 1 2 {Hi Y'all}
+} {1 2 A quoted string: ''}
+do_test printf-4.16 {
+ sqlite3_mprintf_str {%d A quoted string: '%.*q'} 1 6 {Hi Y'all}
+} {1 A quoted string: 'Hi Y''a'}
+
+
+do_test printf-5.1 {
+ set x [sqlite3_mprintf_str {%d %d %100000s} 0 0 {Hello}]
+ string length $x
+} {100004}
+do_test printf-5.2 {
+ sqlite3_mprintf_str {%d %d (%-10.10s) %} -9 -10 {HelloHelloHello}
+} {-9 -10 (HelloHello) %}
+
+do_test printf-6.1 {
+ sqlite3_mprintf_z_test , one two three four five six
+} {,one,two,three,four,five,six}
+
+
+do_test printf-7.1 {
+ sqlite3_mprintf_scaled {A double: %g} 1.0e307 1.0
+} {A double: 1e+307}
+do_test printf-7.2 {
+ sqlite3_mprintf_scaled {A double: %g} 1.0e307 10.0
+} {A double: 1e+308}
+do_test printf-7.3 {
+ sqlite3_mprintf_scaled {A double: %g} 1.0e307 100.0
+} {A double: Inf}
+do_test printf-7.4 {
+ sqlite3_mprintf_scaled {A double: %g} -1.0e307 100.0
+} {A double: -Inf}
+do_test printf-7.5 {
+ sqlite3_mprintf_scaled {A double: %+g} 1.0e307 100.0
+} {A double: +Inf}
+
+do_test printf-8.1 {
+ sqlite3_mprintf_int {%u %u %u} 0x7fffffff 0x80000000 0xffffffff
+} {2147483647 2147483648 4294967295}
+do_test printf-8.2 {
+ sqlite3_mprintf_long {%lu %lu %lu} 0x7fffffff 0x80000000 0xffffffff
+} {2147483647 2147483648 4294967295}
+do_test printf-8.3 {
+ sqlite3_mprintf_int64 {%llu %llu %llu} 2147483647 2147483648 4294967296
+} {2147483647 2147483648 4294967296}
+do_test printf-8.4 {
+ sqlite3_mprintf_int64 {%lld %lld %lld} 2147483647 2147483648 4294967296
+} {2147483647 2147483648 4294967296}
+do_test printf-8.5 {
+ sqlite3_mprintf_int64 {%llx %llx %llx} 2147483647 2147483648 4294967296
+} {7fffffff 80000000 100000000}
+do_test printf-8.6 {
+ sqlite3_mprintf_int64 {%llx %llo %lld} -1 -1 -1
+} {ffffffffffffffff 1777777777777777777777 -1}
+do_test printf-8.7 {
+ sqlite3_mprintf_int64 {%llx %llx %llx} +2147483647 +2147483648 +4294967296
+} {7fffffff 80000000 100000000}
+
+do_test printf-9.1 {
+ sqlite3_mprintf_int {%*.*c} 4 4 65
+} {AAAA}
+do_test printf-9.2 {
+ sqlite3_mprintf_int {%*.*c} -4 1 66
+} {B }
+do_test printf-9.3 {
+ sqlite3_mprintf_int {%*.*c} 4 1 67
+} { C}
+do_test printf-9.4 {
+ sqlite3_mprintf_int {%d %d %c} 4 1 67
+} {4 1 C}
+set ten { }
+set fifty $ten$ten$ten$ten$ten
+do_test printf-9.5 {
+ sqlite3_mprintf_int {%d %*c} 1 -201 67
+} "1 C$fifty$fifty$fifty$fifty"
+do_test printf-9.6 {
+ sqlite3_mprintf_int {hi%12345.12346yhello} 0 0 0
+} {hi}
+
+# Ticket #812
+#
+do_test printf-10.1 {
+ sqlite3_mprintf_stronly %s {}
+} {}
+
+# Ticket #831
+#
+do_test printf-10.2 {
+ sqlite3_mprintf_stronly %q {}
+} {}
+
+# Ticket #1340: Test for loss of precision on large positive exponents
+#
+do_test printf-10.3 {
+ sqlite3_mprintf_double {%d %d %f} 1 1 1e300
+} {1 1 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000}
+
+# The non-standard '!' flag on a 'g' conversion forces a decimal point
+# and at least one digit on either side of the decimal point.
+#
+do_test printf-11.1 {
+ sqlite3_mprintf_double {%d %d %!g} 1 1 1
+} {1 1 1.0}
+do_test printf-11.2 {
+ sqlite3_mprintf_double {%d %d %!g} 1 1 123
+} {1 1 123.0}
+do_test printf-11.3 {
+ sqlite3_mprintf_double {%d %d %!g} 1 1 12.3
+} {1 1 12.3}
+do_test printf-11.4 {
+ sqlite3_mprintf_double {%d %d %!g} 1 1 0.123
+} {1 1 0.123}
+do_test printf-11.5 {
+ sqlite3_mprintf_double {%d %d %!.15g} 1 1 1
+} {1 1 1.0}
+do_test printf-11.6 {
+ sqlite3_mprintf_double {%d %d %!.15g} 1 1 1e10
+} {1 1 10000000000.0}
+do_test printf-11.7 {
+ sqlite3_mprintf_double {%d %d %!.15g} 1 1 1e300
+} {1 1 1.0e+300}
+
+# Additional tests for coverage
+#
+do_test printf-12.1 {
+ sqlite3_mprintf_double {%d %d %.2000g} 1 1 1.0
+} {1 1 1}
+
+# Floating point boundary cases
+#
+do_test printf-13.1 {
+ sqlite3_mprintf_hexdouble %.20f 4024000000000000
+} {10.00000000000000000000}
+do_test printf-13.2 {
+ sqlite3_mprintf_hexdouble %.20f 4197d78400000000
+} {100000000.00000000000000000000}
+do_test printf-13.3 {
+ sqlite3_mprintf_hexdouble %.20f 4693b8b5b5056e17
+} {100000000000000000000000000000000.00000000000000000000}
+do_test printf-13.4 {
+ sqlite3_mprintf_hexdouble %.20f 7ff0000000000000
+} {Inf}
+do_test printf-13.5 {
+ sqlite3_mprintf_hexdouble %.20f fff0000000000000
+} {-Inf}
+do_test printf-13.6 {
+ sqlite3_mprintf_hexdouble %.20f fff8000000000000
+} {NaN}
+
+do_test printf-14.1 {
+ sqlite3_mprintf_str {abc-%y-123} 0 0 {not used}
+} {abc-}
+do_test printf-14.2 {
+ sqlite3_mprintf_n_test {xyzzy}
+} 5
+do_test printf-14.3 {
+ sqlite3_mprintf_str {abc-%T-123} 0 0 {not used}
+} {abc-}
+do_test printf-14.4 {
+ sqlite3_mprintf_str {abc-%#} 0 0 {not used}
+} {abc-}
+do_test printf-14.5 {
+ sqlite3_mprintf_str {abc-%*.*s-xyz} 10 -10 {a_very_long_string}
+} {abc-a_very_lon-xyz}
+do_test printf-14.6 {
+ sqlite3_mprintf_str {abc-%5.10/} 0 0 {not used}
+} {abc-}
+do_test printf-14.7 {
+ sqlite3_mprintf_str {abc-%05.5d} 123 0 {not used}
+} {abc-00123}
+do_test printf-14.8 {
+ sqlite3_mprintf_str {abc-%05.5d} 1234567 0 {not used}
+} {abc-1234567}
+
+for {set i 2} {$i<200} {incr i} {
+ set res [string repeat { } [expr {$i-1}]]x
+ do_test printf-14.90.$i "
+ sqlite3_mprintf_str {%*.*s} $i 500 x
+ " $res
+}
+
+do_test printf-15.1 {
+ sqlite3_snprintf_int 5 {12345} 0
+} {1234}
+do_test printf-15.2 {
+ sqlite3_snprintf_int 5 {} 0
+} {}
+do_test printf-15.3 {
+ sqlite3_snprintf_int 0 {} 0
+} {abcdefghijklmnopqrstuvwxyz}
+
+# Now test malloc() failure within a sqlite3_mprintf():
+#
+ifcapable memdebug {
+ foreach var {a b c d} {
+ set $var [string repeat $var 400]
+ }
+ set str1 "[string repeat A 360]%d%d%s"
+ set str2 [string repeat B 5000]
+ set zSuccess "[string repeat A 360]11[string repeat B 5000]"
+ foreach ::iRepeat {0 1} {
+ set nTestNum 1
+ while {1} {
+ sqlite3_memdebug_fail $nTestNum -repeat $::iRepeat
+ set z [sqlite3_mprintf_str $str1 1 1 $str2]
+ set nFail [sqlite3_memdebug_fail -1 -benign nBenign]
+ do_test printf-malloc-$::iRepeat.$nTestNum {
+ expr {($nFail>0 && $z eq "") || ($nFail==$nBenign && $z eq $zSuccess)}
+ } {1}
+ if {$nFail == 0} break
+ incr nTestNum
+ }
+ }
+}
+
+finish_test
diff --git a/test/progress.test b/test/progress.test
new file mode 100644
index 0000000..b25a100
--- /dev/null
+++ b/test/progress.test
@@ -0,0 +1,177 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the 'progress callback'.
+#
+# $Id: progress.test,v 1.8 2007/06/15 14:53:53 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If the progress callback is not available in this build, skip this
+# whole file.
+ifcapable !progress {
+ finish_test
+ return
+}
+
+# Build some test data
+#
+execsql {
+ BEGIN;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ INSERT INTO t1 VALUES(5);
+ INSERT INTO t1 VALUES(6);
+ INSERT INTO t1 VALUES(7);
+ INSERT INTO t1 VALUES(8);
+ INSERT INTO t1 VALUES(9);
+ INSERT INTO t1 VALUES(10);
+ COMMIT;
+}
+
+
+# Test that the progress callback is invoked.
+do_test progress-1.0 {
+ set counter 0
+ db progress 1 "[namespace code {incr counter}] ; expr 0"
+ execsql {
+ SELECT * FROM t1
+ }
+ expr $counter > 1
+} 1
+do_test progress-1.0.1 {
+ db progress
+} {::namespace inscope :: {incr counter} ; expr 0}
+do_test progress-1.0.2 {
+ set v [catch {db progress xyz bogus} msg]
+ lappend v $msg
+} {1 {expected integer but got "xyz"}}
+
+# Test that the query is abandoned when the progress callback returns non-zero
+do_test progress-1.1 {
+ set counter 0
+ db progress 1 "[namespace code {incr counter}] ; expr 1"
+ set rc [catch {execsql {
+ SELECT * FROM t1
+ }}]
+ list $counter $rc
+} {1 1}
+
+# Test that the query is rolled back when the progress callback returns
+# non-zero.
+do_test progress-1.2 {
+
+ # This figures out how many opcodes it takes to copy 5 extra rows into t1.
+ db progress 1 "[namespace code {incr five_rows}] ; expr 0"
+ set five_rows 0
+ execsql {
+ INSERT INTO t1 SELECT a+10 FROM t1 WHERE a < 6
+ }
+ db progress 0 ""
+ execsql {
+ DELETE FROM t1 WHERE a > 10
+ }
+
+ # Now set up the progress callback to abandon the query after the number of
+ # opcodes to copy 5 rows. That way, when we try to copy 6 rows, we know
+ # some data will have been inserted into the table by the time the progress
+ # callback abandons the query.
+ db progress $five_rows "expr 1"
+ catchsql {
+ INSERT INTO t1 SELECT a+10 FROM t1 WHERE a < 9
+ }
+ execsql {
+ SELECT count(*) FROM t1
+ }
+} 10
+
+# Test that an active transaction remains active and not rolled back
+# after the progress query abandons a query.
+#
+# UPDATE: It is now recognised that this is a sure route to database
+# corruption. So the transaction is rolled back.
+do_test progress-1.3 {
+
+ db progress 0 ""
+ execsql BEGIN
+ execsql {
+ INSERT INTO t1 VALUES(11)
+ }
+ db progress 1 "expr 1"
+ catchsql {
+ INSERT INTO t1 VALUES(12)
+ }
+ db progress 0 ""
+ catchsql COMMIT
+} {1 {cannot commit - no transaction is active}}
+do_test progress-1.3.1 {
+ execsql {
+ SELECT count(*) FROM t1
+ }
+} 10
+
+# Check that a value of 0 for N means no progress callback
+do_test progress-1.4 {
+ set counter 0
+ db progress 0 "[namespace code {incr counter}] ; expr 0"
+ execsql {
+ SELECT * FROM t1;
+ }
+ set counter
+} 0
+
+db progress 0 ""
+
+# Make sure other queries can be run from within the progress
+# handler. Ticket #1827
+#
+do_test progress-1.5 {
+ set rx 0
+ proc set_rx {args} {
+ db progress 0 {}
+ set ::rx [db eval {SELECT count(*) FROM t1}]
+ return [expr 0]
+ }
+ db progress 10 set_rx
+ db eval {
+ SELECT sum(a) FROM t1
+ }
+} {55}
+do_test progress-1.6 {
+ set ::rx
+} {10}
+
+# Check that abandoning a query using the progress handler does
+# not cause other queries to abort. Ticket #2415.
+do_test progress-1.7 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(4, 5, 6);
+ INSERT INTO abc VALUES(7, 8, 9);
+ }
+
+ set ::res [list]
+ db eval {SELECT a, b, c FROM abc} {
+ lappend ::res $a $b $c
+ db progress 10 "expr 1"
+ catch {db eval {SELECT a, b, c FROM abc} { }} msg
+ lappend ::res $msg
+ }
+
+ set ::res
+} {1 2 3 interrupted 4 5 6 interrupted 7 8 9 interrupted}
+
+finish_test
diff --git a/test/ptrchng.test b/test/ptrchng.test
new file mode 100644
index 0000000..75525f9
--- /dev/null
+++ b/test/ptrchng.test
@@ -0,0 +1,223 @@
+# 2007 April 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# The focus of the tests in this file are to verify that the
+# underlying TEXT or BLOB representation of an sqlite3_value
+# changes appropriately when APIs from the following set are
+# called:
+#
+# sqlite3_value_text()
+# sqlite3_value_text16()
+# sqlite3_value_blob()
+# sqlite3_value_bytes()
+# sqlite3_value_bytes16()
+#
+# $Id: ptrchng.test,v 1.5 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !bloblit {
+ finish_test
+ return
+}
+
+# Register the "pointer_change" SQL function.
+#
+sqlite3_create_function db
+
+do_test ptrchng-1.1 {
+ execsql {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y BLOB);
+ INSERT INTO t1 VALUES(1, 'abc');
+ INSERT INTO t1 VALUES(2,
+ 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234356789');
+ INSERT INTO t1 VALUES(3, x'626c6f62');
+ INSERT INTO t1 VALUES(4,
+ x'000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324'
+ );
+ SELECT count(*) FROM t1;
+ }
+} {4}
+
+# For the short entries that fit in the Mem.zBuf[], the pointer should
+# never change regardless of what type conversions occur.
+#
+# UPDATE: No longer true, as Mem.zBuf[] has been removed.
+#
+do_test ptrchng-2.1 {
+ execsql {
+ SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=1
+ }
+} {0}
+do_test ptrchng-2.2 {
+ execsql {
+ SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=1
+ }
+} {0}
+ifcapable utf16 {
+ do_test ptrchng-2.3 {
+ execsql {
+ SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=1
+ }
+ } {1}
+ do_test ptrchng-2.4 {
+ execsql {
+ SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=1
+ }
+ } {1}
+ do_test ptrchng-2.5 {
+ execsql {
+ SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=1
+ }
+ } {0}
+ do_test ptrchng-2.6 {
+ execsql {
+ SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=1
+ }
+ } {1}
+}
+do_test ptrchng-2.11 {
+ execsql {
+ SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=3
+ }
+} {0}
+do_test ptrchng-2.12 {
+ execsql {
+ SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=3
+ }
+} {0}
+ifcapable utf16 {
+ do_test ptrchng-2.13 {
+ execsql {
+ SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=3
+ }
+ } {1}
+ do_test ptrchng-2.14 {
+ execsql {
+ SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=3
+ }
+ } {1}
+ do_test ptrchng-2.15 {
+ execsql {
+ SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=3
+ }
+ } {0}
+ do_test ptrchng-2.16 {
+ execsql {
+ SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=3
+ }
+ } {1}
+}
+
+# For the long entries that do not fit in the Mem.zBuf[], the pointer
+# should change sometimes.
+#
+do_test ptrchng-3.1 {
+ execsql {
+ SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=2
+ }
+} {0}
+do_test ptrchng-3.2 {
+ execsql {
+ SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=2
+ }
+} {0}
+ifcapable utf16 {
+ do_test ptrchng-3.3 {
+ execsql {
+ SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=2
+ }
+ } {1}
+ do_test ptrchng-3.4 {
+ execsql {
+ SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=2
+ }
+ } {1}
+ do_test ptrchng-3.5 {
+ execsql {
+ SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=2
+ }
+ } {0}
+ do_test ptrchng-3.6 {
+ execsql {
+ SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=2
+ }
+ } {1}
+}
+do_test ptrchng-3.11 {
+ execsql {
+ SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=4
+ }
+} {0}
+do_test ptrchng-3.12 {
+ execsql {
+ SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=4
+ }
+} {0}
+ifcapable utf16 {
+ do_test ptrchng-3.13 {
+ execsql {
+ SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=4
+ }
+ } {1}
+ do_test ptrchng-3.14 {
+ execsql {
+ SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=4
+ }
+ } {1}
+ do_test ptrchng-3.15 {
+ execsql {
+ SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=4
+ }
+ } {0}
+ do_test ptrchng-3.16 {
+ execsql {
+ SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=4
+ }
+ } {1}
+}
+
+# A call to _bytes() should never reformat a _text() or _blob().
+#
+do_test ptrchng-4.1 {
+ execsql {
+ SELECT pointer_change(y, 'text', 'bytes', 'text') FROM t1
+ }
+} {0 0 0 0}
+do_test ptrchng-4.2 {
+ execsql {
+ SELECT pointer_change(y, 'blob', 'bytes', 'blob') FROM t1
+ }
+} {0 0 0 0}
+
+# A call to _blob() should never trigger a reformat
+#
+do_test ptrchng-5.1 {
+ execsql {
+ SELECT pointer_change(y, 'text', 'bytes', 'blob') FROM t1
+ }
+} {0 0 0 0}
+ifcapable utf16 {
+ do_test ptrchng-5.2 {
+ execsql {
+ SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1
+ }
+ } {0 0 0 0}
+ do_test ptrchng-5.3 {
+ execsql {
+ SELECT pointer_change(y, 'text16', 'bytes16', 'blob') FROM t1
+ }
+ } {0 0 0 0}
+}
+
+finish_test
diff --git a/test/quick.test b/test/quick.test
new file mode 100644
index 0000000..974b02d
--- /dev/null
+++ b/test/quick.test
@@ -0,0 +1,15 @@
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file runs all tests.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/permutations.test
+
+run_test_suite quick
+
+finish_test
diff --git a/test/quota.test b/test/quota.test
new file mode 100644
index 0000000..49b403f
--- /dev/null
+++ b/test/quota.test
@@ -0,0 +1,516 @@
+# 2010 September 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+db close
+
+do_test quota-1.1 { sqlite3_quota_initialize nosuchvfs 1 } {SQLITE_ERROR}
+do_test quota-1.2 { sqlite3_quota_initialize "" 1 } {SQLITE_OK}
+do_test quota-1.3 { sqlite3_quota_initialize "" 1 } {SQLITE_MISUSE}
+do_test quota-1.4 { sqlite3_quota_shutdown } {SQLITE_OK}
+
+do_test quota-1.5 { sqlite3_quota_initialize "" 0 } {SQLITE_OK}
+do_test quota-1.6 { sqlite3_quota_shutdown } {SQLITE_OK}
+do_test quota-1.7 { sqlite3_quota_initialize "" 1 } {SQLITE_OK}
+do_test quota-1.8 { sqlite3_quota_shutdown } {SQLITE_OK}
+
+
+#-------------------------------------------------------------------------
+# Some simple warm-body tests with a single database file in rollback
+# mode:
+#
+# quota-2.1.*: Test that SQLITE_FULL is returned if the database would
+# exceed the configured quota.
+#
+# quota-2.2.*: Test that SQLITE_FULL is not returned and the database
+# grows if the callback extends the quota when the database
+# attempts to grow beyond the configured quota.
+#
+# quota-2.3.*: Open and close a db that is not part of any quota group. At
+# one point this was causing mutex refs to be leaked.
+#
+# quota-2.4.*: Try to shutdown the quota system before closing the db
+# file. Check that this fails and the quota system still works
+# afterwards. Then close the database and successfully shut
+# down the quota system.
+#
+sqlite3_quota_initialize "" 1
+
+proc quota_check {filename limitvar size} {
+ upvar $limitvar limit
+
+ lappend ::quota [set limit] $size
+ if {[info exists ::quota_request_ok]} { set limit $size }
+}
+
+do_test quota-2.1.1 {
+ sqlite3_quota_set *test.db 4096 quota_check
+} {SQLITE_OK}
+do_test quota-2.1.2 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size=1024;
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA journal_mode=DELETE;
+ }
+ set ::quota [list]
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, randomblob(1100));
+ INSERT INTO t1 VALUES(2, randomblob(1100));
+ }
+ set ::quota
+} {}
+do_test quota-2.1.3 { file size test.db } {4096}
+do_test quota-2.1.4 {
+ catchsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }
+} {1 {database or disk is full}}
+do_test quota-2.1.5 { set ::quota } {4096 5120}
+
+set ::quota_request_ok 1
+set ::quota [list]
+do_test quota-2.2.1 {
+ execsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }
+} {}
+do_test quota-2.2.2 { set ::quota } {4096 5120}
+do_test quota-2.2.3 { file size test.db } {5120}
+unset ::quota_request_ok
+
+do_test quota-2.3.1 {
+ sqlite3 db2 bak.db
+ db2 close
+} {}
+
+do_test quota-2.4.1 {
+ sqlite3_quota_shutdown
+} {SQLITE_MISUSE}
+set ::quota [list]
+do_test quota-2.4.2 {
+ catchsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }
+} {1 {database or disk is full}}
+do_test quota-2.4.3 { set ::quota } {5120 6144}
+do_test quota-2.4.4 { file size test.db } {5120}
+do_test quota-2.4.99 {
+ db close
+ sqlite3_quota_shutdown
+} {SQLITE_OK}
+
+#-------------------------------------------------------------------------
+# Try some tests with more than one connection to a database file. Still
+# in rollback mode.
+#
+# quota-3.1.*: Two connections to a single database file.
+#
+# quota-3.2.*: Two connections to each of several database files (that
+# are in the same quota group).
+#
+proc quota_check {filename limitvar size} {
+ upvar $limitvar limit
+ lappend ::quota [set limit] $size
+ if {[info exists ::quota_request_ok]} { set limit $size }
+}
+
+do_test quota-3.1.1 {
+ forcedelete test.db
+ sqlite3_quota_initialize "" 1
+ sqlite3_quota_set *test.db 4096 quota_check
+} {SQLITE_OK}
+do_test quota-3.1.2 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = delete;
+ PRAGMA auto_vacuum = off;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ }
+ file size test.db
+} {3072}
+do_test quota-3.1.3 {
+ sqlite3 db2 test.db
+ set ::quota [list]
+ execsql { CREATE TABLE t2(a, b) } db2
+ set ::quota
+} {}
+do_test quota-3.1.4 {
+ catchsql { CREATE TABLE t3(a, b) }
+} {1 {database or disk is full}}
+do_test quota-3.1.5 {
+ set ::quota_request_ok 1
+ execsql { CREATE TABLE t3(a, b) }
+} {}
+do_test quota-3.1.6 {
+ db close
+ db2 close
+ sqlite3_quota_set *test.db 0 {}
+} {SQLITE_OK}
+
+do_test quota-3.2.1 {
+ delete_file force test.db test2.db
+
+ sqlite3_quota_set * 4096 {}
+ sqlite3 db1a test.db
+ sqlite3 db2a test2.db
+
+ foreach db {db1a db2a} {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = delete;
+ PRAGMA auto_vacuum = off;
+ CREATE TABLE t1(a, b);
+ } $db
+ }
+
+ sqlite3 db1b test.db
+ sqlite3 db2b test2.db
+
+ list [file size test.db] [file size test2.db]
+} {2048 2048}
+
+catch { unset ::quota_request_ok }
+
+do_test quota-3.2.2 { execsql { INSERT INTO t1 VALUES('x', 'y') } db1a } {}
+do_test quota-3.2.3 { execsql { INSERT INTO t1 VALUES('v', 'w') } db1b } {}
+do_test quota-3.2.4 { execsql { INSERT INTO t1 VALUES('t', 'u') } db2a } {}
+do_test quota-3.2.5 { execsql { INSERT INTO t1 VALUES('r', 's') } db2b } {}
+
+do_test quota-3.2.6 {
+ catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1a
+} {1 {database or disk is full}}
+do_test quota-3.2.7 {
+ catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1b
+} {1 {database or disk is full}}
+do_test quota-3.2.8 {
+ catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a
+} {1 {database or disk is full}}
+do_test quota-3.2.9 {
+ catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b
+} {1 {database or disk is full}}
+
+set ::quota [list]
+proc quota_callback {file limitvar size} {
+ upvar $limitvar limit
+ if {$::tcl_platform(platform)=="windows"} {
+ set file [ lindex [string map {\\ \/} $file] 0 ]
+ }
+ lappend ::quota $file $size
+ set limit 0
+}
+sqlite3_quota_set * 4096 quota_callback
+do_test quota-3.3.1 {
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1a
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1b
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b
+ set ::quota
+} [list [file join [pwd] test.db] 5120]
+
+do_test quota-3.2.X {
+ foreach db {db1a db2a db2b db1b} { catch { $db close } }
+ sqlite3_quota_set * 0 {}
+} {SQLITE_OK}
+
+#-------------------------------------------------------------------------
+# Quotas are deleted when unused and when their limit is set to zero
+#
+
+# Return a list of all currently defined quotas. Each quota is identified
+# by its pattern.
+proc quota_list {} {
+ set allq {}
+ foreach q [sqlite3_quota_dump] {
+ lappend allq [lindex $q 0]
+ }
+ return [lsort $allq]
+}
+proc quota_size {name} {
+ set allq {}
+ foreach q [sqlite3_quota_dump] {
+ if {[lindex $q 0]==$name} {return [lindex $q 2]}
+ }
+ return 0
+}
+
+do_test quota-4.1.1 {
+ sqlite3_quota_set *test.db 0 {}
+ quota_list
+} {}
+do_test quota-4.1.2 {
+ sqlite3_quota_set *test.db 4096 {}
+ quota_list
+} {*test.db}
+do_test quota-4.1.3 {
+ sqlite3_quota_set *test2.db 0 {}
+ quota_list
+} {*test.db}
+do_test quota-4.1.4 {
+ sqlite3_quota_set *test2.db 100000 {}
+ quota_list
+} {*test.db *test2.db}
+do_test quota-4.1.5 {
+ sqlite3_quota_set *test.db 0 {}
+ quota_list
+} {*test2.db}
+do_test quota-4.1.6 {
+ forcedelete test2.db test2.db-journal test2.db-wal
+ sqlite3 db test2.db
+ db eval {CREATE TABLE t2(x); INSERT INTO t2 VALUES('tab-t2');}
+ quota_list
+} {*test2.db}
+do_test quota-4.1.7 {
+ catchsql {INSERT INTO t2 VALUES(zeroblob(200000))}
+} {1 {database or disk is full}}
+do_test quota-4.1.8 {
+ sqlite3 db2 test2.db
+ db2 eval {SELECT * FROM t2}
+} {tab-t2}
+do_test quota-4.1.9 {
+ sqlite3_quota_set *test2.db 0 {}
+ catchsql {INSERT INTO t2 VALUES(zeroblob(200000))}
+} {0 {}}
+do_test quota-4.1.10 {
+ quota_list
+} {*test2.db}
+do_test quota-4.1.11 {
+ db2 close
+ quota_list
+} {*test2.db}
+do_test quota-4.1.12 {
+ db close
+ quota_list
+} {}
+
+do_test quota-4.2.1 {
+ sqlite3_quota_set A 1000 {}
+ sqlite3_quota_set B 1000 {}
+ sqlite3_quota_set C 1000 {}
+ sqlite3_quota_set D 1000 {}
+ quota_list
+} {A B C D}
+do_test quota-4.2.2 {
+ sqlite3_quota_set C 0 {}
+ sqlite3_quota_set B 0 {}
+ quota_list
+} {A D}
+do_test quota-4.2.3 {
+ sqlite3_quota_set A 0 {}
+ sqlite3_quota_set D 0 {}
+ quota_list
+} {}
+do_test quota-4.2.4 {
+ sqlite3_quota_set A 1000 {}
+ sqlite3_quota_set B 1000 {}
+ sqlite3_quota_set C 1000 {}
+ sqlite3_quota_set A 0 {}
+ sqlite3_quota_set B 0 {}
+ sqlite3_quota_set C 0 {}
+ quota_list
+} {}
+do_test quota-4.2.5 {
+ sqlite3_quota_set A 1000 {}
+ sqlite3_quota_set B 1000 {}
+ sqlite3_quota_set C 1000 {}
+ sqlite3_quota_set C 0 {}
+ sqlite3_quota_set B 0 {}
+ sqlite3_quota_set A 0 {}
+ quota_list
+} {}
+
+do_test quota-4.3.1 {
+ sqlite3_quota_set A 1000 quota_callback
+ sqlite3 db A
+ sqlite3_quota_set A 0 quota_callback
+ db close
+ quota_list
+} {}
+
+unset -nocomplain quotagroup
+if {$tcl_platform(platform)=="windows"} {
+ set quotagroup *\\quota-test-A?.db
+} else {
+ set quotagroup */quota-test-A?.db
+}
+foreach file [glob -nocomplain quota-test-A*] {
+ forcedelete $file
+}
+do_test quota-4.4.1 {
+ set ::quota {}
+ sqlite3_quota_set $::quotagroup 10000 quota_callback
+ file delete -force ./quota-test-A1.db ./quota-test-A2.db
+ sqlite3 db ./quota-test-A1.db
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(5000));
+ }
+ quota_list
+} [list $quotagroup]
+do_test quota-4.4.2 {
+ expr {$::quota==""}
+} {1}
+do_test quota-4.4.3 {
+ db close
+ sqlite3 db ./quota-test-A2.db
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(5000));
+ }
+ quota_list
+} [list $quotagroup]
+do_test quota-4.4.4 {
+ expr {$::quota!=""}
+} {1}
+do_test quota-4.4.5 {
+ db close
+ sqlite3_quota_set $::quotagroup 0 {}
+ sqlite3_quota_dump
+} {}
+do_test quota-4.4.6 {
+ sqlite3_quota_set $quotagroup 10000 quota_callback
+ sqlite3 db quota-test-A1.db
+ db eval {SELECT count(*) FROM sqlite_master}
+ quota_size $quotagroup
+} [file size quota-test-A1.db]
+do_test quota-4.4.7 {
+ sqlite3_quota_file quota-test-A2.db
+ quota_size $::quotagroup
+} [expr {[file size quota-test-A1.db]+[file size quota-test-A2.db]}]
+
+unset -nocomplain quotagroup
+if {$tcl_platform(platform)=="windows"} {
+ set quotagroup *\\quota-test-B*
+} else {
+ set quotagroup */quota-test-B*
+}
+foreach file [glob -nocomplain quota-test-B*] {
+ forcedelete $file
+}
+do_test quota-4.5.1 {
+ sqlite3_quota_set $::quotagroup 100000 quota_callback
+ quota_size $::quotagroup
+} {0}
+do_test quota-4.5.2 {
+ sqlite3_quota_file quota-test-B1.txt
+ quota_size $::quotagroup
+} {0}
+proc add_to_file {name n} {
+ set out [open $name a]
+ fconfigure $out -translation binary
+ puts -nonewline $out [string repeat x $n]
+ close $out
+}
+do_test quota-4.5.3 {
+ add_to_file quota-test-B1.txt 123
+ sqlite3_quota_file quota-test-B1.txt
+ quota_size $::quotagroup
+} {123}
+do_test quota-4.5.4 {
+ add_to_file quota-test-B2.txt 234
+ sqlite3_quota_file quota-test-B2.txt
+ quota_size $::quotagroup
+} {357}
+do_test quota-4.5.5 {
+ add_to_file quota-test-B1.txt 2000
+ sqlite3_quota_file quota-test-B1.txt
+ quota_size $::quotagroup
+} {2357}
+do_test quota-4.5.6 {
+ forcedelete quota-test-B1.txt
+ sqlite3_quota_file quota-test-B1.txt
+ quota_size $::quotagroup
+} {234}
+do_test quota-4.5.7 {
+ forcedelete quota-test-B2.txt
+ sqlite3_quota_file quota-test-B2.txt
+ quota_size $::quotagroup
+} {0}
+do_test quota-4.5.8 {
+ add_to_file quota-test-B3.txt 1234
+ sqlite3_quota_file quota-test-B3.txt
+ quota_size $::quotagroup
+} {1234}
+do_test quota-4.5.9 {
+ sqlite3_quota_set $quotagroup 0 {}
+ quota_size $::quotagroup
+} {0}
+
+do_test quota-4.9.1 {
+ db close
+ sqlite3_quota_set A 1000 quota_callback
+ sqlite3_quota_shutdown
+} {SQLITE_OK}
+do_test quota-4.9.2 {
+ quota_list
+} {}
+
+#-------------------------------------------------------------------------
+# The following tests test that the quota VFS handles malloc and IO
+# errors.
+#
+
+sqlite3_quota_initialize "" 1
+sqlite3_quota_set *test.db 4096 {}
+
+do_faultsim_test quota-5.1 -prep {
+ catch {db close}
+} -body {
+ sqlite3 db test2.db
+}
+do_faultsim_test quota-5.2 -prep {
+ catch {db close}
+} -body {
+ sqlite3 db test.db
+}
+
+catch { db close }
+forcedelete test.db
+
+do_test quota-5.3.prep {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(10, zeroblob(1200));
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test quota-5.3 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { DELETE FROM t1 }
+}
+
+do_test quota-5.4.1 {
+ catch { db close }
+ forcedelete test.db
+ file mkdir test.db
+ list [catch { sqlite3 db test.db } msg] $msg
+} {1 {unable to open database file}}
+
+do_faultsim_test quota-5.5 -prep {
+ catch { sqlite3_quota_shutdown }
+} -body {
+ sqlite3_quota_initialize "" 1
+}
+
+do_faultsim_test quota-5.6 -prep {
+ catch { sqlite3_quota_shutdown }
+ sqlite3_quota_initialize "" 1
+} -body {
+ sqlite3_quota_set * 4096 {}
+}
+
+catch { sqlite3_quota_shutdown }
+finish_test
diff --git a/test/quote.test b/test/quote.test
new file mode 100644
index 0000000..f13d6f9
--- /dev/null
+++ b/test/quote.test
@@ -0,0 +1,89 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is the ability to specify table and column names
+# as quoted strings.
+#
+# $Id: quote.test,v 1.7 2007/04/25 11:32:30 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table with a strange name and with strange column names.
+#
+do_test quote-1.0 {
+ catchsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );}
+} {0 {}}
+
+# Insert, update and query the table.
+#
+do_test quote-1.1 {
+ catchsql {INSERT INTO '@abc' VALUES(5,'hello')}
+} {0 {}}
+do_test quote-1.2.1 {
+ catchsql {SELECT * FROM '@abc'}
+} {0 {5 hello}}
+do_test quote-1.2.2 {
+ catchsql {SELECT * FROM [@abc]} ;# SqlServer compatibility
+} {0 {5 hello}}
+do_test quote-1.2.3 {
+ catchsql {SELECT * FROM `@abc`} ;# MySQL compatibility
+} {0 {5 hello}}
+do_test quote-1.3 {
+ catchsql {
+ SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'
+ }
+} {0 {hello 10}}
+do_test quote-1.3.1 {
+ catchsql {
+ SELECT '!pqr', '#xyz'+5 FROM '@abc'
+ }
+} {0 {!pqr 5}}
+do_test quote-1.3.2 {
+ catchsql {
+ SELECT "!pqr", "#xyz"+5 FROM '@abc'
+ }
+} {0 {hello 10}}
+do_test quote-1.3.3 {
+ catchsql {
+ SELECT [!pqr], `#xyz`+5 FROM '@abc'
+ }
+} {0 {hello 10}}
+do_test quote-1.3.4 {
+ set r [catch {
+ execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
+ } msg ]
+ lappend r $msg
+} {0 {hello 10}}
+do_test quote-1.4 {
+ set r [catch {
+ execsql {UPDATE '@abc' SET '#xyz'=11}
+ } msg ]
+ lappend r $msg
+} {0 {}}
+do_test quote-1.5 {
+ set r [catch {
+ execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
+ } msg ]
+ lappend r $msg
+} {0 {hello 16}}
+
+# Drop the table with the strange name.
+#
+do_test quote-1.6 {
+ set r [catch {
+ execsql {DROP TABLE '@abc'}
+ } msg ]
+ lappend r $msg
+} {0 {}}
+
+
+finish_test
diff --git a/test/randexpr1.tcl b/test/randexpr1.tcl
new file mode 100644
index 0000000..37ebf53
--- /dev/null
+++ b/test/randexpr1.tcl
@@ -0,0 +1,342 @@
+# Run this TCL script to generate thousands of test cases containing
+# complicated expressions.
+#
+# The generated tests are intended to verify expression evaluation
+# in SQLite against expression evaluation TCL.
+#
+
+# Terms of the $intexpr list each contain two sub-terms.
+#
+# * An SQL expression template
+# * The equivalent TCL expression
+#
+# EXPR is replaced by an integer subexpression. BOOL is replaced
+# by a boolean subexpression.
+#
+set intexpr {
+ {11 wide(11)}
+ {13 wide(13)}
+ {17 wide(17)}
+ {19 wide(19)}
+ {a $a}
+ {b $b}
+ {c $c}
+ {d $d}
+ {e $e}
+ {f $f}
+ {t1.a $a}
+ {t1.b $b}
+ {t1.c $c}
+ {t1.d $d}
+ {t1.e $e}
+ {t1.f $f}
+ {(EXPR) (EXPR)}
+ {{ -EXPR} {-EXPR}}
+ {+EXPR +EXPR}
+ {~EXPR ~EXPR}
+ {EXPR+EXPR EXPR+EXPR}
+ {EXPR-EXPR EXPR-EXPR}
+ {EXPR*EXPR EXPR*EXPR}
+ {EXPR+EXPR EXPR+EXPR}
+ {EXPR-EXPR EXPR-EXPR}
+ {EXPR*EXPR EXPR*EXPR}
+ {EXPR+EXPR EXPR+EXPR}
+ {EXPR-EXPR EXPR-EXPR}
+ {EXPR*EXPR EXPR*EXPR}
+ {{EXPR | EXPR} {EXPR | EXPR}}
+ {(abs(EXPR)/abs(EXPR)) (abs(EXPR)/abs(EXPR))}
+ {
+ {case when BOOL then EXPR else EXPR end}
+ {((BOOL)?EXPR:EXPR)}
+ }
+ {
+ {case when BOOL then EXPR when BOOL then EXPR else EXPR end}
+ {((BOOL)?EXPR:((BOOL)?EXPR:EXPR))}
+ }
+ {
+ {case EXPR when EXPR then EXPR else EXPR end}
+ {(((EXPR)==(EXPR))?EXPR:EXPR)}
+ }
+ {
+ {(select AGG from t1)}
+ {(AGG)}
+ }
+ {
+ {coalesce((select max(EXPR) from t1 where BOOL),EXPR)}
+ {[coalesce_subquery [expr {EXPR}] [expr {BOOL}] [expr {EXPR}]]}
+ }
+ {
+ {coalesce((select EXPR from t1 where BOOL),EXPR)}
+ {[coalesce_subquery [expr {EXPR}] [expr {BOOL}] [expr {EXPR}]]}
+ }
+}
+
+# The $boolexpr list contains terms that show both an SQL boolean
+# expression and its equivalent TCL.
+#
+set boolexpr {
+ {EXPR=EXPR ((EXPR)==(EXPR))}
+ {EXPR<EXPR ((EXPR)<(EXPR))}
+ {EXPR>EXPR ((EXPR)>(EXPR))}
+ {EXPR<=EXPR ((EXPR)<=(EXPR))}
+ {EXPR>=EXPR ((EXPR)>=(EXPR))}
+ {EXPR<>EXPR ((EXPR)!=(EXPR))}
+ {
+ {EXPR between EXPR and EXPR}
+ {[betweenop [expr {EXPR}] [expr {EXPR}] [expr {EXPR}]]}
+ }
+ {
+ {EXPR not between EXPR and EXPR}
+ {(![betweenop [expr {EXPR}] [expr {EXPR}] [expr {EXPR}]])}
+ }
+ {
+ {EXPR in (EXPR,EXPR,EXPR)}
+ {([inop [expr {EXPR}] [expr {EXPR}] [expr {EXPR}] [expr {EXPR}]])}
+ }
+ {
+ {EXPR not in (EXPR,EXPR,EXPR)}
+ {(![inop [expr {EXPR}] [expr {EXPR}] [expr {EXPR}] [expr {EXPR}]])}
+ }
+ {
+ {EXPR in (select EXPR from t1 union select EXPR from t1)}
+ {[inop [expr {EXPR}] [expr {EXPR}] [expr {EXPR}]]}
+ }
+ {
+ {EXPR in (select AGG from t1 union select AGG from t1)}
+ {[inop [expr {EXPR}] [expr {AGG}] [expr {AGG}]]}
+ }
+ {
+ {exists(select 1 from t1 where BOOL)}
+ {(BOOL)}
+ }
+ {
+ {not exists(select 1 from t1 where BOOL)}
+ {!(BOOL)}
+ }
+ {{not BOOL} !BOOL}
+ {{BOOL and BOOL} {BOOL tcland BOOL}}
+ {{BOOL or BOOL} {BOOL || BOOL}}
+ {{BOOL and BOOL} {BOOL tcland BOOL}}
+ {{BOOL or BOOL} {BOOL || BOOL}}
+ {(BOOL) (BOOL)}
+ {(BOOL) (BOOL)}
+}
+
+# Aggregate expressions
+#
+set aggexpr {
+ {count(*) wide(1)}
+ {{count(distinct EXPR)} {[one {EXPR}]}}
+ {{cast(avg(EXPR) AS integer)} (EXPR)}
+ {min(EXPR) (EXPR)}
+ {max(EXPR) (EXPR)}
+ {(AGG) (AGG)}
+ {{ -AGG} {-AGG}}
+ {+AGG +AGG}
+ {~AGG ~AGG}
+ {abs(AGG) abs(AGG)}
+ {AGG+AGG AGG+AGG}
+ {AGG-AGG AGG-AGG}
+ {AGG*AGG AGG*AGG}
+ {{AGG | AGG} {AGG | AGG}}
+ {
+ {case AGG when AGG then AGG else AGG end}
+ {(((AGG)==(AGG))?AGG:AGG)}
+ }
+}
+
+# Convert a string containing EXPR, AGG, and BOOL into a string
+# that contains nothing but X, Y, and Z.
+#
+proc extract_vars {a} {
+ regsub -all {EXPR} $a X a
+ regsub -all {AGG} $a Y a
+ regsub -all {BOOL} $a Z a
+ regsub -all {[^XYZ]} $a {} a
+ return $a
+}
+
+
+# Test all templates to make sure the number of EXPR, AGG, and BOOL
+# expressions match.
+#
+foreach term [concat $aggexpr $intexpr $boolexpr] {
+ foreach {a b} $term break
+ if {[extract_vars $a]!=[extract_vars $b]} {
+ error "mismatch: $term"
+ }
+}
+
+# Generate a random expression according to the templates given above.
+# If the argument is EXPR or omitted, then an integer expression is
+# generated. If the argument is BOOL then a boolean expression is
+# produced.
+#
+proc generate_expr {{e EXPR}} {
+ set tcle $e
+ set ne [llength $::intexpr]
+ set nb [llength $::boolexpr]
+ set na [llength $::aggexpr]
+ set div 2
+ set mx 50
+ set i 0
+ while {1} {
+ set cnt 0
+ set re [lindex $::intexpr [expr {int(rand()*$ne)}]]
+ incr cnt [regsub {EXPR} $e [lindex $re 0] e]
+ regsub {EXPR} $tcle [lindex $re 1] tcle
+ set rb [lindex $::boolexpr [expr {int(rand()*$nb)}]]
+ incr cnt [regsub {BOOL} $e [lindex $rb 0] e]
+ regsub {BOOL} $tcle [lindex $rb 1] tcle
+ set ra [lindex $::aggexpr [expr {int(rand()*$na)}]]
+ incr cnt [regsub {AGG} $e [lindex $ra 0] e]
+ regsub {AGG} $tcle [lindex $ra 1] tcle
+
+ if {$cnt==0} break
+ incr i $cnt
+
+ set v1 [extract_vars $e]
+ if {$v1!=[extract_vars $tcle]} {
+ exit
+ }
+
+ if {$i+[string length $v1]>=$mx} {
+ set ne [expr {$ne/$div}]
+ set nb [expr {$nb/$div}]
+ set na [expr {$na/$div}]
+ set div 1
+ set mx [expr {$mx*1000}]
+ }
+ }
+ regsub -all { tcland } $tcle { \&\& } tcle
+ return [list $e $tcle]
+}
+
+# Implementation of routines used to implement the IN and BETWEEN
+# operators.
+proc inop {lhs args} {
+ foreach a $args {
+ if {$a==$lhs} {return 1}
+ }
+ return 0
+}
+proc betweenop {lhs first second} {
+ return [expr {$lhs>=$first && $lhs<=$second}]
+}
+proc coalesce_subquery {a b e} {
+ if {$b} {
+ return $a
+ } else {
+ return $e
+ }
+}
+proc one {args} {
+ return 1
+}
+
+# Begin generating the test script:
+#
+puts {# 2008 December 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file tests randomly generated SQL expressions. The expressions
+# are generated by a TCL script. The same TCL script also computes the
+# correct value of the expression. So, from one point of view, this
+# file verifies the expression evaluation logic of SQLite against the
+# expression evaluation logic of TCL.
+#
+# An early version of this script is how bug #3541 was detected.
+#
+# $Id: randexpr1.tcl,v 1.1 2008/12/15 16:33:30 drh Exp $
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create test data
+#
+do_test randexpr1-1.1 {
+ db eval {
+ CREATE TABLE t1(a,b,c,d,e,f);
+ INSERT INTO t1 VALUES(100,200,300,400,500,600);
+ SELECT * FROM t1
+ }
+} {100 200 300 400 500 600}
+}
+
+# Test data for TCL evaluation.
+#
+set a [expr {wide(100)}]
+set b [expr {wide(200)}]
+set c [expr {wide(300)}]
+set d [expr {wide(400)}]
+set e [expr {wide(500)}]
+set f [expr {wide(600)}]
+
+# A procedure to generate a test case.
+#
+set tn 0
+proc make_test_case {sql result} {
+ global tn
+ incr tn
+ puts "do_test randexpr-2.$tn {\n db eval {$sql}\n} {$result}"
+}
+
+# Generate many random test cases.
+#
+expr srand(0)
+for {set i 0} {$i<1000} {incr i} {
+ while {1} {
+ foreach {sqle tcle} [generate_expr EXPR] break;
+ if {[catch {expr $tcle} ans]} {
+ #puts stderr [list $tcle]
+ #puts stderr ans=$ans
+ if {![regexp {divide by zero} $ans]} exit
+ continue
+ }
+ set len [string length $sqle]
+ if {$len<100 || $len>2000} continue
+ if {[info exists seen($sqle)]} continue
+ set seen($sqle) 1
+ break
+ }
+ while {1} {
+ foreach {sqlb tclb} [generate_expr BOOL] break;
+ if {[catch {expr $tclb} bans]} {
+ #puts stderr [list $tclb]
+ #puts stderr bans=$bans
+ if {![regexp {divide by zero} $bans]} exit
+ continue
+ }
+ break
+ }
+ if {$bans} {
+ make_test_case "SELECT $sqle FROM t1 WHERE $sqlb" $ans
+ make_test_case "SELECT $sqle FROM t1 WHERE NOT ($sqlb)" {}
+ } else {
+ make_test_case "SELECT $sqle FROM t1 WHERE $sqlb" {}
+ make_test_case "SELECT $sqle FROM t1 WHERE NOT ($sqlb)" $ans
+ }
+ if {[regexp { \| } $sqle]} {
+ regsub -all { \| } $sqle { \& } sqle
+ regsub -all { \| } $tcle { \& } tcle
+ if {[catch {expr $tcle} ans]==0} {
+ if {$bans} {
+ make_test_case "SELECT $sqle FROM t1 WHERE $sqlb" $ans
+ } else {
+ make_test_case "SELECT $sqle FROM t1 WHERE NOT ($sqlb)" $ans
+ }
+ }
+ }
+}
+
+# Terminate the test script
+#
+puts {finish_test}
diff --git a/test/randexpr1.test b/test/randexpr1.test
new file mode 100644
index 0000000..10a1d17
--- /dev/null
+++ b/test/randexpr1.test
@@ -0,0 +1,7832 @@
+# 2008 December 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file tests randomly generated SQL expressions. The expressions
+# are generated by a TCL script. The same TCL script also computes the
+# correct value of the expression. So, from one point of view, this
+# file verifies the expression evaluation logic of SQLite against the
+# expression evaluation logic of TCL.
+#
+# An early version of this script is how bug #3541 was detected.
+#
+# $Id: randexpr1.test,v 1.1 2008/12/15 16:33:30 drh Exp $
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create test data
+#
+do_test randexpr1-1.1 {
+ db eval {
+ CREATE TABLE t1(a,b,c,d,e,f);
+ INSERT INTO t1 VALUES(100,200,300,400,500,600);
+ SELECT * FROM t1
+ }
+} {100 200 300 400 500 600}
+
+do_test randexpr-2.1 {
+ db eval {SELECT coalesce((select 11 from t1 where 19 in (t1.b,+11,coalesce((select max((abs(17)/abs(t1.f))) from t1 where ((abs(t1.f)/abs(t1.b)) in (select case (min(t1.a | d*d)+(abs(count(*)-count(*)+ -count(*)*max( -t1.c))-max(f))) when -count(distinct 19) then ((count(*))) else max(13) end from t1 union select count(distinct b) from t1)) or 19 in (t1.a,t1.c,17)),17) | 17)),13) FROM t1 WHERE not not c=a-+(select case ~case -~+count(distinct (select count(distinct t1.a)*max(13) from t1))+max( -19*f)*max(f)*max(f)* -count(distinct d)-(count(distinct 11)) | max(t1.f)*count(*) when count(distinct b) then count(distinct t1.b) else -min(t1.f) end*cast(avg(11) AS integer) when max(t1.f) then max(c) else count(*) end from t1)+d}
+} {}
+do_test randexpr-2.2 {
+ db eval {SELECT coalesce((select 11 from t1 where 19 in (t1.b,+11,coalesce((select max((abs(17)/abs(t1.f))) from t1 where ((abs(t1.f)/abs(t1.b)) in (select case (min(t1.a | d*d)+(abs(count(*)-count(*)+ -count(*)*max( -t1.c))-max(f))) when -count(distinct 19) then ((count(*))) else max(13) end from t1 union select count(distinct b) from t1)) or 19 in (t1.a,t1.c,17)),17) | 17)),13) FROM t1 WHERE NOT (not not c=a-+(select case ~case -~+count(distinct (select count(distinct t1.a)*max(13) from t1))+max( -19*f)*max(f)*max(f)* -count(distinct d)-(count(distinct 11)) | max(t1.f)*count(*) when count(distinct b) then count(distinct t1.b) else -min(t1.f) end*cast(avg(11) AS integer) when max(t1.f) then max(c) else count(*) end from t1)+d)}
+} {13}
+do_test randexpr-2.3 {
+ db eval {SELECT coalesce((select 11 from t1 where 19 in (t1.b,+11,coalesce((select max((abs(17)/abs(t1.f))) from t1 where ((abs(t1.f)/abs(t1.b)) in (select case (min(t1.a & d*d)+(abs(count(*)-count(*)+ -count(*)*max( -t1.c))-max(f))) when -count(distinct 19) then ((count(*))) else max(13) end from t1 union select count(distinct b) from t1)) or 19 in (t1.a,t1.c,17)),17) & 17)),13) FROM t1 WHERE NOT (not not c=a-+(select case ~case -~+count(distinct (select count(distinct t1.a)*max(13) from t1))+max( -19*f)*max(f)*max(f)* -count(distinct d)-(count(distinct 11)) | max(t1.f)*count(*) when count(distinct b) then count(distinct t1.b) else -min(t1.f) end*cast(avg(11) AS integer) when max(t1.f) then max(c) else count(*) end from t1)+d)}
+} {13}
+do_test randexpr-2.4 {
+ db eval {SELECT t1.c*19-t1.f*19+coalesce((select 17 from t1 where e in (f,case (select cast(avg(t1.a) AS integer) from t1)-t1.d when coalesce((select +case when not exists(select 1 from t1 where 17<>t1.f and ((a))<t1.b) then t1.c when c not between b and 11 then case when t1.c<f then t1.b when e in (t1.d,t1.d, -e) then d else t1.b end else f end+11 from t1 where exists(select 1 from t1 where t1.f in (select (count(distinct f)) from t1 union select max(11) from t1))),e) then 11 else t1.a end,t1.d)),13)*b+b FROM t1 WHERE ~t1.b<case when t1.b+t1.c in (select -count(distinct 17+coalesce((select max( -f+t1.c-d) from t1 where (19>=a) and t1.b between f and 13),t1.a))+case abs(+(max(19))) | count(distinct t1.e) | count(distinct 19) when count(*) then (max(a)) else count(distinct d) end from t1 union select (count(*)) from t1) and t1.b>=19 then d when t1.b in (select d from t1 union select c from t1) then t1.e else a end}
+} {-2900}
+do_test randexpr-2.5 {
+ db eval {SELECT t1.c*19-t1.f*19+coalesce((select 17 from t1 where e in (f,case (select cast(avg(t1.a) AS integer) from t1)-t1.d when coalesce((select +case when not exists(select 1 from t1 where 17<>t1.f and ((a))<t1.b) then t1.c when c not between b and 11 then case when t1.c<f then t1.b when e in (t1.d,t1.d, -e) then d else t1.b end else f end+11 from t1 where exists(select 1 from t1 where t1.f in (select (count(distinct f)) from t1 union select max(11) from t1))),e) then 11 else t1.a end,t1.d)),13)*b+b FROM t1 WHERE NOT (~t1.b<case when t1.b+t1.c in (select -count(distinct 17+coalesce((select max( -f+t1.c-d) from t1 where (19>=a) and t1.b between f and 13),t1.a))+case abs(+(max(19))) | count(distinct t1.e) | count(distinct 19) when count(*) then (max(a)) else count(distinct d) end from t1 union select (count(*)) from t1) and t1.b>=19 then d when t1.b in (select d from t1 union select c from t1) then t1.e else a end)}
+} {}
+do_test randexpr-2.6 {
+ db eval {SELECT case when case when not exists(select 1 from t1 where e not in (~t1.d,+case when t1.c<b then t1.e else t1.a end-11 | t1.f,c) or b in (select cast(avg(b) AS integer)*(~abs((count(*))))* -( -cast(avg(e) AS integer)) from t1 union select min(t1.c) from t1)) then t1.f when not exists(select 1 from t1 where not c<>d) then 17 else t1.e end in (a,t1.e,17) or (not exists(select 1 from t1 where a in (f,t1.c,t1.a))) then 11 else 13 end FROM t1 WHERE t1.b<case when exists(select 1 from t1 where not -(select min(t1.b*b*t1.a+t1.d)+abs(case count(*) | (cast(avg(c) AS integer)) when max(17) then min(c) else (min(13)) end)+min(e) from t1) not in (t1.c,f-d,11) and c not between (19) and e) then ~13*t1.a when 13 not in (t1.e,c,11) then b else t1.c end*c-t1.d}
+} {11}
+do_test randexpr-2.7 {
+ db eval {SELECT case when case when not exists(select 1 from t1 where e not in (~t1.d,+case when t1.c<b then t1.e else t1.a end-11 | t1.f,c) or b in (select cast(avg(b) AS integer)*(~abs((count(*))))* -( -cast(avg(e) AS integer)) from t1 union select min(t1.c) from t1)) then t1.f when not exists(select 1 from t1 where not c<>d) then 17 else t1.e end in (a,t1.e,17) or (not exists(select 1 from t1 where a in (f,t1.c,t1.a))) then 11 else 13 end FROM t1 WHERE NOT (t1.b<case when exists(select 1 from t1 where not -(select min(t1.b*b*t1.a+t1.d)+abs(case count(*) | (cast(avg(c) AS integer)) when max(17) then min(c) else (min(13)) end)+min(e) from t1) not in (t1.c,f-d,11) and c not between (19) and e) then ~13*t1.a when 13 not in (t1.e,c,11) then b else t1.c end*c-t1.d)}
+} {}
+do_test randexpr-2.8 {
+ db eval {SELECT case when case when not exists(select 1 from t1 where e not in (~t1.d,+case when t1.c<b then t1.e else t1.a end-11 & t1.f,c) or b in (select cast(avg(b) AS integer)*(~abs((count(*))))* -( -cast(avg(e) AS integer)) from t1 union select min(t1.c) from t1)) then t1.f when not exists(select 1 from t1 where not c<>d) then 17 else t1.e end in (a,t1.e,17) or (not exists(select 1 from t1 where a in (f,t1.c,t1.a))) then 11 else 13 end FROM t1 WHERE t1.b<case when exists(select 1 from t1 where not -(select min(t1.b*b*t1.a+t1.d)+abs(case count(*) | (cast(avg(c) AS integer)) when max(17) then min(c) else (min(13)) end)+min(e) from t1) not in (t1.c,f-d,11) and c not between (19) and e) then ~13*t1.a when 13 not in (t1.e,c,11) then b else t1.c end*c-t1.d}
+} {11}
+do_test randexpr-2.9 {
+ db eval {SELECT coalesce((select max(11- -19-f-t1.b+a) from t1 where exists(select 1 from t1 where 11-~(d)-c*a*~t1.a-t1.e-t1.e+coalesce((select coalesce((select t1.c from t1 where case (c) when d then e else 11 end=t1.f),t1.d) from t1 where (t1.d)>b), -11) | f+t1.f not in (((c)),b,13))),f) FROM t1 WHERE case when 19+c>=t1.a then t1.c when not case when not exists(select 1 from t1 where +f | b*b*19+19*13-a | case when t1.e not in (t1.f,t1.c,b) then 11 when 17>t1.c then a else e end<>e) then b when 17=t1.e then b else e end<>t1.b then a else d end-t1.b=(13)}
+} {}
+do_test randexpr-2.10 {
+ db eval {SELECT coalesce((select max(11- -19-f-t1.b+a) from t1 where exists(select 1 from t1 where 11-~(d)-c*a*~t1.a-t1.e-t1.e+coalesce((select coalesce((select t1.c from t1 where case (c) when d then e else 11 end=t1.f),t1.d) from t1 where (t1.d)>b), -11) | f+t1.f not in (((c)),b,13))),f) FROM t1 WHERE NOT (case when 19+c>=t1.a then t1.c when not case when not exists(select 1 from t1 where +f | b*b*19+19*13-a | case when t1.e not in (t1.f,t1.c,b) then 11 when 17>t1.c then a else e end<>e) then b when 17=t1.e then b else e end<>t1.b then a else d end-t1.b=(13))}
+} {-670}
+do_test randexpr-2.11 {
+ db eval {SELECT coalesce((select max(11- -19-f-t1.b+a) from t1 where exists(select 1 from t1 where 11-~(d)-c*a*~t1.a-t1.e-t1.e+coalesce((select coalesce((select t1.c from t1 where case (c) when d then e else 11 end=t1.f),t1.d) from t1 where (t1.d)>b), -11) & f+t1.f not in (((c)),b,13))),f) FROM t1 WHERE NOT (case when 19+c>=t1.a then t1.c when not case when not exists(select 1 from t1 where +f | b*b*19+19*13-a | case when t1.e not in (t1.f,t1.c,b) then 11 when 17>t1.c then a else e end<>e) then b when 17=t1.e then b else e end<>t1.b then a else d end-t1.b=(13))}
+} {-670}
+do_test randexpr-2.12 {
+ db eval {SELECT (abs(17)/abs(~case when (abs(t1.c* -(abs(case b | coalesce((select max(17*e*case when 11 in (select t1.b from t1 union select t1.c from t1) then 19 when d between f and t1.e then t1.e else t1.e end | b) from t1 where (13 not in (11,t1.d,e))),e)*a*d when 11 then e else d end*17)/abs(19)))/abs(t1.e))<>e then t1.b else t1.d end*(19))) FROM t1 WHERE exists(select 1 from t1 where t1.d+11 in (case t1.b++c when +a*(+case (select count(*) from t1) when 19 then t1.c else a end) then t1.a else case when (t1.b> -d) and not exists(select 1 from t1 where not exists(select 1 from t1 where (abs(f)/abs( -f*a+c*11))<>a)) then 13 else 19 end end,17,a)) or c=t1.d}
+} {}
+do_test randexpr-2.13 {
+ db eval {SELECT (abs(17)/abs(~case when (abs(t1.c* -(abs(case b | coalesce((select max(17*e*case when 11 in (select t1.b from t1 union select t1.c from t1) then 19 when d between f and t1.e then t1.e else t1.e end | b) from t1 where (13 not in (11,t1.d,e))),e)*a*d when 11 then e else d end*17)/abs(19)))/abs(t1.e))<>e then t1.b else t1.d end*(19))) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.d+11 in (case t1.b++c when +a*(+case (select count(*) from t1) when 19 then t1.c else a end) then t1.a else case when (t1.b> -d) and not exists(select 1 from t1 where not exists(select 1 from t1 where (abs(f)/abs( -f*a+c*11))<>a)) then 13 else 19 end end,17,a)) or c=t1.d)}
+} {0}
+do_test randexpr-2.14 {
+ db eval {SELECT (abs(17)/abs(~case when (abs(t1.c* -(abs(case b & coalesce((select max(17*e*case when 11 in (select t1.b from t1 union select t1.c from t1) then 19 when d between f and t1.e then t1.e else t1.e end & b) from t1 where (13 not in (11,t1.d,e))),e)*a*d when 11 then e else d end*17)/abs(19)))/abs(t1.e))<>e then t1.b else t1.d end*(19))) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.d+11 in (case t1.b++c when +a*(+case (select count(*) from t1) when 19 then t1.c else a end) then t1.a else case when (t1.b> -d) and not exists(select 1 from t1 where not exists(select 1 from t1 where (abs(f)/abs( -f*a+c*11))<>a)) then 13 else 19 end end,17,a)) or c=t1.d)}
+} {0}
+do_test randexpr-2.15 {
+ db eval {SELECT coalesce((select t1.c from t1 where e not between 19 and b*d or not exists(select 1 from t1 where t1.a not in (case when d not between b+~(t1.d)-case when ((t1.f<=t1.e) and -11<f) then e*(abs(t1.a)/abs((t1.c))) else c end+b and t1.e then e when not exists(select 1 from t1 where 11<17) then a else t1.f end,(c),c))),t1.d) FROM t1 WHERE t1.c*((select -count(distinct t1.a) | + -count(distinct t1.b)*cast(avg(a) AS integer)-cast(avg(13) AS integer) | ~abs(min(17)) | -min(c)*(count(distinct t1.e)) from t1)- -(abs(+t1.b-13)/abs(11)))+t1.f-coalesce((select max(f) from t1 where t1.d between c and t1.a),17)*a in (select 17 from t1 union select -17 from t1)}
+} {}
+do_test randexpr-2.16 {
+ db eval {SELECT coalesce((select t1.c from t1 where e not between 19 and b*d or not exists(select 1 from t1 where t1.a not in (case when d not between b+~(t1.d)-case when ((t1.f<=t1.e) and -11<f) then e*(abs(t1.a)/abs((t1.c))) else c end+b and t1.e then e when not exists(select 1 from t1 where 11<17) then a else t1.f end,(c),c))),t1.d) FROM t1 WHERE NOT (t1.c*((select -count(distinct t1.a) | + -count(distinct t1.b)*cast(avg(a) AS integer)-cast(avg(13) AS integer) | ~abs(min(17)) | -min(c)*(count(distinct t1.e)) from t1)- -(abs(+t1.b-13)/abs(11)))+t1.f-coalesce((select max(f) from t1 where t1.d between c and t1.a),17)*a in (select 17 from t1 union select -17 from t1))}
+} {400}
+do_test randexpr-2.17 {
+ db eval {SELECT +t1.f*~t1.c-coalesce((select max(~b) from t1 where t1.e+11-(abs(e+case d when b then case when f=(13) then (abs(13+b*t1.f)/abs(t1.c)) when d<=t1.e then 13 else a end else 19 end*13+f)/abs((a)))*17<=c),b)-13*c FROM t1 WHERE not exists(select 1 from t1 where coalesce((select max(case when case when exists(select 1 from t1 where ~t1.d+d in (select ~count(distinct 13) from t1 union select count(*)+~abs(+(~min(t1.a))) from t1)) then t1.e+t1.c else -(abs(t1.d)/abs(coalesce((select max(t1.d) from t1 where d not in (17,f,f)),11)*t1.c)) end<=(11) then 19 else (t1.e) end) from t1 where (13=11)),c) not between 13 and 19)}
+} {}
+do_test randexpr-2.18 {
+ db eval {SELECT +t1.f*~t1.c-coalesce((select max(~b) from t1 where t1.e+11-(abs(e+case d when b then case when f=(13) then (abs(13+b*t1.f)/abs(t1.c)) when d<=t1.e then 13 else a end else 19 end*13+f)/abs((a)))*17<=c),b)-13*c FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select max(case when case when exists(select 1 from t1 where ~t1.d+d in (select ~count(distinct 13) from t1 union select count(*)+~abs(+(~min(t1.a))) from t1)) then t1.e+t1.c else -(abs(t1.d)/abs(coalesce((select max(t1.d) from t1 where d not in (17,f,f)),11)*t1.c)) end<=(11) then 19 else (t1.e) end) from t1 where (13=11)),c) not between 13 and 19))}
+} {-184299}
+do_test randexpr-2.19 {
+ db eval {SELECT case when (a not in (t1.e,(+case when t1.b<=(abs(coalesce((select max(a+(select count(distinct (select max(((abs( -t1.d)/abs(a))) | t1.c)*min(t1.e) from t1)) from t1)) from t1 where +t1.f>e),17))/abs( - -17)) then 17 else t1.d end-t1.b-d) | -f,c)) then 11-t1.f when ( -13<e) then t1.d else a end FROM t1 WHERE t1.c not between ~case when case when (select - -abs( -case -count(distinct c) when count(*) then max(c) else count(distinct 13) end) | min(c) from t1) in (t1.f,b+11,19*t1.d) then 19 else a end*t1.b>13 or t1.e in (select (count(*)) from t1 union select cast(avg(t1.e) AS integer) from t1) or 19>17 and 13 not between 19 and 17 then (t1.f) when not t1.b<>t1.f or d<>b then t1.e else a end and c}
+} {}
+do_test randexpr-2.20 {
+ db eval {SELECT case when (a not in (t1.e,(+case when t1.b<=(abs(coalesce((select max(a+(select count(distinct (select max(((abs( -t1.d)/abs(a))) | t1.c)*min(t1.e) from t1)) from t1)) from t1 where +t1.f>e),17))/abs( - -17)) then 17 else t1.d end-t1.b-d) | -f,c)) then 11-t1.f when ( -13<e) then t1.d else a end FROM t1 WHERE NOT (t1.c not between ~case when case when (select - -abs( -case -count(distinct c) when count(*) then max(c) else count(distinct 13) end) | min(c) from t1) in (t1.f,b+11,19*t1.d) then 19 else a end*t1.b>13 or t1.e in (select (count(*)) from t1 union select cast(avg(t1.e) AS integer) from t1) or 19>17 and 13 not between 19 and 17 then (t1.f) when not t1.b<>t1.f or d<>b then t1.e else a end and c)}
+} {-589}
+do_test randexpr-2.21 {
+ db eval {SELECT case when (a not in (t1.e,(+case when t1.b<=(abs(coalesce((select max(a+(select count(distinct (select max(((abs( -t1.d)/abs(a))) & t1.c)*min(t1.e) from t1)) from t1)) from t1 where +t1.f>e),17))/abs( - -17)) then 17 else t1.d end-t1.b-d) & -f,c)) then 11-t1.f when ( -13<e) then t1.d else a end FROM t1 WHERE NOT (t1.c not between ~case when case when (select - -abs( -case -count(distinct c) when count(*) then max(c) else count(distinct 13) end) | min(c) from t1) in (t1.f,b+11,19*t1.d) then 19 else a end*t1.b>13 or t1.e in (select (count(*)) from t1 union select cast(avg(t1.e) AS integer) from t1) or 19>17 and 13 not between 19 and 17 then (t1.f) when not t1.b<>t1.f or d<>b then t1.e else a end and c)}
+} {-589}
+do_test randexpr-2.22 {
+ db eval {SELECT t1.a | case when e in (select (13) from t1 union select d from t1) then (17) when c*~case (17) when coalesce((select max(case when case when 19 in (13,t1.f,11) then t1.b else t1.b end | 11>t1.a then 11 else t1.b end-b) from t1 where (13 not in (a,19,b)) and t1.a not between -11 and t1.f),f) then e else t1.c end | a in (select 11 from t1 union select t1.d from t1) then 17 else t1.a end | f FROM t1 WHERE coalesce((select t1.a*t1.a from t1 where ~ -(abs((select abs(count(*))-count(distinct t1.d*11) from t1)*+b)/abs(~t1.c))+c not in (coalesce((select ~13*t1.a from t1 where f+(abs(d* -t1.f)/abs(t1.c))<=t1.b or not t1.a<=t1.c),t1.c),e,(t1.e))),(a))+11<>11}
+} {636}
+do_test randexpr-2.23 {
+ db eval {SELECT t1.a | case when e in (select (13) from t1 union select d from t1) then (17) when c*~case (17) when coalesce((select max(case when case when 19 in (13,t1.f,11) then t1.b else t1.b end | 11>t1.a then 11 else t1.b end-b) from t1 where (13 not in (a,19,b)) and t1.a not between -11 and t1.f),f) then e else t1.c end | a in (select 11 from t1 union select t1.d from t1) then 17 else t1.a end | f FROM t1 WHERE NOT (coalesce((select t1.a*t1.a from t1 where ~ -(abs((select abs(count(*))-count(distinct t1.d*11) from t1)*+b)/abs(~t1.c))+c not in (coalesce((select ~13*t1.a from t1 where f+(abs(d* -t1.f)/abs(t1.c))<=t1.b or not t1.a<=t1.c),t1.c),e,(t1.e))),(a))+11<>11)}
+} {}
+do_test randexpr-2.24 {
+ db eval {SELECT t1.a & case when e in (select (13) from t1 union select d from t1) then (17) when c*~case (17) when coalesce((select max(case when case when 19 in (13,t1.f,11) then t1.b else t1.b end & 11>t1.a then 11 else t1.b end-b) from t1 where (13 not in (a,19,b)) and t1.a not between -11 and t1.f),f) then e else t1.c end & a in (select 11 from t1 union select t1.d from t1) then 17 else t1.a end & f FROM t1 WHERE coalesce((select t1.a*t1.a from t1 where ~ -(abs((select abs(count(*))-count(distinct t1.d*11) from t1)*+b)/abs(~t1.c))+c not in (coalesce((select ~13*t1.a from t1 where f+(abs(d* -t1.f)/abs(t1.c))<=t1.b or not t1.a<=t1.c),t1.c),e,(t1.e))),(a))+11<>11}
+} {64}
+do_test randexpr-2.25 {
+ db eval {SELECT c*coalesce((select ~19-e from t1 where not exists(select 1 from t1 where case when t1.b<>(d) then case when exists(select 1 from t1 where not exists(select 1 from t1 where case t1.e when e*(11) then 13 else 11 end in (select t1.a from t1 union select 13 from t1))) then coalesce((select case when f in (select t1.c from t1 union select (t1.b) from t1) then f else a end from t1 where t1.f not between 17 and f), -f) else 11 end else (a) end*d not in (e,t1.c,t1.e))),t1.e)-a FROM t1 WHERE 19+(select cast(avg((abs(t1.d)/abs(coalesce((select max(+b-(t1.e+b+ -c)*19) from t1 where 11 not between t1.b and f), -17)))*(11)) AS integer) from t1)*f in (select count(*) from t1 union select case max(t1.d)-( -min(t1.d)*(+max(e))) when max(t1.a) then cast(avg(t1.d) AS integer)-(count(distinct t1.f))-( -cast(avg(f) AS integer)) else max(t1.e) end from t1)}
+} {}
+do_test randexpr-2.26 {
+ db eval {SELECT c*coalesce((select ~19-e from t1 where not exists(select 1 from t1 where case when t1.b<>(d) then case when exists(select 1 from t1 where not exists(select 1 from t1 where case t1.e when e*(11) then 13 else 11 end in (select t1.a from t1 union select 13 from t1))) then coalesce((select case when f in (select t1.c from t1 union select (t1.b) from t1) then f else a end from t1 where t1.f not between 17 and f), -f) else 11 end else (a) end*d not in (e,t1.c,t1.e))),t1.e)-a FROM t1 WHERE NOT (19+(select cast(avg((abs(t1.d)/abs(coalesce((select max(+b-(t1.e+b+ -c)*19) from t1 where 11 not between t1.b and f), -17)))*(11)) AS integer) from t1)*f in (select count(*) from t1 union select case max(t1.d)-( -min(t1.d)*(+max(e))) when max(t1.a) then cast(avg(t1.d) AS integer)-(count(distinct t1.f))-( -cast(avg(f) AS integer)) else max(t1.e) end from t1))}
+} {149900}
+do_test randexpr-2.27 {
+ db eval {SELECT (abs((select (case abs(min(t1.f)) | count(distinct e) when (~+count(*)+max(e)++abs(cast(avg(~19) AS integer))) then +cast(avg(c) AS integer) else ~ -max(+t1.b)+~max(19)*count(distinct a)*min(17) | max(t1.d) end) from t1))/abs(~c+(select -(count(distinct t1.e)) from t1)-11+t1.e)) FROM t1 WHERE 11>=t1.f}
+} {}
+do_test randexpr-2.28 {
+ db eval {SELECT (abs((select (case abs(min(t1.f)) | count(distinct e) when (~+count(*)+max(e)++abs(cast(avg(~19) AS integer))) then +cast(avg(c) AS integer) else ~ -max(+t1.b)+~max(19)*count(distinct a)*min(17) | max(t1.d) end) from t1))/abs(~c+(select -(count(distinct t1.e)) from t1)-11+t1.e)) FROM t1 WHERE NOT (11>=t1.f)}
+} {0}
+do_test randexpr-2.29 {
+ db eval {SELECT (abs((select (case abs(min(t1.f)) & count(distinct e) when (~+count(*)+max(e)++abs(cast(avg(~19) AS integer))) then +cast(avg(c) AS integer) else ~ -max(+t1.b)+~max(19)*count(distinct a)*min(17) & max(t1.d) end) from t1))/abs(~c+(select -(count(distinct t1.e)) from t1)-11+t1.e)) FROM t1 WHERE NOT (11>=t1.f)}
+} {1}
+do_test randexpr-2.30 {
+ db eval {SELECT (select +count(distinct case when 11=a or e<+t1.f+t1.c and not exists(select 1 from t1 where not t1.a-t1.b=~a and f<=coalesce((select max((e)) from t1 where +t1.f>=b),t1.d)*13) and t1.c>t1.e and t1.a<17 then f when a<c then t1.d else c end) from t1) FROM t1 WHERE t1.b=case t1.e | f+t1.d when case when t1.f | t1.e in (select -+min(case when t1.c in (select t1.b from t1 union select b-19*(abs(b)/abs(t1.b*case when not exists(select 1 from t1 where t1.a in (select ~cast(avg(d) AS integer) from t1 union select max(t1.f) from t1)) then ~(13) when -c=t1.b then t1.c else f end)) from t1) then e else 17 end) from t1 union select max((a)) from t1) then -b else t1.d end+13 then a else 13 end}
+} {}
+do_test randexpr-2.31 {
+ db eval {SELECT (select +count(distinct case when 11=a or e<+t1.f+t1.c and not exists(select 1 from t1 where not t1.a-t1.b=~a and f<=coalesce((select max((e)) from t1 where +t1.f>=b),t1.d)*13) and t1.c>t1.e and t1.a<17 then f when a<c then t1.d else c end) from t1) FROM t1 WHERE NOT (t1.b=case t1.e | f+t1.d when case when t1.f | t1.e in (select -+min(case when t1.c in (select t1.b from t1 union select b-19*(abs(b)/abs(t1.b*case when not exists(select 1 from t1 where t1.a in (select ~cast(avg(d) AS integer) from t1 union select max(t1.f) from t1)) then ~(13) when -c=t1.b then t1.c else f end)) from t1) then e else 17 end) from t1 union select max((a)) from t1) then -b else t1.d end+13 then a else 13 end)}
+} {1}
+do_test randexpr-2.32 {
+ db eval {SELECT coalesce((select (select max(t1.a)*(max(a))*max(t1.f*~11*case when b not in ((select min(19) from t1),b,coalesce((select max((t1.f)) from t1 where t1.c in (c,t1.b,(t1.f)) or t1.a<>(c)),b)*t1.b-t1.b) then d else t1.e end | f* -13-c) from t1) from t1 where not ~a<f), -19)+t1.d+b FROM t1 WHERE 13*t1.d between coalesce((select t1.d from t1 where b in (select t1.d from t1 union select case b*t1.f+t1.a*+coalesce((select t1.a from t1 where (not exists(select 1 from t1 where b*t1.c=13))),11)+t1.e when ~f then d+case b when e then f else t1.e end*13 else f end from t1)),19) and t1.d and 19 between 17 and e and a>a}
+} {}
+do_test randexpr-2.33 {
+ db eval {SELECT coalesce((select (select max(t1.a)*(max(a))*max(t1.f*~11*case when b not in ((select min(19) from t1),b,coalesce((select max((t1.f)) from t1 where t1.c in (c,t1.b,(t1.f)) or t1.a<>(c)),b)*t1.b-t1.b) then d else t1.e end | f* -13-c) from t1) from t1 where not ~a<f), -19)+t1.d+b FROM t1 WHERE NOT (13*t1.d between coalesce((select t1.d from t1 where b in (select t1.d from t1 union select case b*t1.f+t1.a*+coalesce((select t1.a from t1 where (not exists(select 1 from t1 where b*t1.c=13))),11)+t1.e when ~f then d+case b when e then f else t1.e end*13 else f end from t1)),19) and t1.d and 19 between 17 and e and a>a)}
+} {581}
+do_test randexpr-2.34 {
+ db eval {SELECT coalesce((select (select max(t1.a)*(max(a))*max(t1.f*~11*case when b not in ((select min(19) from t1),b,coalesce((select max((t1.f)) from t1 where t1.c in (c,t1.b,(t1.f)) or t1.a<>(c)),b)*t1.b-t1.b) then d else t1.e end & f* -13-c) from t1) from t1 where not ~a<f), -19)+t1.d+b FROM t1 WHERE NOT (13*t1.d between coalesce((select t1.d from t1 where b in (select t1.d from t1 union select case b*t1.f+t1.a*+coalesce((select t1.a from t1 where (not exists(select 1 from t1 where b*t1.c=13))),11)+t1.e when ~f then d+case b when e then f else t1.e end*13 else f end from t1)),19) and t1.d and 19 between 17 and e and a>a)}
+} {581}
+do_test randexpr-2.35 {
+ db eval {SELECT case when t1.d not in (t1.d,coalesce((select max(11) from t1 where f not between 13 and c-coalesce((select max(d) from t1 where 19 not in ((t1.f),f,11)),t1.d)*t1.e | a),13), -(t1.e)) then t1.b when t1.f=t1.a and exists(select 1 from t1 where b in (select c from t1 union select 11 from t1) and t1.c=b and not -d in (t1.d,t1.d,t1.b) and d between 11 and c) or d<=17 or a not in (e,19,(t1.b)) then 17 else 11 end FROM t1 WHERE a<>f+f}
+} {17}
+do_test randexpr-2.36 {
+ db eval {SELECT case when t1.d not in (t1.d,coalesce((select max(11) from t1 where f not between 13 and c-coalesce((select max(d) from t1 where 19 not in ((t1.f),f,11)),t1.d)*t1.e | a),13), -(t1.e)) then t1.b when t1.f=t1.a and exists(select 1 from t1 where b in (select c from t1 union select 11 from t1) and t1.c=b and not -d in (t1.d,t1.d,t1.b) and d between 11 and c) or d<=17 or a not in (e,19,(t1.b)) then 17 else 11 end FROM t1 WHERE NOT (a<>f+f)}
+} {}
+do_test randexpr-2.37 {
+ db eval {SELECT case when t1.d not in (t1.d,coalesce((select max(11) from t1 where f not between 13 and c-coalesce((select max(d) from t1 where 19 not in ((t1.f),f,11)),t1.d)*t1.e & a),13), -(t1.e)) then t1.b when t1.f=t1.a and exists(select 1 from t1 where b in (select c from t1 union select 11 from t1) and t1.c=b and not -d in (t1.d,t1.d,t1.b) and d between 11 and c) or d<=17 or a not in (e,19,(t1.b)) then 17 else 11 end FROM t1 WHERE a<>f+f}
+} {17}
+do_test randexpr-2.38 {
+ db eval {SELECT case 13 when coalesce((select t1.a*d+++b | b+(abs(t1.e)/abs(c))+(select count(*) from t1) from t1 where not exists(select 1 from t1 where 17 in (select d from t1 union select t1.f from t1))),t1.b) then ~t1.c-(select case min(case when 17 not in (19,19,t1.c) then c when 13 between (19) and t1.e then e else 19 end-19) when cast(avg( -11) AS integer) then max(t1.c)* -min(t1.d) else (count(distinct t1.f)) end from t1) | +t1.f else t1.c end FROM t1 WHERE coalesce((select max(t1.c) from t1 where (abs(t1.b)/abs(a))>=(e)),+ -case when (11<17) then t1.a when t1.a*e=19* -11 and not exists(select 1 from t1 where -t1.d not between coalesce((select a from t1 where -t1.c>t1.e), -19) and t1.d and not exists(select 1 from t1 where (t1.e) in (select d from t1 union select t1.c from t1))) then c else a end*a)-t1.b* -(b) in (e,d,b)}
+} {}
+do_test randexpr-2.39 {
+ db eval {SELECT case 13 when coalesce((select t1.a*d+++b | b+(abs(t1.e)/abs(c))+(select count(*) from t1) from t1 where not exists(select 1 from t1 where 17 in (select d from t1 union select t1.f from t1))),t1.b) then ~t1.c-(select case min(case when 17 not in (19,19,t1.c) then c when 13 between (19) and t1.e then e else 19 end-19) when cast(avg( -11) AS integer) then max(t1.c)* -min(t1.d) else (count(distinct t1.f)) end from t1) | +t1.f else t1.c end FROM t1 WHERE NOT (coalesce((select max(t1.c) from t1 where (abs(t1.b)/abs(a))>=(e)),+ -case when (11<17) then t1.a when t1.a*e=19* -11 and not exists(select 1 from t1 where -t1.d not between coalesce((select a from t1 where -t1.c>t1.e), -19) and t1.d and not exists(select 1 from t1 where (t1.e) in (select d from t1 union select t1.c from t1))) then c else a end*a)-t1.b* -(b) in (e,d,b))}
+} {300}
+do_test randexpr-2.40 {
+ db eval {SELECT case 13 when coalesce((select t1.a*d+++b & b+(abs(t1.e)/abs(c))+(select count(*) from t1) from t1 where not exists(select 1 from t1 where 17 in (select d from t1 union select t1.f from t1))),t1.b) then ~t1.c-(select case min(case when 17 not in (19,19,t1.c) then c when 13 between (19) and t1.e then e else 19 end-19) when cast(avg( -11) AS integer) then max(t1.c)* -min(t1.d) else (count(distinct t1.f)) end from t1) & +t1.f else t1.c end FROM t1 WHERE NOT (coalesce((select max(t1.c) from t1 where (abs(t1.b)/abs(a))>=(e)),+ -case when (11<17) then t1.a when t1.a*e=19* -11 and not exists(select 1 from t1 where -t1.d not between coalesce((select a from t1 where -t1.c>t1.e), -19) and t1.d and not exists(select 1 from t1 where (t1.e) in (select d from t1 union select t1.c from t1))) then c else a end*a)-t1.b* -(b) in (e,d,b))}
+} {300}
+do_test randexpr-2.41 {
+ db eval {SELECT case when not exists(select 1 from t1 where ( -case when b in ((11),coalesce((select f from t1 where (not exists(select 1 from t1 where coalesce((select (t1.a) from t1 where e<=a),11) in (select t1.f from t1 union select 13 from t1)) or t1.a>d)),t1.a),t1.e) or not not exists(select 1 from t1 where (t1.f<=(t1.a))) then e*t1.a else t1.c end)<=d and not (t1.e)>=t1.e) then coalesce((select max( -t1.e) from t1 where t1.d between t1.b and t1.c),t1.d) else t1.c end+13*13 FROM t1 WHERE t1.b=t1.f | 19+coalesce((select max(a) from t1 where case t1.e when case when (11<=11 | t1.f and b>=b or t1.f<=a) then case when c between t1.e and b then e else +t1.f end else -t1.c end then t1.b else 13 end*13 between t1.f and c and exists(select 1 from t1 where (b not between 11 and a)) and f>=t1.b), -t1.b)-c}
+} {}
+do_test randexpr-2.42 {
+ db eval {SELECT case when not exists(select 1 from t1 where ( -case when b in ((11),coalesce((select f from t1 where (not exists(select 1 from t1 where coalesce((select (t1.a) from t1 where e<=a),11) in (select t1.f from t1 union select 13 from t1)) or t1.a>d)),t1.a),t1.e) or not not exists(select 1 from t1 where (t1.f<=(t1.a))) then e*t1.a else t1.c end)<=d and not (t1.e)>=t1.e) then coalesce((select max( -t1.e) from t1 where t1.d between t1.b and t1.c),t1.d) else t1.c end+13*13 FROM t1 WHERE NOT (t1.b=t1.f | 19+coalesce((select max(a) from t1 where case t1.e when case when (11<=11 | t1.f and b>=b or t1.f<=a) then case when c between t1.e and b then e else +t1.f end else -t1.c end then t1.b else 13 end*13 between t1.f and c and exists(select 1 from t1 where (b not between 11 and a)) and f>=t1.b), -t1.b)-c)}
+} {569}
+do_test randexpr-2.43 {
+ db eval {SELECT coalesce((select c from t1 where t1.a=case when a=t1.b+~(select case cast(avg( -b*13) AS integer) when max(f*13* -c) then (cast(avg(t1.d) AS integer)) else count(distinct t1.e*c) end from t1) then t1.d | t1.a else case when t1.a-b not between e and -t1.c* -13 then 19 else d end end),d) | t1.d FROM t1 WHERE +13 in (f,t1.f+t1.f, -coalesce((select max(t1.f) from t1 where (t1.a-13)<=(case (select count(*) from t1) when 13 then -+t1.e | -(coalesce((select max(~coalesce((select ( -13) from t1 where -c<(11) or 11 between a and t1.d),13)*t1.d) from t1 where d not between b and 13),19))*t1.a else 13 end-b-c)),t1.e)-19)}
+} {}
+do_test randexpr-2.44 {
+ db eval {SELECT coalesce((select c from t1 where t1.a=case when a=t1.b+~(select case cast(avg( -b*13) AS integer) when max(f*13* -c) then (cast(avg(t1.d) AS integer)) else count(distinct t1.e*c) end from t1) then t1.d | t1.a else case when t1.a-b not between e and -t1.c* -13 then 19 else d end end),d) | t1.d FROM t1 WHERE NOT (+13 in (f,t1.f+t1.f, -coalesce((select max(t1.f) from t1 where (t1.a-13)<=(case (select count(*) from t1) when 13 then -+t1.e | -(coalesce((select max(~coalesce((select ( -13) from t1 where -c<(11) or 11 between a and t1.d),13)*t1.d) from t1 where d not between b and 13),19))*t1.a else 13 end-b-c)),t1.e)-19))}
+} {400}
+do_test randexpr-2.45 {
+ db eval {SELECT coalesce((select c from t1 where t1.a=case when a=t1.b+~(select case cast(avg( -b*13) AS integer) when max(f*13* -c) then (cast(avg(t1.d) AS integer)) else count(distinct t1.e*c) end from t1) then t1.d & t1.a else case when t1.a-b not between e and -t1.c* -13 then 19 else d end end),d) & t1.d FROM t1 WHERE NOT (+13 in (f,t1.f+t1.f, -coalesce((select max(t1.f) from t1 where (t1.a-13)<=(case (select count(*) from t1) when 13 then -+t1.e | -(coalesce((select max(~coalesce((select ( -13) from t1 where -c<(11) or 11 between a and t1.d),13)*t1.d) from t1 where d not between b and 13),19))*t1.a else 13 end-b-c)),t1.e)-19))}
+} {400}
+do_test randexpr-2.46 {
+ db eval {SELECT case ~11-13 when 11-d-case when t1.f*+a-t1.a-t1.f=t1.a then a when t1.f between 19-t1.a+coalesce((select a from t1 where e in (select case -max(t1.c) when count(*) then max(t1.d) else -(cast(avg((t1.e)) AS integer)) end from t1 union select (max(t1.b)) from t1)), -b) and e or ((11<c)) or e>=t1.d then t1.b else a end+13+(t1.c) then a else -d end FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where (not +t1.b-~a*(d*t1.e | + -coalesce((select t1.c from t1 where t1.b*case t1.b when f then -a*b else e end<>a+t1.a),17))+e*t1.e*11 | t1.a not between 13 and -t1.a and b between d and -f)))}
+} {-400}
+do_test randexpr-2.47 {
+ db eval {SELECT case ~11-13 when 11-d-case when t1.f*+a-t1.a-t1.f=t1.a then a when t1.f between 19-t1.a+coalesce((select a from t1 where e in (select case -max(t1.c) when count(*) then max(t1.d) else -(cast(avg((t1.e)) AS integer)) end from t1 union select (max(t1.b)) from t1)), -b) and e or ((11<c)) or e>=t1.d then t1.b else a end+13+(t1.c) then a else -d end FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where (not +t1.b-~a*(d*t1.e | + -coalesce((select t1.c from t1 where t1.b*case t1.b when f then -a*b else e end<>a+t1.a),17))+e*t1.e*11 | t1.a not between 13 and -t1.a and b between d and -f))))}
+} {}
+do_test randexpr-2.48 {
+ db eval {SELECT 11++(case 19 when t1.c-19-coalesce((select t1.b from t1 where e*19-t1.e<=+case when c in (select 19 | 17 from t1 union select 11 from t1) then (abs(a)/abs(19)) when a*t1.d>19 or (11) not in (b,t1.a,t1.a) then b else b end-11),f) then 13 else 11 end-t1.e*a) FROM t1 WHERE f in (17,t1.f | coalesce((select max(t1.e) from t1 where not 17 in (select f from t1 union select +17 from t1)),b+coalesce((select max(b) from t1 where 19 in (select case min(t1.d) when (count(*)) then min(d) else -min(d) end from t1 union select max(d) from t1)),f)*f-17+19),b) or d<=f or t1.f>=11 or t1.b<=11 or t1.c<=11 or t1.b<=b}
+} {-49978}
+do_test randexpr-2.49 {
+ db eval {SELECT 11++(case 19 when t1.c-19-coalesce((select t1.b from t1 where e*19-t1.e<=+case when c in (select 19 | 17 from t1 union select 11 from t1) then (abs(a)/abs(19)) when a*t1.d>19 or (11) not in (b,t1.a,t1.a) then b else b end-11),f) then 13 else 11 end-t1.e*a) FROM t1 WHERE NOT (f in (17,t1.f | coalesce((select max(t1.e) from t1 where not 17 in (select f from t1 union select +17 from t1)),b+coalesce((select max(b) from t1 where 19 in (select case min(t1.d) when (count(*)) then min(d) else -min(d) end from t1 union select max(d) from t1)),f)*f-17+19),b) or d<=f or t1.f>=11 or t1.b<=11 or t1.c<=11 or t1.b<=b)}
+} {}
+do_test randexpr-2.50 {
+ db eval {SELECT 11++(case 19 when t1.c-19-coalesce((select t1.b from t1 where e*19-t1.e<=+case when c in (select 19 & 17 from t1 union select 11 from t1) then (abs(a)/abs(19)) when a*t1.d>19 or (11) not in (b,t1.a,t1.a) then b else b end-11),f) then 13 else 11 end-t1.e*a) FROM t1 WHERE f in (17,t1.f | coalesce((select max(t1.e) from t1 where not 17 in (select f from t1 union select +17 from t1)),b+coalesce((select max(b) from t1 where 19 in (select case min(t1.d) when (count(*)) then min(d) else -min(d) end from t1 union select max(d) from t1)),f)*f-17+19),b) or d<=f or t1.f>=11 or t1.b<=11 or t1.c<=11 or t1.b<=b}
+} {-49978}
+do_test randexpr-2.51 {
+ db eval {SELECT -c-coalesce((select max(t1.a) from t1 where (a>17-t1.a) and (select abs(min(t1.a))*case abs(case (((min((t1.c))))+min(a)) when count(distinct f) then min(11) else count(distinct b) end) when min(t1.f) then (count(distinct t1.b)) else -count(*) end from t1)<>case d when +(select ((min(t1.a))) from t1)-(abs(c)/abs(f)) then b else 17 end+t1.c),coalesce((select t1.d from t1 where d>19),t1.a)) FROM t1 WHERE b+(coalesce((select max(a) from t1 where exists(select 1 from t1 where t1.b<=c-(select ~~max((abs(e)/abs(13 | (t1.e)-c-19))) from t1) or d in (select t1.b from t1 union select d from t1)) or 13 in (select cast(avg(19) AS integer) from t1 union select ( -cast(avg(19) AS integer) | count(*)*min(19)) from t1) or 19<=11),t1.c))-t1.d-c>f}
+} {}
+do_test randexpr-2.52 {
+ db eval {SELECT -c-coalesce((select max(t1.a) from t1 where (a>17-t1.a) and (select abs(min(t1.a))*case abs(case (((min((t1.c))))+min(a)) when count(distinct f) then min(11) else count(distinct b) end) when min(t1.f) then (count(distinct t1.b)) else -count(*) end from t1)<>case d when +(select ((min(t1.a))) from t1)-(abs(c)/abs(f)) then b else 17 end+t1.c),coalesce((select t1.d from t1 where d>19),t1.a)) FROM t1 WHERE NOT (b+(coalesce((select max(a) from t1 where exists(select 1 from t1 where t1.b<=c-(select ~~max((abs(e)/abs(13 | (t1.e)-c-19))) from t1) or d in (select t1.b from t1 union select d from t1)) or 13 in (select cast(avg(19) AS integer) from t1 union select ( -cast(avg(19) AS integer) | count(*)*min(19)) from t1) or 19<=11),t1.c))-t1.d-c>f)}
+} {-400}
+do_test randexpr-2.53 {
+ db eval {SELECT case when t1.b+coalesce((select max(a) from t1 where exists(select 1 from t1 where not not t1.d>19)),13) | case when f in (select a from t1 union select case when (a)<>t1.c then c when not exists(select 1 from t1 where t1.c not between 17 and -(t1.d)) then f else (11) end from t1) then t1.c when (not exists(select 1 from t1 where 17 not between t1.f and a)) and d=b then t1.c else d end<=19 and (t1.c<>c and (13) not between t1.d and t1.c) and a>= -b or 11>13 and c<>13 then -f else d end FROM t1 WHERE (case when (17 not in (f*11,+coalesce((select max(b-b) from t1 where t1.c+f not between 11 and t1.d),13),c)) or (t1.e in (select ~min(t1.f) from t1 union select ~count(*) from t1) and exists(select 1 from t1 where (not f>=19 and 17 not between a and t1.e)) or (e) not in (e,d,13) or t1.d>=f) then e when 17 between t1.c and 13 then case when 11<>19 then t1.d else t1.a end else b end in (select -t1.a from t1 union select a from t1))}
+} {}
+do_test randexpr-2.54 {
+ db eval {SELECT case when t1.b+coalesce((select max(a) from t1 where exists(select 1 from t1 where not not t1.d>19)),13) | case when f in (select a from t1 union select case when (a)<>t1.c then c when not exists(select 1 from t1 where t1.c not between 17 and -(t1.d)) then f else (11) end from t1) then t1.c when (not exists(select 1 from t1 where 17 not between t1.f and a)) and d=b then t1.c else d end<=19 and (t1.c<>c and (13) not between t1.d and t1.c) and a>= -b or 11>13 and c<>13 then -f else d end FROM t1 WHERE NOT ((case when (17 not in (f*11,+coalesce((select max(b-b) from t1 where t1.c+f not between 11 and t1.d),13),c)) or (t1.e in (select ~min(t1.f) from t1 union select ~count(*) from t1) and exists(select 1 from t1 where (not f>=19 and 17 not between a and t1.e)) or (e) not in (e,d,13) or t1.d>=f) then e when 17 between t1.c and 13 then case when 11<>19 then t1.d else t1.a end else b end in (select -t1.a from t1 union select a from t1)))}
+} {400}
+do_test randexpr-2.55 {
+ db eval {SELECT case when t1.b+coalesce((select max(a) from t1 where exists(select 1 from t1 where not not t1.d>19)),13) & case when f in (select a from t1 union select case when (a)<>t1.c then c when not exists(select 1 from t1 where t1.c not between 17 and -(t1.d)) then f else (11) end from t1) then t1.c when (not exists(select 1 from t1 where 17 not between t1.f and a)) and d=b then t1.c else d end<=19 and (t1.c<>c and (13) not between t1.d and t1.c) and a>= -b or 11>13 and c<>13 then -f else d end FROM t1 WHERE NOT ((case when (17 not in (f*11,+coalesce((select max(b-b) from t1 where t1.c+f not between 11 and t1.d),13),c)) or (t1.e in (select ~min(t1.f) from t1 union select ~count(*) from t1) and exists(select 1 from t1 where (not f>=19 and 17 not between a and t1.e)) or (e) not in (e,d,13) or t1.d>=f) then e when 17 between t1.c and 13 then case when 11<>19 then t1.d else t1.a end else b end in (select -t1.a from t1 union select a from t1)))}
+} {400}
+do_test randexpr-2.56 {
+ db eval {SELECT t1.e+case when d not between f and case when a in (select t1.c from t1 union select t1.e from t1) or coalesce((select 19 from t1 where 17<=t1.d or 19*t1.f*t1.b<>t1.d | t1.d | t1.a),t1.b)*case when (t1.a) in (t1.d,t1.a,a) then -c when 17<13 then t1.f else 17 end-t1.f*e not in (19,t1.d,17) then 19 else t1.e end then -b else t1.b end FROM t1 WHERE (coalesce((select t1.d-coalesce((select max(coalesce((select max(c+13) from t1 where ~13*t1.b in (select abs(abs(abs((cast(avg( -e) AS integer)))))- -count(distinct (13))*max(13) from t1 union select count(distinct 19) from t1)), -t1.f)) from t1 where exists(select 1 from t1 where 17 in (t1.b,13,b))),b)+d+t1.a from t1 where d not in (13,t1.b,b)),17) not between 11 and e or not 17 between d and d)}
+} {300}
+do_test randexpr-2.57 {
+ db eval {SELECT t1.e+case when d not between f and case when a in (select t1.c from t1 union select t1.e from t1) or coalesce((select 19 from t1 where 17<=t1.d or 19*t1.f*t1.b<>t1.d | t1.d | t1.a),t1.b)*case when (t1.a) in (t1.d,t1.a,a) then -c when 17<13 then t1.f else 17 end-t1.f*e not in (19,t1.d,17) then 19 else t1.e end then -b else t1.b end FROM t1 WHERE NOT ((coalesce((select t1.d-coalesce((select max(coalesce((select max(c+13) from t1 where ~13*t1.b in (select abs(abs(abs((cast(avg( -e) AS integer)))))- -count(distinct (13))*max(13) from t1 union select count(distinct 19) from t1)), -t1.f)) from t1 where exists(select 1 from t1 where 17 in (t1.b,13,b))),b)+d+t1.a from t1 where d not in (13,t1.b,b)),17) not between 11 and e or not 17 between d and d))}
+} {}
+do_test randexpr-2.58 {
+ db eval {SELECT t1.e+case when d not between f and case when a in (select t1.c from t1 union select t1.e from t1) or coalesce((select 19 from t1 where 17<=t1.d or 19*t1.f*t1.b<>t1.d & t1.d & t1.a),t1.b)*case when (t1.a) in (t1.d,t1.a,a) then -c when 17<13 then t1.f else 17 end-t1.f*e not in (19,t1.d,17) then 19 else t1.e end then -b else t1.b end FROM t1 WHERE (coalesce((select t1.d-coalesce((select max(coalesce((select max(c+13) from t1 where ~13*t1.b in (select abs(abs(abs((cast(avg( -e) AS integer)))))- -count(distinct (13))*max(13) from t1 union select count(distinct 19) from t1)), -t1.f)) from t1 where exists(select 1 from t1 where 17 in (t1.b,13,b))),b)+d+t1.a from t1 where d not in (13,t1.b,b)),17) not between 11 and e or not 17 between d and d)}
+} {300}
+do_test randexpr-2.59 {
+ db eval {SELECT coalesce((select max(t1.f*case when not exists(select 1 from t1 where exists(select 1 from t1 where (select count(distinct 11) from t1) between coalesce((select max(c) from t1 where t1.e=t1.a+17),a) and t1.b) or c not in (t1.e,19,t1.e)) then 13 when exists(select 1 from t1 where t1.a between 19 and -c) then coalesce((select coalesce((select max((( -d))) from t1 where 17 not in (t1.d,e,t1.e)),e) from t1 where c= -f),( -c)) else t1.f end) from t1 where not (11 between a and t1.e)),19) FROM t1 WHERE case c when case when (exists(select 1 from t1 where t1.d<>coalesce((select 13 from t1 where (t1.b>+e)),(17))+coalesce((select 13 from t1 where exists(select 1 from t1 where 13 in (t1.b+c,case when f between t1.f and b then t1.b else f end,(11)))),f)-17-17)) then -c-(c) when 11 in (b,f,(t1.d)) then t1.c else t1.b end then t1.d else 11 end in (select -count(*) from t1 union select count(*) from t1)}
+} {}
+do_test randexpr-2.60 {
+ db eval {SELECT coalesce((select max(t1.f*case when not exists(select 1 from t1 where exists(select 1 from t1 where (select count(distinct 11) from t1) between coalesce((select max(c) from t1 where t1.e=t1.a+17),a) and t1.b) or c not in (t1.e,19,t1.e)) then 13 when exists(select 1 from t1 where t1.a between 19 and -c) then coalesce((select coalesce((select max((( -d))) from t1 where 17 not in (t1.d,e,t1.e)),e) from t1 where c= -f),( -c)) else t1.f end) from t1 where not (11 between a and t1.e)),19) FROM t1 WHERE NOT (case c when case when (exists(select 1 from t1 where t1.d<>coalesce((select 13 from t1 where (t1.b>+e)),(17))+coalesce((select 13 from t1 where exists(select 1 from t1 where 13 in (t1.b+c,case when f between t1.f and b then t1.b else f end,(11)))),f)-17-17)) then -c-(c) when 11 in (b,f,(t1.d)) then t1.c else t1.b end then t1.d else 11 end in (select -count(*) from t1 union select count(*) from t1))}
+} {360000}
+do_test randexpr-2.61 {
+ db eval {SELECT case when t1.a-coalesce((select t1.b from t1 where (d<=~a)),t1.b+t1.d | 19+13)-t1.a | ~coalesce((select ~17 from t1 where not exists(select 1 from t1 where ~case when 13 in (select +(cast(avg(b) AS integer)) from t1 union select count(*) from t1) then 17 when 11 not in (c,t1.a,t1.a) then e else e end*a not between 11 and c)),t1.c) in (11,t1.a,e) then t1.f when 19 in (select ~count(distinct d) from t1 union select cast(avg(19) AS integer) from t1) then t1.d else 19 end FROM t1 WHERE not exists(select 1 from t1 where (select count(*) from t1)+coalesce((select max(a) from t1 where t1.a between (abs(case when exists(select 1 from t1 where case when t1.e=case when 19 between 11 and e then t1.f else a end then t1.e else t1.b end in (select count(distinct d) | max(11)*abs(case count(*) when max(f) then cast(avg(e) AS integer) else count(distinct t1.e) end) from t1 union select -cast(avg(c) AS integer) from t1)) then (select -min(e) from t1) when (c>e) then t1.d else f end)/abs(b)) and (17)),e) not between t1.a and d)}
+} {}
+do_test randexpr-2.62 {
+ db eval {SELECT case when t1.a-coalesce((select t1.b from t1 where (d<=~a)),t1.b+t1.d | 19+13)-t1.a | ~coalesce((select ~17 from t1 where not exists(select 1 from t1 where ~case when 13 in (select +(cast(avg(b) AS integer)) from t1 union select count(*) from t1) then 17 when 11 not in (c,t1.a,t1.a) then e else e end*a not between 11 and c)),t1.c) in (11,t1.a,e) then t1.f when 19 in (select ~count(distinct d) from t1 union select cast(avg(19) AS integer) from t1) then t1.d else 19 end FROM t1 WHERE NOT (not exists(select 1 from t1 where (select count(*) from t1)+coalesce((select max(a) from t1 where t1.a between (abs(case when exists(select 1 from t1 where case when t1.e=case when 19 between 11 and e then t1.f else a end then t1.e else t1.b end in (select count(distinct d) | max(11)*abs(case count(*) when max(f) then cast(avg(e) AS integer) else count(distinct t1.e) end) from t1 union select -cast(avg(c) AS integer) from t1)) then (select -min(e) from t1) when (c>e) then t1.d else f end)/abs(b)) and (17)),e) not between t1.a and d))}
+} {400}
+do_test randexpr-2.63 {
+ db eval {SELECT case when t1.a-coalesce((select t1.b from t1 where (d<=~a)),t1.b+t1.d & 19+13)-t1.a & ~coalesce((select ~17 from t1 where not exists(select 1 from t1 where ~case when 13 in (select +(cast(avg(b) AS integer)) from t1 union select count(*) from t1) then 17 when 11 not in (c,t1.a,t1.a) then e else e end*a not between 11 and c)),t1.c) in (11,t1.a,e) then t1.f when 19 in (select ~count(distinct d) from t1 union select cast(avg(19) AS integer) from t1) then t1.d else 19 end FROM t1 WHERE NOT (not exists(select 1 from t1 where (select count(*) from t1)+coalesce((select max(a) from t1 where t1.a between (abs(case when exists(select 1 from t1 where case when t1.e=case when 19 between 11 and e then t1.f else a end then t1.e else t1.b end in (select count(distinct d) | max(11)*abs(case count(*) when max(f) then cast(avg(e) AS integer) else count(distinct t1.e) end) from t1 union select -cast(avg(c) AS integer) from t1)) then (select -min(e) from t1) when (c>e) then t1.d else f end)/abs(b)) and (17)),e) not between t1.a and d))}
+} {400}
+do_test randexpr-2.64 {
+ db eval {SELECT case when 11 in (select max(f) from t1 union select min(19++13) | min(t1.c) from t1) and (e in (select t1.d from t1 union select t1.a | 17*case e when coalesce((select max(a) from t1 where b not in (b,f,d) or t1.a<=f),11) then t1.a else t1.b end from t1) and -a not between b and d) then d when -t1.f=b or t1.b between -f and -d then 19 else d end+d FROM t1 WHERE case when (coalesce((select case (select max(t1.b) from t1) when (b* -t1.e+e*e-t1.a) then c else a end from t1 where 17 in (select min(t1.d)-abs(count(*)) from t1 union select count(distinct c) from t1)),t1.d)=(t1.d)) and e in (select -min(t1.b) from t1 union select count(distinct 11) from t1) and a< - -17 then t1.d | 11 else 19 end in (select 17 from t1 union select d from t1)}
+} {}
+do_test randexpr-2.65 {
+ db eval {SELECT case when 11 in (select max(f) from t1 union select min(19++13) | min(t1.c) from t1) and (e in (select t1.d from t1 union select t1.a | 17*case e when coalesce((select max(a) from t1 where b not in (b,f,d) or t1.a<=f),11) then t1.a else t1.b end from t1) and -a not between b and d) then d when -t1.f=b or t1.b between -f and -d then 19 else d end+d FROM t1 WHERE NOT (case when (coalesce((select case (select max(t1.b) from t1) when (b* -t1.e+e*e-t1.a) then c else a end from t1 where 17 in (select min(t1.d)-abs(count(*)) from t1 union select count(distinct c) from t1)),t1.d)=(t1.d)) and e in (select -min(t1.b) from t1 union select count(distinct 11) from t1) and a< - -17 then t1.d | 11 else 19 end in (select 17 from t1 union select d from t1))}
+} {800}
+do_test randexpr-2.66 {
+ db eval {SELECT case when 11 in (select max(f) from t1 union select min(19++13) & min(t1.c) from t1) and (e in (select t1.d from t1 union select t1.a & 17*case e when coalesce((select max(a) from t1 where b not in (b,f,d) or t1.a<=f),11) then t1.a else t1.b end from t1) and -a not between b and d) then d when -t1.f=b or t1.b between -f and -d then 19 else d end+d FROM t1 WHERE NOT (case when (coalesce((select case (select max(t1.b) from t1) when (b* -t1.e+e*e-t1.a) then c else a end from t1 where 17 in (select min(t1.d)-abs(count(*)) from t1 union select count(distinct c) from t1)),t1.d)=(t1.d)) and e in (select -min(t1.b) from t1 union select count(distinct 11) from t1) and a< - -17 then t1.d | 11 else 19 end in (select 17 from t1 union select d from t1))}
+} {800}
+do_test randexpr-2.67 {
+ db eval {SELECT (abs((select min(13) from t1))/abs(coalesce((select t1.e from t1 where coalesce((select t1.f from t1 where -11<=b-t1.c*case when (d)-t1.f+t1.e-13<>t1.b then 11 when exists(select 1 from t1 where t1.d<>((t1.b)) or t1.a not between d and 13) or t1.b<>t1.c then t1.e else -t1.d end+t1.a or t1.c not between f and d),e)<>e), -f))) FROM t1 WHERE t1.c<>(select min((abs(( -19-t1.b*13- -++~t1.f*d-17*19*11))/abs(17))) from t1)}
+} {0}
+do_test randexpr-2.68 {
+ db eval {SELECT (abs((select min(13) from t1))/abs(coalesce((select t1.e from t1 where coalesce((select t1.f from t1 where -11<=b-t1.c*case when (d)-t1.f+t1.e-13<>t1.b then 11 when exists(select 1 from t1 where t1.d<>((t1.b)) or t1.a not between d and 13) or t1.b<>t1.c then t1.e else -t1.d end+t1.a or t1.c not between f and d),e)<>e), -f))) FROM t1 WHERE NOT (t1.c<>(select min((abs(( -19-t1.b*13- -++~t1.f*d-17*19*11))/abs(17))) from t1))}
+} {}
+do_test randexpr-2.69 {
+ db eval {SELECT case d-case when c< -case when b<=f or coalesce((select t1.e from t1 where 11<coalesce((select b+(t1.f)+t1.e-d from t1 where (t1.c<f)),t1.d)),t1.e)>e then 19 when not exists(select 1 from t1 where not exists(select 1 from t1 where t1.d>=d)) then t1.f else 17 end then e when not exists(select 1 from t1 where d=b) then t1.c else f end when 17 then 19 else t1.f end FROM t1 WHERE coalesce((select max(+t1.d) from t1 where e<>e or not exists(select 1 from t1 where not exists(select 1 from t1 where (abs(f)/abs(f))++t1.b in (select case abs(cast(avg(e) AS integer)) when cast(avg(17) AS integer) | max(d) | cast(avg(t1.e) AS integer) | min(t1.e) then (cast(avg(19) AS integer)) else cast(avg(c) AS integer) end from t1 union select cast(avg(t1.f) AS integer) from t1))) and t1.a between t1.f and b or not 17<13 or -11= -t1.f or t1.f between c and 19),d)+(t1.d) not between b and e}
+} {600}
+do_test randexpr-2.70 {
+ db eval {SELECT case d-case when c< -case when b<=f or coalesce((select t1.e from t1 where 11<coalesce((select b+(t1.f)+t1.e-d from t1 where (t1.c<f)),t1.d)),t1.e)>e then 19 when not exists(select 1 from t1 where not exists(select 1 from t1 where t1.d>=d)) then t1.f else 17 end then e when not exists(select 1 from t1 where d=b) then t1.c else f end when 17 then 19 else t1.f end FROM t1 WHERE NOT (coalesce((select max(+t1.d) from t1 where e<>e or not exists(select 1 from t1 where not exists(select 1 from t1 where (abs(f)/abs(f))++t1.b in (select case abs(cast(avg(e) AS integer)) when cast(avg(17) AS integer) | max(d) | cast(avg(t1.e) AS integer) | min(t1.e) then (cast(avg(19) AS integer)) else cast(avg(c) AS integer) end from t1 union select cast(avg(t1.f) AS integer) from t1))) and t1.a between t1.f and b or not 17<13 or -11= -t1.f or t1.f between c and 19),d)+(t1.d) not between b and e)}
+} {}
+do_test randexpr-2.71 {
+ db eval {SELECT case when t1.e in (select abs(max(case a+case when t1.a>=e+ -c then a else t1.b end+t1.a when t1.f then 19 else -19 end)+abs( -count(distinct t1.c))+~(count(distinct t1.b)))-min(b) from t1 union select max(f) from t1) and case t1.e when -t1.c then 19 else b end<t1.d then e+(d) when exists(select 1 from t1 where 19 not between t1.e and (19)) then -19 else t1.c end FROM t1 WHERE (exists(select 1 from t1 where t1.e between t1.c-t1.d and (t1.a)) and ((not case 19 when 11 then e else ~d | t1.a*19 end*((b))>=t1.e))) or c in (select f from t1 union select 13 from t1) and (b)< -t1.c and f in (select max(13) from t1 union select ~+abs(count(distinct e)*abs(((count(*)))*((max(f))))) from t1)}
+} {}
+do_test randexpr-2.72 {
+ db eval {SELECT case when t1.e in (select abs(max(case a+case when t1.a>=e+ -c then a else t1.b end+t1.a when t1.f then 19 else -19 end)+abs( -count(distinct t1.c))+~(count(distinct t1.b)))-min(b) from t1 union select max(f) from t1) and case t1.e when -t1.c then 19 else b end<t1.d then e+(d) when exists(select 1 from t1 where 19 not between t1.e and (19)) then -19 else t1.c end FROM t1 WHERE NOT ((exists(select 1 from t1 where t1.e between t1.c-t1.d and (t1.a)) and ((not case 19 when 11 then e else ~d | t1.a*19 end*((b))>=t1.e))) or c in (select f from t1 union select 13 from t1) and (b)< -t1.c and f in (select max(13) from t1 union select ~+abs(count(distinct e)*abs(((count(*)))*((max(f))))) from t1))}
+} {-19}
+do_test randexpr-2.73 {
+ db eval {SELECT c*case when t1.a in (select ~count(*) from t1 union select -count(distinct ~case (abs(11)/abs(b-(coalesce((select 17-t1.a from t1 where not t1.d=t1.d),(abs(11)/abs(a)))))) when case when t1.d between 19 and c and t1.b between 11 and t1.a then 13 else (13) end then (13) else 19 end-19*13+11) from t1) then t1.a when t1.f<=t1.e then f else b end-19-c+f FROM t1 WHERE t1.b>=c+case when exists(select 1 from t1 where a>=+f- -c*e+coalesce((select max(b) from t1 where (b not between (t1.b) and 19) or t1.f<11),d)*f | t1.e+t1.b) then ( -t1.e)-19 when ((t1.a in (select 19 from t1 union select t1.f from t1) or b<c and b> -17)) then f else f end | d}
+} {}
+do_test randexpr-2.74 {
+ db eval {SELECT c*case when t1.a in (select ~count(*) from t1 union select -count(distinct ~case (abs(11)/abs(b-(coalesce((select 17-t1.a from t1 where not t1.d=t1.d),(abs(11)/abs(a)))))) when case when t1.d between 19 and c and t1.b between 11 and t1.a then 13 else (13) end then (13) else 19 end-19*13+11) from t1) then t1.a when t1.f<=t1.e then f else b end-19-c+f FROM t1 WHERE NOT (t1.b>=c+case when exists(select 1 from t1 where a>=+f- -c*e+coalesce((select max(b) from t1 where (b not between (t1.b) and 19) or t1.f<11),d)*f | t1.e+t1.b) then ( -t1.e)-19 when ((t1.a in (select 19 from t1 union select t1.f from t1) or b<c and b> -17)) then f else f end | d)}
+} {60281}
+do_test randexpr-2.75 {
+ db eval {SELECT (abs(case when a>=b then t1.c-case when not exists(select 1 from t1 where case d when +17 then 19+c else 11 end-(abs((select - -cast(avg(case when (11- -(abs(e)/abs(13))-t1.f<t1.e) then t1.c+d else a end-t1.c) AS integer) from t1))/abs(t1.a))<=b) then -e+d else (t1.c) end else 19 end)/abs(c)) FROM t1 WHERE f<>11}
+} {0}
+do_test randexpr-2.76 {
+ db eval {SELECT (abs(case when a>=b then t1.c-case when not exists(select 1 from t1 where case d when +17 then 19+c else 11 end-(abs((select - -cast(avg(case when (11- -(abs(e)/abs(13))-t1.f<t1.e) then t1.c+d else a end-t1.c) AS integer) from t1))/abs(t1.a))<=b) then -e+d else (t1.c) end else 19 end)/abs(c)) FROM t1 WHERE NOT (f<>11)}
+} {}
+do_test randexpr-2.77 {
+ db eval {SELECT -coalesce((select max(e-t1.b) from t1 where t1.e<11 and t1.b | e in ((abs(13)/abs(t1.b)),(abs((+17-case when t1.c | 13*(d) | b<>a or ((t1.e)>=a) then t1.b-t1.e when not exists(select 1 from t1 where 17<13) then -(13) else 17 end*13))/abs(13)),t1.c)),t1.e) | c FROM t1 WHERE not exists(select 1 from t1 where 17<=(select (case (~+abs(cast(avg((t1.e)-17 | b) AS integer))-((case -cast(avg(case when ~t1.b in (select d from t1 union select 19 from t1) then b when 13 in (t1.f,c,t1.b) then c else f end) AS integer)+count(distinct t1.f)+count(distinct t1.d) when count(*) then ((max(c))) else count(*) end)*cast(avg(t1.e) AS integer))) when ((cast(avg(a) AS integer))) then -max(d) else ((count(*))) end) from t1))}
+} {-212}
+do_test randexpr-2.78 {
+ db eval {SELECT -coalesce((select max(e-t1.b) from t1 where t1.e<11 and t1.b | e in ((abs(13)/abs(t1.b)),(abs((+17-case when t1.c | 13*(d) | b<>a or ((t1.e)>=a) then t1.b-t1.e when not exists(select 1 from t1 where 17<13) then -(13) else 17 end*13))/abs(13)),t1.c)),t1.e) | c FROM t1 WHERE NOT (not exists(select 1 from t1 where 17<=(select (case (~+abs(cast(avg((t1.e)-17 | b) AS integer))-((case -cast(avg(case when ~t1.b in (select d from t1 union select 19 from t1) then b when 13 in (t1.f,c,t1.b) then c else f end) AS integer)+count(distinct t1.f)+count(distinct t1.d) when count(*) then ((max(c))) else count(*) end)*cast(avg(t1.e) AS integer))) when ((cast(avg(a) AS integer))) then -max(d) else ((count(*))) end) from t1)))}
+} {}
+do_test randexpr-2.79 {
+ db eval {SELECT -coalesce((select max(e-t1.b) from t1 where t1.e<11 and t1.b & e in ((abs(13)/abs(t1.b)),(abs((+17-case when t1.c & 13*(d) & b<>a or ((t1.e)>=a) then t1.b-t1.e when not exists(select 1 from t1 where 17<13) then -(13) else 17 end*13))/abs(13)),t1.c)),t1.e) & c FROM t1 WHERE not exists(select 1 from t1 where 17<=(select (case (~+abs(cast(avg((t1.e)-17 | b) AS integer))-((case -cast(avg(case when ~t1.b in (select d from t1 union select 19 from t1) then b when 13 in (t1.f,c,t1.b) then c else f end) AS integer)+count(distinct t1.f)+count(distinct t1.d) when count(*) then ((max(c))) else count(*) end)*cast(avg(t1.e) AS integer))) when ((cast(avg(a) AS integer))) then -max(d) else ((count(*))) end) from t1))}
+} {12}
+do_test randexpr-2.80 {
+ db eval {SELECT 17-coalesce((select c+t1.f from t1 where (select count(distinct d)-abs(min((select case - -count(*) when -max(19) then -count(*) else count(*) end from t1))-count(*)) from t1)-t1.a+case when (abs(t1.e)/abs(t1.e)) not in (a,t1.a,19) and (b between 19 and -t1.c) then 17 else c end-19+t1.e*13<= -(t1.a)),11)-t1.d-c FROM t1 WHERE ((t1.d in ((select +cast(avg(coalesce((select max(coalesce((select max(a) from t1 where not a in (b,~(select ~count(*) from t1),case (select +max(11) | -count(*) from t1) when 17*t1.f*17 then b else (t1.b) end+f | 17)),e)) from t1 where not exists(select 1 from t1 where 17 between a and a)),(19))) AS integer) from t1),coalesce((select max(e) from t1 where t1.e<>11),b),t1.d)))}
+} {-694}
+do_test randexpr-2.81 {
+ db eval {SELECT 17-coalesce((select c+t1.f from t1 where (select count(distinct d)-abs(min((select case - -count(*) when -max(19) then -count(*) else count(*) end from t1))-count(*)) from t1)-t1.a+case when (abs(t1.e)/abs(t1.e)) not in (a,t1.a,19) and (b between 19 and -t1.c) then 17 else c end-19+t1.e*13<= -(t1.a)),11)-t1.d-c FROM t1 WHERE NOT (((t1.d in ((select +cast(avg(coalesce((select max(coalesce((select max(a) from t1 where not a in (b,~(select ~count(*) from t1),case (select +max(11) | -count(*) from t1) when 17*t1.f*17 then b else (t1.b) end+f | 17)),e)) from t1 where not exists(select 1 from t1 where 17 between a and a)),(19))) AS integer) from t1),coalesce((select max(e) from t1 where t1.e<>11),b),t1.d))))}
+} {}
+do_test randexpr-2.82 {
+ db eval {SELECT case (t1.a) when e then t1.a else t1.d end+(b)*t1.c | (select ~count(distinct (select count(distinct t1.f) from t1)) from t1)* -case c*t1.b when 19 then t1.d else (t1.b) | case when not (e)*f in (select count(distinct a)-count(distinct c) | min(a) from t1 union select -count(*) from t1) and (t1.f in (d, -t1.c,f)) then e when t1.c not in (t1.b,t1.e,b) then t1.e else f end end FROM t1 WHERE t1.d<>coalesce((select max(case when exists(select 1 from t1 where f<=e | b) then (select min(+t1.f) from t1) else 11 end) from t1 where +case when t1.e=c then -t1.c else t1.a end-t1.a-11-f in (select (case -min(a) when count(*)*(( -+abs(cast(avg(a) AS integer))*max((17))) | max(19)) then min(11) else min(a) end | count(distinct -d)) from t1 union select min(t1.e) from t1)),t1.c)}
+} {60408}
+do_test randexpr-2.83 {
+ db eval {SELECT case (t1.a) when e then t1.a else t1.d end+(b)*t1.c | (select ~count(distinct (select count(distinct t1.f) from t1)) from t1)* -case c*t1.b when 19 then t1.d else (t1.b) | case when not (e)*f in (select count(distinct a)-count(distinct c) | min(a) from t1 union select -count(*) from t1) and (t1.f in (d, -t1.c,f)) then e when t1.c not in (t1.b,t1.e,b) then t1.e else f end end FROM t1 WHERE NOT (t1.d<>coalesce((select max(case when exists(select 1 from t1 where f<=e | b) then (select min(+t1.f) from t1) else 11 end) from t1 where +case when t1.e=c then -t1.c else t1.a end-t1.a-11-f in (select (case -min(a) when count(*)*(( -+abs(cast(avg(a) AS integer))*max((17))) | max(19)) then min(11) else min(a) end | count(distinct -d)) from t1 union select min(t1.e) from t1)),t1.c))}
+} {}
+do_test randexpr-2.84 {
+ db eval {SELECT case (t1.a) when e then t1.a else t1.d end+(b)*t1.c & (select ~count(distinct (select count(distinct t1.f) from t1)) from t1)* -case c*t1.b when 19 then t1.d else (t1.b) & case when not (e)*f in (select count(distinct a)-count(distinct c) & min(a) from t1 union select -count(*) from t1) and (t1.f in (d, -t1.c,f)) then e when t1.c not in (t1.b,t1.e,b) then t1.e else f end end FROM t1 WHERE t1.d<>coalesce((select max(case when exists(select 1 from t1 where f<=e | b) then (select min(+t1.f) from t1) else 11 end) from t1 where +case when t1.e=c then -t1.c else t1.a end-t1.a-11-f in (select (case -min(a) when count(*)*(( -+abs(cast(avg(a) AS integer))*max((17))) | max(19)) then min(11) else min(a) end | count(distinct -d)) from t1 union select min(t1.e) from t1)),t1.c)}
+} {384}
+do_test randexpr-2.85 {
+ db eval {SELECT (select abs(max((select (case cast(avg(t1.a) AS integer) when +~abs(cast(avg( -17+case when t1.a in (c,(e),t1.f) and f in (c,t1.d,t1.a) then d when d between c and t1.d then f else e end) AS integer))-(abs(~max((b)))-min(t1.f)) then cast(avg(t1.f) AS integer) else count(*) end) from t1)+case when (exists(select 1 from t1 where t1.a in (select -max(e) from t1 union select -count(*) from t1)) or e in (t1.b*d,a, - -d)) then 17*t1.c else c end)) from t1) FROM t1 WHERE ~t1.e>case 13 when e then a else coalesce((select ~t1.d from t1 where exists(select 1 from t1 where t1.f between coalesce((select t1.a from t1 where ((select min(d-d- -t1.d+a) from t1)) not between f and t1.c or exists(select 1 from t1 where b<>17)),(a)) and -d) or not exists(select 1 from t1 where e in (select min(19)*(count(*))*cast(avg(11) AS integer) | min(b) from t1 union select (cast(avg(t1.e) AS integer)) from t1))),c) end-t1.c}
+} {}
+do_test randexpr-2.86 {
+ db eval {SELECT (select abs(max((select (case cast(avg(t1.a) AS integer) when +~abs(cast(avg( -17+case when t1.a in (c,(e),t1.f) and f in (c,t1.d,t1.a) then d when d between c and t1.d then f else e end) AS integer))-(abs(~max((b)))-min(t1.f)) then cast(avg(t1.f) AS integer) else count(*) end) from t1)+case when (exists(select 1 from t1 where t1.a in (select -max(e) from t1 union select -count(*) from t1)) or e in (t1.b*d,a, - -d)) then 17*t1.c else c end)) from t1) FROM t1 WHERE NOT (~t1.e>case 13 when e then a else coalesce((select ~t1.d from t1 where exists(select 1 from t1 where t1.f between coalesce((select t1.a from t1 where ((select min(d-d- -t1.d+a) from t1)) not between f and t1.c or exists(select 1 from t1 where b<>17)),(a)) and -d) or not exists(select 1 from t1 where e in (select min(19)*(count(*))*cast(avg(11) AS integer) | min(b) from t1 union select (cast(avg(t1.e) AS integer)) from t1))),c) end-t1.c)}
+} {301}
+do_test randexpr-2.87 {
+ db eval {SELECT t1.c+(abs(t1.b*t1.b)/abs(++t1.a-t1.e-(abs(t1.b)/abs(d))*11*t1.f)) | 19-b-t1.e | t1.e-+~t1.d*13+a+case case when (d)+17-c=d then a else t1.b end when e then t1.a else 19 end FROM t1 WHERE not coalesce((select (abs(case t1.b when coalesce((select case when exists(select 1 from t1 where f between 17 and f) then 11 else f end from t1 where not exists(select 1 from t1 where c>=t1.d)),17)*t1.a then t1.e else 13 end)/abs(17)) from t1 where ((13 in (select abs(~min(d)*count(distinct -(f)) | count(*)*cast(avg(11) AS integer)) from t1 union select count(*) from t1) and a<=13) and c<> -(t1.c))), -t1.a)*t1.e*f+d not in (11,d,t1.c)}
+} {}
+do_test randexpr-2.88 {
+ db eval {SELECT t1.c+(abs(t1.b*t1.b)/abs(++t1.a-t1.e-(abs(t1.b)/abs(d))*11*t1.f)) | 19-b-t1.e | t1.e-+~t1.d*13+a+case case when (d)+17-c=d then a else t1.b end when e then t1.a else 19 end FROM t1 WHERE NOT (not coalesce((select (abs(case t1.b when coalesce((select case when exists(select 1 from t1 where f between 17 and f) then 11 else f end from t1 where not exists(select 1 from t1 where c>=t1.d)),17)*t1.a then t1.e else 13 end)/abs(17)) from t1 where ((13 in (select abs(~min(d)*count(distinct -(f)) | count(*)*cast(avg(11) AS integer)) from t1 union select count(*) from t1) and a<=13) and c<> -(t1.c))), -t1.a)*t1.e*f+d not in (11,d,t1.c))}
+} {-33}
+do_test randexpr-2.89 {
+ db eval {SELECT t1.c+(abs(t1.b*t1.b)/abs(++t1.a-t1.e-(abs(t1.b)/abs(d))*11*t1.f)) & 19-b-t1.e & t1.e-+~t1.d*13+a+case case when (d)+17-c=d then a else t1.b end when e then t1.a else 19 end FROM t1 WHERE NOT (not coalesce((select (abs(case t1.b when coalesce((select case when exists(select 1 from t1 where f between 17 and f) then 11 else f end from t1 where not exists(select 1 from t1 where c>=t1.d)),17)*t1.a then t1.e else 13 end)/abs(17)) from t1 where ((13 in (select abs(~min(d)*count(distinct -(f)) | count(*)*cast(avg(11) AS integer)) from t1 union select count(*) from t1) and a<=13) and c<> -(t1.c))), -t1.a)*t1.e*f+d not in (11,d,t1.c))}
+} {0}
+do_test randexpr-2.90 {
+ db eval {SELECT case when t1.f>t1.d then (select abs(+count(distinct c)+(abs(min((abs(+11)/abs(b)))* -count(*)))) from t1)-t1.a when d+case when (select cast(avg(t1.f) AS integer)-count(distinct 19) from t1)<>17 then c when t1.e in (select cast(avg(t1.a) AS integer) from t1 union select count(distinct f) from t1) and d>t1.c and t1.f not in (11,19,t1.b) then a else (c) end+(17)=c then t1.d else t1.c end-c FROM t1 WHERE 13 not in (e,t1.b,+coalesce((select max(b) from t1 where 13*b-t1.d-case when 11>=a then t1.a-t1.d else (t1.d)*e+19 end*t1.a+19+(11) | t1.c*t1.a-17<t1.e),b)-a+17*17*c)}
+} {-399}
+do_test randexpr-2.91 {
+ db eval {SELECT case when t1.f>t1.d then (select abs(+count(distinct c)+(abs(min((abs(+11)/abs(b)))* -count(*)))) from t1)-t1.a when d+case when (select cast(avg(t1.f) AS integer)-count(distinct 19) from t1)<>17 then c when t1.e in (select cast(avg(t1.a) AS integer) from t1 union select count(distinct f) from t1) and d>t1.c and t1.f not in (11,19,t1.b) then a else (c) end+(17)=c then t1.d else t1.c end-c FROM t1 WHERE NOT (13 not in (e,t1.b,+coalesce((select max(b) from t1 where 13*b-t1.d-case when 11>=a then t1.a-t1.d else (t1.d)*e+19 end*t1.a+19+(11) | t1.c*t1.a-17<t1.e),b)-a+17*17*c))}
+} {}
+do_test randexpr-2.92 {
+ db eval {SELECT coalesce((select +19 from t1 where 19-c+t1.c-f not in (coalesce((select 19 from t1 where (t1.b between t1.c*t1.a*t1.b | a-e | 13-(abs(19)/abs((select max(t1.d | coalesce((select max( -t1.c) from t1 where b in (select e from t1 union select (f) from t1)),t1.d)+(e)) from t1)+c)) and f)),11),f,17)),f) FROM t1 WHERE (select count(distinct 11)+min((coalesce((select max(case when t1.d<>(abs(t1.a)/abs(e)) then d else ~(t1.e)-e+d+13-t1.b+b*19 end) from t1 where (select max(19)-cast(avg(a) AS integer) from t1)> -t1.e),17)+e+t1.e-t1.c+(c))*17) from t1) between -17 and t1.c}
+} {}
+do_test randexpr-2.93 {
+ db eval {SELECT coalesce((select +19 from t1 where 19-c+t1.c-f not in (coalesce((select 19 from t1 where (t1.b between t1.c*t1.a*t1.b | a-e | 13-(abs(19)/abs((select max(t1.d | coalesce((select max( -t1.c) from t1 where b in (select e from t1 union select (f) from t1)),t1.d)+(e)) from t1)+c)) and f)),11),f,17)),f) FROM t1 WHERE NOT ((select count(distinct 11)+min((coalesce((select max(case when t1.d<>(abs(t1.a)/abs(e)) then d else ~(t1.e)-e+d+13-t1.b+b*19 end) from t1 where (select max(19)-cast(avg(a) AS integer) from t1)> -t1.e),17)+e+t1.e-t1.c+(c))*17) from t1) between -17 and t1.c)}
+} {19}
+do_test randexpr-2.94 {
+ db eval {SELECT coalesce((select +19 from t1 where 19-c+t1.c-f not in (coalesce((select 19 from t1 where (t1.b between t1.c*t1.a*t1.b & a-e & 13-(abs(19)/abs((select max(t1.d & coalesce((select max( -t1.c) from t1 where b in (select e from t1 union select (f) from t1)),t1.d)+(e)) from t1)+c)) and f)),11),f,17)),f) FROM t1 WHERE NOT ((select count(distinct 11)+min((coalesce((select max(case when t1.d<>(abs(t1.a)/abs(e)) then d else ~(t1.e)-e+d+13-t1.b+b*19 end) from t1 where (select max(19)-cast(avg(a) AS integer) from t1)> -t1.e),17)+e+t1.e-t1.c+(c))*17) from t1) between -17 and t1.c)}
+} {19}
+do_test randexpr-2.95 {
+ db eval {SELECT (case t1.a when (select (count(distinct t1.f)) from t1)-e then 11 else t1.c+17-f*~f | f+~e-a*t1.b+13 end | 13) FROM t1 WHERE (coalesce((select max(f) from t1 where (c+t1.f | (select count(distinct t1.d) from t1)>=coalesce((select b+(abs(case when t1.f>=(select case max(f) when max(19) then cast(avg(t1.a) AS integer) else count(distinct 13) end from t1) | t1.b and (a in (select (b) from t1 union select t1.b from t1)) then (a)-b when not exists(select 1 from t1 where c between t1.c and t1.a) then a else t1.a end)/abs(t1.b))- -f from t1 where b not in (t1.b,t1.f,c)),t1.d)-t1.d)), -17) between 13 and t1.f)}
+} {-19491}
+do_test randexpr-2.96 {
+ db eval {SELECT (case t1.a when (select (count(distinct t1.f)) from t1)-e then 11 else t1.c+17-f*~f | f+~e-a*t1.b+13 end | 13) FROM t1 WHERE NOT ((coalesce((select max(f) from t1 where (c+t1.f | (select count(distinct t1.d) from t1)>=coalesce((select b+(abs(case when t1.f>=(select case max(f) when max(19) then cast(avg(t1.a) AS integer) else count(distinct 13) end from t1) | t1.b and (a in (select (b) from t1 union select t1.b from t1)) then (a)-b when not exists(select 1 from t1 where c between t1.c and t1.a) then a else t1.a end)/abs(t1.b))- -f from t1 where b not in (t1.b,t1.f,c)),t1.d)-t1.d)), -17) between 13 and t1.f))}
+} {}
+do_test randexpr-2.97 {
+ db eval {SELECT (case t1.a when (select (count(distinct t1.f)) from t1)-e then 11 else t1.c+17-f*~f & f+~e-a*t1.b+13 end & 13) FROM t1 WHERE (coalesce((select max(f) from t1 where (c+t1.f | (select count(distinct t1.d) from t1)>=coalesce((select b+(abs(case when t1.f>=(select case max(f) when max(19) then cast(avg(t1.a) AS integer) else count(distinct 13) end from t1) | t1.b and (a in (select (b) from t1 union select t1.b from t1)) then (a)-b when not exists(select 1 from t1 where c between t1.c and t1.a) then a else t1.a end)/abs(t1.b))- -f from t1 where b not in (t1.b,t1.f,c)),t1.d)-t1.d)), -17) between 13 and t1.f)}
+} {0}
+do_test randexpr-2.98 {
+ db eval {SELECT case when ((select -abs(min(coalesce((select max(11 | t1.f) from t1 where coalesce((select f from t1 where e+c in (select 19 from t1 union select f from t1)),b) not in (t1.a,+case when 13>=t1.e then t1.a when 17 not in (t1.d,b,t1.e) then 13 else t1.b end-t1.e,t1.f)),t1.f))*count(*)*min(t1.c)) from t1)<17) and 13* -f+a not between (a) and f then c-11+b else 19 end FROM t1 WHERE e+case case when a<>c then (abs(case when coalesce((select (abs( -19+11)/abs(t1.c)) from t1 where (17) in (a,13,11) and 17 in (select 11 from t1 union select t1.f from t1)),t1.a) between t1.f and c then t1.d when not exists(select 1 from t1 where not exists(select 1 from t1 where 19=f)) then f else (b) end-19)/abs(e)) else 11 end when 17 then a else t1.f end-13 | e between -t1.e and 13}
+} {}
+do_test randexpr-2.99 {
+ db eval {SELECT case when ((select -abs(min(coalesce((select max(11 | t1.f) from t1 where coalesce((select f from t1 where e+c in (select 19 from t1 union select f from t1)),b) not in (t1.a,+case when 13>=t1.e then t1.a when 17 not in (t1.d,b,t1.e) then 13 else t1.b end-t1.e,t1.f)),t1.f))*count(*)*min(t1.c)) from t1)<17) and 13* -f+a not between (a) and f then c-11+b else 19 end FROM t1 WHERE NOT (e+case case when a<>c then (abs(case when coalesce((select (abs( -19+11)/abs(t1.c)) from t1 where (17) in (a,13,11) and 17 in (select 11 from t1 union select t1.f from t1)),t1.a) between t1.f and c then t1.d when not exists(select 1 from t1 where not exists(select 1 from t1 where 19=f)) then f else (b) end-19)/abs(e)) else 11 end when 17 then a else t1.f end-13 | e between -t1.e and 13)}
+} {489}
+do_test randexpr-2.100 {
+ db eval {SELECT case when ((select -abs(min(coalesce((select max(11 & t1.f) from t1 where coalesce((select f from t1 where e+c in (select 19 from t1 union select f from t1)),b) not in (t1.a,+case when 13>=t1.e then t1.a when 17 not in (t1.d,b,t1.e) then 13 else t1.b end-t1.e,t1.f)),t1.f))*count(*)*min(t1.c)) from t1)<17) and 13* -f+a not between (a) and f then c-11+b else 19 end FROM t1 WHERE NOT (e+case case when a<>c then (abs(case when coalesce((select (abs( -19+11)/abs(t1.c)) from t1 where (17) in (a,13,11) and 17 in (select 11 from t1 union select t1.f from t1)),t1.a) between t1.f and c then t1.d when not exists(select 1 from t1 where not exists(select 1 from t1 where 19=f)) then f else (b) end-19)/abs(e)) else 11 end when 17 then a else t1.f end-13 | e between -t1.e and 13)}
+} {489}
+do_test randexpr-2.101 {
+ db eval {SELECT case when t1.b-t1.e*c<>c then coalesce((select -17 from t1 where (t1.f+((select case count(*) when -cast(avg(19) AS integer)+count(distinct (t1.c)) | (cast(avg(19) AS integer))*max(t1.c)*count(*)-((count(*))) then cast(avg(b) AS integer) else (count(*)) end-min(a) from t1)) | case when t1.b | a in (select t1.a from t1 union select (select count(distinct e) from t1) from t1) then t1.e else b end+t1.a)<e),17) else 19 end FROM t1 WHERE case -coalesce((select d-+t1.d-13-b from t1 where case when not exists(select 1 from t1 where (t1.a-t1.f in (select t1.e from t1 union select 17 from t1)) or 19<=t1.a) then t1.c-b else b end in (select -max(13)++abs(max(t1.c))*+max(t1.d) from t1 union select cast(avg(t1.e) AS integer) from t1)),13) | t1.d when (t1.f) then f else a end not between 11 and b}
+} {}
+do_test randexpr-2.102 {
+ db eval {SELECT case when t1.b-t1.e*c<>c then coalesce((select -17 from t1 where (t1.f+((select case count(*) when -cast(avg(19) AS integer)+count(distinct (t1.c)) | (cast(avg(19) AS integer))*max(t1.c)*count(*)-((count(*))) then cast(avg(b) AS integer) else (count(*)) end-min(a) from t1)) | case when t1.b | a in (select t1.a from t1 union select (select count(distinct e) from t1) from t1) then t1.e else b end+t1.a)<e),17) else 19 end FROM t1 WHERE NOT (case -coalesce((select d-+t1.d-13-b from t1 where case when not exists(select 1 from t1 where (t1.a-t1.f in (select t1.e from t1 union select 17 from t1)) or 19<=t1.a) then t1.c-b else b end in (select -max(13)++abs(max(t1.c))*+max(t1.d) from t1 union select cast(avg(t1.e) AS integer) from t1)),13) | t1.d when (t1.f) then f else a end not between 11 and b)}
+} {17}
+do_test randexpr-2.103 {
+ db eval {SELECT case when t1.b-t1.e*c<>c then coalesce((select -17 from t1 where (t1.f+((select case count(*) when -cast(avg(19) AS integer)+count(distinct (t1.c)) & (cast(avg(19) AS integer))*max(t1.c)*count(*)-((count(*))) then cast(avg(b) AS integer) else (count(*)) end-min(a) from t1)) & case when t1.b & a in (select t1.a from t1 union select (select count(distinct e) from t1) from t1) then t1.e else b end+t1.a)<e),17) else 19 end FROM t1 WHERE NOT (case -coalesce((select d-+t1.d-13-b from t1 where case when not exists(select 1 from t1 where (t1.a-t1.f in (select t1.e from t1 union select 17 from t1)) or 19<=t1.a) then t1.c-b else b end in (select -max(13)++abs(max(t1.c))*+max(t1.d) from t1 union select cast(avg(t1.e) AS integer) from t1)),13) | t1.d when (t1.f) then f else a end not between 11 and b)}
+} {-17}
+do_test randexpr-2.104 {
+ db eval {SELECT coalesce((select max(case when (select ~cast(avg(a) AS integer) from t1)>~t1.a then f else +~11 end) from t1 where ((select case ~abs(count(distinct t1.e)+(count(*)+count(*)+(abs( -~count(*) | max((t1.b))))))*(cast(avg(t1.a) AS integer)) when (count(*)) then min(19) else -(min(b)) end from t1))+11<>t1.f), -c-f) FROM t1 WHERE ~e>coalesce((select max(case case case coalesce((select max(coalesce((select c from t1 where t1.a-t1.c>13),13)) from t1 where -b not in (case d when ~t1.f | t1.c then 13 else 11 end,19,19)),t1.d) when c then t1.a else t1.b end+f-e*b when f then 19 else -t1.b end when t1.b then 11 else 13 end) from t1 where c in (select 19 from t1 union select e from t1)),t1.d)}
+} {}
+do_test randexpr-2.105 {
+ db eval {SELECT coalesce((select max(case when (select ~cast(avg(a) AS integer) from t1)>~t1.a then f else +~11 end) from t1 where ((select case ~abs(count(distinct t1.e)+(count(*)+count(*)+(abs( -~count(*) | max((t1.b))))))*(cast(avg(t1.a) AS integer)) when (count(*)) then min(19) else -(min(b)) end from t1))+11<>t1.f), -c-f) FROM t1 WHERE NOT (~e>coalesce((select max(case case case coalesce((select max(coalesce((select c from t1 where t1.a-t1.c>13),13)) from t1 where -b not in (case d when ~t1.f | t1.c then 13 else 11 end,19,19)),t1.d) when c then t1.a else t1.b end+f-e*b when f then 19 else -t1.b end when t1.b then 11 else 13 end) from t1 where c in (select 19 from t1 union select e from t1)),t1.d))}
+} {-12}
+do_test randexpr-2.106 {
+ db eval {SELECT coalesce((select max(case when (select ~cast(avg(a) AS integer) from t1)>~t1.a then f else +~11 end) from t1 where ((select case ~abs(count(distinct t1.e)+(count(*)+count(*)+(abs( -~count(*) & max((t1.b))))))*(cast(avg(t1.a) AS integer)) when (count(*)) then min(19) else -(min(b)) end from t1))+11<>t1.f), -c-f) FROM t1 WHERE NOT (~e>coalesce((select max(case case case coalesce((select max(coalesce((select c from t1 where t1.a-t1.c>13),13)) from t1 where -b not in (case d when ~t1.f | t1.c then 13 else 11 end,19,19)),t1.d) when c then t1.a else t1.b end+f-e*b when f then 19 else -t1.b end when t1.b then 11 else 13 end) from t1 where c in (select 19 from t1 union select e from t1)),t1.d))}
+} {-12}
+do_test randexpr-2.107 {
+ db eval {SELECT coalesce((select a from t1 where b>=~11-coalesce((select max((abs(19)/abs(t1.e))+19+t1.d) from t1 where (select abs(count(*) | count(*) | case count(*) when cast(avg(17) AS integer) then -cast(avg(b) AS integer) else count(*) end*min(b))*(min(t1.e)) from t1) in (11*(select count(*) from t1)*17*t1.e-e*t1.b,t1.e,t1.f)),a)*t1.d),13)-f FROM t1 WHERE ~((case when not 13-+t1.c>=17 then -~ -b+t1.f+case when t1.c<t1.b then t1.b when e*t1.b in (c,f,19) then (abs(a)/abs(case when 13=e then t1.e when -a<>t1.d then 11 else t1.e end)) else t1.b end when d>a then (a) else t1.b end))+t1.c in (13,t1.a,13) or t1.e>c}
+} {-500}
+do_test randexpr-2.108 {
+ db eval {SELECT coalesce((select a from t1 where b>=~11-coalesce((select max((abs(19)/abs(t1.e))+19+t1.d) from t1 where (select abs(count(*) | count(*) | case count(*) when cast(avg(17) AS integer) then -cast(avg(b) AS integer) else count(*) end*min(b))*(min(t1.e)) from t1) in (11*(select count(*) from t1)*17*t1.e-e*t1.b,t1.e,t1.f)),a)*t1.d),13)-f FROM t1 WHERE NOT (~((case when not 13-+t1.c>=17 then -~ -b+t1.f+case when t1.c<t1.b then t1.b when e*t1.b in (c,f,19) then (abs(a)/abs(case when 13=e then t1.e when -a<>t1.d then 11 else t1.e end)) else t1.b end when d>a then (a) else t1.b end))+t1.c in (13,t1.a,13) or t1.e>c)}
+} {}
+do_test randexpr-2.109 {
+ db eval {SELECT coalesce((select a from t1 where b>=~11-coalesce((select max((abs(19)/abs(t1.e))+19+t1.d) from t1 where (select abs(count(*) & count(*) & case count(*) when cast(avg(17) AS integer) then -cast(avg(b) AS integer) else count(*) end*min(b))*(min(t1.e)) from t1) in (11*(select count(*) from t1)*17*t1.e-e*t1.b,t1.e,t1.f)),a)*t1.d),13)-f FROM t1 WHERE ~((case when not 13-+t1.c>=17 then -~ -b+t1.f+case when t1.c<t1.b then t1.b when e*t1.b in (c,f,19) then (abs(a)/abs(case when 13=e then t1.e when -a<>t1.d then 11 else t1.e end)) else t1.b end when d>a then (a) else t1.b end))+t1.c in (13,t1.a,13) or t1.e>c}
+} {-500}
+do_test randexpr-2.110 {
+ db eval {SELECT case when 13>=~t1.a or (exists(select 1 from t1 where 11 not in (17,t1.f,17))) then f when not exists(select 1 from t1 where exists(select 1 from t1 where 13 not between e and ~+case b when t1.f then case -case f when 11 then -17 else 19 end+17 when b then b else 13 end else 13 end- -t1.a and t1.c not in (t1.f,a,c) or t1.f<11)) then t1.c else 11 end FROM t1 WHERE +t1.e in (select cast(avg(t1.c*t1.a*(abs(13)/abs(t1.e))) AS integer) from t1 union select min(c+13) from t1)}
+} {}
+do_test randexpr-2.111 {
+ db eval {SELECT case when 13>=~t1.a or (exists(select 1 from t1 where 11 not in (17,t1.f,17))) then f when not exists(select 1 from t1 where exists(select 1 from t1 where 13 not between e and ~+case b when t1.f then case -case f when 11 then -17 else 19 end+17 when b then b else 13 end else 13 end- -t1.a and t1.c not in (t1.f,a,c) or t1.f<11)) then t1.c else 11 end FROM t1 WHERE NOT (+t1.e in (select cast(avg(t1.c*t1.a*(abs(13)/abs(t1.e))) AS integer) from t1 union select min(c+13) from t1))}
+} {600}
+do_test randexpr-2.112 {
+ db eval {SELECT case when coalesce((select max(13) from t1 where coalesce((select max(c) from t1 where coalesce((select max(17) from t1 where 11 in (select ~d | case when t1.a>+19 then 11 when t1.d not in ( -e,e,c) or 13<t1.c then t1.b else d end-t1.d from t1 union select e from t1)),t1.b) in (select e from t1 union select c from t1)),d)<>d or t1.e<>b),t1.b)*13<=f then -t1.e when 19 between -t1.f and t1.a then -t1.b else t1.f end FROM t1 WHERE exists(select 1 from t1 where t1.f between a and coalesce((select max(t1.f) from t1 where exists(select 1 from t1 where coalesce((select 19 from t1 where t1.c=b),a)= -t1.b and not exists(select 1 from t1 where b between e and b) and a<= -17 or exists(select 1 from t1 where 17<=f)) or t1.a>=t1.c),13)*~13*t1.c*13 or t1.d>13 and 11>=t1.d and 11 not between c and c and t1.f>=17 and (d)=f)}
+} {}
+do_test randexpr-2.113 {
+ db eval {SELECT case when coalesce((select max(13) from t1 where coalesce((select max(c) from t1 where coalesce((select max(17) from t1 where 11 in (select ~d | case when t1.a>+19 then 11 when t1.d not in ( -e,e,c) or 13<t1.c then t1.b else d end-t1.d from t1 union select e from t1)),t1.b) in (select e from t1 union select c from t1)),d)<>d or t1.e<>b),t1.b)*13<=f then -t1.e when 19 between -t1.f and t1.a then -t1.b else t1.f end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.f between a and coalesce((select max(t1.f) from t1 where exists(select 1 from t1 where coalesce((select 19 from t1 where t1.c=b),a)= -t1.b and not exists(select 1 from t1 where b between e and b) and a<= -17 or exists(select 1 from t1 where 17<=f)) or t1.a>=t1.c),13)*~13*t1.c*13 or t1.d>13 and 11>=t1.d and 11 not between c and c and t1.f>=17 and (d)=f))}
+} {-500}
+do_test randexpr-2.114 {
+ db eval {SELECT case when coalesce((select max(13) from t1 where coalesce((select max(c) from t1 where coalesce((select max(17) from t1 where 11 in (select ~d & case when t1.a>+19 then 11 when t1.d not in ( -e,e,c) or 13<t1.c then t1.b else d end-t1.d from t1 union select e from t1)),t1.b) in (select e from t1 union select c from t1)),d)<>d or t1.e<>b),t1.b)*13<=f then -t1.e when 19 between -t1.f and t1.a then -t1.b else t1.f end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.f between a and coalesce((select max(t1.f) from t1 where exists(select 1 from t1 where coalesce((select 19 from t1 where t1.c=b),a)= -t1.b and not exists(select 1 from t1 where b between e and b) and a<= -17 or exists(select 1 from t1 where 17<=f)) or t1.a>=t1.c),13)*~13*t1.c*13 or t1.d>13 and 11>=t1.d and 11 not between c and c and t1.f>=17 and (d)=f))}
+} {-500}
+do_test randexpr-2.115 {
+ db eval {SELECT case when coalesce((select +case when not exists(select 1 from t1 where 19*t1.e< -~11*a or t1.b>=t1.c and t1.a<>e) then coalesce((select max(13) from t1 where 11>11), -(e)) | t1.a when (t1.d) in (select f from t1 union select b from t1) then a else e end from t1 where t1.f<> -t1.d),t1.b) not in (d,t1.d,t1.c) then 19 when (t1.b<>t1.e or -t1.b>=t1.b) then (f) else d end FROM t1 WHERE t1.e=a and b>=(abs(case when 19 not between ~+17 and +case when ((b+e-f=t1.d or b not in (t1.a,t1.f,t1.b) or t1.a not between 19 and e or b>=(t1.d) or t1.b not in (d,t1.a,t1.b))) then e-f else t1.e*t1.f end | f then d else -d end)/abs(11))}
+} {}
+do_test randexpr-2.116 {
+ db eval {SELECT case when coalesce((select +case when not exists(select 1 from t1 where 19*t1.e< -~11*a or t1.b>=t1.c and t1.a<>e) then coalesce((select max(13) from t1 where 11>11), -(e)) | t1.a when (t1.d) in (select f from t1 union select b from t1) then a else e end from t1 where t1.f<> -t1.d),t1.b) not in (d,t1.d,t1.c) then 19 when (t1.b<>t1.e or -t1.b>=t1.b) then (f) else d end FROM t1 WHERE NOT (t1.e=a and b>=(abs(case when 19 not between ~+17 and +case when ((b+e-f=t1.d or b not in (t1.a,t1.f,t1.b) or t1.a not between 19 and e or b>=(t1.d) or t1.b not in (d,t1.a,t1.b))) then e-f else t1.e*t1.f end | f then d else -d end)/abs(11)))}
+} {19}
+do_test randexpr-2.117 {
+ db eval {SELECT case when coalesce((select +case when not exists(select 1 from t1 where 19*t1.e< -~11*a or t1.b>=t1.c and t1.a<>e) then coalesce((select max(13) from t1 where 11>11), -(e)) & t1.a when (t1.d) in (select f from t1 union select b from t1) then a else e end from t1 where t1.f<> -t1.d),t1.b) not in (d,t1.d,t1.c) then 19 when (t1.b<>t1.e or -t1.b>=t1.b) then (f) else d end FROM t1 WHERE NOT (t1.e=a and b>=(abs(case when 19 not between ~+17 and +case when ((b+e-f=t1.d or b not in (t1.a,t1.f,t1.b) or t1.a not between 19 and e or b>=(t1.d) or t1.b not in (d,t1.a,t1.b))) then e-f else t1.e*t1.f end | f then d else -d end)/abs(11)))}
+} {19}
+do_test randexpr-2.118 {
+ db eval {SELECT (select (cast(avg(b) AS integer) | count(distinct case when coalesce((select 13 from t1 where (+(abs(e)/abs(t1.b))) in ( -b, -(a),13)),t1.e)>=b then 11 else - -19 end-17+19) | abs(~case count(distinct t1.b) when +min(e) then +abs(~ - -count(distinct 11)-count(distinct t1.b))-count(distinct a) else -min(b) end)*count(distinct 19)-count(distinct t1.b)) from t1) FROM t1 WHERE 11<=t1.a-t1.f-19*t1.b+19+coalesce((select e from t1 where d not between (select count(distinct coalesce((select t1.a from t1 where (select cast(avg(t1.e) AS integer)-+count(distinct c)+max((abs(t1.c)/abs(t1.f))-a)-(count(*)-cast(avg((17)) AS integer)) from t1) in (t1.e, -e | d,b)),c)) from t1) and t1.a),t1.d)-t1.d}
+} {}
+do_test randexpr-2.119 {
+ db eval {SELECT (select (cast(avg(b) AS integer) | count(distinct case when coalesce((select 13 from t1 where (+(abs(e)/abs(t1.b))) in ( -b, -(a),13)),t1.e)>=b then 11 else - -19 end-17+19) | abs(~case count(distinct t1.b) when +min(e) then +abs(~ - -count(distinct 11)-count(distinct t1.b))-count(distinct a) else -min(b) end)*count(distinct 19)-count(distinct t1.b)) from t1) FROM t1 WHERE NOT (11<=t1.a-t1.f-19*t1.b+19+coalesce((select e from t1 where d not between (select count(distinct coalesce((select t1.a from t1 where (select cast(avg(t1.e) AS integer)-+count(distinct c)+max((abs(t1.c)/abs(t1.f))-a)-(count(*)-cast(avg((17)) AS integer)) from t1) in (t1.e, -e | d,b)),c)) from t1) and t1.a),t1.d)-t1.d)}
+} {207}
+do_test randexpr-2.120 {
+ db eval {SELECT (select (cast(avg(b) AS integer) & count(distinct case when coalesce((select 13 from t1 where (+(abs(e)/abs(t1.b))) in ( -b, -(a),13)),t1.e)>=b then 11 else - -19 end-17+19) & abs(~case count(distinct t1.b) when +min(e) then +abs(~ - -count(distinct 11)-count(distinct t1.b))-count(distinct a) else -min(b) end)*count(distinct 19)-count(distinct t1.b)) from t1) FROM t1 WHERE NOT (11<=t1.a-t1.f-19*t1.b+19+coalesce((select e from t1 where d not between (select count(distinct coalesce((select t1.a from t1 where (select cast(avg(t1.e) AS integer)-+count(distinct c)+max((abs(t1.c)/abs(t1.f))-a)-(count(*)-cast(avg((17)) AS integer)) from t1) in (t1.e, -e | d,b)),c)) from t1) and t1.a),t1.d)-t1.d)}
+} {0}
+do_test randexpr-2.121 {
+ db eval {SELECT 11+a*case t1.a*t1.e when 17 then coalesce((select +t1.b from t1 where t1.c<>t1.c and e between +(abs(case b+f*coalesce((select c from t1 where t1.d>17), -t1.c)+(19) when b then t1.f else t1.d end)/abs(t1.d)) and t1.c and t1.a>b or t1.f<t1.a),t1.c)*17 else -t1.d end*t1.b FROM t1 WHERE -19-~t1.b<(select ~count(*) from t1)+(abs(++coalesce((select max(t1.a-c) from t1 where t1.a=11),11))/abs(case when not not exists(select 1 from t1 where exists(select 1 from t1 where t1.a>c or t1.d | 11 in (select t1.e from t1 union select d from t1))) then 17 else (abs(coalesce((select max(f) from t1 where not (c)<t1.a),t1.b))/abs(d))+f end-t1.c))-t1.e-t1.e}
+} {}
+do_test randexpr-2.122 {
+ db eval {SELECT 11+a*case t1.a*t1.e when 17 then coalesce((select +t1.b from t1 where t1.c<>t1.c and e between +(abs(case b+f*coalesce((select c from t1 where t1.d>17), -t1.c)+(19) when b then t1.f else t1.d end)/abs(t1.d)) and t1.c and t1.a>b or t1.f<t1.a),t1.c)*17 else -t1.d end*t1.b FROM t1 WHERE NOT ( -19-~t1.b<(select ~count(*) from t1)+(abs(++coalesce((select max(t1.a-c) from t1 where t1.a=11),11))/abs(case when not not exists(select 1 from t1 where exists(select 1 from t1 where t1.a>c or t1.d | 11 in (select t1.e from t1 union select d from t1))) then 17 else (abs(coalesce((select max(f) from t1 where not (c)<t1.a),t1.b))/abs(d))+f end-t1.c))-t1.e-t1.e)}
+} {-7999989}
+do_test randexpr-2.123 {
+ db eval {SELECT (e)+case when t1.a>e then t1.f else t1.b+case when b between coalesce((select max(t1.d-~(abs(a)/abs(c))+t1.c) from t1 where f in (select -min(t1.f)-+cast(avg(e) AS integer) from t1 union select -(cast(avg(13) AS integer)) from t1) and f<=a and not exists(select 1 from t1 where f not between t1.d and t1.d or (f)<=a) and (t1.f) between 11 and d),t1.a) and t1.f then e when (11<d) then 11 else d end end | t1.e FROM t1 WHERE (abs(13)/abs(a)) in (+coalesce((select 13 from t1 where (t1.e in (select cast(avg(t1.c) AS integer) from t1 union select case +count(distinct t1.c) when +count(*) then ( -min( -b)) else count(*) end*max(e) from t1)) and +case when c in (select (11) from t1 union select -t1.c from t1) then 17 when 17 in (select 17 from t1 union select d from t1) then c else t1.a end>13),case when c<=11 then t1.e when t1.e<=b then t1.d else t1.e end)-11,11,17)}
+} {}
+do_test randexpr-2.124 {
+ db eval {SELECT (e)+case when t1.a>e then t1.f else t1.b+case when b between coalesce((select max(t1.d-~(abs(a)/abs(c))+t1.c) from t1 where f in (select -min(t1.f)-+cast(avg(e) AS integer) from t1 union select -(cast(avg(13) AS integer)) from t1) and f<=a and not exists(select 1 from t1 where f not between t1.d and t1.d or (f)<=a) and (t1.f) between 11 and d),t1.a) and t1.f then e when (11<d) then 11 else d end end | t1.e FROM t1 WHERE NOT ((abs(13)/abs(a)) in (+coalesce((select 13 from t1 where (t1.e in (select cast(avg(t1.c) AS integer) from t1 union select case +count(distinct t1.c) when +count(*) then ( -min( -b)) else count(*) end*max(e) from t1)) and +case when c in (select (11) from t1 union select -t1.c from t1) then 17 when 17 in (select 17 from t1 union select d from t1) then c else t1.a end>13),case when c<=11 then t1.e when t1.e<=b then t1.d else t1.e end)-11,11,17))}
+} {1524}
+do_test randexpr-2.125 {
+ db eval {SELECT (e)+case when t1.a>e then t1.f else t1.b+case when b between coalesce((select max(t1.d-~(abs(a)/abs(c))+t1.c) from t1 where f in (select -min(t1.f)-+cast(avg(e) AS integer) from t1 union select -(cast(avg(13) AS integer)) from t1) and f<=a and not exists(select 1 from t1 where f not between t1.d and t1.d or (f)<=a) and (t1.f) between 11 and d),t1.a) and t1.f then e when (11<d) then 11 else d end end & t1.e FROM t1 WHERE NOT ((abs(13)/abs(a)) in (+coalesce((select 13 from t1 where (t1.e in (select cast(avg(t1.c) AS integer) from t1 union select case +count(distinct t1.c) when +count(*) then ( -min( -b)) else count(*) end*max(e) from t1)) and +case when c in (select (11) from t1 union select -t1.c from t1) then 17 when 17 in (select 17 from t1 union select d from t1) then c else t1.a end>13),case when c<=11 then t1.e when t1.e<=b then t1.d else t1.e end)-11,11,17))}
+} {176}
+do_test randexpr-2.126 {
+ db eval {SELECT coalesce((select max(~d-t1.f+b-13) from t1 where t1.c not between case when +f=t1.b then 13 when ~f not in (~t1.a,coalesce((select max(t1.b) from t1 where b between c-t1.c+e and (t1.b)),coalesce((select max(t1.d) from t1 where not e in (select 17 from t1 union select t1.c+e | a from t1)),b)),t1.e) then t1.b else a end and c),t1.a) FROM t1 WHERE (select (++ -count(*) | cast(avg(t1.b) AS integer) | ++(max(t1.d))+count(*)+max(t1.b)-count(distinct t1.e)-+abs( -+~max((abs(t1.c)/abs((select min(a) from t1)))))+count(distinct t1.a-t1.b)) from t1) between e and c}
+} {}
+do_test randexpr-2.127 {
+ db eval {SELECT coalesce((select max(~d-t1.f+b-13) from t1 where t1.c not between case when +f=t1.b then 13 when ~f not in (~t1.a,coalesce((select max(t1.b) from t1 where b between c-t1.c+e and (t1.b)),coalesce((select max(t1.d) from t1 where not e in (select 17 from t1 union select t1.c+e | a from t1)),b)),t1.e) then t1.b else a end and c),t1.a) FROM t1 WHERE NOT ((select (++ -count(*) | cast(avg(t1.b) AS integer) | ++(max(t1.d))+count(*)+max(t1.b)-count(distinct t1.e)-+abs( -+~max((abs(t1.c)/abs((select min(a) from t1)))))+count(distinct t1.a-t1.b)) from t1) between e and c)}
+} {100}
+do_test randexpr-2.128 {
+ db eval {SELECT coalesce((select max(~d-t1.f+b-13) from t1 where t1.c not between case when +f=t1.b then 13 when ~f not in (~t1.a,coalesce((select max(t1.b) from t1 where b between c-t1.c+e and (t1.b)),coalesce((select max(t1.d) from t1 where not e in (select 17 from t1 union select t1.c+e & a from t1)),b)),t1.e) then t1.b else a end and c),t1.a) FROM t1 WHERE NOT ((select (++ -count(*) | cast(avg(t1.b) AS integer) | ++(max(t1.d))+count(*)+max(t1.b)-count(distinct t1.e)-+abs( -+~max((abs(t1.c)/abs((select min(a) from t1)))))+count(distinct t1.a-t1.b)) from t1) between e and c)}
+} {100}
+do_test randexpr-2.129 {
+ db eval {SELECT a+case when exists(select 1 from t1 where 19>=e) then b*b+coalesce((select max( -coalesce((select max(19 | t1.e) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where +case t1.a when a then a else (17) end*19 in (select max(d) from t1 union select max(t1.a) from t1) and not exists(select 1 from t1 where t1.a<=11)) or 11>(19))),11* -a)) from t1 where t1.e<>17),f) else t1.e end-11 FROM t1 WHERE (t1.a>=(abs(coalesce((select +13*t1.a | c from t1 where 11+case when exists(select 1 from t1 where case when +t1.d in (select case +count(*) when count(distinct 11) then count(*) else (min(11)) end from t1 union select max( -11) from t1) or 11<> -t1.f then t1.d when t1.b in (13,a,d) then c else c end+t1.b=b) then e-c else (t1.d) end>t1.d),d))/abs(t1.f)) and 11 in (select -t1.a from t1 union select 13 from t1))}
+} {}
+do_test randexpr-2.130 {
+ db eval {SELECT a+case when exists(select 1 from t1 where 19>=e) then b*b+coalesce((select max( -coalesce((select max(19 | t1.e) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where +case t1.a when a then a else (17) end*19 in (select max(d) from t1 union select max(t1.a) from t1) and not exists(select 1 from t1 where t1.a<=11)) or 11>(19))),11* -a)) from t1 where t1.e<>17),f) else t1.e end-11 FROM t1 WHERE NOT ((t1.a>=(abs(coalesce((select +13*t1.a | c from t1 where 11+case when exists(select 1 from t1 where case when +t1.d in (select case +count(*) when count(distinct 11) then count(*) else (min(11)) end from t1 union select max( -11) from t1) or 11<> -t1.f then t1.d when t1.b in (13,a,d) then c else c end+t1.b=b) then e-c else (t1.d) end>t1.d),d))/abs(t1.f)) and 11 in (select -t1.a from t1 union select 13 from t1)))}
+} {589}
+do_test randexpr-2.131 {
+ db eval {SELECT a+case when exists(select 1 from t1 where 19>=e) then b*b+coalesce((select max( -coalesce((select max(19 & t1.e) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where +case t1.a when a then a else (17) end*19 in (select max(d) from t1 union select max(t1.a) from t1) and not exists(select 1 from t1 where t1.a<=11)) or 11>(19))),11* -a)) from t1 where t1.e<>17),f) else t1.e end-11 FROM t1 WHERE NOT ((t1.a>=(abs(coalesce((select +13*t1.a | c from t1 where 11+case when exists(select 1 from t1 where case when +t1.d in (select case +count(*) when count(distinct 11) then count(*) else (min(11)) end from t1 union select max( -11) from t1) or 11<> -t1.f then t1.d when t1.b in (13,a,d) then c else c end+t1.b=b) then e-c else (t1.d) end>t1.d),d))/abs(t1.f)) and 11 in (select -t1.a from t1 union select 13 from t1)))}
+} {589}
+do_test randexpr-2.132 {
+ db eval {SELECT case ~13 when t1.e then e else (select case case (abs(count(*))-~count(*)+count(*) | count(*)-count(*)+max(t1.b)* -(cast(avg(13) AS integer)) | -(count(distinct t1.c))) when min(e) then (min(13)) else count(*) end*count(*) when max(e) then count(distinct -d) else count(*) end from t1) end-t1.d*case (abs(e | t1.b)/abs((select cast(avg(t1.c) AS integer) from t1))) when (select cast(avg(a) AS integer) from t1) then t1.c else f+13 end FROM t1 WHERE not exists(select 1 from t1 where coalesce((select case when t1.a>t1.f-~case when ~t1.d+c+t1.f>11 then t1.a when (f between t1.f and t1.c) then t1.f else 13 end*t1.a then t1.d when c<t1.e or e>19 then c else t1.e end from t1 where e<>a and 19<>t1.f),t1.b)+t1.f-t1.e<d)}
+} {-245199}
+do_test randexpr-2.133 {
+ db eval {SELECT case ~13 when t1.e then e else (select case case (abs(count(*))-~count(*)+count(*) | count(*)-count(*)+max(t1.b)* -(cast(avg(13) AS integer)) | -(count(distinct t1.c))) when min(e) then (min(13)) else count(*) end*count(*) when max(e) then count(distinct -d) else count(*) end from t1) end-t1.d*case (abs(e | t1.b)/abs((select cast(avg(t1.c) AS integer) from t1))) when (select cast(avg(a) AS integer) from t1) then t1.c else f+13 end FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select case when t1.a>t1.f-~case when ~t1.d+c+t1.f>11 then t1.a when (f between t1.f and t1.c) then t1.f else 13 end*t1.a then t1.d when c<t1.e or e>19 then c else t1.e end from t1 where e<>a and 19<>t1.f),t1.b)+t1.f-t1.e<d))}
+} {}
+do_test randexpr-2.134 {
+ db eval {SELECT case ~13 when t1.e then e else (select case case (abs(count(*))-~count(*)+count(*) & count(*)-count(*)+max(t1.b)* -(cast(avg(13) AS integer)) & -(count(distinct t1.c))) when min(e) then (min(13)) else count(*) end*count(*) when max(e) then count(distinct -d) else count(*) end from t1) end-t1.d*case (abs(e & t1.b)/abs((select cast(avg(t1.c) AS integer) from t1))) when (select cast(avg(a) AS integer) from t1) then t1.c else f+13 end FROM t1 WHERE not exists(select 1 from t1 where coalesce((select case when t1.a>t1.f-~case when ~t1.d+c+t1.f>11 then t1.a when (f between t1.f and t1.c) then t1.f else 13 end*t1.a then t1.d when c<t1.e or e>19 then c else t1.e end from t1 where e<>a and 19<>t1.f),t1.b)+t1.f-t1.e<d)}
+} {-245199}
+do_test randexpr-2.135 {
+ db eval {SELECT 11-case when 17<=c and (select ( -abs(case count(*)+~case -min(e) when count(distinct t1.a) then -count(*) else min(a) end+max(t1.c) when count(*) then max(b) else -count(distinct 19) end)*cast(avg(17) AS integer)) from t1) not in (case f when e then 19 | 11 else (t1.d) end,d, -t1.b) then +t1.c when t1.d not in (11,c,t1.a) then 13 else a end-t1.d*t1.d FROM t1 WHERE ((abs((abs(coalesce((select a from t1 where (select max(case when t1.f=b then e when 11>t1.c and 11<>e then 13 else a end-(a))-max(t1.e)*count(distinct t1.f) | case max((f)) when (count(distinct f)) then count(*) else min(t1.c) end+min(19) from t1) not in (11,19,t1.e)),t1.f*17))/abs(a)))/abs(c)) in (select t1.c from t1 union select t1.a from t1)) or ( -t1.f=e)}
+} {}
+do_test randexpr-2.136 {
+ db eval {SELECT 11-case when 17<=c and (select ( -abs(case count(*)+~case -min(e) when count(distinct t1.a) then -count(*) else min(a) end+max(t1.c) when count(*) then max(b) else -count(distinct 19) end)*cast(avg(17) AS integer)) from t1) not in (case f when e then 19 | 11 else (t1.d) end,d, -t1.b) then +t1.c when t1.d not in (11,c,t1.a) then 13 else a end-t1.d*t1.d FROM t1 WHERE NOT (((abs((abs(coalesce((select a from t1 where (select max(case when t1.f=b then e when 11>t1.c and 11<>e then 13 else a end-(a))-max(t1.e)*count(distinct t1.f) | case max((f)) when (count(distinct f)) then count(*) else min(t1.c) end+min(19) from t1) not in (11,19,t1.e)),t1.f*17))/abs(a)))/abs(c)) in (select t1.c from t1 union select t1.a from t1)) or ( -t1.f=e))}
+} {-160289}
+do_test randexpr-2.137 {
+ db eval {SELECT 11-case when 17<=c and (select ( -abs(case count(*)+~case -min(e) when count(distinct t1.a) then -count(*) else min(a) end+max(t1.c) when count(*) then max(b) else -count(distinct 19) end)*cast(avg(17) AS integer)) from t1) not in (case f when e then 19 & 11 else (t1.d) end,d, -t1.b) then +t1.c when t1.d not in (11,c,t1.a) then 13 else a end-t1.d*t1.d FROM t1 WHERE NOT (((abs((abs(coalesce((select a from t1 where (select max(case when t1.f=b then e when 11>t1.c and 11<>e then 13 else a end-(a))-max(t1.e)*count(distinct t1.f) | case max((f)) when (count(distinct f)) then count(*) else min(t1.c) end+min(19) from t1) not in (11,19,t1.e)),t1.f*17))/abs(a)))/abs(c)) in (select t1.c from t1 union select t1.a from t1)) or ( -t1.f=e))}
+} {-160289}
+do_test randexpr-2.138 {
+ db eval {SELECT (f+case +t1.e when t1.d then 17 else f*19 end | -(abs( -coalesce((select 17* -c+19 from t1 where (abs(case 19*e*d when (select +(cast(avg( -11) AS integer)) | -count(*)*max( -13) from t1) then 11 | case t1.b when a then a else t1.f end else t1.a end)/abs(a)) in (select t1.b from t1 union select (a) from t1)),t1.b))/abs( -13))) FROM t1 WHERE +b in (select case case case when not ((~coalesce((select t1.e+d from t1 where (19 between f and t1.b)),(select cast(avg(c+t1.b) AS integer)++cast(avg(b) AS integer) from t1))) not in (t1.c+c,b,e)) or (13 not between d and t1.d) then 13 else b end when -11 then 13 else 19 end*t1.e when (f) then 19 else 19 end from t1 union select f from t1)}
+} {}
+do_test randexpr-2.139 {
+ db eval {SELECT (f+case +t1.e when t1.d then 17 else f*19 end | -(abs( -coalesce((select 17* -c+19 from t1 where (abs(case 19*e*d when (select +(cast(avg( -11) AS integer)) | -count(*)*max( -13) from t1) then 11 | case t1.b when a then a else t1.f end else t1.a end)/abs(a)) in (select t1.b from t1 union select (a) from t1)),t1.b))/abs( -13))) FROM t1 WHERE NOT (+b in (select case case case when not ((~coalesce((select t1.e+d from t1 where (19 between f and t1.b)),(select cast(avg(c+t1.b) AS integer)++cast(avg(b) AS integer) from t1))) not in (t1.c+c,b,e)) or (13 not between d and t1.d) then 13 else b end when -11 then 13 else 19 end*t1.e when (f) then 19 else 19 end from t1 union select f from t1))}
+} {-15}
+do_test randexpr-2.140 {
+ db eval {SELECT (f+case +t1.e when t1.d then 17 else f*19 end & -(abs( -coalesce((select 17* -c+19 from t1 where (abs(case 19*e*d when (select +(cast(avg( -11) AS integer)) & -count(*)*max( -13) from t1) then 11 & case t1.b when a then a else t1.f end else t1.a end)/abs(a)) in (select t1.b from t1 union select (a) from t1)),t1.b))/abs( -13))) FROM t1 WHERE NOT (+b in (select case case case when not ((~coalesce((select t1.e+d from t1 where (19 between f and t1.b)),(select cast(avg(c+t1.b) AS integer)++cast(avg(b) AS integer) from t1))) not in (t1.c+c,b,e)) or (13 not between d and t1.d) then 13 else b end when -11 then 13 else 19 end*t1.e when (f) then 19 else 19 end from t1 union select f from t1))}
+} {12000}
+do_test randexpr-2.141 {
+ db eval {SELECT 11*coalesce((select max(t1.f) from t1 where a-case t1.c when +coalesce((select t1.a-t1.b from t1 where (abs(19)/abs(b)) in (17-case when a<t1.b then t1.a when c not between 19 and t1.d then e else (t1.b) end, -t1.b,f) or 19 in (select t1.b from t1 union select t1.a from t1)),e)+t1.f*t1.b then t1.c else 13 end in (select t1.b from t1 union select f from t1) or e<>17),d)*(t1.e) FROM t1 WHERE (coalesce((select max(~t1.b) from t1 where t1.c in (select ~+case count(distinct a) when (max(t1.a)) then (count(*)) else ~+abs(cast(avg(d | t1.a) AS integer)+case (cast(avg(13) AS integer)) when cast(avg(b) AS integer) then cast(avg(t1.f) AS integer) else min(t1.a) end) | count(distinct c)*( -( -max(t1.f)))*count(*) end from t1 union select count(distinct -e) from t1)),~a-11)<19 or t1.a*13<>t1.d and not exists(select 1 from t1 where t1.e=e))}
+} {3300000}
+do_test randexpr-2.142 {
+ db eval {SELECT 11*coalesce((select max(t1.f) from t1 where a-case t1.c when +coalesce((select t1.a-t1.b from t1 where (abs(19)/abs(b)) in (17-case when a<t1.b then t1.a when c not between 19 and t1.d then e else (t1.b) end, -t1.b,f) or 19 in (select t1.b from t1 union select t1.a from t1)),e)+t1.f*t1.b then t1.c else 13 end in (select t1.b from t1 union select f from t1) or e<>17),d)*(t1.e) FROM t1 WHERE NOT ((coalesce((select max(~t1.b) from t1 where t1.c in (select ~+case count(distinct a) when (max(t1.a)) then (count(*)) else ~+abs(cast(avg(d | t1.a) AS integer)+case (cast(avg(13) AS integer)) when cast(avg(b) AS integer) then cast(avg(t1.f) AS integer) else min(t1.a) end) | count(distinct c)*( -( -max(t1.f)))*count(*) end from t1 union select count(distinct -e) from t1)),~a-11)<19 or t1.a*13<>t1.d and not exists(select 1 from t1 where t1.e=e)))}
+} {}
+do_test randexpr-2.143 {
+ db eval {SELECT 11+t1.b+17+case when 13 not between t1.d*(17)+d-t1.f and 13 then t1.d when case when case when t1.f not in (t1.b,c,t1.f) and -d between d and 11 then d else 19 end not between a and e then t1.b when t1.d in (17,13,11) then 19 else t1.e end*a>e then t1.a else t1.d end*f*e FROM t1 WHERE not exists(select 1 from t1 where (t1.f) in (b-b,(select +(max( -13*t1.c*c+t1.e+case t1.a when +t1.d-(c) then -t1.a else t1.c end | 19* -17)*count(distinct a) | (count(distinct t1.f)))++cast(avg(f) AS integer)-max(13) | cast(avg(b) AS integer) from t1),t1.f))}
+} {}
+do_test randexpr-2.144 {
+ db eval {SELECT 11+t1.b+17+case when 13 not between t1.d*(17)+d-t1.f and 13 then t1.d when case when case when t1.f not in (t1.b,c,t1.f) and -d between d and 11 then d else 19 end not between a and e then t1.b when t1.d in (17,13,11) then 19 else t1.e end*a>e then t1.a else t1.d end*f*e FROM t1 WHERE NOT (not exists(select 1 from t1 where (t1.f) in (b-b,(select +(max( -13*t1.c*c+t1.e+case t1.a when +t1.d-(c) then -t1.a else t1.c end | 19* -17)*count(distinct a) | (count(distinct t1.f)))++cast(avg(f) AS integer)-max(13) | cast(avg(b) AS integer) from t1),t1.f)))}
+} {120000228}
+do_test randexpr-2.145 {
+ db eval {SELECT ((abs(+((select count(*)*abs(min((abs(case (abs(c)/abs(f)) | e when case when 19>=d then 13 when a=f then 13 else f end then b else a end+t1.a)/abs(11))*t1.c*17))-cast(avg(e) AS integer)*count(*) from t1)))/abs(coalesce((select max(case when t1.a in (select t1.c from t1 union select 19 from t1) then e else t1.e end) from t1 where (t1.a<= -t1.e)),17)+c*13))) FROM t1 WHERE exists(select 1 from t1 where ~coalesce((select max(c) from t1 where exists(select 1 from t1 where case when not case coalesce((select max(coalesce((select d from t1 where exists(select 1 from t1 where a<(t1.c))),19)) from t1 where e=t1.e),13) when t1.e then t1.b else f end in (select abs((min(e))*(max(t1.d))+min(t1.e)*(( -((max(t1.a)))))) from t1 union select count(distinct t1.a) from t1) then coalesce((select t1.c from t1 where t1.a< -t1.c and a in (t1.b,t1.f,t1.c)),17) else 17 end>=t1.f)),t1.f)+t1.a*b in (select c from t1 union select 19 from t1)) or exists(select 1 from t1 where not t1.f not in (t1.f,11,t1.d) and 19<=19)}
+} {23}
+do_test randexpr-2.146 {
+ db eval {SELECT ((abs(+((select count(*)*abs(min((abs(case (abs(c)/abs(f)) | e when case when 19>=d then 13 when a=f then 13 else f end then b else a end+t1.a)/abs(11))*t1.c*17))-cast(avg(e) AS integer)*count(*) from t1)))/abs(coalesce((select max(case when t1.a in (select t1.c from t1 union select 19 from t1) then e else t1.e end) from t1 where (t1.a<= -t1.e)),17)+c*13))) FROM t1 WHERE NOT (exists(select 1 from t1 where ~coalesce((select max(c) from t1 where exists(select 1 from t1 where case when not case coalesce((select max(coalesce((select d from t1 where exists(select 1 from t1 where a<(t1.c))),19)) from t1 where e=t1.e),13) when t1.e then t1.b else f end in (select abs((min(e))*(max(t1.d))+min(t1.e)*(( -((max(t1.a)))))) from t1 union select count(distinct t1.a) from t1) then coalesce((select t1.c from t1 where t1.a< -t1.c and a in (t1.b,t1.f,t1.c)),17) else 17 end>=t1.f)),t1.f)+t1.a*b in (select c from t1 union select 19 from t1)) or exists(select 1 from t1 where not t1.f not in (t1.f,11,t1.d) and 19<=19))}
+} {}
+do_test randexpr-2.147 {
+ db eval {SELECT ((abs(+((select count(*)*abs(min((abs(case (abs(c)/abs(f)) & e when case when 19>=d then 13 when a=f then 13 else f end then b else a end+t1.a)/abs(11))*t1.c*17))-cast(avg(e) AS integer)*count(*) from t1)))/abs(coalesce((select max(case when t1.a in (select t1.c from t1 union select 19 from t1) then e else t1.e end) from t1 where (t1.a<= -t1.e)),17)+c*13))) FROM t1 WHERE exists(select 1 from t1 where ~coalesce((select max(c) from t1 where exists(select 1 from t1 where case when not case coalesce((select max(coalesce((select d from t1 where exists(select 1 from t1 where a<(t1.c))),19)) from t1 where e=t1.e),13) when t1.e then t1.b else f end in (select abs((min(e))*(max(t1.d))+min(t1.e)*(( -((max(t1.a)))))) from t1 union select count(distinct t1.a) from t1) then coalesce((select t1.c from t1 where t1.a< -t1.c and a in (t1.b,t1.f,t1.c)),17) else 17 end>=t1.f)),t1.f)+t1.a*b in (select c from t1 union select 19 from t1)) or exists(select 1 from t1 where not t1.f not in (t1.f,11,t1.d) and 19<=19)}
+} {23}
+do_test randexpr-2.148 {
+ db eval {SELECT coalesce((select max(case when t1.f between 17 and 11+case when not coalesce((select max(11) from t1 where t1.f in (select max(t1.d) from t1 union select -count(*) from t1) or 17=(13) or f in (( -t1.b),13,a)),case when d>13 then 13 else 11 end) between 19 and 19 then 19 when t1.c=d then e else 17 end then t1.e else t1.d end) from t1 where e in (select -(+max(11)-max((t1.a))+ -count(distinct d) | cast(avg(t1.a) AS integer)*count(distinct b))-count(*)* -count(distinct t1.e) from t1 union select cast(avg(d) AS integer) from t1)),d)+b FROM t1 WHERE (select +~abs( -min(t1.a)-abs(count(*)))+ -abs(+ -+case (cast(avg(a) AS integer)) when min(e+t1.d) then +case cast(avg(coalesce((select max(t1.f+ -t1.e) from t1 where t1.c between 13 and t1.b),19)) AS integer) when ~~min(t1.f) then count(distinct 13) else cast(avg(t1.b) AS integer) end+count(distinct t1.e) else -count(*) end | max(a)+max(t1.e)) from t1)+e<a}
+} {600}
+do_test randexpr-2.149 {
+ db eval {SELECT coalesce((select max(case when t1.f between 17 and 11+case when not coalesce((select max(11) from t1 where t1.f in (select max(t1.d) from t1 union select -count(*) from t1) or 17=(13) or f in (( -t1.b),13,a)),case when d>13 then 13 else 11 end) between 19 and 19 then 19 when t1.c=d then e else 17 end then t1.e else t1.d end) from t1 where e in (select -(+max(11)-max((t1.a))+ -count(distinct d) | cast(avg(t1.a) AS integer)*count(distinct b))-count(*)* -count(distinct t1.e) from t1 union select cast(avg(d) AS integer) from t1)),d)+b FROM t1 WHERE NOT ((select +~abs( -min(t1.a)-abs(count(*)))+ -abs(+ -+case (cast(avg(a) AS integer)) when min(e+t1.d) then +case cast(avg(coalesce((select max(t1.f+ -t1.e) from t1 where t1.c between 13 and t1.b),19)) AS integer) when ~~min(t1.f) then count(distinct 13) else cast(avg(t1.b) AS integer) end+count(distinct t1.e) else -count(*) end | max(a)+max(t1.e)) from t1)+e<a)}
+} {}
+do_test randexpr-2.150 {
+ db eval {SELECT coalesce((select max(case when t1.f between 17 and 11+case when not coalesce((select max(11) from t1 where t1.f in (select max(t1.d) from t1 union select -count(*) from t1) or 17=(13) or f in (( -t1.b),13,a)),case when d>13 then 13 else 11 end) between 19 and 19 then 19 when t1.c=d then e else 17 end then t1.e else t1.d end) from t1 where e in (select -(+max(11)-max((t1.a))+ -count(distinct d) & cast(avg(t1.a) AS integer)*count(distinct b))-count(*)* -count(distinct t1.e) from t1 union select cast(avg(d) AS integer) from t1)),d)+b FROM t1 WHERE (select +~abs( -min(t1.a)-abs(count(*)))+ -abs(+ -+case (cast(avg(a) AS integer)) when min(e+t1.d) then +case cast(avg(coalesce((select max(t1.f+ -t1.e) from t1 where t1.c between 13 and t1.b),19)) AS integer) when ~~min(t1.f) then count(distinct 13) else cast(avg(t1.b) AS integer) end+count(distinct t1.e) else -count(*) end | max(a)+max(t1.e)) from t1)+e<a}
+} {600}
+do_test randexpr-2.151 {
+ db eval {SELECT case when ((+b in (select min(coalesce((select c from t1 where t1.b-t1.c+coalesce((select max(case when 13 in (select -count(distinct b)*max(c) from t1 union select (( - -cast(avg(d) AS integer))) from t1) then b else t1.f end) from t1 where t1.f<t1.e),13) between (b) and -t1.b), -e)) from t1 union select +( -case -abs(( -count(*))) | count(distinct d) when max(17) then max(13) else -(min(13)) end) | (count(distinct t1.a)) from t1))) then t1.f else case c when t1.d then e else 11 end end FROM t1 WHERE t1.a+case t1.c when case c when 13 then t1.f*(select count(*) | cast(avg(a) AS integer) from t1)+13*t1.a else (select abs( -count(*)) from t1) end then b else t1.c end in (t1.a,d,17) or -(select ~ -max(c) from t1)+17<>d or t1.a not between b and 13 or f<> -19 and t1.b>a}
+} {11}
+do_test randexpr-2.152 {
+ db eval {SELECT case when ((+b in (select min(coalesce((select c from t1 where t1.b-t1.c+coalesce((select max(case when 13 in (select -count(distinct b)*max(c) from t1 union select (( - -cast(avg(d) AS integer))) from t1) then b else t1.f end) from t1 where t1.f<t1.e),13) between (b) and -t1.b), -e)) from t1 union select +( -case -abs(( -count(*))) | count(distinct d) when max(17) then max(13) else -(min(13)) end) | (count(distinct t1.a)) from t1))) then t1.f else case c when t1.d then e else 11 end end FROM t1 WHERE NOT (t1.a+case t1.c when case c when 13 then t1.f*(select count(*) | cast(avg(a) AS integer) from t1)+13*t1.a else (select abs( -count(*)) from t1) end then b else t1.c end in (t1.a,d,17) or -(select ~ -max(c) from t1)+17<>d or t1.a not between b and 13 or f<> -19 and t1.b>a)}
+} {}
+do_test randexpr-2.153 {
+ db eval {SELECT case when ((+b in (select min(coalesce((select c from t1 where t1.b-t1.c+coalesce((select max(case when 13 in (select -count(distinct b)*max(c) from t1 union select (( - -cast(avg(d) AS integer))) from t1) then b else t1.f end) from t1 where t1.f<t1.e),13) between (b) and -t1.b), -e)) from t1 union select +( -case -abs(( -count(*))) & count(distinct d) when max(17) then max(13) else -(min(13)) end) & (count(distinct t1.a)) from t1))) then t1.f else case c when t1.d then e else 11 end end FROM t1 WHERE t1.a+case t1.c when case c when 13 then t1.f*(select count(*) | cast(avg(a) AS integer) from t1)+13*t1.a else (select abs( -count(*)) from t1) end then b else t1.c end in (t1.a,d,17) or -(select ~ -max(c) from t1)+17<>d or t1.a not between b and 13 or f<> -19 and t1.b>a}
+} {11}
+do_test randexpr-2.154 {
+ db eval {SELECT case when t1.a | (abs(case when -t1.e in (17,11,(abs(t1.b)/abs(b+case when (17 in (select f-c from t1 union select -a from t1)) or t1.b<=a then d when t1.e in (select -(count(*)) from t1 union select max(t1.b) from t1) then c else c end*a-t1.f))) then t1.b else t1.e end)/abs(t1.f))>=11 and not exists(select 1 from t1 where exists(select 1 from t1 where t1.d in (select t1.d from t1 union select 17 from t1))) then c else t1.c end FROM t1 WHERE (coalesce((select f from t1 where case a-e+a when (abs(t1.d)/abs((coalesce((select ~t1.e*+t1.a+b*a*(abs(19)/abs(a))*a+e from t1 where 13<t1.e),a))))+11 then 11 else d end>=13 or t1.b<= -19),t1.f)+17* -t1.c<t1.c)}
+} {300}
+do_test randexpr-2.155 {
+ db eval {SELECT case when t1.a | (abs(case when -t1.e in (17,11,(abs(t1.b)/abs(b+case when (17 in (select f-c from t1 union select -a from t1)) or t1.b<=a then d when t1.e in (select -(count(*)) from t1 union select max(t1.b) from t1) then c else c end*a-t1.f))) then t1.b else t1.e end)/abs(t1.f))>=11 and not exists(select 1 from t1 where exists(select 1 from t1 where t1.d in (select t1.d from t1 union select 17 from t1))) then c else t1.c end FROM t1 WHERE NOT ((coalesce((select f from t1 where case a-e+a when (abs(t1.d)/abs((coalesce((select ~t1.e*+t1.a+b*a*(abs(19)/abs(a))*a+e from t1 where 13<t1.e),a))))+11 then 11 else d end>=13 or t1.b<= -19),t1.f)+17* -t1.c<t1.c))}
+} {}
+do_test randexpr-2.156 {
+ db eval {SELECT case when t1.a & (abs(case when -t1.e in (17,11,(abs(t1.b)/abs(b+case when (17 in (select f-c from t1 union select -a from t1)) or t1.b<=a then d when t1.e in (select -(count(*)) from t1 union select max(t1.b) from t1) then c else c end*a-t1.f))) then t1.b else t1.e end)/abs(t1.f))>=11 and not exists(select 1 from t1 where exists(select 1 from t1 where t1.d in (select t1.d from t1 union select 17 from t1))) then c else t1.c end FROM t1 WHERE (coalesce((select f from t1 where case a-e+a when (abs(t1.d)/abs((coalesce((select ~t1.e*+t1.a+b*a*(abs(19)/abs(a))*a+e from t1 where 13<t1.e),a))))+11 then 11 else d end>=13 or t1.b<= -19),t1.f)+17* -t1.c<t1.c)}
+} {300}
+do_test randexpr-2.157 {
+ db eval {SELECT coalesce((select max(~t1.b) from t1 where b in (select count(distinct b) from t1 union select max(case coalesce((select max(b) from t1 where d in (select t1.f from t1 union select d from t1) and t1.a=d),t1.a) when -t1.a then d*t1.e+t1.c-11+b | e-t1.a+e+t1.f else c end) from t1)),t1.a) FROM t1 WHERE (e<t1.f*case 17 when t1.a then t1.d else +coalesce((select max(17) from t1 where not 13<>~a-11),t1.f) end)}
+} {100}
+do_test randexpr-2.158 {
+ db eval {SELECT coalesce((select max(~t1.b) from t1 where b in (select count(distinct b) from t1 union select max(case coalesce((select max(b) from t1 where d in (select t1.f from t1 union select d from t1) and t1.a=d),t1.a) when -t1.a then d*t1.e+t1.c-11+b | e-t1.a+e+t1.f else c end) from t1)),t1.a) FROM t1 WHERE NOT ((e<t1.f*case 17 when t1.a then t1.d else +coalesce((select max(17) from t1 where not 13<>~a-11),t1.f) end))}
+} {}
+do_test randexpr-2.159 {
+ db eval {SELECT coalesce((select max(~t1.b) from t1 where b in (select count(distinct b) from t1 union select max(case coalesce((select max(b) from t1 where d in (select t1.f from t1 union select d from t1) and t1.a=d),t1.a) when -t1.a then d*t1.e+t1.c-11+b & e-t1.a+e+t1.f else c end) from t1)),t1.a) FROM t1 WHERE (e<t1.f*case 17 when t1.a then t1.d else +coalesce((select max(17) from t1 where not 13<>~a-11),t1.f) end)}
+} {100}
+do_test randexpr-2.160 {
+ db eval {SELECT case when not t1.c not in (13,d,~case when coalesce((select max((abs(t1.c)/abs(t1.e))) from t1 where b-t1.d+b+t1.f>a),t1.a) in (select 19 from t1 union select t1.a from t1) then -b else a end*b | d) and -(t1.b)>=e and 11<d or ((19))<> -t1.c then t1.f else t1.f end+(t1.b)+a FROM t1 WHERE e>e}
+} {}
+do_test randexpr-2.161 {
+ db eval {SELECT case when not t1.c not in (13,d,~case when coalesce((select max((abs(t1.c)/abs(t1.e))) from t1 where b-t1.d+b+t1.f>a),t1.a) in (select 19 from t1 union select t1.a from t1) then -b else a end*b | d) and -(t1.b)>=e and 11<d or ((19))<> -t1.c then t1.f else t1.f end+(t1.b)+a FROM t1 WHERE NOT (e>e)}
+} {900}
+do_test randexpr-2.162 {
+ db eval {SELECT case when not t1.c not in (13,d,~case when coalesce((select max((abs(t1.c)/abs(t1.e))) from t1 where b-t1.d+b+t1.f>a),t1.a) in (select 19 from t1 union select t1.a from t1) then -b else a end*b & d) and -(t1.b)>=e and 11<d or ((19))<> -t1.c then t1.f else t1.f end+(t1.b)+a FROM t1 WHERE NOT (e>e)}
+} {900}
+do_test randexpr-2.163 {
+ db eval {SELECT coalesce((select t1.c*c from t1 where (select (abs(cast(avg(b*13) AS integer))) from t1) in (select 11 from t1 union select e | a-17 from t1)), -case t1.c when t1.b++(select cast(avg(e) AS integer) from t1) then 17 else t1.b end)-d FROM t1 WHERE b<=t1.d}
+} {-600}
+do_test randexpr-2.164 {
+ db eval {SELECT coalesce((select t1.c*c from t1 where (select (abs(cast(avg(b*13) AS integer))) from t1) in (select 11 from t1 union select e | a-17 from t1)), -case t1.c when t1.b++(select cast(avg(e) AS integer) from t1) then 17 else t1.b end)-d FROM t1 WHERE NOT (b<=t1.d)}
+} {}
+do_test randexpr-2.165 {
+ db eval {SELECT coalesce((select t1.c*c from t1 where (select (abs(cast(avg(b*13) AS integer))) from t1) in (select 11 from t1 union select e & a-17 from t1)), -case t1.c when t1.b++(select cast(avg(e) AS integer) from t1) then 17 else t1.b end)-d FROM t1 WHERE b<=t1.d}
+} {-600}
+do_test randexpr-2.166 {
+ db eval {SELECT coalesce((select max((case (abs(t1.b)/abs(e)) when 13 then ((select +case count(*)*count(distinct coalesce((select max((11)+b) from t1 where exists(select 1 from t1 where t1.e=(t1.b))), -13)) when count(distinct -c) then count(*)*max( -d) else max((a)) end+min(c) from t1)) else t1.a end-(abs(case when a=17 and e<=b then a when a>=e then t1.c else t1.c end+13)/abs(e))*(e))) from t1 where t1.a in (select d from t1 union select -t1.e from t1)),13) FROM t1 WHERE not coalesce((select max(case when f<=d | b | case when case when (t1.c in (f,19,c)) then t1.f when d>t1.b then t1.f else t1.f end<=c then 11 else c end- -t1.c-13 and t1.c in (select b from t1 union select -17 from t1) then t1.b else a end) from t1 where 11 between d and a), -17) not between t1.f and t1.f and t1.f>11 or (not exists(select 1 from t1 where t1.b in (select min(t1.d) from t1 union select min(c) from t1)))}
+} {13}
+do_test randexpr-2.167 {
+ db eval {SELECT coalesce((select max((case (abs(t1.b)/abs(e)) when 13 then ((select +case count(*)*count(distinct coalesce((select max((11)+b) from t1 where exists(select 1 from t1 where t1.e=(t1.b))), -13)) when count(distinct -c) then count(*)*max( -d) else max((a)) end+min(c) from t1)) else t1.a end-(abs(case when a=17 and e<=b then a when a>=e then t1.c else t1.c end+13)/abs(e))*(e))) from t1 where t1.a in (select d from t1 union select -t1.e from t1)),13) FROM t1 WHERE NOT (not coalesce((select max(case when f<=d | b | case when case when (t1.c in (f,19,c)) then t1.f when d>t1.b then t1.f else t1.f end<=c then 11 else c end- -t1.c-13 and t1.c in (select b from t1 union select -17 from t1) then t1.b else a end) from t1 where 11 between d and a), -17) not between t1.f and t1.f and t1.f>11 or (not exists(select 1 from t1 where t1.b in (select min(t1.d) from t1 union select min(c) from t1))))}
+} {}
+do_test randexpr-2.168 {
+ db eval {SELECT case when ((t1.e | (select min( -t1.f) from t1)*((abs(b)/abs(19)))-b<=t1.b and not e>13 or -f in (select count(distinct e)-min(t1.a) from t1 union select count(distinct f) from t1))) then 13 when 17 between f and 19 or 11 between b and 19 or not t1.f>e then t1.d else d | f end FROM t1 WHERE not case when t1.a=t1.a then c when ~case when case when t1.e in (select + -count(distinct t1.d) from t1 union select cast(avg(t1.a) AS integer) from t1) then (t1.e) when 17 in (13, -f,a) then t1.d else d end<17 then e else f end+17+a* -e+b+b>t1.e then t1.e else t1.a end<c and a in (select max( -t1.f) | count(distinct t1.b)+~~count(distinct t1.b)-max(e)- -max(a) from t1 union select min(11) from t1)}
+} {}
+do_test randexpr-2.169 {
+ db eval {SELECT case when ((t1.e | (select min( -t1.f) from t1)*((abs(b)/abs(19)))-b<=t1.b and not e>13 or -f in (select count(distinct e)-min(t1.a) from t1 union select count(distinct f) from t1))) then 13 when 17 between f and 19 or 11 between b and 19 or not t1.f>e then t1.d else d | f end FROM t1 WHERE NOT (not case when t1.a=t1.a then c when ~case when case when t1.e in (select + -count(distinct t1.d) from t1 union select cast(avg(t1.a) AS integer) from t1) then (t1.e) when 17 in (13, -f,a) then t1.d else d end<17 then e else f end+17+a* -e+b+b>t1.e then t1.e else t1.a end<c and a in (select max( -t1.f) | count(distinct t1.b)+~~count(distinct t1.b)-max(e)- -max(a) from t1 union select min(11) from t1))}
+} {984}
+do_test randexpr-2.170 {
+ db eval {SELECT case when ((t1.e & (select min( -t1.f) from t1)*((abs(b)/abs(19)))-b<=t1.b and not e>13 or -f in (select count(distinct e)-min(t1.a) from t1 union select count(distinct f) from t1))) then 13 when 17 between f and 19 or 11 between b and 19 or not t1.f>e then t1.d else d & f end FROM t1 WHERE NOT (not case when t1.a=t1.a then c when ~case when case when t1.e in (select + -count(distinct t1.d) from t1 union select cast(avg(t1.a) AS integer) from t1) then (t1.e) when 17 in (13, -f,a) then t1.d else d end<17 then e else f end+17+a* -e+b+b>t1.e then t1.e else t1.a end<c and a in (select max( -t1.f) | count(distinct t1.b)+~~count(distinct t1.b)-max(e)- -max(a) from t1 union select min(11) from t1))}
+} {16}
+do_test randexpr-2.171 {
+ db eval {SELECT coalesce((select (select cast(avg(~13) AS integer)-count(distinct ~19-coalesce((select d-17 from t1 where case when (case 17 when b then d else (select min(11) | min(17) from t1)++t1.a end in (d, -c,t1.d)) then b else t1.c end between t1.a and (t1.e)),19)-t1.f) from t1) | (abs(t1.e)/abs(t1.e)) from t1 where (t1.c not in (( -t1.d),(t1.b),(d)))),t1.e) FROM t1 WHERE 13 between 19 and ~ -(abs( -t1.d | coalesce((select t1.f from t1 where 19 not between + -case when ~~b+coalesce((select max(t1.d) from t1 where exists(select 1 from t1 where (select cast(avg(19) AS integer)-cast(avg(b) AS integer) from t1)<>a and 19 between 11 and b and 11 between a and b)),t1.f) | c in ( -t1.c,13,b) then 11 when f in (select min(t1.d) from t1 union select cast(avg(f) AS integer) from t1) then t1.b else a end and t1.a),t1.c))/abs(11))+ -f}
+} {}
+do_test randexpr-2.172 {
+ db eval {SELECT coalesce((select (select cast(avg(~13) AS integer)-count(distinct ~19-coalesce((select d-17 from t1 where case when (case 17 when b then d else (select min(11) | min(17) from t1)++t1.a end in (d, -c,t1.d)) then b else t1.c end between t1.a and (t1.e)),19)-t1.f) from t1) | (abs(t1.e)/abs(t1.e)) from t1 where (t1.c not in (( -t1.d),(t1.b),(d)))),t1.e) FROM t1 WHERE NOT (13 between 19 and ~ -(abs( -t1.d | coalesce((select t1.f from t1 where 19 not between + -case when ~~b+coalesce((select max(t1.d) from t1 where exists(select 1 from t1 where (select cast(avg(19) AS integer)-cast(avg(b) AS integer) from t1)<>a and 19 between 11 and b and 11 between a and b)),t1.f) | c in ( -t1.c,13,b) then 11 when f in (select min(t1.d) from t1 union select cast(avg(f) AS integer) from t1) then t1.b else a end and t1.a),t1.c))/abs(11))+ -f)}
+} {-15}
+do_test randexpr-2.173 {
+ db eval {SELECT coalesce((select (select cast(avg(~13) AS integer)-count(distinct ~19-coalesce((select d-17 from t1 where case when (case 17 when b then d else (select min(11) & min(17) from t1)++t1.a end in (d, -c,t1.d)) then b else t1.c end between t1.a and (t1.e)),19)-t1.f) from t1) & (abs(t1.e)/abs(t1.e)) from t1 where (t1.c not in (( -t1.d),(t1.b),(d)))),t1.e) FROM t1 WHERE NOT (13 between 19 and ~ -(abs( -t1.d | coalesce((select t1.f from t1 where 19 not between + -case when ~~b+coalesce((select max(t1.d) from t1 where exists(select 1 from t1 where (select cast(avg(19) AS integer)-cast(avg(b) AS integer) from t1)<>a and 19 between 11 and b and 11 between a and b)),t1.f) | c in ( -t1.c,13,b) then 11 when f in (select min(t1.d) from t1 union select cast(avg(f) AS integer) from t1) then t1.b else a end and t1.a),t1.c))/abs(11))+ -f)}
+} {1}
+do_test randexpr-2.174 {
+ db eval {SELECT coalesce((select max(+(d+a)*b) from t1 where (case e-t1.b when 17+11*13 then t1.a else 17 end-(17)<>(select cast(avg(t1.f) AS integer) from t1))),case when case when 11+13<>19 then 13 else t1.f end*e in (a,t1.f,t1.c) and not exists(select 1 from t1 where t1.b in (select - -count(distinct t1.b)*( -count(*)) from t1 union select count(distinct t1.e) from t1)) then t1.c else a end) FROM t1 WHERE case when t1.d in (select count(*)-count(*)+ -min(case d when t1.c then 19 else 11 end)*count(*) | min(19)-(max((e))) from t1 union select count(*) from t1) then c when exists(select 1 from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (abs(b)/abs(t1.c))>coalesce((select max(f) from t1 where f<=t1.a),t1.d)))) then f*t1.c+11 else t1.f end+e-e*t1.f<=17}
+} {100000}
+do_test randexpr-2.175 {
+ db eval {SELECT coalesce((select max(+(d+a)*b) from t1 where (case e-t1.b when 17+11*13 then t1.a else 17 end-(17)<>(select cast(avg(t1.f) AS integer) from t1))),case when case when 11+13<>19 then 13 else t1.f end*e in (a,t1.f,t1.c) and not exists(select 1 from t1 where t1.b in (select - -count(distinct t1.b)*( -count(*)) from t1 union select count(distinct t1.e) from t1)) then t1.c else a end) FROM t1 WHERE NOT (case when t1.d in (select count(*)-count(*)+ -min(case d when t1.c then 19 else 11 end)*count(*) | min(19)-(max((e))) from t1 union select count(*) from t1) then c when exists(select 1 from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (abs(b)/abs(t1.c))>coalesce((select max(f) from t1 where f<=t1.a),t1.d)))) then f*t1.c+11 else t1.f end+e-e*t1.f<=17)}
+} {}
+do_test randexpr-2.176 {
+ db eval {SELECT t1.c*case when t1.e>(select +cast(avg(13) AS integer)*min((11)* - -d | - -coalesce((select max(b) from t1 where (select cast(avg((abs(a)/abs(b-(e)))) AS integer) from t1)+11*c<t1.d),e)-t1.f-t1.b+(t1.a)) from t1) then t1.c when +b in (17,a,b) then d else f end FROM t1 WHERE ((not exists(select 1 from t1 where not (exists(select 1 from t1 where (t1.c in (select t1.d from t1 union select -c from t1)) or (select cast(avg(~(e)) AS integer) | min(case when f=t1.e and t1.e in (t1.b,t1.f,t1.a) then t1.f when t1.d>=a then t1.b else t1.b end | 19+a-c)*count(distinct t1.d)-+count(distinct t1.d) from t1) not in (19,d,b) and t1.f not between b and t1.f)))))}
+} {}
+do_test randexpr-2.177 {
+ db eval {SELECT t1.c*case when t1.e>(select +cast(avg(13) AS integer)*min((11)* - -d | - -coalesce((select max(b) from t1 where (select cast(avg((abs(a)/abs(b-(e)))) AS integer) from t1)+11*c<t1.d),e)-t1.f-t1.b+(t1.a)) from t1) then t1.c when +b in (17,a,b) then d else f end FROM t1 WHERE NOT (((not exists(select 1 from t1 where not (exists(select 1 from t1 where (t1.c in (select t1.d from t1 union select -c from t1)) or (select cast(avg(~(e)) AS integer) | min(case when f=t1.e and t1.e in (t1.b,t1.f,t1.a) then t1.f when t1.d>=a then t1.b else t1.b end | 19+a-c)*count(distinct t1.d)-+count(distinct t1.d) from t1) not in (19,d,b) and t1.f not between b and t1.f))))))}
+} {90000}
+do_test randexpr-2.178 {
+ db eval {SELECT t1.c*case when t1.e>(select +cast(avg(13) AS integer)*min((11)* - -d & - -coalesce((select max(b) from t1 where (select cast(avg((abs(a)/abs(b-(e)))) AS integer) from t1)+11*c<t1.d),e)-t1.f-t1.b+(t1.a)) from t1) then t1.c when +b in (17,a,b) then d else f end FROM t1 WHERE NOT (((not exists(select 1 from t1 where not (exists(select 1 from t1 where (t1.c in (select t1.d from t1 union select -c from t1)) or (select cast(avg(~(e)) AS integer) | min(case when f=t1.e and t1.e in (t1.b,t1.f,t1.a) then t1.f when t1.d>=a then t1.b else t1.b end | 19+a-c)*count(distinct t1.d)-+count(distinct t1.d) from t1) not in (19,d,b) and t1.f not between b and t1.f))))))}
+} {120000}
+do_test randexpr-2.179 {
+ db eval {SELECT case when not exists(select 1 from t1 where (not exists(select 1 from t1 where not exists(select 1 from t1 where not d*19=b))) or t1.a-a-t1.d*t1.f in (select ~case cast(avg(t1.d) AS integer) | count(*)+max(t1.c) when max(17) then cast(avg( -f) AS integer) else -min(e) end from t1 union select max( -13) from t1)) then (select abs((+ -min(a)) | min(t1.a)-cast(avg(t1.f) AS integer)) | max(e) from t1) else 11 end*a | t1.a*f FROM t1 WHERE t1.c in (c,t1.b,~e) and 13+19-t1.b | coalesce((select max(case d when +t1.e+13*13 then coalesce((select case when f<t1.f then ~d else 19 end from t1 where not d>=e or -f<=e and t1.d<>19),d) else d end) from t1 where t1.d<b),t1.a)*d*(a)<=t1.d}
+} {61036}
+do_test randexpr-2.180 {
+ db eval {SELECT case when not exists(select 1 from t1 where (not exists(select 1 from t1 where not exists(select 1 from t1 where not d*19=b))) or t1.a-a-t1.d*t1.f in (select ~case cast(avg(t1.d) AS integer) | count(*)+max(t1.c) when max(17) then cast(avg( -f) AS integer) else -min(e) end from t1 union select max( -13) from t1)) then (select abs((+ -min(a)) | min(t1.a)-cast(avg(t1.f) AS integer)) | max(e) from t1) else 11 end*a | t1.a*f FROM t1 WHERE NOT (t1.c in (c,t1.b,~e) and 13+19-t1.b | coalesce((select max(case d when +t1.e+13*13 then coalesce((select case when f<t1.f then ~d else 19 end from t1 where not d>=e or -f<=e and t1.d<>19),d) else d end) from t1 where t1.d<b),t1.a)*d*(a)<=t1.d)}
+} {}
+do_test randexpr-2.181 {
+ db eval {SELECT case when not exists(select 1 from t1 where (not exists(select 1 from t1 where not exists(select 1 from t1 where not d*19=b))) or t1.a-a-t1.d*t1.f in (select ~case cast(avg(t1.d) AS integer) & count(*)+max(t1.c) when max(17) then cast(avg( -f) AS integer) else -min(e) end from t1 union select max( -13) from t1)) then (select abs((+ -min(a)) & min(t1.a)-cast(avg(t1.f) AS integer)) & max(e) from t1) else 11 end*a & t1.a*f FROM t1 WHERE t1.c in (c,t1.b,~e) and 13+19-t1.b | coalesce((select max(case d when +t1.e+13*13 then coalesce((select case when f<t1.f then ~d else 19 end from t1 where not d>=e or -f<=e and t1.d<>19),d) else d end) from t1 where t1.d<b),t1.a)*d*(a)<=t1.d}
+} {64}
+do_test randexpr-2.182 {
+ db eval {SELECT (abs(t1.f-(abs(case c when t1.a+(select max(17-coalesce((select +e-t1.a+11-13+d+11-t1.a from t1 where t1.e in (select ~coalesce((select a from t1 where t1.c-a=b),t1.c)+17 from t1 union select t1.e from t1)),c)-d) from t1) then 17 else -t1.e end)/abs(d))-17)/abs(t1.b)) FROM t1 WHERE b in (select +count(distinct (19)-11) from t1 union select case count(*) when -case min((abs(t1.c*(t1.c)+11)/abs(19))*~d*f) when abs(count(*)+count(*)) then (+(min(e)* -cast(avg(17) AS integer)* -cast(avg(d) AS integer)+max(t1.f))) else (count(*)) end | (min( -((t1.b)))) then (max(t1.c)) else -count(distinct t1.d) end from t1) and not exists(select 1 from t1 where d<f)}
+} {}
+do_test randexpr-2.183 {
+ db eval {SELECT (abs(t1.f-(abs(case c when t1.a+(select max(17-coalesce((select +e-t1.a+11-13+d+11-t1.a from t1 where t1.e in (select ~coalesce((select a from t1 where t1.c-a=b),t1.c)+17 from t1 union select t1.e from t1)),c)-d) from t1) then 17 else -t1.e end)/abs(d))-17)/abs(t1.b)) FROM t1 WHERE NOT (b in (select +count(distinct (19)-11) from t1 union select case count(*) when -case min((abs(t1.c*(t1.c)+11)/abs(19))*~d*f) when abs(count(*)+count(*)) then (+(min(e)* -cast(avg(17) AS integer)* -cast(avg(d) AS integer)+max(t1.f))) else (count(*)) end | (min( -((t1.b)))) then (max(t1.c)) else -count(distinct t1.d) end from t1) and not exists(select 1 from t1 where d<f))}
+} {2}
+do_test randexpr-2.184 {
+ db eval {SELECT ~case +~c+(case when not exists(select 1 from t1 where t1.d in (select abs( -abs(max(t1.f)-count(distinct e)* -cast(avg(11) AS integer) | count(*))+min(f)*min( -17)*cast(avg(19) AS integer)) from t1 union select count(*) from t1)) or (t1.f)<>t1.b then d*t1.f*17 else (b) end)+t1.f*13 when c then t1.a else t1.e end- -t1.f FROM t1 WHERE b-case when t1.b=t1.b and (coalesce((select max(t1.e) from t1 where t1.b in (select ~cast(avg(19) AS integer)+max(t1.b)+min(t1.e) from t1 union select max(t1.a) from t1) or exists(select 1 from t1 where 11 in (select max(t1.e) from t1 union select max(t1.f) from t1))),(abs(17)/abs(17)))) not between c and t1.a then 13 else 13 end | t1.c in (select ++cast(avg(f) AS integer)-(+(count(distinct 13) | max(19))-count(*) | -max(t1.e)) from t1 union select count(*) from t1)}
+} {}
+do_test randexpr-2.185 {
+ db eval {SELECT ~case +~c+(case when not exists(select 1 from t1 where t1.d in (select abs( -abs(max(t1.f)-count(distinct e)* -cast(avg(11) AS integer) | count(*))+min(f)*min( -17)*cast(avg(19) AS integer)) from t1 union select count(*) from t1)) or (t1.f)<>t1.b then d*t1.f*17 else (b) end)+t1.f*13 when c then t1.a else t1.e end- -t1.f FROM t1 WHERE NOT (b-case when t1.b=t1.b and (coalesce((select max(t1.e) from t1 where t1.b in (select ~cast(avg(19) AS integer)+max(t1.b)+min(t1.e) from t1 union select max(t1.a) from t1) or exists(select 1 from t1 where 11 in (select max(t1.e) from t1 union select max(t1.f) from t1))),(abs(17)/abs(17)))) not between c and t1.a then 13 else 13 end | t1.c in (select ++cast(avg(f) AS integer)-(+(count(distinct 13) | max(19))-count(*) | -max(t1.e)) from t1 union select count(*) from t1))}
+} {99}
+do_test randexpr-2.186 {
+ db eval {SELECT ~case +~c+(case when not exists(select 1 from t1 where t1.d in (select abs( -abs(max(t1.f)-count(distinct e)* -cast(avg(11) AS integer) & count(*))+min(f)*min( -17)*cast(avg(19) AS integer)) from t1 union select count(*) from t1)) or (t1.f)<>t1.b then d*t1.f*17 else (b) end)+t1.f*13 when c then t1.a else t1.e end- -t1.f FROM t1 WHERE NOT (b-case when t1.b=t1.b and (coalesce((select max(t1.e) from t1 where t1.b in (select ~cast(avg(19) AS integer)+max(t1.b)+min(t1.e) from t1 union select max(t1.a) from t1) or exists(select 1 from t1 where 11 in (select max(t1.e) from t1 union select max(t1.f) from t1))),(abs(17)/abs(17)))) not between c and t1.a then 13 else 13 end | t1.c in (select ++cast(avg(f) AS integer)-(+(count(distinct 13) | max(19))-count(*) | -max(t1.e)) from t1 union select count(*) from t1))}
+} {99}
+do_test randexpr-2.187 {
+ db eval {SELECT case when t1.c in (select c from t1 union select a from t1) then 11 when ((select max(19) from t1) | t1.a+e not between (case -19 when b*e-b-case when b<>~d*t1.d+t1.c*d then t1.d when t1.c=19 then f else d end-f*t1.d then t1.d else 13 end) and 13) then 11 else t1.b end FROM t1 WHERE t1.b*coalesce((select max(t1.d) from t1 where -f<=(select max(t1.e) from t1)*e),case when case when t1.e- -13>t1.b+t1.f+c then 13 else -d end in (select 19 from t1 union select t1.f from t1) then e when t1.b in (select ~count(distinct t1.a)+count(*) from t1 union select abs( - -((cast(avg(c) AS integer)))*(cast(avg(t1.b) AS integer))) from t1) then 17 else d end)+ -17 | t1.a-t1.d in (t1.e,f,f)}
+} {}
+do_test randexpr-2.188 {
+ db eval {SELECT case when t1.c in (select c from t1 union select a from t1) then 11 when ((select max(19) from t1) | t1.a+e not between (case -19 when b*e-b-case when b<>~d*t1.d+t1.c*d then t1.d when t1.c=19 then f else d end-f*t1.d then t1.d else 13 end) and 13) then 11 else t1.b end FROM t1 WHERE NOT (t1.b*coalesce((select max(t1.d) from t1 where -f<=(select max(t1.e) from t1)*e),case when case when t1.e- -13>t1.b+t1.f+c then 13 else -d end in (select 19 from t1 union select t1.f from t1) then e when t1.b in (select ~count(distinct t1.a)+count(*) from t1 union select abs( - -((cast(avg(c) AS integer)))*(cast(avg(t1.b) AS integer))) from t1) then 17 else d end)+ -17 | t1.a-t1.d in (t1.e,f,f))}
+} {11}
+do_test randexpr-2.189 {
+ db eval {SELECT case when t1.c in (select c from t1 union select a from t1) then 11 when ((select max(19) from t1) & t1.a+e not between (case -19 when b*e-b-case when b<>~d*t1.d+t1.c*d then t1.d when t1.c=19 then f else d end-f*t1.d then t1.d else 13 end) and 13) then 11 else t1.b end FROM t1 WHERE NOT (t1.b*coalesce((select max(t1.d) from t1 where -f<=(select max(t1.e) from t1)*e),case when case when t1.e- -13>t1.b+t1.f+c then 13 else -d end in (select 19 from t1 union select t1.f from t1) then e when t1.b in (select ~count(distinct t1.a)+count(*) from t1 union select abs( - -((cast(avg(c) AS integer)))*(cast(avg(t1.b) AS integer))) from t1) then 17 else d end)+ -17 | t1.a-t1.d in (t1.e,f,f))}
+} {11}
+do_test randexpr-2.190 {
+ db eval {SELECT ~(d)-(select case case cast(avg(t1.b- -~b) AS integer) when max(coalesce((select e from t1 where 11<>e),coalesce((select c from t1 where c not in (t1.e,a,(17)) or t1.b in ((b),t1.c,t1.f)),13))) then +cast(avg(d) AS integer) | case max(t1.c) when min((e)) then max(e)+cast(avg(t1.d) AS integer) else min(t1.f) end+max(d) else count(*) end | -cast(avg(t1.f) AS integer) | - -count(distinct c)*max(b) when count(distinct t1.d) then - -min(a) else count(*) end from t1) FROM t1 WHERE t1.c+a=t1.e+t1.c*t1.e | case t1.d when case when 13 in (select min(c) from t1 union select max(d) from t1) or t1.f>=13 then 19 when t1.c<=11 then -t1.b else 13 end then 13 else t1.e end or f in (select t1.a from t1 union select t1.f from t1) or (t1.a<t1.b) and e>t1.b and (((t1.d not between -a and t1.f))) or t1.a not in ( -t1.d,13,a) and d<c or d=t1.d or e<d}
+} {-402}
+do_test randexpr-2.191 {
+ db eval {SELECT ~(d)-(select case case cast(avg(t1.b- -~b) AS integer) when max(coalesce((select e from t1 where 11<>e),coalesce((select c from t1 where c not in (t1.e,a,(17)) or t1.b in ((b),t1.c,t1.f)),13))) then +cast(avg(d) AS integer) | case max(t1.c) when min((e)) then max(e)+cast(avg(t1.d) AS integer) else min(t1.f) end+max(d) else count(*) end | -cast(avg(t1.f) AS integer) | - -count(distinct c)*max(b) when count(distinct t1.d) then - -min(a) else count(*) end from t1) FROM t1 WHERE NOT (t1.c+a=t1.e+t1.c*t1.e | case t1.d when case when 13 in (select min(c) from t1 union select max(d) from t1) or t1.f>=13 then 19 when t1.c<=11 then -t1.b else 13 end then 13 else t1.e end or f in (select t1.a from t1 union select t1.f from t1) or (t1.a<t1.b) and e>t1.b and (((t1.d not between -a and t1.f))) or t1.a not in ( -t1.d,13,a) and d<c or d=t1.d or e<d)}
+} {}
+do_test randexpr-2.192 {
+ db eval {SELECT ~(d)-(select case case cast(avg(t1.b- -~b) AS integer) when max(coalesce((select e from t1 where 11<>e),coalesce((select c from t1 where c not in (t1.e,a,(17)) or t1.b in ((b),t1.c,t1.f)),13))) then +cast(avg(d) AS integer) & case max(t1.c) when min((e)) then max(e)+cast(avg(t1.d) AS integer) else min(t1.f) end+max(d) else count(*) end & -cast(avg(t1.f) AS integer) & - -count(distinct c)*max(b) when count(distinct t1.d) then - -min(a) else count(*) end from t1) FROM t1 WHERE t1.c+a=t1.e+t1.c*t1.e | case t1.d when case when 13 in (select min(c) from t1 union select max(d) from t1) or t1.f>=13 then 19 when t1.c<=11 then -t1.b else 13 end then 13 else t1.e end or f in (select t1.a from t1 union select t1.f from t1) or (t1.a<t1.b) and e>t1.b and (((t1.d not between -a and t1.f))) or t1.a not in ( -t1.d,13,a) and d<c or d=t1.d or e<d}
+} {-402}
+do_test randexpr-2.193 {
+ db eval {SELECT (abs(coalesce((select max(a) from t1 where exists(select 1 from t1 where t1.f<19 and coalesce((select max(case when t1.a+e in (select t1.c from t1 union select f from t1) then f else (17) end) from t1 where t1.e in (f,coalesce((select max(t1.f) from t1 where 17<=((abs(t1.d | (t1.a))/abs(13))*(a))-d),17),e)),t1.c) not between t1.b and 11 and 13<t1.f)),f+t1.d))/abs(19)) FROM t1 WHERE 11*c+17-f in (select min(t1.e*11*case when exists(select 1 from t1 where not exists(select 1 from t1 where + -17<a)) then (abs((d))/abs(13)) when 11 in (select case count(*) when count(distinct t1.f) then count(distinct 17) else cast(avg((11)) AS integer) end from t1 union select cast(avg(t1.c) AS integer) from t1) then b else e end) from t1 union select case count(*) when -count(distinct t1.d) then max(a) else (count(distinct t1.c))-max((b)) | (count(distinct t1.e))*count(distinct (13))-count(distinct e) end-count(*)-count(*) from t1)}
+} {}
+do_test randexpr-2.194 {
+ db eval {SELECT (abs(coalesce((select max(a) from t1 where exists(select 1 from t1 where t1.f<19 and coalesce((select max(case when t1.a+e in (select t1.c from t1 union select f from t1) then f else (17) end) from t1 where t1.e in (f,coalesce((select max(t1.f) from t1 where 17<=((abs(t1.d | (t1.a))/abs(13))*(a))-d),17),e)),t1.c) not between t1.b and 11 and 13<t1.f)),f+t1.d))/abs(19)) FROM t1 WHERE NOT (11*c+17-f in (select min(t1.e*11*case when exists(select 1 from t1 where not exists(select 1 from t1 where + -17<a)) then (abs((d))/abs(13)) when 11 in (select case count(*) when count(distinct t1.f) then count(distinct 17) else cast(avg((11)) AS integer) end from t1 union select cast(avg(t1.c) AS integer) from t1) then b else e end) from t1 union select case count(*) when -count(distinct t1.d) then max(a) else (count(distinct t1.c))-max((b)) | (count(distinct t1.e))*count(distinct (13))-count(distinct e) end-count(*)-count(*) from t1))}
+} {52}
+do_test randexpr-2.195 {
+ db eval {SELECT (abs(coalesce((select max(a) from t1 where exists(select 1 from t1 where t1.f<19 and coalesce((select max(case when t1.a+e in (select t1.c from t1 union select f from t1) then f else (17) end) from t1 where t1.e in (f,coalesce((select max(t1.f) from t1 where 17<=((abs(t1.d & (t1.a))/abs(13))*(a))-d),17),e)),t1.c) not between t1.b and 11 and 13<t1.f)),f+t1.d))/abs(19)) FROM t1 WHERE NOT (11*c+17-f in (select min(t1.e*11*case when exists(select 1 from t1 where not exists(select 1 from t1 where + -17<a)) then (abs((d))/abs(13)) when 11 in (select case count(*) when count(distinct t1.f) then count(distinct 17) else cast(avg((11)) AS integer) end from t1 union select cast(avg(t1.c) AS integer) from t1) then b else e end) from t1 union select case count(*) when -count(distinct t1.d) then max(a) else (count(distinct t1.c))-max((b)) | (count(distinct t1.e))*count(distinct (13))-count(distinct e) end-count(*)-count(*) from t1))}
+} {52}
+do_test randexpr-2.196 {
+ db eval {SELECT coalesce((select max(~t1.d) from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where c>t1.c or ((t1.f>e)) and t1.e-19+c+ -d*t1.d+11<>17+coalesce((select max(t1.d) from t1 where 17+t1.c<t1.d),t1.b) or f<>11))),11) | case e when c then a else t1.b end+a FROM t1 WHERE case when d not in (a,11,(13)) then a when exists(select 1 from t1 where case when case when case when (t1.c) in (c,e,b) then f else (19) end-t1.f<t1.d then 11 else a end>=t1.a then 11 else t1.c end in (select abs(~~max(t1.c)) from t1 union select cast(avg(c) AS integer) from t1)) then 11 else t1.f end in (select (~~count(*)*cast(avg(19) AS integer)) from t1 union select min(t1.d)+ -count(distinct f) from t1)}
+} {}
+do_test randexpr-2.197 {
+ db eval {SELECT coalesce((select max(~t1.d) from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where c>t1.c or ((t1.f>e)) and t1.e-19+c+ -d*t1.d+11<>17+coalesce((select max(t1.d) from t1 where 17+t1.c<t1.d),t1.b) or f<>11))),11) | case e when c then a else t1.b end+a FROM t1 WHERE NOT (case when d not in (a,11,(13)) then a when exists(select 1 from t1 where case when case when case when (t1.c) in (c,e,b) then f else (19) end-t1.f<t1.d then 11 else a end>=t1.a then 11 else t1.c end in (select abs(~~max(t1.c)) from t1 union select cast(avg(c) AS integer) from t1)) then 11 else t1.f end in (select (~~count(*)*cast(avg(19) AS integer)) from t1 union select min(t1.d)+ -count(distinct f) from t1))}
+} {303}
+do_test randexpr-2.198 {
+ db eval {SELECT coalesce((select max(~t1.d) from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where c>t1.c or ((t1.f>e)) and t1.e-19+c+ -d*t1.d+11<>17+coalesce((select max(t1.d) from t1 where 17+t1.c<t1.d),t1.b) or f<>11))),11) & case e when c then a else t1.b end+a FROM t1 WHERE NOT (case when d not in (a,11,(13)) then a when exists(select 1 from t1 where case when case when case when (t1.c) in (c,e,b) then f else (19) end-t1.f<t1.d then 11 else a end>=t1.a then 11 else t1.c end in (select abs(~~max(t1.c)) from t1 union select cast(avg(c) AS integer) from t1)) then 11 else t1.f end in (select (~~count(*)*cast(avg(19) AS integer)) from t1 union select min(t1.d)+ -count(distinct f) from t1))}
+} {8}
+do_test randexpr-2.199 {
+ db eval {SELECT case when t1.e*t1.b<>e then 19 else -11-b+coalesce((select max(t1.e+t1.f) from t1 where 11+f*t1.c<>t1.a*(~f+case when t1.f in (t1.f, -((13)),19) then t1.a when t1.e>17 then a else a end+b-t1.e-(f))),13)+d end+t1.b* -c FROM t1 WHERE exists(select 1 from t1 where coalesce((select max(t1.a*t1.e+13) from t1 where 13 in ((abs(e)/abs(t1.a)),a+t1.c,17*t1.c)),(select -case max(c) | cast(avg(e) AS integer) when ~+ -count(distinct coalesce((select d from t1 where exists(select 1 from t1 where -17<e)),( -t1.e))) | case max(11) when cast(avg(a) AS integer) then max( -t1.f) else count(distinct -11) end then cast(avg(t1.d) AS integer) else max((d)) end*count(distinct t1.b) from t1) | t1.b-t1.d*t1.c+11)<=b)}
+} {-59981}
+do_test randexpr-2.200 {
+ db eval {SELECT case when t1.e*t1.b<>e then 19 else -11-b+coalesce((select max(t1.e+t1.f) from t1 where 11+f*t1.c<>t1.a*(~f+case when t1.f in (t1.f, -((13)),19) then t1.a when t1.e>17 then a else a end+b-t1.e-(f))),13)+d end+t1.b* -c FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select max(t1.a*t1.e+13) from t1 where 13 in ((abs(e)/abs(t1.a)),a+t1.c,17*t1.c)),(select -case max(c) | cast(avg(e) AS integer) when ~+ -count(distinct coalesce((select d from t1 where exists(select 1 from t1 where -17<e)),( -t1.e))) | case max(11) when cast(avg(a) AS integer) then max( -t1.f) else count(distinct -11) end then cast(avg(t1.d) AS integer) else max((d)) end*count(distinct t1.b) from t1) | t1.b-t1.d*t1.c+11)<=b))}
+} {}
+do_test randexpr-2.201 {
+ db eval {SELECT coalesce((select max(coalesce((select 19 from t1 where (case when ((abs(coalesce((select max(case when t1.a between (t1.c)+ -b and d then e else d end) from t1 where t1.e in (select (count(*)) from t1 union select max( -a)-count(distinct t1.c)-((min(13))) | max((t1.f)) from t1)),11))/abs(19)))+d>c then t1.b when 17 not between t1.e and c then 11 else f end in (select a from t1 union select 13 from t1))),11)) from t1 where not exists(select 1 from t1 where f=17)),e) FROM t1 WHERE ( -13 in (13,b,case when 19=11 then t1.d else case when (d | b-case when t1.f-(select +abs(cast(avg( -17* -17) AS integer)*count(*)+max(t1.e)) from t1)*t1.f not in (f,a,c) then t1.a else t1.b end between 19 and e) then a else 13 end end-t1.a) or t1.c<19)}
+} {}
+do_test randexpr-2.202 {
+ db eval {SELECT coalesce((select max(coalesce((select 19 from t1 where (case when ((abs(coalesce((select max(case when t1.a between (t1.c)+ -b and d then e else d end) from t1 where t1.e in (select (count(*)) from t1 union select max( -a)-count(distinct t1.c)-((min(13))) | max((t1.f)) from t1)),11))/abs(19)))+d>c then t1.b when 17 not between t1.e and c then 11 else f end in (select a from t1 union select 13 from t1))),11)) from t1 where not exists(select 1 from t1 where f=17)),e) FROM t1 WHERE NOT (( -13 in (13,b,case when 19=11 then t1.d else case when (d | b-case when t1.f-(select +abs(cast(avg( -17* -17) AS integer)*count(*)+max(t1.e)) from t1)*t1.f not in (f,a,c) then t1.a else t1.b end between 19 and e) then a else 13 end end-t1.a) or t1.c<19))}
+} {11}
+do_test randexpr-2.203 {
+ db eval {SELECT coalesce((select max(coalesce((select 19 from t1 where (case when ((abs(coalesce((select max(case when t1.a between (t1.c)+ -b and d then e else d end) from t1 where t1.e in (select (count(*)) from t1 union select max( -a)-count(distinct t1.c)-((min(13))) & max((t1.f)) from t1)),11))/abs(19)))+d>c then t1.b when 17 not between t1.e and c then 11 else f end in (select a from t1 union select 13 from t1))),11)) from t1 where not exists(select 1 from t1 where f=17)),e) FROM t1 WHERE NOT (( -13 in (13,b,case when 19=11 then t1.d else case when (d | b-case when t1.f-(select +abs(cast(avg( -17* -17) AS integer)*count(*)+max(t1.e)) from t1)*t1.f not in (f,a,c) then t1.a else t1.b end between 19 and e) then a else 13 end end-t1.a) or t1.c<19))}
+} {11}
+do_test randexpr-2.204 {
+ db eval {SELECT -~d*19-a-c | t1.c+(abs(case -19 | ~case t1.d when c then t1.f else c end when +t1.d then 17 else case case when b>case case when t1.c=d or -t1.a=17 then ((a)) when t1.a<>d then (t1.c) else a end+19+11 when 19 then t1.a else b end-(t1.e) then f else t1.c end when 17 then t1.b else a end end)/abs(d))+t1.b FROM t1 WHERE t1.f+13<>19}
+} {7671}
+do_test randexpr-2.205 {
+ db eval {SELECT -~d*19-a-c | t1.c+(abs(case -19 | ~case t1.d when c then t1.f else c end when +t1.d then 17 else case case when b>case case when t1.c=d or -t1.a=17 then ((a)) when t1.a<>d then (t1.c) else a end+19+11 when 19 then t1.a else b end-(t1.e) then f else t1.c end when 17 then t1.b else a end end)/abs(d))+t1.b FROM t1 WHERE NOT (t1.f+13<>19)}
+} {}
+do_test randexpr-2.206 {
+ db eval {SELECT -~d*19-a-c & t1.c+(abs(case -19 & ~case t1.d when c then t1.f else c end when +t1.d then 17 else case case when b>case case when t1.c=d or -t1.a=17 then ((a)) when t1.a<>d then (t1.c) else a end+19+11 when 19 then t1.a else b end-(t1.e) then f else t1.c end when 17 then t1.b else a end end)/abs(d))+t1.b FROM t1 WHERE t1.f+13<>19}
+} {48}
+do_test randexpr-2.207 {
+ db eval {SELECT (abs(coalesce((select b from t1 where t1.a>(abs(t1.f)/abs(coalesce((select 13 from t1 where not coalesce((select (select cast(avg(case when case when t1.e not between t1.c and 19 then t1.d when d in (11,t1.b,13) then e else 17 end*b between 13 and (t1.b) then t1.f when a<>19 and t1.c not in (a,t1.f,b) then t1.e else t1.f end) AS integer) from t1)+t1.c-b* -a*f from t1 where (t1.d in (select c from t1 union select t1.b from t1))),t1.e)-c<>c),t1.c)))),e))/abs(t1.e)) FROM t1 WHERE (t1.a-t1.c-case when e<c*17 then t1.e when case case t1.b when t1.c then coalesce((select max(t1.c) from t1 where t1.c in (select ~cast(avg(case when 17 in (t1.f,t1.f,t1.a) then c when 13<>b then f else d end | t1.d) AS integer) from t1 union select count(distinct 11) from t1)),c) else t1.f end when f then 19 else t1.b end<t1.f then t1.b else t1.e end-11 not between 11 and t1.d)}
+} {0}
+do_test randexpr-2.208 {
+ db eval {SELECT (abs(coalesce((select b from t1 where t1.a>(abs(t1.f)/abs(coalesce((select 13 from t1 where not coalesce((select (select cast(avg(case when case when t1.e not between t1.c and 19 then t1.d when d in (11,t1.b,13) then e else 17 end*b between 13 and (t1.b) then t1.f when a<>19 and t1.c not in (a,t1.f,b) then t1.e else t1.f end) AS integer) from t1)+t1.c-b* -a*f from t1 where (t1.d in (select c from t1 union select t1.b from t1))),t1.e)-c<>c),t1.c)))),e))/abs(t1.e)) FROM t1 WHERE NOT ((t1.a-t1.c-case when e<c*17 then t1.e when case case t1.b when t1.c then coalesce((select max(t1.c) from t1 where t1.c in (select ~cast(avg(case when 17 in (t1.f,t1.f,t1.a) then c when 13<>b then f else d end | t1.d) AS integer) from t1 union select count(distinct 11) from t1)),c) else t1.f end when f then 19 else t1.b end<t1.f then t1.b else t1.e end-11 not between 11 and t1.d))}
+} {}
+do_test randexpr-2.209 {
+ db eval {SELECT case when t1.d<>d then case 11 when ~+case t1.a when (abs(t1.a)/abs( -c))*t1.c+ -a+coalesce((select t1.c from t1 where ((abs(e)/abs((case when (11>=e) then -17 when (11)<=a then e else b end)+t1.f))>19)),b)-d then c else 17 end+ -b then ( -t1.a) else c end when 11<=t1.f then 11 else 17 end FROM t1 WHERE (coalesce((select max(17) from t1 where ~case ((select min( -e-a)*+cast(avg(11) AS integer)*count(*)-(count(*))*max(b)*min( -13)+count(*)-min( -13) from t1)+19)+a when e then (select min(f) from t1) else coalesce((select t1.f from t1 where 17>t1.c),19) end=11 and f=t1.b),19) not between -a and t1.a)}
+} {}
+do_test randexpr-2.210 {
+ db eval {SELECT case when t1.d<>d then case 11 when ~+case t1.a when (abs(t1.a)/abs( -c))*t1.c+ -a+coalesce((select t1.c from t1 where ((abs(e)/abs((case when (11>=e) then -17 when (11)<=a then e else b end)+t1.f))>19)),b)-d then c else 17 end+ -b then ( -t1.a) else c end when 11<=t1.f then 11 else 17 end FROM t1 WHERE NOT ((coalesce((select max(17) from t1 where ~case ((select min( -e-a)*+cast(avg(11) AS integer)*count(*)-(count(*))*max(b)*min( -13)+count(*)-min( -13) from t1)+19)+a when e then (select min(f) from t1) else coalesce((select t1.f from t1 where 17>t1.c),19) end=11 and f=t1.b),19) not between -a and t1.a))}
+} {11}
+do_test randexpr-2.211 {
+ db eval {SELECT coalesce((select max(t1.e) from t1 where not d in (select (abs(t1.f)/abs(~case when (abs(t1.e)/abs( -t1.a))+t1.b-t1.e*t1.a-t1.c between b and t1.e then f else a end+19)) from t1 union select 13 from t1) or (t1.e=(a)) and -11 in (select t1.f from t1 union select c from t1)),a)*coalesce((select max(f) from t1 where d=f),f)*c+(t1.c) FROM t1 WHERE case when +(abs(19)/abs(13*t1.e))<>11 then 19 when coalesce((select max(c) from t1 where t1.e+t1.a between t1.f and f),t1.a)=(a) then d else -19 end<=f or (((e in (b,t1.b,13)))) or b<(f) and t1.a<>11 or exists(select 1 from t1 where t1.d=d) or (t1.a)<>a or t1.a<>e}
+} {90000300}
+do_test randexpr-2.212 {
+ db eval {SELECT coalesce((select max(t1.e) from t1 where not d in (select (abs(t1.f)/abs(~case when (abs(t1.e)/abs( -t1.a))+t1.b-t1.e*t1.a-t1.c between b and t1.e then f else a end+19)) from t1 union select 13 from t1) or (t1.e=(a)) and -11 in (select t1.f from t1 union select c from t1)),a)*coalesce((select max(f) from t1 where d=f),f)*c+(t1.c) FROM t1 WHERE NOT (case when +(abs(19)/abs(13*t1.e))<>11 then 19 when coalesce((select max(c) from t1 where t1.e+t1.a between t1.f and f),t1.a)=(a) then d else -19 end<=f or (((e in (b,t1.b,13)))) or b<(f) and t1.a<>11 or exists(select 1 from t1 where t1.d=d) or (t1.a)<>a or t1.a<>e)}
+} {}
+do_test randexpr-2.213 {
+ db eval {SELECT case (select abs(count(distinct -17+(abs(c)/abs(case when exists(select 1 from t1 where (17<>(f))) then e when t1.c not between 11 and t1.d then +11 else t1.e end | b))+d)*+ -(min(f)*max(t1.e))*+cast(avg(t1.f) AS integer) | count(distinct (f))- - -count(*)-cast(avg((e)) AS integer)) from t1) when (abs(11)/abs(t1.e)) then 13 else b end FROM t1 WHERE case when t1.e not between coalesce((select (select count(*)+case max(17) when count(distinct 19-t1.c*t1.c-e) then -min(b)-cast(avg((13)) AS integer)*count(*) else min(19) end from t1)*a*t1.d-17*a+17 from t1 where t1.d not in (13,t1.f, -c)),t1.c) and e then ( -b) when (13)>=(e) then t1.c else e end in (t1.d,t1.c, -11)}
+} {}
+do_test randexpr-2.214 {
+ db eval {SELECT case (select abs(count(distinct -17+(abs(c)/abs(case when exists(select 1 from t1 where (17<>(f))) then e when t1.c not between 11 and t1.d then +11 else t1.e end | b))+d)*+ -(min(f)*max(t1.e))*+cast(avg(t1.f) AS integer) | count(distinct (f))- - -count(*)-cast(avg((e)) AS integer)) from t1) when (abs(11)/abs(t1.e)) then 13 else b end FROM t1 WHERE NOT (case when t1.e not between coalesce((select (select count(*)+case max(17) when count(distinct 19-t1.c*t1.c-e) then -min(b)-cast(avg((13)) AS integer)*count(*) else min(19) end from t1)*a*t1.d-17*a+17 from t1 where t1.d not in (13,t1.f, -c)),t1.c) and e then ( -b) when (13)>=(e) then t1.c else e end in (t1.d,t1.c, -11))}
+} {200}
+do_test randexpr-2.215 {
+ db eval {SELECT case (select abs(count(distinct -17+(abs(c)/abs(case when exists(select 1 from t1 where (17<>(f))) then e when t1.c not between 11 and t1.d then +11 else t1.e end & b))+d)*+ -(min(f)*max(t1.e))*+cast(avg(t1.f) AS integer) & count(distinct (f))- - -count(*)-cast(avg((e)) AS integer)) from t1) when (abs(11)/abs(t1.e)) then 13 else b end FROM t1 WHERE NOT (case when t1.e not between coalesce((select (select count(*)+case max(17) when count(distinct 19-t1.c*t1.c-e) then -min(b)-cast(avg((13)) AS integer)*count(*) else min(19) end from t1)*a*t1.d-17*a+17 from t1 where t1.d not in (13,t1.f, -c)),t1.c) and e then ( -b) when (13)>=(e) then t1.c else e end in (t1.d,t1.c, -11))}
+} {200}
+do_test randexpr-2.216 {
+ db eval {SELECT -case when d<d or not exists(select 1 from t1 where not exists(select 1 from t1 where not not not exists(select 1 from t1 where not e+~t1.c between t1.e and t1.c and t1.c>t1.d))) then case +coalesce((select case when 13>t1.b then 17+t1.d+d when 17 in (t1.b,b,b) and 17<=t1.e then (c) else t1.d end from t1 where 17<a),11) when f then t1.c else b end when 19 between 11 and t1.e then f else a end-19*13 FROM t1 WHERE exists(select 1 from t1 where +13 in (select count(distinct 13) from t1 union select case count(*)+ -(max(t1.c)) when count(*) | ~( -count(*)-count(distinct -f))+min(a)-max(t1.b) then - -max(13) else max(e) end+count(distinct 17) from t1) and d*t1.b>b+t1.a*t1.a-coalesce((select max(d) from t1 where (17 between (t1.d) and (f))),t1.e)-t1.c and t1.d>11)}
+} {}
+do_test randexpr-2.217 {
+ db eval {SELECT -case when d<d or not exists(select 1 from t1 where not exists(select 1 from t1 where not not not exists(select 1 from t1 where not e+~t1.c between t1.e and t1.c and t1.c>t1.d))) then case +coalesce((select case when 13>t1.b then 17+t1.d+d when 17 in (t1.b,b,b) and 17<=t1.e then (c) else t1.d end from t1 where 17<a),11) when f then t1.c else b end when 19 between 11 and t1.e then f else a end-19*13 FROM t1 WHERE NOT (exists(select 1 from t1 where +13 in (select count(distinct 13) from t1 union select case count(*)+ -(max(t1.c)) when count(*) | ~( -count(*)-count(distinct -f))+min(a)-max(t1.b) then - -max(13) else max(e) end+count(distinct 17) from t1) and d*t1.b>b+t1.a*t1.a-coalesce((select max(d) from t1 where (17 between (t1.d) and (f))),t1.e)-t1.c and t1.d>11))}
+} {-447}
+do_test randexpr-2.218 {
+ db eval {SELECT (select + -max(t1.c)*abs(min(t1.b) | case (abs(min(13)))+count(*)-max(t1.a) when max(~13) then abs( -~min(t1.b)+abs(count(distinct (select +++cast(avg(t1.b) AS integer)-case -count(*) when -count(*) then -count(distinct b) else count(distinct c) end from t1)))) else count(*) end-max((e))) | -cast(avg(t1.e) AS integer) from t1) FROM t1 WHERE exists(select 1 from t1 where -f-d*t1.f-c-coalesce((select max(t1.a) from t1 where 11 not in ((select count(*) from t1),coalesce((select max(t1.f+e) from t1 where t1.b in (select count(distinct t1.c) from t1 union select -case abs(abs(count(distinct 13))) when max(t1.b) then abs(cast(avg(11) AS integer)) else -cast(avg(17) AS integer) end from t1)),case t1.f when -b then 17 else 17 end)- -t1.f,b)),a)+f+c-t1.c<t1.b)}
+} {-452}
+do_test randexpr-2.219 {
+ db eval {SELECT (select + -max(t1.c)*abs(min(t1.b) | case (abs(min(13)))+count(*)-max(t1.a) when max(~13) then abs( -~min(t1.b)+abs(count(distinct (select +++cast(avg(t1.b) AS integer)-case -count(*) when -count(*) then -count(distinct b) else count(distinct c) end from t1)))) else count(*) end-max((e))) | -cast(avg(t1.e) AS integer) from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where -f-d*t1.f-c-coalesce((select max(t1.a) from t1 where 11 not in ((select count(*) from t1),coalesce((select max(t1.f+e) from t1 where t1.b in (select count(distinct t1.c) from t1 union select -case abs(abs(count(distinct 13))) when max(t1.b) then abs(cast(avg(11) AS integer)) else -cast(avg(17) AS integer) end from t1)),case t1.f when -b then 17 else 17 end)- -t1.f,b)),a)+f+c-t1.c<t1.b))}
+} {}
+do_test randexpr-2.220 {
+ db eval {SELECT (select + -max(t1.c)*abs(min(t1.b) & case (abs(min(13)))+count(*)-max(t1.a) when max(~13) then abs( -~min(t1.b)+abs(count(distinct (select +++cast(avg(t1.b) AS integer)-case -count(*) when -count(*) then -count(distinct b) else count(distinct c) end from t1)))) else count(*) end-max((e))) & -cast(avg(t1.e) AS integer) from t1) FROM t1 WHERE exists(select 1 from t1 where -f-d*t1.f-c-coalesce((select max(t1.a) from t1 where 11 not in ((select count(*) from t1),coalesce((select max(t1.f+e) from t1 where t1.b in (select count(distinct t1.c) from t1 union select -case abs(abs(count(distinct 13))) when max(t1.b) then abs(cast(avg(11) AS integer)) else -cast(avg(17) AS integer) end from t1)),case t1.f when -b then 17 else 17 end)- -t1.f,b)),a)+f+c-t1.c<t1.b)}
+} {-2560}
+do_test randexpr-2.221 {
+ db eval {SELECT -+(select count(distinct case when (case ~c | coalesce((select max(t1.e-f+t1.d) from t1 where b-coalesce((select max(b) from t1 where t1.c in (select max(t1.d) from t1 union select min(a) from t1)),t1.f) in (select t1.a from t1 union select e from t1)),c) when e then -c else -t1.b end in ( -19, -d,b)) then d when t1.e in (19,d,19) and (t1.b between c and t1.a) then t1.d else 17 end-d) from t1) FROM t1 WHERE f<= -b}
+} {}
+do_test randexpr-2.222 {
+ db eval {SELECT -+(select count(distinct case when (case ~c | coalesce((select max(t1.e-f+t1.d) from t1 where b-coalesce((select max(b) from t1 where t1.c in (select max(t1.d) from t1 union select min(a) from t1)),t1.f) in (select t1.a from t1 union select e from t1)),c) when e then -c else -t1.b end in ( -19, -d,b)) then d when t1.e in (19,d,19) and (t1.b between c and t1.a) then t1.d else 17 end-d) from t1) FROM t1 WHERE NOT (f<= -b)}
+} {-1}
+do_test randexpr-2.223 {
+ db eval {SELECT -+(select count(distinct case when (case ~c & coalesce((select max(t1.e-f+t1.d) from t1 where b-coalesce((select max(b) from t1 where t1.c in (select max(t1.d) from t1 union select min(a) from t1)),t1.f) in (select t1.a from t1 union select e from t1)),c) when e then -c else -t1.b end in ( -19, -d,b)) then d when t1.e in (19,d,19) and (t1.b between c and t1.a) then t1.d else 17 end-d) from t1) FROM t1 WHERE NOT (f<= -b)}
+} {-1}
+do_test randexpr-2.224 {
+ db eval {SELECT (abs(~(+t1.b))/abs(~coalesce((select max(t1.a) from t1 where t1.f<+case when not exists(select 1 from t1 where not c+11=case c when t1.e then 13 else t1.f end+t1.e) and t1.f in (select 11 from t1 union select t1.d from t1) and c not in (t1.f,17,a) then case when a=17 or t1.c between t1.e and 19 or t1.a<>e then 19 else t1.c-t1.d end else b end),(e))-t1.a+(13)-19)) FROM t1 WHERE (not t1.e not in (case when exists(select 1 from t1 where 17<=t1.f*17*t1.b) then f+coalesce((select max(t1.b-c-11+t1.c-a) from t1 where 13 in (select t1.e from t1 union select case when a not between t1.f and d or f<t1.f then d when t1.f<=e then d else e end+17- -17 from t1)),t1.c) else t1.f end,e,t1.a) or exists(select 1 from t1 where t1.a not in (t1.c,(t1.d),(t1.c))))}
+} {0}
+do_test randexpr-2.225 {
+ db eval {SELECT (abs(~(+t1.b))/abs(~coalesce((select max(t1.a) from t1 where t1.f<+case when not exists(select 1 from t1 where not c+11=case c when t1.e then 13 else t1.f end+t1.e) and t1.f in (select 11 from t1 union select t1.d from t1) and c not in (t1.f,17,a) then case when a=17 or t1.c between t1.e and 19 or t1.a<>e then 19 else t1.c-t1.d end else b end),(e))-t1.a+(13)-19)) FROM t1 WHERE NOT ((not t1.e not in (case when exists(select 1 from t1 where 17<=t1.f*17*t1.b) then f+coalesce((select max(t1.b-c-11+t1.c-a) from t1 where 13 in (select t1.e from t1 union select case when a not between t1.f and d or f<t1.f then d when t1.f<=e then d else e end+17- -17 from t1)),t1.c) else t1.f end,e,t1.a) or exists(select 1 from t1 where t1.a not in (t1.c,(t1.d),(t1.c)))))}
+} {}
+do_test randexpr-2.226 {
+ db eval {SELECT (select min(b) | case case cast(avg(c) AS integer) when ~+~count(distinct -19*f*f) then count(distinct (select cast(avg(d-case when t1.a<=19 then 19 else 11 end+f+a) AS integer) from t1))+count(distinct t1.c)+ -+ -count(*) | - -max((17))*min(t1.b)*min((e)) else max(t1.c) end when ( - - -min(a)) then ( -min(c)) else max((11)) end from t1) FROM t1 WHERE case when (((exists(select 1 from t1 where ~t1.d-t1.f between -+t1.f*c and f and not t1.e in (19,a,13))) or -e>=t1.b) and (t1.e<>( -t1.d)) and (t1.c<=13)) then c else d+11 end<=case when (t1.c)>=19 then (t1.e) when (f) not between 11 and f then coalesce((select 13 from t1 where -t1.b>=d),13) else b end}
+} {203}
+do_test randexpr-2.227 {
+ db eval {SELECT (select min(b) | case case cast(avg(c) AS integer) when ~+~count(distinct -19*f*f) then count(distinct (select cast(avg(d-case when t1.a<=19 then 19 else 11 end+f+a) AS integer) from t1))+count(distinct t1.c)+ -+ -count(*) | - -max((17))*min(t1.b)*min((e)) else max(t1.c) end when ( - - -min(a)) then ( -min(c)) else max((11)) end from t1) FROM t1 WHERE NOT (case when (((exists(select 1 from t1 where ~t1.d-t1.f between -+t1.f*c and f and not t1.e in (19,a,13))) or -e>=t1.b) and (t1.e<>( -t1.d)) and (t1.c<=13)) then c else d+11 end<=case when (t1.c)>=19 then (t1.e) when (f) not between 11 and f then coalesce((select 13 from t1 where -t1.b>=d),13) else b end)}
+} {}
+do_test randexpr-2.228 {
+ db eval {SELECT (select min(b) & case case cast(avg(c) AS integer) when ~+~count(distinct -19*f*f) then count(distinct (select cast(avg(d-case when t1.a<=19 then 19 else 11 end+f+a) AS integer) from t1))+count(distinct t1.c)+ -+ -count(*) & - -max((17))*min(t1.b)*min((e)) else max(t1.c) end when ( - - -min(a)) then ( -min(c)) else max((11)) end from t1) FROM t1 WHERE case when (((exists(select 1 from t1 where ~t1.d-t1.f between -+t1.f*c and f and not t1.e in (19,a,13))) or -e>=t1.b) and (t1.e<>( -t1.d)) and (t1.c<=13)) then c else d+11 end<=case when (t1.c)>=19 then (t1.e) when (f) not between 11 and f then coalesce((select 13 from t1 where -t1.b>=d),13) else b end}
+} {8}
+do_test randexpr-2.229 {
+ db eval {SELECT case when 19-b in (select (min(case coalesce((select e from t1 where (c not between c and e)),(select abs(count(distinct coalesce((select max( -coalesce((select max(17) from t1 where (d)>17 and c not between d and b),11)-d) from t1 where ((11)) not in (d,d,e)), - -e))) from t1)+t1.e+t1.a) when f then t1.e else t1.a end)) from t1 union select max(11) from t1) then c else f end+t1.e FROM t1 WHERE coalesce((select max(d) from t1 where coalesce((select max(case when (a++19=case t1.d when t1.e then t1.b else t1.a end*f) and -13=a then case t1.d+13 when t1.f then 17 else t1.f end when (11 not in (d,17,t1.f)) then e else 11 end+b*t1.b) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where t1.f in (select t1.e from t1 union select b from t1)))),(d))<=c),a) between t1.f and d}
+} {}
+do_test randexpr-2.230 {
+ db eval {SELECT case when 19-b in (select (min(case coalesce((select e from t1 where (c not between c and e)),(select abs(count(distinct coalesce((select max( -coalesce((select max(17) from t1 where (d)>17 and c not between d and b),11)-d) from t1 where ((11)) not in (d,d,e)), - -e))) from t1)+t1.e+t1.a) when f then t1.e else t1.a end)) from t1 union select max(11) from t1) then c else f end+t1.e FROM t1 WHERE NOT (coalesce((select max(d) from t1 where coalesce((select max(case when (a++19=case t1.d when t1.e then t1.b else t1.a end*f) and -13=a then case t1.d+13 when t1.f then 17 else t1.f end when (11 not in (d,17,t1.f)) then e else 11 end+b*t1.b) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where t1.f in (select t1.e from t1 union select b from t1)))),(d))<=c),a) between t1.f and d)}
+} {1100}
+do_test randexpr-2.231 {
+ db eval {SELECT -t1.e*coalesce((select max(17) from t1 where (11*(select case -abs( -+count(*)) when -case +(cast(avg( -f) AS integer)) | (abs(cast(avg(c) AS integer))) when min(d) then -max(t1.f) else count(*) end then cast(avg( -t1.f) AS integer) else max(b) end from t1)*~t1.e*case (select min(e) from t1) when 17-t1.b then (e) else t1.f+t1.f end) in (select t1.d from t1 union select 19 from t1)), -t1.a) FROM t1 WHERE (select min(19) from t1) in (select 17 from t1 union select -11+t1.d+t1.c from t1)}
+} {}
+do_test randexpr-2.232 {
+ db eval {SELECT -t1.e*coalesce((select max(17) from t1 where (11*(select case -abs( -+count(*)) when -case +(cast(avg( -f) AS integer)) | (abs(cast(avg(c) AS integer))) when min(d) then -max(t1.f) else count(*) end then cast(avg( -t1.f) AS integer) else max(b) end from t1)*~t1.e*case (select min(e) from t1) when 17-t1.b then (e) else t1.f+t1.f end) in (select t1.d from t1 union select 19 from t1)), -t1.a) FROM t1 WHERE NOT ((select min(19) from t1) in (select 17 from t1 union select -11+t1.d+t1.c from t1))}
+} {50000}
+do_test randexpr-2.233 {
+ db eval {SELECT -t1.e*coalesce((select max(17) from t1 where (11*(select case -abs( -+count(*)) when -case +(cast(avg( -f) AS integer)) & (abs(cast(avg(c) AS integer))) when min(d) then -max(t1.f) else count(*) end then cast(avg( -t1.f) AS integer) else max(b) end from t1)*~t1.e*case (select min(e) from t1) when 17-t1.b then (e) else t1.f+t1.f end) in (select t1.d from t1 union select 19 from t1)), -t1.a) FROM t1 WHERE NOT ((select min(19) from t1) in (select 17 from t1 union select -11+t1.d+t1.c from t1))}
+} {50000}
+do_test randexpr-2.234 {
+ db eval {SELECT (coalesce((select max(case when t1.e>= -e | 13-19*d then case when c not in (+(select count(*) from t1),coalesce((select max(t1.a) from t1 where 13 in (select case count(distinct t1.a) | count(*) when cast(avg(t1.b) AS integer) then count(distinct a) else min(11) end from t1 union select count(*) from t1)),19),t1.a) then t1.c else c end when t1.f in (select t1.f from t1 union select t1.e from t1) then t1.e else -t1.e end) from t1 where (17 in (e,d,a))),t1.d)* -19) FROM t1 WHERE (((abs(t1.f)/abs(d)) in (select case (case max(coalesce((select max(e*(t1.d*13+t1.b)-t1.b) from t1 where t1.a=13),(t1.c))) when (case max(t1.a) when -abs(max(17))-count(distinct 19) then cast(avg(t1.d) AS integer) else max(13) end)*count(distinct t1.c) then (max((t1.b))) else min(19) end) when max(f) then -(count(distinct t1.f)) else min(t1.b) end from t1 union select cast(avg(13) AS integer) from t1) and (13 in (select ((min(b))) from t1 union select - -count(*) from t1))))}
+} {}
+do_test randexpr-2.235 {
+ db eval {SELECT (coalesce((select max(case when t1.e>= -e | 13-19*d then case when c not in (+(select count(*) from t1),coalesce((select max(t1.a) from t1 where 13 in (select case count(distinct t1.a) | count(*) when cast(avg(t1.b) AS integer) then count(distinct a) else min(11) end from t1 union select count(*) from t1)),19),t1.a) then t1.c else c end when t1.f in (select t1.f from t1 union select t1.e from t1) then t1.e else -t1.e end) from t1 where (17 in (e,d,a))),t1.d)* -19) FROM t1 WHERE NOT ((((abs(t1.f)/abs(d)) in (select case (case max(coalesce((select max(e*(t1.d*13+t1.b)-t1.b) from t1 where t1.a=13),(t1.c))) when (case max(t1.a) when -abs(max(17))-count(distinct 19) then cast(avg(t1.d) AS integer) else max(13) end)*count(distinct t1.c) then (max((t1.b))) else min(19) end) when max(f) then -(count(distinct t1.f)) else min(t1.b) end from t1 union select cast(avg(13) AS integer) from t1) and (13 in (select ((min(b))) from t1 union select - -count(*) from t1)))))}
+} {-7600}
+do_test randexpr-2.236 {
+ db eval {SELECT (coalesce((select max(case when t1.e>= -e & 13-19*d then case when c not in (+(select count(*) from t1),coalesce((select max(t1.a) from t1 where 13 in (select case count(distinct t1.a) & count(*) when cast(avg(t1.b) AS integer) then count(distinct a) else min(11) end from t1 union select count(*) from t1)),19),t1.a) then t1.c else c end when t1.f in (select t1.f from t1 union select t1.e from t1) then t1.e else -t1.e end) from t1 where (17 in (e,d,a))),t1.d)* -19) FROM t1 WHERE NOT ((((abs(t1.f)/abs(d)) in (select case (case max(coalesce((select max(e*(t1.d*13+t1.b)-t1.b) from t1 where t1.a=13),(t1.c))) when (case max(t1.a) when -abs(max(17))-count(distinct 19) then cast(avg(t1.d) AS integer) else max(13) end)*count(distinct t1.c) then (max((t1.b))) else min(19) end) when max(f) then -(count(distinct t1.f)) else min(t1.b) end from t1 union select cast(avg(13) AS integer) from t1) and (13 in (select ((min(b))) from t1 union select - -count(*) from t1)))))}
+} {-7600}
+do_test randexpr-2.237 {
+ db eval {SELECT case when case when b in (select abs(abs( -max(case c+d when f then f else 19 end | c)-( -case min(c) when -(cast(avg((t1.f)) AS integer)) then count(*) else ((cast(avg(t1.b) AS integer))) end))+count(*)+(max(17))) from t1 union select count(*) from t1) then t1.a when ~13*t1.a- -c not in (b,e,19) then t1.c else (t1.d) end<=(b) and 13 between t1.f and 11 then t1.f else -19 end FROM t1 WHERE d>=case when t1.d+case when ( -17)-c>11 or b in ((select min(13)+ -cast(avg(11) AS integer) from t1)+~t1.f, -c,(13)) and e in (select (d) from t1 union select f from t1) then t1.a when d= -t1.d then a- -17 else 17 end-t1.c>d then 11 when exists(select 1 from t1 where 17 not between t1.b and t1.b) then t1.b else (t1.a) end}
+} {-19}
+do_test randexpr-2.238 {
+ db eval {SELECT case when case when b in (select abs(abs( -max(case c+d when f then f else 19 end | c)-( -case min(c) when -(cast(avg((t1.f)) AS integer)) then count(*) else ((cast(avg(t1.b) AS integer))) end))+count(*)+(max(17))) from t1 union select count(*) from t1) then t1.a when ~13*t1.a- -c not in (b,e,19) then t1.c else (t1.d) end<=(b) and 13 between t1.f and 11 then t1.f else -19 end FROM t1 WHERE NOT (d>=case when t1.d+case when ( -17)-c>11 or b in ((select min(13)+ -cast(avg(11) AS integer) from t1)+~t1.f, -c,(13)) and e in (select (d) from t1 union select f from t1) then t1.a when d= -t1.d then a- -17 else 17 end-t1.c>d then 11 when exists(select 1 from t1 where 17 not between t1.b and t1.b) then t1.b else (t1.a) end)}
+} {}
+do_test randexpr-2.239 {
+ db eval {SELECT case when case when b in (select abs(abs( -max(case c+d when f then f else 19 end & c)-( -case min(c) when -(cast(avg((t1.f)) AS integer)) then count(*) else ((cast(avg(t1.b) AS integer))) end))+count(*)+(max(17))) from t1 union select count(*) from t1) then t1.a when ~13*t1.a- -c not in (b,e,19) then t1.c else (t1.d) end<=(b) and 13 between t1.f and 11 then t1.f else -19 end FROM t1 WHERE d>=case when t1.d+case when ( -17)-c>11 or b in ((select min(13)+ -cast(avg(11) AS integer) from t1)+~t1.f, -c,(13)) and e in (select (d) from t1 union select f from t1) then t1.a when d= -t1.d then a- -17 else 17 end-t1.c>d then 11 when exists(select 1 from t1 where 17 not between t1.b and t1.b) then t1.b else (t1.a) end}
+} {-19}
+do_test randexpr-2.240 {
+ db eval {SELECT e-coalesce((select coalesce((select max(19) from t1 where (coalesce((select max(case 11 when b then 13 else t1.a end) from t1 where 19 not in (c,t1.f,b)),t1.a)+t1.d in (select 17 from t1 union select 19 from t1) and 11 in (13,t1.c,17) or 19 not in (t1.f,a,17) or t1.e not between 13 and f and a>=d)),(a)-17+t1.f)+t1.a+17 from t1 where not exists(select 1 from t1 where a>t1.f)),t1.b) FROM t1 WHERE t1.a-17 in (select (abs(count(*)))-case case case abs(abs(count(*))) when min(t1.f) then count(*) else cast(avg(+t1.a+(e) | 19*e+t1.f) AS integer) end when abs(+cast(avg(b) AS integer) | count(distinct (13))*+~ -(min(e)) | cast(avg(19) AS integer)) then cast(avg(19) AS integer) else count(distinct t1.c) end | min(t1.d) when count(*) then (count(distinct d)) else (min(11)) end from t1 union select (cast(avg(t1.a) AS integer)) from t1)}
+} {}
+do_test randexpr-2.241 {
+ db eval {SELECT e-coalesce((select coalesce((select max(19) from t1 where (coalesce((select max(case 11 when b then 13 else t1.a end) from t1 where 19 not in (c,t1.f,b)),t1.a)+t1.d in (select 17 from t1 union select 19 from t1) and 11 in (13,t1.c,17) or 19 not in (t1.f,a,17) or t1.e not between 13 and f and a>=d)),(a)-17+t1.f)+t1.a+17 from t1 where not exists(select 1 from t1 where a>t1.f)),t1.b) FROM t1 WHERE NOT (t1.a-17 in (select (abs(count(*)))-case case case abs(abs(count(*))) when min(t1.f) then count(*) else cast(avg(+t1.a+(e) | 19*e+t1.f) AS integer) end when abs(+cast(avg(b) AS integer) | count(distinct (13))*+~ -(min(e)) | cast(avg(19) AS integer)) then cast(avg(19) AS integer) else count(distinct t1.c) end | min(t1.d) when count(*) then (count(distinct d)) else (min(11)) end from t1 union select (cast(avg(t1.a) AS integer)) from t1))}
+} {364}
+do_test randexpr-2.242 {
+ db eval {SELECT -coalesce((select case when b>19 | f-(select abs(max(t1.b+case when e>17 then 11 else f end)+count(*)) from t1) and case when (19<11*t1.d*t1.b) then 13 else t1.e end not between c and b then d+17 else c end-f from t1 where t1.b>=f),t1.c)+17-a FROM t1 WHERE +c in (+~a+case when ((case t1.d when coalesce((select f from t1 where e in (select count(distinct t1.e) from t1 union select min((abs(t1.c)/abs(e | b)) | d* -t1.d) from t1)),t1.e)+a then c else b end in (select -cast(avg(t1.c) AS integer)-~cast(avg(11) AS integer) from t1 union select -count(distinct 19) from t1))) then -e*19 else 13 end,t1.a,d)}
+} {}
+do_test randexpr-2.243 {
+ db eval {SELECT -coalesce((select case when b>19 | f-(select abs(max(t1.b+case when e>17 then 11 else f end)+count(*)) from t1) and case when (19<11*t1.d*t1.b) then 13 else t1.e end not between c and b then d+17 else c end-f from t1 where t1.b>=f),t1.c)+17-a FROM t1 WHERE NOT (+c in (+~a+case when ((case t1.d when coalesce((select f from t1 where e in (select count(distinct t1.e) from t1 union select min((abs(t1.c)/abs(e | b)) | d* -t1.d) from t1)),t1.e)+a then c else b end in (select -cast(avg(t1.c) AS integer)-~cast(avg(11) AS integer) from t1 union select -count(distinct 19) from t1))) then -e*19 else 13 end,t1.a,d))}
+} {-383}
+do_test randexpr-2.244 {
+ db eval {SELECT -coalesce((select case when b>19 & f-(select abs(max(t1.b+case when e>17 then 11 else f end)+count(*)) from t1) and case when (19<11*t1.d*t1.b) then 13 else t1.e end not between c and b then d+17 else c end-f from t1 where t1.b>=f),t1.c)+17-a FROM t1 WHERE NOT (+c in (+~a+case when ((case t1.d when coalesce((select f from t1 where e in (select count(distinct t1.e) from t1 union select min((abs(t1.c)/abs(e | b)) | d* -t1.d) from t1)),t1.e)+a then c else b end in (select -cast(avg(t1.c) AS integer)-~cast(avg(11) AS integer) from t1 union select -count(distinct 19) from t1))) then -e*19 else 13 end,t1.a,d))}
+} {-383}
+do_test randexpr-2.245 {
+ db eval {SELECT case when t1.b>=+(abs(t1.e)/abs(coalesce((select c from t1 where 17<=+(e)),(e)-+~11*17+t1.d-e | +coalesce((select max(t1.d) from t1 where f>e),t1.a)*b | (e))))-t1.a and c>=t1.d or (17 not between e and b) then t1.e else d end FROM t1 WHERE exists(select 1 from t1 where (19-((17))+(b) in (select d*e*a from t1 union select ~19 from t1)) and case b-(abs(case a when coalesce((select max(19) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where b not between e and (t1.f) or a not in (t1.c,17,t1.d)))),case t1.b when -d then 13 else 13 end)*a+t1.c then e else a end)/abs(t1.d))*t1.e when -13 then t1.c else 19 end in (select +count(distinct e) from t1 union select count(*) from t1))}
+} {}
+do_test randexpr-2.246 {
+ db eval {SELECT case when t1.b>=+(abs(t1.e)/abs(coalesce((select c from t1 where 17<=+(e)),(e)-+~11*17+t1.d-e | +coalesce((select max(t1.d) from t1 where f>e),t1.a)*b | (e))))-t1.a and c>=t1.d or (17 not between e and b) then t1.e else d end FROM t1 WHERE NOT (exists(select 1 from t1 where (19-((17))+(b) in (select d*e*a from t1 union select ~19 from t1)) and case b-(abs(case a when coalesce((select max(19) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where b not between e and (t1.f) or a not in (t1.c,17,t1.d)))),case t1.b when -d then 13 else 13 end)*a+t1.c then e else a end)/abs(t1.d))*t1.e when -13 then t1.c else 19 end in (select +count(distinct e) from t1 union select count(*) from t1)))}
+} {500}
+do_test randexpr-2.247 {
+ db eval {SELECT case when t1.b>=+(abs(t1.e)/abs(coalesce((select c from t1 where 17<=+(e)),(e)-+~11*17+t1.d-e & +coalesce((select max(t1.d) from t1 where f>e),t1.a)*b & (e))))-t1.a and c>=t1.d or (17 not between e and b) then t1.e else d end FROM t1 WHERE NOT (exists(select 1 from t1 where (19-((17))+(b) in (select d*e*a from t1 union select ~19 from t1)) and case b-(abs(case a when coalesce((select max(19) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where b not between e and (t1.f) or a not in (t1.c,17,t1.d)))),case t1.b when -d then 13 else 13 end)*a+t1.c then e else a end)/abs(t1.d))*t1.e when -13 then t1.c else 19 end in (select +count(distinct e) from t1 union select count(*) from t1)))}
+} {500}
+do_test randexpr-2.248 {
+ db eval {SELECT case when 11 in (select min(+t1.e)* -max(a)+count(distinct d*11*c)*(count(distinct (e))) | ( -min(t1.b)) | count(distinct 19) | (max(t1.f))-max(t1.b) from t1 union select (min(19)) from t1) then coalesce((select max(17) from t1 where -17=13 or c in (select t1.d from t1 union select d from t1)),b)*t1.b-a+19 when t1.d<(d) then (d) else 19 end FROM t1 WHERE case when case when t1.c not in (f,19,b) then t1.d-t1.c-case when 17<>t1.a then -(abs((select cast(avg(b) AS integer)- -max(t1.c) from t1))/abs(t1.c)) else t1.f end-17 | 19 when exists(select 1 from t1 where exists(select 1 from t1 where (e between 13 and (t1.a))) and e<=t1.c) then f else t1.a end>=11 then c when f<a then t1.b else t1.e end=t1.c}
+} {19}
+do_test randexpr-2.249 {
+ db eval {SELECT case when 11 in (select min(+t1.e)* -max(a)+count(distinct d*11*c)*(count(distinct (e))) | ( -min(t1.b)) | count(distinct 19) | (max(t1.f))-max(t1.b) from t1 union select (min(19)) from t1) then coalesce((select max(17) from t1 where -17=13 or c in (select t1.d from t1 union select d from t1)),b)*t1.b-a+19 when t1.d<(d) then (d) else 19 end FROM t1 WHERE NOT (case when case when t1.c not in (f,19,b) then t1.d-t1.c-case when 17<>t1.a then -(abs((select cast(avg(b) AS integer)- -max(t1.c) from t1))/abs(t1.c)) else t1.f end-17 | 19 when exists(select 1 from t1 where exists(select 1 from t1 where (e between 13 and (t1.a))) and e<=t1.c) then f else t1.a end>=11 then c when f<a then t1.b else t1.e end=t1.c)}
+} {}
+do_test randexpr-2.250 {
+ db eval {SELECT case when 11 in (select min(+t1.e)* -max(a)+count(distinct d*11*c)*(count(distinct (e))) & ( -min(t1.b)) & count(distinct 19) & (max(t1.f))-max(t1.b) from t1 union select (min(19)) from t1) then coalesce((select max(17) from t1 where -17=13 or c in (select t1.d from t1 union select d from t1)),b)*t1.b-a+19 when t1.d<(d) then (d) else 19 end FROM t1 WHERE case when case when t1.c not in (f,19,b) then t1.d-t1.c-case when 17<>t1.a then -(abs((select cast(avg(b) AS integer)- -max(t1.c) from t1))/abs(t1.c)) else t1.f end-17 | 19 when exists(select 1 from t1 where exists(select 1 from t1 where (e between 13 and (t1.a))) and e<=t1.c) then f else t1.a end>=11 then c when f<a then t1.b else t1.e end=t1.c}
+} {19}
+do_test randexpr-2.251 {
+ db eval {SELECT c*~17+~case when (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(e)/abs(c))=case when t1.c not in (a,13,11) and t1.b>=c then t1.b else t1.f end)) and 17<>f) then case when (e) not in (t1.a,t1.f,e) then case case t1.c when 13 then 19 else t1.d end-19 when t1.d then -t1.b else t1.f end when t1.d not in (17,t1.a,t1.d) or c in (d,(19),t1.b) then -t1.b else c end else 19 end+t1.b-f+t1.e FROM t1 WHERE t1.f-case when (coalesce((select 13*(abs(~11)/abs(t1.b)) from t1 where ~a between +f+~+17 and t1.e),e) not between coalesce((select 19-(abs(11)/abs(t1.b)) from t1 where f<>c),t1.b) and t1.f or t1.d between (select case min(a) when cast(avg(e) AS integer) then -((count(*))) else cast(avg(t1.a) AS integer) end | count(*) from t1) and (t1.a)) then 19 else f end=f}
+} {}
+do_test randexpr-2.252 {
+ db eval {SELECT c*~17+~case when (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(e)/abs(c))=case when t1.c not in (a,13,11) and t1.b>=c then t1.b else t1.f end)) and 17<>f) then case when (e) not in (t1.a,t1.f,e) then case case t1.c when 13 then 19 else t1.d end-19 when t1.d then -t1.b else t1.f end when t1.d not in (17,t1.a,t1.d) or c in (d,(19),t1.b) then -t1.b else c end else 19 end+t1.b-f+t1.e FROM t1 WHERE NOT (t1.f-case when (coalesce((select 13*(abs(~11)/abs(t1.b)) from t1 where ~a between +f+~+17 and t1.e),e) not between coalesce((select 19-(abs(11)/abs(t1.b)) from t1 where f<>c),t1.b) and t1.f or t1.d between (select case min(a) when cast(avg(e) AS integer) then -((count(*))) else cast(avg(t1.a) AS integer) end | count(*) from t1) and (t1.a)) then 19 else f end=f)}
+} {-5601}
+do_test randexpr-2.253 {
+ db eval {SELECT coalesce((select c-t1.a | 17 | b-~t1.e-11 from t1 where not exists(select 1 from t1 where t1.c<=t1.b)),17) FROM t1 WHERE (((coalesce((select max((abs(b-t1.d-19*t1.a*e+~case when t1.e=t1.f-e then (select abs(abs(cast(avg((f)) AS integer))) from t1) else ((abs(t1.b)/abs(t1.a))) end-t1.b-t1.c)/abs(t1.b))) from t1 where not t1.c in (select count(distinct c) from t1 union select count(*) from t1) and 17< -t1.e),(c)) | -(c))<>e))}
+} {763}
+do_test randexpr-2.254 {
+ db eval {SELECT coalesce((select c-t1.a | 17 | b-~t1.e-11 from t1 where not exists(select 1 from t1 where t1.c<=t1.b)),17) FROM t1 WHERE NOT ((((coalesce((select max((abs(b-t1.d-19*t1.a*e+~case when t1.e=t1.f-e then (select abs(abs(cast(avg((f)) AS integer))) from t1) else ((abs(t1.b)/abs(t1.a))) end-t1.b-t1.c)/abs(t1.b))) from t1 where not t1.c in (select count(distinct c) from t1 union select count(*) from t1) and 17< -t1.e),(c)) | -(c))<>e)))}
+} {}
+do_test randexpr-2.255 {
+ db eval {SELECT coalesce((select c-t1.a & 17 & b-~t1.e-11 from t1 where not exists(select 1 from t1 where t1.c<=t1.b)),17) FROM t1 WHERE (((coalesce((select max((abs(b-t1.d-19*t1.a*e+~case when t1.e=t1.f-e then (select abs(abs(cast(avg((f)) AS integer))) from t1) else ((abs(t1.b)/abs(t1.a))) end-t1.b-t1.c)/abs(t1.b))) from t1 where not t1.c in (select count(distinct c) from t1 union select count(*) from t1) and 17< -t1.e),(c)) | -(c))<>e))}
+} {0}
+do_test randexpr-2.256 {
+ db eval {SELECT case case +(select case count(distinct case when case when (abs(f | t1.d)/abs(13))<= -c then t1.a else t1.b end+t1.b<=19 then c when 19=a then 17 else 11 end+13) when ~+case (cast(avg(t1.b) AS integer) | ((count(*)))-max(t1.d)) when count(distinct d) then count(*) else cast(avg(t1.c) AS integer) end then count(*) else count(*) end from t1) when c*t1.a then 13 else t1.a end when a then -f else t1.a end+d FROM t1 WHERE case when coalesce((select t1.c | c*t1.e-11 from t1 where exists(select 1 from t1 where t1.d-t1.d*d between - -t1.e and a)), -13)<=e and 11 not in (d,t1.a,f) and t1.a not between 11 and 19 or t1.e<>t1.e and t1.e<c or a between t1.c and c and d>=t1.a or -t1.e>=b then b when 17 not between t1.f and t1.b then a else b end in (select 11 from t1 union select f from t1)}
+} {}
+do_test randexpr-2.257 {
+ db eval {SELECT case case +(select case count(distinct case when case when (abs(f | t1.d)/abs(13))<= -c then t1.a else t1.b end+t1.b<=19 then c when 19=a then 17 else 11 end+13) when ~+case (cast(avg(t1.b) AS integer) | ((count(*)))-max(t1.d)) when count(distinct d) then count(*) else cast(avg(t1.c) AS integer) end then count(*) else count(*) end from t1) when c*t1.a then 13 else t1.a end when a then -f else t1.a end+d FROM t1 WHERE NOT (case when coalesce((select t1.c | c*t1.e-11 from t1 where exists(select 1 from t1 where t1.d-t1.d*d between - -t1.e and a)), -13)<=e and 11 not in (d,t1.a,f) and t1.a not between 11 and 19 or t1.e<>t1.e and t1.e<c or a between t1.c and c and d>=t1.a or -t1.e>=b then b when 17 not between t1.f and t1.b then a else b end in (select 11 from t1 union select f from t1))}
+} {-200}
+do_test randexpr-2.258 {
+ db eval {SELECT case case +(select case count(distinct case when case when (abs(f & t1.d)/abs(13))<= -c then t1.a else t1.b end+t1.b<=19 then c when 19=a then 17 else 11 end+13) when ~+case (cast(avg(t1.b) AS integer) & ((count(*)))-max(t1.d)) when count(distinct d) then count(*) else cast(avg(t1.c) AS integer) end then count(*) else count(*) end from t1) when c*t1.a then 13 else t1.a end when a then -f else t1.a end+d FROM t1 WHERE NOT (case when coalesce((select t1.c | c*t1.e-11 from t1 where exists(select 1 from t1 where t1.d-t1.d*d between - -t1.e and a)), -13)<=e and 11 not in (d,t1.a,f) and t1.a not between 11 and 19 or t1.e<>t1.e and t1.e<c or a between t1.c and c and d>=t1.a or -t1.e>=b then b when 17 not between t1.f and t1.b then a else b end in (select 11 from t1 union select f from t1))}
+} {-200}
+do_test randexpr-2.259 {
+ db eval {SELECT f*coalesce((select max((select count(*) from t1)) from t1 where ~case when t1.e<=case when 17>=+case when c*a in (c,t1.b,13) then t1.e when a>t1.b and a<=19 then c else t1.e end then t1.c else 17 end-f*17 or a between b and 19 then t1.c when -f<=11 then c else -11 end*t1.c+d>=e),17) FROM t1 WHERE (19 not between t1.b and ~e)}
+} {10200}
+do_test randexpr-2.260 {
+ db eval {SELECT f*coalesce((select max((select count(*) from t1)) from t1 where ~case when t1.e<=case when 17>=+case when c*a in (c,t1.b,13) then t1.e when a>t1.b and a<=19 then c else t1.e end then t1.c else 17 end-f*17 or a between b and 19 then t1.c when -f<=11 then c else -11 end*t1.c+d>=e),17) FROM t1 WHERE NOT ((19 not between t1.b and ~e))}
+} {}
+do_test randexpr-2.261 {
+ db eval {SELECT coalesce((select max(t1.c- -case when (~(select max(b*t1.a)*~((min(t1.e))-min((a))) | -cast(avg(t1.e+t1.a) AS integer) from t1))<d then c else (abs( -~19)/abs(c)) end-coalesce((select max(t1.e+a) from t1 where 11<>c or (t1.b)> -(11)),11)) from t1 where -11 in ((d),f,t1.d)),t1.a) FROM t1 WHERE c<>e+t1.c}
+} {100}
+do_test randexpr-2.262 {
+ db eval {SELECT coalesce((select max(t1.c- -case when (~(select max(b*t1.a)*~((min(t1.e))-min((a))) | -cast(avg(t1.e+t1.a) AS integer) from t1))<d then c else (abs( -~19)/abs(c)) end-coalesce((select max(t1.e+a) from t1 where 11<>c or (t1.b)> -(11)),11)) from t1 where -11 in ((d),f,t1.d)),t1.a) FROM t1 WHERE NOT (c<>e+t1.c)}
+} {}
+do_test randexpr-2.263 {
+ db eval {SELECT coalesce((select max(t1.c- -case when (~(select max(b*t1.a)*~((min(t1.e))-min((a))) & -cast(avg(t1.e+t1.a) AS integer) from t1))<d then c else (abs( -~19)/abs(c)) end-coalesce((select max(t1.e+a) from t1 where 11<>c or (t1.b)> -(11)),11)) from t1 where -11 in ((d),f,t1.d)),t1.a) FROM t1 WHERE c<>e+t1.c}
+} {100}
+do_test randexpr-2.264 {
+ db eval {SELECT -case when (not exists(select 1 from t1 where e*d*case 17 when case t1.c-t1.f when t1.a then t1.a else 11 end then t1.c else t1.b end-e+(t1.a)-e not in (e,e,t1.a) and (t1.f not between 19 and t1.e))) and t1.b<t1.a then f-d-c+b when 17=17 then 19 else d end FROM t1 WHERE f*t1.a not between coalesce((select t1.b from t1 where 17=13),17*e) and e}
+} {-19}
+do_test randexpr-2.265 {
+ db eval {SELECT -case when (not exists(select 1 from t1 where e*d*case 17 when case t1.c-t1.f when t1.a then t1.a else 11 end then t1.c else t1.b end-e+(t1.a)-e not in (e,e,t1.a) and (t1.f not between 19 and t1.e))) and t1.b<t1.a then f-d-c+b when 17=17 then 19 else d end FROM t1 WHERE NOT (f*t1.a not between coalesce((select t1.b from t1 where 17=13),17*e) and e)}
+} {}
+do_test randexpr-2.266 {
+ db eval {SELECT coalesce((select 17+coalesce((select max(case when -coalesce((select max((abs( -(abs(t1.a)/abs(t1.d))+11)/abs(e))-b) from t1 where t1.b not between f and t1.c and t1.f<>e),c) between t1.e and f then t1.e when -f> - -b then c else t1.c end) from t1 where not 11 in (select f from t1 union select a from t1)),t1.d)-t1.a-13 from t1 where t1.d between -t1.e and t1.a),f) FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where c in (select (abs(f)/abs(13)) from t1 union select t1.a+b from t1)))}
+} {}
+do_test randexpr-2.267 {
+ db eval {SELECT coalesce((select 17+coalesce((select max(case when -coalesce((select max((abs( -(abs(t1.a)/abs(t1.d))+11)/abs(e))-b) from t1 where t1.b not between f and t1.c and t1.f<>e),c) between t1.e and f then t1.e when -f> - -b then c else t1.c end) from t1 where not 11 in (select f from t1 union select a from t1)),t1.d)-t1.a-13 from t1 where t1.d between -t1.e and t1.a),f) FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where c in (select (abs(f)/abs(13)) from t1 union select t1.a+b from t1))))}
+} {600}
+do_test randexpr-2.268 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where exists(select 1 from t1 where t1.d in (select case (abs(((count(distinct t1.d-c))* -cast(avg(11) AS integer)+max(t1.c)))) when (cast(avg(t1.c+a) AS integer)*+min(a)*max(c)-max(t1.a)+cast(avg(f) AS integer))+cast(avg(t1.e) AS integer) then min(11) else (((min(11)))) end from t1 union select count(*) from t1))),coalesce((select max(b+13) from t1 where exists(select 1 from t1 where f in (select 11 from t1 union select t1.b from t1))),t1.e)) FROM t1 WHERE b>11}
+} {500}
+do_test randexpr-2.269 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where exists(select 1 from t1 where t1.d in (select case (abs(((count(distinct t1.d-c))* -cast(avg(11) AS integer)+max(t1.c)))) when (cast(avg(t1.c+a) AS integer)*+min(a)*max(c)-max(t1.a)+cast(avg(f) AS integer))+cast(avg(t1.e) AS integer) then min(11) else (((min(11)))) end from t1 union select count(*) from t1))),coalesce((select max(b+13) from t1 where exists(select 1 from t1 where f in (select 11 from t1 union select t1.b from t1))),t1.e)) FROM t1 WHERE NOT (b>11)}
+} {}
+do_test randexpr-2.270 {
+ db eval {SELECT coalesce((select max( -(select count(*)-case min(19)-abs(count(*))+(max( -b)-+count(distinct (t1.e))) when max(a) then (count(distinct 19)) else count(*) end from t1)) from t1 where exists(select 1 from t1 where a<(abs(case when a-t1.c+ -19+t1.d between 11 and f then t1.f else d end+t1.a+d)/abs(c))) or t1.c>t1.c),17)*f FROM t1 WHERE not f<>t1.b}
+} {}
+do_test randexpr-2.271 {
+ db eval {SELECT coalesce((select max( -(select count(*)-case min(19)-abs(count(*))+(max( -b)-+count(distinct (t1.e))) when max(a) then (count(distinct 19)) else count(*) end from t1)) from t1 where exists(select 1 from t1 where a<(abs(case when a-t1.c+ -19+t1.d between 11 and f then t1.f else d end+t1.a+d)/abs(c))) or t1.c>t1.c),17)*f FROM t1 WHERE NOT (not f<>t1.b)}
+} {10200}
+do_test randexpr-2.272 {
+ db eval {SELECT case when coalesce((select f-coalesce((select +coalesce((select t1.c from t1 where (t1.c=(abs(t1.e)/abs(+t1.c+f+(f))))),13+17)+t1.b | t1.c from t1 where case when t1.a not in (d,17,t1.c) then f else f end | -13 in (select cast(avg(t1.e) AS integer) from t1 union select min(t1.a) from t1)),c) from t1 where 17>c), -t1.b)>t1.c then 17 when t1.b<>11 then e else t1.f end FROM t1 WHERE case when t1.f in (t1.a+(abs(17)/abs((t1.d))),coalesce((select max(c) from t1 where (not (d- -case f when 17 then d else (17) end+e*t1.d) not in ((t1.d),t1.f,f))),coalesce((select c from t1 where 13 not in (19,d,b)),f)),17) then t1.b when e<=f then 17 else c end<d or t1.d> -19}
+} {500}
+do_test randexpr-2.273 {
+ db eval {SELECT case when coalesce((select f-coalesce((select +coalesce((select t1.c from t1 where (t1.c=(abs(t1.e)/abs(+t1.c+f+(f))))),13+17)+t1.b | t1.c from t1 where case when t1.a not in (d,17,t1.c) then f else f end | -13 in (select cast(avg(t1.e) AS integer) from t1 union select min(t1.a) from t1)),c) from t1 where 17>c), -t1.b)>t1.c then 17 when t1.b<>11 then e else t1.f end FROM t1 WHERE NOT (case when t1.f in (t1.a+(abs(17)/abs((t1.d))),coalesce((select max(c) from t1 where (not (d- -case f when 17 then d else (17) end+e*t1.d) not in ((t1.d),t1.f,f))),coalesce((select c from t1 where 13 not in (19,d,b)),f)),17) then t1.b when e<=f then 17 else c end<d or t1.d> -19)}
+} {}
+do_test randexpr-2.274 {
+ db eval {SELECT case when coalesce((select f-coalesce((select +coalesce((select t1.c from t1 where (t1.c=(abs(t1.e)/abs(+t1.c+f+(f))))),13+17)+t1.b & t1.c from t1 where case when t1.a not in (d,17,t1.c) then f else f end & -13 in (select cast(avg(t1.e) AS integer) from t1 union select min(t1.a) from t1)),c) from t1 where 17>c), -t1.b)>t1.c then 17 when t1.b<>11 then e else t1.f end FROM t1 WHERE case when t1.f in (t1.a+(abs(17)/abs((t1.d))),coalesce((select max(c) from t1 where (not (d- -case f when 17 then d else (17) end+e*t1.d) not in ((t1.d),t1.f,f))),coalesce((select c from t1 where 13 not in (19,d,b)),f)),17) then t1.b when e<=f then 17 else c end<d or t1.d> -19}
+} {500}
+do_test randexpr-2.275 {
+ db eval {SELECT case when d*t1.c*a<>t1.b*~t1.b*t1.f-b then e else 17 end*t1.e+case when a not between t1.a and t1.d or (select - -cast(avg(c) AS integer) from t1)<>17+c then case 11 when t1.f then -t1.b else t1.b end when 13 not in (c,t1.f,19) or not exists(select 1 from t1 where 13=t1.d or t1.e<>a) then (17) else -t1.f end FROM t1 WHERE (not (case e when e then +case when e>=a and 13<>e*t1.e or t1.d<>11 then t1.c else t1.b end else 17 end) in (select cast(avg( -t1.c) AS integer) from t1 union select case min(13) when -+count(distinct 13) then case (+(cast(avg(e) AS integer))+((cast(avg(13) AS integer)))* - -count(distinct c)*count(*)) | count(*) when min(t1.c) then (min(11)) else max(f) end else cast(avg(17) AS integer) end from t1))}
+} {250200}
+do_test randexpr-2.276 {
+ db eval {SELECT case when d*t1.c*a<>t1.b*~t1.b*t1.f-b then e else 17 end*t1.e+case when a not between t1.a and t1.d or (select - -cast(avg(c) AS integer) from t1)<>17+c then case 11 when t1.f then -t1.b else t1.b end when 13 not in (c,t1.f,19) or not exists(select 1 from t1 where 13=t1.d or t1.e<>a) then (17) else -t1.f end FROM t1 WHERE NOT ((not (case e when e then +case when e>=a and 13<>e*t1.e or t1.d<>11 then t1.c else t1.b end else 17 end) in (select cast(avg( -t1.c) AS integer) from t1 union select case min(13) when -+count(distinct 13) then case (+(cast(avg(e) AS integer))+((cast(avg(13) AS integer)))* - -count(distinct c)*count(*)) | count(*) when min(t1.c) then (min(11)) else max(f) end else cast(avg(17) AS integer) end from t1)))}
+} {}
+do_test randexpr-2.277 {
+ db eval {SELECT (select max(t1.a)*abs(count(distinct f-t1.a-(abs(t1.a)/abs(case e when case t1.f when e*(b)-19 then 11 else t1.d end then t1.f else 11 end)))) | case +~cast(avg(t1.a) AS integer)-+abs(count(distinct 17)) when case count(distinct t1.b)*cast(avg(t1.a) AS integer)+count(distinct t1.c) when count(*) then min(t1.f) else count(distinct e) end then max((t1.e)) else max(d) end-count(*) from t1) FROM t1 WHERE e not between (select min(t1.a) from t1) and d+t1.d}
+} {}
+do_test randexpr-2.278 {
+ db eval {SELECT (select max(t1.a)*abs(count(distinct f-t1.a-(abs(t1.a)/abs(case e when case t1.f when e*(b)-19 then 11 else t1.d end then t1.f else 11 end)))) | case +~cast(avg(t1.a) AS integer)-+abs(count(distinct 17)) when case count(distinct t1.b)*cast(avg(t1.a) AS integer)+count(distinct t1.c) when count(*) then min(t1.f) else count(distinct e) end then max((t1.e)) else max(d) end-count(*) from t1) FROM t1 WHERE NOT (e not between (select min(t1.a) from t1) and d+t1.d)}
+} {495}
+do_test randexpr-2.279 {
+ db eval {SELECT (select max(t1.a)*abs(count(distinct f-t1.a-(abs(t1.a)/abs(case e when case t1.f when e*(b)-19 then 11 else t1.d end then t1.f else 11 end)))) & case +~cast(avg(t1.a) AS integer)-+abs(count(distinct 17)) when case count(distinct t1.b)*cast(avg(t1.a) AS integer)+count(distinct t1.c) when count(*) then min(t1.f) else count(distinct e) end then max((t1.e)) else max(d) end-count(*) from t1) FROM t1 WHERE NOT (e not between (select min(t1.a) from t1) and d+t1.d)}
+} {4}
+do_test randexpr-2.280 {
+ db eval {SELECT e*c-t1.e*t1.c++(select abs(case abs(max(coalesce((select f from t1 where (b*coalesce((select max(b) from t1 where 17>f),t1.e) not between c and f or t1.a>d and t1.a<11 or a<> -f)),(t1.a)))) when -+count(distinct e) then -+(count(distinct 19))+min(t1.c) else -min(t1.f) end) from t1)+t1.b-19 FROM t1 WHERE d-coalesce((select max(t1.d*c+c) from t1 where t1.f between (select count(distinct t1.b-e)+abs(~case case ~cast(avg(t1.f) AS integer)-count(distinct t1.a) when count(*) then count(distinct e) else count(*) end when min(e) then min( -t1.c) else max(a) end) from t1)+17 and -case when d>=d-11 then t1.c else t1.a end),t1.a)*t1.a not in (t1.f,t1.f,d)}
+} {781}
+do_test randexpr-2.281 {
+ db eval {SELECT e*c-t1.e*t1.c++(select abs(case abs(max(coalesce((select f from t1 where (b*coalesce((select max(b) from t1 where 17>f),t1.e) not between c and f or t1.a>d and t1.a<11 or a<> -f)),(t1.a)))) when -+count(distinct e) then -+(count(distinct 19))+min(t1.c) else -min(t1.f) end) from t1)+t1.b-19 FROM t1 WHERE NOT (d-coalesce((select max(t1.d*c+c) from t1 where t1.f between (select count(distinct t1.b-e)+abs(~case case ~cast(avg(t1.f) AS integer)-count(distinct t1.a) when count(*) then count(distinct e) else count(*) end when min(e) then min( -t1.c) else max(a) end) from t1)+17 and -case when d>=d-11 then t1.c else t1.a end),t1.a)*t1.a not in (t1.f,t1.f,d))}
+} {}
+do_test randexpr-2.282 {
+ db eval {SELECT coalesce((select a from t1 where (exists(select 1 from t1 where 11-case when ((select count(distinct t1.e+d) from t1))<>t1.d*f then -13 when t1.b in (select abs(cast(avg(c) AS integer)) from t1 union select count(distinct e)*count(distinct c)-cast(avg(e) AS integer) from t1) or c in (select t1.d from t1 union select 17 from t1) then a else t1.b end>=t1.c) and f>=d and d>=t1.f)),case when 11=19 and t1.a between t1.d and e then t1.d-b else t1.b end) FROM t1 WHERE 19 not in ( -t1.f,+19,t1.b)}
+} {}
+do_test randexpr-2.283 {
+ db eval {SELECT coalesce((select a from t1 where (exists(select 1 from t1 where 11-case when ((select count(distinct t1.e+d) from t1))<>t1.d*f then -13 when t1.b in (select abs(cast(avg(c) AS integer)) from t1 union select count(distinct e)*count(distinct c)-cast(avg(e) AS integer) from t1) or c in (select t1.d from t1 union select 17 from t1) then a else t1.b end>=t1.c) and f>=d and d>=t1.f)),case when 11=19 and t1.a between t1.d and e then t1.d-b else t1.b end) FROM t1 WHERE NOT (19 not in ( -t1.f,+19,t1.b))}
+} {200}
+do_test randexpr-2.284 {
+ db eval {SELECT (~case when t1.f>(abs(t1.c)/abs(13-coalesce((select max(t1.a) from t1 where case when e not in (c,t1.a,~11) then 19+( -c) else a end in (select (19) from t1 union select t1.c from t1)),t1.b)+a)) and e>d and (t1.a)=e then t1.e when (not exists(select 1 from t1 where -t1.d=e) and -d in (select d from t1 union select e from t1)) then t1.b else a end) FROM t1 WHERE (t1.f in (select coalesce((select max(coalesce((select c from t1 where coalesce((select max(coalesce((select max(++13*t1.d) from t1 where case when case when e<>13 or b<= -t1.a then t1.c when t1.a not in ( - -13,t1.a,13) then a else c end not in ( -e,d,(11)) or t1.d<t1.a then t1.b when t1.a<> -b then t1.e else t1.d end<a),t1.d)) from t1 where e<>t1.b),c) not in (t1.e,c,b)),13)) from t1 where ((t1.f) in (select max(a) from t1 union select abs(abs(min(13))) from t1))),11) from t1 union select b from t1))}
+} {}
+do_test randexpr-2.285 {
+ db eval {SELECT (~case when t1.f>(abs(t1.c)/abs(13-coalesce((select max(t1.a) from t1 where case when e not in (c,t1.a,~11) then 19+( -c) else a end in (select (19) from t1 union select t1.c from t1)),t1.b)+a)) and e>d and (t1.a)=e then t1.e when (not exists(select 1 from t1 where -t1.d=e) and -d in (select d from t1 union select e from t1)) then t1.b else a end) FROM t1 WHERE NOT ((t1.f in (select coalesce((select max(coalesce((select c from t1 where coalesce((select max(coalesce((select max(++13*t1.d) from t1 where case when case when e<>13 or b<= -t1.a then t1.c when t1.a not in ( - -13,t1.a,13) then a else c end not in ( -e,d,(11)) or t1.d<t1.a then t1.b when t1.a<> -b then t1.e else t1.d end<a),t1.d)) from t1 where e<>t1.b),c) not in (t1.e,c,b)),13)) from t1 where ((t1.f) in (select max(a) from t1 union select abs(abs(min(13))) from t1))),11) from t1 union select b from t1)))}
+} {-101}
+do_test randexpr-2.286 {
+ db eval {SELECT (select count(distinct case b when 13 then (select (+(cast(avg(+(d)*case t1.f-c*(abs(case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (d<=t1.e) or d between c and t1.b)) then 11 else 19 end in ((t1.d),t1.a,t1.f) then t1.f when c<=t1.e then t1.c else b end | a)/abs(c))+t1.b when t1.c then a else d end) AS integer))) from t1) else t1.b*(e) end) from t1) FROM t1 WHERE not t1.a+t1.b | t1.f-11*(select max(+case when case ~e-(abs(d*t1.d+t1.d)/abs( -f)) when t1.a then t1.e else t1.c end in (select cast(avg((f)) AS integer) from t1 union select +~(min(t1.d)) from t1) then (t1.d) when not exists(select 1 from t1 where a not in (17,a,d)) then 19 else -t1.a end* -t1.d) from t1)* -17>13}
+} {1}
+do_test randexpr-2.287 {
+ db eval {SELECT (select count(distinct case b when 13 then (select (+(cast(avg(+(d)*case t1.f-c*(abs(case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (d<=t1.e) or d between c and t1.b)) then 11 else 19 end in ((t1.d),t1.a,t1.f) then t1.f when c<=t1.e then t1.c else b end | a)/abs(c))+t1.b when t1.c then a else d end) AS integer))) from t1) else t1.b*(e) end) from t1) FROM t1 WHERE NOT (not t1.a+t1.b | t1.f-11*(select max(+case when case ~e-(abs(d*t1.d+t1.d)/abs( -f)) when t1.a then t1.e else t1.c end in (select cast(avg((f)) AS integer) from t1 union select +~(min(t1.d)) from t1) then (t1.d) when not exists(select 1 from t1 where a not in (17,a,d)) then 19 else -t1.a end* -t1.d) from t1)* -17>13)}
+} {}
+do_test randexpr-2.288 {
+ db eval {SELECT (select count(distinct case b when 13 then (select (+(cast(avg(+(d)*case t1.f-c*(abs(case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (d<=t1.e) or d between c and t1.b)) then 11 else 19 end in ((t1.d),t1.a,t1.f) then t1.f when c<=t1.e then t1.c else b end & a)/abs(c))+t1.b when t1.c then a else d end) AS integer))) from t1) else t1.b*(e) end) from t1) FROM t1 WHERE not t1.a+t1.b | t1.f-11*(select max(+case when case ~e-(abs(d*t1.d+t1.d)/abs( -f)) when t1.a then t1.e else t1.c end in (select cast(avg((f)) AS integer) from t1 union select +~(min(t1.d)) from t1) then (t1.d) when not exists(select 1 from t1 where a not in (17,a,d)) then 19 else -t1.a end* -t1.d) from t1)* -17>13}
+} {1}
+do_test randexpr-2.289 {
+ db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where ((~t1.f) between b and (abs(e)/abs(f)))),13+(select case abs((+count(*)*max(19))) when (~min(b)) then -min(a) | min( -a) else (max(t1.c)) end from t1)+17*f+11)) from t1 where not 19<=coalesce((select e from t1 where t1.d-d not between 19 and 19),11)),13) FROM t1 WHERE t1.f+t1.d=t1.f+17-case when (abs(t1.a*(case when not exists(select 1 from t1 where not exists(select 1 from t1 where (b) between d and t1.f)) then (t1.b | -(t1.c)) | 19 when d=t1.a then 13 else d end)+ -t1.d)/abs(d)) not in (d,e,t1.d) then t1.f when 19 in (select t1.f from t1 union select t1.e from t1) then e else -t1.a end- - -t1.e*17-t1.d-t1.d}
+} {}
+do_test randexpr-2.290 {
+ db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where ((~t1.f) between b and (abs(e)/abs(f)))),13+(select case abs((+count(*)*max(19))) when (~min(b)) then -min(a) | min( -a) else (max(t1.c)) end from t1)+17*f+11)) from t1 where not 19<=coalesce((select e from t1 where t1.d-d not between 19 and 19),11)),13) FROM t1 WHERE NOT (t1.f+t1.d=t1.f+17-case when (abs(t1.a*(case when not exists(select 1 from t1 where not exists(select 1 from t1 where (b) between d and t1.f)) then (t1.b | -(t1.c)) | 19 when d=t1.a then 13 else d end)+ -t1.d)/abs(d)) not in (d,e,t1.d) then t1.f when 19 in (select t1.f from t1 union select t1.e from t1) then e else -t1.a end- - -t1.e*17-t1.d-t1.d)}
+} {13}
+do_test randexpr-2.291 {
+ db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where ((~t1.f) between b and (abs(e)/abs(f)))),13+(select case abs((+count(*)*max(19))) when (~min(b)) then -min(a) & min( -a) else (max(t1.c)) end from t1)+17*f+11)) from t1 where not 19<=coalesce((select e from t1 where t1.d-d not between 19 and 19),11)),13) FROM t1 WHERE NOT (t1.f+t1.d=t1.f+17-case when (abs(t1.a*(case when not exists(select 1 from t1 where not exists(select 1 from t1 where (b) between d and t1.f)) then (t1.b | -(t1.c)) | 19 when d=t1.a then 13 else d end)+ -t1.d)/abs(d)) not in (d,e,t1.d) then t1.f when 19 in (select t1.f from t1 union select t1.e from t1) then e else -t1.a end- - -t1.e*17-t1.d-t1.d)}
+} {13}
+do_test randexpr-2.292 {
+ db eval {SELECT case when -t1.b=c and ((t1.c>t1.b)) and not exists(select 1 from t1 where (abs((select max(t1.d) from t1))/abs((abs(c+t1.b)/abs(t1.d))-t1.e))+c in (select cast(avg((t1.a)) AS integer) | abs(count(distinct t1.d))+count(*) | count(*)+count(*) from t1 union select (min(t1.d)) from t1)) then (abs(t1.b)/abs(t1.f)) when t1.b not in (a,t1.f,(a)) then t1.b else t1.d end-11 FROM t1 WHERE case when ~e in (coalesce((select 13 from t1 where 17 between t1.a and b or not exists(select 1 from t1 where (c in (11,e,a)))),t1.e),c,e) then e else t1.f end in (select ++abs(case case count(*) when (max(t1.d)) then cast(avg(t1.c) AS integer) else count(distinct b) end | count(*) when max(e) then min(c) else max(13) end | count(*)*count(*)) | max(t1.a) from t1 union select count(distinct t1.c) from t1) or b in (select cast(avg(t1.b) AS integer) from t1 union select cast(avg( -t1.a) AS integer) from t1)}
+} {189}
+do_test randexpr-2.293 {
+ db eval {SELECT case when -t1.b=c and ((t1.c>t1.b)) and not exists(select 1 from t1 where (abs((select max(t1.d) from t1))/abs((abs(c+t1.b)/abs(t1.d))-t1.e))+c in (select cast(avg((t1.a)) AS integer) | abs(count(distinct t1.d))+count(*) | count(*)+count(*) from t1 union select (min(t1.d)) from t1)) then (abs(t1.b)/abs(t1.f)) when t1.b not in (a,t1.f,(a)) then t1.b else t1.d end-11 FROM t1 WHERE NOT (case when ~e in (coalesce((select 13 from t1 where 17 between t1.a and b or not exists(select 1 from t1 where (c in (11,e,a)))),t1.e),c,e) then e else t1.f end in (select ++abs(case case count(*) when (max(t1.d)) then cast(avg(t1.c) AS integer) else count(distinct b) end | count(*) when max(e) then min(c) else max(13) end | count(*)*count(*)) | max(t1.a) from t1 union select count(distinct t1.c) from t1) or b in (select cast(avg(t1.b) AS integer) from t1 union select cast(avg( -t1.a) AS integer) from t1))}
+} {}
+do_test randexpr-2.294 {
+ db eval {SELECT case when -t1.b=c and ((t1.c>t1.b)) and not exists(select 1 from t1 where (abs((select max(t1.d) from t1))/abs((abs(c+t1.b)/abs(t1.d))-t1.e))+c in (select cast(avg((t1.a)) AS integer) & abs(count(distinct t1.d))+count(*) & count(*)+count(*) from t1 union select (min(t1.d)) from t1)) then (abs(t1.b)/abs(t1.f)) when t1.b not in (a,t1.f,(a)) then t1.b else t1.d end-11 FROM t1 WHERE case when ~e in (coalesce((select 13 from t1 where 17 between t1.a and b or not exists(select 1 from t1 where (c in (11,e,a)))),t1.e),c,e) then e else t1.f end in (select ++abs(case case count(*) when (max(t1.d)) then cast(avg(t1.c) AS integer) else count(distinct b) end | count(*) when max(e) then min(c) else max(13) end | count(*)*count(*)) | max(t1.a) from t1 union select count(distinct t1.c) from t1) or b in (select cast(avg(t1.b) AS integer) from t1 union select cast(avg( -t1.a) AS integer) from t1)}
+} {189}
+do_test randexpr-2.295 {
+ db eval {SELECT case when (((abs(11 | e)/abs(17-d))+t1.b | a<>11)) and t1.d in (13,t1.c,11) or 17 between t1.f and b or not f in (select 19 from t1 union select t1.e from t1) and b<>19 or e between 19 and t1.d or b<=d or d<17 or t1.a<>t1.f then 17 when t1.e=t1.b then 11 else coalesce((select t1.e from t1 where (b) between - -d and e),t1.b) end FROM t1 WHERE t1.a between d and +17-17*coalesce((select ~ -19-13-19 from t1 where 19>(select abs(count(distinct t1.d-17))+count(distinct case when 19>17 then t1.f else t1.e end+b) | max(t1.b)+count(distinct 13) from t1)-coalesce((select 13 from t1 where t1.e not in (19,17,e) and 11<=t1.d),c)),t1.f)}
+} {}
+do_test randexpr-2.296 {
+ db eval {SELECT case when (((abs(11 | e)/abs(17-d))+t1.b | a<>11)) and t1.d in (13,t1.c,11) or 17 between t1.f and b or not f in (select 19 from t1 union select t1.e from t1) and b<>19 or e between 19 and t1.d or b<=d or d<17 or t1.a<>t1.f then 17 when t1.e=t1.b then 11 else coalesce((select t1.e from t1 where (b) between - -d and e),t1.b) end FROM t1 WHERE NOT (t1.a between d and +17-17*coalesce((select ~ -19-13-19 from t1 where 19>(select abs(count(distinct t1.d-17))+count(distinct case when 19>17 then t1.f else t1.e end+b) | max(t1.b)+count(distinct 13) from t1)-coalesce((select 13 from t1 where t1.e not in (19,17,e) and 11<=t1.d),c)),t1.f))}
+} {17}
+do_test randexpr-2.297 {
+ db eval {SELECT case when (((abs(11 & e)/abs(17-d))+t1.b & a<>11)) and t1.d in (13,t1.c,11) or 17 between t1.f and b or not f in (select 19 from t1 union select t1.e from t1) and b<>19 or e between 19 and t1.d or b<=d or d<17 or t1.a<>t1.f then 17 when t1.e=t1.b then 11 else coalesce((select t1.e from t1 where (b) between - -d and e),t1.b) end FROM t1 WHERE NOT (t1.a between d and +17-17*coalesce((select ~ -19-13-19 from t1 where 19>(select abs(count(distinct t1.d-17))+count(distinct case when 19>17 then t1.f else t1.e end+b) | max(t1.b)+count(distinct 13) from t1)-coalesce((select 13 from t1 where t1.e not in (19,17,e) and 11<=t1.d),c)),t1.f))}
+} {17}
+do_test randexpr-2.298 {
+ db eval {SELECT case when 19=13 or 13+a | 19*11+b<>b and ((19<=b+(select count(*) from t1))) then t1.d when t1.e<= -19 then d-t1.e+(select ~max(19)*+(count(distinct b)) from t1)+t1.d*t1.d+f else t1.c end FROM t1 WHERE (13*case when 19*case when 19 not between 17 and t1.e then t1.e when ((case when case case when e<>11 or t1.b not in (t1.a, -c,17) then b else a end when -e then b else a end*a in (select 19 from t1 union select 13 from t1) then e else t1.c end in (select -abs(+count(*)) from t1 union select count(distinct f) from t1))) then 19 else d end>=f then t1.a when t1.e>=b then a else c end>=t1.d)}
+} {400}
+do_test randexpr-2.299 {
+ db eval {SELECT case when 19=13 or 13+a | 19*11+b<>b and ((19<=b+(select count(*) from t1))) then t1.d when t1.e<= -19 then d-t1.e+(select ~max(19)*+(count(distinct b)) from t1)+t1.d*t1.d+f else t1.c end FROM t1 WHERE NOT ((13*case when 19*case when 19 not between 17 and t1.e then t1.e when ((case when case case when e<>11 or t1.b not in (t1.a, -c,17) then b else a end when -e then b else a end*a in (select 19 from t1 union select 13 from t1) then e else t1.c end in (select -abs(+count(*)) from t1 union select count(distinct f) from t1))) then 19 else d end>=f then t1.a when t1.e>=b then a else c end>=t1.d))}
+} {}
+do_test randexpr-2.300 {
+ db eval {SELECT case when 19=13 or 13+a & 19*11+b<>b and ((19<=b+(select count(*) from t1))) then t1.d when t1.e<= -19 then d-t1.e+(select ~max(19)*+(count(distinct b)) from t1)+t1.d*t1.d+f else t1.c end FROM t1 WHERE (13*case when 19*case when 19 not between 17 and t1.e then t1.e when ((case when case case when e<>11 or t1.b not in (t1.a, -c,17) then b else a end when -e then b else a end*a in (select 19 from t1 union select 13 from t1) then e else t1.c end in (select -abs(+count(*)) from t1 union select count(distinct f) from t1))) then 19 else d end>=f then t1.a when t1.e>=b then a else c end>=t1.d)}
+} {400}
+do_test randexpr-2.301 {
+ db eval {SELECT +coalesce((select t1.d from t1 where coalesce((select t1.c+t1.b-case (19) when t1.c then 13+13+17 else t1.e end from t1 where (not exists(select 1 from t1 where t1.f<13)) and d not in (t1.e,11,19) and not 19>=t1.f or e in (select min(t1.c) from t1 union select cast(avg(t1.c) AS integer) from t1)), -a)-b*(13)<t1.b),(t1.c)) | t1.e FROM t1 WHERE not (11>(+b))}
+} {500}
+do_test randexpr-2.302 {
+ db eval {SELECT +coalesce((select t1.d from t1 where coalesce((select t1.c+t1.b-case (19) when t1.c then 13+13+17 else t1.e end from t1 where (not exists(select 1 from t1 where t1.f<13)) and d not in (t1.e,11,19) and not 19>=t1.f or e in (select min(t1.c) from t1 union select cast(avg(t1.c) AS integer) from t1)), -a)-b*(13)<t1.b),(t1.c)) | t1.e FROM t1 WHERE NOT (not (11>(+b)))}
+} {}
+do_test randexpr-2.303 {
+ db eval {SELECT +coalesce((select t1.d from t1 where coalesce((select t1.c+t1.b-case (19) when t1.c then 13+13+17 else t1.e end from t1 where (not exists(select 1 from t1 where t1.f<13)) and d not in (t1.e,11,19) and not 19>=t1.f or e in (select min(t1.c) from t1 union select cast(avg(t1.c) AS integer) from t1)), -a)-b*(13)<t1.b),(t1.c)) & t1.e FROM t1 WHERE not (11>(+b))}
+} {400}
+do_test randexpr-2.304 {
+ db eval {SELECT case when (((t1.c)<=a-11*t1.e)) then t1.b else a end | ((abs(b*(abs(t1.e | +c)/abs(11)))/abs(t1.a))) FROM t1 WHERE case when t1.e in (select t1.a-e from t1 union select t1.e from t1) then 19*coalesce((select a*t1.c-19+f+t1.d-case case when 11>=d then f when not f<>17 then t1.d else t1.f end+t1.e-t1.c when d then b else t1.f end from t1 where t1.f>a), -t1.a)- -(t1.c)-t1.e+b else 11 end<t1.f}
+} {}
+do_test randexpr-2.305 {
+ db eval {SELECT case when (((t1.c)<=a-11*t1.e)) then t1.b else a end | ((abs(b*(abs(t1.e | +c)/abs(11)))/abs(t1.a))) FROM t1 WHERE NOT (case when t1.e in (select t1.a-e from t1 union select t1.e from t1) then 19*coalesce((select a*t1.c-19+f+t1.d-case case when 11>=d then f when not f<>17 then t1.d else t1.f end+t1.e-t1.c when d then b else t1.f end from t1 where t1.f>a), -t1.a)- -(t1.c)-t1.e+b else 11 end<t1.f)}
+} {124}
+do_test randexpr-2.306 {
+ db eval {SELECT case when (((t1.c)<=a-11*t1.e)) then t1.b else a end & ((abs(b*(abs(t1.e & +c)/abs(11)))/abs(t1.a))) FROM t1 WHERE NOT (case when t1.e in (select t1.a-e from t1 union select t1.e from t1) then 19*coalesce((select a*t1.c-19+f+t1.d-case case when 11>=d then f when not f<>17 then t1.d else t1.f end+t1.e-t1.c when d then b else t1.f end from t1 where t1.f>a), -t1.a)- -(t1.c)-t1.e+b else 11 end<t1.f)}
+} {36}
+do_test randexpr-2.307 {
+ db eval {SELECT 17*case when case t1.e when 13-c+f then d else (select + -case cast(avg(b) AS integer)*count(*) when (count(distinct 17)+case abs((count(distinct t1.e))) when count(*) then count(*) else count(distinct c) end) | count(*) then -count(distinct b) else - -min(e) end*min(f)-min(t1.e) from t1) end-(select (count(*)) from t1) in (select 19 from t1 union select t1.a-(select count(distinct t1.c) from t1) from t1) then a-13 else t1.d end FROM t1 WHERE not exists(select 1 from t1 where (case -17 when c then (abs(t1.d)/abs(c-(abs(case when t1.e in (17,t1.a,(abs(e)/abs(t1.d))) then +d-17*t1.b when (select +cast(avg(t1.a*t1.e+e-19) AS integer) from t1) in (select (abs(b)/abs(f)) from t1 union select (19) from t1) then b else t1.f end)/abs(e))*e))+(c) else -t1.c end<=(11)))}
+} {}
+do_test randexpr-2.308 {
+ db eval {SELECT 17*case when case t1.e when 13-c+f then d else (select + -case cast(avg(b) AS integer)*count(*) when (count(distinct 17)+case abs((count(distinct t1.e))) when count(*) then count(*) else count(distinct c) end) | count(*) then -count(distinct b) else - -min(e) end*min(f)-min(t1.e) from t1) end-(select (count(*)) from t1) in (select 19 from t1 union select t1.a-(select count(distinct t1.c) from t1) from t1) then a-13 else t1.d end FROM t1 WHERE NOT (not exists(select 1 from t1 where (case -17 when c then (abs(t1.d)/abs(c-(abs(case when t1.e in (17,t1.a,(abs(e)/abs(t1.d))) then +d-17*t1.b when (select +cast(avg(t1.a*t1.e+e-19) AS integer) from t1) in (select (abs(b)/abs(f)) from t1 union select (19) from t1) then b else t1.f end)/abs(e))*e))+(c) else -t1.c end<=(11))))}
+} {6800}
+do_test randexpr-2.309 {
+ db eval {SELECT 17*case when case t1.e when 13-c+f then d else (select + -case cast(avg(b) AS integer)*count(*) when (count(distinct 17)+case abs((count(distinct t1.e))) when count(*) then count(*) else count(distinct c) end) & count(*) then -count(distinct b) else - -min(e) end*min(f)-min(t1.e) from t1) end-(select (count(*)) from t1) in (select 19 from t1 union select t1.a-(select count(distinct t1.c) from t1) from t1) then a-13 else t1.d end FROM t1 WHERE NOT (not exists(select 1 from t1 where (case -17 when c then (abs(t1.d)/abs(c-(abs(case when t1.e in (17,t1.a,(abs(e)/abs(t1.d))) then +d-17*t1.b when (select +cast(avg(t1.a*t1.e+e-19) AS integer) from t1) in (select (abs(b)/abs(f)) from t1 union select (19) from t1) then b else t1.f end)/abs(e))*e))+(c) else -t1.c end<=(11))))}
+} {6800}
+do_test randexpr-2.310 {
+ db eval {SELECT t1.f+coalesce((select t1.b-13-(coalesce((select 17 from t1 where b>a),13)*11)-t1.c from t1 where 11 between t1.a and -13+t1.f*~coalesce((select max(b-f) from t1 where t1.a<=13 or a not in (13,f,17)),b) or (t1.d<19 or b> -t1.c)),b) FROM t1 WHERE 11 not between d and coalesce((select -(select (cast(avg(d) AS integer)) from t1) from t1 where case when 17<t1.a then t1.b else coalesce((select max(f) from t1 where t1.d-+case when (d<=t1.f) and t1.e not in (17,t1.d,t1.a) and 11 in (13,t1.e, -t1.a) and t1.c<13 then -b else case when a>13 then e when 19 between t1.a and t1.b then b else b end end*13<=c),t1.c) end in (select t1.e from t1 union select d from t1)),t1.b)}
+} {300}
+do_test randexpr-2.311 {
+ db eval {SELECT t1.f+coalesce((select t1.b-13-(coalesce((select 17 from t1 where b>a),13)*11)-t1.c from t1 where 11 between t1.a and -13+t1.f*~coalesce((select max(b-f) from t1 where t1.a<=13 or a not in (13,f,17)),b) or (t1.d<19 or b> -t1.c)),b) FROM t1 WHERE NOT (11 not between d and coalesce((select -(select (cast(avg(d) AS integer)) from t1) from t1 where case when 17<t1.a then t1.b else coalesce((select max(f) from t1 where t1.d-+case when (d<=t1.f) and t1.e not in (17,t1.d,t1.a) and 11 in (13,t1.e, -t1.a) and t1.c<13 then -b else case when a>13 then e when 19 between t1.a and t1.b then b else b end end*13<=c),t1.c) end in (select t1.e from t1 union select d from t1)),t1.b))}
+} {}
+do_test randexpr-2.312 {
+ db eval {SELECT (abs(13)/abs((select min(case when case when exists(select 1 from t1 where not exists(select 1 from t1 where (select count(distinct (t1.e)) from t1)+t1.f>t1.e) and t1.a>=13 or f in (select t1.e from t1 union select t1.e from t1)) then b when f not in (13,13,13) then coalesce((select max(d*f) from t1 where t1.e in (t1.d,t1.e,(e))),t1.e) else a end>=t1.f then b when t1.c in (e,f,t1.e) then b else t1.c end)*abs(count(*))-abs(~count(*)-min(e))-cast(avg(17) AS integer) from t1))) FROM t1 WHERE t1.b not in (a*17-17-case when -17-t1.f in (select coalesce((select t1.a from t1 where (d)=t1.a),d) from t1 union select 19 from t1) or 13 not between 17 and 13 and (19 between (t1.e) and t1.f) or ( -t1.e)>=17 then b when t1.d not in (19,f,t1.f) then a else case when t1.a=t1.d then e when 17 in (t1.e,t1.b,t1.d) then t1.a else a end end,e,11)}
+} {0}
+do_test randexpr-2.313 {
+ db eval {SELECT (abs(13)/abs((select min(case when case when exists(select 1 from t1 where not exists(select 1 from t1 where (select count(distinct (t1.e)) from t1)+t1.f>t1.e) and t1.a>=13 or f in (select t1.e from t1 union select t1.e from t1)) then b when f not in (13,13,13) then coalesce((select max(d*f) from t1 where t1.e in (t1.d,t1.e,(e))),t1.e) else a end>=t1.f then b when t1.c in (e,f,t1.e) then b else t1.c end)*abs(count(*))-abs(~count(*)-min(e))-cast(avg(17) AS integer) from t1))) FROM t1 WHERE NOT (t1.b not in (a*17-17-case when -17-t1.f in (select coalesce((select t1.a from t1 where (d)=t1.a),d) from t1 union select 19 from t1) or 13 not between 17 and 13 and (19 between (t1.e) and t1.f) or ( -t1.e)>=17 then b when t1.d not in (19,f,t1.f) then a else case when t1.a=t1.d then e when 17 in (t1.e,t1.b,t1.d) then t1.a else a end end,e,11))}
+} {}
+do_test randexpr-2.314 {
+ db eval {SELECT (abs(case coalesce((select t1.d* -case when d in (select cast(avg(13) AS integer)*abs(((cast(avg(d) AS integer)))+ -count(distinct c))-max(t1.c) from t1 union select min(e) from t1) then (abs(19)/abs(case when b not in (19,d,13) or t1.b not in (b,17,17) then e else b end)) else 19 end from t1 where a>=t1.c and 17 not in (t1.c,17,t1.f)),13)*t1.f when e then (11) else 17 end+19 | b)/abs(f))-t1.e FROM t1 WHERE not exists(select 1 from t1 where case a when coalesce((select max(case 19 when 17 then b-d else t1.e end) from t1 where ( -coalesce((select max(t1.a) from t1 where e between t1.b and (abs(e)/abs(17))),(abs(case when case when 13 between e and (t1.b) and 11 not in (t1.f,t1.e,c) then (t1.d) else -c end< -e then 11 when 13>t1.b then 11 else t1.a end*13)/abs((f)))-t1.a) not in (e,(b),t1.c))),19) then t1.b else 13 end not between t1.b and 11)}
+} {}
+do_test randexpr-2.315 {
+ db eval {SELECT (abs(case coalesce((select t1.d* -case when d in (select cast(avg(13) AS integer)*abs(((cast(avg(d) AS integer)))+ -count(distinct c))-max(t1.c) from t1 union select min(e) from t1) then (abs(19)/abs(case when b not in (19,d,13) or t1.b not in (b,17,17) then e else b end)) else 19 end from t1 where a>=t1.c and 17 not in (t1.c,17,t1.f)),13)*t1.f when e then (11) else 17 end+19 | b)/abs(f))-t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where case a when coalesce((select max(case 19 when 17 then b-d else t1.e end) from t1 where ( -coalesce((select max(t1.a) from t1 where e between t1.b and (abs(e)/abs(17))),(abs(case when case when 13 between e and (t1.b) and 11 not in (t1.f,t1.e,c) then (t1.d) else -c end< -e then 11 when 13>t1.b then 11 else t1.a end*13)/abs((f)))-t1.a) not in (e,(b),t1.c))),19) then t1.b else 13 end not between t1.b and 11))}
+} {-500}
+do_test randexpr-2.316 {
+ db eval {SELECT (abs(case coalesce((select t1.d* -case when d in (select cast(avg(13) AS integer)*abs(((cast(avg(d) AS integer)))+ -count(distinct c))-max(t1.c) from t1 union select min(e) from t1) then (abs(19)/abs(case when b not in (19,d,13) or t1.b not in (b,17,17) then e else b end)) else 19 end from t1 where a>=t1.c and 17 not in (t1.c,17,t1.f)),13)*t1.f when e then (11) else 17 end+19 & b)/abs(f))-t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where case a when coalesce((select max(case 19 when 17 then b-d else t1.e end) from t1 where ( -coalesce((select max(t1.a) from t1 where e between t1.b and (abs(e)/abs(17))),(abs(case when case when 13 between e and (t1.b) and 11 not in (t1.f,t1.e,c) then (t1.d) else -c end< -e then 11 when 13>t1.b then 11 else t1.a end*13)/abs((f)))-t1.a) not in (e,(b),t1.c))),19) then t1.b else 13 end not between t1.b and 11))}
+} {-500}
+do_test randexpr-2.317 {
+ db eval {SELECT -(+case when ~t1.d-f-case coalesce((select max((select (min((abs(t1.f)/abs(t1.b))-17)) from t1)) from t1 where e<=17),f) when t1.f then (select case -( -count(distinct b)) when cast(avg( -13) AS integer) then cast(avg(13) AS integer) else max(19) end from t1)-t1.e else 13 end*b between t1.c and t1.d then t1.d when e<t1.f then -t1.b else 19 end | d*e) FROM t1 WHERE ~t1.d*~( -coalesce((select max(t1.d | t1.a) from t1 where d-(select -( - -count(distinct 13)) | min((t1.f))+min(t1.c) from t1) not between case t1.a when t1.b then e else -c end and c or t1.a not in (a,19,c)),d)) in (select +(max(t1.b))*max((13))++(count(distinct t1.a))+count(*)-count(distinct f) | cast(avg(t1.d) AS integer) from t1 union select cast(avg(13) AS integer) from t1)}
+} {}
+do_test randexpr-2.318 {
+ db eval {SELECT -(+case when ~t1.d-f-case coalesce((select max((select (min((abs(t1.f)/abs(t1.b))-17)) from t1)) from t1 where e<=17),f) when t1.f then (select case -( -count(distinct b)) when cast(avg( -13) AS integer) then cast(avg(13) AS integer) else max(19) end from t1)-t1.e else 13 end*b between t1.c and t1.d then t1.d when e<t1.f then -t1.b else 19 end | d*e) FROM t1 WHERE NOT (~t1.d*~( -coalesce((select max(t1.d | t1.a) from t1 where d-(select -( - -count(distinct 13)) | min((t1.f))+min(t1.c) from t1) not between case t1.a when t1.b then e else -c end and c or t1.a not in (a,19,c)),d)) in (select +(max(t1.b))*max((13))++(count(distinct t1.a))+count(*)-count(distinct f) | cast(avg(t1.d) AS integer) from t1 union select cast(avg(13) AS integer) from t1))}
+} {136}
+do_test randexpr-2.319 {
+ db eval {SELECT -(+case when ~t1.d-f-case coalesce((select max((select (min((abs(t1.f)/abs(t1.b))-17)) from t1)) from t1 where e<=17),f) when t1.f then (select case -( -count(distinct b)) when cast(avg( -13) AS integer) then cast(avg(13) AS integer) else max(19) end from t1)-t1.e else 13 end*b between t1.c and t1.d then t1.d when e<t1.f then -t1.b else 19 end & d*e) FROM t1 WHERE NOT (~t1.d*~( -coalesce((select max(t1.d | t1.a) from t1 where d-(select -( - -count(distinct 13)) | min((t1.f))+min(t1.c) from t1) not between case t1.a when t1.b then e else -c end and c or t1.a not in (a,19,c)),d)) in (select +(max(t1.b))*max((13))++(count(distinct t1.a))+count(*)-count(distinct f) | cast(avg(t1.d) AS integer) from t1 union select cast(avg(13) AS integer) from t1))}
+} {-199936}
+do_test randexpr-2.320 {
+ db eval {SELECT ~d-coalesce((select +e from t1 where b not between b and ~d++ -t1.b),f)-f-+19-t1.a+case when d<=(abs(19)/abs(+coalesce((select 11 from t1 where not exists(select 1 from t1 where not coalesce((select t1.d from t1 where not t1.a<=t1.c),11) in (select 19 from t1 union select t1.a from t1) or t1.c<=t1.c and a<t1.b)),17-t1.e))) then f else t1.a end*c FROM t1 WHERE (select count(*) from t1)*e-17 | f not between 11 and t1.d or t1.c* -b in (select (abs(case when not 19<( -(t1.e-c*t1.b)+(d)-c) then t1.f-t1.b when t1.f<=11 or exists(select 1 from t1 where t1.e in (13,t1.f,t1.d)) then t1.f else 19 end)/abs(e)) from t1 union select 17 from t1)}
+} {28380}
+do_test randexpr-2.321 {
+ db eval {SELECT ~d-coalesce((select +e from t1 where b not between b and ~d++ -t1.b),f)-f-+19-t1.a+case when d<=(abs(19)/abs(+coalesce((select 11 from t1 where not exists(select 1 from t1 where not coalesce((select t1.d from t1 where not t1.a<=t1.c),11) in (select 19 from t1 union select t1.a from t1) or t1.c<=t1.c and a<t1.b)),17-t1.e))) then f else t1.a end*c FROM t1 WHERE NOT ((select count(*) from t1)*e-17 | f not between 11 and t1.d or t1.c* -b in (select (abs(case when not 19<( -(t1.e-c*t1.b)+(d)-c) then t1.f-t1.b when t1.f<=11 or exists(select 1 from t1 where t1.e in (13,t1.f,t1.d)) then t1.f else 19 end)/abs(e)) from t1 union select 17 from t1))}
+} {}
+do_test randexpr-2.322 {
+ db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where 11 in (select count(distinct d-coalesce((select t1.c-t1.f from t1 where 13 in (19,e,t1.b) and e in (select ( -count(*)) from t1 union select max(e) from t1) or t1.a>t1.f),d)*t1.e)+max(t1.f)+cast(avg(e) AS integer) | (abs((count(distinct 17)))) from t1 union select max(t1.b) from t1) or 17 in (select -t1.b from t1 union select t1.a from t1) and exists(select 1 from t1 where t1.e=t1.c))),f+(t1.e)) FROM t1 WHERE exists(select 1 from t1 where +t1.d between (abs((abs(t1.c)/abs(case when not exists(select 1 from t1 where d*~(select abs(min(13))-( -(max(t1.f))*( -(count(distinct a)))-max(17)*min(t1.a) | (cast(avg(t1.b) AS integer))) from t1)>case when a in (select max(c) from t1 union select count(distinct -t1.a) from t1) or +17 in (select -count(distinct t1.f) from t1 union select cast(avg(t1.f) AS integer) from t1) then c else t1.a end) then -t1.f else t1.f end)))/abs(c+a)) and d)}
+} {17}
+do_test randexpr-2.323 {
+ db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where 11 in (select count(distinct d-coalesce((select t1.c-t1.f from t1 where 13 in (19,e,t1.b) and e in (select ( -count(*)) from t1 union select max(e) from t1) or t1.a>t1.f),d)*t1.e)+max(t1.f)+cast(avg(e) AS integer) | (abs((count(distinct 17)))) from t1 union select max(t1.b) from t1) or 17 in (select -t1.b from t1 union select t1.a from t1) and exists(select 1 from t1 where t1.e=t1.c))),f+(t1.e)) FROM t1 WHERE NOT (exists(select 1 from t1 where +t1.d between (abs((abs(t1.c)/abs(case when not exists(select 1 from t1 where d*~(select abs(min(13))-( -(max(t1.f))*( -(count(distinct a)))-max(17)*min(t1.a) | (cast(avg(t1.b) AS integer))) from t1)>case when a in (select max(c) from t1 union select count(distinct -t1.a) from t1) or +17 in (select -count(distinct t1.f) from t1 union select cast(avg(t1.f) AS integer) from t1) then c else t1.a end) then -t1.f else t1.f end)))/abs(c+a)) and d))}
+} {}
+do_test randexpr-2.324 {
+ db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where 11 in (select count(distinct d-coalesce((select t1.c-t1.f from t1 where 13 in (19,e,t1.b) and e in (select ( -count(*)) from t1 union select max(e) from t1) or t1.a>t1.f),d)*t1.e)+max(t1.f)+cast(avg(e) AS integer) & (abs((count(distinct 17)))) from t1 union select max(t1.b) from t1) or 17 in (select -t1.b from t1 union select t1.a from t1) and exists(select 1 from t1 where t1.e=t1.c))),f+(t1.e)) FROM t1 WHERE exists(select 1 from t1 where +t1.d between (abs((abs(t1.c)/abs(case when not exists(select 1 from t1 where d*~(select abs(min(13))-( -(max(t1.f))*( -(count(distinct a)))-max(17)*min(t1.a) | (cast(avg(t1.b) AS integer))) from t1)>case when a in (select max(c) from t1 union select count(distinct -t1.a) from t1) or +17 in (select -count(distinct t1.f) from t1 union select cast(avg(t1.f) AS integer) from t1) then c else t1.a end) then -t1.f else t1.f end)))/abs(c+a)) and d)}
+} {17}
+do_test randexpr-2.325 {
+ db eval {SELECT t1.d*17- -case when case (b) when t1.c then (abs(t1.f)/abs((select + -~abs(min(f) | +cast(avg(++t1.e+t1.d) AS integer) | ((count(distinct t1.a)-count(*)))) from t1))) else c*case t1.b when t1.d then (t1.c) else t1.c end*(b)-c end=t1.d then t1.c when -17=c then t1.e else t1.c end FROM t1 WHERE t1.b in (f,b,a)}
+} {7100}
+do_test randexpr-2.326 {
+ db eval {SELECT t1.d*17- -case when case (b) when t1.c then (abs(t1.f)/abs((select + -~abs(min(f) | +cast(avg(++t1.e+t1.d) AS integer) | ((count(distinct t1.a)-count(*)))) from t1))) else c*case t1.b when t1.d then (t1.c) else t1.c end*(b)-c end=t1.d then t1.c when -17=c then t1.e else t1.c end FROM t1 WHERE NOT (t1.b in (f,b,a))}
+} {}
+do_test randexpr-2.327 {
+ db eval {SELECT t1.d*17- -case when case (b) when t1.c then (abs(t1.f)/abs((select + -~abs(min(f) & +cast(avg(++t1.e+t1.d) AS integer) & ((count(distinct t1.a)-count(*)))) from t1))) else c*case t1.b when t1.d then (t1.c) else t1.c end*(b)-c end=t1.d then t1.c when -17=c then t1.e else t1.c end FROM t1 WHERE t1.b in (f,b,a)}
+} {7100}
+do_test randexpr-2.328 {
+ db eval {SELECT coalesce((select e-t1.d-+b*coalesce((select 11 from t1 where (t1.a<=coalesce((select - -coalesce((select max(case case 19 when t1.d then t1.e else t1.a end when b then 13 else t1.e end) from t1 where (c)>=(b)),t1.c)+t1.b from t1 where t1.e>e and exists(select 1 from t1 where b in (t1.b,e,t1.c) or e not between a and d) and 13<b),a))),t1.e) from t1 where t1.a<t1.a),t1.e) FROM t1 WHERE exists(select 1 from t1 where coalesce((select max(coalesce((select case case coalesce((select d from t1 where b in (17,t1.a,13)),11) when (coalesce((select 11 from t1 where a++t1.d>(coalesce((select (f)+t1.c from t1 where a>t1.c),b))),t1.e)) then 19 else e end when t1.d then t1.e else b end from t1 where t1.b>=f),13)-b*17) from t1 where 11<>e),t1.b)<(c))}
+} {500}
+do_test randexpr-2.329 {
+ db eval {SELECT coalesce((select e-t1.d-+b*coalesce((select 11 from t1 where (t1.a<=coalesce((select - -coalesce((select max(case case 19 when t1.d then t1.e else t1.a end when b then 13 else t1.e end) from t1 where (c)>=(b)),t1.c)+t1.b from t1 where t1.e>e and exists(select 1 from t1 where b in (t1.b,e,t1.c) or e not between a and d) and 13<b),a))),t1.e) from t1 where t1.a<t1.a),t1.e) FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select max(coalesce((select case case coalesce((select d from t1 where b in (17,t1.a,13)),11) when (coalesce((select 11 from t1 where a++t1.d>(coalesce((select (f)+t1.c from t1 where a>t1.c),b))),t1.e)) then 19 else e end when t1.d then t1.e else b end from t1 where t1.b>=f),13)-b*17) from t1 where 11<>e),t1.b)<(c)))}
+} {}
+do_test randexpr-2.330 {
+ db eval {SELECT (abs(case when ++e not in (~c-(19)*+case t1.c when t1.d-coalesce((select max(t1.f) from t1 where (select count(*) from t1)>case when exists(select 1 from t1 where not exists(select 1 from t1 where (not not exists(select 1 from t1 where 19<t1.c)))) then ~t1.d else case coalesce((select 17 from t1 where -t1.b<>e),t1.e) when 13 then b else t1.c end end+f),c)*t1.c then t1.e else t1.b end,11,b) then -(t1.b) else a end)/abs(13)) FROM t1 WHERE a*t1.a<=17 and exists(select 1 from t1 where (+case coalesce((select max(f) from t1 where d in (select ((+count(*)-( -max(b))))*min(t1.c)* -max(11) from t1 union select count(distinct (19)) from t1)),t1.c) when 13 then 19 else coalesce((select t1.a from t1 where t1.c not in (t1.c,f,13)),b) end)>t1.c) and ( -( -19) between 13 and b or b in (select 11 from t1 union select a from t1) and 19 in (t1.d,t1.d,19))}
+} {}
+do_test randexpr-2.331 {
+ db eval {SELECT (abs(case when ++e not in (~c-(19)*+case t1.c when t1.d-coalesce((select max(t1.f) from t1 where (select count(*) from t1)>case when exists(select 1 from t1 where not exists(select 1 from t1 where (not not exists(select 1 from t1 where 19<t1.c)))) then ~t1.d else case coalesce((select 17 from t1 where -t1.b<>e),t1.e) when 13 then b else t1.c end end+f),c)*t1.c then t1.e else t1.b end,11,b) then -(t1.b) else a end)/abs(13)) FROM t1 WHERE NOT (a*t1.a<=17 and exists(select 1 from t1 where (+case coalesce((select max(f) from t1 where d in (select ((+count(*)-( -max(b))))*min(t1.c)* -max(11) from t1 union select count(distinct (19)) from t1)),t1.c) when 13 then 19 else coalesce((select t1.a from t1 where t1.c not in (t1.c,f,13)),b) end)>t1.c) and ( -( -19) between 13 and b or b in (select 11 from t1 union select a from t1) and 19 in (t1.d,t1.d,19)))}
+} {15}
+do_test randexpr-2.332 {
+ db eval {SELECT case when a>=f then -t1.a-11*t1.c when ((t1.e-t1.e+17 between (select max(c) from t1)-13 and coalesce((select t1.d from t1 where ((coalesce((select max(case when (not b>17) then t1.b-b when -e in (c,a,13) then 11 else t1.a end) from t1 where 19<=11),t1.e)>=e))),t1.a))) then c else t1.b end | 17 FROM t1 WHERE 11-t1.d+d-13+(t1.f*case when exists(select 1 from t1 where ( -coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where 19 in (select d from t1 union select t1.f from t1)))),t1.d)<=case when 13*11+11 in (select abs(+~abs( -min(c))) from t1 union select (min(t1.e)) from t1) then t1.f else 19 end)) then t1.c else (abs(e)/abs(19)) end*t1.f*f)<(t1.d)}
+} {}
+do_test randexpr-2.333 {
+ db eval {SELECT case when a>=f then -t1.a-11*t1.c when ((t1.e-t1.e+17 between (select max(c) from t1)-13 and coalesce((select t1.d from t1 where ((coalesce((select max(case when (not b>17) then t1.b-b when -e in (c,a,13) then 11 else t1.a end) from t1 where 19<=11),t1.e)>=e))),t1.a))) then c else t1.b end | 17 FROM t1 WHERE NOT (11-t1.d+d-13+(t1.f*case when exists(select 1 from t1 where ( -coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where 19 in (select d from t1 union select t1.f from t1)))),t1.d)<=case when 13*11+11 in (select abs(+~abs( -min(c))) from t1 union select (min(t1.e)) from t1) then t1.f else 19 end)) then t1.c else (abs(e)/abs(19)) end*t1.f*f)<(t1.d))}
+} {217}
+do_test randexpr-2.334 {
+ db eval {SELECT case when a>=f then -t1.a-11*t1.c when ((t1.e-t1.e+17 between (select max(c) from t1)-13 and coalesce((select t1.d from t1 where ((coalesce((select max(case when (not b>17) then t1.b-b when -e in (c,a,13) then 11 else t1.a end) from t1 where 19<=11),t1.e)>=e))),t1.a))) then c else t1.b end & 17 FROM t1 WHERE NOT (11-t1.d+d-13+(t1.f*case when exists(select 1 from t1 where ( -coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where 19 in (select d from t1 union select t1.f from t1)))),t1.d)<=case when 13*11+11 in (select abs(+~abs( -min(c))) from t1 union select (min(t1.e)) from t1) then t1.f else 19 end)) then t1.c else (abs(e)/abs(19)) end*t1.f*f)<(t1.d))}
+} {0}
+do_test randexpr-2.335 {
+ db eval {SELECT case ~13*c-t1.f- -t1.f when coalesce((select max(coalesce((select max(t1.c) from t1 where coalesce((select t1.d from t1 where 11*f-a=a),t1.e) in (select case ~count(distinct 11) | min(c) when (count(*))-count(*) then max( -17) else (min(13)) end from t1 union select - -cast(avg(b) AS integer) from t1)),19)-t1.c) from t1 where exists(select 1 from t1 where t1.b not between t1.e and 11 and ((a<>t1.f)) and (t1.a)=t1.d)),17) then t1.d else -b end FROM t1 WHERE case when ~13+t1.e-19>=13 then 17 else t1.c end>=a*19 and (f in (select case min(t1.e*+(abs(11)/abs(13))) when count(distinct t1.c) | abs((min(t1.b)-(max(t1.d)))+abs(max(a))+count(*)) | cast(avg(e) AS integer) then max(c) else max(c) end from t1 union select min(t1.c) from t1))}
+} {}
+do_test randexpr-2.336 {
+ db eval {SELECT case ~13*c-t1.f- -t1.f when coalesce((select max(coalesce((select max(t1.c) from t1 where coalesce((select t1.d from t1 where 11*f-a=a),t1.e) in (select case ~count(distinct 11) | min(c) when (count(*))-count(*) then max( -17) else (min(13)) end from t1 union select - -cast(avg(b) AS integer) from t1)),19)-t1.c) from t1 where exists(select 1 from t1 where t1.b not between t1.e and 11 and ((a<>t1.f)) and (t1.a)=t1.d)),17) then t1.d else -b end FROM t1 WHERE NOT (case when ~13+t1.e-19>=13 then 17 else t1.c end>=a*19 and (f in (select case min(t1.e*+(abs(11)/abs(13))) when count(distinct t1.c) | abs((min(t1.b)-(max(t1.d)))+abs(max(a))+count(*)) | cast(avg(e) AS integer) then max(c) else max(c) end from t1 union select min(t1.c) from t1)))}
+} {-200}
+do_test randexpr-2.337 {
+ db eval {SELECT case ~13*c-t1.f- -t1.f when coalesce((select max(coalesce((select max(t1.c) from t1 where coalesce((select t1.d from t1 where 11*f-a=a),t1.e) in (select case ~count(distinct 11) & min(c) when (count(*))-count(*) then max( -17) else (min(13)) end from t1 union select - -cast(avg(b) AS integer) from t1)),19)-t1.c) from t1 where exists(select 1 from t1 where t1.b not between t1.e and 11 and ((a<>t1.f)) and (t1.a)=t1.d)),17) then t1.d else -b end FROM t1 WHERE NOT (case when ~13+t1.e-19>=13 then 17 else t1.c end>=a*19 and (f in (select case min(t1.e*+(abs(11)/abs(13))) when count(distinct t1.c) | abs((min(t1.b)-(max(t1.d)))+abs(max(a))+count(*)) | cast(avg(e) AS integer) then max(c) else max(c) end from t1 union select min(t1.c) from t1)))}
+} {-200}
+do_test randexpr-2.338 {
+ db eval {SELECT f*13-t1.f*(abs(19*t1.a*c-(select ~max(t1.c)- -( -cast(avg(f) AS integer))+(max(d))*cast(avg(t1.d) AS integer)*(count(*)) from t1))/abs(case when coalesce((select (coalesce((select max(t1.c) from t1 where -(b)<> -t1.a),b)+11) from t1 where not (11)<=t1.e and c not between 17 and t1.e and b not in (f,(t1.a),t1.e)),t1.f) in (select t1.d from t1 union select 19 from t1) then t1.a when f>13 then t1.e else a end)) FROM t1 WHERE -b<>b*t1.e}
+} {-484800}
+do_test randexpr-2.339 {
+ db eval {SELECT f*13-t1.f*(abs(19*t1.a*c-(select ~max(t1.c)- -( -cast(avg(f) AS integer))+(max(d))*cast(avg(t1.d) AS integer)*(count(*)) from t1))/abs(case when coalesce((select (coalesce((select max(t1.c) from t1 where -(b)<> -t1.a),b)+11) from t1 where not (11)<=t1.e and c not between 17 and t1.e and b not in (f,(t1.a),t1.e)),t1.f) in (select t1.d from t1 union select 19 from t1) then t1.a when f>13 then t1.e else a end)) FROM t1 WHERE NOT ( -b<>b*t1.e)}
+} {}
+do_test randexpr-2.340 {
+ db eval {SELECT case when coalesce((select c from t1 where (13-(11-t1.e | t1.b) in (select +min(c)*+case +min(t1.e) when min(coalesce((select t1.e*t1.a from t1 where t1.f in (t1.d,11,t1.d) or t1.e>11 or t1.d>=c),17))+max(11)-count(distinct -a) | max(11)+min(t1.c)-max(13) then count(distinct c) else (max(13)) end from t1 union select (( -cast(avg(11) AS integer))) from t1))),d) in (select f from t1 union select t1.a from t1) then 17 else 19 end FROM t1 WHERE not exists(select 1 from t1 where (select +min(case when not (f*e between (select min(~~t1.d) from t1)*(abs(c)/abs(d)) and case when f<t1.b then 19 else e end+t1.b) and not exists(select 1 from t1 where exists(select 1 from t1 where 11 in (select t1.e from t1 union select (a) from t1))) then case when -c>=b then t1.f when not c>=17 then ~t1.b else 11 end else 19 end) from t1)-19 not in (d,t1.a,d))}
+} {}
+do_test randexpr-2.341 {
+ db eval {SELECT case when coalesce((select c from t1 where (13-(11-t1.e | t1.b) in (select +min(c)*+case +min(t1.e) when min(coalesce((select t1.e*t1.a from t1 where t1.f in (t1.d,11,t1.d) or t1.e>11 or t1.d>=c),17))+max(11)-count(distinct -a) | max(11)+min(t1.c)-max(13) then count(distinct c) else (max(13)) end from t1 union select (( -cast(avg(11) AS integer))) from t1))),d) in (select f from t1 union select t1.a from t1) then 17 else 19 end FROM t1 WHERE NOT (not exists(select 1 from t1 where (select +min(case when not (f*e between (select min(~~t1.d) from t1)*(abs(c)/abs(d)) and case when f<t1.b then 19 else e end+t1.b) and not exists(select 1 from t1 where exists(select 1 from t1 where 11 in (select t1.e from t1 union select (a) from t1))) then case when -c>=b then t1.f when not c>=17 then ~t1.b else 11 end else 19 end) from t1)-19 not in (d,t1.a,d)))}
+} {19}
+do_test randexpr-2.342 {
+ db eval {SELECT case when coalesce((select c from t1 where (13-(11-t1.e & t1.b) in (select +min(c)*+case +min(t1.e) when min(coalesce((select t1.e*t1.a from t1 where t1.f in (t1.d,11,t1.d) or t1.e>11 or t1.d>=c),17))+max(11)-count(distinct -a) & max(11)+min(t1.c)-max(13) then count(distinct c) else (max(13)) end from t1 union select (( -cast(avg(11) AS integer))) from t1))),d) in (select f from t1 union select t1.a from t1) then 17 else 19 end FROM t1 WHERE NOT (not exists(select 1 from t1 where (select +min(case when not (f*e between (select min(~~t1.d) from t1)*(abs(c)/abs(d)) and case when f<t1.b then 19 else e end+t1.b) and not exists(select 1 from t1 where exists(select 1 from t1 where 11 in (select t1.e from t1 union select (a) from t1))) then case when -c>=b then t1.f when not c>=17 then ~t1.b else 11 end else 19 end) from t1)-19 not in (d,t1.a,d)))}
+} {19}
+do_test randexpr-2.343 {
+ db eval {SELECT t1.c*a+(case when t1.b+11 | case when exists(select 1 from t1 where b<>17 or not exists(select 1 from t1 where t1.f in (19,t1.f,c)) or (t1.d)<>b) then e else d end+t1.b+t1.a*b=t1.d or d=b then t1.e when not exists(select 1 from t1 where b>t1.c or 17 between t1.f and e and d>=t1.c) then t1.d else c end) FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where (abs(c)/abs(b)) in (t1.a, -e*~e*17,17)))}
+} {30400}
+do_test randexpr-2.344 {
+ db eval {SELECT t1.c*a+(case when t1.b+11 | case when exists(select 1 from t1 where b<>17 or not exists(select 1 from t1 where t1.f in (19,t1.f,c)) or (t1.d)<>b) then e else d end+t1.b+t1.a*b=t1.d or d=b then t1.e when not exists(select 1 from t1 where b>t1.c or 17 between t1.f and e and d>=t1.c) then t1.d else c end) FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(c)/abs(b)) in (t1.a, -e*~e*17,17))))}
+} {}
+do_test randexpr-2.345 {
+ db eval {SELECT t1.c*a+(case when t1.b+11 & case when exists(select 1 from t1 where b<>17 or not exists(select 1 from t1 where t1.f in (19,t1.f,c)) or (t1.d)<>b) then e else d end+t1.b+t1.a*b=t1.d or d=b then t1.e when not exists(select 1 from t1 where b>t1.c or 17 between t1.f and e and d>=t1.c) then t1.d else c end) FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where (abs(c)/abs(b)) in (t1.a, -e*~e*17,17)))}
+} {30400}
+do_test randexpr-2.346 {
+ db eval {SELECT coalesce((select -b from t1 where t1.f=d),case when case -17-t1.b*t1.d+d when b then t1.a else t1.e end not in (t1.c,13,19) and e>f and 13 not between 17 and -f and e not between d and a then 13 when c<=a then 13 else 19 | e end)*a-d*t1.e FROM t1 WHERE (abs(+t1.f)/abs(coalesce((select max(coalesce((select max(e) from t1 where t1.a in (select (abs( -t1.b)/abs(a)) from t1 union select e from t1)),(abs(case t1.f when c then (select (~cast(avg(b*d) AS integer))*abs(min(11)) from t1) else coalesce((select f from t1 where d in (select ( -min(e)) from t1 union select -count(*) from t1)),t1.c) end*t1.b)/abs(c))+17)) from t1 where exists(select 1 from t1 where d not between t1.f and t1.b)),(t1.c))))*t1.d between t1.f and t1.a}
+} {}
+do_test randexpr-2.347 {
+ db eval {SELECT coalesce((select -b from t1 where t1.f=d),case when case -17-t1.b*t1.d+d when b then t1.a else t1.e end not in (t1.c,13,19) and e>f and 13 not between 17 and -f and e not between d and a then 13 when c<=a then 13 else 19 | e end)*a-d*t1.e FROM t1 WHERE NOT ((abs(+t1.f)/abs(coalesce((select max(coalesce((select max(e) from t1 where t1.a in (select (abs( -t1.b)/abs(a)) from t1 union select e from t1)),(abs(case t1.f when c then (select (~cast(avg(b*d) AS integer))*abs(min(11)) from t1) else coalesce((select f from t1 where d in (select ( -min(e)) from t1 union select -count(*) from t1)),t1.c) end*t1.b)/abs(c))+17)) from t1 where exists(select 1 from t1 where d not between t1.f and t1.b)),(t1.c))))*t1.d between t1.f and t1.a)}
+} {-149700}
+do_test randexpr-2.348 {
+ db eval {SELECT coalesce((select -b from t1 where t1.f=d),case when case -17-t1.b*t1.d+d when b then t1.a else t1.e end not in (t1.c,13,19) and e>f and 13 not between 17 and -f and e not between d and a then 13 when c<=a then 13 else 19 & e end)*a-d*t1.e FROM t1 WHERE NOT ((abs(+t1.f)/abs(coalesce((select max(coalesce((select max(e) from t1 where t1.a in (select (abs( -t1.b)/abs(a)) from t1 union select e from t1)),(abs(case t1.f when c then (select (~cast(avg(b*d) AS integer))*abs(min(11)) from t1) else coalesce((select f from t1 where d in (select ( -min(e)) from t1 union select -count(*) from t1)),t1.c) end*t1.b)/abs(c))+17)) from t1 where exists(select 1 from t1 where d not between t1.f and t1.b)),(t1.c))))*t1.d between t1.f and t1.a)}
+} {-198400}
+do_test randexpr-2.349 {
+ db eval {SELECT coalesce((select t1.b*19 from t1 where ~f in (select 19 from t1 union select ~b-+case 13 when coalesce((select max(a) from t1 where (abs(d)/abs(t1.d)) | t1.e-c-t1.d-t1.c+11*f-c+t1.a>17), -a) then f else t1.d end+17 | a*f | t1.c-d from t1)),19) FROM t1 WHERE t1.e*t1.c>coalesce((select 13 from t1 where ~t1.a<>case when exists(select 1 from t1 where e<>~d and not +17 not between a+case 13 when d then case t1.d when t1.a then b else 13 end else 13 end and 13) or 13 not in (t1.e,t1.f,t1.c) then 19-e+19 when f<=t1.f then b else 11 end),e)-13}
+} {19}
+do_test randexpr-2.350 {
+ db eval {SELECT coalesce((select t1.b*19 from t1 where ~f in (select 19 from t1 union select ~b-+case 13 when coalesce((select max(a) from t1 where (abs(d)/abs(t1.d)) | t1.e-c-t1.d-t1.c+11*f-c+t1.a>17), -a) then f else t1.d end+17 | a*f | t1.c-d from t1)),19) FROM t1 WHERE NOT (t1.e*t1.c>coalesce((select 13 from t1 where ~t1.a<>case when exists(select 1 from t1 where e<>~d and not +17 not between a+case 13 when d then case t1.d when t1.a then b else 13 end else 13 end and 13) or 13 not in (t1.e,t1.f,t1.c) then 19-e+19 when f<=t1.f then b else 11 end),e)-13)}
+} {}
+do_test randexpr-2.351 {
+ db eval {SELECT coalesce((select t1.b*19 from t1 where ~f in (select 19 from t1 union select ~b-+case 13 when coalesce((select max(a) from t1 where (abs(d)/abs(t1.d)) & t1.e-c-t1.d-t1.c+11*f-c+t1.a>17), -a) then f else t1.d end+17 & a*f & t1.c-d from t1)),19) FROM t1 WHERE t1.e*t1.c>coalesce((select 13 from t1 where ~t1.a<>case when exists(select 1 from t1 where e<>~d and not +17 not between a+case 13 when d then case t1.d when t1.a then b else 13 end else 13 end and 13) or 13 not in (t1.e,t1.f,t1.c) then 19-e+19 when f<=t1.f then b else 11 end),e)-13}
+} {19}
+do_test randexpr-2.352 {
+ db eval {SELECT (abs( -coalesce((select max((t1.f)) from t1 where not exists(select 1 from t1 where -b-~b not between t1.c and f and t1.d*( -(select abs(+count(*)) from t1))-d>=a) and case when +case when ((f)) in (select -count(distinct t1.a) from t1 union select count(*) from t1) then t1.b else d end in (select min(17) from t1 union select min(t1.e) from t1) then d else 17 end+c not between 11 and a),f)*11)/abs(a)) FROM t1 WHERE t1.f*t1.a*(+c)+case case when t1.d=f and (t1.a<>~+a*a*e*t1.e+case when t1.c between 11 and b and t1.a<>e then 13 when ( -t1.e)<>(t1.a) then (t1.b) else 13 end-t1.b-e+f) then t1.f+a else 17 end when d then 17 else d end-t1.e not in (13,t1.a,11)}
+} {66}
+do_test randexpr-2.353 {
+ db eval {SELECT (abs( -coalesce((select max((t1.f)) from t1 where not exists(select 1 from t1 where -b-~b not between t1.c and f and t1.d*( -(select abs(+count(*)) from t1))-d>=a) and case when +case when ((f)) in (select -count(distinct t1.a) from t1 union select count(*) from t1) then t1.b else d end in (select min(17) from t1 union select min(t1.e) from t1) then d else 17 end+c not between 11 and a),f)*11)/abs(a)) FROM t1 WHERE NOT (t1.f*t1.a*(+c)+case case when t1.d=f and (t1.a<>~+a*a*e*t1.e+case when t1.c between 11 and b and t1.a<>e then 13 when ( -t1.e)<>(t1.a) then (t1.b) else 13 end-t1.b-e+f) then t1.f+a else 17 end when d then 17 else d end-t1.e not in (13,t1.a,11))}
+} {}
+do_test randexpr-2.354 {
+ db eval {SELECT case t1.b- -t1.d+t1.d+t1.f when t1.f then 19+~13 else d end-case when not exists(select 1 from t1 where (f not between coalesce((select b from t1 where d in (17,13,t1.a) and 13 between c and 13 and 19>=f),13) and e or d not between 13 and f) or f>=d) then t1.f else coalesce((select max(~e-11) from t1 where t1.b in (f,13,13)),t1.a) end FROM t1 WHERE a<e}
+} {300}
+do_test randexpr-2.355 {
+ db eval {SELECT case t1.b- -t1.d+t1.d+t1.f when t1.f then 19+~13 else d end-case when not exists(select 1 from t1 where (f not between coalesce((select b from t1 where d in (17,13,t1.a) and 13 between c and 13 and 19>=f),13) and e or d not between 13 and f) or f>=d) then t1.f else coalesce((select max(~e-11) from t1 where t1.b in (f,13,13)),t1.a) end FROM t1 WHERE NOT (a<e)}
+} {}
+do_test randexpr-2.356 {
+ db eval {SELECT -coalesce((select max(13) from t1 where case case when f in (select e from t1 union select coalesce((select max(e) from t1 where (select -max(e) from t1)*t1.e<e and exists(select 1 from t1 where -c in (a,a,a))),t1.d) from t1) and e>=t1.c and exists(select 1 from t1 where t1.f>=13) then t1.d when d between t1.d and t1.a then 19 else a end | e when (a) then e else a end between b and t1.c and not exists(select 1 from t1 where 13 in (t1.d,t1.a,13)) or t1.a>= -13),c) FROM t1 WHERE t1.e not in ( -coalesce((select max(13) from t1 where exists(select 1 from t1 where not t1.d>a) and t1.a not in (d*+case when t1.b in (select max(e*11+t1.a)+ -count(*)-( -max(t1.e))-min(11)-count(distinct t1.a) from t1 union select - -min(t1.b) from t1) then t1.e when e in (select count(distinct t1.a) from t1 union select (max(d)) from t1) then e else -(19) end+ -t1.d, -17,f)),case c when a then f else 17 end),d,11)}
+} {-13}
+do_test randexpr-2.357 {
+ db eval {SELECT -coalesce((select max(13) from t1 where case case when f in (select e from t1 union select coalesce((select max(e) from t1 where (select -max(e) from t1)*t1.e<e and exists(select 1 from t1 where -c in (a,a,a))),t1.d) from t1) and e>=t1.c and exists(select 1 from t1 where t1.f>=13) then t1.d when d between t1.d and t1.a then 19 else a end | e when (a) then e else a end between b and t1.c and not exists(select 1 from t1 where 13 in (t1.d,t1.a,13)) or t1.a>= -13),c) FROM t1 WHERE NOT (t1.e not in ( -coalesce((select max(13) from t1 where exists(select 1 from t1 where not t1.d>a) and t1.a not in (d*+case when t1.b in (select max(e*11+t1.a)+ -count(*)-( -max(t1.e))-min(11)-count(distinct t1.a) from t1 union select - -min(t1.b) from t1) then t1.e when e in (select count(distinct t1.a) from t1 union select (max(d)) from t1) then e else -(19) end+ -t1.d, -17,f)),case c when a then f else 17 end),d,11))}
+} {}
+do_test randexpr-2.358 {
+ db eval {SELECT -coalesce((select max(13) from t1 where case case when f in (select e from t1 union select coalesce((select max(e) from t1 where (select -max(e) from t1)*t1.e<e and exists(select 1 from t1 where -c in (a,a,a))),t1.d) from t1) and e>=t1.c and exists(select 1 from t1 where t1.f>=13) then t1.d when d between t1.d and t1.a then 19 else a end & e when (a) then e else a end between b and t1.c and not exists(select 1 from t1 where 13 in (t1.d,t1.a,13)) or t1.a>= -13),c) FROM t1 WHERE t1.e not in ( -coalesce((select max(13) from t1 where exists(select 1 from t1 where not t1.d>a) and t1.a not in (d*+case when t1.b in (select max(e*11+t1.a)+ -count(*)-( -max(t1.e))-min(11)-count(distinct t1.a) from t1 union select - -min(t1.b) from t1) then t1.e when e in (select count(distinct t1.a) from t1 union select (max(d)) from t1) then e else -(19) end+ -t1.d, -17,f)),case c when a then f else 17 end),d,11)}
+} {-13}
+do_test randexpr-2.359 {
+ db eval {SELECT case d when -e+coalesce((select max(case (select +abs((~case case count(distinct b) when -count(*) then count(*) else max(t1.e) end when max(e) then min(t1.c) else count(*) end-min(c))) from t1) when t1.c then t1.a else -11 end) from t1 where case ~t1.b when e then d else 11 end in (b,t1.e,t1.b) or not t1.f>=b or (t1.f in (a,e,t1.e)) or f<b),t1.e) then t1.b else f end FROM t1 WHERE b<=(d) and (abs(coalesce((select max(coalesce((select case when (abs(~11)/abs(((abs(17+f+t1.f)/abs(t1.c))-11*c)-d*17)) not in (b,13,((e))) then 19 else 19 end from t1 where a in (select t1.b from t1 union select t1.b from t1)),13)) from t1 where t1.d in (select a from t1 union select 13 from t1)), -e)+17*c)/abs(t1.c))=13}
+} {}
+do_test randexpr-2.360 {
+ db eval {SELECT case d when -e+coalesce((select max(case (select +abs((~case case count(distinct b) when -count(*) then count(*) else max(t1.e) end when max(e) then min(t1.c) else count(*) end-min(c))) from t1) when t1.c then t1.a else -11 end) from t1 where case ~t1.b when e then d else 11 end in (b,t1.e,t1.b) or not t1.f>=b or (t1.f in (a,e,t1.e)) or f<b),t1.e) then t1.b else f end FROM t1 WHERE NOT (b<=(d) and (abs(coalesce((select max(coalesce((select case when (abs(~11)/abs(((abs(17+f+t1.f)/abs(t1.c))-11*c)-d*17)) not in (b,13,((e))) then 19 else 19 end from t1 where a in (select t1.b from t1 union select t1.b from t1)),13)) from t1 where t1.d in (select a from t1 union select 13 from t1)), -e)+17*c)/abs(t1.c))=13)}
+} {600}
+do_test randexpr-2.361 {
+ db eval {SELECT case a when ~c then e+17-d else case t1.a when c then t1.b else case when ((case t1.e when c then d-11 else t1.f end not in (e,(17),t1.d))) or not exists(select 1 from t1 where e not in (d,t1.f,11) and -t1.a>t1.b) or t1.a not in (f,t1.b,t1.e) or t1.d<=t1.b and 19 not in (t1.d,11,t1.f) then t1.d else 19 end+e+17 end | -t1.c*d end-13 FROM t1 WHERE e not in (e,t1.b,t1.d)}
+} {}
+do_test randexpr-2.362 {
+ db eval {SELECT case a when ~c then e+17-d else case t1.a when c then t1.b else case when ((case t1.e when c then d-11 else t1.f end not in (e,(17),t1.d))) or not exists(select 1 from t1 where e not in (d,t1.f,11) and -t1.a>t1.b) or t1.a not in (f,t1.b,t1.e) or t1.d<=t1.b and 19 not in (t1.d,11,t1.f) then t1.d else 19 end+e+17 end | -t1.c*d end-13 FROM t1 WHERE NOT (e not in (e,t1.b,t1.d))}
+} {-119864}
+do_test randexpr-2.363 {
+ db eval {SELECT case a when ~c then e+17-d else case t1.a when c then t1.b else case when ((case t1.e when c then d-11 else t1.f end not in (e,(17),t1.d))) or not exists(select 1 from t1 where e not in (d,t1.f,11) and -t1.a>t1.b) or t1.a not in (f,t1.b,t1.e) or t1.d<=t1.b and 19 not in (t1.d,11,t1.f) then t1.d else 19 end+e+17 end & -t1.c*d end-13 FROM t1 WHERE NOT (e not in (e,t1.b,t1.d))}
+} {755}
+do_test randexpr-2.364 {
+ db eval {SELECT coalesce((select max(case t1.a when d then ~11 else t1.e end) from t1 where (t1.f*17<t1.d-(t1.a*t1.a+t1.b+case case d when coalesce((select max(19) from t1 where -(t1.e) in (select count(distinct c) from t1 union select (count(distinct t1.f)) from t1)),13) then c else 19 end*d when c then 13 else 17 end+t1.c)) and (f>=a or t1.e=t1.a and -c>=t1.b)),t1.b) FROM t1 WHERE a+( -t1.c) between case when case a when t1.f then ~t1.b*t1.c+17 else -case when f not in (e,f,17) then a when 11=13 then t1.c else t1.d end end>=t1.b then b when t1.d in (select +max(19) from t1 union select abs(cast(avg(t1.f) AS integer))+case ~count(*)-max(t1.a)+max(11) when (max(a)) then (max(t1.d)) else count(distinct 11) end from t1) and e in (t1.d,17,11) then (11) else b end and a}
+} {}
+do_test randexpr-2.365 {
+ db eval {SELECT coalesce((select max(case t1.a when d then ~11 else t1.e end) from t1 where (t1.f*17<t1.d-(t1.a*t1.a+t1.b+case case d when coalesce((select max(19) from t1 where -(t1.e) in (select count(distinct c) from t1 union select (count(distinct t1.f)) from t1)),13) then c else 19 end*d when c then 13 else 17 end+t1.c)) and (f>=a or t1.e=t1.a and -c>=t1.b)),t1.b) FROM t1 WHERE NOT (a+( -t1.c) between case when case a when t1.f then ~t1.b*t1.c+17 else -case when f not in (e,f,17) then a when 11=13 then t1.c else t1.d end end>=t1.b then b when t1.d in (select +max(19) from t1 union select abs(cast(avg(t1.f) AS integer))+case ~count(*)-max(t1.a)+max(11) when (max(a)) then (max(t1.d)) else count(distinct 11) end from t1) and e in (t1.d,17,11) then (11) else b end and a)}
+} {200}
+do_test randexpr-2.366 {
+ db eval {SELECT t1.f+case when c*f | (t1.a) in (select b*f from t1 union select -case when d not between ~13 | 13+case a when a then e else a end and f then 11 else e-t1.d end from t1) then -(abs(case when ((case t1.f when t1.b then t1.f else a end*f+t1.c)) in (select d from t1 union select (t1.e) from t1) then d else (t1.f) end)/abs(b)) else t1.a end FROM t1 WHERE ~(f+17-(select +max(t1.f)-case count(distinct d-19) when ~count(distinct (abs(b)/abs(a))) then cast(avg(17) AS integer) else ~count(distinct e)*count(*) end from t1)-f-coalesce((select t1.f from t1 where t1.a>=t1.c or t1.b between -t1.a and 19 or exists(select 1 from t1 where t1.e not in (13,t1.c,e)) and d>a),t1.d)) not between d and c}
+} {700}
+do_test randexpr-2.367 {
+ db eval {SELECT t1.f+case when c*f | (t1.a) in (select b*f from t1 union select -case when d not between ~13 | 13+case a when a then e else a end and f then 11 else e-t1.d end from t1) then -(abs(case when ((case t1.f when t1.b then t1.f else a end*f+t1.c)) in (select d from t1 union select (t1.e) from t1) then d else (t1.f) end)/abs(b)) else t1.a end FROM t1 WHERE NOT (~(f+17-(select +max(t1.f)-case count(distinct d-19) when ~count(distinct (abs(b)/abs(a))) then cast(avg(17) AS integer) else ~count(distinct e)*count(*) end from t1)-f-coalesce((select t1.f from t1 where t1.a>=t1.c or t1.b between -t1.a and 19 or exists(select 1 from t1 where t1.e not in (13,t1.c,e)) and d>a),t1.d)) not between d and c)}
+} {}
+do_test randexpr-2.368 {
+ db eval {SELECT t1.f+case when c*f & (t1.a) in (select b*f from t1 union select -case when d not between ~13 & 13+case a when a then e else a end and f then 11 else e-t1.d end from t1) then -(abs(case when ((case t1.f when t1.b then t1.f else a end*f+t1.c)) in (select d from t1 union select (t1.e) from t1) then d else (t1.f) end)/abs(b)) else t1.a end FROM t1 WHERE ~(f+17-(select +max(t1.f)-case count(distinct d-19) when ~count(distinct (abs(b)/abs(a))) then cast(avg(17) AS integer) else ~count(distinct e)*count(*) end from t1)-f-coalesce((select t1.f from t1 where t1.a>=t1.c or t1.b between -t1.a and 19 or exists(select 1 from t1 where t1.e not in (13,t1.c,e)) and d>a),t1.d)) not between d and c}
+} {700}
+do_test randexpr-2.369 {
+ db eval {SELECT case when coalesce((select d from t1 where not coalesce((select f*t1.b from t1 where exists(select 1 from t1 where (t1.f*t1.a)-19-13 in (select ~(cast(avg(t1.b) AS integer)) from t1 union select min(t1.a)+case min( -t1.a) when cast(avg(19) AS integer) then cast(avg(19) AS integer) else min(13) end+( -min(a)) from t1))),(t1.f)) between 17 and d),11)=19 then t1.b when 17<11 or exists(select 1 from t1 where d in (select 13 from t1 union select f from t1)) then 11 else t1.c end FROM t1 WHERE case c when 13 then +t1.d else t1.a end in (select abs(case + -count(*)+count(distinct coalesce((select (abs(~case when t1.c=19 | 13 then t1.c when not e>(13) then f else d end)/abs(a)) from t1 where 17>=t1.b),t1.b))+min(t1.a)*count(*) | (((max(a)))-cast(avg((17)) AS integer)) when max(d) then count(*) else cast(avg(t1.e) AS integer) end) from t1 union select count(*) from t1)}
+} {}
+do_test randexpr-2.370 {
+ db eval {SELECT case when coalesce((select d from t1 where not coalesce((select f*t1.b from t1 where exists(select 1 from t1 where (t1.f*t1.a)-19-13 in (select ~(cast(avg(t1.b) AS integer)) from t1 union select min(t1.a)+case min( -t1.a) when cast(avg(19) AS integer) then cast(avg(19) AS integer) else min(13) end+( -min(a)) from t1))),(t1.f)) between 17 and d),11)=19 then t1.b when 17<11 or exists(select 1 from t1 where d in (select 13 from t1 union select f from t1)) then 11 else t1.c end FROM t1 WHERE NOT (case c when 13 then +t1.d else t1.a end in (select abs(case + -count(*)+count(distinct coalesce((select (abs(~case when t1.c=19 | 13 then t1.c when not e>(13) then f else d end)/abs(a)) from t1 where 17>=t1.b),t1.b))+min(t1.a)*count(*) | (((max(a)))-cast(avg((17)) AS integer)) when max(d) then count(*) else cast(avg(t1.e) AS integer) end) from t1 union select count(*) from t1))}
+} {300}
+do_test randexpr-2.371 {
+ db eval {SELECT -(select count(*) from t1)*(select (+(cast(avg(+f) AS integer))+++case +max(t1.b-case when t1.e+t1.e>=11 then -a else t1.e end)-abs(min(e)+ -max(c) | ((max(11)))) when max(11) then (min(b)) else cast(avg( -b) AS integer) end-cast(avg(b) AS integer)-count(*)+count(*)) from t1)+~17- -t1.a FROM t1 WHERE f between 19*t1.d and 19}
+} {}
+do_test randexpr-2.372 {
+ db eval {SELECT -(select count(*) from t1)*(select (+(cast(avg(+f) AS integer))+++case +max(t1.b-case when t1.e+t1.e>=11 then -a else t1.e end)-abs(min(e)+ -max(c) | ((max(11)))) when max(11) then (min(b)) else cast(avg( -b) AS integer) end-cast(avg(b) AS integer)-count(*)+count(*)) from t1)+~17- -t1.a FROM t1 WHERE NOT (f between 19*t1.d and 19)}
+} {-118}
+do_test randexpr-2.373 {
+ db eval {SELECT -(select count(*) from t1)*(select (+(cast(avg(+f) AS integer))+++case +max(t1.b-case when t1.e+t1.e>=11 then -a else t1.e end)-abs(min(e)+ -max(c) & ((max(11)))) when max(11) then (min(b)) else cast(avg( -b) AS integer) end-cast(avg(b) AS integer)-count(*)+count(*)) from t1)+~17- -t1.a FROM t1 WHERE NOT (f between 19*t1.d and 19)}
+} {-118}
+do_test randexpr-2.374 {
+ db eval {SELECT case when not t1.a< -~~e then b when c*(select +case max((abs( -a)/abs(a))) when min(t1.b) then case ~min(t1.d)-cast(avg(e) AS integer) | max(e) when count(distinct 11) then count(*) else max(b) end else count(*) end from t1) not between 13 and case when exists(select 1 from t1 where exists(select 1 from t1 where f not in (19,t1.f,19)) and 11 between t1.b and t1.b) then (13) else -t1.d end then f else e end FROM t1 WHERE d>11}
+} {200}
+do_test randexpr-2.375 {
+ db eval {SELECT case when not t1.a< -~~e then b when c*(select +case max((abs( -a)/abs(a))) when min(t1.b) then case ~min(t1.d)-cast(avg(e) AS integer) | max(e) when count(distinct 11) then count(*) else max(b) end else count(*) end from t1) not between 13 and case when exists(select 1 from t1 where exists(select 1 from t1 where f not in (19,t1.f,19)) and 11 between t1.b and t1.b) then (13) else -t1.d end then f else e end FROM t1 WHERE NOT (d>11)}
+} {}
+do_test randexpr-2.376 {
+ db eval {SELECT case when not t1.a< -~~e then b when c*(select +case max((abs( -a)/abs(a))) when min(t1.b) then case ~min(t1.d)-cast(avg(e) AS integer) & max(e) when count(distinct 11) then count(*) else max(b) end else count(*) end from t1) not between 13 and case when exists(select 1 from t1 where exists(select 1 from t1 where f not in (19,t1.f,19)) and 11 between t1.b and t1.b) then (13) else -t1.d end then f else e end FROM t1 WHERE d>11}
+} {200}
+do_test randexpr-2.377 {
+ db eval {SELECT coalesce((select max(t1.c | ~17) from t1 where exists(select 1 from t1 where t1.f<>b-(abs(13)/abs(e)))),13) FROM t1 WHERE case when case (abs(c+a+19+coalesce((select max(t1.a) from t1 where coalesce((select coalesce((select (f) from t1 where t1.d between 19 and b),t1.a) from t1 where 13=(c)),f) in (select ~case count(*) when max(t1.b) then ((count(distinct 11))) else count(*) end- -count(distinct a) from t1 union select count(distinct 13) from t1)),t1.c) | t1.b+t1.d)/abs(e)) when t1.d then a else 17 end not between 19 and t1.f then t1.b else d end in (select t1.c from t1 union select (t1.a) from t1)}
+} {}
+do_test randexpr-2.378 {
+ db eval {SELECT coalesce((select max(t1.c | ~17) from t1 where exists(select 1 from t1 where t1.f<>b-(abs(13)/abs(e)))),13) FROM t1 WHERE NOT (case when case (abs(c+a+19+coalesce((select max(t1.a) from t1 where coalesce((select coalesce((select (f) from t1 where t1.d between 19 and b),t1.a) from t1 where 13=(c)),f) in (select ~case count(*) when max(t1.b) then ((count(distinct 11))) else count(*) end- -count(distinct a) from t1 union select count(distinct 13) from t1)),t1.c) | t1.b+t1.d)/abs(e)) when t1.d then a else 17 end not between 19 and t1.f then t1.b else d end in (select t1.c from t1 union select (t1.a) from t1))}
+} {-18}
+do_test randexpr-2.379 {
+ db eval {SELECT coalesce((select max(t1.c & ~17) from t1 where exists(select 1 from t1 where t1.f<>b-(abs(13)/abs(e)))),13) FROM t1 WHERE NOT (case when case (abs(c+a+19+coalesce((select max(t1.a) from t1 where coalesce((select coalesce((select (f) from t1 where t1.d between 19 and b),t1.a) from t1 where 13=(c)),f) in (select ~case count(*) when max(t1.b) then ((count(distinct 11))) else count(*) end- -count(distinct a) from t1 union select count(distinct 13) from t1)),t1.c) | t1.b+t1.d)/abs(e)) when t1.d then a else 17 end not between 19 and t1.f then t1.b else d end in (select t1.c from t1 union select (t1.a) from t1))}
+} {300}
+do_test randexpr-2.380 {
+ db eval {SELECT (coalesce((select (coalesce((select d from t1 where not exists(select 1 from t1 where 17>t1.c)),d))*c from t1 where t1.b between t1.d | (select count(distinct coalesce((select max(t1.e) from t1 where case when -e>t1.b then f when t1.a<t1.f then t1.e else t1.d end<=c),(19))) from t1) and b or 13 in (t1.d,t1.d,t1.d)),t1.b)-b*f)+11-t1.e FROM t1 WHERE d<case when d>(abs(19*case when coalesce((select b*case when 11 not between 19 and (abs(13)/abs(t1.b-t1.d-e+b-f+19*t1.a)) then -t1.a else f end from t1 where (b=17)),f)= -t1.d then 17 when 11<>19 then f else t1.d end)/abs(t1.b)) then d else 19 end}
+} {}
+do_test randexpr-2.381 {
+ db eval {SELECT (coalesce((select (coalesce((select d from t1 where not exists(select 1 from t1 where 17>t1.c)),d))*c from t1 where t1.b between t1.d | (select count(distinct coalesce((select max(t1.e) from t1 where case when -e>t1.b then f when t1.a<t1.f then t1.e else t1.d end<=c),(19))) from t1) and b or 13 in (t1.d,t1.d,t1.d)),t1.b)-b*f)+11-t1.e FROM t1 WHERE NOT (d<case when d>(abs(19*case when coalesce((select b*case when 11 not between 19 and (abs(13)/abs(t1.b-t1.d-e+b-f+19*t1.a)) then -t1.a else f end from t1 where (b=17)),f)= -t1.d then 17 when 11<>19 then f else t1.d end)/abs(t1.b)) then d else 19 end)}
+} {-120289}
+do_test randexpr-2.382 {
+ db eval {SELECT (coalesce((select (coalesce((select d from t1 where not exists(select 1 from t1 where 17>t1.c)),d))*c from t1 where t1.b between t1.d & (select count(distinct coalesce((select max(t1.e) from t1 where case when -e>t1.b then f when t1.a<t1.f then t1.e else t1.d end<=c),(19))) from t1) and b or 13 in (t1.d,t1.d,t1.d)),t1.b)-b*f)+11-t1.e FROM t1 WHERE NOT (d<case when d>(abs(19*case when coalesce((select b*case when 11 not between 19 and (abs(13)/abs(t1.b-t1.d-e+b-f+19*t1.a)) then -t1.a else f end from t1 where (b=17)),f)= -t1.d then 17 when 11<>19 then f else t1.d end)/abs(t1.b)) then d else 19 end)}
+} {-489}
+do_test randexpr-2.383 {
+ db eval {SELECT 19*case when coalesce((select max(t1.e-c) from t1 where f=(abs(coalesce((select t1.c from t1 where not (not exists(select 1 from t1 where a in (select b from t1 union select c from t1)))),13))/abs(coalesce((select 13 from t1 where t1.b in (d,t1.d,a)), -t1.b)))),c) in (select ~min(t1.c) from t1 union select count(*) from t1) and -f<>t1.c then t1.a-t1.e when not t1.a in (select cast(avg(a) AS integer) from t1 union select min(13) from t1) then -19 else f end FROM t1 WHERE 11<>13}
+} {11400}
+do_test randexpr-2.384 {
+ db eval {SELECT 19*case when coalesce((select max(t1.e-c) from t1 where f=(abs(coalesce((select t1.c from t1 where not (not exists(select 1 from t1 where a in (select b from t1 union select c from t1)))),13))/abs(coalesce((select 13 from t1 where t1.b in (d,t1.d,a)), -t1.b)))),c) in (select ~min(t1.c) from t1 union select count(*) from t1) and -f<>t1.c then t1.a-t1.e when not t1.a in (select cast(avg(a) AS integer) from t1 union select min(13) from t1) then -19 else f end FROM t1 WHERE NOT (11<>13)}
+} {}
+do_test randexpr-2.385 {
+ db eval {SELECT t1.b*(select max(t1.b*coalesce((select max(t1.f*(t1.b)) from t1 where 17 not in (d,(a),(t1.b)+13)),t1.c)-t1.a) | cast(avg(t1.d) AS integer) | ~+case abs(abs(count(distinct t1.b))) when ~count(distinct e)-(count(*)) then max(t1.e) else max(d) end | max((19)) | min(19) from t1)-t1.d-t1.d*17 FROM t1 WHERE t1.f-case t1.d+19+13*case when (abs(e)/abs((select count(*)+cast(avg(a) AS integer)*count(*) from t1)-c*(abs(d)/abs(c*t1.e-19)))) not in (17,17,t1.a) then t1.f when t1.d<>t1.f then b else d end+ - -f*t1.b*d when b then 11 else -13 end<=(t1.b)}
+} {}
+do_test randexpr-2.386 {
+ db eval {SELECT t1.b*(select max(t1.b*coalesce((select max(t1.f*(t1.b)) from t1 where 17 not in (d,(a),(t1.b)+13)),t1.c)-t1.a) | cast(avg(t1.d) AS integer) | ~+case abs(abs(count(distinct t1.b))) when ~count(distinct e)-(count(*)) then max(t1.e) else max(d) end | max((19)) | min(19) from t1)-t1.d-t1.d*17 FROM t1 WHERE NOT (t1.f-case t1.d+19+13*case when (abs(e)/abs((select count(*)+cast(avg(a) AS integer)*count(*) from t1)-c*(abs(d)/abs(c*t1.e-19)))) not in (17,17,t1.a) then t1.f when t1.d<>t1.f then b else d end+ - -f*t1.b*d when b then 11 else -13 end<=(t1.b))}
+} {-7400}
+do_test randexpr-2.387 {
+ db eval {SELECT t1.b*(select max(t1.b*coalesce((select max(t1.f*(t1.b)) from t1 where 17 not in (d,(a),(t1.b)+13)),t1.c)-t1.a) & cast(avg(t1.d) AS integer) & ~+case abs(abs(count(distinct t1.b))) when ~count(distinct e)-(count(*)) then max(t1.e) else max(d) end & max((19)) & min(19) from t1)-t1.d-t1.d*17 FROM t1 WHERE NOT (t1.f-case t1.d+19+13*case when (abs(e)/abs((select count(*)+cast(avg(a) AS integer)*count(*) from t1)-c*(abs(d)/abs(c*t1.e-19)))) not in (17,17,t1.a) then t1.f when t1.d<>t1.f then b else d end+ - -f*t1.b*d when b then 11 else -13 end<=(t1.b))}
+} {-7200}
+do_test randexpr-2.388 {
+ db eval {SELECT (select abs(count(distinct t1.e) | min(b))-cast(avg(c) AS integer) | case +~+max(t1.a)*abs(+~ - -+cast(avg(19*f) AS integer) | count(*) | ~max(b) | ((max(t1.e)))-count(distinct t1.d)+ -(count(distinct t1.c)))* -count(distinct 17) | count(distinct a) when ((count(distinct t1.d))) then -min(t1.c) else count(distinct t1.c) end- -min(d) from t1) FROM t1 WHERE ((not exists(select 1 from t1 where c=f)) and case when not 19+t1.c- -11+11+e>=a or t1.d>b then f else t1.e end<> -t1.c) or (t1.a in (select +count(*) from t1 union select abs((case max(d) when count(distinct d) then min( -t1.e) else count(distinct a) end-count(distinct -t1.f)))*count(*) from t1) or not exists(select 1 from t1 where t1.d not in (c,17,e)))}
+} {-99}
+do_test randexpr-2.389 {
+ db eval {SELECT (select abs(count(distinct t1.e) | min(b))-cast(avg(c) AS integer) | case +~+max(t1.a)*abs(+~ - -+cast(avg(19*f) AS integer) | count(*) | ~max(b) | ((max(t1.e)))-count(distinct t1.d)+ -(count(distinct t1.c)))* -count(distinct 17) | count(distinct a) when ((count(distinct t1.d))) then -min(t1.c) else count(distinct t1.c) end- -min(d) from t1) FROM t1 WHERE NOT (((not exists(select 1 from t1 where c=f)) and case when not 19+t1.c- -11+11+e>=a or t1.d>b then f else t1.e end<> -t1.c) or (t1.a in (select +count(*) from t1 union select abs((case max(d) when count(distinct d) then min( -t1.e) else count(distinct a) end-count(distinct -t1.f)))*count(*) from t1) or not exists(select 1 from t1 where t1.d not in (c,17,e))))}
+} {}
+do_test randexpr-2.390 {
+ db eval {SELECT (select abs(count(distinct t1.e) & min(b))-cast(avg(c) AS integer) & case +~+max(t1.a)*abs(+~ - -+cast(avg(19*f) AS integer) & count(*) & ~max(b) & ((max(t1.e)))-count(distinct t1.d)+ -(count(distinct t1.c)))* -count(distinct 17) & count(distinct a) when ((count(distinct t1.d))) then -min(t1.c) else count(distinct t1.c) end- -min(d) from t1) FROM t1 WHERE ((not exists(select 1 from t1 where c=f)) and case when not 19+t1.c- -11+11+e>=a or t1.d>b then f else t1.e end<> -t1.c) or (t1.a in (select +count(*) from t1 union select abs((case max(d) when count(distinct d) then min( -t1.e) else count(distinct a) end-count(distinct -t1.f)))*count(*) from t1) or not exists(select 1 from t1 where t1.d not in (c,17,e)))}
+} {144}
+do_test randexpr-2.391 {
+ db eval {SELECT case when exists(select 1 from t1 where coalesce((select b from t1 where case when (b<t1.b) then (select (min(a+17+a-t1.f)) from t1) else t1.a end in (select (17-a)*t1.e+c*c from t1 union select 17 from t1)),t1.f)<e) then case when t1.e in (t1.d, -t1.a,c) then 17 else -e end when not t1.c in (select t1.e from t1 union select e from t1) then t1.c else t1.b end FROM t1 WHERE coalesce((select max(13) from t1 where e=t1.a),case when f+(d)<=~case when (case when 17*t1.a in (select 13 from t1 union select 19 from t1) then f else 17 end in (select max(t1.a) from t1 union select cast(avg(t1.e) AS integer)+max(a) | count(*) from t1)) or 13 in (b,t1.e,19) then t1.b*b when t1.a> -11 then -t1.c else -b end then d else t1.a end) not in (t1.b,d,t1.b)}
+} {300}
+do_test randexpr-2.392 {
+ db eval {SELECT case when exists(select 1 from t1 where coalesce((select b from t1 where case when (b<t1.b) then (select (min(a+17+a-t1.f)) from t1) else t1.a end in (select (17-a)*t1.e+c*c from t1 union select 17 from t1)),t1.f)<e) then case when t1.e in (t1.d, -t1.a,c) then 17 else -e end when not t1.c in (select t1.e from t1 union select e from t1) then t1.c else t1.b end FROM t1 WHERE NOT (coalesce((select max(13) from t1 where e=t1.a),case when f+(d)<=~case when (case when 17*t1.a in (select 13 from t1 union select 19 from t1) then f else 17 end in (select max(t1.a) from t1 union select cast(avg(t1.e) AS integer)+max(a) | count(*) from t1)) or 13 in (b,t1.e,19) then t1.b*b when t1.a> -11 then -t1.c else -b end then d else t1.a end) not in (t1.b,d,t1.b))}
+} {}
+do_test randexpr-2.393 {
+ db eval {SELECT t1.f+coalesce((select t1.a-t1.d*f-coalesce((select max(coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where a=~t1.d+case when (c in (select abs(~( -cast(avg(e) AS integer))) from t1 union select -min(19) from t1)) and 19<>t1.e or t1.e<11 and c in (t1.b,t1.b,t1.d) or 17 between -t1.d and t1.d then 11 else d end)),c-f)) from t1 where t1.a<=t1.c),11)-t1.c from t1 where f between t1.a and d),19) FROM t1 WHERE exists(select 1 from t1 where case +t1.d when d then f else t1.e end in (t1.e,17,11) or 13*e-t1.b in (select t1.e from t1 union select 17 from t1)) and 11<=case -case when not exists(select 1 from t1 where (17 | t1.e in (11,11,11) and b<(19))) then case t1.c+t1.f+c when t1.b then c else 19 end else 17 end when d then t1.b else t1.a end}
+} {}
+do_test randexpr-2.394 {
+ db eval {SELECT t1.f+coalesce((select t1.a-t1.d*f-coalesce((select max(coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where a=~t1.d+case when (c in (select abs(~( -cast(avg(e) AS integer))) from t1 union select -min(19) from t1)) and 19<>t1.e or t1.e<11 and c in (t1.b,t1.b,t1.d) or 17 between -t1.d and t1.d then 11 else d end)),c-f)) from t1 where t1.a<=t1.c),11)-t1.c from t1 where f between t1.a and d),19) FROM t1 WHERE NOT (exists(select 1 from t1 where case +t1.d when d then f else t1.e end in (t1.e,17,11) or 13*e-t1.b in (select t1.e from t1 union select 17 from t1)) and 11<=case -case when not exists(select 1 from t1 where (17 | t1.e in (11,11,11) and b<(19))) then case t1.c+t1.f+c when t1.b then c else 19 end else 17 end when d then t1.b else t1.a end)}
+} {619}
+do_test randexpr-2.395 {
+ db eval {SELECT case when (coalesce((select coalesce((select max( -11) from t1 where not case t1.c*case when exists(select 1 from t1 where (t1.d) in (select case count(*) when count(distinct t1.c) then count(*) else count(*) end from t1 union select cast(avg(t1.c) AS integer) from t1)) then +e when f=19 then 17 else t1.e end when t1.a then 19 else c end=e),t1.a)- -d*f-a from t1 where (t1.e)<>13),19)*(a)=19) then (c) when (exists(select 1 from t1 where 17=t1.d)) then 19 else c end FROM t1 WHERE t1.d*c*(select cast(avg(((abs(t1.d*13)/abs(f)))) AS integer) from t1)+t1.d=case when +(coalesce((select t1.a from t1 where case when not exists(select 1 from t1 where not exists(select 1 from t1 where c=t1.e)) then 19 | -17 else 13 end not in (t1.f,b,t1.b)),t1.f))*t1.a-t1.c-13 in (e,11,t1.c) then t1.a when (d between -t1.f and f) then t1.d else t1.a end}
+} {}
+do_test randexpr-2.396 {
+ db eval {SELECT case when (coalesce((select coalesce((select max( -11) from t1 where not case t1.c*case when exists(select 1 from t1 where (t1.d) in (select case count(*) when count(distinct t1.c) then count(*) else count(*) end from t1 union select cast(avg(t1.c) AS integer) from t1)) then +e when f=19 then 17 else t1.e end when t1.a then 19 else c end=e),t1.a)- -d*f-a from t1 where (t1.e)<>13),19)*(a)=19) then (c) when (exists(select 1 from t1 where 17=t1.d)) then 19 else c end FROM t1 WHERE NOT (t1.d*c*(select cast(avg(((abs(t1.d*13)/abs(f)))) AS integer) from t1)+t1.d=case when +(coalesce((select t1.a from t1 where case when not exists(select 1 from t1 where not exists(select 1 from t1 where c=t1.e)) then 19 | -17 else 13 end not in (t1.f,b,t1.b)),t1.f))*t1.a-t1.c-13 in (e,11,t1.c) then t1.a when (d between -t1.f and f) then t1.d else t1.a end)}
+} {300}
+do_test randexpr-2.397 {
+ db eval {SELECT coalesce((select d from t1 where f in (select max(19) from t1 union select ~+max(t1.e) from t1)),b-case -11 when 13 then t1.a-e else case when not exists(select 1 from t1 where c not in ( -t1.c,(t1.e),19)) and d+t1.b-t1.b in (select t1.a from t1 union select t1.d from t1) then 19+19*(t1.f) when t1.b<=a then 17 else t1.a end end+t1.b)*t1.a FROM t1 WHERE (select +cast(avg(~13+(select count(*) from t1)) AS integer)++min(case when (not d<>a) then coalesce((select t1.b from t1 where t1.f not between e and t1.d),13)+13 when t1.d not between 11 and t1.d then 17 else f end) | count(*) | ~count(distinct t1.e) | cast(avg(e) AS integer)-max(t1.d) from t1) not between coalesce((select case t1.a when a then e else 17 end from t1 where t1.a in (t1.e,11,( -t1.d))), -(b)) and t1.a}
+} {}
+do_test randexpr-2.398 {
+ db eval {SELECT coalesce((select d from t1 where f in (select max(19) from t1 union select ~+max(t1.e) from t1)),b-case -11 when 13 then t1.a-e else case when not exists(select 1 from t1 where c not in ( -t1.c,(t1.e),19)) and d+t1.b-t1.b in (select t1.a from t1 union select t1.d from t1) then 19+19*(t1.f) when t1.b<=a then 17 else t1.a end end+t1.b)*t1.a FROM t1 WHERE NOT ((select +cast(avg(~13+(select count(*) from t1)) AS integer)++min(case when (not d<>a) then coalesce((select t1.b from t1 where t1.f not between e and t1.d),13)+13 when t1.d not between 11 and t1.d then 17 else f end) | count(*) | ~count(distinct t1.e) | cast(avg(e) AS integer)-max(t1.d) from t1) not between coalesce((select case t1.a when a then e else 17 end from t1 where t1.a in (t1.e,11,( -t1.d))), -(b)) and t1.a)}
+} {30000}
+do_test randexpr-2.399 {
+ db eval {SELECT (abs(c)/abs((coalesce((select t1.d from t1 where ((19) in (select count(distinct - -(abs(coalesce((select max(t1.e) from t1 where t1.c*t1.a | t1.d=t1.d or t1.f in (select min(t1.f)-cast(avg(e) AS integer) from t1 union select -count(*) from t1)),c))/abs(a))) from t1 union select case cast(avg(c) AS integer)-abs( -((count(*))))*(count(*))*min(d) when cast(avg(a) AS integer) then count(distinct 11) else count(*) end-(count(distinct 17)) from t1))),a))))*t1.e FROM t1 WHERE case when a between -t1.a+(t1.c) and c-case when (~+t1.b-~case when t1.a not between 19*11 and 11 then t1.a when 11=f and -t1.d not between t1.a and d then e else b end in (select min(19) from t1 union select case count(distinct 17) when count(*) then count(distinct t1.f) else min(c) end from t1)) then t1.f else 17 end then 17 else 13 end in (t1.a,t1.d,a)}
+} {}
+do_test randexpr-2.400 {
+ db eval {SELECT (abs(c)/abs((coalesce((select t1.d from t1 where ((19) in (select count(distinct - -(abs(coalesce((select max(t1.e) from t1 where t1.c*t1.a | t1.d=t1.d or t1.f in (select min(t1.f)-cast(avg(e) AS integer) from t1 union select -count(*) from t1)),c))/abs(a))) from t1 union select case cast(avg(c) AS integer)-abs( -((count(*))))*(count(*))*min(d) when cast(avg(a) AS integer) then count(distinct 11) else count(*) end-(count(distinct 17)) from t1))),a))))*t1.e FROM t1 WHERE NOT (case when a between -t1.a+(t1.c) and c-case when (~+t1.b-~case when t1.a not between 19*11 and 11 then t1.a when 11=f and -t1.d not between t1.a and d then e else b end in (select min(19) from t1 union select case count(distinct 17) when count(*) then count(distinct t1.f) else min(c) end from t1)) then t1.f else 17 end then 17 else 13 end in (t1.a,t1.d,a))}
+} {1500}
+do_test randexpr-2.401 {
+ db eval {SELECT (abs(c)/abs((coalesce((select t1.d from t1 where ((19) in (select count(distinct - -(abs(coalesce((select max(t1.e) from t1 where t1.c*t1.a & t1.d=t1.d or t1.f in (select min(t1.f)-cast(avg(e) AS integer) from t1 union select -count(*) from t1)),c))/abs(a))) from t1 union select case cast(avg(c) AS integer)-abs( -((count(*))))*(count(*))*min(d) when cast(avg(a) AS integer) then count(distinct 11) else count(*) end-(count(distinct 17)) from t1))),a))))*t1.e FROM t1 WHERE NOT (case when a between -t1.a+(t1.c) and c-case when (~+t1.b-~case when t1.a not between 19*11 and 11 then t1.a when 11=f and -t1.d not between t1.a and d then e else b end in (select min(19) from t1 union select case count(distinct 17) when count(*) then count(distinct t1.f) else min(c) end from t1)) then t1.f else 17 end then 17 else 13 end in (t1.a,t1.d,a))}
+} {1500}
+do_test randexpr-2.402 {
+ db eval {SELECT case when d=c-(select (~max(t1.f*t1.c-11)) from t1) then coalesce((select max(19) from t1 where 13<coalesce((select case when (select count(distinct t1.f+13) from t1)>d then t1.e when not not exists(select 1 from t1 where t1.c not in (a,a,t1.d) and d not between b and 19) then t1.a else 11 end*f-f from t1 where t1.f between e and e and d between 19 and t1.e or 11<>t1.a),t1.c)),d) else 17 end FROM t1 WHERE (t1.e=11)}
+} {}
+do_test randexpr-2.403 {
+ db eval {SELECT case when d=c-(select (~max(t1.f*t1.c-11)) from t1) then coalesce((select max(19) from t1 where 13<coalesce((select case when (select count(distinct t1.f+13) from t1)>d then t1.e when not not exists(select 1 from t1 where t1.c not in (a,a,t1.d) and d not between b and 19) then t1.a else 11 end*f-f from t1 where t1.f between e and e and d between 19 and t1.e or 11<>t1.a),t1.c)),d) else 17 end FROM t1 WHERE NOT ((t1.e=11))}
+} {17}
+do_test randexpr-2.404 {
+ db eval {SELECT case when t1.a-t1.a | case when (abs(t1.d)/abs(t1.c | t1.a))<>t1.e then e*+t1.c-t1.d*coalesce((select t1.b from t1 where b>=+d+ -e*11),11)+t1.b | t1.f when not exists(select 1 from t1 where d not in (17,e,d)) then 11 else t1.d end>=13 then 11 when d=c then a else f end FROM t1 WHERE (abs(case when not t1.d<=t1.f and not t1.d not between -f and -17-11*t1.d and (13<t1.b) and 17 in (select min(c)-+min(13)-min(t1.b) from t1 union select -max((( -11))) from t1) then 13 when c<>d then t1.d*coalesce((select max(t1.a) from t1 where (17) not between (t1.b) and 11),d) else t1.d end)/abs(f)) not between 13 and 19}
+} {11}
+do_test randexpr-2.405 {
+ db eval {SELECT case when t1.a-t1.a | case when (abs(t1.d)/abs(t1.c | t1.a))<>t1.e then e*+t1.c-t1.d*coalesce((select t1.b from t1 where b>=+d+ -e*11),11)+t1.b | t1.f when not exists(select 1 from t1 where d not in (17,e,d)) then 11 else t1.d end>=13 then 11 when d=c then a else f end FROM t1 WHERE NOT ((abs(case when not t1.d<=t1.f and not t1.d not between -f and -17-11*t1.d and (13<t1.b) and 17 in (select min(c)-+min(13)-min(t1.b) from t1 union select -max((( -11))) from t1) then 13 when c<>d then t1.d*coalesce((select max(t1.a) from t1 where (17) not between (t1.b) and 11),d) else t1.d end)/abs(f)) not between 13 and 19)}
+} {}
+do_test randexpr-2.406 {
+ db eval {SELECT case when t1.a-t1.a & case when (abs(t1.d)/abs(t1.c & t1.a))<>t1.e then e*+t1.c-t1.d*coalesce((select t1.b from t1 where b>=+d+ -e*11),11)+t1.b & t1.f when not exists(select 1 from t1 where d not in (17,e,d)) then 11 else t1.d end>=13 then 11 when d=c then a else f end FROM t1 WHERE (abs(case when not t1.d<=t1.f and not t1.d not between -f and -17-11*t1.d and (13<t1.b) and 17 in (select min(c)-+min(13)-min(t1.b) from t1 union select -max((( -11))) from t1) then 13 when c<>d then t1.d*coalesce((select max(t1.a) from t1 where (17) not between (t1.b) and 11),d) else t1.d end)/abs(f)) not between 13 and 19}
+} {600}
+do_test randexpr-2.407 {
+ db eval {SELECT coalesce((select t1.f*13 from t1 where exists(select 1 from t1 where 13<=t1.e)),(abs(+ -17)/abs(c))) FROM t1 WHERE coalesce((select 17 from t1 where 11>++a-~t1.a+d | (19)),(abs(t1.c)/abs(case when case t1.c*17-case when b not between t1.b and f then t1.a when f>=a then 19 else 13 end when 19 then 13 else t1.f end not between c and a then c else 13 end)))> -e or 13 between f and c and t1.e>=b}
+} {7800}
+do_test randexpr-2.408 {
+ db eval {SELECT coalesce((select t1.f*13 from t1 where exists(select 1 from t1 where 13<=t1.e)),(abs(+ -17)/abs(c))) FROM t1 WHERE NOT (coalesce((select 17 from t1 where 11>++a-~t1.a+d | (19)),(abs(t1.c)/abs(case when case t1.c*17-case when b not between t1.b and f then t1.a when f>=a then 19 else 13 end when 19 then 13 else t1.f end not between c and a then c else 13 end)))> -e or 13 between f and c and t1.e>=b)}
+} {}
+do_test randexpr-2.409 {
+ db eval {SELECT ~+coalesce((select (select count(distinct +coalesce((select c from t1 where e>=13),+c)-t1.c) from t1) from t1 where case a when t1.d*(select cast(avg(case when t1.b*coalesce((select 17 from t1 where case -a when t1.b then d else (t1.f) end not in ((t1.e),a,t1.f)),t1.c)-c in (d,a,t1.c) then c else b end) AS integer) from t1)+t1.d then 13 else t1.e end not in (19,a,17)),13) FROM t1 WHERE +c in (a,17,t1.d)}
+} {}
+do_test randexpr-2.410 {
+ db eval {SELECT ~+coalesce((select (select count(distinct +coalesce((select c from t1 where e>=13),+c)-t1.c) from t1) from t1 where case a when t1.d*(select cast(avg(case when t1.b*coalesce((select 17 from t1 where case -a when t1.b then d else (t1.f) end not in ((t1.e),a,t1.f)),t1.c)-c in (d,a,t1.c) then c else b end) AS integer) from t1)+t1.d then 13 else t1.e end not in (19,a,17)),13) FROM t1 WHERE NOT (+c in (a,17,t1.d))}
+} {-2}
+do_test randexpr-2.411 {
+ db eval {SELECT f-coalesce((select t1.d from t1 where t1.a>11+t1.d),coalesce((select coalesce((select t1.d from t1 where 17>=d or (case c when t1.c then (t1.c) else t1.e end in (b,17,17) or t1.b>=t1.a) or t1.b<=e),case d when (19) then t1.d else t1.a end)-t1.d from t1 where 13 in (select ( -count(distinct (e)) | cast(avg(t1.d) AS integer)*count(*))+max( -11) | max( -c) from t1 union select count(distinct 11) from t1)),a)) FROM t1 WHERE not b<=13 or (coalesce((select max(t1.b) from t1 where b in (case when not a<>13 then 17 when -(select ~abs( -(max(f))+count(distinct t1.a)) from t1)+13>=t1.b then case c when t1.a then d else f end-c else t1.d end-19, -t1.d,f)),19)) not in (t1.a,c,t1.d) or t1.e>t1.f}
+} {500}
+do_test randexpr-2.412 {
+ db eval {SELECT f-coalesce((select t1.d from t1 where t1.a>11+t1.d),coalesce((select coalesce((select t1.d from t1 where 17>=d or (case c when t1.c then (t1.c) else t1.e end in (b,17,17) or t1.b>=t1.a) or t1.b<=e),case d when (19) then t1.d else t1.a end)-t1.d from t1 where 13 in (select ( -count(distinct (e)) | cast(avg(t1.d) AS integer)*count(*))+max( -11) | max( -c) from t1 union select count(distinct 11) from t1)),a)) FROM t1 WHERE NOT (not b<=13 or (coalesce((select max(t1.b) from t1 where b in (case when not a<>13 then 17 when -(select ~abs( -(max(f))+count(distinct t1.a)) from t1)+13>=t1.b then case c when t1.a then d else f end-c else t1.d end-19, -t1.d,f)),19)) not in (t1.a,c,t1.d) or t1.e>t1.f)}
+} {}
+do_test randexpr-2.413 {
+ db eval {SELECT f-coalesce((select t1.d from t1 where t1.a>11+t1.d),coalesce((select coalesce((select t1.d from t1 where 17>=d or (case c when t1.c then (t1.c) else t1.e end in (b,17,17) or t1.b>=t1.a) or t1.b<=e),case d when (19) then t1.d else t1.a end)-t1.d from t1 where 13 in (select ( -count(distinct (e)) & cast(avg(t1.d) AS integer)*count(*))+max( -11) & max( -c) from t1 union select count(distinct 11) from t1)),a)) FROM t1 WHERE not b<=13 or (coalesce((select max(t1.b) from t1 where b in (case when not a<>13 then 17 when -(select ~abs( -(max(f))+count(distinct t1.a)) from t1)+13>=t1.b then case c when t1.a then d else f end-c else t1.d end-19, -t1.d,f)),19)) not in (t1.a,c,t1.d) or t1.e>t1.f}
+} {500}
+do_test randexpr-2.414 {
+ db eval {SELECT coalesce((select e from t1 where (coalesce((select max(+e+e*11*t1.c-e) from t1 where exists(select 1 from t1 where (19<=~t1.f))),case (abs(t1.c)/abs(case t1.c when 19 then f*~case when t1.e+t1.d between -t1.f and (d) then b when (d=a) then t1.e else e end else c end*t1.a)) | f when (d) then 17 else t1.f end)<t1.c)),13) FROM t1 WHERE a>coalesce((select coalesce((select e from t1 where case when -d+t1.e>e then coalesce((select d+b from t1 where exists(select 1 from t1 where not 13-b not in (f,a,d)) and (t1.b between (a) and t1.c)),c) when a=13 then t1.e else a end in (select t1.d from t1 union select t1.d from t1) and e not in (d, -19,11)),d) from t1 where not f in (t1.a,19,t1.d)),t1.d)}
+} {}
+do_test randexpr-2.415 {
+ db eval {SELECT coalesce((select e from t1 where (coalesce((select max(+e+e*11*t1.c-e) from t1 where exists(select 1 from t1 where (19<=~t1.f))),case (abs(t1.c)/abs(case t1.c when 19 then f*~case when t1.e+t1.d between -t1.f and (d) then b when (d=a) then t1.e else e end else c end*t1.a)) | f when (d) then 17 else t1.f end)<t1.c)),13) FROM t1 WHERE NOT (a>coalesce((select coalesce((select e from t1 where case when -d+t1.e>e then coalesce((select d+b from t1 where exists(select 1 from t1 where not 13-b not in (f,a,d)) and (t1.b between (a) and t1.c)),c) when a=13 then t1.e else a end in (select t1.d from t1 union select t1.d from t1) and e not in (d, -19,11)),d) from t1 where not f in (t1.a,19,t1.d)),t1.d))}
+} {13}
+do_test randexpr-2.416 {
+ db eval {SELECT coalesce((select e from t1 where (coalesce((select max(+e+e*11*t1.c-e) from t1 where exists(select 1 from t1 where (19<=~t1.f))),case (abs(t1.c)/abs(case t1.c when 19 then f*~case when t1.e+t1.d between -t1.f and (d) then b when (d=a) then t1.e else e end else c end*t1.a)) & f when (d) then 17 else t1.f end)<t1.c)),13) FROM t1 WHERE NOT (a>coalesce((select coalesce((select e from t1 where case when -d+t1.e>e then coalesce((select d+b from t1 where exists(select 1 from t1 where not 13-b not in (f,a,d)) and (t1.b between (a) and t1.c)),c) when a=13 then t1.e else a end in (select t1.d from t1 union select t1.d from t1) and e not in (d, -19,11)),d) from t1 where not f in (t1.a,19,t1.d)),t1.d))}
+} {13}
+do_test randexpr-2.417 {
+ db eval {SELECT (select count(distinct 11-17-11) from t1)-coalesce((select (abs(13)/abs(t1.b-c*11+coalesce((select max(f) from t1 where t1.a>t1.a),(e))*case when (abs(e)/abs(t1.b)) not between ~f and t1.e then c else (abs(t1.b)/abs(t1.d)) end | 13+b | b+t1.e)) from t1 where t1.c in (select t1.c from t1 union select (a) from t1)),19) FROM t1 WHERE t1.f>=19}
+} {1}
+do_test randexpr-2.418 {
+ db eval {SELECT (select count(distinct 11-17-11) from t1)-coalesce((select (abs(13)/abs(t1.b-c*11+coalesce((select max(f) from t1 where t1.a>t1.a),(e))*case when (abs(e)/abs(t1.b)) not between ~f and t1.e then c else (abs(t1.b)/abs(t1.d)) end | 13+b | b+t1.e)) from t1 where t1.c in (select t1.c from t1 union select (a) from t1)),19) FROM t1 WHERE NOT (t1.f>=19)}
+} {}
+do_test randexpr-2.419 {
+ db eval {SELECT (select count(distinct 11-17-11) from t1)-coalesce((select (abs(13)/abs(t1.b-c*11+coalesce((select max(f) from t1 where t1.a>t1.a),(e))*case when (abs(e)/abs(t1.b)) not between ~f and t1.e then c else (abs(t1.b)/abs(t1.d)) end & 13+b & b+t1.e)) from t1 where t1.c in (select t1.c from t1 union select (a) from t1)),19) FROM t1 WHERE t1.f>=19}
+} {1}
+do_test randexpr-2.420 {
+ db eval {SELECT coalesce((select max(case when 11+(select +abs(count(*)) from t1) not in (case when (case when not exists(select 1 from t1 where t1.d=f) then a else a end+11 in (select ((13)) from t1 union select t1.d from t1)) then (abs(t1.c)/abs(t1.b)) when a>=t1.c then b else f end,t1.a,c) then t1.a when b in (select cast(avg(t1.a) AS integer) | ~ -count(distinct 17) from t1 union select min(c) from t1) then b else -t1.e end) from t1 where d not between c and -t1.b and b=d and b between 13 and t1.c),(17)) FROM t1 WHERE t1.a in (coalesce((select max(e) from t1 where case case (select count(*) from t1)-~19 when t1.f*t1.d+coalesce((select max((select + -(((min(t1.b)))) | -(count(distinct t1.c)) | count(*) from t1)*11) from t1 where f>=case when d in ((d),t1.d,13) then 19 when 17=17 then 11 else a end),t1.e) then c else t1.f end when t1.e then f else t1.d end in (13,(13),c)),t1.d),t1.e,a)}
+} {17}
+do_test randexpr-2.421 {
+ db eval {SELECT coalesce((select max(case when 11+(select +abs(count(*)) from t1) not in (case when (case when not exists(select 1 from t1 where t1.d=f) then a else a end+11 in (select ((13)) from t1 union select t1.d from t1)) then (abs(t1.c)/abs(t1.b)) when a>=t1.c then b else f end,t1.a,c) then t1.a when b in (select cast(avg(t1.a) AS integer) | ~ -count(distinct 17) from t1 union select min(c) from t1) then b else -t1.e end) from t1 where d not between c and -t1.b and b=d and b between 13 and t1.c),(17)) FROM t1 WHERE NOT (t1.a in (coalesce((select max(e) from t1 where case case (select count(*) from t1)-~19 when t1.f*t1.d+coalesce((select max((select + -(((min(t1.b)))) | -(count(distinct t1.c)) | count(*) from t1)*11) from t1 where f>=case when d in ((d),t1.d,13) then 19 when 17=17 then 11 else a end),t1.e) then c else t1.f end when t1.e then f else t1.d end in (13,(13),c)),t1.d),t1.e,a))}
+} {}
+do_test randexpr-2.422 {
+ db eval {SELECT coalesce((select max(case when 11+(select +abs(count(*)) from t1) not in (case when (case when not exists(select 1 from t1 where t1.d=f) then a else a end+11 in (select ((13)) from t1 union select t1.d from t1)) then (abs(t1.c)/abs(t1.b)) when a>=t1.c then b else f end,t1.a,c) then t1.a when b in (select cast(avg(t1.a) AS integer) & ~ -count(distinct 17) from t1 union select min(c) from t1) then b else -t1.e end) from t1 where d not between c and -t1.b and b=d and b between 13 and t1.c),(17)) FROM t1 WHERE t1.a in (coalesce((select max(e) from t1 where case case (select count(*) from t1)-~19 when t1.f*t1.d+coalesce((select max((select + -(((min(t1.b)))) | -(count(distinct t1.c)) | count(*) from t1)*11) from t1 where f>=case when d in ((d),t1.d,13) then 19 when 17=17 then 11 else a end),t1.e) then c else t1.f end when t1.e then f else t1.d end in (13,(13),c)),t1.d),t1.e,a)}
+} {17}
+do_test randexpr-2.423 {
+ db eval {SELECT coalesce((select t1.a-case t1.a when c then coalesce((select case (abs(11-(abs(t1.b)/abs(t1.a)))/abs((abs(t1.c)/abs(t1.a))))-t1.f when t1.d then f else 19 end from t1 where +t1.b*a in (select t1.e from t1 union select c from t1) and e between d and 11),t1.b) else a end from t1 where exists(select 1 from t1 where ((a in (13,c,d)))) and -t1.e in ((t1.d),t1.a,t1.b)),t1.c) FROM t1 WHERE ++e*19 in (case when case when not (d<>case when -case when (t1.a not between b and -e) then 17 when f<>a then -t1.d else t1.a end not in (a,a,c) then b when b<=c then e else b end) then 19 when (t1.b not in ( -13,t1.a,a)) then t1.b | 13 else e end* -19*t1.a<t1.f then t1.c when t1.f=t1.f then t1.a else t1.b end+d,a,11)}
+} {}
+do_test randexpr-2.424 {
+ db eval {SELECT coalesce((select t1.a-case t1.a when c then coalesce((select case (abs(11-(abs(t1.b)/abs(t1.a)))/abs((abs(t1.c)/abs(t1.a))))-t1.f when t1.d then f else 19 end from t1 where +t1.b*a in (select t1.e from t1 union select c from t1) and e between d and 11),t1.b) else a end from t1 where exists(select 1 from t1 where ((a in (13,c,d)))) and -t1.e in ((t1.d),t1.a,t1.b)),t1.c) FROM t1 WHERE NOT (++e*19 in (case when case when not (d<>case when -case when (t1.a not between b and -e) then 17 when f<>a then -t1.d else t1.a end not in (a,a,c) then b when b<=c then e else b end) then 19 when (t1.b not in ( -13,t1.a,a)) then t1.b | 13 else e end* -19*t1.a<t1.f then t1.c when t1.f=t1.f then t1.a else t1.b end+d,a,11))}
+} {300}
+do_test randexpr-2.425 {
+ db eval {SELECT (abs(e-((coalesce((select max(t1.c) from t1 where t1.f-a-case coalesce((select max(d) from t1 where (13<>~19)),f) when a- -t1.a | t1.f then t1.a*11-t1.e else coalesce((select max(t1.b) from t1 where not exists(select 1 from t1 where 17=t1.a or b>=f)),c) | t1.b end>19),t1.a))+c)-t1.c*e)/abs(t1.d)) FROM t1 WHERE a-t1.b not in (a,a-19-c | t1.d-d | e*t1.c*b,t1.e+t1.a)}
+} {375}
+do_test randexpr-2.426 {
+ db eval {SELECT (abs(e-((coalesce((select max(t1.c) from t1 where t1.f-a-case coalesce((select max(d) from t1 where (13<>~19)),f) when a- -t1.a | t1.f then t1.a*11-t1.e else coalesce((select max(t1.b) from t1 where not exists(select 1 from t1 where 17=t1.a or b>=f)),c) | t1.b end>19),t1.a))+c)-t1.c*e)/abs(t1.d)) FROM t1 WHERE NOT (a-t1.b not in (a,a-19-c | t1.d-d | e*t1.c*b,t1.e+t1.a))}
+} {}
+do_test randexpr-2.427 {
+ db eval {SELECT (abs(e-((coalesce((select max(t1.c) from t1 where t1.f-a-case coalesce((select max(d) from t1 where (13<>~19)),f) when a- -t1.a & t1.f then t1.a*11-t1.e else coalesce((select max(t1.b) from t1 where not exists(select 1 from t1 where 17=t1.a or b>=f)),c) & t1.b end>19),t1.a))+c)-t1.c*e)/abs(t1.d)) FROM t1 WHERE a-t1.b not in (a,a-19-c | t1.d-d | e*t1.c*b,t1.e+t1.a)}
+} {375}
+do_test randexpr-2.428 {
+ db eval {SELECT t1.b-coalesce((select t1.a from t1 where (d<=f)),~~case b when coalesce((select coalesce((select t1.c from t1 where a+~+~(abs(t1.d)/abs(17)) | -d*a*(b++ -13)*b>=b),17) | a from t1 where a<a),17)-13 then 11 else t1.a end) FROM t1 WHERE -coalesce((select (abs(t1.d)/abs(~t1.e))-a from t1 where (c>=coalesce((select t1.d+(select case min(a) | max(t1.b) when max(e) then count(*) else -count(distinct f) end from t1)-t1.f+( - - -19) from t1 where t1.c in (select 19 from t1 union select 17 from t1)),11))),19)+11 not in ((b),e,e) or t1.e in (select min(t1.f) from t1 union select count(*)- -(cast(avg(17) AS integer)) from t1) or e>=t1.c}
+} {100}
+do_test randexpr-2.429 {
+ db eval {SELECT t1.b-coalesce((select t1.a from t1 where (d<=f)),~~case b when coalesce((select coalesce((select t1.c from t1 where a+~+~(abs(t1.d)/abs(17)) | -d*a*(b++ -13)*b>=b),17) | a from t1 where a<a),17)-13 then 11 else t1.a end) FROM t1 WHERE NOT ( -coalesce((select (abs(t1.d)/abs(~t1.e))-a from t1 where (c>=coalesce((select t1.d+(select case min(a) | max(t1.b) when max(e) then count(*) else -count(distinct f) end from t1)-t1.f+( - - -19) from t1 where t1.c in (select 19 from t1 union select 17 from t1)),11))),19)+11 not in ((b),e,e) or t1.e in (select min(t1.f) from t1 union select count(*)- -(cast(avg(17) AS integer)) from t1) or e>=t1.c)}
+} {}
+do_test randexpr-2.430 {
+ db eval {SELECT t1.b-coalesce((select t1.a from t1 where (d<=f)),~~case b when coalesce((select coalesce((select t1.c from t1 where a+~+~(abs(t1.d)/abs(17)) & -d*a*(b++ -13)*b>=b),17) & a from t1 where a<a),17)-13 then 11 else t1.a end) FROM t1 WHERE -coalesce((select (abs(t1.d)/abs(~t1.e))-a from t1 where (c>=coalesce((select t1.d+(select case min(a) | max(t1.b) when max(e) then count(*) else -count(distinct f) end from t1)-t1.f+( - - -19) from t1 where t1.c in (select 19 from t1 union select 17 from t1)),11))),19)+11 not in ((b),e,e) or t1.e in (select min(t1.f) from t1 union select count(*)- -(cast(avg(17) AS integer)) from t1) or e>=t1.c}
+} {100}
+do_test randexpr-2.431 {
+ db eval {SELECT coalesce((select max(case when e<=t1.d then f*+case 17 when 17 then (abs((select abs(cast(avg(13) AS integer)+min(t1.b)) from t1))/abs(t1.c)) else d end*t1.c else a end) from t1 where coalesce((select t1.c from t1 where a<>t1.e+f-t1.c-a),+t1.a)+t1.d*case when d in (select t1.c from t1 union select 11 from t1) then a when 19 not in (d,e,b) then 11 else 19 end | t1.b in (select 19 from t1 union select t1.a from t1)),17)*11 FROM t1 WHERE 17>=t1.b}
+} {}
+do_test randexpr-2.432 {
+ db eval {SELECT coalesce((select max(case when e<=t1.d then f*+case 17 when 17 then (abs((select abs(cast(avg(13) AS integer)+min(t1.b)) from t1))/abs(t1.c)) else d end*t1.c else a end) from t1 where coalesce((select t1.c from t1 where a<>t1.e+f-t1.c-a),+t1.a)+t1.d*case when d in (select t1.c from t1 union select 11 from t1) then a when 19 not in (d,e,b) then 11 else 19 end | t1.b in (select 19 from t1 union select t1.a from t1)),17)*11 FROM t1 WHERE NOT (17>=t1.b)}
+} {187}
+do_test randexpr-2.433 {
+ db eval {SELECT coalesce((select max(case when e<=t1.d then f*+case 17 when 17 then (abs((select abs(cast(avg(13) AS integer)+min(t1.b)) from t1))/abs(t1.c)) else d end*t1.c else a end) from t1 where coalesce((select t1.c from t1 where a<>t1.e+f-t1.c-a),+t1.a)+t1.d*case when d in (select t1.c from t1 union select 11 from t1) then a when 19 not in (d,e,b) then 11 else 19 end & t1.b in (select 19 from t1 union select t1.a from t1)),17)*11 FROM t1 WHERE NOT (17>=t1.b)}
+} {187}
+do_test randexpr-2.434 {
+ db eval {SELECT case when coalesce((select max(case f when (abs(t1.d)/abs(case when +~e not in (t1.d,c,t1.a) or 17 in (select count(distinct -b) from t1 union select count(distinct d) from t1) and d<=t1.b or b>(f) then coalesce((select c from t1 where t1.f<t1.e),e)+(d) when 17<19 then t1.c else t1.b end)) then t1.b else f end) from t1 where (17 not between 11 and t1.b) or t1.f>f or t1.b<> -t1.c), -t1.d)<11 then c else f end FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where case -case when case t1.c-t1.b-e when t1.b then t1.e else -t1.c+~17 | coalesce((select max(t1.c) from t1 where 19 not between -(a)-t1.c and 17),t1.c) end in (select (t1.f) from t1 union select b from t1) then e when c<>19 then t1.b else f end when -11 then 11 else 19 end in ( -19,t1.a,d)) and not 17<t1.d)}
+} {600}
+do_test randexpr-2.435 {
+ db eval {SELECT case when coalesce((select max(case f when (abs(t1.d)/abs(case when +~e not in (t1.d,c,t1.a) or 17 in (select count(distinct -b) from t1 union select count(distinct d) from t1) and d<=t1.b or b>(f) then coalesce((select c from t1 where t1.f<t1.e),e)+(d) when 17<19 then t1.c else t1.b end)) then t1.b else f end) from t1 where (17 not between 11 and t1.b) or t1.f>f or t1.b<> -t1.c), -t1.d)<11 then c else f end FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where case -case when case t1.c-t1.b-e when t1.b then t1.e else -t1.c+~17 | coalesce((select max(t1.c) from t1 where 19 not between -(a)-t1.c and 17),t1.c) end in (select (t1.f) from t1 union select b from t1) then e when c<>19 then t1.b else f end when -11 then 11 else 19 end in ( -19,t1.a,d)) and not 17<t1.d))}
+} {}
+do_test randexpr-2.436 {
+ db eval {SELECT ((select abs(min(t1.b-t1.b)-cast(avg((t1.d-t1.a*a) | (select max(t1.e-e) | max(17)*~abs(count(*)-cast(avg(coalesce((select t1.c from t1 where t1.c<=11),19)+ -e) AS integer) | max(t1.c)) | min(b) | (count(*))*min(19)- -count(*) | (cast(avg(b) AS integer)) from t1)) AS integer)-cast(avg(t1.b) AS integer)) from t1)) FROM t1 WHERE +b+(19*19)+c+t1.d<=e-19+case 13 when t1.f+~11+(select cast(avg(t1.e) AS integer) from t1) then (case when not exists(select 1 from t1 where t1.a between d and t1.b) then case c when d then d else t1.f end when not t1.b in (11,t1.c,t1.d) or t1.c<=(d) then (t1.a) else t1.b end) else -e end or f in (t1.f,d,t1.c)}
+} {7995}
+do_test randexpr-2.437 {
+ db eval {SELECT ((select abs(min(t1.b-t1.b)-cast(avg((t1.d-t1.a*a) | (select max(t1.e-e) | max(17)*~abs(count(*)-cast(avg(coalesce((select t1.c from t1 where t1.c<=11),19)+ -e) AS integer) | max(t1.c)) | min(b) | (count(*))*min(19)- -count(*) | (cast(avg(b) AS integer)) from t1)) AS integer)-cast(avg(t1.b) AS integer)) from t1)) FROM t1 WHERE NOT (+b+(19*19)+c+t1.d<=e-19+case 13 when t1.f+~11+(select cast(avg(t1.e) AS integer) from t1) then (case when not exists(select 1 from t1 where t1.a between d and t1.b) then case c when d then d else t1.f end when not t1.b in (11,t1.c,t1.d) or t1.c<=(d) then (t1.a) else t1.b end) else -e end or f in (t1.f,d,t1.c))}
+} {}
+do_test randexpr-2.438 {
+ db eval {SELECT ((select abs(min(t1.b-t1.b)-cast(avg((t1.d-t1.a*a) & (select max(t1.e-e) & max(17)*~abs(count(*)-cast(avg(coalesce((select t1.c from t1 where t1.c<=11),19)+ -e) AS integer) & max(t1.c)) & min(b) & (count(*))*min(19)- -count(*) & (cast(avg(b) AS integer)) from t1)) AS integer)-cast(avg(t1.b) AS integer)) from t1)) FROM t1 WHERE +b+(19*19)+c+t1.d<=e-19+case 13 when t1.f+~11+(select cast(avg(t1.e) AS integer) from t1) then (case when not exists(select 1 from t1 where t1.a between d and t1.b) then case c when d then d else t1.f end when not t1.b in (11,t1.c,t1.d) or t1.c<=(d) then (t1.a) else t1.b end) else -e end or f in (t1.f,d,t1.c)}
+} {200}
+do_test randexpr-2.439 {
+ db eval {SELECT case when (b<coalesce((select coalesce((select max(19 | t1.c) from t1 where 13 not in (t1.f,e,t1.e) or (select (count(distinct coalesce((select d from t1 where t1.c between -17 and b),11)) | count(*)-max(t1.d)* -(max(d))) from t1)-c*t1.e in (select 19 | f from t1 union select a from t1)),c)*a from t1 where (13 not between a and 19)),19) and b>a) then t1.f else t1.c end FROM t1 WHERE case when (((case coalesce((select -t1.b-t1.b*19*c | 19 from t1 where (exists(select 1 from t1 where e>=t1.a))),t1.a)+11 when d then t1.e else t1.c end=t1.d))) then t1.b when not not exists(select 1 from t1 where t1.f<(t1.a)) and t1.d>=f or t1.c>t1.a or t1.b between t1.f and 19 then t1.c else ~t1.c end=11 or (t1.e) not between 13 and t1.c}
+} {600}
+do_test randexpr-2.440 {
+ db eval {SELECT case when (b<coalesce((select coalesce((select max(19 | t1.c) from t1 where 13 not in (t1.f,e,t1.e) or (select (count(distinct coalesce((select d from t1 where t1.c between -17 and b),11)) | count(*)-max(t1.d)* -(max(d))) from t1)-c*t1.e in (select 19 | f from t1 union select a from t1)),c)*a from t1 where (13 not between a and 19)),19) and b>a) then t1.f else t1.c end FROM t1 WHERE NOT (case when (((case coalesce((select -t1.b-t1.b*19*c | 19 from t1 where (exists(select 1 from t1 where e>=t1.a))),t1.a)+11 when d then t1.e else t1.c end=t1.d))) then t1.b when not not exists(select 1 from t1 where t1.f<(t1.a)) and t1.d>=f or t1.c>t1.a or t1.b between t1.f and 19 then t1.c else ~t1.c end=11 or (t1.e) not between 13 and t1.c)}
+} {}
+do_test randexpr-2.441 {
+ db eval {SELECT case when (b<coalesce((select coalesce((select max(19 & t1.c) from t1 where 13 not in (t1.f,e,t1.e) or (select (count(distinct coalesce((select d from t1 where t1.c between -17 and b),11)) & count(*)-max(t1.d)* -(max(d))) from t1)-c*t1.e in (select 19 & f from t1 union select a from t1)),c)*a from t1 where (13 not between a and 19)),19) and b>a) then t1.f else t1.c end FROM t1 WHERE case when (((case coalesce((select -t1.b-t1.b*19*c | 19 from t1 where (exists(select 1 from t1 where e>=t1.a))),t1.a)+11 when d then t1.e else t1.c end=t1.d))) then t1.b when not not exists(select 1 from t1 where t1.f<(t1.a)) and t1.d>=f or t1.c>t1.a or t1.b between t1.f and 19 then t1.c else ~t1.c end=11 or (t1.e) not between 13 and t1.c}
+} {300}
+do_test randexpr-2.442 {
+ db eval {SELECT case when not t1.d not in (coalesce((select 17 | -coalesce((select (select min(a-t1.a+t1.a-t1.c*t1.e) from t1) from t1 where t1.d<=a),11) | 19 from t1 where not ( -13 in ( -t1.d,t1.d,19))),e)+11,11,13) then e when ((t1.b<t1.c) or d=19) then (t1.a) else a end FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where ~f-e+t1.b*d+case when coalesce((select max(d) from t1 where (t1.c*t1.b in (b,t1.e,17)) or t1.b not in (t1.c,t1.a,t1.c)), -17) in (select count(distinct 13) from t1 union select - -~min( -11) | cast(avg(c) AS integer) from t1) then f else a end+e*t1.c+t1.c>t1.f and a>=17))}
+} {}
+do_test randexpr-2.443 {
+ db eval {SELECT case when not t1.d not in (coalesce((select 17 | -coalesce((select (select min(a-t1.a+t1.a-t1.c*t1.e) from t1) from t1 where t1.d<=a),11) | 19 from t1 where not ( -13 in ( -t1.d,t1.d,19))),e)+11,11,13) then e when ((t1.b<t1.c) or d=19) then (t1.a) else a end FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where ~f-e+t1.b*d+case when coalesce((select max(d) from t1 where (t1.c*t1.b in (b,t1.e,17)) or t1.b not in (t1.c,t1.a,t1.c)), -17) in (select count(distinct 13) from t1 union select - -~min( -11) | cast(avg(c) AS integer) from t1) then f else a end+e*t1.c+t1.c>t1.f and a>=17)))}
+} {100}
+do_test randexpr-2.444 {
+ db eval {SELECT case when not t1.d not in (coalesce((select 17 & -coalesce((select (select min(a-t1.a+t1.a-t1.c*t1.e) from t1) from t1 where t1.d<=a),11) & 19 from t1 where not ( -13 in ( -t1.d,t1.d,19))),e)+11,11,13) then e when ((t1.b<t1.c) or d=19) then (t1.a) else a end FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where ~f-e+t1.b*d+case when coalesce((select max(d) from t1 where (t1.c*t1.b in (b,t1.e,17)) or t1.b not in (t1.c,t1.a,t1.c)), -17) in (select count(distinct 13) from t1 union select - -~min( -11) | cast(avg(c) AS integer) from t1) then f else a end+e*t1.c+t1.c>t1.f and a>=17)))}
+} {100}
+do_test randexpr-2.445 {
+ db eval {SELECT e+c-(c)+t1.e*(abs(case when 13 in (select abs(max(17)*case -count(*) when cast(avg(a) AS integer) then count(distinct b) else -max(f) end | (cast(avg(t1.e) AS integer)) | -min(f)) from t1 union select count(distinct d) from t1) and case when (t1.e+a> -(a)) then e when not c<t1.f or t1.d=f then e else t1.e end<=t1.f then -a when t1.d<=13 then a else t1.b end)/abs( -t1.a))-t1.b+t1.b FROM t1 WHERE case when -case when t1.f<t1.c then -(t1.e) when 11 between e and coalesce((select c from t1 where not exists(select 1 from t1 where b>=e)),coalesce((select max(case t1.e when t1.c then t1.a else a end) from t1 where b>=t1.c and b<>t1.c),13)) then t1.b else a end<11 then b when (11 in (select a from t1 union select t1.b from t1)) or t1.b=e or a between a and 13 then t1.b else b end>19}
+} {1500}
+do_test randexpr-2.446 {
+ db eval {SELECT e+c-(c)+t1.e*(abs(case when 13 in (select abs(max(17)*case -count(*) when cast(avg(a) AS integer) then count(distinct b) else -max(f) end | (cast(avg(t1.e) AS integer)) | -min(f)) from t1 union select count(distinct d) from t1) and case when (t1.e+a> -(a)) then e when not c<t1.f or t1.d=f then e else t1.e end<=t1.f then -a when t1.d<=13 then a else t1.b end)/abs( -t1.a))-t1.b+t1.b FROM t1 WHERE NOT (case when -case when t1.f<t1.c then -(t1.e) when 11 between e and coalesce((select c from t1 where not exists(select 1 from t1 where b>=e)),coalesce((select max(case t1.e when t1.c then t1.a else a end) from t1 where b>=t1.c and b<>t1.c),13)) then t1.b else a end<11 then b when (11 in (select a from t1 union select t1.b from t1)) or t1.b=e or a between a and 13 then t1.b else b end>19)}
+} {}
+do_test randexpr-2.447 {
+ db eval {SELECT e+c-(c)+t1.e*(abs(case when 13 in (select abs(max(17)*case -count(*) when cast(avg(a) AS integer) then count(distinct b) else -max(f) end & (cast(avg(t1.e) AS integer)) & -min(f)) from t1 union select count(distinct d) from t1) and case when (t1.e+a> -(a)) then e when not c<t1.f or t1.d=f then e else t1.e end<=t1.f then -a when t1.d<=13 then a else t1.b end)/abs( -t1.a))-t1.b+t1.b FROM t1 WHERE case when -case when t1.f<t1.c then -(t1.e) when 11 between e and coalesce((select c from t1 where not exists(select 1 from t1 where b>=e)),coalesce((select max(case t1.e when t1.c then t1.a else a end) from t1 where b>=t1.c and b<>t1.c),13)) then t1.b else a end<11 then b when (11 in (select a from t1 union select t1.b from t1)) or t1.b=e or a between a and 13 then t1.b else b end>19}
+} {1500}
+do_test randexpr-2.448 {
+ db eval {SELECT 13-coalesce((select t1.a*a from t1 where not exists(select 1 from t1 where 17 not between case +coalesce((select -case 19 when a*b then 19 else f end from t1 where (t1.d-t1.e between case f when (select abs(case abs( -min(13)) when min(t1.b) then -(count(distinct f)) else min(t1.b) end) from t1) then 17*( -13) | f else t1.e end and -t1.a)),d)*c when 13 then 11 else t1.a end and c)),t1.a)*19 FROM t1 WHERE ((not f-c<=(abs(a)/abs(+t1.a)) or t1.e not between coalesce((select 11 from t1 where - -a*t1.d*case coalesce((select max(d) from t1 where ((t1.b<=t1.c))),case when f>t1.d or t1.d=t1.a or t1.c<=c then a else -c end*t1.b) when (f) then 11 else 19 end-t1.a<=b),c) and 13))}
+} {-1887}
+do_test randexpr-2.449 {
+ db eval {SELECT 13-coalesce((select t1.a*a from t1 where not exists(select 1 from t1 where 17 not between case +coalesce((select -case 19 when a*b then 19 else f end from t1 where (t1.d-t1.e between case f when (select abs(case abs( -min(13)) when min(t1.b) then -(count(distinct f)) else min(t1.b) end) from t1) then 17*( -13) | f else t1.e end and -t1.a)),d)*c when 13 then 11 else t1.a end and c)),t1.a)*19 FROM t1 WHERE NOT (((not f-c<=(abs(a)/abs(+t1.a)) or t1.e not between coalesce((select 11 from t1 where - -a*t1.d*case coalesce((select max(d) from t1 where ((t1.b<=t1.c))),case when f>t1.d or t1.d=t1.a or t1.c<=c then a else -c end*t1.b) when (f) then 11 else 19 end-t1.a<=b),c) and 13)))}
+} {}
+do_test randexpr-2.450 {
+ db eval {SELECT 13-coalesce((select t1.a*a from t1 where not exists(select 1 from t1 where 17 not between case +coalesce((select -case 19 when a*b then 19 else f end from t1 where (t1.d-t1.e between case f when (select abs(case abs( -min(13)) when min(t1.b) then -(count(distinct f)) else min(t1.b) end) from t1) then 17*( -13) & f else t1.e end and -t1.a)),d)*c when 13 then 11 else t1.a end and c)),t1.a)*19 FROM t1 WHERE ((not f-c<=(abs(a)/abs(+t1.a)) or t1.e not between coalesce((select 11 from t1 where - -a*t1.d*case coalesce((select max(d) from t1 where ((t1.b<=t1.c))),case when f>t1.d or t1.d=t1.a or t1.c<=c then a else -c end*t1.b) when (f) then 11 else 19 end-t1.a<=b),c) and 13))}
+} {-1887}
+do_test randexpr-2.451 {
+ db eval {SELECT ~case when (t1.d | 17 in (b*t1.e,19*case when t1.d<= -a then t1.d*~t1.c*e*t1.c-19 else ~t1.b+17 end-d,(t1.c))) then +t1.d else (abs( -case t1.e when t1.c then (t1.b) else t1.f end-11+ -a)/abs(f))+a end FROM t1 WHERE not exists(select 1 from t1 where not c in (select case count(distinct (f)-19) when ~( -+~cast(avg(c) AS integer) | count(distinct 11)-max(d)+min(t1.a)+ -( -count(distinct b))+(count(*)))-count(*)+cast(avg(c) AS integer) then count(distinct d) else ((max(t1.b))) end-min(b) from t1 union select min(t1.c) from t1)) and t1.c in (select +d from t1 union select case when c+b=17 then a else 13 end+11 from t1)}
+} {}
+do_test randexpr-2.452 {
+ db eval {SELECT ~case when (t1.d | 17 in (b*t1.e,19*case when t1.d<= -a then t1.d*~t1.c*e*t1.c-19 else ~t1.b+17 end-d,(t1.c))) then +t1.d else (abs( -case t1.e when t1.c then (t1.b) else t1.f end-11+ -a)/abs(f))+a end FROM t1 WHERE NOT (not exists(select 1 from t1 where not c in (select case count(distinct (f)-19) when ~( -+~cast(avg(c) AS integer) | count(distinct 11)-max(d)+min(t1.a)+ -( -count(distinct b))+(count(*)))-count(*)+cast(avg(c) AS integer) then count(distinct d) else ((max(t1.b))) end-min(b) from t1 union select min(t1.c) from t1)) and t1.c in (select +d from t1 union select case when c+b=17 then a else 13 end+11 from t1))}
+} {-102}
+do_test randexpr-2.453 {
+ db eval {SELECT ~case when (t1.d & 17 in (b*t1.e,19*case when t1.d<= -a then t1.d*~t1.c*e*t1.c-19 else ~t1.b+17 end-d,(t1.c))) then +t1.d else (abs( -case t1.e when t1.c then (t1.b) else t1.f end-11+ -a)/abs(f))+a end FROM t1 WHERE NOT (not exists(select 1 from t1 where not c in (select case count(distinct (f)-19) when ~( -+~cast(avg(c) AS integer) | count(distinct 11)-max(d)+min(t1.a)+ -( -count(distinct b))+(count(*)))-count(*)+cast(avg(c) AS integer) then count(distinct d) else ((max(t1.b))) end-min(b) from t1 union select min(t1.c) from t1)) and t1.c in (select +d from t1 union select case when c+b=17 then a else 13 end+11 from t1))}
+} {-102}
+do_test randexpr-2.454 {
+ db eval {SELECT (select case case min(d) when abs(cast(avg((abs(a)/abs(coalesce((select (select abs(cast(avg(t1.f) AS integer)) from t1) from t1 where (case when t1.e in (select 11 from t1 union select 17 from t1) then -t1.e- -t1.e else a end<>a) and not not exists(select 1 from t1 where t1.b in (select ~+max( -t1.b) | max(t1.c) from t1 union select count(distinct -t1.a) from t1))),t1.a)))) AS integer)) then (count(*) | ((count(distinct b)))-count(*)) else min(11) end when max(a) then count(distinct f) else (min(17)) end from t1) FROM t1 WHERE coalesce((select max(13) from t1 where t1.b not in ( -case when 13 not between 17 and b then f when t1.e+~+e between coalesce((select max(case 19 when e then 17 else coalesce((select coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.b not between t1.a and a)),e)*b*t1.f from t1 where t1.f>=t1.c),c) end) from t1 where e>b),t1.f) | f and f then c else 11 end,(c),t1.e)),19)-t1.c in (select t1.a from t1 union select e from t1)}
+} {}
+do_test randexpr-2.455 {
+ db eval {SELECT (select case case min(d) when abs(cast(avg((abs(a)/abs(coalesce((select (select abs(cast(avg(t1.f) AS integer)) from t1) from t1 where (case when t1.e in (select 11 from t1 union select 17 from t1) then -t1.e- -t1.e else a end<>a) and not not exists(select 1 from t1 where t1.b in (select ~+max( -t1.b) | max(t1.c) from t1 union select count(distinct -t1.a) from t1))),t1.a)))) AS integer)) then (count(*) | ((count(distinct b)))-count(*)) else min(11) end when max(a) then count(distinct f) else (min(17)) end from t1) FROM t1 WHERE NOT (coalesce((select max(13) from t1 where t1.b not in ( -case when 13 not between 17 and b then f when t1.e+~+e between coalesce((select max(case 19 when e then 17 else coalesce((select coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.b not between t1.a and a)),e)*b*t1.f from t1 where t1.f>=t1.c),c) end) from t1 where e>b),t1.f) | f and f then c else 11 end,(c),t1.e)),19)-t1.c in (select t1.a from t1 union select e from t1))}
+} {17}
+do_test randexpr-2.456 {
+ db eval {SELECT (select case case min(d) when abs(cast(avg((abs(a)/abs(coalesce((select (select abs(cast(avg(t1.f) AS integer)) from t1) from t1 where (case when t1.e in (select 11 from t1 union select 17 from t1) then -t1.e- -t1.e else a end<>a) and not not exists(select 1 from t1 where t1.b in (select ~+max( -t1.b) & max(t1.c) from t1 union select count(distinct -t1.a) from t1))),t1.a)))) AS integer)) then (count(*) & ((count(distinct b)))-count(*)) else min(11) end when max(a) then count(distinct f) else (min(17)) end from t1) FROM t1 WHERE NOT (coalesce((select max(13) from t1 where t1.b not in ( -case when 13 not between 17 and b then f when t1.e+~+e between coalesce((select max(case 19 when e then 17 else coalesce((select coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.b not between t1.a and a)),e)*b*t1.f from t1 where t1.f>=t1.c),c) end) from t1 where e>b),t1.f) | f and f then c else 11 end,(c),t1.e)),19)-t1.c in (select t1.a from t1 union select e from t1))}
+} {17}
+do_test randexpr-2.457 {
+ db eval {SELECT (a*f+c | ~b*(select cast(avg(19) AS integer) from t1)+17*(select max(a*b-d) from t1)+(abs((select count(distinct b) from t1))/abs(case when -13*c between t1.f and t1.c then c when not 17 between 17 and 11 and 17<=((t1.c)) then c else a end*t1.c))-a*a)-c FROM t1 WHERE exists(select 1 from t1 where t1.e-11+t1.d*e+(abs(coalesce((select max(t1.b) from t1 where 19-13- -coalesce((select c*t1.e+t1.f*f from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (17<=d or -11 in (select cast(avg(c) AS integer) from t1 union select +count(*) from t1))))),t1.b)<a),(t1.c)))/abs(t1.c))<=a or 13 between t1.e and -t1.b)}
+} {}
+do_test randexpr-2.458 {
+ db eval {SELECT (a*f+c | ~b*(select cast(avg(19) AS integer) from t1)+17*(select max(a*b-d) from t1)+(abs((select count(distinct b) from t1))/abs(case when -13*c between t1.f and t1.c then c when not 17 between 17 and 11 and 17<=((t1.c)) then c else a end*t1.c))-a*a)-c FROM t1 WHERE NOT (exists(select 1 from t1 where t1.e-11+t1.d*e+(abs(coalesce((select max(t1.b) from t1 where 19-13- -coalesce((select c*t1.e+t1.f*f from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (17<=d or -11 in (select cast(avg(c) AS integer) from t1 union select +count(*) from t1))))),t1.b)<a),(t1.c)))/abs(t1.c))<=a or 13 between t1.e and -t1.b))}
+} {327281}
+do_test randexpr-2.459 {
+ db eval {SELECT (a*f+c & ~b*(select cast(avg(19) AS integer) from t1)+17*(select max(a*b-d) from t1)+(abs((select count(distinct b) from t1))/abs(case when -13*c between t1.f and t1.c then c when not 17 between 17 and 11 and 17<=((t1.c)) then c else a end*t1.c))-a*a)-c FROM t1 WHERE NOT (exists(select 1 from t1 where t1.e-11+t1.d*e+(abs(coalesce((select max(t1.b) from t1 where 19-13- -coalesce((select c*t1.e+t1.f*f from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (17<=d or -11 in (select cast(avg(c) AS integer) from t1 union select +count(*) from t1))))),t1.b)<a),(t1.c)))/abs(t1.c))<=a or 13 between t1.e and -t1.b))}
+} {51800}
+do_test randexpr-2.460 {
+ db eval {SELECT coalesce((select max(case when not ((select ((count(distinct t1.f)*(cast(avg(e) AS integer)))-min(t1.d)*min(t1.c)) from t1)*(select min(t1.d) from t1) not in ((select count(distinct b) from t1),f*d,19) and -a in (t1.d,b,a)) and d>=t1.c or t1.b>t1.c or 19 not between c and t1.e then 17 else t1.b end) from t1 where (e<=t1.b)),11) FROM t1 WHERE t1.a in (f,t1.d*+a,t1.c* -(select (abs(case +(max(coalesce((select max((select count(*)-cast(avg(b) AS integer) from t1)) from t1 where (c<c)),b)-t1.d))+max(c)*+count(distinct coalesce((select max((17)) from t1 where d in (select 11 from t1 union select 17 from t1)),t1.e))*count(*) when ~count(*) then cast(avg(d) AS integer) else max(t1.a) end*count(distinct c))) from t1))}
+} {}
+do_test randexpr-2.461 {
+ db eval {SELECT coalesce((select max(case when not ((select ((count(distinct t1.f)*(cast(avg(e) AS integer)))-min(t1.d)*min(t1.c)) from t1)*(select min(t1.d) from t1) not in ((select count(distinct b) from t1),f*d,19) and -a in (t1.d,b,a)) and d>=t1.c or t1.b>t1.c or 19 not between c and t1.e then 17 else t1.b end) from t1 where (e<=t1.b)),11) FROM t1 WHERE NOT (t1.a in (f,t1.d*+a,t1.c* -(select (abs(case +(max(coalesce((select max((select count(*)-cast(avg(b) AS integer) from t1)) from t1 where (c<c)),b)-t1.d))+max(c)*+count(distinct coalesce((select max((17)) from t1 where d in (select 11 from t1 union select 17 from t1)),t1.e))*count(*) when ~count(*) then cast(avg(d) AS integer) else max(t1.a) end*count(distinct c))) from t1)))}
+} {11}
+do_test randexpr-2.462 {
+ db eval {SELECT (case case when +c>e then case t1.d when 13 then t1.c else 19 end-13 else t1.e+coalesce((select max(19) from t1 where case when e in (+b,coalesce((select a+(11) from t1 where b not between c and d or t1.b not in (a,11,17)),b),11) then 19 when (c) not in (t1.c,t1.b,d) then t1.c else t1.d end*f not between t1.a and d),13) end when c then 11 else c end) FROM t1 WHERE 19 not between coalesce((select max(d*t1.c) from t1 where (select cast(avg((b)) AS integer) from t1) in (select ( - -(abs(case max(b) when cast(avg( -13-11) AS integer) then count(distinct a-e) else ~ -cast(avg((c)) AS integer)-min(17)+count(*) end) | (min(e)))-min((19))) from t1 union select count(distinct 13) from t1)),case when -e | 19 between -11 and f then 19 else 19 end) and (f)}
+} {}
+do_test randexpr-2.463 {
+ db eval {SELECT (case case when +c>e then case t1.d when 13 then t1.c else 19 end-13 else t1.e+coalesce((select max(19) from t1 where case when e in (+b,coalesce((select a+(11) from t1 where b not between c and d or t1.b not in (a,11,17)),b),11) then 19 when (c) not in (t1.c,t1.b,d) then t1.c else t1.d end*f not between t1.a and d),13) end when c then 11 else c end) FROM t1 WHERE NOT (19 not between coalesce((select max(d*t1.c) from t1 where (select cast(avg((b)) AS integer) from t1) in (select ( - -(abs(case max(b) when cast(avg( -13-11) AS integer) then count(distinct a-e) else ~ -cast(avg((c)) AS integer)-min(17)+count(*) end) | (min(e)))-min((19))) from t1 union select count(distinct 13) from t1)),case when -e | 19 between -11 and f then 19 else 19 end) and (f))}
+} {300}
+do_test randexpr-2.464 {
+ db eval {SELECT (abs((select abs(case -max(e)+max(t1.f)+(count(*)* -count(distinct case e when 19 then c else 13 end))*~min(t1.a) when cast(avg(t1.a) AS integer) then -min(e) else -count(*) end) from t1)*coalesce((select (t1.a) from t1 where case when c+t1.b-b | d in (select max(d) from t1 union select -max(19) from t1) then t1.b else f end=t1.d),t1.b)*(t1.d) | e+t1.a)/abs(t1.d)) FROM t1 WHERE t1.f in (19,d*t1.d,(select min((select count(*)*min((17)+(abs(11)/abs(+~coalesce((select max(f) from t1 where 13 not between t1.c and t1.a),t1.e)-11))) from t1)) from t1)+17)}
+} {}
+do_test randexpr-2.465 {
+ db eval {SELECT (abs((select abs(case -max(e)+max(t1.f)+(count(*)* -count(distinct case e when 19 then c else 13 end))*~min(t1.a) when cast(avg(t1.a) AS integer) then -min(e) else -count(*) end) from t1)*coalesce((select (t1.a) from t1 where case when c+t1.b-b | d in (select max(d) from t1 union select -max(19) from t1) then t1.b else f end=t1.d),t1.b)*(t1.d) | e+t1.a)/abs(t1.d)) FROM t1 WHERE NOT (t1.f in (19,d*t1.d,(select min((select count(*)*min((17)+(abs(11)/abs(+~coalesce((select max(f) from t1 where 13 not between t1.c and t1.a),t1.e)-11))) from t1)) from t1)+17))}
+} {201}
+do_test randexpr-2.466 {
+ db eval {SELECT (abs((select abs(case -max(e)+max(t1.f)+(count(*)* -count(distinct case e when 19 then c else 13 end))*~min(t1.a) when cast(avg(t1.a) AS integer) then -min(e) else -count(*) end) from t1)*coalesce((select (t1.a) from t1 where case when c+t1.b-b & d in (select max(d) from t1 union select -max(19) from t1) then t1.b else f end=t1.d),t1.b)*(t1.d) & e+t1.a)/abs(t1.d)) FROM t1 WHERE NOT (t1.f in (19,d*t1.d,(select min((select count(*)*min((17)+(abs(11)/abs(+~coalesce((select max(f) from t1 where 13 not between t1.c and t1.a),t1.e)-11))) from t1)) from t1)+17))}
+} {0}
+do_test randexpr-2.467 {
+ db eval {SELECT d+case when (coalesce((select max(t1.a) from t1 where t1.a not in (t1.d,f*(select count(distinct t1.d) from t1)+t1.f,c)),b)-c-17-t1.c)-case when 13*t1.a-19*e<>11 then f when t1.f not between 11 and t1.d then b else f end=t1.d then t1.f when not e>t1.f then 17 else b end FROM t1 WHERE exists(select 1 from t1 where 11* -d>=e) or t1.c<+ -e*11 or (17 not between t1.d and case t1.a when t1.a then t1.d+f-b else 11 end | t1.e)}
+} {417}
+do_test randexpr-2.468 {
+ db eval {SELECT d+case when (coalesce((select max(t1.a) from t1 where t1.a not in (t1.d,f*(select count(distinct t1.d) from t1)+t1.f,c)),b)-c-17-t1.c)-case when 13*t1.a-19*e<>11 then f when t1.f not between 11 and t1.d then b else f end=t1.d then t1.f when not e>t1.f then 17 else b end FROM t1 WHERE NOT (exists(select 1 from t1 where 11* -d>=e) or t1.c<+ -e*11 or (17 not between t1.d and case t1.a when t1.a then t1.d+f-b else 11 end | t1.e))}
+} {}
+do_test randexpr-2.469 {
+ db eval {SELECT t1.f-coalesce((select max(+e | b) from t1 where case when -(abs(11)/abs(~(19 | t1.d)))-~c*e not in (19,b*t1.b,b) then 11 when f<=13 then d else t1.d end in (select (count(*))-cast(avg(11 | 17*t1.b) AS integer) from t1 union select count(distinct a-17) from t1)),t1.c)-c FROM t1 WHERE case when (t1.f*a<=11+d+coalesce((select max(19+19) from t1 where 13 in (select min(f)+cast(avg((abs(t1.e)/abs((select count(distinct c) from t1)))) AS integer)+(~cast(avg(e) AS integer))-min(c) from t1 union select count(*) from t1)),b)) then (a) else t1.b end-t1.b<=t1.b and 13 in (select t1.e from t1 union select t1.e from t1) and a<e}
+} {}
+do_test randexpr-2.470 {
+ db eval {SELECT t1.f-coalesce((select max(+e | b) from t1 where case when -(abs(11)/abs(~(19 | t1.d)))-~c*e not in (19,b*t1.b,b) then 11 when f<=13 then d else t1.d end in (select (count(*))-cast(avg(11 | 17*t1.b) AS integer) from t1 union select count(distinct a-17) from t1)),t1.c)-c FROM t1 WHERE NOT (case when (t1.f*a<=11+d+coalesce((select max(19+19) from t1 where 13 in (select min(f)+cast(avg((abs(t1.e)/abs((select count(distinct c) from t1)))) AS integer)+(~cast(avg(e) AS integer))-min(c) from t1 union select count(*) from t1)),b)) then (a) else t1.b end-t1.b<=t1.b and 13 in (select t1.e from t1 union select t1.e from t1) and a<e)}
+} {0}
+do_test randexpr-2.471 {
+ db eval {SELECT t1.f-coalesce((select max(+e & b) from t1 where case when -(abs(11)/abs(~(19 & t1.d)))-~c*e not in (19,b*t1.b,b) then 11 when f<=13 then d else t1.d end in (select (count(*))-cast(avg(11 & 17*t1.b) AS integer) from t1 union select count(distinct a-17) from t1)),t1.c)-c FROM t1 WHERE NOT (case when (t1.f*a<=11+d+coalesce((select max(19+19) from t1 where 13 in (select min(f)+cast(avg((abs(t1.e)/abs((select count(distinct c) from t1)))) AS integer)+(~cast(avg(e) AS integer))-min(c) from t1 union select count(*) from t1)),b)) then (a) else t1.b end-t1.b<=t1.b and 13 in (select t1.e from t1 union select t1.e from t1) and a<e)}
+} {0}
+do_test randexpr-2.472 {
+ db eval {SELECT coalesce((select max(t1.c) from t1 where case when (t1.e*19*f-t1.b in (select cast(avg(d-~d) AS integer) from t1 union select +( -case +~count(*)*count(distinct (c)) when cast(avg(19) AS integer) then min(c) else count(distinct 17) end*cast(avg((13)) AS integer)-max(11)+(count(distinct b))) from t1)) then +11 else t1.b end>=t1.d or (exists(select 1 from t1 where (t1.e=t1.c)))),t1.c)-11 FROM t1 WHERE (not exists(select 1 from t1 where 11+t1.c-13>=t1.c or not exists(select 1 from t1 where a in (select b from t1 union select 19-d from t1) and ((abs(a+(abs(coalesce((select t1.d from t1 where exists(select 1 from t1 where case when t1.e>= -13 or -e<>f then d when t1.c=13 then (b) else t1.c end not between 13 and b)),d))/abs(t1.d))-b)/abs(t1.a))<> -13 and exists(select 1 from t1 where 19<>e) or 13>=19))))}
+} {}
+do_test randexpr-2.473 {
+ db eval {SELECT coalesce((select max(t1.c) from t1 where case when (t1.e*19*f-t1.b in (select cast(avg(d-~d) AS integer) from t1 union select +( -case +~count(*)*count(distinct (c)) when cast(avg(19) AS integer) then min(c) else count(distinct 17) end*cast(avg((13)) AS integer)-max(11)+(count(distinct b))) from t1)) then +11 else t1.b end>=t1.d or (exists(select 1 from t1 where (t1.e=t1.c)))),t1.c)-11 FROM t1 WHERE NOT ((not exists(select 1 from t1 where 11+t1.c-13>=t1.c or not exists(select 1 from t1 where a in (select b from t1 union select 19-d from t1) and ((abs(a+(abs(coalesce((select t1.d from t1 where exists(select 1 from t1 where case when t1.e>= -13 or -e<>f then d when t1.c=13 then (b) else t1.c end not between 13 and b)),d))/abs(t1.d))-b)/abs(t1.a))<> -13 and exists(select 1 from t1 where 19<>e) or 13>=19)))))}
+} {289}
+do_test randexpr-2.474 {
+ db eval {SELECT +coalesce((select max(11) from t1 where not case d+t1.c*coalesce((select max(coalesce((select d | e from t1 where 17 not between coalesce((select (t1.d) from t1 where t1.a between (select max(t1.b+d+t1.a) from t1)-t1.e and 17),t1.a) and 11),19)) from t1 where t1.d<t1.b),d)+t1.e when t1.f then t1.d else t1.f end not in (e,t1.c,t1.c)),c) | c FROM t1 WHERE exists(select 1 from t1 where c in (t1.a,(select count(distinct -t1.d) from t1),t1.b)) or (~d=t1.e)}
+} {}
+do_test randexpr-2.475 {
+ db eval {SELECT +coalesce((select max(11) from t1 where not case d+t1.c*coalesce((select max(coalesce((select d | e from t1 where 17 not between coalesce((select (t1.d) from t1 where t1.a between (select max(t1.b+d+t1.a) from t1)-t1.e and 17),t1.a) and 11),19)) from t1 where t1.d<t1.b),d)+t1.e when t1.f then t1.d else t1.f end not in (e,t1.c,t1.c)),c) | c FROM t1 WHERE NOT (exists(select 1 from t1 where c in (t1.a,(select count(distinct -t1.d) from t1),t1.b)) or (~d=t1.e))}
+} {300}
+do_test randexpr-2.476 {
+ db eval {SELECT +coalesce((select max(11) from t1 where not case d+t1.c*coalesce((select max(coalesce((select d & e from t1 where 17 not between coalesce((select (t1.d) from t1 where t1.a between (select max(t1.b+d+t1.a) from t1)-t1.e and 17),t1.a) and 11),19)) from t1 where t1.d<t1.b),d)+t1.e when t1.f then t1.d else t1.f end not in (e,t1.c,t1.c)),c) & c FROM t1 WHERE NOT (exists(select 1 from t1 where c in (t1.a,(select count(distinct -t1.d) from t1),t1.b)) or (~d=t1.e))}
+} {300}
+do_test randexpr-2.477 {
+ db eval {SELECT case when ((select -min(e)+cast(avg(t1.a) AS integer) from t1)>t1.d*a) then (abs(~a)/abs(+11))*f when (c-(coalesce((select 11 from t1 where t1.d in (case when (19)+11>=c then 19 when e<>b then 13 else c end,a,13)),17))+13) not between 11 and t1.c then (t1.b) else 17 end+b FROM t1 WHERE a*b*11 in (select case when not coalesce((select max(~13 | (select abs((count(distinct t1.f))*cast(avg(t1.f) AS integer)+(max(t1.e))) from t1)) from t1 where coalesce((select max(11) from t1 where t1.b=19),b) in (f,11,19) and t1.f between a and t1.c or 19=t1.a and d=17 or c>=t1.f or t1.d<>t1.c),11)*c in (select f from t1 union select -t1.b from t1) then t1.c when c not between f and 13 then e else -e end from t1 union select e from t1)}
+} {}
+do_test randexpr-2.478 {
+ db eval {SELECT case when ((select -min(e)+cast(avg(t1.a) AS integer) from t1)>t1.d*a) then (abs(~a)/abs(+11))*f when (c-(coalesce((select 11 from t1 where t1.d in (case when (19)+11>=c then 19 when e<>b then 13 else c end,a,13)),17))+13) not between 11 and t1.c then (t1.b) else 17 end+b FROM t1 WHERE NOT (a*b*11 in (select case when not coalesce((select max(~13 | (select abs((count(distinct t1.f))*cast(avg(t1.f) AS integer)+(max(t1.e))) from t1)) from t1 where coalesce((select max(11) from t1 where t1.b=19),b) in (f,11,19) and t1.f between a and t1.c or 19=t1.a and d=17 or c>=t1.f or t1.d<>t1.c),11)*c in (select f from t1 union select -t1.b from t1) then t1.c when c not between f and 13 then e else -e end from t1 union select e from t1))}
+} {217}
+do_test randexpr-2.479 {
+ db eval {SELECT t1.d-coalesce((select -t1.c from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where t1.d<=case t1.d+e when case when d>19 then 11+t1.c else t1.b end-t1.f-t1.e then (abs(t1.d-19*t1.b)/abs(13+case when t1.f in (select count(*)-count(distinct t1.b) from t1 union select (max((t1.f))) from t1) then (((t1.d))) when t1.b not in (t1.d,13,a) then t1.d else 19 end*t1.c))-t1.d else e end))),13)+c*t1.a FROM t1 WHERE exists(select 1 from t1 where ~coalesce((select a+t1.a from t1 where ~(abs(c)/abs(17 | +13))-t1.f in (select f from t1 union select case when t1.b between 11*e and f then e when a in (e* -t1.f-f,coalesce((select 17 from t1 where t1.e in (select (cast(avg(e) AS integer)) from t1 union select max(b) from t1)),a),d) then t1.c else (f) end from t1)),f) between -19 and (13) or t1.f<>t1.a)}
+} {30700}
+do_test randexpr-2.480 {
+ db eval {SELECT t1.d-coalesce((select -t1.c from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where t1.d<=case t1.d+e when case when d>19 then 11+t1.c else t1.b end-t1.f-t1.e then (abs(t1.d-19*t1.b)/abs(13+case when t1.f in (select count(*)-count(distinct t1.b) from t1 union select (max((t1.f))) from t1) then (((t1.d))) when t1.b not in (t1.d,13,a) then t1.d else 19 end*t1.c))-t1.d else e end))),13)+c*t1.a FROM t1 WHERE NOT (exists(select 1 from t1 where ~coalesce((select a+t1.a from t1 where ~(abs(c)/abs(17 | +13))-t1.f in (select f from t1 union select case when t1.b between 11*e and f then e when a in (e* -t1.f-f,coalesce((select 17 from t1 where t1.e in (select (cast(avg(e) AS integer)) from t1 union select max(b) from t1)),a),d) then t1.c else (f) end from t1)),f) between -19 and (13) or t1.f<>t1.a))}
+} {}
+do_test randexpr-2.481 {
+ db eval {SELECT (abs((abs(t1.b*t1.b*t1.f+a)/abs(t1.f))*t1.a-case -(abs(coalesce((select (case when 11*19 in (select count(*) from t1 union select -min(13)-(max(t1.a)) from t1) then 19 else -17 end) from t1 where t1.e between 13 and (a)),t1.b)+d)/abs(t1.f))-t1.b-t1.c | d when -t1.f then c else 17 end)/abs(13))-b*t1.d FROM t1 WHERE 13 in (t1.b,17*e+c*a,coalesce((select max(d) from t1 where +f+b not in (a,t1.a*~t1.c | t1.b-case when t1.a<=case when t1.f in (b,11,e) then d else t1.e end+f then 19 else (f) end-b*13- -t1.f-17,t1.c)),17))}
+} {}
+do_test randexpr-2.482 {
+ db eval {SELECT (abs((abs(t1.b*t1.b*t1.f+a)/abs(t1.f))*t1.a-case -(abs(coalesce((select (case when 11*19 in (select count(*) from t1 union select -min(13)-(max(t1.a)) from t1) then 19 else -17 end) from t1 where t1.e between 13 and (a)),t1.b)+d)/abs(t1.f))-t1.b-t1.c | d when -t1.f then c else 17 end)/abs(13))-b*t1.d FROM t1 WHERE NOT (13 in (t1.b,17*e+c*a,coalesce((select max(d) from t1 where +f+b not in (a,t1.a*~t1.c | t1.b-case when t1.a<=case when t1.f in (b,11,e) then d else t1.e end+f then 19 else (f) end-b*13- -t1.f-17,t1.c)),17)))}
+} {227691}
+do_test randexpr-2.483 {
+ db eval {SELECT (abs((abs(t1.b*t1.b*t1.f+a)/abs(t1.f))*t1.a-case -(abs(coalesce((select (case when 11*19 in (select count(*) from t1 union select -min(13)-(max(t1.a)) from t1) then 19 else -17 end) from t1 where t1.e between 13 and (a)),t1.b)+d)/abs(t1.f))-t1.b-t1.c & d when -t1.f then c else 17 end)/abs(13))-b*t1.d FROM t1 WHERE NOT (13 in (t1.b,17*e+c*a,coalesce((select max(d) from t1 where +f+b not in (a,t1.a*~t1.c | t1.b-case when t1.a<=case when t1.f in (b,11,e) then d else t1.e end+f then 19 else (f) end-b*13- -t1.f-17,t1.c)),17)))}
+} {227691}
+do_test randexpr-2.484 {
+ db eval {SELECT coalesce((select t1.c*f from t1 where t1.f-+coalesce((select max(t1.d) from t1 where - -t1.e in (select f from t1 union select t1.e from t1)),a)+case when 19 not in (t1.e,case when ~t1.a<>e+a then -t1.d else t1.e end,f) then t1.b when -(t1.e) in (e,(19),t1.c) then t1.f else e end+17*t1.c+d>b),t1.c)+a FROM t1 WHERE t1.b>=~b}
+} {180100}
+do_test randexpr-2.485 {
+ db eval {SELECT coalesce((select t1.c*f from t1 where t1.f-+coalesce((select max(t1.d) from t1 where - -t1.e in (select f from t1 union select t1.e from t1)),a)+case when 19 not in (t1.e,case when ~t1.a<>e+a then -t1.d else t1.e end,f) then t1.b when -(t1.e) in (e,(19),t1.c) then t1.f else e end+17*t1.c+d>b),t1.c)+a FROM t1 WHERE NOT (t1.b>=~b)}
+} {}
+do_test randexpr-2.486 {
+ db eval {SELECT case case when case when 13 between coalesce((select max(t1.f) from t1 where b+f in (b+(coalesce((select t1.f from t1 where (t1.c)>=17 or 19 not in (11,t1.e,c)),13)),b,t1.e) and c<=e and not t1.b<>13 and 19 not between t1.c and a or c between f and f),t1.c) and b then t1.b when 13<>t1.a then 11 else d end in (select 13 from t1 union select 19 from t1) then t1.c when t1.f not in (17,b,b) then t1.f else e end when t1.e then t1.e else -d end FROM t1 WHERE case when not exists(select 1 from t1 where t1.f not between coalesce((select coalesce((select max(+case t1.a when f then t1.a else t1.e end+case when t1.f>t1.d or 11 in (t1.e,11,b) then b else a end) from t1 where t1.f in (select a from t1 union select d from t1)),t1.d) from t1 where t1.a=b),(t1.c)) and d) then (select case max(t1.a) when ~min((11)) | min(e) then max(t1.e) else abs(max(t1.c)*count(distinct 19)) end from t1) else t1.b end<>b}
+} {}
+do_test randexpr-2.487 {
+ db eval {SELECT case case when case when 13 between coalesce((select max(t1.f) from t1 where b+f in (b+(coalesce((select t1.f from t1 where (t1.c)>=17 or 19 not in (11,t1.e,c)),13)),b,t1.e) and c<=e and not t1.b<>13 and 19 not between t1.c and a or c between f and f),t1.c) and b then t1.b when 13<>t1.a then 11 else d end in (select 13 from t1 union select 19 from t1) then t1.c when t1.f not in (17,b,b) then t1.f else e end when t1.e then t1.e else -d end FROM t1 WHERE NOT (case when not exists(select 1 from t1 where t1.f not between coalesce((select coalesce((select max(+case t1.a when f then t1.a else t1.e end+case when t1.f>t1.d or 11 in (t1.e,11,b) then b else a end) from t1 where t1.f in (select a from t1 union select d from t1)),t1.d) from t1 where t1.a=b),(t1.c)) and d) then (select case max(t1.a) when ~min((11)) | min(e) then max(t1.e) else abs(max(t1.c)*count(distinct 19)) end from t1) else t1.b end<>b)}
+} {-400}
+do_test randexpr-2.488 {
+ db eval {SELECT case -coalesce((select max(case when case when t1.e in (11*t1.e*17,(select (min(b) | - -+cast(avg(17) AS integer)*max((t1.c))+cast(avg(t1.a) AS integer))+(( -(min(t1.c))))*count(*) from t1), -~b*t1.d+t1.d) then d else t1.a end<(t1.c) then t1.f else e end) from t1 where 13<>c),e)-(t1.b) when t1.a then 17 else t1.f end FROM t1 WHERE coalesce((select max(t1.e) from t1 where (not exists(select 1 from t1 where b<+c))),case when b | ~case t1.a when -t1.b then -t1.f else t1.f end*f+f in (select t1.b from t1 union select t1.c from t1) then -(t1.f) when a<>11 then (d) else 11 end) in (select abs(~(abs(case (min(t1.b)*abs(count(distinct a)+count(*) | -count(distinct a)))- -max(19) when max(t1.e) then min(d) else (max(a)) end))) from t1 union select count(*) from t1)}
+} {}
+do_test randexpr-2.489 {
+ db eval {SELECT case -coalesce((select max(case when case when t1.e in (11*t1.e*17,(select (min(b) | - -+cast(avg(17) AS integer)*max((t1.c))+cast(avg(t1.a) AS integer))+(( -(min(t1.c))))*count(*) from t1), -~b*t1.d+t1.d) then d else t1.a end<(t1.c) then t1.f else e end) from t1 where 13<>c),e)-(t1.b) when t1.a then 17 else t1.f end FROM t1 WHERE NOT (coalesce((select max(t1.e) from t1 where (not exists(select 1 from t1 where b<+c))),case when b | ~case t1.a when -t1.b then -t1.f else t1.f end*f+f in (select t1.b from t1 union select t1.c from t1) then -(t1.f) when a<>11 then (d) else 11 end) in (select abs(~(abs(case (min(t1.b)*abs(count(distinct a)+count(*) | -count(distinct a)))- -max(19) when max(t1.e) then min(d) else (max(a)) end))) from t1 union select count(*) from t1))}
+} {600}
+do_test randexpr-2.490 {
+ db eval {SELECT case -coalesce((select max(case when case when t1.e in (11*t1.e*17,(select (min(b) & - -+cast(avg(17) AS integer)*max((t1.c))+cast(avg(t1.a) AS integer))+(( -(min(t1.c))))*count(*) from t1), -~b*t1.d+t1.d) then d else t1.a end<(t1.c) then t1.f else e end) from t1 where 13<>c),e)-(t1.b) when t1.a then 17 else t1.f end FROM t1 WHERE NOT (coalesce((select max(t1.e) from t1 where (not exists(select 1 from t1 where b<+c))),case when b | ~case t1.a when -t1.b then -t1.f else t1.f end*f+f in (select t1.b from t1 union select t1.c from t1) then -(t1.f) when a<>11 then (d) else 11 end) in (select abs(~(abs(case (min(t1.b)*abs(count(distinct a)+count(*) | -count(distinct a)))- -max(19) when max(t1.e) then min(d) else (max(a)) end))) from t1 union select count(*) from t1))}
+} {600}
+do_test randexpr-2.491 {
+ db eval {SELECT +case when case when ~t1.b<=case when ~17*19 | 11*11*f between t1.c and b then t1.a when e in (t1.a,t1.e,e) then t1.c else 19 end-t1.c-17+a then (t1.d) when 13 not between 13 and 19 then c else c end=(f) or d<t1.f then -t1.f else t1.d end FROM t1 WHERE 19*++t1.e=coalesce((select case -t1.f when case when d-t1.a*d*coalesce((select max(t1.d) from t1 where b-b> -coalesce((select t1.b from t1 where c*13+c<>t1.f),a)),t1.e)+t1.f=t1.f then - - -f else b end then -11 else -d end from t1 where ( -t1.c<f)),t1.e)+19}
+} {}
+do_test randexpr-2.492 {
+ db eval {SELECT +case when case when ~t1.b<=case when ~17*19 | 11*11*f between t1.c and b then t1.a when e in (t1.a,t1.e,e) then t1.c else 19 end-t1.c-17+a then (t1.d) when 13 not between 13 and 19 then c else c end=(f) or d<t1.f then -t1.f else t1.d end FROM t1 WHERE NOT (19*++t1.e=coalesce((select case -t1.f when case when d-t1.a*d*coalesce((select max(t1.d) from t1 where b-b> -coalesce((select t1.b from t1 where c*13+c<>t1.f),a)),t1.e)+t1.f=t1.f then - - -f else b end then -11 else -d end from t1 where ( -t1.c<f)),t1.e)+19)}
+} {-600}
+do_test randexpr-2.493 {
+ db eval {SELECT +case when case when ~t1.b<=case when ~17*19 & 11*11*f between t1.c and b then t1.a when e in (t1.a,t1.e,e) then t1.c else 19 end-t1.c-17+a then (t1.d) when 13 not between 13 and 19 then c else c end=(f) or d<t1.f then -t1.f else t1.d end FROM t1 WHERE NOT (19*++t1.e=coalesce((select case -t1.f when case when d-t1.a*d*coalesce((select max(t1.d) from t1 where b-b> -coalesce((select t1.b from t1 where c*13+c<>t1.f),a)),t1.e)+t1.f=t1.f then - - -f else b end then -11 else -d end from t1 where ( -t1.c<f)),t1.e)+19)}
+} {-600}
+do_test randexpr-2.494 {
+ db eval {SELECT case when case when 19 in (select abs(abs(count(distinct f))*~~~count(*)-abs(+abs(count(*))* -cast(avg(17) AS integer) | cast(avg(t1.d) AS integer))+count(distinct -t1.a)+count(*)) from t1 union select -cast(avg(19) AS integer) from t1) then b* -b-c else t1.e*c end=17 then d else coalesce((select -11 from t1 where e<e),a)-c end+d*t1.a FROM t1 WHERE (a-t1.b+19<>case when b between ~11 and (abs(case when (coalesce((select max(+13) from t1 where not not exists(select 1 from t1 where t1.b+e in (b,t1.b,t1.d)) and 13 not in (d,f,17)),t1.a) not in (t1.f,17,17)) then coalesce((select max(19) from t1 where (17) in (t1.a,17,a)),t1.b) when b in (13,t1.a,b) then t1.c else d end)/abs(11)) then t1.f when t1.d>19 then d else d end)}
+} {39800}
+do_test randexpr-2.495 {
+ db eval {SELECT case when case when 19 in (select abs(abs(count(distinct f))*~~~count(*)-abs(+abs(count(*))* -cast(avg(17) AS integer) | cast(avg(t1.d) AS integer))+count(distinct -t1.a)+count(*)) from t1 union select -cast(avg(19) AS integer) from t1) then b* -b-c else t1.e*c end=17 then d else coalesce((select -11 from t1 where e<e),a)-c end+d*t1.a FROM t1 WHERE NOT ((a-t1.b+19<>case when b between ~11 and (abs(case when (coalesce((select max(+13) from t1 where not not exists(select 1 from t1 where t1.b+e in (b,t1.b,t1.d)) and 13 not in (d,f,17)),t1.a) not in (t1.f,17,17)) then coalesce((select max(19) from t1 where (17) in (t1.a,17,a)),t1.b) when b in (13,t1.a,b) then t1.c else d end)/abs(11)) then t1.f when t1.d>19 then d else d end))}
+} {}
+do_test randexpr-2.496 {
+ db eval {SELECT case when case when 19 in (select abs(abs(count(distinct f))*~~~count(*)-abs(+abs(count(*))* -cast(avg(17) AS integer) & cast(avg(t1.d) AS integer))+count(distinct -t1.a)+count(*)) from t1 union select -cast(avg(19) AS integer) from t1) then b* -b-c else t1.e*c end=17 then d else coalesce((select -11 from t1 where e<e),a)-c end+d*t1.a FROM t1 WHERE (a-t1.b+19<>case when b between ~11 and (abs(case when (coalesce((select max(+13) from t1 where not not exists(select 1 from t1 where t1.b+e in (b,t1.b,t1.d)) and 13 not in (d,f,17)),t1.a) not in (t1.f,17,17)) then coalesce((select max(19) from t1 where (17) in (t1.a,17,a)),t1.b) when b in (13,t1.a,b) then t1.c else d end)/abs(11)) then t1.f when t1.d>19 then d else d end)}
+} {39800}
+do_test randexpr-2.497 {
+ db eval {SELECT t1.a-coalesce((select t1.e from t1 where not exists(select 1 from t1 where a in (select min(d-11) | cast(avg((select -case count(*) when count(*) then +abs(+case ~min((abs(13- -a)/abs(t1.c))) when ~~count(*)+min((13)) then max(t1.e) else cast(avg(t1.a) AS integer) end | max(c))+count(*) else count(*) end*max(t1.d) from t1)) AS integer)+max(t1.c)*count(distinct f) from t1 union select -count(*) from t1))),~17) FROM t1 WHERE case 11 when coalesce((select coalesce((select 19 from t1 where t1.b not between t1.e and e and not not exists(select 1 from t1 where (e in ((abs(c)/abs(17)),(d) | e,(select count(distinct t1.b) from t1)-b)))),case d when a then f else t1.c end) | (t1.d) | b from t1 where t1.c not in (t1.a,19,11)),t1.b)-d then t1.e else t1.d end*t1.d<>f}
+} {-400}
+do_test randexpr-2.498 {
+ db eval {SELECT t1.a-coalesce((select t1.e from t1 where not exists(select 1 from t1 where a in (select min(d-11) | cast(avg((select -case count(*) when count(*) then +abs(+case ~min((abs(13- -a)/abs(t1.c))) when ~~count(*)+min((13)) then max(t1.e) else cast(avg(t1.a) AS integer) end | max(c))+count(*) else count(*) end*max(t1.d) from t1)) AS integer)+max(t1.c)*count(distinct f) from t1 union select -count(*) from t1))),~17) FROM t1 WHERE NOT (case 11 when coalesce((select coalesce((select 19 from t1 where t1.b not between t1.e and e and not not exists(select 1 from t1 where (e in ((abs(c)/abs(17)),(d) | e,(select count(distinct t1.b) from t1)-b)))),case d when a then f else t1.c end) | (t1.d) | b from t1 where t1.c not in (t1.a,19,11)),t1.b)-d then t1.e else t1.d end*t1.d<>f)}
+} {}
+do_test randexpr-2.499 {
+ db eval {SELECT t1.a-coalesce((select t1.e from t1 where not exists(select 1 from t1 where a in (select min(d-11) & cast(avg((select -case count(*) when count(*) then +abs(+case ~min((abs(13- -a)/abs(t1.c))) when ~~count(*)+min((13)) then max(t1.e) else cast(avg(t1.a) AS integer) end & max(c))+count(*) else count(*) end*max(t1.d) from t1)) AS integer)+max(t1.c)*count(distinct f) from t1 union select -count(*) from t1))),~17) FROM t1 WHERE case 11 when coalesce((select coalesce((select 19 from t1 where t1.b not between t1.e and e and not not exists(select 1 from t1 where (e in ((abs(c)/abs(17)),(d) | e,(select count(distinct t1.b) from t1)-b)))),case d when a then f else t1.c end) | (t1.d) | b from t1 where t1.c not in (t1.a,19,11)),t1.b)-d then t1.e else t1.d end*t1.d<>f}
+} {-400}
+do_test randexpr-2.500 {
+ db eval {SELECT case b*coalesce((select coalesce((select max(coalesce((select t1.b from t1 where t1.a<>11),17+~19)) from t1 where (t1.e<>e)),case 13 when 17 then 13 else c-coalesce((select max(case when (select min(d) from t1) in (select max(13) from t1 union select min(t1.f) from t1) then 13 else t1.a end*c) from t1 where t1.b<(t1.b)),f) end) from t1 where 19<=t1.e),(t1.b)) when t1.b then e else t1.d end+t1.c FROM t1 WHERE b+coalesce((select max((d)) from t1 where e=b),t1.c)*((select -(min(coalesce((select 19+(abs((abs((t1.a)*case f when c then t1.b else t1.d end-e)/abs((t1.f))))/abs( -t1.e))+b from t1 where 13 not between d and t1.c),t1.f))) from t1))*case e when 19 then t1.d else t1.b end+t1.e not in (t1.d,t1.a,17)}
+} {700}
+do_test randexpr-2.501 {
+ db eval {SELECT case b*coalesce((select coalesce((select max(coalesce((select t1.b from t1 where t1.a<>11),17+~19)) from t1 where (t1.e<>e)),case 13 when 17 then 13 else c-coalesce((select max(case when (select min(d) from t1) in (select max(13) from t1 union select min(t1.f) from t1) then 13 else t1.a end*c) from t1 where t1.b<(t1.b)),f) end) from t1 where 19<=t1.e),(t1.b)) when t1.b then e else t1.d end+t1.c FROM t1 WHERE NOT (b+coalesce((select max((d)) from t1 where e=b),t1.c)*((select -(min(coalesce((select 19+(abs((abs((t1.a)*case f when c then t1.b else t1.d end-e)/abs((t1.f))))/abs( -t1.e))+b from t1 where 13 not between d and t1.c),t1.f))) from t1))*case e when 19 then t1.d else t1.b end+t1.e not in (t1.d,t1.a,17))}
+} {}
+do_test randexpr-2.502 {
+ db eval {SELECT case when case when exists(select 1 from t1 where 17 in (select b from t1 union select 13 from t1)) and 19+a in (select count(distinct -(select min(t1.a-f) from t1)) from t1 union select min(case when 11 between coalesce((select max(t1.b) from t1 where case when t1.d<>c or t1.b>=t1.a then ( -11) else t1.d end>=t1.a),t1.c) and -17 then -t1.f else e end) from t1) then a else 19 end+t1.e in (select e from t1 union select -t1.b from t1) then t1.b when not (f) between f and t1.c then t1.e else e end FROM t1 WHERE 17>coalesce((select t1.b from t1 where t1.a+case when b in (19,t1.c,case t1.e when d-(b) then t1.f else 13 end) then 13 when d in (select count(distinct t1.a) from t1 union select case ~max(f) when cast(avg(b) AS integer) then max(d) else min(t1.f) end*min(e) from t1) or (t1.c<a) then t1.f else -t1.c end<f or 13<=f),c) or 19>=t1.e}
+} {}
+do_test randexpr-2.503 {
+ db eval {SELECT case when case when exists(select 1 from t1 where 17 in (select b from t1 union select 13 from t1)) and 19+a in (select count(distinct -(select min(t1.a-f) from t1)) from t1 union select min(case when 11 between coalesce((select max(t1.b) from t1 where case when t1.d<>c or t1.b>=t1.a then ( -11) else t1.d end>=t1.a),t1.c) and -17 then -t1.f else e end) from t1) then a else 19 end+t1.e in (select e from t1 union select -t1.b from t1) then t1.b when not (f) between f and t1.c then t1.e else e end FROM t1 WHERE NOT (17>coalesce((select t1.b from t1 where t1.a+case when b in (19,t1.c,case t1.e when d-(b) then t1.f else 13 end) then 13 when d in (select count(distinct t1.a) from t1 union select case ~max(f) when cast(avg(b) AS integer) then max(d) else min(t1.f) end*min(e) from t1) or (t1.c<a) then t1.f else -t1.c end<f or 13<=f),c) or 19>=t1.e)}
+} {500}
+do_test randexpr-2.504 {
+ db eval {SELECT c*(select (count(distinct (abs(case when t1.c<>e then e else 19 end)/abs(case when case when +case when a | t1.e+t1.e in (select -count(*) from t1 union select (max(case when 11 not in (t1.f,11,f) then c when c not in (d,t1.f,t1.f) then -t1.a else 13 end)) from t1) then 17 else 13 end>=t1.e then -11 when (t1.f)>c then 11 else 11 end<=11 and not exists(select 1 from t1 where t1.a between t1.e and e) then 19 else (17) end)))) from t1) FROM t1 WHERE ((select -case min(a-13*17+c*coalesce((select 19 from t1 where 19>=t1.d),(t1.b))+t1.e) when +(min(17)) then min(17) else +min(b) end* -cast(avg(19) AS integer)*count(*) from t1) not between a and d) and +c in (c,t1.d,d) or d<>t1.f}
+} {300}
+do_test randexpr-2.505 {
+ db eval {SELECT c*(select (count(distinct (abs(case when t1.c<>e then e else 19 end)/abs(case when case when +case when a | t1.e+t1.e in (select -count(*) from t1 union select (max(case when 11 not in (t1.f,11,f) then c when c not in (d,t1.f,t1.f) then -t1.a else 13 end)) from t1) then 17 else 13 end>=t1.e then -11 when (t1.f)>c then 11 else 11 end<=11 and not exists(select 1 from t1 where t1.a between t1.e and e) then 19 else (17) end)))) from t1) FROM t1 WHERE NOT (((select -case min(a-13*17+c*coalesce((select 19 from t1 where 19>=t1.d),(t1.b))+t1.e) when +(min(17)) then min(17) else +min(b) end* -cast(avg(19) AS integer)*count(*) from t1) not between a and d) and +c in (c,t1.d,d) or d<>t1.f)}
+} {}
+do_test randexpr-2.506 {
+ db eval {SELECT c*(select (count(distinct (abs(case when t1.c<>e then e else 19 end)/abs(case when case when +case when a & t1.e+t1.e in (select -count(*) from t1 union select (max(case when 11 not in (t1.f,11,f) then c when c not in (d,t1.f,t1.f) then -t1.a else 13 end)) from t1) then 17 else 13 end>=t1.e then -11 when (t1.f)>c then 11 else 11 end<=11 and not exists(select 1 from t1 where t1.a between t1.e and e) then 19 else (17) end)))) from t1) FROM t1 WHERE ((select -case min(a-13*17+c*coalesce((select 19 from t1 where 19>=t1.d),(t1.b))+t1.e) when +(min(17)) then min(17) else +min(b) end* -cast(avg(19) AS integer)*count(*) from t1) not between a and d) and +c in (c,t1.d,d) or d<>t1.f}
+} {300}
+do_test randexpr-2.507 {
+ db eval {SELECT a*coalesce((select t1.d+17 from t1 where 13*case a when t1.a then 11 else -t1.a-d-11-coalesce((select max(e-coalesce((select d from t1 where a<=t1.d*(coalesce((select max( -t1.d) from t1 where t1.f not in (11, -t1.d,17) and t1.a between (13) and c and e not in (t1.b,t1.b,b)),b))), -17)) from t1 where t1.b<>a),19)+t1.d+t1.c end<13),t1.e) FROM t1 WHERE t1.e not between f and 19}
+} {50000}
+do_test randexpr-2.508 {
+ db eval {SELECT a*coalesce((select t1.d+17 from t1 where 13*case a when t1.a then 11 else -t1.a-d-11-coalesce((select max(e-coalesce((select d from t1 where a<=t1.d*(coalesce((select max( -t1.d) from t1 where t1.f not in (11, -t1.d,17) and t1.a between (13) and c and e not in (t1.b,t1.b,b)),b))), -17)) from t1 where t1.b<>a),19)+t1.d+t1.c end<13),t1.e) FROM t1 WHERE NOT (t1.e not between f and 19)}
+} {}
+do_test randexpr-2.509 {
+ db eval {SELECT 17 | case case when exists(select 1 from t1 where (not t1.d between a and f)) then t1.e when not (b=coalesce((select ~t1.c-case when (select (count(*))*(count(distinct t1.f)) from t1)>=11 then b else 19 end from t1 where not not (13<=e) and t1.b=t1.b),13)) then coalesce((select max((abs(11)/abs(t1.b))) from t1 where t1.a not between t1.e and t1.b),(t1.a)) else t1.a end when c then 13 else 19 end+b FROM t1 WHERE ~t1.a+t1.d+c*17 | (select max(t1.d)*abs(case (max(t1.f)+count(distinct t1.b))*(count(distinct f)) when count(distinct e) then -min(t1.e) else min(t1.f) end)+max(b)+count(distinct t1.d) from t1) in (select max(t1.d*(19)) from t1 union select count(distinct case when t1.c+b in (select max(e) from t1 union select cast(avg(f) AS integer) from t1) then (17) when e not in (c,d,19) or 11=19 then (19) else t1.e end+t1.a) from t1)}
+} {}
+do_test randexpr-2.510 {
+ db eval {SELECT 17 | case case when exists(select 1 from t1 where (not t1.d between a and f)) then t1.e when not (b=coalesce((select ~t1.c-case when (select (count(*))*(count(distinct t1.f)) from t1)>=11 then b else 19 end from t1 where not not (13<=e) and t1.b=t1.b),13)) then coalesce((select max((abs(11)/abs(t1.b))) from t1 where t1.a not between t1.e and t1.b),(t1.a)) else t1.a end when c then 13 else 19 end+b FROM t1 WHERE NOT (~t1.a+t1.d+c*17 | (select max(t1.d)*abs(case (max(t1.f)+count(distinct t1.b))*(count(distinct f)) when count(distinct e) then -min(t1.e) else min(t1.f) end)+max(b)+count(distinct t1.d) from t1) in (select max(t1.d*(19)) from t1 union select count(distinct case when t1.c+b in (select max(e) from t1 union select cast(avg(f) AS integer) from t1) then (17) when e not in (c,d,19) or 11=19 then (19) else t1.e end+t1.a) from t1))}
+} {219}
+do_test randexpr-2.511 {
+ db eval {SELECT 17 & case case when exists(select 1 from t1 where (not t1.d between a and f)) then t1.e when not (b=coalesce((select ~t1.c-case when (select (count(*))*(count(distinct t1.f)) from t1)>=11 then b else 19 end from t1 where not not (13<=e) and t1.b=t1.b),13)) then coalesce((select max((abs(11)/abs(t1.b))) from t1 where t1.a not between t1.e and t1.b),(t1.a)) else t1.a end when c then 13 else 19 end+b FROM t1 WHERE NOT (~t1.a+t1.d+c*17 | (select max(t1.d)*abs(case (max(t1.f)+count(distinct t1.b))*(count(distinct f)) when count(distinct e) then -min(t1.e) else min(t1.f) end)+max(b)+count(distinct t1.d) from t1) in (select max(t1.d*(19)) from t1 union select count(distinct case when t1.c+b in (select max(e) from t1 union select cast(avg(f) AS integer) from t1) then (17) when e not in (c,d,19) or 11=19 then (19) else t1.e end+t1.a) from t1))}
+} {17}
+do_test randexpr-2.512 {
+ db eval {SELECT case when coalesce((select max((+t1.a+17+11+case when (abs(19)/abs(t1.a)) in (select ~(case count(*) when min( -c) then count(distinct b) else count(*) end) from t1 union select -min(t1.e) from t1) or 13>=t1.a then case c when 13 then t1.d else e end when -t1.e<=t1.a then t1.c else t1.c end)) from t1 where not t1.c= -t1.f),b)=f and t1.e<=(t1.f) then ~(t1.a) when 17=e then 19 else t1.b end FROM t1 WHERE case when -t1.f in (select (13) from t1 union select coalesce((select max(coalesce((select (~13) from t1 where t1.b>(11)),e*t1.c)) from t1 where (not (abs(t1.c)/abs(a))>=c)),t1.d) from t1) then -t1.e+ -a-coalesce((select t1.d from t1 where not exists(select 1 from t1 where -b=t1.f-f)),t1.c)*17 when 19<=11 then 19 else t1.d end>=b}
+} {200}
+do_test randexpr-2.513 {
+ db eval {SELECT case when coalesce((select max((+t1.a+17+11+case when (abs(19)/abs(t1.a)) in (select ~(case count(*) when min( -c) then count(distinct b) else count(*) end) from t1 union select -min(t1.e) from t1) or 13>=t1.a then case c when 13 then t1.d else e end when -t1.e<=t1.a then t1.c else t1.c end)) from t1 where not t1.c= -t1.f),b)=f and t1.e<=(t1.f) then ~(t1.a) when 17=e then 19 else t1.b end FROM t1 WHERE NOT (case when -t1.f in (select (13) from t1 union select coalesce((select max(coalesce((select (~13) from t1 where t1.b>(11)),e*t1.c)) from t1 where (not (abs(t1.c)/abs(a))>=c)),t1.d) from t1) then -t1.e+ -a-coalesce((select t1.d from t1 where not exists(select 1 from t1 where -b=t1.f-f)),t1.c)*17 when 19<=11 then 19 else t1.d end>=b)}
+} {}
+do_test randexpr-2.514 {
+ db eval {SELECT +(case when t1.a<=a then t1.d when ((abs(t1.a)/abs((coalesce((select t1.e from t1 where t1.f>=t1.c),e))))) between coalesce((select case when not 19> -11 then (case when t1.d in (select e from t1 union select f from t1) then -d when t1.b not between 11 and t1.d then (19) else c end) else t1.e end from t1 where not exists(select 1 from t1 where e not in (t1.d,a, -a)) and t1.d>t1.b),a) and t1.a then d else b end)-17 FROM t1 WHERE (+e*t1.d in (select (+abs(abs(min(~+b)-min(a)-case -case abs(max(t1.c)) when max(e) then count(*) else count(distinct 19) end- -max(t1.a) when count(distinct t1.a) then (count(*)) else min(t1.f) end)))-(count(*)) from t1 union select max(t1.f) from t1) or ~c*case when not exists(select 1 from t1 where t1.f in (t1.f,t1.a,d)) then t1.c when t1.c<t1.d then (17) else e end+t1.b | -((c)) not between a and 17)}
+} {383}
+do_test randexpr-2.515 {
+ db eval {SELECT +(case when t1.a<=a then t1.d when ((abs(t1.a)/abs((coalesce((select t1.e from t1 where t1.f>=t1.c),e))))) between coalesce((select case when not 19> -11 then (case when t1.d in (select e from t1 union select f from t1) then -d when t1.b not between 11 and t1.d then (19) else c end) else t1.e end from t1 where not exists(select 1 from t1 where e not in (t1.d,a, -a)) and t1.d>t1.b),a) and t1.a then d else b end)-17 FROM t1 WHERE NOT ((+e*t1.d in (select (+abs(abs(min(~+b)-min(a)-case -case abs(max(t1.c)) when max(e) then count(*) else count(distinct 19) end- -max(t1.a) when count(distinct t1.a) then (count(*)) else min(t1.f) end)))-(count(*)) from t1 union select max(t1.f) from t1) or ~c*case when not exists(select 1 from t1 where t1.f in (t1.f,t1.a,d)) then t1.c when t1.c<t1.d then (17) else e end+t1.b | -((c)) not between a and 17))}
+} {}
+do_test randexpr-2.516 {
+ db eval {SELECT -case when coalesce((select max(case when ~(+case when t1.b*t1.b>t1.e then t1.a when -d=t1.e or t1.c not between t1.c and e then c else t1.d end)- -17 in (select a from t1 union select -t1.e from t1) then 19 else a end) from t1 where t1.a in (select -a from t1 union select 19 from t1)),t1.a)<>t1.d then 13 when a in (19,d,c) and a<11 then t1.a else b end+t1.a-t1.b FROM t1 WHERE c>=t1.e}
+} {}
+do_test randexpr-2.517 {
+ db eval {SELECT -case when coalesce((select max(case when ~(+case when t1.b*t1.b>t1.e then t1.a when -d=t1.e or t1.c not between t1.c and e then c else t1.d end)- -17 in (select a from t1 union select -t1.e from t1) then 19 else a end) from t1 where t1.a in (select -a from t1 union select 19 from t1)),t1.a)<>t1.d then 13 when a in (19,d,c) and a<11 then t1.a else b end+t1.a-t1.b FROM t1 WHERE NOT (c>=t1.e)}
+} {-113}
+do_test randexpr-2.518 {
+ db eval {SELECT coalesce((select case coalesce((select max(19) from t1 where +case when exists(select 1 from t1 where not exists(select 1 from t1 where not c in (case when e>=c then b else t1.b end,t1.b,t1.e))) then a-f+13-t1.f+19 when f>=t1.e then t1.e else t1.c end+17 in (select count(distinct 19) from t1 union select cast(avg(b) AS integer) | count(distinct 11)-count(*) from t1)),a) when b then 17 else c end from t1 where t1.f<=t1.e),t1.e) FROM t1 WHERE ~~+d-d*19*case ~(select count(*) from t1)-11 when 19 then -+(abs(t1.a)/abs(a)) | (f)-(abs(+t1.c)/abs((select ~+max(13*e)+min(f)*count(distinct 13) from t1)))*t1.a else -t1.f-t1.b end*t1.a not between -e and t1.e}
+} {500}
+do_test randexpr-2.519 {
+ db eval {SELECT coalesce((select case coalesce((select max(19) from t1 where +case when exists(select 1 from t1 where not exists(select 1 from t1 where not c in (case when e>=c then b else t1.b end,t1.b,t1.e))) then a-f+13-t1.f+19 when f>=t1.e then t1.e else t1.c end+17 in (select count(distinct 19) from t1 union select cast(avg(b) AS integer) | count(distinct 11)-count(*) from t1)),a) when b then 17 else c end from t1 where t1.f<=t1.e),t1.e) FROM t1 WHERE NOT (~~+d-d*19*case ~(select count(*) from t1)-11 when 19 then -+(abs(t1.a)/abs(a)) | (f)-(abs(+t1.c)/abs((select ~+max(13*e)+min(f)*count(distinct 13) from t1)))*t1.a else -t1.f-t1.b end*t1.a not between -e and t1.e)}
+} {}
+do_test randexpr-2.520 {
+ db eval {SELECT coalesce((select case coalesce((select max(19) from t1 where +case when exists(select 1 from t1 where not exists(select 1 from t1 where not c in (case when e>=c then b else t1.b end,t1.b,t1.e))) then a-f+13-t1.f+19 when f>=t1.e then t1.e else t1.c end+17 in (select count(distinct 19) from t1 union select cast(avg(b) AS integer) & count(distinct 11)-count(*) from t1)),a) when b then 17 else c end from t1 where t1.f<=t1.e),t1.e) FROM t1 WHERE ~~+d-d*19*case ~(select count(*) from t1)-11 when 19 then -+(abs(t1.a)/abs(a)) | (f)-(abs(+t1.c)/abs((select ~+max(13*e)+min(f)*count(distinct 13) from t1)))*t1.a else -t1.f-t1.b end*t1.a not between -e and t1.e}
+} {500}
+do_test randexpr-2.521 {
+ db eval {SELECT a*17+ -case when not exists(select 1 from t1 where 11=t1.d) then 11-b when case when t1.c<>t1.c++t1.a or t1.c*t1.a+d-f between 19 and case when not t1.e>=11 and t1.b<=t1.c then coalesce((select max(a) from t1 where 19=11),f) when f not in (t1.b,13,b) then f else -d end then d else t1.c end in (select 17 from t1 union select d from t1) then 17 else b end FROM t1 WHERE -(+~ -d++c+b)>=t1.a-case when coalesce((select t1.a-(select max(t1.e) from t1)-(abs(11)/abs(17))+t1.d from t1 where not (not exists(select 1 from t1 where c=t1.c)) or t1.b in (select abs(max(11)+count(*)) from t1 union select ((max(a))) from t1)),f)>=a then t1.f when d not in (11,c,17) then a else 19 end}
+} {}
+do_test randexpr-2.522 {
+ db eval {SELECT a*17+ -case when not exists(select 1 from t1 where 11=t1.d) then 11-b when case when t1.c<>t1.c++t1.a or t1.c*t1.a+d-f between 19 and case when not t1.e>=11 and t1.b<=t1.c then coalesce((select max(a) from t1 where 19=11),f) when f not in (t1.b,13,b) then f else -d end then d else t1.c end in (select 17 from t1 union select d from t1) then 17 else b end FROM t1 WHERE NOT ( -(+~ -d++c+b)>=t1.a-case when coalesce((select t1.a-(select max(t1.e) from t1)-(abs(11)/abs(17))+t1.d from t1 where not (not exists(select 1 from t1 where c=t1.c)) or t1.b in (select abs(max(11)+count(*)) from t1 union select ((max(a))) from t1)),f)>=a then t1.f when d not in (11,c,17) then a else 19 end)}
+} {1889}
+do_test randexpr-2.523 {
+ db eval {SELECT coalesce((select max(t1.b+a) from t1 where case (select count(distinct b*case when t1.f*+~a | b+17*13+a+11 in (select c from t1 union select d from t1) then t1.f else t1.b end) from t1) when t1.a then f else t1.c end+ -f between 17 and d and b in (13,t1.e,t1.e) and d not between t1.f and d),13) FROM t1 WHERE coalesce((select max(t1.d) from t1 where (coalesce((select ~t1.c from t1 where -t1.a<=c*+d or not (case when (t1.b)>=t1.d then t1.e when 17<d then (a) else 11 end>a and a<>e and t1.e<t1.e) or 19<=t1.c),(c))+b*t1.c+17*t1.a | 11+(t1.f)>=19)),19)<>t1.c}
+} {13}
+do_test randexpr-2.524 {
+ db eval {SELECT coalesce((select max(t1.b+a) from t1 where case (select count(distinct b*case when t1.f*+~a | b+17*13+a+11 in (select c from t1 union select d from t1) then t1.f else t1.b end) from t1) when t1.a then f else t1.c end+ -f between 17 and d and b in (13,t1.e,t1.e) and d not between t1.f and d),13) FROM t1 WHERE NOT (coalesce((select max(t1.d) from t1 where (coalesce((select ~t1.c from t1 where -t1.a<=c*+d or not (case when (t1.b)>=t1.d then t1.e when 17<d then (a) else 11 end>a and a<>e and t1.e<t1.e) or 19<=t1.c),(c))+b*t1.c+17*t1.a | 11+(t1.f)>=19)),19)<>t1.c)}
+} {}
+do_test randexpr-2.525 {
+ db eval {SELECT coalesce((select max(t1.b+a) from t1 where case (select count(distinct b*case when t1.f*+~a & b+17*13+a+11 in (select c from t1 union select d from t1) then t1.f else t1.b end) from t1) when t1.a then f else t1.c end+ -f between 17 and d and b in (13,t1.e,t1.e) and d not between t1.f and d),13) FROM t1 WHERE coalesce((select max(t1.d) from t1 where (coalesce((select ~t1.c from t1 where -t1.a<=c*+d or not (case when (t1.b)>=t1.d then t1.e when 17<d then (a) else 11 end>a and a<>e and t1.e<t1.e) or 19<=t1.c),(c))+b*t1.c+17*t1.a | 11+(t1.f)>=19)),19)<>t1.c}
+} {13}
+do_test randexpr-2.526 {
+ db eval {SELECT coalesce((select (t1.b-(abs(t1.b-~17 | 13+13)/abs(t1.e))* -t1.a- -19+t1.d) from t1 where exists(select 1 from t1 where 19 in (select t1.a from t1 union select -19 from t1) and a in (c,e,13) and 19 in (select t1.a from t1 union select b from t1) or 13 in (select 19 from t1 union select d from t1) and not t1.c=t1.f or ( -t1.d between e and 19) or -((17))<>c)),e) FROM t1 WHERE ((abs(a)/abs(f-a)) between -(abs(++t1.b)/abs(13)) and t1.c)}
+} {619}
+do_test randexpr-2.527 {
+ db eval {SELECT coalesce((select (t1.b-(abs(t1.b-~17 | 13+13)/abs(t1.e))* -t1.a- -19+t1.d) from t1 where exists(select 1 from t1 where 19 in (select t1.a from t1 union select -19 from t1) and a in (c,e,13) and 19 in (select t1.a from t1 union select b from t1) or 13 in (select 19 from t1 union select d from t1) and not t1.c=t1.f or ( -t1.d between e and 19) or -((17))<>c)),e) FROM t1 WHERE NOT (((abs(a)/abs(f-a)) between -(abs(++t1.b)/abs(13)) and t1.c))}
+} {}
+do_test randexpr-2.528 {
+ db eval {SELECT coalesce((select (t1.b-(abs(t1.b-~17 & 13+13)/abs(t1.e))* -t1.a- -19+t1.d) from t1 where exists(select 1 from t1 where 19 in (select t1.a from t1 union select -19 from t1) and a in (c,e,13) and 19 in (select t1.a from t1 union select b from t1) or 13 in (select 19 from t1 union select d from t1) and not t1.c=t1.f or ( -t1.d between e and 19) or -((17))<>c)),e) FROM t1 WHERE ((abs(a)/abs(f-a)) between -(abs(++t1.b)/abs(13)) and t1.c)}
+} {619}
+do_test randexpr-2.529 {
+ db eval {SELECT case when coalesce((select max(c- -b-t1.c) from t1 where t1.d between 11 and case when b | ~t1.e*(t1.f)>t1.f then a when (19<13) and not exists(select 1 from t1 where f not in (t1.a,((b)),17)) or d in ((a),t1.c,19) or (f)>13 then t1.e else f end*t1.a),t1.a)>=e then t1.d when t1.e>=c then 13 else f end FROM t1 WHERE +11 between case when t1.f>t1.c then t1.b else t1.b end and ((select count(distinct case when t1.a between (abs(coalesce((select t1.b from t1 where case when t1.d<=(abs((c))/abs(coalesce((select max(17) from t1 where 11=b),13))) then 17 when b=t1.e then d else e end-13>=(e)), -d))/abs(b)) and b then t1.d when (b) in (13,t1.b,t1.a) then f else 19 end) from t1))-d}
+} {}
+do_test randexpr-2.530 {
+ db eval {SELECT case when coalesce((select max(c- -b-t1.c) from t1 where t1.d between 11 and case when b | ~t1.e*(t1.f)>t1.f then a when (19<13) and not exists(select 1 from t1 where f not in (t1.a,((b)),17)) or d in ((a),t1.c,19) or (f)>13 then t1.e else f end*t1.a),t1.a)>=e then t1.d when t1.e>=c then 13 else f end FROM t1 WHERE NOT (+11 between case when t1.f>t1.c then t1.b else t1.b end and ((select count(distinct case when t1.a between (abs(coalesce((select t1.b from t1 where case when t1.d<=(abs((c))/abs(coalesce((select max(17) from t1 where 11=b),13))) then 17 when b=t1.e then d else e end-13>=(e)), -d))/abs(b)) and b then t1.d when (b) in (13,t1.b,t1.a) then f else 19 end) from t1))-d)}
+} {13}
+do_test randexpr-2.531 {
+ db eval {SELECT case when coalesce((select max(c- -b-t1.c) from t1 where t1.d between 11 and case when b & ~t1.e*(t1.f)>t1.f then a when (19<13) and not exists(select 1 from t1 where f not in (t1.a,((b)),17)) or d in ((a),t1.c,19) or (f)>13 then t1.e else f end*t1.a),t1.a)>=e then t1.d when t1.e>=c then 13 else f end FROM t1 WHERE NOT (+11 between case when t1.f>t1.c then t1.b else t1.b end and ((select count(distinct case when t1.a between (abs(coalesce((select t1.b from t1 where case when t1.d<=(abs((c))/abs(coalesce((select max(17) from t1 where 11=b),13))) then 17 when b=t1.e then d else e end-13>=(e)), -d))/abs(b)) and b then t1.d when (b) in (13,t1.b,t1.a) then f else 19 end) from t1))-d)}
+} {13}
+do_test randexpr-2.532 {
+ db eval {SELECT (select ~abs(max(case when (case when ( -t1.a>e) then t1.a else (select (~count(*) | max(case when t1.d<>c then -+13 else case when b between 19 and 17 or (t1.a)>=13 then 19 else t1.c end end)) from t1) end<>t1.e) then 19 when c*e+t1.b<=19 then f else (t1.d) end | b)) from t1)+c FROM t1 WHERE f | t1.a+b>=t1.d}
+} {80}
+do_test randexpr-2.533 {
+ db eval {SELECT (select ~abs(max(case when (case when ( -t1.a>e) then t1.a else (select (~count(*) | max(case when t1.d<>c then -+13 else case when b between 19 and 17 or (t1.a)>=13 then 19 else t1.c end end)) from t1) end<>t1.e) then 19 when c*e+t1.b<=19 then f else (t1.d) end | b)) from t1)+c FROM t1 WHERE NOT (f | t1.a+b>=t1.d)}
+} {}
+do_test randexpr-2.534 {
+ db eval {SELECT (select ~abs(max(case when (case when ( -t1.a>e) then t1.a else (select (~count(*) & max(case when t1.d<>c then -+13 else case when b between 19 and 17 or (t1.a)>=13 then 19 else t1.c end end)) from t1) end<>t1.e) then 19 when c*e+t1.b<=19 then f else (t1.d) end & b)) from t1)+c FROM t1 WHERE f | t1.a+b>=t1.d}
+} {299}
+do_test randexpr-2.535 {
+ db eval {SELECT -case when ~case t1.f+13+t1.a when coalesce((select max(17) from t1 where coalesce((select max(( -11)) from t1 where not exists(select 1 from t1 where case case when not exists(select 1 from t1 where (a in (select f from t1 union select b from t1))) then d when (a) in (f,t1.a, -f) then t1.a else b end when t1.d then c else t1.b end<>a and 11= -t1.a and 19=a)),11) in (select c from t1 union select 17 from t1)),t1.c) then e else 11 end=t1.d then 17 else 17 end FROM t1 WHERE not exists(select 1 from t1 where f<d or exists(select 1 from t1 where ~t1.a not between coalesce((select max(case b+(select -case max(t1.b)- -count(distinct c)*max(t1.b) when min(17) then (count(*)) else cast(avg(t1.d) AS integer) end*max(f) from t1)+case when (abs((abs(19)/abs(e)))/abs(t1.d))*t1.a not between b and 13 then e else (e) end when d then b else 17 end) from t1 where t1.c between b and t1.f),t1.b) and a))}
+} {}
+do_test randexpr-2.536 {
+ db eval {SELECT -case when ~case t1.f+13+t1.a when coalesce((select max(17) from t1 where coalesce((select max(( -11)) from t1 where not exists(select 1 from t1 where case case when not exists(select 1 from t1 where (a in (select f from t1 union select b from t1))) then d when (a) in (f,t1.a, -f) then t1.a else b end when t1.d then c else t1.b end<>a and 11= -t1.a and 19=a)),11) in (select c from t1 union select 17 from t1)),t1.c) then e else 11 end=t1.d then 17 else 17 end FROM t1 WHERE NOT (not exists(select 1 from t1 where f<d or exists(select 1 from t1 where ~t1.a not between coalesce((select max(case b+(select -case max(t1.b)- -count(distinct c)*max(t1.b) when min(17) then (count(*)) else cast(avg(t1.d) AS integer) end*max(f) from t1)+case when (abs((abs(19)/abs(e)))/abs(t1.d))*t1.a not between b and 13 then e else (e) end when d then b else 17 end) from t1 where t1.c between b and t1.f),t1.b) and a)))}
+} {-17}
+do_test randexpr-2.537 {
+ db eval {SELECT t1.f-t1.b | coalesce((select max((select max(case -case when t1.f>coalesce((select max(case when (17> -t1.e) then f when 19=t1.a then t1.a else a end) from t1 where t1.c<=t1.e or (t1.d)>=t1.d),t1.a)+a then f when b not in (e,t1.e,t1.b) or t1.f not in (f,t1.c, -d) or e<=13 then f else (17) end-t1.d+t1.f*13 when (t1.c) then b else -t1.e end) from t1)) from t1 where t1.b in (t1.b,t1.f,(t1.e))),t1.e)*(a) FROM t1 WHERE t1.f<=a}
+} {}
+do_test randexpr-2.538 {
+ db eval {SELECT t1.f-t1.b | coalesce((select max((select max(case -case when t1.f>coalesce((select max(case when (17> -t1.e) then f when 19=t1.a then t1.a else a end) from t1 where t1.c<=t1.e or (t1.d)>=t1.d),t1.a)+a then f when b not in (e,t1.e,t1.b) or t1.f not in (f,t1.c, -d) or e<=13 then f else (17) end-t1.d+t1.f*13 when (t1.c) then b else -t1.e end) from t1)) from t1 where t1.b in (t1.b,t1.f,(t1.e))),t1.e)*(a) FROM t1 WHERE NOT (t1.f<=a)}
+} {-49744}
+do_test randexpr-2.539 {
+ db eval {SELECT t1.f-t1.b & coalesce((select max((select max(case -case when t1.f>coalesce((select max(case when (17> -t1.e) then f when 19=t1.a then t1.a else a end) from t1 where t1.c<=t1.e or (t1.d)>=t1.d),t1.a)+a then f when b not in (e,t1.e,t1.b) or t1.f not in (f,t1.c, -d) or e<=13 then f else (17) end-t1.d+t1.f*13 when (t1.c) then b else -t1.e end) from t1)) from t1 where t1.b in (t1.b,t1.f,(t1.e))),t1.e)*(a) FROM t1 WHERE NOT (t1.f<=a)}
+} {144}
+do_test randexpr-2.540 {
+ db eval {SELECT t1.e+t1.a*case when not t1.f<=d-(c)*13 then t1.e+13*(abs(case when exists(select 1 from t1 where (select -count(*)* -max(t1.a) | ((((cast(avg((e)) AS integer))))) from t1)>=+c+b) then +11 when t1.a not between t1.c and c then t1.b else -19 end)/abs(b)) | (19) when not exists(select 1 from t1 where t1.c between t1.e and t1.c) then d else t1.f end FROM t1 WHERE b in (+c,case b when f*~19-t1.b*t1.f then t1.f else a end,a | t1.a)}
+} {}
+do_test randexpr-2.541 {
+ db eval {SELECT t1.e+t1.a*case when not t1.f<=d-(c)*13 then t1.e+13*(abs(case when exists(select 1 from t1 where (select -count(*)* -max(t1.a) | ((((cast(avg((e)) AS integer))))) from t1)>=+c+b) then +11 when t1.a not between t1.c and c then t1.b else -19 end)/abs(b)) | (19) when not exists(select 1 from t1 where t1.c between t1.e and t1.c) then d else t1.f end FROM t1 WHERE NOT (b in (+c,case b when f*~19-t1.b*t1.f then t1.f else a end,a | t1.a))}
+} {50800}
+do_test randexpr-2.542 {
+ db eval {SELECT t1.e+t1.a*case when not t1.f<=d-(c)*13 then t1.e+13*(abs(case when exists(select 1 from t1 where (select -count(*)* -max(t1.a) & ((((cast(avg((e)) AS integer))))) from t1)>=+c+b) then +11 when t1.a not between t1.c and c then t1.b else -19 end)/abs(b)) & (19) when not exists(select 1 from t1 where t1.c between t1.e and t1.c) then d else t1.f end FROM t1 WHERE NOT (b in (+c,case b when f*~19-t1.b*t1.f then t1.f else a end,a | t1.a))}
+} {600}
+do_test randexpr-2.543 {
+ db eval {SELECT t1.e++a-c-a+coalesce((select t1.e from t1 where 11=case when t1.f not between 13 and t1.b+a*t1.c then 17 when (select min((select cast(avg(17) AS integer)*max(d)-(cast(avg(c) AS integer))*count(distinct t1.b) from t1)) from t1)>=case coalesce((select t1.b | e from t1 where t1.d in (t1.c,17,t1.c)),a) when 13 then t1.a else 19 end then t1.a else e end),t1.d) FROM t1 WHERE +t1.a*t1.c between case when case coalesce((select max(+t1.f-t1.b*(select min((b))+count(distinct c) from t1)) from t1 where -b between 11 and t1.b or b in (select -max(19) from t1 union select -count(*)+ -count(*) from t1) and 17=d),13)-t1.b*a when t1.b then (17) else c end>b then e else 11 end and ( -b) or t1.e not between a and 11}
+} {600}
+do_test randexpr-2.544 {
+ db eval {SELECT t1.e++a-c-a+coalesce((select t1.e from t1 where 11=case when t1.f not between 13 and t1.b+a*t1.c then 17 when (select min((select cast(avg(17) AS integer)*max(d)-(cast(avg(c) AS integer))*count(distinct t1.b) from t1)) from t1)>=case coalesce((select t1.b | e from t1 where t1.d in (t1.c,17,t1.c)),a) when 13 then t1.a else 19 end then t1.a else e end),t1.d) FROM t1 WHERE NOT (+t1.a*t1.c between case when case coalesce((select max(+t1.f-t1.b*(select min((b))+count(distinct c) from t1)) from t1 where -b between 11 and t1.b or b in (select -max(19) from t1 union select -count(*)+ -count(*) from t1) and 17=d),13)-t1.b*a when t1.b then (17) else c end>b then e else 11 end and ( -b) or t1.e not between a and 11)}
+} {}
+do_test randexpr-2.545 {
+ db eval {SELECT t1.e++a-c-a+coalesce((select t1.e from t1 where 11=case when t1.f not between 13 and t1.b+a*t1.c then 17 when (select min((select cast(avg(17) AS integer)*max(d)-(cast(avg(c) AS integer))*count(distinct t1.b) from t1)) from t1)>=case coalesce((select t1.b & e from t1 where t1.d in (t1.c,17,t1.c)),a) when 13 then t1.a else 19 end then t1.a else e end),t1.d) FROM t1 WHERE +t1.a*t1.c between case when case coalesce((select max(+t1.f-t1.b*(select min((b))+count(distinct c) from t1)) from t1 where -b between 11 and t1.b or b in (select -max(19) from t1 union select -count(*)+ -count(*) from t1) and 17=d),13)-t1.b*a when t1.b then (17) else c end>b then e else 11 end and ( -b) or t1.e not between a and 11}
+} {600}
+do_test randexpr-2.546 {
+ db eval {SELECT (select case ~case count(*) when (count(distinct d)*min(17)+min(13)+min(11))-max(t1.a) then count(distinct -13) else min(t1.c) end-max( - -t1.d)*count(*) when -count(*) then count(*) else (cast(avg(e) AS integer)) end from t1)-case when a>b then t1.d+case when (e= -t1.a) and c<c then coalesce((select t1.f+f from t1 where t1.b not in (f,13,t1.b)),t1.d) else d end+ -t1.a-c+e else 19 end FROM t1 WHERE t1.b not between a and 11 and t1.c in (select +case count(*) when count(*)*cast(avg(13) AS integer) then min(~b-c-t1.e*(abs(a)/abs(case when t1.d>=(13) and t1.e<=c then 11 else t1.f end | t1.a)))-abs(abs(count(*)))-+~min(t1.e)+~count(distinct 11)* -count(*) | max(t1.d)-( -cast(avg(13) AS integer))*(min(e)) else -min(t1.a) end from t1 union select max(t1.f) from t1)}
+} {}
+do_test randexpr-2.547 {
+ db eval {SELECT (select case ~case count(*) when (count(distinct d)*min(17)+min(13)+min(11))-max(t1.a) then count(distinct -13) else min(t1.c) end-max( - -t1.d)*count(*) when -count(*) then count(*) else (cast(avg(e) AS integer)) end from t1)-case when a>b then t1.d+case when (e= -t1.a) and c<c then coalesce((select t1.f+f from t1 where t1.b not in (f,13,t1.b)),t1.d) else d end+ -t1.a-c+e else 19 end FROM t1 WHERE NOT (t1.b not between a and 11 and t1.c in (select +case count(*) when count(*)*cast(avg(13) AS integer) then min(~b-c-t1.e*(abs(a)/abs(case when t1.d>=(13) and t1.e<=c then 11 else t1.f end | t1.a)))-abs(abs(count(*)))-+~min(t1.e)+~count(distinct 11)* -count(*) | max(t1.d)-( -cast(avg(13) AS integer))*(min(e)) else -min(t1.a) end from t1 union select max(t1.f) from t1))}
+} {481}
+do_test randexpr-2.548 {
+ db eval {SELECT case ~case 19 when t1.e then f else 19*f end*case when exists(select 1 from t1 where t1.e not between t1.f-~case case -e when f then t1.d else case when t1.b in (t1.e,f,11) then e when 11<=d then -t1.d else 17 end end when 13 then 19 else c end and 19) then coalesce((select t1.b from t1 where not exists(select 1 from t1 where (a<>b))),b) else t1.c end | e+t1.b when a then f else 19 end FROM t1 WHERE 17 in (select count(distinct t1.f)+~min(coalesce((select max(e*f-case when case when 11<>e and t1.e<=t1.d or (t1.d)<=t1.e then d when ( -17) not between -t1.c and t1.a then coalesce((select max((19)) from t1 where -b between e and 11), -a) else d end in (b,t1.d,a) and 19 in (13,13,t1.c) or b not in (f,(t1.e),19) then t1.c when 17 not in ((19),(t1.b),f) then +t1.d else f end) from t1 where (not a between 19 and d and (d>a))),d)) from t1 union select cast(avg(f) AS integer) from t1)}
+} {}
+do_test randexpr-2.549 {
+ db eval {SELECT case ~case 19 when t1.e then f else 19*f end*case when exists(select 1 from t1 where t1.e not between t1.f-~case case -e when f then t1.d else case when t1.b in (t1.e,f,11) then e when 11<=d then -t1.d else 17 end end when 13 then 19 else c end and 19) then coalesce((select t1.b from t1 where not exists(select 1 from t1 where (a<>b))),b) else t1.c end | e+t1.b when a then f else 19 end FROM t1 WHERE NOT (17 in (select count(distinct t1.f)+~min(coalesce((select max(e*f-case when case when 11<>e and t1.e<=t1.d or (t1.d)<=t1.e then d when ( -17) not between -t1.c and t1.a then coalesce((select max((19)) from t1 where -b between e and 11), -a) else d end in (b,t1.d,a) and 19 in (13,13,t1.c) or b not in (f,(t1.e),19) then t1.c when 17 not in ((19),(t1.b),f) then +t1.d else f end) from t1 where (not a between 19 and d and (d>a))),d)) from t1 union select cast(avg(f) AS integer) from t1))}
+} {19}
+do_test randexpr-2.550 {
+ db eval {SELECT case ~case 19 when t1.e then f else 19*f end*case when exists(select 1 from t1 where t1.e not between t1.f-~case case -e when f then t1.d else case when t1.b in (t1.e,f,11) then e when 11<=d then -t1.d else 17 end end when 13 then 19 else c end and 19) then coalesce((select t1.b from t1 where not exists(select 1 from t1 where (a<>b))),b) else t1.c end & e+t1.b when a then f else 19 end FROM t1 WHERE NOT (17 in (select count(distinct t1.f)+~min(coalesce((select max(e*f-case when case when 11<>e and t1.e<=t1.d or (t1.d)<=t1.e then d when ( -17) not between -t1.c and t1.a then coalesce((select max((19)) from t1 where -b between e and 11), -a) else d end in (b,t1.d,a) and 19 in (13,13,t1.c) or b not in (f,(t1.e),19) then t1.c when 17 not in ((19),(t1.b),f) then +t1.d else f end) from t1 where (not a between 19 and d and (d>a))),d)) from t1 union select cast(avg(f) AS integer) from t1))}
+} {19}
+do_test randexpr-2.551 {
+ db eval {SELECT (abs(11*coalesce((select max(t1.a) from t1 where d>=case when coalesce((select case when not exists(select 1 from t1 where -d in (select b-(abs(13)/abs(t1.e)) from t1 union select e from t1)) then ~c when not exists(select 1 from t1 where not exists(select 1 from t1 where -t1.d in (select cast(avg(c) AS integer) | count(distinct e)+max( -t1.d)-(max(f)) from t1 union select count(*) from t1))) then t1.a else e end from t1 where exists(select 1 from t1 where t1.f between d and t1.b) or 17 in (11,17,d)),11) not between t1.c and t1.d then 17 when 13=t1.a then 19 else (13) end), -t1.b)-e)/abs(a)) FROM t1 WHERE t1.c+t1.c=t1.f}
+} {6}
+do_test randexpr-2.552 {
+ db eval {SELECT (abs(11*coalesce((select max(t1.a) from t1 where d>=case when coalesce((select case when not exists(select 1 from t1 where -d in (select b-(abs(13)/abs(t1.e)) from t1 union select e from t1)) then ~c when not exists(select 1 from t1 where not exists(select 1 from t1 where -t1.d in (select cast(avg(c) AS integer) | count(distinct e)+max( -t1.d)-(max(f)) from t1 union select count(*) from t1))) then t1.a else e end from t1 where exists(select 1 from t1 where t1.f between d and t1.b) or 17 in (11,17,d)),11) not between t1.c and t1.d then 17 when 13=t1.a then 19 else (13) end), -t1.b)-e)/abs(a)) FROM t1 WHERE NOT (t1.c+t1.c=t1.f)}
+} {}
+do_test randexpr-2.553 {
+ db eval {SELECT (abs(11*coalesce((select max(t1.a) from t1 where d>=case when coalesce((select case when not exists(select 1 from t1 where -d in (select b-(abs(13)/abs(t1.e)) from t1 union select e from t1)) then ~c when not exists(select 1 from t1 where not exists(select 1 from t1 where -t1.d in (select cast(avg(c) AS integer) & count(distinct e)+max( -t1.d)-(max(f)) from t1 union select count(*) from t1))) then t1.a else e end from t1 where exists(select 1 from t1 where t1.f between d and t1.b) or 17 in (11,17,d)),11) not between t1.c and t1.d then 17 when 13=t1.a then 19 else (13) end), -t1.b)-e)/abs(a)) FROM t1 WHERE t1.c+t1.c=t1.f}
+} {6}
+do_test randexpr-2.554 {
+ db eval {SELECT -t1.a*coalesce((select max(c) from t1 where -(17 | case when (select cast(avg(17+coalesce((select max(c) from t1 where exists(select 1 from t1 where (coalesce((select max( -f) from t1 where (t1.b<=t1.b)),t1.e)<>e))),f | -t1.a)) AS integer) from t1) in (13,e,t1.c) then f when (f>e) then b else t1.a end)*c*e not between 19 and t1.b),11)+13-19*(19) FROM t1 WHERE (c<=t1.e)}
+} {-30348}
+do_test randexpr-2.555 {
+ db eval {SELECT -t1.a*coalesce((select max(c) from t1 where -(17 | case when (select cast(avg(17+coalesce((select max(c) from t1 where exists(select 1 from t1 where (coalesce((select max( -f) from t1 where (t1.b<=t1.b)),t1.e)<>e))),f | -t1.a)) AS integer) from t1) in (13,e,t1.c) then f when (f>e) then b else t1.a end)*c*e not between 19 and t1.b),11)+13-19*(19) FROM t1 WHERE NOT ((c<=t1.e))}
+} {}
+do_test randexpr-2.556 {
+ db eval {SELECT -t1.a*coalesce((select max(c) from t1 where -(17 & case when (select cast(avg(17+coalesce((select max(c) from t1 where exists(select 1 from t1 where (coalesce((select max( -f) from t1 where (t1.b<=t1.b)),t1.e)<>e))),f & -t1.a)) AS integer) from t1) in (13,e,t1.c) then f when (f>e) then b else t1.a end)*c*e not between 19 and t1.b),11)+13-19*(19) FROM t1 WHERE (c<=t1.e)}
+} {-30348}
+do_test randexpr-2.557 {
+ db eval {SELECT 19-coalesce((select max(case when 17 | t1.a in (select case case coalesce((select max(t1.b) from t1 where t1.f not between case when -b in (13,f,a) then a else a end and t1.f or (a not in (d,d,t1.c))),c) when a then t1.e else f end when 13 then 13 else b end from t1 union select 17 from t1) then c when not b not in (d, -t1.e,c) then 17 else b end) from t1 where e not in (17,t1.e,b)),t1.e) FROM t1 WHERE t1.a in (select -count(*) from t1 union select min((select (cast(avg((select +max(t1.b) from t1)) AS integer)) from t1)+17*c) from t1)}
+} {}
+do_test randexpr-2.558 {
+ db eval {SELECT 19-coalesce((select max(case when 17 | t1.a in (select case case coalesce((select max(t1.b) from t1 where t1.f not between case when -b in (13,f,a) then a else a end and t1.f or (a not in (d,d,t1.c))),c) when a then t1.e else f end when 13 then 13 else b end from t1 union select 17 from t1) then c when not b not in (d, -t1.e,c) then 17 else b end) from t1 where e not in (17,t1.e,b)),t1.e) FROM t1 WHERE NOT (t1.a in (select -count(*) from t1 union select min((select (cast(avg((select +max(t1.b) from t1)) AS integer)) from t1)+17*c) from t1))}
+} {-481}
+do_test randexpr-2.559 {
+ db eval {SELECT 19-coalesce((select max(case when 17 & t1.a in (select case case coalesce((select max(t1.b) from t1 where t1.f not between case when -b in (13,f,a) then a else a end and t1.f or (a not in (d,d,t1.c))),c) when a then t1.e else f end when 13 then 13 else b end from t1 union select 17 from t1) then c when not b not in (d, -t1.e,c) then 17 else b end) from t1 where e not in (17,t1.e,b)),t1.e) FROM t1 WHERE NOT (t1.a in (select -count(*) from t1 union select min((select (cast(avg((select +max(t1.b) from t1)) AS integer)) from t1)+17*c) from t1))}
+} {-481}
+do_test randexpr-2.560 {
+ db eval {SELECT -f-coalesce((select max(case a-t1.a when t1.f then 13 else +t1.a-t1.f end) from t1 where (select count(distinct a) from t1)>d),( -~t1.a+17+case when (not exists(select 1 from t1 where c=t1.b and c>t1.d)) then ~coalesce((select t1.f from t1 where t1.e not between t1.b and t1.e),11)+a when b<=t1.d then t1.c else 11 end+t1.b)*d)*17+d FROM t1 WHERE +t1.c in (select max(~case when 17>t1.f then 19 else -case when d=11 or t1.b> -t1.e or d not in (b,t1.a,t1.e) then e-( -13)+d else 11 end end-t1.d) from t1 union select max(17)+case min(t1.a) | case + -case abs(cast(avg(t1.d) AS integer)) when -count(*) then count(*) else max(19) end when min(e) then count(*) else cast(avg(t1.c) AS integer) end when min(t1.f) then count(*) else min(b) end from t1)}
+} {}
+do_test randexpr-2.561 {
+ db eval {SELECT -f-coalesce((select max(case a-t1.a when t1.f then 13 else +t1.a-t1.f end) from t1 where (select count(distinct a) from t1)>d),( -~t1.a+17+case when (not exists(select 1 from t1 where c=t1.b and c>t1.d)) then ~coalesce((select t1.f from t1 where t1.e not between t1.b and t1.e),11)+a when b<=t1.d then t1.c else 11 end+t1.b)*d)*17+d FROM t1 WHERE NOT (+t1.c in (select max(~case when 17>t1.f then 19 else -case when d=11 or t1.b> -t1.e or d not in (b,t1.a,t1.e) then e-( -13)+d else 11 end end-t1.d) from t1 union select max(17)+case min(t1.a) | case + -case abs(cast(avg(t1.d) AS integer)) when -count(*) then count(*) else max(19) end when min(e) then count(*) else cast(avg(t1.c) AS integer) end when min(t1.f) then count(*) else min(b) end from t1))}
+} {-2761000}
+do_test randexpr-2.562 {
+ db eval {SELECT coalesce((select 11 from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not (select +count(*)* -count(distinct case when exists(select 1 from t1 where 13+a=t1.b) then d else 13 end-t1.b) from t1)<=17 | e-13)) or not exists(select 1 from t1 where not t1.e in ((13),17,19) and not t1.d>a and t1.e not between t1.e and b)),coalesce((select max(coalesce((select max(b) from t1 where (b)>11),d)) from t1 where 11> -19),f)-c) FROM t1 WHERE case when -13 not in (b,(abs(coalesce((select max(case when -17<>t1.f then b when coalesce((select t1.b from t1 where t1.c in (select (a) from t1 union select c from t1)),17)<=t1.e then b else f end) from t1 where b<=11),t1.c))/abs((d))),19) then t1.b when (exists(select 1 from t1 where not exists(select 1 from t1 where ((13)=e and t1.f between 17 and t1.a) or t1.f between (a) and -(t1.f)))) and t1.e between b and 13 or b<>(f) then t1.f else d end>=a or d>=13}
+} {11}
+do_test randexpr-2.563 {
+ db eval {SELECT coalesce((select 11 from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not (select +count(*)* -count(distinct case when exists(select 1 from t1 where 13+a=t1.b) then d else 13 end-t1.b) from t1)<=17 | e-13)) or not exists(select 1 from t1 where not t1.e in ((13),17,19) and not t1.d>a and t1.e not between t1.e and b)),coalesce((select max(coalesce((select max(b) from t1 where (b)>11),d)) from t1 where 11> -19),f)-c) FROM t1 WHERE NOT (case when -13 not in (b,(abs(coalesce((select max(case when -17<>t1.f then b when coalesce((select t1.b from t1 where t1.c in (select (a) from t1 union select c from t1)),17)<=t1.e then b else f end) from t1 where b<=11),t1.c))/abs((d))),19) then t1.b when (exists(select 1 from t1 where not exists(select 1 from t1 where ((13)=e and t1.f between 17 and t1.a) or t1.f between (a) and -(t1.f)))) and t1.e between b and 13 or b<>(f) then t1.f else d end>=a or d>=13)}
+} {}
+do_test randexpr-2.564 {
+ db eval {SELECT coalesce((select 11 from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not (select +count(*)* -count(distinct case when exists(select 1 from t1 where 13+a=t1.b) then d else 13 end-t1.b) from t1)<=17 & e-13)) or not exists(select 1 from t1 where not t1.e in ((13),17,19) and not t1.d>a and t1.e not between t1.e and b)),coalesce((select max(coalesce((select max(b) from t1 where (b)>11),d)) from t1 where 11> -19),f)-c) FROM t1 WHERE case when -13 not in (b,(abs(coalesce((select max(case when -17<>t1.f then b when coalesce((select t1.b from t1 where t1.c in (select (a) from t1 union select c from t1)),17)<=t1.e then b else f end) from t1 where b<=11),t1.c))/abs((d))),19) then t1.b when (exists(select 1 from t1 where not exists(select 1 from t1 where ((13)=e and t1.f between 17 and t1.a) or t1.f between (a) and -(t1.f)))) and t1.e between b and 13 or b<>(f) then t1.f else d end>=a or d>=13}
+} {11}
+do_test randexpr-2.565 {
+ db eval {SELECT coalesce((select max(coalesce((select max(13+f | c+a) from t1 where 17<t1.a),~case when 17 in (select count(distinct 11) from t1 union select ++cast(avg(a | 11) AS integer)-count(*) from t1) then t1.a else 17 end)) from t1 where case t1.d when 17 then t1.a else 17 end not between 13 and case t1.c when t1.b*case when t1.d<>d then 13 else c end-c then e else t1.e end),c) FROM t1 WHERE exists(select 1 from t1 where t1.a+( -case when exists(select 1 from t1 where exists(select 1 from t1 where b | c-c+t1.d not between 19 and 11)) then coalesce((select t1.c from t1 where c+17 in (f,13,c) or t1.e*coalesce((select case when (not exists(select 1 from t1 where 17>e)) then t1.d else ~t1.e end from t1 where (t1.f not in (19,a,t1.b) or c=f)),c)=c), -11) else e end)<=t1.b)}
+} {300}
+do_test randexpr-2.566 {
+ db eval {SELECT coalesce((select max(coalesce((select max(13+f | c+a) from t1 where 17<t1.a),~case when 17 in (select count(distinct 11) from t1 union select ++cast(avg(a | 11) AS integer)-count(*) from t1) then t1.a else 17 end)) from t1 where case t1.d when 17 then t1.a else 17 end not between 13 and case t1.c when t1.b*case when t1.d<>d then 13 else c end-c then e else t1.e end),c) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.a+( -case when exists(select 1 from t1 where exists(select 1 from t1 where b | c-c+t1.d not between 19 and 11)) then coalesce((select t1.c from t1 where c+17 in (f,13,c) or t1.e*coalesce((select case when (not exists(select 1 from t1 where 17>e)) then t1.d else ~t1.e end from t1 where (t1.f not in (19,a,t1.b) or c=f)),c)=c), -11) else e end)<=t1.b))}
+} {}
+do_test randexpr-2.567 {
+ db eval {SELECT coalesce((select max(coalesce((select max(13+f & c+a) from t1 where 17<t1.a),~case when 17 in (select count(distinct 11) from t1 union select ++cast(avg(a & 11) AS integer)-count(*) from t1) then t1.a else 17 end)) from t1 where case t1.d when 17 then t1.a else 17 end not between 13 and case t1.c when t1.b*case when t1.d<>d then 13 else c end-c then e else t1.e end),c) FROM t1 WHERE exists(select 1 from t1 where t1.a+( -case when exists(select 1 from t1 where exists(select 1 from t1 where b | c-c+t1.d not between 19 and 11)) then coalesce((select t1.c from t1 where c+17 in (f,13,c) or t1.e*coalesce((select case when (not exists(select 1 from t1 where 17>e)) then t1.d else ~t1.e end from t1 where (t1.f not in (19,a,t1.b) or c=f)),c)=c), -11) else e end)<=t1.b)}
+} {300}
+do_test randexpr-2.568 {
+ db eval {SELECT case when ((coalesce((select max((select ~cast(avg((~d*f)) AS integer) from t1)) from t1 where - -t1.f<>d),e) in (select cast(avg(+13) AS integer)*~count(*) | case count(*) when -abs(abs(max(f))) then cast(avg(e) AS integer) else (count(distinct b)) end from t1 union select count(*) from t1) and b>= -t1.d)) then (17) when b between 13 and t1.d then -e+t1.a else t1.f end FROM t1 WHERE (case when +t1.f-(select abs(count(distinct d)) from t1)*case when c in (select min(b) from t1 union select max(c+f*case 11*t1.b when b then t1.c else c end | t1.a) from t1) then d else f end | t1.a*b in (t1.d,17,a) then -t1.a else t1.d end) in (e,t1.c,f) and -((t1.c)) in (11,t1.e,t1.c)}
+} {}
+do_test randexpr-2.569 {
+ db eval {SELECT case when ((coalesce((select max((select ~cast(avg((~d*f)) AS integer) from t1)) from t1 where - -t1.f<>d),e) in (select cast(avg(+13) AS integer)*~count(*) | case count(*) when -abs(abs(max(f))) then cast(avg(e) AS integer) else (count(distinct b)) end from t1 union select count(*) from t1) and b>= -t1.d)) then (17) when b between 13 and t1.d then -e+t1.a else t1.f end FROM t1 WHERE NOT ((case when +t1.f-(select abs(count(distinct d)) from t1)*case when c in (select min(b) from t1 union select max(c+f*case 11*t1.b when b then t1.c else c end | t1.a) from t1) then d else f end | t1.a*b in (t1.d,17,a) then -t1.a else t1.d end) in (e,t1.c,f) and -((t1.c)) in (11,t1.e,t1.c))}
+} {-400}
+do_test randexpr-2.570 {
+ db eval {SELECT case when ((coalesce((select max((select ~cast(avg((~d*f)) AS integer) from t1)) from t1 where - -t1.f<>d),e) in (select cast(avg(+13) AS integer)*~count(*) & case count(*) when -abs(abs(max(f))) then cast(avg(e) AS integer) else (count(distinct b)) end from t1 union select count(*) from t1) and b>= -t1.d)) then (17) when b between 13 and t1.d then -e+t1.a else t1.f end FROM t1 WHERE NOT ((case when +t1.f-(select abs(count(distinct d)) from t1)*case when c in (select min(b) from t1 union select max(c+f*case 11*t1.b when b then t1.c else c end | t1.a) from t1) then d else f end | t1.a*b in (t1.d,17,a) then -t1.a else t1.d end) in (e,t1.c,f) and -((t1.c)) in (11,t1.e,t1.c))}
+} {-400}
+do_test randexpr-2.571 {
+ db eval {SELECT t1.d-case when e in (17,coalesce((select max((select count(*) from t1)) from t1 where (~t1.f++19*t1.f+b in (a,t1.b, -t1.e)) and b in (select count(distinct t1.a) from t1 union select (abs(abs(abs(max(t1.e)*max(t1.d))-min(11)* -count(*)))) from t1)),17),13) and t1.f in (select t1.b from t1 union select f from t1) then t1.c else c end+f FROM t1 WHERE not (select (abs(abs((+count(*)*~ -cast(avg(+t1.f-c) AS integer)*count(distinct +coalesce((select max((abs(c)/abs(t1.e))) from t1 where coalesce((select coalesce((select max(f) from t1 where t1.d<=t1.d),e)*c from t1 where t1.f<>f),c) not between t1.a and c),t1.e)+13)-count(distinct f) | abs(cast(avg(t1.b) AS integer)))))) from t1)-13<t1.c}
+} {700}
+do_test randexpr-2.572 {
+ db eval {SELECT t1.d-case when e in (17,coalesce((select max((select count(*) from t1)) from t1 where (~t1.f++19*t1.f+b in (a,t1.b, -t1.e)) and b in (select count(distinct t1.a) from t1 union select (abs(abs(abs(max(t1.e)*max(t1.d))-min(11)* -count(*)))) from t1)),17),13) and t1.f in (select t1.b from t1 union select f from t1) then t1.c else c end+f FROM t1 WHERE NOT (not (select (abs(abs((+count(*)*~ -cast(avg(+t1.f-c) AS integer)*count(distinct +coalesce((select max((abs(c)/abs(t1.e))) from t1 where coalesce((select coalesce((select max(f) from t1 where t1.d<=t1.d),e)*c from t1 where t1.f<>f),c) not between t1.a and c),t1.e)+13)-count(distinct f) | abs(cast(avg(t1.b) AS integer)))))) from t1)-13<t1.c)}
+} {}
+do_test randexpr-2.573 {
+ db eval {SELECT (abs(t1.f*case when (abs(t1.f+17-(t1.a*11*(abs(d)/abs(coalesce((select max(11) from t1 where e=a-t1.a or e not between 17 and 11 or (t1.f)>=c or f<>e),+d))) | t1.c*b+t1.d)- -f)/abs(13))<>t1.e then -t1.e when t1.e not between f and t1.a then t1.c else t1.c end)/abs(t1.e)) FROM t1 WHERE (abs(b*t1.e+t1.a)/abs(t1.c))<case when 13 in (coalesce((select max(~(abs( -11*t1.a)/abs(c))+t1.e) from t1 where t1.d in (f,c,(f))),f)-f,b,t1.b) then e when not exists(select 1 from t1 where f in (select max(19) from t1 union select cast(avg(t1.e) AS integer)- -min(11) | abs((cast(avg(t1.d) AS integer))) from t1)) then d else d end and e<e}
+} {}
+do_test randexpr-2.574 {
+ db eval {SELECT (abs(t1.f*case when (abs(t1.f+17-(t1.a*11*(abs(d)/abs(coalesce((select max(11) from t1 where e=a-t1.a or e not between 17 and 11 or (t1.f)>=c or f<>e),+d))) | t1.c*b+t1.d)- -f)/abs(13))<>t1.e then -t1.e when t1.e not between f and t1.a then t1.c else t1.c end)/abs(t1.e)) FROM t1 WHERE NOT ((abs(b*t1.e+t1.a)/abs(t1.c))<case when 13 in (coalesce((select max(~(abs( -11*t1.a)/abs(c))+t1.e) from t1 where t1.d in (f,c,(f))),f)-f,b,t1.b) then e when not exists(select 1 from t1 where f in (select max(19) from t1 union select cast(avg(t1.e) AS integer)- -min(11) | abs((cast(avg(t1.d) AS integer))) from t1)) then d else d end and e<e)}
+} {600}
+do_test randexpr-2.575 {
+ db eval {SELECT (abs(t1.f*case when (abs(t1.f+17-(t1.a*11*(abs(d)/abs(coalesce((select max(11) from t1 where e=a-t1.a or e not between 17 and 11 or (t1.f)>=c or f<>e),+d))) & t1.c*b+t1.d)- -f)/abs(13))<>t1.e then -t1.e when t1.e not between f and t1.a then t1.c else t1.c end)/abs(t1.e)) FROM t1 WHERE NOT ((abs(b*t1.e+t1.a)/abs(t1.c))<case when 13 in (coalesce((select max(~(abs( -11*t1.a)/abs(c))+t1.e) from t1 where t1.d in (f,c,(f))),f)-f,b,t1.b) then e when not exists(select 1 from t1 where f in (select max(19) from t1 union select cast(avg(t1.e) AS integer)- -min(11) | abs((cast(avg(t1.d) AS integer))) from t1)) then d else d end and e<e)}
+} {600}
+do_test randexpr-2.576 {
+ db eval {SELECT (abs(t1.c-case when +coalesce((select max(coalesce((select max(a-a*t1.f) from t1 where ~t1.a*t1.a-t1.b+f* -19 not in (t1.d,e,b)),11)*t1.a) from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (c) in (b,c,t1.c))) or t1.e between -b and b),a)+a<=e then t1.d else 17 end)/abs(f)) FROM t1 WHERE t1.d-t1.c+~t1.c<>case when (17) in (select + -abs(count(distinct t1.e*17*c+f)-max(19)) from t1 union select count(*)-max(case t1.f when a then (11+19*t1.b+t1.f) else (19) end*t1.c) from t1) then (abs(b- -f)/abs(f)) else t1.f end}
+} {0}
+do_test randexpr-2.577 {
+ db eval {SELECT (abs(t1.c-case when +coalesce((select max(coalesce((select max(a-a*t1.f) from t1 where ~t1.a*t1.a-t1.b+f* -19 not in (t1.d,e,b)),11)*t1.a) from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (c) in (b,c,t1.c))) or t1.e between -b and b),a)+a<=e then t1.d else 17 end)/abs(f)) FROM t1 WHERE NOT (t1.d-t1.c+~t1.c<>case when (17) in (select + -abs(count(distinct t1.e*17*c+f)-max(19)) from t1 union select count(*)-max(case t1.f when a then (11+19*t1.b+t1.f) else (19) end*t1.c) from t1) then (abs(b- -f)/abs(f)) else t1.f end)}
+} {}
+do_test randexpr-2.578 {
+ db eval {SELECT (abs( -coalesce((select 11 from t1 where (case f when (19+ -(select count(*) from t1)) then (select ++~count(distinct 17+t1.f*(17)) | cast(avg(c) AS integer) from t1) else 13-t1.b*t1.b end*t1.c*(select max(e)*cast(avg(t1.b) AS integer) from t1) | 13) | 17 between 11 and 17),(e))+d)/abs(t1.b))-t1.d FROM t1 WHERE 11<>t1.b}
+} {-400}
+do_test randexpr-2.579 {
+ db eval {SELECT (abs( -coalesce((select 11 from t1 where (case f when (19+ -(select count(*) from t1)) then (select ++~count(distinct 17+t1.f*(17)) | cast(avg(c) AS integer) from t1) else 13-t1.b*t1.b end*t1.c*(select max(e)*cast(avg(t1.b) AS integer) from t1) | 13) | 17 between 11 and 17),(e))+d)/abs(t1.b))-t1.d FROM t1 WHERE NOT (11<>t1.b)}
+} {}
+do_test randexpr-2.580 {
+ db eval {SELECT (abs( -coalesce((select 11 from t1 where (case f when (19+ -(select count(*) from t1)) then (select ++~count(distinct 17+t1.f*(17)) & cast(avg(c) AS integer) from t1) else 13-t1.b*t1.b end*t1.c*(select max(e)*cast(avg(t1.b) AS integer) from t1) & 13) & 17 between 11 and 17),(e))+d)/abs(t1.b))-t1.d FROM t1 WHERE 11<>t1.b}
+} {-400}
+do_test randexpr-2.581 {
+ db eval {SELECT ( -13)-case when (13)+19 between (select cast(avg(11+coalesce((select d from t1 where t1.a in (select b from t1 union select c from t1)),11)+t1.e*d) AS integer)*+(max(t1.c))+cast(avg((c)) AS integer)*count(*) | max( -t1.b) from t1)-t1.d and t1.a then t1.b when b<>t1.f then t1.c else a end-b-t1.b FROM t1 WHERE 11<=t1.e+19*+t1.d}
+} {-613}
+do_test randexpr-2.582 {
+ db eval {SELECT ( -13)-case when (13)+19 between (select cast(avg(11+coalesce((select d from t1 where t1.a in (select b from t1 union select c from t1)),11)+t1.e*d) AS integer)*+(max(t1.c))+cast(avg((c)) AS integer)*count(*) | max( -t1.b) from t1)-t1.d and t1.a then t1.b when b<>t1.f then t1.c else a end-b-t1.b FROM t1 WHERE NOT (11<=t1.e+19*+t1.d)}
+} {}
+do_test randexpr-2.583 {
+ db eval {SELECT ( -13)-case when (13)+19 between (select cast(avg(11+coalesce((select d from t1 where t1.a in (select b from t1 union select c from t1)),11)+t1.e*d) AS integer)*+(max(t1.c))+cast(avg((c)) AS integer)*count(*) & max( -t1.b) from t1)-t1.d and t1.a then t1.b when b<>t1.f then t1.c else a end-b-t1.b FROM t1 WHERE 11<=t1.e+19*+t1.d}
+} {-713}
+do_test randexpr-2.584 {
+ db eval {SELECT coalesce((select max(t1.e++case ~t1.c when t1.f-c then t1.b*+coalesce((select max(+t1.c) from t1 where 19-19-13 | t1.d+(select ~min(17) from t1) not in (case when t1.a<>b then e else -e end,(t1.d),t1.a)),b)+((e))* -t1.e else t1.d end | b) from t1 where a not between 13 and c),t1.e) FROM t1 WHERE not case when (exists(select 1 from t1 where (((abs(19)/abs((case when exists(select 1 from t1 where +t1.f>c) then 19 when f in (t1.d,t1.a,13) and b=t1.e then t1.f else t1.a end))) in (e, -t1.c,t1.b))))) then -t1.f when b in (d,11, -d) then t1.e*t1.a else a end+d<>t1.f and (t1.f=( -17))}
+} {}
+do_test randexpr-2.585 {
+ db eval {SELECT coalesce((select max(t1.e++case ~t1.c when t1.f-c then t1.b*+coalesce((select max(+t1.c) from t1 where 19-19-13 | t1.d+(select ~min(17) from t1) not in (case when t1.a<>b then e else -e end,(t1.d),t1.a)),b)+((e))* -t1.e else t1.d end | b) from t1 where a not between 13 and c),t1.e) FROM t1 WHERE NOT (not case when (exists(select 1 from t1 where (((abs(19)/abs((case when exists(select 1 from t1 where +t1.f>c) then 19 when f in (t1.d,t1.a,13) and b=t1.e then t1.f else t1.a end))) in (e, -t1.c,t1.b))))) then -t1.f when b in (d,11, -d) then t1.e*t1.a else a end+d<>t1.f and (t1.f=( -17)))}
+} {500}
+do_test randexpr-2.586 {
+ db eval {SELECT coalesce((select max(t1.e++case ~t1.c when t1.f-c then t1.b*+coalesce((select max(+t1.c) from t1 where 19-19-13 & t1.d+(select ~min(17) from t1) not in (case when t1.a<>b then e else -e end,(t1.d),t1.a)),b)+((e))* -t1.e else t1.d end & b) from t1 where a not between 13 and c),t1.e) FROM t1 WHERE NOT (not case when (exists(select 1 from t1 where (((abs(19)/abs((case when exists(select 1 from t1 where +t1.f>c) then 19 when f in (t1.d,t1.a,13) and b=t1.e then t1.f else t1.a end))) in (e, -t1.c,t1.b))))) then -t1.f when b in (d,11, -d) then t1.e*t1.a else a end+d<>t1.f and (t1.f=( -17)))}
+} {500}
+do_test randexpr-2.587 {
+ db eval {SELECT case when t1.d-~case t1.b when coalesce((select max(b) from t1 where exists(select 1 from t1 where t1.c<>b)),case when 17 in (select min(c+17) from t1 union select ~ -count(distinct 11) | max(d) from t1) then d when ((t1.a not between t1.f and t1.f)) then t1.a else t1.b end) then (c) else (t1.c) end<t1.a then t1.d when f not between 19 and c and 17 in (t1.f,t1.d,c) then t1.f else 11 end+t1.e*( -11) FROM t1 WHERE case c when f then case (abs(t1.d | case when ((13))*a+c+19>=d then -13 when b in (select cast(avg((a)) AS integer) from t1 union select -~abs(count(*))*min(t1.f) from t1) then d else 19 end)/abs(19)) when 11 then 11 else t1.f end+13-t1.d else t1.b end+b>=d and not exists(select 1 from t1 where e>=19)}
+} {}
+do_test randexpr-2.588 {
+ db eval {SELECT case when t1.d-~case t1.b when coalesce((select max(b) from t1 where exists(select 1 from t1 where t1.c<>b)),case when 17 in (select min(c+17) from t1 union select ~ -count(distinct 11) | max(d) from t1) then d when ((t1.a not between t1.f and t1.f)) then t1.a else t1.b end) then (c) else (t1.c) end<t1.a then t1.d when f not between 19 and c and 17 in (t1.f,t1.d,c) then t1.f else 11 end+t1.e*( -11) FROM t1 WHERE NOT (case c when f then case (abs(t1.d | case when ((13))*a+c+19>=d then -13 when b in (select cast(avg((a)) AS integer) from t1 union select -~abs(count(*))*min(t1.f) from t1) then d else 19 end)/abs(19)) when 11 then 11 else t1.f end+13-t1.d else t1.b end+b>=d and not exists(select 1 from t1 where e>=19))}
+} {-5489}
+do_test randexpr-2.589 {
+ db eval {SELECT case when t1.d-~case t1.b when coalesce((select max(b) from t1 where exists(select 1 from t1 where t1.c<>b)),case when 17 in (select min(c+17) from t1 union select ~ -count(distinct 11) & max(d) from t1) then d when ((t1.a not between t1.f and t1.f)) then t1.a else t1.b end) then (c) else (t1.c) end<t1.a then t1.d when f not between 19 and c and 17 in (t1.f,t1.d,c) then t1.f else 11 end+t1.e*( -11) FROM t1 WHERE NOT (case c when f then case (abs(t1.d | case when ((13))*a+c+19>=d then -13 when b in (select cast(avg((a)) AS integer) from t1 union select -~abs(count(*))*min(t1.f) from t1) then d else 19 end)/abs(19)) when 11 then 11 else t1.f end+13-t1.d else t1.b end+b>=d and not exists(select 1 from t1 where e>=19))}
+} {-5489}
+do_test randexpr-2.590 {
+ db eval {SELECT b+coalesce((select (t1.e) from t1 where coalesce((select max((select abs(cast(avg( -t1.f*17) AS integer))+count(*) from t1)-19*coalesce((select b*+~(t1.c)*(abs(c)/abs(a))+t1.e from t1 where 11 in (t1.a,17,b* -t1.f)),t1.e)*t1.b) from t1 where t1.f<>17),17) in (11,11, -t1.f)),t1.e) FROM t1 WHERE coalesce((select max(coalesce((select 19-e from t1 where t1.b not in (coalesce((select max(t1.e+coalesce((select 11+ -coalesce((select max(t1.a) from t1 where t1.a in (select cast(avg( -11) AS integer) from t1 union select -max(c) from t1)),11)*t1.a from t1 where exists(select 1 from t1 where a= -e)),e)-t1.c | t1.d) from t1 where t1.e=t1.a),17),(t1.e),c)),t1.b)) from t1 where not exists(select 1 from t1 where (13>=a) or exists(select 1 from t1 where d<>11))), -19)<=t1.b}
+} {700}
+do_test randexpr-2.591 {
+ db eval {SELECT b+coalesce((select (t1.e) from t1 where coalesce((select max((select abs(cast(avg( -t1.f*17) AS integer))+count(*) from t1)-19*coalesce((select b*+~(t1.c)*(abs(c)/abs(a))+t1.e from t1 where 11 in (t1.a,17,b* -t1.f)),t1.e)*t1.b) from t1 where t1.f<>17),17) in (11,11, -t1.f)),t1.e) FROM t1 WHERE NOT (coalesce((select max(coalesce((select 19-e from t1 where t1.b not in (coalesce((select max(t1.e+coalesce((select 11+ -coalesce((select max(t1.a) from t1 where t1.a in (select cast(avg( -11) AS integer) from t1 union select -max(c) from t1)),11)*t1.a from t1 where exists(select 1 from t1 where a= -e)),e)-t1.c | t1.d) from t1 where t1.e=t1.a),17),(t1.e),c)),t1.b)) from t1 where not exists(select 1 from t1 where (13>=a) or exists(select 1 from t1 where d<>11))), -19)<=t1.b)}
+} {}
+do_test randexpr-2.592 {
+ db eval {SELECT (select count(distinct t1.a)-cast(avg(~c+coalesce((select e from t1 where e in (select t1.f from t1 union select d from t1) or t1.d not in (case when a not in (t1.d,t1.c,t1.b) then a-case when ~t1.b+t1.e | -t1.e not in (a,(b),19) then t1.d else 11 end*b when 13 in (c,13,t1.a) then -t1.a else 17 end,c,d)),t1.e)) AS integer) from t1) FROM t1 WHERE ~e<=(a-(select count(*) from t1)+c+(select -abs(abs( -(max((abs(coalesce((select a*(abs(b-b)/abs((c*a*b)-11+coalesce((select max(b) from t1 where a<c),e))) from t1 where 17<>e),e))/abs(11))*t1.e)))) | abs((count(*))) from t1))}
+} {-198}
+do_test randexpr-2.593 {
+ db eval {SELECT (select count(distinct t1.a)-cast(avg(~c+coalesce((select e from t1 where e in (select t1.f from t1 union select d from t1) or t1.d not in (case when a not in (t1.d,t1.c,t1.b) then a-case when ~t1.b+t1.e | -t1.e not in (a,(b),19) then t1.d else 11 end*b when 13 in (c,13,t1.a) then -t1.a else 17 end,c,d)),t1.e)) AS integer) from t1) FROM t1 WHERE NOT (~e<=(a-(select count(*) from t1)+c+(select -abs(abs( -(max((abs(coalesce((select a*(abs(b-b)/abs((c*a*b)-11+coalesce((select max(b) from t1 where a<c),e))) from t1 where 17<>e),e))/abs(11))*t1.e)))) | abs((count(*))) from t1)))}
+} {}
+do_test randexpr-2.594 {
+ db eval {SELECT (select count(distinct t1.a)-cast(avg(~c+coalesce((select e from t1 where e in (select t1.f from t1 union select d from t1) or t1.d not in (case when a not in (t1.d,t1.c,t1.b) then a-case when ~t1.b+t1.e & -t1.e not in (a,(b),19) then t1.d else 11 end*b when 13 in (c,13,t1.a) then -t1.a else 17 end,c,d)),t1.e)) AS integer) from t1) FROM t1 WHERE ~e<=(a-(select count(*) from t1)+c+(select -abs(abs( -(max((abs(coalesce((select a*(abs(b-b)/abs((c*a*b)-11+coalesce((select max(b) from t1 where a<c),e))) from t1 where 17<>e),e))/abs(11))*t1.e)))) | abs((count(*))) from t1))}
+} {-198}
+do_test randexpr-2.595 {
+ db eval {SELECT 13-(select cast(avg(t1.c-13) AS integer) from t1) | 11+t1.b | coalesce((select max(case when b in (select case -case max(17) when ~cast(avg(13-t1.a) AS integer) then count(distinct 13) else - -((cast(avg(e) AS integer))) end when cast(avg(t1.c) AS integer) then count(distinct d) else count(*) end from t1 union select count(*) from t1) then case when t1.d<>~13 then b when t1.c<>13 then t1.a else a end else t1.a end) from t1 where t1.f<>( -(17))),t1.e)+c FROM t1 WHERE (~coalesce((select (11+t1.d) from t1 where 17 in (select f+a from t1 union select case when 11>coalesce((select -case when (11 not in (t1.f,(abs(t1.a)/abs((select count(distinct -case when 13<=e then c when d between (t1.d) and t1.d then a else 11 end) from t1)-f)),c)) then f when (t1.f>t1.d) then 17 else 13 end from t1 where t1.e>a),17) then f else t1.b end from t1)),b)*13>e)}
+} {}
+do_test randexpr-2.596 {
+ db eval {SELECT 13-(select cast(avg(t1.c-13) AS integer) from t1) | 11+t1.b | coalesce((select max(case when b in (select case -case max(17) when ~cast(avg(13-t1.a) AS integer) then count(distinct 13) else - -((cast(avg(e) AS integer))) end when cast(avg(t1.c) AS integer) then count(distinct d) else count(*) end from t1 union select count(*) from t1) then case when t1.d<>~13 then b when t1.c<>13 then t1.a else a end else t1.a end) from t1 where t1.f<>( -(17))),t1.e)+c FROM t1 WHERE NOT ((~coalesce((select (11+t1.d) from t1 where 17 in (select f+a from t1 union select case when 11>coalesce((select -case when (11 not in (t1.f,(abs(t1.a)/abs((select count(distinct -case when 13<=e then c when d between (t1.d) and t1.d then a else 11 end) from t1)-f)),c)) then f when (t1.f>t1.d) then 17 else 13 end from t1 where t1.e>a),17) then f else t1.b end from t1)),b)*13>e))}
+} {-1}
+do_test randexpr-2.597 {
+ db eval {SELECT 13-(select cast(avg(t1.c-13) AS integer) from t1) & 11+t1.b & coalesce((select max(case when b in (select case -case max(17) when ~cast(avg(13-t1.a) AS integer) then count(distinct 13) else - -((cast(avg(e) AS integer))) end when cast(avg(t1.c) AS integer) then count(distinct d) else count(*) end from t1 union select count(*) from t1) then case when t1.d<>~13 then b when t1.c<>13 then t1.a else a end else t1.a end) from t1 where t1.f<>( -(17))),t1.e)+c FROM t1 WHERE NOT ((~coalesce((select (11+t1.d) from t1 where 17 in (select f+a from t1 union select case when 11>coalesce((select -case when (11 not in (t1.f,(abs(t1.a)/abs((select count(distinct -case when 13<=e then c when d between (t1.d) and t1.d then a else 11 end) from t1)-f)),c)) then f when (t1.f>t1.d) then 17 else 13 end from t1 where t1.e>a),17) then f else t1.b end from t1)),b)*13>e))}
+} {128}
+do_test randexpr-2.598 {
+ db eval {SELECT f+coalesce((select case when ~case when coalesce((select max(b) from t1 where not exists(select 1 from t1 where 11*t1.b>case t1.b when 13 then 11 else b end)),t1.b) not in (a,b,+t1.e | case when t1.a<>17 then 17 else t1.e end) then c when (t1.e)<>d then 11 else f end*(e) not between d and e then 17 else 17 end from t1 where 13 not between 19 and f),t1.b)*11 FROM t1 WHERE not exists(select 1 from t1 where 11 between c and b and -case when 13 between -f | case when t1.b<+c then b when t1.f>13 then a else (d) end and d then t1.d when t1.a in (select 19 from t1 union select 11 from t1) or not exists(select 1 from t1 where exists(select 1 from t1 where not b=t1.b)) then -19 else t1.b end in (select max(17) from t1 union select count(distinct a)+count(distinct 11) from t1) and t1.f<t1.d or b not in (d,t1.d,a))}
+} {}
+do_test randexpr-2.599 {
+ db eval {SELECT f+coalesce((select case when ~case when coalesce((select max(b) from t1 where not exists(select 1 from t1 where 11*t1.b>case t1.b when 13 then 11 else b end)),t1.b) not in (a,b,+t1.e | case when t1.a<>17 then 17 else t1.e end) then c when (t1.e)<>d then 11 else f end*(e) not between d and e then 17 else 17 end from t1 where 13 not between 19 and f),t1.b)*11 FROM t1 WHERE NOT (not exists(select 1 from t1 where 11 between c and b and -case when 13 between -f | case when t1.b<+c then b when t1.f>13 then a else (d) end and d then t1.d when t1.a in (select 19 from t1 union select 11 from t1) or not exists(select 1 from t1 where exists(select 1 from t1 where not b=t1.b)) then -19 else t1.b end in (select max(17) from t1 union select count(distinct a)+count(distinct 11) from t1) and t1.f<t1.d or b not in (d,t1.d,a)))}
+} {787}
+do_test randexpr-2.600 {
+ db eval {SELECT f+coalesce((select case when ~case when coalesce((select max(b) from t1 where not exists(select 1 from t1 where 11*t1.b>case t1.b when 13 then 11 else b end)),t1.b) not in (a,b,+t1.e & case when t1.a<>17 then 17 else t1.e end) then c when (t1.e)<>d then 11 else f end*(e) not between d and e then 17 else 17 end from t1 where 13 not between 19 and f),t1.b)*11 FROM t1 WHERE NOT (not exists(select 1 from t1 where 11 between c and b and -case when 13 between -f | case when t1.b<+c then b when t1.f>13 then a else (d) end and d then t1.d when t1.a in (select 19 from t1 union select 11 from t1) or not exists(select 1 from t1 where exists(select 1 from t1 where not b=t1.b)) then -19 else t1.b end in (select max(17) from t1 union select count(distinct a)+count(distinct 11) from t1) and t1.f<t1.d or b not in (d,t1.d,a)))}
+} {787}
+do_test randexpr-2.601 {
+ db eval {SELECT coalesce((select max(e) from t1 where e*~t1.b*e+c*case when +(abs(coalesce((select max(t1.b) from t1 where t1.b>=t1.a-11),11))/abs(17))=t1.f and ((t1.f)=t1.e) then t1.a+t1.d when not exists(select 1 from t1 where -b>c) or t1.a>=11 then t1.e else e end*13*t1.f | d>=19),t1.b)+t1.a FROM t1 WHERE t1.e not in (t1.f+case when f-d not between coalesce((select max(d) from t1 where (coalesce((select max(17) from t1 where not 19 in (select cast(avg(c) AS integer)-~count(distinct f- -e)+cast(avg(19) AS integer) from t1 union select cast(avg(d) AS integer) from t1)),b) not in (13,t1.c,13))),17)+ -e+t1.f and -(t1.b) then (t1.d) when t1.b in (select min(a) from t1 union select min(17) from t1) then c else 11 end,c, -13)}
+} {600}
+do_test randexpr-2.602 {
+ db eval {SELECT coalesce((select max(e) from t1 where e*~t1.b*e+c*case when +(abs(coalesce((select max(t1.b) from t1 where t1.b>=t1.a-11),11))/abs(17))=t1.f and ((t1.f)=t1.e) then t1.a+t1.d when not exists(select 1 from t1 where -b>c) or t1.a>=11 then t1.e else e end*13*t1.f | d>=19),t1.b)+t1.a FROM t1 WHERE NOT (t1.e not in (t1.f+case when f-d not between coalesce((select max(d) from t1 where (coalesce((select max(17) from t1 where not 19 in (select cast(avg(c) AS integer)-~count(distinct f- -e)+cast(avg(19) AS integer) from t1 union select cast(avg(d) AS integer) from t1)),b) not in (13,t1.c,13))),17)+ -e+t1.f and -(t1.b) then (t1.d) when t1.b in (select min(a) from t1 union select min(17) from t1) then c else 11 end,c, -13))}
+} {}
+do_test randexpr-2.603 {
+ db eval {SELECT coalesce((select max(e) from t1 where e*~t1.b*e+c*case when +(abs(coalesce((select max(t1.b) from t1 where t1.b>=t1.a-11),11))/abs(17))=t1.f and ((t1.f)=t1.e) then t1.a+t1.d when not exists(select 1 from t1 where -b>c) or t1.a>=11 then t1.e else e end*13*t1.f & d>=19),t1.b)+t1.a FROM t1 WHERE t1.e not in (t1.f+case when f-d not between coalesce((select max(d) from t1 where (coalesce((select max(17) from t1 where not 19 in (select cast(avg(c) AS integer)-~count(distinct f- -e)+cast(avg(19) AS integer) from t1 union select cast(avg(d) AS integer) from t1)),b) not in (13,t1.c,13))),17)+ -e+t1.f and -(t1.b) then (t1.d) when t1.b in (select min(a) from t1 union select min(17) from t1) then c else 11 end,c, -13)}
+} {600}
+do_test randexpr-2.604 {
+ db eval {SELECT case when exists(select 1 from t1 where f in (select cast(avg(t1.c) AS integer) from t1 union select min(t1.b) from t1)) then c+d-d when (coalesce((select a from t1 where a<(select abs(count(*)) from t1)),(select count(distinct t1.e) | abs(+ -count(distinct t1.e)*min(t1.b) | count(distinct 11)) from t1))) not in (17,(abs(t1.d)/abs(coalesce((select max(t1.f) from t1 where t1.a*t1.f>=t1.c),t1.f))),t1.e) then t1.c else t1.e end-f FROM t1 WHERE 13*~~(abs(b)/abs(coalesce((select max(t1.a) from t1 where t1.e in ( -(13-17)-b+(e | (abs(t1.e)/abs(case when ~t1.d between t1.e and c and t1.b in (select t1.c from t1 union select b from t1) then 11+t1.b when a=t1.d then b else c end)))*17,t1.c, -17)),13)))-e+b-19>19}
+} {}
+do_test randexpr-2.605 {
+ db eval {SELECT case when exists(select 1 from t1 where f in (select cast(avg(t1.c) AS integer) from t1 union select min(t1.b) from t1)) then c+d-d when (coalesce((select a from t1 where a<(select abs(count(*)) from t1)),(select count(distinct t1.e) | abs(+ -count(distinct t1.e)*min(t1.b) | count(distinct 11)) from t1))) not in (17,(abs(t1.d)/abs(coalesce((select max(t1.f) from t1 where t1.a*t1.f>=t1.c),t1.f))),t1.e) then t1.c else t1.e end-f FROM t1 WHERE NOT (13*~~(abs(b)/abs(coalesce((select max(t1.a) from t1 where t1.e in ( -(13-17)-b+(e | (abs(t1.e)/abs(case when ~t1.d between t1.e and c and t1.b in (select t1.c from t1 union select b from t1) then 11+t1.b when a=t1.d then b else c end)))*17,t1.c, -17)),13)))-e+b-19>19)}
+} {-300}
+do_test randexpr-2.606 {
+ db eval {SELECT case when exists(select 1 from t1 where f in (select cast(avg(t1.c) AS integer) from t1 union select min(t1.b) from t1)) then c+d-d when (coalesce((select a from t1 where a<(select abs(count(*)) from t1)),(select count(distinct t1.e) & abs(+ -count(distinct t1.e)*min(t1.b) & count(distinct 11)) from t1))) not in (17,(abs(t1.d)/abs(coalesce((select max(t1.f) from t1 where t1.a*t1.f>=t1.c),t1.f))),t1.e) then t1.c else t1.e end-f FROM t1 WHERE NOT (13*~~(abs(b)/abs(coalesce((select max(t1.a) from t1 where t1.e in ( -(13-17)-b+(e | (abs(t1.e)/abs(case when ~t1.d between t1.e and c and t1.b in (select t1.c from t1 union select b from t1) then 11+t1.b when a=t1.d then b else c end)))*17,t1.c, -17)),13)))-e+b-19>19)}
+} {-100}
+do_test randexpr-2.607 {
+ db eval {SELECT case when t1.f<d or t1.d>=17 then t1.d-19-11*f*t1.a*t1.b-case (select +cast(avg(a) AS integer) from t1) when 19 then 17 else a end when t1.a between case t1.c when t1.c*t1.c then (d) else t1.c end and c then e else t1.a end FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where (abs(+f-( -~(select count(distinct ~a*e | (select max(f)*count(distinct t1.f) from t1)) | -max(17)+(count(*))+max(11)+count(distinct t1.e)- - -count(distinct f) from t1)+b*b-t1.c) | t1.e)/abs(17))*c*b in (17,19,t1.e)))}
+} {-131999719}
+do_test randexpr-2.608 {
+ db eval {SELECT case when t1.f<d or t1.d>=17 then t1.d-19-11*f*t1.a*t1.b-case (select +cast(avg(a) AS integer) from t1) when 19 then 17 else a end when t1.a between case t1.c when t1.c*t1.c then (d) else t1.c end and c then e else t1.a end FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where (abs(+f-( -~(select count(distinct ~a*e | (select max(f)*count(distinct t1.f) from t1)) | -max(17)+(count(*))+max(11)+count(distinct t1.e)- - -count(distinct f) from t1)+b*b-t1.c) | t1.e)/abs(17))*c*b in (17,19,t1.e))))}
+} {}
+do_test randexpr-2.609 {
+ db eval {SELECT f-~+17*(abs(t1.f)/abs(a*case when case when (case when d>=t1.b or t1.b>=11 then t1.c when t1.b>t1.d then t1.d else t1.a end+17) not in (11,t1.e,17) then c when (t1.b>=a and b>b) then t1.d else d end in (select +abs( -max(t1.e)) from t1 union select count(*) | max(17) from t1) then (t1.a) else a end+(t1.e)))*(11)-f | t1.a-f FROM t1 WHERE ((t1.d>=t1.c))}
+} {-500}
+do_test randexpr-2.610 {
+ db eval {SELECT f-~+17*(abs(t1.f)/abs(a*case when case when (case when d>=t1.b or t1.b>=11 then t1.c when t1.b>t1.d then t1.d else t1.a end+17) not in (11,t1.e,17) then c when (t1.b>=a and b>b) then t1.d else d end in (select +abs( -max(t1.e)) from t1 union select count(*) | max(17) from t1) then (t1.a) else a end+(t1.e)))*(11)-f | t1.a-f FROM t1 WHERE NOT (((t1.d>=t1.c)))}
+} {}
+do_test randexpr-2.611 {
+ db eval {SELECT f-~+17*(abs(t1.f)/abs(a*case when case when (case when d>=t1.b or t1.b>=11 then t1.c when t1.b>t1.d then t1.d else t1.a end+17) not in (11,t1.e,17) then c when (t1.b>=a and b>b) then t1.d else d end in (select +abs( -max(t1.e)) from t1 union select count(*) & max(17) from t1) then (t1.a) else a end+(t1.e)))*(11)-f & t1.a-f FROM t1 WHERE ((t1.d>=t1.c))}
+} {0}
+do_test randexpr-2.612 {
+ db eval {SELECT e+ -((abs(f)/abs(17))) | t1.e*11-coalesce((select max(f) from t1 where ((abs(~+t1.b-coalesce((select coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where ((f) not in (11,19,t1.b)))),11* -t1.b) from t1 where -a<=c),t1.f))/abs( -b)) between t1.c and e and not exists(select 1 from t1 where f not in ( -t1.f,19,t1.e)))),case t1.c when 19 then (11) else (t1.a) end) | (13) FROM t1 WHERE d<>13 or t1.c in (select count(distinct -c*11-( -e)-t1.e)-( -case +max(t1.c)-min((select +cast(avg(19*17) AS integer) from t1)* -t1.f)+~(~count(distinct f))+count(*)-cast(avg(t1.c) AS integer) when count(distinct t1.f) then count(distinct e) else -count(*) end-count(*)) from t1 union select count(distinct 11) from t1)}
+} {5597}
+do_test randexpr-2.613 {
+ db eval {SELECT e+ -((abs(f)/abs(17))) | t1.e*11-coalesce((select max(f) from t1 where ((abs(~+t1.b-coalesce((select coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where ((f) not in (11,19,t1.b)))),11* -t1.b) from t1 where -a<=c),t1.f))/abs( -b)) between t1.c and e and not exists(select 1 from t1 where f not in ( -t1.f,19,t1.e)))),case t1.c when 19 then (11) else (t1.a) end) | (13) FROM t1 WHERE NOT (d<>13 or t1.c in (select count(distinct -c*11-( -e)-t1.e)-( -case +max(t1.c)-min((select +cast(avg(19*17) AS integer) from t1)* -t1.f)+~(~count(distinct f))+count(*)-cast(avg(t1.c) AS integer) when count(distinct t1.f) then count(distinct e) else -count(*) end-count(*)) from t1 union select count(distinct 11) from t1))}
+} {}
+do_test randexpr-2.614 {
+ db eval {SELECT e+ -((abs(f)/abs(17))) & t1.e*11-coalesce((select max(f) from t1 where ((abs(~+t1.b-coalesce((select coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where ((f) not in (11,19,t1.b)))),11* -t1.b) from t1 where -a<=c),t1.f))/abs( -b)) between t1.c and e and not exists(select 1 from t1 where f not in ( -t1.f,19,t1.e)))),case t1.c when 19 then (11) else (t1.a) end) & (13) FROM t1 WHERE d<>13 or t1.c in (select count(distinct -c*11-( -e)-t1.e)-( -case +max(t1.c)-min((select +cast(avg(19*17) AS integer) from t1)* -t1.f)+~(~count(distinct f))+count(*)-cast(avg(t1.c) AS integer) when count(distinct t1.f) then count(distinct e) else -count(*) end-count(*)) from t1 union select count(distinct 11) from t1)}
+} {0}
+do_test randexpr-2.615 {
+ db eval {SELECT coalesce((select case t1.e when t1.d then -t1.b else b | t1.f end from t1 where case e when case 11 when t1.f then 13 else c end-19 then case -(select count(distinct 19+ - -d*t1.f+d) from t1)*(abs(c)/abs(coalesce((select max(e) from t1 where not t1.c>t1.d),(17-t1.a)))) when 11 then t1.f else t1.a end else a end<>t1.c),t1.e) FROM t1 WHERE (select case count(*)* -+abs(+count(*)+min(t1.d)) | max(+(17)) when ~count(*)*(count(*))-(count(distinct t1.b)) then count(distinct 11) else max(t1.e) end from t1)>=(abs(coalesce((select t1.b from t1 where (a<f)),b-t1.a))/abs((11*c)-t1.f-b)) and 13 not between (t1.b) and t1.b}
+} {728}
+do_test randexpr-2.616 {
+ db eval {SELECT coalesce((select case t1.e when t1.d then -t1.b else b | t1.f end from t1 where case e when case 11 when t1.f then 13 else c end-19 then case -(select count(distinct 19+ - -d*t1.f+d) from t1)*(abs(c)/abs(coalesce((select max(e) from t1 where not t1.c>t1.d),(17-t1.a)))) when 11 then t1.f else t1.a end else a end<>t1.c),t1.e) FROM t1 WHERE NOT ((select case count(*)* -+abs(+count(*)+min(t1.d)) | max(+(17)) when ~count(*)*(count(*))-(count(distinct t1.b)) then count(distinct 11) else max(t1.e) end from t1)>=(abs(coalesce((select t1.b from t1 where (a<f)),b-t1.a))/abs((11*c)-t1.f-b)) and 13 not between (t1.b) and t1.b)}
+} {}
+do_test randexpr-2.617 {
+ db eval {SELECT coalesce((select case t1.e when t1.d then -t1.b else b & t1.f end from t1 where case e when case 11 when t1.f then 13 else c end-19 then case -(select count(distinct 19+ - -d*t1.f+d) from t1)*(abs(c)/abs(coalesce((select max(e) from t1 where not t1.c>t1.d),(17-t1.a)))) when 11 then t1.f else t1.a end else a end<>t1.c),t1.e) FROM t1 WHERE (select case count(*)* -+abs(+count(*)+min(t1.d)) | max(+(17)) when ~count(*)*(count(*))-(count(distinct t1.b)) then count(distinct 11) else max(t1.e) end from t1)>=(abs(coalesce((select t1.b from t1 where (a<f)),b-t1.a))/abs((11*c)-t1.f-b)) and 13 not between (t1.b) and t1.b}
+} {72}
+do_test randexpr-2.618 {
+ db eval {SELECT case when 13<11 then 19 when -(abs(f)/abs(13))*17-13 | case t1.b when ~((select (count(*)-abs(case cast(avg(19) AS integer) when count(distinct 19)*(count(*))-count(*) then count(distinct t1.d) else -count(distinct 17) end)+max(17)) from t1)) then t1.c else d end+11*t1.e*t1.a | e>(t1.c) then t1.d else t1.d end FROM t1 WHERE case when 17-t1.f in (select case -~max(c-~e+19)*max(c)*count(*)+~count(distinct f)+case count(distinct d) when max(t1.b) then cast(avg(t1.d) AS integer) else count(distinct d) end-count(distinct d)*max(f)+ -count(distinct 13) when count(*) then ( -min(t1.c)) else min(( -d)) end from t1 union select -min(c) from t1) then 13 else case t1.c when t1.c then f else d end end-e-(17) in (select c from t1 union select c from t1)}
+} {}
+do_test randexpr-2.619 {
+ db eval {SELECT case when 13<11 then 19 when -(abs(f)/abs(13))*17-13 | case t1.b when ~((select (count(*)-abs(case cast(avg(19) AS integer) when count(distinct 19)*(count(*))-count(*) then count(distinct t1.d) else -count(distinct 17) end)+max(17)) from t1)) then t1.c else d end+11*t1.e*t1.a | e>(t1.c) then t1.d else t1.d end FROM t1 WHERE NOT (case when 17-t1.f in (select case -~max(c-~e+19)*max(c)*count(*)+~count(distinct f)+case count(distinct d) when max(t1.b) then cast(avg(t1.d) AS integer) else count(distinct d) end-count(distinct d)*max(f)+ -count(distinct 13) when count(*) then ( -min(t1.c)) else min(( -d)) end from t1 union select -min(c) from t1) then 13 else case t1.c when t1.c then f else d end end-e-(17) in (select c from t1 union select c from t1))}
+} {400}
+do_test randexpr-2.620 {
+ db eval {SELECT case when 13<11 then 19 when -(abs(f)/abs(13))*17-13 & case t1.b when ~((select (count(*)-abs(case cast(avg(19) AS integer) when count(distinct 19)*(count(*))-count(*) then count(distinct t1.d) else -count(distinct 17) end)+max(17)) from t1)) then t1.c else d end+11*t1.e*t1.a & e>(t1.c) then t1.d else t1.d end FROM t1 WHERE NOT (case when 17-t1.f in (select case -~max(c-~e+19)*max(c)*count(*)+~count(distinct f)+case count(distinct d) when max(t1.b) then cast(avg(t1.d) AS integer) else count(distinct d) end-count(distinct d)*max(f)+ -count(distinct 13) when count(*) then ( -min(t1.c)) else min(( -d)) end from t1 union select -min(c) from t1) then 13 else case t1.c when t1.c then f else d end end-e-(17) in (select c from t1 union select c from t1))}
+} {400}
+do_test randexpr-2.621 {
+ db eval {SELECT coalesce((select case ~(case when -f between t1.e and f then coalesce((select max(t1.a-t1.d) from t1 where d=b),case when (f*11-a-t1.d-c>t1.e and b>=19) then -+d when t1.b>= -13 then 17 else t1.f end) else (19) end) when 11 then b else f end from t1 where -t1.e<=t1.d),a) FROM t1 WHERE (+coalesce((select max((abs(19*a-t1.b+t1.a*a)/abs(19))) from t1 where not t1.f in (select case -count(*)-cast(avg(c) AS integer)+cast(avg(e) AS integer)*count(*) when min(t1.d) then -(cast(avg(t1.f) AS integer)) else max(13) end+min(t1.d)+count(*) | count(*) | min(11) | count(distinct f) from t1 union select -count(*) from t1)),e))-t1.e*d | f in (t1.d,e,e)}
+} {}
+do_test randexpr-2.622 {
+ db eval {SELECT coalesce((select case ~(case when -f between t1.e and f then coalesce((select max(t1.a-t1.d) from t1 where d=b),case when (f*11-a-t1.d-c>t1.e and b>=19) then -+d when t1.b>= -13 then 17 else t1.f end) else (19) end) when 11 then b else f end from t1 where -t1.e<=t1.d),a) FROM t1 WHERE NOT ((+coalesce((select max((abs(19*a-t1.b+t1.a*a)/abs(19))) from t1 where not t1.f in (select case -count(*)-cast(avg(c) AS integer)+cast(avg(e) AS integer)*count(*) when min(t1.d) then -(cast(avg(t1.f) AS integer)) else max(13) end+min(t1.d)+count(*) | count(*) | min(11) | count(distinct f) from t1 union select -count(*) from t1)),e))-t1.e*d | f in (t1.d,e,e))}
+} {600}
+do_test randexpr-2.623 {
+ db eval {SELECT case d*t1.f when -t1.a then t1.c+(coalesce((select max(13+case when -t1.d*13*c*d | case t1.e when t1.e then t1.b+t1.d else (abs(t1.b)/abs(case when c>b or d in (t1.e,a,d) then d else e end))+f end=t1.f then a when t1.a<=19 then 17 else d end) from t1 where (t1.f>t1.b)),(f))) else f end+t1.a FROM t1 WHERE t1.f+case d when 19 then +t1.c else 19-(abs((t1.b)*~coalesce((select f from t1 where (case when +case when t1.d>13 then t1.e else (t1.a) end<13 then f when t1.c<=e then d else t1.a end*t1.d in (select +case ~min(b) when -max(13) then cast(avg( -(11)) AS integer) else -cast(avg(17) AS integer) end+count(distinct t1.a) from t1 union select min(t1.f) from t1))),t1.a))/abs(f)) end+(a) in (b,t1.c,t1.a)}
+} {}
+do_test randexpr-2.624 {
+ db eval {SELECT case d*t1.f when -t1.a then t1.c+(coalesce((select max(13+case when -t1.d*13*c*d | case t1.e when t1.e then t1.b+t1.d else (abs(t1.b)/abs(case when c>b or d in (t1.e,a,d) then d else e end))+f end=t1.f then a when t1.a<=19 then 17 else d end) from t1 where (t1.f>t1.b)),(f))) else f end+t1.a FROM t1 WHERE NOT (t1.f+case d when 19 then +t1.c else 19-(abs((t1.b)*~coalesce((select f from t1 where (case when +case when t1.d>13 then t1.e else (t1.a) end<13 then f when t1.c<=e then d else t1.a end*t1.d in (select +case ~min(b) when -max(13) then cast(avg( -(11)) AS integer) else -cast(avg(17) AS integer) end+count(distinct t1.a) from t1 union select min(t1.f) from t1))),t1.a))/abs(f)) end+(a) in (b,t1.c,t1.a))}
+} {700}
+do_test randexpr-2.625 {
+ db eval {SELECT case d*t1.f when -t1.a then t1.c+(coalesce((select max(13+case when -t1.d*13*c*d & case t1.e when t1.e then t1.b+t1.d else (abs(t1.b)/abs(case when c>b or d in (t1.e,a,d) then d else e end))+f end=t1.f then a when t1.a<=19 then 17 else d end) from t1 where (t1.f>t1.b)),(f))) else f end+t1.a FROM t1 WHERE NOT (t1.f+case d when 19 then +t1.c else 19-(abs((t1.b)*~coalesce((select f from t1 where (case when +case when t1.d>13 then t1.e else (t1.a) end<13 then f when t1.c<=e then d else t1.a end*t1.d in (select +case ~min(b) when -max(13) then cast(avg( -(11)) AS integer) else -cast(avg(17) AS integer) end+count(distinct t1.a) from t1 union select min(t1.f) from t1))),t1.a))/abs(f)) end+(a) in (b,t1.c,t1.a))}
+} {700}
+do_test randexpr-2.626 {
+ db eval {SELECT case case when (not exists(select 1 from t1 where -e in (select t1.c from t1 union select b from t1))) then coalesce((select max(t1.d) from t1 where (17+~t1.c in (select min(t1.b) from t1 union select min(13) from t1))),t1.d)*t1.a+d when not a=a and t1.b not in (b,13,d) or d<13 or t1.f not between t1.c and f or t1.c<>c then t1.e else t1.d end when t1.c then (t1.d) else -f end FROM t1 WHERE (abs(case when (t1.e in (17,19+t1.b,t1.a)) or (t1.d-19)+(t1.d)+t1.d in (select t1.f from t1 union select t1.e from t1) and 13 in (select t1.c from t1 union select c from t1) or 11 not between e and 17 then -17-a else d end*13)/abs((b)))*d-f-13 between t1.d and (b)}
+} {}
+do_test randexpr-2.627 {
+ db eval {SELECT case case when (not exists(select 1 from t1 where -e in (select t1.c from t1 union select b from t1))) then coalesce((select max(t1.d) from t1 where (17+~t1.c in (select min(t1.b) from t1 union select min(13) from t1))),t1.d)*t1.a+d when not a=a and t1.b not in (b,13,d) or d<13 or t1.f not between t1.c and f or t1.c<>c then t1.e else t1.d end when t1.c then (t1.d) else -f end FROM t1 WHERE NOT ((abs(case when (t1.e in (17,19+t1.b,t1.a)) or (t1.d-19)+(t1.d)+t1.d in (select t1.f from t1 union select t1.e from t1) and 13 in (select t1.c from t1 union select c from t1) or 11 not between e and 17 then -17-a else d end*13)/abs((b)))*d-f-13 between t1.d and (b))}
+} {-600}
+do_test randexpr-2.628 {
+ db eval {SELECT a+a+(f)-(t1.f+d+t1.e | case when case (13) when t1.c then case coalesce((select -t1.b-t1.f-13 from t1 where t1.f between t1.d and (a)),t1.b) when b then 13 else t1.f end-f else t1.d end>=e then 19 else t1.c end*t1.c)*f-(t1.d)-b FROM t1 WHERE (t1.b)=t1.a+t1.d-13 | +~f+13 | e+t1.c+coalesce((select t1.a+e from t1 where b in (select (~max(b-t1.b-coalesce((select ((a)) from t1 where e=d or b not between b and t1.e),t1.b)))++~case case count(*) when -max(t1.c) then min(b) else min(17) end when max( -t1.a) then (min(t1.f)) else max((a)) end*cast(avg(f) AS integer)+max(19) from t1 union select count(distinct f) from t1)),(t1.e)) | t1.b}
+} {}
+do_test randexpr-2.629 {
+ db eval {SELECT a+a+(f)-(t1.f+d+t1.e | case when case (13) when t1.c then case coalesce((select -t1.b-t1.f-13 from t1 where t1.f between t1.d and (a)),t1.b) when b then 13 else t1.f end-f else t1.d end>=e then 19 else t1.c end*t1.c)*f-(t1.d)-b FROM t1 WHERE NOT ((t1.b)=t1.a+t1.d-13 | +~f+13 | e+t1.c+coalesce((select t1.a+e from t1 where b in (select (~max(b-t1.b-coalesce((select ((a)) from t1 where e=d or b not between b and t1.e),t1.b)))++~case case count(*) when -max(t1.c) then min(b) else min(17) end when max( -t1.a) then (min(t1.f)) else max((a)) end*cast(avg(f) AS integer)+max(19) from t1 union select count(distinct f) from t1)),(t1.e)) | t1.b)}
+} {-54045400}
+do_test randexpr-2.630 {
+ db eval {SELECT a+a+(f)-(t1.f+d+t1.e & case when case (13) when t1.c then case coalesce((select -t1.b-t1.f-13 from t1 where t1.f between t1.d and (a)),t1.b) when b then 13 else t1.f end-f else t1.d end>=e then 19 else t1.c end*t1.c)*f-(t1.d)-b FROM t1 WHERE NOT ((t1.b)=t1.a+t1.d-13 | +~f+13 | e+t1.c+coalesce((select t1.a+e from t1 where b in (select (~max(b-t1.b-coalesce((select ((a)) from t1 where e=d or b not between b and t1.e),t1.b)))++~case case count(*) when -max(t1.c) then min(b) else min(17) end when max( -t1.a) then (min(t1.f)) else max((a)) end*cast(avg(f) AS integer)+max(19) from t1 union select count(distinct f) from t1)),(t1.e)) | t1.b)}
+} {-854200}
+do_test randexpr-2.631 {
+ db eval {SELECT 19-e+t1.d | 19-(abs(11)/abs(t1.b-(select case cast(avg(t1.f) AS integer)-count(*)-count(distinct t1.c)-abs(count(*))-(cast(avg(case when 11<b then d when (c) in (t1.a,t1.b,t1.a) then t1.a else t1.f end) AS integer) | min(t1.a) | (max(t1.a)))+max((t1.d)) when min(t1.a) then -count(*) else min((e)) end from t1)*19))-c+13 FROM t1 WHERE case when case when not b-(t1.c)-11 in (case -(b*11) when t1.d then coalesce((select 13 from t1 where e<>b),t1.d) else ~11 end+t1.b,11,19) then t1.a else -t1.d-case d*a when t1.d then t1.e else 13 end end+e+b>19 then t1.a else t1.f end not between t1.d and e}
+} {-1}
+do_test randexpr-2.632 {
+ db eval {SELECT 19-e+t1.d | 19-(abs(11)/abs(t1.b-(select case cast(avg(t1.f) AS integer)-count(*)-count(distinct t1.c)-abs(count(*))-(cast(avg(case when 11<b then d when (c) in (t1.a,t1.b,t1.a) then t1.a else t1.f end) AS integer) | min(t1.a) | (max(t1.a)))+max((t1.d)) when min(t1.a) then -count(*) else min((e)) end from t1)*19))-c+13 FROM t1 WHERE NOT (case when case when not b-(t1.c)-11 in (case -(b*11) when t1.d then coalesce((select 13 from t1 where e<>b),t1.d) else ~11 end+t1.b,11,19) then t1.a else -t1.d-case d*a when t1.d then t1.e else 13 end end+e+b>19 then t1.a else t1.f end not between t1.d and e)}
+} {}
+do_test randexpr-2.633 {
+ db eval {SELECT 19-e+t1.d & 19-(abs(11)/abs(t1.b-(select case cast(avg(t1.f) AS integer)-count(*)-count(distinct t1.c)-abs(count(*))-(cast(avg(case when 11<b then d when (c) in (t1.a,t1.b,t1.a) then t1.a else t1.f end) AS integer) & min(t1.a) & (max(t1.a)))+max((t1.d)) when min(t1.a) then -count(*) else min((e)) end from t1)*19))-c+13 FROM t1 WHERE case when case when not b-(t1.c)-11 in (case -(b*11) when t1.d then coalesce((select 13 from t1 where e<>b),t1.d) else ~11 end+t1.b,11,19) then t1.a else -t1.d-case d*a when t1.d then t1.e else 13 end end+e+b>19 then t1.a else t1.f end not between t1.d and e}
+} {-348}
+do_test randexpr-2.634 {
+ db eval {SELECT (select abs(abs(~ -min(case t1.a-d when (abs(f)/abs(f+t1.b)) then ~e-11-+ -13*t1.a else 13 end)-count(*)*case + -count(*) when (count(distinct t1.e)) then max(t1.f) else (count(*)* - -+count(*) | min(17)) end+(cast(avg(t1.f) AS integer))+min(d))) from t1) FROM t1 WHERE not t1.f>=t1.a or not exists(select 1 from t1 where 19=17) and 13 in (select abs(count(*) | ((count(*)))) from t1 union select count(distinct -t1.c | t1.a) | abs(abs(min(d+c))) from t1)}
+} {}
+do_test randexpr-2.635 {
+ db eval {SELECT (select abs(abs(~ -min(case t1.a-d when (abs(f)/abs(f+t1.b)) then ~e-11-+ -13*t1.a else 13 end)-count(*)*case + -count(*) when (count(distinct t1.e)) then max(t1.f) else (count(*)* - -+count(*) | min(17)) end+(cast(avg(t1.f) AS integer))+min(d))) from t1) FROM t1 WHERE NOT (not t1.f>=t1.a or not exists(select 1 from t1 where 19=17) and 13 in (select abs(count(*) | ((count(*)))) from t1 union select count(distinct -t1.c | t1.a) | abs(abs(min(d+c))) from t1))}
+} {995}
+do_test randexpr-2.636 {
+ db eval {SELECT (select abs(abs(~ -min(case t1.a-d when (abs(f)/abs(f+t1.b)) then ~e-11-+ -13*t1.a else 13 end)-count(*)*case + -count(*) when (count(distinct t1.e)) then max(t1.f) else (count(*)* - -+count(*) & min(17)) end+(cast(avg(t1.f) AS integer))+min(d))) from t1) FROM t1 WHERE NOT (not t1.f>=t1.a or not exists(select 1 from t1 where 19=17) and 13 in (select abs(count(*) | ((count(*)))) from t1 union select count(distinct -t1.c | t1.a) | abs(abs(min(d+c))) from t1))}
+} {1011}
+do_test randexpr-2.637 {
+ db eval {SELECT (case when not exists(select 1 from t1 where ((not t1.f in (b,17-d,t1.a) and f<t1.f)) or b=t1.e or a in (select - -count(distinct t1.c) from t1 union select min(11) from t1)) then (select case max( -t1.c) when (~ -count(distinct (b))-count(*))* -count(*) then count(distinct 11) else -cast(avg(c) AS integer) end | min(t1.e)*cast(avg(13) AS integer) from t1)+b else (abs(t1.c)/abs( -b)) end-t1.b) FROM t1 WHERE exists(select 1 from t1 where (13>=t1.a))}
+} {}
+do_test randexpr-2.638 {
+ db eval {SELECT (case when not exists(select 1 from t1 where ((not t1.f in (b,17-d,t1.a) and f<t1.f)) or b=t1.e or a in (select - -count(distinct t1.c) from t1 union select min(11) from t1)) then (select case max( -t1.c) when (~ -count(distinct (b))-count(*))* -count(*) then count(distinct 11) else -cast(avg(c) AS integer) end | min(t1.e)*cast(avg(13) AS integer) from t1)+b else (abs(t1.c)/abs( -b)) end-t1.b) FROM t1 WHERE NOT (exists(select 1 from t1 where (13>=t1.a)))}
+} {-12}
+do_test randexpr-2.639 {
+ db eval {SELECT (case when not exists(select 1 from t1 where ((not t1.f in (b,17-d,t1.a) and f<t1.f)) or b=t1.e or a in (select - -count(distinct t1.c) from t1 union select min(11) from t1)) then (select case max( -t1.c) when (~ -count(distinct (b))-count(*))* -count(*) then count(distinct 11) else -cast(avg(c) AS integer) end & min(t1.e)*cast(avg(13) AS integer) from t1)+b else (abs(t1.c)/abs( -b)) end-t1.b) FROM t1 WHERE NOT (exists(select 1 from t1 where (13>=t1.a)))}
+} {6212}
+do_test randexpr-2.640 {
+ db eval {SELECT coalesce((select t1.a from t1 where case when +(abs(e)/abs(19))+(abs(coalesce((select max(b) from t1 where 19 not in (f,(c),11) or -c not in (t1.f,e,d)),13)*e+t1.f)/abs((d)))<>t1.b then t1.e when t1.d not in (t1.f,17,t1.b) or t1.f not between t1.d and 13 then t1.a else t1.e end>e or not exists(select 1 from t1 where a>=e or not exists(select 1 from t1 where d<>t1.b))),f)+19 FROM t1 WHERE 13 in (case when (select +max( -t1.b+a*case when not 13*13<t1.c then 19 else d end*11*c)+max(b) from t1)<>t1.f and ~e>= -t1.b then t1.c when 11 not between t1.d and e and (d<c) then t1.f else d end | e,a,t1.c)}
+} {}
+do_test randexpr-2.641 {
+ db eval {SELECT coalesce((select t1.a from t1 where case when +(abs(e)/abs(19))+(abs(coalesce((select max(b) from t1 where 19 not in (f,(c),11) or -c not in (t1.f,e,d)),13)*e+t1.f)/abs((d)))<>t1.b then t1.e when t1.d not in (t1.f,17,t1.b) or t1.f not between t1.d and 13 then t1.a else t1.e end>e or not exists(select 1 from t1 where a>=e or not exists(select 1 from t1 where d<>t1.b))),f)+19 FROM t1 WHERE NOT (13 in (case when (select +max( -t1.b+a*case when not 13*13<t1.c then 19 else d end*11*c)+max(b) from t1)<>t1.f and ~e>= -t1.b then t1.c when 11 not between t1.d and e and (d<c) then t1.f else d end | e,a,t1.c))}
+} {119}
+do_test randexpr-2.642 {
+ db eval {SELECT +coalesce((select case when coalesce((select f+t1.e from t1 where b not in (case when not exists(select 1 from t1 where (f not in (t1.f-t1.b,t1.d,t1.d))) then t1.a when t1.f*t1.c*17>+(t1.e*(d))-t1.d then t1.f else 11 end,17,f)),e) | 19-13<d then t1.a else t1.d end from t1 where d not between c and e),19) FROM t1 WHERE not exists(select 1 from t1 where ((t1.c not between case d-c+(t1.b) when d then 17 else 13 end+f and coalesce((select t1.f from t1 where ((t1.f*case when not exists(select 1 from t1 where t1.f>=t1.b) then (select max(11)-(count(distinct f)) from t1) else t1.a end+c in (t1.d,e,f) or e in (11,11,11)))),b)*t1.b*11))) and t1.b>=a}
+} {}
+do_test randexpr-2.643 {
+ db eval {SELECT +coalesce((select case when coalesce((select f+t1.e from t1 where b not in (case when not exists(select 1 from t1 where (f not in (t1.f-t1.b,t1.d,t1.d))) then t1.a when t1.f*t1.c*17>+(t1.e*(d))-t1.d then t1.f else 11 end,17,f)),e) | 19-13<d then t1.a else t1.d end from t1 where d not between c and e),19) FROM t1 WHERE NOT (not exists(select 1 from t1 where ((t1.c not between case d-c+(t1.b) when d then 17 else 13 end+f and coalesce((select t1.f from t1 where ((t1.f*case when not exists(select 1 from t1 where t1.f>=t1.b) then (select max(11)-(count(distinct f)) from t1) else t1.a end+c in (t1.d,e,f) or e in (11,11,11)))),b)*t1.b*11))) and t1.b>=a)}
+} {19}
+do_test randexpr-2.644 {
+ db eval {SELECT +coalesce((select case when coalesce((select f+t1.e from t1 where b not in (case when not exists(select 1 from t1 where (f not in (t1.f-t1.b,t1.d,t1.d))) then t1.a when t1.f*t1.c*17>+(t1.e*(d))-t1.d then t1.f else 11 end,17,f)),e) & 19-13<d then t1.a else t1.d end from t1 where d not between c and e),19) FROM t1 WHERE NOT (not exists(select 1 from t1 where ((t1.c not between case d-c+(t1.b) when d then 17 else 13 end+f and coalesce((select t1.f from t1 where ((t1.f*case when not exists(select 1 from t1 where t1.f>=t1.b) then (select max(11)-(count(distinct f)) from t1) else t1.a end+c in (t1.d,e,f) or e in (11,11,11)))),b)*t1.b*11))) and t1.b>=a)}
+} {19}
+do_test randexpr-2.645 {
+ db eval {SELECT (case when case 19 when b then 13 else t1.e end in (select (c) from t1 union select a from t1) then 11 else (d*coalesce((select t1.b from t1 where 19 | (t1.c)+case when -17>t1.a then t1.a when (19>=13) then t1.a else t1.e end=f and (e)>a or 11 in (select e from t1 union select t1.b from t1)),t1.d*t1.e))+c+a end) FROM t1 WHERE case case when case when not (abs(t1.d | f)/abs(a)) in (d,a,t1.c) then -d when (not exists(select 1 from t1 where f>=c)) then t1.a else e end+t1.d not in (t1.b,(t1.f),11) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b in (19,t1.c,13))) then b+t1.c when t1.d>=t1.a then t1.c else (c) end when (13) then t1.e else b end in (t1.a,t1.b,13)}
+} {80000400}
+do_test randexpr-2.646 {
+ db eval {SELECT (case when case 19 when b then 13 else t1.e end in (select (c) from t1 union select a from t1) then 11 else (d*coalesce((select t1.b from t1 where 19 | (t1.c)+case when -17>t1.a then t1.a when (19>=13) then t1.a else t1.e end=f and (e)>a or 11 in (select e from t1 union select t1.b from t1)),t1.d*t1.e))+c+a end) FROM t1 WHERE NOT (case case when case when not (abs(t1.d | f)/abs(a)) in (d,a,t1.c) then -d when (not exists(select 1 from t1 where f>=c)) then t1.a else e end+t1.d not in (t1.b,(t1.f),11) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b in (19,t1.c,13))) then b+t1.c when t1.d>=t1.a then t1.c else (c) end when (13) then t1.e else b end in (t1.a,t1.b,13))}
+} {}
+do_test randexpr-2.647 {
+ db eval {SELECT (case when case 19 when b then 13 else t1.e end in (select (c) from t1 union select a from t1) then 11 else (d*coalesce((select t1.b from t1 where 19 & (t1.c)+case when -17>t1.a then t1.a when (19>=13) then t1.a else t1.e end=f and (e)>a or 11 in (select e from t1 union select t1.b from t1)),t1.d*t1.e))+c+a end) FROM t1 WHERE case case when case when not (abs(t1.d | f)/abs(a)) in (d,a,t1.c) then -d when (not exists(select 1 from t1 where f>=c)) then t1.a else e end+t1.d not in (t1.b,(t1.f),11) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b in (19,t1.c,13))) then b+t1.c when t1.d>=t1.a then t1.c else (c) end when (13) then t1.e else b end in (t1.a,t1.b,13)}
+} {80000400}
+do_test randexpr-2.648 {
+ db eval {SELECT case when 19<=19 then d when not exists(select 1 from t1 where case case when case when (select -min(((t1.f)))*((cast(avg(t1.d) AS integer))) from t1) in (select t1.a-b from t1 union select 17 from t1) then f when (19 not between t1.c and 13 and f>13) then d else a end | b-t1.b in (t1.e,t1.f, -d) then t1.e when c<t1.e then ( -b) else (c) end-t1.e | (17)+17 when 13 then t1.a else d end+19>=17) then t1.e else t1.e end FROM t1 WHERE coalesce((select +a- -t1.d*b*coalesce((select t1.c from t1 where t1.a in (select (abs(11)/abs(case when not exists(select 1 from t1 where +e=t1.e) then case t1.b when a-c then b else b end when (not exists(select 1 from t1 where 19 in (select 13 from t1 union select t1.b from t1))) and e in (t1.e, -f,e) then 19 else t1.a end)) from t1 union select b from t1)),17)*d from t1 where t1.f not in (t1.a,(t1.b),t1.d)),13)<=(13)}
+} {}
+do_test randexpr-2.649 {
+ db eval {SELECT case when 19<=19 then d when not exists(select 1 from t1 where case case when case when (select -min(((t1.f)))*((cast(avg(t1.d) AS integer))) from t1) in (select t1.a-b from t1 union select 17 from t1) then f when (19 not between t1.c and 13 and f>13) then d else a end | b-t1.b in (t1.e,t1.f, -d) then t1.e when c<t1.e then ( -b) else (c) end-t1.e | (17)+17 when 13 then t1.a else d end+19>=17) then t1.e else t1.e end FROM t1 WHERE NOT (coalesce((select +a- -t1.d*b*coalesce((select t1.c from t1 where t1.a in (select (abs(11)/abs(case when not exists(select 1 from t1 where +e=t1.e) then case t1.b when a-c then b else b end when (not exists(select 1 from t1 where 19 in (select 13 from t1 union select t1.b from t1))) and e in (t1.e, -f,e) then 19 else t1.a end)) from t1 union select b from t1)),17)*d from t1 where t1.f not in (t1.a,(t1.b),t1.d)),13)<=(13))}
+} {400}
+do_test randexpr-2.650 {
+ db eval {SELECT case when 19<=19 then d when not exists(select 1 from t1 where case case when case when (select -min(((t1.f)))*((cast(avg(t1.d) AS integer))) from t1) in (select t1.a-b from t1 union select 17 from t1) then f when (19 not between t1.c and 13 and f>13) then d else a end & b-t1.b in (t1.e,t1.f, -d) then t1.e when c<t1.e then ( -b) else (c) end-t1.e & (17)+17 when 13 then t1.a else d end+19>=17) then t1.e else t1.e end FROM t1 WHERE NOT (coalesce((select +a- -t1.d*b*coalesce((select t1.c from t1 where t1.a in (select (abs(11)/abs(case when not exists(select 1 from t1 where +e=t1.e) then case t1.b when a-c then b else b end when (not exists(select 1 from t1 where 19 in (select 13 from t1 union select t1.b from t1))) and e in (t1.e, -f,e) then 19 else t1.a end)) from t1 union select b from t1)),17)*d from t1 where t1.f not in (t1.a,(t1.b),t1.d)),13)<=(13))}
+} {400}
+do_test randexpr-2.651 {
+ db eval {SELECT case when c<=t1.b*e+case when not exists(select 1 from t1 where a+ -t1.f= -t1.e*(17)+f and 19 in (select -13 from t1 union select t1.f from t1) and 19>=t1.a or -11 in (select a from t1 union select 17 from t1)) then t1.f else 19 end+t1.d or ((c))<>a then t1.f-t1.c when c not between ((t1.b)) and f then a else d end FROM t1 WHERE coalesce((select t1.e from t1 where t1.c in (t1.a,f,coalesce((select max( -f) from t1 where t1.f<coalesce((select (select cast(avg(b) AS integer) from t1) from t1 where a>=(abs(13)/abs(~19+(abs((select count(distinct t1.f) from t1))/abs(coalesce((select 13 from t1 where d | 17*c*a*b+d<>t1.a),b)-(b)))))),b)),19))),t1.e)*c<>t1.e}
+} {300}
+do_test randexpr-2.652 {
+ db eval {SELECT case when c<=t1.b*e+case when not exists(select 1 from t1 where a+ -t1.f= -t1.e*(17)+f and 19 in (select -13 from t1 union select t1.f from t1) and 19>=t1.a or -11 in (select a from t1 union select 17 from t1)) then t1.f else 19 end+t1.d or ((c))<>a then t1.f-t1.c when c not between ((t1.b)) and f then a else d end FROM t1 WHERE NOT (coalesce((select t1.e from t1 where t1.c in (t1.a,f,coalesce((select max( -f) from t1 where t1.f<coalesce((select (select cast(avg(b) AS integer) from t1) from t1 where a>=(abs(13)/abs(~19+(abs((select count(distinct t1.f) from t1))/abs(coalesce((select 13 from t1 where d | 17*c*a*b+d<>t1.a),b)-(b)))))),b)),19))),t1.e)*c<>t1.e)}
+} {}
+do_test randexpr-2.653 {
+ db eval {SELECT case when t1.c>=13 or d in (select case ((case min(t1.f)+min(f) when max( -11) then min(19) else cast(avg( -t1.d) AS integer) end | count(*))) when count(distinct 13) then -cast(avg( -t1.e) AS integer) else min(e) end from t1 union select max( -a) from t1) then case when +c-11+(t1.d)<e or f in (select 17 from t1 union select 13 from t1) then f when t1.c in (select t1.c from t1 union select 19 from t1) then t1.f else -f end when e in (a,19,t1.e) then t1.d else f end FROM t1 WHERE (c<=t1.f or 11<case when t1.b+ -~a*case when exists(select 1 from t1 where case when b | 17 not between 17 and c then 11 else t1.e end in (d,a,b)) then t1.b when t1.b not in (t1.f,b,c) then 11 else b end>13 then d when not exists(select 1 from t1 where t1.c in (f,t1.b,t1.b)) then a else 19 end*t1.c and t1.d>=19)}
+} {600}
+do_test randexpr-2.654 {
+ db eval {SELECT case when t1.c>=13 or d in (select case ((case min(t1.f)+min(f) when max( -11) then min(19) else cast(avg( -t1.d) AS integer) end | count(*))) when count(distinct 13) then -cast(avg( -t1.e) AS integer) else min(e) end from t1 union select max( -a) from t1) then case when +c-11+(t1.d)<e or f in (select 17 from t1 union select 13 from t1) then f when t1.c in (select t1.c from t1 union select 19 from t1) then t1.f else -f end when e in (a,19,t1.e) then t1.d else f end FROM t1 WHERE NOT ((c<=t1.f or 11<case when t1.b+ -~a*case when exists(select 1 from t1 where case when b | 17 not between 17 and c then 11 else t1.e end in (d,a,b)) then t1.b when t1.b not in (t1.f,b,c) then 11 else b end>13 then d when not exists(select 1 from t1 where t1.c in (f,t1.b,t1.b)) then a else 19 end*t1.c and t1.d>=19))}
+} {}
+do_test randexpr-2.655 {
+ db eval {SELECT case when t1.c>=13 or d in (select case ((case min(t1.f)+min(f) when max( -11) then min(19) else cast(avg( -t1.d) AS integer) end & count(*))) when count(distinct 13) then -cast(avg( -t1.e) AS integer) else min(e) end from t1 union select max( -a) from t1) then case when +c-11+(t1.d)<e or f in (select 17 from t1 union select 13 from t1) then f when t1.c in (select t1.c from t1 union select 19 from t1) then t1.f else -f end when e in (a,19,t1.e) then t1.d else f end FROM t1 WHERE (c<=t1.f or 11<case when t1.b+ -~a*case when exists(select 1 from t1 where case when b | 17 not between 17 and c then 11 else t1.e end in (d,a,b)) then t1.b when t1.b not in (t1.f,b,c) then 11 else b end>13 then d when not exists(select 1 from t1 where t1.c in (f,t1.b,t1.b)) then a else 19 end*t1.c and t1.d>=19)}
+} {600}
+do_test randexpr-2.656 {
+ db eval {SELECT t1.a+(e*a)*t1.d+(abs(d)/abs(case when case f when t1.a then t1.f else d end*t1.f*t1.e*c*17+coalesce((select t1.d from t1 where c<=~t1.f | 13),e)*t1.a<case when 13 between a and 19 and c<a then t1.b else f end then t1.e when exists(select 1 from t1 where ((t1.b)=t1.f)) then t1.c else f end)) FROM t1 WHERE d*19 between 11 and f}
+} {}
+do_test randexpr-2.657 {
+ db eval {SELECT t1.a+(e*a)*t1.d+(abs(d)/abs(case when case f when t1.a then t1.f else d end*t1.f*t1.e*c*17+coalesce((select t1.d from t1 where c<=~t1.f | 13),e)*t1.a<case when 13 between a and 19 and c<a then t1.b else f end then t1.e when exists(select 1 from t1 where ((t1.b)=t1.f)) then t1.c else f end)) FROM t1 WHERE NOT (d*19 between 11 and f)}
+} {20000100}
+do_test randexpr-2.658 {
+ db eval {SELECT t1.a+(e*a)*t1.d+(abs(d)/abs(case when case f when t1.a then t1.f else d end*t1.f*t1.e*c*17+coalesce((select t1.d from t1 where c<=~t1.f & 13),e)*t1.a<case when 13 between a and 19 and c<a then t1.b else f end then t1.e when exists(select 1 from t1 where ((t1.b)=t1.f)) then t1.c else f end)) FROM t1 WHERE NOT (d*19 between 11 and f)}
+} {20000100}
+do_test randexpr-2.659 {
+ db eval {SELECT case f when (abs(t1.f)/abs(case when d+case when exists(select 1 from t1 where exists(select 1 from t1 where exists(select 1 from t1 where case when not case when +11>=t1.d then t1.d when (t1.b)<>17 or t1.b<=t1.c then a else (e) end in (select min(t1.e) from t1 union select abs( -max((17))) from t1) then c when 19<>17 then 13 else -d end>t1.d))) then 17 when t1.a<=13 then coalesce((select (17) | t1.c from t1 where t1.e>d),b) else 13 end in (select min(f) from t1 union select count(*) from t1) then 19 else t1.f end)) then t1.f else f end FROM t1 WHERE coalesce((select max(11 | e+case c*t1.b+13 when 19 | ~t1.f+case when d>11 then t1.f-(case t1.d when a then 19+t1.f else t1.b end) else d-case e when c+t1.a then 13 else case when not exists(select 1 from t1 where (t1.d)<>17) then d when b in ( -f,11,17) then 11 else t1.f end end end+d then e else t1.a end) from t1 where t1.a>= -11),b)>t1.c}
+} {600}
+do_test randexpr-2.660 {
+ db eval {SELECT case f when (abs(t1.f)/abs(case when d+case when exists(select 1 from t1 where exists(select 1 from t1 where exists(select 1 from t1 where case when not case when +11>=t1.d then t1.d when (t1.b)<>17 or t1.b<=t1.c then a else (e) end in (select min(t1.e) from t1 union select abs( -max((17))) from t1) then c when 19<>17 then 13 else -d end>t1.d))) then 17 when t1.a<=13 then coalesce((select (17) | t1.c from t1 where t1.e>d),b) else 13 end in (select min(f) from t1 union select count(*) from t1) then 19 else t1.f end)) then t1.f else f end FROM t1 WHERE NOT (coalesce((select max(11 | e+case c*t1.b+13 when 19 | ~t1.f+case when d>11 then t1.f-(case t1.d when a then 19+t1.f else t1.b end) else d-case e when c+t1.a then 13 else case when not exists(select 1 from t1 where (t1.d)<>17) then d when b in ( -f,11,17) then 11 else t1.f end end end+d then e else t1.a end) from t1 where t1.a>= -11),b)>t1.c)}
+} {}
+do_test randexpr-2.661 {
+ db eval {SELECT case f when (abs(t1.f)/abs(case when d+case when exists(select 1 from t1 where exists(select 1 from t1 where exists(select 1 from t1 where case when not case when +11>=t1.d then t1.d when (t1.b)<>17 or t1.b<=t1.c then a else (e) end in (select min(t1.e) from t1 union select abs( -max((17))) from t1) then c when 19<>17 then 13 else -d end>t1.d))) then 17 when t1.a<=13 then coalesce((select (17) & t1.c from t1 where t1.e>d),b) else 13 end in (select min(f) from t1 union select count(*) from t1) then 19 else t1.f end)) then t1.f else f end FROM t1 WHERE coalesce((select max(11 | e+case c*t1.b+13 when 19 | ~t1.f+case when d>11 then t1.f-(case t1.d when a then 19+t1.f else t1.b end) else d-case e when c+t1.a then 13 else case when not exists(select 1 from t1 where (t1.d)<>17) then d when b in ( -f,11,17) then 11 else t1.f end end end+d then e else t1.a end) from t1 where t1.a>= -11),b)>t1.c}
+} {600}
+do_test randexpr-2.662 {
+ db eval {SELECT (select abs(case max(t1.b)-(min(17))* -count(distinct case when case t1.f when t1.b then case e when c then t1.c else c end else t1.b end>=t1.e then d else e end) | ~+count(distinct t1.c)-(abs( -count(*))- -max(c)) | count(distinct t1.c) when count(distinct ( -t1.c)) then count(*) else max(t1.b) end* -count(*))-cast(avg( -11) AS integer)*min(19)+max(e) from t1) FROM t1 WHERE t1.a+t1.a>13}
+} {909}
+do_test randexpr-2.663 {
+ db eval {SELECT (select abs(case max(t1.b)-(min(17))* -count(distinct case when case t1.f when t1.b then case e when c then t1.c else c end else t1.b end>=t1.e then d else e end) | ~+count(distinct t1.c)-(abs( -count(*))- -max(c)) | count(distinct t1.c) when count(distinct ( -t1.c)) then count(*) else max(t1.b) end* -count(*))-cast(avg( -11) AS integer)*min(19)+max(e) from t1) FROM t1 WHERE NOT (t1.a+t1.a>13)}
+} {}
+do_test randexpr-2.664 {
+ db eval {SELECT (select abs(case max(t1.b)-(min(17))* -count(distinct case when case t1.f when t1.b then case e when c then t1.c else c end else t1.b end>=t1.e then d else e end) & ~+count(distinct t1.c)-(abs( -count(*))- -max(c)) & count(distinct t1.c) when count(distinct ( -t1.c)) then count(*) else max(t1.b) end* -count(*))-cast(avg( -11) AS integer)*min(19)+max(e) from t1) FROM t1 WHERE t1.a+t1.a>13}
+} {710}
+do_test randexpr-2.665 {
+ db eval {SELECT (t1.d- -c+e-f++case when a between case f when case when ~~~11-coalesce((select b from t1 where coalesce((select max(e) from t1 where not t1.d>= -11),a)+a between 11 and t1.a), -d)*17-a-13 | 13>=17 then a else 11 end then t1.a else t1.d end and t1.f then 19 else t1.a end) FROM t1 WHERE t1.f<> -13}
+} {700}
+do_test randexpr-2.666 {
+ db eval {SELECT (t1.d- -c+e-f++case when a between case f when case when ~~~11-coalesce((select b from t1 where coalesce((select max(e) from t1 where not t1.d>= -11),a)+a between 11 and t1.a), -d)*17-a-13 | 13>=17 then a else 11 end then t1.a else t1.d end and t1.f then 19 else t1.a end) FROM t1 WHERE NOT (t1.f<> -13)}
+} {}
+do_test randexpr-2.667 {
+ db eval {SELECT (t1.d- -c+e-f++case when a between case f when case when ~~~11-coalesce((select b from t1 where coalesce((select max(e) from t1 where not t1.d>= -11),a)+a between 11 and t1.a), -d)*17-a-13 & 13>=17 then a else 11 end then t1.a else t1.d end and t1.f then 19 else t1.a end) FROM t1 WHERE t1.f<> -13}
+} {700}
+do_test randexpr-2.668 {
+ db eval {SELECT (abs(case when (c<=b+t1.b) then -11+t1.a-d when b*(select count(distinct e)*+max(~t1.a*case when (select count(*)*+min(t1.b)+max(t1.a) from t1) in (c,t1.d,t1.d) then (select -(count(*)) from t1) else e end) from t1)<=a-11 then 11 else t1.e end)/abs(t1.e))+c FROM t1 WHERE a<+coalesce((select t1.f from t1 where exists(select 1 from t1 where ~case when (e not between t1.a-~case d when b then -c else 13 end and d) then 11 else a end+17-f-a*19*t1.f not in (f, -t1.d,11))),c)-t1.f and (t1.d<17) and t1.f=c or f<= -e}
+} {}
+do_test randexpr-2.669 {
+ db eval {SELECT (abs(case when (c<=b+t1.b) then -11+t1.a-d when b*(select count(distinct e)*+max(~t1.a*case when (select count(*)*+min(t1.b)+max(t1.a) from t1) in (c,t1.d,t1.d) then (select -(count(*)) from t1) else e end) from t1)<=a-11 then 11 else t1.e end)/abs(t1.e))+c FROM t1 WHERE NOT (a<+coalesce((select t1.f from t1 where exists(select 1 from t1 where ~case when (e not between t1.a-~case d when b then -c else 13 end and d) then 11 else a end+17-f-a*19*t1.f not in (f, -t1.d,11))),c)-t1.f and (t1.d<17) and t1.f=c or f<= -e)}
+} {300}
+do_test randexpr-2.670 {
+ db eval {SELECT case when case when c in (select abs((max(d*case t1.b when t1.b+t1.f then d else b end+d))- - -~count(*)*cast(avg(t1.b) AS integer)-min(d)*cast(avg(b) AS integer)*count(*)) from t1 union select -count(distinct t1.f) from t1) then case when 17 between t1.f and 11 then c else d end when t1.c>=13 then a else a end<=c then t1.d else 13 end+e FROM t1 WHERE t1.f between -11 and b}
+} {}
+do_test randexpr-2.671 {
+ db eval {SELECT case when case when c in (select abs((max(d*case t1.b when t1.b+t1.f then d else b end+d))- - -~count(*)*cast(avg(t1.b) AS integer)-min(d)*cast(avg(b) AS integer)*count(*)) from t1 union select -count(distinct t1.f) from t1) then case when 17 between t1.f and 11 then c else d end when t1.c>=13 then a else a end<=c then t1.d else 13 end+e FROM t1 WHERE NOT (t1.f between -11 and b)}
+} {900}
+do_test randexpr-2.672 {
+ db eval {SELECT b*~~t1.b*(a-t1.c+t1.b)+13-+~case t1.b when d then case 17*13 when t1.e then case when case when t1.c<>~(11) then t1.e else coalesce((select max( -c) from t1 where (f<>e)),t1.f) end<=a then (t1.c) else t1.c end else -f end else 13 end*t1.e-t1.f | 13 FROM t1 WHERE b between (d) and t1.c*(abs(t1.c-13 | t1.d+t1.a)/abs(13))}
+} {}
+do_test randexpr-2.673 {
+ db eval {SELECT b*~~t1.b*(a-t1.c+t1.b)+13-+~case t1.b when d then case 17*13 when t1.e then case when case when t1.c<>~(11) then t1.e else coalesce((select max( -c) from t1 where (f<>e)),t1.f) end<=a then (t1.c) else t1.c end else -f end else 13 end*t1.e-t1.f | 13 FROM t1 WHERE NOT (b between (d) and t1.c*(abs(t1.c-13 | t1.d+t1.a)/abs(13)))}
+} {6413}
+do_test randexpr-2.674 {
+ db eval {SELECT b*~~t1.b*(a-t1.c+t1.b)+13-+~case t1.b when d then case 17*13 when t1.e then case when case when t1.c<>~(11) then t1.e else coalesce((select max( -c) from t1 where (f<>e)),t1.f) end<=a then (t1.c) else t1.c end else -f end else 13 end*t1.e-t1.f & 13 FROM t1 WHERE NOT (b between (d) and t1.c*(abs(t1.c-13 | t1.d+t1.a)/abs(13)))}
+} {13}
+do_test randexpr-2.675 {
+ db eval {SELECT case when t1.b in (select case 13 when 13 | t1.e then case +(select (min((e)))-case count(*) | max(t1.b*d+17+e) when abs(count(distinct (11))*count(*)-cast(avg(a) AS integer) | max( -t1.a)) then (count(distinct 13)) else -(cast(avg(t1.b) AS integer)) end from t1) when (select count(distinct e) from t1) then t1.e else a+(t1.b) end-d-t1.d else t1.e end from t1 union select (f) from t1) then t1.b else (b) end FROM t1 WHERE b in (select a from t1 union select 11+t1.e from t1)}
+} {}
+do_test randexpr-2.676 {
+ db eval {SELECT case when t1.b in (select case 13 when 13 | t1.e then case +(select (min((e)))-case count(*) | max(t1.b*d+17+e) when abs(count(distinct (11))*count(*)-cast(avg(a) AS integer) | max( -t1.a)) then (count(distinct 13)) else -(cast(avg(t1.b) AS integer)) end from t1) when (select count(distinct e) from t1) then t1.e else a+(t1.b) end-d-t1.d else t1.e end from t1 union select (f) from t1) then t1.b else (b) end FROM t1 WHERE NOT (b in (select a from t1 union select 11+t1.e from t1))}
+} {200}
+do_test randexpr-2.677 {
+ db eval {SELECT case when t1.b in (select case 13 when 13 & t1.e then case +(select (min((e)))-case count(*) & max(t1.b*d+17+e) when abs(count(distinct (11))*count(*)-cast(avg(a) AS integer) & max( -t1.a)) then (count(distinct 13)) else -(cast(avg(t1.b) AS integer)) end from t1) when (select count(distinct e) from t1) then t1.e else a+(t1.b) end-d-t1.d else t1.e end from t1 union select (f) from t1) then t1.b else (b) end FROM t1 WHERE NOT (b in (select a from t1 union select 11+t1.e from t1))}
+} {200}
+do_test randexpr-2.678 {
+ db eval {SELECT coalesce((select 17 from t1 where d between 17 and 13),case when t1.f in (select c+a from t1 union select a from t1) and (abs(f)/abs(t1.b))-t1.e>=case when not exists(select 1 from t1 where t1.e>(select count(distinct t1.f) from t1)) then t1.f when (11)-~t1.f<case 13 when f then 19 else coalesce((select -t1.c from t1 where 11<=t1.e),e) end then t1.e else 13 end*t1.e then t1.f else b end) FROM t1 WHERE -coalesce((select max(11) from t1 where (abs( -case 19 when (abs(coalesce((select max(coalesce((select 13 from t1 where a>e),b)) from t1 where (t1.f) in (13,e,t1.c) or t1.c>13),t1.b))/abs(13)) then t1.b else d end)/abs(13)) in (t1.f,t1.e,t1.a) or 17 between 13 and f or (f>11 and t1.f<t1.b)),case when 19 not between -17 and d then 11 when t1.c=d then t1.a else t1.f end)>=t1.e}
+} {}
+do_test randexpr-2.679 {
+ db eval {SELECT coalesce((select 17 from t1 where d between 17 and 13),case when t1.f in (select c+a from t1 union select a from t1) and (abs(f)/abs(t1.b))-t1.e>=case when not exists(select 1 from t1 where t1.e>(select count(distinct t1.f) from t1)) then t1.f when (11)-~t1.f<case 13 when f then 19 else coalesce((select -t1.c from t1 where 11<=t1.e),e) end then t1.e else 13 end*t1.e then t1.f else b end) FROM t1 WHERE NOT ( -coalesce((select max(11) from t1 where (abs( -case 19 when (abs(coalesce((select max(coalesce((select 13 from t1 where a>e),b)) from t1 where (t1.f) in (13,e,t1.c) or t1.c>13),t1.b))/abs(13)) then t1.b else d end)/abs(13)) in (t1.f,t1.e,t1.a) or 17 between 13 and f or (f>11 and t1.f<t1.b)),case when 19 not between -17 and d then 11 when t1.c=d then t1.a else t1.f end)>=t1.e)}
+} {200}
+do_test randexpr-2.680 {
+ db eval {SELECT (select min(19-case 19 when -t1.a+13 then coalesce((select c from t1 where (abs(13)/abs(11))>=coalesce((select f+b*+t1.c from t1 where t1.c=+11+t1.e),11) or (e in (a,a,13) and t1.a<f) and t1.c not between t1.f and -b),t1.b) else t1.b end) from t1) | f FROM t1 WHERE case 13-t1.e when 13 then f*c else ~f+(abs(t1.f | t1.e-c)/abs((coalesce((select max((select -cast(avg(b) AS integer) from t1)-b) from t1 where 17 in (c,( -(f)),11) and 17>=f or t1.a=t1.e),t1.f)*t1.a+t1.f)*19)) end*f-t1.f in (select d from t1 union select t1.c from t1) and b in (t1.f,t1.d,c)}
+} {}
+do_test randexpr-2.681 {
+ db eval {SELECT (select min(19-case 19 when -t1.a+13 then coalesce((select c from t1 where (abs(13)/abs(11))>=coalesce((select f+b*+t1.c from t1 where t1.c=+11+t1.e),11) or (e in (a,a,13) and t1.a<f) and t1.c not between t1.f and -b),t1.b) else t1.b end) from t1) | f FROM t1 WHERE NOT (case 13-t1.e when 13 then f*c else ~f+(abs(t1.f | t1.e-c)/abs((coalesce((select max((select -cast(avg(b) AS integer) from t1)-b) from t1 where 17 in (c,( -(f)),11) and 17>=f or t1.a=t1.e),t1.f)*t1.a+t1.f)*19)) end*f-t1.f in (select d from t1 union select t1.c from t1) and b in (t1.f,t1.d,c))}
+} {-165}
+do_test randexpr-2.682 {
+ db eval {SELECT (select min(19-case 19 when -t1.a+13 then coalesce((select c from t1 where (abs(13)/abs(11))>=coalesce((select f+b*+t1.c from t1 where t1.c=+11+t1.e),11) or (e in (a,a,13) and t1.a<f) and t1.c not between t1.f and -b),t1.b) else t1.b end) from t1) & f FROM t1 WHERE NOT (case 13-t1.e when 13 then f*c else ~f+(abs(t1.f | t1.e-c)/abs((coalesce((select max((select -cast(avg(b) AS integer) from t1)-b) from t1 where 17 in (c,( -(f)),11) and 17>=f or t1.a=t1.e),t1.f)*t1.a+t1.f)*19)) end*f-t1.f in (select d from t1 union select t1.c from t1) and b in (t1.f,t1.d,c))}
+} {584}
+do_test randexpr-2.683 {
+ db eval {SELECT ~case when exists(select 1 from t1 where t1.c not between case case ~t1.b*19 when b then t1.c*t1.e else t1.d end when c then case ++13 when case when a+d+~~11 not between e and -19 then 19 else b end then t1.d else 19 end else t1.a end and d) then 19 when c in (select abs(count(distinct 17)) from t1 union select max(t1.b) from t1) then (d) else t1.e end | 19 FROM t1 WHERE t1.d between 11 and ~19-coalesce((select d from t1 where (d>=c)),t1.d)*+t1.e+t1.e}
+} {}
+do_test randexpr-2.684 {
+ db eval {SELECT ~case when exists(select 1 from t1 where t1.c not between case case ~t1.b*19 when b then t1.c*t1.e else t1.d end when c then case ++13 when case when a+d+~~11 not between e and -19 then 19 else b end then t1.d else 19 end else t1.a end and d) then 19 when c in (select abs(count(distinct 17)) from t1 union select max(t1.b) from t1) then (d) else t1.e end | 19 FROM t1 WHERE NOT (t1.d between 11 and ~19-coalesce((select d from t1 where (d>=c)),t1.d)*+t1.e+t1.e)}
+} {-485}
+do_test randexpr-2.685 {
+ db eval {SELECT ~case when exists(select 1 from t1 where t1.c not between case case ~t1.b*19 when b then t1.c*t1.e else t1.d end when c then case ++13 when case when a+d+~~11 not between e and -19 then 19 else b end then t1.d else 19 end else t1.a end and d) then 19 when c in (select abs(count(distinct 17)) from t1 union select max(t1.b) from t1) then (d) else t1.e end & 19 FROM t1 WHERE NOT (t1.d between 11 and ~19-coalesce((select d from t1 where (d>=c)),t1.d)*+t1.e+t1.e)}
+} {3}
+do_test randexpr-2.686 {
+ db eval {SELECT +t1.b-17*11-coalesce((select coalesce((select max(t1.f+a-t1.c+b) from t1 where 17* -b+t1.e=13),coalesce((select +t1.f*coalesce((select b from t1 where 19 between -a and c),t1.d) from t1 where 17<>b),17)*11) from t1 where f<c),e) | -t1.e-b-t1.b-t1.e FROM t1 WHERE t1.b=11}
+} {}
+do_test randexpr-2.687 {
+ db eval {SELECT +t1.b-17*11-coalesce((select coalesce((select max(t1.f+a-t1.c+b) from t1 where 17* -b+t1.e=13),coalesce((select +t1.f*coalesce((select b from t1 where 19 between -a and c),t1.d) from t1 where 17<>b),17)*11) from t1 where f<c),e) | -t1.e-b-t1.b-t1.e FROM t1 WHERE NOT (t1.b=11)}
+} {-359}
+do_test randexpr-2.688 {
+ db eval {SELECT +t1.b-17*11-coalesce((select coalesce((select max(t1.f+a-t1.c+b) from t1 where 17* -b+t1.e=13),coalesce((select +t1.f*coalesce((select b from t1 where 19 between -a and c),t1.d) from t1 where 17<>b),17)*11) from t1 where f<c),e) & -t1.e-b-t1.b-t1.e FROM t1 WHERE NOT (t1.b=11)}
+} {-1528}
+do_test randexpr-2.689 {
+ db eval {SELECT -d+t1.d-t1.a-+t1.c-(select +min((abs(+(case when b>=case when b not between -t1.f and c then e else f end or a<=11 or t1.e between a and 11 or t1.d not in (b,d,d) then case when f>=c then t1.c else 19 end when t1.e=a then e else t1.e end) | f)/abs(t1.a))) from t1)+e* -t1.a+f+d FROM t1 WHERE t1.b<=t1.c+ -(abs(t1.b)/abs(case t1.b+t1.e when 11 then t1.c else 17 end))*coalesce((select coalesce((select coalesce((select 13 from t1 where b=t1.b),f) | t1.f-11 from t1 where (t1.c) in (select +min(19)*(~max(b)-max(11))*max(11) from t1 union select min(f) from t1)),t1.f) from t1 where f in (select case count(distinct 19) when max(t1.b) then -cast(avg(t1.e) AS integer) else cast(avg(b) AS integer) end from t1 union select count(*) from t1)),t1.a)}
+} {}
+do_test randexpr-2.690 {
+ db eval {SELECT -d+t1.d-t1.a-+t1.c-(select +min((abs(+(case when b>=case when b not between -t1.f and c then e else f end or a<=11 or t1.e between a and 11 or t1.d not in (b,d,d) then case when f>=c then t1.c else 19 end when t1.e=a then e else t1.e end) | f)/abs(t1.a))) from t1)+e* -t1.a+f+d FROM t1 WHERE NOT (t1.b<=t1.c+ -(abs(t1.b)/abs(case t1.b+t1.e when 11 then t1.c else 17 end))*coalesce((select coalesce((select coalesce((select 13 from t1 where b=t1.b),f) | t1.f-11 from t1 where (t1.c) in (select +min(19)*(~max(b)-max(11))*max(11) from t1 union select min(f) from t1)),t1.f) from t1 where f in (select case count(distinct 19) when max(t1.b) then -cast(avg(t1.e) AS integer) else cast(avg(b) AS integer) end from t1 union select count(*) from t1)),t1.a))}
+} {-49410}
+do_test randexpr-2.691 {
+ db eval {SELECT -d+t1.d-t1.a-+t1.c-(select +min((abs(+(case when b>=case when b not between -t1.f and c then e else f end or a<=11 or t1.e between a and 11 or t1.d not in (b,d,d) then case when f>=c then t1.c else 19 end when t1.e=a then e else t1.e end) & f)/abs(t1.a))) from t1)+e* -t1.a+f+d FROM t1 WHERE NOT (t1.b<=t1.c+ -(abs(t1.b)/abs(case t1.b+t1.e when 11 then t1.c else 17 end))*coalesce((select coalesce((select coalesce((select 13 from t1 where b=t1.b),f) | t1.f-11 from t1 where (t1.c) in (select +min(19)*(~max(b)-max(11))*max(11) from t1 union select min(f) from t1)),t1.f) from t1 where f in (select case count(distinct 19) when max(t1.b) then -cast(avg(t1.e) AS integer) else cast(avg(b) AS integer) end from t1 union select count(*) from t1)),t1.a))}
+} {-49400}
+do_test randexpr-2.692 {
+ db eval {SELECT ~case +t1.a when t1.a then 19 else coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where t1.b*f<>e and e not in (17,t1.c-case when t1.e<19 then t1.c else (abs(t1.c)/abs(d*coalesce((select t1.e from t1 where exists(select 1 from t1 where t1.c in (select t1.f from t1 union select 11 from t1)) or t1.a<=t1.d),a))) end*t1.e,t1.e))),coalesce((select max(a) from t1 where (b) in ((11),e,b)),17)) end FROM t1 WHERE not (c)+c*d>t1.e and exists(select 1 from t1 where d*coalesce((select +case when ((select cast(avg((c)) AS integer)- -cast(avg(a) AS integer) from t1) in (select min(b)-count(*) from t1 union select count(distinct 19) from t1)) or not t1.b between 19 and 19 then t1.c else coalesce((select e from t1 where t1.e>=e),c) end from t1 where ( -f)<a),17)>19) and 17<> -t1.e and b>=a}
+} {}
+do_test randexpr-2.693 {
+ db eval {SELECT ~case +t1.a when t1.a then 19 else coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where t1.b*f<>e and e not in (17,t1.c-case when t1.e<19 then t1.c else (abs(t1.c)/abs(d*coalesce((select t1.e from t1 where exists(select 1 from t1 where t1.c in (select t1.f from t1 union select 11 from t1)) or t1.a<=t1.d),a))) end*t1.e,t1.e))),coalesce((select max(a) from t1 where (b) in ((11),e,b)),17)) end FROM t1 WHERE NOT (not (c)+c*d>t1.e and exists(select 1 from t1 where d*coalesce((select +case when ((select cast(avg((c)) AS integer)- -cast(avg(a) AS integer) from t1) in (select min(b)-count(*) from t1 union select count(distinct 19) from t1)) or not t1.b between 19 and 19 then t1.c else coalesce((select e from t1 where t1.e>=e),c) end from t1 where ( -f)<a),17)>19) and 17<> -t1.e and b>=a)}
+} {-20}
+do_test randexpr-2.694 {
+ db eval {SELECT coalesce((select max(t1.d-t1.e) from t1 where not exists(select 1 from t1 where c*+19<=(d)) or c+e not between a and ~f*t1.f*case when t1.e<> -coalesce((select case when ((e between t1.d and f)) then -(17) | b else t1.d end from t1 where b in (select t1.c from t1 union select 11 from t1)),d) then t1.d when e not in ( -t1.b,t1.c,(t1.e)) then t1.c else d end), -b) FROM t1 WHERE t1.d<>d}
+} {}
+do_test randexpr-2.695 {
+ db eval {SELECT coalesce((select max(t1.d-t1.e) from t1 where not exists(select 1 from t1 where c*+19<=(d)) or c+e not between a and ~f*t1.f*case when t1.e<> -coalesce((select case when ((e between t1.d and f)) then -(17) | b else t1.d end from t1 where b in (select t1.c from t1 union select 11 from t1)),d) then t1.d when e not in ( -t1.b,t1.c,(t1.e)) then t1.c else d end), -b) FROM t1 WHERE NOT (t1.d<>d)}
+} {-100}
+do_test randexpr-2.696 {
+ db eval {SELECT coalesce((select max(t1.d-t1.e) from t1 where not exists(select 1 from t1 where c*+19<=(d)) or c+e not between a and ~f*t1.f*case when t1.e<> -coalesce((select case when ((e between t1.d and f)) then -(17) & b else t1.d end from t1 where b in (select t1.c from t1 union select 11 from t1)),d) then t1.d when e not in ( -t1.b,t1.c,(t1.e)) then t1.c else d end), -b) FROM t1 WHERE NOT (t1.d<>d)}
+} {-100}
+do_test randexpr-2.697 {
+ db eval {SELECT case when a in (select max(17) from t1 union select abs(count(*)) from t1) then t1.a- -e-t1.d | e- -t1.f*19+(select -abs(max(a))*count(distinct e)*max(19) from t1)-11-13-d*11+t1.a else d end-b FROM t1 WHERE t1.e in (select (abs(case when (abs(f)/abs((select ~min(a) from t1)+coalesce((select t1.f from t1 where 11<>t1.b),19)))*t1.e+ -t1.d | e<=t1.f then -e when (b)>t1.a then t1.d else t1.a end)/abs(11)) from t1 union select 13 from t1) and f not between t1.b and e or not exists(select 1 from t1 where not exists(select 1 from t1 where 19<c)) and t1.c not in (t1.d,e,t1.a)}
+} {200}
+do_test randexpr-2.698 {
+ db eval {SELECT case when a in (select max(17) from t1 union select abs(count(*)) from t1) then t1.a- -e-t1.d | e- -t1.f*19+(select -abs(max(a))*count(distinct e)*max(19) from t1)-11-13-d*11+t1.a else d end-b FROM t1 WHERE NOT (t1.e in (select (abs(case when (abs(f)/abs((select ~min(a) from t1)+coalesce((select t1.f from t1 where 11<>t1.b),19)))*t1.e+ -t1.d | e<=t1.f then -e when (b)>t1.a then t1.d else t1.a end)/abs(11)) from t1 union select 13 from t1) and f not between t1.b and e or not exists(select 1 from t1 where not exists(select 1 from t1 where 19<c)) and t1.c not in (t1.d,e,t1.a))}
+} {}
+do_test randexpr-2.699 {
+ db eval {SELECT case when a in (select max(17) from t1 union select abs(count(*)) from t1) then t1.a- -e-t1.d & e- -t1.f*19+(select -abs(max(a))*count(distinct e)*max(19) from t1)-11-13-d*11+t1.a else d end-b FROM t1 WHERE t1.e in (select (abs(case when (abs(f)/abs((select ~min(a) from t1)+coalesce((select t1.f from t1 where 11<>t1.b),19)))*t1.e+ -t1.d | e<=t1.f then -e when (b)>t1.a then t1.d else t1.a end)/abs(11)) from t1 union select 13 from t1) and f not between t1.b and e or not exists(select 1 from t1 where not exists(select 1 from t1 where 19<c)) and t1.c not in (t1.d,e,t1.a)}
+} {200}
+do_test randexpr-2.700 {
+ db eval {SELECT coalesce((select f from t1 where (case t1.a*t1.b*c when t1.d*coalesce((select max(coalesce((select 19 from t1 where t1.b in (select max(~case -e when c+coalesce((select max(e) from t1 where (t1.d) not between c and t1.f),17) then c else 13 end) from t1 union select count(distinct a) from t1)),t1.f)) from t1 where f>t1.d),c) then 19 else 17 end between t1.b and t1.f and t1.d not in (c,e,(17)))),11) FROM t1 WHERE (((select min(t1.f) from t1)<=e))}
+} {}
+do_test randexpr-2.701 {
+ db eval {SELECT coalesce((select f from t1 where (case t1.a*t1.b*c when t1.d*coalesce((select max(coalesce((select 19 from t1 where t1.b in (select max(~case -e when c+coalesce((select max(e) from t1 where (t1.d) not between c and t1.f),17) then c else 13 end) from t1 union select count(distinct a) from t1)),t1.f)) from t1 where f>t1.d),c) then 19 else 17 end between t1.b and t1.f and t1.d not in (c,e,(17)))),11) FROM t1 WHERE NOT ((((select min(t1.f) from t1)<=e)))}
+} {11}
+do_test randexpr-2.702 {
+ db eval {SELECT case t1.a when e*t1.e then case when exists(select 1 from t1 where (coalesce((select max(17) from t1 where (not (case when not a>=13*c then t1.f else (11)*t1.b end between 11 and t1.f or t1.c>(t1.c)))),t1.b*~t1.c)*b*d>=13)) then (abs(17)/abs(e)) else b end else t1.f end | t1.c+t1.f FROM t1 WHERE coalesce((select max(11) from t1 where c-d not between ~case when (select +~count(distinct t1.f)*cast(avg(t1.e) AS integer) from t1)+19 not in (t1.e,t1.f,t1.a) then t1.a when a in (e,t1.d,d) then t1.b else t1.e end and t1.b and c>=e or (t1.d<>b) and not exists(select 1 from t1 where (t1.f between 13 and a))),t1.a)-e<=t1.e}
+} {988}
+do_test randexpr-2.703 {
+ db eval {SELECT case t1.a when e*t1.e then case when exists(select 1 from t1 where (coalesce((select max(17) from t1 where (not (case when not a>=13*c then t1.f else (11)*t1.b end between 11 and t1.f or t1.c>(t1.c)))),t1.b*~t1.c)*b*d>=13)) then (abs(17)/abs(e)) else b end else t1.f end | t1.c+t1.f FROM t1 WHERE NOT (coalesce((select max(11) from t1 where c-d not between ~case when (select +~count(distinct t1.f)*cast(avg(t1.e) AS integer) from t1)+19 not in (t1.e,t1.f,t1.a) then t1.a when a in (e,t1.d,d) then t1.b else t1.e end and t1.b and c>=e or (t1.d<>b) and not exists(select 1 from t1 where (t1.f between 13 and a))),t1.a)-e<=t1.e)}
+} {}
+do_test randexpr-2.704 {
+ db eval {SELECT case t1.a when e*t1.e then case when exists(select 1 from t1 where (coalesce((select max(17) from t1 where (not (case when not a>=13*c then t1.f else (11)*t1.b end between 11 and t1.f or t1.c>(t1.c)))),t1.b*~t1.c)*b*d>=13)) then (abs(17)/abs(e)) else b end else t1.f end & t1.c+t1.f FROM t1 WHERE coalesce((select max(11) from t1 where c-d not between ~case when (select +~count(distinct t1.f)*cast(avg(t1.e) AS integer) from t1)+19 not in (t1.e,t1.f,t1.a) then t1.a when a in (e,t1.d,d) then t1.b else t1.e end and t1.b and c>=e or (t1.d<>b) and not exists(select 1 from t1 where (t1.f between 13 and a))),t1.a)-e<=t1.e}
+} {512}
+do_test randexpr-2.705 {
+ db eval {SELECT coalesce((select max(t1.e+(t1.b)) from t1 where 17<=t1.d-(select ~+cast(avg(b) AS integer) | case -case cast(avg(t1.e) AS integer) when min((abs((a))/abs(t1.e))) then cast(avg(t1.c) AS integer)+count(*) else min(d) end when max(t1.e) then count(*) else ( -count(*)) end-min(t1.b)-count(distinct -a)*count(*) from t1) | c+coalesce((select f from t1 where (19=t1.c-t1.b)),t1.f+17)),f) FROM t1 WHERE c not between (abs(t1.f)/abs(case when t1.f+e<=t1.c+t1.d then case when d in (select +count(distinct case when -t1.a*19-t1.c not between 11 and c then t1.e when (19<>19) then t1.d else d end) from t1 union select cast(avg(e) AS integer) from t1) then t1.e when c in (select count(*) from t1 union select cast(avg(f) AS integer)* - - -cast(avg(t1.e) AS integer) from t1) then b else (t1.b) end when not (11>=11) then -t1.e else b end)) and t1.f}
+} {}
+do_test randexpr-2.706 {
+ db eval {SELECT coalesce((select max(t1.e+(t1.b)) from t1 where 17<=t1.d-(select ~+cast(avg(b) AS integer) | case -case cast(avg(t1.e) AS integer) when min((abs((a))/abs(t1.e))) then cast(avg(t1.c) AS integer)+count(*) else min(d) end when max(t1.e) then count(*) else ( -count(*)) end-min(t1.b)-count(distinct -a)*count(*) from t1) | c+coalesce((select f from t1 where (19=t1.c-t1.b)),t1.f+17)),f) FROM t1 WHERE NOT (c not between (abs(t1.f)/abs(case when t1.f+e<=t1.c+t1.d then case when d in (select +count(distinct case when -t1.a*19-t1.c not between 11 and c then t1.e when (19<>19) then t1.d else d end) from t1 union select cast(avg(e) AS integer) from t1) then t1.e when c in (select count(*) from t1 union select cast(avg(f) AS integer)* - - -cast(avg(t1.e) AS integer) from t1) then b else (t1.b) end when not (11>=11) then -t1.e else b end)) and t1.f)}
+} {700}
+do_test randexpr-2.707 {
+ db eval {SELECT coalesce((select max(t1.e+(t1.b)) from t1 where 17<=t1.d-(select ~+cast(avg(b) AS integer) & case -case cast(avg(t1.e) AS integer) when min((abs((a))/abs(t1.e))) then cast(avg(t1.c) AS integer)+count(*) else min(d) end when max(t1.e) then count(*) else ( -count(*)) end-min(t1.b)-count(distinct -a)*count(*) from t1) & c+coalesce((select f from t1 where (19=t1.c-t1.b)),t1.f+17)),f) FROM t1 WHERE NOT (c not between (abs(t1.f)/abs(case when t1.f+e<=t1.c+t1.d then case when d in (select +count(distinct case when -t1.a*19-t1.c not between 11 and c then t1.e when (19<>19) then t1.d else d end) from t1 union select cast(avg(e) AS integer) from t1) then t1.e when c in (select count(*) from t1 union select cast(avg(f) AS integer)* - - -cast(avg(t1.e) AS integer) from t1) then b else (t1.b) end when not (11>=11) then -t1.e else b end)) and t1.f)}
+} {700}
+do_test randexpr-2.708 {
+ db eval {SELECT 17-(abs(case when t1.e<+(select count(distinct -f) from t1)+t1.b then +case when t1.b not in (coalesce((select max(coalesce((select case when 17<e then 13 else t1.e end+t1.b from t1 where not (t1.f) between d and ((t1.d))),t1.f)) from t1 where t1.f>=a and 13 not in (b,t1.f,d)),b),t1.d, -13) then (e) else (13) end-19 when not exists(select 1 from t1 where 19<>f) then c else t1.e end | t1.d)/abs((13)))*f FROM t1 WHERE coalesce((select f from t1 where coalesce((select ~d*19-d*~case c when case a when t1.e*19 then (select - -( -max(t1.f))*cast(avg(t1.c) AS integer) from t1) else 13 end*13-11 then -11 else t1.f end | t1.e | t1.f*19 from t1 where t1.f>t1.a),b)*b not in (17,17,t1.e)),t1.a)-b*d>=11}
+} {}
+do_test randexpr-2.709 {
+ db eval {SELECT 17-(abs(case when t1.e<+(select count(distinct -f) from t1)+t1.b then +case when t1.b not in (coalesce((select max(coalesce((select case when 17<e then 13 else t1.e end+t1.b from t1 where not (t1.f) between d and ((t1.d))),t1.f)) from t1 where t1.f>=a and 13 not in (b,t1.f,d)),b),t1.d, -13) then (e) else (13) end-19 when not exists(select 1 from t1 where 19<>f) then c else t1.e end | t1.d)/abs((13)))*f FROM t1 WHERE NOT (coalesce((select f from t1 where coalesce((select ~d*19-d*~case c when case a when t1.e*19 then (select - -( -max(t1.f))*cast(avg(t1.c) AS integer) from t1) else 13 end*13-11 then -11 else t1.f end | t1.e | t1.f*19 from t1 where t1.f>t1.a),b)*b not in (17,17,t1.e)),t1.a)-b*d>=11)}
+} {-22783}
+do_test randexpr-2.710 {
+ db eval {SELECT 17-(abs(case when t1.e<+(select count(distinct -f) from t1)+t1.b then +case when t1.b not in (coalesce((select max(coalesce((select case when 17<e then 13 else t1.e end+t1.b from t1 where not (t1.f) between d and ((t1.d))),t1.f)) from t1 where t1.f>=a and 13 not in (b,t1.f,d)),b),t1.d, -13) then (e) else (13) end-19 when not exists(select 1 from t1 where 19<>f) then c else t1.e end & t1.d)/abs((13)))*f FROM t1 WHERE NOT (coalesce((select f from t1 where coalesce((select ~d*19-d*~case c when case a when t1.e*19 then (select - -( -max(t1.f))*cast(avg(t1.c) AS integer) from t1) else 13 end*13-11 then -11 else t1.f end | t1.e | t1.f*19 from t1 where t1.f>t1.a),b)*b not in (17,17,t1.e)),t1.a)-b*d>=11)}
+} {-17983}
+do_test randexpr-2.711 {
+ db eval {SELECT (select cast(avg(case when (e=case when e>d and case coalesce((select ((t1.b)) from t1 where 17<=t1.c),a) when t1.b then f else d end*b>t1.d then (t1.a) else 11 end or 17 not in (19,f,d) or not not exists(select 1 from t1 where - -e>=13)) and 17 in ( -t1.b,c,t1.f) then t1.c when t1.c not between t1.f and 17 then t1.c else d end) AS integer) from t1)+b+a FROM t1 WHERE (((coalesce((select coalesce((select max(19) from t1 where d between ~t1.a and 11),c+d-coalesce((select e from t1 where (abs(b)/abs(coalesce((select 13 from t1 where case when (17) not in (19,t1.c,t1.b) or 17 not in (t1.b,t1.f,t1.e) then 11 else 19 end<>t1.c),11)*17))=t1.b),d)) from t1 where d not in (b,b,d)),t1.a) not between b and b) and d>=t1.d) and t1.d in (13,c,t1.b))}
+} {}
+do_test randexpr-2.712 {
+ db eval {SELECT (select cast(avg(case when (e=case when e>d and case coalesce((select ((t1.b)) from t1 where 17<=t1.c),a) when t1.b then f else d end*b>t1.d then (t1.a) else 11 end or 17 not in (19,f,d) or not not exists(select 1 from t1 where - -e>=13)) and 17 in ( -t1.b,c,t1.f) then t1.c when t1.c not between t1.f and 17 then t1.c else d end) AS integer) from t1)+b+a FROM t1 WHERE NOT ((((coalesce((select coalesce((select max(19) from t1 where d between ~t1.a and 11),c+d-coalesce((select e from t1 where (abs(b)/abs(coalesce((select 13 from t1 where case when (17) not in (19,t1.c,t1.b) or 17 not in (t1.b,t1.f,t1.e) then 11 else 19 end<>t1.c),11)*17))=t1.b),d)) from t1 where d not in (b,b,d)),t1.a) not between b and b) and d>=t1.d) and t1.d in (13,c,t1.b)))}
+} {600}
+do_test randexpr-2.713 {
+ db eval {SELECT (abs((select +abs(+max(b) | abs(~~count(distinct -19))) from t1))/abs(coalesce((select max(19*11*d) from t1 where (t1.e<=t1.e)),t1.f)))+case e when (t1.e) then d else c*13 | 11 end FROM t1 WHERE t1.d>=(case when (select count(*) from t1)*t1.c*t1.e+e<>t1.e*13 | f+(select (min(13+t1.b) | ~+~count(*)) from t1)*e*coalesce((select max(19+t1.a) from t1 where t1.e in (select +(count(distinct b))+count(*) from t1 union select ( -min(17)) from t1)),t1.a)-t1.d* -t1.e then e else -a end)}
+} {}
+do_test randexpr-2.714 {
+ db eval {SELECT (abs((select +abs(+max(b) | abs(~~count(distinct -19))) from t1))/abs(coalesce((select max(19*11*d) from t1 where (t1.e<=t1.e)),t1.f)))+case e when (t1.e) then d else c*13 | 11 end FROM t1 WHERE NOT (t1.d>=(case when (select count(*) from t1)*t1.c*t1.e+e<>t1.e*13 | f+(select (min(13+t1.b) | ~+~count(*)) from t1)*e*coalesce((select max(19+t1.a) from t1 where t1.e in (select +(count(distinct b))+count(*) from t1 union select ( -min(17)) from t1)),t1.a)-t1.d* -t1.e then e else -a end))}
+} {400}
+do_test randexpr-2.715 {
+ db eval {SELECT (abs((select +abs(+max(b) & abs(~~count(distinct -19))) from t1))/abs(coalesce((select max(19*11*d) from t1 where (t1.e<=t1.e)),t1.f)))+case e when (t1.e) then d else c*13 & 11 end FROM t1 WHERE NOT (t1.d>=(case when (select count(*) from t1)*t1.c*t1.e+e<>t1.e*13 | f+(select (min(13+t1.b) | ~+~count(*)) from t1)*e*coalesce((select max(19+t1.a) from t1 where t1.e in (select +(count(distinct b))+count(*) from t1 union select ( -min(17)) from t1)),t1.a)-t1.d* -t1.e then e else -a end))}
+} {400}
+do_test randexpr-2.716 {
+ db eval {SELECT -17+c-(abs(t1.a)/abs(t1.c))-case when t1.a<>c then case when exists(select 1 from t1 where 11 not between + -d and d and 13 not between 13 and 17 or not -f<=19 or (t1.a)<a or t1.a>(11)) and 11<t1.b then t1.e else coalesce((select case when t1.f not in (c,t1.c,t1.e) then (select +count(*) from t1) when -t1.f>=t1.f then b else a end from t1 where t1.e in (e,t1.c,b)),11) end else -17 end FROM t1 WHERE not exists(select 1 from t1 where t1.a>=coalesce((select t1.f from t1 where + -19*t1.c<~+t1.a*13),a))}
+} {-217}
+do_test randexpr-2.717 {
+ db eval {SELECT -17+c-(abs(t1.a)/abs(t1.c))-case when t1.a<>c then case when exists(select 1 from t1 where 11 not between + -d and d and 13 not between 13 and 17 or not -f<=19 or (t1.a)<a or t1.a>(11)) and 11<t1.b then t1.e else coalesce((select case when t1.f not in (c,t1.c,t1.e) then (select +count(*) from t1) when -t1.f>=t1.f then b else a end from t1 where t1.e in (e,t1.c,b)),11) end else -17 end FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.a>=coalesce((select t1.f from t1 where + -19*t1.c<~+t1.a*13),a)))}
+} {}
+do_test randexpr-2.718 {
+ db eval {SELECT f*19+17*(select max(b)+count(*)- -~count(*)-min(case when (e<=b-t1.b) then case when t1.b>t1.a or f not in (c, -c,f) or f in (e,13,13) then t1.b else t1.b end else a end*a) from t1)+t1.f*(abs(case b | t1.c+t1.a when ((f)) then f else c end+b)/abs(17))-(c) FROM t1 WHERE t1.e>11}
+} {-138117}
+do_test randexpr-2.719 {
+ db eval {SELECT f*19+17*(select max(b)+count(*)- -~count(*)-min(case when (e<=b-t1.b) then case when t1.b>t1.a or f not in (c, -c,f) or f in (e,13,13) then t1.b else t1.b end else a end*a) from t1)+t1.f*(abs(case b | t1.c+t1.a when ((f)) then f else c end+b)/abs(17))-(c) FROM t1 WHERE NOT (t1.e>11)}
+} {}
+do_test randexpr-2.720 {
+ db eval {SELECT f*19+17*(select max(b)+count(*)- -~count(*)-min(case when (e<=b-t1.b) then case when t1.b>t1.a or f not in (c, -c,f) or f in (e,13,13) then t1.b else t1.b end else a end*a) from t1)+t1.f*(abs(case b & t1.c+t1.a when ((f)) then f else c end+b)/abs(17))-(c) FROM t1 WHERE t1.e>11}
+} {-138117}
+do_test randexpr-2.721 {
+ db eval {SELECT -case when case when (case (abs(13)/abs(t1.e-13*t1.f)) when b- -13+t1.d then 11 else a end) not between t1.b and b then t1.c when d not between t1.e and t1.c or t1.f in (select 11 from t1 union select f from t1) and 17=d then 13 else t1.a end+11>=f then a when f>b then t1.d else 17 end-t1.e FROM t1 WHERE (case when not exists(select 1 from t1 where exists(select 1 from t1 where (abs(b*d-t1.e)/abs(t1.b))>c)) and t1.d in (13,t1.f,17) then e else ( - -t1.a)+11+c end*t1.b in (select (case -+min(17) when +count(*) | min(t1.a) | cast(avg(11) AS integer) then cast(avg(11) AS integer) else cast(avg(a) AS integer) end)-cast(avg(t1.a) AS integer) from t1 union select (min(t1.e)) from t1) or not t1.c in ((f),t1.c,(t1.e)))}
+} {}
+do_test randexpr-2.722 {
+ db eval {SELECT -case when case when (case (abs(13)/abs(t1.e-13*t1.f)) when b- -13+t1.d then 11 else a end) not between t1.b and b then t1.c when d not between t1.e and t1.c or t1.f in (select 11 from t1 union select f from t1) and 17=d then 13 else t1.a end+11>=f then a when f>b then t1.d else 17 end-t1.e FROM t1 WHERE NOT ((case when not exists(select 1 from t1 where exists(select 1 from t1 where (abs(b*d-t1.e)/abs(t1.b))>c)) and t1.d in (13,t1.f,17) then e else ( - -t1.a)+11+c end*t1.b in (select (case -+min(17) when +count(*) | min(t1.a) | cast(avg(11) AS integer) then cast(avg(11) AS integer) else cast(avg(a) AS integer) end)-cast(avg(t1.a) AS integer) from t1 union select (min(t1.e)) from t1) or not t1.c in ((f),t1.c,(t1.e))))}
+} {-900}
+do_test randexpr-2.723 {
+ db eval {SELECT case t1.a when a then t1.c else -case coalesce((select t1.e from t1 where (abs(case when not (a*case when f>=f*13-19 then t1.e else +t1.a end=t1.a) then (select min(a)+min(+19) from t1) else case when t1.a=(f) then c else c end+17 end)/abs(t1.e)) between 17 and 13),e) when 17 then 13 else t1.d end end FROM t1 WHERE 17 in (select case cast(avg(b+b) AS integer) when abs(abs(count(*))) then min(case t1.c+t1.b+t1.e+17+case case when t1.b<>17 and t1.e>=t1.b then b else -t1.f end when 11 then 13 else f end*t1.f*b when 19 then -11 else t1.d end- -t1.f) else min(t1.c) end from t1 union select abs(abs(count(distinct b)*max(t1.d))+count(distinct 13)-count(*)) from t1)}
+} {}
+do_test randexpr-2.724 {
+ db eval {SELECT case t1.a when a then t1.c else -case coalesce((select t1.e from t1 where (abs(case when not (a*case when f>=f*13-19 then t1.e else +t1.a end=t1.a) then (select min(a)+min(+19) from t1) else case when t1.a=(f) then c else c end+17 end)/abs(t1.e)) between 17 and 13),e) when 17 then 13 else t1.d end end FROM t1 WHERE NOT (17 in (select case cast(avg(b+b) AS integer) when abs(abs(count(*))) then min(case t1.c+t1.b+t1.e+17+case case when t1.b<>17 and t1.e>=t1.b then b else -t1.f end when 11 then 13 else f end*t1.f*b when 19 then -11 else t1.d end- -t1.f) else min(t1.c) end from t1 union select abs(abs(count(distinct b)*max(t1.d))+count(distinct 13)-count(*)) from t1))}
+} {300}
+do_test randexpr-2.725 {
+ db eval {SELECT case when coalesce((select e from t1 where coalesce((select coalesce((select max( -coalesce((select max(case when exists(select 1 from t1 where not exists(select 1 from t1 where b in (select e+d from t1 union select t1.e from t1))) then t1.d else t1.f end) from t1 where exists(select 1 from t1 where f not in ((c),a,11))),e)) from t1 where t1.b=t1.f and e<d or d>t1.b),t1.b) from t1 where t1.a in (select a from t1 union select -f from t1)),17)>=17),((b))) not in (t1.e,b,e) then 19 when not -a<=f then t1.f else t1.b end FROM t1 WHERE 13=t1.d}
+} {}
+do_test randexpr-2.726 {
+ db eval {SELECT case when coalesce((select e from t1 where coalesce((select coalesce((select max( -coalesce((select max(case when exists(select 1 from t1 where not exists(select 1 from t1 where b in (select e+d from t1 union select t1.e from t1))) then t1.d else t1.f end) from t1 where exists(select 1 from t1 where f not in ((c),a,11))),e)) from t1 where t1.b=t1.f and e<d or d>t1.b),t1.b) from t1 where t1.a in (select a from t1 union select -f from t1)),17)>=17),((b))) not in (t1.e,b,e) then 19 when not -a<=f then t1.f else t1.b end FROM t1 WHERE NOT (13=t1.d)}
+} {200}
+do_test randexpr-2.727 {
+ db eval {SELECT 19*13+((abs(case when 17*d in ((abs((case (abs((abs((select abs(min(d))+cast(avg(19) AS integer) from t1) | t1.d | 11 | b)/abs(19)))/abs(b)) when 11 then a else e end))/abs(13)),t1.f,b) then t1.b when t1.c>=t1.d then (t1.c) else c end*d)/abs(f))) | t1.a-a-17 FROM t1 WHERE ( -t1.d+coalesce((select max(11) from t1 where t1.c between 13 and t1.d and case d when b then 13+ -~t1.a else +case when coalesce((select max((select +case (cast(avg(e) AS integer)) when count(distinct t1.a) then count(*) else min(( -d)) end from t1)-+a+d) from t1 where (e in (17,t1.e, -a))),b)<>f then a else 11 end end<(t1.e)),t1.d) in (select t1.a from t1 union select b from t1))}
+} {}
+do_test randexpr-2.728 {
+ db eval {SELECT 19*13+((abs(case when 17*d in ((abs((case (abs((abs((select abs(min(d))+cast(avg(19) AS integer) from t1) | t1.d | 11 | b)/abs(19)))/abs(b)) when 11 then a else e end))/abs(13)),t1.f,b) then t1.b when t1.c>=t1.d then (t1.c) else c end*d)/abs(f))) | t1.a-a-17 FROM t1 WHERE NOT (( -t1.d+coalesce((select max(11) from t1 where t1.c between 13 and t1.d and case d when b then 13+ -~t1.a else +case when coalesce((select max((select +case (cast(avg(e) AS integer)) when count(distinct t1.a) then count(*) else min(( -d)) end from t1)-+a+d) from t1 where (e in (17,t1.e, -a))),b)<>f then a else 11 end end<(t1.e)),t1.d) in (select t1.a from t1 union select b from t1)))}
+} {-1}
+do_test randexpr-2.729 {
+ db eval {SELECT 19*13+((abs(case when 17*d in ((abs((case (abs((abs((select abs(min(d))+cast(avg(19) AS integer) from t1) & t1.d & 11 & b)/abs(19)))/abs(b)) when 11 then a else e end))/abs(13)),t1.f,b) then t1.b when t1.c>=t1.d then (t1.c) else c end*d)/abs(f))) & t1.a-a-17 FROM t1 WHERE NOT (( -t1.d+coalesce((select max(11) from t1 where t1.c between 13 and t1.d and case d when b then 13+ -~t1.a else +case when coalesce((select max((select +case (cast(avg(e) AS integer)) when count(distinct t1.a) then count(*) else min(( -d)) end from t1)-+a+d) from t1 where (e in (17,t1.e, -a))),b)<>f then a else 11 end end<(t1.e)),t1.d) in (select t1.a from t1 union select b from t1)))}
+} {431}
+do_test randexpr-2.730 {
+ db eval {SELECT case when (19*b)+11*~f-coalesce((select max(11) from t1 where f<>case when case 17 when 11 then 17 else c end-11 in (t1.c,c,t1.e) and 19=t1.a or 17<=e or e<=19 then 19 | c when t1.b=t1.f then d else 19 end or t1.e not in (13,19,c)),b) | -c not between -e and -a then (t1.c) else t1.d end FROM t1 WHERE c in (select case abs((count(*))) when -max(t1.c) | abs(abs(+count(*)))-~case (case -max(e) when max(11)- -count(*) then ((max(t1.e))) else count(*) end) when count(distinct t1.e) then cast(avg(f) AS integer) else cast(avg(t1.c) AS integer) end* -cast(avg(f) AS integer) then max(f) else (max(b)) end from t1 union select (max(13)) from t1) and not exists(select 1 from t1 where case when t1.e<=19-b then c else c end in (select c from t1 union select (select -((count(distinct t1.d))) from t1)-t1.b from t1))}
+} {}
+do_test randexpr-2.731 {
+ db eval {SELECT case when (19*b)+11*~f-coalesce((select max(11) from t1 where f<>case when case 17 when 11 then 17 else c end-11 in (t1.c,c,t1.e) and 19=t1.a or 17<=e or e<=19 then 19 | c when t1.b=t1.f then d else 19 end or t1.e not in (13,19,c)),b) | -c not between -e and -a then (t1.c) else t1.d end FROM t1 WHERE NOT (c in (select case abs((count(*))) when -max(t1.c) | abs(abs(+count(*)))-~case (case -max(e) when max(11)- -count(*) then ((max(t1.e))) else count(*) end) when count(distinct t1.e) then cast(avg(f) AS integer) else cast(avg(t1.c) AS integer) end* -cast(avg(f) AS integer) then max(f) else (max(b)) end from t1 union select (max(13)) from t1) and not exists(select 1 from t1 where case when t1.e<=19-b then c else c end in (select c from t1 union select (select -((count(distinct t1.d))) from t1)-t1.b from t1)))}
+} {400}
+do_test randexpr-2.732 {
+ db eval {SELECT case when (19*b)+11*~f-coalesce((select max(11) from t1 where f<>case when case 17 when 11 then 17 else c end-11 in (t1.c,c,t1.e) and 19=t1.a or 17<=e or e<=19 then 19 & c when t1.b=t1.f then d else 19 end or t1.e not in (13,19,c)),b) & -c not between -e and -a then (t1.c) else t1.d end FROM t1 WHERE NOT (c in (select case abs((count(*))) when -max(t1.c) | abs(abs(+count(*)))-~case (case -max(e) when max(11)- -count(*) then ((max(t1.e))) else count(*) end) when count(distinct t1.e) then cast(avg(f) AS integer) else cast(avg(t1.c) AS integer) end* -cast(avg(f) AS integer) then max(f) else (max(b)) end from t1 union select (max(13)) from t1) and not exists(select 1 from t1 where case when t1.e<=19-b then c else c end in (select c from t1 union select (select -((count(distinct t1.d))) from t1)-t1.b from t1)))}
+} {300}
+do_test randexpr-2.733 {
+ db eval {SELECT case when t1.e not between e and 13 then (select count(*) from t1) when f>=case when c in (select a from t1 union select t1.e+coalesce((select 11 from t1 where (select count(distinct t1.b) from t1)+17 not in (b,t1.c,t1.f-(select ~count(distinct 17) from t1)+ -e)),13) from t1) or 19 between d and t1.f then (select min(19) from t1) when not (e not between c and a) then d else a end then d else (t1.c) end FROM t1 WHERE f not in (17,f+d | f+case when -f=19 then (select max((select +abs(abs(max(((select ((max(t1.d))+count(distinct t1.e))-min(t1.a) from t1))+t1.e)-abs(count(distinct -t1.b)-count(distinct 11)))*min(a)-count(*))-min(t1.a) from t1)) from t1) else t1.f end,c-a) and c<>11}
+} {1}
+do_test randexpr-2.734 {
+ db eval {SELECT case when t1.e not between e and 13 then (select count(*) from t1) when f>=case when c in (select a from t1 union select t1.e+coalesce((select 11 from t1 where (select count(distinct t1.b) from t1)+17 not in (b,t1.c,t1.f-(select ~count(distinct 17) from t1)+ -e)),13) from t1) or 19 between d and t1.f then (select min(19) from t1) when not (e not between c and a) then d else a end then d else (t1.c) end FROM t1 WHERE NOT (f not in (17,f+d | f+case when -f=19 then (select max((select +abs(abs(max(((select ((max(t1.d))+count(distinct t1.e))-min(t1.a) from t1))+t1.e)-abs(count(distinct -t1.b)-count(distinct 11)))*min(a)-count(*))-min(t1.a) from t1)) from t1) else t1.f end,c-a) and c<>11)}
+} {}
+do_test randexpr-2.735 {
+ db eval {SELECT case c-+case when t1.f in (t1.a,t1.e,19) then t1.b else case when a<>t1.a then case ~(t1.d) when t1.e then (select max(t1.f) from t1)-(select +(cast(avg(b) AS integer))*cast(avg(t1.a) AS integer)+max(d)*count(*)+count(*) from t1)* -t1.f else 13 end else t1.a+a end*t1.f-t1.b*(e) end when d then d else 17 end FROM t1 WHERE case when not exists(select 1 from t1 where not exists(select 1 from t1 where c in (select t1.a*t1.b from t1 union select t1.d | e from t1))) and (coalesce((select (abs(11)/abs(13-17*c)) from t1 where b in (select 13 from t1 union select (t1.c) from t1)),11) not in (17,b,b)) then (abs(+t1.f)/abs(c)) when exists(select 1 from t1 where not exists(select 1 from t1 where not (not exists(select 1 from t1 where e<=19 and e>19)))) then c else t1.e end not between t1.f and c}
+} {17}
+do_test randexpr-2.736 {
+ db eval {SELECT case c-+case when t1.f in (t1.a,t1.e,19) then t1.b else case when a<>t1.a then case ~(t1.d) when t1.e then (select max(t1.f) from t1)-(select +(cast(avg(b) AS integer))*cast(avg(t1.a) AS integer)+max(d)*count(*)+count(*) from t1)* -t1.f else 13 end else t1.a+a end*t1.f-t1.b*(e) end when d then d else 17 end FROM t1 WHERE NOT (case when not exists(select 1 from t1 where not exists(select 1 from t1 where c in (select t1.a*t1.b from t1 union select t1.d | e from t1))) and (coalesce((select (abs(11)/abs(13-17*c)) from t1 where b in (select 13 from t1 union select (t1.c) from t1)),11) not in (17,b,b)) then (abs(+t1.f)/abs(c)) when exists(select 1 from t1 where not exists(select 1 from t1 where not (not exists(select 1 from t1 where e<=19 and e>19)))) then c else t1.e end not between t1.f and c)}
+} {}
+do_test randexpr-2.737 {
+ db eval {SELECT 11+a+(select count(distinct coalesce((select -coalesce((select case when (t1.a<=a) then (case when 17=t1.c then (select count(distinct e)-min(11) from t1) else f end) when f>=t1.f and t1.c not in (t1.e,a,17) and 17=t1.f then -t1.d else 11 end*t1.d from t1 where t1.a<=t1.b),t1.b) from t1 where t1.e not between d and 13),t1.a)) | +max(t1.c) from t1) FROM t1 WHERE 11 in (t1.a,+t1.c* -t1.f | t1.d*+t1.c-b-(abs((select min(case when 19 in (select abs(count(distinct c)) from t1 union select ~ -min(t1.c) from t1) then case (11) when a then t1.c else t1.d end when (f)<=t1.b then t1.b else t1.a end)+min((t1.d)) | min(b) from t1))/abs(t1.e))+case 13 when t1.b then b else - -t1.b end*b-11, -f)}
+} {}
+do_test randexpr-2.738 {
+ db eval {SELECT 11+a+(select count(distinct coalesce((select -coalesce((select case when (t1.a<=a) then (case when 17=t1.c then (select count(distinct e)-min(11) from t1) else f end) when f>=t1.f and t1.c not in (t1.e,a,17) and 17=t1.f then -t1.d else 11 end*t1.d from t1 where t1.a<=t1.b),t1.b) from t1 where t1.e not between d and 13),t1.a)) | +max(t1.c) from t1) FROM t1 WHERE NOT (11 in (t1.a,+t1.c* -t1.f | t1.d*+t1.c-b-(abs((select min(case when 19 in (select abs(count(distinct c)) from t1 union select ~ -min(t1.c) from t1) then case (11) when a then t1.c else t1.d end when (f)<=t1.b then t1.b else t1.a end)+min((t1.d)) | min(b) from t1))/abs(t1.e))+case 13 when t1.b then b else - -t1.b end*b-11, -f))}
+} {412}
+do_test randexpr-2.739 {
+ db eval {SELECT 11+a+(select count(distinct coalesce((select -coalesce((select case when (t1.a<=a) then (case when 17=t1.c then (select count(distinct e)-min(11) from t1) else f end) when f>=t1.f and t1.c not in (t1.e,a,17) and 17=t1.f then -t1.d else 11 end*t1.d from t1 where t1.a<=t1.b),t1.b) from t1 where t1.e not between d and 13),t1.a)) & +max(t1.c) from t1) FROM t1 WHERE NOT (11 in (t1.a,+t1.c* -t1.f | t1.d*+t1.c-b-(abs((select min(case when 19 in (select abs(count(distinct c)) from t1 union select ~ -min(t1.c) from t1) then case (11) when a then t1.c else t1.d end when (f)<=t1.b then t1.b else t1.a end)+min((t1.d)) | min(b) from t1))/abs(t1.e))+case 13 when t1.b then b else - -t1.b end*b-11, -f))}
+} {111}
+do_test randexpr-2.740 {
+ db eval {SELECT -c-case 11 when ++e*(select cast(avg( -t1.f+case when case when 19=t1.e+((select min(17 | a) from t1)) then t1.f else t1.b end>=t1.e then t1.e when (((exists(select 1 from t1 where b in (select case -count(*) when (count(distinct d)) then count(*) else (cast(avg(t1.b) AS integer)) end from t1 union select -count(*) from t1))))) then t1.a else a end+t1.a*d) AS integer) from t1) then 13 else f end*e FROM t1 WHERE (select cast(avg(case when +d>=e+17 and (not case when 13>=(select case -count(distinct t1.e) when cast(avg(c) AS integer) then cast(avg(19) AS integer) else count(distinct t1.a) end from t1) then t1.e else t1.f end in (select t1.b from t1 union select 13 from t1)) or t1.a<=e and e in (select count(*) from t1 union select -count(*) from t1) and b>=t1.b or t1.e between c and 19 then c when f between 19 and b then coalesce((select max(t1.d) from t1 where a<>t1.b),13)* -(d) else t1.e end) AS integer) from t1)<=19}
+} {}
+do_test randexpr-2.741 {
+ db eval {SELECT -c-case 11 when ++e*(select cast(avg( -t1.f+case when case when 19=t1.e+((select min(17 | a) from t1)) then t1.f else t1.b end>=t1.e then t1.e when (((exists(select 1 from t1 where b in (select case -count(*) when (count(distinct d)) then count(*) else (cast(avg(t1.b) AS integer)) end from t1 union select -count(*) from t1))))) then t1.a else a end+t1.a*d) AS integer) from t1) then 13 else f end*e FROM t1 WHERE NOT ((select cast(avg(case when +d>=e+17 and (not case when 13>=(select case -count(distinct t1.e) when cast(avg(c) AS integer) then cast(avg(19) AS integer) else count(distinct t1.a) end from t1) then t1.e else t1.f end in (select t1.b from t1 union select 13 from t1)) or t1.a<=e and e in (select count(*) from t1 union select -count(*) from t1) and b>=t1.b or t1.e between c and 19 then c when f between 19 and b then coalesce((select max(t1.d) from t1 where a<>t1.b),13)* -(d) else t1.e end) AS integer) from t1)<=19)}
+} {-300300}
+do_test randexpr-2.742 {
+ db eval {SELECT -c-case 11 when ++e*(select cast(avg( -t1.f+case when case when 19=t1.e+((select min(17 & a) from t1)) then t1.f else t1.b end>=t1.e then t1.e when (((exists(select 1 from t1 where b in (select case -count(*) when (count(distinct d)) then count(*) else (cast(avg(t1.b) AS integer)) end from t1 union select -count(*) from t1))))) then t1.a else a end+t1.a*d) AS integer) from t1) then 13 else f end*e FROM t1 WHERE NOT ((select cast(avg(case when +d>=e+17 and (not case when 13>=(select case -count(distinct t1.e) when cast(avg(c) AS integer) then cast(avg(19) AS integer) else count(distinct t1.a) end from t1) then t1.e else t1.f end in (select t1.b from t1 union select 13 from t1)) or t1.a<=e and e in (select count(*) from t1 union select -count(*) from t1) and b>=t1.b or t1.e between c and 19 then c when f between 19 and b then coalesce((select max(t1.d) from t1 where a<>t1.b),13)* -(d) else t1.e end) AS integer) from t1)<=19)}
+} {-300300}
+do_test randexpr-2.743 {
+ db eval {SELECT case d when 11 then t1.d-(abs(t1.d)/abs(19))+coalesce((select d*d from t1 where (select cast(avg(case when f | c+case when e in (select min(coalesce((select t1.f from t1 where 11 not between t1.b and 19),t1.f)) from t1 union select (max(t1.b)) from t1) then 19 when t1.b=b or t1.c>=c then 13 else e end*19 in (select 17 from t1 union select 11 from t1) then -c else t1.d end) AS integer) from t1)<13),d) else 11 end FROM t1 WHERE (b>~t1.c-+(abs(case when 11>(c) and t1.a>13 then t1.d else (b) end)/abs(t1.d))-13 or t1.f between t1.a and 19 and 11 in (select (min(t1.e))-~( -+count(*)) from t1 union select count(distinct t1.c) from t1)) and 17 not in (f,(t1.b),t1.c) and (t1.f<>t1.e) or d in (f,t1.a,t1.d) or (d)<=t1.e}
+} {11}
+do_test randexpr-2.744 {
+ db eval {SELECT case d when 11 then t1.d-(abs(t1.d)/abs(19))+coalesce((select d*d from t1 where (select cast(avg(case when f | c+case when e in (select min(coalesce((select t1.f from t1 where 11 not between t1.b and 19),t1.f)) from t1 union select (max(t1.b)) from t1) then 19 when t1.b=b or t1.c>=c then 13 else e end*19 in (select 17 from t1 union select 11 from t1) then -c else t1.d end) AS integer) from t1)<13),d) else 11 end FROM t1 WHERE NOT ((b>~t1.c-+(abs(case when 11>(c) and t1.a>13 then t1.d else (b) end)/abs(t1.d))-13 or t1.f between t1.a and 19 and 11 in (select (min(t1.e))-~( -+count(*)) from t1 union select count(distinct t1.c) from t1)) and 17 not in (f,(t1.b),t1.c) and (t1.f<>t1.e) or d in (f,t1.a,t1.d) or (d)<=t1.e)}
+} {}
+do_test randexpr-2.745 {
+ db eval {SELECT case d when 11 then t1.d-(abs(t1.d)/abs(19))+coalesce((select d*d from t1 where (select cast(avg(case when f & c+case when e in (select min(coalesce((select t1.f from t1 where 11 not between t1.b and 19),t1.f)) from t1 union select (max(t1.b)) from t1) then 19 when t1.b=b or t1.c>=c then 13 else e end*19 in (select 17 from t1 union select 11 from t1) then -c else t1.d end) AS integer) from t1)<13),d) else 11 end FROM t1 WHERE (b>~t1.c-+(abs(case when 11>(c) and t1.a>13 then t1.d else (b) end)/abs(t1.d))-13 or t1.f between t1.a and 19 and 11 in (select (min(t1.e))-~( -+count(*)) from t1 union select count(distinct t1.c) from t1)) and 17 not in (f,(t1.b),t1.c) and (t1.f<>t1.e) or d in (f,t1.a,t1.d) or (d)<=t1.e}
+} {11}
+do_test randexpr-2.746 {
+ db eval {SELECT (select -~count(distinct ~+case when c<>coalesce((select max(case when ~13 in (t1.a,t1.f,13+t1.d+(19)*t1.d*f-e) then 13 else a end) from t1 where -t1.d<>19),(a))*d+a then t1.d when exists(select 1 from t1 where b=d) then t1.f else 17 end*11) | count(*)-max(t1.e) from t1) FROM t1 WHERE 19 in (select max(b) from t1 union select count(*) from t1) and +t1.b+c*d+coalesce((select max(17) from t1 where case when t1.a=coalesce((select max((select (min(t1.f)) from t1)) from t1 where not case when not exists(select 1 from t1 where ( -t1.b)=13 and d in (f,c,e)) or 17 between 17 and e then t1.e-t1.c else 11 end>=d),19)-11 then 11 else 17 end<=t1.a),t1.f)+t1.f-f<>17}
+} {}
+do_test randexpr-2.747 {
+ db eval {SELECT (select -~count(distinct ~+case when c<>coalesce((select max(case when ~13 in (t1.a,t1.f,13+t1.d+(19)*t1.d*f-e) then 13 else a end) from t1 where -t1.d<>19),(a))*d+a then t1.d when exists(select 1 from t1 where b=d) then t1.f else 17 end*11) | count(*)-max(t1.e) from t1) FROM t1 WHERE NOT (19 in (select max(b) from t1 union select count(*) from t1) and +t1.b+c*d+coalesce((select max(17) from t1 where case when t1.a=coalesce((select max((select (min(t1.f)) from t1)) from t1 where not case when not exists(select 1 from t1 where ( -t1.b)=13 and d in (f,c,e)) or 17 between 17 and e then t1.e-t1.c else 11 end>=d),19)-11 then 11 else 17 end<=t1.a),t1.f)+t1.f-f<>17)}
+} {-497}
+do_test randexpr-2.748 {
+ db eval {SELECT (select -~count(distinct ~+case when c<>coalesce((select max(case when ~13 in (t1.a,t1.f,13+t1.d+(19)*t1.d*f-e) then 13 else a end) from t1 where -t1.d<>19),(a))*d+a then t1.d when exists(select 1 from t1 where b=d) then t1.f else 17 end*11) & count(*)-max(t1.e) from t1) FROM t1 WHERE NOT (19 in (select max(b) from t1 union select count(*) from t1) and +t1.b+c*d+coalesce((select max(17) from t1 where case when t1.a=coalesce((select max((select (min(t1.f)) from t1)) from t1 where not case when not exists(select 1 from t1 where ( -t1.b)=13 and d in (f,c,e)) or 17 between 17 and e then t1.e-t1.c else 11 end>=d),19)-11 then 11 else 17 end<=t1.a),t1.f)+t1.f-f<>17)}
+} {0}
+do_test randexpr-2.749 {
+ db eval {SELECT coalesce((select max(a) from t1 where exists(select 1 from t1 where (abs(t1.f)/abs(case when (t1.a+case when exists(select 1 from t1 where t1.e>=(abs(coalesce((select f from t1 where (((b>=t1.d) or t1.e= -a) or 17=a)),case when t1.d between t1.a and b then t1.b when e in (e,t1.a,t1.e) then 13 else (f) end))/abs(13))) then 11 else t1.d end* - -t1.f)<=c then d else t1.d end))-t1.c-19>=t1.a)),((t1.b))) FROM t1 WHERE case when t1.f in (e,19,(abs(t1.e)/abs(t1.e))) and (17 between 11+(select +max(case case when f=(t1.b) then e when t1.e in (13,19,c) then c else -t1.b end- -c when (13) then d else t1.f end) from t1) and 17 and (19 in (b,t1.d,11))) and f not between 19 and b then e when 13 not between (t1.e) and t1.a then 11 else 11 end not between d and t1.a}
+} {200}
+do_test randexpr-2.750 {
+ db eval {SELECT coalesce((select max(a) from t1 where exists(select 1 from t1 where (abs(t1.f)/abs(case when (t1.a+case when exists(select 1 from t1 where t1.e>=(abs(coalesce((select f from t1 where (((b>=t1.d) or t1.e= -a) or 17=a)),case when t1.d between t1.a and b then t1.b when e in (e,t1.a,t1.e) then 13 else (f) end))/abs(13))) then 11 else t1.d end* - -t1.f)<=c then d else t1.d end))-t1.c-19>=t1.a)),((t1.b))) FROM t1 WHERE NOT (case when t1.f in (e,19,(abs(t1.e)/abs(t1.e))) and (17 between 11+(select +max(case case when f=(t1.b) then e when t1.e in (13,19,c) then c else -t1.b end- -c when (13) then d else t1.f end) from t1) and 17 and (19 in (b,t1.d,11))) and f not between 19 and b then e when 13 not between (t1.e) and t1.a then 11 else 11 end not between d and t1.a)}
+} {}
+do_test randexpr-2.751 {
+ db eval {SELECT 11-17 | case when 11<t1.c then case when ~f<=(abs(t1.e)/abs(19))-t1.f then 17 when 11>=c or 11 in (select cast(avg(t1.c) AS integer)-case cast(avg(t1.b) AS integer) when count(distinct e) then min(t1.a) else -count(distinct 19) end from t1 union select count(*) from t1) or e in (t1.e,t1.b,b) or 13=t1.f and e>=t1.a then e else e end when ( -19<=e) then 13 else e end+a FROM t1 WHERE t1.c*d not in ( -t1.a,coalesce((select d from t1 where coalesce((select c from t1 where ((d<=11))),(17)+(abs(coalesce((select (select ( -+count(*))+count(distinct d) from t1) from t1 where (coalesce((select b from t1 where ~a<>13),(t1.c))) not between d and t1.d),17))/abs(d)))*f<a and t1.b<>17),e),t1.b)}
+} {-1}
+do_test randexpr-2.752 {
+ db eval {SELECT 11-17 | case when 11<t1.c then case when ~f<=(abs(t1.e)/abs(19))-t1.f then 17 when 11>=c or 11 in (select cast(avg(t1.c) AS integer)-case cast(avg(t1.b) AS integer) when count(distinct e) then min(t1.a) else -count(distinct 19) end from t1 union select count(*) from t1) or e in (t1.e,t1.b,b) or 13=t1.f and e>=t1.a then e else e end when ( -19<=e) then 13 else e end+a FROM t1 WHERE NOT (t1.c*d not in ( -t1.a,coalesce((select d from t1 where coalesce((select c from t1 where ((d<=11))),(17)+(abs(coalesce((select (select ( -+count(*))+count(distinct d) from t1) from t1 where (coalesce((select b from t1 where ~a<>13),(t1.c))) not between d and t1.d),17))/abs(d)))*f<a and t1.b<>17),e),t1.b))}
+} {}
+do_test randexpr-2.753 {
+ db eval {SELECT 11-17 & case when 11<t1.c then case when ~f<=(abs(t1.e)/abs(19))-t1.f then 17 when 11>=c or 11 in (select cast(avg(t1.c) AS integer)-case cast(avg(t1.b) AS integer) when count(distinct e) then min(t1.a) else -count(distinct 19) end from t1 union select count(*) from t1) or e in (t1.e,t1.b,b) or 13=t1.f and e>=t1.a then e else e end when ( -19<=e) then 13 else e end+a FROM t1 WHERE t1.c*d not in ( -t1.a,coalesce((select d from t1 where coalesce((select c from t1 where ((d<=11))),(17)+(abs(coalesce((select (select ( -+count(*))+count(distinct d) from t1) from t1 where (coalesce((select b from t1 where ~a<>13),(t1.c))) not between d and t1.d),17))/abs(d)))*f<a and t1.b<>17),e),t1.b)}
+} {112}
+do_test randexpr-2.754 {
+ db eval {SELECT (abs(f-case when +(t1.f)-c<case when 17=case when not exists(select 1 from t1 where (19)=17 or c<>13 and -f<t1.a) then (select max((select min(t1.b) | count(distinct 19) from t1)) from t1) when e not between t1.b and e then t1.e else 17 end+t1.e or t1.c in (t1.f,f,t1.d) then (11)+f when t1.c=11 and t1.e not in (a,(t1.e),a) then a else t1.f end-d then 11 else (t1.e) end-t1.b)/abs(11))*11 FROM t1 WHERE (case when (f not in (~(t1.f*case when case when case 11 when t1.e then t1.c else a end | 19 in (select t1.a from t1 union select t1.e from t1) then f when d>t1.c then 11 else -11 end<>t1.c and t1.f not between (11) and (t1.f) then b else 11 end)*b+t1.f,a,t1.d)) then 11 else t1.d end=e) or e<(t1.f)}
+} {99}
+do_test randexpr-2.755 {
+ db eval {SELECT (abs(f-case when +(t1.f)-c<case when 17=case when not exists(select 1 from t1 where (19)=17 or c<>13 and -f<t1.a) then (select max((select min(t1.b) | count(distinct 19) from t1)) from t1) when e not between t1.b and e then t1.e else 17 end+t1.e or t1.c in (t1.f,f,t1.d) then (11)+f when t1.c=11 and t1.e not in (a,(t1.e),a) then a else t1.f end-d then 11 else (t1.e) end-t1.b)/abs(11))*11 FROM t1 WHERE NOT ((case when (f not in (~(t1.f*case when case when case 11 when t1.e then t1.c else a end | 19 in (select t1.a from t1 union select t1.e from t1) then f when d>t1.c then 11 else -11 end<>t1.c and t1.f not between (11) and (t1.f) then b else 11 end)*b+t1.f,a,t1.d)) then 11 else t1.d end=e) or e<(t1.f))}
+} {}
+do_test randexpr-2.756 {
+ db eval {SELECT (abs(f-case when +(t1.f)-c<case when 17=case when not exists(select 1 from t1 where (19)=17 or c<>13 and -f<t1.a) then (select max((select min(t1.b) & count(distinct 19) from t1)) from t1) when e not between t1.b and e then t1.e else 17 end+t1.e or t1.c in (t1.f,f,t1.d) then (11)+f when t1.c=11 and t1.e not in (a,(t1.e),a) then a else t1.f end-d then 11 else (t1.e) end-t1.b)/abs(11))*11 FROM t1 WHERE (case when (f not in (~(t1.f*case when case when case 11 when t1.e then t1.c else a end | 19 in (select t1.a from t1 union select t1.e from t1) then f when d>t1.c then 11 else -11 end<>t1.c and t1.f not between (11) and (t1.f) then b else 11 end)*b+t1.f,a,t1.d)) then 11 else t1.d end=e) or e<(t1.f)}
+} {99}
+do_test randexpr-2.757 {
+ db eval {SELECT +(select (max(case when not (((exists(select 1 from t1 where b not between t1.a and t1.d) or t1.a>=coalesce((select max(17) from t1 where -t1.e between t1.e and a),f)-11) or 11<=t1.c)) then b when 19 between 19 and b then t1.f else +d+ -t1.a-t1.f-e end | f-t1.b+ -t1.b)+min(t1.b)) from t1)*t1.c FROM t1 WHERE b in (t1.b-b,coalesce((select max(e) from t1 where t1.d not between 11 and case when d>=+13 then case when t1.a between e and a then t1.c else (t1.f)+(t1.b) end else case (d)*e when b then f else a end end or t1.d in (select cast(avg(d) AS integer) from t1 union select +abs( -max(e))*max(19) | max(d) from t1)),11),t1.c)}
+} {}
+do_test randexpr-2.758 {
+ db eval {SELECT +(select (max(case when not (((exists(select 1 from t1 where b not between t1.a and t1.d) or t1.a>=coalesce((select max(17) from t1 where -t1.e between t1.e and a),f)-11) or 11<=t1.c)) then b when 19 between 19 and b then t1.f else +d+ -t1.a-t1.f-e end | f-t1.b+ -t1.b)+min(t1.b)) from t1)*t1.c FROM t1 WHERE NOT (b in (t1.b-b,coalesce((select max(e) from t1 where t1.d not between 11 and case when d>=+13 then case when t1.a between e and a then t1.c else (t1.f)+(t1.b) end else case (d)*e when b then f else a end end or t1.d in (select cast(avg(d) AS integer) from t1 union select +abs( -max(e))*max(19) | max(d) from t1)),11),t1.c))}
+} {278400}
+do_test randexpr-2.759 {
+ db eval {SELECT +(select (max(case when not (((exists(select 1 from t1 where b not between t1.a and t1.d) or t1.a>=coalesce((select max(17) from t1 where -t1.e between t1.e and a),f)-11) or 11<=t1.c)) then b when 19 between 19 and b then t1.f else +d+ -t1.a-t1.f-e end & f-t1.b+ -t1.b)+min(t1.b)) from t1)*t1.c FROM t1 WHERE NOT (b in (t1.b-b,coalesce((select max(e) from t1 where t1.d not between 11 and case when d>=+13 then case when t1.a between e and a then t1.c else (t1.f)+(t1.b) end else case (d)*e when b then f else a end end or t1.d in (select cast(avg(d) AS integer) from t1 union select +abs( -max(e))*max(19) | max(d) from t1)),11),t1.c))}
+} {81600}
+do_test randexpr-2.760 {
+ db eval {SELECT t1.e*t1.c*(select count(*)+abs(cast(avg(case t1.a when (select -count(*)-(min(t1.a)) | +(abs(case max(a) when abs(min(17)) then +cast(avg(a) AS integer) | count(distinct d) else count(*) end)) from t1) then a else -+b-coalesce((select max(f*19) from t1 where ~~c in (a,13,t1.a)),t1.b) end) AS integer)) from t1) FROM t1 WHERE 19-(abs(b)/abs(t1.b)) | case when t1.e in (select case (+cast(avg(t1.c+a) AS integer) | (cast(avg(t1.d) AS integer) | -cast(avg( -d) AS integer)* -( -count(*))+min(17))) when min(13) then max( -11) else count(*) end from t1 union select min(17) from t1) or 13 in (case when t1.e between e and coalesce((select c from t1 where not exists(select 1 from t1 where (b)>=t1.e)),t1.b) then 19 else 11 end,17,f) then 11 else b end in (select c from t1 union select 19 from t1)}
+} {}
+do_test randexpr-2.761 {
+ db eval {SELECT t1.e*t1.c*(select count(*)+abs(cast(avg(case t1.a when (select -count(*)-(min(t1.a)) | +(abs(case max(a) when abs(min(17)) then +cast(avg(a) AS integer) | count(distinct d) else count(*) end)) from t1) then a else -+b-coalesce((select max(f*19) from t1 where ~~c in (a,13,t1.a)),t1.b) end) AS integer)) from t1) FROM t1 WHERE NOT (19-(abs(b)/abs(t1.b)) | case when t1.e in (select case (+cast(avg(t1.c+a) AS integer) | (cast(avg(t1.d) AS integer) | -cast(avg( -d) AS integer)* -( -count(*))+min(17))) when min(13) then max( -11) else count(*) end from t1 union select min(17) from t1) or 13 in (case when t1.e between e and coalesce((select c from t1 where not exists(select 1 from t1 where (b)>=t1.e)),t1.b) then 19 else 11 end,17,f) then 11 else b end in (select c from t1 union select 19 from t1))}
+} {60150000}
+do_test randexpr-2.762 {
+ db eval {SELECT t1.e*t1.c*(select count(*)+abs(cast(avg(case t1.a when (select -count(*)-(min(t1.a)) & +(abs(case max(a) when abs(min(17)) then +cast(avg(a) AS integer) & count(distinct d) else count(*) end)) from t1) then a else -+b-coalesce((select max(f*19) from t1 where ~~c in (a,13,t1.a)),t1.b) end) AS integer)) from t1) FROM t1 WHERE NOT (19-(abs(b)/abs(t1.b)) | case when t1.e in (select case (+cast(avg(t1.c+a) AS integer) | (cast(avg(t1.d) AS integer) | -cast(avg( -d) AS integer)* -( -count(*))+min(17))) when min(13) then max( -11) else count(*) end from t1 union select min(17) from t1) or 13 in (case when t1.e between e and coalesce((select c from t1 where not exists(select 1 from t1 where (b)>=t1.e)),t1.b) then 19 else 11 end,17,f) then 11 else b end in (select c from t1 union select 19 from t1))}
+} {60150000}
+do_test randexpr-2.763 {
+ db eval {SELECT t1.b+case when e+(select abs(abs(min(d+case 11 when t1.d+19 | b | case when e<=b+coalesce((select 11 from t1 where 11<>13),17)-17 then t1.d else d end+19 then 11 else d end))) from t1)- -d-(t1.e) in (select 17 from t1 union select 11 from t1) then t1.e when exists(select 1 from t1 where e>t1.c) then t1.b else 13 end FROM t1 WHERE e in (select count(*) from t1 union select min(case when (select abs(cast(avg(+17) AS integer)) from t1) not between t1.e and 17+t1.f then f when ((case when ((select cast(avg(t1.d) AS integer) from t1)=17) then 19 else t1.f end)<>t1.c or t1.a in (select -+abs(cast(avg(t1.b) AS integer)) from t1 union select +((cast(avg(11) AS integer)))+ -min(b) from t1)) or not exists(select 1 from t1 where ((t1.d in (b,a,17)) and f<=t1.a)) and t1.f<> - -t1.a then d else - -t1.d end) from t1)}
+} {}
+do_test randexpr-2.764 {
+ db eval {SELECT t1.b+case when e+(select abs(abs(min(d+case 11 when t1.d+19 | b | case when e<=b+coalesce((select 11 from t1 where 11<>13),17)-17 then t1.d else d end+19 then 11 else d end))) from t1)- -d-(t1.e) in (select 17 from t1 union select 11 from t1) then t1.e when exists(select 1 from t1 where e>t1.c) then t1.b else 13 end FROM t1 WHERE NOT (e in (select count(*) from t1 union select min(case when (select abs(cast(avg(+17) AS integer)) from t1) not between t1.e and 17+t1.f then f when ((case when ((select cast(avg(t1.d) AS integer) from t1)=17) then 19 else t1.f end)<>t1.c or t1.a in (select -+abs(cast(avg(t1.b) AS integer)) from t1 union select +((cast(avg(11) AS integer)))+ -min(b) from t1)) or not exists(select 1 from t1 where ((t1.d in (b,a,17)) and f<=t1.a)) and t1.f<> - -t1.a then d else - -t1.d end) from t1))}
+} {400}
+do_test randexpr-2.765 {
+ db eval {SELECT t1.b+case when e+(select abs(abs(min(d+case 11 when t1.d+19 & b & case when e<=b+coalesce((select 11 from t1 where 11<>13),17)-17 then t1.d else d end+19 then 11 else d end))) from t1)- -d-(t1.e) in (select 17 from t1 union select 11 from t1) then t1.e when exists(select 1 from t1 where e>t1.c) then t1.b else 13 end FROM t1 WHERE NOT (e in (select count(*) from t1 union select min(case when (select abs(cast(avg(+17) AS integer)) from t1) not between t1.e and 17+t1.f then f when ((case when ((select cast(avg(t1.d) AS integer) from t1)=17) then 19 else t1.f end)<>t1.c or t1.a in (select -+abs(cast(avg(t1.b) AS integer)) from t1 union select +((cast(avg(11) AS integer)))+ -min(b) from t1)) or not exists(select 1 from t1 where ((t1.d in (b,a,17)) and f<=t1.a)) and t1.f<> - -t1.a then d else - -t1.d end) from t1))}
+} {400}
+do_test randexpr-2.766 {
+ db eval {SELECT (select cast(avg( -coalesce((select max(+(abs(t1.d)/abs(~d))*+c*t1.c) from t1 where e in (select coalesce((select f from t1 where t1.f<> -11),17)+c*19 from t1 union select f from t1)),t1.c)) AS integer)-~case ~count(distinct 17)*count(distinct 19) when count(distinct t1.c)*count(*)-count(distinct 19) then +(max(a)+case - - - -min(t1.f) when max(c) then count(distinct (f)) else min(13) end) else ( -cast(avg( -t1.b) AS integer)) end from t1) FROM t1 WHERE exists(select 1 from t1 where (abs(e*coalesce((select (abs(b*(t1.b)+f)/abs(d)) from t1 where t1.c in (select min(a | t1.b) from t1 union select abs(case -case ~ -~cast(avg(e) AS integer) when ++min(17)+( -cast(avg(a) AS integer))-max(t1.c) then cast(avg(t1.b) AS integer) else cast(avg(f) AS integer) end when - -max((t1.d)) then -min(t1.b) else cast(avg(t1.c) AS integer) end) from t1)),b))/abs(t1.d)) in (select min(t1.c)-cast(avg( -e) AS integer)- -cast(avg(t1.f) AS integer) from t1 union select (max((19))) from t1))}
+} {}
+do_test randexpr-2.767 {
+ db eval {SELECT (select cast(avg( -coalesce((select max(+(abs(t1.d)/abs(~d))*+c*t1.c) from t1 where e in (select coalesce((select f from t1 where t1.f<> -11),17)+c*19 from t1 union select f from t1)),t1.c)) AS integer)-~case ~count(distinct 17)*count(distinct 19) when count(distinct t1.c)*count(*)-count(distinct 19) then +(max(a)+case - - - -min(t1.f) when max(c) then count(distinct (f)) else min(13) end) else ( -cast(avg( -t1.b) AS integer)) end from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where (abs(e*coalesce((select (abs(b*(t1.b)+f)/abs(d)) from t1 where t1.c in (select min(a | t1.b) from t1 union select abs(case -case ~ -~cast(avg(e) AS integer) when ++min(17)+( -cast(avg(a) AS integer))-max(t1.c) then cast(avg(t1.b) AS integer) else cast(avg(f) AS integer) end when - -max((t1.d)) then -min(t1.b) else cast(avg(t1.c) AS integer) end) from t1)),b))/abs(t1.d)) in (select min(t1.c)-cast(avg( -e) AS integer)- -cast(avg(t1.f) AS integer) from t1 union select (max((19))) from t1)))}
+} {-99}
+do_test randexpr-2.768 {
+ db eval {SELECT t1.a+11*coalesce((select max( -t1.e-coalesce((select max((abs(t1.c)/abs((13*e+t1.c)-t1.f))) from t1 where exists(select 1 from t1 where d<>a) or ~(select case abs(count(distinct f)) when (count(*)) then count(*) else min(t1.f) end from t1)+coalesce((select f from t1 where d in (select min(t1.d) from t1 union select count(*) from t1)),c) in (11,t1.a,t1.b)),11)- -11) from t1 where 13<11),t1.b) FROM t1 WHERE not ++coalesce((select t1.f from t1 where not exists(select 1 from t1 where ((select min(b) from t1)<>case t1.d when coalesce((select max(case e-t1.c when 19-t1.c+f+(t1.c*coalesce((select max(17) from t1 where 17 between 11 and t1.a),t1.d)+b) then -17 else d end-a) from t1 where t1.d>11),b) then 11 else c end))),b | t1.d)*17 not between t1.e and 17}
+} {}
+do_test randexpr-2.769 {
+ db eval {SELECT t1.a+11*coalesce((select max( -t1.e-coalesce((select max((abs(t1.c)/abs((13*e+t1.c)-t1.f))) from t1 where exists(select 1 from t1 where d<>a) or ~(select case abs(count(distinct f)) when (count(*)) then count(*) else min(t1.f) end from t1)+coalesce((select f from t1 where d in (select min(t1.d) from t1 union select count(*) from t1)),c) in (11,t1.a,t1.b)),11)- -11) from t1 where 13<11),t1.b) FROM t1 WHERE NOT (not ++coalesce((select t1.f from t1 where not exists(select 1 from t1 where ((select min(b) from t1)<>case t1.d when coalesce((select max(case e-t1.c when 19-t1.c+f+(t1.c*coalesce((select max(17) from t1 where 17 between 11 and t1.a),t1.d)+b) then -17 else d end-a) from t1 where t1.d>11),b) then 11 else c end))),b | t1.d)*17 not between t1.e and 17)}
+} {2300}
+do_test randexpr-2.770 {
+ db eval {SELECT coalesce((select max(coalesce((select ((abs(coalesce((select max((select ~(count(distinct e-11)-cast(avg(t1.a) AS integer) | count(*)) from t1)) from t1 where t1.f<case when not exists(select 1 from t1 where exists(select 1 from t1 where t1.a not in (11,e,13))) then t1.b when t1.d<t1.b then t1.e else t1.b end+ -c or t1.e>b or t1.c in (select c from t1 union select 19 from t1)),e | b))/abs(t1.f))) from t1 where e in (select -(b) from t1 union select 13 from t1)),t1.a)) from t1 where f<>11),t1.e) FROM t1 WHERE -11 in (a,case when exists(select 1 from t1 where 11 in (select 13 from t1 union select t1.d from t1)) and exists(select 1 from t1 where exists(select 1 from t1 where (t1.a) not between t1.c and t1.c)) then ~case when ~t1.f not between +t1.b-11 and e or not b in (c,17,e) and (not exists(select 1 from t1 where b in (( -t1.e), -t1.c,t1.c))) or 17 not in (t1.e,t1.c,t1.f) then c when 19= - -11 then t1.b else t1.c end when (13) between t1.f and ( -t1.e) then t1.d else -t1.d end*c,d)}
+} {}
+do_test randexpr-2.771 {
+ db eval {SELECT coalesce((select max(coalesce((select ((abs(coalesce((select max((select ~(count(distinct e-11)-cast(avg(t1.a) AS integer) | count(*)) from t1)) from t1 where t1.f<case when not exists(select 1 from t1 where exists(select 1 from t1 where t1.a not in (11,e,13))) then t1.b when t1.d<t1.b then t1.e else t1.b end+ -c or t1.e>b or t1.c in (select c from t1 union select 19 from t1)),e | b))/abs(t1.f))) from t1 where e in (select -(b) from t1 union select 13 from t1)),t1.a)) from t1 where f<>11),t1.e) FROM t1 WHERE NOT ( -11 in (a,case when exists(select 1 from t1 where 11 in (select 13 from t1 union select t1.d from t1)) and exists(select 1 from t1 where exists(select 1 from t1 where (t1.a) not between t1.c and t1.c)) then ~case when ~t1.f not between +t1.b-11 and e or not b in (c,17,e) and (not exists(select 1 from t1 where b in (( -t1.e), -t1.c,t1.c))) or 17 not in (t1.e,t1.c,t1.f) then c when 19= - -11 then t1.b else t1.c end when (13) between t1.f and ( -t1.e) then t1.d else -t1.d end*c,d))}
+} {100}
+do_test randexpr-2.772 {
+ db eval {SELECT coalesce((select max(coalesce((select ((abs(coalesce((select max((select ~(count(distinct e-11)-cast(avg(t1.a) AS integer) & count(*)) from t1)) from t1 where t1.f<case when not exists(select 1 from t1 where exists(select 1 from t1 where t1.a not in (11,e,13))) then t1.b when t1.d<t1.b then t1.e else t1.b end+ -c or t1.e>b or t1.c in (select c from t1 union select 19 from t1)),e & b))/abs(t1.f))) from t1 where e in (select -(b) from t1 union select 13 from t1)),t1.a)) from t1 where f<>11),t1.e) FROM t1 WHERE NOT ( -11 in (a,case when exists(select 1 from t1 where 11 in (select 13 from t1 union select t1.d from t1)) and exists(select 1 from t1 where exists(select 1 from t1 where (t1.a) not between t1.c and t1.c)) then ~case when ~t1.f not between +t1.b-11 and e or not b in (c,17,e) and (not exists(select 1 from t1 where b in (( -t1.e), -t1.c,t1.c))) or 17 not in (t1.e,t1.c,t1.f) then c when 19= - -11 then t1.b else t1.c end when (13) between t1.f and ( -t1.e) then t1.d else -t1.d end*c,d))}
+} {100}
+do_test randexpr-2.773 {
+ db eval {SELECT 17-13-case 19 when 17+case case t1.b when t1.b then coalesce((select coalesce((select 11 from t1 where (coalesce((select t1.a from t1 where (abs(f)/abs(case t1.e when 11 then a else t1.c end))<c),b)*a- -t1.e) not between t1.e and -13),19) from t1 where d>19 or d not between f and t1.e),(t1.c)) else 11 end when -a then 13 else e end then t1.b else b end+t1.c FROM t1 WHERE not exists(select 1 from t1 where coalesce((select e from t1 where case when not exists(select 1 from t1 where not not exists(select 1 from t1 where f<> -t1.e-t1.c)) or coalesce((select max(17+t1.c) from t1 where t1.f in (select cast(avg(17) AS integer) from t1 union select cast(avg(t1.c) AS integer) from t1)),t1.d)<>19 then 19 else t1.a+ -(b)+t1.c end<=t1.c),t1.b)>t1.d) or (e) in (t1.c,f,13) or d in (select +count(*) from t1 union select count(*) from t1)}
+} {}
+do_test randexpr-2.774 {
+ db eval {SELECT 17-13-case 19 when 17+case case t1.b when t1.b then coalesce((select coalesce((select 11 from t1 where (coalesce((select t1.a from t1 where (abs(f)/abs(case t1.e when 11 then a else t1.c end))<c),b)*a- -t1.e) not between t1.e and -13),19) from t1 where d>19 or d not between f and t1.e),(t1.c)) else 11 end when -a then 13 else e end then t1.b else b end+t1.c FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select e from t1 where case when not exists(select 1 from t1 where not not exists(select 1 from t1 where f<> -t1.e-t1.c)) or coalesce((select max(17+t1.c) from t1 where t1.f in (select cast(avg(17) AS integer) from t1 union select cast(avg(t1.c) AS integer) from t1)),t1.d)<>19 then 19 else t1.a+ -(b)+t1.c end<=t1.c),t1.b)>t1.d) or (e) in (t1.c,f,13) or d in (select +count(*) from t1 union select count(*) from t1))}
+} {104}
+do_test randexpr-2.775 {
+ db eval {SELECT t1.e*(abs(coalesce((select max(case when t1.c in (select (case when d>13 then t1.c else 11 end+e) from t1 union select t1.a from t1) or t1.a between 17 and c then c when t1.d>=a then t1.c else t1.e end-t1.e*t1.b-d) from t1 where b<>(t1.c) or not exists(select 1 from t1 where b in (t1.d,13,a))),11)*t1.a)/abs(t1.a))+t1.c FROM t1 WHERE a>c}
+} {}
+do_test randexpr-2.776 {
+ db eval {SELECT t1.e*(abs(coalesce((select max(case when t1.c in (select (case when d>13 then t1.c else 11 end+e) from t1 union select t1.a from t1) or t1.a between 17 and c then c when t1.d>=a then t1.c else t1.e end-t1.e*t1.b-d) from t1 where b<>(t1.c) or not exists(select 1 from t1 where b in (t1.d,13,a))),11)*t1.a)/abs(t1.a))+t1.c FROM t1 WHERE NOT (a>c)}
+} {50050300}
+do_test randexpr-2.777 {
+ db eval {SELECT t1.d*(+coalesce((select max(case when coalesce((select (abs(f)/abs((abs(d)/abs((select cast(avg(19+11) AS integer) from t1)))+t1.b)) from t1 where exists(select 1 from t1 where t1.d not between t1.f and t1.e)),17) not in (17,t1.f, -t1.b) then 19 else -19 end) from t1 where exists(select 1 from t1 where 11 in (select abs(count(distinct t1.f)) from t1 union select cast(avg(t1.e) AS integer) from t1) and exists(select 1 from t1 where t1.f<t1.c) or 17<f)),13)+13) FROM t1 WHERE not exists(select 1 from t1 where t1.c*coalesce((select max(19) from t1 where a between (select abs(+min(b)*case cast(avg(b) AS integer) when case -(count(distinct 11)) when max(coalesce((select 11 from t1 where c in (13,17,t1.b)),b)) then -count(*) else (cast(avg(19) AS integer)) end+max(11) then max(t1.e) else count(*) end | count(*))+count(*) from t1) and ~a),(select -count(*) from t1)) between t1.c and 13-d)}
+} {12800}
+do_test randexpr-2.778 {
+ db eval {SELECT t1.d*(+coalesce((select max(case when coalesce((select (abs(f)/abs((abs(d)/abs((select cast(avg(19+11) AS integer) from t1)))+t1.b)) from t1 where exists(select 1 from t1 where t1.d not between t1.f and t1.e)),17) not in (17,t1.f, -t1.b) then 19 else -19 end) from t1 where exists(select 1 from t1 where 11 in (select abs(count(distinct t1.f)) from t1 union select cast(avg(t1.e) AS integer) from t1) and exists(select 1 from t1 where t1.f<t1.c) or 17<f)),13)+13) FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.c*coalesce((select max(19) from t1 where a between (select abs(+min(b)*case cast(avg(b) AS integer) when case -(count(distinct 11)) when max(coalesce((select 11 from t1 where c in (13,17,t1.b)),b)) then -count(*) else (cast(avg(19) AS integer)) end+max(11) then max(t1.e) else count(*) end | count(*))+count(*) from t1) and ~a),(select -count(*) from t1)) between t1.c and 13-d))}
+} {}
+do_test randexpr-2.779 {
+ db eval {SELECT coalesce((select max(coalesce((select (select cast(avg(d) AS integer) | case max(~f) | count(distinct t1.d) when count(*) then count(*) else -min(17) end from t1) from t1 where b=t1.e+ -e or t1.a not in (t1.f,t1.d,t1.d) or f not in (t1.a, -t1.b,f)),t1.c)+b | 13-d) from t1 where t1.b> -11),(17)) | b-19*d FROM t1 WHERE b>coalesce((select max(13+d) from t1 where 17>=11),t1.b)}
+} {}
+do_test randexpr-2.780 {
+ db eval {SELECT coalesce((select max(coalesce((select (select cast(avg(d) AS integer) | case max(~f) | count(distinct t1.d) when count(*) then count(*) else -min(17) end from t1) from t1 where b=t1.e+ -e or t1.a not in (t1.f,t1.d,t1.d) or f not in (t1.a, -t1.b,f)),t1.c)+b | 13-d) from t1 where t1.b> -11),(17)) | b-19*d FROM t1 WHERE NOT (b>coalesce((select max(13+d) from t1 where 17>=11),t1.b))}
+} {-1}
+do_test randexpr-2.781 {
+ db eval {SELECT coalesce((select max(coalesce((select (select cast(avg(d) AS integer) & case max(~f) & count(distinct t1.d) when count(*) then count(*) else -min(17) end from t1) from t1 where b=t1.e+ -e or t1.a not in (t1.f,t1.d,t1.d) or f not in (t1.a, -t1.b,f)),t1.c)+b & 13-d) from t1 where t1.b> -11),(17)) & b-19*d FROM t1 WHERE NOT (b>coalesce((select max(13+d) from t1 where 17>=11),t1.b))}
+} {8}
+do_test randexpr-2.782 {
+ db eval {SELECT (d+f*t1.c-t1.e+coalesce((select c from t1 where c>=a),case when (c in (select e from t1 union select 13 from t1)) then 11+a else f end))-13 FROM t1 WHERE c not between c and b+coalesce((select c from t1 where t1.d<case when 13 not in (case a when b then coalesce((select max(case when f in (select case when ((t1.c | t1.f not between c and 13)) then t1.e-(t1.a) else 17 end from t1 union select 13 from t1) then t1.e else e end*a) from t1 where 11=17),t1.f) else f end,17,t1.f) then t1.d else t1.d end+t1.a | b),f)}
+} {}
+do_test randexpr-2.783 {
+ db eval {SELECT (d+f*t1.c-t1.e+coalesce((select c from t1 where c>=a),case when (c in (select e from t1 union select 13 from t1)) then 11+a else f end))-13 FROM t1 WHERE NOT (c not between c and b+coalesce((select c from t1 where t1.d<case when 13 not in (case a when b then coalesce((select max(case when f in (select case when ((t1.c | t1.f not between c and 13)) then t1.e-(t1.a) else 17 end from t1 union select 13 from t1) then t1.e else e end*a) from t1 where 11=17),t1.f) else f end,17,t1.f) then t1.d else t1.d end+t1.a | b),f))}
+} {180187}
+do_test randexpr-2.784 {
+ db eval {SELECT case when t1.e not in (t1.a,~case when case when 17>=d then (abs(13)/abs(t1.f)) when (d in ((select abs(min(19)) from t1), -(select count(*)-abs( -count(*)) from t1),t1.e)) then coalesce((select max(19) from t1 where (c)>t1.f),17) else 13 end<>a then 11 when b<(d) then b else c end,d) then 17 when (17 in (13,t1.a,t1.c)) then e else c end+t1.c FROM t1 WHERE t1.a+t1.e in (select 19 from t1 union select t1.c from t1)}
+} {}
+do_test randexpr-2.785 {
+ db eval {SELECT case when t1.e not in (t1.a,~case when case when 17>=d then (abs(13)/abs(t1.f)) when (d in ((select abs(min(19)) from t1), -(select count(*)-abs( -count(*)) from t1),t1.e)) then coalesce((select max(19) from t1 where (c)>t1.f),17) else 13 end<>a then 11 when b<(d) then b else c end,d) then 17 when (17 in (13,t1.a,t1.c)) then e else c end+t1.c FROM t1 WHERE NOT (t1.a+t1.e in (select 19 from t1 union select t1.c from t1))}
+} {317}
+do_test randexpr-2.786 {
+ db eval {SELECT (select ~cast(avg(t1.c) AS integer)*case count(*) | +min(case +case when a<13 or case t1.f when c then 17 else t1.d end in (11,a,(t1.a)) and a<>a then t1.b+f when f not in (d,t1.a,c) then t1.f else t1.e end when t1.f then 17 else f end)+abs(++count(distinct 19))*(count(distinct 13))-count(distinct t1.e)-(count(*))*max(19) when max(11) then cast(avg(a) AS integer) else min(t1.f) end from t1) FROM t1 WHERE t1.a not between 17 and d}
+} {}
+do_test randexpr-2.787 {
+ db eval {SELECT (select ~cast(avg(t1.c) AS integer)*case count(*) | +min(case +case when a<13 or case t1.f when c then 17 else t1.d end in (11,a,(t1.a)) and a<>a then t1.b+f when f not in (d,t1.a,c) then t1.f else t1.e end when t1.f then 17 else f end)+abs(++count(distinct 19))*(count(distinct 13))-count(distinct t1.e)-(count(*))*max(19) when max(11) then cast(avg(a) AS integer) else min(t1.f) end from t1) FROM t1 WHERE NOT (t1.a not between 17 and d)}
+} {-180600}
+do_test randexpr-2.788 {
+ db eval {SELECT (select ~cast(avg(t1.c) AS integer)*case count(*) & +min(case +case when a<13 or case t1.f when c then 17 else t1.d end in (11,a,(t1.a)) and a<>a then t1.b+f when f not in (d,t1.a,c) then t1.f else t1.e end when t1.f then 17 else f end)+abs(++count(distinct 19))*(count(distinct 13))-count(distinct t1.e)-(count(*))*max(19) when max(11) then cast(avg(a) AS integer) else min(t1.f) end from t1) FROM t1 WHERE NOT (t1.a not between 17 and d)}
+} {-180600}
+do_test randexpr-2.789 {
+ db eval {SELECT case t1.a when c then -~t1.d*t1.e-coalesce((select max((abs(d+e+d)/abs(case when 11-t1.d in (select t1.d from t1 union select coalesce((select t1.c from t1 where 17<=t1.d and e between 11 and a),c) from t1) or 11 in (select ( -+(count(*))) from t1 union select count(distinct -t1.a) from t1) then (f) when b=a then c else t1.b end))) from t1 where t1.c not between 17 and t1.b),13)+t1.f else d end FROM t1 WHERE not exists(select 1 from t1 where f<=a)}
+} {400}
+do_test randexpr-2.790 {
+ db eval {SELECT case t1.a when c then -~t1.d*t1.e-coalesce((select max((abs(d+e+d)/abs(case when 11-t1.d in (select t1.d from t1 union select coalesce((select t1.c from t1 where 17<=t1.d and e between 11 and a),c) from t1) or 11 in (select ( -+(count(*))) from t1 union select count(distinct -t1.a) from t1) then (f) when b=a then c else t1.b end))) from t1 where t1.c not between 17 and t1.b),13)+t1.f else d end FROM t1 WHERE NOT (not exists(select 1 from t1 where f<=a))}
+} {}
+do_test randexpr-2.791 {
+ db eval {SELECT (select -max(d) from t1)+coalesce((select max(t1.e*t1.d*f) from t1 where t1.b-coalesce((select -a*d from t1 where t1.c not in (t1.f,coalesce((select b+t1.b from t1 where t1.a not between f and t1.b),coalesce((select -b from t1 where (t1.d>=t1.c) and 19<>t1.f),t1.a))-e*a,e)),(t1.a))+t1.f between 19 and e),t1.a)*a FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where case when t1.d-t1.b-t1.d*(case when t1.b>= -t1.d then c when t1.d not between c and t1.d then (19) else d end*e)+t1.d | 19>t1.c then e when exists(select 1 from t1 where t1.e not between d and t1.b or (17 in (t1.e, - -a,t1.d))) then t1.f else (e) end between 13 and e or 11>t1.b))}
+} {9600}
+do_test randexpr-2.792 {
+ db eval {SELECT (select -max(d) from t1)+coalesce((select max(t1.e*t1.d*f) from t1 where t1.b-coalesce((select -a*d from t1 where t1.c not in (t1.f,coalesce((select b+t1.b from t1 where t1.a not between f and t1.b),coalesce((select -b from t1 where (t1.d>=t1.c) and 19<>t1.f),t1.a))-e*a,e)),(t1.a))+t1.f between 19 and e),t1.a)*a FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where case when t1.d-t1.b-t1.d*(case when t1.b>= -t1.d then c when t1.d not between c and t1.d then (19) else d end*e)+t1.d | 19>t1.c then e when exists(select 1 from t1 where t1.e not between d and t1.b or (17 in (t1.e, - -a,t1.d))) then t1.f else (e) end between 13 and e or 11>t1.b)))}
+} {}
+do_test randexpr-2.793 {
+ db eval {SELECT 11-t1.d-t1.e-case when (select count(distinct t1.b+coalesce((select max((abs(19)/abs(case when coalesce((select t1.f from t1 where e not between t1.f and t1.f),f)*( -11)=((e)) then 11 else d end))) from t1 where e in (17,t1.b,t1.b)), -t1.a)-(t1.c)) from t1)>t1.f then t1.b when 11>13 and a>=f then 11 else d end-t1.f FROM t1 WHERE (select min(d)-case cast(avg(case (d-~t1.c+~(select max(+d-coalesce((select max(t1.f) from t1 where c<>e),t1.a))-(( - -(cast(avg(13) AS integer)))-count(distinct e))*max(17) from t1) | 19-13*b) when -t1.d then 13 else -13 end) AS integer) when min(t1.c) then cast(avg(e) AS integer) else ~count(*) end from t1)<b}
+} {}
+do_test randexpr-2.794 {
+ db eval {SELECT 11-t1.d-t1.e-case when (select count(distinct t1.b+coalesce((select max((abs(19)/abs(case when coalesce((select t1.f from t1 where e not between t1.f and t1.f),f)*( -11)=((e)) then 11 else d end))) from t1 where e in (17,t1.b,t1.b)), -t1.a)-(t1.c)) from t1)>t1.f then t1.b when 11>13 and a>=f then 11 else d end-t1.f FROM t1 WHERE NOT ((select min(d)-case cast(avg(case (d-~t1.c+~(select max(+d-coalesce((select max(t1.f) from t1 where c<>e),t1.a))-(( - -(cast(avg(13) AS integer)))-count(distinct e))*max(17) from t1) | 19-13*b) when -t1.d then 13 else -13 end) AS integer) when min(t1.c) then cast(avg(e) AS integer) else ~count(*) end from t1)<b)}
+} {-1889}
+do_test randexpr-2.795 {
+ db eval {SELECT case f when 13 then 19 else case when (case when c not between b and d then t1.c when +~t1.d+(select -+cast(avg(t1.a) AS integer) | ((max(t1.d)))*(max(e)) from t1)-19+t1.a*t1.d in (select ~max(c) from t1 union select count(distinct d)-count(distinct b) from t1) then f else -11 end not between 11 and 11) or 17>(c) then t1.d else 13 end end FROM t1 WHERE not ((abs(f)/abs(t1.b))<=(select min(+t1.d)+~+case count(distinct (abs(case d when 11 then coalesce((select coalesce((select max(t1.a) from t1 where t1.b=t1.e),t1.f) | a from t1 where 13<>(a)),d) else 17 end*f)/abs(t1.f))) when cast(avg(t1.c) AS integer) then case count(*) when min(t1.b) | cast(avg(t1.c) AS integer) then count(distinct f) else max(17) end else cast(avg((c)) AS integer) end from t1))}
+} {}
+do_test randexpr-2.796 {
+ db eval {SELECT case f when 13 then 19 else case when (case when c not between b and d then t1.c when +~t1.d+(select -+cast(avg(t1.a) AS integer) | ((max(t1.d)))*(max(e)) from t1)-19+t1.a*t1.d in (select ~max(c) from t1 union select count(distinct d)-count(distinct b) from t1) then f else -11 end not between 11 and 11) or 17>(c) then t1.d else 13 end end FROM t1 WHERE NOT (not ((abs(f)/abs(t1.b))<=(select min(+t1.d)+~+case count(distinct (abs(case d when 11 then coalesce((select coalesce((select max(t1.a) from t1 where t1.b=t1.e),t1.f) | a from t1 where 13<>(a)),d) else 17 end*f)/abs(t1.f))) when cast(avg(t1.c) AS integer) then case count(*) when min(t1.b) | cast(avg(t1.c) AS integer) then count(distinct f) else max(17) end else cast(avg((c)) AS integer) end from t1)))}
+} {400}
+do_test randexpr-2.797 {
+ db eval {SELECT case f when 13 then 19 else case when (case when c not between b and d then t1.c when +~t1.d+(select -+cast(avg(t1.a) AS integer) & ((max(t1.d)))*(max(e)) from t1)-19+t1.a*t1.d in (select ~max(c) from t1 union select count(distinct d)-count(distinct b) from t1) then f else -11 end not between 11 and 11) or 17>(c) then t1.d else 13 end end FROM t1 WHERE NOT (not ((abs(f)/abs(t1.b))<=(select min(+t1.d)+~+case count(distinct (abs(case d when 11 then coalesce((select coalesce((select max(t1.a) from t1 where t1.b=t1.e),t1.f) | a from t1 where 13<>(a)),d) else 17 end*f)/abs(t1.f))) when cast(avg(t1.c) AS integer) then case count(*) when min(t1.b) | cast(avg(t1.c) AS integer) then count(distinct f) else max(17) end else cast(avg((c)) AS integer) end from t1)))}
+} {400}
+do_test randexpr-2.798 {
+ db eval {SELECT f+case when (not exists(select 1 from t1 where ((17<>+t1.b+t1.f or b between t1.e and t1.e)))) then (abs( -(abs(case when exists(select 1 from t1 where not exists(select 1 from t1 where d in (select (select cast(avg((t1.b)) AS integer)-count(*) from t1) from t1 union select t1.e+(11) from t1))) then c when not t1.d between f and 11 or d>a then (a) else 13 end+t1.e+e)/abs(d)))/abs(t1.b)) else f end-13 FROM t1 WHERE case when 17< - -t1.b-case when not exists(select 1 from t1 where 19<>t1.d) then 13+coalesce((select max((abs((case case when - -t1.c*11 in (select +max(t1.d)*count(distinct -t1.c) from t1 union select max(t1.b) from t1) then 13 else 19 end when f then 19 else (t1.d) end)+e)/abs(f))) from t1 where (13 between t1.d and 19)),t1.b) else 13 end then a else t1.a end-13 not in (t1.d,d,(t1.f))}
+} {1187}
+do_test randexpr-2.799 {
+ db eval {SELECT f+case when (not exists(select 1 from t1 where ((17<>+t1.b+t1.f or b between t1.e and t1.e)))) then (abs( -(abs(case when exists(select 1 from t1 where not exists(select 1 from t1 where d in (select (select cast(avg((t1.b)) AS integer)-count(*) from t1) from t1 union select t1.e+(11) from t1))) then c when not t1.d between f and 11 or d>a then (a) else 13 end+t1.e+e)/abs(d)))/abs(t1.b)) else f end-13 FROM t1 WHERE NOT (case when 17< - -t1.b-case when not exists(select 1 from t1 where 19<>t1.d) then 13+coalesce((select max((abs((case case when - -t1.c*11 in (select +max(t1.d)*count(distinct -t1.c) from t1 union select max(t1.b) from t1) then 13 else 19 end when f then 19 else (t1.d) end)+e)/abs(f))) from t1 where (13 between t1.d and 19)),t1.b) else 13 end then a else t1.a end-13 not in (t1.d,d,(t1.f)))}
+} {}
+do_test randexpr-2.800 {
+ db eval {SELECT +~t1.a-(abs(+case when (((t1.d*t1.c+11 in (select cast(avg(17) AS integer) from t1 union select -(count(*)) from t1)))) then -coalesce((select t1.e-b from t1 where not exists(select 1 from t1 where t1.c in (select max(f) from t1 union select max(e) | max( -t1.e)-count(*) from t1))),f) else f end)/abs(t1.f))-e+11+t1.b+t1.a- -17 FROM t1 WHERE +b between case when c<=t1.a then t1.b when case when -t1.a*d-17+17*~e- -13 in (select + -max(19) | +cast(avg(19) AS integer) from t1 union select (count(distinct -19)*case max((13)) when max(e)*count(*) then min(t1.d) else count(*) end) from t1) then t1.f else (d) end in (select e from t1 union select d from t1) then f else -t1.b end and b}
+} {}
+do_test randexpr-2.801 {
+ db eval {SELECT +~t1.a-(abs(+case when (((t1.d*t1.c+11 in (select cast(avg(17) AS integer) from t1 union select -(count(*)) from t1)))) then -coalesce((select t1.e-b from t1 where not exists(select 1 from t1 where t1.c in (select max(f) from t1 union select max(e) | max( -t1.e)-count(*) from t1))),f) else f end)/abs(t1.f))-e+11+t1.b+t1.a- -17 FROM t1 WHERE NOT (+b between case when c<=t1.a then t1.b when case when -t1.a*d-17+17*~e- -13 in (select + -max(19) | +cast(avg(19) AS integer) from t1 union select (count(distinct -19)*case max((13)) when max(e)*count(*) then min(t1.d) else count(*) end) from t1) then t1.f else (d) end in (select e from t1 union select d from t1) then f else -t1.b end and b)}
+} {-274}
+do_test randexpr-2.802 {
+ db eval {SELECT +~t1.a-(abs(+case when (((t1.d*t1.c+11 in (select cast(avg(17) AS integer) from t1 union select -(count(*)) from t1)))) then -coalesce((select t1.e-b from t1 where not exists(select 1 from t1 where t1.c in (select max(f) from t1 union select max(e) & max( -t1.e)-count(*) from t1))),f) else f end)/abs(t1.f))-e+11+t1.b+t1.a- -17 FROM t1 WHERE NOT (+b between case when c<=t1.a then t1.b when case when -t1.a*d-17+17*~e- -13 in (select + -max(19) | +cast(avg(19) AS integer) from t1 union select (count(distinct -19)*case max((13)) when max(e)*count(*) then min(t1.d) else count(*) end) from t1) then t1.f else (d) end in (select e from t1 union select d from t1) then f else -t1.b end and b)}
+} {-274}
+do_test randexpr-2.803 {
+ db eval {SELECT case when 19=(select ( -count(*)* -(cast(avg(t1.e) AS integer))+count(distinct 13)*min(t1.f)) | cast(avg(t1.e) AS integer) | -cast(avg(13) AS integer)-(min(d)) from t1) then 13*a when t1.a+((select min((t1.d)) from t1)) in (select t1.b from t1 union select 11 from t1) or not exists(select 1 from t1 where not exists(select 1 from t1 where - -e in (select t1.e from t1 union select t1.d from t1) or t1.d in (select count(distinct t1.a) from t1 union select count(*) from t1)) or -b=(19) and 11<c) then b else t1.c end*a FROM t1 WHERE 17-case 19 when t1.f-+(t1.d)-t1.a*t1.a then ~t1.d | e*coalesce((select b from t1 where 17< -17), -f)-17 else 19 end-case when (~t1.d)*17<f then f when t1.c in (f,a,t1.e) then t1.f else 17 end not in (t1.c,e,t1.d)}
+} {20000}
+do_test randexpr-2.804 {
+ db eval {SELECT case when 19=(select ( -count(*)* -(cast(avg(t1.e) AS integer))+count(distinct 13)*min(t1.f)) | cast(avg(t1.e) AS integer) | -cast(avg(13) AS integer)-(min(d)) from t1) then 13*a when t1.a+((select min((t1.d)) from t1)) in (select t1.b from t1 union select 11 from t1) or not exists(select 1 from t1 where not exists(select 1 from t1 where - -e in (select t1.e from t1 union select t1.d from t1) or t1.d in (select count(distinct t1.a) from t1 union select count(*) from t1)) or -b=(19) and 11<c) then b else t1.c end*a FROM t1 WHERE NOT (17-case 19 when t1.f-+(t1.d)-t1.a*t1.a then ~t1.d | e*coalesce((select b from t1 where 17< -17), -f)-17 else 19 end-case when (~t1.d)*17<f then f when t1.c in (f,a,t1.e) then t1.f else 17 end not in (t1.c,e,t1.d))}
+} {}
+do_test randexpr-2.805 {
+ db eval {SELECT case when 19=(select ( -count(*)* -(cast(avg(t1.e) AS integer))+count(distinct 13)*min(t1.f)) & cast(avg(t1.e) AS integer) & -cast(avg(13) AS integer)-(min(d)) from t1) then 13*a when t1.a+((select min((t1.d)) from t1)) in (select t1.b from t1 union select 11 from t1) or not exists(select 1 from t1 where not exists(select 1 from t1 where - -e in (select t1.e from t1 union select t1.d from t1) or t1.d in (select count(distinct t1.a) from t1 union select count(*) from t1)) or -b=(19) and 11<c) then b else t1.c end*a FROM t1 WHERE 17-case 19 when t1.f-+(t1.d)-t1.a*t1.a then ~t1.d | e*coalesce((select b from t1 where 17< -17), -f)-17 else 19 end-case when (~t1.d)*17<f then f when t1.c in (f,a,t1.e) then t1.f else 17 end not in (t1.c,e,t1.d)}
+} {20000}
+do_test randexpr-2.806 {
+ db eval {SELECT +t1.a*11+case when 19<13-11 or exists(select 1 from t1 where not (abs(f)/abs(+t1.a+t1.c*t1.d-t1.c))*t1.a between t1.e and 17) then coalesce((select max(t1.a) from t1 where t1.b not between t1.a and t1.a),17) when 13 not between -f and -t1.d then t1.c else d end-13-13*c*t1.e FROM t1 WHERE 19<=case t1.b when -t1.d+c-t1.a-19-t1.f*t1.b-coalesce((select max(coalesce((select max( -b) from t1 where not t1.f+19 in (select case cast(avg(17) AS integer) when min(t1.a) then max((d)) else max(b) end | count(*) from t1 union select max(13) from t1) and not exists(select 1 from t1 where t1.c not between 19 and 11)),t1.e)*19) from t1 where 13 in (select -d from t1 union select t1.f from t1)),b)-e-(t1.e) then t1.f else t1.e end}
+} {-1948813}
+do_test randexpr-2.807 {
+ db eval {SELECT +t1.a*11+case when 19<13-11 or exists(select 1 from t1 where not (abs(f)/abs(+t1.a+t1.c*t1.d-t1.c))*t1.a between t1.e and 17) then coalesce((select max(t1.a) from t1 where t1.b not between t1.a and t1.a),17) when 13 not between -f and -t1.d then t1.c else d end-13-13*c*t1.e FROM t1 WHERE NOT (19<=case t1.b when -t1.d+c-t1.a-19-t1.f*t1.b-coalesce((select max(coalesce((select max( -b) from t1 where not t1.f+19 in (select case cast(avg(17) AS integer) when min(t1.a) then max((d)) else max(b) end | count(*) from t1 union select max(13) from t1) and not exists(select 1 from t1 where t1.c not between 19 and 11)),t1.e)*19) from t1 where 13 in (select -d from t1 union select t1.f from t1)),b)-e-(t1.e) then t1.f else t1.e end)}
+} {}
+do_test randexpr-2.808 {
+ db eval {SELECT case (abs(f)/abs(f)) when t1.e*t1.f then (abs(t1.d)/abs(t1.b*11)) else ~case when case ~~19 when t1.f then e else case coalesce((select (abs(f)/abs(a)) from t1 where t1.a<>17 and t1.a>= -t1.b),t1.f) when t1.d then c else t1.d end end in (select count(*) from t1 union select ~abs(min(t1.a)) | count(*) from t1) then 17 when t1.f not between (e) and t1.c then f else b end+c+a end FROM t1 WHERE t1.f in (case when ~(select max(d) from t1)*t1.f>=case when 17*d<t1.f then d when (t1.d) not between t1.e-t1.d-e and +(t1.e*13*(select case count(*) when -count(distinct e) then max(13) else count(distinct t1.b) end from t1)-case when c<e then c else 11 end)-17 then -c else t1.c end then e else (13) end+d,t1.a,11)}
+} {}
+do_test randexpr-2.809 {
+ db eval {SELECT case (abs(f)/abs(f)) when t1.e*t1.f then (abs(t1.d)/abs(t1.b*11)) else ~case when case ~~19 when t1.f then e else case coalesce((select (abs(f)/abs(a)) from t1 where t1.a<>17 and t1.a>= -t1.b),t1.f) when t1.d then c else t1.d end end in (select count(*) from t1 union select ~abs(min(t1.a)) | count(*) from t1) then 17 when t1.f not between (e) and t1.c then f else b end+c+a end FROM t1 WHERE NOT (t1.f in (case when ~(select max(d) from t1)*t1.f>=case when 17*d<t1.f then d when (t1.d) not between t1.e-t1.d-e and +(t1.e*13*(select case count(*) when -count(distinct e) then max(13) else count(distinct t1.b) end from t1)-case when c<e then c else 11 end)-17 then -c else t1.c end then e else (13) end+d,t1.a,11))}
+} {-201}
+do_test randexpr-2.810 {
+ db eval {SELECT case (abs(f)/abs(f)) when t1.e*t1.f then (abs(t1.d)/abs(t1.b*11)) else ~case when case ~~19 when t1.f then e else case coalesce((select (abs(f)/abs(a)) from t1 where t1.a<>17 and t1.a>= -t1.b),t1.f) when t1.d then c else t1.d end end in (select count(*) from t1 union select ~abs(min(t1.a)) & count(*) from t1) then 17 when t1.f not between (e) and t1.c then f else b end+c+a end FROM t1 WHERE NOT (t1.f in (case when ~(select max(d) from t1)*t1.f>=case when 17*d<t1.f then d when (t1.d) not between t1.e-t1.d-e and +(t1.e*13*(select case count(*) when -count(distinct e) then max(13) else count(distinct t1.b) end from t1)-case when c<e then c else 11 end)-17 then -c else t1.c end then e else (13) end+d,t1.a,11))}
+} {-201}
+do_test randexpr-2.811 {
+ db eval {SELECT (abs(case when a*case when e<+(t1.e) then e else d end+t1.f<c then t1.e when d not between +13 and case when (e>=(select cast(avg(13) AS integer) from t1)) and (exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select t1.c from t1 where (b between d and 13)),t1.e)>13))) then case when b not between 19 and t1.c then a else 13 end+t1.b when t1.c>11 then c else b end then 13 else t1.d end*t1.f)/abs(17)) FROM t1 WHERE c not in (coalesce((select max(d) from t1 where (select min(t1.e) from t1)-17<=coalesce((select t1.c from t1 where exists(select 1 from t1 where 17<19 or coalesce((select 13 from t1 where t1.e not in (a+t1.c,t1.e*t1.a+t1.d* -a*(a)*f,((b)))),19) not in (c,t1.f,t1.b))),(select abs( -max(19)) from t1))),t1.f)-t1.b, -f,17)}
+} {458}
+do_test randexpr-2.812 {
+ db eval {SELECT (abs(case when a*case when e<+(t1.e) then e else d end+t1.f<c then t1.e when d not between +13 and case when (e>=(select cast(avg(13) AS integer) from t1)) and (exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select t1.c from t1 where (b between d and 13)),t1.e)>13))) then case when b not between 19 and t1.c then a else 13 end+t1.b when t1.c>11 then c else b end then 13 else t1.d end*t1.f)/abs(17)) FROM t1 WHERE NOT (c not in (coalesce((select max(d) from t1 where (select min(t1.e) from t1)-17<=coalesce((select t1.c from t1 where exists(select 1 from t1 where 17<19 or coalesce((select 13 from t1 where t1.e not in (a+t1.c,t1.e*t1.a+t1.d* -a*(a)*f,((b)))),19) not in (c,t1.f,t1.b))),(select abs( -max(19)) from t1))),t1.f)-t1.b, -f,17))}
+} {}
+do_test randexpr-2.813 {
+ db eval {SELECT t1.c*case when (t1.f in (select case (coalesce((select t1.d from t1 where not (coalesce((select d from t1 where f<=(11)),19)*e in (select ((min((17)) | -min(t1.b))) from t1 union select -cast(avg(t1.f) AS integer) from t1))),19)+11)*t1.a when t1.d then t1.a else f end-e-t1.a*( -17) from t1 union select c from t1) or 13 not between t1.e and b) then d+19-t1.f else t1.c end-e FROM t1 WHERE t1.f in (~t1.b,13,+e) and 11<>d-case when t1.e<>t1.b or f>t1.f and 19 not between 17 and case when (b not in (b,t1.d,a)) then e else (abs(11)/abs(d)) end and not exists(select 1 from t1 where t1.a<>c) then t1.f when not (t1.b) in (select t1.d from t1 union select t1.c from t1) then 13 else t1.b+a end}
+} {}
+do_test randexpr-2.814 {
+ db eval {SELECT t1.c*case when (t1.f in (select case (coalesce((select t1.d from t1 where not (coalesce((select d from t1 where f<=(11)),19)*e in (select ((min((17)) | -min(t1.b))) from t1 union select -cast(avg(t1.f) AS integer) from t1))),19)+11)*t1.a when t1.d then t1.a else f end-e-t1.a*( -17) from t1 union select c from t1) or 13 not between t1.e and b) then d+19-t1.f else t1.c end-e FROM t1 WHERE NOT (t1.f in (~t1.b,13,+e) and 11<>d-case when t1.e<>t1.b or f>t1.f and 19 not between 17 and case when (b not in (b,t1.d,a)) then e else (abs(11)/abs(d)) end and not exists(select 1 from t1 where t1.a<>c) then t1.f when not (t1.b) in (select t1.d from t1 union select t1.c from t1) then 13 else t1.b+a end)}
+} {-54800}
+do_test randexpr-2.815 {
+ db eval {SELECT t1.c*case when (t1.f in (select case (coalesce((select t1.d from t1 where not (coalesce((select d from t1 where f<=(11)),19)*e in (select ((min((17)) & -min(t1.b))) from t1 union select -cast(avg(t1.f) AS integer) from t1))),19)+11)*t1.a when t1.d then t1.a else f end-e-t1.a*( -17) from t1 union select c from t1) or 13 not between t1.e and b) then d+19-t1.f else t1.c end-e FROM t1 WHERE NOT (t1.f in (~t1.b,13,+e) and 11<>d-case when t1.e<>t1.b or f>t1.f and 19 not between 17 and case when (b not in (b,t1.d,a)) then e else (abs(11)/abs(d)) end and not exists(select 1 from t1 where t1.a<>c) then t1.f when not (t1.b) in (select t1.d from t1 union select t1.c from t1) then 13 else t1.b+a end)}
+} {-54800}
+do_test randexpr-2.816 {
+ db eval {SELECT e-t1.e+a*f*11*c*case when ~f*t1.d-t1.c*b-13*19+(abs(t1.d)/abs(case when t1.c=13 then 17 else 19 end))*a between b*(select abs(cast(avg(( -13)) AS integer)) from t1)-19+19 and t1.b then t1.d else t1.d end+13 FROM t1 WHERE t1.b not between a and e}
+} {}
+do_test randexpr-2.817 {
+ db eval {SELECT e-t1.e+a*f*11*c*case when ~f*t1.d-t1.c*b-13*19+(abs(t1.d)/abs(case when t1.c=13 then 17 else 19 end))*a between b*(select abs(cast(avg(( -13)) AS integer)) from t1)-19+19 and t1.b then t1.d else t1.d end+13 FROM t1 WHERE NOT (t1.b not between a and e)}
+} {79200000013}
+do_test randexpr-2.818 {
+ db eval {SELECT case case when coalesce((select b from t1 where not exists(select 1 from t1 where d-e+coalesce((select max(b) from t1 where case case when t1.d-t1.e not between t1.f and e then 11 else t1.d end when t1.e then f else b end+t1.e=13),t1.c) not in (( -c),c,t1.d))),t1.f)<>a and c not in (t1.b,c,t1.a) then (select count(*) from t1) else c end-11 when t1.d then t1.e else c end FROM t1 WHERE ~b | coalesce((select case (select +count(distinct b) from t1) when coalesce((select case when coalesce((select e from t1 where c>b),t1.c) between 11 and (b) then t1.d else t1.b end-e from t1 where t1.d in (13,t1.a,f)),17) then e else 17 end from t1 where not b=t1.c or t1.d in (select abs(abs( -min(13)*(cast(avg(t1.c) AS integer)))) from t1 union select (max(c)) from t1) and b>t1.a),t1.f) in (select 11 from t1 union select c from t1)}
+} {}
+do_test randexpr-2.819 {
+ db eval {SELECT case case when coalesce((select b from t1 where not exists(select 1 from t1 where d-e+coalesce((select max(b) from t1 where case case when t1.d-t1.e not between t1.f and e then 11 else t1.d end when t1.e then f else b end+t1.e=13),t1.c) not in (( -c),c,t1.d))),t1.f)<>a and c not in (t1.b,c,t1.a) then (select count(*) from t1) else c end-11 when t1.d then t1.e else c end FROM t1 WHERE NOT (~b | coalesce((select case (select +count(distinct b) from t1) when coalesce((select case when coalesce((select e from t1 where c>b),t1.c) between 11 and (b) then t1.d else t1.b end-e from t1 where t1.d in (13,t1.a,f)),17) then e else 17 end from t1 where not b=t1.c or t1.d in (select abs(abs( -min(13)*(cast(avg(t1.c) AS integer)))) from t1 union select (max(c)) from t1) and b>t1.a),t1.f) in (select 11 from t1 union select c from t1))}
+} {300}
+do_test randexpr-2.820 {
+ db eval {SELECT case t1.c when t1.e then 19 else -case when not exists(select 1 from t1 where t1.b in (select (t1.b) from t1 union select +13 from t1)) then coalesce((select max(c*t1.b) from t1 where 17>=19*e),coalesce((select (select abs(~min(coalesce((select max(t1.a) from t1 where -19 in (f,a,13)),f)))+min(e) | ( -(min(13))) from t1) from t1 where f between -a and t1.c),t1.e)) when 19<>a then 13 else c end end FROM t1 WHERE t1.e<>f}
+} {-13}
+do_test randexpr-2.821 {
+ db eval {SELECT case t1.c when t1.e then 19 else -case when not exists(select 1 from t1 where t1.b in (select (t1.b) from t1 union select +13 from t1)) then coalesce((select max(c*t1.b) from t1 where 17>=19*e),coalesce((select (select abs(~min(coalesce((select max(t1.a) from t1 where -19 in (f,a,13)),f)))+min(e) | ( -(min(13))) from t1) from t1 where f between -a and t1.c),t1.e)) when 19<>a then 13 else c end end FROM t1 WHERE NOT (t1.e<>f)}
+} {}
+do_test randexpr-2.822 {
+ db eval {SELECT case t1.c when t1.e then 19 else -case when not exists(select 1 from t1 where t1.b in (select (t1.b) from t1 union select +13 from t1)) then coalesce((select max(c*t1.b) from t1 where 17>=19*e),coalesce((select (select abs(~min(coalesce((select max(t1.a) from t1 where -19 in (f,a,13)),f)))+min(e) & ( -(min(13))) from t1) from t1 where f between -a and t1.c),t1.e)) when 19<>a then 13 else c end end FROM t1 WHERE t1.e<>f}
+} {-13}
+do_test randexpr-2.823 {
+ db eval {SELECT 13- -(abs(coalesce((select max(17) from t1 where f*b in (select count(*)*case -min(~t1.f)+min(coalesce((select -(select min(17) from t1) from t1 where (t1.b in (select abs(min(t1.f)) from t1 union select -max(t1.e) from t1))),17)+d) when count(distinct a) then abs(count(*)) else count(*) end from t1 union select min(t1.c) from t1)),coalesce((select max(f) from t1 where d in (select t1.b from t1 union select t1.e from t1)),17)) | t1.a)/abs(c)) | t1.f FROM t1 WHERE (abs(t1.f*11++ -f)/abs(19 | (abs(((abs(f)/abs(17))))/abs(case when a not in (t1.d,(c)-~c*f | -13-t1.b+ -d,13) then t1.f when 11=11 then c else d end))*d+t1.c))+e+ -(t1.d) in (select t1.a from t1 union select 19 from t1)}
+} {}
+do_test randexpr-2.824 {
+ db eval {SELECT 13- -(abs(coalesce((select max(17) from t1 where f*b in (select count(*)*case -min(~t1.f)+min(coalesce((select -(select min(17) from t1) from t1 where (t1.b in (select abs(min(t1.f)) from t1 union select -max(t1.e) from t1))),17)+d) when count(distinct a) then abs(count(*)) else count(*) end from t1 union select min(t1.c) from t1)),coalesce((select max(f) from t1 where d in (select t1.b from t1 union select t1.e from t1)),17)) | t1.a)/abs(c)) | t1.f FROM t1 WHERE NOT ((abs(t1.f*11++ -f)/abs(19 | (abs(((abs(f)/abs(17))))/abs(case when a not in (t1.d,(c)-~c*f | -13-t1.b+ -d,13) then t1.f when 11=11 then c else d end))*d+t1.c))+e+ -(t1.d) in (select t1.a from t1 union select 19 from t1))}
+} {605}
+do_test randexpr-2.825 {
+ db eval {SELECT 13- -(abs(coalesce((select max(17) from t1 where f*b in (select count(*)*case -min(~t1.f)+min(coalesce((select -(select min(17) from t1) from t1 where (t1.b in (select abs(min(t1.f)) from t1 union select -max(t1.e) from t1))),17)+d) when count(distinct a) then abs(count(*)) else count(*) end from t1 union select min(t1.c) from t1)),coalesce((select max(f) from t1 where d in (select t1.b from t1 union select t1.e from t1)),17)) & t1.a)/abs(c)) & t1.f FROM t1 WHERE NOT ((abs(t1.f*11++ -f)/abs(19 | (abs(((abs(f)/abs(17))))/abs(case when a not in (t1.d,(c)-~c*f | -13-t1.b+ -d,13) then t1.f when 11=11 then c else d end))*d+t1.c))+e+ -(t1.d) in (select t1.a from t1 union select 19 from t1))}
+} {8}
+do_test randexpr-2.826 {
+ db eval {SELECT (a+case when (exists(select 1 from t1 where not exists(select 1 from t1 where not t1.e*13=13-f or (e)=t1.c or -d not between t1.b and t1.a or e not between 17 and (a) and 11 not in (a,(t1.f),a) or t1.e<>13 or t1.d between t1.e and t1.c or t1.d=17 or a>=b))) and a between t1.e and t1.b then case when e not between (17) and t1.d then ~c*coalesce((select t1.a | 13+d from t1 where t1.e not between b and 11),t1.a) else t1.f end else t1.f end-11) FROM t1 WHERE case when case case when case when -(select +min(11) from t1)*(13)>11 then t1.e when 13<e then 19 else c end in (t1.a,a,t1.e) then 17 when c<>t1.a then t1.d else -t1.e end when (a) then a else t1.e end>t1.a then 13 when t1.a not in (t1.f,t1.b,t1.a) then a else t1.c end in (select cast(avg(13) AS integer) from t1 union select (max(t1.e)+min(17)) from t1)}
+} {689}
+do_test randexpr-2.827 {
+ db eval {SELECT (a+case when (exists(select 1 from t1 where not exists(select 1 from t1 where not t1.e*13=13-f or (e)=t1.c or -d not between t1.b and t1.a or e not between 17 and (a) and 11 not in (a,(t1.f),a) or t1.e<>13 or t1.d between t1.e and t1.c or t1.d=17 or a>=b))) and a between t1.e and t1.b then case when e not between (17) and t1.d then ~c*coalesce((select t1.a | 13+d from t1 where t1.e not between b and 11),t1.a) else t1.f end else t1.f end-11) FROM t1 WHERE NOT (case when case case when case when -(select +min(11) from t1)*(13)>11 then t1.e when 13<e then 19 else c end in (t1.a,a,t1.e) then 17 when c<>t1.a then t1.d else -t1.e end when (a) then a else t1.e end>t1.a then 13 when t1.a not in (t1.f,t1.b,t1.a) then a else t1.c end in (select cast(avg(13) AS integer) from t1 union select (max(t1.e)+min(17)) from t1))}
+} {}
+do_test randexpr-2.828 {
+ db eval {SELECT (a+case when (exists(select 1 from t1 where not exists(select 1 from t1 where not t1.e*13=13-f or (e)=t1.c or -d not between t1.b and t1.a or e not between 17 and (a) and 11 not in (a,(t1.f),a) or t1.e<>13 or t1.d between t1.e and t1.c or t1.d=17 or a>=b))) and a between t1.e and t1.b then case when e not between (17) and t1.d then ~c*coalesce((select t1.a & 13+d from t1 where t1.e not between b and 11),t1.a) else t1.f end else t1.f end-11) FROM t1 WHERE case when case case when case when -(select +min(11) from t1)*(13)>11 then t1.e when 13<e then 19 else c end in (t1.a,a,t1.e) then 17 when c<>t1.a then t1.d else -t1.e end when (a) then a else t1.e end>t1.a then 13 when t1.a not in (t1.f,t1.b,t1.a) then a else t1.c end in (select cast(avg(13) AS integer) from t1 union select (max(t1.e)+min(17)) from t1)}
+} {689}
+do_test randexpr-2.829 {
+ db eval {SELECT ~b-t1.a-f*+case when exists(select 1 from t1 where 17<>t1.d-f or not exists(select 1 from t1 where (select (min(a)+count(distinct d)) from t1)+( -f)- -c<t1.e or d not between t1.a and b and exists(select 1 from t1 where 11<(a)) and 13=d or 13 between (t1.f) and f)) then t1.b when a not in (e,d,d) then (select ((count(*))) from t1) else case d when d then -e else 11 end end FROM t1 WHERE ~(abs(17)/abs((a)))*~t1.e-coalesce((select (abs((select abs(cast(avg(d) AS integer)) from t1) | 13*e+17)/abs(t1.f)) from t1 where t1.c<>f and not exists(select 1 from t1 where t1.c<b or 19 in (17,19,b) or 17 not between a and f) or a not in (c,b,17)),t1.c)+t1.a-e-t1.f*e+ -a-t1.a*d not in (d,( -f),t1.a)}
+} {-120301}
+do_test randexpr-2.830 {
+ db eval {SELECT ~b-t1.a-f*+case when exists(select 1 from t1 where 17<>t1.d-f or not exists(select 1 from t1 where (select (min(a)+count(distinct d)) from t1)+( -f)- -c<t1.e or d not between t1.a and b and exists(select 1 from t1 where 11<(a)) and 13=d or 13 between (t1.f) and f)) then t1.b when a not in (e,d,d) then (select ((count(*))) from t1) else case d when d then -e else 11 end end FROM t1 WHERE NOT (~(abs(17)/abs((a)))*~t1.e-coalesce((select (abs((select abs(cast(avg(d) AS integer)) from t1) | 13*e+17)/abs(t1.f)) from t1 where t1.c<>f and not exists(select 1 from t1 where t1.c<b or 19 in (17,19,b) or 17 not between a and f) or a not in (c,b,17)),t1.c)+t1.a-e-t1.f*e+ -a-t1.a*d not in (d,( -f),t1.a))}
+} {}
+do_test randexpr-2.831 {
+ db eval {SELECT (t1.a)*t1.d*t1.c+t1.b*case when (select case count(*) when (count(*))+ - -count(*)+cast(avg(t1.d) AS integer)- - -min(f) then min(11) else cast(avg(c) AS integer) end from t1) in (select (cast(avg((19)) AS integer)) from t1 union select max(t1.e) from t1) then b when d=a then t1.f else coalesce((select t1.c from t1 where not exists(select 1 from t1 where (~+a not in ((a),b,t1.f)))),case e when 13 then t1.f else 13 end) end FROM t1 WHERE c | a | ~(t1.d)+t1.b not in (t1.a* -+13+~(abs( -case when (11) in (select e from t1 union select t1.f*coalesce((select case when e<e then t1.f when (13) in (13,t1.d,t1.c) then c else t1.d end from t1 where t1.b between -11 and e),e) from t1) then t1.a else d end*t1.a)/abs(t1.e)),19,d) or t1.e<b}
+} {12002600}
+do_test randexpr-2.832 {
+ db eval {SELECT (t1.a)*t1.d*t1.c+t1.b*case when (select case count(*) when (count(*))+ - -count(*)+cast(avg(t1.d) AS integer)- - -min(f) then min(11) else cast(avg(c) AS integer) end from t1) in (select (cast(avg((19)) AS integer)) from t1 union select max(t1.e) from t1) then b when d=a then t1.f else coalesce((select t1.c from t1 where not exists(select 1 from t1 where (~+a not in ((a),b,t1.f)))),case e when 13 then t1.f else 13 end) end FROM t1 WHERE NOT (c | a | ~(t1.d)+t1.b not in (t1.a* -+13+~(abs( -case when (11) in (select e from t1 union select t1.f*coalesce((select case when e<e then t1.f when (13) in (13,t1.d,t1.c) then c else t1.d end from t1 where t1.b between -11 and e),e) from t1) then t1.a else d end*t1.a)/abs(t1.e)),19,d) or t1.e<b)}
+} {}
+do_test randexpr-2.833 {
+ db eval {SELECT case when case ~( -t1.e)-a when coalesce((select max(case +t1.e when t1.b*~19 | t1.a*case when c-c<>19 then 13 else c end*d+t1.c then f else 17 end) from t1 where d<=e), -d) then 19 else 17 end in (t1.b,19,c) then 19 when t1.a in (select a from t1 union select 13 from t1) then t1.d else t1.d end FROM t1 WHERE (select abs(cast(avg(t1.d*t1.f) AS integer))-cast(avg(b) AS integer) from t1)-~coalesce((select max(t1.a+t1.d-coalesce((select max(a*case when t1.e<=e then f when t1.d<>a then 11 else 11 end*t1.a*11) from t1 where t1.d>=d),t1.f)) from t1 where 11 not between (13) and 17),f)*t1.b+17-e not in (t1.d,t1.f,t1.f)}
+} {400}
+do_test randexpr-2.834 {
+ db eval {SELECT case when case ~( -t1.e)-a when coalesce((select max(case +t1.e when t1.b*~19 | t1.a*case when c-c<>19 then 13 else c end*d+t1.c then f else 17 end) from t1 where d<=e), -d) then 19 else 17 end in (t1.b,19,c) then 19 when t1.a in (select a from t1 union select 13 from t1) then t1.d else t1.d end FROM t1 WHERE NOT ((select abs(cast(avg(t1.d*t1.f) AS integer))-cast(avg(b) AS integer) from t1)-~coalesce((select max(t1.a+t1.d-coalesce((select max(a*case when t1.e<=e then f when t1.d<>a then 11 else 11 end*t1.a*11) from t1 where t1.d>=d),t1.f)) from t1 where 11 not between (13) and 17),f)*t1.b+17-e not in (t1.d,t1.f,t1.f))}
+} {}
+do_test randexpr-2.835 {
+ db eval {SELECT case when case ~( -t1.e)-a when coalesce((select max(case +t1.e when t1.b*~19 & t1.a*case when c-c<>19 then 13 else c end*d+t1.c then f else 17 end) from t1 where d<=e), -d) then 19 else 17 end in (t1.b,19,c) then 19 when t1.a in (select a from t1 union select 13 from t1) then t1.d else t1.d end FROM t1 WHERE (select abs(cast(avg(t1.d*t1.f) AS integer))-cast(avg(b) AS integer) from t1)-~coalesce((select max(t1.a+t1.d-coalesce((select max(a*case when t1.e<=e then f when t1.d<>a then 11 else 11 end*t1.a*11) from t1 where t1.d>=d),t1.f)) from t1 where 11 not between (13) and 17),f)*t1.b+17-e not in (t1.d,t1.f,t1.f)}
+} {400}
+do_test randexpr-2.836 {
+ db eval {SELECT t1.d+case when case when case when (19 not between ~(t1.a)*b and t1.c) then (select (abs(case count(distinct t1.e) when min( -f) then -max(t1.d) else cast(avg(19) AS integer) end-(count(distinct t1.e)))) from t1) when a<>t1.f then -19 else 11 end>f or b in ((13),f,11) then t1.a when t1.e in (e,f,t1.f) then (t1.d) else t1.d end in (17,t1.c,17) then 13 when b not between t1.a and (19) then t1.e else -11 end+a+((f)) FROM t1 WHERE t1.f in (select case +cast(avg(t1.f+c) AS integer)++count(*) when count(*) then ~~(count(distinct 11+t1.a)) else +(case max(e-f) | ~ -max(t1.f) | -abs(abs(min(e-19+e))-abs(count(*)))-abs(cast(avg(f) AS integer)) when (min(f)) then cast(avg(a) AS integer) else min(13) end) end from t1 union select -count(distinct 13) from t1)}
+} {}
+do_test randexpr-2.837 {
+ db eval {SELECT t1.d+case when case when case when (19 not between ~(t1.a)*b and t1.c) then (select (abs(case count(distinct t1.e) when min( -f) then -max(t1.d) else cast(avg(19) AS integer) end-(count(distinct t1.e)))) from t1) when a<>t1.f then -19 else 11 end>f or b in ((13),f,11) then t1.a when t1.e in (e,f,t1.f) then (t1.d) else t1.d end in (17,t1.c,17) then 13 when b not between t1.a and (19) then t1.e else -11 end+a+((f)) FROM t1 WHERE NOT (t1.f in (select case +cast(avg(t1.f+c) AS integer)++count(*) when count(*) then ~~(count(distinct 11+t1.a)) else +(case max(e-f) | ~ -max(t1.f) | -abs(abs(min(e-19+e))-abs(count(*)))-abs(cast(avg(f) AS integer)) when (min(f)) then cast(avg(a) AS integer) else min(13) end) end from t1 union select -count(distinct 13) from t1))}
+} {1600}
+do_test randexpr-2.838 {
+ db eval {SELECT (select (min(case when b+b*(select cast(avg(e+19-t1.f*case when case when not (c) in (select (e) from t1 union select f from t1) or t1.b not in (t1.e,t1.b,11) or 19= -t1.a then 17 else -d end<e then e when t1.b>13 then 13 else t1.f end+11*19) AS integer) from t1)+d not between 11 and c then t1.c else t1.c end)) from t1) FROM t1 WHERE 13 not between +b* -f and coalesce((select f*19-case when not a=~f+t1.d then case when d*b not in (case when d not between -c and t1.d then e else 13 end+17,c,t1.a) then b when t1.e>t1.f then b else -d end else f end-e+(d) from t1 where 17 between t1.a and t1.e),t1.d) | t1.b}
+} {}
+do_test randexpr-2.839 {
+ db eval {SELECT (select (min(case when b+b*(select cast(avg(e+19-t1.f*case when case when not (c) in (select (e) from t1 union select f from t1) or t1.b not in (t1.e,t1.b,11) or 19= -t1.a then 17 else -d end<e then e when t1.b>13 then 13 else t1.f end+11*19) AS integer) from t1)+d not between 11 and c then t1.c else t1.c end)) from t1) FROM t1 WHERE NOT (13 not between +b* -f and coalesce((select f*19-case when not a=~f+t1.d then case when d*b not in (case when d not between -c and t1.d then e else 13 end+17,c,t1.a) then b when t1.e>t1.f then b else -d end else f end-e+(d) from t1 where 17 between t1.a and t1.e),t1.d) | t1.b)}
+} {300}
+do_test randexpr-2.840 {
+ db eval {SELECT t1.c-(abs((select (case abs(count(distinct 11-c*11)) when count(*) then count(*) else -min(+e+~e+coalesce((select d-a*t1.d+t1.e from t1 where (t1.f>=17) and t1.e in (11,a,e)),13)*t1.d) end) from t1)-(a-t1.f)-t1.d)/abs(d)) FROM t1 WHERE t1.c in (select d from t1 union select ( -t1.e) from t1)}
+} {}
+do_test randexpr-2.841 {
+ db eval {SELECT t1.c-(abs((select (case abs(count(distinct 11-c*11)) when count(*) then count(*) else -min(+e+~e+coalesce((select d-a*t1.d+t1.e from t1 where (t1.f>=17) and t1.e in (11,a,e)),13)*t1.d) end) from t1)-(a-t1.f)-t1.d)/abs(d)) FROM t1 WHERE NOT (t1.c in (select d from t1 union select ( -t1.e) from t1))}
+} {300}
+do_test randexpr-2.842 {
+ db eval {SELECT case when coalesce((select max(t1.a-case when not (coalesce((select d+c from t1 where c between ( -(a)) and b or 17 between 11 and (c)),(t1.f)))=f then b | d when f not in (t1.b,f,a) then t1.a else f end-t1.f) from t1 where 19<=11 and t1.c between 19 and t1.a or t1.f>11), -t1.e)*e between b and 17 then -t1.f when -a<=19 or -11<>t1.f then -19 else d end FROM t1 WHERE ((13 in (t1.b,f,b)))}
+} {}
+do_test randexpr-2.843 {
+ db eval {SELECT case when coalesce((select max(t1.a-case when not (coalesce((select d+c from t1 where c between ( -(a)) and b or 17 between 11 and (c)),(t1.f)))=f then b | d when f not in (t1.b,f,a) then t1.a else f end-t1.f) from t1 where 19<=11 and t1.c between 19 and t1.a or t1.f>11), -t1.e)*e between b and 17 then -t1.f when -a<=19 or -11<>t1.f then -19 else d end FROM t1 WHERE NOT (((13 in (t1.b,f,b))))}
+} {-19}
+do_test randexpr-2.844 {
+ db eval {SELECT case when coalesce((select max(t1.a-case when not (coalesce((select d+c from t1 where c between ( -(a)) and b or 17 between 11 and (c)),(t1.f)))=f then b & d when f not in (t1.b,f,a) then t1.a else f end-t1.f) from t1 where 19<=11 and t1.c between 19 and t1.a or t1.f>11), -t1.e)*e between b and 17 then -t1.f when -a<=19 or -11<>t1.f then -19 else d end FROM t1 WHERE NOT (((13 in (t1.b,f,b))))}
+} {-19}
+do_test randexpr-2.845 {
+ db eval {SELECT case -(abs(t1.b-13*d*b*t1.e- -11)/abs(+d-t1.f*(11+ -13)-t1.c))+c+(e*t1.c)+f*17*a | t1.e-13+f when t1.d then t1.e else f end-t1.f FROM t1 WHERE -b*t1.c>13}
+} {}
+do_test randexpr-2.846 {
+ db eval {SELECT case -(abs(t1.b-13*d*b*t1.e- -11)/abs(+d-t1.f*(11+ -13)-t1.c))+c+(e*t1.c)+f*17*a | t1.e-13+f when t1.d then t1.e else f end-t1.f FROM t1 WHERE NOT ( -b*t1.c>13)}
+} {0}
+do_test randexpr-2.847 {
+ db eval {SELECT case -(abs(t1.b-13*d*b*t1.e- -11)/abs(+d-t1.f*(11+ -13)-t1.c))+c+(e*t1.c)+f*17*a & t1.e-13+f when t1.d then t1.e else f end-t1.f FROM t1 WHERE NOT ( -b*t1.c>13)}
+} {0}
+do_test randexpr-2.848 {
+ db eval {SELECT case when t1.c between t1.e and ~t1.d+(abs(~d*case t1.b-19 when t1.e then e else e end)/abs(case case t1.b when c then t1.d else 13+17 | e end when (select abs(abs(min(11) | max((a)))) from t1) then d else ~t1.f end)) | t1.b then t1.c when (not (11>=b)) then 13 else e end-a FROM t1 WHERE +13*case when +11*t1.f=f+t1.b then t1.f else t1.b end not between coalesce((select max(f) from t1 where (not exists(select 1 from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where t1.c in (select abs(min(e)) from t1 union select ~ -case cast(avg(~17) AS integer) when min(e | 17) then min(e) else cast(avg(c) AS integer) end from t1)))) or f>e*t1.a+e)),t1.c) and 17}
+} {-87}
+do_test randexpr-2.849 {
+ db eval {SELECT case when t1.c between t1.e and ~t1.d+(abs(~d*case t1.b-19 when t1.e then e else e end)/abs(case case t1.b when c then t1.d else 13+17 | e end when (select abs(abs(min(11) | max((a)))) from t1) then d else ~t1.f end)) | t1.b then t1.c when (not (11>=b)) then 13 else e end-a FROM t1 WHERE NOT (+13*case when +11*t1.f=f+t1.b then t1.f else t1.b end not between coalesce((select max(f) from t1 where (not exists(select 1 from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where t1.c in (select abs(min(e)) from t1 union select ~ -case cast(avg(~17) AS integer) when min(e | 17) then min(e) else cast(avg(c) AS integer) end from t1)))) or f>e*t1.a+e)),t1.c) and 17)}
+} {}
+do_test randexpr-2.850 {
+ db eval {SELECT case when t1.c between t1.e and ~t1.d+(abs(~d*case t1.b-19 when t1.e then e else e end)/abs(case case t1.b when c then t1.d else 13+17 & e end when (select abs(abs(min(11) & max((a)))) from t1) then d else ~t1.f end)) & t1.b then t1.c when (not (11>=b)) then 13 else e end-a FROM t1 WHERE +13*case when +11*t1.f=f+t1.b then t1.f else t1.b end not between coalesce((select max(f) from t1 where (not exists(select 1 from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where t1.c in (select abs(min(e)) from t1 union select ~ -case cast(avg(~17) AS integer) when min(e | 17) then min(e) else cast(avg(c) AS integer) end from t1)))) or f>e*t1.a+e)),t1.c) and 17}
+} {-87}
+do_test randexpr-2.851 {
+ db eval {SELECT coalesce((select +case when case d when b then e else (select min(case b when 17 then b else t1.c end)+ -+ -(abs(max(t1.e))-min(t1.d)+max( -d)) | count(distinct t1.e)+( -cast(avg(13) AS integer)) | max(t1.f)+min(e)+count(*) from t1) end<>b then t1.a else 19*~t1.e-c | t1.c end from t1 where b in ( -c,t1.f,t1.c)),19) FROM t1 WHERE (abs(d)/abs(coalesce((select max(coalesce((select d*c from t1 where ((abs(t1.b)/abs(t1.d))-(abs(t1.f)/abs(t1.c))+(t1.a)*13-t1.e not between t1.e and ~f*11+t1.f-11 | t1.a+13+d)),19)) from t1 where c not in (+ -11,a,c)),t1.c))) in (b,b,a)}
+} {}
+do_test randexpr-2.852 {
+ db eval {SELECT coalesce((select +case when case d when b then e else (select min(case b when 17 then b else t1.c end)+ -+ -(abs(max(t1.e))-min(t1.d)+max( -d)) | count(distinct t1.e)+( -cast(avg(13) AS integer)) | max(t1.f)+min(e)+count(*) from t1) end<>b then t1.a else 19*~t1.e-c | t1.c end from t1 where b in ( -c,t1.f,t1.c)),19) FROM t1 WHERE NOT ((abs(d)/abs(coalesce((select max(coalesce((select d*c from t1 where ((abs(t1.b)/abs(t1.d))-(abs(t1.f)/abs(t1.c))+(t1.a)*13-t1.e not between t1.e and ~f*11+t1.f-11 | t1.a+13+d)),19)) from t1 where c not in (+ -11,a,c)),t1.c))) in (b,b,a))}
+} {19}
+do_test randexpr-2.853 {
+ db eval {SELECT coalesce((select +case when case d when b then e else (select min(case b when 17 then b else t1.c end)+ -+ -(abs(max(t1.e))-min(t1.d)+max( -d)) & count(distinct t1.e)+( -cast(avg(13) AS integer)) & max(t1.f)+min(e)+count(*) from t1) end<>b then t1.a else 19*~t1.e-c & t1.c end from t1 where b in ( -c,t1.f,t1.c)),19) FROM t1 WHERE NOT ((abs(d)/abs(coalesce((select max(coalesce((select d*c from t1 where ((abs(t1.b)/abs(t1.d))-(abs(t1.f)/abs(t1.c))+(t1.a)*13-t1.e not between t1.e and ~f*11+t1.f-11 | t1.a+13+d)),19)) from t1 where c not in (+ -11,a,c)),t1.c))) in (b,b,a))}
+} {19}
+do_test randexpr-2.854 {
+ db eval {SELECT a-a-(abs(f)/abs(coalesce((select 17+19 from t1 where (select min(t1.e*e) from t1)>t1.b+case when not exists(select 1 from t1 where e not between 11 and t1.f-e) then coalesce((select max(f*case when t1.f not in (19,t1.c,(t1.a)) and c<=17 then 11 when 17 not between 11 and 17 then c else 17 end) from t1 where d not between t1.a and 13),t1.c) else t1.b end-13 and a=t1.e),17)+t1.c))-f FROM t1 WHERE +(select cast(avg(13-t1.a-t1.b++t1.a-(select count(*) from t1)+case b-(select +~ -min(case when exists(select 1 from t1 where ((select count(*)+ -(min(13)) from t1)) not between 13 and 13) then d else e end) from t1) when f*t1.b*t1.b then t1.a else b end*t1.a) AS integer) from t1)*t1.b in (t1.f,17,f)}
+} {}
+do_test randexpr-2.855 {
+ db eval {SELECT a-a-(abs(f)/abs(coalesce((select 17+19 from t1 where (select min(t1.e*e) from t1)>t1.b+case when not exists(select 1 from t1 where e not between 11 and t1.f-e) then coalesce((select max(f*case when t1.f not in (19,t1.c,(t1.a)) and c<=17 then 11 when 17 not between 11 and 17 then c else 17 end) from t1 where d not between t1.a and 13),t1.c) else t1.b end-13 and a=t1.e),17)+t1.c))-f FROM t1 WHERE NOT (+(select cast(avg(13-t1.a-t1.b++t1.a-(select count(*) from t1)+case b-(select +~ -min(case when exists(select 1 from t1 where ((select count(*)+ -(min(13)) from t1)) not between 13 and 13) then d else e end) from t1) when f*t1.b*t1.b then t1.a else b end*t1.a) AS integer) from t1)*t1.b in (t1.f,17,f))}
+} {-601}
+do_test randexpr-2.856 {
+ db eval {SELECT case when (11+19 | t1.e-e*17=t1.e*~d+t1.a+ -d | a-~(abs((abs((case when 13 not in (b,((t1.a)),f) then t1.d else t1.a end+e))/abs(t1.f))*b+t1.b)/abs(17))+t1.e+t1.a) then 11 else t1.a end FROM t1 WHERE case (case when (select +~ -~ -cast(avg(b*e*case when t1.a between t1.c and a and d<13 then b else 19 end* -f*d) AS integer) | count(*)++~+min((11))*max(19)-min((b)) from t1) in (select 13 from t1 union select (select min(19) from t1) from t1) then t1.f+t1.d else 13 end-t1.e) when t1.e then t1.f else a end<e}
+} {100}
+do_test randexpr-2.857 {
+ db eval {SELECT case when (11+19 | t1.e-e*17=t1.e*~d+t1.a+ -d | a-~(abs((abs((case when 13 not in (b,((t1.a)),f) then t1.d else t1.a end+e))/abs(t1.f))*b+t1.b)/abs(17))+t1.e+t1.a) then 11 else t1.a end FROM t1 WHERE NOT (case (case when (select +~ -~ -cast(avg(b*e*case when t1.a between t1.c and a and d<13 then b else 19 end* -f*d) AS integer) | count(*)++~+min((11))*max(19)-min((b)) from t1) in (select 13 from t1 union select (select min(19) from t1) from t1) then t1.f+t1.d else 13 end-t1.e) when t1.e then t1.f else a end<e)}
+} {}
+do_test randexpr-2.858 {
+ db eval {SELECT case when (11+19 & t1.e-e*17=t1.e*~d+t1.a+ -d & a-~(abs((abs((case when 13 not in (b,((t1.a)),f) then t1.d else t1.a end+e))/abs(t1.f))*b+t1.b)/abs(17))+t1.e+t1.a) then 11 else t1.a end FROM t1 WHERE case (case when (select +~ -~ -cast(avg(b*e*case when t1.a between t1.c and a and d<13 then b else 19 end* -f*d) AS integer) | count(*)++~+min((11))*max(19)-min((b)) from t1) in (select 13 from t1 union select (select min(19) from t1) from t1) then t1.f+t1.d else 13 end-t1.e) when t1.e then t1.f else a end<e}
+} {100}
+do_test randexpr-2.859 {
+ db eval {SELECT coalesce((select max(+t1.a) from t1 where c in (select -max(d | coalesce((select max(t1.b) from t1 where (abs(case d when t1.f then t1.e else t1.c end-t1.f)/abs(13))<=11), -a)) | min(t1.c) | (max(f))++abs(case max(b) when (count(distinct e)) then count(*) else min(17) end) from t1 union select (min(19)) from t1) or not exists(select 1 from t1 where coalesce((select c from t1 where b in (select - - - -count(*) from t1 union select -min((a)) from t1)),13)<t1.d)),17) FROM t1 WHERE ~a in (select count(*) from t1 union select case +abs((abs(abs(count(*))))+min(a))*max(case when exists(select 1 from t1 where d between 17+(b)-a and 17) then (select count(*) from t1) when 13<> -t1.b then t1.f else t1.e end)*min(t1.a)+ -count(*) | +max(e)*(min(t1.e)) | count(distinct t1.d) | (count(*)) when count(distinct ((19))) then count(*) else max(t1.f) end from t1)}
+} {}
+do_test randexpr-2.860 {
+ db eval {SELECT coalesce((select max(+t1.a) from t1 where c in (select -max(d | coalesce((select max(t1.b) from t1 where (abs(case d when t1.f then t1.e else t1.c end-t1.f)/abs(13))<=11), -a)) | min(t1.c) | (max(f))++abs(case max(b) when (count(distinct e)) then count(*) else min(17) end) from t1 union select (min(19)) from t1) or not exists(select 1 from t1 where coalesce((select c from t1 where b in (select - - - -count(*) from t1 union select -min((a)) from t1)),13)<t1.d)),17) FROM t1 WHERE NOT (~a in (select count(*) from t1 union select case +abs((abs(abs(count(*))))+min(a))*max(case when exists(select 1 from t1 where d between 17+(b)-a and 17) then (select count(*) from t1) when 13<> -t1.b then t1.f else t1.e end)*min(t1.a)+ -count(*) | +max(e)*(min(t1.e)) | count(distinct t1.d) | (count(*)) when count(distinct ((19))) then count(*) else max(t1.f) end from t1))}
+} {17}
+do_test randexpr-2.861 {
+ db eval {SELECT coalesce((select max(+t1.a) from t1 where c in (select -max(d & coalesce((select max(t1.b) from t1 where (abs(case d when t1.f then t1.e else t1.c end-t1.f)/abs(13))<=11), -a)) & min(t1.c) & (max(f))++abs(case max(b) when (count(distinct e)) then count(*) else min(17) end) from t1 union select (min(19)) from t1) or not exists(select 1 from t1 where coalesce((select c from t1 where b in (select - - - -count(*) from t1 union select -min((a)) from t1)),13)<t1.d)),17) FROM t1 WHERE NOT (~a in (select count(*) from t1 union select case +abs((abs(abs(count(*))))+min(a))*max(case when exists(select 1 from t1 where d between 17+(b)-a and 17) then (select count(*) from t1) when 13<> -t1.b then t1.f else t1.e end)*min(t1.a)+ -count(*) | +max(e)*(min(t1.e)) | count(distinct t1.d) | (count(*)) when count(distinct ((19))) then count(*) else max(t1.f) end from t1))}
+} {17}
+do_test randexpr-2.862 {
+ db eval {SELECT case 17 when (select ~count(distinct t1.d) from t1) then e else case when not not exists(select 1 from t1 where (abs(~coalesce((select (coalesce((select max(13) from t1 where e>a),19)) from t1 where (not exists(select 1 from t1 where t1.c in (f,b,c)))),c)*t1.c | 17-(e))/abs(t1.f)) | 17*17*a in (select e from t1 union select f from t1)) then 13 when t1.a not between (b) and t1.c then (abs(17)/abs(17)) else t1.d end*f end FROM t1 WHERE t1.a>t1.c-19}
+} {}
+do_test randexpr-2.863 {
+ db eval {SELECT case 17 when (select ~count(distinct t1.d) from t1) then e else case when not not exists(select 1 from t1 where (abs(~coalesce((select (coalesce((select max(13) from t1 where e>a),19)) from t1 where (not exists(select 1 from t1 where t1.c in (f,b,c)))),c)*t1.c | 17-(e))/abs(t1.f)) | 17*17*a in (select e from t1 union select f from t1)) then 13 when t1.a not between (b) and t1.c then (abs(17)/abs(17)) else t1.d end*f end FROM t1 WHERE NOT (t1.a>t1.c-19)}
+} {600}
+do_test randexpr-2.864 {
+ db eval {SELECT case 17 when (select ~count(distinct t1.d) from t1) then e else case when not not exists(select 1 from t1 where (abs(~coalesce((select (coalesce((select max(13) from t1 where e>a),19)) from t1 where (not exists(select 1 from t1 where t1.c in (f,b,c)))),c)*t1.c & 17-(e))/abs(t1.f)) & 17*17*a in (select e from t1 union select f from t1)) then 13 when t1.a not between (b) and t1.c then (abs(17)/abs(17)) else t1.d end*f end FROM t1 WHERE NOT (t1.a>t1.c-19)}
+} {600}
+do_test randexpr-2.865 {
+ db eval {SELECT case when f>=t1.c then t1.d when coalesce((select max(+11-b) from t1 where a-t1.d in (select +case when f in (13,b | 11,t1.b) then -t1.d when f in (select ~count(distinct 17) from t1 union select count(distinct t1.a) from t1) then 19 else c end-d+b from t1 union select a from t1) and (17) in (t1.f,11,t1.c)),f)< -a then d else t1.c end-11 FROM t1 WHERE a<(select count(distinct +11*coalesce((select max(coalesce((select max(t1.d) from t1 where t1.e>t1.b),b)*t1.f) from t1 where case 11 when t1.a then -t1.e else a end<=17),e)-11+c-19) | count(distinct 19)*count(*)* -(count(distinct t1.f))+cast(avg(17) AS integer)-(~~(count(*)))-cast(avg(11) AS integer) | cast(avg((19)) AS integer) from t1)-t1.c}
+} {}
+do_test randexpr-2.866 {
+ db eval {SELECT case when f>=t1.c then t1.d when coalesce((select max(+11-b) from t1 where a-t1.d in (select +case when f in (13,b | 11,t1.b) then -t1.d when f in (select ~count(distinct 17) from t1 union select count(distinct t1.a) from t1) then 19 else c end-d+b from t1 union select a from t1) and (17) in (t1.f,11,t1.c)),f)< -a then d else t1.c end-11 FROM t1 WHERE NOT (a<(select count(distinct +11*coalesce((select max(coalesce((select max(t1.d) from t1 where t1.e>t1.b),b)*t1.f) from t1 where case 11 when t1.a then -t1.e else a end<=17),e)-11+c-19) | count(distinct 19)*count(*)* -(count(distinct t1.f))+cast(avg(17) AS integer)-(~~(count(*)))-cast(avg(11) AS integer) | cast(avg((19)) AS integer) from t1)-t1.c)}
+} {389}
+do_test randexpr-2.867 {
+ db eval {SELECT case when f>=t1.c then t1.d when coalesce((select max(+11-b) from t1 where a-t1.d in (select +case when f in (13,b & 11,t1.b) then -t1.d when f in (select ~count(distinct 17) from t1 union select count(distinct t1.a) from t1) then 19 else c end-d+b from t1 union select a from t1) and (17) in (t1.f,11,t1.c)),f)< -a then d else t1.c end-11 FROM t1 WHERE NOT (a<(select count(distinct +11*coalesce((select max(coalesce((select max(t1.d) from t1 where t1.e>t1.b),b)*t1.f) from t1 where case 11 when t1.a then -t1.e else a end<=17),e)-11+c-19) | count(distinct 19)*count(*)* -(count(distinct t1.f))+cast(avg(17) AS integer)-(~~(count(*)))-cast(avg(11) AS integer) | cast(avg((19)) AS integer) from t1)-t1.c)}
+} {389}
+do_test randexpr-2.868 {
+ db eval {SELECT coalesce((select max(17) from t1 where -coalesce((select t1.b+coalesce((select case when case t1.f when c then (e) else a end+t1.c+(f)>17 and e>=f and (13>t1.f) then (select ~(cast(avg(t1.e) AS integer)) | min(t1.a) from t1) when -c>c then 19 else t1.f end from t1 where (17<t1.f)),t1.f) from t1 where not exists(select 1 from t1 where 13 not between t1.a and c)),d)*17< -t1.c),b) FROM t1 WHERE not exists(select 1 from t1 where not exists(select 1 from t1 where -11=17*t1.d*f))}
+} {}
+do_test randexpr-2.869 {
+ db eval {SELECT coalesce((select max(17) from t1 where -coalesce((select t1.b+coalesce((select case when case t1.f when c then (e) else a end+t1.c+(f)>17 and e>=f and (13>t1.f) then (select ~(cast(avg(t1.e) AS integer)) | min(t1.a) from t1) when -c>c then 19 else t1.f end from t1 where (17<t1.f)),t1.f) from t1 where not exists(select 1 from t1 where 13 not between t1.a and c)),d)*17< -t1.c),b) FROM t1 WHERE NOT (not exists(select 1 from t1 where not exists(select 1 from t1 where -11=17*t1.d*f)))}
+} {17}
+do_test randexpr-2.870 {
+ db eval {SELECT coalesce((select max(17) from t1 where -coalesce((select t1.b+coalesce((select case when case t1.f when c then (e) else a end+t1.c+(f)>17 and e>=f and (13>t1.f) then (select ~(cast(avg(t1.e) AS integer)) & min(t1.a) from t1) when -c>c then 19 else t1.f end from t1 where (17<t1.f)),t1.f) from t1 where not exists(select 1 from t1 where 13 not between t1.a and c)),d)*17< -t1.c),b) FROM t1 WHERE NOT (not exists(select 1 from t1 where not exists(select 1 from t1 where -11=17*t1.d*f)))}
+} {17}
+do_test randexpr-2.871 {
+ db eval {SELECT case when a*t1.a*a in (select case (e- -11+case when ~c>=a then 13 when ((case when t1.d<t1.d then f when t1.c not between a and t1.e then -f else t1.f end>=a)) then 19 else t1.b end-t1.f) when 19 then - -13 else 17 end from t1 union select -17 from t1) and 19 in (select d from t1 union select e from t1) then (select abs(min(t1.f)) from t1) else c end FROM t1 WHERE case coalesce((select 19 from t1 where 13<coalesce((select 19 | case when t1.e>=e then d when (case when not exists(select 1 from t1 where (a>d and d not between e and ((19)) and c in (e,t1.b,(b)) and e not in (t1.f,t1.a,t1.b))) then t1.b when f not between 11 and d then t1.d else d end<=11) then (abs(13)/abs(11)) else -11 end from t1 where (t1.b)<d),b)),11) | d when c then 17 else (e) end not in (t1.e,t1.c,a)}
+} {}
+do_test randexpr-2.872 {
+ db eval {SELECT case when a*t1.a*a in (select case (e- -11+case when ~c>=a then 13 when ((case when t1.d<t1.d then f when t1.c not between a and t1.e then -f else t1.f end>=a)) then 19 else t1.b end-t1.f) when 19 then - -13 else 17 end from t1 union select -17 from t1) and 19 in (select d from t1 union select e from t1) then (select abs(min(t1.f)) from t1) else c end FROM t1 WHERE NOT (case coalesce((select 19 from t1 where 13<coalesce((select 19 | case when t1.e>=e then d when (case when not exists(select 1 from t1 where (a>d and d not between e and ((19)) and c in (e,t1.b,(b)) and e not in (t1.f,t1.a,t1.b))) then t1.b when f not between 11 and d then t1.d else d end<=11) then (abs(13)/abs(11)) else -11 end from t1 where (t1.b)<d),b)),11) | d when c then 17 else (e) end not in (t1.e,t1.c,a))}
+} {300}
+do_test randexpr-2.873 {
+ db eval {SELECT case when t1.e not between (select +max(17) from t1)*t1.f and d then t1.c+case when e+f<=coalesce((select max((19)) from t1 where t1.e not in ((abs( -17-17)/abs(t1.e)),(c),(t1.b))),d) and 13 in (select d from t1 union select c from t1) then 19 else c end-19 when exists(select 1 from t1 where t1.a in (select t1.a from t1 union select 13 from t1)) and not exists(select 1 from t1 where a<19) then b else t1.b end FROM t1 WHERE not t1.d=b}
+} {581}
+do_test randexpr-2.874 {
+ db eval {SELECT case when t1.e not between (select +max(17) from t1)*t1.f and d then t1.c+case when e+f<=coalesce((select max((19)) from t1 where t1.e not in ((abs( -17-17)/abs(t1.e)),(c),(t1.b))),d) and 13 in (select d from t1 union select c from t1) then 19 else c end-19 when exists(select 1 from t1 where t1.a in (select t1.a from t1 union select 13 from t1)) and not exists(select 1 from t1 where a<19) then b else t1.b end FROM t1 WHERE NOT (not t1.d=b)}
+} {}
+do_test randexpr-2.875 {
+ db eval {SELECT +17+(11)-coalesce((select max(case (11) when f then +e+case when +11< -13-f or b between (b) and t1.b and e<>t1.c and e not between 13 and t1.d and t1.e in (t1.d,17,t1.c) then c+t1.e*t1.d when t1.f>=t1.d then t1.a else t1.c end else t1.e end-e) from t1 where t1.b not in (t1.b,t1.d,d)), -c)*13 FROM t1 WHERE (abs(e+17)/abs((select count(distinct 11-t1.b)*cast(avg(case c when coalesce((select max(19-coalesce((select max(f) from t1 where 19 in (17,t1.f,11)),t1.d)) from t1 where c in (t1.a,11,13) and t1.a<=t1.c),t1.c) then t1.c else e end) AS integer) | max(e) | (+~case case cast(avg(t1.d) AS integer) when -min(13) then count(*) else count(*) end when max(t1.c) then count(distinct f) else count(*) end-count(distinct 19)) from t1)))>=t1.e | f}
+} {}
+do_test randexpr-2.876 {
+ db eval {SELECT +17+(11)-coalesce((select max(case (11) when f then +e+case when +11< -13-f or b between (b) and t1.b and e<>t1.c and e not between 13 and t1.d and t1.e in (t1.d,17,t1.c) then c+t1.e*t1.d when t1.f>=t1.d then t1.a else t1.c end else t1.e end-e) from t1 where t1.b not in (t1.b,t1.d,d)), -c)*13 FROM t1 WHERE NOT ((abs(e+17)/abs((select count(distinct 11-t1.b)*cast(avg(case c when coalesce((select max(19-coalesce((select max(f) from t1 where 19 in (17,t1.f,11)),t1.d)) from t1 where c in (t1.a,11,13) and t1.a<=t1.c),t1.c) then t1.c else e end) AS integer) | max(e) | (+~case case cast(avg(t1.d) AS integer) when -min(13) then count(*) else count(*) end when max(t1.c) then count(distinct f) else count(*) end-count(distinct 19)) from t1)))>=t1.e | f)}
+} {3928}
+do_test randexpr-2.877 {
+ db eval {SELECT case when case when d*c not in (13,a,d) then (t1.b-f)+coalesce((select max((select count(distinct 13)-case max(11) when count(*) then count(*) else min(t1.b) end*min(17)+(min(t1.c)) from t1)) from t1 where not exists(select 1 from t1 where t1.c between 17-d | d and t1.e)),b) else t1.e end<=d then e when f in (a,13,d) or t1.b between f and -b then c else t1.a end FROM t1 WHERE t1.d<>t1.a}
+} {500}
+do_test randexpr-2.878 {
+ db eval {SELECT case when case when d*c not in (13,a,d) then (t1.b-f)+coalesce((select max((select count(distinct 13)-case max(11) when count(*) then count(*) else min(t1.b) end*min(17)+(min(t1.c)) from t1)) from t1 where not exists(select 1 from t1 where t1.c between 17-d | d and t1.e)),b) else t1.e end<=d then e when f in (a,13,d) or t1.b between f and -b then c else t1.a end FROM t1 WHERE NOT (t1.d<>t1.a)}
+} {}
+do_test randexpr-2.879 {
+ db eval {SELECT case when case when d*c not in (13,a,d) then (t1.b-f)+coalesce((select max((select count(distinct 13)-case max(11) when count(*) then count(*) else min(t1.b) end*min(17)+(min(t1.c)) from t1)) from t1 where not exists(select 1 from t1 where t1.c between 17-d & d and t1.e)),b) else t1.e end<=d then e when f in (a,13,d) or t1.b between f and -b then c else t1.a end FROM t1 WHERE t1.d<>t1.a}
+} {500}
+do_test randexpr-2.880 {
+ db eval {SELECT case case c when -b then (abs(b)/abs(c)) else (select count(distinct f) | (~abs(min(c-+case 11 when case when t1.a between b and t1.e-case when (13<=b) then (select -count(*) from t1) else a end then t1.e when e>=11 then (19) else b end then d else 17 end | e))) from t1) end when -13 then t1.f else +17 end FROM t1 WHERE 17 in (select +(count(*) | case abs( -abs(abs( -min(d)))) | max(+11) when -+~count(distinct -(abs(coalesce((select max(f) from t1 where t1.e in (select e from t1 union select t1.a from t1)),f) | t1.c-t1.b)/abs(13))) | +abs(case max(b) when count(*) then -min(t1.e) else (cast(avg(t1.f) AS integer)) end)- -count(*) then -count(*) else max(19) end* -cast(avg(t1.b) AS integer))+(max(t1.f)) from t1 union select count(distinct b) from t1)}
+} {}
+do_test randexpr-2.881 {
+ db eval {SELECT case case c when -b then (abs(b)/abs(c)) else (select count(distinct f) | (~abs(min(c-+case 11 when case when t1.a between b and t1.e-case when (13<=b) then (select -count(*) from t1) else a end then t1.e when e>=11 then (19) else b end then d else 17 end | e))) from t1) end when -13 then t1.f else +17 end FROM t1 WHERE NOT (17 in (select +(count(*) | case abs( -abs(abs( -min(d)))) | max(+11) when -+~count(distinct -(abs(coalesce((select max(f) from t1 where t1.e in (select e from t1 union select t1.a from t1)),f) | t1.c-t1.b)/abs(13))) | +abs(case max(b) when count(*) then -min(t1.e) else (cast(avg(t1.f) AS integer)) end)- -count(*) then -count(*) else max(19) end* -cast(avg(t1.b) AS integer))+(max(t1.f)) from t1 union select count(distinct b) from t1))}
+} {17}
+do_test randexpr-2.882 {
+ db eval {SELECT case case c when -b then (abs(b)/abs(c)) else (select count(distinct f) & (~abs(min(c-+case 11 when case when t1.a between b and t1.e-case when (13<=b) then (select -count(*) from t1) else a end then t1.e when e>=11 then (19) else b end then d else 17 end & e))) from t1) end when -13 then t1.f else +17 end FROM t1 WHERE NOT (17 in (select +(count(*) | case abs( -abs(abs( -min(d)))) | max(+11) when -+~count(distinct -(abs(coalesce((select max(f) from t1 where t1.e in (select e from t1 union select t1.a from t1)),f) | t1.c-t1.b)/abs(13))) | +abs(case max(b) when count(*) then -min(t1.e) else (cast(avg(t1.f) AS integer)) end)- -count(*) then -count(*) else max(19) end* -cast(avg(t1.b) AS integer))+(max(t1.f)) from t1 union select count(distinct b) from t1))}
+} {17}
+do_test randexpr-2.883 {
+ db eval {SELECT case 11 when (case when t1.e in (select +cast(avg(coalesce((select max(13) from t1 where case when exists(select 1 from t1 where t1.b in ((a),d,(t1.e))) then case when 19 in (select -max(17) from t1 union select min(t1.f) from t1) then t1.b else 17 end when a not in ((t1.f),11,t1.e) then 17 else t1.c end<t1.b),11)*a) AS integer) from t1 union select max(b) | case (+min(t1.f)) when cast(avg(a) AS integer) then count(distinct 13) else max(t1.c) end from t1) then t1.e when c<=t1.d then t1.b else t1.f end-17) then b else t1.e end FROM t1 WHERE e-case when a*b between t1.d-(abs(11)/abs(coalesce((select t1.b from t1 where not exists(select 1 from t1 where c=17) or a not between (coalesce((select t1.c from t1 where 19>(19)),c)) and c and (11 in (select t1.b from t1 union select 13 from t1) and ( -t1.d)=d)),e | 19*t1.a))) and t1.a then t1.a when 19>=t1.a then e else c end> -e}
+} {500}
+do_test randexpr-2.884 {
+ db eval {SELECT case 11 when (case when t1.e in (select +cast(avg(coalesce((select max(13) from t1 where case when exists(select 1 from t1 where t1.b in ((a),d,(t1.e))) then case when 19 in (select -max(17) from t1 union select min(t1.f) from t1) then t1.b else 17 end when a not in ((t1.f),11,t1.e) then 17 else t1.c end<t1.b),11)*a) AS integer) from t1 union select max(b) | case (+min(t1.f)) when cast(avg(a) AS integer) then count(distinct 13) else max(t1.c) end from t1) then t1.e when c<=t1.d then t1.b else t1.f end-17) then b else t1.e end FROM t1 WHERE NOT (e-case when a*b between t1.d-(abs(11)/abs(coalesce((select t1.b from t1 where not exists(select 1 from t1 where c=17) or a not between (coalesce((select t1.c from t1 where 19>(19)),c)) and c and (11 in (select t1.b from t1 union select 13 from t1) and ( -t1.d)=d)),e | 19*t1.a))) and t1.a then t1.a when 19>=t1.a then e else c end> -e)}
+} {}
+do_test randexpr-2.885 {
+ db eval {SELECT case 11 when (case when t1.e in (select +cast(avg(coalesce((select max(13) from t1 where case when exists(select 1 from t1 where t1.b in ((a),d,(t1.e))) then case when 19 in (select -max(17) from t1 union select min(t1.f) from t1) then t1.b else 17 end when a not in ((t1.f),11,t1.e) then 17 else t1.c end<t1.b),11)*a) AS integer) from t1 union select max(b) & case (+min(t1.f)) when cast(avg(a) AS integer) then count(distinct 13) else max(t1.c) end from t1) then t1.e when c<=t1.d then t1.b else t1.f end-17) then b else t1.e end FROM t1 WHERE e-case when a*b between t1.d-(abs(11)/abs(coalesce((select t1.b from t1 where not exists(select 1 from t1 where c=17) or a not between (coalesce((select t1.c from t1 where 19>(19)),c)) and c and (11 in (select t1.b from t1 union select 13 from t1) and ( -t1.d)=d)),e | 19*t1.a))) and t1.a then t1.a when 19>=t1.a then e else c end> -e}
+} {500}
+do_test randexpr-2.886 {
+ db eval {SELECT case a*t1.a when ~++a*(abs(e)/abs(19)) | t1.d+(select count(*) from t1) then b else t1.a end*coalesce((select max(f) from t1 where f<>t1.d),b) FROM t1 WHERE (abs(c-~t1.b)/abs(d))-((+coalesce((select max(c) from t1 where -+(select ~ -(cast(avg((13+case 11*t1.c when t1.b then f else ~e-coalesce((select max((f)) from t1 where t1.f<a), -t1.c-(t1.c)) end)) AS integer)) from t1)=d*a),t1.d)+a))* -t1.e=t1.f}
+} {}
+do_test randexpr-2.887 {
+ db eval {SELECT case a*t1.a when ~++a*(abs(e)/abs(19)) | t1.d+(select count(*) from t1) then b else t1.a end*coalesce((select max(f) from t1 where f<>t1.d),b) FROM t1 WHERE NOT ((abs(c-~t1.b)/abs(d))-((+coalesce((select max(c) from t1 where -+(select ~ -(cast(avg((13+case 11*t1.c when t1.b then f else ~e-coalesce((select max((f)) from t1 where t1.f<a), -t1.c-(t1.c)) end)) AS integer)) from t1)=d*a),t1.d)+a))* -t1.e=t1.f)}
+} {60000}
+do_test randexpr-2.888 {
+ db eval {SELECT case a*t1.a when ~++a*(abs(e)/abs(19)) & t1.d+(select count(*) from t1) then b else t1.a end*coalesce((select max(f) from t1 where f<>t1.d),b) FROM t1 WHERE NOT ((abs(c-~t1.b)/abs(d))-((+coalesce((select max(c) from t1 where -+(select ~ -(cast(avg((13+case 11*t1.c when t1.b then f else ~e-coalesce((select max((f)) from t1 where t1.f<a), -t1.c-(t1.c)) end)) AS integer)) from t1)=d*a),t1.d)+a))* -t1.e=t1.f)}
+} {60000}
+do_test randexpr-2.889 {
+ db eval {SELECT t1.c-t1.f-coalesce((select max(a) from t1 where e in ((abs(a)/abs(t1.d))*coalesce((select max((abs(case when e>=+t1.b then f when t1.c+f<a or e<>13 then t1.d else t1.a end)/abs(t1.d))) from t1 where t1.c not between t1.c and 11 and e>d),f)*t1.e+d,a,13)),e) | t1.b FROM t1 WHERE (abs(+(+t1.a)+case a-case when c>=d then 13 when t1.c not in (17,17,e) then a else t1.d end when c then -f else b end*d)/abs(17))<=11 and 11 in (select cast(avg(17) AS integer) from t1 union select min( -19)+(case max(a) when abs(count(*)) then -abs(count(*)*min(t1.e)+max(11)) else min(c) end) from t1)}
+} {}
+do_test randexpr-2.890 {
+ db eval {SELECT t1.c-t1.f-coalesce((select max(a) from t1 where e in ((abs(a)/abs(t1.d))*coalesce((select max((abs(case when e>=+t1.b then f when t1.c+f<a or e<>13 then t1.d else t1.a end)/abs(t1.d))) from t1 where t1.c not between t1.c and 11 and e>d),f)*t1.e+d,a,13)),e) | t1.b FROM t1 WHERE NOT ((abs(+(+t1.a)+case a-case when c>=d then 13 when t1.c not in (17,17,e) then a else t1.d end when c then -f else b end*d)/abs(17))<=11 and 11 in (select cast(avg(17) AS integer) from t1 union select min( -19)+(case max(a) when abs(count(*)) then -abs(count(*)*min(t1.e)+max(11)) else min(c) end) from t1))}
+} {-792}
+do_test randexpr-2.891 {
+ db eval {SELECT t1.c-t1.f-coalesce((select max(a) from t1 where e in ((abs(a)/abs(t1.d))*coalesce((select max((abs(case when e>=+t1.b then f when t1.c+f<a or e<>13 then t1.d else t1.a end)/abs(t1.d))) from t1 where t1.c not between t1.c and 11 and e>d),f)*t1.e+d,a,13)),e) & t1.b FROM t1 WHERE NOT ((abs(+(+t1.a)+case a-case when c>=d then 13 when t1.c not in (17,17,e) then a else t1.d end when c then -f else b end*d)/abs(17))<=11 and 11 in (select cast(avg(17) AS integer) from t1 union select min( -19)+(case max(a) when abs(count(*)) then -abs(count(*)*min(t1.e)+max(11)) else min(c) end) from t1))}
+} {192}
+do_test randexpr-2.892 {
+ db eval {SELECT coalesce((select (select count(*) from t1)*a*b from t1 where ((~b*a-t1.d+11*e-(select -count(*) | count(*) | count(*) from t1)*(select min((abs(coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where -17 in (t1.b,t1.f,t1.d))),11))/abs(t1.d))) from t1)-17+(abs(11)/abs(11)) | b+d | 11 in (select t1.a from t1 union select 13 from t1)))),t1.a) FROM t1 WHERE f>case when f-case when not exists(select 1 from t1 where case when b in (select abs(max(coalesce((select max(~t1.c) from t1 where t1.f<=13),17))) from t1 union select cast(avg(t1.c) AS integer) from t1) then t1.e else (13) end> -t1.e) or d<>19 then coalesce((select max((select abs(max(d)+cast(avg(d) AS integer)) from t1)) from t1 where t1.e<t1.c),19) when -t1.c in (t1.e,t1.f,e) then 11 else t1.a end<>19 then b when t1.a<=11 then 11 else t1.d end}
+} {100}
+do_test randexpr-2.893 {
+ db eval {SELECT coalesce((select (select count(*) from t1)*a*b from t1 where ((~b*a-t1.d+11*e-(select -count(*) | count(*) | count(*) from t1)*(select min((abs(coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where -17 in (t1.b,t1.f,t1.d))),11))/abs(t1.d))) from t1)-17+(abs(11)/abs(11)) | b+d | 11 in (select t1.a from t1 union select 13 from t1)))),t1.a) FROM t1 WHERE NOT (f>case when f-case when not exists(select 1 from t1 where case when b in (select abs(max(coalesce((select max(~t1.c) from t1 where t1.f<=13),17))) from t1 union select cast(avg(t1.c) AS integer) from t1) then t1.e else (13) end> -t1.e) or d<>19 then coalesce((select max((select abs(max(d)+cast(avg(d) AS integer)) from t1)) from t1 where t1.e<t1.c),19) when -t1.c in (t1.e,t1.f,e) then 11 else t1.a end<>19 then b when t1.a<=11 then 11 else t1.d end)}
+} {}
+do_test randexpr-2.894 {
+ db eval {SELECT coalesce((select (select count(*) from t1)*a*b from t1 where ((~b*a-t1.d+11*e-(select -count(*) & count(*) & count(*) from t1)*(select min((abs(coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where -17 in (t1.b,t1.f,t1.d))),11))/abs(t1.d))) from t1)-17+(abs(11)/abs(11)) & b+d & 11 in (select t1.a from t1 union select 13 from t1)))),t1.a) FROM t1 WHERE f>case when f-case when not exists(select 1 from t1 where case when b in (select abs(max(coalesce((select max(~t1.c) from t1 where t1.f<=13),17))) from t1 union select cast(avg(t1.c) AS integer) from t1) then t1.e else (13) end> -t1.e) or d<>19 then coalesce((select max((select abs(max(d)+cast(avg(d) AS integer)) from t1)) from t1 where t1.e<t1.c),19) when -t1.c in (t1.e,t1.f,e) then 11 else t1.a end<>19 then b when t1.a<=11 then 11 else t1.d end}
+} {100}
+do_test randexpr-2.895 {
+ db eval {SELECT coalesce((select e from t1 where ((abs((select case (~max(f) | ~max(19-t1.d) | cast(avg(11) AS integer)) when min(+t1.d*c) then max(case when 19+13 not between 13 and t1.c or t1.c not in ((b),11,(e)) then d else t1.d end+ -t1.d) else min(a) end from t1))/abs(11)))<17),t1.b)+17 FROM t1 WHERE (13 in (a,t1.a,~+(e)+t1.c*t1.c | t1.c- -t1.b-t1.b+e*b | t1.e-t1.e-e*coalesce((select max(t1.b) from t1 where t1.a*d<>coalesce((select max(t1.e-t1.b) from t1 where exists(select 1 from t1 where coalesce((select e from t1 where (17 not between 13 and t1.c)),t1.c)>=t1.c)),b)),t1.f)+17))}
+} {}
+do_test randexpr-2.896 {
+ db eval {SELECT coalesce((select e from t1 where ((abs((select case (~max(f) | ~max(19-t1.d) | cast(avg(11) AS integer)) when min(+t1.d*c) then max(case when 19+13 not between 13 and t1.c or t1.c not in ((b),11,(e)) then d else t1.d end+ -t1.d) else min(a) end from t1))/abs(11)))<17),t1.b)+17 FROM t1 WHERE NOT ((13 in (a,t1.a,~+(e)+t1.c*t1.c | t1.c- -t1.b-t1.b+e*b | t1.e-t1.e-e*coalesce((select max(t1.b) from t1 where t1.a*d<>coalesce((select max(t1.e-t1.b) from t1 where exists(select 1 from t1 where coalesce((select e from t1 where (17 not between 13 and t1.c)),t1.c)>=t1.c)),b)),t1.f)+17)))}
+} {517}
+do_test randexpr-2.897 {
+ db eval {SELECT coalesce((select e from t1 where ((abs((select case (~max(f) & ~max(19-t1.d) & cast(avg(11) AS integer)) when min(+t1.d*c) then max(case when 19+13 not between 13 and t1.c or t1.c not in ((b),11,(e)) then d else t1.d end+ -t1.d) else min(a) end from t1))/abs(11)))<17),t1.b)+17 FROM t1 WHERE NOT ((13 in (a,t1.a,~+(e)+t1.c*t1.c | t1.c- -t1.b-t1.b+e*b | t1.e-t1.e-e*coalesce((select max(t1.b) from t1 where t1.a*d<>coalesce((select max(t1.e-t1.b) from t1 where exists(select 1 from t1 where coalesce((select e from t1 where (17 not between 13 and t1.c)),t1.c)>=t1.c)),b)),t1.f)+17)))}
+} {517}
+do_test randexpr-2.898 {
+ db eval {SELECT c | coalesce((select max(~b*case +coalesce((select max( -(abs(c)/abs(11))+case when t1.c*17 not in (a,a,c) then t1.e when t1.b in (select 13 from t1 union select (c) from t1) then -(t1.c) else d end* -t1.c+a) from t1 where t1.f>=11),17) | t1.b when t1.b then c else t1.a end) from t1 where t1.f>t1.a),t1.c)+13*17 FROM t1 WHERE t1.e<t1.c*(select min((select count(*) from t1)) from t1)*f}
+} {-19587}
+do_test randexpr-2.899 {
+ db eval {SELECT c | coalesce((select max(~b*case +coalesce((select max( -(abs(c)/abs(11))+case when t1.c*17 not in (a,a,c) then t1.e when t1.b in (select 13 from t1 union select (c) from t1) then -(t1.c) else d end* -t1.c+a) from t1 where t1.f>=11),17) | t1.b when t1.b then c else t1.a end) from t1 where t1.f>t1.a),t1.c)+13*17 FROM t1 WHERE NOT (t1.e<t1.c*(select min((select count(*) from t1)) from t1)*f)}
+} {}
+do_test randexpr-2.900 {
+ db eval {SELECT c & coalesce((select max(~b*case +coalesce((select max( -(abs(c)/abs(11))+case when t1.c*17 not in (a,a,c) then t1.e when t1.b in (select 13 from t1 union select (c) from t1) then -(t1.c) else d end* -t1.c+a) from t1 where t1.f>=11),17) & t1.b when t1.b then c else t1.a end) from t1 where t1.f>t1.a),t1.c)+13*17 FROM t1 WHERE t1.e<t1.c*(select min((select count(*) from t1)) from t1)*f}
+} {8}
+do_test randexpr-2.901 {
+ db eval {SELECT coalesce((select max(a) from t1 where t1.b<t1.b),13 | -(coalesce((select max((abs(~t1.a | (abs(11)/abs((abs(t1.e)/abs(coalesce((select max(t1.e) from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where (t1.d)<>e) and not exists(select 1 from t1 where (19)=t1.e))),19*t1.e)-t1.c)) | 17))*t1.b)/abs(17))) from t1 where (t1.b) between d and t1.b),t1.c)) | t1.f-c-d) FROM t1 WHERE 13 not in (f,t1.c+11*c,coalesce((select e from t1 where case t1.b when c- -case (select cast(avg(+t1.c*t1.f) AS integer) from t1) when 13*case when not case when -17 in (select (t1.c) from t1 union select t1.c from t1) or t1.f in (t1.b,t1.d,t1.b) then t1.a when 11<>t1.c then e else a end>=(11) and a=d or -t1.f between c and b then e else t1.f end then 19 else t1.d end then t1.c else t1.b end<>13),d))}
+} {-35}
+do_test randexpr-2.902 {
+ db eval {SELECT coalesce((select max(a) from t1 where t1.b<t1.b),13 | -(coalesce((select max((abs(~t1.a | (abs(11)/abs((abs(t1.e)/abs(coalesce((select max(t1.e) from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where (t1.d)<>e) and not exists(select 1 from t1 where (19)=t1.e))),19*t1.e)-t1.c)) | 17))*t1.b)/abs(17))) from t1 where (t1.b) between d and t1.b),t1.c)) | t1.f-c-d) FROM t1 WHERE NOT (13 not in (f,t1.c+11*c,coalesce((select e from t1 where case t1.b when c- -case (select cast(avg(+t1.c*t1.f) AS integer) from t1) when 13*case when not case when -17 in (select (t1.c) from t1 union select t1.c from t1) or t1.f in (t1.b,t1.d,t1.b) then t1.a when 11<>t1.c then e else a end>=(11) and a=d or -t1.f between c and b then e else t1.f end then 19 else t1.d end then t1.c else t1.b end<>13),d)))}
+} {}
+do_test randexpr-2.903 {
+ db eval {SELECT f+b+(t1.a+c)+(case when (select (cast(avg(coalesce((select max(t1.b) from t1 where case -(select +cast(avg(b-t1.e) AS integer)-abs(cast(avg(~(abs(f)/abs(f))) AS integer)) from t1)+d when 11 then d else 13 end+t1.e<>t1.e),(t1.e))-13+13) AS integer)) from t1)-t1.b<>a then t1.e else e end) FROM t1 WHERE c in (select abs((max(t1.d))) from t1 union select count(*) from t1) and (coalesce((select max(+ -(t1.f-d)* -b) from t1 where not exists(select 1 from t1 where (b not in (coalesce((select t1.e-a from t1 where not t1.a between 13 and f or t1.b in (t1.e,e,17)),11),17,t1.a) and (b<>d)))),b) in (select -min(17) from t1 union select abs(max(e)) from t1))}
+} {}
+do_test randexpr-2.904 {
+ db eval {SELECT f+b+(t1.a+c)+(case when (select (cast(avg(coalesce((select max(t1.b) from t1 where case -(select +cast(avg(b-t1.e) AS integer)-abs(cast(avg(~(abs(f)/abs(f))) AS integer)) from t1)+d when 11 then d else 13 end+t1.e<>t1.e),(t1.e))-13+13) AS integer)) from t1)-t1.b<>a then t1.e else e end) FROM t1 WHERE NOT (c in (select abs((max(t1.d))) from t1 union select count(*) from t1) and (coalesce((select max(+ -(t1.f-d)* -b) from t1 where not exists(select 1 from t1 where (b not in (coalesce((select t1.e-a from t1 where not t1.a between 13 and f or t1.b in (t1.e,e,17)),11),17,t1.a) and (b<>d)))),b) in (select -min(17) from t1 union select abs(max(e)) from t1)))}
+} {1700}
+do_test randexpr-2.905 {
+ db eval {SELECT case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (case when (select -min(t1.e) from t1) in (select f from t1 union select d from t1) then +e else d end | t1.e not between t1.a and t1.b))) and not exists(select 1 from t1 where a>=t1.e) and b=e then 13 else coalesce((select 19 from t1 where t1.d>=t1.e),13) end<11*t1.b then 17 when 17 in (19,t1.e, -t1.c) or 17<f then t1.d else t1.b end FROM t1 WHERE exists(select 1 from t1 where f<=19)}
+} {}
+do_test randexpr-2.906 {
+ db eval {SELECT case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (case when (select -min(t1.e) from t1) in (select f from t1 union select d from t1) then +e else d end | t1.e not between t1.a and t1.b))) and not exists(select 1 from t1 where a>=t1.e) and b=e then 13 else coalesce((select 19 from t1 where t1.d>=t1.e),13) end<11*t1.b then 17 when 17 in (19,t1.e, -t1.c) or 17<f then t1.d else t1.b end FROM t1 WHERE NOT (exists(select 1 from t1 where f<=19))}
+} {17}
+do_test randexpr-2.907 {
+ db eval {SELECT case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (case when (select -min(t1.e) from t1) in (select f from t1 union select d from t1) then +e else d end & t1.e not between t1.a and t1.b))) and not exists(select 1 from t1 where a>=t1.e) and b=e then 13 else coalesce((select 19 from t1 where t1.d>=t1.e),13) end<11*t1.b then 17 when 17 in (19,t1.e, -t1.c) or 17<f then t1.d else t1.b end FROM t1 WHERE NOT (exists(select 1 from t1 where f<=19))}
+} {17}
+do_test randexpr-2.908 {
+ db eval {SELECT 11*t1.c* -case when t1.d<=t1.c then case when case case +t1.b-case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.e not in (t1.a,a,11)))) then (abs((select case count(distinct d) when cast(avg(19) AS integer) then -min(t1.a) else (cast(avg(f) AS integer)) end from t1))/abs(b)) when t1.c<>t1.a then c else 19 end when t1.c then e else t1.d end when 17 then t1.d else -d end between e and t1.e then 13 when (13<>13) then t1.c else 17 end when exists(select 1 from t1 where (t1.c between b and 11)) then e else f end FROM t1 WHERE ~a* -b+11-case when coalesce((select max(case when (t1.c in (case t1.b when t1.c then 13 else 17 end,17,19)) then case e when a then c else 13 end else c end) from t1 where a between b and t1.c),t1.a)=c or (17>d) then case when f= -t1.a then t1.b when (t1.d)<t1.e then (f) else t1.e end else c end+d<a}
+} {}
+do_test randexpr-2.909 {
+ db eval {SELECT 11*t1.c* -case when t1.d<=t1.c then case when case case +t1.b-case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.e not in (t1.a,a,11)))) then (abs((select case count(distinct d) when cast(avg(19) AS integer) then -min(t1.a) else (cast(avg(f) AS integer)) end from t1))/abs(b)) when t1.c<>t1.a then c else 19 end when t1.c then e else t1.d end when 17 then t1.d else -d end between e and t1.e then 13 when (13<>13) then t1.c else 17 end when exists(select 1 from t1 where (t1.c between b and 11)) then e else f end FROM t1 WHERE NOT (~a* -b+11-case when coalesce((select max(case when (t1.c in (case t1.b when t1.c then 13 else 17 end,17,19)) then case e when a then c else 13 end else c end) from t1 where a between b and t1.c),t1.a)=c or (17>d) then case when f= -t1.a then t1.b when (t1.d)<t1.e then (f) else t1.e end else c end+d<a)}
+} {-1980000}
+do_test randexpr-2.910 {
+ db eval {SELECT +case when e in (13, -b,11) then d else coalesce((select max(13 | d | d+19+(abs(case when (19) between (abs(case f when t1.f then (13) else 17 end)/abs(a)) and d then 19 when (not exists(select 1 from t1 where t1.a>=t1.f)) and t1.f>t1.a or e<>c then 17 else d end)/abs(a))) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (t1.f) in (t1.c,(t1.e),17)))),t1.a) end+e FROM t1 WHERE exists(select 1 from t1 where 17>(case coalesce((select max((abs(+t1.f-case when 11=(abs((select count(*) from t1)-13*13)/abs(t1.d)) then coalesce((select max(t1.c) from t1 where 19 in (select ((max(19))) from t1 union select min(t1.d) from t1) or -t1.a=t1.a and f<17),t1.e-d) when not exists(select 1 from t1 where t1.b not between (d) and -t1.f) then 11 else t1.a end)/abs(t1.a))) from t1 where t1.e not in ((f),11,t1.f)),t1.c) when b then -t1.a else 13 end)-t1.c)}
+} {947}
+do_test randexpr-2.911 {
+ db eval {SELECT +case when e in (13, -b,11) then d else coalesce((select max(13 | d | d+19+(abs(case when (19) between (abs(case f when t1.f then (13) else 17 end)/abs(a)) and d then 19 when (not exists(select 1 from t1 where t1.a>=t1.f)) and t1.f>t1.a or e<>c then 17 else d end)/abs(a))) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (t1.f) in (t1.c,(t1.e),17)))),t1.a) end+e FROM t1 WHERE NOT (exists(select 1 from t1 where 17>(case coalesce((select max((abs(+t1.f-case when 11=(abs((select count(*) from t1)-13*13)/abs(t1.d)) then coalesce((select max(t1.c) from t1 where 19 in (select ((max(19))) from t1 union select min(t1.d) from t1) or -t1.a=t1.a and f<17),t1.e-d) when not exists(select 1 from t1 where t1.b not between (d) and -t1.f) then 11 else t1.a end)/abs(t1.a))) from t1 where t1.e not in ((f),11,t1.f)),t1.c) when b then -t1.a else 13 end)-t1.c))}
+} {}
+do_test randexpr-2.912 {
+ db eval {SELECT +case when e in (13, -b,11) then d else coalesce((select max(13 & d & d+19+(abs(case when (19) between (abs(case f when t1.f then (13) else 17 end)/abs(a)) and d then 19 when (not exists(select 1 from t1 where t1.a>=t1.f)) and t1.f>t1.a or e<>c then 17 else d end)/abs(a))) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (t1.f) in (t1.c,(t1.e),17)))),t1.a) end+e FROM t1 WHERE exists(select 1 from t1 where 17>(case coalesce((select max((abs(+t1.f-case when 11=(abs((select count(*) from t1)-13*13)/abs(t1.d)) then coalesce((select max(t1.c) from t1 where 19 in (select ((max(19))) from t1 union select min(t1.d) from t1) or -t1.a=t1.a and f<17),t1.e-d) when not exists(select 1 from t1 where t1.b not between (d) and -t1.f) then 11 else t1.a end)/abs(t1.a))) from t1 where t1.e not in ((f),11,t1.f)),t1.c) when b then -t1.a else 13 end)-t1.c)}
+} {500}
+do_test randexpr-2.913 {
+ db eval {SELECT (13*case when exists(select 1 from t1 where exists(select 1 from t1 where coalesce((select max(b) from t1 where t1.b=e),a)<(b-a)+13)) then 11 else t1.e end*coalesce((select 17 from t1 where not ((select cast(avg(13) AS integer) from t1)< -t1.c) and 17 between 13 and 13),case when f<c then b when t1.c<t1.a then -d else e end)*d+b)+ - -t1.b+11 FROM t1 WHERE not exists(select 1 from t1 where b>=case when exists(select 1 from t1 where (13 in ( -(b)*(select count(*)* -cast(avg(case t1.e when t1.b then (f)-f-f else e end) AS integer)*cast(avg(17) AS integer) | cast(avg((17)) AS integer) | min(d) | count(distinct e) from t1),19+(abs(19)/abs(17))*f,t1.b))) then 11 when 17>t1.f then +a else t1.d end)}
+} {28600411}
+do_test randexpr-2.914 {
+ db eval {SELECT (13*case when exists(select 1 from t1 where exists(select 1 from t1 where coalesce((select max(b) from t1 where t1.b=e),a)<(b-a)+13)) then 11 else t1.e end*coalesce((select 17 from t1 where not ((select cast(avg(13) AS integer) from t1)< -t1.c) and 17 between 13 and 13),case when f<c then b when t1.c<t1.a then -d else e end)*d+b)+ - -t1.b+11 FROM t1 WHERE NOT (not exists(select 1 from t1 where b>=case when exists(select 1 from t1 where (13 in ( -(b)*(select count(*)* -cast(avg(case t1.e when t1.b then (f)-f-f else e end) AS integer)*cast(avg(17) AS integer) | cast(avg((17)) AS integer) | min(d) | count(distinct e) from t1),19+(abs(19)/abs(17))*f,t1.b))) then 11 when 17>t1.f then +a else t1.d end))}
+} {}
+do_test randexpr-2.915 {
+ db eval {SELECT case when +11 | (select min(case 13+a when e then d else 17-t1.b-~b*a end) from t1)-f*t1.f=(coalesce((select e from t1 where a<=f and not exists(select 1 from t1 where d-case 19 when 11 then (b) else t1.e end not between -t1.a and (t1.c))),e)) then t1.e when -17>=d then t1.f else t1.b end*t1.a FROM t1 WHERE e<=19}
+} {}
+do_test randexpr-2.916 {
+ db eval {SELECT case when +11 | (select min(case 13+a when e then d else 17-t1.b-~b*a end) from t1)-f*t1.f=(coalesce((select e from t1 where a<=f and not exists(select 1 from t1 where d-case 19 when 11 then (b) else t1.e end not between -t1.a and (t1.c))),e)) then t1.e when -17>=d then t1.f else t1.b end*t1.a FROM t1 WHERE NOT (e<=19)}
+} {20000}
+do_test randexpr-2.917 {
+ db eval {SELECT case when +11 & (select min(case 13+a when e then d else 17-t1.b-~b*a end) from t1)-f*t1.f=(coalesce((select e from t1 where a<=f and not exists(select 1 from t1 where d-case 19 when 11 then (b) else t1.e end not between -t1.a and (t1.c))),e)) then t1.e when -17>=d then t1.f else t1.b end*t1.a FROM t1 WHERE NOT (e<=19)}
+} {20000}
+do_test randexpr-2.918 {
+ db eval {SELECT 11-coalesce((select max(coalesce((select max((select abs(case +max((e)) when abs(abs( -count(distinct e))) then +cast(avg(f) AS integer) else count(*) end+count(*)+min( -e)) from t1)) from t1 where t1.b in (select count(distinct (17 | case case when e in (13,t1.a,e) or t1.d>=t1.e then 17 else a end when t1.e then 17 else t1.d end*t1.c)) from t1 union select cast(avg(t1.a) AS integer) from t1)),17)) from t1 where t1.c in (select ~cast(avg(t1.b) AS integer) from t1 union select -(cast(avg(t1.c) AS integer)) from t1)),(t1.c)) FROM t1 WHERE t1.b not in (case when 11 in (select case +min(t1.f) when (+cast(avg((case t1.c when a then f else a end-f)) AS integer)) then +count(distinct (t1.f))-count(distinct t1.f) else count(*) end-count(*) | count(*) from t1 union select min(e) from t1) then (abs(b | 13-f | c)/abs(t1.f)) else t1.c end,f,t1.b) or not -t1.a<t1.f or t1.f>=11}
+} {-289}
+do_test randexpr-2.919 {
+ db eval {SELECT 11-coalesce((select max(coalesce((select max((select abs(case +max((e)) when abs(abs( -count(distinct e))) then +cast(avg(f) AS integer) else count(*) end+count(*)+min( -e)) from t1)) from t1 where t1.b in (select count(distinct (17 | case case when e in (13,t1.a,e) or t1.d>=t1.e then 17 else a end when t1.e then 17 else t1.d end*t1.c)) from t1 union select cast(avg(t1.a) AS integer) from t1)),17)) from t1 where t1.c in (select ~cast(avg(t1.b) AS integer) from t1 union select -(cast(avg(t1.c) AS integer)) from t1)),(t1.c)) FROM t1 WHERE NOT (t1.b not in (case when 11 in (select case +min(t1.f) when (+cast(avg((case t1.c when a then f else a end-f)) AS integer)) then +count(distinct (t1.f))-count(distinct t1.f) else count(*) end-count(*) | count(*) from t1 union select min(e) from t1) then (abs(b | 13-f | c)/abs(t1.f)) else t1.c end,f,t1.b) or not -t1.a<t1.f or t1.f>=11)}
+} {}
+do_test randexpr-2.920 {
+ db eval {SELECT 11-coalesce((select max(coalesce((select max((select abs(case +max((e)) when abs(abs( -count(distinct e))) then +cast(avg(f) AS integer) else count(*) end+count(*)+min( -e)) from t1)) from t1 where t1.b in (select count(distinct (17 & case case when e in (13,t1.a,e) or t1.d>=t1.e then 17 else a end when t1.e then 17 else t1.d end*t1.c)) from t1 union select cast(avg(t1.a) AS integer) from t1)),17)) from t1 where t1.c in (select ~cast(avg(t1.b) AS integer) from t1 union select -(cast(avg(t1.c) AS integer)) from t1)),(t1.c)) FROM t1 WHERE t1.b not in (case when 11 in (select case +min(t1.f) when (+cast(avg((case t1.c when a then f else a end-f)) AS integer)) then +count(distinct (t1.f))-count(distinct t1.f) else count(*) end-count(*) | count(*) from t1 union select min(e) from t1) then (abs(b | 13-f | c)/abs(t1.f)) else t1.c end,f,t1.b) or not -t1.a<t1.f or t1.f>=11}
+} {-289}
+do_test randexpr-2.921 {
+ db eval {SELECT (select -abs(max(+(select +count(*) from t1)))-max(case when b in (select (abs(13)/abs(b)) from t1 union select case when exists(select 1 from t1 where not exists(select 1 from t1 where (abs(17)/abs(coalesce((select max(+19*t1.e+case t1.f when (abs(f)/abs(t1.f)) then t1.f else e end) from t1 where 19<17),t1.a)))+11 in (select b from t1 union select t1.e from t1))) then d else t1.c end from t1) then f when 13=d then -a else t1.a end) from t1) FROM t1 WHERE ~(select ~ -(min(f)- -cast(avg(f) AS integer)-abs(count(distinct case when t1.d=b then d when e in (select +cast(avg(e) AS integer) from t1 union select count(*) from t1) then t1.f else c end*17*f))) | (count(*)) from t1)-f<>case when (select + -max(t1.e) from t1)+(select -min(17) from t1)*13 between 17 and 19 then t1.b else t1.d end}
+} {-101}
+do_test randexpr-2.922 {
+ db eval {SELECT (select -abs(max(+(select +count(*) from t1)))-max(case when b in (select (abs(13)/abs(b)) from t1 union select case when exists(select 1 from t1 where not exists(select 1 from t1 where (abs(17)/abs(coalesce((select max(+19*t1.e+case t1.f when (abs(f)/abs(t1.f)) then t1.f else e end) from t1 where 19<17),t1.a)))+11 in (select b from t1 union select t1.e from t1))) then d else t1.c end from t1) then f when 13=d then -a else t1.a end) from t1) FROM t1 WHERE NOT (~(select ~ -(min(f)- -cast(avg(f) AS integer)-abs(count(distinct case when t1.d=b then d when e in (select +cast(avg(e) AS integer) from t1 union select count(*) from t1) then t1.f else c end*17*f))) | (count(*)) from t1)-f<>case when (select + -max(t1.e) from t1)+(select -min(17) from t1)*13 between 17 and 19 then t1.b else t1.d end)}
+} {}
+do_test randexpr-2.923 {
+ db eval {SELECT case (select ( - - -(+max(c))+min(e)-(count(*))+cast(avg(t1.e) AS integer)-min(t1.a)*(cast(avg(11) AS integer))) from t1) when t1.d then t1.c else case (select max(a) from t1) when -t1.b then case when not 17<>case when t1.e<=t1.d or ((t1.e))=t1.e then t1.f when e>=t1.b then 11 else t1.d end or d in (t1.f,t1.a,t1.a) then c | 17 when t1.f between t1.a and -t1.e then d else t1.c end else t1.c end end-t1.c FROM t1 WHERE not (exists(select 1 from t1 where a<>11+t1.d-t1.a+(select count(distinct t1.d)++max(case e when coalesce((select 11 from t1 where a>=case when coalesce((select f from t1 where exists(select 1 from t1 where 13 in (t1.c,13,t1.a))),(d))+f not between d and t1.e then d else (t1.c) end-13),(d))-t1.d then t1.a else 17 end) from t1)) and not a<(d)*19)}
+} {0}
+do_test randexpr-2.924 {
+ db eval {SELECT case (select ( - - -(+max(c))+min(e)-(count(*))+cast(avg(t1.e) AS integer)-min(t1.a)*(cast(avg(11) AS integer))) from t1) when t1.d then t1.c else case (select max(a) from t1) when -t1.b then case when not 17<>case when t1.e<=t1.d or ((t1.e))=t1.e then t1.f when e>=t1.b then 11 else t1.d end or d in (t1.f,t1.a,t1.a) then c | 17 when t1.f between t1.a and -t1.e then d else t1.c end else t1.c end end-t1.c FROM t1 WHERE NOT (not (exists(select 1 from t1 where a<>11+t1.d-t1.a+(select count(distinct t1.d)++max(case e when coalesce((select 11 from t1 where a>=case when coalesce((select f from t1 where exists(select 1 from t1 where 13 in (t1.c,13,t1.a))),(d))+f not between d and t1.e then d else (t1.c) end-13),(d))-t1.d then t1.a else 17 end) from t1)) and not a<(d)*19))}
+} {}
+do_test randexpr-2.925 {
+ db eval {SELECT case (select ( - - -(+max(c))+min(e)-(count(*))+cast(avg(t1.e) AS integer)-min(t1.a)*(cast(avg(11) AS integer))) from t1) when t1.d then t1.c else case (select max(a) from t1) when -t1.b then case when not 17<>case when t1.e<=t1.d or ((t1.e))=t1.e then t1.f when e>=t1.b then 11 else t1.d end or d in (t1.f,t1.a,t1.a) then c & 17 when t1.f between t1.a and -t1.e then d else t1.c end else t1.c end end-t1.c FROM t1 WHERE not (exists(select 1 from t1 where a<>11+t1.d-t1.a+(select count(distinct t1.d)++max(case e when coalesce((select 11 from t1 where a>=case when coalesce((select f from t1 where exists(select 1 from t1 where 13 in (t1.c,13,t1.a))),(d))+f not between d and t1.e then d else (t1.c) end-13),(d))-t1.d then t1.a else 17 end) from t1)) and not a<(d)*19)}
+} {0}
+do_test randexpr-2.926 {
+ db eval {SELECT case t1.b when c*(case when ((select ++case abs(cast(avg(a) AS integer))*min(c) when min(t1.c) then cast(avg(t1.b) AS integer) else count(*) end | (count(distinct t1.c)) | ((max(t1.a))) | count(distinct b) from t1) not between t1.e and 11 and coalesce((select max(e) from t1 where a between t1.c and c+b),e) in (select t1.d from t1 union select t1.b from t1) or (not exists(select 1 from t1 where 13<>t1.a))) then 11*b else t1.b end) then t1.c else e end FROM t1 WHERE exists(select 1 from t1 where t1.d>=f)}
+} {}
+do_test randexpr-2.927 {
+ db eval {SELECT case t1.b when c*(case when ((select ++case abs(cast(avg(a) AS integer))*min(c) when min(t1.c) then cast(avg(t1.b) AS integer) else count(*) end | (count(distinct t1.c)) | ((max(t1.a))) | count(distinct b) from t1) not between t1.e and 11 and coalesce((select max(e) from t1 where a between t1.c and c+b),e) in (select t1.d from t1 union select t1.b from t1) or (not exists(select 1 from t1 where 13<>t1.a))) then 11*b else t1.b end) then t1.c else e end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.d>=f))}
+} {500}
+do_test randexpr-2.928 {
+ db eval {SELECT case t1.b when c*(case when ((select ++case abs(cast(avg(a) AS integer))*min(c) when min(t1.c) then cast(avg(t1.b) AS integer) else count(*) end & (count(distinct t1.c)) & ((max(t1.a))) & count(distinct b) from t1) not between t1.e and 11 and coalesce((select max(e) from t1 where a between t1.c and c+b),e) in (select t1.d from t1 union select t1.b from t1) or (not exists(select 1 from t1 where 13<>t1.a))) then 11*b else t1.b end) then t1.c else e end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.d>=f))}
+} {500}
+do_test randexpr-2.929 {
+ db eval {SELECT d-coalesce((select d from t1 where case when ~11*a*c>=17 then coalesce((select (abs(t1.e+c+(abs(f*(select abs((min(e))) from t1)-t1.f)/abs( - -a))-a)/abs(t1.d)) from t1 where f not in (e,b,t1.f) and c<>f),f)*19 else f end in (b,e,17)),13)-19 FROM t1 WHERE not f>=11}
+} {}
+do_test randexpr-2.930 {
+ db eval {SELECT d-coalesce((select d from t1 where case when ~11*a*c>=17 then coalesce((select (abs(t1.e+c+(abs(f*(select abs((min(e))) from t1)-t1.f)/abs( - -a))-a)/abs(t1.d)) from t1 where f not in (e,b,t1.f) and c<>f),f)*19 else f end in (b,e,17)),13)-19 FROM t1 WHERE NOT (not f>=11)}
+} {368}
+do_test randexpr-2.931 {
+ db eval {SELECT f*t1.d+coalesce((select a+17-t1.e from t1 where 13=t1.f and not (t1.f | b*t1.d-t1.c*coalesce((select max(coalesce((select t1.f from t1 where f not in (13,a,d)),d)) from t1 where t1.a in (select cast(avg(c) AS integer) from t1 union select count(distinct b)*count(distinct t1.c) from t1)),((17)))+ -b+19+13)=t1.f and 19>=t1.a or - -a>=t1.b),a) FROM t1 WHERE f not in (coalesce((select max(19) from t1 where (t1.e<=+t1.f*case when ~(abs(b)/abs(b)) in (f,t1.d,17) then (abs(t1.e-11 | d)/abs(coalesce((select d from t1 where not coalesce((select t1.a from t1 where not exists(select 1 from t1 where c>=t1.c)),d) in (select count(distinct f)*cast(avg(19) AS integer) from t1 union select count(distinct d) from t1)),13))) when not 11<=t1.a then t1.f else 19 end-19)),f)-17, -a,e)}
+} {240100}
+do_test randexpr-2.932 {
+ db eval {SELECT f*t1.d+coalesce((select a+17-t1.e from t1 where 13=t1.f and not (t1.f | b*t1.d-t1.c*coalesce((select max(coalesce((select t1.f from t1 where f not in (13,a,d)),d)) from t1 where t1.a in (select cast(avg(c) AS integer) from t1 union select count(distinct b)*count(distinct t1.c) from t1)),((17)))+ -b+19+13)=t1.f and 19>=t1.a or - -a>=t1.b),a) FROM t1 WHERE NOT (f not in (coalesce((select max(19) from t1 where (t1.e<=+t1.f*case when ~(abs(b)/abs(b)) in (f,t1.d,17) then (abs(t1.e-11 | d)/abs(coalesce((select d from t1 where not coalesce((select t1.a from t1 where not exists(select 1 from t1 where c>=t1.c)),d) in (select count(distinct f)*cast(avg(19) AS integer) from t1 union select count(distinct d) from t1)),13))) when not 11<=t1.a then t1.f else 19 end-19)),f)-17, -a,e))}
+} {}
+do_test randexpr-2.933 {
+ db eval {SELECT f*t1.d+coalesce((select a+17-t1.e from t1 where 13=t1.f and not (t1.f & b*t1.d-t1.c*coalesce((select max(coalesce((select t1.f from t1 where f not in (13,a,d)),d)) from t1 where t1.a in (select cast(avg(c) AS integer) from t1 union select count(distinct b)*count(distinct t1.c) from t1)),((17)))+ -b+19+13)=t1.f and 19>=t1.a or - -a>=t1.b),a) FROM t1 WHERE f not in (coalesce((select max(19) from t1 where (t1.e<=+t1.f*case when ~(abs(b)/abs(b)) in (f,t1.d,17) then (abs(t1.e-11 | d)/abs(coalesce((select d from t1 where not coalesce((select t1.a from t1 where not exists(select 1 from t1 where c>=t1.c)),d) in (select count(distinct f)*cast(avg(19) AS integer) from t1 union select count(distinct d) from t1)),13))) when not 11<=t1.a then t1.f else 19 end-19)),f)-17, -a,e)}
+} {240100}
+do_test randexpr-2.934 {
+ db eval {SELECT coalesce((select case e*+(abs(t1.f-t1.b)/abs(e))-d when coalesce((select t1.e from t1 where exists(select 1 from t1 where +d+ -t1.e not between case when (abs(b)/abs(t1.b)) between a and 17 then t1.b when not 11 not between b and d then 19 else 19 end and t1.f and t1.a between 17 and b)), -13) then (t1.a) else 13 end from t1 where 17 between b and 13), -19) | c FROM t1 WHERE case when t1.e*t1.b | f+d | f+11+(a)-+a+ -t1.c-t1.f | coalesce((select case t1.e when 17 then e else t1.a end from t1 where t1.a<t1.b),t1.b)*f<= -t1.a and c<t1.f then (select (max((b))) from t1) else t1.b end not in (a,a,t1.c)}
+} {-19}
+do_test randexpr-2.935 {
+ db eval {SELECT coalesce((select case e*+(abs(t1.f-t1.b)/abs(e))-d when coalesce((select t1.e from t1 where exists(select 1 from t1 where +d+ -t1.e not between case when (abs(b)/abs(t1.b)) between a and 17 then t1.b when not 11 not between b and d then 19 else 19 end and t1.f and t1.a between 17 and b)), -13) then (t1.a) else 13 end from t1 where 17 between b and 13), -19) | c FROM t1 WHERE NOT (case when t1.e*t1.b | f+d | f+11+(a)-+a+ -t1.c-t1.f | coalesce((select case t1.e when 17 then e else t1.a end from t1 where t1.a<t1.b),t1.b)*f<= -t1.a and c<t1.f then (select (max((b))) from t1) else t1.b end not in (a,a,t1.c))}
+} {}
+do_test randexpr-2.936 {
+ db eval {SELECT coalesce((select case e*+(abs(t1.f-t1.b)/abs(e))-d when coalesce((select t1.e from t1 where exists(select 1 from t1 where +d+ -t1.e not between case when (abs(b)/abs(t1.b)) between a and 17 then t1.b when not 11 not between b and d then 19 else 19 end and t1.f and t1.a between 17 and b)), -13) then (t1.a) else 13 end from t1 where 17 between b and 13), -19) & c FROM t1 WHERE case when t1.e*t1.b | f+d | f+11+(a)-+a+ -t1.c-t1.f | coalesce((select case t1.e when 17 then e else t1.a end from t1 where t1.a<t1.b),t1.b)*f<= -t1.a and c<t1.f then (select (max((b))) from t1) else t1.b end not in (a,a,t1.c)}
+} {300}
+do_test randexpr-2.937 {
+ db eval {SELECT coalesce((select max(t1.d*case when case when ~ -t1.d+17-b-13*t1.f*(abs(t1.b+13)/abs(t1.a))+a*t1.e*t1.a+c*t1.d-t1.a in (select t1.b from t1 union select t1.d from t1) then t1.e else t1.e end not in (t1.f,t1.e,19) then t1.d else 11 end) from t1 where d not between t1.a and a),c) FROM t1 WHERE t1.e in (select a from t1 union select +b-t1.b from t1)}
+} {}
+do_test randexpr-2.938 {
+ db eval {SELECT coalesce((select max(t1.d*case when case when ~ -t1.d+17-b-13*t1.f*(abs(t1.b+13)/abs(t1.a))+a*t1.e*t1.a+c*t1.d-t1.a in (select t1.b from t1 union select t1.d from t1) then t1.e else t1.e end not in (t1.f,t1.e,19) then t1.d else 11 end) from t1 where d not between t1.a and a),c) FROM t1 WHERE NOT (t1.e in (select a from t1 union select +b-t1.b from t1))}
+} {4400}
+do_test randexpr-2.939 {
+ db eval {SELECT d*(select - - -max( -(abs(e)/abs(~t1.c))) from t1)-13 | coalesce((select max(+t1.a*a) from t1 where t1.e+case e when a then t1.f+(select case ~ -max(d)* - -cast(avg(c) AS integer) when -min( -t1.b) then min(t1.b) else count(distinct 13) end from t1)-a else ~case when t1.f not in (b,b,a) or c between d and t1.a then c when t1.b>b then e else t1.d end end-11>=13),e) | 13 FROM t1 WHERE not exists(select 1 from t1 where t1.c< -d or t1.e between c and -t1.d or d<=17)}
+} {10143}
+do_test randexpr-2.940 {
+ db eval {SELECT d*(select - - -max( -(abs(e)/abs(~t1.c))) from t1)-13 | coalesce((select max(+t1.a*a) from t1 where t1.e+case e when a then t1.f+(select case ~ -max(d)* - -cast(avg(c) AS integer) when -min( -t1.b) then min(t1.b) else count(distinct 13) end from t1)-a else ~case when t1.f not in (b,b,a) or c between d and t1.a then c when t1.b>b then e else t1.d end end-11>=13),e) | 13 FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.c< -d or t1.e between c and -t1.d or d<=17))}
+} {}
+do_test randexpr-2.941 {
+ db eval {SELECT d*(select - - -max( -(abs(e)/abs(~t1.c))) from t1)-13 & coalesce((select max(+t1.a*a) from t1 where t1.e+case e when a then t1.f+(select case ~ -max(d)* - -cast(avg(c) AS integer) when -min( -t1.b) then min(t1.b) else count(distinct 13) end from t1)-a else ~case when t1.f not in (b,b,a) or c between d and t1.a then c when t1.b>b then e else t1.d end end-11>=13),e) & 13 FROM t1 WHERE not exists(select 1 from t1 where t1.c< -d or t1.e between c and -t1.d or d<=17)}
+} {0}
+do_test randexpr-2.942 {
+ db eval {SELECT t1.c*+case when a<>+case when b>t1.e or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e in (select coalesce((select b from t1 where (d<f) or t1.e in ((t1.f),(t1.a),13) and (t1.e)<>( -t1.d)),(( -b))) from t1 union select t1.d from t1))) then (select -max(t1.e)-count(*) from t1) else (t1.c) end+b+(t1.f) | f | e then t1.d when t1.f not in (19,13,e) then 13 else 11 end FROM t1 WHERE (f<>coalesce((select max(a) from t1 where (exists(select 1 from t1 where c between t1.b and case when (abs(19)/abs(t1.f)) in (t1.f,17,t1.a) then t1.b when t1.d<=t1.a then t1.a else c end or c<c) or 13>=b and c>=t1.d and t1.d between c and t1.c)),e+case (select count(distinct case 19 when 13 then t1.b else 11 end) from t1) when 13 then b else t1.b end)-17-17)}
+} {120000}
+do_test randexpr-2.943 {
+ db eval {SELECT t1.c*+case when a<>+case when b>t1.e or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e in (select coalesce((select b from t1 where (d<f) or t1.e in ((t1.f),(t1.a),13) and (t1.e)<>( -t1.d)),(( -b))) from t1 union select t1.d from t1))) then (select -max(t1.e)-count(*) from t1) else (t1.c) end+b+(t1.f) | f | e then t1.d when t1.f not in (19,13,e) then 13 else 11 end FROM t1 WHERE NOT ((f<>coalesce((select max(a) from t1 where (exists(select 1 from t1 where c between t1.b and case when (abs(19)/abs(t1.f)) in (t1.f,17,t1.a) then t1.b when t1.d<=t1.a then t1.a else c end or c<c) or 13>=b and c>=t1.d and t1.d between c and t1.c)),e+case (select count(distinct case 19 when 13 then t1.b else 11 end) from t1) when 13 then b else t1.b end)-17-17))}
+} {}
+do_test randexpr-2.944 {
+ db eval {SELECT t1.c*+case when a<>+case when b>t1.e or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e in (select coalesce((select b from t1 where (d<f) or t1.e in ((t1.f),(t1.a),13) and (t1.e)<>( -t1.d)),(( -b))) from t1 union select t1.d from t1))) then (select -max(t1.e)-count(*) from t1) else (t1.c) end+b+(t1.f) & f & e then t1.d when t1.f not in (19,13,e) then 13 else 11 end FROM t1 WHERE (f<>coalesce((select max(a) from t1 where (exists(select 1 from t1 where c between t1.b and case when (abs(19)/abs(t1.f)) in (t1.f,17,t1.a) then t1.b when t1.d<=t1.a then t1.a else c end or c<c) or 13>=b and c>=t1.d and t1.d between c and t1.c)),e+case (select count(distinct case 19 when 13 then t1.b else 11 end) from t1) when 13 then b else t1.b end)-17-17)}
+} {120000}
+do_test randexpr-2.945 {
+ db eval {SELECT case when (e)- -((select case min(case when e in (select coalesce((select max(d) from t1 where 13<>(t1.d-e)),e) from t1 union select c from t1) then d else -11 end+a) when count(distinct -f) then count(*) else -(case cast(avg(17) AS integer)- -count(distinct t1.c)+cast(avg(b) AS integer) when -max(11) then count(*) else cast(avg(t1.e) AS integer) end+max(t1.f)) end from t1))<=t1.b | t1.e then t1.d when not exists(select 1 from t1 where c<>13) then 11 else d end FROM t1 WHERE (select max(t1.a*case f when b then ~case when not exists(select 1 from t1 where f-d>(select abs(cast(avg(~17+b+d) AS integer)) from t1) or f-e in (select b from t1 union select t1.d from t1) or exists(select 1 from t1 where 13<>b)) then (abs(a)/abs( -d)) when (d<t1.a) then e else t1.e end else t1.a end) from t1)*t1.e in (select t1.f from t1 union select t1.b from t1)}
+} {}
+do_test randexpr-2.946 {
+ db eval {SELECT case when (e)- -((select case min(case when e in (select coalesce((select max(d) from t1 where 13<>(t1.d-e)),e) from t1 union select c from t1) then d else -11 end+a) when count(distinct -f) then count(*) else -(case cast(avg(17) AS integer)- -count(distinct t1.c)+cast(avg(b) AS integer) when -max(11) then count(*) else cast(avg(t1.e) AS integer) end+max(t1.f)) end from t1))<=t1.b | t1.e then t1.d when not exists(select 1 from t1 where c<>13) then 11 else d end FROM t1 WHERE NOT ((select max(t1.a*case f when b then ~case when not exists(select 1 from t1 where f-d>(select abs(cast(avg(~17+b+d) AS integer)) from t1) or f-e in (select b from t1 union select t1.d from t1) or exists(select 1 from t1 where 13<>b)) then (abs(a)/abs( -d)) when (d<t1.a) then e else t1.e end else t1.a end) from t1)*t1.e in (select t1.f from t1 union select t1.b from t1))}
+} {400}
+do_test randexpr-2.947 {
+ db eval {SELECT case when (e)- -((select case min(case when e in (select coalesce((select max(d) from t1 where 13<>(t1.d-e)),e) from t1 union select c from t1) then d else -11 end+a) when count(distinct -f) then count(*) else -(case cast(avg(17) AS integer)- -count(distinct t1.c)+cast(avg(b) AS integer) when -max(11) then count(*) else cast(avg(t1.e) AS integer) end+max(t1.f)) end from t1))<=t1.b & t1.e then t1.d when not exists(select 1 from t1 where c<>13) then 11 else d end FROM t1 WHERE NOT ((select max(t1.a*case f when b then ~case when not exists(select 1 from t1 where f-d>(select abs(cast(avg(~17+b+d) AS integer)) from t1) or f-e in (select b from t1 union select t1.d from t1) or exists(select 1 from t1 where 13<>b)) then (abs(a)/abs( -d)) when (d<t1.a) then e else t1.e end else t1.a end) from t1)*t1.e in (select t1.f from t1 union select t1.b from t1))}
+} {400}
+do_test randexpr-2.948 {
+ db eval {SELECT (t1.b+coalesce((select case when e-13+11 | f+case when not t1.b not between t1.f and t1.f then e else (t1.e) end-c-b+c>=e and d between d and a then t1.c when (t1.c>19) then -11 else a end from t1 where a<d),e)+f+t1.e*d)*17 FROM t1 WHERE t1.b in (select cast(avg(17) AS integer) from t1 union select ~case (+abs(cast(avg((d)) AS integer))) when count(distinct case when (case when c>c then t1.e else -d end-t1.e) between b and 11 then b when exists(select 1 from t1 where a<=d) then 11 else 13 end) then cast(avg(t1.b) AS integer)-(cast(avg(11) AS integer)-min(a))-count(distinct -e) else cast(avg(13) AS integer) end*max(b) from t1) or (t1.f not between t1.d and 17 | 19*e)}
+} {}
+do_test randexpr-2.949 {
+ db eval {SELECT (t1.b+coalesce((select case when e-13+11 | f+case when not t1.b not between t1.f and t1.f then e else (t1.e) end-c-b+c>=e and d between d and a then t1.c when (t1.c>19) then -11 else a end from t1 where a<d),e)+f+t1.e*d)*17 FROM t1 WHERE NOT (t1.b in (select cast(avg(17) AS integer) from t1 union select ~case (+abs(cast(avg((d)) AS integer))) when count(distinct case when (case when c>c then t1.e else -d end-t1.e) between b and 11 then b when exists(select 1 from t1 where a<=d) then 11 else 13 end) then cast(avg(t1.b) AS integer)-(cast(avg(11) AS integer)-min(a))-count(distinct -e) else cast(avg(13) AS integer) end*max(b) from t1) or (t1.f not between t1.d and 17 | 19*e))}
+} {3413413}
+do_test randexpr-2.950 {
+ db eval {SELECT (t1.b+coalesce((select case when e-13+11 & f+case when not t1.b not between t1.f and t1.f then e else (t1.e) end-c-b+c>=e and d between d and a then t1.c when (t1.c>19) then -11 else a end from t1 where a<d),e)+f+t1.e*d)*17 FROM t1 WHERE NOT (t1.b in (select cast(avg(17) AS integer) from t1 union select ~case (+abs(cast(avg((d)) AS integer))) when count(distinct case when (case when c>c then t1.e else -d end-t1.e) between b and 11 then b when exists(select 1 from t1 where a<=d) then 11 else 13 end) then cast(avg(t1.b) AS integer)-(cast(avg(11) AS integer)-min(a))-count(distinct -e) else cast(avg(13) AS integer) end*max(b) from t1) or (t1.f not between t1.d and 17 | 19*e))}
+} {3413413}
+do_test randexpr-2.951 {
+ db eval {SELECT coalesce((select max(+19) from t1 where t1.f>=(abs(19)/abs(t1.c*(select count(distinct (abs(t1.f)/abs(t1.c))*coalesce((select max(case when (select count(*) from t1)*t1.f in (t1.b,17,t1.f) then d when t1.e not in (t1.b,t1.a,t1.b) then -17 else t1.d end) from t1 where (11 not in (t1.b,(f),t1.c)) and t1.c>=t1.f),e)) from t1))) or ((t1.d<=t1.b))),13) FROM t1 WHERE t1.a<>(coalesce((select coalesce((select max(t1.a) from t1 where case -t1.c when t1.b then coalesce((select t1.b from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where ((select count(*)++count(distinct a) from t1) not between b and +(17))))),19)*t1.e else f end<=(t1.b)),t1.c) from t1 where d<>b),13)-17+a)+d+(19)+a or d between 11 and -11}
+} {19}
+do_test randexpr-2.952 {
+ db eval {SELECT coalesce((select max(+19) from t1 where t1.f>=(abs(19)/abs(t1.c*(select count(distinct (abs(t1.f)/abs(t1.c))*coalesce((select max(case when (select count(*) from t1)*t1.f in (t1.b,17,t1.f) then d when t1.e not in (t1.b,t1.a,t1.b) then -17 else t1.d end) from t1 where (11 not in (t1.b,(f),t1.c)) and t1.c>=t1.f),e)) from t1))) or ((t1.d<=t1.b))),13) FROM t1 WHERE NOT (t1.a<>(coalesce((select coalesce((select max(t1.a) from t1 where case -t1.c when t1.b then coalesce((select t1.b from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where ((select count(*)++count(distinct a) from t1) not between b and +(17))))),19)*t1.e else f end<=(t1.b)),t1.c) from t1 where d<>b),13)-17+a)+d+(19)+a or d between 11 and -11)}
+} {}
+do_test randexpr-2.953 {
+ db eval {SELECT t1.b-coalesce((select max(~t1.a) from t1 where coalesce((select max(t1.d) from t1 where coalesce((select max(coalesce((select t1.c*t1.d from t1 where not f>=a-t1.c+ -coalesce((select t1.f*e from t1 where (not exists(select 1 from t1 where d<=19))),b)-d),13)* -e) from t1 where (d<19 or 13 not between t1.f and t1.d)),11) between 17 and 19),t1.c)< -b),d) FROM t1 WHERE +case when b in (b+~b+t1.f,coalesce((select max(13) from t1 where exists(select 1 from t1 where 17<>+a or not exists(select 1 from t1 where e+19=f))),(e)),case when c>case when coalesce((select 13 from t1 where f>=t1.b and c not between t1.e and t1.d),11) in (select (case max(11) when (min(b)) then min( -d) else cast(avg(t1.e) AS integer) end) from t1 union select max(19) from t1) then t1.d else 13 end then t1.f else t1.e end) or b>=(t1.f) then t1.e else t1.e end*b>f}
+} {-200}
+do_test randexpr-2.954 {
+ db eval {SELECT t1.b-coalesce((select max(~t1.a) from t1 where coalesce((select max(t1.d) from t1 where coalesce((select max(coalesce((select t1.c*t1.d from t1 where not f>=a-t1.c+ -coalesce((select t1.f*e from t1 where (not exists(select 1 from t1 where d<=19))),b)-d),13)* -e) from t1 where (d<19 or 13 not between t1.f and t1.d)),11) between 17 and 19),t1.c)< -b),d) FROM t1 WHERE NOT (+case when b in (b+~b+t1.f,coalesce((select max(13) from t1 where exists(select 1 from t1 where 17<>+a or not exists(select 1 from t1 where e+19=f))),(e)),case when c>case when coalesce((select 13 from t1 where f>=t1.b and c not between t1.e and t1.d),11) in (select (case max(11) when (min(b)) then min( -d) else cast(avg(t1.e) AS integer) end) from t1 union select max(19) from t1) then t1.d else 13 end then t1.f else t1.e end) or b>=(t1.f) then t1.e else t1.e end*b>f)}
+} {}
+do_test randexpr-2.955 {
+ db eval {SELECT (select count(distinct + - -f-c-17*a+(t1.d)-+((select abs( - - -count(distinct 13)-count(*)*count(distinct t1.d)*count(*))-cast(avg(f) AS integer) from t1))-~19+13- -d*t1.e*(19)+ -f- -b) from t1)-e FROM t1 WHERE not t1.c between t1.f and coalesce((select coalesce((select case when exists(select 1 from t1 where +~f=case when d<>t1.d then t1.f else -d end and d between 17 and t1.c) then ~case when a in (d,c,t1.d) then 17 else t1.f end when f=f then d else -b end from t1 where c>f),e) from t1 where not exists(select 1 from t1 where t1.d<=c) and 19=(11) and t1.e<>19),a)}
+} {-499}
+do_test randexpr-2.956 {
+ db eval {SELECT (select count(distinct + - -f-c-17*a+(t1.d)-+((select abs( - - -count(distinct 13)-count(*)*count(distinct t1.d)*count(*))-cast(avg(f) AS integer) from t1))-~19+13- -d*t1.e*(19)+ -f- -b) from t1)-e FROM t1 WHERE NOT (not t1.c between t1.f and coalesce((select coalesce((select case when exists(select 1 from t1 where +~f=case when d<>t1.d then t1.f else -d end and d between 17 and t1.c) then ~case when a in (d,c,t1.d) then 17 else t1.f end when f=f then d else -b end from t1 where c>f),e) from t1 where not exists(select 1 from t1 where t1.d<=c) and 19=(11) and t1.e<>19),a))}
+} {}
+do_test randexpr-2.957 {
+ db eval {SELECT case when f-t1.b*coalesce((select max(11) from t1 where exists(select 1 from t1 where (abs(t1.b)/abs(13-11))=(19+c))),coalesce((select t1.c | f from t1 where (abs(c*19)/abs(17))=t1.e),19))-e between t1.f and -((19)) and 13 not between t1.c and 11 and not exists(select 1 from t1 where t1.b>b) then t1.d when t1.c>=13 then c else f end FROM t1 WHERE e-t1.c=+e*~coalesce((select max(t1.f) from t1 where (t1.f in (coalesce((select max(11) from t1 where -13<>(13)-(select (count(*)) from t1)*t1.f and ( -11+t1.b+b*b-(select max(13) from t1)) in (t1.f,a,f)),d),17,13))),t1.f)-e}
+} {}
+do_test randexpr-2.958 {
+ db eval {SELECT case when f-t1.b*coalesce((select max(11) from t1 where exists(select 1 from t1 where (abs(t1.b)/abs(13-11))=(19+c))),coalesce((select t1.c | f from t1 where (abs(c*19)/abs(17))=t1.e),19))-e between t1.f and -((19)) and 13 not between t1.c and 11 and not exists(select 1 from t1 where t1.b>b) then t1.d when t1.c>=13 then c else f end FROM t1 WHERE NOT (e-t1.c=+e*~coalesce((select max(t1.f) from t1 where (t1.f in (coalesce((select max(11) from t1 where -13<>(13)-(select (count(*)) from t1)*t1.f and ( -11+t1.b+b*b-(select max(13) from t1)) in (t1.f,a,f)),d),17,13))),t1.f)-e)}
+} {300}
+do_test randexpr-2.959 {
+ db eval {SELECT case when f-t1.b*coalesce((select max(11) from t1 where exists(select 1 from t1 where (abs(t1.b)/abs(13-11))=(19+c))),coalesce((select t1.c & f from t1 where (abs(c*19)/abs(17))=t1.e),19))-e between t1.f and -((19)) and 13 not between t1.c and 11 and not exists(select 1 from t1 where t1.b>b) then t1.d when t1.c>=13 then c else f end FROM t1 WHERE NOT (e-t1.c=+e*~coalesce((select max(t1.f) from t1 where (t1.f in (coalesce((select max(11) from t1 where -13<>(13)-(select (count(*)) from t1)*t1.f and ( -11+t1.b+b*b-(select max(13) from t1)) in (t1.f,a,f)),d),17,13))),t1.f)-e)}
+} {300}
+do_test randexpr-2.960 {
+ db eval {SELECT t1.e+case when coalesce((select -(abs(t1.e)/abs(t1.c-t1.e)) from t1 where d | d between -t1.d and ~case t1.d when t1.f then ((abs((select ((min(b)+abs(cast(avg(t1.a) AS integer)*(max(19))))-(cast(avg(t1.d) AS integer))) from t1)*~f)/abs(t1.a*t1.c)))*17 else 19 end),f)- -c<>t1.c then f else t1.f end FROM t1 WHERE 19*coalesce((select max(a) from t1 where not (select count(distinct ~t1.b | t1.d) from t1)<case when b+(case when t1.c not in (f,(b),t1.c) then t1.d else 19 end)>t1.e then c when -b<11 then t1.c else -t1.e end and not d in ( -t1.d,t1.a,f) and c=t1.f and f<>t1.a),t1.b) between t1.a and b}
+} {}
+do_test randexpr-2.961 {
+ db eval {SELECT t1.e+case when coalesce((select -(abs(t1.e)/abs(t1.c-t1.e)) from t1 where d | d between -t1.d and ~case t1.d when t1.f then ((abs((select ((min(b)+abs(cast(avg(t1.a) AS integer)*(max(19))))-(cast(avg(t1.d) AS integer))) from t1)*~f)/abs(t1.a*t1.c)))*17 else 19 end),f)- -c<>t1.c then f else t1.f end FROM t1 WHERE NOT (19*coalesce((select max(a) from t1 where not (select count(distinct ~t1.b | t1.d) from t1)<case when b+(case when t1.c not in (f,(b),t1.c) then t1.d else 19 end)>t1.e then c when -b<11 then t1.c else -t1.e end and not d in ( -t1.d,t1.a,f) and c=t1.f and f<>t1.a),t1.b) between t1.a and b)}
+} {1100}
+do_test randexpr-2.962 {
+ db eval {SELECT t1.e+case when coalesce((select -(abs(t1.e)/abs(t1.c-t1.e)) from t1 where d & d between -t1.d and ~case t1.d when t1.f then ((abs((select ((min(b)+abs(cast(avg(t1.a) AS integer)*(max(19))))-(cast(avg(t1.d) AS integer))) from t1)*~f)/abs(t1.a*t1.c)))*17 else 19 end),f)- -c<>t1.c then f else t1.f end FROM t1 WHERE NOT (19*coalesce((select max(a) from t1 where not (select count(distinct ~t1.b | t1.d) from t1)<case when b+(case when t1.c not in (f,(b),t1.c) then t1.d else 19 end)>t1.e then c when -b<11 then t1.c else -t1.e end and not d in ( -t1.d,t1.a,f) and c=t1.f and f<>t1.a),t1.b) between t1.a and b)}
+} {1100}
+do_test randexpr-2.963 {
+ db eval {SELECT t1.b*coalesce((select max(e) from t1 where ((t1.d))<=case case when +coalesce((select (abs(t1.a)/abs(c))-(abs( -e)/abs(11* -t1.b+t1.d* -c))-t1.c from t1 where not exists(select 1 from t1 where t1.c=(11))), -11) between 17 and t1.a then t1.a when t1.b>t1.e then (b) else b end-c when d then d else t1.f end),((t1.e))) FROM t1 WHERE ~ -case when not exists(select 1 from t1 where t1.b between b and 11 | d) then -(abs(17+d)/abs(e)) else case when not (t1.d>=case when case a when case t1.f when (e) then 17 else 19 end then 13 else 19 end in (t1.e,b,((t1.b))) then d when t1.d not in (19,t1.a, -c) then 11 else -a end) then 11 else c end end*17*t1.b not in (a,b,13)}
+} {100000}
+do_test randexpr-2.964 {
+ db eval {SELECT t1.b*coalesce((select max(e) from t1 where ((t1.d))<=case case when +coalesce((select (abs(t1.a)/abs(c))-(abs( -e)/abs(11* -t1.b+t1.d* -c))-t1.c from t1 where not exists(select 1 from t1 where t1.c=(11))), -11) between 17 and t1.a then t1.a when t1.b>t1.e then (b) else b end-c when d then d else t1.f end),((t1.e))) FROM t1 WHERE NOT (~ -case when not exists(select 1 from t1 where t1.b between b and 11 | d) then -(abs(17+d)/abs(e)) else case when not (t1.d>=case when case a when case t1.f when (e) then 17 else 19 end then 13 else 19 end in (t1.e,b,((t1.b))) then d when t1.d not in (19,t1.a, -c) then 11 else -a end) then 11 else c end end*17*t1.b not in (a,b,13))}
+} {}
+do_test randexpr-2.965 {
+ db eval {SELECT e*case +case when not (select max(17) from t1)>=case when not d=c+t1.c then 11 else 11 end or (c in (select t1.c from t1 union select c from t1) or 11<=t1.a) or d<=11 or 19 in ( -13,d,19) or a not between 13 and (t1.c) then case when t1.f<=(t1.a) then t1.e+13*e when (t1.b) not between f and a then c else 11 end*11 else a end when 19 then t1.a else 17 end FROM t1 WHERE b<>17}
+} {8500}
+do_test randexpr-2.966 {
+ db eval {SELECT e*case +case when not (select max(17) from t1)>=case when not d=c+t1.c then 11 else 11 end or (c in (select t1.c from t1 union select c from t1) or 11<=t1.a) or d<=11 or 19 in ( -13,d,19) or a not between 13 and (t1.c) then case when t1.f<=(t1.a) then t1.e+13*e when (t1.b) not between f and a then c else 11 end*11 else a end when 19 then t1.a else 17 end FROM t1 WHERE NOT (b<>17)}
+} {}
+do_test randexpr-2.967 {
+ db eval {SELECT (abs(case when (13+e in (select min(a) | case abs(min(case when t1.e in (select b from t1 union select a from t1) then t1.e when t1.b=t1.c then t1.b else c end-f)) when ~(cast(avg(c) AS integer)) then min(t1.e) else count(*) end from t1 union select min(f) from t1)) and t1.d not between c and 13 then coalesce((select t1.d from t1 where t1.e<>a),19)-t1.d else 19 end)/abs(c))-c+11+c FROM t1 WHERE t1.e<f+11-b}
+} {}
+do_test randexpr-2.968 {
+ db eval {SELECT (abs(case when (13+e in (select min(a) | case abs(min(case when t1.e in (select b from t1 union select a from t1) then t1.e when t1.b=t1.c then t1.b else c end-f)) when ~(cast(avg(c) AS integer)) then min(t1.e) else count(*) end from t1 union select min(f) from t1)) and t1.d not between c and 13 then coalesce((select t1.d from t1 where t1.e<>a),19)-t1.d else 19 end)/abs(c))-c+11+c FROM t1 WHERE NOT (t1.e<f+11-b)}
+} {11}
+do_test randexpr-2.969 {
+ db eval {SELECT (abs(case when (13+e in (select min(a) & case abs(min(case when t1.e in (select b from t1 union select a from t1) then t1.e when t1.b=t1.c then t1.b else c end-f)) when ~(cast(avg(c) AS integer)) then min(t1.e) else count(*) end from t1 union select min(f) from t1)) and t1.d not between c and 13 then coalesce((select t1.d from t1 where t1.e<>a),19)-t1.d else 19 end)/abs(c))-c+11+c FROM t1 WHERE NOT (t1.e<f+11-b)}
+} {11}
+do_test randexpr-2.970 {
+ db eval {SELECT case when case when not exists(select 1 from t1 where (11 not between ~~t1.d-case c when coalesce((select case f when coalesce((select max(t1.f) from t1 where 11 not in (((13)),d,t1.d)),11) then f else a end from t1 where 11 not between (t1.a) and 17),t1.c)-c*17 then (17) else t1.b end+t1.d+t1.a and d)) then t1.e-11+19 else (d) end*d<=11 then t1.b else f end FROM t1 WHERE not exists(select 1 from t1 where d>=t1.f)}
+} {600}
+do_test randexpr-2.971 {
+ db eval {SELECT case when case when not exists(select 1 from t1 where (11 not between ~~t1.d-case c when coalesce((select case f when coalesce((select max(t1.f) from t1 where 11 not in (((13)),d,t1.d)),11) then f else a end from t1 where 11 not between (t1.a) and 17),t1.c)-c*17 then (17) else t1.b end+t1.d+t1.a and d)) then t1.e-11+19 else (d) end*d<=11 then t1.b else f end FROM t1 WHERE NOT (not exists(select 1 from t1 where d>=t1.f))}
+} {}
+do_test randexpr-2.972 {
+ db eval {SELECT 13 | t1.c+case when (not t1.d-c between +t1.b and -coalesce((select (select count(distinct 17) from t1)*a from t1 where -case when not t1.f in (select count(distinct 13) from t1 union select min( -t1.a) from t1) then case when (t1.e)< -11 then -c else t1.a end else d end-c*t1.a-d+ -e-t1.a not in (17,e,t1.a)),b) | t1.f) then c else 11 end FROM t1 WHERE case when (+e | (t1.e) | 11)<>b then t1.b when t1.e<>~(case when (t1.a*b) in (select d from t1 union select b from t1) or t1.c not in (t1.a,t1.d,13) and t1.f in (select case min(19) when min(17) then min(19) else count(distinct t1.e) end from t1 union select (count(*)) from t1) then t1.f else b end)+11 then b else 13 end+t1.d between b and 17}
+} {}
+do_test randexpr-2.973 {
+ db eval {SELECT 13 | t1.c+case when (not t1.d-c between +t1.b and -coalesce((select (select count(distinct 17) from t1)*a from t1 where -case when not t1.f in (select count(distinct 13) from t1 union select min( -t1.a) from t1) then case when (t1.e)< -11 then -c else t1.a end else d end-c*t1.a-d+ -e-t1.a not in (17,e,t1.a)),b) | t1.f) then c else 11 end FROM t1 WHERE NOT (case when (+e | (t1.e) | 11)<>b then t1.b when t1.e<>~(case when (t1.a*b) in (select d from t1 union select b from t1) or t1.c not in (t1.a,t1.d,13) and t1.f in (select case min(19) when min(17) then min(19) else count(distinct t1.e) end from t1 union select (count(*)) from t1) then t1.f else b end)+11 then b else 13 end+t1.d between b and 17)}
+} {605}
+do_test randexpr-2.974 {
+ db eval {SELECT 13 & t1.c+case when (not t1.d-c between +t1.b and -coalesce((select (select count(distinct 17) from t1)*a from t1 where -case when not t1.f in (select count(distinct 13) from t1 union select min( -t1.a) from t1) then case when (t1.e)< -11 then -c else t1.a end else d end-c*t1.a-d+ -e-t1.a not in (17,e,t1.a)),b) & t1.f) then c else 11 end FROM t1 WHERE NOT (case when (+e | (t1.e) | 11)<>b then t1.b when t1.e<>~(case when (t1.a*b) in (select d from t1 union select b from t1) or t1.c not in (t1.a,t1.d,13) and t1.f in (select case min(19) when min(17) then min(19) else count(distinct t1.e) end from t1 union select (count(*)) from t1) then t1.f else b end)+11 then b else 13 end+t1.d between b and 17)}
+} {8}
+do_test randexpr-2.975 {
+ db eval {SELECT case when case when t1.a<>t1.d then d*t1.a*11-e-(+11+d)-e else (select case -count(distinct t1.e) when cast(avg(b) AS integer) then count(distinct t1.d) else cast(avg(13) AS integer) end*cast(avg(19) AS integer) from t1) end<>case e when e then t1.e else (t1.f) end or not exists(select 1 from t1 where 19=f) and -t1.d>t1.e then t1.e+e*e when 11=t1.c then e else c end FROM t1 WHERE ~c>(case when t1.e<=e then case when case when 17+f in (d,t1.d | t1.c,t1.b) and 13<>19 or not t1.c<f then coalesce((select max(b) from t1 where c not between b and t1.c),c)+(17) when d<=t1.c then t1.b else t1.c end-b not in (a,f,11) then c else 17 end else f end)}
+} {}
+do_test randexpr-2.976 {
+ db eval {SELECT case when case when t1.a<>t1.d then d*t1.a*11-e-(+11+d)-e else (select case -count(distinct t1.e) when cast(avg(b) AS integer) then count(distinct t1.d) else cast(avg(13) AS integer) end*cast(avg(19) AS integer) from t1) end<>case e when e then t1.e else (t1.f) end or not exists(select 1 from t1 where 19=f) and -t1.d>t1.e then t1.e+e*e when 11=t1.c then e else c end FROM t1 WHERE NOT (~c>(case when t1.e<=e then case when case when 17+f in (d,t1.d | t1.c,t1.b) and 13<>19 or not t1.c<f then coalesce((select max(b) from t1 where c not between b and t1.c),c)+(17) when d<=t1.c then t1.b else t1.c end-b not in (a,f,11) then c else 17 end else f end))}
+} {250500}
+do_test randexpr-2.977 {
+ db eval {SELECT case when (13 in (select ~t1.c from t1 union select case when t1.a in (select t1.f-t1.e | t1.c+19 from t1 union select coalesce((select max(13) from t1 where e in (select ~19-(select case count(*)-cast(avg(c) AS integer) when cast(avg(t1.f) AS integer) then -max(d) else min(t1.d) end | ( -cast(avg(t1.a) AS integer)) from t1)-b*d-coalesce((select max(f) from t1 where not t1.c=c),b) from t1 union select 13 from t1)),a) from t1) then t1.c else t1.b end from t1)) then (abs(c)/abs(19)) else c end FROM t1 WHERE coalesce((select -case (select count(*) from t1) when d*+b then a else d end from t1 where b not in (11*case t1.e when case +coalesce((select b+19*+case t1.c when t1.a then t1.b else t1.f end*f*11 from t1 where t1.a=t1.f),c) when t1.e then 17 else d end then t1.f else t1.b end,f,d)),t1.d) in (13,e, -b)}
+} {}
+do_test randexpr-2.978 {
+ db eval {SELECT case when (13 in (select ~t1.c from t1 union select case when t1.a in (select t1.f-t1.e | t1.c+19 from t1 union select coalesce((select max(13) from t1 where e in (select ~19-(select case count(*)-cast(avg(c) AS integer) when cast(avg(t1.f) AS integer) then -max(d) else min(t1.d) end | ( -cast(avg(t1.a) AS integer)) from t1)-b*d-coalesce((select max(f) from t1 where not t1.c=c),b) from t1 union select 13 from t1)),a) from t1) then t1.c else t1.b end from t1)) then (abs(c)/abs(19)) else c end FROM t1 WHERE NOT (coalesce((select -case (select count(*) from t1) when d*+b then a else d end from t1 where b not in (11*case t1.e when case +coalesce((select b+19*+case t1.c when t1.a then t1.b else t1.f end*f*11 from t1 where t1.a=t1.f),c) when t1.e then 17 else d end then t1.f else t1.b end,f,d)),t1.d) in (13,e, -b))}
+} {300}
+do_test randexpr-2.979 {
+ db eval {SELECT case when (13 in (select ~t1.c from t1 union select case when t1.a in (select t1.f-t1.e & t1.c+19 from t1 union select coalesce((select max(13) from t1 where e in (select ~19-(select case count(*)-cast(avg(c) AS integer) when cast(avg(t1.f) AS integer) then -max(d) else min(t1.d) end & ( -cast(avg(t1.a) AS integer)) from t1)-b*d-coalesce((select max(f) from t1 where not t1.c=c),b) from t1 union select 13 from t1)),a) from t1) then t1.c else t1.b end from t1)) then (abs(c)/abs(19)) else c end FROM t1 WHERE NOT (coalesce((select -case (select count(*) from t1) when d*+b then a else d end from t1 where b not in (11*case t1.e when case +coalesce((select b+19*+case t1.c when t1.a then t1.b else t1.f end*f*11 from t1 where t1.a=t1.f),c) when t1.e then 17 else d end then t1.f else t1.b end,f,d)),t1.d) in (13,e, -b))}
+} {300}
+do_test randexpr-2.980 {
+ db eval {SELECT ~case when exists(select 1 from t1 where ((coalesce((select d from t1 where t1.e-f | +t1.d between t1.c and t1.a or exists(select 1 from t1 where 19 in (11,11,13)) and 17 in (select case min(d) when count(*) then (min(13)) else -(cast(avg( -c) AS integer)) end*count(distinct 19) from t1 union select count(distinct e) from t1)),f) | c*b<= -b or not not t1.c<13 or (t1.f)>=t1.f))) and t1.c not in (17,b,e) then a else (select count(distinct t1.d) from t1) end FROM t1 WHERE (select (count(*)) from t1) between 11 and t1.d}
+} {}
+do_test randexpr-2.981 {
+ db eval {SELECT ~case when exists(select 1 from t1 where ((coalesce((select d from t1 where t1.e-f | +t1.d between t1.c and t1.a or exists(select 1 from t1 where 19 in (11,11,13)) and 17 in (select case min(d) when count(*) then (min(13)) else -(cast(avg( -c) AS integer)) end*count(distinct 19) from t1 union select count(distinct e) from t1)),f) | c*b<= -b or not not t1.c<13 or (t1.f)>=t1.f))) and t1.c not in (17,b,e) then a else (select count(distinct t1.d) from t1) end FROM t1 WHERE NOT ((select (count(*)) from t1) between 11 and t1.d)}
+} {-101}
+do_test randexpr-2.982 {
+ db eval {SELECT ~case when exists(select 1 from t1 where ((coalesce((select d from t1 where t1.e-f & +t1.d between t1.c and t1.a or exists(select 1 from t1 where 19 in (11,11,13)) and 17 in (select case min(d) when count(*) then (min(13)) else -(cast(avg( -c) AS integer)) end*count(distinct 19) from t1 union select count(distinct e) from t1)),f) & c*b<= -b or not not t1.c<13 or (t1.f)>=t1.f))) and t1.c not in (17,b,e) then a else (select count(distinct t1.d) from t1) end FROM t1 WHERE NOT ((select (count(*)) from t1) between 11 and t1.d)}
+} {-101}
+do_test randexpr-2.983 {
+ db eval {SELECT coalesce((select max(b) from t1 where not not c*t1.e>=19 or case when 17<=t1.b and case when 13 not between d and -f then case e when 11 then case when e in (select ( -d) from t1 union select e from t1) and 19<=(a) then t1.a else (19) end else f end else t1.a end+t1.a<19 then ~d when e in (a,11, -b) then b else e end not between f and 13),a) FROM t1 WHERE t1.a>=+a}
+} {200}
+do_test randexpr-2.984 {
+ db eval {SELECT coalesce((select max(b) from t1 where not not c*t1.e>=19 or case when 17<=t1.b and case when 13 not between d and -f then case e when 11 then case when e in (select ( -d) from t1 union select e from t1) and 19<=(a) then t1.a else (19) end else f end else t1.a end+t1.a<19 then ~d when e in (a,11, -b) then b else e end not between f and 13),a) FROM t1 WHERE NOT (t1.a>=+a)}
+} {}
+do_test randexpr-2.985 {
+ db eval {SELECT case when case when 11 between a+a+t1.b and b then c*e-t1.c*t1.a when +b<= -t1.c-t1.e-19*t1.b+c*t1.b then e else d end-(11)-e<d then 11 when 13=t1.e then a else 13 end+c-d FROM t1 WHERE ~coalesce((select max((select count(*) from t1)+t1.f) from t1 where 17 in (~t1.a,d,13)), -(select max(13) from t1) | coalesce((select c from t1 where t1.e* -coalesce((select 17 from t1 where (abs(t1.a+t1.d)/abs(t1.f))*t1.e | 17 | 11 not in ((t1.d),c,t1.c)),13)*13 in (11,t1.e,a)),19)) in (13,13,c)}
+} {}
+do_test randexpr-2.986 {
+ db eval {SELECT case when case when 11 between a+a+t1.b and b then c*e-t1.c*t1.a when +b<= -t1.c-t1.e-19*t1.b+c*t1.b then e else d end-(11)-e<d then 11 when 13=t1.e then a else 13 end+c-d FROM t1 WHERE NOT (~coalesce((select max((select count(*) from t1)+t1.f) from t1 where 17 in (~t1.a,d,13)), -(select max(13) from t1) | coalesce((select c from t1 where t1.e* -coalesce((select 17 from t1 where (abs(t1.a+t1.d)/abs(t1.f))*t1.e | 17 | 11 not in ((t1.d),c,t1.c)),13)*13 in (11,t1.e,a)),19)) in (13,13,c))}
+} {-89}
+do_test randexpr-2.987 {
+ db eval {SELECT c-case 17 when c+b-t1.a-a*coalesce((select max(t1.c) from t1 where t1.b- -(abs(13)/abs(t1.e)) in (case t1.f when f then coalesce((select max(coalesce((select 13 from t1 where exists(select 1 from t1 where f not between e and c)),e)) from t1 where d not between t1.a and 13),d)-b else a end, -13,(t1.f)) and 13 between e and 17),a) | a then t1.d else e end+ -t1.e FROM t1 WHERE not exists(select 1 from t1 where coalesce((select -+t1.c | case when a in (select case max(+b) when ~count(*) then count(*) else (abs((max(f)))) end from t1 union select -max(e) from t1) then case when (t1.d>=11) or t1.c not between t1.d and - -11 then t1.a when 11 not between -t1.e and t1.a then 11 else t1.b end when (d not in (a,c,19)) then f else c end*17 from t1 where -11<=t1.c),t1.c)+f not in (t1.f, -d,19))}
+} {}
+do_test randexpr-2.988 {
+ db eval {SELECT c-case 17 when c+b-t1.a-a*coalesce((select max(t1.c) from t1 where t1.b- -(abs(13)/abs(t1.e)) in (case t1.f when f then coalesce((select max(coalesce((select 13 from t1 where exists(select 1 from t1 where f not between e and c)),e)) from t1 where d not between t1.a and 13),d)-b else a end, -13,(t1.f)) and 13 between e and 17),a) | a then t1.d else e end+ -t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select -+t1.c | case when a in (select case max(+b) when ~count(*) then count(*) else (abs((max(f)))) end from t1 union select -max(e) from t1) then case when (t1.d>=11) or t1.c not between t1.d and - -11 then t1.a when 11 not between -t1.e and t1.a then 11 else t1.b end when (d not in (a,c,19)) then f else c end*17 from t1 where -11<=t1.c),t1.c)+f not in (t1.f, -d,19)))}
+} {-700}
+do_test randexpr-2.989 {
+ db eval {SELECT c-case 17 when c+b-t1.a-a*coalesce((select max(t1.c) from t1 where t1.b- -(abs(13)/abs(t1.e)) in (case t1.f when f then coalesce((select max(coalesce((select 13 from t1 where exists(select 1 from t1 where f not between e and c)),e)) from t1 where d not between t1.a and 13),d)-b else a end, -13,(t1.f)) and 13 between e and 17),a) & a then t1.d else e end+ -t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select -+t1.c | case when a in (select case max(+b) when ~count(*) then count(*) else (abs((max(f)))) end from t1 union select -max(e) from t1) then case when (t1.d>=11) or t1.c not between t1.d and - -11 then t1.a when 11 not between -t1.e and t1.a then 11 else t1.b end when (d not in (a,c,19)) then f else c end*17 from t1 where -11<=t1.c),t1.c)+f not in (t1.f, -d,19)))}
+} {-700}
+do_test randexpr-2.990 {
+ db eval {SELECT (select ( -count(distinct case case a when e then c*case when e<=t1.d+b then a when (abs(t1.f)/abs(case when b-coalesce((select max(t1.f-t1.b) from t1 where not exists(select 1 from t1 where 17 in (b,13,(b)) or b in (d,c,t1.e))),t1.b) not in (d,((c)),t1.b) then -19 when c between a and 13 then 19 else t1.f end))=13 then f else 13 end else 17 end when 13 then t1.f else t1.b end-t1.c)) from t1) FROM t1 WHERE coalesce((select max(t1.d) from t1 where t1.c<>t1.c-13),t1.a)>=d or b*coalesce((select max((d)) from t1 where c not between +coalesce((select max(13) from t1 where e between -(abs(( -coalesce((select max(case f when t1.f then e else -t1.c end) from t1 where 11>e and t1.b<t1.e),t1.c)))/abs(b)) and d),a) and t1.e),t1.b)* -19 not between (17) and t1.f and (t1.e<=a)}
+} {-1}
+do_test randexpr-2.991 {
+ db eval {SELECT (select ( -count(distinct case case a when e then c*case when e<=t1.d+b then a when (abs(t1.f)/abs(case when b-coalesce((select max(t1.f-t1.b) from t1 where not exists(select 1 from t1 where 17 in (b,13,(b)) or b in (d,c,t1.e))),t1.b) not in (d,((c)),t1.b) then -19 when c between a and 13 then 19 else t1.f end))=13 then f else 13 end else 17 end when 13 then t1.f else t1.b end-t1.c)) from t1) FROM t1 WHERE NOT (coalesce((select max(t1.d) from t1 where t1.c<>t1.c-13),t1.a)>=d or b*coalesce((select max((d)) from t1 where c not between +coalesce((select max(13) from t1 where e between -(abs(( -coalesce((select max(case f when t1.f then e else -t1.c end) from t1 where 11>e and t1.b<t1.e),t1.c)))/abs(b)) and d),a) and t1.e),t1.b)* -19 not between (17) and t1.f and (t1.e<=a))}
+} {}
+do_test randexpr-2.992 {
+ db eval {SELECT case when (11=(t1.b)) then t1.c-coalesce((select case when t1.f*c-b<>b then t1.a else e end | f from t1 where 13 in (select abs(~max((17))) from t1 union select cast(avg(t1.b) AS integer)-min(19) from t1)), -t1.a) when c<d or (e=17 or t1.f in (select min(t1.a) from t1 union select max(a) from t1)) then e else d end*b+t1.e FROM t1 WHERE (select case case case cast(avg(+(select abs(+count(distinct t1.d)-count(distinct t1.b) | max(17)) | -cast(avg(f) AS integer)*count(*) from t1)) AS integer) when -count(*)* - -max(b) then (count(distinct 19)) else max(t1.e) end when count(*) then count(*) else cast(avg(t1.c) AS integer) end when max(c) then (cast(avg(t1.c) AS integer)) else min(t1.f) end-max(17) | min((11)) from t1)<>+case ~e+~t1.d | 13 when case when t1.c<=t1.c or (11)=t1.a then 11 when -11 in (17,11, -d) then t1.a else t1.b end then 19 else 13 end* -t1.c}
+} {100500}
+do_test randexpr-2.993 {
+ db eval {SELECT case when (11=(t1.b)) then t1.c-coalesce((select case when t1.f*c-b<>b then t1.a else e end | f from t1 where 13 in (select abs(~max((17))) from t1 union select cast(avg(t1.b) AS integer)-min(19) from t1)), -t1.a) when c<d or (e=17 or t1.f in (select min(t1.a) from t1 union select max(a) from t1)) then e else d end*b+t1.e FROM t1 WHERE NOT ((select case case case cast(avg(+(select abs(+count(distinct t1.d)-count(distinct t1.b) | max(17)) | -cast(avg(f) AS integer)*count(*) from t1)) AS integer) when -count(*)* - -max(b) then (count(distinct 19)) else max(t1.e) end when count(*) then count(*) else cast(avg(t1.c) AS integer) end when max(c) then (cast(avg(t1.c) AS integer)) else min(t1.f) end-max(17) | min((11)) from t1)<>+case ~e+~t1.d | 13 when case when t1.c<=t1.c or (11)=t1.a then 11 when -11 in (17,11, -d) then t1.a else t1.b end then 19 else 13 end* -t1.c)}
+} {}
+do_test randexpr-2.994 {
+ db eval {SELECT case when (11=(t1.b)) then t1.c-coalesce((select case when t1.f*c-b<>b then t1.a else e end & f from t1 where 13 in (select abs(~max((17))) from t1 union select cast(avg(t1.b) AS integer)-min(19) from t1)), -t1.a) when c<d or (e=17 or t1.f in (select min(t1.a) from t1 union select max(a) from t1)) then e else d end*b+t1.e FROM t1 WHERE (select case case case cast(avg(+(select abs(+count(distinct t1.d)-count(distinct t1.b) | max(17)) | -cast(avg(f) AS integer)*count(*) from t1)) AS integer) when -count(*)* - -max(b) then (count(distinct 19)) else max(t1.e) end when count(*) then count(*) else cast(avg(t1.c) AS integer) end when max(c) then (cast(avg(t1.c) AS integer)) else min(t1.f) end-max(17) | min((11)) from t1)<>+case ~e+~t1.d | 13 when case when t1.c<=t1.c or (11)=t1.a then 11 when -11 in (17,11, -d) then t1.a else t1.b end then 19 else 13 end* -t1.c}
+} {100500}
+do_test randexpr-2.995 {
+ db eval {SELECT case when (f in (select count(distinct 17) from t1 union select count(distinct t1.b) from t1)) then d when e in (coalesce((select max(e+e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where 11-t1.a in (select case -max(11)-max(b) when min(t1.f) then count(distinct f) else count(distinct t1.c) end | count(*) from t1 union select min( -a) from t1)) and t1.e in (select count(distinct -t1.e) from t1 union select count(distinct a) from t1) and d not in (b,f,t1.d)) and a between t1.c and t1.e),f),c,11) then c else t1.f end | a FROM t1 WHERE coalesce((select a from t1 where t1.a | (17-coalesce((select t1.b from t1 where ~t1.f | t1.e=d and a<=19+(select (cast(avg(c) AS integer)) from t1)),t1.c))+t1.e*t1.d+t1.c not between t1.d and 19), -t1.d) in (select (count(*)) from t1 union select (++~min(c)*+max(t1.a)+cast(avg( -(t1.e)) AS integer)) from t1)}
+} {}
+do_test randexpr-2.996 {
+ db eval {SELECT case when (f in (select count(distinct 17) from t1 union select count(distinct t1.b) from t1)) then d when e in (coalesce((select max(e+e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where 11-t1.a in (select case -max(11)-max(b) when min(t1.f) then count(distinct f) else count(distinct t1.c) end | count(*) from t1 union select min( -a) from t1)) and t1.e in (select count(distinct -t1.e) from t1 union select count(distinct a) from t1) and d not in (b,f,t1.d)) and a between t1.c and t1.e),f),c,11) then c else t1.f end | a FROM t1 WHERE NOT (coalesce((select a from t1 where t1.a | (17-coalesce((select t1.b from t1 where ~t1.f | t1.e=d and a<=19+(select (cast(avg(c) AS integer)) from t1)),t1.c))+t1.e*t1.d+t1.c not between t1.d and 19), -t1.d) in (select (count(*)) from t1 union select (++~min(c)*+max(t1.a)+cast(avg( -(t1.e)) AS integer)) from t1))}
+} {636}
+do_test randexpr-2.997 {
+ db eval {SELECT case when (f in (select count(distinct 17) from t1 union select count(distinct t1.b) from t1)) then d when e in (coalesce((select max(e+e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where 11-t1.a in (select case -max(11)-max(b) when min(t1.f) then count(distinct f) else count(distinct t1.c) end & count(*) from t1 union select min( -a) from t1)) and t1.e in (select count(distinct -t1.e) from t1 union select count(distinct a) from t1) and d not in (b,f,t1.d)) and a between t1.c and t1.e),f),c,11) then c else t1.f end & a FROM t1 WHERE NOT (coalesce((select a from t1 where t1.a | (17-coalesce((select t1.b from t1 where ~t1.f | t1.e=d and a<=19+(select (cast(avg(c) AS integer)) from t1)),t1.c))+t1.e*t1.d+t1.c not between t1.d and 19), -t1.d) in (select (count(*)) from t1 union select (++~min(c)*+max(t1.a)+cast(avg( -(t1.e)) AS integer)) from t1))}
+} {64}
+do_test randexpr-2.998 {
+ db eval {SELECT case when coalesce((select t1.b from t1 where a not in (19,coalesce((select max(t1.f) from t1 where (select count(distinct t1.b) from t1) in (t1.e,t1.f*13-11,d)),(t1.f))-17*c,c) or t1.c<=11),19)>13 and f not in (t1.a,11,t1.d) then (((e))) when f=11 or f not in (a,19,17) then 13 else e end FROM t1 WHERE c in (select min(t1.a*a+(select count(distinct t1.b+(t1.a)- - -c) from t1)-t1.e) from t1 union select count(*) from t1) and c in (select min(t1.d) from t1 union select cast(avg(d) AS integer)+abs(case count(*) when count(distinct 11) then -count(distinct 19) else count(distinct (t1.b)) end) | cast(avg((t1.c)) AS integer)+count(*) from t1) and e=13 and t1.d>c or 13 not in (17,(t1.f),t1.a) or (11)=t1.b and t1.e>=a or 11<=t1.b or d<=17}
+} {500}
+do_test randexpr-2.999 {
+ db eval {SELECT case when coalesce((select t1.b from t1 where a not in (19,coalesce((select max(t1.f) from t1 where (select count(distinct t1.b) from t1) in (t1.e,t1.f*13-11,d)),(t1.f))-17*c,c) or t1.c<=11),19)>13 and f not in (t1.a,11,t1.d) then (((e))) when f=11 or f not in (a,19,17) then 13 else e end FROM t1 WHERE NOT (c in (select min(t1.a*a+(select count(distinct t1.b+(t1.a)- - -c) from t1)-t1.e) from t1 union select count(*) from t1) and c in (select min(t1.d) from t1 union select cast(avg(d) AS integer)+abs(case count(*) when count(distinct 11) then -count(distinct 19) else count(distinct (t1.b)) end) | cast(avg((t1.c)) AS integer)+count(*) from t1) and e=13 and t1.d>c or 13 not in (17,(t1.f),t1.a) or (11)=t1.b and t1.e>=a or 11<=t1.b or d<=17)}
+} {}
+do_test randexpr-2.1000 {
+ db eval {SELECT case when t1.d not between (abs(d)/abs(t1.e))+t1.f*t1.a*a and 17*e then case when 11 between a and coalesce((select max(t1.b) from t1 where (case when t1.e+(t1.b) not in (t1.e,d,f) or 13<>17 then 17 when a>e then 11 else a end in (select count(*) from t1 union select min(a) from t1))),17) then 19 when -11 in (select t1.c from t1 union select -19 from t1) or - - -t1.e=t1.a then 17 else t1.a end else t1.e end FROM t1 WHERE (select +count(distinct f) from t1)-t1.f between t1.f and c}
+} {}
+do_test randexpr-2.1001 {
+ db eval {SELECT case when t1.d not between (abs(d)/abs(t1.e))+t1.f*t1.a*a and 17*e then case when 11 between a and coalesce((select max(t1.b) from t1 where (case when t1.e+(t1.b) not in (t1.e,d,f) or 13<>17 then 17 when a>e then 11 else a end in (select count(*) from t1 union select min(a) from t1))),17) then 19 when -11 in (select t1.c from t1 union select -19 from t1) or - - -t1.e=t1.a then 17 else t1.a end else t1.e end FROM t1 WHERE NOT ((select +count(distinct f) from t1)-t1.f between t1.f and c)}
+} {100}
+do_test randexpr-2.1002 {
+ db eval {SELECT case when (case when e between t1.b and c+(select cast(avg( -case c when a then t1.f+c else 17 end) AS integer) from t1) then t1.e when not 19>=t1.a then 17 else d end in (select cast(avg(13) AS integer)-max(11) | +count(*) from t1 union select case (cast(avg(d) AS integer)) when min(a) then abs( -max(19)) else count(*) end from t1)) then (t1.a) else c end | -e*a FROM t1 WHERE f*t1.d*(abs(case d when coalesce((select max((abs(t1.e)/abs(t1.f))) from t1 where ((e between (b) and 13) or t1.d=(c)) and t1.f between 17 and t1.e),a) then -b else -e end+ -t1.e)/abs(t1.c))+f<=17 or t1.f not between f and t1.e or (t1.c in (select 17 from t1 union select f from t1)) or exists(select 1 from t1 where (a not in (d,t1.a,t1.e) and t1.a in (t1.a,c,19))) and f not in (t1.d,t1.c,c)}
+} {-49732}
+do_test randexpr-2.1003 {
+ db eval {SELECT case when (case when e between t1.b and c+(select cast(avg( -case c when a then t1.f+c else 17 end) AS integer) from t1) then t1.e when not 19>=t1.a then 17 else d end in (select cast(avg(13) AS integer)-max(11) | +count(*) from t1 union select case (cast(avg(d) AS integer)) when min(a) then abs( -max(19)) else count(*) end from t1)) then (t1.a) else c end | -e*a FROM t1 WHERE NOT (f*t1.d*(abs(case d when coalesce((select max((abs(t1.e)/abs(t1.f))) from t1 where ((e between (b) and 13) or t1.d=(c)) and t1.f between 17 and t1.e),a) then -b else -e end+ -t1.e)/abs(t1.c))+f<=17 or t1.f not between f and t1.e or (t1.c in (select 17 from t1 union select f from t1)) or exists(select 1 from t1 where (a not in (d,t1.a,t1.e) and t1.a in (t1.a,c,19))) and f not in (t1.d,t1.c,c))}
+} {}
+do_test randexpr-2.1004 {
+ db eval {SELECT case when (case when e between t1.b and c+(select cast(avg( -case c when a then t1.f+c else 17 end) AS integer) from t1) then t1.e when not 19>=t1.a then 17 else d end in (select cast(avg(13) AS integer)-max(11) & +count(*) from t1 union select case (cast(avg(d) AS integer)) when min(a) then abs( -max(19)) else count(*) end from t1)) then (t1.a) else c end & -e*a FROM t1 WHERE f*t1.d*(abs(case d when coalesce((select max((abs(t1.e)/abs(t1.f))) from t1 where ((e between (b) and 13) or t1.d=(c)) and t1.f between 17 and t1.e),a) then -b else -e end+ -t1.e)/abs(t1.c))+f<=17 or t1.f not between f and t1.e or (t1.c in (select 17 from t1 union select f from t1)) or exists(select 1 from t1 where (a not in (d,t1.a,t1.e) and t1.a in (t1.a,c,19))) and f not in (t1.d,t1.c,c)}
+} {32}
+do_test randexpr-2.1005 {
+ db eval {SELECT -case coalesce((select case when f<>t1.d | c-(e)*t1.b and 17 in (select t1.b from t1 union select -(t1.c) from t1) or t1.e>=11 and t1.f not between b and f or e not in (11,19,t1.e) and t1.c<=a then coalesce((select max(t1.f+t1.f) from t1 where -t1.a<t1.f),t1.c) when e not in (t1.c,t1.d,t1.e) then t1.f else t1.e end-d from t1 where e>=13),e) when t1.e then c else t1.a end FROM t1 WHERE coalesce((select t1.f from t1 where (t1.e>=case (abs(11)/abs(t1.a)) when 11 then case t1.c when t1.a then t1.e else a end else t1.f end+t1.d) and (exists(select 1 from t1 where t1.b not in (t1.b,a,19))) or t1.a>=11),(select abs((~cast(avg(t1.b) AS integer)-~cast(avg((t1.b)) AS integer)* -count(*))+ -count(distinct t1.b)) from t1)*19)<=f and b in (select count(*) from t1 union select -min(d) from t1)}
+} {}
+do_test randexpr-2.1006 {
+ db eval {SELECT -case coalesce((select case when f<>t1.d | c-(e)*t1.b and 17 in (select t1.b from t1 union select -(t1.c) from t1) or t1.e>=11 and t1.f not between b and f or e not in (11,19,t1.e) and t1.c<=a then coalesce((select max(t1.f+t1.f) from t1 where -t1.a<t1.f),t1.c) when e not in (t1.c,t1.d,t1.e) then t1.f else t1.e end-d from t1 where e>=13),e) when t1.e then c else t1.a end FROM t1 WHERE NOT (coalesce((select t1.f from t1 where (t1.e>=case (abs(11)/abs(t1.a)) when 11 then case t1.c when t1.a then t1.e else a end else t1.f end+t1.d) and (exists(select 1 from t1 where t1.b not in (t1.b,a,19))) or t1.a>=11),(select abs((~cast(avg(t1.b) AS integer)-~cast(avg((t1.b)) AS integer)* -count(*))+ -count(distinct t1.b)) from t1)*19)<=f and b in (select count(*) from t1 union select -min(d) from t1))}
+} {-100}
+do_test randexpr-2.1007 {
+ db eval {SELECT -case coalesce((select case when f<>t1.d & c-(e)*t1.b and 17 in (select t1.b from t1 union select -(t1.c) from t1) or t1.e>=11 and t1.f not between b and f or e not in (11,19,t1.e) and t1.c<=a then coalesce((select max(t1.f+t1.f) from t1 where -t1.a<t1.f),t1.c) when e not in (t1.c,t1.d,t1.e) then t1.f else t1.e end-d from t1 where e>=13),e) when t1.e then c else t1.a end FROM t1 WHERE NOT (coalesce((select t1.f from t1 where (t1.e>=case (abs(11)/abs(t1.a)) when 11 then case t1.c when t1.a then t1.e else a end else t1.f end+t1.d) and (exists(select 1 from t1 where t1.b not in (t1.b,a,19))) or t1.a>=11),(select abs((~cast(avg(t1.b) AS integer)-~cast(avg((t1.b)) AS integer)* -count(*))+ -count(distinct t1.b)) from t1)*19)<=f and b in (select count(*) from t1 union select -min(d) from t1))}
+} {-100}
+do_test randexpr-2.1008 {
+ db eval {SELECT case when exists(select 1 from t1 where exists(select 1 from t1 where -case when t1.d<=coalesce((select t1.d | (f)*t1.a from t1 where not exists(select 1 from t1 where t1.f not in ((e),t1.e,13) or t1.a not between a and -t1.d or (f) not between f and 13)),19) then e when (t1.f)<19 or e<=d then b else d end in (select case ~ -(cast(avg(b) AS integer)*cast(avg(t1.b) AS integer)*min(t1.f)) | count(*) when min(t1.c) then ( - -count(distinct -d)) else count(*) end from t1 union select cast(avg(f) AS integer) from t1) and b<a)) then t1.b else t1.d end FROM t1 WHERE case case when case when not d<t1.a+t1.d+t1.c then ~f when ((not exists(select 1 from t1 where 19 in ( -(t1.f),17, -e)))) or f not between a and a then t1.f else 19 end in (select min(e)-~ -count(*)*(count(*))+count(*)*min(e) from t1 union select -( -( -count(*))) from t1) then 11 when e<=f then 17 else 13 end+(19)+f when c then b else c end<>t1.b or 19<>t1.f}
+} {400}
+do_test randexpr-2.1009 {
+ db eval {SELECT case when exists(select 1 from t1 where exists(select 1 from t1 where -case when t1.d<=coalesce((select t1.d | (f)*t1.a from t1 where not exists(select 1 from t1 where t1.f not in ((e),t1.e,13) or t1.a not between a and -t1.d or (f) not between f and 13)),19) then e when (t1.f)<19 or e<=d then b else d end in (select case ~ -(cast(avg(b) AS integer)*cast(avg(t1.b) AS integer)*min(t1.f)) | count(*) when min(t1.c) then ( - -count(distinct -d)) else count(*) end from t1 union select cast(avg(f) AS integer) from t1) and b<a)) then t1.b else t1.d end FROM t1 WHERE NOT (case case when case when not d<t1.a+t1.d+t1.c then ~f when ((not exists(select 1 from t1 where 19 in ( -(t1.f),17, -e)))) or f not between a and a then t1.f else 19 end in (select min(e)-~ -count(*)*(count(*))+count(*)*min(e) from t1 union select -( -( -count(*))) from t1) then 11 when e<=f then 17 else 13 end+(19)+f when c then b else c end<>t1.b or 19<>t1.f)}
+} {}
+do_test randexpr-2.1010 {
+ db eval {SELECT case when exists(select 1 from t1 where exists(select 1 from t1 where -case when t1.d<=coalesce((select t1.d & (f)*t1.a from t1 where not exists(select 1 from t1 where t1.f not in ((e),t1.e,13) or t1.a not between a and -t1.d or (f) not between f and 13)),19) then e when (t1.f)<19 or e<=d then b else d end in (select case ~ -(cast(avg(b) AS integer)*cast(avg(t1.b) AS integer)*min(t1.f)) & count(*) when min(t1.c) then ( - -count(distinct -d)) else count(*) end from t1 union select cast(avg(f) AS integer) from t1) and b<a)) then t1.b else t1.d end FROM t1 WHERE case case when case when not d<t1.a+t1.d+t1.c then ~f when ((not exists(select 1 from t1 where 19 in ( -(t1.f),17, -e)))) or f not between a and a then t1.f else 19 end in (select min(e)-~ -count(*)*(count(*))+count(*)*min(e) from t1 union select -( -( -count(*))) from t1) then 11 when e<=f then 17 else 13 end+(19)+f when c then b else c end<>t1.b or 19<>t1.f}
+} {400}
+do_test randexpr-2.1011 {
+ db eval {SELECT case when ~+11<>f then case e when 11 then coalesce((select case d when t1.e-coalesce((select a+t1.c from t1 where (d) in (select +min(t1.f)+count(*) from t1 union select count(distinct t1.e) from t1)),t1.f) then t1.c else d end from t1 where t1.f in (select t1.f from t1 union select b from t1) or (t1.a not in ( -a,t1.a,t1.b))),t1.c) else t1.f end-t1.f when not exists(select 1 from t1 where b between f and t1.a) then t1.c else t1.f end FROM t1 WHERE t1.a<=coalesce((select max(b) from t1 where coalesce((select t1.c*case when coalesce((select max((select count(*) from t1)) from t1 where not not exists(select 1 from t1 where case t1.b | a when t1.f then c else 11 end<>f and 13>=13 and f between t1.b and c)),13)=case e when a then 19 else d end then t1.b when t1.a not in (a,t1.b,a) then e else b end-d from t1 where t1.f between t1.d and t1.e),e)>t1.f),17)+t1.f}
+} {0}
+do_test randexpr-2.1012 {
+ db eval {SELECT case when ~+11<>f then case e when 11 then coalesce((select case d when t1.e-coalesce((select a+t1.c from t1 where (d) in (select +min(t1.f)+count(*) from t1 union select count(distinct t1.e) from t1)),t1.f) then t1.c else d end from t1 where t1.f in (select t1.f from t1 union select b from t1) or (t1.a not in ( -a,t1.a,t1.b))),t1.c) else t1.f end-t1.f when not exists(select 1 from t1 where b between f and t1.a) then t1.c else t1.f end FROM t1 WHERE NOT (t1.a<=coalesce((select max(b) from t1 where coalesce((select t1.c*case when coalesce((select max((select count(*) from t1)) from t1 where not not exists(select 1 from t1 where case t1.b | a when t1.f then c else 11 end<>f and 13>=13 and f between t1.b and c)),13)=case e when a then 19 else d end then t1.b when t1.a not in (a,t1.b,a) then e else b end-d from t1 where t1.f between t1.d and t1.e),e)>t1.f),17)+t1.f)}
+} {}
+do_test randexpr-2.1013 {
+ db eval {SELECT (abs(d)/abs(t1.f++(select cast(avg(coalesce((select max(b) from t1 where case when t1.a*+(abs( -t1.b)/abs((select cast(avg(13) AS integer) from t1)))<=(t1.c-t1.d- -t1.c) then case d when 17 then -t1.d else f end when t1.b between t1.b and t1.b then a else t1.d end in (select count(*) from t1 union select abs(cast(avg(13) AS integer)) | min(t1.c) from t1) or ((13))>=b),17)) AS integer) from t1)+13)) FROM t1 WHERE coalesce((select +t1.a from t1 where not exists(select 1 from t1 where (select cast(avg(13) AS integer) from t1)<=(abs( -11)/abs(t1.f))*coalesce((select t1.e from t1 where not t1.f in (select max(+b-t1.d) from t1 union select + -(abs(cast(avg((t1.b)) AS integer)))-+count(*)-(min(13)) from t1)),d+t1.d*t1.d) | (17)-t1.b)),f) in (select max(t1.c) from t1 union select count(distinct f) from t1)}
+} {}
+do_test randexpr-2.1014 {
+ db eval {SELECT (abs(d)/abs(t1.f++(select cast(avg(coalesce((select max(b) from t1 where case when t1.a*+(abs( -t1.b)/abs((select cast(avg(13) AS integer) from t1)))<=(t1.c-t1.d- -t1.c) then case d when 17 then -t1.d else f end when t1.b between t1.b and t1.b then a else t1.d end in (select count(*) from t1 union select abs(cast(avg(13) AS integer)) | min(t1.c) from t1) or ((13))>=b),17)) AS integer) from t1)+13)) FROM t1 WHERE NOT (coalesce((select +t1.a from t1 where not exists(select 1 from t1 where (select cast(avg(13) AS integer) from t1)<=(abs( -11)/abs(t1.f))*coalesce((select t1.e from t1 where not t1.f in (select max(+b-t1.d) from t1 union select + -(abs(cast(avg((t1.b)) AS integer)))-+count(*)-(min(13)) from t1)),d+t1.d*t1.d) | (17)-t1.b)),f) in (select max(t1.c) from t1 union select count(distinct f) from t1))}
+} {0}
+do_test randexpr-2.1015 {
+ db eval {SELECT (abs(d)/abs(t1.f++(select cast(avg(coalesce((select max(b) from t1 where case when t1.a*+(abs( -t1.b)/abs((select cast(avg(13) AS integer) from t1)))<=(t1.c-t1.d- -t1.c) then case d when 17 then -t1.d else f end when t1.b between t1.b and t1.b then a else t1.d end in (select count(*) from t1 union select abs(cast(avg(13) AS integer)) & min(t1.c) from t1) or ((13))>=b),17)) AS integer) from t1)+13)) FROM t1 WHERE NOT (coalesce((select +t1.a from t1 where not exists(select 1 from t1 where (select cast(avg(13) AS integer) from t1)<=(abs( -11)/abs(t1.f))*coalesce((select t1.e from t1 where not t1.f in (select max(+b-t1.d) from t1 union select + -(abs(cast(avg((t1.b)) AS integer)))-+count(*)-(min(13)) from t1)),d+t1.d*t1.d) | (17)-t1.b)),f) in (select max(t1.c) from t1 union select count(distinct f) from t1))}
+} {0}
+do_test randexpr-2.1016 {
+ db eval {SELECT case t1.a when (select ~max(coalesce((select (t1.b-a*+t1.c-t1.e) from t1 where not 11*t1.f++t1.f-t1.a*f*+t1.e*t1.b>17 and 19+e not in (t1.c,t1.b,a)),19)) from t1) then 19*11 else d end | (17) | t1.d FROM t1 WHERE exists(select 1 from t1 where coalesce((select max(13) from t1 where t1.e not in (d,13-19,17) or e*19=d or ((t1.a< -t1.a or 11- -t1.d-case when 13<( -t1.e) then a else e end*t1.b+t1.e in (select t1.d from t1 union select t1.e from t1) and 19<>d))),b)+11*11=t1.e)}
+} {}
+do_test randexpr-2.1017 {
+ db eval {SELECT case t1.a when (select ~max(coalesce((select (t1.b-a*+t1.c-t1.e) from t1 where not 11*t1.f++t1.f-t1.a*f*+t1.e*t1.b>17 and 19+e not in (t1.c,t1.b,a)),19)) from t1) then 19*11 else d end | (17) | t1.d FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select max(13) from t1 where t1.e not in (d,13-19,17) or e*19=d or ((t1.a< -t1.a or 11- -t1.d-case when 13<( -t1.e) then a else e end*t1.b+t1.e in (select t1.d from t1 union select t1.e from t1) and 19<>d))),b)+11*11=t1.e))}
+} {401}
+do_test randexpr-2.1018 {
+ db eval {SELECT case t1.a when (select ~max(coalesce((select (t1.b-a*+t1.c-t1.e) from t1 where not 11*t1.f++t1.f-t1.a*f*+t1.e*t1.b>17 and 19+e not in (t1.c,t1.b,a)),19)) from t1) then 19*11 else d end & (17) & t1.d FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select max(13) from t1 where t1.e not in (d,13-19,17) or e*19=d or ((t1.a< -t1.a or 11- -t1.d-case when 13<( -t1.e) then a else e end*t1.b+t1.e in (select t1.d from t1 union select t1.e from t1) and 19<>d))),b)+11*11=t1.e))}
+} {16}
+do_test randexpr-2.1019 {
+ db eval {SELECT t1.a-coalesce((select 11-case when 11<19-f+t1.a then a | (t1.a+++(select cast(avg((abs(t1.d | e)/abs((abs(t1.a)/abs(13))))) AS integer)-max(a) from t1)+e+13*19+t1.a-c) else 13 end+t1.e-19 from t1 where 13>t1.f),e) FROM t1 WHERE ~(abs((select max( -case when d+(11)*d between coalesce((select 11 from t1 where (t1.f)=e),d*f) and t1.e then d-case when a<> -17+(abs(t1.d)/abs(t1.f)) then t1.f else t1.e end*11+c-(c) else d end) from t1)*t1.e)/abs((t1.f)))-f<>11}
+} {-400}
+do_test randexpr-2.1020 {
+ db eval {SELECT t1.a-coalesce((select 11-case when 11<19-f+t1.a then a | (t1.a+++(select cast(avg((abs(t1.d | e)/abs((abs(t1.a)/abs(13))))) AS integer)-max(a) from t1)+e+13*19+t1.a-c) else 13 end+t1.e-19 from t1 where 13>t1.f),e) FROM t1 WHERE NOT (~(abs((select max( -case when d+(11)*d between coalesce((select 11 from t1 where (t1.f)=e),d*f) and t1.e then d-case when a<> -17+(abs(t1.d)/abs(t1.f)) then t1.f else t1.e end*11+c-(c) else d end) from t1)*t1.e)/abs((t1.f)))-f<>11)}
+} {}
+do_test randexpr-2.1021 {
+ db eval {SELECT t1.a-coalesce((select 11-case when 11<19-f+t1.a then a & (t1.a+++(select cast(avg((abs(t1.d & e)/abs((abs(t1.a)/abs(13))))) AS integer)-max(a) from t1)+e+13*19+t1.a-c) else 13 end+t1.e-19 from t1 where 13>t1.f),e) FROM t1 WHERE ~(abs((select max( -case when d+(11)*d between coalesce((select 11 from t1 where (t1.f)=e),d*f) and t1.e then d-case when a<> -17+(abs(t1.d)/abs(t1.f)) then t1.f else t1.e end*11+c-(c) else d end) from t1)*t1.e)/abs((t1.f)))-f<>11}
+} {-400}
+do_test randexpr-2.1022 {
+ db eval {SELECT d | (select (cast(avg((abs(case when b*(abs((abs(case f when 17 then t1.e else t1.c end)/abs( -d)))/abs(t1.c)) in (d,a,a) then 19 when (exists(select 1 from t1 where t1.c=t1.a) or a<>d) then a else c end)/abs(t1.e))-17) AS integer)* -min(19)-count(distinct a)-+count(distinct 17)*min(t1.a)+ -cast(avg(t1.a) AS integer)- -max(17) | max(e)) from t1) FROM t1 WHERE -f-t1.f++e+case when not (((select abs(count(*)) from t1)) not in ((case when (t1.b>t1.c) then t1.b else f end),e,13)) and not exists(select 1 from t1 where 11 in (select t1.f from t1 union select ((t1.f)) from t1)) then (t1.e)+c-c+c when -b in (13,19,t1.c) then 17 else 13 end-d | t1.a not in (a,b,b)}
+} {511}
+do_test randexpr-2.1023 {
+ db eval {SELECT d | (select (cast(avg((abs(case when b*(abs((abs(case f when 17 then t1.e else t1.c end)/abs( -d)))/abs(t1.c)) in (d,a,a) then 19 when (exists(select 1 from t1 where t1.c=t1.a) or a<>d) then a else c end)/abs(t1.e))-17) AS integer)* -min(19)-count(distinct a)-+count(distinct 17)*min(t1.a)+ -cast(avg(t1.a) AS integer)- -max(17) | max(e)) from t1) FROM t1 WHERE NOT ( -f-t1.f++e+case when not (((select abs(count(*)) from t1)) not in ((case when (t1.b>t1.c) then t1.b else f end),e,13)) and not exists(select 1 from t1 where 11 in (select t1.f from t1 union select ((t1.f)) from t1)) then (t1.e)+c-c+c when -b in (13,19,t1.c) then 17 else 13 end-d | t1.a not in (a,b,b))}
+} {}
+do_test randexpr-2.1024 {
+ db eval {SELECT d & (select (cast(avg((abs(case when b*(abs((abs(case f when 17 then t1.e else t1.c end)/abs( -d)))/abs(t1.c)) in (d,a,a) then 19 when (exists(select 1 from t1 where t1.c=t1.a) or a<>d) then a else c end)/abs(t1.e))-17) AS integer)* -min(19)-count(distinct a)-+count(distinct 17)*min(t1.a)+ -cast(avg(t1.a) AS integer)- -max(17) & max(e)) from t1) FROM t1 WHERE -f-t1.f++e+case when not (((select abs(count(*)) from t1)) not in ((case when (t1.b>t1.c) then t1.b else f end),e,13)) and not exists(select 1 from t1 where 11 in (select t1.f from t1 union select ((t1.f)) from t1)) then (t1.e)+c-c+c when -b in (13,19,t1.c) then 17 else 13 end-d | t1.a not in (a,b,b)}
+} {128}
+do_test randexpr-2.1025 {
+ db eval {SELECT 11-(select min((abs(e)/abs(f*t1.e*c+17+~case when f | 11 between (select case -max(19) when (cast(avg(t1.a) AS integer)) then count(distinct t1.f) else count(*) end from t1) and coalesce((select 13 from t1 where a<=(t1.d)),f)-a then t1.a when f in (select 17 from t1 union select -b from t1) and t1.d<a or d<>(17) or 19>=d then (f) else 11 end))) from t1) FROM t1 WHERE e in (e, -17*t1.c*17,e)}
+} {11}
+do_test randexpr-2.1026 {
+ db eval {SELECT 11-(select min((abs(e)/abs(f*t1.e*c+17+~case when f | 11 between (select case -max(19) when (cast(avg(t1.a) AS integer)) then count(distinct t1.f) else count(*) end from t1) and coalesce((select 13 from t1 where a<=(t1.d)),f)-a then t1.a when f in (select 17 from t1 union select -b from t1) and t1.d<a or d<>(17) or 19>=d then (f) else 11 end))) from t1) FROM t1 WHERE NOT (e in (e, -17*t1.c*17,e))}
+} {}
+do_test randexpr-2.1027 {
+ db eval {SELECT 11-(select min((abs(e)/abs(f*t1.e*c+17+~case when f & 11 between (select case -max(19) when (cast(avg(t1.a) AS integer)) then count(distinct t1.f) else count(*) end from t1) and coalesce((select 13 from t1 where a<=(t1.d)),f)-a then t1.a when f in (select 17 from t1 union select -b from t1) and t1.d<a or d<>(17) or 19>=d then (f) else 11 end))) from t1) FROM t1 WHERE e in (e, -17*t1.c*17,e)}
+} {11}
+do_test randexpr-2.1028 {
+ db eval {SELECT coalesce((select max( -t1.d-f+~t1.d*t1.b) from t1 where (select ~+min(t1.f)+abs(min(+(select cast(avg((b)) AS integer) from t1)-d*d))-max(f)-count(distinct 19) | count(*)*count(*) from t1)>c),case 13 when +t1.c-t1.c-t1.a then c else c end*d) FROM t1 WHERE ((t1.b>=case when not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where e>=t1.a or (coalesce((select max(coalesce((select case when a in (select t1.d from t1 union select t1.c from t1) then a when -b in (17,c,t1.f) then f else b end from t1 where not exists(select 1 from t1 where f<=13)),17)) from t1 where t1.f>=t1.b),d) between t1.f and 11) or t1.b between 13 and t1.b))) then a when e<=17 then t1.b+ -~11 else a end and not e>= - -b or 13 not in (c,f,11)) and d not between 11 and t1.a)}
+} {-81200}
+do_test randexpr-2.1029 {
+ db eval {SELECT coalesce((select max( -t1.d-f+~t1.d*t1.b) from t1 where (select ~+min(t1.f)+abs(min(+(select cast(avg((b)) AS integer) from t1)-d*d))-max(f)-count(distinct 19) | count(*)*count(*) from t1)>c),case 13 when +t1.c-t1.c-t1.a then c else c end*d) FROM t1 WHERE NOT (((t1.b>=case when not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where e>=t1.a or (coalesce((select max(coalesce((select case when a in (select t1.d from t1 union select t1.c from t1) then a when -b in (17,c,t1.f) then f else b end from t1 where not exists(select 1 from t1 where f<=13)),17)) from t1 where t1.f>=t1.b),d) between t1.f and 11) or t1.b between 13 and t1.b))) then a when e<=17 then t1.b+ -~11 else a end and not e>= - -b or 13 not in (c,f,11)) and d not between 11 and t1.a))}
+} {}
+do_test randexpr-2.1030 {
+ db eval {SELECT coalesce((select max( -t1.d-f+~t1.d*t1.b) from t1 where (select ~+min(t1.f)+abs(min(+(select cast(avg((b)) AS integer) from t1)-d*d))-max(f)-count(distinct 19) & count(*)*count(*) from t1)>c),case 13 when +t1.c-t1.c-t1.a then c else c end*d) FROM t1 WHERE ((t1.b>=case when not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where e>=t1.a or (coalesce((select max(coalesce((select case when a in (select t1.d from t1 union select t1.c from t1) then a when -b in (17,c,t1.f) then f else b end from t1 where not exists(select 1 from t1 where f<=13)),17)) from t1 where t1.f>=t1.b),d) between t1.f and 11) or t1.b between 13 and t1.b))) then a when e<=17 then t1.b+ -~11 else a end and not e>= - -b or 13 not in (c,f,11)) and d not between 11 and t1.a)}
+} {120000}
+do_test randexpr-2.1031 {
+ db eval {SELECT case when t1.d<>coalesce((select 13 from t1 where (d in (select case when (13<>t1.a*d-19-+11*13-t1.c) then case when t1.c=d then e else t1.b end when not exists(select 1 from t1 where 17<>t1.b) then t1.e else t1.e end | t1.a+t1.e from t1 union select t1.d from t1))),t1.f) or a> -t1.e then 11 else 17 end*d FROM t1 WHERE t1.a-d<=d-(abs(coalesce((select b from t1 where ~e<case when (case when case when d>=13 then t1.d else (t1.c) end not between t1.a and 13 then a when (17) not between 11 and t1.c then a else a end) not between 13 and t1.d then 13 else a end),19))/abs(t1.e))+t1.c+t1.e*b+c or ((17 in (select f from t1 union select t1.e from t1)))}
+} {4400}
+do_test randexpr-2.1032 {
+ db eval {SELECT case when t1.d<>coalesce((select 13 from t1 where (d in (select case when (13<>t1.a*d-19-+11*13-t1.c) then case when t1.c=d then e else t1.b end when not exists(select 1 from t1 where 17<>t1.b) then t1.e else t1.e end | t1.a+t1.e from t1 union select t1.d from t1))),t1.f) or a> -t1.e then 11 else 17 end*d FROM t1 WHERE NOT (t1.a-d<=d-(abs(coalesce((select b from t1 where ~e<case when (case when case when d>=13 then t1.d else (t1.c) end not between t1.a and 13 then a when (17) not between 11 and t1.c then a else a end) not between 13 and t1.d then 13 else a end),19))/abs(t1.e))+t1.c+t1.e*b+c or ((17 in (select f from t1 union select t1.e from t1))))}
+} {}
+do_test randexpr-2.1033 {
+ db eval {SELECT case when t1.d<>coalesce((select 13 from t1 where (d in (select case when (13<>t1.a*d-19-+11*13-t1.c) then case when t1.c=d then e else t1.b end when not exists(select 1 from t1 where 17<>t1.b) then t1.e else t1.e end & t1.a+t1.e from t1 union select t1.d from t1))),t1.f) or a> -t1.e then 11 else 17 end*d FROM t1 WHERE t1.a-d<=d-(abs(coalesce((select b from t1 where ~e<case when (case when case when d>=13 then t1.d else (t1.c) end not between t1.a and 13 then a when (17) not between 11 and t1.c then a else a end) not between 13 and t1.d then 13 else a end),19))/abs(t1.e))+t1.c+t1.e*b+c or ((17 in (select f from t1 union select t1.e from t1)))}
+} {4400}
+do_test randexpr-2.1034 {
+ db eval {SELECT coalesce((select (abs(c)/abs(case when 13<=11 then t1.a when case t1.d when (11) then coalesce((select coalesce((select d-17 from t1 where t1.e=a),11) from t1 where 13 in (select t1.e from t1 union select c from t1)),19) else d end>=t1.f or 11 in (select cast(avg(t1.f) AS integer) from t1 union select ( - -count(*)) from t1) and t1.c between 13 and -b then f else e end)) from t1 where d<=(19)),d)-t1.b FROM t1 WHERE 17>=case when t1.c not in (f,t1.a,c*17*a | t1.c-~t1.d+(+coalesce((select max(case when exists(select 1 from t1 where (t1.e in (select -t1.e from t1 union select t1.c from t1))) then t1.b else t1.b*t1.b end) from t1 where not exists(select 1 from t1 where 17=t1.a)),d))+t1.e | (13)*t1.e+c) and e in (select -c from t1 union select 17 from t1) then t1.d*13 else c end- -e}
+} {}
+do_test randexpr-2.1035 {
+ db eval {SELECT coalesce((select (abs(c)/abs(case when 13<=11 then t1.a when case t1.d when (11) then coalesce((select coalesce((select d-17 from t1 where t1.e=a),11) from t1 where 13 in (select t1.e from t1 union select c from t1)),19) else d end>=t1.f or 11 in (select cast(avg(t1.f) AS integer) from t1 union select ( - -count(*)) from t1) and t1.c between 13 and -b then f else e end)) from t1 where d<=(19)),d)-t1.b FROM t1 WHERE NOT (17>=case when t1.c not in (f,t1.a,c*17*a | t1.c-~t1.d+(+coalesce((select max(case when exists(select 1 from t1 where (t1.e in (select -t1.e from t1 union select t1.c from t1))) then t1.b else t1.b*t1.b end) from t1 where not exists(select 1 from t1 where 17=t1.a)),d))+t1.e | (13)*t1.e+c) and e in (select -c from t1 union select 17 from t1) then t1.d*13 else c end- -e)}
+} {200}
+do_test randexpr-2.1036 {
+ db eval {SELECT (abs(case when t1.a in (select case when d=(select ~cast(avg(t1.a) AS integer) | ~+min(17*(abs(19)/abs(t1.a))) from t1) or 13 in (select count(distinct t1.b | 11) from t1 union select count(*) | count(distinct c) | count(distinct 17) from t1) and not b<=17 then t1.a when 11=t1.f then (abs(t1.c)/abs(11)) else f end from t1 union select c from t1) then t1.c else a end)/abs(t1.d))-t1.d FROM t1 WHERE ((abs(e)/abs(t1.a* -(coalesce((select max(t1.b-t1.d) from t1 where f>=13),~a+ -a)) | case when not exists(select 1 from t1 where coalesce((select max(c) from t1 where 19-t1.a | e<=17),~( -t1.a)) in (select f from t1 union select t1.d from t1)) then t1.d else (t1.c) end)) in (17,f,t1.a)) or 19=13 or 19=17}
+} {}
+do_test randexpr-2.1037 {
+ db eval {SELECT (abs(case when t1.a in (select case when d=(select ~cast(avg(t1.a) AS integer) | ~+min(17*(abs(19)/abs(t1.a))) from t1) or 13 in (select count(distinct t1.b | 11) from t1 union select count(*) | count(distinct c) | count(distinct 17) from t1) and not b<=17 then t1.a when 11=t1.f then (abs(t1.c)/abs(11)) else f end from t1 union select c from t1) then t1.c else a end)/abs(t1.d))-t1.d FROM t1 WHERE NOT (((abs(e)/abs(t1.a* -(coalesce((select max(t1.b-t1.d) from t1 where f>=13),~a+ -a)) | case when not exists(select 1 from t1 where coalesce((select max(c) from t1 where 19-t1.a | e<=17),~( -t1.a)) in (select f from t1 union select t1.d from t1)) then t1.d else (t1.c) end)) in (17,f,t1.a)) or 19=13 or 19=17)}
+} {-400}
+do_test randexpr-2.1038 {
+ db eval {SELECT (abs(case when t1.a in (select case when d=(select ~cast(avg(t1.a) AS integer) & ~+min(17*(abs(19)/abs(t1.a))) from t1) or 13 in (select count(distinct t1.b & 11) from t1 union select count(*) & count(distinct c) & count(distinct 17) from t1) and not b<=17 then t1.a when 11=t1.f then (abs(t1.c)/abs(11)) else f end from t1 union select c from t1) then t1.c else a end)/abs(t1.d))-t1.d FROM t1 WHERE NOT (((abs(e)/abs(t1.a* -(coalesce((select max(t1.b-t1.d) from t1 where f>=13),~a+ -a)) | case when not exists(select 1 from t1 where coalesce((select max(c) from t1 where 19-t1.a | e<=17),~( -t1.a)) in (select f from t1 union select t1.d from t1)) then t1.d else (t1.c) end)) in (17,f,t1.a)) or 19=13 or 19=17)}
+} {-400}
+do_test randexpr-2.1039 {
+ db eval {SELECT case when f>coalesce((select c from t1 where coalesce((select max(c+c) from t1 where t1.f in (select - -abs(max(19))+(min(a)) from t1 union select count(distinct -t1.d) from t1)),e)>=e),t1.f) | t1.a | 19 or (t1.c) not in (19, - -t1.f,t1.c) or exists(select 1 from t1 where t1.b not between t1.a and -11) then coalesce((select -b from t1 where -t1.a in (select c from t1 union select 17 from t1)),t1.d) when t1.a=c then c else t1.e end FROM t1 WHERE t1.e in (select +cast(avg(f) AS integer) from t1 union select case +max(19) | count(*) when count(*)*+count(*) then ~+count(*) else count(*) end from t1)}
+} {}
+do_test randexpr-2.1040 {
+ db eval {SELECT case when f>coalesce((select c from t1 where coalesce((select max(c+c) from t1 where t1.f in (select - -abs(max(19))+(min(a)) from t1 union select count(distinct -t1.d) from t1)),e)>=e),t1.f) | t1.a | 19 or (t1.c) not in (19, - -t1.f,t1.c) or exists(select 1 from t1 where t1.b not between t1.a and -11) then coalesce((select -b from t1 where -t1.a in (select c from t1 union select 17 from t1)),t1.d) when t1.a=c then c else t1.e end FROM t1 WHERE NOT (t1.e in (select +cast(avg(f) AS integer) from t1 union select case +max(19) | count(*) when count(*)*+count(*) then ~+count(*) else count(*) end from t1))}
+} {400}
+do_test randexpr-2.1041 {
+ db eval {SELECT case when f>coalesce((select c from t1 where coalesce((select max(c+c) from t1 where t1.f in (select - -abs(max(19))+(min(a)) from t1 union select count(distinct -t1.d) from t1)),e)>=e),t1.f) & t1.a & 19 or (t1.c) not in (19, - -t1.f,t1.c) or exists(select 1 from t1 where t1.b not between t1.a and -11) then coalesce((select -b from t1 where -t1.a in (select c from t1 union select 17 from t1)),t1.d) when t1.a=c then c else t1.e end FROM t1 WHERE NOT (t1.e in (select +cast(avg(f) AS integer) from t1 union select case +max(19) | count(*) when count(*)*+count(*) then ~+count(*) else count(*) end from t1))}
+} {400}
+do_test randexpr-2.1042 {
+ db eval {SELECT +case t1.d when d then t1.f else +t1.b+(select -count(distinct coalesce((select max(c) from t1 where exists(select 1 from t1 where 17 not between d and e)),case when t1.f+f-~17<>d then case when exists(select 1 from t1 where t1.d=(13)) then t1.e when c=t1.e then -a else f end when not 17>11 then t1.b else e end))-max(t1.d) from t1)+ -e-(t1.d) end-11-b FROM t1 WHERE e-case +t1.e when e*e then t1.d else case (abs(case when (abs(case when t1.a+11+t1.a>11-t1.e then +t1.f when e<=a then (c) else b end)/abs(13))*b between b and t1.f then -a else t1.c end+d)/abs(a)) when d then 13 else t1.e end end+e+t1.d<=c}
+} {}
+do_test randexpr-2.1043 {
+ db eval {SELECT +case t1.d when d then t1.f else +t1.b+(select -count(distinct coalesce((select max(c) from t1 where exists(select 1 from t1 where 17 not between d and e)),case when t1.f+f-~17<>d then case when exists(select 1 from t1 where t1.d=(13)) then t1.e when c=t1.e then -a else f end when not 17>11 then t1.b else e end))-max(t1.d) from t1)+ -e-(t1.d) end-11-b FROM t1 WHERE NOT (e-case +t1.e when e*e then t1.d else case (abs(case when (abs(case when t1.a+11+t1.a>11-t1.e then +t1.f when e<=a then (c) else b end)/abs(13))*b between b and t1.f then -a else t1.c end+d)/abs(a)) when d then 13 else t1.e end end+e+t1.d<=c)}
+} {389}
+do_test randexpr-2.1044 {
+ db eval {SELECT + -(select count(*) from t1)*(t1.b)-a-t1.e+17*coalesce((select max(13) from t1 where not exists(select 1 from t1 where case when t1.f<coalesce((select a from t1 where t1.a not in (t1.b,t1.a,19)),t1.a)*f and not exists(select 1 from t1 where exists(select 1 from t1 where (t1.d)=19)) then +t1.d when c<>t1.d then 17 else -17 end* -(t1.f)=(t1.a))), -d)*t1.f*t1.a* -e FROM t1 WHERE not exists(select 1 from t1 where ~case when d+ -t1.c+11*t1.e-t1.c*a*(t1.b)<=~~t1.b then f else case b when t1.b*t1.c-t1.d then c-b else -t1.c end end-13+f>=case when d not between t1.c and (t1.b) then t1.e else t1.c end) or t1.d in (d,t1.c,t1.c)}
+} {-6630000800}
+do_test randexpr-2.1045 {
+ db eval {SELECT + -(select count(*) from t1)*(t1.b)-a-t1.e+17*coalesce((select max(13) from t1 where not exists(select 1 from t1 where case when t1.f<coalesce((select a from t1 where t1.a not in (t1.b,t1.a,19)),t1.a)*f and not exists(select 1 from t1 where exists(select 1 from t1 where (t1.d)=19)) then +t1.d when c<>t1.d then 17 else -17 end* -(t1.f)=(t1.a))), -d)*t1.f*t1.a* -e FROM t1 WHERE NOT (not exists(select 1 from t1 where ~case when d+ -t1.c+11*t1.e-t1.c*a*(t1.b)<=~~t1.b then f else case b when t1.b*t1.c-t1.d then c-b else -t1.c end end-13+f>=case when d not between t1.c and (t1.b) then t1.e else t1.c end) or t1.d in (d,t1.c,t1.c))}
+} {}
+do_test randexpr-2.1046 {
+ db eval {SELECT (abs((select -~~ -count(*)+++count(distinct c) from t1))/abs(coalesce((select e from t1 where (case when case when b not between case t1.d when f then -t1.c else t1.e end and c then d when b=19 then t1.c else d end in (select max(13) from t1 union select count(distinct b) from t1) and t1.d not in (a,t1.b,a) or -t1.d between 13 and e then 17+t1.e when 19 not between t1.f and 17 then t1.b else t1.a end in (17,(t1.e),t1.a))),b) | 17)) FROM t1 WHERE 11>t1.b}
+} {}
+do_test randexpr-2.1047 {
+ db eval {SELECT (abs((select -~~ -count(*)+++count(distinct c) from t1))/abs(coalesce((select e from t1 where (case when case when b not between case t1.d when f then -t1.c else t1.e end and c then d when b=19 then t1.c else d end in (select max(13) from t1 union select count(distinct b) from t1) and t1.d not in (a,t1.b,a) or -t1.d between 13 and e then 17+t1.e when 19 not between t1.f and 17 then t1.b else t1.a end in (17,(t1.e),t1.a))),b) | 17)) FROM t1 WHERE NOT (11>t1.b)}
+} {0}
+do_test randexpr-2.1048 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where coalesce((select e from t1 where case when (c)<>11+case f when t1.a then (select abs( -cast(avg(t1.c) AS integer)) | max((17)) | cast(avg(t1.d) AS integer)-count(distinct e) from t1) else 17*(abs(case t1.d when t1.b then a else b end)/abs(b)) end- -c-17+c*t1.c- -t1.d then t1.c else e end>=f),d)<>t1.a), -t1.f) FROM t1 WHERE not a<=17-t1.f}
+} {400}
+do_test randexpr-2.1049 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where coalesce((select e from t1 where case when (c)<>11+case f when t1.a then (select abs( -cast(avg(t1.c) AS integer)) | max((17)) | cast(avg(t1.d) AS integer)-count(distinct e) from t1) else 17*(abs(case t1.d when t1.b then a else b end)/abs(b)) end- -c-17+c*t1.c- -t1.d then t1.c else e end>=f),d)<>t1.a), -t1.f) FROM t1 WHERE NOT (not a<=17-t1.f)}
+} {}
+do_test randexpr-2.1050 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where coalesce((select e from t1 where case when (c)<>11+case f when t1.a then (select abs( -cast(avg(t1.c) AS integer)) & max((17)) & cast(avg(t1.d) AS integer)-count(distinct e) from t1) else 17*(abs(case t1.d when t1.b then a else b end)/abs(b)) end- -c-17+c*t1.c- -t1.d then t1.c else e end>=f),d)<>t1.a), -t1.f) FROM t1 WHERE not a<=17-t1.f}
+} {400}
+do_test randexpr-2.1051 {
+ db eval {SELECT coalesce((select coalesce((select ~d from t1 where t1.b-t1.c+13 not between t1.b and (abs(t1.a-case t1.c when t1.c | (select max((abs(case when (select count(*) from t1)<>(~t1.e-13*+d+d) then -t1.e else -t1.f end*13)/abs(f))-t1.f) from t1) then t1.f else t1.c end)/abs(c))),t1.e) from t1 where t1.f=f), - -11) FROM t1 WHERE case ((abs(t1.e)/abs(case b when ~17 then 19+(t1.d)+13 else case t1.a*17 when c then 19*case when c<>coalesce((select max(~a) from t1 where 19<>case case when t1.d in (select +count(distinct 11) from t1 union select ( -max(a)) from t1) then t1.f else b end when t1.f then d else t1.a end-t1.b),11) then t1.b else t1.d end else 11 end end))) when t1.b then 11 else t1.d end*t1.c= -t1.f}
+} {}
+do_test randexpr-2.1052 {
+ db eval {SELECT coalesce((select coalesce((select ~d from t1 where t1.b-t1.c+13 not between t1.b and (abs(t1.a-case t1.c when t1.c | (select max((abs(case when (select count(*) from t1)<>(~t1.e-13*+d+d) then -t1.e else -t1.f end*13)/abs(f))-t1.f) from t1) then t1.f else t1.c end)/abs(c))),t1.e) from t1 where t1.f=f), - -11) FROM t1 WHERE NOT (case ((abs(t1.e)/abs(case b when ~17 then 19+(t1.d)+13 else case t1.a*17 when c then 19*case when c<>coalesce((select max(~a) from t1 where 19<>case case when t1.d in (select +count(distinct 11) from t1 union select ( -max(a)) from t1) then t1.f else b end when t1.f then d else t1.a end-t1.b),11) then t1.b else t1.d end else 11 end end))) when t1.b then 11 else t1.d end*t1.c= -t1.f)}
+} {-401}
+do_test randexpr-2.1053 {
+ db eval {SELECT coalesce((select coalesce((select ~d from t1 where t1.b-t1.c+13 not between t1.b and (abs(t1.a-case t1.c when t1.c & (select max((abs(case when (select count(*) from t1)<>(~t1.e-13*+d+d) then -t1.e else -t1.f end*13)/abs(f))-t1.f) from t1) then t1.f else t1.c end)/abs(c))),t1.e) from t1 where t1.f=f), - -11) FROM t1 WHERE NOT (case ((abs(t1.e)/abs(case b when ~17 then 19+(t1.d)+13 else case t1.a*17 when c then 19*case when c<>coalesce((select max(~a) from t1 where 19<>case case when t1.d in (select +count(distinct 11) from t1 union select ( -max(a)) from t1) then t1.f else b end when t1.f then d else t1.a end-t1.b),11) then t1.b else t1.d end else 11 end end))) when t1.b then 11 else t1.d end*t1.c= -t1.f)}
+} {-401}
+do_test randexpr-2.1054 {
+ db eval {SELECT -13-case when (not d<=11-t1.c*t1.e+t1.b) then case when t1.f | coalesce((select +d from t1 where t1.d= -c),(t1.a)) not between b and t1.a then t1.f+a when t1.a<11 and exists(select 1 from t1 where t1.f in (t1.b,17,11)) then b else 19 end when (t1.b between t1.d and e) then b else -t1.c end FROM t1 WHERE case when b between case when coalesce((select t1.c-t1.c from t1 where 13*(select case min(11) when cast(avg(t1.c) AS integer) then (count(*)) else count(distinct 11) end+cast(avg( -f) AS integer) from t1)>=t1.a),t1.c) in ( -t1.c,d,b) then t1.e when f in (select e from t1 union select t1.d from t1) then f else c end and a and 13<>c and exists(select 1 from t1 where f<>c) then case when c in (11,b, -11) then t1.e else e end else 13 end<=t1.c}
+} {-713}
+do_test randexpr-2.1055 {
+ db eval {SELECT -13-case when (not d<=11-t1.c*t1.e+t1.b) then case when t1.f | coalesce((select +d from t1 where t1.d= -c),(t1.a)) not between b and t1.a then t1.f+a when t1.a<11 and exists(select 1 from t1 where t1.f in (t1.b,17,11)) then b else 19 end when (t1.b between t1.d and e) then b else -t1.c end FROM t1 WHERE NOT (case when b between case when coalesce((select t1.c-t1.c from t1 where 13*(select case min(11) when cast(avg(t1.c) AS integer) then (count(*)) else count(distinct 11) end+cast(avg( -f) AS integer) from t1)>=t1.a),t1.c) in ( -t1.c,d,b) then t1.e when f in (select e from t1 union select t1.d from t1) then f else c end and a and 13<>c and exists(select 1 from t1 where f<>c) then case when c in (11,b, -11) then t1.e else e end else 13 end<=t1.c)}
+} {}
+do_test randexpr-2.1056 {
+ db eval {SELECT -13-case when (not d<=11-t1.c*t1.e+t1.b) then case when t1.f & coalesce((select +d from t1 where t1.d= -c),(t1.a)) not between b and t1.a then t1.f+a when t1.a<11 and exists(select 1 from t1 where t1.f in (t1.b,17,11)) then b else 19 end when (t1.b between t1.d and e) then b else -t1.c end FROM t1 WHERE case when b between case when coalesce((select t1.c-t1.c from t1 where 13*(select case min(11) when cast(avg(t1.c) AS integer) then (count(*)) else count(distinct 11) end+cast(avg( -f) AS integer) from t1)>=t1.a),t1.c) in ( -t1.c,d,b) then t1.e when f in (select e from t1 union select t1.d from t1) then f else c end and a and 13<>c and exists(select 1 from t1 where f<>c) then case when c in (11,b, -11) then t1.e else e end else 13 end<=t1.c}
+} {-713}
+do_test randexpr-2.1057 {
+ db eval {SELECT t1.b | (abs( -(select ~ -~abs(case ~min((c* -b+c))+min(f) when ~abs(count(distinct 13))+(min(13)) then max(11) else count(*) end) from t1)-11 | +(abs(t1.d-t1.e)/abs(t1.b))-t1.f*19+t1.c*17)/abs(f))+t1.b FROM t1 WHERE (a between t1.e and -13)}
+} {}
+do_test randexpr-2.1058 {
+ db eval {SELECT t1.b | (abs( -(select ~ -~abs(case ~min((c* -b+c))+min(f) when ~abs(count(distinct 13))+(min(13)) then max(11) else count(*) end) from t1)-11 | +(abs(t1.d-t1.e)/abs(t1.b))-t1.f*19+t1.c*17)/abs(f))+t1.b FROM t1 WHERE NOT ((a between t1.e and -13))}
+} {200}
+do_test randexpr-2.1059 {
+ db eval {SELECT t1.b & (abs( -(select ~ -~abs(case ~min((c* -b+c))+min(f) when ~abs(count(distinct 13))+(min(13)) then max(11) else count(*) end) from t1)-11 & +(abs(t1.d-t1.e)/abs(t1.b))-t1.f*19+t1.c*17)/abs(f))+t1.b FROM t1 WHERE NOT ((a between t1.e and -13))}
+} {192}
+do_test randexpr-2.1060 {
+ db eval {SELECT t1.c-case t1.b when t1.f-t1.b-f then +coalesce((select b from t1 where (t1.d in (select (select count(*)+abs(count(*)) | ~cast(avg(b | case when 11 between b and (f) then b when (19)>19 then 17 else t1.e end) AS integer) | min(d) from t1) from t1 union select 19 from t1))),(abs(c*c)/abs(11))-a-t1.c+t1.f-t1.c)+b else b end FROM t1 WHERE (t1.d)+t1.b<( -t1.b)}
+} {}
+do_test randexpr-2.1061 {
+ db eval {SELECT t1.c-case t1.b when t1.f-t1.b-f then +coalesce((select b from t1 where (t1.d in (select (select count(*)+abs(count(*)) | ~cast(avg(b | case when 11 between b and (f) then b when (19)>19 then 17 else t1.e end) AS integer) | min(d) from t1) from t1 union select 19 from t1))),(abs(c*c)/abs(11))-a-t1.c+t1.f-t1.c)+b else b end FROM t1 WHERE NOT ((t1.d)+t1.b<( -t1.b))}
+} {100}
+do_test randexpr-2.1062 {
+ db eval {SELECT t1.c-case t1.b when t1.f-t1.b-f then +coalesce((select b from t1 where (t1.d in (select (select count(*)+abs(count(*)) & ~cast(avg(b & case when 11 between b and (f) then b when (19)>19 then 17 else t1.e end) AS integer) & min(d) from t1) from t1 union select 19 from t1))),(abs(c*c)/abs(11))-a-t1.c+t1.f-t1.c)+b else b end FROM t1 WHERE NOT ((t1.d)+t1.b<( -t1.b))}
+} {100}
+do_test randexpr-2.1063 {
+ db eval {SELECT 17*(select (case case min(t1.d+( -d | case 11* -11*11 when 13 then t1.c else -17 end)-d*t1.d)-count(*)-abs( -max(17)+~max(t1.b)) | +abs(cast(avg((a)) AS integer))+(count(*)) when -max(17) then -max(19) else (cast(avg(d) AS integer)) end when count(distinct t1.c) then min(b) else count(*) end) from t1) FROM t1 WHERE d>=(abs(coalesce((select max(d) from t1 where not not case when a in (select count(*)* -case +min(case when t1.e<t1.e then 11 else a end-19)*case count(*) when max(13) then count(*) else min(b) end | ( -cast(avg(b) AS integer)) when max(t1.d) then (cast(avg((t1.a)) AS integer)) else min(f) end | -max(t1.d) from t1 union select -min(c) from t1) then e else e end<(select max(t1.c) from t1)),c++t1.f*c))/abs(e))+t1.d}
+} {}
+do_test randexpr-2.1064 {
+ db eval {SELECT 17*(select (case case min(t1.d+( -d | case 11* -11*11 when 13 then t1.c else -17 end)-d*t1.d)-count(*)-abs( -max(17)+~max(t1.b)) | +abs(cast(avg((a)) AS integer))+(count(*)) when -max(17) then -max(19) else (cast(avg(d) AS integer)) end when count(distinct t1.c) then min(b) else count(*) end) from t1) FROM t1 WHERE NOT (d>=(abs(coalesce((select max(d) from t1 where not not case when a in (select count(*)* -case +min(case when t1.e<t1.e then 11 else a end-19)*case count(*) when max(13) then count(*) else min(b) end | ( -cast(avg(b) AS integer)) when max(t1.d) then (cast(avg((t1.a)) AS integer)) else min(f) end | -max(t1.d) from t1 union select -min(c) from t1) then e else e end<(select max(t1.c) from t1)),c++t1.f*c))/abs(e))+t1.d)}
+} {17}
+do_test randexpr-2.1065 {
+ db eval {SELECT 17*(select (case case min(t1.d+( -d & case 11* -11*11 when 13 then t1.c else -17 end)-d*t1.d)-count(*)-abs( -max(17)+~max(t1.b)) & +abs(cast(avg((a)) AS integer))+(count(*)) when -max(17) then -max(19) else (cast(avg(d) AS integer)) end when count(distinct t1.c) then min(b) else count(*) end) from t1) FROM t1 WHERE NOT (d>=(abs(coalesce((select max(d) from t1 where not not case when a in (select count(*)* -case +min(case when t1.e<t1.e then 11 else a end-19)*case count(*) when max(13) then count(*) else min(b) end | ( -cast(avg(b) AS integer)) when max(t1.d) then (cast(avg((t1.a)) AS integer)) else min(f) end | -max(t1.d) from t1 union select -min(c) from t1) then e else e end<(select max(t1.c) from t1)),c++t1.f*c))/abs(e))+t1.d)}
+} {17}
+do_test randexpr-2.1066 {
+ db eval {SELECT 11 | ~case case when e between 17 and coalesce((select max(((f-t1.f))) from t1 where d<>f),t1.f) and 11 not between 13 and 13 and ( -11<>c and t1.b>c) or 19<>t1.e and t1.b<=t1.f then +f*b when t1.d>=e then -13 else t1.c end when b then (17) else t1.d end+a+f*a FROM t1 WHERE not exists(select 1 from t1 where a between t1.f and 17 or e>=(d)*19+t1.e*c)}
+} {59707}
+do_test randexpr-2.1067 {
+ db eval {SELECT 11 | ~case case when e between 17 and coalesce((select max(((f-t1.f))) from t1 where d<>f),t1.f) and 11 not between 13 and 13 and ( -11<>c and t1.b>c) or 19<>t1.e and t1.b<=t1.f then +f*b when t1.d>=e then -13 else t1.c end when b then (17) else t1.d end+a+f*a FROM t1 WHERE NOT (not exists(select 1 from t1 where a between t1.f and 17 or e>=(d)*19+t1.e*c))}
+} {}
+do_test randexpr-2.1068 {
+ db eval {SELECT 11 & ~case case when e between 17 and coalesce((select max(((f-t1.f))) from t1 where d<>f),t1.f) and 11 not between 13 and 13 and ( -11<>c and t1.b>c) or 19<>t1.e and t1.b<=t1.f then +f*b when t1.d>=e then -13 else t1.c end when b then (17) else t1.d end+a+f*a FROM t1 WHERE not exists(select 1 from t1 where a between t1.f and 17 or e>=(d)*19+t1.e*c)}
+} {3}
+do_test randexpr-2.1069 {
+ db eval {SELECT -case when t1.d | ~b<>coalesce((select max(t1.c) from t1 where t1.c not between coalesce((select max(coalesce((select max(e) from t1 where 11 not in (case when 13 not between d and c then 17 when (t1.a) not in (e,b,b) then 19 else c end,a,t1.d)),b)+f) from t1 where t1.d not in (11,f,t1.e)),t1.b) and f),11) or 11<>(d) then -f* -d else (e) end*f FROM t1 WHERE case f when 11 then coalesce((select b from t1 where 19+case when 17*t1.d-t1.f+t1.f between t1.d-case when +d=coalesce((select max(f) from t1 where e>t1.f),17) and c=t1.e and b not in (17,11,(t1.f)) then -17 else t1.c end and c then -t1.a else t1.d end+11*e not between t1.f and d),13)+t1.d else -13 end=c}
+} {}
+do_test randexpr-2.1070 {
+ db eval {SELECT -case when t1.d | ~b<>coalesce((select max(t1.c) from t1 where t1.c not between coalesce((select max(coalesce((select max(e) from t1 where 11 not in (case when 13 not between d and c then 17 when (t1.a) not in (e,b,b) then 19 else c end,a,t1.d)),b)+f) from t1 where t1.d not in (11,f,t1.e)),t1.b) and f),11) or 11<>(d) then -f* -d else (e) end*f FROM t1 WHERE NOT (case f when 11 then coalesce((select b from t1 where 19+case when 17*t1.d-t1.f+t1.f between t1.d-case when +d=coalesce((select max(f) from t1 where e>t1.f),17) and c=t1.e and b not in (17,11,(t1.f)) then -17 else t1.c end and c then -t1.a else t1.d end+11*e not between t1.f and d),13)+t1.d else -13 end=c)}
+} {-144000000}
+do_test randexpr-2.1071 {
+ db eval {SELECT -case when t1.d & ~b<>coalesce((select max(t1.c) from t1 where t1.c not between coalesce((select max(coalesce((select max(e) from t1 where 11 not in (case when 13 not between d and c then 17 when (t1.a) not in (e,b,b) then 19 else c end,a,t1.d)),b)+f) from t1 where t1.d not in (11,f,t1.e)),t1.b) and f),11) or 11<>(d) then -f* -d else (e) end*f FROM t1 WHERE NOT (case f when 11 then coalesce((select b from t1 where 19+case when 17*t1.d-t1.f+t1.f between t1.d-case when +d=coalesce((select max(f) from t1 where e>t1.f),17) and c=t1.e and b not in (17,11,(t1.f)) then -17 else t1.c end and c then -t1.a else t1.d end+11*e not between t1.f and d),13)+t1.d else -13 end=c)}
+} {-144000000}
+do_test randexpr-2.1072 {
+ db eval {SELECT coalesce((select t1.b from t1 where not (t1.c>19) and 11<=+(abs(t1.b-19)/abs(a))+case when ((coalesce((select 13 from t1 where c in (b,t1.b,t1.d)),e))<>13) or f in ((t1.b),t1.e, -b) then 11+(c) else b end or b<>d),t1.f+t1.f+13) | - -a FROM t1 WHERE 13 between t1.c and 13+~19+c+(select min(f-(abs(17)/abs((t1.e)))) from t1)}
+} {}
+do_test randexpr-2.1073 {
+ db eval {SELECT coalesce((select t1.b from t1 where not (t1.c>19) and 11<=+(abs(t1.b-19)/abs(a))+case when ((coalesce((select 13 from t1 where c in (b,t1.b,t1.d)),e))<>13) or f in ((t1.b),t1.e, -b) then 11+(c) else b end or b<>d),t1.f+t1.f+13) | - -a FROM t1 WHERE NOT (13 between t1.c and 13+~19+c+(select min(f-(abs(17)/abs((t1.e)))) from t1))}
+} {236}
+do_test randexpr-2.1074 {
+ db eval {SELECT coalesce((select t1.b from t1 where not (t1.c>19) and 11<=+(abs(t1.b-19)/abs(a))+case when ((coalesce((select 13 from t1 where c in (b,t1.b,t1.d)),e))<>13) or f in ((t1.b),t1.e, -b) then 11+(c) else b end or b<>d),t1.f+t1.f+13) & - -a FROM t1 WHERE NOT (13 between t1.c and 13+~19+c+(select min(f-(abs(17)/abs((t1.e)))) from t1))}
+} {64}
+do_test randexpr-2.1075 {
+ db eval {SELECT -(coalesce((select max(coalesce((select t1.f from t1 where not exists(select 1 from t1 where (abs(+b+19+19)/abs(t1.b))<t1.b) or 19+f>=(select -max(19) from t1)+t1.f),t1.e+t1.f)* -t1.e+19-f) from t1 where (( -t1.c<19) or d>=c)),t1.c))*c*((t1.b))-17 FROM t1 WHERE t1.e not between t1.f*c and t1.f+ -d}
+} {18034859983}
+do_test randexpr-2.1076 {
+ db eval {SELECT -(coalesce((select max(coalesce((select t1.f from t1 where not exists(select 1 from t1 where (abs(+b+19+19)/abs(t1.b))<t1.b) or 19+f>=(select -max(19) from t1)+t1.f),t1.e+t1.f)* -t1.e+19-f) from t1 where (( -t1.c<19) or d>=c)),t1.c))*c*((t1.b))-17 FROM t1 WHERE NOT (t1.e not between t1.f*c and t1.f+ -d)}
+} {}
+do_test randexpr-2.1077 {
+ db eval {SELECT case 17 when (t1.d)*coalesce((select (select case (cast(avg(c) AS integer)+max(case when (not d+ -t1.e not between 11 and -f) then f when b<(11) then t1.b else 11 end))+count(distinct t1.c)*max(b) when -min(e) | -count(distinct t1.c) then cast(avg(e) AS integer) else count(*) end from t1) from t1 where case c when a then a else t1.d end-11<>19),t1.a)+t1.b then f else t1.f end FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where (abs(d)/abs((f*+coalesce((select -~case when exists(select 1 from t1 where b<c) then t1.b else 17 end+case (select (min(coalesce((select b from t1 where 11<>t1.c or ((t1.c))<>e),(t1.e)))) from t1)*17 when e then a else t1.e end-t1.b-19 from t1 where t1.e in (select abs(+min(f)+cast(avg( -a) AS integer)) from t1 union select count(distinct c) from t1)),d))))<>f))}
+} {}
+do_test randexpr-2.1078 {
+ db eval {SELECT case 17 when (t1.d)*coalesce((select (select case (cast(avg(c) AS integer)+max(case when (not d+ -t1.e not between 11 and -f) then f when b<(11) then t1.b else 11 end))+count(distinct t1.c)*max(b) when -min(e) | -count(distinct t1.c) then cast(avg(e) AS integer) else count(*) end from t1) from t1 where case c when a then a else t1.d end-11<>19),t1.a)+t1.b then f else t1.f end FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where (abs(d)/abs((f*+coalesce((select -~case when exists(select 1 from t1 where b<c) then t1.b else 17 end+case (select (min(coalesce((select b from t1 where 11<>t1.c or ((t1.c))<>e),(t1.e)))) from t1)*17 when e then a else t1.e end-t1.b-19 from t1 where t1.e in (select abs(+min(f)+cast(avg( -a) AS integer)) from t1 union select count(distinct c) from t1)),d))))<>f)))}
+} {600}
+do_test randexpr-2.1079 {
+ db eval {SELECT case 17 when (t1.d)*coalesce((select (select case (cast(avg(c) AS integer)+max(case when (not d+ -t1.e not between 11 and -f) then f when b<(11) then t1.b else 11 end))+count(distinct t1.c)*max(b) when -min(e) & -count(distinct t1.c) then cast(avg(e) AS integer) else count(*) end from t1) from t1 where case c when a then a else t1.d end-11<>19),t1.a)+t1.b then f else t1.f end FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where (abs(d)/abs((f*+coalesce((select -~case when exists(select 1 from t1 where b<c) then t1.b else 17 end+case (select (min(coalesce((select b from t1 where 11<>t1.c or ((t1.c))<>e),(t1.e)))) from t1)*17 when e then a else t1.e end-t1.b-19 from t1 where t1.e in (select abs(+min(f)+cast(avg( -a) AS integer)) from t1 union select count(distinct c) from t1)),d))))<>f)))}
+} {600}
+do_test randexpr-2.1080 {
+ db eval {SELECT ((select -case min(17 | (abs(a)/abs(case (select max(a) from t1)+13+t1.c when c then (abs(case when 17<>a and t1.c=d then ((17)) else e end)/abs(t1.b)) else 17 end)) | f*a) when abs(~(count(distinct t1.e))-abs((~max(c)))-count(*) | min(t1.f)+max(11)) then -cast(avg((b)) AS integer) else min(b) end from t1))*a FROM t1 WHERE (13)-(t1.a*17-t1.b)-coalesce((select (select -cast(avg(t1.c) AS integer)+case - -count(*) | (count(distinct t1.a)) when -min(t1.e) then (max(t1.d)) else count(distinct t1.b) end from t1)-e+(abs(17)/abs(e)) from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (d)>=13 and (t1.b not in (c,a, -t1.d) or t1.e in (select c from t1 union select t1.c from t1)) or 11<=t1.d))),17) in (select e from t1 union select e from t1)}
+} {}
+do_test randexpr-2.1081 {
+ db eval {SELECT ((select -case min(17 | (abs(a)/abs(case (select max(a) from t1)+13+t1.c when c then (abs(case when 17<>a and t1.c=d then ((17)) else e end)/abs(t1.b)) else 17 end)) | f*a) when abs(~(count(distinct t1.e))-abs((~max(c)))-count(*) | min(t1.f)+max(11)) then -cast(avg((b)) AS integer) else min(b) end from t1))*a FROM t1 WHERE NOT ((13)-(t1.a*17-t1.b)-coalesce((select (select -cast(avg(t1.c) AS integer)+case - -count(*) | (count(distinct t1.a)) when -min(t1.e) then (max(t1.d)) else count(distinct t1.b) end from t1)-e+(abs(17)/abs(e)) from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (d)>=13 and (t1.b not in (c,a, -t1.d) or t1.e in (select c from t1 union select t1.c from t1)) or 11<=t1.d))),17) in (select e from t1 union select e from t1))}
+} {-20000}
+do_test randexpr-2.1082 {
+ db eval {SELECT ((select -case min(17 & (abs(a)/abs(case (select max(a) from t1)+13+t1.c when c then (abs(case when 17<>a and t1.c=d then ((17)) else e end)/abs(t1.b)) else 17 end)) & f*a) when abs(~(count(distinct t1.e))-abs((~max(c)))-count(*) & min(t1.f)+max(11)) then -cast(avg((b)) AS integer) else min(b) end from t1))*a FROM t1 WHERE NOT ((13)-(t1.a*17-t1.b)-coalesce((select (select -cast(avg(t1.c) AS integer)+case - -count(*) | (count(distinct t1.a)) when -min(t1.e) then (max(t1.d)) else count(distinct t1.b) end from t1)-e+(abs(17)/abs(e)) from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (d)>=13 and (t1.b not in (c,a, -t1.d) or t1.e in (select c from t1 union select t1.c from t1)) or 11<=t1.d))),17) in (select e from t1 union select e from t1))}
+} {-20000}
+do_test randexpr-2.1083 {
+ db eval {SELECT case when (select -min(11) from t1)<>(abs(17)/abs(t1.d | e)) then case 11+case 11 when b | e-e then 19+e else b end*(abs(t1.a)/abs(b | a)) | coalesce((select case when a in (select cast(avg(d) AS integer) from t1 union select - - -max(c) from t1) or e not in (c,d,a) then +13 when t1.a>a then 19 else f end from t1 where t1.c=13 or f<>t1.e),a) when f then f else c end else t1.e end FROM t1 WHERE ~17 in (11,t1.c,19)}
+} {}
+do_test randexpr-2.1084 {
+ db eval {SELECT case when (select -min(11) from t1)<>(abs(17)/abs(t1.d | e)) then case 11+case 11 when b | e-e then 19+e else b end*(abs(t1.a)/abs(b | a)) | coalesce((select case when a in (select cast(avg(d) AS integer) from t1 union select - - -max(c) from t1) or e not in (c,d,a) then +13 when t1.a>a then 19 else f end from t1 where t1.c=13 or f<>t1.e),a) when f then f else c end else t1.e end FROM t1 WHERE NOT (~17 in (11,t1.c,19))}
+} {300}
+do_test randexpr-2.1085 {
+ db eval {SELECT case when (select -min(11) from t1)<>(abs(17)/abs(t1.d & e)) then case 11+case 11 when b & e-e then 19+e else b end*(abs(t1.a)/abs(b & a)) & coalesce((select case when a in (select cast(avg(d) AS integer) from t1 union select - - -max(c) from t1) or e not in (c,d,a) then +13 when t1.a>a then 19 else f end from t1 where t1.c=13 or f<>t1.e),a) when f then f else c end else t1.e end FROM t1 WHERE NOT (~17 in (11,t1.c,19))}
+} {300}
+do_test randexpr-2.1086 {
+ db eval {SELECT (select case +cast(avg(+19) AS integer) when (abs(count(*))) then (cast(avg(e*t1.b) AS integer)) else cast(avg(t1.a) AS integer) end+count(*) | +max(f-t1.e*t1.e | (f)* -19+ -b*d) | count(*)*count(*)* -count(*) | ~count(distinct -b)*cast(avg(t1.f) AS integer)+count(*) from t1)-t1.c+t1.b FROM t1 WHERE ((select -count(*)+min(case ~coalesce((select max(d) from t1 where (not not exists(select 1 from t1 where t1.b not in ((select -max(a)+(count(*)) from t1) | c+case when t1.e not in (13,e,c) then (t1.f) else t1.c end+17*c+19,c,e)))),t1.f) when (f) then t1.a else t1.f end | b | t1.a) from t1) in (c,t1.c+ -a,f))}
+} {}
+do_test randexpr-2.1087 {
+ db eval {SELECT (select case +cast(avg(+19) AS integer) when (abs(count(*))) then (cast(avg(e*t1.b) AS integer)) else cast(avg(t1.a) AS integer) end+count(*) | +max(f-t1.e*t1.e | (f)* -19+ -b*d) | count(*)*count(*)* -count(*) | ~count(distinct -b)*cast(avg(t1.f) AS integer)+count(*) from t1)-t1.c+t1.b FROM t1 WHERE NOT (((select -count(*)+min(case ~coalesce((select max(d) from t1 where (not not exists(select 1 from t1 where t1.b not in ((select -max(a)+(count(*)) from t1) | c+case when t1.e not in (13,e,c) then (t1.f) else t1.c end+17*c+19,c,e)))),t1.f) when (f) then t1.a else t1.f end | b | t1.a) from t1) in (c,t1.c+ -a,f)))}
+} {-101}
+do_test randexpr-2.1088 {
+ db eval {SELECT (select case +cast(avg(+19) AS integer) when (abs(count(*))) then (cast(avg(e*t1.b) AS integer)) else cast(avg(t1.a) AS integer) end+count(*) & +max(f-t1.e*t1.e & (f)* -19+ -b*d) & count(*)*count(*)* -count(*) & ~count(distinct -b)*cast(avg(t1.f) AS integer)+count(*) from t1)-t1.c+t1.b FROM t1 WHERE NOT (((select -count(*)+min(case ~coalesce((select max(d) from t1 where (not not exists(select 1 from t1 where t1.b not in ((select -max(a)+(count(*)) from t1) | c+case when t1.e not in (13,e,c) then (t1.f) else t1.c end+17*c+19,c,e)))),t1.f) when (f) then t1.a else t1.f end | b | t1.a) from t1) in (c,t1.c+ -a,f)))}
+} {-36}
+do_test randexpr-2.1089 {
+ db eval {SELECT (coalesce((select (select -~+ -abs(case cast(avg(a*t1.d) AS integer) when case ~case count(distinct ((abs(t1.a)/abs(d)))) when case cast(avg(17) AS integer)-count(*) when -count(*) then count(distinct d) else (max(t1.d)) end*count(*) then count(distinct t1.c) else min(19) end-count(*) when cast(avg(t1.a) AS integer) then ((count(*))) else min(a) end then (count(*)) else max(e) end)*(count(*))*max(a) from t1) from t1 where (19>=(17))),d)) FROM t1 WHERE exists(select 1 from t1 where 19 in (t1.a*coalesce((select a from t1 where (11<case a when (t1.e+c-t1.a) then t1.b else t1.c end) or d between +t1.e-+coalesce((select max(coalesce((select (select cast(avg((19)) AS integer) from t1) from t1 where t1.e>t1.b),t1.e)) from t1 where e not between 13 and t1.c),(a))-t1.d and 13),13*b)-17, -b,17))}
+} {}
+do_test randexpr-2.1090 {
+ db eval {SELECT (coalesce((select (select -~+ -abs(case cast(avg(a*t1.d) AS integer) when case ~case count(distinct ((abs(t1.a)/abs(d)))) when case cast(avg(17) AS integer)-count(*) when -count(*) then count(distinct d) else (max(t1.d)) end*count(*) then count(distinct t1.c) else min(19) end-count(*) when cast(avg(t1.a) AS integer) then ((count(*))) else min(a) end then (count(*)) else max(e) end)*(count(*))*max(a) from t1) from t1 where (19>=(17))),d)) FROM t1 WHERE NOT (exists(select 1 from t1 where 19 in (t1.a*coalesce((select a from t1 where (11<case a when (t1.e+c-t1.a) then t1.b else t1.c end) or d between +t1.e-+coalesce((select max(coalesce((select (select cast(avg((19)) AS integer) from t1) from t1 where t1.e>t1.b),t1.e)) from t1 where e not between 13 and t1.c),(a))-t1.d and 13),13*b)-17, -b,17)))}
+} {-49900}
+do_test randexpr-2.1091 {
+ db eval {SELECT case when (coalesce((select max((select +max(c) from t1)) from t1 where t1.c<>t1.a),d) not in (t1.d,+case when 17>19 then e when t1.b<>+(select count(*) from t1) then t1.e else t1.d end,t1.c)) then (select count(*)-count(distinct t1.d)+ -max( -t1.c-a)*case cast(avg((f)) AS integer) when count(distinct d) then max((13)) else max(t1.d) end from t1)*t1.b else t1.c end | -13*t1.d*t1.c FROM t1 WHERE c in (select case count(distinct ~(abs( -a)/abs(d))) when ~count(*) then ~min(coalesce((select max((abs(e)/abs(d))) from t1 where not exists(select 1 from t1 where t1.e>( -+t1.a-t1.e*17))),19))+count(*) else case ~ -cast(avg((11)) AS integer) | +cast(avg(d) AS integer) | (cast(avg(c) AS integer))+min(t1.e) when min(t1.c) then max(11) else -count(*) end end+max(t1.c) from t1 union select -count(*) from t1)}
+} {}
+do_test randexpr-2.1092 {
+ db eval {SELECT case when (coalesce((select max((select +max(c) from t1)) from t1 where t1.c<>t1.a),d) not in (t1.d,+case when 17>19 then e when t1.b<>+(select count(*) from t1) then t1.e else t1.d end,t1.c)) then (select count(*)-count(distinct t1.d)+ -max( -t1.c-a)*case cast(avg((f)) AS integer) when count(distinct d) then max((13)) else max(t1.d) end from t1)*t1.b else t1.c end | -13*t1.d*t1.c FROM t1 WHERE NOT (c in (select case count(distinct ~(abs( -a)/abs(d))) when ~count(*) then ~min(coalesce((select max((abs(e)/abs(d))) from t1 where not exists(select 1 from t1 where t1.e>( -+t1.a-t1.e*17))),19))+count(*) else case ~ -cast(avg((11)) AS integer) | +cast(avg(d) AS integer) | (cast(avg(c) AS integer))+min(t1.e) when min(t1.c) then max(11) else -count(*) end end+max(t1.c) from t1 union select -count(*) from t1))}
+} {-1559700}
+do_test randexpr-2.1093 {
+ db eval {SELECT case when (coalesce((select max((select +max(c) from t1)) from t1 where t1.c<>t1.a),d) not in (t1.d,+case when 17>19 then e when t1.b<>+(select count(*) from t1) then t1.e else t1.d end,t1.c)) then (select count(*)-count(distinct t1.d)+ -max( -t1.c-a)*case cast(avg((f)) AS integer) when count(distinct d) then max((13)) else max(t1.d) end from t1)*t1.b else t1.c end & -13*t1.d*t1.c FROM t1 WHERE NOT (c in (select case count(distinct ~(abs( -a)/abs(d))) when ~count(*) then ~min(coalesce((select max((abs(e)/abs(d))) from t1 where not exists(select 1 from t1 where t1.e>( -+t1.a-t1.e*17))),19))+count(*) else case ~ -cast(avg((11)) AS integer) | +cast(avg(d) AS integer) | (cast(avg(c) AS integer))+min(t1.e) when min(t1.c) then max(11) else -count(*) end end+max(t1.c) from t1 union select -count(*) from t1))}
+} {0}
+do_test randexpr-2.1094 {
+ db eval {SELECT coalesce((select max(t1.c+t1.b-t1.b+(abs(d++t1.f)/abs(t1.a)) | 13*17) from t1 where coalesce((select 11 from t1 where case case case c when d then t1.d else 13 end when b then -11 else t1.b end when 13 then (t1.a) else d end not in (c,13,a)),t1.c) | f not in (t1.a,t1.c,13) and not exists(select 1 from t1 where t1.c in (select e from t1 union select -11 from t1))),t1.f) FROM t1 WHERE (((13+coalesce((select max(13) from t1 where not exists(select 1 from t1 where ((abs(c-case when not exists(select 1 from t1 where ((f) between c and 13)) then (select case min(f) when max(17) then min(13) else min(b) end from t1) when 17 in (t1.e,13,f) then -13 else 11 end)/abs(t1.f)) in (select min(c) from t1 union select -count(*) | + -min(19) from t1))) and f<13),t1.e+t1.c) in (select count(distinct c)-count(*) from t1 union select -case min((e))+cast(avg(t1.a) AS integer) when ((min(t1.c))) then count(distinct e) else -cast(avg(t1.d) AS integer) end from t1))))}
+} {}
+do_test randexpr-2.1095 {
+ db eval {SELECT coalesce((select max(t1.c+t1.b-t1.b+(abs(d++t1.f)/abs(t1.a)) | 13*17) from t1 where coalesce((select 11 from t1 where case case case c when d then t1.d else 13 end when b then -11 else t1.b end when 13 then (t1.a) else d end not in (c,13,a)),t1.c) | f not in (t1.a,t1.c,13) and not exists(select 1 from t1 where t1.c in (select e from t1 union select -11 from t1))),t1.f) FROM t1 WHERE NOT ((((13+coalesce((select max(13) from t1 where not exists(select 1 from t1 where ((abs(c-case when not exists(select 1 from t1 where ((f) between c and 13)) then (select case min(f) when max(17) then min(13) else min(b) end from t1) when 17 in (t1.e,13,f) then -13 else 11 end)/abs(t1.f)) in (select min(c) from t1 union select -count(*) | + -min(19) from t1))) and f<13),t1.e+t1.c) in (select count(distinct c)-count(*) from t1 union select -case min((e))+cast(avg(t1.a) AS integer) when ((min(t1.c))) then count(distinct e) else -cast(avg(t1.d) AS integer) end from t1)))))}
+} {511}
+do_test randexpr-2.1096 {
+ db eval {SELECT coalesce((select max(t1.c+t1.b-t1.b+(abs(d++t1.f)/abs(t1.a)) & 13*17) from t1 where coalesce((select 11 from t1 where case case case c when d then t1.d else 13 end when b then -11 else t1.b end when 13 then (t1.a) else d end not in (c,13,a)),t1.c) & f not in (t1.a,t1.c,13) and not exists(select 1 from t1 where t1.c in (select e from t1 union select -11 from t1))),t1.f) FROM t1 WHERE NOT ((((13+coalesce((select max(13) from t1 where not exists(select 1 from t1 where ((abs(c-case when not exists(select 1 from t1 where ((f) between c and 13)) then (select case min(f) when max(17) then min(13) else min(b) end from t1) when 17 in (t1.e,13,f) then -13 else 11 end)/abs(t1.f)) in (select min(c) from t1 union select -count(*) | + -min(19) from t1))) and f<13),t1.e+t1.c) in (select count(distinct c)-count(*) from t1 union select -case min((e))+cast(avg(t1.a) AS integer) when ((min(t1.c))) then count(distinct e) else -cast(avg(t1.d) AS integer) end from t1)))))}
+} {20}
+do_test randexpr-2.1097 {
+ db eval {SELECT case when t1.a in (select t1.e*case when t1.b between t1.d and 11 or c-case when (t1.e=13) then ~e when e<>a then t1.d else t1.f end in (11,t1.e,t1.c) and 11 not between t1.a and 13 and 19<11 then 11 else t1.e end*t1.d from t1 union select t1.c from t1) then a when e between e and b then ((19)) else 11 end FROM t1 WHERE coalesce((select (select count(distinct t1.f) from t1) from t1 where case coalesce((select max(t1.d) from t1 where 17<>19),t1.d) when a then coalesce((select ~t1.f- - -c-c*17-f-c-t1.a from t1 where (t1.f) in (select max(11) from t1 union select ~cast(avg(17) AS integer) | ~count(*)+max(f)- -cast(avg(11) AS integer) from t1)),13) else e end in (a,t1.c,11)),c)>=t1.e}
+} {}
+do_test randexpr-2.1098 {
+ db eval {SELECT case when t1.a in (select t1.e*case when t1.b between t1.d and 11 or c-case when (t1.e=13) then ~e when e<>a then t1.d else t1.f end in (11,t1.e,t1.c) and 11 not between t1.a and 13 and 19<11 then 11 else t1.e end*t1.d from t1 union select t1.c from t1) then a when e between e and b then ((19)) else 11 end FROM t1 WHERE NOT (coalesce((select (select count(distinct t1.f) from t1) from t1 where case coalesce((select max(t1.d) from t1 where 17<>19),t1.d) when a then coalesce((select ~t1.f- - -c-c*17-f-c-t1.a from t1 where (t1.f) in (select max(11) from t1 union select ~cast(avg(17) AS integer) | ~count(*)+max(f)- -cast(avg(11) AS integer) from t1)),13) else e end in (a,t1.c,11)),c)>=t1.e)}
+} {11}
+do_test randexpr-2.1099 {
+ db eval {SELECT coalesce((select max(case t1.b+(select ~((cast(avg(17) AS integer)))*min(a)+ -count(distinct b)*cast(avg(t1.b) AS integer)-count(*)+max(19) from t1)-(e) when d then 13 else 13*c end+t1.c) from t1 where t1.b in (select +cast(avg(e) AS integer)*case count(*) when cast(avg(13) AS integer) then count(distinct t1.b) else count(*) end-(count(distinct 19))*min(t1.d) from t1 union select max(a) from t1)),(f))*e+t1.f*19 FROM t1 WHERE 17 not between -t1.e and d}
+} {}
+do_test randexpr-2.1100 {
+ db eval {SELECT coalesce((select max(case t1.b+(select ~((cast(avg(17) AS integer)))*min(a)+ -count(distinct b)*cast(avg(t1.b) AS integer)-count(*)+max(19) from t1)-(e) when d then 13 else 13*c end+t1.c) from t1 where t1.b in (select +cast(avg(e) AS integer)*case count(*) when cast(avg(13) AS integer) then count(distinct t1.b) else count(*) end-(count(distinct 19))*min(t1.d) from t1 union select max(a) from t1)),(f))*e+t1.f*19 FROM t1 WHERE NOT (17 not between -t1.e and d)}
+} {311400}
+do_test randexpr-2.1101 {
+ db eval {SELECT coalesce((select max(~19) from t1 where 11 in (select t1.b-11*coalesce((select max(b) from t1 where coalesce((select max(e) from t1 where c*case 19*19+coalesce((select 19 from t1 where (11 not in (13+t1.d,b,(11)))),13)*d when t1.e then t1.b else t1.b end+t1.e between d and t1.b),t1.b) | (f)<>13), - -17)+c from t1 union select -19 from t1)),17) FROM t1 WHERE ~t1.d not between 11*13-+t1.d-11-f and t1.d}
+} {}
+do_test randexpr-2.1102 {
+ db eval {SELECT coalesce((select max(~19) from t1 where 11 in (select t1.b-11*coalesce((select max(b) from t1 where coalesce((select max(e) from t1 where c*case 19*19+coalesce((select 19 from t1 where (11 not in (13+t1.d,b,(11)))),13)*d when t1.e then t1.b else t1.b end+t1.e between d and t1.b),t1.b) | (f)<>13), - -17)+c from t1 union select -19 from t1)),17) FROM t1 WHERE NOT (~t1.d not between 11*13-+t1.d-11-f and t1.d)}
+} {17}
+do_test randexpr-2.1103 {
+ db eval {SELECT coalesce((select max(~19) from t1 where 11 in (select t1.b-11*coalesce((select max(b) from t1 where coalesce((select max(e) from t1 where c*case 19*19+coalesce((select 19 from t1 where (11 not in (13+t1.d,b,(11)))),13)*d when t1.e then t1.b else t1.b end+t1.e between d and t1.b),t1.b) & (f)<>13), - -17)+c from t1 union select -19 from t1)),17) FROM t1 WHERE NOT (~t1.d not between 11*13-+t1.d-11-f and t1.d)}
+} {17}
+do_test randexpr-2.1104 {
+ db eval {SELECT case t1.b when coalesce((select max(17+coalesce((select max(coalesce((select (select count(distinct case f when 19 then coalesce((select coalesce((select max(11-(abs(d)/abs(11))) from t1 where not -a in (19,t1.b,17)),17) from t1 where (f in (b,f,t1.a))),b) else b end) from t1) from t1 where 17 between e and t1.f),t1.a)) from t1 where 13>=e),b)) from t1 where t1.f>t1.f),t1.b) then 17 else t1.f end FROM t1 WHERE not exists(select 1 from t1 where 13 between a+17 and (t1.c))}
+} {17}
+do_test randexpr-2.1105 {
+ db eval {SELECT case t1.b when coalesce((select max(17+coalesce((select max(coalesce((select (select count(distinct case f when 19 then coalesce((select coalesce((select max(11-(abs(d)/abs(11))) from t1 where not -a in (19,t1.b,17)),17) from t1 where (f in (b,f,t1.a))),b) else b end) from t1) from t1 where 17 between e and t1.f),t1.a)) from t1 where 13>=e),b)) from t1 where t1.f>t1.f),t1.b) then 17 else t1.f end FROM t1 WHERE NOT (not exists(select 1 from t1 where 13 between a+17 and (t1.c)))}
+} {}
+do_test randexpr-2.1106 {
+ db eval {SELECT case when coalesce((select max(d) from t1 where t1.a in (select a-a from t1 union select a from t1)),t1.b)*(select max(t1.b) from t1)>=case when t1.b<case 17 when 19 then t1.a else t1.a end then b when 17<19 then t1.e else t1.b end and (t1.e=t1.c or (not exists(select 1 from t1 where not exists(select 1 from t1 where a=(13)))) or t1.b between 17 and t1.d and b in (t1.f,f,13) or t1.d<e) then t1.c when t1.c between 19 and 11 then d else a end FROM t1 WHERE t1.c>=t1.a}
+} {300}
+do_test randexpr-2.1107 {
+ db eval {SELECT case when coalesce((select max(d) from t1 where t1.a in (select a-a from t1 union select a from t1)),t1.b)*(select max(t1.b) from t1)>=case when t1.b<case 17 when 19 then t1.a else t1.a end then b when 17<19 then t1.e else t1.b end and (t1.e=t1.c or (not exists(select 1 from t1 where not exists(select 1 from t1 where a=(13)))) or t1.b between 17 and t1.d and b in (t1.f,f,13) or t1.d<e) then t1.c when t1.c between 19 and 11 then d else a end FROM t1 WHERE NOT (t1.c>=t1.a)}
+} {}
+do_test randexpr-2.1108 {
+ db eval {SELECT case when case when f*~case when t1.c*t1.f in (c,t1.b,(17)) then 17 when 11>t1.c then 13 else t1.e end+t1.f in (select +max(e)+case (count(distinct a)*count(*))+max(19) when -max(11) then count(distinct a) else ((count(distinct t1.d))) end from t1 union select count(distinct c) from t1) then 17 else d end+(t1.c)<17 then b when not exists(select 1 from t1 where 11>t1.b) then t1.d else t1.a end FROM t1 WHERE t1.b< -f}
+} {}
+do_test randexpr-2.1109 {
+ db eval {SELECT case when case when f*~case when t1.c*t1.f in (c,t1.b,(17)) then 17 when 11>t1.c then 13 else t1.e end+t1.f in (select +max(e)+case (count(distinct a)*count(*))+max(19) when -max(11) then count(distinct a) else ((count(distinct t1.d))) end from t1 union select count(distinct c) from t1) then 17 else d end+(t1.c)<17 then b when not exists(select 1 from t1 where 11>t1.b) then t1.d else t1.a end FROM t1 WHERE NOT (t1.b< -f)}
+} {400}
+do_test randexpr-2.1110 {
+ db eval {SELECT (select cast(avg(f) AS integer) | ~++cast(avg((abs(17)/abs( -f+(c-coalesce((select case when c=d and t1.e=t1.b then e when e in (t1.b,19,t1.c) then 17 else d end from t1 where e between t1.a and t1.c),a))+a))) AS integer)-abs( -min(t1.c))-abs(max((t1.b)) | -~(count(*))+max(17))+cast(avg(t1.a) AS integer) | min(a)*(count(*))*min(17) from t1) FROM t1 WHERE b-(t1.e*t1.e)-t1.d=t1.c}
+} {}
+do_test randexpr-2.1111 {
+ db eval {SELECT (select cast(avg(f) AS integer) | ~++cast(avg((abs(17)/abs( -f+(c-coalesce((select case when c=d and t1.e=t1.b then e when e in (t1.b,19,t1.c) then 17 else d end from t1 where e between t1.a and t1.c),a))+a))) AS integer)-abs( -min(t1.c))-abs(max((t1.b)) | -~(count(*))+max(17))+cast(avg(t1.a) AS integer) | min(a)*(count(*))*min(17) from t1) FROM t1 WHERE NOT (b-(t1.e*t1.e)-t1.d=t1.c)}
+} {-260}
+do_test randexpr-2.1112 {
+ db eval {SELECT (select cast(avg(f) AS integer) & ~++cast(avg((abs(17)/abs( -f+(c-coalesce((select case when c=d and t1.e=t1.b then e when e in (t1.b,19,t1.c) then 17 else d end from t1 where e between t1.a and t1.c),a))+a))) AS integer)-abs( -min(t1.c))-abs(max((t1.b)) & -~(count(*))+max(17))+cast(avg(t1.a) AS integer) & min(a)*(count(*))*min(17) from t1) FROM t1 WHERE NOT (b-(t1.e*t1.e)-t1.d=t1.c)}
+} {512}
+do_test randexpr-2.1113 {
+ db eval {SELECT ~+coalesce((select case when t1.f>d then b when (abs(t1.a)/abs((abs(f)/abs(t1.c))))*case ~b when e then (select cast(avg( -+t1.f) AS integer) from t1) else c end+coalesce((select max(17*case t1.a+b when t1.b then t1.d else t1.f end) from t1 where d=e),t1.f)+13>=17 then 19 else f end from t1 where t1.a in (select d from t1 union select e from t1)),b) FROM t1 WHERE 17<>f-~t1.a-case when -b in (t1.b,(select min( -coalesce((select max(coalesce((select a- -t1.b from t1 where 11 in (t1.b,13, -t1.e) and f not between -13 and t1.b),c)) from t1 where b not in (a,11,17)),t1.e)) from t1),e) or not exists(select 1 from t1 where t1.c in (select t1.b from t1 union select t1.b from t1)) then coalesce((select -t1.e from t1 where e<>t1.e),f) when not t1.e<>t1.c then 19 else e end}
+} {-201}
+do_test randexpr-2.1114 {
+ db eval {SELECT ~+coalesce((select case when t1.f>d then b when (abs(t1.a)/abs((abs(f)/abs(t1.c))))*case ~b when e then (select cast(avg( -+t1.f) AS integer) from t1) else c end+coalesce((select max(17*case t1.a+b when t1.b then t1.d else t1.f end) from t1 where d=e),t1.f)+13>=17 then 19 else f end from t1 where t1.a in (select d from t1 union select e from t1)),b) FROM t1 WHERE NOT (17<>f-~t1.a-case when -b in (t1.b,(select min( -coalesce((select max(coalesce((select a- -t1.b from t1 where 11 in (t1.b,13, -t1.e) and f not between -13 and t1.b),c)) from t1 where b not in (a,11,17)),t1.e)) from t1),e) or not exists(select 1 from t1 where t1.c in (select t1.b from t1 union select t1.b from t1)) then coalesce((select -t1.e from t1 where e<>t1.e),f) when not t1.e<>t1.c then 19 else e end)}
+} {}
+do_test randexpr-2.1115 {
+ db eval {SELECT d- -e*(abs(t1.c)/abs(d)) | t1.a+ -coalesce((select max(t1.e) from t1 where case when case when (a in (13,b,t1.b)) and d in (t1.c,17,a) then 17+t1.e when 19>=t1.b then a else 11 end=t1.f and d between c and (d) then (abs(17)/abs(d)) else t1.d end*f>e and not f<=13 and -t1.f>=t1.e and t1.b<t1.b),t1.e)-case when t1.c<>e then t1.b else c end FROM t1 WHERE b-coalesce((select (coalesce((select max((coalesce((select d from t1 where not -case when case 13 when +~(select case count(*) when -max(t1.b) then max(a) else min(c) end from t1) then c else -a end in (17,t1.b,(b)) then f else b end-f+17<=t1.a),t1.f)-d)) from t1 where t1.e=b),t1.b)) from t1 where (t1.a=t1.c)), -t1.a) not between 19 and 19}
+} {-584}
+do_test randexpr-2.1116 {
+ db eval {SELECT d- -e*(abs(t1.c)/abs(d)) | t1.a+ -coalesce((select max(t1.e) from t1 where case when case when (a in (13,b,t1.b)) and d in (t1.c,17,a) then 17+t1.e when 19>=t1.b then a else 11 end=t1.f and d between c and (d) then (abs(17)/abs(d)) else t1.d end*f>e and not f<=13 and -t1.f>=t1.e and t1.b<t1.b),t1.e)-case when t1.c<>e then t1.b else c end FROM t1 WHERE NOT (b-coalesce((select (coalesce((select max((coalesce((select d from t1 where not -case when case 13 when +~(select case count(*) when -max(t1.b) then max(a) else min(c) end from t1) then c else -a end in (17,t1.b,(b)) then f else b end-f+17<=t1.a),t1.f)-d)) from t1 where t1.e=b),t1.b)) from t1 where (t1.a=t1.c)), -t1.a) not between 19 and 19)}
+} {}
+do_test randexpr-2.1117 {
+ db eval {SELECT d- -e*(abs(t1.c)/abs(d)) & t1.a+ -coalesce((select max(t1.e) from t1 where case when case when (a in (13,b,t1.b)) and d in (t1.c,17,a) then 17+t1.e when 19>=t1.b then a else 11 end=t1.f and d between c and (d) then (abs(17)/abs(d)) else t1.d end*f>e and not f<=13 and -t1.f>=t1.e and t1.b<t1.b),t1.e)-case when t1.c<>e then t1.b else c end FROM t1 WHERE b-coalesce((select (coalesce((select max((coalesce((select d from t1 where not -case when case 13 when +~(select case count(*) when -max(t1.b) then max(a) else min(c) end from t1) then c else -a end in (17,t1.b,(b)) then f else b end-f+17<=t1.a),t1.f)-d)) from t1 where t1.e=b),t1.b)) from t1 where (t1.a=t1.c)), -t1.a) not between 19 and 19}
+} {384}
+do_test randexpr-2.1118 {
+ db eval {SELECT 19-case 13-f when b then t1.a*11-t1.d-+17*t1.b-coalesce((select 17 from t1 where 13<=f),+coalesce((select (abs(17+~coalesce((select a from t1 where 11<>t1.b and 11 not between t1.e and 19),17)+t1.e+t1.d | b)/abs(c))+f from t1 where 19 not between 19 and c),d)) else 19 end*t1.e+b FROM t1 WHERE 11+11 not in (t1.c,t1.e,19) and f+19*19*case when ~t1.a+19*b between t1.a-case case when f=(t1.d) then ((t1.d)) else -d end*e when c then e else t1.a end*t1.e and c then t1.e else b end in (select d from t1 union select t1.a from t1) or t1.d>=t1.f or not exists(select 1 from t1 where a<=13)}
+} {-9281}
+do_test randexpr-2.1119 {
+ db eval {SELECT 19-case 13-f when b then t1.a*11-t1.d-+17*t1.b-coalesce((select 17 from t1 where 13<=f),+coalesce((select (abs(17+~coalesce((select a from t1 where 11<>t1.b and 11 not between t1.e and 19),17)+t1.e+t1.d | b)/abs(c))+f from t1 where 19 not between 19 and c),d)) else 19 end*t1.e+b FROM t1 WHERE NOT (11+11 not in (t1.c,t1.e,19) and f+19*19*case when ~t1.a+19*b between t1.a-case case when f=(t1.d) then ((t1.d)) else -d end*e when c then e else t1.a end*t1.e and c then t1.e else b end in (select d from t1 union select t1.a from t1) or t1.d>=t1.f or not exists(select 1 from t1 where a<=13))}
+} {}
+do_test randexpr-2.1120 {
+ db eval {SELECT 19-case 13-f when b then t1.a*11-t1.d-+17*t1.b-coalesce((select 17 from t1 where 13<=f),+coalesce((select (abs(17+~coalesce((select a from t1 where 11<>t1.b and 11 not between t1.e and 19),17)+t1.e+t1.d & b)/abs(c))+f from t1 where 19 not between 19 and c),d)) else 19 end*t1.e+b FROM t1 WHERE 11+11 not in (t1.c,t1.e,19) and f+19*19*case when ~t1.a+19*b between t1.a-case case when f=(t1.d) then ((t1.d)) else -d end*e when c then e else t1.a end*t1.e and c then t1.e else b end in (select d from t1 union select t1.a from t1) or t1.d>=t1.f or not exists(select 1 from t1 where a<=13)}
+} {-9281}
+do_test randexpr-2.1121 {
+ db eval {SELECT case 19 when e then t1.b-t1.d else 11+coalesce((select 19 from t1 where not (t1.a)+(abs(case coalesce((select coalesce((select t1.e from t1 where 11=d),a) from t1 where t1.d<=13),a) when 17 then 13 else t1.a end)/abs(t1.b))-t1.d*e+t1.d not between b and b or e in (select -min(c) from t1 union select min(t1.b) from t1)),(abs(e)/abs(t1.b)))+t1.c end FROM t1 WHERE exists(select 1 from t1 where c in (select t1.a from t1 union select f from t1))}
+} {}
+do_test randexpr-2.1122 {
+ db eval {SELECT case 19 when e then t1.b-t1.d else 11+coalesce((select 19 from t1 where not (t1.a)+(abs(case coalesce((select coalesce((select t1.e from t1 where 11=d),a) from t1 where t1.d<=13),a) when 17 then 13 else t1.a end)/abs(t1.b))-t1.d*e+t1.d not between b and b or e in (select -min(c) from t1 union select min(t1.b) from t1)),(abs(e)/abs(t1.b)))+t1.c end FROM t1 WHERE NOT (exists(select 1 from t1 where c in (select t1.a from t1 union select f from t1)))}
+} {313}
+do_test randexpr-2.1123 {
+ db eval {SELECT 17 | t1.d-(select +max(case when not exists(select 1 from t1 where (a<=t1.f)) then -19 else -t1.d end)- -min(t1.f+t1.f-(select (count(*)) from t1)) from t1)- -19 | b-d+coalesce((select max(d) from t1 where e-t1.a in (19,b,11) or e in (19,t1.b,c)),11) FROM t1 WHERE (11<=11 and case coalesce((select max((f)) from t1 where t1.b | case 11 when t1.e*t1.e then e else case when ~b-case when 19 not in (t1.d,13,e) then 13 when c between t1.e and b then 19 else t1.c end-(c) in (select -t1.f from t1 union select d from t1) then c else t1.b end end*t1.a in (19,e,c)),t1.a) when t1.d then t1.a else -a end not in (t1.c,b,t1.f))}
+} {-41}
+do_test randexpr-2.1124 {
+ db eval {SELECT 17 | t1.d-(select +max(case when not exists(select 1 from t1 where (a<=t1.f)) then -19 else -t1.d end)- -min(t1.f+t1.f-(select (count(*)) from t1)) from t1)- -19 | b-d+coalesce((select max(d) from t1 where e-t1.a in (19,b,11) or e in (19,t1.b,c)),11) FROM t1 WHERE NOT ((11<=11 and case coalesce((select max((f)) from t1 where t1.b | case 11 when t1.e*t1.e then e else case when ~b-case when 19 not in (t1.d,13,e) then 13 when c between t1.e and b then 19 else t1.c end-(c) in (select -t1.f from t1 union select d from t1) then c else t1.b end end*t1.a in (19,e,c)),t1.a) when t1.d then t1.a else -a end not in (t1.c,b,t1.f)))}
+} {}
+do_test randexpr-2.1125 {
+ db eval {SELECT 17 & t1.d-(select +max(case when not exists(select 1 from t1 where (a<=t1.f)) then -19 else -t1.d end)- -min(t1.f+t1.f-(select (count(*)) from t1)) from t1)- -19 & b-d+coalesce((select max(d) from t1 where e-t1.a in (19,b,11) or e in (19,t1.b,c)),11) FROM t1 WHERE (11<=11 and case coalesce((select max((f)) from t1 where t1.b | case 11 when t1.e*t1.e then e else case when ~b-case when 19 not in (t1.d,13,e) then 13 when c between t1.e and b then 19 else t1.c end-(c) in (select -t1.f from t1 union select d from t1) then c else t1.b end end*t1.a in (19,e,c)),t1.a) when t1.d then t1.a else -a end not in (t1.c,b,t1.f))}
+} {0}
+do_test randexpr-2.1126 {
+ db eval {SELECT case t1.e-d+b when coalesce((select (select max(t1.a | a | -(select (count(*))+( - - -count(*)) from t1)*19+ -f+t1.e) from t1) from t1 where not exists(select 1 from t1 where (d not between a and 11) or not d>=11 and exists(select 1 from t1 where not t1.a<>13)) or 19 not in (17,t1.c,t1.c)),19)*t1.c+d then b else c end-b FROM t1 WHERE c<17}
+} {}
+do_test randexpr-2.1127 {
+ db eval {SELECT case t1.e-d+b when coalesce((select (select max(t1.a | a | -(select (count(*))+( - - -count(*)) from t1)*19+ -f+t1.e) from t1) from t1 where not exists(select 1 from t1 where (d not between a and 11) or not d>=11 and exists(select 1 from t1 where not t1.a<>13)) or 19 not in (17,t1.c,t1.c)),19)*t1.c+d then b else c end-b FROM t1 WHERE NOT (c<17)}
+} {100}
+do_test randexpr-2.1128 {
+ db eval {SELECT case t1.e-d+b when coalesce((select (select max(t1.a & a & -(select (count(*))+( - - -count(*)) from t1)*19+ -f+t1.e) from t1) from t1 where not exists(select 1 from t1 where (d not between a and 11) or not d>=11 and exists(select 1 from t1 where not t1.a<>13)) or 19 not in (17,t1.c,t1.c)),19)*t1.c+d then b else c end-b FROM t1 WHERE NOT (c<17)}
+} {100}
+do_test randexpr-2.1129 {
+ db eval {SELECT f*f*(abs(case when (17-coalesce((select max(11) from t1 where coalesce((select max(t1.c-11*t1.a) from t1 where +e=(abs(d)/abs(11))+ -13),t1.b)<b and exists(select 1 from t1 where t1.f between d and -t1.c)),19)-19 in (select max(t1.e) | min(t1.e) from t1 union select count(*) from t1) and 17>t1.e) then e else 17 end)/abs(c)) FROM t1 WHERE (t1.a in ((t1.f-t1.c)+b,11,t1.a+f))}
+} {}
+do_test randexpr-2.1130 {
+ db eval {SELECT f*f*(abs(case when (17-coalesce((select max(11) from t1 where coalesce((select max(t1.c-11*t1.a) from t1 where +e=(abs(d)/abs(11))+ -13),t1.b)<b and exists(select 1 from t1 where t1.f between d and -t1.c)),19)-19 in (select max(t1.e) | min(t1.e) from t1 union select count(*) from t1) and 17>t1.e) then e else 17 end)/abs(c)) FROM t1 WHERE NOT ((t1.a in ((t1.f-t1.c)+b,11,t1.a+f)))}
+} {0}
+do_test randexpr-2.1131 {
+ db eval {SELECT f*f*(abs(case when (17-coalesce((select max(11) from t1 where coalesce((select max(t1.c-11*t1.a) from t1 where +e=(abs(d)/abs(11))+ -13),t1.b)<b and exists(select 1 from t1 where t1.f between d and -t1.c)),19)-19 in (select max(t1.e) & min(t1.e) from t1 union select count(*) from t1) and 17>t1.e) then e else 17 end)/abs(c)) FROM t1 WHERE NOT ((t1.a in ((t1.f-t1.c)+b,11,t1.a+f)))}
+} {0}
+do_test randexpr-2.1132 {
+ db eval {SELECT ( -19-f+coalesce((select max( -~case when case 11 when ~coalesce((select max(13) from t1 where not (e)<>(t1.c)),19)+11 | -19-f then -13 else t1.c end-e<=t1.a then 11 when not exists(select 1 from t1 where (not t1.c<19) and not (13<>17)) then -e else f end) from t1 where (b)<=t1.e),t1.d)+ -t1.c) | b FROM t1 WHERE (~(select (max(f)-count(distinct c)) from t1) | case when e>=t1.c then t1.b+(select abs(count(*)+max(c)*abs(count(distinct e)+max(t1.f))+cast(avg(c) AS integer)) | cast(avg(t1.d) AS integer)*min(11) from t1)-t1.c else c end in (select case -t1.b when 17 then 17 else -case when not t1.c not in (17,t1.d,17) then 19 else a end end from t1 union select a from t1)) or (11)<=t1.b}
+} {-771}
+do_test randexpr-2.1133 {
+ db eval {SELECT ( -19-f+coalesce((select max( -~case when case 11 when ~coalesce((select max(13) from t1 where not (e)<>(t1.c)),19)+11 | -19-f then -13 else t1.c end-e<=t1.a then 11 when not exists(select 1 from t1 where (not t1.c<19) and not (13<>17)) then -e else f end) from t1 where (b)<=t1.e),t1.d)+ -t1.c) | b FROM t1 WHERE NOT ((~(select (max(f)-count(distinct c)) from t1) | case when e>=t1.c then t1.b+(select abs(count(*)+max(c)*abs(count(distinct e)+max(t1.f))+cast(avg(c) AS integer)) | cast(avg(t1.d) AS integer)*min(11) from t1)-t1.c else c end in (select case -t1.b when 17 then 17 else -case when not t1.c not in (17,t1.d,17) then 19 else a end end from t1 union select a from t1)) or (11)<=t1.b)}
+} {}
+do_test randexpr-2.1134 {
+ db eval {SELECT ( -19-f+coalesce((select max( -~case when case 11 when ~coalesce((select max(13) from t1 where not (e)<>(t1.c)),19)+11 & -19-f then -13 else t1.c end-e<=t1.a then 11 when not exists(select 1 from t1 where (not t1.c<19) and not (13<>17)) then -e else f end) from t1 where (b)<=t1.e),t1.d)+ -t1.c) & b FROM t1 WHERE (~(select (max(f)-count(distinct c)) from t1) | case when e>=t1.c then t1.b+(select abs(count(*)+max(c)*abs(count(distinct e)+max(t1.f))+cast(avg(c) AS integer)) | cast(avg(t1.d) AS integer)*min(11) from t1)-t1.c else c end in (select case -t1.b when 17 then 17 else -case when not t1.c not in (17,t1.d,17) then 19 else a end end from t1 union select a from t1)) or (11)<=t1.b}
+} {64}
+do_test randexpr-2.1135 {
+ db eval {SELECT +case when (not exists(select 1 from t1 where (abs(t1.a+coalesce((select max(b+ -case when e=t1.f then (abs(d)/abs(t1.e)) when not exists(select 1 from t1 where 17<t1.c) then d else f end | -(t1.e) | 13*e) from t1 where f in (select t1.e from t1 union select t1.f from t1)),d) | 11)/abs(t1.b))-b not between b and t1.d) and t1.d>t1.c) then e else e end FROM t1 WHERE not t1.d-d+case b when t1.a+t1.a then t1.f+ -t1.e else 11+b*coalesce((select max(t1.f) from t1 where 11>= -f+t1.d),t1.c)*19 end not between d and t1.c-(11)+17}
+} {}
+do_test randexpr-2.1136 {
+ db eval {SELECT +case when (not exists(select 1 from t1 where (abs(t1.a+coalesce((select max(b+ -case when e=t1.f then (abs(d)/abs(t1.e)) when not exists(select 1 from t1 where 17<t1.c) then d else f end | -(t1.e) | 13*e) from t1 where f in (select t1.e from t1 union select t1.f from t1)),d) | 11)/abs(t1.b))-b not between b and t1.d) and t1.d>t1.c) then e else e end FROM t1 WHERE NOT (not t1.d-d+case b when t1.a+t1.a then t1.f+ -t1.e else 11+b*coalesce((select max(t1.f) from t1 where 11>= -f+t1.d),t1.c)*19 end not between d and t1.c-(11)+17)}
+} {500}
+do_test randexpr-2.1137 {
+ db eval {SELECT +case when (not exists(select 1 from t1 where (abs(t1.a+coalesce((select max(b+ -case when e=t1.f then (abs(d)/abs(t1.e)) when not exists(select 1 from t1 where 17<t1.c) then d else f end & -(t1.e) & 13*e) from t1 where f in (select t1.e from t1 union select t1.f from t1)),d) & 11)/abs(t1.b))-b not between b and t1.d) and t1.d>t1.c) then e else e end FROM t1 WHERE NOT (not t1.d-d+case b when t1.a+t1.a then t1.f+ -t1.e else 11+b*coalesce((select max(t1.f) from t1 where 11>= -f+t1.d),t1.c)*19 end not between d and t1.c-(11)+17)}
+} {500}
+do_test randexpr-2.1138 {
+ db eval {SELECT t1.d+case when (t1.a)<=11 then ~t1.a else ~19 end-+~ -coalesce((select t1.d from t1 where ~t1.f in (select (cast(avg(t1.e+c) AS integer)) from t1 union select count(distinct (abs(coalesce((select max(19) from t1 where not ~11-t1.a=t1.c+case when t1.d between c and t1.d then 11 when t1.f>=17 then f else 19 end*t1.c),17)+f)/abs(f))) from t1)),11) FROM t1 WHERE e>c}
+} {370}
+do_test randexpr-2.1139 {
+ db eval {SELECT t1.d+case when (t1.a)<=11 then ~t1.a else ~19 end-+~ -coalesce((select t1.d from t1 where ~t1.f in (select (cast(avg(t1.e+c) AS integer)) from t1 union select count(distinct (abs(coalesce((select max(19) from t1 where not ~11-t1.a=t1.c+case when t1.d between c and t1.d then 11 when t1.f>=17 then f else 19 end*t1.c),17)+f)/abs(f))) from t1)),11) FROM t1 WHERE NOT (e>c)}
+} {}
+do_test randexpr-2.1140 {
+ db eval {SELECT case when coalesce((select max(case b | d*(abs(t1.e)/abs(a))-f | t1.b when t1.e then coalesce((select max(t1.e) from t1 where t1.e between (select ~count(*)*cast(avg(19) AS integer) from t1) and case c when a then 13 else a end),t1.f)+e*c else t1.d end) from t1 where t1.a in (select t1.d from t1 union select 17 from t1)),e)+17<19 then t1.a else 19 end | 11+e-17*19 FROM t1 WHERE d*t1.c-case when case when ((13 in (17+e,b,11)) or 19>(13)) then (abs(coalesce((select t1.a from t1 where t1.a not in (13,c,t1.f)),11))/abs(t1.e))-f when t1.b not between t1.b and f then t1.d else t1.a end in (a,e,t1.d) then t1.f else t1.f end+f+t1.e in (t1.d,e,b)}
+} {}
+do_test randexpr-2.1141 {
+ db eval {SELECT case when coalesce((select max(case b | d*(abs(t1.e)/abs(a))-f | t1.b when t1.e then coalesce((select max(t1.e) from t1 where t1.e between (select ~count(*)*cast(avg(19) AS integer) from t1) and case c when a then 13 else a end),t1.f)+e*c else t1.d end) from t1 where t1.a in (select t1.d from t1 union select 17 from t1)),e)+17<19 then t1.a else 19 end | 11+e-17*19 FROM t1 WHERE NOT (d*t1.c-case when case when ((13 in (17+e,b,11)) or 19>(13)) then (abs(coalesce((select t1.a from t1 where t1.a not in (13,c,t1.f)),11))/abs(t1.e))-f when t1.b not between t1.b and f then t1.d else t1.a end in (a,e,t1.d) then t1.f else t1.f end+f+t1.e in (t1.d,e,b))}
+} {191}
+do_test randexpr-2.1142 {
+ db eval {SELECT case when coalesce((select max(case b & d*(abs(t1.e)/abs(a))-f & t1.b when t1.e then coalesce((select max(t1.e) from t1 where t1.e between (select ~count(*)*cast(avg(19) AS integer) from t1) and case c when a then 13 else a end),t1.f)+e*c else t1.d end) from t1 where t1.a in (select t1.d from t1 union select 17 from t1)),e)+17<19 then t1.a else 19 end & 11+e-17*19 FROM t1 WHERE NOT (d*t1.c-case when case when ((13 in (17+e,b,11)) or 19>(13)) then (abs(coalesce((select t1.a from t1 where t1.a not in (13,c,t1.f)),11))/abs(t1.e))-f when t1.b not between t1.b and f then t1.d else t1.a end in (a,e,t1.d) then t1.f else t1.f end+f+t1.e in (t1.d,e,b))}
+} {16}
+do_test randexpr-2.1143 {
+ db eval {SELECT ((select (count(*) | +~(case ++(min(t1.f+17+(11-case when b between d and d and t1.a not in (13,c,t1.c) and e< -t1.b then 17+(11) else t1.e end+ -b))) when case min(e) when min( -13) | ~max(t1.f) then count(distinct t1.f) | ~count(distinct t1.d) else count(*) end then min(t1.c) else -cast(avg(11) AS integer) end)+count(distinct (f))) from t1)+e) FROM t1 WHERE (a in (11*a-t1.a | t1.b+e*13,(f | a | (select min((select min(13)-min(17)*((count(distinct t1.d))) from t1)) from t1)+t1.a- -11)+(11),t1.c) and (a) between t1.d and t1.f or t1.d not between t1.c and f or d not in (t1.c,t1.f,c))}
+} {511}
+do_test randexpr-2.1144 {
+ db eval {SELECT ((select (count(*) | +~(case ++(min(t1.f+17+(11-case when b between d and d and t1.a not in (13,c,t1.c) and e< -t1.b then 17+(11) else t1.e end+ -b))) when case min(e) when min( -13) | ~max(t1.f) then count(distinct t1.f) | ~count(distinct t1.d) else count(*) end then min(t1.c) else -cast(avg(11) AS integer) end)+count(distinct (f))) from t1)+e) FROM t1 WHERE NOT ((a in (11*a-t1.a | t1.b+e*13,(f | a | (select min((select min(13)-min(17)*((count(distinct t1.d))) from t1)) from t1)+t1.a- -11)+(11),t1.c) and (a) between t1.d and t1.f or t1.d not between t1.c and f or d not in (t1.c,t1.f,c)))}
+} {}
+do_test randexpr-2.1145 {
+ db eval {SELECT ((select (count(*) & +~(case ++(min(t1.f+17+(11-case when b between d and d and t1.a not in (13,c,t1.c) and e< -t1.b then 17+(11) else t1.e end+ -b))) when case min(e) when min( -13) & ~max(t1.f) then count(distinct t1.f) & ~count(distinct t1.d) else count(*) end then min(t1.c) else -cast(avg(11) AS integer) end)+count(distinct (f))) from t1)+e) FROM t1 WHERE (a in (11*a-t1.a | t1.b+e*13,(f | a | (select min((select min(13)-min(17)*((count(distinct t1.d))) from t1)) from t1)+t1.a- -11)+(11),t1.c) and (a) between t1.d and t1.f or t1.d not between t1.c and f or d not in (t1.c,t1.f,c))}
+} {501}
+do_test randexpr-2.1146 {
+ db eval {SELECT coalesce((select max(13) from t1 where d in (select (max(19)*count(distinct case when t1.f between ~e and -b-t1.f then b else d end)-count(distinct f)) from t1 union select cast(avg(case e when case t1.b when -a | t1.e*19 then t1.a else -t1.c end then -d else t1.e end) AS integer) from t1)),case when t1.d in (select t1.e from t1 union select b from t1) then t1.f when t1.f between 13 and f then f else f end) FROM t1 WHERE c in (select (t1.a) from t1 union select e from t1)}
+} {}
+do_test randexpr-2.1147 {
+ db eval {SELECT coalesce((select max(13) from t1 where d in (select (max(19)*count(distinct case when t1.f between ~e and -b-t1.f then b else d end)-count(distinct f)) from t1 union select cast(avg(case e when case t1.b when -a | t1.e*19 then t1.a else -t1.c end then -d else t1.e end) AS integer) from t1)),case when t1.d in (select t1.e from t1 union select b from t1) then t1.f when t1.f between 13 and f then f else f end) FROM t1 WHERE NOT (c in (select (t1.a) from t1 union select e from t1))}
+} {600}
+do_test randexpr-2.1148 {
+ db eval {SELECT coalesce((select max(13) from t1 where d in (select (max(19)*count(distinct case when t1.f between ~e and -b-t1.f then b else d end)-count(distinct f)) from t1 union select cast(avg(case e when case t1.b when -a & t1.e*19 then t1.a else -t1.c end then -d else t1.e end) AS integer) from t1)),case when t1.d in (select t1.e from t1 union select b from t1) then t1.f when t1.f between 13 and f then f else f end) FROM t1 WHERE NOT (c in (select (t1.a) from t1 union select e from t1))}
+} {600}
+do_test randexpr-2.1149 {
+ db eval {SELECT (abs(t1.d+b)/abs(~t1.f+case when t1.f=t1.c or exists(select 1 from t1 where c>=+~t1.c*17) or exists(select 1 from t1 where (select -cast(avg(case when 19<>t1.f then -c when c<>b then t1.e else t1.d end) AS integer) from t1) in (d-t1.f,b,19)) then d+b when 11<b then t1.c else d end* -t1.a-19)) FROM t1 WHERE t1.a-(select cast(avg(a) AS integer) from t1) in (select t1.c from t1 union select 19 from t1) and not exists(select 1 from t1 where coalesce((select max(11) from t1 where case when not d>(19) then c else -case when 11>b or t1.c<=c then f when t1.f>t1.a then t1.a else t1.e end*d-11 end+d*t1.b>t1.e),d)>t1.b and c<>d and not exists(select 1 from t1 where 17>=(t1.f)) and t1.e not in (f,t1.b,t1.b))}
+} {}
+do_test randexpr-2.1150 {
+ db eval {SELECT (abs(t1.d+b)/abs(~t1.f+case when t1.f=t1.c or exists(select 1 from t1 where c>=+~t1.c*17) or exists(select 1 from t1 where (select -cast(avg(case when 19<>t1.f then -c when c<>b then t1.e else t1.d end) AS integer) from t1) in (d-t1.f,b,19)) then d+b when 11<b then t1.c else d end* -t1.a-19)) FROM t1 WHERE NOT (t1.a-(select cast(avg(a) AS integer) from t1) in (select t1.c from t1 union select 19 from t1) and not exists(select 1 from t1 where coalesce((select max(11) from t1 where case when not d>(19) then c else -case when 11>b or t1.c<=c then f when t1.f>t1.a then t1.a else t1.e end*d-11 end+d*t1.b>t1.e),d)>t1.b and c<>d and not exists(select 1 from t1 where 17>=(t1.f)) and t1.e not in (f,t1.b,t1.b)))}
+} {0}
+do_test randexpr-2.1151 {
+ db eval {SELECT t1.b-~case when +a in (select ~min(11) from t1 union select -count(*)+count(distinct ~coalesce((select coalesce((select t1.b-19+c from t1 where a<>13 or 13 in (t1.b,d,t1.e)),11) from t1 where 19 in (19,e,17)),e)) from t1) then (select -min(19)+cast(avg(t1.d) AS integer) from t1) else d end | 17 | t1.e FROM t1 WHERE c-b+e*11+(c+13+11)+(13)+(select cast(avg((abs(e-d+a)/abs(t1.f))) AS integer) from t1)-t1.d+~13<=t1.e-c-17}
+} {}
+do_test randexpr-2.1152 {
+ db eval {SELECT t1.b-~case when +a in (select ~min(11) from t1 union select -count(*)+count(distinct ~coalesce((select coalesce((select t1.b-19+c from t1 where a<>13 or 13 in (t1.b,d,t1.e)),11) from t1 where 19 in (19,e,17)),e)) from t1) then (select -min(19)+cast(avg(t1.d) AS integer) from t1) else d end | 17 | t1.e FROM t1 WHERE NOT (c-b+e*11+(c+13+11)+(13)+(select cast(avg((abs(e-d+a)/abs(t1.f))) AS integer) from t1)-t1.d+~13<=t1.e-c-17)}
+} {1021}
+do_test randexpr-2.1153 {
+ db eval {SELECT t1.b-~case when +a in (select ~min(11) from t1 union select -count(*)+count(distinct ~coalesce((select coalesce((select t1.b-19+c from t1 where a<>13 or 13 in (t1.b,d,t1.e)),11) from t1 where 19 in (19,e,17)),e)) from t1) then (select -min(19)+cast(avg(t1.d) AS integer) from t1) else d end & 17 & t1.e FROM t1 WHERE NOT (c-b+e*11+(c+13+11)+(13)+(select cast(avg((abs(e-d+a)/abs(t1.f))) AS integer) from t1)-t1.d+~13<=t1.e-c-17)}
+} {16}
+do_test randexpr-2.1154 {
+ db eval {SELECT coalesce((select max(b) from t1 where t1.e<t1.b-11*case when ( -c*case d when case +t1.c+t1.b when ~11*(select count(distinct d) from t1) then a else t1.d end then t1.b else (abs((select max(+coalesce((select (t1.d) from t1 where 19 not between t1.b and t1.a and t1.d between 19 and -13),t1.a)) from t1))/abs(f)) end)<>t1.e then 17 when 19 not between 11 and b then t1.e else 19 end*t1.c),t1.c) FROM t1 WHERE not t1.f*(abs(case when ~19-17*e>=t1.d then t1.b when (select cast(avg(t1.e) AS integer) from t1) in ((abs(t1.e)/abs(t1.e))-case when f not in (t1.d,13,c) then c else t1.e end-t1.b-t1.a | b-(t1.c), -a,e) then t1.e else e end+a)/abs(t1.d)) | b not between b and t1.d}
+} {}
+do_test randexpr-2.1155 {
+ db eval {SELECT coalesce((select max(b) from t1 where t1.e<t1.b-11*case when ( -c*case d when case +t1.c+t1.b when ~11*(select count(distinct d) from t1) then a else t1.d end then t1.b else (abs((select max(+coalesce((select (t1.d) from t1 where 19 not between t1.b and t1.a and t1.d between 19 and -13),t1.a)) from t1))/abs(f)) end)<>t1.e then 17 when 19 not between 11 and b then t1.e else 19 end*t1.c),t1.c) FROM t1 WHERE NOT (not t1.f*(abs(case when ~19-17*e>=t1.d then t1.b when (select cast(avg(t1.e) AS integer) from t1) in ((abs(t1.e)/abs(t1.e))-case when f not in (t1.d,13,c) then c else t1.e end-t1.b-t1.a | b-(t1.c), -a,e) then t1.e else e end+a)/abs(t1.d)) | b not between b and t1.d)}
+} {300}
+do_test randexpr-2.1156 {
+ db eval {SELECT -f+( - -case when 13-b not between case when (a<>t1.f or case when not exists(select 1 from t1 where 11<>t1.a) then b when c<=t1.b then t1.f else 11 end in (select 17 from t1 union select t1.b from t1)) then b-c-b when t1.f=13 then a else 19 end | t1.d and t1.e and not exists(select 1 from t1 where 19=t1.f) then -c else 19 end+17) FROM t1 WHERE not not exists(select 1 from t1 where ~(select cast(avg(t1.d) AS integer) from t1) | +~~case case when f-case when exists(select 1 from t1 where 13 not in (d,11,case when not exists(select 1 from t1 where f between t1.d and e) then 13 when t1.e<>19 then f else 11 end) or b in ( -d,t1.c,17)) then b else f end-(t1.d) in (t1.c,t1.c,b) then t1.b else e end when 11 then t1.e else -c end-c<>t1.b)}
+} {-883}
+do_test randexpr-2.1157 {
+ db eval {SELECT -f+( - -case when 13-b not between case when (a<>t1.f or case when not exists(select 1 from t1 where 11<>t1.a) then b when c<=t1.b then t1.f else 11 end in (select 17 from t1 union select t1.b from t1)) then b-c-b when t1.f=13 then a else 19 end | t1.d and t1.e and not exists(select 1 from t1 where 19=t1.f) then -c else 19 end+17) FROM t1 WHERE NOT (not not exists(select 1 from t1 where ~(select cast(avg(t1.d) AS integer) from t1) | +~~case case when f-case when exists(select 1 from t1 where 13 not in (d,11,case when not exists(select 1 from t1 where f between t1.d and e) then 13 when t1.e<>19 then f else 11 end) or b in ( -d,t1.c,17)) then b else f end-(t1.d) in (t1.c,t1.c,b) then t1.b else e end when 11 then t1.e else -c end-c<>t1.b))}
+} {}
+do_test randexpr-2.1158 {
+ db eval {SELECT -f+( - -case when 13-b not between case when (a<>t1.f or case when not exists(select 1 from t1 where 11<>t1.a) then b when c<=t1.b then t1.f else 11 end in (select 17 from t1 union select t1.b from t1)) then b-c-b when t1.f=13 then a else 19 end & t1.d and t1.e and not exists(select 1 from t1 where 19=t1.f) then -c else 19 end+17) FROM t1 WHERE not not exists(select 1 from t1 where ~(select cast(avg(t1.d) AS integer) from t1) | +~~case case when f-case when exists(select 1 from t1 where 13 not in (d,11,case when not exists(select 1 from t1 where f between t1.d and e) then 13 when t1.e<>19 then f else 11 end) or b in ( -d,t1.c,17)) then b else f end-(t1.d) in (t1.c,t1.c,b) then t1.b else e end when 11 then t1.e else -c end-c<>t1.b)}
+} {-883}
+do_test randexpr-2.1159 {
+ db eval {SELECT +(abs(d+d+a+b+t1.d)/abs(coalesce((select (select abs(cast(avg(17-11+e*t1.d) AS integer)++cast(avg(coalesce((select max(11-+t1.f- -e-a* -19+t1.a) from t1 where -a in (select 11 from t1 union select -11 from t1)),e)) AS integer)) from t1) from t1 where f=17),t1.b)*a)) FROM t1 WHERE t1.b in (select t1.e from t1 union select coalesce((select max(11) from t1 where d<t1.f),f) from t1)}
+} {}
+do_test randexpr-2.1160 {
+ db eval {SELECT +(abs(d+d+a+b+t1.d)/abs(coalesce((select (select abs(cast(avg(17-11+e*t1.d) AS integer)++cast(avg(coalesce((select max(11-+t1.f- -e-a* -19+t1.a) from t1 where -a in (select 11 from t1 union select -11 from t1)),e)) AS integer)) from t1) from t1 where f=17),t1.b)*a)) FROM t1 WHERE NOT (t1.b in (select t1.e from t1 union select coalesce((select max(11) from t1 where d<t1.f),f) from t1))}
+} {0}
+do_test randexpr-2.1161 {
+ db eval {SELECT case when t1.b*t1.c=coalesce((select t1.f from t1 where case when exists(select 1 from t1 where t1.d in (select e from t1 union select 19 from t1)) or t1.e>t1.e then t1.a+e-a when 19>t1.c then c else t1.c end+c not between b and t1.d),t1.f) and -(t1.b) between t1.e and -t1.d or b<>19 then (select ~(min(13))+max(f) from t1) else (t1.b) end*t1.b FROM t1 WHERE b in (b,e,case coalesce((select max(t1.b) from t1 where e>13 or ( -(select case -~count(distinct 17)-cast(avg((t1.f)) AS integer)*cast(avg(d) AS integer) when -cast(avg(f) AS integer) then max(17) else -(count(*)) end from t1)-(coalesce((select (b) from t1 where t1.b>=t1.e),t1.c)) in (17,t1.e,b)) or (exists(select 1 from t1 where (t1.d=(d))))),t1.c) when b then c else (e) end)}
+} {117200}
+do_test randexpr-2.1162 {
+ db eval {SELECT case when t1.b*t1.c=coalesce((select t1.f from t1 where case when exists(select 1 from t1 where t1.d in (select e from t1 union select 19 from t1)) or t1.e>t1.e then t1.a+e-a when 19>t1.c then c else t1.c end+c not between b and t1.d),t1.f) and -(t1.b) between t1.e and -t1.d or b<>19 then (select ~(min(13))+max(f) from t1) else (t1.b) end*t1.b FROM t1 WHERE NOT (b in (b,e,case coalesce((select max(t1.b) from t1 where e>13 or ( -(select case -~count(distinct 17)-cast(avg((t1.f)) AS integer)*cast(avg(d) AS integer) when -cast(avg(f) AS integer) then max(17) else -(count(*)) end from t1)-(coalesce((select (b) from t1 where t1.b>=t1.e),t1.c)) in (17,t1.e,b)) or (exists(select 1 from t1 where (t1.d=(d))))),t1.c) when b then c else (e) end))}
+} {}
+do_test randexpr-2.1163 {
+ db eval {SELECT +t1.c+case when t1.e not in ((e)-(case when 17<11 then 19 when (t1.d in (d,coalesce((select max(t1.a) from t1 where not b<>t1.b),case t1.b when coalesce((select max(t1.a) from t1 where exists(select 1 from t1 where e not in (t1.f,11,17))),(19))*t1.f then c else t1.c end+ -t1.d)-t1.b+t1.e,d)) then 19 else b end)-e,t1.c, -13) then e else 17 end FROM t1 WHERE t1.e*t1.b | t1.b<>17*+coalesce((select max(t1.b) from t1 where case when coalesce((select max(b) from t1 where case when (b between 17 and d) then t1.f when t1.c between b and t1.a then t1.e else t1.a end not in (11,19,13)),11) in (t1.d,17,17) then t1.f when d<>13 then 11 else t1.a end+a<17),t1.a)-17+t1.f*d-a}
+} {800}
+do_test randexpr-2.1164 {
+ db eval {SELECT +t1.c+case when t1.e not in ((e)-(case when 17<11 then 19 when (t1.d in (d,coalesce((select max(t1.a) from t1 where not b<>t1.b),case t1.b when coalesce((select max(t1.a) from t1 where exists(select 1 from t1 where e not in (t1.f,11,17))),(19))*t1.f then c else t1.c end+ -t1.d)-t1.b+t1.e,d)) then 19 else b end)-e,t1.c, -13) then e else 17 end FROM t1 WHERE NOT (t1.e*t1.b | t1.b<>17*+coalesce((select max(t1.b) from t1 where case when coalesce((select max(b) from t1 where case when (b between 17 and d) then t1.f when t1.c between b and t1.a then t1.e else t1.a end not in (11,19,13)),11) in (t1.d,17,17) then t1.f when d<>13 then 11 else t1.a end+a<17),t1.a)-17+t1.f*d-a)}
+} {}
+do_test randexpr-2.1165 {
+ db eval {SELECT 11+case when case case f when (abs(t1.a)/abs(19))+t1.e then (abs(19)/abs(b+e)) else 13 end | 11 when (select ~~+min(t1.e) from t1) then t1.c else -e end<>case t1.a when 17 then case when (c not between 19 and t1.b) and t1.b<>t1.d then coalesce((select a from t1 where t1.d in (t1.e,t1.f,f)),t1.e) else 13 end else d end or t1.c<t1.d then t1.f else 17 end-f FROM t1 WHERE (f*c*coalesce((select e from t1 where (exists(select 1 from t1 where +t1.e<= -e | t1.f))),a)+b in (select t1.c from t1 union select c from t1) or (t1.e between b and (19)) and 13 between t1.e and 13 and 11 in (13,t1.c,17) and exists(select 1 from t1 where t1.d in (select count(*)-max(e)-((max((11)))) from t1 union select max(17) from t1)) and c>f)}
+} {}
+do_test randexpr-2.1166 {
+ db eval {SELECT 11+case when case case f when (abs(t1.a)/abs(19))+t1.e then (abs(19)/abs(b+e)) else 13 end | 11 when (select ~~+min(t1.e) from t1) then t1.c else -e end<>case t1.a when 17 then case when (c not between 19 and t1.b) and t1.b<>t1.d then coalesce((select a from t1 where t1.d in (t1.e,t1.f,f)),t1.e) else 13 end else d end or t1.c<t1.d then t1.f else 17 end-f FROM t1 WHERE NOT ((f*c*coalesce((select e from t1 where (exists(select 1 from t1 where +t1.e<= -e | t1.f))),a)+b in (select t1.c from t1 union select c from t1) or (t1.e between b and (19)) and 13 between t1.e and 13 and 11 in (13,t1.c,17) and exists(select 1 from t1 where t1.d in (select count(*)-max(e)-((max((11)))) from t1 union select max(17) from t1)) and c>f))}
+} {11}
+do_test randexpr-2.1167 {
+ db eval {SELECT 11+case when case case f when (abs(t1.a)/abs(19))+t1.e then (abs(19)/abs(b+e)) else 13 end & 11 when (select ~~+min(t1.e) from t1) then t1.c else -e end<>case t1.a when 17 then case when (c not between 19 and t1.b) and t1.b<>t1.d then coalesce((select a from t1 where t1.d in (t1.e,t1.f,f)),t1.e) else 13 end else d end or t1.c<t1.d then t1.f else 17 end-f FROM t1 WHERE NOT ((f*c*coalesce((select e from t1 where (exists(select 1 from t1 where +t1.e<= -e | t1.f))),a)+b in (select t1.c from t1 union select c from t1) or (t1.e between b and (19)) and 13 between t1.e and 13 and 11 in (13,t1.c,17) and exists(select 1 from t1 where t1.d in (select count(*)-max(e)-((max((11)))) from t1 union select max(17) from t1)) and c>f))}
+} {11}
+do_test randexpr-2.1168 {
+ db eval {SELECT d-case when ~c<>case when not exists(select 1 from t1 where -t1.b<>19) then coalesce((select max(t1.f) from t1 where exists(select 1 from t1 where (t1.c in (select ~~+~max(~case when 13 not between t1.d and t1.d or c between c and f then t1.f else t1.a end)*abs(count(*)+(min( -t1.e))) from t1 union select cast(avg(e) AS integer) from t1) and (abs(t1.f*f-t1.a)/abs(d))>t1.b)) and (17) not in ( -t1.f,13,17)),19) else a end then b else f end FROM t1 WHERE f=(select case ~ -~count(distinct t1.b)+count(distinct d) | -count(distinct t1.e)*count(*)* -cast(avg(b) AS integer)*(cast(avg(13) AS integer)) when -min(19) then min(t1.e) else ((cast(avg(17) AS integer))) end from t1) or 19>=(19) and not exists(select 1 from t1 where (select count(*) from t1)*t1.d not between 19+11 and d) and -t1.e not in (e,t1.a, -a) and t1.e between t1.f and (t1.b) or c in ( -11,17,t1.c) or t1.a in (a,11,t1.d)}
+} {200}
+do_test randexpr-2.1169 {
+ db eval {SELECT d-case when ~c<>case when not exists(select 1 from t1 where -t1.b<>19) then coalesce((select max(t1.f) from t1 where exists(select 1 from t1 where (t1.c in (select ~~+~max(~case when 13 not between t1.d and t1.d or c between c and f then t1.f else t1.a end)*abs(count(*)+(min( -t1.e))) from t1 union select cast(avg(e) AS integer) from t1) and (abs(t1.f*f-t1.a)/abs(d))>t1.b)) and (17) not in ( -t1.f,13,17)),19) else a end then b else f end FROM t1 WHERE NOT (f=(select case ~ -~count(distinct t1.b)+count(distinct d) | -count(distinct t1.e)*count(*)* -cast(avg(b) AS integer)*(cast(avg(13) AS integer)) when -min(19) then min(t1.e) else ((cast(avg(17) AS integer))) end from t1) or 19>=(19) and not exists(select 1 from t1 where (select count(*) from t1)*t1.d not between 19+11 and d) and -t1.e not in (e,t1.a, -a) and t1.e between t1.f and (t1.b) or c in ( -11,17,t1.c) or t1.a in (a,11,t1.d))}
+} {}
+do_test randexpr-2.1170 {
+ db eval {SELECT case when a in (select t1.b from t1 union select coalesce((select ~19 from t1 where e>13*t1.d or c in (select b from t1 union select case a*t1.f when e then (t1.c) else (t1.b) end from t1)),t1.a) from t1) and t1.d>b or not exists(select 1 from t1 where t1.e in (select count(*)*min(t1.b)*~count(*) from t1 union select case -min((19)) when -max(b) then (min(t1.a)) else (count(distinct t1.d)) end from t1)) then (t1.c) when exists(select 1 from t1 where f not between 19 and f) then 19 else t1.c end-a FROM t1 WHERE a=coalesce((select f from t1 where t1.c in (11,(abs(coalesce((select max(t1.d) from t1 where (abs(t1.c | 13)/abs(11)) not in (b+case when coalesce((select max(b) from t1 where 11 between d and t1.a),b)<a then 19 when (e) not in (t1.e,13,t1.d) then t1.c else - -t1.e end-19,a,17)),19))/abs(t1.a)),t1.b) or (((13)>=t1.b))),c) and f between 19 and t1.d or c>(f)}
+} {}
+do_test randexpr-2.1171 {
+ db eval {SELECT case when a in (select t1.b from t1 union select coalesce((select ~19 from t1 where e>13*t1.d or c in (select b from t1 union select case a*t1.f when e then (t1.c) else (t1.b) end from t1)),t1.a) from t1) and t1.d>b or not exists(select 1 from t1 where t1.e in (select count(*)*min(t1.b)*~count(*) from t1 union select case -min((19)) when -max(b) then (min(t1.a)) else (count(distinct t1.d)) end from t1)) then (t1.c) when exists(select 1 from t1 where f not between 19 and f) then 19 else t1.c end-a FROM t1 WHERE NOT (a=coalesce((select f from t1 where t1.c in (11,(abs(coalesce((select max(t1.d) from t1 where (abs(t1.c | 13)/abs(11)) not in (b+case when coalesce((select max(b) from t1 where 11 between d and t1.a),b)<a then 19 when (e) not in (t1.e,13,t1.d) then t1.c else - -t1.e end-19,a,17)),19))/abs(t1.a)),t1.b) or (((13)>=t1.b))),c) and f between 19 and t1.d or c>(f))}
+} {200}
+do_test randexpr-2.1172 {
+ db eval {SELECT case when -(t1.f)- -case when t1.e not in ((t1.d)+a-t1.a,t1.c, - -a) then t1.b when (not exists(select 1 from t1 where t1.d>= -t1.f)) then -19 else f end-t1.f in (select cast(avg(19) AS integer)*case count(*) when abs((++min( -11))*max(13)-count(distinct 13)) then min(t1.a) else count(distinct 17) end from t1 union select count(distinct t1.a) from t1) then t1.c when b not between t1.f and 13 then e else t1.a end FROM t1 WHERE 11 not between ~17+d and ~case when t1.b in (c*((abs(case 13 when -(select abs(count(distinct coalesce((select max(coalesce((select t1.b from t1 where not exists(select 1 from t1 where (t1.c) in (t1.a,e,13))),t1.d)) from t1 where not t1.d>c),b))) from t1) then t1.f else t1.b end- -t1.c)/abs(c))+a),t1.d,t1.a) then (t1.c) else (d) end-13 or -t1.a in (17,a,f)}
+} {500}
+do_test randexpr-2.1173 {
+ db eval {SELECT case when -(t1.f)- -case when t1.e not in ((t1.d)+a-t1.a,t1.c, - -a) then t1.b when (not exists(select 1 from t1 where t1.d>= -t1.f)) then -19 else f end-t1.f in (select cast(avg(19) AS integer)*case count(*) when abs((++min( -11))*max(13)-count(distinct 13)) then min(t1.a) else count(distinct 17) end from t1 union select count(distinct t1.a) from t1) then t1.c when b not between t1.f and 13 then e else t1.a end FROM t1 WHERE NOT (11 not between ~17+d and ~case when t1.b in (c*((abs(case 13 when -(select abs(count(distinct coalesce((select max(coalesce((select t1.b from t1 where not exists(select 1 from t1 where (t1.c) in (t1.a,e,13))),t1.d)) from t1 where not t1.d>c),b))) from t1) then t1.f else t1.b end- -t1.c)/abs(c))+a),t1.d,t1.a) then (t1.c) else (d) end-13 or -t1.a in (17,a,f))}
+} {}
+do_test randexpr-2.1174 {
+ db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where (t1.b- -b+(select +case max(b)-~count(distinct e*(select case max(c) when abs((count(*))) then max(t1.f) else max(t1.c) end+cast(avg(t1.b) AS integer) from t1)) when abs(count(distinct e*19)) then max(b) else max(t1.c) end | count(distinct t1.e) from t1)-b*+t1.b not in ((11),17,13)))),t1.e) FROM t1 WHERE t1.c in (select min(coalesce((select 17 from t1 where t1.c | 17>=(abs(t1.a)/abs(case when t1.e not in (19,t1.d,19) then a when 13<=case when not exists(select 1 from t1 where (abs(e)/abs(t1.c)) in (select 19 from t1 union select d from t1) and t1.c>=17 or 19=t1.a) then f else a end then t1.d else e end))-f),e))*min(f) | ++min(a) from t1 union select cast(avg(f) AS integer) from t1)}
+} {}
+do_test randexpr-2.1175 {
+ db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where (t1.b- -b+(select +case max(b)-~count(distinct e*(select case max(c) when abs((count(*))) then max(t1.f) else max(t1.c) end+cast(avg(t1.b) AS integer) from t1)) when abs(count(distinct e*19)) then max(b) else max(t1.c) end | count(distinct t1.e) from t1)-b*+t1.b not in ((11),17,13)))),t1.e) FROM t1 WHERE NOT (t1.c in (select min(coalesce((select 17 from t1 where t1.c | 17>=(abs(t1.a)/abs(case when t1.e not in (19,t1.d,19) then a when 13<=case when not exists(select 1 from t1 where (abs(e)/abs(t1.c)) in (select 19 from t1 union select d from t1) and t1.c>=17 or 19=t1.a) then f else a end then t1.d else e end))-f),e))*min(f) | ++min(a) from t1 union select cast(avg(f) AS integer) from t1))}
+} {500}
+do_test randexpr-2.1176 {
+ db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where (t1.b- -b+(select +case max(b)-~count(distinct e*(select case max(c) when abs((count(*))) then max(t1.f) else max(t1.c) end+cast(avg(t1.b) AS integer) from t1)) when abs(count(distinct e*19)) then max(b) else max(t1.c) end & count(distinct t1.e) from t1)-b*+t1.b not in ((11),17,13)))),t1.e) FROM t1 WHERE NOT (t1.c in (select min(coalesce((select 17 from t1 where t1.c | 17>=(abs(t1.a)/abs(case when t1.e not in (19,t1.d,19) then a when 13<=case when not exists(select 1 from t1 where (abs(e)/abs(t1.c)) in (select 19 from t1 union select d from t1) and t1.c>=17 or 19=t1.a) then f else a end then t1.d else e end))-f),e))*min(f) | ++min(a) from t1 union select cast(avg(f) AS integer) from t1))}
+} {500}
+do_test randexpr-2.1177 {
+ db eval {SELECT case coalesce((select t1.e from t1 where +coalesce((select a from t1 where 13 | b | t1.b<=11*a*case when exists(select 1 from t1 where (a-t1.d+t1.e-f<17 and -17 between 19 and a)) then c when 17 between f and t1.c then a*11 else t1.d end),t1.e) not in (b,t1.f,t1.d)),a) when c then -c else t1.b end FROM t1 WHERE (exists(select 1 from t1 where case when not exists(select 1 from t1 where (select cast(avg(d) AS integer) from t1) in (select a from t1 union select case case when t1.e>t1.d or t1.b in (select c from t1 union select e from t1) or t1.a>=f and b>=11 then t1.c-(t1.c)*19 when b not in (e,c,t1.d) then t1.b else t1.c end when 13 then f else -t1.f end from t1)) then 17 when not exists(select 1 from t1 where not exists(select 1 from t1 where f not in (t1.d,f, -t1.b)) or -19<=t1.c) or t1.e between 13 and t1.a then f else d end<>t1.f) and f between 11 and t1.c and t1.e not in (t1.d,c,t1.e)) or d not between t1.b and t1.d}
+} {}
+do_test randexpr-2.1178 {
+ db eval {SELECT case coalesce((select t1.e from t1 where +coalesce((select a from t1 where 13 | b | t1.b<=11*a*case when exists(select 1 from t1 where (a-t1.d+t1.e-f<17 and -17 between 19 and a)) then c when 17 between f and t1.c then a*11 else t1.d end),t1.e) not in (b,t1.f,t1.d)),a) when c then -c else t1.b end FROM t1 WHERE NOT ((exists(select 1 from t1 where case when not exists(select 1 from t1 where (select cast(avg(d) AS integer) from t1) in (select a from t1 union select case case when t1.e>t1.d or t1.b in (select c from t1 union select e from t1) or t1.a>=f and b>=11 then t1.c-(t1.c)*19 when b not in (e,c,t1.d) then t1.b else t1.c end when 13 then f else -t1.f end from t1)) then 17 when not exists(select 1 from t1 where not exists(select 1 from t1 where f not in (t1.d,f, -t1.b)) or -19<=t1.c) or t1.e between 13 and t1.a then f else d end<>t1.f) and f between 11 and t1.c and t1.e not in (t1.d,c,t1.e)) or d not between t1.b and t1.d)}
+} {200}
+do_test randexpr-2.1179 {
+ db eval {SELECT case coalesce((select t1.e from t1 where +coalesce((select a from t1 where 13 & b & t1.b<=11*a*case when exists(select 1 from t1 where (a-t1.d+t1.e-f<17 and -17 between 19 and a)) then c when 17 between f and t1.c then a*11 else t1.d end),t1.e) not in (b,t1.f,t1.d)),a) when c then -c else t1.b end FROM t1 WHERE NOT ((exists(select 1 from t1 where case when not exists(select 1 from t1 where (select cast(avg(d) AS integer) from t1) in (select a from t1 union select case case when t1.e>t1.d or t1.b in (select c from t1 union select e from t1) or t1.a>=f and b>=11 then t1.c-(t1.c)*19 when b not in (e,c,t1.d) then t1.b else t1.c end when 13 then f else -t1.f end from t1)) then 17 when not exists(select 1 from t1 where not exists(select 1 from t1 where f not in (t1.d,f, -t1.b)) or -19<=t1.c) or t1.e between 13 and t1.a then f else d end<>t1.f) and f between 11 and t1.c and t1.e not in (t1.d,c,t1.e)) or d not between t1.b and t1.d)}
+} {200}
+do_test randexpr-2.1180 {
+ db eval {SELECT case when exists(select 1 from t1 where b<>coalesce((select (select + - -count(*)-~count(*)+~+case - -count(distinct (t1.d)) when max(t1.d) then count(*) else max(a) end+(cast(avg(17) AS integer)) from t1) | d from t1 where not exists(select 1 from t1 where (abs(f)/abs(t1.c)) between 13+a and -t1.d)),19) or (coalesce((select t1.d from t1 where (( - -19)>a)),t1.f) in (e,e,t1.e))) then t1.b*t1.f when t1.d not between (a) and a then e else b end FROM t1 WHERE not exists(select 1 from t1 where a in (select 13 from t1 union select 17 from t1))}
+} {120000}
+do_test randexpr-2.1181 {
+ db eval {SELECT case when exists(select 1 from t1 where b<>coalesce((select (select + - -count(*)-~count(*)+~+case - -count(distinct (t1.d)) when max(t1.d) then count(*) else max(a) end+(cast(avg(17) AS integer)) from t1) | d from t1 where not exists(select 1 from t1 where (abs(f)/abs(t1.c)) between 13+a and -t1.d)),19) or (coalesce((select t1.d from t1 where (( - -19)>a)),t1.f) in (e,e,t1.e))) then t1.b*t1.f when t1.d not between (a) and a then e else b end FROM t1 WHERE NOT (not exists(select 1 from t1 where a in (select 13 from t1 union select 17 from t1)))}
+} {}
+do_test randexpr-2.1182 {
+ db eval {SELECT case when exists(select 1 from t1 where b<>coalesce((select (select + - -count(*)-~count(*)+~+case - -count(distinct (t1.d)) when max(t1.d) then count(*) else max(a) end+(cast(avg(17) AS integer)) from t1) & d from t1 where not exists(select 1 from t1 where (abs(f)/abs(t1.c)) between 13+a and -t1.d)),19) or (coalesce((select t1.d from t1 where (( - -19)>a)),t1.f) in (e,e,t1.e))) then t1.b*t1.f when t1.d not between (a) and a then e else b end FROM t1 WHERE not exists(select 1 from t1 where a in (select 13 from t1 union select 17 from t1))}
+} {120000}
+do_test randexpr-2.1183 {
+ db eval {SELECT coalesce((select case when f>17-t1.f then (select +max(coalesce((select +11 from t1 where coalesce((select max(d) from t1 where +t1.c between (f) and c),t1.f) not in (c, -f,t1.e)),d)) from t1) else 17+19 end from t1 where not not exists(select 1 from t1 where t1.a in (select a from t1 union select t1.a from t1) and 17=d or (17)<=(( -19)) and t1.f in (select d from t1 union select 13 from t1) or 19>13 or t1.b not in (t1.b,17,d))), -(t1.c)) FROM t1 WHERE +t1.a-13+(select count(distinct a) from t1)-e*e*case when coalesce((select max(coalesce((select a from t1 where ((case b+t1.c-t1.c*d*17 when t1.a then t1.a else f end<>c))),t1.b+13)) from t1 where t1.f between 17 and t1.d),t1.c)<=(b) then f else t1.e end-13<>t1.f}
+} {11}
+do_test randexpr-2.1184 {
+ db eval {SELECT coalesce((select case when f>17-t1.f then (select +max(coalesce((select +11 from t1 where coalesce((select max(d) from t1 where +t1.c between (f) and c),t1.f) not in (c, -f,t1.e)),d)) from t1) else 17+19 end from t1 where not not exists(select 1 from t1 where t1.a in (select a from t1 union select t1.a from t1) and 17=d or (17)<=(( -19)) and t1.f in (select d from t1 union select 13 from t1) or 19>13 or t1.b not in (t1.b,17,d))), -(t1.c)) FROM t1 WHERE NOT (+t1.a-13+(select count(distinct a) from t1)-e*e*case when coalesce((select max(coalesce((select a from t1 where ((case b+t1.c-t1.c*d*17 when t1.a then t1.a else f end<>c))),t1.b+13)) from t1 where t1.f between 17 and t1.d),t1.c)<=(b) then f else t1.e end-13<>t1.f)}
+} {}
+do_test randexpr-2.1185 {
+ db eval {SELECT coalesce((select 13 from t1 where ~(select max(b) from t1)<= -+d*f+t1.b*f or coalesce((select max(case when d=(abs(19)/abs(t1.f)) then case b+d when (abs(coalesce((select 11 from t1 where t1.f between -d and c),t1.f))/abs(t1.a)) then b else t1.d end when a<t1.d then 13 else 11 end) from t1 where a not between t1.e and b),t1.d)>=t1.e),17)+ -c FROM t1 WHERE t1.b-+(t1.b) in (select a from t1 union select 19 from t1)}
+} {}
+do_test randexpr-2.1186 {
+ db eval {SELECT coalesce((select 13 from t1 where ~(select max(b) from t1)<= -+d*f+t1.b*f or coalesce((select max(case when d=(abs(19)/abs(t1.f)) then case b+d when (abs(coalesce((select 11 from t1 where t1.f between -d and c),t1.f))/abs(t1.a)) then b else t1.d end when a<t1.d then 13 else 11 end) from t1 where a not between t1.e and b),t1.d)>=t1.e),17)+ -c FROM t1 WHERE NOT (t1.b-+(t1.b) in (select a from t1 union select 19 from t1))}
+} {-283}
+do_test randexpr-2.1187 {
+ db eval {SELECT case when (abs((abs(d)/abs(t1.f-c)))/abs( -t1.f))*case when (t1.c not in (case when t1.b>case t1.d when t1.b then e else 11 end then t1.a when ( -t1.d in (select -count(*)-cast(avg(f) AS integer) from t1 union select count(*) from t1)) or 11 in (e,t1.e,c) then a else b end,t1.a,11) or t1.a in (17,t1.a,t1.d) and b>(t1.a)) then 11 when c<b then t1.f+t1.e else b end+t1.a>t1.b then t1.c else 17 end FROM t1 WHERE t1.b>f}
+} {}
+do_test randexpr-2.1188 {
+ db eval {SELECT case when (abs((abs(d)/abs(t1.f-c)))/abs( -t1.f))*case when (t1.c not in (case when t1.b>case t1.d when t1.b then e else 11 end then t1.a when ( -t1.d in (select -count(*)-cast(avg(f) AS integer) from t1 union select count(*) from t1)) or 11 in (e,t1.e,c) then a else b end,t1.a,11) or t1.a in (17,t1.a,t1.d) and b>(t1.a)) then 11 when c<b then t1.f+t1.e else b end+t1.a>t1.b then t1.c else 17 end FROM t1 WHERE NOT (t1.b>f)}
+} {17}
+do_test randexpr-2.1189 {
+ db eval {SELECT t1.e-case when case when ((exists(select 1 from t1 where not exists(select 1 from t1 where case when not 13<=13 or (t1.c<>t1.e) then t1.d else +13 end+13 in (select max(13) | max((t1.b)) from t1 union select max(f) from t1))))) then t1.f else ~t1.e | t1.d*t1.b end+11 not between t1.c and 13 then b when (t1.f not in (19,t1.f,t1.d)) then c else -b end FROM t1 WHERE ( -(select -min(13-t1.b) from t1)-coalesce((select case when -d>=t1.e or 11 between 17 and -t1.e then 19+f when t1.f=11 then -t1.c else t1.b end from t1 where t1.a not in (11,t1.e,t1.a)),t1.c)*11 in (select -case abs((abs(min(t1.d)))) when max(19) then cast(avg(f) AS integer) else case count(*) when count(*) then (count(distinct t1.f)) else cast(avg(11) AS integer) end end from t1 union select min(d) from t1)) or b in (select (count(*)) from t1 union select max(t1.a) from t1)}
+} {}
+do_test randexpr-2.1190 {
+ db eval {SELECT t1.e-case when case when ((exists(select 1 from t1 where not exists(select 1 from t1 where case when not 13<=13 or (t1.c<>t1.e) then t1.d else +13 end+13 in (select max(13) | max((t1.b)) from t1 union select max(f) from t1))))) then t1.f else ~t1.e | t1.d*t1.b end+11 not between t1.c and 13 then b when (t1.f not in (19,t1.f,t1.d)) then c else -b end FROM t1 WHERE NOT (( -(select -min(13-t1.b) from t1)-coalesce((select case when -d>=t1.e or 11 between 17 and -t1.e then 19+f when t1.f=11 then -t1.c else t1.b end from t1 where t1.a not in (11,t1.e,t1.a)),t1.c)*11 in (select -case abs((abs(min(t1.d)))) when max(19) then cast(avg(f) AS integer) else case count(*) when count(*) then (count(distinct t1.f)) else cast(avg(11) AS integer) end end from t1 union select min(d) from t1)) or b in (select (count(*)) from t1 union select max(t1.a) from t1))}
+} {300}
+do_test randexpr-2.1191 {
+ db eval {SELECT t1.e-case when case when ((exists(select 1 from t1 where not exists(select 1 from t1 where case when not 13<=13 or (t1.c<>t1.e) then t1.d else +13 end+13 in (select max(13) & max((t1.b)) from t1 union select max(f) from t1))))) then t1.f else ~t1.e & t1.d*t1.b end+11 not between t1.c and 13 then b when (t1.f not in (19,t1.f,t1.d)) then c else -b end FROM t1 WHERE NOT (( -(select -min(13-t1.b) from t1)-coalesce((select case when -d>=t1.e or 11 between 17 and -t1.e then 19+f when t1.f=11 then -t1.c else t1.b end from t1 where t1.a not in (11,t1.e,t1.a)),t1.c)*11 in (select -case abs((abs(min(t1.d)))) when max(19) then cast(avg(f) AS integer) else case count(*) when count(*) then (count(distinct t1.f)) else cast(avg(11) AS integer) end end from t1 union select min(d) from t1)) or b in (select (count(*)) from t1 union select max(t1.a) from t1))}
+} {300}
+do_test randexpr-2.1192 {
+ db eval {SELECT (coalesce((select c*(select +~count(distinct 19)-cast(avg(~ -c) AS integer)-max( -f)-cast(avg(t1.d) AS integer) from t1)+t1.a*t1.f+t1.e-a*b from t1 where not t1.e<t1.b or 11=d and 19<>d and 11<=t1.e and (not exists(select 1 from t1 where exists(select 1 from t1 where (13=a)) or t1.e>t1.b))),19)) FROM t1 WHERE coalesce((select max(t1.f*11) from t1 where not exists(select 1 from t1 where t1.a<>17) and t1.b>case (abs(b* -t1.a)/abs(11)) when b*case case when f>=t1.e then 11 when t1.b<=d then 17 else a end* -a when e then 11 else c end then (t1.b) else 19 end or t1.f<13), -b)>=e and ((d in (select f from t1 union select f from t1)))}
+} {}
+do_test randexpr-2.1193 {
+ db eval {SELECT (coalesce((select c*(select +~count(distinct 19)-cast(avg(~ -c) AS integer)-max( -f)-cast(avg(t1.d) AS integer) from t1)+t1.a*t1.f+t1.e-a*b from t1 where not t1.e<t1.b or 11=d and 19<>d and 11<=t1.e and (not exists(select 1 from t1 where exists(select 1 from t1 where (13=a)) or t1.e>t1.b))),19)) FROM t1 WHERE NOT (coalesce((select max(t1.f*11) from t1 where not exists(select 1 from t1 where t1.a<>17) and t1.b>case (abs(b* -t1.a)/abs(11)) when b*case case when f>=t1.e then 11 when t1.b<=d then 17 else a end* -a when e then 11 else c end then (t1.b) else 19 end or t1.f<13), -b)>=e and ((d in (select f from t1 union select f from t1))))}
+} {10200}
+do_test randexpr-2.1194 {
+ db eval {SELECT b-b+case when d+e between 17 and case when exists(select 1 from t1 where coalesce((select max(coalesce((select 11 from t1 where t1.e not between 13 and case when t1.e<>c then c | 19+t1.a else 17 end),t1.a)) from t1 where t1.d<=17 or a not in (b,11,a)),(t1.b))+b>=t1.a) then 11 else a end then d else a end+11*f FROM t1 WHERE (t1.b*19<=17)}
+} {}
+do_test randexpr-2.1195 {
+ db eval {SELECT b-b+case when d+e between 17 and case when exists(select 1 from t1 where coalesce((select max(coalesce((select 11 from t1 where t1.e not between 13 and case when t1.e<>c then c | 19+t1.a else 17 end),t1.a)) from t1 where t1.d<=17 or a not in (b,11,a)),(t1.b))+b>=t1.a) then 11 else a end then d else a end+11*f FROM t1 WHERE NOT ((t1.b*19<=17))}
+} {6700}
+do_test randexpr-2.1196 {
+ db eval {SELECT b-b+case when d+e between 17 and case when exists(select 1 from t1 where coalesce((select max(coalesce((select 11 from t1 where t1.e not between 13 and case when t1.e<>c then c & 19+t1.a else 17 end),t1.a)) from t1 where t1.d<=17 or a not in (b,11,a)),(t1.b))+b>=t1.a) then 11 else a end then d else a end+11*f FROM t1 WHERE NOT ((t1.b*19<=17))}
+} {6700}
+do_test randexpr-2.1197 {
+ db eval {SELECT +(abs(13)/abs(+~~case t1.e | +11-b-coalesce((select max(c) from t1 where 19 in (select cast(avg(coalesce((select max(case when t1.a<t1.d and t1.f<(11) then t1.f else -a end*t1.c) from t1 where e<=d and c<f),17)) AS integer)- -max(t1.e)-count(distinct a) from t1 union select max(f) from t1)),t1.c) when t1.a then t1.e else t1.c end*17)) FROM t1 WHERE t1.a between 19 and (t1.b)}
+} {0}
+do_test randexpr-2.1198 {
+ db eval {SELECT +(abs(13)/abs(+~~case t1.e | +11-b-coalesce((select max(c) from t1 where 19 in (select cast(avg(coalesce((select max(case when t1.a<t1.d and t1.f<(11) then t1.f else -a end*t1.c) from t1 where e<=d and c<f),17)) AS integer)- -max(t1.e)-count(distinct a) from t1 union select max(f) from t1)),t1.c) when t1.a then t1.e else t1.c end*17)) FROM t1 WHERE NOT (t1.a between 19 and (t1.b))}
+} {}
+do_test randexpr-2.1199 {
+ db eval {SELECT +(abs(13)/abs(+~~case t1.e & +11-b-coalesce((select max(c) from t1 where 19 in (select cast(avg(coalesce((select max(case when t1.a<t1.d and t1.f<(11) then t1.f else -a end*t1.c) from t1 where e<=d and c<f),17)) AS integer)- -max(t1.e)-count(distinct a) from t1 union select max(f) from t1)),t1.c) when t1.a then t1.e else t1.c end*17)) FROM t1 WHERE t1.a between 19 and (t1.b)}
+} {0}
+do_test randexpr-2.1200 {
+ db eval {SELECT coalesce((select t1.f from t1 where case d-(select case cast(avg(coalesce((select case when not 11<>e*c then 11 else 13 end from t1 where -t1.c not between t1.f and 11),t1.e)) AS integer) when case max( -d) when ((min(17))) then cast(avg(t1.a) AS integer) else min(e) end+cast(avg((t1.b)) AS integer) then cast(avg(t1.d) AS integer) else -(max(c)) end from t1)-f | b*13+e when t1.b then (f) else t1.a end in (select d from t1 union select 17 from t1)),d) FROM t1 WHERE t1.e*c>13-+t1.f | (abs((select abs(min(b)-abs( - -count(distinct 17-d-13+ -e-(t1.d)*e)+max(t1.e)) | (~abs((max(c)))+cast(avg(17) AS integer)-count(*)*cast(avg(11) AS integer))) from t1))/abs(t1.f))}
+} {400}
+do_test randexpr-2.1201 {
+ db eval {SELECT coalesce((select t1.f from t1 where case d-(select case cast(avg(coalesce((select case when not 11<>e*c then 11 else 13 end from t1 where -t1.c not between t1.f and 11),t1.e)) AS integer) when case max( -d) when ((min(17))) then cast(avg(t1.a) AS integer) else min(e) end+cast(avg((t1.b)) AS integer) then cast(avg(t1.d) AS integer) else -(max(c)) end from t1)-f | b*13+e when t1.b then (f) else t1.a end in (select d from t1 union select 17 from t1)),d) FROM t1 WHERE NOT (t1.e*c>13-+t1.f | (abs((select abs(min(b)-abs( - -count(distinct 17-d-13+ -e-(t1.d)*e)+max(t1.e)) | (~abs((max(c)))+cast(avg(17) AS integer)-count(*)*cast(avg(11) AS integer))) from t1))/abs(t1.f)))}
+} {}
+do_test randexpr-2.1202 {
+ db eval {SELECT coalesce((select t1.f from t1 where case d-(select case cast(avg(coalesce((select case when not 11<>e*c then 11 else 13 end from t1 where -t1.c not between t1.f and 11),t1.e)) AS integer) when case max( -d) when ((min(17))) then cast(avg(t1.a) AS integer) else min(e) end+cast(avg((t1.b)) AS integer) then cast(avg(t1.d) AS integer) else -(max(c)) end from t1)-f & b*13+e when t1.b then (f) else t1.a end in (select d from t1 union select 17 from t1)),d) FROM t1 WHERE t1.e*c>13-+t1.f | (abs((select abs(min(b)-abs( - -count(distinct 17-d-13+ -e-(t1.d)*e)+max(t1.e)) | (~abs((max(c)))+cast(avg(17) AS integer)-count(*)*cast(avg(11) AS integer))) from t1))/abs(t1.f))}
+} {400}
+do_test randexpr-2.1203 {
+ db eval {SELECT t1.b-~case when ~(abs(17)/abs(t1.a))+17+t1.b in (select count(distinct d) | count(*) from t1 union select case count(*) | count(distinct e) when count(*) then -count(*) else cast(avg(11) AS integer) end from t1) and t1.e>b or e not between (e) and c and 17 in (t1.c,b,b) and t1.a not between a and (t1.f) then coalesce((select t1.a*t1.c from t1 where -11 in (t1.a,(t1.f), -f)),13)*t1.c else t1.f end FROM t1 WHERE (t1.e<>t1.a+~~c-t1.a+13*e-17+t1.b)}
+} {801}
+do_test randexpr-2.1204 {
+ db eval {SELECT t1.b-~case when ~(abs(17)/abs(t1.a))+17+t1.b in (select count(distinct d) | count(*) from t1 union select case count(*) | count(distinct e) when count(*) then -count(*) else cast(avg(11) AS integer) end from t1) and t1.e>b or e not between (e) and c and 17 in (t1.c,b,b) and t1.a not between a and (t1.f) then coalesce((select t1.a*t1.c from t1 where -11 in (t1.a,(t1.f), -f)),13)*t1.c else t1.f end FROM t1 WHERE NOT ((t1.e<>t1.a+~~c-t1.a+13*e-17+t1.b))}
+} {}
+do_test randexpr-2.1205 {
+ db eval {SELECT t1.b-~case when ~(abs(17)/abs(t1.a))+17+t1.b in (select count(distinct d) & count(*) from t1 union select case count(*) & count(distinct e) when count(*) then -count(*) else cast(avg(11) AS integer) end from t1) and t1.e>b or e not between (e) and c and 17 in (t1.c,b,b) and t1.a not between a and (t1.f) then coalesce((select t1.a*t1.c from t1 where -11 in (t1.a,(t1.f), -f)),13)*t1.c else t1.f end FROM t1 WHERE (t1.e<>t1.a+~~c-t1.a+13*e-17+t1.b)}
+} {801}
+do_test randexpr-2.1206 {
+ db eval {SELECT ((abs(b)/abs(t1.e+coalesce((select max((abs(coalesce((select max(11) from t1 where t1.a<=coalesce((select case when t1.a in (case t1.b when t1.d then t1.d else a end,17,11) then 13 when t1.a>b then 19 else d end from t1 where c in (select (~case count(*) when min(f) then -min(d) else count(distinct (t1.f)) end)*(count(*)) from t1 union select -min((t1.c)) from t1)),11) and (b<=t1.c)),t1.f))/abs(e))-13) from t1 where b not in (d,( -e),e)),c)-t1.c))) FROM t1 WHERE (exists(select 1 from t1 where b in (select +( -abs(max(19+((select case -+cast(avg(e) AS integer) when -max(19)-min(t1.c) | count(*) then count(distinct t1.e) else min(f) end-cast(avg( -19) AS integer)*count(*) | count(*) from t1))-17)) | +cast(avg((select cast(avg(a) AS integer) from t1)*f) AS integer)-cast(avg(13-t1.a+b) AS integer))+ -max(t1.a) from t1 union select cast(avg( -f) AS integer) from t1)))}
+} {}
+do_test randexpr-2.1207 {
+ db eval {SELECT ((abs(b)/abs(t1.e+coalesce((select max((abs(coalesce((select max(11) from t1 where t1.a<=coalesce((select case when t1.a in (case t1.b when t1.d then t1.d else a end,17,11) then 13 when t1.a>b then 19 else d end from t1 where c in (select (~case count(*) when min(f) then -min(d) else count(distinct (t1.f)) end)*(count(*)) from t1 union select -min((t1.c)) from t1)),11) and (b<=t1.c)),t1.f))/abs(e))-13) from t1 where b not in (d,( -e),e)),c)-t1.c))) FROM t1 WHERE NOT ((exists(select 1 from t1 where b in (select +( -abs(max(19+((select case -+cast(avg(e) AS integer) when -max(19)-min(t1.c) | count(*) then count(distinct t1.e) else min(f) end-cast(avg( -19) AS integer)*count(*) | count(*) from t1))-17)) | +cast(avg((select cast(avg(a) AS integer) from t1)*f) AS integer)-cast(avg(13-t1.a+b) AS integer))+ -max(t1.a) from t1 union select cast(avg( -f) AS integer) from t1))))}
+} {1}
+do_test randexpr-2.1208 {
+ db eval {SELECT t1.f-17+(abs(case when ~e*coalesce((select max(coalesce((select d from t1 where not -(19*t1.d*17) not in (t1.a*t1.c,b,b)),f)) from t1 where 13 between t1.d and 19),11* -t1.e)-(t1.a)>d then 17 when (e in (select -(t1.d) from t1 union select -(t1.b) from t1)) then e else -t1.d end)/abs(17))*a FROM t1 WHERE 17 in (select 19 from t1 union select -17 | d from t1)}
+} {}
+do_test randexpr-2.1209 {
+ db eval {SELECT t1.f-17+(abs(case when ~e*coalesce((select max(coalesce((select d from t1 where not -(19*t1.d*17) not in (t1.a*t1.c,b,b)),f)) from t1 where 13 between t1.d and 19),11* -t1.e)-(t1.a)>d then 17 when (e in (select -(t1.d) from t1 union select -(t1.b) from t1)) then e else -t1.d end)/abs(17))*a FROM t1 WHERE NOT (17 in (select 19 from t1 union select -17 | d from t1))}
+} {683}
+do_test randexpr-2.1210 {
+ db eval {SELECT case t1.a when case when 13+( -f-b)*c-t1.d-t1.c | c+d>=d*case when not ++c+t1.d<>+b- -a*t1.e then -f else 17 end+t1.f then t1.e when 11<>19 then c else 11 end then e else f end FROM t1 WHERE (case when (abs(t1.f+case f-case when exists(select 1 from t1 where t1.c>13) then t1.e when t1.f>= -f then b else e end when 13 then t1.e else t1.c end)/abs(c)) in (select max(f)*max(f)*( -max( -17)) | min(t1.a) | cast(avg(13) AS integer)+count(*) from t1 union select ( -max(e)) from t1) then ( -d) when c not between f and ( -c) then 13 else b end between t1.a and e) and 19 not between 19 and c}
+} {}
+do_test randexpr-2.1211 {
+ db eval {SELECT case t1.a when case when 13+( -f-b)*c-t1.d-t1.c | c+d>=d*case when not ++c+t1.d<>+b- -a*t1.e then -f else 17 end+t1.f then t1.e when 11<>19 then c else 11 end then e else f end FROM t1 WHERE NOT ((case when (abs(t1.f+case f-case when exists(select 1 from t1 where t1.c>13) then t1.e when t1.f>= -f then b else e end when 13 then t1.e else t1.c end)/abs(c)) in (select max(f)*max(f)*( -max( -17)) | min(t1.a) | cast(avg(13) AS integer)+count(*) from t1 union select ( -max(e)) from t1) then ( -d) when c not between f and ( -c) then 13 else b end between t1.a and e) and 19 not between 19 and c)}
+} {600}
+do_test randexpr-2.1212 {
+ db eval {SELECT case t1.a when case when 13+( -f-b)*c-t1.d-t1.c & c+d>=d*case when not ++c+t1.d<>+b- -a*t1.e then -f else 17 end+t1.f then t1.e when 11<>19 then c else 11 end then e else f end FROM t1 WHERE NOT ((case when (abs(t1.f+case f-case when exists(select 1 from t1 where t1.c>13) then t1.e when t1.f>= -f then b else e end when 13 then t1.e else t1.c end)/abs(c)) in (select max(f)*max(f)*( -max( -17)) | min(t1.a) | cast(avg(13) AS integer)+count(*) from t1 union select ( -max(e)) from t1) then ( -d) when c not between f and ( -c) then 13 else b end between t1.a and e) and 19 not between 19 and c)}
+} {600}
+do_test randexpr-2.1213 {
+ db eval {SELECT case when 19=t1.e or (abs(t1.f)/abs(((select -count(distinct f+~t1.e-t1.b-coalesce((select max(b*c) from t1 where 17<>b),b))+~cast(avg(d) AS integer) from t1)))) not between f and d then coalesce((select max( -a) from t1 where 13<=11 or t1.d>=f),t1.d) when 17 in (select 11 from t1 union select t1.a from t1) then t1.d else t1.c end | 19 FROM t1 WHERE (case t1.d when ~a then coalesce((select max((abs( -~+b)/abs(t1.c))) from t1 where case t1.e when (abs((abs(case t1.a++t1.d | 19-coalesce((select e from t1 where b not between t1.f+b+c and t1.b), -t1.f) when t1.e then t1.a else f end)/abs(t1.b)))/abs(t1.e)) then t1.d else t1.d end>t1.f),t1.d)*t1.b else t1.f end not between a and e)}
+} {403}
+do_test randexpr-2.1214 {
+ db eval {SELECT case when 19=t1.e or (abs(t1.f)/abs(((select -count(distinct f+~t1.e-t1.b-coalesce((select max(b*c) from t1 where 17<>b),b))+~cast(avg(d) AS integer) from t1)))) not between f and d then coalesce((select max( -a) from t1 where 13<=11 or t1.d>=f),t1.d) when 17 in (select 11 from t1 union select t1.a from t1) then t1.d else t1.c end | 19 FROM t1 WHERE NOT ((case t1.d when ~a then coalesce((select max((abs( -~+b)/abs(t1.c))) from t1 where case t1.e when (abs((abs(case t1.a++t1.d | 19-coalesce((select e from t1 where b not between t1.f+b+c and t1.b), -t1.f) when t1.e then t1.a else f end)/abs(t1.b)))/abs(t1.e)) then t1.d else t1.d end>t1.f),t1.d)*t1.b else t1.f end not between a and e))}
+} {}
+do_test randexpr-2.1215 {
+ db eval {SELECT case when 19=t1.e or (abs(t1.f)/abs(((select -count(distinct f+~t1.e-t1.b-coalesce((select max(b*c) from t1 where 17<>b),b))+~cast(avg(d) AS integer) from t1)))) not between f and d then coalesce((select max( -a) from t1 where 13<=11 or t1.d>=f),t1.d) when 17 in (select 11 from t1 union select t1.a from t1) then t1.d else t1.c end & 19 FROM t1 WHERE (case t1.d when ~a then coalesce((select max((abs( -~+b)/abs(t1.c))) from t1 where case t1.e when (abs((abs(case t1.a++t1.d | 19-coalesce((select e from t1 where b not between t1.f+b+c and t1.b), -t1.f) when t1.e then t1.a else f end)/abs(t1.b)))/abs(t1.e)) then t1.d else t1.d end>t1.f),t1.d)*t1.b else t1.f end not between a and e)}
+} {16}
+do_test randexpr-2.1216 {
+ db eval {SELECT coalesce((select t1.c from t1 where -a in (select e from t1 union select 13 from t1)),(select count(distinct coalesce((select max((17)) from t1 where c not between case 19-t1.b when a then ~+(abs((select count(distinct (t1.a)) from t1)+(t1.b))/abs((t1.a)*a+13 | t1.d | t1.a)) else a end and 13 or d in (a,a,t1.f)),d)) from t1) | t1.d) FROM t1 WHERE e<d or case case when -t1.a between coalesce((select coalesce((select d from t1 where (t1.f=~coalesce((select max(t1.d) from t1 where t1.d<=t1.e),f)*19)),17) from t1 where (t1.f in ( -11,t1.f,a)) or 19<=13),t1.b) and c then t1.f when t1.d=f then t1.f else f end when t1.d then 11 else 17 end*t1.e not in (t1.a,t1.f,e)}
+} {401}
+do_test randexpr-2.1217 {
+ db eval {SELECT coalesce((select t1.c from t1 where -a in (select e from t1 union select 13 from t1)),(select count(distinct coalesce((select max((17)) from t1 where c not between case 19-t1.b when a then ~+(abs((select count(distinct (t1.a)) from t1)+(t1.b))/abs((t1.a)*a+13 | t1.d | t1.a)) else a end and 13 or d in (a,a,t1.f)),d)) from t1) | t1.d) FROM t1 WHERE NOT (e<d or case case when -t1.a between coalesce((select coalesce((select d from t1 where (t1.f=~coalesce((select max(t1.d) from t1 where t1.d<=t1.e),f)*19)),17) from t1 where (t1.f in ( -11,t1.f,a)) or 19<=13),t1.b) and c then t1.f when t1.d=f then t1.f else f end when t1.d then 11 else 17 end*t1.e not in (t1.a,t1.f,e))}
+} {}
+do_test randexpr-2.1218 {
+ db eval {SELECT coalesce((select t1.c from t1 where -a in (select e from t1 union select 13 from t1)),(select count(distinct coalesce((select max((17)) from t1 where c not between case 19-t1.b when a then ~+(abs((select count(distinct (t1.a)) from t1)+(t1.b))/abs((t1.a)*a+13 & t1.d & t1.a)) else a end and 13 or d in (a,a,t1.f)),d)) from t1) & t1.d) FROM t1 WHERE e<d or case case when -t1.a between coalesce((select coalesce((select d from t1 where (t1.f=~coalesce((select max(t1.d) from t1 where t1.d<=t1.e),f)*19)),17) from t1 where (t1.f in ( -11,t1.f,a)) or 19<=13),t1.b) and c then t1.f when t1.d=f then t1.f else f end when t1.d then 11 else 17 end*t1.e not in (t1.a,t1.f,e)}
+} {0}
+do_test randexpr-2.1219 {
+ db eval {SELECT case when case when t1.b<=f+coalesce((select max(11) from t1 where not e in (select count(distinct f) from t1 union select count(*) from t1)),t1.d) or 19 between (e) and 19 and f not in (t1.d,(19),t1.e) and exists(select 1 from t1 where t1.e<=19) or t1.e>t1.a then (select +abs(count(distinct t1.f)*max(13)) from t1) else +d end>=b+t1.c and b not in (f,13,b) then t1.d when b>b then d else t1.d end*11 FROM t1 WHERE d<>b}
+} {4400}
+do_test randexpr-2.1220 {
+ db eval {SELECT case when case when t1.b<=f+coalesce((select max(11) from t1 where not e in (select count(distinct f) from t1 union select count(*) from t1)),t1.d) or 19 between (e) and 19 and f not in (t1.d,(19),t1.e) and exists(select 1 from t1 where t1.e<=19) or t1.e>t1.a then (select +abs(count(distinct t1.f)*max(13)) from t1) else +d end>=b+t1.c and b not in (f,13,b) then t1.d when b>b then d else t1.d end*11 FROM t1 WHERE NOT (d<>b)}
+} {}
+do_test randexpr-2.1221 {
+ db eval {SELECT ~(abs(case when t1.a not between -t1.d*(b) and 17 then f when e<=t1.f then b*t1.d else 13*(a) end)/abs((coalesce((select d from t1 where +(abs((select (min(a)) from t1))/abs((select count(distinct a) from t1)))- -t1.a in (select -case max(e)+count(distinct d) when cast(avg(( -t1.e)) AS integer) then ( -(count(*))) else -min(d) end+max(t1.f) from t1 union select max(t1.a) from t1)),t1.d)))) FROM t1 WHERE (t1.a<t1.a)}
+} {}
+do_test randexpr-2.1222 {
+ db eval {SELECT ~(abs(case when t1.a not between -t1.d*(b) and 17 then f when e<=t1.f then b*t1.d else 13*(a) end)/abs((coalesce((select d from t1 where +(abs((select (min(a)) from t1))/abs((select count(distinct a) from t1)))- -t1.a in (select -case max(e)+count(distinct d) when cast(avg(( -t1.e)) AS integer) then ( -(count(*))) else -min(d) end+max(t1.f) from t1 union select max(t1.a) from t1)),t1.d)))) FROM t1 WHERE NOT ((t1.a<t1.a))}
+} {-2}
+do_test randexpr-2.1223 {
+ db eval {SELECT f+case when (~t1.c between case when +d between (select -abs(count(distinct t1.a+17+t1.f))+case min(19)*count(distinct -t1.a) when (count(*)) then ((count(*))) else ((max(t1.e))) end from t1) and case when -t1.b>=13 then 11 else a end then -17 else a end and (t1.c) and (b=17)) then (+(t1.c)) when t1.a<=t1.f then t1.d else 11 end FROM t1 WHERE c<>~13}
+} {1000}
+do_test randexpr-2.1224 {
+ db eval {SELECT f+case when (~t1.c between case when +d between (select -abs(count(distinct t1.a+17+t1.f))+case min(19)*count(distinct -t1.a) when (count(*)) then ((count(*))) else ((max(t1.e))) end from t1) and case when -t1.b>=13 then 11 else a end then -17 else a end and (t1.c) and (b=17)) then (+(t1.c)) when t1.a<=t1.f then t1.d else 11 end FROM t1 WHERE NOT (c<>~13)}
+} {}
+do_test randexpr-2.1225 {
+ db eval {SELECT case when ~(abs((select count(*) from t1))/abs(c))<>case when 17*case when coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.f=t1.e)),t1.a) in (select min(t1.f) from t1 union select -min(t1.d) from t1) then 11 when 11<=(a) then f else -e end | -t1.b< -c then d else f end then ((t1.a)) when t1.f in (select ~(++(count(*))+cast(avg(t1.f) AS integer))+max(( -t1.d)) from t1 union select cast(avg(e) AS integer) from t1) then 11 else d end FROM t1 WHERE t1.a between case when t1.d=t1.a*11 | (select (cast(avg(t1.a) AS integer)+abs( -count(distinct e)) | ~count(distinct coalesce((select max(b) from t1 where not exists(select 1 from t1 where -e>=13)),(t1.e)))- -( -max(d))* -count(*)) from t1)+(abs(t1.f)/abs((select cast(avg(11) AS integer) from t1))) then t1.a else coalesce((select max(c) from t1 where 11>=t1.e or 11 in (t1.b,t1.b,t1.d) or t1.a>=t1.a),13)*a end and t1.c}
+} {}
+do_test randexpr-2.1226 {
+ db eval {SELECT case when ~(abs((select count(*) from t1))/abs(c))<>case when 17*case when coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.f=t1.e)),t1.a) in (select min(t1.f) from t1 union select -min(t1.d) from t1) then 11 when 11<=(a) then f else -e end | -t1.b< -c then d else f end then ((t1.a)) when t1.f in (select ~(++(count(*))+cast(avg(t1.f) AS integer))+max(( -t1.d)) from t1 union select cast(avg(e) AS integer) from t1) then 11 else d end FROM t1 WHERE NOT (t1.a between case when t1.d=t1.a*11 | (select (cast(avg(t1.a) AS integer)+abs( -count(distinct e)) | ~count(distinct coalesce((select max(b) from t1 where not exists(select 1 from t1 where -e>=13)),(t1.e)))- -( -max(d))* -count(*)) from t1)+(abs(t1.f)/abs((select cast(avg(11) AS integer) from t1))) then t1.a else coalesce((select max(c) from t1 where 11>=t1.e or 11 in (t1.b,t1.b,t1.d) or t1.a>=t1.a),13)*a end and t1.c)}
+} {100}
+do_test randexpr-2.1227 {
+ db eval {SELECT case when ~(abs((select count(*) from t1))/abs(c))<>case when 17*case when coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.f=t1.e)),t1.a) in (select min(t1.f) from t1 union select -min(t1.d) from t1) then 11 when 11<=(a) then f else -e end & -t1.b< -c then d else f end then ((t1.a)) when t1.f in (select ~(++(count(*))+cast(avg(t1.f) AS integer))+max(( -t1.d)) from t1 union select cast(avg(e) AS integer) from t1) then 11 else d end FROM t1 WHERE NOT (t1.a between case when t1.d=t1.a*11 | (select (cast(avg(t1.a) AS integer)+abs( -count(distinct e)) | ~count(distinct coalesce((select max(b) from t1 where not exists(select 1 from t1 where -e>=13)),(t1.e)))- -( -max(d))* -count(*)) from t1)+(abs(t1.f)/abs((select cast(avg(11) AS integer) from t1))) then t1.a else coalesce((select max(c) from t1 where 11>=t1.e or 11 in (t1.b,t1.b,t1.d) or t1.a>=t1.a),13)*a end and t1.c)}
+} {100}
+do_test randexpr-2.1228 {
+ db eval {SELECT (coalesce((select 19 from t1 where - -t1.d | t1.c+~(select max(11) | -~count(*)+count(*)-cast(avg(case when t1.e in (select a from t1 union select f from t1) then c else 11 end) AS integer) from t1)*coalesce((select t1.b from t1 where ((abs(t1.b)/abs(coalesce((select (b)-f from t1 where t1.f not in ( -e, -t1.b, -t1.d) and t1.d>=a or 19 not in (a,13,t1.f)),b))))<t1.e),f)+b<t1.c),d)) FROM t1 WHERE t1.f | +19+f*t1.d+t1.b*d<case when (select min(t1.e) from t1) not in (t1.b,11, -b*case c when coalesce((select max(t1.b+b) from t1 where 19+13=t1.f),coalesce((select max(19*f) from t1 where t1.a=a),a)) then d else t1.f end) then t1.f when f=t1.c then a else 19 end}
+} {}
+do_test randexpr-2.1229 {
+ db eval {SELECT (coalesce((select 19 from t1 where - -t1.d | t1.c+~(select max(11) | -~count(*)+count(*)-cast(avg(case when t1.e in (select a from t1 union select f from t1) then c else 11 end) AS integer) from t1)*coalesce((select t1.b from t1 where ((abs(t1.b)/abs(coalesce((select (b)-f from t1 where t1.f not in ( -e, -t1.b, -t1.d) and t1.d>=a or 19 not in (a,13,t1.f)),b))))<t1.e),f)+b<t1.c),d)) FROM t1 WHERE NOT (t1.f | +19+f*t1.d+t1.b*d<case when (select min(t1.e) from t1) not in (t1.b,11, -b*case c when coalesce((select max(t1.b+b) from t1 where 19+13=t1.f),coalesce((select max(19*f) from t1 where t1.a=a),a)) then d else t1.f end) then t1.f when f=t1.c then a else 19 end)}
+} {400}
+do_test randexpr-2.1230 {
+ db eval {SELECT (coalesce((select 19 from t1 where - -t1.d & t1.c+~(select max(11) & -~count(*)+count(*)-cast(avg(case when t1.e in (select a from t1 union select f from t1) then c else 11 end) AS integer) from t1)*coalesce((select t1.b from t1 where ((abs(t1.b)/abs(coalesce((select (b)-f from t1 where t1.f not in ( -e, -t1.b, -t1.d) and t1.d>=a or 19 not in (a,13,t1.f)),b))))<t1.e),f)+b<t1.c),d)) FROM t1 WHERE NOT (t1.f | +19+f*t1.d+t1.b*d<case when (select min(t1.e) from t1) not in (t1.b,11, -b*case c when coalesce((select max(t1.b+b) from t1 where 19+13=t1.f),coalesce((select max(19*f) from t1 where t1.a=a),a)) then d else t1.f end) then t1.f when f=t1.c then a else 19 end)}
+} {19}
+do_test randexpr-2.1231 {
+ db eval {SELECT +case when t1.f<c then 19 when f<=case t1.c when c*d then case when (t1.d=17) and not (d-case when 11<19 then t1.b when t1.d in (t1.e, - -e,c) then a else t1.d end+b in (t1.a,19,11)) then case 19 when c then t1.d else t1.d end when d in (select a from t1 union select 11 from t1) then (t1.e) else 11 end else 19 end then c else 19 end FROM t1 WHERE exists(select 1 from t1 where 19 in (select ++min(t1.f)+case abs((count(distinct 11-t1.a-t1.f)-case ((min(13))) when count(distinct t1.f) then - -cast(avg(t1.d) AS integer) else cast(avg(t1.d) AS integer) end | count(*)*max(b)- -min(b)))- -min((b)) | min(b) | count(*)*count(*) when count(*) then max(19) else max(19) end | cast(avg(t1.b) AS integer)+min(t1.d)* -max(t1.c) | ( -( -min(t1.e)))*min(d)- -min(d) from t1 union select ((min(b))) from t1))}
+} {}
+do_test randexpr-2.1232 {
+ db eval {SELECT +case when t1.f<c then 19 when f<=case t1.c when c*d then case when (t1.d=17) and not (d-case when 11<19 then t1.b when t1.d in (t1.e, - -e,c) then a else t1.d end+b in (t1.a,19,11)) then case 19 when c then t1.d else t1.d end when d in (select a from t1 union select 11 from t1) then (t1.e) else 11 end else 19 end then c else 19 end FROM t1 WHERE NOT (exists(select 1 from t1 where 19 in (select ++min(t1.f)+case abs((count(distinct 11-t1.a-t1.f)-case ((min(13))) when count(distinct t1.f) then - -cast(avg(t1.d) AS integer) else cast(avg(t1.d) AS integer) end | count(*)*max(b)- -min(b)))- -min((b)) | min(b) | count(*)*count(*) when count(*) then max(19) else max(19) end | cast(avg(t1.b) AS integer)+min(t1.d)* -max(t1.c) | ( -( -min(t1.e)))*min(d)- -min(d) from t1 union select ((min(b))) from t1)))}
+} {19}
+do_test randexpr-2.1233 {
+ db eval {SELECT ~case when exists(select 1 from t1 where t1.c in (t1.a,e+t1.b+e-19 | coalesce((select max(t1.f | t1.a+11*a) from t1 where (abs((abs(f)/abs(d)))/abs(coalesce((select max(t1.a) from t1 where (13 between (f) and f and t1.e between e and t1.b)),t1.c)))<=(f)),e)+f+13, -t1.c)) then t1.b when t1.d<>t1.d then (17) else e end+t1.d-19 FROM t1 WHERE not -t1.e+t1.c not between case when -case case when exists(select 1 from t1 where 17 in (select min(19) from t1 union select -min(19) from t1) and 13 not in (17,a,t1.e)) then case when f>=19 then (c) when t1.f>13 then 19 else 19 end | t1.a else e end when b then t1.c else b end in (select -max(13) from t1 union select count(distinct 17) from t1) and 11 not in (11,t1.a,f) and t1.c=f then ~(abs(t1.e)/abs(t1.d)) when f<13 then 17 else 19 end*b and t1.e}
+} {}
+do_test randexpr-2.1234 {
+ db eval {SELECT ~case when exists(select 1 from t1 where t1.c in (t1.a,e+t1.b+e-19 | coalesce((select max(t1.f | t1.a+11*a) from t1 where (abs((abs(f)/abs(d)))/abs(coalesce((select max(t1.a) from t1 where (13 between (f) and f and t1.e between e and t1.b)),t1.c)))<=(f)),e)+f+13, -t1.c)) then t1.b when t1.d<>t1.d then (17) else e end+t1.d-19 FROM t1 WHERE NOT (not -t1.e+t1.c not between case when -case case when exists(select 1 from t1 where 17 in (select min(19) from t1 union select -min(19) from t1) and 13 not in (17,a,t1.e)) then case when f>=19 then (c) when t1.f>13 then 19 else 19 end | t1.a else e end when b then t1.c else b end in (select -max(13) from t1 union select count(distinct 17) from t1) and 11 not in (11,t1.a,f) and t1.c=f then ~(abs(t1.e)/abs(t1.d)) when f<13 then 17 else 19 end*b and t1.e)}
+} {-120}
+do_test randexpr-2.1235 {
+ db eval {SELECT ~case when exists(select 1 from t1 where t1.c in (t1.a,e+t1.b+e-19 & coalesce((select max(t1.f & t1.a+11*a) from t1 where (abs((abs(f)/abs(d)))/abs(coalesce((select max(t1.a) from t1 where (13 between (f) and f and t1.e between e and t1.b)),t1.c)))<=(f)),e)+f+13, -t1.c)) then t1.b when t1.d<>t1.d then (17) else e end+t1.d-19 FROM t1 WHERE NOT (not -t1.e+t1.c not between case when -case case when exists(select 1 from t1 where 17 in (select min(19) from t1 union select -min(19) from t1) and 13 not in (17,a,t1.e)) then case when f>=19 then (c) when t1.f>13 then 19 else 19 end | t1.a else e end when b then t1.c else b end in (select -max(13) from t1 union select count(distinct 17) from t1) and 11 not in (11,t1.a,f) and t1.c=f then ~(abs(t1.e)/abs(t1.d)) when f<13 then 17 else 19 end*b and t1.e)}
+} {-120}
+do_test randexpr-2.1236 {
+ db eval {SELECT ((select min(e+case when b not between coalesce((select t1.d | b from t1 where not exists(select 1 from t1 where 17>11)), -c) and (t1.a) or e<t1.b and (11)<>d then a when 19>11 then -13 else t1.b end+13)+count(distinct d)+count(*)* -count(distinct t1.f)-((count(distinct t1.c)))+min(a) | max(c) from t1)*t1.e*19*11) FROM t1 WHERE b<>(select count(distinct f) from t1)}
+} {104918000}
+do_test randexpr-2.1237 {
+ db eval {SELECT ((select min(e+case when b not between coalesce((select t1.d | b from t1 where not exists(select 1 from t1 where 17>11)), -c) and (t1.a) or e<t1.b and (11)<>d then a when 19>11 then -13 else t1.b end+13)+count(distinct d)+count(*)* -count(distinct t1.f)-((count(distinct t1.c)))+min(a) | max(c) from t1)*t1.e*19*11) FROM t1 WHERE NOT (b<>(select count(distinct f) from t1))}
+} {}
+do_test randexpr-2.1238 {
+ db eval {SELECT ((select min(e+case when b not between coalesce((select t1.d & b from t1 where not exists(select 1 from t1 where 17>11)), -c) and (t1.a) or e<t1.b and (11)<>d then a when 19>11 then -13 else t1.b end+13)+count(distinct d)+count(*)* -count(distinct t1.f)-((count(distinct t1.c)))+min(a) & max(c) from t1)*t1.e*19*11) FROM t1 WHERE b<>(select count(distinct f) from t1)}
+} {836000}
+do_test randexpr-2.1239 {
+ db eval {SELECT coalesce((select max(t1.a) from t1 where +b-b+t1.e<>(case when (case when ((select case -cast(avg(17) AS integer) when max(17) then count(*) else count(distinct t1.d) end from t1))-case 19 when 11 then e else t1.f end<=e then 19 when b not between t1.c and 13 then e else 17 end+t1.c in (select 19 from t1 union select a from t1)) then e-t1.c else t1.f end*t1.b)-e),a) FROM t1 WHERE coalesce((select 13 from t1 where t1.c<>t1.b | t1.e*19-e),f+t1.d) not in (13,(c)*a,e)}
+} {}
+do_test randexpr-2.1240 {
+ db eval {SELECT coalesce((select max(t1.a) from t1 where +b-b+t1.e<>(case when (case when ((select case -cast(avg(17) AS integer) when max(17) then count(*) else count(distinct t1.d) end from t1))-case 19 when 11 then e else t1.f end<=e then 19 when b not between t1.c and 13 then e else 17 end+t1.c in (select 19 from t1 union select a from t1)) then e-t1.c else t1.f end*t1.b)-e),a) FROM t1 WHERE NOT (coalesce((select 13 from t1 where t1.c<>t1.b | t1.e*19-e),f+t1.d) not in (13,(c)*a,e))}
+} {100}
+do_test randexpr-2.1241 {
+ db eval {SELECT t1.d-case when (11) not between coalesce((select max(a) from t1 where f in (select cast(avg(t1.c+(select case case case max(a) when -count(*) then min(b) else - -(min((t1.a))) end when (max((19))) then max(t1.f) else count(*) end when max(t1.a) then -min(t1.c) else count(*) end from t1)+c+t1.d) AS integer)-min(a) | -cast(avg(f) AS integer)*(cast(avg(f) AS integer))-( -count(*)) from t1 union select min( -c) from t1)),t1.a) and -c then (d) when t1.f<=((t1.c)) then - -13 else c end FROM t1 WHERE 13-e>(abs(t1.f)/abs((t1.d)*d))}
+} {}
+do_test randexpr-2.1242 {
+ db eval {SELECT t1.d-case when (11) not between coalesce((select max(a) from t1 where f in (select cast(avg(t1.c+(select case case case max(a) when -count(*) then min(b) else - -(min((t1.a))) end when (max((19))) then max(t1.f) else count(*) end when max(t1.a) then -min(t1.c) else count(*) end from t1)+c+t1.d) AS integer)-min(a) | -cast(avg(f) AS integer)*(cast(avg(f) AS integer))-( -count(*)) from t1 union select min( -c) from t1)),t1.a) and -c then (d) when t1.f<=((t1.c)) then - -13 else c end FROM t1 WHERE NOT (13-e>(abs(t1.f)/abs((t1.d)*d)))}
+} {0}
+do_test randexpr-2.1243 {
+ db eval {SELECT t1.d-case when (11) not between coalesce((select max(a) from t1 where f in (select cast(avg(t1.c+(select case case case max(a) when -count(*) then min(b) else - -(min((t1.a))) end when (max((19))) then max(t1.f) else count(*) end when max(t1.a) then -min(t1.c) else count(*) end from t1)+c+t1.d) AS integer)-min(a) & -cast(avg(f) AS integer)*(cast(avg(f) AS integer))-( -count(*)) from t1 union select min( -c) from t1)),t1.a) and -c then (d) when t1.f<=((t1.c)) then - -13 else c end FROM t1 WHERE NOT (13-e>(abs(t1.f)/abs((t1.d)*d)))}
+} {0}
+do_test randexpr-2.1244 {
+ db eval {SELECT (abs(coalesce((select max(b) from t1 where not exists(select 1 from t1 where 19>(t1.c))),(11+(abs(c)/abs(19)))+b)+coalesce((select max(t1.c) from t1 where t1.a<=13),t1.d+t1.b+case when exists(select 1 from t1 where -t1.b in (select min(t1.a-+13) from t1 union select max(t1.c) from t1)) then (select ++(cast(avg(11) AS integer)) | cast(avg(b) AS integer)*cast(avg(d) AS integer) from t1) when f>=b then 19 else 19 end))/abs(b)) FROM t1 WHERE not b in (select case when t1.e in (select +cast(avg(d) AS integer)-count(*)*count(*)-(case ~count(distinct d)*cast(avg(t1.b) AS integer) when count(distinct t1.e) then max(19) else cast(avg(t1.b) AS integer) end+(count(distinct t1.c))) from t1 union select -min(t1.f) from t1) or 19<=+11 then ((select (min(t1.b)) from t1)*a-19+17*13) | a when (11 in (select d from t1 union select t1.e from t1)) then 19 else t1.b end from t1 union select t1.c from t1)}
+} {}
+do_test randexpr-2.1245 {
+ db eval {SELECT (abs(coalesce((select max(b) from t1 where not exists(select 1 from t1 where 19>(t1.c))),(11+(abs(c)/abs(19)))+b)+coalesce((select max(t1.c) from t1 where t1.a<=13),t1.d+t1.b+case when exists(select 1 from t1 where -t1.b in (select min(t1.a-+13) from t1 union select max(t1.c) from t1)) then (select ++(cast(avg(11) AS integer)) | cast(avg(b) AS integer)*cast(avg(d) AS integer) from t1) when f>=b then 19 else 19 end))/abs(b)) FROM t1 WHERE NOT (not b in (select case when t1.e in (select +cast(avg(d) AS integer)-count(*)*count(*)-(case ~count(distinct d)*cast(avg(t1.b) AS integer) when count(distinct t1.e) then max(19) else cast(avg(t1.b) AS integer) end+(count(distinct t1.c))) from t1 union select -min(t1.f) from t1) or 19<=+11 then ((select (min(t1.b)) from t1)*a-19+17*13) | a when (11 in (select d from t1 union select t1.e from t1)) then 19 else t1.b end from t1 union select t1.c from t1))}
+} {4}
+do_test randexpr-2.1246 {
+ db eval {SELECT (abs(coalesce((select max(b) from t1 where not exists(select 1 from t1 where 19>(t1.c))),(11+(abs(c)/abs(19)))+b)+coalesce((select max(t1.c) from t1 where t1.a<=13),t1.d+t1.b+case when exists(select 1 from t1 where -t1.b in (select min(t1.a-+13) from t1 union select max(t1.c) from t1)) then (select ++(cast(avg(11) AS integer)) & cast(avg(b) AS integer)*cast(avg(d) AS integer) from t1) when f>=b then 19 else 19 end))/abs(b)) FROM t1 WHERE NOT (not b in (select case when t1.e in (select +cast(avg(d) AS integer)-count(*)*count(*)-(case ~count(distinct d)*cast(avg(t1.b) AS integer) when count(distinct t1.e) then max(19) else cast(avg(t1.b) AS integer) end+(count(distinct t1.c))) from t1 union select -min(t1.f) from t1) or 19<=+11 then ((select (min(t1.b)) from t1)*a-19+17*13) | a when (11 in (select d from t1 union select t1.e from t1)) then 19 else t1.b end from t1 union select t1.c from t1))}
+} {4}
+do_test randexpr-2.1247 {
+ db eval {SELECT +case ~t1.d when case when b*f in (select b from t1 union select 17 from t1) and ((case when t1.f | e in (select ~abs(~(case cast(avg(t1.f) AS integer) when min(b) then min(t1.d) else - -count(distinct e) end | count(*)*( -cast(avg(t1.b) AS integer)))) from t1 union select (count(distinct t1.b)) from t1) then t1.f else t1.f*17+a end-13+e<>t1.c)) then d else t1.c end then t1.f else t1.e end+19 FROM t1 WHERE b>=+t1.e or f<=t1.b and -c*17-t1.d*19 not in (c+coalesce((select (abs(~+d*t1.f)/abs(11)) from t1 where +case when t1.d+ -t1.e in (select max(t1.d)*count(distinct b) from t1 union select count(distinct 11) from t1) then (17) when (t1.e>t1.a) then e else e end not in (e,f,t1.a)),t1.f),t1.a,b)}
+} {}
+do_test randexpr-2.1248 {
+ db eval {SELECT +case ~t1.d when case when b*f in (select b from t1 union select 17 from t1) and ((case when t1.f | e in (select ~abs(~(case cast(avg(t1.f) AS integer) when min(b) then min(t1.d) else - -count(distinct e) end | count(*)*( -cast(avg(t1.b) AS integer)))) from t1 union select (count(distinct t1.b)) from t1) then t1.f else t1.f*17+a end-13+e<>t1.c)) then d else t1.c end then t1.f else t1.e end+19 FROM t1 WHERE NOT (b>=+t1.e or f<=t1.b and -c*17-t1.d*19 not in (c+coalesce((select (abs(~+d*t1.f)/abs(11)) from t1 where +case when t1.d+ -t1.e in (select max(t1.d)*count(distinct b) from t1 union select count(distinct 11) from t1) then (17) when (t1.e>t1.a) then e else e end not in (e,f,t1.a)),t1.f),t1.a,b))}
+} {519}
+do_test randexpr-2.1249 {
+ db eval {SELECT +case ~t1.d when case when b*f in (select b from t1 union select 17 from t1) and ((case when t1.f & e in (select ~abs(~(case cast(avg(t1.f) AS integer) when min(b) then min(t1.d) else - -count(distinct e) end & count(*)*( -cast(avg(t1.b) AS integer)))) from t1 union select (count(distinct t1.b)) from t1) then t1.f else t1.f*17+a end-13+e<>t1.c)) then d else t1.c end then t1.f else t1.e end+19 FROM t1 WHERE NOT (b>=+t1.e or f<=t1.b and -c*17-t1.d*19 not in (c+coalesce((select (abs(~+d*t1.f)/abs(11)) from t1 where +case when t1.d+ -t1.e in (select max(t1.d)*count(distinct b) from t1 union select count(distinct 11) from t1) then (17) when (t1.e>t1.a) then e else e end not in (e,f,t1.a)),t1.f),t1.a,b))}
+} {519}
+do_test randexpr-2.1250 {
+ db eval {SELECT (abs((abs(t1.a)/abs(~17 | coalesce((select ~coalesce((select (d) from t1 where t1.b>=t1.a),case when t1.e-(select ~max( -19*c | e+t1.c) from t1) not between (abs(c)/abs(e)) and t1.e then a else 17 end*17)+13 from t1 where a in (select max(t1.f) from t1 union select ~count(distinct b) from t1)),b) | 13)))/abs(e)) FROM t1 WHERE exists(select 1 from t1 where t1.a+t1.d-11<=t1.e)}
+} {0}
+do_test randexpr-2.1251 {
+ db eval {SELECT (abs((abs(t1.a)/abs(~17 | coalesce((select ~coalesce((select (d) from t1 where t1.b>=t1.a),case when t1.e-(select ~max( -19*c | e+t1.c) from t1) not between (abs(c)/abs(e)) and t1.e then a else 17 end*17)+13 from t1 where a in (select max(t1.f) from t1 union select ~count(distinct b) from t1)),b) | 13)))/abs(e)) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.a+t1.d-11<=t1.e))}
+} {}
+do_test randexpr-2.1252 {
+ db eval {SELECT (abs((abs(t1.a)/abs(~17 & coalesce((select ~coalesce((select (d) from t1 where t1.b>=t1.a),case when t1.e-(select ~max( -19*c & e+t1.c) from t1) not between (abs(c)/abs(e)) and t1.e then a else 17 end*17)+13 from t1 where a in (select max(t1.f) from t1 union select ~count(distinct b) from t1)),b) & 13)))/abs(e)) FROM t1 WHERE exists(select 1 from t1 where t1.a+t1.d-11<=t1.e)}
+} {0}
+do_test randexpr-2.1253 {
+ db eval {SELECT coalesce((select max(d) from t1 where not exists(select 1 from t1 where t1.e not in (13,e,coalesce((select f from t1 where (abs(case -t1.e when ~f then (t1.c)*13-t1.b+a-d+ -t1.a else a end)/abs(11))*19*t1.d>=a),(t1.b)))) or d not in (f,e,19)),coalesce((select max(17) from t1 where e in (select t1.e from t1 union select 17 from t1)),t1.c)) | t1.f FROM t1 WHERE t1.e not in (13,(select +count(*)+abs(cast(avg(case t1.d when 17 then -t1.e+13 else (abs( -c)/abs(case when t1.e*+coalesce((select max(13) from t1 where a>t1.b),t1.f)>=(13) then -f else t1.a end)) end) AS integer)) from t1)*(13),(select ((max(t1.d))) from t1)) and not exists(select 1 from t1 where e+b not in (b,t1.c,t1.e))}
+} {}
+do_test randexpr-2.1254 {
+ db eval {SELECT coalesce((select max(d) from t1 where not exists(select 1 from t1 where t1.e not in (13,e,coalesce((select f from t1 where (abs(case -t1.e when ~f then (t1.c)*13-t1.b+a-d+ -t1.a else a end)/abs(11))*19*t1.d>=a),(t1.b)))) or d not in (f,e,19)),coalesce((select max(17) from t1 where e in (select t1.e from t1 union select 17 from t1)),t1.c)) | t1.f FROM t1 WHERE NOT (t1.e not in (13,(select +count(*)+abs(cast(avg(case t1.d when 17 then -t1.e+13 else (abs( -c)/abs(case when t1.e*+coalesce((select max(13) from t1 where a>t1.b),t1.f)>=(13) then -f else t1.a end)) end) AS integer)) from t1)*(13),(select ((max(t1.d))) from t1)) and not exists(select 1 from t1 where e+b not in (b,t1.c,t1.e)))}
+} {984}
+do_test randexpr-2.1255 {
+ db eval {SELECT coalesce((select max(d) from t1 where not exists(select 1 from t1 where t1.e not in (13,e,coalesce((select f from t1 where (abs(case -t1.e when ~f then (t1.c)*13-t1.b+a-d+ -t1.a else a end)/abs(11))*19*t1.d>=a),(t1.b)))) or d not in (f,e,19)),coalesce((select max(17) from t1 where e in (select t1.e from t1 union select 17 from t1)),t1.c)) & t1.f FROM t1 WHERE NOT (t1.e not in (13,(select +count(*)+abs(cast(avg(case t1.d when 17 then -t1.e+13 else (abs( -c)/abs(case when t1.e*+coalesce((select max(13) from t1 where a>t1.b),t1.f)>=(13) then -f else t1.a end)) end) AS integer)) from t1)*(13),(select ((max(t1.d))) from t1)) and not exists(select 1 from t1 where e+b not in (b,t1.c,t1.e)))}
+} {16}
+do_test randexpr-2.1256 {
+ db eval {SELECT (abs(case when (t1.d*coalesce((select max(case coalesce((select max(e) from t1 where t1.a not in (coalesce((select (select count(distinct t1.e) from t1) from t1 where c>=t1.c),f),19,a)),t1.a) when t1.c then t1.a else b end-a) from t1 where c>t1.d),b)<= -11) then t1.a when not exists(select 1 from t1 where not (t1.d=e) or t1.f between t1.a and -e and (t1.c)=f and a not in (t1.c,a,c)) then t1.a else t1.a end)/abs( -13))+e-d FROM t1 WHERE 17 not in (13,19,t1.c)}
+} {107}
+do_test randexpr-2.1257 {
+ db eval {SELECT (abs(case when (t1.d*coalesce((select max(case coalesce((select max(e) from t1 where t1.a not in (coalesce((select (select count(distinct t1.e) from t1) from t1 where c>=t1.c),f),19,a)),t1.a) when t1.c then t1.a else b end-a) from t1 where c>t1.d),b)<= -11) then t1.a when not exists(select 1 from t1 where not (t1.d=e) or t1.f between t1.a and -e and (t1.c)=f and a not in (t1.c,a,c)) then t1.a else t1.a end)/abs( -13))+e-d FROM t1 WHERE NOT (17 not in (13,19,t1.c))}
+} {}
+do_test randexpr-2.1258 {
+ db eval {SELECT ~ -coalesce((select c from t1 where (case when b<= -e*t1.f then +coalesce((select case when (select count(*) from t1)=e then t1.f | c else f end from t1 where e>=(select ~case count(*) when -abs(max(11)-count(distinct -t1.d)) then count(distinct e) else max(f) end*count(*) from t1)),13) else 19 end>=t1.e)),case when t1.c<t1.a then t1.f else a end | -a*d)-13-17 FROM t1 WHERE (abs(coalesce((select -coalesce((select max((select +count(distinct a | t1.d)- -(((count(distinct d))))-max(t1.c) from t1)) from t1 where (( -case t1.b when 17 then 17 else 13 end<c))),t1.b) from t1 where d not in (t1.c,19,17) or t1.a in (select (max(b)) from t1 union select (cast(avg(b) AS integer)) from t1)),(t1.b))*19)/abs(e))<a or (not exists(select 1 from t1 where t1.f not in (a, -17,e))) and (t1.a) in (select cast(avg(e) AS integer) from t1 union select max(19) from t1)}
+} {-39995}
+do_test randexpr-2.1259 {
+ db eval {SELECT ~ -coalesce((select c from t1 where (case when b<= -e*t1.f then +coalesce((select case when (select count(*) from t1)=e then t1.f | c else f end from t1 where e>=(select ~case count(*) when -abs(max(11)-count(distinct -t1.d)) then count(distinct e) else max(f) end*count(*) from t1)),13) else 19 end>=t1.e)),case when t1.c<t1.a then t1.f else a end | -a*d)-13-17 FROM t1 WHERE NOT ((abs(coalesce((select -coalesce((select max((select +count(distinct a | t1.d)- -(((count(distinct d))))-max(t1.c) from t1)) from t1 where (( -case t1.b when 17 then 17 else 13 end<c))),t1.b) from t1 where d not in (t1.c,19,17) or t1.a in (select (max(b)) from t1 union select (cast(avg(b) AS integer)) from t1)),(t1.b))*19)/abs(e))<a or (not exists(select 1 from t1 where t1.f not in (a, -17,e))) and (t1.a) in (select cast(avg(e) AS integer) from t1 union select max(19) from t1))}
+} {}
+do_test randexpr-2.1260 {
+ db eval {SELECT ~ -coalesce((select c from t1 where (case when b<= -e*t1.f then +coalesce((select case when (select count(*) from t1)=e then t1.f & c else f end from t1 where e>=(select ~case count(*) when -abs(max(11)-count(distinct -t1.d)) then count(distinct e) else max(f) end*count(*) from t1)),13) else 19 end>=t1.e)),case when t1.c<t1.a then t1.f else a end & -a*d)-13-17 FROM t1 WHERE (abs(coalesce((select -coalesce((select max((select +count(distinct a | t1.d)- -(((count(distinct d))))-max(t1.c) from t1)) from t1 where (( -case t1.b when 17 then 17 else 13 end<c))),t1.b) from t1 where d not in (t1.c,19,17) or t1.a in (select (max(b)) from t1 union select (cast(avg(b) AS integer)) from t1)),(t1.b))*19)/abs(e))<a or (not exists(select 1 from t1 where t1.f not in (a, -17,e))) and (t1.a) in (select cast(avg(e) AS integer) from t1 union select max(19) from t1)}
+} {33}
+do_test randexpr-2.1261 {
+ db eval {SELECT case t1.b when coalesce((select t1.b from t1 where not exists(select 1 from t1 where +case ( -case f when 13 then (abs(t1.b+f)/abs(c)) else t1.d end) when f*t1.f+t1.d then e else coalesce((select coalesce((select max(b) from t1 where t1.a<=t1.a or t1.d+f<=19 or t1.b in (select (11) from t1 union select (19) from t1)),t1.d) from t1 where not exists(select 1 from t1 where 17=b)),c)+e end between t1.c and b)),d) then c else t1.d end FROM t1 WHERE b>t1.e | case when exists(select 1 from t1 where not ~+11<=coalesce((select max(a) from t1 where ~17*case when a=+(select cast(avg(t1.a*e) AS integer) from t1) then t1.e when c<11 then b else f end+c not between t1.e and -17), -t1.c)) then e+c when not exists(select 1 from t1 where t1.c not between 13 and -f) then 17 else -t1.d end or (f)<=c}
+} {300}
+do_test randexpr-2.1262 {
+ db eval {SELECT case t1.b when coalesce((select t1.b from t1 where not exists(select 1 from t1 where +case ( -case f when 13 then (abs(t1.b+f)/abs(c)) else t1.d end) when f*t1.f+t1.d then e else coalesce((select coalesce((select max(b) from t1 where t1.a<=t1.a or t1.d+f<=19 or t1.b in (select (11) from t1 union select (19) from t1)),t1.d) from t1 where not exists(select 1 from t1 where 17=b)),c)+e end between t1.c and b)),d) then c else t1.d end FROM t1 WHERE NOT (b>t1.e | case when exists(select 1 from t1 where not ~+11<=coalesce((select max(a) from t1 where ~17*case when a=+(select cast(avg(t1.a*e) AS integer) from t1) then t1.e when c<11 then b else f end+c not between t1.e and -17), -t1.c)) then e+c when not exists(select 1 from t1 where t1.c not between 13 and -f) then 17 else -t1.d end or (f)<=c)}
+} {}
+do_test randexpr-2.1263 {
+ db eval {SELECT case when case when case when exists(select 1 from t1 where exists(select 1 from t1 where t1.a+t1.a | case when t1.b between f and 19 and t1.c<a then t1.e else t1.d end<e)) then a else coalesce((select 11 from t1 where c in (select -(abs(count(*)) | cast(avg(t1.b) AS integer))+( -min(17))+ -(count(distinct t1.e)) from t1 union select max((t1.a)) from t1)),a) end-t1.d=13 then t1.a else e end*t1.e*t1.c>=t1.e then t1.e else 19 end | a FROM t1 WHERE t1.b not in ((a),t1.d,b)}
+} {}
+do_test randexpr-2.1264 {
+ db eval {SELECT case when case when case when exists(select 1 from t1 where exists(select 1 from t1 where t1.a+t1.a | case when t1.b between f and 19 and t1.c<a then t1.e else t1.d end<e)) then a else coalesce((select 11 from t1 where c in (select -(abs(count(*)) | cast(avg(t1.b) AS integer))+( -min(17))+ -(count(distinct t1.e)) from t1 union select max((t1.a)) from t1)),a) end-t1.d=13 then t1.a else e end*t1.e*t1.c>=t1.e then t1.e else 19 end | a FROM t1 WHERE NOT (t1.b not in ((a),t1.d,b))}
+} {500}
+do_test randexpr-2.1265 {
+ db eval {SELECT case when case when case when exists(select 1 from t1 where exists(select 1 from t1 where t1.a+t1.a & case when t1.b between f and 19 and t1.c<a then t1.e else t1.d end<e)) then a else coalesce((select 11 from t1 where c in (select -(abs(count(*)) & cast(avg(t1.b) AS integer))+( -min(17))+ -(count(distinct t1.e)) from t1 union select max((t1.a)) from t1)),a) end-t1.d=13 then t1.a else e end*t1.e*t1.c>=t1.e then t1.e else 19 end & a FROM t1 WHERE NOT (t1.b not in ((a),t1.d,b))}
+} {100}
+do_test randexpr-2.1266 {
+ db eval {SELECT case when exists(select 1 from t1 where a between 13+t1.e and t1.e and (abs((abs(case when not 19 between t1.e and b and not exists(select 1 from t1 where (abs(17)/abs(f-c)) not between (d) and t1.e) then t1.e else 19 end)/abs(11)))/abs(19))=f) or t1.e<= -a then t1.b when exists(select 1 from t1 where t1.d>t1.c) and t1.b<19 then a else 11 end*d FROM t1 WHERE exists(select 1 from t1 where t1.e<>(select count(distinct ((coalesce((select coalesce((select max( -coalesce((select max( -e) from t1 where ((abs(t1.a)/abs(d)) in (select ~~count(*) from t1 union select count(*) from t1) or a in (d,t1.f,d) and -c in (b,e,t1.d))),t1.c)-19 | 11-t1.e) from t1 where exists(select 1 from t1 where a<=e) and f not in (17,t1.b,t1.c) or (t1.a)>=t1.d),e)-t1.c from t1 where b<t1.d or d<= -t1.c),t1.e)))) from t1))}
+} {4400}
+do_test randexpr-2.1267 {
+ db eval {SELECT case when exists(select 1 from t1 where a between 13+t1.e and t1.e and (abs((abs(case when not 19 between t1.e and b and not exists(select 1 from t1 where (abs(17)/abs(f-c)) not between (d) and t1.e) then t1.e else 19 end)/abs(11)))/abs(19))=f) or t1.e<= -a then t1.b when exists(select 1 from t1 where t1.d>t1.c) and t1.b<19 then a else 11 end*d FROM t1 WHERE NOT (exists(select 1 from t1 where t1.e<>(select count(distinct ((coalesce((select coalesce((select max( -coalesce((select max( -e) from t1 where ((abs(t1.a)/abs(d)) in (select ~~count(*) from t1 union select count(*) from t1) or a in (d,t1.f,d) and -c in (b,e,t1.d))),t1.c)-19 | 11-t1.e) from t1 where exists(select 1 from t1 where a<=e) and f not in (17,t1.b,t1.c) or (t1.a)>=t1.d),e)-t1.c from t1 where b<t1.d or d<= -t1.c),t1.e)))) from t1)))}
+} {}
+do_test randexpr-2.1268 {
+ db eval {SELECT t1.c | 13-19-d+case when t1.d-t1.b+t1.f*t1.a-coalesce((select max(c-17-case when t1.e<c then t1.f when exists(select 1 from t1 where d between -c and f) then t1.a else 17 end) from t1 where 11 in (select a from t1 union select 17 from t1)),c)*11-d in (select c from t1 union select t1.c from t1) then 17 when 11 between a and (a) then a else t1.a end FROM t1 WHERE t1.a<b}
+} {-18}
+do_test randexpr-2.1269 {
+ db eval {SELECT t1.c | 13-19-d+case when t1.d-t1.b+t1.f*t1.a-coalesce((select max(c-17-case when t1.e<c then t1.f when exists(select 1 from t1 where d between -c and f) then t1.a else 17 end) from t1 where 11 in (select a from t1 union select 17 from t1)),c)*11-d in (select c from t1 union select t1.c from t1) then 17 when 11 between a and (a) then a else t1.a end FROM t1 WHERE NOT (t1.a<b)}
+} {}
+do_test randexpr-2.1270 {
+ db eval {SELECT t1.c & 13-19-d+case when t1.d-t1.b+t1.f*t1.a-coalesce((select max(c-17-case when t1.e<c then t1.f when exists(select 1 from t1 where d between -c and f) then t1.a else 17 end) from t1 where 11 in (select a from t1 union select 17 from t1)),c)*11-d in (select c from t1 union select t1.c from t1) then 17 when 11 between a and (a) then a else t1.a end FROM t1 WHERE t1.a<b}
+} {12}
+do_test randexpr-2.1271 {
+ db eval {SELECT case when coalesce((select b from t1 where t1.d not in (t1.c,case when t1.d not in (d,coalesce((select (select count(distinct d) from t1)*e from t1 where not exists(select 1 from t1 where t1.d>=t1.f) or 11+t1.a between (select -cast(avg( -t1.b | 19) AS integer)+case min(t1.d) when -max(t1.e) then -count(distinct 11) else - -max((t1.c)) end from t1) and f),(e)),13) then t1.a else d end* -t1.f,13)),d)>=e then 17 else -11 end FROM t1 WHERE t1.d*b<=+~t1.c-t1.d+d*~b | e}
+} {}
+do_test randexpr-2.1272 {
+ db eval {SELECT case when coalesce((select b from t1 where t1.d not in (t1.c,case when t1.d not in (d,coalesce((select (select count(distinct d) from t1)*e from t1 where not exists(select 1 from t1 where t1.d>=t1.f) or 11+t1.a between (select -cast(avg( -t1.b | 19) AS integer)+case min(t1.d) when -max(t1.e) then -count(distinct 11) else - -max((t1.c)) end from t1) and f),(e)),13) then t1.a else d end* -t1.f,13)),d)>=e then 17 else -11 end FROM t1 WHERE NOT (t1.d*b<=+~t1.c-t1.d+d*~b | e)}
+} {-11}
+do_test randexpr-2.1273 {
+ db eval {SELECT case when coalesce((select b from t1 where t1.d not in (t1.c,case when t1.d not in (d,coalesce((select (select count(distinct d) from t1)*e from t1 where not exists(select 1 from t1 where t1.d>=t1.f) or 11+t1.a between (select -cast(avg( -t1.b & 19) AS integer)+case min(t1.d) when -max(t1.e) then -count(distinct 11) else - -max((t1.c)) end from t1) and f),(e)),13) then t1.a else d end* -t1.f,13)),d)>=e then 17 else -11 end FROM t1 WHERE NOT (t1.d*b<=+~t1.c-t1.d+d*~b | e)}
+} {-11}
+do_test randexpr-2.1274 {
+ db eval {SELECT t1.a*a+11-case when exists(select 1 from t1 where (t1.d)<d and (b=case when t1.d+(t1.c*c)*t1.b=t1.f then t1.e else -11 end)) or not exists(select 1 from t1 where t1.d between 13 and -19 and d<>b) and (19 not in ((t1.a),11,a)) then ~t1.b when t1.c<c then ~c else a end FROM t1 WHERE a+d> -coalesce((select (select max(e) | min(coalesce((select coalesce((select t1.d from t1 where a<a),11)+c from t1 where (b<e)),19)+t1.c)*abs(count(*))*case count(*) when -min(a) then min(t1.c) else max( -19) end* -count(*) from t1) from t1 where (abs((abs(e)/abs(t1.e)))/abs(t1.e)) between a and b),((t1.a)))-17 and t1.e not between 13 and 17}
+} {10212}
+do_test randexpr-2.1275 {
+ db eval {SELECT t1.a*a+11-case when exists(select 1 from t1 where (t1.d)<d and (b=case when t1.d+(t1.c*c)*t1.b=t1.f then t1.e else -11 end)) or not exists(select 1 from t1 where t1.d between 13 and -19 and d<>b) and (19 not in ((t1.a),11,a)) then ~t1.b when t1.c<c then ~c else a end FROM t1 WHERE NOT (a+d> -coalesce((select (select max(e) | min(coalesce((select coalesce((select t1.d from t1 where a<a),11)+c from t1 where (b<e)),19)+t1.c)*abs(count(*))*case count(*) when -min(a) then min(t1.c) else max( -19) end* -count(*) from t1) from t1 where (abs((abs(e)/abs(t1.e)))/abs(t1.e)) between a and b),((t1.a)))-17 and t1.e not between 13 and 17)}
+} {}
+do_test randexpr-2.1276 {
+ db eval {SELECT case when case when case (abs(t1.b)/abs(t1.a)) when e then f else t1.a end>c then 19 else b end- -11 in (select case case count(distinct t1.f) | (max(17)) when (count(*)) then count(distinct b) else count(distinct 19) end when min(t1.f) then (count(distinct t1.f)) else count(*) end-min(13) from t1 union select cast(avg( -t1.c) AS integer) from t1) or f<>t1.a then coalesce((select max(t1.b) from t1 where exists(select 1 from t1 where t1.e>=t1.e)), -t1.a) when exists(select 1 from t1 where 17 between t1.f and t1.d) then t1.c else c end FROM t1 WHERE t1.b=t1.b}
+} {200}
+do_test randexpr-2.1277 {
+ db eval {SELECT case when case when case (abs(t1.b)/abs(t1.a)) when e then f else t1.a end>c then 19 else b end- -11 in (select case case count(distinct t1.f) | (max(17)) when (count(*)) then count(distinct b) else count(distinct 19) end when min(t1.f) then (count(distinct t1.f)) else count(*) end-min(13) from t1 union select cast(avg( -t1.c) AS integer) from t1) or f<>t1.a then coalesce((select max(t1.b) from t1 where exists(select 1 from t1 where t1.e>=t1.e)), -t1.a) when exists(select 1 from t1 where 17 between t1.f and t1.d) then t1.c else c end FROM t1 WHERE NOT (t1.b=t1.b)}
+} {}
+do_test randexpr-2.1278 {
+ db eval {SELECT case when case when case (abs(t1.b)/abs(t1.a)) when e then f else t1.a end>c then 19 else b end- -11 in (select case case count(distinct t1.f) & (max(17)) when (count(*)) then count(distinct b) else count(distinct 19) end when min(t1.f) then (count(distinct t1.f)) else count(*) end-min(13) from t1 union select cast(avg( -t1.c) AS integer) from t1) or f<>t1.a then coalesce((select max(t1.b) from t1 where exists(select 1 from t1 where t1.e>=t1.e)), -t1.a) when exists(select 1 from t1 where 17 between t1.f and t1.d) then t1.c else c end FROM t1 WHERE t1.b=t1.b}
+} {200}
+do_test randexpr-2.1279 {
+ db eval {SELECT (abs(b)/abs(case 19 when case e+13*~t1.c*11 when case when (select ~min(t1.a) from t1)>t1.c then (case when 11 between (a) and (19) then d else d+t1.c end) else f end then (abs((e+t1.d)*e*19-t1.d)/abs(c)) else t1.b end then 11 else ( -t1.b) end*13)) FROM t1 WHERE case when ((select min( -case when b in (d-t1.e,case when e in (select d from t1 union select 17 from t1) then 11 else c end,( -t1.d)) then t1.b when b>e then c else -t1.f end)+ -((min(t1.f)))-+min(f) | ( -(cast(avg(a) AS integer))) from t1)) in (select 11 from t1 union select 19 from t1) then 19 when not exists(select 1 from t1 where -17>t1.f and t1.e in (select t1.e from t1 union select d from t1)) then 11 else d end=t1.d}
+} {}
+do_test randexpr-2.1280 {
+ db eval {SELECT (abs(b)/abs(case 19 when case e+13*~t1.c*11 when case when (select ~min(t1.a) from t1)>t1.c then (case when 11 between (a) and (19) then d else d+t1.c end) else f end then (abs((e+t1.d)*e*19-t1.d)/abs(c)) else t1.b end then 11 else ( -t1.b) end*13)) FROM t1 WHERE NOT (case when ((select min( -case when b in (d-t1.e,case when e in (select d from t1 union select 17 from t1) then 11 else c end,( -t1.d)) then t1.b when b>e then c else -t1.f end)+ -((min(t1.f)))-+min(f) | ( -(cast(avg(a) AS integer))) from t1)) in (select 11 from t1 union select 19 from t1) then 19 when not exists(select 1 from t1 where -17>t1.f and t1.e in (select t1.e from t1 union select d from t1)) then 11 else d end=t1.d)}
+} {0}
+do_test randexpr-2.1281 {
+ db eval {SELECT coalesce((select max(11) from t1 where not not exists(select 1 from t1 where ((abs(b)/abs(t1.f))-19+f-case ~11 when 19 then c else t1.a end)> -c+t1.a)),(11))- -b FROM t1 WHERE b*case when 19 not in (t1.e,a*+t1.d,(abs(+c)/abs(case 11 when b then +case when (not exists(select 1 from t1 where d<=c or c<t1.d or f<=b)) then e*19 | d+f else (t1.d) end | t1.d else b end))) then t1.b when not exists(select 1 from t1 where -t1.e between 11 and e) then a else 17 end*t1.f between -c and -t1.d}
+} {}
+do_test randexpr-2.1282 {
+ db eval {SELECT coalesce((select max(11) from t1 where not not exists(select 1 from t1 where ((abs(b)/abs(t1.f))-19+f-case ~11 when 19 then c else t1.a end)> -c+t1.a)),(11))- -b FROM t1 WHERE NOT (b*case when 19 not in (t1.e,a*+t1.d,(abs(+c)/abs(case 11 when b then +case when (not exists(select 1 from t1 where d<=c or c<t1.d or f<=b)) then e*19 | d+f else (t1.d) end | t1.d else b end))) then t1.b when not exists(select 1 from t1 where -t1.e between 11 and e) then a else 17 end*t1.f between -c and -t1.d)}
+} {211}
+do_test randexpr-2.1283 {
+ db eval {SELECT case when ((select count(*) from t1) not between b+t1.f and -(coalesce((select max(coalesce((select max((select count(*) from t1) | -case when ~19-b between a and 17 and (t1.c) between (13) and d and t1.a<=a then f-19 when 19<t1.d then f else t1.d end) from t1 where - -t1.d between t1.b and a),t1.c)) from t1 where 11<(11)),e)-t1.c)) then b+t1.f else (b) end+13 FROM t1 WHERE e in (case when 17+b-17*+11 | +case when ~b-17*t1.d in (13,19, -t1.b) or 13 between t1.a and d and 11 not in (t1.e,f, -b) then t1.d*17 else b end not in (17,17,t1.c) then t1.c when t1.d not in (f,e,b) then t1.d else 11 end,11,t1.a)}
+} {}
+do_test randexpr-2.1284 {
+ db eval {SELECT case when ((select count(*) from t1) not between b+t1.f and -(coalesce((select max(coalesce((select max((select count(*) from t1) | -case when ~19-b between a and 17 and (t1.c) between (13) and d and t1.a<=a then f-19 when 19<t1.d then f else t1.d end) from t1 where - -t1.d between t1.b and a),t1.c)) from t1 where 11<(11)),e)-t1.c)) then b+t1.f else (b) end+13 FROM t1 WHERE NOT (e in (case when 17+b-17*+11 | +case when ~b-17*t1.d in (13,19, -t1.b) or 13 between t1.a and d and 11 not in (t1.e,f, -b) then t1.d*17 else b end not in (17,17,t1.c) then t1.c when t1.d not in (f,e,b) then t1.d else 11 end,11,t1.a))}
+} {813}
+do_test randexpr-2.1285 {
+ db eval {SELECT case when ((select count(*) from t1) not between b+t1.f and -(coalesce((select max(coalesce((select max((select count(*) from t1) & -case when ~19-b between a and 17 and (t1.c) between (13) and d and t1.a<=a then f-19 when 19<t1.d then f else t1.d end) from t1 where - -t1.d between t1.b and a),t1.c)) from t1 where 11<(11)),e)-t1.c)) then b+t1.f else (b) end+13 FROM t1 WHERE NOT (e in (case when 17+b-17*+11 | +case when ~b-17*t1.d in (13,19, -t1.b) or 13 between t1.a and d and 11 not in (t1.e,f, -b) then t1.d*17 else b end not in (17,17,t1.c) then t1.c when t1.d not in (f,e,b) then t1.d else 11 end,11,t1.a))}
+} {813}
+do_test randexpr-2.1286 {
+ db eval {SELECT case coalesce((select t1.e from t1 where 19 in (select 13 from t1 union select 11 | coalesce((select -(t1.c) from t1 where t1.a<=t1.c),case when ~case when t1.e not between 11 and t1.e then d else 19 end+t1.a+f in (select -(count(distinct -c))-max(d)+count(distinct t1.d) from t1 union select cast(avg((b)) AS integer) from t1) then (t1.d) when not (t1.a not in ( -t1.e,t1.b,17) and 11<d) then e else b end) from t1)),11) when t1.c then a else a end-t1.b FROM t1 WHERE t1.d>=11*t1.d}
+} {}
+do_test randexpr-2.1287 {
+ db eval {SELECT case coalesce((select t1.e from t1 where 19 in (select 13 from t1 union select 11 | coalesce((select -(t1.c) from t1 where t1.a<=t1.c),case when ~case when t1.e not between 11 and t1.e then d else 19 end+t1.a+f in (select -(count(distinct -c))-max(d)+count(distinct t1.d) from t1 union select cast(avg((b)) AS integer) from t1) then (t1.d) when not (t1.a not in ( -t1.e,t1.b,17) and 11<d) then e else b end) from t1)),11) when t1.c then a else a end-t1.b FROM t1 WHERE NOT (t1.d>=11*t1.d)}
+} {-100}
+do_test randexpr-2.1288 {
+ db eval {SELECT case coalesce((select t1.e from t1 where 19 in (select 13 from t1 union select 11 & coalesce((select -(t1.c) from t1 where t1.a<=t1.c),case when ~case when t1.e not between 11 and t1.e then d else 19 end+t1.a+f in (select -(count(distinct -c))-max(d)+count(distinct t1.d) from t1 union select cast(avg((b)) AS integer) from t1) then (t1.d) when not (t1.a not in ( -t1.e,t1.b,17) and 11<d) then e else b end) from t1)),11) when t1.c then a else a end-t1.b FROM t1 WHERE NOT (t1.d>=11*t1.d)}
+} {-100}
+do_test randexpr-2.1289 {
+ db eval {SELECT (select min(coalesce((select max(case (b | case -e when 11 then +(abs(17)/abs((19))) else 13 end) when t1.f then 17 else a end) from t1 where 17 not between e and -a and 19=13 or t1.f=19 and t1.c<e and t1.c in (select cast(avg(19) AS integer)*min(c) from t1 union select +count(*) from t1)),t1.c)) from t1)*t1.e-t1.a FROM t1 WHERE (19)<>t1.b}
+} {149900}
+do_test randexpr-2.1290 {
+ db eval {SELECT (select min(coalesce((select max(case (b | case -e when 11 then +(abs(17)/abs((19))) else 13 end) when t1.f then 17 else a end) from t1 where 17 not between e and -a and 19=13 or t1.f=19 and t1.c<e and t1.c in (select cast(avg(19) AS integer)*min(c) from t1 union select +count(*) from t1)),t1.c)) from t1)*t1.e-t1.a FROM t1 WHERE NOT ((19)<>t1.b)}
+} {}
+do_test randexpr-2.1291 {
+ db eval {SELECT (select min(coalesce((select max(case (b & case -e when 11 then +(abs(17)/abs((19))) else 13 end) when t1.f then 17 else a end) from t1 where 17 not between e and -a and 19=13 or t1.f=19 and t1.c<e and t1.c in (select cast(avg(19) AS integer)*min(c) from t1 union select +count(*) from t1)),t1.c)) from t1)*t1.e-t1.a FROM t1 WHERE (19)<>t1.b}
+} {149900}
+do_test randexpr-2.1292 {
+ db eval {SELECT t1.f*b | coalesce((select max(t1.f) from t1 where (case when (select cast(avg((select (count(distinct e+t1.c)) from t1)) AS integer) from t1)=t1.d then case when not exists(select 1 from t1 where (b)+t1.e+t1.f in (select min(e) from t1 union select case count(distinct t1.c) when count(distinct f) then cast(avg((t1.f)) AS integer) else (cast(avg(13) AS integer)) end from t1)) and not exists(select 1 from t1 where (d=b)) then t1.d when 13 in (f,c,c) then case t1.c when 11 then -a else t1.b end else 13 end else 19 end)<17),19)-t1.a FROM t1 WHERE c>=case when d<t1.e then t1.b when t1.f not between 11 and 17 then coalesce((select max( -~e | (17-c)) from t1 where not exists(select 1 from t1 where (( -13-b) in (select ++cast(avg(b) AS integer) from t1 union select case -case ~max(e)-count(*) when (min(19)) then count(*) else max(t1.c) end | -cast(avg(11) AS integer) when max(b) then (max(e)) else count(*) end | min(t1.d) from t1)))),t1.d) else t1.c end}
+} {-17}
+do_test randexpr-2.1293 {
+ db eval {SELECT t1.f*b | coalesce((select max(t1.f) from t1 where (case when (select cast(avg((select (count(distinct e+t1.c)) from t1)) AS integer) from t1)=t1.d then case when not exists(select 1 from t1 where (b)+t1.e+t1.f in (select min(e) from t1 union select case count(distinct t1.c) when count(distinct f) then cast(avg((t1.f)) AS integer) else (cast(avg(13) AS integer)) end from t1)) and not exists(select 1 from t1 where (d=b)) then t1.d when 13 in (f,c,c) then case t1.c when 11 then -a else t1.b end else 13 end else 19 end)<17),19)-t1.a FROM t1 WHERE NOT (c>=case when d<t1.e then t1.b when t1.f not between 11 and 17 then coalesce((select max( -~e | (17-c)) from t1 where not exists(select 1 from t1 where (( -13-b) in (select ++cast(avg(b) AS integer) from t1 union select case -case ~max(e)-count(*) when (min(19)) then count(*) else max(t1.c) end | -cast(avg(11) AS integer) when max(b) then (max(e)) else count(*) end | min(t1.d) from t1)))),t1.d) else t1.c end)}
+} {}
+do_test randexpr-2.1294 {
+ db eval {SELECT t1.f*b & coalesce((select max(t1.f) from t1 where (case when (select cast(avg((select (count(distinct e+t1.c)) from t1)) AS integer) from t1)=t1.d then case when not exists(select 1 from t1 where (b)+t1.e+t1.f in (select min(e) from t1 union select case count(distinct t1.c) when count(distinct f) then cast(avg((t1.f)) AS integer) else (cast(avg(13) AS integer)) end from t1)) and not exists(select 1 from t1 where (d=b)) then t1.d when 13 in (f,c,c) then case t1.c when 11 then -a else t1.b end else 13 end else 19 end)<17),19)-t1.a FROM t1 WHERE c>=case when d<t1.e then t1.b when t1.f not between 11 and 17 then coalesce((select max( -~e | (17-c)) from t1 where not exists(select 1 from t1 where (( -13-b) in (select ++cast(avg(b) AS integer) from t1 union select case -case ~max(e)-count(*) when (min(19)) then count(*) else max(t1.c) end | -cast(avg(11) AS integer) when max(b) then (max(e)) else count(*) end | min(t1.d) from t1)))),t1.d) else t1.c end}
+} {119936}
+do_test randexpr-2.1295 {
+ db eval {SELECT +case when b in (13,(t1.f),19+a) and not exists(select 1 from t1 where -case when case when case (abs(coalesce((select b from t1 where t1.b>=t1.a),t1.e))/abs(13)) when t1.b then b else -a end=11 then 13 else a end<>t1.f or 19 not in (b,(t1.b), -19) then b else e end<>e) then t1.f else c end | t1.a+d- -f+f FROM t1 WHERE a in (13+17,case when (t1.a>t1.e) then ~t1.c+d*case coalesce((select coalesce((select d from t1 where 11 not between t1.e and coalesce((select t1.b from t1 where -coalesce((select max(t1.b) from t1 where t1.d in (a,11,d) and b=c),c) between b and d),(t1.e))),t1.f) from t1 where t1.e=a),t1.a) when 17 then (t1.f) else t1.d end+b+c when a>=t1.d then t1.a else f end,b)}
+} {}
+do_test randexpr-2.1296 {
+ db eval {SELECT +case when b in (13,(t1.f),19+a) and not exists(select 1 from t1 where -case when case when case (abs(coalesce((select b from t1 where t1.b>=t1.a),t1.e))/abs(13)) when t1.b then b else -a end=11 then 13 else a end<>t1.f or 19 not in (b,(t1.b), -19) then b else e end<>e) then t1.f else c end | t1.a+d- -f+f FROM t1 WHERE NOT (a in (13+17,case when (t1.a>t1.e) then ~t1.c+d*case coalesce((select coalesce((select d from t1 where 11 not between t1.e and coalesce((select t1.b from t1 where -coalesce((select max(t1.b) from t1 where t1.d in (a,11,d) and b=c),c) between b and d),(t1.e))),t1.f) from t1 where t1.e=a),t1.a) when 17 then (t1.f) else t1.d end+b+c when a>=t1.d then t1.a else f end,b))}
+} {1964}
+do_test randexpr-2.1297 {
+ db eval {SELECT +case when b in (13,(t1.f),19+a) and not exists(select 1 from t1 where -case when case when case (abs(coalesce((select b from t1 where t1.b>=t1.a),t1.e))/abs(13)) when t1.b then b else -a end=11 then 13 else a end<>t1.f or 19 not in (b,(t1.b), -19) then b else e end<>e) then t1.f else c end & t1.a+d- -f+f FROM t1 WHERE NOT (a in (13+17,case when (t1.a>t1.e) then ~t1.c+d*case coalesce((select coalesce((select d from t1 where 11 not between t1.e and coalesce((select t1.b from t1 where -coalesce((select max(t1.b) from t1 where t1.d in (a,11,d) and b=c),c) between b and d),(t1.e))),t1.f) from t1 where t1.e=a),t1.a) when 17 then (t1.f) else t1.d end+b+c when a>=t1.d then t1.a else f end,b))}
+} {36}
+do_test randexpr-2.1298 {
+ db eval {SELECT coalesce((select t1.b from t1 where 17+13+t1.b in (e,19,case when 17 in (select case max(b*17-d*t1.b*t1.d)+case max((19)) when ~ -max(t1.f) then +count(*) else cast(avg(13) AS integer) end when count(distinct 11) then min(e) else max(t1.c) end from t1 union select min(d) from t1) then t1.a* -(t1.a) when t1.c=19 then (t1.c) else t1.f end) and t1.f<=13),17) FROM t1 WHERE t1.e<>~t1.b}
+} {17}
+do_test randexpr-2.1299 {
+ db eval {SELECT coalesce((select t1.b from t1 where 17+13+t1.b in (e,19,case when 17 in (select case max(b*17-d*t1.b*t1.d)+case max((19)) when ~ -max(t1.f) then +count(*) else cast(avg(13) AS integer) end when count(distinct 11) then min(e) else max(t1.c) end from t1 union select min(d) from t1) then t1.a* -(t1.a) when t1.c=19 then (t1.c) else t1.f end) and t1.f<=13),17) FROM t1 WHERE NOT (t1.e<>~t1.b)}
+} {}
+do_test randexpr-2.1300 {
+ db eval {SELECT (abs(coalesce((select -~(abs(t1.d)/abs(a)) from t1 where case when f in (select ~~(+abs( - -count(*)) | cast(avg(d) AS integer)) from t1 union select (min(f)) from t1) then (abs(t1.c)/abs( -13)) | f-13+d*17 when a in (t1.f,t1.c,11) then f else -(f) end*c not in (13,d,d) and 19 in (t1.d,t1.d,b)),13))/abs(17)) FROM t1 WHERE exists(select 1 from t1 where t1.d<>case case when not exists(select 1 from t1 where t1.b<e and t1.c>(abs(c)/abs(t1.a))) then t1.b else 17 end when +~(e- -coalesce((select e from t1 where not (b) in (select max(t1.b) from t1 union select case max(t1.e)-max(17)-count(distinct (13)) when -cast(avg( -t1.b) AS integer) then count(distinct d) else min(t1.f) end from t1)),c*d))*a*13 | f then (13) else c end)}
+} {0}
+do_test randexpr-2.1301 {
+ db eval {SELECT (abs(coalesce((select -~(abs(t1.d)/abs(a)) from t1 where case when f in (select ~~(+abs( - -count(*)) | cast(avg(d) AS integer)) from t1 union select (min(f)) from t1) then (abs(t1.c)/abs( -13)) | f-13+d*17 when a in (t1.f,t1.c,11) then f else -(f) end*c not in (13,d,d) and 19 in (t1.d,t1.d,b)),13))/abs(17)) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.d<>case case when not exists(select 1 from t1 where t1.b<e and t1.c>(abs(c)/abs(t1.a))) then t1.b else 17 end when +~(e- -coalesce((select e from t1 where not (b) in (select max(t1.b) from t1 union select case max(t1.e)-max(17)-count(distinct (13)) when -cast(avg( -t1.b) AS integer) then count(distinct d) else min(t1.f) end from t1)),c*d))*a*13 | f then (13) else c end))}
+} {}
+do_test randexpr-2.1302 {
+ db eval {SELECT (abs(coalesce((select -~(abs(t1.d)/abs(a)) from t1 where case when f in (select ~~(+abs( - -count(*)) & cast(avg(d) AS integer)) from t1 union select (min(f)) from t1) then (abs(t1.c)/abs( -13)) & f-13+d*17 when a in (t1.f,t1.c,11) then f else -(f) end*c not in (13,d,d) and 19 in (t1.d,t1.d,b)),13))/abs(17)) FROM t1 WHERE exists(select 1 from t1 where t1.d<>case case when not exists(select 1 from t1 where t1.b<e and t1.c>(abs(c)/abs(t1.a))) then t1.b else 17 end when +~(e- -coalesce((select e from t1 where not (b) in (select max(t1.b) from t1 union select case max(t1.e)-max(17)-count(distinct (13)) when -cast(avg( -t1.b) AS integer) then count(distinct d) else min(t1.f) end from t1)),c*d))*a*13 | f then (13) else c end)}
+} {0}
+do_test randexpr-2.1303 {
+ db eval {SELECT t1.f*+case when ( -17-a*t1.f | case when (coalesce((select max((case a when +13*19* -b then a else 17 end)) from t1 where (t1.b) not between 13 and t1.a),e))-t1.b=t1.f then f else 17 end-b*a*d)<>11 then f else t1.c end-t1.c*e FROM t1 WHERE (select +cast(avg(case when 13*a in (select 11 from t1 union select b from t1) then e when t1.f in (select ~count(distinct f) | count(*) from t1 union select count(distinct 13*t1.a+coalesce((select max(e) from t1 where ~(abs(t1.e)/abs(a)) not in (t1.a+e-c,t1.e,case when t1.f>t1.c or f>t1.c then 13 when t1.c>c then t1.a else -t1.d end)),f)*19) from t1) then d else d end) AS integer) from t1)=d}
+} {210000}
+do_test randexpr-2.1304 {
+ db eval {SELECT t1.f*+case when ( -17-a*t1.f | case when (coalesce((select max((case a when +13*19* -b then a else 17 end)) from t1 where (t1.b) not between 13 and t1.a),e))-t1.b=t1.f then f else 17 end-b*a*d)<>11 then f else t1.c end-t1.c*e FROM t1 WHERE NOT ((select +cast(avg(case when 13*a in (select 11 from t1 union select b from t1) then e when t1.f in (select ~count(distinct f) | count(*) from t1 union select count(distinct 13*t1.a+coalesce((select max(e) from t1 where ~(abs(t1.e)/abs(a)) not in (t1.a+e-c,t1.e,case when t1.f>t1.c or f>t1.c then 13 when t1.c>c then t1.a else -t1.d end)),f)*19) from t1) then d else d end) AS integer) from t1)=d)}
+} {}
+do_test randexpr-2.1305 {
+ db eval {SELECT t1.f*+case when ( -17-a*t1.f & case when (coalesce((select max((case a when +13*19* -b then a else 17 end)) from t1 where (t1.b) not between 13 and t1.a),e))-t1.b=t1.f then f else 17 end-b*a*d)<>11 then f else t1.c end-t1.c*e FROM t1 WHERE (select +cast(avg(case when 13*a in (select 11 from t1 union select b from t1) then e when t1.f in (select ~count(distinct f) | count(*) from t1 union select count(distinct 13*t1.a+coalesce((select max(e) from t1 where ~(abs(t1.e)/abs(a)) not in (t1.a+e-c,t1.e,case when t1.f>t1.c or f>t1.c then 13 when t1.c>c then t1.a else -t1.d end)),f)*19) from t1) then d else d end) AS integer) from t1)=d}
+} {210000}
+do_test randexpr-2.1306 {
+ db eval {SELECT t1.c+case when t1.a in (select max(coalesce((select coalesce((select coalesce((select max(19+case t1.f when a then e else t1.d end) from t1 where t1.d> -c),b) from t1 where (t1.c=e) and t1.f=17), -a) from t1 where (e not between e and 11)),t1.f)) | cast(avg(t1.a) AS integer)*max(t1.c) from t1 union select count(distinct c)-max(a) | min(t1.b) | (count(*))* -min(f) from t1) then t1.a when exists(select 1 from t1 where not exists(select 1 from t1 where -17>11)) then (13) else 13 end FROM t1 WHERE 19=case when exists(select 1 from t1 where t1.f not between 11 and ~c+b-t1.c*case when t1.f<13+(t1.d) and -t1.f<17 or (b<>b) then ~d else t1.b end) or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e=19)) then c+f*17 else t1.a end and t1.e<13}
+} {}
+do_test randexpr-2.1307 {
+ db eval {SELECT t1.c+case when t1.a in (select max(coalesce((select coalesce((select coalesce((select max(19+case t1.f when a then e else t1.d end) from t1 where t1.d> -c),b) from t1 where (t1.c=e) and t1.f=17), -a) from t1 where (e not between e and 11)),t1.f)) | cast(avg(t1.a) AS integer)*max(t1.c) from t1 union select count(distinct c)-max(a) | min(t1.b) | (count(*))* -min(f) from t1) then t1.a when exists(select 1 from t1 where not exists(select 1 from t1 where -17>11)) then (13) else 13 end FROM t1 WHERE NOT (19=case when exists(select 1 from t1 where t1.f not between 11 and ~c+b-t1.c*case when t1.f<13+(t1.d) and -t1.f<17 or (b<>b) then ~d else t1.b end) or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e=19)) then c+f*17 else t1.a end and t1.e<13)}
+} {313}
+do_test randexpr-2.1308 {
+ db eval {SELECT t1.c+case when t1.a in (select max(coalesce((select coalesce((select coalesce((select max(19+case t1.f when a then e else t1.d end) from t1 where t1.d> -c),b) from t1 where (t1.c=e) and t1.f=17), -a) from t1 where (e not between e and 11)),t1.f)) & cast(avg(t1.a) AS integer)*max(t1.c) from t1 union select count(distinct c)-max(a) & min(t1.b) & (count(*))* -min(f) from t1) then t1.a when exists(select 1 from t1 where not exists(select 1 from t1 where -17>11)) then (13) else 13 end FROM t1 WHERE NOT (19=case when exists(select 1 from t1 where t1.f not between 11 and ~c+b-t1.c*case when t1.f<13+(t1.d) and -t1.f<17 or (b<>b) then ~d else t1.b end) or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e=19)) then c+f*17 else t1.a end and t1.e<13)}
+} {313}
+do_test randexpr-2.1309 {
+ db eval {SELECT 13-case when exists(select 1 from t1 where f+b>t1.f+t1.c) or +17 | -coalesce((select case coalesce((select 13-(select (cast(avg(13) AS integer))-max(t1.b) from t1) from t1 where -c in (select max(17) from t1 union select max(t1.b) from t1)),t1.a) when t1.d then 19 else d end from t1 where d>=11),b) between 13 and 11 and 17<=13 then a | t1.c+t1.f else c end FROM t1 WHERE (case when a not in (t1.d+t1.f,b,t1.b) then case when case f | t1.c when t1.e then e else (t1.a)-d | 13 end<>f then t1.e when (((13) in (select min(t1.a) from t1 union select max( -e) from t1) or t1.f between 13 and -t1.b or (f>=f) or 19<c or t1.d<=13)) then 13 else 19 end else -t1.b end) not between 17 and e}
+} {}
+do_test randexpr-2.1310 {
+ db eval {SELECT 13-case when exists(select 1 from t1 where f+b>t1.f+t1.c) or +17 | -coalesce((select case coalesce((select 13-(select (cast(avg(13) AS integer))-max(t1.b) from t1) from t1 where -c in (select max(17) from t1 union select max(t1.b) from t1)),t1.a) when t1.d then 19 else d end from t1 where d>=11),b) between 13 and 11 and 17<=13 then a | t1.c+t1.f else c end FROM t1 WHERE NOT ((case when a not in (t1.d+t1.f,b,t1.b) then case when case f | t1.c when t1.e then e else (t1.a)-d | 13 end<>f then t1.e when (((13) in (select min(t1.a) from t1 union select max( -e) from t1) or t1.f between 13 and -t1.b or (f>=f) or 19<c or t1.d<=13)) then 13 else 19 end else -t1.b end) not between 17 and e)}
+} {-287}
+do_test randexpr-2.1311 {
+ db eval {SELECT 13-case when exists(select 1 from t1 where f+b>t1.f+t1.c) or +17 & -coalesce((select case coalesce((select 13-(select (cast(avg(13) AS integer))-max(t1.b) from t1) from t1 where -c in (select max(17) from t1 union select max(t1.b) from t1)),t1.a) when t1.d then 19 else d end from t1 where d>=11),b) between 13 and 11 and 17<=13 then a & t1.c+t1.f else c end FROM t1 WHERE NOT ((case when a not in (t1.d+t1.f,b,t1.b) then case when case f | t1.c when t1.e then e else (t1.a)-d | 13 end<>f then t1.e when (((13) in (select min(t1.a) from t1 union select max( -e) from t1) or t1.f between 13 and -t1.b or (f>=f) or 19<c or t1.d<=13)) then 13 else 19 end else -t1.b end) not between 17 and e)}
+} {-287}
+do_test randexpr-2.1312 {
+ db eval {SELECT a+case when ((~t1.d*13<=e or (coalesce((select coalesce((select case when -t1.e<>t1.e or f between b and 13 then t1.c else c end | -b from t1 where 17<=17),t1.e) from t1 where 11<c and t1.b not between f and t1.d or 13<=17),t1.f)) not in (13,t1.e,13) and ((13>=d) and t1.e>17))) then t1.a | (select ~ - -cast(avg( -c) AS integer) from t1) else c end FROM t1 WHERE t1.f>=e and t1.f in (select 17 from t1 union select case when (not exists(select 1 from t1 where case when coalesce((select max(19+t1.c) from t1 where 17>=t1.f),c)+19+t1.c< -d then t1.d when t1.c not in (c,t1.f,e) then 17 else t1.d end<t1.e) or (f<=t1.b)) and t1.a not in (a,11, -t1.f) then coalesce((select f from t1 where 17 not in (e,b,t1.f)),t1.f-t1.d) | t1.b when -19<>11 then d else 13 end from t1)}
+} {}
+do_test randexpr-2.1313 {
+ db eval {SELECT a+case when ((~t1.d*13<=e or (coalesce((select coalesce((select case when -t1.e<>t1.e or f between b and 13 then t1.c else c end | -b from t1 where 17<=17),t1.e) from t1 where 11<c and t1.b not between f and t1.d or 13<=17),t1.f)) not in (13,t1.e,13) and ((13>=d) and t1.e>17))) then t1.a | (select ~ - -cast(avg( -c) AS integer) from t1) else c end FROM t1 WHERE NOT (t1.f>=e and t1.f in (select 17 from t1 union select case when (not exists(select 1 from t1 where case when coalesce((select max(19+t1.c) from t1 where 17>=t1.f),c)+19+t1.c< -d then t1.d when t1.c not in (c,t1.f,e) then 17 else t1.d end<t1.e) or (f<=t1.b)) and t1.a not in (a,11, -t1.f) then coalesce((select f from t1 where 17 not in (e,b,t1.f)),t1.f-t1.d) | t1.b when -19<>11 then d else 13 end from t1))}
+} {467}
+do_test randexpr-2.1314 {
+ db eval {SELECT a+case when ((~t1.d*13<=e or (coalesce((select coalesce((select case when -t1.e<>t1.e or f between b and 13 then t1.c else c end & -b from t1 where 17<=17),t1.e) from t1 where 11<c and t1.b not between f and t1.d or 13<=17),t1.f)) not in (13,t1.e,13) and ((13>=d) and t1.e>17))) then t1.a & (select ~ - -cast(avg( -c) AS integer) from t1) else c end FROM t1 WHERE NOT (t1.f>=e and t1.f in (select 17 from t1 union select case when (not exists(select 1 from t1 where case when coalesce((select max(19+t1.c) from t1 where 17>=t1.f),c)+19+t1.c< -d then t1.d when t1.c not in (c,t1.f,e) then 17 else t1.d end<t1.e) or (f<=t1.b)) and t1.a not in (a,11, -t1.f) then coalesce((select f from t1 where 17 not in (e,b,t1.f)),t1.f-t1.d) | t1.b when -19<>11 then d else 13 end from t1))}
+} {132}
+do_test randexpr-2.1315 {
+ db eval {SELECT case when t1.b not in (17 | t1.e*t1.a,11,(select +case max((select -+case (max(t1.f)) when count(*) then count(distinct d) else -( -(cast(avg(f) AS integer))) end-count(distinct t1.a) from t1)) | count(distinct (t1.e)) when -min(c) then count(*) else -count(distinct e) end | cast(avg(17) AS integer) from t1)) then case when d<=t1.c and (exists(select 1 from t1 where (select count(distinct (e)) from t1)=(abs(17)/abs(d)))) then (abs(t1.f)/abs(t1.c)) when t1.f<>e or t1.c<=d and t1.e<=t1.d then 19 else - -d end-t1.e else (t1.f) end FROM t1 WHERE not t1.b=coalesce((select (abs(c)/abs(11)) from t1 where exists(select 1 from t1 where -coalesce((select max(((abs(coalesce((select max(case (select min((abs(19)/abs(19))+19)*count(*)- -cast(avg(t1.d) AS integer)-max(17)+min( -11) from t1) when e then t1.e else f end) from t1 where t1.d<=t1.f), -f)- -t1.e)/abs(d))-t1.b)) from t1 where c<11),t1.b)*a not in (d,d,f))),c)}
+} {-481}
+do_test randexpr-2.1316 {
+ db eval {SELECT case when t1.b not in (17 | t1.e*t1.a,11,(select +case max((select -+case (max(t1.f)) when count(*) then count(distinct d) else -( -(cast(avg(f) AS integer))) end-count(distinct t1.a) from t1)) | count(distinct (t1.e)) when -min(c) then count(*) else -count(distinct e) end | cast(avg(17) AS integer) from t1)) then case when d<=t1.c and (exists(select 1 from t1 where (select count(distinct (e)) from t1)=(abs(17)/abs(d)))) then (abs(t1.f)/abs(t1.c)) when t1.f<>e or t1.c<=d and t1.e<=t1.d then 19 else - -d end-t1.e else (t1.f) end FROM t1 WHERE NOT (not t1.b=coalesce((select (abs(c)/abs(11)) from t1 where exists(select 1 from t1 where -coalesce((select max(((abs(coalesce((select max(case (select min((abs(19)/abs(19))+19)*count(*)- -cast(avg(t1.d) AS integer)-max(17)+min( -11) from t1) when e then t1.e else f end) from t1 where t1.d<=t1.f), -f)- -t1.e)/abs(d))-t1.b)) from t1 where c<11),t1.b)*a not in (d,d,f))),c))}
+} {}
+do_test randexpr-2.1317 {
+ db eval {SELECT case when t1.b not in (17 & t1.e*t1.a,11,(select +case max((select -+case (max(t1.f)) when count(*) then count(distinct d) else -( -(cast(avg(f) AS integer))) end-count(distinct t1.a) from t1)) & count(distinct (t1.e)) when -min(c) then count(*) else -count(distinct e) end & cast(avg(17) AS integer) from t1)) then case when d<=t1.c and (exists(select 1 from t1 where (select count(distinct (e)) from t1)=(abs(17)/abs(d)))) then (abs(t1.f)/abs(t1.c)) when t1.f<>e or t1.c<=d and t1.e<=t1.d then 19 else - -d end-t1.e else (t1.f) end FROM t1 WHERE not t1.b=coalesce((select (abs(c)/abs(11)) from t1 where exists(select 1 from t1 where -coalesce((select max(((abs(coalesce((select max(case (select min((abs(19)/abs(19))+19)*count(*)- -cast(avg(t1.d) AS integer)-max(17)+min( -11) from t1) when e then t1.e else f end) from t1 where t1.d<=t1.f), -f)- -t1.e)/abs(d))-t1.b)) from t1 where c<11),t1.b)*a not in (d,d,f))),c)}
+} {-481}
+do_test randexpr-2.1318 {
+ db eval {SELECT -t1.a*(select (cast(avg((select count(*)-abs(count(*)*count(*)) from t1)) AS integer)++max(t1.d))*cast(avg(t1.a) AS integer) from t1)+t1.c+t1.c+d-e | 11+t1.b-coalesce((select max(case when exists(select 1 from t1 where t1.a+11=t1.b) then c when t1.a not between t1.f and t1.d or 13<11 then -b else 19 end) from t1 where c>=t1.f),t1.f) FROM t1 WHERE exists(select 1 from t1 where (f=(d)*e))}
+} {}
+do_test randexpr-2.1319 {
+ db eval {SELECT -t1.a*(select (cast(avg((select count(*)-abs(count(*)*count(*)) from t1)) AS integer)++max(t1.d))*cast(avg(t1.a) AS integer) from t1)+t1.c+t1.c+d-e | 11+t1.b-coalesce((select max(case when exists(select 1 from t1 where t1.a+11=t1.b) then c when t1.a not between t1.f and t1.d or 13<11 then -b else 19 end) from t1 where c>=t1.f),t1.f) FROM t1 WHERE NOT (exists(select 1 from t1 where (f=(d)*e)))}
+} {-257}
+do_test randexpr-2.1320 {
+ db eval {SELECT -t1.a*(select (cast(avg((select count(*)-abs(count(*)*count(*)) from t1)) AS integer)++max(t1.d))*cast(avg(t1.a) AS integer) from t1)+t1.c+t1.c+d-e & 11+t1.b-coalesce((select max(case when exists(select 1 from t1 where t1.a+11=t1.b) then c when t1.a not between t1.f and t1.d or 13<11 then -b else 19 end) from t1 where c>=t1.f),t1.f) FROM t1 WHERE NOT (exists(select 1 from t1 where (f=(d)*e)))}
+} {-3999632}
+do_test randexpr-2.1321 {
+ db eval {SELECT -case when t1.a+ -c+coalesce((select d from t1 where (t1.d between a and case when t1.c*t1.b*a between a and 13 then t1.d else 11 end) or not t1.e in (select max(d) from t1 union select max(t1.e)-( -count(distinct t1.e)) from t1) or t1.c>=t1.b or a not in (c,t1.f,t1.d) and b<=t1.c),13)+d-(17) | t1.c*17<=t1.a then t1.c else d end FROM t1 WHERE case a when e then f else case when -t1.c not between e*f | b and t1.d then case (select max((b)) from t1)+coalesce((select max(case when 19 in (b,e,17) then 13 when 11 in (t1.a,t1.a,t1.a) then t1.e else 19 end) from t1 where a<=e and 13 between t1.e and -t1.f),13) when 17 then a else t1.d end when e in (select f from t1 union select -t1.d from t1) then t1.a else c end*d end-13*a not in (19,t1.d,19)}
+} {-400}
+do_test randexpr-2.1322 {
+ db eval {SELECT -case when t1.a+ -c+coalesce((select d from t1 where (t1.d between a and case when t1.c*t1.b*a between a and 13 then t1.d else 11 end) or not t1.e in (select max(d) from t1 union select max(t1.e)-( -count(distinct t1.e)) from t1) or t1.c>=t1.b or a not in (c,t1.f,t1.d) and b<=t1.c),13)+d-(17) | t1.c*17<=t1.a then t1.c else d end FROM t1 WHERE NOT (case a when e then f else case when -t1.c not between e*f | b and t1.d then case (select max((b)) from t1)+coalesce((select max(case when 19 in (b,e,17) then 13 when 11 in (t1.a,t1.a,t1.a) then t1.e else 19 end) from t1 where a<=e and 13 between t1.e and -t1.f),13) when 17 then a else t1.d end when e in (select f from t1 union select -t1.d from t1) then t1.a else c end*d end-13*a not in (19,t1.d,19))}
+} {}
+do_test randexpr-2.1323 {
+ db eval {SELECT -case when t1.a+ -c+coalesce((select d from t1 where (t1.d between a and case when t1.c*t1.b*a between a and 13 then t1.d else 11 end) or not t1.e in (select max(d) from t1 union select max(t1.e)-( -count(distinct t1.e)) from t1) or t1.c>=t1.b or a not in (c,t1.f,t1.d) and b<=t1.c),13)+d-(17) & t1.c*17<=t1.a then t1.c else d end FROM t1 WHERE case a when e then f else case when -t1.c not between e*f | b and t1.d then case (select max((b)) from t1)+coalesce((select max(case when 19 in (b,e,17) then 13 when 11 in (t1.a,t1.a,t1.a) then t1.e else 19 end) from t1 where a<=e and 13 between t1.e and -t1.f),13) when 17 then a else t1.d end when e in (select f from t1 union select -t1.d from t1) then t1.a else c end*d end-13*a not in (19,t1.d,19)}
+} {-400}
+do_test randexpr-2.1324 {
+ db eval {SELECT coalesce((select (abs(t1.a)/abs(13)) from t1 where a<>(select max(b)-abs(+min(f+13*17+~coalesce((select case when 11-t1.c<>19 then t1.c when (c) not between t1.e and d and 11 in (t1.f,13,((c))) then 19 else 11 end from t1 where ( -d)<e and 17>f),11)+c-t1.c)) | - - -+max(19) from t1)-f),b) FROM t1 WHERE t1.b-t1.a+case ((t1.a)) when t1.f then (abs(e*e-(e)*c)/abs(t1.f)) else (abs(t1.a)/abs(t1.b)) end between f and (select case cast(avg(13) AS integer) when (count(*)) then (~abs( -case count(*) when abs((count(*))) then count(distinct 13) else count(*) end)-(count(distinct 11)))-count(distinct 19)*((max(t1.c)))-cast(avg(11) AS integer) else (max(19)) end from t1)}
+} {}
+do_test randexpr-2.1325 {
+ db eval {SELECT coalesce((select (abs(t1.a)/abs(13)) from t1 where a<>(select max(b)-abs(+min(f+13*17+~coalesce((select case when 11-t1.c<>19 then t1.c when (c) not between t1.e and d and 11 in (t1.f,13,((c))) then 19 else 11 end from t1 where ( -d)<e and 17>f),11)+c-t1.c)) | - - -+max(19) from t1)-f),b) FROM t1 WHERE NOT (t1.b-t1.a+case ((t1.a)) when t1.f then (abs(e*e-(e)*c)/abs(t1.f)) else (abs(t1.a)/abs(t1.b)) end between f and (select case cast(avg(13) AS integer) when (count(*)) then (~abs( -case count(*) when abs((count(*))) then count(distinct 13) else count(*) end)-(count(distinct 11)))-count(distinct 19)*((max(t1.c)))-cast(avg(11) AS integer) else (max(19)) end from t1))}
+} {7}
+do_test randexpr-2.1326 {
+ db eval {SELECT coalesce((select (abs(t1.a)/abs(13)) from t1 where a<>(select max(b)-abs(+min(f+13*17+~coalesce((select case when 11-t1.c<>19 then t1.c when (c) not between t1.e and d and 11 in (t1.f,13,((c))) then 19 else 11 end from t1 where ( -d)<e and 17>f),11)+c-t1.c)) & - - -+max(19) from t1)-f),b) FROM t1 WHERE NOT (t1.b-t1.a+case ((t1.a)) when t1.f then (abs(e*e-(e)*c)/abs(t1.f)) else (abs(t1.a)/abs(t1.b)) end between f and (select case cast(avg(13) AS integer) when (count(*)) then (~abs( -case count(*) when abs((count(*))) then count(distinct 13) else count(*) end)-(count(distinct 11)))-count(distinct 19)*((max(t1.c)))-cast(avg(11) AS integer) else (max(19)) end from t1))}
+} {7}
+do_test randexpr-2.1327 {
+ db eval {SELECT t1.d*coalesce((select d from t1 where coalesce((select max(t1.c) from t1 where 11<>13),e)<=(select ~min(13) from t1)*t1.a),c)-coalesce((select (t1.b+17) | (abs( -~17)/abs(t1.d)) from t1 where not exists(select 1 from t1 where case t1.d when case when t1.f not in (t1.e,e,17) then f when t1.c not between 11 and -t1.a then b else 17 end+13 then t1.f else t1.b end+13+t1.b between 17 and 13)),t1.b)+t1.a FROM t1 WHERE (not d in (t1.d,(select max(e) from t1),case d*case when not exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where t1.b<=11-d+(select -max(13-t1.f) from t1)*t1.a),19)>t1.c) and c not between d and 19) then 11+~ -t1.a when t1.e<t1.d then f else t1.a end when 17 then t1.b else t1.c end))}
+} {}
+do_test randexpr-2.1328 {
+ db eval {SELECT t1.d*coalesce((select d from t1 where coalesce((select max(t1.c) from t1 where 11<>13),e)<=(select ~min(13) from t1)*t1.a),c)-coalesce((select (t1.b+17) | (abs( -~17)/abs(t1.d)) from t1 where not exists(select 1 from t1 where case t1.d when case when t1.f not in (t1.e,e,17) then f when t1.c not between 11 and -t1.a then b else 17 end+13 then t1.f else t1.b end+13+t1.b between 17 and 13)),t1.b)+t1.a FROM t1 WHERE NOT ((not d in (t1.d,(select max(e) from t1),case d*case when not exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where t1.b<=11-d+(select -max(13-t1.f) from t1)*t1.a),19)>t1.c) and c not between d and 19) then 11+~ -t1.a when t1.e<t1.d then f else t1.a end when 17 then t1.b else t1.c end)))}
+} {119883}
+do_test randexpr-2.1329 {
+ db eval {SELECT t1.d*coalesce((select d from t1 where coalesce((select max(t1.c) from t1 where 11<>13),e)<=(select ~min(13) from t1)*t1.a),c)-coalesce((select (t1.b+17) & (abs( -~17)/abs(t1.d)) from t1 where not exists(select 1 from t1 where case t1.d when case when t1.f not in (t1.e,e,17) then f when t1.c not between 11 and -t1.a then b else 17 end+13 then t1.f else t1.b end+13+t1.b between 17 and 13)),t1.b)+t1.a FROM t1 WHERE NOT ((not d in (t1.d,(select max(e) from t1),case d*case when not exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where t1.b<=11-d+(select -max(13-t1.f) from t1)*t1.a),19)>t1.c) and c not between d and 19) then 11+~ -t1.a when t1.e<t1.d then f else t1.a end when 17 then t1.b else t1.c end)))}
+} {120100}
+do_test randexpr-2.1330 {
+ db eval {SELECT d+~e-case when exists(select 1 from t1 where -a in (select max( -(select -count(*)-min(e)++cast(avg(case when d in (select +max(c) from t1 union select ((count(distinct (e)))) from t1) then (c) when t1.c<e then 13 else t1.f end) AS integer) from t1)++case 19 when a*t1.e then (t1.c) else 13 end+t1.b) from t1 union select max(11) from t1)) then (abs(19)/abs(t1.b)) when f>=f then t1.b else t1.a end*a+19-13 FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where (select min(case when 13 not in (19,e-t1.a*17,17- -case 19 when 17+17 then a else t1.d end+f-t1.a*11) then 17 else t1.b end*17+11-b) from t1) between 11 and f or t1.e<>t1.d)) or c not in (t1.c,17,d)}
+} {}
+do_test randexpr-2.1331 {
+ db eval {SELECT d+~e-case when exists(select 1 from t1 where -a in (select max( -(select -count(*)-min(e)++cast(avg(case when d in (select +max(c) from t1 union select ((count(distinct (e)))) from t1) then (c) when t1.c<e then 13 else t1.f end) AS integer) from t1)++case 19 when a*t1.e then (t1.c) else 13 end+t1.b) from t1 union select max(11) from t1)) then (abs(19)/abs(t1.b)) when f>=f then t1.b else t1.a end*a+19-13 FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where (select min(case when 13 not in (19,e-t1.a*17,17- -case 19 when 17+17 then a else t1.d end+f-t1.a*11) then 17 else t1.b end*17+11-b) from t1) between 11 and f or t1.e<>t1.d)) or c not in (t1.c,17,d))}
+} {-20095}
+do_test randexpr-2.1332 {
+ db eval {SELECT case coalesce((select 11*19*t1.a+(abs(t1.e*(select count(distinct -d) from t1)*case t1.f when +c then d else c end+b)/abs(d)) from t1 where t1.b*13=(e)),13) when (t1.d)*b-19*(e)*e-19+(t1.d) then 13 else b end*a FROM t1 WHERE not d=19 and (abs(t1.c)/abs(17))-a<coalesce((select max(d-+d+case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.b<>b))) then case when 13 not between t1.e and t1.a then c when t1.c>t1.c then 13 else a end | 19 else (19) end*f*13) from t1 where 17=t1.d and (b<>11)),t1.b)+t1.a | d}
+} {20000}
+do_test randexpr-2.1333 {
+ db eval {SELECT case coalesce((select 11*19*t1.a+(abs(t1.e*(select count(distinct -d) from t1)*case t1.f when +c then d else c end+b)/abs(d)) from t1 where t1.b*13=(e)),13) when (t1.d)*b-19*(e)*e-19+(t1.d) then 13 else b end*a FROM t1 WHERE NOT (not d=19 and (abs(t1.c)/abs(17))-a<coalesce((select max(d-+d+case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.b<>b))) then case when 13 not between t1.e and t1.a then c when t1.c>t1.c then 13 else a end | 19 else (19) end*f*13) from t1 where 17=t1.d and (b<>11)),t1.b)+t1.a | d)}
+} {}
+do_test randexpr-2.1334 {
+ db eval {SELECT (c*(abs(coalesce((select t1.b from t1 where (select ~~count(*)+ -count(distinct coalesce((select max(case coalesce((select max(a+(t1.e)) from t1 where -(a)>=t1.e or t1.e<17),c) when t1.d then t1.a else 17 end) from t1 where t1.b not in (e,(c),t1.a)),f)) from t1) between t1.a and b),case when exists(select 1 from t1 where t1.c>=t1.a) then 19 else t1.e end+t1.c))/abs(b))-11 | 19) FROM t1 WHERE not t1.e<=d or not exists(select 1 from t1 where exists(select 1 from t1 where ( -t1.c+d)>t1.a+case when f | -b not between 17 and e then -t1.d else (19) end) or 11 not between 17 and t1.f) or a in (select -cast(avg(13) AS integer)*count(distinct 17)-min(b)- -max(11) | (count(*)) from t1 union select ((((max(b))))) from t1) and t1.e in (13,(13),b)}
+} {307}
+do_test randexpr-2.1335 {
+ db eval {SELECT (c*(abs(coalesce((select t1.b from t1 where (select ~~count(*)+ -count(distinct coalesce((select max(case coalesce((select max(a+(t1.e)) from t1 where -(a)>=t1.e or t1.e<17),c) when t1.d then t1.a else 17 end) from t1 where t1.b not in (e,(c),t1.a)),f)) from t1) between t1.a and b),case when exists(select 1 from t1 where t1.c>=t1.a) then 19 else t1.e end+t1.c))/abs(b))-11 | 19) FROM t1 WHERE NOT (not t1.e<=d or not exists(select 1 from t1 where exists(select 1 from t1 where ( -t1.c+d)>t1.a+case when f | -b not between 17 and e then -t1.d else (19) end) or 11 not between 17 and t1.f) or a in (select -cast(avg(13) AS integer)*count(distinct 17)-min(b)- -max(11) | (count(*)) from t1 union select ((((max(b))))) from t1) and t1.e in (13,(13),b))}
+} {}
+do_test randexpr-2.1336 {
+ db eval {SELECT (c*(abs(coalesce((select t1.b from t1 where (select ~~count(*)+ -count(distinct coalesce((select max(case coalesce((select max(a+(t1.e)) from t1 where -(a)>=t1.e or t1.e<17),c) when t1.d then t1.a else 17 end) from t1 where t1.b not in (e,(c),t1.a)),f)) from t1) between t1.a and b),case when exists(select 1 from t1 where t1.c>=t1.a) then 19 else t1.e end+t1.c))/abs(b))-11 & 19) FROM t1 WHERE not t1.e<=d or not exists(select 1 from t1 where exists(select 1 from t1 where ( -t1.c+d)>t1.a+case when f | -b not between 17 and e then -t1.d else (19) end) or 11 not between 17 and t1.f) or a in (select -cast(avg(13) AS integer)*count(distinct 17)-min(b)- -max(11) | (count(*)) from t1 union select ((((max(b))))) from t1) and t1.e in (13,(13),b)}
+} {1}
+do_test randexpr-2.1337 {
+ db eval {SELECT (select cast(avg(13*13* -coalesce((select b from t1 where case +(abs(17)/abs(d))*e+c-case -case when not a in (d,13,t1.b) then t1.b when t1.f<=b then e else -f end-17 when t1.e then t1.d else a end when c then b else f end<>e or e<b),f)+t1.a-d*a+t1.c) AS integer) from t1) FROM t1 WHERE 19 in (select -~count(distinct case when not not not exists(select 1 from t1 where (d in ((abs(19*t1.f-t1.e*e)/abs(11))*13,t1.f,t1.f))) then 13 else t1.a+17-13 end)-min(t1.f) from t1 union select ( -abs(count(distinct d)))-min(t1.b)*+(+count(*) | (min(19)))+min(c) from t1)}
+} {}
+do_test randexpr-2.1338 {
+ db eval {SELECT (select cast(avg(13*13* -coalesce((select b from t1 where case +(abs(17)/abs(d))*e+c-case -case when not a in (d,13,t1.b) then t1.b when t1.f<=b then e else -f end-17 when t1.e then t1.d else a end when c then b else f end<>e or e<b),f)+t1.a-d*a+t1.c) AS integer) from t1) FROM t1 WHERE NOT (19 in (select -~count(distinct case when not not not exists(select 1 from t1 where (d in ((abs(19*t1.f-t1.e*e)/abs(11))*13,t1.f,t1.f))) then 13 else t1.a+17-13 end)-min(t1.f) from t1 union select ( -abs(count(distinct d)))-min(t1.b)*+(+count(*) | (min(19)))+min(c) from t1))}
+} {-73400}
+do_test randexpr-2.1339 {
+ db eval {SELECT b | t1.d- -coalesce((select case coalesce((select max((select (abs(cast(avg(coalesce((select max(coalesce((select 17 from t1 where -11=t1.e),a)) from t1 where not exists(select 1 from t1 where 13 between t1.f and 13)),11)-c) AS integer)))+min( -b) from t1)+b) from t1 where t1.d not in (b*19,t1.a,a)),t1.e) when t1.e then t1.b else t1.d end from t1 where (e not in (b,t1.a,(a)))),13) FROM t1 WHERE t1.c=coalesce((select t1.d*(select count(*) from t1) from t1 where ((abs(e)/abs(case 13 when t1.d then t1.e else 11 end+13))>t1.d) or (t1.f in (select 11 from t1 union select t1.c from t1) or c>t1.e and b not in (t1.b, -t1.e,t1.a)) or c<>b),(a))-19*t1.c-c*t1.d and exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (t1.b,e,19) or not exists(select 1 from t1 where t1.c=19)))}
+} {}
+do_test randexpr-2.1340 {
+ db eval {SELECT b | t1.d- -coalesce((select case coalesce((select max((select (abs(cast(avg(coalesce((select max(coalesce((select 17 from t1 where -11=t1.e),a)) from t1 where not exists(select 1 from t1 where 13 between t1.f and 13)),11)-c) AS integer)))+min( -b) from t1)+b) from t1 where t1.d not in (b*19,t1.a,a)),t1.e) when t1.e then t1.b else t1.d end from t1 where (e not in (b,t1.a,(a)))),13) FROM t1 WHERE NOT (t1.c=coalesce((select t1.d*(select count(*) from t1) from t1 where ((abs(e)/abs(case 13 when t1.d then t1.e else 11 end+13))>t1.d) or (t1.f in (select 11 from t1 union select t1.c from t1) or c>t1.e and b not in (t1.b, -t1.e,t1.a)) or c<>b),(a))-19*t1.c-c*t1.d and exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (t1.b,e,19) or not exists(select 1 from t1 where t1.c=19))))}
+} {1000}
+do_test randexpr-2.1341 {
+ db eval {SELECT b & t1.d- -coalesce((select case coalesce((select max((select (abs(cast(avg(coalesce((select max(coalesce((select 17 from t1 where -11=t1.e),a)) from t1 where not exists(select 1 from t1 where 13 between t1.f and 13)),11)-c) AS integer)))+min( -b) from t1)+b) from t1 where t1.d not in (b*19,t1.a,a)),t1.e) when t1.e then t1.b else t1.d end from t1 where (e not in (b,t1.a,(a)))),13) FROM t1 WHERE NOT (t1.c=coalesce((select t1.d*(select count(*) from t1) from t1 where ((abs(e)/abs(case 13 when t1.d then t1.e else 11 end+13))>t1.d) or (t1.f in (select 11 from t1 union select t1.c from t1) or c>t1.e and b not in (t1.b, -t1.e,t1.a)) or c<>b),(a))-19*t1.c-c*t1.d and exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (t1.b,e,19) or not exists(select 1 from t1 where t1.c=19))))}
+} {0}
+do_test randexpr-2.1342 {
+ db eval {SELECT coalesce((select 19 from t1 where not exists(select 1 from t1 where 11+d between b and 19-case when t1.e>e*f+case when 13 in (select count(*) from t1 union select ~min(a*t1.d)+count(*) from t1) then c when (select min(d) from t1) in (select cast(avg(17) AS integer) from t1 union select min(t1.a) from t1) and 11<>(f) then -f else 19 end | c then 13 else 19 end*b*t1.b)),a) FROM t1 WHERE (coalesce((select d from t1 where coalesce((select ~(coalesce((select max(t1.a) from t1 where 13+t1.c-c*coalesce((select t1.a from t1 where ( -t1.d not between a and d)),t1.e)+t1.e- - -11-t1.d*11<17),d)) from t1 where f between t1.a and t1.a),t1.c)<>e),t1.d)*(19)-t1.e- -17-a>=d or t1.c between f and a)}
+} {19}
+do_test randexpr-2.1343 {
+ db eval {SELECT coalesce((select 19 from t1 where not exists(select 1 from t1 where 11+d between b and 19-case when t1.e>e*f+case when 13 in (select count(*) from t1 union select ~min(a*t1.d)+count(*) from t1) then c when (select min(d) from t1) in (select cast(avg(17) AS integer) from t1 union select min(t1.a) from t1) and 11<>(f) then -f else 19 end | c then 13 else 19 end*b*t1.b)),a) FROM t1 WHERE NOT ((coalesce((select d from t1 where coalesce((select ~(coalesce((select max(t1.a) from t1 where 13+t1.c-c*coalesce((select t1.a from t1 where ( -t1.d not between a and d)),t1.e)+t1.e- - -11-t1.d*11<17),d)) from t1 where f between t1.a and t1.a),t1.c)<>e),t1.d)*(19)-t1.e- -17-a>=d or t1.c between f and a))}
+} {}
+do_test randexpr-2.1344 {
+ db eval {SELECT coalesce((select 19 from t1 where not exists(select 1 from t1 where 11+d between b and 19-case when t1.e>e*f+case when 13 in (select count(*) from t1 union select ~min(a*t1.d)+count(*) from t1) then c when (select min(d) from t1) in (select cast(avg(17) AS integer) from t1 union select min(t1.a) from t1) and 11<>(f) then -f else 19 end & c then 13 else 19 end*b*t1.b)),a) FROM t1 WHERE (coalesce((select d from t1 where coalesce((select ~(coalesce((select max(t1.a) from t1 where 13+t1.c-c*coalesce((select t1.a from t1 where ( -t1.d not between a and d)),t1.e)+t1.e- - -11-t1.d*11<17),d)) from t1 where f between t1.a and t1.a),t1.c)<>e),t1.d)*(19)-t1.e- -17-a>=d or t1.c between f and a)}
+} {19}
+do_test randexpr-2.1345 {
+ db eval {SELECT coalesce((select +case case when f>t1.d then a+t1.b-f when coalesce((select max(t1.b-case f when 13*t1.a then 11 else 11 end*c) from t1 where f in (select min(t1.d) from t1 union select +count(distinct f) from t1)),17) not in (e,b,t1.a) then f else t1.b end-e*t1.a when -11 then 19 else (t1.d) end from t1 where 17 not between -13 and t1.e),19) FROM t1 WHERE not t1.b*coalesce((select max(17 | coalesce((select coalesce((select +coalesce((select max(case when (b not in (a,t1.b, -t1.a)) and t1.f=t1.b then t1.c-t1.f when 11>d then 17 else 11 end+f) from t1 where t1.e<>b), -t1.e) from t1 where t1.f in (select min(b) from t1 union select max(19)+count(distinct e)+(count(distinct e)) | - -count(distinct 17)*count(*) from t1)),13) from t1 where t1.f>=t1.f),t1.f)) from t1 where t1.f>=b),c)<t1.d}
+} {19}
+do_test randexpr-2.1346 {
+ db eval {SELECT coalesce((select +case case when f>t1.d then a+t1.b-f when coalesce((select max(t1.b-case f when 13*t1.a then 11 else 11 end*c) from t1 where f in (select min(t1.d) from t1 union select +count(distinct f) from t1)),17) not in (e,b,t1.a) then f else t1.b end-e*t1.a when -11 then 19 else (t1.d) end from t1 where 17 not between -13 and t1.e),19) FROM t1 WHERE NOT (not t1.b*coalesce((select max(17 | coalesce((select coalesce((select +coalesce((select max(case when (b not in (a,t1.b, -t1.a)) and t1.f=t1.b then t1.c-t1.f when 11>d then 17 else 11 end+f) from t1 where t1.e<>b), -t1.e) from t1 where t1.f in (select min(b) from t1 union select max(19)+count(distinct e)+(count(distinct e)) | - -count(distinct 17)*count(*) from t1)),13) from t1 where t1.f>=t1.f),t1.f)) from t1 where t1.f>=b),c)<t1.d)}
+} {}
+do_test randexpr-2.1347 {
+ db eval {SELECT -11* -t1.b-t1.b+ -case when t1.e-(select max((select abs((cast(avg(t1.f) AS integer)+++ -cast(avg(a | a) AS integer))) from t1))+(( -max( -b))) from t1)<=(abs(11)/abs((select count(distinct t1.e) from t1)-b*case when t1.a<>11 then t1.a when 17 not between d and 13 or t1.f in (b,b,t1.a) then t1.d else c end)) then -t1.e else b end*t1.a FROM t1 WHERE a in ((abs(t1.c*+(abs(17-(abs(19)/abs(b-coalesce((select max(t1.c) from t1 where c>t1.f),t1.e))))/abs(t1.e))+t1.b | t1.d*t1.a)/abs(coalesce((select case when t1.f in (case when -e<=t1.a then f else 17 end,f,b) then b else t1.c end from t1 where not a in (t1.d,t1.a,c)),t1.f))),b,t1.b) and e in (select f from t1 union select e from t1)}
+} {}
+do_test randexpr-2.1348 {
+ db eval {SELECT -11* -t1.b-t1.b+ -case when t1.e-(select max((select abs((cast(avg(t1.f) AS integer)+++ -cast(avg(a | a) AS integer))) from t1))+(( -max( -b))) from t1)<=(abs(11)/abs((select count(distinct t1.e) from t1)-b*case when t1.a<>11 then t1.a when 17 not between d and 13 or t1.f in (b,b,t1.a) then t1.d else c end)) then -t1.e else b end*t1.a FROM t1 WHERE NOT (a in ((abs(t1.c*+(abs(17-(abs(19)/abs(b-coalesce((select max(t1.c) from t1 where c>t1.f),t1.e))))/abs(t1.e))+t1.b | t1.d*t1.a)/abs(coalesce((select case when t1.f in (case when -e<=t1.a then f else 17 end,f,b) then b else t1.c end from t1 where not a in (t1.d,t1.a,c)),t1.f))),b,t1.b) and e in (select f from t1 union select e from t1))}
+} {52000}
+do_test randexpr-2.1349 {
+ db eval {SELECT -11* -t1.b-t1.b+ -case when t1.e-(select max((select abs((cast(avg(t1.f) AS integer)+++ -cast(avg(a & a) AS integer))) from t1))+(( -max( -b))) from t1)<=(abs(11)/abs((select count(distinct t1.e) from t1)-b*case when t1.a<>11 then t1.a when 17 not between d and 13 or t1.f in (b,b,t1.a) then t1.d else c end)) then -t1.e else b end*t1.a FROM t1 WHERE NOT (a in ((abs(t1.c*+(abs(17-(abs(19)/abs(b-coalesce((select max(t1.c) from t1 where c>t1.f),t1.e))))/abs(t1.e))+t1.b | t1.d*t1.a)/abs(coalesce((select case when t1.f in (case when -e<=t1.a then f else 17 end,f,b) then b else t1.c end from t1 where not a in (t1.d,t1.a,c)),t1.f))),b,t1.b) and e in (select f from t1 union select e from t1))}
+} {52000}
+do_test randexpr-2.1350 {
+ db eval {SELECT case when ((select count(*) | min(case when (a*e in (select -+ -min(a) | cast(avg(11) AS integer) from t1 union select count(distinct t1.e) from t1) and exists(select 1 from t1 where not 13 in (select count(distinct 11) from t1 union select (max(19)) from t1) or (t1.f) between t1.e and (t1.e)) or t1.a<=f) or t1.e<t1.a then t1.a when t1.e not between t1.c and t1.b then t1.c | a*t1.c else -b end) from t1))+19-17<=c then f when 19>t1.c then t1.e else t1.b end FROM t1 WHERE (c not between +(select + -~~max(coalesce((select case when t1.b<=t1.d*a then t1.c else t1.e end*t1.e from t1 where t1.d>=t1.b and c=(f) or t1.e>t1.d and b<e),t1.b))-count(*) | max(d)+cast(avg(19) AS integer) | count(distinct 17) from t1)*t1.a and ((coalesce((select max(t1.b) from t1 where t1.f in (select 17 from t1 union select a from t1)),e))*c))}
+} {}
+do_test randexpr-2.1351 {
+ db eval {SELECT case when ((select count(*) | min(case when (a*e in (select -+ -min(a) | cast(avg(11) AS integer) from t1 union select count(distinct t1.e) from t1) and exists(select 1 from t1 where not 13 in (select count(distinct 11) from t1 union select (max(19)) from t1) or (t1.f) between t1.e and (t1.e)) or t1.a<=f) or t1.e<t1.a then t1.a when t1.e not between t1.c and t1.b then t1.c | a*t1.c else -b end) from t1))+19-17<=c then f when 19>t1.c then t1.e else t1.b end FROM t1 WHERE NOT ((c not between +(select + -~~max(coalesce((select case when t1.b<=t1.d*a then t1.c else t1.e end*t1.e from t1 where t1.d>=t1.b and c=(f) or t1.e>t1.d and b<e),t1.b))-count(*) | max(d)+cast(avg(19) AS integer) | count(distinct 17) from t1)*t1.a and ((coalesce((select max(t1.b) from t1 where t1.f in (select 17 from t1 union select a from t1)),e))*c)))}
+} {600}
+do_test randexpr-2.1352 {
+ db eval {SELECT case when ((select count(*) & min(case when (a*e in (select -+ -min(a) & cast(avg(11) AS integer) from t1 union select count(distinct t1.e) from t1) and exists(select 1 from t1 where not 13 in (select count(distinct 11) from t1 union select (max(19)) from t1) or (t1.f) between t1.e and (t1.e)) or t1.a<=f) or t1.e<t1.a then t1.a when t1.e not between t1.c and t1.b then t1.c & a*t1.c else -b end) from t1))+19-17<=c then f when 19>t1.c then t1.e else t1.b end FROM t1 WHERE NOT ((c not between +(select + -~~max(coalesce((select case when t1.b<=t1.d*a then t1.c else t1.e end*t1.e from t1 where t1.d>=t1.b and c=(f) or t1.e>t1.d and b<e),t1.b))-count(*) | max(d)+cast(avg(19) AS integer) | count(distinct 17) from t1)*t1.a and ((coalesce((select max(t1.b) from t1 where t1.f in (select 17 from t1 union select a from t1)),e))*c)))}
+} {600}
+do_test randexpr-2.1353 {
+ db eval {SELECT coalesce((select max(coalesce((select max((abs((11))/abs(13))-e) from t1 where 11 not in (c,f,(select count(distinct -17+t1.a) from t1)) or (d*coalesce((select b | coalesce((select max(17) from t1 where e in (d,t1.c,t1.c)),+b) from t1 where d in (d-13,t1.c,f)),13))<>t1.c),t1.d)) from t1 where b not in (t1.e, -13,f)),f) FROM t1 WHERE d*a | 19<> -t1.d}
+} {-500}
+do_test randexpr-2.1354 {
+ db eval {SELECT coalesce((select max(coalesce((select max((abs((11))/abs(13))-e) from t1 where 11 not in (c,f,(select count(distinct -17+t1.a) from t1)) or (d*coalesce((select b | coalesce((select max(17) from t1 where e in (d,t1.c,t1.c)),+b) from t1 where d in (d-13,t1.c,f)),13))<>t1.c),t1.d)) from t1 where b not in (t1.e, -13,f)),f) FROM t1 WHERE NOT (d*a | 19<> -t1.d)}
+} {}
+do_test randexpr-2.1355 {
+ db eval {SELECT coalesce((select max(coalesce((select max((abs((11))/abs(13))-e) from t1 where 11 not in (c,f,(select count(distinct -17+t1.a) from t1)) or (d*coalesce((select b & coalesce((select max(17) from t1 where e in (d,t1.c,t1.c)),+b) from t1 where d in (d-13,t1.c,f)),13))<>t1.c),t1.d)) from t1 where b not in (t1.e, -13,f)),f) FROM t1 WHERE d*a | 19<> -t1.d}
+} {-500}
+do_test randexpr-2.1356 {
+ db eval {SELECT coalesce((select t1.f from t1 where case when 19<>(c*case when 19 | -t1.e in (select ~+(max(c)) from t1 union select min(19) from t1) then -t1.f else 13 end-f) then ( -17) else -19 end-b in (t1.b,t1.f,b) or c in (select ~case max( -t1.d) | count(*)*cast(avg(b) AS integer) when count(distinct t1.f) then cast(avg(t1.f) AS integer) else cast(avg(f) AS integer) end | (cast(avg( -t1.e) AS integer)) from t1 union select max(c) from t1) and t1.f in (select max(17) from t1 union select max(11) from t1)),e) FROM t1 WHERE not 13 in (select (t1.b)*(coalesce((select (abs(t1.f)/abs( -t1.f-d))-coalesce((select 19 from t1 where not exists(select 1 from t1 where (select count(distinct t1.f+19-(abs(e)/abs(e))) from t1)- -e<>d)),t1.e)* -t1.a-t1.a-(t1.f)*t1.e*t1.d-t1.b from t1 where t1.e between t1.a and b),11)) from t1 union select d from t1)}
+} {500}
+do_test randexpr-2.1357 {
+ db eval {SELECT coalesce((select t1.f from t1 where case when 19<>(c*case when 19 | -t1.e in (select ~+(max(c)) from t1 union select min(19) from t1) then -t1.f else 13 end-f) then ( -17) else -19 end-b in (t1.b,t1.f,b) or c in (select ~case max( -t1.d) | count(*)*cast(avg(b) AS integer) when count(distinct t1.f) then cast(avg(t1.f) AS integer) else cast(avg(f) AS integer) end | (cast(avg( -t1.e) AS integer)) from t1 union select max(c) from t1) and t1.f in (select max(17) from t1 union select max(11) from t1)),e) FROM t1 WHERE NOT (not 13 in (select (t1.b)*(coalesce((select (abs(t1.f)/abs( -t1.f-d))-coalesce((select 19 from t1 where not exists(select 1 from t1 where (select count(distinct t1.f+19-(abs(e)/abs(e))) from t1)- -e<>d)),t1.e)* -t1.a-t1.a-(t1.f)*t1.e*t1.d-t1.b from t1 where t1.e between t1.a and b),11)) from t1 union select d from t1))}
+} {}
+do_test randexpr-2.1358 {
+ db eval {SELECT coalesce((select t1.f from t1 where case when 19<>(c*case when 19 & -t1.e in (select ~+(max(c)) from t1 union select min(19) from t1) then -t1.f else 13 end-f) then ( -17) else -19 end-b in (t1.b,t1.f,b) or c in (select ~case max( -t1.d) & count(*)*cast(avg(b) AS integer) when count(distinct t1.f) then cast(avg(t1.f) AS integer) else cast(avg(f) AS integer) end & (cast(avg( -t1.e) AS integer)) from t1 union select max(c) from t1) and t1.f in (select max(17) from t1 union select max(11) from t1)),e) FROM t1 WHERE not 13 in (select (t1.b)*(coalesce((select (abs(t1.f)/abs( -t1.f-d))-coalesce((select 19 from t1 where not exists(select 1 from t1 where (select count(distinct t1.f+19-(abs(e)/abs(e))) from t1)- -e<>d)),t1.e)* -t1.a-t1.a-(t1.f)*t1.e*t1.d-t1.b from t1 where t1.e between t1.a and b),11)) from t1 union select d from t1)}
+} {500}
+do_test randexpr-2.1359 {
+ db eval {SELECT ~ -case when t1.d in (17,t1.e,case t1.b*c when -c+f-11 | coalesce((select 11 from t1 where (select (min(13)-max(t1.c))+count(*) from t1)+13<=(( -(t1.f)))),b)+17 then t1.d else b end) then c when c between 13 and f and b>17 then f else t1.a end-t1.f FROM t1 WHERE t1.e>= -f}
+} {-1}
+do_test randexpr-2.1360 {
+ db eval {SELECT ~ -case when t1.d in (17,t1.e,case t1.b*c when -c+f-11 | coalesce((select 11 from t1 where (select (min(13)-max(t1.c))+count(*) from t1)+13<=(( -(t1.f)))),b)+17 then t1.d else b end) then c when c between 13 and f and b>17 then f else t1.a end-t1.f FROM t1 WHERE NOT (t1.e>= -f)}
+} {}
+do_test randexpr-2.1361 {
+ db eval {SELECT ~ -case when t1.d in (17,t1.e,case t1.b*c when -c+f-11 & coalesce((select 11 from t1 where (select (min(13)-max(t1.c))+count(*) from t1)+13<=(( -(t1.f)))),b)+17 then t1.d else b end) then c when c between 13 and f and b>17 then f else t1.a end-t1.f FROM t1 WHERE t1.e>= -f}
+} {-1}
+do_test randexpr-2.1362 {
+ db eval {SELECT ((abs(13)/abs( -b | coalesce((select 17 | t1.e from t1 where (d in (select coalesce((select 17 | (a) | c*case when case when t1.c in (select max(13) | cast(avg(t1.b) AS integer) from t1 union select count(*) from t1) then t1.c when 13>=17 then (11) else t1.e end>t1.d and t1.b>=t1.f then 13 when 11 not in (t1.d, -f,13) then f else 11 end from t1 where b<>11),d) from t1 union select t1.e from t1) or b not in (t1.e,b,e))),t1.e)))) FROM t1 WHERE 11<=coalesce((select max(t1.d) from t1 where coalesce((select ~d+t1.d-case when c not in (t1.b-f,19+~coalesce((select t1.a from t1 where t1.f<=b),case when not (e not between f and t1.e) then (t1.e)-d else b end), -t1.d) then 17 when t1.d not between 13 and t1.d then d else (c) end from t1 where c>t1.a),t1.b)<d),t1.c)}
+} {3}
+do_test randexpr-2.1363 {
+ db eval {SELECT ((abs(13)/abs( -b | coalesce((select 17 | t1.e from t1 where (d in (select coalesce((select 17 | (a) | c*case when case when t1.c in (select max(13) | cast(avg(t1.b) AS integer) from t1 union select count(*) from t1) then t1.c when 13>=17 then (11) else t1.e end>t1.d and t1.b>=t1.f then 13 when 11 not in (t1.d, -f,13) then f else 11 end from t1 where b<>11),d) from t1 union select t1.e from t1) or b not in (t1.e,b,e))),t1.e)))) FROM t1 WHERE NOT (11<=coalesce((select max(t1.d) from t1 where coalesce((select ~d+t1.d-case when c not in (t1.b-f,19+~coalesce((select t1.a from t1 where t1.f<=b),case when not (e not between f and t1.e) then (t1.e)-d else b end), -t1.d) then 17 when t1.d not between 13 and t1.d then d else (c) end from t1 where c>t1.a),t1.b)<d),t1.c))}
+} {}
+do_test randexpr-2.1364 {
+ db eval {SELECT ((abs(13)/abs( -b & coalesce((select 17 & t1.e from t1 where (d in (select coalesce((select 17 & (a) & c*case when case when t1.c in (select max(13) & cast(avg(t1.b) AS integer) from t1 union select count(*) from t1) then t1.c when 13>=17 then (11) else t1.e end>t1.d and t1.b>=t1.f then 13 when 11 not in (t1.d, -f,13) then f else 11 end from t1 where b<>11),d) from t1 union select t1.e from t1) or b not in (t1.e,b,e))),t1.e)))) FROM t1 WHERE 11<=coalesce((select max(t1.d) from t1 where coalesce((select ~d+t1.d-case when c not in (t1.b-f,19+~coalesce((select t1.a from t1 where t1.f<=b),case when not (e not between f and t1.e) then (t1.e)-d else b end), -t1.d) then 17 when t1.d not between 13 and t1.d then d else (c) end from t1 where c>t1.a),t1.b)<d),t1.c)}
+} {0}
+do_test randexpr-2.1365 {
+ db eval {SELECT case when (c between 11 and t1.e*t1.a | c) then case when (case when (b=(select max((t1.c))-min(t1.d) from t1)*b) then t1.c else 17 end-e>t1.d and a between d and d) then c else d end when exists(select 1 from t1 where (11)>19) or a in (t1.b,(t1.c),(a)) and - -11<>13 and t1.b not between -b and d then 19 else a end FROM t1 WHERE 19 | t1.d not between (select ~case case count(distinct t1.c) when (count(*)) then ~~~count(*) else -count(*)- -max(coalesce((select max(19) from t1 where (abs(t1.b-b)/abs(d))+11<a and 17>=t1.a),11))*max(t1.e) | count(*)-abs(max((c)))*max(t1.d) end when -count(*) then cast(avg(f) AS integer) else -(max(c)) end from t1) and t1.c}
+} {400}
+do_test randexpr-2.1366 {
+ db eval {SELECT case when (c between 11 and t1.e*t1.a | c) then case when (case when (b=(select max((t1.c))-min(t1.d) from t1)*b) then t1.c else 17 end-e>t1.d and a between d and d) then c else d end when exists(select 1 from t1 where (11)>19) or a in (t1.b,(t1.c),(a)) and - -11<>13 and t1.b not between -b and d then 19 else a end FROM t1 WHERE NOT (19 | t1.d not between (select ~case case count(distinct t1.c) when (count(*)) then ~~~count(*) else -count(*)- -max(coalesce((select max(19) from t1 where (abs(t1.b-b)/abs(d))+11<a and 17>=t1.a),11))*max(t1.e) | count(*)-abs(max((c)))*max(t1.d) end when -count(*) then cast(avg(f) AS integer) else -(max(c)) end from t1) and t1.c)}
+} {}
+do_test randexpr-2.1367 {
+ db eval {SELECT case when (c between 11 and t1.e*t1.a & c) then case when (case when (b=(select max((t1.c))-min(t1.d) from t1)*b) then t1.c else 17 end-e>t1.d and a between d and d) then c else d end when exists(select 1 from t1 where (11)>19) or a in (t1.b,(t1.c),(a)) and - -11<>13 and t1.b not between -b and d then 19 else a end FROM t1 WHERE 19 | t1.d not between (select ~case case count(distinct t1.c) when (count(*)) then ~~~count(*) else -count(*)- -max(coalesce((select max(19) from t1 where (abs(t1.b-b)/abs(d))+11<a and 17>=t1.a),11))*max(t1.e) | count(*)-abs(max((c)))*max(t1.d) end when -count(*) then cast(avg(f) AS integer) else -(max(c)) end from t1) and t1.c}
+} {100}
+do_test randexpr-2.1368 {
+ db eval {SELECT case when not exists(select 1 from t1 where t1.c not in (t1.d,17,t1.c | coalesce((select t1.f from t1 where t1.c*t1.c-t1.e not in (t1.e*(case when (f) not between c and +f then (a) else t1.e end)+17,13, -((t1.a))) and f not between f and t1.d), -t1.e))) then (abs(e)/abs(a)) when 17<17 or 13<>a then f else (f) end FROM t1 WHERE t1.f in (e,(19),case when not exists(select 1 from t1 where coalesce((select max( -(abs(case -t1.d when t1.d*13+coalesce((select a from t1 where d>19),t1.c) then f else b end)/abs(t1.b))) from t1 where f in (t1.a,t1.d,(c))),t1.d)+c+17<t1.b) then t1.c*t1.b else d end) and (((17 not in (17,t1.c,19))))}
+} {}
+do_test randexpr-2.1369 {
+ db eval {SELECT case when not exists(select 1 from t1 where t1.c not in (t1.d,17,t1.c | coalesce((select t1.f from t1 where t1.c*t1.c-t1.e not in (t1.e*(case when (f) not between c and +f then (a) else t1.e end)+17,13, -((t1.a))) and f not between f and t1.d), -t1.e))) then (abs(e)/abs(a)) when 17<17 or 13<>a then f else (f) end FROM t1 WHERE NOT (t1.f in (e,(19),case when not exists(select 1 from t1 where coalesce((select max( -(abs(case -t1.d when t1.d*13+coalesce((select a from t1 where d>19),t1.c) then f else b end)/abs(t1.b))) from t1 where f in (t1.a,t1.d,(c))),t1.d)+c+17<t1.b) then t1.c*t1.b else d end) and (((17 not in (17,t1.c,19)))))}
+} {600}
+do_test randexpr-2.1370 {
+ db eval {SELECT case when not exists(select 1 from t1 where t1.c not in (t1.d,17,t1.c & coalesce((select t1.f from t1 where t1.c*t1.c-t1.e not in (t1.e*(case when (f) not between c and +f then (a) else t1.e end)+17,13, -((t1.a))) and f not between f and t1.d), -t1.e))) then (abs(e)/abs(a)) when 17<17 or 13<>a then f else (f) end FROM t1 WHERE NOT (t1.f in (e,(19),case when not exists(select 1 from t1 where coalesce((select max( -(abs(case -t1.d when t1.d*13+coalesce((select a from t1 where d>19),t1.c) then f else b end)/abs(t1.b))) from t1 where f in (t1.a,t1.d,(c))),t1.d)+c+17<t1.b) then t1.c*t1.b else d end) and (((17 not in (17,t1.c,19)))))}
+} {600}
+do_test randexpr-2.1371 {
+ db eval {SELECT case +b when coalesce((select max(b) from t1 where exists(select 1 from t1 where (((+~13) in (select case cast(avg(t1.e+(11)+t1.b*e) AS integer) when max(((t1.e))) then min(b)-case -cast(avg(17) AS integer) when min(e) then cast(avg(t1.c) AS integer) else (max(d)) end-count(distinct t1.f) else count(distinct d) end+count(*) from t1 union select max(d) from t1))))),(abs(~d)/abs(11))) then -e else - -13 end+d | t1.d FROM t1 WHERE ((a)>coalesce((select max(coalesce((select max(case when case case when 19 in (select case min(11) when - -cast(avg(c) AS integer) then count(*) else count(*) end-cast(avg(19) AS integer) | cast(avg(17) AS integer) from t1 union select min(t1.d) from t1) then t1.b*t1.a else -t1.a end when t1.f then e else t1.d end<a then t1.a when b between -a and t1.d then -a else t1.f end) from t1 where b<>d),t1.d)) from t1 where t1.c<>e and -17<=a),t1.d))}
+} {413}
+do_test randexpr-2.1372 {
+ db eval {SELECT case +b when coalesce((select max(b) from t1 where exists(select 1 from t1 where (((+~13) in (select case cast(avg(t1.e+(11)+t1.b*e) AS integer) when max(((t1.e))) then min(b)-case -cast(avg(17) AS integer) when min(e) then cast(avg(t1.c) AS integer) else (max(d)) end-count(distinct t1.f) else count(distinct d) end+count(*) from t1 union select max(d) from t1))))),(abs(~d)/abs(11))) then -e else - -13 end+d | t1.d FROM t1 WHERE NOT (((a)>coalesce((select max(coalesce((select max(case when case case when 19 in (select case min(11) when - -cast(avg(c) AS integer) then count(*) else count(*) end-cast(avg(19) AS integer) | cast(avg(17) AS integer) from t1 union select min(t1.d) from t1) then t1.b*t1.a else -t1.a end when t1.f then e else t1.d end<a then t1.a when b between -a and t1.d then -a else t1.f end) from t1 where b<>d),t1.d)) from t1 where t1.c<>e and -17<=a),t1.d)))}
+} {}
+do_test randexpr-2.1373 {
+ db eval {SELECT case +b when coalesce((select max(b) from t1 where exists(select 1 from t1 where (((+~13) in (select case cast(avg(t1.e+(11)+t1.b*e) AS integer) when max(((t1.e))) then min(b)-case -cast(avg(17) AS integer) when min(e) then cast(avg(t1.c) AS integer) else (max(d)) end-count(distinct t1.f) else count(distinct d) end+count(*) from t1 union select max(d) from t1))))),(abs(~d)/abs(11))) then -e else - -13 end+d & t1.d FROM t1 WHERE ((a)>coalesce((select max(coalesce((select max(case when case case when 19 in (select case min(11) when - -cast(avg(c) AS integer) then count(*) else count(*) end-cast(avg(19) AS integer) | cast(avg(17) AS integer) from t1 union select min(t1.d) from t1) then t1.b*t1.a else -t1.a end when t1.f then e else t1.d end<a then t1.a when b between -a and t1.d then -a else t1.f end) from t1 where b<>d),t1.d)) from t1 where t1.c<>e and -17<=a),t1.d))}
+} {400}
+do_test randexpr-2.1374 {
+ db eval {SELECT +c+case when (~t1.e in (+(select case cast(avg(17) AS integer)+min(19)+count(*) when -max(c) then count(distinct t1.c) else - - -(max(13)) end*count(distinct ( -17)) from t1)-case when d+case when f<>d or t1.d<=t1.e then t1.a else -11 end in (select cast(avg(t1.e) AS integer) from t1 union select cast(avg(b) AS integer) from t1) then 19 when ((t1.c) between e and a and -13 not in (d,f,e)) then t1.e else d end,a,t1.b)) then case when t1.b<19 then 13 else 19 end else t1.c end FROM t1 WHERE not exists(select 1 from t1 where 19>t1.f+coalesce((select 13 from t1 where t1.d in (coalesce((select max(e) from t1 where c<t1.c),case when exists(select 1 from t1 where not exists(select 1 from t1 where not (coalesce((select 19 from t1 where case when not exists(select 1 from t1 where 17<17) then t1.f else a end>=t1.c),t1.d) between t1.b and c))) then -f+(t1.b)-t1.e-t1.c+t1.c when c in (select -( -f) from t1 union select 13 from t1) then t1.e else t1.a end),t1.b,a)),11))}
+} {600}
+do_test randexpr-2.1375 {
+ db eval {SELECT +c+case when (~t1.e in (+(select case cast(avg(17) AS integer)+min(19)+count(*) when -max(c) then count(distinct t1.c) else - - -(max(13)) end*count(distinct ( -17)) from t1)-case when d+case when f<>d or t1.d<=t1.e then t1.a else -11 end in (select cast(avg(t1.e) AS integer) from t1 union select cast(avg(b) AS integer) from t1) then 19 when ((t1.c) between e and a and -13 not in (d,f,e)) then t1.e else d end,a,t1.b)) then case when t1.b<19 then 13 else 19 end else t1.c end FROM t1 WHERE NOT (not exists(select 1 from t1 where 19>t1.f+coalesce((select 13 from t1 where t1.d in (coalesce((select max(e) from t1 where c<t1.c),case when exists(select 1 from t1 where not exists(select 1 from t1 where not (coalesce((select 19 from t1 where case when not exists(select 1 from t1 where 17<17) then t1.f else a end>=t1.c),t1.d) between t1.b and c))) then -f+(t1.b)-t1.e-t1.c+t1.c when c in (select -( -f) from t1 union select 13 from t1) then t1.e else t1.a end),t1.b,a)),11)))}
+} {}
+do_test randexpr-2.1376 {
+ db eval {SELECT (17-t1.e-17*t1.d+coalesce((select -(abs(t1.a)/abs(t1.e))-t1.e*13*c*c-c from t1 where coalesce((select max(t1.a) from t1 where +case when t1.a not in (e,(t1.b),t1.f) then 11 when t1.b not between t1.c and t1.c then d else b end not in (13,t1.c,b)),f) between f and 11),d)-t1.d)-f+13 FROM t1 WHERE t1.f<>case when 11 in (coalesce((select e from t1 where not exists(select 1 from t1 where not case when t1.c between 11 and f then +t1.d else (((abs(coalesce((select -t1.c from t1 where (c in (b,b,t1.e))),13) | t1.e*t1.d)/abs(c))-t1.f)) end-t1.d<a and a>=c)),t1.e),d,t1.e) or t1.b<t1.a then 13 when 11=a then t1.a else t1.a end}
+} {-7870}
+do_test randexpr-2.1377 {
+ db eval {SELECT (17-t1.e-17*t1.d+coalesce((select -(abs(t1.a)/abs(t1.e))-t1.e*13*c*c-c from t1 where coalesce((select max(t1.a) from t1 where +case when t1.a not in (e,(t1.b),t1.f) then 11 when t1.b not between t1.c and t1.c then d else b end not in (13,t1.c,b)),f) between f and 11),d)-t1.d)-f+13 FROM t1 WHERE NOT (t1.f<>case when 11 in (coalesce((select e from t1 where not exists(select 1 from t1 where not case when t1.c between 11 and f then +t1.d else (((abs(coalesce((select -t1.c from t1 where (c in (b,b,t1.e))),13) | t1.e*t1.d)/abs(c))-t1.f)) end-t1.d<a and a>=c)),t1.e),d,t1.e) or t1.b<t1.a then 13 when 11=a then t1.a else t1.a end)}
+} {}
+do_test randexpr-2.1378 {
+ db eval {SELECT case +c when 19*t1.b*coalesce((select t1.b-(19* -case when (coalesce((select t1.a from t1 where c>=e or t1.a not in (t1.c,e,t1.f)),t1.b)+19<=t1.a) then ((b)) when d>=b or d not between 19 and t1.e then t1.c else t1.b end-t1.a*f) from t1 where 13 between t1.f and t1.b or e not in (t1.e,b,19)),t1.a) then d else t1.a end FROM t1 WHERE -b>=(select max(19) from t1)}
+} {}
+do_test randexpr-2.1379 {
+ db eval {SELECT case +c when 19*t1.b*coalesce((select t1.b-(19* -case when (coalesce((select t1.a from t1 where c>=e or t1.a not in (t1.c,e,t1.f)),t1.b)+19<=t1.a) then ((b)) when d>=b or d not between 19 and t1.e then t1.c else t1.b end-t1.a*f) from t1 where 13 between t1.f and t1.b or e not in (t1.e,b,19)),t1.a) then d else t1.a end FROM t1 WHERE NOT ( -b>=(select max(19) from t1))}
+} {100}
+do_test randexpr-2.1380 {
+ db eval {SELECT d+(abs(case t1.e when e*(abs(17)/abs(b)) then f else case when not not 13=c then coalesce((select t1.b from t1 where ((e-11 in (select 19 from t1 union select 17 from t1))) or f>=f),d) else case when c in (t1.a,t1.c,d) then t1.e when -11 in (t1.a,e,t1.d) then t1.a else 19 end end-t1.e end*19)/abs(t1.c))-t1.e+d*t1.f FROM t1 WHERE t1.d+t1.c*coalesce((select e from t1 where coalesce((select max(t1.f) from t1 where not f in (select abs(case min(case when a not between a and f then 17 when e>17 then t1.d else 13 end) when abs(case cast(avg(t1.a) AS integer) when -min(t1.b) then count(distinct 17) else (count(distinct t1.a)) end)-count(distinct -b) then count(distinct d) else max(t1.f) end)+count(*)*max(e) from t1 union select (cast(avg(t1.c) AS integer)) from t1)),b*case 19 when t1.a then 11 else e end)<=f),17)=c}
+} {}
+do_test randexpr-2.1381 {
+ db eval {SELECT d+(abs(case t1.e when e*(abs(17)/abs(b)) then f else case when not not 13=c then coalesce((select t1.b from t1 where ((e-11 in (select 19 from t1 union select 17 from t1))) or f>=f),d) else case when c in (t1.a,t1.c,d) then t1.e when -11 in (t1.a,e,t1.d) then t1.a else 19 end end-t1.e end*19)/abs(t1.c))-t1.e+d*t1.f FROM t1 WHERE NOT (t1.d+t1.c*coalesce((select e from t1 where coalesce((select max(t1.f) from t1 where not f in (select abs(case min(case when a not between a and f then 17 when e>17 then t1.d else 13 end) when abs(case cast(avg(t1.a) AS integer) when -min(t1.b) then count(distinct 17) else (count(distinct t1.a)) end)-count(distinct -b) then count(distinct d) else max(t1.f) end)+count(*)*max(e) from t1 union select (cast(avg(t1.c) AS integer)) from t1)),b*case 19 when t1.a then 11 else e end)<=f),17)=c)}
+} {239900}
+do_test randexpr-2.1382 {
+ db eval {SELECT case when ~t1.b=t1.b-coalesce((select 17 from t1 where t1.d-a>=(abs(case when c*11 between 19+(select cast(avg(13*b) AS integer) from t1) and case t1.e-t1.f when t1.a then 11 else a end then 19 else 17 end-c+a)/abs(t1.a))),e) then (f) when exists(select 1 from t1 where (11) in (c,t1.c,t1.b)) then f else 19 end*t1.f FROM t1 WHERE case 19 when t1.b then b*case t1.a when +t1.f then e else 17+t1.a end-11++(select ~~abs(~count(*))+count(distinct 13) from t1)*t1.b-t1.c- -a else 17 end>=t1.e}
+} {}
+do_test randexpr-2.1383 {
+ db eval {SELECT case when ~t1.b=t1.b-coalesce((select 17 from t1 where t1.d-a>=(abs(case when c*11 between 19+(select cast(avg(13*b) AS integer) from t1) and case t1.e-t1.f when t1.a then 11 else a end then 19 else 17 end-c+a)/abs(t1.a))),e) then (f) when exists(select 1 from t1 where (11) in (c,t1.c,t1.b)) then f else 19 end*t1.f FROM t1 WHERE NOT (case 19 when t1.b then b*case t1.a when +t1.f then e else 17+t1.a end-11++(select ~~abs(~count(*))+count(distinct 13) from t1)*t1.b-t1.c- -a else 17 end>=t1.e)}
+} {11400}
+do_test randexpr-2.1384 {
+ db eval {SELECT case when t1.a<=e and d*(t1.d)+t1.d++a-t1.f-a<=e or c not between b and d and 19 not between t1.e and 11 or -t1.b in (select b from t1 union select 17 from t1) and t1.d<>t1.e or t1.d in (select t1.c from t1 union select t1.d from t1) then t1.e else 17 end+f+t1.b FROM t1 WHERE t1.c*~case 19+coalesce((select 19 from t1 where e>11-d),t1.e) when coalesce((select max(11) from t1 where not t1.f in (select ~abs(cast(avg(coalesce((select max(b+f) from t1 where -f=(t1.b) and a between t1.c and t1.b),a)) AS integer))+ -count(distinct t1.b)- -max(f)*max((f)) from t1 union select min(t1.e) from t1) or a in (select +d*d from t1 union select t1.c from t1)),t1.e) then t1.d else t1.c end*t1.b<t1.b}
+} {1300}
+do_test randexpr-2.1385 {
+ db eval {SELECT case when t1.a<=e and d*(t1.d)+t1.d++a-t1.f-a<=e or c not between b and d and 19 not between t1.e and 11 or -t1.b in (select b from t1 union select 17 from t1) and t1.d<>t1.e or t1.d in (select t1.c from t1 union select t1.d from t1) then t1.e else 17 end+f+t1.b FROM t1 WHERE NOT (t1.c*~case 19+coalesce((select 19 from t1 where e>11-d),t1.e) when coalesce((select max(11) from t1 where not t1.f in (select ~abs(cast(avg(coalesce((select max(b+f) from t1 where -f=(t1.b) and a between t1.c and t1.b),a)) AS integer))+ -count(distinct t1.b)- -max(f)*max((f)) from t1 union select min(t1.e) from t1) or a in (select +d*d from t1 union select t1.c from t1)),t1.e) then t1.d else t1.c end*t1.b<t1.b)}
+} {}
+do_test randexpr-2.1386 {
+ db eval {SELECT coalesce((select 17 from t1 where (~f=(abs(coalesce((select t1.d from t1 where case (select count(distinct c | 13)- -(cast(avg(11) AS integer)) from t1)+coalesce((select 19 from t1 where d in (select t1.c from t1 union select 17 from t1)),t1.f) when e then t1.c else t1.d end*d<=19 and not exists(select 1 from t1 where (e)<>b)),e)-13)/abs(t1.e))+17)),t1.a)*t1.d+b FROM t1 WHERE not exists(select 1 from t1 where t1.b=case 19 when f then d+case when t1.c not between 13 and d | (select abs((min(17) | (min(t1.f)))) from t1) and coalesce((select max(11*19) from t1 where not exists(select 1 from t1 where (e>=t1.b))),11) not in (t1.c,19,t1.c) or t1.a in (select count(*) from t1 union select max(c)+cast(avg(11) AS integer) from t1) and (c) not between t1.a and t1.d and t1.b between 11 and a then t1.d else c end else (t1.f) end)}
+} {40200}
+do_test randexpr-2.1387 {
+ db eval {SELECT coalesce((select 17 from t1 where (~f=(abs(coalesce((select t1.d from t1 where case (select count(distinct c | 13)- -(cast(avg(11) AS integer)) from t1)+coalesce((select 19 from t1 where d in (select t1.c from t1 union select 17 from t1)),t1.f) when e then t1.c else t1.d end*d<=19 and not exists(select 1 from t1 where (e)<>b)),e)-13)/abs(t1.e))+17)),t1.a)*t1.d+b FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.b=case 19 when f then d+case when t1.c not between 13 and d | (select abs((min(17) | (min(t1.f)))) from t1) and coalesce((select max(11*19) from t1 where not exists(select 1 from t1 where (e>=t1.b))),11) not in (t1.c,19,t1.c) or t1.a in (select count(*) from t1 union select max(c)+cast(avg(11) AS integer) from t1) and (c) not between t1.a and t1.d and t1.b between 11 and a then t1.d else c end else (t1.f) end))}
+} {}
+do_test randexpr-2.1388 {
+ db eval {SELECT coalesce((select 17 from t1 where (~f=(abs(coalesce((select t1.d from t1 where case (select count(distinct c & 13)- -(cast(avg(11) AS integer)) from t1)+coalesce((select 19 from t1 where d in (select t1.c from t1 union select 17 from t1)),t1.f) when e then t1.c else t1.d end*d<=19 and not exists(select 1 from t1 where (e)<>b)),e)-13)/abs(t1.e))+17)),t1.a)*t1.d+b FROM t1 WHERE not exists(select 1 from t1 where t1.b=case 19 when f then d+case when t1.c not between 13 and d | (select abs((min(17) | (min(t1.f)))) from t1) and coalesce((select max(11*19) from t1 where not exists(select 1 from t1 where (e>=t1.b))),11) not in (t1.c,19,t1.c) or t1.a in (select count(*) from t1 union select max(c)+cast(avg(11) AS integer) from t1) and (c) not between t1.a and t1.d and t1.b between 11 and a then t1.d else c end else (t1.f) end)}
+} {40200}
+do_test randexpr-2.1389 {
+ db eval {SELECT coalesce((select max(t1.f+19+case -d when t1.f then t1.e else e end+case when +d in (select case when exists(select 1 from t1 where coalesce((select max( -17-d+t1.b-t1.d) from t1 where e not in (f,t1.e,11)),c) | t1.e>=c) then b else d end from t1 union select c from t1) then t1.b else d end-e*b+11) from t1 where f<>t1.b),d) FROM t1 WHERE (exists(select 1 from t1 where f> -t1.a*11 or e in (a-~ -t1.e,+a | e*case when coalesce((select t1.c from t1 where t1.f in (select (count(*)) from t1 union select ((count(*))) from t1)),a)-t1.e not in (e,t1.a,d) or 19 in (t1.b,t1.c,13) and c>19 then b*d else ( -t1.d) end-t1.a*t1.b*19,b)))}
+} {-98470}
+do_test randexpr-2.1390 {
+ db eval {SELECT coalesce((select max(t1.f+19+case -d when t1.f then t1.e else e end+case when +d in (select case when exists(select 1 from t1 where coalesce((select max( -17-d+t1.b-t1.d) from t1 where e not in (f,t1.e,11)),c) | t1.e>=c) then b else d end from t1 union select c from t1) then t1.b else d end-e*b+11) from t1 where f<>t1.b),d) FROM t1 WHERE NOT ((exists(select 1 from t1 where f> -t1.a*11 or e in (a-~ -t1.e,+a | e*case when coalesce((select t1.c from t1 where t1.f in (select (count(*)) from t1 union select ((count(*))) from t1)),a)-t1.e not in (e,t1.a,d) or 19 in (t1.b,t1.c,13) and c>19 then b*d else ( -t1.d) end-t1.a*t1.b*19,b))))}
+} {}
+do_test randexpr-2.1391 {
+ db eval {SELECT coalesce((select max(t1.f+19+case -d when t1.f then t1.e else e end+case when +d in (select case when exists(select 1 from t1 where coalesce((select max( -17-d+t1.b-t1.d) from t1 where e not in (f,t1.e,11)),c) & t1.e>=c) then b else d end from t1 union select c from t1) then t1.b else d end-e*b+11) from t1 where f<>t1.b),d) FROM t1 WHERE (exists(select 1 from t1 where f> -t1.a*11 or e in (a-~ -t1.e,+a | e*case when coalesce((select t1.c from t1 where t1.f in (select (count(*)) from t1 union select ((count(*))) from t1)),a)-t1.e not in (e,t1.a,d) or 19 in (t1.b,t1.c,13) and c>19 then b*d else ( -t1.d) end-t1.a*t1.b*19,b)))}
+} {-98670}
+do_test randexpr-2.1392 {
+ db eval {SELECT case t1.b* -(abs(e)/abs(d+b)) when ~a-11 then coalesce((select max(case when (~~19- -t1.d<t1.f or t1.e>=f) then +(abs(t1.c)/abs(t1.e)) when (t1.d>e or t1.a>=t1.a) then 19 else t1.a end*b-(19)-a-t1.c) from t1 where t1.f>=11),13) else b end FROM t1 WHERE (not exists(select 1 from t1 where t1.e<=t1.f) or c- -e*17 in (t1.c+c, -b-17, -coalesce((select case when +coalesce((select max(coalesce((select t1.f from t1 where t1.d in (select max(t1.d)-count(*) from t1 union select max( -t1.a) from t1)),e)+11) from t1 where ( -19)>=t1.a),t1.e)-13 not between t1.a and d then t1.d else 19 end+t1.b from t1 where t1.d<>19),11)))}
+} {}
+do_test randexpr-2.1393 {
+ db eval {SELECT case t1.b* -(abs(e)/abs(d+b)) when ~a-11 then coalesce((select max(case when (~~19- -t1.d<t1.f or t1.e>=f) then +(abs(t1.c)/abs(t1.e)) when (t1.d>e or t1.a>=t1.a) then 19 else t1.a end*b-(19)-a-t1.c) from t1 where t1.f>=11),13) else b end FROM t1 WHERE NOT ((not exists(select 1 from t1 where t1.e<=t1.f) or c- -e*17 in (t1.c+c, -b-17, -coalesce((select case when +coalesce((select max(coalesce((select t1.f from t1 where t1.d in (select max(t1.d)-count(*) from t1 union select max( -t1.a) from t1)),e)+11) from t1 where ( -19)>=t1.a),t1.e)-13 not between t1.a and d then t1.d else 19 end+t1.b from t1 where t1.d<>19),11))))}
+} {200}
+do_test randexpr-2.1394 {
+ db eval {SELECT (select case case min(d-t1.c)-max(t1.a) when ~count(distinct d+case -f*t1.d+11 when b then b else b end)-min(c) then case +max(t1.a)*~abs(count(*)) when -min(13) then max(17) else count(*) end else -max(e) end when max(t1.a) then max(d) else max(17) end-count(distinct t1.b) from t1)-(d) FROM t1 WHERE +19 between b*11 and (select max(d-13) | ~+~+~((count(*)))*cast(avg(b) AS integer) from t1)+b}
+} {}
+do_test randexpr-2.1395 {
+ db eval {SELECT (select case case min(d-t1.c)-max(t1.a) when ~count(distinct d+case -f*t1.d+11 when b then b else b end)-min(c) then case +max(t1.a)*~abs(count(*)) when -min(13) then max(17) else count(*) end else -max(e) end when max(t1.a) then max(d) else max(17) end-count(distinct t1.b) from t1)-(d) FROM t1 WHERE NOT (+19 between b*11 and (select max(d-13) | ~+~+~((count(*)))*cast(avg(b) AS integer) from t1)+b)}
+} {-384}
+do_test randexpr-2.1396 {
+ db eval {SELECT (abs(case when +a*t1.e+(abs(t1.e | 11+coalesce((select max(d) from t1 where (not not b<coalesce((select e from t1 where e<>19),17)) and t1.b>13 and d=t1.a and 13 in (d,t1.a,11)),t1.e)*d)/abs(11+t1.a-19))=c or b<>c then t1.e when b<>19 then 17 else b end)/abs(11)) FROM t1 WHERE (coalesce((select max(case when exists(select 1 from t1 where coalesce((select a from t1 where not 19-~(coalesce((select t1.d from t1 where d between e and 17),t1.a)-t1.a-17) in (t1.d,t1.e,19)),19)*11*d in (select d from t1 union select t1.b from t1)) then c when d between t1.a and -19 then t1.e else 19 end-d*c) from t1 where (t1.f>=t1.c)),11)) not in (17,17,a)}
+} {45}
+do_test randexpr-2.1397 {
+ db eval {SELECT (abs(case when +a*t1.e+(abs(t1.e | 11+coalesce((select max(d) from t1 where (not not b<coalesce((select e from t1 where e<>19),17)) and t1.b>13 and d=t1.a and 13 in (d,t1.a,11)),t1.e)*d)/abs(11+t1.a-19))=c or b<>c then t1.e when b<>19 then 17 else b end)/abs(11)) FROM t1 WHERE NOT ((coalesce((select max(case when exists(select 1 from t1 where coalesce((select a from t1 where not 19-~(coalesce((select t1.d from t1 where d between e and 17),t1.a)-t1.a-17) in (t1.d,t1.e,19)),19)*11*d in (select d from t1 union select t1.b from t1)) then c when d between t1.a and -19 then t1.e else 19 end-d*c) from t1 where (t1.f>=t1.c)),11)) not in (17,17,a))}
+} {}
+do_test randexpr-2.1398 {
+ db eval {SELECT (abs(case when +a*t1.e+(abs(t1.e & 11+coalesce((select max(d) from t1 where (not not b<coalesce((select e from t1 where e<>19),17)) and t1.b>13 and d=t1.a and 13 in (d,t1.a,11)),t1.e)*d)/abs(11+t1.a-19))=c or b<>c then t1.e when b<>19 then 17 else b end)/abs(11)) FROM t1 WHERE (coalesce((select max(case when exists(select 1 from t1 where coalesce((select a from t1 where not 19-~(coalesce((select t1.d from t1 where d between e and 17),t1.a)-t1.a-17) in (t1.d,t1.e,19)),19)*11*d in (select d from t1 union select t1.b from t1)) then c when d between t1.a and -19 then t1.e else 19 end-d*c) from t1 where (t1.f>=t1.c)),11)) not in (17,17,a)}
+} {45}
+do_test randexpr-2.1399 {
+ db eval {SELECT 19+(t1.f)*case coalesce((select max(b) from t1 where not f not between coalesce((select (select (count(distinct t1.c))+ -max( -(f)) from t1)+t1.c from t1 where t1.c<=d),17)-c-19 and 17 or f<>13),case when not exists(select 1 from t1 where ((a)) between b and t1.f) then c when not ( -f not in (t1.b,t1.a,t1.c)) then -t1.b else 19 end)-t1.d-t1.e when t1.e then 11 else 19 end FROM t1 WHERE not not exists(select 1 from t1 where not 11=c and a*e between coalesce((select max(t1.e) from t1 where f=t1.b*19+case when (e not in (t1.d,t1.d, -c) or t1.a<e or 13 in (select - -count(*) from t1 union select min(17) from t1)) then t1.c when -19 in (13,f,e) then -t1.d else 17 end+t1.b*d),f)*d and t1.a)}
+} {}
+do_test randexpr-2.1400 {
+ db eval {SELECT 19+(t1.f)*case coalesce((select max(b) from t1 where not f not between coalesce((select (select (count(distinct t1.c))+ -max( -(f)) from t1)+t1.c from t1 where t1.c<=d),17)-c-19 and 17 or f<>13),case when not exists(select 1 from t1 where ((a)) between b and t1.f) then c when not ( -f not in (t1.b,t1.a,t1.c)) then -t1.b else 19 end)-t1.d-t1.e when t1.e then 11 else 19 end FROM t1 WHERE NOT (not not exists(select 1 from t1 where not 11=c and a*e between coalesce((select max(t1.e) from t1 where f=t1.b*19+case when (e not in (t1.d,t1.d, -c) or t1.a<e or 13 in (select - -count(*) from t1 union select min(17) from t1)) then t1.c when -19 in (13,f,e) then -t1.d else 17 end+t1.b*d),f)*d and t1.a))}
+} {11419}
+do_test randexpr-2.1401 {
+ db eval {SELECT coalesce((select max(19) from t1 where e-coalesce((select 13 from t1 where exists(select 1 from t1 where ((+(case when d*t1.b not in (t1.d,t1.f,e) then 11 else t1.c end))+19*11+e<=11))),19+t1.d) between t1.c and -e and exists(select 1 from t1 where t1.d=c and exists(select 1 from t1 where exists(select 1 from t1 where t1.f=b and a in (19,t1.b,d) or t1.b=11) or t1.c>19) or t1.d=a)),19) FROM t1 WHERE t1.c not between f and d}
+} {19}
+do_test randexpr-2.1402 {
+ db eval {SELECT coalesce((select max(19) from t1 where e-coalesce((select 13 from t1 where exists(select 1 from t1 where ((+(case when d*t1.b not in (t1.d,t1.f,e) then 11 else t1.c end))+19*11+e<=11))),19+t1.d) between t1.c and -e and exists(select 1 from t1 where t1.d=c and exists(select 1 from t1 where exists(select 1 from t1 where t1.f=b and a in (19,t1.b,d) or t1.b=11) or t1.c>19) or t1.d=a)),19) FROM t1 WHERE NOT (t1.c not between f and d)}
+} {}
+do_test randexpr-2.1403 {
+ db eval {SELECT case e when (t1.e+case when t1.e not between t1.c and case when d+coalesce((select t1.d+13+case case a when t1.a then t1.b else t1.c end when 17 then t1.b else f end+19 from t1 where exists(select 1 from t1 where t1.f< -17)),11)>=d then 13 else 13 end*(t1.c) then -c when t1.e not between t1.f and t1.d then t1.a else ( - -t1.a) end-d) then t1.a else t1.d end FROM t1 WHERE t1.d between case when -(t1.e-c)+a between -+coalesce((select max(+t1.c) from t1 where (coalesce((select max(case when d>~t1.e then t1.c when t1.f in (select t1.d from t1 union select t1.e from t1) then (19) else t1.e end) from t1 where not exists(select 1 from t1 where t1.e< -(11))),t1.f) in (select min(t1.f) from t1 union select count(distinct 13) from t1))),t1.e) and t1.d then a when 13<=c then b else t1.c end-c and f}
+} {400}
+do_test randexpr-2.1404 {
+ db eval {SELECT case e when (t1.e+case when t1.e not between t1.c and case when d+coalesce((select t1.d+13+case case a when t1.a then t1.b else t1.c end when 17 then t1.b else f end+19 from t1 where exists(select 1 from t1 where t1.f< -17)),11)>=d then 13 else 13 end*(t1.c) then -c when t1.e not between t1.f and t1.d then t1.a else ( - -t1.a) end-d) then t1.a else t1.d end FROM t1 WHERE NOT (t1.d between case when -(t1.e-c)+a between -+coalesce((select max(+t1.c) from t1 where (coalesce((select max(case when d>~t1.e then t1.c when t1.f in (select t1.d from t1 union select t1.e from t1) then (19) else t1.e end) from t1 where not exists(select 1 from t1 where t1.e< -(11))),t1.f) in (select min(t1.f) from t1 union select count(distinct 13) from t1))),t1.e) and t1.d then a when 13<=c then b else t1.c end-c and f)}
+} {}
+do_test randexpr-2.1405 {
+ db eval {SELECT (select abs(min(case when d not between coalesce((select max(case case t1.e when e-t1.f-a then case when (not exists(select 1 from t1 where coalesce((select max(t1.f) from t1 where 19<>17 and e not between -13 and t1.a),t1.c)>=t1.e)) then (select abs(cast(avg(17) AS integer)) from t1) when c between e and 17 then (select (count(*)) from t1) else 11 end else 11 end when e then 11 else a end) from t1 where t1.b>t1.b),t1.e) and 13 then t1.d else 17 end))*min(b) | -count(distinct t1.f) from t1) FROM t1 WHERE (e) in (select +t1.f from t1 union select t1.f+coalesce((select t1.d+e from t1 where t1.f not in (t1.b,t1.f,e)),(19))*case when t1.a<=a and t1.e<=e then t1.d else t1.c end from t1) and (t1.c not between 11 and e) or d in (select count(*)-cast(avg(t1.a) AS integer) from t1 union select max(19) from t1) and not t1.a not in (11,t1.d,b) or 17>=t1.a}
+} {}
+do_test randexpr-2.1406 {
+ db eval {SELECT (select abs(min(case when d not between coalesce((select max(case case t1.e when e-t1.f-a then case when (not exists(select 1 from t1 where coalesce((select max(t1.f) from t1 where 19<>17 and e not between -13 and t1.a),t1.c)>=t1.e)) then (select abs(cast(avg(17) AS integer)) from t1) when c between e and 17 then (select (count(*)) from t1) else 11 end else 11 end when e then 11 else a end) from t1 where t1.b>t1.b),t1.e) and 13 then t1.d else 17 end))*min(b) | -count(distinct t1.f) from t1) FROM t1 WHERE NOT ((e) in (select +t1.f from t1 union select t1.f+coalesce((select t1.d+e from t1 where t1.f not in (t1.b,t1.f,e)),(19))*case when t1.a<=a and t1.e<=e then t1.d else t1.c end from t1) and (t1.c not between 11 and e) or d in (select count(*)-cast(avg(t1.a) AS integer) from t1 union select max(19) from t1) and not t1.a not in (11,t1.d,b) or 17>=t1.a)}
+} {-1}
+do_test randexpr-2.1407 {
+ db eval {SELECT (select abs(min(case when d not between coalesce((select max(case case t1.e when e-t1.f-a then case when (not exists(select 1 from t1 where coalesce((select max(t1.f) from t1 where 19<>17 and e not between -13 and t1.a),t1.c)>=t1.e)) then (select abs(cast(avg(17) AS integer)) from t1) when c between e and 17 then (select (count(*)) from t1) else 11 end else 11 end when e then 11 else a end) from t1 where t1.b>t1.b),t1.e) and 13 then t1.d else 17 end))*min(b) & -count(distinct t1.f) from t1) FROM t1 WHERE NOT ((e) in (select +t1.f from t1 union select t1.f+coalesce((select t1.d+e from t1 where t1.f not in (t1.b,t1.f,e)),(19))*case when t1.a<=a and t1.e<=e then t1.d else t1.c end from t1) and (t1.c not between 11 and e) or d in (select count(*)-cast(avg(t1.a) AS integer) from t1 union select max(19) from t1) and not t1.a not in (11,t1.d,b) or 17>=t1.a)}
+} {80000}
+do_test randexpr-2.1408 {
+ db eval {SELECT case when ++coalesce((select (abs(a)/abs((select max((abs(13*f)/abs(t1.d))-t1.d*t1.e) from t1)))+b-t1.c+(select +(cast(avg(c) AS integer))*count(*) from t1)-t1.d-b*t1.e+19 from t1 where t1.c not between 11 and t1.d),19)<=t1.d then t1.d when not exists(select 1 from t1 where -11=t1.a) then e else 11 end FROM t1 WHERE (coalesce((select max(coalesce((select a-19 | ~~t1.b from t1 where (abs(t1.f)/abs(b)) not between case when t1.d<=case when not exists(select 1 from t1 where 19<=t1.d) then case when t1.a<=c then f else t1.d end when d>=17 then t1.c else (b) end*t1.c then - -t1.c when c<>t1.a then t1.f else 11 end and e),t1.e)-(t1.a)) from t1 where e<=a),17)<=t1.e) and t1.d=(f)}
+} {}
+do_test randexpr-2.1409 {
+ db eval {SELECT case when ++coalesce((select (abs(a)/abs((select max((abs(13*f)/abs(t1.d))-t1.d*t1.e) from t1)))+b-t1.c+(select +(cast(avg(c) AS integer))*count(*) from t1)-t1.d-b*t1.e+19 from t1 where t1.c not between 11 and t1.d),19)<=t1.d then t1.d when not exists(select 1 from t1 where -11=t1.a) then e else 11 end FROM t1 WHERE NOT ((coalesce((select max(coalesce((select a-19 | ~~t1.b from t1 where (abs(t1.f)/abs(b)) not between case when t1.d<=case when not exists(select 1 from t1 where 19<=t1.d) then case when t1.a<=c then f else t1.d end when d>=17 then t1.c else (b) end*t1.c then - -t1.c when c<>t1.a then t1.f else 11 end and e),t1.e)-(t1.a)) from t1 where e<=a),17)<=t1.e) and t1.d=(f))}
+} {400}
+do_test randexpr-2.1410 {
+ db eval {SELECT c*t1.c*(abs(case 11 when case when 11*11 not between b and t1.a then t1.d else -coalesce((select t1.c from t1 where (not exists(select 1 from t1 where e*~13 not in (a*t1.c, -t1.a,case when 13=t1.c or 13 between 11 and a then - -a when e<=t1.e then 13 else 11 end)))),t1.b+t1.b) end then t1.c else ((e)) end)/abs(t1.a))+t1.a-e-13 FROM t1 WHERE t1.a*13+case when (select count(distinct b++(select case count(distinct 19*(select -+min((13*f))-count(distinct t1.c)-max(t1.e) | (count(distinct 11)) from t1)*(f)) when count(*) then min(a)+(cast(avg(t1.d) AS integer)) else -min(17) end from t1) | t1.c-f) from t1)>t1.b then 19 else c end+17<c}
+} {}
+do_test randexpr-2.1411 {
+ db eval {SELECT c*t1.c*(abs(case 11 when case when 11*11 not between b and t1.a then t1.d else -coalesce((select t1.c from t1 where (not exists(select 1 from t1 where e*~13 not in (a*t1.c, -t1.a,case when 13=t1.c or 13 between 11 and a then - -a when e<=t1.e then 13 else 11 end)))),t1.b+t1.b) end then t1.c else ((e)) end)/abs(t1.a))+t1.a-e-13 FROM t1 WHERE NOT (t1.a*13+case when (select count(distinct b++(select case count(distinct 19*(select -+min((13*f))-count(distinct t1.c)-max(t1.e) | (count(distinct 11)) from t1)*(f)) when count(*) then min(a)+(cast(avg(t1.d) AS integer)) else -min(17) end from t1) | t1.c-f) from t1)>t1.b then 19 else c end+17<c)}
+} {449587}
+do_test randexpr-2.1412 {
+ db eval {SELECT ~coalesce((select b from t1 where b between e and case when t1.c+coalesce((select 11 from t1 where (a in (+d-11,t1.f-a,b)) and t1.c in (select t1.f from t1 union select c from t1) or b between 13 and t1.b and t1.e<(c) and a>=t1.c and e between d and t1.f),case when (13)<>(t1.e) then d when t1.a<=t1.e then 13 else d end) not in (17,b,17) then t1.d else t1.a end+a),t1.d) FROM t1 WHERE case t1.f when 11 then t1.e | f*case when ((select max(17) from t1) | 11>17+~coalesce((select max(t1.b) from t1 where (coalesce((select max(t1.e) from t1 where t1.e in (select (cast(avg( -t1.a) AS integer)) from t1 union select count(*) from t1)),a)) in (t1.f,a,t1.e)),f)+17) then t1.a when 19 in (t1.c, -e,11) or not exists(select 1 from t1 where t1.e between d and a) then 13 else 19 end+t1.f else 11 end<17}
+} {-401}
+do_test randexpr-2.1413 {
+ db eval {SELECT ~coalesce((select b from t1 where b between e and case when t1.c+coalesce((select 11 from t1 where (a in (+d-11,t1.f-a,b)) and t1.c in (select t1.f from t1 union select c from t1) or b between 13 and t1.b and t1.e<(c) and a>=t1.c and e between d and t1.f),case when (13)<>(t1.e) then d when t1.a<=t1.e then 13 else d end) not in (17,b,17) then t1.d else t1.a end+a),t1.d) FROM t1 WHERE NOT (case t1.f when 11 then t1.e | f*case when ((select max(17) from t1) | 11>17+~coalesce((select max(t1.b) from t1 where (coalesce((select max(t1.e) from t1 where t1.e in (select (cast(avg( -t1.a) AS integer)) from t1 union select count(*) from t1)),a)) in (t1.f,a,t1.e)),f)+17) then t1.a when 19 in (t1.c, -e,11) or not exists(select 1 from t1 where t1.e between d and a) then 13 else 19 end+t1.f else 11 end<17)}
+} {}
+do_test randexpr-2.1414 {
+ db eval {SELECT ~case when (a<> -++ -11) then e+case when c*t1.a<t1.d then 19 when not not 11>d then t1.a else b end else a end | case when not exists(select 1 from t1 where not exists(select 1 from t1 where 13 | d in (select a from t1 union select d from t1))) or t1.f not between c and 19 then +t1.a else c-a end-17*c FROM t1 WHERE (case when (case when b in (select 11*coalesce((select 11 from t1 where (d not between 13 and 13+17)),coalesce((select max(13) from t1 where t1.c in (select max(e) from t1 union select count(*) from t1)),t1.b)) from t1 union select -t1.e from t1) then 13 when t1.f in ( -f, -(f),c) then 19 else f end in (select t1.a from t1 union select (t1.c) from t1)) then (abs(19)/abs(t1.b)) when (e in (b,11,19)) and t1.a<c then 19 else a end between d and 11)}
+} {}
+do_test randexpr-2.1415 {
+ db eval {SELECT ~case when (a<> -++ -11) then e+case when c*t1.a<t1.d then 19 when not not 11>d then t1.a else b end else a end | case when not exists(select 1 from t1 where not exists(select 1 from t1 where 13 | d in (select a from t1 union select d from t1))) or t1.f not between c and 19 then +t1.a else c-a end-17*c FROM t1 WHERE NOT ((case when (case when b in (select 11*coalesce((select 11 from t1 where (d not between 13 and 13+17)),coalesce((select max(13) from t1 where t1.c in (select max(e) from t1 union select count(*) from t1)),t1.b)) from t1 union select -t1.e from t1) then 13 when t1.f in ( -f, -(f),c) then 19 else f end in (select t1.a from t1 union select (t1.c) from t1)) then (abs(19)/abs(t1.b)) when (e in (b,11,19)) and t1.a<c then 19 else a end between d and 11))}
+} {-645}
+do_test randexpr-2.1416 {
+ db eval {SELECT ~case when (a<> -++ -11) then e+case when c*t1.a<t1.d then 19 when not not 11>d then t1.a else b end else a end & case when not exists(select 1 from t1 where not exists(select 1 from t1 where 13 & d in (select a from t1 union select d from t1))) or t1.f not between c and 19 then +t1.a else c-a end-17*c FROM t1 WHERE NOT ((case when (case when b in (select 11*coalesce((select 11 from t1 where (d not between 13 and 13+17)),coalesce((select max(13) from t1 where t1.c in (select max(e) from t1 union select count(*) from t1)),t1.b)) from t1 union select -t1.e from t1) then 13 when t1.f in ( -f, -(f),c) then 19 else f end in (select t1.a from t1 union select (t1.c) from t1)) then (abs(19)/abs(t1.b)) when (e in (b,11,19)) and t1.a<c then 19 else a end between d and 11))}
+} {-5056}
+do_test randexpr-2.1417 {
+ db eval {SELECT case when t1.d in (select case when exists(select 1 from t1 where 13>19) then -d when ~c in (select min(e) from t1 union select cast(avg(case when c not between b and t1.a then b else 13-e+t1.e end) AS integer) from t1) then 13-coalesce((select max(coalesce((select max(19) from t1 where (17=a)),13)) from t1 where t1.a>=c),a) else t1.d end*(t1.c) from t1 union select (11) from t1) then a when b not in (e,t1.f,13) then t1.f else 13 end FROM t1 WHERE 13<>e or t1.a in (select f from t1 union select f from t1)}
+} {600}
+do_test randexpr-2.1418 {
+ db eval {SELECT case when t1.d in (select case when exists(select 1 from t1 where 13>19) then -d when ~c in (select min(e) from t1 union select cast(avg(case when c not between b and t1.a then b else 13-e+t1.e end) AS integer) from t1) then 13-coalesce((select max(coalesce((select max(19) from t1 where (17=a)),13)) from t1 where t1.a>=c),a) else t1.d end*(t1.c) from t1 union select (11) from t1) then a when b not in (e,t1.f,13) then t1.f else 13 end FROM t1 WHERE NOT (13<>e or t1.a in (select f from t1 union select f from t1))}
+} {}
+do_test randexpr-2.1419 {
+ db eval {SELECT 17-(select case max(t1.f*~case when 17>=b then t1.d else t1.a end) when (count(distinct t1.c)) then count(distinct t1.d+~13*19) else -min((select +case abs(count(*)) when abs(+count(*)) then ~case count(distinct a) when max(t1.c) then max(t1.c) else min(t1.f) end+max(17) else count(*) end from t1))- -cast(avg(f) AS integer)-min(a) end from t1) FROM t1 WHERE (select count(*) from t1) in (select abs(min(coalesce((select t1.d from t1 where coalesce((select max((t1.d)) from t1 where not b+t1.e*(select min(t1.a+t1.e) from t1)<=(abs(t1.d)/abs(t1.c))+t1.d),f*17+d+case when f between e and d and t1.c= -c then ~13 when b not between 11 and e then (11) else e end+t1.d)=13),t1.e))) from t1 union select (cast(avg(b) AS integer)) from t1)}
+} {}
+do_test randexpr-2.1420 {
+ db eval {SELECT 17-(select case max(t1.f*~case when 17>=b then t1.d else t1.a end) when (count(distinct t1.c)) then count(distinct t1.d+~13*19) else -min((select +case abs(count(*)) when abs(+count(*)) then ~case count(distinct a) when max(t1.c) then max(t1.c) else min(t1.f) end+max(17) else count(*) end from t1))- -cast(avg(f) AS integer)-min(a) end from t1) FROM t1 WHERE NOT ((select count(*) from t1) in (select abs(min(coalesce((select t1.d from t1 where coalesce((select max((t1.d)) from t1 where not b+t1.e*(select min(t1.a+t1.e) from t1)<=(abs(t1.d)/abs(t1.c))+t1.d),f*17+d+case when f between e and d and t1.c= -c then ~13 when b not between 11 and e then (11) else e end+t1.d)=13),t1.e))) from t1 union select (cast(avg(b) AS integer)) from t1))}
+} {-1067}
+do_test randexpr-2.1421 {
+ db eval {SELECT case when +coalesce((select 19 from t1 where c between f and 13),t1.f)<>t1.c*t1.d then coalesce((select max(d) from t1 where t1.d between t1.a and t1.a),t1.f-f)-(13 | case when 11 in (select abs(max(t1.b)*cast(avg(t1.c) AS integer))+count(*) from t1 union select count(distinct b) from t1) and t1.a not in (b,t1.a,e) or a not in (e,19,(t1.e)) then t1.b else 17+t1.a end*t1.a) when 13 in (select e from t1 union select c from t1) then a else e end FROM t1 WHERE (select -count(*) from t1)*case when not coalesce((select max(11) from t1 where t1.f<>a),t1.a)<>b then c else ~case when not 19+13-t1.d=t1.d or c>c or (t1.a=t1.d) or 13>=a then a when t1.c not between 13 and 17 then (abs(13+t1.d-t1.a)/abs(b)) else d end end+a | 11<=e}
+} {-20013}
+do_test randexpr-2.1422 {
+ db eval {SELECT case when +coalesce((select 19 from t1 where c between f and 13),t1.f)<>t1.c*t1.d then coalesce((select max(d) from t1 where t1.d between t1.a and t1.a),t1.f-f)-(13 | case when 11 in (select abs(max(t1.b)*cast(avg(t1.c) AS integer))+count(*) from t1 union select count(distinct b) from t1) and t1.a not in (b,t1.a,e) or a not in (e,19,(t1.e)) then t1.b else 17+t1.a end*t1.a) when 13 in (select e from t1 union select c from t1) then a else e end FROM t1 WHERE NOT ((select -count(*) from t1)*case when not coalesce((select max(11) from t1 where t1.f<>a),t1.a)<>b then c else ~case when not 19+13-t1.d=t1.d or c>c or (t1.a=t1.d) or 13>=a then a when t1.c not between 13 and 17 then (abs(13+t1.d-t1.a)/abs(b)) else d end end+a | 11<=e)}
+} {}
+do_test randexpr-2.1423 {
+ db eval {SELECT case when +coalesce((select 19 from t1 where c between f and 13),t1.f)<>t1.c*t1.d then coalesce((select max(d) from t1 where t1.d between t1.a and t1.a),t1.f-f)-(13 & case when 11 in (select abs(max(t1.b)*cast(avg(t1.c) AS integer))+count(*) from t1 union select count(distinct b) from t1) and t1.a not in (b,t1.a,e) or a not in (e,19,(t1.e)) then t1.b else 17+t1.a end*t1.a) when 13 in (select e from t1 union select c from t1) then a else e end FROM t1 WHERE (select -count(*) from t1)*case when not coalesce((select max(11) from t1 where t1.f<>a),t1.a)<>b then c else ~case when not 19+13-t1.d=t1.d or c>c or (t1.a=t1.d) or 13>=a then a when t1.c not between 13 and 17 then (abs(13+t1.d-t1.a)/abs(b)) else d end end+a | 11<=e}
+} {0}
+do_test randexpr-2.1424 {
+ db eval {SELECT case t1.d | t1.f+(e)+case when +t1.e-d*t1.a+17-b*(abs(t1.f)/abs( -a))-case when 19>=e then ~t1.a*case when t1.e>19 and t1.f<>d then t1.a else t1.d end | b*e else 17 end+t1.a=17 then t1.c else t1.b end when 17 then t1.b else t1.b end FROM t1 WHERE case when c<=13*t1.a then 11 else -case when t1.f*e>= -((19)) then case when a>=t1.c then t1.d*e else b end else coalesce((select t1.b from t1 where 11+d-17-t1.d-t1.b not in (case d-17 when f then t1.d else t1.b end,e,t1.c)),t1.c) end*19 end<>b}
+} {200}
+do_test randexpr-2.1425 {
+ db eval {SELECT case t1.d | t1.f+(e)+case when +t1.e-d*t1.a+17-b*(abs(t1.f)/abs( -a))-case when 19>=e then ~t1.a*case when t1.e>19 and t1.f<>d then t1.a else t1.d end | b*e else 17 end+t1.a=17 then t1.c else t1.b end when 17 then t1.b else t1.b end FROM t1 WHERE NOT (case when c<=13*t1.a then 11 else -case when t1.f*e>= -((19)) then case when a>=t1.c then t1.d*e else b end else coalesce((select t1.b from t1 where 11+d-17-t1.d-t1.b not in (case d-17 when f then t1.d else t1.b end,e,t1.c)),t1.c) end*19 end<>b)}
+} {}
+do_test randexpr-2.1426 {
+ db eval {SELECT case t1.d & t1.f+(e)+case when +t1.e-d*t1.a+17-b*(abs(t1.f)/abs( -a))-case when 19>=e then ~t1.a*case when t1.e>19 and t1.f<>d then t1.a else t1.d end & b*e else 17 end+t1.a=17 then t1.c else t1.b end when 17 then t1.b else t1.b end FROM t1 WHERE case when c<=13*t1.a then 11 else -case when t1.f*e>= -((19)) then case when a>=t1.c then t1.d*e else b end else coalesce((select t1.b from t1 where 11+d-17-t1.d-t1.b not in (case d-17 when f then t1.d else t1.b end,e,t1.c)),t1.c) end*19 end<>b}
+} {200}
+do_test randexpr-2.1427 {
+ db eval {SELECT (coalesce((select max(~t1.d*19*t1.f) from t1 where (abs(17)/abs(t1.f-case when not exists(select 1 from t1 where case when a in (f,t1.a,c) then c when t1.a not in (13,t1.c,a) then e else t1.a end in (select abs(abs(min(t1.e))) from t1 union select cast(avg(11) AS integer) from t1)) or c<a then t1.f else a+d end-11))<>13 or t1.e in (e,t1.c,d)),t1.e) | 13)-d*e FROM t1 WHERE 11 in (select max(+(select max(d | b) from t1)*17-e) from t1 union select (cast(avg(+a-+((coalesce((select t1.e from t1 where exists(select 1 from t1 where (abs( -case when coalesce((select max(b-17) from t1 where not exists(select 1 from t1 where t1.f not between a and 11)),t1.c) in (select t1.d from t1 union select (17) from t1) then t1.c else ( - -t1.d) end)/abs(t1.f))+11>f)),b)))*19) AS integer))-count(distinct t1.f) from t1)}
+} {}
+do_test randexpr-2.1428 {
+ db eval {SELECT (coalesce((select max(~t1.d*19*t1.f) from t1 where (abs(17)/abs(t1.f-case when not exists(select 1 from t1 where case when a in (f,t1.a,c) then c when t1.a not in (13,t1.c,a) then e else t1.a end in (select abs(abs(min(t1.e))) from t1 union select cast(avg(11) AS integer) from t1)) or c<a then t1.f else a+d end-11))<>13 or t1.e in (e,t1.c,d)),t1.e) | 13)-d*e FROM t1 WHERE NOT (11 in (select max(+(select max(d | b) from t1)*17-e) from t1 union select (cast(avg(+a-+((coalesce((select t1.e from t1 where exists(select 1 from t1 where (abs( -case when coalesce((select max(b-17) from t1 where not exists(select 1 from t1 where t1.f not between a and 11)),t1.c) in (select t1.d from t1 union select (17) from t1) then t1.c else ( - -t1.d) end)/abs(t1.f))+11>f)),b)))*19) AS integer))-count(distinct t1.f) from t1))}
+} {-4771395}
+do_test randexpr-2.1429 {
+ db eval {SELECT (coalesce((select max(~t1.d*19*t1.f) from t1 where (abs(17)/abs(t1.f-case when not exists(select 1 from t1 where case when a in (f,t1.a,c) then c when t1.a not in (13,t1.c,a) then e else t1.a end in (select abs(abs(min(t1.e))) from t1 union select cast(avg(11) AS integer) from t1)) or c<a then t1.f else a+d end-11))<>13 or t1.e in (e,t1.c,d)),t1.e) & 13)-d*e FROM t1 WHERE NOT (11 in (select max(+(select max(d | b) from t1)*17-e) from t1 union select (cast(avg(+a-+((coalesce((select t1.e from t1 where exists(select 1 from t1 where (abs( -case when coalesce((select max(b-17) from t1 where not exists(select 1 from t1 where t1.f not between a and 11)),t1.c) in (select t1.d from t1 union select (17) from t1) then t1.c else ( - -t1.d) end)/abs(t1.f))+11>f)),b)))*19) AS integer))-count(distinct t1.f) from t1))}
+} {-199992}
+do_test randexpr-2.1430 {
+ db eval {SELECT coalesce((select t1.e from t1 where +~case when d-(abs(+t1.b)/abs( -19*t1.c-(select (abs( -cast(avg((abs(d)/abs(t1.d))) AS integer))) from t1)))+11<19 then t1.a-19-a-f when not (c in (case f when t1.a then 17 else 11 end-a,t1.d, -e)) then 17 else (t1.b) end<d),t1.d) FROM t1 WHERE exists(select 1 from t1 where f not between ~17+t1.e and coalesce((select max(t1.f) from t1 where 17+19=t1.c),case when case -case when e not in (+c, - -19,t1.c) then 19 else (b)*t1.a end+t1.c when c then 19 else t1.d end<>(t1.b) then t1.d when (not exists(select 1 from t1 where t1.f<>t1.c)) then t1.b else 17 end-e)-19)}
+} {500}
+do_test randexpr-2.1431 {
+ db eval {SELECT coalesce((select t1.e from t1 where +~case when d-(abs(+t1.b)/abs( -19*t1.c-(select (abs( -cast(avg((abs(d)/abs(t1.d))) AS integer))) from t1)))+11<19 then t1.a-19-a-f when not (c in (case f when t1.a then 17 else 11 end-a,t1.d, -e)) then 17 else (t1.b) end<d),t1.d) FROM t1 WHERE NOT (exists(select 1 from t1 where f not between ~17+t1.e and coalesce((select max(t1.f) from t1 where 17+19=t1.c),case when case -case when e not in (+c, - -19,t1.c) then 19 else (b)*t1.a end+t1.c when c then 19 else t1.d end<>(t1.b) then t1.d when (not exists(select 1 from t1 where t1.f<>t1.c)) then t1.b else 17 end-e)-19))}
+} {}
+do_test randexpr-2.1432 {
+ db eval {SELECT case when (abs(17)/abs(t1.e))<t1.b then t1.d when (select count(distinct coalesce((select d from t1 where exists(select 1 from t1 where 19<(select abs(max(t1.b)) from t1)*case when t1.e>=case when (exists(select 1 from t1 where not exists(select 1 from t1 where t1.f<>19))) then coalesce((select 11 from t1 where not exists(select 1 from t1 where t1.e not in ( -t1.d,(b),t1.d))),t1.a)+t1.f*11 else t1.a end then b else e end)),17)) from t1) not in (13,e,17) then t1.e else 11 end FROM t1 WHERE not (t1.e<>coalesce((select (case t1.c when (coalesce((select 19 from t1 where (case when not exists(select 1 from t1 where e not in (c,e,t1.f)) then t1.f | t1.a else t1.a end in (d,19,t1.a)) or t1.f<=t1.c),+13))*t1.b-t1.d then -t1.c else b end) from t1 where 17<f), -e) or ((a)<=a)) or e<t1.e and -(13) between 19 and 19}
+} {}
+do_test randexpr-2.1433 {
+ db eval {SELECT case when (abs(17)/abs(t1.e))<t1.b then t1.d when (select count(distinct coalesce((select d from t1 where exists(select 1 from t1 where 19<(select abs(max(t1.b)) from t1)*case when t1.e>=case when (exists(select 1 from t1 where not exists(select 1 from t1 where t1.f<>19))) then coalesce((select 11 from t1 where not exists(select 1 from t1 where t1.e not in ( -t1.d,(b),t1.d))),t1.a)+t1.f*11 else t1.a end then b else e end)),17)) from t1) not in (13,e,17) then t1.e else 11 end FROM t1 WHERE NOT (not (t1.e<>coalesce((select (case t1.c when (coalesce((select 19 from t1 where (case when not exists(select 1 from t1 where e not in (c,e,t1.f)) then t1.f | t1.a else t1.a end in (d,19,t1.a)) or t1.f<=t1.c),+13))*t1.b-t1.d then -t1.c else b end) from t1 where 17<f), -e) or ((a)<=a)) or e<t1.e and -(13) between 19 and 19)}
+} {400}
+do_test randexpr-2.1434 {
+ db eval {SELECT (select max(t1.c) from t1) | case when d=(abs(t1.d)/abs(t1.b)) then 19 else case b when a then b+17+c-t1.d+d-a*t1.c else e+t1.f+ -(select abs(~+count(distinct case when b<d and t1.f<> -19 then e when a in (17,d,t1.f) then -t1.f else f end)+count(*)-max(t1.f) | count(distinct t1.a) | cast(avg(t1.c) AS integer)) | -max(a) from t1) end end FROM t1 WHERE a | t1.c in (select f from t1 union select case -t1.c when (abs(c | t1.c)/abs(17)) then (abs(t1.e)/abs(t1.c))+~19 else coalesce((select b from t1 where 11<=case d+coalesce((select max((select ( -(cast(avg(17) AS integer)))*max(t1.e)-max(t1.d)*cast(avg(t1.e) AS integer) from t1)) from t1 where (abs(case t1.f when 19 then b else t1.c end)/abs(t1.e))=b),d)*t1.f when -t1.b then t1.d else 19 end),a) end+d+e from t1)}
+} {}
+do_test randexpr-2.1435 {
+ db eval {SELECT (select max(t1.c) from t1) | case when d=(abs(t1.d)/abs(t1.b)) then 19 else case b when a then b+17+c-t1.d+d-a*t1.c else e+t1.f+ -(select abs(~+count(distinct case when b<d and t1.f<> -19 then e when a in (17,d,t1.f) then -t1.f else f end)+count(*)-max(t1.f) | count(distinct t1.a) | cast(avg(t1.c) AS integer)) | -max(a) from t1) end end FROM t1 WHERE NOT (a | t1.c in (select f from t1 union select case -t1.c when (abs(c | t1.c)/abs(17)) then (abs(t1.e)/abs(t1.c))+~19 else coalesce((select b from t1 where 11<=case d+coalesce((select max((select ( -(cast(avg(17) AS integer)))*max(t1.e)-max(t1.d)*cast(avg(t1.e) AS integer) from t1)) from t1 where (abs(case t1.f when 19 then b else t1.c end)/abs(t1.e))=b),d)*t1.f when -t1.b then t1.d else 19 end),a) end+d+e from t1))}
+} {1391}
+do_test randexpr-2.1436 {
+ db eval {SELECT (select max(t1.c) from t1) & case when d=(abs(t1.d)/abs(t1.b)) then 19 else case b when a then b+17+c-t1.d+d-a*t1.c else e+t1.f+ -(select abs(~+count(distinct case when b<d and t1.f<> -19 then e when a in (17,d,t1.f) then -t1.f else f end)+count(*)-max(t1.f) & count(distinct t1.a) & cast(avg(t1.c) AS integer)) & -max(a) from t1) end end FROM t1 WHERE NOT (a | t1.c in (select f from t1 union select case -t1.c when (abs(c | t1.c)/abs(17)) then (abs(t1.e)/abs(t1.c))+~19 else coalesce((select b from t1 where 11<=case d+coalesce((select max((select ( -(cast(avg(17) AS integer)))*max(t1.e)-max(t1.d)*cast(avg(t1.e) AS integer) from t1)) from t1 where (abs(case t1.f when 19 then b else t1.c end)/abs(t1.e))=b),d)*t1.f when -t1.b then t1.d else 19 end),a) end+d+e from t1))}
+} {12}
+do_test randexpr-2.1437 {
+ db eval {SELECT case e*case when case coalesce((select max(13) from t1 where exists(select 1 from t1 where t1.a in (17,b,17))),t1.e)-t1.c when c then 19 else -t1.d end+17 in (t1.d,c,11) or b<= -( - -a) then ~(a) when f in (select case case (max(e)) when count(*) then max(17) else (max(17)) end+count(distinct e)- -count(distinct d) when -count(*) then -count(distinct d) else ((min(t1.f))) end from t1 union select min( -19) from t1) then c else (13) end when b then t1.b else f end FROM t1 WHERE t1.b<t1.e}
+} {600}
+do_test randexpr-2.1438 {
+ db eval {SELECT case e*case when case coalesce((select max(13) from t1 where exists(select 1 from t1 where t1.a in (17,b,17))),t1.e)-t1.c when c then 19 else -t1.d end+17 in (t1.d,c,11) or b<= -( - -a) then ~(a) when f in (select case case (max(e)) when count(*) then max(17) else (max(17)) end+count(distinct e)- -count(distinct d) when -count(*) then -count(distinct d) else ((min(t1.f))) end from t1 union select min( -19) from t1) then c else (13) end when b then t1.b else f end FROM t1 WHERE NOT (t1.b<t1.e)}
+} {}
+do_test randexpr-2.1439 {
+ db eval {SELECT case when d in (c,t1.a*19,+++case when exists(select 1 from t1 where case 17 when ~t1.b then f-e*~b-17+ -t1.c else c end<>17 or (t1.c in (19,c,a))) then 13 else c end-11+11*11) then t1.e when (11)<13 then - -t1.c else t1.d end FROM t1 WHERE ((t1.c+17 not between case b*(11-coalesce((select max(t1.a) from t1 where ~case when (not t1.d*17=f) then t1.c-13+c else t1.d end+t1.c>=(b)),b)*e) when t1.f then b else f end-f- -17 and d or t1.d not in (t1.c,11,b)))}
+} {300}
+do_test randexpr-2.1440 {
+ db eval {SELECT case when d in (c,t1.a*19,+++case when exists(select 1 from t1 where case 17 when ~t1.b then f-e*~b-17+ -t1.c else c end<>17 or (t1.c in (19,c,a))) then 13 else c end-11+11*11) then t1.e when (11)<13 then - -t1.c else t1.d end FROM t1 WHERE NOT (((t1.c+17 not between case b*(11-coalesce((select max(t1.a) from t1 where ~case when (not t1.d*17=f) then t1.c-13+c else t1.d end+t1.c>=(b)),b)*e) when t1.f then b else f end-f- -17 and d or t1.d not in (t1.c,11,b))))}
+} {}
+do_test randexpr-2.1441 {
+ db eval {SELECT t1.e*coalesce((select 17 from t1 where (19>(abs(case coalesce((select coalesce((select ~11 from t1 where b not between (13) and b),17) from t1 where 19 not between e+b+13 and -t1.d),t1.f) when d then t1.e else t1.d end-e | f)/abs((e)))) and (t1.b<=a and 11<> - -t1.e) and t1.d<d),c) FROM t1 WHERE t1.a>t1.a | t1.c}
+} {}
+do_test randexpr-2.1442 {
+ db eval {SELECT t1.e*coalesce((select 17 from t1 where (19>(abs(case coalesce((select coalesce((select ~11 from t1 where b not between (13) and b),17) from t1 where 19 not between e+b+13 and -t1.d),t1.f) when d then t1.e else t1.d end-e | f)/abs((e)))) and (t1.b<=a and 11<> - -t1.e) and t1.d<d),c) FROM t1 WHERE NOT (t1.a>t1.a | t1.c)}
+} {150000}
+do_test randexpr-2.1443 {
+ db eval {SELECT t1.e*coalesce((select 17 from t1 where (19>(abs(case coalesce((select coalesce((select ~11 from t1 where b not between (13) and b),17) from t1 where 19 not between e+b+13 and -t1.d),t1.f) when d then t1.e else t1.d end-e & f)/abs((e)))) and (t1.b<=a and 11<> - -t1.e) and t1.d<d),c) FROM t1 WHERE NOT (t1.a>t1.a | t1.c)}
+} {150000}
+do_test randexpr-2.1444 {
+ db eval {SELECT ~coalesce((select max(t1.a) from t1 where ((t1.c)<=case 11-~t1.b++(t1.a+ -c)*t1.d-b | d when ~e then 17 else (abs(f)/abs(t1.f-t1.c)) end-19 | b-~t1.e*a-t1.b | +c)),b)*a FROM t1 WHERE not exists(select 1 from t1 where t1.a=((abs(coalesce((select coalesce((select max(+d) from t1 where not exists(select 1 from t1 where -t1.d in (select -max(13)-(min((t1.a))) from t1 union select count(distinct f) from t1)) and 11 in (select f from t1 union select 17 from t1) and a<>13),case when e>(11) then -c else d end) from t1 where e<>11 and e<d),t1.d)+t1.b)/abs(17))* -19)-b or t1.e not in (a,11,t1.f) or not exists(select 1 from t1 where (exists(select 1 from t1 where -11=b and (d)<>t1.e))))}
+} {}
+do_test randexpr-2.1445 {
+ db eval {SELECT ~coalesce((select max(t1.a) from t1 where ((t1.c)<=case 11-~t1.b++(t1.a+ -c)*t1.d-b | d when ~e then 17 else (abs(f)/abs(t1.f-t1.c)) end-19 | b-~t1.e*a-t1.b | +c)),b)*a FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.a=((abs(coalesce((select coalesce((select max(+d) from t1 where not exists(select 1 from t1 where -t1.d in (select -max(13)-(min((t1.a))) from t1 union select count(distinct f) from t1)) and 11 in (select f from t1 union select 17 from t1) and a<>13),case when e>(11) then -c else d end) from t1 where e<>11 and e<d),t1.d)+t1.b)/abs(17))* -19)-b or t1.e not in (a,11,t1.f) or not exists(select 1 from t1 where (exists(select 1 from t1 where -11=b and (d)<>t1.e)))))}
+} {-20100}
+do_test randexpr-2.1446 {
+ db eval {SELECT ~coalesce((select max(t1.a) from t1 where ((t1.c)<=case 11-~t1.b++(t1.a+ -c)*t1.d-b & d when ~e then 17 else (abs(f)/abs(t1.f-t1.c)) end-19 & b-~t1.e*a-t1.b & +c)),b)*a FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.a=((abs(coalesce((select coalesce((select max(+d) from t1 where not exists(select 1 from t1 where -t1.d in (select -max(13)-(min((t1.a))) from t1 union select count(distinct f) from t1)) and 11 in (select f from t1 union select 17 from t1) and a<>13),case when e>(11) then -c else d end) from t1 where e<>11 and e<d),t1.d)+t1.b)/abs(17))* -19)-b or t1.e not in (a,11,t1.f) or not exists(select 1 from t1 where (exists(select 1 from t1 where -11=b and (d)<>t1.e)))))}
+} {-20100}
+do_test randexpr-2.1447 {
+ db eval {SELECT (select count(distinct ~(((abs(b-a)/abs(case (select min((select case cast(avg(11+t1.e) AS integer) when case min( -~coalesce((select 13 from t1 where case t1.e when f then d else 17 end>=b),e)) when case max(t1.b) when (~ -count(*)+(( -max( -t1.a)))-(count(*))) then -count(distinct (t1.c)) else min( -t1.e) end then count(*) else cast(avg( -(e)) AS integer) end then cast(avg(13) AS integer) else max(17) end from t1)) from t1) when 13 then c else (d) end))))) from t1)*t1.b FROM t1 WHERE not t1.c>=t1.b}
+} {}
+do_test randexpr-2.1448 {
+ db eval {SELECT (select count(distinct ~(((abs(b-a)/abs(case (select min((select case cast(avg(11+t1.e) AS integer) when case min( -~coalesce((select 13 from t1 where case t1.e when f then d else 17 end>=b),e)) when case max(t1.b) when (~ -count(*)+(( -max( -t1.a)))-(count(*))) then -count(distinct (t1.c)) else min( -t1.e) end then count(*) else cast(avg( -(e)) AS integer) end then cast(avg(13) AS integer) else max(17) end from t1)) from t1) when 13 then c else (d) end))))) from t1)*t1.b FROM t1 WHERE NOT (not t1.c>=t1.b)}
+} {200}
+do_test randexpr-2.1449 {
+ db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where t1.b in (select e from t1 union select t1.e from t1)),t1.a)) from t1 where case when t1.d=case when d not between t1.a and case when not t1.c in ((t1.e),a,t1.c) then 19 | t1.c when a not between 19 and b then (19) else 13 end then t1.d else b end-11 and not t1.f=t1.c or 19 not in (t1.d,c, -t1.f) and 17< -t1.d then e when t1.b not between 17 and t1.b then f else d end<11),t1.c)*f FROM t1 WHERE t1.b<=(coalesce((select c from t1 where e in (t1.a,t1.c,case when 17 not between 19 and (19)-t1.a-(abs(coalesce((select d from t1 where case (t1.b+e*b*t1.c) when 13 then t1.b else 19 end<>19),17))/abs(a))*t1.a then 17 when exists(select 1 from t1 where ( -e)=a) or 13>=d then 17 else t1.f end)),c))}
+} {180000}
+do_test randexpr-2.1450 {
+ db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where t1.b in (select e from t1 union select t1.e from t1)),t1.a)) from t1 where case when t1.d=case when d not between t1.a and case when not t1.c in ((t1.e),a,t1.c) then 19 | t1.c when a not between 19 and b then (19) else 13 end then t1.d else b end-11 and not t1.f=t1.c or 19 not in (t1.d,c, -t1.f) and 17< -t1.d then e when t1.b not between 17 and t1.b then f else d end<11),t1.c)*f FROM t1 WHERE NOT (t1.b<=(coalesce((select c from t1 where e in (t1.a,t1.c,case when 17 not between 19 and (19)-t1.a-(abs(coalesce((select d from t1 where case (t1.b+e*b*t1.c) when 13 then t1.b else 19 end<>19),17))/abs(a))*t1.a then 17 when exists(select 1 from t1 where ( -e)=a) or 13>=d then 17 else t1.f end)),c)))}
+} {}
+do_test randexpr-2.1451 {
+ db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where t1.b in (select e from t1 union select t1.e from t1)),t1.a)) from t1 where case when t1.d=case when d not between t1.a and case when not t1.c in ((t1.e),a,t1.c) then 19 & t1.c when a not between 19 and b then (19) else 13 end then t1.d else b end-11 and not t1.f=t1.c or 19 not in (t1.d,c, -t1.f) and 17< -t1.d then e when t1.b not between 17 and t1.b then f else d end<11),t1.c)*f FROM t1 WHERE t1.b<=(coalesce((select c from t1 where e in (t1.a,t1.c,case when 17 not between 19 and (19)-t1.a-(abs(coalesce((select d from t1 where case (t1.b+e*b*t1.c) when 13 then t1.b else 19 end<>19),17))/abs(a))*t1.a then 17 when exists(select 1 from t1 where ( -e)=a) or 13>=d then 17 else t1.f end)),c))}
+} {180000}
+do_test randexpr-2.1452 {
+ db eval {SELECT (d)+(select -abs(+cast(avg((select max((coalesce((select d from t1 where case when 13>=e then t1.c else 19 end>=d),coalesce((select 19-(select count(distinct 19 | (abs(19)/abs(~13))) from t1) | t1.d from t1 where coalesce((select max(11) from t1 where t1.a in (select t1.d from t1 union select c from t1)),19)>t1.d),e)+t1.b))) from t1)) AS integer)+abs( -max(b))) from t1) FROM t1 WHERE c-t1.c not between t1.c and +case when +case -case when 17 not in (17,(e),t1.c) then a else 19 end-13 when t1.e then b else 13 end>19 or 17 in (select b from t1 union select t1.c from t1) then case c when t1.c then d else c end when not t1.f in (select -cast(avg(a) AS integer)*count(distinct (17))+min(f)* - - -cast(avg(b) AS integer) from t1 union select (count(*)) from t1) then d else a end}
+} {-500}
+do_test randexpr-2.1453 {
+ db eval {SELECT (d)+(select -abs(+cast(avg((select max((coalesce((select d from t1 where case when 13>=e then t1.c else 19 end>=d),coalesce((select 19-(select count(distinct 19 | (abs(19)/abs(~13))) from t1) | t1.d from t1 where coalesce((select max(11) from t1 where t1.a in (select t1.d from t1 union select c from t1)),19)>t1.d),e)+t1.b))) from t1)) AS integer)+abs( -max(b))) from t1) FROM t1 WHERE NOT (c-t1.c not between t1.c and +case when +case -case when 17 not in (17,(e),t1.c) then a else 19 end-13 when t1.e then b else 13 end>19 or 17 in (select b from t1 union select t1.c from t1) then case c when t1.c then d else c end when not t1.f in (select -cast(avg(a) AS integer)*count(distinct (17))+min(f)* - - -cast(avg(b) AS integer) from t1 union select (count(*)) from t1) then d else a end)}
+} {}
+do_test randexpr-2.1454 {
+ db eval {SELECT (d)+(select -abs(+cast(avg((select max((coalesce((select d from t1 where case when 13>=e then t1.c else 19 end>=d),coalesce((select 19-(select count(distinct 19 & (abs(19)/abs(~13))) from t1) & t1.d from t1 where coalesce((select max(11) from t1 where t1.a in (select t1.d from t1 union select c from t1)),19)>t1.d),e)+t1.b))) from t1)) AS integer)+abs( -max(b))) from t1) FROM t1 WHERE c-t1.c not between t1.c and +case when +case -case when 17 not in (17,(e),t1.c) then a else 19 end-13 when t1.e then b else 13 end>19 or 17 in (select b from t1 union select t1.c from t1) then case c when t1.c then d else c end when not t1.f in (select -cast(avg(a) AS integer)*count(distinct (17))+min(f)* - - -cast(avg(b) AS integer) from t1 union select (count(*)) from t1) then d else a end}
+} {-500}
+do_test randexpr-2.1455 {
+ db eval {SELECT case when 19 in (case when coalesce((select max(case when e*t1.b in (coalesce((select t1.a from t1 where (abs(f)/abs(coalesce((select f from t1 where t1.f in (a,b,t1.d)),13))) in (b,b,11)),c),t1.a,17) then b else d end) from t1 where f>=13 and a>=17 and not exists(select 1 from t1 where (b<>f))), -t1.c) between d and 11 then d else t1.f end,t1.c,11) then 13 else 17 end FROM t1 WHERE t1.d in (select (abs(t1.a)/abs(t1.f)) from t1 union select e from t1) and ((b*coalesce((select -11 from t1 where (coalesce((select max( -t1.e+ -coalesce((select d from t1 where t1.c<= - -t1.d),t1.c)) from t1 where b in (select -count(distinct d)+count(distinct d)- -((min(e))) from t1 union select count(*) from t1)),(t1.e))-19*d<>t1.e)),a)*t1.f)=b)}
+} {}
+do_test randexpr-2.1456 {
+ db eval {SELECT case when 19 in (case when coalesce((select max(case when e*t1.b in (coalesce((select t1.a from t1 where (abs(f)/abs(coalesce((select f from t1 where t1.f in (a,b,t1.d)),13))) in (b,b,11)),c),t1.a,17) then b else d end) from t1 where f>=13 and a>=17 and not exists(select 1 from t1 where (b<>f))), -t1.c) between d and 11 then d else t1.f end,t1.c,11) then 13 else 17 end FROM t1 WHERE NOT (t1.d in (select (abs(t1.a)/abs(t1.f)) from t1 union select e from t1) and ((b*coalesce((select -11 from t1 where (coalesce((select max( -t1.e+ -coalesce((select d from t1 where t1.c<= - -t1.d),t1.c)) from t1 where b in (select -count(distinct d)+count(distinct d)- -((min(e))) from t1 union select count(*) from t1)),(t1.e))-19*d<>t1.e)),a)*t1.f)=b))}
+} {17}
+do_test randexpr-2.1457 {
+ db eval {SELECT coalesce((select max((select count(*) from t1)) from t1 where coalesce((select max(t1.a-coalesce((select t1.d+case when exists(select 1 from t1 where exists(select 1 from t1 where t1.f between t1.a and f)) or d | b between 19 and 19 then f+17 else (t1.b) end from t1 where t1.e not between -t1.d and (19)),(17))) from t1 where not exists(select 1 from t1 where 19 between t1.b and 13 or t1.b>t1.c) or 19>=19),b) between 13 and f), -t1.a) FROM t1 WHERE exists(select 1 from t1 where +t1.f+t1.e<(abs(t1.b)/abs( -f*e))) or case t1.c when case when 19 not between 17 and case when t1.e<>e then t1.b when not exists(select 1 from t1 where coalesce((select max(b) from t1 where (e<t1.a)),e)>t1.d or (t1.d<>t1.e)) then t1.c else 17 end then t1.c when e<>b then 17 else e end then t1.d else t1.e end between d and b}
+} {}
+do_test randexpr-2.1458 {
+ db eval {SELECT coalesce((select max((select count(*) from t1)) from t1 where coalesce((select max(t1.a-coalesce((select t1.d+case when exists(select 1 from t1 where exists(select 1 from t1 where t1.f between t1.a and f)) or d | b between 19 and 19 then f+17 else (t1.b) end from t1 where t1.e not between -t1.d and (19)),(17))) from t1 where not exists(select 1 from t1 where 19 between t1.b and 13 or t1.b>t1.c) or 19>=19),b) between 13 and f), -t1.a) FROM t1 WHERE NOT (exists(select 1 from t1 where +t1.f+t1.e<(abs(t1.b)/abs( -f*e))) or case t1.c when case when 19 not between 17 and case when t1.e<>e then t1.b when not exists(select 1 from t1 where coalesce((select max(b) from t1 where (e<t1.a)),e)>t1.d or (t1.d<>t1.e)) then t1.c else 17 end then t1.c when e<>b then 17 else e end then t1.d else t1.e end between d and b)}
+} {-100}
+do_test randexpr-2.1459 {
+ db eval {SELECT coalesce((select max((select count(*) from t1)) from t1 where coalesce((select max(t1.a-coalesce((select t1.d+case when exists(select 1 from t1 where exists(select 1 from t1 where t1.f between t1.a and f)) or d & b between 19 and 19 then f+17 else (t1.b) end from t1 where t1.e not between -t1.d and (19)),(17))) from t1 where not exists(select 1 from t1 where 19 between t1.b and 13 or t1.b>t1.c) or 19>=19),b) between 13 and f), -t1.a) FROM t1 WHERE NOT (exists(select 1 from t1 where +t1.f+t1.e<(abs(t1.b)/abs( -f*e))) or case t1.c when case when 19 not between 17 and case when t1.e<>e then t1.b when not exists(select 1 from t1 where coalesce((select max(b) from t1 where (e<t1.a)),e)>t1.d or (t1.d<>t1.e)) then t1.c else 17 end then t1.c when e<>b then 17 else e end then t1.d else t1.e end between d and b)}
+} {-100}
+do_test randexpr-2.1460 {
+ db eval {SELECT case when not case 11 when t1.e*coalesce((select max(t1.b) from t1 where (abs(t1.c)/abs(~11)) not between coalesce((select max((abs(a)/abs(c))) from t1 where t1.b>=t1.a or b= -e),t1.f) and e and c not in (t1.a,t1.f,t1.c) and not (a)<t1.b or t1.b not between b and t1.a),17)*11+b+f then f else 17 end not between t1.f and a then b else t1.a end FROM t1 WHERE not exists(select 1 from t1 where a in (select coalesce((select max(13) from t1 where t1.e not in (t1.d,case when t1.b not in ((select (count(distinct case when -t1.a not between a and t1.f then t1.c when 13 not in (t1.a,t1.b,d) then f else 19 end)) from t1),b,t1.f) then c when 11 in (select min(a)+max(19) from t1 union select cast(avg(11) AS integer) from t1) and t1.c in (f,13,t1.e) or a>17 then c else a end | t1.b,a) or not (t1.d<11)),d) from t1 union select t1.a from t1) and f in (select b from t1 union select b from t1))}
+} {100}
+do_test randexpr-2.1461 {
+ db eval {SELECT case when not case 11 when t1.e*coalesce((select max(t1.b) from t1 where (abs(t1.c)/abs(~11)) not between coalesce((select max((abs(a)/abs(c))) from t1 where t1.b>=t1.a or b= -e),t1.f) and e and c not in (t1.a,t1.f,t1.c) and not (a)<t1.b or t1.b not between b and t1.a),17)*11+b+f then f else 17 end not between t1.f and a then b else t1.a end FROM t1 WHERE NOT (not exists(select 1 from t1 where a in (select coalesce((select max(13) from t1 where t1.e not in (t1.d,case when t1.b not in ((select (count(distinct case when -t1.a not between a and t1.f then t1.c when 13 not in (t1.a,t1.b,d) then f else 19 end)) from t1),b,t1.f) then c when 11 in (select min(a)+max(19) from t1 union select cast(avg(11) AS integer) from t1) and t1.c in (f,13,t1.e) or a>17 then c else a end | t1.b,a) or not (t1.d<11)),d) from t1 union select t1.a from t1) and f in (select b from t1 union select b from t1)))}
+} {}
+do_test randexpr-2.1462 {
+ db eval {SELECT case when case when coalesce((select max(case when ((a<=case t1.a+t1.a when t1.d then -c else b end or t1.b<>e)) then 17 else 19*19*a end*13) from t1 where d<>t1.d),d)<=a or 11<=t1.e then t1.c when 17<11 then 17 else e end<=t1.a then t1.d when e= -e then t1.d else 19 end FROM t1 WHERE t1.e<=t1.a or (abs(+a+coalesce((select max(t1.b) from t1 where (select ~count(distinct 17) from t1)-b in (select t1.b+t1.b from t1 union select 19 from t1)), -11))/abs(case when not exists(select 1 from t1 where t1.d not between 17 and c- -c+e) or t1.e>t1.f then t1.d when t1.d not in (17,e,d) then a else 17 end)) in (c,d,11)}
+} {}
+do_test randexpr-2.1463 {
+ db eval {SELECT case when case when coalesce((select max(case when ((a<=case t1.a+t1.a when t1.d then -c else b end or t1.b<>e)) then 17 else 19*19*a end*13) from t1 where d<>t1.d),d)<=a or 11<=t1.e then t1.c when 17<11 then 17 else e end<=t1.a then t1.d when e= -e then t1.d else 19 end FROM t1 WHERE NOT (t1.e<=t1.a or (abs(+a+coalesce((select max(t1.b) from t1 where (select ~count(distinct 17) from t1)-b in (select t1.b+t1.b from t1 union select 19 from t1)), -11))/abs(case when not exists(select 1 from t1 where t1.d not between 17 and c- -c+e) or t1.e>t1.f then t1.d when t1.d not in (17,e,d) then a else 17 end)) in (c,d,11))}
+} {19}
+do_test randexpr-2.1464 {
+ db eval {SELECT ~case when t1.e<=t1.a then b else (11) end+(select -((cast(avg(coalesce((select a from t1 where (select cast(avg(t1.d) AS integer) | case case min((t1.e)) when cast(avg(t1.b) AS integer) then max(t1.c) else max(19) end*count(*) when -count(distinct e) then count(*) else max( - -17) end from t1) not between c and -t1.e-f+f),11)-11) AS integer)))*max(e) from t1)+e* - -a-t1.d*e FROM t1 WHERE coalesce((select max(case when 11 between d and d then e | b else case (select (case count(distinct coalesce((select -coalesce((select max(t1.f) from t1 where t1.b in (select 11 from t1 union select 19 from t1)),t1.e) from t1 where 13<>17),17)) when (max( -t1.e)) then max(17)+max(11) else ((count(*))) end)*(count(*)) from t1) when 11 then -13+19 else t1.e end end) from t1 where ((t1.a not between d and -t1.c))),t1.a)<11}
+} {}
+do_test randexpr-2.1465 {
+ db eval {SELECT ~case when t1.e<=t1.a then b else (11) end+(select -((cast(avg(coalesce((select a from t1 where (select cast(avg(t1.d) AS integer) | case case min((t1.e)) when cast(avg(t1.b) AS integer) then max(t1.c) else max(19) end*count(*) when -count(distinct e) then count(*) else max( - -17) end from t1) not between c and -t1.e-f+f),11)-11) AS integer)))*max(e) from t1)+e* - -a-t1.d*e FROM t1 WHERE NOT (coalesce((select max(case when 11 between d and d then e | b else case (select (case count(distinct coalesce((select -coalesce((select max(t1.f) from t1 where t1.b in (select 11 from t1 union select 19 from t1)),t1.e) from t1 where 13<>17),17)) when (max( -t1.e)) then max(17)+max(11) else ((count(*))) end)*(count(*)) from t1) when 11 then -13+19 else t1.e end end) from t1 where ((t1.a not between d and -t1.c))),t1.a)<11)}
+} {-194512}
+do_test randexpr-2.1466 {
+ db eval {SELECT ~case when t1.e<=t1.a then b else (11) end+(select -((cast(avg(coalesce((select a from t1 where (select cast(avg(t1.d) AS integer) & case case min((t1.e)) when cast(avg(t1.b) AS integer) then max(t1.c) else max(19) end*count(*) when -count(distinct e) then count(*) else max( - -17) end from t1) not between c and -t1.e-f+f),11)-11) AS integer)))*max(e) from t1)+e* - -a-t1.d*e FROM t1 WHERE NOT (coalesce((select max(case when 11 between d and d then e | b else case (select (case count(distinct coalesce((select -coalesce((select max(t1.f) from t1 where t1.b in (select 11 from t1 union select 19 from t1)),t1.e) from t1 where 13<>17),17)) when (max( -t1.e)) then max(17)+max(11) else ((count(*))) end)*(count(*)) from t1) when 11 then -13+19 else t1.e end end) from t1 where ((t1.a not between d and -t1.c))),t1.a)<11)}
+} {-194512}
+do_test randexpr-2.1467 {
+ db eval {SELECT t1.e*~13-t1.a-~case when (abs(t1.a)/abs(coalesce((select max(t1.a) from t1 where e not between f and e-t1.b+13),case when (a in (select ( -c) from t1 union select 11 from t1) or exists(select 1 from t1 where 11 between f and t1.f)) then t1.b-a else -t1.e end)+13*t1.f)) | 13<t1.a then t1.f when (t1.a in (select 19 from t1 union select c from t1)) then a else -19 end FROM t1 WHERE exists(select 1 from t1 where t1.c*coalesce((select f from t1 where - -f+b-(select min(t1.b) from t1) not in (c,17-t1.b*t1.a,t1.c)),case when (select abs(count(*)) from t1)<> -19-a then (a)-coalesce((select max(case when a in (13,t1.b,11) then t1.b else (13) end) from t1 where not exists(select 1 from t1 where t1.b>=b)),t1.c) else -13 end)*(a)<17)}
+} {}
+do_test randexpr-2.1468 {
+ db eval {SELECT t1.e*~13-t1.a-~case when (abs(t1.a)/abs(coalesce((select max(t1.a) from t1 where e not between f and e-t1.b+13),case when (a in (select ( -c) from t1 union select 11 from t1) or exists(select 1 from t1 where 11 between f and t1.f)) then t1.b-a else -t1.e end)+13*t1.f)) | 13<t1.a then t1.f when (t1.a in (select 19 from t1 union select c from t1)) then a else -19 end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.c*coalesce((select f from t1 where - -f+b-(select min(t1.b) from t1) not in (c,17-t1.b*t1.a,t1.c)),case when (select abs(count(*)) from t1)<> -19-a then (a)-coalesce((select max(case when a in (13,t1.b,11) then t1.b else (13) end) from t1 where not exists(select 1 from t1 where t1.b>=b)),t1.c) else -13 end)*(a)<17))}
+} {-6499}
+do_test randexpr-2.1469 {
+ db eval {SELECT t1.e*~13-t1.a-~case when (abs(t1.a)/abs(coalesce((select max(t1.a) from t1 where e not between f and e-t1.b+13),case when (a in (select ( -c) from t1 union select 11 from t1) or exists(select 1 from t1 where 11 between f and t1.f)) then t1.b-a else -t1.e end)+13*t1.f)) & 13<t1.a then t1.f when (t1.a in (select 19 from t1 union select c from t1)) then a else -19 end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.c*coalesce((select f from t1 where - -f+b-(select min(t1.b) from t1) not in (c,17-t1.b*t1.a,t1.c)),case when (select abs(count(*)) from t1)<> -19-a then (a)-coalesce((select max(case when a in (13,t1.b,11) then t1.b else (13) end) from t1 where not exists(select 1 from t1 where t1.b>=b)),t1.c) else -13 end)*(a)<17))}
+} {-6499}
+do_test randexpr-2.1470 {
+ db eval {SELECT coalesce((select max(f*b | case when f in (t1.b,t1.b*(select count(*) from t1)+(select -count(*) from t1), -b) and +13<(abs( -~d-case when t1.a in (select -f from t1 union select t1.c from t1) then (t1.a) when t1.a<e then t1.d else a end)/abs(t1.c)) then t1.b*19 else e end+t1.c | t1.d) from t1 where 13 not in (t1.e,13,c)),11)-11 FROM t1 WHERE b not between e-case when case 11 when t1.a then t1.e*17 else t1.c end in (select ~t1.a | b+(abs(f)/abs(case coalesce((select (select abs( -cast(avg(17) AS integer)) from t1) from t1 where not f=t1.b or 11>=a),coalesce((select 11 from t1 where 11 not between 19 and t1.c),t1.a))-19 when t1.e then t1.f else e end)) from t1 union select -d from t1) then d when t1.f between 17 and d then t1.d else t1.d end and (f) or d<17}
+} {}
+do_test randexpr-2.1471 {
+ db eval {SELECT coalesce((select max(f*b | case when f in (t1.b,t1.b*(select count(*) from t1)+(select -count(*) from t1), -b) and +13<(abs( -~d-case when t1.a in (select -f from t1 union select t1.c from t1) then (t1.a) when t1.a<e then t1.d else a end)/abs(t1.c)) then t1.b*19 else e end+t1.c | t1.d) from t1 where 13 not in (t1.e,13,c)),11)-11 FROM t1 WHERE NOT (b not between e-case when case 11 when t1.a then t1.e*17 else t1.c end in (select ~t1.a | b+(abs(f)/abs(case coalesce((select (select abs( -cast(avg(17) AS integer)) from t1) from t1 where not f=t1.b or 11>=a),coalesce((select 11 from t1 where 11 not between 19 and t1.c),t1.a))-19 when t1.e then t1.f else e end)) from t1 union select -d from t1) then d when t1.f between 17 and d then t1.d else t1.d end and (f) or d<17)}
+} {0}
+do_test randexpr-2.1472 {
+ db eval {SELECT coalesce((select max(f*b & case when f in (t1.b,t1.b*(select count(*) from t1)+(select -count(*) from t1), -b) and +13<(abs( -~d-case when t1.a in (select -f from t1 union select t1.c from t1) then (t1.a) when t1.a<e then t1.d else a end)/abs(t1.c)) then t1.b*19 else e end+t1.c & t1.d) from t1 where 13 not in (t1.e,13,c)),11)-11 FROM t1 WHERE NOT (b not between e-case when case 11 when t1.a then t1.e*17 else t1.c end in (select ~t1.a | b+(abs(f)/abs(case coalesce((select (select abs( -cast(avg(17) AS integer)) from t1) from t1 where not f=t1.b or 11>=a),coalesce((select 11 from t1 where 11 not between 19 and t1.c),t1.a))-19 when t1.e then t1.f else e end)) from t1 union select -d from t1) then d when t1.f between 17 and d then t1.d else t1.d end and (f) or d<17)}
+} {0}
+do_test randexpr-2.1473 {
+ db eval {SELECT case when (t1.b+case when a in (select coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where 11=case e when (e) then t1.b else t1.c end or c in (t1.f,f,11))),t1.f) from t1 union select t1.d from t1) and t1.e<>e then t1.f when t1.a in (t1.d,a,13) then 17 else t1.d end not in (t1.f,t1.d,17)) or c<> -19 then b when f<t1.c and t1.b in (e,11,t1.f) then t1.b-t1.c else - -d end FROM t1 WHERE t1.f- -t1.d in (select case a when 13+coalesce((select coalesce((select coalesce((select case when b>a-e then b else 19 end from t1 where 11<>t1.b),a) from t1 where not 19 in (select max(19)*count(distinct a) from t1 union select cast(avg(11) AS integer) from t1)),11) from t1 where t1.e<>a),17) then d else 19 end from t1 union select f from t1) and c in (select count(distinct c) from t1 union select -+max(d) | abs(count(*)) from t1)}
+} {}
+do_test randexpr-2.1474 {
+ db eval {SELECT case when (t1.b+case when a in (select coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where 11=case e when (e) then t1.b else t1.c end or c in (t1.f,f,11))),t1.f) from t1 union select t1.d from t1) and t1.e<>e then t1.f when t1.a in (t1.d,a,13) then 17 else t1.d end not in (t1.f,t1.d,17)) or c<> -19 then b when f<t1.c and t1.b in (e,11,t1.f) then t1.b-t1.c else - -d end FROM t1 WHERE NOT (t1.f- -t1.d in (select case a when 13+coalesce((select coalesce((select coalesce((select case when b>a-e then b else 19 end from t1 where 11<>t1.b),a) from t1 where not 19 in (select max(19)*count(distinct a) from t1 union select cast(avg(11) AS integer) from t1)),11) from t1 where t1.e<>a),17) then d else 19 end from t1 union select f from t1) and c in (select count(distinct c) from t1 union select -+max(d) | abs(count(*)) from t1))}
+} {200}
+do_test randexpr-2.1475 {
+ db eval {SELECT 17+coalesce((select max(19) from t1 where -(select max(t1.d) from t1)>coalesce((select max((13)) from t1 where (coalesce((select 11 from t1 where -e-t1.d-b-(abs(t1.b)/abs(11))*t1.f*b-e not between (f) and t1.e or 11 in (t1.b,t1.e, -e)),t1.a) in (select t1.b from t1 union select 19 from t1)) and exists(select 1 from t1 where 13<19)),t1.e)),e) FROM t1 WHERE t1.a<>t1.d or not exists(select 1 from t1 where t1.a>=coalesce((select case t1.e*d when -case d*11 when t1.f then t1.e else t1.c end then 13*coalesce((select max(f*b*t1.e*t1.c) from t1 where t1.d in (select t1.c from t1 union select f from t1) or ((t1.e<f or t1.e=t1.b))),t1.d) | t1.b else d end from t1 where t1.f between t1.c and a),(13)))}
+} {517}
+do_test randexpr-2.1476 {
+ db eval {SELECT 17+coalesce((select max(19) from t1 where -(select max(t1.d) from t1)>coalesce((select max((13)) from t1 where (coalesce((select 11 from t1 where -e-t1.d-b-(abs(t1.b)/abs(11))*t1.f*b-e not between (f) and t1.e or 11 in (t1.b,t1.e, -e)),t1.a) in (select t1.b from t1 union select 19 from t1)) and exists(select 1 from t1 where 13<19)),t1.e)),e) FROM t1 WHERE NOT (t1.a<>t1.d or not exists(select 1 from t1 where t1.a>=coalesce((select case t1.e*d when -case d*11 when t1.f then t1.e else t1.c end then 13*coalesce((select max(f*b*t1.e*t1.c) from t1 where t1.d in (select t1.c from t1 union select f from t1) or ((t1.e<f or t1.e=t1.b))),t1.d) | t1.b else d end from t1 where t1.f between t1.c and a),(13))))}
+} {}
+do_test randexpr-2.1477 {
+ db eval {SELECT case +a when (coalesce((select d*f*t1.d from t1 where t1.f between (case when e* -13<~ - -t1.e then e when 13>=t1.a then f-coalesce((select -(select max((select min(a)-count(distinct c) from t1)) from t1) from t1 where a between f and d),c) else d end) and c or not exists(select 1 from t1 where 11<=13)),f)) then (e) else t1.b end FROM t1 WHERE not -c between -d+f | 17+t1.a and 11 or 11*e=(+case when c>=d then coalesce((select max(d-t1.f*f) from t1 where 11 in (select count(distinct t1.e) from t1 union select (~case count(*) when -max(t1.f) then count(distinct t1.d) else (cast(avg(t1.f) AS integer)) end) from t1)),t1.c) else d end+t1.b-t1.c+b)+t1.c- -(13)}
+} {200}
+do_test randexpr-2.1478 {
+ db eval {SELECT case +a when (coalesce((select d*f*t1.d from t1 where t1.f between (case when e* -13<~ - -t1.e then e when 13>=t1.a then f-coalesce((select -(select max((select min(a)-count(distinct c) from t1)) from t1) from t1 where a between f and d),c) else d end) and c or not exists(select 1 from t1 where 11<=13)),f)) then (e) else t1.b end FROM t1 WHERE NOT (not -c between -d+f | 17+t1.a and 11 or 11*e=(+case when c>=d then coalesce((select max(d-t1.f*f) from t1 where 11 in (select count(distinct t1.e) from t1 union select (~case count(*) when -max(t1.f) then count(distinct t1.d) else (cast(avg(t1.f) AS integer)) end) from t1)),t1.c) else d end+t1.b-t1.c+b)+t1.c- -(13))}
+} {}
+do_test randexpr-2.1479 {
+ db eval {SELECT case when case when not exists(select 1 from t1 where a between +d-case when t1.c+e not between case 11 when +t1.b+11 then 19 else -t1.f end+(11) and d and exists(select 1 from t1 where (a)>b) and not exists(select 1 from t1 where 11 in (a,11,t1.c)) then 19 else t1.a end and t1.a) then 17 when t1.d<>e then (t1.a) else e end-a<=e then c else 11 end FROM t1 WHERE coalesce((select a from t1 where not exists(select 1 from t1 where -t1.c not between b and t1.a)),case when t1.d<=19-13 then coalesce((select max((select count(*)*cast(avg(~t1.a-e*~17+t1.e) AS integer) from t1)) from t1 where (exists(select 1 from t1 where + - -e-11*a-t1.d in (11,(t1.b),c)))),19+e)* -b else c end)>=17}
+} {300}
+do_test randexpr-2.1480 {
+ db eval {SELECT case when case when not exists(select 1 from t1 where a between +d-case when t1.c+e not between case 11 when +t1.b+11 then 19 else -t1.f end+(11) and d and exists(select 1 from t1 where (a)>b) and not exists(select 1 from t1 where 11 in (a,11,t1.c)) then 19 else t1.a end and t1.a) then 17 when t1.d<>e then (t1.a) else e end-a<=e then c else 11 end FROM t1 WHERE NOT (coalesce((select a from t1 where not exists(select 1 from t1 where -t1.c not between b and t1.a)),case when t1.d<=19-13 then coalesce((select max((select count(*)*cast(avg(~t1.a-e*~17+t1.e) AS integer) from t1)) from t1 where (exists(select 1 from t1 where + - -e-11*a-t1.d in (11,(t1.b),c)))),19+e)* -b else c end)>=17)}
+} {}
+do_test randexpr-2.1481 {
+ db eval {SELECT coalesce((select t1.c-~t1.e*19++case t1.b when coalesce((select 17 from t1 where t1.f not between t1.c-+coalesce((select max(a+ -t1.c) from t1 where (select count(distinct 11) from t1) in (select -+case when a not between f and b or b>=t1.d then (t1.d) when a in (t1.e,b,13) then t1.d else t1.c end*a from t1 union select t1.f from t1)),f) and 17),a) | 17*c then 19 else d end+t1.c from t1 where e<>t1.b),19) FROM t1 WHERE not (t1.e not between ~17 and +t1.e*(~b)*e)}
+} {}
+do_test randexpr-2.1482 {
+ db eval {SELECT coalesce((select t1.c-~t1.e*19++case t1.b when coalesce((select 17 from t1 where t1.f not between t1.c-+coalesce((select max(a+ -t1.c) from t1 where (select count(distinct 11) from t1) in (select -+case when a not between f and b or b>=t1.d then (t1.d) when a in (t1.e,b,13) then t1.d else t1.c end*a from t1 union select t1.f from t1)),f) and 17),a) | 17*c then 19 else d end+t1.c from t1 where e<>t1.b),19) FROM t1 WHERE NOT (not (t1.e not between ~17 and +t1.e*(~b)*e))}
+} {10519}
+do_test randexpr-2.1483 {
+ db eval {SELECT coalesce((select t1.c-~t1.e*19++case t1.b when coalesce((select 17 from t1 where t1.f not between t1.c-+coalesce((select max(a+ -t1.c) from t1 where (select count(distinct 11) from t1) in (select -+case when a not between f and b or b>=t1.d then (t1.d) when a in (t1.e,b,13) then t1.d else t1.c end*a from t1 union select t1.f from t1)),f) and 17),a) & 17*c then 19 else d end+t1.c from t1 where e<>t1.b),19) FROM t1 WHERE NOT (not (t1.e not between ~17 and +t1.e*(~b)*e))}
+} {10519}
+do_test randexpr-2.1484 {
+ db eval {SELECT ~case when b<=(t1.c | (abs(d)/abs(a*f)))+case when (13*(t1.b) not in (19,b,t1.d)) and exists(select 1 from t1 where 19 between t1.d and 11) then (select case count(distinct t1.f) when +( -count(distinct c) | cast(avg(t1.d) AS integer)) then cast(avg(t1.c) AS integer) else min(f) end from t1) else 13 end*t1.c or exists(select 1 from t1 where -f in (select e from t1 union select -t1.a from t1)) then t1.d else t1.c end FROM t1 WHERE exists(select 1 from t1 where t1.c+b-t1.d between 11 and 17)}
+} {}
+do_test randexpr-2.1485 {
+ db eval {SELECT ~case when b<=(t1.c | (abs(d)/abs(a*f)))+case when (13*(t1.b) not in (19,b,t1.d)) and exists(select 1 from t1 where 19 between t1.d and 11) then (select case count(distinct t1.f) when +( -count(distinct c) | cast(avg(t1.d) AS integer)) then cast(avg(t1.c) AS integer) else min(f) end from t1) else 13 end*t1.c or exists(select 1 from t1 where -f in (select e from t1 union select -t1.a from t1)) then t1.d else t1.c end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.c+b-t1.d between 11 and 17))}
+} {-401}
+do_test randexpr-2.1486 {
+ db eval {SELECT ~case when b<=(t1.c & (abs(d)/abs(a*f)))+case when (13*(t1.b) not in (19,b,t1.d)) and exists(select 1 from t1 where 19 between t1.d and 11) then (select case count(distinct t1.f) when +( -count(distinct c) & cast(avg(t1.d) AS integer)) then cast(avg(t1.c) AS integer) else min(f) end from t1) else 13 end*t1.c or exists(select 1 from t1 where -f in (select e from t1 union select -t1.a from t1)) then t1.d else t1.c end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.c+b-t1.d between 11 and 17))}
+} {-401}
+do_test randexpr-2.1487 {
+ db eval {SELECT coalesce((select max(~coalesce((select 19+~coalesce((select (abs((19)*c+~t1.a-t1.a*19)/abs(case when t1.d<>t1.b then t1.f when 13<>19 then (11) else t1.c end)) from t1 where f= -t1.a or t1.d not between t1.d and -f),t1.f) from t1 where not exists(select 1 from t1 where -19 not between d and f)),d)*t1.a-f) from t1 where c not in (c,c,c)),t1.b) FROM t1 WHERE (coalesce((select max( -t1.d+19+11+coalesce((select a from t1 where 11 not between e and t1.d),t1.d)) from t1 where not ( -t1.f not between b and f) and t1.e in (b,11,f)),f)+t1.e<=19) or c>t1.d or e in (a,19,11) or t1.f>b or -t1.f<=13 and a between 11 and t1.a}
+} {200}
+do_test randexpr-2.1488 {
+ db eval {SELECT coalesce((select max(~coalesce((select 19+~coalesce((select (abs((19)*c+~t1.a-t1.a*19)/abs(case when t1.d<>t1.b then t1.f when 13<>19 then (11) else t1.c end)) from t1 where f= -t1.a or t1.d not between t1.d and -f),t1.f) from t1 where not exists(select 1 from t1 where -19 not between d and f)),d)*t1.a-f) from t1 where c not in (c,c,c)),t1.b) FROM t1 WHERE NOT ((coalesce((select max( -t1.d+19+11+coalesce((select a from t1 where 11 not between e and t1.d),t1.d)) from t1 where not ( -t1.f not between b and f) and t1.e in (b,11,f)),f)+t1.e<=19) or c>t1.d or e in (a,19,11) or t1.f>b or -t1.f<=13 and a between 11 and t1.a)}
+} {}
+do_test randexpr-2.1489 {
+ db eval {SELECT case t1.d when 17 then 11 | t1.a-17+13+t1.f*t1.e+t1.e-case when d | t1.e in (t1.b,t1.a,c) then -13 else (b*19) end-(select cast(avg(coalesce((select a from t1 where e in (t1.f,t1.b,f)), -e)) AS integer) from t1)*d-11-t1.e-t1.a else t1.f end FROM t1 WHERE d*13 in (select abs(min(d)) from t1 union select cast(avg(d) AS integer) from t1)}
+} {}
+do_test randexpr-2.1490 {
+ db eval {SELECT case t1.d when 17 then 11 | t1.a-17+13+t1.f*t1.e+t1.e-case when d | t1.e in (t1.b,t1.a,c) then -13 else (b*19) end-(select cast(avg(coalesce((select a from t1 where e in (t1.f,t1.b,f)), -e)) AS integer) from t1)*d-11-t1.e-t1.a else t1.f end FROM t1 WHERE NOT (d*13 in (select abs(min(d)) from t1 union select cast(avg(d) AS integer) from t1))}
+} {600}
+do_test randexpr-2.1491 {
+ db eval {SELECT case t1.d when 17 then 11 & t1.a-17+13+t1.f*t1.e+t1.e-case when d & t1.e in (t1.b,t1.a,c) then -13 else (b*19) end-(select cast(avg(coalesce((select a from t1 where e in (t1.f,t1.b,f)), -e)) AS integer) from t1)*d-11-t1.e-t1.a else t1.f end FROM t1 WHERE NOT (d*13 in (select abs(min(d)) from t1 union select cast(avg(d) AS integer) from t1))}
+} {600}
+do_test randexpr-2.1492 {
+ db eval {SELECT coalesce((select max(19-(abs(t1.c)/abs( -13))-(select count(*)*abs(max(t1.a-b)) from t1)-t1.d) from t1 where (case coalesce((select max(~(select ~count(*) from t1)) from t1 where b=(abs(17)/abs(d))),11*case when not t1.c>=e or 17=c then d else 17*b end*t1.d) when 13 then 11 else t1.c end) in (select c from t1 union select t1.c from t1)),13) FROM t1 WHERE case t1.a*(select -case count(distinct ~(case 13-+t1.d-f when d then c else (19) end)*19)* -max(19) | -count(*)+abs(min(19)) | cast(avg(d) AS integer) when min(a) then count(distinct 11) else count(*) end from t1)*(abs(t1.a)/abs(11))-f-t1.b+(t1.f) when 11 then 17 else 19 end<>d}
+} {-504}
+do_test randexpr-2.1493 {
+ db eval {SELECT coalesce((select max(19-(abs(t1.c)/abs( -13))-(select count(*)*abs(max(t1.a-b)) from t1)-t1.d) from t1 where (case coalesce((select max(~(select ~count(*) from t1)) from t1 where b=(abs(17)/abs(d))),11*case when not t1.c>=e or 17=c then d else 17*b end*t1.d) when 13 then 11 else t1.c end) in (select c from t1 union select t1.c from t1)),13) FROM t1 WHERE NOT (case t1.a*(select -case count(distinct ~(case 13-+t1.d-f when d then c else (19) end)*19)* -max(19) | -count(*)+abs(min(19)) | cast(avg(d) AS integer) when min(a) then count(distinct 11) else count(*) end from t1)*(abs(t1.a)/abs(11))-f-t1.b+(t1.f) when 11 then 17 else 19 end<>d)}
+} {}
+do_test randexpr-2.1494 {
+ db eval {SELECT +(select abs( -abs(count(distinct case when (abs(t1.f)/abs(t1.a-t1.d)) in (select count(distinct 19) from t1 union select +abs(+ -cast(avg(c) AS integer)) from t1) then -(f) else e end-17)) | case count(distinct b) when count(*) then cast(avg(13) AS integer) else ( -count(distinct d)) end-count(*)* - -cast(avg(a) AS integer)) from t1)+case when t1.f in (select d*b | t1.d from t1 union select d from t1) then t1.f when 19<>t1.e then t1.b else 11 end+11 FROM t1 WHERE f<a+t1.f}
+} {212}
+do_test randexpr-2.1495 {
+ db eval {SELECT +(select abs( -abs(count(distinct case when (abs(t1.f)/abs(t1.a-t1.d)) in (select count(distinct 19) from t1 union select +abs(+ -cast(avg(c) AS integer)) from t1) then -(f) else e end-17)) | case count(distinct b) when count(*) then cast(avg(13) AS integer) else ( -count(distinct d)) end-count(*)* - -cast(avg(a) AS integer)) from t1)+case when t1.f in (select d*b | t1.d from t1 union select d from t1) then t1.f when 19<>t1.e then t1.b else 11 end+11 FROM t1 WHERE NOT (f<a+t1.f)}
+} {}
+do_test randexpr-2.1496 {
+ db eval {SELECT +(select abs( -abs(count(distinct case when (abs(t1.f)/abs(t1.a-t1.d)) in (select count(distinct 19) from t1 union select +abs(+ -cast(avg(c) AS integer)) from t1) then -(f) else e end-17)) & case count(distinct b) when count(*) then cast(avg(13) AS integer) else ( -count(distinct d)) end-count(*)* - -cast(avg(a) AS integer)) from t1)+case when t1.f in (select d*b & t1.d from t1 union select d from t1) then t1.f when 19<>t1.e then t1.b else 11 end+11 FROM t1 WHERE f<a+t1.f}
+} {298}
+do_test randexpr-2.1497 {
+ db eval {SELECT case when e in (+(select ~(max(t1.f)-+count(distinct 11)) from t1)*t1.b+t1.c*a*t1.b+e,a,t1.c) and (19)<>17 or 17 between 13 and a and exists(select 1 from t1 where c not between t1.f and t1.d) then coalesce((select max(d) from t1 where t1.e<>19),17) else a end*(( -f))+t1.d FROM t1 WHERE exists(select 1 from t1 where exists(select 1 from t1 where t1.c between case when (a<a and not exists(select 1 from t1 where exists(select 1 from t1 where d<~t1.f-+t1.a or (abs(17)/abs(t1.c)) in (select 19 from t1 union select 11 from t1)))) then +e when d<>13 or b>=e or 19 between t1.d and -t1.e then t1.f else f end and f) and c>((t1.c))) and not exists(select 1 from t1 where 17<t1.c)}
+} {}
+do_test randexpr-2.1498 {
+ db eval {SELECT case when e in (+(select ~(max(t1.f)-+count(distinct 11)) from t1)*t1.b+t1.c*a*t1.b+e,a,t1.c) and (19)<>17 or 17 between 13 and a and exists(select 1 from t1 where c not between t1.f and t1.d) then coalesce((select max(d) from t1 where t1.e<>19),17) else a end*(( -f))+t1.d FROM t1 WHERE NOT (exists(select 1 from t1 where exists(select 1 from t1 where t1.c between case when (a<a and not exists(select 1 from t1 where exists(select 1 from t1 where d<~t1.f-+t1.a or (abs(17)/abs(t1.c)) in (select 19 from t1 union select 11 from t1)))) then +e when d<>13 or b>=e or 19 between t1.d and -t1.e then t1.f else f end and f) and c>((t1.c))) and not exists(select 1 from t1 where 17<t1.c))}
+} {-239600}
+do_test randexpr-2.1499 {
+ db eval {SELECT 17+11+d+t1.d | t1.c+(abs(case when 11 in (select count(distinct 11*+t1.d) from t1 union select ~cast(avg(t1.c) AS integer)*case (count(distinct 19)) when (cast(avg(t1.c) AS integer) | min(t1.a-f)) then cast(avg(a) AS integer) else cast(avg(t1.b) AS integer) end+max( - -d) from t1) then t1.a-13 when (11)>=13 then t1.e else t1.c end)/abs(19)) | (t1.d) FROM t1 WHERE d>=(case when ((t1.a)) between t1.f and a then case when 11 between 19-case when (~coalesce((select t1.e from t1 where d>t1.c and e<>t1.f),e))>=13 then t1.b when t1.d in (select (count(*)-min(19)) from t1 union select cast(avg(t1.e) AS integer) from t1) then 17 else (t1.d) end*t1.a and (13) then 11 when not exists(select 1 from t1 where not 19<>(t1.e) and t1.a between d and d and t1.c=a) then 17 else t1.a end-17 else e end)}
+} {}
+do_test randexpr-2.1500 {
+ db eval {SELECT 17+11+d+t1.d | t1.c+(abs(case when 11 in (select count(distinct 11*+t1.d) from t1 union select ~cast(avg(t1.c) AS integer)*case (count(distinct 19)) when (cast(avg(t1.c) AS integer) | min(t1.a-f)) then cast(avg(a) AS integer) else cast(avg(t1.b) AS integer) end+max( - -d) from t1) then t1.a-13 when (11)>=13 then t1.e else t1.c end)/abs(19)) | (t1.d) FROM t1 WHERE NOT (d>=(case when ((t1.a)) between t1.f and a then case when 11 between 19-case when (~coalesce((select t1.e from t1 where d>t1.c and e<>t1.f),e))>=13 then t1.b when t1.d in (select (count(*)-min(19)) from t1 union select cast(avg(t1.e) AS integer) from t1) then 17 else (t1.d) end*t1.a and (13) then 11 when not exists(select 1 from t1 where not 19<>(t1.e) and t1.a between d and d and t1.c=a) then 17 else t1.a end-17 else e end))}
+} {959}
+do_test randexpr-2.1501 {
+ db eval {SELECT 17+11+d+t1.d & t1.c+(abs(case when 11 in (select count(distinct 11*+t1.d) from t1 union select ~cast(avg(t1.c) AS integer)*case (count(distinct 19)) when (cast(avg(t1.c) AS integer) & min(t1.a-f)) then cast(avg(a) AS integer) else cast(avg(t1.b) AS integer) end+max( - -d) from t1) then t1.a-13 when (11)>=13 then t1.e else t1.c end)/abs(19)) & (t1.d) FROM t1 WHERE NOT (d>=(case when ((t1.a)) between t1.f and a then case when 11 between 19-case when (~coalesce((select t1.e from t1 where d>t1.c and e<>t1.f),e))>=13 then t1.b when t1.d in (select (count(*)-min(19)) from t1 union select cast(avg(t1.e) AS integer) from t1) then 17 else (t1.d) end*t1.a and (13) then 11 when not exists(select 1 from t1 where not 19<>(t1.e) and t1.a between d and d and t1.c=a) then 17 else t1.a end-17 else e end))}
+} {272}
+do_test randexpr-2.1502 {
+ db eval {SELECT coalesce((select 17 from t1 where ((abs(19)/abs(case when ((f+17<(d))) and (abs(t1.c)/abs((t1.b)))>11 then ~a+11 when (t1.f)>t1.d then 19 else c end))<>t1.b) or (b in (( -t1.d),b,e) and (t1.a)<>c) and (17) not in (t1.f,11,17) or (f) not between t1.c and -t1.c),t1.a) FROM t1 WHERE 17 between -t1.b+f-19 | 17 and t1.e+t1.c}
+} {}
+do_test randexpr-2.1503 {
+ db eval {SELECT coalesce((select 17 from t1 where ((abs(19)/abs(case when ((f+17<(d))) and (abs(t1.c)/abs((t1.b)))>11 then ~a+11 when (t1.f)>t1.d then 19 else c end))<>t1.b) or (b in (( -t1.d),b,e) and (t1.a)<>c) and (17) not in (t1.f,11,17) or (f) not between t1.c and -t1.c),t1.a) FROM t1 WHERE NOT (17 between -t1.b+f-19 | 17 and t1.e+t1.c)}
+} {17}
+do_test randexpr-2.1504 {
+ db eval {SELECT +(11)-19-case when 19+13-19+f*19*c not in (coalesce((select max((select ~min(t1.b)+(count(distinct t1.d)) | min(13)*count(distinct t1.a)*max(a) from t1)) from t1 where not 19 in (select t1.d from t1 union select 19 from t1) or 19<=t1.c),t1.b | f) | e-f,d,d) then t1.a else d end FROM t1 WHERE t1.d in (select case when t1.e>(case coalesce((select (11)-t1.e from t1 where case t1.e when t1.c then (coalesce((select max(+t1.b) from t1 where (a in (case when 19 in (select cast(avg((t1.b)) AS integer) from t1 union select cast(avg( - -17) AS integer) from t1) then a when 17>=13 then c else t1.e end,11,11) or not 19 between t1.b and t1.a)),t1.e)) else d end<=t1.c),13) when e then a else d end) then a when 19 in (select (11) from t1 union select t1.e from t1) then (e) else t1.d end from t1 union select t1.d from t1)}
+} {-108}
+do_test randexpr-2.1505 {
+ db eval {SELECT +(11)-19-case when 19+13-19+f*19*c not in (coalesce((select max((select ~min(t1.b)+(count(distinct t1.d)) | min(13)*count(distinct t1.a)*max(a) from t1)) from t1 where not 19 in (select t1.d from t1 union select 19 from t1) or 19<=t1.c),t1.b | f) | e-f,d,d) then t1.a else d end FROM t1 WHERE NOT (t1.d in (select case when t1.e>(case coalesce((select (11)-t1.e from t1 where case t1.e when t1.c then (coalesce((select max(+t1.b) from t1 where (a in (case when 19 in (select cast(avg((t1.b)) AS integer) from t1 union select cast(avg( - -17) AS integer) from t1) then a when 17>=13 then c else t1.e end,11,11) or not 19 between t1.b and t1.a)),t1.e)) else d end<=t1.c),13) when e then a else d end) then a when 19 in (select (11) from t1 union select t1.e from t1) then (e) else t1.d end from t1 union select t1.d from t1))}
+} {}
+do_test randexpr-2.1506 {
+ db eval {SELECT +(11)-19-case when 19+13-19+f*19*c not in (coalesce((select max((select ~min(t1.b)+(count(distinct t1.d)) & min(13)*count(distinct t1.a)*max(a) from t1)) from t1 where not 19 in (select t1.d from t1 union select 19 from t1) or 19<=t1.c),t1.b & f) & e-f,d,d) then t1.a else d end FROM t1 WHERE t1.d in (select case when t1.e>(case coalesce((select (11)-t1.e from t1 where case t1.e when t1.c then (coalesce((select max(+t1.b) from t1 where (a in (case when 19 in (select cast(avg((t1.b)) AS integer) from t1 union select cast(avg( - -17) AS integer) from t1) then a when 17>=13 then c else t1.e end,11,11) or not 19 between t1.b and t1.a)),t1.e)) else d end<=t1.c),13) when e then a else d end) then a when 19 in (select (11) from t1 union select t1.e from t1) then (e) else t1.d end from t1 union select t1.d from t1)}
+} {-108}
+do_test randexpr-2.1507 {
+ db eval {SELECT (abs(case t1.f when (abs((abs( -t1.b+t1.f | case when t1.e-b*19<=17 then 13 when t1.d<>c-coalesce((select max(coalesce((select t1.d from t1 where (not exists(select 1 from t1 where (19)<=a) or 11 between t1.e and f)),d | t1.f)) from t1 where (t1.a between 19 and t1.a)),13) then 19 else f end)/abs(t1.f))-t1.a)/abs(e))+t1.e then t1.b else b end)/abs(19))+t1.a FROM t1 WHERE 17 in (select f*f from t1 union select a+d from t1)}
+} {}
+do_test randexpr-2.1508 {
+ db eval {SELECT (abs(case t1.f when (abs((abs( -t1.b+t1.f | case when t1.e-b*19<=17 then 13 when t1.d<>c-coalesce((select max(coalesce((select t1.d from t1 where (not exists(select 1 from t1 where (19)<=a) or 11 between t1.e and f)),d | t1.f)) from t1 where (t1.a between 19 and t1.a)),13) then 19 else f end)/abs(t1.f))-t1.a)/abs(e))+t1.e then t1.b else b end)/abs(19))+t1.a FROM t1 WHERE NOT (17 in (select f*f from t1 union select a+d from t1))}
+} {110}
+do_test randexpr-2.1509 {
+ db eval {SELECT (abs(case t1.f when (abs((abs( -t1.b+t1.f & case when t1.e-b*19<=17 then 13 when t1.d<>c-coalesce((select max(coalesce((select t1.d from t1 where (not exists(select 1 from t1 where (19)<=a) or 11 between t1.e and f)),d & t1.f)) from t1 where (t1.a between 19 and t1.a)),13) then 19 else f end)/abs(t1.f))-t1.a)/abs(e))+t1.e then t1.b else b end)/abs(19))+t1.a FROM t1 WHERE NOT (17 in (select f*f from t1 union select a+d from t1))}
+} {110}
+do_test randexpr-2.1510 {
+ db eval {SELECT (coalesce((select t1.e from t1 where +case when t1.c+f<>d-17 then t1.a when not (abs(t1.c)/abs(case case -f when f then a else t1.b end-t1.e-t1.f when t1.b then -e else t1.c end))>e or t1.b=a or exists(select 1 from t1 where 19>=t1.b) and t1.c< -e then t1.e else 13 end<=t1.b),b)) | d FROM t1 WHERE case 13 when 13 then 17-f else a end=e and (exists(select 1 from t1 where b in (select t1.f from t1 union select coalesce((select case when (abs(t1.c)/abs(17)) in (a,f*c,11) then c when ( -t1.d) in (select ~count(distinct t1.b) from t1 union select min((t1.c)) from t1) then t1.a else t1.e end from t1 where exists(select 1 from t1 where (t1.f) in (t1.d,17, -11))),b)-d*11*c+a from t1)))}
+} {}
+do_test randexpr-2.1511 {
+ db eval {SELECT (coalesce((select t1.e from t1 where +case when t1.c+f<>d-17 then t1.a when not (abs(t1.c)/abs(case case -f when f then a else t1.b end-t1.e-t1.f when t1.b then -e else t1.c end))>e or t1.b=a or exists(select 1 from t1 where 19>=t1.b) and t1.c< -e then t1.e else 13 end<=t1.b),b)) | d FROM t1 WHERE NOT (case 13 when 13 then 17-f else a end=e and (exists(select 1 from t1 where b in (select t1.f from t1 union select coalesce((select case when (abs(t1.c)/abs(17)) in (a,f*c,11) then c when ( -t1.d) in (select ~count(distinct t1.b) from t1 union select min((t1.c)) from t1) then t1.a else t1.e end from t1 where exists(select 1 from t1 where (t1.f) in (t1.d,17, -11))),b)-d*11*c+a from t1))))}
+} {500}
+do_test randexpr-2.1512 {
+ db eval {SELECT (coalesce((select t1.e from t1 where +case when t1.c+f<>d-17 then t1.a when not (abs(t1.c)/abs(case case -f when f then a else t1.b end-t1.e-t1.f when t1.b then -e else t1.c end))>e or t1.b=a or exists(select 1 from t1 where 19>=t1.b) and t1.c< -e then t1.e else 13 end<=t1.b),b)) & d FROM t1 WHERE NOT (case 13 when 13 then 17-f else a end=e and (exists(select 1 from t1 where b in (select t1.f from t1 union select coalesce((select case when (abs(t1.c)/abs(17)) in (a,f*c,11) then c when ( -t1.d) in (select ~count(distinct t1.b) from t1 union select min((t1.c)) from t1) then t1.a else t1.e end from t1 where exists(select 1 from t1 where (t1.f) in (t1.d,17, -11))),b)-d*11*c+a from t1))))}
+} {400}
+do_test randexpr-2.1513 {
+ db eval {SELECT (abs( -case when exists(select 1 from t1 where (abs(e++11-(abs(c)/abs(t1.f)))/abs(19+t1.b))+t1.b-c=(b)) or d in (~d, -f,c) then (select min(13) from t1)+11+~t1.a*t1.a else d end-t1.d)/abs((select (max(d))+count(*)-min(t1.c) from t1))) FROM t1 WHERE (select +min(c+d) | (max(13)+min(case when t1.e not in (t1.d,t1.d,19*t1.d) then t1.a when 17=d then t1.b else a end)+ - -max(t1.a)*count(distinct f) | count(*)+max(t1.d) | count(distinct d))-count(distinct 17)-count(*) from t1) not in (e,d+11,(t1.a+t1.f))}
+} {7}
+do_test randexpr-2.1514 {
+ db eval {SELECT (abs( -case when exists(select 1 from t1 where (abs(e++11-(abs(c)/abs(t1.f)))/abs(19+t1.b))+t1.b-c=(b)) or d in (~d, -f,c) then (select min(13) from t1)+11+~t1.a*t1.a else d end-t1.d)/abs((select (max(d))+count(*)-min(t1.c) from t1))) FROM t1 WHERE NOT ((select +min(c+d) | (max(13)+min(case when t1.e not in (t1.d,t1.d,19*t1.d) then t1.a when 17=d then t1.b else a end)+ - -max(t1.a)*count(distinct f) | count(*)+max(t1.d) | count(distinct d))-count(distinct 17)-count(*) from t1) not in (e,d+11,(t1.a+t1.f)))}
+} {}
+do_test randexpr-2.1515 {
+ db eval {SELECT case when not exists(select 1 from t1 where (not case t1.b when d then c else coalesce((select max(b+case c+c when t1.c then coalesce((select ((e)) from t1 where c in (e,t1.f,t1.d)),t1.a) else t1.f end+t1.e) from t1 where not t1.e not between t1.f and t1.a),19) end+f<>b)) then e when f in (19,t1.d, -c) then 19 else case when e>=t1.f then 19 else 19 end end FROM t1 WHERE 19 between e+case when d>(select ~max(t1.d)+max(t1.d*t1.c)-~count(distinct c)-count(*)-count(distinct t1.b)* -(count(*)) from t1) then ~a when not exists(select 1 from t1 where t1.c>=13) or (t1.f=t1.a or c in ((f), -c,t1.e)) and b=b and e not between t1.b and -11 or t1.c in (t1.c,17,t1.c) and t1.f=t1.d then t1.a*t1.d*t1.c else d end and e}
+} {}
+do_test randexpr-2.1516 {
+ db eval {SELECT case when not exists(select 1 from t1 where (not case t1.b when d then c else coalesce((select max(b+case c+c when t1.c then coalesce((select ((e)) from t1 where c in (e,t1.f,t1.d)),t1.a) else t1.f end+t1.e) from t1 where not t1.e not between t1.f and t1.a),19) end+f<>b)) then e when f in (19,t1.d, -c) then 19 else case when e>=t1.f then 19 else 19 end end FROM t1 WHERE NOT (19 between e+case when d>(select ~max(t1.d)+max(t1.d*t1.c)-~count(distinct c)-count(*)-count(distinct t1.b)* -(count(*)) from t1) then ~a when not exists(select 1 from t1 where t1.c>=13) or (t1.f=t1.a or c in ((f), -c,t1.e)) and b=b and e not between t1.b and -11 or t1.c in (t1.c,17,t1.c) and t1.f=t1.d then t1.a*t1.d*t1.c else d end and e)}
+} {500}
+do_test randexpr-2.1517 {
+ db eval {SELECT (select -+case -(case -max(d) when ~+ -+(count(*)) then abs(max(case 17+t1.a-11-t1.c when 19 then f else e end*((t1.c))+b)) else (min(d)*count(distinct t1.e)) end)++abs(count(*))- -cast(avg(c) AS integer)+max(d) when count(distinct c) then min(f) else (count(distinct a)) end from t1) FROM t1 WHERE ((case -a when case when f between 11 and t1.d then d else c+17 end then b else a end+11-c between -a and t1.a) or b>t1.f and t1.a<t1.e and (t1.d)<=b or 19 in (select f from t1 union select e from t1) and t1.f not between 19 and 11 or t1.b not in (t1.e,t1.e,11))}
+} {-1}
+do_test randexpr-2.1518 {
+ db eval {SELECT (select -+case -(case -max(d) when ~+ -+(count(*)) then abs(max(case 17+t1.a-11-t1.c when 19 then f else e end*((t1.c))+b)) else (min(d)*count(distinct t1.e)) end)++abs(count(*))- -cast(avg(c) AS integer)+max(d) when count(distinct c) then min(f) else (count(distinct a)) end from t1) FROM t1 WHERE NOT (((case -a when case when f between 11 and t1.d then d else c+17 end then b else a end+11-c between -a and t1.a) or b>t1.f and t1.a<t1.e and (t1.d)<=b or 19 in (select f from t1 union select e from t1) and t1.f not between 19 and 11 or t1.b not in (t1.e,t1.e,11)))}
+} {}
+do_test randexpr-2.1519 {
+ db eval {SELECT -coalesce((select max((select case +count(*)+(case min((abs(d)/abs(b))) when +count(*) | (min(b)) then -min((t1.a)) else max( -t1.a) end*max( -t1.e))+max(f) when (count(*)) then count(distinct 17) else cast(avg((t1.c)) AS integer) end from t1)) from t1 where t1.d in (select 13 from t1 union select t1.c from t1)),(abs(case when ((c>=f) or f in (t1.a,(t1.a),a)) then -~c-d else t1.e end)/abs(13))) FROM t1 WHERE (select (+~max(case when t1.e>=coalesce((select max(t1.d) from t1 where +f not in (coalesce((select 11 from t1 where 13 | c in (select c from t1 union select b from t1)),f),t1.c, -a)),13) then e else 19 end)-min(t1.a)) from t1)+((coalesce((select t1.e from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where t1.c=t1.a))),a)))+13 in (select d from t1 union select t1.a from t1) and e>=b}
+} {}
+do_test randexpr-2.1520 {
+ db eval {SELECT -coalesce((select max((select case +count(*)+(case min((abs(d)/abs(b))) when +count(*) | (min(b)) then -min((t1.a)) else max( -t1.a) end*max( -t1.e))+max(f) when (count(*)) then count(distinct 17) else cast(avg((t1.c)) AS integer) end from t1)) from t1 where t1.d in (select 13 from t1 union select t1.c from t1)),(abs(case when ((c>=f) or f in (t1.a,(t1.a),a)) then -~c-d else t1.e end)/abs(13))) FROM t1 WHERE NOT ((select (+~max(case when t1.e>=coalesce((select max(t1.d) from t1 where +f not in (coalesce((select 11 from t1 where 13 | c in (select c from t1 union select b from t1)),f),t1.c, -a)),13) then e else 19 end)-min(t1.a)) from t1)+((coalesce((select t1.e from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where t1.c=t1.a))),a)))+13 in (select d from t1 union select t1.a from t1) and e>=b)}
+} {-38}
+do_test randexpr-2.1521 {
+ db eval {SELECT -coalesce((select max((select case +count(*)+(case min((abs(d)/abs(b))) when +count(*) & (min(b)) then -min((t1.a)) else max( -t1.a) end*max( -t1.e))+max(f) when (count(*)) then count(distinct 17) else cast(avg((t1.c)) AS integer) end from t1)) from t1 where t1.d in (select 13 from t1 union select t1.c from t1)),(abs(case when ((c>=f) or f in (t1.a,(t1.a),a)) then -~c-d else t1.e end)/abs(13))) FROM t1 WHERE NOT ((select (+~max(case when t1.e>=coalesce((select max(t1.d) from t1 where +f not in (coalesce((select 11 from t1 where 13 | c in (select c from t1 union select b from t1)),f),t1.c, -a)),13) then e else 19 end)-min(t1.a)) from t1)+((coalesce((select t1.e from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where t1.c=t1.a))),a)))+13 in (select d from t1 union select t1.a from t1) and e>=b)}
+} {-38}
+do_test randexpr-2.1522 {
+ db eval {SELECT +(select +abs(+cast(avg(t1.b) AS integer)*abs(case -max( -(t1.a*t1.f)+t1.e* -t1.f*13 | 17 | f+t1.c) when abs(cast(avg(d) AS integer))-(++~min(t1.f) | count(*)-cast(avg(f) AS integer)) then count(*) else cast(avg(13) AS integer) end+ -min(b)))+min(a) from t1) FROM t1 WHERE case t1.a-t1.e*+t1.f-(select abs(count(*)) from t1)+coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where ~t1.b in (select +count(*) | count(distinct case b when t1.a then f else case when (t1.d-t1.b)<11 then t1.d else f end end) from t1 union select +cast(avg(( -d)) AS integer) from t1))),t1.d*t1.a) | e when t1.f then (t1.d) else t1.f end not in (d,f,e)}
+} {}
+do_test randexpr-2.1523 {
+ db eval {SELECT +(select +abs(+cast(avg(t1.b) AS integer)*abs(case -max( -(t1.a*t1.f)+t1.e* -t1.f*13 | 17 | f+t1.c) when abs(cast(avg(d) AS integer))-(++~min(t1.f) | count(*)-cast(avg(f) AS integer)) then count(*) else cast(avg(13) AS integer) end+ -min(b)))+min(a) from t1) FROM t1 WHERE NOT (case t1.a-t1.e*+t1.f-(select abs(count(*)) from t1)+coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where ~t1.b in (select +count(*) | count(distinct case b when t1.a then f else case when (t1.d-t1.b)<11 then t1.d else f end end) from t1 union select +cast(avg(( -d)) AS integer) from t1))),t1.d*t1.a) | e when t1.f then (t1.d) else t1.f end not in (d,f,e))}
+} {37500}
+do_test randexpr-2.1524 {
+ db eval {SELECT +(select +abs(+cast(avg(t1.b) AS integer)*abs(case -max( -(t1.a*t1.f)+t1.e* -t1.f*13 & 17 & f+t1.c) when abs(cast(avg(d) AS integer))-(++~min(t1.f) & count(*)-cast(avg(f) AS integer)) then count(*) else cast(avg(13) AS integer) end+ -min(b)))+min(a) from t1) FROM t1 WHERE NOT (case t1.a-t1.e*+t1.f-(select abs(count(*)) from t1)+coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where ~t1.b in (select +count(*) | count(distinct case b when t1.a then f else case when (t1.d-t1.b)<11 then t1.d else f end end) from t1 union select +cast(avg(( -d)) AS integer) from t1))),t1.d*t1.a) | e when t1.f then (t1.d) else t1.f end not in (d,f,e))}
+} {37500}
+do_test randexpr-2.1525 {
+ db eval {SELECT t1.d+case when coalesce((select b from t1 where case when (select max(t1.a*(select case count(distinct c) when max(17+c) then - -max(d)-count(*) else cast(avg((e)) AS integer) end from t1)) from t1) not between t1.d and t1.d then t1.d when t1.c not between c and t1.f then ( -t1.d) else t1.d end not between e and t1.e),d)<>17 then (t1.f) when 11=t1.c then 11 else t1.f end*c*t1.a-c FROM t1 WHERE (case when coalesce((select ~coalesce((select max(a) from t1 where 11 in (select ~case -count(*) when cast(avg(d) AS integer) then -max(t1.f) else (count(distinct 11)) end+cast(avg( - -13) AS integer) | count(*)-min(f) from t1 union select count(*) from t1)),t1.b*t1.f*17) from t1 where not exists(select 1 from t1 where t1.a not between d and 11)),b)-17*t1.d+t1.a in ( -t1.c,t1.e,11) then b else t1.d end in (select 17 from t1 union select 13 from t1)) and -t1.a in (select (d) from t1 union select t1.b from t1)}
+} {}
+do_test randexpr-2.1526 {
+ db eval {SELECT t1.d+case when coalesce((select b from t1 where case when (select max(t1.a*(select case count(distinct c) when max(17+c) then - -max(d)-count(*) else cast(avg((e)) AS integer) end from t1)) from t1) not between t1.d and t1.d then t1.d when t1.c not between c and t1.f then ( -t1.d) else t1.d end not between e and t1.e),d)<>17 then (t1.f) when 11=t1.c then 11 else t1.f end*c*t1.a-c FROM t1 WHERE NOT ((case when coalesce((select ~coalesce((select max(a) from t1 where 11 in (select ~case -count(*) when cast(avg(d) AS integer) then -max(t1.f) else (count(distinct 11)) end+cast(avg( - -13) AS integer) | count(*)-min(f) from t1 union select count(*) from t1)),t1.b*t1.f*17) from t1 where not exists(select 1 from t1 where t1.a not between d and 11)),b)-17*t1.d+t1.a in ( -t1.c,t1.e,11) then b else t1.d end in (select 17 from t1 union select 13 from t1)) and -t1.a in (select (d) from t1 union select t1.b from t1))}
+} {18000100}
+do_test randexpr-2.1527 {
+ db eval {SELECT coalesce((select (abs(b+t1.c)/abs(coalesce((select max( -~t1.d) from t1 where coalesce((select max(11) from t1 where not t1.d>=(select count(*) from t1)),case b-coalesce((select t1.e-f from t1 where coalesce((select max(case a when t1.e then t1.f else 11 end) from t1 where t1.b>=t1.f),t1.d) not in (f,e,13)),t1.f) when -11 then t1.c else 19 end)-d not in (f,f,b)),f))) from t1 where d<=t1.d),f) FROM t1 WHERE c+case when coalesce((select d from t1 where coalesce((select max(17) from t1 where c>17-11),17)<c),case when not (t1.d) in (select 19 from t1 union select t1.a from t1) then case when -d<=17 then f else t1.a end else 19 end)+e in (select 17 from t1 union select -t1.b from t1) then b when 17<t1.b or 17<f then -11 else t1.d end*b-t1.d in (select count(distinct d) from t1 union select count(distinct c) from t1)}
+} {}
+do_test randexpr-2.1528 {
+ db eval {SELECT coalesce((select (abs(b+t1.c)/abs(coalesce((select max( -~t1.d) from t1 where coalesce((select max(11) from t1 where not t1.d>=(select count(*) from t1)),case b-coalesce((select t1.e-f from t1 where coalesce((select max(case a when t1.e then t1.f else 11 end) from t1 where t1.b>=t1.f),t1.d) not in (f,e,13)),t1.f) when -11 then t1.c else 19 end)-d not in (f,f,b)),f))) from t1 where d<=t1.d),f) FROM t1 WHERE NOT (c+case when coalesce((select d from t1 where coalesce((select max(17) from t1 where c>17-11),17)<c),case when not (t1.d) in (select 19 from t1 union select t1.a from t1) then case when -d<=17 then f else t1.a end else 19 end)+e in (select 17 from t1 union select -t1.b from t1) then b when 17<t1.b or 17<f then -11 else t1.d end*b-t1.d in (select count(distinct d) from t1 union select count(distinct c) from t1))}
+} {1}
+do_test randexpr-2.1529 {
+ db eval {SELECT (abs(19)/abs(coalesce((select max((abs((abs(t1.a)/abs(e)))/abs(b))) from t1 where not t1.f<13 and 17-(abs(b-13*f*(abs(+17-f+t1.a)/abs(t1.d)))/abs(t1.e))+e-17>f and (exists(select 1 from t1 where (17 in (e, -t1.f,c)) and t1.f<=19))),d))) FROM t1 WHERE f*t1.c<>t1.b}
+} {0}
+do_test randexpr-2.1530 {
+ db eval {SELECT (abs(19)/abs(coalesce((select max((abs((abs(t1.a)/abs(e)))/abs(b))) from t1 where not t1.f<13 and 17-(abs(b-13*f*(abs(+17-f+t1.a)/abs(t1.d)))/abs(t1.e))+e-17>f and (exists(select 1 from t1 where (17 in (e, -t1.f,c)) and t1.f<=19))),d))) FROM t1 WHERE NOT (f*t1.c<>t1.b)}
+} {}
+do_test randexpr-2.1531 {
+ db eval {SELECT case when t1.d in (select count(distinct 11) from t1 union select case abs(++cast(avg(t1.b) AS integer)+count(*) | -(count(*))) when count(*) then count(distinct t1.b) else count(distinct -t1.a) end | max(t1.c) from t1) and t1.f<=case when exists(select 1 from t1 where t1.f+t1.f<>17 and t1.b>d) then 19 when t1.e=a then coalesce((select b from t1 where 13 not in (t1.b,t1.a,t1.a)),t1.c) else t1.d end and t1.d>(t1.b) and c in (e,t1.d,t1.b) then b | c when f=t1.e then e else 19 end FROM t1 WHERE t1.f between (c-t1.d+t1.f*t1.f) and 11+t1.e*coalesce((select max(coalesce((select max(t1.e) from t1 where exists(select 1 from t1 where (c-13 between t1.e*a and 11 or (t1.f>f) or t1.c>=t1.f))),t1.b-b-11)) from t1 where (f>t1.f)),11)-t1.b*e}
+} {}
+do_test randexpr-2.1532 {
+ db eval {SELECT case when t1.d in (select count(distinct 11) from t1 union select case abs(++cast(avg(t1.b) AS integer)+count(*) | -(count(*))) when count(*) then count(distinct t1.b) else count(distinct -t1.a) end | max(t1.c) from t1) and t1.f<=case when exists(select 1 from t1 where t1.f+t1.f<>17 and t1.b>d) then 19 when t1.e=a then coalesce((select b from t1 where 13 not in (t1.b,t1.a,t1.a)),t1.c) else t1.d end and t1.d>(t1.b) and c in (e,t1.d,t1.b) then b | c when f=t1.e then e else 19 end FROM t1 WHERE NOT (t1.f between (c-t1.d+t1.f*t1.f) and 11+t1.e*coalesce((select max(coalesce((select max(t1.e) from t1 where exists(select 1 from t1 where (c-13 between t1.e*a and 11 or (t1.f>f) or t1.c>=t1.f))),t1.b-b-11)) from t1 where (f>t1.f)),11)-t1.b*e)}
+} {19}
+do_test randexpr-2.1533 {
+ db eval {SELECT case when t1.d in (select count(distinct 11) from t1 union select case abs(++cast(avg(t1.b) AS integer)+count(*) & -(count(*))) when count(*) then count(distinct t1.b) else count(distinct -t1.a) end & max(t1.c) from t1) and t1.f<=case when exists(select 1 from t1 where t1.f+t1.f<>17 and t1.b>d) then 19 when t1.e=a then coalesce((select b from t1 where 13 not in (t1.b,t1.a,t1.a)),t1.c) else t1.d end and t1.d>(t1.b) and c in (e,t1.d,t1.b) then b & c when f=t1.e then e else 19 end FROM t1 WHERE NOT (t1.f between (c-t1.d+t1.f*t1.f) and 11+t1.e*coalesce((select max(coalesce((select max(t1.e) from t1 where exists(select 1 from t1 where (c-13 between t1.e*a and 11 or (t1.f>f) or t1.c>=t1.f))),t1.b-b-11)) from t1 where (f>t1.f)),11)-t1.b*e)}
+} {19}
+do_test randexpr-2.1534 {
+ db eval {SELECT coalesce((select t1.e from t1 where (case when 19>=t1.c then t1.d else coalesce((select max(11*t1.b) from t1 where case ~t1.c-(select max(11) from t1)*~t1.b+f*~coalesce((select max(d) from t1 where d>=b),d)-t1.a*t1.c*t1.d when -t1.c then 13 else f end in (select b from t1 union select 13 from t1)),t1.f) end | b<>a)),t1.e) FROM t1 WHERE not exists(select 1 from t1 where not (t1.e<t1.b and t1.e<>t1.b+case (select count(distinct e)*cast(avg(case c when e then case a when f then b else d end-a-13 else 13 end*t1.a+ -t1.d) AS integer) from t1)+c | (t1.f)*f when -c then d else 19 end) and -17 in (select min(t1.b) from t1 union select count(distinct f) from t1))}
+} {500}
+do_test randexpr-2.1535 {
+ db eval {SELECT coalesce((select t1.e from t1 where (case when 19>=t1.c then t1.d else coalesce((select max(11*t1.b) from t1 where case ~t1.c-(select max(11) from t1)*~t1.b+f*~coalesce((select max(d) from t1 where d>=b),d)-t1.a*t1.c*t1.d when -t1.c then 13 else f end in (select b from t1 union select 13 from t1)),t1.f) end | b<>a)),t1.e) FROM t1 WHERE NOT (not exists(select 1 from t1 where not (t1.e<t1.b and t1.e<>t1.b+case (select count(distinct e)*cast(avg(case c when e then case a when f then b else d end-a-13 else 13 end*t1.a+ -t1.d) AS integer) from t1)+c | (t1.f)*f when -c then d else 19 end) and -17 in (select min(t1.b) from t1 union select count(distinct f) from t1)))}
+} {}
+do_test randexpr-2.1536 {
+ db eval {SELECT coalesce((select t1.e from t1 where (case when 19>=t1.c then t1.d else coalesce((select max(11*t1.b) from t1 where case ~t1.c-(select max(11) from t1)*~t1.b+f*~coalesce((select max(d) from t1 where d>=b),d)-t1.a*t1.c*t1.d when -t1.c then 13 else f end in (select b from t1 union select 13 from t1)),t1.f) end & b<>a)),t1.e) FROM t1 WHERE not exists(select 1 from t1 where not (t1.e<t1.b and t1.e<>t1.b+case (select count(distinct e)*cast(avg(case c when e then case a when f then b else d end-a-13 else 13 end*t1.a+ -t1.d) AS integer) from t1)+c | (t1.f)*f when -c then d else 19 end) and -17 in (select min(t1.b) from t1 union select count(distinct f) from t1))}
+} {500}
+do_test randexpr-2.1537 {
+ db eval {SELECT coalesce((select t1.c from t1 where f between case when (abs(coalesce((select 11* -~coalesce((select a*case coalesce((select max(a) from t1 where exists(select 1 from t1 where e in (17,t1.b,13))), -t1.e) when -a then d else c end from t1 where t1.a>=t1.e),17)+t1.a-t1.d from t1 where exists(select 1 from t1 where -b>t1.b)),e))/abs(d))<>17 then t1.d when 11< -f then d else d end*d and 17),b)-f-t1.d FROM t1 WHERE case when e<t1.d then t1.a when t1.f>=(abs(t1.b)/abs((abs(t1.f)/abs( -case b when 19 then ((abs((case when (+case when f between e and c then t1.f when t1.b>19 then t1.e else t1.f end+11+t1.a in (select t1.c from t1 union select f from t1)) then e-(13) when not exists(select 1 from t1 where not exists(select 1 from t1 where (13)>t1.f)) then t1.c else t1.f end))/abs(t1.d))) else c end)))) then b else (t1.d) end not between t1.a and t1.a}
+} {-800}
+do_test randexpr-2.1538 {
+ db eval {SELECT coalesce((select t1.c from t1 where f between case when (abs(coalesce((select 11* -~coalesce((select a*case coalesce((select max(a) from t1 where exists(select 1 from t1 where e in (17,t1.b,13))), -t1.e) when -a then d else c end from t1 where t1.a>=t1.e),17)+t1.a-t1.d from t1 where exists(select 1 from t1 where -b>t1.b)),e))/abs(d))<>17 then t1.d when 11< -f then d else d end*d and 17),b)-f-t1.d FROM t1 WHERE NOT (case when e<t1.d then t1.a when t1.f>=(abs(t1.b)/abs((abs(t1.f)/abs( -case b when 19 then ((abs((case when (+case when f between e and c then t1.f when t1.b>19 then t1.e else t1.f end+11+t1.a in (select t1.c from t1 union select f from t1)) then e-(13) when not exists(select 1 from t1 where not exists(select 1 from t1 where (13)>t1.f)) then t1.c else t1.f end))/abs(t1.d))) else c end)))) then b else (t1.d) end not between t1.a and t1.a)}
+} {}
+do_test randexpr-2.1539 {
+ db eval {SELECT case when not exists(select 1 from t1 where (coalesce((select max(coalesce((select 11 from t1 where t1.b*t1.d<=+case t1.c when (select max(case when not exists(select 1 from t1 where e=t1.b) then t1.a else f end) from t1)*t1.b | t1.a then 17 else 13 end-f | t1.e),13)) from t1 where a in (t1.b,t1.b,(t1.e))),11)*11 not in (d,t1.a,17))) then 13 when c in (select e from t1 union select t1.d from t1) then 19 else 13 end FROM t1 WHERE not exists(select 1 from t1 where case when -b*13>+d then t1.e else coalesce((select case when not exists(select 1 from t1 where 11 in (c,+case when (case when e between t1.b and f then t1.a when t1.c not in (a,(c),t1.a) then -t1.b else t1.a end<>d or f>e) then t1.e else t1.c end,t1.b)) then 19 else -17 end*t1.d from t1 where (17 in (19,17,t1.f))),(t1.e)) end between 11 and t1.b and t1.a<>b)}
+} {13}
+do_test randexpr-2.1540 {
+ db eval {SELECT case when not exists(select 1 from t1 where (coalesce((select max(coalesce((select 11 from t1 where t1.b*t1.d<=+case t1.c when (select max(case when not exists(select 1 from t1 where e=t1.b) then t1.a else f end) from t1)*t1.b | t1.a then 17 else 13 end-f | t1.e),13)) from t1 where a in (t1.b,t1.b,(t1.e))),11)*11 not in (d,t1.a,17))) then 13 when c in (select e from t1 union select t1.d from t1) then 19 else 13 end FROM t1 WHERE NOT (not exists(select 1 from t1 where case when -b*13>+d then t1.e else coalesce((select case when not exists(select 1 from t1 where 11 in (c,+case when (case when e between t1.b and f then t1.a when t1.c not in (a,(c),t1.a) then -t1.b else t1.a end<>d or f>e) then t1.e else t1.c end,t1.b)) then 19 else -17 end*t1.d from t1 where (17 in (19,17,t1.f))),(t1.e)) end between 11 and t1.b and t1.a<>b))}
+} {}
+do_test randexpr-2.1541 {
+ db eval {SELECT case when not exists(select 1 from t1 where (coalesce((select max(coalesce((select 11 from t1 where t1.b*t1.d<=+case t1.c when (select max(case when not exists(select 1 from t1 where e=t1.b) then t1.a else f end) from t1)*t1.b & t1.a then 17 else 13 end-f & t1.e),13)) from t1 where a in (t1.b,t1.b,(t1.e))),11)*11 not in (d,t1.a,17))) then 13 when c in (select e from t1 union select t1.d from t1) then 19 else 13 end FROM t1 WHERE not exists(select 1 from t1 where case when -b*13>+d then t1.e else coalesce((select case when not exists(select 1 from t1 where 11 in (c,+case when (case when e between t1.b and f then t1.a when t1.c not in (a,(c),t1.a) then -t1.b else t1.a end<>d or f>e) then t1.e else t1.c end,t1.b)) then 19 else -17 end*t1.d from t1 where (17 in (19,17,t1.f))),(t1.e)) end between 11 and t1.b and t1.a<>b)}
+} {13}
+do_test randexpr-2.1542 {
+ db eval {SELECT a-coalesce((select max(++19) from t1 where (select count(distinct coalesce((select max(t1.c) from t1 where not (t1.c+t1.c)-case when (not coalesce((select max(t1.a-t1.a) from t1 where t1.d>t1.b),e) in (t1.d,19,(t1.e))) then b when exists(select 1 from t1 where t1.e> -13) then c else e end<>c),17)) from t1) not between 19 and t1.f),t1.b) | 19-t1.d*f+b FROM t1 WHERE t1.f | coalesce((select case when c>=t1.f then t1.e+t1.e when -19 | (a)+t1.f in (b,coalesce((select t1.c | (f+e)-e*17 from t1 where -c not in (t1.d,c,(13))),19),t1.e) then t1.c else 17 end+b from t1 where t1.a not in (17,d,c)),17) in (select f from t1 union select f from t1)}
+} {}
+do_test randexpr-2.1543 {
+ db eval {SELECT a-coalesce((select max(++19) from t1 where (select count(distinct coalesce((select max(t1.c) from t1 where not (t1.c+t1.c)-case when (not coalesce((select max(t1.a-t1.a) from t1 where t1.d>t1.b),e) in (t1.d,19,(t1.e))) then b when exists(select 1 from t1 where t1.e> -13) then c else e end<>c),17)) from t1) not between 19 and t1.f),t1.b) | 19-t1.d*f+b FROM t1 WHERE NOT (t1.f | coalesce((select case when c>=t1.f then t1.e+t1.e when -19 | (a)+t1.f in (b,coalesce((select t1.c | (f+e)-e*17 from t1 where -c not in (t1.d,c,(13))),19),t1.e) then t1.c else 17 end+b from t1 where t1.a not in (17,d,c)),17) in (select f from t1 union select f from t1))}
+} {-239781}
+do_test randexpr-2.1544 {
+ db eval {SELECT a-coalesce((select max(++19) from t1 where (select count(distinct coalesce((select max(t1.c) from t1 where not (t1.c+t1.c)-case when (not coalesce((select max(t1.a-t1.a) from t1 where t1.d>t1.b),e) in (t1.d,19,(t1.e))) then b when exists(select 1 from t1 where t1.e> -13) then c else e end<>c),17)) from t1) not between 19 and t1.f),t1.b) & 19-t1.d*f+b FROM t1 WHERE NOT (t1.f | coalesce((select case when c>=t1.f then t1.e+t1.e when -19 | (a)+t1.f in (b,coalesce((select t1.c | (f+e)-e*17 from t1 where -c not in (t1.d,c,(13))),19),t1.e) then t1.c else 17 end+b from t1 where t1.a not in (17,d,c)),17) in (select f from t1 union select f from t1))}
+} {81}
+do_test randexpr-2.1545 {
+ db eval {SELECT coalesce((select (t1.d) from t1 where not not case when c<coalesce((select f from t1 where 13 | t1.d in (select 11*t1.f*case when exists(select 1 from t1 where d>=case when f<>( -t1.c) then c when 19<>t1.d then t1.f else d end) then e-f when c in (select d from t1 union select f from t1) then a else t1.b end | t1.a-f from t1 union select -19 from t1)),19) then 19 when 11 between f and t1.f then t1.c else 19 end=a),t1.f) FROM t1 WHERE coalesce((select t1.d from t1 where (case when exists(select 1 from t1 where not - -19 in (17,f,t1.b)) and 19>c or t1.c in (select t1.e from t1 union select 17 from t1) then a when exists(select 1 from t1 where (t1.c<>d)) and -t1.c not between b and e then 11 else (select cast(avg((abs(b)/abs(d))) AS integer) from t1) end+t1.d not in (t1.f,11,b) and f not between 17 and t1.d)),t1.e)=t1.a}
+} {}
+do_test randexpr-2.1546 {
+ db eval {SELECT coalesce((select (t1.d) from t1 where not not case when c<coalesce((select f from t1 where 13 | t1.d in (select 11*t1.f*case when exists(select 1 from t1 where d>=case when f<>( -t1.c) then c when 19<>t1.d then t1.f else d end) then e-f when c in (select d from t1 union select f from t1) then a else t1.b end | t1.a-f from t1 union select -19 from t1)),19) then 19 when 11 between f and t1.f then t1.c else 19 end=a),t1.f) FROM t1 WHERE NOT (coalesce((select t1.d from t1 where (case when exists(select 1 from t1 where not - -19 in (17,f,t1.b)) and 19>c or t1.c in (select t1.e from t1 union select 17 from t1) then a when exists(select 1 from t1 where (t1.c<>d)) and -t1.c not between b and e then 11 else (select cast(avg((abs(b)/abs(d))) AS integer) from t1) end+t1.d not in (t1.f,11,b) and f not between 17 and t1.d)),t1.e)=t1.a)}
+} {600}
+do_test randexpr-2.1547 {
+ db eval {SELECT coalesce((select (t1.d) from t1 where not not case when c<coalesce((select f from t1 where 13 & t1.d in (select 11*t1.f*case when exists(select 1 from t1 where d>=case when f<>( -t1.c) then c when 19<>t1.d then t1.f else d end) then e-f when c in (select d from t1 union select f from t1) then a else t1.b end & t1.a-f from t1 union select -19 from t1)),19) then 19 when 11 between f and t1.f then t1.c else 19 end=a),t1.f) FROM t1 WHERE NOT (coalesce((select t1.d from t1 where (case when exists(select 1 from t1 where not - -19 in (17,f,t1.b)) and 19>c or t1.c in (select t1.e from t1 union select 17 from t1) then a when exists(select 1 from t1 where (t1.c<>d)) and -t1.c not between b and e then 11 else (select cast(avg((abs(b)/abs(d))) AS integer) from t1) end+t1.d not in (t1.f,11,b) and f not between 17 and t1.d)),t1.e)=t1.a)}
+} {600}
+do_test randexpr-2.1548 {
+ db eval {SELECT coalesce((select max(case when -++t1.c++(abs(case when t1.b<case when exists(select 1 from t1 where -t1.b-13=t1.e) then t1.b else c end then t1.f else case when t1.a<t1.b+t1.d then 19 when t1.f not in (t1.c,c,c) then t1.d else t1.f end end)/abs(19))*b-d>b then 11 else b end) from t1 where ((t1.b)) between e and e),t1.e) FROM t1 WHERE not ~t1.c-(coalesce((select max(~case t1.e | b*11+d+19 when t1.a then t1.b else t1.d end) from t1 where (13 not in (t1.a,t1.a,13))),e)) not between t1.a and 11 or exists(select 1 from t1 where (t1.d) not in (11,13,t1.a) and (c<>b or -13<>t1.b and c in (t1.f, -c,t1.d)))}
+} {500}
+do_test randexpr-2.1549 {
+ db eval {SELECT coalesce((select max(case when -++t1.c++(abs(case when t1.b<case when exists(select 1 from t1 where -t1.b-13=t1.e) then t1.b else c end then t1.f else case when t1.a<t1.b+t1.d then 19 when t1.f not in (t1.c,c,c) then t1.d else t1.f end end)/abs(19))*b-d>b then 11 else b end) from t1 where ((t1.b)) between e and e),t1.e) FROM t1 WHERE NOT (not ~t1.c-(coalesce((select max(~case t1.e | b*11+d+19 when t1.a then t1.b else t1.d end) from t1 where (13 not in (t1.a,t1.a,13))),e)) not between t1.a and 11 or exists(select 1 from t1 where (t1.d) not in (11,13,t1.a) and (c<>b or -13<>t1.b and c in (t1.f, -c,t1.d))))}
+} {}
+do_test randexpr-2.1550 {
+ db eval {SELECT case 19*d-+t1.a | coalesce((select f from t1 where +b between coalesce((select +t1.f from t1 where not exists(select 1 from t1 where case 17 when b then f else f end>=~13)),t1.f) and t1.d),c+11)- -t1.e | 17+case t1.b when t1.a then 17 else t1.f end*t1.c+a when f then -f else t1.f end | t1.b FROM t1 WHERE t1.f=f and not exists(select 1 from t1 where case when t1.b>e then (abs(13)/abs(t1.f | 17))+(t1.f) else ~t1.a-(~e) end in (select count(distinct coalesce((select max(coalesce((select 11 from t1 where t1.a<d),(b))*17) from t1 where (e in (select count(*) from t1 union select max(t1.a)-cast(avg(17) AS integer)-(cast(avg(11) AS integer)) from t1))),t1.d)) from t1 union select cast(avg(c) AS integer) from t1)) and e between c and f}
+} {728}
+do_test randexpr-2.1551 {
+ db eval {SELECT case 19*d-+t1.a | coalesce((select f from t1 where +b between coalesce((select +t1.f from t1 where not exists(select 1 from t1 where case 17 when b then f else f end>=~13)),t1.f) and t1.d),c+11)- -t1.e | 17+case t1.b when t1.a then 17 else t1.f end*t1.c+a when f then -f else t1.f end | t1.b FROM t1 WHERE NOT (t1.f=f and not exists(select 1 from t1 where case when t1.b>e then (abs(13)/abs(t1.f | 17))+(t1.f) else ~t1.a-(~e) end in (select count(distinct coalesce((select max(coalesce((select 11 from t1 where t1.a<d),(b))*17) from t1 where (e in (select count(*) from t1 union select max(t1.a)-cast(avg(17) AS integer)-(cast(avg(11) AS integer)) from t1))),t1.d)) from t1 union select cast(avg(c) AS integer) from t1)) and e between c and f)}
+} {}
+do_test randexpr-2.1552 {
+ db eval {SELECT case 19*d-+t1.a & coalesce((select f from t1 where +b between coalesce((select +t1.f from t1 where not exists(select 1 from t1 where case 17 when b then f else f end>=~13)),t1.f) and t1.d),c+11)- -t1.e & 17+case t1.b when t1.a then 17 else t1.f end*t1.c+a when f then -f else t1.f end & t1.b FROM t1 WHERE t1.f=f and not exists(select 1 from t1 where case when t1.b>e then (abs(13)/abs(t1.f | 17))+(t1.f) else ~t1.a-(~e) end in (select count(distinct coalesce((select max(coalesce((select 11 from t1 where t1.a<d),(b))*17) from t1 where (e in (select count(*) from t1 union select max(t1.a)-cast(avg(17) AS integer)-(cast(avg(11) AS integer)) from t1))),t1.d)) from t1 union select cast(avg(c) AS integer) from t1)) and e between c and f}
+} {72}
+do_test randexpr-2.1553 {
+ db eval {SELECT (coalesce((select max(coalesce((select (abs(t1.e* -b*coalesce((select max( -t1.e*t1.e+t1.f) from t1 where -case when b>=t1.e and e>f then 11 | 19 else t1.c end | b in (select a from t1 union select 13 from t1)),b)+t1.b | (d)*11)/abs(e)) from t1 where a=19),t1.e)*13) from t1 where 13>f),t1.f)) FROM t1 WHERE coalesce((select max(~t1.a*t1.f*t1.b+f+a) from t1 where case when d in (select -+count(distinct (t1.c))*max(t1.e+b)-(( -count(distinct 17))) from t1 union select -count(distinct t1.d) from t1) then t1.d else (abs(case when t1.e in (select t1.c from t1 union select c from t1) then c else d end)/abs(f)) end in (select max( -c) from t1 union select abs(count(distinct 19)) from t1)), -a) not in (d,t1.f,13)}
+} {600}
+do_test randexpr-2.1554 {
+ db eval {SELECT (coalesce((select max(coalesce((select (abs(t1.e* -b*coalesce((select max( -t1.e*t1.e+t1.f) from t1 where -case when b>=t1.e and e>f then 11 | 19 else t1.c end | b in (select a from t1 union select 13 from t1)),b)+t1.b | (d)*11)/abs(e)) from t1 where a=19),t1.e)*13) from t1 where 13>f),t1.f)) FROM t1 WHERE NOT (coalesce((select max(~t1.a*t1.f*t1.b+f+a) from t1 where case when d in (select -+count(distinct (t1.c))*max(t1.e+b)-(( -count(distinct 17))) from t1 union select -count(distinct t1.d) from t1) then t1.d else (abs(case when t1.e in (select t1.c from t1 union select c from t1) then c else d end)/abs(f)) end in (select max( -c) from t1 union select abs(count(distinct 19)) from t1)), -a) not in (d,t1.f,13))}
+} {}
+do_test randexpr-2.1555 {
+ db eval {SELECT (coalesce((select max(coalesce((select (abs(t1.e* -b*coalesce((select max( -t1.e*t1.e+t1.f) from t1 where -case when b>=t1.e and e>f then 11 & 19 else t1.c end & b in (select a from t1 union select 13 from t1)),b)+t1.b & (d)*11)/abs(e)) from t1 where a=19),t1.e)*13) from t1 where 13>f),t1.f)) FROM t1 WHERE coalesce((select max(~t1.a*t1.f*t1.b+f+a) from t1 where case when d in (select -+count(distinct (t1.c))*max(t1.e+b)-(( -count(distinct 17))) from t1 union select -count(distinct t1.d) from t1) then t1.d else (abs(case when t1.e in (select t1.c from t1 union select c from t1) then c else d end)/abs(f)) end in (select max( -c) from t1 union select abs(count(distinct 19)) from t1)), -a) not in (d,t1.f,13)}
+} {600}
+do_test randexpr-2.1556 {
+ db eval {SELECT +(abs(17*(abs(a | t1.a)/abs(11)) | f)/abs(coalesce((select +t1.b+~a from t1 where case when a=t1.b then c when t1.d=t1.e then t1.b else 17 end<=t1.f and (b<>13) or t1.a<>a or t1.d>d and 11 between 17 and t1.a and t1.b<> -e and -13<(17)),a)+ -t1.e))*(t1.c) FROM t1 WHERE not a not between t1.a and 11+ -coalesce((select -c*coalesce((select max(~f*a+11-t1.a | -a+t1.a*t1.b*f) from t1 where 11=11),t1.a)+d from t1 where 13>=e),d) | t1.b or t1.a not between -b and f or 17<>13}
+} {300}
+do_test randexpr-2.1557 {
+ db eval {SELECT +(abs(17*(abs(a | t1.a)/abs(11)) | f)/abs(coalesce((select +t1.b+~a from t1 where case when a=t1.b then c when t1.d=t1.e then t1.b else 17 end<=t1.f and (b<>13) or t1.a<>a or t1.d>d and 11 between 17 and t1.a and t1.b<> -e and -13<(17)),a)+ -t1.e))*(t1.c) FROM t1 WHERE NOT (not a not between t1.a and 11+ -coalesce((select -c*coalesce((select max(~f*a+11-t1.a | -a+t1.a*t1.b*f) from t1 where 11=11),t1.a)+d from t1 where 13>=e),d) | t1.b or t1.a not between -b and f or 17<>13)}
+} {}
+do_test randexpr-2.1558 {
+ db eval {SELECT +(abs(17*(abs(a & t1.a)/abs(11)) & f)/abs(coalesce((select +t1.b+~a from t1 where case when a=t1.b then c when t1.d=t1.e then t1.b else 17 end<=t1.f and (b<>13) or t1.a<>a or t1.d>d and 11 between 17 and t1.a and t1.b<> -e and -13<(17)),a)+ -t1.e))*(t1.c) FROM t1 WHERE not a not between t1.a and 11+ -coalesce((select -c*coalesce((select max(~f*a+11-t1.a | -a+t1.a*t1.b*f) from t1 where 11=11),t1.a)+d from t1 where 13>=e),d) | t1.b or t1.a not between -b and f or 17<>13}
+} {0}
+do_test randexpr-2.1559 {
+ db eval {SELECT b-case e*13+case when not not t1.d in (select t1.b from t1 union select f from t1) then t1.c when coalesce((select max(coalesce((select (select ~min(coalesce((select max(a*f) from t1 where t1.f<=t1.b or a<=f),t1.a)) | -(count(distinct 19)) from t1) from t1 where f between (t1.f) and 11),a)) from t1 where 11 not in (f, -11,19)),e)>=d then t1.f else t1.c end when -a then 11 else t1.e end FROM t1 WHERE coalesce((select case case when case when (coalesce((select max(t1.e) from t1 where c>c and -19>= -a),d) not in (11,t1.b,t1.a)) then d else a end between 11 and t1.c then b else a end+13-t1.a when t1.d then (b) else t1.d end from t1 where b between e and t1.f),11) in (select (+abs(count(*)+case -count(distinct t1.e) when -(max(19)) then (count(distinct 19)) else -count(distinct e) end-max(t1.b)) | count(distinct t1.e) | (cast(avg(11) AS integer))) from t1 union select cast(avg(c) AS integer) from t1)}
+} {}
+do_test randexpr-2.1560 {
+ db eval {SELECT b-case e*13+case when not not t1.d in (select t1.b from t1 union select f from t1) then t1.c when coalesce((select max(coalesce((select (select ~min(coalesce((select max(a*f) from t1 where t1.f<=t1.b or a<=f),t1.a)) | -(count(distinct 19)) from t1) from t1 where f between (t1.f) and 11),a)) from t1 where 11 not in (f, -11,19)),e)>=d then t1.f else t1.c end when -a then 11 else t1.e end FROM t1 WHERE NOT (coalesce((select case case when case when (coalesce((select max(t1.e) from t1 where c>c and -19>= -a),d) not in (11,t1.b,t1.a)) then d else a end between 11 and t1.c then b else a end+13-t1.a when t1.d then (b) else t1.d end from t1 where b between e and t1.f),11) in (select (+abs(count(*)+case -count(distinct t1.e) when -(max(19)) then (count(distinct 19)) else -count(distinct e) end-max(t1.b)) | count(distinct t1.e) | (cast(avg(11) AS integer))) from t1 union select cast(avg(c) AS integer) from t1))}
+} {-300}
+do_test randexpr-2.1561 {
+ db eval {SELECT b-case e*13+case when not not t1.d in (select t1.b from t1 union select f from t1) then t1.c when coalesce((select max(coalesce((select (select ~min(coalesce((select max(a*f) from t1 where t1.f<=t1.b or a<=f),t1.a)) & -(count(distinct 19)) from t1) from t1 where f between (t1.f) and 11),a)) from t1 where 11 not in (f, -11,19)),e)>=d then t1.f else t1.c end when -a then 11 else t1.e end FROM t1 WHERE NOT (coalesce((select case case when case when (coalesce((select max(t1.e) from t1 where c>c and -19>= -a),d) not in (11,t1.b,t1.a)) then d else a end between 11 and t1.c then b else a end+13-t1.a when t1.d then (b) else t1.d end from t1 where b between e and t1.f),11) in (select (+abs(count(*)+case -count(distinct t1.e) when -(max(19)) then (count(distinct 19)) else -count(distinct e) end-max(t1.b)) | count(distinct t1.e) | (cast(avg(11) AS integer))) from t1 union select cast(avg(c) AS integer) from t1))}
+} {-300}
+do_test randexpr-2.1562 {
+ db eval {SELECT coalesce((select case when a not in (~17,a,c) then b when t1.c<>t1.f-13 then +f else 11 end+t1.e*t1.a+case when ((a-c)>case when (exists(select 1 from t1 where (c) between d and -t1.b)) then a+t1.f else f end) or e between t1.c and 13 then -t1.c else t1.e end-t1.d from t1 where ( -17=a)),e) FROM t1 WHERE +case when not exists(select 1 from t1 where f+(select ~ -min(b) | abs(+max(+c)) from t1)+b not between 13-a*17 and t1.e-t1.b) then t1.a when b not between ((11)) and 11 then 13 else 17 end+ - -t1.f in (f,t1.d,f) or t1.b>t1.a and not exists(select 1 from t1 where t1.d in (t1.c,d,t1.c))}
+} {}
+do_test randexpr-2.1563 {
+ db eval {SELECT coalesce((select case when a not in (~17,a,c) then b when t1.c<>t1.f-13 then +f else 11 end+t1.e*t1.a+case when ((a-c)>case when (exists(select 1 from t1 where (c) between d and -t1.b)) then a+t1.f else f end) or e between t1.c and 13 then -t1.c else t1.e end-t1.d from t1 where ( -17=a)),e) FROM t1 WHERE NOT (+case when not exists(select 1 from t1 where f+(select ~ -min(b) | abs(+max(+c)) from t1)+b not between 13-a*17 and t1.e-t1.b) then t1.a when b not between ((11)) and 11 then 13 else 17 end+ - -t1.f in (f,t1.d,f) or t1.b>t1.a and not exists(select 1 from t1 where t1.d in (t1.c,d,t1.c)))}
+} {500}
+do_test randexpr-2.1564 {
+ db eval {SELECT case coalesce((select 19-case when case when f in (select t1.c from t1 union select (select count(*) from t1) from t1) then a+e else 19 end*19-19-13 not in (11,19,a) then f when (13<>(t1.c) or d>e and b=b) then t1.a else 13 end from t1 where (not exists(select 1 from t1 where not exists(select 1 from t1 where t1.a=17)))),a) when t1.d then 19 else e end FROM t1 WHERE 13-coalesce((select (abs(19)/abs(11)) from t1 where case when a in (select d from t1 union select case when -11-11<>d or t1.e between (t1.d) and b then t1.f else f end from t1) then t1.e else -a end not between 13 and 19 or exists(select 1 from t1 where f< -( -t1.d)) and t1.a not between -e and t1.e or t1.f<f and 13=13 and t1.f>(t1.f)),t1.d)=11}
+} {}
+do_test randexpr-2.1565 {
+ db eval {SELECT case coalesce((select 19-case when case when f in (select t1.c from t1 union select (select count(*) from t1) from t1) then a+e else 19 end*19-19-13 not in (11,19,a) then f when (13<>(t1.c) or d>e and b=b) then t1.a else 13 end from t1 where (not exists(select 1 from t1 where not exists(select 1 from t1 where t1.a=17)))),a) when t1.d then 19 else e end FROM t1 WHERE NOT (13-coalesce((select (abs(19)/abs(11)) from t1 where case when a in (select d from t1 union select case when -11-11<>d or t1.e between (t1.d) and b then t1.f else f end from t1) then t1.e else -a end not between 13 and 19 or exists(select 1 from t1 where f< -( -t1.d)) and t1.a not between -e and t1.e or t1.f<f and 13=13 and t1.f>(t1.f)),t1.d)=11)}
+} {500}
+do_test randexpr-2.1566 {
+ db eval {SELECT (select -count(distinct -case (select (max( -c-t1.b+~f)*count(distinct 11) | +cast(avg(11) AS integer)-min(t1.f)+ -(cast(avg(( -11)) AS integer))-count(distinct t1.d)*(max(13))*(max(d))-(count(*))-min(e)) from t1) when + -c then t1.d else t1.b*19 end-a | t1.d+t1.d) from t1) FROM t1 WHERE not 11-t1.a=a+11}
+} {-1}
+do_test randexpr-2.1567 {
+ db eval {SELECT (select -count(distinct -case (select (max( -c-t1.b+~f)*count(distinct 11) | +cast(avg(11) AS integer)-min(t1.f)+ -(cast(avg(( -11)) AS integer))-count(distinct t1.d)*(max(13))*(max(d))-(count(*))-min(e)) from t1) when + -c then t1.d else t1.b*19 end-a | t1.d+t1.d) from t1) FROM t1 WHERE NOT (not 11-t1.a=a+11)}
+} {}
+do_test randexpr-2.1568 {
+ db eval {SELECT (select -count(distinct -case (select (max( -c-t1.b+~f)*count(distinct 11) & +cast(avg(11) AS integer)-min(t1.f)+ -(cast(avg(( -11)) AS integer))-count(distinct t1.d)*(max(13))*(max(d))-(count(*))-min(e)) from t1) when + -c then t1.d else t1.b*19 end-a & t1.d+t1.d) from t1) FROM t1 WHERE not 11-t1.a=a+11}
+} {-1}
+do_test randexpr-2.1569 {
+ db eval {SELECT (select ~count(distinct t1.d*e+19)+abs(+cast(avg((select (count(*)) from t1)) AS integer)-cast(avg(t1.c) AS integer) | min(case when d | f* -19 in (select min(c) from t1 union select ~count(*)-max(17) from t1) then t1.e when (t1.b between 17 and (b)) then t1.d else t1.d end)*cast(avg(e) AS integer))-count(distinct t1.f) | cast(avg( -d) AS integer)*cast(avg(f) AS integer) from t1)*t1.e FROM t1 WHERE coalesce((select 17 from t1 where coalesce((select max(case when 13-b+coalesce((select case when (f>a) then t1.f when t1.c<=19 then a else a end from t1 where c in (select (e) from t1 union select 13 from t1)),13)<13 then 13 else t1.b end) from t1 where (13)<>13),17) in (select +min(b) from t1 union select ~max(t1.d)*max( -t1.b)*min(t1.e) from t1) and e>c),f) between ((t1.f)) and b and t1.a=19}
+} {}
+do_test randexpr-2.1570 {
+ db eval {SELECT (select ~count(distinct t1.d*e+19)+abs(+cast(avg((select (count(*)) from t1)) AS integer)-cast(avg(t1.c) AS integer) | min(case when d | f* -19 in (select min(c) from t1 union select ~count(*)-max(17) from t1) then t1.e when (t1.b between 17 and (b)) then t1.d else t1.d end)*cast(avg(e) AS integer))-count(distinct t1.f) | cast(avg( -d) AS integer)*cast(avg(f) AS integer) from t1)*t1.e FROM t1 WHERE NOT (coalesce((select 17 from t1 where coalesce((select max(case when 13-b+coalesce((select case when (f>a) then t1.f when t1.c<=19 then a else a end from t1 where c in (select (e) from t1 union select 13 from t1)),13)<13 then 13 else t1.b end) from t1 where (13)<>13),17) in (select +min(b) from t1 union select ~max(t1.d)*max( -t1.b)*min(t1.e) from t1) and e>c),f) between ((t1.f)) and b and t1.a=19)}
+} {-119980000}
+do_test randexpr-2.1571 {
+ db eval {SELECT (select ~count(distinct t1.d*e+19)+abs(+cast(avg((select (count(*)) from t1)) AS integer)-cast(avg(t1.c) AS integer) & min(case when d & f* -19 in (select min(c) from t1 union select ~count(*)-max(17) from t1) then t1.e when (t1.b between 17 and (b)) then t1.d else t1.d end)*cast(avg(e) AS integer))-count(distinct t1.f) & cast(avg( -d) AS integer)*cast(avg(f) AS integer) from t1)*t1.e FROM t1 WHERE NOT (coalesce((select 17 from t1 where coalesce((select max(case when 13-b+coalesce((select case when (f>a) then t1.f when t1.c<=19 then a else a end from t1 where c in (select (e) from t1 union select 13 from t1)),13)<13 then 13 else t1.b end) from t1 where (13)<>13),17) in (select +min(b) from t1 union select ~max(t1.d)*max( -t1.b)*min(t1.e) from t1) and e>c),f) between ((t1.f)) and b and t1.a=19)}
+} {512000}
+do_test randexpr-2.1572 {
+ db eval {SELECT coalesce((select d from t1 where case when (17 between c+t1.d-t1.a and b and t1.b in (13,t1.d,19)) then case when t1.c<(a) then t1.c when t1.e not in (a,11,(t1.d)) then t1.d else d end else t1.a end in (select abs(min(a) | ~~count(distinct t1.e)+min(b)-count(*)) from t1 union select count(*) from t1) and not exists(select 1 from t1 where (t1.a) between t1.a and t1.d)),t1.f)-t1.a FROM t1 WHERE case when t1.e not in (coalesce((select max(coalesce((select max(b+t1.c-19*(e)-~11) from t1 where t1.a in (select ~cast(avg(~t1.a) AS integer) from t1 union select abs(~cast(avg(f) AS integer)) from t1)),e)* -c-c-b-t1.d-f) from t1 where t1.f>=t1.c),((t1.d)))- - -19,17,t1.b) then b else t1.f end<d}
+} {500}
+do_test randexpr-2.1573 {
+ db eval {SELECT coalesce((select d from t1 where case when (17 between c+t1.d-t1.a and b and t1.b in (13,t1.d,19)) then case when t1.c<(a) then t1.c when t1.e not in (a,11,(t1.d)) then t1.d else d end else t1.a end in (select abs(min(a) | ~~count(distinct t1.e)+min(b)-count(*)) from t1 union select count(*) from t1) and not exists(select 1 from t1 where (t1.a) between t1.a and t1.d)),t1.f)-t1.a FROM t1 WHERE NOT (case when t1.e not in (coalesce((select max(coalesce((select max(b+t1.c-19*(e)-~11) from t1 where t1.a in (select ~cast(avg(~t1.a) AS integer) from t1 union select abs(~cast(avg(f) AS integer)) from t1)),e)* -c-c-b-t1.d-f) from t1 where t1.f>=t1.c),((t1.d)))- - -19,17,t1.b) then b else t1.f end<d)}
+} {}
+do_test randexpr-2.1574 {
+ db eval {SELECT coalesce((select d from t1 where case when (17 between c+t1.d-t1.a and b and t1.b in (13,t1.d,19)) then case when t1.c<(a) then t1.c when t1.e not in (a,11,(t1.d)) then t1.d else d end else t1.a end in (select abs(min(a) & ~~count(distinct t1.e)+min(b)-count(*)) from t1 union select count(*) from t1) and not exists(select 1 from t1 where (t1.a) between t1.a and t1.d)),t1.f)-t1.a FROM t1 WHERE case when t1.e not in (coalesce((select max(coalesce((select max(b+t1.c-19*(e)-~11) from t1 where t1.a in (select ~cast(avg(~t1.a) AS integer) from t1 union select abs(~cast(avg(f) AS integer)) from t1)),e)* -c-c-b-t1.d-f) from t1 where t1.f>=t1.c),((t1.d)))- - -19,17,t1.b) then b else t1.f end<d}
+} {500}
+do_test randexpr-2.1575 {
+ db eval {SELECT (abs((select min(t1.a)*~+ -count(*)-max(t1.f) from t1))/abs((abs(13*~t1.c- -e-( -19) | case 17*~13 when t1.c+case when not 19 between 13 and a then t1.c when -11 not between e and 17 then 19 else a end then 19 else 17 end*19)/abs(t1.d)))) FROM t1 WHERE t1.e in (select d from t1 union select case when not exists(select 1 from t1 where c+a*17 not between case when t1.f>=(t1.f)+a then t1.d else 19 end and t1.c or exists(select 1 from t1 where (b in (13,13,b)) and (t1.f<>t1.e)) or (13)<>17 and e<=f and e<= -c) and t1.f>f then t1.e*19-t1.e-b else 17 end from t1)}
+} {}
+do_test randexpr-2.1576 {
+ db eval {SELECT (abs((select min(t1.a)*~+ -count(*)-max(t1.f) from t1))/abs((abs(13*~t1.c- -e-( -19) | case 17*~13 when t1.c+case when not 19 between 13 and a then t1.c when -11 not between e and 17 then 19 else a end then 19 else 17 end*19)/abs(t1.d)))) FROM t1 WHERE NOT (t1.e in (select d from t1 union select case when not exists(select 1 from t1 where c+a*17 not between case when t1.f>=(t1.f)+a then t1.d else 19 end and t1.c or exists(select 1 from t1 where (b in (13,13,b)) and (t1.f<>t1.e)) or (13)<>17 and e<=f and e<= -c) and t1.f>f then t1.e*19-t1.e-b else 17 end from t1))}
+} {85}
+do_test randexpr-2.1577 {
+ db eval {SELECT b-t1.b-coalesce((select (abs(case t1.c+coalesce((select +17*case when b in (select abs(max(19) | count(distinct t1.e)) | cast(avg(t1.d) AS integer) from t1 union select (count(*)) from t1) then +11+t1.a when 11<d then -b else t1.c end from t1 where t1.f not between d and t1.c),t1.d)-13*t1.b when e then t1.e else -17 end)/abs( - -d)) from t1 where (t1.a<>e)),d) FROM t1 WHERE t1.a<> -a}
+} {0}
+do_test randexpr-2.1578 {
+ db eval {SELECT b-t1.b-coalesce((select (abs(case t1.c+coalesce((select +17*case when b in (select abs(max(19) | count(distinct t1.e)) | cast(avg(t1.d) AS integer) from t1 union select (count(*)) from t1) then +11+t1.a when 11<d then -b else t1.c end from t1 where t1.f not between d and t1.c),t1.d)-13*t1.b when e then t1.e else -17 end)/abs( - -d)) from t1 where (t1.a<>e)),d) FROM t1 WHERE NOT (t1.a<> -a)}
+} {}
+do_test randexpr-2.1579 {
+ db eval {SELECT b-t1.b-coalesce((select (abs(case t1.c+coalesce((select +17*case when b in (select abs(max(19) & count(distinct t1.e)) & cast(avg(t1.d) AS integer) from t1 union select (count(*)) from t1) then +11+t1.a when 11<d then -b else t1.c end from t1 where t1.f not between d and t1.c),t1.d)-13*t1.b when e then t1.e else -17 end)/abs( - -d)) from t1 where (t1.a<>e)),d) FROM t1 WHERE t1.a<> -a}
+} {0}
+do_test randexpr-2.1580 {
+ db eval {SELECT ~(abs(b*t1.b)/abs(case when coalesce((select max((abs(a)/abs(case t1.e when t1.e then c*(t1.d) else t1.a end))) from t1 where b in (select min((t1.a)) from t1 union select + -max(b) from t1)),19)+a not between t1.e and -19 and 13<=a then (select case cast(avg((a)) AS integer) when min(e)*max(f) then -(count(distinct 13)) else cast(avg(13) AS integer) end-count(*) | count(distinct d) | -count(*) from t1) else b end)) FROM t1 WHERE f not between t1.d and b}
+} {-40001}
+do_test randexpr-2.1581 {
+ db eval {SELECT ~(abs(b*t1.b)/abs(case when coalesce((select max((abs(a)/abs(case t1.e when t1.e then c*(t1.d) else t1.a end))) from t1 where b in (select min((t1.a)) from t1 union select + -max(b) from t1)),19)+a not between t1.e and -19 and 13<=a then (select case cast(avg((a)) AS integer) when min(e)*max(f) then -(count(distinct 13)) else cast(avg(13) AS integer) end-count(*) | count(distinct d) | -count(*) from t1) else b end)) FROM t1 WHERE NOT (f not between t1.d and b)}
+} {}
+do_test randexpr-2.1582 {
+ db eval {SELECT +(abs(19)/abs(d | 11*t1.f))*t1.e-coalesce((select t1.b from t1 where not ((f*case when a>=17 then t1.c else (a) end-b not in (t1.b,t1.f,t1.f) or not exists(select 1 from t1 where t1.c>t1.a) and c not in (t1.d,t1.b,c)))),e) | coalesce((select ( - -f) from t1 where 19 not between 17 and 17),(a))-17*d*c FROM t1 WHERE t1.b>=e}
+} {}
+do_test randexpr-2.1583 {
+ db eval {SELECT +(abs(19)/abs(d | 11*t1.f))*t1.e-coalesce((select t1.b from t1 where not ((f*case when a>=17 then t1.c else (a) end-b not in (t1.b,t1.f,t1.f) or not exists(select 1 from t1 where t1.c>t1.a) and c not in (t1.d,t1.b,c)))),e) | coalesce((select ( - -f) from t1 where 19 not between 17 and 17),(a))-17*d*c FROM t1 WHERE NOT (t1.b>=e)}
+} {-100}
+do_test randexpr-2.1584 {
+ db eval {SELECT +(abs(19)/abs(d & 11*t1.f))*t1.e-coalesce((select t1.b from t1 where not ((f*case when a>=17 then t1.c else (a) end-b not in (t1.b,t1.f,t1.f) or not exists(select 1 from t1 where t1.c>t1.a) and c not in (t1.d,t1.b,c)))),e) & coalesce((select ( - -f) from t1 where 19 not between 17 and 17),(a))-17*d*c FROM t1 WHERE NOT (t1.b>=e)}
+} {-2039800}
+do_test randexpr-2.1585 {
+ db eval {SELECT (abs((abs(a)/abs(~17+t1.b-e+(abs(a)/abs(coalesce((select max(13) from t1 where c not in (c-(abs(+coalesce((select max(t1.b-f) from t1 where (abs(13+case ~t1.f when t1.c then t1.b else b end-e)/abs(c))-t1.e>t1.c),t1.c))/abs(11))+t1.b,t1.a,11)),t1.a)))))+19)/abs( - -t1.c)) FROM t1 WHERE ~t1.e+t1.a+(abs(case when d+e+17*~t1.a-t1.a-a*~(abs(~f)/abs( -13))*+(t1.c | a)*t1.b=e then t1.d when ( -e) not between c and -d then -(t1.f) else t1.b end)/abs(19))>t1.f and 11<(11)}
+} {}
+do_test randexpr-2.1586 {
+ db eval {SELECT (abs((abs(a)/abs(~17+t1.b-e+(abs(a)/abs(coalesce((select max(13) from t1 where c not in (c-(abs(+coalesce((select max(t1.b-f) from t1 where (abs(13+case ~t1.f when t1.c then t1.b else b end-e)/abs(c))-t1.e>t1.c),t1.c))/abs(11))+t1.b,t1.a,11)),t1.a)))))+19)/abs( - -t1.c)) FROM t1 WHERE NOT (~t1.e+t1.a+(abs(case when d+e+17*~t1.a-t1.a-a*~(abs(~f)/abs( -13))*+(t1.c | a)*t1.b=e then t1.d when ( -e) not between c and -d then -(t1.f) else t1.b end)/abs(19))>t1.f and 11<(11))}
+} {0}
+do_test randexpr-2.1587 {
+ db eval {SELECT (abs((abs( -t1.e)/abs(~17+b)))/abs((case 19 when case when t1.b in (select ~cast(avg(19) AS integer) from t1 union select max(t1.b) from t1) then case when case when exists(select 1 from t1 where t1.c not between d and e) then (11) when t1.d<11 then ( -t1.f) else c end in (select count(distinct 17) from t1 union select ~min(a) | max( -t1.a)- -min(b) from t1) then d else 17 end when 13> -t1.b then f else d end then (t1.b) else c end))) FROM t1 WHERE d in (b,+(abs(t1.b | t1.e)/abs(coalesce((select max(t1.b) from t1 where t1.f=(e*+t1.b-t1.d+b-t1.f-t1.a-case case a*t1.b when coalesce((select max(f) from t1 where c<11),(a)) then -t1.b else t1.f end when e then d else 19 end*t1.e+19)*d),t1.b))),t1.b)}
+} {}
+do_test randexpr-2.1588 {
+ db eval {SELECT (abs((abs( -t1.e)/abs(~17+b)))/abs((case 19 when case when t1.b in (select ~cast(avg(19) AS integer) from t1 union select max(t1.b) from t1) then case when case when exists(select 1 from t1 where t1.c not between d and e) then (11) when t1.d<11 then ( -t1.f) else c end in (select count(distinct 17) from t1 union select ~min(a) | max( -t1.a)- -min(b) from t1) then d else 17 end when 13> -t1.b then f else d end then (t1.b) else c end))) FROM t1 WHERE NOT (d in (b,+(abs(t1.b | t1.e)/abs(coalesce((select max(t1.b) from t1 where t1.f=(e*+t1.b-t1.d+b-t1.f-t1.a-case case a*t1.b when coalesce((select max(f) from t1 where c<11),(a)) then -t1.b else t1.f end when e then d else 19 end*t1.e+19)*d),t1.b))),t1.b))}
+} {0}
+do_test randexpr-2.1589 {
+ db eval {SELECT (abs((abs( -t1.e)/abs(~17+b)))/abs((case 19 when case when t1.b in (select ~cast(avg(19) AS integer) from t1 union select max(t1.b) from t1) then case when case when exists(select 1 from t1 where t1.c not between d and e) then (11) when t1.d<11 then ( -t1.f) else c end in (select count(distinct 17) from t1 union select ~min(a) & max( -t1.a)- -min(b) from t1) then d else 17 end when 13> -t1.b then f else d end then (t1.b) else c end))) FROM t1 WHERE NOT (d in (b,+(abs(t1.b | t1.e)/abs(coalesce((select max(t1.b) from t1 where t1.f=(e*+t1.b-t1.d+b-t1.f-t1.a-case case a*t1.b when coalesce((select max(f) from t1 where c<11),(a)) then -t1.b else t1.f end when e then d else 19 end*t1.e+19)*d),t1.b))),t1.b))}
+} {0}
+do_test randexpr-2.1590 {
+ db eval {SELECT c | case when e<=(abs(case when case when not exists(select 1 from t1 where case when t1.f>case when 19>=17 or f in (19,c,t1.d) then t1.b else b end then t1.e else -t1.b end*t1.d in (select t1.e from t1 union select c from t1)) then e else f end<>t1.d then -a when (11 in (select b from t1 union select a from t1)) then 19 else t1.a end-(c))/abs(c))+t1.d | t1.a then -19 else 17 end+t1.d-(t1.a) FROM t1 WHERE coalesce((select 13 from t1 where not exists(select 1 from t1 where t1.e*t1.d*t1.f>=(11) and d in (13,coalesce((select t1.f+t1.b from t1 where coalesce((select max(t1.a) from t1 where not (t1.d)<=t1.c),c) not in (t1.e,t1.d,b)),b)+f,d)) or (t1.f>f) or 11<=t1.d and 17<>13),a)<(t1.a)}
+} {317}
+do_test randexpr-2.1591 {
+ db eval {SELECT c | case when e<=(abs(case when case when not exists(select 1 from t1 where case when t1.f>case when 19>=17 or f in (19,c,t1.d) then t1.b else b end then t1.e else -t1.b end*t1.d in (select t1.e from t1 union select c from t1)) then e else f end<>t1.d then -a when (11 in (select b from t1 union select a from t1)) then 19 else t1.a end-(c))/abs(c))+t1.d | t1.a then -19 else 17 end+t1.d-(t1.a) FROM t1 WHERE NOT (coalesce((select 13 from t1 where not exists(select 1 from t1 where t1.e*t1.d*t1.f>=(11) and d in (13,coalesce((select t1.f+t1.b from t1 where coalesce((select max(t1.a) from t1 where not (t1.d)<=t1.c),c) not in (t1.e,t1.d,b)),b)+f,d)) or (t1.f>f) or 11<=t1.d and 17<>13),a)<(t1.a))}
+} {}
+do_test randexpr-2.1592 {
+ db eval {SELECT c & case when e<=(abs(case when case when not exists(select 1 from t1 where case when t1.f>case when 19>=17 or f in (19,c,t1.d) then t1.b else b end then t1.e else -t1.b end*t1.d in (select t1.e from t1 union select c from t1)) then e else f end<>t1.d then -a when (11 in (select b from t1 union select a from t1)) then 19 else t1.a end-(c))/abs(c))+t1.d & t1.a then -19 else 17 end+t1.d-(t1.a) FROM t1 WHERE coalesce((select 13 from t1 where not exists(select 1 from t1 where t1.e*t1.d*t1.f>=(11) and d in (13,coalesce((select t1.f+t1.b from t1 where coalesce((select max(t1.a) from t1 where not (t1.d)<=t1.c),c) not in (t1.e,t1.d,b)),b)+f,d)) or (t1.f>f) or 11<=t1.d and 17<>13),a)<(t1.a)}
+} {300}
+do_test randexpr-2.1593 {
+ db eval {SELECT -+t1.f*coalesce((select 17 from t1 where b in (coalesce((select f- -11 from t1 where not exists(select 1 from t1 where t1.d*a<=(case when -17<t1.c or d in (c,t1.f,c) then 13 else 13 end-e+t1.d) or 17 in (select count(distinct t1.c) from t1 union select -count(*)-~+cast(avg(11) AS integer) | cast(avg((t1.b)) AS integer)* -cast(avg(d) AS integer)+count(distinct t1.c) from t1))),19),t1.f,e)),(f))+11-e FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where ((exists(select 1 from t1 where not b | t1.d<t1.f)))) or t1.b | f | b>=d-coalesce((select a from t1 where coalesce((select max(19) from t1 where case when 13 between coalesce((select max(b) from t1 where t1.e in (c,t1.a,17)),(a)) and ((17)) then t1.b when f=t1.b then t1.f else 17 end>t1.b),e)+b*a>=t1.a),c))}
+} {}
+do_test randexpr-2.1594 {
+ db eval {SELECT -+t1.f*coalesce((select 17 from t1 where b in (coalesce((select f- -11 from t1 where not exists(select 1 from t1 where t1.d*a<=(case when -17<t1.c or d in (c,t1.f,c) then 13 else 13 end-e+t1.d) or 17 in (select count(distinct t1.c) from t1 union select -count(*)-~+cast(avg(11) AS integer) | cast(avg((t1.b)) AS integer)* -cast(avg(d) AS integer)+count(distinct t1.c) from t1))),19),t1.f,e)),(f))+11-e FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where ((exists(select 1 from t1 where not b | t1.d<t1.f)))) or t1.b | f | b>=d-coalesce((select a from t1 where coalesce((select max(19) from t1 where case when 13 between coalesce((select max(b) from t1 where t1.e in (c,t1.a,17)),(a)) and ((17)) then t1.b when f=t1.b then t1.f else 17 end>t1.b),e)+b*a>=t1.a),c)))}
+} {-360489}
+do_test randexpr-2.1595 {
+ db eval {SELECT -+t1.f*coalesce((select 17 from t1 where b in (coalesce((select f- -11 from t1 where not exists(select 1 from t1 where t1.d*a<=(case when -17<t1.c or d in (c,t1.f,c) then 13 else 13 end-e+t1.d) or 17 in (select count(distinct t1.c) from t1 union select -count(*)-~+cast(avg(11) AS integer) & cast(avg((t1.b)) AS integer)* -cast(avg(d) AS integer)+count(distinct t1.c) from t1))),19),t1.f,e)),(f))+11-e FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where ((exists(select 1 from t1 where not b | t1.d<t1.f)))) or t1.b | f | b>=d-coalesce((select a from t1 where coalesce((select max(19) from t1 where case when 13 between coalesce((select max(b) from t1 where t1.e in (c,t1.a,17)),(a)) and ((17)) then t1.b when f=t1.b then t1.f else 17 end>t1.b),e)+b*a>=t1.a),c)))}
+} {-360489}
+do_test randexpr-2.1596 {
+ db eval {SELECT ~f+coalesce((select max(17+~a+t1.b) from t1 where 17>t1.c),c+case when t1.f*d not between t1.f-13 and ~t1.b then 19 when t1.a between case coalesce((select 17 from t1 where (e in (f,e,t1.b))),13) | t1.a* - -c*t1.f-a+a when e then t1.a else 13 end and b then b else e end)-11 FROM t1 WHERE 17=19*~d-case when (exists(select 1 from t1 where 17-e not between t1.b and f) or -f not in ( -13,b,c) and t1.f not between t1.f and 13) then 13 else coalesce((select t1.f from t1 where 11 not in (a,(e),t1.f)),(t1.c)) end+t1.c or 17 in (select +(count(*)) from t1 union select ~+case -min(t1.b) when case case max(19) when cast(avg((b)) AS integer) then (count(distinct t1.b)) else -cast(avg(t1.b) AS integer) end when ( -max(t1.e)) then max(17) else -count(distinct t1.f) end then cast(avg(19) AS integer) else count(*) end-count(*) | -cast(avg(11) AS integer) from t1)}
+} {}
+do_test randexpr-2.1597 {
+ db eval {SELECT ~f+coalesce((select max(17+~a+t1.b) from t1 where 17>t1.c),c+case when t1.f*d not between t1.f-13 and ~t1.b then 19 when t1.a between case coalesce((select 17 from t1 where (e in (f,e,t1.b))),13) | t1.a* - -c*t1.f-a+a when e then t1.a else 13 end and b then b else e end)-11 FROM t1 WHERE NOT (17=19*~d-case when (exists(select 1 from t1 where 17-e not between t1.b and f) or -f not in ( -13,b,c) and t1.f not between t1.f and 13) then 13 else coalesce((select t1.f from t1 where 11 not in (a,(e),t1.f)),(t1.c)) end+t1.c or 17 in (select +(count(*)) from t1 union select ~+case -min(t1.b) when case case max(19) when cast(avg((b)) AS integer) then (count(distinct t1.b)) else -cast(avg(t1.b) AS integer) end when ( -max(t1.e)) then max(17) else -count(distinct t1.f) end then cast(avg(19) AS integer) else count(*) end-count(*) | -cast(avg(11) AS integer) from t1))}
+} {-293}
+do_test randexpr-2.1598 {
+ db eval {SELECT ~f+coalesce((select max(17+~a+t1.b) from t1 where 17>t1.c),c+case when t1.f*d not between t1.f-13 and ~t1.b then 19 when t1.a between case coalesce((select 17 from t1 where (e in (f,e,t1.b))),13) & t1.a* - -c*t1.f-a+a when e then t1.a else 13 end and b then b else e end)-11 FROM t1 WHERE NOT (17=19*~d-case when (exists(select 1 from t1 where 17-e not between t1.b and f) or -f not in ( -13,b,c) and t1.f not between t1.f and 13) then 13 else coalesce((select t1.f from t1 where 11 not in (a,(e),t1.f)),(t1.c)) end+t1.c or 17 in (select +(count(*)) from t1 union select ~+case -min(t1.b) when case case max(19) when cast(avg((b)) AS integer) then (count(distinct t1.b)) else -cast(avg(t1.b) AS integer) end when ( -max(t1.e)) then max(17) else -count(distinct t1.f) end then cast(avg(19) AS integer) else count(*) end-count(*) | -cast(avg(11) AS integer) from t1))}
+} {-293}
+do_test randexpr-2.1599 {
+ db eval {SELECT (case when (select count(*) from t1)++t1.d+b*t1.e | t1.a+coalesce((select max(t1.d) from t1 where d-19<>c),t1.a)+t1.f in (select coalesce((select max(b) from t1 where t1.c-case when t1.c in (select c from t1 union select t1.f from t1) then f when t1.c not in ( -e,t1.e,11) then (t1.e) else 13 end in (f,t1.e,t1.f) or t1.a not between 19 and 17),t1.c) from t1 union select e from t1) then -t1.e else t1.a end) FROM t1 WHERE 11*b+~ -coalesce((select t1.e from t1 where not exists(select 1 from t1 where 19=t1.f)),t1.d+(abs( -a)/abs(t1.d)))-t1.d-19<=11}
+} {}
+do_test randexpr-2.1600 {
+ db eval {SELECT (case when (select count(*) from t1)++t1.d+b*t1.e | t1.a+coalesce((select max(t1.d) from t1 where d-19<>c),t1.a)+t1.f in (select coalesce((select max(b) from t1 where t1.c-case when t1.c in (select c from t1 union select t1.f from t1) then f when t1.c not in ( -e,t1.e,11) then (t1.e) else 13 end in (f,t1.e,t1.f) or t1.a not between 19 and 17),t1.c) from t1 union select e from t1) then -t1.e else t1.a end) FROM t1 WHERE NOT (11*b+~ -coalesce((select t1.e from t1 where not exists(select 1 from t1 where 19=t1.f)),t1.d+(abs( -a)/abs(t1.d)))-t1.d-19<=11)}
+} {100}
+do_test randexpr-2.1601 {
+ db eval {SELECT (case when (select count(*) from t1)++t1.d+b*t1.e & t1.a+coalesce((select max(t1.d) from t1 where d-19<>c),t1.a)+t1.f in (select coalesce((select max(b) from t1 where t1.c-case when t1.c in (select c from t1 union select t1.f from t1) then f when t1.c not in ( -e,t1.e,11) then (t1.e) else 13 end in (f,t1.e,t1.f) or t1.a not between 19 and 17),t1.c) from t1 union select e from t1) then -t1.e else t1.a end) FROM t1 WHERE NOT (11*b+~ -coalesce((select t1.e from t1 where not exists(select 1 from t1 where 19=t1.f)),t1.d+(abs( -a)/abs(t1.d)))-t1.d-19<=11)}
+} {100}
+do_test randexpr-2.1602 {
+ db eval {SELECT 19+~case when not not (select + - -min(f | f)-count(*)+count(*)-min(b)+count(distinct a) from t1)<=13-case when +13 between t1.a and a then 11 else 11 end and (11 not in (17, -t1.d,(f))) then t1.b | a-t1.f when t1.d<>17 then e else 17 end FROM t1 WHERE +t1.e-c<>case when c in (select d from t1 union select f from t1) then case (case when 13 in (select +c*a*13-11 from t1 union select b from t1) then t1.a when t1.f in ( -t1.f,11,a) or t1.a<=f or (exists(select 1 from t1 where 13>=d)) then t1.c else b end) when t1.d then 11 else e end when t1.b in (19,t1.d,(19)) then c else a end}
+} {-482}
+do_test randexpr-2.1603 {
+ db eval {SELECT 19+~case when not not (select + - -min(f | f)-count(*)+count(*)-min(b)+count(distinct a) from t1)<=13-case when +13 between t1.a and a then 11 else 11 end and (11 not in (17, -t1.d,(f))) then t1.b | a-t1.f when t1.d<>17 then e else 17 end FROM t1 WHERE NOT (+t1.e-c<>case when c in (select d from t1 union select f from t1) then case (case when 13 in (select +c*a*13-11 from t1 union select b from t1) then t1.a when t1.f in ( -t1.f,11,a) or t1.a<=f or (exists(select 1 from t1 where 13>=d)) then t1.c else b end) when t1.d then 11 else e end when t1.b in (19,t1.d,(19)) then c else a end)}
+} {}
+do_test randexpr-2.1604 {
+ db eval {SELECT 19+~case when not not (select + - -min(f & f)-count(*)+count(*)-min(b)+count(distinct a) from t1)<=13-case when +13 between t1.a and a then 11 else 11 end and (11 not in (17, -t1.d,(f))) then t1.b & a-t1.f when t1.d<>17 then e else 17 end FROM t1 WHERE +t1.e-c<>case when c in (select d from t1 union select f from t1) then case (case when 13 in (select +c*a*13-11 from t1 union select b from t1) then t1.a when t1.f in ( -t1.f,11,a) or t1.a<=f or (exists(select 1 from t1 where 13>=d)) then t1.c else b end) when t1.d then 11 else e end when t1.b in (19,t1.d,(19)) then c else a end}
+} {-482}
+do_test randexpr-2.1605 {
+ db eval {SELECT (case when e not between 19 and t1.a then case coalesce((select t1.e from t1 where (exists(select 1 from t1 where c in (select case count(distinct t1.b) when max(b) then min((t1.d)) else count(distinct 11) end+ -count(*) | - -count(distinct t1.e) from t1 union select min(f) from t1))) or (select min(17) from t1) not between 13 and b and - -c<e),t1.a)+f when (select cast(avg(a) AS integer) from t1) then 19 else 19 end when not 13>=17 and 17 between t1.e and 13 or 13>d or 11>= -t1.d then a else 13 end)+t1.f FROM t1 WHERE b<=13}
+} {}
+do_test randexpr-2.1606 {
+ db eval {SELECT (case when e not between 19 and t1.a then case coalesce((select t1.e from t1 where (exists(select 1 from t1 where c in (select case count(distinct t1.b) when max(b) then min((t1.d)) else count(distinct 11) end+ -count(*) | - -count(distinct t1.e) from t1 union select min(f) from t1))) or (select min(17) from t1) not between 13 and b and - -c<e),t1.a)+f when (select cast(avg(a) AS integer) from t1) then 19 else 19 end when not 13>=17 and 17 between t1.e and 13 or 13>d or 11>= -t1.d then a else 13 end)+t1.f FROM t1 WHERE NOT (b<=13)}
+} {619}
+do_test randexpr-2.1607 {
+ db eval {SELECT (case when e not between 19 and t1.a then case coalesce((select t1.e from t1 where (exists(select 1 from t1 where c in (select case count(distinct t1.b) when max(b) then min((t1.d)) else count(distinct 11) end+ -count(*) & - -count(distinct t1.e) from t1 union select min(f) from t1))) or (select min(17) from t1) not between 13 and b and - -c<e),t1.a)+f when (select cast(avg(a) AS integer) from t1) then 19 else 19 end when not 13>=17 and 17 between t1.e and 13 or 13>d or 11>= -t1.d then a else 13 end)+t1.f FROM t1 WHERE NOT (b<=13)}
+} {619}
+do_test randexpr-2.1608 {
+ db eval {SELECT case c when d then +e else 17-e+case when exists(select 1 from t1 where not -f<19) then (a) when t1.a between case when t1.d- -~t1.a+(select case min(t1.a) when count(distinct t1.e) then max(f) else max(t1.f) end-min(t1.b) from t1)*(select max(17) from t1)+e*13-f in (t1.d,f,d) then f else t1.b end and b then t1.d else d end end FROM t1 WHERE b<>c*f}
+} {-83}
+do_test randexpr-2.1609 {
+ db eval {SELECT case c when d then +e else 17-e+case when exists(select 1 from t1 where not -f<19) then (a) when t1.a between case when t1.d- -~t1.a+(select case min(t1.a) when count(distinct t1.e) then max(f) else max(t1.f) end-min(t1.b) from t1)*(select max(17) from t1)+e*13-f in (t1.d,f,d) then f else t1.b end and b then t1.d else d end end FROM t1 WHERE NOT (b<>c*f)}
+} {}
+do_test randexpr-2.1610 {
+ db eval {SELECT -(select min(coalesce((select max(case when d>=t1.c then f-t1.c else t1.b end) from t1 where case when (17)-13<=(abs(a-e)/abs(19-t1.a)) then (select -max(c++t1.d | +case when 19 in (select b from t1 union select t1.c from t1) then t1.d else f end) from t1) else 11-19 end not in (e,t1.e,17)),c)+t1.b) from t1) FROM t1 WHERE -case when case when e=case when not 17>+t1.d and b*b in (e, -d,13) then -b*c else t1.e end then t1.f when e>=a then c else 19 end+t1.e<> -t1.d then 11 when not 11<>13 then 13 else e end*17*t1.d+t1.f in (select e from t1 union select t1.b from t1)}
+} {}
+do_test randexpr-2.1611 {
+ db eval {SELECT -(select min(coalesce((select max(case when d>=t1.c then f-t1.c else t1.b end) from t1 where case when (17)-13<=(abs(a-e)/abs(19-t1.a)) then (select -max(c++t1.d | +case when 19 in (select b from t1 union select t1.c from t1) then t1.d else f end) from t1) else 11-19 end not in (e,t1.e,17)),c)+t1.b) from t1) FROM t1 WHERE NOT ( -case when case when e=case when not 17>+t1.d and b*b in (e, -d,13) then -b*c else t1.e end then t1.f when e>=a then c else 19 end+t1.e<> -t1.d then 11 when not 11<>13 then 13 else e end*17*t1.d+t1.f in (select e from t1 union select t1.b from t1))}
+} {-500}
+do_test randexpr-2.1612 {
+ db eval {SELECT -(select min(coalesce((select max(case when d>=t1.c then f-t1.c else t1.b end) from t1 where case when (17)-13<=(abs(a-e)/abs(19-t1.a)) then (select -max(c++t1.d & +case when 19 in (select b from t1 union select t1.c from t1) then t1.d else f end) from t1) else 11-19 end not in (e,t1.e,17)),c)+t1.b) from t1) FROM t1 WHERE NOT ( -case when case when e=case when not 17>+t1.d and b*b in (e, -d,13) then -b*c else t1.e end then t1.f when e>=a then c else 19 end+t1.e<> -t1.d then 11 when not 11<>13 then 13 else e end*17*t1.d+t1.f in (select e from t1 union select t1.b from t1))}
+} {-500}
+do_test randexpr-2.1613 {
+ db eval {SELECT case when b<=(abs(19)/abs(t1.a)) | 13-b then +f | ~d else ~case when case case when t1.c in (select 13+19 from t1 union select t1.a from t1) then -c when 13 between t1.a and b then 17 else c end when t1.c then e else 11 end between t1.e and 11 or f in (select 17 from t1 union select (a) from t1) then t1.f-d when t1.b in (select t1.f from t1 union select t1.f from t1) then t1.c else t1.b end end FROM t1 WHERE (t1.e in (select +17 from t1 union select 11 from t1))}
+} {}
+do_test randexpr-2.1614 {
+ db eval {SELECT case when b<=(abs(19)/abs(t1.a)) | 13-b then +f | ~d else ~case when case case when t1.c in (select 13+19 from t1 union select t1.a from t1) then -c when 13 between t1.a and b then 17 else c end when t1.c then e else 11 end between t1.e and 11 or f in (select 17 from t1 union select (a) from t1) then t1.f-d when t1.b in (select t1.f from t1 union select t1.f from t1) then t1.c else t1.b end end FROM t1 WHERE NOT ((t1.e in (select +17 from t1 union select 11 from t1)))}
+} {-201}
+do_test randexpr-2.1615 {
+ db eval {SELECT case when b<=(abs(19)/abs(t1.a)) & 13-b then +f & ~d else ~case when case case when t1.c in (select 13+19 from t1 union select t1.a from t1) then -c when 13 between t1.a and b then 17 else c end when t1.c then e else 11 end between t1.e and 11 or f in (select 17 from t1 union select (a) from t1) then t1.f-d when t1.b in (select t1.f from t1 union select t1.f from t1) then t1.c else t1.b end end FROM t1 WHERE NOT ((t1.e in (select +17 from t1 union select 11 from t1)))}
+} {-201}
+do_test randexpr-2.1616 {
+ db eval {SELECT coalesce((select coalesce((select coalesce((select ~e+coalesce((select -e-+17 from t1 where (select cast(avg(11) AS integer) from t1) between case when +13+13 between 19 and t1.c then t1.d else 13 end and 13),t1.c)* -(19)+17-t1.a+e from t1 where t1.b>=t1.f),t1.b) | t1.f from t1 where f in (select d from t1 union select 11 from t1)),t1.b) from t1 where t1.b=13),t1.d) FROM t1 WHERE t1.f<>(abs(t1.c)/abs(t1.a))}
+} {400}
+do_test randexpr-2.1617 {
+ db eval {SELECT coalesce((select coalesce((select coalesce((select ~e+coalesce((select -e-+17 from t1 where (select cast(avg(11) AS integer) from t1) between case when +13+13 between 19 and t1.c then t1.d else 13 end and 13),t1.c)* -(19)+17-t1.a+e from t1 where t1.b>=t1.f),t1.b) | t1.f from t1 where f in (select d from t1 union select 11 from t1)),t1.b) from t1 where t1.b=13),t1.d) FROM t1 WHERE NOT (t1.f<>(abs(t1.c)/abs(t1.a)))}
+} {}
+do_test randexpr-2.1618 {
+ db eval {SELECT coalesce((select coalesce((select coalesce((select ~e+coalesce((select -e-+17 from t1 where (select cast(avg(11) AS integer) from t1) between case when +13+13 between 19 and t1.c then t1.d else 13 end and 13),t1.c)* -(19)+17-t1.a+e from t1 where t1.b>=t1.f),t1.b) & t1.f from t1 where f in (select d from t1 union select 11 from t1)),t1.b) from t1 where t1.b=13),t1.d) FROM t1 WHERE t1.f<>(abs(t1.c)/abs(t1.a))}
+} {400}
+do_test randexpr-2.1619 {
+ db eval {SELECT (abs(a)/abs(coalesce((select case when coalesce((select d from t1 where d+case (coalesce((select max(e) from t1 where 17+f*13-(case 19 when t1.f then 17 else t1.e end)<>b),17)) when t1.e then t1.e else t1.a end- -13+ -t1.f between b and f),11)+t1.d between 13 and t1.d then b else (19) end-t1.c from t1 where c in (select t1.e from t1 union select f from t1)),b))) FROM t1 WHERE d>t1.a}
+} {0}
+do_test randexpr-2.1620 {
+ db eval {SELECT (abs(a)/abs(coalesce((select case when coalesce((select d from t1 where d+case (coalesce((select max(e) from t1 where 17+f*13-(case 19 when t1.f then 17 else t1.e end)<>b),17)) when t1.e then t1.e else t1.a end- -13+ -t1.f between b and f),11)+t1.d between 13 and t1.d then b else (19) end-t1.c from t1 where c in (select t1.e from t1 union select f from t1)),b))) FROM t1 WHERE NOT (d>t1.a)}
+} {}
+do_test randexpr-2.1621 {
+ db eval {SELECT coalesce((select case when coalesce((select max(coalesce((select max(e-c-coalesce((select max(c) from t1 where 19 between 13 and 13),(abs(case when c<=17 or f in (t1.a, -17,t1.f) then b else t1.c end)/abs(e))+t1.b)) from t1 where not exists(select 1 from t1 where t1.e>=b)),e)) from t1 where not exists(select 1 from t1 where 13<=t1.b or t1.f in (select d from t1 union select t1.d from t1))),17) in (select 11 from t1 union select t1.d from t1) then c else t1.e end from t1 where t1.c in (select b from t1 union select b from t1)),f) | t1.c FROM t1 WHERE c<=e}
+} {892}
+do_test randexpr-2.1622 {
+ db eval {SELECT coalesce((select case when coalesce((select max(coalesce((select max(e-c-coalesce((select max(c) from t1 where 19 between 13 and 13),(abs(case when c<=17 or f in (t1.a, -17,t1.f) then b else t1.c end)/abs(e))+t1.b)) from t1 where not exists(select 1 from t1 where t1.e>=b)),e)) from t1 where not exists(select 1 from t1 where 13<=t1.b or t1.f in (select d from t1 union select t1.d from t1))),17) in (select 11 from t1 union select t1.d from t1) then c else t1.e end from t1 where t1.c in (select b from t1 union select b from t1)),f) | t1.c FROM t1 WHERE NOT (c<=e)}
+} {}
+do_test randexpr-2.1623 {
+ db eval {SELECT coalesce((select case when coalesce((select max(coalesce((select max(e-c-coalesce((select max(c) from t1 where 19 between 13 and 13),(abs(case when c<=17 or f in (t1.a, -17,t1.f) then b else t1.c end)/abs(e))+t1.b)) from t1 where not exists(select 1 from t1 where t1.e>=b)),e)) from t1 where not exists(select 1 from t1 where 13<=t1.b or t1.f in (select d from t1 union select t1.d from t1))),17) in (select 11 from t1 union select t1.d from t1) then c else t1.e end from t1 where t1.c in (select b from t1 union select b from t1)),f) & t1.c FROM t1 WHERE c<=e}
+} {8}
+do_test randexpr-2.1624 {
+ db eval {SELECT (select +max(case when t1.a in (f,case when f in (t1.b,+ -(select count(*)-min(17) from t1)+19,11) then -19 else 19 end*(abs(b)/abs(a)),a) then t1.b when (case a when 17 then c | t1.d else t1.c end+11)-13 in (b,11,f) then b else 17 end*17) from t1) FROM t1 WHERE c between (abs(case when (abs(d+19)/abs(19))-c*t1.d+t1.e+case when -(abs(case when exists(select 1 from t1 where exists(select 1 from t1 where 13 in (select cast(avg(t1.b) AS integer) from t1 union select max(d) from t1))) then ~c when t1.d not between 13 and d then -t1.b else -f end)/abs(t1.b))+d in (t1.e,(13),e) then e when (b)<>d then t1.b else 19 end in (select 17 from t1 union select e from t1) then t1.e else t1.e end)/abs(t1.f)) and t1.e}
+} {3400}
+do_test randexpr-2.1625 {
+ db eval {SELECT (select +max(case when t1.a in (f,case when f in (t1.b,+ -(select count(*)-min(17) from t1)+19,11) then -19 else 19 end*(abs(b)/abs(a)),a) then t1.b when (case a when 17 then c | t1.d else t1.c end+11)-13 in (b,11,f) then b else 17 end*17) from t1) FROM t1 WHERE NOT (c between (abs(case when (abs(d+19)/abs(19))-c*t1.d+t1.e+case when -(abs(case when exists(select 1 from t1 where exists(select 1 from t1 where 13 in (select cast(avg(t1.b) AS integer) from t1 union select max(d) from t1))) then ~c when t1.d not between 13 and d then -t1.b else -f end)/abs(t1.b))+d in (t1.e,(13),e) then e when (b)<>d then t1.b else 19 end in (select 17 from t1 union select e from t1) then t1.e else t1.e end)/abs(t1.f)) and t1.e)}
+} {}
+do_test randexpr-2.1626 {
+ db eval {SELECT (select +max(case when t1.a in (f,case when f in (t1.b,+ -(select count(*)-min(17) from t1)+19,11) then -19 else 19 end*(abs(b)/abs(a)),a) then t1.b when (case a when 17 then c & t1.d else t1.c end+11)-13 in (b,11,f) then b else 17 end*17) from t1) FROM t1 WHERE c between (abs(case when (abs(d+19)/abs(19))-c*t1.d+t1.e+case when -(abs(case when exists(select 1 from t1 where exists(select 1 from t1 where 13 in (select cast(avg(t1.b) AS integer) from t1 union select max(d) from t1))) then ~c when t1.d not between 13 and d then -t1.b else -f end)/abs(t1.b))+d in (t1.e,(13),e) then e when (b)<>d then t1.b else 19 end in (select 17 from t1 union select e from t1) then t1.e else t1.e end)/abs(t1.f)) and t1.e}
+} {3400}
+do_test randexpr-2.1627 {
+ db eval {SELECT case when c between f and t1.f*t1.f then (coalesce((select max(d | coalesce((select 19+t1.c from t1 where t1.a between d and (b)),(t1.f))*t1.f*t1.b) from t1 where 11>13 or 19 not between 13 and 11 or t1.a>=b or b>t1.e or 11=a and t1.b<=d),f)) when a in (select min(t1.b)-abs(count(distinct 11)) from t1 union select cast(avg(t1.d) AS integer) from t1) then f else c end-t1.e FROM t1 WHERE (t1.f+a)*t1.b+(abs(b)/abs(b)) in (t1.e,case when 11-t1.a+e+case 19 when +11+ -t1.b then case ~t1.f*(f)-b when d then a else ( -c) end*(c) else t1.a end+t1.a not in (17,11,t1.e) then t1.b else (d) end*19,t1.a)}
+} {}
+do_test randexpr-2.1628 {
+ db eval {SELECT case when c between f and t1.f*t1.f then (coalesce((select max(d | coalesce((select 19+t1.c from t1 where t1.a between d and (b)),(t1.f))*t1.f*t1.b) from t1 where 11>13 or 19 not between 13 and 11 or t1.a>=b or b>t1.e or 11=a and t1.b<=d),f)) when a in (select min(t1.b)-abs(count(distinct 11)) from t1 union select cast(avg(t1.d) AS integer) from t1) then f else c end-t1.e FROM t1 WHERE NOT ((t1.f+a)*t1.b+(abs(b)/abs(b)) in (t1.e,case when 11-t1.a+e+case 19 when +11+ -t1.b then case ~t1.f*(f)-b when d then a else ( -c) end*(c) else t1.a end+t1.a not in (17,11,t1.e) then t1.b else (d) end*19,t1.a))}
+} {-200}
+do_test randexpr-2.1629 {
+ db eval {SELECT case when c between f and t1.f*t1.f then (coalesce((select max(d & coalesce((select 19+t1.c from t1 where t1.a between d and (b)),(t1.f))*t1.f*t1.b) from t1 where 11>13 or 19 not between 13 and 11 or t1.a>=b or b>t1.e or 11=a and t1.b<=d),f)) when a in (select min(t1.b)-abs(count(distinct 11)) from t1 union select cast(avg(t1.d) AS integer) from t1) then f else c end-t1.e FROM t1 WHERE NOT ((t1.f+a)*t1.b+(abs(b)/abs(b)) in (t1.e,case when 11-t1.a+e+case 19 when +11+ -t1.b then case ~t1.f*(f)-b when d then a else ( -c) end*(c) else t1.a end+t1.a not in (17,11,t1.e) then t1.b else (d) end*19,t1.a))}
+} {-200}
+do_test randexpr-2.1630 {
+ db eval {SELECT coalesce((select max(f) from t1 where (a+13>19*t1.e+a | a | 17*e or ~c not between 17 and 19*(select +(~count(distinct e)*(cast(avg(t1.b) AS integer))) | count(distinct t1.c) from t1)-f and t1.a*t1.f+c not between t1.f and f)),t1.c*(t1.e)*e) FROM t1 WHERE case case t1.f when ~17 then 11 else t1.d end when a then t1.a else e end>d*11}
+} {}
+do_test randexpr-2.1631 {
+ db eval {SELECT coalesce((select max(f) from t1 where (a+13>19*t1.e+a | a | 17*e or ~c not between 17 and 19*(select +(~count(distinct e)*(cast(avg(t1.b) AS integer))) | count(distinct t1.c) from t1)-f and t1.a*t1.f+c not between t1.f and f)),t1.c*(t1.e)*e) FROM t1 WHERE NOT (case case t1.f when ~17 then 11 else t1.d end when a then t1.a else e end>d*11)}
+} {600}
+do_test randexpr-2.1632 {
+ db eval {SELECT coalesce((select max(f) from t1 where (a+13>19*t1.e+a & a & 17*e or ~c not between 17 and 19*(select +(~count(distinct e)*(cast(avg(t1.b) AS integer))) & count(distinct t1.c) from t1)-f and t1.a*t1.f+c not between t1.f and f)),t1.c*(t1.e)*e) FROM t1 WHERE NOT (case case t1.f when ~17 then 11 else t1.d end when a then t1.a else e end>d*11)}
+} {600}
+do_test randexpr-2.1633 {
+ db eval {SELECT case when e<11 then (case case t1.a when coalesce((select max(11) from t1 where t1.c<=case when exists(select 1 from t1 where 13=e) then case when c not in (t1.f,t1.e,c) then c else ~(c)+d*f end when a>b then 11 else 11 end),(t1.c)) | 11 then b else t1.a end when 11 then t1.f else t1.d end) when d<c then t1.f else (e) end | t1.d FROM t1 WHERE 17 in (select case t1.e+ -coalesce((select max(coalesce((select max(e+t1.a) from t1 where -t1.a in (select min(coalesce((select 11 from t1 where -t1.a in (select a from t1 union select t1.e from t1)),t1.c))+(~cast(avg(f) AS integer)) from t1 union select case abs(( -count(distinct t1.e))) when count(distinct -11) then count(distinct t1.b) else (max(t1.c)) end from t1)),t1.f)) from t1 where t1.c in (t1.c,t1.f,f)),c)-t1.b-t1.c-(t1.d) when 17 then 17 else t1.c end from t1 union select c from t1)}
+} {}
+do_test randexpr-2.1634 {
+ db eval {SELECT case when e<11 then (case case t1.a when coalesce((select max(11) from t1 where t1.c<=case when exists(select 1 from t1 where 13=e) then case when c not in (t1.f,t1.e,c) then c else ~(c)+d*f end when a>b then 11 else 11 end),(t1.c)) | 11 then b else t1.a end when 11 then t1.f else t1.d end) when d<c then t1.f else (e) end | t1.d FROM t1 WHERE NOT (17 in (select case t1.e+ -coalesce((select max(coalesce((select max(e+t1.a) from t1 where -t1.a in (select min(coalesce((select 11 from t1 where -t1.a in (select a from t1 union select t1.e from t1)),t1.c))+(~cast(avg(f) AS integer)) from t1 union select case abs(( -count(distinct t1.e))) when count(distinct -11) then count(distinct t1.b) else (max(t1.c)) end from t1)),t1.f)) from t1 where t1.c in (t1.c,t1.f,f)),c)-t1.b-t1.c-(t1.d) when 17 then 17 else t1.c end from t1 union select c from t1))}
+} {500}
+do_test randexpr-2.1635 {
+ db eval {SELECT case when e<11 then (case case t1.a when coalesce((select max(11) from t1 where t1.c<=case when exists(select 1 from t1 where 13=e) then case when c not in (t1.f,t1.e,c) then c else ~(c)+d*f end when a>b then 11 else 11 end),(t1.c)) & 11 then b else t1.a end when 11 then t1.f else t1.d end) when d<c then t1.f else (e) end & t1.d FROM t1 WHERE NOT (17 in (select case t1.e+ -coalesce((select max(coalesce((select max(e+t1.a) from t1 where -t1.a in (select min(coalesce((select 11 from t1 where -t1.a in (select a from t1 union select t1.e from t1)),t1.c))+(~cast(avg(f) AS integer)) from t1 union select case abs(( -count(distinct t1.e))) when count(distinct -11) then count(distinct t1.b) else (max(t1.c)) end from t1)),t1.f)) from t1 where t1.c in (t1.c,t1.f,f)),c)-t1.b-t1.c-(t1.d) when 17 then 17 else t1.c end from t1 union select c from t1))}
+} {400}
+do_test randexpr-2.1636 {
+ db eval {SELECT case coalesce((select a from t1 where exists(select 1 from t1 where t1.e>f)),17) when coalesce((select max((b)) from t1 where not case (abs(t1.b)/abs(t1.d+t1.b)) when t1.d then f-coalesce((select max(a) from t1 where case t1.e when c then c else 11 end not between b and -t1.b),t1.e) else t1.a end-17 between t1.e and f and (t1.e<e) and t1.d>17), -e)*19 then t1.b else t1.c end FROM t1 WHERE not -coalesce((select d from t1 where exists(select 1 from t1 where coalesce((select max(case when 11 not in (case when d*11<>17-(t1.e) then 13 else c end,t1.d,t1.c) then e else t1.c end) from t1 where t1.d<= - -d),11) in (select + -case (+ -cast(avg(19) AS integer)+ - -(count(*))* -count(distinct ((t1.e)))*max(d)) when count(*) then max(b) else count(*) end from t1 union select count(*) from t1))),t1.d)+13>a}
+} {300}
+do_test randexpr-2.1637 {
+ db eval {SELECT case coalesce((select a from t1 where exists(select 1 from t1 where t1.e>f)),17) when coalesce((select max((b)) from t1 where not case (abs(t1.b)/abs(t1.d+t1.b)) when t1.d then f-coalesce((select max(a) from t1 where case t1.e when c then c else 11 end not between b and -t1.b),t1.e) else t1.a end-17 between t1.e and f and (t1.e<e) and t1.d>17), -e)*19 then t1.b else t1.c end FROM t1 WHERE NOT (not -coalesce((select d from t1 where exists(select 1 from t1 where coalesce((select max(case when 11 not in (case when d*11<>17-(t1.e) then 13 else c end,t1.d,t1.c) then e else t1.c end) from t1 where t1.d<= - -d),11) in (select + -case (+ -cast(avg(19) AS integer)+ - -(count(*))* -count(distinct ((t1.e)))*max(d)) when count(*) then max(b) else count(*) end from t1 union select count(*) from t1))),t1.d)+13>a)}
+} {}
+do_test randexpr-2.1638 {
+ db eval {SELECT ~coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.e-t1.e in (select t1.c+case d when case when not case when t1.f between ( -t1.a) and (b) or 11<>19 then (abs(t1.e)/abs(t1.f)) else e end between t1.b and e then t1.d | t1.e when 19>b then 13 else t1.a end*e*13 | 11+t1.f then t1.b else 17 end from t1 union select e from t1))),t1.a-t1.b)*t1.d*e FROM t1 WHERE d in (select 11 from t1 union select +11 from t1) or coalesce((select max(coalesce((select b-e*case when (c) | e | b in (select 19*t1.d from t1 union select t1.e from t1) then t1.d else e end from t1 where t1.a<11),d)) from t1 where (not ((17 not in ( -t1.a,e,d) and 13<11) and f>=11))),t1.b)<11}
+} {}
+do_test randexpr-2.1639 {
+ db eval {SELECT ~coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.e-t1.e in (select t1.c+case d when case when not case when t1.f between ( -t1.a) and (b) or 11<>19 then (abs(t1.e)/abs(t1.f)) else e end between t1.b and e then t1.d | t1.e when 19>b then 13 else t1.a end*e*13 | 11+t1.f then t1.b else 17 end from t1 union select e from t1))),t1.a-t1.b)*t1.d*e FROM t1 WHERE NOT (d in (select 11 from t1 union select +11 from t1) or coalesce((select max(coalesce((select b-e*case when (c) | e | b in (select 19*t1.d from t1 union select t1.e from t1) then t1.d else e end from t1 where t1.a<11),d)) from t1 where (not ((17 not in ( -t1.a,e,d) and 13<11) and f>=11))),t1.b)<11)}
+} {-3600000}
+do_test randexpr-2.1640 {
+ db eval {SELECT ~coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.e-t1.e in (select t1.c+case d when case when not case when t1.f between ( -t1.a) and (b) or 11<>19 then (abs(t1.e)/abs(t1.f)) else e end between t1.b and e then t1.d & t1.e when 19>b then 13 else t1.a end*e*13 & 11+t1.f then t1.b else 17 end from t1 union select e from t1))),t1.a-t1.b)*t1.d*e FROM t1 WHERE NOT (d in (select 11 from t1 union select +11 from t1) or coalesce((select max(coalesce((select b-e*case when (c) | e | b in (select 19*t1.d from t1 union select t1.e from t1) then t1.d else e end from t1 where t1.a<11),d)) from t1 where (not ((17 not in ( -t1.a,e,d) and 13<11) and f>=11))),t1.b)<11)}
+} {-3600000}
+do_test randexpr-2.1641 {
+ db eval {SELECT case b-f when t1.a then -case when not (case t1.a when (select case cast(avg(c) AS integer) when count(distinct t1.f) then +max(t1.e) | -((( -(count(*))))) else cast(avg(f) AS integer) end from t1)-b then a else coalesce((select t1.a from t1 where (e<d)),t1.d) end not between t1.a and t1.f) then coalesce((select max(13) from t1 where (13)=e),t1.d) when d not in (a,t1.f,c) then -11 else t1.a end else 17 end FROM t1 WHERE -13*t1.b-c-e+case when t1.b | b in (select cast(avg(t1.a | +(select abs(+count(*))-count(distinct (t1.f))*abs(min(t1.d))+count(distinct case when exists(select 1 from t1 where (19)>=a and e>c) or c not between a and 19 then 11 when t1.b not between e and t1.a then 17 else 11 end) from t1)) AS integer) from t1 union select cast(avg((abs(b)/abs(t1.f))) AS integer) from t1) then 17 else t1.e end>=a}
+} {}
+do_test randexpr-2.1642 {
+ db eval {SELECT case b-f when t1.a then -case when not (case t1.a when (select case cast(avg(c) AS integer) when count(distinct t1.f) then +max(t1.e) | -((( -(count(*))))) else cast(avg(f) AS integer) end from t1)-b then a else coalesce((select t1.a from t1 where (e<d)),t1.d) end not between t1.a and t1.f) then coalesce((select max(13) from t1 where (13)=e),t1.d) when d not in (a,t1.f,c) then -11 else t1.a end else 17 end FROM t1 WHERE NOT ( -13*t1.b-c-e+case when t1.b | b in (select cast(avg(t1.a | +(select abs(+count(*))-count(distinct (t1.f))*abs(min(t1.d))+count(distinct case when exists(select 1 from t1 where (19)>=a and e>c) or c not between a and 19 then 11 when t1.b not between e and t1.a then 17 else 11 end) from t1)) AS integer) from t1 union select cast(avg((abs(b)/abs(t1.f))) AS integer) from t1) then 17 else t1.e end>=a)}
+} {17}
+do_test randexpr-2.1643 {
+ db eval {SELECT case b-f when t1.a then -case when not (case t1.a when (select case cast(avg(c) AS integer) when count(distinct t1.f) then +max(t1.e) & -((( -(count(*))))) else cast(avg(f) AS integer) end from t1)-b then a else coalesce((select t1.a from t1 where (e<d)),t1.d) end not between t1.a and t1.f) then coalesce((select max(13) from t1 where (13)=e),t1.d) when d not in (a,t1.f,c) then -11 else t1.a end else 17 end FROM t1 WHERE NOT ( -13*t1.b-c-e+case when t1.b | b in (select cast(avg(t1.a | +(select abs(+count(*))-count(distinct (t1.f))*abs(min(t1.d))+count(distinct case when exists(select 1 from t1 where (19)>=a and e>c) or c not between a and 19 then 11 when t1.b not between e and t1.a then 17 else 11 end) from t1)) AS integer) from t1 union select cast(avg((abs(b)/abs(t1.f))) AS integer) from t1) then 17 else t1.e end>=a)}
+} {17}
+do_test randexpr-2.1644 {
+ db eval {SELECT coalesce((select max((abs(t1.b*t1.d*case when f*t1.d<a*17* -t1.c+coalesce((select max(a) from t1 where 11>b),t1.d*19)*e+c+t1.d then t1.c when exists(select 1 from t1 where 13>=e) then t1.e else f end-f*e)/abs(13))) from t1 where (a)<=t1.d),13) | e FROM t1 WHERE +t1.c>t1.d}
+} {}
+do_test randexpr-2.1645 {
+ db eval {SELECT coalesce((select max((abs(t1.b*t1.d*case when f*t1.d<a*17* -t1.c+coalesce((select max(a) from t1 where 11>b),t1.d*19)*e+c+t1.d then t1.c when exists(select 1 from t1 where 13>=e) then t1.e else f end-f*e)/abs(13))) from t1 where (a)<=t1.d),13) | e FROM t1 WHERE NOT (+t1.c>t1.d)}
+} {1823220}
+do_test randexpr-2.1646 {
+ db eval {SELECT coalesce((select max((abs(t1.b*t1.d*case when f*t1.d<a*17* -t1.c+coalesce((select max(a) from t1 where 11>b),t1.d*19)*e+c+t1.d then t1.c when exists(select 1 from t1 where 13>=e) then t1.e else f end-f*e)/abs(13))) from t1 where (a)<=t1.d),13) & e FROM t1 WHERE NOT (+t1.c>t1.d)}
+} {356}
+do_test randexpr-2.1647 {
+ db eval {SELECT case when not exists(select 1 from t1 where 17>=19) or t1.c in (select min(19)-(cast(avg(f) AS integer)) from t1 union select cast(avg(19) AS integer) from t1) and e in (select ~+count(distinct 19)*max(13) from t1 union select min(17+d) from t1) or t1.f in (select count(*) from t1 union select (max(a)) from t1) then coalesce((select -d- -t1.d from t1 where b in (select cast(avg(c) AS integer) from t1 union select (count(*)) from t1) or b<=11),e) else t1.e end FROM t1 WHERE a< -13}
+} {}
+do_test randexpr-2.1648 {
+ db eval {SELECT case when not exists(select 1 from t1 where 17>=19) or t1.c in (select min(19)-(cast(avg(f) AS integer)) from t1 union select cast(avg(19) AS integer) from t1) and e in (select ~+count(distinct 19)*max(13) from t1 union select min(17+d) from t1) or t1.f in (select count(*) from t1 union select (max(a)) from t1) then coalesce((select -d- -t1.d from t1 where b in (select cast(avg(c) AS integer) from t1 union select (count(*)) from t1) or b<=11),e) else t1.e end FROM t1 WHERE NOT (a< -13)}
+} {500}
+do_test randexpr-2.1649 {
+ db eval {SELECT f+case when 17-t1.f in (select ~count(distinct (abs((abs(c)/abs(c)))/abs((abs(11)/abs(+case -t1.a when t1.d then -13 else 17 end))))-t1.c) from t1 union select ~case cast(avg(t1.c) AS integer) when -~ -count(*)*max((t1.f))+count(*) then (min(d)) else max(a) end-count(distinct t1.a)+ -count(*)-count(*) from t1) then d when b not between t1.f and t1.e then a else 11 end+t1.a FROM t1 WHERE (exists(select 1 from t1 where case when exists(select 1 from t1 where case when (t1.e+case (t1.b) when f then case t1.c when 11 | -13-coalesce((select max(d) from t1 where c not in ( -t1.e,t1.c,17) and t1.c<17),e)*17+t1.a then t1.b else 11 end else d end)+t1.f not in (d,13,d) then f else t1.d end not between (c) and f) then t1.e else f end-t1.c in (t1.b,t1.a,f)))}
+} {}
+do_test randexpr-2.1650 {
+ db eval {SELECT f+case when 17-t1.f in (select ~count(distinct (abs((abs(c)/abs(c)))/abs((abs(11)/abs(+case -t1.a when t1.d then -13 else 17 end))))-t1.c) from t1 union select ~case cast(avg(t1.c) AS integer) when -~ -count(*)*max((t1.f))+count(*) then (min(d)) else max(a) end-count(distinct t1.a)+ -count(*)-count(*) from t1) then d when b not between t1.f and t1.e then a else 11 end+t1.a FROM t1 WHERE NOT ((exists(select 1 from t1 where case when exists(select 1 from t1 where case when (t1.e+case (t1.b) when f then case t1.c when 11 | -13-coalesce((select max(d) from t1 where c not in ( -t1.e,t1.c,17) and t1.c<17),e)*17+t1.a then t1.b else 11 end else d end)+t1.f not in (d,13,d) then f else t1.d end not between (c) and f) then t1.e else f end-t1.c in (t1.b,t1.a,f))))}
+} {800}
+do_test randexpr-2.1651 {
+ db eval {SELECT case ~t1.d when case when c in (select count(*) from t1 union select +(( -min(17)-~cast(avg(t1.c) AS integer)))* -min(t1.f)-max(t1.d)*count(*) | cast(avg(17) AS integer) from t1) then 17*e*t1.f | t1.e else 19-coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where t1.c>=e)),t1.f) end | 13+13 then 17 else t1.f end FROM t1 WHERE (not exists(select 1 from t1 where +c-19 in (select (~((min(b)))-+count(*) | cast(avg(case when 11 in (select (abs((t1.b))/abs(e)) from t1 union select (17) from t1) then t1.c when -a<=b then t1.a else t1.e end) AS integer)++case max(t1.b) when cast(avg(c) AS integer) then count(*) else cast(avg(f) AS integer) end | -count(*)-(count(*))*max(t1.e)*count(*)*cast(avg(a) AS integer))+min(11) from t1 union select max((d)) from t1)))}
+} {600}
+do_test randexpr-2.1652 {
+ db eval {SELECT case ~t1.d when case when c in (select count(*) from t1 union select +(( -min(17)-~cast(avg(t1.c) AS integer)))* -min(t1.f)-max(t1.d)*count(*) | cast(avg(17) AS integer) from t1) then 17*e*t1.f | t1.e else 19-coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where t1.c>=e)),t1.f) end | 13+13 then 17 else t1.f end FROM t1 WHERE NOT ((not exists(select 1 from t1 where +c-19 in (select (~((min(b)))-+count(*) | cast(avg(case when 11 in (select (abs((t1.b))/abs(e)) from t1 union select (17) from t1) then t1.c when -a<=b then t1.a else t1.e end) AS integer)++case max(t1.b) when cast(avg(c) AS integer) then count(*) else cast(avg(f) AS integer) end | -count(*)-(count(*))*max(t1.e)*count(*)*cast(avg(a) AS integer))+min(11) from t1 union select max((d)) from t1))))}
+} {}
+do_test randexpr-2.1653 {
+ db eval {SELECT case ~t1.d when case when c in (select count(*) from t1 union select +(( -min(17)-~cast(avg(t1.c) AS integer)))* -min(t1.f)-max(t1.d)*count(*) & cast(avg(17) AS integer) from t1) then 17*e*t1.f & t1.e else 19-coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where t1.c>=e)),t1.f) end & 13+13 then 17 else t1.f end FROM t1 WHERE (not exists(select 1 from t1 where +c-19 in (select (~((min(b)))-+count(*) | cast(avg(case when 11 in (select (abs((t1.b))/abs(e)) from t1 union select (17) from t1) then t1.c when -a<=b then t1.a else t1.e end) AS integer)++case max(t1.b) when cast(avg(c) AS integer) then count(*) else cast(avg(f) AS integer) end | -count(*)-(count(*))*max(t1.e)*count(*)*cast(avg(a) AS integer))+min(11) from t1 union select max((d)) from t1)))}
+} {600}
+do_test randexpr-2.1654 {
+ db eval {SELECT 19 | case when not (select min(17) from t1)>t1.e then coalesce((select max(coalesce((select b from t1 where (t1.a not in (a | t1.c,t1.d,19) or not exists(select 1 from t1 where t1.b in (select t1.d from t1 union select a from t1)) and (a in (select count(*) from t1 union select max(t1.b) from t1) and t1.c in (t1.b,f,t1.d)))),t1.c)) from t1 where f=d and -b>c),t1.f)-t1.c when c in ((a),11,t1.c) then 13 else 13 end-c FROM t1 WHERE (t1.e)*case when +a*t1.f*t1.e>=+d*a+b-t1.f*~13 | t1.d*11-f-~f+17-coalesce((select max( -f) from t1 where b<t1.a),t1.b) | a-(17)-13-f then e else c end<17}
+} {}
+do_test randexpr-2.1655 {
+ db eval {SELECT 19 | case when not (select min(17) from t1)>t1.e then coalesce((select max(coalesce((select b from t1 where (t1.a not in (a | t1.c,t1.d,19) or not exists(select 1 from t1 where t1.b in (select t1.d from t1 union select a from t1)) and (a in (select count(*) from t1 union select max(t1.b) from t1) and t1.c in (t1.b,f,t1.d)))),t1.c)) from t1 where f=d and -b>c),t1.f)-t1.c when c in ((a),11,t1.c) then 13 else 13 end-c FROM t1 WHERE NOT ((t1.e)*case when +a*t1.f*t1.e>=+d*a+b-t1.f*~13 | t1.d*11-f-~f+17-coalesce((select max( -f) from t1 where b<t1.a),t1.b) | a-(17)-13-f then e else c end<17)}
+} {19}
+do_test randexpr-2.1656 {
+ db eval {SELECT 19 & case when not (select min(17) from t1)>t1.e then coalesce((select max(coalesce((select b from t1 where (t1.a not in (a & t1.c,t1.d,19) or not exists(select 1 from t1 where t1.b in (select t1.d from t1 union select a from t1)) and (a in (select count(*) from t1 union select max(t1.b) from t1) and t1.c in (t1.b,f,t1.d)))),t1.c)) from t1 where f=d and -b>c),t1.f)-t1.c when c in ((a),11,t1.c) then 13 else 13 end-c FROM t1 WHERE NOT ((t1.e)*case when +a*t1.f*t1.e>=+d*a+b-t1.f*~13 | t1.d*11-f-~f+17-coalesce((select max( -f) from t1 where b<t1.a),t1.b) | a-(17)-13-f then e else c end<17)}
+} {0}
+do_test randexpr-2.1657 {
+ db eval {SELECT case when not exists(select 1 from t1 where not not not d=17) then t1.b when (not coalesce((select coalesce((select max(d) from t1 where c+c>t1.c),11)*e*t1.e from t1 where e<=t1.d),t1.a)*f<t1.b) then coalesce((select case when 19>=11 then e when t1.a in (select e from t1 union select b from t1) then t1.b-t1.a else e end from t1 where a=t1.a), -17) else e end FROM t1 WHERE not exists(select 1 from t1 where t1.e in (select max((abs(~+t1.a-t1.c*a)/abs(17))) from t1 union select min(11*t1.c+t1.f) from t1))}
+} {500}
+do_test randexpr-2.1658 {
+ db eval {SELECT case when not exists(select 1 from t1 where not not not d=17) then t1.b when (not coalesce((select coalesce((select max(d) from t1 where c+c>t1.c),11)*e*t1.e from t1 where e<=t1.d),t1.a)*f<t1.b) then coalesce((select case when 19>=11 then e when t1.a in (select e from t1 union select b from t1) then t1.b-t1.a else e end from t1 where a=t1.a), -17) else e end FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.e in (select max((abs(~+t1.a-t1.c*a)/abs(17))) from t1 union select min(11*t1.c+t1.f) from t1)))}
+} {}
+do_test randexpr-2.1659 {
+ db eval {SELECT coalesce((select coalesce((select max(case when not a not in ((abs(11)/abs(coalesce((select t1.d from t1 where 17 in (select count(*) from t1 union select count(distinct t1.a) from t1)),b)*t1.e*c)),t1.a,t1.b) or t1.c<=t1.f or (t1.d>= -a) then (select cast(avg(~t1.f-t1.f) AS integer) from t1) else 17 end) from t1 where t1.b<=c and t1.b<=a),11) from t1 where exists(select 1 from t1 where e<c) and 11 not between t1.d and c),a) FROM t1 WHERE e>=(select min(coalesce((select max(19) from t1 where not exists(select 1 from t1 where (select count(distinct +case when coalesce((select max(case when e<a then b else (c) end) from t1 where f<>t1.d),t1.d) in (select abs(cast(avg(t1.d) AS integer)-min(t1.c)) from t1 union select -cast(avg(19) AS integer) from t1) then b when t1.e< -t1.c then t1.b else t1.c end-19*e) from t1)<=a)),17))+ -(max(a))- -cast(avg(11) AS integer)+ -count(distinct c) from t1)-11}
+} {100}
+do_test randexpr-2.1660 {
+ db eval {SELECT coalesce((select coalesce((select max(case when not a not in ((abs(11)/abs(coalesce((select t1.d from t1 where 17 in (select count(*) from t1 union select count(distinct t1.a) from t1)),b)*t1.e*c)),t1.a,t1.b) or t1.c<=t1.f or (t1.d>= -a) then (select cast(avg(~t1.f-t1.f) AS integer) from t1) else 17 end) from t1 where t1.b<=c and t1.b<=a),11) from t1 where exists(select 1 from t1 where e<c) and 11 not between t1.d and c),a) FROM t1 WHERE NOT (e>=(select min(coalesce((select max(19) from t1 where not exists(select 1 from t1 where (select count(distinct +case when coalesce((select max(case when e<a then b else (c) end) from t1 where f<>t1.d),t1.d) in (select abs(cast(avg(t1.d) AS integer)-min(t1.c)) from t1 union select -cast(avg(19) AS integer) from t1) then b when t1.e< -t1.c then t1.b else t1.c end-19*e) from t1)<=a)),17))+ -(max(a))- -cast(avg(11) AS integer)+ -count(distinct c) from t1)-11)}
+} {}
+do_test randexpr-2.1661 {
+ db eval {SELECT e*(case when +t1.c+t1.e+f<=13 then (select case cast(avg(coalesce((select (t1.f*a)*11 from t1 where c<>t1.a),b)) AS integer)+cast(avg(b) AS integer)+max( -b)-min(e) when max(11) then cast(avg(t1.e) AS integer) else cast(avg(t1.b) AS integer) end from t1) when ~11*t1.d<=t1.b or (t1.e=t1.a) then t1.b else -19 end)+e FROM t1 WHERE a>13*d+t1.e+c}
+} {}
+do_test randexpr-2.1662 {
+ db eval {SELECT e*(case when +t1.c+t1.e+f<=13 then (select case cast(avg(coalesce((select (t1.f*a)*11 from t1 where c<>t1.a),b)) AS integer)+cast(avg(b) AS integer)+max( -b)-min(e) when max(11) then cast(avg(t1.e) AS integer) else cast(avg(t1.b) AS integer) end from t1) when ~11*t1.d<=t1.b or (t1.e=t1.a) then t1.b else -19 end)+e FROM t1 WHERE NOT (a>13*d+t1.e+c)}
+} {100500}
+do_test randexpr-2.1663 {
+ db eval {SELECT (abs(t1.d-t1.b)/abs(t1.c))+t1.a*coalesce((select max(coalesce((select max(~11+11) from t1 where e-a>=case when 11*t1.d+13+(select cast(avg(t1.d+f) AS integer) from t1)-d+t1.d-b not between a and a then e else coalesce((select e from t1 where d>b and b between 11 and t1.d),t1.b) end), -t1.b)) from t1 where t1.e<=c),17)+ -t1.d FROM t1 WHERE case when (19>b) then case (abs(t1.d+case when not exists(select 1 from t1 where f in (19,d,11) and f not between t1.e and a) then (19) when a<=t1.d then 17 else t1.c end* -c*13)/abs(d))*f when 19 then t1.c else - - -t1.d end when c in (select max(t1.e) from t1 union select ( - -abs(cast(avg(t1.f) AS integer))-case cast(avg(a) AS integer) when (min(t1.f)) then max(13) else max(11) end | -((min(11)))+max((a))) from t1) then c else -b end*t1.d>d}
+} {}
+do_test randexpr-2.1664 {
+ db eval {SELECT (abs(t1.d-t1.b)/abs(t1.c))+t1.a*coalesce((select max(coalesce((select max(~11+11) from t1 where e-a>=case when 11*t1.d+13+(select cast(avg(t1.d+f) AS integer) from t1)-d+t1.d-b not between a and a then e else coalesce((select e from t1 where d>b and b between 11 and t1.d),t1.b) end), -t1.b)) from t1 where t1.e<=c),17)+ -t1.d FROM t1 WHERE NOT (case when (19>b) then case (abs(t1.d+case when not exists(select 1 from t1 where f in (19,d,11) and f not between t1.e and a) then (19) when a<=t1.d then 17 else t1.c end* -c*13)/abs(d))*f when 19 then t1.c else - - -t1.d end when c in (select max(t1.e) from t1 union select ( - -abs(cast(avg(t1.f) AS integer))-case cast(avg(a) AS integer) when (min(t1.f)) then max(13) else max(11) end | -((min(11)))+max((a))) from t1) then c else -b end*t1.d>d)}
+} {1300}
+do_test randexpr-2.1665 {
+ db eval {SELECT ~t1.a*(case when not not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where (select count(distinct b | case 13 | case when -11<>a then t1.a else b end when t1.e then t1.b else d end*t1.f) from t1)<>17 or t1.a not between c and t1.a),11) in (t1.e,c,c)) and -11>f then t1.d else f end-17)+ -(t1.b) FROM t1 WHERE (13-coalesce((select -case when 19+c=a then f else 11 end*(e) from t1 where (t1.b in (select t1.a from t1 union select 11 from t1))),(t1.f))*e+f*(t1.f)=a and not 17 in (select max(f) from t1 union select max(19) from t1) or 19<>t1.f) and 13 between f and f and d<>b}
+} {}
+do_test randexpr-2.1666 {
+ db eval {SELECT ~t1.a*(case when not not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where (select count(distinct b | case 13 | case when -11<>a then t1.a else b end when t1.e then t1.b else d end*t1.f) from t1)<>17 or t1.a not between c and t1.a),11) in (t1.e,c,c)) and -11>f then t1.d else f end-17)+ -(t1.b) FROM t1 WHERE NOT ((13-coalesce((select -case when 19+c=a then f else 11 end*(e) from t1 where (t1.b in (select t1.a from t1 union select 11 from t1))),(t1.f))*e+f*(t1.f)=a and not 17 in (select max(f) from t1 union select max(19) from t1) or 19<>t1.f) and 13 between f and f and d<>b)}
+} {-59083}
+do_test randexpr-2.1667 {
+ db eval {SELECT ~t1.a*(case when not not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where (select count(distinct b & case 13 & case when -11<>a then t1.a else b end when t1.e then t1.b else d end*t1.f) from t1)<>17 or t1.a not between c and t1.a),11) in (t1.e,c,c)) and -11>f then t1.d else f end-17)+ -(t1.b) FROM t1 WHERE NOT ((13-coalesce((select -case when 19+c=a then f else 11 end*(e) from t1 where (t1.b in (select t1.a from t1 union select 11 from t1))),(t1.f))*e+f*(t1.f)=a and not 17 in (select max(f) from t1 union select max(19) from t1) or 19<>t1.f) and 13 between f and f and d<>b)}
+} {-59083}
+do_test randexpr-2.1668 {
+ db eval {SELECT ~13+case when (t1.e-~b+13*case when b>(select max(case when (19*f in (select ~count(distinct a)+count(distinct (e)) from t1 union select (cast(avg(t1.c) AS integer)) from t1)) then coalesce((select -19 from t1 where t1.f<=c or 19 not in (t1.c, -b,19)),t1.e) when t1.e>c then e else 13 end | f) from t1) then 13 else d end in (select t1.f from t1 union select c from t1)) then t1.f when not exists(select 1 from t1 where a between f and f) then (d) else t1.c end FROM t1 WHERE exists(select 1 from t1 where case when 19 in (19,+(abs(case t1.f when e then case (select +cast(avg(a) AS integer)*min(e) from t1) when case when 19 not between -t1.c and d then 11 else t1.f end then f else t1.c end else e end+17+b)/abs(t1.d))*13,t1.f) then a when t1.d not in (f,d, -c) then t1.c else t1.b end not between d and c and t1.b not between t1.b and f)}
+} {}
+do_test randexpr-2.1669 {
+ db eval {SELECT ~13+case when (t1.e-~b+13*case when b>(select max(case when (19*f in (select ~count(distinct a)+count(distinct (e)) from t1 union select (cast(avg(t1.c) AS integer)) from t1)) then coalesce((select -19 from t1 where t1.f<=c or 19 not in (t1.c, -b,19)),t1.e) when t1.e>c then e else 13 end | f) from t1) then 13 else d end in (select t1.f from t1 union select c from t1)) then t1.f when not exists(select 1 from t1 where a between f and f) then (d) else t1.c end FROM t1 WHERE NOT (exists(select 1 from t1 where case when 19 in (19,+(abs(case t1.f when e then case (select +cast(avg(a) AS integer)*min(e) from t1) when case when 19 not between -t1.c and d then 11 else t1.f end then f else t1.c end else e end+17+b)/abs(t1.d))*13,t1.f) then a when t1.d not in (f,d, -c) then t1.c else t1.b end not between d and c and t1.b not between t1.b and f))}
+} {386}
+do_test randexpr-2.1670 {
+ db eval {SELECT ~13+case when (t1.e-~b+13*case when b>(select max(case when (19*f in (select ~count(distinct a)+count(distinct (e)) from t1 union select (cast(avg(t1.c) AS integer)) from t1)) then coalesce((select -19 from t1 where t1.f<=c or 19 not in (t1.c, -b,19)),t1.e) when t1.e>c then e else 13 end & f) from t1) then 13 else d end in (select t1.f from t1 union select c from t1)) then t1.f when not exists(select 1 from t1 where a between f and f) then (d) else t1.c end FROM t1 WHERE NOT (exists(select 1 from t1 where case when 19 in (19,+(abs(case t1.f when e then case (select +cast(avg(a) AS integer)*min(e) from t1) when case when 19 not between -t1.c and d then 11 else t1.f end then f else t1.c end else e end+17+b)/abs(t1.d))*13,t1.f) then a when t1.d not in (f,d, -c) then t1.c else t1.b end not between d and c and t1.b not between t1.b and f))}
+} {386}
+do_test randexpr-2.1671 {
+ db eval {SELECT -case coalesce((select max((case when a>t1.c | t1.a then (select abs(count(distinct a)) from t1) when (e not in (coalesce((select c from t1 where exists(select 1 from t1 where c<=11) and t1.a>e),e),d,a)) or t1.d<>e then t1.c else c end)- -11*b) from t1 where not exists(select 1 from t1 where not (c in ((t1.e),d,19)))),(t1.c))*b when 17 then t1.b else 19 end FROM t1 WHERE e<=coalesce((select t1.b from t1 where coalesce((select c*19 | (a) from t1 where not exists(select 1 from t1 where 19>=13 or case when coalesce((select max(19) from t1 where t1.e=t1.d or t1.f<>e),t1.f)>19 and t1.f=t1.d then 11+ -t1.d when -t1.f not between f and f then t1.a else d end not in ((t1.a),13,t1.a) and c in (select (13) from t1 union select f from t1) and 17<(f)) and t1.a<>t1.e),t1.d)>=t1.c),t1.f)}
+} {}
+do_test randexpr-2.1672 {
+ db eval {SELECT -case coalesce((select max((case when a>t1.c | t1.a then (select abs(count(distinct a)) from t1) when (e not in (coalesce((select c from t1 where exists(select 1 from t1 where c<=11) and t1.a>e),e),d,a)) or t1.d<>e then t1.c else c end)- -11*b) from t1 where not exists(select 1 from t1 where not (c in ((t1.e),d,19)))),(t1.c))*b when 17 then t1.b else 19 end FROM t1 WHERE NOT (e<=coalesce((select t1.b from t1 where coalesce((select c*19 | (a) from t1 where not exists(select 1 from t1 where 19>=13 or case when coalesce((select max(19) from t1 where t1.e=t1.d or t1.f<>e),t1.f)>19 and t1.f=t1.d then 11+ -t1.d when -t1.f not between f and f then t1.a else d end not in ((t1.a),13,t1.a) and c in (select (13) from t1 union select f from t1) and 17<(f)) and t1.a<>t1.e),t1.d)>=t1.c),t1.f))}
+} {-19}
+do_test randexpr-2.1673 {
+ db eval {SELECT -case coalesce((select max((case when a>t1.c & t1.a then (select abs(count(distinct a)) from t1) when (e not in (coalesce((select c from t1 where exists(select 1 from t1 where c<=11) and t1.a>e),e),d,a)) or t1.d<>e then t1.c else c end)- -11*b) from t1 where not exists(select 1 from t1 where not (c in ((t1.e),d,19)))),(t1.c))*b when 17 then t1.b else 19 end FROM t1 WHERE NOT (e<=coalesce((select t1.b from t1 where coalesce((select c*19 | (a) from t1 where not exists(select 1 from t1 where 19>=13 or case when coalesce((select max(19) from t1 where t1.e=t1.d or t1.f<>e),t1.f)>19 and t1.f=t1.d then 11+ -t1.d when -t1.f not between f and f then t1.a else d end not in ((t1.a),13,t1.a) and c in (select (13) from t1 union select f from t1) and 17<(f)) and t1.a<>t1.e),t1.d)>=t1.c),t1.f))}
+} {-19}
+do_test randexpr-2.1674 {
+ db eval {SELECT coalesce((select (11) from t1 where not e in (select -min(d*13) from t1 union select count(distinct f) from t1)),t1.f*t1.d | t1.f) FROM t1 WHERE -t1.c*d>case d when ~coalesce((select max(e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not e=c))),+coalesce((select +t1.e from t1 where not exists(select 1 from t1 where c>=t1.b)),(abs( -t1.c+case t1.c when ~~t1.c+a-t1.c then coalesce((select max(case when t1.b<=c then 19 else f end) from t1 where 13<b),d) else t1.d end)/abs(a))*(d))) then -t1.e else (13) end}
+} {}
+do_test randexpr-2.1675 {
+ db eval {SELECT coalesce((select (11) from t1 where not e in (select -min(d*13) from t1 union select count(distinct f) from t1)),t1.f*t1.d | t1.f) FROM t1 WHERE NOT ( -t1.c*d>case d when ~coalesce((select max(e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not e=c))),+coalesce((select +t1.e from t1 where not exists(select 1 from t1 where c>=t1.b)),(abs( -t1.c+case t1.c when ~~t1.c+a-t1.c then coalesce((select max(case when t1.b<=c then 19 else f end) from t1 where 13<b),d) else t1.d end)/abs(a))*(d))) then -t1.e else (13) end)}
+} {11}
+do_test randexpr-2.1676 {
+ db eval {SELECT coalesce((select (11) from t1 where not e in (select -min(d*13) from t1 union select count(distinct f) from t1)),t1.f*t1.d & t1.f) FROM t1 WHERE NOT ( -t1.c*d>case d when ~coalesce((select max(e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not e=c))),+coalesce((select +t1.e from t1 where not exists(select 1 from t1 where c>=t1.b)),(abs( -t1.c+case t1.c when ~~t1.c+a-t1.c then coalesce((select max(case when t1.b<=c then 19 else f end) from t1 where 13<b),d) else t1.d end)/abs(a))*(d))) then -t1.e else (13) end)}
+} {11}
+do_test randexpr-2.1677 {
+ db eval {SELECT +case when t1.e>=(select max(17) from t1) then case 11 when e then coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.d in (select t1.a from t1 union select e from t1) and e=case when 11<19 and t1.e<19 then t1.e when t1.c in (t1.b,t1.e,t1.d) then 13 else 13 end and e<=d or b between 19 and t1.a or t1.a<=(13))),t1.a) else t1.e-t1.d end*t1.a when -11 not in (17,t1.d,a) then t1.c else b end*19 FROM t1 WHERE not t1.b>t1.e or t1.d not in (~t1.f,d+case when (b+(abs(19*~t1.c | t1.b*d*(b)-t1.e-t1.e+a)/abs(t1.c)) not in (17,b,t1.e)) then 13+f else b end-t1.f,t1.e) or t1.e not in (f,a,t1.d)}
+} {190000}
+do_test randexpr-2.1678 {
+ db eval {SELECT +case when t1.e>=(select max(17) from t1) then case 11 when e then coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.d in (select t1.a from t1 union select e from t1) and e=case when 11<19 and t1.e<19 then t1.e when t1.c in (t1.b,t1.e,t1.d) then 13 else 13 end and e<=d or b between 19 and t1.a or t1.a<=(13))),t1.a) else t1.e-t1.d end*t1.a when -11 not in (17,t1.d,a) then t1.c else b end*19 FROM t1 WHERE NOT (not t1.b>t1.e or t1.d not in (~t1.f,d+case when (b+(abs(19*~t1.c | t1.b*d*(b)-t1.e-t1.e+a)/abs(t1.c)) not in (17,b,t1.e)) then 13+f else b end-t1.f,t1.e) or t1.e not in (f,a,t1.d))}
+} {}
+do_test randexpr-2.1679 {
+ db eval {SELECT t1.e | t1.b+a*coalesce((select t1.a from t1 where ~(d)-f<>e-c or 17+f in (select -(~case max(t1.c) when abs(count(*)) then abs( - -cast(avg(b) AS integer)*count(*)) else cast(avg(t1.c) AS integer) end) from t1 union select count(distinct (11)) from t1) and exists(select 1 from t1 where not 13>t1.e) or t1.c<d),~b)- -b FROM t1 WHERE d between t1.f and t1.c}
+} {}
+do_test randexpr-2.1680 {
+ db eval {SELECT t1.e | t1.b+a*coalesce((select t1.a from t1 where ~(d)-f<>e-c or 17+f in (select -(~case max(t1.c) when abs(count(*)) then abs( - -cast(avg(b) AS integer)*count(*)) else cast(avg(t1.c) AS integer) end) from t1 union select count(distinct (11)) from t1) and exists(select 1 from t1 where not 13>t1.e) or t1.c<d),~b)- -b FROM t1 WHERE NOT (d between t1.f and t1.c)}
+} {10740}
+do_test randexpr-2.1681 {
+ db eval {SELECT t1.e & t1.b+a*coalesce((select t1.a from t1 where ~(d)-f<>e-c or 17+f in (select -(~case max(t1.c) when abs(count(*)) then abs( - -cast(avg(b) AS integer)*count(*)) else cast(avg(t1.c) AS integer) end) from t1 union select count(distinct (11)) from t1) and exists(select 1 from t1 where not 13>t1.e) or t1.c<d),~b)- -b FROM t1 WHERE NOT (d between t1.f and t1.c)}
+} {160}
+do_test randexpr-2.1682 {
+ db eval {SELECT ~(select +~count(distinct 17)*count(distinct t1.e) from t1)-t1.e+a*11-case when 13<>t1.b then 19 when case when case (select ( -max(c)) from t1) when 11 then d else e end*t1.d<>d then a else 11 end=t1.b or 17=d then b else t1.e end+11+t1.a*a-e FROM t1 WHERE coalesce((select coalesce((select max(c) from t1 where -+ -e-t1.d*case when coalesce((select d from t1 where (c=a)),f) between t1.b and t1.b or (13)<>c and e in (t1.e,e,(t1.a)) then b*t1.c else b end+t1.c in (select t1.f from t1 union select t1.b from t1)),19) from t1 where t1.f in (select count(*) from t1 union select cast(avg(t1.e) AS integer)*min((a))*+(max(t1.b))+max(17) from t1)),t1.d)< -e}
+} {}
+do_test randexpr-2.1683 {
+ db eval {SELECT ~(select +~count(distinct 17)*count(distinct t1.e) from t1)-t1.e+a*11-case when 13<>t1.b then 19 when case when case (select ( -max(c)) from t1) when 11 then d else e end*t1.d<>d then a else 11 end=t1.b or 17=d then b else t1.e end+11+t1.a*a-e FROM t1 WHERE NOT (coalesce((select coalesce((select max(c) from t1 where -+ -e-t1.d*case when coalesce((select d from t1 where (c=a)),f) between t1.b and t1.b or (13)<>c and e in (t1.e,e,(t1.a)) then b*t1.c else b end+t1.c in (select t1.f from t1 union select t1.b from t1)),19) from t1 where t1.f in (select count(*) from t1 union select cast(avg(t1.e) AS integer)*min((a))*+(max(t1.b))+max(17) from t1)),t1.d)< -e)}
+} {10093}
+do_test randexpr-2.1684 {
+ db eval {SELECT coalesce((select max(case when f<=(17-coalesce((select ~t1.e+11 from t1 where t1.f in (select c from t1 union select b from t1)),f)) then -case when e>case when 17+ -t1.b in (select cast(avg(f) AS integer) from t1 union select min(c-17+a) from t1) then -17 else t1.d end then a when 19<11 then t1.a else t1.b end | t1.f else a end) from t1 where e between a and d),19) FROM t1 WHERE case 19 when ((select max(f) from t1)) then 13 else t1.d end-t1.c>a-b-t1.d}
+} {19}
+do_test randexpr-2.1685 {
+ db eval {SELECT coalesce((select max(case when f<=(17-coalesce((select ~t1.e+11 from t1 where t1.f in (select c from t1 union select b from t1)),f)) then -case when e>case when 17+ -t1.b in (select cast(avg(f) AS integer) from t1 union select min(c-17+a) from t1) then -17 else t1.d end then a when 19<11 then t1.a else t1.b end | t1.f else a end) from t1 where e between a and d),19) FROM t1 WHERE NOT (case 19 when ((select max(f) from t1)) then 13 else t1.d end-t1.c>a-b-t1.d)}
+} {}
+do_test randexpr-2.1686 {
+ db eval {SELECT coalesce((select max(case when f<=(17-coalesce((select ~t1.e+11 from t1 where t1.f in (select c from t1 union select b from t1)),f)) then -case when e>case when 17+ -t1.b in (select cast(avg(f) AS integer) from t1 union select min(c-17+a) from t1) then -17 else t1.d end then a when 19<11 then t1.a else t1.b end & t1.f else a end) from t1 where e between a and d),19) FROM t1 WHERE case 19 when ((select max(f) from t1)) then 13 else t1.d end-t1.c>a-b-t1.d}
+} {19}
+do_test randexpr-2.1687 {
+ db eval {SELECT case when (select case min(t1.b) when max(13) | +max(t1.e)*max(f) then abs( -+count(*)) else max(t1.f) end from t1)*t1.a+(abs(case 19 when 19 then d else ((13)) end)/abs(13))+(19) between f and 13 or (not not 17<e) then (abs(17)/abs((f))) when f in (select min(f) from t1 union select cast(avg(11) AS integer) from t1) then c else b end FROM t1 WHERE exists(select 1 from t1 where f<13)}
+} {}
+do_test randexpr-2.1688 {
+ db eval {SELECT case when (select case min(t1.b) when max(13) | +max(t1.e)*max(f) then abs( -+count(*)) else max(t1.f) end from t1)*t1.a+(abs(case 19 when 19 then d else ((13)) end)/abs(13))+(19) between f and 13 or (not not 17<e) then (abs(17)/abs((f))) when f in (select min(f) from t1 union select cast(avg(11) AS integer) from t1) then c else b end FROM t1 WHERE NOT (exists(select 1 from t1 where f<13))}
+} {0}
+do_test randexpr-2.1689 {
+ db eval {SELECT case when (select case min(t1.b) when max(13) & +max(t1.e)*max(f) then abs( -+count(*)) else max(t1.f) end from t1)*t1.a+(abs(case 19 when 19 then d else ((13)) end)/abs(13))+(19) between f and 13 or (not not 17<e) then (abs(17)/abs((f))) when f in (select min(f) from t1 union select cast(avg(11) AS integer) from t1) then c else b end FROM t1 WHERE NOT (exists(select 1 from t1 where f<13))}
+} {0}
+do_test randexpr-2.1690 {
+ db eval {SELECT coalesce((select +(select max(coalesce((select (abs(((t1.e)+b))/abs(f))+e from t1 where (select (case min(t1.b) when count(*) then count(*) else abs(++count(distinct t1.a)+cast(avg(d) AS integer)) end)+min(f)-max(11) from t1)<>~17),t1.e+(select count(*) from t1) | 11-coalesce((select 13 from t1 where 11 not in ( -t1.f,t1.e,t1.f)),t1.b))+ -(t1.c)) from t1) from t1 where t1.a=(13)), -a)*e FROM t1 WHERE not exists(select 1 from t1 where (select count(distinct t1.e) from t1)<=coalesce((select case when not exists(select 1 from t1 where e=t1.b*coalesce((select max(+b) from t1 where exists(select 1 from t1 where not (not not exists(select 1 from t1 where t1.c in (select 11 from t1 union select 19+13 from t1)))) and not t1.b<a),case when b in (t1.c,t1.e,f) and b=t1.a then ~b when 13 not between d and 11 then -t1.d-c else t1.d end)) then (abs((11))/abs(17)) else b end from t1 where t1.b not in (t1.f,t1.e,17)), -t1.d))}
+} {-50000}
+do_test randexpr-2.1691 {
+ db eval {SELECT coalesce((select +(select max(coalesce((select (abs(((t1.e)+b))/abs(f))+e from t1 where (select (case min(t1.b) when count(*) then count(*) else abs(++count(distinct t1.a)+cast(avg(d) AS integer)) end)+min(f)-max(11) from t1)<>~17),t1.e+(select count(*) from t1) | 11-coalesce((select 13 from t1 where 11 not in ( -t1.f,t1.e,t1.f)),t1.b))+ -(t1.c)) from t1) from t1 where t1.a=(13)), -a)*e FROM t1 WHERE NOT (not exists(select 1 from t1 where (select count(distinct t1.e) from t1)<=coalesce((select case when not exists(select 1 from t1 where e=t1.b*coalesce((select max(+b) from t1 where exists(select 1 from t1 where not (not not exists(select 1 from t1 where t1.c in (select 11 from t1 union select 19+13 from t1)))) and not t1.b<a),case when b in (t1.c,t1.e,f) and b=t1.a then ~b when 13 not between d and 11 then -t1.d-c else t1.d end)) then (abs((11))/abs(17)) else b end from t1 where t1.b not in (t1.f,t1.e,17)), -t1.d)))}
+} {}
+do_test randexpr-2.1692 {
+ db eval {SELECT coalesce((select +(select max(coalesce((select (abs(((t1.e)+b))/abs(f))+e from t1 where (select (case min(t1.b) when count(*) then count(*) else abs(++count(distinct t1.a)+cast(avg(d) AS integer)) end)+min(f)-max(11) from t1)<>~17),t1.e+(select count(*) from t1) & 11-coalesce((select 13 from t1 where 11 not in ( -t1.f,t1.e,t1.f)),t1.b))+ -(t1.c)) from t1) from t1 where t1.a=(13)), -a)*e FROM t1 WHERE not exists(select 1 from t1 where (select count(distinct t1.e) from t1)<=coalesce((select case when not exists(select 1 from t1 where e=t1.b*coalesce((select max(+b) from t1 where exists(select 1 from t1 where not (not not exists(select 1 from t1 where t1.c in (select 11 from t1 union select 19+13 from t1)))) and not t1.b<a),case when b in (t1.c,t1.e,f) and b=t1.a then ~b when 13 not between d and 11 then -t1.d-c else t1.d end)) then (abs((11))/abs(17)) else b end from t1 where t1.b not in (t1.f,t1.e,17)), -t1.d))}
+} {-50000}
+do_test randexpr-2.1693 {
+ db eval {SELECT ~~t1.b | 11+d*coalesce((select max(t1.f-a) from t1 where not exists(select 1 from t1 where (a-coalesce((select b from t1 where t1.f<case when not exists(select 1 from t1 where 11=b or d<>e) then t1.e*c else c end-13+t1.a),f)+t1.d- -t1.a)*t1.c<>f) and t1.b not between (e) and t1.c),f)+11*t1.f FROM t1 WHERE (17 in (select 13 from t1 union select case coalesce((select max( -case when not b in ((select -+case max((b)) when cast(avg(13) AS integer) then count(*) else max(a) end+min(b)-max(d) from t1),coalesce((select t1.d from t1 where case when -13 in ( -t1.e,f,t1.e) then t1.c else e end | 11<=(t1.b)),t1.c)-11,t1.e) then t1.f else 13 end) from t1 where b>=t1.e),f) when e then t1.c else c end from t1))}
+} {}
+do_test randexpr-2.1694 {
+ db eval {SELECT ~~t1.b | 11+d*coalesce((select max(t1.f-a) from t1 where not exists(select 1 from t1 where (a-coalesce((select b from t1 where t1.f<case when not exists(select 1 from t1 where 11=b or d<>e) then t1.e*c else c end-13+t1.a),f)+t1.d- -t1.a)*t1.c<>f) and t1.b not between (e) and t1.c),f)+11*t1.f FROM t1 WHERE NOT ((17 in (select 13 from t1 union select case coalesce((select max( -case when not b in ((select -+case max((b)) when cast(avg(13) AS integer) then count(*) else max(a) end+min(b)-max(d) from t1),coalesce((select t1.d from t1 where case when -13 in ( -t1.e,f,t1.e) then t1.c else e end | 11<=(t1.b)),t1.c)-11,t1.e) then t1.f else 13 end) from t1 where b>=t1.e),f) when e then t1.c else c end from t1)))}
+} {246747}
+do_test randexpr-2.1695 {
+ db eval {SELECT ~~t1.b & 11+d*coalesce((select max(t1.f-a) from t1 where not exists(select 1 from t1 where (a-coalesce((select b from t1 where t1.f<case when not exists(select 1 from t1 where 11=b or d<>e) then t1.e*c else c end-13+t1.a),f)+t1.d- -t1.a)*t1.c<>f) and t1.b not between (e) and t1.c),f)+11*t1.f FROM t1 WHERE NOT ((17 in (select 13 from t1 union select case coalesce((select max( -case when not b in ((select -+case max((b)) when cast(avg(13) AS integer) then count(*) else max(a) end+min(b)-max(d) from t1),coalesce((select t1.d from t1 where case when -13 in ( -t1.e,f,t1.e) then t1.c else e end | 11<=(t1.b)),t1.c)-11,t1.e) then t1.f else 13 end) from t1 where b>=t1.e),f) when e then t1.c else c end from t1)))}
+} {64}
+do_test randexpr-2.1696 {
+ db eval {SELECT case case when not ++b+~e-11-d-f*e*case when (t1.f) not between t1.c and t1.e or (13>e) then (abs(17)/abs(d)) when 11 not between 17 and (t1.b) then c else 13 end-(f)-f between t1.c and t1.f then t1.c when a between t1.d and 13 then t1.e else t1.a end when a then f else 13 end FROM t1 WHERE t1.a in (select case when (+e*t1.f not in ( -(select (case max(+t1.e-case when not exists(select 1 from t1 where 19 in (select 13 from t1 union select ((t1.d)) from t1)) then 13-t1.b else 19 end) when count(*)-(cast(avg(t1.b) AS integer)-cast(avg(b) AS integer)) then count(distinct t1.b) else count(distinct t1.c) end | cast(avg((19)) AS integer)) from t1),~17-f,c)) then (select count(*) from t1) when t1.a>t1.a then b else t1.d end+(f) from t1 union select b from t1)}
+} {}
+do_test randexpr-2.1697 {
+ db eval {SELECT case case when not ++b+~e-11-d-f*e*case when (t1.f) not between t1.c and t1.e or (13>e) then (abs(17)/abs(d)) when 11 not between 17 and (t1.b) then c else 13 end-(f)-f between t1.c and t1.f then t1.c when a between t1.d and 13 then t1.e else t1.a end when a then f else 13 end FROM t1 WHERE NOT (t1.a in (select case when (+e*t1.f not in ( -(select (case max(+t1.e-case when not exists(select 1 from t1 where 19 in (select 13 from t1 union select ((t1.d)) from t1)) then 13-t1.b else 19 end) when count(*)-(cast(avg(t1.b) AS integer)-cast(avg(b) AS integer)) then count(distinct t1.b) else count(distinct t1.c) end | cast(avg((19)) AS integer)) from t1),~17-f,c)) then (select count(*) from t1) when t1.a>t1.a then b else t1.d end+(f) from t1 union select b from t1))}
+} {13}
+do_test randexpr-2.1698 {
+ db eval {SELECT 13-case when a<=case when e not between t1.b*(abs(t1.c)/abs(e | 19-(select -~count(distinct t1.b)+min(t1.a-t1.c-f+t1.d+t1.d+t1.d) from t1)))-t1.e and coalesce((select 11 from t1 where c<e),d)* -d then 17 else t1.e end then t1.c else 17 end+f FROM t1 WHERE (t1.f<>t1.c)}
+} {596}
+do_test randexpr-2.1699 {
+ db eval {SELECT 13-case when a<=case when e not between t1.b*(abs(t1.c)/abs(e | 19-(select -~count(distinct t1.b)+min(t1.a-t1.c-f+t1.d+t1.d+t1.d) from t1)))-t1.e and coalesce((select 11 from t1 where c<e),d)* -d then 17 else t1.e end then t1.c else 17 end+f FROM t1 WHERE NOT ((t1.f<>t1.c))}
+} {}
+do_test randexpr-2.1700 {
+ db eval {SELECT 13-case when a<=case when e not between t1.b*(abs(t1.c)/abs(e & 19-(select -~count(distinct t1.b)+min(t1.a-t1.c-f+t1.d+t1.d+t1.d) from t1)))-t1.e and coalesce((select 11 from t1 where c<e),d)* -d then 17 else t1.e end then t1.c else 17 end+f FROM t1 WHERE (t1.f<>t1.c)}
+} {596}
+do_test randexpr-2.1701 {
+ db eval {SELECT (case when coalesce((select max(~case coalesce((select max(b) from t1 where case (select count(distinct 17) from t1)-e when b then d else t1.b end<13),f) when c then (( -c)) else 13 end) from t1 where t1.e between a and b),t1.b) in (select -min(t1.f) from t1 union select case cast(avg(t1.d) AS integer) when count(distinct b) then case +~ -cast(avg(b) AS integer) when max(t1.f) then count(*) else (max(e)) end else count(*) end from t1) then c when 13<=t1.f then ( -17) else t1.b end) FROM t1 WHERE (select min(19*coalesce((select max(t1.e) from t1 where ~coalesce((select t1.a-coalesce((select max((abs(a)/abs(d))) from t1 where -13 not in ((d)*t1.a+t1.e,13,t1.c) or 17 not in (a,b,t1.d)), -t1.a) from t1 where c<>t1.e),a) | 11+17 between b and 17),c))*~ -max(e) from t1)<>11}
+} {-17}
+do_test randexpr-2.1702 {
+ db eval {SELECT (case when coalesce((select max(~case coalesce((select max(b) from t1 where case (select count(distinct 17) from t1)-e when b then d else t1.b end<13),f) when c then (( -c)) else 13 end) from t1 where t1.e between a and b),t1.b) in (select -min(t1.f) from t1 union select case cast(avg(t1.d) AS integer) when count(distinct b) then case +~ -cast(avg(b) AS integer) when max(t1.f) then count(*) else (max(e)) end else count(*) end from t1) then c when 13<=t1.f then ( -17) else t1.b end) FROM t1 WHERE NOT ((select min(19*coalesce((select max(t1.e) from t1 where ~coalesce((select t1.a-coalesce((select max((abs(a)/abs(d))) from t1 where -13 not in ((d)*t1.a+t1.e,13,t1.c) or 17 not in (a,b,t1.d)), -t1.a) from t1 where c<>t1.e),a) | 11+17 between b and 17),c))*~ -max(e) from t1)<>11)}
+} {}
+do_test randexpr-2.1703 {
+ db eval {SELECT t1.f* -t1.e-c | b++19*(select (case max(t1.c) when +abs(count(distinct case when e<t1.a then 19 else d end)) then -count(distinct e) else (((count(distinct t1.d)))) end | max(e)+(cast(avg(t1.c) AS integer)))+count(*) from t1)+case when t1.d>=13 then coalesce((select max(t1.c) from t1 where not -c+b-t1.f<>d),a) else b end FROM t1 WHERE d in (select 11 from t1 union select -d*~t1.b from t1)}
+} {}
+do_test randexpr-2.1704 {
+ db eval {SELECT t1.f* -t1.e-c | b++19*(select (case max(t1.c) when +abs(count(distinct case when e<t1.a then 19 else d end)) then -count(distinct e) else (((count(distinct t1.d)))) end | max(e)+(cast(avg(t1.c) AS integer)))+count(*) from t1)+case when t1.d>=13 then coalesce((select max(t1.c) from t1 where not -c+b-t1.f<>d),a) else b end FROM t1 WHERE NOT (d in (select 11 from t1 union select -d*~t1.b from t1))}
+} {-295178}
+do_test randexpr-2.1705 {
+ db eval {SELECT t1.f* -t1.e-c & b++19*(select (case max(t1.c) when +abs(count(distinct case when e<t1.a then 19 else d end)) then -count(distinct e) else (((count(distinct t1.d)))) end & max(e)+(cast(avg(t1.c) AS integer)))+count(*) from t1)+case when t1.d>=13 then coalesce((select max(t1.c) from t1 where not -c+b-t1.f<>d),a) else b end FROM t1 WHERE NOT (d in (select 11 from t1 union select -d*~t1.b from t1))}
+} {52}
+do_test randexpr-2.1706 {
+ db eval {SELECT 11-t1.e+d+case case when (b between -+case when f not between case coalesce((select t1.a from t1 where e not between (t1.d) and t1.a or 17<11),t1.d) when 17 then t1.f else t1.e end and d then 17 when e>=t1.f then t1.b else t1.b end and t1.e) then case f when t1.d then t1.c else -e end when (not exists(select 1 from t1 where -(11)>a) or t1.c<b) then 17 else 11 end when (t1.e) then d else t1.e end FROM t1 WHERE not (f)>t1.e}
+} {}
+do_test randexpr-2.1707 {
+ db eval {SELECT 11-t1.e+d+case case when (b between -+case when f not between case coalesce((select t1.a from t1 where e not between (t1.d) and t1.a or 17<11),t1.d) when 17 then t1.f else t1.e end and d then 17 when e>=t1.f then t1.b else t1.b end and t1.e) then case f when t1.d then t1.c else -e end when (not exists(select 1 from t1 where -(11)>a) or t1.c<b) then 17 else 11 end when (t1.e) then d else t1.e end FROM t1 WHERE NOT (not (f)>t1.e)}
+} {411}
+do_test randexpr-2.1708 {
+ db eval {SELECT coalesce((select max(case when f>11 then 13 when 19*e+(select -count(distinct t1.c)-max(c) | count(distinct 13) from t1) between coalesce((select max(case when t1.a<t1.c and (t1.a)<=d then c when 17 between t1.b and b then (t1.c) else a end) from t1 where -19 in (select min(11) from t1 union select count(*) from t1)),11) and 11 or (exists(select 1 from t1 where not exists(select 1 from t1 where c not between ( -b) and e))) and b not between 17 and t1.a and 19<b then 17 else f end) from t1 where t1.b between t1.c and 13 and t1.b<>e),17) FROM t1 WHERE case case 13+coalesce((select max( -t1.b*t1.c) from t1 where t1.c*c<>(select -(count(distinct e)) from t1)-t1.c | t1.d*t1.e+11*t1.a+11-t1.a*b),d)+t1.d+e when t1.f then e else -11 end-d when t1.e then 11 else f end+f=19}
+} {}
+do_test randexpr-2.1709 {
+ db eval {SELECT coalesce((select max(case when f>11 then 13 when 19*e+(select -count(distinct t1.c)-max(c) | count(distinct 13) from t1) between coalesce((select max(case when t1.a<t1.c and (t1.a)<=d then c when 17 between t1.b and b then (t1.c) else a end) from t1 where -19 in (select min(11) from t1 union select count(*) from t1)),11) and 11 or (exists(select 1 from t1 where not exists(select 1 from t1 where c not between ( -b) and e))) and b not between 17 and t1.a and 19<b then 17 else f end) from t1 where t1.b between t1.c and 13 and t1.b<>e),17) FROM t1 WHERE NOT (case case 13+coalesce((select max( -t1.b*t1.c) from t1 where t1.c*c<>(select -(count(distinct e)) from t1)-t1.c | t1.d*t1.e+11*t1.a+11-t1.a*b),d)+t1.d+e when t1.f then e else -11 end-d when t1.e then 11 else f end+f=19)}
+} {17}
+do_test randexpr-2.1710 {
+ db eval {SELECT coalesce((select max(case when f>11 then 13 when 19*e+(select -count(distinct t1.c)-max(c) & count(distinct 13) from t1) between coalesce((select max(case when t1.a<t1.c and (t1.a)<=d then c when 17 between t1.b and b then (t1.c) else a end) from t1 where -19 in (select min(11) from t1 union select count(*) from t1)),11) and 11 or (exists(select 1 from t1 where not exists(select 1 from t1 where c not between ( -b) and e))) and b not between 17 and t1.a and 19<b then 17 else f end) from t1 where t1.b between t1.c and 13 and t1.b<>e),17) FROM t1 WHERE NOT (case case 13+coalesce((select max( -t1.b*t1.c) from t1 where t1.c*c<>(select -(count(distinct e)) from t1)-t1.c | t1.d*t1.e+11*t1.a+11-t1.a*b),d)+t1.d+e when t1.f then e else -11 end-d when t1.e then 11 else f end+f=19)}
+} {17}
+do_test randexpr-2.1711 {
+ db eval {SELECT 13+coalesce((select -(abs(b)/abs(coalesce((select (abs(e+t1.a)/abs(13)) from t1 where a<c), -19)+t1.a+t1.c)) from t1 where (not t1.a not between e and e)),t1.d) FROM t1 WHERE ~(abs(t1.f)/abs(f)) not in (f,case c when coalesce((select max(17) from t1 where case when 17 not between 13 and 11+case when exists(select 1 from t1 where t1.e<c) then case when d between f and t1.c then 19 when 11 in (t1.a,11,e) then a else t1.e end else 13 end | 11+17 then t1.e else e end<>17 and t1.d<>t1.f),17)+a- -t1.d then t1.d else -t1.b end,b)}
+} {413}
+do_test randexpr-2.1712 {
+ db eval {SELECT 13+coalesce((select -(abs(b)/abs(coalesce((select (abs(e+t1.a)/abs(13)) from t1 where a<c), -19)+t1.a+t1.c)) from t1 where (not t1.a not between e and e)),t1.d) FROM t1 WHERE NOT (~(abs(t1.f)/abs(f)) not in (f,case c when coalesce((select max(17) from t1 where case when 17 not between 13 and 11+case when exists(select 1 from t1 where t1.e<c) then case when d between f and t1.c then 19 when 11 in (t1.a,11,e) then a else t1.e end else 13 end | 11+17 then t1.e else e end<>17 and t1.d<>t1.f),17)+a- -t1.d then t1.d else -t1.b end,b))}
+} {}
+do_test randexpr-2.1713 {
+ db eval {SELECT (~(abs(case when t1.f*17 not in (coalesce((select 13 from t1 where d in (select count(distinct t1.e- -t1.e+t1.e*11) from t1 union select (abs(~~(cast(avg(d) AS integer))* -(min(13))+max(d) | min(13))) from t1)),d),a,t1.e) then c else t1.c end-c)/abs((t1.d)))*t1.c)*t1.d+t1.b-b FROM t1 WHERE (abs(case when (t1.e+case when t1.f+t1.d*t1.c<=t1.f or t1.c>=a and a not between 19 and t1.e then e else b end-t1.c) | t1.b<>19 then t1.f when 19<=t1.d and not -t1.c>=11 and t1.a between t1.f and (19) then b else t1.c end)/abs(b))+11>=t1.f and t1.f not between f and t1.a}
+} {}
+do_test randexpr-2.1714 {
+ db eval {SELECT (~(abs(case when t1.f*17 not in (coalesce((select 13 from t1 where d in (select count(distinct t1.e- -t1.e+t1.e*11) from t1 union select (abs(~~(cast(avg(d) AS integer))* -(min(13))+max(d) | min(13))) from t1)),d),a,t1.e) then c else t1.c end-c)/abs((t1.d)))*t1.c)*t1.d+t1.b-b FROM t1 WHERE NOT ((abs(case when (t1.e+case when t1.f+t1.d*t1.c<=t1.f or t1.c>=a and a not between 19 and t1.e then e else b end-t1.c) | t1.b<>19 then t1.f when 19<=t1.d and not -t1.c>=11 and t1.a between t1.f and (19) then b else t1.c end)/abs(b))+11>=t1.f and t1.f not between f and t1.a)}
+} {-120000}
+do_test randexpr-2.1715 {
+ db eval {SELECT (~(abs(case when t1.f*17 not in (coalesce((select 13 from t1 where d in (select count(distinct t1.e- -t1.e+t1.e*11) from t1 union select (abs(~~(cast(avg(d) AS integer))* -(min(13))+max(d) & min(13))) from t1)),d),a,t1.e) then c else t1.c end-c)/abs((t1.d)))*t1.c)*t1.d+t1.b-b FROM t1 WHERE NOT ((abs(case when (t1.e+case when t1.f+t1.d*t1.c<=t1.f or t1.c>=a and a not between 19 and t1.e then e else b end-t1.c) | t1.b<>19 then t1.f when 19<=t1.d and not -t1.c>=11 and t1.a between t1.f and (19) then b else t1.c end)/abs(b))+11>=t1.f and t1.f not between f and t1.a)}
+} {-120000}
+do_test randexpr-2.1716 {
+ db eval {SELECT (abs(a)/abs(case when (not t1.f in (select count(*) from t1 union select - -min(c) | min(13*t1.d) from t1)) and ( -t1.a*t1.d)>=d or (t1.a in (a,11,f)) or (c>=t1.a) then 17+case when not exists(select 1 from t1 where e<t1.f) then + -(e)-d when t1.e in (19,19, -e) then -t1.f else t1.a end else t1.b end)) FROM t1 WHERE t1.d in (select min(t1.d) from t1 union select +~case abs(max(case when t1.e not between 19-f | f | t1.c and b then t1.b else e end+b) | count(distinct f)) when count(distinct e) then count(*) else (+count(*)-(count(*))+min(t1.d)) end from t1) and (f)*coalesce((select 17 from t1 where f between t1.e and a),(13))<=b}
+} {}
+do_test randexpr-2.1717 {
+ db eval {SELECT (abs(a)/abs(case when (not t1.f in (select count(*) from t1 union select - -min(c) | min(13*t1.d) from t1)) and ( -t1.a*t1.d)>=d or (t1.a in (a,11,f)) or (c>=t1.a) then 17+case when not exists(select 1 from t1 where e<t1.f) then + -(e)-d when t1.e in (19,19, -e) then -t1.f else t1.a end else t1.b end)) FROM t1 WHERE NOT (t1.d in (select min(t1.d) from t1 union select +~case abs(max(case when t1.e not between 19-f | f | t1.c and b then t1.b else e end+b) | count(distinct f)) when count(distinct e) then count(*) else (+count(*)-(count(*))+min(t1.d)) end from t1) and (f)*coalesce((select 17 from t1 where f between t1.e and a),(13))<=b)}
+} {0}
+do_test randexpr-2.1718 {
+ db eval {SELECT (abs(a)/abs(case when (not t1.f in (select count(*) from t1 union select - -min(c) & min(13*t1.d) from t1)) and ( -t1.a*t1.d)>=d or (t1.a in (a,11,f)) or (c>=t1.a) then 17+case when not exists(select 1 from t1 where e<t1.f) then + -(e)-d when t1.e in (19,19, -e) then -t1.f else t1.a end else t1.b end)) FROM t1 WHERE NOT (t1.d in (select min(t1.d) from t1 union select +~case abs(max(case when t1.e not between 19-f | f | t1.c and b then t1.b else e end+b) | count(distinct f)) when count(distinct e) then count(*) else (+count(*)-(count(*))+min(t1.d)) end from t1) and (f)*coalesce((select 17 from t1 where f between t1.e and a),(13))<=b)}
+} {0}
+do_test randexpr-2.1719 {
+ db eval {SELECT +case when case when coalesce((select c from t1 where (exists(select 1 from t1 where not (abs(b)/abs(t1.b)) not between f and 19 and -b>c)) and 13 between t1.c and 17 or a=13),coalesce((select a from t1 where (t1.d) in (c,11,t1.c)),t1.d)) | c | coalesce((select max(d) from t1 where t1.b>b),t1.a)=19 then e else 13 end between t1.a and t1.f and 17>=c then a when d in (e,13,c) or t1.b<> -19 then (17) else 17 end FROM t1 WHERE -b in (t1.b,t1.f,case when a in (select case +(min(t1.c)*+~cast(avg(+t1.f) AS integer)*cast(avg(d) AS integer) | abs(count(*))+count(*)*count(distinct 17)) when count(distinct e) then -cast(avg(t1.a) AS integer) else min(11) end from t1 union select ((min(13))) from t1) then (abs(t1.d)/abs(case when -19<b then t1.e- -f+f else b end)) when t1.a between t1.f and 13 then f else t1.e end)}
+} {}
+do_test randexpr-2.1720 {
+ db eval {SELECT +case when case when coalesce((select c from t1 where (exists(select 1 from t1 where not (abs(b)/abs(t1.b)) not between f and 19 and -b>c)) and 13 between t1.c and 17 or a=13),coalesce((select a from t1 where (t1.d) in (c,11,t1.c)),t1.d)) | c | coalesce((select max(d) from t1 where t1.b>b),t1.a)=19 then e else 13 end between t1.a and t1.f and 17>=c then a when d in (e,13,c) or t1.b<> -19 then (17) else 17 end FROM t1 WHERE NOT ( -b in (t1.b,t1.f,case when a in (select case +(min(t1.c)*+~cast(avg(+t1.f) AS integer)*cast(avg(d) AS integer) | abs(count(*))+count(*)*count(distinct 17)) when count(distinct e) then -cast(avg(t1.a) AS integer) else min(11) end from t1 union select ((min(13))) from t1) then (abs(t1.d)/abs(case when -19<b then t1.e- -f+f else b end)) when t1.a between t1.f and 13 then f else t1.e end))}
+} {17}
+do_test randexpr-2.1721 {
+ db eval {SELECT +case when case when coalesce((select c from t1 where (exists(select 1 from t1 where not (abs(b)/abs(t1.b)) not between f and 19 and -b>c)) and 13 between t1.c and 17 or a=13),coalesce((select a from t1 where (t1.d) in (c,11,t1.c)),t1.d)) & c & coalesce((select max(d) from t1 where t1.b>b),t1.a)=19 then e else 13 end between t1.a and t1.f and 17>=c then a when d in (e,13,c) or t1.b<> -19 then (17) else 17 end FROM t1 WHERE NOT ( -b in (t1.b,t1.f,case when a in (select case +(min(t1.c)*+~cast(avg(+t1.f) AS integer)*cast(avg(d) AS integer) | abs(count(*))+count(*)*count(distinct 17)) when count(distinct e) then -cast(avg(t1.a) AS integer) else min(11) end from t1 union select ((min(13))) from t1) then (abs(t1.d)/abs(case when -19<b then t1.e- -f+f else b end)) when t1.a between t1.f and 13 then f else t1.e end))}
+} {17}
+do_test randexpr-2.1722 {
+ db eval {SELECT coalesce((select t1.b from t1 where not exists(select 1 from t1 where 13 in (select count(*) | ~min((select max((abs(d)/abs(t1.e+t1.e))) from t1)* -case when f*case e*~a when case e when (d) then 19 else (b) end then d else 17 end*t1.b between 11 and 13 then e when d in (a,(19),e) then c else 13 end-e*17) from t1 union select (count(*)) from t1))),f) FROM t1 WHERE not exists(select 1 from t1 where t1.a<>e)}
+} {}
+do_test randexpr-2.1723 {
+ db eval {SELECT coalesce((select t1.b from t1 where not exists(select 1 from t1 where 13 in (select count(*) | ~min((select max((abs(d)/abs(t1.e+t1.e))) from t1)* -case when f*case e*~a when case e when (d) then 19 else (b) end then d else 17 end*t1.b between 11 and 13 then e when d in (a,(19),e) then c else 13 end-e*17) from t1 union select (count(*)) from t1))),f) FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.a<>e))}
+} {200}
+do_test randexpr-2.1724 {
+ db eval {SELECT coalesce((select t1.b from t1 where not exists(select 1 from t1 where 13 in (select count(*) & ~min((select max((abs(d)/abs(t1.e+t1.e))) from t1)* -case when f*case e*~a when case e when (d) then 19 else (b) end then d else 17 end*t1.b between 11 and 13 then e when d in (a,(19),e) then c else 13 end-e*17) from t1 union select (count(*)) from t1))),f) FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.a<>e))}
+} {200}
+do_test randexpr-2.1725 {
+ db eval {SELECT - -case b when +~coalesce((select max(coalesce((select c from t1 where coalesce((select max(t1.a+f) from t1 where (t1.a not between t1.a and t1.e)),t1.a)-b not between e and -t1.d),d)+19) from t1 where (f in (select ( -count(*) | count(*)+cast(avg(11) AS integer)) from t1 union select count(distinct 13) from t1) or -b<>19 or 17>=t1.a)),t1.e)-c-t1.d then t1.a else 19 end- - -11 FROM t1 WHERE d+a*~coalesce((select max((select count(distinct t1.e)-max(t1.d) from t1)) from t1 where not exists(select 1 from t1 where t1.e in (11-f*19,a,c-b)) and 11=t1.b),t1.a)=(t1.b) and -t1.b<case when (+11 | coalesce((select t1.f from t1 where b<=(t1.b) and -t1.e<=(t1.f)),13) | t1.e between 13 and 19) then 17 else 11 end}
+} {}
+do_test randexpr-2.1726 {
+ db eval {SELECT - -case b when +~coalesce((select max(coalesce((select c from t1 where coalesce((select max(t1.a+f) from t1 where (t1.a not between t1.a and t1.e)),t1.a)-b not between e and -t1.d),d)+19) from t1 where (f in (select ( -count(*) | count(*)+cast(avg(11) AS integer)) from t1 union select count(distinct 13) from t1) or -b<>19 or 17>=t1.a)),t1.e)-c-t1.d then t1.a else 19 end- - -11 FROM t1 WHERE NOT (d+a*~coalesce((select max((select count(distinct t1.e)-max(t1.d) from t1)) from t1 where not exists(select 1 from t1 where t1.e in (11-f*19,a,c-b)) and 11=t1.b),t1.a)=(t1.b) and -t1.b<case when (+11 | coalesce((select t1.f from t1 where b<=(t1.b) and -t1.e<=(t1.f)),13) | t1.e between 13 and 19) then 17 else 11 end)}
+} {8}
+do_test randexpr-2.1727 {
+ db eval {SELECT - -case b when +~coalesce((select max(coalesce((select c from t1 where coalesce((select max(t1.a+f) from t1 where (t1.a not between t1.a and t1.e)),t1.a)-b not between e and -t1.d),d)+19) from t1 where (f in (select ( -count(*) & count(*)+cast(avg(11) AS integer)) from t1 union select count(distinct 13) from t1) or -b<>19 or 17>=t1.a)),t1.e)-c-t1.d then t1.a else 19 end- - -11 FROM t1 WHERE NOT (d+a*~coalesce((select max((select count(distinct t1.e)-max(t1.d) from t1)) from t1 where not exists(select 1 from t1 where t1.e in (11-f*19,a,c-b)) and 11=t1.b),t1.a)=(t1.b) and -t1.b<case when (+11 | coalesce((select t1.f from t1 where b<=(t1.b) and -t1.e<=(t1.f)),13) | t1.e between 13 and 19) then 17 else 11 end)}
+} {8}
+do_test randexpr-2.1728 {
+ db eval {SELECT -(abs(t1.a)/abs(case when coalesce((select max( -c) from t1 where t1.a*e>coalesce((select max(coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where e | t1.f-19 between t1.e-a and b and e>=t1.d)),+d)) from t1 where (exists(select 1 from t1 where t1.b in (select 19 from t1 union select 17 from t1) or 11 between t1.b and d))),c)),t1.e)*t1.a<=c then b else t1.d end)) FROM t1 WHERE (select abs( -abs(abs(case count(*) when ~ -min(f)+case - -abs(+cast(avg(c*17) AS integer)) when count(*) then max(t1.a) else max(11) end+(cast(avg(e) AS integer)) then min(17) else count(*) end-cast(avg(a) AS integer)-count(*))))+ -cast(avg(t1.a) AS integer) | ((count(*))) from t1)+f in (select max((abs(+11*t1.a)/abs(t1.f))) from t1 union select max(d)-(( -count(distinct 11))) from t1)}
+} {}
+do_test randexpr-2.1729 {
+ db eval {SELECT -(abs(t1.a)/abs(case when coalesce((select max( -c) from t1 where t1.a*e>coalesce((select max(coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where e | t1.f-19 between t1.e-a and b and e>=t1.d)),+d)) from t1 where (exists(select 1 from t1 where t1.b in (select 19 from t1 union select 17 from t1) or 11 between t1.b and d))),c)),t1.e)*t1.a<=c then b else t1.d end)) FROM t1 WHERE NOT ((select abs( -abs(abs(case count(*) when ~ -min(f)+case - -abs(+cast(avg(c*17) AS integer)) when count(*) then max(t1.a) else max(11) end+(cast(avg(e) AS integer)) then min(17) else count(*) end-cast(avg(a) AS integer)-count(*))))+ -cast(avg(t1.a) AS integer) | ((count(*))) from t1)+f in (select max((abs(+11*t1.a)/abs(t1.f))) from t1 union select max(d)-(( -count(distinct 11))) from t1))}
+} {0}
+do_test randexpr-2.1730 {
+ db eval {SELECT -(abs(t1.a)/abs(case when coalesce((select max( -c) from t1 where t1.a*e>coalesce((select max(coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where e & t1.f-19 between t1.e-a and b and e>=t1.d)),+d)) from t1 where (exists(select 1 from t1 where t1.b in (select 19 from t1 union select 17 from t1) or 11 between t1.b and d))),c)),t1.e)*t1.a<=c then b else t1.d end)) FROM t1 WHERE NOT ((select abs( -abs(abs(case count(*) when ~ -min(f)+case - -abs(+cast(avg(c*17) AS integer)) when count(*) then max(t1.a) else max(11) end+(cast(avg(e) AS integer)) then min(17) else count(*) end-cast(avg(a) AS integer)-count(*))))+ -cast(avg(t1.a) AS integer) | ((count(*))) from t1)+f in (select max((abs(+11*t1.a)/abs(t1.f))) from t1 union select max(d)-(( -count(distinct 11))) from t1))}
+} {0}
+do_test randexpr-2.1731 {
+ db eval {SELECT case when ((select (+~~max(13)*count(distinct t1.c)) from t1)<>(select (+ -count(*)) from t1)) then +(17) else 19 end+~(abs(13)/abs(d))-t1.d FROM t1 WHERE coalesce((select (select -+ -count(distinct a)*count(*)+max(t1.b) from t1) from t1 where exists(select 1 from t1 where t1.b=c)),t1.c)+f<>t1.f}
+} {-384}
+do_test randexpr-2.1732 {
+ db eval {SELECT case when ((select (+~~max(13)*count(distinct t1.c)) from t1)<>(select (+ -count(*)) from t1)) then +(17) else 19 end+~(abs(13)/abs(d))-t1.d FROM t1 WHERE NOT (coalesce((select (select -+ -count(distinct a)*count(*)+max(t1.b) from t1) from t1 where exists(select 1 from t1 where t1.b=c)),t1.c)+f<>t1.f)}
+} {}
+do_test randexpr-2.1733 {
+ db eval {SELECT case t1.f when case when 17<=c and coalesce((select case when e in (case when (t1.a=c) then b else -13 end,t1.d,t1.a) then 13 else t1.b end from t1 where (b)=13),t1.d) in ((t1.e),b,t1.b) and d not between 19 and 11 then +(select ~ -~max(e)+count(*)+cast(avg((t1.c)) AS integer) from t1) when t1.f<>e and t1.e<d then t1.c else 19 end then t1.a else t1.f end FROM t1 WHERE t1.b between t1.b and case when ((select abs(cast(avg( -17+f) AS integer)) from t1) between -a and c) then case when coalesce((select max(d) from t1 where 11 in (select max(c) | (count(distinct 13)) from t1 union select count(*) from t1)),13) | t1.a between 13 and t1.f then f else (c) end-c when f in (19,(f), -13) then f else (t1.f) end-d or (f) not in (b,c,d)}
+} {600}
+do_test randexpr-2.1734 {
+ db eval {SELECT case t1.f when case when 17<=c and coalesce((select case when e in (case when (t1.a=c) then b else -13 end,t1.d,t1.a) then 13 else t1.b end from t1 where (b)=13),t1.d) in ((t1.e),b,t1.b) and d not between 19 and 11 then +(select ~ -~max(e)+count(*)+cast(avg((t1.c)) AS integer) from t1) when t1.f<>e and t1.e<d then t1.c else 19 end then t1.a else t1.f end FROM t1 WHERE NOT (t1.b between t1.b and case when ((select abs(cast(avg( -17+f) AS integer)) from t1) between -a and c) then case when coalesce((select max(d) from t1 where 11 in (select max(c) | (count(distinct 13)) from t1 union select count(*) from t1)),13) | t1.a between 13 and t1.f then f else (c) end-c when f in (19,(f), -13) then f else (t1.f) end-d or (f) not in (b,c,d))}
+} {}
+do_test randexpr-2.1735 {
+ db eval {SELECT t1.c+b+t1.c*case when f in (select max(case when not t1.e<case when (select ~+(min(13)) from t1)+t1.e in (select -+count(*) from t1 union select ((cast(avg(e) AS integer))) from t1) then c when t1.f not between f and t1.f or (c) in (t1.e,c,d) then c else 11 end then +f else b end)-count(*) from t1 union select +min(11)-count(distinct t1.e) from t1) then d else 17 end-19 FROM t1 WHERE (select abs(case (count(distinct case when not exists(select 1 from t1 where -t1.c=t1.c) and t1.d not in (13,t1.c,t1.c) then case (19)-c when t1.b then 11 else t1.f end else t1.d end+t1.c)+max(11)) when (count(distinct t1.f)*count(distinct 19)) then -max(f) else count(*) end) from t1)*coalesce((select max(e) from t1 where (abs(case -d when t1.b then 19 else t1.e end)/abs(c))< -e), -b)-e<=f}
+} {5581}
+do_test randexpr-2.1736 {
+ db eval {SELECT t1.c+b+t1.c*case when f in (select max(case when not t1.e<case when (select ~+(min(13)) from t1)+t1.e in (select -+count(*) from t1 union select ((cast(avg(e) AS integer))) from t1) then c when t1.f not between f and t1.f or (c) in (t1.e,c,d) then c else 11 end then +f else b end)-count(*) from t1 union select +min(11)-count(distinct t1.e) from t1) then d else 17 end-19 FROM t1 WHERE NOT ((select abs(case (count(distinct case when not exists(select 1 from t1 where -t1.c=t1.c) and t1.d not in (13,t1.c,t1.c) then case (19)-c when t1.b then 11 else t1.f end else t1.d end+t1.c)+max(11)) when (count(distinct t1.f)*count(distinct 19)) then -max(f) else count(*) end) from t1)*coalesce((select max(e) from t1 where (abs(case -d when t1.b then 19 else t1.e end)/abs(c))< -e), -b)-e<=f)}
+} {}
+do_test randexpr-2.1737 {
+ db eval {SELECT +case + -(+t1.a)-~13+t1.b*t1.b+ -c+(select abs(case ~max(t1.c)++min( -13)+ -count(*)+(count(*)) | ((cast(avg(t1.e) AS integer))) when min(t1.c) then min(t1.d) else min(b) end)+min(13) | count(distinct f) | min(t1.a) from t1) when t1.e then 11-17 else t1.b*c end FROM t1 WHERE (~coalesce((select max(coalesce((select max(19) from t1 where case when case f-(coalesce((select ~11 from t1 where -19= -t1.f or b=t1.b),13)) when 19 then t1.d else t1.b end<=17 then 17 when t1.b>t1.e then t1.d else (d) end in (select count(*) from t1 union select -abs(~abs(count(distinct d)) | min(t1.e))*count(*) from t1)),t1.f)) from t1 where a>13),d) not between t1.d and c)}
+} {60000}
+do_test randexpr-2.1738 {
+ db eval {SELECT +case + -(+t1.a)-~13+t1.b*t1.b+ -c+(select abs(case ~max(t1.c)++min( -13)+ -count(*)+(count(*)) | ((cast(avg(t1.e) AS integer))) when min(t1.c) then min(t1.d) else min(b) end)+min(13) | count(distinct f) | min(t1.a) from t1) when t1.e then 11-17 else t1.b*c end FROM t1 WHERE NOT ((~coalesce((select max(coalesce((select max(19) from t1 where case when case f-(coalesce((select ~11 from t1 where -19= -t1.f or b=t1.b),13)) when 19 then t1.d else t1.b end<=17 then 17 when t1.b>t1.e then t1.d else (d) end in (select count(*) from t1 union select -abs(~abs(count(distinct d)) | min(t1.e))*count(*) from t1)),t1.f)) from t1 where a>13),d) not between t1.d and c))}
+} {}
+do_test randexpr-2.1739 {
+ db eval {SELECT +case + -(+t1.a)-~13+t1.b*t1.b+ -c+(select abs(case ~max(t1.c)++min( -13)+ -count(*)+(count(*)) & ((cast(avg(t1.e) AS integer))) when min(t1.c) then min(t1.d) else min(b) end)+min(13) & count(distinct f) & min(t1.a) from t1) when t1.e then 11-17 else t1.b*c end FROM t1 WHERE (~coalesce((select max(coalesce((select max(19) from t1 where case when case f-(coalesce((select ~11 from t1 where -19= -t1.f or b=t1.b),13)) when 19 then t1.d else t1.b end<=17 then 17 when t1.b>t1.e then t1.d else (d) end in (select count(*) from t1 union select -abs(~abs(count(distinct d)) | min(t1.e))*count(*) from t1)),t1.f)) from t1 where a>13),d) not between t1.d and c)}
+} {60000}
+do_test randexpr-2.1740 {
+ db eval {SELECT (abs(e)/abs((+b)*coalesce((select c+c+t1.a+t1.e+t1.a+t1.a | 17+e*(t1.c) from t1 where a in (select count(distinct t1.c)-+count(*) from t1 union select - -( -max(t1.f))-count(distinct t1.b)+min(t1.b)*count(*)+count(distinct a) from t1)),t1.a)+e))*19 FROM t1 WHERE coalesce((select 11 from t1 where case t1.e-(t1.a) when (f) then ((19)) else t1.f end+ -t1.b+a+coalesce((select coalesce((select d from t1 where exists(select 1 from t1 where 13+(t1.a)<>19 or 17 not in (c,e,t1.c) or f not in (t1.e,t1.a, -f))),~ -13+e) from t1 where b between (11) and t1.f),t1.a)<=t1.d), -c)<=11}
+} {0}
+do_test randexpr-2.1741 {
+ db eval {SELECT (abs(e)/abs((+b)*coalesce((select c+c+t1.a+t1.e+t1.a+t1.a | 17+e*(t1.c) from t1 where a in (select count(distinct t1.c)-+count(*) from t1 union select - -( -max(t1.f))-count(distinct t1.b)+min(t1.b)*count(*)+count(distinct a) from t1)),t1.a)+e))*19 FROM t1 WHERE NOT (coalesce((select 11 from t1 where case t1.e-(t1.a) when (f) then ((19)) else t1.f end+ -t1.b+a+coalesce((select coalesce((select d from t1 where exists(select 1 from t1 where 13+(t1.a)<>19 or 17 not in (c,e,t1.c) or f not in (t1.e,t1.a, -f))),~ -13+e) from t1 where b between (11) and t1.f),t1.a)<=t1.d), -c)<=11)}
+} {}
+do_test randexpr-2.1742 {
+ db eval {SELECT (abs(e)/abs((+b)*coalesce((select c+c+t1.a+t1.e+t1.a+t1.a & 17+e*(t1.c) from t1 where a in (select count(distinct t1.c)-+count(*) from t1 union select - -( -max(t1.f))-count(distinct t1.b)+min(t1.b)*count(*)+count(distinct a) from t1)),t1.a)+e))*19 FROM t1 WHERE coalesce((select 11 from t1 where case t1.e-(t1.a) when (f) then ((19)) else t1.f end+ -t1.b+a+coalesce((select coalesce((select d from t1 where exists(select 1 from t1 where 13+(t1.a)<>19 or 17 not in (c,e,t1.c) or f not in (t1.e,t1.a, -f))),~ -13+e) from t1 where b between (11) and t1.f),t1.a)<=t1.d), -c)<=11}
+} {0}
+do_test randexpr-2.1743 {
+ db eval {SELECT case coalesce((select t1.f from t1 where not exists(select 1 from t1 where coalesce((select max(d) from t1 where 13 not in (11,coalesce((select max((+f)) from t1 where not d>=f or e in (select 11-t1.b from t1 union select t1.d from t1) or not exists(select 1 from t1 where -b in (select t1.d from t1 union select b from t1) or t1.a<>b or t1.d>e) or t1.a not between (t1.f) and t1.e),+f),t1.e)),t1.f)*t1.b not in (13,t1.b,t1.f))),t1.a)*b when c then b else t1.f end FROM t1 WHERE case when c*coalesce((select max(19+t1.e*~case case t1.e when t1.f then -t1.a else 11 end when 11 then t1.a else (select cast(avg(a) AS integer) from t1) end- -t1.b*coalesce((select 19 from t1 where t1.f in ((a),t1.d,t1.c)),a)) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where t1.a not in (t1.b,t1.a,17)))),13)>=a then b when t1.c>t1.a then d else 17 end not in (a,17,t1.b)}
+} {600}
+do_test randexpr-2.1744 {
+ db eval {SELECT case coalesce((select t1.f from t1 where not exists(select 1 from t1 where coalesce((select max(d) from t1 where 13 not in (11,coalesce((select max((+f)) from t1 where not d>=f or e in (select 11-t1.b from t1 union select t1.d from t1) or not exists(select 1 from t1 where -b in (select t1.d from t1 union select b from t1) or t1.a<>b or t1.d>e) or t1.a not between (t1.f) and t1.e),+f),t1.e)),t1.f)*t1.b not in (13,t1.b,t1.f))),t1.a)*b when c then b else t1.f end FROM t1 WHERE NOT (case when c*coalesce((select max(19+t1.e*~case case t1.e when t1.f then -t1.a else 11 end when 11 then t1.a else (select cast(avg(a) AS integer) from t1) end- -t1.b*coalesce((select 19 from t1 where t1.f in ((a),t1.d,t1.c)),a)) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where t1.a not in (t1.b,t1.a,17)))),13)>=a then b when t1.c>t1.a then d else 17 end not in (a,17,t1.b))}
+} {}
+do_test randexpr-2.1745 {
+ db eval {SELECT (abs(case when (c*+~t1.d++t1.b+a-case when (select +case count(*)+min(d) when -count(distinct 17) then max(t1.b) else -cast(avg(d) AS integer) end from t1) in (select cast(avg(c) AS integer) from t1 union select ((count(*))) from t1) then t1.a* -f else f end*c*19-(f)-t1.c-t1.f+t1.d>=f) then (t1.d) else d end)/abs(t1.b)) FROM t1 WHERE coalesce((select a from t1 where t1.d not in ( -13*d,19,t1.a)),(abs(coalesce((select case when c>=t1.e then b else case ~t1.d+a-+t1.b+17 when case when t1.e+t1.e not between e and (c) then t1.d when d>a then t1.d else t1.c end | t1.a-(d) then t1.f else c end end from t1 where d>=t1.c),13))/abs(t1.c)))=t1.e}
+} {}
+do_test randexpr-2.1746 {
+ db eval {SELECT (abs(case when (c*+~t1.d++t1.b+a-case when (select +case count(*)+min(d) when -count(distinct 17) then max(t1.b) else -cast(avg(d) AS integer) end from t1) in (select cast(avg(c) AS integer) from t1 union select ((count(*))) from t1) then t1.a* -f else f end*c*19-(f)-t1.c-t1.f+t1.d>=f) then (t1.d) else d end)/abs(t1.b)) FROM t1 WHERE NOT (coalesce((select a from t1 where t1.d not in ( -13*d,19,t1.a)),(abs(coalesce((select case when c>=t1.e then b else case ~t1.d+a-+t1.b+17 when case when t1.e+t1.e not between e and (c) then t1.d when d>a then t1.d else t1.c end | t1.a-(d) then t1.f else c end end from t1 where d>=t1.c),13))/abs(t1.c)))=t1.e)}
+} {2}
+do_test randexpr-2.1747 {
+ db eval {SELECT d+coalesce((select max(coalesce((select f from t1 where coalesce((select 17 | t1.b from t1 where 11 not in ((t1.e),+a-f,t1.c | b+17*t1.e-c)), -c) in (select -count(distinct e)-+max(t1.b) from t1 union select count(distinct c)+cast(avg(t1.b) AS integer) from t1)),17)) from t1 where not t1.c<t1.e),17)+b+e FROM t1 WHERE case t1.f when t1.a then t1.e else d-case when e<>(select ~~+(min(11-11)) | ~ -(count(*)) from t1)*(case when t1.d=19 then a when not t1.a in (11,t1.e,c) or t1.a not between t1.f and e then t1.a else t1.e end+19) then 13 when 19 between -17 and t1.a then t1.a else 19 end end>=t1.f and t1.e>t1.a}
+} {}
+do_test randexpr-2.1748 {
+ db eval {SELECT d+coalesce((select max(coalesce((select f from t1 where coalesce((select 17 | t1.b from t1 where 11 not in ((t1.e),+a-f,t1.c | b+17*t1.e-c)), -c) in (select -count(distinct e)-+max(t1.b) from t1 union select count(distinct c)+cast(avg(t1.b) AS integer) from t1)),17)) from t1 where not t1.c<t1.e),17)+b+e FROM t1 WHERE NOT (case t1.f when t1.a then t1.e else d-case when e<>(select ~~+(min(11-11)) | ~ -(count(*)) from t1)*(case when t1.d=19 then a when not t1.a in (11,t1.e,c) or t1.a not between t1.f and e then t1.a else t1.e end+19) then 13 when 19 between -17 and t1.a then t1.a else 19 end end>=t1.f and t1.e>t1.a)}
+} {1117}
+do_test randexpr-2.1749 {
+ db eval {SELECT d+coalesce((select max(coalesce((select f from t1 where coalesce((select 17 & t1.b from t1 where 11 not in ((t1.e),+a-f,t1.c & b+17*t1.e-c)), -c) in (select -count(distinct e)-+max(t1.b) from t1 union select count(distinct c)+cast(avg(t1.b) AS integer) from t1)),17)) from t1 where not t1.c<t1.e),17)+b+e FROM t1 WHERE NOT (case t1.f when t1.a then t1.e else d-case when e<>(select ~~+(min(11-11)) | ~ -(count(*)) from t1)*(case when t1.d=19 then a when not t1.a in (11,t1.e,c) or t1.a not between t1.f and e then t1.a else t1.e end+19) then 13 when 19 between -17 and t1.a then t1.a else 19 end end>=t1.f and t1.e>t1.a)}
+} {1117}
+do_test randexpr-2.1750 {
+ db eval {SELECT (select case ~ -(~case case cast(avg(t1.e) AS integer) when min(case when t1.c between coalesce((select t1.b from t1 where d in (select f from t1 union select t1.e from t1)),(e)) and t1.d and (19=(11)) then 17 else b end) | max((13))-min(t1.c) | -count(distinct t1.d)*max(11) then count(*) else max(f) end*count(*)-(( -count(distinct f))) when min(t1.c) then (count(distinct (13))) else max((b)) end)+max(t1.a) when (max(t1.c)) then -cast(avg(a) AS integer) else cast(avg(t1.c) AS integer) end from t1) FROM t1 WHERE (f) not between c and 17 | t1.b | coalesce((select t1.d from t1 where t1.d*~case when a<=f or (case t1.f when d+17+17 then e else +case when (11<>17) then 11 when -t1.b not in (e,19,(f)) then t1.c else a end+13 end>= -t1.f) then ~ -t1.c else c end*t1.f*a*17<=t1.f),17)}
+} {300}
+do_test randexpr-2.1751 {
+ db eval {SELECT (select case ~ -(~case case cast(avg(t1.e) AS integer) when min(case when t1.c between coalesce((select t1.b from t1 where d in (select f from t1 union select t1.e from t1)),(e)) and t1.d and (19=(11)) then 17 else b end) | max((13))-min(t1.c) | -count(distinct t1.d)*max(11) then count(*) else max(f) end*count(*)-(( -count(distinct f))) when min(t1.c) then (count(distinct (13))) else max((b)) end)+max(t1.a) when (max(t1.c)) then -cast(avg(a) AS integer) else cast(avg(t1.c) AS integer) end from t1) FROM t1 WHERE NOT ((f) not between c and 17 | t1.b | coalesce((select t1.d from t1 where t1.d*~case when a<=f or (case t1.f when d+17+17 then e else +case when (11<>17) then 11 when -t1.b not in (e,19,(f)) then t1.c else a end+13 end>= -t1.f) then ~ -t1.c else c end*t1.f*a*17<=t1.f),17))}
+} {}
+do_test randexpr-2.1752 {
+ db eval {SELECT (select case ~ -(~case case cast(avg(t1.e) AS integer) when min(case when t1.c between coalesce((select t1.b from t1 where d in (select f from t1 union select t1.e from t1)),(e)) and t1.d and (19=(11)) then 17 else b end) & max((13))-min(t1.c) & -count(distinct t1.d)*max(11) then count(*) else max(f) end*count(*)-(( -count(distinct f))) when min(t1.c) then (count(distinct (13))) else max((b)) end)+max(t1.a) when (max(t1.c)) then -cast(avg(a) AS integer) else cast(avg(t1.c) AS integer) end from t1) FROM t1 WHERE (f) not between c and 17 | t1.b | coalesce((select t1.d from t1 where t1.d*~case when a<=f or (case t1.f when d+17+17 then e else +case when (11<>17) then 11 when -t1.b not in (e,19,(f)) then t1.c else a end+13 end>= -t1.f) then ~ -t1.c else c end*t1.f*a*17<=t1.f),17)}
+} {300}
+do_test randexpr-2.1753 {
+ db eval {SELECT (select abs(min(t1.b)) from t1)-f | case when +t1.d*d not in (t1.f,t1.a,case when ~t1.f-17*c<>t1.a then 11 when 19 in (select (+count(distinct b)) | cast(avg(19) AS integer)*count(*) from t1 union select count(distinct t1.d) from t1) then d else d end+19+b) then (a) else 17 end*13+d FROM t1 WHERE t1.f<>(abs(t1.a)/abs(coalesce((select max(case when coalesce((select max((select count(*) from t1)) from t1 where f<>t1.a),coalesce((select max(11) from t1 where 17+coalesce((select t1.a from t1 where a in (select +~cast(avg(d+11) AS integer) from t1 union select count(distinct coalesce((select max((13)) from t1 where not (t1.f)<>19),f)*d) from t1)),19)+t1.e between 13 and (t1.b)),e))>=e then d else t1.f end) from t1 where ((not f>= -t1.b))),t1.c)))}
+} {-268}
+do_test randexpr-2.1754 {
+ db eval {SELECT (select abs(min(t1.b)) from t1)-f | case when +t1.d*d not in (t1.f,t1.a,case when ~t1.f-17*c<>t1.a then 11 when 19 in (select (+count(distinct b)) | cast(avg(19) AS integer)*count(*) from t1 union select count(distinct t1.d) from t1) then d else d end+19+b) then (a) else 17 end*13+d FROM t1 WHERE NOT (t1.f<>(abs(t1.a)/abs(coalesce((select max(case when coalesce((select max((select count(*) from t1)) from t1 where f<>t1.a),coalesce((select max(11) from t1 where 17+coalesce((select t1.a from t1 where a in (select +~cast(avg(d+11) AS integer) from t1 union select count(distinct coalesce((select max((13)) from t1 where not (t1.f)<>19),f)*d) from t1)),19)+t1.e between 13 and (t1.b)),e))>=e then d else t1.f end) from t1 where ((not f>= -t1.b))),t1.c))))}
+} {}
+do_test randexpr-2.1755 {
+ db eval {SELECT (select abs(min(t1.b)) from t1)-f & case when +t1.d*d not in (t1.f,t1.a,case when ~t1.f-17*c<>t1.a then 11 when 19 in (select (+count(distinct b)) & cast(avg(19) AS integer)*count(*) from t1 union select count(distinct t1.d) from t1) then d else d end+19+b) then (a) else 17 end*13+d FROM t1 WHERE t1.f<>(abs(t1.a)/abs(coalesce((select max(case when coalesce((select max((select count(*) from t1)) from t1 where f<>t1.a),coalesce((select max(11) from t1 where 17+coalesce((select t1.a from t1 where a in (select +~cast(avg(d+11) AS integer) from t1 union select count(distinct coalesce((select max((13)) from t1 where not (t1.f)<>19),f)*d) from t1)),19)+t1.e between 13 and (t1.b)),e))>=e then d else t1.f end) from t1 where ((not f>= -t1.b))),t1.c)))}
+} {1568}
+do_test randexpr-2.1756 {
+ db eval {SELECT coalesce((select max(a) from t1 where a>a*(((t1.d)) | a)-+case t1.a-t1.d-19+coalesce((select max(t1.c) from t1 where ~(select -cast(avg(a+d) AS integer) from t1) not in (~((17)),t1.a,(t1.e))),b)+a*(c) when t1.f then a else t1.f end-17+c),13)*t1.a FROM t1 WHERE t1.b*t1.d*11*case 13 | t1.a when (case when not exists(select 1 from t1 where t1.a not between coalesce((select f-a from t1 where a not in (11,d,(a)) or e<=d and 11=t1.e),d)+e and t1.c) and (t1.a>=t1.f or (t1.a)>=t1.a) then (c)+t1.d else a end)* -t1.a then e else t1.f end | 13>=b}
+} {1300}
+do_test randexpr-2.1757 {
+ db eval {SELECT coalesce((select max(a) from t1 where a>a*(((t1.d)) | a)-+case t1.a-t1.d-19+coalesce((select max(t1.c) from t1 where ~(select -cast(avg(a+d) AS integer) from t1) not in (~((17)),t1.a,(t1.e))),b)+a*(c) when t1.f then a else t1.f end-17+c),13)*t1.a FROM t1 WHERE NOT (t1.b*t1.d*11*case 13 | t1.a when (case when not exists(select 1 from t1 where t1.a not between coalesce((select f-a from t1 where a not in (11,d,(a)) or e<=d and 11=t1.e),d)+e and t1.c) and (t1.a>=t1.f or (t1.a)>=t1.a) then (c)+t1.d else a end)* -t1.a then e else t1.f end | 13>=b)}
+} {}
+do_test randexpr-2.1758 {
+ db eval {SELECT coalesce((select max(a) from t1 where a>a*(((t1.d)) & a)-+case t1.a-t1.d-19+coalesce((select max(t1.c) from t1 where ~(select -cast(avg(a+d) AS integer) from t1) not in (~((17)),t1.a,(t1.e))),b)+a*(c) when t1.f then a else t1.f end-17+c),13)*t1.a FROM t1 WHERE t1.b*t1.d*11*case 13 | t1.a when (case when not exists(select 1 from t1 where t1.a not between coalesce((select f-a from t1 where a not in (11,d,(a)) or e<=d and 11=t1.e),d)+e and t1.c) and (t1.a>=t1.f or (t1.a)>=t1.a) then (c)+t1.d else a end)* -t1.a then e else t1.f end | 13>=b}
+} {10000}
+do_test randexpr-2.1759 {
+ db eval {SELECT (abs(t1.f)/abs(11*19 | case when (e+t1.b*t1.d+(abs(case -13+t1.d*t1.a-+coalesce((select t1.d from t1 where t1.b not between b and d and d in (select c from t1 union select d from t1)),(19)) when d then 13 else d end*t1.e)/abs(d))+f not between e and t1.a) then ( -f) else d end*a)) FROM t1 WHERE a in (select abs(max(b))-count(distinct case when d not between coalesce((select max(13) from t1 where a+a<+(19)), -f*case (select -cast(avg(t1.c) AS integer)*cast(avg(c) AS integer)-cast(avg(13) AS integer) from t1)*coalesce((select d from t1 where (e=(f))),t1.d) when t1.a then 17 else 19 end) and d then t1.f when (19 between t1.e and -a) then t1.a else (t1.c) end) from t1 union select max(t1.e)+~min(t1.c) from t1)}
+} {}
+do_test randexpr-2.1760 {
+ db eval {SELECT (abs(t1.f)/abs(11*19 | case when (e+t1.b*t1.d+(abs(case -13+t1.d*t1.a-+coalesce((select t1.d from t1 where t1.b not between b and d and d in (select c from t1 union select d from t1)),(19)) when d then 13 else d end*t1.e)/abs(d))+f not between e and t1.a) then ( -f) else d end*a)) FROM t1 WHERE NOT (a in (select abs(max(b))-count(distinct case when d not between coalesce((select max(13) from t1 where a+a<+(19)), -f*case (select -cast(avg(t1.c) AS integer)*cast(avg(c) AS integer)-cast(avg(13) AS integer) from t1)*coalesce((select d from t1 where (e=(f))),t1.d) when t1.a then 17 else 19 end) and d then t1.f when (19 between t1.e and -a) then t1.a else (t1.c) end) from t1 union select max(t1.e)+~min(t1.c) from t1))}
+} {0}
+do_test randexpr-2.1761 {
+ db eval {SELECT (abs(t1.f)/abs(11*19 & case when (e+t1.b*t1.d+(abs(case -13+t1.d*t1.a-+coalesce((select t1.d from t1 where t1.b not between b and d and d in (select c from t1 union select d from t1)),(19)) when d then 13 else d end*t1.e)/abs(d))+f not between e and t1.a) then ( -f) else d end*a)) FROM t1 WHERE NOT (a in (select abs(max(b))-count(distinct case when d not between coalesce((select max(13) from t1 where a+a<+(19)), -f*case (select -cast(avg(t1.c) AS integer)*cast(avg(c) AS integer)-cast(avg(13) AS integer) from t1)*coalesce((select d from t1 where (e=(f))),t1.d) when t1.a then 17 else 19 end) and d then t1.f when (19 between t1.e and -a) then t1.a else (t1.c) end) from t1 union select max(t1.e)+~min(t1.c) from t1))}
+} {4}
+do_test randexpr-2.1762 {
+ db eval {SELECT +t1.d | (d)*t1.e | (select case abs((max(t1.e)-abs(+case min(a) | (~(min(~t1.c)))*(abs(abs(count(*))+count(distinct b)*count(distinct 17)))*max(c) when max(t1.c) then max(t1.d) else cast(avg(d) AS integer) end | max(t1.a))))*cast(avg(11) AS integer) when (cast(avg( -a) AS integer)) then min(19) else -count(distinct 13) end from t1)+t1.b FROM t1 WHERE not exists(select 1 from t1 where e<t1.a)}
+} {200151}
+do_test randexpr-2.1763 {
+ db eval {SELECT +t1.d | (d)*t1.e | (select case abs((max(t1.e)-abs(+case min(a) | (~(min(~t1.c)))*(abs(abs(count(*))+count(distinct b)*count(distinct 17)))*max(c) when max(t1.c) then max(t1.d) else cast(avg(d) AS integer) end | max(t1.a))))*cast(avg(11) AS integer) when (cast(avg( -a) AS integer)) then min(19) else -count(distinct 13) end from t1)+t1.b FROM t1 WHERE NOT (not exists(select 1 from t1 where e<t1.a))}
+} {}
+do_test randexpr-2.1764 {
+ db eval {SELECT +t1.d & (d)*t1.e & (select case abs((max(t1.e)-abs(+case min(a) & (~(min(~t1.c)))*(abs(abs(count(*))+count(distinct b)*count(distinct 17)))*max(c) when max(t1.c) then max(t1.d) else cast(avg(d) AS integer) end & max(t1.a))))*cast(avg(11) AS integer) when (cast(avg( -a) AS integer)) then min(19) else -count(distinct 13) end from t1)+t1.b FROM t1 WHERE not exists(select 1 from t1 where e<t1.a)}
+} {0}
+do_test randexpr-2.1765 {
+ db eval {SELECT coalesce((select max(e) from t1 where -(abs(~(t1.f+b))/abs(t1.f)) not in (~case 11+c*case when -t1.d not between coalesce((select max(d) from t1 where f- -t1.f+t1.f-13-e<c),(f)) and a then t1.d else t1.a end when d then 17 else 13 end,d,c) or exists(select 1 from t1 where b<d)),13) FROM t1 WHERE (case when (t1.f<>13) or t1.a*t1.f- -a>=t1.d or d in (select -case cast(avg(b) AS integer) when max(19) then count(distinct -t1.f) else count(distinct f) end* -max(t1.d) from t1 union select -cast(avg(13) AS integer) from t1) and 11 between t1.f and d then case when t1.f not between b and 13 then f else t1.e end-t1.c when t1.d in (t1.e,b,d) then t1.f else -t1.d end-t1.d)*d*f>=a}
+} {}
+do_test randexpr-2.1766 {
+ db eval {SELECT coalesce((select max(e) from t1 where -(abs(~(t1.f+b))/abs(t1.f)) not in (~case 11+c*case when -t1.d not between coalesce((select max(d) from t1 where f- -t1.f+t1.f-13-e<c),(f)) and a then t1.d else t1.a end when d then 17 else 13 end,d,c) or exists(select 1 from t1 where b<d)),13) FROM t1 WHERE NOT ((case when (t1.f<>13) or t1.a*t1.f- -a>=t1.d or d in (select -case cast(avg(b) AS integer) when max(19) then count(distinct -t1.f) else count(distinct f) end* -max(t1.d) from t1 union select -cast(avg(13) AS integer) from t1) and 11 between t1.f and d then case when t1.f not between b and 13 then f else t1.e end-t1.c when t1.d in (t1.e,b,d) then t1.f else -t1.d end-t1.d)*d*f>=a)}
+} {500}
+do_test randexpr-2.1767 {
+ db eval {SELECT case when ~case when t1.a | case when exists(select 1 from t1 where 19 in (select (count(*))-count(*) from t1 union select -min(b) from t1) or t1.f not in (17,11,t1.c) and t1.d in (a,19,t1.a)) then ~c | 11 else 17 end* -19 in (select count(*) from t1 union select abs( - -case ~cast(avg(t1.b) AS integer) when min(b) then max(a) else (max( -d)) end | count(*)) from t1) then t1.a else t1.c end | b in (select f from t1 union select 13 from t1) then t1.b when t1.a<>(17) then c else t1.a end FROM t1 WHERE exists(select 1 from t1 where d<>13)}
+} {300}
+do_test randexpr-2.1768 {
+ db eval {SELECT case when ~case when t1.a | case when exists(select 1 from t1 where 19 in (select (count(*))-count(*) from t1 union select -min(b) from t1) or t1.f not in (17,11,t1.c) and t1.d in (a,19,t1.a)) then ~c | 11 else 17 end* -19 in (select count(*) from t1 union select abs( - -case ~cast(avg(t1.b) AS integer) when min(b) then max(a) else (max( -d)) end | count(*)) from t1) then t1.a else t1.c end | b in (select f from t1 union select 13 from t1) then t1.b when t1.a<>(17) then c else t1.a end FROM t1 WHERE NOT (exists(select 1 from t1 where d<>13))}
+} {}
+do_test randexpr-2.1769 {
+ db eval {SELECT case when ~case when t1.a & case when exists(select 1 from t1 where 19 in (select (count(*))-count(*) from t1 union select -min(b) from t1) or t1.f not in (17,11,t1.c) and t1.d in (a,19,t1.a)) then ~c & 11 else 17 end* -19 in (select count(*) from t1 union select abs( - -case ~cast(avg(t1.b) AS integer) when min(b) then max(a) else (max( -d)) end & count(*)) from t1) then t1.a else t1.c end & b in (select f from t1 union select 13 from t1) then t1.b when t1.a<>(17) then c else t1.a end FROM t1 WHERE exists(select 1 from t1 where d<>13)}
+} {300}
+do_test randexpr-2.1770 {
+ db eval {SELECT coalesce((select a+t1.d from t1 where t1.d+coalesce((select max(case when e not between 11 and case when (abs(f)/abs(t1.f+19*t1.b))>e then ~d when not not 17 in (13,17,t1.a) then f else t1.f end then 11 when b<17 then t1.b else f end) from t1 where exists(select 1 from t1 where (c<>c))), -f)+t1.c in (select (t1.e) from t1 union select c from t1)),c) FROM t1 WHERE not (t1.a)<=case a when t1.f then +coalesce((select max(c) from t1 where (abs(d-11)/abs(t1.a))+t1.f<=d*d*t1.a+coalesce((select 19 from t1 where (select cast(avg(f) AS integer) from t1)*t1.f+19+ -13 in ((t1.d),c,t1.a)),t1.c) or ((not exists(select 1 from t1 where 19 in (select e from t1 union select -11 from t1))))),c) else e end}
+} {}
+do_test randexpr-2.1771 {
+ db eval {SELECT coalesce((select a+t1.d from t1 where t1.d+coalesce((select max(case when e not between 11 and case when (abs(f)/abs(t1.f+19*t1.b))>e then ~d when not not 17 in (13,17,t1.a) then f else t1.f end then 11 when b<17 then t1.b else f end) from t1 where exists(select 1 from t1 where (c<>c))), -f)+t1.c in (select (t1.e) from t1 union select c from t1)),c) FROM t1 WHERE NOT (not (t1.a)<=case a when t1.f then +coalesce((select max(c) from t1 where (abs(d-11)/abs(t1.a))+t1.f<=d*d*t1.a+coalesce((select 19 from t1 where (select cast(avg(f) AS integer) from t1)*t1.f+19+ -13 in ((t1.d),c,t1.a)),t1.c) or ((not exists(select 1 from t1 where 19 in (select e from t1 union select -11 from t1))))),c) else e end)}
+} {300}
+do_test randexpr-2.1772 {
+ db eval {SELECT (abs( -c+b)/abs(case when ~11 in (select t1.c from t1 union select coalesce((select t1.f from t1 where coalesce((select max(17) from t1 where coalesce((select case -t1.d when t1.e then a else b end-(t1.d) from t1 where t1.a not between -a and t1.b or t1.f<t1.e and e<=a),t1.e)*t1.d not in (b,11,t1.f)),19)<19 and not exists(select 1 from t1 where t1.f>=t1.b) and (f)>= -13),t1.b) from t1) then t1.c when t1.b<=t1.f then 13 else t1.e end)) FROM t1 WHERE (d-coalesce((select max(case 11 when +13-17 | 13 | coalesce((select t1.b from t1 where ((abs(t1.b)/abs((abs(b)/abs(+(19)))*t1.c)) | a in ( -t1.c,t1.a,t1.b))),d)* -d then 13 else 11 end) from t1 where e not in (d,11,11) or t1.e>t1.e),17)+t1.a>b)}
+} {7}
+do_test randexpr-2.1773 {
+ db eval {SELECT (abs( -c+b)/abs(case when ~11 in (select t1.c from t1 union select coalesce((select t1.f from t1 where coalesce((select max(17) from t1 where coalesce((select case -t1.d when t1.e then a else b end-(t1.d) from t1 where t1.a not between -a and t1.b or t1.f<t1.e and e<=a),t1.e)*t1.d not in (b,11,t1.f)),19)<19 and not exists(select 1 from t1 where t1.f>=t1.b) and (f)>= -13),t1.b) from t1) then t1.c when t1.b<=t1.f then 13 else t1.e end)) FROM t1 WHERE NOT ((d-coalesce((select max(case 11 when +13-17 | 13 | coalesce((select t1.b from t1 where ((abs(t1.b)/abs((abs(b)/abs(+(19)))*t1.c)) | a in ( -t1.c,t1.a,t1.b))),d)* -d then 13 else 11 end) from t1 where e not in (d,11,11) or t1.e>t1.e),17)+t1.a>b))}
+} {}
+do_test randexpr-2.1774 {
+ db eval {SELECT coalesce((select max(17) from t1 where (e* -t1.f*e*c-coalesce((select max(t1.f) from t1 where t1.c between case when e+~ -t1.e+11 in (select c from t1 union select t1.a from t1) and t1.d>=c then 19 else ( - -(t1.a)) end*c+f and t1.b),13) not in (t1.b,e,t1.c) and (11) not in (b,( -t1.b),13))),19) FROM t1 WHERE d>e+f}
+} {}
+do_test randexpr-2.1775 {
+ db eval {SELECT coalesce((select max(17) from t1 where (e* -t1.f*e*c-coalesce((select max(t1.f) from t1 where t1.c between case when e+~ -t1.e+11 in (select c from t1 union select t1.a from t1) and t1.d>=c then 19 else ( - -(t1.a)) end*c+f and t1.b),13) not in (t1.b,e,t1.c) and (11) not in (b,( -t1.b),13))),19) FROM t1 WHERE NOT (d>e+f)}
+} {17}
+do_test randexpr-2.1776 {
+ db eval {SELECT case when t1.b in (select case 13-(select case count(*) when count(distinct (abs(19)/abs(t1.d)))*~count(distinct 13)*(max((abs(t1.e*d*f)/abs(17)))) then -case - -count(distinct e) when min(19) then (cast(avg(17) AS integer)) else count(distinct t1.a) end*max(t1.b)-cast(avg(a) AS integer) else count(distinct t1.d) end from t1)+t1.b*d when t1.c+t1.a then f else t1.f end from t1 union select t1.c from t1) then t1.a when a in (select 11 from t1 union select a from t1) then a else e end FROM t1 WHERE (case when case 11+case f when e then d else (abs(e)/abs(19))*a end when 19 then b else d end<t1.d then t1.c when b>= -19 then 13 else t1.e end between 17 and t1.a or b>=17 and ((( -t1.f))>=t1.c and 17 between t1.c and 19 and t1.c between t1.d and a or t1.d=17) or c in (b,13,17))}
+} {}
+do_test randexpr-2.1777 {
+ db eval {SELECT case when t1.b in (select case 13-(select case count(*) when count(distinct (abs(19)/abs(t1.d)))*~count(distinct 13)*(max((abs(t1.e*d*f)/abs(17)))) then -case - -count(distinct e) when min(19) then (cast(avg(17) AS integer)) else count(distinct t1.a) end*max(t1.b)-cast(avg(a) AS integer) else count(distinct t1.d) end from t1)+t1.b*d when t1.c+t1.a then f else t1.f end from t1 union select t1.c from t1) then t1.a when a in (select 11 from t1 union select a from t1) then a else e end FROM t1 WHERE NOT ((case when case 11+case f when e then d else (abs(e)/abs(19))*a end when 19 then b else d end<t1.d then t1.c when b>= -19 then 13 else t1.e end between 17 and t1.a or b>=17 and ((( -t1.f))>=t1.c and 17 between t1.c and 19 and t1.c between t1.d and a or t1.d=17) or c in (b,13,17)))}
+} {100}
+do_test randexpr-2.1778 {
+ db eval {SELECT case when coalesce((select case when (not exists(select 1 from t1 where t1.f<>t1.f)) then case when d-t1.e*t1.d=((select (count(distinct t1.a)) from t1)) then t1.a when 13 not in ( -b,13,19) then t1.b else e end when t1.e=13 then e else 17 end-17*b from t1 where (t1.d in (d,t1.e,t1.f))),( -f)) not in (d,t1.e,c) then t1.d else -t1.f end* -t1.b FROM t1 WHERE not exists(select 1 from t1 where 11 in (select max(coalesce((select max(case when e+coalesce((select max(d) from t1 where not a<t1.c),(a)) in (((f)),c,13) then t1.e else e end-d) from t1 where 17 between (c) and t1.c),17)) from t1 union select ( -case cast(avg(c) AS integer) when case min(11) when ( -min(e)) then min(t1.b) else min(f) end then -min(b) else count(distinct 13) end+min(13)- - -count(*)) from t1) or 17 in (19,t1.d,(a)) and exists(select 1 from t1 where t1.e in (t1.d,e,11)))}
+} {}
+do_test randexpr-2.1779 {
+ db eval {SELECT case when coalesce((select case when (not exists(select 1 from t1 where t1.f<>t1.f)) then case when d-t1.e*t1.d=((select (count(distinct t1.a)) from t1)) then t1.a when 13 not in ( -b,13,19) then t1.b else e end when t1.e=13 then e else 17 end-17*b from t1 where (t1.d in (d,t1.e,t1.f))),( -f)) not in (d,t1.e,c) then t1.d else -t1.f end* -t1.b FROM t1 WHERE NOT (not exists(select 1 from t1 where 11 in (select max(coalesce((select max(case when e+coalesce((select max(d) from t1 where not a<t1.c),(a)) in (((f)),c,13) then t1.e else e end-d) from t1 where 17 between (c) and t1.c),17)) from t1 union select ( -case cast(avg(c) AS integer) when case min(11) when ( -min(e)) then min(t1.b) else min(f) end then -min(b) else count(distinct 13) end+min(13)- - -count(*)) from t1) or 17 in (19,t1.d,(a)) and exists(select 1 from t1 where t1.e in (t1.d,e,11))))}
+} {-80000}
+do_test randexpr-2.1780 {
+ db eval {SELECT coalesce((select (abs(~c*t1.a+t1.b*coalesce((select case c when b+coalesce((select t1.b-case e when 19 then b else b end*11 from t1 where t1.b<>b or not t1.f in (11,t1.a,t1.e)),t1.a) | e then c else e end from t1 where -t1.a<11),13))/abs(t1.b))-t1.b*17 from t1 where c=t1.c),17) FROM t1 WHERE t1.e+e>=coalesce((select max(t1.d) from t1 where +(t1.f) not between c and f),case when exists(select 1 from t1 where t1.e+t1.c<>(abs(e*(select -count(*) from t1))/abs(t1.e*coalesce((select max((select cast(avg(13) AS integer) from t1)) from t1 where not (a) not between -c and -17), -d)+ -a+t1.f))) then case when e between 17 and d then a else 19 end when not c between e and 11 then 13 else t1.a end)}
+} {-3051}
+do_test randexpr-2.1781 {
+ db eval {SELECT coalesce((select (abs(~c*t1.a+t1.b*coalesce((select case c when b+coalesce((select t1.b-case e when 19 then b else b end*11 from t1 where t1.b<>b or not t1.f in (11,t1.a,t1.e)),t1.a) | e then c else e end from t1 where -t1.a<11),13))/abs(t1.b))-t1.b*17 from t1 where c=t1.c),17) FROM t1 WHERE NOT (t1.e+e>=coalesce((select max(t1.d) from t1 where +(t1.f) not between c and f),case when exists(select 1 from t1 where t1.e+t1.c<>(abs(e*(select -count(*) from t1))/abs(t1.e*coalesce((select max((select cast(avg(13) AS integer) from t1)) from t1 where not (a) not between -c and -17), -d)+ -a+t1.f))) then case when e between 17 and d then a else 19 end when not c between e and 11 then 13 else t1.a end))}
+} {}
+do_test randexpr-2.1782 {
+ db eval {SELECT coalesce((select (abs(~c*t1.a+t1.b*coalesce((select case c when b+coalesce((select t1.b-case e when 19 then b else b end*11 from t1 where t1.b<>b or not t1.f in (11,t1.a,t1.e)),t1.a) & e then c else e end from t1 where -t1.a<11),13))/abs(t1.b))-t1.b*17 from t1 where c=t1.c),17) FROM t1 WHERE t1.e+e>=coalesce((select max(t1.d) from t1 where +(t1.f) not between c and f),case when exists(select 1 from t1 where t1.e+t1.c<>(abs(e*(select -count(*) from t1))/abs(t1.e*coalesce((select max((select cast(avg(13) AS integer) from t1)) from t1 where not (a) not between -c and -17), -d)+ -a+t1.f))) then case when e between 17 and d then a else 19 end when not c between e and 11 then 13 else t1.a end)}
+} {-3051}
+do_test randexpr-2.1783 {
+ db eval {SELECT t1.a-~17-t1.c+t1.c | (c) | (13)*coalesce((select max((case when 11 in (case when (19 in (select abs(max(c)) from t1 union select ( -cast(avg(19) AS integer)) from t1)) then 13 when t1.a= -t1.a then t1.b else c end,a,13) then t1.e when t1.b in (t1.a,13, -19) then d else t1.a end)) from t1 where t1.d between t1.d and t1.b and t1.d<=17),t1.d)*11 | t1.e FROM t1 WHERE e in (select 11 from t1 union select a from t1)}
+} {}
+do_test randexpr-2.1784 {
+ db eval {SELECT t1.a-~17-t1.c+t1.c | (c) | (13)*coalesce((select max((case when 11 in (case when (19 in (select abs(max(c)) from t1 union select ( -cast(avg(19) AS integer)) from t1)) then 13 when t1.a= -t1.a then t1.b else c end,a,13) then t1.e when t1.b in (t1.a,13, -19) then d else t1.a end)) from t1 where t1.d between t1.d and t1.b and t1.d<=17),t1.d)*11 | t1.e FROM t1 WHERE NOT (e in (select 11 from t1 union select a from t1))}
+} {57342}
+do_test randexpr-2.1785 {
+ db eval {SELECT t1.a-~17-t1.c+t1.c & (c) & (13)*coalesce((select max((case when 11 in (case when (19 in (select abs(max(c)) from t1 union select ( -cast(avg(19) AS integer)) from t1)) then 13 when t1.a= -t1.a then t1.b else c end,a,13) then t1.e when t1.b in (t1.a,13, -19) then d else t1.a end)) from t1 where t1.d between t1.d and t1.b and t1.d<=17),t1.d)*11 & t1.e FROM t1 WHERE NOT (e in (select 11 from t1 union select a from t1))}
+} {32}
+do_test randexpr-2.1786 {
+ db eval {SELECT (abs(case when 11 not between t1.d and case coalesce((select case c+case when b in (case when a<=t1.b then (t1.a) when f not in (d,t1.f, -(a)) then (t1.a) else c end,t1.a,b) then 11 when (t1.c not between 17 and -d) then t1.d else e end+e*t1.a when 19 then b else t1.e end from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where -(19)=d))),t1.d) when c then a else -17 end or a>=19 then 17 else b end+ -13)/abs(b)) FROM t1 WHERE not exists(select 1 from t1 where not e+case 13 when 11 then +t1.d else t1.f+11 end*a-19+t1.c+a in (~e | coalesce((select ~a*+(abs( -case case b*e when f then e else -13 end when t1.d then t1.b else t1.b end)/abs(17))+t1.b from t1 where t1.a=e),d),e,e))}
+} {}
+do_test randexpr-2.1787 {
+ db eval {SELECT (abs(case when 11 not between t1.d and case coalesce((select case c+case when b in (case when a<=t1.b then (t1.a) when f not in (d,t1.f, -(a)) then (t1.a) else c end,t1.a,b) then 11 when (t1.c not between 17 and -d) then t1.d else e end+e*t1.a when 19 then b else t1.e end from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where -(19)=d))),t1.d) when c then a else -17 end or a>=19 then 17 else b end+ -13)/abs(b)) FROM t1 WHERE NOT (not exists(select 1 from t1 where not e+case 13 when 11 then +t1.d else t1.f+11 end*a-19+t1.c+a in (~e | coalesce((select ~a*+(abs( -case case b*e when f then e else -13 end when t1.d then t1.b else t1.b end)/abs(17))+t1.b from t1 where t1.a=e),d),e,e)))}
+} {0}
+do_test randexpr-2.1788 {
+ db eval {SELECT t1.c-coalesce((select t1.e from t1 where not 17 | (select abs(min((t1.c) | +case 19 when d then f else t1.c end*(13)+a)- -count(*)) from t1)>t1.c and (exists(select 1 from t1 where c in (select f from t1 union select a from t1))) or t1.e>t1.c),coalesce((select e*(e) from t1 where not exists(select 1 from t1 where b not in (f,a,19))),c)) FROM t1 WHERE t1.f*t1.e*b+coalesce((select case when 17 not in (case e++t1.d+19*11 when case when 11 in (select -min(t1.a)*min(t1.e)+cast(avg(t1.a) AS integer) from t1 union select -count(*) from t1) then 13 else 11 end*17 then a else t1.a end,(t1.b),t1.d) then t1.f else -b end from t1 where t1.b not between 17 and (a)),d)-t1.d-c*b<c}
+} {}
+do_test randexpr-2.1789 {
+ db eval {SELECT t1.c-coalesce((select t1.e from t1 where not 17 | (select abs(min((t1.c) | +case 19 when d then f else t1.c end*(13)+a)- -count(*)) from t1)>t1.c and (exists(select 1 from t1 where c in (select f from t1 union select a from t1))) or t1.e>t1.c),coalesce((select e*(e) from t1 where not exists(select 1 from t1 where b not in (f,a,19))),c)) FROM t1 WHERE NOT (t1.f*t1.e*b+coalesce((select case when 17 not in (case e++t1.d+19*11 when case when 11 in (select -min(t1.a)*min(t1.e)+cast(avg(t1.a) AS integer) from t1 union select -count(*) from t1) then 13 else 11 end*17 then a else t1.a end,(t1.b),t1.d) then t1.f else -b end from t1 where t1.b not between 17 and (a)),d)-t1.d-c*b<c)}
+} {-200}
+do_test randexpr-2.1790 {
+ db eval {SELECT t1.c-coalesce((select t1.e from t1 where not 17 & (select abs(min((t1.c) & +case 19 when d then f else t1.c end*(13)+a)- -count(*)) from t1)>t1.c and (exists(select 1 from t1 where c in (select f from t1 union select a from t1))) or t1.e>t1.c),coalesce((select e*(e) from t1 where not exists(select 1 from t1 where b not in (f,a,19))),c)) FROM t1 WHERE NOT (t1.f*t1.e*b+coalesce((select case when 17 not in (case e++t1.d+19*11 when case when 11 in (select -min(t1.a)*min(t1.e)+cast(avg(t1.a) AS integer) from t1 union select -count(*) from t1) then 13 else 11 end*17 then a else t1.a end,(t1.b),t1.d) then t1.f else -b end from t1 where t1.b not between 17 and (a)),d)-t1.d-c*b<c)}
+} {-200}
+do_test randexpr-2.1791 {
+ db eval {SELECT c-coalesce((select max(case when (case t1.a when a then case f when e*e then ~c | case when +c>= -b+t1.f | 19 then t1.d else 11 end else t1.a end-t1.e else d end not between f and t1.f) then c else e end) from t1 where f>=t1.b and t1.c between t1.f and t1.a),e)*d*b FROM t1 WHERE t1.b in (select 11-case when (t1.a+19<=case when c>=(19) then 11 else t1.e+t1.a*c end*e and t1.f in (select case abs(+abs( -count(*) | count(*)*count(distinct c)+max(13))) when min(d) then min(b) else min(t1.b) end | cast(avg(t1.e) AS integer) from t1 union select count(distinct t1.e) from t1)) then t1.a else t1.f end*17 from t1 union select t1.a from t1)}
+} {}
+do_test randexpr-2.1792 {
+ db eval {SELECT c-coalesce((select max(case when (case t1.a when a then case f when e*e then ~c | case when +c>= -b+t1.f | 19 then t1.d else 11 end else t1.a end-t1.e else d end not between f and t1.f) then c else e end) from t1 where f>=t1.b and t1.c between t1.f and t1.a),e)*d*b FROM t1 WHERE NOT (t1.b in (select 11-case when (t1.a+19<=case when c>=(19) then 11 else t1.e+t1.a*c end*e and t1.f in (select case abs(+abs( -count(*) | count(*)*count(distinct c)+max(13))) when min(d) then min(b) else min(t1.b) end | cast(avg(t1.e) AS integer) from t1 union select count(distinct t1.e) from t1)) then t1.a else t1.f end*17 from t1 union select t1.a from t1))}
+} {-39999700}
+do_test randexpr-2.1793 {
+ db eval {SELECT c-coalesce((select max(case when (case t1.a when a then case f when e*e then ~c & case when +c>= -b+t1.f & 19 then t1.d else 11 end else t1.a end-t1.e else d end not between f and t1.f) then c else e end) from t1 where f>=t1.b and t1.c between t1.f and t1.a),e)*d*b FROM t1 WHERE NOT (t1.b in (select 11-case when (t1.a+19<=case when c>=(19) then 11 else t1.e+t1.a*c end*e and t1.f in (select case abs(+abs( -count(*) | count(*)*count(distinct c)+max(13))) when min(d) then min(b) else min(t1.b) end | cast(avg(t1.e) AS integer) from t1 union select count(distinct t1.e) from t1)) then t1.a else t1.f end*17 from t1 union select t1.a from t1))}
+} {-39999700}
+do_test randexpr-2.1794 {
+ db eval {SELECT coalesce((select f from t1 where ~coalesce((select max(b-e) from t1 where 13 in (select d from t1 union select d from t1)),(abs(t1.f)/abs(t1.f)))-t1.d+case a when t1.b then 13 else case when 19>case a when t1.a then 13 else -d end or e<>c then coalesce((select max(a) from t1 where t1.e not between (13) and t1.d),11) when b in (select t1.a from t1 union select t1.f from t1) then 19 else a end end-b>11),17) FROM t1 WHERE b in (select e-17 from t1 union select d from t1)}
+} {}
+do_test randexpr-2.1795 {
+ db eval {SELECT coalesce((select f from t1 where ~coalesce((select max(b-e) from t1 where 13 in (select d from t1 union select d from t1)),(abs(t1.f)/abs(t1.f)))-t1.d+case a when t1.b then 13 else case when 19>case a when t1.a then 13 else -d end or e<>c then coalesce((select max(a) from t1 where t1.e not between (13) and t1.d),11) when b in (select t1.a from t1 union select t1.f from t1) then 19 else a end end-b>11),17) FROM t1 WHERE NOT (b in (select e-17 from t1 union select d from t1))}
+} {17}
+do_test randexpr-2.1796 {
+ db eval {SELECT coalesce((select case case when 13<>((abs(t1.b)/abs(f+t1.c))) then 11 else coalesce((select max(b) from t1 where (b=(abs((select min((select case -min(11) when count(distinct d) then count(*) else min(t1.c) end from t1)) from t1))/abs(t1.f))-c)), -19)*e end*d* -e+t1.d when 13 then c else c end+b from t1 where d>13 or (b between t1.e and 19)),a) FROM t1 WHERE not exists(select 1 from t1 where ((not not exists(select 1 from t1 where ((case when coalesce((select max(19) from t1 where case when b>=e and f between t1.d and t1.c or ( -t1.b)=t1.f then b+a else 11 end in (d,t1.d,(17))),t1.d)>t1.b then (t1.f) else d end*e*t1.e<=t1.b)) or 13<>13)) or 17<d) and t1.f in (t1.e,d,t1.b)) and e<=a}
+} {}
+do_test randexpr-2.1797 {
+ db eval {SELECT coalesce((select case case when 13<>((abs(t1.b)/abs(f+t1.c))) then 11 else coalesce((select max(b) from t1 where (b=(abs((select min((select case -min(11) when count(distinct d) then count(*) else min(t1.c) end from t1)) from t1))/abs(t1.f))-c)), -19)*e end*d* -e+t1.d when 13 then c else c end+b from t1 where d>13 or (b between t1.e and 19)),a) FROM t1 WHERE NOT (not exists(select 1 from t1 where ((not not exists(select 1 from t1 where ((case when coalesce((select max(19) from t1 where case when b>=e and f between t1.d and t1.c or ( -t1.b)=t1.f then b+a else 11 end in (d,t1.d,(17))),t1.d)>t1.b then (t1.f) else d end*e*t1.e<=t1.b)) or 13<>13)) or 17<d) and t1.f in (t1.e,d,t1.b)) and e<=a)}
+} {500}
+do_test randexpr-2.1798 {
+ db eval {SELECT ~case when 19 not between ~case when coalesce((select max(t1.c*(select cast(avg(13) AS integer) from t1)) from t1 where exists(select 1 from t1 where case when (t1.b in (d,b,t1.c)) and 13>t1.d then e+t1.c when 19 between t1.f and t1.f then 11 else e end between t1.e and 17) and c=t1.f),t1.c) not between t1.a and (19) then c else t1.b end*a-19 and b then b when a not in (a,t1.f,11) then a else a end FROM t1 WHERE (select abs((+min(t1.c)*min(t1.d)*count(*)))*count(*)++count(distinct ~13*11+t1.f) | case abs(+count(*)) when min(t1.e) then count(*) else max(13) end from t1)*t1.b between d and a++19 and t1.c in (select ~((abs(17)/abs(c)))-d from t1 union select t1.f from t1)}
+} {}
+do_test randexpr-2.1799 {
+ db eval {SELECT ~case when 19 not between ~case when coalesce((select max(t1.c*(select cast(avg(13) AS integer) from t1)) from t1 where exists(select 1 from t1 where case when (t1.b in (d,b,t1.c)) and 13>t1.d then e+t1.c when 19 between t1.f and t1.f then 11 else e end between t1.e and 17) and c=t1.f),t1.c) not between t1.a and (19) then c else t1.b end*a-19 and b then b when a not in (a,t1.f,11) then a else a end FROM t1 WHERE NOT ((select abs((+min(t1.c)*min(t1.d)*count(*)))*count(*)++count(distinct ~13*11+t1.f) | case abs(+count(*)) when min(t1.e) then count(*) else max(13) end from t1)*t1.b between d and a++19 and t1.c in (select ~((abs(17)/abs(c)))-d from t1 union select t1.f from t1))}
+} {-101}
+do_test randexpr-2.1800 {
+ db eval {SELECT (t1.d)+(abs(coalesce((select ((abs(case t1.e when a+(abs(11)/abs(b)) then t1.f else case coalesce((select max(d+c) from t1 where +19+11<b),t1.d)-t1.d-t1.d*d when t1.c then -e else t1.d end end-c)/abs(17))) from t1 where 17<>t1.c),d))/abs(t1.d))-11 | (17) | b FROM t1 WHERE (select ~min(b)+count(distinct 17) from t1)>(select max((abs((13))/abs(coalesce((select case when b*13 in (case when e=t1.b then c when 11<>e then f else t1.b end,t1.f,t1.a) then d when not exists(select 1 from t1 where t1.f<>e) then t1.a else c end from t1 where t1.e=13),t1.f) | b)))+(~~cast(avg(f) AS integer)-min((13))) from t1)}
+} {}
+do_test randexpr-2.1801 {
+ db eval {SELECT (t1.d)+(abs(coalesce((select ((abs(case t1.e when a+(abs(11)/abs(b)) then t1.f else case coalesce((select max(d+c) from t1 where +19+11<b),t1.d)-t1.d-t1.d*d when t1.c then -e else t1.d end end-c)/abs(17))) from t1 where 17<>t1.c),d))/abs(t1.d))-11 | (17) | b FROM t1 WHERE NOT ((select ~min(b)+count(distinct 17) from t1)>(select max((abs((13))/abs(coalesce((select case when b*13 in (case when e=t1.b then c when 11<>e then f else t1.b end,t1.f,t1.a) then d when not exists(select 1 from t1 where t1.f<>e) then t1.a else c end from t1 where t1.e=13),t1.f) | b)))+(~~cast(avg(f) AS integer)-min((13))) from t1))}
+} {477}
+do_test randexpr-2.1802 {
+ db eval {SELECT (t1.d)+(abs(coalesce((select ((abs(case t1.e when a+(abs(11)/abs(b)) then t1.f else case coalesce((select max(d+c) from t1 where +19+11<b),t1.d)-t1.d-t1.d*d when t1.c then -e else t1.d end end-c)/abs(17))) from t1 where 17<>t1.c),d))/abs(t1.d))-11 & (17) & b FROM t1 WHERE NOT ((select ~min(b)+count(distinct 17) from t1)>(select max((abs((13))/abs(coalesce((select case when b*13 in (case when e=t1.b then c when 11<>e then f else t1.b end,t1.f,t1.a) then d when not exists(select 1 from t1 where t1.f<>e) then t1.a else c end from t1 where t1.e=13),t1.f) | b)))+(~~cast(avg(f) AS integer)-min((13))) from t1))}
+} {0}
+do_test randexpr-2.1803 {
+ db eval {SELECT d+case coalesce((select t1.f from t1 where coalesce((select max((11)) from t1 where (coalesce((select d from t1 where ((case b when ( -a) then 19 else e end)) not in ( -d,t1.c,13)),b))>t1.b and ((c in (select ~~cast(avg(t1.b) AS integer)+ -(max(t1.e)) from t1 union select max(c) from t1) and (e) in (select -count(distinct 17) from t1 union select count(*) from t1) or 11<>t1.c))),t1.b) not between (f) and 11),t1.d) when (19) then e else 13 end-t1.f FROM t1 WHERE exists(select 1 from t1 where (t1.a between case when e | b*c-19 | a<t1.a or (19 in (select coalesce((select max(f) from t1 where e<19),t1.e-17 | t1.e) from t1 union select 13 from t1)) then coalesce((select t1.e from t1 where not exists(select 1 from t1 where 11<=19) or exists(select 1 from t1 where -(e) between a and 19) or b between b and c),c) else f end and 19))}
+} {}
+do_test randexpr-2.1804 {
+ db eval {SELECT d+case coalesce((select t1.f from t1 where coalesce((select max((11)) from t1 where (coalesce((select d from t1 where ((case b when ( -a) then 19 else e end)) not in ( -d,t1.c,13)),b))>t1.b and ((c in (select ~~cast(avg(t1.b) AS integer)+ -(max(t1.e)) from t1 union select max(c) from t1) and (e) in (select -count(distinct 17) from t1 union select count(*) from t1) or 11<>t1.c))),t1.b) not between (f) and 11),t1.d) when (19) then e else 13 end-t1.f FROM t1 WHERE NOT (exists(select 1 from t1 where (t1.a between case when e | b*c-19 | a<t1.a or (19 in (select coalesce((select max(f) from t1 where e<19),t1.e-17 | t1.e) from t1 union select 13 from t1)) then coalesce((select t1.e from t1 where not exists(select 1 from t1 where 11<=19) or exists(select 1 from t1 where -(e) between a and 19) or b between b and c),c) else f end and 19)))}
+} {-187}
+do_test randexpr-2.1805 {
+ db eval {SELECT coalesce((select c from t1 where - -19-coalesce((select t1.e from t1 where not f<=b-17 or not -13>=f or (select -count(*) from t1) in (select t1.c from t1 union select 17 from t1)),b)*e not between case coalesce((select max(~case when 17>t1.e then d else 13 end) from t1 where not t1.c<=17),t1.c) when 13 then c else t1.e end+t1.c-t1.e and t1.e),t1.e) FROM t1 WHERE case ~case when not exists(select 1 from t1 where f<=~t1.d) then (abs(coalesce((select ~19 from t1 where d+t1.f=b),d))/abs(e)) when d in (select +min(11) from t1 union select ( -abs(count(distinct e)))+count(distinct t1.a) from t1) then e else t1.d end when -d then t1.e else t1.b end=t1.f or t1.d not in (t1.c,t1.e,t1.e) and t1.c not in (17,t1.a,e)}
+} {300}
+do_test randexpr-2.1806 {
+ db eval {SELECT coalesce((select c from t1 where - -19-coalesce((select t1.e from t1 where not f<=b-17 or not -13>=f or (select -count(*) from t1) in (select t1.c from t1 union select 17 from t1)),b)*e not between case coalesce((select max(~case when 17>t1.e then d else 13 end) from t1 where not t1.c<=17),t1.c) when 13 then c else t1.e end+t1.c-t1.e and t1.e),t1.e) FROM t1 WHERE NOT (case ~case when not exists(select 1 from t1 where f<=~t1.d) then (abs(coalesce((select ~19 from t1 where d+t1.f=b),d))/abs(e)) when d in (select +min(11) from t1 union select ( -abs(count(distinct e)))+count(distinct t1.a) from t1) then e else t1.d end when -d then t1.e else t1.b end=t1.f or t1.d not in (t1.c,t1.e,t1.e) and t1.c not in (17,t1.a,e))}
+} {}
+do_test randexpr-2.1807 {
+ db eval {SELECT case when t1.e<=~d then case when t1.d-e in (~t1.c-case e*case when t1.e not in (t1.d,19,f) then e else b end*e when (19) then t1.a else -e end,19,17) then t1.f when t1.d not in (t1.b,b,17) then t1.b else 19 end when 13= -t1.f and not (19=t1.d) then t1.f else (d) end FROM t1 WHERE 19<>d}
+} {400}
+do_test randexpr-2.1808 {
+ db eval {SELECT case when t1.e<=~d then case when t1.d-e in (~t1.c-case e*case when t1.e not in (t1.d,19,f) then e else b end*e when (19) then t1.a else -e end,19,17) then t1.f when t1.d not in (t1.b,b,17) then t1.b else 19 end when 13= -t1.f and not (19=t1.d) then t1.f else (d) end FROM t1 WHERE NOT (19<>d)}
+} {}
+do_test randexpr-2.1809 {
+ db eval {SELECT (select max(case when (t1.d<=t1.a*t1.b) then t1.e else case when t1.a> -t1.c*t1.f then b else b*(a) end end)*min(+ -19-(select min(a) from t1)-+17*case when not exists(select 1 from t1 where (select abs(cast(avg(a) AS integer)) from t1)=t1.a) then e when 19>=a then 13 else t1.a end*19-e) from t1) FROM t1 WHERE t1.e in (select max(t1.e)-cast(avg(e) AS integer) from t1 union select (~+count(*) | count(*) | cast(avg((abs(coalesce((select max(case f+c-17 when t1.b then t1.e else t1.d end) from t1 where 17 in (select a from t1 union select t1.b from t1)),a))/abs( -t1.e))) AS integer)+~case count(*) when cast(avg(t1.d) AS integer) then -cast(avg(t1.e) AS integer) else count(distinct d) end-max(13)+ -min(t1.a) | min((17)) | count(distinct d))-min(e) from t1)}
+} {}
+do_test randexpr-2.1810 {
+ db eval {SELECT (select max(case when (t1.d<=t1.a*t1.b) then t1.e else case when t1.a> -t1.c*t1.f then b else b*(a) end end)*min(+ -19-(select min(a) from t1)-+17*case when not exists(select 1 from t1 where (select abs(cast(avg(a) AS integer)) from t1)=t1.a) then e when 19>=a then 13 else t1.a end*19-e) from t1) FROM t1 WHERE NOT (t1.e in (select max(t1.e)-cast(avg(e) AS integer) from t1 union select (~+count(*) | count(*) | cast(avg((abs(coalesce((select max(case f+c-17 when t1.b then t1.e else t1.d end) from t1 where 17 in (select a from t1 union select t1.b from t1)),a))/abs( -t1.e))) AS integer)+~case count(*) when cast(avg(t1.d) AS integer) then -cast(avg(t1.e) AS integer) else count(distinct d) end-max(13)+ -min(t1.a) | min((17)) | count(distinct d))-min(e) from t1))}
+} {-16459500}
+do_test randexpr-2.1811 {
+ db eval {SELECT case when case (select max(t1.b)*min(case when (abs(t1.e)/abs(d)) in (select 19 from t1 union select +t1.d from t1) then t1.d when t1.d=d or 11 in (t1.c,b,t1.b) and 13 in (select max(b)-count(distinct b) from t1 union select count(distinct -t1.c) from t1) then f else 17 end) from t1) when t1.a then 11 else t1.d end+t1.a>c or t1.c between 13 and a then f when (t1.b)>=t1.a then d else b end FROM t1 WHERE (not exists(select 1 from t1 where coalesce((select max(e) from t1 where -b+a-(abs(c)/abs(b))-( -t1.a)-t1.c>=d),d) in (select count(distinct a) from t1 union select cast(avg(t1.b) AS integer) from t1) and exists(select 1 from t1 where not t1.d<>f) and t1.a in (select min(t1.a)+max(a)*max(19)*count(distinct c) from t1 union select ((count(distinct 11))) from t1) or t1.c>(13) and a between (t1.f) and 13))}
+} {600}
+do_test randexpr-2.1812 {
+ db eval {SELECT case when case (select max(t1.b)*min(case when (abs(t1.e)/abs(d)) in (select 19 from t1 union select +t1.d from t1) then t1.d when t1.d=d or 11 in (t1.c,b,t1.b) and 13 in (select max(b)-count(distinct b) from t1 union select count(distinct -t1.c) from t1) then f else 17 end) from t1) when t1.a then 11 else t1.d end+t1.a>c or t1.c between 13 and a then f when (t1.b)>=t1.a then d else b end FROM t1 WHERE NOT ((not exists(select 1 from t1 where coalesce((select max(e) from t1 where -b+a-(abs(c)/abs(b))-( -t1.a)-t1.c>=d),d) in (select count(distinct a) from t1 union select cast(avg(t1.b) AS integer) from t1) and exists(select 1 from t1 where not t1.d<>f) and t1.a in (select min(t1.a)+max(a)*max(19)*count(distinct c) from t1 union select ((count(distinct 11))) from t1) or t1.c>(13) and a between (t1.f) and 13)))}
+} {}
+do_test randexpr-2.1813 {
+ db eval {SELECT f*~13*(abs(13*d- -(abs(case when ~coalesce((select max(c) from t1 where b>case when not exists(select 1 from t1 where f not in ( - -(t1.b),t1.b,t1.f)) then e when t1.c<>f then c else 13 end),17) | -19 not in (f,b,f) then -b when not 13 in (select max((19)) from t1 union select count(*) | count(*) from t1) and 11 not between t1.b and e or 13 in (t1.a, -e,(t1.c)) then a else 11 end)/abs(t1.c))*b | t1.b)/abs(f))*f*f FROM t1 WHERE ~case f when coalesce((select max(17) from t1 where b+t1.f*case 11 when coalesce((select max(t1.f) from t1 where 17>t1.f),19)-t1.b-t1.b | d then b else c end+t1.d*11-t1.c<=case when b>=a then 19 else f end | t1.a),13) then f else t1.e end*t1.e*17-d in (select 13 from t1 union select t1.e from t1)}
+} {}
+do_test randexpr-2.1814 {
+ db eval {SELECT f*~13*(abs(13*d- -(abs(case when ~coalesce((select max(c) from t1 where b>case when not exists(select 1 from t1 where f not in ( - -(t1.b),t1.b,t1.f)) then e when t1.c<>f then c else 13 end),17) | -19 not in (f,b,f) then -b when not 13 in (select max((19)) from t1 union select count(*) | count(*) from t1) and 11 not between t1.b and e or 13 in (t1.a, -e,(t1.c)) then a else 11 end)/abs(t1.c))*b | t1.b)/abs(f))*f*f FROM t1 WHERE NOT (~case f when coalesce((select max(17) from t1 where b+t1.f*case 11 when coalesce((select max(t1.f) from t1 where 17>t1.f),19)-t1.b-t1.b | d then b else c end+t1.d*11-t1.c<=case when b>=a then 19 else f end | t1.a),13) then f else t1.e end*t1.e*17-d in (select 13 from t1 union select t1.e from t1))}
+} {-24192000000}
+do_test randexpr-2.1815 {
+ db eval {SELECT f*~13*(abs(13*d- -(abs(case when ~coalesce((select max(c) from t1 where b>case when not exists(select 1 from t1 where f not in ( - -(t1.b),t1.b,t1.f)) then e when t1.c<>f then c else 13 end),17) & -19 not in (f,b,f) then -b when not 13 in (select max((19)) from t1 union select count(*) & count(*) from t1) and 11 not between t1.b and e or 13 in (t1.a, -e,(t1.c)) then a else 11 end)/abs(t1.c))*b & t1.b)/abs(f))*f*f FROM t1 WHERE NOT (~case f when coalesce((select max(17) from t1 where b+t1.f*case 11 when coalesce((select max(t1.f) from t1 where 17>t1.f),19)-t1.b-t1.b | d then b else c end+t1.d*11-t1.c<=case when b>=a then 19 else f end | t1.a),13) then f else t1.e end*t1.e*17-d in (select 13 from t1 union select t1.e from t1))}
+} {0}
+do_test randexpr-2.1816 {
+ db eval {SELECT t1.b | (select case max( -17)-min(17) when cast(avg(a) AS integer)*(+cast(avg(f) AS integer)-cast(avg(case when not exists(select 1 from t1 where not case when t1.c<>t1.b or -d not between b and a then 11 when (11)=11 then b else t1.b end in (t1.d,t1.c,13)) then 13 when t1.e not between 17 and t1.b then t1.c else t1.d end*t1.b) AS integer))-cast(avg(19) AS integer)*~max(t1.c)-((max(13)))*(count(*))+(max(11)) then count(distinct 13) else cast(avg(17) AS integer) end from t1) FROM t1 WHERE (abs(t1.c)/abs(case t1.d when t1.f then 13 else t1.f+13 end)) not between c and 19}
+} {217}
+do_test randexpr-2.1817 {
+ db eval {SELECT t1.b | (select case max( -17)-min(17) when cast(avg(a) AS integer)*(+cast(avg(f) AS integer)-cast(avg(case when not exists(select 1 from t1 where not case when t1.c<>t1.b or -d not between b and a then 11 when (11)=11 then b else t1.b end in (t1.d,t1.c,13)) then 13 when t1.e not between 17 and t1.b then t1.c else t1.d end*t1.b) AS integer))-cast(avg(19) AS integer)*~max(t1.c)-((max(13)))*(count(*))+(max(11)) then count(distinct 13) else cast(avg(17) AS integer) end from t1) FROM t1 WHERE NOT ((abs(t1.c)/abs(case t1.d when t1.f then 13 else t1.f+13 end)) not between c and 19)}
+} {}
+do_test randexpr-2.1818 {
+ db eval {SELECT t1.b & (select case max( -17)-min(17) when cast(avg(a) AS integer)*(+cast(avg(f) AS integer)-cast(avg(case when not exists(select 1 from t1 where not case when t1.c<>t1.b or -d not between b and a then 11 when (11)=11 then b else t1.b end in (t1.d,t1.c,13)) then 13 when t1.e not between 17 and t1.b then t1.c else t1.d end*t1.b) AS integer))-cast(avg(19) AS integer)*~max(t1.c)-((max(13)))*(count(*))+(max(11)) then count(distinct 13) else cast(avg(17) AS integer) end from t1) FROM t1 WHERE (abs(t1.c)/abs(case t1.d when t1.f then 13 else t1.f+13 end)) not between c and 19}
+} {0}
+do_test randexpr-2.1819 {
+ db eval {SELECT case +c-case (select case count(distinct 13) when min(19*e) then ~count(*) else ~min(case when not +13*(case when e*c>=e then e else f end)-a+c not in (b,t1.b,t1.e) then 19 else 17 end*a) end from t1) when 11 then 11 else c end+t1.c when t1.b then d else 19 end FROM t1 WHERE t1.a<>~coalesce((select max(e) from t1 where 13-17*13<>19*17-f or coalesce((select max(~case +t1.d-f*e | c+(17)+a | c*((b)) when a then t1.a else d end-d) from t1 where t1.c>= -t1.a),t1.b) | 19>t1.a),c)}
+} {19}
+do_test randexpr-2.1820 {
+ db eval {SELECT case +c-case (select case count(distinct 13) when min(19*e) then ~count(*) else ~min(case when not +13*(case when e*c>=e then e else f end)-a+c not in (b,t1.b,t1.e) then 19 else 17 end*a) end from t1) when 11 then 11 else c end+t1.c when t1.b then d else 19 end FROM t1 WHERE NOT (t1.a<>~coalesce((select max(e) from t1 where 13-17*13<>19*17-f or coalesce((select max(~case +t1.d-f*e | c+(17)+a | c*((b)) when a then t1.a else d end-d) from t1 where t1.c>= -t1.a),t1.b) | 19>t1.a),c))}
+} {}
+do_test randexpr-2.1821 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where f between case when (19 not in (t1.b,(a),t1.a)) or t1.a=t1.b | -(select +cast(avg(17-case when -c<=17 then a when -11 not in (11,19,a) then e else 11 end-t1.a*d) AS integer) from t1) then t1.b when (11)*f in (13,t1.a,a) or t1.a<t1.d then b*t1.f else a end and -11), -b) FROM t1 WHERE (f-b<case case (a) when a then 19+coalesce((select t1.a from t1 where 11 between +coalesce((select max(case when t1.b not in (t1.f,f,t1.b) and a in (select 11 from t1 union select c from t1) then ~(t1.e) else 13 end) from t1 where t1.c>=e),f)*b-f and t1.f),t1.b) else d end+19 when t1.a then 11 else e end-t1.a)}
+} {}
+do_test randexpr-2.1822 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where f between case when (19 not in (t1.b,(a),t1.a)) or t1.a=t1.b | -(select +cast(avg(17-case when -c<=17 then a when -11 not in (11,19,a) then e else 11 end-t1.a*d) AS integer) from t1) then t1.b when (11)*f in (13,t1.a,a) or t1.a<t1.d then b*t1.f else a end and -11), -b) FROM t1 WHERE NOT ((f-b<case case (a) when a then 19+coalesce((select t1.a from t1 where 11 between +coalesce((select max(case when t1.b not in (t1.f,f,t1.b) and a in (select 11 from t1 union select c from t1) then ~(t1.e) else 13 end) from t1 where t1.c>=e),f)*b-f and t1.f),t1.b) else d end+19 when t1.a then 11 else e end-t1.a))}
+} {-200}
+do_test randexpr-2.1823 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where f between case when (19 not in (t1.b,(a),t1.a)) or t1.a=t1.b & -(select +cast(avg(17-case when -c<=17 then a when -11 not in (11,19,a) then e else 11 end-t1.a*d) AS integer) from t1) then t1.b when (11)*f in (13,t1.a,a) or t1.a<t1.d then b*t1.f else a end and -11), -b) FROM t1 WHERE NOT ((f-b<case case (a) when a then 19+coalesce((select t1.a from t1 where 11 between +coalesce((select max(case when t1.b not in (t1.f,f,t1.b) and a in (select 11 from t1 union select c from t1) then ~(t1.e) else 13 end) from t1 where t1.c>=e),f)*b-f and t1.f),t1.b) else d end+19 when t1.a then 11 else e end-t1.a))}
+} {-200}
+do_test randexpr-2.1824 {
+ db eval {SELECT case when not -t1.c in (coalesce((select d from t1 where t1.a not in (t1.c+f, -f,19) and t1.b in (select max(t1.d)+min(19)*min(t1.e) from t1 union select count(distinct d) from t1) and (t1.d) in (select -count(*) from t1 union select -count(*) from t1)),d* -t1.e),b,f) or -c not in (a, -t1.a,t1.e) then case when b between 17 and t1.b and a not in (t1.a,e,t1.e) then t1.d else 19 end*t1.b else t1.d end+t1.d FROM t1 WHERE (abs((17))/abs(11 | e*e+d++t1.d)) in (19+t1.f,e,(abs(13)/abs( -t1.c)))}
+} {4200}
+do_test randexpr-2.1825 {
+ db eval {SELECT case when not -t1.c in (coalesce((select d from t1 where t1.a not in (t1.c+f, -f,19) and t1.b in (select max(t1.d)+min(19)*min(t1.e) from t1 union select count(distinct d) from t1) and (t1.d) in (select -count(*) from t1 union select -count(*) from t1)),d* -t1.e),b,f) or -c not in (a, -t1.a,t1.e) then case when b between 17 and t1.b and a not in (t1.a,e,t1.e) then t1.d else 19 end*t1.b else t1.d end+t1.d FROM t1 WHERE NOT ((abs((17))/abs(11 | e*e+d++t1.d)) in (19+t1.f,e,(abs(13)/abs( -t1.c))))}
+} {}
+do_test randexpr-2.1826 {
+ db eval {SELECT case when ( -(select ~ -~ -(max(c))-min(t1.e) | count(distinct (11)) | min(t1.a) from t1)-case when case d when a then case when t1.e=t1.a then t1.c else c end else c end<=t1.f then t1.b when t1.c not in (a,19,c) then b else 17 end>=19) or d in (19,f, -11) then 19 else (select case min(t1.a)-(cast(avg(t1.f) AS integer))-(min(11)) when count(*) then count(*) else count(distinct a) end from t1) end FROM t1 WHERE not exists(select 1 from t1 where (abs(11-13)/abs(f))>19*~19+t1.d-t1.f+coalesce((select max(f) from t1 where t1.a-t1.e+case when case when a not between t1.c and 19 and -t1.e>t1.c then case when t1.f in (t1.d,e,t1.f) then d when c not in (11,t1.c,d) then t1.a else a end when t1.b=11 then t1.c else t1.e end>e then e else e end-11<t1.f),c)- -c-17) or 19<>t1.f}
+} {1}
+do_test randexpr-2.1827 {
+ db eval {SELECT case when ( -(select ~ -~ -(max(c))-min(t1.e) | count(distinct (11)) | min(t1.a) from t1)-case when case d when a then case when t1.e=t1.a then t1.c else c end else c end<=t1.f then t1.b when t1.c not in (a,19,c) then b else 17 end>=19) or d in (19,f, -11) then 19 else (select case min(t1.a)-(cast(avg(t1.f) AS integer))-(min(11)) when count(*) then count(*) else count(distinct a) end from t1) end FROM t1 WHERE NOT (not exists(select 1 from t1 where (abs(11-13)/abs(f))>19*~19+t1.d-t1.f+coalesce((select max(f) from t1 where t1.a-t1.e+case when case when a not between t1.c and 19 and -t1.e>t1.c then case when t1.f in (t1.d,e,t1.f) then d when c not in (11,t1.c,d) then t1.a else a end when t1.b=11 then t1.c else t1.e end>e then e else e end-11<t1.f),c)- -c-17) or 19<>t1.f)}
+} {}
+do_test randexpr-2.1828 {
+ db eval {SELECT case when ( -(select ~ -~ -(max(c))-min(t1.e) & count(distinct (11)) & min(t1.a) from t1)-case when case d when a then case when t1.e=t1.a then t1.c else c end else c end<=t1.f then t1.b when t1.c not in (a,19,c) then b else 17 end>=19) or d in (19,f, -11) then 19 else (select case min(t1.a)-(cast(avg(t1.f) AS integer))-(min(11)) when count(*) then count(*) else count(distinct a) end from t1) end FROM t1 WHERE not exists(select 1 from t1 where (abs(11-13)/abs(f))>19*~19+t1.d-t1.f+coalesce((select max(f) from t1 where t1.a-t1.e+case when case when a not between t1.c and 19 and -t1.e>t1.c then case when t1.f in (t1.d,e,t1.f) then d when c not in (11,t1.c,d) then t1.a else a end when t1.b=11 then t1.c else t1.e end>e then e else e end-11<t1.f),c)- -c-17) or 19<>t1.f}
+} {1}
+do_test randexpr-2.1829 {
+ db eval {SELECT t1.e | t1.a*~(17)-t1.c*f*f-coalesce((select max( -t1.a+coalesce((select t1.a from t1 where 19 not between 17 and f),(t1.b))*c+11) from t1 where 19 in (select -cast(avg(f) AS integer)-cast(avg(a) AS integer)*count(distinct d) from t1 union select count(*) from t1) and t1.d in (17,t1.d, -t1.c) or 19<>19),a)*11 FROM t1 WHERE not +19+coalesce((select -19 from t1 where t1.c | e in (select ~ -abs(case ~abs(+(count(distinct 17) | case ~(max(t1.a))+(+~ -min(17)) when abs(min(t1.c)) then count(distinct 17) else -cast(avg(t1.e) AS integer) end)*cast(avg(c) AS integer)*cast(avg(t1.b) AS integer)) when count(distinct t1.d) then min(b) else -cast(avg(d) AS integer) end) from t1 union select count(*) from t1)),13)>13}
+} {}
+do_test randexpr-2.1830 {
+ db eval {SELECT t1.e | t1.a*~(17)-t1.c*f*f-coalesce((select max( -t1.a+coalesce((select t1.a from t1 where 19 not between 17 and f),(t1.b))*c+11) from t1 where 19 in (select -cast(avg(f) AS integer)-cast(avg(a) AS integer)*count(distinct d) from t1 union select count(*) from t1) and t1.d in (17,t1.d, -t1.c) or 19<>19),a)*11 FROM t1 WHERE NOT (not +19+coalesce((select -19 from t1 where t1.c | e in (select ~ -abs(case ~abs(+(count(distinct 17) | case ~(max(t1.a))+(+~ -min(17)) when abs(min(t1.c)) then count(distinct 17) else -cast(avg(t1.e) AS integer) end)*cast(avg(c) AS integer)*cast(avg(t1.b) AS integer)) when count(distinct t1.d) then min(b) else -cast(avg(d) AS integer) end) from t1 union select count(*) from t1)),13)>13)}
+} {-108002820}
+do_test randexpr-2.1831 {
+ db eval {SELECT t1.e & t1.a*~(17)-t1.c*f*f-coalesce((select max( -t1.a+coalesce((select t1.a from t1 where 19 not between 17 and f),(t1.b))*c+11) from t1 where 19 in (select -cast(avg(f) AS integer)-cast(avg(a) AS integer)*count(distinct d) from t1 union select count(*) from t1) and t1.d in (17,t1.d, -t1.c) or 19<>19),a)*11 FROM t1 WHERE NOT (not +19+coalesce((select -19 from t1 where t1.c | e in (select ~ -abs(case ~abs(+(count(distinct 17) | case ~(max(t1.a))+(+~ -min(17)) when abs(min(t1.c)) then count(distinct 17) else -cast(avg(t1.e) AS integer) end)*cast(avg(c) AS integer)*cast(avg(t1.b) AS integer)) when count(distinct t1.d) then min(b) else -cast(avg(d) AS integer) end) from t1 union select count(*) from t1)),13)>13)}
+} {420}
+do_test randexpr-2.1832 {
+ db eval {SELECT case when t1.a<(abs((abs(13)/abs(case t1.e+11*17*case +case case when ~19>=t1.c then f when f not in (a,e,d) then 19 else b end when 19 then 19 else b end | -c when c then t1.c else c end*d-t1.e when e then 13 else c end)))/abs(t1.b)) then 17 when t1.b not in (t1.a,13,e) then e else -t1.c end FROM t1 WHERE 19>=11}
+} {500}
+do_test randexpr-2.1833 {
+ db eval {SELECT case when t1.a<(abs((abs(13)/abs(case t1.e+11*17*case +case case when ~19>=t1.c then f when f not in (a,e,d) then 19 else b end when 19 then 19 else b end | -c when c then t1.c else c end*d-t1.e when e then 13 else c end)))/abs(t1.b)) then 17 when t1.b not in (t1.a,13,e) then e else -t1.c end FROM t1 WHERE NOT (19>=11)}
+} {}
+do_test randexpr-2.1834 {
+ db eval {SELECT case when t1.a<(abs((abs(13)/abs(case t1.e+11*17*case +case case when ~19>=t1.c then f when f not in (a,e,d) then 19 else b end when 19 then 19 else b end & -c when c then t1.c else c end*d-t1.e when e then 13 else c end)))/abs(t1.b)) then 17 when t1.b not in (t1.a,13,e) then e else -t1.c end FROM t1 WHERE 19>=11}
+} {500}
+do_test randexpr-2.1835 {
+ db eval {SELECT coalesce((select (select count(*)-+count(*) from t1) from t1 where +t1.f+t1.f<~case when exists(select 1 from t1 where coalesce((select t1.a from t1 where b-19<t1.f),11) in (case when -(select count(distinct t1.a) from t1)-c-t1.d between b and (d) then d else t1.e end,f,c)) then t1.b when t1.e<>(11) then d else (c) end+e+t1.d),c) FROM t1 WHERE case when t1.f+(select min(t1.c+(abs(13+(abs(t1.e+d-11-e+d+c)/abs(t1.e))-c*t1.f)/abs(t1.b))) from t1)+f=d or t1.b not between t1.e and t1.a then 11-a when (13 in (13,19,19)) then t1.d else t1.b end<t1.f}
+} {300}
+do_test randexpr-2.1836 {
+ db eval {SELECT coalesce((select (select count(*)-+count(*) from t1) from t1 where +t1.f+t1.f<~case when exists(select 1 from t1 where coalesce((select t1.a from t1 where b-19<t1.f),11) in (case when -(select count(distinct t1.a) from t1)-c-t1.d between b and (d) then d else t1.e end,f,c)) then t1.b when t1.e<>(11) then d else (c) end+e+t1.d),c) FROM t1 WHERE NOT (case when t1.f+(select min(t1.c+(abs(13+(abs(t1.e+d-11-e+d+c)/abs(t1.e))-c*t1.f)/abs(t1.b))) from t1)+f=d or t1.b not between t1.e and t1.a then 11-a when (13 in (13,19,19)) then t1.d else t1.b end<t1.f)}
+} {}
+do_test randexpr-2.1837 {
+ db eval {SELECT case when not exists(select 1 from t1 where not exists(select 1 from t1 where (case when (abs(a)/abs(t1.f))<a then t1.a when t1.b not in (11,t1.f,(c+d*t1.d)+t1.b+d-t1.a+e) then e else e end<=d))) then (select ~max(13) from t1) when 13 not between coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where 13>=t1.b)),((d))) and t1.c then 19 else 13 end FROM t1 WHERE d*a in (case when 19>t1.e then c | (select +~count(distinct t1.b)-++abs(min(11)+ -~min(t1.b)+ -(max(t1.d))-min(t1.b)-count(distinct t1.f)) | max(f) from t1) else a+t1.c end,t1.a+case 19 when (11*a)*t1.c then d else a end*t1.a-d,f)}
+} {}
+do_test randexpr-2.1838 {
+ db eval {SELECT case when not exists(select 1 from t1 where not exists(select 1 from t1 where (case when (abs(a)/abs(t1.f))<a then t1.a when t1.b not in (11,t1.f,(c+d*t1.d)+t1.b+d-t1.a+e) then e else e end<=d))) then (select ~max(13) from t1) when 13 not between coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where 13>=t1.b)),((d))) and t1.c then 19 else 13 end FROM t1 WHERE NOT (d*a in (case when 19>t1.e then c | (select +~count(distinct t1.b)-++abs(min(11)+ -~min(t1.b)+ -(max(t1.d))-min(t1.b)-count(distinct t1.f)) | max(f) from t1) else a+t1.c end,t1.a+case 19 when (11*a)*t1.c then d else a end*t1.a-d,f))}
+} {-14}
+do_test randexpr-2.1839 {
+ db eval {SELECT case when b<= -coalesce((select max(t1.b+t1.c+a*a-t1.c-e) from t1 where not 11>e or c<=17 and b<=b), -t1.d)+13 and 17 not between a and c and not exists(select 1 from t1 where f not between t1.d and t1.e and t1.d between 13 and -t1.a) then t1.b when e not in (a,t1.f, -t1.d) then t1.c else e end FROM t1 WHERE not coalesce((select max((c)) from t1 where d* -coalesce((select max(coalesce((select t1.d from t1 where (d<=d)),d)) from t1 where (abs(case 11 when (select -+count(distinct 13)*min(c) | count(*) from t1) then 11 else case when (19 between (19) and 17 or t1.c in (c,19,d)) then c when -t1.e>=c then c else c end end*11)/abs((13))) not in (17, -t1.e, -t1.e)),t1.e)=17),t1.c) between 13 and t1.f}
+} {}
+do_test randexpr-2.1840 {
+ db eval {SELECT case when b<= -coalesce((select max(t1.b+t1.c+a*a-t1.c-e) from t1 where not 11>e or c<=17 and b<=b), -t1.d)+13 and 17 not between a and c and not exists(select 1 from t1 where f not between t1.d and t1.e and t1.d between 13 and -t1.a) then t1.b when e not in (a,t1.f, -t1.d) then t1.c else e end FROM t1 WHERE NOT (not coalesce((select max((c)) from t1 where d* -coalesce((select max(coalesce((select t1.d from t1 where (d<=d)),d)) from t1 where (abs(case 11 when (select -+count(distinct 13)*min(c) | count(*) from t1) then 11 else case when (19 between (19) and 17 or t1.c in (c,19,d)) then c when -t1.e>=c then c else c end end*11)/abs((13))) not in (17, -t1.e, -t1.e)),t1.e)=17),t1.c) between 13 and t1.f)}
+} {300}
+do_test randexpr-2.1841 {
+ db eval {SELECT 17 | -(case when (a) not between 11 and case (abs(~(abs(13-case (abs(17)/abs(19+e | t1.e)) when (t1.d) then -(t1.c) else t1.f end+t1.f*t1.c)/abs(a)))/abs(17)) when 19 then d else t1.d end then 17 when not exists(select 1 from t1 where t1.e not in (t1.b,t1.b,b) or a between a and 17) then 11 else b end) | t1.e FROM t1 WHERE 17>=e}
+} {}
+do_test randexpr-2.1842 {
+ db eval {SELECT 17 | -(case when (a) not between 11 and case (abs(~(abs(13-case (abs(17)/abs(19+e | t1.e)) when (t1.d) then -(t1.c) else t1.f end+t1.f*t1.c)/abs(a)))/abs(17)) when 19 then d else t1.d end then 17 when not exists(select 1 from t1 where t1.e not in (t1.b,t1.b,b) or a between a and 17) then 11 else b end) | t1.e FROM t1 WHERE NOT (17>=e)}
+} {-3}
+do_test randexpr-2.1843 {
+ db eval {SELECT 17 & -(case when (a) not between 11 and case (abs(~(abs(13-case (abs(17)/abs(19+e & t1.e)) when (t1.d) then -(t1.c) else t1.f end+t1.f*t1.c)/abs(a)))/abs(17)) when 19 then d else t1.d end then 17 when not exists(select 1 from t1 where t1.e not in (t1.b,t1.b,b) or a between a and 17) then 11 else b end) & t1.e FROM t1 WHERE NOT (17>=e)}
+} {16}
+do_test randexpr-2.1844 {
+ db eval {SELECT (abs(11 | t1.e)/abs(case 13 when 17*+t1.a+d*+d then ~ -17*+ - -case f when b then a-b else t1.d end-f+t1.f+17 else t1.a end)) FROM t1 WHERE t1.f<>17}
+} {5}
+do_test randexpr-2.1845 {
+ db eval {SELECT (abs(11 | t1.e)/abs(case 13 when 17*+t1.a+d*+d then ~ -17*+ - -case f when b then a-b else t1.d end-f+t1.f+17 else t1.a end)) FROM t1 WHERE NOT (t1.f<>17)}
+} {}
+do_test randexpr-2.1846 {
+ db eval {SELECT (abs(11 & t1.e)/abs(case 13 when 17*+t1.a+d*+d then ~ -17*+ - -case f when b then a-b else t1.d end-f+t1.f+17 else t1.a end)) FROM t1 WHERE t1.f<>17}
+} {0}
+do_test randexpr-2.1847 {
+ db eval {SELECT case when not coalesce((select max(case 11 when case d when coalesce((select f from t1 where case when (t1.d) | case 11 when t1.d then 11 else (t1.a) end | t1.b in (e,c,(11)) then 17 when c between e and f then t1.e else t1.a end>t1.e),t1.d) then 13 else c end then c else c end) from t1 where t1.e not between (a) and (t1.d)),c) not in ((11),((19)),a) then (t1.c) else (c) end FROM t1 WHERE t1.d-t1.c>=13}
+} {300}
+do_test randexpr-2.1848 {
+ db eval {SELECT case when not coalesce((select max(case 11 when case d when coalesce((select f from t1 where case when (t1.d) | case 11 when t1.d then 11 else (t1.a) end | t1.b in (e,c,(11)) then 17 when c between e and f then t1.e else t1.a end>t1.e),t1.d) then 13 else c end then c else c end) from t1 where t1.e not between (a) and (t1.d)),c) not in ((11),((19)),a) then (t1.c) else (c) end FROM t1 WHERE NOT (t1.d-t1.c>=13)}
+} {}
+do_test randexpr-2.1849 {
+ db eval {SELECT case when not coalesce((select max(case 11 when case d when coalesce((select f from t1 where case when (t1.d) & case 11 when t1.d then 11 else (t1.a) end & t1.b in (e,c,(11)) then 17 when c between e and f then t1.e else t1.a end>t1.e),t1.d) then 13 else c end then c else c end) from t1 where t1.e not between (a) and (t1.d)),c) not in ((11),((19)),a) then (t1.c) else (c) end FROM t1 WHERE t1.d-t1.c>=13}
+} {300}
+do_test randexpr-2.1850 {
+ db eval {SELECT (select case count(distinct ~case when (abs(coalesce((select t1.e from t1 where (not exists(select 1 from t1 where a | e between c and coalesce((select (t1.d) from t1 where (t1.a=t1.a)), -(c))))),b+19))/abs(d))>11 then b else t1.d end) when count(distinct 17) then ~min((t1.d))-case -(case -cast(avg(t1.b) AS integer) when -max(13) then (min(t1.d)) else count(distinct t1.b) end+(min(t1.e)))*(cast(avg( -17) AS integer)) when -count(distinct 19) then count(*) else max(t1.c) end else count(distinct f) end from t1) FROM t1 WHERE t1.e=t1.d}
+} {}
+do_test randexpr-2.1851 {
+ db eval {SELECT (select case count(distinct ~case when (abs(coalesce((select t1.e from t1 where (not exists(select 1 from t1 where a | e between c and coalesce((select (t1.d) from t1 where (t1.a=t1.a)), -(c))))),b+19))/abs(d))>11 then b else t1.d end) when count(distinct 17) then ~min((t1.d))-case -(case -cast(avg(t1.b) AS integer) when -max(13) then (min(t1.d)) else count(distinct t1.b) end+(min(t1.e)))*(cast(avg( -17) AS integer)) when -count(distinct 19) then count(*) else max(t1.c) end else count(distinct f) end from t1) FROM t1 WHERE NOT (t1.e=t1.d)}
+} {-701}
+do_test randexpr-2.1852 {
+ db eval {SELECT (select case count(distinct ~case when (abs(coalesce((select t1.e from t1 where (not exists(select 1 from t1 where a & e between c and coalesce((select (t1.d) from t1 where (t1.a=t1.a)), -(c))))),b+19))/abs(d))>11 then b else t1.d end) when count(distinct 17) then ~min((t1.d))-case -(case -cast(avg(t1.b) AS integer) when -max(13) then (min(t1.d)) else count(distinct t1.b) end+(min(t1.e)))*(cast(avg( -17) AS integer)) when -count(distinct 19) then count(*) else max(t1.c) end else count(distinct f) end from t1) FROM t1 WHERE NOT (t1.e=t1.d)}
+} {-701}
+do_test randexpr-2.1853 {
+ db eval {SELECT case when t1.d<>t1.a and a-t1.b-c in (13,t1.e-(abs(d)/abs(coalesce((select max(e) from t1 where 19 not between -b and 17),b))),t1.b) or (not exists(select 1 from t1 where t1.f not between -17 and a)) then case when e>t1.e then t1.d when t1.c<d or (19<=13) then (13) else b end+t1.e when c<=a then t1.d else f end+17 FROM t1 WHERE (t1.d)-case when not exists(select 1 from t1 where c<>f-11 and not not b<coalesce((select max(a) from t1 where (select cast(avg(case t1.a*19 when (select abs(cast(avg(c) AS integer)+(count(*))) from t1) | t1.f+11* -b then ((e)) else t1.a end) AS integer) from t1)-t1.f in (a,a,e)),19)) then 13*e else t1.b end not between 13 and t1.c}
+} {617}
+do_test randexpr-2.1854 {
+ db eval {SELECT case when t1.d<>t1.a and a-t1.b-c in (13,t1.e-(abs(d)/abs(coalesce((select max(e) from t1 where 19 not between -b and 17),b))),t1.b) or (not exists(select 1 from t1 where t1.f not between -17 and a)) then case when e>t1.e then t1.d when t1.c<d or (19<=13) then (13) else b end+t1.e when c<=a then t1.d else f end+17 FROM t1 WHERE NOT ((t1.d)-case when not exists(select 1 from t1 where c<>f-11 and not not b<coalesce((select max(a) from t1 where (select cast(avg(case t1.a*19 when (select abs(cast(avg(c) AS integer)+(count(*))) from t1) | t1.f+11* -b then ((e)) else t1.a end) AS integer) from t1)-t1.f in (a,a,e)),19)) then 13*e else t1.b end not between 13 and t1.c)}
+} {}
+do_test randexpr-2.1855 {
+ db eval {SELECT ~case 17 when t1.c then coalesce((select max((case when not exists(select 1 from t1 where 11<>coalesce((select d from t1 where not exists(select 1 from t1 where c*b in (t1.b*t1.d,t1.c,b) or c between d and a)),19)-t1.c*e) then coalesce((select f from t1 where 11 in (select c from t1 union select b from t1)),(c)) when 17<>t1.b then d else 19 end)) from t1 where f in (a,t1.f,t1.d)),(19)) else t1.e end FROM t1 WHERE not not exists(select 1 from t1 where (select abs(min(19-19))*count(*) | min(13)*min((a))+cast(avg(t1.e) AS integer)+(cast(avg(19) AS integer)) from t1) in (17,+(select min(b) from t1),(select cast(avg(f) AS integer) from t1)) and 11 in (select ( -(min(c))) from t1 union select (min(13)) from t1)) or t1.d between c and -(f) or not t1.c in (select min(e) from t1 union select -(max(e)) from t1) and t1.e in (t1.f,a,11) and f not between a and 17 and 19<=17 and 13 not in (b,t1.b,13)}
+} {}
+do_test randexpr-2.1856 {
+ db eval {SELECT ~case 17 when t1.c then coalesce((select max((case when not exists(select 1 from t1 where 11<>coalesce((select d from t1 where not exists(select 1 from t1 where c*b in (t1.b*t1.d,t1.c,b) or c between d and a)),19)-t1.c*e) then coalesce((select f from t1 where 11 in (select c from t1 union select b from t1)),(c)) when 17<>t1.b then d else 19 end)) from t1 where f in (a,t1.f,t1.d)),(19)) else t1.e end FROM t1 WHERE NOT (not not exists(select 1 from t1 where (select abs(min(19-19))*count(*) | min(13)*min((a))+cast(avg(t1.e) AS integer)+(cast(avg(19) AS integer)) from t1) in (17,+(select min(b) from t1),(select cast(avg(f) AS integer) from t1)) and 11 in (select ( -(min(c))) from t1 union select (min(13)) from t1)) or t1.d between c and -(f) or not t1.c in (select min(e) from t1 union select -(max(e)) from t1) and t1.e in (t1.f,a,11) and f not between a and 17 and 19<=17 and 13 not in (b,t1.b,13))}
+} {-501}
+do_test randexpr-2.1857 {
+ db eval {SELECT coalesce((select +f+coalesce((select case when b- -f*t1.d-t1.a>d and t1.e in (select b from t1 union select t1.d from t1) then 11 else -a end from t1 where (not (t1.f) not between 13 and t1.f)),11) from t1 where t1.c<=c and (d) between 11 and t1.b or b in (select d from t1 union select t1.e from t1) and 19<>t1.e or 19 not between a and a),19) FROM t1 WHERE t1.e<>(select cast(avg((b)*(select abs( -max(t1.f)) from t1)) AS integer) from t1)}
+} {500}
+do_test randexpr-2.1858 {
+ db eval {SELECT coalesce((select +f+coalesce((select case when b- -f*t1.d-t1.a>d and t1.e in (select b from t1 union select t1.d from t1) then 11 else -a end from t1 where (not (t1.f) not between 13 and t1.f)),11) from t1 where t1.c<=c and (d) between 11 and t1.b or b in (select d from t1 union select t1.e from t1) and 19<>t1.e or 19 not between a and a),19) FROM t1 WHERE NOT (t1.e<>(select cast(avg((b)*(select abs( -max(t1.f)) from t1)) AS integer) from t1))}
+} {}
+do_test randexpr-2.1859 {
+ db eval {SELECT coalesce((select max(coalesce((select (t1.f) from t1 where f in (select t1.f+(select case count(distinct 19) when count(*) then max(t1.d) else -count(*) end from t1) from t1 union select 13 from t1)),c)) from t1 where not exists(select 1 from t1 where coalesce((select (select +count(*) | ~(~ -count(distinct -13)) from t1) from t1 where case when d*~f-13<>((d)) then 19 else t1.a end not between d and t1.e),t1.f) | t1.d in (select t1.d from t1 union select t1.d from t1))),13) FROM t1 WHERE b= -~case f-t1.a | ~case coalesce((select max(t1.b) from t1 where b>t1.e or t1.d=17-(abs(coalesce((select 17 from t1 where 17 between c and c),a)-c+a)/abs(t1.f))-c and d not in (17,19,c)),c) when 11 then e else t1.d end | t1.c-d when t1.c then c else e end | a}
+} {}
+do_test randexpr-2.1860 {
+ db eval {SELECT coalesce((select max(coalesce((select (t1.f) from t1 where f in (select t1.f+(select case count(distinct 19) when count(*) then max(t1.d) else -count(*) end from t1) from t1 union select 13 from t1)),c)) from t1 where not exists(select 1 from t1 where coalesce((select (select +count(*) | ~(~ -count(distinct -13)) from t1) from t1 where case when d*~f-13<>((d)) then 19 else t1.a end not between d and t1.e),t1.f) | t1.d in (select t1.d from t1 union select t1.d from t1))),13) FROM t1 WHERE NOT (b= -~case f-t1.a | ~case coalesce((select max(t1.b) from t1 where b>t1.e or t1.d=17-(abs(coalesce((select 17 from t1 where 17 between c and c),a)-c+a)/abs(t1.f))-c and d not in (17,19,c)),c) when 11 then e else t1.d end | t1.c-d when t1.c then c else e end | a)}
+} {300}
+do_test randexpr-2.1861 {
+ db eval {SELECT coalesce((select max(coalesce((select (t1.f) from t1 where f in (select t1.f+(select case count(distinct 19) when count(*) then max(t1.d) else -count(*) end from t1) from t1 union select 13 from t1)),c)) from t1 where not exists(select 1 from t1 where coalesce((select (select +count(*) & ~(~ -count(distinct -13)) from t1) from t1 where case when d*~f-13<>((d)) then 19 else t1.a end not between d and t1.e),t1.f) & t1.d in (select t1.d from t1 union select t1.d from t1))),13) FROM t1 WHERE NOT (b= -~case f-t1.a | ~case coalesce((select max(t1.b) from t1 where b>t1.e or t1.d=17-(abs(coalesce((select 17 from t1 where 17 between c and c),a)-c+a)/abs(t1.f))-c and d not in (17,19,c)),c) when 11 then e else t1.d end | t1.c-d when t1.c then c else e end | a)}
+} {300}
+do_test randexpr-2.1862 {
+ db eval {SELECT coalesce((select max(( -17-case when t1.c-13<+11 | (t1.a)-e then 13*t1.a when coalesce((select 11 from t1 where t1.a>t1.c),17)+f+t1.a not between 13 and e then t1.f else c end)) from t1 where exists(select 1 from t1 where (19>=t1.f)) and f in (select max(13) from t1 union select count(*) from t1) and (19)>=t1.f),d) FROM t1 WHERE t1.f in (select 19 from t1 union select -17*11+t1.d from t1)}
+} {}
+do_test randexpr-2.1863 {
+ db eval {SELECT coalesce((select max(( -17-case when t1.c-13<+11 | (t1.a)-e then 13*t1.a when coalesce((select 11 from t1 where t1.a>t1.c),17)+f+t1.a not between 13 and e then t1.f else c end)) from t1 where exists(select 1 from t1 where (19>=t1.f)) and f in (select max(13) from t1 union select count(*) from t1) and (19)>=t1.f),d) FROM t1 WHERE NOT (t1.f in (select 19 from t1 union select -17*11+t1.d from t1))}
+} {400}
+do_test randexpr-2.1864 {
+ db eval {SELECT coalesce((select max(( -17-case when t1.c-13<+11 & (t1.a)-e then 13*t1.a when coalesce((select 11 from t1 where t1.a>t1.c),17)+f+t1.a not between 13 and e then t1.f else c end)) from t1 where exists(select 1 from t1 where (19>=t1.f)) and f in (select max(13) from t1 union select count(*) from t1) and (19)>=t1.f),d) FROM t1 WHERE NOT (t1.f in (select 19 from t1 union select -17*11+t1.d from t1))}
+} {400}
+do_test randexpr-2.1865 {
+ db eval {SELECT (t1.a)+c*case when not b in (select 11 from t1 union select 13 from t1) and a=case when not exists(select 1 from t1 where exists(select 1 from t1 where ~+( -(17)) | t1.d>=b)) then case t1.d when c then 19 else t1.c end*a else d end-a then e when b not between f and d and t1.b>=11 or not (t1.e>=b) and 11<=17 then 13 else t1.d end FROM t1 WHERE b in (e | 19,t1.c,case 17 when 19 then +(case when 19> -coalesce((select max(a) from t1 where t1.a not in (case e when t1.d then (c)-c else 11 end | (11)-c*t1.f,e,t1.f)),13) then t1.e else t1.e end)*e else 13 end-19+ - -t1.d* -b) or -t1.e>b}
+} {}
+do_test randexpr-2.1866 {
+ db eval {SELECT (t1.a)+c*case when not b in (select 11 from t1 union select 13 from t1) and a=case when not exists(select 1 from t1 where exists(select 1 from t1 where ~+( -(17)) | t1.d>=b)) then case t1.d when c then 19 else t1.c end*a else d end-a then e when b not between f and d and t1.b>=11 or not (t1.e>=b) and 11<=17 then 13 else t1.d end FROM t1 WHERE NOT (b in (e | 19,t1.c,case 17 when 19 then +(case when 19> -coalesce((select max(a) from t1 where t1.a not in (case e when t1.d then (c)-c else 11 end | (11)-c*t1.f,e,t1.f)),13) then t1.e else t1.e end)*e else 13 end-19+ - -t1.d* -b) or -t1.e>b)}
+} {4000}
+do_test randexpr-2.1867 {
+ db eval {SELECT (t1.a)+c*case when not b in (select 11 from t1 union select 13 from t1) and a=case when not exists(select 1 from t1 where exists(select 1 from t1 where ~+( -(17)) & t1.d>=b)) then case t1.d when c then 19 else t1.c end*a else d end-a then e when b not between f and d and t1.b>=11 or not (t1.e>=b) and 11<=17 then 13 else t1.d end FROM t1 WHERE NOT (b in (e | 19,t1.c,case 17 when 19 then +(case when 19> -coalesce((select max(a) from t1 where t1.a not in (case e when t1.d then (c)-c else 11 end | (11)-c*t1.f,e,t1.f)),13) then t1.e else t1.e end)*e else 13 end-19+ - -t1.d* -b) or -t1.e>b)}
+} {4000}
+do_test randexpr-2.1868 {
+ db eval {SELECT case when b | case when 13 between ~coalesce((select 19 from t1 where b in (select max(a*17) from t1 union select cast(avg( -19) AS integer)+abs(cast(avg(a) AS integer)) from t1)),17) and 11 then a when not exists(select 1 from t1 where not exists(select 1 from t1 where 19<=e)) and d in (select 17 from t1 union select 17 from t1) then -b else a end-a in (select max(t1.c) from t1 union select min(e) | count(*)+count(*) from t1) then t1.b when not (not 19<=t1.b) then 13 else a end-b FROM t1 WHERE +~+13>=t1.c}
+} {}
+do_test randexpr-2.1869 {
+ db eval {SELECT case when b | case when 13 between ~coalesce((select 19 from t1 where b in (select max(a*17) from t1 union select cast(avg( -19) AS integer)+abs(cast(avg(a) AS integer)) from t1)),17) and 11 then a when not exists(select 1 from t1 where not exists(select 1 from t1 where 19<=e)) and d in (select 17 from t1 union select 17 from t1) then -b else a end-a in (select max(t1.c) from t1 union select min(e) | count(*)+count(*) from t1) then t1.b when not (not 19<=t1.b) then 13 else a end-b FROM t1 WHERE NOT (+~+13>=t1.c)}
+} {-187}
+do_test randexpr-2.1870 {
+ db eval {SELECT case when b & case when 13 between ~coalesce((select 19 from t1 where b in (select max(a*17) from t1 union select cast(avg( -19) AS integer)+abs(cast(avg(a) AS integer)) from t1)),17) and 11 then a when not exists(select 1 from t1 where not exists(select 1 from t1 where 19<=e)) and d in (select 17 from t1 union select 17 from t1) then -b else a end-a in (select max(t1.c) from t1 union select min(e) & count(*)+count(*) from t1) then t1.b when not (not 19<=t1.b) then 13 else a end-b FROM t1 WHERE NOT (+~+13>=t1.c)}
+} {0}
+do_test randexpr-2.1871 {
+ db eval {SELECT coalesce((select case when t1.d in (select min(f) from t1 union select ~ -count(*) from t1) then d else 13 end from t1 where 19<=case when 13>=+17-c+(select count(*)-min(11) from t1)+t1.f*t1.e*c*t1.d then c else t1.b end),t1.c | +t1.e) FROM t1 WHERE a between (abs(coalesce((select max(case when (t1.d+a*coalesce((select d-13 from t1 where a<=19),t1.f))>= -c then c else 13 end) from t1 where f>=d or t1.a>t1.d),t1.a))/abs(t1.f)) and 19 and 13=t1.e and not exists(select 1 from t1 where 13 in (select -( -count(distinct (a))) | -cast(avg(t1.c) AS integer) from t1 union select (min(t1.c)) from t1) or t1.f not between t1.c and t1.c)}
+} {}
+do_test randexpr-2.1872 {
+ db eval {SELECT coalesce((select case when t1.d in (select min(f) from t1 union select ~ -count(*) from t1) then d else 13 end from t1 where 19<=case when 13>=+17-c+(select count(*)-min(11) from t1)+t1.f*t1.e*c*t1.d then c else t1.b end),t1.c | +t1.e) FROM t1 WHERE NOT (a between (abs(coalesce((select max(case when (t1.d+a*coalesce((select d-13 from t1 where a<=19),t1.f))>= -c then c else 13 end) from t1 where f>=d or t1.a>t1.d),t1.a))/abs(t1.f)) and 19 and 13=t1.e and not exists(select 1 from t1 where 13 in (select -( -count(distinct (a))) | -cast(avg(t1.c) AS integer) from t1 union select (min(t1.c)) from t1) or t1.f not between t1.c and t1.c))}
+} {13}
+do_test randexpr-2.1873 {
+ db eval {SELECT coalesce((select case when t1.d in (select min(f) from t1 union select ~ -count(*) from t1) then d else 13 end from t1 where 19<=case when 13>=+17-c+(select count(*)-min(11) from t1)+t1.f*t1.e*c*t1.d then c else t1.b end),t1.c & +t1.e) FROM t1 WHERE NOT (a between (abs(coalesce((select max(case when (t1.d+a*coalesce((select d-13 from t1 where a<=19),t1.f))>= -c then c else 13 end) from t1 where f>=d or t1.a>t1.d),t1.a))/abs(t1.f)) and 19 and 13=t1.e and not exists(select 1 from t1 where 13 in (select -( -count(distinct (a))) | -cast(avg(t1.c) AS integer) from t1 union select (min(t1.c)) from t1) or t1.f not between t1.c and t1.c))}
+} {13}
+do_test randexpr-2.1874 {
+ db eval {SELECT coalesce((select max(f) from t1 where coalesce((select max(+(select cast(avg(t1.d) AS integer) from t1)*19) from t1 where (abs(t1.d*t1.c)/abs(f))+t1.e> -t1.d*t1.e-a),13-case +coalesce((select max(t1.c) from t1 where d<=d and - -t1.a<=(t1.f) or f<>19 and 17<19),(t1.c)) | c*t1.f*b when t1.a then 19 else (b) end)>=a),t1.f) FROM t1 WHERE (~c-13*case when case when a+19-c in (select case count(distinct c)-case cast(avg(t1.a) AS integer) when max( -b) then cast(avg(t1.f) AS integer) else cast(avg((t1.d)) AS integer) end when min(b) then cast(avg(b) AS integer) else count(*) end from t1 union select max(t1.f) from t1) and 17 between (t1.b) and c and 19>t1.d or 19 in (t1.f,t1.a,(b)) then a else t1.e end in (13,t1.a,b) then 17 else t1.e end*t1.d+a+t1.b+t1.f)<t1.d}
+} {600}
+do_test randexpr-2.1875 {
+ db eval {SELECT coalesce((select max(f) from t1 where coalesce((select max(+(select cast(avg(t1.d) AS integer) from t1)*19) from t1 where (abs(t1.d*t1.c)/abs(f))+t1.e> -t1.d*t1.e-a),13-case +coalesce((select max(t1.c) from t1 where d<=d and - -t1.a<=(t1.f) or f<>19 and 17<19),(t1.c)) | c*t1.f*b when t1.a then 19 else (b) end)>=a),t1.f) FROM t1 WHERE NOT ((~c-13*case when case when a+19-c in (select case count(distinct c)-case cast(avg(t1.a) AS integer) when max( -b) then cast(avg(t1.f) AS integer) else cast(avg((t1.d)) AS integer) end when min(b) then cast(avg(b) AS integer) else count(*) end from t1 union select max(t1.f) from t1) and 17 between (t1.b) and c and 19>t1.d or 19 in (t1.f,t1.a,(b)) then a else t1.e end in (13,t1.a,b) then 17 else t1.e end*t1.d+a+t1.b+t1.f)<t1.d)}
+} {}
+do_test randexpr-2.1876 {
+ db eval {SELECT coalesce((select max(f) from t1 where coalesce((select max(+(select cast(avg(t1.d) AS integer) from t1)*19) from t1 where (abs(t1.d*t1.c)/abs(f))+t1.e> -t1.d*t1.e-a),13-case +coalesce((select max(t1.c) from t1 where d<=d and - -t1.a<=(t1.f) or f<>19 and 17<19),(t1.c)) & c*t1.f*b when t1.a then 19 else (b) end)>=a),t1.f) FROM t1 WHERE (~c-13*case when case when a+19-c in (select case count(distinct c)-case cast(avg(t1.a) AS integer) when max( -b) then cast(avg(t1.f) AS integer) else cast(avg((t1.d)) AS integer) end when min(b) then cast(avg(b) AS integer) else count(*) end from t1 union select max(t1.f) from t1) and 17 between (t1.b) and c and 19>t1.d or 19 in (t1.f,t1.a,(b)) then a else t1.e end in (13,t1.a,b) then 17 else t1.e end*t1.d+a+t1.b+t1.f)<t1.d}
+} {600}
+do_test randexpr-2.1877 {
+ db eval {SELECT a | t1.c-case t1.b when case when f< -(c*case when f<13 then t1.e | 13-coalesce((select max( -13+13+t1.a) from t1 where not exists(select 1 from t1 where 17=11)),19) else a end+t1.e*t1.d)+11+(13) then t1.f when not t1.f> -b then a else f end then t1.e else f end FROM t1 WHERE t1.f-~coalesce((select 17 from t1 where (e+ -case when (d<coalesce((select max(a) from t1 where a | a<t1.a and t1.c<=17 or t1.d not between a and b),13)) then 17*t1.d else t1.f end in (select ~~~cast(avg(f) AS integer)*max(t1.c)-count(distinct t1.e)-( -min(t1.f))+( -count(*)) from t1 union select max(a) from t1))),13)*t1.c-t1.d not between 17 and d}
+} {-268}
+do_test randexpr-2.1878 {
+ db eval {SELECT a | t1.c-case t1.b when case when f< -(c*case when f<13 then t1.e | 13-coalesce((select max( -13+13+t1.a) from t1 where not exists(select 1 from t1 where 17=11)),19) else a end+t1.e*t1.d)+11+(13) then t1.f when not t1.f> -b then a else f end then t1.e else f end FROM t1 WHERE NOT (t1.f-~coalesce((select 17 from t1 where (e+ -case when (d<coalesce((select max(a) from t1 where a | a<t1.a and t1.c<=17 or t1.d not between a and b),13)) then 17*t1.d else t1.f end in (select ~~~cast(avg(f) AS integer)*max(t1.c)-count(distinct t1.e)-( -min(t1.f))+( -count(*)) from t1 union select max(a) from t1))),13)*t1.c-t1.d not between 17 and d)}
+} {}
+do_test randexpr-2.1879 {
+ db eval {SELECT a & t1.c-case t1.b when case when f< -(c*case when f<13 then t1.e & 13-coalesce((select max( -13+13+t1.a) from t1 where not exists(select 1 from t1 where 17=11)),19) else a end+t1.e*t1.d)+11+(13) then t1.f when not t1.f> -b then a else f end then t1.e else f end FROM t1 WHERE t1.f-~coalesce((select 17 from t1 where (e+ -case when (d<coalesce((select max(a) from t1 where a | a<t1.a and t1.c<=17 or t1.d not between a and b),13)) then 17*t1.d else t1.f end in (select ~~~cast(avg(f) AS integer)*max(t1.c)-count(distinct t1.e)-( -min(t1.f))+( -count(*)) from t1 union select max(a) from t1))),13)*t1.c-t1.d not between 17 and d}
+} {68}
+do_test randexpr-2.1880 {
+ db eval {SELECT -(17-case (select max(a)+min( -(abs(t1.c-t1.a | t1.e- -t1.b+19*t1.c)/abs(c)))+ -case min(a) when count(distinct -a) then count(distinct 19) else count(*) end-count(distinct t1.e)*(max(t1.a))-(count(distinct 19)) from t1) when (select count(*) from t1) then b else t1.d end*11)-11* -c FROM t1 WHERE f between (case case when +(f) in (select t1.f from t1 union select case when t1.b in ((abs(19)/abs(11)),f,c) and (d) in (select -count(distinct b)*count(*) from t1 union select count(distinct -13) from t1) or (t1.e>19) then case when f in (11,11,d) then t1.e when t1.a<=19 then a else e end else -t1.e end from t1) then e when t1.c=t1.b then 19 else e end when f then 19 else c end) | d-c and a}
+} {}
+do_test randexpr-2.1881 {
+ db eval {SELECT -(17-case (select max(a)+min( -(abs(t1.c-t1.a | t1.e- -t1.b+19*t1.c)/abs(c)))+ -case min(a) when count(distinct -a) then count(distinct 19) else count(*) end-count(distinct t1.e)*(max(t1.a))-(count(distinct 19)) from t1) when (select count(*) from t1) then b else t1.d end*11)-11* -c FROM t1 WHERE NOT (f between (case case when +(f) in (select t1.f from t1 union select case when t1.b in ((abs(19)/abs(11)),f,c) and (d) in (select -count(distinct b)*count(*) from t1 union select count(distinct -13) from t1) or (t1.e>19) then case when f in (11,11,d) then t1.e when t1.a<=19 then a else e end else -t1.e end from t1) then e when t1.c=t1.b then 19 else e end when f then 19 else c end) | d-c and a)}
+} {7683}
+do_test randexpr-2.1882 {
+ db eval {SELECT -(17-case (select max(a)+min( -(abs(t1.c-t1.a & t1.e- -t1.b+19*t1.c)/abs(c)))+ -case min(a) when count(distinct -a) then count(distinct 19) else count(*) end-count(distinct t1.e)*(max(t1.a))-(count(distinct 19)) from t1) when (select count(*) from t1) then b else t1.d end*11)-11* -c FROM t1 WHERE NOT (f between (case case when +(f) in (select t1.f from t1 union select case when t1.b in ((abs(19)/abs(11)),f,c) and (d) in (select -count(distinct b)*count(*) from t1 union select count(distinct -13) from t1) or (t1.e>19) then case when f in (11,11,d) then t1.e when t1.a<=19 then a else e end else -t1.e end from t1) then e when t1.c=t1.b then 19 else e end when f then 19 else c end) | d-c and a)}
+} {7683}
+do_test randexpr-2.1883 {
+ db eval {SELECT (case coalesce((select +a from t1 where exists(select 1 from t1 where t1.e not between t1.f-b and (select count(*) from t1)-t1.f | e)),t1.d+case when t1.b not between t1.d and 17+case when a in (t1.d,a,(abs(~case when (t1.f)<=t1.c then -17 else t1.f end)/abs(19))*d*t1.d) then (b) else a end then 11 else f end+(t1.a)) when f then 17 else t1.e end) FROM t1 WHERE a-e*case t1.d+case c when (abs(~t1.d*(select min(case when not exists(select 1 from t1 where ((d)+(19) between 11 and 19)) then 11+13 when e not in (t1.f,17,e) and t1.c<>a then t1.e else 19 end*t1.a-f) from t1))/abs(b)) then 13 else 17 end when t1.f then (f) else t1.c end<b and 19 between t1.a and t1.a or d<f}
+} {500}
+do_test randexpr-2.1884 {
+ db eval {SELECT (case coalesce((select +a from t1 where exists(select 1 from t1 where t1.e not between t1.f-b and (select count(*) from t1)-t1.f | e)),t1.d+case when t1.b not between t1.d and 17+case when a in (t1.d,a,(abs(~case when (t1.f)<=t1.c then -17 else t1.f end)/abs(19))*d*t1.d) then (b) else a end then 11 else f end+(t1.a)) when f then 17 else t1.e end) FROM t1 WHERE NOT (a-e*case t1.d+case c when (abs(~t1.d*(select min(case when not exists(select 1 from t1 where ((d)+(19) between 11 and 19)) then 11+13 when e not in (t1.f,17,e) and t1.c<>a then t1.e else 19 end*t1.a-f) from t1))/abs(b)) then 13 else 17 end when t1.f then (f) else t1.c end<b and 19 between t1.a and t1.a or d<f)}
+} {}
+do_test randexpr-2.1885 {
+ db eval {SELECT (case coalesce((select +a from t1 where exists(select 1 from t1 where t1.e not between t1.f-b and (select count(*) from t1)-t1.f & e)),t1.d+case when t1.b not between t1.d and 17+case when a in (t1.d,a,(abs(~case when (t1.f)<=t1.c then -17 else t1.f end)/abs(19))*d*t1.d) then (b) else a end then 11 else f end+(t1.a)) when f then 17 else t1.e end) FROM t1 WHERE a-e*case t1.d+case c when (abs(~t1.d*(select min(case when not exists(select 1 from t1 where ((d)+(19) between 11 and 19)) then 11+13 when e not in (t1.f,17,e) and t1.c<>a then t1.e else 19 end*t1.a-f) from t1))/abs(b)) then 13 else 17 end when t1.f then (f) else t1.c end<b and 19 between t1.a and t1.a or d<f}
+} {500}
+do_test randexpr-2.1886 {
+ db eval {SELECT -19 | t1.c*coalesce((select max(+(select cast(avg(case when -e+t1.d in (select t1.e*a from t1 union select a from t1) then t1.b when 17 in (select t1.a from t1 union select 11 from t1) then 19 else 11 end-19+a+t1.f) AS integer)+count(distinct t1.a) from t1)+(t1.b)) from t1 where (19) not in (17,d,a)),t1.a)*t1.b*19* -11 FROM t1 WHERE case t1.e when f then (select ~count(distinct a) | abs((count(distinct d*f+d+t1.b+17+~t1.f))) from t1) else coalesce((select e from t1 where t1.f not between 17+t1.f+19 and (abs(f)/abs(t1.f))*~t1.b*(b)),coalesce((select t1.b from t1 where 19 in (select count(distinct (t1.d)) from t1 union select -count(distinct a) from t1)),19)) | 17 end not between t1.c and t1.c}
+} {-19}
+do_test randexpr-2.1887 {
+ db eval {SELECT -19 | t1.c*coalesce((select max(+(select cast(avg(case when -e+t1.d in (select t1.e*a from t1 union select a from t1) then t1.b when 17 in (select t1.a from t1 union select 11 from t1) then 19 else 11 end-19+a+t1.f) AS integer)+count(distinct t1.a) from t1)+(t1.b)) from t1 where (19) not in (17,d,a)),t1.a)*t1.b*19* -11 FROM t1 WHERE NOT (case t1.e when f then (select ~count(distinct a) | abs((count(distinct d*f+d+t1.b+17+~t1.f))) from t1) else coalesce((select e from t1 where t1.f not between 17+t1.f+19 and (abs(f)/abs(t1.f))*~t1.b*(b)),coalesce((select t1.b from t1 where 19 in (select count(distinct (t1.d)) from t1 union select -count(distinct a) from t1)),19)) | 17 end not between t1.c and t1.c)}
+} {}
+do_test randexpr-2.1888 {
+ db eval {SELECT -19 & t1.c*coalesce((select max(+(select cast(avg(case when -e+t1.d in (select t1.e*a from t1 union select a from t1) then t1.b when 17 in (select t1.a from t1 union select 11 from t1) then 19 else 11 end-19+a+t1.f) AS integer)+count(distinct t1.a) from t1)+(t1.b)) from t1 where (19) not in (17,d,a)),t1.a)*t1.b*19* -11 FROM t1 WHERE case t1.e when f then (select ~count(distinct a) | abs((count(distinct d*f+d+t1.b+17+~t1.f))) from t1) else coalesce((select e from t1 where t1.f not between 17+t1.f+19 and (abs(f)/abs(t1.f))*~t1.b*(b)),coalesce((select t1.b from t1 where 19 in (select count(distinct (t1.d)) from t1 union select -count(distinct a) from t1)),19)) | 17 end not between t1.c and t1.c}
+} {-11198220000}
+do_test randexpr-2.1889 {
+ db eval {SELECT (abs(b)/abs((select max(c) from t1)))+case when (select +cast(avg(17 | ~coalesce((select e from t1 where t1.b>(13) | -11 and c>f),19)+t1.c) AS integer)-(~case cast(avg(t1.f) AS integer)*abs(max(b)+(count(*))+count(distinct b)) when min(c) then cast(avg(t1.b) AS integer) else count(*) end) from t1) in (select t1.e from t1 union select t1.c from t1) then f when d<t1.e then t1.e else 19 end FROM t1 WHERE not ( -a*(select case min(coalesce((select max(a) from t1 where case when 11 between t1.c and d then c when t1.c not in (t1.a,e,t1.c) then d else 13 end*d>=(c)),b)) when max(d) then ( -max(c))+((min(11)))+max(t1.c) else max(t1.a) end from t1)-e+t1.b-(b)-11-t1.d*t1.c<>t1.c)}
+} {}
+do_test randexpr-2.1890 {
+ db eval {SELECT (abs(b)/abs((select max(c) from t1)))+case when (select +cast(avg(17 | ~coalesce((select e from t1 where t1.b>(13) | -11 and c>f),19)+t1.c) AS integer)-(~case cast(avg(t1.f) AS integer)*abs(max(b)+(count(*))+count(distinct b)) when min(c) then cast(avg(t1.b) AS integer) else count(*) end) from t1) in (select t1.e from t1 union select t1.c from t1) then f when d<t1.e then t1.e else 19 end FROM t1 WHERE NOT (not ( -a*(select case min(coalesce((select max(a) from t1 where case when 11 between t1.c and d then c when t1.c not in (t1.a,e,t1.c) then d else 13 end*d>=(c)),b)) when max(d) then ( -max(c))+((min(11)))+max(t1.c) else max(t1.a) end from t1)-e+t1.b-(b)-11-t1.d*t1.c<>t1.c))}
+} {500}
+do_test randexpr-2.1891 {
+ db eval {SELECT (abs(b)/abs((select max(c) from t1)))+case when (select +cast(avg(17 & ~coalesce((select e from t1 where t1.b>(13) & -11 and c>f),19)+t1.c) AS integer)-(~case cast(avg(t1.f) AS integer)*abs(max(b)+(count(*))+count(distinct b)) when min(c) then cast(avg(t1.b) AS integer) else count(*) end) from t1) in (select t1.e from t1 union select t1.c from t1) then f when d<t1.e then t1.e else 19 end FROM t1 WHERE NOT (not ( -a*(select case min(coalesce((select max(a) from t1 where case when 11 between t1.c and d then c when t1.c not in (t1.a,e,t1.c) then d else 13 end*d>=(c)),b)) when max(d) then ( -max(c))+((min(11)))+max(t1.c) else max(t1.a) end from t1)-e+t1.b-(b)-11-t1.d*t1.c<>t1.c))}
+} {500}
+do_test randexpr-2.1892 {
+ db eval {SELECT coalesce((select max(case 13 when +coalesce((select max(c) from t1 where t1.a+f in (t1.b,t1.b,(abs(19)/abs(+17+~(abs(t1.a+f)/abs(~t1.c))+case when not exists(select 1 from t1 where coalesce((select max(e) from t1 where (b)> -t1.a),c)=t1.b) then 19 else b end))-f)),t1.a)+a then f else 17 end*t1.e) from t1 where 13<>t1.f),t1.f) FROM t1 WHERE not exists(select 1 from t1 where coalesce((select max(case when 13 not in (t1.b,b,t1.c) then t1.c | t1.a else 13-19+a+t1.e-t1.e end+t1.a*17+( -d)-17 | t1.c-t1.a | 19+b) from t1 where not a=e),11) in (select 17 from t1 union select c from t1) or t1.c>=t1.e)}
+} {8500}
+do_test randexpr-2.1893 {
+ db eval {SELECT coalesce((select max(case 13 when +coalesce((select max(c) from t1 where t1.a+f in (t1.b,t1.b,(abs(19)/abs(+17+~(abs(t1.a+f)/abs(~t1.c))+case when not exists(select 1 from t1 where coalesce((select max(e) from t1 where (b)> -t1.a),c)=t1.b) then 19 else b end))-f)),t1.a)+a then f else 17 end*t1.e) from t1 where 13<>t1.f),t1.f) FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select max(case when 13 not in (t1.b,b,t1.c) then t1.c | t1.a else 13-19+a+t1.e-t1.e end+t1.a*17+( -d)-17 | t1.c-t1.a | 19+b) from t1 where not a=e),11) in (select 17 from t1 union select c from t1) or t1.c>=t1.e))}
+} {}
+do_test randexpr-2.1894 {
+ db eval {SELECT t1.f++c*coalesce((select +t1.f from t1 where a<~13),case when exists(select 1 from t1 where not exists(select 1 from t1 where 17 in (select 11 from t1 union select (17) from t1))) then b else + -19 | coalesce((select case when (select cast(avg(a) AS integer) from t1)>e then case when (11=(e) and 17<f) then (e)+ -c else e end else c end from t1 where 13 not in (f,t1.b,e)),t1.d) end*t1.c) FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where t1.e=+(abs((coalesce((select max( -a | case when coalesce((select c from t1 where not 17 not between t1.e and t1.b),e)-(a) not between t1.e and t1.b then f when c>=t1.a then -c else 19 end-f) from t1 where not exists(select 1 from t1 where d in (select -~count(distinct 11)+max(t1.a) from t1 union select count(distinct e)* -count(distinct t1.b) from t1)) or (c<t1.c)),t1.f)))/abs(t1.c))))}
+} {-1709400}
+do_test randexpr-2.1895 {
+ db eval {SELECT t1.f++c*coalesce((select +t1.f from t1 where a<~13),case when exists(select 1 from t1 where not exists(select 1 from t1 where 17 in (select 11 from t1 union select (17) from t1))) then b else + -19 | coalesce((select case when (select cast(avg(a) AS integer) from t1)>e then case when (11=(e) and 17<f) then (e)+ -c else e end else c end from t1 where 13 not in (f,t1.b,e)),t1.d) end*t1.c) FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where t1.e=+(abs((coalesce((select max( -a | case when coalesce((select c from t1 where not 17 not between t1.e and t1.b),e)-(a) not between t1.e and t1.b then f when c>=t1.a then -c else 19 end-f) from t1 where not exists(select 1 from t1 where d in (select -~count(distinct 11)+max(t1.a) from t1 union select count(distinct e)* -count(distinct t1.b) from t1)) or (c<t1.c)),t1.f)))/abs(t1.c)))))}
+} {}
+do_test randexpr-2.1896 {
+ db eval {SELECT t1.f++c*coalesce((select +t1.f from t1 where a<~13),case when exists(select 1 from t1 where not exists(select 1 from t1 where 17 in (select 11 from t1 union select (17) from t1))) then b else + -19 & coalesce((select case when (select cast(avg(a) AS integer) from t1)>e then case when (11=(e) and 17<f) then (e)+ -c else e end else c end from t1 where 13 not in (f,t1.b,e)),t1.d) end*t1.c) FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where t1.e=+(abs((coalesce((select max( -a | case when coalesce((select c from t1 where not 17 not between t1.e and t1.b),e)-(a) not between t1.e and t1.b then f when c>=t1.a then -c else 19 end-f) from t1 where not exists(select 1 from t1 where d in (select -~count(distinct 11)+max(t1.a) from t1 union select count(distinct e)* -count(distinct t1.b) from t1)) or (c<t1.c)),t1.f)))/abs(t1.c))))}
+} {27000600}
+do_test randexpr-2.1897 {
+ db eval {SELECT (select + -min(case when case when exists(select 1 from t1 where a<=c or coalesce((select max(11) from t1 where d=17),19)*11<=f and t1.e in (select t1.c from t1 union select a from t1)) then (f)-d when a<t1.a then t1.b else a end in (select ~( -min(f)) from t1 union select case -max(t1.d)-count(distinct t1.c) when min(f) then cast(avg( -e) AS integer) else ( -count(distinct 17)) end from t1) then d when t1.f>=t1.c then f else t1.f end-f) from t1) FROM t1 WHERE (~ -t1.c in (select d from t1 union select t1.c*case when (17 in (+case c when t1.f then t1.c else c+e+t1.c*e+coalesce((select max((c)) from t1 where (t1.e)>a),19)-t1.e end | e-t1.b,t1.d,c)) then d when t1.e in (select (max( -e)-~~count(*)) from t1 union select count(*) from t1) then d else t1.f end from t1))}
+} {}
+do_test randexpr-2.1898 {
+ db eval {SELECT (select + -min(case when case when exists(select 1 from t1 where a<=c or coalesce((select max(11) from t1 where d=17),19)*11<=f and t1.e in (select t1.c from t1 union select a from t1)) then (f)-d when a<t1.a then t1.b else a end in (select ~( -min(f)) from t1 union select case -max(t1.d)-count(distinct t1.c) when min(f) then cast(avg( -e) AS integer) else ( -count(distinct 17)) end from t1) then d when t1.f>=t1.c then f else t1.f end-f) from t1) FROM t1 WHERE NOT ((~ -t1.c in (select d from t1 union select t1.c*case when (17 in (+case c when t1.f then t1.c else c+e+t1.c*e+coalesce((select max((c)) from t1 where (t1.e)>a),19)-t1.e end | e-t1.b,t1.d,c)) then d when t1.e in (select (max( -e)-~~count(*)) from t1 union select count(*) from t1) then d else t1.f end from t1)))}
+} {0}
+do_test randexpr-2.1899 {
+ db eval {SELECT ~+t1.f-coalesce((select t1.f from t1 where case when t1.d>=t1.f then b else case c when 11 then t1.f*case when (select (count(*)) from t1)<>a+t1.b | +11-coalesce((select max(t1.f-a) from t1 where (f<=t1.c and t1.d=c)),d)-11 then b when (t1.c)<=t1.b then 19 else 11 end else c end end*19-13< - -b),e) FROM t1 WHERE (exists(select 1 from t1 where -t1.f not between ~17 and t1.a+(b+d+13)))}
+} {-1101}
+do_test randexpr-2.1900 {
+ db eval {SELECT ~+t1.f-coalesce((select t1.f from t1 where case when t1.d>=t1.f then b else case c when 11 then t1.f*case when (select (count(*)) from t1)<>a+t1.b | +11-coalesce((select max(t1.f-a) from t1 where (f<=t1.c and t1.d=c)),d)-11 then b when (t1.c)<=t1.b then 19 else 11 end else c end end*19-13< - -b),e) FROM t1 WHERE NOT ((exists(select 1 from t1 where -t1.f not between ~17 and t1.a+(b+d+13))))}
+} {}
+do_test randexpr-2.1901 {
+ db eval {SELECT ~+t1.f-coalesce((select t1.f from t1 where case when t1.d>=t1.f then b else case c when 11 then t1.f*case when (select (count(*)) from t1)<>a+t1.b & +11-coalesce((select max(t1.f-a) from t1 where (f<=t1.c and t1.d=c)),d)-11 then b when (t1.c)<=t1.b then 19 else 11 end else c end end*19-13< - -b),e) FROM t1 WHERE (exists(select 1 from t1 where -t1.f not between ~17 and t1.a+(b+d+13)))}
+} {-1101}
+do_test randexpr-2.1902 {
+ db eval {SELECT -t1.e+coalesce((select (d) from t1 where t1.f=t1.f*(select +count(distinct case when (coalesce((select max(case when a in (select b+17 from t1 union select -17 from t1) then 19 when 17<c then t1.b else c end | t1.e) from t1 where exists(select 1 from t1 where -e in (t1.b,t1.d,c) and f not between t1.f and b) and 17<>a),e)<>f or d not between (e) and b) then 11 else (abs(13)/abs( -(d))) end*t1.c) from t1)),e-f) FROM t1 WHERE ((case when t1.e+d*~coalesce((select coalesce((select max(b) from t1 where ~case when t1.f not between t1.c and coalesce((select t1.b from t1 where -t1.e in (select (( - -min(19))) from t1 union select count(distinct t1.d) from t1)),t1.d) then c when t1.f=e then t1.f else b end=13),13) from t1 where t1.e not between 13 and 11 or not exists(select 1 from t1 where t1.a not between (11) and d and 11>=a)),t1.f) in (select count(*) from t1 union select ~max( -13) from t1) then -13 else 17 end) | d in (a,d,13))}
+} {}
+do_test randexpr-2.1903 {
+ db eval {SELECT -t1.e+coalesce((select (d) from t1 where t1.f=t1.f*(select +count(distinct case when (coalesce((select max(case when a in (select b+17 from t1 union select -17 from t1) then 19 when 17<c then t1.b else c end | t1.e) from t1 where exists(select 1 from t1 where -e in (t1.b,t1.d,c) and f not between t1.f and b) and 17<>a),e)<>f or d not between (e) and b) then 11 else (abs(13)/abs( -(d))) end*t1.c) from t1)),e-f) FROM t1 WHERE NOT (((case when t1.e+d*~coalesce((select coalesce((select max(b) from t1 where ~case when t1.f not between t1.c and coalesce((select t1.b from t1 where -t1.e in (select (( - -min(19))) from t1 union select count(distinct t1.d) from t1)),t1.d) then c when t1.f=e then t1.f else b end=13),13) from t1 where t1.e not between 13 and 11 or not exists(select 1 from t1 where t1.a not between (11) and d and 11>=a)),t1.f) in (select count(*) from t1 union select ~max( -13) from t1) then -13 else 17 end) | d in (a,d,13)))}
+} {-100}
+do_test randexpr-2.1904 {
+ db eval {SELECT -t1.e+coalesce((select (d) from t1 where t1.f=t1.f*(select +count(distinct case when (coalesce((select max(case when a in (select b+17 from t1 union select -17 from t1) then 19 when 17<c then t1.b else c end & t1.e) from t1 where exists(select 1 from t1 where -e in (t1.b,t1.d,c) and f not between t1.f and b) and 17<>a),e)<>f or d not between (e) and b) then 11 else (abs(13)/abs( -(d))) end*t1.c) from t1)),e-f) FROM t1 WHERE NOT (((case when t1.e+d*~coalesce((select coalesce((select max(b) from t1 where ~case when t1.f not between t1.c and coalesce((select t1.b from t1 where -t1.e in (select (( - -min(19))) from t1 union select count(distinct t1.d) from t1)),t1.d) then c when t1.f=e then t1.f else b end=13),13) from t1 where t1.e not between 13 and 11 or not exists(select 1 from t1 where t1.a not between (11) and d and 11>=a)),t1.f) in (select count(*) from t1 union select ~max( -13) from t1) then -13 else 17 end) | d in (a,d,13)))}
+} {-100}
+do_test randexpr-2.1905 {
+ db eval {SELECT coalesce((select max((19)) from t1 where d* -a<=(select count(*) from t1)+19*19*a-e-d or b in (t1.c+ -t1.b,t1.a,b+t1.b)),d) FROM t1 WHERE exists(select 1 from t1 where exists(select 1 from t1 where not t1.e>e))}
+} {19}
+do_test randexpr-2.1906 {
+ db eval {SELECT coalesce((select max((19)) from t1 where d* -a<=(select count(*) from t1)+19*19*a-e-d or b in (t1.c+ -t1.b,t1.a,b+t1.b)),d) FROM t1 WHERE NOT (exists(select 1 from t1 where exists(select 1 from t1 where not t1.e>e)))}
+} {}
+do_test randexpr-2.1907 {
+ db eval {SELECT (select -~count(distinct (abs(11)/abs(f-17-+(select cast(avg(+(select count(*) from t1)) AS integer) from t1)))) from t1) FROM t1 WHERE (abs((a))/abs(t1.b))>(select count(distinct case case when 17 in (select -b-case when 17 in (select +(( - -max(t1.b))) from t1 union select max((t1.b)) from t1) then f when t1.e=(t1.d) then 17 else e end | e-t1.d | t1.c* -13*d*t1.b from t1 union select 11 from t1) then c when c>=a then 13 else 13 end+t1.b when -f then 19 else 13 end)*min(t1.f) from t1)-19-f}
+} {2}
+do_test randexpr-2.1908 {
+ db eval {SELECT (select -~count(distinct (abs(11)/abs(f-17-+(select cast(avg(+(select count(*) from t1)) AS integer) from t1)))) from t1) FROM t1 WHERE NOT ((abs((a))/abs(t1.b))>(select count(distinct case case when 17 in (select -b-case when 17 in (select +(( - -max(t1.b))) from t1 union select max((t1.b)) from t1) then f when t1.e=(t1.d) then 17 else e end | e-t1.d | t1.c* -13*d*t1.b from t1 union select 11 from t1) then c when c>=a then 13 else 13 end+t1.b when -f then 19 else 13 end)*min(t1.f) from t1)-19-f)}
+} {}
+do_test randexpr-2.1909 {
+ db eval {SELECT -(select cast(avg(coalesce((select max(f) from t1 where -case coalesce((select max(~c-case when exists(select 1 from t1 where -b in (~e,t1.e,t1.e)) then t1.e when (17 in (select ++ -(count(distinct t1.a)) from t1 union select (max( -f)) from t1)) then b else t1.f end) from t1 where (13 in (19,b,11))),t1.e) when c then (b) else 11 end-a*b*13=t1.e),13)) AS integer) from t1) FROM t1 WHERE exists(select 1 from t1 where case when not (case when ~17*d>=b then a when c*(abs((abs(f)/abs(t1.c)))/abs(t1.b))+d*t1.b<19 and not case 13 when a then 11 else -t1.e end<>f then 11 else c end+t1.d) not in (t1.c,t1.f,d) then (abs(c)/abs(t1.f)) else t1.a end*t1.f not between t1.d and c)}
+} {-13}
+do_test randexpr-2.1910 {
+ db eval {SELECT -(select cast(avg(coalesce((select max(f) from t1 where -case coalesce((select max(~c-case when exists(select 1 from t1 where -b in (~e,t1.e,t1.e)) then t1.e when (17 in (select ++ -(count(distinct t1.a)) from t1 union select (max( -f)) from t1)) then b else t1.f end) from t1 where (13 in (19,b,11))),t1.e) when c then (b) else 11 end-a*b*13=t1.e),13)) AS integer) from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where case when not (case when ~17*d>=b then a when c*(abs((abs(f)/abs(t1.c)))/abs(t1.b))+d*t1.b<19 and not case 13 when a then 11 else -t1.e end<>f then 11 else c end+t1.d) not in (t1.c,t1.f,d) then (abs(c)/abs(t1.f)) else t1.a end*t1.f not between t1.d and c))}
+} {}
+do_test randexpr-2.1911 {
+ db eval {SELECT case t1.c when (select abs( -max(t1.a*t1.f*t1.a*e)) from t1)*case when not exists(select 1 from t1 where (select cast(avg(c) AS integer) from t1) in (select case case when ( -case t1.f when 17 then t1.c else e end=17) then 19 else e end when e then c else -a end*t1.d from t1 union select d from t1)) then e*t1.a else b end+e*t1.d+t1.b then t1.d else c end+t1.e FROM t1 WHERE 13 in (select +abs(case count(distinct t1.e+(abs((abs(coalesce((select t1.b from t1 where coalesce((select max(case when (19<=t1.d) then (13) when a>=13 then 13 else t1.f end) from t1 where a in (t1.c,19,t1.b)),19)>13),d))/abs(f))+t1.a*t1.b)/abs(e))) when +cast(avg(c) AS integer) then ~~+max(f) | cast(avg(t1.c) AS integer) else count(distinct 13)+min(t1.b) | count(*) end)*max(t1.d)-count(*) from t1 union select count(*) from t1)}
+} {}
+do_test randexpr-2.1912 {
+ db eval {SELECT case t1.c when (select abs( -max(t1.a*t1.f*t1.a*e)) from t1)*case when not exists(select 1 from t1 where (select cast(avg(c) AS integer) from t1) in (select case case when ( -case t1.f when 17 then t1.c else e end=17) then 19 else e end when e then c else -a end*t1.d from t1 union select d from t1)) then e*t1.a else b end+e*t1.d+t1.b then t1.d else c end+t1.e FROM t1 WHERE NOT (13 in (select +abs(case count(distinct t1.e+(abs((abs(coalesce((select t1.b from t1 where coalesce((select max(case when (19<=t1.d) then (13) when a>=13 then 13 else t1.f end) from t1 where a in (t1.c,19,t1.b)),19)>13),d))/abs(f))+t1.a*t1.b)/abs(e))) when +cast(avg(c) AS integer) then ~~+max(f) | cast(avg(t1.c) AS integer) else count(distinct 13)+min(t1.b) | count(*) end)*max(t1.d)-count(*) from t1 union select count(*) from t1))}
+} {800}
+do_test randexpr-2.1913 {
+ db eval {SELECT case when f in (d, -case when (case 11 when (select max(t1.d) from t1) then (abs(a)/abs(+t1.b)) else ~b end<19) then (abs( -(abs(17)/abs(t1.f)))/abs((select count(*) from t1))) when (f) not between coalesce((select 13 from t1 where t1.a<=case t1.a when 13 then -t1.c else 13 end and 13 not between t1.f and 11),11) and 19 then e else b end,t1.d) then b else t1.b end FROM t1 WHERE t1.f between f and a-c-t1.d-t1.d+t1.d*case when exists(select 1 from t1 where d between (select ~cast(avg(17) AS integer) from t1) and a) then case when case b when f then 13 else b end<c then t1.d when (t1.a) in (select -( -b) from t1 union select -t1.f from t1) and f not in (t1.b,t1.d,t1.a) then -d else (13) end when d in (c,((t1.d)),c) then b else 19 end and exists(select 1 from t1 where not t1.a=17)}
+} {200}
+do_test randexpr-2.1914 {
+ db eval {SELECT case when f in (d, -case when (case 11 when (select max(t1.d) from t1) then (abs(a)/abs(+t1.b)) else ~b end<19) then (abs( -(abs(17)/abs(t1.f)))/abs((select count(*) from t1))) when (f) not between coalesce((select 13 from t1 where t1.a<=case t1.a when 13 then -t1.c else 13 end and 13 not between t1.f and 11),11) and 19 then e else b end,t1.d) then b else t1.b end FROM t1 WHERE NOT (t1.f between f and a-c-t1.d-t1.d+t1.d*case when exists(select 1 from t1 where d between (select ~cast(avg(17) AS integer) from t1) and a) then case when case b when f then 13 else b end<c then t1.d when (t1.a) in (select -( -b) from t1 union select -t1.f from t1) and f not in (t1.b,t1.d,t1.a) then -d else (13) end when d in (c,((t1.d)),c) then b else 19 end and exists(select 1 from t1 where not t1.a=17))}
+} {}
+do_test randexpr-2.1915 {
+ db eval {SELECT (abs(case when 11<=case 17 when t1.d then t1.b+~19-~case when not t1.b not in (t1.a,b,coalesce((select a+(a) from t1 where t1.b>19),t1.b)) or ((t1.a>19)) or e<>19 then -t1.e else -13 end-b+t1.d else a end then 19 when d between b and t1.c then t1.e else e end)/abs(t1.a)) FROM t1 WHERE b | t1.b>b-case when a-f in (select 17 from t1 union select coalesce((select coalesce((select t1.e+t1.a+d+d from t1 where 13 not between t1.e+19 and 13),(select count(distinct t1.e) from t1)*11) from t1 where b not in (b,(t1.f),t1.a)),13) from t1) then b else c end+a-13-13*(13) | 11}
+} {0}
+do_test randexpr-2.1916 {
+ db eval {SELECT (abs(case when 11<=case 17 when t1.d then t1.b+~19-~case when not t1.b not in (t1.a,b,coalesce((select a+(a) from t1 where t1.b>19),t1.b)) or ((t1.a>19)) or e<>19 then -t1.e else -13 end-b+t1.d else a end then 19 when d between b and t1.c then t1.e else e end)/abs(t1.a)) FROM t1 WHERE NOT (b | t1.b>b-case when a-f in (select 17 from t1 union select coalesce((select coalesce((select t1.e+t1.a+d+d from t1 where 13 not between t1.e+19 and 13),(select count(distinct t1.e) from t1)*11) from t1 where b not in (b,(t1.f),t1.a)),13) from t1) then b else c end+a-13-13*(13) | 11)}
+} {}
+do_test randexpr-2.1917 {
+ db eval {SELECT -t1.a | coalesce((select t1.f*(select min(f)+min(( -(select -case (min(13)) when -abs(min(t1.b)) then count(distinct a) else count(*) end from t1)*(select - -count(*) from t1)))* -count(*) from t1) from t1 where t1.d in (select case case when t1.a<(f) then c else 19 end when f then b else -c end*a*t1.c from t1 union select t1.b from t1)),b) | a FROM t1 WHERE +19*case when exists(select 1 from t1 where e<+13 | f or t1.d=19) then t1.a when case when exists(select 1 from t1 where t1.c in (select 11 from t1 union select c from t1)) then 13*t1.e else 19 end<=c and (t1.e between (b) and 13) or 11 not between t1.f and 13 or 17 between b and 13 then t1.e+a else 17 end not between b and d or t1.e not between 13 and 17}
+} {-4}
+do_test randexpr-2.1918 {
+ db eval {SELECT -t1.a | coalesce((select t1.f*(select min(f)+min(( -(select -case (min(13)) when -abs(min(t1.b)) then count(distinct a) else count(*) end from t1)*(select - -count(*) from t1)))* -count(*) from t1) from t1 where t1.d in (select case case when t1.a<(f) then c else 19 end when f then b else -c end*a*t1.c from t1 union select t1.b from t1)),b) | a FROM t1 WHERE NOT (+19*case when exists(select 1 from t1 where e<+13 | f or t1.d=19) then t1.a when case when exists(select 1 from t1 where t1.c in (select 11 from t1 union select c from t1)) then 13*t1.e else 19 end<=c and (t1.e between (b) and 13) or 11 not between t1.f and 13 or 17 between b and 13 then t1.e+a else 17 end not between b and d or t1.e not between 13 and 17)}
+} {}
+do_test randexpr-2.1919 {
+ db eval {SELECT -t1.a & coalesce((select t1.f*(select min(f)+min(( -(select -case (min(13)) when -abs(min(t1.b)) then count(distinct a) else count(*) end from t1)*(select - -count(*) from t1)))* -count(*) from t1) from t1 where t1.d in (select case case when t1.a<(f) then c else 19 end when f then b else -c end*a*t1.c from t1 union select t1.b from t1)),b) & a FROM t1 WHERE +19*case when exists(select 1 from t1 where e<+13 | f or t1.d=19) then t1.a when case when exists(select 1 from t1 where t1.c in (select 11 from t1 union select c from t1)) then 13*t1.e else 19 end<=c and (t1.e between (b) and 13) or 11 not between t1.f and 13 or 17 between b and 13 then t1.e+a else 17 end not between b and d or t1.e not between 13 and 17}
+} {0}
+do_test randexpr-2.1920 {
+ db eval {SELECT (select -case +count(distinct case when -+ -~case when ((t1.e)) not between e and f then e when t1.b between -11 and t1.b then d else t1.a end*19 in (select t1.f from t1 union select t1.d from t1) then t1.b when a in (select -19 from t1 union select c from t1) then a else f end) when +~ -(count(*)) then -( -count(distinct t1.e))-count(distinct c) else max(t1.c) end-count(distinct t1.c)-count(distinct 19)-(max(11)) from t1) FROM t1 WHERE -~coalesce((select max(19*t1.b) from t1 where t1.d in (select max( -coalesce((select max(t1.c) from t1 where case 13 when f+ -13+t1.b-case 13 when t1.a | (abs(t1.a)/abs(t1.f)) then 11 else f end then f else 17 end in (b,t1.d,(e))),13)) from t1 union select ~~min(b)*abs(cast(avg(b) AS integer)) from t1)),e)*((t1.d))<>t1.d}
+} {-313}
+do_test randexpr-2.1921 {
+ db eval {SELECT (select -case +count(distinct case when -+ -~case when ((t1.e)) not between e and f then e when t1.b between -11 and t1.b then d else t1.a end*19 in (select t1.f from t1 union select t1.d from t1) then t1.b when a in (select -19 from t1 union select c from t1) then a else f end) when +~ -(count(*)) then -( -count(distinct t1.e))-count(distinct c) else max(t1.c) end-count(distinct t1.c)-count(distinct 19)-(max(11)) from t1) FROM t1 WHERE NOT ( -~coalesce((select max(19*t1.b) from t1 where t1.d in (select max( -coalesce((select max(t1.c) from t1 where case 13 when f+ -13+t1.b-case 13 when t1.a | (abs(t1.a)/abs(t1.f)) then 11 else f end then f else 17 end in (b,t1.d,(e))),13)) from t1 union select ~~min(b)*abs(cast(avg(b) AS integer)) from t1)),e)*((t1.d))<>t1.d)}
+} {}
+do_test randexpr-2.1922 {
+ db eval {SELECT case a when c then (abs((select abs(~(+~~case max(t1.d) when +count(distinct ~d | (select case max(17) when count(*) then count(distinct (t1.c)) else count(distinct 11) end from t1)) then (+cast(avg((17)) AS integer))+count(*) else -(( - -(cast(avg(c) AS integer)))) end)+count(distinct t1.e)+min(13)) from t1)*+11-((abs(t1.a)/abs(coalesce((select c from t1 where ((t1.f<>d))),(t1.c))))) | t1.d)/abs( -(d))) else a end FROM t1 WHERE coalesce((select max(case t1.a when +t1.e then case when t1.c+(select (max(t1.d))-max(13)+cast(avg(c) AS integer)+min((e)) | max(a) from t1)<= -t1.a | case when not exists(select 1 from t1 where -t1.d<=t1.a) then t1.f when 11<a then f else t1.f end then b when -t1.c>=c then a else 13 end | t1.c else t1.a end) from t1 where 19<=e and t1.e between t1.d and 11),13) not in (e,a,c)}
+} {100}
+do_test randexpr-2.1923 {
+ db eval {SELECT case a when c then (abs((select abs(~(+~~case max(t1.d) when +count(distinct ~d | (select case max(17) when count(*) then count(distinct (t1.c)) else count(distinct 11) end from t1)) then (+cast(avg((17)) AS integer))+count(*) else -(( - -(cast(avg(c) AS integer)))) end)+count(distinct t1.e)+min(13)) from t1)*+11-((abs(t1.a)/abs(coalesce((select c from t1 where ((t1.f<>d))),(t1.c))))) | t1.d)/abs( -(d))) else a end FROM t1 WHERE NOT (coalesce((select max(case t1.a when +t1.e then case when t1.c+(select (max(t1.d))-max(13)+cast(avg(c) AS integer)+min((e)) | max(a) from t1)<= -t1.a | case when not exists(select 1 from t1 where -t1.d<=t1.a) then t1.f when 11<a then f else t1.f end then b when -t1.c>=c then a else 13 end | t1.c else t1.a end) from t1 where 19<=e and t1.e between t1.d and 11),13) not in (e,a,c))}
+} {}
+do_test randexpr-2.1924 {
+ db eval {SELECT case a when c then (abs((select abs(~(+~~case max(t1.d) when +count(distinct ~d & (select case max(17) when count(*) then count(distinct (t1.c)) else count(distinct 11) end from t1)) then (+cast(avg((17)) AS integer))+count(*) else -(( - -(cast(avg(c) AS integer)))) end)+count(distinct t1.e)+min(13)) from t1)*+11-((abs(t1.a)/abs(coalesce((select c from t1 where ((t1.f<>d))),(t1.c))))) & t1.d)/abs( -(d))) else a end FROM t1 WHERE coalesce((select max(case t1.a when +t1.e then case when t1.c+(select (max(t1.d))-max(13)+cast(avg(c) AS integer)+min((e)) | max(a) from t1)<= -t1.a | case when not exists(select 1 from t1 where -t1.d<=t1.a) then t1.f when 11<a then f else t1.f end then b when -t1.c>=c then a else 13 end | t1.c else t1.a end) from t1 where 19<=e and t1.e between t1.d and 11),13) not in (e,a,c)}
+} {100}
+do_test randexpr-2.1925 {
+ db eval {SELECT t1.d-+case ~(select ~+~count(distinct case when case when case when 11 not between t1.c and t1.a-e then t1.d else e end*d-(d) between -13 and e then a else c end in (select b from t1 union select 17 from t1) then a else 13 end)*cast(avg(d) AS integer) from t1) when t1.e then (abs(11)/abs(coalesce((select max(19) from t1 where (a)<>t1.e),19))) else t1.c end+t1.c FROM t1 WHERE 19 not in (t1.a*+case when -c+~t1.a-t1.c in (t1.a,b*case t1.a | coalesce((select max(coalesce((select 17 from t1 where t1.e>t1.a),t1.d)) from t1 where not 11=19),17) when 11 then t1.d else (f) end*b-t1.a+c, -b) then d when a<>f then a else b end-c,d,t1.b)}
+} {400}
+do_test randexpr-2.1926 {
+ db eval {SELECT t1.d-+case ~(select ~+~count(distinct case when case when case when 11 not between t1.c and t1.a-e then t1.d else e end*d-(d) between -13 and e then a else c end in (select b from t1 union select 17 from t1) then a else 13 end)*cast(avg(d) AS integer) from t1) when t1.e then (abs(11)/abs(coalesce((select max(19) from t1 where (a)<>t1.e),19))) else t1.c end+t1.c FROM t1 WHERE NOT (19 not in (t1.a*+case when -c+~t1.a-t1.c in (t1.a,b*case t1.a | coalesce((select max(coalesce((select 17 from t1 where t1.e>t1.a),t1.d)) from t1 where not 11=19),17) when 11 then t1.d else (f) end*b-t1.a+c, -b) then d when a<>f then a else b end-c,d,t1.b))}
+} {}
+do_test randexpr-2.1927 {
+ db eval {SELECT case when case (select +min(~ -11+f*~b) | case abs(cast(avg(t1.f) AS integer))*~min(c) when count(*)+max( -11) then abs(count(*)) else max(13) end from t1) when coalesce((select max(coalesce((select max(19) from t1 where (17>=17)),t1.f)) from t1 where c<b),13) then t1.f else (f) end*t1.f>t1.a then -d else -t1.b end FROM t1 WHERE t1.a+b-t1.c*17>=c}
+} {}
+do_test randexpr-2.1928 {
+ db eval {SELECT case when case (select +min(~ -11+f*~b) | case abs(cast(avg(t1.f) AS integer))*~min(c) when count(*)+max( -11) then abs(count(*)) else max(13) end from t1) when coalesce((select max(coalesce((select max(19) from t1 where (17>=17)),t1.f)) from t1 where c<b),13) then t1.f else (f) end*t1.f>t1.a then -d else -t1.b end FROM t1 WHERE NOT (t1.a+b-t1.c*17>=c)}
+} {-400}
+do_test randexpr-2.1929 {
+ db eval {SELECT case when case (select +min(~ -11+f*~b) & case abs(cast(avg(t1.f) AS integer))*~min(c) when count(*)+max( -11) then abs(count(*)) else max(13) end from t1) when coalesce((select max(coalesce((select max(19) from t1 where (17>=17)),t1.f)) from t1 where c<b),13) then t1.f else (f) end*t1.f>t1.a then -d else -t1.b end FROM t1 WHERE NOT (t1.a+b-t1.c*17>=c)}
+} {-400}
+do_test randexpr-2.1930 {
+ db eval {SELECT case when ~case when t1.f>11*t1.a then f when case when (t1.c*19<(t1.f)) then (e) when a<t1.f then c else -e end not in (11,b,19) then t1.a else f end=17 or not t1.a>t1.e and a in (d,t1.c,13) then t1.b when -17 not between f and d then f else t1.c end FROM t1 WHERE c in (select + -min(case (select count(*) from t1) when t1.a then t1.c else coalesce((select max(b) from t1 where d in (select -abs(cast(avg(t1.b) AS integer)) | (min(t1.f)) | count(distinct a)+abs(cast(avg(b) AS integer))*( -min(b)) | cast(avg(t1.c) AS integer)*((min(t1.e))) from t1 union select cast(avg(f) AS integer) from t1)),t1.e) | +case b when -t1.c then (select (count(*)) from t1) else b end | 13 end) from t1 union select min(t1.d) from t1)}
+} {}
+do_test randexpr-2.1931 {
+ db eval {SELECT case when ~case when t1.f>11*t1.a then f when case when (t1.c*19<(t1.f)) then (e) when a<t1.f then c else -e end not in (11,b,19) then t1.a else f end=17 or not t1.a>t1.e and a in (d,t1.c,13) then t1.b when -17 not between f and d then f else t1.c end FROM t1 WHERE NOT (c in (select + -min(case (select count(*) from t1) when t1.a then t1.c else coalesce((select max(b) from t1 where d in (select -abs(cast(avg(t1.b) AS integer)) | (min(t1.f)) | count(distinct a)+abs(cast(avg(b) AS integer))*( -min(b)) | cast(avg(t1.c) AS integer)*((min(t1.e))) from t1 union select cast(avg(f) AS integer) from t1)),t1.e) | +case b when -t1.c then (select (count(*)) from t1) else b end | 13 end) from t1 union select min(t1.d) from t1))}
+} {600}
+do_test randexpr-2.1932 {
+ db eval {SELECT case when (b) between 19 and case when t1.a* -t1.d+t1.a-t1.d-b-a<=d then t1.c when not exists(select 1 from t1 where (13>t1.e) and ((a>a))) and -(13)>t1.b then t1.d else 11 end or d=e then 13+t1.f when ( -a) not between t1.e and t1.b then (c) else t1.e end+t1.a+17 FROM t1 WHERE (case when a<=f+t1.a | f then t1.c*a-coalesce((select max( -e) from t1 where t1.a=t1.d),b)*d- -f else t1.b end) in (select min(t1.f)+~max(b) | count(distinct t1.d)*+ - -case (count(*)) when +count(distinct e) then count(*) else -cast(avg(d) AS integer) end from t1 union select count(*) from t1) and d between 11 and t1.a}
+} {}
+do_test randexpr-2.1933 {
+ db eval {SELECT case when (b) between 19 and case when t1.a* -t1.d+t1.a-t1.d-b-a<=d then t1.c when not exists(select 1 from t1 where (13>t1.e) and ((a>a))) and -(13)>t1.b then t1.d else 11 end or d=e then 13+t1.f when ( -a) not between t1.e and t1.b then (c) else t1.e end+t1.a+17 FROM t1 WHERE NOT ((case when a<=f+t1.a | f then t1.c*a-coalesce((select max( -e) from t1 where t1.a=t1.d),b)*d- -f else t1.b end) in (select min(t1.f)+~max(b) | count(distinct t1.d)*+ - -case (count(*)) when +count(distinct e) then count(*) else -cast(avg(d) AS integer) end from t1 union select count(*) from t1) and d between 11 and t1.a)}
+} {730}
+do_test randexpr-2.1934 {
+ db eval {SELECT +f*19*~~ -t1.c-13-case when t1.b in (select +case when not exists(select 1 from t1 where (((abs((abs((select count(*)*(count(distinct t1.d)) from t1))/abs(b)))/abs(e))*(e))>=d)) then f when t1.a=f then b else t1.e end+19 | (17) from t1 union select t1.b from t1) or -e<t1.d then 11 else a end-t1.b FROM t1 WHERE (e in (17,t1.b*19+(abs(19)/abs(coalesce((select t1.b+d from t1 where not exists(select 1 from t1 where 19* -t1.c+ -t1.b-~e not between 11-c+b and 11) or e=a),d))),a)) and d<=b or b>e and t1.e<=t1.b}
+} {}
+do_test randexpr-2.1935 {
+ db eval {SELECT +f*19*~~ -t1.c-13-case when t1.b in (select +case when not exists(select 1 from t1 where (((abs((abs((select count(*)*(count(distinct t1.d)) from t1))/abs(b)))/abs(e))*(e))>=d)) then f when t1.a=f then b else t1.e end+19 | (17) from t1 union select t1.b from t1) or -e<t1.d then 11 else a end-t1.b FROM t1 WHERE NOT ((e in (17,t1.b*19+(abs(19)/abs(coalesce((select t1.b+d from t1 where not exists(select 1 from t1 where 19* -t1.c+ -t1.b-~e not between 11-c+b and 11) or e=a),d))),a)) and d<=b or b>e and t1.e<=t1.b)}
+} {-3420224}
+do_test randexpr-2.1936 {
+ db eval {SELECT +f*19*~~ -t1.c-13-case when t1.b in (select +case when not exists(select 1 from t1 where (((abs((abs((select count(*)*(count(distinct t1.d)) from t1))/abs(b)))/abs(e))*(e))>=d)) then f when t1.a=f then b else t1.e end+19 & (17) from t1 union select t1.b from t1) or -e<t1.d then 11 else a end-t1.b FROM t1 WHERE NOT ((e in (17,t1.b*19+(abs(19)/abs(coalesce((select t1.b+d from t1 where not exists(select 1 from t1 where 19* -t1.c+ -t1.b-~e not between 11-c+b and 11) or e=a),d))),a)) and d<=b or b>e and t1.e<=t1.b)}
+} {-3420224}
+do_test randexpr-2.1937 {
+ db eval {SELECT f-coalesce((select max(d+~+ - -(a)*(select min(t1.d) from t1)*t1.f+case when ( -13)*t1.e<>11 | -t1.e or c=11 then (t1.e) when -t1.d<=t1.b and (t1.f<>t1.c) then a else -t1.f end) from t1 where 11 not between t1.e and b),t1.f)-13 FROM t1 WHERE -a not in (17+~coalesce((select t1.a from t1 where (exists(select 1 from t1 where 11>c))),11)+17-11,11,t1.c) or f in (select case (min((t1.a))) when max(b) then min(13) else cast(avg(c) AS integer) end*max(d)*(case cast(avg(19) AS integer) when ( -min(19)) then count(*) else count(*) end) | -cast(avg(19) AS integer) from t1 union select cast(avg(b) AS integer) from t1) or t1.f>= -t1.d}
+} {24239687}
+do_test randexpr-2.1938 {
+ db eval {SELECT f-coalesce((select max(d+~+ - -(a)*(select min(t1.d) from t1)*t1.f+case when ( -13)*t1.e<>11 | -t1.e or c=11 then (t1.e) when -t1.d<=t1.b and (t1.f<>t1.c) then a else -t1.f end) from t1 where 11 not between t1.e and b),t1.f)-13 FROM t1 WHERE NOT ( -a not in (17+~coalesce((select t1.a from t1 where (exists(select 1 from t1 where 11>c))),11)+17-11,11,t1.c) or f in (select case (min((t1.a))) when max(b) then min(13) else cast(avg(c) AS integer) end*max(d)*(case cast(avg(19) AS integer) when ( -min(19)) then count(*) else count(*) end) | -cast(avg(19) AS integer) from t1 union select cast(avg(b) AS integer) from t1) or t1.f>= -t1.d)}
+} {}
+do_test randexpr-2.1939 {
+ db eval {SELECT f-coalesce((select max(d+~+ - -(a)*(select min(t1.d) from t1)*t1.f+case when ( -13)*t1.e<>11 & -t1.e or c=11 then (t1.e) when -t1.d<=t1.b and (t1.f<>t1.c) then a else -t1.f end) from t1 where 11 not between t1.e and b),t1.f)-13 FROM t1 WHERE -a not in (17+~coalesce((select t1.a from t1 where (exists(select 1 from t1 where 11>c))),11)+17-11,11,t1.c) or f in (select case (min((t1.a))) when max(b) then min(13) else cast(avg(c) AS integer) end*max(d)*(case cast(avg(19) AS integer) when ( -min(19)) then count(*) else count(*) end) | -cast(avg(19) AS integer) from t1 union select cast(avg(b) AS integer) from t1) or t1.f>= -t1.d}
+} {24239687}
+do_test randexpr-2.1940 {
+ db eval {SELECT ~case when ~coalesce((select max(f) from t1 where b | (select +max(13) from t1)+t1.b<~13*t1.d*coalesce((select -t1.b from t1 where coalesce((select t1.e+a from t1 where 11=17),a) between 19 and e),17)*d),t1.b) in (select cast(avg(t1.d) AS integer) from t1 union select ~count(distinct 11) from t1) then 11 when t1.d>=t1.b then 13 else f end-t1.e FROM t1 WHERE not exists(select 1 from t1 where coalesce((select case t1.b when -t1.c then c-17 else case f when (abs(case when ((13*case -e when case when b>c and 11>11 then -a when -(t1.c)>t1.e then d else t1.d end then t1.d else t1.e end<=11)) then ~t1.b+f when (d)<=c then t1.a else (t1.a) end+b)/abs(b)) then -b else 11 end end-19 from t1 where t1.e<=t1.b),a)>t1.a)}
+} {-514}
+do_test randexpr-2.1941 {
+ db eval {SELECT ~case when ~coalesce((select max(f) from t1 where b | (select +max(13) from t1)+t1.b<~13*t1.d*coalesce((select -t1.b from t1 where coalesce((select t1.e+a from t1 where 11=17),a) between 19 and e),17)*d),t1.b) in (select cast(avg(t1.d) AS integer) from t1 union select ~count(distinct 11) from t1) then 11 when t1.d>=t1.b then 13 else f end-t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select case t1.b when -t1.c then c-17 else case f when (abs(case when ((13*case -e when case when b>c and 11>11 then -a when -(t1.c)>t1.e then d else t1.d end then t1.d else t1.e end<=11)) then ~t1.b+f when (d)<=c then t1.a else (t1.a) end+b)/abs(b)) then -b else 11 end end-19 from t1 where t1.e<=t1.b),a)>t1.a))}
+} {}
+do_test randexpr-2.1942 {
+ db eval {SELECT ~case when ~coalesce((select max(f) from t1 where b & (select +max(13) from t1)+t1.b<~13*t1.d*coalesce((select -t1.b from t1 where coalesce((select t1.e+a from t1 where 11=17),a) between 19 and e),17)*d),t1.b) in (select cast(avg(t1.d) AS integer) from t1 union select ~count(distinct 11) from t1) then 11 when t1.d>=t1.b then 13 else f end-t1.e FROM t1 WHERE not exists(select 1 from t1 where coalesce((select case t1.b when -t1.c then c-17 else case f when (abs(case when ((13*case -e when case when b>c and 11>11 then -a when -(t1.c)>t1.e then d else t1.d end then t1.d else t1.e end<=11)) then ~t1.b+f when (d)<=c then t1.a else (t1.a) end+b)/abs(b)) then -b else 11 end end-19 from t1 where t1.e<=t1.b),a)>t1.a)}
+} {-514}
+do_test randexpr-2.1943 {
+ db eval {SELECT +(case when (not exists(select 1 from t1 where t1.c in (select +(abs(a)/abs( -coalesce((select max(17) from t1 where (not (c>=t1.d and t1.c>=f) and t1.e>e)),19-17))) from t1 union select case when (b)>d then d when c not in (f,t1.b,t1.d) then t1.f else t1.d end from t1) or a not in (t1.d,a, -b))) and exists(select 1 from t1 where b<11) then c when t1.c not between e and -19 then t1.b else ~c end) FROM t1 WHERE t1.e*f-a- -13-b= -d}
+} {}
+do_test randexpr-2.1944 {
+ db eval {SELECT +(case when (not exists(select 1 from t1 where t1.c in (select +(abs(a)/abs( -coalesce((select max(17) from t1 where (not (c>=t1.d and t1.c>=f) and t1.e>e)),19-17))) from t1 union select case when (b)>d then d when c not in (f,t1.b,t1.d) then t1.f else t1.d end from t1) or a not in (t1.d,a, -b))) and exists(select 1 from t1 where b<11) then c when t1.c not between e and -19 then t1.b else ~c end) FROM t1 WHERE NOT (t1.e*f-a- -13-b= -d)}
+} {200}
+do_test randexpr-2.1945 {
+ db eval {SELECT b-case when a not between t1.f and case when t1.d in (select count(*) from t1 union select cast(avg(coalesce((select +11*t1.e from t1 where e+b<case when 19 not in (t1.a | c,t1.a,f) then 13 when -b<=17 then t1.e else a end),17)) AS integer) from t1) then 13 when not exists(select 1 from t1 where 13 between e and 17) or (a= -13) then t1.e else -11 end then 11 else t1.a end FROM t1 WHERE not exists(select 1 from t1 where (e+17+t1.f)<=(case b when ~t1.f+(select +max(t1.f*case t1.b when +t1.f then t1.b else case when (not case when c=d then t1.c when t1.c<>b and t1.d between c and b then t1.d else t1.d end<t1.b) then t1.d when f<= -a then case when 17<c then a else a end else t1.e end end) from t1)*+t1.f then e else 17 end))}
+} {189}
+do_test randexpr-2.1946 {
+ db eval {SELECT b-case when a not between t1.f and case when t1.d in (select count(*) from t1 union select cast(avg(coalesce((select +11*t1.e from t1 where e+b<case when 19 not in (t1.a | c,t1.a,f) then 13 when -b<=17 then t1.e else a end),17)) AS integer) from t1) then 13 when not exists(select 1 from t1 where 13 between e and 17) or (a= -13) then t1.e else -11 end then 11 else t1.a end FROM t1 WHERE NOT (not exists(select 1 from t1 where (e+17+t1.f)<=(case b when ~t1.f+(select +max(t1.f*case t1.b when +t1.f then t1.b else case when (not case when c=d then t1.c when t1.c<>b and t1.d between c and b then t1.d else t1.d end<t1.b) then t1.d when f<= -a then case when 17<c then a else a end else t1.e end end) from t1)*+t1.f then e else 17 end)))}
+} {}
+do_test randexpr-2.1947 {
+ db eval {SELECT b-case when a not between t1.f and case when t1.d in (select count(*) from t1 union select cast(avg(coalesce((select +11*t1.e from t1 where e+b<case when 19 not in (t1.a & c,t1.a,f) then 13 when -b<=17 then t1.e else a end),17)) AS integer) from t1) then 13 when not exists(select 1 from t1 where 13 between e and 17) or (a= -13) then t1.e else -11 end then 11 else t1.a end FROM t1 WHERE not exists(select 1 from t1 where (e+17+t1.f)<=(case b when ~t1.f+(select +max(t1.f*case t1.b when +t1.f then t1.b else case when (not case when c=d then t1.c when t1.c<>b and t1.d between c and b then t1.d else t1.d end<t1.b) then t1.d when f<= -a then case when 17<c then a else a end else t1.e end end) from t1)*+t1.f then e else 17 end))}
+} {189}
+do_test randexpr-2.1948 {
+ db eval {SELECT (select (min(coalesce((select max((case when t1.f<coalesce((select max(e+case when (t1.d in (select cast(avg(b) AS integer)+count(*) from t1 union select max(13) from t1)) then e*a else c end-t1.e) from t1 where (t1.c between b and t1.f and -t1.b between -t1.d and -t1.a or c in (t1.b,t1.f,(f)))),13)+t1.c*19 then f else c end)) from t1 where -t1.b not between t1.b and t1.c),11)-19))+count(distinct t1.e) from t1) FROM t1 WHERE - -+t1.b*(19-t1.a | e*(select abs((count(distinct -f+t1.d-11*t1.a))) from t1))*+(abs(c)/abs(t1.c))+t1.c*(t1.a)+case when b>=t1.d and 17<=13 or f between -t1.c and 11 then case d when t1.c then 13 else t1.e end when (11)>b then a else c end in (t1.e,a,b)}
+} {}
+do_test randexpr-2.1949 {
+ db eval {SELECT (select (min(coalesce((select max((case when t1.f<coalesce((select max(e+case when (t1.d in (select cast(avg(b) AS integer)+count(*) from t1 union select max(13) from t1)) then e*a else c end-t1.e) from t1 where (t1.c between b and t1.f and -t1.b between -t1.d and -t1.a or c in (t1.b,t1.f,(f)))),13)+t1.c*19 then f else c end)) from t1 where -t1.b not between t1.b and t1.c),11)-19))+count(distinct t1.e) from t1) FROM t1 WHERE NOT ( - -+t1.b*(19-t1.a | e*(select abs((count(distinct -f+t1.d-11*t1.a))) from t1))*+(abs(c)/abs(t1.c))+t1.c*(t1.a)+case when b>=t1.d and 17<=13 or f between -t1.c and 11 then case d when t1.c then 13 else t1.e end when (11)>b then a else c end in (t1.e,a,b))}
+} {582}
+do_test randexpr-2.1950 {
+ db eval {SELECT coalesce((select max((abs(e)/abs(t1.a))) from t1 where (select (count(distinct ~ - -11- -t1.a-a*t1.d | 11-19+t1.f+17*c)-cast(avg(17) AS integer)+(cast(avg((19)) AS integer))) from t1)>a),17 | 11+17)+e-(c)-d-b FROM t1 WHERE (d>t1.d-case when case +(abs(t1.d | t1.f)/abs(t1.b)) when +b then coalesce((select max(t1.d | t1.c+(11+t1.d-t1.c)) from t1 where ((t1.e=17))),17) else t1.c end>=b then a else t1.f end) and (not (e<=c)) and not (t1.c<>b)}
+} {}
+do_test randexpr-2.1951 {
+ db eval {SELECT coalesce((select max((abs(e)/abs(t1.a))) from t1 where (select (count(distinct ~ - -11- -t1.a-a*t1.d | 11-19+t1.f+17*c)-cast(avg(17) AS integer)+(cast(avg((19)) AS integer))) from t1)>a),17 | 11+17)+e-(c)-d-b FROM t1 WHERE NOT ((d>t1.d-case when case +(abs(t1.d | t1.f)/abs(t1.b)) when +b then coalesce((select max(t1.d | t1.c+(11+t1.d-t1.c)) from t1 where ((t1.e=17))),17) else t1.c end>=b then a else t1.f end) and (not (e<=c)) and not (t1.c<>b))}
+} {-371}
+do_test randexpr-2.1952 {
+ db eval {SELECT coalesce((select max((abs(e)/abs(t1.a))) from t1 where (select (count(distinct ~ - -11- -t1.a-a*t1.d & 11-19+t1.f+17*c)-cast(avg(17) AS integer)+(cast(avg((19)) AS integer))) from t1)>a),17 & 11+17)+e-(c)-d-b FROM t1 WHERE NOT ((d>t1.d-case when case +(abs(t1.d | t1.f)/abs(t1.b)) when +b then coalesce((select max(t1.d | t1.c+(11+t1.d-t1.c)) from t1 where ((t1.e=17))),17) else t1.c end>=b then a else t1.f end) and (not (e<=c)) and not (t1.c<>b))}
+} {-384}
+do_test randexpr-2.1953 {
+ db eval {SELECT coalesce((select c from t1 where case b when t1.a*(17) | case b++b when e then d else t1.b+f end+a+t1.d then d else t1.b | +e end<+~(select (count(*)) from t1)),17) FROM t1 WHERE (b+t1.c*c in (11, -t1.f,t1.b))}
+} {}
+do_test randexpr-2.1954 {
+ db eval {SELECT coalesce((select c from t1 where case b when t1.a*(17) | case b++b when e then d else t1.b+f end+a+t1.d then d else t1.b | +e end<+~(select (count(*)) from t1)),17) FROM t1 WHERE NOT ((b+t1.c*c in (11, -t1.f,t1.b)))}
+} {17}
+do_test randexpr-2.1955 {
+ db eval {SELECT coalesce((select c from t1 where case b when t1.a*(17) & case b++b when e then d else t1.b+f end+a+t1.d then d else t1.b & +e end<+~(select (count(*)) from t1)),17) FROM t1 WHERE NOT ((b+t1.c*c in (11, -t1.f,t1.b)))}
+} {17}
+do_test randexpr-2.1956 {
+ db eval {SELECT case when coalesce((select max((abs(c)/abs(t1.d))) from t1 where t1.f*case when t1.a in (select (abs(17)/abs(c))*(t1.a) from t1 union select t1.e from t1) then t1.b else b end<19),e)+a-d in (select case max(t1.b)-count(distinct t1.c) when +case abs(cast(avg(t1.f) AS integer)) when +cast(avg(f) AS integer)-min(f) then count(distinct c) else cast(avg(d) AS integer) end then count(distinct t1.a) else cast(avg(b) AS integer) end from t1 union select count(distinct t1.e) from t1) then t1.c else f end FROM t1 WHERE ((19 in (t1.b,case t1.f when 11 then 11 else -+t1.b | 19 end+coalesce((select 11 from t1 where c<=t1.c* -e),f),t1.f)) or (b between t1.b and 17) or not exists(select 1 from t1 where -17 between -f and t1.e or (not b<>11) and 19 in (select 11 from t1 union select t1.b from t1))) or 13>(t1.e)}
+} {}
+do_test randexpr-2.1957 {
+ db eval {SELECT case when coalesce((select max((abs(c)/abs(t1.d))) from t1 where t1.f*case when t1.a in (select (abs(17)/abs(c))*(t1.a) from t1 union select t1.e from t1) then t1.b else b end<19),e)+a-d in (select case max(t1.b)-count(distinct t1.c) when +case abs(cast(avg(t1.f) AS integer)) when +cast(avg(f) AS integer)-min(f) then count(distinct c) else cast(avg(d) AS integer) end then count(distinct t1.a) else cast(avg(b) AS integer) end from t1 union select count(distinct t1.e) from t1) then t1.c else f end FROM t1 WHERE NOT (((19 in (t1.b,case t1.f when 11 then 11 else -+t1.b | 19 end+coalesce((select 11 from t1 where c<=t1.c* -e),f),t1.f)) or (b between t1.b and 17) or not exists(select 1 from t1 where -17 between -f and t1.e or (not b<>11) and 19 in (select 11 from t1 union select t1.b from t1))) or 13>(t1.e))}
+} {300}
+do_test randexpr-2.1958 {
+ db eval {SELECT f+case when e>+11+t1.e or ~t1.a=f+t1.e+t1.c then t1.a+case when b*coalesce((select max(a) from t1 where not exists(select 1 from t1 where (t1.f=case when exists(select 1 from t1 where t1.f<b) then f when 19<13 then t1.e else f end))),coalesce((select max(11) from t1 where (t1.d) between t1.c and - -f and d<>f),11))<(e) then t1.e else 19 end+(c) else t1.a end*c-t1.c FROM t1 WHERE not ~coalesce((select max(t1.f*coalesce((select max(f) from t1 where case 17 when e*19 then case t1.a when 17 then f else t1.c+t1.d end | (e) else ~a end>=e or not t1.b in (select a from t1 union select d from t1)),19)) from t1 where e>coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.c=t1.a)),case t1.b when t1.b then a else 19 end)),13)*t1.b not between t1.e and t1.e}
+} {}
+do_test randexpr-2.1959 {
+ db eval {SELECT f+case when e>+11+t1.e or ~t1.a=f+t1.e+t1.c then t1.a+case when b*coalesce((select max(a) from t1 where not exists(select 1 from t1 where (t1.f=case when exists(select 1 from t1 where t1.f<b) then f when 19<13 then t1.e else f end))),coalesce((select max(11) from t1 where (t1.d) between t1.c and - -f and d<>f),11))<(e) then t1.e else 19 end+(c) else t1.a end*c-t1.c FROM t1 WHERE NOT (not ~coalesce((select max(t1.f*coalesce((select max(f) from t1 where case 17 when e*19 then case t1.a when 17 then f else t1.c+t1.d end | (e) else ~a end>=e or not t1.b in (select a from t1 union select d from t1)),19)) from t1 where e>coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.c=t1.a)),case t1.b when t1.b then a else 19 end)),13)*t1.b not between t1.e and t1.e)}
+} {30300}
+do_test randexpr-2.1960 {
+ db eval {SELECT e*(select -max((case when -case when (+(abs(f)/abs(17))*13)> -a then 17 else f end | -t1.f-e*11<>11 then c when exists(select 1 from t1 where not exists(select 1 from t1 where t1.b not in (t1.d,19,d) and t1.d<>11)) or 13<= -t1.f then 11 else d end-t1.a)*e) from t1) FROM t1 WHERE exists(select 1 from t1 where c<>a)}
+} {-50000000}
+do_test randexpr-2.1961 {
+ db eval {SELECT e*(select -max((case when -case when (+(abs(f)/abs(17))*13)> -a then 17 else f end | -t1.f-e*11<>11 then c when exists(select 1 from t1 where not exists(select 1 from t1 where t1.b not in (t1.d,19,d) and t1.d<>11)) or 13<= -t1.f then 11 else d end-t1.a)*e) from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where c<>a))}
+} {}
+do_test randexpr-2.1962 {
+ db eval {SELECT e*(select -max((case when -case when (+(abs(f)/abs(17))*13)> -a then 17 else f end & -t1.f-e*11<>11 then c when exists(select 1 from t1 where not exists(select 1 from t1 where t1.b not in (t1.d,19,d) and t1.d<>11)) or 13<= -t1.f then 11 else d end-t1.a)*e) from t1) FROM t1 WHERE exists(select 1 from t1 where c<>a)}
+} {-50000000}
+do_test randexpr-2.1963 {
+ db eval {SELECT a-t1.b | (case case when 13 in (t1.c,(t1.c),t1.e) then e+b when b in (select e from t1 union select d from t1) then (select count(distinct (abs(case when t1.e not between c and c then f else case t1.a when t1.c then e+t1.d else c end end)/abs(b))) from t1) else t1.b- -t1.d end when t1.c then 11 else e end- -a)+d-t1.b FROM t1 WHERE (case when f between f+(abs(coalesce((select t1.c*t1.c from t1 where f between 19 and (select count(distinct coalesce((select max(case case when t1.b<>t1.c then t1.d when 19<d then t1.c else d end | 19-17 when b then 11 else f end) from t1 where c in (select 11 from t1 union select t1.e from t1)),e)) from t1)),13))/abs(19)) and (e) then c when 17 in ((c),t1.e,f) and a in (select 19 from t1 union select t1.e from t1) then t1.f else 13 end<13)}
+} {}
+do_test randexpr-2.1964 {
+ db eval {SELECT a-t1.b | (case case when 13 in (t1.c,(t1.c),t1.e) then e+b when b in (select e from t1 union select d from t1) then (select count(distinct (abs(case when t1.e not between c and c then f else case t1.a when t1.c then e+t1.d else c end end)/abs(b))) from t1) else t1.b- -t1.d end when t1.c then 11 else e end- -a)+d-t1.b FROM t1 WHERE NOT ((case when f between f+(abs(coalesce((select t1.c*t1.c from t1 where f between 19 and (select count(distinct coalesce((select max(case case when t1.b<>t1.c then t1.d when 19<d then t1.c else d end | 19-17 when b then 11 else f end) from t1 where c in (select 11 from t1 union select t1.e from t1)),e)) from t1)),13))/abs(19)) and (e) then c when 17 in ((c),t1.e,f) and a in (select 19 from t1 union select t1.e from t1) then t1.f else 13 end<13))}
+} {-68}
+do_test randexpr-2.1965 {
+ db eval {SELECT a-t1.b & (case case when 13 in (t1.c,(t1.c),t1.e) then e+b when b in (select e from t1 union select d from t1) then (select count(distinct (abs(case when t1.e not between c and c then f else case t1.a when t1.c then e+t1.d else c end end)/abs(b))) from t1) else t1.b- -t1.d end when t1.c then 11 else e end- -a)+d-t1.b FROM t1 WHERE NOT ((case when f between f+(abs(coalesce((select t1.c*t1.c from t1 where f between 19 and (select count(distinct coalesce((select max(case case when t1.b<>t1.c then t1.d when 19<d then t1.c else d end | 19-17 when b then 11 else f end) from t1 where c in (select 11 from t1 union select t1.e from t1)),e)) from t1)),13))/abs(19)) and (e) then c when 17 in ((c),t1.e,f) and a in (select 19 from t1 union select t1.e from t1) then t1.f else 13 end<13))}
+} {768}
+do_test randexpr-2.1966 {
+ db eval {SELECT (abs(case t1.f | d when coalesce((select max(~b) from t1 where +t1.a<> -case t1.f when +b-case when (17 in (select count(distinct b)+count(distinct t1.a) from t1 union select count(distinct 13) from t1)) then d else 13 end+t1.d | d* -11+t1.d*t1.f | a-17 then 13 else c end*t1.e),d) then t1.b else d end)/abs(t1.a))*19 FROM t1 WHERE t1.f in (select count(*) from t1 union select count(*) from t1)}
+} {}
+do_test randexpr-2.1967 {
+ db eval {SELECT (abs(case t1.f | d when coalesce((select max(~b) from t1 where +t1.a<> -case t1.f when +b-case when (17 in (select count(distinct b)+count(distinct t1.a) from t1 union select count(distinct 13) from t1)) then d else 13 end+t1.d | d* -11+t1.d*t1.f | a-17 then 13 else c end*t1.e),d) then t1.b else d end)/abs(t1.a))*19 FROM t1 WHERE NOT (t1.f in (select count(*) from t1 union select count(*) from t1))}
+} {76}
+do_test randexpr-2.1968 {
+ db eval {SELECT (abs(case t1.f & d when coalesce((select max(~b) from t1 where +t1.a<> -case t1.f when +b-case when (17 in (select count(distinct b)+count(distinct t1.a) from t1 union select count(distinct 13) from t1)) then d else 13 end+t1.d & d* -11+t1.d*t1.f & a-17 then 13 else c end*t1.e),d) then t1.b else d end)/abs(t1.a))*19 FROM t1 WHERE NOT (t1.f in (select count(*) from t1 union select count(*) from t1))}
+} {76}
+do_test randexpr-2.1969 {
+ db eval {SELECT t1.d+coalesce((select max(t1.b*t1.b | ~case a | c | t1.d when t1.c then t1.a else t1.e end | e-13*b) from t1 where -t1.a in (select e from t1 union select t1.b from t1) and not exists(select 1 from t1 where (a) in (select min(13)* -cast(avg(t1.e) AS integer)*~case count(*) when count(*) then ((cast(avg(e) AS integer))) else count(*) end | (min(t1.e)) | -count(*) from t1 union select max(t1.a) from t1))), -t1.b)+a FROM t1 WHERE not exists(select 1 from t1 where 11*d+a>=(t1.a-e+17*(select +cast(avg((select cast(avg((abs(case when (abs(t1.a)/abs(coalesce((select max(c+t1.e) from t1 where not exists(select 1 from t1 where 13 in (select -t1.c from t1 union select t1.f from t1))),17) | e*e)) not between e and t1.f then 19 else t1.b end)/abs(19))) AS integer)* -count(*) from t1)) AS integer)*count(distinct 11)-abs(cast(avg(b) AS integer)) from t1)))}
+} {}
+do_test randexpr-2.1970 {
+ db eval {SELECT t1.d+coalesce((select max(t1.b*t1.b | ~case a | c | t1.d when t1.c then t1.a else t1.e end | e-13*b) from t1 where -t1.a in (select e from t1 union select t1.b from t1) and not exists(select 1 from t1 where (a) in (select min(13)* -cast(avg(t1.e) AS integer)*~case count(*) when count(*) then ((cast(avg(e) AS integer))) else count(*) end | (min(t1.e)) | -count(*) from t1 union select max(t1.a) from t1))), -t1.b)+a FROM t1 WHERE NOT (not exists(select 1 from t1 where 11*d+a>=(t1.a-e+17*(select +cast(avg((select cast(avg((abs(case when (abs(t1.a)/abs(coalesce((select max(c+t1.e) from t1 where not exists(select 1 from t1 where 13 in (select -t1.c from t1 union select t1.f from t1))),17) | e*e)) not between e and t1.f then 19 else t1.b end)/abs(19))) AS integer)* -count(*) from t1)) AS integer)*count(distinct 11)-abs(cast(avg(b) AS integer)) from t1))))}
+} {300}
+do_test randexpr-2.1971 {
+ db eval {SELECT t1.d+coalesce((select max(t1.b*t1.b & ~case a & c & t1.d when t1.c then t1.a else t1.e end & e-13*b) from t1 where -t1.a in (select e from t1 union select t1.b from t1) and not exists(select 1 from t1 where (a) in (select min(13)* -cast(avg(t1.e) AS integer)*~case count(*) when count(*) then ((cast(avg(e) AS integer))) else count(*) end & (min(t1.e)) & -count(*) from t1 union select max(t1.a) from t1))), -t1.b)+a FROM t1 WHERE NOT (not exists(select 1 from t1 where 11*d+a>=(t1.a-e+17*(select +cast(avg((select cast(avg((abs(case when (abs(t1.a)/abs(coalesce((select max(c+t1.e) from t1 where not exists(select 1 from t1 where 13 in (select -t1.c from t1 union select t1.f from t1))),17) | e*e)) not between e and t1.f then 19 else t1.b end)/abs(19))) AS integer)* -count(*) from t1)) AS integer)*count(distinct 11)-abs(cast(avg(b) AS integer)) from t1))))}
+} {300}
+do_test randexpr-2.1972 {
+ db eval {SELECT ~case when case when +d+case b when 11 then coalesce((select max(b) from t1 where (((abs(f)/abs((abs(11)/abs(e))+t1.b))>t1.f))),(select max(t1.e) from t1)) else t1.f end*t1.f*17>=(t1.e) or 17>t1.f then t1.a else t1.a end in (c,13,c) then t1.f when t1.a not in (t1.d, -t1.b,a) then -t1.b else 11 end FROM t1 WHERE t1.a in (+e,17,11*13) and b not between t1.f*(abs(t1.c-((abs(t1.a | coalesce((select max(case when -f-t1.c<=t1.f then 19 when (t1.a)<>t1.f and 13 between a and t1.e then -11 else 17 end) from t1 where c>19),f)-t1.e)/abs(e))))/abs(b))-t1.e | (19) and -t1.a and t1.f in (select 13 from t1 union select a from t1)}
+} {}
+do_test randexpr-2.1973 {
+ db eval {SELECT ~case when case when +d+case b when 11 then coalesce((select max(b) from t1 where (((abs(f)/abs((abs(11)/abs(e))+t1.b))>t1.f))),(select max(t1.e) from t1)) else t1.f end*t1.f*17>=(t1.e) or 17>t1.f then t1.a else t1.a end in (c,13,c) then t1.f when t1.a not in (t1.d, -t1.b,a) then -t1.b else 11 end FROM t1 WHERE NOT (t1.a in (+e,17,11*13) and b not between t1.f*(abs(t1.c-((abs(t1.a | coalesce((select max(case when -f-t1.c<=t1.f then 19 when (t1.a)<>t1.f and 13 between a and t1.e then -11 else 17 end) from t1 where c>19),f)-t1.e)/abs(e))))/abs(b))-t1.e | (19) and -t1.a and t1.f in (select 13 from t1 union select a from t1))}
+} {-12}
+do_test randexpr-2.1974 {
+ db eval {SELECT case when case 17 when case when (abs(t1.c)/abs(t1.c | coalesce((select max(t1.d) from t1 where not t1.e<17 or 11 not in (t1.a,t1.c,a) or c=d and (t1.b)<f and t1.c>=t1.e and 17 in ( -t1.c,a,d) and t1.f not in (19,a,b)),11) | (select -max(+t1.b) from t1)+19-19 | f))<>t1.a or e>17 then f else a end then 11 else f end=t1.a then f else -t1.f end FROM t1 WHERE -t1.b+a>= -t1.a}
+} {-600}
+do_test randexpr-2.1975 {
+ db eval {SELECT case when case 17 when case when (abs(t1.c)/abs(t1.c | coalesce((select max(t1.d) from t1 where not t1.e<17 or 11 not in (t1.a,t1.c,a) or c=d and (t1.b)<f and t1.c>=t1.e and 17 in ( -t1.c,a,d) and t1.f not in (19,a,b)),11) | (select -max(+t1.b) from t1)+19-19 | f))<>t1.a or e>17 then f else a end then 11 else f end=t1.a then f else -t1.f end FROM t1 WHERE NOT ( -t1.b+a>= -t1.a)}
+} {}
+do_test randexpr-2.1976 {
+ db eval {SELECT (abs(coalesce((select ((t1.c)) from t1 where not exists(select 1 from t1 where t1.e*17<13*coalesce((select max(a) from t1 where 19 in (select max(e*11) from t1 union select cast(avg(t1.b) AS integer) from t1)),a | a))),case when f-13<d+17 and not exists(select 1 from t1 where e<= -13) or a between e and d then case t1.a when t1.b then f else t1.f end when - -t1.f<>t1.e then t1.b else f end))/abs(17)) FROM t1 WHERE ((d not between -a and b))}
+} {17}
+do_test randexpr-2.1977 {
+ db eval {SELECT (abs(coalesce((select ((t1.c)) from t1 where not exists(select 1 from t1 where t1.e*17<13*coalesce((select max(a) from t1 where 19 in (select max(e*11) from t1 union select cast(avg(t1.b) AS integer) from t1)),a | a))),case when f-13<d+17 and not exists(select 1 from t1 where e<= -13) or a between e and d then case t1.a when t1.b then f else t1.f end when - -t1.f<>t1.e then t1.b else f end))/abs(17)) FROM t1 WHERE NOT (((d not between -a and b)))}
+} {}
+do_test randexpr-2.1978 {
+ db eval {SELECT (abs(coalesce((select ((t1.c)) from t1 where not exists(select 1 from t1 where t1.e*17<13*coalesce((select max(a) from t1 where 19 in (select max(e*11) from t1 union select cast(avg(t1.b) AS integer) from t1)),a & a))),case when f-13<d+17 and not exists(select 1 from t1 where e<= -13) or a between e and d then case t1.a when t1.b then f else t1.f end when - -t1.f<>t1.e then t1.b else f end))/abs(17)) FROM t1 WHERE ((d not between -a and b))}
+} {17}
+do_test randexpr-2.1979 {
+ db eval {SELECT case f when (d)-case when coalesce((select max(coalesce((select 11 from t1 where case when (t1.f<=17 or exists(select 1 from t1 where 11 | d in (select (abs(max(t1.f))) from t1 union select ( -min(c)) from t1))) then a when t1.f not in (e,13,13) then t1.c else e end between 19 and c),t1.a)) from t1 where f>=t1.d),17) not between e and t1.c and 11<=17 then t1.e-19 when t1.a not in (c,t1.e,t1.c) then 11 else t1.b end then t1.e else t1.f end FROM t1 WHERE (not (case 17 when d then t1.c else c end=f | (select case count(*) when count(*)++max(11)+ -(abs(+cast(avg(c) AS integer)-(~count(*))+count(*)*(~case max( -c) when - -cast(avg(t1.f) AS integer) then (count(*)) else -max(t1.b) end*cast(avg(a) AS integer))-count(*) | ( -( -max(11)))) | ( -min(17))+count(*)) then (max(19)) else max(t1.c) end from t1)))}
+} {600}
+do_test randexpr-2.1980 {
+ db eval {SELECT case f when (d)-case when coalesce((select max(coalesce((select 11 from t1 where case when (t1.f<=17 or exists(select 1 from t1 where 11 | d in (select (abs(max(t1.f))) from t1 union select ( -min(c)) from t1))) then a when t1.f not in (e,13,13) then t1.c else e end between 19 and c),t1.a)) from t1 where f>=t1.d),17) not between e and t1.c and 11<=17 then t1.e-19 when t1.a not in (c,t1.e,t1.c) then 11 else t1.b end then t1.e else t1.f end FROM t1 WHERE NOT ((not (case 17 when d then t1.c else c end=f | (select case count(*) when count(*)++max(11)+ -(abs(+cast(avg(c) AS integer)-(~count(*))+count(*)*(~case max( -c) when - -cast(avg(t1.f) AS integer) then (count(*)) else -max(t1.b) end*cast(avg(a) AS integer))-count(*) | ( -( -max(11)))) | ( -min(17))+count(*)) then (max(19)) else max(t1.c) end from t1))))}
+} {}
+do_test randexpr-2.1981 {
+ db eval {SELECT case f when (d)-case when coalesce((select max(coalesce((select 11 from t1 where case when (t1.f<=17 or exists(select 1 from t1 where 11 & d in (select (abs(max(t1.f))) from t1 union select ( -min(c)) from t1))) then a when t1.f not in (e,13,13) then t1.c else e end between 19 and c),t1.a)) from t1 where f>=t1.d),17) not between e and t1.c and 11<=17 then t1.e-19 when t1.a not in (c,t1.e,t1.c) then 11 else t1.b end then t1.e else t1.f end FROM t1 WHERE (not (case 17 when d then t1.c else c end=f | (select case count(*) when count(*)++max(11)+ -(abs(+cast(avg(c) AS integer)-(~count(*))+count(*)*(~case max( -c) when - -cast(avg(t1.f) AS integer) then (count(*)) else -max(t1.b) end*cast(avg(a) AS integer))-count(*) | ( -( -max(11)))) | ( -min(17))+count(*)) then (max(19)) else max(t1.c) end from t1)))}
+} {600}
+do_test randexpr-2.1982 {
+ db eval {SELECT case when d+t1.d not between t1.f and + -t1.c then ~+a+(select +count(*) from t1) else (select +abs(count(*)) from t1)-t1.a end FROM t1 WHERE t1.b+f | d+a in (select +cast(avg(b) AS integer)++case min(coalesce((select t1.c from t1 where (e) in ((a)+17,t1.b,d)),t1.f)) when ~~cast(avg(17) AS integer)-max((t1.a)) then case min(13) when count(*) then count(distinct t1.a) else cast(avg(b) AS integer) end*max(d)+max(t1.b) else -count(*) end-count(*) from t1 union select cast(avg(t1.f) AS integer) from t1)}
+} {}
+do_test randexpr-2.1983 {
+ db eval {SELECT case when d+t1.d not between t1.f and + -t1.c then ~+a+(select +count(*) from t1) else (select +abs(count(*)) from t1)-t1.a end FROM t1 WHERE NOT (t1.b+f | d+a in (select +cast(avg(b) AS integer)++case min(coalesce((select t1.c from t1 where (e) in ((a)+17,t1.b,d)),t1.f)) when ~~cast(avg(17) AS integer)-max((t1.a)) then case min(13) when count(*) then count(distinct t1.a) else cast(avg(b) AS integer) end*max(d)+max(t1.b) else -count(*) end-count(*) from t1 union select cast(avg(t1.f) AS integer) from t1))}
+} {-100}
+do_test randexpr-2.1984 {
+ db eval {SELECT case when case when case case when (case when (( -f<t1.a)) and a between t1.b and 17 then c else +t1.c end-f+11+e between (17) and a) then t1.d else f end+t1.e*11-11 when -11 then 17 else f end in (select t1.d from t1 union select b from t1) then c when t1.d<=(a) then t1.e else -f end<t1.d then a else 11 end-19*f FROM t1 WHERE t1.b in (case +t1.f | d*~(case when b not between c and e+t1.d-coalesce((select -t1.f* -t1.c from t1 where (f in (select t1.d from t1 union select -t1.d from t1))),t1.b) then t1.c when not exists(select 1 from t1 where a<>t1.c or exists(select 1 from t1 where not exists(select 1 from t1 where (a not between b and -t1.e)) and t1.f>=(t1.a)) and t1.f<(t1.b)) then 19 else e end) when a then t1.e else 11 end,(a),19)}
+} {}
+do_test randexpr-2.1985 {
+ db eval {SELECT case when case when case case when (case when (( -f<t1.a)) and a between t1.b and 17 then c else +t1.c end-f+11+e between (17) and a) then t1.d else f end+t1.e*11-11 when -11 then 17 else f end in (select t1.d from t1 union select b from t1) then c when t1.d<=(a) then t1.e else -f end<t1.d then a else 11 end-19*f FROM t1 WHERE NOT (t1.b in (case +t1.f | d*~(case when b not between c and e+t1.d-coalesce((select -t1.f* -t1.c from t1 where (f in (select t1.d from t1 union select -t1.d from t1))),t1.b) then t1.c when not exists(select 1 from t1 where a<>t1.c or exists(select 1 from t1 where not exists(select 1 from t1 where (a not between b and -t1.e)) and t1.f>=(t1.a)) and t1.f<(t1.b)) then 19 else e end) when a then t1.e else 11 end,(a),19))}
+} {-11300}
+do_test randexpr-2.1986 {
+ db eval {SELECT coalesce((select 11 from t1 where 19 in (select ((count(*)*min(11)*(abs(max(a)))-max(b)*+count(*))) from t1 union select case abs(abs(min(t1.b))*case count(distinct b) when count(distinct t1.a) then count(distinct t1.f-t1.f) else max(11) end) when cast(avg(e) AS integer) then count(*) else count(*) end from t1)),d)*11+t1.c+b | 13+19 FROM t1 WHERE t1.c in (select 19 from t1 union select ~t1.f-t1.f+17- -17 from t1)}
+} {}
+do_test randexpr-2.1987 {
+ db eval {SELECT coalesce((select 11 from t1 where 19 in (select ((count(*)*min(11)*(abs(max(a)))-max(b)*+count(*))) from t1 union select case abs(abs(min(t1.b))*case count(distinct b) when count(distinct t1.a) then count(distinct t1.f-t1.f) else max(11) end) when cast(avg(e) AS integer) then count(*) else count(*) end from t1)),d)*11+t1.c+b | 13+19 FROM t1 WHERE NOT (t1.c in (select 19 from t1 union select ~t1.f-t1.f+17- -17 from t1))}
+} {4900}
+do_test randexpr-2.1988 {
+ db eval {SELECT coalesce((select 11 from t1 where 19 in (select ((count(*)*min(11)*(abs(max(a)))-max(b)*+count(*))) from t1 union select case abs(abs(min(t1.b))*case count(distinct b) when count(distinct t1.a) then count(distinct t1.f-t1.f) else max(11) end) when cast(avg(e) AS integer) then count(*) else count(*) end from t1)),d)*11+t1.c+b & 13+19 FROM t1 WHERE NOT (t1.c in (select 19 from t1 union select ~t1.f-t1.f+17- -17 from t1))}
+} {32}
+do_test randexpr-2.1989 {
+ db eval {SELECT case f when (select ++abs(max(d))+case case count(*) when min(t1.c) then (count(*)) else min(t1.e) end when -count(distinct t1.e) then count(distinct a) else min(t1.b) end from t1) then coalesce((select case when e in (select d from t1 union select f from t1) and t1.a not between b and 13 and d in (select 17 from t1 union select b from t1) then 17 when 11=f then 19 else d end from t1 where 11 not in (t1.c,t1.c,t1.d)),a) else e end-t1.e-t1.d-17*t1.f FROM t1 WHERE case when coalesce((select max(c) from t1 where 19 not between 11 and t1.e and t1.b in (select count(*) from t1 union select ~min(case c when (abs(case when d=( -t1.e) or t1.b<>t1.f then b else t1.b end)/abs(t1.c))+19 then t1.f else d end) from t1) and -b in (select min(17) from t1 union select min( -c) | count(distinct 17)- -(count(*))+max(t1.c) | -cast(avg(t1.c) AS integer) from t1)),t1.c)*t1.f not between -t1.e and t1.f then 11 else f end>f}
+} {}
+do_test randexpr-2.1990 {
+ db eval {SELECT case f when (select ++abs(max(d))+case case count(*) when min(t1.c) then (count(*)) else min(t1.e) end when -count(distinct t1.e) then count(distinct a) else min(t1.b) end from t1) then coalesce((select case when e in (select d from t1 union select f from t1) and t1.a not between b and 13 and d in (select 17 from t1 union select b from t1) then 17 when 11=f then 19 else d end from t1 where 11 not in (t1.c,t1.c,t1.d)),a) else e end-t1.e-t1.d-17*t1.f FROM t1 WHERE NOT (case when coalesce((select max(c) from t1 where 19 not between 11 and t1.e and t1.b in (select count(*) from t1 union select ~min(case c when (abs(case when d=( -t1.e) or t1.b<>t1.f then b else t1.b end)/abs(t1.c))+19 then t1.f else d end) from t1) and -b in (select min(17) from t1 union select min( -c) | count(distinct 17)- -(count(*))+max(t1.c) | -cast(avg(t1.c) AS integer) from t1)),t1.c)*t1.f not between -t1.e and t1.f then 11 else f end>f)}
+} {-10700}
+do_test randexpr-2.1991 {
+ db eval {SELECT case when ((coalesce((select t1.a from t1 where exists(select 1 from t1 where t1.a<=t1.b-e*coalesce((select max(a) from t1 where t1.e in (select min(13+13) from t1 union select -(count(distinct t1.f)-count(*)) from t1)),17)-f-t1.f) or t1.d in (select t1.a from t1 union select b from t1)),t1.d*t1.f)<>a)) then t1.d when not exists(select 1 from t1 where ((t1.f in (c,19,f)))) then t1.f else 17 end FROM t1 WHERE t1.c<=a}
+} {}
+do_test randexpr-2.1992 {
+ db eval {SELECT case when ((coalesce((select t1.a from t1 where exists(select 1 from t1 where t1.a<=t1.b-e*coalesce((select max(a) from t1 where t1.e in (select min(13+13) from t1 union select -(count(distinct t1.f)-count(*)) from t1)),17)-f-t1.f) or t1.d in (select t1.a from t1 union select b from t1)),t1.d*t1.f)<>a)) then t1.d when not exists(select 1 from t1 where ((t1.f in (c,19,f)))) then t1.f else 17 end FROM t1 WHERE NOT (t1.c<=a)}
+} {400}
+do_test randexpr-2.1993 {
+ db eval {SELECT case 17 when t1.f then 11 else (case when (c between case when ~t1.e+13-t1.c+case coalesce((select t1.c from t1 where t1.a not between a and 17),coalesce((select max(case when exists(select 1 from t1 where a>=t1.a) then ((t1.e)) when t1.e>=11 then 17 else t1.b end) from t1 where ( -11<e)),a)*t1.c) when t1.f then t1.d else b end | 13<t1.d then f else t1.f end and e) then case t1.b when t1.b then -t1.c else 17 end else t1.b end) end FROM t1 WHERE d- -coalesce((select max( -(17)+(t1.d)* -coalesce((select max(+d) from t1 where case when t1.e between 19 and t1.d then a when t1.d between t1.e and 17 then e else t1.c end+13 between a and t1.b or (c) in (select t1.b from t1 union select a from t1) or 11<>d),t1.c) | b- -17-(17)*c) from t1 where (19<13)),t1.c) not between a and t1.a}
+} {200}
+do_test randexpr-2.1994 {
+ db eval {SELECT case 17 when t1.f then 11 else (case when (c between case when ~t1.e+13-t1.c+case coalesce((select t1.c from t1 where t1.a not between a and 17),coalesce((select max(case when exists(select 1 from t1 where a>=t1.a) then ((t1.e)) when t1.e>=11 then 17 else t1.b end) from t1 where ( -11<e)),a)*t1.c) when t1.f then t1.d else b end | 13<t1.d then f else t1.f end and e) then case t1.b when t1.b then -t1.c else 17 end else t1.b end) end FROM t1 WHERE NOT (d- -coalesce((select max( -(17)+(t1.d)* -coalesce((select max(+d) from t1 where case when t1.e between 19 and t1.d then a when t1.d between t1.e and 17 then e else t1.c end+13 between a and t1.b or (c) in (select t1.b from t1 union select a from t1) or 11<>d),t1.c) | b- -17-(17)*c) from t1 where (19<13)),t1.c) not between a and t1.a)}
+} {}
+do_test randexpr-2.1995 {
+ db eval {SELECT case 17 when t1.f then 11 else (case when (c between case when ~t1.e+13-t1.c+case coalesce((select t1.c from t1 where t1.a not between a and 17),coalesce((select max(case when exists(select 1 from t1 where a>=t1.a) then ((t1.e)) when t1.e>=11 then 17 else t1.b end) from t1 where ( -11<e)),a)*t1.c) when t1.f then t1.d else b end & 13<t1.d then f else t1.f end and e) then case t1.b when t1.b then -t1.c else 17 end else t1.b end) end FROM t1 WHERE d- -coalesce((select max( -(17)+(t1.d)* -coalesce((select max(+d) from t1 where case when t1.e between 19 and t1.d then a when t1.d between t1.e and 17 then e else t1.c end+13 between a and t1.b or (c) in (select t1.b from t1 union select a from t1) or 11<>d),t1.c) | b- -17-(17)*c) from t1 where (19<13)),t1.c) not between a and t1.a}
+} {200}
+do_test randexpr-2.1996 {
+ db eval {SELECT 17+(select case ~max((abs(t1.c+coalesce((select max(t1.f) from t1 where t1.f in (select 13-c-case when not a>=t1.c then f else t1.c end+t1.c from t1 union select 19 from t1) or exists(select 1 from t1 where 13<t1.e)),17)*(19))/abs(b))) when ~abs( -+max(t1.a)) then +abs(cast(avg(t1.e) AS integer)) | ~abs(~cast(avg(b) AS integer)) else cast(avg(t1.f) AS integer) end from t1) | t1.d FROM t1 WHERE (case when case when 13<>17 | e*d-17*t1.e*case a when case when (not f>=19 and t1.f<=t1.b) then coalesce((select case 11 when -c then t1.f else (t1.f) end from t1 where 13 between t1.e and t1.f),(e)) when -t1.f not between b and d then t1.d else t1.a end then 11 else 19 end then d when a<t1.d then 19 else 11 end=t1.e then t1.a else t1.d end+f>d)}
+} {1017}
+do_test randexpr-2.1997 {
+ db eval {SELECT 17+(select case ~max((abs(t1.c+coalesce((select max(t1.f) from t1 where t1.f in (select 13-c-case when not a>=t1.c then f else t1.c end+t1.c from t1 union select 19 from t1) or exists(select 1 from t1 where 13<t1.e)),17)*(19))/abs(b))) when ~abs( -+max(t1.a)) then +abs(cast(avg(t1.e) AS integer)) | ~abs(~cast(avg(b) AS integer)) else cast(avg(t1.f) AS integer) end from t1) | t1.d FROM t1 WHERE NOT ((case when case when 13<>17 | e*d-17*t1.e*case a when case when (not f>=19 and t1.f<=t1.b) then coalesce((select case 11 when -c then t1.f else (t1.f) end from t1 where 13 between t1.e and t1.f),(e)) when -t1.f not between b and d then t1.d else t1.a end then 11 else 19 end then d when a<t1.d then 19 else 11 end=t1.e then t1.a else t1.d end+f>d))}
+} {}
+do_test randexpr-2.1998 {
+ db eval {SELECT 17+(select case ~max((abs(t1.c+coalesce((select max(t1.f) from t1 where t1.f in (select 13-c-case when not a>=t1.c then f else t1.c end+t1.c from t1 union select 19 from t1) or exists(select 1 from t1 where 13<t1.e)),17)*(19))/abs(b))) when ~abs( -+max(t1.a)) then +abs(cast(avg(t1.e) AS integer)) & ~abs(~cast(avg(b) AS integer)) else cast(avg(t1.f) AS integer) end from t1) & t1.d FROM t1 WHERE (case when case when 13<>17 | e*d-17*t1.e*case a when case when (not f>=19 and t1.f<=t1.b) then coalesce((select case 11 when -c then t1.f else (t1.f) end from t1 where 13 between t1.e and t1.f),(e)) when -t1.f not between b and d then t1.d else t1.a end then 11 else 19 end then d when a<t1.d then 19 else 11 end=t1.e then t1.a else t1.d end+f>d)}
+} {0}
+do_test randexpr-2.1999 {
+ db eval {SELECT ~c-t1.a*case -case 19 when d then t1.f else t1.a end-d when 11 then coalesce((select max(case when (case when exists(select 1 from t1 where 11*11>13) then t1.c else 11 end)<=(select min(~d+case 19 when e then 13 else e end) from t1) then c when ((f))<=17 then d else t1.c end+t1.f) from t1 where (t1.b between -c and t1.e)),t1.e) else 17 end FROM t1 WHERE +(abs(d-(select cast(avg((select (abs(max(t1.d*+d*( -e*(13)) | 17)+ -min(t1.d)+~ - -max(17) | max(t1.a) | -count(distinct t1.a)-count(distinct 13)*(count(distinct t1.a)) | (count(distinct 17)))) from t1)) AS integer) from t1)-11)/abs(c+d-t1.e))>=t1.d}
+} {}
+do_test randexpr-2.2000 {
+ db eval {SELECT ~c-t1.a*case -case 19 when d then t1.f else t1.a end-d when 11 then coalesce((select max(case when (case when exists(select 1 from t1 where 11*11>13) then t1.c else 11 end)<=(select min(~d+case 19 when e then 13 else e end) from t1) then c when ((f))<=17 then d else t1.c end+t1.f) from t1 where (t1.b between -c and t1.e)),t1.e) else 17 end FROM t1 WHERE NOT (+(abs(d-(select cast(avg((select (abs(max(t1.d*+d*( -e*(13)) | 17)+ -min(t1.d)+~ - -max(17) | max(t1.a) | -count(distinct t1.a)-count(distinct 13)*(count(distinct t1.a)) | (count(distinct 17)))) from t1)) AS integer) from t1)-11)/abs(c+d-t1.e))>=t1.d)}
+} {-2001}
+do_test randexpr-2.2001 {
+ db eval {SELECT coalesce((select 11 from t1 where a not in (17,e,(select -abs(case ( -count(distinct t1.e)) when count(distinct 13) | max((abs(case 11 when -(abs(19)/abs(17 | t1.c*t1.e))*t1.c | t1.b then a else +d end)/abs(b*t1.a))) then max(c*13) else cast(avg(t1.f) AS integer) end)-max(11) from t1)*d)),t1.d) FROM t1 WHERE 19-c*coalesce((select max(case (select count(distinct t1.f) from t1) | t1.a when case a when (abs(case when not c+t1.d>=e then 17*t1.e+a when not exists(select 1 from t1 where 11>b) then c else a end)/abs(t1.e))+t1.f*13 then 11 else t1.f end then 19 else d end-b) from t1 where (d) not between f and e),t1.d)= -c}
+} {}
+do_test randexpr-2.2002 {
+ db eval {SELECT coalesce((select 11 from t1 where a not in (17,e,(select -abs(case ( -count(distinct t1.e)) when count(distinct 13) | max((abs(case 11 when -(abs(19)/abs(17 | t1.c*t1.e))*t1.c | t1.b then a else +d end)/abs(b*t1.a))) then max(c*13) else cast(avg(t1.f) AS integer) end)-max(11) from t1)*d)),t1.d) FROM t1 WHERE NOT (19-c*coalesce((select max(case (select count(distinct t1.f) from t1) | t1.a when case a when (abs(case when not c+t1.d>=e then 17*t1.e+a when not exists(select 1 from t1 where 11>b) then c else a end)/abs(t1.e))+t1.f*13 then 11 else t1.f end then 19 else d end-b) from t1 where (d) not between f and e),t1.d)= -c)}
+} {11}
+do_test randexpr-2.2003 {
+ db eval {SELECT coalesce((select 11 from t1 where a not in (17,e,(select -abs(case ( -count(distinct t1.e)) when count(distinct 13) & max((abs(case 11 when -(abs(19)/abs(17 & t1.c*t1.e))*t1.c & t1.b then a else +d end)/abs(b*t1.a))) then max(c*13) else cast(avg(t1.f) AS integer) end)-max(11) from t1)*d)),t1.d) FROM t1 WHERE NOT (19-c*coalesce((select max(case (select count(distinct t1.f) from t1) | t1.a when case a when (abs(case when not c+t1.d>=e then 17*t1.e+a when not exists(select 1 from t1 where 11>b) then c else a end)/abs(t1.e))+t1.f*13 then 11 else t1.f end then 19 else d end-b) from t1 where (d) not between f and e),t1.d)= -c)}
+} {11}
+do_test randexpr-2.2004 {
+ db eval {SELECT 11+t1.b*~c*17-13-a+t1.d | t1.f+t1.b*coalesce((select 17 from t1 where t1.e in (select (select cast(avg(case case e when (t1.d) then 17 else (abs((abs(case when d<t1.d then b when t1.c<>19 then 19 else a end)/abs(f)))/abs((t1.e))) end when b then (11) else f end+17) AS integer) from t1) from t1 union select t1.c from t1)),(17)) FROM t1 WHERE e=11}
+} {}
+do_test randexpr-2.2005 {
+ db eval {SELECT 11+t1.b*~c*17-13-a+t1.d | t1.f+t1.b*coalesce((select 17 from t1 where t1.e in (select (select cast(avg(case case e when (t1.d) then 17 else (abs((abs(case when d<t1.d then b when t1.c<>19 then 19 else a end)/abs(f)))/abs((t1.e))) end when b then (11) else f end+17) AS integer) from t1) from t1 union select t1.c from t1)),(17)) FROM t1 WHERE NOT (e=11)}
+} {-1019998}
+do_test randexpr-2.2006 {
+ db eval {SELECT 11+t1.b*~c*17-13-a+t1.d & t1.f+t1.b*coalesce((select 17 from t1 where t1.e in (select (select cast(avg(case case e when (t1.d) then 17 else (abs((abs(case when d<t1.d then b when t1.c<>19 then 19 else a end)/abs(f)))/abs((t1.e))) end when b then (11) else f end+17) AS integer) from t1) from t1 union select t1.c from t1)),(17)) FROM t1 WHERE NOT (e=11)}
+} {896}
+do_test randexpr-2.2007 {
+ db eval {SELECT e*~~(coalesce((select +case when not exists(select 1 from t1 where 13*coalesce((select max(coalesce((select max(11) from t1 where not exists(select 1 from t1 where (select -count(distinct 11) | min(11) from t1)>case b when b then c else d end)),13)) from t1 where -c<>d),13)<>t1.f and 13 between 13 and 19) then b-t1.e+e else (t1.f) end from t1 where ((not not e>t1.c and c not between a and e))),t1.d)) FROM t1 WHERE exists(select 1 from t1 where case when case when e<c then -coalesce((select max((abs(17)/abs(coalesce((select max(d) from t1 where (abs(13)/abs(t1.b)) between 11 and e),19)*f+d))*t1.f) from t1 where not exists(select 1 from t1 where 11 not in (t1.d, -t1.a,11))),t1.b)-e when (t1.c=17) then b else e end=f then d else t1.b end<=t1.d or t1.a<> -b)}
+} {200000}
+do_test randexpr-2.2008 {
+ db eval {SELECT e*~~(coalesce((select +case when not exists(select 1 from t1 where 13*coalesce((select max(coalesce((select max(11) from t1 where not exists(select 1 from t1 where (select -count(distinct 11) | min(11) from t1)>case b when b then c else d end)),13)) from t1 where -c<>d),13)<>t1.f and 13 between 13 and 19) then b-t1.e+e else (t1.f) end from t1 where ((not not e>t1.c and c not between a and e))),t1.d)) FROM t1 WHERE NOT (exists(select 1 from t1 where case when case when e<c then -coalesce((select max((abs(17)/abs(coalesce((select max(d) from t1 where (abs(13)/abs(t1.b)) between 11 and e),19)*f+d))*t1.f) from t1 where not exists(select 1 from t1 where 11 not in (t1.d, -t1.a,11))),t1.b)-e when (t1.c=17) then b else e end=f then d else t1.b end<=t1.d or t1.a<> -b))}
+} {}
+do_test randexpr-2.2009 {
+ db eval {SELECT e*~~(coalesce((select +case when not exists(select 1 from t1 where 13*coalesce((select max(coalesce((select max(11) from t1 where not exists(select 1 from t1 where (select -count(distinct 11) & min(11) from t1)>case b when b then c else d end)),13)) from t1 where -c<>d),13)<>t1.f and 13 between 13 and 19) then b-t1.e+e else (t1.f) end from t1 where ((not not e>t1.c and c not between a and e))),t1.d)) FROM t1 WHERE exists(select 1 from t1 where case when case when e<c then -coalesce((select max((abs(17)/abs(coalesce((select max(d) from t1 where (abs(13)/abs(t1.b)) between 11 and e),19)*f+d))*t1.f) from t1 where not exists(select 1 from t1 where 11 not in (t1.d, -t1.a,11))),t1.b)-e when (t1.c=17) then b else e end=f then d else t1.b end<=t1.d or t1.a<> -b)}
+} {200000}
+do_test randexpr-2.2010 {
+ db eval {SELECT (case t1.b-coalesce((select max(t1.f) from t1 where +t1.c=e or coalesce((select max(t1.a) from t1 where exists(select 1 from t1 where ((13-(select +cast(avg( -t1.b) AS integer) from t1) in (case f when (19) then t1.f else t1.f end,11,t1.e))))),(t1.a)+t1.e) not in (t1.f,t1.a,b) and t1.e not in (11,t1.b,t1.b)),d) when 19 then t1.e else c end-t1.e*t1.f) FROM t1 WHERE t1.e<t1.e}
+} {}
+do_test randexpr-2.2011 {
+ db eval {SELECT (case t1.b-coalesce((select max(t1.f) from t1 where +t1.c=e or coalesce((select max(t1.a) from t1 where exists(select 1 from t1 where ((13-(select +cast(avg( -t1.b) AS integer) from t1) in (case f when (19) then t1.f else t1.f end,11,t1.e))))),(t1.a)+t1.e) not in (t1.f,t1.a,b) and t1.e not in (11,t1.b,t1.b)),d) when 19 then t1.e else c end-t1.e*t1.f) FROM t1 WHERE NOT (t1.e<t1.e)}
+} {-299700}
+do_test randexpr-2.2012 {
+ db eval {SELECT t1.a+e-case when 19<+17 then case when 19 not between t1.e and t1.e then (abs(case when e+17*(select count(distinct (abs(+17)/abs(t1.c))) from t1)<>coalesce((select max(f) from t1 where 19>=b),19) then f else t1.e end-f)/abs(t1.a))-11 else t1.e end when exists(select 1 from t1 where not exists(select 1 from t1 where ((c)) not in (b,a,e))) then t1.c else ((11)) end FROM t1 WHERE (not 13 not in (17,a,e))}
+} {}
+do_test randexpr-2.2013 {
+ db eval {SELECT t1.a+e-case when 19<+17 then case when 19 not between t1.e and t1.e then (abs(case when e+17*(select count(distinct (abs(+17)/abs(t1.c))) from t1)<>coalesce((select max(f) from t1 where 19>=b),19) then f else t1.e end-f)/abs(t1.a))-11 else t1.e end when exists(select 1 from t1 where not exists(select 1 from t1 where ((c)) not in (b,a,e))) then t1.c else ((11)) end FROM t1 WHERE NOT ((not 13 not in (17,a,e)))}
+} {589}
+do_test randexpr-2.2014 {
+ db eval {SELECT case when not exists(select 1 from t1 where case when -~(19)=t1.c then t1.f*~case when t1.f<=(select max(t1.c) from t1) then e when (c<>13) then t1.a else (b) end when t1.b between 19 and 17 then 17 else e end-e+t1.a>e or -19 in (select max(13) from t1 union select min( -19) from t1)) then t1.b when -11>=a then ~b else 19 end FROM t1 WHERE (c not between coalesce((select max(c) from t1 where (not t1.c<>t1.a)), -(abs(case when t1.e<=t1.c then t1.d when exists(select 1 from t1 where 17 in (select case when coalesce((select c from t1 where 17-t1.a-coalesce((select 17 from t1 where t1.f in (t1.b,19,t1.c)),17) not between e and 13),t1.b) not in (e,13,t1.a) then t1.c else b end | f from t1 union select t1.f from t1)) then t1.f else 11 end)/abs(t1.a))) and t1.e)}
+} {}
+do_test randexpr-2.2015 {
+ db eval {SELECT case when not exists(select 1 from t1 where case when -~(19)=t1.c then t1.f*~case when t1.f<=(select max(t1.c) from t1) then e when (c<>13) then t1.a else (b) end when t1.b between 19 and 17 then 17 else e end-e+t1.a>e or -19 in (select max(13) from t1 union select min( -19) from t1)) then t1.b when -11>=a then ~b else 19 end FROM t1 WHERE NOT ((c not between coalesce((select max(c) from t1 where (not t1.c<>t1.a)), -(abs(case when t1.e<=t1.c then t1.d when exists(select 1 from t1 where 17 in (select case when coalesce((select c from t1 where 17-t1.a-coalesce((select 17 from t1 where t1.f in (t1.b,19,t1.c)),17) not between e and 13),t1.b) not in (e,13,t1.a) then t1.c else b end | f from t1 union select t1.f from t1)) then t1.f else 11 end)/abs(t1.a))) and t1.e))}
+} {19}
+do_test randexpr-2.2016 {
+ db eval {SELECT case t1.c | t1.b when t1.f-c then case when c<t1.c then t1.e when not t1.f in (select case when exists(select 1 from t1 where t1.e<=coalesce((select (select case count(distinct -e*a) when ~( -min(11)) then count(*) else count(*) end from t1) from t1 where (b-d<= -t1.f)),t1.e) or exists(select 1 from t1 where t1.d>=11) or t1.c<=t1.e) then + - -b+11 else 13 end from t1 union select (t1.c) from t1) then 17 else 11 end else t1.a end FROM t1 WHERE t1.f | 13+coalesce((select max(11) from t1 where e>=(select ~case cast(avg(19*f+(c)) AS integer) when (min(c))-min(t1.a) then cast(avg(13) AS integer) else count(distinct e) end from t1)),t1.f)>=coalesce((select c from t1 where (exists(select 1 from t1 where t1.f>=f and (t1.d)<>t1.a))),c) or not exists(select 1 from t1 where not 11>=t1.d) or (b between c and 11 and 11< -t1.b and t1.e>=t1.b) or t1.c>e}
+} {100}
+do_test randexpr-2.2017 {
+ db eval {SELECT case t1.c | t1.b when t1.f-c then case when c<t1.c then t1.e when not t1.f in (select case when exists(select 1 from t1 where t1.e<=coalesce((select (select case count(distinct -e*a) when ~( -min(11)) then count(*) else count(*) end from t1) from t1 where (b-d<= -t1.f)),t1.e) or exists(select 1 from t1 where t1.d>=11) or t1.c<=t1.e) then + - -b+11 else 13 end from t1 union select (t1.c) from t1) then 17 else 11 end else t1.a end FROM t1 WHERE NOT (t1.f | 13+coalesce((select max(11) from t1 where e>=(select ~case cast(avg(19*f+(c)) AS integer) when (min(c))-min(t1.a) then cast(avg(13) AS integer) else count(distinct e) end from t1)),t1.f)>=coalesce((select c from t1 where (exists(select 1 from t1 where t1.f>=f and (t1.d)<>t1.a))),c) or not exists(select 1 from t1 where not 11>=t1.d) or (b between c and 11 and 11< -t1.b and t1.e>=t1.b) or t1.c>e)}
+} {}
+do_test randexpr-2.2018 {
+ db eval {SELECT case t1.c & t1.b when t1.f-c then case when c<t1.c then t1.e when not t1.f in (select case when exists(select 1 from t1 where t1.e<=coalesce((select (select case count(distinct -e*a) when ~( -min(11)) then count(*) else count(*) end from t1) from t1 where (b-d<= -t1.f)),t1.e) or exists(select 1 from t1 where t1.d>=11) or t1.c<=t1.e) then + - -b+11 else 13 end from t1 union select (t1.c) from t1) then 17 else 11 end else t1.a end FROM t1 WHERE t1.f | 13+coalesce((select max(11) from t1 where e>=(select ~case cast(avg(19*f+(c)) AS integer) when (min(c))-min(t1.a) then cast(avg(13) AS integer) else count(distinct e) end from t1)),t1.f)>=coalesce((select c from t1 where (exists(select 1 from t1 where t1.f>=f and (t1.d)<>t1.a))),c) or not exists(select 1 from t1 where not 11>=t1.d) or (b between c and 11 and 11< -t1.b and t1.e>=t1.b) or t1.c>e}
+} {100}
+do_test randexpr-2.2019 {
+ db eval {SELECT coalesce((select 19 from t1 where a<=case (abs(e)/abs(case b+f when b then t1.e else e end)) when + -t1.b+coalesce((select max(t1.f) from t1 where (19<=+e) and (c*b)>= -t1.e and (c>=c)),11+(e)+a)-t1.b then 17 else 17 end-t1.e),a) FROM t1 WHERE +d*t1.f+c+t1.c*13<>t1.e}
+} {100}
+do_test randexpr-2.2020 {
+ db eval {SELECT coalesce((select 19 from t1 where a<=case (abs(e)/abs(case b+f when b then t1.e else e end)) when + -t1.b+coalesce((select max(t1.f) from t1 where (19<=+e) and (c*b)>= -t1.e and (c>=c)),11+(e)+a)-t1.b then 17 else 17 end-t1.e),a) FROM t1 WHERE NOT (+d*t1.f+c+t1.c*13<>t1.e)}
+} {}
+do_test randexpr-2.2021 {
+ db eval {SELECT (abs(t1.e)/abs(coalesce((select +t1.a*c from t1 where (abs(e)/abs(d)) in (select +~count(*)-min(t1.d) from t1 union select abs(abs(cast(avg(t1.b) AS integer))+cast(avg(b) AS integer)) from t1)),d))) FROM t1 WHERE not b not between (select max(13) from t1) and 13}
+} {}
+do_test randexpr-2.2022 {
+ db eval {SELECT (abs(t1.e)/abs(coalesce((select +t1.a*c from t1 where (abs(e)/abs(d)) in (select +~count(*)-min(t1.d) from t1 union select abs(abs(cast(avg(t1.b) AS integer))+cast(avg(b) AS integer)) from t1)),d))) FROM t1 WHERE NOT (not b not between (select max(13) from t1) and 13)}
+} {1}
+do_test randexpr-2.2023 {
+ db eval {SELECT +(select +~(count(distinct (abs((abs(coalesce((select max(t1.c) from t1 where -e in (select t1.e from t1 union select (e) from t1)),c)-11)/abs(19))*t1.c)/abs(19))))*count(distinct t1.a)*+count(distinct a)*count(distinct t1.d) | count(*)-max(11)+cast(avg(t1.b) AS integer)*min(t1.a) from t1)+19+t1.c*19+~coalesce((select e from t1 where 13 in (select count(distinct 17) from t1 union select count(distinct 11) from t1) or t1.f<>c),17) FROM t1 WHERE exists(select 1 from t1 where coalesce((select t1.f from t1 where t1.a in (case when exists(select 1 from t1 where b*t1.e in (select (t1.a) from t1 union select (case -13 when f then t1.b else t1.a end) from t1)) then t1.d else 17 end,d,11)),c) not in (17,19,t1.b)) or (b) in (select abs(~~abs(count(*)) | - -min(c)-min(11)+count(*) | max(a) | count(*)-count(distinct 11)) from t1 union select max(t1.f) from t1) or t1.b>=19}
+} {5216}
+do_test randexpr-2.2024 {
+ db eval {SELECT +(select +~(count(distinct (abs((abs(coalesce((select max(t1.c) from t1 where -e in (select t1.e from t1 union select (e) from t1)),c)-11)/abs(19))*t1.c)/abs(19))))*count(distinct t1.a)*+count(distinct a)*count(distinct t1.d) | count(*)-max(11)+cast(avg(t1.b) AS integer)*min(t1.a) from t1)+19+t1.c*19+~coalesce((select e from t1 where 13 in (select count(distinct 17) from t1 union select count(distinct 11) from t1) or t1.f<>c),17) FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select t1.f from t1 where t1.a in (case when exists(select 1 from t1 where b*t1.e in (select (t1.a) from t1 union select (case -13 when f then t1.b else t1.a end) from t1)) then t1.d else 17 end,d,11)),c) not in (17,19,t1.b)) or (b) in (select abs(~~abs(count(*)) | - -min(c)-min(11)+count(*) | max(a) | count(*)-count(distinct 11)) from t1 union select max(t1.f) from t1) or t1.b>=19)}
+} {}
+do_test randexpr-2.2025 {
+ db eval {SELECT +(select +~(count(distinct (abs((abs(coalesce((select max(t1.c) from t1 where -e in (select t1.e from t1 union select (e) from t1)),c)-11)/abs(19))*t1.c)/abs(19))))*count(distinct t1.a)*+count(distinct a)*count(distinct t1.d) & count(*)-max(11)+cast(avg(t1.b) AS integer)*min(t1.a) from t1)+19+t1.c*19+~coalesce((select e from t1 where 13 in (select count(distinct 17) from t1 union select count(distinct 11) from t1) or t1.f<>c),17) FROM t1 WHERE exists(select 1 from t1 where coalesce((select t1.f from t1 where t1.a in (case when exists(select 1 from t1 where b*t1.e in (select (t1.a) from t1 union select (case -13 when f then t1.b else t1.a end) from t1)) then t1.d else 17 end,d,11)),c) not in (17,19,t1.b)) or (b) in (select abs(~~abs(count(*)) | - -min(c)-min(11)+count(*) | max(a) | count(*)-count(distinct 11)) from t1 union select max(t1.f) from t1) or t1.b>=19}
+} {25208}
+do_test randexpr-2.2026 {
+ db eval {SELECT (abs(case t1.c when ~coalesce((select max(case coalesce((select max(b) from t1 where not a<b or e*coalesce((select case t1.d when c then e else 13 end from t1 where not t1.c in (select t1.e from t1 union select 11 from t1)),(d))+c in (select +min(t1.d) from t1 union select cast(avg(13) AS integer) from t1)),e-f)*e when t1.e then t1.f else 19 end) from t1 where e>a),e) then 17 else a end)/abs(19)) FROM t1 WHERE d not in (d,d+case coalesce((select t1.e from t1 where (case when 17*case case f-+t1.c+coalesce((select t1.c from t1 where t1.d<e),t1.e) when -t1.d then e else t1.f end when d then t1.c else -17 end*17*b<=t1.f then b when t1.a<e then 11 else 13 end>f)),d) when t1.e then (t1.c) else -e end,t1.f)}
+} {}
+do_test randexpr-2.2027 {
+ db eval {SELECT (abs(case t1.c when ~coalesce((select max(case coalesce((select max(b) from t1 where not a<b or e*coalesce((select case t1.d when c then e else 13 end from t1 where not t1.c in (select t1.e from t1 union select 11 from t1)),(d))+c in (select +min(t1.d) from t1 union select cast(avg(13) AS integer) from t1)),e-f)*e when t1.e then t1.f else 19 end) from t1 where e>a),e) then 17 else a end)/abs(19)) FROM t1 WHERE NOT (d not in (d,d+case coalesce((select t1.e from t1 where (case when 17*case case f-+t1.c+coalesce((select t1.c from t1 where t1.d<e),t1.e) when -t1.d then e else t1.f end when d then t1.c else -17 end*17*b<=t1.f then b when t1.a<e then 11 else 13 end>f)),d) when t1.e then (t1.c) else -e end,t1.f))}
+} {5}
+do_test randexpr-2.2028 {
+ db eval {SELECT case 13 when 13 then case when 11 between case case when not 17 not between f-t1.e and (abs(19)/abs(((t1.b))))*19 then t1.a when exists(select 1 from t1 where t1.e not between d and 13) then t1.c else -e end when t1.e then t1.c else e end and 17 then 19 when not exists(select 1 from t1 where 11=f) and exists(select 1 from t1 where d<>t1.a) or t1.f>=17 then a else t1.e end else 19 end*11 FROM t1 WHERE case 17 when t1.f then 11 else c end+d=t1.f}
+} {}
+do_test randexpr-2.2029 {
+ db eval {SELECT case 13 when 13 then case when 11 between case case when not 17 not between f-t1.e and (abs(19)/abs(((t1.b))))*19 then t1.a when exists(select 1 from t1 where t1.e not between d and 13) then t1.c else -e end when t1.e then t1.c else e end and 17 then 19 when not exists(select 1 from t1 where 11=f) and exists(select 1 from t1 where d<>t1.a) or t1.f>=17 then a else t1.e end else 19 end*11 FROM t1 WHERE NOT (case 17 when t1.f then 11 else c end+d=t1.f)}
+} {1100}
+do_test randexpr-2.2030 {
+ db eval {SELECT coalesce((select max(b-case when exists(select 1 from t1 where case when t1.c>t1.b then t1.c*19 else coalesce((select max((abs(t1.a)/abs(~(select +max(t1.c)*max(a)*cast(avg(t1.d) AS integer) from t1)+case when e=t1.c or t1.c between e and b then +a else 13 end))) from t1 where 17=b),t1.a) end not between f and t1.c) then c else e end+ - -d-17) from t1 where t1.e<d),17) FROM t1 WHERE -a>=(select cast(avg(d) AS integer) from t1)}
+} {}
+do_test randexpr-2.2031 {
+ db eval {SELECT coalesce((select max(b-case when exists(select 1 from t1 where case when t1.c>t1.b then t1.c*19 else coalesce((select max((abs(t1.a)/abs(~(select +max(t1.c)*max(a)*cast(avg(t1.d) AS integer) from t1)+case when e=t1.c or t1.c between e and b then +a else 13 end))) from t1 where 17=b),t1.a) end not between f and t1.c) then c else e end+ - -d-17) from t1 where t1.e<d),17) FROM t1 WHERE NOT ( -a>=(select cast(avg(d) AS integer) from t1))}
+} {17}
+do_test randexpr-2.2032 {
+ db eval {SELECT case when -13 in (select +case when case when exists(select 1 from t1 where ~coalesce((select t1.f from t1 where exists(select 1 from t1 where t1.a not between t1.b and -t1.e)),t1.c)+c | b not between f and t1.b) then -11-19 else t1.d end in (select ~abs(max(19))+cast(avg(e) AS integer)-max(13)-count(*) from t1 union select min(f) from t1) then t1.f else b end+t1.e from t1 union select t1.f from t1) then b when e<t1.f then d else t1.f end+11 FROM t1 WHERE (select count(distinct +t1.e) from t1) in (select max(coalesce((select case when exists(select 1 from t1 where +19*a<>(select count(distinct d) from t1)) then t1.a when +(select cast(avg(e-19*~case 19 when t1.f then (t1.d) else t1.e end*t1.d*c) AS integer) from t1) in (e,t1.c,t1.e) then 13 else a end from t1 where d not between t1.b and f),a)) from t1 union select min((t1.b)) from t1) or (t1.e<=13)}
+} {}
+do_test randexpr-2.2033 {
+ db eval {SELECT case when -13 in (select +case when case when exists(select 1 from t1 where ~coalesce((select t1.f from t1 where exists(select 1 from t1 where t1.a not between t1.b and -t1.e)),t1.c)+c | b not between f and t1.b) then -11-19 else t1.d end in (select ~abs(max(19))+cast(avg(e) AS integer)-max(13)-count(*) from t1 union select min(f) from t1) then t1.f else b end+t1.e from t1 union select t1.f from t1) then b when e<t1.f then d else t1.f end+11 FROM t1 WHERE NOT ((select count(distinct +t1.e) from t1) in (select max(coalesce((select case when exists(select 1 from t1 where +19*a<>(select count(distinct d) from t1)) then t1.a when +(select cast(avg(e-19*~case 19 when t1.f then (t1.d) else t1.e end*t1.d*c) AS integer) from t1) in (e,t1.c,t1.e) then 13 else a end from t1 where d not between t1.b and f),a)) from t1 union select min((t1.b)) from t1) or (t1.e<=13))}
+} {411}
+do_test randexpr-2.2034 {
+ db eval {SELECT case when -13 in (select +case when case when exists(select 1 from t1 where ~coalesce((select t1.f from t1 where exists(select 1 from t1 where t1.a not between t1.b and -t1.e)),t1.c)+c & b not between f and t1.b) then -11-19 else t1.d end in (select ~abs(max(19))+cast(avg(e) AS integer)-max(13)-count(*) from t1 union select min(f) from t1) then t1.f else b end+t1.e from t1 union select t1.f from t1) then b when e<t1.f then d else t1.f end+11 FROM t1 WHERE NOT ((select count(distinct +t1.e) from t1) in (select max(coalesce((select case when exists(select 1 from t1 where +19*a<>(select count(distinct d) from t1)) then t1.a when +(select cast(avg(e-19*~case 19 when t1.f then (t1.d) else t1.e end*t1.d*c) AS integer) from t1) in (e,t1.c,t1.e) then 13 else a end from t1 where d not between t1.b and f),a)) from t1 union select min((t1.b)) from t1) or (t1.e<=13))}
+} {411}
+do_test randexpr-2.2035 {
+ db eval {SELECT (+coalesce((select max(c) from t1 where case when ( -t1.f between t1.a | -a*(abs(11 | e+case when not exists(select 1 from t1 where t1.b<>f or a=t1.a) then 17*(a) else 17 end*c)/abs(c))-d+f* -e-t1.a and b) then -11-a else t1.a end*19+b | t1.a<=t1.e),t1.b)) FROM t1 WHERE t1.e between -case when e not in (t1.e,case when d+t1.c-b-t1.b+case when -e<f then + -t1.c*t1.d+a*13*e when ( -t1.f<=a) then f else 13 end*t1.e-a-t1.b<(t1.e) then t1.d else t1.d end,t1.f) then f else t1.d end and t1.c}
+} {}
+do_test randexpr-2.2036 {
+ db eval {SELECT (+coalesce((select max(c) from t1 where case when ( -t1.f between t1.a | -a*(abs(11 | e+case when not exists(select 1 from t1 where t1.b<>f or a=t1.a) then 17*(a) else 17 end*c)/abs(c))-d+f* -e-t1.a and b) then -11-a else t1.a end*19+b | t1.a<=t1.e),t1.b)) FROM t1 WHERE NOT (t1.e between -case when e not in (t1.e,case when d+t1.c-b-t1.b+case when -e<f then + -t1.c*t1.d+a*13*e when ( -t1.f<=a) then f else 13 end*t1.e-a-t1.b<(t1.e) then t1.d else t1.d end,t1.f) then f else t1.d end and t1.c)}
+} {300}
+do_test randexpr-2.2037 {
+ db eval {SELECT (+coalesce((select max(c) from t1 where case when ( -t1.f between t1.a & -a*(abs(11 & e+case when not exists(select 1 from t1 where t1.b<>f or a=t1.a) then 17*(a) else 17 end*c)/abs(c))-d+f* -e-t1.a and b) then -11-a else t1.a end*19+b & t1.a<=t1.e),t1.b)) FROM t1 WHERE NOT (t1.e between -case when e not in (t1.e,case when d+t1.c-b-t1.b+case when -e<f then + -t1.c*t1.d+a*13*e when ( -t1.f<=a) then f else 13 end*t1.e-a-t1.b<(t1.e) then t1.d else t1.d end,t1.f) then f else t1.d end and t1.c)}
+} {300}
+do_test randexpr-2.2038 {
+ db eval {SELECT (select +~~ -(count(*))+max((select ~count(*)+count(distinct d)*~cast(avg(19) AS integer)+case count(*)- -abs(abs(~abs(++abs(cast(avg(t1.c) AS integer)))+count(distinct e)+count(*)))+(min(19) | ( -cast(avg(b) AS integer) | - -(count(distinct t1.f)))) when -count(*) then max( -b) else max((t1.d)) end from t1)) from t1) FROM t1 WHERE (abs(c)/abs((select (abs(count(*))) from t1))) not between t1.b and (select abs(count(*)* -~min(~e+case when t1.a+(a)>e then t1.d else a end+f)-case (+min(t1.f)*min(e)+cast(avg(c) AS integer))*count(*) when - -((count(distinct f))) then max(a) else count(*) end | -cast(avg(11) AS integer)*count(*))-count(*)*( -max(f)) from t1)}
+} {}
+do_test randexpr-2.2039 {
+ db eval {SELECT (select +~~ -(count(*))+max((select ~count(*)+count(distinct d)*~cast(avg(19) AS integer)+case count(*)- -abs(abs(~abs(++abs(cast(avg(t1.c) AS integer)))+count(distinct e)+count(*)))+(min(19) | ( -cast(avg(b) AS integer) | - -(count(distinct t1.f)))) when -count(*) then max( -b) else max((t1.d)) end from t1)) from t1) FROM t1 WHERE NOT ((abs(c)/abs((select (abs(count(*))) from t1))) not between t1.b and (select abs(count(*)* -~min(~e+case when t1.a+(a)>e then t1.d else a end+f)-case (+min(t1.f)*min(e)+cast(avg(c) AS integer))*count(*) when - -((count(distinct f))) then max(a) else count(*) end | -cast(avg(11) AS integer)*count(*))-count(*)*( -max(f)) from t1))}
+} {377}
+do_test randexpr-2.2040 {
+ db eval {SELECT (select +~~ -(count(*))+max((select ~count(*)+count(distinct d)*~cast(avg(19) AS integer)+case count(*)- -abs(abs(~abs(++abs(cast(avg(t1.c) AS integer)))+count(distinct e)+count(*)))+(min(19) & ( -cast(avg(b) AS integer) & - -(count(distinct t1.f)))) when -count(*) then max( -b) else max((t1.d)) end from t1)) from t1) FROM t1 WHERE NOT ((abs(c)/abs((select (abs(count(*))) from t1))) not between t1.b and (select abs(count(*)* -~min(~e+case when t1.a+(a)>e then t1.d else a end+f)-case (+min(t1.f)*min(e)+cast(avg(c) AS integer))*count(*) when - -((count(distinct f))) then max(a) else count(*) end | -cast(avg(11) AS integer)*count(*))-count(*)*( -max(f)) from t1))}
+} {377}
+do_test randexpr-2.2041 {
+ db eval {SELECT case when ((select abs((count(*)))+min(case 17 when b then 13 | 11+c | f else 19 end) | +count(*)- - -max(t1.d) from t1) not between 19-case when t1.c not between ~e and (e) then t1.d else t1.c end and t1.e) then t1.d when t1.d in (select -~count(distinct t1.f)*(min(t1.b)) from t1 union select (cast(avg(17) AS integer)) from t1) then d else t1.b end FROM t1 WHERE not exists(select 1 from t1 where d in (coalesce((select max((select abs(~min(f))++~count(distinct t1.a)+cast(avg(t1.b) AS integer)*cast(avg(13) AS integer) from t1)) from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where (exists(select 1 from t1 where 11<e or t1.a not between t1.a and c)) or e<t1.f)) or t1.a not in (13,f,13)),case when t1.b>=13 then ~19*13 | t1.c+t1.e when c between t1.d and a then t1.b else t1.d end)-13,17,11))}
+} {400}
+do_test randexpr-2.2042 {
+ db eval {SELECT case when ((select abs((count(*)))+min(case 17 when b then 13 | 11+c | f else 19 end) | +count(*)- - -max(t1.d) from t1) not between 19-case when t1.c not between ~e and (e) then t1.d else t1.c end and t1.e) then t1.d when t1.d in (select -~count(distinct t1.f)*(min(t1.b)) from t1 union select (cast(avg(17) AS integer)) from t1) then d else t1.b end FROM t1 WHERE NOT (not exists(select 1 from t1 where d in (coalesce((select max((select abs(~min(f))++~count(distinct t1.a)+cast(avg(t1.b) AS integer)*cast(avg(13) AS integer) from t1)) from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where (exists(select 1 from t1 where 11<e or t1.a not between t1.a and c)) or e<t1.f)) or t1.a not in (13,f,13)),case when t1.b>=13 then ~19*13 | t1.c+t1.e when c between t1.d and a then t1.b else t1.d end)-13,17,11)))}
+} {}
+do_test randexpr-2.2043 {
+ db eval {SELECT case when ((select abs((count(*)))+min(case 17 when b then 13 & 11+c & f else 19 end) & +count(*)- - -max(t1.d) from t1) not between 19-case when t1.c not between ~e and (e) then t1.d else t1.c end and t1.e) then t1.d when t1.d in (select -~count(distinct t1.f)*(min(t1.b)) from t1 union select (cast(avg(17) AS integer)) from t1) then d else t1.b end FROM t1 WHERE not exists(select 1 from t1 where d in (coalesce((select max((select abs(~min(f))++~count(distinct t1.a)+cast(avg(t1.b) AS integer)*cast(avg(13) AS integer) from t1)) from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where (exists(select 1 from t1 where 11<e or t1.a not between t1.a and c)) or e<t1.f)) or t1.a not in (13,f,13)),case when t1.b>=13 then ~19*13 | t1.c+t1.e when c between t1.d and a then t1.b else t1.d end)-13,17,11))}
+} {400}
+do_test randexpr-2.2044 {
+ db eval {SELECT case when not exists(select 1 from t1 where e in (select +(count(distinct (abs(case when ((abs(coalesce((select coalesce((select case when c>f and a in (19, -e,t1.c) then +t1.a else t1.e end from t1 where c<b and f=13),13) from t1 where 11 not between t1.f and f and t1.c<=(11)),t1.e))/abs(t1.e))+17)<=c then t1.b when not exists(select 1 from t1 where t1.f in (select c from t1 union select 11 from t1)) then t1.f else 17 end)/abs(t1.e)))) from t1 union select max(t1.e) from t1)) then f else c end*t1.d FROM t1 WHERE (select max(t1.c) from t1) in (t1.f+coalesce((select max(d) from t1 where (c in (select 11*case when e=c then a else t1.f end from t1 union select b from t1)) and t1.c in (select b from t1 union select d from t1) and not exists(select 1 from t1 where t1.c in (t1.a,17,t1.b)) and t1.e=17 or c<>t1.f),(select case abs(count(distinct t1.e)-cast(avg(t1.d) AS integer)*cast(avg(t1.b) AS integer)) when min(19) then count(*) else min(c) end+count(distinct t1.c) from t1))+t1.b,t1.d, -d)}
+} {}
+do_test randexpr-2.2045 {
+ db eval {SELECT case when not exists(select 1 from t1 where e in (select +(count(distinct (abs(case when ((abs(coalesce((select coalesce((select case when c>f and a in (19, -e,t1.c) then +t1.a else t1.e end from t1 where c<b and f=13),13) from t1 where 11 not between t1.f and f and t1.c<=(11)),t1.e))/abs(t1.e))+17)<=c then t1.b when not exists(select 1 from t1 where t1.f in (select c from t1 union select 11 from t1)) then t1.f else 17 end)/abs(t1.e)))) from t1 union select max(t1.e) from t1)) then f else c end*t1.d FROM t1 WHERE NOT ((select max(t1.c) from t1) in (t1.f+coalesce((select max(d) from t1 where (c in (select 11*case when e=c then a else t1.f end from t1 union select b from t1)) and t1.c in (select b from t1 union select d from t1) and not exists(select 1 from t1 where t1.c in (t1.a,17,t1.b)) and t1.e=17 or c<>t1.f),(select case abs(count(distinct t1.e)-cast(avg(t1.d) AS integer)*cast(avg(t1.b) AS integer)) when min(19) then count(*) else min(c) end+count(distinct t1.c) from t1))+t1.b,t1.d, -d))}
+} {120000}
+do_test randexpr-2.2046 {
+ db eval {SELECT -case when -b=t1.c then t1.a when (select min(t1.b) from t1)<=d+coalesce((select max(11+a) from t1 where (not exists(select 1 from t1 where c | -((case case when (t1.f between a and t1.b) then b else c end-t1.c when 19 then t1.c else f end+t1.c)+t1.b | a)-t1.c-(c)<=19))),t1.c) then e else -t1.d end-(17) FROM t1 WHERE (t1.b | case t1.b when ((t1.e)) then (abs(19)/abs(t1.a))-coalesce((select max(t1.e*case b when a then 11 else t1.a end) from t1 where +~case when 13=17 and t1.e+11 in (select t1.f from t1 union select t1.d from t1) then t1.b when (b<17 and a>= -17) then f else -t1.e end+(17)<=13),d) else b end | b between t1.d and t1.f)}
+} {}
+do_test randexpr-2.2047 {
+ db eval {SELECT -case when -b=t1.c then t1.a when (select min(t1.b) from t1)<=d+coalesce((select max(11+a) from t1 where (not exists(select 1 from t1 where c | -((case case when (t1.f between a and t1.b) then b else c end-t1.c when 19 then t1.c else f end+t1.c)+t1.b | a)-t1.c-(c)<=19))),t1.c) then e else -t1.d end-(17) FROM t1 WHERE NOT ((t1.b | case t1.b when ((t1.e)) then (abs(19)/abs(t1.a))-coalesce((select max(t1.e*case b when a then 11 else t1.a end) from t1 where +~case when 13=17 and t1.e+11 in (select t1.f from t1 union select t1.d from t1) then t1.b when (b<17 and a>= -17) then f else -t1.e end+(17)<=13),d) else b end | b between t1.d and t1.f))}
+} {-517}
+do_test randexpr-2.2048 {
+ db eval {SELECT -case when -b=t1.c then t1.a when (select min(t1.b) from t1)<=d+coalesce((select max(11+a) from t1 where (not exists(select 1 from t1 where c & -((case case when (t1.f between a and t1.b) then b else c end-t1.c when 19 then t1.c else f end+t1.c)+t1.b & a)-t1.c-(c)<=19))),t1.c) then e else -t1.d end-(17) FROM t1 WHERE NOT ((t1.b | case t1.b when ((t1.e)) then (abs(19)/abs(t1.a))-coalesce((select max(t1.e*case b when a then 11 else t1.a end) from t1 where +~case when 13=17 and t1.e+11 in (select t1.f from t1 union select t1.d from t1) then t1.b when (b<17 and a>= -17) then f else -t1.e end+(17)<=13),d) else b end | b between t1.d and t1.f))}
+} {-517}
+do_test randexpr-2.2049 {
+ db eval {SELECT case when not c<b and case when not (11 not in (c+b+t1.d- -13+e,(select -min((case (abs(t1.a)/abs(a)) when 13 then b else -19 end+11)) from t1),d)) and 13 in (19,t1.c,t1.e) then t1.b else 17 end<=~t1.e then +b*t1.c else t1.b end FROM t1 WHERE (abs(a)/abs(coalesce((select (e) from t1 where case when not d<=c then b else (19) end in (select ~( -(~(((count(*)))) | (count(distinct t1.e)))+min(t1.b)-(cast(avg(d) AS integer))-count(distinct b))-min(e)*max(t1.a) from t1 union select count(distinct f) from t1)),19 | t1.b)*t1.c+13)) in (select ~ -count(distinct e)*max((b)) | min(a) from t1 union select count(*) from t1)}
+} {}
+do_test randexpr-2.2050 {
+ db eval {SELECT case when not c<b and case when not (11 not in (c+b+t1.d- -13+e,(select -min((case (abs(t1.a)/abs(a)) when 13 then b else -19 end+11)) from t1),d)) and 13 in (19,t1.c,t1.e) then t1.b else 17 end<=~t1.e then +b*t1.c else t1.b end FROM t1 WHERE NOT ((abs(a)/abs(coalesce((select (e) from t1 where case when not d<=c then b else (19) end in (select ~( -(~(((count(*)))) | (count(distinct t1.e)))+min(t1.b)-(cast(avg(d) AS integer))-count(distinct b))-min(e)*max(t1.a) from t1 union select count(distinct f) from t1)),19 | t1.b)*t1.c+13)) in (select ~ -count(distinct e)*max((b)) | min(a) from t1 union select count(*) from t1))}
+} {200}
+do_test randexpr-2.2051 {
+ db eval {SELECT +11+~coalesce((select -19 from t1 where exists(select 1 from t1 where f*t1.e not in ( -f*~t1.a-f*case when t1.f in ((e),coalesce((select b from t1 where b>=t1.f | t1.d),19),t1.a) then (t1.d) when -a<=( -t1.a) then a else f end*a,13,19)) or e=17),a)*17 FROM t1 WHERE (select case min(+19) when abs((max(17)* -min(a*(abs(case e when t1.b then t1.f else -t1.c end*f)/abs(t1.d))*e)-count(*) | max(19))) then - -case count(distinct 11) when min(11) then max(19) else min(13) end-( -count(distinct 13)) else -(count(distinct b)) end*cast(avg(17) AS integer)-max(e) from t1) between t1.d and coalesce((select max(13) from t1 where not 17>a-f-e),13)}
+} {}
+do_test randexpr-2.2052 {
+ db eval {SELECT +11+~coalesce((select -19 from t1 where exists(select 1 from t1 where f*t1.e not in ( -f*~t1.a-f*case when t1.f in ((e),coalesce((select b from t1 where b>=t1.f | t1.d),19),t1.a) then (t1.d) when -a<=( -t1.a) then a else f end*a,13,19)) or e=17),a)*17 FROM t1 WHERE NOT ((select case min(+19) when abs((max(17)* -min(a*(abs(case e when t1.b then t1.f else -t1.c end*f)/abs(t1.d))*e)-count(*) | max(19))) then - -case count(distinct 11) when min(11) then max(19) else min(13) end-( -count(distinct 13)) else -(count(distinct b)) end*cast(avg(17) AS integer)-max(e) from t1) between t1.d and coalesce((select max(13) from t1 where not 17>a-f-e),13))}
+} {317}
+do_test randexpr-2.2053 {
+ db eval {SELECT +11+~coalesce((select -19 from t1 where exists(select 1 from t1 where f*t1.e not in ( -f*~t1.a-f*case when t1.f in ((e),coalesce((select b from t1 where b>=t1.f & t1.d),19),t1.a) then (t1.d) when -a<=( -t1.a) then a else f end*a,13,19)) or e=17),a)*17 FROM t1 WHERE NOT ((select case min(+19) when abs((max(17)* -min(a*(abs(case e when t1.b then t1.f else -t1.c end*f)/abs(t1.d))*e)-count(*) | max(19))) then - -case count(distinct 11) when min(11) then max(19) else min(13) end-( -count(distinct 13)) else -(count(distinct b)) end*cast(avg(17) AS integer)-max(e) from t1) between t1.d and coalesce((select max(13) from t1 where not 17>a-f-e),13))}
+} {317}
+do_test randexpr-2.2054 {
+ db eval {SELECT coalesce((select 11 from t1 where (b-case (select count(distinct t1.f*e) from t1) when t1.f | 11 | 11*coalesce((select 19 from t1 where (~coalesce((select f from t1 where (t1.c>17)),a)+t1.c not between f and t1.e or 19>=c)),(t1.d)) then a else t1.f end>=f and exists(select 1 from t1 where 13<>c) or - -t1.f<t1.f)),13) FROM t1 WHERE a not in (f,t1.e,11)}
+} {13}
+do_test randexpr-2.2055 {
+ db eval {SELECT coalesce((select 11 from t1 where (b-case (select count(distinct t1.f*e) from t1) when t1.f | 11 | 11*coalesce((select 19 from t1 where (~coalesce((select f from t1 where (t1.c>17)),a)+t1.c not between f and t1.e or 19>=c)),(t1.d)) then a else t1.f end>=f and exists(select 1 from t1 where 13<>c) or - -t1.f<t1.f)),13) FROM t1 WHERE NOT (a not in (f,t1.e,11))}
+} {}
+do_test randexpr-2.2056 {
+ db eval {SELECT coalesce((select 11 from t1 where (b-case (select count(distinct t1.f*e) from t1) when t1.f & 11 & 11*coalesce((select 19 from t1 where (~coalesce((select f from t1 where (t1.c>17)),a)+t1.c not between f and t1.e or 19>=c)),(t1.d)) then a else t1.f end>=f and exists(select 1 from t1 where 13<>c) or - -t1.f<t1.f)),13) FROM t1 WHERE a not in (f,t1.e,11)}
+} {13}
+do_test randexpr-2.2057 {
+ db eval {SELECT (abs(coalesce((select max(t1.e) from t1 where c>coalesce((select max(coalesce((select t1.e from t1 where not (abs(a+t1.e*c | case when t1.b in (select -max(t1.b)*cast(avg(19) AS integer) from t1 union select -max(13) from t1) then t1.f else 19 end-f+(19)+19)/abs(t1.e)) in (d,13,e) or t1.e<=t1.e),t1.b-17)) from t1 where -11<>17 or e in (select max(19) from t1 union select (cast(avg(f) AS integer)) from t1)),a)),17))/abs(t1.e)) FROM t1 WHERE t1.e<>13 | (t1.f)+c-((13))-~13 | (abs(e)/abs(coalesce((select max(t1.c) from t1 where (d)<=t1.d),case when (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(17)/abs(t1.d))>coalesce((select max(a) from t1 where t1.c not between t1.f and t1.f and f not in (t1.f, -t1.c,13)),t1.c)))) then c else 19 end))) | t1.a*11* -e*t1.c or not exists(select 1 from t1 where f>c)}
+} {0}
+do_test randexpr-2.2058 {
+ db eval {SELECT (abs(coalesce((select max(t1.e) from t1 where c>coalesce((select max(coalesce((select t1.e from t1 where not (abs(a+t1.e*c | case when t1.b in (select -max(t1.b)*cast(avg(19) AS integer) from t1 union select -max(13) from t1) then t1.f else 19 end-f+(19)+19)/abs(t1.e)) in (d,13,e) or t1.e<=t1.e),t1.b-17)) from t1 where -11<>17 or e in (select max(19) from t1 union select (cast(avg(f) AS integer)) from t1)),a)),17))/abs(t1.e)) FROM t1 WHERE NOT (t1.e<>13 | (t1.f)+c-((13))-~13 | (abs(e)/abs(coalesce((select max(t1.c) from t1 where (d)<=t1.d),case when (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(17)/abs(t1.d))>coalesce((select max(a) from t1 where t1.c not between t1.f and t1.f and f not in (t1.f, -t1.c,13)),t1.c)))) then c else 19 end))) | t1.a*11* -e*t1.c or not exists(select 1 from t1 where f>c))}
+} {}
+do_test randexpr-2.2059 {
+ db eval {SELECT (abs(coalesce((select max(t1.e) from t1 where c>coalesce((select max(coalesce((select t1.e from t1 where not (abs(a+t1.e*c & case when t1.b in (select -max(t1.b)*cast(avg(19) AS integer) from t1 union select -max(13) from t1) then t1.f else 19 end-f+(19)+19)/abs(t1.e)) in (d,13,e) or t1.e<=t1.e),t1.b-17)) from t1 where -11<>17 or e in (select max(19) from t1 union select (cast(avg(f) AS integer)) from t1)),a)),17))/abs(t1.e)) FROM t1 WHERE t1.e<>13 | (t1.f)+c-((13))-~13 | (abs(e)/abs(coalesce((select max(t1.c) from t1 where (d)<=t1.d),case when (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(17)/abs(t1.d))>coalesce((select max(a) from t1 where t1.c not between t1.f and t1.f and f not in (t1.f, -t1.c,13)),t1.c)))) then c else 19 end))) | t1.a*11* -e*t1.c or not exists(select 1 from t1 where f>c)}
+} {0}
+do_test randexpr-2.2060 {
+ db eval {SELECT case t1.e when a then case when not exists(select 1 from t1 where (abs(~coalesce((select c from t1 where (case when not case when a between t1.b and t1.a then t1.c when -17 not in (11,t1.d,11) then a else t1.a end in (select count(distinct t1.a)+count(distinct t1.a) from t1 union select count(*) from t1) then t1.c when t1.b<(11) then f else a end>=11 and (t1.f)=11)),+11))/abs(e)) not between 17 and -t1.a) or c not between 19 and t1.b then t1.c when t1.e<t1.a then -e*t1.d else 17 end | t1.e else t1.b end FROM t1 WHERE f+17<=17}
+} {}
+do_test randexpr-2.2061 {
+ db eval {SELECT case t1.e when a then case when not exists(select 1 from t1 where (abs(~coalesce((select c from t1 where (case when not case when a between t1.b and t1.a then t1.c when -17 not in (11,t1.d,11) then a else t1.a end in (select count(distinct t1.a)+count(distinct t1.a) from t1 union select count(*) from t1) then t1.c when t1.b<(11) then f else a end>=11 and (t1.f)=11)),+11))/abs(e)) not between 17 and -t1.a) or c not between 19 and t1.b then t1.c when t1.e<t1.a then -e*t1.d else 17 end | t1.e else t1.b end FROM t1 WHERE NOT (f+17<=17)}
+} {200}
+do_test randexpr-2.2062 {
+ db eval {SELECT case t1.e when a then case when not exists(select 1 from t1 where (abs(~coalesce((select c from t1 where (case when not case when a between t1.b and t1.a then t1.c when -17 not in (11,t1.d,11) then a else t1.a end in (select count(distinct t1.a)+count(distinct t1.a) from t1 union select count(*) from t1) then t1.c when t1.b<(11) then f else a end>=11 and (t1.f)=11)),+11))/abs(e)) not between 17 and -t1.a) or c not between 19 and t1.b then t1.c when t1.e<t1.a then -e*t1.d else 17 end & t1.e else t1.b end FROM t1 WHERE NOT (f+17<=17)}
+} {200}
+do_test randexpr-2.2063 {
+ db eval {SELECT ~~coalesce((select t1.a from t1 where case f*+e when ~11-coalesce((select max(t1.f) from t1 where t1.f>b),~case when b between 17 and e | coalesce((select max(a) from t1 where (f in (t1.b,f,a))),13) then f when -d<=d then t1.e else e end+13)+13 then d else d end+t1.f=d),b)+b FROM t1 WHERE b=b}
+} {400}
+do_test randexpr-2.2064 {
+ db eval {SELECT ~~coalesce((select t1.a from t1 where case f*+e when ~11-coalesce((select max(t1.f) from t1 where t1.f>b),~case when b between 17 and e | coalesce((select max(a) from t1 where (f in (t1.b,f,a))),13) then f when -d<=d then t1.e else e end+13)+13 then d else d end+t1.f=d),b)+b FROM t1 WHERE NOT (b=b)}
+} {}
+do_test randexpr-2.2065 {
+ db eval {SELECT ~~coalesce((select t1.a from t1 where case f*+e when ~11-coalesce((select max(t1.f) from t1 where t1.f>b),~case when b between 17 and e & coalesce((select max(a) from t1 where (f in (t1.b,f,a))),13) then f when -d<=d then t1.e else e end+13)+13 then d else d end+t1.f=d),b)+b FROM t1 WHERE b=b}
+} {400}
+do_test randexpr-2.2066 {
+ db eval {SELECT e | t1.e*case d when t1.e then a else case when t1.a<= -~+e then b else 17-t1.e end*c*f+case when case when +c in (select +min(11) from t1 union select cast(avg(f) AS integer) from t1) and b between c and t1.f then 11+t1.a when f>=c then d else t1.c end<t1.c and t1.d between t1.a and t1.e then 19 when t1.a<=t1.c then t1.d else f end end FROM t1 WHERE 13 in (select case when ++(select abs(max((select count(*) from t1)+~13)) from t1)*11 not in ((d*~19),(abs(f)/abs(t1.b)),case when not exists(select 1 from t1 where b<=e+t1.d) then b*f when d in (select min(t1.d) from t1 union select min(e) from t1) then 19 else f end*a) then t1.c else -c end from t1 union select t1.a from t1) or f<c}
+} {}
+do_test randexpr-2.2067 {
+ db eval {SELECT e | t1.e*case d when t1.e then a else case when t1.a<= -~+e then b else 17-t1.e end*c*f+case when case when +c in (select +min(11) from t1 union select cast(avg(f) AS integer) from t1) and b between c and t1.f then 11+t1.a when f>=c then d else t1.c end<t1.c and t1.d between t1.a and t1.e then 19 when t1.a<=t1.c then t1.d else f end end FROM t1 WHERE NOT (13 in (select case when ++(select abs(max((select count(*) from t1)+~13)) from t1)*11 not in ((d*~19),(abs(f)/abs(t1.b)),case when not exists(select 1 from t1 where b<=e+t1.d) then b*f when d in (select min(t1.d) from t1 union select min(e) from t1) then 19 else f end*a) then t1.c else -c end from t1 union select t1.a from t1) or f<c)}
+} {18000200180}
+do_test randexpr-2.2068 {
+ db eval {SELECT e & t1.e*case d when t1.e then a else case when t1.a<= -~+e then b else 17-t1.e end*c*f+case when case when +c in (select +min(11) from t1 union select cast(avg(f) AS integer) from t1) and b between c and t1.f then 11+t1.a when f>=c then d else t1.c end<t1.c and t1.d between t1.a and t1.e then 19 when t1.a<=t1.c then t1.d else f end end FROM t1 WHERE NOT (13 in (select case when ++(select abs(max((select count(*) from t1)+~13)) from t1)*11 not in ((d*~19),(abs(f)/abs(t1.b)),case when not exists(select 1 from t1 where b<=e+t1.d) then b*f when d in (select min(t1.d) from t1 union select min(e) from t1) then 19 else f end*a) then t1.c else -c end from t1 union select t1.a from t1) or f<c)}
+} {320}
+do_test randexpr-2.2069 {
+ db eval {SELECT coalesce((select -(select min(f)-+min(f)*~case +cast(avg(t1.e) AS integer) when max(13)-abs( -max(a)) then +count(distinct a) | abs(max( -c+13)) else (count(*)) end from t1) from t1 where t1.a<>t1.e), -t1.d) FROM t1 WHERE t1.b between coalesce((select (coalesce((select max(case when case when not exists(select 1 from t1 where (17) not in (13,case when 19 not in (19,t1.f,t1.e) and b>=t1.a then e when b<=t1.c then 11 else b end,11)) then c | t1.a else 17 end | 19 in (c,t1.b,d) then t1.a else t1.a end | t1.c) from t1 where not exists(select 1 from t1 where t1.a<=t1.e)),t1.c)) from t1 where t1.d<=t1.a),17)*c-11 and d}
+} {}
+do_test randexpr-2.2070 {
+ db eval {SELECT coalesce((select -(select min(f)-+min(f)*~case +cast(avg(t1.e) AS integer) when max(13)-abs( -max(a)) then +count(distinct a) | abs(max( -c+13)) else (count(*)) end from t1) from t1 where t1.a<>t1.e), -t1.d) FROM t1 WHERE NOT (t1.b between coalesce((select (coalesce((select max(case when case when not exists(select 1 from t1 where (17) not in (13,case when 19 not in (19,t1.f,t1.e) and b>=t1.a then e when b<=t1.c then 11 else b end,11)) then c | t1.a else 17 end | 19 in (c,t1.b,d) then t1.a else t1.a end | t1.c) from t1 where not exists(select 1 from t1 where t1.a<=t1.e)),t1.c)) from t1 where t1.d<=t1.a),17)*c-11 and d)}
+} {-1800}
+do_test randexpr-2.2071 {
+ db eval {SELECT coalesce((select -(select min(f)-+min(f)*~case +cast(avg(t1.e) AS integer) when max(13)-abs( -max(a)) then +count(distinct a) & abs(max( -c+13)) else (count(*)) end from t1) from t1 where t1.a<>t1.e), -t1.d) FROM t1 WHERE NOT (t1.b between coalesce((select (coalesce((select max(case when case when not exists(select 1 from t1 where (17) not in (13,case when 19 not in (19,t1.f,t1.e) and b>=t1.a then e when b<=t1.c then 11 else b end,11)) then c | t1.a else 17 end | 19 in (c,t1.b,d) then t1.a else t1.a end | t1.c) from t1 where not exists(select 1 from t1 where t1.a<=t1.e)),t1.c)) from t1 where t1.d<=t1.a),17)*c-11 and d)}
+} {-1800}
+do_test randexpr-2.2072 {
+ db eval {SELECT coalesce((select c from t1 where case when +case when not 11 | c not in (11,case when 13> -d then e when a>t1.c then 17 else t1.e end,t1.b) then t1.d when c<>t1.a then t1.b else 19 end-b>=17 or 11<t1.c then case when not exists(select 1 from t1 where not exists(select 1 from t1 where t1.f<t1.c)) then t1.f when not exists(select 1 from t1 where 19 not in (t1.d,t1.b,t1.a)) then t1.c else t1.a end else - -f end>=19 and b<=e),d) FROM t1 WHERE (+a*t1.a+(19-(abs(case -c when d then (abs(f)/abs(case t1.a when 19 then b else +~( -case t1.f*t1.a | 17 when -t1.a then d else (t1.e) end*d)+t1.a-a end)) else 13 end)/abs(11))*t1.c)+17-d not in (11,a,b))}
+} {300}
+do_test randexpr-2.2073 {
+ db eval {SELECT coalesce((select c from t1 where case when +case when not 11 | c not in (11,case when 13> -d then e when a>t1.c then 17 else t1.e end,t1.b) then t1.d when c<>t1.a then t1.b else 19 end-b>=17 or 11<t1.c then case when not exists(select 1 from t1 where not exists(select 1 from t1 where t1.f<t1.c)) then t1.f when not exists(select 1 from t1 where 19 not in (t1.d,t1.b,t1.a)) then t1.c else t1.a end else - -f end>=19 and b<=e),d) FROM t1 WHERE NOT ((+a*t1.a+(19-(abs(case -c when d then (abs(f)/abs(case t1.a when 19 then b else +~( -case t1.f*t1.a | 17 when -t1.a then d else (t1.e) end*d)+t1.a-a end)) else 13 end)/abs(11))*t1.c)+17-d not in (11,a,b)))}
+} {}
+do_test randexpr-2.2074 {
+ db eval {SELECT coalesce((select c from t1 where case when +case when not 11 & c not in (11,case when 13> -d then e when a>t1.c then 17 else t1.e end,t1.b) then t1.d when c<>t1.a then t1.b else 19 end-b>=17 or 11<t1.c then case when not exists(select 1 from t1 where not exists(select 1 from t1 where t1.f<t1.c)) then t1.f when not exists(select 1 from t1 where 19 not in (t1.d,t1.b,t1.a)) then t1.c else t1.a end else - -f end>=19 and b<=e),d) FROM t1 WHERE (+a*t1.a+(19-(abs(case -c when d then (abs(f)/abs(case t1.a when 19 then b else +~( -case t1.f*t1.a | 17 when -t1.a then d else (t1.e) end*d)+t1.a-a end)) else 13 end)/abs(11))*t1.c)+17-d not in (11,a,b))}
+} {300}
+do_test randexpr-2.2075 {
+ db eval {SELECT case 17 when t1.c then t1.c*f | t1.b+t1.d+b+c-t1.e+t1.c+t1.c-t1.c*t1.f else case when t1.f+case when (abs(t1.a-coalesce((select a from t1 where (t1.c) in (t1.c,d,19)), -t1.a))/abs(f)) between t1.c and a then -(t1.b) else b end not in (11, -t1.d,t1.d) then t1.d else d end end FROM t1 WHERE ~17 between (select -count(distinct b+b)++max(t1.b)*(~(max(t1.d)))-abs(cast(avg(17) AS integer)*count(*))-max(f) | count(distinct t1.a)-count(distinct 13)-cast(avg(c) AS integer) from t1) and c-case when f<>t1.e then (abs(~(a)+e+t1.a | t1.a)/abs(t1.c)) else 13 end- -t1.e}
+} {400}
+do_test randexpr-2.2076 {
+ db eval {SELECT case 17 when t1.c then t1.c*f | t1.b+t1.d+b+c-t1.e+t1.c+t1.c-t1.c*t1.f else case when t1.f+case when (abs(t1.a-coalesce((select a from t1 where (t1.c) in (t1.c,d,19)), -t1.a))/abs(f)) between t1.c and a then -(t1.b) else b end not in (11, -t1.d,t1.d) then t1.d else d end end FROM t1 WHERE NOT (~17 between (select -count(distinct b+b)++max(t1.b)*(~(max(t1.d)))-abs(cast(avg(17) AS integer)*count(*))-max(f) | count(distinct t1.a)-count(distinct 13)-cast(avg(c) AS integer) from t1) and c-case when f<>t1.e then (abs(~(a)+e+t1.a | t1.a)/abs(t1.c)) else 13 end- -t1.e)}
+} {}
+do_test randexpr-2.2077 {
+ db eval {SELECT case 17 when t1.c then t1.c*f & t1.b+t1.d+b+c-t1.e+t1.c+t1.c-t1.c*t1.f else case when t1.f+case when (abs(t1.a-coalesce((select a from t1 where (t1.c) in (t1.c,d,19)), -t1.a))/abs(f)) between t1.c and a then -(t1.b) else b end not in (11, -t1.d,t1.d) then t1.d else d end end FROM t1 WHERE ~17 between (select -count(distinct b+b)++max(t1.b)*(~(max(t1.d)))-abs(cast(avg(17) AS integer)*count(*))-max(f) | count(distinct t1.a)-count(distinct 13)-cast(avg(c) AS integer) from t1) and c-case when f<>t1.e then (abs(~(a)+e+t1.a | t1.a)/abs(t1.c)) else 13 end- -t1.e}
+} {400}
+do_test randexpr-2.2078 {
+ db eval {SELECT (select cast(avg(coalesce((select max(coalesce((select e from t1 where not ((coalesce((select b from t1 where coalesce((select max(11) from t1 where exists(select 1 from t1 where (a in (select count(*)+max(((t1.a))) from t1 union select cast(avg(a) AS integer) from t1)))),b)<=19), -b))*f<t1.b and not exists(select 1 from t1 where d>=t1.e) and 17<>11 and e in (t1.f,f,17)) or a not between -a and (17)),+~b)-17*b) from t1 where t1.b>=b),t1.a)) AS integer) from t1) FROM t1 WHERE f in (select cast(avg(t1.e-f-t1.e) AS integer)+min(t1.d) from t1 union select max(case b when 11 then case case when f in (a,a,f) then t1.b when (t1.f)>d then -19 else t1.a end when 11 then a else t1.e end else (t1.b) end*a)*cast(avg(a) AS integer)+ -+cast(avg(t1.e) AS integer)*case cast(avg(t1.e) AS integer) when (cast(avg( -t1.a) AS integer)) then count(*) else count(*) end*min(t1.d)*min(e) from t1) and (a between d and t1.f)}
+} {}
+do_test randexpr-2.2079 {
+ db eval {SELECT (select cast(avg(coalesce((select max(coalesce((select e from t1 where not ((coalesce((select b from t1 where coalesce((select max(11) from t1 where exists(select 1 from t1 where (a in (select count(*)+max(((t1.a))) from t1 union select cast(avg(a) AS integer) from t1)))),b)<=19), -b))*f<t1.b and not exists(select 1 from t1 where d>=t1.e) and 17<>11 and e in (t1.f,f,17)) or a not between -a and (17)),+~b)-17*b) from t1 where t1.b>=b),t1.a)) AS integer) from t1) FROM t1 WHERE NOT (f in (select cast(avg(t1.e-f-t1.e) AS integer)+min(t1.d) from t1 union select max(case b when 11 then case case when f in (a,a,f) then t1.b when (t1.f)>d then -19 else t1.a end when 11 then a else t1.e end else (t1.b) end*a)*cast(avg(a) AS integer)+ -+cast(avg(t1.e) AS integer)*case cast(avg(t1.e) AS integer) when (cast(avg( -t1.a) AS integer)) then count(*) else count(*) end*min(t1.d)*min(e) from t1) and (a between d and t1.f))}
+} {-2900}
+do_test randexpr-2.2080 {
+ db eval {SELECT case when coalesce((select max(coalesce((select max((select min(13) from t1)*d*case when not 19<>(t1.c)-d then 11 else 17 end) from t1 where 13<t1.f and t1.e not between (t1.a) and d),c)) from t1 where t1.d between (d) and 19 or t1.c in (t1.f,(11),17)), -11)>=t1.e then t1.d when not exists(select 1 from t1 where t1.c in (select (count(*)) from t1 union select +count(*) from t1)) then t1.c else 19 end FROM t1 WHERE ((11>=11))}
+} {300}
+do_test randexpr-2.2081 {
+ db eval {SELECT case when coalesce((select max(coalesce((select max((select min(13) from t1)*d*case when not 19<>(t1.c)-d then 11 else 17 end) from t1 where 13<t1.f and t1.e not between (t1.a) and d),c)) from t1 where t1.d between (d) and 19 or t1.c in (t1.f,(11),17)), -11)>=t1.e then t1.d when not exists(select 1 from t1 where t1.c in (select (count(*)) from t1 union select +count(*) from t1)) then t1.c else 19 end FROM t1 WHERE NOT (((11>=11)))}
+} {}
+do_test randexpr-2.2082 {
+ db eval {SELECT -case when 19 in (select abs((count(*))) from t1 union select abs(min(t1.f)*min(e*e)) from t1) and case when not not (17>a) or d>=c and (19)<=t1.b and - -t1.f<>t1.f then f when t1.b between d and t1.f then case when t1.e=e then coalesce((select max(d) from t1 where t1.b>=b),a) when t1.a not between c and e then e else 13 end else (17) end>t1.d then b else b end+t1.b-a FROM t1 WHERE exists(select 1 from t1 where +coalesce((select 19 from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where case when (select max(11-(select +count(distinct +case + -coalesce((select t1.d from t1 where exists(select 1 from t1 where (b)>t1.c)),t1.f)*11 when -a then 19 else 19 end) from t1)) from t1)<=t1.d-c then f when exists(select 1 from t1 where t1.f not between b and a) then -d else t1.d end not in (t1.b,t1.e, -t1.f)))),f) not in (f,e,13))}
+} {}
+do_test randexpr-2.2083 {
+ db eval {SELECT -case when 19 in (select abs((count(*))) from t1 union select abs(min(t1.f)*min(e*e)) from t1) and case when not not (17>a) or d>=c and (19)<=t1.b and - -t1.f<>t1.f then f when t1.b between d and t1.f then case when t1.e=e then coalesce((select max(d) from t1 where t1.b>=b),a) when t1.a not between c and e then e else 13 end else (17) end>t1.d then b else b end+t1.b-a FROM t1 WHERE NOT (exists(select 1 from t1 where +coalesce((select 19 from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where case when (select max(11-(select +count(distinct +case + -coalesce((select t1.d from t1 where exists(select 1 from t1 where (b)>t1.c)),t1.f)*11 when -a then 19 else 19 end) from t1)) from t1)<=t1.d-c then f when exists(select 1 from t1 where t1.f not between b and a) then -d else t1.d end not in (t1.b,t1.e, -t1.f)))),f) not in (f,e,13)))}
+} {-100}
+do_test randexpr-2.2084 {
+ db eval {SELECT coalesce((select max(b) from t1 where d not between a-t1.e and a),coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where t1.e<t1.a)),e)+19) FROM t1 WHERE +case f when case -~c-case when d=17 then t1.c*(select abs(case (cast(avg(19) AS integer)) when ( -count(*)) then min(19) else count(*) end*min(a)) from t1) when b* -(e)-t1.b in (select max(19) | max(t1.c) from t1 union select max(17) from t1) then c else a end when -f then 13 else 19 end then t1.d else t1.c end<>e or 11 between b and 13}
+} {200}
+do_test randexpr-2.2085 {
+ db eval {SELECT coalesce((select max(b) from t1 where d not between a-t1.e and a),coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where t1.e<t1.a)),e)+19) FROM t1 WHERE NOT (+case f when case -~c-case when d=17 then t1.c*(select abs(case (cast(avg(19) AS integer)) when ( -count(*)) then min(19) else count(*) end*min(a)) from t1) when b* -(e)-t1.b in (select max(19) | max(t1.c) from t1 union select max(17) from t1) then c else a end when -f then 13 else 19 end then t1.d else t1.c end<>e or 11 between b and 13)}
+} {}
+do_test randexpr-2.2086 {
+ db eval {SELECT (select case count(*) when ~(case case -abs(count(*) | (case case ~case -count(distinct case when t1.a< -t1.d then b when 19 in (t1.e, - -19,t1.b) then t1.c else t1.f end)-count(distinct (t1.f)) when count(*) then max(c) else count(distinct 17) end when count(*) then ((cast(avg(b) AS integer))) else -count(*) end when -count(distinct t1.f) then count(distinct t1.a) else count(distinct t1.e) end))+count(*) when cast(avg(19) AS integer) then -min( -t1.c) else count(*) end when (min(t1.e)) then cast(avg(c) AS integer) else min(t1.f) end) then min(e) else count(*) end | max(11) from t1)+19 FROM t1 WHERE case when (((d not between (+t1.a-coalesce((select max(b*t1.b* -t1.f) from t1 where a>a),13)) and a)) and c>=d or f<c) then coalesce((select (abs(17)/abs(13))*e from t1 where f in (t1.a,13,t1.b) and (t1.c)<>e and t1.c< -11 and f<>b or t1.b<17),c) else t1.a end>=11}
+} {30}
+do_test randexpr-2.2087 {
+ db eval {SELECT (select case count(*) when ~(case case -abs(count(*) | (case case ~case -count(distinct case when t1.a< -t1.d then b when 19 in (t1.e, - -19,t1.b) then t1.c else t1.f end)-count(distinct (t1.f)) when count(*) then max(c) else count(distinct 17) end when count(*) then ((cast(avg(b) AS integer))) else -count(*) end when -count(distinct t1.f) then count(distinct t1.a) else count(distinct t1.e) end))+count(*) when cast(avg(19) AS integer) then -min( -t1.c) else count(*) end when (min(t1.e)) then cast(avg(c) AS integer) else min(t1.f) end) then min(e) else count(*) end | max(11) from t1)+19 FROM t1 WHERE NOT (case when (((d not between (+t1.a-coalesce((select max(b*t1.b* -t1.f) from t1 where a>a),13)) and a)) and c>=d or f<c) then coalesce((select (abs(17)/abs(13))*e from t1 where f in (t1.a,13,t1.b) and (t1.c)<>e and t1.c< -11 and f<>b or t1.b<17),c) else t1.a end>=11)}
+} {}
+do_test randexpr-2.2088 {
+ db eval {SELECT (select case count(*) when ~(case case -abs(count(*) & (case case ~case -count(distinct case when t1.a< -t1.d then b when 19 in (t1.e, - -19,t1.b) then t1.c else t1.f end)-count(distinct (t1.f)) when count(*) then max(c) else count(distinct 17) end when count(*) then ((cast(avg(b) AS integer))) else -count(*) end when -count(distinct t1.f) then count(distinct t1.a) else count(distinct t1.e) end))+count(*) when cast(avg(19) AS integer) then -min( -t1.c) else count(*) end when (min(t1.e)) then cast(avg(c) AS integer) else min(t1.f) end) then min(e) else count(*) end & max(11) from t1)+19 FROM t1 WHERE case when (((d not between (+t1.a-coalesce((select max(b*t1.b* -t1.f) from t1 where a>a),13)) and a)) and c>=d or f<c) then coalesce((select (abs(17)/abs(13))*e from t1 where f in (t1.a,13,t1.b) and (t1.c)<>e and t1.c< -11 and f<>b or t1.b<17),c) else t1.a end>=11}
+} {20}
+do_test randexpr-2.2089 {
+ db eval {SELECT case when case when t1.a*~t1.a-19-c | 17+t1.d*f*c=d then f else -13 end+t1.b+a in (t1.f,t1.d,t1.f) and (not c=11) and t1.e<>f then coalesce((select f from t1 where t1.d not in (t1.e,f,11)), -17) else f end-b FROM t1 WHERE not exists(select 1 from t1 where +d between d*13 and ((abs(13+e+e)/abs(+case when not t1.c in (~(select cast(avg(case e when b then 11 else 13 end) AS integer) from t1)*b*17,t1.e,t1.e) then 11* -c when t1.f in (select min(e)*count(distinct c) from t1 union select - - - -max(e) | cast(avg((d)) AS integer) from t1) then (c) else e end)))) or d<17}
+} {400}
+do_test randexpr-2.2090 {
+ db eval {SELECT case when case when t1.a*~t1.a-19-c | 17+t1.d*f*c=d then f else -13 end+t1.b+a in (t1.f,t1.d,t1.f) and (not c=11) and t1.e<>f then coalesce((select f from t1 where t1.d not in (t1.e,f,11)), -17) else f end-b FROM t1 WHERE NOT (not exists(select 1 from t1 where +d between d*13 and ((abs(13+e+e)/abs(+case when not t1.c in (~(select cast(avg(case e when b then 11 else 13 end) AS integer) from t1)*b*17,t1.e,t1.e) then 11* -c when t1.f in (select min(e)*count(distinct c) from t1 union select - - - -max(e) | cast(avg((d)) AS integer) from t1) then (c) else e end)))) or d<17)}
+} {}
+do_test randexpr-2.2091 {
+ db eval {SELECT case when case when t1.a*~t1.a-19-c & 17+t1.d*f*c=d then f else -13 end+t1.b+a in (t1.f,t1.d,t1.f) and (not c=11) and t1.e<>f then coalesce((select f from t1 where t1.d not in (t1.e,f,11)), -17) else f end-b FROM t1 WHERE not exists(select 1 from t1 where +d between d*13 and ((abs(13+e+e)/abs(+case when not t1.c in (~(select cast(avg(case e when b then 11 else 13 end) AS integer) from t1)*b*17,t1.e,t1.e) then 11* -c when t1.f in (select min(e)*count(distinct c) from t1 union select - - - -max(e) | cast(avg((d)) AS integer) from t1) then (c) else e end)))) or d<17}
+} {400}
+do_test randexpr-2.2092 {
+ db eval {SELECT coalesce((select c from t1 where t1.b between t1.b and -17),coalesce((select -t1.e from t1 where (select count(distinct coalesce((select case t1.b-t1.a*(b)*13 when 11 then (a) else 11 end from t1 where a not in ((t1.e),c,11) and e>b),13)) from t1) in (t1.d,b,13) and not t1.b<13 or 11<> -17 or (11)>17 or t1.f not between b and (t1.a)),(b))) FROM t1 WHERE ((+case +d when f then (d) else case t1.f-(b)-11 when d then -t1.c else a end end not in ( -17,(t1.d),13) and (11 not in ((c),t1.f,t1.d)) and (e in (select 13 from t1 union select t1.a from t1) and d in (select t1.e from t1 union select 19 from t1))) or exists(select 1 from t1 where -t1.a= -t1.d)) and exists(select 1 from t1 where t1.b not between f and e or 19>=t1.d)}
+} {}
+do_test randexpr-2.2093 {
+ db eval {SELECT coalesce((select c from t1 where t1.b between t1.b and -17),coalesce((select -t1.e from t1 where (select count(distinct coalesce((select case t1.b-t1.a*(b)*13 when 11 then (a) else 11 end from t1 where a not in ((t1.e),c,11) and e>b),13)) from t1) in (t1.d,b,13) and not t1.b<13 or 11<> -17 or (11)>17 or t1.f not between b and (t1.a)),(b))) FROM t1 WHERE NOT (((+case +d when f then (d) else case t1.f-(b)-11 when d then -t1.c else a end end not in ( -17,(t1.d),13) and (11 not in ((c),t1.f,t1.d)) and (e in (select 13 from t1 union select t1.a from t1) and d in (select t1.e from t1 union select 19 from t1))) or exists(select 1 from t1 where -t1.a= -t1.d)) and exists(select 1 from t1 where t1.b not between f and e or 19>=t1.d))}
+} {-500}
+do_test randexpr-2.2094 {
+ db eval {SELECT case d when f then case when (abs(coalesce((select ~f*case when t1.f<(select -count(distinct (select count(*)-min(13) from t1)) from t1) then d when t1.d between t1.b and f and not (t1.b between ( -t1.f) and f) then -d else b end-b | t1.f*17 from t1 where ((d>t1.d))),17))/abs(11))-13=t1.c then a else 11 end else b end FROM t1 WHERE t1.b between coalesce((select case when coalesce((select t1.c from t1 where not ((t1.a>=11+17 and (13+(11)<>13))) and b<=c and c in (c, -c,(e)) and d not in (f,b,c) or t1.d>=13 and 13 between 19 and a),d) not between 13-case when t1.f<>t1.b then t1.f else t1.c end | d and d then b when c<c then 13 else 11 end*t1.e from t1 where b>= -d),19) and c}
+} {}
+do_test randexpr-2.2095 {
+ db eval {SELECT case d when f then case when (abs(coalesce((select ~f*case when t1.f<(select -count(distinct (select count(*)-min(13) from t1)) from t1) then d when t1.d between t1.b and f and not (t1.b between ( -t1.f) and f) then -d else b end-b | t1.f*17 from t1 where ((d>t1.d))),17))/abs(11))-13=t1.c then a else 11 end else b end FROM t1 WHERE NOT (t1.b between coalesce((select case when coalesce((select t1.c from t1 where not ((t1.a>=11+17 and (13+(11)<>13))) and b<=c and c in (c, -c,(e)) and d not in (f,b,c) or t1.d>=13 and 13 between 19 and a),d) not between 13-case when t1.f<>t1.b then t1.f else t1.c end | d and d then b when c<c then 13 else 11 end*t1.e from t1 where b>= -d),19) and c)}
+} {200}
+do_test randexpr-2.2096 {
+ db eval {SELECT case d when f then case when (abs(coalesce((select ~f*case when t1.f<(select -count(distinct (select count(*)-min(13) from t1)) from t1) then d when t1.d between t1.b and f and not (t1.b between ( -t1.f) and f) then -d else b end-b & t1.f*17 from t1 where ((d>t1.d))),17))/abs(11))-13=t1.c then a else 11 end else b end FROM t1 WHERE NOT (t1.b between coalesce((select case when coalesce((select t1.c from t1 where not ((t1.a>=11+17 and (13+(11)<>13))) and b<=c and c in (c, -c,(e)) and d not in (f,b,c) or t1.d>=13 and 13 between 19 and a),d) not between 13-case when t1.f<>t1.b then t1.f else t1.c end | d and d then b when c<c then 13 else 11 end*t1.e from t1 where b>= -d),19) and c)}
+} {200}
+do_test randexpr-2.2097 {
+ db eval {SELECT (coalesce((select case when exists(select 1 from t1 where case when (t1.b)>=f+e*coalesce((select max( -+t1.c) from t1 where case a when e then e else 11 end in (select 17 from t1 union select d from t1) or e not between d and a),t1.f) then ( -t1.d) else e end in (11,c,b)) then 17 else t1.f end+t1.f from t1 where not d in ((b),(f),11) and t1.f<f),19)) FROM t1 WHERE exists(select 1 from t1 where coalesce((select max(case when t1.d in (select -a from t1 union select 11 from t1) then t1.b when case when t1.f not in (t1.d, -19,t1.e) and t1.a>=t1.b and 19<13 then 19 else 13 end<a then e else b end) from t1 where t1.f in (select +count(distinct - -13)* - -case max(t1.f) when max(13) then (min(t1.c)) else (max(t1.b)) end from t1 union select cast(avg(t1.a) AS integer) from t1) or t1.e not in (b,17,e)), -17)>=19) and b not in (c,t1.a,d) or b between e and -t1.f or t1.b between t1.e and c and t1.a<=t1.d}
+} {}
+do_test randexpr-2.2098 {
+ db eval {SELECT (coalesce((select case when exists(select 1 from t1 where case when (t1.b)>=f+e*coalesce((select max( -+t1.c) from t1 where case a when e then e else 11 end in (select 17 from t1 union select d from t1) or e not between d and a),t1.f) then ( -t1.d) else e end in (11,c,b)) then 17 else t1.f end+t1.f from t1 where not d in ((b),(f),11) and t1.f<f),19)) FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select max(case when t1.d in (select -a from t1 union select 11 from t1) then t1.b when case when t1.f not in (t1.d, -19,t1.e) and t1.a>=t1.b and 19<13 then 19 else 13 end<a then e else b end) from t1 where t1.f in (select +count(distinct - -13)* - -case max(t1.f) when max(13) then (min(t1.c)) else (max(t1.b)) end from t1 union select cast(avg(t1.a) AS integer) from t1) or t1.e not in (b,17,e)), -17)>=19) and b not in (c,t1.a,d) or b between e and -t1.f or t1.b between t1.e and c and t1.a<=t1.d)}
+} {19}
+do_test randexpr-2.2099 {
+ db eval {SELECT 11+17+case when case 17 when coalesce((select max(d) from t1 where 13+(t1.c-e)+19+e-t1.e>=b and not 11 not in (19,t1.e,13) and (t1.f)>b),19)*19 then c else -d end not in (c,19,t1.c) then d when d<=t1.d then 13 else 11 end+ -a FROM t1 WHERE coalesce((select max(~t1.f) from t1 where (13*t1.e)<=case when 17 | a<=t1.e then coalesce((select max(19) from t1 where case when not not exists(select 1 from t1 where 19 in (t1.d+19,11,t1.f) or not exists(select 1 from t1 where a<e)) then case when t1.d<(t1.b) then t1.d when 13>=t1.c then - -11 else t1.b end else f end-f<=b),t1.b) else t1.e end),f)-19>=13}
+} {328}
+do_test randexpr-2.2100 {
+ db eval {SELECT 11+17+case when case 17 when coalesce((select max(d) from t1 where 13+(t1.c-e)+19+e-t1.e>=b and not 11 not in (19,t1.e,13) and (t1.f)>b),19)*19 then c else -d end not in (c,19,t1.c) then d when d<=t1.d then 13 else 11 end+ -a FROM t1 WHERE NOT (coalesce((select max(~t1.f) from t1 where (13*t1.e)<=case when 17 | a<=t1.e then coalesce((select max(19) from t1 where case when not not exists(select 1 from t1 where 19 in (t1.d+19,11,t1.f) or not exists(select 1 from t1 where a<e)) then case when t1.d<(t1.b) then t1.d when 13>=t1.c then - -11 else t1.b end else f end-f<=b),t1.b) else t1.e end),f)-19>=13)}
+} {}
+do_test randexpr-2.2101 {
+ db eval {SELECT coalesce((select max(t1.a+(select count(distinct 11-case when coalesce((select max(11) from t1 where t1.f<(t1.a)-t1.b),b) in (select ~abs(min(c-case when (case 13 when -coalesce((select (t1.e) from t1 where -a not in (f,t1.d,d)),(11)) then b else t1.e end not between b and -t1.e) then e else t1.a end)) | count(*) from t1 union select -min(17) from t1) then t1.a else t1.d end) from t1)-t1.b) from t1 where 17<t1.e),t1.e) FROM t1 WHERE case when not (not exists(select 1 from t1 where c*case when (a>11) then e else a end-t1.c+(d)*(13) in (select ~count(distinct (t1.f))+ -~ -count(distinct t1.e)+(min(13)) from t1 union select cast(avg(11) AS integer) from t1) or t1.e<>t1.f)) then f when not a<19 then coalesce((select max(11) from t1 where (t1.d) between -d and -t1.e or t1.f not between d and a and -b=19),t1.b) else +t1.f end not between a and e}
+} {-99}
+do_test randexpr-2.2102 {
+ db eval {SELECT coalesce((select max(t1.a+(select count(distinct 11-case when coalesce((select max(11) from t1 where t1.f<(t1.a)-t1.b),b) in (select ~abs(min(c-case when (case 13 when -coalesce((select (t1.e) from t1 where -a not in (f,t1.d,d)),(11)) then b else t1.e end not between b and -t1.e) then e else t1.a end)) | count(*) from t1 union select -min(17) from t1) then t1.a else t1.d end) from t1)-t1.b) from t1 where 17<t1.e),t1.e) FROM t1 WHERE NOT (case when not (not exists(select 1 from t1 where c*case when (a>11) then e else a end-t1.c+(d)*(13) in (select ~count(distinct (t1.f))+ -~ -count(distinct t1.e)+(min(13)) from t1 union select cast(avg(11) AS integer) from t1) or t1.e<>t1.f)) then f when not a<19 then coalesce((select max(11) from t1 where (t1.d) between -d and -t1.e or t1.f not between d and a and -b=19),t1.b) else +t1.f end not between a and e)}
+} {}
+do_test randexpr-2.2103 {
+ db eval {SELECT coalesce((select max(t1.a+(select count(distinct 11-case when coalesce((select max(11) from t1 where t1.f<(t1.a)-t1.b),b) in (select ~abs(min(c-case when (case 13 when -coalesce((select (t1.e) from t1 where -a not in (f,t1.d,d)),(11)) then b else t1.e end not between b and -t1.e) then e else t1.a end)) & count(*) from t1 union select -min(17) from t1) then t1.a else t1.d end) from t1)-t1.b) from t1 where 17<t1.e),t1.e) FROM t1 WHERE case when not (not exists(select 1 from t1 where c*case when (a>11) then e else a end-t1.c+(d)*(13) in (select ~count(distinct (t1.f))+ -~ -count(distinct t1.e)+(min(13)) from t1 union select cast(avg(11) AS integer) from t1) or t1.e<>t1.f)) then f when not a<19 then coalesce((select max(11) from t1 where (t1.d) between -d and -t1.e or t1.f not between d and a and -b=19),t1.b) else +t1.f end not between a and e}
+} {-99}
+do_test randexpr-2.2104 {
+ db eval {SELECT t1.b-case when 13 not between 13 and (select +count(*) from t1) then t1.e when +11 in (coalesce((select t1.f from t1 where d-((f))*coalesce((select d from t1 where 17 between ~(select max(d) | count(*) | cast(avg(e) AS integer)+count(*) from t1) and case when c<13 or 17>13 then a else e end-t1.b),e)-t1.a<=(t1.e)),19),b,13) then e else b end-t1.b FROM t1 WHERE t1.b>=coalesce((select max(d-c) from t1 where exists(select 1 from t1 where (~a*(select -count(distinct 11-d*13+d+19) from t1)* -b in (f,t1.d-c,a-(abs(c)/abs(case when (abs(13- -(19))/abs(t1.f)) in (select c from t1 union select -a from t1) then t1.c when b<=c then t1.a else -13 end)))))),19)}
+} {-500}
+do_test randexpr-2.2105 {
+ db eval {SELECT t1.b-case when 13 not between 13 and (select +count(*) from t1) then t1.e when +11 in (coalesce((select t1.f from t1 where d-((f))*coalesce((select d from t1 where 17 between ~(select max(d) | count(*) | cast(avg(e) AS integer)+count(*) from t1) and case when c<13 or 17>13 then a else e end-t1.b),e)-t1.a<=(t1.e)),19),b,13) then e else b end-t1.b FROM t1 WHERE NOT (t1.b>=coalesce((select max(d-c) from t1 where exists(select 1 from t1 where (~a*(select -count(distinct 11-d*13+d+19) from t1)* -b in (f,t1.d-c,a-(abs(c)/abs(case when (abs(13- -(19))/abs(t1.f)) in (select c from t1 union select -a from t1) then t1.c when b<=c then t1.a else -13 end)))))),19))}
+} {}
+do_test randexpr-2.2106 {
+ db eval {SELECT t1.b-case when 13 not between 13 and (select +count(*) from t1) then t1.e when +11 in (coalesce((select t1.f from t1 where d-((f))*coalesce((select d from t1 where 17 between ~(select max(d) & count(*) & cast(avg(e) AS integer)+count(*) from t1) and case when c<13 or 17>13 then a else e end-t1.b),e)-t1.a<=(t1.e)),19),b,13) then e else b end-t1.b FROM t1 WHERE t1.b>=coalesce((select max(d-c) from t1 where exists(select 1 from t1 where (~a*(select -count(distinct 11-d*13+d+19) from t1)* -b in (f,t1.d-c,a-(abs(c)/abs(case when (abs(13- -(19))/abs(t1.f)) in (select c from t1 union select -a from t1) then t1.c when b<=c then t1.a else -13 end)))))),19)}
+} {-500}
+do_test randexpr-2.2107 {
+ db eval {SELECT t1.f*case when c*case when t1.d*t1.b-(~19) in (select (cast(avg(d-t1.d) AS integer)) from t1 union select min(11)+cast(avg(e) AS integer) | abs(count(distinct t1.a) | min(19)) from t1) then t1.d when not 11 not in (d,t1.e,13) then t1.a else 11 end in (select (t1.c) from t1 union select 11 from t1) or t1.e not in (f, -t1.f,t1.e) then c else d end FROM t1 WHERE case when t1.e=t1.c and (abs(case when (11* -17 not in (c,t1.f-t1.c-coalesce((select max(c) from t1 where c in (select min(19) from t1 union select ~count(*)*max(t1.f) from t1)),a),t1.a)) then coalesce((select max(17) from t1 where -b>=(t1.c)),19) else f end+19)/abs(t1.f))*t1.d between d and b then t1.b-t1.e else c end=19}
+} {}
+do_test randexpr-2.2108 {
+ db eval {SELECT t1.f*case when c*case when t1.d*t1.b-(~19) in (select (cast(avg(d-t1.d) AS integer)) from t1 union select min(11)+cast(avg(e) AS integer) | abs(count(distinct t1.a) | min(19)) from t1) then t1.d when not 11 not in (d,t1.e,13) then t1.a else 11 end in (select (t1.c) from t1 union select 11 from t1) or t1.e not in (f, -t1.f,t1.e) then c else d end FROM t1 WHERE NOT (case when t1.e=t1.c and (abs(case when (11* -17 not in (c,t1.f-t1.c-coalesce((select max(c) from t1 where c in (select min(19) from t1 union select ~count(*)*max(t1.f) from t1)),a),t1.a)) then coalesce((select max(17) from t1 where -b>=(t1.c)),19) else f end+19)/abs(t1.f))*t1.d between d and b then t1.b-t1.e else c end=19)}
+} {240000}
+do_test randexpr-2.2109 {
+ db eval {SELECT t1.f*case when c*case when t1.d*t1.b-(~19) in (select (cast(avg(d-t1.d) AS integer)) from t1 union select min(11)+cast(avg(e) AS integer) & abs(count(distinct t1.a) & min(19)) from t1) then t1.d when not 11 not in (d,t1.e,13) then t1.a else 11 end in (select (t1.c) from t1 union select 11 from t1) or t1.e not in (f, -t1.f,t1.e) then c else d end FROM t1 WHERE NOT (case when t1.e=t1.c and (abs(case when (11* -17 not in (c,t1.f-t1.c-coalesce((select max(c) from t1 where c in (select min(19) from t1 union select ~count(*)*max(t1.f) from t1)),a),t1.a)) then coalesce((select max(17) from t1 where -b>=(t1.c)),19) else f end+19)/abs(t1.f))*t1.d between d and b then t1.b-t1.e else c end=19)}
+} {240000}
+do_test randexpr-2.2110 {
+ db eval {SELECT coalesce((select max((abs(t1.d)/abs((coalesce((select c from t1 where (abs(+f)/abs(t1.b))-t1.a between 13 and case (13+c+((abs(coalesce((select 11 from t1 where 11+19<b),case t1.f when t1.f then b else 11 end)*a)/abs(c)))+t1.f) when f then -c else t1.f end),e)-t1.e*19)))) from t1 where e<e),t1.c) FROM t1 WHERE c in (select c+19 from t1 union select +t1.f from t1) and t1.e<case when case (abs(t1.a)/abs(t1.b))-coalesce((select (abs(e+t1.e | b)/abs(e))*13 from t1 where (c=11) and b< -f or 13=b or -d< -(e)),b) when e then 11 else t1.e end between b and (19) then t1.b else c end}
+} {}
+do_test randexpr-2.2111 {
+ db eval {SELECT coalesce((select max((abs(t1.d)/abs((coalesce((select c from t1 where (abs(+f)/abs(t1.b))-t1.a between 13 and case (13+c+((abs(coalesce((select 11 from t1 where 11+19<b),case t1.f when t1.f then b else 11 end)*a)/abs(c)))+t1.f) when f then -c else t1.f end),e)-t1.e*19)))) from t1 where e<e),t1.c) FROM t1 WHERE NOT (c in (select c+19 from t1 union select +t1.f from t1) and t1.e<case when case (abs(t1.a)/abs(t1.b))-coalesce((select (abs(e+t1.e | b)/abs(e))*13 from t1 where (c=11) and b< -f or 13=b or -d< -(e)),b) when e then 11 else t1.e end between b and (19) then t1.b else c end)}
+} {300}
+do_test randexpr-2.2112 {
+ db eval {SELECT f+coalesce((select max(t1.f) from t1 where (case when 13<>a then (coalesce((select -e from t1 where case coalesce((select case when 19 in (select t1.e from t1 union select f from t1) then b when t1.c=11 then a else (13) end from t1 where t1.a in (select ( -cast(avg(13) AS integer)+max(t1.e)) from t1 union select cast(avg(19) AS integer) from t1)),19) when f then f else ( -t1.c) end+17<=e and a>=t1.b or t1.c>=b),t1.e)) else e end)>=e),b)+f FROM t1 WHERE exists(select 1 from t1 where 17 in (select -abs(case (min(t1.b)) when count(*)*max(a) then -abs((max(e))) | ~max( -coalesce((select max(coalesce((select e from t1 where f>=11 or exists(select 1 from t1 where 11 not in (11,t1.c,f))),d)) from t1 where 13=t1.d and 17<>f),t1.d))+count(distinct t1.e) else count(*)+~cast(avg(t1.f) AS integer) end | count(distinct t1.a))+count(distinct t1.a) from t1 union select count(*) from t1))}
+} {}
+do_test randexpr-2.2113 {
+ db eval {SELECT f+coalesce((select max(t1.f) from t1 where (case when 13<>a then (coalesce((select -e from t1 where case coalesce((select case when 19 in (select t1.e from t1 union select f from t1) then b when t1.c=11 then a else (13) end from t1 where t1.a in (select ( -cast(avg(13) AS integer)+max(t1.e)) from t1 union select cast(avg(19) AS integer) from t1)),19) when f then f else ( -t1.c) end+17<=e and a>=t1.b or t1.c>=b),t1.e)) else e end)>=e),b)+f FROM t1 WHERE NOT (exists(select 1 from t1 where 17 in (select -abs(case (min(t1.b)) when count(*)*max(a) then -abs((max(e))) | ~max( -coalesce((select max(coalesce((select e from t1 where f>=11 or exists(select 1 from t1 where 11 not in (11,t1.c,f))),d)) from t1 where 13=t1.d and 17<>f),t1.d))+count(distinct t1.e) else count(*)+~cast(avg(t1.f) AS integer) end | count(distinct t1.a))+count(distinct t1.a) from t1 union select count(*) from t1)))}
+} {1400}
+do_test randexpr-2.2114 {
+ db eval {SELECT case when case when (abs( -t1.b)/abs(case case case (select ~ -(+abs(case min(19) when (( -min(t1.e))) then count(distinct (t1.e)) else cast(avg(11) AS integer) end)) from t1) when t1.e then (select min(19) from t1) else 17 end when (13)-a*17 then t1.d else t1.a end when a then 19 else -( -f) end))>=d then t1.e else 13 end between f and 19 then f when t1.c<=t1.a or (t1.b>(11)) then 11 else t1.b end FROM t1 WHERE t1.c in (select case when 11<17 then case when (t1.b*coalesce((select (abs((coalesce((select a-19 from t1 where t1.c between e and f and d<>17 and t1.d not between 19 and 19),a)))/abs(t1.c))+t1.b-17 from t1 where c=a), -t1.d)+c>t1.f) then -13+(t1.e) when 11<>t1.c then 13 else t1.c end when 11=c then t1.c else (c) end from t1 union select t1.e from t1)}
+} {}
+do_test randexpr-2.2115 {
+ db eval {SELECT case when case when (abs( -t1.b)/abs(case case case (select ~ -(+abs(case min(19) when (( -min(t1.e))) then count(distinct (t1.e)) else cast(avg(11) AS integer) end)) from t1) when t1.e then (select min(19) from t1) else 17 end when (13)-a*17 then t1.d else t1.a end when a then 19 else -( -f) end))>=d then t1.e else 13 end between f and 19 then f when t1.c<=t1.a or (t1.b>(11)) then 11 else t1.b end FROM t1 WHERE NOT (t1.c in (select case when 11<17 then case when (t1.b*coalesce((select (abs((coalesce((select a-19 from t1 where t1.c between e and f and d<>17 and t1.d not between 19 and 19),a)))/abs(t1.c))+t1.b-17 from t1 where c=a), -t1.d)+c>t1.f) then -13+(t1.e) when 11<>t1.c then 13 else t1.c end when 11=c then t1.c else (c) end from t1 union select t1.e from t1))}
+} {11}
+do_test randexpr-2.2116 {
+ db eval {SELECT t1.e+coalesce((select case t1.a-case when t1.a in (case (abs(coalesce((select t1.e from t1 where t1.a>t1.b),~c))/abs(t1.b))* -(select count(distinct t1.c)-cast(avg(coalesce((select 19 from t1 where c not between (abs(b-11)/abs( -t1.e)) and (17)),17)) AS integer) from t1) when t1.e then f else 17 end,t1.c,t1.c) then d else t1.e end when d then 17 else 13 end from t1 where 11<11),t1.f) FROM t1 WHERE 11* -19 in (select case when ~coalesce((select t1.b from t1 where coalesce((select d from t1 where t1.a=17*~e+t1.d*case when 11< -~t1.b*t1.b*c+a then (c) else 19 end*a),e)>e),11)<=19 then t1.c when (not exists(select 1 from t1 where t1.d<17)) then b else c end from t1 union select t1.a from t1)}
+} {}
+do_test randexpr-2.2117 {
+ db eval {SELECT t1.e+coalesce((select case t1.a-case when t1.a in (case (abs(coalesce((select t1.e from t1 where t1.a>t1.b),~c))/abs(t1.b))* -(select count(distinct t1.c)-cast(avg(coalesce((select 19 from t1 where c not between (abs(b-11)/abs( -t1.e)) and (17)),17)) AS integer) from t1) when t1.e then f else 17 end,t1.c,t1.c) then d else t1.e end when d then 17 else 13 end from t1 where 11<11),t1.f) FROM t1 WHERE NOT (11* -19 in (select case when ~coalesce((select t1.b from t1 where coalesce((select d from t1 where t1.a=17*~e+t1.d*case when 11< -~t1.b*t1.b*c+a then (c) else 19 end*a),e)>e),11)<=19 then t1.c when (not exists(select 1 from t1 where t1.d<17)) then b else c end from t1 union select t1.a from t1))}
+} {1100}
+do_test randexpr-2.2118 {
+ db eval {SELECT 19* -coalesce((select coalesce((select t1.d*17 from t1 where t1.b<=t1.b+17), -(a | 17)) from t1 where t1.d in (select case abs(count(*))*count(distinct (17)) when max(11) then abs(+max(13)-case -cast(avg(t1.d) AS integer)- -(max(19))-count(distinct d) when min(t1.c) then cast(avg(c) AS integer) else count(distinct t1.f) end | max(c)) else max(t1.d) end from t1 union select count(*) from t1)),t1.f)-t1.e+c FROM t1 WHERE ~(abs(case 17 when d then coalesce((select t1.d from t1 where 13 in (select t1.d-f | case when (17 in (t1.a,19,t1.f)) then case when a*f in (select e from t1 union select t1.a from t1) or 11=t1.c or t1.a>=(19) and ( -b)<f or e<>13 then b when t1.e in (t1.c, -t1.b,a) then 19 else 19 end else a end from t1 union select t1.b from t1)),d) else 13 end)/abs(11))+19*t1.e in (e, -t1.e,a)}
+} {}
+do_test randexpr-2.2119 {
+ db eval {SELECT 19* -coalesce((select coalesce((select t1.d*17 from t1 where t1.b<=t1.b+17), -(a | 17)) from t1 where t1.d in (select case abs(count(*))*count(distinct (17)) when max(11) then abs(+max(13)-case -cast(avg(t1.d) AS integer)- -(max(19))-count(distinct d) when min(t1.c) then cast(avg(c) AS integer) else count(distinct t1.f) end | max(c)) else max(t1.d) end from t1 union select count(*) from t1)),t1.f)-t1.e+c FROM t1 WHERE NOT (~(abs(case 17 when d then coalesce((select t1.d from t1 where 13 in (select t1.d-f | case when (17 in (t1.a,19,t1.f)) then case when a*f in (select e from t1 union select t1.a from t1) or 11=t1.c or t1.a>=(19) and ( -b)<f or e<>13 then b when t1.e in (t1.c, -t1.b,a) then 19 else 19 end else a end from t1 union select t1.b from t1)),d) else 13 end)/abs(11))+19*t1.e in (e, -t1.e,a))}
+} {-129400}
+do_test randexpr-2.2120 {
+ db eval {SELECT 19* -coalesce((select coalesce((select t1.d*17 from t1 where t1.b<=t1.b+17), -(a & 17)) from t1 where t1.d in (select case abs(count(*))*count(distinct (17)) when max(11) then abs(+max(13)-case -cast(avg(t1.d) AS integer)- -(max(19))-count(distinct d) when min(t1.c) then cast(avg(c) AS integer) else count(distinct t1.f) end & max(c)) else max(t1.d) end from t1 union select count(*) from t1)),t1.f)-t1.e+c FROM t1 WHERE NOT (~(abs(case 17 when d then coalesce((select t1.d from t1 where 13 in (select t1.d-f | case when (17 in (t1.a,19,t1.f)) then case when a*f in (select e from t1 union select t1.a from t1) or 11=t1.c or t1.a>=(19) and ( -b)<f or e<>13 then b when t1.e in (t1.c, -t1.b,a) then 19 else 19 end else a end from t1 union select t1.b from t1)),d) else 13 end)/abs(11))+19*t1.e in (e, -t1.e,a))}
+} {-129400}
+do_test randexpr-2.2121 {
+ db eval {SELECT case t1.f when f then t1.a-case d+t1.d+coalesce((select (select cast(avg( -case when t1.d in (select -min(17)-count(*)+max(f) from t1 union select -count(distinct 13) from t1) then t1.e else a end*a) AS integer) from t1)-t1.d from t1 where -t1.b not in (11, -(t1.b),t1.d) and c in (select b from t1 union select 19 from t1) and t1.a in (select -e from t1 union select t1.e from t1)),a)*t1.f when 19 then t1.f else 11 end else c end FROM t1 WHERE t1.c>11}
+} {89}
+do_test randexpr-2.2122 {
+ db eval {SELECT case t1.f when f then t1.a-case d+t1.d+coalesce((select (select cast(avg( -case when t1.d in (select -min(17)-count(*)+max(f) from t1 union select -count(distinct 13) from t1) then t1.e else a end*a) AS integer) from t1)-t1.d from t1 where -t1.b not in (11, -(t1.b),t1.d) and c in (select b from t1 union select 19 from t1) and t1.a in (select -e from t1 union select t1.e from t1)),a)*t1.f when 19 then t1.f else 11 end else c end FROM t1 WHERE NOT (t1.c>11)}
+} {}
+do_test randexpr-2.2123 {
+ db eval {SELECT case when (case when (e not in (e | e,17,e)) then 13 else t1.b end>+t1.b*f-b+t1.d-e) or 19 between b and t1.a then 11 when exists(select 1 from t1 where (t1.d) | t1.d in (case when (e>=(11)) or (t1.a)>=t1.f then c-b when t1.c<>t1.e then t1.a else (17) end,c,13)) then 17 else t1.b end FROM t1 WHERE (select min(case when a not in (coalesce((select 19 from t1 where t1.f<((abs(e)/abs(t1.a+e)) | d)-e),e),t1.f,t1.a) then c else 13 end)-(count(distinct d)-abs(count(distinct t1.c)-cast(avg(d) AS integer) | min(b)+(cast(avg(19) AS integer) | case count(distinct t1.c) when cast(avg( -t1.b) AS integer) then cast(avg(t1.a) AS integer) else max(13) end))) from t1) not between b | a and 19}
+} {200}
+do_test randexpr-2.2124 {
+ db eval {SELECT case when (case when (e not in (e | e,17,e)) then 13 else t1.b end>+t1.b*f-b+t1.d-e) or 19 between b and t1.a then 11 when exists(select 1 from t1 where (t1.d) | t1.d in (case when (e>=(11)) or (t1.a)>=t1.f then c-b when t1.c<>t1.e then t1.a else (17) end,c,13)) then 17 else t1.b end FROM t1 WHERE NOT ((select min(case when a not in (coalesce((select 19 from t1 where t1.f<((abs(e)/abs(t1.a+e)) | d)-e),e),t1.f,t1.a) then c else 13 end)-(count(distinct d)-abs(count(distinct t1.c)-cast(avg(d) AS integer) | min(b)+(cast(avg(19) AS integer) | case count(distinct t1.c) when cast(avg( -t1.b) AS integer) then cast(avg(t1.a) AS integer) else max(13) end))) from t1) not between b | a and 19)}
+} {}
+do_test randexpr-2.2125 {
+ db eval {SELECT case when (case when (e not in (e & e,17,e)) then 13 else t1.b end>+t1.b*f-b+t1.d-e) or 19 between b and t1.a then 11 when exists(select 1 from t1 where (t1.d) & t1.d in (case when (e>=(11)) or (t1.a)>=t1.f then c-b when t1.c<>t1.e then t1.a else (17) end,c,13)) then 17 else t1.b end FROM t1 WHERE (select min(case when a not in (coalesce((select 19 from t1 where t1.f<((abs(e)/abs(t1.a+e)) | d)-e),e),t1.f,t1.a) then c else 13 end)-(count(distinct d)-abs(count(distinct t1.c)-cast(avg(d) AS integer) | min(b)+(cast(avg(19) AS integer) | case count(distinct t1.c) when cast(avg( -t1.b) AS integer) then cast(avg(t1.a) AS integer) else max(13) end))) from t1) not between b | a and 19}
+} {200}
+do_test randexpr-2.2126 {
+ db eval {SELECT case when case when t1.c+13<13 then 11 when (t1.b) not in (t1.b,e,t1.c) then t1.f else -t1.c end- -a | 13 in (select max(a) from t1 union select count(distinct 17)* -case count(*) when count(*) then -((count(distinct 17))) else max(t1.b) end | ( -count(*)) from t1) and e<=17 and t1.c<=d then coalesce((select max(coalesce((select max(e) from t1 where t1.f not in (e,17,t1.b) and d= -t1.b),t1.d)) from t1 where t1.d<f),b) when -c not between f and t1.f then b else t1.a end FROM t1 WHERE a<=case b when coalesce((select max(19) from t1 where (coalesce((select max(11) from t1 where ((not coalesce((select max(t1.e) from t1 where -19 in (select count(*) from t1 union select (max(t1.c)) from t1)),t1.a)-11 between f and t1.c))),case when exists(select 1 from t1 where -(17)< -a) then 17*17 else a end) not in (17,b,t1.e)) or 17 between a and t1.f and -a<11 and 19<=(t1.b)),t1.c) then ~case when 11>(f) then t1.e else 17 end else t1.c end-19}
+} {200}
+do_test randexpr-2.2127 {
+ db eval {SELECT case when case when t1.c+13<13 then 11 when (t1.b) not in (t1.b,e,t1.c) then t1.f else -t1.c end- -a | 13 in (select max(a) from t1 union select count(distinct 17)* -case count(*) when count(*) then -((count(distinct 17))) else max(t1.b) end | ( -count(*)) from t1) and e<=17 and t1.c<=d then coalesce((select max(coalesce((select max(e) from t1 where t1.f not in (e,17,t1.b) and d= -t1.b),t1.d)) from t1 where t1.d<f),b) when -c not between f and t1.f then b else t1.a end FROM t1 WHERE NOT (a<=case b when coalesce((select max(19) from t1 where (coalesce((select max(11) from t1 where ((not coalesce((select max(t1.e) from t1 where -19 in (select count(*) from t1 union select (max(t1.c)) from t1)),t1.a)-11 between f and t1.c))),case when exists(select 1 from t1 where -(17)< -a) then 17*17 else a end) not in (17,b,t1.e)) or 17 between a and t1.f and -a<11 and 19<=(t1.b)),t1.c) then ~case when 11>(f) then t1.e else 17 end else t1.c end-19)}
+} {}
+do_test randexpr-2.2128 {
+ db eval {SELECT case when case when t1.c+13<13 then 11 when (t1.b) not in (t1.b,e,t1.c) then t1.f else -t1.c end- -a & 13 in (select max(a) from t1 union select count(distinct 17)* -case count(*) when count(*) then -((count(distinct 17))) else max(t1.b) end & ( -count(*)) from t1) and e<=17 and t1.c<=d then coalesce((select max(coalesce((select max(e) from t1 where t1.f not in (e,17,t1.b) and d= -t1.b),t1.d)) from t1 where t1.d<f),b) when -c not between f and t1.f then b else t1.a end FROM t1 WHERE a<=case b when coalesce((select max(19) from t1 where (coalesce((select max(11) from t1 where ((not coalesce((select max(t1.e) from t1 where -19 in (select count(*) from t1 union select (max(t1.c)) from t1)),t1.a)-11 between f and t1.c))),case when exists(select 1 from t1 where -(17)< -a) then 17*17 else a end) not in (17,b,t1.e)) or 17 between a and t1.f and -a<11 and 19<=(t1.b)),t1.c) then ~case when 11>(f) then t1.e else 17 end else t1.c end-19}
+} {200}
+do_test randexpr-2.2129 {
+ db eval {SELECT coalesce((select case t1.e when coalesce((select max(e- -coalesce((select 17-d-e from t1 where ( -e*(d)>t1.c and 17=(t1.b) or not 11>(a) and b not between ((f)) and t1.d)),t1.c)-f-(f)*b+t1.a) from t1 where f<>13),t1.b) then t1.c else t1.b end from t1 where c in (select t1.a from t1 union select (t1.e) from t1)),e) FROM t1 WHERE (c in (select ~abs(cast(avg(19) AS integer))- -(case (++abs(max( -(select case case ( -abs(+cast(avg(b) AS integer) | count(distinct t1.b*17)*min( -11)*count(distinct t1.e))) when (max( -t1.b)) then count(distinct e) else max(11) end when -min(d) then count(*) else cast(avg(t1.a) AS integer) end from t1))*max(11))) when min(b) then max(19) else (count(*)) end)* -(max(t1.a))-count(*) from t1 union select count(distinct t1.a) from t1))}
+} {}
+do_test randexpr-2.2130 {
+ db eval {SELECT coalesce((select case t1.e when coalesce((select max(e- -coalesce((select 17-d-e from t1 where ( -e*(d)>t1.c and 17=(t1.b) or not 11>(a) and b not between ((f)) and t1.d)),t1.c)-f-(f)*b+t1.a) from t1 where f<>13),t1.b) then t1.c else t1.b end from t1 where c in (select t1.a from t1 union select (t1.e) from t1)),e) FROM t1 WHERE NOT ((c in (select ~abs(cast(avg(19) AS integer))- -(case (++abs(max( -(select case case ( -abs(+cast(avg(b) AS integer) | count(distinct t1.b*17)*min( -11)*count(distinct t1.e))) when (max( -t1.b)) then count(distinct e) else max(11) end when -min(d) then count(*) else cast(avg(t1.a) AS integer) end from t1))*max(11))) when min(b) then max(19) else (count(*)) end)* -(max(t1.a))-count(*) from t1 union select count(distinct t1.a) from t1)))}
+} {500}
+do_test randexpr-2.2131 {
+ db eval {SELECT t1.e+13-(abs(f)/abs(e | coalesce((select case when (f>=~t1.c*case t1.a when -d then (11) else 17 end*19) then case a when t1.e then b else e end else t1.c end from t1 where e in (select t1.a from t1 union select a from t1) or t1.d not in (f,f,17) and t1.b not between f and 17 and e=c),t1.c)*17+d+t1.d)) FROM t1 WHERE coalesce((select ~f+t1.c*t1.d | t1.d*t1.d-t1.b from t1 where t1.b | t1.a between case when (abs(coalesce((select f from t1 where t1.e between 11-17 and t1.c),e)-t1.d*b)/abs(((d))))-d between t1.b and d then a when -(f) between e and t1.e then t1.a else a end and t1.b),t1.a)-11=d}
+} {}
+do_test randexpr-2.2132 {
+ db eval {SELECT t1.e+13-(abs(f)/abs(e | coalesce((select case when (f>=~t1.c*case t1.a when -d then (11) else 17 end*19) then case a when t1.e then b else e end else t1.c end from t1 where e in (select t1.a from t1 union select a from t1) or t1.d not in (f,f,17) and t1.b not between f and 17 and e=c),t1.c)*17+d+t1.d)) FROM t1 WHERE NOT (coalesce((select ~f+t1.c*t1.d | t1.d*t1.d-t1.b from t1 where t1.b | t1.a between case when (abs(coalesce((select f from t1 where t1.e between 11-17 and t1.c),e)-t1.d*b)/abs(((d))))-d between t1.b and d then a when -(f) between e and t1.e then t1.a else a end and t1.b),t1.a)-11=d)}
+} {513}
+do_test randexpr-2.2133 {
+ db eval {SELECT t1.e+13-(abs(f)/abs(e & coalesce((select case when (f>=~t1.c*case t1.a when -d then (11) else 17 end*19) then case a when t1.e then b else e end else t1.c end from t1 where e in (select t1.a from t1 union select a from t1) or t1.d not in (f,f,17) and t1.b not between f and 17 and e=c),t1.c)*17+d+t1.d)) FROM t1 WHERE NOT (coalesce((select ~f+t1.c*t1.d | t1.d*t1.d-t1.b from t1 where t1.b | t1.a between case when (abs(coalesce((select f from t1 where t1.e between 11-17 and t1.c),e)-t1.d*b)/abs(((d))))-d between t1.b and d then a when -(f) between e and t1.e then t1.a else a end and t1.b),t1.a)-11=d)}
+} {511}
+do_test randexpr-2.2134 {
+ db eval {SELECT +(abs(~+13+(abs(t1.c)/abs(t1.c | coalesce((select t1.a from t1 where (select min(t1.c) from t1)<>(abs(t1.f | coalesce((select c from t1 where b=17),f)-b)/abs(coalesce((select max(d-t1.e) from t1 where not exists(select 1 from t1 where t1.e in (select f from t1 union select t1.d from t1))),19)*e+19)) or t1.a in (select 13 from t1 union select t1.d from t1) and (b)<= -t1.f),11))))/abs(e)) FROM t1 WHERE t1.e<>coalesce((select case 17 when f then coalesce((select max(t1.c) from t1 where coalesce((select coalesce((select ~e from t1 where not 17<=e | 17),11)+t1.d+t1.e from t1 where (e>=f or (not t1.e>=t1.a or e between f and t1.f))),t1.b) not in (13,17,c) or t1.a> -t1.d),19) else t1.c end from t1 where (not 17 not in (t1.b,11,b) and f>=t1.f) or 19<=t1.f),d)-11}
+} {0}
+do_test randexpr-2.2135 {
+ db eval {SELECT +(abs(~+13+(abs(t1.c)/abs(t1.c | coalesce((select t1.a from t1 where (select min(t1.c) from t1)<>(abs(t1.f | coalesce((select c from t1 where b=17),f)-b)/abs(coalesce((select max(d-t1.e) from t1 where not exists(select 1 from t1 where t1.e in (select f from t1 union select t1.d from t1))),19)*e+19)) or t1.a in (select 13 from t1 union select t1.d from t1) and (b)<= -t1.f),11))))/abs(e)) FROM t1 WHERE NOT (t1.e<>coalesce((select case 17 when f then coalesce((select max(t1.c) from t1 where coalesce((select coalesce((select ~e from t1 where not 17<=e | 17),11)+t1.d+t1.e from t1 where (e>=f or (not t1.e>=t1.a or e between f and t1.f))),t1.b) not in (13,17,c) or t1.a> -t1.d),19) else t1.c end from t1 where (not 17 not in (t1.b,11,b) and f>=t1.f) or 19<=t1.f),d)-11)}
+} {}
+do_test randexpr-2.2136 {
+ db eval {SELECT +(abs(~+13+(abs(t1.c)/abs(t1.c & coalesce((select t1.a from t1 where (select min(t1.c) from t1)<>(abs(t1.f & coalesce((select c from t1 where b=17),f)-b)/abs(coalesce((select max(d-t1.e) from t1 where not exists(select 1 from t1 where t1.e in (select f from t1 union select t1.d from t1))),19)*e+19)) or t1.a in (select 13 from t1 union select t1.d from t1) and (b)<= -t1.f),11))))/abs(e)) FROM t1 WHERE t1.e<>coalesce((select case 17 when f then coalesce((select max(t1.c) from t1 where coalesce((select coalesce((select ~e from t1 where not 17<=e | 17),11)+t1.d+t1.e from t1 where (e>=f or (not t1.e>=t1.a or e between f and t1.f))),t1.b) not in (13,17,c) or t1.a> -t1.d),19) else t1.c end from t1 where (not 17 not in (t1.b,11,b) and f>=t1.f) or 19<=t1.f),d)-11}
+} {0}
+do_test randexpr-2.2137 {
+ db eval {SELECT (case when not case when ((e not between d and case when not exists(select 1 from t1 where 11>=(a)*t1.d*11 or -(d) not in (a,11,t1.f)) then f else ~f end or not d<>t1.e or t1.c in (a,t1.d,t1.c))) then case when -b between 11 and b then (select count(distinct 17) from t1) when t1.e<>11 then f else d end else t1.d end<=a then (abs(t1.d)/abs(e)) when t1.d<t1.f then d else t1.e end) FROM t1 WHERE case when ~ -13*case when (not exists(select 1 from t1 where t1.c in (a,case case when 11<=17 then e else 13 end when 11 then 11 else b end,f))) then t1.a when not exists(select 1 from t1 where (t1.a>=t1.b and 17=t1.e)) then f else 19 end-t1.a*t1.a-e<=t1.b and 17 in (t1.d,13,t1.b) then c else t1.b end<>t1.b or not exists(select 1 from t1 where 17 between (d) and ( -(t1.d)))}
+} {0}
+do_test randexpr-2.2138 {
+ db eval {SELECT (case when not case when ((e not between d and case when not exists(select 1 from t1 where 11>=(a)*t1.d*11 or -(d) not in (a,11,t1.f)) then f else ~f end or not d<>t1.e or t1.c in (a,t1.d,t1.c))) then case when -b between 11 and b then (select count(distinct 17) from t1) when t1.e<>11 then f else d end else t1.d end<=a then (abs(t1.d)/abs(e)) when t1.d<t1.f then d else t1.e end) FROM t1 WHERE NOT (case when ~ -13*case when (not exists(select 1 from t1 where t1.c in (a,case case when 11<=17 then e else 13 end when 11 then 11 else b end,f))) then t1.a when not exists(select 1 from t1 where (t1.a>=t1.b and 17=t1.e)) then f else 19 end-t1.a*t1.a-e<=t1.b and 17 in (t1.d,13,t1.b) then c else t1.b end<>t1.b or not exists(select 1 from t1 where 17 between (d) and ( -(t1.d))))}
+} {}
+do_test randexpr-2.2139 {
+ db eval {SELECT t1.b+case when f+f not in (c+case when t1.f<>d then 11 when f between 11 and t1.d then 11 else 13 end,e,(t1.f)) and not exists(select 1 from t1 where (exists(select 1 from t1 where 19<11)) or 11 in ((t1.d),t1.c,b) and t1.b>13) and t1.b=t1.b then (abs(t1.d)/abs(13)) when a not between t1.c and 19 then t1.f else 19 end+13*17-t1.e FROM t1 WHERE not exists(select 1 from t1 where (exists(select 1 from t1 where t1.c>=19)))}
+} {}
+do_test randexpr-2.2140 {
+ db eval {SELECT t1.b+case when f+f not in (c+case when t1.f<>d then 11 when f between 11 and t1.d then 11 else 13 end,e,(t1.f)) and not exists(select 1 from t1 where (exists(select 1 from t1 where 19<11)) or 11 in ((t1.d),t1.c,b) and t1.b>13) and t1.b=t1.b then (abs(t1.d)/abs(13)) when a not between t1.c and 19 then t1.f else 19 end+13*17-t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where (exists(select 1 from t1 where t1.c>=19))))}
+} {-49}
+do_test randexpr-2.2141 {
+ db eval {SELECT (case when f>(select abs((((count(*)-+cast(avg(d) AS integer)))) | count(distinct a)) from t1) then case when (abs(coalesce((select max(t1.d) from t1 where coalesce((select max(case when t1.b between t1.f and a then -f when f<> -b then t1.e else -19 end) from t1 where not exists(select 1 from t1 where t1.c not in (t1.f,t1.c,t1.a))),t1.c)<=b), -t1.c))/abs(t1.a))<t1.b and exists(select 1 from t1 where t1.c between d and t1.f) then t1.a else t1.d end when a not in (e, -t1.f,t1.a) or f in (d,t1.c,(f)) and d in (t1.e,17,c) then 19 else (b) end)+t1.b FROM t1 WHERE t1.d>11}
+} {600}
+do_test randexpr-2.2142 {
+ db eval {SELECT (case when f>(select abs((((count(*)-+cast(avg(d) AS integer)))) | count(distinct a)) from t1) then case when (abs(coalesce((select max(t1.d) from t1 where coalesce((select max(case when t1.b between t1.f and a then -f when f<> -b then t1.e else -19 end) from t1 where not exists(select 1 from t1 where t1.c not in (t1.f,t1.c,t1.a))),t1.c)<=b), -t1.c))/abs(t1.a))<t1.b and exists(select 1 from t1 where t1.c between d and t1.f) then t1.a else t1.d end when a not in (e, -t1.f,t1.a) or f in (d,t1.c,(f)) and d in (t1.e,17,c) then 19 else (b) end)+t1.b FROM t1 WHERE NOT (t1.d>11)}
+} {}
+do_test randexpr-2.2143 {
+ db eval {SELECT (case when f>(select abs((((count(*)-+cast(avg(d) AS integer)))) & count(distinct a)) from t1) then case when (abs(coalesce((select max(t1.d) from t1 where coalesce((select max(case when t1.b between t1.f and a then -f when f<> -b then t1.e else -19 end) from t1 where not exists(select 1 from t1 where t1.c not in (t1.f,t1.c,t1.a))),t1.c)<=b), -t1.c))/abs(t1.a))<t1.b and exists(select 1 from t1 where t1.c between d and t1.f) then t1.a else t1.d end when a not in (e, -t1.f,t1.a) or f in (d,t1.c,(f)) and d in (t1.e,17,c) then 19 else (b) end)+t1.b FROM t1 WHERE t1.d>11}
+} {600}
+do_test randexpr-2.2144 {
+ db eval {SELECT (abs(+coalesce((select t1.f from t1 where not exists(select 1 from t1 where (((c)<=t1.a)))),f+(select count(distinct t1.b) from t1)*t1.b+case when case (select count(*) from t1) when coalesce((select max(t1.f-e+13) from t1 where (t1.e>a and 19 not in (13,b,19))),t1.c)+e then t1.b else t1.b end in (select -c from t1 union select c from t1) then f when t1.a>t1.e then t1.c else d end+ -13))/abs((t1.f))) FROM t1 WHERE coalesce((select t1.f from t1 where a>=e),13) between -c and t1.a}
+} {1}
+do_test randexpr-2.2145 {
+ db eval {SELECT (abs(+coalesce((select t1.f from t1 where not exists(select 1 from t1 where (((c)<=t1.a)))),f+(select count(distinct t1.b) from t1)*t1.b+case when case (select count(*) from t1) when coalesce((select max(t1.f-e+13) from t1 where (t1.e>a and 19 not in (13,b,19))),t1.c)+e then t1.b else t1.b end in (select -c from t1 union select c from t1) then f when t1.a>t1.e then t1.c else d end+ -13))/abs((t1.f))) FROM t1 WHERE NOT (coalesce((select t1.f from t1 where a>=e),13) between -c and t1.a)}
+} {}
+do_test randexpr-2.2146 {
+ db eval {SELECT coalesce((select max(~19) from t1 where t1.a between case t1.c when t1.b then t1.e else +~f end and case when 19 not in (e+b,t1.e-d,(select max(e) from t1)) then t1.a else case 13 when case e when e then t1.f else f end-a+t1.f then 19 else t1.b end+11 end-t1.d-17 or t1.b<>t1.a),13)-t1.b | 11 FROM t1 WHERE (+(17)-(select cast(avg( -((17)*case t1.b when 13+f then t1.f else t1.b end)) AS integer) | case case cast(avg(e) AS integer) when abs((case (~min(t1.c)) when max(t1.e) then cast(avg(t1.b) AS integer) else (( -count(*))) end-max(b)))+(min(t1.c)) then -cast(avg(c) AS integer) else min(f) end when cast(avg(17) AS integer) then max(f) else (min(d)) end from t1)+e+c*19>=13)}
+} {-209}
+do_test randexpr-2.2147 {
+ db eval {SELECT coalesce((select max(~19) from t1 where t1.a between case t1.c when t1.b then t1.e else +~f end and case when 19 not in (e+b,t1.e-d,(select max(e) from t1)) then t1.a else case 13 when case e when e then t1.f else f end-a+t1.f then 19 else t1.b end+11 end-t1.d-17 or t1.b<>t1.a),13)-t1.b | 11 FROM t1 WHERE NOT ((+(17)-(select cast(avg( -((17)*case t1.b when 13+f then t1.f else t1.b end)) AS integer) | case case cast(avg(e) AS integer) when abs((case (~min(t1.c)) when max(t1.e) then cast(avg(t1.b) AS integer) else (( -count(*))) end-max(b)))+(min(t1.c)) then -cast(avg(c) AS integer) else min(f) end when cast(avg(17) AS integer) then max(f) else (min(d)) end from t1)+e+c*19>=13))}
+} {}
+do_test randexpr-2.2148 {
+ db eval {SELECT coalesce((select max(~19) from t1 where t1.a between case t1.c when t1.b then t1.e else +~f end and case when 19 not in (e+b,t1.e-d,(select max(e) from t1)) then t1.a else case 13 when case e when e then t1.f else f end-a+t1.f then 19 else t1.b end+11 end-t1.d-17 or t1.b<>t1.a),13)-t1.b & 11 FROM t1 WHERE (+(17)-(select cast(avg( -((17)*case t1.b when 13+f then t1.f else t1.b end)) AS integer) | case case cast(avg(e) AS integer) when abs((case (~min(t1.c)) when max(t1.e) then cast(avg(t1.b) AS integer) else (( -count(*))) end-max(b)))+(min(t1.c)) then -cast(avg(c) AS integer) else min(f) end when cast(avg(17) AS integer) then max(f) else (min(d)) end from t1)+e+c*19>=13)}
+} {0}
+do_test randexpr-2.2149 {
+ db eval {SELECT coalesce((select max(e) from t1 where 11>=coalesce((select max(b) from t1 where (abs(13)/abs(coalesce((select max(11) from t1 where f not between t1.a and t1.d),t1.d)))=case when 11 in (select (11 | d)-coalesce((select t1.e | coalesce((select t1.e from t1 where t1.f in (select 13 from t1 union select t1.c from t1) and d in (select t1.b from t1 union select 17 from t1)),(c))-17-19 from t1 where (t1.b)<=t1.b),(d)) from t1 union select t1.d from t1) then t1.a else (b) end),c)),19) FROM t1 WHERE ~t1.b not in (~++(select (case ~ -min( -11) when abs(count(*)*count(*)) then +~max(t1.a-11 | (19)) else case abs((cast(avg(f) AS integer)))-count(distinct t1.a) when (( -(max(a)))) then (min(t1.d)) else (min(a)) end end) from t1)+(abs(+t1.b)/abs(a))-t1.f+~t1.d+b+t1.c,13,e)}
+} {19}
+do_test randexpr-2.2150 {
+ db eval {SELECT coalesce((select max(e) from t1 where 11>=coalesce((select max(b) from t1 where (abs(13)/abs(coalesce((select max(11) from t1 where f not between t1.a and t1.d),t1.d)))=case when 11 in (select (11 | d)-coalesce((select t1.e | coalesce((select t1.e from t1 where t1.f in (select 13 from t1 union select t1.c from t1) and d in (select t1.b from t1 union select 17 from t1)),(c))-17-19 from t1 where (t1.b)<=t1.b),(d)) from t1 union select t1.d from t1) then t1.a else (b) end),c)),19) FROM t1 WHERE NOT (~t1.b not in (~++(select (case ~ -min( -11) when abs(count(*)*count(*)) then +~max(t1.a-11 | (19)) else case abs((cast(avg(f) AS integer)))-count(distinct t1.a) when (( -(max(a)))) then (min(t1.d)) else (min(a)) end end) from t1)+(abs(+t1.b)/abs(a))-t1.f+~t1.d+b+t1.c,13,e))}
+} {}
+do_test randexpr-2.2151 {
+ db eval {SELECT coalesce((select max(e) from t1 where 11>=coalesce((select max(b) from t1 where (abs(13)/abs(coalesce((select max(11) from t1 where f not between t1.a and t1.d),t1.d)))=case when 11 in (select (11 & d)-coalesce((select t1.e & coalesce((select t1.e from t1 where t1.f in (select 13 from t1 union select t1.c from t1) and d in (select t1.b from t1 union select 17 from t1)),(c))-17-19 from t1 where (t1.b)<=t1.b),(d)) from t1 union select t1.d from t1) then t1.a else (b) end),c)),19) FROM t1 WHERE ~t1.b not in (~++(select (case ~ -min( -11) when abs(count(*)*count(*)) then +~max(t1.a-11 | (19)) else case abs((cast(avg(f) AS integer)))-count(distinct t1.a) when (( -(max(a)))) then (min(t1.d)) else (min(a)) end end) from t1)+(abs(+t1.b)/abs(a))-t1.f+~t1.d+b+t1.c,13,e)}
+} {19}
+do_test randexpr-2.2152 {
+ db eval {SELECT (abs(+b)/abs(coalesce((select max(t1.b) from t1 where (not t1.a not between t1.c-(abs(b)/abs(d)) and c)),19)+19*t1.e | t1.e))-t1.f*coalesce((select case d when e*t1.d*f then 17 else t1.c+t1.c end from t1 where t1.b>=(select count(*) from t1)),+f+t1.b-t1.b+19- -b) FROM t1 WHERE not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where not (b>=(abs(case when case (select count(*) from t1) when t1.a then a+case t1.f when a+ -t1.a*t1.d then 19 else e end+t1.a+f else -d end>=e then f when t1.b>=t1.d or not d<f or t1.f>t1.b then t1.e else d end)/abs(f)) or a>e))))}
+} {-360000}
+do_test randexpr-2.2153 {
+ db eval {SELECT (abs(+b)/abs(coalesce((select max(t1.b) from t1 where (not t1.a not between t1.c-(abs(b)/abs(d)) and c)),19)+19*t1.e | t1.e))-t1.f*coalesce((select case d when e*t1.d*f then 17 else t1.c+t1.c end from t1 where t1.b>=(select count(*) from t1)),+f+t1.b-t1.b+19- -b) FROM t1 WHERE NOT (not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where not (b>=(abs(case when case (select count(*) from t1) when t1.a then a+case t1.f when a+ -t1.a*t1.d then 19 else e end+t1.a+f else -d end>=e then f when t1.b>=t1.d or not d<f or t1.f>t1.b then t1.e else d end)/abs(f)) or a>e)))))}
+} {}
+do_test randexpr-2.2154 {
+ db eval {SELECT (abs(+b)/abs(coalesce((select max(t1.b) from t1 where (not t1.a not between t1.c-(abs(b)/abs(d)) and c)),19)+19*t1.e & t1.e))-t1.f*coalesce((select case d when e*t1.d*f then 17 else t1.c+t1.c end from t1 where t1.b>=(select count(*) from t1)),+f+t1.b-t1.b+19- -b) FROM t1 WHERE not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where not (b>=(abs(case when case (select count(*) from t1) when t1.a then a+case t1.f when a+ -t1.a*t1.d then 19 else e end+t1.a+f else -d end>=e then f when t1.b>=t1.d or not d<f or t1.f>t1.b then t1.e else d end)/abs(f)) or a>e))))}
+} {-360000}
+do_test randexpr-2.2155 {
+ db eval {SELECT (abs((select +abs(case count(*) when +max(19) then count(distinct b)*count(distinct (13+(select max(t1.d) from t1)* -a+t1.e*t1.b*a))+cast(avg(13) AS integer) | min(13)*cast(avg(c) AS integer)-count(distinct t1.e)-((min(f))) | cast(avg(17) AS integer)-( -cast(avg(( -t1.d)) AS integer))- -cast(avg(t1.d) AS integer) | count(*) else max(t1.f) end) from t1))/abs(t1.a)) FROM t1 WHERE b<=e or exists(select 1 from t1 where 17 in (select ~e+coalesce((select d from t1 where 11* -~+case when not (b) not between t1.f and b then -~t1.c-11*+19+((b)) when f not between f and 11 then b else a end+11-(b)-t1.f<>17),d) from t1 union select t1.a from t1))}
+} {6}
+do_test randexpr-2.2156 {
+ db eval {SELECT (abs((select +abs(case count(*) when +max(19) then count(distinct b)*count(distinct (13+(select max(t1.d) from t1)* -a+t1.e*t1.b*a))+cast(avg(13) AS integer) | min(13)*cast(avg(c) AS integer)-count(distinct t1.e)-((min(f))) | cast(avg(17) AS integer)-( -cast(avg(( -t1.d)) AS integer))- -cast(avg(t1.d) AS integer) | count(*) else max(t1.f) end) from t1))/abs(t1.a)) FROM t1 WHERE NOT (b<=e or exists(select 1 from t1 where 17 in (select ~e+coalesce((select d from t1 where 11* -~+case when not (b) not between t1.f and b then -~t1.c-11*+19+((b)) when f not between f and 11 then b else a end+11-(b)-t1.f<>17),d) from t1 union select t1.a from t1)))}
+} {}
+do_test randexpr-2.2157 {
+ db eval {SELECT (abs((select +abs(case count(*) when +max(19) then count(distinct b)*count(distinct (13+(select max(t1.d) from t1)* -a+t1.e*t1.b*a))+cast(avg(13) AS integer) & min(13)*cast(avg(c) AS integer)-count(distinct t1.e)-((min(f))) & cast(avg(17) AS integer)-( -cast(avg(( -t1.d)) AS integer))- -cast(avg(t1.d) AS integer) & count(*) else max(t1.f) end) from t1))/abs(t1.a)) FROM t1 WHERE b<=e or exists(select 1 from t1 where 17 in (select ~e+coalesce((select d from t1 where 11* -~+case when not (b) not between t1.f and b then -~t1.c-11*+19+((b)) when f not between f and 11 then b else a end+11-(b)-t1.f<>17),d) from t1 union select t1.a from t1))}
+} {6}
+do_test randexpr-2.2158 {
+ db eval {SELECT coalesce((select max(11) from t1 where c=(abs(coalesce((select case when t1.c-t1.f+coalesce((select max(b) from t1 where case when (11<>17) then t1.c else c end in (select b from t1 union select t1.b from t1) and 13=11),f)+t1.b>=t1.f then 11 when c>t1.f then 19 else 19 end from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (e>19)))),t1.d))/abs(b)) and -t1.d between t1.b and 13 or 17<>t1.e), -((11))) FROM t1 WHERE case when case when (not exists(select 1 from t1 where 19 not between case when coalesce((select b from t1 where (abs(t1.c)/abs(17))+t1.e between case when not exists(select 1 from t1 where not a<=t1.e) then t1.e when d<t1.c then 17 else -d end and f),e)<13 then t1.a else t1.c end and e)) then +t1.a else d end not in (e,t1.d,t1.a) then t1.a when a in (select 19 from t1 union select t1.a from t1) then 19 else -e end<t1.c}
+} {11}
+do_test randexpr-2.2159 {
+ db eval {SELECT coalesce((select max(11) from t1 where c=(abs(coalesce((select case when t1.c-t1.f+coalesce((select max(b) from t1 where case when (11<>17) then t1.c else c end in (select b from t1 union select t1.b from t1) and 13=11),f)+t1.b>=t1.f then 11 when c>t1.f then 19 else 19 end from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (e>19)))),t1.d))/abs(b)) and -t1.d between t1.b and 13 or 17<>t1.e), -((11))) FROM t1 WHERE NOT (case when case when (not exists(select 1 from t1 where 19 not between case when coalesce((select b from t1 where (abs(t1.c)/abs(17))+t1.e between case when not exists(select 1 from t1 where not a<=t1.e) then t1.e when d<t1.c then 17 else -d end and f),e)<13 then t1.a else t1.c end and e)) then +t1.a else d end not in (e,t1.d,t1.a) then t1.a when a in (select 19 from t1 union select t1.a from t1) then 19 else -e end<t1.c)}
+} {}
+do_test randexpr-2.2160 {
+ db eval {SELECT coalesce((select ( -t1.e*(abs((case when not 13 not in (case coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where d between -b and f)),11) when 11 then 19 else a end,t1.a,t1.a) then f-t1.f when t1.c in (select -abs(count(*)+(max((t1.a)))) from t1 union select -max((19)) from t1) then d else 13 end-19))/abs(t1.b))-t1.d*e-19) from t1 where t1.e not between 13 and c),19)*13 FROM t1 WHERE 19<>(t1.c)}
+} {-2600247}
+do_test randexpr-2.2161 {
+ db eval {SELECT coalesce((select ( -t1.e*(abs((case when not 13 not in (case coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where d between -b and f)),11) when 11 then 19 else a end,t1.a,t1.a) then f-t1.f when t1.c in (select -abs(count(*)+(max((t1.a)))) from t1 union select -max((19)) from t1) then d else 13 end-19))/abs(t1.b))-t1.d*e-19) from t1 where t1.e not between 13 and c),19)*13 FROM t1 WHERE NOT (19<>(t1.c))}
+} {}
+do_test randexpr-2.2162 {
+ db eval {SELECT coalesce((select max(13) from t1 where f= -case when exists(select 1 from t1 where not t1.b>=e and b in (select b from t1 union select (+(t1.f-d)) from t1) or 19 in (select min(e) from t1 union select -~+++ -abs(min(17*t1.d)) from t1) or not t1.a>a) then 13 else t1.c end+a | ~11),19) FROM t1 WHERE (exists(select 1 from t1 where t1.c>19)) and a>d-a}
+} {}
+do_test randexpr-2.2163 {
+ db eval {SELECT coalesce((select max(13) from t1 where f= -case when exists(select 1 from t1 where not t1.b>=e and b in (select b from t1 union select (+(t1.f-d)) from t1) or 19 in (select min(e) from t1 union select -~+++ -abs(min(17*t1.d)) from t1) or not t1.a>a) then 13 else t1.c end+a | ~11),19) FROM t1 WHERE NOT ((exists(select 1 from t1 where t1.c>19)) and a>d-a)}
+} {19}
+do_test randexpr-2.2164 {
+ db eval {SELECT coalesce((select max(13) from t1 where f= -case when exists(select 1 from t1 where not t1.b>=e and b in (select b from t1 union select (+(t1.f-d)) from t1) or 19 in (select min(e) from t1 union select -~+++ -abs(min(17*t1.d)) from t1) or not t1.a>a) then 13 else t1.c end+a & ~11),19) FROM t1 WHERE NOT ((exists(select 1 from t1 where t1.c>19)) and a>d-a)}
+} {19}
+do_test randexpr-2.2165 {
+ db eval {SELECT coalesce((select case when a between (select count(distinct 19) from t1) and case when d<t1.d and (select min(d)*min(a) from t1)<=t1.c+d then case 11 when 13 then t1.b else t1.a end else t1.d end+19 and exists(select 1 from t1 where t1.b between -t1.e and t1.d) then f-d when 13 not between -(c) and 13 then t1.c else 17 end from t1 where t1.e not in (c,f,t1.b)), -b) FROM t1 WHERE case 13*(abs(c)/abs(c*d-~t1.f-case coalesce((select +t1.f-a from t1 where b in (13,t1.f,f+19*+c)),b-a+coalesce((select max(c) from t1 where t1.f=d),d)-t1.a) when 13 then t1.d else t1.d end)) when 19 then 13 else -11 end | 19=t1.c}
+} {}
+do_test randexpr-2.2166 {
+ db eval {SELECT coalesce((select case when a between (select count(distinct 19) from t1) and case when d<t1.d and (select min(d)*min(a) from t1)<=t1.c+d then case 11 when 13 then t1.b else t1.a end else t1.d end+19 and exists(select 1 from t1 where t1.b between -t1.e and t1.d) then f-d when 13 not between -(c) and 13 then t1.c else 17 end from t1 where t1.e not in (c,f,t1.b)), -b) FROM t1 WHERE NOT (case 13*(abs(c)/abs(c*d-~t1.f-case coalesce((select +t1.f-a from t1 where b in (13,t1.f,f+19*+c)),b-a+coalesce((select max(c) from t1 where t1.f=d),d)-t1.a) when 13 then t1.d else t1.d end)) when 19 then 13 else -11 end | 19=t1.c)}
+} {200}
+do_test randexpr-2.2167 {
+ db eval {SELECT case 17 when -b then e*c else (abs(coalesce((select max(coalesce((select coalesce((select max(case when t1.d<=19 and t1.d>e then b*t1.e else a end) from t1 where t1.e=t1.e),t1.f) from t1 where (d not between 13 and (f))),17)-d) from t1 where (11<>19)),t1.e)+t1.c)/abs(t1.e))*11*c-t1.d*t1.d+a end FROM t1 WHERE 13-e*t1.e<case when (coalesce((select max(c*13) from t1 where not exists(select 1 from t1 where (19+(coalesce((select coalesce((select max(a) from t1 where 17>=19),(abs(e)/abs((abs( -d+e)/abs(a))))+t1.a) from t1 where t1.b in (t1.e,(t1.e),t1.f)),f))=t1.e)) or b<=19),t1.b)<=13) then 13 else t1.f end-f}
+} {-159900}
+do_test randexpr-2.2168 {
+ db eval {SELECT case 17 when -b then e*c else (abs(coalesce((select max(coalesce((select coalesce((select max(case when t1.d<=19 and t1.d>e then b*t1.e else a end) from t1 where t1.e=t1.e),t1.f) from t1 where (d not between 13 and (f))),17)-d) from t1 where (11<>19)),t1.e)+t1.c)/abs(t1.e))*11*c-t1.d*t1.d+a end FROM t1 WHERE NOT (13-e*t1.e<case when (coalesce((select max(c*13) from t1 where not exists(select 1 from t1 where (19+(coalesce((select coalesce((select max(a) from t1 where 17>=19),(abs(e)/abs((abs( -d+e)/abs(a))))+t1.a) from t1 where t1.b in (t1.e,(t1.e),t1.f)),f))=t1.e)) or b<=19),t1.b)<=13) then 13 else t1.f end-f)}
+} {}
+do_test randexpr-2.2169 {
+ db eval {SELECT case when case when e*(d-case a when 13 then (19) else d end) between 13 and f then f when exists(select 1 from t1 where 19<>t1.a) then e else b end in (select -max(e)+min(11)-case ~~cast(avg(t1.c) AS integer) when max(19) then max(f) else -cast(avg(f) AS integer) end from t1 union select -max(13) from t1) and f>d and (t1.f=c) then t1.b else t1.c+ -t1.f end FROM t1 WHERE t1.e+11>=~t1.a-11}
+} {-300}
+do_test randexpr-2.2170 {
+ db eval {SELECT case when case when e*(d-case a when 13 then (19) else d end) between 13 and f then f when exists(select 1 from t1 where 19<>t1.a) then e else b end in (select -max(e)+min(11)-case ~~cast(avg(t1.c) AS integer) when max(19) then max(f) else -cast(avg(f) AS integer) end from t1 union select -max(13) from t1) and f>d and (t1.f=c) then t1.b else t1.c+ -t1.f end FROM t1 WHERE NOT (t1.e+11>=~t1.a-11)}
+} {}
+do_test randexpr-2.2171 {
+ db eval {SELECT coalesce((select t1.f from t1 where not (abs(coalesce((select 17*13+(select cast(avg(t1.a) AS integer)-(count(distinct t1.c)*+cast(avg((select count(*) from t1)) AS integer))+count(*) from t1) from t1 where (select count(distinct t1.d*(((t1.d)))+f) from t1) in ( -b*t1.e-11,t1.d,d) and exists(select 1 from t1 where t1.d>c)),t1.e))/abs(b)) not in (t1.f,11,d)),t1.d) FROM t1 WHERE exists(select 1 from t1 where +t1.c-case when exists(select 1 from t1 where (select +case count(distinct case when 19*d in (select (cast(avg(11) AS integer)*cast(avg( -13) AS integer)) from t1 union select count(*) from t1) then t1.c else 13 end) when count(*) then count(*) else (min(t1.b)) end from t1)<>case when (not t1.f<b) or b>t1.d then case when f>=17 then t1.a else t1.e end else b end) then 11+t1.f when d<>17 then t1.e else a end- -13<>e) and t1.a<=17}
+} {}
+do_test randexpr-2.2172 {
+ db eval {SELECT coalesce((select t1.f from t1 where not (abs(coalesce((select 17*13+(select cast(avg(t1.a) AS integer)-(count(distinct t1.c)*+cast(avg((select count(*) from t1)) AS integer))+count(*) from t1) from t1 where (select count(distinct t1.d*(((t1.d)))+f) from t1) in ( -b*t1.e-11,t1.d,d) and exists(select 1 from t1 where t1.d>c)),t1.e))/abs(b)) not in (t1.f,11,d)),t1.d) FROM t1 WHERE NOT (exists(select 1 from t1 where +t1.c-case when exists(select 1 from t1 where (select +case count(distinct case when 19*d in (select (cast(avg(11) AS integer)*cast(avg( -13) AS integer)) from t1 union select count(*) from t1) then t1.c else 13 end) when count(*) then count(*) else (min(t1.b)) end from t1)<>case when (not t1.f<b) or b>t1.d then case when f>=17 then t1.a else t1.e end else b end) then 11+t1.f when d<>17 then t1.e else a end- -13<>e) and t1.a<=17)}
+} {400}
+do_test randexpr-2.2173 {
+ db eval {SELECT case when not (select - -count(distinct t1.f)-(max(case when e not between f and t1.b+(13)+ -d-t1.a then t1.d else 11 end))+ -max(t1.b)*cast(avg(13) AS integer)-count(*) | (max(t1.e)) from t1)<>~t1.d then b when -coalesce((select (abs(t1.e)/abs(t1.b)) from t1 where a<>b), - -17)<=t1.a then -f else 11 end FROM t1 WHERE t1.a<>(select max(19) from t1)}
+} {-600}
+do_test randexpr-2.2174 {
+ db eval {SELECT case when not (select - -count(distinct t1.f)-(max(case when e not between f and t1.b+(13)+ -d-t1.a then t1.d else 11 end))+ -max(t1.b)*cast(avg(13) AS integer)-count(*) | (max(t1.e)) from t1)<>~t1.d then b when -coalesce((select (abs(t1.e)/abs(t1.b)) from t1 where a<>b), - -17)<=t1.a then -f else 11 end FROM t1 WHERE NOT (t1.a<>(select max(19) from t1))}
+} {}
+do_test randexpr-2.2175 {
+ db eval {SELECT case when not (select - -count(distinct t1.f)-(max(case when e not between f and t1.b+(13)+ -d-t1.a then t1.d else 11 end))+ -max(t1.b)*cast(avg(13) AS integer)-count(*) & (max(t1.e)) from t1)<>~t1.d then b when -coalesce((select (abs(t1.e)/abs(t1.b)) from t1 where a<>b), - -17)<=t1.a then -f else 11 end FROM t1 WHERE t1.a<>(select max(19) from t1)}
+} {-600}
+do_test randexpr-2.2176 {
+ db eval {SELECT case when case coalesce((select t1.d+a*11 from t1 where e<=t1.d),19) when 19 then -t1.d-t1.a else t1.e end not between 17 and d then t1.f when not (t1.c<=e and ((13<>e or t1.c not between t1.c and 13)) or t1.c=17 and t1.a not in (t1.e, -t1.d,t1.b) and b<t1.e) and c>=b then t1.d else 13 end FROM t1 WHERE (case t1.f when t1.b then case when case when not exists(select 1 from t1 where (t1.d+t1.a in (c,coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where (t1.a>=c))),+b), -t1.b))) then (select abs( -case ((abs( - - -count(*)+count(*)))) when min(d) then -(cast(avg(t1.d) AS integer)) else cast(avg(e) AS integer) end | ((max((t1.f)))))+(min(t1.c)) from t1) else 11 end>f then 19 else t1.b end else b end)<=13 or (t1.f>b)}
+} {600}
+do_test randexpr-2.2177 {
+ db eval {SELECT case when case coalesce((select t1.d+a*11 from t1 where e<=t1.d),19) when 19 then -t1.d-t1.a else t1.e end not between 17 and d then t1.f when not (t1.c<=e and ((13<>e or t1.c not between t1.c and 13)) or t1.c=17 and t1.a not in (t1.e, -t1.d,t1.b) and b<t1.e) and c>=b then t1.d else 13 end FROM t1 WHERE NOT ((case t1.f when t1.b then case when case when not exists(select 1 from t1 where (t1.d+t1.a in (c,coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where (t1.a>=c))),+b), -t1.b))) then (select abs( -case ((abs( - - -count(*)+count(*)))) when min(d) then -(cast(avg(t1.d) AS integer)) else cast(avg(e) AS integer) end | ((max((t1.f)))))+(min(t1.c)) from t1) else 11 end>f then 19 else t1.b end else b end)<=13 or (t1.f>b))}
+} {}
+do_test randexpr-2.2178 {
+ db eval {SELECT (((d)+t1.f))-case +t1.d when coalesce((select max(13) from t1 where (select -max(17*case when d>=coalesce((select 19 from t1 where a<>t1.e),t1.b) then e when -c<>d then e else t1.a end*t1.f)+ -case count(*) when (+cast(avg(c) AS integer)) then count(*) else -count(distinct t1.f) end+count(*) from t1)<=(abs(t1.c)/abs(t1.f))),17) then 17 else t1.d end-t1.b FROM t1 WHERE ~d-c in (select cast(avg(19) AS integer) from t1 union select - -abs((abs((cast(avg(f) AS integer)) | abs(count(distinct 19))))) from t1)}
+} {}
+do_test randexpr-2.2179 {
+ db eval {SELECT (((d)+t1.f))-case +t1.d when coalesce((select max(13) from t1 where (select -max(17*case when d>=coalesce((select 19 from t1 where a<>t1.e),t1.b) then e when -c<>d then e else t1.a end*t1.f)+ -case count(*) when (+cast(avg(c) AS integer)) then count(*) else -count(distinct t1.f) end+count(*) from t1)<=(abs(t1.c)/abs(t1.f))),17) then 17 else t1.d end-t1.b FROM t1 WHERE NOT (~d-c in (select cast(avg(19) AS integer) from t1 union select - -abs((abs((cast(avg(f) AS integer)) | abs(count(distinct 19))))) from t1))}
+} {400}
+do_test randexpr-2.2180 {
+ db eval {SELECT coalesce((select max(f+t1.c*b) from t1 where (select abs(cast(avg(f) AS integer)) from t1)-c*~ -b+ -coalesce((select max(t1.a) from t1 where (select cast(avg((c) | ~t1.d) AS integer) from t1) not between t1.d-+(abs(t1.d)/abs(t1.c))+d and 11 and 17>=t1.e),t1.e)-b in (t1.c,d,e)),a)+c FROM t1 WHERE 19*e not in (a,t1.d,coalesce((select coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where not exists(select 1 from t1 where e*case when ~c | f+11* -a in ( -t1.c,17,(t1.b)) then (f) when e=e or t1.d=f and (e)>(e) then (11) else a end+a*c in (select d from t1 union select -11 from t1))))),t1.f) from t1 where t1.d<=d),13))}
+} {400}
+do_test randexpr-2.2181 {
+ db eval {SELECT coalesce((select max(f+t1.c*b) from t1 where (select abs(cast(avg(f) AS integer)) from t1)-c*~ -b+ -coalesce((select max(t1.a) from t1 where (select cast(avg((c) | ~t1.d) AS integer) from t1) not between t1.d-+(abs(t1.d)/abs(t1.c))+d and 11 and 17>=t1.e),t1.e)-b in (t1.c,d,e)),a)+c FROM t1 WHERE NOT (19*e not in (a,t1.d,coalesce((select coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where not exists(select 1 from t1 where e*case when ~c | f+11* -a in ( -t1.c,17,(t1.b)) then (f) when e=e or t1.d=f and (e)>(e) then (11) else a end+a*c in (select d from t1 union select -11 from t1))))),t1.f) from t1 where t1.d<=d),13)))}
+} {}
+do_test randexpr-2.2182 {
+ db eval {SELECT coalesce((select max(f+t1.c*b) from t1 where (select abs(cast(avg(f) AS integer)) from t1)-c*~ -b+ -coalesce((select max(t1.a) from t1 where (select cast(avg((c) & ~t1.d) AS integer) from t1) not between t1.d-+(abs(t1.d)/abs(t1.c))+d and 11 and 17>=t1.e),t1.e)-b in (t1.c,d,e)),a)+c FROM t1 WHERE 19*e not in (a,t1.d,coalesce((select coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where not exists(select 1 from t1 where e*case when ~c | f+11* -a in ( -t1.c,17,(t1.b)) then (f) when e=e or t1.d=f and (e)>(e) then (11) else a end+a*c in (select d from t1 union select -11 from t1))))),t1.f) from t1 where t1.d<=d),13))}
+} {400}
+do_test randexpr-2.2183 {
+ db eval {SELECT c*~case ((abs(t1.b)/abs(t1.b))) when c then e else t1.c end-(case when (c)>=case coalesce((select max((abs(d)/abs(c))) from t1 where 13 not in (a-t1.e-(select count(*) | min(e)+min(c) from t1)*19*t1.b,11,a)),e) when e then b else t1.d end then d when 17<11 then c else t1.d end) | t1.f FROM t1 WHERE case when not (abs(t1.d | (abs( - -coalesce((select max(coalesce((select c+e from t1 where not t1.b in ((c),b,(f))),t1.b)) from t1 where 11=b),t1.f)+13*t1.f*e)/abs(t1.e)))/abs(t1.b))>=c then coalesce((select (t1.c) from t1 where t1.e in (11,e,t1.a)),a) when 13<=t1.b then t1.f else t1.d end in (select e from t1 union select (t1.d) from t1)}
+} {}
+do_test randexpr-2.2184 {
+ db eval {SELECT c*~case ((abs(t1.b)/abs(t1.b))) when c then e else t1.c end-(case when (c)>=case coalesce((select max((abs(d)/abs(c))) from t1 where 13 not in (a-t1.e-(select count(*) | min(e)+min(c) from t1)*19*t1.b,11,a)),e) when e then b else t1.d end then d when 17<11 then c else t1.d end) | t1.f FROM t1 WHERE NOT (case when not (abs(t1.d | (abs( - -coalesce((select max(coalesce((select c+e from t1 where not t1.b in ((c),b,(f))),t1.b)) from t1 where 11=b),t1.f)+13*t1.f*e)/abs(t1.e)))/abs(t1.b))>=c then coalesce((select (t1.c) from t1 where t1.e in (11,e,t1.a)),a) when 13<=t1.b then t1.f else t1.d end in (select e from t1 union select (t1.d) from t1))}
+} {-90116}
+do_test randexpr-2.2185 {
+ db eval {SELECT c*~case ((abs(t1.b)/abs(t1.b))) when c then e else t1.c end-(case when (c)>=case coalesce((select max((abs(d)/abs(c))) from t1 where 13 not in (a-t1.e-(select count(*) & min(e)+min(c) from t1)*19*t1.b,11,a)),e) when e then b else t1.d end then d when 17<11 then c else t1.d end) & t1.f FROM t1 WHERE NOT (case when not (abs(t1.d | (abs( - -coalesce((select max(coalesce((select c+e from t1 where not t1.b in ((c),b,(f))),t1.b)) from t1 where 11=b),t1.f)+13*t1.f*e)/abs(t1.e)))/abs(t1.b))>=c then coalesce((select (t1.c) from t1 where t1.e in (11,e,t1.a)),a) when 13<=t1.b then t1.f else t1.d end in (select e from t1 union select (t1.d) from t1))}
+} {16}
+do_test randexpr-2.2186 {
+ db eval {SELECT case when a+13*+ -~case when 17=t1.c*17 then 19 | (t1.b) when f+t1.e+(d)+b+c not between (d) and e or (a between t1.b and t1.a) then 17 else a end-17-(e)<=17 then b when c in (select 17 from t1 union select t1.a from t1) then c else t1.e end FROM t1 WHERE e-coalesce((select f-case 17+t1.a*(abs(t1.e)/abs((abs(coalesce((select max(+ -case when t1.a>=d then c else t1.e end-d) from t1 where (not exists(select 1 from t1 where (t1.d in ( -f,d,t1.b))) or -t1.f not between -b and t1.b)),11))/abs(13)))) when 13 then d else t1.f end from t1 where t1.e in ((19),t1.e,17) or e>=t1.d),e)<>17 or 19<=19}
+} {200}
+do_test randexpr-2.2187 {
+ db eval {SELECT case when a+13*+ -~case when 17=t1.c*17 then 19 | (t1.b) when f+t1.e+(d)+b+c not between (d) and e or (a between t1.b and t1.a) then 17 else a end-17-(e)<=17 then b when c in (select 17 from t1 union select t1.a from t1) then c else t1.e end FROM t1 WHERE NOT (e-coalesce((select f-case 17+t1.a*(abs(t1.e)/abs((abs(coalesce((select max(+ -case when t1.a>=d then c else t1.e end-d) from t1 where (not exists(select 1 from t1 where (t1.d in ( -f,d,t1.b))) or -t1.f not between -b and t1.b)),11))/abs(13)))) when 13 then d else t1.f end from t1 where t1.e in ((19),t1.e,17) or e>=t1.d),e)<>17 or 19<=19)}
+} {}
+do_test randexpr-2.2188 {
+ db eval {SELECT case when a+13*+ -~case when 17=t1.c*17 then 19 & (t1.b) when f+t1.e+(d)+b+c not between (d) and e or (a between t1.b and t1.a) then 17 else a end-17-(e)<=17 then b when c in (select 17 from t1 union select t1.a from t1) then c else t1.e end FROM t1 WHERE e-coalesce((select f-case 17+t1.a*(abs(t1.e)/abs((abs(coalesce((select max(+ -case when t1.a>=d then c else t1.e end-d) from t1 where (not exists(select 1 from t1 where (t1.d in ( -f,d,t1.b))) or -t1.f not between -b and t1.b)),11))/abs(13)))) when 13 then d else t1.f end from t1 where t1.e in ((19),t1.e,17) or e>=t1.d),e)<>17 or 19<=19}
+} {200}
+do_test randexpr-2.2189 {
+ db eval {SELECT 17-t1.a*(select abs(~count(*)*abs(count(distinct a)) | (~count(distinct case (a* -coalesce((select a from t1 where (13 in (select max((abs(t1.e)/abs(case when not exists(select 1 from t1 where (b<>c)) then (11)-t1.f-e else e end))) from t1 union select (count(distinct 11)) from t1))),t1.b)+11) when (17) then e else f end))) from t1) FROM t1 WHERE 13>case (e) when t1.a then t1.a else 11 end-t1.b}
+} {-183}
+do_test randexpr-2.2190 {
+ db eval {SELECT 17-t1.a*(select abs(~count(*)*abs(count(distinct a)) | (~count(distinct case (a* -coalesce((select a from t1 where (13 in (select max((abs(t1.e)/abs(case when not exists(select 1 from t1 where (b<>c)) then (11)-t1.f-e else e end))) from t1 union select (count(distinct 11)) from t1))),t1.b)+11) when (17) then e else f end))) from t1) FROM t1 WHERE NOT (13>case (e) when t1.a then t1.a else 11 end-t1.b)}
+} {}
+do_test randexpr-2.2191 {
+ db eval {SELECT 17-t1.a*(select abs(~count(*)*abs(count(distinct a)) & (~count(distinct case (a* -coalesce((select a from t1 where (13 in (select max((abs(t1.e)/abs(case when not exists(select 1 from t1 where (b<>c)) then (11)-t1.f-e else e end))) from t1 union select (count(distinct 11)) from t1))),t1.b)+11) when (17) then e else f end))) from t1) FROM t1 WHERE 13>case (e) when t1.a then t1.a else 11 end-t1.b}
+} {-183}
+do_test randexpr-2.2192 {
+ db eval {SELECT case when t1.b= -b then e else (select -(count(distinct t1.a))*max(c)-count(*)+count(distinct t1.b+d)*min(t1.f-case when 19 in (select t1.d from t1 union select e from t1) then 17 when f<=t1.c then t1.b else e end-(d)*c)-count(distinct t1.d)*case +max(f) when max(17) | max(d) | -(cast(avg(d) AS integer)) then -cast(avg(11) AS integer) else -count(distinct 11) end*min(t1.d) from t1) end FROM t1 WHERE t1.f>=f}
+} {-119801}
+do_test randexpr-2.2193 {
+ db eval {SELECT case when t1.b= -b then e else (select -(count(distinct t1.a))*max(c)-count(*)+count(distinct t1.b+d)*min(t1.f-case when 19 in (select t1.d from t1 union select e from t1) then 17 when f<=t1.c then t1.b else e end-(d)*c)-count(distinct t1.d)*case +max(f) when max(17) | max(d) | -(cast(avg(d) AS integer)) then -cast(avg(11) AS integer) else -count(distinct 11) end*min(t1.d) from t1) end FROM t1 WHERE NOT (t1.f>=f)}
+} {}
+do_test randexpr-2.2194 {
+ db eval {SELECT case when t1.b= -b then e else (select -(count(distinct t1.a))*max(c)-count(*)+count(distinct t1.b+d)*min(t1.f-case when 19 in (select t1.d from t1 union select e from t1) then 17 when f<=t1.c then t1.b else e end-(d)*c)-count(distinct t1.d)*case +max(f) when max(17) & max(d) & -(cast(avg(d) AS integer)) then -cast(avg(11) AS integer) else -count(distinct 11) end*min(t1.d) from t1) end FROM t1 WHERE t1.f>=f}
+} {-119801}
+do_test randexpr-2.2195 {
+ db eval {SELECT -~f | (abs(13+t1.b)/abs((select max(t1.b | t1.f+ -17-11) | +case min(e) when count(*) | case (~ -min(c)*cast(avg(19) AS integer)) when -count(*) then min(a) else min(13) end then -((max(t1.c))) else max(e) end-(count(distinct -t1.a)) from t1)))+~(abs((abs(case when a<>19 then t1.a when f>17 then a else b end)/abs(t1.b)))/abs(t1.f)) FROM t1 WHERE (17 between t1.f*(abs(b)/abs((abs((select max(17) from t1) | 17)/abs(13))+c-coalesce((select max(d) from t1 where d between f-a-11-d and a+t1.a+d-t1.b+17+13),case when a not between a and t1.b then t1.d when t1.d not in ((e),a,d) then c else b end*d))) and b and t1.e> -17)}
+} {}
+do_test randexpr-2.2196 {
+ db eval {SELECT -~f | (abs(13+t1.b)/abs((select max(t1.b | t1.f+ -17-11) | +case min(e) when count(*) | case (~ -min(c)*cast(avg(19) AS integer)) when -count(*) then min(a) else min(13) end then -((max(t1.c))) else max(e) end-(count(distinct -t1.a)) from t1)))+~(abs((abs(case when a<>19 then t1.a when f>17 then a else b end)/abs(t1.b)))/abs(t1.f)) FROM t1 WHERE NOT ((17 between t1.f*(abs(b)/abs((abs((select max(17) from t1) | 17)/abs(13))+c-coalesce((select max(d) from t1 where d between f-a-11-d and a+t1.a+d-t1.b+17+13),case when a not between a and t1.b then t1.d when t1.d not in ((e),a,d) then c else b end*d))) and b and t1.e> -17))}
+} {-1}
+do_test randexpr-2.2197 {
+ db eval {SELECT (select abs(abs( -case case ~count(distinct t1.f+(t1.f)+coalesce((select (abs(t1.e+(b)+a)/abs(11))+b from t1 where exists(select 1 from t1 where t1.f not in (t1.b,(b),e) and not (t1.b)>c)),f)) when ~count(*)-min(t1.f) then +(count(*))*( -count(*)-max(t1.a)) else min(11) end when count(distinct (f)) then -count(distinct a) else count(*) end | count(distinct 13))) from t1) FROM t1 WHERE exists(select 1 from t1 where case when t1.f>(abs(b)/abs(a)) then ~case when t1.e+13-b<=(coalesce((select max(11) from t1 where (select abs(min(11)) from t1) in (select case d when f then 17 else t1.f end from t1 union select t1.f from t1)),b)*13)-19 then 11 when not 19 between t1.c and t1.b then a else e end-t1.a when (t1.a) not between b and t1.f then t1.a else c end=t1.e)}
+} {}
+do_test randexpr-2.2198 {
+ db eval {SELECT (select abs(abs( -case case ~count(distinct t1.f+(t1.f)+coalesce((select (abs(t1.e+(b)+a)/abs(11))+b from t1 where exists(select 1 from t1 where t1.f not in (t1.b,(b),e) and not (t1.b)>c)),f)) when ~count(*)-min(t1.f) then +(count(*))*( -count(*)-max(t1.a)) else min(11) end when count(distinct (f)) then -count(distinct a) else count(*) end | count(distinct 13))) from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where case when t1.f>(abs(b)/abs(a)) then ~case when t1.e+13-b<=(coalesce((select max(11) from t1 where (select abs(min(11)) from t1) in (select case d when f then 17 else t1.f end from t1 union select t1.f from t1)),b)*13)-19 then 11 when not 19 between t1.c and t1.b then a else e end-t1.a when (t1.a) not between b and t1.f then t1.a else c end=t1.e))}
+} {1}
+do_test randexpr-2.2199 {
+ db eval {SELECT (select abs(abs( -case case ~count(distinct t1.f+(t1.f)+coalesce((select (abs(t1.e+(b)+a)/abs(11))+b from t1 where exists(select 1 from t1 where t1.f not in (t1.b,(b),e) and not (t1.b)>c)),f)) when ~count(*)-min(t1.f) then +(count(*))*( -count(*)-max(t1.a)) else min(11) end when count(distinct (f)) then -count(distinct a) else count(*) end & count(distinct 13))) from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where case when t1.f>(abs(b)/abs(a)) then ~case when t1.e+13-b<=(coalesce((select max(11) from t1 where (select abs(min(11)) from t1) in (select case d when f then 17 else t1.f end from t1 union select t1.f from t1)),b)*13)-19 then 11 when not 19 between t1.c and t1.b then a else e end-t1.a when (t1.a) not between b and t1.f then t1.a else c end=t1.e))}
+} {1}
+do_test randexpr-2.2200 {
+ db eval {SELECT 19 | t1.a*(select case max(case when t1.b*17>=t1.b then coalesce((select max(e) from t1 where e in (select count(*) from t1 union select count(distinct t1.f) from t1)),d) when t1.a in (select min(11) from t1 union select (( -( -max(t1.f)))) from t1) and 17 in (select count(distinct 17) from t1 union select -count(distinct d) from t1) and (d)<>t1.c and t1.c not between b and b then a else 11 end)+cast(avg(t1.a) AS integer) when ~count(distinct t1.e) then count(distinct d) else count(distinct e) end from t1) | e*t1.b-t1.d FROM t1 WHERE (((abs(19)/abs(case ~c*d+(abs(e)/abs((coalesce((select case when (f in (select count(*) from t1 union select -min(d) from t1)) then case when -t1.f between t1.c and t1.f then b when 11<>a then t1.a else t1.c end when 13=13 then 13 else t1.a end from t1 where 19 not between 11 and t1.b or t1.b not in ((e),(b),c)),a)- -((t1.c))-c)))+t1.b+17 when 13 then ((13)) else t1.f end*t1.b)) in ( -17,t1.a,11)))}
+} {}
+do_test randexpr-2.2201 {
+ db eval {SELECT 19 | t1.a*(select case max(case when t1.b*17>=t1.b then coalesce((select max(e) from t1 where e in (select count(*) from t1 union select count(distinct t1.f) from t1)),d) when t1.a in (select min(11) from t1 union select (( -( -max(t1.f)))) from t1) and 17 in (select count(distinct 17) from t1 union select -count(distinct d) from t1) and (d)<>t1.c and t1.c not between b and b then a else 11 end)+cast(avg(t1.a) AS integer) when ~count(distinct t1.e) then count(distinct d) else count(distinct e) end from t1) | e*t1.b-t1.d FROM t1 WHERE NOT ((((abs(19)/abs(case ~c*d+(abs(e)/abs((coalesce((select case when (f in (select count(*) from t1 union select -min(d) from t1)) then case when -t1.f between t1.c and t1.f then b when 11<>a then t1.a else t1.c end when 13=13 then 13 else t1.a end from t1 where 19 not between 11 and t1.b or t1.b not in ((e),(b),c)),a)- -((t1.c))-c)))+t1.b+17 when 13 then ((13)) else t1.f end*t1.b)) in ( -17,t1.a,11))))}
+} {99703}
+do_test randexpr-2.2202 {
+ db eval {SELECT 19 & t1.a*(select case max(case when t1.b*17>=t1.b then coalesce((select max(e) from t1 where e in (select count(*) from t1 union select count(distinct t1.f) from t1)),d) when t1.a in (select min(11) from t1 union select (( -( -max(t1.f)))) from t1) and 17 in (select count(distinct 17) from t1 union select -count(distinct d) from t1) and (d)<>t1.c and t1.c not between b and b then a else 11 end)+cast(avg(t1.a) AS integer) when ~count(distinct t1.e) then count(distinct d) else count(distinct e) end from t1) & e*t1.b-t1.d FROM t1 WHERE NOT ((((abs(19)/abs(case ~c*d+(abs(e)/abs((coalesce((select case when (f in (select count(*) from t1 union select -min(d) from t1)) then case when -t1.f between t1.c and t1.f then b when 11<>a then t1.a else t1.c end when 13=13 then 13 else t1.a end from t1 where 19 not between 11 and t1.b or t1.b not in ((e),(b),c)),a)- -((t1.c))-c)))+t1.b+17 when 13 then ((13)) else t1.f end*t1.b)) in ( -17,t1.a,11))))}
+} {0}
+do_test randexpr-2.2203 {
+ db eval {SELECT c-coalesce((select -coalesce((select max(case when (abs(~~case when case when t1.e<=e and t1.f>t1.d then b when t1.a<>t1.a then 17 else 17 end+t1.c>=t1.a then (c) when c not in (f,e,t1.c) then t1.d else 13 end)/abs(t1.a))<t1.b then t1.e when c<=t1.a then b else d end) from t1 where (19) not in (13,t1.e,f)),17) from t1 where 19>c),t1.a)*19 FROM t1 WHERE (17) | case when 19 not in ((case when (e*19=f) then case t1.f when a then 13 else t1.d end when b<t1.f then f else a end)*t1.d,c, -t1.f) then t1.f when (e=(d) and 19<>t1.b) then f else a end in (select c from t1 union select -13 from t1) or 17 in (select 19 from t1 union select d from t1) and t1.b in (c,b,19) and t1.b>=( -b)}
+} {}
+do_test randexpr-2.2204 {
+ db eval {SELECT c-coalesce((select -coalesce((select max(case when (abs(~~case when case when t1.e<=e and t1.f>t1.d then b when t1.a<>t1.a then 17 else 17 end+t1.c>=t1.a then (c) when c not in (f,e,t1.c) then t1.d else 13 end)/abs(t1.a))<t1.b then t1.e when c<=t1.a then b else d end) from t1 where (19) not in (13,t1.e,f)),17) from t1 where 19>c),t1.a)*19 FROM t1 WHERE NOT ((17) | case when 19 not in ((case when (e*19=f) then case t1.f when a then 13 else t1.d end when b<t1.f then f else a end)*t1.d,c, -t1.f) then t1.f when (e=(d) and 19<>t1.b) then f else a end in (select c from t1 union select -13 from t1) or 17 in (select 19 from t1 union select d from t1) and t1.b in (c,b,19) and t1.b>=( -b))}
+} {-1600}
+do_test randexpr-2.2205 {
+ db eval {SELECT 13+case when not (t1.d in (11,f,t1.a)) then coalesce((select +t1.e from t1 where case t1.e when t1.b then 19+t1.a+~e+a*t1.a else 11 end not between 19 and 19),(abs(t1.f-case when (19)<t1.a and d=t1.d then a else a end-f)/abs(13))*c+t1.c)+c else 19 end*t1.e FROM t1 WHERE t1.e in (select +count(distinct a-(select count(*)+count(distinct (abs((select max(coalesce((select case d++11+(t1.c-t1.d-t1.e*t1.e) when t1.a then t1.b else t1.b end from t1 where f in (select (abs(case when e not between -t1.a and f then 11 when t1.b>=17 then t1.c else t1.f end)/abs(19)) from t1 union select c from t1)), -d)) from t1))/abs(t1.d))) from t1)*(c) | 11+t1.c*t1.b) from t1 union select cast(avg(t1.c) AS integer) from t1)}
+} {}
+do_test randexpr-2.2206 {
+ db eval {SELECT 13+case when not (t1.d in (11,f,t1.a)) then coalesce((select +t1.e from t1 where case t1.e when t1.b then 19+t1.a+~e+a*t1.a else 11 end not between 19 and 19),(abs(t1.f-case when (19)<t1.a and d=t1.d then a else a end-f)/abs(13))*c+t1.c)+c else 19 end*t1.e FROM t1 WHERE NOT (t1.e in (select +count(distinct a-(select count(*)+count(distinct (abs((select max(coalesce((select case d++11+(t1.c-t1.d-t1.e*t1.e) when t1.a then t1.b else t1.b end from t1 where f in (select (abs(case when e not between -t1.a and f then 11 when t1.b>=17 then t1.c else t1.f end)/abs(19)) from t1 union select c from t1)), -d)) from t1))/abs(t1.d))) from t1)*(c) | 11+t1.c*t1.b) from t1 union select cast(avg(t1.c) AS integer) from t1))}
+} {400013}
+do_test randexpr-2.2207 {
+ db eval {SELECT case when -11-t1.b-f-t1.b>~c then t1.e else case when t1.d<>b*~17+t1.d*(select max(+(select count(distinct t1.a)+ -cast(avg(d) AS integer)*max(13) from t1)) from t1) or (abs(c)/abs(c)) not in (11,d,t1.c) then 13 when d in (select f from t1 union select b from t1) then t1.f else -t1.a end+ -f end FROM t1 WHERE ~t1.b*19-d not between ~b and t1.f}
+} {-587}
+do_test randexpr-2.2208 {
+ db eval {SELECT case when -11-t1.b-f-t1.b>~c then t1.e else case when t1.d<>b*~17+t1.d*(select max(+(select count(distinct t1.a)+ -cast(avg(d) AS integer)*max(13) from t1)) from t1) or (abs(c)/abs(c)) not in (11,d,t1.c) then 13 when d in (select f from t1 union select b from t1) then t1.f else -t1.a end+ -f end FROM t1 WHERE NOT (~t1.b*19-d not between ~b and t1.f)}
+} {}
+do_test randexpr-2.2209 {
+ db eval {SELECT coalesce((select t1.b from t1 where coalesce((select max(coalesce((select max(t1.a) from t1 where t1.c=t1.e),case b-f when f then e else 13 end-t1.d)) from t1 where not exists(select 1 from t1 where -t1.f>=17)),a)*(19) in (select max(d) from t1 union select case -count(*) when +count(distinct (t1.f)) then min(t1.d) else count(*) end from t1) and a<=f and d not between b and 19 and not exists(select 1 from t1 where b between t1.c and e or c<>t1.f)),17) FROM t1 WHERE t1.a-19<>c*d}
+} {17}
+do_test randexpr-2.2210 {
+ db eval {SELECT coalesce((select t1.b from t1 where coalesce((select max(coalesce((select max(t1.a) from t1 where t1.c=t1.e),case b-f when f then e else 13 end-t1.d)) from t1 where not exists(select 1 from t1 where -t1.f>=17)),a)*(19) in (select max(d) from t1 union select case -count(*) when +count(distinct (t1.f)) then min(t1.d) else count(*) end from t1) and a<=f and d not between b and 19 and not exists(select 1 from t1 where b between t1.c and e or c<>t1.f)),17) FROM t1 WHERE NOT (t1.a-19<>c*d)}
+} {}
+do_test randexpr-2.2211 {
+ db eval {SELECT (coalesce((select case (select ~count(*) | max(b+t1.b)+case max((abs(+coalesce((select max(f) from t1 where not (17=e)),t1.f))/abs(b))*a) when -~~ -(cast(avg(13) AS integer)) | count(*) then min(13) else count(*) end-count(distinct d) from t1) when 17+t1.d then t1.a else 13 end from t1 where e not between 13 and 11),11)+t1.e+b) FROM t1 WHERE not f in (select t1.e from t1 union select t1.f from t1) or 13 not in (t1.b | t1.e,t1.f,d) or (abs(f)/abs(+(abs(f+(select max(case when ((13<>t1.c)) then 13 else t1.c end) | ~min(t1.a)+cast(avg(a) AS integer) from t1)*(d)-b)/abs(d))*e))-t1.b not in (t1.c,f,t1.d) and t1.b<>t1.f}
+} {713}
+do_test randexpr-2.2212 {
+ db eval {SELECT (coalesce((select case (select ~count(*) | max(b+t1.b)+case max((abs(+coalesce((select max(f) from t1 where not (17=e)),t1.f))/abs(b))*a) when -~~ -(cast(avg(13) AS integer)) | count(*) then min(13) else count(*) end-count(distinct d) from t1) when 17+t1.d then t1.a else 13 end from t1 where e not between 13 and 11),11)+t1.e+b) FROM t1 WHERE NOT (not f in (select t1.e from t1 union select t1.f from t1) or 13 not in (t1.b | t1.e,t1.f,d) or (abs(f)/abs(+(abs(f+(select max(case when ((13<>t1.c)) then 13 else t1.c end) | ~min(t1.a)+cast(avg(a) AS integer) from t1)*(d)-b)/abs(d))*e))-t1.b not in (t1.c,f,t1.d) and t1.b<>t1.f)}
+} {}
+do_test randexpr-2.2213 {
+ db eval {SELECT (coalesce((select case (select ~count(*) & max(b+t1.b)+case max((abs(+coalesce((select max(f) from t1 where not (17=e)),t1.f))/abs(b))*a) when -~~ -(cast(avg(13) AS integer)) & count(*) then min(13) else count(*) end-count(distinct d) from t1) when 17+t1.d then t1.a else 13 end from t1 where e not between 13 and 11),11)+t1.e+b) FROM t1 WHERE not f in (select t1.e from t1 union select t1.f from t1) or 13 not in (t1.b | t1.e,t1.f,d) or (abs(f)/abs(+(abs(f+(select max(case when ((13<>t1.c)) then 13 else t1.c end) | ~min(t1.a)+cast(avg(a) AS integer) from t1)*(d)-b)/abs(d))*e))-t1.b not in (t1.c,f,t1.d) and t1.b<>t1.f}
+} {713}
+do_test randexpr-2.2214 {
+ db eval {SELECT t1.b-c*a*t1.b+ -f | (case when 13<f then d else t1.a+case (select +min(a) from t1) when case when a<=d*a | e then b when not f not between e and 17 or not 19=coalesce((select 13 from t1 where t1.f in (t1.b,t1.d,t1.a)),d) then 11 else (13) end then 11 else (a) end end-b) FROM t1 WHERE exists(select 1 from t1 where t1.a>17)}
+} {-6000392}
+do_test randexpr-2.2215 {
+ db eval {SELECT t1.b-c*a*t1.b+ -f | (case when 13<f then d else t1.a+case (select +min(a) from t1) when case when a<=d*a | e then b when not f not between e and 17 or not 19=coalesce((select 13 from t1 where t1.f in (t1.b,t1.d,t1.a)),d) then 11 else (13) end then 11 else (a) end end-b) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.a>17))}
+} {}
+do_test randexpr-2.2216 {
+ db eval {SELECT t1.b-c*a*t1.b+ -f & (case when 13<f then d else t1.a+case (select +min(a) from t1) when case when a<=d*a & e then b when not f not between e and 17 or not 19=coalesce((select 13 from t1 where t1.f in (t1.b,t1.d,t1.a)),d) then 11 else (13) end then 11 else (a) end end-b) FROM t1 WHERE exists(select 1 from t1 where t1.a>17)}
+} {192}
+do_test randexpr-2.2217 {
+ db eval {SELECT ~(select (abs(cast(avg(((b)-d*t1.a-c+17+f+e+ -17)) AS integer))) from t1)*t1.c++ -(11-t1.b*~f-e*t1.b)-coalesce((select max(case when not c=13 then 17 else b end) from t1 where (t1.a>17)),c) | -f-f FROM t1 WHERE a+coalesce((select max(coalesce((select max(f) from t1 where ((not b in (select t1.b from t1 union select (select -cast(avg(t1.b) AS integer) from t1) from t1)) or not t1.d= -t1.c and 19<=t1.c)),t1.f)-coalesce((select c from t1 where d<=t1.a), -e)) from t1 where d in (select t1.d from t1 union select t1.d from t1)),t1.d)-a | t1.b>(f) or t1.d between 19 and t1.c and exists(select 1 from t1 where b=13) and not 13 not in (t1.d,(c),d) and e not between 17 and 13}
+} {-1040}
+do_test randexpr-2.2218 {
+ db eval {SELECT ~(select (abs(cast(avg(((b)-d*t1.a-c+17+f+e+ -17)) AS integer))) from t1)*t1.c++ -(11-t1.b*~f-e*t1.b)-coalesce((select max(case when not c=13 then 17 else b end) from t1 where (t1.a>17)),c) | -f-f FROM t1 WHERE NOT (a+coalesce((select max(coalesce((select max(f) from t1 where ((not b in (select t1.b from t1 union select (select -cast(avg(t1.b) AS integer) from t1) from t1)) or not t1.d= -t1.c and 19<=t1.c)),t1.f)-coalesce((select c from t1 where d<=t1.a), -e)) from t1 where d in (select t1.d from t1 union select t1.d from t1)),t1.d)-a | t1.b>(f) or t1.d between 19 and t1.c and exists(select 1 from t1 where b=13) and not 13 not in (t1.d,(c),d) and e not between 17 and 13)}
+} {}
+do_test randexpr-2.2219 {
+ db eval {SELECT ~(select (abs(cast(avg(((b)-d*t1.a-c+17+f+e+ -17)) AS integer))) from t1)*t1.c++ -(11-t1.b*~f-e*t1.b)-coalesce((select max(case when not c=13 then 17 else b end) from t1 where (t1.a>17)),c) & -f-f FROM t1 WHERE a+coalesce((select max(coalesce((select max(f) from t1 where ((not b in (select t1.b from t1 union select (select -cast(avg(t1.b) AS integer) from t1) from t1)) or not t1.d= -t1.c and 19<=t1.c)),t1.f)-coalesce((select c from t1 where d<=t1.a), -e)) from t1 where d in (select t1.d from t1 union select t1.d from t1)),t1.d)-a | t1.b>(f) or t1.d between 19 and t1.c and exists(select 1 from t1 where b=13) and not 13 not in (t1.d,(c),d) and e not between 17 and 13}
+} {-11720688}
+do_test randexpr-2.2220 {
+ db eval {SELECT case when t1.a in (select count(*) from t1 union select cast(avg(t1.a) AS integer)*count(distinct 17) | -count(*) from t1) then ~coalesce((select max(19+t1.a) from t1 where +d=t1.a),case t1.c-(select count(*) from t1) when coalesce((select (abs((select (cast(avg(13) AS integer)) from t1))/abs(13)) from t1 where f<~13-(t1.a)*19),d) then a else 19 end) | b when t1.d>a then f else b end FROM t1 WHERE 19<=case when (t1.a*11*19-e<>(select abs(min(e))+case -abs(abs( - -( -(( -max(c)))))-(min(c))) when min(e) then -(min(f)) else - -min(t1.a) end from t1)*t1.d) then e+f+coalesce((select max(e-a) from t1 where (t1.b) between 11 and -t1.c),c) when t1.c<=17 then 17 else t1.b end and 19<>t1.f}
+} {600}
+do_test randexpr-2.2221 {
+ db eval {SELECT case when t1.a in (select count(*) from t1 union select cast(avg(t1.a) AS integer)*count(distinct 17) | -count(*) from t1) then ~coalesce((select max(19+t1.a) from t1 where +d=t1.a),case t1.c-(select count(*) from t1) when coalesce((select (abs((select (cast(avg(13) AS integer)) from t1))/abs(13)) from t1 where f<~13-(t1.a)*19),d) then a else 19 end) | b when t1.d>a then f else b end FROM t1 WHERE NOT (19<=case when (t1.a*11*19-e<>(select abs(min(e))+case -abs(abs( - -( -(( -max(c)))))-(min(c))) when min(e) then -(min(f)) else - -min(t1.a) end from t1)*t1.d) then e+f+coalesce((select max(e-a) from t1 where (t1.b) between 11 and -t1.c),c) when t1.c<=17 then 17 else t1.b end and 19<>t1.f)}
+} {}
+do_test randexpr-2.2222 {
+ db eval {SELECT case when t1.a in (select count(*) from t1 union select cast(avg(t1.a) AS integer)*count(distinct 17) & -count(*) from t1) then ~coalesce((select max(19+t1.a) from t1 where +d=t1.a),case t1.c-(select count(*) from t1) when coalesce((select (abs((select (cast(avg(13) AS integer)) from t1))/abs(13)) from t1 where f<~13-(t1.a)*19),d) then a else 19 end) & b when t1.d>a then f else b end FROM t1 WHERE 19<=case when (t1.a*11*19-e<>(select abs(min(e))+case -abs(abs( - -( -(( -max(c)))))-(min(c))) when min(e) then -(min(f)) else - -min(t1.a) end from t1)*t1.d) then e+f+coalesce((select max(e-a) from t1 where (t1.b) between 11 and -t1.c),c) when t1.c<=17 then 17 else t1.b end and 19<>t1.f}
+} {200}
+do_test randexpr-2.2223 {
+ db eval {SELECT c-case when t1.e>coalesce((select case -t1.d-case when d in (select -t1.f from t1 union select t1.c+t1.c from t1) and (t1.a<=t1.a) then 11*(17) when d between 11 and e or -c<>t1.f then 19 else 19 end+11 when 19 then b else t1.b end-t1.a from t1 where not e<=f),( -t1.f)) then b when ((d<c)) then 19 else f end FROM t1 WHERE t1.c in (t1.c,~19,13)}
+} {100}
+do_test randexpr-2.2224 {
+ db eval {SELECT c-case when t1.e>coalesce((select case -t1.d-case when d in (select -t1.f from t1 union select t1.c+t1.c from t1) and (t1.a<=t1.a) then 11*(17) when d between 11 and e or -c<>t1.f then 19 else 19 end+11 when 19 then b else t1.b end-t1.a from t1 where not e<=f),( -t1.f)) then b when ((d<c)) then 19 else f end FROM t1 WHERE NOT (t1.c in (t1.c,~19,13))}
+} {}
+do_test randexpr-2.2225 {
+ db eval {SELECT (abs(~(select case max(t1.a) when min(coalesce((select ~coalesce((select max((abs(e)/abs(t1.d))*t1.b*13+t1.b) from t1 where t1.d=t1.f),t1.e)-d from t1 where e between t1.f and 19),(b))) then ~case ~cast(avg(t1.b) AS integer)+~case cast(avg(f) AS integer) when min(19) then -min(t1.f) else (cast(avg(e) AS integer)) end when cast(avg(f) AS integer) then count(*) else count(distinct c) end-cast(avg(11) AS integer) else cast(avg(t1.f) AS integer) end | min(b) from t1))/abs(t1.b)) FROM t1 WHERE e<a}
+} {}
+do_test randexpr-2.2226 {
+ db eval {SELECT (abs(~(select case max(t1.a) when min(coalesce((select ~coalesce((select max((abs(e)/abs(t1.d))*t1.b*13+t1.b) from t1 where t1.d=t1.f),t1.e)-d from t1 where e between t1.f and 19),(b))) then ~case ~cast(avg(t1.b) AS integer)+~case cast(avg(f) AS integer) when min(19) then -min(t1.f) else (cast(avg(e) AS integer)) end when cast(avg(f) AS integer) then count(*) else count(distinct c) end-cast(avg(11) AS integer) else cast(avg(t1.f) AS integer) end | min(b) from t1))/abs(t1.b)) FROM t1 WHERE NOT (e<a)}
+} {3}
+do_test randexpr-2.2227 {
+ db eval {SELECT (abs(~(select case max(t1.a) when min(coalesce((select ~coalesce((select max((abs(e)/abs(t1.d))*t1.b*13+t1.b) from t1 where t1.d=t1.f),t1.e)-d from t1 where e between t1.f and 19),(b))) then ~case ~cast(avg(t1.b) AS integer)+~case cast(avg(f) AS integer) when min(19) then -min(t1.f) else (cast(avg(e) AS integer)) end when cast(avg(f) AS integer) then count(*) else count(distinct c) end-cast(avg(11) AS integer) else cast(avg(t1.f) AS integer) end & min(b) from t1))/abs(t1.b)) FROM t1 WHERE NOT (e<a)}
+} {0}
+do_test randexpr-2.2228 {
+ db eval {SELECT case when not (select -case (( -(count(*)) | cast(avg(d) AS integer))) | min((e)) when cast(avg(d) AS integer) then count(*) else count(distinct t1.e) end+max((17)) | max(t1.a)+ -count(*) from t1)-e in (t1.a,11-t1.d,t1.b) and coalesce((select max(t1.c) from t1 where case t1.d when t1.f then d else b end<>t1.d),d)>=13 then coalesce((select -17+e from t1 where t1.a<=19),b) else (19) end FROM t1 WHERE (abs( -t1.f)/abs(t1.a))<=t1.d}
+} {200}
+do_test randexpr-2.2229 {
+ db eval {SELECT case when not (select -case (( -(count(*)) | cast(avg(d) AS integer))) | min((e)) when cast(avg(d) AS integer) then count(*) else count(distinct t1.e) end+max((17)) | max(t1.a)+ -count(*) from t1)-e in (t1.a,11-t1.d,t1.b) and coalesce((select max(t1.c) from t1 where case t1.d when t1.f then d else b end<>t1.d),d)>=13 then coalesce((select -17+e from t1 where t1.a<=19),b) else (19) end FROM t1 WHERE NOT ((abs( -t1.f)/abs(t1.a))<=t1.d)}
+} {}
+do_test randexpr-2.2230 {
+ db eval {SELECT case when not (select -case (( -(count(*)) & cast(avg(d) AS integer))) & min((e)) when cast(avg(d) AS integer) then count(*) else count(distinct t1.e) end+max((17)) & max(t1.a)+ -count(*) from t1)-e in (t1.a,11-t1.d,t1.b) and coalesce((select max(t1.c) from t1 where case t1.d when t1.f then d else b end<>t1.d),d)>=13 then coalesce((select -17+e from t1 where t1.a<=19),b) else (19) end FROM t1 WHERE (abs( -t1.f)/abs(t1.a))<=t1.d}
+} {200}
+do_test randexpr-2.2231 {
+ db eval {SELECT case when 13 in (select cast(avg(11) AS integer) from t1 union select count(*) from t1) then t1.f-case c-(abs(d+~+t1.d-(abs(13)/abs(t1.e-t1.b-t1.c))*e)/abs(17*19+t1.e)) when 19 then 17 else a end when (t1.a in (select count(distinct 13) from t1 union select max(t1.f) from t1)) and c between ((c)) and (t1.a) then c else 19 end+t1.e FROM t1 WHERE 19<>t1.c}
+} {519}
+do_test randexpr-2.2232 {
+ db eval {SELECT case when 13 in (select cast(avg(11) AS integer) from t1 union select count(*) from t1) then t1.f-case c-(abs(d+~+t1.d-(abs(13)/abs(t1.e-t1.b-t1.c))*e)/abs(17*19+t1.e)) when 19 then 17 else a end when (t1.a in (select count(distinct 13) from t1 union select max(t1.f) from t1)) and c between ((c)) and (t1.a) then c else 19 end+t1.e FROM t1 WHERE NOT (19<>t1.c)}
+} {}
+do_test randexpr-2.2233 {
+ db eval {SELECT coalesce((select max(case when not exists(select 1 from t1 where coalesce((select a from t1 where (t1.c+t1.d<=t1.b and exists(select 1 from t1 where t1.f not in (~case when t1.d>d then t1.a else a end,( -e),t1.b))) and (c<>17)),e) in (select e from t1 union select d from t1)) then case when b not in (a,17,e) or f=t1.e then t1.d else d end else a end*19) from t1 where ((t1.c not between e and t1.e))),13) FROM t1 WHERE c not in (~t1.e,t1.e,a)}
+} {1900}
+do_test randexpr-2.2234 {
+ db eval {SELECT coalesce((select max(case when not exists(select 1 from t1 where coalesce((select a from t1 where (t1.c+t1.d<=t1.b and exists(select 1 from t1 where t1.f not in (~case when t1.d>d then t1.a else a end,( -e),t1.b))) and (c<>17)),e) in (select e from t1 union select d from t1)) then case when b not in (a,17,e) or f=t1.e then t1.d else d end else a end*19) from t1 where ((t1.c not between e and t1.e))),13) FROM t1 WHERE NOT (c not in (~t1.e,t1.e,a))}
+} {}
+do_test randexpr-2.2235 {
+ db eval {SELECT coalesce((select t1.f from t1 where d+(select count(distinct e) from t1)+~+ -~e-a+t1.a-b- -a*coalesce((select c-t1.d*case when ( -11<=e or b>= - -c and t1.c<t1.f) then (t1.d)-11 when a not between t1.b and t1.e then 11 else b end from t1 where t1.e<=11),t1.f)*t1.e<>19),t1.f) FROM t1 WHERE t1.f<>c}
+} {600}
+do_test randexpr-2.2236 {
+ db eval {SELECT coalesce((select t1.f from t1 where d+(select count(distinct e) from t1)+~+ -~e-a+t1.a-b- -a*coalesce((select c-t1.d*case when ( -11<=e or b>= - -c and t1.c<t1.f) then (t1.d)-11 when a not between t1.b and t1.e then 11 else b end from t1 where t1.e<=11),t1.f)*t1.e<>19),t1.f) FROM t1 WHERE NOT (t1.f<>c)}
+} {}
+do_test randexpr-2.2237 {
+ db eval {SELECT 19+case when d between t1.b and 19+t1.d*(select ~min(t1.e | a) from t1)-case when exists(select 1 from t1 where 19<>t1.a and 19 between case +19 when 19 then t1.e else e end and t1.a) then a when t1.a between 13 and f or (t1.f<19) and d>=t1.c and f not between a and t1.b then a else t1.d end then b else t1.a end+ -d FROM t1 WHERE f>=t1.d+(t1.a)}
+} {-281}
+do_test randexpr-2.2238 {
+ db eval {SELECT 19+case when d between t1.b and 19+t1.d*(select ~min(t1.e | a) from t1)-case when exists(select 1 from t1 where 19<>t1.a and 19 between case +19 when 19 then t1.e else e end and t1.a) then a when t1.a between 13 and f or (t1.f<19) and d>=t1.c and f not between a and t1.b then a else t1.d end then b else t1.a end+ -d FROM t1 WHERE NOT (f>=t1.d+(t1.a))}
+} {}
+do_test randexpr-2.2239 {
+ db eval {SELECT 19+case when d between t1.b and 19+t1.d*(select ~min(t1.e & a) from t1)-case when exists(select 1 from t1 where 19<>t1.a and 19 between case +19 when 19 then t1.e else e end and t1.a) then a when t1.a between 13 and f or (t1.f<19) and d>=t1.c and f not between a and t1.b then a else t1.d end then b else t1.a end+ -d FROM t1 WHERE f>=t1.d+(t1.a)}
+} {-281}
+do_test randexpr-2.2240 {
+ db eval {SELECT t1.d+(select case max(t1.f) when count(distinct ~coalesce((select case when 17 in (select t1.b from t1 union select t1.e from t1) then c when (d<= -(abs(t1.a)/abs(t1.d))) then t1.b+ -case when t1.b<b then f when d not in ( - -f,11,t1.c) then d else t1.d end*a | d else e end-t1.e from t1 where a<f or a=f),c)) then cast(avg(17) AS integer) else -~count(*) end from t1)+e FROM t1 WHERE (e-coalesce((select b+11+( -t1.e) | coalesce((select (abs(c)/abs(coalesce((select max(t1.b) from t1 where t1.d<=f),c)*t1.b)) from t1 where 13 not in (f,19,b)),e)+t1.b+t1.e+13+19-t1.b-t1.c from t1 where d>t1.a or t1.d>=t1.f),t1.a)-e)<=t1.e}
+} {902}
+do_test randexpr-2.2241 {
+ db eval {SELECT t1.d+(select case max(t1.f) when count(distinct ~coalesce((select case when 17 in (select t1.b from t1 union select t1.e from t1) then c when (d<= -(abs(t1.a)/abs(t1.d))) then t1.b+ -case when t1.b<b then f when d not in ( - -f,11,t1.c) then d else t1.d end*a | d else e end-t1.e from t1 where a<f or a=f),c)) then cast(avg(17) AS integer) else -~count(*) end from t1)+e FROM t1 WHERE NOT ((e-coalesce((select b+11+( -t1.e) | coalesce((select (abs(c)/abs(coalesce((select max(t1.b) from t1 where t1.d<=f),c)*t1.b)) from t1 where 13 not in (f,19,b)),e)+t1.b+t1.e+13+19-t1.b-t1.c from t1 where d>t1.a or t1.d>=t1.f),t1.a)-e)<=t1.e)}
+} {}
+do_test randexpr-2.2242 {
+ db eval {SELECT t1.d+(select case max(t1.f) when count(distinct ~coalesce((select case when 17 in (select t1.b from t1 union select t1.e from t1) then c when (d<= -(abs(t1.a)/abs(t1.d))) then t1.b+ -case when t1.b<b then f when d not in ( - -f,11,t1.c) then d else t1.d end*a & d else e end-t1.e from t1 where a<f or a=f),c)) then cast(avg(17) AS integer) else -~count(*) end from t1)+e FROM t1 WHERE (e-coalesce((select b+11+( -t1.e) | coalesce((select (abs(c)/abs(coalesce((select max(t1.b) from t1 where t1.d<=f),c)*t1.b)) from t1 where 13 not in (f,19,b)),e)+t1.b+t1.e+13+19-t1.b-t1.c from t1 where d>t1.a or t1.d>=t1.f),t1.a)-e)<=t1.e}
+} {902}
+do_test randexpr-2.2243 {
+ db eval {SELECT (select count(distinct (select case ~abs(~+abs(case (max(17)) when max(coalesce((select ~b from t1 where (not exists(select 1 from t1 where -17<>f or t1.d>=b and 19 between 19 and t1.b))),(abs(case when 19<>a then t1.c else t1.b end)/abs(19)))) then ~+cast(avg(19) AS integer) else min(t1.a) end) | case min(13) when max(11) then count(distinct -d) else count(distinct t1.d) end)*max(t1.d) when count(*) then -min(e) else (count(*)) end+count(*) from t1)) from t1) FROM t1 WHERE (d in (select abs(count(*) | case max((case when b<=13 then t1.b*e when case when t1.c between t1.d and a then t1.a when (f< -19) then t1.c else d end between t1.d and b then t1.e else t1.b end))-max((t1.c)) when max(t1.f) then -abs(+cast(avg(19) AS integer)) else abs(max(t1.c)) end++max(17))- -cast(avg(f) AS integer) from t1 union select min(11) from t1))}
+} {}
+do_test randexpr-2.2244 {
+ db eval {SELECT (select count(distinct (select case ~abs(~+abs(case (max(17)) when max(coalesce((select ~b from t1 where (not exists(select 1 from t1 where -17<>f or t1.d>=b and 19 between 19 and t1.b))),(abs(case when 19<>a then t1.c else t1.b end)/abs(19)))) then ~+cast(avg(19) AS integer) else min(t1.a) end) | case min(13) when max(11) then count(distinct -d) else count(distinct t1.d) end)*max(t1.d) when count(*) then -min(e) else (count(*)) end+count(*) from t1)) from t1) FROM t1 WHERE NOT ((d in (select abs(count(*) | case max((case when b<=13 then t1.b*e when case when t1.c between t1.d and a then t1.a when (f< -19) then t1.c else d end between t1.d and b then t1.e else t1.b end))-max((t1.c)) when max(t1.f) then -abs(+cast(avg(19) AS integer)) else abs(max(t1.c)) end++max(17))- -cast(avg(f) AS integer) from t1 union select min(11) from t1)))}
+} {1}
+do_test randexpr-2.2245 {
+ db eval {SELECT (select count(distinct (select case ~abs(~+abs(case (max(17)) when max(coalesce((select ~b from t1 where (not exists(select 1 from t1 where -17<>f or t1.d>=b and 19 between 19 and t1.b))),(abs(case when 19<>a then t1.c else t1.b end)/abs(19)))) then ~+cast(avg(19) AS integer) else min(t1.a) end) & case min(13) when max(11) then count(distinct -d) else count(distinct t1.d) end)*max(t1.d) when count(*) then -min(e) else (count(*)) end+count(*) from t1)) from t1) FROM t1 WHERE NOT ((d in (select abs(count(*) | case max((case when b<=13 then t1.b*e when case when t1.c between t1.d and a then t1.a when (f< -19) then t1.c else d end between t1.d and b then t1.e else t1.b end))-max((t1.c)) when max(t1.f) then -abs(+cast(avg(19) AS integer)) else abs(max(t1.c)) end++max(17))- -cast(avg(f) AS integer) from t1 union select min(11) from t1)))}
+} {1}
+do_test randexpr-2.2246 {
+ db eval {SELECT case d*coalesce((select e from t1 where t1.f in (case when not exists(select 1 from t1 where 19>=(+f-13)) then case when not not exists(select 1 from t1 where 17>=t1.d-13) then f else d end else t1.c end,c,+(abs(e)/abs(19*d | case 19 when b then 17 else b end-b))) or e between 13 and a),19) when b then c else t1.b end FROM t1 WHERE t1.b<=coalesce((select coalesce((select t1.a from t1 where not t1.b*(select max(t1.d) from t1)<a),e)-b-~11+t1.d from t1 where c not in (((abs((select -case -case abs(+count(*)-(count(distinct a))) when min(a) then min(d) else cast(avg(t1.a) AS integer) end when min(19) then cast(avg(a) AS integer) else min(d) end from t1) | d)/abs(d)))+19,17,11-c)),t1.c)}
+} {200}
+do_test randexpr-2.2247 {
+ db eval {SELECT case d*coalesce((select e from t1 where t1.f in (case when not exists(select 1 from t1 where 19>=(+f-13)) then case when not not exists(select 1 from t1 where 17>=t1.d-13) then f else d end else t1.c end,c,+(abs(e)/abs(19*d | case 19 when b then 17 else b end-b))) or e between 13 and a),19) when b then c else t1.b end FROM t1 WHERE NOT (t1.b<=coalesce((select coalesce((select t1.a from t1 where not t1.b*(select max(t1.d) from t1)<a),e)-b-~11+t1.d from t1 where c not in (((abs((select -case -case abs(+count(*)-(count(distinct a))) when min(a) then min(d) else cast(avg(t1.a) AS integer) end when min(19) then cast(avg(a) AS integer) else min(d) end from t1) | d)/abs(d)))+19,17,11-c)),t1.c))}
+} {}
+do_test randexpr-2.2248 {
+ db eval {SELECT 13-case when f in (select t1.f from t1 union select ~17 from t1) then ~t1.c*t1.f-(abs(17-e*c)/abs(b))*t1.b-11-a+19-coalesce((select (abs(case -(abs(coalesce((select t1.f from t1 where t1.e in (t1.a,b,f)),t1.a))/abs(c)) when c then t1.c else c end)/abs(17)) from t1 where e<t1.c),f) else t1.c end- -d FROM t1 WHERE 17 in (select t1.f from t1 union select t1.d from t1) and (select max((case when t1.d*19 not between -t1.e-case when e=t1.f then (select abs(max( -17)-count(*)-min(13)) from t1) else b- -(c) end*d* -t1.c and 11 then 19 else e end-t1.a-t1.f)+(a)) from t1) in (t1.b,b,t1.f) and 11<=e}
+} {}
+do_test randexpr-2.2249 {
+ db eval {SELECT 13-case when f in (select t1.f from t1 union select ~17 from t1) then ~t1.c*t1.f-(abs(17-e*c)/abs(b))*t1.b-11-a+19-coalesce((select (abs(case -(abs(coalesce((select t1.f from t1 where t1.e in (t1.a,b,f)),t1.a))/abs(c)) when c then t1.c else c end)/abs(17)) from t1 where e<t1.c),f) else t1.c end- -d FROM t1 WHERE NOT (17 in (select t1.f from t1 union select t1.d from t1) and (select max((case when t1.d*19 not between -t1.e-case when e=t1.f then (select abs(max( -17)-count(*)-min(13)) from t1) else b- -(c) end*d* -t1.c and 11 then 19 else e end-t1.a-t1.f)+(a)) from t1) in (t1.b,b,t1.f) and 11<=e)}
+} {331505}
+do_test randexpr-2.2250 {
+ db eval {SELECT case when case when case when case when t1.b<> -c then (b)* -19 else t1.d end<=11 or 17 not between t1.f and 13 or a not in (t1.c,t1.b,11) then c else c end<>t1.a and (f) in (select cast(avg(11) AS integer) from t1 union select case max(b) when (min(t1.c)) then count(distinct f) else max(19) end from t1) then 13 else d end | f-t1.d<=t1.f then f else 19 end FROM t1 WHERE ((f not between t1.f and d))}
+} {600}
+do_test randexpr-2.2251 {
+ db eval {SELECT case when case when case when case when t1.b<> -c then (b)* -19 else t1.d end<=11 or 17 not between t1.f and 13 or a not in (t1.c,t1.b,11) then c else c end<>t1.a and (f) in (select cast(avg(11) AS integer) from t1 union select case max(b) when (min(t1.c)) then count(distinct f) else max(19) end from t1) then 13 else d end | f-t1.d<=t1.f then f else 19 end FROM t1 WHERE NOT (((f not between t1.f and d)))}
+} {}
+do_test randexpr-2.2252 {
+ db eval {SELECT case when case when case when case when t1.b<> -c then (b)* -19 else t1.d end<=11 or 17 not between t1.f and 13 or a not in (t1.c,t1.b,11) then c else c end<>t1.a and (f) in (select cast(avg(11) AS integer) from t1 union select case max(b) when (min(t1.c)) then count(distinct f) else max(19) end from t1) then 13 else d end & f-t1.d<=t1.f then f else 19 end FROM t1 WHERE ((f not between t1.f and d))}
+} {600}
+do_test randexpr-2.2253 {
+ db eval {SELECT d-b-(abs(a)/abs(coalesce((select b from t1 where coalesce((select t1.f from t1 where 13>=f-b),t1.c)*case when coalesce((select case (d*t1.e+b) when t1.a-13 then - -t1.d else t1.a end+13 from t1 where e>=t1.f),11) | b<t1.e then d else c end between c and d),11)-19))+11 FROM t1 WHERE d>=case when coalesce((select max(case when f<>~b | coalesce((select max(11*c) from t1 where 17=t1.f),t1.d)*d then b when a in (c,(t1.d),(f)) then a else 19 end-t1.f) from t1 where not 13 in (select cast(avg(t1.b) AS integer)-cast(avg( -t1.a) AS integer) from t1 union select count(*) from t1)),17) not in ((t1.f),c, -19) and e between 11 and (19) then 19 else t1.d end}
+} {199}
+do_test randexpr-2.2254 {
+ db eval {SELECT d-b-(abs(a)/abs(coalesce((select b from t1 where coalesce((select t1.f from t1 where 13>=f-b),t1.c)*case when coalesce((select case (d*t1.e+b) when t1.a-13 then - -t1.d else t1.a end+13 from t1 where e>=t1.f),11) | b<t1.e then d else c end between c and d),11)-19))+11 FROM t1 WHERE NOT (d>=case when coalesce((select max(case when f<>~b | coalesce((select max(11*c) from t1 where 17=t1.f),t1.d)*d then b when a in (c,(t1.d),(f)) then a else 19 end-t1.f) from t1 where not 13 in (select cast(avg(t1.b) AS integer)-cast(avg( -t1.a) AS integer) from t1 union select count(*) from t1)),17) not in ((t1.f),c, -19) and e between 11 and (19) then 19 else t1.d end)}
+} {}
+do_test randexpr-2.2255 {
+ db eval {SELECT d-b-(abs(a)/abs(coalesce((select b from t1 where coalesce((select t1.f from t1 where 13>=f-b),t1.c)*case when coalesce((select case (d*t1.e+b) when t1.a-13 then - -t1.d else t1.a end+13 from t1 where e>=t1.f),11) & b<t1.e then d else c end between c and d),11)-19))+11 FROM t1 WHERE d>=case when coalesce((select max(case when f<>~b | coalesce((select max(11*c) from t1 where 17=t1.f),t1.d)*d then b when a in (c,(t1.d),(f)) then a else 19 end-t1.f) from t1 where not 13 in (select cast(avg(t1.b) AS integer)-cast(avg( -t1.a) AS integer) from t1 union select count(*) from t1)),17) not in ((t1.f),c, -19) and e between 11 and (19) then 19 else t1.d end}
+} {199}
+do_test randexpr-2.2256 {
+ db eval {SELECT coalesce((select max(coalesce((select 13 from t1 where not t1.b<>e*b),t1.c*case when d>=case case 13 when coalesce((select ~~t1.f*(abs(t1.f)/abs(t1.e))-e | -t1.b from t1 where a in (11,13,t1.e)),d)*t1.e then -e else t1.b end when t1.e then 11 else t1.e end then -f else c end) | t1.a) from t1 where e>t1.d), -(t1.f)) FROM t1 WHERE not -13 in (select (+(case case min(a+t1.a) when abs(count(*)-count(distinct t1.d-+(f)-case 19 when b then t1.b else a end)) then case count(*)*max(c) when ~ -count(*)*cast(avg(t1.e) AS integer)*count(distinct -a) then count(*) else cast(avg(19) AS integer) end else cast(avg(b) AS integer) end when min(f) then max( -a) else (count(*)) end)*count(distinct t1.f)-count(*)) from t1 union select count(distinct f) from t1)}
+} {90100}
+do_test randexpr-2.2257 {
+ db eval {SELECT coalesce((select max(coalesce((select 13 from t1 where not t1.b<>e*b),t1.c*case when d>=case case 13 when coalesce((select ~~t1.f*(abs(t1.f)/abs(t1.e))-e | -t1.b from t1 where a in (11,13,t1.e)),d)*t1.e then -e else t1.b end when t1.e then 11 else t1.e end then -f else c end) | t1.a) from t1 where e>t1.d), -(t1.f)) FROM t1 WHERE NOT (not -13 in (select (+(case case min(a+t1.a) when abs(count(*)-count(distinct t1.d-+(f)-case 19 when b then t1.b else a end)) then case count(*)*max(c) when ~ -count(*)*cast(avg(t1.e) AS integer)*count(distinct -a) then count(*) else cast(avg(19) AS integer) end else cast(avg(b) AS integer) end when min(f) then max( -a) else (count(*)) end)*count(distinct t1.f)-count(*)) from t1 union select count(distinct f) from t1))}
+} {}
+do_test randexpr-2.2258 {
+ db eval {SELECT coalesce((select max(coalesce((select 13 from t1 where not t1.b<>e*b),t1.c*case when d>=case case 13 when coalesce((select ~~t1.f*(abs(t1.f)/abs(t1.e))-e & -t1.b from t1 where a in (11,13,t1.e)),d)*t1.e then -e else t1.b end when t1.e then 11 else t1.e end then -f else c end) & t1.a) from t1 where e>t1.d), -(t1.f)) FROM t1 WHERE not -13 in (select (+(case case min(a+t1.a) when abs(count(*)-count(distinct t1.d-+(f)-case 19 when b then t1.b else a end)) then case count(*)*max(c) when ~ -count(*)*cast(avg(t1.e) AS integer)*count(distinct -a) then count(*) else cast(avg(19) AS integer) end else cast(avg(b) AS integer) end when min(f) then max( -a) else (count(*)) end)*count(distinct t1.f)-count(*)) from t1 union select count(distinct f) from t1)}
+} {0}
+do_test randexpr-2.2259 {
+ db eval {SELECT coalesce((select max(t1.e*~t1.b- -t1.b-t1.b-coalesce((select t1.a from t1 where exists(select 1 from t1 where ~d+case case when a between b and f then 13 else -17 end-13 when -19 then t1.f else d end+t1.b<>e or not t1.e between 19 and t1.a or 11 in (19,c, -19))),a)*e) from t1 where t1.f<19),t1.e)-13 FROM t1 WHERE t1.b not between e and 13}
+} {487}
+do_test randexpr-2.2260 {
+ db eval {SELECT coalesce((select max(t1.e*~t1.b- -t1.b-t1.b-coalesce((select t1.a from t1 where exists(select 1 from t1 where ~d+case case when a between b and f then 13 else -17 end-13 when -19 then t1.f else d end+t1.b<>e or not t1.e between 19 and t1.a or 11 in (19,c, -19))),a)*e) from t1 where t1.f<19),t1.e)-13 FROM t1 WHERE NOT (t1.b not between e and 13)}
+} {}
+do_test randexpr-2.2261 {
+ db eval {SELECT (select (count(distinct case t1.d+case when (coalesce((select max((select + -cast(avg(b) AS integer)-min(19) | (cast(avg(19) AS integer)) from t1)) from t1 where ~c+t1.c<t1.d),(c)) in (select t1.c from t1 union select t1.f from t1)) then (select abs( -min(t1.e)) | min(t1.c) from t1) when 11 not between -d and a or a<>t1.a and f between t1.e and d and f<=19 then t1.f else t1.b end-c*a when t1.f then e else t1.b end)) from t1) FROM t1 WHERE not b*c+d<>b}
+} {}
+do_test randexpr-2.2262 {
+ db eval {SELECT (select (count(distinct case t1.d+case when (coalesce((select max((select + -cast(avg(b) AS integer)-min(19) | (cast(avg(19) AS integer)) from t1)) from t1 where ~c+t1.c<t1.d),(c)) in (select t1.c from t1 union select t1.f from t1)) then (select abs( -min(t1.e)) | min(t1.c) from t1) when 11 not between -d and a or a<>t1.a and f between t1.e and d and f<=19 then t1.f else t1.b end-c*a when t1.f then e else t1.b end)) from t1) FROM t1 WHERE NOT (not b*c+d<>b)}
+} {1}
+do_test randexpr-2.2263 {
+ db eval {SELECT (select (count(distinct case t1.d+case when (coalesce((select max((select + -cast(avg(b) AS integer)-min(19) & (cast(avg(19) AS integer)) from t1)) from t1 where ~c+t1.c<t1.d),(c)) in (select t1.c from t1 union select t1.f from t1)) then (select abs( -min(t1.e)) & min(t1.c) from t1) when 11 not between -d and a or a<>t1.a and f between t1.e and d and f<=19 then t1.f else t1.b end-c*a when t1.f then e else t1.b end)) from t1) FROM t1 WHERE NOT (not b*c+d<>b)}
+} {1}
+do_test randexpr-2.2264 {
+ db eval {SELECT t1.b+case case c when f-((abs(t1.f)/abs(coalesce((select max(f+t1.d | t1.c*e+f+~case when c not between b and t1.a or 11<19 then c-d else t1.f end+e-t1.b*11+t1.e) from t1 where 17 not between e and 19),19)))) then d else a end when (t1.c) then t1.f else f end FROM t1 WHERE (b)-t1.c*19-t1.b>17*b-13}
+} {}
+do_test randexpr-2.2265 {
+ db eval {SELECT t1.b+case case c when f-((abs(t1.f)/abs(coalesce((select max(f+t1.d | t1.c*e+f+~case when c not between b and t1.a or 11<19 then c-d else t1.f end+e-t1.b*11+t1.e) from t1 where 17 not between e and 19),19)))) then d else a end when (t1.c) then t1.f else f end FROM t1 WHERE NOT ((b)-t1.c*19-t1.b>17*b-13)}
+} {800}
+do_test randexpr-2.2266 {
+ db eval {SELECT t1.b+case case c when f-((abs(t1.f)/abs(coalesce((select max(f+t1.d & t1.c*e+f+~case when c not between b and t1.a or 11<19 then c-d else t1.f end+e-t1.b*11+t1.e) from t1 where 17 not between e and 19),19)))) then d else a end when (t1.c) then t1.f else f end FROM t1 WHERE NOT ((b)-t1.c*19-t1.b>17*b-13)}
+} {800}
+do_test randexpr-2.2267 {
+ db eval {SELECT coalesce((select coalesce((select ((abs(19)/abs(17))) from t1 where +13 | d>d),13-(select abs(abs(~count(*)))+~count(*) from t1)+(t1.c*t1.e*(abs(19+(13))/abs(a)))-coalesce((select 17 from t1 where c<>e and b not in ((d),t1.b,b)),t1.c)+t1.d)-13 from t1 where t1.f<b),11)+ -t1.c FROM t1 WHERE (t1.e in (select -(+min(f*t1.c)- -max(t1.a))-+min(b) | count(distinct 17) from t1 union select abs(case count(*) when abs(min(d*t1.c-t1.b*~b+c) | (max(case when not 19<(e) then 19 when -17>19 then 17 else t1.c end)-count(*))) then max(11) else +max(b) end) from t1))}
+} {}
+do_test randexpr-2.2268 {
+ db eval {SELECT coalesce((select coalesce((select ((abs(19)/abs(17))) from t1 where +13 | d>d),13-(select abs(abs(~count(*)))+~count(*) from t1)+(t1.c*t1.e*(abs(19+(13))/abs(a)))-coalesce((select 17 from t1 where c<>e and b not in ((d),t1.b,b)),t1.c)+t1.d)-13 from t1 where t1.f<b),11)+ -t1.c FROM t1 WHERE NOT ((t1.e in (select -(+min(f*t1.c)- -max(t1.a))-+min(b) | count(distinct 17) from t1 union select abs(case count(*) when abs(min(d*t1.c-t1.b*~b+c) | (max(case when not 19<(e) then 19 when -17>19 then 17 else t1.c end)-count(*))) then max(11) else +max(b) end) from t1)))}
+} {-289}
+do_test randexpr-2.2269 {
+ db eval {SELECT coalesce((select coalesce((select ((abs(19)/abs(17))) from t1 where +13 & d>d),13-(select abs(abs(~count(*)))+~count(*) from t1)+(t1.c*t1.e*(abs(19+(13))/abs(a)))-coalesce((select 17 from t1 where c<>e and b not in ((d),t1.b,b)),t1.c)+t1.d)-13 from t1 where t1.f<b),11)+ -t1.c FROM t1 WHERE NOT ((t1.e in (select -(+min(f*t1.c)- -max(t1.a))-+min(b) | count(distinct 17) from t1 union select abs(case count(*) when abs(min(d*t1.c-t1.b*~b+c) | (max(case when not 19<(e) then 19 when -17>19 then 17 else t1.c end)-count(*))) then max(11) else +max(b) end) from t1)))}
+} {-289}
+do_test randexpr-2.2270 {
+ db eval {SELECT coalesce((select case d when e then t1.f else d++(abs((select count(*) from t1)-case when t1.f*case when t1.b-c in (select -cast(avg(e) AS integer) from t1 union select max(t1.a) from t1) or b between t1.a and -17 and -t1.f not between 17 and a then t1.e when 17<>11 then (abs(19)/abs(f)) else 17 end-17 not in (13,11,c) then t1.f else t1.c end)/abs(c))*t1.e end from t1 where f between t1.c and 17),t1.f) FROM t1 WHERE t1.b<>19}
+} {600}
+do_test randexpr-2.2271 {
+ db eval {SELECT coalesce((select case d when e then t1.f else d++(abs((select count(*) from t1)-case when t1.f*case when t1.b-c in (select -cast(avg(e) AS integer) from t1 union select max(t1.a) from t1) or b between t1.a and -17 and -t1.f not between 17 and a then t1.e when 17<>11 then (abs(19)/abs(f)) else 17 end-17 not in (13,11,c) then t1.f else t1.c end)/abs(c))*t1.e end from t1 where f between t1.c and 17),t1.f) FROM t1 WHERE NOT (t1.b<>19)}
+} {}
+do_test randexpr-2.2272 {
+ db eval {SELECT t1.f-case when ((t1.a in (select case case +min(case when coalesce((select max(a) from t1 where t1.e not between f and t1.b),f)<>(t1.d) then - -t1.f else 19 end)-case count(*)+(count(distinct t1.d)) when -min(e) then max(t1.f) else min(19) end when cast(avg(13) AS integer) then cast(avg( -t1.a) AS integer) else (min(t1.f)) end when (count(distinct t1.e)) then -cast(avg(a) AS integer) else cast(avg(19) AS integer) end | count(distinct 13)+ -count(*) from t1 union select -max(t1.b) from t1))) then a when d between a and 11 or t1.e<>c then +t1.a-(t1.e) else t1.e end FROM t1 WHERE t1.e between d | t1.a*13 and 11+13*17+b*c++13-~b}
+} {}
+do_test randexpr-2.2273 {
+ db eval {SELECT t1.f-case when ((t1.a in (select case case +min(case when coalesce((select max(a) from t1 where t1.e not between f and t1.b),f)<>(t1.d) then - -t1.f else 19 end)-case count(*)+(count(distinct t1.d)) when -min(e) then max(t1.f) else min(19) end when cast(avg(13) AS integer) then cast(avg( -t1.a) AS integer) else (min(t1.f)) end when (count(distinct t1.e)) then -cast(avg(a) AS integer) else cast(avg(19) AS integer) end | count(distinct 13)+ -count(*) from t1 union select -max(t1.b) from t1))) then a when d between a and 11 or t1.e<>c then +t1.a-(t1.e) else t1.e end FROM t1 WHERE NOT (t1.e between d | t1.a*13 and 11+13*17+b*c++13-~b)}
+} {1000}
+do_test randexpr-2.2274 {
+ db eval {SELECT t1.f-case when ((t1.a in (select case case +min(case when coalesce((select max(a) from t1 where t1.e not between f and t1.b),f)<>(t1.d) then - -t1.f else 19 end)-case count(*)+(count(distinct t1.d)) when -min(e) then max(t1.f) else min(19) end when cast(avg(13) AS integer) then cast(avg( -t1.a) AS integer) else (min(t1.f)) end when (count(distinct t1.e)) then -cast(avg(a) AS integer) else cast(avg(19) AS integer) end & count(distinct 13)+ -count(*) from t1 union select -max(t1.b) from t1))) then a when d between a and 11 or t1.e<>c then +t1.a-(t1.e) else t1.e end FROM t1 WHERE NOT (t1.e between d | t1.a*13 and 11+13*17+b*c++13-~b)}
+} {1000}
+do_test randexpr-2.2275 {
+ db eval {SELECT coalesce((select ~(abs(e)/abs(case when exists(select 1 from t1 where 19=+c or exists(select 1 from t1 where not exists(select 1 from t1 where 11>=d or b not between b and 19)) or t1.a not in (t1.a,(11),13)) then e-13+a-c else a end))*t1.f-(19) | 19 from t1 where t1.d in (select -(cast(avg(19) AS integer)) from t1 union select count(distinct (t1.e)) from t1) and (f in (a,c,(t1.a))) and a between 11 and 11 and t1.d>=t1.f and 11 not in ((t1.f),e,(f)) and 13 not in (t1.c,t1.d,t1.c)),t1.d) FROM t1 WHERE not exists(select 1 from t1 where not coalesce((select max(b) from t1 where coalesce((select t1.f from t1 where t1.f not between t1.e and coalesce((select 13*+ -t1.a | e+case when t1.a not in (case t1.f when d then 19 else 11 end,f*e+19,t1.e+(d)) then 13 else t1.d end+t1.c-17 from t1 where t1.c>=t1.d),t1.c)),t1.d)>t1.c),11) not between b and t1.f)}
+} {}
+do_test randexpr-2.2276 {
+ db eval {SELECT coalesce((select ~(abs(e)/abs(case when exists(select 1 from t1 where 19=+c or exists(select 1 from t1 where not exists(select 1 from t1 where 11>=d or b not between b and 19)) or t1.a not in (t1.a,(11),13)) then e-13+a-c else a end))*t1.f-(19) | 19 from t1 where t1.d in (select -(cast(avg(19) AS integer)) from t1 union select count(distinct (t1.e)) from t1) and (f in (a,c,(t1.a))) and a between 11 and 11 and t1.d>=t1.f and 11 not in ((t1.f),e,(f)) and 13 not in (t1.c,t1.d,t1.c)),t1.d) FROM t1 WHERE NOT (not exists(select 1 from t1 where not coalesce((select max(b) from t1 where coalesce((select t1.f from t1 where t1.f not between t1.e and coalesce((select 13*+ -t1.a | e+case when t1.a not in (case t1.f when d then 19 else 11 end,f*e+19,t1.e+(d)) then 13 else t1.d end+t1.c-17 from t1 where t1.c>=t1.d),t1.c)),t1.d)>t1.c),11) not between b and t1.f))}
+} {400}
+do_test randexpr-2.2277 {
+ db eval {SELECT coalesce((select ~(abs(e)/abs(case when exists(select 1 from t1 where 19=+c or exists(select 1 from t1 where not exists(select 1 from t1 where 11>=d or b not between b and 19)) or t1.a not in (t1.a,(11),13)) then e-13+a-c else a end))*t1.f-(19) & 19 from t1 where t1.d in (select -(cast(avg(19) AS integer)) from t1 union select count(distinct (t1.e)) from t1) and (f in (a,c,(t1.a))) and a between 11 and 11 and t1.d>=t1.f and 11 not in ((t1.f),e,(f)) and 13 not in (t1.c,t1.d,t1.c)),t1.d) FROM t1 WHERE NOT (not exists(select 1 from t1 where not coalesce((select max(b) from t1 where coalesce((select t1.f from t1 where t1.f not between t1.e and coalesce((select 13*+ -t1.a | e+case when t1.a not in (case t1.f when d then 19 else 11 end,f*e+19,t1.e+(d)) then 13 else t1.d end+t1.c-17 from t1 where t1.c>=t1.d),t1.c)),t1.d)>t1.c),11) not between b and t1.f))}
+} {400}
+do_test randexpr-2.2278 {
+ db eval {SELECT case when (select +case -+ -case min(t1.f) when cast(avg(t1.a) AS integer) then abs(~case (min(t1.a)) when (count(*)) then (min(e)) else count(*) end) else ( -cast(avg(b) AS integer)) end*count(*) | count(distinct 11) when -cast(avg(13) AS integer) then -min(13) else max(b) end+max(a) from t1) in ((abs(coalesce((select max(11*a) from t1 where t1.b>11-(select -cast(avg(t1.d) AS integer) from t1)),case when exists(select 1 from t1 where t1.f<13) then a else e end))/abs(c)) | t1.f,f,f) then t1.e else a end FROM t1 WHERE (select case min(case when not 17<11 then (abs(+(d)*t1.c+e-f)/abs(13)) when b between a and 11 then e else b end) when abs(min(t1.b) | (+count(*))) | ~case ( -count(*))-cast(avg(a) AS integer) when count(distinct t1.a) then -count(distinct f) else count(distinct 11) end then max( -t1.d) else -max(f) end from t1)-~c*t1.a not in (t1.e,t1.c,t1.a)}
+} {100}
+do_test randexpr-2.2279 {
+ db eval {SELECT case when (select +case -+ -case min(t1.f) when cast(avg(t1.a) AS integer) then abs(~case (min(t1.a)) when (count(*)) then (min(e)) else count(*) end) else ( -cast(avg(b) AS integer)) end*count(*) | count(distinct 11) when -cast(avg(13) AS integer) then -min(13) else max(b) end+max(a) from t1) in ((abs(coalesce((select max(11*a) from t1 where t1.b>11-(select -cast(avg(t1.d) AS integer) from t1)),case when exists(select 1 from t1 where t1.f<13) then a else e end))/abs(c)) | t1.f,f,f) then t1.e else a end FROM t1 WHERE NOT ((select case min(case when not 17<11 then (abs(+(d)*t1.c+e-f)/abs(13)) when b between a and 11 then e else b end) when abs(min(t1.b) | (+count(*))) | ~case ( -count(*))-cast(avg(a) AS integer) when count(distinct t1.a) then -count(distinct f) else count(distinct 11) end then max( -t1.d) else -max(f) end from t1)-~c*t1.a not in (t1.e,t1.c,t1.a))}
+} {}
+do_test randexpr-2.2280 {
+ db eval {SELECT case when (select +case -+ -case min(t1.f) when cast(avg(t1.a) AS integer) then abs(~case (min(t1.a)) when (count(*)) then (min(e)) else count(*) end) else ( -cast(avg(b) AS integer)) end*count(*) & count(distinct 11) when -cast(avg(13) AS integer) then -min(13) else max(b) end+max(a) from t1) in ((abs(coalesce((select max(11*a) from t1 where t1.b>11-(select -cast(avg(t1.d) AS integer) from t1)),case when exists(select 1 from t1 where t1.f<13) then a else e end))/abs(c)) & t1.f,f,f) then t1.e else a end FROM t1 WHERE (select case min(case when not 17<11 then (abs(+(d)*t1.c+e-f)/abs(13)) when b between a and 11 then e else b end) when abs(min(t1.b) | (+count(*))) | ~case ( -count(*))-cast(avg(a) AS integer) when count(distinct t1.a) then -count(distinct f) else count(distinct 11) end then max( -t1.d) else -max(f) end from t1)-~c*t1.a not in (t1.e,t1.c,t1.a)}
+} {100}
+do_test randexpr-2.2281 {
+ db eval {SELECT case when ~t1.b | 13>=~coalesce((select t1.e from t1 where 11 in (select -case +max(case when (t1.f) in (t1.b,t1.a,t1.f) then f else e end) when max(f)*cast(avg(t1.d) AS integer) then cast(avg(c) AS integer) else -( - -max(t1.f)) end from t1 union select count(*) from t1)),b | ( -t1.e))*t1.c*t1.a*t1.d-f then a when 19 not between -t1.e and t1.e or f not between -a and 19 then d else 11 end FROM t1 WHERE not (d in (select t1.c from t1 union select 11 from t1))}
+} {400}
+do_test randexpr-2.2282 {
+ db eval {SELECT case when ~t1.b | 13>=~coalesce((select t1.e from t1 where 11 in (select -case +max(case when (t1.f) in (t1.b,t1.a,t1.f) then f else e end) when max(f)*cast(avg(t1.d) AS integer) then cast(avg(c) AS integer) else -( - -max(t1.f)) end from t1 union select count(*) from t1)),b | ( -t1.e))*t1.c*t1.a*t1.d-f then a when 19 not between -t1.e and t1.e or f not between -a and 19 then d else 11 end FROM t1 WHERE NOT (not (d in (select t1.c from t1 union select 11 from t1)))}
+} {}
+do_test randexpr-2.2283 {
+ db eval {SELECT case when ~t1.b & 13>=~coalesce((select t1.e from t1 where 11 in (select -case +max(case when (t1.f) in (t1.b,t1.a,t1.f) then f else e end) when max(f)*cast(avg(t1.d) AS integer) then cast(avg(c) AS integer) else -( - -max(t1.f)) end from t1 union select count(*) from t1)),b & ( -t1.e))*t1.c*t1.a*t1.d-f then a when 19 not between -t1.e and t1.e or f not between -a and 19 then d else 11 end FROM t1 WHERE not (d in (select t1.c from t1 union select 11 from t1))}
+} {100}
+do_test randexpr-2.2284 {
+ db eval {SELECT coalesce((select c from t1 where 19 in (select case count(*) when count(distinct c)*+cast(avg(13) AS integer) then max(t1.d) else max(case case when exists(select 1 from t1 where 13 not in (d,e,(19)) and 13 between t1.d and t1.f) then t1.a when b in (t1.a,a,17) then case when t1.a not between 13 and c then (t1.b) else t1.b end else 19 end when 13 then a else 19 end) end from t1 union select (abs(abs(~cast(avg(t1.d) AS integer))) | cast(avg(t1.a) AS integer)) from t1)),t1.e-11)*(t1.a) FROM t1 WHERE not exists(select 1 from t1 where t1.e in (coalesce((select max(13) from t1 where 19 in (select f from t1 union select a from t1) or (not exists(select 1 from t1 where t1.a<=(19)*c*c | 13))),+e-(f)*case when t1.c not in (coalesce((select max(t1.a) from t1 where not c<(19)),19),e,(19)) then d else f end)+a,19,17)) or (d<t1.a)}
+} {30000}
+do_test randexpr-2.2285 {
+ db eval {SELECT coalesce((select c from t1 where 19 in (select case count(*) when count(distinct c)*+cast(avg(13) AS integer) then max(t1.d) else max(case case when exists(select 1 from t1 where 13 not in (d,e,(19)) and 13 between t1.d and t1.f) then t1.a when b in (t1.a,a,17) then case when t1.a not between 13 and c then (t1.b) else t1.b end else 19 end when 13 then a else 19 end) end from t1 union select (abs(abs(~cast(avg(t1.d) AS integer))) | cast(avg(t1.a) AS integer)) from t1)),t1.e-11)*(t1.a) FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.e in (coalesce((select max(13) from t1 where 19 in (select f from t1 union select a from t1) or (not exists(select 1 from t1 where t1.a<=(19)*c*c | 13))),+e-(f)*case when t1.c not in (coalesce((select max(t1.a) from t1 where not c<(19)),19),e,(19)) then d else f end)+a,19,17)) or (d<t1.a))}
+} {}
+do_test randexpr-2.2286 {
+ db eval {SELECT coalesce((select c from t1 where 19 in (select case count(*) when count(distinct c)*+cast(avg(13) AS integer) then max(t1.d) else max(case case when exists(select 1 from t1 where 13 not in (d,e,(19)) and 13 between t1.d and t1.f) then t1.a when b in (t1.a,a,17) then case when t1.a not between 13 and c then (t1.b) else t1.b end else 19 end when 13 then a else 19 end) end from t1 union select (abs(abs(~cast(avg(t1.d) AS integer))) & cast(avg(t1.a) AS integer)) from t1)),t1.e-11)*(t1.a) FROM t1 WHERE not exists(select 1 from t1 where t1.e in (coalesce((select max(13) from t1 where 19 in (select f from t1 union select a from t1) or (not exists(select 1 from t1 where t1.a<=(19)*c*c | 13))),+e-(f)*case when t1.c not in (coalesce((select max(t1.a) from t1 where not c<(19)),19),e,(19)) then d else f end)+a,19,17)) or (d<t1.a)}
+} {30000}
+do_test randexpr-2.2287 {
+ db eval {SELECT -~a+d-case d when -(select max(d)*~min(coalesce((select max(t1.e) from t1 where (exists(select 1 from t1 where 17<>13))),t1.a)-f-a+t1.f) | case (cast(avg(t1.c) AS integer)) when cast(avg(t1.a) AS integer)-(count(*))+max(19) then - -max(19) else cast(avg(e) AS integer) end from t1)+(select cast(avg(b) AS integer) from t1) then t1.a else e-t1.d end-17+11 FROM t1 WHERE +c-(c)*d in (coalesce((select max( -t1.d-d-13) from t1 where (t1.c) not between (abs(13)/abs(t1.c)) and t1.b),d),11,c)}
+} {}
+do_test randexpr-2.2288 {
+ db eval {SELECT -~a+d-case d when -(select max(d)*~min(coalesce((select max(t1.e) from t1 where (exists(select 1 from t1 where 17<>13))),t1.a)-f-a+t1.f) | case (cast(avg(t1.c) AS integer)) when cast(avg(t1.a) AS integer)-(count(*))+max(19) then - -max(19) else cast(avg(e) AS integer) end from t1)+(select cast(avg(b) AS integer) from t1) then t1.a else e-t1.d end-17+11 FROM t1 WHERE NOT (+c-(c)*d in (coalesce((select max( -t1.d-d-13) from t1 where (t1.c) not between (abs(13)/abs(t1.c)) and t1.b),d),11,c))}
+} {395}
+do_test randexpr-2.2289 {
+ db eval {SELECT -~a+d-case d when -(select max(d)*~min(coalesce((select max(t1.e) from t1 where (exists(select 1 from t1 where 17<>13))),t1.a)-f-a+t1.f) & case (cast(avg(t1.c) AS integer)) when cast(avg(t1.a) AS integer)-(count(*))+max(19) then - -max(19) else cast(avg(e) AS integer) end from t1)+(select cast(avg(b) AS integer) from t1) then t1.a else e-t1.d end-17+11 FROM t1 WHERE NOT (+c-(c)*d in (coalesce((select max( -t1.d-d-13) from t1 where (t1.c) not between (abs(13)/abs(t1.c)) and t1.b),d),11,c))}
+} {395}
+do_test randexpr-2.2290 {
+ db eval {SELECT case when 17 in (case (abs(coalesce((select max((select cast(avg(case when 17-(t1.b)+t1.a | b+b in (select b from t1 union select 17 from t1) then c when t1.f in (select t1.a from t1 union select 19 from t1) then 11 else t1.c end) AS integer) from t1)) from t1 where t1.e>=t1.e or (b)<b or t1.a>=b and c not in (f,t1.a,t1.a)),d))/abs(t1.b)) when 17 then t1.b else 13 end-a,13,17) then t1.a else -d end FROM t1 WHERE t1.e<t1.e}
+} {}
+do_test randexpr-2.2291 {
+ db eval {SELECT case when 17 in (case (abs(coalesce((select max((select cast(avg(case when 17-(t1.b)+t1.a | b+b in (select b from t1 union select 17 from t1) then c when t1.f in (select t1.a from t1 union select 19 from t1) then 11 else t1.c end) AS integer) from t1)) from t1 where t1.e>=t1.e or (b)<b or t1.a>=b and c not in (f,t1.a,t1.a)),d))/abs(t1.b)) when 17 then t1.b else 13 end-a,13,17) then t1.a else -d end FROM t1 WHERE NOT (t1.e<t1.e)}
+} {100}
+do_test randexpr-2.2292 {
+ db eval {SELECT case when 17 in (case (abs(coalesce((select max((select cast(avg(case when 17-(t1.b)+t1.a & b+b in (select b from t1 union select 17 from t1) then c when t1.f in (select t1.a from t1 union select 19 from t1) then 11 else t1.c end) AS integer) from t1)) from t1 where t1.e>=t1.e or (b)<b or t1.a>=b and c not in (f,t1.a,t1.a)),d))/abs(t1.b)) when 17 then t1.b else 13 end-a,13,17) then t1.a else -d end FROM t1 WHERE NOT (t1.e<t1.e)}
+} {100}
+do_test randexpr-2.2293 {
+ db eval {SELECT case t1.a when coalesce((select a from t1 where t1.b>19),b-case when +13>case when (coalesce((select b from t1 where coalesce((select max(t1.f) from t1 where 17<=case c when t1.e+f then d else case when 11<17 and t1.d<=t1.e then 13 when t1.d<>f then (t1.f) else c end end*t1.c),a) in (select 17 from t1 union select b from t1)),t1.c)>= -11) then (a)*t1.a else 19 end then 13 else 17 end*19) then d else (t1.a) end FROM t1 WHERE t1.d+t1.b not in (b,f,coalesce((select max(t1.b) from t1 where exists(select 1 from t1 where c-t1.b not between case when coalesce((select max(~t1.e) from t1 where f not in (t1.b,17,t1.a)),t1.e) not in (e,13,(t1.d)) then 11 when t1.d>=17 then t1.c else 11 end and (11) and (exists(select 1 from t1 where t1.b<>11))) or 13 in (select max(t1.d) from t1 union select max(b) from t1)),t1.b+19+a))}
+} {}
+do_test randexpr-2.2294 {
+ db eval {SELECT case t1.a when coalesce((select a from t1 where t1.b>19),b-case when +13>case when (coalesce((select b from t1 where coalesce((select max(t1.f) from t1 where 17<=case c when t1.e+f then d else case when 11<17 and t1.d<=t1.e then 13 when t1.d<>f then (t1.f) else c end end*t1.c),a) in (select 17 from t1 union select b from t1)),t1.c)>= -11) then (a)*t1.a else 19 end then 13 else 17 end*19) then d else (t1.a) end FROM t1 WHERE NOT (t1.d+t1.b not in (b,f,coalesce((select max(t1.b) from t1 where exists(select 1 from t1 where c-t1.b not between case when coalesce((select max(~t1.e) from t1 where f not in (t1.b,17,t1.a)),t1.e) not in (e,13,(t1.d)) then 11 when t1.d>=17 then t1.c else 11 end and (11) and (exists(select 1 from t1 where t1.b<>11))) or 13 in (select max(t1.d) from t1 union select max(b) from t1)),t1.b+19+a)))}
+} {400}
+do_test randexpr-2.2295 {
+ db eval {SELECT coalesce((select max((coalesce((select coalesce((select max(case when case when e<case 17 when case when t1.e=f then a else t1.b end then 13 else d end then t1.b when 13<>t1.f then t1.b else c end<b or 13<17 then e* -17 else 11 end*e | e) from t1 where 19<>19),t1.f) from t1 where t1.e<>t1.d),t1.b))) from t1 where 11=t1.c), -c) FROM t1 WHERE not exists(select 1 from t1 where -~e not in (c++case when 17+t1.c<coalesce((select max(t1.c) from t1 where (not exists(select 1 from t1 where 19+coalesce((select a from t1 where d in (( -t1.a), - -b, -t1.f)),e)-a-c>=d))),f-13) then a else (t1.a) end+f*19-a,b,f)) and t1.a=b}
+} {}
+do_test randexpr-2.2296 {
+ db eval {SELECT coalesce((select max((coalesce((select coalesce((select max(case when case when e<case 17 when case when t1.e=f then a else t1.b end then 13 else d end then t1.b when 13<>t1.f then t1.b else c end<b or 13<17 then e* -17 else 11 end*e | e) from t1 where 19<>19),t1.f) from t1 where t1.e<>t1.d),t1.b))) from t1 where 11=t1.c), -c) FROM t1 WHERE NOT (not exists(select 1 from t1 where -~e not in (c++case when 17+t1.c<coalesce((select max(t1.c) from t1 where (not exists(select 1 from t1 where 19+coalesce((select a from t1 where d in (( -t1.a), - -b, -t1.f)),e)-a-c>=d))),f-13) then a else (t1.a) end+f*19-a,b,f)) and t1.a=b)}
+} {-300}
+do_test randexpr-2.2297 {
+ db eval {SELECT coalesce((select max((coalesce((select coalesce((select max(case when case when e<case 17 when case when t1.e=f then a else t1.b end then 13 else d end then t1.b when 13<>t1.f then t1.b else c end<b or 13<17 then e* -17 else 11 end*e & e) from t1 where 19<>19),t1.f) from t1 where t1.e<>t1.d),t1.b))) from t1 where 11=t1.c), -c) FROM t1 WHERE NOT (not exists(select 1 from t1 where -~e not in (c++case when 17+t1.c<coalesce((select max(t1.c) from t1 where (not exists(select 1 from t1 where 19+coalesce((select a from t1 where d in (( -t1.a), - -b, -t1.f)),e)-a-c>=d))),f-13) then a else (t1.a) end+f*19-a,b,f)) and t1.a=b)}
+} {-300}
+do_test randexpr-2.2298 {
+ db eval {SELECT t1.b-11-case when t1.d+13+t1.c | 17+case when (+a*t1.b*t1.c not in (e,t1.f,t1.e)) then coalesce((select max(e) from t1 where t1.f>=f), -d) when f>b and t1.e<t1.a or t1.f>t1.c then 17 else -13 end not in (f,t1.f,a) and exists(select 1 from t1 where a<=11) then t1.e else c end FROM t1 WHERE case f+~d*case when t1.f<=t1.b*t1.a then e*t1.e else f end*a+f when ~case when 11 not between +(abs(b)/abs(case b+d when t1.a then f else t1.e end*13))+a and (b) then t1.e when t1.e<>11 then t1.d else 17 end+11 then t1.d else t1.b end<=13}
+} {}
+do_test randexpr-2.2299 {
+ db eval {SELECT t1.b-11-case when t1.d+13+t1.c | 17+case when (+a*t1.b*t1.c not in (e,t1.f,t1.e)) then coalesce((select max(e) from t1 where t1.f>=f), -d) when f>b and t1.e<t1.a or t1.f>t1.c then 17 else -13 end not in (f,t1.f,a) and exists(select 1 from t1 where a<=11) then t1.e else c end FROM t1 WHERE NOT (case f+~d*case when t1.f<=t1.b*t1.a then e*t1.e else f end*a+f when ~case when 11 not between +(abs(b)/abs(case b+d when t1.a then f else t1.e end*13))+a and (b) then t1.e when t1.e<>11 then t1.d else 17 end+11 then t1.d else t1.b end<=13)}
+} {-111}
+do_test randexpr-2.2300 {
+ db eval {SELECT t1.b-11-case when t1.d+13+t1.c & 17+case when (+a*t1.b*t1.c not in (e,t1.f,t1.e)) then coalesce((select max(e) from t1 where t1.f>=f), -d) when f>b and t1.e<t1.a or t1.f>t1.c then 17 else -13 end not in (f,t1.f,a) and exists(select 1 from t1 where a<=11) then t1.e else c end FROM t1 WHERE NOT (case f+~d*case when t1.f<=t1.b*t1.a then e*t1.e else f end*a+f when ~case when 11 not between +(abs(b)/abs(case b+d when t1.a then f else t1.e end*13))+a and (b) then t1.e when t1.e<>11 then t1.d else 17 end+11 then t1.d else t1.b end<=13)}
+} {-111}
+do_test randexpr-2.2301 {
+ db eval {SELECT coalesce((select t1.a from t1 where d not between 11 and 13 or case 13*17 when -c then case when (coalesce((select 17 from t1 where (~case when t1.e=d then 19 when 11 in (t1.d,b,17) then t1.c else c end-11 in (select max(e) from t1 union select (case cast(avg((t1.b)) AS integer) when max(11) then min(17) else ( -count(*)) end) from t1))),(19))>d) then t1.d else 11 end else t1.c end<=a),c) FROM t1 WHERE 19 | (abs(t1.d)/abs(11))=b}
+} {}
+do_test randexpr-2.2302 {
+ db eval {SELECT coalesce((select t1.a from t1 where d not between 11 and 13 or case 13*17 when -c then case when (coalesce((select 17 from t1 where (~case when t1.e=d then 19 when 11 in (t1.d,b,17) then t1.c else c end-11 in (select max(e) from t1 union select (case cast(avg((t1.b)) AS integer) when max(11) then min(17) else ( -count(*)) end) from t1))),(19))>d) then t1.d else 11 end else t1.c end<=a),c) FROM t1 WHERE NOT (19 | (abs(t1.d)/abs(11))=b)}
+} {100}
+do_test randexpr-2.2303 {
+ db eval {SELECT coalesce((select max(17-t1.e-17) from t1 where (t1.c>d)),case when coalesce((select +f+~coalesce((select coalesce((select case when (select cast(avg(17) AS integer) | cast(avg(t1.e) AS integer) from t1)<>coalesce((select t1.e from t1 where 19 in (select count(*) from t1 union select -( -count(*)) from t1)), -d) then b when exists(select 1 from t1 where t1.b between (t1.b) and 13) then a else -b end from t1 where 19=e),t1.c) from t1 where t1.c<=b),t1.d) from t1 where 17 between t1.a and b),t1.e) between c and t1.e then -t1.d else 13 end) FROM t1 WHERE exists(select 1 from t1 where t1.e-13-17-f*f*t1.d*coalesce((select 19-case when not not t1.d>e then case when t1.f<t1.a then case when e<=t1.c then t1.e when (c)>=t1.c then 19 else f end else -t1.b end when e in (f,t1.e,17) then t1.a else t1.b end*t1.d from t1 where ((f)) in (select (~case count(distinct 11) when count(distinct t1.d) | count(distinct t1.b)-max( -f) then max(e) else (count(distinct (((a))))) end) from t1 union select max(e) from t1)),f)+c>=t1.f)}
+} {}
+do_test randexpr-2.2304 {
+ db eval {SELECT coalesce((select max(17-t1.e-17) from t1 where (t1.c>d)),case when coalesce((select +f+~coalesce((select coalesce((select case when (select cast(avg(17) AS integer) | cast(avg(t1.e) AS integer) from t1)<>coalesce((select t1.e from t1 where 19 in (select count(*) from t1 union select -( -count(*)) from t1)), -d) then b when exists(select 1 from t1 where t1.b between (t1.b) and 13) then a else -b end from t1 where 19=e),t1.c) from t1 where t1.c<=b),t1.d) from t1 where 17 between t1.a and b),t1.e) between c and t1.e then -t1.d else 13 end) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.e-13-17-f*f*t1.d*coalesce((select 19-case when not not t1.d>e then case when t1.f<t1.a then case when e<=t1.c then t1.e when (c)>=t1.c then 19 else f end else -t1.b end when e in (f,t1.e,17) then t1.a else t1.b end*t1.d from t1 where ((f)) in (select (~case count(distinct 11) when count(distinct t1.d) | count(distinct t1.b)-max( -f) then max(e) else (count(distinct (((a))))) end) from t1 union select max(e) from t1)),f)+c>=t1.f))}
+} {-400}
+do_test randexpr-2.2305 {
+ db eval {SELECT coalesce((select max(17-t1.e-17) from t1 where (t1.c>d)),case when coalesce((select +f+~coalesce((select coalesce((select case when (select cast(avg(17) AS integer) & cast(avg(t1.e) AS integer) from t1)<>coalesce((select t1.e from t1 where 19 in (select count(*) from t1 union select -( -count(*)) from t1)), -d) then b when exists(select 1 from t1 where t1.b between (t1.b) and 13) then a else -b end from t1 where 19=e),t1.c) from t1 where t1.c<=b),t1.d) from t1 where 17 between t1.a and b),t1.e) between c and t1.e then -t1.d else 13 end) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.e-13-17-f*f*t1.d*coalesce((select 19-case when not not t1.d>e then case when t1.f<t1.a then case when e<=t1.c then t1.e when (c)>=t1.c then 19 else f end else -t1.b end when e in (f,t1.e,17) then t1.a else t1.b end*t1.d from t1 where ((f)) in (select (~case count(distinct 11) when count(distinct t1.d) | count(distinct t1.b)-max( -f) then max(e) else (count(distinct (((a))))) end) from t1 union select max(e) from t1)),f)+c>=t1.f))}
+} {-400}
+do_test randexpr-2.2306 {
+ db eval {SELECT coalesce((select t1.b from t1 where exists(select 1 from t1 where (abs(~case (~13*case when c in (select (max(case when b<>11 then d when 13 not in (19,c,e) then t1.f else 19 end*t1.d)) from t1 union select abs(count(*)) | min(19) from t1) then t1.a else t1.c end-a-13-f*e*17) when f then t1.a else 13 end*t1.c)/abs(a))>t1.b)),13) FROM t1 WHERE ++case when a<=t1.a then 17 else 13 end>+f+(coalesce((select max(19) from t1 where 11 not in (case when t1.e<(abs(11)/abs(19*d*t1.c)) and (c in (select t1.c from t1 union select f from t1) or a>a) then t1.a when 11 not between t1.c and t1.a or t1.e not in ( -t1.a,17,f) then t1.d else e end+t1.f,19,(17))),17))* -11}
+} {}
+do_test randexpr-2.2307 {
+ db eval {SELECT coalesce((select t1.b from t1 where exists(select 1 from t1 where (abs(~case (~13*case when c in (select (max(case when b<>11 then d when 13 not in (19,c,e) then t1.f else 19 end*t1.d)) from t1 union select abs(count(*)) | min(19) from t1) then t1.a else t1.c end-a-13-f*e*17) when f then t1.a else 13 end*t1.c)/abs(a))>t1.b)),13) FROM t1 WHERE NOT (++case when a<=t1.a then 17 else 13 end>+f+(coalesce((select max(19) from t1 where 11 not in (case when t1.e<(abs(11)/abs(19*d*t1.c)) and (c in (select t1.c from t1 union select f from t1) or a>a) then t1.a when 11 not between t1.c and t1.a or t1.e not in ( -t1.a,17,f) then t1.d else e end+t1.f,19,(17))),17))* -11)}
+} {13}
+do_test randexpr-2.2308 {
+ db eval {SELECT coalesce((select t1.b from t1 where exists(select 1 from t1 where (abs(~case (~13*case when c in (select (max(case when b<>11 then d when 13 not in (19,c,e) then t1.f else 19 end*t1.d)) from t1 union select abs(count(*)) & min(19) from t1) then t1.a else t1.c end-a-13-f*e*17) when f then t1.a else 13 end*t1.c)/abs(a))>t1.b)),13) FROM t1 WHERE NOT (++case when a<=t1.a then 17 else 13 end>+f+(coalesce((select max(19) from t1 where 11 not in (case when t1.e<(abs(11)/abs(19*d*t1.c)) and (c in (select t1.c from t1 union select f from t1) or a>a) then t1.a when 11 not between t1.c and t1.a or t1.e not in ( -t1.a,17,f) then t1.d else e end+t1.f,19,(17))),17))* -11)}
+} {13}
+do_test randexpr-2.2309 {
+ db eval {SELECT case when c*(abs(t1.f)/abs(c))*b-11-t1.a<coalesce((select max(case when coalesce((select max(c*+(t1.e)) from t1 where t1.c+ - -t1.f*t1.b in (select a from t1 union select d from t1)),t1.e)<>t1.d then -d else t1.f end*e) from t1 where (b)<>t1.a or 11 between ( -a) and a),t1.b) then t1.d when e=t1.e then t1.c else t1.e end FROM t1 WHERE (coalesce((select (t1.b)+f*case case +coalesce((select 13 from t1 where t1.e<=d),f)-a when d then t1.b else t1.c end+t1.e when a then 17 else t1.e end from t1 where not t1.d in (select b from t1 union select 19 from t1) or not (17<t1.a) or t1.c in (select count(*) from t1 union select max(t1.c) from t1)),t1.e) in (b,t1.b,t1.f) or not exists(select 1 from t1 where not t1.d between 11 and -t1.f))}
+} {}
+do_test randexpr-2.2310 {
+ db eval {SELECT case when c*(abs(t1.f)/abs(c))*b-11-t1.a<coalesce((select max(case when coalesce((select max(c*+(t1.e)) from t1 where t1.c+ - -t1.f*t1.b in (select a from t1 union select d from t1)),t1.e)<>t1.d then -d else t1.f end*e) from t1 where (b)<>t1.a or 11 between ( -a) and a),t1.b) then t1.d when e=t1.e then t1.c else t1.e end FROM t1 WHERE NOT ((coalesce((select (t1.b)+f*case case +coalesce((select 13 from t1 where t1.e<=d),f)-a when d then t1.b else t1.c end+t1.e when a then 17 else t1.e end from t1 where not t1.d in (select b from t1 union select 19 from t1) or not (17<t1.a) or t1.c in (select count(*) from t1 union select max(t1.c) from t1)),t1.e) in (b,t1.b,t1.f) or not exists(select 1 from t1 where not t1.d between 11 and -t1.f)))}
+} {300}
+do_test randexpr-2.2311 {
+ db eval {SELECT (17)+coalesce((select (case when (case (case t1.d when t1.d then 11 else 13 end) when e then e else 13 end*11)*t1.c not between a and 11 then (17) else c end)+t1.a from t1 where 17 in (select max(t1.d)*count(distinct 17) from t1 union select -cast(avg(t1.d) AS integer)*case case +min(t1.c) when min(e) then cast(avg(b) AS integer) else max(t1.d) end when (max(c)) then cast(avg(t1.b) AS integer) else count(distinct 17) end from t1)),b)-a FROM t1 WHERE ((abs(t1.c)/abs(a)) between 11 | 11 and -b)}
+} {}
+do_test randexpr-2.2312 {
+ db eval {SELECT (17)+coalesce((select (case when (case (case t1.d when t1.d then 11 else 13 end) when e then e else 13 end*11)*t1.c not between a and 11 then (17) else c end)+t1.a from t1 where 17 in (select max(t1.d)*count(distinct 17) from t1 union select -cast(avg(t1.d) AS integer)*case case +min(t1.c) when min(e) then cast(avg(b) AS integer) else max(t1.d) end when (max(c)) then cast(avg(t1.b) AS integer) else count(distinct 17) end from t1)),b)-a FROM t1 WHERE NOT (((abs(t1.c)/abs(a)) between 11 | 11 and -b))}
+} {117}
+do_test randexpr-2.2313 {
+ db eval {SELECT case when case when -f-case when t1.a between 13 and (e) then t1.d | a else 13 end<t1.d and -(13) in (select cast(avg(13) AS integer) from t1 union select +count(distinct c)-cast(avg(t1.c) AS integer) from t1) or not exists(select 1 from t1 where (not exists(select 1 from t1 where t1.e<>a) or ( -d) between c and c or (19) between t1.f and t1.b) or (b) not in (t1.d,t1.c,e)) then t1.b*t1.b when a>19 then t1.d else 11 end>=11 then t1.e else -e end FROM t1 WHERE not exists(select 1 from t1 where ((11<=+11)))}
+} {}
+do_test randexpr-2.2314 {
+ db eval {SELECT case when case when -f-case when t1.a between 13 and (e) then t1.d | a else 13 end<t1.d and -(13) in (select cast(avg(13) AS integer) from t1 union select +count(distinct c)-cast(avg(t1.c) AS integer) from t1) or not exists(select 1 from t1 where (not exists(select 1 from t1 where t1.e<>a) or ( -d) between c and c or (19) between t1.f and t1.b) or (b) not in (t1.d,t1.c,e)) then t1.b*t1.b when a>19 then t1.d else 11 end>=11 then t1.e else -e end FROM t1 WHERE NOT (not exists(select 1 from t1 where ((11<=+11))))}
+} {500}
+do_test randexpr-2.2315 {
+ db eval {SELECT case when case when -f-case when t1.a between 13 and (e) then t1.d & a else 13 end<t1.d and -(13) in (select cast(avg(13) AS integer) from t1 union select +count(distinct c)-cast(avg(t1.c) AS integer) from t1) or not exists(select 1 from t1 where (not exists(select 1 from t1 where t1.e<>a) or ( -d) between c and c or (19) between t1.f and t1.b) or (b) not in (t1.d,t1.c,e)) then t1.b*t1.b when a>19 then t1.d else 11 end>=11 then t1.e else -e end FROM t1 WHERE NOT (not exists(select 1 from t1 where ((11<=+11))))}
+} {500}
+do_test randexpr-2.2316 {
+ db eval {SELECT (abs(+case when 11*t1.d not between 13 and t1.d then coalesce((select 17 from t1 where case ~e when (abs(+(b+(select ~ -cast(avg(t1.c) AS integer) from t1)))/abs(case 17 when 17 then c else a end)) then t1.d else t1.d end<>t1.a),f) when not exists(select 1 from t1 where (19<=(f))) and 17=t1.b or 19 not between a and a then t1.d else d end)/abs(b)) FROM t1 WHERE t1.d-13 in (t1.a,d,(t1.b))}
+} {}
+do_test randexpr-2.2317 {
+ db eval {SELECT (abs(+case when 11*t1.d not between 13 and t1.d then coalesce((select 17 from t1 where case ~e when (abs(+(b+(select ~ -cast(avg(t1.c) AS integer) from t1)))/abs(case 17 when 17 then c else a end)) then t1.d else t1.d end<>t1.a),f) when not exists(select 1 from t1 where (19<=(f))) and 17=t1.b or 19 not between a and a then t1.d else d end)/abs(b)) FROM t1 WHERE NOT (t1.d-13 in (t1.a,d,(t1.b)))}
+} {0}
+do_test randexpr-2.2318 {
+ db eval {SELECT b+(select case ~min(t1.a+13) when (cast(avg(t1.a) AS integer)) then max(d) else max(case when case t1.b when t1.e then t1.c else t1.f end+19<>+(select count(*) from t1) then case when b in (t1.e,t1.d,t1.e) and t1.c not between t1.f and 13 then (t1.c) when 17>t1.b then 19 else t1.b end-t1.d when d in (e,f,t1.f) and (a)<t1.c then 13 else -t1.e end) end from t1)* -11-t1.f FROM t1 WHERE t1.a between (abs(e)/abs(a)) and t1.f-case when not (19)<>+t1.e then e+case when (exists(select 1 from t1 where d<17) and d<(abs(t1.e)/abs(+ - -t1.f+d))) then coalesce((select max((t1.f)) from t1 where not 19=t1.e),t1.e)+t1.e else t1.d end when not exists(select 1 from t1 where t1.d not in (19,11,t1.c)) then (t1.f) else d end}
+} {1800}
+do_test randexpr-2.2319 {
+ db eval {SELECT b+(select case ~min(t1.a+13) when (cast(avg(t1.a) AS integer)) then max(d) else max(case when case t1.b when t1.e then t1.c else t1.f end+19<>+(select count(*) from t1) then case when b in (t1.e,t1.d,t1.e) and t1.c not between t1.f and 13 then (t1.c) when 17>t1.b then 19 else t1.b end-t1.d when d in (e,f,t1.f) and (a)<t1.c then 13 else -t1.e end) end from t1)* -11-t1.f FROM t1 WHERE NOT (t1.a between (abs(e)/abs(a)) and t1.f-case when not (19)<>+t1.e then e+case when (exists(select 1 from t1 where d<17) and d<(abs(t1.e)/abs(+ - -t1.f+d))) then coalesce((select max((t1.f)) from t1 where not 19=t1.e),t1.e)+t1.e else t1.d end when not exists(select 1 from t1 where t1.d not in (19,11,t1.c)) then (t1.f) else d end)}
+} {}
+do_test randexpr-2.2320 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where t1.b+b in (select (t1.c)*11*e+f+ -c-t1.b*coalesce((select max(a) from t1 where t1.a*17 between 19 and (((abs(f)/abs(t1.c+d))))),t1.c-(abs(t1.c)/abs(19)) | case when t1.d= -t1.f then b when (t1.c) not in (e, -11,19) then 19 else t1.a end-c)*t1.a-c from t1 union select t1.d from t1)),a) FROM t1 WHERE (select abs(+min(b)) from t1)<=d+t1.a}
+} {400}
+do_test randexpr-2.2321 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where t1.b+b in (select (t1.c)*11*e+f+ -c-t1.b*coalesce((select max(a) from t1 where t1.a*17 between 19 and (((abs(f)/abs(t1.c+d))))),t1.c-(abs(t1.c)/abs(19)) | case when t1.d= -t1.f then b when (t1.c) not in (e, -11,19) then 19 else t1.a end-c)*t1.a-c from t1 union select t1.d from t1)),a) FROM t1 WHERE NOT ((select abs(+min(b)) from t1)<=d+t1.a)}
+} {}
+do_test randexpr-2.2322 {
+ db eval {SELECT coalesce((select max(t1.d) from t1 where t1.b+b in (select (t1.c)*11*e+f+ -c-t1.b*coalesce((select max(a) from t1 where t1.a*17 between 19 and (((abs(f)/abs(t1.c+d))))),t1.c-(abs(t1.c)/abs(19)) & case when t1.d= -t1.f then b when (t1.c) not in (e, -11,19) then 19 else t1.a end-c)*t1.a-c from t1 union select t1.d from t1)),a) FROM t1 WHERE (select abs(+min(b)) from t1)<=d+t1.a}
+} {400}
+do_test randexpr-2.2323 {
+ db eval {SELECT case when coalesce((select c from t1 where (~13<>d)),t1.d-+d+13*coalesce((select max(17) from t1 where -f<case when (abs(a+coalesce((select max(19) from t1 where not t1.d<>d),e))/abs(13))*f not in (t1.e,t1.c,e) then 19 when 17 not between t1.f and 17 then t1.f else t1.e end),f)+t1.c) | d<>11 then a else 19 end FROM t1 WHERE 13=b}
+} {}
+do_test randexpr-2.2324 {
+ db eval {SELECT case when coalesce((select c from t1 where (~13<>d)),t1.d-+d+13*coalesce((select max(17) from t1 where -f<case when (abs(a+coalesce((select max(19) from t1 where not t1.d<>d),e))/abs(13))*f not in (t1.e,t1.c,e) then 19 when 17 not between t1.f and 17 then t1.f else t1.e end),f)+t1.c) | d<>11 then a else 19 end FROM t1 WHERE NOT (13=b)}
+} {100}
+do_test randexpr-2.2325 {
+ db eval {SELECT case when coalesce((select c from t1 where (~13<>d)),t1.d-+d+13*coalesce((select max(17) from t1 where -f<case when (abs(a+coalesce((select max(19) from t1 where not t1.d<>d),e))/abs(13))*f not in (t1.e,t1.c,e) then 19 when 17 not between t1.f and 17 then t1.f else t1.e end),f)+t1.c) & d<>11 then a else 19 end FROM t1 WHERE NOT (13=b)}
+} {100}
+do_test randexpr-2.2326 {
+ db eval {SELECT case case t1.e+13 when case when not -f>coalesce((select max(t1.b) from t1 where (select min(a) from t1)<a),a) then case when not exists(select 1 from t1 where d>t1.d and t1.c<19 and d between b and ( -c)) then (select case ~max( -( - -t1.f)) when min(e) then -count(*) else count(*) end-cast(avg(b) AS integer) from t1) when 17<>11 then f else case -17 when t1.d then b else -t1.f end end+t1.e when t1.d>=11 then 17 else 11 end then t1.d else t1.d end when t1.c then t1.a else 11 end FROM t1 WHERE (coalesce((select coalesce((select max(coalesce((select max( -(select + -case ++case (count(*)) when cast(avg(11) AS integer) then count(*) else -min(13) end when max(19) then -cast(avg(11) AS integer) else count(distinct (b)) end | max(t1.a)+max(b) from t1)) from t1 where 11 in (select b from t1 union select 13 from t1)),case (select count(*) from t1) when 19 then case when d not between -d and b then t1.f else t1.b end else t1.c end)+d-t1.e) from t1 where t1.f not between t1.c and 19),t1.b) from t1 where t1.c between d and -t1.b),t1.b))>=c}
+} {}
+do_test randexpr-2.2327 {
+ db eval {SELECT case case t1.e+13 when case when not -f>coalesce((select max(t1.b) from t1 where (select min(a) from t1)<a),a) then case when not exists(select 1 from t1 where d>t1.d and t1.c<19 and d between b and ( -c)) then (select case ~max( -( - -t1.f)) when min(e) then -count(*) else count(*) end-cast(avg(b) AS integer) from t1) when 17<>11 then f else case -17 when t1.d then b else -t1.f end end+t1.e when t1.d>=11 then 17 else 11 end then t1.d else t1.d end when t1.c then t1.a else 11 end FROM t1 WHERE NOT ((coalesce((select coalesce((select max(coalesce((select max( -(select + -case ++case (count(*)) when cast(avg(11) AS integer) then count(*) else -min(13) end when max(19) then -cast(avg(11) AS integer) else count(distinct (b)) end | max(t1.a)+max(b) from t1)) from t1 where 11 in (select b from t1 union select 13 from t1)),case (select count(*) from t1) when 19 then case when d not between -d and b then t1.f else t1.b end else t1.c end)+d-t1.e) from t1 where t1.f not between t1.c and 19),t1.b) from t1 where t1.c between d and -t1.b),t1.b))>=c)}
+} {11}
+do_test randexpr-2.2328 {
+ db eval {SELECT case when +case when coalesce((select t1.b from t1 where not exists(select 1 from t1 where f<=coalesce((select c from t1 where t1.a in (select ~f from t1 union select coalesce((select max(case -(13) when 13 then t1.f else a end | 13) from t1 where c<= -c or b not between f and t1.d and t1.b not in (e,t1.a,17)),a)+d from t1)),13) or t1.a>c)),11*19) between e and 17 then c else -(c) end>=t1.c then t1.d else c end FROM t1 WHERE t1.d<17-t1.a | a-+11}
+} {}
+do_test randexpr-2.2329 {
+ db eval {SELECT case when +case when coalesce((select t1.b from t1 where not exists(select 1 from t1 where f<=coalesce((select c from t1 where t1.a in (select ~f from t1 union select coalesce((select max(case -(13) when 13 then t1.f else a end | 13) from t1 where c<= -c or b not between f and t1.d and t1.b not in (e,t1.a,17)),a)+d from t1)),13) or t1.a>c)),11*19) between e and 17 then c else -(c) end>=t1.c then t1.d else c end FROM t1 WHERE NOT (t1.d<17-t1.a | a-+11)}
+} {300}
+do_test randexpr-2.2330 {
+ db eval {SELECT case when +case when coalesce((select t1.b from t1 where not exists(select 1 from t1 where f<=coalesce((select c from t1 where t1.a in (select ~f from t1 union select coalesce((select max(case -(13) when 13 then t1.f else a end & 13) from t1 where c<= -c or b not between f and t1.d and t1.b not in (e,t1.a,17)),a)+d from t1)),13) or t1.a>c)),11*19) between e and 17 then c else -(c) end>=t1.c then t1.d else c end FROM t1 WHERE NOT (t1.d<17-t1.a | a-+11)}
+} {300}
+do_test randexpr-2.2331 {
+ db eval {SELECT t1.c+c- -d*t1.d+t1.e | case when t1.e<=e and (a*t1.c) in (select ((abs(f)/abs(( -+(select abs(~(min( -c))-max( - -b)-count(*)) from t1))))) from t1 union select b from t1) then +a*t1.c-t1.d*t1.c else e end-t1.d+t1.f FROM t1 WHERE (exists(select 1 from t1 where coalesce((select max(++11+coalesce((select max(17) from t1 where case case when exists(select 1 from t1 where c not between t1.e and 17) then 19 else f end when -t1.f then t1.f else t1.a end<=t1.e or 11 in (b,a,e) and e between 11 and 11), -(a)-19)*t1.f) from t1 where t1.b between d and 17 and 17=e),19) not in (a,b,b))) and (e>=d) or b not in (c,13,19)}
+} {161788}
+do_test randexpr-2.2332 {
+ db eval {SELECT t1.c+c- -d*t1.d+t1.e | case when t1.e<=e and (a*t1.c) in (select ((abs(f)/abs(( -+(select abs(~(min( -c))-max( - -b)-count(*)) from t1))))) from t1 union select b from t1) then +a*t1.c-t1.d*t1.c else e end-t1.d+t1.f FROM t1 WHERE NOT ((exists(select 1 from t1 where coalesce((select max(++11+coalesce((select max(17) from t1 where case case when exists(select 1 from t1 where c not between t1.e and 17) then 19 else f end when -t1.f then t1.f else t1.a end<=t1.e or 11 in (b,a,e) and e between 11 and 11), -(a)-19)*t1.f) from t1 where t1.b between d and 17 and 17=e),19) not in (a,b,b))) and (e>=d) or b not in (c,13,19))}
+} {}
+do_test randexpr-2.2333 {
+ db eval {SELECT t1.c+c- -d*t1.d+t1.e & case when t1.e<=e and (a*t1.c) in (select ((abs(f)/abs(( -+(select abs(~(min( -c))-max( - -b)-count(*)) from t1))))) from t1 union select b from t1) then +a*t1.c-t1.d*t1.c else e end-t1.d+t1.f FROM t1 WHERE (exists(select 1 from t1 where coalesce((select max(++11+coalesce((select max(17) from t1 where case case when exists(select 1 from t1 where c not between t1.e and 17) then 19 else f end when -t1.f then t1.f else t1.a end<=t1.e or 11 in (b,a,e) and e between 11 and 11), -(a)-19)*t1.f) from t1 where t1.b between d and 17 and 17=e),19) not in (a,b,b))) and (e>=d) or b not in (c,13,19)}
+} {12}
+do_test randexpr-2.2334 {
+ db eval {SELECT b-case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.a not between 17 and a+t1.f) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b+f+a in (select max(19) | -max(t1.e)-cast(avg(t1.c) AS integer)- -count(distinct t1.b) from t1 union select max(t1.b) from t1)) or not exists(select 1 from t1 where not exists(select 1 from t1 where 11>c or (13) in ( -11,c,19)) or 11>f))) and t1.c not in ( -(d),t1.a,t1.a) and 17 in (t1.b,13,19)) then coalesce((select max(+19) from t1 where 17<b),13) else (abs(11)/abs(t1.e)) end FROM t1 WHERE not exists(select 1 from t1 where (13 between f and (e) or (f-d in (select t1.c*t1.d | f-19 from t1 union select 19*t1.d*coalesce((select coalesce((select max(t1.d-c*11) from t1 where 17= -t1.a),t1.a)-c from t1 where exists(select 1 from t1 where 17>e)),b) from t1))) or ((t1.d<f)))}
+} {}
+do_test randexpr-2.2335 {
+ db eval {SELECT b-case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.a not between 17 and a+t1.f) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b+f+a in (select max(19) | -max(t1.e)-cast(avg(t1.c) AS integer)- -count(distinct t1.b) from t1 union select max(t1.b) from t1)) or not exists(select 1 from t1 where not exists(select 1 from t1 where 11>c or (13) in ( -11,c,19)) or 11>f))) and t1.c not in ( -(d),t1.a,t1.a) and 17 in (t1.b,13,19)) then coalesce((select max(+19) from t1 where 17<b),13) else (abs(11)/abs(t1.e)) end FROM t1 WHERE NOT (not exists(select 1 from t1 where (13 between f and (e) or (f-d in (select t1.c*t1.d | f-19 from t1 union select 19*t1.d*coalesce((select coalesce((select max(t1.d-c*11) from t1 where 17= -t1.a),t1.a)-c from t1 where exists(select 1 from t1 where 17>e)),b) from t1))) or ((t1.d<f))))}
+} {200}
+do_test randexpr-2.2336 {
+ db eval {SELECT b-case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.a not between 17 and a+t1.f) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b+f+a in (select max(19) & -max(t1.e)-cast(avg(t1.c) AS integer)- -count(distinct t1.b) from t1 union select max(t1.b) from t1)) or not exists(select 1 from t1 where not exists(select 1 from t1 where 11>c or (13) in ( -11,c,19)) or 11>f))) and t1.c not in ( -(d),t1.a,t1.a) and 17 in (t1.b,13,19)) then coalesce((select max(+19) from t1 where 17<b),13) else (abs(11)/abs(t1.e)) end FROM t1 WHERE NOT (not exists(select 1 from t1 where (13 between f and (e) or (f-d in (select t1.c*t1.d | f-19 from t1 union select 19*t1.d*coalesce((select coalesce((select max(t1.d-c*11) from t1 where 17= -t1.a),t1.a)-c from t1 where exists(select 1 from t1 where 17>e)),b) from t1))) or ((t1.d<f))))}
+} {200}
+do_test randexpr-2.2337 {
+ db eval {SELECT coalesce((select t1.f*t1.b+case t1.a when 17 then -t1.c else coalesce((select b from t1 where 19 in (f,d+b,coalesce((select t1.e-b from t1 where t1.b*d+case t1.c when case coalesce((select t1.b from t1 where c not in (b,a,13)),(13)) when t1.b then 19 else 19 end then t1.d else 19 end+ -b>= -t1.f),t1.c))),b) end from t1 where not a=11),t1.c) FROM t1 WHERE not 13<>11+17-case when 17 between (abs(case f when 19 | t1.a then +(select cast(avg(case when not exists(select 1 from t1 where ~ -13*(select -cast(avg(t1.b*d) AS integer) from t1)+17<>(t1.b)) then ~t1.c when b>t1.d then c else (f) end) AS integer) from t1) else a end)/abs(19)) and t1.f then t1.b when a<>t1.c then t1.e else b end}
+} {}
+do_test randexpr-2.2338 {
+ db eval {SELECT coalesce((select t1.f*t1.b+case t1.a when 17 then -t1.c else coalesce((select b from t1 where 19 in (f,d+b,coalesce((select t1.e-b from t1 where t1.b*d+case t1.c when case coalesce((select t1.b from t1 where c not in (b,a,13)),(13)) when t1.b then 19 else 19 end then t1.d else 19 end+ -b>= -t1.f),t1.c))),b) end from t1 where not a=11),t1.c) FROM t1 WHERE NOT (not 13<>11+17-case when 17 between (abs(case f when 19 | t1.a then +(select cast(avg(case when not exists(select 1 from t1 where ~ -13*(select -cast(avg(t1.b*d) AS integer) from t1)+17<>(t1.b)) then ~t1.c when b>t1.d then c else (f) end) AS integer) from t1) else a end)/abs(19)) and t1.f then t1.b when a<>t1.c then t1.e else b end)}
+} {120200}
+do_test randexpr-2.2339 {
+ db eval {SELECT coalesce((select max(19) from t1 where t1.f*17+case t1.f when 11 then coalesce((select max(t1.a) from t1 where 13<>t1.d),(abs(13+b-case when not c+(abs(case when t1.c not between a and t1.f then -(e) else t1.d end)/abs( -17))<a then 11 else t1.c end)/abs(17)))*d*t1.a else c end-((f))-e*t1.a<17),t1.f)+t1.a FROM t1 WHERE e>=13}
+} {119}
+do_test randexpr-2.2340 {
+ db eval {SELECT coalesce((select max(19) from t1 where t1.f*17+case t1.f when 11 then coalesce((select max(t1.a) from t1 where 13<>t1.d),(abs(13+b-case when not c+(abs(case when t1.c not between a and t1.f then -(e) else t1.d end)/abs( -17))<a then 11 else t1.c end)/abs(17)))*d*t1.a else c end-((f))-e*t1.a<17),t1.f)+t1.a FROM t1 WHERE NOT (e>=13)}
+} {}
+do_test randexpr-2.2341 {
+ db eval {SELECT +coalesce((select max(e) from t1 where -(case 13*(t1.b* -case when e<=19 then b when t1.e=c then (b) else f end*t1.e) when e then 13 else t1.f end)=t1.b and t1.a in (select count(*) | case case min(b)*(count(*)) when abs(cast(avg(13) AS integer))-max(t1.d) then min(19) else -cast(avg(b) AS integer) end when count(*) then (max(c)) else count(distinct 19) end+cast(avg((b)) AS integer) from t1 union select count(*) from t1)),t1.a) FROM t1 WHERE (select (min(13-(abs(c)/abs(case when coalesce((select case when coalesce((select -a from t1 where case a*f when t1.a then -c else (f) end between t1.a and t1.c),b) not between t1.e and b then 19 when 17 not in (19,d,11) then b else a end from t1 where b in (select t1.e from t1 union select t1.b from t1)),t1.a) not in (t1.e,t1.a,t1.f) then (d) else 19 end)))) from t1) in (select +13 from t1 union select 17 from t1)}
+} {100}
+do_test randexpr-2.2342 {
+ db eval {SELECT +coalesce((select max(e) from t1 where -(case 13*(t1.b* -case when e<=19 then b when t1.e=c then (b) else f end*t1.e) when e then 13 else t1.f end)=t1.b and t1.a in (select count(*) | case case min(b)*(count(*)) when abs(cast(avg(13) AS integer))-max(t1.d) then min(19) else -cast(avg(b) AS integer) end when count(*) then (max(c)) else count(distinct 19) end+cast(avg((b)) AS integer) from t1 union select count(*) from t1)),t1.a) FROM t1 WHERE NOT ((select (min(13-(abs(c)/abs(case when coalesce((select case when coalesce((select -a from t1 where case a*f when t1.a then -c else (f) end between t1.a and t1.c),b) not between t1.e and b then 19 when 17 not in (19,d,11) then b else a end from t1 where b in (select t1.e from t1 union select t1.b from t1)),t1.a) not in (t1.e,t1.a,t1.f) then (d) else 19 end)))) from t1) in (select +13 from t1 union select 17 from t1))}
+} {}
+do_test randexpr-2.2343 {
+ db eval {SELECT +coalesce((select max(e) from t1 where -(case 13*(t1.b* -case when e<=19 then b when t1.e=c then (b) else f end*t1.e) when e then 13 else t1.f end)=t1.b and t1.a in (select count(*) & case case min(b)*(count(*)) when abs(cast(avg(13) AS integer))-max(t1.d) then min(19) else -cast(avg(b) AS integer) end when count(*) then (max(c)) else count(distinct 19) end+cast(avg((b)) AS integer) from t1 union select count(*) from t1)),t1.a) FROM t1 WHERE (select (min(13-(abs(c)/abs(case when coalesce((select case when coalesce((select -a from t1 where case a*f when t1.a then -c else (f) end between t1.a and t1.c),b) not between t1.e and b then 19 when 17 not in (19,d,11) then b else a end from t1 where b in (select t1.e from t1 union select t1.b from t1)),t1.a) not in (t1.e,t1.a,t1.f) then (d) else 19 end)))) from t1) in (select +13 from t1 union select 17 from t1)}
+} {100}
+do_test randexpr-2.2344 {
+ db eval {SELECT case when b in (select 19 from t1 union select c from t1) then -d else 19-13+coalesce((select t1.c from t1 where t1.d>=case when e in (select f*t1.b from t1 union select t1.d from t1) then t1.c when not exists(select 1 from t1 where t1.f not in (17,t1.c,11) and b between b and 17 or c in (t1.b,17,a) or t1.d>t1.d and t1.c<>11 and 13=e and t1.f not in ( -t1.c,19,f)) then coalesce((select max(case when t1.c in (t1.e,d,b) then t1.f else t1.a end) from t1 where e<=t1.f),11) else t1.b end*11),t1.e) end FROM t1 WHERE 13 not between +19 and a}
+} {506}
+do_test randexpr-2.2345 {
+ db eval {SELECT case when b in (select 19 from t1 union select c from t1) then -d else 19-13+coalesce((select t1.c from t1 where t1.d>=case when e in (select f*t1.b from t1 union select t1.d from t1) then t1.c when not exists(select 1 from t1 where t1.f not in (17,t1.c,11) and b between b and 17 or c in (t1.b,17,a) or t1.d>t1.d and t1.c<>11 and 13=e and t1.f not in ( -t1.c,19,f)) then coalesce((select max(case when t1.c in (t1.e,d,b) then t1.f else t1.a end) from t1 where e<=t1.f),11) else t1.b end*11),t1.e) end FROM t1 WHERE NOT (13 not between +19 and a)}
+} {}
+do_test randexpr-2.2346 {
+ db eval {SELECT (abs(13)/abs(case when t1.f not between a and f then 19-t1.d-t1.d*d | c+(select case count(*) | (~ -count(*)) when cast(avg( -19) AS integer) then min(d) else (cast(avg(e) AS integer)) end from t1) | t1.f-t1.b when f<>case when f<>b and 19 in (d,( -t1.a),t1.c) then 11 when e not between b and (t1.d) then t1.e else t1.d end-t1.e or t1.b not in (f,c,(a)) then -d else t1.f end-t1.f)) FROM t1 WHERE (select -count(*) from t1)=d+11}
+} {}
+do_test randexpr-2.2347 {
+ db eval {SELECT (abs(13)/abs(case when t1.f not between a and f then 19-t1.d-t1.d*d | c+(select case count(*) | (~ -count(*)) when cast(avg( -19) AS integer) then min(d) else (cast(avg(e) AS integer)) end from t1) | t1.f-t1.b when f<>case when f<>b and 19 in (d,( -t1.a),t1.c) then 11 when e not between b and (t1.d) then t1.e else t1.d end-t1.e or t1.b not in (f,c,(a)) then -d else t1.f end-t1.f)) FROM t1 WHERE NOT ((select -count(*) from t1)=d+11)}
+} {0}
+do_test randexpr-2.2348 {
+ db eval {SELECT (abs(13)/abs(case when t1.f not between a and f then 19-t1.d-t1.d*d & c+(select case count(*) & (~ -count(*)) when cast(avg( -19) AS integer) then min(d) else (cast(avg(e) AS integer)) end from t1) & t1.f-t1.b when f<>case when f<>b and 19 in (d,( -t1.a),t1.c) then 11 when e not between b and (t1.d) then t1.e else t1.d end-t1.e or t1.b not in (f,c,(a)) then -d else t1.f end-t1.f)) FROM t1 WHERE NOT ((select -count(*) from t1)=d+11)}
+} {0}
+do_test randexpr-2.2349 {
+ db eval {SELECT ((select count(distinct 11+19 | case (d) when t1.b then coalesce((select case coalesce((select max(+c*t1.f) from t1 where (t1.e=f and 13<=t1.d)), -17)+11-t1.a when (t1.c) then 19 else 13 end from t1 where t1.c in (select ~+ -count(distinct t1.f) from t1 union select count(*)+count(distinct b)*min(11) from t1)),e) else 19 end+d) | count(*) from t1)) FROM t1 WHERE case b when 19 then ~b-~e-d+d+t1.c else a end in (select max(t1.b)-~count(*)+abs(abs((case min((abs(~t1.c*t1.f)/abs(t1.e))) when case max(b) when abs(count(distinct t1.b)) then +cast(avg((13)) AS integer) else +case min(b) when count(*) then count(*) else count(distinct t1.f) end end then max(19) else ( -count(*)) end)))*count(distinct f)*cast(avg(t1.c) AS integer) from t1 union select count(distinct a) from t1)}
+} {}
+do_test randexpr-2.2350 {
+ db eval {SELECT ((select count(distinct 11+19 | case (d) when t1.b then coalesce((select case coalesce((select max(+c*t1.f) from t1 where (t1.e=f and 13<=t1.d)), -17)+11-t1.a when (t1.c) then 19 else 13 end from t1 where t1.c in (select ~+ -count(distinct t1.f) from t1 union select count(*)+count(distinct b)*min(11) from t1)),e) else 19 end+d) | count(*) from t1)) FROM t1 WHERE NOT (case b when 19 then ~b-~e-d+d+t1.c else a end in (select max(t1.b)-~count(*)+abs(abs((case min((abs(~t1.c*t1.f)/abs(t1.e))) when case max(b) when abs(count(distinct t1.b)) then +cast(avg((13)) AS integer) else +case min(b) when count(*) then count(*) else count(distinct t1.f) end end then max(19) else ( -count(*)) end)))*count(distinct f)*cast(avg(t1.c) AS integer) from t1 union select count(distinct a) from t1))}
+} {1}
+do_test randexpr-2.2351 {
+ db eval {SELECT ((select count(distinct 11+19 & case (d) when t1.b then coalesce((select case coalesce((select max(+c*t1.f) from t1 where (t1.e=f and 13<=t1.d)), -17)+11-t1.a when (t1.c) then 19 else 13 end from t1 where t1.c in (select ~+ -count(distinct t1.f) from t1 union select count(*)+count(distinct b)*min(11) from t1)),e) else 19 end+d) & count(*) from t1)) FROM t1 WHERE NOT (case b when 19 then ~b-~e-d+d+t1.c else a end in (select max(t1.b)-~count(*)+abs(abs((case min((abs(~t1.c*t1.f)/abs(t1.e))) when case max(b) when abs(count(distinct t1.b)) then +cast(avg((13)) AS integer) else +case min(b) when count(*) then count(*) else count(distinct t1.f) end end then max(19) else ( -count(*)) end)))*count(distinct f)*cast(avg(t1.c) AS integer) from t1 union select count(distinct a) from t1))}
+} {1}
+do_test randexpr-2.2352 {
+ db eval {SELECT 17+ -(abs(case case when a>t1.c then t1.e else a end*11-case when not exists(select 1 from t1 where coalesce((select -t1.e-11+coalesce((select t1.e from t1 where 13=t1.e),d) from t1 where t1.e between t1.d and a),13)-t1.e in (select t1.d from t1 union select d from t1)) then t1.b else t1.d end-t1.e-13+b when 19 then t1.b else c end)/abs(t1.d)) FROM t1 WHERE coalesce((select max(t1.d) from t1 where t1.a+t1.d<19),t1.a) in (select t1.b from t1 union select c from t1) or t1.c in (select -abs(max(case when -f<>t1.b and b<>11 then t1.f when t1.a=e then t1.d else -(f) end) | case cast(avg(f) AS integer) when count(distinct t1.f) then min(e) else -count(*) end+cast(avg((t1.f)) AS integer)) from t1 union select max(17) from t1) or t1.c between ((c)) and -t1.b and -c not between d and 11 or b>=19}
+} {17}
+do_test randexpr-2.2353 {
+ db eval {SELECT 17+ -(abs(case case when a>t1.c then t1.e else a end*11-case when not exists(select 1 from t1 where coalesce((select -t1.e-11+coalesce((select t1.e from t1 where 13=t1.e),d) from t1 where t1.e between t1.d and a),13)-t1.e in (select t1.d from t1 union select d from t1)) then t1.b else t1.d end-t1.e-13+b when 19 then t1.b else c end)/abs(t1.d)) FROM t1 WHERE NOT (coalesce((select max(t1.d) from t1 where t1.a+t1.d<19),t1.a) in (select t1.b from t1 union select c from t1) or t1.c in (select -abs(max(case when -f<>t1.b and b<>11 then t1.f when t1.a=e then t1.d else -(f) end) | case cast(avg(f) AS integer) when count(distinct t1.f) then min(e) else -count(*) end+cast(avg((t1.f)) AS integer)) from t1 union select max(17) from t1) or t1.c between ((c)) and -t1.b and -c not between d and 11 or b>=19)}
+} {}
+do_test randexpr-2.2354 {
+ db eval {SELECT e*~+(e)-(abs(~case when (t1.f)>13+~t1.d then case when d=t1.b+13 then 17 when 11 in (t1.d,e,e) then ~19*t1.a else coalesce((select t1.c from t1 where 19*(abs(t1.e)/abs(b)) between t1.c and t1.c),t1.d) end when a not between 13 and -17 then 19 else b end)/abs(t1.b)) FROM t1 WHERE (not d>case t1.b+t1.f when +(~(select (case abs(cast(avg(13) AS integer)) when cast(avg(+a) AS integer) then abs(abs(count(distinct case when t1.f*e<=11 then 13 when exists(select 1 from t1 where t1.e<17 or t1.a>=t1.a) then (11) else f end))) else min(t1.b)-min(11) end) from t1))+17*t1.b*f*17 then e else 11 end)}
+} {}
+do_test randexpr-2.2355 {
+ db eval {SELECT e*~+(e)-(abs(~case when (t1.f)>13+~t1.d then case when d=t1.b+13 then 17 when 11 in (t1.d,e,e) then ~19*t1.a else coalesce((select t1.c from t1 where 19*(abs(t1.e)/abs(b)) between t1.c and t1.c),t1.d) end when a not between 13 and -17 then 19 else b end)/abs(t1.b)) FROM t1 WHERE NOT ((not d>case t1.b+t1.f when +(~(select (case abs(cast(avg(13) AS integer)) when cast(avg(+a) AS integer) then abs(abs(count(distinct case when t1.f*e<=11 then 13 when exists(select 1 from t1 where t1.e<17 or t1.a>=t1.a) then (11) else f end))) else min(t1.b)-min(11) end) from t1))+17*t1.b*f*17 then e else 11 end))}
+} {-250502}
+do_test randexpr-2.2356 {
+ db eval {SELECT -case when t1.c<= -case coalesce((select max((coalesce((select case 11 when t1.b then t1.f else 11 end-d from t1 where c in (select count(*) | ~count(distinct f) from t1 union select count(*) from t1)),a)*t1.a)-t1.f) from t1 where not exists(select 1 from t1 where ((t1.f not in ( -c,t1.d,b)) or t1.a not in (b,11,t1.c)) or t1.d not in (17,a,t1.a))),19)-t1.b when d then t1.e else t1.e end-19 | e then b else -13 end*e-c FROM t1 WHERE b<>coalesce((select max((abs((abs(11)/abs(13)))/abs(case when t1.e between 11 and 19 then t1.d when 11>=b-19 then (select count(distinct ~a | 19*f+case when f not in (t1.e,t1.f, -t1.f) then 17 when c not in ( -t1.a,t1.c,b) then f else 11 end) from t1) else t1.e end))-t1.e*a) from t1 where e in (t1.c,17,17)),t1.a) or a=t1.e or d>t1.b}
+} {6200}
+do_test randexpr-2.2357 {
+ db eval {SELECT -case when t1.c<= -case coalesce((select max((coalesce((select case 11 when t1.b then t1.f else 11 end-d from t1 where c in (select count(*) | ~count(distinct f) from t1 union select count(*) from t1)),a)*t1.a)-t1.f) from t1 where not exists(select 1 from t1 where ((t1.f not in ( -c,t1.d,b)) or t1.a not in (b,11,t1.c)) or t1.d not in (17,a,t1.a))),19)-t1.b when d then t1.e else t1.e end-19 | e then b else -13 end*e-c FROM t1 WHERE NOT (b<>coalesce((select max((abs((abs(11)/abs(13)))/abs(case when t1.e between 11 and 19 then t1.d when 11>=b-19 then (select count(distinct ~a | 19*f+case when f not in (t1.e,t1.f, -t1.f) then 17 when c not in ( -t1.a,t1.c,b) then f else 11 end) from t1) else t1.e end))-t1.e*a) from t1 where e in (t1.c,17,17)),t1.a) or a=t1.e or d>t1.b)}
+} {}
+do_test randexpr-2.2358 {
+ db eval {SELECT -case when t1.c<= -case coalesce((select max((coalesce((select case 11 when t1.b then t1.f else 11 end-d from t1 where c in (select count(*) & ~count(distinct f) from t1 union select count(*) from t1)),a)*t1.a)-t1.f) from t1 where not exists(select 1 from t1 where ((t1.f not in ( -c,t1.d,b)) or t1.a not in (b,11,t1.c)) or t1.d not in (17,a,t1.a))),19)-t1.b when d then t1.e else t1.e end-19 & e then b else -13 end*e-c FROM t1 WHERE b<>coalesce((select max((abs((abs(11)/abs(13)))/abs(case when t1.e between 11 and 19 then t1.d when 11>=b-19 then (select count(distinct ~a | 19*f+case when f not in (t1.e,t1.f, -t1.f) then 17 when c not in ( -t1.a,t1.c,b) then f else 11 end) from t1) else t1.e end))-t1.e*a) from t1 where e in (t1.c,17,17)),t1.a) or a=t1.e or d>t1.b}
+} {-100300}
+do_test randexpr-2.2359 {
+ db eval {SELECT (abs(case when t1.d not in (t1.f,t1.d,(select abs(min(((select +count(*)*case max(t1.e-coalesce((select max(case t1.b when 13 then a else e end) from t1 where t1.b>b),19)+d)- -+count(*) when +cast(avg(d) AS integer) then max(c) else (cast(avg(c) AS integer)) end | count(*) from t1)+t1.f)))-max(t1.c) from t1)) then t1.b*t1.f else f end)/abs(b+19)) FROM t1 WHERE a not in ((11),(t1.d),a) or case when f<t1.e | 11+t1.b+17-coalesce((select t1.f+case when ((not (t1.d)>(abs(d)/abs(t1.d)))) then a when f not between t1.f | t1.b and t1.d then a else 13 end from t1 where 19<=c),f) then t1.a else f end between 13 and 11}
+} {}
+do_test randexpr-2.2360 {
+ db eval {SELECT (abs(case when t1.d not in (t1.f,t1.d,(select abs(min(((select +count(*)*case max(t1.e-coalesce((select max(case t1.b when 13 then a else e end) from t1 where t1.b>b),19)+d)- -+count(*) when +cast(avg(d) AS integer) then max(c) else (cast(avg(c) AS integer)) end | count(*) from t1)+t1.f)))-max(t1.c) from t1)) then t1.b*t1.f else f end)/abs(b+19)) FROM t1 WHERE NOT (a not in ((11),(t1.d),a) or case when f<t1.e | 11+t1.b+17-coalesce((select t1.f+case when ((not (t1.d)>(abs(d)/abs(t1.d)))) then a when f not between t1.f | t1.b and t1.d then a else 13 end from t1 where 19<=c),f) then t1.a else f end between 13 and 11)}
+} {2}
+do_test randexpr-2.2361 {
+ db eval {SELECT (abs(case when t1.d not in (t1.f,t1.d,(select abs(min(((select +count(*)*case max(t1.e-coalesce((select max(case t1.b when 13 then a else e end) from t1 where t1.b>b),19)+d)- -+count(*) when +cast(avg(d) AS integer) then max(c) else (cast(avg(c) AS integer)) end & count(*) from t1)+t1.f)))-max(t1.c) from t1)) then t1.b*t1.f else f end)/abs(b+19)) FROM t1 WHERE NOT (a not in ((11),(t1.d),a) or case when f<t1.e | 11+t1.b+17-coalesce((select t1.f+case when ((not (t1.d)>(abs(d)/abs(t1.d)))) then a when f not between t1.f | t1.b and t1.d then a else 13 end from t1 where 19<=c),f) then t1.a else f end between 13 and 11)}
+} {2}
+do_test randexpr-2.2362 {
+ db eval {SELECT t1.a+d | +case when +t1.a-t1.f++t1.c+(select case ~count(*) when (+cast(avg(f*t1.f) AS integer) | min(t1.b)) then -(cast(avg(t1.f) AS integer)) else min(e) end from t1)-b* - -13-f+c in (select b from t1 union select t1.d from t1) or e<e then b | 13 else t1.c end FROM t1 WHERE coalesce((select max(coalesce((select -e*a from t1 where (select max(case t1.a when b then d else 17 end) from t1) in (select 17 from t1 union select -case when exists(select 1 from t1 where coalesce((select t1.d from t1 where t1.a not between t1.d and 17 and 19=17),t1.c)-t1.e+b<=a) then 17 | c when -e<=d then 13 else (b) end from t1)),e)) from t1 where t1.e not in (11, -t1.b,(f))),t1.c) not in ( -c,t1.d,t1.d) and b<=13}
+} {}
+do_test randexpr-2.2363 {
+ db eval {SELECT t1.a+d | +case when +t1.a-t1.f++t1.c+(select case ~count(*) when (+cast(avg(f*t1.f) AS integer) | min(t1.b)) then -(cast(avg(t1.f) AS integer)) else min(e) end from t1)-b* - -13-f+c in (select b from t1 union select t1.d from t1) or e<e then b | 13 else t1.c end FROM t1 WHERE NOT (coalesce((select max(coalesce((select -e*a from t1 where (select max(case t1.a when b then d else 17 end) from t1) in (select 17 from t1 union select -case when exists(select 1 from t1 where coalesce((select t1.d from t1 where t1.a not between t1.d and 17 and 19=17),t1.c)-t1.e+b<=a) then 17 | c when -e<=d then 13 else (b) end from t1)),e)) from t1 where t1.e not in (11, -t1.b,(f))),t1.c) not in ( -c,t1.d,t1.d) and b<=13)}
+} {508}
+do_test randexpr-2.2364 {
+ db eval {SELECT t1.a+d & +case when +t1.a-t1.f++t1.c+(select case ~count(*) when (+cast(avg(f*t1.f) AS integer) & min(t1.b)) then -(cast(avg(t1.f) AS integer)) else min(e) end from t1)-b* - -13-f+c in (select b from t1 union select t1.d from t1) or e<e then b & 13 else t1.c end FROM t1 WHERE NOT (coalesce((select max(coalesce((select -e*a from t1 where (select max(case t1.a when b then d else 17 end) from t1) in (select 17 from t1 union select -case when exists(select 1 from t1 where coalesce((select t1.d from t1 where t1.a not between t1.d and 17 and 19=17),t1.c)-t1.e+b<=a) then 17 | c when -e<=d then 13 else (b) end from t1)),e)) from t1 where t1.e not in (11, -t1.b,(f))),t1.c) not in ( -c,t1.d,t1.d) and b<=13)}
+} {292}
+do_test randexpr-2.2365 {
+ db eval {SELECT coalesce((select max((select (max((abs(coalesce((select max(+case when ~t1.d=t1.a then a when coalesce((select case when t1.c in (select 19 from t1 union select (d) from t1) then e else f end from t1 where t1.a<>t1.a),t1.f) between t1.a and 19 then ( -b) else t1.a end) from t1 where t1.c in (a,(f),e)),t1.c))/abs(a)))) from t1)) from t1 where case when exists(select 1 from t1 where e<11) and 17 in (select 11 from t1 union select a from t1) then d else (d) end in (select cast(avg(f) AS integer) from t1 union select count(*) from t1)),t1.d) FROM t1 WHERE exists(select 1 from t1 where b not between case 11 when d then (select + -(abs(abs(case -min(d)+ - -count(*)-max(c) when count(*) then max(t1.b) else count(*) end))) from t1)+t1.f-f*t1.b*((select min(a) from t1))-b+f else t1.e end | t1.c+13 and 19) and b<t1.c or (17>t1.e)}
+} {400}
+do_test randexpr-2.2366 {
+ db eval {SELECT coalesce((select max((select (max((abs(coalesce((select max(+case when ~t1.d=t1.a then a when coalesce((select case when t1.c in (select 19 from t1 union select (d) from t1) then e else f end from t1 where t1.a<>t1.a),t1.f) between t1.a and 19 then ( -b) else t1.a end) from t1 where t1.c in (a,(f),e)),t1.c))/abs(a)))) from t1)) from t1 where case when exists(select 1 from t1 where e<11) and 17 in (select 11 from t1 union select a from t1) then d else (d) end in (select cast(avg(f) AS integer) from t1 union select count(*) from t1)),t1.d) FROM t1 WHERE NOT (exists(select 1 from t1 where b not between case 11 when d then (select + -(abs(abs(case -min(d)+ - -count(*)-max(c) when count(*) then max(t1.b) else count(*) end))) from t1)+t1.f-f*t1.b*((select min(a) from t1))-b+f else t1.e end | t1.c+13 and 19) and b<t1.c or (17>t1.e))}
+} {}
+do_test randexpr-2.2367 {
+ db eval {SELECT case when t1.d+b+c | case +a-t1.d-f*(select cast(avg(17) AS integer)+count(distinct e)-count(distinct t1.a) | - -cast(avg(t1.b) AS integer) from t1)+~t1.e-a when d then t1.f else d end+t1.e*b<>11 then f when t1.a=b or t1.b>(t1.d) then 19 else t1.f end+19 FROM t1 WHERE coalesce((select case t1.e-case coalesce((select (select min(t1.d) from t1) from t1 where coalesce((select max(coalesce((select max(a) from t1 where t1.d in (select cast(avg(t1.b) AS integer) from t1 union select count(distinct a) from t1)), -19)*t1.e) from t1 where d>11),t1.f)>17),t1.f) when (17) then e else d end when b then (19) else 19 end from t1 where not t1.f in (select ( -max(13)) from t1 union select max(c) from t1)),11)-d not in ( -19,13,d)}
+} {619}
+do_test randexpr-2.2368 {
+ db eval {SELECT case when t1.d+b+c | case +a-t1.d-f*(select cast(avg(17) AS integer)+count(distinct e)-count(distinct t1.a) | - -cast(avg(t1.b) AS integer) from t1)+~t1.e-a when d then t1.f else d end+t1.e*b<>11 then f when t1.a=b or t1.b>(t1.d) then 19 else t1.f end+19 FROM t1 WHERE NOT (coalesce((select case t1.e-case coalesce((select (select min(t1.d) from t1) from t1 where coalesce((select max(coalesce((select max(a) from t1 where t1.d in (select cast(avg(t1.b) AS integer) from t1 union select count(distinct a) from t1)), -19)*t1.e) from t1 where d>11),t1.f)>17),t1.f) when (17) then e else d end when b then (19) else 19 end from t1 where not t1.f in (select ( -max(13)) from t1 union select max(c) from t1)),11)-d not in ( -19,13,d))}
+} {}
+do_test randexpr-2.2369 {
+ db eval {SELECT case when t1.d+b+c & case +a-t1.d-f*(select cast(avg(17) AS integer)+count(distinct e)-count(distinct t1.a) & - -cast(avg(t1.b) AS integer) from t1)+~t1.e-a when d then t1.f else d end+t1.e*b<>11 then f when t1.a=b or t1.b>(t1.d) then 19 else t1.f end+19 FROM t1 WHERE coalesce((select case t1.e-case coalesce((select (select min(t1.d) from t1) from t1 where coalesce((select max(coalesce((select max(a) from t1 where t1.d in (select cast(avg(t1.b) AS integer) from t1 union select count(distinct a) from t1)), -19)*t1.e) from t1 where d>11),t1.f)>17),t1.f) when (17) then e else d end when b then (19) else 19 end from t1 where not t1.f in (select ( -max(13)) from t1 union select max(c) from t1)),11)-d not in ( -19,13,d)}
+} {619}
+do_test randexpr-2.2370 {
+ db eval {SELECT case when (t1.a not in (coalesce((select 17 from t1 where case when t1.b*(abs( -t1.b*f*coalesce((select 17 from t1 where not t1.d<t1.d),t1.b)*t1.a+19* -17)/abs(b))<=b then t1.b else 13 end+t1.d not between t1.b and - -11),d),11,t1.e) or a<=19) or t1.e not between t1.c and 13 then 13 else e end FROM t1 WHERE t1.f+(abs(f)/abs((abs(t1.e+19)/abs(t1.c))*t1.d)) in (e*11,(select count(*) from t1),t1.e)}
+} {}
+do_test randexpr-2.2371 {
+ db eval {SELECT case when (t1.a not in (coalesce((select 17 from t1 where case when t1.b*(abs( -t1.b*f*coalesce((select 17 from t1 where not t1.d<t1.d),t1.b)*t1.a+19* -17)/abs(b))<=b then t1.b else 13 end+t1.d not between t1.b and - -11),d),11,t1.e) or a<=19) or t1.e not between t1.c and 13 then 13 else e end FROM t1 WHERE NOT (t1.f+(abs(f)/abs((abs(t1.e+19)/abs(t1.c))*t1.d)) in (e*11,(select count(*) from t1),t1.e))}
+} {13}
+do_test randexpr-2.2372 {
+ db eval {SELECT case when case when (case (t1.a)*case when c<f and t1.e<>t1.d then 13 when c>b then c else 11 end when e then a else t1.e end>c) or 19 in (select ++min(f) from t1 union select -count(distinct t1.a) from t1) then (case when t1.f in (select t1.f from t1 union select -t1.a from t1) then c when b not between t1.a and b then -t1.c else t1.a end) else t1.c end not in (f,a,17) then 11 else 11 end FROM t1 WHERE not c not between (select abs(max(~(19*e-t1.a*c*t1.d))*~abs((abs(min(a)-min(c) | cast(avg(19) AS integer))) | count(distinct 19)) | (cast(avg(d) AS integer))) from t1) and (abs(case coalesce((select max(19) from t1 where b not between a and f or 19 in (t1.c,t1.c,b)),t1.e) when c then f else 11 end)/abs(c))}
+} {}
+do_test randexpr-2.2373 {
+ db eval {SELECT case when case when (case (t1.a)*case when c<f and t1.e<>t1.d then 13 when c>b then c else 11 end when e then a else t1.e end>c) or 19 in (select ++min(f) from t1 union select -count(distinct t1.a) from t1) then (case when t1.f in (select t1.f from t1 union select -t1.a from t1) then c when b not between t1.a and b then -t1.c else t1.a end) else t1.c end not in (f,a,17) then 11 else 11 end FROM t1 WHERE NOT (not c not between (select abs(max(~(19*e-t1.a*c*t1.d))*~abs((abs(min(a)-min(c) | cast(avg(19) AS integer))) | count(distinct 19)) | (cast(avg(d) AS integer))) from t1) and (abs(case coalesce((select max(19) from t1 where b not between a and f or 19 in (t1.c,t1.c,b)),t1.e) when c then f else 11 end)/abs(c)))}
+} {11}
+do_test randexpr-2.2374 {
+ db eval {SELECT (select count(*)-+ -(max(~coalesce((select ~b from t1 where not t1.c | 19 not between c+t1.c and d),a)*(abs(t1.a)/abs(d*(case t1.a*case when 17>e then 11 else 13 end when 19 then e else t1.d end)))+17))-cast(avg(c) AS integer) | count(distinct f) from t1)+(select abs(min(11)) from t1) FROM t1 WHERE coalesce((select max(11) from t1 where case when b<=13-~case when ~~(select count(*)+count(*)* -count(*) from t1)>17*17 then t1.f+case when not case when 19 in (t1.e,a,19) then 17 when f<=19 then 17 else -d end=19 then f when a>=19 then d else f end else t1.c end | f then 19 else b end*t1.d between e and b),f)<c}
+} {}
+do_test randexpr-2.2375 {
+ db eval {SELECT (select count(*)-+ -(max(~coalesce((select ~b from t1 where not t1.c | 19 not between c+t1.c and d),a)*(abs(t1.a)/abs(d*(case t1.a*case when 17>e then 11 else 13 end when 19 then e else t1.d end)))+17))-cast(avg(c) AS integer) | count(distinct f) from t1)+(select abs(min(11)) from t1) FROM t1 WHERE NOT (coalesce((select max(11) from t1 where case when b<=13-~case when ~~(select count(*)+count(*)* -count(*) from t1)>17*17 then t1.f+case when not case when 19 in (t1.e,a,19) then 17 when f<=19 then 17 else -d end=19 then f when a>=19 then d else f end else t1.c end | f then 19 else b end*t1.d between e and b),f)<c)}
+} {-270}
+do_test randexpr-2.2376 {
+ db eval {SELECT (select count(*)-+ -(max(~coalesce((select ~b from t1 where not t1.c & 19 not between c+t1.c and d),a)*(abs(t1.a)/abs(d*(case t1.a*case when 17>e then 11 else 13 end when 19 then e else t1.d end)))+17))-cast(avg(c) AS integer) & count(distinct f) from t1)+(select abs(min(11)) from t1) FROM t1 WHERE NOT (coalesce((select max(11) from t1 where case when b<=13-~case when ~~(select count(*)+count(*)* -count(*) from t1)>17*17 then t1.f+case when not case when 19 in (t1.e,a,19) then 17 when f<=19 then 17 else -d end=19 then f when a>=19 then d else f end else t1.c end | f then 19 else b end*t1.d between e and b),f)<c)}
+} {11}
+do_test randexpr-2.2377 {
+ db eval {SELECT case when ((select max((t1.e+19 | (abs((select case ++cast(avg(b-coalesce((select t1.c from t1 where t1.e not in (t1.a, -e,e)),c)) AS integer) when count(distinct t1.b) then count(distinct -t1.a) | - -count(distinct t1.b) else count(*) end*( -(min(11)))+(min(t1.f))-(count(*)) from t1))/abs(b+t1.b+t1.d | t1.e-19+t1.a))*t1.c)) from t1))>19 then 11 else 17 end-t1.d FROM t1 WHERE (select min(a) from t1)<t1.e}
+} {-389}
+do_test randexpr-2.2378 {
+ db eval {SELECT case when ((select max((t1.e+19 | (abs((select case ++cast(avg(b-coalesce((select t1.c from t1 where t1.e not in (t1.a, -e,e)),c)) AS integer) when count(distinct t1.b) then count(distinct -t1.a) | - -count(distinct t1.b) else count(*) end*( -(min(11)))+(min(t1.f))-(count(*)) from t1))/abs(b+t1.b+t1.d | t1.e-19+t1.a))*t1.c)) from t1))>19 then 11 else 17 end-t1.d FROM t1 WHERE NOT ((select min(a) from t1)<t1.e)}
+} {}
+do_test randexpr-2.2379 {
+ db eval {SELECT case when ((select max((t1.e+19 & (abs((select case ++cast(avg(b-coalesce((select t1.c from t1 where t1.e not in (t1.a, -e,e)),c)) AS integer) when count(distinct t1.b) then count(distinct -t1.a) & - -count(distinct t1.b) else count(*) end*( -(min(11)))+(min(t1.f))-(count(*)) from t1))/abs(b+t1.b+t1.d & t1.e-19+t1.a))*t1.c)) from t1))>19 then 11 else 17 end-t1.d FROM t1 WHERE (select min(a) from t1)<t1.e}
+} {-383}
+do_test randexpr-2.2380 {
+ db eval {SELECT t1.d*11-case 11 when a then 11 else - -t1.b-(t1.b)+c+t1.a* -case when not exists(select 1 from t1 where coalesce((select t1.c from t1 where t1.c=case when 13 in (coalesce((select max(coalesce((select max(t1.c) from t1 where c between t1.d and t1.f and t1.a<=b),e)) from t1 where (11 not in (b,19,c))),b),e, -b) then 17 when t1.a in (b,t1.d,b) and t1.f>c then t1.a else (d) end),d)<= -t1.c) then t1.e*t1.c else 13 end end FROM t1 WHERE exists(select 1 from t1 where ((b not between f and t1.a)))}
+} {15004100}
+do_test randexpr-2.2381 {
+ db eval {SELECT t1.d*11-case 11 when a then 11 else - -t1.b-(t1.b)+c+t1.a* -case when not exists(select 1 from t1 where coalesce((select t1.c from t1 where t1.c=case when 13 in (coalesce((select max(coalesce((select max(t1.c) from t1 where c between t1.d and t1.f and t1.a<=b),e)) from t1 where (11 not in (b,19,c))),b),e, -b) then 17 when t1.a in (b,t1.d,b) and t1.f>c then t1.a else (d) end),d)<= -t1.c) then t1.e*t1.c else 13 end end FROM t1 WHERE NOT (exists(select 1 from t1 where ((b not between f and t1.a))))}
+} {}
+do_test randexpr-2.2382 {
+ db eval {SELECT t1.c*case when not b>(+coalesce((select t1.e from t1 where t1.b>(abs(case when t1.d<=c+ -17*t1.f*19*17 then 11+a-13-t1.d else case (select abs(count(distinct 19))+ -count(distinct 17) from t1) when 17*t1.d then a else t1.a end end)/abs(17))),(11)))+17 then (t1.c)*f else 17 end FROM t1 WHERE (t1.b)-b<=t1.a*13}
+} {54000000}
+do_test randexpr-2.2383 {
+ db eval {SELECT t1.c*case when not b>(+coalesce((select t1.e from t1 where t1.b>(abs(case when t1.d<=c+ -17*t1.f*19*17 then 11+a-13-t1.d else case (select abs(count(distinct 19))+ -count(distinct 17) from t1) when 17*t1.d then a else t1.a end end)/abs(17))),(11)))+17 then (t1.c)*f else 17 end FROM t1 WHERE NOT ((t1.b)-b<=t1.a*13)}
+} {}
+do_test randexpr-2.2384 {
+ db eval {SELECT t1.b+coalesce((select max(~e- -t1.d+case +b+f when a-case when t1.a-d+t1.c between t1.e and a*e then (abs(e)/abs(t1.a)) else f | -f*t1.b-t1.c end*t1.e+f then 19 else t1.b end*19) from t1 where 19 in (select e from t1 union select 17 from t1)),19) FROM t1 WHERE d in (11,t1.c+c*t1.d+case when t1.c-case when ~(19+13)*c=11 and d<>17 or t1.e>=c then case t1.a when c then f else 11 end+t1.c when t1.f in (select max(13) from t1 union select cast(avg(c) AS integer) from t1) or t1.c<t1.b then 13 else b end=13 then 11 when d<>t1.b then t1.e else 19 end,a)}
+} {}
+do_test randexpr-2.2385 {
+ db eval {SELECT t1.b+coalesce((select max(~e- -t1.d+case +b+f when a-case when t1.a-d+t1.c between t1.e and a*e then (abs(e)/abs(t1.a)) else f | -f*t1.b-t1.c end*t1.e+f then 19 else t1.b end*19) from t1 where 19 in (select e from t1 union select 17 from t1)),19) FROM t1 WHERE NOT (d in (11,t1.c+c*t1.d+case when t1.c-case when ~(19+13)*c=11 and d<>17 or t1.e>=c then case t1.a when c then f else 11 end+t1.c when t1.f in (select max(13) from t1 union select cast(avg(c) AS integer) from t1) or t1.c<t1.b then 13 else b end=13 then 11 when d<>t1.b then t1.e else 19 end,a))}
+} {219}
+do_test randexpr-2.2386 {
+ db eval {SELECT t1.b+coalesce((select max(~e- -t1.d+case +b+f when a-case when t1.a-d+t1.c between t1.e and a*e then (abs(e)/abs(t1.a)) else f & -f*t1.b-t1.c end*t1.e+f then 19 else t1.b end*19) from t1 where 19 in (select e from t1 union select 17 from t1)),19) FROM t1 WHERE NOT (d in (11,t1.c+c*t1.d+case when t1.c-case when ~(19+13)*c=11 and d<>17 or t1.e>=c then case t1.a when c then f else 11 end+t1.c when t1.f in (select max(13) from t1 union select cast(avg(c) AS integer) from t1) or t1.c<t1.b then 13 else b end=13 then 11 when d<>t1.b then t1.e else 19 end,a))}
+} {219}
+do_test randexpr-2.2387 {
+ db eval {SELECT (abs((select (case (abs(max( -t1.a))* -case count(*) when case min(c) when max(d) then count(*) else max(17) end-cast(avg(17) AS integer) then max(11) else cast(avg(t1.d) AS integer) end | max(13)+max(f)) when cast(avg(f) AS integer) then cast(avg(19) AS integer) else (max(11)) end) from t1) | coalesce((select (select max( -t1.d) from t1) from t1 where t1.b-~e in (select d from t1 union select e from t1) and t1.e=t1.d), -t1.e)-17)/abs(t1.e)) | -t1.e FROM t1 WHERE exists(select 1 from t1 where coalesce((select +19 from t1 where (coalesce((select max(e) from t1 where ((coalesce((select max(19) from t1 where coalesce((select t1.d*19+(t1.c) from t1 where e in (select -11 from t1 union select t1.f from t1) and (t1.d) in (select ~max(t1.e) from t1 union select (( -count(*))) from t1) or 19>=(a)),f) in ((e),e,t1.a)),t1.a)<=t1.c))),t1.f+t1.c)>13)),11) in (11,17,t1.d) and e>=t1.b)}
+} {}
+do_test randexpr-2.2388 {
+ db eval {SELECT (abs((select (case (abs(max( -t1.a))* -case count(*) when case min(c) when max(d) then count(*) else max(17) end-cast(avg(17) AS integer) then max(11) else cast(avg(t1.d) AS integer) end | max(13)+max(f)) when cast(avg(f) AS integer) then cast(avg(19) AS integer) else (max(11)) end) from t1) | coalesce((select (select max( -t1.d) from t1) from t1 where t1.b-~e in (select d from t1 union select e from t1) and t1.e=t1.d), -t1.e)-17)/abs(t1.e)) | -t1.e FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select +19 from t1 where (coalesce((select max(e) from t1 where ((coalesce((select max(19) from t1 where coalesce((select t1.d*19+(t1.c) from t1 where e in (select -11 from t1 union select t1.f from t1) and (t1.d) in (select ~max(t1.e) from t1 union select (( -count(*))) from t1) or 19>=(a)),f) in ((e),e,t1.a)),t1.a)<=t1.c))),t1.f+t1.c)>13)),11) in (11,17,t1.d) and e>=t1.b))}
+} {-499}
+do_test randexpr-2.2389 {
+ db eval {SELECT (abs((select (case (abs(max( -t1.a))* -case count(*) when case min(c) when max(d) then count(*) else max(17) end-cast(avg(17) AS integer) then max(11) else cast(avg(t1.d) AS integer) end & max(13)+max(f)) when cast(avg(f) AS integer) then cast(avg(19) AS integer) else (max(11)) end) from t1) & coalesce((select (select max( -t1.d) from t1) from t1 where t1.b-~e in (select d from t1 union select e from t1) and t1.e=t1.d), -t1.e)-17)/abs(t1.e)) & -t1.e FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select +19 from t1 where (coalesce((select max(e) from t1 where ((coalesce((select max(19) from t1 where coalesce((select t1.d*19+(t1.c) from t1 where e in (select -11 from t1 union select t1.f from t1) and (t1.d) in (select ~max(t1.e) from t1 union select (( -count(*))) from t1) or 19>=(a)),f) in ((e),e,t1.a)),t1.a)<=t1.c))),t1.f+t1.c)>13)),11) in (11,17,t1.d) and e>=t1.b))}
+} {0}
+do_test randexpr-2.2390 {
+ db eval {SELECT f-coalesce((select 19+t1.e+t1.f from t1 where +11>coalesce((select +t1.f from t1 where t1.a between ~ -(select case cast(avg((abs(t1.d)/abs(t1.b))) AS integer) when -~max(19) then - -case count(distinct c) when count(*) then min((a)) else -min(t1.d) end else max( -t1.b) end from t1) and (select count(distinct f) from t1)),(coalesce((select max(t1.e) from t1 where not 11>=d),t1.c)))),19)-t1.f+19+f*t1.d FROM t1 WHERE f in (select (min((abs(d-t1.c+coalesce((select t1.f from t1 where f<t1.a),t1.c)+a-t1.d*(f)-19)/abs(11))) | abs((count(*))))+(abs(~case count(*) | max(t1.a) when max(t1.d) then count(distinct 19) else count(distinct e) end)+cast(avg((t1.e)) AS integer))+max(t1.c) from t1 union select count(*) from t1) and c*t1.a in (select e from t1 union select f from t1)}
+} {}
+do_test randexpr-2.2391 {
+ db eval {SELECT f-coalesce((select 19+t1.e+t1.f from t1 where +11>coalesce((select +t1.f from t1 where t1.a between ~ -(select case cast(avg((abs(t1.d)/abs(t1.b))) AS integer) when -~max(19) then - -case count(distinct c) when count(*) then min((a)) else -min(t1.d) end else max( -t1.b) end from t1) and (select count(distinct f) from t1)),(coalesce((select max(t1.e) from t1 where not 11>=d),t1.c)))),19)-t1.f+19+f*t1.d FROM t1 WHERE NOT (f in (select (min((abs(d-t1.c+coalesce((select t1.f from t1 where f<t1.a),t1.c)+a-t1.d*(f)-19)/abs(11))) | abs((count(*))))+(abs(~case count(*) | max(t1.a) when max(t1.d) then count(distinct 19) else count(distinct e) end)+cast(avg((t1.e)) AS integer))+max(t1.c) from t1 union select count(*) from t1) and c*t1.a in (select e from t1 union select f from t1))}
+} {240000}
+do_test randexpr-2.2392 {
+ db eval {SELECT t1.b-case when b not between 17 and t1.d*11*f*t1.a or t1.c+case when -t1.e between t1.d and coalesce((select coalesce((select max((select ~count(*) from t1)) from t1 where -17*13-19-((d))<>(c)), -a) from t1 where (e)<=t1.a),d) then d when e<t1.f then 19 else e end>=a then t1.f else f end FROM t1 WHERE f in (13*13-(abs(d)/abs(e)),19,case t1.b+coalesce((select max((abs((abs(17)/abs(a)))/abs(11+t1.c))) from t1 where -t1.c>=t1.f and e in (select count(*) | min(t1.c) from t1 union select cast(avg(e) AS integer) from t1) or 11 not in (e,b,a) or t1.c< -a and t1.e not in (t1.e,b,t1.d)),t1.b) when f then 19 else b end-11) or d>t1.b}
+} {-400}
+do_test randexpr-2.2393 {
+ db eval {SELECT t1.b-case when b not between 17 and t1.d*11*f*t1.a or t1.c+case when -t1.e between t1.d and coalesce((select coalesce((select max((select ~count(*) from t1)) from t1 where -17*13-19-((d))<>(c)), -a) from t1 where (e)<=t1.a),d) then d when e<t1.f then 19 else e end>=a then t1.f else f end FROM t1 WHERE NOT (f in (13*13-(abs(d)/abs(e)),19,case t1.b+coalesce((select max((abs((abs(17)/abs(a)))/abs(11+t1.c))) from t1 where -t1.c>=t1.f and e in (select count(*) | min(t1.c) from t1 union select cast(avg(e) AS integer) from t1) or 11 not in (e,b,a) or t1.c< -a and t1.e not in (t1.e,b,t1.d)),t1.b) when f then 19 else b end-11) or d>t1.b)}
+} {}
+do_test randexpr-2.2394 {
+ db eval {SELECT case t1.d when (abs(17)/abs(coalesce((select max(e) from t1 where a not in (t1.e,case when 11+t1.d not between t1.e and -t1.c | t1.a*(abs(b)/abs(c)) then -d when a in (select +11 from t1 union select c from t1) then -t1.c else 13 end | t1.c,t1.b)),d)-f)) | t1.c then case when 13<c then t1.b when d<>t1.d then 13 else f end else b end FROM t1 WHERE 17>d*~t1.e+case when not t1.f<>(select count(distinct 19)+min(e) from t1) then case when (13-a<= -t1.b) and t1.f<=t1.f then 19*d else f end-t1.f*d+t1.d when b not in (t1.b,19,19) or t1.d not between t1.b and a then t1.f else b end}
+} {200}
+do_test randexpr-2.2395 {
+ db eval {SELECT case t1.d when (abs(17)/abs(coalesce((select max(e) from t1 where a not in (t1.e,case when 11+t1.d not between t1.e and -t1.c | t1.a*(abs(b)/abs(c)) then -d when a in (select +11 from t1 union select c from t1) then -t1.c else 13 end | t1.c,t1.b)),d)-f)) | t1.c then case when 13<c then t1.b when d<>t1.d then 13 else f end else b end FROM t1 WHERE NOT (17>d*~t1.e+case when not t1.f<>(select count(distinct 19)+min(e) from t1) then case when (13-a<= -t1.b) and t1.f<=t1.f then 19*d else f end-t1.f*d+t1.d when b not in (t1.b,19,19) or t1.d not between t1.b and a then t1.f else b end)}
+} {}
+do_test randexpr-2.2396 {
+ db eval {SELECT case t1.d when (abs(17)/abs(coalesce((select max(e) from t1 where a not in (t1.e,case when 11+t1.d not between t1.e and -t1.c & t1.a*(abs(b)/abs(c)) then -d when a in (select +11 from t1 union select c from t1) then -t1.c else 13 end & t1.c,t1.b)),d)-f)) & t1.c then case when 13<c then t1.b when d<>t1.d then 13 else f end else b end FROM t1 WHERE 17>d*~t1.e+case when not t1.f<>(select count(distinct 19)+min(e) from t1) then case when (13-a<= -t1.b) and t1.f<=t1.f then 19*d else f end-t1.f*d+t1.d when b not in (t1.b,19,19) or t1.d not between t1.b and a then t1.f else b end}
+} {200}
+do_test randexpr-2.2397 {
+ db eval {SELECT coalesce((select max(d) from t1 where coalesce((select t1.c from t1 where 17>b),d*coalesce((select max(11*19) from t1 where coalesce((select c from t1 where 19<(abs((case a when b then ~case t1.a+(select min(t1.f)+min(b) from t1) when (d) then e else t1.b end else t1.c end+f+t1.f))/abs(t1.b))),c)<=19),13))*d | e<e),t1.e) FROM t1 WHERE (t1.d*t1.c not in (t1.b,t1.b*t1.f,t1.c))}
+} {}
+do_test randexpr-2.2398 {
+ db eval {SELECT coalesce((select max(d) from t1 where coalesce((select t1.c from t1 where 17>b),d*coalesce((select max(11*19) from t1 where coalesce((select c from t1 where 19<(abs((case a when b then ~case t1.a+(select min(t1.f)+min(b) from t1) when (d) then e else t1.b end else t1.c end+f+t1.f))/abs(t1.b))),c)<=19),13))*d | e<e),t1.e) FROM t1 WHERE NOT ((t1.d*t1.c not in (t1.b,t1.b*t1.f,t1.c)))}
+} {500}
+do_test randexpr-2.2399 {
+ db eval {SELECT coalesce((select max(d) from t1 where coalesce((select t1.c from t1 where 17>b),d*coalesce((select max(11*19) from t1 where coalesce((select c from t1 where 19<(abs((case a when b then ~case t1.a+(select min(t1.f)+min(b) from t1) when (d) then e else t1.b end else t1.c end+f+t1.f))/abs(t1.b))),c)<=19),13))*d & e<e),t1.e) FROM t1 WHERE NOT ((t1.d*t1.c not in (t1.b,t1.b*t1.f,t1.c)))}
+} {400}
+do_test randexpr-2.2400 {
+ db eval {SELECT t1.b+ -t1.d*(select max(t1.a) | count(*) | abs(cast(avg(f+a-(select ~(min((abs(a)/abs(13+case when f=coalesce((select t1.b from t1 where d<>t1.e and 11 in (t1.e,t1.e,d)),f)+13 then t1.b else c end))- -f)) from t1)) AS integer))-count(distinct 11+11+13)+count(distinct t1.a) from t1) FROM t1 WHERE t1.d<c+t1.c | (select max((t1.e)) from t1)+case when t1.f-t1.d<a then t1.c-(abs(c)/abs(b*t1.c)) when case when not -c>=b then t1.c when -f*e<=t1.b then e else 17 end not between 17 and t1.f then t1.c else t1.b end-19+f+19*(t1.c)}
+} {-558600}
+do_test randexpr-2.2401 {
+ db eval {SELECT t1.b+ -t1.d*(select max(t1.a) | count(*) | abs(cast(avg(f+a-(select ~(min((abs(a)/abs(13+case when f=coalesce((select t1.b from t1 where d<>t1.e and 11 in (t1.e,t1.e,d)),f)+13 then t1.b else c end))- -f)) from t1)) AS integer))-count(distinct 11+11+13)+count(distinct t1.a) from t1) FROM t1 WHERE NOT (t1.d<c+t1.c | (select max((t1.e)) from t1)+case when t1.f-t1.d<a then t1.c-(abs(c)/abs(b*t1.c)) when case when not -c>=b then t1.c when -f*e<=t1.b then e else 17 end not between 17 and t1.f then t1.c else t1.b end-19+f+19*(t1.c))}
+} {}
+do_test randexpr-2.2402 {
+ db eval {SELECT t1.b+ -t1.d*(select max(t1.a) & count(*) & abs(cast(avg(f+a-(select ~(min((abs(a)/abs(13+case when f=coalesce((select t1.b from t1 where d<>t1.e and 11 in (t1.e,t1.e,d)),f)+13 then t1.b else c end))- -f)) from t1)) AS integer))-count(distinct 11+11+13)+count(distinct t1.a) from t1) FROM t1 WHERE t1.d<c+t1.c | (select max((t1.e)) from t1)+case when t1.f-t1.d<a then t1.c-(abs(c)/abs(b*t1.c)) when case when not -c>=b then t1.c when -f*e<=t1.b then e else 17 end not between 17 and t1.f then t1.c else t1.b end-19+f+19*(t1.c)}
+} {200}
+do_test randexpr-2.2403 {
+ db eval {SELECT case when case when t1.e<~17 or (case case case t1.d*17*13 when t1.a then e+c else c end when d*f+coalesce((select 17 from t1 where 13 not between 13 and -13),(17)) then t1.b else b end when t1.a then a else t1.c end*d<>d) then ~t1.c else a end<>t1.f then -t1.d else t1.a end+11-t1.c-e FROM t1 WHERE (case when (~f- -e in (17,case when d in (select t1.f from t1 union select a+(abs(coalesce((select (t1.c) from t1 where a in (select min(13) | (max(t1.e)) from t1 union select count(distinct t1.d) from t1)),b)+13)/abs(e))*19*f from t1) then b when not a between 13 and 13 then t1.f else 17 end,t1.c)) then (select max(t1.e)-count(*) | count(*) from t1) else c end)>(t1.e)}
+} {}
+do_test randexpr-2.2404 {
+ db eval {SELECT case when case when t1.e<~17 or (case case case t1.d*17*13 when t1.a then e+c else c end when d*f+coalesce((select 17 from t1 where 13 not between 13 and -13),(17)) then t1.b else b end when t1.a then a else t1.c end*d<>d) then ~t1.c else a end<>t1.f then -t1.d else t1.a end+11-t1.c-e FROM t1 WHERE NOT ((case when (~f- -e in (17,case when d in (select t1.f from t1 union select a+(abs(coalesce((select (t1.c) from t1 where a in (select min(13) | (max(t1.e)) from t1 union select count(distinct t1.d) from t1)),b)+13)/abs(e))*19*f from t1) then b when not a between 13 and 13 then t1.f else 17 end,t1.c)) then (select max(t1.e)-count(*) | count(*) from t1) else c end)>(t1.e))}
+} {-1189}
+do_test randexpr-2.2405 {
+ db eval {SELECT coalesce((select max(t1.a-(abs(e*coalesce((select max(d) from t1 where (case when case e when case when (t1.e)=d then t1.a+11 else 17 end then (c) else b end<=a then b when 19 in (t1.b,b,t1.e) then f else -19 end+17 between 19 and c or b in (select t1.c from t1 union select t1.a from t1))),t1.a))/abs( -t1.d))) from t1 where 13=17),t1.b)+(t1.b) FROM t1 WHERE coalesce((select -case when (d)>=(select ~case +(+~~cast(avg(a) AS integer)*abs(( -count(*))) | count(distinct 11)) when (count(*)) then count(distinct 19) else min(t1.a) end+min(t1.a) from t1)*13-t1.f then 13 else (e) | t1.c*(select (min(17)) from t1) end*case when (c) in (select 11 from t1 union select t1.f from t1) then 17 else 19 end from t1 where t1.c<t1.f),19)*19<>c}
+} {400}
+do_test randexpr-2.2406 {
+ db eval {SELECT coalesce((select max(t1.a-(abs(e*coalesce((select max(d) from t1 where (case when case e when case when (t1.e)=d then t1.a+11 else 17 end then (c) else b end<=a then b when 19 in (t1.b,b,t1.e) then f else -19 end+17 between 19 and c or b in (select t1.c from t1 union select t1.a from t1))),t1.a))/abs( -t1.d))) from t1 where 13=17),t1.b)+(t1.b) FROM t1 WHERE NOT (coalesce((select -case when (d)>=(select ~case +(+~~cast(avg(a) AS integer)*abs(( -count(*))) | count(distinct 11)) when (count(*)) then count(distinct 19) else min(t1.a) end+min(t1.a) from t1)*13-t1.f then 13 else (e) | t1.c*(select (min(17)) from t1) end*case when (c) in (select 11 from t1 union select t1.f from t1) then 17 else 19 end from t1 where t1.c<t1.f),19)*19<>c)}
+} {}
+do_test randexpr-2.2407 {
+ db eval {SELECT t1.b-t1.d-case when exists(select 1 from t1 where -coalesce((select t1.a from t1 where a in (c,coalesce((select max((abs(t1.d)/abs(e))) from t1 where case t1.b when t1.e then t1.d else t1.d end-17 between b and t1.f),17)-t1.f-t1.e,t1.a) or t1.b in (t1.a,19,t1.f)),19)>=d) then 19-b when t1.c between (f) and t1.f then t1.d else t1.f end-11 FROM t1 WHERE coalesce((select 13 from t1 where ( -t1.a<d)),(abs(t1.d)/abs(case when ( -11)+f+d+ -17+f*e not between t1.b and -11 and not t1.a<>13 or a in (select cast(avg(d) AS integer) | count(*)* -max(t1.f) from t1 union select count(*) from t1) then 17 when not exists(select 1 from t1 where b>=c) then e else 17 end | -t1.a))*b)*t1.d>=b}
+} {-811}
+do_test randexpr-2.2408 {
+ db eval {SELECT t1.b-t1.d-case when exists(select 1 from t1 where -coalesce((select t1.a from t1 where a in (c,coalesce((select max((abs(t1.d)/abs(e))) from t1 where case t1.b when t1.e then t1.d else t1.d end-17 between b and t1.f),17)-t1.f-t1.e,t1.a) or t1.b in (t1.a,19,t1.f)),19)>=d) then 19-b when t1.c between (f) and t1.f then t1.d else t1.f end-11 FROM t1 WHERE NOT (coalesce((select 13 from t1 where ( -t1.a<d)),(abs(t1.d)/abs(case when ( -11)+f+d+ -17+f*e not between t1.b and -11 and not t1.a<>13 or a in (select cast(avg(d) AS integer) | count(*)* -max(t1.f) from t1 union select count(*) from t1) then 17 when not exists(select 1 from t1 where b>=c) then e else 17 end | -t1.a))*b)*t1.d>=b)}
+} {}
+do_test randexpr-2.2409 {
+ db eval {SELECT 17 | t1.c*t1.a | case when ~ -~(abs(t1.b)/abs(coalesce((select max(coalesce((select max(+t1.d) from t1 where (t1.b not between 17 and t1.b) and d not between c and 19),d)*(t1.d)-d) from t1 where t1.a in (t1.c,(t1.c),t1.f)),19)))-b+19+ -17>=t1.a then 19 when 19 in (select t1.f from t1 union select t1.b from t1) then t1.c else f end-19*t1.c FROM t1 WHERE (17-t1.f in (d | b-17,t1.f,coalesce((select e+(abs(11)/abs(case t1.c when case (abs(a)/abs(11)) when e then t1.c else 17+c end then b else 11+t1.e end)) from t1 where (13 not between + -b and 13)),t1.c)) and 17 between t1.d | t1.f and t1.e)}
+} {}
+do_test randexpr-2.2410 {
+ db eval {SELECT 17 | t1.c*t1.a | case when ~ -~(abs(t1.b)/abs(coalesce((select max(coalesce((select max(+t1.d) from t1 where (t1.b not between 17 and t1.b) and d not between c and 19),d)*(t1.d)-d) from t1 where t1.a in (t1.c,(t1.c),t1.f)),19)))-b+19+ -17>=t1.a then 19 when 19 in (select t1.f from t1 union select t1.b from t1) then t1.c else f end-19*t1.c FROM t1 WHERE NOT ((17-t1.f in (d | b-17,t1.f,coalesce((select e+(abs(11)/abs(case t1.c when case (abs(a)/abs(11)) when e then t1.c else 17+c end then b else 11+t1.e end)) from t1 where (13 not between + -b and 13)),t1.c)) and 17 between t1.d | t1.f and t1.e))}
+} {-715}
+do_test randexpr-2.2411 {
+ db eval {SELECT 17 & t1.c*t1.a & case when ~ -~(abs(t1.b)/abs(coalesce((select max(coalesce((select max(+t1.d) from t1 where (t1.b not between 17 and t1.b) and d not between c and 19),d)*(t1.d)-d) from t1 where t1.a in (t1.c,(t1.c),t1.f)),19)))-b+19+ -17>=t1.a then 19 when 19 in (select t1.f from t1 union select t1.b from t1) then t1.c else f end-19*t1.c FROM t1 WHERE NOT ((17-t1.f in (d | b-17,t1.f,coalesce((select e+(abs(11)/abs(case t1.c when case (abs(a)/abs(11)) when e then t1.c else 17+c end then b else 11+t1.e end)) from t1 where (13 not between + -b and 13)),t1.c)) and 17 between t1.d | t1.f and t1.e))}
+} {16}
+do_test randexpr-2.2412 {
+ db eval {SELECT coalesce((select t1.a*a+t1.f | t1.d from t1 where t1.d<+t1.c*d-c*19+t1.e-(abs( -t1.e)/abs(19))), -t1.c+coalesce((select t1.b from t1 where not not (select max(t1.c) from t1)-17+e in (e,t1.c,b) and not (d in (select ( -((max(b)))) from t1 union select min(d) from t1))),t1.b) | t1.a) FROM t1 WHERE not t1.f in (select ((select abs(count(*)) from t1)-11) from t1 union select t1.a-17 from t1) or not exists(select 1 from t1 where case (abs(e)/abs(+c)) when coalesce((select max((select +(count(distinct t1.a)) from t1)) from t1 where not (e<=c*t1.a)),~(case when t1.c<=17 then e when t1.c<=t1.c then e else 17 end)) then 13 else d end*b-a= -d)}
+} {10744}
+do_test randexpr-2.2413 {
+ db eval {SELECT coalesce((select t1.a*a+t1.f | t1.d from t1 where t1.d<+t1.c*d-c*19+t1.e-(abs( -t1.e)/abs(19))), -t1.c+coalesce((select t1.b from t1 where not not (select max(t1.c) from t1)-17+e in (e,t1.c,b) and not (d in (select ( -((max(b)))) from t1 union select min(d) from t1))),t1.b) | t1.a) FROM t1 WHERE NOT (not t1.f in (select ((select abs(count(*)) from t1)-11) from t1 union select t1.a-17 from t1) or not exists(select 1 from t1 where case (abs(e)/abs(+c)) when coalesce((select max((select +(count(distinct t1.a)) from t1)) from t1 where not (e<=c*t1.a)),~(case when t1.c<=17 then e when t1.c<=t1.c then e else 17 end)) then 13 else d end*b-a= -d))}
+} {}
+do_test randexpr-2.2414 {
+ db eval {SELECT coalesce((select t1.a*a+t1.f & t1.d from t1 where t1.d<+t1.c*d-c*19+t1.e-(abs( -t1.e)/abs(19))), -t1.c+coalesce((select t1.b from t1 where not not (select max(t1.c) from t1)-17+e in (e,t1.c,b) and not (d in (select ( -((max(b)))) from t1 union select min(d) from t1))),t1.b) & t1.a) FROM t1 WHERE not t1.f in (select ((select abs(count(*)) from t1)-11) from t1 union select t1.a-17 from t1) or not exists(select 1 from t1 where case (abs(e)/abs(+c)) when coalesce((select max((select +(count(distinct t1.a)) from t1)) from t1 where not (e<=c*t1.a)),~(case when t1.c<=17 then e when t1.c<=t1.c then e else 17 end)) then 13 else d end*b-a= -d)}
+} {256}
+do_test randexpr-2.2415 {
+ db eval {SELECT case a+(abs(+13)/abs(a)) when ~(e)*(abs(b* -t1.d*19-t1.c+a-~t1.b*b-coalesce((select max(case when not exists(select 1 from t1 where d in (f,t1.c,f) or t1.c not in (13,f,t1.a)) then case when t1.a>= -t1.e then (( - -b)) else t1.b end else c end+e) from t1 where (a>11)),13)*17)/abs(e)) then 11 else c end FROM t1 WHERE 17 between a and t1.a}
+} {}
+do_test randexpr-2.2416 {
+ db eval {SELECT case a+(abs(+13)/abs(a)) when ~(e)*(abs(b* -t1.d*19-t1.c+a-~t1.b*b-coalesce((select max(case when not exists(select 1 from t1 where d in (f,t1.c,f) or t1.c not in (13,f,t1.a)) then case when t1.a>= -t1.e then (( - -b)) else t1.b end else c end+e) from t1 where (a>11)),13)*17)/abs(e)) then 11 else c end FROM t1 WHERE NOT (17 between a and t1.a)}
+} {300}
+do_test randexpr-2.2417 {
+ db eval {SELECT +~t1.f-c*case when t1.f between coalesce((select max(a) from t1 where (t1.c-17*t1.b | c=e)),t1.b) and (abs(coalesce((select max(19) from t1 where t1.b not between c+(select min(t1.d) from t1)-t1.d+d+t1.d+t1.c*t1.e and 11),t1.a))/abs(a))-c*b then 17 else 13 end FROM t1 WHERE t1.c not between (abs(+case when not -19 in (case when t1.b+~d+11+f>e then (select -cast(avg(coalesce((select 17 from t1 where (t1.b>=f)),19)) AS integer)*min(d)*(min(e))* -min(b) from t1) when 17+b not between 17 and t1.a then 11 else a end,19,(t1.e)) then f else 19 end*t1.a)/abs(b)) and 19}
+} {-4501}
+do_test randexpr-2.2418 {
+ db eval {SELECT +~t1.f-c*case when t1.f between coalesce((select max(a) from t1 where (t1.c-17*t1.b | c=e)),t1.b) and (abs(coalesce((select max(19) from t1 where t1.b not between c+(select min(t1.d) from t1)-t1.d+d+t1.d+t1.c*t1.e and 11),t1.a))/abs(a))-c*b then 17 else 13 end FROM t1 WHERE NOT (t1.c not between (abs(+case when not -19 in (case when t1.b+~d+11+f>e then (select -cast(avg(coalesce((select 17 from t1 where (t1.b>=f)),19)) AS integer)*min(d)*(min(e))* -min(b) from t1) when 17+b not between 17 and t1.a then 11 else a end,19,(t1.e)) then f else 19 end*t1.a)/abs(b)) and 19)}
+} {}
+do_test randexpr-2.2419 {
+ db eval {SELECT +~t1.f-c*case when t1.f between coalesce((select max(a) from t1 where (t1.c-17*t1.b & c=e)),t1.b) and (abs(coalesce((select max(19) from t1 where t1.b not between c+(select min(t1.d) from t1)-t1.d+d+t1.d+t1.c*t1.e and 11),t1.a))/abs(a))-c*b then 17 else 13 end FROM t1 WHERE t1.c not between (abs(+case when not -19 in (case when t1.b+~d+11+f>e then (select -cast(avg(coalesce((select 17 from t1 where (t1.b>=f)),19)) AS integer)*min(d)*(min(e))* -min(b) from t1) when 17+b not between 17 and t1.a then 11 else a end,19,(t1.e)) then f else 19 end*t1.a)/abs(b)) and 19}
+} {-4501}
+do_test randexpr-2.2420 {
+ db eval {SELECT +(abs(case t1.a when coalesce((select max(13) from t1 where d<=case when t1.b=(select abs(count(distinct t1.e)) from t1) and (select -count(distinct e) from t1) not in ( -11,e,13) then 13 else t1.e end and (not exists(select 1 from t1 where t1.d in (select count(*) from t1 union select max(f) from t1))) and 19<f and t1.f>=13 or -e=17),coalesce((select (abs(17)/abs(b))-t1.b from t1 where (19)<=t1.f),t1.d))*t1.b then 17 else 13 end)/abs(19)) FROM t1 WHERE a in (select case max(13)-~cast(avg(case when t1.d>13 or exists(select 1 from t1 where not (( -c<=e)) and (b)*t1.a in (select count(*) from t1 union select cast(avg(t1.c) AS integer)+max(f) from t1)) then t1.a else t1.c end) AS integer) when abs(count(distinct t1.d)) then count(distinct (~t1.a)) else count(distinct c)-cast(avg(e) AS integer) end from t1 union select abs(count(distinct a)*max(t1.d)) from t1)}
+} {}
+do_test randexpr-2.2421 {
+ db eval {SELECT +(abs(case t1.a when coalesce((select max(13) from t1 where d<=case when t1.b=(select abs(count(distinct t1.e)) from t1) and (select -count(distinct e) from t1) not in ( -11,e,13) then 13 else t1.e end and (not exists(select 1 from t1 where t1.d in (select count(*) from t1 union select max(f) from t1))) and 19<f and t1.f>=13 or -e=17),coalesce((select (abs(17)/abs(b))-t1.b from t1 where (19)<=t1.f),t1.d))*t1.b then 17 else 13 end)/abs(19)) FROM t1 WHERE NOT (a in (select case max(13)-~cast(avg(case when t1.d>13 or exists(select 1 from t1 where not (( -c<=e)) and (b)*t1.a in (select count(*) from t1 union select cast(avg(t1.c) AS integer)+max(f) from t1)) then t1.a else t1.c end) AS integer) when abs(count(distinct t1.d)) then count(distinct (~t1.a)) else count(distinct c)-cast(avg(e) AS integer) end from t1 union select abs(count(distinct a)*max(t1.d)) from t1))}
+} {0}
+do_test randexpr-2.2422 {
+ db eval {SELECT +coalesce((select max(f+c) from t1 where t1.b in (select +max(b+t1.b) from t1 union select cast(avg(d-b | f-11-t1.b | coalesce((select ~t1.a from t1 where (t1.a=case when not exists(select 1 from t1 where 13 not in (t1.b,t1.e,t1.f)) then (abs(t1.d)/abs(c)) when c<>17 then c else 19 end)),t1.c)) AS integer) from t1) and t1.e not in (b,d,(13))),t1.b) FROM t1 WHERE (select cast(avg(~t1.f) AS integer) from t1) not in ( -c,17,11*c)}
+} {200}
+do_test randexpr-2.2423 {
+ db eval {SELECT +coalesce((select max(f+c) from t1 where t1.b in (select +max(b+t1.b) from t1 union select cast(avg(d-b | f-11-t1.b | coalesce((select ~t1.a from t1 where (t1.a=case when not exists(select 1 from t1 where 13 not in (t1.b,t1.e,t1.f)) then (abs(t1.d)/abs(c)) when c<>17 then c else 19 end)),t1.c)) AS integer) from t1) and t1.e not in (b,d,(13))),t1.b) FROM t1 WHERE NOT ((select cast(avg(~t1.f) AS integer) from t1) not in ( -c,17,11*c))}
+} {}
+do_test randexpr-2.2424 {
+ db eval {SELECT +coalesce((select max(f+c) from t1 where t1.b in (select +max(b+t1.b) from t1 union select cast(avg(d-b & f-11-t1.b & coalesce((select ~t1.a from t1 where (t1.a=case when not exists(select 1 from t1 where 13 not in (t1.b,t1.e,t1.f)) then (abs(t1.d)/abs(c)) when c<>17 then c else 19 end)),t1.c)) AS integer) from t1) and t1.e not in (b,d,(13))),t1.b) FROM t1 WHERE (select cast(avg(~t1.f) AS integer) from t1) not in ( -c,17,11*c)}
+} {200}
+do_test randexpr-2.2425 {
+ db eval {SELECT t1.e*case when ((13)-13-13-t1.d+t1.c*b>11) then b when case when (t1.a*b not in (t1.a,t1.b,t1.f)) then 11+e else t1.f end<= -f or f in (t1.a,11,13) or exists(select 1 from t1 where not exists(select 1 from t1 where f in (f,d,t1.e))) then t1.d else b end FROM t1 WHERE coalesce((select 19 from t1 where 13-t1.b*c-t1.a+case when case when coalesce((select +t1.b from t1 where a<>b),13) in ((b),t1.f,b) and not t1.b in (select -cast(avg(13) AS integer) from t1 union select cast(avg(11) AS integer) from t1) or a>=13 then (abs(t1.b+a)/abs(11)) else t1.e end-17+t1.d<>b then (19) else f end=e),13)>=t1.c}
+} {}
+do_test randexpr-2.2426 {
+ db eval {SELECT t1.e*case when ((13)-13-13-t1.d+t1.c*b>11) then b when case when (t1.a*b not in (t1.a,t1.b,t1.f)) then 11+e else t1.f end<= -f or f in (t1.a,11,13) or exists(select 1 from t1 where not exists(select 1 from t1 where f in (f,d,t1.e))) then t1.d else b end FROM t1 WHERE NOT (coalesce((select 19 from t1 where 13-t1.b*c-t1.a+case when case when coalesce((select +t1.b from t1 where a<>b),13) in ((b),t1.f,b) and not t1.b in (select -cast(avg(13) AS integer) from t1 union select cast(avg(11) AS integer) from t1) or a>=13 then (abs(t1.b+a)/abs(11)) else t1.e end-17+t1.d<>b then (19) else f end=e),13)>=t1.c)}
+} {100000}
+do_test randexpr-2.2427 {
+ db eval {SELECT coalesce((select max(d) from t1 where 19+case t1.b when t1.a-a then (abs(case when (e>=case t1.a when coalesce((select max(t1.d) from t1 where (select case -max(c)+cast(avg(t1.a) AS integer) when cast(avg(t1.a) AS integer) then cast(avg(19) AS integer) else cast(avg(t1.b) AS integer) end from t1)>t1.c),coalesce((select max(d) from t1 where 19<>17 and d<=b), -(t1.c)))+e then c else t1.d end+b) then b when 19 between c and 17 then 11 else e end)/abs( -t1.b)) else t1.a end+13>=d),d) FROM t1 WHERE a=case when t1.f in (select (max(f)-++(min(t1.a))-max(19)-count(*)) from t1 union select +max(t1.b) from t1) then t1.b*19*19 when t1.f>d then 17-d else t1.f end and exists(select 1 from t1 where not exists(select 1 from t1 where d in (select count(distinct 11)+max(a) from t1 union select cast(avg(13) AS integer) from t1) or 19 not in (t1.b,c,13)))}
+} {}
+do_test randexpr-2.2428 {
+ db eval {SELECT coalesce((select max(d) from t1 where 19+case t1.b when t1.a-a then (abs(case when (e>=case t1.a when coalesce((select max(t1.d) from t1 where (select case -max(c)+cast(avg(t1.a) AS integer) when cast(avg(t1.a) AS integer) then cast(avg(19) AS integer) else cast(avg(t1.b) AS integer) end from t1)>t1.c),coalesce((select max(d) from t1 where 19<>17 and d<=b), -(t1.c)))+e then c else t1.d end+b) then b when 19 between c and 17 then 11 else e end)/abs( -t1.b)) else t1.a end+13>=d),d) FROM t1 WHERE NOT (a=case when t1.f in (select (max(f)-++(min(t1.a))-max(19)-count(*)) from t1 union select +max(t1.b) from t1) then t1.b*19*19 when t1.f>d then 17-d else t1.f end and exists(select 1 from t1 where not exists(select 1 from t1 where d in (select count(distinct 11)+max(a) from t1 union select cast(avg(13) AS integer) from t1) or 19 not in (t1.b,c,13))))}
+} {400}
+do_test randexpr-2.2429 {
+ db eval {SELECT coalesce((select max(case t1.c | b-t1.d+13 when 17 then c else 13 end) from t1 where case when exists(select 1 from t1 where b<>t1.c) then t1.d when a not between (abs(t1.d)/abs((t1.b))) and (t1.c) or (a in (select ~max(((17))) from t1 union select case -(count(distinct -t1.c)) when count(distinct t1.c) then (count(*)) else max(f) end from t1)) and t1.f>19 or a<>11 then t1.b else t1.b end>(11)),13)+b*(b) FROM t1 WHERE case when not exists(select 1 from t1 where (19<>11+t1.b*c+d)) and 13<>b or t1.d between t1.c and b and f between t1.b and -a or 19 between 19 and 17 or t1.e not between e and t1.d then ~13 else coalesce((select max(t1.b) from t1 where f=a),(a)) end in (select -( -+count(distinct 11)-count(*))*count(distinct ( -t1.c))+(count(distinct t1.c))+max(17)-count(*) from t1 union select count(*) from t1)}
+} {}
+do_test randexpr-2.2430 {
+ db eval {SELECT coalesce((select max(case t1.c | b-t1.d+13 when 17 then c else 13 end) from t1 where case when exists(select 1 from t1 where b<>t1.c) then t1.d when a not between (abs(t1.d)/abs((t1.b))) and (t1.c) or (a in (select ~max(((17))) from t1 union select case -(count(distinct -t1.c)) when count(distinct t1.c) then (count(*)) else max(f) end from t1)) and t1.f>19 or a<>11 then t1.b else t1.b end>(11)),13)+b*(b) FROM t1 WHERE NOT (case when not exists(select 1 from t1 where (19<>11+t1.b*c+d)) and 13<>b or t1.d between t1.c and b and f between t1.b and -a or 19 between 19 and 17 or t1.e not between e and t1.d then ~13 else coalesce((select max(t1.b) from t1 where f=a),(a)) end in (select -( -+count(distinct 11)-count(*))*count(distinct ( -t1.c))+(count(distinct t1.c))+max(17)-count(*) from t1 union select count(*) from t1))}
+} {40013}
+do_test randexpr-2.2431 {
+ db eval {SELECT coalesce((select max(case t1.c & b-t1.d+13 when 17 then c else 13 end) from t1 where case when exists(select 1 from t1 where b<>t1.c) then t1.d when a not between (abs(t1.d)/abs((t1.b))) and (t1.c) or (a in (select ~max(((17))) from t1 union select case -(count(distinct -t1.c)) when count(distinct t1.c) then (count(*)) else max(f) end from t1)) and t1.f>19 or a<>11 then t1.b else t1.b end>(11)),13)+b*(b) FROM t1 WHERE NOT (case when not exists(select 1 from t1 where (19<>11+t1.b*c+d)) and 13<>b or t1.d between t1.c and b and f between t1.b and -a or 19 between 19 and 17 or t1.e not between e and t1.d then ~13 else coalesce((select max(t1.b) from t1 where f=a),(a)) end in (select -( -+count(distinct 11)-count(*))*count(distinct ( -t1.c))+(count(distinct t1.c))+max(17)-count(*) from t1 union select count(*) from t1))}
+} {40013}
+do_test randexpr-2.2432 {
+ db eval {SELECT coalesce((select max(coalesce((select max(11) from t1 where t1.b< -t1.b),e)+coalesce((select t1.b from t1 where not case when ~case when -17+t1.d> - -t1.d then t1.b when t1.b between 13 and c or t1.a>= -f then t1.b else t1.e end+t1.c<= -c then 19 else t1.f end not in (c,d,e) or t1.f not between t1.b and 19 and 13>= -t1.f or 13 in (e,(t1.b),11)),t1.b)) from t1 where -(f) not in (f,(t1.e),b)),t1.f) FROM t1 WHERE f in (select f from t1 union select t1.f*t1.b from t1)}
+} {700}
+do_test randexpr-2.2433 {
+ db eval {SELECT coalesce((select max(coalesce((select max(11) from t1 where t1.b< -t1.b),e)+coalesce((select t1.b from t1 where not case when ~case when -17+t1.d> - -t1.d then t1.b when t1.b between 13 and c or t1.a>= -f then t1.b else t1.e end+t1.c<= -c then 19 else t1.f end not in (c,d,e) or t1.f not between t1.b and 19 and 13>= -t1.f or 13 in (e,(t1.b),11)),t1.b)) from t1 where -(f) not in (f,(t1.e),b)),t1.f) FROM t1 WHERE NOT (f in (select f from t1 union select t1.f*t1.b from t1))}
+} {}
+do_test randexpr-2.2434 {
+ db eval {SELECT ( -+(a)*(abs(case coalesce((select max(d) from t1 where t1.d<>c*(select count(distinct e*coalesce((select 13-17 from t1 where not exists(select 1 from t1 where t1.a in (select f from t1 union select (a) from t1))),t1.f)+(t1.c)) from t1) | t1.e*19 and not t1.a<13),t1.b)+t1.b when t1.d then (t1.f) else t1.c end)/abs(t1.f))-13*t1.f) FROM t1 WHERE f>=t1.a+ -(select (count(*))-(~case cast(avg(t1.b-13-e) AS integer) when count(*) then (max(t1.f*case 13 when 11 then 13 else c end))- -cast(avg(t1.f) AS integer)*count(*)-min(19) else count(distinct d) end)+min(t1.d) | -max(t1.b) from t1) | t1.b*17+t1.d+t1.b-d}
+} {}
+do_test randexpr-2.2435 {
+ db eval {SELECT ( -+(a)*(abs(case coalesce((select max(d) from t1 where t1.d<>c*(select count(distinct e*coalesce((select 13-17 from t1 where not exists(select 1 from t1 where t1.a in (select f from t1 union select (a) from t1))),t1.f)+(t1.c)) from t1) | t1.e*19 and not t1.a<13),t1.b)+t1.b when t1.d then (t1.f) else t1.c end)/abs(t1.f))-13*t1.f) FROM t1 WHERE NOT (f>=t1.a+ -(select (count(*))-(~case cast(avg(t1.b-13-e) AS integer) when count(*) then (max(t1.f*case 13 when 11 then 13 else c end))- -cast(avg(t1.f) AS integer)*count(*)-min(19) else count(distinct d) end)+min(t1.d) | -max(t1.b) from t1) | t1.b*17+t1.d+t1.b-d)}
+} {-7800}
+do_test randexpr-2.2436 {
+ db eval {SELECT ( -+(a)*(abs(case coalesce((select max(d) from t1 where t1.d<>c*(select count(distinct e*coalesce((select 13-17 from t1 where not exists(select 1 from t1 where t1.a in (select f from t1 union select (a) from t1))),t1.f)+(t1.c)) from t1) & t1.e*19 and not t1.a<13),t1.b)+t1.b when t1.d then (t1.f) else t1.c end)/abs(t1.f))-13*t1.f) FROM t1 WHERE NOT (f>=t1.a+ -(select (count(*))-(~case cast(avg(t1.b-13-e) AS integer) when count(*) then (max(t1.f*case 13 when 11 then 13 else c end))- -cast(avg(t1.f) AS integer)*count(*)-min(19) else count(distinct d) end)+min(t1.d) | -max(t1.b) from t1) | t1.b*17+t1.d+t1.b-d)}
+} {-7800}
+do_test randexpr-2.2437 {
+ db eval {SELECT coalesce((select t1.a from t1 where c in (select a from t1 union select t1.a*f from t1) and t1.b in (select (select count(*) from t1)*11 from t1 union select -13 from t1)),13) FROM t1 WHERE (d<t1.b)}
+} {}
+do_test randexpr-2.2438 {
+ db eval {SELECT coalesce((select t1.a from t1 where c in (select a from t1 union select t1.a*f from t1) and t1.b in (select (select count(*) from t1)*11 from t1 union select -13 from t1)),13) FROM t1 WHERE NOT ((d<t1.b))}
+} {13}
+do_test randexpr-2.2439 {
+ db eval {SELECT case when (not exists(select 1 from t1 where a<=case a | e-case t1.f when c then e else 19 end | t1.b when t1.c then t1.e else 19 end+d)) or f between a and b and (t1.f) not in (d,t1.e,11) then case 17+e | t1.c when 19 then 13 else -(19) end | 11 else a end-t1.f-f*t1.c FROM t1 WHERE case when t1.b in ( - -case when case when t1.f-case when 19<=c then a else 19 end between 13 and t1.d and not a not in ((f),d,f) then t1.c-a when t1.d not in ( -b,c,11) then 13 else f end>=17 then d when f<=t1.c then t1.a else d end,t1.e,e) or not 19>c then t1.c-19 else 13 end<>t1.c}
+} {-180500}
+do_test randexpr-2.2440 {
+ db eval {SELECT case when (not exists(select 1 from t1 where a<=case a | e-case t1.f when c then e else 19 end | t1.b when t1.c then t1.e else 19 end+d)) or f between a and b and (t1.f) not in (d,t1.e,11) then case 17+e | t1.c when 19 then 13 else -(19) end | 11 else a end-t1.f-f*t1.c FROM t1 WHERE NOT (case when t1.b in ( - -case when case when t1.f-case when 19<=c then a else 19 end between 13 and t1.d and not a not in ((f),d,f) then t1.c-a when t1.d not in ( -b,c,11) then 13 else f end>=17 then d when f<=t1.c then t1.a else d end,t1.e,e) or not 19>c then t1.c-19 else 13 end<>t1.c)}
+} {}
+do_test randexpr-2.2441 {
+ db eval {SELECT case when (not exists(select 1 from t1 where a<=case a & e-case t1.f when c then e else 19 end & t1.b when t1.c then t1.e else 19 end+d)) or f between a and b and (t1.f) not in (d,t1.e,11) then case 17+e & t1.c when 19 then 13 else -(19) end & 11 else a end-t1.f-f*t1.c FROM t1 WHERE case when t1.b in ( - -case when case when t1.f-case when 19<=c then a else 19 end between 13 and t1.d and not a not in ((f),d,f) then t1.c-a when t1.d not in ( -b,c,11) then 13 else f end>=17 then d when f<=t1.c then t1.a else d end,t1.e,e) or not 19>c then t1.c-19 else 13 end<>t1.c}
+} {-180500}
+do_test randexpr-2.2442 {
+ db eval {SELECT coalesce((select d-(abs(case when +coalesce((select 19 from t1 where not exists(select 1 from t1 where d | f in (select ~case count(distinct f) when ( -(cast(avg((( -19))) AS integer))) then (count(*)) else count(distinct 17) end*(max(t1.d)) from t1 union select min(b) from t1))),13) | t1.b+t1.e in (13,(t1.b),t1.a) then t1.a when a in (select t1.f from t1 union select t1.b from t1) then t1.e else a end)/abs(f))-t1.e from t1 where not exists(select 1 from t1 where not 19 in (select t1.b from t1 union select t1.f from t1) or 13 in (select e from t1 union select e from t1))),f) FROM t1 WHERE not exists(select 1 from t1 where case when not exists(select 1 from t1 where a<+case c when (abs(t1.b)/abs(e))+t1.b-b-t1.b then (t1.d)*t1.c else t1.d end) then b else 19 end in (select -count(distinct c)*(max(f)) | ~+case min(t1.a) when cast(avg(c) AS integer) then cast(avg(t1.a) AS integer) | count(distinct t1.d)* -count(distinct t1.e) else ( -count(*)) end | -cast(avg(t1.d) AS integer)+min(a)*count(distinct b) from t1 union select max(13) from t1))}
+} {600}
+do_test randexpr-2.2443 {
+ db eval {SELECT coalesce((select d-(abs(case when +coalesce((select 19 from t1 where not exists(select 1 from t1 where d | f in (select ~case count(distinct f) when ( -(cast(avg((( -19))) AS integer))) then (count(*)) else count(distinct 17) end*(max(t1.d)) from t1 union select min(b) from t1))),13) | t1.b+t1.e in (13,(t1.b),t1.a) then t1.a when a in (select t1.f from t1 union select t1.b from t1) then t1.e else a end)/abs(f))-t1.e from t1 where not exists(select 1 from t1 where not 19 in (select t1.b from t1 union select t1.f from t1) or 13 in (select e from t1 union select e from t1))),f) FROM t1 WHERE NOT (not exists(select 1 from t1 where case when not exists(select 1 from t1 where a<+case c when (abs(t1.b)/abs(e))+t1.b-b-t1.b then (t1.d)*t1.c else t1.d end) then b else 19 end in (select -count(distinct c)*(max(f)) | ~+case min(t1.a) when cast(avg(c) AS integer) then cast(avg(t1.a) AS integer) | count(distinct t1.d)* -count(distinct t1.e) else ( -count(*)) end | -cast(avg(t1.d) AS integer)+min(a)*count(distinct b) from t1 union select max(13) from t1)))}
+} {}
+do_test randexpr-2.2444 {
+ db eval {SELECT coalesce((select d-(abs(case when +coalesce((select 19 from t1 where not exists(select 1 from t1 where d & f in (select ~case count(distinct f) when ( -(cast(avg((( -19))) AS integer))) then (count(*)) else count(distinct 17) end*(max(t1.d)) from t1 union select min(b) from t1))),13) & t1.b+t1.e in (13,(t1.b),t1.a) then t1.a when a in (select t1.f from t1 union select t1.b from t1) then t1.e else a end)/abs(f))-t1.e from t1 where not exists(select 1 from t1 where not 19 in (select t1.b from t1 union select t1.f from t1) or 13 in (select e from t1 union select e from t1))),f) FROM t1 WHERE not exists(select 1 from t1 where case when not exists(select 1 from t1 where a<+case c when (abs(t1.b)/abs(e))+t1.b-b-t1.b then (t1.d)*t1.c else t1.d end) then b else 19 end in (select -count(distinct c)*(max(f)) | ~+case min(t1.a) when cast(avg(c) AS integer) then cast(avg(t1.a) AS integer) | count(distinct t1.d)* -count(distinct t1.e) else ( -count(*)) end | -cast(avg(t1.d) AS integer)+min(a)*count(distinct b) from t1 union select max(13) from t1))}
+} {600}
+do_test randexpr-2.2445 {
+ db eval {SELECT (t1.e)+t1.c-coalesce((select max((abs(coalesce((select case when f>=(abs(coalesce((select max(a) from t1 where 11*(t1.f)*a*t1.d=11),t1.b))/abs(t1.d))+t1.b then c when not exists(select 1 from t1 where t1.c<>b) then 13 else 11 end from t1 where (13 not in (f,t1.c,13))),b)+t1.d)/abs(t1.f))) from t1 where b<>t1.a),t1.a) | t1.d FROM t1 WHERE ~a<>a or d<>t1.e}
+} {927}
+do_test randexpr-2.2446 {
+ db eval {SELECT (t1.e)+t1.c-coalesce((select max((abs(coalesce((select case when f>=(abs(coalesce((select max(a) from t1 where 11*(t1.f)*a*t1.d=11),t1.b))/abs(t1.d))+t1.b then c when not exists(select 1 from t1 where t1.c<>b) then 13 else 11 end from t1 where (13 not in (f,t1.c,13))),b)+t1.d)/abs(t1.f))) from t1 where b<>t1.a),t1.a) | t1.d FROM t1 WHERE NOT (~a<>a or d<>t1.e)}
+} {}
+do_test randexpr-2.2447 {
+ db eval {SELECT (t1.e)+t1.c-coalesce((select max((abs(coalesce((select case when f>=(abs(coalesce((select max(a) from t1 where 11*(t1.f)*a*t1.d=11),t1.b))/abs(t1.d))+t1.b then c when not exists(select 1 from t1 where t1.c<>b) then 13 else 11 end from t1 where (13 not in (f,t1.c,13))),b)+t1.d)/abs(t1.f))) from t1 where b<>t1.a),t1.a) & t1.d FROM t1 WHERE ~a<>a or d<>t1.e}
+} {272}
+do_test randexpr-2.2448 {
+ db eval {SELECT case when coalesce((select 11 from t1 where exists(select 1 from t1 where t1.a<= -19)),t1.c-t1.e*e-19-t1.d-t1.e-~a*coalesce((select max(b) from t1 where b>(abs(+c+case c when 11 then t1.f else 11 end)/abs(b))),t1.e)-f+t1.c+19+e-t1.e)<=t1.f then e else c end FROM t1 WHERE (abs(t1.d)/abs(~b)) in (select count(distinct case when t1.c+t1.f<coalesce((select b from t1 where ((select case min( -d+d+f+d) when ~max(t1.c) then case max(d) when -( - -min(d)) then cast(avg(t1.d) AS integer) else (max( -c)) end else cast(avg(t1.e) AS integer) end from t1)<t1.b)),17) or t1.b=f then case when t1.f<>e and ((d) between t1.a and d) then t1.b else 13 end else 11 end) from t1 union select count(*) from t1)}
+} {500}
+do_test randexpr-2.2449 {
+ db eval {SELECT case when coalesce((select 11 from t1 where exists(select 1 from t1 where t1.a<= -19)),t1.c-t1.e*e-19-t1.d-t1.e-~a*coalesce((select max(b) from t1 where b>(abs(+c+case c when 11 then t1.f else 11 end)/abs(b))),t1.e)-f+t1.c+19+e-t1.e)<=t1.f then e else c end FROM t1 WHERE NOT ((abs(t1.d)/abs(~b)) in (select count(distinct case when t1.c+t1.f<coalesce((select b from t1 where ((select case min( -d+d+f+d) when ~max(t1.c) then case max(d) when -( - -min(d)) then cast(avg(t1.d) AS integer) else (max( -c)) end else cast(avg(t1.e) AS integer) end from t1)<t1.b)),17) or t1.b=f then case when t1.f<>e and ((d) between t1.a and d) then t1.b else 13 end else 11 end) from t1 union select count(*) from t1))}
+} {}
+do_test randexpr-2.2450 {
+ db eval {SELECT case when 19*case when case when t1.e>((t1.d)) and 11>t1.d then -17 else e end in (select count(distinct a) from t1 union select min(d) from t1) then (d) else e end | t1.c+a in (select count(*) from t1 union select case +(max(19))+count(distinct -t1.d) when min(19) then cast(avg(e) AS integer) else cast(avg(t1.a) AS integer) end from t1) and 17 between 17 and t1.b then -(t1.e) when b between t1.c and 13 then b else 11 end+t1.f*(t1.d)+t1.c FROM t1 WHERE ~+e+11>b}
+} {}
+do_test randexpr-2.2451 {
+ db eval {SELECT case when 19*case when case when t1.e>((t1.d)) and 11>t1.d then -17 else e end in (select count(distinct a) from t1 union select min(d) from t1) then (d) else e end | t1.c+a in (select count(*) from t1 union select case +(max(19))+count(distinct -t1.d) when min(19) then cast(avg(e) AS integer) else cast(avg(t1.a) AS integer) end from t1) and 17 between 17 and t1.b then -(t1.e) when b between t1.c and 13 then b else 11 end+t1.f*(t1.d)+t1.c FROM t1 WHERE NOT (~+e+11>b)}
+} {240311}
+do_test randexpr-2.2452 {
+ db eval {SELECT case when 19*case when case when t1.e>((t1.d)) and 11>t1.d then -17 else e end in (select count(distinct a) from t1 union select min(d) from t1) then (d) else e end & t1.c+a in (select count(*) from t1 union select case +(max(19))+count(distinct -t1.d) when min(19) then cast(avg(e) AS integer) else cast(avg(t1.a) AS integer) end from t1) and 17 between 17 and t1.b then -(t1.e) when b between t1.c and 13 then b else 11 end+t1.f*(t1.d)+t1.c FROM t1 WHERE NOT (~+e+11>b)}
+} {240311}
+do_test randexpr-2.2453 {
+ db eval {SELECT coalesce((select max((e)) from t1 where not (((abs(c)/abs((abs(t1.e)/abs(t1.d)))) between d and a+t1.f+19-a or (not exists(select 1 from t1 where f*11 in (19,t1.d,case when (11 in (19,17,19) and t1.a>t1.d) then t1.e-19 else t1.e end+f))) and a<11) and 19<>a)),c+d) FROM t1 WHERE 17+case b*f when b then a+e else d end*t1.b<=case when not f=11 then c when t1.e<f-coalesce((select max(d) from t1 where e in (select (select count(*) from t1) | coalesce((select e from t1 where t1.d>d and exists(select 1 from t1 where 19 in (t1.e,t1.a,(e)))),a)*c from t1 union select f from t1)),t1.a)+f+17 then t1.c else b end}
+} {}
+do_test randexpr-2.2454 {
+ db eval {SELECT coalesce((select max((e)) from t1 where not (((abs(c)/abs((abs(t1.e)/abs(t1.d)))) between d and a+t1.f+19-a or (not exists(select 1 from t1 where f*11 in (19,t1.d,case when (11 in (19,17,19) and t1.a>t1.d) then t1.e-19 else t1.e end+f))) and a<11) and 19<>a)),c+d) FROM t1 WHERE NOT (17+case b*f when b then a+e else d end*t1.b<=case when not f=11 then c when t1.e<f-coalesce((select max(d) from t1 where e in (select (select count(*) from t1) | coalesce((select e from t1 where t1.d>d and exists(select 1 from t1 where 19 in (t1.e,t1.a,(e)))),a)*c from t1 union select f from t1)),t1.a)+f+17 then t1.c else b end)}
+} {500}
+do_test randexpr-2.2455 {
+ db eval {SELECT ((select cast(avg(case a when t1.d then (abs(coalesce((select coalesce((select coalesce((select e-a from t1 where not exists(select 1 from t1 where t1.f>11 or t1.a= -f)), -t1.a) from t1 where 11<= -t1.f),t1.f)-13 from t1 where not exists(select 1 from t1 where t1.e in (f,t1.b,d))),t1.d))/abs(11)) else (17) end) AS integer)+abs( -count(distinct e)+count(*)) | -count(*)*+min(e)*count(distinct b)*cast(avg(11) AS integer) from t1)) FROM t1 WHERE d= -19}
+} {}
+do_test randexpr-2.2456 {
+ db eval {SELECT ((select cast(avg(case a when t1.d then (abs(coalesce((select coalesce((select coalesce((select e-a from t1 where not exists(select 1 from t1 where t1.f>11 or t1.a= -f)), -t1.a) from t1 where 11<= -t1.f),t1.f)-13 from t1 where not exists(select 1 from t1 where t1.e in (f,t1.b,d))),t1.d))/abs(11)) else (17) end) AS integer)+abs( -count(distinct e)+count(*)) | -count(*)*+min(e)*count(distinct b)*cast(avg(11) AS integer) from t1)) FROM t1 WHERE NOT (d= -19)}
+} {-5483}
+do_test randexpr-2.2457 {
+ db eval {SELECT ((select cast(avg(case a when t1.d then (abs(coalesce((select coalesce((select coalesce((select e-a from t1 where not exists(select 1 from t1 where t1.f>11 or t1.a= -f)), -t1.a) from t1 where 11<= -t1.f),t1.f)-13 from t1 where not exists(select 1 from t1 where t1.e in (f,t1.b,d))),t1.d))/abs(11)) else (17) end) AS integer)+abs( -count(distinct e)+count(*)) & -count(*)*+min(e)*count(distinct b)*cast(avg(11) AS integer) from t1)) FROM t1 WHERE NOT (d= -19)}
+} {0}
+do_test randexpr-2.2458 {
+ db eval {SELECT 11+t1.e*c | t1.a+t1.a*coalesce((select max(b*t1.d*case when c in (select t1.b from t1 union select case when (t1.b>=d) then 19 else case when ((((t1.a<>t1.b)))) then b when f<=11 then case when e not in (19,t1.d,a) then coalesce((select 11 from t1 where e between a and e),e) when 11<=e then t1.a else 13 end else t1.c end end from t1) then 19 else (t1.d) end-a) from t1 where (t1.d)<= -e),t1.f) FROM t1 WHERE ((f not between t1.a and (abs(19)/abs(17 | (a))) and ((exists(select 1 from t1 where coalesce((select case e*(17) when b-(abs((abs(11)/abs(t1.c+e+t1.c)))/abs(17-((t1.f-t1.e | 11)))) then e else a end from t1 where t1.c not in (19,t1.b,t1.d)),c)=b)))))}
+} {}
+do_test randexpr-2.2459 {
+ db eval {SELECT 11+t1.e*c | t1.a+t1.a*coalesce((select max(b*t1.d*case when c in (select t1.b from t1 union select case when (t1.b>=d) then 19 else case when ((((t1.a<>t1.b)))) then b when f<=11 then case when e not in (19,t1.d,a) then coalesce((select 11 from t1 where e between a and e),e) when 11<=e then t1.a else 13 end else t1.c end end from t1) then 19 else (t1.d) end-a) from t1 where (t1.d)<= -e),t1.f) FROM t1 WHERE NOT (((f not between t1.a and (abs(19)/abs(17 | (a))) and ((exists(select 1 from t1 where coalesce((select case e*(17) when b-(abs((abs(11)/abs(t1.c+e+t1.c)))/abs(17-((t1.f-t1.e | 11)))) then e else a end from t1 where t1.c not in (19,t1.b,t1.d)),c)=b))))))}
+} {191487}
+do_test randexpr-2.2460 {
+ db eval {SELECT 11+t1.e*c & t1.a+t1.a*coalesce((select max(b*t1.d*case when c in (select t1.b from t1 union select case when (t1.b>=d) then 19 else case when ((((t1.a<>t1.b)))) then b when f<=11 then case when e not in (19,t1.d,a) then coalesce((select 11 from t1 where e between a and e),e) when 11<=e then t1.a else 13 end else t1.c end end from t1) then 19 else (t1.d) end-a) from t1 where (t1.d)<= -e),t1.f) FROM t1 WHERE NOT (((f not between t1.a and (abs(19)/abs(17 | (a))) and ((exists(select 1 from t1 where coalesce((select case e*(17) when b-(abs((abs(11)/abs(t1.c+e+t1.c)))/abs(17-((t1.f-t1.e | 11)))) then e else a end from t1 where t1.c not in (19,t1.b,t1.d)),c)=b))))))}
+} {18624}
+do_test randexpr-2.2461 {
+ db eval {SELECT (select (case +~ -abs(count(distinct + -(select (case ~((min(t1.b)+max(a))+count(*))*cast(avg(e) AS integer) when count(distinct (17)) then count(distinct t1.d) else max(a) end) from t1)*(17)-t1.f+case (abs( -t1.e)/abs(17)) when t1.f then b else 11 end)) | max(c)-case max(f) when (max(t1.f)) then min(c) else cast(avg((t1.d)) AS integer) end when count(*) then min(t1.a) else cast(avg(t1.c) AS integer) end) from t1) FROM t1 WHERE 13 in ((select ~ -abs((abs( -max(c)+count(distinct c)-~case +max(f) when min(13) then count(distinct t1.e) else count(*) end-((cast(avg(t1.c) AS integer)))))) from t1),~t1.c-t1.e,case when exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (select case when t1.c<d or e>a then b else (c) end+t1.d from t1 union select -t1.e from t1)) or 11 not between b and d or e>e) then t1.f else t1.f end*t1.b- -t1.b)}
+} {}
+do_test randexpr-2.2462 {
+ db eval {SELECT (select (case +~ -abs(count(distinct + -(select (case ~((min(t1.b)+max(a))+count(*))*cast(avg(e) AS integer) when count(distinct (17)) then count(distinct t1.d) else max(a) end) from t1)*(17)-t1.f+case (abs( -t1.e)/abs(17)) when t1.f then b else 11 end)) | max(c)-case max(f) when (max(t1.f)) then min(c) else cast(avg((t1.d)) AS integer) end when count(*) then min(t1.a) else cast(avg(t1.c) AS integer) end) from t1) FROM t1 WHERE NOT (13 in ((select ~ -abs((abs( -max(c)+count(distinct c)-~case +max(f) when min(13) then count(distinct t1.e) else count(*) end-((cast(avg(t1.c) AS integer)))))) from t1),~t1.c-t1.e,case when exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (select case when t1.c<d or e>a then b else (c) end+t1.d from t1 union select -t1.e from t1)) or 11 not between b and d or e>e) then t1.f else t1.f end*t1.b- -t1.b))}
+} {300}
+do_test randexpr-2.2463 {
+ db eval {SELECT (select (case +~ -abs(count(distinct + -(select (case ~((min(t1.b)+max(a))+count(*))*cast(avg(e) AS integer) when count(distinct (17)) then count(distinct t1.d) else max(a) end) from t1)*(17)-t1.f+case (abs( -t1.e)/abs(17)) when t1.f then b else 11 end)) & max(c)-case max(f) when (max(t1.f)) then min(c) else cast(avg((t1.d)) AS integer) end when count(*) then min(t1.a) else cast(avg(t1.c) AS integer) end) from t1) FROM t1 WHERE NOT (13 in ((select ~ -abs((abs( -max(c)+count(distinct c)-~case +max(f) when min(13) then count(distinct t1.e) else count(*) end-((cast(avg(t1.c) AS integer)))))) from t1),~t1.c-t1.e,case when exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (select case when t1.c<d or e>a then b else (c) end+t1.d from t1 union select -t1.e from t1)) or 11 not between b and d or e>e) then t1.f else t1.f end*t1.b- -t1.b))}
+} {300}
+do_test randexpr-2.2464 {
+ db eval {SELECT case when (abs(~(t1.e))/abs(case when (( -13<d or b not in (t1.d,a,19)) and t1.b<d) or a<13 then +~c else 17 end)) in (select cast(avg(t1.b | -t1.f) AS integer)- - -case (~min(t1.e)+count(*)) when -max(13) then max(t1.c) else -cast(avg(11) AS integer) end from t1 union select cast(avg(11) AS integer) from t1) then t1.e when not exists(select 1 from t1 where (19 not between d and 13)) then 19 else c end-t1.c FROM t1 WHERE -t1.a-+case when c between b and t1.a then 19 else t1.b end | (coalesce((select t1.f from t1 where case ~((abs(case case t1.e when t1.b then -13 else f end when t1.a then t1.f else t1.b end+(e)-t1.b)/abs(c))+t1.d) when 19 then 11 else a end not in ( - -13,a,11)),b))+t1.b+e in (select t1.d from t1 union select d from t1)}
+} {}
+do_test randexpr-2.2465 {
+ db eval {SELECT case when (abs(~(t1.e))/abs(case when (( -13<d or b not in (t1.d,a,19)) and t1.b<d) or a<13 then +~c else 17 end)) in (select cast(avg(t1.b | -t1.f) AS integer)- - -case (~min(t1.e)+count(*)) when -max(13) then max(t1.c) else -cast(avg(11) AS integer) end from t1 union select cast(avg(11) AS integer) from t1) then t1.e when not exists(select 1 from t1 where (19 not between d and 13)) then 19 else c end-t1.c FROM t1 WHERE NOT ( -t1.a-+case when c between b and t1.a then 19 else t1.b end | (coalesce((select t1.f from t1 where case ~((abs(case case t1.e when t1.b then -13 else f end when t1.a then t1.f else t1.b end+(e)-t1.b)/abs(c))+t1.d) when 19 then 11 else a end not in ( - -13,a,11)),b))+t1.b+e in (select t1.d from t1 union select d from t1))}
+} {0}
+do_test randexpr-2.2466 {
+ db eval {SELECT case when (abs(~(t1.e))/abs(case when (( -13<d or b not in (t1.d,a,19)) and t1.b<d) or a<13 then +~c else 17 end)) in (select cast(avg(t1.b & -t1.f) AS integer)- - -case (~min(t1.e)+count(*)) when -max(13) then max(t1.c) else -cast(avg(11) AS integer) end from t1 union select cast(avg(11) AS integer) from t1) then t1.e when not exists(select 1 from t1 where (19 not between d and 13)) then 19 else c end-t1.c FROM t1 WHERE NOT ( -t1.a-+case when c between b and t1.a then 19 else t1.b end | (coalesce((select t1.f from t1 where case ~((abs(case case t1.e when t1.b then -13 else f end when t1.a then t1.f else t1.b end+(e)-t1.b)/abs(c))+t1.d) when 19 then 11 else a end not in ( - -13,a,11)),b))+t1.b+e in (select t1.d from t1 union select d from t1))}
+} {0}
+do_test randexpr-2.2467 {
+ db eval {SELECT case when (select -case abs(min(c)) when count(distinct a)-min(t1.c) then -~abs(max(c)) | min( -13) | -count(*)+min(d)*count(*) else -(count(distinct t1.f)) end from t1) in (select count(distinct b)+max(f) from t1 union select cast(avg(19) AS integer) from t1) then (t1.d) when b<=case d when t1.d then t1.a else t1.d end then coalesce((select t1.d from t1 where not exists(select 1 from t1 where t1.a not in (11,e,13))),13) else 17 end FROM t1 WHERE t1.f in (select count(*)-max(case f+(abs(e-17*(abs(11+17+e)/abs(f)) | t1.e*b+t1.d)/abs(e))+t1.a when t1.a then -t1.d else 13 end) | abs( -cast(avg(b) AS integer)-count(distinct 13) | (count(*))+count(*))-cast(avg(((a))) AS integer) from t1 union select count(distinct 11) from t1)}
+} {}
+do_test randexpr-2.2468 {
+ db eval {SELECT case when (select -case abs(min(c)) when count(distinct a)-min(t1.c) then -~abs(max(c)) | min( -13) | -count(*)+min(d)*count(*) else -(count(distinct t1.f)) end from t1) in (select count(distinct b)+max(f) from t1 union select cast(avg(19) AS integer) from t1) then (t1.d) when b<=case d when t1.d then t1.a else t1.d end then coalesce((select t1.d from t1 where not exists(select 1 from t1 where t1.a not in (11,e,13))),13) else 17 end FROM t1 WHERE NOT (t1.f in (select count(*)-max(case f+(abs(e-17*(abs(11+17+e)/abs(f)) | t1.e*b+t1.d)/abs(e))+t1.a when t1.a then -t1.d else 13 end) | abs( -cast(avg(b) AS integer)-count(distinct 13) | (count(*))+count(*))-cast(avg(((a))) AS integer) from t1 union select count(distinct 11) from t1))}
+} {17}
+do_test randexpr-2.2469 {
+ db eval {SELECT case when (select -case abs(min(c)) when count(distinct a)-min(t1.c) then -~abs(max(c)) & min( -13) & -count(*)+min(d)*count(*) else -(count(distinct t1.f)) end from t1) in (select count(distinct b)+max(f) from t1 union select cast(avg(19) AS integer) from t1) then (t1.d) when b<=case d when t1.d then t1.a else t1.d end then coalesce((select t1.d from t1 where not exists(select 1 from t1 where t1.a not in (11,e,13))),13) else 17 end FROM t1 WHERE NOT (t1.f in (select count(*)-max(case f+(abs(e-17*(abs(11+17+e)/abs(f)) | t1.e*b+t1.d)/abs(e))+t1.a when t1.a then -t1.d else 13 end) | abs( -cast(avg(b) AS integer)-count(distinct 13) | (count(*))+count(*))-cast(avg(((a))) AS integer) from t1 union select count(distinct 11) from t1))}
+} {17}
+do_test randexpr-2.2470 {
+ db eval {SELECT (select min(coalesce((select max(t1.c-case t1.e | (abs(coalesce((select max(t1.b) from t1 where 19<f-13 or exists(select 1 from t1 where -case coalesce((select max( -17-19) from t1 where (e>c)),f)+t1.b when 13 then t1.c else t1.b end<>a) or t1.a=a),e+t1.e))/abs((f))) when a then e else f end) from t1 where t1.a>t1.d),19)) from t1) FROM t1 WHERE 19*~case when (case when t1.f<>t1.a*17*(abs(t1.e)/abs(a))*a*(select case +min(11)*cast(avg(b) AS integer)*cast(avg(19) AS integer) when count(distinct t1.f) then max( -t1.e) else cast(avg( -f) AS integer) end from t1)*(select min(t1.b) from t1)*t1.d then coalesce((select max(11) from t1 where t1.a between t1.d and 17 and 19 not between 17 and a),17) else 17 end in (select t1.f from t1 union select 17 from t1)) then ~t1.b else t1.d end<=b}
+} {}
+do_test randexpr-2.2471 {
+ db eval {SELECT (select min(coalesce((select max(t1.c-case t1.e | (abs(coalesce((select max(t1.b) from t1 where 19<f-13 or exists(select 1 from t1 where -case coalesce((select max( -17-19) from t1 where (e>c)),f)+t1.b when 13 then t1.c else t1.b end<>a) or t1.a=a),e+t1.e))/abs((f))) when a then e else f end) from t1 where t1.a>t1.d),19)) from t1) FROM t1 WHERE NOT (19*~case when (case when t1.f<>t1.a*17*(abs(t1.e)/abs(a))*a*(select case +min(11)*cast(avg(b) AS integer)*cast(avg(19) AS integer) when count(distinct t1.f) then max( -t1.e) else cast(avg( -f) AS integer) end from t1)*(select min(t1.b) from t1)*t1.d then coalesce((select max(11) from t1 where t1.a between t1.d and 17 and 19 not between 17 and a),17) else 17 end in (select t1.f from t1 union select 17 from t1)) then ~t1.b else t1.d end<=b)}
+} {19}
+do_test randexpr-2.2472 {
+ db eval {SELECT (select min(coalesce((select max(t1.c-case t1.e & (abs(coalesce((select max(t1.b) from t1 where 19<f-13 or exists(select 1 from t1 where -case coalesce((select max( -17-19) from t1 where (e>c)),f)+t1.b when 13 then t1.c else t1.b end<>a) or t1.a=a),e+t1.e))/abs((f))) when a then e else f end) from t1 where t1.a>t1.d),19)) from t1) FROM t1 WHERE NOT (19*~case when (case when t1.f<>t1.a*17*(abs(t1.e)/abs(a))*a*(select case +min(11)*cast(avg(b) AS integer)*cast(avg(19) AS integer) when count(distinct t1.f) then max( -t1.e) else cast(avg( -f) AS integer) end from t1)*(select min(t1.b) from t1)*t1.d then coalesce((select max(11) from t1 where t1.a between t1.d and 17 and 19 not between 17 and a),17) else 17 end in (select t1.f from t1 union select 17 from t1)) then ~t1.b else t1.d end<=b)}
+} {19}
+do_test randexpr-2.2473 {
+ db eval {SELECT -case (select ~count(*)-~abs(~ -(count(*)+count(*)))*count(*) from t1)*13++coalesce((select max( -+17+case when f not between e and t1.c and t1.f between t1.e and t1.a then e when (b)>19 then f else t1.b end) from t1 where 17 not in (a,t1.f,17) or (d>=t1.e) or a<=17),d) when t1.c then 19 else t1.f end FROM t1 WHERE (19<+case when not 17>e then +t1.f when e | 13 in (select ~(abs(a)/abs(t1.b)) from t1 union select t1.f from t1) then case when f between case case b*f+19-case t1.c when f then 13 else c end when t1.d then b else b end*11 when 19 then 13 else t1.c end and t1.f then c when t1.b<=c then t1.d else 13 end else t1.d end)}
+} {-600}
+do_test randexpr-2.2474 {
+ db eval {SELECT -case (select ~count(*)-~abs(~ -(count(*)+count(*)))*count(*) from t1)*13++coalesce((select max( -+17+case when f not between e and t1.c and t1.f between t1.e and t1.a then e when (b)>19 then f else t1.b end) from t1 where 17 not in (a,t1.f,17) or (d>=t1.e) or a<=17),d) when t1.c then 19 else t1.f end FROM t1 WHERE NOT ((19<+case when not 17>e then +t1.f when e | 13 in (select ~(abs(a)/abs(t1.b)) from t1 union select t1.f from t1) then case when f between case case b*f+19-case t1.c when f then 13 else c end when t1.d then b else b end*11 when 19 then 13 else t1.c end and t1.f then c when t1.b<=c then t1.d else 13 end else t1.d end))}
+} {}
+do_test randexpr-2.2475 {
+ db eval {SELECT case when e not in (t1.a,t1.b,t1.e-t1.a) then f-coalesce((select max(~19-t1.b-f) from t1 where case when (select count(*)*count(*) from t1)-coalesce((select max(13) from t1 where (abs(13)/abs(19-f)) in (select count(distinct f) from t1 union select ~ - -count(distinct -f) from t1)),t1.b) between t1.f and t1.d then d else f end between t1.f and a),t1.f)+ -t1.f else t1.e end FROM t1 WHERE d not in (c,t1.d, -coalesce((select max( -coalesce((select f from t1 where t1.b>t1.c* - -t1.f),case when (t1.e-t1.e | 19*t1.c+e<19 and 19<=e or not exists(select 1 from t1 where t1.a<=t1.d or e in (a,t1.e,b))) then -e when f in ((t1.a),d,11) then 13 else d end)) from t1 where c between 19 and f),b))}
+} {}
+do_test randexpr-2.2476 {
+ db eval {SELECT case when e not in (t1.a,t1.b,t1.e-t1.a) then f-coalesce((select max(~19-t1.b-f) from t1 where case when (select count(*)*count(*) from t1)-coalesce((select max(13) from t1 where (abs(13)/abs(19-f)) in (select count(distinct f) from t1 union select ~ - -count(distinct -f) from t1)),t1.b) between t1.f and t1.d then d else f end between t1.f and a),t1.f)+ -t1.f else t1.e end FROM t1 WHERE NOT (d not in (c,t1.d, -coalesce((select max( -coalesce((select f from t1 where t1.b>t1.c* - -t1.f),case when (t1.e-t1.e | 19*t1.c+e<19 and 19<=e or not exists(select 1 from t1 where t1.a<=t1.d or e in (a,t1.e,b))) then -e when f in ((t1.a),d,11) then 13 else d end)) from t1 where c between 19 and f),b)))}
+} {-600}
+do_test randexpr-2.2477 {
+ db eval {SELECT -case when (17<>t1.b-d+t1.a | t1.f) then ~c when ((19)-coalesce((select case t1.d-t1.f when (abs(((select abs(cast(avg(13) AS integer) | cast(avg( -(t1.b)) AS integer)) from t1)))/abs(case d when t1.b then -11 else 19 end))*17 then t1.e else t1.a end from t1 where (19 not in (f,t1.d,t1.e))),t1.d)<>a) then t1.d else t1.c end FROM t1 WHERE a in (~b-t1.f*c,13 | coalesce((select max(t1.a) from t1 where -t1.a-~case when b in (case when t1.e in (select 11 from t1 union select d from t1) and 13>19 then 13*c when f not in (t1.d,c,13) then t1.a else a end,t1.f,d) then a else 11 end+b in (select +(min(11)) from t1 union select max(11)+cast(avg(19) AS integer) from t1)),13),t1.f)}
+} {}
+do_test randexpr-2.2478 {
+ db eval {SELECT -case when (17<>t1.b-d+t1.a | t1.f) then ~c when ((19)-coalesce((select case t1.d-t1.f when (abs(((select abs(cast(avg(13) AS integer) | cast(avg( -(t1.b)) AS integer)) from t1)))/abs(case d when t1.b then -11 else 19 end))*17 then t1.e else t1.a end from t1 where (19 not in (f,t1.d,t1.e))),t1.d)<>a) then t1.d else t1.c end FROM t1 WHERE NOT (a in (~b-t1.f*c,13 | coalesce((select max(t1.a) from t1 where -t1.a-~case when b in (case when t1.e in (select 11 from t1 union select d from t1) and 13>19 then 13*c when f not in (t1.d,c,13) then t1.a else a end,t1.f,d) then a else 11 end+b in (select +(min(11)) from t1 union select max(11)+cast(avg(19) AS integer) from t1)),13),t1.f))}
+} {301}
+do_test randexpr-2.2479 {
+ db eval {SELECT -case when (17<>t1.b-d+t1.a & t1.f) then ~c when ((19)-coalesce((select case t1.d-t1.f when (abs(((select abs(cast(avg(13) AS integer) & cast(avg( -(t1.b)) AS integer)) from t1)))/abs(case d when t1.b then -11 else 19 end))*17 then t1.e else t1.a end from t1 where (19 not in (f,t1.d,t1.e))),t1.d)<>a) then t1.d else t1.c end FROM t1 WHERE NOT (a in (~b-t1.f*c,13 | coalesce((select max(t1.a) from t1 where -t1.a-~case when b in (case when t1.e in (select 11 from t1 union select d from t1) and 13>19 then 13*c when f not in (t1.d,c,13) then t1.a else a end,t1.f,d) then a else 11 end+b in (select +(min(11)) from t1 union select max(11)+cast(avg(19) AS integer) from t1)),13),t1.f))}
+} {301}
+do_test randexpr-2.2480 {
+ db eval {SELECT case f when case when +t1.a between a and case e when 17 then t1.e else f-t1.e+a-((select ++count(distinct d) | cast(avg(t1.e) AS integer)+count(distinct e) | -count(*) from t1)) end-t1.b*f and t1.b | t1.b-b<=c then -t1.b+d when 11 in (select t1.e from t1 union select 11 from t1) then 13 else a end then b else c end FROM t1 WHERE case when ++c-13*d>t1.a and f=t1.d-t1.b then (select count(distinct 11)*(+cast(avg(t1.b) AS integer)+case cast(avg(e) AS integer) when max(d) | min(11) then min(f) else ( -min(t1.b)) end*(count(*)))* -min(19) from t1) else t1.e end*11 in (select a from t1 union select t1.e from t1) and e=17 or 11 not in ( -t1.d,f,t1.f)}
+} {300}
+do_test randexpr-2.2481 {
+ db eval {SELECT case f when case when +t1.a between a and case e when 17 then t1.e else f-t1.e+a-((select ++count(distinct d) | cast(avg(t1.e) AS integer)+count(distinct e) | -count(*) from t1)) end-t1.b*f and t1.b | t1.b-b<=c then -t1.b+d when 11 in (select t1.e from t1 union select 11 from t1) then 13 else a end then b else c end FROM t1 WHERE NOT (case when ++c-13*d>t1.a and f=t1.d-t1.b then (select count(distinct 11)*(+cast(avg(t1.b) AS integer)+case cast(avg(e) AS integer) when max(d) | min(11) then min(f) else ( -min(t1.b)) end*(count(*)))* -min(19) from t1) else t1.e end*11 in (select a from t1 union select t1.e from t1) and e=17 or 11 not in ( -t1.d,f,t1.f))}
+} {}
+do_test randexpr-2.2482 {
+ db eval {SELECT case f when case when +t1.a between a and case e when 17 then t1.e else f-t1.e+a-((select ++count(distinct d) & cast(avg(t1.e) AS integer)+count(distinct e) & -count(*) from t1)) end-t1.b*f and t1.b & t1.b-b<=c then -t1.b+d when 11 in (select t1.e from t1 union select 11 from t1) then 13 else a end then b else c end FROM t1 WHERE case when ++c-13*d>t1.a and f=t1.d-t1.b then (select count(distinct 11)*(+cast(avg(t1.b) AS integer)+case cast(avg(e) AS integer) when max(d) | min(11) then min(f) else ( -min(t1.b)) end*(count(*)))* -min(19) from t1) else t1.e end*11 in (select a from t1 union select t1.e from t1) and e=17 or 11 not in ( -t1.d,f,t1.f)}
+} {300}
+do_test randexpr-2.2483 {
+ db eval {SELECT -(19)-coalesce((select max(t1.e) from t1 where c not in (t1.b,17,t1.c)),case coalesce((select b+f+coalesce((select t1.a from t1 where t1.e>=t1.e+t1.a+t1.c or t1.f between c and t1.f),t1.e) from t1 where 11<>13 or t1.a=b),t1.c)*f+a when a then 17 else 17 end+t1.e)+a FROM t1 WHERE e | a not between -case when not c between case when exists(select 1 from t1 where (f not in (coalesce((select max(t1.d) from t1 where t1.e=t1.d),t1.e)+a,19,t1.c)) or not exists(select 1 from t1 where a in (19,a,e) and 11>=t1.f)) or 11<17 then t1.e+19*t1.f-b when t1.c in (e,t1.b,e) then f else t1.f end and t1.b or (11>=(t1.a)) then e when t1.a=t1.a then (select count(*) from t1) else e end and t1.b}
+} {-436}
+do_test randexpr-2.2484 {
+ db eval {SELECT -(19)-coalesce((select max(t1.e) from t1 where c not in (t1.b,17,t1.c)),case coalesce((select b+f+coalesce((select t1.a from t1 where t1.e>=t1.e+t1.a+t1.c or t1.f between c and t1.f),t1.e) from t1 where 11<>13 or t1.a=b),t1.c)*f+a when a then 17 else 17 end+t1.e)+a FROM t1 WHERE NOT (e | a not between -case when not c between case when exists(select 1 from t1 where (f not in (coalesce((select max(t1.d) from t1 where t1.e=t1.d),t1.e)+a,19,t1.c)) or not exists(select 1 from t1 where a in (19,a,e) and 11>=t1.f)) or 11<17 then t1.e+19*t1.f-b when t1.c in (e,t1.b,e) then f else t1.f end and t1.b or (11>=(t1.a)) then e when t1.a=t1.a then (select count(*) from t1) else e end and t1.b)}
+} {}
+do_test randexpr-2.2485 {
+ db eval {SELECT case (abs(case when 13 not in (t1.f,a,t1.b) then d*(abs((coalesce((select coalesce((select coalesce((select max(t1.d-t1.a) from t1 where (t1.c between 19 and (c) and c<t1.c)),17) from t1 where (11>=17)),t1.f) from t1 where t1.e between e and 17),17))-b)/abs(d)) | b+t1.b when e between t1.f and d then 19 else 17 end*f)/abs(a)) when t1.c then 11 else t1.d end FROM t1 WHERE d>=e}
+} {}
+do_test randexpr-2.2486 {
+ db eval {SELECT case (abs(case when 13 not in (t1.f,a,t1.b) then d*(abs((coalesce((select coalesce((select coalesce((select max(t1.d-t1.a) from t1 where (t1.c between 19 and (c) and c<t1.c)),17) from t1 where (11>=17)),t1.f) from t1 where t1.e between e and 17),17))-b)/abs(d)) | b+t1.b when e between t1.f and d then 19 else 17 end*f)/abs(a)) when t1.c then 11 else t1.d end FROM t1 WHERE NOT (d>=e)}
+} {400}
+do_test randexpr-2.2487 {
+ db eval {SELECT case (abs(case when 13 not in (t1.f,a,t1.b) then d*(abs((coalesce((select coalesce((select coalesce((select max(t1.d-t1.a) from t1 where (t1.c between 19 and (c) and c<t1.c)),17) from t1 where (11>=17)),t1.f) from t1 where t1.e between e and 17),17))-b)/abs(d)) & b+t1.b when e between t1.f and d then 19 else 17 end*f)/abs(a)) when t1.c then 11 else t1.d end FROM t1 WHERE NOT (d>=e)}
+} {400}
+do_test randexpr-2.2488 {
+ db eval {SELECT case ((abs(case when case -(select count(distinct case when t1.d in (select t1.b from t1 union select t1.b from t1) then b when f not in (t1.a,b,a) then c else 17 end) | cast(avg(d) AS integer) | min(b) from t1) | +b-e when t1.e then f else a end not between 11 and 13 then f when 17>e and 17<c or exists(select 1 from t1 where b>=t1.f) or d in ( -t1.c,f,t1.a) then -a else t1.f end)/abs(t1.b))) when 17 then t1.f else t1.f end FROM t1 WHERE t1.d=t1.b+case c-11+coalesce((select case when +(select +(case max(t1.e) when count(*) then (count(*)) else cast(avg(d) AS integer) end) from t1)-d between b and t1.d then 11 else f end from t1 where t1.f<=t1.c and exists(select 1 from t1 where exists(select 1 from t1 where e between t1.e and t1.e))),t1.b)-19 when t1.d then t1.f else (t1.f) end | e-c or t1.f not in (b, -f, -f)}
+} {600}
+do_test randexpr-2.2489 {
+ db eval {SELECT case ((abs(case when case -(select count(distinct case when t1.d in (select t1.b from t1 union select t1.b from t1) then b when f not in (t1.a,b,a) then c else 17 end) | cast(avg(d) AS integer) | min(b) from t1) | +b-e when t1.e then f else a end not between 11 and 13 then f when 17>e and 17<c or exists(select 1 from t1 where b>=t1.f) or d in ( -t1.c,f,t1.a) then -a else t1.f end)/abs(t1.b))) when 17 then t1.f else t1.f end FROM t1 WHERE NOT (t1.d=t1.b+case c-11+coalesce((select case when +(select +(case max(t1.e) when count(*) then (count(*)) else cast(avg(d) AS integer) end) from t1)-d between b and t1.d then 11 else f end from t1 where t1.f<=t1.c and exists(select 1 from t1 where exists(select 1 from t1 where e between t1.e and t1.e))),t1.b)-19 when t1.d then t1.f else (t1.f) end | e-c or t1.f not in (b, -f, -f))}
+} {}
+do_test randexpr-2.2490 {
+ db eval {SELECT case ((abs(case when case -(select count(distinct case when t1.d in (select t1.b from t1 union select t1.b from t1) then b when f not in (t1.a,b,a) then c else 17 end) & cast(avg(d) AS integer) & min(b) from t1) & +b-e when t1.e then f else a end not between 11 and 13 then f when 17>e and 17<c or exists(select 1 from t1 where b>=t1.f) or d in ( -t1.c,f,t1.a) then -a else t1.f end)/abs(t1.b))) when 17 then t1.f else t1.f end FROM t1 WHERE t1.d=t1.b+case c-11+coalesce((select case when +(select +(case max(t1.e) when count(*) then (count(*)) else cast(avg(d) AS integer) end) from t1)-d between b and t1.d then 11 else f end from t1 where t1.f<=t1.c and exists(select 1 from t1 where exists(select 1 from t1 where e between t1.e and t1.e))),t1.b)-19 when t1.d then t1.f else (t1.f) end | e-c or t1.f not in (b, -f, -f)}
+} {600}
+do_test randexpr-2.2491 {
+ db eval {SELECT coalesce((select max(11) from t1 where 17 not in (11,case when (case when t1.f>b then t1.d*t1.d else (abs((abs(19)/abs(coalesce((select 17*t1.e-t1.c from t1 where 17<13 and (t1.a in (select (min(17)) from t1 union select max(c) from t1) and -t1.d not in ((t1.b),d,a))), -17))))/abs(c))*13 end)<>(t1.f) then a when a=t1.a then 17 else -19 end-d,a)),e) FROM t1 WHERE 19<=case when not exists(select 1 from t1 where case when case when case when ((t1.a in (select +min(t1.c) from t1 union select max(t1.a) from t1))) or 19 between t1.d and b then +c | 11*f else d end<b and 17 not in (t1.b,t1.e,t1.c) then case when f=t1.b then t1.c when d between t1.c and t1.c then 17 else 19 end else t1.d end<>b then c else t1.d end in (17,( -b),t1.c)) then t1.e when t1.f in (t1.a,13,d) then 17 else t1.f end*11*t1.d and a<=t1.d}
+} {11}
+do_test randexpr-2.2492 {
+ db eval {SELECT coalesce((select max(11) from t1 where 17 not in (11,case when (case when t1.f>b then t1.d*t1.d else (abs((abs(19)/abs(coalesce((select 17*t1.e-t1.c from t1 where 17<13 and (t1.a in (select (min(17)) from t1 union select max(c) from t1) and -t1.d not in ((t1.b),d,a))), -17))))/abs(c))*13 end)<>(t1.f) then a when a=t1.a then 17 else -19 end-d,a)),e) FROM t1 WHERE NOT (19<=case when not exists(select 1 from t1 where case when case when case when ((t1.a in (select +min(t1.c) from t1 union select max(t1.a) from t1))) or 19 between t1.d and b then +c | 11*f else d end<b and 17 not in (t1.b,t1.e,t1.c) then case when f=t1.b then t1.c when d between t1.c and t1.c then 17 else 19 end else t1.d end<>b then c else t1.d end in (17,( -b),t1.c)) then t1.e when t1.f in (t1.a,13,d) then 17 else t1.f end*11*t1.d and a<=t1.d)}
+} {}
+do_test randexpr-2.2493 {
+ db eval {SELECT b*case when t1.f not in (a,f,t1.e-e) and t1.b in (select coalesce((select max(t1.e) from t1 where coalesce((select max(~d) from t1 where case when t1.b not in (t1.c,17, -c) then t1.f when t1.c>17 then 17 else e end>t1.f and t1.f not in (b,f,d)),17)>=t1.c or 19<=t1.e),t1.a) from t1 union select (e) from t1) then d when t1.c<e then -t1.b else b end*c FROM t1 WHERE b not between 13 and d}
+} {}
+do_test randexpr-2.2494 {
+ db eval {SELECT b*case when t1.f not in (a,f,t1.e-e) and t1.b in (select coalesce((select max(t1.e) from t1 where coalesce((select max(~d) from t1 where case when t1.b not in (t1.c,17, -c) then t1.f when t1.c>17 then 17 else e end>t1.f and t1.f not in (b,f,d)),17)>=t1.c or 19<=t1.e),t1.a) from t1 union select (e) from t1) then d when t1.c<e then -t1.b else b end*c FROM t1 WHERE NOT (b not between 13 and d)}
+} {-12000000}
+do_test randexpr-2.2495 {
+ db eval {SELECT +(select ~(~cast(avg(t1.c) AS integer)* -cast(avg(c) AS integer))-case min(t1.e) when case count(*)*~(count(*)-+count(*)*cast(avg(case t1.d when 19 then d else (t1.a) end*e) AS integer) | cast(avg(13) AS integer)-cast(avg( -11) AS integer)+max(b)+cast(avg(19) AS integer) | (max(t1.e))) | min(f) when -max(19) then (count(distinct -t1.a)) else (count(distinct 17)) end then max(t1.d) else cast(avg(t1.e) AS integer) end from t1) FROM t1 WHERE t1.c-case f when 17 | b then case +case f | case when +t1.a>c and e in (select +max(17) from t1 union select count(*) from t1) then (abs( -c)/abs(a)) when b>=t1.f then t1.b else 11 end when t1.f then 17 else t1.d end*(c)+17 when e then c else t1.f end else -c end-t1.c-c-19+c+a not in (t1.a,13,e)}
+} {-90801}
+do_test randexpr-2.2496 {
+ db eval {SELECT +(select ~(~cast(avg(t1.c) AS integer)* -cast(avg(c) AS integer))-case min(t1.e) when case count(*)*~(count(*)-+count(*)*cast(avg(case t1.d when 19 then d else (t1.a) end*e) AS integer) | cast(avg(13) AS integer)-cast(avg( -11) AS integer)+max(b)+cast(avg(19) AS integer) | (max(t1.e))) | min(f) when -max(19) then (count(distinct -t1.a)) else (count(distinct 17)) end then max(t1.d) else cast(avg(t1.e) AS integer) end from t1) FROM t1 WHERE NOT (t1.c-case f when 17 | b then case +case f | case when +t1.a>c and e in (select +max(17) from t1 union select count(*) from t1) then (abs( -c)/abs(a)) when b>=t1.f then t1.b else 11 end when t1.f then 17 else t1.d end*(c)+17 when e then c else t1.f end else -c end-t1.c-c-19+c+a not in (t1.a,13,e))}
+} {}
+do_test randexpr-2.2497 {
+ db eval {SELECT +(select ~(~cast(avg(t1.c) AS integer)* -cast(avg(c) AS integer))-case min(t1.e) when case count(*)*~(count(*)-+count(*)*cast(avg(case t1.d when 19 then d else (t1.a) end*e) AS integer) & cast(avg(13) AS integer)-cast(avg( -11) AS integer)+max(b)+cast(avg(19) AS integer) & (max(t1.e))) & min(f) when -max(19) then (count(distinct -t1.a)) else (count(distinct 17)) end then max(t1.d) else cast(avg(t1.e) AS integer) end from t1) FROM t1 WHERE t1.c-case f when 17 | b then case +case f | case when +t1.a>c and e in (select +max(17) from t1 union select count(*) from t1) then (abs( -c)/abs(a)) when b>=t1.f then t1.b else 11 end when t1.f then 17 else t1.d end*(c)+17 when e then c else t1.f end else -c end-t1.c-c-19+c+a not in (t1.a,13,e)}
+} {-90801}
+do_test randexpr-2.2498 {
+ db eval {SELECT case t1.d when e then t1.d else (abs(e-b)/abs(t1.c+a*a | 17+19*coalesce((select 17 from t1 where 11 between +(select abs(+cast(avg(13) AS integer)) from t1)*19 and t1.e),t1.e-11-t1.e+( -t1.e*13)*t1.e | e*t1.b)*f)) end FROM t1 WHERE (abs(t1.d)/abs(t1.c)) not between +13 and t1.c}
+} {0}
+do_test randexpr-2.2499 {
+ db eval {SELECT case t1.d when e then t1.d else (abs(e-b)/abs(t1.c+a*a | 17+19*coalesce((select 17 from t1 where 11 between +(select abs(+cast(avg(13) AS integer)) from t1)*19 and t1.e),t1.e-11-t1.e+( -t1.e*13)*t1.e | e*t1.b)*f)) end FROM t1 WHERE NOT ((abs(t1.d)/abs(t1.c)) not between +13 and t1.c)}
+} {}
+do_test randexpr-2.2500 {
+ db eval {SELECT case t1.d when e then t1.d else (abs(e-b)/abs(t1.c+a*a & 17+19*coalesce((select 17 from t1 where 11 between +(select abs(+cast(avg(13) AS integer)) from t1)*19 and t1.e),t1.e-11-t1.e+( -t1.e*13)*t1.e & e*t1.b)*f)) end FROM t1 WHERE (abs(t1.d)/abs(t1.c)) not between +13 and t1.c}
+} {18}
+do_test randexpr-2.2501 {
+ db eval {SELECT coalesce((select coalesce((select t1.e from t1 where case when c+a in (select t1.f from t1 union select 13 from t1) then c when not not exists(select 1 from t1 where d>= -11) then t1.d else -t1.f end between b and 11 or d not between e and 11), -f)+e+ -11*17 from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where t1.e in (select ~min(e) from t1 union select case case count(distinct f) | min(19)+min(a) when count(*) then max( -t1.c) else max(17) end when (max(t1.c)) then min(11) else min(t1.c) end from t1)) or d=a)),t1.e) FROM t1 WHERE +t1.e<~case when t1.e in (select (abs(c)/abs(~t1.d)) from t1 union select a from t1) then coalesce((select e from t1 where t1.d+ -coalesce((select max(11-t1.e*b) from t1 where 19 in (11,t1.b,e)),11)*t1.e+19 in (select t1.d from t1 union select -t1.d from t1)),17) | t1.e+e when t1.f in (17,f,f) then t1.b else 17 end*13}
+} {}
+do_test randexpr-2.2502 {
+ db eval {SELECT coalesce((select coalesce((select t1.e from t1 where case when c+a in (select t1.f from t1 union select 13 from t1) then c when not not exists(select 1 from t1 where d>= -11) then t1.d else -t1.f end between b and 11 or d not between e and 11), -f)+e+ -11*17 from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where t1.e in (select ~min(e) from t1 union select case case count(distinct f) | min(19)+min(a) when count(*) then max( -t1.c) else max(17) end when (max(t1.c)) then min(11) else min(t1.c) end from t1)) or d=a)),t1.e) FROM t1 WHERE NOT (+t1.e<~case when t1.e in (select (abs(c)/abs(~t1.d)) from t1 union select a from t1) then coalesce((select e from t1 where t1.d+ -coalesce((select max(11-t1.e*b) from t1 where 19 in (11,t1.b,e)),11)*t1.e+19 in (select t1.d from t1 union select -t1.d from t1)),17) | t1.e+e when t1.f in (17,f,f) then t1.b else 17 end*13)}
+} {813}
+do_test randexpr-2.2503 {
+ db eval {SELECT coalesce((select coalesce((select t1.e from t1 where case when c+a in (select t1.f from t1 union select 13 from t1) then c when not not exists(select 1 from t1 where d>= -11) then t1.d else -t1.f end between b and 11 or d not between e and 11), -f)+e+ -11*17 from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where t1.e in (select ~min(e) from t1 union select case case count(distinct f) & min(19)+min(a) when count(*) then max( -t1.c) else max(17) end when (max(t1.c)) then min(11) else min(t1.c) end from t1)) or d=a)),t1.e) FROM t1 WHERE NOT (+t1.e<~case when t1.e in (select (abs(c)/abs(~t1.d)) from t1 union select a from t1) then coalesce((select e from t1 where t1.d+ -coalesce((select max(11-t1.e*b) from t1 where 19 in (11,t1.b,e)),11)*t1.e+19 in (select t1.d from t1 union select -t1.d from t1)),17) | t1.e+e when t1.f in (17,f,f) then t1.b else 17 end*13)}
+} {813}
+do_test randexpr-2.2504 {
+ db eval {SELECT case when ((t1.f)+coalesce((select coalesce((select ++d from t1 where not t1.d not between e and e),19) from t1 where t1.d<>19),a)-c*a not between c and t1.a and not exists(select 1 from t1 where 17<=a) and exists(select 1 from t1 where not e in (select t1.b from t1 union select t1.e from t1)) and t1.f between 11 and t1.d) or e between c and 13 then t1.a+e when t1.a not between a and d then 17 else t1.a end FROM t1 WHERE (a)+t1.f>t1.e+a}
+} {100}
+do_test randexpr-2.2505 {
+ db eval {SELECT case when ((t1.f)+coalesce((select coalesce((select ++d from t1 where not t1.d not between e and e),19) from t1 where t1.d<>19),a)-c*a not between c and t1.a and not exists(select 1 from t1 where 17<=a) and exists(select 1 from t1 where not e in (select t1.b from t1 union select t1.e from t1)) and t1.f between 11 and t1.d) or e between c and 13 then t1.a+e when t1.a not between a and d then 17 else t1.a end FROM t1 WHERE NOT ((a)+t1.f>t1.e+a)}
+} {}
+do_test randexpr-2.2506 {
+ db eval {SELECT b*b+case d*d when t1.f then c else coalesce((select coalesce((select max(f) from t1 where (d=t1.b or case when e=11 then t1.a else f end<>t1.d and exists(select 1 from t1 where f not between t1.c and a))),(select count(distinct f) from t1)+case when t1.b between a and (19) and t1.e=a then 13 else 17 end) from t1 where d>=11),f)*t1.e end-11-a- -(11) FROM t1 WHERE (c<19)}
+} {}
+do_test randexpr-2.2507 {
+ db eval {SELECT b*b+case d*d when t1.f then c else coalesce((select coalesce((select max(f) from t1 where (d=t1.b or case when e=11 then t1.a else f end<>t1.d and exists(select 1 from t1 where f not between t1.c and a))),(select count(distinct f) from t1)+case when t1.b between a and (19) and t1.e=a then 13 else 17 end) from t1 where d>=11),f)*t1.e end-11-a- -(11) FROM t1 WHERE NOT ((c<19))}
+} {339900}
+do_test randexpr-2.2508 {
+ db eval {SELECT coalesce((select max(c) from t1 where ((d between t1.c and c)) and b not between t1.a and a or f+c in (d | +f*d*coalesce((select case when not -t1.c<t1.b then t1.b when -t1.a between t1.a and e then 11 else c end from t1 where (t1.d>=a)),e)*f,b,11) or -19>=t1.c and t1.a in (b,t1.f,c)),13) FROM t1 WHERE t1.c in (select count(distinct t1.a)*max(d) | +case (~ -~+count(distinct 13)*min(19) | (max(e))+ -(count(*))) when count(distinct t1.a) then max(d) else count(*) end+min(t1.c) from t1 union select min(e) from t1) and 17=t1.c-t1.d or t1.c-d not in ( -c,(abs(case a when t1.a then 13 else e end+f)/abs(e)),t1.a)}
+} {13}
+do_test randexpr-2.2509 {
+ db eval {SELECT coalesce((select max(c) from t1 where ((d between t1.c and c)) and b not between t1.a and a or f+c in (d | +f*d*coalesce((select case when not -t1.c<t1.b then t1.b when -t1.a between t1.a and e then 11 else c end from t1 where (t1.d>=a)),e)*f,b,11) or -19>=t1.c and t1.a in (b,t1.f,c)),13) FROM t1 WHERE NOT (t1.c in (select count(distinct t1.a)*max(d) | +case (~ -~+count(distinct 13)*min(19) | (max(e))+ -(count(*))) when count(distinct t1.a) then max(d) else count(*) end+min(t1.c) from t1 union select min(e) from t1) and 17=t1.c-t1.d or t1.c-d not in ( -c,(abs(case a when t1.a then 13 else e end+f)/abs(e)),t1.a))}
+} {}
+do_test randexpr-2.2510 {
+ db eval {SELECT coalesce((select max(c) from t1 where ((d between t1.c and c)) and b not between t1.a and a or f+c in (d & +f*d*coalesce((select case when not -t1.c<t1.b then t1.b when -t1.a between t1.a and e then 11 else c end from t1 where (t1.d>=a)),e)*f,b,11) or -19>=t1.c and t1.a in (b,t1.f,c)),13) FROM t1 WHERE t1.c in (select count(distinct t1.a)*max(d) | +case (~ -~+count(distinct 13)*min(19) | (max(e))+ -(count(*))) when count(distinct t1.a) then max(d) else count(*) end+min(t1.c) from t1 union select min(e) from t1) and 17=t1.c-t1.d or t1.c-d not in ( -c,(abs(case a when t1.a then 13 else e end+f)/abs(e)),t1.a)}
+} {13}
+do_test randexpr-2.2511 {
+ db eval {SELECT case case when not (abs(t1.d)/abs(17))>=t1.a+((19))+ -e-b or 11 between t1.a and 11 then 13 when t1.f in (select case count(distinct t1.d) when abs( -+(cast(avg(t1.c) AS integer)))*count(distinct (t1.e)) then max(19) else case count(distinct t1.a) when cast(avg(19) AS integer) then count(*) else cast(avg((t1.a)) AS integer) end end from t1 union select max(13) from t1) then -t1.b else t1.f end when c then -c else b end FROM t1 WHERE not exists(select 1 from t1 where not exists(select 1 from t1 where 13>=f))}
+} {}
+do_test randexpr-2.2512 {
+ db eval {SELECT case case when not (abs(t1.d)/abs(17))>=t1.a+((19))+ -e-b or 11 between t1.a and 11 then 13 when t1.f in (select case count(distinct t1.d) when abs( -+(cast(avg(t1.c) AS integer)))*count(distinct (t1.e)) then max(19) else case count(distinct t1.a) when cast(avg(19) AS integer) then count(*) else cast(avg((t1.a)) AS integer) end end from t1 union select max(13) from t1) then -t1.b else t1.f end when c then -c else b end FROM t1 WHERE NOT (not exists(select 1 from t1 where not exists(select 1 from t1 where 13>=f)))}
+} {200}
+do_test randexpr-2.2513 {
+ db eval {SELECT 11-(abs( -(select ((count(*)-(abs( -min(~19)))+case min(case when not exists(select 1 from t1 where (exists(select 1 from t1 where 17>f) or t1.c>=a)) then d else 11 end) | abs(cast(avg(19) AS integer)) when (count(distinct t1.f*19))-+ -( -count(*)) then ((cast(avg(t1.d) AS integer))) else cast(avg(t1.a) AS integer) end*count(distinct t1.d))+cast(avg(c) AS integer))-max(17) from t1)-17)/abs(t1.f)) FROM t1 WHERE - - -f+d in (select 19 from t1 union select t1.b from t1) or ((abs(a)/abs( -11+case when t1.e>=( -f) | d then ~t1.a when coalesce((select t1.d from t1 where e not in (e-(d)+a,e,t1.b)),a)<>t1.b then a else -t1.c end)))<=t1.e and t1.e in (13,t1.a,t1.f)}
+} {}
+do_test randexpr-2.2514 {
+ db eval {SELECT 11-(abs( -(select ((count(*)-(abs( -min(~19)))+case min(case when not exists(select 1 from t1 where (exists(select 1 from t1 where 17>f) or t1.c>=a)) then d else 11 end) | abs(cast(avg(19) AS integer)) when (count(distinct t1.f*19))-+ -( -count(*)) then ((cast(avg(t1.d) AS integer))) else cast(avg(t1.a) AS integer) end*count(distinct t1.d))+cast(avg(c) AS integer))-max(17) from t1)-17)/abs(t1.f)) FROM t1 WHERE NOT ( - - -f+d in (select 19 from t1 union select t1.b from t1) or ((abs(a)/abs( -11+case when t1.e>=( -f) | d then ~t1.a when coalesce((select t1.d from t1 where e not in (e-(d)+a,e,t1.b)),a)<>t1.b then a else -t1.c end)))<=t1.e and t1.e in (13,t1.a,t1.f))}
+} {11}
+do_test randexpr-2.2515 {
+ db eval {SELECT 11-(abs( -(select ((count(*)-(abs( -min(~19)))+case min(case when not exists(select 1 from t1 where (exists(select 1 from t1 where 17>f) or t1.c>=a)) then d else 11 end) & abs(cast(avg(19) AS integer)) when (count(distinct t1.f*19))-+ -( -count(*)) then ((cast(avg(t1.d) AS integer))) else cast(avg(t1.a) AS integer) end*count(distinct t1.d))+cast(avg(c) AS integer))-max(17) from t1)-17)/abs(t1.f)) FROM t1 WHERE NOT ( - - -f+d in (select 19 from t1 union select t1.b from t1) or ((abs(a)/abs( -11+case when t1.e>=( -f) | d then ~t1.a when coalesce((select t1.d from t1 where e not in (e-(d)+a,e,t1.b)),a)<>t1.b then a else -t1.c end)))<=t1.e and t1.e in (13,t1.a,t1.f))}
+} {11}
+do_test randexpr-2.2516 {
+ db eval {SELECT coalesce((select ~11*b from t1 where (not exists(select 1 from t1 where case d when t1.b then t1.b else d end not between b and t1.b and f in (select ~count(*) from t1 union select count(distinct coalesce((select max( -c+(abs(coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where d>a)),t1.b)-17)/abs((b)))*(a)) from t1 where t1.f>b),f)) from t1) or t1.e not in ((d),c,c)))),c)*17+t1.c FROM t1 WHERE coalesce((select 17*case when exists(select 1 from t1 where coalesce((select t1.e from t1 where f<>e and e not between c and 11),d) in (select 11 from t1 union select c from t1)) then t1.b when t1.a between t1.f and 19 then t1.d else t1.c end*f | 19 from t1 where a between t1.c and b or t1.e in ((b),b,t1.f)),17) in (select ( -~case case (((count(*)))) when max(e) then max(e) else cast(avg(c) AS integer) end when min(17) then cast(avg(13) AS integer) else cast(avg(t1.b) AS integer) end+ -count(*)* -count(*))+min(d) from t1 union select count(distinct t1.e) from t1)}
+} {}
+do_test randexpr-2.2517 {
+ db eval {SELECT coalesce((select ~11*b from t1 where (not exists(select 1 from t1 where case d when t1.b then t1.b else d end not between b and t1.b and f in (select ~count(*) from t1 union select count(distinct coalesce((select max( -c+(abs(coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where d>a)),t1.b)-17)/abs((b)))*(a)) from t1 where t1.f>b),f)) from t1) or t1.e not in ((d),c,c)))),c)*17+t1.c FROM t1 WHERE NOT (coalesce((select 17*case when exists(select 1 from t1 where coalesce((select t1.e from t1 where f<>e and e not between c and 11),d) in (select 11 from t1 union select c from t1)) then t1.b when t1.a between t1.f and 19 then t1.d else t1.c end*f | 19 from t1 where a between t1.c and b or t1.e in ((b),b,t1.f)),17) in (select ( -~case case (((count(*)))) when max(e) then max(e) else cast(avg(c) AS integer) end when min(17) then cast(avg(13) AS integer) else cast(avg(t1.b) AS integer) end+ -count(*)* -count(*))+min(d) from t1 union select count(distinct t1.e) from t1))}
+} {5400}
+do_test randexpr-2.2518 {
+ db eval {SELECT (abs(case when not +c<>coalesce((select max(19) from t1 where not (abs(c)/abs(a))*a-t1.a>=case when (exists(select 1 from t1 where d=11)) then t1.a*~b else case when b in (select (f) from t1 union select 17 from t1) or not 17 not between f and -b then t1.a when f<t1.e then a else t1.c end end),t1.c) then case when 19 between 13 and a then 13 else t1.f end else 11 end)/abs(a)) FROM t1 WHERE (t1.f in (select case case ~abs(case case -cast(avg((select +max((select min(c) from t1)) from t1)) AS integer) when -abs( -max(f)*count(*)) then ~case max(c)-count(distinct (t1.f))-(cast(avg(t1.d) AS integer)) when ( -cast(avg( -11) AS integer)) then min( -13) else count(*) end else -cast(avg(f) AS integer) end when ((min(e))) then min(t1.f) else (count(distinct 17)) end | cast(avg(11) AS integer)-cast(avg(13) AS integer)) when count(*) then count(*) else max(b) end when count(distinct 17) then -count(distinct t1.d) else count(distinct -e) end*min(t1.c) from t1 union select count(distinct 17) from t1))}
+} {}
+do_test randexpr-2.2519 {
+ db eval {SELECT (abs(case when not +c<>coalesce((select max(19) from t1 where not (abs(c)/abs(a))*a-t1.a>=case when (exists(select 1 from t1 where d=11)) then t1.a*~b else case when b in (select (f) from t1 union select 17 from t1) or not 17 not between f and -b then t1.a when f<t1.e then a else t1.c end end),t1.c) then case when 19 between 13 and a then 13 else t1.f end else 11 end)/abs(a)) FROM t1 WHERE NOT ((t1.f in (select case case ~abs(case case -cast(avg((select +max((select min(c) from t1)) from t1)) AS integer) when -abs( -max(f)*count(*)) then ~case max(c)-count(distinct (t1.f))-(cast(avg(t1.d) AS integer)) when ( -cast(avg( -11) AS integer)) then min( -13) else count(*) end else -cast(avg(f) AS integer) end when ((min(e))) then min(t1.f) else (count(distinct 17)) end | cast(avg(11) AS integer)-cast(avg(13) AS integer)) when count(*) then count(*) else max(b) end when count(distinct 17) then -count(distinct t1.d) else count(distinct -e) end*min(t1.c) from t1 union select count(distinct 17) from t1)))}
+} {0}
+do_test randexpr-2.2520 {
+ db eval {SELECT ~case when case 11*17 when f then t1.a else t1.e end in ( -coalesce((select max(case coalesce((select t1.f from t1 where exists(select 1 from t1 where t1.c in (case t1.e when -d then c else (d) end,t1.e,t1.a))), -t1.c) when 19 then 11 else t1.e end) from t1 where t1.e in (19, -t1.b,a)),17)+f-11,17,19) then a when ((d<d)) then 11 else -t1.e end FROM t1 WHERE not e>=t1.b and (b not in (c,t1.e,t1.a))}
+} {}
+do_test randexpr-2.2521 {
+ db eval {SELECT ~case when case 11*17 when f then t1.a else t1.e end in ( -coalesce((select max(case coalesce((select t1.f from t1 where exists(select 1 from t1 where t1.c in (case t1.e when -d then c else (d) end,t1.e,t1.a))), -t1.c) when 19 then 11 else t1.e end) from t1 where t1.e in (19, -t1.b,a)),17)+f-11,17,19) then a when ((d<d)) then 11 else -t1.e end FROM t1 WHERE NOT (not e>=t1.b and (b not in (c,t1.e,t1.a)))}
+} {499}
+do_test randexpr-2.2522 {
+ db eval {SELECT (abs(case f when case when d+f between e and t1.f then f when coalesce((select max(t1.f) from t1 where c in (select t1.a from t1 union select case when a not between t1.c and 13 then a else t1.c end from t1) or f*f not in (case when (11<=d) then case when 13<t1.a then (t1.d) else t1.a end else t1.a end-t1.d,17,f) or a>= -d),b)<=t1.b then t1.e else 13 end then f else t1.b end)/abs(f)) FROM t1 WHERE c between c and coalesce((select max(f) from t1 where b in (select count(*) from t1 union select max(13) from t1)),19)}
+} {}
+do_test randexpr-2.2523 {
+ db eval {SELECT (abs(case f when case when d+f between e and t1.f then f when coalesce((select max(t1.f) from t1 where c in (select t1.a from t1 union select case when a not between t1.c and 13 then a else t1.c end from t1) or f*f not in (case when (11<=d) then case when 13<t1.a then (t1.d) else t1.a end else t1.a end-t1.d,17,f) or a>= -d),b)<=t1.b then t1.e else 13 end then f else t1.b end)/abs(f)) FROM t1 WHERE NOT (c between c and coalesce((select max(f) from t1 where b in (select count(*) from t1 union select max(13) from t1)),19))}
+} {0}
+do_test randexpr-2.2524 {
+ db eval {SELECT d++11*a+coalesce((select max(t1.a) from t1 where 17+case when (19>=a) then t1.b when f>=f then -(select cast(avg(t1.e-t1.f*t1.a) AS integer) from t1)-f else t1.f end*a+f*t1.a not in (t1.e,e,13)),17)- -t1.b-a-c*19 FROM t1 WHERE f*t1.a*t1.b>17 and case when 13 not in (19, -(select count(*) from t1),coalesce((select max(coalesce((select max(t1.a) from t1 where -coalesce((select max(case when not t1.f<=(t1.d) then t1.a else (a) end) from t1 where t1.f>c or 13<(t1.a)),17)>=t1.a or not exists(select 1 from t1 where - -c not in (a,t1.b,t1.e))),t1.e)) from t1 where (f not in (b,f,f))),c)) then (t1.e) when t1.a<>e then e else b end- -t1.f not in (a, -c,(c))}
+} {-4000}
+do_test randexpr-2.2525 {
+ db eval {SELECT d++11*a+coalesce((select max(t1.a) from t1 where 17+case when (19>=a) then t1.b when f>=f then -(select cast(avg(t1.e-t1.f*t1.a) AS integer) from t1)-f else t1.f end*a+f*t1.a not in (t1.e,e,13)),17)- -t1.b-a-c*19 FROM t1 WHERE NOT (f*t1.a*t1.b>17 and case when 13 not in (19, -(select count(*) from t1),coalesce((select max(coalesce((select max(t1.a) from t1 where -coalesce((select max(case when not t1.f<=(t1.d) then t1.a else (a) end) from t1 where t1.f>c or 13<(t1.a)),17)>=t1.a or not exists(select 1 from t1 where - -c not in (a,t1.b,t1.e))),t1.e)) from t1 where (f not in (b,f,f))),c)) then (t1.e) when t1.a<>e then e else b end- -t1.f not in (a, -c,(c)))}
+} {}
+do_test randexpr-2.2526 {
+ db eval {SELECT coalesce((select (a) from t1 where 11-11+t1.b<=17-b),case when case when not t1.e*f>= -t1.f and a in (11,t1.c,t1.b) or 19>e then (select case min((f)-f) when cast(avg(t1.a) AS integer) then (cast(avg(17) AS integer)) else ((cast(avg((13)) AS integer))) end from t1) when 13 not between f and t1.c then (abs(e)/abs(17)) else t1.e end | -17<=f then b when f<19 or t1.b<=t1.d then f else f end) FROM t1 WHERE -f | t1.f*c-t1.a | t1.c+11*case ~17 when -coalesce((select max(t1.e) from t1 where 13*(17)>=11),t1.a) then case case when (t1.b>= -t1.b) then t1.f when t1.f<a or 11>a and t1.e in (e,(t1.d),19) then t1.f else t1.c end when a then t1.a else t1.e end else a end*t1.a-13<c}
+} {200}
+do_test randexpr-2.2527 {
+ db eval {SELECT coalesce((select (a) from t1 where 11-11+t1.b<=17-b),case when case when not t1.e*f>= -t1.f and a in (11,t1.c,t1.b) or 19>e then (select case min((f)-f) when cast(avg(t1.a) AS integer) then (cast(avg(17) AS integer)) else ((cast(avg((13)) AS integer))) end from t1) when 13 not between f and t1.c then (abs(e)/abs(17)) else t1.e end | -17<=f then b when f<19 or t1.b<=t1.d then f else f end) FROM t1 WHERE NOT ( -f | t1.f*c-t1.a | t1.c+11*case ~17 when -coalesce((select max(t1.e) from t1 where 13*(17)>=11),t1.a) then case case when (t1.b>= -t1.b) then t1.f when t1.f<a or 11>a and t1.e in (e,(t1.d),19) then t1.f else t1.c end when a then t1.a else t1.e end else a end*t1.a-13<c)}
+} {}
+do_test randexpr-2.2528 {
+ db eval {SELECT coalesce((select (a) from t1 where 11-11+t1.b<=17-b),case when case when not t1.e*f>= -t1.f and a in (11,t1.c,t1.b) or 19>e then (select case min((f)-f) when cast(avg(t1.a) AS integer) then (cast(avg(17) AS integer)) else ((cast(avg((13)) AS integer))) end from t1) when 13 not between f and t1.c then (abs(e)/abs(17)) else t1.e end & -17<=f then b when f<19 or t1.b<=t1.d then f else f end) FROM t1 WHERE -f | t1.f*c-t1.a | t1.c+11*case ~17 when -coalesce((select max(t1.e) from t1 where 13*(17)>=11),t1.a) then case case when (t1.b>= -t1.b) then t1.f when t1.f<a or 11>a and t1.e in (e,(t1.d),19) then t1.f else t1.c end when a then t1.a else t1.e end else a end*t1.a-13<c}
+} {200}
+do_test randexpr-2.2529 {
+ db eval {SELECT (abs(case when exists(select 1 from t1 where b not between ~case when (t1.e-(c-t1.c) | t1.a) in (select abs(~((min(t1.f) | cast(avg(c) AS integer))*(min(b))-count(distinct 19)*min(e)) | -((count(*))))-cast(avg(d) AS integer) from t1 union select -count(distinct t1.a) from t1) or f>a then 11 else e end*11 and t1.e) then t1.e when -17<11 then 17 else t1.a end)/abs(a)) FROM t1 WHERE c<=19}
+} {}
+do_test randexpr-2.2530 {
+ db eval {SELECT (abs(case when exists(select 1 from t1 where b not between ~case when (t1.e-(c-t1.c) | t1.a) in (select abs(~((min(t1.f) | cast(avg(c) AS integer))*(min(b))-count(distinct 19)*min(e)) | -((count(*))))-cast(avg(d) AS integer) from t1 union select -count(distinct t1.a) from t1) or f>a then 11 else e end*11 and t1.e) then t1.e when -17<11 then 17 else t1.a end)/abs(a)) FROM t1 WHERE NOT (c<=19)}
+} {0}
+do_test randexpr-2.2531 {
+ db eval {SELECT (abs(case when exists(select 1 from t1 where b not between ~case when (t1.e-(c-t1.c) & t1.a) in (select abs(~((min(t1.f) & cast(avg(c) AS integer))*(min(b))-count(distinct 19)*min(e)) & -((count(*))))-cast(avg(d) AS integer) from t1 union select -count(distinct t1.a) from t1) or f>a then 11 else e end*11 and t1.e) then t1.e when -17<11 then 17 else t1.a end)/abs(a)) FROM t1 WHERE NOT (c<=19)}
+} {0}
+do_test randexpr-2.2532 {
+ db eval {SELECT case when t1.e-19 in (case (abs(t1.a*+~c*coalesce((select c from t1 where ~ -(select abs(case cast(avg(13) AS integer) when - -cast(avg(f) AS integer) then count(distinct t1.d) else (count(*)) end+count(*)) from t1) not between (abs(a | t1.a)/abs(t1.c)) and 19),t1.b)-c*17*(t1.f))/abs(d)) when 13 then 19 else t1.b end,(b),17) then 19 when (11)>=t1.b then b else b end*11 FROM t1 WHERE (case 11 when case t1.e when coalesce((select a from t1 where t1.a<t1.e),t1.e | case when 13 in (coalesce((select max( -b) from t1 where d not between (t1.a) and t1.e and t1.e>=t1.a),t1.f),d,13) then c when 11 between t1.b and 17 then d else 19 end) then f else 19 end then t1.d else c end< -c) and a not in (11,c,11) or 11<>e or exists(select 1 from t1 where b<17)}
+} {2200}
+do_test randexpr-2.2533 {
+ db eval {SELECT case when t1.e-19 in (case (abs(t1.a*+~c*coalesce((select c from t1 where ~ -(select abs(case cast(avg(13) AS integer) when - -cast(avg(f) AS integer) then count(distinct t1.d) else (count(*)) end+count(*)) from t1) not between (abs(a | t1.a)/abs(t1.c)) and 19),t1.b)-c*17*(t1.f))/abs(d)) when 13 then 19 else t1.b end,(b),17) then 19 when (11)>=t1.b then b else b end*11 FROM t1 WHERE NOT ((case 11 when case t1.e when coalesce((select a from t1 where t1.a<t1.e),t1.e | case when 13 in (coalesce((select max( -b) from t1 where d not between (t1.a) and t1.e and t1.e>=t1.a),t1.f),d,13) then c when 11 between t1.b and 17 then d else 19 end) then f else 19 end then t1.d else c end< -c) and a not in (11,c,11) or 11<>e or exists(select 1 from t1 where b<17))}
+} {}
+do_test randexpr-2.2534 {
+ db eval {SELECT case when t1.e-19 in (case (abs(t1.a*+~c*coalesce((select c from t1 where ~ -(select abs(case cast(avg(13) AS integer) when - -cast(avg(f) AS integer) then count(distinct t1.d) else (count(*)) end+count(*)) from t1) not between (abs(a & t1.a)/abs(t1.c)) and 19),t1.b)-c*17*(t1.f))/abs(d)) when 13 then 19 else t1.b end,(b),17) then 19 when (11)>=t1.b then b else b end*11 FROM t1 WHERE (case 11 when case t1.e when coalesce((select a from t1 where t1.a<t1.e),t1.e | case when 13 in (coalesce((select max( -b) from t1 where d not between (t1.a) and t1.e and t1.e>=t1.a),t1.f),d,13) then c when 11 between t1.b and 17 then d else 19 end) then f else 19 end then t1.d else c end< -c) and a not in (11,c,11) or 11<>e or exists(select 1 from t1 where b<17)}
+} {2200}
+do_test randexpr-2.2535 {
+ db eval {SELECT t1.b*case when (abs(t1.c+case when d not in (a,case when b=(t1.a) then (e) when b not between f and t1.c then t1.b else t1.e end, -11) then t1.d when not exists(select 1 from t1 where 19 not between (a) and a or t1.c>d) then d else b end+t1.a+13-19+d)/abs(t1.d))> -t1.f then t1.a when t1.d in (select d from t1 union select c from t1) or 13 not between d and t1.f then t1.b else e end+ - -a FROM t1 WHERE t1.f<=11}
+} {}
+do_test randexpr-2.2536 {
+ db eval {SELECT t1.b*case when (abs(t1.c+case when d not in (a,case when b=(t1.a) then (e) when b not between f and t1.c then t1.b else t1.e end, -11) then t1.d when not exists(select 1 from t1 where 19 not between (a) and a or t1.c>d) then d else b end+t1.a+13-19+d)/abs(t1.d))> -t1.f then t1.a when t1.d in (select d from t1 union select c from t1) or 13 not between d and t1.f then t1.b else e end+ - -a FROM t1 WHERE NOT (t1.f<=11)}
+} {20100}
+do_test randexpr-2.2537 {
+ db eval {SELECT coalesce((select max(coalesce((select e+t1.c from t1 where f*11+coalesce((select max(17) from t1 where not ~case a when t1.f+13*e-(11)*t1.f then d else a end>d and (a not between t1.c and t1.c)),t1.d)- -f-b+11=b),19)-t1.f) from t1 where exists(select 1 from t1 where 19<>11)),c) FROM t1 WHERE case when 11 in (select -abs(abs( - -(cast(avg(+11-c) AS integer)+cast(avg(~a) AS integer))*max(11))+cast(avg(d) AS integer)-cast(avg(e) AS integer)-((max(t1.e))))+count(*) from t1 union select ( -count(*)) from t1) then t1.a when e>d then c- - -t1.a else 19 end in (select count(distinct -f) from t1 union select count(distinct d) from t1) and not e<17}
+} {}
+do_test randexpr-2.2538 {
+ db eval {SELECT coalesce((select max(coalesce((select e+t1.c from t1 where f*11+coalesce((select max(17) from t1 where not ~case a when t1.f+13*e-(11)*t1.f then d else a end>d and (a not between t1.c and t1.c)),t1.d)- -f-b+11=b),19)-t1.f) from t1 where exists(select 1 from t1 where 19<>11)),c) FROM t1 WHERE NOT (case when 11 in (select -abs(abs( - -(cast(avg(+11-c) AS integer)+cast(avg(~a) AS integer))*max(11))+cast(avg(d) AS integer)-cast(avg(e) AS integer)-((max(t1.e))))+count(*) from t1 union select ( -count(*)) from t1) then t1.a when e>d then c- - -t1.a else 19 end in (select count(distinct -f) from t1 union select count(distinct d) from t1) and not e<17)}
+} {-581}
+do_test randexpr-2.2539 {
+ db eval {SELECT case when (coalesce((select max(a*case when 17+f>f-t1.d*t1.f then t1.d when t1.c not between t1.e and d then 19 else (c) end) from t1 where not t1.d not between - -17 and 19),t1.a) in (select min((13)) from t1 union select ~(abs(count(distinct t1.a))*((( -max( -t1.f)))+max( -t1.c) | count(*)))-cast(avg(11) AS integer) from t1)) then c- - -d when t1.d>=d then d else 13 end FROM t1 WHERE ((abs(t1.a-t1.a*t1.d*coalesce((select coalesce((select max(11) from t1 where exists(select 1 from t1 where 11+t1.d | -t1.c-case when b+d in (select count(*) from t1 union select max(17)+ -count(distinct t1.d) from t1) then t1.c else d end-a | 13<>c)),t1.c) from t1 where 13 not in (d,t1.a,f) and 19=t1.f),(13))+(t1.d))/abs(t1.c)) between t1.f and t1.d)}
+} {}
+do_test randexpr-2.2540 {
+ db eval {SELECT case when (coalesce((select max(a*case when 17+f>f-t1.d*t1.f then t1.d when t1.c not between t1.e and d then 19 else (c) end) from t1 where not t1.d not between - -17 and 19),t1.a) in (select min((13)) from t1 union select ~(abs(count(distinct t1.a))*((( -max( -t1.f)))+max( -t1.c) | count(*)))-cast(avg(11) AS integer) from t1)) then c- - -d when t1.d>=d then d else 13 end FROM t1 WHERE NOT (((abs(t1.a-t1.a*t1.d*coalesce((select coalesce((select max(11) from t1 where exists(select 1 from t1 where 11+t1.d | -t1.c-case when b+d in (select count(*) from t1 union select max(17)+ -count(distinct t1.d) from t1) then t1.c else d end-a | 13<>c)),t1.c) from t1 where 13 not in (d,t1.a,f) and 19=t1.f),(13))+(t1.d))/abs(t1.c)) between t1.f and t1.d))}
+} {400}
+do_test randexpr-2.2541 {
+ db eval {SELECT case when (coalesce((select max(a*case when 17+f>f-t1.d*t1.f then t1.d when t1.c not between t1.e and d then 19 else (c) end) from t1 where not t1.d not between - -17 and 19),t1.a) in (select min((13)) from t1 union select ~(abs(count(distinct t1.a))*((( -max( -t1.f)))+max( -t1.c) & count(*)))-cast(avg(11) AS integer) from t1)) then c- - -d when t1.d>=d then d else 13 end FROM t1 WHERE NOT (((abs(t1.a-t1.a*t1.d*coalesce((select coalesce((select max(11) from t1 where exists(select 1 from t1 where 11+t1.d | -t1.c-case when b+d in (select count(*) from t1 union select max(17)+ -count(distinct t1.d) from t1) then t1.c else d end-a | 13<>c)),t1.c) from t1 where 13 not in (d,t1.a,f) and 19=t1.f),(13))+(t1.d))/abs(t1.c)) between t1.f and t1.d))}
+} {400}
+do_test randexpr-2.2542 {
+ db eval {SELECT case when f | c>t1.d-case when (abs(t1.b-t1.d*f)/abs(c))=t1.e then 17 when not exists(select 1 from t1 where t1.b=(11) or c not in (13,17,b)) or a<e then t1.f else 19 end+b-t1.f and t1.b between t1.b and t1.f and e in (t1.f,b,b) then (select cast(avg(e) AS integer)-~ -~count(*) from t1) else 11 end FROM t1 WHERE e<=case when (case when 17<>a then t1.c when not 11<(f) then case when t1.c= -b then c else 11 end else e end | f>=t1.b and b not between -(t1.e) and f) then 17 when f in (select -count(distinct t1.e) from t1 union select case min(f) when case cast(avg( -t1.b) AS integer) when cast(avg(e) AS integer) then -max(e) else min(t1.b) end then count(*) else (cast(avg(t1.e) AS integer)) end from t1) then case c when e then t1.f else 13 end else t1.d end}
+} {}
+do_test randexpr-2.2543 {
+ db eval {SELECT case when f | c>t1.d-case when (abs(t1.b-t1.d*f)/abs(c))=t1.e then 17 when not exists(select 1 from t1 where t1.b=(11) or c not in (13,17,b)) or a<e then t1.f else 19 end+b-t1.f and t1.b between t1.b and t1.f and e in (t1.f,b,b) then (select cast(avg(e) AS integer)-~ -~count(*) from t1) else 11 end FROM t1 WHERE NOT (e<=case when (case when 17<>a then t1.c when not 11<(f) then case when t1.c= -b then c else 11 end else e end | f>=t1.b and b not between -(t1.e) and f) then 17 when f in (select -count(distinct t1.e) from t1 union select case min(f) when case cast(avg( -t1.b) AS integer) when cast(avg(e) AS integer) then -max(e) else min(t1.b) end then count(*) else (cast(avg(t1.e) AS integer)) end from t1) then case c when e then t1.f else 13 end else t1.d end)}
+} {11}
+do_test randexpr-2.2544 {
+ db eval {SELECT case when f & c>t1.d-case when (abs(t1.b-t1.d*f)/abs(c))=t1.e then 17 when not exists(select 1 from t1 where t1.b=(11) or c not in (13,17,b)) or a<e then t1.f else 19 end+b-t1.f and t1.b between t1.b and t1.f and e in (t1.f,b,b) then (select cast(avg(e) AS integer)-~ -~count(*) from t1) else 11 end FROM t1 WHERE NOT (e<=case when (case when 17<>a then t1.c when not 11<(f) then case when t1.c= -b then c else 11 end else e end | f>=t1.b and b not between -(t1.e) and f) then 17 when f in (select -count(distinct t1.e) from t1 union select case min(f) when case cast(avg( -t1.b) AS integer) when cast(avg(e) AS integer) then -max(e) else min(t1.b) end then count(*) else (cast(avg(t1.e) AS integer)) end from t1) then case c when e then t1.f else 13 end else t1.d end)}
+} {11}
+do_test randexpr-2.2545 {
+ db eval {SELECT 17+coalesce((select max(19) from t1 where 11 in (select (abs((abs(~(case +b+17 when t1.e*t1.b then 17 else case when t1.b+17+d*a in (select (~count(distinct a)) from t1 union select case cast(avg(t1.e) AS integer) when count(*) then count(distinct t1.d) else count(distinct b) end from t1) then t1.f when (t1.e in ( -t1.a,t1.e,d)) then 17 else t1.e end | e end)- -b)/abs(t1.f)))/abs(13)) from t1 union select t1.d from t1)),17) FROM t1 WHERE e+t1.b not in (d,a,t1.c) and case case e when (case when +case 13 when t1.a then 19 else 19 end+d in (select count(*)-min(b) from t1 union select - -min(t1.d) from t1) or f in (select ( -min(t1.e)) from t1 union select cast(avg( -19) AS integer) from t1) or (t1.f in (select -max( -t1.c) from t1 union select (min(t1.c)) from t1)) then b else +t1.b end)-t1.b then b else 19 end when a then b else e end between ( -(t1.c)) and a}
+} {}
+do_test randexpr-2.2546 {
+ db eval {SELECT 17+coalesce((select max(19) from t1 where 11 in (select (abs((abs(~(case +b+17 when t1.e*t1.b then 17 else case when t1.b+17+d*a in (select (~count(distinct a)) from t1 union select case cast(avg(t1.e) AS integer) when count(*) then count(distinct t1.d) else count(distinct b) end from t1) then t1.f when (t1.e in ( -t1.a,t1.e,d)) then 17 else t1.e end | e end)- -b)/abs(t1.f)))/abs(13)) from t1 union select t1.d from t1)),17) FROM t1 WHERE NOT (e+t1.b not in (d,a,t1.c) and case case e when (case when +case 13 when t1.a then 19 else 19 end+d in (select count(*)-min(b) from t1 union select - -min(t1.d) from t1) or f in (select ( -min(t1.e)) from t1 union select cast(avg( -19) AS integer) from t1) or (t1.f in (select -max( -t1.c) from t1 union select (min(t1.c)) from t1)) then b else +t1.b end)-t1.b then b else 19 end when a then b else e end between ( -(t1.c)) and a)}
+} {34}
+do_test randexpr-2.2547 {
+ db eval {SELECT 17+coalesce((select max(19) from t1 where 11 in (select (abs((abs(~(case +b+17 when t1.e*t1.b then 17 else case when t1.b+17+d*a in (select (~count(distinct a)) from t1 union select case cast(avg(t1.e) AS integer) when count(*) then count(distinct t1.d) else count(distinct b) end from t1) then t1.f when (t1.e in ( -t1.a,t1.e,d)) then 17 else t1.e end & e end)- -b)/abs(t1.f)))/abs(13)) from t1 union select t1.d from t1)),17) FROM t1 WHERE NOT (e+t1.b not in (d,a,t1.c) and case case e when (case when +case 13 when t1.a then 19 else 19 end+d in (select count(*)-min(b) from t1 union select - -min(t1.d) from t1) or f in (select ( -min(t1.e)) from t1 union select cast(avg( -19) AS integer) from t1) or (t1.f in (select -max( -t1.c) from t1 union select (min(t1.c)) from t1)) then b else +t1.b end)-t1.b then b else 19 end when a then b else e end between ( -(t1.c)) and a)}
+} {34}
+do_test randexpr-2.2548 {
+ db eval {SELECT (abs(~(abs((select ~count(*) | +(max( -coalesce((select max(13) from t1 where coalesce((select max(t1.d) from t1 where 11<+coalesce((select max((case when 19=t1.a then (d) else 19 end)) from t1 where (11) in (17,c,b)),c)*t1.e),t1.c)<13),11)*b | t1.c+17)) from t1))/abs(~b-f))-t1.d*a)/abs(e)) FROM t1 WHERE c not in (coalesce((select t1.a from t1 where -(t1.a+17*~case when coalesce((select max(t1.c) from t1 where (coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where a<=t1.a)),11) in (select (count(distinct t1.d)+count(distinct c)) from t1 union select count(distinct e) from t1))),13)*f=d then d when t1.d in (select t1.d from t1 union select t1.f from t1) then d else t1.f end+c*c | f)+t1.c*t1.a in (select 17 from t1 union select 13 from t1)),t1.f),17,t1.f)}
+} {80}
+do_test randexpr-2.2549 {
+ db eval {SELECT (abs(~(abs((select ~count(*) | +(max( -coalesce((select max(13) from t1 where coalesce((select max(t1.d) from t1 where 11<+coalesce((select max((case when 19=t1.a then (d) else 19 end)) from t1 where (11) in (17,c,b)),c)*t1.e),t1.c)<13),11)*b | t1.c+17)) from t1))/abs(~b-f))-t1.d*a)/abs(e)) FROM t1 WHERE NOT (c not in (coalesce((select t1.a from t1 where -(t1.a+17*~case when coalesce((select max(t1.c) from t1 where (coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where a<=t1.a)),11) in (select (count(distinct t1.d)+count(distinct c)) from t1 union select count(distinct e) from t1))),13)*f=d then d when t1.d in (select t1.d from t1 union select t1.f from t1) then d else t1.f end+c*c | f)+t1.c*t1.a in (select 17 from t1 union select 13 from t1)),t1.f),17,t1.f))}
+} {}
+do_test randexpr-2.2550 {
+ db eval {SELECT (abs(~(abs((select ~count(*) & +(max( -coalesce((select max(13) from t1 where coalesce((select max(t1.d) from t1 where 11<+coalesce((select max((case when 19=t1.a then (d) else 19 end)) from t1 where (11) in (17,c,b)),c)*t1.e),t1.c)<13),11)*b & t1.c+17)) from t1))/abs(~b-f))-t1.d*a)/abs(e)) FROM t1 WHERE c not in (coalesce((select t1.a from t1 where -(t1.a+17*~case when coalesce((select max(t1.c) from t1 where (coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where a<=t1.a)),11) in (select (count(distinct t1.d)+count(distinct c)) from t1 union select count(distinct e) from t1))),13)*f=d then d when t1.d in (select t1.d from t1 union select t1.f from t1) then d else t1.f end+c*c | f)+t1.c*t1.a in (select 17 from t1 union select 13 from t1)),t1.f),17,t1.f)}
+} {80}
+do_test randexpr-2.2551 {
+ db eval {SELECT case (19) when t1.a then t1.f+coalesce((select max(t1.f) from t1 where case when t1.c=t1.a or (t1.d | case when t1.f=t1.d then a else coalesce((select max(case when 11>=a then t1.b else d end+t1.a) from t1 where -t1.a not between t1.e and 19),11) end<>t1.d) then t1.e else c end-t1.f*b+f=19),t1.b) | (t1.a)+e else a end FROM t1 WHERE (case e when d then +(select (min(t1.a)) from t1) else case when a in ((select min(case -t1.c when d then d else f end+ -e)-+cast(avg(19) AS integer)+max(d) from t1)*t1.d | -t1.c,b,e) then t1.d when t1.b in (select +min(e) | min(t1.b) from t1 union select -count(distinct e) from t1) then d else 11 end*13-(e) end not in (t1.c,c,17))}
+} {100}
+do_test randexpr-2.2552 {
+ db eval {SELECT case (19) when t1.a then t1.f+coalesce((select max(t1.f) from t1 where case when t1.c=t1.a or (t1.d | case when t1.f=t1.d then a else coalesce((select max(case when 11>=a then t1.b else d end+t1.a) from t1 where -t1.a not between t1.e and 19),11) end<>t1.d) then t1.e else c end-t1.f*b+f=19),t1.b) | (t1.a)+e else a end FROM t1 WHERE NOT ((case e when d then +(select (min(t1.a)) from t1) else case when a in ((select min(case -t1.c when d then d else f end+ -e)-+cast(avg(19) AS integer)+max(d) from t1)*t1.d | -t1.c,b,e) then t1.d when t1.b in (select +min(e) | min(t1.b) from t1 union select -count(distinct e) from t1) then d else 11 end*13-(e) end not in (t1.c,c,17)))}
+} {}
+do_test randexpr-2.2553 {
+ db eval {SELECT case (19) when t1.a then t1.f+coalesce((select max(t1.f) from t1 where case when t1.c=t1.a or (t1.d & case when t1.f=t1.d then a else coalesce((select max(case when 11>=a then t1.b else d end+t1.a) from t1 where -t1.a not between t1.e and 19),11) end<>t1.d) then t1.e else c end-t1.f*b+f=19),t1.b) & (t1.a)+e else a end FROM t1 WHERE (case e when d then +(select (min(t1.a)) from t1) else case when a in ((select min(case -t1.c when d then d else f end+ -e)-+cast(avg(19) AS integer)+max(d) from t1)*t1.d | -t1.c,b,e) then t1.d when t1.b in (select +min(e) | min(t1.b) from t1 union select -count(distinct e) from t1) then d else 11 end*13-(e) end not in (t1.c,c,17))}
+} {100}
+do_test randexpr-2.2554 {
+ db eval {SELECT (abs(( -case when 11*coalesce((select coalesce((select d from t1 where ((+t1.f*(select max(t1.f)*min(t1.a) from t1)*d*t1.f between 11 and 13))), -t1.c) from t1 where ((e)>=t1.b) or not t1.a in (select f from t1 union select c from t1) and 11<=a or c between (t1.c) and t1.d),t1.f)<t1.b then 13 else c end-d-t1.e))/abs(17)) FROM t1 WHERE +(select ~case -++(( -~count(distinct t1.b)))*min(c)*max(t1.f) when ~+count(distinct -(abs(d)/abs(t1.a))+t1.d+c-13) then count(*) else case (~max(d))+((count(distinct f))) when max(t1.e) then min(t1.c) else (cast(avg(t1.e) AS integer)) end end from t1)-+(select min(17) from t1)+19>t1.f}
+} {}
+do_test randexpr-2.2555 {
+ db eval {SELECT (abs(( -case when 11*coalesce((select coalesce((select d from t1 where ((+t1.f*(select max(t1.f)*min(t1.a) from t1)*d*t1.f between 11 and 13))), -t1.c) from t1 where ((e)>=t1.b) or not t1.a in (select f from t1 union select c from t1) and 11<=a or c between (t1.c) and t1.d),t1.f)<t1.b then 13 else c end-d-t1.e))/abs(17)) FROM t1 WHERE NOT (+(select ~case -++(( -~count(distinct t1.b)))*min(c)*max(t1.f) when ~+count(distinct -(abs(d)/abs(t1.a))+t1.d+c-13) then count(*) else case (~max(d))+((count(distinct f))) when max(t1.e) then min(t1.c) else (cast(avg(t1.e) AS integer)) end end from t1)-+(select min(17) from t1)+19>t1.f)}
+} {53}
+do_test randexpr-2.2556 {
+ db eval {SELECT case (t1.b) | t1.d-+t1.e*(select (~count(*) | min(c)-case max(case when e | b in (select t1.b from t1 union select t1.b from t1) then d when 17 between 13 and t1.d then d else t1.c end) when abs(count(distinct (t1.e)))- -min(t1.e) then cast(avg(17) AS integer) else count(distinct c) end) from t1) | b-a-+f-t1.f when +a then t1.d else d end FROM t1 WHERE (17>t1.d) and coalesce((select max((t1.a)+coalesce((select max(17*b) from t1 where t1.d-coalesce((select t1.e from t1 where t1.b<>13 or 19=t1.a),t1.d)*f<=(19) or (t1.c<11 and not not d<t1.a)), -11)-17) from t1 where t1.d not in (19,a,t1.c)),e)*13>t1.d or d=11}
+} {}
+do_test randexpr-2.2557 {
+ db eval {SELECT case (t1.b) | t1.d-+t1.e*(select (~count(*) | min(c)-case max(case when e | b in (select t1.b from t1 union select t1.b from t1) then d when 17 between 13 and t1.d then d else t1.c end) when abs(count(distinct (t1.e)))- -min(t1.e) then cast(avg(17) AS integer) else count(distinct c) end) from t1) | b-a-+f-t1.f when +a then t1.d else d end FROM t1 WHERE NOT ((17>t1.d) and coalesce((select max((t1.a)+coalesce((select max(17*b) from t1 where t1.d-coalesce((select t1.e from t1 where t1.b<>13 or 19=t1.a),t1.d)*f<=(19) or (t1.c<11 and not not d<t1.a)), -11)-17) from t1 where t1.d not in (19,a,t1.c)),e)*13>t1.d or d=11)}
+} {400}
+do_test randexpr-2.2558 {
+ db eval {SELECT case (t1.b) & t1.d-+t1.e*(select (~count(*) & min(c)-case max(case when e & b in (select t1.b from t1 union select t1.b from t1) then d when 17 between 13 and t1.d then d else t1.c end) when abs(count(distinct (t1.e)))- -min(t1.e) then cast(avg(17) AS integer) else count(distinct c) end) from t1) & b-a-+f-t1.f when +a then t1.d else d end FROM t1 WHERE NOT ((17>t1.d) and coalesce((select max((t1.a)+coalesce((select max(17*b) from t1 where t1.d-coalesce((select t1.e from t1 where t1.b<>13 or 19=t1.a),t1.d)*f<=(19) or (t1.c<11 and not not d<t1.a)), -11)-17) from t1 where t1.d not in (19,a,t1.c)),e)*13>t1.d or d=11)}
+} {400}
+do_test randexpr-2.2559 {
+ db eval {SELECT case when case when coalesce((select max(c*case (select min(case when f in (select t1.e from t1 union select f+case when d<=d then t1.f when b<=11 then t1.c else t1.b end*11 from t1) then f else c end) from t1) when f then 11 else b end) from t1 where d in (t1.b,t1.a,c)),d) between (d) and 19 then -a else a end in ( -c,t1.d,t1.d) then c when e<> -d then a else t1.c end FROM t1 WHERE a=c or case when e<coalesce((select t1.c from t1 where exists(select 1 from t1 where (f not in (case (select case +(min(11)) when cast(avg(t1.c) AS integer) then count(*) else - -cast(avg(t1.a) AS integer) end from t1) when t1.b then d else t1.b end,13,a) and t1.c<= -t1.d and (t1.a)<=b or e not between t1.a and b) or a not between t1.b and t1.f) or 19>=(e)),t1.a) then c | t1.f when exists(select 1 from t1 where a not between 19 and e) then t1.a else 17 end>t1.d}
+} {}
+do_test randexpr-2.2560 {
+ db eval {SELECT case when case when coalesce((select max(c*case (select min(case when f in (select t1.e from t1 union select f+case when d<=d then t1.f when b<=11 then t1.c else t1.b end*11 from t1) then f else c end) from t1) when f then 11 else b end) from t1 where d in (t1.b,t1.a,c)),d) between (d) and 19 then -a else a end in ( -c,t1.d,t1.d) then c when e<> -d then a else t1.c end FROM t1 WHERE NOT (a=c or case when e<coalesce((select t1.c from t1 where exists(select 1 from t1 where (f not in (case (select case +(min(11)) when cast(avg(t1.c) AS integer) then count(*) else - -cast(avg(t1.a) AS integer) end from t1) when t1.b then d else t1.b end,13,a) and t1.c<= -t1.d and (t1.a)<=b or e not between t1.a and b) or a not between t1.b and t1.f) or 19>=(e)),t1.a) then c | t1.f when exists(select 1 from t1 where a not between 19 and e) then t1.a else 17 end>t1.d)}
+} {100}
+do_test randexpr-2.2561 {
+ db eval {SELECT 13+(select -abs(+cast(avg((select cast(avg(t1.e*(t1.c)- -(abs(b+e)/abs(f))) AS integer) from t1)) AS integer)-~ -+abs(abs(count(*))) | min(t1.e | t1.e-t1.b)*max(e)-max(t1.f) | min(c)*min(t1.b)+min(t1.e)-count(distinct 11) | min(b)*( - -count(distinct 19)))-count(*) from t1) FROM t1 WHERE d in (select count(*) from t1 union select case count(*) when max(17) | -max(coalesce((select case t1.d*t1.e when t1.a then 11 else 13 end*f- -f from t1 where b in (select case ~abs(max(13)) when case ((max(c))) when cast(avg(t1.c) AS integer) then max(13) else count(distinct t1.d) end then cast(avg(t1.a) AS integer) else cast(avg(11) AS integer) end from t1 union select -max(13) from t1)),13))*cast(avg(f) AS integer) then count(*) else count(distinct e) end from t1) and exists(select 1 from t1 where case d when -(abs(17)/abs(t1.f)) then t1.a else t1.d end<t1.a)}
+} {}
+do_test randexpr-2.2562 {
+ db eval {SELECT 13+(select -abs(+cast(avg((select cast(avg(t1.e*(t1.c)- -(abs(b+e)/abs(f))) AS integer) from t1)) AS integer)-~ -+abs(abs(count(*))) | min(t1.e | t1.e-t1.b)*max(e)-max(t1.f) | min(c)*min(t1.b)+min(t1.e)-count(distinct 11) | min(b)*( - -count(distinct 19)))-count(*) from t1) FROM t1 WHERE NOT (d in (select count(*) from t1 union select case count(*) when max(17) | -max(coalesce((select case t1.d*t1.e when t1.a then 11 else 13 end*f- -f from t1 where b in (select case ~abs(max(13)) when case ((max(c))) when cast(avg(t1.c) AS integer) then max(13) else count(distinct t1.d) end then cast(avg(t1.a) AS integer) else cast(avg(11) AS integer) end from t1 union select -max(13) from t1)),13))*cast(avg(f) AS integer) then count(*) else count(distinct e) end from t1) and exists(select 1 from t1 where case d when -(abs(17)/abs(t1.f)) then t1.a else t1.d end<t1.a))}
+} {-261615}
+do_test randexpr-2.2563 {
+ db eval {SELECT 13+(select -abs(+cast(avg((select cast(avg(t1.e*(t1.c)- -(abs(b+e)/abs(f))) AS integer) from t1)) AS integer)-~ -+abs(abs(count(*))) & min(t1.e & t1.e-t1.b)*max(e)-max(t1.f) & min(c)*min(t1.b)+min(t1.e)-count(distinct 11) & min(b)*( - -count(distinct 19)))-count(*) from t1) FROM t1 WHERE NOT (d in (select count(*) from t1 union select case count(*) when max(17) | -max(coalesce((select case t1.d*t1.e when t1.a then 11 else 13 end*f- -f from t1 where b in (select case ~abs(max(13)) when case ((max(c))) when cast(avg(t1.c) AS integer) then max(13) else count(distinct t1.d) end then cast(avg(t1.a) AS integer) else cast(avg(11) AS integer) end from t1 union select -max(13) from t1)),13))*cast(avg(f) AS integer) then count(*) else count(distinct e) end from t1) and exists(select 1 from t1 where case d when -(abs(17)/abs(t1.f)) then t1.a else t1.d end<t1.a))}
+} {-52}
+do_test randexpr-2.2564 {
+ db eval {SELECT c+c*(abs(t1.c+coalesce((select case when 17 not in (t1.f,t1.e,t1.d) or (17<t1.d) then case d when t1.a then t1.f else 11 end else t1.e end*d from t1 where 19 in (select abs(~count(distinct a)) from t1 union select case cast(avg(t1.c) AS integer) when -max(t1.b) then min(c) else min(f) end+ -max(t1.d) from t1)),t1.b)+t1.e)/abs(17))+t1.b+ -t1.f+17-t1.c FROM t1 WHERE (13)+19>=19}
+} {17017}
+do_test randexpr-2.2565 {
+ db eval {SELECT c+c*(abs(t1.c+coalesce((select case when 17 not in (t1.f,t1.e,t1.d) or (17<t1.d) then case d when t1.a then t1.f else 11 end else t1.e end*d from t1 where 19 in (select abs(~count(distinct a)) from t1 union select case cast(avg(t1.c) AS integer) when -max(t1.b) then min(c) else min(f) end+ -max(t1.d) from t1)),t1.b)+t1.e)/abs(17))+t1.b+ -t1.f+17-t1.c FROM t1 WHERE NOT ((13)+19>=19)}
+} {}
+do_test randexpr-2.2566 {
+ db eval {SELECT +case when not c in (select count(distinct t1.b) from t1 union select -+(cast(avg(b*t1.b) AS integer))*max(case 17 when b then 13 else t1.a end)-count(distinct a) | cast(avg(t1.f) AS integer)+max(t1.d) from t1) then t1.e when a<=case t1.a when (e) then t1.d else d end then d else t1.b end*11-a | 17 | t1.a-f FROM t1 WHERE (c not in (t1.b,(select case case ++(min(19))*(count(distinct t1.a))+count(distinct e) | cast(avg(t1.e) AS integer) when min( -t1.d) then cast(avg(13) AS integer) else min(17) end*cast(avg(a) AS integer) when count(distinct -b) then cast(avg(11) AS integer) else - -(cast(avg(c) AS integer)) end from t1)-11+t1.e,t1.a) or d*case d when a then t1.c else 17 end*19 not between b and t1.c or -17=b or f in (select a from t1 union select -b from t1))}
+} {-227}
+do_test randexpr-2.2567 {
+ db eval {SELECT +case when not c in (select count(distinct t1.b) from t1 union select -+(cast(avg(b*t1.b) AS integer))*max(case 17 when b then 13 else t1.a end)-count(distinct a) | cast(avg(t1.f) AS integer)+max(t1.d) from t1) then t1.e when a<=case t1.a when (e) then t1.d else d end then d else t1.b end*11-a | 17 | t1.a-f FROM t1 WHERE NOT ((c not in (t1.b,(select case case ++(min(19))*(count(distinct t1.a))+count(distinct e) | cast(avg(t1.e) AS integer) when min( -t1.d) then cast(avg(13) AS integer) else min(17) end*cast(avg(a) AS integer) when count(distinct -b) then cast(avg(11) AS integer) else - -(cast(avg(c) AS integer)) end from t1)-11+t1.e,t1.a) or d*case d when a then t1.c else 17 end*19 not between b and t1.c or -17=b or f in (select a from t1 union select -b from t1)))}
+} {}
+do_test randexpr-2.2568 {
+ db eval {SELECT +case when not c in (select count(distinct t1.b) from t1 union select -+(cast(avg(b*t1.b) AS integer))*max(case 17 when b then 13 else t1.a end)-count(distinct a) & cast(avg(t1.f) AS integer)+max(t1.d) from t1) then t1.e when a<=case t1.a when (e) then t1.d else d end then d else t1.b end*11-a & 17 & t1.a-f FROM t1 WHERE (c not in (t1.b,(select case case ++(min(19))*(count(distinct t1.a))+count(distinct e) | cast(avg(t1.e) AS integer) when min( -t1.d) then cast(avg(13) AS integer) else min(17) end*cast(avg(a) AS integer) when count(distinct -b) then cast(avg(11) AS integer) else - -(cast(avg(c) AS integer)) end from t1)-11+t1.e,t1.a) or d*case d when a then t1.c else 17 end*19 not between b and t1.c or -17=b or f in (select a from t1 union select -b from t1))}
+} {0}
+do_test randexpr-2.2569 {
+ db eval {SELECT coalesce((select (abs(f)/abs(coalesce((select max(19*b+d*coalesce((select max(t1.c) from t1 where case when d>=(abs((11))/abs(t1.a*13+(13)-d*e+11)) then t1.c when t1.c>=a then 19 else -17 end*t1.e> -e),t1.f)) from t1 where 13<=t1.e),t1.d))) from t1 where t1.d in (select d from t1 union select a from t1)),t1.e) FROM t1 WHERE t1.c between (11) and coalesce((select max(b*case t1.c when t1.f then t1.f else 11 end) from t1 where +(select count(distinct case when f not between -13 and 19 then t1.f++(f) | t1.e*(+13)* -(t1.c)-t1.b when 13=t1.d then 19 else t1.b end*t1.a) from t1) in (t1.e,11, -19)),d)+f}
+} {0}
+do_test randexpr-2.2570 {
+ db eval {SELECT coalesce((select (abs(f)/abs(coalesce((select max(19*b+d*coalesce((select max(t1.c) from t1 where case when d>=(abs((11))/abs(t1.a*13+(13)-d*e+11)) then t1.c when t1.c>=a then 19 else -17 end*t1.e> -e),t1.f)) from t1 where 13<=t1.e),t1.d))) from t1 where t1.d in (select d from t1 union select a from t1)),t1.e) FROM t1 WHERE NOT (t1.c between (11) and coalesce((select max(b*case t1.c when t1.f then t1.f else 11 end) from t1 where +(select count(distinct case when f not between -13 and 19 then t1.f++(f) | t1.e*(+13)* -(t1.c)-t1.b when 13=t1.d then 19 else t1.b end*t1.a) from t1) in (t1.e,11, -19)),d)+f)}
+} {}
+do_test randexpr-2.2571 {
+ db eval {SELECT case when (not 19>=(abs(t1.b)/abs(+f))) then case 13 when case t1.c when t1.b then f else 13 end then t1.e else t1.a end+coalesce((select max(c) from t1 where a not between t1.d*17*coalesce((select max(e*b) from t1 where t1.a=11),t1.c) and t1.d),t1.d) when (case when t1.d not in (e,t1.a,t1.b) then 19 else t1.f end between t1.c and 19) then t1.e else 11 end FROM t1 WHERE t1.b*+c>=17}
+} {11}
+do_test randexpr-2.2572 {
+ db eval {SELECT case when (not 19>=(abs(t1.b)/abs(+f))) then case 13 when case t1.c when t1.b then f else 13 end then t1.e else t1.a end+coalesce((select max(c) from t1 where a not between t1.d*17*coalesce((select max(e*b) from t1 where t1.a=11),t1.c) and t1.d),t1.d) when (case when t1.d not in (e,t1.a,t1.b) then 19 else t1.f end between t1.c and 19) then t1.e else 11 end FROM t1 WHERE NOT (t1.b*+c>=17)}
+} {}
+do_test randexpr-2.2573 {
+ db eval {SELECT case when d-t1.c<>e then c when (11 not between 13 and 13) then 13 else -case when c*t1.d>=b*b then -t1.f else b-t1.c | d*(case t1.d when -case t1.b when t1.b then t1.b else 19 end*19*(t1.d) then 13 else 19 end) end+19*11 end+b FROM t1 WHERE ~~case when t1.d+(abs(t1.b+coalesce((select coalesce((select max(b-a-a) from t1 where 17 not in (e,case when (t1.d)<=t1.f or -a not between c and t1.b then c when -19 in ( -d,(t1.a),19) then b else f end,t1.e)), -13) from t1 where not b in (t1.b, -t1.b,c)),e))/abs(11)) between 13 and d then (t1.b) when t1.e<13 then 19 else a end-(19)-d*t1.d not in (d,t1.c,13)}
+} {500}
+do_test randexpr-2.2574 {
+ db eval {SELECT case when d-t1.c<>e then c when (11 not between 13 and 13) then 13 else -case when c*t1.d>=b*b then -t1.f else b-t1.c | d*(case t1.d when -case t1.b when t1.b then t1.b else 19 end*19*(t1.d) then 13 else 19 end) end+19*11 end+b FROM t1 WHERE NOT (~~case when t1.d+(abs(t1.b+coalesce((select coalesce((select max(b-a-a) from t1 where 17 not in (e,case when (t1.d)<=t1.f or -a not between c and t1.b then c when -19 in ( -d,(t1.a),19) then b else f end,t1.e)), -13) from t1 where not b in (t1.b, -t1.b,c)),e))/abs(11)) between 13 and d then (t1.b) when t1.e<13 then 19 else a end-(19)-d*t1.d not in (d,t1.c,13))}
+} {}
+do_test randexpr-2.2575 {
+ db eval {SELECT case when d-t1.c<>e then c when (11 not between 13 and 13) then 13 else -case when c*t1.d>=b*b then -t1.f else b-t1.c & d*(case t1.d when -case t1.b when t1.b then t1.b else 19 end*19*(t1.d) then 13 else 19 end) end+19*11 end+b FROM t1 WHERE ~~case when t1.d+(abs(t1.b+coalesce((select coalesce((select max(b-a-a) from t1 where 17 not in (e,case when (t1.d)<=t1.f or -a not between c and t1.b then c when -19 in ( -d,(t1.a),19) then b else f end,t1.e)), -13) from t1 where not b in (t1.b, -t1.b,c)),e))/abs(11)) between 13 and d then (t1.b) when t1.e<13 then 19 else a end-(19)-d*t1.d not in (d,t1.c,13)}
+} {500}
+do_test randexpr-2.2576 {
+ db eval {SELECT 19+t1.d+d-t1.c*case when 11 not between e and ~c+(select min((abs(t1.b*t1.b)/abs(+t1.c-e))) from t1) then 17 when case when 17*13 not in (t1.b,(abs(~c)/abs( -17-e)),(t1.e)) then 17 else (t1.c) end+c+t1.f not in (t1.f,19,t1.f) then -t1.e else t1.f end FROM t1 WHERE (+13) between +b and t1.e+11}
+} {}
+do_test randexpr-2.2577 {
+ db eval {SELECT 19+t1.d+d-t1.c*case when 11 not between e and ~c+(select min((abs(t1.b*t1.b)/abs(+t1.c-e))) from t1) then 17 when case when 17*13 not in (t1.b,(abs(~c)/abs( -17-e)),(t1.e)) then 17 else (t1.c) end+c+t1.f not in (t1.f,19,t1.f) then -t1.e else t1.f end FROM t1 WHERE NOT ((+13) between +b and t1.e+11)}
+} {-4281}
+do_test randexpr-2.2578 {
+ db eval {SELECT 17+d*~(abs(coalesce((select 19 | f | e*~+((abs(e)/abs(+19))-t1.c-case 17 when t1.f then f else 19 end-17) from t1 where (e in (select ~(11) from t1 union select case when (f)>a then b when e between -e and t1.b then 17 else t1.f end*t1.a from t1))),t1.b)*e)/abs(17))-t1.a-19 FROM t1 WHERE t1.e not in (d,e,case 19 when - -~case when exists(select 1 from t1 where 17 not in (t1.d,t1.a,coalesce((select max(11-a) from t1 where coalesce((select +c from t1 where exists(select 1 from t1 where case when t1.f not in (19+(f),d,t1.c) then t1.c when (exists(select 1 from t1 where t1.c>19)) then 19 else f end not between a and t1.f)),t1.c)<=b),17))) then t1.d-11 else t1.b end then (d) else t1.f end-(c))}
+} {}
+do_test randexpr-2.2579 {
+ db eval {SELECT 17+d*~(abs(coalesce((select 19 | f | e*~+((abs(e)/abs(+19))-t1.c-case 17 when t1.f then f else 19 end-17) from t1 where (e in (select ~(11) from t1 union select case when (f)>a then b when e between -e and t1.b then 17 else t1.f end*t1.a from t1))),t1.b)*e)/abs(17))-t1.a-19 FROM t1 WHERE NOT (t1.e not in (d,e,case 19 when - -~case when exists(select 1 from t1 where 17 not in (t1.d,t1.a,coalesce((select max(11-a) from t1 where coalesce((select +c from t1 where exists(select 1 from t1 where case when t1.f not in (19+(f),d,t1.c) then t1.c when (exists(select 1 from t1 where t1.c>19)) then 19 else f end not between a and t1.f)),t1.c)<=b),17))) then t1.d-11 else t1.b end then (d) else t1.f end-(c)))}
+} {-2353302}
+do_test randexpr-2.2580 {
+ db eval {SELECT 17+d*~(abs(coalesce((select 19 & f & e*~+((abs(e)/abs(+19))-t1.c-case 17 when t1.f then f else 19 end-17) from t1 where (e in (select ~(11) from t1 union select case when (f)>a then b when e between -e and t1.b then 17 else t1.f end*t1.a from t1))),t1.b)*e)/abs(17))-t1.a-19 FROM t1 WHERE NOT (t1.e not in (d,e,case 19 when - -~case when exists(select 1 from t1 where 17 not in (t1.d,t1.a,coalesce((select max(11-a) from t1 where coalesce((select +c from t1 where exists(select 1 from t1 where case when t1.f not in (19+(f),d,t1.c) then t1.c when (exists(select 1 from t1 where t1.c>19)) then 19 else f end not between a and t1.f)),t1.c)<=b),17))) then t1.d-11 else t1.b end then (d) else t1.f end-(c)))}
+} {-2353302}
+do_test randexpr-2.2581 {
+ db eval {SELECT case a when b-coalesce((select coalesce((select max(c-(abs((19))/abs(coalesce((select t1.c+d from t1 where 17 not in (d,t1.c, -t1.e)),t1.b)-(e)))) from t1 where t1.d in (t1.e,e,t1.f)),(e)) from t1 where t1.b=t1.e or t1.b not between b and e or t1.f not between t1.b and e or c not between -b and a),d) then 13 else 17 end FROM t1 WHERE a+17+(17) in ( -t1.a,13,coalesce((select max(e) from t1 where b+a-13<=b),e)) or e in (select abs( -+~abs(+(min(c))))+count(distinct b) from t1 union select abs(+((max(t1.c)) | min(t1.b))) from t1) and 13 not between f and 19 or not e not in ( -17,13,t1.a)}
+} {}
+do_test randexpr-2.2582 {
+ db eval {SELECT case a when b-coalesce((select coalesce((select max(c-(abs((19))/abs(coalesce((select t1.c+d from t1 where 17 not in (d,t1.c, -t1.e)),t1.b)-(e)))) from t1 where t1.d in (t1.e,e,t1.f)),(e)) from t1 where t1.b=t1.e or t1.b not between b and e or t1.f not between t1.b and e or c not between -b and a),d) then 13 else 17 end FROM t1 WHERE NOT (a+17+(17) in ( -t1.a,13,coalesce((select max(e) from t1 where b+a-13<=b),e)) or e in (select abs( -+~abs(+(min(c))))+count(distinct b) from t1 union select abs(+((max(t1.c)) | min(t1.b))) from t1) and 13 not between f and 19 or not e not in ( -17,13,t1.a))}
+} {17}
+do_test randexpr-2.2583 {
+ db eval {SELECT case when not t1.e between 17 and a then 11+ -(select ~case count(distinct +13+t1.c | c*13)- -+ -cast(avg(c) AS integer)-min(19)+case -max(c) when -cast(avg(b) AS integer) then max(11) else max(13) end+count(distinct t1.f) when max(( -d)) then cast(avg(t1.c) AS integer) else (min((t1.b))) end | cast(avg(t1.f) AS integer)*count(distinct 17) from t1)+b else +t1.e | -t1.a-a end FROM t1 WHERE (t1.f<=~c+f)}
+} {}
+do_test randexpr-2.2584 {
+ db eval {SELECT case when not t1.e between 17 and a then 11+ -(select ~case count(distinct +13+t1.c | c*13)- -+ -cast(avg(c) AS integer)-min(19)+case -max(c) when -cast(avg(b) AS integer) then max(11) else max(13) end+count(distinct t1.f) when max(( -d)) then cast(avg(t1.c) AS integer) else (min((t1.b))) end | cast(avg(t1.f) AS integer)*count(distinct 17) from t1)+b else +t1.e | -t1.a-a end FROM t1 WHERE NOT ((t1.f<=~c+f))}
+} {340}
+do_test randexpr-2.2585 {
+ db eval {SELECT case when not t1.e between 17 and a then 11+ -(select ~case count(distinct +13+t1.c & c*13)- -+ -cast(avg(c) AS integer)-min(19)+case -max(c) when -cast(avg(b) AS integer) then max(11) else max(13) end+count(distinct t1.f) when max(( -d)) then cast(avg(t1.c) AS integer) else (min((t1.b))) end & cast(avg(t1.f) AS integer)*count(distinct 17) from t1)+b else +t1.e & -t1.a-a end FROM t1 WHERE NOT ((t1.f<=~c+f))}
+} {-317}
+do_test randexpr-2.2586 {
+ db eval {SELECT t1.f-coalesce((select max(case when b<>~t1.f then b+f else coalesce((select t1.c from t1 where case a when 19*t1.e+a then 19 else 13 end between 13 and a),t1.d)+b end) from t1 where (t1.c) in (select -~min(c) | max(t1.d) from t1 union select -cast(avg(t1.a) AS integer) from t1) and t1.c in (t1.a,d,11) or 11<t1.c),t1.a) FROM t1 WHERE not exists(select 1 from t1 where +case when 19+~coalesce((select max(+c*t1.c-d) from t1 where t1.f>13 and not exists(select 1 from t1 where (((t1.d<=t1.b))))),e)*b*t1.f>t1.a or not exists(select 1 from t1 where (13) not in (11,t1.b,t1.c)) then c+d else t1.e end>=t1.f) or (not exists(select 1 from t1 where -11 in (c,t1.d, -a)) or a not between - - -(b) and b) or 13 between t1.b and f}
+} {-200}
+do_test randexpr-2.2587 {
+ db eval {SELECT t1.f-coalesce((select max(case when b<>~t1.f then b+f else coalesce((select t1.c from t1 where case a when 19*t1.e+a then 19 else 13 end between 13 and a),t1.d)+b end) from t1 where (t1.c) in (select -~min(c) | max(t1.d) from t1 union select -cast(avg(t1.a) AS integer) from t1) and t1.c in (t1.a,d,11) or 11<t1.c),t1.a) FROM t1 WHERE NOT (not exists(select 1 from t1 where +case when 19+~coalesce((select max(+c*t1.c-d) from t1 where t1.f>13 and not exists(select 1 from t1 where (((t1.d<=t1.b))))),e)*b*t1.f>t1.a or not exists(select 1 from t1 where (13) not in (11,t1.b,t1.c)) then c+d else t1.e end>=t1.f) or (not exists(select 1 from t1 where -11 in (c,t1.d, -a)) or a not between - - -(b) and b) or 13 between t1.b and f)}
+} {}
+do_test randexpr-2.2588 {
+ db eval {SELECT t1.f-coalesce((select max(case when b<>~t1.f then b+f else coalesce((select t1.c from t1 where case a when 19*t1.e+a then 19 else 13 end between 13 and a),t1.d)+b end) from t1 where (t1.c) in (select -~min(c) & max(t1.d) from t1 union select -cast(avg(t1.a) AS integer) from t1) and t1.c in (t1.a,d,11) or 11<t1.c),t1.a) FROM t1 WHERE not exists(select 1 from t1 where +case when 19+~coalesce((select max(+c*t1.c-d) from t1 where t1.f>13 and not exists(select 1 from t1 where (((t1.d<=t1.b))))),e)*b*t1.f>t1.a or not exists(select 1 from t1 where (13) not in (11,t1.b,t1.c)) then c+d else t1.e end>=t1.f) or (not exists(select 1 from t1 where -11 in (c,t1.d, -a)) or a not between - - -(b) and b) or 13 between t1.b and f}
+} {-200}
+do_test randexpr-2.2589 {
+ db eval {SELECT case when ( -c=~t1.b and coalesce((select max(coalesce((select b from t1 where t1.f between case when t1.e between t1.f and 19 then (t1.b) else t1.a end and t1.f),a)) from t1 where 11=t1.f),t1.f)+t1.c=d) and a>t1.c and 19> -19 and exists(select 1 from t1 where (b=17)) and 17 between 19 and 13 then 19*case (d) when c then b else a end when t1.d not in ( -t1.a,f,13) then -t1.f else (d) end FROM t1 WHERE 11*case when d | (abs(+t1.e-t1.e*b+(select case abs(count(*)) when count(*) then count(*) else cast(avg(t1.c) AS integer) end from t1)*17+(d)-13-11)/abs(c))-f- -t1.c-d | t1.a not between 19 and f then t1.a when t1.d in (select 11 from t1 union select d from t1) then e else e end-t1.c between 19 and c}
+} {}
+do_test randexpr-2.2590 {
+ db eval {SELECT case when ( -c=~t1.b and coalesce((select max(coalesce((select b from t1 where t1.f between case when t1.e between t1.f and 19 then (t1.b) else t1.a end and t1.f),a)) from t1 where 11=t1.f),t1.f)+t1.c=d) and a>t1.c and 19> -19 and exists(select 1 from t1 where (b=17)) and 17 between 19 and 13 then 19*case (d) when c then b else a end when t1.d not in ( -t1.a,f,13) then -t1.f else (d) end FROM t1 WHERE NOT (11*case when d | (abs(+t1.e-t1.e*b+(select case abs(count(*)) when count(*) then count(*) else cast(avg(t1.c) AS integer) end from t1)*17+(d)-13-11)/abs(c))-f- -t1.c-d | t1.a not between 19 and f then t1.a when t1.d in (select 11 from t1 union select d from t1) then e else e end-t1.c between 19 and c)}
+} {-600}
+do_test randexpr-2.2591 {
+ db eval {SELECT +case when t1.a-17 in (select cast(avg(t1.a*t1.d+(abs( -t1.e)/abs(case when t1.e>t1.a or a>t1.d then t1.f when 13<11 then t1.b else c end))*t1.d) AS integer) from t1 union select count(distinct t1.a) from t1) then t1.c when d in (select +count(distinct b)-case case - -cast(avg(d) AS integer) when case max(11) when min(17) then count(*) else (cast(avg(a) AS integer)) end then -count(*) else -cast(avg(17) AS integer) end when max(19) then count(distinct t1.f) else count(distinct -t1.d) end | min(e) from t1 union select count(*) from t1) then t1.d else t1.a end FROM t1 WHERE -+b>=19}
+} {}
+do_test randexpr-2.2592 {
+ db eval {SELECT +case when t1.a-17 in (select cast(avg(t1.a*t1.d+(abs( -t1.e)/abs(case when t1.e>t1.a or a>t1.d then t1.f when 13<11 then t1.b else c end))*t1.d) AS integer) from t1 union select count(distinct t1.a) from t1) then t1.c when d in (select +count(distinct b)-case case - -cast(avg(d) AS integer) when case max(11) when min(17) then count(*) else (cast(avg(a) AS integer)) end then -count(*) else -cast(avg(17) AS integer) end when max(19) then count(distinct t1.f) else count(distinct -t1.d) end | min(e) from t1 union select count(*) from t1) then t1.d else t1.a end FROM t1 WHERE NOT ( -+b>=19)}
+} {100}
+do_test randexpr-2.2593 {
+ db eval {SELECT +case when t1.a-17 in (select cast(avg(t1.a*t1.d+(abs( -t1.e)/abs(case when t1.e>t1.a or a>t1.d then t1.f when 13<11 then t1.b else c end))*t1.d) AS integer) from t1 union select count(distinct t1.a) from t1) then t1.c when d in (select +count(distinct b)-case case - -cast(avg(d) AS integer) when case max(11) when min(17) then count(*) else (cast(avg(a) AS integer)) end then -count(*) else -cast(avg(17) AS integer) end when max(19) then count(distinct t1.f) else count(distinct -t1.d) end & min(e) from t1 union select count(*) from t1) then t1.d else t1.a end FROM t1 WHERE NOT ( -+b>=19)}
+} {100}
+do_test randexpr-2.2594 {
+ db eval {SELECT case ~(t1.f)-t1.b-t1.e*c when coalesce((select case when d*13 | d=case when 19 between b+e+a | t1.f and a+11+t1.b*(t1.f) then d else b end then t1.c when e not between 13 and 13 then 19 else a end from t1 where 13=t1.b),c) then t1.c else b end FROM t1 WHERE not t1.d in (select cast(avg(t1.e) AS integer)-~~min(coalesce((select (abs(11)/abs(11+(select count(*)+min(17)+ -cast(avg(t1.d) AS integer) from t1)*13+coalesce((select max(b) from t1 where (t1.c)<>t1.e or e<(a)),13)-d*t1.c))*t1.b from t1 where 19<=e),c))++abs(count(distinct t1.b))+~max(11)*max(11) from t1 union select +max(11) from t1)}
+} {200}
+do_test randexpr-2.2595 {
+ db eval {SELECT case ~(t1.f)-t1.b-t1.e*c when coalesce((select case when d*13 | d=case when 19 between b+e+a | t1.f and a+11+t1.b*(t1.f) then d else b end then t1.c when e not between 13 and 13 then 19 else a end from t1 where 13=t1.b),c) then t1.c else b end FROM t1 WHERE NOT (not t1.d in (select cast(avg(t1.e) AS integer)-~~min(coalesce((select (abs(11)/abs(11+(select count(*)+min(17)+ -cast(avg(t1.d) AS integer) from t1)*13+coalesce((select max(b) from t1 where (t1.c)<>t1.e or e<(a)),13)-d*t1.c))*t1.b from t1 where 19<=e),c))++abs(count(distinct t1.b))+~max(11)*max(11) from t1 union select +max(11) from t1))}
+} {}
+do_test randexpr-2.2596 {
+ db eval {SELECT case ~(t1.f)-t1.b-t1.e*c when coalesce((select case when d*13 & d=case when 19 between b+e+a & t1.f and a+11+t1.b*(t1.f) then d else b end then t1.c when e not between 13 and 13 then 19 else a end from t1 where 13=t1.b),c) then t1.c else b end FROM t1 WHERE not t1.d in (select cast(avg(t1.e) AS integer)-~~min(coalesce((select (abs(11)/abs(11+(select count(*)+min(17)+ -cast(avg(t1.d) AS integer) from t1)*13+coalesce((select max(b) from t1 where (t1.c)<>t1.e or e<(a)),13)-d*t1.c))*t1.b from t1 where 19<=e),c))++abs(count(distinct t1.b))+~max(11)*max(11) from t1 union select +max(11) from t1)}
+} {200}
+do_test randexpr-2.2597 {
+ db eval {SELECT t1.d+(abs(11)/abs(e*~(select -+ -case min(t1.e) when count(distinct case when (exists(select 1 from t1 where (t1.d not in (19+11,t1.e,t1.c)))) then c*b-t1.a else -c end) then count(*)+case (cast(avg(a) AS integer))-count(distinct f) when -(count(*)) then count(distinct e) else max(t1.b) end- -count(distinct 17)* -min(t1.c) else count(distinct -19) end-count(distinct b) | cast(avg(19) AS integer) from t1)))-~t1.c FROM t1 WHERE c*coalesce((select e from t1 where case when exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select +b | 13 from t1 where ((17<(select (+~min(coalesce((select t1.c from t1 where case e when 13 then a else 11 end not in ( -b,t1.b,e)),(a)))) from t1)+d-19))),17) not between t1.b and t1.a)) then 11*d else t1.a end in (select c from t1 union select t1.e from t1)),t1.f) not between ( -d) and 13}
+} {701}
+do_test randexpr-2.2598 {
+ db eval {SELECT t1.d+(abs(11)/abs(e*~(select -+ -case min(t1.e) when count(distinct case when (exists(select 1 from t1 where (t1.d not in (19+11,t1.e,t1.c)))) then c*b-t1.a else -c end) then count(*)+case (cast(avg(a) AS integer))-count(distinct f) when -(count(*)) then count(distinct e) else max(t1.b) end- -count(distinct 17)* -min(t1.c) else count(distinct -19) end-count(distinct b) | cast(avg(19) AS integer) from t1)))-~t1.c FROM t1 WHERE NOT (c*coalesce((select e from t1 where case when exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select +b | 13 from t1 where ((17<(select (+~min(coalesce((select t1.c from t1 where case e when 13 then a else 11 end not in ( -b,t1.b,e)),(a)))) from t1)+d-19))),17) not between t1.b and t1.a)) then 11*d else t1.a end in (select c from t1 union select t1.e from t1)),t1.f) not between ( -d) and 13)}
+} {}
+do_test randexpr-2.2599 {
+ db eval {SELECT t1.d+(abs(11)/abs(e*~(select -+ -case min(t1.e) when count(distinct case when (exists(select 1 from t1 where (t1.d not in (19+11,t1.e,t1.c)))) then c*b-t1.a else -c end) then count(*)+case (cast(avg(a) AS integer))-count(distinct f) when -(count(*)) then count(distinct e) else max(t1.b) end- -count(distinct 17)* -min(t1.c) else count(distinct -19) end-count(distinct b) & cast(avg(19) AS integer) from t1)))-~t1.c FROM t1 WHERE c*coalesce((select e from t1 where case when exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select +b | 13 from t1 where ((17<(select (+~min(coalesce((select t1.c from t1 where case e when 13 then a else 11 end not in ( -b,t1.b,e)),(a)))) from t1)+d-19))),17) not between t1.b and t1.a)) then 11*d else t1.a end in (select c from t1 union select t1.e from t1)),t1.f) not between ( -d) and 13}
+} {701}
+finish_test
diff --git a/test/rdonly.test b/test/rdonly.test
new file mode 100644
index 0000000..bf19597
--- /dev/null
+++ b/test/rdonly.test
@@ -0,0 +1,84 @@
+# 2007 April 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure SQLite treats a database
+# as readonly if its write version is set to high.
+#
+# $Id: rdonly.test,v 1.2 2008/07/08 10:19:58 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# Create a database.
+#
+do_test rdonly-1.1 {
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ SELECT * FROM t1;
+ }
+} {1}
+
+# Changes the write version from 1 to 3. Verify that the database
+# can be read but not written.
+#
+do_test rdonly-1.2 {
+ db close
+ hexio_get_int [hexio_read test.db 18 1]
+} 1
+do_test rdonly-1.3 {
+ hexio_write test.db 18 03
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM t1;
+ }
+} {1}
+do_test rdonly-1.4 {
+ catchsql {
+ INSERT INTO t1 VALUES(2)
+ }
+} {1 {attempt to write a readonly database}}
+
+# Change the write version back to 1. Verify that the database
+# is read-write again.
+#
+do_test rdonly-1.5 {
+ db close
+ hexio_write test.db 18 01
+ sqlite3 db test.db
+ catchsql {
+ INSERT INTO t1 VALUES(2);
+ SELECT * FROM t1;
+ }
+} {0 {1 2}}
+
+# Now, after connection [db] has loaded the database schema, modify the
+# write-version of the file (and the change-counter, so that the
+# write-version is reloaded). This way, SQLite does not discover that
+# the database is read-only until after it is locked.
+#
+set ro_version 02
+ifcapable wal { set ro_version 03 }
+do_test rdonly-1.6 {
+ hexio_write test.db 18 $ro_version ; # write-version
+ hexio_write test.db 24 11223344 ; # change-counter
+ catchsql {
+ INSERT INTO t1 VALUES(2);
+ }
+} {1 {attempt to write a readonly database}}
+
+finish_test
diff --git a/test/reindex.test b/test/reindex.test
new file mode 100644
index 0000000..9d5ecd9
--- /dev/null
+++ b/test/reindex.test
@@ -0,0 +1,171 @@
+# 2004 November 5
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+# This file implements tests for the REINDEX command.
+#
+# $Id: reindex.test,v 1.4 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# There is nothing to test if REINDEX is disable for this build.
+#
+ifcapable {!reindex} {
+ finish_test
+ return
+}
+
+# Basic sanity checks.
+#
+do_test reindex-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ CREATE INDEX i1 ON t1(a);
+ REINDEX;
+ }
+} {}
+integrity_check reindex-1.2
+do_test reindex-1.3 {
+ execsql {
+ REINDEX t1;
+ }
+} {}
+integrity_check reindex-1.4
+do_test reindex-1.5 {
+ execsql {
+ REINDEX i1;
+ }
+} {}
+integrity_check reindex-1.6
+do_test reindex-1.7 {
+ execsql {
+ REINDEX main.t1;
+ }
+} {}
+do_test reindex-1.8 {
+ execsql {
+ REINDEX main.i1;
+ }
+} {}
+do_test reindex-1.9 {
+ catchsql {
+ REINDEX bogus
+ }
+} {1 {unable to identify the object to be reindexed}}
+
+# Set up a table for testing that includes several different collating
+# sequences including some that we can modify.
+#
+do_test reindex-2.1 {
+ proc c1 {a b} {
+ return [expr {-[string compare $a $b]}]
+ }
+ proc c2 {a b} {
+ return [expr {-[string compare [string tolower $a] [string tolower $b]]}]
+ }
+ db collate c1 c1
+ db collate c2 c2
+ execsql {
+ CREATE TABLE t2(
+ a TEXT PRIMARY KEY COLLATE c1,
+ b TEXT UNIQUE COLLATE c2,
+ c TEXT COLLATE nocase,
+ d TEST COLLATE binary
+ );
+ INSERT INTO t2 VALUES('abc','abc','abc','abc');
+ INSERT INTO t2 VALUES('ABCD','ABCD','ABCD','ABCD');
+ INSERT INTO t2 VALUES('bcd','bcd','bcd','bcd');
+ INSERT INTO t2 VALUES('BCDE','BCDE','BCDE','BCDE');
+ SELECT a FROM t2 ORDER BY a;
+ }
+} {bcd abc BCDE ABCD}
+do_test reindex-2.2 {
+ execsql {
+ SELECT b FROM t2 ORDER BY b;
+ }
+} {BCDE bcd ABCD abc}
+do_test reindex-2.3 {
+ execsql {
+ SELECT c FROM t2 ORDER BY c;
+ }
+} {abc ABCD bcd BCDE}
+do_test reindex-2.4 {
+ execsql {
+ SELECT d FROM t2 ORDER BY d;
+ }
+} {ABCD BCDE abc bcd}
+
+# Change a collating sequence function. Verify that REINDEX rebuilds
+# the index.
+#
+do_test reindex-2.5 {
+ proc c1 {a b} {
+ return [string compare $a $b]
+ }
+ execsql {
+ SELECT a FROM t2 ORDER BY a;
+ }
+} {bcd abc BCDE ABCD}
+ifcapable {integrityck} {
+ do_test reindex-2.5.1 {
+ string equal ok [execsql {PRAGMA integrity_check}]
+ } {0}
+}
+do_test reindex-2.6 {
+ execsql {
+ REINDEX c2;
+ SELECT a FROM t2 ORDER BY a;
+ }
+} {bcd abc BCDE ABCD}
+do_test reindex-2.7 {
+ execsql {
+ REINDEX t1;
+ SELECT a FROM t2 ORDER BY a;
+ }
+} {bcd abc BCDE ABCD}
+do_test reindex-2.8 {
+ execsql {
+ REINDEX c1;
+ SELECT a FROM t2 ORDER BY a;
+ }
+} {ABCD BCDE abc bcd}
+integrity_check reindex-2.8.1
+
+# Try to REINDEX an index for which the collation sequence is not available.
+#
+do_test reindex-3.1 {
+ sqlite3 db2 test.db
+ catchsql {
+ REINDEX c1;
+ } db2
+} {1 {no such collation sequence: c1}}
+do_test reindex-3.2 {
+ proc need_collate {collation} {
+ db2 collate c1 c1
+ }
+ db2 collation_needed need_collate
+ catchsql {
+ REINDEX c1;
+ } db2
+} {0 {}}
+do_test reindex-3.3 {
+ catchsql {
+ REINDEX;
+ } db2
+} {1 {no such collation sequence: c2}}
+
+do_test reindex-3.99 {
+ db2 close
+} {}
+
+finish_test
diff --git a/test/releasetest.mk b/test/releasetest.mk
new file mode 100644
index 0000000..5d217c6
--- /dev/null
+++ b/test/releasetest.mk
@@ -0,0 +1,14 @@
+########################################################
+TOP=/home/drh/sqlite/sqlite
+
+TCL_FLAGS=-I/home/drh/tcltk/86linux
+LIBTCL=/home/drh/tcltk/86linux/libtcl8.6.a -lm -ldl -lpthread
+
+BCC = gcc
+TCC = gcc -ansi -g $(CFLAGS)
+NAWK = awk
+AR = ar cr
+RANLIB = ranlib
+THREADLIB = -lpthread -ldl -lz
+include $(TOP)/main.mk
+########################################################
diff --git a/test/releasetest.tcl b/test/releasetest.tcl
new file mode 100644
index 0000000..7725630
--- /dev/null
+++ b/test/releasetest.tcl
@@ -0,0 +1,339 @@
+
+set rcsid {$Id: $}
+
+# Documentation for this script. This may be output to stderr
+# if the script is invoked incorrectly. See the [process_options]
+# proc below.
+#
+set ::USAGE_MESSAGE {
+This Tcl script is used to test the various configurations required
+before releasing a new version. Supported command line options (all
+optional) are:
+
+ -makefile PATH-TO-MAKEFILE (default "releasetest.mk")
+ -platform PLATFORM (see below)
+ -quick BOOLEAN (default "0")
+
+The default value for -makefile is "./releasetest.mk".
+
+The script determines the default value for -platform using the
+$tcl_platform(os) and $tcl_platform(machine) variables. Supported
+platforms are "Linux-x86", "Linux-x86_64" and "Darwin-i386".
+
+If the -quick option is set to true, then the "veryquick.test" script
+is run for all compilation configurations. Otherwise, sometimes "all.test"
+is run, sometimes "veryquick.test".
+
+Almost any SQLite makefile (except those generated by configure - see below)
+should work. The following properties are required:
+
+ * The makefile should support the "fulltest" target.
+ * The makefile should support the variable "OPTS" as a way to pass
+ options from the make command line to lemon and the C compiler.
+
+More precisely, the following invocation must be supported:
+
+ make -f $::MAKEFILE fulltest OPTS="-DSQLITE_SECURE_DELETE=1 -DSQLITE_DEBUG=1"
+
+Makefiles generated by the sqlite configure program cannot be used as
+they do not respect the OPTS variable.
+
+Example Makefile contents:
+
+ ########################################################
+ TOP=/home/dan/work/sqlite/sqlite
+
+ TCL_FLAGS=-I/home/dan/tcl/include
+ LIBTCL=-L/home/dan/tcl/lib -ltcl
+
+ BCC = gcc
+ TCC = gcc -ansi -g $(CFLAGS)
+ NAWK = awk
+ AR = ar cr
+ RANLIB = ranlib
+ THREADLIB = -lpthread -ldl
+ include $(TOP)/main.mk
+ ########################################################
+}
+
+array set ::Configs {
+ "Default" {
+ -O2
+ }
+ "Ftrapv" {
+ -O2 -ftrapv
+ -DSQLITE_MAX_ATTACHED=55
+ -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
+ }
+ "Unlock-Notify" {
+ -O2
+ -DSQLITE_ENABLE_UNLOCK_NOTIFY
+ -DSQLITE_THREADSAFE
+ -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
+ }
+ "Secure-Delete" {
+ -O2
+ -DSQLITE_SECURE_DELETE=1
+ -DSQLITE_SOUNDEX=1
+ }
+ "Update-Delete-Limit" {
+ -O2
+ -DSQLITE_DEFAULT_FILE_FORMAT=4
+ -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
+ }
+ "Debug-One" {
+ -O2
+ -DSQLITE_DEBUG=1
+ -DSQLITE_MEMDEBUG=1
+ -DSQLITE_MUTEX_NOOP=1
+ -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
+ -DSQLITE_ENABLE_FTS3=1
+ -DSQLITE_ENABLE_RTREE=1
+ -DSQLITE_ENABLE_MEMSYS5=1
+ -DSQLITE_ENABLE_MEMSYS3=1
+ -DSQLITE_ENABLE_COLUMN_METADATA=1
+ }
+ "Device-One" {
+ -O2
+ -DSQLITE_DEBUG=1
+ -DSQLITE_DEFAULT_AUTOVACUUM=1
+ -DSQLITE_DEFAULT_CACHE_SIZE=64
+ -DSQLITE_DEFAULT_PAGE_SIZE=1024
+ -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=32
+ -DSQLITE_DISABLE_LFS=1
+ -DSQLITE_ENABLE_ATOMIC_WRITE=1
+ -DSQLITE_ENABLE_IOTRACE=1
+ -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
+ -DSQLITE_MAX_PAGE_SIZE=4096
+ -DSQLITE_OMIT_LOAD_EXTENSION=1
+ -DSQLITE_OMIT_PROGRESS_CALLBACK=1
+ -DSQLITE_OMIT_VIRTUALTABLE=1
+ -DSQLITE_TEMP_STORE=3
+ }
+ "Device-Two" {
+ -DSQLITE_4_BYTE_ALIGNED_MALLOC=1
+ -DSQLITE_DEFAULT_AUTOVACUUM=1
+ -DSQLITE_DEFAULT_CACHE_SIZE=1000
+ -DSQLITE_DEFAULT_LOCKING_MODE=0
+ -DSQLITE_DEFAULT_PAGE_SIZE=1024
+ -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=1000
+ -DSQLITE_DISABLE_LFS=1
+ -DSQLITE_ENABLE_FTS3=1
+ -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
+ -DSQLITE_ENABLE_RTREE=1
+ -DSQLITE_MAX_COMPOUND_SELECT=50
+ -DSQLITE_MAX_PAGE_SIZE=32768
+ -DSQLITE_OMIT_TRACE=1
+ -DSQLITE_TEMP_STORE=3
+ -DSQLITE_THREADSAFE=2
+ }
+ "Locking-Style" {
+ -O2
+ -DSQLITE_ENABLE_LOCKING_STYLE=1
+ }
+ "OS-X" {
+ -DSQLITE_OMIT_LOAD_EXTENSION=1
+ -DSQLITE_DEFAULT_MEMSTATUS=0
+ -DSQLITE_THREADSAFE=2
+ -DSQLITE_OS_UNIX=1
+ -DSQLITE_ENABLE_LOCKING_STYLE=1
+ -DUSE_PREAD=1
+ -DSQLITE_ENABLE_RTREE=1
+ -DSQLITE_ENABLE_FTS3=1
+ -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
+ -DSQLITE_DEFAULT_CACHE_SIZE=1000
+ -DSQLITE_MAX_LENGTH=2147483645
+ -DSQLITE_MAX_VARIABLE_NUMBER=500000
+ -DSQLITE_DEBUG=1
+ -DSQLITE_PREFER_PROXY_LOCKING=1
+ }
+ "Extra-Robustness" {
+ -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
+ -DSQLITE_MAX_ATTACHED=62
+ }
+}
+
+array set ::Platforms {
+ Linux-x86_64 {
+ "Debug-One" "checksymbols test"
+ "Secure-Delete" test
+ "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
+ "Update-Delete-Limit" test
+ "Extra-Robustness" test
+ "Device-Two" test
+ "Ftrapv" test
+ "Default" "threadtest test"
+ "Device-One" fulltest
+ }
+ Linux-i686 {
+ "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
+ "Device-One" test
+ "Device-Two" test
+ "Default" "threadtest fulltest"
+ }
+ Darwin-i386 {
+ "Locking-Style" test
+ "OS-X" "threadtest fulltest"
+ }
+}
+
+
+# End of configuration section.
+#########################################################################
+#########################################################################
+
+foreach {key value} [array get ::Platforms] {
+ foreach {v t} $value {
+ if {0==[info exists ::Configs($v)]} {
+ puts stderr "No such configuration: \"$v\""
+ exit -1
+ }
+ }
+}
+
+proc run_test_suite {name testtarget config} {
+
+ # Tcl variable $opts is used to build up the value used to set the
+ # OPTS Makefile variable. Variable $cflags holds the value for
+ # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but
+ # CFLAGS is only passed to gcc.
+ #
+ set cflags ""
+ set opts ""
+ foreach arg $config {
+ if {[string match -D* $arg]} {
+ lappend opts $arg
+ } else {
+ lappend cflags $arg
+ }
+ }
+
+ set cflags [join $cflags " "]
+ set opts [join $opts " "]
+ append opts " -DSQLITE_NO_SYNC=1 -DHAVE_USLEEP"
+
+ # Set the sub-directory to use.
+ #
+ set dir [string tolower [string map {- _ " " _} $name]]
+
+ if {$::tcl_platform(platform)=="windows"} {
+ append opts " -DSQLITE_OS_WIN=1"
+ } elseif {$::tcl_platform(platform)=="os2"} {
+ append opts " -DSQLITE_OS_OS2=1"
+ } else {
+ append opts " -DSQLITE_OS_UNIX=1"
+ }
+
+ # Run the test.
+ #
+ set makefile [file normalize $::MAKEFILE]
+ file mkdir $dir
+ puts -nonewline "Testing configuration \"$name\" (logfile=$dir/test.log)..."
+ flush stdout
+
+ set makecmd [concat \
+ [list exec make -C $dir -f $makefile clean] \
+ $testtarget \
+ [list CFLAGS=$cflags OPTS=$opts >& $dir/test.log] \
+ ]
+
+ set tm1 [clock seconds]
+ set rc [catch $makecmd]
+ set tm2 [clock seconds]
+
+ set minutes [expr {($tm2-$tm1)/60}]
+ set seconds [expr {($tm2-$tm1)%60}]
+ puts -nonewline [format " (%d:%.2d) " $minutes $seconds]
+ if {$rc} {
+ puts "FAILED."
+ } else {
+ puts "Ok."
+ }
+}
+
+
+# This proc processes the command line options passed to this script.
+# Currently the only option supported is "-makefile", default
+# "releasetest.mk". Set the ::MAKEFILE variable to the value of this
+# option.
+#
+proc process_options {argv} {
+ set ::MAKEFILE releasetest.mk ;# Default value
+ set ::QUICK 0 ;# Default value
+ set platform $::tcl_platform(os)-$::tcl_platform(machine)
+
+ for {set i 0} {$i < [llength $argv]} {incr i} {
+ switch -- [lindex $argv $i] {
+ -makefile {
+ incr i
+ set ::MAKEFILE [lindex $argv $i]
+ }
+
+ -platform {
+ incr i
+ set platform [lindex $argv $i]
+ }
+
+ -quick {
+ incr i
+ set ::QUICK [lindex $argv $i]
+ }
+
+ default {
+ puts stderr ""
+ puts stderr [string trim $::USAGE_MESSAGE]
+ exit -1
+ }
+ }
+ }
+
+ set ::MAKEFILE [file normalize $::MAKEFILE]
+
+ if {0==[info exists ::Platforms($platform)]} {
+ puts "Unknown platform: $platform"
+ puts -nonewline "Set the -platform option to "
+ set print [list]
+ foreach p [array names ::Platforms] {
+ lappend print "\"$p\""
+ }
+ lset print end "or [lindex $print end]"
+ puts "[join $print {, }]."
+ exit
+ }
+
+ set ::CONFIGLIST $::Platforms($platform)
+ puts "Running the following configurations for $platform:"
+ puts " [string trim $::CONFIGLIST]"
+}
+
+# Main routine.
+#
+proc main {argv} {
+
+ # Process any command line options.
+ process_options $argv
+
+ foreach {zConfig target} $::CONFIGLIST {
+ if {$::QUICK} {set target test}
+ set config_options $::Configs($zConfig)
+
+ run_test_suite $zConfig $target $config_options
+
+ # If the configuration included the SQLITE_DEBUG option, then remove
+ # it and run veryquick.test. If it did not include the SQLITE_DEBUG option
+ # add it and run veryquick.test.
+ set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
+ if {$debug_idx < 0} {
+ run_test_suite "${zConfig}_debug" test [
+ concat $config_options -DSQLITE_DEBUG=1
+ ]
+ } else {
+ run_test_suite "${zConfig}_ndebug" test [
+ lreplace $config_options $debug_idx $debug_idx
+ ]
+ }
+
+ }
+}
+
+main $argv
diff --git a/test/rollback.test b/test/rollback.test
new file mode 100644
index 0000000..fc123ab
--- /dev/null
+++ b/test/rollback.test
@@ -0,0 +1,150 @@
+# 2004 June 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is verifying that a rollback in one statement
+# caused by an ON CONFLICT ROLLBACK clause aborts any other pending
+# statements.
+#
+# $Id: rollback.test,v 1.11 2009/06/26 07:12:07 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set DB [sqlite3_connection_pointer db]
+
+do_test rollback-1.1 {
+ execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ SELECT * FROM t1;
+ }
+} {1 2 3 4}
+
+ifcapable conflict {
+ do_test rollback-1.2 {
+ execsql {
+ CREATE TABLE t3(a unique on conflict rollback);
+ INSERT INTO t3 SELECT a FROM t1;
+ BEGIN;
+ INSERT INTO t1 SELECT * FROM t1;
+ }
+ } {}
+}
+do_test rollback-1.3 {
+ set STMT [sqlite3_prepare $DB "SELECT a FROM t1" -1 TAIL]
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+
+ifcapable conflict {
+ # This causes a ROLLBACK, which deletes the table out from underneath the
+ # SELECT statement.
+ #
+ do_test rollback-1.4 {
+ catchsql {
+ INSERT INTO t3 SELECT a FROM t1;
+ }
+ } {1 {column a is not unique}}
+
+ # Try to continue with the SELECT statement
+ #
+ do_test rollback-1.5 {
+ sqlite3_step $STMT
+ } {SQLITE_ERROR}
+
+ # Restart the SELECT statement
+ #
+ do_test rollback-1.6 { sqlite3_reset $STMT } {SQLITE_ABORT}
+} else {
+ do_test rollback-1.6 { sqlite3_reset $STMT } {SQLITE_OK}
+}
+
+do_test rollback-1.7 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test rollback-1.8 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test rollback-1.9 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+if {$tcl_platform(platform) == "unix"
+ && [permutation] ne "onefile"
+ && [permutation] ne "inmemory_journal"
+} {
+ do_test rollback-2.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t3 VALUES('hello world');
+ }
+ forcecopy test.db testA.db
+ forcecopy test.db-journal testA.db-journal
+ execsql {
+ COMMIT;
+ }
+ } {}
+
+ # At this point files testA.db and testA.db-journal are present in the
+ # file system. This block adds a master-journal file pointer to the
+ # end of testA.db-journal. The master-journal file does not exist.
+ #
+ set mj [file normalize testA.db-mj-123]
+ binary scan $mj c* a
+ set cksum 0
+ foreach i $a { incr cksum $i }
+ set mj_pgno [expr $sqlite_pending_byte / 1024]
+ set zAppend [binary format Ia*IIa8 $mj_pgno $mj [string length $mj] $cksum \
+ "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7"
+ ]
+ set iOffset [expr (([file size testA.db-journal] + 511)/512)*512]
+ set fd [open testA.db-journal a+]
+ fconfigure $fd -encoding binary -translation binary
+ seek $fd $iOffset
+ puts -nonewline $fd $zAppend
+
+ # Also, fix the first journal-header in the journal-file. Because the
+ # journal file has not yet been synced, the 8-byte magic string at the
+ # start of the first journal-header has not been written by SQLite.
+ # So write it now.
+ seek $fd 0
+ puts -nonewline $fd "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7"
+ close $fd
+
+ # Open a handle on testA.db and use it to query the database. At one
+ # point the first query would attempt a hot rollback, attempt to open
+ # the master-journal file and return SQLITE_CANTOPEN when it could not
+ # be opened. This is incorrect, it should simply delete the journal
+ # file and proceed with the query.
+ #
+ do_test rollback-2.2 {
+ sqlite3 db2 testA.db
+ execsql {
+ SELECT distinct tbl_name FROM sqlite_master;
+ } db2
+ } {t1 t3}
+ if {[lsearch {exclusive persistent_journal no_journal} [permutation]]<0} {
+ do_test rollback-2.3 {
+ file exists testA.db-journal
+ } 0
+ }
+ do_test rollback-2.4 {
+ execsql {
+ SELECT distinct tbl_name FROM sqlite_master;
+ } db2
+ } {t1 t3}
+
+ db2 close
+}
+
+finish_test
diff --git a/test/rowhash.test b/test/rowhash.test
new file mode 100644
index 0000000..4a553cd
--- /dev/null
+++ b/test/rowhash.test
@@ -0,0 +1,59 @@
+# 2009 April 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. The
+# focus of this file is the code in rowhash.c.
+#
+# NB: The rowhash.c module is no longer part of the source tree. But
+# we might as well keep this test.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test rowhash-1.1 {
+ execsql {
+ CREATE TABLE t1(id INTEGER PRIMARY KEY, a, b, c);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+ CREATE INDEX i3 ON t1(c);
+ }
+} {}
+
+proc do_keyset_test {name lKey} {
+ db transaction {
+ execsql { DELETE FROM t1 }
+ foreach key $lKey {
+ execsql { INSERT OR IGNORE INTO t1 VALUES($key, 'a', 'b', 'c') }
+ }
+ }
+ do_test $name {
+ lsort -integer [execsql {
+ SELECT id FROM t1 WHERE a = 'a' OR b = 'b' OR c = 'c';
+ }]
+ } [lsort -integer -unique $lKey]
+}
+
+do_keyset_test rowhash-2.1 {1 2 3}
+do_keyset_test rowhash-2.2 {0 1 2 3}
+do_keyset_test rowhash-2.3 {62 125 188}
+if {[working_64bit_int]} {
+ expr srand(1)
+ unset -nocomplain i L
+ for {set i 4} {$i < 10} {incr i} {
+ for {set j 0} {$j < 5000} {incr j} {
+ lappend L [expr int(rand()*1000000000)]
+ }
+ do_keyset_test rowhash-2.$i $L
+ }
+}
+
+finish_test
diff --git a/test/rowid.test b/test/rowid.test
new file mode 100644
index 0000000..4a9404d
--- /dev/null
+++ b/test/rowid.test
@@ -0,0 +1,703 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the magic ROWID column that is
+# found on all tables.
+#
+# $Id: rowid.test,v 1.21 2009/06/26 15:14:55 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Basic ROWID functionality tests.
+#
+do_test rowid-1.1 {
+ execsql {
+ CREATE TABLE t1(x int, y int);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ SELECT x FROM t1 ORDER BY y;
+ }
+} {1 3}
+do_test rowid-1.2 {
+ set r [execsql {SELECT rowid FROM t1 ORDER BY x}]
+ global x2rowid rowid2x
+ set x2rowid(1) [lindex $r 0]
+ set x2rowid(3) [lindex $r 1]
+ set rowid2x($x2rowid(1)) 1
+ set rowid2x($x2rowid(3)) 3
+ llength $r
+} {2}
+do_test rowid-1.3 {
+ global x2rowid
+ set sql "SELECT x FROM t1 WHERE rowid==$x2rowid(1)"
+ execsql $sql
+} {1}
+do_test rowid-1.4 {
+ global x2rowid
+ set sql "SELECT x FROM t1 WHERE rowid==$x2rowid(3)"
+ execsql $sql
+} {3}
+do_test rowid-1.5 {
+ global x2rowid
+ set sql "SELECT x FROM t1 WHERE oid==$x2rowid(1)"
+ execsql $sql
+} {1}
+do_test rowid-1.6 {
+ global x2rowid
+ set sql "SELECT x FROM t1 WHERE OID==$x2rowid(3)"
+ execsql $sql
+} {3}
+do_test rowid-1.7 {
+ global x2rowid
+ set sql "SELECT x FROM t1 WHERE _rowid_==$x2rowid(1)"
+ execsql $sql
+} {1}
+do_test rowid-1.7.1 {
+ while 1 {
+ set norow [expr {int(rand()*1000000)}]
+ if {$norow!=$x2rowid(1) && $norow!=$x2rowid(3)} break
+ }
+ execsql "SELECT x FROM t1 WHERE rowid=$norow"
+} {}
+do_test rowid-1.8 {
+ global x2rowid
+ set v [execsql {SELECT x, oid FROM t1 order by x}]
+ set v2 [list 1 $x2rowid(1) 3 $x2rowid(3)]
+ expr {$v==$v2}
+} {1}
+do_test rowid-1.9 {
+ global x2rowid
+ set v [execsql {SELECT x, RowID FROM t1 order by x}]
+ set v2 [list 1 $x2rowid(1) 3 $x2rowid(3)]
+ expr {$v==$v2}
+} {1}
+do_test rowid-1.10 {
+ global x2rowid
+ set v [execsql {SELECT x, _rowid_ FROM t1 order by x}]
+ set v2 [list 1 $x2rowid(1) 3 $x2rowid(3)]
+ expr {$v==$v2}
+} {1}
+
+# We can insert or update the ROWID column.
+#
+do_test rowid-2.1 {
+ catchsql {
+ INSERT INTO t1(rowid,x,y) VALUES(1234,5,6);
+ SELECT rowid, * FROM t1;
+ }
+} {0 {1 1 2 2 3 4 1234 5 6}}
+do_test rowid-2.2 {
+ catchsql {
+ UPDATE t1 SET rowid=12345 WHERE x==1;
+ SELECT rowid, * FROM t1
+ }
+} {0 {2 3 4 1234 5 6 12345 1 2}}
+do_test rowid-2.3 {
+ catchsql {
+ INSERT INTO t1(y,x,oid) VALUES(8,7,1235);
+ SELECT rowid, * FROM t1 WHERE rowid>1000;
+ }
+} {0 {1234 5 6 1235 7 8 12345 1 2}}
+do_test rowid-2.4 {
+ catchsql {
+ UPDATE t1 SET oid=12346 WHERE x==1;
+ SELECT rowid, * FROM t1;
+ }
+} {0 {2 3 4 1234 5 6 1235 7 8 12346 1 2}}
+do_test rowid-2.5 {
+ catchsql {
+ INSERT INTO t1(x,_rowid_,y) VALUES(9,1236,10);
+ SELECT rowid, * FROM t1 WHERE rowid>1000;
+ }
+} {0 {1234 5 6 1235 7 8 1236 9 10 12346 1 2}}
+do_test rowid-2.6 {
+ catchsql {
+ UPDATE t1 SET _rowid_=12347 WHERE x==1;
+ SELECT rowid, * FROM t1 WHERE rowid>1000;
+ }
+} {0 {1234 5 6 1235 7 8 1236 9 10 12347 1 2}}
+
+# But we can use ROWID in the WHERE clause of an UPDATE that does not
+# change the ROWID.
+#
+do_test rowid-2.7 {
+ global x2rowid
+ set sql "UPDATE t1 SET x=2 WHERE OID==$x2rowid(3)"
+ execsql $sql
+ execsql {SELECT x FROM t1 ORDER BY x}
+} {1 2 5 7 9}
+do_test rowid-2.8 {
+ global x2rowid
+ set sql "UPDATE t1 SET x=3 WHERE _rowid_==$x2rowid(3)"
+ execsql $sql
+ execsql {SELECT x FROM t1 ORDER BY x}
+} {1 3 5 7 9}
+
+# We cannot index by ROWID
+#
+do_test rowid-2.9 {
+ set v [catch {execsql {CREATE INDEX idxt1 ON t1(rowid)}} msg]
+ lappend v $msg
+} {1 {table t1 has no column named rowid}}
+do_test rowid-2.10 {
+ set v [catch {execsql {CREATE INDEX idxt1 ON t1(_rowid_)}} msg]
+ lappend v $msg
+} {1 {table t1 has no column named _rowid_}}
+do_test rowid-2.11 {
+ set v [catch {execsql {CREATE INDEX idxt1 ON t1(oid)}} msg]
+ lappend v $msg
+} {1 {table t1 has no column named oid}}
+do_test rowid-2.12 {
+ set v [catch {execsql {CREATE INDEX idxt1 ON t1(x, rowid)}} msg]
+ lappend v $msg
+} {1 {table t1 has no column named rowid}}
+
+# Columns defined in the CREATE statement override the buildin ROWID
+# column names.
+#
+do_test rowid-3.1 {
+ execsql {
+ CREATE TABLE t2(rowid int, x int, y int);
+ INSERT INTO t2 VALUES(0,2,3);
+ INSERT INTO t2 VALUES(4,5,6);
+ INSERT INTO t2 VALUES(7,8,9);
+ SELECT * FROM t2 ORDER BY x;
+ }
+} {0 2 3 4 5 6 7 8 9}
+do_test rowid-3.2 {
+ execsql {SELECT * FROM t2 ORDER BY rowid}
+} {0 2 3 4 5 6 7 8 9}
+do_test rowid-3.3 {
+ execsql {SELECT rowid, x, y FROM t2 ORDER BY rowid}
+} {0 2 3 4 5 6 7 8 9}
+do_test rowid-3.4 {
+ set r1 [execsql {SELECT _rowid_, rowid FROM t2 ORDER BY rowid}]
+ foreach {a b c d e f} $r1 {}
+ set r2 [execsql {SELECT _rowid_, rowid FROM t2 ORDER BY x DESC}]
+ foreach {u v w x y z} $r2 {}
+ expr {$u==$e && $w==$c && $y==$a}
+} {1}
+# sqlite3 v3 - do_probtest doesn't exist anymore?
+if 0 {
+do_probtest rowid-3.5 {
+ set r1 [execsql {SELECT _rowid_, rowid FROM t2 ORDER BY rowid}]
+ foreach {a b c d e f} $r1 {}
+ expr {$a!=$b && $c!=$d && $e!=$f}
+} {1}
+}
+
+# Let's try some more complex examples, including some joins.
+#
+do_test rowid-4.1 {
+ execsql {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ }
+ for {set i 1} {$i<=50} {incr i} {
+ execsql "INSERT INTO t1(x,y) VALUES($i,[expr {$i*$i}])"
+ }
+ execsql {INSERT INTO t2 SELECT _rowid_, x*y, y*y FROM t1}
+ execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1.rowid==t2.rowid}
+} {256}
+do_test rowid-4.2 {
+ execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1.rowid==t2.rowid}
+} {256}
+do_test rowid-4.2.1 {
+ execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1.oid==t2.rowid}
+} {256}
+do_test rowid-4.2.2 {
+ execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1._rowid_==t2.rowid}
+} {256}
+do_test rowid-4.2.3 {
+ execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t2.rowid==t1.rowid}
+} {256}
+do_test rowid-4.2.4 {
+ execsql {SELECT t2.y FROM t2, t1 WHERE t2.rowid==t1.oid AND t1.x==4}
+} {256}
+do_test rowid-4.2.5 {
+ execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1._rowid_==t2.rowid}
+} {256}
+do_test rowid-4.2.6 {
+ execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t2.rowid==t1.rowid}
+} {256}
+do_test rowid-4.2.7 {
+ execsql {SELECT t2.y FROM t1, t2 WHERE t2.rowid==t1.oid AND t1.x==4}
+} {256}
+do_test rowid-4.3 {
+ execsql {CREATE INDEX idxt1 ON t1(x)}
+ execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1.rowid==t2.rowid}
+} {256}
+do_test rowid-4.3.1 {
+ execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1._rowid_==t2.rowid}
+} {256}
+do_test rowid-4.3.2 {
+ execsql {SELECT t2.y FROM t1, t2 WHERE t2.rowid==t1.oid AND 4==t1.x}
+} {256}
+do_test rowid-4.4 {
+ execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1.rowid==t2.rowid}
+} {256}
+do_test rowid-4.4.1 {
+ execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1._rowid_==t2.rowid}
+} {256}
+do_test rowid-4.4.2 {
+ execsql {SELECT t2.y FROM t2, t1 WHERE t2.rowid==t1.oid AND 4==t1.x}
+} {256}
+do_test rowid-4.5 {
+ execsql {CREATE INDEX idxt2 ON t2(y)}
+ set sqlite_search_count 0
+ concat [execsql {
+ SELECT t1.x FROM t2, t1
+ WHERE t2.y==256 AND t1.rowid==t2.rowid
+ }] $sqlite_search_count
+} {4 3}
+do_test rowid-4.5.1 {
+ set sqlite_search_count 0
+ concat [execsql {
+ SELECT t1.x FROM t2, t1
+ WHERE t1.OID==t2.rowid AND t2.y==81
+ }] $sqlite_search_count
+} {3 3}
+do_test rowid-4.6 {
+ execsql {
+ SELECT t1.x FROM t1, t2
+ WHERE t2.y==256 AND t1.rowid==t2.rowid
+ }
+} {4}
+
+do_test rowid-5.1.1 {
+ ifcapable subquery {
+ execsql {DELETE FROM t1 WHERE _rowid_ IN (SELECT oid FROM t1 WHERE x>8)}
+ } else {
+ set oids [execsql {SELECT oid FROM t1 WHERE x>8}]
+ set where "_rowid_ = [join $oids { OR _rowid_ = }]"
+ execsql "DELETE FROM t1 WHERE $where"
+ }
+} {}
+do_test rowid-5.1.2 {
+ execsql {SELECT max(x) FROM t1}
+} {8}
+
+# Make sure a "WHERE rowid=X" clause works when there is no ROWID of X.
+#
+do_test rowid-6.1 {
+ execsql {
+ SELECT x FROM t1
+ }
+} {1 2 3 4 5 6 7 8}
+do_test rowid-6.2 {
+ for {set ::norow 1} {1} {incr ::norow} {
+ if {[execsql "SELECT x FROM t1 WHERE rowid=$::norow"]==""} break
+ }
+ execsql [subst {
+ DELETE FROM t1 WHERE rowid=$::norow
+ }]
+} {}
+do_test rowid-6.3 {
+ execsql {
+ SELECT x FROM t1
+ }
+} {1 2 3 4 5 6 7 8}
+
+# Beginning with version 2.3.4, SQLite computes rowids of new rows by
+# finding the maximum current rowid and adding one. It falls back to
+# the old random algorithm if the maximum rowid is the largest integer.
+# The following tests are for this new behavior.
+#
+do_test rowid-7.0 {
+ execsql {
+ DELETE FROM t1;
+ DROP TABLE t2;
+ DROP INDEX idxt1;
+ INSERT INTO t1 VALUES(1,2);
+ SELECT rowid, * FROM t1;
+ }
+} {1 1 2}
+do_test rowid-7.1 {
+ execsql {
+ INSERT INTO t1 VALUES(99,100);
+ SELECT rowid,* FROM t1
+ }
+} {1 1 2 2 99 100}
+do_test rowid-7.2 {
+ execsql {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t2(b) VALUES(55);
+ SELECT * FROM t2;
+ }
+} {1 55}
+do_test rowid-7.3 {
+ execsql {
+ INSERT INTO t2(b) VALUES(66);
+ SELECT * FROM t2;
+ }
+} {1 55 2 66}
+do_test rowid-7.4 {
+ execsql {
+ INSERT INTO t2(a,b) VALUES(1000000,77);
+ INSERT INTO t2(b) VALUES(88);
+ SELECT * FROM t2;
+ }
+} {1 55 2 66 1000000 77 1000001 88}
+do_test rowid-7.5 {
+ execsql {
+ INSERT INTO t2(a,b) VALUES(2147483647,99);
+ INSERT INTO t2(b) VALUES(11);
+ SELECT b FROM t2 ORDER BY b;
+ }
+} {11 55 66 77 88 99}
+ifcapable subquery {
+ do_test rowid-7.6 {
+ execsql {
+ SELECT b FROM t2 WHERE a NOT IN(1,2,1000000,1000001,2147483647);
+ }
+ } {11}
+ do_test rowid-7.7 {
+ execsql {
+ INSERT INTO t2(b) VALUES(22);
+ INSERT INTO t2(b) VALUES(33);
+ INSERT INTO t2(b) VALUES(44);
+ INSERT INTO t2(b) VALUES(55);
+ SELECT b FROM t2 WHERE a NOT IN(1,2,1000000,1000001,2147483647)
+ ORDER BY b;
+ }
+ } {11 22 33 44 55}
+}
+do_test rowid-7.8 {
+ execsql {
+ DELETE FROM t2 WHERE a!=2;
+ INSERT INTO t2(b) VALUES(111);
+ SELECT * FROM t2;
+ }
+} {2 66 3 111}
+
+ifcapable {trigger} {
+# Make sure AFTER triggers that do INSERTs do not change the last_insert_rowid.
+# Ticket #290
+#
+do_test rowid-8.1 {
+ execsql {
+ CREATE TABLE t3(a integer primary key);
+ CREATE TABLE t4(x);
+ INSERT INTO t4 VALUES(1);
+ CREATE TRIGGER r3 AFTER INSERT on t3 FOR EACH ROW BEGIN
+ INSERT INTO t4 VALUES(NEW.a+10);
+ END;
+ SELECT * FROM t3;
+ }
+} {}
+do_test rowid-8.2 {
+ execsql {
+ SELECT rowid, * FROM t4;
+ }
+} {1 1}
+do_test rowid-8.3 {
+ execsql {
+ INSERT INTO t3 VALUES(123);
+ SELECT last_insert_rowid();
+ }
+} {123}
+do_test rowid-8.4 {
+ execsql {
+ SELECT * FROM t3;
+ }
+} {123}
+do_test rowid-8.5 {
+ execsql {
+ SELECT rowid, * FROM t4;
+ }
+} {1 1 2 133}
+do_test rowid-8.6 {
+ execsql {
+ INSERT INTO t3 VALUES(NULL);
+ SELECT last_insert_rowid();
+ }
+} {124}
+do_test rowid-8.7 {
+ execsql {
+ SELECT * FROM t3;
+ }
+} {123 124}
+do_test rowid-8.8 {
+ execsql {
+ SELECT rowid, * FROM t4;
+ }
+} {1 1 2 133 3 134}
+} ;# endif trigger
+
+# If triggers are not enable, simulate their effect for the tests that
+# follow.
+ifcapable {!trigger} {
+ execsql {
+ CREATE TABLE t3(a integer primary key);
+ INSERT INTO t3 VALUES(123);
+ INSERT INTO t3 VALUES(124);
+ }
+}
+
+# ticket #377: Comparison between integer primiary key and floating point
+# values.
+#
+do_test rowid-9.1 {
+ execsql {
+ SELECT * FROM t3 WHERE a<123.5
+ }
+} {123}
+do_test rowid-9.2 {
+ execsql {
+ SELECT * FROM t3 WHERE a<124.5
+ }
+} {123 124}
+do_test rowid-9.3 {
+ execsql {
+ SELECT * FROM t3 WHERE a>123.5
+ }
+} {124}
+do_test rowid-9.4 {
+ execsql {
+ SELECT * FROM t3 WHERE a>122.5
+ }
+} {123 124}
+do_test rowid-9.5 {
+ execsql {
+ SELECT * FROM t3 WHERE a==123.5
+ }
+} {}
+do_test rowid-9.6 {
+ execsql {
+ SELECT * FROM t3 WHERE a==123.000
+ }
+} {123}
+do_test rowid-9.7 {
+ execsql {
+ SELECT * FROM t3 WHERE a>100.5 AND a<200.5
+ }
+} {123 124}
+do_test rowid-9.8 {
+ execsql {
+ SELECT * FROM t3 WHERE a>'xyz';
+ }
+} {}
+do_test rowid-9.9 {
+ execsql {
+ SELECT * FROM t3 WHERE a<'xyz';
+ }
+} {123 124}
+do_test rowid-9.10 {
+ execsql {
+ SELECT * FROM t3 WHERE a>=122.9 AND a<=123.1
+ }
+} {123}
+
+# Ticket #567. Comparisons of ROWID or integery primary key against
+# floating point numbers still do not always work.
+#
+do_test rowid-10.1 {
+ execsql {
+ CREATE TABLE t5(a);
+ INSERT INTO t5 VALUES(1);
+ INSERT INTO t5 VALUES(2);
+ INSERT INTO t5 SELECT a+2 FROM t5;
+ INSERT INTO t5 SELECT a+4 FROM t5;
+ SELECT rowid, * FROM t5;
+ }
+} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}
+do_test rowid-10.2 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.5}
+} {6 6 7 7 8 8}
+do_test rowid-10.3 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.0}
+} {5 5 6 6 7 7 8 8}
+do_test rowid-10.4 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>5.5}
+} {6 6 7 7 8 8}
+do_test rowid-10.3.2 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>5.0}
+} {6 6 7 7 8 8}
+do_test rowid-10.5 {
+ execsql {SELECT rowid, a FROM t5 WHERE 5.5<=rowid}
+} {6 6 7 7 8 8}
+do_test rowid-10.6 {
+ execsql {SELECT rowid, a FROM t5 WHERE 5.5<rowid}
+} {6 6 7 7 8 8}
+do_test rowid-10.7 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid<=5.5}
+} {1 1 2 2 3 3 4 4 5 5}
+do_test rowid-10.8 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid<5.5}
+} {1 1 2 2 3 3 4 4 5 5}
+do_test rowid-10.9 {
+ execsql {SELECT rowid, a FROM t5 WHERE 5.5>=rowid}
+} {1 1 2 2 3 3 4 4 5 5}
+do_test rowid-10.10 {
+ execsql {SELECT rowid, a FROM t5 WHERE 5.5>rowid}
+} {1 1 2 2 3 3 4 4 5 5}
+do_test rowid-10.11 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.5 ORDER BY rowid DESC}
+} {8 8 7 7 6 6}
+do_test rowid-10.11.2 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.0 ORDER BY rowid DESC}
+} {8 8 7 7 6 6 5 5}
+do_test rowid-10.12 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>5.5 ORDER BY rowid DESC}
+} {8 8 7 7 6 6}
+do_test rowid-10.12.2 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>5.0 ORDER BY rowid DESC}
+} {8 8 7 7 6 6}
+do_test rowid-10.13 {
+ execsql {SELECT rowid, a FROM t5 WHERE 5.5<=rowid ORDER BY rowid DESC}
+} {8 8 7 7 6 6}
+do_test rowid-10.14 {
+ execsql {SELECT rowid, a FROM t5 WHERE 5.5<rowid ORDER BY rowid DESC}
+} {8 8 7 7 6 6}
+do_test rowid-10.15 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid<=5.5 ORDER BY rowid DESC}
+} {5 5 4 4 3 3 2 2 1 1}
+do_test rowid-10.16 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid<5.5 ORDER BY rowid DESC}
+} {5 5 4 4 3 3 2 2 1 1}
+do_test rowid-10.17 {
+ execsql {SELECT rowid, a FROM t5 WHERE 5.5>=rowid ORDER BY rowid DESC}
+} {5 5 4 4 3 3 2 2 1 1}
+do_test rowid-10.18 {
+ execsql {SELECT rowid, a FROM t5 WHERE 5.5>rowid ORDER BY rowid DESC}
+} {5 5 4 4 3 3 2 2 1 1}
+
+do_test rowid-10.30 {
+ execsql {
+ CREATE TABLE t6(a);
+ INSERT INTO t6(rowid,a) SELECT -a,a FROM t5;
+ SELECT rowid, * FROM t6;
+ }
+} {-8 8 -7 7 -6 6 -5 5 -4 4 -3 3 -2 2 -1 1}
+do_test rowid-10.31.1 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.5}
+} {-5 5 -4 4 -3 3 -2 2 -1 1}
+do_test rowid-10.31.2 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.0}
+} {-5 5 -4 4 -3 3 -2 2 -1 1}
+do_test rowid-10.32.1 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.5 ORDER BY rowid DESC}
+} {-1 1 -2 2 -3 3 -4 4 -5 5}
+do_test rowid-10.32.1 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.0 ORDER BY rowid DESC}
+} {-1 1 -2 2 -3 3 -4 4 -5 5}
+do_test rowid-10.33 {
+ execsql {SELECT rowid, a FROM t6 WHERE -5.5<=rowid}
+} {-5 5 -4 4 -3 3 -2 2 -1 1}
+do_test rowid-10.34 {
+ execsql {SELECT rowid, a FROM t6 WHERE -5.5<=rowid ORDER BY rowid DESC}
+} {-1 1 -2 2 -3 3 -4 4 -5 5}
+do_test rowid-10.35.1 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.5}
+} {-5 5 -4 4 -3 3 -2 2 -1 1}
+do_test rowid-10.35.2 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.0}
+} {-4 4 -3 3 -2 2 -1 1}
+do_test rowid-10.36.1 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.5 ORDER BY rowid DESC}
+} {-1 1 -2 2 -3 3 -4 4 -5 5}
+do_test rowid-10.36.2 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.0 ORDER BY rowid DESC}
+} {-1 1 -2 2 -3 3 -4 4}
+do_test rowid-10.37 {
+ execsql {SELECT rowid, a FROM t6 WHERE -5.5<rowid}
+} {-5 5 -4 4 -3 3 -2 2 -1 1}
+do_test rowid-10.38 {
+ execsql {SELECT rowid, a FROM t6 WHERE -5.5<rowid ORDER BY rowid DESC}
+} {-1 1 -2 2 -3 3 -4 4 -5 5}
+do_test rowid-10.39 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid<=-5.5}
+} {-8 8 -7 7 -6 6}
+do_test rowid-10.40 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid<=-5.5 ORDER BY rowid DESC}
+} {-6 6 -7 7 -8 8}
+do_test rowid-10.41 {
+ execsql {SELECT rowid, a FROM t6 WHERE -5.5>=rowid}
+} {-8 8 -7 7 -6 6}
+do_test rowid-10.42 {
+ execsql {SELECT rowid, a FROM t6 WHERE -5.5>=rowid ORDER BY rowid DESC}
+} {-6 6 -7 7 -8 8}
+do_test rowid-10.43 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid<-5.5}
+} {-8 8 -7 7 -6 6}
+do_test rowid-10.44 {
+ execsql {SELECT rowid, a FROM t6 WHERE rowid<-5.5 ORDER BY rowid DESC}
+} {-6 6 -7 7 -8 8}
+do_test rowid-10.44 {
+ execsql {SELECT rowid, a FROM t6 WHERE -5.5>rowid}
+} {-8 8 -7 7 -6 6}
+do_test rowid-10.46 {
+ execsql {SELECT rowid, a FROM t6 WHERE -5.5>rowid ORDER BY rowid DESC}
+} {-6 6 -7 7 -8 8}
+
+# Comparison of rowid against string values.
+#
+do_test rowid-11.1 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>'abc'}
+} {}
+do_test rowid-11.2 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>='abc'}
+} {}
+do_test rowid-11.3 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid<'abc'}
+} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}
+do_test rowid-11.4 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid<='abc'}
+} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}
+
+# Test the automatic generation of rowids when the table already contains
+# a rowid with the maximum value.
+#
+# Once the the maximum rowid is taken, rowids are normally chosen at
+# random. By by reseting the random number generator, we can cause
+# the rowid guessing loop to collide with prior rowids, and test the
+# loop out to its limit of 100 iterations. After 100 collisions, the
+# rowid guesser gives up and reports SQLITE_FULL.
+#
+do_test rowid-12.1 {
+ execsql {
+ CREATE TABLE t7(x INTEGER PRIMARY KEY, y);
+ CREATE TABLE t7temp(a INTEGER PRIMARY KEY);
+ INSERT INTO t7 VALUES(9223372036854775807,'a');
+ SELECT y FROM t7;
+ }
+} {a}
+do_test rowid-12.2 {
+ db close
+ sqlite3 db test.db
+ save_prng_state
+ execsql {
+ INSERT INTO t7 VALUES(NULL,'b');
+ SELECT x, y FROM t7;
+ }
+} {1 b 9223372036854775807 a}
+execsql {INSERT INTO t7 VALUES(2,'y');}
+for {set i 1} {$i<100} {incr i} {
+ do_test rowid-12.3.$i {
+ db eval {DELETE FROM t7temp; INSERT INTO t7temp VALUES(1);}
+ restore_prng_state
+ execsql {
+ INSERT INTO t7 VALUES(NULL,'x');
+ SELECT count(*) FROM t7 WHERE y=='x';
+ }
+ } $i
+}
+do_test rowid-12.4 {
+ db eval {DELETE FROM t7temp; INSERT INTO t7temp VALUES(1);}
+ restore_prng_state
+ catchsql {
+ INSERT INTO t7 VALUES(NULL,'x');
+ }
+} {1 {database or disk is full}}
+
+
+finish_test
diff --git a/test/rtree.test b/test/rtree.test
new file mode 100644
index 0000000..b504574
--- /dev/null
+++ b/test/rtree.test
@@ -0,0 +1,18 @@
+# 2008 June 23
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file runs all rtree related tests.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/permutations.test
+
+ifcapable rtree {
+ run_test_suite rtree
+}
+
+finish_test
diff --git a/test/savepoint.test b/test/savepoint.test
new file mode 100644
index 0000000..3bbbaaa
--- /dev/null
+++ b/test/savepoint.test
@@ -0,0 +1,1045 @@
+# 2008 December 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: savepoint.test,v 1.13 2009/07/18 08:30:45 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+#----------------------------------------------------------------------
+# The following tests - savepoint-1.* - test that the SAVEPOINT, RELEASE
+# and ROLLBACK TO comands are correctly parsed, and that the auto-commit
+# flag is correctly set and unset as a result.
+#
+do_test savepoint-1.1 {
+ wal_set_journal_mode
+ execsql {
+ SAVEPOINT sp1;
+ RELEASE sp1;
+ }
+} {}
+do_test savepoint-1.2 {
+ execsql {
+ SAVEPOINT sp1;
+ ROLLBACK TO sp1;
+ }
+} {}
+do_test savepoint-1.3 {
+ execsql { SAVEPOINT sp1 }
+ db close
+} {}
+sqlite3 db test.db
+do_test savepoint-1.4.1 {
+ execsql {
+ SAVEPOINT sp1;
+ SAVEPOINT sp2;
+ RELEASE sp1;
+ }
+ sqlite3_get_autocommit db
+} {1}
+do_test savepoint-1.4.2 {
+ execsql {
+ SAVEPOINT sp1;
+ SAVEPOINT sp2;
+ RELEASE sp2;
+ }
+ sqlite3_get_autocommit db
+} {0}
+do_test savepoint-1.4.3 {
+ execsql { RELEASE sp1 }
+ sqlite3_get_autocommit db
+} {1}
+do_test savepoint-1.4.4 {
+ execsql {
+ SAVEPOINT sp1;
+ SAVEPOINT sp2;
+ ROLLBACK TO sp1;
+ }
+ sqlite3_get_autocommit db
+} {0}
+do_test savepoint-1.4.5 {
+ execsql { RELEASE SAVEPOINT sp1 }
+ sqlite3_get_autocommit db
+} {1}
+do_test savepoint-1.4.6 {
+ execsql {
+ SAVEPOINT sp1;
+ SAVEPOINT sp2;
+ SAVEPOINT sp3;
+ ROLLBACK TO SAVEPOINT sp3;
+ ROLLBACK TRANSACTION TO sp2;
+ ROLLBACK TRANSACTION TO SAVEPOINT sp1;
+ }
+ sqlite3_get_autocommit db
+} {0}
+do_test savepoint-1.4.7 {
+ execsql { RELEASE SAVEPOINT SP1 }
+ sqlite3_get_autocommit db
+} {1}
+do_test savepoint-1.5 {
+ execsql {
+ SAVEPOINT sp1;
+ ROLLBACK TO sp1;
+ }
+} {}
+do_test savepoint-1.6 {
+ execsql COMMIT
+} {}
+wal_check_journal_mode savepoint-1.7
+
+#------------------------------------------------------------------------
+# These tests - savepoint-2.* - test rollbacks and releases of savepoints
+# with a very simple data set.
+#
+
+do_test savepoint-2.1 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2, 3);
+ SAVEPOINT one;
+ UPDATE t1 SET a = 2, b = 3, c = 4;
+ }
+ execsql { SELECT * FROM t1 }
+} {2 3 4}
+do_test savepoint-2.2 {
+ execsql {
+ ROLLBACK TO one;
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2 3}
+do_test savepoint-2.3 {
+ execsql {
+ INSERT INTO t1 VALUES(4, 5, 6);
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4 5 6}
+do_test savepoint-2.4 {
+ execsql {
+ ROLLBACK TO one;
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2 3}
+
+
+do_test savepoint-2.5 {
+ execsql {
+ INSERT INTO t1 VALUES(7, 8, 9);
+ SAVEPOINT two;
+ INSERT INTO t1 VALUES(10, 11, 12);
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 7 8 9 10 11 12}
+do_test savepoint-2.6 {
+ execsql {
+ ROLLBACK TO two;
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 7 8 9}
+do_test savepoint-2.7 {
+ execsql {
+ INSERT INTO t1 VALUES(10, 11, 12);
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 7 8 9 10 11 12}
+do_test savepoint-2.8 {
+ execsql {
+ ROLLBACK TO one;
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2 3}
+do_test savepoint-2.9 {
+ execsql {
+ INSERT INTO t1 VALUES('a', 'b', 'c');
+ SAVEPOINT two;
+ INSERT INTO t1 VALUES('d', 'e', 'f');
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 a b c d e f}
+do_test savepoint-2.10 {
+ execsql {
+ RELEASE two;
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 a b c d e f}
+do_test savepoint-2.11 {
+ execsql {
+ ROLLBACK;
+ }
+ execsql { SELECT * FROM t1 }
+} {}
+wal_check_journal_mode savepoint-2.12
+
+#------------------------------------------------------------------------
+# This block of tests - savepoint-3.* - test that when a transaction
+# savepoint is rolled back, locks are not released from database files.
+# And that when a transaction savepoint is released, they are released.
+#
+# These tests do not work in WAL mode. WAL mode does not take RESERVED
+# locks on the database file.
+#
+if {[wal_is_wal_mode]==0} {
+ do_test savepoint-3.1 {
+ execsql { SAVEPOINT "transaction" }
+ execsql { PRAGMA lock_status }
+ } {main unlocked temp closed}
+
+ do_test savepoint-3.2 {
+ execsql { INSERT INTO t1 VALUES(1, 2, 3) }
+ execsql { PRAGMA lock_status }
+ } {main reserved temp closed}
+
+ do_test savepoint-3.3 {
+ execsql { ROLLBACK TO "transaction" }
+ execsql { PRAGMA lock_status }
+ } {main reserved temp closed}
+
+ do_test savepoint-3.4 {
+ execsql { INSERT INTO t1 VALUES(1, 2, 3) }
+ execsql { PRAGMA lock_status }
+ } {main reserved temp closed}
+
+ do_test savepoint-3.5 {
+ execsql { RELEASE "transaction" }
+ execsql { PRAGMA lock_status }
+ } {main unlocked temp closed}
+}
+
+#------------------------------------------------------------------------
+# Test that savepoints that include schema modifications are handled
+# correctly. Test cases savepoint-4.*.
+#
+do_test savepoint-4.1 {
+ execsql {
+ CREATE TABLE t2(d, e, f);
+ SELECT sql FROM sqlite_master;
+ }
+} {{CREATE TABLE t1(a, b, c)} {CREATE TABLE t2(d, e, f)}}
+do_test savepoint-4.2 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(g,h);
+ INSERT INTO t3 VALUES('I', 'II');
+ SAVEPOINT one;
+ DROP TABLE t3;
+ }
+} {}
+do_test savepoint-4.3 {
+ execsql {
+ CREATE TABLE t3(g, h, i);
+ INSERT INTO t3 VALUES('III', 'IV', 'V');
+ }
+ execsql {SELECT * FROM t3}
+} {III IV V}
+do_test savepoint-4.4 {
+ execsql { ROLLBACK TO one; }
+ execsql {SELECT * FROM t3}
+} {I II}
+do_test savepoint-4.5 {
+ execsql {
+ ROLLBACK;
+ SELECT sql FROM sqlite_master;
+ }
+} {{CREATE TABLE t1(a, b, c)} {CREATE TABLE t2(d, e, f)}}
+
+do_test savepoint-4.6 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('o', 't', 't');
+ SAVEPOINT sp1;
+ CREATE TABLE t3(a, b, c);
+ INSERT INTO t3 VALUES('z', 'y', 'x');
+ }
+ execsql {SELECT * FROM t3}
+} {z y x}
+do_test savepoint-4.7 {
+ execsql {
+ ROLLBACK TO sp1;
+ CREATE TABLE t3(a);
+ INSERT INTO t3 VALUES('value');
+ }
+ execsql {SELECT * FROM t3}
+} {value}
+do_test savepoint-4.8 {
+ execsql COMMIT
+} {}
+wal_check_journal_mode savepoint-4.9
+
+#------------------------------------------------------------------------
+# Test some logic errors to do with the savepoint feature.
+#
+
+ifcapable incrblob {
+ do_test savepoint-5.1.1 {
+ execsql {
+ CREATE TABLE blobs(x);
+ INSERT INTO blobs VALUES('a twentyeight character blob');
+ }
+ set fd [db incrblob blobs x 1]
+ puts -nonewline $fd "hello"
+ catchsql {SAVEPOINT abc}
+ } {1 {cannot open savepoint - SQL statements in progress}}
+ do_test savepoint-5.1.2 {
+ close $fd
+ catchsql {SAVEPOINT abc}
+ } {0 {}}
+
+ do_test savepoint-5.2 {
+ execsql {RELEASE abc}
+ catchsql {RELEASE abc}
+ } {1 {no such savepoint: abc}}
+
+ do_test savepoint-5.3.1 {
+ execsql {SAVEPOINT abc}
+ catchsql {ROLLBACK TO def}
+ } {1 {no such savepoint: def}}
+ do_test savepoint-5.3.2 {
+ execsql {SAVEPOINT def}
+ set fd [db incrblob -readonly blobs x 1]
+ catchsql {ROLLBACK TO def}
+ } {1 {cannot rollback savepoint - SQL statements in progress}}
+ do_test savepoint-5.3.3 {
+ catchsql {RELEASE def}
+ } {0 {}}
+ do_test savepoint-5.3.4 {
+ close $fd
+ execsql {savepoint def}
+ set fd [db incrblob blobs x 1]
+ catchsql {release def}
+ } {1 {cannot release savepoint - SQL statements in progress}}
+ do_test savepoint-5.3.5 {
+ close $fd
+ execsql {release abc}
+ } {}
+
+ # Rollback mode:
+ #
+ # Open a savepoint transaction and insert a row into the database. Then,
+ # using a second database handle, open a read-only transaction on the
+ # database file. Check that the savepoint transaction cannot be committed
+ # until after the read-only transaction has been closed.
+ #
+ # WAL mode:
+ #
+ # As above, except that the savepoint transaction can be successfully
+ # committed before the read-only transaction has been closed.
+ #
+ do_test savepoint-5.4.1 {
+ execsql {
+ SAVEPOINT main;
+ INSERT INTO blobs VALUES('another blob');
+ }
+ } {}
+ do_test savepoint-5.4.2 {
+ sqlite3 db2 test.db
+ execsql { BEGIN ; SELECT count(*) FROM blobs } db2
+ } {1}
+ if {[wal_is_wal_mode]} {
+ do_test savepoint-5.4.3 { catchsql "RELEASE main" } {0 {}}
+ do_test savepoint-5.4.4 { db2 close } {}
+ } else {
+ do_test savepoint-5.4.3 {
+ catchsql { RELEASE main }
+ } {1 {database is locked}}
+ do_test savepoint-5.4.4 {
+ db2 close
+ catchsql { RELEASE main }
+ } {0 {}}
+ }
+ do_test savepoint-5.4.5 {
+ execsql { SELECT x FROM blobs WHERE rowid = 2 }
+ } {{another blob}}
+ do_test savepoint-5.4.6 {
+ execsql { SELECT count(*) FROM blobs }
+ } {2}
+}
+wal_check_journal_mode savepoint-5.5
+
+#-------------------------------------------------------------------------
+# The following tests, savepoint-6.*, test an incr-vacuum inside of a
+# couple of nested savepoints.
+#
+ifcapable {autovacuum && pragma} {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+
+ do_test savepoint-6.1 {
+ execsql { PRAGMA auto_vacuum = incremental }
+ wal_set_journal_mode
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(a, b);
+ BEGIN;
+ INSERT INTO t1 VALUES(randstr(10,400),randstr(10,400),randstr(10,400));
+ }
+ set r "randstr(10,400)"
+ for {set ii 0} {$ii < 10} {incr ii} {
+ execsql "INSERT INTO t1 SELECT $r, $r, $r FROM t1"
+ }
+ execsql { COMMIT }
+ } {}
+
+ integrity_check savepoint-6.2
+
+ do_test savepoint-6.3 {
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ UPDATE t1 SET a = randstr(10,10) WHERE (rowid%4)==0;
+ SAVEPOINT one;
+ DELETE FROM t1 WHERE rowid%2;
+ PRAGMA incr_vacuum;
+ SAVEPOINT two;
+ INSERT INTO t1 SELECT randstr(10,400), randstr(10,400), c FROM t1;
+ DELETE FROM t1 WHERE rowid%2;
+ PRAGMA incr_vacuum;
+ ROLLBACK TO one;
+ COMMIT;
+ }
+ } {}
+
+ integrity_check savepoint-6.4
+
+ wal_check_journal_mode savepoint-6.5
+}
+
+#-------------------------------------------------------------------------
+# The following tests, savepoint-7.*, attempt to break the logic
+# surrounding savepoints by growing and shrinking the database file.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+
+do_test savepoint-7.1 {
+ execsql { PRAGMA auto_vacuum = incremental }
+ wal_set_journal_mode
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1(a) VALUES('alligator');
+ INSERT INTO t1(a) VALUES('angelfish');
+ INSERT INTO t1(a) VALUES('ant');
+ INSERT INTO t1(a) VALUES('antelope');
+ INSERT INTO t1(a) VALUES('ape');
+ INSERT INTO t1(a) VALUES('baboon');
+ INSERT INTO t1(a) VALUES('badger');
+ INSERT INTO t1(a) VALUES('bear');
+ INSERT INTO t1(a) VALUES('beetle');
+ INSERT INTO t1(a) VALUES('bird');
+ INSERT INTO t1(a) VALUES('bison');
+ UPDATE t1 SET b = randstr(1000,1000);
+ UPDATE t1 SET b = b||randstr(1000,1000);
+ UPDATE t1 SET b = b||randstr(1000,1000);
+ UPDATE t1 SET b = b||randstr(10,1000);
+ COMMIT;
+ }
+ expr ([execsql { PRAGMA page_count }] > 20)
+} {1}
+do_test savepoint-7.2.1 {
+ execsql {
+ BEGIN;
+ SAVEPOINT one;
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 SELECT a, b FROM t1;
+ ROLLBACK TO one;
+ }
+ execsql {
+ PRAGMA integrity_check;
+ }
+} {ok}
+do_test savepoint-7.2.2 {
+ execsql {
+ COMMIT;
+ PRAGMA integrity_check;
+ }
+} {ok}
+
+do_test savepoint-7.3.1 {
+ execsql {
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 SELECT a, b FROM t1;
+ }
+} {}
+do_test savepoint-7.3.2 {
+ execsql {
+ BEGIN;
+ SAVEPOINT one;
+ DELETE FROM t2;
+ PRAGMA incremental_vacuum;
+ SAVEPOINT two;
+ INSERT INTO t2 SELECT a, b FROM t1;
+ ROLLBACK TO two;
+ COMMIT;
+ }
+ execsql { PRAGMA integrity_check }
+} {ok}
+wal_check_journal_mode savepoint-7.3.3
+
+do_test savepoint-7.4.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql { PRAGMA auto_vacuum = incremental }
+ wal_set_journal_mode
+ execsql {
+ CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
+ INSERT INTO t1 VALUES(randstr(1000,1000), randstr(1000,1000));
+ BEGIN;
+ DELETE FROM t1;
+ SAVEPOINT one;
+ PRAGMA incremental_vacuum;
+ ROLLBACK TO one;
+ COMMIT;
+ }
+
+ execsql { PRAGMA integrity_check }
+} {ok}
+
+do_test savepoint-7.5.1 {
+ execsql {
+ PRAGMA incremental_vacuum;
+ CREATE TABLE t5(x, y);
+ INSERT INTO t5 VALUES(1, randstr(1000,1000));
+ INSERT INTO t5 VALUES(2, randstr(1000,1000));
+ INSERT INTO t5 VALUES(3, randstr(1000,1000));
+
+ BEGIN;
+ INSERT INTO t5 VALUES(4, randstr(1000,1000));
+ INSERT INTO t5 VALUES(5, randstr(1000,1000));
+ DELETE FROM t5 WHERE x=1 OR x=2;
+ SAVEPOINT one;
+ PRAGMA incremental_vacuum;
+ SAVEPOINT two;
+ INSERT INTO t5 VALUES(1, randstr(1000,1000));
+ INSERT INTO t5 VALUES(2, randstr(1000,1000));
+ ROLLBACK TO two;
+ ROLLBACK TO one;
+ COMMIT;
+ PRAGMA integrity_check;
+ }
+} {ok}
+do_test savepoint-7.5.2 {
+ execsql {
+ DROP TABLE t5;
+ }
+} {}
+wal_check_journal_mode savepoint-7.5.3
+
+# Test oddly named and quoted savepoints.
+#
+do_test savepoint-8-1 {
+ execsql { SAVEPOINT "save1" }
+ execsql { RELEASE save1 }
+} {}
+do_test savepoint-8-2 {
+ execsql { SAVEPOINT "Including whitespace " }
+ execsql { RELEASE "including Whitespace " }
+} {}
+
+# Test that the authorization callback works.
+#
+ifcapable auth {
+ proc auth {args} {
+ eval lappend ::authdata $args
+ return SQLITE_OK
+ }
+ db auth auth
+
+ do_test savepoint-9.1 {
+ set ::authdata [list]
+ execsql { SAVEPOINT sp1 }
+ set ::authdata
+ } {SQLITE_SAVEPOINT BEGIN sp1 {} {}}
+ do_test savepoint-9.2 {
+ set ::authdata [list]
+ execsql { ROLLBACK TO sp1 }
+ set ::authdata
+ } {SQLITE_SAVEPOINT ROLLBACK sp1 {} {}}
+ do_test savepoint-9.3 {
+ set ::authdata [list]
+ execsql { RELEASE sp1 }
+ set ::authdata
+ } {SQLITE_SAVEPOINT RELEASE sp1 {} {}}
+
+ proc auth {args} {
+ eval lappend ::authdata $args
+ return SQLITE_DENY
+ }
+ db auth auth
+
+ do_test savepoint-9.4 {
+ set ::authdata [list]
+ set res [catchsql { SAVEPOINT sp1 }]
+ concat $::authdata $res
+ } {SQLITE_SAVEPOINT BEGIN sp1 {} {} 1 {not authorized}}
+ do_test savepoint-9.5 {
+ set ::authdata [list]
+ set res [catchsql { ROLLBACK TO sp1 }]
+ concat $::authdata $res
+ } {SQLITE_SAVEPOINT ROLLBACK sp1 {} {} 1 {not authorized}}
+ do_test savepoint-9.6 {
+ set ::authdata [list]
+ set res [catchsql { RELEASE sp1 }]
+ concat $::authdata $res
+ } {SQLITE_SAVEPOINT RELEASE sp1 {} {} 1 {not authorized}}
+
+ catch { db eval ROLLBACK }
+ db auth ""
+}
+
+#-------------------------------------------------------------------------
+# The following tests - savepoint-10.* - test the interaction of
+# savepoints and ATTACH statements.
+#
+
+# First make sure it is not possible to attach or detach a database while
+# a savepoint is open (it is not possible if any transaction is open).
+#
+do_test savepoint-10.1.1 {
+ catchsql {
+ SAVEPOINT one;
+ ATTACH 'test2.db' AS aux;
+ }
+} {1 {cannot ATTACH database within transaction}}
+do_test savepoint-10.1.2 {
+ execsql {
+ RELEASE one;
+ ATTACH 'test2.db' AS aux;
+ }
+ catchsql {
+ SAVEPOINT one;
+ DETACH aux;
+ }
+} {1 {cannot DETACH database within transaction}}
+do_test savepoint-10.1.3 {
+ execsql {
+ RELEASE one;
+ DETACH aux;
+ }
+} {}
+
+# The lock state of the TEMP database can vary if SQLITE_TEMP_STORE=3
+# And the following set of tests is only really interested in the status
+# of the aux1 and aux2 locks. So record the current lock status of
+# TEMP for use in the answers.
+set templockstate [lindex [db eval {PRAGMA lock_status}] 3]
+
+
+if {[wal_is_wal_mode]==0} {
+ do_test savepoint-10.2.1 {
+ forcedelete test3.db
+ forcedelete test2.db
+ execsql {
+ ATTACH 'test2.db' AS aux1;
+ ATTACH 'test3.db' AS aux2;
+ DROP TABLE t1;
+ CREATE TABLE main.t1(x, y);
+ CREATE TABLE aux1.t2(x, y);
+ CREATE TABLE aux2.t3(x, y);
+ SELECT name FROM sqlite_master
+ UNION ALL
+ SELECT name FROM aux1.sqlite_master
+ UNION ALL
+ SELECT name FROM aux2.sqlite_master;
+ }
+ } {t1 t2 t3}
+ do_test savepoint-10.2.2 {
+ execsql { PRAGMA lock_status }
+ } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
+
+ do_test savepoint-10.2.3 {
+ execsql {
+ SAVEPOINT one;
+ INSERT INTO t1 VALUES(1, 2);
+ PRAGMA lock_status;
+ }
+ } [list main reserved temp $templockstate aux1 unlocked aux2 unlocked]
+ do_test savepoint-10.2.4 {
+ execsql {
+ INSERT INTO t3 VALUES(3, 4);
+ PRAGMA lock_status;
+ }
+ } [list main reserved temp $templockstate aux1 unlocked aux2 reserved]
+ do_test savepoint-10.2.5 {
+ execsql {
+ SAVEPOINT two;
+ INSERT INTO t2 VALUES(5, 6);
+ PRAGMA lock_status;
+ }
+ } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
+ do_test savepoint-10.2.6 {
+ execsql { SELECT * FROM t2 }
+ } {5 6}
+ do_test savepoint-10.2.7 {
+ execsql { ROLLBACK TO two }
+ execsql { SELECT * FROM t2 }
+ } {}
+ do_test savepoint-10.2.8 {
+ execsql { PRAGMA lock_status }
+ } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
+ do_test savepoint-10.2.9 {
+ execsql { SELECT 'a', * FROM t1 UNION ALL SELECT 'b', * FROM t3 }
+ } {a 1 2 b 3 4}
+ do_test savepoint-10.2.9 {
+ execsql {
+ INSERT INTO t2 VALUES(5, 6);
+ RELEASE one;
+ }
+ execsql {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ SELECT * FROM t3;
+ }
+ } {1 2 5 6 3 4}
+ do_test savepoint-10.2.9 {
+ execsql { PRAGMA lock_status }
+ } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
+
+ do_test savepoint-10.2.10 {
+ execsql {
+ SAVEPOINT one;
+ INSERT INTO t1 VALUES('a', 'b');
+ SAVEPOINT two;
+ INSERT INTO t2 VALUES('c', 'd');
+ SAVEPOINT three;
+ INSERT INTO t3 VALUES('e', 'f');
+ }
+ execsql {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ SELECT * FROM t3;
+ }
+ } {1 2 a b 5 6 c d 3 4 e f}
+ do_test savepoint-10.2.11 {
+ execsql { ROLLBACK TO two }
+ execsql {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ SELECT * FROM t3;
+ }
+ } {1 2 a b 5 6 3 4}
+ do_test savepoint-10.2.12 {
+ execsql {
+ INSERT INTO t3 VALUES('g', 'h');
+ ROLLBACK TO two;
+ }
+ execsql {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ SELECT * FROM t3;
+ }
+ } {1 2 a b 5 6 3 4}
+ do_test savepoint-10.2.13 {
+ execsql { ROLLBACK }
+ execsql {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ SELECT * FROM t3;
+ }
+ } {1 2 5 6 3 4}
+ do_test savepoint-10.2.14 {
+ execsql { PRAGMA lock_status }
+ } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
+}
+
+#-------------------------------------------------------------------------
+# The following tests - savepoint-11.* - test the interaction of
+# savepoints and creating or dropping tables and indexes in
+# auto-vacuum mode.
+#
+do_test savepoint-11.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql { PRAGMA auto_vacuum = full; }
+ wal_set_journal_mode
+ execsql {
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, randstr(1000,1000));
+ }
+} {}
+do_test savepoint-11.2 {
+ execsql {
+ SAVEPOINT one;
+ CREATE TABLE t2(a, b, UNIQUE(a, b));
+ SAVEPOINT two;
+ CREATE TABLE t3(a, b, UNIQUE(a, b));
+ }
+} {}
+integrity_check savepoint-11.3
+do_test savepoint-11.4 {
+ execsql { ROLLBACK TO two }
+} {}
+integrity_check savepoint-11.5
+do_test savepoint-11.6 {
+ execsql {
+ CREATE TABLE t3(a, b, UNIQUE(a, b));
+ ROLLBACK TO one;
+ }
+} {}
+integrity_check savepoint-11.7
+do_test savepoint-11.8 {
+ execsql { ROLLBACK }
+ execsql { PRAGMA wal_checkpoint }
+ file size test.db
+} {8192}
+
+do_test savepoint-11.9 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ DROP TABLE IF EXISTS t3;
+ }
+} {}
+do_test savepoint-11.10 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES(1, 2);
+ SAVEPOINT one;
+ INSERT INTO t2 VALUES(3, 4);
+ SAVEPOINT two;
+ DROP TABLE t1;
+ ROLLBACK TO two;
+ }
+ execsql {SELECT * FROM t2}
+} {1 2 3 4}
+do_test savepoint-11.11 {
+ execsql COMMIT
+} {}
+do_test savepoint-11.12 {
+ execsql {SELECT * FROM t2}
+} {1 2 3 4}
+wal_check_journal_mode savepoint-11.13
+
+#-------------------------------------------------------------------------
+# The following tests - savepoint-12.* - test the interaction of
+# savepoints and "ON CONFLICT ROLLBACK" clauses.
+#
+do_test savepoint-12.1 {
+ execsql {
+ CREATE TABLE t4(a PRIMARY KEY, b);
+ INSERT INTO t4 VALUES(1, 'one');
+ }
+} {}
+do_test savepoint-12.2 {
+ # The final statement of the following SQL hits a constraint when the
+ # conflict handling mode is "OR ROLLBACK" and there are a couple of
+ # open savepoints. At one point this would fail to clear the internal
+ # record of the open savepoints, resulting in an assert() failure
+ # later on.
+ #
+ catchsql {
+ BEGIN;
+ INSERT INTO t4 VALUES(2, 'two');
+ SAVEPOINT sp1;
+ INSERT INTO t4 VALUES(3, 'three');
+ SAVEPOINT sp2;
+ INSERT OR ROLLBACK INTO t4 VALUES(1, 'one');
+ }
+} {1 {column a is not unique}}
+do_test savepoint-12.3 {
+ sqlite3_get_autocommit db
+} {1}
+do_test savepoint-12.4 {
+ execsql { SAVEPOINT one }
+} {}
+wal_check_journal_mode savepoint-12.5
+
+#-------------------------------------------------------------------------
+# The following tests - savepoint-13.* - test the interaction of
+# savepoints and "journal_mode = off".
+#
+if {[wal_is_wal_mode]==0} {
+ do_test savepoint-13.1 {
+ db close
+ catch {forcedelete test.db}
+ sqlite3 db test.db
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 2);
+ COMMIT;
+ PRAGMA journal_mode = off;
+ }
+ } {off}
+ do_test savepoint-13.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 SELECT a+4,b+4 FROM t1;
+ COMMIT;
+ }
+ } {}
+ do_test savepoint-13.3 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(9, 10);
+ SAVEPOINT s1;
+ INSERT INTO t1 VALUES(11, 12);
+ COMMIT;
+ }
+ } {}
+ do_test savepoint-13.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(13, 14);
+ SAVEPOINT s1;
+ INSERT INTO t1 VALUES(15, 16);
+ ROLLBACK TO s1;
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4 5 6 7 8 9 10 11 12}
+}
+
+db close
+delete_file test.db
+do_multiclient_test tn {
+ do_test savepoint-14.$tn.1 {
+ sql1 {
+ CREATE TABLE foo(x);
+ INSERT INTO foo VALUES(1);
+ INSERT INTO foo VALUES(2);
+ }
+ sql2 {
+ BEGIN;
+ SELECT * FROM foo;
+ }
+ } {1 2}
+ do_test savepoint-14.$tn.2 {
+ sql1 {
+ SAVEPOINT one;
+ INSERT INTO foo VALUES(1);
+ }
+ csql1 { RELEASE one }
+ } {1 {database is locked}}
+ do_test savepoint-14.$tn.3 {
+ sql1 { ROLLBACK TO one }
+ sql2 { COMMIT }
+ sql1 { RELEASE one }
+ } {}
+
+ do_test savepoint-14.$tn.4 {
+ sql2 {
+ BEGIN;
+ SELECT * FROM foo;
+ }
+ } {1 2}
+ do_test savepoint-14.$tn.5 {
+ sql1 {
+ SAVEPOINT one;
+ INSERT INTO foo VALUES(1);
+ }
+ csql1 { RELEASE one }
+ } {1 {database is locked}}
+ do_test savepoint-14.$tn.6 {
+ sql2 { COMMIT }
+ sql1 {
+ ROLLBACK TO one;
+ INSERT INTO foo VALUES(3);
+ INSERT INTO foo VALUES(4);
+ INSERT INTO foo VALUES(5);
+ RELEASE one;
+ }
+ } {}
+ do_test savepoint-14.$tn.7 {
+ sql2 { CREATE INDEX fooidx ON foo(x); }
+ sql3 { PRAGMA integrity_check }
+ } {ok}
+}
+
+do_multiclient_test tn {
+ do_test savepoint-15.$tn.1 {
+ sql1 {
+ CREATE TABLE foo(x);
+ INSERT INTO foo VALUES(1);
+ INSERT INTO foo VALUES(2);
+ }
+ sql2 { BEGIN; SELECT * FROM foo; }
+ } {1 2}
+ do_test savepoint-15.$tn.2 {
+ sql1 {
+ PRAGMA locking_mode = EXCLUSIVE;
+ BEGIN;
+ INSERT INTO foo VALUES(3);
+ }
+ csql1 { COMMIT }
+ } {1 {database is locked}}
+ do_test savepoint-15.$tn.3 {
+ sql1 { ROLLBACK }
+ sql2 { COMMIT }
+ sql1 {
+ INSERT INTO foo VALUES(3);
+ PRAGMA locking_mode = NORMAL;
+ INSERT INTO foo VALUES(4);
+ }
+ sql2 { CREATE INDEX fooidx ON foo(x); }
+ sql3 { PRAGMA integrity_check }
+ } {ok}
+}
+
+do_multiclient_test tn {
+ do_test savepoint-16.$tn.1 {
+ sql1 {
+ CREATE TABLE foo(x);
+ INSERT INTO foo VALUES(1);
+ INSERT INTO foo VALUES(2);
+ }
+ } {}
+ do_test savepoint-16.$tn.2 {
+
+ db eval {SELECT * FROM foo} {
+ sql1 { INSERT INTO foo VALUES(3) }
+ sql2 { SELECT * FROM foo }
+ sql1 { INSERT INTO foo VALUES(4) }
+ break
+ }
+
+ sql2 { CREATE INDEX fooidx ON foo(x); }
+ sql3 { PRAGMA integrity_check }
+ } {ok}
+ do_test savepoint-16.$tn.3 {
+ sql1 { SELECT * FROM foo }
+ } {1 2 3 4}
+}
+
+#-------------------------------------------------------------------------
+# This next block of tests verifies that a problem reported on the mailing
+# list has been resolved. At one point the second "CREATE TABLE t6" would
+# fail as table t6 still existed in the internal cache of the db schema
+# (even though it had been removed from the database by the ROLLBACK
+# command).
+#
+sqlite3 db test.db
+do_execsql_test savepoint-17.1 {
+ BEGIN;
+ CREATE TABLE t6(a, b);
+ INSERT INTO t6 VALUES(1, 2);
+ SAVEPOINT one;
+ INSERT INTO t6 VALUES(3, 4);
+ ROLLBACK TO one;
+ SELECT * FROM t6;
+ ROLLBACK;
+} {1 2}
+
+do_execsql_test savepoint-17.2 {
+ CREATE TABLE t6(a, b);
+} {}
+
+finish_test
diff --git a/test/savepoint2.test b/test/savepoint2.test
new file mode 100644
index 0000000..be1bdbd
--- /dev/null
+++ b/test/savepoint2.test
@@ -0,0 +1,154 @@
+# 2008 December 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: savepoint2.test,v 1.5 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+# Tests in this file are quite similar to those run by trans.test and
+# avtrans.test.
+#
+
+proc signature {} {
+ return [db eval {SELECT count(*), md5sum(x) FROM t3}]
+}
+
+do_test savepoint2-1 {
+ wal_set_journal_mode
+ execsql {
+ PRAGMA cache_size=10;
+ BEGIN;
+ CREATE TABLE t3(x TEXT);
+ INSERT INTO t3 VALUES(randstr(10,400));
+ INSERT INTO t3 VALUES(randstr(10,400));
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ COMMIT;
+ SELECT count(*) FROM t3;
+ }
+} {1024}
+wal_check_journal_mode savepoint2-1.1
+
+unset -nocomplain ::sig
+unset -nocomplain SQL
+
+set iterations 20
+
+set SQL(1) {
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+}
+set SQL(2) {
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+}
+set SQL(3) {
+ UPDATE t3 SET x = randstr(10, 400) WHERE random()%10;
+ INSERT INTO t3 SELECT x FROM t3 WHERE random()%10;
+ DELETE FROM t3 WHERE random()%10;
+}
+set SQL(4) {
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE (random()%10 == 0);
+}
+
+
+
+for {set ii 2} {$ii < ($iterations+2)} {incr ii} {
+
+ # Record the database signature. Optionally (every second run) open a
+ # transaction. In all cases open savepoint "one", which may or may
+ # not be a transaction savepoint, depending on whether or not a real
+ # transaction has been opened.
+ #
+ do_test savepoint2-$ii.1 {
+ if {$ii % 2} { execsql BEGIN }
+ set ::sig(one) [signature]
+ execsql "SAVEPOINT one"
+ } {}
+
+ # Execute some SQL on the database. Then rollback to savepoint "one".
+ # Check that the database signature is as it was when "one" was opened.
+ #
+ do_test savepoint2-$ii.2 {
+ execsql $SQL(1)
+ execsql "ROLLBACK to one"
+ signature
+ } $::sig(one)
+ integrity_check savepoint2-$ii.2.1
+
+ # Execute some SQL. Then open savepoint "two". Savepoint "two" is therefore
+ # nested in savepoint "one".
+ #
+ do_test savepoint2-$ii.3 {
+ execsql $SQL(1)
+ set ::sig(two) [signature]
+ execsql "SAVEPOINT two"
+ } {}
+
+ # More SQL changes. The rollback to savepoint "two". Check that the
+ # signature is as it was when savepoint "two" was opened.
+ #
+ do_test savepoint2-$ii.4 {
+ execsql $SQL(2)
+ execsql "ROLLBACK to two"
+ signature
+ } $::sig(two)
+ integrity_check savepoint2-$ii.4.1
+
+ # More SQL changes. The rollback to savepoint "two". Check that the
+ # signature is as it was when savepoint "two" was opened.
+ #
+ do_test savepoint2-$ii.5 {
+ execsql $SQL(2)
+ execsql "SAVEPOINT three"
+ execsql $SQL(3)
+ execsql "RELEASE three"
+ execsql "ROLLBACK to one"
+ signature
+ } $::sig(one)
+
+ # By this point the database is in the same state as it was at the
+ # top of the for{} loop (everything having been rolled back by the
+ # "ROLLBACK TO one" command above). So make a few changes to the
+ # database and COMMIT the open transaction, so that the next iteration
+ # of the for{} loop works on a different dataset.
+ #
+ # The transaction being committed here may have been opened normally using
+ # "BEGIN", or may have been opened using a transaction savepoint created
+ # by the "SAVEPOINT one" statement.
+ #
+ do_test savepoint2-$ii.6 {
+ execsql $SQL(4)
+ execsql COMMIT
+ sqlite3_get_autocommit db
+ } {1}
+ integrity_check savepoint2-$ii.6.1
+
+ # Check that the connection is still running in WAL mode.
+ wal_check_journal_mode savepoint2-$ii.7
+}
+
+unset -nocomplain ::sig
+unset -nocomplain SQL
+
+finish_test
diff --git a/test/savepoint3.test b/test/savepoint3.test
new file mode 100644
index 0000000..0dcb0ac
--- /dev/null
+++ b/test/savepoint3.test
@@ -0,0 +1,136 @@
+# 2008 December 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: savepoint3.test,v 1.5 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+source $testdir/malloc_common.tcl
+
+do_malloc_test savepoint3-1 -sqlprep {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+} -sqlbody {
+ SAVEPOINT one;
+ INSERT INTO t1 VALUES(4, 5, 6);
+ SAVEPOINT two;
+ DELETE FROM t1;
+ ROLLBACK TO two;
+ RELEASE one;
+}
+
+do_malloc_test savepoint3-2 -sqlprep {
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(randstr(400,400), randstr(400,400), randstr(400,400));
+ INSERT INTO t1 SELECT
+ randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+} -sqlbody {
+ PRAGMA cache_size = 10;
+ SAVEPOINT one;
+ DELETE FROM t1 WHERE rowid < 5;
+ SAVEPOINT two;
+ DELETE FROM t1 WHERE rowid > 10;
+ ROLLBACK TO two;
+ ROLLBACK TO one;
+ RELEASE one;
+}
+
+do_ioerr_test savepoint3.3 -sqlprep {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000), randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, randstr(1000,1000), randstr(1000,1000));
+} -sqlbody {
+ BEGIN;
+ UPDATE t1 SET a = 3 WHERE a = 1;
+ SAVEPOINT one;
+ UPDATE t1 SET a = 4 WHERE a = 2;
+ COMMIT;
+} -cleanup {
+ db eval {
+ SAVEPOINT one;
+ RELEASE one;
+ }
+}
+
+# The following test does a really big savepoint rollback. One involving
+# more than 4000 pages. The idea is to get a specific sqlite3BitvecSet()
+# operation in pagerPlaybackSavepoint() to fail.
+#do_malloc_test savepoint3-4 -sqlprep {
+# BEGIN;
+# CREATE TABLE t1(a, b);
+# CREATE INDEX i1 ON t1(a);
+# CREATE INDEX i2 ON t1(b);
+# INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 1
+# INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 2
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 4
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 8
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 16
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 32
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 64
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 128
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 256
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 512
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 1024
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 2048
+# COMMIT;
+# BEGIN;
+# SAVEPOINT abc;
+# UPDATE t1 SET a = randstr(500,500);
+#} -sqlbody {
+# ROLLBACK TO abc;
+#}
+
+
+# Cause a specific malloc in savepoint rollback code to fail.
+#
+do_malloc_test savepoint3-4 -start 7 -sqlprep {
+ PRAGMA auto_vacuum = incremental;
+ PRAGMA cache_size = 1000;
+
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ CREATE TABLE t3(a, b);
+ INSERT INTO t1 VALUES(1, randstr(500,500));
+ INSERT INTO t1 VALUES(2, randstr(500,500));
+ INSERT INTO t1 VALUES(3, randstr(500,500));
+ DELETE FROM t1;
+
+ BEGIN;
+ INSERT INTO t1 VALUES(1, randstr(500,500));
+ INSERT INTO t1 VALUES(2, randstr(500,500));
+ INSERT INTO t1 VALUES(3, randstr(500,500));
+ DROP TABLE t3; -- Page 5 of the database file is now free.
+ DROP TABLE t2; -- Page 4 of the database file is now free.
+
+ SAVEPOINT abc;
+ PRAGMA incremental_vacuum;
+} -sqlbody {
+ ROLLBACK TO abc;
+}
+
+
+finish_test
diff --git a/test/savepoint4.test b/test/savepoint4.test
new file mode 100644
index 0000000..f8c5b71
--- /dev/null
+++ b/test/savepoint4.test
@@ -0,0 +1,169 @@
+# 2008 December 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: savepoint4.test,v 1.7 2009/06/09 15:25:33 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !crashtest {
+ finish_test
+ return
+}
+
+proc signature {} {
+ return [db eval {SELECT count(*), md5sum(x) FROM t1}]
+}
+
+set ITERATIONS 25 ;# Number of iterations for savepoint4-1
+set ITERATIONS2 13 ;# Number of iterations for savepoint4-2
+expr srand(0)
+
+do_test savepoint4-1 {
+ execsql {
+ PRAGMA cache_size=10;
+ BEGIN;
+ CREATE TABLE t1(x TEXT);
+ INSERT INTO t1 VALUES(randstr(10,400));
+ INSERT INTO t1 VALUES(randstr(10,400));
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+} {1024}
+
+
+unset -nocomplain ::sig
+
+for {set ii 1} {$ii<=$ITERATIONS} {incr ii} {
+ set ::sig [signature]
+
+ for {set iDelay 1 ; set crashed 1} {$crashed} {incr iDelay} {
+
+ do_test savepoint4-1.$ii.1.$iDelay {
+ set ret [crashsql -delay $iDelay -file test.db-journal {
+ PRAGMA cache_size = 20;
+ SAVEPOINT one;
+ DELETE FROM t1 WHERE random()%2==0;
+ SAVEPOINT two;
+ INSERT INTO t1 SELECT randstr(10,10)||x FROM t1;
+ ROLLBACK TO two;
+ UPDATE t1 SET x = randstr(10, 400) WHERE random()%10;
+ RELEASE two;
+ ROLLBACK TO one;
+ RELEASE one;
+ }]
+ signature
+ } $::sig
+
+ set crashed [lindex $ret 0]
+ integrity_check savepoint4-1.$ii.1.$iDelay.integrity
+ }
+
+ do_test savepoint4-1.$ii.2 {
+ execsql {
+ DELETE FROM t1 WHERE random()%10==0;
+ INSERT INTO t1 SELECT randstr(10,10)||x FROM t1 WHERE random()%9==0;
+ }
+ } {}
+}
+
+do_test savepoint4-2 {
+ execsql {
+ PRAGMA cache_size=10;
+ DROP TABLE IF EXISTS t1;
+ BEGIN;
+ CREATE TABLE t1(x TEXT);
+ CREATE INDEX i1 ON t1(x);
+ INSERT INTO t1 VALUES(randstr(10,400));
+ INSERT INTO t1 VALUES(randstr(10,400));
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ INSERT INTO t1 SELECT randstr(10,400) FROM t1;
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+} {256}
+
+for {set ii 1} {$ii<=$ITERATIONS2} {incr ii} {
+ set ::sig [signature]
+ set file test.db-journal
+
+ for {set iDelay 1 ; set crashed 1} {$crashed} {incr iDelay} {
+
+ do_test savepoint4-2.$ii.1.$iDelay {
+
+ set ret [crashsql -delay $iDelay -file $file {
+ SAVEPOINT one;
+ INSERT INTO t1 SELECT * FROM t1 WHERE rowid<50;
+ ROLLBACK TO one;
+ INSERT INTO t1 SELECT * FROM t1 WHERE rowid<50;
+ SAVEPOINT two;
+ DELETE FROM t1 WHERE (random()%10)==0;
+ SAVEPOINT three;
+ DELETE FROM t1 WHERE (random()%10)==0;
+ SAVEPOINT four;
+ DELETE FROM t1 WHERE (random()%10)==0;
+ RELEASE two;
+
+ SAVEPOINT three;
+ UPDATE t1 SET x = substr(x||x, 12, 100000) WHERE (rowid%12)==0;
+ SAVEPOINT four;
+ UPDATE t1 SET x = substr(x||x, 14, 100000) WHERE (rowid%14)==0;
+ ROLLBACK TO three;
+ UPDATE t1 SET x = substr(x||x, 13, 100000) WHERE (rowid%13)==0;
+ RELEASE three;
+
+ DELETE FROM t1 WHERE rowid > (
+ SELECT rowid FROM t1 ORDER BY rowid ASC LIMIT 1 OFFSET 256
+ );
+ RELEASE one;
+ }]
+
+ set crashed [lindex $ret 0]
+ if {$crashed} {
+ signature
+ } else {
+ set ::sig
+ }
+ } $::sig
+
+ integrity_check savepoint4-2.$ii.1.$iDelay.integrity
+
+ if {$crashed == 0 && $file == "test.db-journal"} {
+ set crashed 1
+ set iDelay 0
+ set file test.db
+ set ::sig [signature]
+ }
+ }
+
+ do_test savepoint4-2.$ii.2 {
+ execsql {
+ DELETE FROM t1 WHERE random()%10==0;
+ INSERT INTO t1 SELECT randstr(10,10)||x FROM t1 WHERE random()%9==0;
+ }
+ } {}
+}
+
+finish_test
diff --git a/test/savepoint5.test b/test/savepoint5.test
new file mode 100644
index 0000000..dc5268b
--- /dev/null
+++ b/test/savepoint5.test
@@ -0,0 +1,46 @@
+# 2009 January 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Verify that a SAVEPOINT on a new, empty database followed by a
+# ROLLBACK TO that savepoint starts over again with another new
+# empty database.
+#
+# $Id: savepoint5.test,v 1.1 2009/01/02 21:08:09 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test savepoint5-1.1 {
+ db eval {
+ SAVEPOINT sp1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ SELECT count(*) FROM sqlite_master;
+ SELECT * FROM t1;
+ }
+} {1 1}
+do_test savepoint5-1.2 {
+ db eval {
+ ROLLBACK TO sp1;
+ SELECT count(*) FROM sqlite_master;
+ }
+} {0}
+do_test savepoint5-1.3 {
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ SELECT count(*) FROM sqlite_master;
+ SELECT * FROM t1;
+ }
+} {1 1}
+
+
+finish_test
diff --git a/test/savepoint6.test b/test/savepoint6.test
new file mode 100644
index 0000000..b1d0d46
--- /dev/null
+++ b/test/savepoint6.test
@@ -0,0 +1,281 @@
+# 2009 January 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: savepoint6.test,v 1.4 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc sql {zSql} {
+ uplevel db eval [list $zSql]
+ #puts stderr "$zSql ;"
+}
+
+set DATABASE_SCHEMA {
+ PRAGMA auto_vacuum = incremental;
+ CREATE TABLE t1(x, y);
+ CREATE UNIQUE INDEX i1 ON t1(x);
+ CREATE INDEX i2 ON t1(y);
+}
+
+if {0==[info exists ::G(savepoint6_iterations)]} {
+ set ::G(savepoint6_iterations) 1000
+}
+
+#--------------------------------------------------------------------------
+# In memory database state.
+#
+# ::lSavepoint is a list containing one entry for each active savepoint. The
+# first entry in the list corresponds to the most recently opened savepoint.
+# Each entry consists of two elements:
+#
+# 1. The savepoint name.
+#
+# 2. A serialized Tcl array representing the contents of table t1 at the
+# start of the savepoint. The keys of the array are the x values. The
+# values are the y values.
+#
+# Array ::aEntry contains the contents of database table t1. Array keys are
+# x values, the array data values are y values.
+#
+set lSavepoint [list]
+array set aEntry [list]
+
+proc x_to_y {x} {
+ set nChar [expr int(rand()*250) + 250]
+ set str " $nChar [string repeat $x. $nChar]"
+ string range $str 1 $nChar
+}
+#--------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Procs to operate on database:
+#
+# savepoint NAME
+# rollback NAME
+# release NAME
+#
+# insert_rows XVALUES
+# delete_rows XVALUES
+#
+proc savepoint {zName} {
+ catch { sql "SAVEPOINT $zName" }
+ lappend ::lSavepoint [list $zName [array get ::aEntry]]
+}
+
+proc rollback {zName} {
+ catch { sql "ROLLBACK TO $zName" }
+ for {set i [expr {[llength $::lSavepoint]-1}]} {$i>=0} {incr i -1} {
+ set zSavepoint [lindex $::lSavepoint $i 0]
+ if {$zSavepoint eq $zName} {
+ unset -nocomplain ::aEntry
+ array set ::aEntry [lindex $::lSavepoint $i 1]
+
+
+ if {$i+1 < [llength $::lSavepoint]} {
+ set ::lSavepoint [lreplace $::lSavepoint [expr $i+1] end]
+ }
+ break
+ }
+ }
+}
+
+proc release {zName} {
+ catch { sql "RELEASE $zName" }
+ for {set i [expr {[llength $::lSavepoint]-1}]} {$i>=0} {incr i -1} {
+ set zSavepoint [lindex $::lSavepoint $i 0]
+ if {$zSavepoint eq $zName} {
+ set ::lSavepoint [lreplace $::lSavepoint $i end]
+ break
+ }
+ }
+
+ if {[llength $::lSavepoint] == 0} {
+ #puts stderr "-- End of transaction!!!!!!!!!!!!!"
+ }
+}
+
+proc insert_rows {lX} {
+ foreach x $lX {
+ set y [x_to_y $x]
+
+ # Update database [db]
+ sql "INSERT OR REPLACE INTO t1 VALUES($x, '$y')"
+
+ # Update the Tcl database.
+ set ::aEntry($x) $y
+ }
+}
+
+proc delete_rows {lX} {
+ foreach x $lX {
+ # Update database [db]
+ sql "DELETE FROM t1 WHERE x = $x"
+
+ # Update the Tcl database.
+ unset -nocomplain ::aEntry($x)
+ }
+}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Proc to compare database content with the in-memory representation.
+#
+# checkdb
+#
+proc checkdb {} {
+ set nEntry [db one {SELECT count(*) FROM t1}]
+ set nEntry2 [array size ::aEntry]
+ if {$nEntry != $nEntry2} {
+ error "$nEntry entries in database, $nEntry2 entries in array"
+ }
+ db eval {SELECT x, y FROM t1} {
+ if {![info exists ::aEntry($x)]} {
+ error "Entry $x exists in database, but not in array"
+ }
+ if {$::aEntry($x) ne $y} {
+ error "Entry $x is set to {$y} in database, {$::aEntry($x)} in array"
+ }
+ }
+
+ db eval { PRAGMA integrity_check }
+}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Proc to return random set of x values.
+#
+# random_integers
+#
+proc random_integers {nRes nRange} {
+ set ret [list]
+ for {set i 0} {$i<$nRes} {incr i} {
+ lappend ret [expr int(rand()*$nRange)]
+ }
+ return $ret
+}
+#-------------------------------------------------------------------------
+
+proc database_op {} {
+ set i [expr int(rand()*2)]
+ if {$i==0} {
+ insert_rows [random_integers 100 1000]
+ }
+ if {$i==1} {
+ delete_rows [random_integers 100 1000]
+ set i [expr int(rand()*3)]
+ if {$i==0} {
+ sql {PRAGMA incremental_vacuum}
+ }
+ }
+}
+
+proc savepoint_op {} {
+ set names {one two three four five}
+ set cmds {savepoint savepoint savepoint savepoint release rollback}
+
+ set C [lindex $cmds [expr int(rand()*6)]]
+ set N [lindex $names [expr int(rand()*5)]]
+
+ #puts stderr " $C $N ; "
+ #flush stderr
+
+ $C $N
+ return ok
+}
+
+expr srand(0)
+
+############################################################################
+############################################################################
+# Start of test cases.
+
+do_test savepoint6-1.1 {
+ sql $DATABASE_SCHEMA
+} {}
+do_test savepoint6-1.2 {
+ insert_rows {
+ 497 166 230 355 779 588 394 317 290 475 362 193 805 851 564
+ 763 44 930 389 819 765 760 966 280 538 414 500 18 25 287 320
+ 30 382 751 87 283 981 429 630 974 421 270 810 405
+ }
+
+ savepoint one
+ insert_rows 858
+ delete_rows 930
+ savepoint two
+ execsql {PRAGMA incremental_vacuum}
+ savepoint three
+ insert_rows 144
+ rollback three
+ rollback two
+ release one
+
+ execsql {SELECT count(*) FROM t1}
+} {44}
+
+foreach zSetup [list {
+ set testname normal
+ sqlite3 db test.db
+} {
+ if {[wal_is_wal_mode]} continue
+ set testname tempdb
+ sqlite3 db ""
+} {
+ if {[permutation] eq "journaltest"} {
+ continue
+ }
+ set testname nosync
+ sqlite3 db test.db
+ sql { PRAGMA synchronous = off }
+} {
+ set testname smallcache
+ sqlite3 db test.db
+ sql { PRAGMA cache_size = 10 }
+}] {
+
+ unset -nocomplain ::lSavepoint
+ unset -nocomplain ::aEntry
+
+ catch { db close }
+ forcedelete test.db test.db-wal test.db-journal
+ eval $zSetup
+ sql $DATABASE_SCHEMA
+
+ wal_set_journal_mode
+
+ do_test savepoint6-$testname.setup {
+ savepoint one
+ insert_rows [random_integers 100 1000]
+ release one
+ checkdb
+ } {ok}
+
+ for {set i 0} {$i < $::G(savepoint6_iterations)} {incr i} {
+ do_test savepoint6-$testname.$i.1 {
+ savepoint_op
+ checkdb
+ } {ok}
+
+ do_test savepoint6-$testname.$i.2 {
+ database_op
+ database_op
+ checkdb
+ } {ok}
+ }
+
+ wal_check_journal_mode savepoint6-$testname.walok
+}
+
+unset -nocomplain ::lSavepoint
+unset -nocomplain ::aEntry
+
+finish_test
diff --git a/test/schema.test b/test/schema.test
new file mode 100644
index 0000000..afca39e
--- /dev/null
+++ b/test/schema.test
@@ -0,0 +1,391 @@
+# 2005 Jan 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file tests the various conditions under which an SQLITE_SCHEMA
+# error should be returned.
+#
+# $Id: schema.test,v 1.9 2009/02/04 17:40:58 drh Exp $
+
+#---------------------------------------------------------------------
+# When any of the following types of SQL statements or actions are
+# executed, all pre-compiled statements are invalidated. An attempt
+# to execute an invalidated statement always returns SQLITE_SCHEMA.
+#
+# CREATE/DROP TABLE...................................schema-1.*
+# CREATE/DROP VIEW....................................schema-2.*
+# CREATE/DROP TRIGGER.................................schema-3.*
+# CREATE/DROP INDEX...................................schema-4.*
+# DETACH..............................................schema-5.*
+# Deleting a user-function............................schema-6.*
+# Deleting a collation sequence.......................schema-7.*
+# Setting or changing the authorization function......schema-8.*
+# Rollback of a DDL statement.........................schema-12.*
+#
+# Test cases schema-9.* and schema-10.* test some specific bugs
+# that came up during development.
+#
+# Test cases schema-11.* test that it is impossible to delete or
+# change a collation sequence or user-function while SQL statements
+# are executing. Adding new collations or functions is allowed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test schema-1.1 {
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ }
+ sqlite3_step $::STMT
+} {SQLITE_ERROR}
+do_test schema-1.2 {
+ sqlite3_finalize $::STMT
+} {SQLITE_SCHEMA}
+do_test schema-1.3 {
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ DROP TABLE abc;
+ }
+ sqlite3_step $::STMT
+} {SQLITE_ERROR}
+do_test schema-1.4 {
+ sqlite3_finalize $::STMT
+} {SQLITE_SCHEMA}
+
+ifcapable view {
+ do_test schema-2.1 {
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ CREATE VIEW v1 AS SELECT * FROM sqlite_master;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_ERROR}
+ do_test schema-2.2 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_SCHEMA}
+ do_test schema-2.3 {
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ DROP VIEW v1;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_ERROR}
+ do_test schema-2.4 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_SCHEMA}
+}
+
+ifcapable trigger {
+ do_test schema-3.1 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ }
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ CREATE TRIGGER abc_trig AFTER INSERT ON abc BEGIN
+ SELECT 1, 2, 3;
+ END;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_ERROR}
+ do_test schema-3.2 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_SCHEMA}
+ do_test schema-3.3 {
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ DROP TRIGGER abc_trig;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_ERROR}
+ do_test schema-3.4 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_SCHEMA}
+}
+
+do_test schema-4.1 {
+ catchsql {
+ CREATE TABLE abc(a, b, c);
+ }
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ CREATE INDEX abc_index ON abc(a);
+ }
+ sqlite3_step $::STMT
+} {SQLITE_ERROR}
+do_test schema-4.2 {
+ sqlite3_finalize $::STMT
+} {SQLITE_SCHEMA}
+do_test schema-4.3 {
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ DROP INDEX abc_index;
+ }
+ sqlite3_step $::STMT
+} {SQLITE_ERROR}
+do_test schema-4.4 {
+ sqlite3_finalize $::STMT
+} {SQLITE_SCHEMA}
+
+#---------------------------------------------------------------------
+# Tests 5.1 to 5.4 check that prepared statements are invalidated when
+# a database is DETACHed (but not when one is ATTACHed).
+#
+ifcapable attach {
+ do_test schema-5.1 {
+ set sql {SELECT * FROM abc;}
+ set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_DONE}
+ do_test schema-5.2 {
+ sqlite3_reset $::STMT
+ } {SQLITE_OK}
+ do_test schema-5.3 {
+ execsql {
+ DETACH aux;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_ERROR}
+ do_test schema-5.4 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_SCHEMA}
+}
+
+#---------------------------------------------------------------------
+# Tests 6.* check that prepared statements are invalidated when
+# a user-function is deleted (but not when one is added).
+do_test schema-6.1 {
+ set sql {SELECT * FROM abc;}
+ set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]
+ db function hello_function {}
+ sqlite3_step $::STMT
+} {SQLITE_DONE}
+do_test schema-6.2 {
+ sqlite3_reset $::STMT
+} {SQLITE_OK}
+do_test schema-6.3 {
+ sqlite_delete_function $::DB hello_function
+ sqlite3_step $::STMT
+} {SQLITE_ERROR}
+do_test schema-6.4 {
+ sqlite3_finalize $::STMT
+} {SQLITE_SCHEMA}
+
+#---------------------------------------------------------------------
+# Tests 7.* check that prepared statements are invalidated when
+# a collation sequence is deleted (but not when one is added).
+#
+ifcapable utf16 {
+ do_test schema-7.1 {
+ set sql {SELECT * FROM abc;}
+ set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]
+ add_test_collate $::DB 1 1 1
+ sqlite3_step $::STMT
+ } {SQLITE_DONE}
+ do_test schema-7.2 {
+ sqlite3_reset $::STMT
+ } {SQLITE_OK}
+ do_test schema-7.3 {
+ add_test_collate $::DB 0 0 0
+ sqlite3_step $::STMT
+ } {SQLITE_ERROR}
+ do_test schema-7.4 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_SCHEMA}
+}
+
+#---------------------------------------------------------------------
+# Tests 8.1 and 8.2 check that prepared statements are invalidated when
+# the authorization function is set.
+#
+ifcapable auth {
+ do_test schema-8.1 {
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ db auth {}
+ sqlite3_step $::STMT
+ } {SQLITE_ERROR}
+ do_test schema-8.3 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_SCHEMA}
+}
+
+#---------------------------------------------------------------------
+# schema-9.1: Test that if a table is dropped by one database connection,
+# other database connections are aware of the schema change.
+# schema-9.2: Test that if a view is dropped by one database connection,
+# other database connections are aware of the schema change.
+#
+do_test schema-9.1 {
+ sqlite3 db2 test.db
+ execsql {
+ DROP TABLE abc;
+ } db2
+ db2 close
+ catchsql {
+ SELECT * FROM abc;
+ }
+} {1 {no such table: abc}}
+execsql {
+ CREATE TABLE abc(a, b, c);
+}
+ifcapable view {
+ do_test schema-9.2 {
+ execsql {
+ CREATE VIEW abcview AS SELECT * FROM abc;
+ }
+ sqlite3 db2 test.db
+ execsql {
+ DROP VIEW abcview;
+ } db2
+ db2 close
+ catchsql {
+ SELECT * FROM abcview;
+ }
+ } {1 {no such table: abcview}}
+}
+
+#---------------------------------------------------------------------
+# Test that if a CREATE TABLE statement fails because there are other
+# btree cursors open on the same database file it does not corrupt
+# the sqlite_master table.
+#
+# 2007-05-02: These tests have been overcome by events. Open btree
+# cursors no longer block CREATE TABLE. But there is no reason not
+# to keep the tests in the test suite.
+#
+do_test schema-10.1 {
+ execsql {
+ INSERT INTO abc VALUES(1, 2, 3);
+ }
+ set sql {SELECT * FROM abc}
+ set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test schema-10.2 {
+ catchsql {
+ CREATE TABLE t2(a, b, c);
+ }
+} {0 {}}
+do_test schema-10.3 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+do_test schema-10.4 {
+ sqlite3 db2 test.db
+ execsql {
+ SELECT * FROM abc
+ } db2
+} {1 2 3}
+do_test schema-10.5 {
+ db2 close
+} {}
+
+#---------------------------------------------------------------------
+# Attempting to delete or replace a user-function or collation sequence
+# while there are active statements returns an SQLITE_BUSY error.
+#
+# schema-11.1 - 11.4: User function.
+# schema-11.5 - 11.8: Collation sequence.
+#
+do_test schema-11.1 {
+ db function tstfunc {}
+ set sql {SELECT * FROM abc}
+ set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test schema-11.2 {
+ sqlite_delete_function $::DB tstfunc
+} {SQLITE_BUSY}
+do_test schema-11.3 {
+ set rc [catch {
+ db function tstfunc {}
+ } msg]
+ list $rc $msg
+} {1 {unable to delete/modify user-function due to active statements}}
+do_test schema-11.4 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+do_test schema-11.5 {
+ db collate tstcollate {}
+ set sql {SELECT * FROM abc}
+ set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test schema-11.6 {
+ sqlite_delete_collation $::DB tstcollate
+} {SQLITE_BUSY}
+do_test schema-11.7 {
+ set rc [catch {
+ db collate tstcollate {}
+ } msg]
+ list $rc $msg
+} {1 {unable to delete/modify collation sequence due to active statements}}
+do_test schema-11.8 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+
+# The following demonstrates why statements need to be expired whenever
+# there is a rollback (explicit or otherwise).
+#
+do_test schema-12.1 {
+ # Begin a transaction and create a table. This increments
+ # the schema cookie. Then compile an SQL statement, using
+ # the current (incremented) value of the cookie.
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(a, b, c);
+ }
+ set ::STMT [sqlite3_prepare $::DB "CREATE TABLE t4(a,b,c)" -1 TAIL]
+
+ # Rollback the transaction, resetting the schema cookie to the value
+ # it had at the start of this test case. Then create a table,
+ # incrementing the schema cookie.
+ execsql {
+ ROLLBACK;
+ CREATE TABLE t4(a, b, c);
+ }
+
+ # The schema cookie now has the same value as it did when SQL statement
+ # $::STMT was prepared. So unless it has been expired, it would be
+ # possible to run the "CREATE TABLE t4" statement and create a
+ # duplicate table.
+ list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
+} {SQLITE_ERROR SQLITE_SCHEMA}
+
+ifcapable {auth} {
+
+do_test schema-13.1 {
+ set S [sqlite3_prepare_v2 db "SELECT * FROM sqlite_master" -1 dummy]
+ db function hello hello
+ db function hello {}
+ db auth auth
+ proc auth {args} {
+ if {[lindex $args 0] == "SQLITE_READ"} {return SQLITE_DENY}
+ return SQLITE_OK
+ }
+ sqlite3_step $S
+} {SQLITE_AUTH}
+
+do_test schema-13.2 {
+ sqlite3_step $S
+} {SQLITE_AUTH}
+
+do_test schema-13.3 {
+ sqlite3_finalize $S
+} {SQLITE_AUTH}
+
+}
+
+finish_test
diff --git a/test/schema2.test b/test/schema2.test
new file mode 100644
index 0000000..61d7f73
--- /dev/null
+++ b/test/schema2.test
@@ -0,0 +1,340 @@
+# 2006 November 08
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file tests the various conditions under which an SQLITE_SCHEMA
+# error should be returned. This is a copy of schema.test that
+# has been altered to use sqlite3_prepare_v2 instead of sqlite3_prepare
+#
+# $Id: schema2.test,v 1.4 2009/02/04 17:40:58 drh Exp $
+
+#---------------------------------------------------------------------
+# When any of the following types of SQL statements or actions are
+# executed, all pre-compiled statements are invalidated. An attempt
+# to execute an invalidated statement always returns SQLITE_SCHEMA.
+#
+# CREATE/DROP TABLE...................................schema2-1.*
+# CREATE/DROP VIEW....................................schema2-2.*
+# CREATE/DROP TRIGGER.................................schema2-3.*
+# CREATE/DROP INDEX...................................schema2-4.*
+# DETACH..............................................schema2-5.*
+# Deleting a user-function............................schema2-6.*
+# Deleting a collation sequence.......................schema2-7.*
+# Setting or changing the authorization function......schema2-8.*
+#
+# Test cases schema2-9.* and schema2-10.* test some specific bugs
+# that came up during development.
+#
+# Test cases schema2-11.* test that it is impossible to delete or
+# change a collation sequence or user-function while SQL statements
+# are executing. Adding new collations or functions is allowed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test schema2-1.1 {
+ set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ }
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test schema2-1.2 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+do_test schema2-1.3 {
+ set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ DROP TABLE abc;
+ }
+ sqlite3_step $::STMT
+} {SQLITE_DONE}
+do_test schema2-1.4 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+
+
+ifcapable view {
+ do_test schema2-2.1 {
+ set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ CREATE VIEW v1 AS SELECT * FROM sqlite_master;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_ROW}
+ do_test schema2-2.2 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_OK}
+ do_test schema2-2.3 {
+ set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ DROP VIEW v1;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_DONE}
+ do_test schema2-2.4 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_OK}
+}
+
+ifcapable trigger {
+ do_test schema2-3.1 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ }
+ set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ CREATE TRIGGER abc_trig AFTER INSERT ON abc BEGIN
+ SELECT 1, 2, 3;
+ END;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_ROW}
+ do_test schema2-3.2 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_OK}
+ do_test schema2-3.3 {
+ set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ DROP TRIGGER abc_trig;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_ROW}
+ do_test schema2-3.4 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_OK}
+}
+
+do_test schema2-4.1 {
+ catchsql {
+ CREATE TABLE abc(a, b, c);
+ }
+ set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ CREATE INDEX abc_index ON abc(a);
+ }
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test schema2-4.2 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+do_test schema2-4.3 {
+ set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ execsql {
+ DROP INDEX abc_index;
+ }
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test schema2-4.4 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+
+#---------------------------------------------------------------------
+# Tests 5.1 to 5.4 check that prepared statements are invalidated when
+# a database is DETACHed (but not when one is ATTACHed).
+#
+ifcapable attach {
+ do_test schema2-5.1 {
+ set sql {SELECT * FROM abc;}
+ set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_DONE}
+ do_test schema2-5.2 {
+ sqlite3_reset $::STMT
+ } {SQLITE_OK}
+ do_test schema2-5.3 {
+ execsql {
+ DETACH aux;
+ }
+ sqlite3_step $::STMT
+ } {SQLITE_DONE}
+ do_test schema2-5.4 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_OK}
+}
+
+#---------------------------------------------------------------------
+# Tests 6.* check that prepared statements are invalidated when
+# a user-function is deleted (but not when one is added).
+do_test schema2-6.1 {
+ set sql {SELECT * FROM abc;}
+ set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]
+ db function hello_function {}
+ sqlite3_step $::STMT
+} {SQLITE_DONE}
+do_test schema2-6.2 {
+ sqlite3_reset $::STMT
+} {SQLITE_OK}
+do_test schema2-6.3 {
+ sqlite_delete_function $::DB hello_function
+ sqlite3_step $::STMT
+} {SQLITE_DONE}
+do_test schema2-6.4 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+
+#---------------------------------------------------------------------
+# Tests 7.* check that prepared statements are invalidated when
+# a collation sequence is deleted (but not when one is added).
+#
+ifcapable utf16 {
+ do_test schema2-7.1 {
+ set sql {SELECT * FROM abc;}
+ set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]
+ add_test_collate $::DB 1 1 1
+ sqlite3_step $::STMT
+ } {SQLITE_DONE}
+ do_test schema2-7.2 {
+ sqlite3_reset $::STMT
+ } {SQLITE_OK}
+ do_test schema2-7.3 {
+ add_test_collate $::DB 0 0 0
+ sqlite3_step $::STMT
+ } {SQLITE_DONE}
+ do_test schema2-7.4 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_OK}
+}
+
+#---------------------------------------------------------------------
+# Tests 8.1 and 8.2 check that prepared statements are invalidated when
+# the authorization function is set.
+#
+ifcapable auth {
+ do_test schema2-8.1 {
+ set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ db auth {}
+ sqlite3_step $::STMT
+ } {SQLITE_ROW}
+ do_test schema2-8.3 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_OK}
+}
+
+#---------------------------------------------------------------------
+# schema2-9.1: Test that if a table is dropped by one database connection,
+# other database connections are aware of the schema change.
+# schema2-9.2: Test that if a view is dropped by one database connection,
+# other database connections are aware of the schema change.
+#
+do_test schema2-9.1 {
+ sqlite3 db2 test.db
+ execsql {
+ DROP TABLE abc;
+ } db2
+ db2 close
+ catchsql {
+ SELECT * FROM abc;
+ }
+} {1 {no such table: abc}}
+execsql {
+ CREATE TABLE abc(a, b, c);
+}
+ifcapable view {
+ do_test schema2-9.2 {
+ execsql {
+ CREATE VIEW abcview AS SELECT * FROM abc;
+ }
+ sqlite3 db2 test.db
+ execsql {
+ DROP VIEW abcview;
+ } db2
+ db2 close
+ catchsql {
+ SELECT * FROM abcview;
+ }
+ } {1 {no such table: abcview}}
+}
+
+#---------------------------------------------------------------------
+# Test that if a CREATE TABLE statement fails because there are other
+# btree cursors open on the same database file it does not corrupt
+# the sqlite_master table.
+#
+# 2007-05-02: These tests have been overcome by events. Open btree
+# cursors no longer block CREATE TABLE. But there is no reason not
+# to keep the tests in the test suite.
+#
+do_test schema2-10.1 {
+ execsql {
+ INSERT INTO abc VALUES(1, 2, 3);
+ }
+ set sql {SELECT * FROM abc}
+ set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test schema2-10.2 {
+ catchsql {
+ CREATE TABLE t2(a, b, c);
+ }
+} {0 {}}
+do_test schema2-10.3 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+do_test schema2-10.4 {
+ sqlite3 db2 test.db
+ execsql {
+ SELECT * FROM abc
+ } db2
+} {1 2 3}
+do_test schema2-10.5 {
+ db2 close
+} {}
+
+#---------------------------------------------------------------------
+# Attempting to delete or replace a user-function or collation sequence
+# while there are active statements returns an SQLITE_BUSY error.
+#
+# schema2-11.1 - 11.4: User function.
+# schema2-11.5 - 11.8: Collation sequence.
+#
+do_test schema2-11.1 {
+ db function tstfunc {}
+ set sql {SELECT * FROM abc}
+ set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test schema2-11.2 {
+ sqlite_delete_function $::DB tstfunc
+} {SQLITE_BUSY}
+do_test schema2-11.3 {
+ set rc [catch {
+ db function tstfunc {}
+ } msg]
+ list $rc $msg
+} {1 {unable to delete/modify user-function due to active statements}}
+do_test schema2-11.4 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+do_test schema2-11.5 {
+ db collate tstcollate {}
+ set sql {SELECT * FROM abc}
+ set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test schema2-11.6 {
+ sqlite_delete_collation $::DB tstcollate
+} {SQLITE_BUSY}
+do_test schema2-11.7 {
+ set rc [catch {
+ db collate tstcollate {}
+ } msg]
+ list $rc $msg
+} {1 {unable to delete/modify collation sequence due to active statements}}
+do_test schema2-11.8 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+
+finish_test
diff --git a/test/schema3.test b/test/schema3.test
new file mode 100644
index 0000000..ba7d745
--- /dev/null
+++ b/test/schema3.test
@@ -0,0 +1,97 @@
+# 2010 Jun 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+source $testdir/lock_common.tcl
+
+# This block tests that if one client modifies the database schema, a
+# second client updates its internal cache of the database schema before
+# executing any queries. Specifically, it does not return a "no such column"
+# or "no such table" error if the table or column in question does exist
+# but was added after the second client loaded its cache of the database
+# schema.
+#
+# Types of schema modifications:
+#
+# 1. Adding a database table.
+# 2. Adding a database view.
+# 3. Adding a database index.
+# 4. Adding a database trigger.
+# 5. Adding a column to an existing table (ALTER TABLE).
+#
+do_multiclient_test tn {
+
+ # Have connections [db1] and [db2] load the current database schema.
+ #
+ sql1 { SELECT * FROM sqlite_master }
+ sql2 { SELECT * FROM sqlite_master }
+
+ foreach {tn2 c1 c2} {
+ 1 { CREATE TABLE t1(a, b) } { SELECT * FROM t1 }
+ 2 { CREATE TABLE t2(a, b) } { UPDATE t2 SET a = b }
+ 3 { CREATE TABLE t3(a, b) } { DELETE FROM t3 }
+ 4 { CREATE TABLE t4(a, b) } { INSERT INTO t4 VALUES(1, 2) }
+ 5 { CREATE TABLE t5(a, b) } { DROP TABLE t5 }
+ 6 { CREATE TABLE t6(a, b) } { CREATE INDEX i1 ON t6(a) }
+
+ 7 { ALTER TABLE t1 ADD COLUMN c } { SELECT a, b, c FROM t1 }
+ 8 { ALTER TABLE t2 ADD COLUMN c } { UPDATE t2 SET a = c }
+ 9 { ALTER TABLE t2 ADD COLUMN d } { UPDATE t2 SET d = c }
+ 10 { ALTER TABLE t3 ADD COLUMN c } { DELETE FROM t3 WHERE c>10 }
+ 11 { ALTER TABLE t4 ADD COLUMN c } { INSERT INTO t4(a,b,c) VALUES(1,2,3) }
+ 12 { ALTER TABLE t6 ADD COLUMN c } { CREATE INDEX i2 ON t6(c) }
+ 13 { ALTER TABLE t6 ADD COLUMN d } {
+ CREATE TRIGGER tr1 AFTER UPDATE OF d ON t6 BEGIN
+ SELECT 1, 2, 3;
+ END;
+ }
+
+ 14 { CREATE INDEX i3 ON t1(a) } { DROP INDEX i3 }
+ 15 { CREATE INDEX i4 ON t2(a) } {
+ SELECT * FROM t2 INDEXED BY i4 ORDER BY a
+ }
+
+ 16 { CREATE TRIGGER tr2 AFTER INSERT ON t3 BEGIN SELECT 1 ; END } {
+ DROP TRIGGER tr2
+ }
+
+ 17 { CREATE VIEW v1 AS SELECT * FROM t1 } { SELECT a,b,c FROM v1 }
+ 18 { ALTER TABLE t1 ADD COLUMN d } { SELECT a,b,c,d FROM v1 }
+
+ 19 { CREATE TABLE t7(a, b) } {
+ DROP TABLE IF EXISTS t7; CREATE TABLE t7(c, d);
+ }
+ 20 { CREATE INDEX i5 ON t7(c, d) } {
+ DROP INDEX IF EXISTS i5; CREATE INDEX i5 ON t7(c)
+ }
+ 21 { CREATE TRIGGER tr3 BEFORE DELETE ON t7 BEGIN SELECT 1, 2, 3 ; END } {
+ DROP TRIGGER IF EXISTS tr3;
+ CREATE TRIGGER tr3 AFTER INSERT ON t7 BEGIN SELECT 1, 2, 3 ; END
+ }
+
+ 22 { CREATE TABLE t8(a, b) } {
+ CREATE TRIGGER tr4 AFTER UPDATE OF a ON t8 BEGIN
+ SELECT 1, 2, 3;
+ END;
+ }
+ } {
+ do_test schema3-1.$tn.$tn2 {
+ sql1 $c1
+ sql2 $c2
+ } {}
+ }
+}
+
+finish_test
diff --git a/test/schema4.test b/test/schema4.test
new file mode 100644
index 0000000..6618d75
--- /dev/null
+++ b/test/schema4.test
@@ -0,0 +1,175 @@
+# 2010 September 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that a trigger may have the same
+# name as an index, view or table in the same database.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+#--------------------------------------------------------------------------
+# Test organization:
+#
+# schema4-1.*: Dropping and creating triggers and other objects where
+# triggers and at least on other object share a name.
+#
+# schema4-2.*: Renaming tables where there is a trigger that shares the
+# name of the table or one of its indices.
+#
+
+do_execsql_test schema4-1.1 {
+ CREATE TABLE log(x, a, b);
+ CREATE TABLE tbl(a, b);
+
+ CREATE TABLE t1(a, b);
+ CREATE VIEW v1 AS SELECT * FROM tbl;
+ CREATE INDEX i1 ON tbl(a);
+} {}
+
+do_execsql_test schema4-1.2 {
+ CREATE TRIGGER t1 AFTER INSERT ON tbl BEGIN
+ INSERT INTO log VALUES('after insert', new.a, new.b);
+ END;
+ CREATE TRIGGER v1 AFTER UPDATE ON tbl BEGIN
+ INSERT INTO log VALUES('after update', new.a, new.b);
+ END;
+ CREATE TRIGGER i1 AFTER DELETE ON tbl BEGIN
+ INSERT INTO log VALUES('after delete', old.a, old.b);
+ END;
+} {}
+
+do_execsql_test schema4-1.3 {
+ INSERT INTO tbl VALUES(1, 2);
+ UPDATE tbl SET b=a+b, a=a+1;
+ DELETE FROM tbl;
+
+ SELECT x, a, b FROM log;
+} {{after insert} 1 2 {after update} 2 3 {after delete} 2 3}
+
+do_execsql_test schema4-1.4 {
+ DELETE FROM log;
+
+ DROP INDEX i1;
+ DROP TABLE t1;
+ DROP VIEW v1;
+
+ INSERT INTO tbl VALUES(1, 2);
+ UPDATE tbl SET b=a+b, a=a+1;
+ DELETE FROM tbl;
+
+ SELECT x, a, b FROM log;
+} {{after insert} 1 2 {after update} 2 3 {after delete} 2 3}
+
+db close
+sqlite3 db test.db
+
+do_execsql_test schema4-1.5 {
+ DELETE FROM log;
+ INSERT INTO tbl VALUES(1, 2);
+ UPDATE tbl SET b=a+b, a=a+1;
+ DELETE FROM tbl;
+ SELECT x, a, b FROM log;
+} {{after insert} 1 2 {after update} 2 3 {after delete} 2 3}
+
+do_execsql_test schema4-1.6 {
+ CREATE TABLE t1(a, b);
+ CREATE VIEW v1 AS SELECT * FROM tbl;
+ CREATE INDEX i1 ON tbl(a);
+} {}
+
+ifcapable fts3 {
+ do_execsql_test schema4-1.7 {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts3;
+ } {}
+
+ do_execsql_test schema4-1.8 {
+ DELETE FROM log;
+ DROP TABLE t1;
+ INSERT INTO tbl VALUES(1, 2);
+ UPDATE tbl SET b=a+b, a=a+1;
+ DELETE FROM tbl;
+ SELECT x, a, b FROM log;
+ } {{after insert} 1 2 {after update} 2 3 {after delete} 2 3}
+}
+
+ifcapable altertable {
+ drop_all_tables
+ do_execsql_test schema4-2.1 {
+ CREATE TABLE log(x, a, b);
+ CREATE TABLE tbl(a, b);
+
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ } {}
+
+ do_execsql_test schema4-2.2 {
+ CREATE TRIGGER t1 AFTER INSERT ON tbl BEGIN
+ INSERT INTO log VALUES('after insert', new.a, new.b);
+ END;
+ CREATE TRIGGER i1 AFTER DELETE ON tbl BEGIN
+ INSERT INTO log VALUES('after delete', old.a, old.b);
+ END;
+ } {}
+
+ do_execsql_test schema4-2.3 { ALTER TABLE t1 RENAME TO t2 } {}
+
+ do_execsql_test schema4-2.4 {
+ INSERT INTO tbl VALUES('a', 'b');
+ DELETE FROM tbl;
+ SELECT * FROM log;
+ } {{after insert} a b {after delete} a b}
+
+ db close
+ sqlite3 db test.db
+
+ do_execsql_test schema4-2.5 {
+ DELETE FROM log;
+ INSERT INTO tbl VALUES('c', 'd');
+ DELETE FROM tbl;
+ SELECT * FROM log;
+ } {{after insert} c d {after delete} c d}
+
+ do_execsql_test schema4-2.6 {
+ CREATE TEMP TRIGGER x1 AFTER UPDATE ON tbl BEGIN
+ INSERT INTO log VALUES('after update', new.a, new.b);
+ END;
+
+ CREATE TEMP TABLE x1(x);
+ INSERT INTO x1 VALUES(123);
+ } {}
+
+ do_execsql_test schema4-2.8 {
+ select sql from sqlite_temp_master WHERE type='table';
+ } {{CREATE TABLE x1(x)}}
+
+ do_execsql_test schema4-2.7 { ALTER TABLE tbl RENAME TO tbl2 } {}
+
+ do_execsql_test schema4-2.9 {
+ select sql from sqlite_temp_master WHERE type='table';
+ } {{CREATE TABLE x1(x)}}
+
+ do_execsql_test schema4-2.10 {
+ DELETE FROM log;
+ INSERT INTO tbl2 VALUES('e', 'f');
+ UPDATE tbl2 SET a='g', b='h';
+ DELETE FROM tbl2;
+ SELECT * FROM log;
+ } {{after insert} e f {after update} g h {after delete} g h}
+
+ do_execsql_test schema4-2.11 {
+ INSERT INTO x1 VALUES(456);
+ SELECT * FROM x1
+ } {123 456}
+}
+
+finish_test
diff --git a/test/securedel.test b/test/securedel.test
new file mode 100644
index 0000000..7ff5a62
--- /dev/null
+++ b/test/securedel.test
@@ -0,0 +1,73 @@
+# 2010 January 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+#
+# Tests for the secure_delete pragma.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+unset -nocomplain DEFAULT_SECDEL
+set DEFAULT_SECDEL 0
+ifcapable secure_delete {
+ set DEFAULT_SECDEL 1
+}
+
+
+do_test securedel-1.0 {
+ db eval {PRAGMA secure_delete;}
+} $DEFAULT_SECDEL
+
+forcedelete test2.db test2.db-journal
+do_test securedel-1.1 {
+ db eval {
+ ATTACH 'test2.db' AS db2;
+ PRAGMA main.secure_delete=ON;
+ PRAGMA db2.secure_delete;
+ }
+} [list 1 $DEFAULT_SECDEL]
+do_test securedel-1.2 {
+ db eval {
+ PRAGMA main.secure_delete=OFF;
+ PRAGMA db2.secure_delete;
+ }
+} [list 0 $DEFAULT_SECDEL]
+do_test securedel-1.3 {
+ db eval {
+ PRAGMA secure_delete=OFF;
+ PRAGMA db2.secure_delete;
+ }
+} {0 0}
+do_test securedel-1.4 {
+breakpoint
+ db eval {
+ PRAGMA secure_delete=ON;
+ PRAGMA db2.secure_delete;
+ }
+} {1 1}
+
+do_test securedel-2.1 {
+ db eval {
+ DETACH db2;
+ ATTACH 'test2.db' AS db2;
+ PRAGMA db2.secure_delete;
+ }
+} 1
+do_test securedel-2.2 {
+ db eval {
+ DETACH db2;
+ PRAGMA main.secure_delete=OFF;
+ ATTACH 'test2.db' AS db2;
+ PRAGMA db2.secure_delete;
+ }
+} {0 0}
+
+finish_test
diff --git a/test/select1.test b/test/select1.test
new file mode 100644
index 0000000..73b0e40
--- /dev/null
+++ b/test/select1.test
@@ -0,0 +1,1070 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the SELECT statement.
+#
+# $Id: select1.test,v 1.70 2009/05/28 01:00:56 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Try to select on a non-existant table.
+#
+do_test select1-1.1 {
+ set v [catch {execsql {SELECT * FROM test1}} msg]
+ lappend v $msg
+} {1 {no such table: test1}}
+
+
+execsql {CREATE TABLE test1(f1 int, f2 int)}
+
+do_test select1-1.2 {
+ set v [catch {execsql {SELECT * FROM test1, test2}} msg]
+ lappend v $msg
+} {1 {no such table: test2}}
+do_test select1-1.3 {
+ set v [catch {execsql {SELECT * FROM test2, test1}} msg]
+ lappend v $msg
+} {1 {no such table: test2}}
+
+execsql {INSERT INTO test1(f1,f2) VALUES(11,22)}
+
+
+# Make sure the columns are extracted correctly.
+#
+do_test select1-1.4 {
+ execsql {SELECT f1 FROM test1}
+} {11}
+do_test select1-1.5 {
+ execsql {SELECT f2 FROM test1}
+} {22}
+do_test select1-1.6 {
+ execsql {SELECT f2, f1 FROM test1}
+} {22 11}
+do_test select1-1.7 {
+ execsql {SELECT f1, f2 FROM test1}
+} {11 22}
+do_test select1-1.8 {
+ execsql {SELECT * FROM test1}
+} {11 22}
+do_test select1-1.8.1 {
+ execsql {SELECT *, * FROM test1}
+} {11 22 11 22}
+do_test select1-1.8.2 {
+ execsql {SELECT *, min(f1,f2), max(f1,f2) FROM test1}
+} {11 22 11 22}
+do_test select1-1.8.3 {
+ execsql {SELECT 'one', *, 'two', * FROM test1}
+} {one 11 22 two 11 22}
+
+execsql {CREATE TABLE test2(r1 real, r2 real)}
+execsql {INSERT INTO test2(r1,r2) VALUES(1.1,2.2)}
+
+do_test select1-1.9 {
+ execsql {SELECT * FROM test1, test2}
+} {11 22 1.1 2.2}
+do_test select1-1.9.1 {
+ execsql {SELECT *, 'hi' FROM test1, test2}
+} {11 22 1.1 2.2 hi}
+do_test select1-1.9.2 {
+ execsql {SELECT 'one', *, 'two', * FROM test1, test2}
+} {one 11 22 1.1 2.2 two 11 22 1.1 2.2}
+do_test select1-1.10 {
+ execsql {SELECT test1.f1, test2.r1 FROM test1, test2}
+} {11 1.1}
+do_test select1-1.11 {
+ execsql {SELECT test1.f1, test2.r1 FROM test2, test1}
+} {11 1.1}
+do_test select1-1.11.1 {
+ execsql {SELECT * FROM test2, test1}
+} {1.1 2.2 11 22}
+do_test select1-1.11.2 {
+ execsql {SELECT * FROM test1 AS a, test1 AS b}
+} {11 22 11 22}
+do_test select1-1.12 {
+ execsql {SELECT max(test1.f1,test2.r1), min(test1.f2,test2.r2)
+ FROM test2, test1}
+} {11 2.2}
+do_test select1-1.13 {
+ execsql {SELECT min(test1.f1,test2.r1), max(test1.f2,test2.r2)
+ FROM test1, test2}
+} {1.1 22}
+
+set long {This is a string that is too big to fit inside a NBFS buffer}
+do_test select1-2.0 {
+ execsql "
+ DROP TABLE test2;
+ DELETE FROM test1;
+ INSERT INTO test1 VALUES(11,22);
+ INSERT INTO test1 VALUES(33,44);
+ CREATE TABLE t3(a,b);
+ INSERT INTO t3 VALUES('abc',NULL);
+ INSERT INTO t3 VALUES(NULL,'xyz');
+ INSERT INTO t3 SELECT * FROM test1;
+ CREATE TABLE t4(a,b);
+ INSERT INTO t4 VALUES(NULL,'$long');
+ SELECT * FROM t3;
+ "
+} {abc {} {} xyz 11 22 33 44}
+
+# Error messges from sqliteExprCheck
+#
+do_test select1-2.1 {
+ set v [catch {execsql {SELECT count(f1,f2) FROM test1}} msg]
+ lappend v $msg
+} {1 {wrong number of arguments to function count()}}
+do_test select1-2.2 {
+ set v [catch {execsql {SELECT count(f1) FROM test1}} msg]
+ lappend v $msg
+} {0 2}
+do_test select1-2.3 {
+ set v [catch {execsql {SELECT Count() FROM test1}} msg]
+ lappend v $msg
+} {0 2}
+do_test select1-2.4 {
+ set v [catch {execsql {SELECT COUNT(*) FROM test1}} msg]
+ lappend v $msg
+} {0 2}
+do_test select1-2.5 {
+ set v [catch {execsql {SELECT COUNT(*)+1 FROM test1}} msg]
+ lappend v $msg
+} {0 3}
+do_test select1-2.5.1 {
+ execsql {SELECT count(*),count(a),count(b) FROM t3}
+} {4 3 3}
+do_test select1-2.5.2 {
+ execsql {SELECT count(*),count(a),count(b) FROM t4}
+} {1 0 1}
+do_test select1-2.5.3 {
+ execsql {SELECT count(*),count(a),count(b) FROM t4 WHERE b=5}
+} {0 0 0}
+do_test select1-2.6 {
+ set v [catch {execsql {SELECT min(*) FROM test1}} msg]
+ lappend v $msg
+} {1 {wrong number of arguments to function min()}}
+do_test select1-2.7 {
+ set v [catch {execsql {SELECT Min(f1) FROM test1}} msg]
+ lappend v $msg
+} {0 11}
+do_test select1-2.8 {
+ set v [catch {execsql {SELECT MIN(f1,f2) FROM test1}} msg]
+ lappend v [lsort $msg]
+} {0 {11 33}}
+do_test select1-2.8.1 {
+ execsql {SELECT coalesce(min(a),'xyzzy') FROM t3}
+} {11}
+do_test select1-2.8.2 {
+ execsql {SELECT min(coalesce(a,'xyzzy')) FROM t3}
+} {11}
+do_test select1-2.8.3 {
+ execsql {SELECT min(b), min(b) FROM t4}
+} [list $long $long]
+do_test select1-2.9 {
+ set v [catch {execsql {SELECT MAX(*) FROM test1}} msg]
+ lappend v $msg
+} {1 {wrong number of arguments to function MAX()}}
+do_test select1-2.10 {
+ set v [catch {execsql {SELECT Max(f1) FROM test1}} msg]
+ lappend v $msg
+} {0 33}
+do_test select1-2.11 {
+ set v [catch {execsql {SELECT max(f1,f2) FROM test1}} msg]
+ lappend v [lsort $msg]
+} {0 {22 44}}
+do_test select1-2.12 {
+ set v [catch {execsql {SELECT MAX(f1,f2)+1 FROM test1}} msg]
+ lappend v [lsort $msg]
+} {0 {23 45}}
+do_test select1-2.13 {
+ set v [catch {execsql {SELECT MAX(f1)+1 FROM test1}} msg]
+ lappend v $msg
+} {0 34}
+do_test select1-2.13.1 {
+ execsql {SELECT coalesce(max(a),'xyzzy') FROM t3}
+} {abc}
+do_test select1-2.13.2 {
+ execsql {SELECT max(coalesce(a,'xyzzy')) FROM t3}
+} {xyzzy}
+do_test select1-2.14 {
+ set v [catch {execsql {SELECT SUM(*) FROM test1}} msg]
+ lappend v $msg
+} {1 {wrong number of arguments to function SUM()}}
+do_test select1-2.15 {
+ set v [catch {execsql {SELECT Sum(f1) FROM test1}} msg]
+ lappend v $msg
+} {0 44}
+do_test select1-2.16 {
+ set v [catch {execsql {SELECT sum(f1,f2) FROM test1}} msg]
+ lappend v $msg
+} {1 {wrong number of arguments to function sum()}}
+do_test select1-2.17 {
+ set v [catch {execsql {SELECT SUM(f1)+1 FROM test1}} msg]
+ lappend v $msg
+} {0 45}
+do_test select1-2.17.1 {
+ execsql {SELECT sum(a) FROM t3}
+} {44.0}
+do_test select1-2.18 {
+ set v [catch {execsql {SELECT XYZZY(f1) FROM test1}} msg]
+ lappend v $msg
+} {1 {no such function: XYZZY}}
+do_test select1-2.19 {
+ set v [catch {execsql {SELECT SUM(min(f1,f2)) FROM test1}} msg]
+ lappend v $msg
+} {0 44}
+do_test select1-2.20 {
+ set v [catch {execsql {SELECT SUM(min(f1)) FROM test1}} msg]
+ lappend v $msg
+} {1 {misuse of aggregate function min()}}
+
+# Ticket #2526
+#
+do_test select1-2.21 {
+ catchsql {
+ SELECT min(f1) AS m FROM test1 GROUP BY f1 HAVING max(m+5)<10
+ }
+} {1 {misuse of aliased aggregate m}}
+do_test select1-2.22 {
+ catchsql {
+ SELECT coalesce(min(f1)+5,11) AS m FROM test1
+ GROUP BY f1
+ HAVING max(m+5)<10
+ }
+} {1 {misuse of aliased aggregate m}}
+do_test select1-2.23 {
+ execsql {
+ CREATE TABLE tkt2526(a,b,c PRIMARY KEY);
+ INSERT INTO tkt2526 VALUES('x','y',NULL);
+ INSERT INTO tkt2526 VALUES('x','z',NULL);
+ }
+ catchsql {
+ SELECT count(a) AS cn FROM tkt2526 GROUP BY a HAVING cn<max(cn)
+ }
+} {1 {misuse of aliased aggregate cn}}
+
+# WHERE clause expressions
+#
+do_test select1-3.1 {
+ set v [catch {execsql {SELECT f1 FROM test1 WHERE f1<11}} msg]
+ lappend v $msg
+} {0 {}}
+do_test select1-3.2 {
+ set v [catch {execsql {SELECT f1 FROM test1 WHERE f1<=11}} msg]
+ lappend v $msg
+} {0 11}
+do_test select1-3.3 {
+ set v [catch {execsql {SELECT f1 FROM test1 WHERE f1=11}} msg]
+ lappend v $msg
+} {0 11}
+do_test select1-3.4 {
+ set v [catch {execsql {SELECT f1 FROM test1 WHERE f1>=11}} msg]
+ lappend v [lsort $msg]
+} {0 {11 33}}
+do_test select1-3.5 {
+ set v [catch {execsql {SELECT f1 FROM test1 WHERE f1>11}} msg]
+ lappend v [lsort $msg]
+} {0 33}
+do_test select1-3.6 {
+ set v [catch {execsql {SELECT f1 FROM test1 WHERE f1!=11}} msg]
+ lappend v [lsort $msg]
+} {0 33}
+do_test select1-3.7 {
+ set v [catch {execsql {SELECT f1 FROM test1 WHERE min(f1,f2)!=11}} msg]
+ lappend v [lsort $msg]
+} {0 33}
+do_test select1-3.8 {
+ set v [catch {execsql {SELECT f1 FROM test1 WHERE max(f1,f2)!=11}} msg]
+ lappend v [lsort $msg]
+} {0 {11 33}}
+do_test select1-3.9 {
+ set v [catch {execsql {SELECT f1 FROM test1 WHERE count(f1,f2)!=11}} msg]
+ lappend v $msg
+} {1 {wrong number of arguments to function count()}}
+
+# ORDER BY expressions
+#
+do_test select1-4.1 {
+ set v [catch {execsql {SELECT f1 FROM test1 ORDER BY f1}} msg]
+ lappend v $msg
+} {0 {11 33}}
+do_test select1-4.2 {
+ set v [catch {execsql {SELECT f1 FROM test1 ORDER BY -f1}} msg]
+ lappend v $msg
+} {0 {33 11}}
+do_test select1-4.3 {
+ set v [catch {execsql {SELECT f1 FROM test1 ORDER BY min(f1,f2)}} msg]
+ lappend v $msg
+} {0 {11 33}}
+do_test select1-4.4 {
+ set v [catch {execsql {SELECT f1 FROM test1 ORDER BY min(f1)}} msg]
+ lappend v $msg
+} {1 {misuse of aggregate: min()}}
+
+# The restriction not allowing constants in the ORDER BY clause
+# has been removed. See ticket #1768
+#do_test select1-4.5 {
+# catchsql {
+# SELECT f1 FROM test1 ORDER BY 8.4;
+# }
+#} {1 {ORDER BY terms must not be non-integer constants}}
+#do_test select1-4.6 {
+# catchsql {
+# SELECT f1 FROM test1 ORDER BY '8.4';
+# }
+#} {1 {ORDER BY terms must not be non-integer constants}}
+#do_test select1-4.7.1 {
+# catchsql {
+# SELECT f1 FROM test1 ORDER BY 'xyz';
+# }
+#} {1 {ORDER BY terms must not be non-integer constants}}
+#do_test select1-4.7.2 {
+# catchsql {
+# SELECT f1 FROM test1 ORDER BY -8.4;
+# }
+#} {1 {ORDER BY terms must not be non-integer constants}}
+#do_test select1-4.7.3 {
+# catchsql {
+# SELECT f1 FROM test1 ORDER BY +8.4;
+# }
+#} {1 {ORDER BY terms must not be non-integer constants}}
+#do_test select1-4.7.4 {
+# catchsql {
+# SELECT f1 FROM test1 ORDER BY 4294967296; -- constant larger than 32 bits
+# }
+#} {1 {ORDER BY terms must not be non-integer constants}}
+
+do_test select1-4.5 {
+ execsql {
+ SELECT f1 FROM test1 ORDER BY 8.4
+ }
+} {11 33}
+do_test select1-4.6 {
+ execsql {
+ SELECT f1 FROM test1 ORDER BY '8.4'
+ }
+} {11 33}
+
+do_test select1-4.8 {
+ execsql {
+ CREATE TABLE t5(a,b);
+ INSERT INTO t5 VALUES(1,10);
+ INSERT INTO t5 VALUES(2,9);
+ SELECT * FROM t5 ORDER BY 1;
+ }
+} {1 10 2 9}
+do_test select1-4.9.1 {
+ execsql {
+ SELECT * FROM t5 ORDER BY 2;
+ }
+} {2 9 1 10}
+do_test select1-4.9.2 {
+ execsql {
+ SELECT * FROM t5 ORDER BY +2;
+ }
+} {2 9 1 10}
+do_test select1-4.10.1 {
+ catchsql {
+ SELECT * FROM t5 ORDER BY 3;
+ }
+} {1 {1st ORDER BY term out of range - should be between 1 and 2}}
+do_test select1-4.10.2 {
+ catchsql {
+ SELECT * FROM t5 ORDER BY -1;
+ }
+} {1 {1st ORDER BY term out of range - should be between 1 and 2}}
+do_test select1-4.11 {
+ execsql {
+ INSERT INTO t5 VALUES(3,10);
+ SELECT * FROM t5 ORDER BY 2, 1 DESC;
+ }
+} {2 9 3 10 1 10}
+do_test select1-4.12 {
+ execsql {
+ SELECT * FROM t5 ORDER BY 1 DESC, b;
+ }
+} {3 10 2 9 1 10}
+do_test select1-4.13 {
+ execsql {
+ SELECT * FROM t5 ORDER BY b DESC, 1;
+ }
+} {1 10 3 10 2 9}
+
+
+# ORDER BY ignored on an aggregate query
+#
+do_test select1-5.1 {
+ set v [catch {execsql {SELECT max(f1) FROM test1 ORDER BY f2}} msg]
+ lappend v $msg
+} {0 33}
+
+execsql {CREATE TABLE test2(t1 text, t2 text)}
+execsql {INSERT INTO test2 VALUES('abc','xyz')}
+
+# Check for column naming
+#
+do_test select1-6.1 {
+ set v [catch {execsql2 {SELECT f1 FROM test1 ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {f1 11 f1 33}}
+do_test select1-6.1.1 {
+ db eval {PRAGMA full_column_names=on}
+ set v [catch {execsql2 {SELECT f1 FROM test1 ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {test1.f1 11 test1.f1 33}}
+do_test select1-6.1.2 {
+ set v [catch {execsql2 {SELECT f1 as 'f1' FROM test1 ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {f1 11 f1 33}}
+do_test select1-6.1.3 {
+ set v [catch {execsql2 {SELECT * FROM test1 WHERE f1==11}} msg]
+ lappend v $msg
+} {0 {f1 11 f2 22}}
+do_test select1-6.1.4 {
+ set v [catch {execsql2 {SELECT DISTINCT * FROM test1 WHERE f1==11}} msg]
+ db eval {PRAGMA full_column_names=off}
+ lappend v $msg
+} {0 {f1 11 f2 22}}
+do_test select1-6.1.5 {
+ set v [catch {execsql2 {SELECT * FROM test1 WHERE f1==11}} msg]
+ lappend v $msg
+} {0 {f1 11 f2 22}}
+do_test select1-6.1.6 {
+ set v [catch {execsql2 {SELECT DISTINCT * FROM test1 WHERE f1==11}} msg]
+ lappend v $msg
+} {0 {f1 11 f2 22}}
+do_test select1-6.2 {
+ set v [catch {execsql2 {SELECT f1 as xyzzy FROM test1 ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {xyzzy 11 xyzzy 33}}
+do_test select1-6.3 {
+ set v [catch {execsql2 {SELECT f1 as "xyzzy" FROM test1 ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {xyzzy 11 xyzzy 33}}
+do_test select1-6.3.1 {
+ set v [catch {execsql2 {SELECT f1 as 'xyzzy ' FROM test1 ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {{xyzzy } 11 {xyzzy } 33}}
+do_test select1-6.4 {
+ set v [catch {execsql2 {SELECT f1+F2 as xyzzy FROM test1 ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {xyzzy 33 xyzzy 77}}
+do_test select1-6.4a {
+ set v [catch {execsql2 {SELECT f1+F2 FROM test1 ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {f1+F2 33 f1+F2 77}}
+do_test select1-6.5 {
+ set v [catch {execsql2 {SELECT test1.f1+F2 FROM test1 ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {test1.f1+F2 33 test1.f1+F2 77}}
+do_test select1-6.5.1 {
+ execsql2 {PRAGMA full_column_names=on}
+ set v [catch {execsql2 {SELECT test1.f1+F2 FROM test1 ORDER BY f2}} msg]
+ execsql2 {PRAGMA full_column_names=off}
+ lappend v $msg
+} {0 {test1.f1+F2 33 test1.f1+F2 77}}
+do_test select1-6.6 {
+ set v [catch {execsql2 {SELECT test1.f1+F2, t1 FROM test1, test2
+ ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {test1.f1+F2 33 t1 abc test1.f1+F2 77 t1 abc}}
+do_test select1-6.7 {
+ set v [catch {execsql2 {SELECT A.f1, t1 FROM test1 as A, test2
+ ORDER BY f2}} msg]
+ lappend v $msg
+} {0 {f1 11 t1 abc f1 33 t1 abc}}
+do_test select1-6.8 {
+ set v [catch {execsql2 {SELECT A.f1, f1 FROM test1 as A, test1 as B
+ ORDER BY f2}} msg]
+ lappend v $msg
+} {1 {ambiguous column name: f1}}
+do_test select1-6.8b {
+ set v [catch {execsql2 {SELECT A.f1, B.f1 FROM test1 as A, test1 as B
+ ORDER BY f2}} msg]
+ lappend v $msg
+} {1 {ambiguous column name: f2}}
+do_test select1-6.8c {
+ set v [catch {execsql2 {SELECT A.f1, f1 FROM test1 as A, test1 as A
+ ORDER BY f2}} msg]
+ lappend v $msg
+} {1 {ambiguous column name: A.f1}}
+do_test select1-6.9.1 {
+ set v [catch {execsql {SELECT A.f1, B.f1 FROM test1 as A, test1 as B
+ ORDER BY A.f1, B.f1}} msg]
+ lappend v $msg
+} {0 {11 11 11 33 33 11 33 33}}
+do_test select1-6.9.2 {
+ set v [catch {execsql2 {SELECT A.f1, B.f1 FROM test1 as A, test1 as B
+ ORDER BY A.f1, B.f1}} msg]
+ lappend v $msg
+} {0 {f1 11 f1 11 f1 33 f1 33 f1 11 f1 11 f1 33 f1 33}}
+
+do_test select1-6.9.3 {
+ db eval {
+ PRAGMA short_column_names=OFF;
+ PRAGMA full_column_names=OFF;
+ }
+ execsql2 {
+ SELECT test1 . f1, test1 . f2 FROM test1 LIMIT 1
+ }
+} {{test1 . f1} 11 {test1 . f2} 22}
+do_test select1-6.9.4 {
+ db eval {
+ PRAGMA short_column_names=OFF;
+ PRAGMA full_column_names=ON;
+ }
+ execsql2 {
+ SELECT test1 . f1, test1 . f2 FROM test1 LIMIT 1
+ }
+} {test1.f1 11 test1.f2 22}
+do_test select1-6.9.5 {
+ db eval {
+ PRAGMA short_column_names=OFF;
+ PRAGMA full_column_names=ON;
+ }
+ execsql2 {
+ SELECT 123.45;
+ }
+} {123.45 123.45}
+do_test select1-6.9.6 {
+ execsql2 {
+ SELECT * FROM test1 a, test1 b LIMIT 1
+ }
+} {a.f1 11 a.f2 22 b.f1 11 b.f2 22}
+do_test select1-6.9.7 {
+ set x [execsql2 {
+ SELECT * FROM test1 a, (select 5, 6) LIMIT 1
+ }]
+ regsub -all {subquery_[0-9a-fA-F]+_} $x {subquery} x
+ set x
+} {a.f1 11 a.f2 22 sqlite_subquery.5 5 sqlite_subquery.6 6}
+do_test select1-6.9.8 {
+ set x [execsql2 {
+ SELECT * FROM test1 a, (select 5 AS x, 6 AS y) AS b LIMIT 1
+ }]
+ regsub -all {subquery_[0-9a-fA-F]+_} $x {subquery} x
+ set x
+} {a.f1 11 a.f2 22 b.x 5 b.y 6}
+do_test select1-6.9.9 {
+ execsql2 {
+ SELECT a.f1, b.f2 FROM test1 a, test1 b LIMIT 1
+ }
+} {test1.f1 11 test1.f2 22}
+do_test select1-6.9.10 {
+ execsql2 {
+ SELECT f1, t1 FROM test1, test2 LIMIT 1
+ }
+} {test1.f1 11 test2.t1 abc}
+do_test select1-6.9.11 {
+ db eval {
+ PRAGMA short_column_names=ON;
+ PRAGMA full_column_names=ON;
+ }
+ execsql2 {
+ SELECT a.f1, b.f2 FROM test1 a, test1 b LIMIT 1
+ }
+} {test1.f1 11 test1.f2 22}
+do_test select1-6.9.12 {
+ execsql2 {
+ SELECT f1, t1 FROM test1, test2 LIMIT 1
+ }
+} {test1.f1 11 test2.t1 abc}
+do_test select1-6.9.13 {
+ db eval {
+ PRAGMA short_column_names=ON;
+ PRAGMA full_column_names=OFF;
+ }
+ execsql2 {
+ SELECT a.f1, b.f1 FROM test1 a, test1 b LIMIT 1
+ }
+} {f1 11 f1 11}
+do_test select1-6.9.14 {
+ execsql2 {
+ SELECT f1, t1 FROM test1, test2 LIMIT 1
+ }
+} {f1 11 t1 abc}
+do_test select1-6.9.15 {
+ db eval {
+ PRAGMA short_column_names=OFF;
+ PRAGMA full_column_names=ON;
+ }
+ execsql2 {
+ SELECT a.f1, b.f1 FROM test1 a, test1 b LIMIT 1
+ }
+} {test1.f1 11 test1.f1 11}
+do_test select1-6.9.16 {
+ execsql2 {
+ SELECT f1, t1 FROM test1, test2 LIMIT 1
+ }
+} {test1.f1 11 test2.t1 abc}
+
+
+db eval {
+ PRAGMA short_column_names=ON;
+ PRAGMA full_column_names=OFF;
+}
+
+ifcapable compound {
+do_test select1-6.10 {
+ set v [catch {execsql2 {
+ SELECT f1 FROM test1 UNION SELECT f2 FROM test1
+ ORDER BY f2;
+ }} msg]
+ lappend v $msg
+} {0 {f1 11 f1 22 f1 33 f1 44}}
+do_test select1-6.11 {
+ set v [catch {execsql2 {
+ SELECT f1 FROM test1 UNION SELECT f2+100 FROM test1
+ ORDER BY f2+101;
+ }} msg]
+ lappend v $msg
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+# Ticket #2296
+ifcapable subquery&&compound {
+do_test select1-6.20 {
+ execsql {
+ CREATE TABLE t6(a TEXT, b TEXT);
+ INSERT INTO t6 VALUES('a','0');
+ INSERT INTO t6 VALUES('b','1');
+ INSERT INTO t6 VALUES('c','2');
+ INSERT INTO t6 VALUES('d','3');
+ SELECT a FROM t6 WHERE b IN
+ (SELECT b FROM t6 WHERE a<='b' UNION SELECT '3' AS x
+ ORDER BY 1 LIMIT 1)
+ }
+} {a}
+do_test select1-6.21 {
+ execsql {
+ SELECT a FROM t6 WHERE b IN
+ (SELECT b FROM t6 WHERE a<='b' UNION SELECT '3' AS x
+ ORDER BY 1 DESC LIMIT 1)
+ }
+} {d}
+do_test select1-6.22 {
+ execsql {
+ SELECT a FROM t6 WHERE b IN
+ (SELECT b FROM t6 WHERE a<='b' UNION SELECT '3' AS x
+ ORDER BY b LIMIT 2)
+ ORDER BY a;
+ }
+} {a b}
+do_test select1-6.23 {
+ execsql {
+ SELECT a FROM t6 WHERE b IN
+ (SELECT b FROM t6 WHERE a<='b' UNION SELECT '3' AS x
+ ORDER BY x DESC LIMIT 2)
+ ORDER BY a;
+ }
+} {b d}
+}
+
+} ;#ifcapable compound
+
+do_test select1-7.1 {
+ set v [catch {execsql {
+ SELECT f1 FROM test1 WHERE f2=;
+ }} msg]
+ lappend v $msg
+} {1 {near ";": syntax error}}
+ifcapable compound {
+do_test select1-7.2 {
+ set v [catch {execsql {
+ SELECT f1 FROM test1 UNION SELECT WHERE;
+ }} msg]
+ lappend v $msg
+} {1 {near "WHERE": syntax error}}
+} ;# ifcapable compound
+do_test select1-7.3 {
+ set v [catch {execsql {SELECT f1 FROM test1 as 'hi', test2 as}} msg]
+ lappend v $msg
+} {1 {near "as": syntax error}}
+do_test select1-7.4 {
+ set v [catch {execsql {
+ SELECT f1 FROM test1 ORDER BY;
+ }} msg]
+ lappend v $msg
+} {1 {near ";": syntax error}}
+do_test select1-7.5 {
+ set v [catch {execsql {
+ SELECT f1 FROM test1 ORDER BY f1 desc, f2 where;
+ }} msg]
+ lappend v $msg
+} {1 {near "where": syntax error}}
+do_test select1-7.6 {
+ set v [catch {execsql {
+ SELECT count(f1,f2 FROM test1;
+ }} msg]
+ lappend v $msg
+} {1 {near "FROM": syntax error}}
+do_test select1-7.7 {
+ set v [catch {execsql {
+ SELECT count(f1,f2+) FROM test1;
+ }} msg]
+ lappend v $msg
+} {1 {near ")": syntax error}}
+do_test select1-7.8 {
+ set v [catch {execsql {
+ SELECT f1 FROM test1 ORDER BY f2, f1+;
+ }} msg]
+ lappend v $msg
+} {1 {near ";": syntax error}}
+do_test select1-7.9 {
+ catchsql {
+ SELECT f1 FROM test1 LIMIT 5+3 OFFSET 11 ORDER BY f2;
+ }
+} {1 {near "ORDER": syntax error}}
+
+do_test select1-8.1 {
+ execsql {SELECT f1 FROM test1 WHERE 4.3+2.4 OR 1 ORDER BY f1}
+} {11 33}
+do_test select1-8.2 {
+ execsql {
+ SELECT f1 FROM test1 WHERE ('x' || f1) BETWEEN 'x10' AND 'x20'
+ ORDER BY f1
+ }
+} {11}
+do_test select1-8.3 {
+ execsql {
+ SELECT f1 FROM test1 WHERE 5-3==2
+ ORDER BY f1
+ }
+} {11 33}
+
+# TODO: This test is failing because f1 is now being loaded off the
+# disk as a vdbe integer, not a string. Hence the value of f1/(f1-11)
+# changes because of rounding. Disable the test for now.
+if 0 {
+do_test select1-8.4 {
+ execsql {
+ SELECT coalesce(f1/(f1-11),'x'),
+ coalesce(min(f1/(f1-11),5),'y'),
+ coalesce(max(f1/(f1-33),6),'z')
+ FROM test1 ORDER BY f1
+ }
+} {x y 6 1.5 1.5 z}
+}
+do_test select1-8.5 {
+ execsql {
+ SELECT min(1,2,3), -max(1,2,3)
+ FROM test1 ORDER BY f1
+ }
+} {1 -3 1 -3}
+
+
+# Check the behavior when the result set is empty
+#
+# SQLite v3 always sets r(*).
+#
+# do_test select1-9.1 {
+# catch {unset r}
+# set r(*) {}
+# db eval {SELECT * FROM test1 WHERE f1<0} r {}
+# set r(*)
+# } {}
+do_test select1-9.2 {
+ execsql {PRAGMA empty_result_callbacks=on}
+ catch {unset r}
+ set r(*) {}
+ db eval {SELECT * FROM test1 WHERE f1<0} r {}
+ set r(*)
+} {f1 f2}
+ifcapable subquery {
+ do_test select1-9.3 {
+ set r(*) {}
+ db eval {SELECT * FROM test1 WHERE f1<(select count(*) from test2)} r {}
+ set r(*)
+ } {f1 f2}
+}
+do_test select1-9.4 {
+ set r(*) {}
+ db eval {SELECT * FROM test1 ORDER BY f1} r {}
+ set r(*)
+} {f1 f2}
+do_test select1-9.5 {
+ set r(*) {}
+ db eval {SELECT * FROM test1 WHERE f1<0 ORDER BY f1} r {}
+ set r(*)
+} {f1 f2}
+unset r
+
+# Check for ORDER BY clauses that refer to an AS name in the column list
+#
+do_test select1-10.1 {
+ execsql {
+ SELECT f1 AS x FROM test1 ORDER BY x
+ }
+} {11 33}
+do_test select1-10.2 {
+ execsql {
+ SELECT f1 AS x FROM test1 ORDER BY -x
+ }
+} {33 11}
+do_test select1-10.3 {
+ execsql {
+ SELECT f1-23 AS x FROM test1 ORDER BY abs(x)
+ }
+} {10 -12}
+do_test select1-10.4 {
+ execsql {
+ SELECT f1-23 AS x FROM test1 ORDER BY -abs(x)
+ }
+} {-12 10}
+do_test select1-10.5 {
+ execsql {
+ SELECT f1-22 AS x, f2-22 as y FROM test1
+ }
+} {-11 0 11 22}
+do_test select1-10.6 {
+ execsql {
+ SELECT f1-22 AS x, f2-22 as y FROM test1 WHERE x>0 AND y<50
+ }
+} {11 22}
+do_test select1-10.7 {
+ execsql {
+ SELECT f1 COLLATE nocase AS x FROM test1 ORDER BY x
+ }
+} {11 33}
+
+# Check the ability to specify "TABLE.*" in the result set of a SELECT
+#
+do_test select1-11.1 {
+ execsql {
+ DELETE FROM t3;
+ DELETE FROM t4;
+ INSERT INTO t3 VALUES(1,2);
+ INSERT INTO t4 VALUES(3,4);
+ SELECT * FROM t3, t4;
+ }
+} {1 2 3 4}
+do_test select1-11.2.1 {
+ execsql {
+ SELECT * FROM t3, t4;
+ }
+} {1 2 3 4}
+do_test select1-11.2.2 {
+ execsql2 {
+ SELECT * FROM t3, t4;
+ }
+} {a 3 b 4 a 3 b 4}
+do_test select1-11.4.1 {
+ execsql {
+ SELECT t3.*, t4.b FROM t3, t4;
+ }
+} {1 2 4}
+do_test select1-11.4.2 {
+ execsql {
+ SELECT "t3".*, t4.b FROM t3, t4;
+ }
+} {1 2 4}
+do_test select1-11.5.1 {
+ execsql2 {
+ SELECT t3.*, t4.b FROM t3, t4;
+ }
+} {a 1 b 4 b 4}
+do_test select1-11.6 {
+ execsql2 {
+ SELECT x.*, y.b FROM t3 AS x, t4 AS y;
+ }
+} {a 1 b 4 b 4}
+do_test select1-11.7 {
+ execsql {
+ SELECT t3.b, t4.* FROM t3, t4;
+ }
+} {2 3 4}
+do_test select1-11.8 {
+ execsql2 {
+ SELECT t3.b, t4.* FROM t3, t4;
+ }
+} {b 4 a 3 b 4}
+do_test select1-11.9 {
+ execsql2 {
+ SELECT x.b, y.* FROM t3 AS x, t4 AS y;
+ }
+} {b 4 a 3 b 4}
+do_test select1-11.10 {
+ catchsql {
+ SELECT t5.* FROM t3, t4;
+ }
+} {1 {no such table: t5}}
+do_test select1-11.11 {
+ catchsql {
+ SELECT t3.* FROM t3 AS x, t4;
+ }
+} {1 {no such table: t3}}
+ifcapable subquery {
+ do_test select1-11.12 {
+ execsql2 {
+ SELECT t3.* FROM t3, (SELECT max(a), max(b) FROM t4)
+ }
+ } {a 1 b 2}
+ do_test select1-11.13 {
+ execsql2 {
+ SELECT t3.* FROM (SELECT max(a), max(b) FROM t4), t3
+ }
+ } {a 1 b 2}
+ do_test select1-11.14 {
+ execsql2 {
+ SELECT * FROM t3, (SELECT max(a), max(b) FROM t4) AS 'tx'
+ }
+ } {a 1 b 2 max(a) 3 max(b) 4}
+ do_test select1-11.15 {
+ execsql2 {
+ SELECT y.*, t3.* FROM t3, (SELECT max(a), max(b) FROM t4) AS y
+ }
+ } {max(a) 3 max(b) 4 a 1 b 2}
+}
+do_test select1-11.16 {
+ execsql2 {
+ SELECT y.* FROM t3 as y, t4 as z
+ }
+} {a 1 b 2}
+
+# Tests of SELECT statements without a FROM clause.
+#
+do_test select1-12.1 {
+ execsql2 {
+ SELECT 1+2+3
+ }
+} {1+2+3 6}
+do_test select1-12.2 {
+ execsql2 {
+ SELECT 1,'hello',2
+ }
+} {1 1 'hello' hello 2 2}
+do_test select1-12.3 {
+ execsql2 {
+ SELECT 1 AS 'a','hello' AS 'b',2 AS 'c'
+ }
+} {a 1 b hello c 2}
+do_test select1-12.4 {
+ execsql {
+ DELETE FROM t3;
+ INSERT INTO t3 VALUES(1,2);
+ }
+} {}
+
+ifcapable compound {
+do_test select1-12.5 {
+ execsql {
+ SELECT * FROM t3 UNION SELECT 3 AS 'a', 4 ORDER BY a;
+ }
+} {1 2 3 4}
+
+do_test select1-12.6 {
+ execsql {
+ SELECT 3, 4 UNION SELECT * FROM t3;
+ }
+} {1 2 3 4}
+} ;# ifcapable compound
+
+ifcapable subquery {
+ do_test select1-12.7 {
+ execsql {
+ SELECT * FROM t3 WHERE a=(SELECT 1);
+ }
+ } {1 2}
+ do_test select1-12.8 {
+ execsql {
+ SELECT * FROM t3 WHERE a=(SELECT 2);
+ }
+ } {}
+}
+
+ifcapable {compound && subquery} {
+ do_test select1-12.9 {
+ execsql2 {
+ SELECT x FROM (
+ SELECT a AS x, b AS y FROM t3 UNION SELECT a,b FROM t4 ORDER BY a,b
+ ) ORDER BY x;
+ }
+ } {x 1 x 3}
+ do_test select1-12.10 {
+ execsql2 {
+ SELECT z.x FROM (
+ SELECT a AS x,b AS y FROM t3 UNION SELECT a, b FROM t4 ORDER BY a,b
+ ) AS 'z' ORDER BY x;
+ }
+ } {x 1 x 3}
+} ;# ifcapable compound
+
+
+# Check for a VDBE stack growth problem that existed at one point.
+#
+ifcapable subquery {
+ do_test select1-13.1 {
+ execsql {
+ BEGIN;
+ create TABLE abc(a, b, c, PRIMARY KEY(a, b));
+ INSERT INTO abc VALUES(1, 1, 1);
+ }
+ for {set i 0} {$i<10} {incr i} {
+ execsql {
+ INSERT INTO abc SELECT a+(select max(a) FROM abc),
+ b+(select max(a) FROM abc), c+(select max(a) FROM abc) FROM abc;
+ }
+ }
+ execsql {COMMIT}
+
+ # This used to seg-fault when the problem existed.
+ execsql {
+ SELECT count(
+ (SELECT a FROM abc WHERE a = NULL AND b >= upper.c)
+ ) FROM abc AS upper;
+ }
+ } {0}
+}
+
+foreach tab [db eval {SELECT name FROM sqlite_master WHERE type = 'table'}] {
+ db eval "DROP TABLE $tab"
+}
+db close
+sqlite3 db test.db
+
+do_test select1-14.1 {
+ execsql {
+ SELECT * FROM sqlite_master WHERE rowid>10;
+ SELECT * FROM sqlite_master WHERE rowid=10;
+ SELECT * FROM sqlite_master WHERE rowid<10;
+ SELECT * FROM sqlite_master WHERE rowid<=10;
+ SELECT * FROM sqlite_master WHERE rowid>=10;
+ SELECT * FROM sqlite_master;
+ }
+} {}
+do_test select1-14.2 {
+ execsql {
+ SELECT 10 IN (SELECT rowid FROM sqlite_master);
+ }
+} {0}
+
+if {[db one {PRAGMA locking_mode}]=="normal"} {
+ # Check that ticket #3771 has been fixed. This test does not
+ # work with locking_mode=EXCLUSIVE so disable in that case.
+ #
+ do_test select1-15.1 {
+ execsql {
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ }
+ } {}
+ do_test select1-15.2 {
+ sqlite3 db2 test.db
+ execsql { DROP INDEX i1 } db2
+ db2 close
+ } {}
+ do_test select1-15.3 {
+ execsql { SELECT 2 IN (SELECT a FROM t1) }
+ } {1}
+}
+
+finish_test
diff --git a/test/select2.test b/test/select2.test
new file mode 100644
index 0000000..35f8dd5
--- /dev/null
+++ b/test/select2.test
@@ -0,0 +1,185 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the SELECT statement.
+#
+# $Id: select2.test,v 1.28 2009/01/15 15:23:59 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table with some data
+#
+execsql {CREATE TABLE tbl1(f1 int, f2 int)}
+execsql {BEGIN}
+for {set i 0} {$i<=30} {incr i} {
+ execsql "INSERT INTO tbl1 VALUES([expr {$i%9}],[expr {$i%10}])"
+}
+execsql {COMMIT}
+
+# Do a second query inside a first.
+#
+do_test select2-1.1 {
+ set sql {SELECT DISTINCT f1 FROM tbl1 ORDER BY f1}
+ set r {}
+ catch {unset data}
+ db eval $sql data {
+ set f1 $data(f1)
+ lappend r $f1:
+ set sql2 "SELECT f2 FROM tbl1 WHERE f1=$f1 ORDER BY f2"
+ db eval $sql2 d2 {
+ lappend r $d2(f2)
+ }
+ }
+ set r
+} {0: 0 7 8 9 1: 0 1 8 9 2: 0 1 2 9 3: 0 1 2 3 4: 2 3 4 5: 3 4 5 6: 4 5 6 7: 5 6 7 8: 6 7 8}
+
+do_test select2-1.2 {
+ set sql {SELECT DISTINCT f1 FROM tbl1 WHERE f1>3 AND f1<5}
+ set r {}
+ db eval $sql data {
+ set f1 $data(f1)
+ lappend r $f1:
+ set sql2 "SELECT f2 FROM tbl1 WHERE f1=$f1 ORDER BY f2"
+ db eval $sql2 d2 {
+ lappend r $d2(f2)
+ }
+ }
+ set r
+} {4: 2 3 4}
+unset data
+
+# Create a largish table. Do this twice, once using the TCL cache and once
+# without. Compare the performance to make sure things go faster with the
+# cache turned on.
+#
+ifcapable tclvar {
+ do_test select2-2.0.1 {
+ set t1 [time {
+ execsql {CREATE TABLE tbl2(f1 int, f2 int, f3 int); BEGIN;}
+ for {set i 1} {$i<=30000} {incr i} {
+ set i2 [expr {$i*2}]
+ set i3 [expr {$i*3}]
+ db eval {INSERT INTO tbl2 VALUES($i,$i2,$i3)}
+ }
+ execsql {COMMIT}
+ }]
+ list
+ } {}
+ puts "time with cache: $::t1"
+}
+catch {execsql {DROP TABLE tbl2}}
+do_test select2-2.0.2 {
+ set t2 [time {
+ execsql {CREATE TABLE tbl2(f1 int, f2 int, f3 int); BEGIN;}
+ for {set i 1} {$i<=30000} {incr i} {
+ set i2 [expr {$i*2}]
+ set i3 [expr {$i*3}]
+ execsql "INSERT INTO tbl2 VALUES($i,$i2,$i3)"
+ }
+ execsql {COMMIT}
+ }]
+ list
+} {}
+puts "time without cache: $t2"
+#ifcapable tclvar {
+# do_test select2-2.0.3 {
+# expr {[lindex $t1 0]<[lindex $t2 0]}
+# } 1
+#}
+
+do_test select2-2.1 {
+ execsql {SELECT count(*) FROM tbl2}
+} {30000}
+do_test select2-2.2 {
+ execsql {SELECT count(*) FROM tbl2 WHERE f2>1000}
+} {29500}
+
+do_test select2-3.1 {
+ execsql {SELECT f1 FROM tbl2 WHERE 1000=f2}
+} {500}
+
+do_test select2-3.2a {
+ execsql {CREATE INDEX idx1 ON tbl2(f2)}
+} {}
+do_test select2-3.2b {
+ execsql {SELECT f1 FROM tbl2 WHERE 1000=f2}
+} {500}
+do_test select2-3.2c {
+ execsql {SELECT f1 FROM tbl2 WHERE f2=1000}
+} {500}
+do_test select2-3.2d {
+ set sqlite_search_count 0
+ execsql {SELECT * FROM tbl2 WHERE 1000=f2}
+ set sqlite_search_count
+} {3}
+do_test select2-3.2e {
+ set sqlite_search_count 0
+ execsql {SELECT * FROM tbl2 WHERE f2=1000}
+ set sqlite_search_count
+} {3}
+
+# Make sure queries run faster with an index than without
+#
+do_test select2-3.3 {
+ execsql {DROP INDEX idx1}
+ set sqlite_search_count 0
+ execsql {SELECT f1 FROM tbl2 WHERE f2==2000}
+ set sqlite_search_count
+} {29999}
+
+# Make sure we can optimize functions in the WHERE clause that
+# use fields from two or more different table. (Bug #6)
+#
+do_test select2-4.1 {
+ execsql {
+ CREATE TABLE aa(a);
+ CREATE TABLE bb(b);
+ INSERT INTO aa VALUES(1);
+ INSERT INTO aa VALUES(3);
+ INSERT INTO bb VALUES(2);
+ INSERT INTO bb VALUES(4);
+ SELECT * FROM aa, bb WHERE max(a,b)>2;
+ }
+} {1 4 3 2 3 4}
+do_test select2-4.2 {
+ execsql {
+ INSERT INTO bb VALUES(0);
+ SELECT * FROM aa CROSS JOIN bb WHERE b;
+ }
+} {1 2 1 4 3 2 3 4}
+do_test select2-4.3 {
+ execsql {
+ SELECT * FROM aa CROSS JOIN bb WHERE NOT b;
+ }
+} {1 0 3 0}
+do_test select2-4.4 {
+ execsql {
+ SELECT * FROM aa, bb WHERE min(a,b);
+ }
+} {1 2 1 4 3 2 3 4}
+do_test select2-4.5 {
+ execsql {
+ SELECT * FROM aa, bb WHERE NOT min(a,b);
+ }
+} {1 0 3 0}
+do_test select2-4.6 {
+ execsql {
+ SELECT * FROM aa, bb WHERE CASE WHEN a=b-1 THEN 1 END;
+ }
+} {1 2 3 4}
+do_test select2-4.7 {
+ execsql {
+ SELECT * FROM aa, bb WHERE CASE WHEN a=b-1 THEN 0 ELSE 1 END;
+ }
+} {1 4 1 0 3 2 3 0}
+
+finish_test
diff --git a/test/select3.test b/test/select3.test
new file mode 100644
index 0000000..b5dbef5
--- /dev/null
+++ b/test/select3.test
@@ -0,0 +1,264 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing aggregate functions and the
+# GROUP BY and HAVING clauses of SELECT statements.
+#
+# $Id: select3.test,v 1.23 2008/01/16 18:20:42 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+do_test select3-1.0 {
+ execsql {
+ CREATE TABLE t1(n int, log int);
+ BEGIN;
+ }
+ for {set i 1} {$i<32} {incr i} {
+ for {set j 0} {(1<<$j)<$i} {incr j} {}
+ execsql "INSERT INTO t1 VALUES($i,$j)"
+ }
+ execsql {
+ COMMIT
+ }
+ execsql {SELECT DISTINCT log FROM t1 ORDER BY log}
+} {0 1 2 3 4 5}
+
+# Basic aggregate functions.
+#
+do_test select3-1.1 {
+ execsql {SELECT count(*) FROM t1}
+} {31}
+do_test select3-1.2 {
+ execsql {
+ SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log)
+ FROM t1
+ }
+} {1 0 31 5 496 124 16.0 4.0}
+do_test select3-1.3 {
+ execsql {SELECT max(n)/avg(n), max(log)/avg(log) FROM t1}
+} {1.9375 1.25}
+
+# Try some basic GROUP BY clauses
+#
+do_test select3-2.1 {
+ execsql {SELECT log, count(*) FROM t1 GROUP BY log ORDER BY log}
+} {0 1 1 1 2 2 3 4 4 8 5 15}
+do_test select3-2.2 {
+ execsql {SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log}
+} {0 1 1 2 2 3 3 5 4 9 5 17}
+do_test select3-2.3.1 {
+ execsql {SELECT log, avg(n) FROM t1 GROUP BY log ORDER BY log}
+} {0 1.0 1 2.0 2 3.5 3 6.5 4 12.5 5 24.0}
+do_test select3-2.3.2 {
+ execsql {SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log}
+} {0 2.0 1 3.0 2 4.5 3 7.5 4 13.5 5 25.0}
+do_test select3-2.4 {
+ execsql {SELECT log, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log}
+} {0 0.0 1 0.0 2 0.5 3 1.5 4 3.5 5 7.0}
+do_test select3-2.5 {
+ execsql {SELECT log*2+1, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log}
+} {1 0.0 3 0.0 5 0.5 7 1.5 9 3.5 11 7.0}
+do_test select3-2.6 {
+ execsql {
+ SELECT log*2+1 as x, count(*) FROM t1 GROUP BY x ORDER BY x
+ }
+} {1 1 3 1 5 2 7 4 9 8 11 15}
+do_test select3-2.7 {
+ execsql {
+ SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY y, x
+ }
+} {1 1 3 1 5 2 7 4 9 8 11 15}
+do_test select3-2.8 {
+ execsql {
+ SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y)
+ }
+} {11 15 9 8 7 4 5 2 3 1 1 1}
+#do_test select3-2.9 {
+# catchsql {
+# SELECT log, count(*) FROM t1 GROUP BY 'x' ORDER BY log;
+# }
+#} {1 {GROUP BY terms must not be non-integer constants}}
+do_test select3-2.10 {
+ catchsql {
+ SELECT log, count(*) FROM t1 GROUP BY 0 ORDER BY log;
+ }
+} {1 {1st GROUP BY term out of range - should be between 1 and 2}}
+do_test select3-2.11 {
+ catchsql {
+ SELECT log, count(*) FROM t1 GROUP BY 3 ORDER BY log;
+ }
+} {1 {1st GROUP BY term out of range - should be between 1 and 2}}
+do_test select3-2.12 {
+ catchsql {
+ SELECT log, count(*) FROM t1 GROUP BY 1 ORDER BY log;
+ }
+} {0 {0 1 1 1 2 2 3 4 4 8 5 15}}
+
+# Cannot have an empty GROUP BY
+do_test select3-2.13 {
+ catchsql {
+ SELECT log, count(*) FROM t1 GROUP BY ORDER BY log;
+ }
+} {1 {near "ORDER": syntax error}}
+do_test select3-2.14 {
+ catchsql {
+ SELECT log, count(*) FROM t1 GROUP BY;
+ }
+} {1 {near ";": syntax error}}
+
+# Cannot have a HAVING without a GROUP BY
+#
+do_test select3-3.1 {
+ set v [catch {execsql {SELECT log, count(*) FROM t1 HAVING log>=4}} msg]
+ lappend v $msg
+} {1 {a GROUP BY clause is required before HAVING}}
+
+# Toss in some HAVING clauses
+#
+do_test select3-4.1 {
+ execsql {SELECT log, count(*) FROM t1 GROUP BY log HAVING log>=4 ORDER BY log}
+} {4 8 5 15}
+do_test select3-4.2 {
+ execsql {
+ SELECT log, count(*) FROM t1
+ GROUP BY log
+ HAVING count(*)>=4
+ ORDER BY log
+ }
+} {3 4 4 8 5 15}
+do_test select3-4.3 {
+ execsql {
+ SELECT log, count(*) FROM t1
+ GROUP BY log
+ HAVING count(*)>=4
+ ORDER BY max(n)+0
+ }
+} {3 4 4 8 5 15}
+do_test select3-4.4 {
+ execsql {
+ SELECT log AS x, count(*) AS y FROM t1
+ GROUP BY x
+ HAVING y>=4
+ ORDER BY max(n)+0
+ }
+} {3 4 4 8 5 15}
+do_test select3-4.5 {
+ execsql {
+ SELECT log AS x FROM t1
+ GROUP BY x
+ HAVING count(*)>=4
+ ORDER BY max(n)+0
+ }
+} {3 4 5}
+
+do_test select3-5.1 {
+ execsql {
+ SELECT log, count(*), avg(n), max(n+log*2) FROM t1
+ GROUP BY log
+ ORDER BY max(n+log*2)+0, avg(n)+0
+ }
+} {0 1 1.0 1 1 1 2.0 4 2 2 3.5 8 3 4 6.5 14 4 8 12.5 24 5 15 24.0 41}
+do_test select3-5.2 {
+ execsql {
+ SELECT log, count(*), avg(n), max(n+log*2) FROM t1
+ GROUP BY log
+ ORDER BY max(n+log*2)+0, min(log,avg(n))+0
+ }
+} {0 1 1.0 1 1 1 2.0 4 2 2 3.5 8 3 4 6.5 14 4 8 12.5 24 5 15 24.0 41}
+
+# Test sorting of GROUP BY results in the presence of an index
+# on the GROUP BY column.
+#
+do_test select3-6.1 {
+ execsql {
+ SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log;
+ }
+} {0 1 1 2 2 3 3 5 4 9 5 17}
+do_test select3-6.2 {
+ execsql {
+ SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log DESC;
+ }
+} {5 17 4 9 3 5 2 3 1 2 0 1}
+do_test select3-6.3 {
+ execsql {
+ SELECT log, min(n) FROM t1 GROUP BY log ORDER BY 1;
+ }
+} {0 1 1 2 2 3 3 5 4 9 5 17}
+do_test select3-6.4 {
+ execsql {
+ SELECT log, min(n) FROM t1 GROUP BY log ORDER BY 1 DESC;
+ }
+} {5 17 4 9 3 5 2 3 1 2 0 1}
+do_test select3-6.5 {
+ execsql {
+ CREATE INDEX i1 ON t1(log);
+ SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log;
+ }
+} {0 1 1 2 2 3 3 5 4 9 5 17}
+do_test select3-6.6 {
+ execsql {
+ SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log DESC;
+ }
+} {5 17 4 9 3 5 2 3 1 2 0 1}
+do_test select3-6.7 {
+ execsql {
+ SELECT log, min(n) FROM t1 GROUP BY log ORDER BY 1;
+ }
+} {0 1 1 2 2 3 3 5 4 9 5 17}
+do_test select3-6.8 {
+ execsql {
+ SELECT log, min(n) FROM t1 GROUP BY log ORDER BY 1 DESC;
+ }
+} {5 17 4 9 3 5 2 3 1 2 0 1}
+
+# Sometimes an aggregate query can return no rows at all.
+#
+do_test select3-7.1 {
+ execsql {
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2 VALUES(1,2);
+ SELECT a, sum(b) FROM t2 WHERE b=5 GROUP BY a;
+ }
+} {}
+do_test select3-7.2 {
+ execsql {
+ SELECT a, sum(b) FROM t2 WHERE b=5;
+ }
+} {{} {}}
+
+# If a table column is of type REAL but we are storing integer values
+# in it, the values are stored as integers to take up less space. The
+# values are converted by to REAL as they are read out of the table.
+# Make sure the GROUP BY clause does this conversion correctly.
+# Ticket #2251.
+#
+do_test select3-8.1 {
+ execsql {
+ CREATE TABLE A (
+ A1 DOUBLE,
+ A2 VARCHAR COLLATE NOCASE,
+ A3 DOUBLE
+ );
+ INSERT INTO A VALUES(39136,'ABC',1201900000);
+ INSERT INTO A VALUES(39136,'ABC',1207000000);
+ SELECT typeof(sum(a3)) FROM a;
+ }
+} {real}
+do_test select3-8.2 {
+ execsql {
+ SELECT typeof(sum(a3)) FROM a GROUP BY a1;
+ }
+} {real}
+
+finish_test
diff --git a/test/select4.test b/test/select4.test
new file mode 100644
index 0000000..dff0b90
--- /dev/null
+++ b/test/select4.test
@@ -0,0 +1,808 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing UNION, INTERSECT and EXCEPT operators
+# in SELECT statements.
+#
+# $Id: select4.test,v 1.30 2009/04/16 00:24:24 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Most tests in this file depend on compound-select. But there are a couple
+# right at the end that test DISTINCT, so we cannot omit the entire file.
+#
+ifcapable compound {
+
+# Build some test data
+#
+execsql {
+ CREATE TABLE t1(n int, log int);
+ BEGIN;
+}
+for {set i 1} {$i<32} {incr i} {
+ for {set j 0} {(1<<$j)<$i} {incr j} {}
+ execsql "INSERT INTO t1 VALUES($i,$j)"
+}
+execsql {
+ COMMIT;
+}
+
+do_test select4-1.0 {
+ execsql {SELECT DISTINCT log FROM t1 ORDER BY log}
+} {0 1 2 3 4 5}
+
+# Union All operator
+#
+do_test select4-1.1a {
+ lsort [execsql {SELECT DISTINCT log FROM t1}]
+} {0 1 2 3 4 5}
+do_test select4-1.1b {
+ lsort [execsql {SELECT n FROM t1 WHERE log=3}]
+} {5 6 7 8}
+do_test select4-1.1c {
+ execsql {
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }
+} {0 1 2 3 4 5 5 6 7 8}
+do_test select4-1.1d {
+ execsql {
+ CREATE TABLE t2 AS
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ SELECT * FROM t2;
+ }
+} {0 1 2 3 4 5 5 6 7 8}
+execsql {DROP TABLE t2}
+do_test select4-1.1e {
+ execsql {
+ CREATE TABLE t2 AS
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log DESC;
+ SELECT * FROM t2;
+ }
+} {8 7 6 5 5 4 3 2 1 0}
+execsql {DROP TABLE t2}
+do_test select4-1.1f {
+ execsql {
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=2
+ }
+} {0 1 2 3 4 5 3 4}
+do_test select4-1.1g {
+ execsql {
+ CREATE TABLE t2 AS
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=2;
+ SELECT * FROM t2;
+ }
+} {0 1 2 3 4 5 3 4}
+execsql {DROP TABLE t2}
+ifcapable subquery {
+ do_test select4-1.2 {
+ execsql {
+ SELECT log FROM t1 WHERE n IN
+ (SELECT DISTINCT log FROM t1 UNION ALL
+ SELECT n FROM t1 WHERE log=3)
+ ORDER BY log;
+ }
+ } {0 1 2 2 3 3 3 3}
+}
+do_test select4-1.3 {
+ set v [catch {execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }} msg]
+ lappend v $msg
+} {1 {ORDER BY clause should come after UNION ALL not before}}
+
+# Union operator
+#
+do_test select4-2.1 {
+ execsql {
+ SELECT DISTINCT log FROM t1
+ UNION
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }
+} {0 1 2 3 4 5 6 7 8}
+ifcapable subquery {
+ do_test select4-2.2 {
+ execsql {
+ SELECT log FROM t1 WHERE n IN
+ (SELECT DISTINCT log FROM t1 UNION
+ SELECT n FROM t1 WHERE log=3)
+ ORDER BY log;
+ }
+ } {0 1 2 2 3 3 3 3}
+}
+do_test select4-2.3 {
+ set v [catch {execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log
+ UNION
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }} msg]
+ lappend v $msg
+} {1 {ORDER BY clause should come after UNION not before}}
+
+# Except operator
+#
+do_test select4-3.1.1 {
+ execsql {
+ SELECT DISTINCT log FROM t1
+ EXCEPT
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }
+} {0 1 2 3 4}
+do_test select4-3.1.2 {
+ execsql {
+ CREATE TABLE t2 AS
+ SELECT DISTINCT log FROM t1
+ EXCEPT
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ SELECT * FROM t2;
+ }
+} {0 1 2 3 4}
+execsql {DROP TABLE t2}
+do_test select4-3.1.3 {
+ execsql {
+ CREATE TABLE t2 AS
+ SELECT DISTINCT log FROM t1
+ EXCEPT
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log DESC;
+ SELECT * FROM t2;
+ }
+} {4 3 2 1 0}
+execsql {DROP TABLE t2}
+ifcapable subquery {
+ do_test select4-3.2 {
+ execsql {
+ SELECT log FROM t1 WHERE n IN
+ (SELECT DISTINCT log FROM t1 EXCEPT
+ SELECT n FROM t1 WHERE log=3)
+ ORDER BY log;
+ }
+ } {0 1 2 2}
+}
+do_test select4-3.3 {
+ set v [catch {execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log
+ EXCEPT
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }} msg]
+ lappend v $msg
+} {1 {ORDER BY clause should come after EXCEPT not before}}
+
+# Intersect operator
+#
+do_test select4-4.1.1 {
+ execsql {
+ SELECT DISTINCT log FROM t1
+ INTERSECT
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }
+} {5}
+
+do_test select4-4.1.2 {
+ execsql {
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT 6
+ INTERSECT
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY t1.log;
+ }
+} {5 6}
+
+do_test select4-4.1.3 {
+ execsql {
+ CREATE TABLE t2 AS
+ SELECT DISTINCT log FROM t1 UNION ALL SELECT 6
+ INTERSECT
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ SELECT * FROM t2;
+ }
+} {5 6}
+execsql {DROP TABLE t2}
+do_test select4-4.1.4 {
+ execsql {
+ CREATE TABLE t2 AS
+ SELECT DISTINCT log FROM t1 UNION ALL SELECT 6
+ INTERSECT
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log DESC;
+ SELECT * FROM t2;
+ }
+} {6 5}
+execsql {DROP TABLE t2}
+ifcapable subquery {
+ do_test select4-4.2 {
+ execsql {
+ SELECT log FROM t1 WHERE n IN
+ (SELECT DISTINCT log FROM t1 INTERSECT
+ SELECT n FROM t1 WHERE log=3)
+ ORDER BY log;
+ }
+ } {3}
+}
+do_test select4-4.3 {
+ set v [catch {execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log
+ INTERSECT
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }} msg]
+ lappend v $msg
+} {1 {ORDER BY clause should come after INTERSECT not before}}
+
+# Various error messages while processing UNION or INTERSECT
+#
+do_test select4-5.1 {
+ set v [catch {execsql {
+ SELECT DISTINCT log FROM t2
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }} msg]
+ lappend v $msg
+} {1 {no such table: t2}}
+do_test select4-5.2 {
+ set v [catch {execsql {
+ SELECT DISTINCT log AS "xyzzy" FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY xyzzy;
+ }} msg]
+ lappend v $msg
+} {0 {0 1 2 3 4 5 5 6 7 8}}
+do_test select4-5.2b {
+ set v [catch {execsql {
+ SELECT DISTINCT log AS xyzzy FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY "xyzzy";
+ }} msg]
+ lappend v $msg
+} {0 {0 1 2 3 4 5 5 6 7 8}}
+do_test select4-5.2c {
+ set v [catch {execsql {
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY "xyzzy";
+ }} msg]
+ lappend v $msg
+} {1 {1st ORDER BY term does not match any column in the result set}}
+do_test select4-5.2d {
+ set v [catch {execsql {
+ SELECT DISTINCT log FROM t1
+ INTERSECT
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY "xyzzy";
+ }} msg]
+ lappend v $msg
+} {1 {1st ORDER BY term does not match any column in the result set}}
+do_test select4-5.2e {
+ set v [catch {execsql {
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY n;
+ }} msg]
+ lappend v $msg
+} {0 {0 1 2 3 4 5 5 6 7 8}}
+do_test select4-5.2f {
+ catchsql {
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }
+} {0 {0 1 2 3 4 5 5 6 7 8}}
+do_test select4-5.2g {
+ catchsql {
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY 1;
+ }
+} {0 {0 1 2 3 4 5 5 6 7 8}}
+do_test select4-5.2h {
+ catchsql {
+ SELECT DISTINCT log FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY 2;
+ }
+} {1 {1st ORDER BY term out of range - should be between 1 and 1}}
+do_test select4-5.2i {
+ catchsql {
+ SELECT DISTINCT 1, log FROM t1
+ UNION ALL
+ SELECT 2, n FROM t1 WHERE log=3
+ ORDER BY 2, 1;
+ }
+} {0 {1 0 1 1 1 2 1 3 1 4 1 5 2 5 2 6 2 7 2 8}}
+do_test select4-5.2j {
+ catchsql {
+ SELECT DISTINCT 1, log FROM t1
+ UNION ALL
+ SELECT 2, n FROM t1 WHERE log=3
+ ORDER BY 1, 2 DESC;
+ }
+} {0 {1 5 1 4 1 3 1 2 1 1 1 0 2 8 2 7 2 6 2 5}}
+do_test select4-5.2k {
+ catchsql {
+ SELECT DISTINCT 1, log FROM t1
+ UNION ALL
+ SELECT 2, n FROM t1 WHERE log=3
+ ORDER BY n, 1;
+ }
+} {0 {1 0 1 1 1 2 1 3 1 4 1 5 2 5 2 6 2 7 2 8}}
+do_test select4-5.3 {
+ set v [catch {execsql {
+ SELECT DISTINCT log, n FROM t1
+ UNION ALL
+ SELECT n FROM t1 WHERE log=3
+ ORDER BY log;
+ }} msg]
+ lappend v $msg
+} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}
+do_test select4-5.3-3807-1 {
+ catchsql {
+ SELECT 1 UNION SELECT 2, 3 UNION SELECT 4, 5 ORDER BY 1;
+ }
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+do_test select4-5.4 {
+ set v [catch {execsql {
+ SELECT log FROM t1 WHERE n=2
+ UNION ALL
+ SELECT log FROM t1 WHERE n=3
+ UNION ALL
+ SELECT log FROM t1 WHERE n=4
+ UNION ALL
+ SELECT log FROM t1 WHERE n=5
+ ORDER BY log;
+ }} msg]
+ lappend v $msg
+} {0 {1 2 2 3}}
+
+do_test select4-6.1 {
+ execsql {
+ SELECT log, count(*) as cnt FROM t1 GROUP BY log
+ UNION
+ SELECT log, n FROM t1 WHERE n=7
+ ORDER BY cnt, log;
+ }
+} {0 1 1 1 2 2 3 4 3 7 4 8 5 15}
+do_test select4-6.2 {
+ execsql {
+ SELECT log, count(*) FROM t1 GROUP BY log
+ UNION
+ SELECT log, n FROM t1 WHERE n=7
+ ORDER BY count(*), log;
+ }
+} {0 1 1 1 2 2 3 4 3 7 4 8 5 15}
+
+# NULLs are indistinct for the UNION operator.
+# Make sure the UNION operator recognizes this
+#
+do_test select4-6.3 {
+ execsql {
+ SELECT NULL UNION SELECT NULL UNION
+ SELECT 1 UNION SELECT 2 AS 'x'
+ ORDER BY x;
+ }
+} {{} 1 2}
+do_test select4-6.3.1 {
+ execsql {
+ SELECT NULL UNION ALL SELECT NULL UNION ALL
+ SELECT 1 UNION ALL SELECT 2 AS 'x'
+ ORDER BY x;
+ }
+} {{} {} 1 2}
+
+# Make sure the DISTINCT keyword treats NULLs as indistinct.
+#
+ifcapable subquery {
+ do_test select4-6.4 {
+ execsql {
+ SELECT * FROM (
+ SELECT NULL, 1 UNION ALL SELECT NULL, 1
+ );
+ }
+ } {{} 1 {} 1}
+ do_test select4-6.5 {
+ execsql {
+ SELECT DISTINCT * FROM (
+ SELECT NULL, 1 UNION ALL SELECT NULL, 1
+ );
+ }
+ } {{} 1}
+ do_test select4-6.6 {
+ execsql {
+ SELECT DISTINCT * FROM (
+ SELECT 1,2 UNION ALL SELECT 1,2
+ );
+ }
+ } {1 2}
+}
+
+# Test distinctness of NULL in other ways.
+#
+do_test select4-6.7 {
+ execsql {
+ SELECT NULL EXCEPT SELECT NULL
+ }
+} {}
+
+
+# Make sure column names are correct when a compound select appears as
+# an expression in the WHERE clause.
+#
+do_test select4-7.1 {
+ execsql {
+ CREATE TABLE t2 AS SELECT log AS 'x', count(*) AS 'y' FROM t1 GROUP BY log;
+ SELECT * FROM t2 ORDER BY x;
+ }
+} {0 1 1 1 2 2 3 4 4 8 5 15}
+ifcapable subquery {
+ do_test select4-7.2 {
+ execsql2 {
+ SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 INTERSECT SELECT x FROM t2)
+ ORDER BY n
+ }
+ } {n 1 log 0 n 2 log 1 n 3 log 2 n 4 log 2 n 5 log 3}
+ do_test select4-7.3 {
+ execsql2 {
+ SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 EXCEPT SELECT x FROM t2)
+ ORDER BY n LIMIT 2
+ }
+ } {n 6 log 3 n 7 log 3}
+ do_test select4-7.4 {
+ execsql2 {
+ SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 UNION SELECT x FROM t2)
+ ORDER BY n LIMIT 2
+ }
+ } {n 1 log 0 n 2 log 1}
+} ;# ifcapable subquery
+
+} ;# ifcapable compound
+
+# Make sure DISTINCT works appropriately on TEXT and NUMERIC columns.
+do_test select4-8.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(a text, b float, c text);
+ INSERT INTO t3 VALUES(1, 1.1, '1.1');
+ INSERT INTO t3 VALUES(2, 1.10, '1.10');
+ INSERT INTO t3 VALUES(3, 1.10, '1.1');
+ INSERT INTO t3 VALUES(4, 1.1, '1.10');
+ INSERT INTO t3 VALUES(5, 1.2, '1.2');
+ INSERT INTO t3 VALUES(6, 1.3, '1.3');
+ COMMIT;
+ }
+ execsql {
+ SELECT DISTINCT b FROM t3 ORDER BY c;
+ }
+} {1.1 1.2 1.3}
+do_test select4-8.2 {
+ execsql {
+ SELECT DISTINCT c FROM t3 ORDER BY c;
+ }
+} {1.1 1.10 1.2 1.3}
+
+# Make sure the names of columns are taken from the right-most subquery
+# right in a compound query. Ticket #1721
+#
+ifcapable compound {
+
+do_test select4-9.1 {
+ execsql2 {
+ SELECT x, y FROM t2 UNION SELECT a, b FROM t3 ORDER BY x LIMIT 1
+ }
+} {x 0 y 1}
+do_test select4-9.2 {
+ execsql2 {
+ SELECT x, y FROM t2 UNION ALL SELECT a, b FROM t3 ORDER BY x LIMIT 1
+ }
+} {x 0 y 1}
+do_test select4-9.3 {
+ execsql2 {
+ SELECT x, y FROM t2 EXCEPT SELECT a, b FROM t3 ORDER BY x LIMIT 1
+ }
+} {x 0 y 1}
+do_test select4-9.4 {
+ execsql2 {
+ SELECT x, y FROM t2 INTERSECT SELECT 0 AS a, 1 AS b;
+ }
+} {x 0 y 1}
+do_test select4-9.5 {
+ execsql2 {
+ SELECT 0 AS x, 1 AS y
+ UNION
+ SELECT 2 AS p, 3 AS q
+ UNION
+ SELECT 4 AS a, 5 AS b
+ ORDER BY x LIMIT 1
+ }
+} {x 0 y 1}
+
+ifcapable subquery {
+do_test select4-9.6 {
+ execsql2 {
+ SELECT * FROM (
+ SELECT 0 AS x, 1 AS y
+ UNION
+ SELECT 2 AS p, 3 AS q
+ UNION
+ SELECT 4 AS a, 5 AS b
+ ) ORDER BY 1 LIMIT 1;
+ }
+} {x 0 y 1}
+do_test select4-9.7 {
+ execsql2 {
+ SELECT * FROM (
+ SELECT 0 AS x, 1 AS y
+ UNION
+ SELECT 2 AS p, 3 AS q
+ UNION
+ SELECT 4 AS a, 5 AS b
+ ) ORDER BY x LIMIT 1;
+ }
+} {x 0 y 1}
+} ;# ifcapable subquery
+
+do_test select4-9.8 {
+ execsql {
+ SELECT 0 AS x, 1 AS y
+ UNION
+ SELECT 2 AS y, -3 AS x
+ ORDER BY x LIMIT 1;
+ }
+} {0 1}
+
+do_test select4-9.9.1 {
+ execsql2 {
+ SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS b, 4 AS a
+ }
+} {a 1 b 2 a 3 b 4}
+
+ifcapable subquery {
+do_test select4-9.9.2 {
+ execsql2 {
+ SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS b, 4 AS a)
+ WHERE b=3
+ }
+} {}
+do_test select4-9.10 {
+ execsql2 {
+ SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS b, 4 AS a)
+ WHERE b=2
+ }
+} {a 1 b 2}
+do_test select4-9.11 {
+ execsql2 {
+ SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS e, 4 AS b)
+ WHERE b=2
+ }
+} {a 1 b 2}
+do_test select4-9.12 {
+ execsql2 {
+ SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS e, 4 AS b)
+ WHERE b>0
+ }
+} {a 1 b 2 a 3 b 4}
+} ;# ifcapable subquery
+
+# Try combining DISTINCT, LIMIT, and OFFSET. Make sure they all work
+# together.
+#
+do_test select4-10.1 {
+ execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log
+ }
+} {0 1 2 3 4 5}
+do_test select4-10.2 {
+ execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log LIMIT 4
+ }
+} {0 1 2 3}
+do_test select4-10.3 {
+ execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log LIMIT 0
+ }
+} {}
+do_test select4-10.4 {
+ execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log LIMIT -1
+ }
+} {0 1 2 3 4 5}
+do_test select4-10.5 {
+ execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log LIMIT -1 OFFSET 2
+ }
+} {2 3 4 5}
+do_test select4-10.6 {
+ execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log LIMIT 3 OFFSET 2
+ }
+} {2 3 4}
+do_test select4-10.7 {
+ execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY +log LIMIT 3 OFFSET 20
+ }
+} {}
+do_test select4-10.8 {
+ execsql {
+ SELECT DISTINCT log FROM t1 ORDER BY log LIMIT 0 OFFSET 3
+ }
+} {}
+do_test select4-10.9 {
+ execsql {
+ SELECT DISTINCT max(n), log FROM t1 ORDER BY +log; -- LIMIT 2 OFFSET 1
+ }
+} {31 5}
+
+# Make sure compound SELECTs with wildly different numbers of columns
+# do not cause assertion faults due to register allocation issues.
+#
+do_test select4-11.1 {
+ catchsql {
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ UNION
+ SELECT x FROM t2
+ }
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+do_test select4-11.2 {
+ catchsql {
+ SELECT x FROM t2
+ UNION
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ }
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+do_test select4-11.3 {
+ catchsql {
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ UNION ALL
+ SELECT x FROM t2
+ }
+} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}
+do_test select4-11.4 {
+ catchsql {
+ SELECT x FROM t2
+ UNION ALL
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ }
+} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}
+do_test select4-11.5 {
+ catchsql {
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ EXCEPT
+ SELECT x FROM t2
+ }
+} {1 {SELECTs to the left and right of EXCEPT do not have the same number of result columns}}
+do_test select4-11.6 {
+ catchsql {
+ SELECT x FROM t2
+ EXCEPT
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ }
+} {1 {SELECTs to the left and right of EXCEPT do not have the same number of result columns}}
+do_test select4-11.7 {
+ catchsql {
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ INTERSECT
+ SELECT x FROM t2
+ }
+} {1 {SELECTs to the left and right of INTERSECT do not have the same number of result columns}}
+do_test select4-11.8 {
+ catchsql {
+ SELECT x FROM t2
+ INTERSECT
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ }
+} {1 {SELECTs to the left and right of INTERSECT do not have the same number of result columns}}
+
+do_test select4-11.11 {
+ catchsql {
+ SELECT x FROM t2
+ UNION
+ SELECT x FROM t2
+ UNION ALL
+ SELECT x FROM t2
+ EXCEPT
+ SELECT x FROM t2
+ INTERSECT
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ }
+} {1 {SELECTs to the left and right of INTERSECT do not have the same number of result columns}}
+do_test select4-11.12 {
+ catchsql {
+ SELECT x FROM t2
+ UNION
+ SELECT x FROM t2
+ UNION ALL
+ SELECT x FROM t2
+ EXCEPT
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ EXCEPT
+ SELECT x FROM t2
+ }
+} {1 {SELECTs to the left and right of EXCEPT do not have the same number of result columns}}
+do_test select4-11.13 {
+ catchsql {
+ SELECT x FROM t2
+ UNION
+ SELECT x FROM t2
+ UNION ALL
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ UNION ALL
+ SELECT x FROM t2
+ EXCEPT
+ SELECT x FROM t2
+ }
+} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}
+do_test select4-11.14 {
+ catchsql {
+ SELECT x FROM t2
+ UNION
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ UNION
+ SELECT x FROM t2
+ UNION ALL
+ SELECT x FROM t2
+ EXCEPT
+ SELECT x FROM t2
+ }
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+do_test select4-11.15 {
+ catchsql {
+ SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2
+ UNION
+ SELECT x FROM t2
+ INTERSECT
+ SELECT x FROM t2
+ UNION ALL
+ SELECT x FROM t2
+ EXCEPT
+ SELECT x FROM t2
+ }
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+
+do_test select4-12.1 {
+ sqlite3 db2 :memory:
+ catchsql {
+ SELECT 1 UNION SELECT 2,3 UNION SELECT 4,5 ORDER BY 1;
+ } db2
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+
+} ;# ifcapable compound
+
+finish_test
diff --git a/test/select5.test b/test/select5.test
new file mode 100644
index 0000000..3a787fc
--- /dev/null
+++ b/test/select5.test
@@ -0,0 +1,257 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing aggregate functions and the
+# GROUP BY and HAVING clauses of SELECT statements.
+#
+# $Id: select5.test,v 1.20 2008/08/21 14:15:59 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+execsql {
+ CREATE TABLE t1(x int, y int);
+ BEGIN;
+}
+for {set i 1} {$i<32} {incr i} {
+ for {set j 0} {(1<<$j)<$i} {incr j} {}
+ execsql "INSERT INTO t1 VALUES([expr {32-$i}],[expr {10-$j}])"
+}
+execsql {
+ COMMIT
+}
+
+do_test select5-1.0 {
+ execsql {SELECT DISTINCT y FROM t1 ORDER BY y}
+} {5 6 7 8 9 10}
+
+# Sort by an aggregate function.
+#
+do_test select5-1.1 {
+ execsql {SELECT y, count(*) FROM t1 GROUP BY y ORDER BY y}
+} {5 15 6 8 7 4 8 2 9 1 10 1}
+do_test select5-1.2 {
+ execsql {SELECT y, count(*) FROM t1 GROUP BY y ORDER BY count(*), y}
+} {9 1 10 1 8 2 7 4 6 8 5 15}
+do_test select5-1.3 {
+ execsql {SELECT count(*), y FROM t1 GROUP BY y ORDER BY count(*), y}
+} {1 9 1 10 2 8 4 7 8 6 15 5}
+
+# Some error messages associated with aggregates and GROUP BY
+#
+do_test select5-2.1.1 {
+ catchsql {
+ SELECT y, count(*) FROM t1 GROUP BY z ORDER BY y
+ }
+} {1 {no such column: z}}
+do_test select5-2.1.2 {
+ catchsql {
+ SELECT y, count(*) FROM t1 GROUP BY temp.t1.y ORDER BY y
+ }
+} {1 {no such column: temp.t1.y}}
+do_test select5-2.2 {
+ set v [catch {execsql {
+ SELECT y, count(*) FROM t1 GROUP BY z(y) ORDER BY y
+ }} msg]
+ lappend v $msg
+} {1 {no such function: z}}
+do_test select5-2.3 {
+ set v [catch {execsql {
+ SELECT y, count(*) FROM t1 GROUP BY y HAVING count(*)<3 ORDER BY y
+ }} msg]
+ lappend v $msg
+} {0 {8 2 9 1 10 1}}
+do_test select5-2.4 {
+ set v [catch {execsql {
+ SELECT y, count(*) FROM t1 GROUP BY y HAVING z(y)<3 ORDER BY y
+ }} msg]
+ lappend v $msg
+} {1 {no such function: z}}
+do_test select5-2.5 {
+ set v [catch {execsql {
+ SELECT y, count(*) FROM t1 GROUP BY y HAVING count(*)<z ORDER BY y
+ }} msg]
+ lappend v $msg
+} {1 {no such column: z}}
+
+# Get the Agg function to rehash in vdbe.c
+#
+do_test select5-3.1 {
+ execsql {
+ SELECT x, count(*), avg(y) FROM t1 GROUP BY x HAVING x<4 ORDER BY x
+ }
+} {1 1 5.0 2 1 5.0 3 1 5.0}
+
+# Run various aggregate functions when the count is zero.
+#
+do_test select5-4.1 {
+ execsql {
+ SELECT avg(x) FROM t1 WHERE x>100
+ }
+} {{}}
+do_test select5-4.2 {
+ execsql {
+ SELECT count(x) FROM t1 WHERE x>100
+ }
+} {0}
+do_test select5-4.3 {
+ execsql {
+ SELECT min(x) FROM t1 WHERE x>100
+ }
+} {{}}
+do_test select5-4.4 {
+ execsql {
+ SELECT max(x) FROM t1 WHERE x>100
+ }
+} {{}}
+do_test select5-4.5 {
+ execsql {
+ SELECT sum(x) FROM t1 WHERE x>100
+ }
+} {{}}
+
+# Some tests for queries with a GROUP BY clause but no aggregate functions.
+#
+# Note: The query in test cases 5.1 through 5.5 are not legal SQL. So if the
+# implementation changes in the future and it returns different results,
+# this is not such a big deal.
+#
+do_test select5-5.1 {
+ execsql {
+ CREATE TABLE t2(a, b, c);
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(1, 4, 5);
+ INSERT INTO t2 VALUES(6, 4, 7);
+ CREATE INDEX t2_idx ON t2(a);
+ }
+} {}
+do_test select5-5.2 {
+ execsql {
+ SELECT a FROM t2 GROUP BY a;
+ }
+} {1 6}
+do_test select5-5.3 {
+ execsql {
+ SELECT a FROM t2 WHERE a>2 GROUP BY a;
+ }
+} {6}
+do_test select5-5.4 {
+ execsql {
+ SELECT a, b FROM t2 GROUP BY a, b;
+ }
+} {1 2 1 4 6 4}
+do_test select5-5.5 {
+ execsql {
+ SELECT a, b FROM t2 GROUP BY a;
+ }
+} {1 4 6 4}
+
+# Test rendering of columns for the GROUP BY clause.
+#
+do_test select5-5.11 {
+ execsql {
+ SELECT max(c), b*a, b, a FROM t2 GROUP BY b*a, b, a
+ }
+} {3 2 2 1 5 4 4 1 7 24 4 6}
+
+# NULL compare equal to each other for the purposes of processing
+# the GROUP BY clause.
+#
+do_test select5-6.1 {
+ execsql {
+ CREATE TABLE t3(x,y);
+ INSERT INTO t3 VALUES(1,NULL);
+ INSERT INTO t3 VALUES(2,NULL);
+ INSERT INTO t3 VALUES(3,4);
+ SELECT count(x), y FROM t3 GROUP BY y ORDER BY 1
+ }
+} {1 4 2 {}}
+do_test select5-6.2 {
+ execsql {
+ CREATE TABLE t4(x,y,z);
+ INSERT INTO t4 VALUES(1,2,NULL);
+ INSERT INTO t4 VALUES(2,3,NULL);
+ INSERT INTO t4 VALUES(3,NULL,5);
+ INSERT INTO t4 VALUES(4,NULL,6);
+ INSERT INTO t4 VALUES(4,NULL,6);
+ INSERT INTO t4 VALUES(5,NULL,NULL);
+ INSERT INTO t4 VALUES(5,NULL,NULL);
+ INSERT INTO t4 VALUES(6,7,8);
+ SELECT max(x), count(x), y, z FROM t4 GROUP BY y, z ORDER BY 1
+ }
+} {1 1 2 {} 2 1 3 {} 3 1 {} 5 4 2 {} 6 5 2 {} {} 6 1 7 8}
+
+do_test select5-7.2 {
+ execsql {
+ SELECT count(*), count(x) as cnt FROM t4 GROUP BY y ORDER BY cnt;
+ }
+} {1 1 1 1 1 1 5 5}
+
+# See ticket #3324.
+#
+do_test select5-8.1 {
+ execsql {
+ CREATE TABLE t8a(a,b);
+ CREATE TABLE t8b(x);
+ INSERT INTO t8a VALUES('one', 1);
+ INSERT INTO t8a VALUES('one', 2);
+ INSERT INTO t8a VALUES('two', 3);
+ INSERT INTO t8a VALUES('one', NULL);
+ INSERT INTO t8b(rowid,x) VALUES(1,111);
+ INSERT INTO t8b(rowid,x) VALUES(2,222);
+ INSERT INTO t8b(rowid,x) VALUES(3,333);
+ SELECT a, count(b) FROM t8a, t8b WHERE b=t8b.rowid GROUP BY a ORDER BY a;
+ }
+} {one 2 two 1}
+do_test select5-8.2 {
+ execsql {
+ SELECT a, count(b) FROM t8a, t8b WHERE b=+t8b.rowid GROUP BY a ORDER BY a;
+ }
+} {one 2 two 1}
+do_test select5-8.3 {
+ execsql {
+ SELECT t8a.a, count(t8a.b) FROM t8a, t8b WHERE t8a.b=t8b.rowid
+ GROUP BY 1 ORDER BY 1;
+ }
+} {one 2 two 1}
+do_test select5-8.4 {
+ execsql {
+ SELECT a, count(*) FROM t8a, t8b WHERE b=+t8b.rowid GROUP BY a ORDER BY a;
+ }
+} {one 2 two 1}
+do_test select5-8.5 {
+ execsql {
+ SELECT a, count(b) FROM t8a, t8b WHERE b<x GROUP BY a ORDER BY a;
+ }
+} {one 6 two 3}
+do_test select5-8.6 {
+ execsql {
+ SELECT a, count(t8a.b) FROM t8a, t8b WHERE b=t8b.rowid
+ GROUP BY a ORDER BY 2;
+ }
+} {two 1 one 2}
+do_test select5-8.7 {
+ execsql {
+ SELECT a, count(b) FROM t8a, t8b GROUP BY a ORDER BY 2;
+ }
+} {two 3 one 6}
+do_test select5-8.8 {
+ execsql {
+ SELECT a, count(*) FROM t8a, t8b GROUP BY a ORDER BY 2;
+ }
+} {two 3 one 9}
+
+
+
+
+finish_test
diff --git a/test/select6.test b/test/select6.test
new file mode 100644
index 0000000..e0ff165
--- /dev/null
+++ b/test/select6.test
@@ -0,0 +1,517 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing SELECT statements that contain
+# subqueries in their FROM clause.
+#
+# $Id: select6.test,v 1.29 2009/01/09 01:12:28 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Omit this whole file if the library is build without subquery support.
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+do_test select6-1.0 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1,1);
+ INSERT INTO t1 VALUES(2,2);
+ INSERT INTO t1 VALUES(3,2);
+ INSERT INTO t1 VALUES(4,3);
+ INSERT INTO t1 VALUES(5,3);
+ INSERT INTO t1 VALUES(6,3);
+ INSERT INTO t1 VALUES(7,3);
+ INSERT INTO t1 VALUES(8,4);
+ INSERT INTO t1 VALUES(9,4);
+ INSERT INTO t1 VALUES(10,4);
+ INSERT INTO t1 VALUES(11,4);
+ INSERT INTO t1 VALUES(12,4);
+ INSERT INTO t1 VALUES(13,4);
+ INSERT INTO t1 VALUES(14,4);
+ INSERT INTO t1 VALUES(15,4);
+ INSERT INTO t1 VALUES(16,5);
+ INSERT INTO t1 VALUES(17,5);
+ INSERT INTO t1 VALUES(18,5);
+ INSERT INTO t1 VALUES(19,5);
+ INSERT INTO t1 VALUES(20,5);
+ COMMIT;
+ SELECT DISTINCT y FROM t1 ORDER BY y;
+ }
+} {1 2 3 4 5}
+
+do_test select6-1.1 {
+ execsql2 {SELECT * FROM (SELECT x, y FROM t1 WHERE x<2)}
+} {x 1 y 1}
+do_test select6-1.2 {
+ execsql {SELECT count(*) FROM (SELECT y FROM t1)}
+} {20}
+do_test select6-1.3 {
+ execsql {SELECT count(*) FROM (SELECT DISTINCT y FROM t1)}
+} {5}
+do_test select6-1.4 {
+ execsql {SELECT count(*) FROM (SELECT DISTINCT * FROM (SELECT y FROM t1))}
+} {5}
+do_test select6-1.5 {
+ execsql {SELECT count(*) FROM (SELECT * FROM (SELECT DISTINCT y FROM t1))}
+} {5}
+
+do_test select6-1.6 {
+ execsql {
+ SELECT *
+ FROM (SELECT count(*),y FROM t1 GROUP BY y) AS a,
+ (SELECT max(x),y FROM t1 GROUP BY y) as b
+ WHERE a.y=b.y ORDER BY a.y
+ }
+} {1 1 1 1 2 2 3 2 4 3 7 3 8 4 15 4 5 5 20 5}
+do_test select6-1.7 {
+ execsql {
+ SELECT a.y, a.[count(*)], [max(x)], [count(*)]
+ FROM (SELECT count(*),y FROM t1 GROUP BY y) AS a,
+ (SELECT max(x),y FROM t1 GROUP BY y) as b
+ WHERE a.y=b.y ORDER BY a.y
+ }
+} {1 1 1 1 2 2 3 2 3 4 7 4 4 8 15 8 5 5 20 5}
+do_test select6-1.8 {
+ execsql {
+ SELECT q, p, r
+ FROM (SELECT count(*) as p , y as q FROM t1 GROUP BY y) AS a,
+ (SELECT max(x) as r, y as s FROM t1 GROUP BY y) as b
+ WHERE q=s ORDER BY s
+ }
+} {1 1 1 2 2 3 3 4 7 4 8 15 5 5 20}
+do_test select6-1.9 {
+ execsql {
+ SELECT q, p, r, b.[min(x)+y]
+ FROM (SELECT count(*) as p , y as q FROM t1 GROUP BY y) AS a,
+ (SELECT max(x) as r, y as s, min(x)+y FROM t1 GROUP BY y) as b
+ WHERE q=s ORDER BY s
+ }
+} {1 1 1 2 2 2 3 4 3 4 7 7 4 8 15 12 5 5 20 21}
+
+do_test select6-2.0 {
+ execsql {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t2 SELECT * FROM t1;
+ SELECT DISTINCT b FROM t2 ORDER BY b;
+ }
+} {1 2 3 4 5}
+do_test select6-2.1 {
+ execsql2 {SELECT * FROM (SELECT a, b FROM t2 WHERE a<2)}
+} {a 1 b 1}
+do_test select6-2.2 {
+ execsql {SELECT count(*) FROM (SELECT b FROM t2)}
+} {20}
+do_test select6-2.3 {
+ execsql {SELECT count(*) FROM (SELECT DISTINCT b FROM t2)}
+} {5}
+do_test select6-2.4 {
+ execsql {SELECT count(*) FROM (SELECT DISTINCT * FROM (SELECT b FROM t2))}
+} {5}
+do_test select6-2.5 {
+ execsql {SELECT count(*) FROM (SELECT * FROM (SELECT DISTINCT b FROM t2))}
+} {5}
+
+do_test select6-2.6 {
+ execsql {
+ SELECT *
+ FROM (SELECT count(*),b FROM t2 GROUP BY b) AS a,
+ (SELECT max(a),b FROM t2 GROUP BY b) as b
+ WHERE a.b=b.b ORDER BY a.b
+ }
+} {1 1 1 1 2 2 3 2 4 3 7 3 8 4 15 4 5 5 20 5}
+do_test select6-2.7 {
+ execsql {
+ SELECT a.b, a.[count(*)], [max(a)], [count(*)]
+ FROM (SELECT count(*),b FROM t2 GROUP BY b) AS a,
+ (SELECT max(a),b FROM t2 GROUP BY b) as b
+ WHERE a.b=b.b ORDER BY a.b
+ }
+} {1 1 1 1 2 2 3 2 3 4 7 4 4 8 15 8 5 5 20 5}
+do_test select6-2.8 {
+ execsql {
+ SELECT q, p, r
+ FROM (SELECT count(*) as p , b as q FROM t2 GROUP BY b) AS a,
+ (SELECT max(a) as r, b as s FROM t2 GROUP BY b) as b
+ WHERE q=s ORDER BY s
+ }
+} {1 1 1 2 2 3 3 4 7 4 8 15 5 5 20}
+do_test select6-2.9 {
+ execsql {
+ SELECT a.q, a.p, b.r
+ FROM (SELECT count(*) as p , b as q FROM t2 GROUP BY q) AS a,
+ (SELECT max(a) as r, b as s FROM t2 GROUP BY s) as b
+ WHERE a.q=b.s ORDER BY a.q
+ }
+} {1 1 1 2 2 3 3 4 7 4 8 15 5 5 20}
+
+do_test select6-3.1 {
+ execsql2 {
+ SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE x=3));
+ }
+} {x 3 y 2}
+do_test select6-3.2 {
+ execsql {
+ SELECT * FROM
+ (SELECT a.q, a.p, b.r
+ FROM (SELECT count(*) as p , b as q FROM t2 GROUP BY q) AS a,
+ (SELECT max(a) as r, b as s FROM t2 GROUP BY s) as b
+ WHERE a.q=b.s ORDER BY a.q)
+ ORDER BY "a.q"
+ }
+} {1 1 1 2 2 3 3 4 7 4 8 15 5 5 20}
+do_test select6-3.3 {
+ execsql {
+ SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)
+ }
+} {10.5 3.7 14.2}
+do_test select6-3.4 {
+ execsql {
+ SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1 WHERE y=4)
+ }
+} {11.5 4.0 15.5}
+do_test select6-3.5 {
+ execsql {
+ SELECT x,y,x+y FROM (SELECT avg(a) as 'x', avg(b) as 'y' FROM t2 WHERE a=4)
+ }
+} {4.0 3.0 7.0}
+do_test select6-3.6 {
+ execsql {
+ SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)
+ WHERE a>10
+ }
+} {10.5 3.7 14.2}
+do_test select6-3.7 {
+ execsql {
+ SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)
+ WHERE a<10
+ }
+} {}
+do_test select6-3.8 {
+ execsql {
+ SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1 WHERE y=4)
+ WHERE a>10
+ }
+} {11.5 4.0 15.5}
+do_test select6-3.9 {
+ execsql {
+ SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1 WHERE y=4)
+ WHERE a<10
+ }
+} {}
+do_test select6-3.10 {
+ execsql {
+ SELECT a,b,a+b FROM (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b)
+ ORDER BY a
+ }
+} {1.0 1 2.0 2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23.0}
+do_test select6-3.11 {
+ execsql {
+ SELECT a,b,a+b FROM
+ (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b)
+ WHERE b<4 ORDER BY a
+ }
+} {1.0 1 2.0 2.5 2 4.5 5.5 3 8.5}
+do_test select6-3.12 {
+ execsql {
+ SELECT a,b,a+b FROM
+ (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b HAVING a>1)
+ WHERE b<4 ORDER BY a
+ }
+} {2.5 2 4.5 5.5 3 8.5}
+do_test select6-3.13 {
+ execsql {
+ SELECT a,b,a+b FROM
+ (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b HAVING a>1)
+ ORDER BY a
+ }
+} {2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23.0}
+do_test select6-3.14 {
+ execsql {
+ SELECT [count(*)],y FROM (SELECT count(*), y FROM t1 GROUP BY y)
+ ORDER BY [count(*)]
+ }
+} {1 1 2 2 4 3 5 5 8 4}
+do_test select6-3.15 {
+ execsql {
+ SELECT [count(*)],y FROM (SELECT count(*), y FROM t1 GROUP BY y)
+ ORDER BY y
+ }
+} {1 1 2 2 4 3 8 4 5 5}
+
+do_test select6-4.1 {
+ execsql {
+ SELECT a,b,c FROM
+ (SELECT x AS 'a', y AS 'b', x+y AS 'c' FROM t1 WHERE y=4)
+ WHERE a<10 ORDER BY a;
+ }
+} {8 4 12 9 4 13}
+do_test select6-4.2 {
+ execsql {
+ SELECT y FROM (SELECT DISTINCT y FROM t1) WHERE y<5 ORDER BY y
+ }
+} {1 2 3 4}
+do_test select6-4.3 {
+ execsql {
+ SELECT DISTINCT y FROM (SELECT y FROM t1) WHERE y<5 ORDER BY y
+ }
+} {1 2 3 4}
+do_test select6-4.4 {
+ execsql {
+ SELECT avg(y) FROM (SELECT DISTINCT y FROM t1) WHERE y<5 ORDER BY y
+ }
+} {2.5}
+do_test select6-4.5 {
+ execsql {
+ SELECT avg(y) FROM (SELECT DISTINCT y FROM t1 WHERE y<5) ORDER BY y
+ }
+} {2.5}
+
+do_test select6-5.1 {
+ execsql {
+ SELECT a,x,b FROM
+ (SELECT x+3 AS 'a', x FROM t1 WHERE y=3) AS 'p',
+ (SELECT x AS 'b' FROM t1 WHERE y=4) AS 'q'
+ WHERE a=b
+ ORDER BY a
+ }
+} {8 5 8 9 6 9 10 7 10}
+do_test select6-5.2 {
+ execsql {
+ SELECT a,x,b FROM
+ (SELECT x+3 AS 'a', x FROM t1 WHERE y=3),
+ (SELECT x AS 'b' FROM t1 WHERE y=4)
+ WHERE a=b
+ ORDER BY a
+ }
+} {8 5 8 9 6 9 10 7 10}
+
+# Tests of compound sub-selects
+#
+do_test select6-6.1 {
+ execsql {
+ DELETE FROM t1 WHERE x>4;
+ SELECT * FROM t1
+ }
+} {1 1 2 2 3 2 4 3}
+ifcapable compound {
+ do_test select6-6.2 {
+ execsql {
+ SELECT * FROM (
+ SELECT x AS 'a' FROM t1 UNION ALL SELECT x+10 AS 'a' FROM t1
+ ) ORDER BY a;
+ }
+ } {1 2 3 4 11 12 13 14}
+ do_test select6-6.3 {
+ execsql {
+ SELECT * FROM (
+ SELECT x AS 'a' FROM t1 UNION ALL SELECT x+1 AS 'a' FROM t1
+ ) ORDER BY a;
+ }
+ } {1 2 2 3 3 4 4 5}
+ do_test select6-6.4 {
+ execsql {
+ SELECT * FROM (
+ SELECT x AS 'a' FROM t1 UNION SELECT x+1 AS 'a' FROM t1
+ ) ORDER BY a;
+ }
+ } {1 2 3 4 5}
+ do_test select6-6.5 {
+ execsql {
+ SELECT * FROM (
+ SELECT x AS 'a' FROM t1 INTERSECT SELECT x+1 AS 'a' FROM t1
+ ) ORDER BY a;
+ }
+ } {2 3 4}
+ do_test select6-6.6 {
+ execsql {
+ SELECT * FROM (
+ SELECT x AS 'a' FROM t1 EXCEPT SELECT x*2 AS 'a' FROM t1
+ ) ORDER BY a;
+ }
+ } {1 3}
+} ;# ifcapable compound
+
+# Subselects with no FROM clause
+#
+do_test select6-7.1 {
+ execsql {
+ SELECT * FROM (SELECT 1)
+ }
+} {1}
+do_test select6-7.2 {
+ execsql {
+ SELECT c,b,a,* FROM (SELECT 1 AS 'a', 2 AS 'b', 'abc' AS 'c')
+ }
+} {abc 2 1 1 2 abc}
+do_test select6-7.3 {
+ execsql {
+ SELECT c,b,a,* FROM (SELECT 1 AS 'a', 2 AS 'b', 'abc' AS 'c' WHERE 0)
+ }
+} {}
+do_test select6-7.4 {
+ execsql2 {
+ SELECT c,b,a,* FROM (SELECT 1 AS 'a', 2 AS 'b', 'abc' AS 'c' WHERE 1)
+ }
+} {c abc b 2 a 1 a 1 b 2 c abc}
+
+# The remaining tests in this file depend on the EXPLAIN keyword.
+# Skip these tests if EXPLAIN is disabled in the current build.
+#
+ifcapable {!explain} {
+ finish_test
+ return
+}
+
+# The following procedure compiles the SQL given as an argument and returns
+# TRUE if that SQL uses any transient tables and returns FALSE if no
+# transient tables are used. This is used to make sure that the
+# sqliteFlattenSubquery() routine in select.c is doing its job.
+#
+proc is_flat {sql} {
+ return [expr 0>[lsearch [execsql "EXPLAIN $sql"] OpenEphemeral]]
+}
+
+# Check that the flattener works correctly for deeply nested subqueries
+# involving joins.
+#
+do_test select6-8.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(p,q);
+ INSERT INTO t3 VALUES(1,11);
+ INSERT INTO t3 VALUES(2,22);
+ CREATE TABLE t4(q,r);
+ INSERT INTO t4 VALUES(11,111);
+ INSERT INTO t4 VALUES(22,222);
+ COMMIT;
+ SELECT * FROM t3 NATURAL JOIN t4;
+ }
+} {1 11 111 2 22 222}
+do_test select6-8.2 {
+ execsql {
+ SELECT y, p, q, r FROM
+ (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,
+ (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n
+ WHERE y=p
+ }
+} {1 1 11 111 2 2 22 222 2 2 22 222}
+# If view support is omitted from the build, then so is the query
+# "flattener". So omit this test and test select6-8.6 in that case.
+ifcapable view {
+do_test select6-8.3 {
+ is_flat {
+ SELECT y, p, q, r FROM
+ (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,
+ (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n
+ WHERE y=p
+ }
+} {1}
+} ;# ifcapable view
+do_test select6-8.4 {
+ execsql {
+ SELECT DISTINCT y, p, q, r FROM
+ (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,
+ (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n
+ WHERE y=p
+ }
+} {1 1 11 111 2 2 22 222}
+do_test select6-8.5 {
+ execsql {
+ SELECT * FROM
+ (SELECT y, p, q, r FROM
+ (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,
+ (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n
+ WHERE y=p) AS e,
+ (SELECT r AS z FROM t4 WHERE q=11) AS f
+ WHERE e.r=f.z
+ }
+} {1 1 11 111 111}
+ifcapable view {
+do_test select6-8.6 {
+ is_flat {
+ SELECT * FROM
+ (SELECT y, p, q, r FROM
+ (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,
+ (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n
+ WHERE y=p) AS e,
+ (SELECT r AS z FROM t4 WHERE q=11) AS f
+ WHERE e.r=f.z
+ }
+} {1}
+} ;# ifcapable view
+
+# Ticket #1634
+#
+do_test select6-9.1 {
+ execsql {
+ SELECT a.x, b.x FROM t1 AS a, (SELECT x FROM t1 LIMIT 2) AS b
+ ORDER BY 1, 2
+ }
+} {1 1 1 2 2 1 2 2 3 1 3 2 4 1 4 2}
+do_test select6-9.2 {
+ execsql {
+ SELECT x FROM (SELECT x FROM t1 LIMIT 2);
+ }
+} {1 2}
+do_test select6-9.3 {
+ execsql {
+ SELECT x FROM (SELECT x FROM t1 LIMIT 2 OFFSET 1);
+ }
+} {2 3}
+do_test select6-9.4 {
+ execsql {
+ SELECT x FROM (SELECT x FROM t1) LIMIT 2;
+ }
+} {1 2}
+do_test select6-9.5 {
+ execsql {
+ SELECT x FROM (SELECT x FROM t1) LIMIT 2 OFFSET 1;
+ }
+} {2 3}
+do_test select6-9.6 {
+ execsql {
+ SELECT x FROM (SELECT x FROM t1 LIMIT 2) LIMIT 3;
+ }
+} {1 2}
+do_test select6-9.7 {
+ execsql {
+ SELECT x FROM (SELECT x FROM t1 LIMIT -1) LIMIT 3;
+ }
+} {1 2 3}
+do_test select6-9.8 {
+ execsql {
+ SELECT x FROM (SELECT x FROM t1 LIMIT -1);
+ }
+} {1 2 3 4}
+do_test select6-9.9 {
+ execsql {
+ SELECT x FROM (SELECT x FROM t1 LIMIT -1 OFFSET 1);
+ }
+} {2 3 4}
+do_test select6-9.10 {
+ execsql {
+ SELECT x, y FROM (SELECT x, (SELECT 10+x) y FROM t1 LIMIT -1 OFFSET 1);
+ }
+} {2 12 3 13 4 14}
+do_test select6-9.11 {
+ execsql {
+ SELECT x, y FROM (SELECT x, (SELECT 10)+x y FROM t1 LIMIT -1 OFFSET 1);
+ }
+} {2 12 3 13 4 14}
+
+
+
+finish_test
diff --git a/test/select7.test b/test/select7.test
new file mode 100644
index 0000000..e8fc440
--- /dev/null
+++ b/test/select7.test
@@ -0,0 +1,202 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing compute SELECT statements and nested
+# views.
+#
+# $Id: select7.test,v 1.11 2007/09/12 17:01:45 danielk1977 Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable compound {
+
+# A 3-way INTERSECT. Ticket #875
+ifcapable tempdb {
+ do_test select7-1.1 {
+ execsql {
+ create temp table t1(x);
+ insert into t1 values('amx');
+ insert into t1 values('anx');
+ insert into t1 values('amy');
+ insert into t1 values('bmy');
+ select * from t1 where x like 'a__'
+ intersect select * from t1 where x like '_m_'
+ intersect select * from t1 where x like '__x';
+ }
+ } {amx}
+}
+
+
+# Nested views do not handle * properly. Ticket #826.
+#
+ifcapable view {
+do_test select7-2.1 {
+ execsql {
+ CREATE TABLE x(id integer primary key, a TEXT NULL);
+ INSERT INTO x (a) VALUES ('first');
+ CREATE TABLE tempx(id integer primary key, a TEXT NULL);
+ INSERT INTO tempx (a) VALUES ('t-first');
+ CREATE VIEW tv1 AS SELECT x.id, tx.id FROM x JOIN tempx tx ON tx.id=x.id;
+ CREATE VIEW tv1b AS SELECT x.id, tx.id FROM x JOIN tempx tx on tx.id=x.id;
+ CREATE VIEW tv2 AS SELECT * FROM tv1 UNION SELECT * FROM tv1b;
+ SELECT * FROM tv2;
+ }
+} {1 1}
+} ;# ifcapable view
+
+} ;# ifcapable compound
+
+# Do not allow GROUP BY without an aggregate. Ticket #1039.
+#
+# Change: force any query with a GROUP BY clause to be processed as
+# an aggregate query, whether it contains aggregates or not.
+#
+ifcapable subquery {
+ # do_test select7-3.1 {
+ # catchsql {
+ # SELECT * FROM (SELECT * FROM sqlite_master) GROUP BY name
+ # }
+ # } {1 {GROUP BY may only be used on aggregate queries}}
+ do_test select7-3.1 {
+ catchsql {
+ SELECT * FROM (SELECT * FROM sqlite_master) GROUP BY name
+ }
+ } [list 0 [execsql {SELECT * FROM sqlite_master ORDER BY name}]]
+}
+
+# Ticket #2018 - Make sure names are resolved correctly on all
+# SELECT statements of a compound subquery.
+#
+ifcapable {subquery && compound} {
+ do_test select7-4.1 {
+ execsql {
+ CREATE TABLE IF NOT EXISTS photo(pk integer primary key, x);
+ CREATE TABLE IF NOT EXISTS tag(pk integer primary key, fk int, name);
+
+ SELECT P.pk from PHOTO P WHERE NOT EXISTS (
+ SELECT T2.pk from TAG T2 WHERE T2.fk = P.pk
+ EXCEPT
+ SELECT T3.pk from TAG T3 WHERE T3.fk = P.pk AND T3.name LIKE '%foo%'
+ );
+ }
+ } {}
+ do_test select7-4.2 {
+ execsql {
+ INSERT INTO photo VALUES(1,1);
+ INSERT INTO photo VALUES(2,2);
+ INSERT INTO photo VALUES(3,3);
+ INSERT INTO tag VALUES(11,1,'one');
+ INSERT INTO tag VALUES(12,1,'two');
+ INSERT INTO tag VALUES(21,1,'one-b');
+ SELECT P.pk from PHOTO P WHERE NOT EXISTS (
+ SELECT T2.pk from TAG T2 WHERE T2.fk = P.pk
+ EXCEPT
+ SELECT T3.pk from TAG T3 WHERE T3.fk = P.pk AND T3.name LIKE '%foo%'
+ );
+ }
+ } {2 3}
+}
+
+# ticket #2347
+#
+ifcapable {subquery && compound} {
+ do_test select7-5.1 {
+ catchsql {
+ CREATE TABLE t2(a,b);
+ SELECT 5 IN (SELECT a,b FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+ do_test select7-5.2 {
+ catchsql {
+ SELECT 5 IN (SELECT * FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+ do_test select7-5.3 {
+ catchsql {
+ SELECT 5 IN (SELECT a,b FROM t2 UNION SELECT b,a FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+ do_test select7-5.4 {
+ catchsql {
+ SELECT 5 IN (SELECT * FROM t2 UNION SELECT * FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+}
+
+# Verify that an error occurs if you have too many terms on a
+# compound select statement.
+#
+ifcapable compound {
+ if {$SQLITE_MAX_COMPOUND_SELECT>0} {
+ set sql {SELECT 0}
+ set result 0
+ for {set i 1} {$i<$SQLITE_MAX_COMPOUND_SELECT} {incr i} {
+ append sql " UNION ALL SELECT $i"
+ lappend result $i
+ }
+ do_test select7-6.1 {
+ catchsql $sql
+ } [list 0 $result]
+ append sql { UNION ALL SELECT 99999999}
+ do_test select7-6.2 {
+ catchsql $sql
+ } {1 {too many terms in compound SELECT}}
+ }
+}
+
+# This block of tests verifies that bug aa92c76cd4 is fixed.
+#
+do_test select7-7.1 {
+ execsql {
+ CREATE TABLE t3(a REAL);
+ INSERT INTO t3 VALUES(44.0);
+ INSERT INTO t3 VALUES(56.0);
+ }
+} {}
+do_test select7-7.2 {
+ execsql {
+ pragma vdbe_trace = 0;
+ SELECT (CASE WHEN a=0 THEN 0 ELSE (a + 25) / 50 END) AS categ, count(*)
+ FROM t3 GROUP BY categ
+ }
+} {1.38 1 1.62 1}
+do_test select7-7.3 {
+ execsql {
+ CREATE TABLE t4(a REAL);
+ INSERT INTO t4 VALUES( 2.0 );
+ INSERT INTO t4 VALUES( 3.0 );
+ }
+} {}
+do_test select7-7.4 {
+ execsql {
+ SELECT (CASE WHEN a=0 THEN 'zero' ELSE a/2 END) AS t FROM t4 GROUP BY t;
+ }
+} {1.0 1.5}
+do_test select7-7.5 {
+ execsql { SELECT a=0, typeof(a) FROM t4 }
+} {0 real 0 real}
+do_test select7-7.6 {
+ execsql { SELECT a=0, typeof(a) FROM t4 GROUP BY a }
+} {0 real 0 real}
+
+do_test select7-7.7 {
+ execsql {
+ CREATE TABLE t5(a TEXT, b INT);
+ INSERT INTO t5 VALUES(123, 456);
+ SELECT typeof(a), a FROM t5 GROUP BY a HAVING a<b;
+ }
+} {text 123}
+
+finish_test
diff --git a/test/select8.test b/test/select8.test
new file mode 100644
index 0000000..9862664
--- /dev/null
+++ b/test/select8.test
@@ -0,0 +1,62 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# The focus of this file is testing that LIMIT and OFFSET work for
+# unusual combinations SELECT statements.
+#
+# $Id: select8.test,v 1.1 2008/01/12 12:48:09 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+execsql {
+ CREATE TABLE songs(songid, artist, timesplayed);
+ INSERT INTO songs VALUES(1,'one',1);
+ INSERT INTO songs VALUES(2,'one',2);
+ INSERT INTO songs VALUES(3,'two',3);
+ INSERT INTO songs VALUES(4,'three',5);
+ INSERT INTO songs VALUES(5,'one',7);
+ INSERT INTO songs VALUES(6,'two',11);
+}
+set result [execsql {
+ SELECT DISTINCT artist,sum(timesplayed) AS total
+ FROM songs
+ GROUP BY LOWER(artist)
+}]
+puts result=$result
+do_test select8-1.1 {
+ execsql {
+ SELECT DISTINCT artist,sum(timesplayed) AS total
+ FROM songs
+ GROUP BY LOWER(artist)
+ LIMIT 1 OFFSET 1
+ }
+} [lrange $result 2 3]
+do_test select8-1.2 {
+ execsql {
+ SELECT DISTINCT artist,sum(timesplayed) AS total
+ FROM songs
+ GROUP BY LOWER(artist)
+ LIMIT 2 OFFSET 1
+ }
+} [lrange $result 2 5]
+do_test select8-1.3 {
+ execsql {
+ SELECT DISTINCT artist,sum(timesplayed) AS total
+ FROM songs
+ GROUP BY LOWER(artist)
+ LIMIT -1 OFFSET 2
+ }
+} [lrange $result 4 end]
+
+
+finish_test
diff --git a/test/select9.test b/test/select9.test
new file mode 100644
index 0000000..085dee0
--- /dev/null
+++ b/test/select9.test
@@ -0,0 +1,419 @@
+# 2008 June 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# $Id: select9.test,v 1.4 2008/07/01 14:39:35 danielk1977 Exp $
+
+# The tests in this file are focused on test compound SELECT statements
+# that have any or all of an ORDER BY, LIMIT or OFFSET clauses. As of
+# version 3.6.0, SQLite contains code to use SQL indexes where possible
+# to optimize such statements.
+#
+
+# TODO Points:
+#
+# * Are there any "column affinity" issues to consider?
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+#-------------------------------------------------------------------------
+# test_compound_select TESTNAME SELECT RESULT
+#
+# This command is used to run multiple LIMIT/OFFSET test cases based on
+# the single SELECT statement passed as the second argument. The SELECT
+# statement may not contain a LIMIT or OFFSET clause. This proc tests
+# many statements of the form:
+#
+# "$SELECT limit $X offset $Y"
+#
+# for various values of $X and $Y.
+#
+# The third argument, $RESULT, should contain the expected result of
+# the command [execsql $SELECT].
+#
+# The first argument, $TESTNAME, is used as the base test case name to
+# pass to [do_test] for each individual LIMIT OFFSET test case.
+#
+proc test_compound_select {testname sql result} {
+
+ set nCol 1
+ db eval $sql A {
+ set nCol [llength $A(*)]
+ break
+ }
+ set nRow [expr {[llength $result] / $nCol}]
+
+ set ::compound_sql $sql
+ do_test $testname {
+ execsql $::compound_sql
+ } $result
+#return
+
+ set iLimitIncr 1
+ set iOffsetIncr 1
+ if {[info exists ::G(isquick)] && $::G(isquick) && $nRow>=5} {
+ set iOffsetIncr [expr $nRow / 5]
+ set iLimitIncr [expr $nRow / 5]
+ }
+
+ set iLimitEnd [expr $nRow+$iLimitIncr]
+ set iOffsetEnd [expr $nRow+$iOffsetIncr]
+
+ for {set iOffset 0} {$iOffset < $iOffsetEnd} {incr iOffset $iOffsetIncr} {
+ for {set iLimit 0} {$iLimit < $iLimitEnd} {incr iLimit} {
+
+ set ::compound_sql "$sql LIMIT $iLimit"
+ if {$iOffset != 0} {
+ append ::compound_sql " OFFSET $iOffset"
+ }
+
+ set iStart [expr {$iOffset*$nCol}]
+ set iEnd [expr {($iOffset*$nCol) + ($iLimit*$nCol) -1}]
+
+ do_test $testname.limit=$iLimit.offset=$iOffset {
+ execsql $::compound_sql
+ } [lrange $result $iStart $iEnd]
+ }
+ }
+}
+
+#-------------------------------------------------------------------------
+# test_compound_select_flippable TESTNAME SELECT RESULT
+#
+# This command is for testing statements of the form:
+#
+# <simple select 1> <compound op> <simple select 2> ORDER BY <order by>
+#
+# where each <simple select> is a simple (non-compound) select statement
+# and <compound op> is one of "INTERSECT", "UNION ALL" or "UNION".
+#
+# This proc calls [test_compound_select] twice, once with the select
+# statement as it is passed to this command, and once with the positions
+# of <select statement 1> and <select statement 2> exchanged.
+#
+proc test_compound_select_flippable {testname sql result} {
+ test_compound_select $testname $sql $result
+
+ set select [string trim $sql]
+ set RE {(.*)(UNION ALL|INTERSECT|UNION)(.*)(ORDER BY.*)}
+ set rc [regexp $RE $select -> s1 op s2 order_by]
+ if {!$rc} {error "Statement is unflippable: $select"}
+
+ set flipsql "$s2 $op $s1 $order_by"
+ test_compound_select $testname.flipped $flipsql $result
+}
+
+#############################################################################
+# Begin tests.
+#
+
+# Create and populate a sample database.
+#
+do_test select9-1.0 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e, f);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 'one', 'I');
+ INSERT INTO t1 VALUES(3, NULL, NULL);
+ INSERT INTO t1 VALUES(5, 'five', 'V');
+ INSERT INTO t1 VALUES(7, 'seven', 'VII');
+ INSERT INTO t1 VALUES(9, NULL, NULL);
+ INSERT INTO t1 VALUES(2, 'two', 'II');
+ INSERT INTO t1 VALUES(4, 'four', 'IV');
+ INSERT INTO t1 VALUES(6, NULL, NULL);
+ INSERT INTO t1 VALUES(8, 'eight', 'VIII');
+ INSERT INTO t1 VALUES(10, 'ten', 'X');
+
+ INSERT INTO t2 VALUES(1, 'two', 'IV');
+ INSERT INTO t2 VALUES(2, 'four', 'VIII');
+ INSERT INTO t2 VALUES(3, NULL, NULL);
+ INSERT INTO t2 VALUES(4, 'eight', 'XVI');
+ INSERT INTO t2 VALUES(5, 'ten', 'XX');
+ INSERT INTO t2 VALUES(6, NULL, NULL);
+ INSERT INTO t2 VALUES(7, 'fourteen', 'XXVIII');
+ INSERT INTO t2 VALUES(8, 'sixteen', 'XXXII');
+ INSERT INTO t2 VALUES(9, NULL, NULL);
+ INSERT INTO t2 VALUES(10, 'twenty', 'XL');
+
+ COMMIT;
+ }
+} {}
+
+# Each iteration of this loop runs the same tests with a different set
+# of indexes present within the database schema. The data returned by
+# the compound SELECT statements in the test cases should be the same
+# in each case.
+#
+set iOuterLoop 1
+foreach indexes [list {
+ /* Do not create any indexes. */
+} {
+ CREATE INDEX i1 ON t1(a)
+} {
+ CREATE INDEX i2 ON t1(b)
+} {
+ CREATE INDEX i3 ON t2(d)
+} {
+ CREATE INDEX i4 ON t2(e)
+}] {
+
+ do_test select9-1.$iOuterLoop.1 {
+ execsql $indexes
+ } {}
+
+ # Test some 2-way UNION ALL queries. No WHERE clauses.
+ #
+ test_compound_select select9-1.$iOuterLoop.2 {
+ SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2
+ } {1 one 3 {} 5 five 7 seven 9 {} 2 two 4 four 6 {} 8 eight 10 ten 1 two 2 four 3 {} 4 eight 5 ten 6 {} 7 fourteen 8 sixteen 9 {} 10 twenty}
+ test_compound_select select9-1.$iOuterLoop.3 {
+ SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY 1
+ } {1 one 1 two 2 two 2 four 3 {} 3 {} 4 four 4 eight 5 five 5 ten 6 {} 6 {} 7 seven 7 fourteen 8 eight 8 sixteen 9 {} 9 {} 10 ten 10 twenty}
+ test_compound_select select9-1.$iOuterLoop.4 {
+ SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY 2
+ } {3 {} 9 {} 6 {} 3 {} 6 {} 9 {} 8 eight 4 eight 5 five 4 four 2 four 7 fourteen 1 one 7 seven 8 sixteen 10 ten 5 ten 10 twenty 2 two 1 two}
+ test_compound_select_flippable select9-1.$iOuterLoop.5 {
+ SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY 1, 2
+ } {1 one 1 two 2 four 2 two 3 {} 3 {} 4 eight 4 four 5 five 5 ten 6 {} 6 {} 7 fourteen 7 seven 8 eight 8 sixteen 9 {} 9 {} 10 ten 10 twenty}
+ test_compound_select_flippable select9-1.$iOuterLoop.6 {
+ SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY 2, 1
+ } {3 {} 3 {} 6 {} 6 {} 9 {} 9 {} 4 eight 8 eight 5 five 2 four 4 four 7 fourteen 1 one 7 seven 8 sixteen 5 ten 10 ten 10 twenty 1 two 2 two}
+
+ # Test some 2-way UNION queries.
+ #
+ test_compound_select select9-1.$iOuterLoop.7 {
+ SELECT a, b FROM t1 UNION SELECT d, e FROM t2
+ } {1 one 1 two 2 four 2 two 3 {} 4 eight 4 four 5 five 5 ten 6 {} 7 fourteen 7 seven 8 eight 8 sixteen 9 {} 10 ten 10 twenty}
+
+ test_compound_select select9-1.$iOuterLoop.8 {
+ SELECT a, b FROM t1 UNION SELECT d, e FROM t2 ORDER BY 1
+ } {1 one 1 two 2 four 2 two 3 {} 4 eight 4 four 5 five 5 ten 6 {} 7 fourteen 7 seven 8 eight 8 sixteen 9 {} 10 ten 10 twenty}
+
+ test_compound_select select9-1.$iOuterLoop.9 {
+ SELECT a, b FROM t1 UNION SELECT d, e FROM t2 ORDER BY 2
+ } {3 {} 6 {} 9 {} 4 eight 8 eight 5 five 2 four 4 four 7 fourteen 1 one 7 seven 8 sixteen 5 ten 10 ten 10 twenty 1 two 2 two}
+
+ test_compound_select_flippable select9-1.$iOuterLoop.10 {
+ SELECT a, b FROM t1 UNION SELECT d, e FROM t2 ORDER BY 1, 2
+ } {1 one 1 two 2 four 2 two 3 {} 4 eight 4 four 5 five 5 ten 6 {} 7 fourteen 7 seven 8 eight 8 sixteen 9 {} 10 ten 10 twenty}
+
+ test_compound_select_flippable select9-1.$iOuterLoop.11 {
+ SELECT a, b FROM t1 UNION SELECT d, e FROM t2 ORDER BY 2, 1
+ } {3 {} 6 {} 9 {} 4 eight 8 eight 5 five 2 four 4 four 7 fourteen 1 one 7 seven 8 sixteen 5 ten 10 ten 10 twenty 1 two 2 two}
+
+ # Test some 2-way INTERSECT queries.
+ #
+ test_compound_select select9-1.$iOuterLoop.11 {
+ SELECT a, b FROM t1 INTERSECT SELECT d, e FROM t2
+ } {3 {} 6 {} 9 {}}
+ test_compound_select_flippable select9-1.$iOuterLoop.12 {
+ SELECT a, b FROM t1 INTERSECT SELECT d, e FROM t2 ORDER BY 1
+ } {3 {} 6 {} 9 {}}
+ test_compound_select select9-1.$iOuterLoop.13 {
+ SELECT a, b FROM t1 INTERSECT SELECT d, e FROM t2 ORDER BY 2
+ } {3 {} 6 {} 9 {}}
+ test_compound_select_flippable select9-1.$iOuterLoop.14 {
+ SELECT a, b FROM t1 INTERSECT SELECT d, e FROM t2 ORDER BY 2, 1
+ } {3 {} 6 {} 9 {}}
+ test_compound_select_flippable select9-1.$iOuterLoop.15 {
+ SELECT a, b FROM t1 INTERSECT SELECT d, e FROM t2 ORDER BY 1, 2
+ } {3 {} 6 {} 9 {}}
+
+ # Test some 2-way EXCEPT queries.
+ #
+ test_compound_select select9-1.$iOuterLoop.16 {
+ SELECT a, b FROM t1 EXCEPT SELECT d, e FROM t2
+ } {1 one 2 two 4 four 5 five 7 seven 8 eight 10 ten}
+
+ test_compound_select select9-1.$iOuterLoop.17 {
+ SELECT a, b FROM t1 EXCEPT SELECT d, e FROM t2 ORDER BY 1
+ } {1 one 2 two 4 four 5 five 7 seven 8 eight 10 ten}
+
+ test_compound_select select9-1.$iOuterLoop.18 {
+ SELECT a, b FROM t1 EXCEPT SELECT d, e FROM t2 ORDER BY 2
+ } {8 eight 5 five 4 four 1 one 7 seven 10 ten 2 two}
+
+ test_compound_select select9-1.$iOuterLoop.19 {
+ SELECT a, b FROM t1 EXCEPT SELECT d, e FROM t2 ORDER BY 1, 2
+ } {1 one 2 two 4 four 5 five 7 seven 8 eight 10 ten}
+
+ test_compound_select select9-1.$iOuterLoop.20 {
+ SELECT a, b FROM t1 EXCEPT SELECT d, e FROM t2 ORDER BY 2, 1
+ } {8 eight 5 five 4 four 1 one 7 seven 10 ten 2 two}
+
+ incr iOuterLoop
+}
+
+do_test select9-2.0 {
+ execsql {
+ DROP INDEX i1;
+ DROP INDEX i2;
+ DROP INDEX i3;
+ DROP INDEX i4;
+ }
+} {}
+
+proc reverse {lhs rhs} {
+ return [string compare $rhs $lhs]
+}
+db collate reverse reverse
+
+# This loop is similar to the previous one (test cases select9-1.*)
+# except that the simple select statements have WHERE clauses attached
+# to them. Sometimes the WHERE clause may be satisfied using the same
+# index used for ORDER BY, sometimes not.
+#
+set iOuterLoop 1
+foreach indexes [list {
+ /* Do not create any indexes. */
+} {
+ CREATE INDEX i1 ON t1(a)
+} {
+ DROP INDEX i1;
+ CREATE INDEX i1 ON t1(b, a)
+} {
+ CREATE INDEX i2 ON t2(d DESC, e COLLATE REVERSE ASC);
+} {
+ CREATE INDEX i3 ON t1(a DESC);
+}] {
+ do_test select9-2.$iOuterLoop.1 {
+ execsql $indexes
+ } {}
+
+ test_compound_select_flippable select9-2.$iOuterLoop.2 {
+ SELECT * FROM t1 WHERE a<5 UNION SELECT * FROM t2 WHERE d>=5 ORDER BY 1
+ } {1 one I 2 two II 3 {} {} 4 four IV 5 ten XX 6 {} {} 7 fourteen XXVIII 8 sixteen XXXII 9 {} {} 10 twenty XL}
+
+ test_compound_select_flippable select9-2.$iOuterLoop.2 {
+ SELECT * FROM t1 WHERE a<5 UNION SELECT * FROM t2 WHERE d>=5 ORDER BY 2, 1
+ } {3 {} {} 6 {} {} 9 {} {} 4 four IV 7 fourteen XXVIII 1 one I 8 sixteen XXXII 5 ten XX 10 twenty XL 2 two II}
+
+ test_compound_select_flippable select9-2.$iOuterLoop.3 {
+ SELECT * FROM t1 WHERE a<5 UNION SELECT * FROM t2 WHERE d>=5
+ ORDER BY 2 COLLATE reverse, 1
+ } {3 {} {} 6 {} {} 9 {} {} 2 two II 10 twenty XL 5 ten XX 8 sixteen XXXII 1 one I 7 fourteen XXVIII 4 four IV}
+
+ test_compound_select_flippable select9-2.$iOuterLoop.4 {
+ SELECT * FROM t1 WHERE a<5 UNION ALL SELECT * FROM t2 WHERE d>=5 ORDER BY 1
+ } {1 one I 2 two II 3 {} {} 4 four IV 5 ten XX 6 {} {} 7 fourteen XXVIII 8 sixteen XXXII 9 {} {} 10 twenty XL}
+
+ test_compound_select_flippable select9-2.$iOuterLoop.5 {
+ SELECT * FROM t1 WHERE a<5 UNION ALL SELECT * FROM t2 WHERE d>=5 ORDER BY 2, 1
+ } {3 {} {} 6 {} {} 9 {} {} 4 four IV 7 fourteen XXVIII 1 one I 8 sixteen XXXII 5 ten XX 10 twenty XL 2 two II}
+
+ test_compound_select_flippable select9-2.$iOuterLoop.6 {
+ SELECT * FROM t1 WHERE a<5 UNION ALL SELECT * FROM t2 WHERE d>=5
+ ORDER BY 2 COLLATE reverse, 1
+ } {3 {} {} 6 {} {} 9 {} {} 2 two II 10 twenty XL 5 ten XX 8 sixteen XXXII 1 one I 7 fourteen XXVIII 4 four IV}
+
+ test_compound_select select9-2.$iOuterLoop.4 {
+ SELECT a FROM t1 WHERE a<8 EXCEPT SELECT d FROM t2 WHERE d<=3 ORDER BY 1
+ } {4 5 6 7}
+
+ test_compound_select select9-2.$iOuterLoop.4 {
+ SELECT a FROM t1 WHERE a<8 INTERSECT SELECT d FROM t2 WHERE d<=3 ORDER BY 1
+ } {1 2 3}
+
+}
+
+do_test select9-2.X {
+ execsql {
+ DROP INDEX i1;
+ DROP INDEX i2;
+ DROP INDEX i3;
+ }
+} {}
+
+# This procedure executes the SQL. Then it checks the generated program
+# for the SQL and appends a "nosort" to the result if the program contains the
+# SortCallback opcode. If the program does not contain the SortCallback
+# opcode it appends "sort"
+#
+proc cksort {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ if {$::sqlite_sort_count} {set x sort} {set x nosort}
+ lappend data $x
+ return $data
+}
+
+# If the right indexes exist, the following query:
+#
+# SELECT t1.a FROM t1 UNION ALL SELECT t2.d FROM t2 ORDER BY 1
+#
+# can use indexes to run without doing a in-memory sort operation.
+# This block of tests (select9-3.*) is used to check if the same
+# is possible with:
+#
+# CREATE VIEW v1 AS SELECT a FROM t1 UNION ALL SELECT d FROM t2
+# SELECT a FROM v1 ORDER BY 1
+#
+# It turns out that it is.
+#
+do_test select9-3.1 {
+ cksort { SELECT a FROM t1 ORDER BY 1 }
+} {1 2 3 4 5 6 7 8 9 10 sort}
+do_test select9-3.2 {
+ execsql { CREATE INDEX i1 ON t1(a) }
+ cksort { SELECT a FROM t1 ORDER BY 1 }
+} {1 2 3 4 5 6 7 8 9 10 nosort}
+do_test select9-3.3 {
+ cksort { SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 LIMIT 5 }
+} {1 1 2 2 3 sort}
+do_test select9-3.4 {
+ execsql { CREATE INDEX i2 ON t2(d) }
+ cksort { SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 LIMIT 5 }
+} {1 1 2 2 3 nosort}
+do_test select9-3.5 {
+ execsql { CREATE VIEW v1 AS SELECT a FROM t1 UNION ALL SELECT d FROM t2 }
+ cksort { SELECT a FROM v1 ORDER BY 1 LIMIT 5 }
+} {1 1 2 2 3 nosort}
+do_test select9-3.X {
+ execsql {
+ DROP INDEX i1;
+ DROP INDEX i2;
+ DROP VIEW v1;
+ }
+} {}
+
+# This block of tests is the same as the preceding one, except that
+# "UNION" is tested instead of "UNION ALL".
+#
+do_test select9-4.1 {
+ cksort { SELECT a FROM t1 ORDER BY 1 }
+} {1 2 3 4 5 6 7 8 9 10 sort}
+do_test select9-4.2 {
+ execsql { CREATE INDEX i1 ON t1(a) }
+ cksort { SELECT a FROM t1 ORDER BY 1 }
+} {1 2 3 4 5 6 7 8 9 10 nosort}
+do_test select9-4.3 {
+ cksort { SELECT a FROM t1 UNION SELECT d FROM t2 ORDER BY 1 LIMIT 5 }
+} {1 2 3 4 5 sort}
+do_test select9-4.4 {
+ execsql { CREATE INDEX i2 ON t2(d) }
+ cksort { SELECT a FROM t1 UNION SELECT d FROM t2 ORDER BY 1 LIMIT 5 }
+} {1 2 3 4 5 nosort}
+do_test select9-4.5 {
+ execsql { CREATE VIEW v1 AS SELECT a FROM t1 UNION SELECT d FROM t2 }
+ cksort { SELECT a FROM v1 ORDER BY 1 LIMIT 5 }
+} {1 2 3 4 5 sort}
+do_test select9-4.X {
+ execsql {
+ DROP INDEX i1;
+ DROP INDEX i2;
+ DROP VIEW v1;
+ }
+} {}
+
+
+finish_test
diff --git a/test/selectA.test b/test/selectA.test
new file mode 100644
index 0000000..5b86377
--- /dev/null
+++ b/test/selectA.test
@@ -0,0 +1,1296 @@
+# 2008 June 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# The focus of this file is testing the compound-SELECT merge
+# optimization. Or, in other words, making sure that all
+# possible combinations of UNION, UNION ALL, EXCEPT, and
+# INTERSECT work together with an ORDER BY clause (with or w/o
+# explicit sort order and explicit collating secquites) and
+# with and without optional LIMIT and OFFSET clauses.
+#
+# $Id: selectA.test,v 1.6 2008/08/21 14:24:29 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+do_test selectA-1.0 {
+ execsql {
+ CREATE TABLE t1(a,b,c COLLATE NOCASE);
+ INSERT INTO t1 VALUES(1,'a','a');
+ INSERT INTO t1 VALUES(9.9, 'b', 'B');
+ INSERT INTO t1 VALUES(NULL, 'C', 'c');
+ INSERT INTO t1 VALUES('hello', 'd', 'D');
+ INSERT INTO t1 VALUES(x'616263', 'e', 'e');
+ SELECT * FROM t1;
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e}
+do_test selectA-1.1 {
+ execsql {
+ CREATE TABLE t2(x,y,z COLLATE NOCASE);
+ INSERT INTO t2 VALUES(NULL,'U','u');
+ INSERT INTO t2 VALUES('mad', 'Z', 'z');
+ INSERT INTO t2 VALUES(x'68617265', 'm', 'M');
+ INSERT INTO t2 VALUES(5.2e6, 'X', 'x');
+ INSERT INTO t2 VALUES(-23, 'Y', 'y');
+ SELECT * FROM t2;
+ }
+} {{} U u mad Z z hare m M 5200000.0 X x -23 Y y}
+do_test selectA-1.2 {
+ execsql {
+ CREATE TABLE t3(a,b,c COLLATE NOCASE);
+ INSERT INTO t3 SELECT * FROM t1;
+ INSERT INTO t3 SELECT * FROM t2;
+ INSERT INTO t3 SELECT * FROM t1;
+ INSERT INTO t3 SELECT * FROM t2;
+ INSERT INTO t3 SELECT * FROM t1;
+ INSERT INTO t3 SELECT * FROM t2;
+ SELECT count(*) FROM t3;
+ }
+} {30}
+
+do_test selectA-2.1 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.1.1 { # Ticket #3314
+ execsql {
+ SELECT t1.a, t1.b, t1.c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.1.2 { # Ticket #3314
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY t1.a, t1.b, t1.c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.2 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-2.3 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.4 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-2.5 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.6 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE DESC,a,c
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.7 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.8 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.9 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.10 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-2.11 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.12 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-2.13 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.14 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-2.15 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.16 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY b COLLATE NOCASE DESC,a,c
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.17 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.18 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.19 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.20 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-2.21 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.22 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-2.23 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.24 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-2.25 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.26 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE DESC,a,c
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.27 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.28 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.29 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.30 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-2.31 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.32 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-2.33 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.34 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-2.35 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.36 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY b COLLATE NOCASE DESC,a,c
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.37 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.38 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.39 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.40 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-2.41 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY a,b,c
+ }
+} {{} C c 1 a a 9.9 b B}
+do_test selectA-2.42 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY a,b,c
+ }
+} {hello d D abc e e}
+do_test selectA-2.43 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY a,b,c
+ }
+} {hello d D abc e e}
+do_test selectA-2.44 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY a,b,c
+ }
+} {hello d D abc e e}
+do_test selectA-2.45 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY a,b,c
+ }
+} {{} C c 1 a a 9.9 b B}
+do_test selectA-2.46 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY a,b,c
+ }
+} {{} C c 1 a a 9.9 b B}
+do_test selectA-2.47 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY a DESC
+ }
+} {9.9 b B 1 a a {} C c}
+do_test selectA-2.48 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY a DESC
+ }
+} {abc e e hello d D}
+do_test selectA-2.49 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY a DESC
+ }
+} {abc e e hello d D}
+do_test selectA-2.50 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY a DESC
+ }
+} {abc e e hello d D}
+do_test selectA-2.51 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY a DESC
+ }
+} {9.9 b B 1 a a {} C c}
+do_test selectA-2.52 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY a DESC
+ }
+} {9.9 b B 1 a a {} C c}
+do_test selectA-2.53 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY b, a DESC
+ }
+} {{} C c 1 a a 9.9 b B}
+do_test selectA-2.54 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY b
+ }
+} {hello d D abc e e}
+do_test selectA-2.55 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY b DESC, c
+ }
+} {abc e e hello d D}
+do_test selectA-2.56 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY b, c DESC, a
+ }
+} {hello d D abc e e}
+do_test selectA-2.57 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY b COLLATE NOCASE
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-2.58 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY b
+ }
+} {{} C c 1 a a 9.9 b B}
+do_test selectA-2.59 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY c, a DESC
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-2.60 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY c
+ }
+} {hello d D abc e e}
+do_test selectA-2.61 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY c COLLATE BINARY, b DESC, c, a, b, c, a, b, c
+ }
+} {hello d D abc e e}
+do_test selectA-2.62 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY c DESC, a
+ }
+} {abc e e hello d D}
+do_test selectA-2.63 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY c COLLATE NOCASE
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-2.64 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY c
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-2.65 {
+ execsql {
+ SELECT a,b,c FROM t3 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY c COLLATE NOCASE
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-2.66 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t3
+ ORDER BY c
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-2.67 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t3 WHERE b<'d'
+ ORDER BY c DESC, a
+ }
+} {abc e e hello d D}
+do_test selectA-2.68 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT b,c,a FROM t3
+ ORDER BY c DESC, a
+ }
+} {abc e e hello d D}
+do_test selectA-2.69 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT b,c,a FROM t3
+ ORDER BY c COLLATE NOCASE
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-2.70 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT b,c,a FROM t3
+ ORDER BY c
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-2.71 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d'
+ INTERSECT SELECT a,b,c FROM t1
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT b,c,a FROM t3
+ INTERSECT SELECT a,b,c FROM t1
+ EXCEPT SELECT x,y,z FROM t2
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT y,x,z FROM t2
+ INTERSECT SELECT a,b,c FROM t1
+ EXCEPT SELECT c,b,a FROM t3
+ ORDER BY c
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-2.72 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.73 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-2.74 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.75 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-2.76 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.77 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE DESC,a,c
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.78 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.79 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.80 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.81 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-2.82 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.83 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-2.84 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-2.85 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-2.86 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.87 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY y COLLATE NOCASE DESC,x,z
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.88 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.89 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-2.90 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.91 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-2.92 {
+ execsql {
+ SELECT x,y,z FROM t2
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT c,b,a FROM t1
+ UNION SELECT a,b,c FROM t3
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT c,b,a FROM t1
+ UNION SELECT a,b,c FROM t3
+ ORDER BY y COLLATE NOCASE DESC,x,z
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-2.93 {
+ execsql {
+ SELECT upper((SELECT c FROM t1 UNION SELECT z FROM t2 ORDER BY 1));
+ }
+} {A}
+do_test selectA-2.94 {
+ execsql {
+ SELECT lower((SELECT c FROM t1 UNION ALL SELECT z FROM t2 ORDER BY 1));
+ }
+} {a}
+do_test selectA-2.95 {
+ execsql {
+ SELECT lower((SELECT c FROM t1 INTERSECT SELECT z FROM t2 ORDER BY 1));
+ }
+} {{}}
+do_test selectA-2.96 {
+ execsql {
+ SELECT lower((SELECT z FROM t2 EXCEPT SELECT c FROM t1 ORDER BY 1));
+ }
+} {m}
+
+
+do_test selectA-3.0 {
+ execsql {
+ CREATE UNIQUE INDEX t1a ON t1(a);
+ CREATE UNIQUE INDEX t1b ON t1(b);
+ CREATE UNIQUE INDEX t1c ON t1(c);
+ CREATE UNIQUE INDEX t2x ON t2(x);
+ CREATE UNIQUE INDEX t2y ON t2(y);
+ CREATE UNIQUE INDEX t2z ON t2(z);
+ SELECT name FROM sqlite_master WHERE type='index'
+ }
+} {t1a t1b t1c t2x t2y t2z}
+do_test selectA-3.1 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.1.1 { # Ticket #3314
+ execsql {
+ SELECT t1.a,b,t1.c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY a,t1.b,t1.c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.2 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-3.3 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.4 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-3.5 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.6 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE DESC,a,c
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.7 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.8 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.9 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.10 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-3.11 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.12 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-3.13 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.14 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-3.15 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.16 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY b COLLATE NOCASE DESC,a,c
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.17 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.18 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.19 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.20 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-3.21 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.22 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-3.23 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.24 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-3.25 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.26 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE DESC,a,c
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.27 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.28 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.29 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.30 {
+ execsql {
+ SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-3.31 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.32 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-3.33 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.34 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-3.35 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.36 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY b COLLATE NOCASE DESC,a,c
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.37 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.38 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.39 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.40 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-3.41 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY a,b,c
+ }
+} {{} C c 1 a a 9.9 b B}
+do_test selectA-3.42 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY a,b,c
+ }
+} {hello d D abc e e}
+do_test selectA-3.43 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY a,b,c
+ }
+} {hello d D abc e e}
+do_test selectA-3.44 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY a,b,c
+ }
+} {hello d D abc e e}
+do_test selectA-3.45 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY a,b,c
+ }
+} {{} C c 1 a a 9.9 b B}
+do_test selectA-3.46 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY a,b,c
+ }
+} {{} C c 1 a a 9.9 b B}
+do_test selectA-3.47 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY a DESC
+ }
+} {9.9 b B 1 a a {} C c}
+do_test selectA-3.48 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY a DESC
+ }
+} {abc e e hello d D}
+do_test selectA-3.49 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY a DESC
+ }
+} {abc e e hello d D}
+do_test selectA-3.50 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY a DESC
+ }
+} {abc e e hello d D}
+do_test selectA-3.51 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY a DESC
+ }
+} {9.9 b B 1 a a {} C c}
+do_test selectA-3.52 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY a DESC
+ }
+} {9.9 b B 1 a a {} C c}
+do_test selectA-3.53 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY b, a DESC
+ }
+} {{} C c 1 a a 9.9 b B}
+do_test selectA-3.54 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY b
+ }
+} {hello d D abc e e}
+do_test selectA-3.55 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY b DESC, c
+ }
+} {abc e e hello d D}
+do_test selectA-3.56 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY b, c DESC, a
+ }
+} {hello d D abc e e}
+do_test selectA-3.57 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY b COLLATE NOCASE
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-3.58 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY b
+ }
+} {{} C c 1 a a 9.9 b B}
+do_test selectA-3.59 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY c, a DESC
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-3.60 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
+ ORDER BY c
+ }
+} {hello d D abc e e}
+do_test selectA-3.61 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY c COLLATE BINARY, b DESC, c, a, b, c, a, b, c
+ }
+} {hello d D abc e e}
+do_test selectA-3.62 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY c DESC, a
+ }
+} {abc e e hello d D}
+do_test selectA-3.63 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY c COLLATE NOCASE
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-3.64 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
+ ORDER BY c
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-3.65 {
+ execsql {
+ SELECT a,b,c FROM t3 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ ORDER BY c COLLATE NOCASE
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-3.66 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t3
+ ORDER BY c
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-3.67 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t3 WHERE b<'d'
+ ORDER BY c DESC, a
+ }
+} {abc e e hello d D}
+do_test selectA-3.68 {
+ execsql {
+ SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT b,c,a FROM t3
+ ORDER BY c DESC, a
+ }
+} {abc e e hello d D}
+do_test selectA-3.69 {
+ execsql {
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT b,c,a FROM t3
+ ORDER BY c COLLATE NOCASE
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-3.70 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT b,c,a FROM t3
+ ORDER BY c
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-3.71 {
+ execsql {
+ SELECT a,b,c FROM t1 WHERE b<'d'
+ INTERSECT SELECT a,b,c FROM t1
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT b,c,a FROM t3
+ INTERSECT SELECT a,b,c FROM t1
+ EXCEPT SELECT x,y,z FROM t2
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT y,x,z FROM t2
+ INTERSECT SELECT a,b,c FROM t1
+ EXCEPT SELECT c,b,a FROM t3
+ ORDER BY c
+ }
+} {1 a a 9.9 b B {} C c}
+do_test selectA-3.72 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.73 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-3.74 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.75 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-3.76 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.77 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY b COLLATE NOCASE DESC,a,c
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.78 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.79 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.80 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.81 {
+ execsql {
+ SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-3.82 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY a,b,c
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.83 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY a DESC,b,c
+ }
+} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
+do_test selectA-3.84 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY a,c,b
+ }
+} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
+do_test selectA-3.85 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY b,a,c
+ }
+} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
+do_test selectA-3.86 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY b COLLATE NOCASE,a,c
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.87 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY y COLLATE NOCASE DESC,x,z
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.88 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY c,b,a
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.89 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY c,a,b
+ }
+} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
+do_test selectA-3.90 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY c DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.91 {
+ execsql {
+ SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
+ ORDER BY c COLLATE BINARY DESC,a,b
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
+do_test selectA-3.92 {
+ execsql {
+ SELECT x,y,z FROM t2
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT c,b,a FROM t1
+ UNION SELECT a,b,c FROM t3
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT c,b,a FROM t1
+ UNION SELECT a,b,c FROM t3
+ ORDER BY y COLLATE NOCASE DESC,x,z
+ }
+} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
+do_test selectA-3.93 {
+ execsql {
+ SELECT upper((SELECT c FROM t1 UNION SELECT z FROM t2 ORDER BY 1));
+ }
+} {A}
+do_test selectA-3.94 {
+ execsql {
+ SELECT lower((SELECT c FROM t1 UNION ALL SELECT z FROM t2 ORDER BY 1));
+ }
+} {a}
+do_test selectA-3.95 {
+ execsql {
+ SELECT lower((SELECT c FROM t1 INTERSECT SELECT z FROM t2 ORDER BY 1));
+ }
+} {{}}
+do_test selectA-3.96 {
+ execsql {
+ SELECT lower((SELECT z FROM t2 EXCEPT SELECT c FROM t1 ORDER BY 1));
+ }
+} {m}
+do_test selectA-3.97 {
+ execsql {
+ SELECT upper((SELECT x FROM (
+ SELECT x,y,z FROM t2
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT c,b,a FROM t1
+ UNION SELECT a,b,c FROM t3
+ INTERSECT SELECT a,b,c FROM t3
+ EXCEPT SELECT c,b,a FROM t1
+ UNION SELECT a,b,c FROM t3
+ ORDER BY y COLLATE NOCASE DESC,x,z)))
+ }
+} {MAD}
+
+finish_test
diff --git a/test/selectB.test b/test/selectB.test
new file mode 100644
index 0000000..b9d979a
--- /dev/null
+++ b/test/selectB.test
@@ -0,0 +1,381 @@
+# 2008 June 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# $Id: selectB.test,v 1.10 2009/04/02 16:59:47 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+proc test_transform {testname sql1 sql2 results} {
+ set ::vdbe1 [list]
+ set ::vdbe2 [list]
+ db eval "explain $sql1" { lappend ::vdbe1 $opcode }
+ db eval "explain $sql2" { lappend ::vdbe2 $opcode }
+
+ do_test $testname.transform {
+ set ::vdbe1
+ } $::vdbe2
+
+ set ::sql1 $sql1
+ do_test $testname.sql1 {
+ execsql $::sql1
+ } $results
+
+ set ::sql2 $sql2
+ do_test $testname.sql2 {
+ execsql $::sql2
+ } $results
+}
+
+do_test selectB-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e, f);
+
+ INSERT INTO t1 VALUES( 2, 4, 6);
+ INSERT INTO t1 VALUES( 8, 10, 12);
+ INSERT INTO t1 VALUES(14, 16, 18);
+
+ INSERT INTO t2 VALUES(3, 6, 9);
+ INSERT INTO t2 VALUES(12, 15, 18);
+ INSERT INTO t2 VALUES(21, 24, 27);
+ }
+} {}
+
+for {set ii 1} {$ii <= 2} {incr ii} {
+
+ if {$ii == 2} {
+ do_test selectB-2.1 {
+ execsql {
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t2(d);
+ }
+ } {}
+ }
+
+ test_transform selectB-$ii.2 {
+ SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2)
+ } {
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2
+ } {2 8 14 3 12 21}
+
+ test_transform selectB-$ii.3 {
+ SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2) ORDER BY 1
+ } {
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1
+ } {2 3 8 12 14 21}
+
+ test_transform selectB-$ii.4 {
+ SELECT * FROM
+ (SELECT a FROM t1 UNION ALL SELECT d FROM t2)
+ WHERE a>10 ORDER BY 1
+ } {
+ SELECT a FROM t1 WHERE a>10 UNION ALL SELECT d FROM t2 WHERE d>10 ORDER BY 1
+ } {12 14 21}
+
+ test_transform selectB-$ii.5 {
+ SELECT * FROM
+ (SELECT a FROM t1 UNION ALL SELECT d FROM t2)
+ WHERE a>10 ORDER BY a
+ } {
+ SELECT a FROM t1 WHERE a>10
+ UNION ALL
+ SELECT d FROM t2 WHERE d>10
+ ORDER BY a
+ } {12 14 21}
+
+ test_transform selectB-$ii.6 {
+ SELECT * FROM
+ (SELECT a FROM t1 UNION ALL SELECT d FROM t2 WHERE d > 12)
+ WHERE a>10 ORDER BY a
+ } {
+ SELECT a FROM t1 WHERE a>10
+ UNION ALL
+ SELECT d FROM t2 WHERE d>12 AND d>10
+ ORDER BY a
+ } {14 21}
+
+ test_transform selectB-$ii.7 {
+ SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2) ORDER BY 1
+ LIMIT 2
+ } {
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 LIMIT 2
+ } {2 3}
+
+ test_transform selectB-$ii.8 {
+ SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2) ORDER BY 1
+ LIMIT 2 OFFSET 3
+ } {
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 LIMIT 2 OFFSET 3
+ } {12 14}
+
+ test_transform selectB-$ii.9 {
+ SELECT * FROM (
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 UNION ALL SELECT c FROM t1
+ )
+ } {
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 UNION ALL SELECT c FROM t1
+ } {2 8 14 3 12 21 6 12 18}
+
+ test_transform selectB-$ii.10 {
+ SELECT * FROM (
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 UNION ALL SELECT c FROM t1
+ ) ORDER BY 1
+ } {
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 UNION ALL SELECT c FROM t1
+ ORDER BY 1
+ } {2 3 6 8 12 12 14 18 21}
+
+ test_transform selectB-$ii.11 {
+ SELECT * FROM (
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 UNION ALL SELECT c FROM t1
+ ) WHERE a>=10 ORDER BY 1 LIMIT 3
+ } {
+ SELECT a FROM t1 WHERE a>=10 UNION ALL SELECT d FROM t2 WHERE d>=10
+ UNION ALL SELECT c FROM t1 WHERE c>=10
+ ORDER BY 1 LIMIT 3
+ } {12 12 14}
+
+ test_transform selectB-$ii.12 {
+ SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2 LIMIT 2)
+ } {
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 LIMIT 2
+ } {2 8}
+
+ # An ORDER BY in a compound subqueries defeats flattening. Ticket #3773
+ # test_transform selectB-$ii.13 {
+ # SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY a ASC)
+ # } {
+ # SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 ASC
+ # } {2 3 8 12 14 21}
+ #
+ # test_transform selectB-$ii.14 {
+ # SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY a DESC)
+ # } {
+ # SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 DESC
+ # } {21 14 12 8 3 2}
+ #
+ # test_transform selectB-$ii.14 {
+ # SELECT * FROM (
+ # SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY a DESC
+ # ) LIMIT 2 OFFSET 2
+ # } {
+ # SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 DESC
+ # LIMIT 2 OFFSET 2
+ # } {12 8}
+ #
+ # test_transform selectB-$ii.15 {
+ # SELECT * FROM (
+ # SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY a ASC, e DESC
+ # )
+ # } {
+ # SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY a ASC, e DESC
+ # } {2 4 3 6 8 10 12 15 14 16 21 24}
+}
+
+do_test selectB-3.0 {
+ execsql {
+ DROP INDEX i1;
+ DROP INDEX i2;
+ }
+} {}
+
+for {set ii 3} {$ii <= 4} {incr ii} {
+
+ if {$ii == 4} {
+ do_test selectB-4.0 {
+ execsql {
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+ CREATE INDEX i3 ON t1(c);
+ CREATE INDEX i4 ON t2(d);
+ CREATE INDEX i5 ON t2(e);
+ CREATE INDEX i6 ON t2(f);
+ }
+ } {}
+ }
+
+ do_test selectB-$ii.1 {
+ execsql {
+ SELECT DISTINCT * FROM
+ (SELECT c FROM t1 UNION ALL SELECT e FROM t2)
+ ORDER BY 1;
+ }
+ } {6 12 15 18 24}
+
+ do_test selectB-$ii.2 {
+ execsql {
+ SELECT c, count(*) FROM
+ (SELECT c FROM t1 UNION ALL SELECT e FROM t2)
+ GROUP BY c ORDER BY 1;
+ }
+ } {6 2 12 1 15 1 18 1 24 1}
+ do_test selectB-$ii.3 {
+ execsql {
+ SELECT c, count(*) FROM
+ (SELECT c FROM t1 UNION ALL SELECT e FROM t2)
+ GROUP BY c HAVING count(*)>1;
+ }
+ } {6 2}
+ do_test selectB-$ii.4 {
+ execsql {
+ SELECT t4.c, t3.a FROM
+ (SELECT c FROM t1 UNION ALL SELECT e FROM t2) AS t4, t1 AS t3
+ WHERE t3.a=14
+ ORDER BY 1
+ }
+ } {6 14 6 14 12 14 15 14 18 14 24 14}
+
+ do_test selectB-$ii.5 {
+ execsql {
+ SELECT d FROM t2
+ EXCEPT
+ SELECT a FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2)
+ }
+ } {}
+ do_test selectB-$ii.6 {
+ execsql {
+ SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2)
+ EXCEPT
+ SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2)
+ }
+ } {}
+ do_test selectB-$ii.7 {
+ execsql {
+ SELECT c FROM t1
+ EXCEPT
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ }
+ } {12}
+ do_test selectB-$ii.8 {
+ execsql {
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ EXCEPT
+ SELECT c FROM t1
+ }
+ } {9 15 24 27}
+ do_test selectB-$ii.9 {
+ execsql {
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ EXCEPT
+ SELECT c FROM t1
+ ORDER BY c DESC
+ }
+ } {27 24 15 9}
+
+ do_test selectB-$ii.10 {
+ execsql {
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ UNION
+ SELECT c FROM t1
+ ORDER BY c DESC
+ }
+ } {27 24 18 15 12 9 6}
+ do_test selectB-$ii.11 {
+ execsql {
+ SELECT c FROM t1
+ UNION
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ ORDER BY c
+ }
+ } {6 9 12 15 18 24 27}
+ do_test selectB-$ii.12 {
+ execsql {
+ SELECT c FROM t1 UNION SELECT e FROM t2 UNION ALL SELECT f FROM t2
+ ORDER BY c
+ }
+ } {6 9 12 15 18 18 24 27}
+ do_test selectB-$ii.13 {
+ execsql {
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ UNION
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ ORDER BY 1
+ }
+ } {6 9 15 18 24 27}
+
+ do_test selectB-$ii.14 {
+ execsql {
+ SELECT c FROM t1
+ INTERSECT
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ ORDER BY 1
+ }
+ } {6 18}
+ do_test selectB-$ii.15 {
+ execsql {
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ INTERSECT
+ SELECT c FROM t1
+ ORDER BY 1
+ }
+ } {6 18}
+ do_test selectB-$ii.16 {
+ execsql {
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ INTERSECT
+ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)
+ ORDER BY 1
+ }
+ } {6 9 15 18 24 27}
+
+ do_test selectB-$ii.17 {
+ execsql {
+ SELECT * FROM (
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 LIMIT 4
+ ) LIMIT 2
+ }
+ } {2 8}
+
+ do_test selectB-$ii.18 {
+ execsql {
+ SELECT * FROM (
+ SELECT a FROM t1 UNION ALL SELECT d FROM t2 LIMIT 4 OFFSET 2
+ ) LIMIT 2
+ }
+ } {14 3}
+
+ do_test selectB-$ii.19 {
+ execsql {
+ SELECT * FROM (
+ SELECT DISTINCT (a/10) FROM t1 UNION ALL SELECT DISTINCT(d%2) FROM t2
+ )
+ }
+ } {0 1 1 0}
+
+ do_test selectB-$ii.20 {
+ execsql {
+ SELECT DISTINCT * FROM (
+ SELECT DISTINCT (a/10) FROM t1 UNION ALL SELECT DISTINCT(d%2) FROM t2
+ )
+ }
+ } {0 1}
+
+ do_test selectB-$ii.21 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 UNION ALL SELECT * FROM t2) ORDER BY a+b
+ }
+ } {2 4 6 3 6 9 8 10 12 12 15 18 14 16 18 21 24 27}
+
+ do_test selectB-$ii.21 {
+ execsql {
+ SELECT * FROM (SELECT 345 UNION ALL SELECT d FROM t2) ORDER BY 1;
+ }
+ } {3 12 21 345}
+}
+
+finish_test
diff --git a/test/selectC.test b/test/selectC.test
new file mode 100644
index 0000000..fd38405
--- /dev/null
+++ b/test/selectC.test
@@ -0,0 +1,236 @@
+# 2008 September 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# $Id: selectC.test,v 1.5 2009/05/17 15:26:21 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Ticket #
+do_test selectC-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1,'aaa','bbb');
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 VALUES(2,'ccc','ddd');
+
+ SELECT DISTINCT a AS x, b||c AS y
+ FROM t1
+ WHERE y IN ('aaabbb','xxx');
+ }
+} {1 aaabbb}
+do_test selectC-1.2 {
+ execsql {
+ SELECT DISTINCT a AS x, b||c AS y
+ FROM t1
+ WHERE b||c IN ('aaabbb','xxx');
+ }
+} {1 aaabbb}
+do_test selectC-1.3 {
+ execsql {
+ SELECT DISTINCT a AS x, b||c AS y
+ FROM t1
+ WHERE y='aaabbb'
+ }
+} {1 aaabbb}
+do_test selectC-1.4 {
+ execsql {
+ SELECT DISTINCT a AS x, b||c AS y
+ FROM t1
+ WHERE b||c='aaabbb'
+ }
+} {1 aaabbb}
+do_test selectC-1.5 {
+ execsql {
+ SELECT DISTINCT a AS x, b||c AS y
+ FROM t1
+ WHERE x=2
+ }
+} {2 cccddd}
+do_test selectC-1.6 {
+ execsql {
+ SELECT DISTINCT a AS x, b||c AS y
+ FROM t1
+ WHERE a=2
+ }
+} {2 cccddd}
+do_test selectC-1.7 {
+ execsql {
+ SELECT DISTINCT a AS x, b||c AS y
+ FROM t1
+ WHERE +y='aaabbb'
+ }
+} {1 aaabbb}
+do_test selectC-1.8 {
+ execsql {
+ SELECT a AS x, b||c AS y
+ FROM t1
+ GROUP BY x, y
+ HAVING y='aaabbb'
+ }
+} {1 aaabbb}
+do_test selectC-1.9 {
+ execsql {
+ SELECT a AS x, b||c AS y
+ FROM t1
+ GROUP BY x, y
+ HAVING b||c='aaabbb'
+ }
+} {1 aaabbb}
+do_test selectC-1.10 {
+ execsql {
+ SELECT a AS x, b||c AS y
+ FROM t1
+ WHERE y='aaabbb'
+ GROUP BY x, y
+ }
+} {1 aaabbb}
+do_test selectC-1.11 {
+ execsql {
+ SELECT a AS x, b||c AS y
+ FROM t1
+ WHERE b||c='aaabbb'
+ GROUP BY x, y
+ }
+} {1 aaabbb}
+proc longname_toupper x {return [string toupper $x]}
+db function uppercaseconversionfunctionwithaverylongname longname_toupper
+do_test selectC-1.12.1 {
+ execsql {
+ SELECT DISTINCT upper(b) AS x
+ FROM t1
+ ORDER BY x
+ }
+} {AAA CCC}
+do_test selectC-1.12.2 {
+ execsql {
+ SELECT DISTINCT uppercaseconversionfunctionwithaverylongname(b) AS x
+ FROM t1
+ ORDER BY x
+ }
+} {AAA CCC}
+do_test selectC-1.13.1 {
+ execsql {
+ SELECT upper(b) AS x
+ FROM t1
+ GROUP BY x
+ ORDER BY x
+ }
+} {AAA CCC}
+do_test selectC-1.13.2 {
+ execsql {
+ SELECT uppercaseconversionfunctionwithaverylongname(b) AS x
+ FROM t1
+ GROUP BY x
+ ORDER BY x
+ }
+} {AAA CCC}
+do_test selectC-1.14.1 {
+ execsql {
+ SELECT upper(b) AS x
+ FROM t1
+ ORDER BY x DESC
+ }
+} {CCC AAA AAA}
+do_test selectC-1.14.2 {
+ execsql {
+ SELECT uppercaseconversionfunctionwithaverylongname(b) AS x
+ FROM t1
+ ORDER BY x DESC
+ }
+} {CCC AAA AAA}
+
+# The following query used to leak memory. Verify that has been fixed.
+#
+ifcapable trigger {
+ do_test selectC-2.1 {
+ catchsql {
+ CREATE TABLE t21a(a,b);
+ INSERT INTO t21a VALUES(1,2);
+ CREATE TABLE t21b(n);
+ CREATE TRIGGER r21 AFTER INSERT ON t21b BEGIN
+ SELECT a FROM t21a WHERE a>new.x UNION ALL
+ SELECT b FROM t21a WHERE b>new.x ORDER BY 1 LIMIT 2;
+ END;
+ INSERT INTO t21b VALUES(6);
+ }
+ } {1 {no such column: new.x}}
+}
+
+# Check that ticket [883034dcb5] is fixed.
+#
+do_test selectC-3.1 {
+ execsql {
+ CREATE TABLE person (
+ org_id TEXT NOT NULL,
+ nickname TEXT NOT NULL,
+ license TEXT,
+ CONSTRAINT person_pk PRIMARY KEY (org_id, nickname),
+ CONSTRAINT person_license_uk UNIQUE (license)
+ );
+ INSERT INTO person VALUES('meyers', 'jack', '2GAT123');
+ INSERT INTO person VALUES('meyers', 'hill', 'V345FMP');
+ INSERT INTO person VALUES('meyers', 'jim', '2GAT138');
+ INSERT INTO person VALUES('smith', 'maggy', '');
+ INSERT INTO person VALUES('smith', 'jose', 'JJZ109');
+ INSERT INTO person VALUES('smith', 'jack', 'THX138');
+ INSERT INTO person VALUES('lakeside', 'dave', '953OKG');
+ INSERT INTO person VALUES('lakeside', 'amy', NULL);
+ INSERT INTO person VALUES('lake-apts', 'tom', NULL);
+ INSERT INTO person VALUES('acorn', 'hideo', 'CQB421');
+
+ SELECT
+ org_id,
+ count((NOT (org_id IS NULL)) AND (NOT (nickname IS NULL)))
+ FROM person
+ WHERE (CASE WHEN license != '' THEN 1 ELSE 0 END)
+ GROUP BY 1;
+ }
+} {acorn 1 lakeside 1 meyers 3 smith 2}
+do_test selectC-3.2 {
+ execsql {
+ CREATE TABLE t2(a PRIMARY KEY, b);
+ INSERT INTO t2 VALUES('abc', 'xxx');
+ INSERT INTO t2 VALUES('def', 'yyy');
+ SELECT a, max(b || a) FROM t2 WHERE (b||b||b)!='value' GROUP BY a;
+ }
+} {abc xxxabc def yyydef}
+do_test selectC-3.3 {
+ execsql {
+ SELECT b, max(a || b) FROM t2 WHERE (b||b||b)!='value' GROUP BY a;
+ }
+} {xxx abcxxx yyy defyyy}
+
+
+proc udf {} { incr ::udf }
+set ::udf 0
+db function udf udf
+
+do_execsql_test selectC-4.1 {
+ create table t_distinct_bug (a, b, c);
+ insert into t_distinct_bug values ('1', '1', 'a');
+ insert into t_distinct_bug values ('1', '2', 'b');
+ insert into t_distinct_bug values ('1', '3', 'c');
+ insert into t_distinct_bug values ('1', '1', 'd');
+ insert into t_distinct_bug values ('1', '2', 'e');
+ insert into t_distinct_bug values ('1', '3', 'f');
+} {}
+
+do_execsql_test selectC-4.2 {
+ select a from (select distinct a, b from t_distinct_bug)
+} {1 1 1}
+
+do_execsql_test selectC-4.3 {
+ select a, udf() from (select distinct a, b from t_distinct_bug)
+} {1 1 1 2 1 3}
+
+finish_test
diff --git a/test/server1.test b/test/server1.test
new file mode 100644
index 0000000..90673ef
--- /dev/null
+++ b/test/server1.test
@@ -0,0 +1,171 @@
+# 2006 January 09
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the server mode of SQLite.
+#
+# This file is derived from thread1.test
+#
+# $Id: server1.test,v 1.5 2007/08/29 18:20:17 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Skip this whole file if the server testing code is not enabled
+#
+if {[llength [info command client_step]]==0 || [sqlite3 -has-codec]} {
+ finish_test
+ return
+}
+
+# The sample server implementation does not work right when memory
+# management is enabled.
+#
+ifcapable (memorymanage||mutex_noop) {
+ finish_test
+ return
+}
+
+# Create some data to work with
+#
+do_test server1-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,'abcdefgh');
+ INSERT INTO t1 SELECT a+1, b||b FROM t1;
+ INSERT INTO t1 SELECT a+2, b||b FROM t1;
+ INSERT INTO t1 SELECT a+4, b||b FROM t1;
+ SELECT count(*), max(length(b)) FROM t1;
+ }
+} {8 64}
+
+# Interleave two threads on read access. Then make sure a third
+# thread can write the database. In other words:
+#
+# read-lock A
+# read-lock B
+# unlock A
+# unlock B
+# write-lock C
+#
+do_test server1-1.2 {
+ client_create A test.db
+ client_create B test.db
+ client_create C test.db
+ client_compile A {SELECT a FROM t1}
+ client_step A
+ client_result A
+} SQLITE_ROW
+do_test server1-1.3 {
+ client_argc A
+} 1
+do_test server1-1.4 {
+ client_argv A 0
+} 1
+do_test server1-1.5 {
+ client_compile B {SELECT b FROM t1}
+ client_step B
+ client_result B
+} SQLITE_ROW
+do_test server1-1.6 {
+ client_argc B
+} 1
+do_test server1-1.7 {
+ client_argv B 0
+} abcdefgh
+do_test server1-1.8 {
+ client_finalize A
+ client_result A
+} SQLITE_OK
+do_test server1-1.9 {
+ client_finalize B
+ client_result B
+} SQLITE_OK
+do_test server1-1.10 {
+ client_compile C {CREATE TABLE t2(x,y)}
+ client_step C
+ client_result C
+} SQLITE_DONE
+do_test server1-1.11 {
+ client_finalize C
+ client_result C
+} SQLITE_OK
+do_test server1-1.12 {
+ catchsql {SELECT name FROM sqlite_master}
+ execsql {SELECT name FROM sqlite_master}
+} {t1 t2}
+
+
+# Read from table t1. Do not finalize the statement. This
+# will leave the lock pending.
+#
+do_test server1-2.1 {
+ client_halt *
+ client_create A test.db
+ client_compile A {SELECT a FROM t1}
+ client_step A
+ client_result A
+} SQLITE_ROW
+
+# Read from the same table from another thread. This is allows.
+#
+do_test server1-2.2 {
+ client_create B test.db
+ client_compile B {SELECT b FROM t1}
+ client_step B
+ client_result B
+} SQLITE_ROW
+
+# Write to a different table from another thread. This is allowed
+# because in server mode with a shared cache we have table-level locking.
+#
+do_test server1-2.3 {
+ client_create C test.db
+ client_compile C {INSERT INTO t2 VALUES(98,99)}
+ client_step C
+ client_result C
+ client_finalize C
+ client_result C
+} SQLITE_OK
+
+# But we cannot insert into table t1 because threads A and B have it locked.
+#
+do_test server1-2.4 {
+ client_compile C {INSERT INTO t1 VALUES(98,99)}
+ client_step C
+ client_result C
+ client_finalize C
+ client_result C
+} SQLITE_LOCKED
+do_test server1-2.5 {
+ client_finalize B
+ client_wait B
+ client_compile C {INSERT INTO t1 VALUES(98,99)}
+ client_step C
+ client_result C
+ client_finalize C
+ client_result C
+} SQLITE_LOCKED
+
+# Insert into t1 is successful after finishing the other two threads.
+do_test server1-2.6 {
+ client_finalize A
+ client_wait A
+ client_compile C {INSERT INTO t1 VALUES(98,99)}
+ client_step C
+ client_result C
+ client_finalize C
+ client_result C
+} SQLITE_OK
+
+client_halt *
+sqlite3_enable_shared_cache 0
+finish_test
diff --git a/test/shared.test b/test/shared.test
new file mode 100644
index 0000000..37564e6
--- /dev/null
+++ b/test/shared.test
@@ -0,0 +1,1062 @@
+# 2005 December 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: shared.test,v 1.36 2009/03/16 13:19:36 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db close
+
+# These tests cannot be run without the ATTACH command.
+#
+ifcapable !shared_cache||!attach {
+ finish_test
+ return
+}
+
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+foreach av [list 0 1] {
+
+# Open the database connection and execute the auto-vacuum pragma
+forcedelete test.db
+sqlite3 db test.db
+
+ifcapable autovacuum {
+ do_test shared-[expr $av+1].1.0 {
+ execsql "pragma auto_vacuum=$::av"
+ execsql {pragma auto_vacuum}
+ } "$av"
+} else {
+ if {$av} {
+ db close
+ break
+ }
+}
+
+# if we're using proxy locks, we use 2 filedescriptors for a db
+# that is open but NOT yet locked, after a lock is taken we'll have 3,
+# normally sqlite uses 1 (proxy locking adds the conch and the local lock)
+set using_proxy 0
+foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
+ set using_proxy $value
+}
+set extrafds_prelock 0
+set extrafds_postlock 0
+if {$using_proxy>0} {
+ set extrafds_prelock 1
+ set extrafds_postlock 2
+}
+
+# $av is currently 0 if this loop iteration is to test with auto-vacuum turned
+# off, and 1 if it is turned on. Increment it so that (1 -> no auto-vacuum)
+# and (2 -> auto-vacuum). The sole reason for this is so that it looks nicer
+# when we use this variable as part of test-case names.
+#
+incr av
+
+# Test organization:
+#
+# shared-1.*: Simple test to verify basic sanity of table level locking when
+# two connections share a pager cache.
+# shared-2.*: Test that a read transaction can co-exist with a
+# write-transaction, including a simple test to ensure the
+# external locking protocol is still working.
+# shared-3.*: Simple test of read-uncommitted mode.
+# shared-4.*: Check that the schema is locked and unlocked correctly.
+# shared-5.*: Test that creating/dropping schema items works when databases
+# are attached in different orders to different handles.
+# shared-6.*: Locking, UNION ALL queries and sub-queries.
+# shared-7.*: Autovacuum and shared-cache.
+# shared-8.*: Tests related to the text encoding of shared-cache databases.
+# shared-9.*: TEMP triggers and shared-cache databases.
+# shared-10.*: Tests of sqlite3_close().
+# shared-11.*: Test transaction locking.
+#
+
+do_test shared-$av.1.1 {
+ # Open a second database on the file test.db. It should use the same pager
+ # cache and schema as the original connection. Verify that only 1 file is
+ # opened.
+ sqlite3 db2 test.db
+ set ::sqlite_open_file_count
+ expr $sqlite_open_file_count-$extrafds_postlock
+} {1}
+do_test shared-$av.1.2 {
+ # Add a table and a single row of data via the first connection.
+ # Ensure that the second connection can see them.
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ } db
+ execsql {
+ SELECT * FROM abc;
+ } db2
+} {1 2 3}
+do_test shared-$av.1.3 {
+ # Have the first connection begin a transaction and obtain a read-lock
+ # on table abc. This should not prevent the second connection from
+ # querying abc.
+ execsql {
+ BEGIN;
+ SELECT * FROM abc;
+ }
+ execsql {
+ SELECT * FROM abc;
+ } db2
+} {1 2 3}
+do_test shared-$av.1.4 {
+ # Try to insert a row into abc via connection 2. This should fail because
+ # of the read-lock connection 1 is holding on table abc (obtained in the
+ # previous test case).
+ catchsql {
+ INSERT INTO abc VALUES(4, 5, 6);
+ } db2
+} {1 {database table is locked: abc}}
+do_test shared-$av.1.5 {
+ # Using connection 2 (the one without the open transaction), try to create
+ # a new table. This should fail because of the open read transaction
+ # held by connection 1.
+ catchsql {
+ CREATE TABLE def(d, e, f);
+ } db2
+} {1 {database table is locked: sqlite_master}}
+do_test shared-$av.1.6 {
+ # Upgrade connection 1's transaction to a write transaction. Create
+ # a new table - def - and insert a row into it. Because the connection 1
+ # transaction modifies the schema, it should not be possible for
+ # connection 2 to access the database at all until the connection 1
+ # has finished the transaction.
+ execsql {
+ CREATE TABLE def(d, e, f);
+ INSERT INTO def VALUES('IV', 'V', 'VI');
+ }
+} {}
+do_test shared-$av.1.7 {
+ # Read from the sqlite_master table with connection 1 (inside the
+ # transaction). Then test that we can not do this with connection 2. This
+ # is because of the schema-modified lock established by connection 1
+ # in the previous test case.
+ execsql {
+ SELECT * FROM sqlite_master;
+ }
+ catchsql {
+ SELECT * FROM sqlite_master;
+ } db2
+} {1 {database schema is locked: main}}
+do_test shared-$av.1.8 {
+ # Commit the connection 1 transaction.
+ execsql {
+ COMMIT;
+ }
+} {}
+
+do_test shared-$av.2.1 {
+ # Open connection db3 to the database. Use a different path to the same
+ # file so that db3 does *not* share the same pager cache as db and db2
+ # (there should be two open file handles).
+ if {$::tcl_platform(platform)=="unix"} {
+ sqlite3 db3 ./test.db
+ } else {
+ sqlite3 db3 TEST.DB
+ }
+ set ::sqlite_open_file_count
+ expr $sqlite_open_file_count-($extrafds_prelock+$extrafds_postlock)
+} {2}
+do_test shared-$av.2.2 {
+ # Start read transactions on db and db2 (the shared pager cache). Ensure
+ # db3 cannot write to the database.
+ execsql {
+ BEGIN;
+ SELECT * FROM abc;
+ }
+ execsql {
+ BEGIN;
+ SELECT * FROM abc;
+ } db2
+ catchsql {
+ INSERT INTO abc VALUES(1, 2, 3);
+ } db2
+} {1 {database table is locked: abc}}
+do_test shared-$av.2.3 {
+ # Turn db's transaction into a write-transaction. db3 should still be
+ # able to read from table def (but will not see the new row). Connection
+ # db2 should not be able to read def (because of the write-lock).
+
+# Todo: The failed "INSERT INTO abc ..." statement in the above test
+# has started a write-transaction on db2 (should this be so?). This
+# would prevent connection db from starting a write-transaction. So roll the
+# db2 transaction back and replace it with a new read transaction.
+ execsql {
+ ROLLBACK;
+ BEGIN;
+ SELECT * FROM abc;
+ } db2
+
+ execsql {
+ INSERT INTO def VALUES('VII', 'VIII', 'IX');
+ }
+ concat [
+ catchsql { SELECT * FROM def; } db3
+ ] [
+ catchsql { SELECT * FROM def; } db2
+ ]
+} {0 {IV V VI} 1 {database table is locked: def}}
+do_test shared-$av.2.4 {
+ # Commit the open transaction on db. db2 still holds a read-transaction.
+ # This should prevent db3 from writing to the database, but not from
+ # reading.
+ execsql {
+ COMMIT;
+ }
+ concat [
+ catchsql { SELECT * FROM def; } db3
+ ] [
+ catchsql { INSERT INTO def VALUES('X', 'XI', 'XII'); } db3
+ ]
+} {0 {IV V VI VII VIII IX} 1 {database is locked}}
+
+catchsql COMMIT db2
+
+do_test shared-$av.3.1.1 {
+ # This test case starts a linear scan of table 'seq' using a
+ # read-uncommitted connection. In the middle of the scan, rows are added
+ # to the end of the seq table (ahead of the current cursor position).
+ # The uncommitted rows should be included in the results of the scan.
+ execsql "
+ CREATE TABLE seq(i PRIMARY KEY, x);
+ INSERT INTO seq VALUES(1, '[string repeat X 500]');
+ INSERT INTO seq VALUES(2, '[string repeat X 500]');
+ "
+ execsql {SELECT * FROM sqlite_master} db2
+ execsql {PRAGMA read_uncommitted = 1} db2
+
+ set ret [list]
+ db2 eval {SELECT i FROM seq ORDER BY i} {
+ if {$i < 4} {
+ set max [execsql {SELECT max(i) FROM seq}]
+ db eval {
+ INSERT INTO seq SELECT i + :max, x FROM seq;
+ }
+ }
+ lappend ret $i
+ }
+ set ret
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}
+do_test shared-$av.3.1.2 {
+ # Another linear scan through table seq using a read-uncommitted connection.
+ # This time, delete each row as it is read. Should not affect the results of
+ # the scan, but the table should be empty after the scan is concluded
+ # (test 3.1.3 verifies this).
+ set ret [list]
+ db2 eval {SELECT i FROM seq} {
+ db eval {DELETE FROM seq WHERE i = :i}
+ lappend ret $i
+ }
+ set ret
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}
+do_test shared-$av.3.1.3 {
+ execsql {
+ SELECT * FROM seq;
+ }
+} {}
+
+catch {db close}
+catch {db2 close}
+catch {db3 close}
+
+#--------------------------------------------------------------------------
+# Tests shared-4.* test that the schema locking rules are applied
+# correctly. i.e.:
+#
+# 1. All transactions require a read-lock on the schemas of databases they
+# access.
+# 2. Transactions that modify a database schema require a write-lock on that
+# schema.
+# 3. It is not possible to compile a statement while another handle has a
+# write-lock on the schema.
+#
+
+# Open two database handles db and db2. Each has a single attach database
+# (as well as main):
+#
+# db.main -> ./test.db
+# db.test2 -> ./test2.db
+# db2.main -> ./test2.db
+# db2.test -> ./test.db
+#
+forcedelete test.db
+forcedelete test2.db
+forcedelete test2.db-journal
+sqlite3 db test.db
+sqlite3 db2 test2.db
+do_test shared-$av.4.1.1 {
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-($extrafds_prelock*2)
+} {2}
+do_test shared-$av.4.1.2 {
+ execsql {ATTACH 'test2.db' AS test2}
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-($extrafds_postlock*2)
+} {2}
+do_test shared-$av.4.1.3 {
+ execsql {ATTACH 'test.db' AS test} db2
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-($extrafds_postlock*2)
+} {2}
+
+# Sanity check: Create a table in ./test.db via handle db, and test that handle
+# db2 can "see" the new table immediately. A handle using a seperate pager
+# cache would have to reload the database schema before this were possible.
+#
+do_test shared-$av.4.2.1 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ CREATE TABLE def(d, e, f);
+ INSERT INTO abc VALUES('i', 'ii', 'iii');
+ INSERT INTO def VALUES('I', 'II', 'III');
+ }
+} {}
+do_test shared-$av.4.2.2 {
+ execsql {
+ SELECT * FROM test.abc;
+ } db2
+} {i ii iii}
+
+# Open a read-transaction and read from table abc via handle 2. Check that
+# handle 1 can read table abc. Check that handle 1 cannot modify table abc
+# or the database schema. Then check that handle 1 can modify table def.
+#
+do_test shared-$av.4.3.1 {
+ execsql {
+ BEGIN;
+ SELECT * FROM test.abc;
+ } db2
+} {i ii iii}
+do_test shared-$av.4.3.2 {
+ catchsql {
+ INSERT INTO abc VALUES('iv', 'v', 'vi');
+ }
+} {1 {database table is locked: abc}}
+do_test shared-$av.4.3.3 {
+ catchsql {
+ CREATE TABLE ghi(g, h, i);
+ }
+} {1 {database table is locked: sqlite_master}}
+do_test shared-$av.4.3.3 {
+ catchsql {
+ INSERT INTO def VALUES('IV', 'V', 'VI');
+ }
+} {0 {}}
+do_test shared-$av.4.3.4 {
+ # Cleanup: commit the transaction opened by db2.
+ execsql {
+ COMMIT
+ } db2
+} {}
+
+# Open a write-transaction using handle 1 and modify the database schema.
+# Then try to execute a compiled statement to read from the same
+# database via handle 2 (fails to get the lock on sqlite_master). Also
+# try to compile a read of the same database using handle 2 (also fails).
+# Finally, compile a read of the other database using handle 2. This
+# should also fail.
+#
+ifcapable compound {
+ do_test shared-$av.4.4.1.2 {
+ # Sanity check 1: Check that the schema is what we think it is when viewed
+ # via handle 1.
+ execsql {
+ CREATE TABLE test2.ghi(g, h, i);
+ SELECT 'test.db:'||name FROM sqlite_master
+ UNION ALL
+ SELECT 'test2.db:'||name FROM test2.sqlite_master;
+ }
+ } {test.db:abc test.db:def test2.db:ghi}
+ do_test shared-$av.4.4.1.2 {
+ # Sanity check 2: Check that the schema is what we think it is when viewed
+ # via handle 2.
+ execsql {
+ SELECT 'test2.db:'||name FROM sqlite_master
+ UNION ALL
+ SELECT 'test.db:'||name FROM test.sqlite_master;
+ } db2
+ } {test2.db:ghi test.db:abc test.db:def}
+}
+
+do_test shared-$av.4.4.2 {
+ set ::DB2 [sqlite3_connection_pointer db2]
+ set sql {SELECT * FROM abc}
+ set ::STMT1 [sqlite3_prepare $::DB2 $sql -1 DUMMY]
+ execsql {
+ BEGIN;
+ CREATE TABLE jkl(j, k, l);
+ }
+ sqlite3_step $::STMT1
+} {SQLITE_ERROR}
+do_test shared-$av.4.4.3 {
+ sqlite3_finalize $::STMT1
+} {SQLITE_LOCKED}
+do_test shared-$av.4.4.4 {
+ set rc [catch {
+ set ::STMT1 [sqlite3_prepare $::DB2 $sql -1 DUMMY]
+ } msg]
+ list $rc $msg
+} {1 {(6) database schema is locked: test}}
+do_test shared-$av.4.4.5 {
+ set rc [catch {
+ set ::STMT1 [sqlite3_prepare $::DB2 "SELECT * FROM ghi" -1 DUMMY]
+ } msg]
+ list $rc $msg
+} {1 {(6) database schema is locked: test}}
+
+
+catch {db2 close}
+catch {db close}
+
+#--------------------------------------------------------------------------
+# Tests shared-5.*
+#
+foreach db [list test.db test1.db test2.db test3.db] {
+ forcedelete $db ${db}-journal
+}
+do_test shared-$av.5.1.1 {
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+ execsql {
+ ATTACH 'test1.db' AS test1;
+ ATTACH 'test2.db' AS test2;
+ ATTACH 'test3.db' AS test3;
+ } db1
+ execsql {
+ ATTACH 'test3.db' AS test3;
+ ATTACH 'test2.db' AS test2;
+ ATTACH 'test1.db' AS test1;
+ } db2
+} {}
+do_test shared-$av.5.1.2 {
+ execsql {
+ CREATE TABLE test1.t1(a, b);
+ CREATE INDEX test1.i1 ON t1(a, b);
+ } db1
+} {}
+ifcapable view {
+ do_test shared-$av.5.1.3 {
+ execsql {
+ CREATE VIEW test1.v1 AS SELECT * FROM t1;
+ } db1
+ } {}
+}
+ifcapable trigger {
+ do_test shared-$av.5.1.4 {
+ execsql {
+ CREATE TRIGGER test1.trig1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t1 VALUES(new.a, new.b);
+ END;
+ } db1
+ } {}
+}
+do_test shared-$av.5.1.5 {
+ execsql {
+ DROP INDEX i1;
+ } db2
+} {}
+ifcapable view {
+ do_test shared-$av.5.1.6 {
+ execsql {
+ DROP VIEW v1;
+ } db2
+ } {}
+}
+ifcapable trigger {
+ do_test shared-$av.5.1.7 {
+ execsql {
+ DROP TRIGGER trig1;
+ } db2
+ } {}
+}
+do_test shared-$av.5.1.8 {
+ execsql {
+ DROP TABLE t1;
+ } db2
+} {}
+ifcapable compound {
+ do_test shared-$av.5.1.9 {
+ execsql {
+ SELECT * FROM sqlite_master UNION ALL SELECT * FROM test1.sqlite_master
+ } db1
+ } {}
+}
+
+#--------------------------------------------------------------------------
+# Tests shared-6.* test that a query obtains all the read-locks it needs
+# before starting execution of the query. This means that there is no chance
+# some rows of data will be returned before a lock fails and SQLITE_LOCK
+# is returned.
+#
+do_test shared-$av.6.1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ } db1
+} {}
+ifcapable compound {
+ do_test shared-$av.6.1.2 {
+ execsql {
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2;
+ } db2
+ } {1 2 3 4}
+}
+do_test shared-$av.6.1.3 {
+ # Establish a write lock on table t2 via connection db2. Then make a
+ # UNION all query using connection db1 that first accesses t1, followed
+ # by t2. If the locks are grabbed at the start of the statement (as
+ # they should be), no rows are returned. If (as was previously the case)
+ # they are grabbed as the tables are accessed, the t1 rows will be
+ # returned before the query fails.
+ #
+ execsql {
+ BEGIN;
+ INSERT INTO t2 VALUES(5, 6);
+ } db2
+ set ret [list]
+ catch {
+ db1 eval {SELECT * FROM t1 UNION ALL SELECT * FROM t2} {
+ lappend ret $a $b
+ }
+ }
+ set ret
+} {}
+do_test shared-$av.6.1.4 {
+ execsql {
+ COMMIT;
+ BEGIN;
+ INSERT INTO t1 VALUES(7, 8);
+ } db2
+ set ret [list]
+ catch {
+ db1 eval {
+ SELECT (CASE WHEN a>4 THEN (SELECT a FROM t1) ELSE 0 END) AS d FROM t2;
+ } {
+ lappend ret $d
+ }
+ }
+ set ret
+} {}
+
+catch {db1 close}
+catch {db2 close}
+foreach f [list test.db test2.db] {
+ forcedelete $f ${f}-journal
+}
+
+#--------------------------------------------------------------------------
+# Tests shared-7.* test auto-vacuum does not invalidate cursors from
+# other shared-cache users when it reorganizes the database on
+# COMMIT.
+#
+do_test shared-$av.7.1 {
+ # This test case sets up a test database in auto-vacuum mode consisting
+ # of two tables, t1 and t2. Both have a single index. Table t1 is
+ # populated first (so consists of pages toward the start of the db file),
+ # t2 second (pages toward the end of the file).
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TABLE t2(a PRIMARY KEY, b);
+ }
+ set ::contents {}
+ for {set i 0} {$i < 100} {incr i} {
+ set a [string repeat "$i " 20]
+ set b [string repeat "$i " 20]
+ db eval {
+ INSERT INTO t1 VALUES(:a, :b);
+ }
+ lappend ::contents [list [expr $i+1] $a $b]
+ }
+ execsql {
+ INSERT INTO t2 SELECT * FROM t1;
+ COMMIT;
+ }
+} {}
+do_test shared-$av.7.2 {
+ # This test case deletes the contents of table t1 (the one at the start of
+ # the file) while many cursors are open on table t2 and its index. All of
+ # the non-root pages will be moved from the end to the start of the file
+ # when the DELETE is committed - this test verifies that moving the pages
+ # does not disturb the open cursors.
+ #
+
+ proc lockrow {db tbl oids body} {
+ set ret [list]
+ db eval "SELECT oid AS i, a, b FROM $tbl ORDER BY a" {
+ if {$i==[lindex $oids 0]} {
+ set noids [lrange $oids 1 end]
+ if {[llength $noids]==0} {
+ set subret [eval $body]
+ } else {
+ set subret [lockrow $db $tbl $noids $body]
+ }
+ }
+ lappend ret [list $i $a $b]
+ }
+ return [linsert $subret 0 $ret]
+ }
+ proc locktblrows {db tbl body} {
+ set oids [db eval "SELECT oid FROM $tbl"]
+ lockrow $db $tbl $oids $body
+ }
+
+ set scans [locktblrows db t2 {
+ execsql {
+ DELETE FROM t1;
+ } db2
+ }]
+ set error 0
+
+ # Test that each SELECT query returned the expected contents of t2.
+ foreach s $scans {
+ if {[lsort -integer -index 0 $s]!=$::contents} {
+ set error 1
+ }
+ }
+ set error
+} {0}
+
+catch {db close}
+catch {db2 close}
+unset -nocomplain contents
+
+#--------------------------------------------------------------------------
+# The following tests try to trick the shared-cache code into assuming
+# the wrong encoding for a database.
+#
+forcedelete test.db test.db-journal
+ifcapable utf16 {
+ do_test shared-$av.8.1.1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA encoding = 'UTF-16';
+ SELECT * FROM sqlite_master;
+ }
+ } {}
+ do_test shared-$av.8.1.2 {
+ string range [execsql {PRAGMA encoding;}] 0 end-2
+ } {UTF-16}
+
+ do_test shared-$av.8.1.3 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA encoding = 'UTF-8';
+ CREATE TABLE abc(a, b, c);
+ } db2
+ } {}
+ do_test shared-$av.8.1.4 {
+ execsql {
+ SELECT * FROM sqlite_master;
+ }
+ } "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}"
+ do_test shared-$av.8.1.5 {
+ db2 close
+ execsql {
+ PRAGMA encoding;
+ }
+ } {UTF-8}
+
+ forcedelete test2.db test2.db-journal
+ do_test shared-$av.8.2.1 {
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ SELECT * FROM aux.sqlite_master;
+ }
+ } {}
+ do_test shared-$av.8.2.2 {
+ sqlite3 db2 test2.db
+ execsql {
+ PRAGMA encoding = 'UTF-16';
+ CREATE TABLE def(d, e, f);
+ } db2
+ string range [execsql {PRAGMA encoding;} db2] 0 end-2
+ } {UTF-16}
+
+ catch {db close}
+ catch {db2 close}
+ forcedelete test.db test2.db
+
+ do_test shared-$av.8.3.2 {
+ sqlite3 db test.db
+ execsql { CREATE TABLE def(d, e, f) }
+ execsql { PRAGMA encoding }
+ } {UTF-8}
+ do_test shared-$av.8.3.3 {
+ set zDb16 "[encoding convertto unicode test.db]\x00\x00"
+ set db16 [sqlite3_open16 $zDb16 {}]
+
+ set stmt [sqlite3_prepare $db16 "SELECT sql FROM sqlite_master" -1 DUMMY]
+ sqlite3_step $stmt
+ set sql [sqlite3_column_text $stmt 0]
+ sqlite3_finalize $stmt
+ set sql
+ } {CREATE TABLE def(d, e, f)}
+ do_test shared-$av.8.3.4 {
+ set stmt [sqlite3_prepare $db16 "PRAGMA encoding" -1 DUMMY]
+ sqlite3_step $stmt
+ set enc [sqlite3_column_text $stmt 0]
+ sqlite3_finalize $stmt
+ set enc
+ } {UTF-8}
+
+ sqlite3_close $db16
+
+# Bug #2547 is causing this to fail.
+if 0 {
+ do_test shared-$av.8.2.3 {
+ catchsql {
+ SELECT * FROM aux.sqlite_master;
+ }
+ } {1 {attached databases must use the same text encoding as main database}}
+}
+}
+
+catch {db close}
+catch {db2 close}
+forcedelete test.db test2.db
+
+#---------------------------------------------------------------------------
+# The following tests - shared-9.* - test interactions between TEMP triggers
+# and shared-schemas.
+#
+ifcapable trigger&&tempdb {
+
+do_test shared-$av.9.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ CREATE TABLE abc_mirror(a, b, c);
+ CREATE TEMP TRIGGER BEFORE INSERT ON abc BEGIN
+ INSERT INTO abc_mirror(a, b, c) VALUES(new.a, new.b, new.c);
+ END;
+ INSERT INTO abc VALUES(1, 2, 3);
+ SELECT * FROM abc_mirror;
+ }
+} {1 2 3}
+do_test shared-$av.9.2 {
+ execsql {
+ INSERT INTO abc VALUES(4, 5, 6);
+ SELECT * FROM abc_mirror;
+ } db2
+} {1 2 3}
+do_test shared-$av.9.3 {
+ db close
+ db2 close
+} {}
+
+} ; # End shared-9.*
+
+#---------------------------------------------------------------------------
+# The following tests - shared-10.* - test that the library behaves
+# correctly when a connection to a shared-cache is closed.
+#
+do_test shared-$av.10.1 {
+ # Create a small sample database with two connections to it (db and db2).
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql {
+ CREATE TABLE ab(a PRIMARY KEY, b);
+ CREATE TABLE de(d PRIMARY KEY, e);
+ INSERT INTO ab VALUES('Chiang Mai', 100000);
+ INSERT INTO ab VALUES('Bangkok', 8000000);
+ INSERT INTO de VALUES('Ubon', 120000);
+ INSERT INTO de VALUES('Khon Kaen', 200000);
+ }
+} {}
+do_test shared-$av.10.2 {
+ # Open a read-transaction with the first connection, a write-transaction
+ # with the second.
+ execsql {
+ BEGIN;
+ SELECT * FROM ab;
+ }
+ execsql {
+ BEGIN;
+ INSERT INTO de VALUES('Pataya', 30000);
+ } db2
+} {}
+do_test shared-$av.10.3 {
+ # An external connection should be able to read the database, but not
+ # prepare a write operation.
+ if {$::tcl_platform(platform)=="unix"} {
+ sqlite3 db3 ./test.db
+ } else {
+ sqlite3 db3 TEST.DB
+ }
+ execsql {
+ SELECT * FROM ab;
+ } db3
+ catchsql {
+ BEGIN;
+ INSERT INTO de VALUES('Pataya', 30000);
+ } db3
+} {1 {database is locked}}
+do_test shared-$av.10.4 {
+ # Close the connection with the write-transaction open
+ db2 close
+} {}
+do_test shared-$av.10.5 {
+ # Test that the db2 transaction has been automatically rolled back.
+ # If it has not the ('Pataya', 30000) entry will still be in the table.
+ execsql {
+ SELECT * FROM de;
+ }
+} {Ubon 120000 {Khon Kaen} 200000}
+do_test shared-$av.10.5 {
+ # Closing db2 should have dropped the shared-cache back to a read-lock.
+ # So db3 should be able to prepare a write...
+ catchsql {INSERT INTO de VALUES('Pataya', 30000);} db3
+} {0 {}}
+do_test shared-$av.10.6 {
+ # ... but not commit it.
+ catchsql {COMMIT} db3
+} {1 {database is locked}}
+do_test shared-$av.10.7 {
+ # Commit the (read-only) db transaction. Check via db3 to make sure the
+ # contents of table "de" are still as they should be.
+ execsql {
+ COMMIT;
+ }
+ execsql {
+ SELECT * FROM de;
+ } db3
+} {Ubon 120000 {Khon Kaen} 200000 Pataya 30000}
+do_test shared-$av.10.9 {
+ # Commit the external transaction.
+ catchsql {COMMIT} db3
+} {0 {}}
+integrity_check shared-$av.10.10
+do_test shared-$av.10.11 {
+ db close
+ db3 close
+} {}
+
+do_test shared-$av.11.1 {
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ CREATE TABLE abc2(a, b, c);
+ BEGIN;
+ INSERT INTO abc VALUES(1, 2, 3);
+ }
+} {}
+do_test shared-$av.11.2 {
+ catchsql {BEGIN;} db2
+ catchsql {SELECT * FROM abc;} db2
+} {1 {database table is locked: abc}}
+do_test shared-$av.11.3 {
+ catchsql {BEGIN} db2
+} {1 {cannot start a transaction within a transaction}}
+do_test shared-$av.11.4 {
+ catchsql {SELECT * FROM abc2;} db2
+} {0 {}}
+do_test shared-$av.11.5 {
+ catchsql {INSERT INTO abc2 VALUES(1, 2, 3);} db2
+} {1 {database table is locked}}
+do_test shared-$av.11.6 {
+ catchsql {SELECT * FROM abc2}
+} {0 {}}
+do_test shared-$av.11.6 {
+ execsql {
+ ROLLBACK;
+ PRAGMA read_uncommitted = 1;
+ } db2
+} {}
+do_test shared-$av.11.7 {
+ execsql {
+ INSERT INTO abc2 VALUES(4, 5, 6);
+ INSERT INTO abc2 VALUES(7, 8, 9);
+ }
+} {}
+do_test shared-$av.11.8 {
+ set res [list]
+ db2 eval {
+ SELECT abc.a as I, abc2.a as II FROM abc, abc2;
+ } {
+ execsql {
+ DELETE FROM abc WHERE 1;
+ }
+ lappend res $I $II
+ }
+ set res
+} {1 4 {} 7}
+if {[llength [info command sqlite3_shared_cache_report]]==1} {
+ do_test shared-$av.11.9 {
+ string tolower [sqlite3_shared_cache_report]
+ } [string tolower [list [file nativename [file normalize test.db]] 2]]
+}
+
+do_test shared-$av.11.11 {
+ db close
+ db2 close
+} {}
+
+# This tests that if it is impossible to free any pages, SQLite will
+# exceed the limit set by PRAGMA cache_size.
+forcedelete test.db test.db-journal
+sqlite3 db test.db
+ifcapable pager_pragmas {
+ do_test shared-$av.12.1 {
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA cache_size;
+ }
+ } {10}
+}
+do_test shared-$av.12.2 {
+ set ::db_handles [list]
+ for {set i 1} {$i < 15} {incr i} {
+ lappend ::db_handles db$i
+ sqlite3 db$i test.db
+ execsql "CREATE TABLE db${i}(a, b, c)" db$i
+ execsql "INSERT INTO db${i} VALUES(1, 2, 3)"
+ }
+} {}
+proc nested_select {handles} {
+ [lindex $handles 0] eval "SELECT * FROM [lindex $handles 0]" {
+ lappend ::res $a $b $c
+ if {[llength $handles]>1} {
+ nested_select [lrange $handles 1 end]
+ }
+ }
+}
+do_test shared-$av.12.3 {
+ set ::res [list]
+ nested_select $::db_handles
+ set ::res
+} [string range [string repeat "1 2 3 " [llength $::db_handles]] 0 end-1]
+
+do_test shared-$av.12.X {
+ db close
+ foreach h $::db_handles {
+ $h close
+ }
+} {}
+
+# Internally, locks are acquired on shared B-Tree structures in the order
+# that the structures appear in the virtual memory address space. This
+# test case attempts to cause the order of the structures in memory
+# to be different from the order in which they are attached to a given
+# database handle. This covers an extra line or two.
+#
+do_test shared-$av.13.1 {
+ forcedelete test2.db test3.db test4.db test5.db
+ sqlite3 db :memory:
+ execsql {
+ ATTACH 'test2.db' AS aux2;
+ ATTACH 'test3.db' AS aux3;
+ ATTACH 'test4.db' AS aux4;
+ ATTACH 'test5.db' AS aux5;
+ DETACH aux2;
+ DETACH aux3;
+ DETACH aux4;
+ ATTACH 'test2.db' AS aux2;
+ ATTACH 'test3.db' AS aux3;
+ ATTACH 'test4.db' AS aux4;
+ }
+} {}
+do_test shared-$av.13.2 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE aux2.t2(a, b, c);
+ CREATE TABLE aux3.t3(a, b, c);
+ CREATE TABLE aux4.t4(a, b, c);
+ CREATE TABLE aux5.t5(a, b, c);
+ SELECT count(*) FROM
+ aux2.sqlite_master,
+ aux3.sqlite_master,
+ aux4.sqlite_master,
+ aux5.sqlite_master
+ }
+} {1}
+do_test shared-$av.13.3 {
+ db close
+} {}
+
+# Test that nothing horrible happens if a connection to a shared B-Tree
+# structure is closed while some other connection has an open cursor.
+#
+do_test shared-$av.14.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql {SELECT name FROM sqlite_master}
+} {db1 db2 db3 db4 db5 db6 db7 db8 db9 db10 db11 db12 db13 db14}
+do_test shared-$av.14.2 {
+ set res [list]
+ db eval {SELECT name FROM sqlite_master} {
+ if {$name eq "db7"} {
+ db2 close
+ }
+ lappend res $name
+ }
+ set res
+} {db1 db2 db3 db4 db5 db6 db7 db8 db9 db10 db11 db12 db13 db14}
+do_test shared-$av.14.3 {
+ db close
+} {}
+
+# Populate a database schema using connection [db]. Then drop it using
+# [db2]. This is to try to find any points where shared-schema elements
+# are allocated using the lookaside buffer of [db].
+#
+# Mutexes are enabled for this test as that activates a couple of useful
+# assert() statements in the C code.
+#
+do_test shared-$av-15.1 {
+ forcedelete test.db
+ sqlite3 db test.db -fullmutex 1
+ sqlite3 db2 test.db -fullmutex 1
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(a, b);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE VIEW v2 AS SELECT * FROM t1, v1
+ WHERE t1.c=v1.c GROUP BY t1.a ORDER BY v1.b;
+ CREATE TRIGGER tr1 AFTER INSERT ON t1
+ WHEN new.a!=1
+ BEGIN
+ DELETE FROM t1 WHERE a=5;
+ INSERT INTO t1 VALUES(1, 2, 3);
+ UPDATE t1 SET c=c+1;
+ END;
+
+ INSERT INTO t1 VALUES(5, 6, 7);
+ INSERT INTO t1 VALUES(8, 9, 10);
+ INSERT INTO t1 VALUES(11, 12, 13);
+ ANALYZE;
+ SELECT * FROM t1;
+ }
+} {1 2 6 8 9 12 1 2 5 11 12 14 1 2 4}
+do_test shared-$av-15.2 {
+ execsql { DROP TABLE t1 } db2
+} {}
+db close
+db2 close
+
+}
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/shared2.test b/test/shared2.test
new file mode 100644
index 0000000..d40c9a2
--- /dev/null
+++ b/test/shared2.test
@@ -0,0 +1,181 @@
+# 2005 January 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: shared2.test,v 1.8 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+db close
+
+ifcapable !shared_cache {
+ finish_test
+ return
+}
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+# Test that if we delete all rows from a table any read-uncommitted
+# cursors are correctly invalidated. Test on both table and index btrees.
+do_test shared2-1.1 {
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+
+ # Set up some data. Table "numbers" has 64 rows after this block
+ # is executed.
+ execsql {
+ BEGIN;
+ CREATE TABLE numbers(a PRIMARY KEY, b);
+ INSERT INTO numbers(oid) VALUES(NULL);
+ INSERT INTO numbers(oid) SELECT NULL FROM numbers;
+ INSERT INTO numbers(oid) SELECT NULL FROM numbers;
+ INSERT INTO numbers(oid) SELECT NULL FROM numbers;
+ INSERT INTO numbers(oid) SELECT NULL FROM numbers;
+ INSERT INTO numbers(oid) SELECT NULL FROM numbers;
+ INSERT INTO numbers(oid) SELECT NULL FROM numbers;
+ UPDATE numbers set a = oid, b = 'abcdefghijklmnopqrstuvwxyz0123456789';
+ COMMIT;
+ } db1
+} {}
+do_test shared2-1.2 {
+ # Put connection 2 in read-uncommitted mode and start a SELECT on table
+ # 'numbers'. Half way through the SELECT, use connection 1 to delete the
+ # contents of this table.
+ execsql {
+ pragma read_uncommitted = 1;
+ } db2
+ set count [execsql {SELECT count(*) FROM numbers} db2]
+ db2 eval {SELECT a FROM numbers ORDER BY oid} {
+ if {$a==32} {
+ execsql {
+ BEGIN;
+ DELETE FROM numbers;
+ } db1
+ }
+ }
+ list $a $count
+} {32 64}
+do_test shared2-1.3 {
+ # Same test as 1.2, except scan using the index this time.
+ execsql {
+ ROLLBACK;
+ } db1
+ set count [execsql {SELECT count(*) FROM numbers} db2]
+ db2 eval {SELECT a, b FROM numbers ORDER BY a} {
+ if {$a==32} {
+ execsql {
+ DELETE FROM numbers;
+ } db1
+ }
+ }
+ list $a $count
+} {32 64}
+
+#---------------------------------------------------------------------------
+# These tests, shared2.2.*, test the outcome when data is added to or
+# removed from a table due to a rollback while a read-uncommitted
+# cursor is scanning it.
+#
+do_test shared2-2.1 {
+ execsql {
+ INSERT INTO numbers VALUES(1, 'Medium length text field');
+ INSERT INTO numbers VALUES(2, 'Medium length text field');
+ INSERT INTO numbers VALUES(3, 'Medium length text field');
+ INSERT INTO numbers VALUES(4, 'Medium length text field');
+ BEGIN;
+ DELETE FROM numbers WHERE (a%2)=0;
+ } db1
+ set res [list]
+ db2 eval {
+ SELECT a FROM numbers ORDER BY a;
+ } {
+ lappend res $a
+ if {$a==3} {
+ execsql {ROLLBACK} db1
+ }
+ }
+ set res
+} {1 3 4}
+do_test shared2-2.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO numbers VALUES(5, 'Medium length text field');
+ INSERT INTO numbers VALUES(6, 'Medium length text field');
+ } db1
+ set res [list]
+ db2 eval {
+ SELECT a FROM numbers ORDER BY a;
+ } {
+ lappend res $a
+ if {$a==5} {
+ execsql {ROLLBACK} db1
+ }
+ }
+ set res
+} {1 2 3 4 5}
+
+db1 close
+db2 close
+
+do_test shared2-3.2 {
+ sqlite3_enable_shared_cache 1
+} {1}
+
+forcedelete test.db
+
+sqlite3 db test.db
+do_test shared2-4.1 {
+ execsql {
+ CREATE TABLE t0(a, b);
+ CREATE TABLE t1(a, b DEFAULT 'hello world');
+ }
+} {}
+db close
+
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+do_test shared2-4.2 {
+ execsql { SELECT a, b FROM t0 } db
+ execsql { INSERT INTO t1(a) VALUES(1) } db2
+} {}
+
+do_test shared2-4.3 {
+ db2 close
+ db close
+} {}
+
+# At one point, this was causing a crash.
+#
+do_test shared2-5.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql { CREATE TABLE t2(a, b, c) }
+
+ # The following statement would crash when attempting to sqlite3_free()
+ # a pointer allocated from a lookaside buffer.
+ execsql { CREATE INDEX i1 ON t2(a) } db2
+} {}
+
+db close
+db2 close
+
+# The following test verifies that shared-cache mode does not automatically
+# turn on exclusive-locking mode for some reason.
+do_multiclient_test {tn} {
+ sql1 { CREATE TABLE t1(a, b) }
+ sql2 { CREATE TABLE t2(a, b) }
+ do_test shared2-6.$tn.1 { sql1 { SELECT * FROM t2 } } {}
+ do_test shared2-6.$tn.2 { sql2 { SELECT * FROM t1 } } {}
+}
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/shared3.test b/test/shared3.test
new file mode 100644
index 0000000..783ae6a
--- /dev/null
+++ b/test/shared3.test
@@ -0,0 +1,107 @@
+# 2005 January 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: shared3.test,v 1.4 2008/08/20 14:49:25 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db close
+
+ifcapable !shared_cache {
+ finish_test
+ return
+}
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+# Ticket #1824
+#
+do_test shared3-1.1 {
+ forcedelete test.db test.db-journal
+ sqlite3 db1 test.db
+ db1 eval {
+ PRAGMA encoding=UTF16;
+ CREATE TABLE t1(x,y);
+ INSERT INTO t1 VALUES('abc','This is a test string');
+ }
+ db1 close
+ sqlite3 db1 test.db
+ db1 eval {SELECT * FROM t1}
+} {abc {This is a test string}}
+do_test shared3-1.2 {
+ sqlite3 db2 test.db
+ db2 eval {SELECT y FROM t1 WHERE x='abc'}
+} {{This is a test string}}
+
+db1 close
+db2 close
+
+do_test shared3-2.1 {
+ sqlite3 db1 test.db
+ execsql {
+ PRAGMA main.cache_size = 10;
+ } db1
+} {}
+do_test shared3-2.2 {
+ execsql { PRAGMA main.cache_size } db1
+} {10}
+do_test shared3-2.3 {
+ sqlite3 db2 test.db
+ execsql { PRAGMA main.cache_size } db1
+} {10}
+do_test shared3-2.4 {
+ execsql { PRAGMA main.cache_size } db2
+} {10}
+do_test shared3-2.5 {
+ execsql { PRAGMA main.cache_size } db1
+} {10}
+
+# The cache-size should now be 10 pages. However at one point there was
+# a bug that caused the cache size to return to the default value when
+# a second connection was opened on the shared-cache (as happened in
+# test case shared3-2.3 above). The goal of the following tests is to
+# ensure that the cache-size really is 10 pages.
+#
+if {$::tcl_platform(platform)=="unix"} {
+ set alternative_name ./test.db
+} else {
+ set alternative_name TEST.DB
+}
+do_test shared3-2.6 {
+ sqlite3 db3 $alternative_name
+ catchsql {select count(*) from sqlite_master} db3
+} {0 1}
+do_test shared3-2.7 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(10, randomblob(5000))
+ } db1
+ catchsql {select count(*) from sqlite_master} db3
+} {0 1}
+do_test shared3-2.8 {
+ db3 close
+ execsql {
+ INSERT INTO t1 VALUES(10, randomblob(10000))
+ } db1
+
+ # If the pager-cache is really still limited to 10 pages, then the INSERT
+ # statement above should have caused the pager to grab an exclusive lock
+ # on the database file so that the cache could be spilled.
+ #
+ catch { sqlite3 db3 $alternative_name }
+ catchsql {select count(*) from sqlite_master} db3
+} {1 {database is locked}}
+
+db1 close
+db2 close
+db3 close
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/shared4.test b/test/shared4.test
new file mode 100644
index 0000000..83925b0
--- /dev/null
+++ b/test/shared4.test
@@ -0,0 +1,237 @@
+# 2008 July 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test the btree mutex protocol for shared cache mode.
+#
+# $Id: shared4.test,v 1.2 2008/08/04 03:51:24 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db close
+puts hello
+
+# This script is only valid if we are running shared-cache mode in a
+# threadsafe-capable database engine.
+#
+ifcapable !shared_cache||!compound {
+ finish_test
+ return
+}
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+# Prepare multiple databases in shared cache mode.
+#
+do_test shared4-1.1 {
+ forcedelete test1.db test1.db-journal
+ forcedelete test2.db test2.db-journal
+ forcedelete test3.db test3.db-journal
+ forcedelete test4.db test4.db-journal
+ sqlite3 db1 test1.db
+ sqlite3 db2 test2.db
+ sqlite3 db3 test3.db
+ sqlite3 db4 test4.db
+ db1 eval {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(111);
+ }
+ db2 eval {
+ CREATE TABLE t2(b);
+ INSERT INTO t2 VALUES(222);
+ }
+ db3 eval {
+ CREATE TABLE t3(c);
+ INSERT INTO t3 VALUES(333);
+ }
+ db4 eval {
+ CREATE TABLE t4(d);
+ INSERT INTO t4 VALUES(444);
+ }
+ db1 eval {
+ ATTACH DATABASE 'test2.db' AS two;
+ ATTACH DATABASE 'test3.db' AS three;
+ ATTACH DATABASE 'test4.db' AS four;
+ }
+ db2 eval {
+ ATTACH DATABASE 'test4.db' AS four;
+ ATTACH DATABASE 'test3.db' AS three;
+ ATTACH DATABASE 'test1.db' AS one;
+ }
+ db3 eval {
+ ATTACH DATABASE 'test1.db' AS one;
+ ATTACH DATABASE 'test2.db' AS two;
+ ATTACH DATABASE 'test4.db' AS four;
+ }
+ db4 eval {
+ ATTACH DATABASE 'test3.db' AS three;
+ ATTACH DATABASE 'test2.db' AS two;
+ ATTACH DATABASE 'test1.db' AS one;
+ }
+ db1 eval {
+ SELECT a FROM t1 UNION ALL
+ SELECT b FROM t2 UNION ALL
+ SELECT c FROM t3 UNION ALL
+ SELECT d FROM t4;
+ }
+} {111 222 333 444}
+do_test shared4-1.2 {
+ db2 eval {
+ SELECT a FROM t1 UNION ALL
+ SELECT b FROM t2 UNION ALL
+ SELECT d FROM t4 UNION ALL
+ SELECT c FROM t3;
+ }
+} {111 222 444 333}
+do_test shared4-1.3 {
+ db3 eval {
+ SELECT a FROM t1 UNION ALL
+ SELECT c FROM t3 UNION ALL
+ SELECT b FROM t2 UNION ALL
+ SELECT d FROM t4;
+ }
+} {111 333 222 444}
+do_test shared4-1.4 {
+ db4 eval {
+ SELECT a FROM t1 UNION ALL
+ SELECT c FROM t3 UNION ALL
+ SELECT d FROM t4 UNION ALL
+ SELECT b FROM t2;
+ }
+} {111 333 444 222}
+do_test shared4-1.5 {
+ db3 eval {
+ SELECT a FROM t1 UNION ALL
+ SELECT d FROM t4 UNION ALL
+ SELECT b FROM t2 UNION ALL
+ SELECT c FROM t3;
+ }
+} {111 444 222 333}
+do_test shared4-1.6 {
+ db4 eval {
+ SELECT a FROM t1 UNION ALL
+ SELECT d FROM t4 UNION ALL
+ SELECT c FROM t3 UNION ALL
+ SELECT b FROM t2;
+ }
+} {111 444 333 222}
+do_test shared4-1.7 {
+ db1 eval {
+ SELECT b FROM t2 UNION ALL
+ SELECT a FROM t1 UNION ALL
+ SELECT c FROM t3 UNION ALL
+ SELECT d FROM t4;
+ }
+} {222 111 333 444}
+do_test shared4-1.8 {
+ db2 eval {
+ SELECT b FROM t2 UNION ALL
+ SELECT a FROM t1 UNION ALL
+ SELECT d FROM t4 UNION ALL
+ SELECT c FROM t3;
+ }
+} {222 111 444 333}
+do_test shared4-1.9 {
+ db3 eval {
+ SELECT b FROM t2 UNION ALL
+ SELECT c FROM t3 UNION ALL
+ SELECT a FROM t1 UNION ALL
+ SELECT d FROM t4;
+ }
+} {222 333 111 444}
+do_test shared4-1.10 {
+ db4 eval {
+ SELECT b FROM t2 UNION ALL
+ SELECT c FROM t3 UNION ALL
+ SELECT d FROM t4 UNION ALL
+ SELECT a FROM t1;
+ }
+} {222 333 444 111}
+do_test shared4-1.11 {
+ db1 eval {
+ SELECT c FROM t3 UNION ALL
+ SELECT a FROM t1 UNION ALL
+ SELECT b FROM t2 UNION ALL
+ SELECT d FROM t4;
+ }
+} {333 111 222 444}
+do_test shared4-1.12 {
+ db2 eval {
+ SELECT c FROM t3 UNION ALL
+ SELECT a FROM t1 UNION ALL
+ SELECT d FROM t4 UNION ALL
+ SELECT b FROM t2;
+ }
+} {333 111 444 222}
+
+do_test shared4-2.1 {
+ db1 eval {
+ UPDATE t1 SET a=a+1000;
+ UPDATE t2 SET b=b+2000;
+ UPDATE t3 SET c=c+3000;
+ UPDATE t4 SET d=d+4000;
+ }
+ db2 eval {
+ UPDATE t1 SET a=a+10000;
+ UPDATE t2 SET b=b+20000;
+ UPDATE t3 SET c=c+30000;
+ UPDATE t4 SET d=d+40000;
+ }
+ db3 eval {
+ UPDATE t1 SET a=a+100000;
+ UPDATE t2 SET b=b+200000;
+ UPDATE t3 SET c=c+300000;
+ UPDATE t4 SET d=d+400000;
+ }
+ db4 eval {
+ UPDATE t1 SET a=a+1000000;
+ UPDATE t2 SET b=b+2000000;
+ UPDATE t3 SET c=c+3000000;
+ UPDATE t4 SET d=d+4000000;
+ }
+ db1 eval {
+ SELECT a FROM t1 UNION ALL
+ SELECT b FROM t2 UNION ALL
+ SELECT c FROM t3 UNION ALL
+ SELECT d FROM t4;
+ }
+} {1111111 2222222 3333333 4444444}
+do_test shared4-2.2 {
+ db2 eval {
+ SELECT a FROM t1 UNION ALL
+ SELECT b FROM t2 UNION ALL
+ SELECT d FROM t4 UNION ALL
+ SELECT c FROM t3;
+ }
+} {1111111 2222222 4444444 3333333}
+do_test shared4-2.3 {
+ db3 eval {
+ SELECT a FROM t1 UNION ALL
+ SELECT c FROM t3 UNION ALL
+ SELECT b FROM t2 UNION ALL
+ SELECT d FROM t4;
+ }
+} {1111111 3333333 2222222 4444444}
+do_test shared4-2.4 {
+ db4 eval {
+ SELECT a FROM t1 UNION ALL
+ SELECT c FROM t3 UNION ALL
+ SELECT d FROM t4 UNION ALL
+ SELECT b FROM t2;
+ }
+} {1111111 3333333 4444444 2222222}
+
+
+db1 close
+db2 close
+db3 close
+db4 close
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/shared6.test b/test/shared6.test
new file mode 100644
index 0000000..499cbb0
--- /dev/null
+++ b/test/shared6.test
@@ -0,0 +1,255 @@
+# 2009 April 01
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: shared6.test,v 1.4 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !shared_cache { finish_test ; return }
+
+do_test shared6-1.1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ CREATE TABLE t3(e, f);
+ }
+ db close
+} {}
+do_test shared6-1.1.2 {
+ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+ sqlite3_enable_shared_cache
+} {1}
+
+do_test shared6-1.1.3 {
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+} {}
+
+# Exclusive shared-cache locks. Test the following:
+#
+# 1.2.1: If [db1] has an exclusive lock, [db2] cannot read.
+# 1.2.2: If [db1] has an exclusive lock, [db1] can read.
+# 1.2.3: If [db1] has a non-exclusive write-lock, [db2] can read.
+#
+do_test shared6-1.2.1 {
+ execsql { SELECT * FROM t1 } db2 ;# Cache a compiled statement
+ execsql { BEGIN EXCLUSIVE } db1
+ catchsql { SELECT * FROM t1 } db2 ;# Execute the cached compiled statement
+} {1 {database table is locked}}
+do_test shared6-1.2.2 {
+ execsql { SELECT * FROM t1 } db1
+} {}
+do_test shared6-1.2.3 {
+ execsql {
+ COMMIT;
+ BEGIN;
+ INSERT INTO t2 VALUES(3, 4);
+ } db1
+ execsql { SELECT * FROM t1 } db2
+} {}
+do_test shared6-1.2.X {
+ execsql { COMMIT } db1
+} {}
+
+# Regular shared-cache locks. Verify the following:
+#
+# 1.3.1: If [db1] has a write-lock on t1, [db1] can read from t1.
+# 1.3.2: If [db1] has a write-lock on t1, [db2] can read from t2.
+# 1.3.3: If [db1] has a write-lock on t1, [db2] cannot read from t1.
+# 1.3.4: If [db1] has a write-lock on t1, [db2] cannot write to t1.
+# 1.3.5: If [db1] has a read-lock on t1, [db2] can read from t1.
+# 1.3.6: If [db1] has a read-lock on t1, [db2] cannot write to t1.
+#
+do_test shared6-1.3.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ } db1
+ execsql { SELECT * FROM t1 } db1
+} {1 2}
+do_test shared6-1.3.2 {
+ execsql { SELECT * FROM t2 } db2
+} {3 4}
+do_test shared6-1.3.3 {
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database table is locked: t1}}
+do_test shared6-1.3.4 {
+ catchsql { INSERT INTO t2 VALUES(1, 2) } db2
+} {1 {database table is locked}}
+do_test shared6-1.3.5 {
+ execsql {
+ COMMIT;
+ BEGIN;
+ SELECT * FROM t1;
+ } db1
+ execsql { SELECT * FROM t1 } db2
+} {1 2}
+do_test shared6-1.3.5 {
+ catchsql { INSERT INTO t1 VALUES(5, 6) } db2
+} {1 {database table is locked: t1}}
+do_test shared6-1.3.X {
+ execsql { COMMIT } db1
+} {}
+
+# Read-uncommitted mode.
+#
+# For these tests, connection [db2] is in read-uncommitted mode.
+#
+# 1.4.1: If [db1] has a write-lock on t1, [db2] can still read from t1.
+# 1.4.2: If [db1] has a write-lock on the db schema (sqlite_master table),
+# [db2] cannot read from the schema.
+# 1.4.3: If [db1] has a read-lock on t1, [db2] cannot write to t1.
+#
+do_test shared6-1.4.1 {
+ execsql { PRAGMA read_uncommitted = 1 } db2
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(5, 6);
+ } db1
+ execsql { SELECT * FROM t1 } db2
+} {1 2 5 6}
+do_test shared6-1.4.2 {
+ execsql { CREATE TABLE t4(a, b) } db1
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database table is locked}}
+do_test shared6-1.4.3 {
+ execsql {
+ COMMIT;
+ BEGIN;
+ SELECT * FROM t1;
+ } db1
+ catchsql { INSERT INTO t1 VALUES(7, 8) } db2
+} {1 {database table is locked: t1}}
+
+do_test shared6-1.X {
+ db1 close
+ db2 close
+} {}
+
+#-------------------------------------------------------------------------
+# The following tests - shared6-2.* - test that two database connections
+# that connect to the same file using different VFS implementations do
+# not share a cache.
+#
+if {$::tcl_platform(platform) eq "unix"} {
+ do_test shared6-2.1 {
+ sqlite3 db1 test.db -vfs unix
+ sqlite3 db2 test.db -vfs unix
+ sqlite3 db3 test.db -vfs unix-none
+ sqlite3 db4 test.db -vfs unix-none
+ } {}
+
+ do_test shared6-2.2 {
+ execsql { BEGIN; INSERT INTO t1 VALUES(9, 10); } db1
+ catchsql { SELECT * FROM t1 } db2
+ } {1 {database table is locked: t1}}
+ do_test shared6-2.3 {
+ execsql { SELECT * FROM t1 } db3
+ } {1 2 5 6}
+
+ do_test shared6-2.3 {
+ execsql { COMMIT } db1
+ execsql { BEGIN; INSERT INTO t1 VALUES(11, 12); } db3
+ catchsql { SELECT * FROM t1 } db4
+ } {1 {database table is locked: t1}}
+
+ do_test shared6-2.4 {
+ execsql { SELECT * FROM t1 } db1
+ } {1 2 5 6 9 10}
+
+ do_test shared6-2.5 {
+ execsql { COMMIT } db3
+ } {}
+
+ do_test shared6-2.X {
+ db1 close
+ db2 close
+ db3 close
+ db4 close
+ } {}
+}
+
+#-------------------------------------------------------------------------
+# Test that it is possible to open an exclusive transaction while
+# already holding a read-lock on the database file. And that it is
+# not possible if some other connection holds such a lock.
+#
+do_test shared6-3.1 {
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+ sqlite3 db3 test.db
+} {}
+db1 eval {SELECT * FROM t1} {
+ # Within this block [db1] is holding a read-lock on t1. Test that
+ # this means t1 cannot be written by [db2].
+ #
+ do_test shared6-3.2 {
+ catchsql { INSERT INTO t1 VALUES(1, 2) } db2
+ } {1 {database table is locked: t1}}
+
+ do_test shared6-3.3 {
+ execsql { BEGIN EXCLUSIVE } db1
+ } {}
+ break
+}
+do_test shared6-3.4 {
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database schema is locked: main}}
+do_test shared6-3.5 {
+ execsql COMMIT db1
+} {}
+db2 eval {SELECT * FROM t1} {
+ do_test shared6-3.6 {
+ catchsql { BEGIN EXCLUSIVE } db1
+ } {1 {database table is locked}}
+ break
+}
+do_test shared6-3.7 {
+ execsql { BEGIN } db1
+ execsql { BEGIN } db2
+} {}
+db2 eval {SELECT * FROM t1} {
+ do_test shared6-3.8 {
+ catchsql { INSERT INTO t1 VALUES(1, 2) } db1
+ } {1 {database table is locked: t1}}
+ break
+}
+do_test shared6-3.9 {
+ execsql { BEGIN ; ROLLBACK } db3
+} {}
+do_test shared6-3.10 {
+ catchsql { SELECT * FROM t1 } db3
+} {1 {database table is locked}}
+do_test shared6-3.X {
+ db1 close
+ db2 close
+ db3 close
+} {}
+
+do_test shared6-4.1 {
+ #forcedelete test.db test.db-journal
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+
+ set ::STMT [sqlite3_prepare_v2 db1 "SELECT * FROM t1" -1 DUMMY]
+ execsql { CREATE TABLE t5(a, b) } db2
+} {}
+do_test shared6-4.2 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+do_test shared6-4.X {
+
+ db1 close
+ db2 close
+} {}
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/shared7.test b/test/shared7.test
new file mode 100644
index 0000000..5c4a1da
--- /dev/null
+++ b/test/shared7.test
@@ -0,0 +1,55 @@
+# 2009 April 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Make sure that attaching the same database multiple times in
+# shared cache mode fails.
+#
+# $Id: shared7.test,v 1.1 2009/04/30 13:30:33 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !shared_cache { finish_test ; return }
+
+do_test shared7-1.1 {
+ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+ sqlite3_enable_shared_cache
+} {1}
+
+do_test shared7-1.2 {
+ db close
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(x);
+ }
+ catchsql {
+ ATTACH 'test.db' AS err1;
+ }
+} {1 {database is already attached}}
+
+do_test shared7-1.3 {
+ forcedelete test2.db test2.db-journal
+ db eval {
+ ATTACH 'test2.db' AS test2;
+ CREATE TABLE test2.t2(y);
+ }
+ catchsql {
+ ATTACH 'test2.db' AS err2;
+ }
+} {1 {database is already attached}}
+do_test shared7-1.4 {
+ catchsql {
+ ATTACH 'test.db' AS err1;
+ }
+} {1 {database is already attached}}
+
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/shared_err.test b/test/shared_err.test
new file mode 100644
index 0000000..f501fc7
--- /dev/null
+++ b/test/shared_err.test
@@ -0,0 +1,521 @@
+# 2005 December 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# The focus of the tests in this file are IO errors that occur in a shared
+# cache context. What happens to connection B if one connection A encounters
+# an IO-error whilst reading or writing the file-system?
+#
+# $Id: shared_err.test,v 1.24 2008/10/12 00:27:54 shane Exp $
+
+proc skip {args} {}
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+db close
+
+ifcapable !shared_cache||!subquery {
+ finish_test
+ return
+}
+
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+do_ioerr_test shared_ioerr-1 -tclprep {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA read_uncommitted = 1;
+ CREATE TABLE t1(a,b,c);
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ } db2
+} -sqlbody {
+ SELECT * FROM sqlite_master;
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN TRANSACTION;
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(4,5,6);
+ ROLLBACK;
+ SELECT * FROM t1;
+ BEGIN TRANSACTION;
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(4,5,6);
+ COMMIT;
+ SELECT * FROM t1;
+ DELETE FROM t1 WHERE a<100;
+} -cleanup {
+ do_test shared_ioerr-1.$n.cleanup.1 {
+ set res [catchsql {
+ SELECT * FROM t1;
+ } db2]
+ set possible_results [list \
+ "1 {disk I/O error}" \
+ "0 {1 2 3}" \
+ "0 {1 2 3 1 2 3 4 5 6}" \
+ "0 {1 2 3 1 2 3 4 5 6 1 2 3 4 5 6}" \
+ "0 {}" \
+ "1 {database disk image is malformed}" \
+ ]
+ set rc [expr [lsearch -exact $possible_results $res] >= 0]
+ if {$rc != 1} {
+ puts ""
+ puts "Result: $res"
+ }
+ set rc
+ } {1}
+
+ # The "database disk image is malformed" is a special case that can
+ # occur if an IO error occurs during a rollback in the {SELECT * FROM t1}
+ # statement above. This test is to make sure there is no real database
+ # corruption.
+ db2 close
+ do_test shared_ioerr-1.$n.cleanup.2 {
+ execsql {pragma integrity_check} db
+ } {ok}
+}
+
+do_ioerr_test shared_ioerr-2 -tclprep {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA read_uncommitted = 1;
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1(oid) VALUES(NULL);
+ INSERT INTO t1(oid) SELECT NULL FROM t1;
+ INSERT INTO t1(oid) SELECT NULL FROM t1;
+ INSERT INTO t1(oid) SELECT NULL FROM t1;
+ INSERT INTO t1(oid) SELECT NULL FROM t1;
+ INSERT INTO t1(oid) SELECT NULL FROM t1;
+ INSERT INTO t1(oid) SELECT NULL FROM t1;
+ INSERT INTO t1(oid) SELECT NULL FROM t1;
+ INSERT INTO t1(oid) SELECT NULL FROM t1;
+ INSERT INTO t1(oid) SELECT NULL FROM t1;
+ INSERT INTO t1(oid) SELECT NULL FROM t1;
+ UPDATE t1 set a = oid, b = 'abcdefghijklmnopqrstuvwxyz0123456789';
+ CREATE INDEX i1 ON t1(a);
+ COMMIT;
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ } db2
+} -tclbody {
+ set ::residx 0
+ execsql {DELETE FROM t1 WHERE 0 = (a % 2);}
+ incr ::residx
+
+ # When this transaction begins the table contains 512 entries. The
+ # two statements together add 512+146 more if it succeeds.
+ # (1024/7==146)
+ execsql {BEGIN;}
+ execsql {INSERT INTO t1 SELECT a+1, b FROM t1;}
+ execsql {INSERT INTO t1 SELECT 'string' || a, b FROM t1 WHERE 0 = (a%7);}
+ execsql {COMMIT;}
+
+ incr ::residx
+} -cleanup {
+ catchsql ROLLBACK
+ do_test shared_ioerr-2.$n.cleanup.1 {
+ set res [catchsql {
+ SELECT max(a), min(a), count(*) FROM (SELECT a FROM t1 order by a);
+ } db2]
+ set possible_results [list \
+ {0 {1024 1 1024}} \
+ {0 {1023 1 512}} \
+ {0 {string994 1 1170}} \
+ ]
+ set idx [lsearch -exact $possible_results $res]
+ set success [expr {$idx==$::residx || $res=="1 {disk I/O error}"}]
+ if {!$success} {
+ puts ""
+ puts "Result: \"$res\" ($::residx)"
+ }
+ set success
+ } {1}
+ db2 close
+}
+
+# This test is designed to provoke an IO error when a cursor position is
+# "saved" (because another cursor is going to modify the underlying table).
+#
+do_ioerr_test shared_ioerr-3 -tclprep {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA read_uncommitted = 1;
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ } db2
+ for {set i 0} {$i < 200} {incr i} {
+ set a [string range [string repeat "[format %03d $i]." 5] 0 end-1]
+
+ set b [string repeat $i 2000]
+ execsql {INSERT INTO t1 VALUES($a, $b)} db2
+ }
+ execsql {COMMIT} db2
+ set ::DB2 [sqlite3_connection_pointer db2]
+ set ::STMT [sqlite3_prepare $::DB2 "SELECT a FROM t1 ORDER BY a" -1 DUMMY]
+ sqlite3_step $::STMT ;# Cursor points at 000.000.000.000
+ sqlite3_step $::STMT ;# Cursor points at 001.001.001.001
+
+} -tclbody {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('201.201.201.201.201', NULL);
+ UPDATE t1 SET a = '202.202.202.202.202' WHERE a LIKE '201%';
+ COMMIT;
+ }
+} -cleanup {
+ set ::steprc [sqlite3_step $::STMT]
+ set ::column [sqlite3_column_text $::STMT 0]
+ set ::finalrc [sqlite3_finalize $::STMT]
+
+ # There are three possible outcomes here (assuming persistent IO errors):
+ #
+ # 1. If the [sqlite3_step] did not require any IO (required pages in
+ # the cache), then the next row ("002...") may be retrieved
+ # successfully.
+ #
+ # 2. If the [sqlite3_step] does require IO, then [sqlite3_step] returns
+ # SQLITE_ERROR and [sqlite3_finalize] returns IOERR.
+ #
+ # 3. If, after the initial IO error, SQLite tried to rollback the
+ # active transaction and a second IO error was encountered, then
+ # statement $::STMT will have been aborted. This means [sqlite3_stmt]
+ # returns SQLITE_ABORT, and the statement cursor does not move. i.e.
+ # [sqlite3_column] still returns the current row ("001...") and
+ # [sqlite3_finalize] returns SQLITE_OK.
+ #
+
+ do_test shared_ioerr-3.$n.cleanup.1 {
+ expr {
+ $::steprc eq "SQLITE_ROW" ||
+ $::steprc eq "SQLITE_ERROR" ||
+ $::steprc eq "SQLITE_ABORT"
+ }
+ } {1}
+ do_test shared_ioerr-3.$n.cleanup.2 {
+ expr {
+ ($::steprc eq "SQLITE_ROW" && $::column eq "002.002.002.002.002") ||
+ ($::steprc eq "SQLITE_ERROR" && $::column eq "") ||
+ ($::steprc eq "SQLITE_ABORT" && $::column eq "001.001.001.001.001")
+ }
+ } {1}
+ do_test shared_ioerr-3.$n.cleanup.3 {
+ expr {
+ ($::steprc eq "SQLITE_ROW" && $::finalrc eq "SQLITE_OK") ||
+ ($::steprc eq "SQLITE_ERROR" && $::finalrc eq "SQLITE_IOERR") ||
+ ($::steprc eq "SQLITE_ERROR" && $::finalrc eq "SQLITE_ABORT")
+ }
+ } {1}
+
+# db2 eval {select * from sqlite_master}
+ db2 close
+}
+
+# This is a repeat of the previous test except that this time we
+# are doing a reverse-order scan of the table when the cursor is
+# "saved".
+#
+do_ioerr_test shared_ioerr-3rev -tclprep {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA read_uncommitted = 1;
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ } db2
+ for {set i 0} {$i < 200} {incr i} {
+ set a [string range [string repeat "[format %03d $i]." 5] 0 end-1]
+
+ set b [string repeat $i 2000]
+ execsql {INSERT INTO t1 VALUES($a, $b)} db2
+ }
+ execsql {COMMIT} db2
+ set ::DB2 [sqlite3_connection_pointer db2]
+ set ::STMT [sqlite3_prepare $::DB2 \
+ "SELECT a FROM t1 ORDER BY a DESC" -1 DUMMY]
+ sqlite3_step $::STMT ;# Cursor points at 199.199.199.199.199
+ sqlite3_step $::STMT ;# Cursor points at 198.198.198.198.198
+
+} -tclbody {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('201.201.201.201.201', NULL);
+ UPDATE t1 SET a = '202.202.202.202.202' WHERE a LIKE '201%';
+ COMMIT;
+ }
+} -cleanup {
+ set ::steprc [sqlite3_step $::STMT]
+ set ::column [sqlite3_column_text $::STMT 0]
+ set ::finalrc [sqlite3_finalize $::STMT]
+
+ # There are three possible outcomes here (assuming persistent IO errors):
+ #
+ # 1. If the [sqlite3_step] did not require any IO (required pages in
+ # the cache), then the next row ("002...") may be retrieved
+ # successfully.
+ #
+ # 2. If the [sqlite3_step] does require IO, then [sqlite3_step] returns
+ # SQLITE_ERROR and [sqlite3_finalize] returns IOERR.
+ #
+ # 3. If, after the initial IO error, SQLite tried to rollback the
+ # active transaction and a second IO error was encountered, then
+ # statement $::STMT will have been aborted. This means [sqlite3_stmt]
+ # returns SQLITE_ABORT, and the statement cursor does not move. i.e.
+ # [sqlite3_column] still returns the current row ("001...") and
+ # [sqlite3_finalize] returns SQLITE_OK.
+ #
+
+ do_test shared_ioerr-3rev.$n.cleanup.1 {
+ expr {
+ $::steprc eq "SQLITE_ROW" ||
+ $::steprc eq "SQLITE_ERROR" ||
+ $::steprc eq "SQLITE_ABORT"
+ }
+ } {1}
+ do_test shared_ioerr-3rev.$n.cleanup.2 {
+ expr {
+ ($::steprc eq "SQLITE_ROW" && $::column eq "197.197.197.197.197") ||
+ ($::steprc eq "SQLITE_ERROR" && $::column eq "") ||
+ ($::steprc eq "SQLITE_ABORT" && $::column eq "198.198.198.198.198")
+ }
+ } {1}
+ do_test shared_ioerr-3rev.$n.cleanup.3 {
+ expr {
+ ($::steprc eq "SQLITE_ROW" && $::finalrc eq "SQLITE_OK") ||
+ ($::steprc eq "SQLITE_ERROR" && $::finalrc eq "SQLITE_IOERR") ||
+ ($::steprc eq "SQLITE_ERROR" && $::finalrc eq "SQLITE_ABORT")
+ }
+ } {1}
+
+# db2 eval {select * from sqlite_master}
+ db2 close
+}
+
+# Provoke a malloc() failure when a cursor position is being saved. This
+# only happens with index cursors (because they malloc() space to save the
+# current key value). It does not happen with tables, because an integer
+# key does not require a malloc() to store.
+#
+# The library should return an SQLITE_NOMEM to the caller. The query that
+# owns the cursor (the one for which the position is not saved) should
+# continue unaffected.
+#
+do_malloc_test shared_err-4 -tclprep {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA read_uncommitted = 1;
+ BEGIN;
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ } db2
+ for {set i 0} {$i < 5} {incr i} {
+ set a [string repeat $i 10]
+ set b [string repeat $i 2000]
+ execsql {INSERT INTO t1 VALUES($a, $b)} db2
+ }
+ execsql {COMMIT} db2
+ set ::DB2 [sqlite3_connection_pointer db2]
+ set ::STMT [sqlite3_prepare $::DB2 "SELECT a FROM t1 ORDER BY a" -1 DUMMY]
+ sqlite3_step $::STMT ;# Cursor points at 0000000000
+ sqlite3_step $::STMT ;# Cursor points at 1111111111
+} -tclbody {
+ execsql {
+ INSERT INTO t1 VALUES(6, NULL);
+ }
+} -cleanup {
+ do_test shared_malloc-4.$::n.cleanup.1 {
+ set ::rc [sqlite3_step $::STMT]
+ expr {$::rc=="SQLITE_ROW" || $::rc=="SQLITE_ERROR"}
+ } {1}
+ if {$::rc=="SQLITE_ROW"} {
+ do_test shared_malloc-4.$::n.cleanup.2 {
+ sqlite3_column_text $::STMT 0
+ } {2222222222}
+ }
+ do_test shared_malloc-4.$::n.cleanup.3 {
+ set rc [sqlite3_finalize $::STMT]
+ expr {$rc=="SQLITE_OK" || $rc=="SQLITE_ABORT" ||
+ $rc=="SQLITE_NOMEM" || $rc=="SQLITE_IOERR"}
+ } {1}
+# db2 eval {select * from sqlite_master}
+ db2 close
+}
+
+do_malloc_test shared_err-5 -tclbody {
+ db close
+ sqlite3 dbX test.db
+ sqlite3 dbY test.db
+ dbX close
+ dbY close
+} -cleanup {
+ catch {dbX close}
+ catch {dbY close}
+}
+
+do_malloc_test shared_err-6 -tclbody {
+ catch {db close}
+ ifcapable deprecated {
+ sqlite3_thread_cleanup
+ }
+ sqlite3_enable_shared_cache 0
+} -cleanup {
+ sqlite3_enable_shared_cache 1
+}
+
+# As of 3.5.0, sqlite3_enable_shared_cache can be called at
+# any time and from any thread
+#do_test shared_err-misuse-7.1 {
+# sqlite3 db test.db
+# catch {
+# sqlite3_enable_shared_cache 0
+# } msg
+# set msg
+#} {library routine called out of sequence}
+
+# Again provoke a malloc() failure when a cursor position is being saved,
+# this time during a ROLLBACK operation by some other handle.
+#
+# The library should return an SQLITE_NOMEM to the caller. The query that
+# owns the cursor (the one for which the position is not saved) should
+# be aborted.
+#
+set ::aborted 0
+do_malloc_test shared_err-8 -tclprep {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA read_uncommitted = 1;
+ BEGIN;
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ } db2
+ for {set i 0} {$i < 2} {incr i} {
+ set a [string repeat $i 10]
+ set b [string repeat $i 2000]
+ execsql {INSERT INTO t1 VALUES($a, $b)} db2
+ }
+ execsql {COMMIT} db2
+ set ::DB2 [sqlite3_connection_pointer db2]
+ set ::STMT [sqlite3_prepare $::DB2 "SELECT a FROM t1 ORDER BY a" -1 DUMMY]
+ sqlite3_step $::STMT ;# Cursor points at 0000000000
+ sqlite3_step $::STMT ;# Cursor points at 1111111111
+} -tclbody {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(6, NULL);
+ ROLLBACK;
+ }
+} -cleanup {
+ # UPDATE: As of [5668], if the rollback fails SQLITE_CORRUPT is returned.
+ # So these tests have been updated to expect SQLITE_CORRUPT and its
+ # associated English language error message.
+ #
+ do_test shared_malloc-8.$::n.cleanup.1 {
+ set res [catchsql {SELECT a FROM t1} db2]
+ set ans [lindex $res 1]
+ if {[lindex $res 0]} {
+ set r [expr {
+ $ans=="disk I/O error" ||
+ $ans=="out of memory" ||
+ $ans=="database disk image is malformed"
+ }]
+ } else {
+ set r [expr {[lrange $ans 0 1]=="0000000000 1111111111"}]
+ }
+ } {1}
+ do_test shared_malloc-8.$::n.cleanup.2 {
+ set rc1 [sqlite3_step $::STMT]
+ set rc2 [sqlite3_finalize $::STMT]
+ if {$rc2=="SQLITE_ABORT"} {
+ incr ::aborted
+ }
+ expr {
+ ($rc1=="SQLITE_DONE" && $rc2=="SQLITE_OK") ||
+ ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_ABORT") ||
+ ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_NOMEM") ||
+ ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_IOERR") ||
+ ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_CORRUPT")
+ }
+ } {1}
+ db2 close
+}
+do_test shared_malloc-8.X {
+ # Test that one or more queries were aborted due to the malloc() failure.
+ expr $::aborted>=1
+} {1}
+
+# This test is designed to catch a specific bug that was present during
+# development of 3.5.0. If a malloc() failed while setting the page-size,
+# a buffer (Pager.pTmpSpace) was being freed. This could cause a seg-fault
+# later if another connection tried to use the pager.
+#
+# This test will crash 3.4.2.
+#
+do_malloc_test shared_err-9 -tclprep {
+ sqlite3 db2 test.db
+} -sqlbody {
+ PRAGMA page_size = 4096;
+ PRAGMA page_size = 1024;
+} -cleanup {
+ db2 eval {
+ CREATE TABLE abc(a, b, c);
+ BEGIN;
+ INSERT INTO abc VALUES(1, 2, 3);
+ ROLLBACK;
+ }
+ db2 close
+}
+
+catch {db close}
+catch {db2 close}
+do_malloc_test shared_err-10 -tclprep {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+
+ db eval { SELECT * FROM sqlite_master }
+ db2 eval {
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ }
+} -tclbody {
+ catch {db eval {SELECT * FROM sqlite_master}}
+ error 1
+} -cleanup {
+ execsql { SELECT * FROM sqlite_master }
+}
+
+do_malloc_test shared_err-11 -tclprep {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+
+ db eval { SELECT * FROM sqlite_master }
+ db2 eval {
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ }
+} -tclbody {
+ catch {db eval {SELECT * FROM sqlite_master}}
+ catch {sqlite3_errmsg16 db}
+ error 1
+} -cleanup {
+ execsql { SELECT * FROM sqlite_master }
+}
+
+catch {db close}
+catch {db2 close}
+
+do_malloc_test shared_err-12 -sqlbody {
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+}
+
+catch {db close}
+catch {db2 close}
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/sharedlock.test b/test/sharedlock.test
new file mode 100644
index 0000000..1e78eea
--- /dev/null
+++ b/test/sharedlock.test
@@ -0,0 +1,55 @@
+# 2009 July 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: sharedlock.test,v 1.1 2009/07/02 17:21:58 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db close
+
+ifcapable !shared_cache {
+ finish_test
+ return
+}
+
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+do_test sharedlock-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ }
+} {}
+
+do_test sharedlock-1.2 {
+ set res [list]
+ db eval { SELECT * FROM t1 ORDER BY rowid } {
+ lappend res $a $b
+ if {$a == 1} { catch { db eval "INSERT INTO t1 VALUES(3, 'three')" } }
+
+ # This should fail. Connection [db] has a read-lock on t1, which should
+ # prevent connection [db2] from obtaining the write-lock it needs to
+ # modify t1. At one point there was a bug causing the previous INSERT
+ # to drop the read-lock belonging to [db].
+ if {$a == 2} { catch { db2 eval "INSERT INTO t1 VALUES(4, 'four')" } }
+ }
+ set res
+} {1 one 2 two 3 three}
+
+db close
+db2 close
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
+
diff --git a/test/shortread1.test b/test/shortread1.test
new file mode 100644
index 0000000..647f2ff
--- /dev/null
+++ b/test/shortread1.test
@@ -0,0 +1,52 @@
+# 2007 Sep 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file attempts to duplicate an error scenario seen on a
+# customer system using version 3.2.2. The problem appears to
+# have been fixed (perhaps by accident) with check-in [3503].
+# These tests will prevent an accidental recurrance.
+#
+# $Id: shortread1.test,v 1.1 2007/09/14 01:48:12 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test shortread1-1.1 {
+ execsql {
+ CREATE TABLE t1(a TEXT);
+ BEGIN;
+ INSERT INTO t1 VALUES(hex(randomblob(5000)));
+ INSERT INTO t1 VALUES(hex(randomblob(100)));
+ PRAGMA freelist_count;
+ }
+} {0}
+do_test shortread1-1.2 {
+ execsql {
+ DELETE FROM t1 WHERE rowid=1;
+ PRAGMA freelist_count;
+ }
+} {11}
+do_test shortread1-1.3 {
+ sqlite3_release_memory [expr {1024*9}]
+ execsql {
+ INSERT INTO t1 VALUES(hex(randomblob(5000)));
+ PRAGMA freelist_count;
+ }
+} {0}
+do_test shortread1-1.4 {
+ execsql {
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+} {2}
+
+finish_test
diff --git a/test/sidedelete.test b/test/sidedelete.test
new file mode 100644
index 0000000..04e457d
--- /dev/null
+++ b/test/sidedelete.test
@@ -0,0 +1,92 @@
+# 2007 Dec 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains test cases for stressing database
+# changes that involve side effects that delete rows from
+# the table being changed. Ticket #2832 shows that in
+# older versions of SQLite that behavior was implemented
+# incorrectly and resulted in corrupt database files.
+#
+# $Id: sidedelete.test,v 1.2 2008/08/04 03:51:24 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# The sequence table is created to store a sequence of integers
+# starting with 1. This is used to reinitialize other tables
+# as part of other tests.
+#
+do_test sidedelete-1.1 {
+ execsql {
+ CREATE TABLE sequence(a INTEGER PRIMARY KEY);
+ INSERT INTO sequence VALUES(1);
+ INSERT INTO sequence VALUES(2);
+ }
+ for {set i 0} {$i<8} {incr i} {
+ execsql {
+ INSERT INTO sequence SELECT a+(SELECT max(a) FROM sequence) FROM sequence;
+ }
+ }
+ execsql {SELECT count(*) FROM sequence}
+} {512}
+
+# Make a series of changes using an UPDATE OR REPLACE and a
+# correlated subquery. This would cause database corruption
+# prior to the fix for ticket #2832.
+#
+do_test sidedelete-2.0 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TABLE chng(a PRIMARY KEY, b);
+ SELECT count(*) FROM t1;
+ SELECT count(*) FROM chng;
+ }
+} {0 0}
+for {set i 2} {$i<=100} {incr i} {
+ set n [expr {($i+2)/2}]
+ do_test sidedelete-2.$i.1 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 SELECT a, a FROM sequence WHERE a<=$i;
+ DELETE FROM chng;
+ INSERT INTO chng SELECT a*2, a*2+1 FROM sequence WHERE a<=$i/2;
+ UPDATE OR REPLACE t1 SET a=(SELECT b FROM chng WHERE a=t1.a);
+ SELECT count(*), sum(a) FROM t1;
+ }
+ } [list $n [expr {$n*$n-1}]]
+ integrity_check sidedelete-2.$i.2
+}
+
+# This will cause stacks leaks but not database corruption prior
+# to the #2832 fix.
+#
+do_test sidedelete-3.0 {
+ execsql {
+ DROP TABLE t1;
+ CREATE TABLE t1(a PRIMARY KEY);
+ SELECT * FROM t1;
+ }
+} {}
+for {set i 1} {$i<=100} {incr i} {
+ set n [expr {($i+1)/2}]
+ do_test sidedelete-3.$i.1 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 SELECT a FROM sequence WHERE a<=$i;
+ UPDATE OR REPLACE t1 SET a=a+1;
+ SELECT count(*), sum(a) FROM t1;
+ }
+ } [list $n [expr {$n*($n+1)}]]
+ integrity_check sidedelete-3.$i.2
+}
+
+finish_test
diff --git a/test/soak.test b/test/soak.test
new file mode 100644
index 0000000..c457dec
--- /dev/null
+++ b/test/soak.test
@@ -0,0 +1,90 @@
+# 2007 May 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file is the driver for the "soak" tests. It is a peer of the
+# quick.test and all.test scripts.
+#
+# $Id: soak.test,v 1.4 2008/11/13 18:29:51 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+rename finish_test really_finish_test
+proc finish_test {} {}
+
+# By default, guarantee that the tests will run for at least 1 hour.
+#
+set TIMEOUT 3600
+
+# Process command-line arguments.
+#
+if {[llength $argv]>0} {
+ foreach {name value} $argv {
+ switch -- $name {
+ -timeout {
+ set TIMEOUT $value
+ }
+ default {
+ puts stderr "Unknown option: $name"
+ exit
+ }
+ }
+ }
+}
+set argv [list]
+
+# Test plan:
+#
+# The general principle is to run those SQLite tests that use
+# pseudo-random data in some way over and over again for a very
+# long time. The number of tests run depends on the value of
+# global variable $TIMEOUT - tests are run for at least $TIMEOUT
+# seconds.
+#
+# fuzz.test (pseudo-random SQL statements)
+# trans.test (pseudo-random changes to a database followed by rollbacks)
+# fuzz_malloc.test
+# corruptC.test (pseudo-random corruption to a database)
+#
+# Many database changes maintaining some kind of invariant.
+# Storing checksums etc.
+#
+
+# List of test files that are run by this file.
+#
+set SOAKTESTS {
+ fuzz.test
+ fuzz_malloc.test
+ trans.test
+ corruptC.test
+}
+
+set G(isquick) 1
+
+set soak_starttime [clock seconds]
+set soak_finishtime [expr {$soak_starttime + $TIMEOUT}]
+
+# Loop until the timeout is reached or an error occurs.
+#
+for {set iRun 0} {[clock seconds] < $soak_finishtime} {incr iRun} {
+
+ set iIdx [expr {$iRun % [llength $SOAKTESTS]}]
+ source [file join $testdir [lindex $SOAKTESTS $iIdx]]
+ catch {db close}
+
+ if {$sqlite_open_file_count>0} {
+ puts "$tail did not close all files: $sqlite_open_file_count"
+ fail_test $tail
+ set sqlite_open_file_count 0
+ }
+
+ if {[set_test_counter errors]>0} break
+}
+
+really_finish_test
diff --git a/test/softheap1.test b/test/softheap1.test
new file mode 100644
index 0000000..6855553
--- /dev/null
+++ b/test/softheap1.test
@@ -0,0 +1,49 @@
+# 2007 Aug 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test script reproduces the problem reported by ticket #2565,
+# A database corruption bug that occurs in auto_vacuum mode when
+# the soft_heap_limit is set low enough to be triggered.
+#
+# $Id: softheap1.test,v 1.5 2008/07/08 17:13:59 danielk1977 Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !integrityck {
+ finish_test
+ return
+}
+
+sqlite3_soft_heap_limit -1
+sqlite3_soft_heap_limit 0
+sqlite3_soft_heap_limit 5000
+do_test softheap1-1.1 {
+ execsql {
+ PRAGMA auto_vacuum=1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(hex(randomblob(1000)));
+ BEGIN;
+ }
+ execsql {
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ }
+ execsql {
+ ROLLBACK;
+ }
+ execsql {
+ PRAGMA integrity_check;
+ }
+} {ok}
+
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+finish_test
diff --git a/test/sort.test b/test/sort.test
new file mode 100644
index 0000000..08d496b
--- /dev/null
+++ b/test/sort.test
@@ -0,0 +1,467 @@
+# 2001 September 15.
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the CREATE TABLE statement.
+#
+# $Id: sort.test,v 1.25 2005/11/14 22:29:06 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a bunch of data to sort against
+#
+do_test sort-1.0 {
+ execsql {
+ CREATE TABLE t1(
+ n int,
+ v varchar(10),
+ log int,
+ roman varchar(10),
+ flt real
+ );
+ INSERT INTO t1 VALUES(1,'one',0,'I',3.141592653);
+ INSERT INTO t1 VALUES(2,'two',1,'II',2.15);
+ INSERT INTO t1 VALUES(3,'three',1,'III',4221.0);
+ INSERT INTO t1 VALUES(4,'four',2,'IV',-0.0013442);
+ INSERT INTO t1 VALUES(5,'five',2,'V',-11);
+ INSERT INTO t1 VALUES(6,'six',2,'VI',0.123);
+ INSERT INTO t1 VALUES(7,'seven',2,'VII',123.0);
+ INSERT INTO t1 VALUES(8,'eight',3,'VIII',-1.6);
+ }
+ execsql {SELECT count(*) FROM t1}
+} {8}
+
+do_test sort-1.1 {
+ execsql {SELECT n FROM t1 ORDER BY n}
+} {1 2 3 4 5 6 7 8}
+do_test sort-1.1.1 {
+ execsql {SELECT n FROM t1 ORDER BY n ASC}
+} {1 2 3 4 5 6 7 8}
+do_test sort-1.1.1 {
+ execsql {SELECT ALL n FROM t1 ORDER BY n ASC}
+} {1 2 3 4 5 6 7 8}
+do_test sort-1.2 {
+ execsql {SELECT n FROM t1 ORDER BY n DESC}
+} {8 7 6 5 4 3 2 1}
+do_test sort-1.3a {
+ execsql {SELECT v FROM t1 ORDER BY v}
+} {eight five four one seven six three two}
+do_test sort-1.3b {
+ execsql {SELECT n FROM t1 ORDER BY v}
+} {8 5 4 1 7 6 3 2}
+do_test sort-1.4 {
+ execsql {SELECT n FROM t1 ORDER BY v DESC}
+} {2 3 6 7 1 4 5 8}
+do_test sort-1.5 {
+ execsql {SELECT flt FROM t1 ORDER BY flt}
+} {-11.0 -1.6 -0.0013442 0.123 2.15 3.141592653 123.0 4221.0}
+do_test sort-1.6 {
+ execsql {SELECT flt FROM t1 ORDER BY flt DESC}
+} {4221.0 123.0 3.141592653 2.15 0.123 -0.0013442 -1.6 -11.0}
+do_test sort-1.7 {
+ execsql {SELECT roman FROM t1 ORDER BY roman}
+} {I II III IV V VI VII VIII}
+do_test sort-1.8 {
+ execsql {SELECT n FROM t1 ORDER BY log, flt}
+} {1 2 3 5 4 6 7 8}
+do_test sort-1.8.1 {
+ execsql {SELECT n FROM t1 ORDER BY log asc, flt}
+} {1 2 3 5 4 6 7 8}
+do_test sort-1.8.2 {
+ execsql {SELECT n FROM t1 ORDER BY log, flt ASC}
+} {1 2 3 5 4 6 7 8}
+do_test sort-1.8.3 {
+ execsql {SELECT n FROM t1 ORDER BY log ASC, flt asc}
+} {1 2 3 5 4 6 7 8}
+do_test sort-1.9 {
+ execsql {SELECT n FROM t1 ORDER BY log, flt DESC}
+} {1 3 2 7 6 4 5 8}
+do_test sort-1.9.1 {
+ execsql {SELECT n FROM t1 ORDER BY log ASC, flt DESC}
+} {1 3 2 7 6 4 5 8}
+do_test sort-1.10 {
+ execsql {SELECT n FROM t1 ORDER BY log DESC, flt}
+} {8 5 4 6 7 2 3 1}
+do_test sort-1.11 {
+ execsql {SELECT n FROM t1 ORDER BY log DESC, flt DESC}
+} {8 7 6 4 5 3 2 1}
+
+# These tests are designed to reach some hard-to-reach places
+# inside the string comparison routines.
+#
+# (Later) The sorting behavior changed in 2.7.0. But we will
+# keep these tests. You can never have too many test cases!
+#
+do_test sort-2.1.1 {
+ execsql {
+ UPDATE t1 SET v='x' || -flt;
+ UPDATE t1 SET v='x-2b' where v=='x-0.123';
+ SELECT v FROM t1 ORDER BY v;
+ }
+} {x-123.0 x-2.15 x-2b x-3.141592653 x-4221.0 x0.0013442 x1.6 x11.0}
+do_test sort-2.1.2 {
+ execsql {
+ SELECT v FROM t1 ORDER BY substr(v,2,999);
+ }
+} {x-123.0 x-2.15 x-2b x-3.141592653 x-4221.0 x0.0013442 x1.6 x11.0}
+do_test sort-2.1.3 {
+ execsql {
+ SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0;
+ }
+} {x-4221.0 x-123.0 x-3.141592653 x-2.15 x-2b x0.0013442 x1.6 x11.0}
+do_test sort-2.1.4 {
+ execsql {
+ SELECT v FROM t1 ORDER BY substr(v,2,999) DESC;
+ }
+} {x11.0 x1.6 x0.0013442 x-4221.0 x-3.141592653 x-2b x-2.15 x-123.0}
+do_test sort-2.1.5 {
+ execsql {
+ SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0 DESC;
+ }
+} {x11.0 x1.6 x0.0013442 x-2b x-2.15 x-3.141592653 x-123.0 x-4221.0}
+
+# This is a bug fix for 2.2.4.
+# Strings are normally mapped to upper-case for a caseless comparison.
+# But this can cause problems for characters in between 'Z' and 'a'.
+#
+do_test sort-3.1 {
+ execsql {
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2 VALUES('AGLIENTU',1);
+ INSERT INTO t2 VALUES('AGLIE`',2);
+ INSERT INTO t2 VALUES('AGNA',3);
+ SELECT a, b FROM t2 ORDER BY a;
+ }
+} {AGLIENTU 1 AGLIE` 2 AGNA 3}
+do_test sort-3.2 {
+ execsql {
+ SELECT a, b FROM t2 ORDER BY a DESC;
+ }
+} {AGNA 3 AGLIE` 2 AGLIENTU 1}
+do_test sort-3.3 {
+ execsql {
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES('aglientu',1);
+ INSERT INTO t2 VALUES('aglie`',2);
+ INSERT INTO t2 VALUES('agna',3);
+ SELECT a, b FROM t2 ORDER BY a;
+ }
+} {aglie` 2 aglientu 1 agna 3}
+do_test sort-3.4 {
+ execsql {
+ SELECT a, b FROM t2 ORDER BY a DESC;
+ }
+} {agna 3 aglientu 1 aglie` 2}
+
+# Version 2.7.0 testing.
+#
+do_test sort-4.1 {
+ execsql {
+ INSERT INTO t1 VALUES(9,'x2.7',3,'IX',4.0e5);
+ INSERT INTO t1 VALUES(10,'x5.0e10',3,'X',-4.0e5);
+ INSERT INTO t1 VALUES(11,'x-4.0e9',3,'XI',4.1e4);
+ INSERT INTO t1 VALUES(12,'x01234567890123456789',3,'XII',-4.2e3);
+ SELECT n FROM t1 ORDER BY n;
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+do_test sort-4.2 {
+ execsql {
+ SELECT n||'' FROM t1 ORDER BY 1;
+ }
+} {1 10 11 12 2 3 4 5 6 7 8 9}
+do_test sort-4.3 {
+ execsql {
+ SELECT n+0 FROM t1 ORDER BY 1;
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+do_test sort-4.4 {
+ execsql {
+ SELECT n||'' FROM t1 ORDER BY 1 DESC;
+ }
+} {9 8 7 6 5 4 3 2 12 11 10 1}
+do_test sort-4.5 {
+ execsql {
+ SELECT n+0 FROM t1 ORDER BY 1 DESC;
+ }
+} {12 11 10 9 8 7 6 5 4 3 2 1}
+do_test sort-4.6 {
+ execsql {
+ SELECT v FROM t1 ORDER BY 1;
+ }
+} {x-123.0 x-2.15 x-2b x-3.141592653 x-4.0e9 x-4221.0 x0.0013442 x01234567890123456789 x1.6 x11.0 x2.7 x5.0e10}
+do_test sort-4.7 {
+ execsql {
+ SELECT v FROM t1 ORDER BY 1 DESC;
+ }
+} {x5.0e10 x2.7 x11.0 x1.6 x01234567890123456789 x0.0013442 x-4221.0 x-4.0e9 x-3.141592653 x-2b x-2.15 x-123.0}
+do_test sort-4.8 {
+ execsql {
+ SELECT substr(v,2,99) FROM t1 ORDER BY 1;
+ }
+} {-123.0 -2.15 -2b -3.141592653 -4.0e9 -4221.0 0.0013442 01234567890123456789 1.6 11.0 2.7 5.0e10}
+#do_test sort-4.9 {
+# execsql {
+# SELECT substr(v,2,99)+0.0 FROM t1 ORDER BY 1;
+# }
+#} {-4000000000 -4221 -123 -3.141592653 -2.15 -2 0.0013442 1.6 2.7 11 50000000000 1.23456789012346e+18}
+
+do_test sort-5.1 {
+ execsql {
+ create table t3(a,b);
+ insert into t3 values(5,NULL);
+ insert into t3 values(6,NULL);
+ insert into t3 values(3,NULL);
+ insert into t3 values(4,'cd');
+ insert into t3 values(1,'ab');
+ insert into t3 values(2,NULL);
+ select a from t3 order by b, a;
+ }
+} {2 3 5 6 1 4}
+do_test sort-5.2 {
+ execsql {
+ select a from t3 order by b, a desc;
+ }
+} {6 5 3 2 1 4}
+do_test sort-5.3 {
+ execsql {
+ select a from t3 order by b desc, a;
+ }
+} {4 1 2 3 5 6}
+do_test sort-5.4 {
+ execsql {
+ select a from t3 order by b desc, a desc;
+ }
+} {4 1 6 5 3 2}
+
+do_test sort-6.1 {
+ execsql {
+ create index i3 on t3(b,a);
+ select a from t3 order by b, a;
+ }
+} {2 3 5 6 1 4}
+do_test sort-6.2 {
+ execsql {
+ select a from t3 order by b, a desc;
+ }
+} {6 5 3 2 1 4}
+do_test sort-6.3 {
+ execsql {
+ select a from t3 order by b desc, a;
+ }
+} {4 1 2 3 5 6}
+do_test sort-6.4 {
+ execsql {
+ select a from t3 order by b desc, a desc;
+ }
+} {4 1 6 5 3 2}
+
+do_test sort-7.1 {
+ execsql {
+ CREATE TABLE t4(
+ a INTEGER,
+ b VARCHAR(30)
+ );
+ INSERT INTO t4 VALUES(1,1);
+ INSERT INTO t4 VALUES(2,2);
+ INSERT INTO t4 VALUES(11,11);
+ INSERT INTO t4 VALUES(12,12);
+ SELECT a FROM t4 ORDER BY 1;
+ }
+} {1 2 11 12}
+do_test sort-7.2 {
+ execsql {
+ SELECT b FROM t4 ORDER BY 1
+ }
+} {1 11 12 2}
+
+# Omit tests sort-7.3 to sort-7.8 if view support was disabled at
+# compilatation time.
+ifcapable view {
+do_test sort-7.3 {
+ execsql {
+ CREATE VIEW v4 AS SELECT * FROM t4;
+ SELECT a FROM v4 ORDER BY 1;
+ }
+} {1 2 11 12}
+do_test sort-7.4 {
+ execsql {
+ SELECT b FROM v4 ORDER BY 1;
+ }
+} {1 11 12 2}
+
+ifcapable compound {
+do_test sort-7.5 {
+ execsql {
+ SELECT a FROM t4 UNION SELECT a FROM v4 ORDER BY 1;
+ }
+} {1 2 11 12}
+do_test sort-7.6 {
+ execsql {
+ SELECT b FROM t4 UNION SELECT a FROM v4 ORDER BY 1;
+ }
+} {1 2 11 12 1 11 12 2} ;# text from t4.b and numeric from v4.a
+do_test sort-7.7 {
+ execsql {
+ SELECT a FROM t4 UNION SELECT b FROM v4 ORDER BY 1;
+ }
+} {1 2 11 12 1 11 12 2} ;# numeric from t4.a and text from v4.b
+do_test sort-7.8 {
+ execsql {
+ SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1;
+ }
+} {1 11 12 2}
+} ;# ifcapable compound
+} ;# ifcapable view
+
+#### Version 3 works differently here:
+#do_test sort-7.9 {
+# execsql {
+# SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE numeric;
+# }
+#} {1 2 11 12}
+#do_test sort-7.10 {
+# execsql {
+# SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE integer;
+# }
+#} {1 2 11 12}
+#do_test sort-7.11 {
+# execsql {
+# SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE text;
+# }
+#} {1 11 12 2}
+#do_test sort-7.12 {
+# execsql {
+# SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE blob;
+# }
+#} {1 11 12 2}
+#do_test sort-7.13 {
+# execsql {
+# SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE clob;
+# }
+#} {1 11 12 2}
+#do_test sort-7.14 {
+# execsql {
+# SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE varchar;
+# }
+#} {1 11 12 2}
+
+# Ticket #297
+#
+do_test sort-8.1 {
+ execsql {
+ CREATE TABLE t5(a real, b text);
+ INSERT INTO t5 VALUES(100,'A1');
+ INSERT INTO t5 VALUES(100.0,'A2');
+ SELECT * FROM t5 ORDER BY a, b;
+ }
+} {100.0 A1 100.0 A2}
+
+
+ifcapable {bloblit} {
+# BLOBs should sort after TEXT
+#
+do_test sort-9.1 {
+ execsql {
+ CREATE TABLE t6(x, y);
+ INSERT INTO t6 VALUES(1,1);
+ INSERT INTO t6 VALUES(2,'1');
+ INSERT INTO t6 VALUES(3,x'31');
+ INSERT INTO t6 VALUES(4,NULL);
+ SELECT x FROM t6 ORDER BY y;
+ }
+} {4 1 2 3}
+do_test sort-9.2 {
+ execsql {
+ SELECT x FROM t6 ORDER BY y DESC;
+ }
+} {3 2 1 4}
+do_test sort-9.3 {
+ execsql {
+ SELECT x FROM t6 WHERE y<1
+ }
+} {}
+do_test sort-9.4 {
+ execsql {
+ SELECT x FROM t6 WHERE y<'1'
+ }
+} {1}
+do_test sort-9.5 {
+ execsql {
+ SELECT x FROM t6 WHERE y<x'31'
+ }
+} {1 2}
+do_test sort-9.6 {
+ execsql {
+ SELECT x FROM t6 WHERE y>1
+ }
+} {2 3}
+do_test sort-9.7 {
+ execsql {
+ SELECT x FROM t6 WHERE y>'1'
+ }
+} {3}
+} ;# endif bloblit
+
+# Ticket #1092 - ORDER BY on rowid fields.
+do_test sort-10.1 {
+ execsql {
+ CREATE TABLE t7(c INTEGER PRIMARY KEY);
+ INSERT INTO t7 VALUES(1);
+ INSERT INTO t7 VALUES(2);
+ INSERT INTO t7 VALUES(3);
+ INSERT INTO t7 VALUES(4);
+ }
+} {}
+do_test sort-10.2 {
+ execsql {
+ SELECT c FROM t7 WHERE c<=3 ORDER BY c DESC;
+ }
+} {3 2 1}
+do_test sort-10.3 {
+ execsql {
+ SELECT c FROM t7 WHERE c<3 ORDER BY c DESC;
+ }
+} {2 1}
+
+# ticket #1358. Just because one table in a join gives a unique
+# result does not mean they all do. We cannot disable sorting unless
+# all tables in the join give unique results.
+#
+do_test sort-11.1 {
+ execsql {
+ create table t8(a unique, b, c);
+ insert into t8 values(1,2,3);
+ insert into t8 values(2,3,4);
+ create table t9(x,y);
+ insert into t9 values(2,4);
+ insert into t9 values(2,3);
+ select y from t8, t9 where a=1 order by a, y;
+ }
+} {3 4}
+
+# Trouble reported on the mailing list. Check for overly aggressive
+# (which is to say, incorrect) optimization of order-by with a rowid
+# in a join.
+#
+do_test sort-12.1 {
+ execsql {
+ create table a (id integer primary key);
+ create table b (id integer primary key, aId integer, text);
+ insert into a values (1);
+ insert into b values (2, 1, 'xxx');
+ insert into b values (1, 1, 'zzz');
+ insert into b values (3, 1, 'yyy');
+ select a.id, b.id, b.text from a join b on (a.id = b.aId)
+ order by a.id, b.text;
+ }
+} {1 2 xxx 1 3 yyy 1 1 zzz}
+
+finish_test
diff --git a/test/speed1.test b/test/speed1.test
new file mode 100644
index 0000000..86d13ba
--- /dev/null
+++ b/test/speed1.test
@@ -0,0 +1,298 @@
+# 2006 November 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is measuring executing speed.
+#
+# $Id: speed1.test,v 1.11 2009/04/09 01:23:49 drh Exp $
+#
+
+sqlite3_shutdown
+#sqlite3_config_scratch 29000 1
+set old_lookaside [sqlite3_config_lookaside 1000 300]
+#sqlite3_config_pagecache 1024 10000
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+speed_trial_init speed1
+
+# Set a uniform random seed
+expr srand(0)
+
+set sqlout [open speed1.txt w]
+proc tracesql {sql} {
+ puts $::sqlout $sql\;
+}
+#db trace tracesql
+
+# The number_name procedure below converts its argment (an integer)
+# into a string which is the English-language name for that number.
+#
+# Example:
+#
+# puts [number_name 123] -> "one hundred twenty three"
+#
+set ones {zero one two three four five six seven eight nine
+ ten eleven twelve thirteen fourteen fifteen sixteen seventeen
+ eighteen nineteen}
+set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
+proc number_name {n} {
+ if {$n>=1000} {
+ set txt "[number_name [expr {$n/1000}]] thousand"
+ set n [expr {$n%1000}]
+ } else {
+ set txt {}
+ }
+ if {$n>=100} {
+ append txt " [lindex $::ones [expr {$n/100}]] hundred"
+ set n [expr {$n%100}]
+ }
+ if {$n>=20} {
+ append txt " [lindex $::tens [expr {$n/10}]]"
+ set n [expr {$n%10}]
+ }
+ if {$n>0} {
+ append txt " [lindex $::ones $n]"
+ }
+ set txt [string trim $txt]
+ if {$txt==""} {set txt zero}
+ return $txt
+}
+
+# Create a database schema.
+#
+do_test speed1-1.0 {
+ execsql {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=8192;
+ PRAGMA locking_mode=EXCLUSIVE;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
+ CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);
+ CREATE INDEX i2a ON t2(a);
+ CREATE INDEX i2b ON t2(b);
+ }
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ }
+} {i2a i2b t1 t2}
+
+
+# 50000 INSERTs on an unindexed table
+#
+set sql {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ append sql "INSERT INTO t1 VALUES($i,$r,'[number_name $r]');\n"
+}
+db eval BEGIN
+speed_trial speed1-insert1 50000 row $sql
+db eval COMMIT
+
+# 50000 INSERTs on an indexed table
+#
+set sql {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ append sql "INSERT INTO t2 VALUES($i,$r,'[number_name $r]');\n"
+}
+db eval BEGIN
+speed_trial speed1-insert2 50000 row $sql
+db eval COMMIT
+
+
+
+# 50 SELECTs on an integer comparison. There is no index so
+# a full table scan is required.
+#
+set sql {}
+for {set i 0} {$i<50} {incr i} {
+ set lwr [expr {$i*100}]
+ set upr [expr {($i+10)*100}]
+ append sql "SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;"
+}
+db eval BEGIN
+speed_trial speed1-select1 [expr {50*50000}] row $sql
+db eval COMMIT
+
+# 50 SELECTs on an LIKE comparison. There is no index so a full
+# table scan is required.
+#
+set sql {}
+for {set i 0} {$i<50} {incr i} {
+ append sql \
+ "SELECT count(*), avg(b) FROM t1 WHERE c LIKE '%[number_name $i]%';"
+}
+db eval BEGIN
+speed_trial speed1-select2 [expr {50*50000}] row $sql
+db eval COMMIT
+
+# Create indices
+#
+db eval BEGIN
+speed_trial speed1-createidx 150000 row {
+ CREATE INDEX i1a ON t1(a);
+ CREATE INDEX i1b ON t1(b);
+ CREATE INDEX i1c ON t1(c);
+}
+db eval COMMIT
+
+# 5000 SELECTs on an integer comparison where the integer is
+# indexed.
+#
+set sql {}
+for {set i 0} {$i<5000} {incr i} {
+ set lwr [expr {$i*100}]
+ set upr [expr {($i+10)*100}]
+ append sql "SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;"
+}
+db eval BEGIN
+speed_trial speed1-select3 5000 stmt $sql
+db eval COMMIT
+
+# 100000 random SELECTs against rowid.
+#
+set sql {}
+for {set i 1} {$i<=100000} {incr i} {
+ set id [expr {int(rand()*50000)+1}]
+ append sql "SELECT c FROM t1 WHERE rowid=$id;"
+}
+db eval BEGIN
+speed_trial speed1-select4 100000 row $sql
+db eval COMMIT
+
+# 100000 random SELECTs against a unique indexed column.
+#
+set sql {}
+for {set i 1} {$i<=100000} {incr i} {
+ set id [expr {int(rand()*50000)+1}]
+ append sql "SELECT c FROM t1 WHERE a=$id;"
+}
+db eval BEGIN
+speed_trial speed1-select5 100000 row $sql
+db eval COMMIT
+
+# 50000 random SELECTs against an indexed column text column
+#
+set sql {}
+db eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000} {
+ append sql "SELECT c FROM t1 WHERE c='$c';"
+}
+db eval BEGIN
+speed_trial speed1-select6 50000 row $sql
+db eval COMMIT
+
+
+# Vacuum
+speed_trial speed1-vacuum 100000 row VACUUM
+
+# 5000 updates of ranges where the field being compared is indexed.
+#
+set sql {}
+for {set i 0} {$i<5000} {incr i} {
+ set lwr [expr {$i*2}]
+ set upr [expr {($i+1)*2}]
+ append sql "UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr;"
+}
+db eval BEGIN
+speed_trial speed1-update1 5000 stmt $sql
+db eval COMMIT
+
+# 50000 single-row updates. An index is used to find the row quickly.
+#
+set sql {}
+for {set i 0} {$i<50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ append sql "UPDATE t1 SET b=$r WHERE a=$i;"
+}
+db eval BEGIN
+speed_trial speed1-update2 50000 row $sql
+db eval COMMIT
+
+# 1 big text update that touches every row in the table.
+#
+speed_trial speed1-update3 50000 row {
+ UPDATE t1 SET c=a;
+}
+
+# Many individual text updates. Each row in the table is
+# touched through an index.
+#
+set sql {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ append sql "UPDATE t1 SET c='[number_name $r]' WHERE a=$i;"
+}
+db eval BEGIN
+speed_trial speed1-update4 50000 row $sql
+db eval COMMIT
+
+# Delete all content in a table.
+#
+speed_trial speed1-delete1 50000 row {DELETE FROM t1}
+
+# Copy one table into another
+#
+speed_trial speed1-copy1 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Delete all content in a table, one row at a time.
+#
+speed_trial speed1-delete2 50000 row {DELETE FROM t1 WHERE 1}
+
+# Refill the table yet again
+#
+speed_trial speed1-copy2 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Drop the table and recreate it without its indices.
+#
+db eval BEGIN
+speed_trial speed1-drop1 50000 row {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
+}
+db eval COMMIT
+
+# Refill the table yet again. This copy should be faster because
+# there are no indices to deal with.
+#
+speed_trial speed1-copy3 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Select 20000 rows from the table at random.
+#
+speed_trial speed1-random1 50000 row {
+ SELECT rowid FROM t1 ORDER BY random() LIMIT 20000
+}
+
+# Delete 20000 random rows from the table.
+#
+speed_trial speed1-random-del1 20000 row {
+ DELETE FROM t1 WHERE rowid IN
+ (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)
+}
+do_test speed1-1.1 {
+ db one {SELECT count(*) FROM t1}
+} 30000
+
+
+# Delete 20000 more rows at random from the table.
+#
+speed_trial speed1-random-del2 20000 row {
+ DELETE FROM t1 WHERE rowid IN
+ (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)
+}
+do_test speed1-1.2 {
+ db one {SELECT count(*) FROM t1}
+} 10000
+speed_trial_summary speed1
+
+db close
+sqlite3_shutdown
+eval sqlite3_config_lookaside $old_lookaside
+sqlite3_initialize
+autoinstall_test_functions
+finish_test
diff --git a/test/speed1p.explain b/test/speed1p.explain
new file mode 100644
index 0000000..e32fedd
--- /dev/null
+++ b/test/speed1p.explain
@@ -0,0 +1,366 @@
+# 2008 March 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is measuring executing speed.
+#
+# This is a copy of speed1.test modified to user prepared statements.
+#
+# $Id: speed1p.explain,v 1.1 2008/04/16 12:57:48 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+speed_trial_init speed1
+
+# Set a uniform random seed
+expr srand(0)
+
+set sqlout [open speed1.txt w]
+proc tracesql {sql} {
+ puts $::sqlout $sql\;
+}
+#db trace tracesql
+
+# The number_name procedure below converts its argment (an integer)
+# into a string which is the English-language name for that number.
+#
+# Example:
+#
+# puts [number_name 123] -> "one hundred twenty three"
+#
+set ones {zero one two three four five six seven eight nine
+ ten eleven twelve thirteen fourteen fifteen sixteen seventeen
+ eighteen nineteen}
+set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
+proc number_name {n} {
+ if {$n>=1000} {
+ set txt "[number_name [expr {$n/1000}]] thousand"
+ set n [expr {$n%1000}]
+ } else {
+ set txt {}
+ }
+ if {$n>=100} {
+ append txt " [lindex $::ones [expr {$n/100}]] hundred"
+ set n [expr {$n%100}]
+ }
+ if {$n>=20} {
+ append txt " [lindex $::tens [expr {$n/10}]]"
+ set n [expr {$n%10}]
+ }
+ if {$n>0} {
+ append txt " [lindex $::ones $n]"
+ }
+ set txt [string trim $txt]
+ if {$txt==""} {set txt zero}
+ return $txt
+}
+
+# Create a database schema.
+#
+do_test speed1p-1.0 {
+ execsql {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=8192;
+ PRAGMA locking_mode=EXCLUSIVE;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
+ CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);
+ CREATE INDEX i2a ON t2(a);
+ CREATE INDEX i2b ON t2(b);
+ }
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ }
+} {i2a i2b t1 t2}
+
+
+# 50000 INSERTs on an unindexed table
+#
+set list {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ set x [number_name $r]
+ lappend list $i $r $x
+}
+set script {
+ foreach {i r x} $::list {
+ db eval {INSERT INTO t1 VALUES($i,$r,$x)}
+ }
+}
+explain {INSERT INTO t1 VALUES($i,$r,$x)}
+db eval BEGIN
+speed_trial_tcl speed1p-insert1 50000 row $script
+db eval COMMIT
+
+# 50000 INSERTs on an indexed table
+#
+set list {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ set x [number_name $r]
+ lappend list $i $r $x
+}
+set script {
+ foreach {i r x} $::list {
+ db eval {INSERT INTO t2 VALUES($i,$r,$x)}
+ }
+}
+explain {INSERT INTO t2 VALUES($i,$r,$x)}
+db eval BEGIN
+speed_trial_tcl speed1p-insert2 50000 row $script
+db eval COMMIT
+
+
+
+# 50 SELECTs on an integer comparison. There is no index so
+# a full table scan is required.
+#
+set list {}
+for {set i 0} {$i<50} {incr i} {
+ set lwr [expr {$i*100}]
+ set upr [expr {($i+10)*100}]
+ lappend list $lwr $upr
+}
+set script {
+ foreach {lwr upr} $::list {
+ db eval {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}
+ }
+}
+explain {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}
+db eval BEGIN
+speed_trial_tcl speed1p-select1 [expr {50*50000}] row $script
+db eval COMMIT
+
+# 50 SELECTs on an LIKE comparison. There is no index so a full
+# table scan is required.
+#
+set list {}
+for {set i 0} {$i<50} {incr i} {
+ lappend list "%[number_name $i]%"
+}
+set script {
+ foreach pattern $::list {
+ db eval {SELECT count(*), avg(b) FROM t1 WHERE c LIKE $pattern}
+ }
+}
+explain {SELECT count(*), avg(b) FROM t1 WHERE c LIKE $pattern}
+db eval BEGIN
+speed_trial_tcl speed1p-select2 [expr {50*50000}] row $script
+db eval COMMIT
+
+# Create indices
+#
+explain {CREATE INDEX i1a ON t1(a)}
+explain {CREATE INDEX i1b ON t1(b)}
+db eval BEGIN
+speed_trial speed1p-createidx 150000 row {
+ CREATE INDEX i1a ON t1(a);
+ CREATE INDEX i1b ON t1(b);
+ CREATE INDEX i1c ON t1(c);
+}
+db eval COMMIT
+
+# 5000 SELECTs on an integer comparison where the integer is
+# indexed.
+#
+set list {}
+for {set i 0} {$i<5000} {incr i} {
+ set lwr [expr {$i*100}]
+ set upr [expr {($i+10)*100}]
+ lappend list $lwr $upr
+}
+set script {
+ foreach {lwr upr} $::list {
+ db eval {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}
+ }
+}
+explain {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}
+db eval BEGIN
+speed_trial_tcl speed1p-select3 5000 stmt $script
+db eval COMMIT
+
+# 100000 random SELECTs against rowid.
+#
+set list {}
+for {set i 1} {$i<=100000} {incr i} {
+ set id [expr {int(rand()*50000)+1}]
+ lappend list $id
+}
+set script {
+ foreach id $::list {
+ db eval {SELECT c FROM t1 WHERE rowid=$id}
+ }
+}
+explain {SELECT c FROM t1 WHERE rowid=$id}
+db eval BEGIN
+speed_trial_tcl speed1p-select4 100000 row $script
+db eval COMMIT
+
+# 100000 random SELECTs against a unique indexed column.
+#
+set list {}
+for {set i 1} {$i<=100000} {incr i} {
+ set id [expr {int(rand()*50000)+1}]
+ lappend list $id
+}
+set script {
+ foreach id $::list {
+ db eval {SELECT c FROM t1 WHERE a=$id}
+ }
+}
+explain {SELECT c FROM t1 WHERE a=$id}
+db eval BEGIN
+speed_trial_tcl speed1p-select5 100000 row $script
+db eval COMMIT
+
+# 50000 random SELECTs against an indexed column text column
+#
+set list [db eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000}]
+set script {
+ foreach c $::list {
+ db eval {SELECT c FROM t1 WHERE c=$c}
+ }
+}
+explain {SELECT c FROM t1 WHERE c=$c}
+db eval BEGIN
+speed_trial_tcl speed1p-select6 50000 row $script
+db eval COMMIT
+
+
+# Vacuum
+speed_trial speed1p-vacuum 100000 row VACUUM
+
+# 5000 updates of ranges where the field being compared is indexed.
+#
+set list {}
+for {set i 0} {$i<5000} {incr i} {
+ set lwr [expr {$i*2}]
+ set upr [expr {($i+1)*2}]
+ lappend list $lwr $upr
+}
+set script {
+ foreach {lwr upr} $::list {
+ db eval {UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr}
+ }
+}
+explain {UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr}
+db eval BEGIN
+speed_trial_tcl speed1p-update1 5000 stmt $script
+db eval COMMIT
+
+# 50000 single-row updates. An index is used to find the row quickly.
+#
+set list {}
+for {set i 0} {$i<50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ lappend list $i $r
+}
+set script {
+ foreach {i r} $::list {
+ db eval {UPDATE t1 SET b=$r WHERE a=$i}
+ }
+}
+explain {UPDATE t1 SET b=$r WHERE a=$i}
+db eval BEGIN
+speed_trial_tcl speed1p-update2 50000 row $script
+db eval COMMIT
+
+# 1 big text update that touches every row in the table.
+#
+explain {UPDATE t1 SET c=a}
+speed_trial speed1p-update3 50000 row {
+ UPDATE t1 SET c=a;
+}
+
+# Many individual text updates. Each row in the table is
+# touched through an index.
+#
+set list {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ lappend list $i [number_name $r]
+}
+set script {
+ foreach {i x} $::list {
+ db eval {UPDATE t1 SET c=$x WHERE a=$i}
+ }
+}
+explain {UPDATE t1 SET c=$x WHERE a=$i}
+db eval BEGIN
+speed_trial_tcl speed1p-update4 50000 row $script
+db eval COMMIT
+
+# Delete all content in a table.
+#
+explain {DELETE FROM t1}
+speed_trial speed1p-delete1 50000 row {DELETE FROM t1}
+
+# Copy one table into another
+#
+explain {INSERT INTO t1 SELECT * FROM t2}
+speed_trial speed1p-copy1 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Delete all content in a table, one row at a time.
+#
+explain {DELETE FROM t1 WHERE 1}
+speed_trial speed1p-delete2 50000 row {DELETE FROM t1 WHERE 1}
+
+# Refill the table yet again
+#
+speed_trial speed1p-copy2 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Drop the table and recreate it without its indices.
+#
+explain {DROP TABLE t1}
+explain {CREATE TABLE tX(a INTEGER, b INTEGER, c TEXT)}
+db eval BEGIN
+speed_trial speed1p-drop1 50000 row {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
+}
+db eval COMMIT
+
+# Refill the table yet again. This copy should be faster because
+# there are no indices to deal with.
+#
+speed_trial speed1p-copy3 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Select 20000 rows from the table at random.
+#
+explain {SELECT rowid FROM t1 ORDER BY random() LIMIT 20000}
+speed_trial speed1p-random1 50000 row {
+ SELECT rowid FROM t1 ORDER BY random() LIMIT 20000
+}
+
+# Delete 20000 random rows from the table.
+#
+explain {DELETE FROM t1 WHERE rowid IN
+ (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)}
+speed_trial speed1p-random-del1 20000 row {
+ DELETE FROM t1 WHERE rowid IN
+ (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)
+}
+do_test speed1p-1.1 {
+ db one {SELECT count(*) FROM t1}
+} 30000
+
+
+# Delete 20000 more rows at random from the table.
+#
+speed_trial speed1p-random-del2 20000 row {
+ DELETE FROM t1 WHERE rowid IN
+ (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)
+}
+do_test speed1p-1.2 {
+ db one {SELECT count(*) FROM t1}
+} 10000
+speed_trial_summary speed1
+
+finish_test
diff --git a/test/speed1p.test b/test/speed1p.test
new file mode 100644
index 0000000..915f165
--- /dev/null
+++ b/test/speed1p.test
@@ -0,0 +1,346 @@
+# 2008 March 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is measuring executing speed.
+#
+# This is a copy of speed1.test modified to user prepared statements.
+#
+# $Id: speed1p.test,v 1.7 2009/04/09 01:23:49 drh Exp $
+#
+
+sqlite3_shutdown
+#sqlite3_config_scratch 29000 1
+set old_lookaside [sqlite3_config_lookaside 2048 300]
+#sqlite3_config_pagecache 1024 11000
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+speed_trial_init speed1
+
+# Set a uniform random seed
+expr srand(0)
+
+# The number_name procedure below converts its argment (an integer)
+# into a string which is the English-language name for that number.
+#
+# Example:
+#
+# puts [number_name 123] -> "one hundred twenty three"
+#
+set ones {zero one two three four five six seven eight nine
+ ten eleven twelve thirteen fourteen fifteen sixteen seventeen
+ eighteen nineteen}
+set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
+proc number_name {n} {
+ if {$n>=1000} {
+ set txt "[number_name [expr {$n/1000}]] thousand"
+ set n [expr {$n%1000}]
+ } else {
+ set txt {}
+ }
+ if {$n>=100} {
+ append txt " [lindex $::ones [expr {$n/100}]] hundred"
+ set n [expr {$n%100}]
+ }
+ if {$n>=20} {
+ append txt " [lindex $::tens [expr {$n/10}]]"
+ set n [expr {$n%10}]
+ }
+ if {$n>0} {
+ append txt " [lindex $::ones $n]"
+ }
+ set txt [string trim $txt]
+ if {$txt==""} {set txt zero}
+ return $txt
+}
+
+# Create a database schema.
+#
+do_test speed1p-1.0 {
+ execsql {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=500;
+ PRAGMA locking_mode=EXCLUSIVE;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
+ CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);
+ CREATE INDEX i2a ON t2(a);
+ CREATE INDEX i2b ON t2(b);
+ }
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ }
+} {i2a i2b t1 t2}
+
+
+# 50000 INSERTs on an unindexed table
+#
+set list {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ set x [number_name $r]
+ lappend list $i $r $x
+}
+set script {
+ foreach {i r x} $::list {
+ db eval {INSERT INTO t1 VALUES($i,$r,$x)}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-insert1 50000 row $script
+db eval COMMIT
+
+# 50000 INSERTs on an indexed table
+#
+set list {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ set x [number_name $r]
+ lappend list $i $r $x
+}
+set script {
+ foreach {i r x} $::list {
+ db eval {INSERT INTO t2 VALUES($i,$r,$x)}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-insert2 50000 row $script
+db eval COMMIT
+
+
+
+# 50 SELECTs on an integer comparison. There is no index so
+# a full table scan is required.
+#
+set list {}
+for {set i 0} {$i<50} {incr i} {
+ set lwr [expr {$i*100}]
+ set upr [expr {($i+10)*100}]
+ lappend list $lwr $upr
+}
+set script {
+ foreach {lwr upr} $::list {
+ db eval {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-select1 [expr {50*50000}] row $script
+db eval COMMIT
+
+# 50 SELECTs on an LIKE comparison. There is no index so a full
+# table scan is required.
+#
+set list {}
+for {set i 0} {$i<50} {incr i} {
+ lappend list "%[number_name $i]%"
+}
+set script {
+ foreach pattern $::list {
+ db eval {SELECT count(*), avg(b) FROM t1 WHERE c LIKE $pattern}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-select2 [expr {50*50000}] row $script
+db eval COMMIT
+
+# Create indices
+#
+db eval BEGIN
+speed_trial speed1p-createidx 150000 row {
+ CREATE INDEX i1a ON t1(a);
+ CREATE INDEX i1b ON t1(b);
+ CREATE INDEX i1c ON t1(c);
+}
+db eval COMMIT
+
+# 5000 SELECTs on an integer comparison where the integer is
+# indexed.
+#
+set list {}
+for {set i 0} {$i<5000} {incr i} {
+ set lwr [expr {$i*100}]
+ set upr [expr {($i+10)*100}]
+ lappend list $lwr $upr
+}
+set script {
+ foreach {lwr upr} $::list {
+ db eval {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-select3 5000 stmt $script
+db eval COMMIT
+
+# 100000 random SELECTs against rowid.
+#
+set list {}
+for {set i 1} {$i<=100000} {incr i} {
+ set id [expr {int(rand()*50000)+1}]
+ lappend list $id
+}
+set script {
+ foreach id $::list {
+ db eval {SELECT c FROM t1 WHERE rowid=$id}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-select4 100000 row $script
+db eval COMMIT
+
+# 100000 random SELECTs against a unique indexed column.
+#
+set list {}
+for {set i 1} {$i<=100000} {incr i} {
+ set id [expr {int(rand()*50000)+1}]
+ lappend list $id
+}
+set script {
+ foreach id $::list {
+ db eval {SELECT c FROM t1 WHERE a=$id}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-select5 100000 row $script
+db eval COMMIT
+
+# 50000 random SELECTs against an indexed column text column
+#
+set list [db eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000}]
+set script {
+ foreach c $::list {
+ db eval {SELECT c FROM t1 WHERE c=$c}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-select6 50000 row $script
+db eval COMMIT
+
+
+# Vacuum
+speed_trial speed1p-vacuum 100000 row VACUUM
+
+# 5000 updates of ranges where the field being compared is indexed.
+#
+set list {}
+for {set i 0} {$i<5000} {incr i} {
+ set lwr [expr {$i*2}]
+ set upr [expr {($i+1)*2}]
+ lappend list $lwr $upr
+}
+set script {
+ foreach {lwr upr} $::list {
+ db eval {UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-update1 5000 stmt $script
+db eval COMMIT
+
+# 50000 single-row updates. An index is used to find the row quickly.
+#
+set list {}
+for {set i 0} {$i<50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ lappend list $i $r
+}
+set script {
+ foreach {i r} $::list {
+ db eval {UPDATE t1 SET b=$r WHERE a=$i}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-update2 50000 row $script
+db eval COMMIT
+
+# 1 big text update that touches every row in the table.
+#
+speed_trial speed1p-update3 50000 row {
+ UPDATE t1 SET c=a;
+}
+
+# Many individual text updates. Each row in the table is
+# touched through an index.
+#
+set list {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ lappend list $i [number_name $r]
+}
+set script {
+ foreach {i x} $::list {
+ db eval {UPDATE t1 SET c=$x WHERE a=$i}
+ }
+}
+db eval BEGIN
+speed_trial_tcl speed1p-update4 50000 row $script
+db eval COMMIT
+
+# Delete all content in a table.
+#
+speed_trial speed1p-delete1 50000 row {DELETE FROM t1}
+
+# Copy one table into another
+#
+speed_trial speed1p-copy1 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Delete all content in a table, one row at a time.
+#
+speed_trial speed1p-delete2 50000 row {DELETE FROM t1 WHERE 1}
+
+# Refill the table yet again
+#
+speed_trial speed1p-copy2 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Drop the table and recreate it without its indices.
+#
+db eval BEGIN
+speed_trial speed1p-drop1 50000 row {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
+}
+db eval COMMIT
+
+# Refill the table yet again. This copy should be faster because
+# there are no indices to deal with.
+#
+speed_trial speed1p-copy3 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Select 20000 rows from the table at random.
+#
+speed_trial speed1p-random1 50000 row {
+ SELECT rowid FROM t1 ORDER BY random() LIMIT 20000
+}
+
+# Delete 20000 random rows from the table.
+#
+speed_trial speed1p-random-del1 20000 row {
+ DELETE FROM t1 WHERE rowid IN
+ (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)
+}
+do_test speed1p-1.1 {
+ db one {SELECT count(*) FROM t1}
+} 30000
+
+# Delete 20000 more rows at random from the table.
+#
+speed_trial speed1p-random-del2 20000 row {
+ DELETE FROM t1 WHERE rowid IN
+ (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)
+}
+do_test speed1p-1.2 {
+ db one {SELECT count(*) FROM t1}
+} 10000
+speed_trial_summary speed1
+
+db close
+sqlite3_shutdown
+eval sqlite3_config_lookaside $old_lookaside
+sqlite3_initialize
+autoinstall_test_functions
+finish_test
diff --git a/test/speed2.test b/test/speed2.test
new file mode 100644
index 0000000..f6d1a4c
--- /dev/null
+++ b/test/speed2.test
@@ -0,0 +1,339 @@
+# 2006 November 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is measuring executing speed.
+#
+# $Id: speed2.test,v 1.7 2007/04/16 15:02:20 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+speed_trial_init speed2
+
+# Set a uniform random seed
+expr srand(0)
+
+set sqlout [open speed2.txt w]
+proc tracesql {sql} {
+ puts $::sqlout $sql\;
+}
+#db trace tracesql
+
+# The number_name procedure below converts its argment (an integer)
+# into a string which is the English-language name for that number.
+#
+# Example:
+#
+# puts [number_name 123] -> "one hundred twenty three"
+#
+set ones {zero one two three four five six seven eight nine
+ ten eleven twelve thirteen fourteen fifteen sixteen seventeen
+ eighteen nineteen}
+set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
+proc number_name {n} {
+ if {$n>=1000} {
+ set txt "[number_name [expr {$n/1000}]] thousand"
+ set n [expr {$n%1000}]
+ } else {
+ set txt {}
+ }
+ if {$n>=100} {
+ append txt " [lindex $::ones [expr {$n/100}]] hundred"
+ set n [expr {$n%100}]
+ }
+ if {$n>=20} {
+ append txt " [lindex $::tens [expr {$n/10}]]"
+ set n [expr {$n%10}]
+ }
+ if {$n>0} {
+ append txt " [lindex $::ones $n]"
+ }
+ set txt [string trim $txt]
+ if {$txt==""} {set txt zero}
+ return $txt
+}
+
+# Create a database schema.
+#
+do_test speed2-1.0 {
+ execsql {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=8192;
+ PRAGMA locking_mode=EXCLUSIVE;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
+ CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);
+ CREATE INDEX i2a ON t2(a);
+ CREATE INDEX i2b ON t2(b);
+ }
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ }
+} {i2a i2b t1 t2}
+
+
+# 50000 INSERTs on an unindexed table
+#
+set sql {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ append sql "INSERT INTO t1 VALUES($i,$r,'[number_name $r]');\n"
+}
+db eval BEGIN
+speed_trial speed2-insert1 50000 row $sql
+db eval COMMIT
+
+# 50000 INSERTs on an indexed table
+#
+set sql {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ append sql "INSERT INTO t2 VALUES($i,$r,'[number_name $r]');\n"
+}
+db eval BEGIN
+speed_trial speed2-insert2 50000 row $sql
+db eval COMMIT
+
+
+
+# 50 SELECTs on an integer comparison. There is no index so
+# a full table scan is required.
+#
+set sql {}
+for {set i 0} {$i<50} {incr i} {
+ set lwr [expr {$i*100}]
+ set upr [expr {($i+10)*100}]
+ append sql "SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;"
+}
+speed_trial speed2-select1a [expr {50*50000}] row $sql
+
+# 50 SELECTs on an LIKE comparison. There is no index so a full
+# table scan is required.
+#
+set sql {}
+for {set i 0} {$i<50} {incr i} {
+ append sql \
+ "SELECT count(*), avg(b) FROM t1 WHERE c LIKE '%[number_name $i]%';"
+}
+speed_trial speed2-select2a [expr {50*50000}] row $sql
+
+# Vacuum
+speed_trial speed2-vacuum1 100000 row VACUUM
+
+# 50 SELECTs on an integer comparison. There is no index so
+# a full table scan is required.
+#
+set sql {}
+for {set i 0} {$i<50} {incr i} {
+ set lwr [expr {$i*100}]
+ set upr [expr {($i+10)*100}]
+ append sql "SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;"
+}
+speed_trial speed2-select1b [expr {50*50000}] row $sql
+
+# 50 SELECTs on an LIKE comparison. There is no index so a full
+# table scan is required.
+#
+set sql {}
+for {set i 0} {$i<50} {incr i} {
+ append sql \
+ "SELECT count(*), avg(b) FROM t1 WHERE c LIKE '%[number_name $i]%';"
+}
+speed_trial speed2-select2b [expr {50*50000}] row $sql
+
+# Create indices
+#
+db eval BEGIN
+speed_trial speed2-createidx 150000 row {
+ CREATE INDEX i1a ON t1(a);
+ CREATE INDEX i1b ON t1(b);
+ CREATE INDEX i1c ON t1(c);
+}
+db eval COMMIT
+
+# 5000 SELECTs on an integer comparison where the integer is
+# indexed.
+#
+set sql {}
+for {set i 0} {$i<5000} {incr i} {
+ set lwr [expr {$i*100}]
+ set upr [expr {($i+10)*100}]
+ append sql "SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;"
+}
+speed_trial speed2-select3a 5000 stmt $sql
+
+# 100000 random SELECTs against rowid.
+#
+set sql {}
+for {set i 1} {$i<=100000} {incr i} {
+ set id [expr {int(rand()*50000)+1}]
+ append sql "SELECT c=='hi' FROM t1 WHERE rowid=$id;\n"
+}
+speed_trial speed2-select4a 100000 row $sql
+
+# 100000 random SELECTs against a unique indexed column.
+#
+set sql {}
+for {set i 1} {$i<=100000} {incr i} {
+ set id [expr {int(rand()*50000)+1}]
+ append sql "SELECT c FROM t1 WHERE a=$id;"
+}
+speed_trial speed2-select5a 100000 row $sql
+
+# 50000 random SELECTs against an indexed column text column
+#
+set sql {}
+db eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000} {
+ append sql "SELECT c FROM t1 WHERE c='$c';"
+}
+speed_trial speed2-select6a 50000 row $sql
+
+# Vacuum
+speed_trial speed2-vacuum2 100000 row VACUUM
+
+
+# 5000 SELECTs on an integer comparison where the integer is
+# indexed.
+#
+set sql {}
+for {set i 0} {$i<5000} {incr i} {
+ set lwr [expr {$i*100}]
+ set upr [expr {($i+10)*100}]
+ append sql "SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;"
+}
+speed_trial speed2-select3b 5000 stmt $sql
+
+# 100000 random SELECTs against rowid.
+#
+set sql {}
+for {set i 1} {$i<=100000} {incr i} {
+ set id [expr {int(rand()*50000)+1}]
+ append sql "SELECT c=='hi' FROM t1 WHERE rowid=$id;\n"
+}
+speed_trial speed2-select4b 100000 row $sql
+
+# 100000 random SELECTs against a unique indexed column.
+#
+set sql {}
+for {set i 1} {$i<=100000} {incr i} {
+ set id [expr {int(rand()*50000)+1}]
+ append sql "SELECT c FROM t1 WHERE a=$id;"
+}
+speed_trial speed2-select5b 100000 row $sql
+
+# 50000 random SELECTs against an indexed column text column
+#
+set sql {}
+db eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000} {
+ append sql "SELECT c FROM t1 WHERE c='$c';"
+}
+speed_trial speed2-select6b 50000 row $sql
+
+# 5000 updates of ranges where the field being compared is indexed.
+#
+set sql {}
+for {set i 0} {$i<5000} {incr i} {
+ set lwr [expr {$i*2}]
+ set upr [expr {($i+1)*2}]
+ append sql "UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr;"
+}
+db eval BEGIN
+speed_trial speed2-update1 5000 stmt $sql
+db eval COMMIT
+
+# 50000 single-row updates. An index is used to find the row quickly.
+#
+set sql {}
+for {set i 0} {$i<50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ append sql "UPDATE t1 SET b=$r WHERE a=$i;"
+}
+db eval BEGIN
+speed_trial speed2-update2 50000 row $sql
+db eval COMMIT
+
+# 1 big text update that touches every row in the table.
+#
+speed_trial speed2-update3 50000 row {
+ UPDATE t1 SET c=a;
+}
+
+# Many individual text updates. Each row in the table is
+# touched through an index.
+#
+set sql {}
+for {set i 1} {$i<=50000} {incr i} {
+ set r [expr {int(rand()*500000)}]
+ append sql "UPDATE t1 SET c='[number_name $r]' WHERE a=$i;"
+}
+db eval BEGIN
+speed_trial speed2-update4 50000 row $sql
+db eval COMMIT
+
+# Delete all content in a table.
+#
+speed_trial speed2-delete1 50000 row {DELETE FROM t1}
+
+# Copy one table into another
+#
+speed_trial speed2-copy1 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Delete all content in a table, one row at a time.
+#
+speed_trial speed2-delete2 50000 row {DELETE FROM t1 WHERE 1}
+
+# Refill the table yet again
+#
+speed_trial speed2-copy2 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Drop the table and recreate it without its indices.
+#
+db eval BEGIN
+speed_trial speed2-drop1 50000 row {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
+}
+db eval COMMIT
+
+# Refill the table yet again. This copy should be faster because
+# there are no indices to deal with.
+#
+speed_trial speed2-copy3 50000 row {INSERT INTO t1 SELECT * FROM t2}
+
+# Select 20000 rows from the table at random.
+#
+speed_trial speed2-random1 50000 row {
+ SELECT rowid FROM t1 ORDER BY random() LIMIT 20000
+}
+
+# Delete 20000 random rows from the table.
+#
+speed_trial speed2-random-del1 20000 row {
+ DELETE FROM t1 WHERE rowid IN
+ (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)
+}
+do_test speed2-1.1 {
+ db one {SELECT count(*) FROM t1}
+} 30000
+
+
+# Delete 20000 more rows at random from the table.
+#
+speed_trial speed2-random-del2 20000 row {
+ DELETE FROM t1 WHERE rowid IN
+ (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)
+}
+do_test speed2-1.2 {
+ db one {SELECT count(*) FROM t1}
+} 10000
+speed_trial_summary speed2
+
+
+finish_test
diff --git a/test/speed3.test b/test/speed3.test
new file mode 100644
index 0000000..1beaeb7
--- /dev/null
+++ b/test/speed3.test
@@ -0,0 +1,172 @@
+# 2007 May 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing that the overflow-page related
+# enhancements added after version 3.3.17 speed things up.
+#
+# $Id: speed3.test,v 1.6 2009/07/09 02:48:24 shane Exp $
+#
+
+#---------------------------------------------------------------------
+# Test plan:
+#
+# If auto-vacuum is enabled for the database, the following cases
+# should show performance improvement with respect to 3.3.17.
+#
+# + When deleting rows that span overflow pages. This is faster
+# because the overflow pages no longer need to be read before
+# they can be moved to the free list (test cases speed3-1.X).
+#
+# + When reading a column value stored on an overflow page that
+# is not the first overflow page for the row. The improvement
+# in this case is because the overflow pages between the tree
+# page and the overflow page containing the value do not have
+# to be read (test cases speed3-2.X).
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !tclvar||!attach {
+ finish_test
+ return
+}
+
+speed_trial_init speed1
+
+# Set a uniform random seed
+expr srand(0)
+
+set ::NROW 1000
+
+# The number_name procedure below converts its argment (an integer)
+# into a string which is the English-language name for that number.
+#
+# Example:
+#
+# puts [number_name 123] -> "one hundred twenty three"
+#
+set ones {zero one two three four five six seven eight nine
+ ten eleven twelve thirteen fourteen fifteen sixteen seventeen
+ eighteen nineteen}
+set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
+proc number_name {n} {
+ if {$n>=1000} {
+ set txt "[number_name [expr {$n/1000}]] thousand"
+ set n [expr {$n%1000}]
+ } else {
+ set txt {}
+ }
+ if {$n>=100} {
+ append txt " [lindex $::ones [expr {$n/100}]] hundred"
+ set n [expr {$n%100}]
+ }
+ if {$n>=20} {
+ append txt " [lindex $::tens [expr {$n/10}]]"
+ set n [expr {$n%10}]
+ }
+ if {$n>0} {
+ append txt " [lindex $::ones $n]"
+ }
+ set txt [string trim $txt]
+ if {$txt==""} {set txt zero}
+ return $txt
+}
+
+proc populate_t1 {db} {
+ $db transaction {
+ for {set ii 0} {$ii < $::NROW} {incr ii} {
+ set N [number_name $ii]
+ set repeats [expr {(10000/[string length $N])+1}]
+ set text [string range [string repeat $N $repeats] 0 10000]
+ $db eval {INSERT INTO main.t1 VALUES($ii, $text, $ii)}
+ }
+ $db eval {INSERT INTO aux.t1 SELECT * FROM main.t1}
+ }
+}
+
+
+proc io_log {db} {
+ db_enter db
+ array set stats1 [btree_pager_stats [btree_from_db db]]
+ array set stats2 [btree_pager_stats [btree_from_db db 2]]
+ db_leave db
+# puts "1: [array get stats1]"
+# puts "2: [array get stats2]"
+ puts "Incrvacuum: Read $stats1(read), wrote $stats1(write)"
+ puts "Normal : Read $stats2(read), wrote $stats2(write)"
+}
+
+proc reset_db {} {
+ db close
+ sqlite3 db test.db
+ db eval {
+ PRAGMA main.cache_size = 200000;
+ PRAGMA main.auto_vacuum = 'incremental';
+ ATTACH 'test2.db' AS 'aux';
+ PRAGMA aux.auto_vacuum = 'none';
+ }
+}
+
+forcedelete test2.db test2.db-journal
+reset_db
+
+# Set up a database in auto-vacuum mode and create a database schema.
+#
+do_test speed3-0.1 {
+ execsql {
+ CREATE TABLE main.t1(a INTEGER, b TEXT, c INTEGER);
+ }
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ }
+} {t1}
+do_test speed3-0.2 {
+ execsql {
+ CREATE TABLE aux.t1(a INTEGER, b TEXT, c INTEGER);
+ }
+ execsql {
+ SELECT name FROM aux.sqlite_master ORDER BY 1;
+ }
+} {t1}
+do_test speed3-0.3 {
+ populate_t1 db
+ execsql {
+ SELECT count(*) FROM main.t1;
+ SELECT count(*) FROM aux.t1;
+ }
+} "$::NROW $::NROW"
+do_test speed3-0.4 {
+ execsql {
+ PRAGMA main.auto_vacuum;
+ PRAGMA aux.auto_vacuum;
+ }
+} {2 0}
+
+# Delete all content in a table, one row at a time.
+#
+#io_log db
+reset_db
+speed_trial speed3-1.incrvacuum $::NROW row {DELETE FROM main.t1 WHERE 1}
+speed_trial speed3-1.normal $::NROW row {DELETE FROM aux.t1 WHERE 1}
+io_log db
+
+# Select the "C" column (located at the far end of the overflow
+# chain) from each table row.
+#
+#db eval {PRAGMA incremental_vacuum(500000)}
+populate_t1 db
+reset_db
+speed_trial speed3-2.incrvacuum $::NROW row {SELECT c FROM main.t1}
+speed_trial speed3-2.normal $::NROW row {SELECT c FROM aux.t1}
+io_log db
+
+finish_test
diff --git a/test/speed4.test b/test/speed4.test
new file mode 100644
index 0000000..2ccdaf5
--- /dev/null
+++ b/test/speed4.test
@@ -0,0 +1,231 @@
+# 2007 October 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is measuring executing speed. More specifically,
+# the focus is on the speed of:
+#
+# * joins
+# * views
+# * sub-selects
+# * triggers
+#
+# $Id: speed4.test,v 1.2 2008/07/12 14:52:20 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+speed_trial_init speed1
+
+# Set a uniform random seed
+expr srand(0)
+
+set sqlout [open speed1.txt w]
+proc tracesql {sql} {
+ puts $::sqlout $sql\;
+}
+#db trace tracesql
+
+# The number_name procedure below converts its argment (an integer)
+# into a string which is the English-language name for that number.
+#
+# Example:
+#
+# puts [number_name 123] -> "one hundred twenty three"
+#
+set ones {zero one two three four five six seven eight nine
+ ten eleven twelve thirteen fourteen fifteen sixteen seventeen
+ eighteen nineteen}
+set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
+proc number_name {n} {
+ if {$n>=1000} {
+ set txt "[number_name [expr {$n/1000}]] thousand"
+ set n [expr {$n%1000}]
+ } else {
+ set txt {}
+ }
+ if {$n>=100} {
+ append txt " [lindex $::ones [expr {$n/100}]] hundred"
+ set n [expr {$n%100}]
+ }
+ if {$n>=20} {
+ append txt " [lindex $::tens [expr {$n/10}]]"
+ set n [expr {$n%10}]
+ }
+ if {$n>0} {
+ append txt " [lindex $::ones $n]"
+ }
+ set txt [string trim $txt]
+ if {$txt==""} {set txt zero}
+ return $txt
+}
+
+# Summary of tests:
+#
+# speed4-join1: Join three tables using IPK index.
+# speed4-join2: Join three tables using an index.
+# speed4-join3: Join two tables without an index.
+#
+# speed4-view1: Querying a view.
+# speed4-table1: Same queries as in speed4-view1, but run directly against
+# the tables for comparison purposes.
+#
+# speed4-subselect1: A SELECT statement that uses many sub-queries..
+#
+# speed4-trigger1: An INSERT statement that fires a trigger.
+# speed4-trigger2: An UPDATE statement that fires a trigger.
+# speed4-trigger3: A DELETE statement that fires a trigger.
+# speed4-notrigger1: Same operation as trigger1, but without the trigger.
+# speed4-notrigger2: " trigger2 "
+# speed4-notrigger3: " trigger3 "
+#
+
+# Set up the schema. Each of the tables t1, t2 and t3 contain 50,000 rows.
+# This creates a database of around 16MB.
+execsql {
+ BEGIN;
+ CREATE TABLE t1(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ CREATE TABLE t2(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ CREATE TABLE t3(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+
+ CREATE VIEW v1 AS SELECT rowid, i, t FROM t1;
+ CREATE VIEW v2 AS SELECT rowid, i, t FROM t2;
+ CREATE VIEW v3 AS SELECT rowid, i, t FROM t3;
+}
+for {set jj 1} {$jj <= 3} {incr jj} {
+ set stmt [string map "%T% t$jj" {INSERT INTO %T% VALUES(NULL, $i, $t)}]
+ for {set ii 0} {$ii < 50000} {incr ii} {
+ set i [expr {int(rand()*50000)}]
+ set t [number_name $i]
+ execsql $stmt
+ }
+}
+execsql {
+ CREATE INDEX i1 ON t1(t);
+ CREATE INDEX i2 ON t2(t);
+ CREATE INDEX i3 ON t3(t);
+ COMMIT;
+}
+
+# Before running these tests, disable the compiled statement cache built into
+# the Tcl interface. This is because we want to test the speed of SQL
+# compilation as well as execution.
+#
+db cache size 0
+
+# Join t1, t2, t3 on IPK.
+set sql "SELECT * FROM t1, t2, t3 WHERE t1.oid = t2.oid AND t2.oid = t3.oid"
+speed_trial speed4-join1 50000 row $sql
+
+# Join t1, t2, t3 on the non-IPK index.
+set sql "SELECT * FROM t1, t2, t3 WHERE t1.t = t2.t AND t2.t = t3.t"
+speed_trial speed4-join2 50000 row $sql
+
+# Run 10000 simple queries against the views.
+set sql ""
+for {set ii 1} {$ii < 10000} {incr ii} {
+ append sql "SELECT * FROM v[expr {($ii%3)+1}] WHERE rowid = [expr {$ii*3}];"
+}
+speed_trial speed4-view1 10000 stmt $sql
+
+# Run the same 10000 simple queries as in the previous test case against
+# the underlying tables. The compiled vdbe programs should be identical, so
+# the only difference in running time is the extra time taken to compile
+# the view definitions.
+#
+set sql ""
+for {set ii 1} {$ii < 10000} {incr ii} {
+ append sql "SELECT t FROM t[expr {($ii%3)+1}] WHERE rowid = [expr {$ii*3}];"
+}
+speed_trial speed4-table1 10000 stmt $sql
+
+# Run a SELECT that uses sub-queries 10000 times. A total of 30000 sub-selects.
+#
+set sql ""
+for {set ii 1} {$ii < 10000} {incr ii} {
+ append sql "
+ SELECT (SELECT t FROM t1 WHERE rowid = [expr {$ii*3}]),
+ (SELECT t FROM t2 WHERE rowid = [expr {$ii*3}]),
+ (SELECT t FROM t3 WHERE rowid = [expr {$ii*3}])
+ ;"
+}
+speed_trial speed4-subselect1 10000 stmt $sql
+
+# The following block tests the speed of some DML statements that cause
+# triggers to fire.
+#
+execsql {
+ CREATE TABLE log(op TEXT, r INTEGER, i INTEGER, t TEXT);
+ CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ CREATE TRIGGER t4_trigger1 AFTER INSERT ON t4 BEGIN
+ INSERT INTO log VALUES('INSERT INTO t4', new.rowid, new.i, new.t);
+ END;
+ CREATE TRIGGER t4_trigger2 AFTER UPDATE ON t4 BEGIN
+ INSERT INTO log VALUES('UPDATE OF t4', new.rowid, new.i, new.t);
+ END;
+ CREATE TRIGGER t4_trigger3 AFTER DELETE ON t4 BEGIN
+ INSERT INTO log VALUES('DELETE OF t4', old.rowid, old.i, old.t);
+ END;
+ BEGIN;
+}
+set sql ""
+for {set ii 1} {$ii < 10000} {incr ii} {
+ append sql "INSERT INTO t4 VALUES(NULL, $ii, '[number_name $ii]');"
+}
+speed_trial speed4-trigger1 10000 stmt $sql
+set sql ""
+for {set ii 1} {$ii < 20000} {incr ii 2} {
+ set ii2 [expr {$ii*2}]
+ append sql "
+ UPDATE t4 SET i = $ii2, t = '[number_name $ii2]' WHERE rowid = $ii;
+ "
+}
+speed_trial speed4-trigger2 10000 stmt $sql
+set sql ""
+for {set ii 1} {$ii < 20000} {incr ii 2} {
+ append sql "DELETE FROM t4 WHERE rowid = $ii;"
+}
+speed_trial speed4-trigger3 10000 stmt $sql
+execsql {COMMIT}
+
+# The following block contains the same tests as the above block that
+# tests triggers, with one crucial difference: no triggers are defined.
+# So the difference in speed between these tests and the preceding ones
+# is the amount of time taken to compile and execute the trigger programs.
+#
+execsql {
+ DROP TABLE t4;
+ DROP TABLE log;
+ VACUUM;
+ CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ BEGIN;
+}
+set sql ""
+for {set ii 1} {$ii < 10000} {incr ii} {
+ append sql "INSERT INTO t4 VALUES(NULL, $ii, '[number_name $ii]');"
+}
+speed_trial speed4-notrigger1 10000 stmt $sql
+set sql ""
+for {set ii 1} {$ii < 20000} {incr ii 2} {
+ set ii2 [expr {$ii*2}]
+ append sql "
+ UPDATE t4 SET i = $ii2, t = '[number_name $ii2]' WHERE rowid = $ii;
+ "
+}
+speed_trial speed4-notrigger2 10000 stmt $sql
+set sql ""
+for {set ii 1} {$ii < 20000} {incr ii 2} {
+ append sql "DELETE FROM t4 WHERE rowid = $ii;"
+}
+speed_trial speed4-notrigger3 10000 stmt $sql
+execsql {COMMIT}
+
+speed_trial_summary speed4
+finish_test
diff --git a/test/speed4p.explain b/test/speed4p.explain
new file mode 100644
index 0000000..a713955
--- /dev/null
+++ b/test/speed4p.explain
@@ -0,0 +1,283 @@
+# 2007 October 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is measuring executing speed. More specifically,
+# the focus is on the speed of:
+#
+# * joins
+# * views
+# * sub-selects
+# * triggers
+#
+# $Id: speed4p.explain,v 1.1 2008/04/16 12:57:48 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+speed_trial_init speed1
+
+# Set a uniform random seed
+expr srand(0)
+
+set sqlout [open speed1.txt w]
+proc tracesql {sql} {
+ puts $::sqlout $sql\;
+}
+#db trace tracesql
+
+# The number_name procedure below converts its argment (an integer)
+# into a string which is the English-language name for that number.
+#
+# Example:
+#
+# puts [number_name 123] -> "one hundred twenty three"
+#
+set ones {zero one two three four five six seven eight nine
+ ten eleven twelve thirteen fourteen fifteen sixteen seventeen
+ eighteen nineteen}
+set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
+proc number_name {n} {
+ if {$n>=1000} {
+ set txt "[number_name [expr {$n/1000}]] thousand"
+ set n [expr {$n%1000}]
+ } else {
+ set txt {}
+ }
+ if {$n>=100} {
+ append txt " [lindex $::ones [expr {$n/100}]] hundred"
+ set n [expr {$n%100}]
+ }
+ if {$n>=20} {
+ append txt " [lindex $::tens [expr {$n/10}]]"
+ set n [expr {$n%10}]
+ }
+ if {$n>0} {
+ append txt " [lindex $::ones $n]"
+ }
+ set txt [string trim $txt]
+ if {$txt==""} {set txt zero}
+ return $txt
+}
+
+# Summary of tests:
+#
+# speed4p-join1: Join three tables using IPK index.
+# speed4p-join2: Join three tables using an index.
+# speed4p-join3: Join two tables without an index.
+#
+# speed4p-view1: Querying a view.
+# speed4p-table1: Same queries as in speed4p-view1, but run directly against
+# the tables for comparison purposes.
+#
+# speed4p-subselect1: A SELECT statement that uses many sub-queries..
+#
+# speed4p-trigger1: An INSERT statement that fires a trigger.
+# speed4p-trigger2: An UPDATE statement that fires a trigger.
+# speed4p-trigger3: A DELETE statement that fires a trigger.
+# speed4p-notrigger1: Same operation as trigger1, but without the trigger.
+# speed4p-notrigger2: " trigger2 "
+# speed4p-notrigger3: " trigger3 "
+#
+
+# Set up the schema. Each of the tables t1, t2 and t3 contain 50,000 rows.
+# This creates a database of around 16MB.
+execsql {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=8192;
+ PRAGMA locking_mode=EXCLUSIVE;
+ BEGIN;
+ CREATE TABLE t1(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ CREATE TABLE t2(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ CREATE TABLE t3(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+
+ CREATE VIEW v1 AS SELECT rowid, i, t FROM t1;
+ CREATE VIEW v2 AS SELECT rowid, i, t FROM t2;
+ CREATE VIEW v3 AS SELECT rowid, i, t FROM t3;
+}
+for {set jj 1} {$jj <= 3} {incr jj} {
+ set stmt [string map "%T% t$jj" {INSERT INTO %T% VALUES(NULL, $i, $t)}]
+ for {set ii 0} {$ii < 50000} {incr ii} {
+ set i [expr {int(rand()*50000)}]
+ set t [number_name $i]
+ execsql $stmt
+ }
+}
+execsql {
+ CREATE INDEX i1 ON t1(t);
+ CREATE INDEX i2 ON t2(t);
+ CREATE INDEX i3 ON t3(t);
+ COMMIT;
+}
+
+# Before running these tests, disable the compiled statement cache built into
+# the Tcl interface. This is because we want to test the speed of SQL
+# compilation as well as execution.
+#
+db cache size 0
+
+# Join t1, t2, t3 on IPK.
+set sql "SELECT * FROM t1, t2, t3 WHERE t1.oid = t2.oid AND t2.oid = t3.oid"
+explain $sql
+speed_trial speed4p-join1 50000 row $sql
+
+# Join t1, t2, t3 on the non-IPK index.
+set sql "SELECT * FROM t1, t2, t3 WHERE t1.t = t2.t AND t2.t = t3.t"
+explain $sql
+speed_trial speed4p-join2 50000 row $sql
+
+# Run 10000 simple queries against the views.
+set script {
+ for {set ii 1} {$ii < 10000} {incr ii} {
+ set v [expr {$ii*3}]
+ set t [expr {$ii%3+1}]
+ db eval "SELECT * FROM v$t WHERE rowid = \$v"
+ }
+}
+explain {SELECT * FROm v1 WHERE rowid=$v}
+speed_trial_tcl speed4p-view1 10000 stmt $script
+
+# Run the same 10000 simple queries as in the previous test case against
+# the underlying tables. The compiled vdbe programs should be identical, so
+# the only difference in running time is the extra time taken to compile
+# the view definitions.
+#
+set script {
+ for {set ii 1} {$ii < 10000} {incr ii} {
+ set v [expr {$ii*3}]
+ set t [expr {$ii%3+1}]
+ db eval "SELECT t FROM t$t WHERE rowid = \$v"
+ }
+}
+explain {SELECT * FROM t1 WHERE rowid=$v}
+speed_trial_tcl speed4p-table1 10000 stmt $script
+
+# Run a SELECT that uses sub-queries 10000 times. A total of 30000 sub-selects.
+#
+set script {
+ for {set ii 1} {$ii < 10000} {incr ii} {
+ set v [expr {$ii*3}]
+ db eval {
+ SELECT (SELECT t FROM t1 WHERE rowid = $v),
+ (SELECT t FROM t2 WHERE rowid = $v),
+ (SELECT t FROM t3 WHERE rowid = $v)
+ }
+ }
+}
+explain {
+ SELECT (SELECT t FROM t1 WHERE rowid = $v),
+ (SELECT t FROM t2 WHERE rowid = $v),
+ (SELECT t FROM t3 WHERE rowid = $v)
+}
+speed_trial_tcl speed4p-subselect1 10000 stmt $script
+
+# The following block tests the speed of some DML statements that cause
+# triggers to fire.
+#
+execsql {
+ CREATE TABLE log(op TEXT, r INTEGER, i INTEGER, t TEXT);
+ CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ CREATE TRIGGER t4_trigger1 AFTER INSERT ON t4 BEGIN
+ INSERT INTO log VALUES('INSERT INTO t4', new.rowid, new.i, new.t);
+ END;
+ CREATE TRIGGER t4_trigger2 AFTER UPDATE ON t4 BEGIN
+ INSERT INTO log VALUES('UPDATE OF t4', new.rowid, new.i, new.t);
+ END;
+ CREATE TRIGGER t4_trigger3 AFTER DELETE ON t4 BEGIN
+ INSERT INTO log VALUES('DELETE OF t4', old.rowid, old.i, old.t);
+ END;
+ BEGIN;
+}
+set list {}
+for {set ii 1} {$ii < 10000} {incr ii} {
+ lappend list $ii [number_name $ii]
+}
+set script {
+ foreach {ii name} $::list {
+ db eval {INSERT INTO t4 VALUES(NULL, $ii, $name)}
+ }
+}
+explain {INSERT INTO t4 VALUES(NULL, $ii, $name)}
+speed_trial_tcl speed4p-trigger1 10000 stmt $script
+
+set list {}
+for {set ii 1} {$ii < 20000} {incr ii 2} {
+ set ii2 [expr {$ii*2}]
+ lappend list $ii $ii2 [number_name $ii2]
+}
+set script {
+ foreach {ii ii2 name} $::list {
+ db eval {
+ UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii;
+ }
+ }
+}
+explain {UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii}
+speed_trial_tcl speed4p-trigger2 10000 stmt $script
+
+set script {
+ for {set ii 1} {$ii < 20000} {incr ii 2} {
+ db eval {DELETE FROM t4 WHERE rowid = $ii}
+ }
+}
+explain {DELETE FROM t4 WHERE rowid = $ii}
+speed_trial_tcl speed4p-trigger3 10000 stmt $script
+execsql {COMMIT}
+
+# The following block contains the same tests as the above block that
+# tests triggers, with one crucial difference: no triggers are defined.
+# So the difference in speed between these tests and the preceding ones
+# is the amount of time taken to compile and execute the trigger programs.
+#
+execsql {
+ DROP TABLE t4;
+ DROP TABLE log;
+ VACUUM;
+ CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ BEGIN;
+}
+set list {}
+for {set ii 1} {$ii < 10000} {incr ii} {
+ lappend list $ii [number_name $ii]
+}
+set script {
+ foreach {ii name} $::list {
+ db eval {INSERT INTO t4 VALUES(NULL, $ii, $name);}
+ }
+}
+explain {INSERT INTO t4 VALUES(NULL, $ii, $name)}
+speed_trial_tcl speed4p-notrigger1 10000 stmt $script
+
+set list {}
+for {set ii 1} {$ii < 20000} {incr ii 2} {
+ set ii2 [expr {$ii*2}]
+ lappend list $ii $ii2 [number_name $ii2]
+}
+set script {
+ foreach {ii ii2 name} $::list {
+ db eval {
+ UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii;
+ }
+ }
+}
+explain {UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii}
+speed_trial_tcl speed4p-notrigger2 10000 stmt $script
+
+set script {
+ for {set ii 1} {$ii < 20000} {incr ii 2} {
+ db eval {DELETE FROM t4 WHERE rowid = $ii}
+ }
+}
+explain {DELETE FROM t4 WHERE rowid = $ii}
+speed_trial_tcl speed4p-notrigger3 10000 stmt $script
+execsql {COMMIT}
+
+speed_trial_summary speed4
+finish_test
diff --git a/test/speed4p.test b/test/speed4p.test
new file mode 100644
index 0000000..024232e
--- /dev/null
+++ b/test/speed4p.test
@@ -0,0 +1,292 @@
+# 2007 October 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is measuring executing speed. More specifically,
+# the focus is on the speed of:
+#
+# * joins
+# * views
+# * sub-selects
+# * triggers
+#
+# $Id: speed4p.test,v 1.4 2008/04/10 13:32:37 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+speed_trial_init speed1
+
+# Set a uniform random seed
+expr srand(0)
+
+set sqlout [open speed1.txt w]
+proc tracesql {sql} {
+ puts $::sqlout $sql\;
+}
+#db trace tracesql
+
+# The number_name procedure below converts its argment (an integer)
+# into a string which is the English-language name for that number.
+#
+# Example:
+#
+# puts [number_name 123] -> "one hundred twenty three"
+#
+set ones {zero one two three four five six seven eight nine
+ ten eleven twelve thirteen fourteen fifteen sixteen seventeen
+ eighteen nineteen}
+set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
+proc number_name {n} {
+ if {$n>=1000} {
+ set txt "[number_name [expr {$n/1000}]] thousand"
+ set n [expr {$n%1000}]
+ } else {
+ set txt {}
+ }
+ if {$n>=100} {
+ append txt " [lindex $::ones [expr {$n/100}]] hundred"
+ set n [expr {$n%100}]
+ }
+ if {$n>=20} {
+ append txt " [lindex $::tens [expr {$n/10}]]"
+ set n [expr {$n%10}]
+ }
+ if {$n>0} {
+ append txt " [lindex $::ones $n]"
+ }
+ set txt [string trim $txt]
+ if {$txt==""} {set txt zero}
+ return $txt
+}
+
+# Summary of tests:
+#
+# speed4p-join1: Join three tables using IPK index.
+# speed4p-join2: Join three tables using an index.
+# speed4p-join3: Join two tables without an index.
+#
+# speed4p-view1: Querying a view.
+# speed4p-table1: Same queries as in speed4p-view1, but run directly against
+# the tables for comparison purposes.
+#
+# speed4p-subselect1: A SELECT statement that uses many sub-queries..
+#
+# speed4p-trigger1: An INSERT statement that fires a trigger.
+# speed4p-trigger2: An UPDATE statement that fires a trigger.
+# speed4p-trigger3: A DELETE statement that fires a trigger.
+# speed4p-notrigger1: Same operation as trigger1, but without the trigger.
+# speed4p-notrigger2: " trigger2 "
+# speed4p-notrigger3: " trigger3 "
+#
+
+# Set up the schema. Each of the tables t1, t2 and t3 contain 50,000 rows.
+# This creates a database of around 16MB.
+execsql {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=8192;
+ PRAGMA locking_mode=EXCLUSIVE;
+ BEGIN;
+ CREATE TABLE t1(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ CREATE TABLE t2(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ CREATE TABLE t3(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+
+ CREATE VIEW v1 AS SELECT rowid, i, t FROM t1;
+ CREATE VIEW v2 AS SELECT rowid, i, t FROM t2;
+ CREATE VIEW v3 AS SELECT rowid, i, t FROM t3;
+}
+for {set jj 1} {$jj <= 3} {incr jj} {
+ set stmt [string map "%T% t$jj" {INSERT INTO %T% VALUES(NULL, $i, $t)}]
+ for {set ii 0} {$ii < 50000} {incr ii} {
+ set i [expr {int(rand()*50000)}]
+ set t [number_name $i]
+ execsql $stmt
+ }
+}
+execsql {
+ CREATE INDEX i1 ON t1(t);
+ CREATE INDEX i2 ON t2(t);
+ CREATE INDEX i3 ON t3(t);
+ COMMIT;
+}
+
+# Join t1, t2, t3 on IPK.
+set sql "SELECT * FROM t1, t2, t3 WHERE t1.oid = t2.oid AND t2.oid = t3.oid"
+speed_trial speed4p-join1 50000 row $sql
+
+# Join t1, t2, t3 on the non-IPK index.
+set sql "SELECT * FROM t1, t2, t3 WHERE t1.t = t2.t AND t2.t = t3.t"
+speed_trial speed4p-join2 50000 row $sql
+
+# Run 10000 simple queries against the views.
+set script {
+ for {set ii 1} {$ii < 10000} {incr ii} {
+ set v [expr {$ii*3}]
+ set t [expr {$ii%3+1}]
+ db eval "SELECT * FROM v$t WHERE rowid = \$v"
+ }
+}
+speed_trial_tcl speed4p-view1 10000 stmt $script
+
+# Run the same 10000 simple queries as in the previous test case against
+# the underlying tables. The compiled vdbe programs should be identical, so
+# the only difference in running time is the extra time taken to compile
+# the view definitions.
+#
+set script {
+ for {set ii 1} {$ii < 10000} {incr ii} {
+ set v [expr {$ii*3}]
+ set t [expr {$ii%3+1}]
+ db eval "SELECT t FROM t$t WHERE rowid = \$v"
+ }
+}
+speed_trial_tcl speed4p-table1 10000 stmt $script
+
+# Run a SELECT that uses sub-queries 10000 times. A total of 30000 sub-selects.
+#
+set script {
+ for {set ii 1} {$ii < 10000} {incr ii} {
+ set v [expr {$ii*3}]
+ db eval {
+ SELECT (SELECT t FROM t1 WHERE rowid = $v),
+ (SELECT t FROM t2 WHERE rowid = $v),
+ (SELECT t FROM t3 WHERE rowid = $v)
+ }
+ }
+}
+speed_trial_tcl speed4p-subselect1 10000 stmt $script
+
+# Single-row updates performance.
+#
+set script {
+ db eval BEGIN
+ for {set ii 1} {$ii < 10000} {incr ii} {
+ set v [expr {$ii*3}]
+ db eval {UPDATE t1 SET i=i+1 WHERE rowid=$ii}
+ }
+ db eval COMMIT
+}
+speed_trial_tcl speed4p-rowid-update 10000 stmt $script
+
+
+db eval {
+ CREATE TABLE t5(t TEXT PRIMARY KEY, i INTEGER);
+}
+speed_trial speed4p-insert-ignore 50000 row {
+ INSERT OR IGNORE INTO t5 SELECT t, i FROM t1;
+}
+
+set list [db eval {SELECT t FROM t5}]
+set script {
+ db eval BEGIN
+ foreach t $::list {
+ db eval {UPDATE t5 SET i=i+1 WHERE t=$t}
+ }
+ db eval COMMIT
+}
+speed_trial_tcl speed4p-unique-update [llength $list] stmt $script
+
+# The following block tests the speed of some DML statements that cause
+# triggers to fire.
+#
+execsql {
+ CREATE TABLE log(op TEXT, r INTEGER, i INTEGER, t TEXT);
+ CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ CREATE TRIGGER t4_trigger1 AFTER INSERT ON t4 BEGIN
+ INSERT INTO log VALUES('INSERT INTO t4', new.rowid, new.i, new.t);
+ END;
+ CREATE TRIGGER t4_trigger2 AFTER UPDATE ON t4 BEGIN
+ INSERT INTO log VALUES('UPDATE OF t4', new.rowid, new.i, new.t);
+ END;
+ CREATE TRIGGER t4_trigger3 AFTER DELETE ON t4 BEGIN
+ INSERT INTO log VALUES('DELETE OF t4', old.rowid, old.i, old.t);
+ END;
+ BEGIN;
+}
+set list {}
+for {set ii 1} {$ii < 10000} {incr ii} {
+ lappend list $ii [number_name $ii]
+}
+set script {
+ foreach {ii name} $::list {
+ db eval {INSERT INTO t4 VALUES(NULL, $ii, $name)}
+ }
+}
+speed_trial_tcl speed4p-trigger1 10000 stmt $script
+
+set list {}
+for {set ii 1} {$ii < 20000} {incr ii 2} {
+ set ii2 [expr {$ii*2}]
+ lappend list $ii $ii2 [number_name $ii2]
+}
+set script {
+ foreach {ii ii2 name} $::list {
+ db eval {
+ UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii;
+ }
+ }
+}
+speed_trial_tcl speed4p-trigger2 10000 stmt $script
+
+set script {
+ for {set ii 1} {$ii < 20000} {incr ii 2} {
+ db eval {DELETE FROM t4 WHERE rowid = $ii}
+ }
+}
+speed_trial_tcl speed4p-trigger3 10000 stmt $script
+execsql {COMMIT}
+
+# The following block contains the same tests as the above block that
+# tests triggers, with one crucial difference: no triggers are defined.
+# So the difference in speed between these tests and the preceding ones
+# is the amount of time taken to compile and execute the trigger programs.
+#
+execsql {
+ DROP TABLE t4;
+ DROP TABLE log;
+ VACUUM;
+ CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
+ BEGIN;
+}
+set list {}
+for {set ii 1} {$ii < 10000} {incr ii} {
+ lappend list $ii [number_name $ii]
+}
+set script {
+ foreach {ii name} $::list {
+ db eval {INSERT INTO t4 VALUES(NULL, $ii, $name);}
+ }
+}
+speed_trial_tcl speed4p-notrigger1 10000 stmt $script
+
+set list {}
+for {set ii 1} {$ii < 20000} {incr ii 2} {
+ set ii2 [expr {$ii*2}]
+ lappend list $ii $ii2 [number_name $ii2]
+}
+set script {
+ foreach {ii ii2 name} $::list {
+ db eval {
+ UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii;
+ }
+ }
+}
+speed_trial_tcl speed4p-notrigger2 10000 stmt $script
+
+set script {
+ for {set ii 1} {$ii < 20000} {incr ii 2} {
+ db eval {DELETE FROM t4 WHERE rowid = $ii}
+ }
+}
+speed_trial_tcl speed4p-notrigger3 10000 stmt $script
+execsql {COMMIT}
+
+speed_trial_summary speed4
+finish_test
diff --git a/test/sqllimits1.test b/test/sqllimits1.test
new file mode 100644
index 0000000..2cbad3f
--- /dev/null
+++ b/test/sqllimits1.test
@@ -0,0 +1,844 @@
+# 2007 May 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests to verify that the limits defined in
+# sqlite source file limits.h are enforced.
+#
+# $Id: sqllimits1.test,v 1.33 2009/06/25 01:47:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Verify that the default per-connection limits are the same as
+# the compile-time hard limits.
+#
+sqlite3 db2 :memory:
+do_test sqllimits1-1.1 {
+ sqlite3_limit db SQLITE_LIMIT_LENGTH -1
+} $SQLITE_MAX_LENGTH
+do_test sqllimits1-1.2 {
+ sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH -1
+} $SQLITE_MAX_SQL_LENGTH
+do_test sqllimits1-1.3 {
+ sqlite3_limit db SQLITE_LIMIT_COLUMN -1
+} $SQLITE_MAX_COLUMN
+do_test sqllimits1-1.4 {
+ sqlite3_limit db SQLITE_LIMIT_EXPR_DEPTH -1
+} $SQLITE_MAX_EXPR_DEPTH
+do_test sqllimits1-1.5 {
+ sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT -1
+} $SQLITE_MAX_COMPOUND_SELECT
+do_test sqllimits1-1.6 {
+ sqlite3_limit db SQLITE_LIMIT_VDBE_OP -1
+} $SQLITE_MAX_VDBE_OP
+do_test sqllimits1-1.7 {
+ sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG -1
+} $SQLITE_MAX_FUNCTION_ARG
+do_test sqllimits1-1.8 {
+ sqlite3_limit db SQLITE_LIMIT_ATTACHED -1
+} $SQLITE_MAX_ATTACHED
+do_test sqllimits1-1.9 {
+ sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH -1
+} $SQLITE_MAX_LIKE_PATTERN_LENGTH
+do_test sqllimits1-1.10 {
+ sqlite3_limit db SQLITE_LIMIT_VARIABLE_NUMBER -1
+} $SQLITE_MAX_VARIABLE_NUMBER
+
+# Limit parameters out of range.
+#
+do_test sqllimits1-1.20 {
+ sqlite3_limit db SQLITE_LIMIT_TOOSMALL 123
+} {-1}
+do_test sqllimits1-1.21 {
+ sqlite3_limit db SQLITE_LIMIT_TOOSMALL 123
+} {-1}
+do_test sqllimits1-1.22 {
+ sqlite3_limit db SQLITE_LIMIT_TOOBIG 123
+} {-1}
+do_test sqllimits1-1.23 {
+ sqlite3_limit db SQLITE_LIMIT_TOOBIG 123
+} {-1}
+
+
+# Decrease all limits by half. Verify that the new limits take.
+#
+if {$SQLITE_MAX_LENGTH>=2} {
+ do_test sqllimits1-2.1.1 {
+ sqlite3_limit db SQLITE_LIMIT_LENGTH \
+ [expr {$::SQLITE_MAX_LENGTH/2}]
+ } $SQLITE_MAX_LENGTH
+ do_test sqllimits1-2.1.2 {
+ sqlite3_limit db SQLITE_LIMIT_LENGTH -1
+ } [expr {$SQLITE_MAX_LENGTH/2}]
+}
+if {$SQLITE_MAX_SQL_LENGTH>=2} {
+ do_test sqllimits1-2.2.1 {
+ sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH \
+ [expr {$::SQLITE_MAX_SQL_LENGTH/2}]
+ } $SQLITE_MAX_SQL_LENGTH
+ do_test sqllimits1-2.2.2 {
+ sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH -1
+ } [expr {$SQLITE_MAX_SQL_LENGTH/2}]
+}
+if {$SQLITE_MAX_COLUMN>=2} {
+ do_test sqllimits1-2.3.1 {
+ sqlite3_limit db SQLITE_LIMIT_COLUMN \
+ [expr {$::SQLITE_MAX_COLUMN/2}]
+ } $SQLITE_MAX_COLUMN
+ do_test sqllimits1-2.3.2 {
+ sqlite3_limit db SQLITE_LIMIT_COLUMN -1
+ } [expr {$SQLITE_MAX_COLUMN/2}]
+}
+if {$SQLITE_MAX_EXPR_DEPTH>=2} {
+ do_test sqllimits1-2.4.1 {
+ sqlite3_limit db SQLITE_LIMIT_EXPR_DEPTH \
+ [expr {$::SQLITE_MAX_EXPR_DEPTH/2}]
+ } $SQLITE_MAX_EXPR_DEPTH
+ do_test sqllimits1-2.4.2 {
+ sqlite3_limit db SQLITE_LIMIT_EXPR_DEPTH -1
+ } [expr {$SQLITE_MAX_EXPR_DEPTH/2}]
+}
+if {$SQLITE_MAX_COMPOUND_SELECT>=2} {
+ do_test sqllimits1-2.5.1 {
+ sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT \
+ [expr {$::SQLITE_MAX_COMPOUND_SELECT/2}]
+ } $SQLITE_MAX_COMPOUND_SELECT
+ do_test sqllimits1-2.5.2 {
+ sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT -1
+ } [expr {$SQLITE_MAX_COMPOUND_SELECT/2}]
+}
+if {$SQLITE_MAX_VDBE_OP>=2} {
+ do_test sqllimits1-2.6.1 {
+ sqlite3_limit db SQLITE_LIMIT_VDBE_OP \
+ [expr {$::SQLITE_MAX_VDBE_OP/2}]
+ } $SQLITE_MAX_VDBE_OP
+ do_test sqllimits1-2.6.2 {
+ sqlite3_limit db SQLITE_LIMIT_VDBE_OP -1
+ } [expr {$SQLITE_MAX_VDBE_OP/2}]
+}
+if {$SQLITE_MAX_FUNCTION_ARG>=2} {
+ do_test sqllimits1-2.7.1 {
+ sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG \
+ [expr {$::SQLITE_MAX_FUNCTION_ARG/2}]
+ } $SQLITE_MAX_FUNCTION_ARG
+ do_test sqllimits1-2.7.2 {
+ sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG -1
+ } [expr {$SQLITE_MAX_FUNCTION_ARG/2}]
+}
+if {$SQLITE_MAX_ATTACHED>=2} {
+ do_test sqllimits1-2.8.1 {
+ sqlite3_limit db SQLITE_LIMIT_ATTACHED \
+ [expr {$::SQLITE_MAX_ATTACHED/2}]
+ } $SQLITE_MAX_ATTACHED
+ do_test sqllimits1-2.8.2 {
+ sqlite3_limit db SQLITE_LIMIT_ATTACHED -1
+ } [expr {$SQLITE_MAX_ATTACHED/2}]
+}
+if {$SQLITE_MAX_LIKE_PATTERN_LENGTH>=2} {
+ do_test sqllimits1-2.9.1 {
+ sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH \
+ [expr {$::SQLITE_MAX_LIKE_PATTERN_LENGTH/2}]
+ } $SQLITE_MAX_LIKE_PATTERN_LENGTH
+ do_test sqllimits1-2.9.2 {
+ sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH -1
+ } [expr {$SQLITE_MAX_LIKE_PATTERN_LENGTH/2}]
+}
+if {$SQLITE_MAX_VARIABLE_NUMBER>=2} {
+ do_test sqllimits1-2.10.1 {
+ sqlite3_limit db SQLITE_LIMIT_VARIABLE_NUMBER \
+ [expr {$::SQLITE_MAX_VARIABLE_NUMBER/2}]
+ } $SQLITE_MAX_VARIABLE_NUMBER
+ do_test sqllimits1-2.10.2 {
+ sqlite3_limit db SQLITE_LIMIT_VARIABLE_NUMBER -1
+ } [expr {$SQLITE_MAX_VARIABLE_NUMBER/2}]
+}
+
+# In a separate database connection, verify that the limits are unchanged.
+#
+do_test sqllimits1-3.1 {
+ sqlite3_limit db2 SQLITE_LIMIT_LENGTH -1
+} $SQLITE_MAX_LENGTH
+do_test sqllimits1-3.2 {
+ sqlite3_limit db2 SQLITE_LIMIT_SQL_LENGTH -1
+} $SQLITE_MAX_SQL_LENGTH
+do_test sqllimits1-3.3 {
+ sqlite3_limit db2 SQLITE_LIMIT_COLUMN -1
+} $SQLITE_MAX_COLUMN
+do_test sqllimits1-3.4 {
+ sqlite3_limit db2 SQLITE_LIMIT_EXPR_DEPTH -1
+} $SQLITE_MAX_EXPR_DEPTH
+do_test sqllimits1-3.5 {
+ sqlite3_limit db2 SQLITE_LIMIT_COMPOUND_SELECT -1
+} $SQLITE_MAX_COMPOUND_SELECT
+do_test sqllimits1-3.6 {
+ sqlite3_limit db2 SQLITE_LIMIT_VDBE_OP -1
+} $SQLITE_MAX_VDBE_OP
+do_test sqllimits1-3.7 {
+ sqlite3_limit db2 SQLITE_LIMIT_FUNCTION_ARG -1
+} $SQLITE_MAX_FUNCTION_ARG
+do_test sqllimits1-3.8 {
+ sqlite3_limit db2 SQLITE_LIMIT_ATTACHED -1
+} $SQLITE_MAX_ATTACHED
+do_test sqllimits1-3.9 {
+ sqlite3_limit db2 SQLITE_LIMIT_LIKE_PATTERN_LENGTH -1
+} $SQLITE_MAX_LIKE_PATTERN_LENGTH
+do_test sqllimits1-3.10 {
+ sqlite3_limit db2 SQLITE_LIMIT_VARIABLE_NUMBER -1
+} $SQLITE_MAX_VARIABLE_NUMBER
+db2 close
+
+# Attempt to set all limits to the maximum 32-bit integer. Verify
+# that the limit does not exceed the compile-time upper bound.
+#
+do_test sqllimits1-4.1.1 {
+ sqlite3_limit db SQLITE_LIMIT_LENGTH 0x7fffffff
+ sqlite3_limit db SQLITE_LIMIT_LENGTH -1
+} $SQLITE_MAX_LENGTH
+do_test sqllimits1-4.2.1 {
+ sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH 0x7fffffff
+ sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH -1
+} $SQLITE_MAX_SQL_LENGTH
+do_test sqllimits1-4.3.1 {
+ sqlite3_limit db SQLITE_LIMIT_COLUMN 0x7fffffff
+ sqlite3_limit db SQLITE_LIMIT_COLUMN -1
+} $SQLITE_MAX_COLUMN
+do_test sqllimits1-4.4.1 {
+ sqlite3_limit db SQLITE_LIMIT_EXPR_DEPTH 0x7fffffff
+ sqlite3_limit db SQLITE_LIMIT_EXPR_DEPTH -1
+} $SQLITE_MAX_EXPR_DEPTH
+do_test sqllimits1-4.5.1 {
+ sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 0x7fffffff
+ sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT -1
+} $SQLITE_MAX_COMPOUND_SELECT
+do_test sqllimits1-4.6.1 {
+ sqlite3_limit db SQLITE_LIMIT_VDBE_OP 0x7fffffff
+ sqlite3_limit db SQLITE_LIMIT_VDBE_OP -1
+} $SQLITE_MAX_VDBE_OP
+do_test sqllimits1-4.7.1 {
+ sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG 0x7fffffff
+ sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG -1
+} $SQLITE_MAX_FUNCTION_ARG
+do_test sqllimits1-4.8.1 {
+ sqlite3_limit db SQLITE_LIMIT_ATTACHED 0x7fffffff
+ sqlite3_limit db SQLITE_LIMIT_ATTACHED -1
+} $SQLITE_MAX_ATTACHED
+do_test sqllimits1-4.9.1 {
+ sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH 0x7fffffff
+ sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH -1
+} $SQLITE_MAX_LIKE_PATTERN_LENGTH
+do_test sqllimits1-4.10.1 {
+ sqlite3_limit db SQLITE_LIMIT_VARIABLE_NUMBER 0x7fffffff
+ sqlite3_limit db SQLITE_LIMIT_VARIABLE_NUMBER -1
+} $SQLITE_MAX_VARIABLE_NUMBER
+
+#--------------------------------------------------------------------
+# Test cases sqllimits1-5.* test that the SQLITE_MAX_LENGTH limit
+# is enforced.
+#
+db close
+sqlite3 db test.db
+set LARGESIZE 99999
+set SQLITE_LIMIT_LENGTH 100000
+sqlite3_limit db SQLITE_LIMIT_LENGTH $SQLITE_LIMIT_LENGTH
+
+do_test sqllimits1-5.1.1 {
+ catchsql { SELECT randomblob(2147483647) }
+} {1 {string or blob too big}}
+do_test sqllimits1-5.1.2 {
+ catchsql { SELECT zeroblob(2147483647) }
+} {1 {string or blob too big}}
+
+do_test sqllimits1-5.2 {
+ catchsql { SELECT LENGTH(randomblob($::LARGESIZE)) }
+} [list 0 $LARGESIZE]
+
+do_test sqllimits1-5.3 {
+ catchsql { SELECT quote(randomblob($::LARGESIZE)) }
+} {1 {string or blob too big}}
+
+do_test sqllimits1-5.4 {
+ catchsql { SELECT LENGTH(zeroblob($::LARGESIZE)) }
+} [list 0 $LARGESIZE]
+
+do_test sqllimits1-5.5 {
+ catchsql { SELECT quote(zeroblob($::LARGESIZE)) }
+} {1 {string or blob too big}}
+
+do_test sqllimits1-5.6 {
+ catchsql { SELECT zeroblob(-1) }
+} {0 {{}}}
+
+do_test sqllimits1-5.9 {
+ set ::str [string repeat A 65537]
+ set ::rep [string repeat B 65537]
+ catchsql { SELECT replace($::str, 'A', $::rep) }
+} {1 {string or blob too big}}
+
+do_test sqllimits1-5.10 {
+ set ::str [string repeat %J 2100]
+ catchsql { SELECT strftime($::str, '2003-10-31') }
+} {1 {string or blob too big}}
+
+do_test sqllimits1-5.11 {
+ set ::str1 [string repeat A [expr {$SQLITE_LIMIT_LENGTH - 10}]]
+ set ::str2 [string repeat B [expr {$SQLITE_LIMIT_LENGTH - 10}]]
+ catchsql { SELECT $::str1 || $::str2 }
+} {1 {string or blob too big}}
+
+do_test sqllimits1-5.12 {
+ set ::str1 [string repeat ' [expr {$SQLITE_LIMIT_LENGTH - 10}]]
+ catchsql { SELECT quote($::str1) }
+} {1 {string or blob too big}}
+
+do_test sqllimits1-5.13 {
+ set ::str1 [string repeat ' [expr {$SQLITE_LIMIT_LENGTH - 10}]]
+ catchsql { SELECT hex($::str1) }
+} {1 {string or blob too big}}
+
+do_test sqllimits1-5.14.1 {
+ set ::STMT [sqlite3_prepare db "SELECT ?" -1 TAIL]
+ sqlite3_bind_zeroblob $::STMT 1 [expr {$SQLITE_LIMIT_LENGTH + 1}]
+} {}
+do_test sqllimits1-5.14.2 {
+ sqlite3_step $::STMT
+} {SQLITE_ERROR}
+do_test sqllimits1-5.14.3 {
+ sqlite3_reset $::STMT
+} {SQLITE_TOOBIG}
+do_test sqllimits1-5.14.4 {
+ set np1 [expr {$SQLITE_LIMIT_LENGTH + 1}]
+ set ::str1 [string repeat A $np1]
+ catch {sqlite3_bind_text $::STMT 1 $::str1 -1} res
+ set res
+} {SQLITE_TOOBIG}
+ifcapable utf16 {
+ do_test sqllimits1-5.14.5 {
+ catch {sqlite3_bind_text16 $::STMT 1 $::str1 -1} res
+ set res
+ } {SQLITE_TOOBIG}
+}
+do_test sqllimits1-5.14.6 {
+ catch {sqlite3_bind_text $::STMT 1 $::str1 $np1} res
+ set res
+} {SQLITE_TOOBIG}
+ifcapable utf16 {
+ do_test sqllimits1-5.14.7 {
+ catch {sqlite3_bind_text16 $::STMT 1 $::str1 $np1} res
+ set res
+ } {SQLITE_TOOBIG}
+}
+do_test sqllimits1-5.14.8 {
+ set n [expr {$np1-1}]
+ catch {sqlite3_bind_text $::STMT 1 $::str1 $n} res
+ set res
+} {}
+do_test sqllimits1-5.14.9 {
+ catch {sqlite3_bind_text16 $::STMT 1 $::str1 $n} res
+ set res
+} {}
+sqlite3_finalize $::STMT
+
+do_test sqllimits1-5.15 {
+ execsql {
+ CREATE TABLE t4(x);
+ INSERT INTO t4 VALUES(1);
+ INSERT INTO t4 VALUES(2);
+ INSERT INTO t4 SELECT 2+x FROM t4;
+ }
+ catchsql {
+ SELECT group_concat(hex(randomblob(20000))) FROM t4;
+ }
+} {1 {string or blob too big}}
+db eval {DROP TABLE t4}
+
+sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH 0x7fffffff
+set strvalue [string repeat A $::SQLITE_LIMIT_LENGTH]
+do_test sqllimits1-5.16 {
+ catchsql "SELECT '$strvalue'"
+} [list 0 $strvalue]
+do_test sqllimits1-5.17.1 {
+ catchsql "SELECT 'A$strvalue'"
+} [list 1 {string or blob too big}]
+do_test sqllimits1-5.17.2 {
+ sqlite3_limit db SQLITE_LIMIT_LENGTH 0x7fffffff
+ catchsql {SELECT 'A' || $::strvalue}
+} [list 0 A$strvalue]
+do_test sqllimits1-5.17.3 {
+ sqlite3_limit db SQLITE_LIMIT_LENGTH $SQLITE_LIMIT_LENGTH
+ catchsql {SELECT 'A' || $::strvalue}
+} [list 1 {string or blob too big}]
+set blobvalue [string repeat 41 $::SQLITE_LIMIT_LENGTH]
+do_test sqllimits1-5.18 {
+ catchsql "SELECT x'$blobvalue'"
+} [list 0 $strvalue]
+do_test sqllimits1-5.19 {
+ catchsql "SELECT '41$blobvalue'"
+} [list 1 {string or blob too big}]
+unset blobvalue
+
+ifcapable datetime {
+ set strvalue [string repeat D [expr {$SQLITE_LIMIT_LENGTH-12}]]
+ do_test sqllimits1-5.20 {
+ catchsql {SELECT strftime('%Y ' || $::strvalue, '2008-01-02')}
+ } [list 0 [list "2008 $strvalue"]]
+ do_test sqllimits1-5.21 {
+ catchsql {SELECT strftime('%Y-%m-%d ' || $::strvalue, '2008-01-02')}
+ } {1 {string or blob too big}}
+}
+unset strvalue
+
+#--------------------------------------------------------------------
+# Test cases sqllimits1-6.* test that the SQLITE_MAX_SQL_LENGTH limit
+# is enforced.
+#
+do_test sqllimits1-6.1 {
+ sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH 50000
+ set sql "SELECT 1 WHERE 1==1"
+ set tail " /* A comment to take up space in order to make the string\
+ longer without increasing the expression depth */\
+ AND 1 == 1"
+ set N [expr {(50000 / [string length $tail])+1}]
+ append sql [string repeat $tail $N]
+ catchsql $sql
+} {1 {string or blob too big}}
+do_test sqllimits1-6.3 {
+ sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH 50000
+ set sql "SELECT 1 WHERE 1==1"
+ set tail " /* A comment to take up space in order to make the string\
+ longer without increasing the expression depth */\
+ AND 1 == 1"
+ set N [expr {(50000 / [string length $tail])+1}]
+ append sql [string repeat $tail $N]
+ set nbytes [string length $sql]
+ append sql { AND 0}
+ set rc [catch {sqlite3_prepare db $sql $nbytes TAIL} STMT]
+ lappend rc $STMT
+} {1 {(18) statement too long}}
+do_test sqllimits1-6.4 {
+ sqlite3_errmsg db
+} {statement too long}
+
+#--------------------------------------------------------------------
+# Test cases sqllimits1-7.* test that the limit set using the
+# max_page_count pragma.
+#
+do_test sqllimits1-7.1 {
+ execsql {
+ PRAGMA max_page_count = 1000;
+ }
+} {1000}
+do_test sqllimits1-7.2 {
+ execsql { CREATE TABLE trig (a INTEGER, b INTEGER); }
+
+ # Set up a tree of triggers to fire when a row is inserted
+ # into table "trig".
+ #
+ # INSERT -> insert_b -> update_b -> insert_a -> update_a (chain 1)
+ # -> update_a -> insert_a -> update_b (chain 2)
+ # -> insert_a -> update_b -> insert_b -> update_a (chain 3)
+ # -> update_a -> insert_b -> update_b (chain 4)
+ #
+ # Table starts with N rows.
+ #
+ # Chain 1: insert_b (update N rows)
+ # -> update_b (insert 1 rows)
+ # -> insert_a (update N rows)
+ # -> update_a (insert 1 rows)
+ #
+ # chains 2, 3 and 4 are similar. Each inserts more than N^2 rows, where
+ # N is the number of rows at the conclusion of the previous chain.
+ #
+ # Therefore, a single insert adds (N^16 plus some) rows to the database.
+ # A really long loop...
+ #
+ execsql {
+ CREATE TRIGGER update_b BEFORE UPDATE ON trig
+ FOR EACH ROW BEGIN
+ INSERT INTO trig VALUES (65, 'update_b');
+ END;
+
+ CREATE TRIGGER update_a AFTER UPDATE ON trig
+ FOR EACH ROW BEGIN
+ INSERT INTO trig VALUES (65, 'update_a');
+ END;
+
+ CREATE TRIGGER insert_b BEFORE INSERT ON trig
+ FOR EACH ROW BEGIN
+ UPDATE trig SET a = 1;
+ END;
+
+ CREATE TRIGGER insert_a AFTER INSERT ON trig
+ FOR EACH ROW BEGIN
+ UPDATE trig SET a = 1;
+ END;
+ }
+} {}
+
+do_test sqllimits1-7.3 {
+ execsql {
+ INSERT INTO trig VALUES (1,1);
+ }
+} {}
+
+do_test sqllimits1-7.4 {
+ execsql {
+ SELECT COUNT(*) FROM trig;
+ }
+} {7}
+
+# This tries to insert so many rows it fills up the database (limited
+# to 1MB, so not that noteworthy an achievement).
+#
+do_test sqllimits1-7.5 {
+ catchsql {
+ INSERT INTO trig VALUES (1,10);
+ }
+} {1 {database or disk is full}}
+
+do_test sqllimits1-7.6 {
+ catchsql {
+ SELECT COUNT(*) FROM trig;
+ }
+} {0 7}
+
+# Now check the response of the library to opening a file larger than
+# the current max_page_count value. The response is to change the
+# internal max_page_count value to match the actual size of the file.
+if {[db eval {PRAGMA auto_vacuum}]} {
+ set fsize 1700
+} else {
+ set fsize 1691
+}
+do_test sqllimits1-7.7.1 {
+ execsql {
+ PRAGMA max_page_count = 1000000;
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;
+ INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;
+ INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;
+ INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;
+ INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;
+ INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;
+ INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;
+ INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;
+ INSERT INTO abc SELECT a, b, c FROM abc;
+ INSERT INTO abc SELECT b, a, c FROM abc;
+ INSERT INTO abc SELECT c, b, a FROM abc;
+ }
+ expr [file size test.db] / 1024
+} $fsize
+do_test sqllimits1-7.7.2 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA max_page_count = 1000;
+ }
+ execsql {
+ SELECT count(*) FROM sqlite_master;
+ }
+} {6}
+do_test sqllimits1-7.7.3 {
+ execsql {
+ PRAGMA max_page_count;
+ }
+} $fsize
+do_test sqllimits1-7.7.4 {
+ execsql {
+ DROP TABLE abc;
+ }
+} {}
+
+#--------------------------------------------------------------------
+# Test cases sqllimits1-8.* test the SQLITE_MAX_COLUMN limit.
+#
+set SQLITE_LIMIT_COLUMN 200
+sqlite3_limit db SQLITE_LIMIT_COLUMN $SQLITE_LIMIT_COLUMN
+do_test sqllimits1-8.1 {
+ # Columns in a table.
+ set cols [list]
+ for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
+ lappend cols "c$i"
+ }
+ catchsql "CREATE TABLE t([join $cols ,])"
+} {1 {too many columns on t}}
+
+do_test sqllimits1-8.2 {
+ # Columns in the result-set of a SELECT.
+ set cols [list]
+ for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
+ lappend cols "sql AS sql$i"
+ }
+ catchsql "SELECT [join $cols ,] FROM sqlite_master"
+} {1 {too many columns in result set}}
+
+do_test sqllimits1-8.3 {
+ # Columns in the result-set of a sub-SELECT.
+ set cols [list]
+ for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
+ lappend cols "sql AS sql$i"
+ }
+ catchsql "SELECT sql4 FROM (SELECT [join $cols ,] FROM sqlite_master)"
+} {1 {too many columns in result set}}
+
+do_test sqllimits1-8.4 {
+ # Columns in an index.
+ set cols [list]
+ for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
+ lappend cols c
+ }
+ set sql1 "CREATE TABLE t1(c);"
+ set sql2 "CREATE INDEX i1 ON t1([join $cols ,]);"
+ catchsql "$sql1 ; $sql2"
+} {1 {too many columns in index}}
+
+do_test sqllimits1-8.5 {
+ # Columns in a GROUP BY clause.
+ catchsql "SELECT * FROM t1 GROUP BY [join $cols ,]"
+} {1 {too many terms in GROUP BY clause}}
+
+do_test sqllimits1-8.6 {
+ # Columns in an ORDER BY clause.
+ catchsql "SELECT * FROM t1 ORDER BY [join $cols ,]"
+} {1 {too many terms in ORDER BY clause}}
+
+do_test sqllimits1-8.7 {
+ # Assignments in an UPDATE statement.
+ set cols [list]
+ for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
+ lappend cols "c = 1"
+ }
+ catchsql "UPDATE t1 SET [join $cols ,];"
+} {1 {too many columns in set list}}
+
+do_test sqllimits1-8.8 {
+ # Columns in a view definition:
+ set cols [list]
+ for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
+ lappend cols "c$i"
+ }
+ catchsql "CREATE VIEW v1 AS SELECT [join $cols ,] FROM t1;"
+} {1 {too many columns in result set}}
+
+do_test sqllimits1-8.9 {
+ # Columns in a view definition (testing * expansion):
+ set cols [list]
+ for {set i 0} {$i < $SQLITE_LIMIT_COLUMN} {incr i} {
+ lappend cols "c$i"
+ }
+ catchsql "CREATE TABLE t2([join $cols ,])"
+ catchsql "CREATE VIEW v1 AS SELECT *, c1 AS o FROM t2;"
+} {1 {too many columns in result set}}
+do_test sqllimits1-8.10 {
+ # ORDER BY columns
+ set cols [list]
+ for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
+ lappend cols c
+ }
+ set sql "SELECT c FROM t1 ORDER BY [join $cols ,]"
+ catchsql $sql
+} {1 {too many terms in ORDER BY clause}}
+do_test sqllimits1-8.11 {
+ # ORDER BY columns
+ set cols [list]
+ for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
+ lappend cols [expr {$i%3 + 1}]
+ }
+ set sql "SELECT c, c+1, c+2 FROM t1 UNION SELECT c-1, c-2, c-3 FROM t1"
+ append sql " ORDER BY [join $cols ,]"
+ catchsql $sql
+} {1 {too many terms in ORDER BY clause}}
+
+
+#--------------------------------------------------------------------
+# These tests - sqllimits1-9.* - test that the SQLITE_LIMIT_EXPR_DEPTH
+# limit is enforced. The limit refers to the number of terms in
+# the expression.
+#
+if {$SQLITE_MAX_EXPR_DEPTH==0} {
+ puts -nonewline stderr "WARNING: Compile with -DSQLITE_MAX_EXPR_DEPTH to run "
+ puts stderr "tests sqllimits1-9.X"
+} else {
+ do_test sqllimits1-9.1 {
+ set max $::SQLITE_MAX_EXPR_DEPTH
+ set expr "(1 [string repeat {AND 1 } $max])"
+ catchsql [subst {
+ SELECT $expr
+ }]
+ } "1 {Expression tree is too large (maximum depth $::SQLITE_MAX_EXPR_DEPTH)}"
+
+ # Attempting to beat the expression depth limit using nested SELECT
+ # queries causes a parser stack overflow.
+ do_test sqllimits1-9.2 {
+ set max $::SQLITE_MAX_EXPR_DEPTH
+ set expr "SELECT 1"
+ for {set i 0} {$i <= $max} {incr i} {
+ set expr "SELECT ($expr)"
+ }
+ catchsql [subst { $expr }]
+ } "1 {parser stack overflow}"
+
+if 0 {
+ do_test sqllimits1-9.3 {
+ execsql {
+ PRAGMA max_page_count = 1000000; -- 1 GB
+ CREATE TABLE v0(a);
+ INSERT INTO v0 VALUES(1);
+ }
+ db transaction {
+ for {set i 1} {$i < 200} {incr i} {
+ set expr "(a [string repeat {AND 1 } 50]) AS a"
+ execsql [subst {
+ CREATE VIEW v${i} AS SELECT $expr FROM v[expr {$i-1}]
+ }]
+ }
+ }
+ } {}
+
+ do_test sqllimits1-9.4 {
+ catchsql {
+ SELECT a FROM v199
+ }
+ } "1 {Expression tree is too large (maximum depth $::SQLITE_MAX_EXPR_DEPTH)}"
+}
+}
+
+#--------------------------------------------------------------------
+# Test cases sqllimits1-10.* test that the SQLITE_MAX_VDBE_OP
+# limit works as expected. The limit refers to the number of opcodes
+# in a single VDBE program.
+#
+# TODO
+
+#--------------------------------------------------------------------
+# Test the SQLITE_LIMIT_FUNCTION_ARG limit works. Test case names
+# match the pattern "sqllimits1-11.*".
+#
+for {set max 5} {$max<=$SQLITE_MAX_FUNCTION_ARG} {incr max} {
+ do_test sqllimits1-11.$max.1 {
+ set vals [list]
+ sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG $::max
+ for {set i 0} {$i < $::max} {incr i} {
+ lappend vals $i
+ }
+ catchsql "SELECT max([join $vals ,])"
+ } "0 [expr {$::max - 1}]"
+ do_test sqllimits1-11.$max.2 {
+ set vals [list]
+ for {set i 0} {$i <= $::max} {incr i} {
+ lappend vals $i
+ }
+ catchsql "SELECT max([join $vals ,])"
+ } {1 {too many arguments on function max}}
+
+ # Test that it is SQLite, and not the implementation of the
+ # user function that is throwing the error.
+ proc myfunc {args} {error "I don't like to be called!"}
+ do_test sqllimits1-11.$max.2 {
+ db function myfunc myfunc
+ set vals [list]
+ for {set i 0} {$i <= $::max} {incr i} {
+ lappend vals $i
+ }
+ catchsql "SELECT myfunc([join $vals ,])"
+ } {1 {too many arguments on function myfunc}}
+}
+
+#--------------------------------------------------------------------
+# Test cases sqllimits1-12.*: Test the SQLITE_MAX_ATTACHED limit.
+#
+ifcapable attach {
+ do_test sqllimits1-12.1 {
+ set max $::SQLITE_MAX_ATTACHED
+ for {set i 0} {$i < ($max)} {incr i} {
+ forcedelete test${i}.db test${i}.db-journal
+ }
+ for {set i 0} {$i < ($max)} {incr i} {
+ execsql "ATTACH 'test${i}.db' AS aux${i}"
+ }
+ catchsql "ATTACH 'test${i}.db' AS aux${i}"
+ } "1 {too many attached databases - max $::SQLITE_MAX_ATTACHED}"
+ do_test sqllimits1-12.2 {
+ set max $::SQLITE_MAX_ATTACHED
+ for {set i 0} {$i < ($max)} {incr i} {
+ execsql "DETACH aux${i}"
+ }
+ } {}
+}
+
+#--------------------------------------------------------------------
+# Test cases sqllimits1-13.*: Check that the SQLITE_MAX_VARIABLE_NUMBER
+# limit works.
+#
+do_test sqllimits1-13.1 {
+ set max $::SQLITE_MAX_VARIABLE_NUMBER
+ catchsql "SELECT ?[expr {$max+1}] FROM t1"
+} "1 {variable number must be between ?1 and ?$::SQLITE_MAX_VARIABLE_NUMBER}"
+do_test sqllimits1-13.2 {
+ set max $::SQLITE_MAX_VARIABLE_NUMBER
+ set vals [list]
+ for {set i 0} {$i < ($max+3)} {incr i} {
+ lappend vals ?
+ }
+ catchsql "SELECT [join $vals ,] FROM t1"
+} "1 {too many SQL variables}"
+
+
+#--------------------------------------------------------------------
+# Test cases sqllimits1-15.* verify that the
+# SQLITE_MAX_LIKE_PATTERN_LENGTH limit is enforced. This limit only
+# applies to the built-in LIKE operator, supplying an external
+# implementation by overriding the like() scalar function bypasses
+# this limitation.
+#
+# These tests check that the limit is not incorrectly applied to
+# the left-hand-side of the LIKE operator (the string being tested
+# against the pattern).
+#
+set SQLITE_LIMIT_LIKE_PATTERN 1000
+sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH $SQLITE_LIMIT_LIKE_PATTERN
+do_test sqllimits1-15.1 {
+ set max $::SQLITE_LIMIT_LIKE_PATTERN
+ set ::pattern [string repeat "A%" [expr $max/2]]
+ set ::string [string repeat "A" [expr {$max*2}]]
+ execsql {
+ SELECT $::string LIKE $::pattern;
+ }
+} {1}
+do_test sqllimits1-15.2 {
+ set max $::SQLITE_LIMIT_LIKE_PATTERN
+ set ::pattern [string repeat "A%" [expr {($max/2) + 1}]]
+ set ::string [string repeat "A" [expr {$max*2}]]
+ catchsql {
+ SELECT $::string LIKE $::pattern;
+ }
+} {1 {LIKE or GLOB pattern too complex}}
+
+#--------------------------------------------------------------------
+# This test case doesn't really belong with the other limits tests.
+# It is in this file because it is taxing to run, like the limits tests.
+#
+do_test sqllimits1-16.1 {
+ set ::N [expr int(([expr pow(2,32)]/50) + 1)]
+ expr (($::N*50) & 0xffffffff)<55
+} {1}
+do_test sqllimits1-16.2 {
+ set ::format "[string repeat A 60][string repeat "%J" $::N]"
+ catchsql {
+ SELECT strftime($::format, 1);
+ }
+} {1 {string or blob too big}}
+
+
+foreach {key value} [array get saved] {
+ catch {set $key $value}
+}
+finish_test
diff --git a/test/stat.test b/test/stat.test
new file mode 100644
index 0000000..21726eb
--- /dev/null
+++ b/test/stat.test
@@ -0,0 +1,167 @@
+# 2010 July 09
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the SELECT statement.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+
+set ::asc 1
+proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n }
+db func a_string a_string
+
+register_dbstat_vtab db
+do_execsql_test stat-0.0 {
+ PRAGMA auto_vacuum = OFF;
+ CREATE VIRTUAL TABLE temp.stat USING dbstat;
+ SELECT * FROM stat;
+} {}
+
+ifcapable wal {
+ do_execsql_test stat-0.1 {
+ PRAGMA journal_mode = WAL;
+ PRAGMA journal_mode = delete;
+ SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
+ FROM stat;
+ } {wal delete sqlite_master / 1 leaf 0 0 916 0}
+}
+
+do_test stat-1.0 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b);
+ INSERT INTO t1(rowid, a, b) VALUES(2, 2, 3);
+ INSERT INTO t1(rowid, a, b) VALUES(3, 4, 5);
+ }
+} {}
+do_test stat-1.1 {
+ execsql {
+ SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
+ FROM stat WHERE name = 't1';
+ }
+} {t1 / 2 leaf 2 10 998 5}
+do_test stat-1.2 {
+ execsql {
+ SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
+ FROM stat WHERE name = 'i1';
+ }
+} {i1 / 3 leaf 2 10 1000 5}
+do_test stat-1.3 {
+ execsql {
+ SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
+ FROM stat WHERE name = 'sqlite_master';
+ }
+} {sqlite_master / 1 leaf 2 77 831 40}
+do_test stat-1.4 {
+ execsql {
+ DROP TABLE t1;
+ }
+} {}
+
+do_execsql_test stat-2.1 {
+ CREATE TABLE t3(a PRIMARY KEY, b);
+ INSERT INTO t3(rowid, a, b) VALUES(2, a_string(111), a_string(222));
+ INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3;
+ INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3;
+ INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3;
+ INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3;
+ INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3;
+ SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
+ FROM stat WHERE name != 'sqlite_master';
+} [list \
+ sqlite_autoindex_t3_1 / 3 internal 3 368 623 125 \
+ sqlite_autoindex_t3_1 /000/ 8 leaf 8 946 46 123 \
+ sqlite_autoindex_t3_1 /001/ 9 leaf 8 988 2 131 \
+ sqlite_autoindex_t3_1 /002/ 15 leaf 7 857 137 132 \
+ sqlite_autoindex_t3_1 /003/ 20 leaf 6 739 257 129 \
+ t3 / 2 internal 15 0 907 0 \
+ t3 /000/ 4 leaf 2 678 328 340 \
+ t3 /001/ 5 leaf 2 682 324 342 \
+ t3 /002/ 6 leaf 2 682 324 342 \
+ t3 /003/ 7 leaf 2 690 316 346 \
+ t3 /004/ 10 leaf 2 682 324 342 \
+ t3 /005/ 11 leaf 2 690 316 346 \
+ t3 /006/ 12 leaf 2 698 308 350 \
+ t3 /007/ 13 leaf 2 706 300 354 \
+ t3 /008/ 14 leaf 2 682 324 342 \
+ t3 /009/ 16 leaf 2 690 316 346 \
+ t3 /00a/ 17 leaf 2 698 308 350 \
+ t3 /00b/ 18 leaf 2 706 300 354 \
+ t3 /00c/ 19 leaf 2 714 292 358 \
+ t3 /00d/ 21 leaf 2 722 284 362 \
+ t3 /00e/ 22 leaf 2 730 276 366 \
+ t3 /00f/ 23 leaf 2 738 268 370 \
+]
+do_execsql_test stat-2.2 { DROP TABLE t3 } {}
+
+do_execsql_test stat-3.1 {
+ CREATE TABLE t4(x);
+ CREATE INDEX i4 ON t4(x);
+ INSERT INTO t4(rowid, x) VALUES(2, a_string(7777));
+ SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
+ FROM stat WHERE name != 'sqlite_master';
+} [list \
+ i4 / 3 leaf 1 103 905 7782 \
+ i4 /000+000000 9 overflow 0 1020 0 0 \
+ i4 /000+000001 10 overflow 0 1020 0 0 \
+ i4 /000+000002 11 overflow 0 1020 0 0 \
+ i4 /000+000003 12 overflow 0 1020 0 0 \
+ i4 /000+000004 13 overflow 0 1020 0 0 \
+ i4 /000+000005 14 overflow 0 1020 0 0 \
+ i4 /000+000006 15 overflow 0 1020 0 0 \
+ i4 /000+000007 16 overflow 0 539 481 0 \
+ t4 / 2 leaf 1 640 367 7780 \
+ t4 /000+000000 22 overflow 0 1020 0 0 \
+ t4 /000+000001 23 overflow 0 1020 0 0 \
+ t4 /000+000002 21 overflow 0 1020 0 0 \
+ t4 /000+000003 20 overflow 0 1020 0 0 \
+ t4 /000+000004 19 overflow 0 1020 0 0 \
+ t4 /000+000005 18 overflow 0 1020 0 0 \
+ t4 /000+000006 17 overflow 0 1020 0 0 \
+]
+
+do_execsql_test stat-4.1 {
+ CREATE TABLE t5(x);
+ CREATE INDEX i5 ON t5(x);
+ SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
+ FROM stat WHERE name = 't5' OR name = 'i5';
+} [list \
+ i5 / 5 leaf 0 0 1016 0 \
+ t5 / 4 leaf 0 0 1016 0 \
+]
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+register_dbstat_vtab db
+breakpoint
+do_execsql_test stat-5.1 {
+ PRAGMA auto_vacuum = OFF;
+ CREATE VIRTUAL TABLE temp.stat USING dbstat;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(zeroblob(1513));
+ INSERT INTO t1 VALUES(zeroblob(1514));
+ SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
+ FROM stat WHERE name = 't1';
+} [list \
+ t1 / 2 leaf 2 993 5 1517 \
+ t1 /000+000000 3 overflow 0 1020 0 0 \
+ t1 /001+000000 4 overflow 0 1020 0 0 \
+]
+
+finish_test
diff --git a/test/stmt.test b/test/stmt.test
new file mode 100644
index 0000000..49a4141
--- /dev/null
+++ b/test/stmt.test
@@ -0,0 +1,97 @@
+# 2010 February 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# The tests in this file check that SQLite uses (or does not use) a
+# statement journal for various SQL statements.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test stmt-1.1 {
+ execsql { CREATE TABLE t1(a integer primary key, b INTEGER NOT NULL) }
+} {}
+
+# The following tests verify the method used for the tests in this file -
+# that if a statement journal is required by a statement it is opened and
+# remains open until the current transaction is committed or rolled back.
+#
+# This only work if SQLITE_TEMP_STORE!=3
+#
+if {$::TEMP_STORE==3} {
+ finish_test
+ return
+}
+do_test stmt-1.2 {
+ set sqlite_open_file_count
+} {1}
+do_test stmt-1.3 {
+ execsql {
+ PRAGMA temp_store = file;
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 1);
+ }
+ set sqlite_open_file_count
+} {2}
+do_test stmt-1.4 {
+ execsql {
+ INSERT INTO t1 SELECT a+1, b+1 FROM t1;
+ }
+ set sqlite_open_file_count
+} {3}
+do_test stmt-1.5 {
+ execsql COMMIT
+ set sqlite_open_file_count
+} {1}
+do_test stmt-1.6.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 SELECT a+2, b+2 FROM t1;
+ }
+ set sqlite_open_file_count
+} {2}
+do_test stmt-1.6.2 {
+ execsql { INSERT INTO t1 SELECT a+4, b+4 FROM t1 }
+ set sqlite_open_file_count
+} {3}
+do_test stmt-1.7 {
+ execsql COMMIT
+ set sqlite_open_file_count
+} {1}
+
+
+proc filecount {testname sql expected} {
+ uplevel [list do_test $testname [subst -nocommand {
+ execsql BEGIN
+ execsql { $sql }
+ set ret [set sqlite_open_file_count]
+ execsql ROLLBACK
+ set ret
+ }] $expected]
+}
+
+filecount stmt-2.1 { INSERT INTO t1 VALUES(9, 9) } 2
+filecount stmt-2.2 { REPLACE INTO t1 VALUES(9, 9) } 2
+filecount stmt-2.3 { INSERT INTO t1 SELECT 9, 9 } 2
+filecount stmt-2.4 {
+ INSERT INTO t1 SELECT 9, 9;
+ INSERT INTO t1 SELECT 10, 10;
+} 3
+
+do_test stmt-2.5 {
+ execsql { CREATE INDEX i1 ON t1(b) }
+} {}
+filecount stmt-2.6 {
+ REPLACE INTO t1 VALUES(5, 5);
+ REPLACE INTO t1 VALUES(5, 5);
+} 3
+
+finish_test
diff --git a/test/subquery.test b/test/subquery.test
new file mode 100644
index 0000000..169ceda
--- /dev/null
+++ b/test/subquery.test
@@ -0,0 +1,499 @@
+# 2005 January 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing correlated subqueries
+#
+# $Id: subquery.test,v 1.17 2009/01/09 01:12:28 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+do_test subquery-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ INSERT INTO t1 VALUES(5,6);
+ INSERT INTO t1 VALUES(7,8);
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(1,1);
+ INSERT INTO t2 VALUES(3,9);
+ INSERT INTO t2 VALUES(5,25);
+ INSERT INTO t2 VALUES(7,49);
+ COMMIT;
+ }
+ execsql {
+ SELECT a, (SELECT y FROM t2 WHERE x=a) FROM t1 WHERE b<8
+ }
+} {1 1 3 9 5 25}
+do_test subquery-1.2 {
+ execsql {
+ UPDATE t1 SET b=b+(SELECT y FROM t2 WHERE x=a);
+ SELECT * FROM t1;
+ }
+} {1 3 3 13 5 31 7 57}
+
+do_test subquery-1.3 {
+ execsql {
+ SELECT b FROM t1 WHERE EXISTS(SELECT * FROM t2 WHERE y=a)
+ }
+} {3}
+do_test subquery-1.4 {
+ execsql {
+ SELECT b FROM t1 WHERE NOT EXISTS(SELECT * FROM t2 WHERE y=a)
+ }
+} {13 31 57}
+
+# Simple tests to make sure correlated subqueries in WHERE clauses
+# are used by the query optimizer correctly.
+do_test subquery-1.5 {
+ execsql {
+ SELECT a, x FROM t1, t2 WHERE t1.a = (SELECT x);
+ }
+} {1 1 3 3 5 5 7 7}
+do_test subquery-1.6 {
+ execsql {
+ CREATE INDEX i1 ON t1(a);
+ SELECT a, x FROM t1, t2 WHERE t1.a = (SELECT x);
+ }
+} {1 1 3 3 5 5 7 7}
+do_test subquery-1.7 {
+ execsql {
+ SELECT a, x FROM t2, t1 WHERE t1.a = (SELECT x);
+ }
+} {1 1 3 3 5 5 7 7}
+
+# Try an aggregate in both the subquery and the parent query.
+do_test subquery-1.8 {
+ execsql {
+ SELECT count(*) FROM t1 WHERE a > (SELECT count(*) FROM t2);
+ }
+} {2}
+
+# Test a correlated subquery disables the "only open the index" optimization.
+do_test subquery-1.9.1 {
+ execsql {
+ SELECT (y*2)>b FROM t1, t2 WHERE a=x;
+ }
+} {0 1 1 1}
+do_test subquery-1.9.2 {
+ execsql {
+ SELECT a FROM t1 WHERE (SELECT (y*2)>b FROM t2 WHERE a=x);
+ }
+} {3 5 7}
+
+# Test that the flattening optimization works with subquery expressions.
+do_test subquery-1.10.1 {
+ execsql {
+ SELECT (SELECT a), b FROM t1;
+ }
+} {1 3 3 13 5 31 7 57}
+do_test subquery-1.10.2 {
+ execsql {
+ SELECT * FROM (SELECT (SELECT a), b FROM t1);
+ }
+} {1 3 3 13 5 31 7 57}
+do_test subquery-1.10.3 {
+ execsql {
+ SELECT * FROM (SELECT (SELECT sum(a) FROM t1));
+ }
+} {16}
+do_test subquery-1.10.4 {
+ execsql {
+ CREATE TABLE t5 (val int, period text PRIMARY KEY);
+ INSERT INTO t5 VALUES(5, '2001-3');
+ INSERT INTO t5 VALUES(10, '2001-4');
+ INSERT INTO t5 VALUES(15, '2002-1');
+ INSERT INTO t5 VALUES(5, '2002-2');
+ INSERT INTO t5 VALUES(10, '2002-3');
+ INSERT INTO t5 VALUES(15, '2002-4');
+ INSERT INTO t5 VALUES(10, '2003-1');
+ INSERT INTO t5 VALUES(5, '2003-2');
+ INSERT INTO t5 VALUES(25, '2003-3');
+ INSERT INTO t5 VALUES(5, '2003-4');
+
+ SELECT period, vsum
+ FROM (SELECT
+ a.period,
+ (select sum(val) from t5 where period between a.period and '2002-4') vsum
+ FROM t5 a where a.period between '2002-1' and '2002-4')
+ WHERE vsum < 45 ;
+ }
+} {2002-2 30 2002-3 25 2002-4 15}
+do_test subquery-1.10.5 {
+ execsql {
+ SELECT period, vsum from
+ (select a.period,
+ (select sum(val) from t5 where period between a.period and '2002-4') vsum
+ FROM t5 a where a.period between '2002-1' and '2002-4')
+ WHERE vsum < 45 ;
+ }
+} {2002-2 30 2002-3 25 2002-4 15}
+do_test subquery-1.10.6 {
+ execsql {
+ DROP TABLE t5;
+ }
+} {}
+
+
+
+#------------------------------------------------------------------
+# The following test cases - subquery-2.* - are not logically
+# organized. They're here largely because they were failing during
+# one stage of development of sub-queries.
+#
+do_test subquery-2.1 {
+ execsql {
+ SELECT (SELECT 10);
+ }
+} {10}
+do_test subquery-2.2.1 {
+ execsql {
+ CREATE TABLE t3(a PRIMARY KEY, b);
+ INSERT INTO t3 VALUES(1, 2);
+ INSERT INTO t3 VALUES(3, 1);
+ }
+} {}
+do_test subquery-2.2.2 {
+ execsql {
+ SELECT * FROM t3 WHERE a IN (SELECT b FROM t3);
+ }
+} {1 2}
+do_test subquery-2.2.3 {
+ execsql {
+ DROP TABLE t3;
+ }
+} {}
+do_test subquery-2.3.1 {
+ execsql {
+ CREATE TABLE t3(a TEXT);
+ INSERT INTO t3 VALUES('10');
+ }
+} {}
+do_test subquery-2.3.2 {
+ execsql {
+ SELECT a IN (10.0, 20) FROM t3;
+ }
+} {0}
+do_test subquery-2.3.3 {
+ execsql {
+ DROP TABLE t3;
+ }
+} {}
+do_test subquery-2.4.1 {
+ execsql {
+ CREATE TABLE t3(a TEXT);
+ INSERT INTO t3 VALUES('XX');
+ }
+} {}
+do_test subquery-2.4.2 {
+ execsql {
+ SELECT count(*) FROM t3 WHERE a IN (SELECT 'XX')
+ }
+} {1}
+do_test subquery-2.4.3 {
+ execsql {
+ DROP TABLE t3;
+ }
+} {}
+do_test subquery-2.5.1 {
+ execsql {
+ CREATE TABLE t3(a INTEGER);
+ INSERT INTO t3 VALUES(10);
+
+ CREATE TABLE t4(x TEXT);
+ INSERT INTO t4 VALUES('10.0');
+ }
+} {}
+do_test subquery-2.5.2 {
+ # In the expr "x IN (SELECT a FROM t3)" the RHS of the IN operator
+ # has text affinity and the LHS has integer affinity. The rule is
+ # that we try to convert both sides to an integer before doing the
+ # comparision. Hence, the integer value 10 in t3 will compare equal
+ # to the string value '10.0' in t4 because the t4 value will be
+ # converted into an integer.
+ execsql {
+ SELECT * FROM t4 WHERE x IN (SELECT a FROM t3);
+ }
+} {10.0}
+do_test subquery-2.5.3.1 {
+ # The t4i index cannot be used to resolve the "x IN (...)" constraint
+ # because the constraint has integer affinity but t4i has text affinity.
+ execsql {
+ CREATE INDEX t4i ON t4(x);
+ SELECT * FROM t4 WHERE x IN (SELECT a FROM t3);
+ }
+} {10.0}
+do_test subquery-2.5.3.2 {
+ # Verify that the t4i index was not used in the previous query
+ set ::sqlite_query_plan
+} {t4 {}}
+do_test subquery-2.5.4 {
+ execsql {
+ DROP TABLE t3;
+ DROP TABLE t4;
+ }
+} {}
+
+#------------------------------------------------------------------
+# The following test cases - subquery-3.* - test tickets that
+# were raised during development of correlated subqueries.
+#
+
+# Ticket 1083
+ifcapable view {
+ do_test subquery-3.1 {
+ catchsql { DROP TABLE t1; }
+ catchsql { DROP TABLE t2; }
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ CREATE VIEW v1 AS SELECT b FROM t1 WHERE a>0;
+ CREATE TABLE t2(p,q);
+ INSERT INTO t2 VALUES(2,9);
+ SELECT * FROM v1 WHERE EXISTS(SELECT * FROM t2 WHERE p=v1.b);
+ }
+ } {2}
+ do_test subquery-3.1.1 {
+ execsql {
+ SELECT * FROM v1 WHERE EXISTS(SELECT 1);
+ }
+ } {2}
+} else {
+ catchsql { DROP TABLE t1; }
+ catchsql { DROP TABLE t2; }
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ CREATE TABLE t2(p,q);
+ INSERT INTO t2 VALUES(2,9);
+ }
+}
+
+# Ticket 1084
+do_test subquery-3.2 {
+ catchsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ }
+ execsql {
+ SELECT (SELECT t1.a) FROM t1;
+ }
+} {1}
+
+# Test Cases subquery-3.3.* test correlated subqueries where the
+# parent query is an aggregate query. Ticket #1105 is an example
+# of such a query.
+#
+do_test subquery-3.3.1 {
+ execsql {
+ SELECT a, (SELECT b) FROM t1 GROUP BY a;
+ }
+} {1 2}
+do_test subquery-3.3.2 {
+ catchsql {DROP TABLE t2}
+ execsql {
+ CREATE TABLE t2(c, d);
+ INSERT INTO t2 VALUES(1, 'one');
+ INSERT INTO t2 VALUES(2, 'two');
+ SELECT a, (SELECT d FROM t2 WHERE a=c) FROM t1 GROUP BY a;
+ }
+} {1 one}
+do_test subquery-3.3.3 {
+ execsql {
+ INSERT INTO t1 VALUES(2, 4);
+ SELECT max(a), (SELECT d FROM t2 WHERE a=c) FROM t1;
+ }
+} {2 two}
+do_test subquery-3.3.4 {
+ execsql {
+ SELECT a, (SELECT (SELECT d FROM t2 WHERE a=c)) FROM t1 GROUP BY a;
+ }
+} {1 one 2 two}
+do_test subquery-3.3.5 {
+ execsql {
+ SELECT a, (SELECT count(*) FROM t2 WHERE a=c) FROM t1;
+ }
+} {1 1 2 1}
+
+#------------------------------------------------------------------
+# These tests - subquery-4.* - use the TCL statement cache to try
+# and expose bugs to do with re-using statements that have been
+# passed to sqlite3_reset().
+#
+# One problem was that VDBE memory cells were not being initialised
+# to NULL on the second and subsequent executions.
+#
+do_test subquery-4.1.1 {
+ execsql {
+ SELECT (SELECT a FROM t1);
+ }
+} {1}
+do_test subquery-4.2 {
+ execsql {
+ DELETE FROM t1;
+ SELECT (SELECT a FROM t1);
+ }
+} {{}}
+do_test subquery-4.2.1 {
+ execsql {
+ CREATE TABLE t3(a PRIMARY KEY);
+ INSERT INTO t3 VALUES(10);
+ }
+ execsql {INSERT INTO t3 VALUES((SELECT max(a) FROM t3)+1)}
+} {}
+do_test subquery-4.2.2 {
+ execsql {INSERT INTO t3 VALUES((SELECT max(a) FROM t3)+1)}
+} {}
+
+#------------------------------------------------------------------
+# The subquery-5.* tests make sure string literals in double-quotes
+# are handled efficiently. Double-quote literals are first checked
+# to see if they match any column names. If there is not column name
+# match then those literals are used a string constants. When a
+# double-quoted string appears, we want to make sure that the search
+# for a matching column name did not cause an otherwise static subquery
+# to become a dynamic (correlated) subquery.
+#
+do_test subquery-5.1 {
+ proc callcntproc {n} {
+ incr ::callcnt
+ return $n
+ }
+ set callcnt 0
+ db function callcnt callcntproc
+ execsql {
+ CREATE TABLE t4(x,y);
+ INSERT INTO t4 VALUES('one',1);
+ INSERT INTO t4 VALUES('two',2);
+ INSERT INTO t4 VALUES('three',3);
+ INSERT INTO t4 VALUES('four',4);
+ CREATE TABLE t5(a,b);
+ INSERT INTO t5 VALUES(1,11);
+ INSERT INTO t5 VALUES(2,22);
+ INSERT INTO t5 VALUES(3,33);
+ INSERT INTO t5 VALUES(4,44);
+ SELECT b FROM t5 WHERE a IN
+ (SELECT callcnt(y)+0 FROM t4 WHERE x="two")
+ }
+} {22}
+do_test subquery-5.2 {
+ # This is the key test. The subquery should have only run once. If
+ # The double-quoted identifier "two" were causing the subquery to be
+ # processed as a correlated subquery, then it would have run 4 times.
+ set callcnt
+} {1}
+
+
+# Ticket #1380. Make sure correlated subqueries on an IN clause work
+# correctly when the left-hand side of the IN operator is constant.
+#
+do_test subquery-6.1 {
+ set callcnt 0
+ execsql {
+ SELECT x FROM t4 WHERE 1 IN (SELECT callcnt(count(*)) FROM t5 WHERE a=y)
+ }
+} {one two three four}
+do_test subquery-6.2 {
+ set callcnt
+} {4}
+do_test subquery-6.3 {
+ set callcnt 0
+ execsql {
+ SELECT x FROM t4 WHERE 1 IN (SELECT callcnt(count(*)) FROM t5 WHERE a=1)
+ }
+} {one two three four}
+do_test subquery-6.4 {
+ set callcnt
+} {1}
+
+if 0 { ############# disable until we get #2652 fixed
+# Ticket #2652. Allow aggregate functions of outer queries inside
+# a non-aggregate subquery.
+#
+do_test subquery-7.1 {
+ execsql {
+ CREATE TABLE t7(c7);
+ INSERT INTO t7 VALUES(1);
+ INSERT INTO t7 VALUES(2);
+ INSERT INTO t7 VALUES(3);
+ CREATE TABLE t8(c8);
+ INSERT INTO t8 VALUES(100);
+ INSERT INTO t8 VALUES(200);
+ INSERT INTO t8 VALUES(300);
+ CREATE TABLE t9(c9);
+ INSERT INTO t9 VALUES(10000);
+ INSERT INTO t9 VALUES(20000);
+ INSERT INTO t9 VALUES(30000);
+
+ SELECT (SELECT c7+c8 FROM t7) FROM t8;
+ }
+} {101 201 301}
+do_test subquery-7.2 {
+ execsql {
+ SELECT (SELECT max(c7)+c8 FROM t7) FROM t8;
+ }
+} {103 203 303}
+do_test subquery-7.3 {
+ execsql {
+ SELECT (SELECT c7+max(c8) FROM t8) FROM t7
+ }
+} {301}
+do_test subquery-7.4 {
+ execsql {
+ SELECT (SELECT max(c7)+max(c8) FROM t8) FROM t7
+ }
+} {303}
+do_test subquery-7.5 {
+ execsql {
+ SELECT (SELECT c8 FROM t8 WHERE rowid=max(c7)) FROM t7
+ }
+} {300}
+do_test subquery-7.6 {
+ execsql {
+ SELECT (SELECT (SELECT max(c7+c8+c9) FROM t9) FROM t8) FROM t7
+ }
+} {30101 30102 30103}
+do_test subquery-7.7 {
+ execsql {
+ SELECT (SELECT (SELECT c7+max(c8+c9) FROM t9) FROM t8) FROM t7
+ }
+} {30101 30102 30103}
+do_test subquery-7.8 {
+ execsql {
+ SELECT (SELECT (SELECT max(c7)+c8+c9 FROM t9) FROM t8) FROM t7
+ }
+} {10103}
+do_test subquery-7.9 {
+ execsql {
+ SELECT (SELECT (SELECT c7+max(c8)+c9 FROM t9) FROM t8) FROM t7
+ }
+} {10301 10302 10303}
+do_test subquery-7.10 {
+ execsql {
+ SELECT (SELECT (SELECT c7+c8+max(c9) FROM t9) FROM t8) FROM t7
+ }
+} {30101 30102 30103}
+do_test subquery-7.11 {
+ execsql {
+ SELECT (SELECT (SELECT max(c7)+max(c8)+max(c9) FROM t9) FROM t8) FROM t7
+ }
+} {30303}
+} ;############# Disabled
+
+finish_test
diff --git a/test/subquery2.test b/test/subquery2.test
new file mode 100644
index 0000000..0420004
--- /dev/null
+++ b/test/subquery2.test
@@ -0,0 +1,86 @@
+# 2011 September 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing correlated subqueries
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+do_test subquery2-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ INSERT INTO t1 VALUES(5,6);
+ INSERT INTO t1 VALUES(7,8);
+ CREATE TABLE t2(c,d);
+ INSERT INTO t2 VALUES(1,1);
+ INSERT INTO t2 VALUES(3,9);
+ INSERT INTO t2 VALUES(5,25);
+ INSERT INTO t2 VALUES(7,49);
+ CREATE TABLE t3(e,f);
+ INSERT INTO t3 VALUES(1,1);
+ INSERT INTO t3 VALUES(3,27);
+ INSERT INTO t3 VALUES(5,125);
+ INSERT INTO t3 VALUES(7,343);
+ COMMIT;
+ }
+ execsql {
+ SELECT a FROM t1
+ WHERE b IN (SELECT x+1 FROM (SELECT DISTINCT f/(a*a) AS x FROM t3));
+ }
+} {1 3 5 7}
+do_test subquery2-1.2 {
+ execsql {
+ CREATE INDEX t1b ON t1(b);
+ SELECT a FROM t1
+ WHERE b IN (SELECT x+1 FROM (SELECT DISTINCT f/(a*a) AS x FROM t3));
+ }
+} {1 3 5 7}
+
+do_test subquery2-1.11 {
+ execsql {
+ SELECT a FROM t1
+ WHERE +b=(SELECT x+1 FROM (SELECT DISTINCT f/(a*a) AS x FROM t3));
+ }
+} {1}
+do_test subquery2-1.12 {
+ execsql {
+ SELECT a FROM t1
+ WHERE b=(SELECT x+1 FROM (SELECT DISTINCT f/(a*a) AS x FROM t3));
+ }
+} {1}
+
+do_test subquery2-1.21 {
+ execsql {
+ SELECT a FROM t1
+ WHERE +b=(SELECT x+1 FROM
+ (SELECT DISTINCT f/d AS x FROM t2 JOIN t3 ON d*a=f))
+ }
+} {1 3 5 7}
+do_test subquery2-1.22 {
+ execsql {
+ SELECT a FROM t1
+ WHERE b=(SELECT x+1 FROM
+ (SELECT DISTINCT f/d AS x FROM t2 JOIN t3 ON d*a=f))
+ }
+} {1 3 5 7}
+
+
+finish_test
diff --git a/test/subselect.test b/test/subselect.test
new file mode 100644
index 0000000..247f68e
--- /dev/null
+++ b/test/subselect.test
@@ -0,0 +1,210 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing SELECT statements that are part of
+# expressions.
+#
+# $Id: subselect.test,v 1.16 2008/08/04 03:51:24 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Omit this whole file if the library is build without subquery support.
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+# Basic sanity checking. Try a simple subselect.
+#
+do_test subselect-1.1 {
+ execsql {
+ CREATE TABLE t1(a int, b int);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ INSERT INTO t1 VALUES(5,6);
+ }
+ execsql {SELECT * FROM t1 WHERE a = (SELECT count(*) FROM t1)}
+} {3 4}
+
+# Try a select with more than one result column.
+#
+do_test subselect-1.2 {
+ set v [catch {execsql {SELECT * FROM t1 WHERE a = (SELECT * FROM t1)}} msg]
+ lappend v $msg
+} {1 {only a single result allowed for a SELECT that is part of an expression}}
+
+# A subselect without an aggregate.
+#
+do_test subselect-1.3a {
+ execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=2)}
+} {2}
+do_test subselect-1.3b {
+ execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=4)}
+} {4}
+do_test subselect-1.3c {
+ execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=6)}
+} {6}
+do_test subselect-1.3d {
+ execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=8)}
+} {}
+ifcapable compound {
+ do_test subselect-1.3e {
+ execsql {
+ SELECT b FROM t1
+ WHERE a = (SELECT a FROM t1 UNION SELECT b FROM t1 ORDER BY 1);
+ }
+ } {2}
+}
+
+# What if the subselect doesn't return any value. We should get
+# NULL as the result. Check it out.
+#
+do_test subselect-1.4 {
+ execsql {SELECT b from t1 where a = coalesce((SELECT a FROM t1 WHERE b=5),1)}
+} {2}
+
+# Try multiple subselects within a single expression.
+#
+do_test subselect-1.5 {
+ execsql {
+ CREATE TABLE t2(x int, y int);
+ INSERT INTO t2 VALUES(1,2);
+ INSERT INTO t2 VALUES(2,4);
+ INSERT INTO t2 VALUES(3,8);
+ INSERT INTO t2 VALUES(4,16);
+ }
+ execsql {
+ SELECT y from t2
+ WHERE x = (SELECT sum(b) FROM t1 where a notnull) - (SELECT sum(a) FROM t1)
+ }
+} {8}
+
+# Try something useful. Delete every entry from t2 where the
+# x value is less than half of the maximum.
+#
+do_test subselect-1.6 {
+ execsql {DELETE FROM t2 WHERE x < 0.5*(SELECT max(x) FROM t2)}
+ execsql {SELECT x FROM t2 ORDER BY x}
+} {2 3 4}
+
+# Make sure sorting works for SELECTs there used as a scalar expression.
+#
+do_test subselect-2.1 {
+ execsql {
+ SELECT (SELECT a FROM t1 ORDER BY a), (SELECT a FROM t1 ORDER BY a DESC)
+ }
+} {1 5}
+do_test subselect-2.2 {
+ execsql {
+ SELECT 1 IN (SELECT a FROM t1 ORDER BY a);
+ }
+} {1}
+do_test subselect-2.3 {
+ execsql {
+ SELECT 2 IN (SELECT a FROM t1 ORDER BY a DESC);
+ }
+} {0}
+
+# Verify that the ORDER BY clause is honored in a subquery.
+#
+ifcapable compound {
+do_test subselect-3.1 {
+ execsql {
+ CREATE TABLE t3(x int);
+ INSERT INTO t3 SELECT a FROM t1 UNION ALL SELECT b FROM t1;
+ SELECT * FROM t3 ORDER BY x;
+ }
+} {1 2 3 4 5 6}
+} ;# ifcapable compound
+ifcapable !compound {
+do_test subselect-3.1 {
+ execsql {
+ CREATE TABLE t3(x int);
+ INSERT INTO t3 SELECT a FROM t1;
+ INSERT INTO t3 SELECT b FROM t1;
+ SELECT * FROM t3 ORDER BY x;
+ }
+} {1 2 3 4 5 6}
+} ;# ifcapable !compound
+
+do_test subselect-3.2 {
+ execsql {
+ SELECT sum(x) FROM (SELECT x FROM t3 ORDER BY x LIMIT 2);
+ }
+} {3}
+do_test subselect-3.3 {
+ execsql {
+ SELECT sum(x) FROM (SELECT x FROM t3 ORDER BY x DESC LIMIT 2);
+ }
+} {11}
+do_test subselect-3.4 {
+ execsql {
+ SELECT (SELECT x FROM t3 ORDER BY x);
+ }
+} {1}
+do_test subselect-3.5 {
+ execsql {
+ SELECT (SELECT x FROM t3 ORDER BY x DESC);
+ }
+} {6}
+do_test subselect-3.6 {
+ execsql {
+ SELECT (SELECT x FROM t3 ORDER BY x LIMIT 1);
+ }
+} {1}
+do_test subselect-3.7 {
+ execsql {
+ SELECT (SELECT x FROM t3 ORDER BY x DESC LIMIT 1);
+ }
+} {6}
+do_test subselect-3.8 {
+ execsql {
+ SELECT (SELECT x FROM t3 ORDER BY x LIMIT 1 OFFSET 2);
+ }
+} {3}
+do_test subselect-3.9 {
+ execsql {
+ SELECT (SELECT x FROM t3 ORDER BY x DESC LIMIT 1 OFFSET 2);
+ }
+} {4}
+do_test subselect-3.10 {
+ execsql {
+ SELECT x FROM t3 WHERE x IN
+ (SELECT x FROM t3 ORDER BY x DESC LIMIT 1 OFFSET 2);
+ }
+} {4}
+
+# Ticket #2295.
+# Make sure type affinities work correctly on subqueries with
+# an ORDER BY clause.
+#
+do_test subselect-4.1 {
+ execsql {
+ CREATE TABLE t4(a TEXT, b TEXT);
+ INSERT INTO t4 VALUES('a','1');
+ INSERT INTO t4 VALUES('b','2');
+ INSERT INTO t4 VALUES('c','3');
+ SELECT a FROM t4 WHERE b IN (SELECT b FROM t4 ORDER BY b);
+ }
+} {a b c}
+do_test subselect-4.2 {
+ execsql {
+ SELECT a FROM t4 WHERE b IN (SELECT b FROM t4 ORDER BY b LIMIT 1);
+ }
+} {a}
+do_test subselect-4.3 {
+ execsql {
+ SELECT a FROM t4 WHERE b IN (SELECT b FROM t4 ORDER BY b DESC LIMIT 1);
+ }
+} {c}
+
+finish_test
diff --git a/test/substr.test b/test/substr.test
new file mode 100644
index 0000000..bcd0588
--- /dev/null
+++ b/test/substr.test
@@ -0,0 +1,159 @@
+# 2007 May 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the built-in SUBSTR() functions.
+#
+# $Id: substr.test,v 1.7 2009/02/03 13:10:54 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !tclvar {
+ finish_test
+ return
+}
+
+# Create a table to work with.
+#
+execsql {
+ CREATE TABLE t1(t text, b blob)
+}
+proc substr-test {id string i1 i2 result} {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1(t) VALUES($string)
+ }
+ do_test substr-$id.1 [subst {
+ execsql {
+ SELECT substr(t, $i1, $i2) FROM t1
+ }
+ }] [list $result]
+ set qstr '[string map {' ''} $string]'
+ do_test substr-$id.2 [subst {
+ execsql {
+ SELECT substr($qstr, $i1, $i2)
+ }
+ }] [list $result]
+}
+proc subblob-test {id hex i1 i2 hexresult} {
+ db eval "
+ DELETE FROM t1;
+ INSERT INTO t1(b) VALUES(x'$hex')
+ "
+ do_test substr-$id.1 [subst {
+ execsql {
+ SELECT hex(substr(b, $i1, $i2)) FROM t1
+ }
+ }] [list $hexresult]
+ do_test substr-$id.2 [subst {
+ execsql {
+ SELECT hex(substr(x'$hex', $i1, $i2))
+ }
+ }] [list $hexresult]
+}
+
+# Basic SUBSTR functionality
+#
+substr-test 1.1 abcdefg 1 1 a
+substr-test 1.2 abcdefg 2 1 b
+substr-test 1.3 abcdefg 1 2 ab
+substr-test 1.4 abcdefg 1 100 abcdefg
+substr-test 1.5 abcdefg 0 2 a
+substr-test 1.6 abcdefg -1 1 g
+substr-test 1.7 abcdefg -1 10 g
+substr-test 1.8 abcdefg -5 3 cde
+substr-test 1.9 abcdefg -7 3 abc
+substr-test 1.10 abcdefg -100 98 abcde
+substr-test 1.11 abcdefg 5 -1 d
+substr-test 1.12 abcdefg 5 -4 abcd
+substr-test 1.13 abcdefg 5 -5 abcd
+substr-test 1.14 abcdefg -5 -1 b
+substr-test 1.15 abcdefg -5 -2 ab
+substr-test 1.16 abcdefg -5 -3 ab
+substr-test 1.17 abcdefg 100 200 {}
+substr-test 1.18 abcdefg 200 100 {}
+
+# Make sure NULL is returned if any parameter is NULL
+#
+do_test substr-1.90 {
+ db eval {SELECT ifnull(substr(NULL,1,1),'nil')}
+} nil
+do_test substr-1.91 {
+ db eval {SELECT ifnull(substr(NULL,1),'nil')}
+} nil
+do_test substr-1.92 {
+ db eval {SELECT ifnull(substr('abcdefg',NULL,1),'nil')}
+} nil
+do_test substr-1.93 {
+ db eval {SELECT ifnull(substr('abcdefg',NULL),'nil')}
+} nil
+do_test substr-1.94 {
+ db eval {SELECT ifnull(substr('abcdefg',1,NULL),'nil')}
+} nil
+
+# Make sure everything works with long unicode characters
+#
+substr-test 2.1 \u1234\u2345\u3456 1 1 \u1234
+substr-test 2.2 \u1234\u2345\u3456 2 1 \u2345
+substr-test 2.3 \u1234\u2345\u3456 1 2 \u1234\u2345
+substr-test 2.4 \u1234\u2345\u3456 -1 1 \u3456
+substr-test 2.5 a\u1234b\u2345c\u3456c -5 3 b\u2345c
+substr-test 2.6 a\u1234b\u2345c\u3456c -2 -3 b\u2345c
+
+# Basic functionality for BLOBs
+#
+subblob-test 3.1 61626364656667 1 1 61
+subblob-test 3.2 61626364656667 2 1 62
+subblob-test 3.3 61626364656667 1 2 6162
+subblob-test 3.4 61626364656667 1 100 61626364656667
+subblob-test 3.5 61626364656667 0 2 61
+subblob-test 3.6 61626364656667 -1 1 67
+subblob-test 3.7 61626364656667 -1 10 67
+subblob-test 3.8 61626364656667 -5 3 636465
+subblob-test 3.9 61626364656667 -7 3 616263
+subblob-test 3.10 61626364656667 -100 98 6162636465
+subblob-test 3.11 61626364656667 100 200 {}
+subblob-test 3.12 61626364656667 200 100 {}
+
+# If these blobs were strings, then they would contain multi-byte
+# characters. But since they are blobs, the substr indices refer
+# to bytes.
+#
+subblob-test 4.1 61E188B462E28D8563E3919663 1 1 61
+subblob-test 4.2 61E188B462E28D8563E3919663 2 1 E1
+subblob-test 4.3 61E188B462E28D8563E3919663 1 2 61E1
+subblob-test 4.4 61E188B462E28D8563E3919663 -2 1 96
+subblob-test 4.5 61E188B462E28D8563E3919663 -5 4 63E39196
+subblob-test 4.6 61E188B462E28D8563E3919663 -100 98 61E188B462E28D8563E391
+
+# Two-argument SUBSTR
+#
+proc substr-2-test {id string idx result} {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1(t) VALUES($string)
+ }
+ do_test substr-$id.1 [subst {
+ execsql {
+ SELECT substr(t, $idx) FROM t1
+ }
+ }] [list $result]
+ set qstr '[string map {' ''} $string]'
+ do_test substr-$id.2 [subst {
+ execsql {
+ SELECT substr($qstr, $idx)
+ }
+ }] [list $result]
+}
+substr-2-test 5.1 abcdefghijklmnop 5 efghijklmnop
+substr-2-test 5.2 abcdef -5 bcdef
+
+finish_test
diff --git a/test/superlock.test b/test/superlock.test
new file mode 100644
index 0000000..8155d92
--- /dev/null
+++ b/test/superlock.test
@@ -0,0 +1,254 @@
+# 2010 November 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+
+set testprefix superlock
+
+# Test organization:
+#
+# 1.*: Test superlock on a rollback database. Test that once the db is
+# superlocked, it is not possible for a second client to read from
+# it.
+#
+# 2.*: Test superlock on a WAL database with zero frames in the WAL file.
+# Test that once the db is superlocked, it is not possible to read,
+# write or checkpoint the db.
+#
+# 3.*: As 2.*, for WAL databases with one or more frames in the WAL.
+#
+# 4.*: As 2.*, for WAL databases with one or more checkpointed frames
+# in the WAL.
+#
+# 5.*: Test that a call to sqlite3demo_superlock() uses the busy handler
+# correctly to wait for existing clients to clear on a WAL database.
+# And returns SQLITE_BUSY if no busy handler is defined or the busy
+# handler returns 0 before said clients relinquish their locks.
+#
+# 6.*: Test that if a superlocked WAL database is overwritten, existing
+# clients run the recovery to build the new wal-index after the
+# superlock is released.
+#
+#
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ PRAGMA journal_mode = DELETE;
+} {delete}
+
+ifcapable !wal {
+ finish_test
+ return
+}
+
+do_test 1.2 { sqlite3demo_superlock unlock test.db } {unlock}
+do_catchsql_test 1.3 { SELECT * FROM t1 } {1 {database is locked}}
+do_test 1.4 { unlock } {}
+
+do_execsql_test 2.1 {
+ INSERT INTO t1 VALUES(3, 4);
+ PRAGMA journal_mode = WAL;
+} {wal}
+
+do_test 2.2 { sqlite3demo_superlock unlock test.db } {unlock}
+do_catchsql_test 2.3 { SELECT * FROM t1 } {1 {database is locked}}
+do_catchsql_test 2.4 { INSERT INTO t1 VALUES(5, 6)} {1 {database is locked}}
+do_catchsql_test 2.5 { PRAGMA wal_checkpoint } {0 {1 -1 -1}}
+do_test 2.6 { unlock } {}
+
+do_execsql_test 3.1 { INSERT INTO t1 VALUES(3, 4) }
+
+do_test 3.2 { sqlite3demo_superlock unlock test.db } {unlock}
+do_catchsql_test 3.3 { SELECT * FROM t1 } {1 {database is locked}}
+do_catchsql_test 3.4 { INSERT INTO t1 VALUES(5, 6)} {1 {database is locked}}
+do_catchsql_test 3.5 { PRAGMA wal_checkpoint } {0 {1 -1 -1}}
+do_test 3.6 { unlock } {}
+
+do_execsql_test 4.1 { PRAGMA wal_checkpoint } {0 2 2}
+
+do_test 4.2 { sqlite3demo_superlock unlock test.db } {unlock}
+do_catchsql_test 4.3 { SELECT * FROM t1 } {1 {database is locked}}
+do_catchsql_test 4.4 { INSERT INTO t1 VALUES(5, 6)} {1 {database is locked}}
+do_catchsql_test 4.5 { PRAGMA wal_checkpoint } {0 {1 -1 -1}}
+do_test 4.6 { unlock } {}
+
+do_multiclient_test tn {
+
+ proc busyhandler {x} {
+ switch -- $x {
+ 1 { sql1 "COMMIT" }
+ 2 { sql2 "COMMIT" }
+ 3 { sql3 "COMMIT" }
+ }
+ lappend ::busylist $x
+ return 1
+ }
+ set ::busylist [list]
+
+ do_test 5.$tn.1 {
+ sql1 {
+ CREATE TABLE t1(a, b);
+ PRAGMA journal_mode = WAL;
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ } {wal}
+
+ do_test 5.$tn.2 {
+ sql1 { BEGIN ; SELECT * FROM t1 }
+ sql2 { BEGIN ; INSERT INTO t1 VALUES(3, 4) }
+ sql3 { BEGIN ; SELECT * FROM t1 }
+ } {1 2}
+
+ do_test 5.$tn.3 {
+ set ::busylist [list]
+ sqlite3demo_superlock unlock test.db "" busyhandler
+ set ::busylist
+ } {0 1 2 3}
+
+ do_test 5.$tn.4 { csql2 { SELECT * FROM t1 } } {1 {database is locked}}
+ do_test 5.$tn.5 {
+ csql3 { INSERT INTO t1 VALUES(5, 6) }
+ } {1 {database is locked}}
+ do_test 5.$tn.6 { csql1 "PRAGMA wal_checkpoint" } {0 {1 -1 -1}}
+
+ do_test 5.$tn.7 { unlock } {}
+
+
+ do_test 5.$tn.8 {
+ sql1 { BEGIN ; SELECT * FROM t1 }
+ sql2 { BEGIN ; INSERT INTO t1 VALUES(5, 6) }
+ sql3 { BEGIN ; SELECT * FROM t1 }
+ } {1 2 3 4}
+
+ do_test 5.$tn.9 {
+ list [catch {sqlite3demo_superlock unlock test.db} msg] $msg
+ } {1 {database is locked}}
+ do_test 5.$tn.10 {
+ sql1 COMMIT
+ list [catch {sqlite3demo_superlock unlock test.db} msg] $msg
+ } {1 {database is locked}}
+ do_test 5.$tn.11 {
+ sql2 COMMIT
+ list [catch {sqlite3demo_superlock unlock test.db} msg] $msg
+ } {1 {database is locked}}
+ do_test 5.$tn.12 {
+ sql3 COMMIT
+ list [catch {sqlite3demo_superlock unlock test.db} msg] $msg
+ } {0 unlock}
+ unlock
+
+
+ do_test 5.$tn.13 { sql1 { SELECT * FROM t1 } } {1 2 3 4 5 6}
+ do_test 5.$tn.14 { sql2 { SELECT * FROM t1 } } {1 2 3 4 5 6}
+ do_test 5.$tn.15 { sqlite3demo_superlock unlock test.db } {unlock}
+ do_test 5.$tn.16 { unlock } {}
+ do_test 5.$tn.17 { sql2 { SELECT * FROM t1 } } {1 2 3 4 5 6}
+ do_test 5.$tn.18 { sql1 { SELECT * FROM t1 } } {1 2 3 4 5 6}
+ do_test 5.$tn.19 { sql2 { SELECT * FROM t1 } } {1 2 3 4 5 6}
+}
+
+proc read_content {file} {
+ if {[file exists $file]==0} {return ""}
+ set fd [open $file]
+ fconfigure $fd -encoding binary -translation binary
+ set content [read $fd]
+ close $fd
+ return $content
+}
+
+proc write_content {file content} {
+ set fd [open $file w+]
+ fconfigure $fd -encoding binary -translation binary
+ puts -nonewline $fd $content
+ close $fd
+}
+
+# Both $file1 and $file2 are database files. This function takes a
+# superlock on each, then exchanges the content of the two files (i.e.
+# overwrites $file1 with the initial contents of $file2, and overwrites
+# $file2 with the initial contents of $file1). The contents of any WAL
+# file is also exchanged.
+#
+proc db_swap {file1 file2} {
+ sqlite3demo_superlock unlock1 $file1
+ sqlite3demo_superlock unlock2 $file2
+
+ set db1 [read_content $file1]
+ set db2 [read_content $file2]
+ write_content $file1 $db2
+ write_content $file2 $db1
+
+ set wal1 [read_content ${file1}-wal]
+ set wal2 [read_content ${file2}-wal]
+ write_content ${file1}-wal $wal2
+ write_content ${file2}-wal $wal1
+
+ unlock1
+ unlock2
+}
+
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test 6.1 {
+ ATTACH 'test.db2' AS aux;
+ PRAGMA aux.journal_mode = wal;
+ CREATE TABLE aux.t2(x, y);
+ INSERT INTO aux.t2 VALUES('a', 'b');
+ PRAGMA schema_version = 450;
+ DETACH aux;
+
+ PRAGMA main.journal_mode = wal;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ SELECT * FROM t1;
+} {wal wal 1 2 3 4}
+
+
+db_swap test.db2 test.db
+do_catchsql_test 6.2 { SELECT * FROM t1 } {1 {no such table: t1}}
+do_catchsql_test 6.3 { SELECT * FROM t2 } {0 {a b}}
+
+db_swap test.db2 test.db
+do_catchsql_test 6.4 { SELECT * FROM t1 } {0 {1 2 3 4}}
+do_catchsql_test 6.5 { SELECT * FROM t2 } {1 {no such table: t2}}
+
+do_execsql_test 6.6 { PRAGMA wal_checkpoint } {0 0 0}
+
+db_swap test.db2 test.db
+do_catchsql_test 6.7 { SELECT * FROM t1 } {1 {no such table: t1}}
+do_catchsql_test 6.8 { SELECT * FROM t2 } {0 {a b}}
+
+db_swap test.db2 test.db
+do_catchsql_test 6.9 { SELECT * FROM t1 } {0 {1 2 3 4}}
+do_catchsql_test 6.10 { SELECT * FROM t2 } {1 {no such table: t2}}
+
+do_execsql_test 6.11 {
+ PRAGMA journal_mode = delete;
+ PRAGMA page_size = 512;
+ VACUUM;
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(5, 6);
+} {delete wal}
+
+db_swap test.db2 test.db
+do_catchsql_test 6.12 { SELECT * FROM t1 } {1 {no such table: t1}}
+do_catchsql_test 6.13 { SELECT * FROM t2 } {0 {a b}}
+
+db_swap test.db2 test.db
+do_catchsql_test 6.14 { SELECT * FROM t1 } {0 {1 2 3 4 5 6}}
+do_catchsql_test 6.15 { SELECT * FROM t2 } {1 {no such table: t2}}
+
+finish_test
diff --git a/test/sync.test b/test/sync.test
new file mode 100644
index 0000000..14252b5
--- /dev/null
+++ b/test/sync.test
@@ -0,0 +1,100 @@
+# 2005 August 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that fsync is disabled when
+# pragma synchronous=off even for multi-database commits.
+#
+# $Id: sync.test,v 1.6 2007/10/09 08:29:33 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+#
+# These tests are only applicable when pager pragma are
+# enabled. Also, since every test uses an ATTACHed database, they
+# are only run when ATTACH is enabled.
+#
+ifcapable !pager_pragmas||!attach {
+ finish_test
+ return
+}
+
+set sqlite_sync_count 0
+proc cond_incr_sync_count {adj} {
+ global sqlite_sync_count
+ if {$::tcl_platform(platform) == "windows"} {
+ incr sqlite_sync_count $adj
+ } {
+ ifcapable !dirsync {
+ incr sqlite_sync_count $adj
+ }
+ }
+}
+
+do_test sync-1.1 {
+ set sqlite_sync_count 0
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ execsql {
+ PRAGMA fullfsync=OFF;
+ CREATE TABLE t1(a,b);
+ ATTACH DATABASE 'test2.db' AS db2;
+ CREATE TABLE db2.t2(x,y);
+ }
+ cond_incr_sync_count 2
+ set sqlite_sync_count
+} 8
+ifcapable pager_pragmas {
+ do_test sync-1.2 {
+ set sqlite_sync_count 0
+ execsql {
+ PRAGMA main.synchronous=on;
+ PRAGMA db2.synchronous=on;
+ BEGIN;
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(3,4);
+ COMMIT;
+ }
+ cond_incr_sync_count 3
+ set sqlite_sync_count
+ } 8
+}
+do_test sync-1.3 {
+ set sqlite_sync_count 0
+ execsql {
+ PRAGMA main.synchronous=full;
+ PRAGMA db2.synchronous=full;
+ BEGIN;
+ INSERT INTO t1 VALUES(3,4);
+ INSERT INTO t2 VALUES(5,6);
+ COMMIT;
+ }
+ cond_incr_sync_count 3
+ set sqlite_sync_count
+} 10
+ifcapable pager_pragmas {
+ do_test sync-1.4 {
+ set sqlite_sync_count 0
+ execsql {
+ PRAGMA main.synchronous=off;
+ PRAGMA db2.synchronous=off;
+ BEGIN;
+ INSERT INTO t1 VALUES(5,6);
+ INSERT INTO t2 VALUES(7,8);
+ COMMIT;
+ }
+ set sqlite_sync_count
+ } 0
+}
+
+
+finish_test
diff --git a/test/syscall.test b/test/syscall.test
new file mode 100644
index 0000000..201bd63
--- /dev/null
+++ b/test/syscall.test
@@ -0,0 +1,276 @@
+# 2011 March 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+if {[llength [info commands test_syscall]]==0} {
+ finish_test
+ return
+}
+
+if {[test_syscall defaultvfs] != "unix"} {
+ finish_test
+ return
+}
+set testprefix syscall
+
+#-------------------------------------------------------------------------
+# Tests for the xSetSystemCall method.
+#
+do_test 1.1.1 {
+ list [catch { test_syscall reset open } msg] $msg
+} {0 {}}
+do_test 1.1.2 {
+ list [catch { test_syscall reset nosuchcall } msg] $msg
+} {1 SQLITE_NOTFOUND}
+do_test 1.1.3 {
+ list [catch { test_syscall reset open } msg] $msg
+} {0 {}}
+do_test 1.1.4 {
+ list [catch { test_syscall reset ""} msg] $msg
+} {1 SQLITE_NOTFOUND}
+
+do_test 1.2 { test_syscall reset } {}
+
+do_test 1.3.1 { test_syscall install {open getcwd access} } {}
+do_test 1.3.2 { test_syscall reset } {}
+
+#-------------------------------------------------------------------------
+# Tests for the xGetSystemCall method.
+#
+do_test 2.1.1 { test_syscall exists open } 1
+do_test 2.1.2 { test_syscall exists nosuchcall } 0
+
+#-------------------------------------------------------------------------
+# Tests for the xNextSystemCall method.
+#
+foreach s {
+ open close access getcwd stat fstat ftruncate
+ fcntl read pread write pwrite fchmod fallocate
+ pread64 pwrite64 unlink openDirectory
+} {
+ if {[test_syscall exists $s]} {lappend syscall_list $s}
+}
+do_test 3.1 { lsort [test_syscall list] } [lsort $syscall_list]
+
+#-------------------------------------------------------------------------
+# This test verifies that if a call to open() fails and errno is set to
+# EINTR, the call is retried. If it succeeds, execution continues as if
+# nothing happened.
+#
+test_syscall reset
+forcedelete test.db2
+do_execsql_test 4.1 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t2(x, y);
+ INSERT INTO t2 VALUES(3, 4);
+}
+
+db_save_and_close
+test_syscall install open
+foreach jrnl [list wal delete] {
+ for {set i 1} {$i < 20} {incr i} {
+ db_restore_and_reopen
+ test_syscall fault $i 0
+ test_syscall errno open EINTR
+
+ do_test 4.2.$jrnl.$i {
+ sqlite3 db test.db
+ execsql { ATTACH 'test.db2' AS aux }
+ execsql "PRAGMA main.journal_mode = $jrnl"
+ execsql "PRAGMA aux.journal_mode = $jrnl"
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(5, 6);
+ INSERT INTO t2 VALUES(7, 8);
+ COMMIT;
+ }
+
+ db close
+ sqlite3 db test.db
+ execsql { ATTACH 'test.db2' AS aux }
+ execsql {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+ } {1 2 5 6 3 4 7 8}
+ }
+}
+
+#-------------------------------------------------------------------------
+# This test verifies that closing database handles does not drop locks
+# held by other database handles in the same process on the same file.
+#
+# The os_unix.c module has to take precautions to prevent this as the
+# close() system call drops locks held by other file-descriptors on the
+# same file. From the Linux man page:
+#
+# close() closes a file descriptor, so that it no longer refers to any file
+# and may be reused. Any record locks (see fcntl(2)) held on the file it
+# was associated with, and owned by the process, are removed (regardless
+# of the file descriptor that was used to obtain the lock).
+#
+catch { db close }
+forcedelete test.db test.db2
+
+do_multiclient_test tn {
+ code1 {
+ sqlite3 dbX1 test.db
+ sqlite3 dbX2 test.db
+ }
+
+ do_test syscall-5.$tn.1 {
+ sql1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ } {}
+
+ do_test syscall-5.$tn.2 { sql2 { SELECT * FROM t1 } } {1 2}
+ do_test syscall-5.$tn.3 {
+ csql2 { INSERT INTO t1 VALUES(5, 6) }
+ } {1 {database is locked}}
+
+ do_test syscall-5.$tn.4 {
+ code1 {
+ dbX1 close
+ dbX2 close
+ }
+ } {}
+
+ do_test syscall-5.$tn.5 {
+ csql2 { INSERT INTO t1 VALUES(5, 6) }
+ } {1 {database is locked}}
+
+ do_test syscall-5.$tn.6 { sql1 { COMMIT } } {}
+
+ do_test syscall-5.$tn.7 {
+ csql2 { INSERT INTO t1 VALUES(5, 6) }
+ } {0 {}}
+}
+
+catch {db close}
+do_test 6.1 {
+ sqlite3 db1 test.db1
+ sqlite3 db2 test.db2
+ sqlite3 db3 test.db3
+ sqlite3 dbM ""
+
+ db2 close
+ db3 close
+ dbM close
+ db1 close
+} {}
+
+do_test 6.2 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA temp_store = file;
+
+ PRAGMA main.cache_size = 10;
+ PRAGMA temp.cache_size = 10;
+ CREATE TABLE temp.tt(a, b);
+ INSERT INTO tt VALUES(randomblob(500), randomblob(600));
+ INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
+ INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
+ INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
+ INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
+ INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
+ INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
+ INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
+ INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;
+ }
+
+ db close
+} {}
+
+#-------------------------------------------------------------------------
+# Test that a database file a single byte in size is treated as an empty
+# file. Whereas a file 2 bytes or larger might be considered corrupt.
+#
+catch { db close }
+forcedelete test.db test.db2
+
+proc create_db_file {nByte} {
+ set fd [open test.db w]
+ fconfigure $fd -translation binary -encoding binary
+ puts -nonewline $fd [string range "xSQLite" 1 $nByte]
+ close $fd
+}
+
+foreach {nByte res} {
+ 1 {0 {}}
+ 2 {1 {file is encrypted or is not a database}}
+ 3 {1 {file is encrypted or is not a database}}
+} {
+ do_test 7.$nByte {
+ create_db_file $nByte
+ list [catch {
+ sqlite3 db test.db
+ execsql { CREATE TABLE t1(a, b) }
+ } msg] $msg
+ } $res
+ catch { db close }
+}
+
+#-------------------------------------------------------------------------
+#
+catch { db close }
+forcedelete test.db test.db2
+
+do_test 8.1 {
+ sqlite3 db test.db
+ file_control_chunksize_test db main 4096
+ file size test.db
+} {0}
+foreach {tn hint size} {
+ 1 1000 4096
+ 2 1000 4096
+ 3 3000 4096
+ 4 4096 4096
+ 5 4197 8192
+} {
+ do_test 8.2.$tn {
+ file_control_sizehint_test db main $hint
+ file size test.db
+ } $size
+}
+
+do_test 8.3 {
+ db close
+ forcedelete test.db test.db2
+ sqlite3 db test.db
+ file_control_chunksize_test db main 16
+ file size test.db
+} {0}
+foreach {tn hint size} {
+ 1 5 16
+ 2 13 16
+ 3 45 48
+ 4 48 48
+ 5 49 64
+} {
+ do_test 8.4.$tn {
+ file_control_sizehint_test db main $hint
+ file size test.db
+ } $size
+}
+
+test_syscall reset
+finish_test
diff --git a/test/sysfault.test b/test/sysfault.test
new file mode 100644
index 0000000..07d525c
--- /dev/null
+++ b/test/sysfault.test
@@ -0,0 +1,247 @@
+# 2011 March 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+if {[llength [info commands test_syscall]]==0} {
+ finish_test
+ return
+}
+
+set testprefix sysfault
+
+set FAULTSIM(vfsfault-transient) [list \
+ -injectinstall vfsfault_install \
+ -injectstart vfsfault_injectstart_t \
+ -injectstop vfsfault_injectstop \
+ -injecterrlist {} \
+ -injectuninstall {test_syscall uninstall} \
+]
+set FAULTSIM(vfsfault-persistent) [list \
+ -injectinstall vfsfault_install \
+ -injectstart vfsfault_injectstart_p \
+ -injectstop vfsfault_injectstop \
+ -injecterrlist {} \
+ -injectuninstall {test_syscall uninstall} \
+]
+
+proc vfsfault_injectstart_t {iFail} { test_syscall fault $iFail 0 }
+proc vfsfault_injectstart_p {iFail} { test_syscall fault $iFail 1 }
+proc vfsfault_injectstop {} { test_syscall fault }
+
+faultsim_save_and_close
+
+
+set open_and_write_body {
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ PRAGMA journal_mode = WAL;
+ INSERT INTO t1 VALUES(3, 4);
+ SELECT * FROM t1;
+ CREATE TEMP TABLE t2(x);
+ INSERT INTO t2 VALUES('y');
+ }
+}
+
+proc vfsfault_install {} { test_syscall install {open getcwd} }
+do_faultsim_test 1 -faults vfsfault-* -prep {
+ faultsim_restore
+} -body $open_and_write_body -test {
+ faultsim_test_result {0 {wal 1 2 3 4}} \
+ {1 {unable to open database file}} \
+ {1 {attempt to write a readonly database}}
+}
+
+#-------------------------------------------------------------------------
+# Errors in the fstat() function when opening and writing a file. Cases
+# where fstat() fails and sets errno to ENOMEM and EOVERFLOW are both
+# tested. EOVERFLOW is interpreted as meaning that a file on disk is
+# too large to be opened by the OS.
+#
+foreach {tn errno errlist} {
+ 1 ENOMEM {{disk I/O error}}
+ 2 EOVERFLOW {{disk I/O error} {large file support is disabled}}
+} {
+ proc vfsfault_install {} { test_syscall install fstat }
+ set errs [list]
+ foreach e $errlist { lappend errs [list 1 $e] }
+ do_faultsim_test 1.2.$tn -faults vfsfault-* -prep {
+ faultsim_restore
+ } -body "
+ test_syscall errno fstat $errno
+ $open_and_write_body
+ " -test "
+ faultsim_test_result {0 {wal 1 2 3 4}} $errs
+ "
+}
+
+#-------------------------------------------------------------------------
+# Various errors in locking functions.
+#
+foreach vfs {unix unix-excl} {
+ foreach {tn errno errlist} {
+ 1 EAGAIN {{database is locked} {disk I/O error}}
+ 2 ETIMEDOUT {{database is locked} {disk I/O error}}
+ 3 EBUSY {{database is locked} {disk I/O error}}
+ 4 EINTR {{database is locked} {disk I/O error}}
+ 5 ENOLCK {{database is locked} {disk I/O error}}
+ 6 EACCES {{database is locked} {disk I/O error}}
+ 7 EPERM {{access permission denied} {disk I/O error}}
+ 8 EDEADLK {{disk I/O error}}
+ 9 ENOMEM {{disk I/O error}}
+ } {
+ proc vfsfault_install {} { test_syscall install fcntl }
+ set errs [list]
+ foreach e $errlist { lappend errs [list 1 $e] }
+
+ set body [string map [list %VFS% $vfs] {
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ set fd [open test.db-journal w]
+ puts $fd "hello world"
+ close $fd
+ sqlite3 db test.db -vfs %VFS%
+ db eval {
+ SELECT * FROM t1;
+ }
+ }]
+
+ do_faultsim_test 1.3.$vfs.$tn -faults vfsfault-* -prep {
+ faultsim_restore
+ } -body "
+ test_syscall errno fcntl $errno
+ $body
+ " -test "
+ faultsim_test_result {0 {1 2}} $errs
+ "
+ }
+}
+
+#-------------------------------------------------------------------------
+# Check that a single EINTR error does not affect processing.
+#
+proc vfsfault_install {} {
+ test_syscall reset
+ test_syscall install {open ftruncate close read pread pread64 write fallocate}
+}
+
+forcedelete test.db test.db2
+sqlite3 db test.db
+do_test 2.setup {
+ execsql {
+ CREATE TABLE t1(a, b, c, PRIMARY KEY(a));
+ INSERT INTO t1 VALUES('abc', 'def', 'ghi');
+ ATTACH 'test.db2' AS 'aux';
+ CREATE TABLE aux.t2(x);
+ INSERT INTO t2 VALUES(1);
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test 2.1 -faults vfsfault-transient -prep {
+ catch { db close }
+ faultsim_restore
+} -body {
+ test_syscall errno open EINTR
+ test_syscall errno ftruncate EINTR
+ test_syscall errno close EINTR
+ test_syscall errno read EINTR
+ test_syscall errno pread EINTR
+ test_syscall errno pread64 EINTR
+ test_syscall errno write EINTR
+ test_syscall errno fallocate EINTR
+
+ sqlite3 db test.db
+ file_control_chunksize_test db main 8192
+
+ set res [db eval {
+ ATTACH 'test.db2' AS 'aux';
+ SELECT * FROM t1;
+ PRAGMA journal_mode = truncate;
+ BEGIN;
+ INSERT INTO t1 VALUES('jkl', 'mno', 'pqr');
+ INSERT INTO t1 VALUES(randomblob(10000), 0, 0);
+ UPDATE t2 SET x = 2;
+ COMMIT;
+ DELETE FROM t1 WHERE length(a)>3;
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }]
+ db close
+ set res
+} -test {
+ faultsim_test_result {0 {abc def ghi truncate abc def ghi jkl mno pqr 2}}
+}
+
+do_faultsim_test 2.2 -faults vfsfault-* -prep {
+ catch { db close }
+ faultsim_restore
+} -body {
+ sqlite3 db test.db
+ set res [db eval {
+ ATTACH 'test.db2' AS 'aux';
+ SELECT * FROM t1;
+ PRAGMA journal_mode = truncate;
+ BEGIN;
+ INSERT INTO t1 VALUES('jkl', 'mno', 'pqr');
+ UPDATE t2 SET x = 2;
+ COMMIT;
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }]
+ db close
+ set res
+} -test {
+ faultsim_test_result {0 {abc def ghi truncate abc def ghi jkl mno pqr 2}} \
+ {1 {unable to open database file}} \
+ {1 {unable to open database: test.db2}} \
+ {1 {attempt to write a readonly database}} \
+ {1 {disk I/O error}}
+}
+
+#-------------------------------------------------------------------------
+
+proc vfsfault_install {} {
+ test_syscall reset
+ test_syscall install {fstat fallocate}
+}
+do_faultsim_test 3 -faults vfsfault-* -prep {
+ faultsim_delete_and_reopen
+ file_control_chunksize_test db main 8192
+ execsql {
+ CREATE TABLE t1(a, b);
+ BEGIN;
+ SELECT * FROM t1;
+ }
+} -body {
+ test_syscall errno fstat EIO
+ test_syscall errno fallocate EIO
+
+ execsql {
+ INSERT INTO t1 VALUES(randomblob(10000), randomblob(10000));
+ SELECT length(a) + length(b) FROM t1;
+ COMMIT;
+ }
+} -test {
+ faultsim_test_result {0 20000}
+}
+
+finish_test
+
diff --git a/test/table.test b/test/table.test
new file mode 100644
index 0000000..4826cb9
--- /dev/null
+++ b/test/table.test
@@ -0,0 +1,728 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the CREATE TABLE statement.
+#
+# $Id: table.test,v 1.53 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a basic table and verify it is added to sqlite_master
+#
+do_test table-1.1 {
+ execsql {
+ CREATE TABLE test1 (
+ one varchar(10),
+ two text
+ )
+ }
+ execsql {
+ SELECT sql FROM sqlite_master WHERE type!='meta'
+ }
+} {{CREATE TABLE test1 (
+ one varchar(10),
+ two text
+ )}}
+
+
+# Verify the other fields of the sqlite_master file.
+#
+do_test table-1.3 {
+ execsql {SELECT name, tbl_name, type FROM sqlite_master WHERE type!='meta'}
+} {test1 test1 table}
+
+# Close and reopen the database. Verify that everything is
+# still the same.
+#
+do_test table-1.4 {
+ db close
+ sqlite3 db test.db
+ execsql {SELECT name, tbl_name, type from sqlite_master WHERE type!='meta'}
+} {test1 test1 table}
+
+# Drop the database and make sure it disappears.
+#
+do_test table-1.5 {
+ execsql {DROP TABLE test1}
+ execsql {SELECT * FROM sqlite_master WHERE type!='meta'}
+} {}
+
+# Close and reopen the database. Verify that the table is
+# still gone.
+#
+do_test table-1.6 {
+ db close
+ sqlite3 db test.db
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
+} {}
+
+# Repeat the above steps, but this time quote the table name.
+#
+do_test table-1.10 {
+ execsql {CREATE TABLE "create" (f1 int)}
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
+} {create}
+do_test table-1.11 {
+ execsql {DROP TABLE "create"}
+ execsql {SELECT name FROM "sqlite_master" WHERE type!='meta'}
+} {}
+do_test table-1.12 {
+ execsql {CREATE TABLE test1("f1 ho" int)}
+ execsql {SELECT name as "X" FROM sqlite_master WHERE type!='meta'}
+} {test1}
+do_test table-1.13 {
+ execsql {DROP TABLE "TEST1"}
+ execsql {SELECT name FROM "sqlite_master" WHERE type!='meta'}
+} {}
+
+
+
+# Verify that we cannot make two tables with the same name
+#
+do_test table-2.1 {
+ execsql {CREATE TABLE TEST2(one text)}
+ catchsql {CREATE TABLE test2(two text default 'hi')}
+} {1 {table test2 already exists}}
+do_test table-2.1.1 {
+ catchsql {CREATE TABLE "test2" (two)}
+} {1 {table "test2" already exists}}
+do_test table-2.1b {
+ set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg]
+ lappend v $msg
+} {1 {object name reserved for internal use: sqlite_master}}
+do_test table-2.1c {
+ db close
+ sqlite3 db test.db
+ set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg]
+ lappend v $msg
+} {1 {object name reserved for internal use: sqlite_master}}
+do_test table-2.1d {
+ catchsql {CREATE TABLE IF NOT EXISTS test2(x,y)}
+} {0 {}}
+do_test table-2.1e {
+ catchsql {CREATE TABLE IF NOT EXISTS test2(x UNIQUE, y TEXT PRIMARY KEY)}
+} {0 {}}
+do_test table-2.1f {
+ execsql {DROP TABLE test2; SELECT name FROM sqlite_master WHERE type!='meta'}
+} {}
+
+# Verify that we cannot make a table with the same name as an index
+#
+do_test table-2.2a {
+ execsql {CREATE TABLE test2(one text)}
+ execsql {CREATE INDEX test3 ON test2(one)}
+ catchsql {CREATE TABLE test3(two text)}
+} {1 {there is already an index named test3}}
+do_test table-2.2b {
+ db close
+ sqlite3 db test.db
+ set v [catch {execsql {CREATE TABLE test3(two text)}} msg]
+ lappend v $msg
+} {1 {there is already an index named test3}}
+do_test table-2.2c {
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {test2 test3}
+do_test table-2.2d {
+ execsql {DROP INDEX test3}
+ set v [catch {execsql {CREATE TABLE test3(two text)}} msg]
+ lappend v $msg
+} {0 {}}
+do_test table-2.2e {
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {test2 test3}
+do_test table-2.2f {
+ execsql {DROP TABLE test2; DROP TABLE test3}
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {}
+
+# Create a table with many field names
+#
+set big_table \
+{CREATE TABLE big(
+ f1 varchar(20),
+ f2 char(10),
+ f3 varchar(30) primary key,
+ f4 text,
+ f5 text,
+ f6 text,
+ f7 text,
+ f8 text,
+ f9 text,
+ f10 text,
+ f11 text,
+ f12 text,
+ f13 text,
+ f14 text,
+ f15 text,
+ f16 text,
+ f17 text,
+ f18 text,
+ f19 text,
+ f20 text
+)}
+do_test table-3.1 {
+ execsql $big_table
+ execsql {SELECT sql FROM sqlite_master WHERE type=='table'}
+} \{$big_table\}
+do_test table-3.2 {
+ set v [catch {execsql {CREATE TABLE BIG(xyz foo)}} msg]
+ lappend v $msg
+} {1 {table BIG already exists}}
+do_test table-3.3 {
+ set v [catch {execsql {CREATE TABLE biG(xyz foo)}} msg]
+ lappend v $msg
+} {1 {table biG already exists}}
+do_test table-3.4 {
+ set v [catch {execsql {CREATE TABLE bIg(xyz foo)}} msg]
+ lappend v $msg
+} {1 {table bIg already exists}}
+do_test table-3.5 {
+ db close
+ sqlite3 db test.db
+ set v [catch {execsql {CREATE TABLE Big(xyz foo)}} msg]
+ lappend v $msg
+} {1 {table Big already exists}}
+do_test table-3.6 {
+ execsql {DROP TABLE big}
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
+} {}
+
+# Try creating large numbers of tables
+#
+set r {}
+for {set i 1} {$i<=100} {incr i} {
+ lappend r [format test%03d $i]
+}
+do_test table-4.1 {
+ for {set i 1} {$i<=100} {incr i} {
+ set sql "CREATE TABLE [format test%03d $i] ("
+ for {set k 1} {$k<$i} {incr k} {
+ append sql "field$k text,"
+ }
+ append sql "last_field text)"
+ execsql $sql
+ }
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} $r
+do_test table-4.1b {
+ db close
+ sqlite3 db test.db
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} $r
+
+# Drop the even numbered tables
+#
+set r {}
+for {set i 1} {$i<=100} {incr i 2} {
+ lappend r [format test%03d $i]
+}
+do_test table-4.2 {
+ for {set i 2} {$i<=100} {incr i 2} {
+ # if {$i==38} {execsql {pragma vdbe_trace=on}}
+ set sql "DROP TABLE [format TEST%03d $i]"
+ execsql $sql
+ }
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} $r
+#exit
+
+# Drop the odd number tables
+#
+do_test table-4.3 {
+ for {set i 1} {$i<=100} {incr i 2} {
+ set sql "DROP TABLE [format test%03d $i]"
+ execsql $sql
+ }
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
+} {}
+
+# Try to drop a table that does not exist
+#
+do_test table-5.1.1 {
+ catchsql {DROP TABLE test009}
+} {1 {no such table: test009}}
+do_test table-5.1.2 {
+ catchsql {DROP TABLE IF EXISTS test009}
+} {0 {}}
+
+# Try to drop sqlite_master
+#
+do_test table-5.2 {
+ catchsql {DROP TABLE IF EXISTS sqlite_master}
+} {1 {table sqlite_master may not be dropped}}
+
+# Dropping sqlite_statN tables is OK.
+#
+do_test table-5.2.1 {
+ db eval {
+ ANALYZE;
+ DROP TABLE IF EXISTS sqlite_stat1;
+ DROP TABLE IF EXISTS sqlite_stat2;
+ DROP TABLE IF EXISTS sqlite_stat3;
+ SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_stat*';
+ }
+} {}
+
+# Make sure an EXPLAIN does not really create a new table
+#
+do_test table-5.3 {
+ ifcapable {explain} {
+ execsql {EXPLAIN CREATE TABLE test1(f1 int)}
+ }
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
+} {}
+
+# Make sure an EXPLAIN does not really drop an existing table
+#
+do_test table-5.4 {
+ execsql {CREATE TABLE test1(f1 int)}
+ ifcapable {explain} {
+ execsql {EXPLAIN DROP TABLE test1}
+ }
+ execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
+} {test1}
+
+# Create a table with a goofy name
+#
+#do_test table-6.1 {
+# execsql {CREATE TABLE 'Spaces In This Name!'(x int)}
+# execsql {INSERT INTO 'spaces in this name!' VALUES(1)}
+# set list [glob -nocomplain testdb/spaces*.tbl]
+#} {testdb/spaces+in+this+name+.tbl}
+
+# Try using keywords as table names or column names.
+#
+do_test table-7.1 {
+ set v [catch {execsql {
+ CREATE TABLE weird(
+ desc text,
+ asc text,
+ key int,
+ [14_vac] boolean,
+ fuzzy_dog_12 varchar(10),
+ begin blob,
+ end clob
+ )
+ }} msg]
+ lappend v $msg
+} {0 {}}
+do_test table-7.2 {
+ execsql {
+ INSERT INTO weird VALUES('a','b',9,0,'xyz','hi','y''all');
+ SELECT * FROM weird;
+ }
+} {a b 9 0 xyz hi y'all}
+do_test table-7.3 {
+ execsql2 {
+ SELECT * FROM weird;
+ }
+} {desc a asc b key 9 14_vac 0 fuzzy_dog_12 xyz begin hi end y'all}
+do_test table-7.3 {
+ execsql {
+ CREATE TABLE savepoint(release);
+ INSERT INTO savepoint(release) VALUES(10);
+ UPDATE savepoint SET release = 5;
+ SELECT release FROM savepoint;
+ }
+} {5}
+
+# Try out the CREATE TABLE AS syntax
+#
+do_test table-8.1 {
+ execsql2 {
+ CREATE TABLE t2 AS SELECT * FROM weird;
+ SELECT * FROM t2;
+ }
+} {desc a asc b key 9 14_vac 0 fuzzy_dog_12 xyz begin hi end y'all}
+do_test table-8.1.1 {
+ execsql {
+ SELECT sql FROM sqlite_master WHERE name='t2';
+ }
+} {{CREATE TABLE t2(
+ "desc" TEXT,
+ "asc" TEXT,
+ "key" INT,
+ "14_vac" NUM,
+ fuzzy_dog_12 TEXT,
+ "begin",
+ "end" TEXT
+)}}
+do_test table-8.2 {
+ execsql {
+ CREATE TABLE "t3""xyz"(a,b,c);
+ INSERT INTO [t3"xyz] VALUES(1,2,3);
+ SELECT * FROM [t3"xyz];
+ }
+} {1 2 3}
+do_test table-8.3 {
+ execsql2 {
+ CREATE TABLE [t4"abc] AS SELECT count(*) as cnt, max(b+c) FROM [t3"xyz];
+ SELECT * FROM [t4"abc];
+ }
+} {cnt 1 max(b+c) 5}
+
+# Update for v3: The declaration type of anything except a column is now a
+# NULL pointer, so the created table has no column types. (Changed result
+# from {{CREATE TABLE 't4"abc'(cnt NUMERIC,"max(b+c)" NUMERIC)}}).
+do_test table-8.3.1 {
+ execsql {
+ SELECT sql FROM sqlite_master WHERE name='t4"abc'
+ }
+} {{CREATE TABLE "t4""abc"(cnt,"max(b+c)")}}
+
+ifcapable tempdb {
+ do_test table-8.4 {
+ execsql2 {
+ CREATE TEMPORARY TABLE t5 AS SELECT count(*) AS [y'all] FROM [t3"xyz];
+ SELECT * FROM t5;
+ }
+ } {y'all 1}
+}
+
+do_test table-8.5 {
+ db close
+ sqlite3 db test.db
+ execsql2 {
+ SELECT * FROM [t4"abc];
+ }
+} {cnt 1 max(b+c) 5}
+do_test table-8.6 {
+ execsql2 {
+ SELECT * FROM t2;
+ }
+} {desc a asc b key 9 14_vac 0 fuzzy_dog_12 xyz begin hi end y'all}
+do_test table-8.7 {
+ catchsql {
+ SELECT * FROM t5;
+ }
+} {1 {no such table: t5}}
+do_test table-8.8 {
+ catchsql {
+ CREATE TABLE t5 AS SELECT * FROM no_such_table;
+ }
+} {1 {no such table: no_such_table}}
+
+do_test table-8.9 {
+ execsql {
+ CREATE TABLE t10("col.1" [char.3]);
+ CREATE TABLE t11 AS SELECT * FROM t10;
+ SELECT sql FROM sqlite_master WHERE name = 't11';
+ }
+} {{CREATE TABLE t11("col.1" TEXT)}}
+do_test table-8.10 {
+ execsql {
+ CREATE TABLE t12(
+ a INTEGER,
+ b VARCHAR(10),
+ c VARCHAR(1,10),
+ d VARCHAR(+1,-10),
+ e VARCHAR (+1,-10),
+ f "VARCHAR (+1,-10, 5)",
+ g BIG INTEGER
+ );
+ CREATE TABLE t13 AS SELECT * FROM t12;
+ SELECT sql FROM sqlite_master WHERE name = 't13';
+ }
+} {{CREATE TABLE t13(
+ a INT,
+ b TEXT,
+ c TEXT,
+ d TEXT,
+ e TEXT,
+ f TEXT,
+ g INT
+)}}
+
+# Make sure we cannot have duplicate column names within a table.
+#
+do_test table-9.1 {
+ catchsql {
+ CREATE TABLE t6(a,b,a);
+ }
+} {1 {duplicate column name: a}}
+do_test table-9.2 {
+ catchsql {
+ CREATE TABLE t6(a varchar(100), b blob, a integer);
+ }
+} {1 {duplicate column name: a}}
+
+# Check the foreign key syntax.
+#
+ifcapable {foreignkey} {
+do_test table-10.1 {
+ catchsql {
+ CREATE TABLE t6(a REFERENCES t4(a) NOT NULL);
+ INSERT INTO t6 VALUES(NULL);
+ }
+} {1 {t6.a may not be NULL}}
+do_test table-10.2 {
+ catchsql {
+ DROP TABLE t6;
+ CREATE TABLE t6(a REFERENCES t4(a) MATCH PARTIAL);
+ }
+} {0 {}}
+do_test table-10.3 {
+ catchsql {
+ DROP TABLE t6;
+ CREATE TABLE t6(a REFERENCES t4 MATCH FULL ON DELETE SET NULL NOT NULL);
+ }
+} {0 {}}
+do_test table-10.4 {
+ catchsql {
+ DROP TABLE t6;
+ CREATE TABLE t6(a REFERENCES t4 MATCH FULL ON UPDATE SET DEFAULT DEFAULT 1);
+ }
+} {0 {}}
+do_test table-10.5 {
+ catchsql {
+ DROP TABLE t6;
+ CREATE TABLE t6(a NOT NULL NOT DEFERRABLE INITIALLY IMMEDIATE);
+ }
+} {0 {}}
+do_test table-10.6 {
+ catchsql {
+ DROP TABLE t6;
+ CREATE TABLE t6(a NOT NULL DEFERRABLE INITIALLY DEFERRED);
+ }
+} {0 {}}
+do_test table-10.7 {
+ catchsql {
+ DROP TABLE t6;
+ CREATE TABLE t6(a,
+ FOREIGN KEY (a) REFERENCES t4(b) DEFERRABLE INITIALLY DEFERRED
+ );
+ }
+} {0 {}}
+do_test table-10.8 {
+ catchsql {
+ DROP TABLE t6;
+ CREATE TABLE t6(a,b,c,
+ FOREIGN KEY (b,c) REFERENCES t4(x,y) MATCH PARTIAL
+ ON UPDATE SET NULL ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
+ );
+ }
+} {0 {}}
+do_test table-10.9 {
+ catchsql {
+ DROP TABLE t6;
+ CREATE TABLE t6(a,b,c,
+ FOREIGN KEY (b,c) REFERENCES t4(x)
+ );
+ }
+} {1 {number of columns in foreign key does not match the number of columns in the referenced table}}
+do_test table-10.10 {
+ catchsql {DROP TABLE t6}
+ catchsql {
+ CREATE TABLE t6(a,b,c,
+ FOREIGN KEY (b,c) REFERENCES t4(x,y,z)
+ );
+ }
+} {1 {number of columns in foreign key does not match the number of columns in the referenced table}}
+do_test table-10.11 {
+ catchsql {DROP TABLE t6}
+ catchsql {
+ CREATE TABLE t6(a,b, c REFERENCES t4(x,y));
+ }
+} {1 {foreign key on c should reference only one column of table t4}}
+do_test table-10.12 {
+ catchsql {DROP TABLE t6}
+ catchsql {
+ CREATE TABLE t6(a,b,c,
+ FOREIGN KEY (b,x) REFERENCES t4(x,y)
+ );
+ }
+} {1 {unknown column "x" in foreign key definition}}
+do_test table-10.13 {
+ catchsql {DROP TABLE t6}
+ catchsql {
+ CREATE TABLE t6(a,b,c,
+ FOREIGN KEY (x,b) REFERENCES t4(x,y)
+ );
+ }
+} {1 {unknown column "x" in foreign key definition}}
+} ;# endif foreignkey
+
+# Test for the "typeof" function. More tests for the
+# typeof() function are found in bind.test and types.test.
+#
+do_test table-11.1 {
+ execsql {
+ CREATE TABLE t7(
+ a integer primary key,
+ b number(5,10),
+ c character varying (8),
+ d VARCHAR(9),
+ e clob,
+ f BLOB,
+ g Text,
+ h
+ );
+ INSERT INTO t7(a) VALUES(1);
+ SELECT typeof(a), typeof(b), typeof(c), typeof(d),
+ typeof(e), typeof(f), typeof(g), typeof(h)
+ FROM t7 LIMIT 1;
+ }
+} {integer null null null null null null null}
+do_test table-11.2 {
+ execsql {
+ SELECT typeof(a+b), typeof(a||b), typeof(c+d), typeof(c||d)
+ FROM t7 LIMIT 1;
+ }
+} {null null null null}
+
+# Test that when creating a table using CREATE TABLE AS, column types are
+# assigned correctly for (SELECT ...) and 'x AS y' expressions.
+do_test table-12.1 {
+ ifcapable subquery {
+ execsql {
+ CREATE TABLE t8 AS SELECT b, h, a as i, (SELECT f FROM t7) as j FROM t7;
+ }
+ } else {
+ execsql {
+ CREATE TABLE t8 AS SELECT b, h, a as i, f as j FROM t7;
+ }
+ }
+} {}
+do_test table-12.2 {
+ execsql {
+ SELECT sql FROM sqlite_master WHERE tbl_name = 't8'
+ }
+} {{CREATE TABLE t8(b NUM,h,i INT,j)}}
+
+#--------------------------------------------------------------------
+# Test cases table-13.*
+#
+# Test the ability to have default values of CURRENT_TIME, CURRENT_DATE
+# and CURRENT_TIMESTAMP.
+#
+do_test table-13.1 {
+ execsql {
+ CREATE TABLE tablet8(
+ a integer primary key,
+ tm text DEFAULT CURRENT_TIME,
+ dt text DEFAULT CURRENT_DATE,
+ dttm text DEFAULT CURRENT_TIMESTAMP
+ );
+ SELECT * FROM tablet8;
+ }
+} {}
+set i 0
+unset -nocomplain date time seconds
+foreach {date time seconds} {
+ 1976-07-04 12:00:00 205329600
+ 1994-04-16 14:00:00 766504800
+ 2000-01-01 00:00:00 946684800
+ 2003-12-31 12:34:56 1072874096
+} {
+ incr i
+ set sqlite_current_time $seconds
+ do_test table-13.2.$i {
+ execsql "
+ INSERT INTO tablet8(a) VALUES($i);
+ SELECT tm, dt, dttm FROM tablet8 WHERE a=$i;
+ "
+ } [list $time $date [list $date $time]]
+}
+set sqlite_current_time 0
+
+#--------------------------------------------------------------------
+# Test cases table-14.*
+#
+# Test that a table cannot be created or dropped while other virtual
+# machines are active. This is required because otherwise when in
+# auto-vacuum mode the btree-layer may need to move the root-pages of
+# a table for which there is an open cursor.
+#
+# 2007-05-02: A open btree cursor no longer blocks CREATE TABLE.
+# But DROP TABLE is still prohibited because we do not want to
+# delete a table out from under a running query.
+#
+
+# db eval {
+# pragma vdbe_trace = 0;
+# }
+# Try to create a table from within a callback:
+unset -nocomplain result
+do_test table-14.1 {
+ set rc [
+ catch {
+ db eval {SELECT * FROM tablet8 LIMIT 1} {} {
+ db eval {CREATE TABLE t9(a, b, c)}
+ }
+ } msg
+ ]
+ set result [list $rc $msg]
+} {0 {}}
+
+# Try to drop a table from within a callback:
+do_test table-14.2 {
+ set rc [
+ catch {
+ db eval {SELECT * FROM tablet8 LIMIT 1} {} {
+ db eval {DROP TABLE t9;}
+ }
+ } msg
+ ]
+ set result [list $rc $msg]
+} {1 {database table is locked}}
+
+ifcapable attach {
+ # Now attach a database and ensure that a table can be created in the
+ # attached database whilst in a callback from a query on the main database.
+ do_test table-14.3 {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ execsql {
+ ATTACH 'test2.db' as aux;
+ }
+ db eval {SELECT * FROM tablet8 LIMIT 1} {} {
+ db eval {CREATE TABLE aux.t1(a, b, c)}
+ }
+ } {}
+
+ # On the other hand, it should be impossible to drop a table when any VMs
+ # are active. This is because VerifyCookie instructions may have already
+ # been executed, and btree root-pages may not move after this (which a
+ # delete table might do).
+ do_test table-14.4 {
+ set rc [
+ catch {
+ db eval {SELECT * FROM tablet8 LIMIT 1} {} {
+ db eval {DROP TABLE aux.t1;}
+ }
+ } msg
+ ]
+ set result [list $rc $msg]
+ } {1 {database table is locked}}
+}
+
+# Create and drop 2000 tables. This is to check that the balance_shallow()
+# routine works correctly on the sqlite_master table. At one point it
+# contained a bug that would prevent the right-child pointer of the
+# child page from being copied to the root page.
+#
+do_test table-15.1 {
+ execsql {BEGIN}
+ for {set i 0} {$i<2000} {incr i} {
+ execsql "CREATE TABLE tbl$i (a, b, c)"
+ }
+ execsql {COMMIT}
+} {}
+do_test table-15.2 {
+ execsql {BEGIN}
+ for {set i 0} {$i<2000} {incr i} {
+ execsql "DROP TABLE tbl$i"
+ }
+ execsql {COMMIT}
+} {}
+
+finish_test
diff --git a/test/tableapi.test b/test/tableapi.test
new file mode 100644
index 0000000..122267f
--- /dev/null
+++ b/test/tableapi.test
@@ -0,0 +1,256 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the sqlite_exec_printf() and
+# sqlite_get_table_printf() APIs.
+#
+# $Id: tableapi.test,v 1.21 2009/07/17 14:37:25 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !gettable {
+ finish_test
+ return
+}
+
+ifcapable memdebug {
+ source $testdir/malloc_common.tcl
+}
+
+do_test tableapi-1.0 {
+ set ::dbx [sqlite3_open test.db]
+ catch {sqlite_exec_printf $::dbx {DROP TABLE xyz} {}}
+ sqlite3_exec_printf $::dbx {CREATE TABLE %s(a int, b text)} xyz
+} {0 {}}
+do_test tableapi-1.1 {
+ sqlite3_exec_printf $::dbx {
+ INSERT INTO xyz VALUES(1,'%q')
+ } {Hi Y'all}
+} {0 {}}
+do_test tableapi-1.2 {
+ sqlite3_exec_printf $::dbx {SELECT * FROM xyz} {}
+} {0 {a b 1 {Hi Y'all}}}
+
+do_test tableapi-2.1 {
+ sqlite3_get_table_printf $::dbx {
+ BEGIN TRANSACTION;
+ SELECT * FROM xyz WHERE b='%q'
+ } {Hi Y'all}
+} {0 1 2 a b 1 {Hi Y'all}}
+do_test tableapi-2.2 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz
+ } {}
+} {0 1 2 a b 1 {Hi Y'all}}
+do_test tableapi-2.3 {
+ for {set i 2} {$i<=50} {incr i} {
+ sqlite3_get_table_printf $::dbx \
+ "INSERT INTO xyz VALUES($i,'(%s)')" $i
+ }
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz ORDER BY a
+ } {}
+} {0 50 2 a b 1 {Hi Y'all} 2 (2) 3 (3) 4 (4) 5 (5) 6 (6) 7 (7) 8 (8) 9 (9) 10 (10) 11 (11) 12 (12) 13 (13) 14 (14) 15 (15) 16 (16) 17 (17) 18 (18) 19 (19) 20 (20) 21 (21) 22 (22) 23 (23) 24 (24) 25 (25) 26 (26) 27 (27) 28 (28) 29 (29) 30 (30) 31 (31) 32 (32) 33 (33) 34 (34) 35 (35) 36 (36) 37 (37) 38 (38) 39 (39) 40 (40) 41 (41) 42 (42) 43 (43) 44 (44) 45 (45) 46 (46) 47 (47) 48 (48) 49 (49) 50 (50)}
+do_test tableapi-2.3.1 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a>49 ORDER BY a
+ } {}
+} {0 1 2 a b 50 (50)}
+do_test tableapi-2.3.2 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a>47 ORDER BY a
+ } {}
+} {0 3 2 a b 48 (48) 49 (49) 50 (50)}
+do_test tableapi-2.3.3 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a>47 ORDER BY a; invalid
+ } {}
+} {1 {near "invalid": syntax error}}
+do_test tableapi-2.3.4 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a>47 ORDER BY a
+ } {} 8
+} {0 a b 48 (48) 49 (49) 50 (50)}
+do_test tableapi-2.4 {
+ set manyquote ''''''''
+ append manyquote $manyquote
+ append manyquote $manyquote
+ append manyquote $manyquote
+ append manyquote $manyquote
+ append manyquote $manyquote
+ append manyquote $manyquote
+ set ::big_str "$manyquote Hello $manyquote"
+ sqlite3_get_table_printf $::dbx {
+ INSERT INTO xyz VALUES(51,'%q')
+ } $::big_str
+} {0 0 0}
+do_test tableapi-2.5 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a>49 ORDER BY a;
+ } {}
+} "0 2 2 a b 50 (50) 51 \173$::big_str\175"
+do_test tableapi-2.6 {
+ sqlite3_get_table_printf $::dbx {
+ INSERT INTO xyz VALUES(52,NULL)
+ } {}
+ ifcapable subquery {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a IN (42,50,52) ORDER BY a DESC
+ } {}
+ } else {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a=42 OR a=50 OR a=52 ORDER BY a DESC
+ } {}
+ }
+} {0 3 2 a b 52 NULL 50 (50) 42 (42)}
+do_test tableapi-2.7 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a>1000
+ } {}
+} {0 0 0}
+
+# Repeat all tests with the empty_result_callbacks pragma turned on
+#
+do_test tableapi-3.1 {
+ sqlite3_get_table_printf $::dbx {
+ ROLLBACK;
+ PRAGMA empty_result_callbacks = ON;
+ SELECT * FROM xyz WHERE b='%q'
+ } {Hi Y'all}
+} {0 1 2 a b 1 {Hi Y'all}}
+do_test tableapi-3.2 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz
+ } {}
+} {0 1 2 a b 1 {Hi Y'all}}
+do_test tableapi-3.3 {
+ for {set i 2} {$i<=50} {incr i} {
+ sqlite3_get_table_printf $::dbx \
+ "INSERT INTO xyz VALUES($i,'(%s)')" $i
+ }
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz ORDER BY a
+ } {}
+} {0 50 2 a b 1 {Hi Y'all} 2 (2) 3 (3) 4 (4) 5 (5) 6 (6) 7 (7) 8 (8) 9 (9) 10 (10) 11 (11) 12 (12) 13 (13) 14 (14) 15 (15) 16 (16) 17 (17) 18 (18) 19 (19) 20 (20) 21 (21) 22 (22) 23 (23) 24 (24) 25 (25) 26 (26) 27 (27) 28 (28) 29 (29) 30 (30) 31 (31) 32 (32) 33 (33) 34 (34) 35 (35) 36 (36) 37 (37) 38 (38) 39 (39) 40 (40) 41 (41) 42 (42) 43 (43) 44 (44) 45 (45) 46 (46) 47 (47) 48 (48) 49 (49) 50 (50)}
+do_test tableapi-3.3.1 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a>49 ORDER BY a
+ } {}
+} {0 1 2 a b 50 (50)}
+do_test tableapi-3.3.2 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a>47 ORDER BY a
+ } {}
+} {0 3 2 a b 48 (48) 49 (49) 50 (50)}
+do_test tableapi-3.4 {
+ sqlite3_get_table_printf $::dbx {
+ INSERT INTO xyz VALUES(51,'%q')
+ } $::big_str
+} {0 0 0}
+do_test tableapi-3.5 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a>49 ORDER BY a;
+ } {}
+} "0 2 2 a b 50 (50) 51 \173$::big_str\175"
+do_test tableapi-3.6 {
+ sqlite3_get_table_printf $::dbx {
+ INSERT INTO xyz VALUES(52,NULL)
+ } {}
+ ifcapable subquery {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a IN (42,50,52) ORDER BY a DESC
+ } {}
+ } else {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a=42 OR a=50 OR a=52 ORDER BY a DESC
+ } {}
+ }
+} {0 3 2 a b 52 NULL 50 (50) 42 (42)}
+do_test tableapi-3.7 {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz WHERE a>1000
+ } {}
+} {0 0 2 a b}
+
+do_test tableapi-4.1 {
+ set rc [catch {
+ sqlite3_get_table_printf $::dbx {
+ SELECT * FROM xyz; SELECT * FROM sqlite_master
+ } {}
+ } msg]
+ concat $rc $msg
+} {0 1 {sqlite3_get_table() called with two or more incompatible queries}}
+
+# A report on the mailing list says that the sqlite_get_table() api fails
+# on queries involving more than 40 columns. The following code attempts
+# to test that complaint
+#
+do_test tableapi-5.1 {
+ set sql "CREATE TABLE t2("
+ set sep ""
+ for {set i 1} {$i<=100} {incr i} {
+ append sql ${sep}x$i
+ set sep ,
+ }
+ append sql )
+ sqlite3_get_table_printf $::dbx $sql {}
+ set sql "INSERT INTO t2 VALUES("
+ set sep ""
+ for {set i 1} {$i<=100} {incr i} {
+ append sql ${sep}$i
+ set sep ,
+ }
+ append sql )
+ sqlite3_get_table_printf $::dbx $sql {}
+ sqlite3_get_table_printf $::dbx {SELECT * FROM t2} {}
+} {0 1 100 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41 x42 x43 x44 x45 x46 x47 x48 x49 x50 x51 x52 x53 x54 x55 x56 x57 x58 x59 x60 x61 x62 x63 x64 x65 x66 x67 x68 x69 x70 x71 x72 x73 x74 x75 x76 x77 x78 x79 x80 x81 x82 x83 x84 x85 x86 x87 x88 x89 x90 x91 x92 x93 x94 x95 x96 x97 x98 x99 x100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100}
+do_test tableapi-5.2 {
+ set sql "INSERT INTO t2 VALUES("
+ set sep ""
+ for {set i 1} {$i<=100} {incr i} {
+ append sql ${sep}[expr {$i+1000}]
+ set sep ,
+ }
+ append sql )
+ sqlite3_get_table_printf $::dbx $sql {}
+ sqlite3_get_table_printf $::dbx {SELECT * FROM t2} {}
+} {0 2 100 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41 x42 x43 x44 x45 x46 x47 x48 x49 x50 x51 x52 x53 x54 x55 x56 x57 x58 x59 x60 x61 x62 x63 x64 x65 x66 x67 x68 x69 x70 x71 x72 x73 x74 x75 x76 x77 x78 x79 x80 x81 x82 x83 x84 x85 x86 x87 x88 x89 x90 x91 x92 x93 x94 x95 x96 x97 x98 x99 x100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100}
+
+ifcapable schema_pragmas {
+ do_test tableapi-6.1 {
+ sqlite3_get_table_printf $::dbx {PRAGMA user_version} {}
+ } {0 1 1 user_version 0}
+}
+
+# do_malloc_test closes and deletes the usual db connections and files on
+# each iteration. $::dbx is a seperate connection, and on Windows, will
+# cause the file deletion of test.db to fail, so we move the close of $::dbx
+# up to here before the do_malloc_test.
+do_test tableapi-99.0 {
+ sqlite3_close $::dbx
+} {SQLITE_OK}
+
+ifcapable memdebug {
+ do_malloc_test tableapi-7 -sqlprep {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ INSERT INTO t1 SELECT a+4, b+4 FROM t1;
+ INSERT INTO t1 SELECT a+8, b+8 FROM t1;
+ } -tclbody {
+ set r [sqlite3_get_table_printf db {SELECT rowid, a, b FROM t1} {}]
+ if {[llength $r]<26} {error "out of memory"}
+ }
+}
+
+finish_test
diff --git a/test/tclsqlite.test b/test/tclsqlite.test
new file mode 100644
index 0000000..0ed0602
--- /dev/null
+++ b/test/tclsqlite.test
@@ -0,0 +1,632 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for TCL interface to the
+# SQLite library.
+#
+# Actually, all tests are based on the TCL interface, so the main
+# interface is pretty well tested. This file contains some addition
+# tests for fringe issues that the main test suite does not cover.
+#
+# $Id: tclsqlite.test,v 1.73 2009/03/16 13:19:36 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Check the error messages generated by tclsqlite
+#
+if {[sqlite3 -has-codec]} {
+ set r "sqlite_orig HANDLE FILENAME ?-key CODEC-KEY?"
+} else {
+ set r "sqlite_orig HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN?"
+}
+do_test tcl-1.1 {
+ set v [catch {sqlite3 bogus} msg]
+ regsub {really_sqlite3} $msg {sqlite3} msg
+ lappend v $msg
+} [list 1 "wrong # args: should be \"$r\""]
+do_test tcl-1.2 {
+ set v [catch {db bogus} msg]
+ lappend v $msg
+} {1 {bad option "bogus": must be authorizer, backup, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, copy, enable_load_extension, errorcode, eval, exists, function, incrblob, interrupt, last_insert_rowid, nullvalue, onecolumn, profile, progress, rekey, restore, rollback_hook, status, timeout, total_changes, trace, transaction, unlock_notify, update_hook, version, or wal_hook}}
+do_test tcl-1.2.1 {
+ set v [catch {db cache bogus} msg]
+ lappend v $msg
+} {1 {bad option "bogus": must be flush or size}}
+do_test tcl-1.2.2 {
+ set v [catch {db cache} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db cache option ?arg?"}}
+do_test tcl-1.3 {
+ execsql {CREATE TABLE t1(a int, b int)}
+ execsql {INSERT INTO t1 VALUES(10,20)}
+ set v [catch {
+ db eval {SELECT * FROM t1} data {
+ error "The error message"
+ }
+ } msg]
+ lappend v $msg
+} {1 {The error message}}
+do_test tcl-1.4 {
+ set v [catch {
+ db eval {SELECT * FROM t2} data {
+ error "The error message"
+ }
+ } msg]
+ lappend v $msg
+} {1 {no such table: t2}}
+do_test tcl-1.5 {
+ set v [catch {
+ db eval {SELECT * FROM t1} data {
+ break
+ }
+ } msg]
+ lappend v $msg
+} {0 {}}
+catch {expr x*} msg
+do_test tcl-1.6 {
+ set v [catch {
+ db eval {SELECT * FROM t1} data {
+ expr x*
+ }
+ } msg]
+ lappend v $msg
+} [list 1 $msg]
+do_test tcl-1.7 {
+ set v [catch {db} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db SUBCOMMAND ..."}}
+if {[catch {db auth {}}]==0} {
+ do_test tcl-1.8 {
+ set v [catch {db authorizer 1 2 3} msg]
+ lappend v $msg
+ } {1 {wrong # args: should be "db authorizer ?CALLBACK?"}}
+}
+do_test tcl-1.9 {
+ set v [catch {db busy 1 2 3} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db busy CALLBACK"}}
+do_test tcl-1.10 {
+ set v [catch {db progress 1} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db progress N CALLBACK"}}
+do_test tcl-1.11 {
+ set v [catch {db changes xyz} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db changes "}}
+do_test tcl-1.12 {
+ set v [catch {db commit_hook a b c} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db commit_hook ?CALLBACK?"}}
+ifcapable {complete} {
+ do_test tcl-1.13 {
+ set v [catch {db complete} msg]
+ lappend v $msg
+ } {1 {wrong # args: should be "db complete SQL"}}
+}
+do_test tcl-1.14 {
+ set v [catch {db eval} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db eval SQL ?ARRAY-NAME? ?SCRIPT?"}}
+do_test tcl-1.15 {
+ set v [catch {db function} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db function NAME [-argcount N] SCRIPT"}}
+do_test tcl-1.16 {
+ set v [catch {db last_insert_rowid xyz} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db last_insert_rowid "}}
+do_test tcl-1.17 {
+ set v [catch {db rekey} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db rekey KEY"}}
+do_test tcl-1.18 {
+ set v [catch {db timeout} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db timeout MILLISECONDS"}}
+do_test tcl-1.19 {
+ set v [catch {db collate} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db collate NAME SCRIPT"}}
+do_test tcl-1.20 {
+ set v [catch {db collation_needed} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db collation_needed SCRIPT"}}
+do_test tcl-1.21 {
+ set v [catch {db total_changes xyz} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db total_changes "}}
+do_test tcl-1.20 {
+ set v [catch {db copy} msg]
+ lappend v $msg
+} {1 {wrong # args: should be "db copy CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?"}}
+do_test tcl-1.21 {
+ set v [catch {sqlite3 db2 test.db -vfs nosuchvfs} msg]
+ lappend v $msg
+} {1 {no such vfs: nosuchvfs}}
+
+catch {unset ::result}
+do_test tcl-2.1 {
+ execsql "CREATE TABLE t\u0123x(a int, b\u1235 float)"
+} {}
+ifcapable schema_pragmas {
+ do_test tcl-2.2 {
+ execsql "PRAGMA table_info(t\u0123x)"
+ } "0 a int 0 {} 0 1 b\u1235 float 0 {} 0"
+}
+do_test tcl-2.3 {
+ execsql "INSERT INTO t\u0123x VALUES(1,2.3)"
+ db eval "SELECT * FROM t\u0123x" result break
+ set result(*)
+} "a b\u1235"
+
+
+# Test the onecolumn method
+#
+do_test tcl-3.1 {
+ execsql {
+ INSERT INTO t1 SELECT a*2, b*2 FROM t1;
+ INSERT INTO t1 SELECT a*2+1, b*2+1 FROM t1;
+ INSERT INTO t1 SELECT a*2+3, b*2+3 FROM t1;
+ }
+ set rc [catch {db onecolumn {SELECT * FROM t1 ORDER BY a}} msg]
+ lappend rc $msg
+} {0 10}
+do_test tcl-3.2 {
+ db onecolumn {SELECT * FROM t1 WHERE a<0}
+} {}
+do_test tcl-3.3 {
+ set rc [catch {db onecolumn} errmsg]
+ lappend rc $errmsg
+} {1 {wrong # args: should be "db onecolumn SQL"}}
+do_test tcl-3.4 {
+ set rc [catch {db onecolumn {SELECT bogus}} errmsg]
+ lappend rc $errmsg
+} {1 {no such column: bogus}}
+ifcapable {tclvar} {
+ do_test tcl-3.5 {
+ set b 50
+ set rc [catch {db one {SELECT * FROM t1 WHERE b>$b}} msg]
+ lappend rc $msg
+ } {0 41}
+ do_test tcl-3.6 {
+ set b 500
+ set rc [catch {db one {SELECT * FROM t1 WHERE b>$b}} msg]
+ lappend rc $msg
+ } {0 {}}
+ do_test tcl-3.7 {
+ set b 500
+ set rc [catch {db one {
+ INSERT INTO t1 VALUES(99,510);
+ SELECT * FROM t1 WHERE b>$b
+ }} msg]
+ lappend rc $msg
+ } {0 99}
+}
+ifcapable {!tclvar} {
+ execsql {INSERT INTO t1 VALUES(99,510)}
+}
+
+# Turn the busy handler on and off
+#
+do_test tcl-4.1 {
+ proc busy_callback {cnt} {
+ break
+ }
+ db busy busy_callback
+ db busy
+} {busy_callback}
+do_test tcl-4.2 {
+ db busy {}
+ db busy
+} {}
+
+ifcapable {tclvar} {
+ # Parsing of TCL variable names within SQL into bound parameters.
+ #
+ do_test tcl-5.1 {
+ execsql {CREATE TABLE t3(a,b,c)}
+ catch {unset x}
+ set x(1) A
+ set x(2) B
+ execsql {
+ INSERT INTO t3 VALUES($::x(1),$::x(2),$::x(3));
+ SELECT * FROM t3
+ }
+ } {A B {}}
+ do_test tcl-5.2 {
+ execsql {
+ SELECT typeof(a), typeof(b), typeof(c) FROM t3
+ }
+ } {text text null}
+ do_test tcl-5.3 {
+ catch {unset x}
+ set x [binary format h12 686900686f00]
+ execsql {
+ UPDATE t3 SET a=$::x;
+ }
+ db eval {
+ SELECT a FROM t3
+ } break
+ binary scan $a h12 adata
+ set adata
+ } {686900686f00}
+ do_test tcl-5.4 {
+ execsql {
+ SELECT typeof(a), typeof(b), typeof(c) FROM t3
+ }
+ } {blob text null}
+}
+
+# Operation of "break" and "continue" within row scripts
+#
+do_test tcl-6.1 {
+ db eval {SELECT * FROM t1} {
+ break
+ }
+ lappend a $b
+} {10 20}
+do_test tcl-6.2 {
+ set cnt 0
+ db eval {SELECT * FROM t1} {
+ if {$a>40} continue
+ incr cnt
+ }
+ set cnt
+} {4}
+do_test tcl-6.3 {
+ set cnt 0
+ db eval {SELECT * FROM t1} {
+ if {$a<40} continue
+ incr cnt
+ }
+ set cnt
+} {5}
+do_test tcl-6.4 {
+ proc return_test {x} {
+ db eval {SELECT * FROM t1} {
+ if {$a==$x} {return $b}
+ }
+ }
+ return_test 10
+} 20
+do_test tcl-6.5 {
+ return_test 20
+} 40
+do_test tcl-6.6 {
+ return_test 99
+} 510
+do_test tcl-6.7 {
+ return_test 0
+} {}
+
+do_test tcl-7.1 {
+ db version
+ expr 0
+} {0}
+
+# modify and reset the NULL representation
+#
+do_test tcl-8.1 {
+ db nullvalue NaN
+ execsql {INSERT INTO t1 VALUES(30,NULL)}
+ db eval {SELECT * FROM t1 WHERE b IS NULL}
+} {30 NaN}
+do_test tcl-8.2 {
+ db nullvalue NULL
+ db nullvalue
+} {NULL}
+do_test tcl-8.3 {
+ db nullvalue {}
+ db eval {SELECT * FROM t1 WHERE b IS NULL}
+} {30 {}}
+
+# Test the return type of user-defined functions
+#
+do_test tcl-9.1 {
+ db function ret_str {return "hi"}
+ execsql {SELECT typeof(ret_str())}
+} {text}
+do_test tcl-9.2 {
+ db function ret_dbl {return [expr {rand()*0.5}]}
+ execsql {SELECT typeof(ret_dbl())}
+} {real}
+do_test tcl-9.3 {
+ db function ret_int {return [expr {int(rand()*200)}]}
+ execsql {SELECT typeof(ret_int())}
+} {integer}
+
+# Recursive calls to the same user-defined function
+#
+ifcapable tclvar {
+ do_test tcl-9.10 {
+ proc userfunc_r1 {n} {
+ if {$n<=0} {return 0}
+ set nm1 [expr {$n-1}]
+ return [expr {[db eval {SELECT r1($nm1)}]+$n}]
+ }
+ db function r1 userfunc_r1
+ execsql {SELECT r1(10)}
+ } {55}
+ do_test tcl-9.11 {
+ execsql {SELECT r1(100)}
+ } {5050}
+}
+
+# Tests for the new transaction method
+#
+do_test tcl-10.1 {
+ db transaction {}
+} {}
+do_test tcl-10.2 {
+ db transaction deferred {}
+} {}
+do_test tcl-10.3 {
+ db transaction immediate {}
+} {}
+do_test tcl-10.4 {
+ db transaction exclusive {}
+} {}
+do_test tcl-10.5 {
+ set rc [catch {db transaction xyzzy {}} msg]
+ lappend rc $msg
+} {1 {bad transaction type "xyzzy": must be deferred, exclusive, or immediate}}
+do_test tcl-10.6 {
+ set rc [catch {db transaction {error test-error}} msg]
+ lappend rc $msg
+} {1 test-error}
+do_test tcl-10.7 {
+ db transaction {
+ db eval {CREATE TABLE t4(x)}
+ db transaction {
+ db eval {INSERT INTO t4 VALUES(1)}
+ }
+ }
+ db eval {SELECT * FROM t4}
+} 1
+do_test tcl-10.8 {
+ catch {
+ db transaction {
+ db eval {INSERT INTO t4 VALUES(2)}
+ db eval {INSERT INTO t4 VALUES(3)}
+ db eval {INSERT INTO t4 VALUES(4)}
+ error test-error
+ }
+ }
+ db eval {SELECT * FROM t4}
+} 1
+do_test tcl-10.9 {
+ db transaction {
+ db eval {INSERT INTO t4 VALUES(2)}
+ catch {
+ db transaction {
+ db eval {INSERT INTO t4 VALUES(3)}
+ db eval {INSERT INTO t4 VALUES(4)}
+ error test-error
+ }
+ }
+ }
+ db eval {SELECT * FROM t4}
+} {1 2}
+do_test tcl-10.10 {
+ for {set i 0} {$i<1} {incr i} {
+ db transaction {
+ db eval {INSERT INTO t4 VALUES(5)}
+ continue
+ }
+ error "This line should not be run"
+ }
+ db eval {SELECT * FROM t4}
+} {1 2 5}
+do_test tcl-10.11 {
+ for {set i 0} {$i<10} {incr i} {
+ db transaction {
+ db eval {INSERT INTO t4 VALUES(6)}
+ break
+ }
+ }
+ db eval {SELECT * FROM t4}
+} {1 2 5 6}
+do_test tcl-10.12 {
+ set rc [catch {
+ for {set i 0} {$i<10} {incr i} {
+ db transaction {
+ db eval {INSERT INTO t4 VALUES(7)}
+ return
+ }
+ }
+ }]
+} {2}
+do_test tcl-10.13 {
+ db eval {SELECT * FROM t4}
+} {1 2 5 6 7}
+
+# Now test that [db transaction] commands may be nested with
+# the expected results.
+#
+do_test tcl-10.14 {
+ db transaction {
+ db eval {
+ DELETE FROM t4;
+ INSERT INTO t4 VALUES('one');
+ }
+
+ catch {
+ db transaction {
+ db eval { INSERT INTO t4 VALUES('two') }
+ db transaction {
+ db eval { INSERT INTO t4 VALUES('three') }
+ error "throw an error!"
+ }
+ }
+ }
+ }
+
+ db eval {SELECT * FROM t4}
+} {one}
+do_test tcl-10.15 {
+ # Make sure a transaction has not been left open.
+ db eval {BEGIN ; COMMIT}
+} {}
+do_test tcl-10.16 {
+ db transaction {
+ db eval { INSERT INTO t4 VALUES('two'); }
+ db transaction {
+ db eval { INSERT INTO t4 VALUES('three') }
+ db transaction {
+ db eval { INSERT INTO t4 VALUES('four') }
+ }
+ }
+ }
+ db eval {SELECT * FROM t4}
+} {one two three four}
+do_test tcl-10.17 {
+ catch {
+ db transaction {
+ db eval { INSERT INTO t4 VALUES('A'); }
+ db transaction {
+ db eval { INSERT INTO t4 VALUES('B') }
+ db transaction {
+ db eval { INSERT INTO t4 VALUES('C') }
+ error "throw an error!"
+ }
+ }
+ }
+ }
+ db eval {SELECT * FROM t4}
+} {one two three four}
+do_test tcl-10.18 {
+ # Make sure a transaction has not been left open.
+ db eval {BEGIN ; COMMIT}
+} {}
+
+# Mess up a [db transaction] command by locking the database using a
+# second connection when it tries to commit. Make sure the transaction
+# is not still open after the "database is locked" exception is thrown.
+#
+do_test tcl-10.18 {
+ sqlite3 db2 test.db
+ db2 eval {
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ }
+
+ set rc [catch {
+ db transaction {
+ db eval {INSERT INTO t4 VALUES('five')}
+ }
+ } msg]
+ list $rc $msg
+} {1 {database is locked}}
+do_test tcl-10.19 {
+ db eval {BEGIN ; COMMIT}
+} {}
+
+# Thwart a [db transaction] command by locking the database using a
+# second connection with "BEGIN EXCLUSIVE". Make sure no transaction is
+# open after the "database is locked" exception is thrown.
+#
+do_test tcl-10.20 {
+ db2 eval {
+ COMMIT;
+ BEGIN EXCLUSIVE;
+ }
+ set rc [catch {
+ db transaction {
+ db eval {INSERT INTO t4 VALUES('five')}
+ }
+ } msg]
+ list $rc $msg
+} {1 {database is locked}}
+do_test tcl-10.21 {
+ db2 close
+ db eval {BEGIN ; COMMIT}
+} {}
+do_test tcl-10.22 {
+ sqlite3 db2 test.db
+ db transaction exclusive {
+ catch { db2 eval {SELECT * FROM sqlite_master} } msg
+ set msg "db2: $msg"
+ }
+ set msg
+} {db2: database is locked}
+db2 close
+
+do_test tcl-11.1 {
+ db eval {INSERT INTO t4 VALUES(6)}
+ db exists {SELECT x,x*2,x+x FROM t4 WHERE x==6}
+} {1}
+do_test tcl-11.2 {
+ db exists {SELECT 0 FROM t4 WHERE x==6}
+} {1}
+do_test tcl-11.3 {
+ db exists {SELECT 1 FROM t4 WHERE x==8}
+} {0}
+do_test tcl-11.3.1 {
+ tcl_objproc db exists {SELECT 1 FROM t4 WHERE x==8}
+} {0}
+
+do_test tcl-12.1 {
+ unset -nocomplain a b c version
+ set version [db version]
+ scan $version "%d.%d.%d" a b c
+ expr $a*1000000 + $b*1000 + $c
+} [sqlite3_libversion_number]
+
+
+# Check to see that when bindings of the form @aaa are used instead
+# of $aaa, that objects are treated as bytearray and are inserted
+# as BLOBs.
+#
+ifcapable tclvar {
+ do_test tcl-13.1 {
+ db eval {CREATE TABLE t5(x BLOB)}
+ set x abc123
+ db eval {INSERT INTO t5 VALUES($x)}
+ db eval {SELECT typeof(x) FROM t5}
+ } {text}
+ do_test tcl-13.2 {
+ binary scan $x H notUsed
+ db eval {
+ DELETE FROM t5;
+ INSERT INTO t5 VALUES($x);
+ SELECT typeof(x) FROM t5;
+ }
+ } {text}
+ do_test tcl-13.3 {
+ db eval {
+ DELETE FROM t5;
+ INSERT INTO t5 VALUES(@x);
+ SELECT typeof(x) FROM t5;
+ }
+ } {blob}
+ do_test tcl-13.4 {
+ set y 1234
+ db eval {
+ DELETE FROM t5;
+ INSERT INTO t5 VALUES(@y);
+ SELECT hex(x), typeof(x) FROM t5
+ }
+ } {31323334 blob}
+}
+
+db func xCall xCall
+proc xCall {} { return "value" }
+do_execsql_test tcl-14.1 {
+ CREATE TABLE t6(x);
+ INSERT INTO t6 VALUES(1);
+}
+do_test tcl-14.2 {
+ db one {SELECT x FROM t6 WHERE xCall()!='value'}
+} {}
+
+
+
+finish_test
diff --git a/test/tempdb.test b/test/tempdb.test
new file mode 100644
index 0000000..ecd23d4
--- /dev/null
+++ b/test/tempdb.test
@@ -0,0 +1,93 @@
+# 2008 April 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+# The focus of this file is in making sure that rolling back
+# a statement journal works correctly.
+#
+# $Id: tempdb.test,v 1.4 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Use a temporary database.
+#
+db close
+sqlite3 db {}
+
+# Force a statement journal rollback on a database file that
+# has never been opened.
+#
+do_test tempdb-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(x UNIQUE);
+ CREATE TABLE t2(y);
+ INSERT INTO t2 VALUES('hello');
+ INSERT INTO t2 VALUES(NULL);
+ }
+ # Because of the transaction, the temporary database file
+ # has not even been opened yet. The following statement
+ # will cause a statement journal rollback on this non-existant
+ # file.
+ catchsql {
+ INSERT INTO t1
+ SELECT CASE WHEN y IS NULL THEN test_error('oops', 11) ELSE y END
+ FROM t2;
+ }
+} {1 oops}
+
+# Verify that no writes occurred in t1.
+#
+do_test tempdb-1.2 {
+ execsql {
+ SELECT * FROM t1
+ }
+} {}
+
+do_test tempdb-2.1 {
+ # Set $::jrnl_in_memory if the journal file is expected to be in-memory.
+ # Similarly, set $::subj_in_memory if the sub-journal file is expected
+ # to be in memory. These variables are used to calculate the expected
+ # number of open files in the test cases below.
+ #
+ set jrnl_in_memory [expr {[permutation] eq "inmemory_journal"}]
+ set subj_in_memory [expr {$jrnl_in_memory || $TEMP_STORE>=2}]
+
+ db close
+ sqlite3 db test.db
+} {}
+do_test tempdb-2.2 {
+ execsql {
+ CREATE TABLE t1 (a PRIMARY KEY, b, c);
+ CREATE TABLE t2 (a, b, c);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ INSERT INTO t2 VALUES(7, 8, 9);
+ INSERT INTO t2 SELECT * FROM t1;
+ }
+ catchsql { INSERT INTO t1 SELECT * FROM t2 }
+ set sqlite_open_file_count
+} [expr 1 + (0==$jrnl_in_memory) + (0==$subj_in_memory)]
+do_test tempdb-2.3 {
+ execsql {
+ PRAGMA temp_store = 'memory';
+ ROLLBACK;
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ INSERT INTO t2 SELECT * FROM t1;
+ }
+ catchsql { INSERT INTO t1 SELECT * FROM t2 }
+ set sqlite_open_file_count
+} [expr 1 + (0==$jrnl_in_memory)]
+
+finish_test
diff --git a/test/temptable.test b/test/temptable.test
new file mode 100644
index 0000000..5eeb0f5
--- /dev/null
+++ b/test/temptable.test
@@ -0,0 +1,441 @@
+# 2001 October 7
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for temporary tables and indices.
+#
+# $Id: temptable.test,v 1.21 2009/06/16 17:49:36 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !tempdb {
+ finish_test
+ return
+}
+
+# Create an alternative connection to the database
+#
+do_test temptable-1.0 {
+ sqlite3 db2 ./test.db
+ set dummy {}
+} {}
+
+# Create a permanent table.
+#
+do_test temptable-1.1 {
+ execsql {CREATE TABLE t1(a,b,c);}
+ execsql {INSERT INTO t1 VALUES(1,2,3);}
+ execsql {SELECT * FROM t1}
+} {1 2 3}
+do_test temptable-1.2 {
+ catch {db2 eval {SELECT * FROM sqlite_master}}
+ db2 eval {SELECT * FROM t1}
+} {1 2 3}
+do_test temptable-1.3 {
+ execsql {SELECT name FROM sqlite_master}
+} {t1}
+do_test temptable-1.4 {
+ db2 eval {SELECT name FROM sqlite_master}
+} {t1}
+
+# Create a temporary table. Verify that only one of the two
+# processes can see it.
+#
+do_test temptable-1.5 {
+ db2 eval {
+ CREATE TEMP TABLE t2(x,y,z);
+ INSERT INTO t2 VALUES(4,5,6);
+ }
+ db2 eval {SELECT * FROM t2}
+} {4 5 6}
+do_test temptable-1.6 {
+ catch {execsql {SELECT * FROM sqlite_master}}
+ catchsql {SELECT * FROM t2}
+} {1 {no such table: t2}}
+do_test temptable-1.7 {
+ catchsql {INSERT INTO t2 VALUES(8,9,0);}
+} {1 {no such table: t2}}
+do_test temptable-1.8 {
+ db2 eval {INSERT INTO t2 VALUES(8,9,0);}
+ db2 eval {SELECT * FROM t2 ORDER BY x}
+} {4 5 6 8 9 0}
+do_test temptable-1.9 {
+ db2 eval {DELETE FROM t2 WHERE x==8}
+ db2 eval {SELECT * FROM t2 ORDER BY x}
+} {4 5 6}
+do_test temptable-1.10 {
+ db2 eval {DELETE FROM t2}
+ db2 eval {SELECT * FROM t2}
+} {}
+do_test temptable-1.11 {
+ db2 eval {
+ INSERT INTO t2 VALUES(7,6,5);
+ INSERT INTO t2 VALUES(4,3,2);
+ SELECT * FROM t2 ORDER BY x;
+ }
+} {4 3 2 7 6 5}
+do_test temptable-1.12 {
+ db2 eval {DROP TABLE t2;}
+ set r [catch {db2 eval {SELECT * FROM t2}} msg]
+ lappend r $msg
+} {1 {no such table: t2}}
+
+# Make sure temporary tables work with transactions
+#
+do_test temptable-2.1 {
+ execsql {
+ BEGIN TRANSACTION;
+ CREATE TEMPORARY TABLE t2(x,y);
+ INSERT INTO t2 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+} {1 2}
+do_test temptable-2.2 {
+ execsql {ROLLBACK}
+ catchsql {SELECT * FROM t2}
+} {1 {no such table: t2}}
+do_test temptable-2.3 {
+ execsql {
+ BEGIN TRANSACTION;
+ CREATE TEMPORARY TABLE t2(x,y);
+ INSERT INTO t2 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+} {1 2}
+do_test temptable-2.4 {
+ execsql {COMMIT}
+ catchsql {SELECT * FROM t2}
+} {0 {1 2}}
+do_test temptable-2.5 {
+ set r [catch {db2 eval {SELECT * FROM t2}} msg]
+ lappend r $msg
+} {1 {no such table: t2}}
+
+# Make sure indices on temporary tables are also temporary.
+#
+do_test temptable-3.1 {
+ execsql {
+ CREATE INDEX i2 ON t2(x);
+ SELECT name FROM sqlite_master WHERE type='index';
+ }
+} {}
+do_test temptable-3.2 {
+ execsql {
+ SELECT y FROM t2 WHERE x=1;
+ }
+} {2}
+do_test temptable-3.3 {
+ execsql {
+ DROP INDEX i2;
+ SELECT y FROM t2 WHERE x=1;
+ }
+} {2}
+do_test temptable-3.4 {
+ execsql {
+ CREATE INDEX i2 ON t2(x);
+ DROP TABLE t2;
+ }
+ catchsql {DROP INDEX i2}
+} {1 {no such index: i2}}
+
+# Check for correct name collision processing. A name collision can
+# occur when process A creates a temporary table T then process B
+# creates a permanent table also named T. The temp table in process A
+# hides the existance of the permanent table.
+#
+do_test temptable-4.1 {
+ execsql {
+ CREATE TEMP TABLE t2(x,y);
+ INSERT INTO t2 VALUES(10,20);
+ SELECT * FROM t2;
+ } db2
+} {10 20}
+do_test temptable-4.2 {
+ execsql {
+ CREATE TABLE t2(x,y,z);
+ INSERT INTO t2 VALUES(9,8,7);
+ SELECT * FROM t2;
+ }
+} {9 8 7}
+do_test temptable-4.3 {
+ catchsql {
+ SELECT * FROM t2;
+ } db2
+} {0 {10 20}}
+do_test temptable-4.4.1 {
+ catchsql {
+ SELECT * FROM temp.t2;
+ } db2
+} {0 {10 20}}
+do_test temptable-4.4.2 {
+ catchsql {
+ SELECT * FROM main.t2;
+ } db2
+} {0 {9 8 7}}
+#do_test temptable-4.4.3 {
+# catchsql {
+# SELECT name FROM main.sqlite_master WHERE type='table';
+# } db2
+#} {1 {database schema has changed}}
+do_test temptable-4.4.4 {
+ catchsql {
+ SELECT name FROM main.sqlite_master WHERE type='table';
+ } db2
+} {0 {t1 t2}}
+do_test temptable-4.4.5 {
+ catchsql {
+ SELECT * FROM main.t2;
+ } db2
+} {0 {9 8 7}}
+do_test temptable-4.4.6 {
+ # TEMP takes precedence over MAIN
+ catchsql {
+ SELECT * FROM t2;
+ } db2
+} {0 {10 20}}
+do_test temptable-4.5 {
+ catchsql {
+ DROP TABLE t2; -- should drop TEMP
+ SELECT * FROM t2; -- data should be from MAIN
+ } db2
+} {0 {9 8 7}}
+do_test temptable-4.6 {
+ db2 close
+ sqlite3 db2 ./test.db
+ catchsql {
+ SELECT * FROM t2;
+ } db2
+} {0 {9 8 7}}
+do_test temptable-4.7 {
+ catchsql {
+ DROP TABLE t2;
+ SELECT * FROM t2;
+ }
+} {1 {no such table: t2}}
+do_test temptable-4.8 {
+ db2 close
+ sqlite3 db2 ./test.db
+ execsql {
+ CREATE TEMP TABLE t2(x unique,y);
+ INSERT INTO t2 VALUES(1,2);
+ SELECT * FROM t2;
+ } db2
+} {1 2}
+do_test temptable-4.9 {
+ execsql {
+ CREATE TABLE t2(x unique, y);
+ INSERT INTO t2 VALUES(3,4);
+ SELECT * FROM t2;
+ }
+} {3 4}
+do_test temptable-4.10.1 {
+ catchsql {
+ SELECT * FROM t2;
+ } db2
+} {0 {1 2}}
+# Update: The schema is reloaded in test temptable-4.10.1. And tclsqlite.c
+# handles it and retries the query anyway.
+# do_test temptable-4.10.2 {
+# catchsql {
+# SELECT name FROM sqlite_master WHERE type='table'
+# } db2
+# } {1 {database schema has changed}}
+do_test temptable-4.10.3 {
+ catchsql {
+ SELECT name FROM sqlite_master WHERE type='table'
+ } db2
+} {0 {t1 t2}}
+do_test temptable-4.11 {
+ execsql {
+ SELECT * FROM t2;
+ } db2
+} {1 2}
+do_test temptable-4.12 {
+ execsql {
+ SELECT * FROM t2;
+ }
+} {3 4}
+do_test temptable-4.13 {
+ catchsql {
+ DROP TABLE t2; -- drops TEMP.T2
+ SELECT * FROM t2; -- uses MAIN.T2
+ } db2
+} {0 {3 4}}
+do_test temptable-4.14 {
+ execsql {
+ SELECT * FROM t2;
+ }
+} {3 4}
+do_test temptable-4.15 {
+ db2 close
+ sqlite3 db2 ./test.db
+ execsql {
+ SELECT * FROM t2;
+ } db2
+} {3 4}
+
+# Now create a temporary table in db2 and a permanent index in db. The
+# temporary table in db2 should mask the name of the permanent index,
+# but the permanent index should still be accessible and should still
+# be updated when its corresponding table changes.
+#
+do_test temptable-5.1 {
+ execsql {
+ CREATE TEMP TABLE mask(a,b,c)
+ } db2
+ if {[permutation]=="prepare"} { db2 cache flush }
+ execsql {
+ CREATE INDEX mask ON t2(x);
+ SELECT * FROM t2;
+ }
+} {3 4}
+#do_test temptable-5.2 {
+# catchsql {
+# SELECT * FROM t2;
+# } db2
+#} {1 {database schema has changed}}
+do_test temptable-5.3 {
+ catchsql {
+ SELECT * FROM t2;
+ } db2
+} {0 {3 4}}
+do_test temptable-5.4 {
+ execsql {
+ SELECT y FROM t2 WHERE x=3
+ }
+} {4}
+do_test temptable-5.5 {
+ execsql {
+ SELECT y FROM t2 WHERE x=3
+ } db2
+} {4}
+do_test temptable-5.6 {
+ execsql {
+ INSERT INTO t2 VALUES(1,2);
+ SELECT y FROM t2 WHERE x=1;
+ } db2
+} {2}
+do_test temptable-5.7 {
+ execsql {
+ SELECT y FROM t2 WHERE x=3
+ } db2
+} {4}
+do_test temptable-5.8 {
+ execsql {
+ SELECT y FROM t2 WHERE x=1;
+ }
+} {2}
+do_test temptable-5.9 {
+ execsql {
+ SELECT y FROM t2 WHERE x=3
+ }
+} {4}
+
+db2 close
+
+# Test for correct operation of read-only databases
+#
+do_test temptable-6.1 {
+ execsql {
+ CREATE TABLE t8(x);
+ INSERT INTO t8 VALUES('xyzzy');
+ SELECT * FROM t8;
+ }
+} {xyzzy}
+do_test temptable-6.2 {
+ db close
+ catch {file attributes test.db -permissions 0444}
+ catch {file attributes test.db -readonly 1}
+ sqlite3 db test.db
+ if {[file writable test.db]} {
+ error "Unable to make the database file test.db readonly - rerun this test as an unprivileged user"
+ }
+ execsql {
+ SELECT * FROM t8;
+ }
+} {xyzzy}
+do_test temptable-6.3 {
+ if {[file writable test.db]} {
+ error "Unable to make the database file test.db readonly - rerun this test as an unprivileged user"
+ }
+ catchsql {
+ CREATE TABLE t9(x,y);
+ }
+} {1 {attempt to write a readonly database}}
+do_test temptable-6.4 {
+ catchsql {
+ CREATE TEMP TABLE t9(x,y);
+ }
+} {0 {}}
+do_test temptable-6.5 {
+ catchsql {
+ INSERT INTO t9 VALUES(1,2);
+ SELECT * FROM t9;
+ }
+} {0 {1 2}}
+do_test temptable-6.6 {
+ if {[file writable test.db]} {
+ error "Unable to make the database file test.db readonly - rerun this test as an unprivileged user"
+ }
+ catchsql {
+ INSERT INTO t8 VALUES('hello');
+ SELECT * FROM t8;
+ }
+} {1 {attempt to write a readonly database}}
+do_test temptable-6.7 {
+ catchsql {
+ SELECT * FROM t8,t9;
+ }
+} {0 {xyzzy 1 2}}
+do_test temptable-6.8 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT * FROM t8,t9;
+ }
+} {1 {no such table: t9}}
+
+forcedelete test2.db test2.db-journal
+ifcapable attach {
+ do_test temptable-7.1 {
+ catchsql {
+ ATTACH 'test2.db' AS two;
+ CREATE TEMP TABLE two.abc(x,y);
+ }
+ } {1 {temporary table name must be unqualified}}
+}
+
+# Need to do the following for tcl 8.5 on mac. On that configuration, the
+# -readonly flag is taken so seriously that a subsequent [forcedelete]
+# (required before the next test file can be executed) will fail.
+#
+catch {file attributes test.db -readonly 0}
+
+do_test temptable-8.0 {
+ db close
+ catch {forcedelete test.db}
+ sqlite3 db test.db
+} {}
+do_test temptable-8.1 {
+ execsql { CREATE TEMP TABLE tbl2(a, b); }
+ execsql {
+ CREATE TABLE tbl(a, b);
+ INSERT INTO tbl VALUES(1, 2);
+ }
+ execsql {SELECT * FROM tbl}
+} {1 2}
+do_test temptable-8.2 {
+ execsql { CREATE TEMP TABLE tbl(a, b); }
+ execsql {SELECT * FROM tbl}
+} {}
+
+finish_test
diff --git a/test/temptrigger.test b/test/temptrigger.test
new file mode 100644
index 0000000..ed1efb9
--- /dev/null
+++ b/test/temptrigger.test
@@ -0,0 +1,204 @@
+# 2009 February 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: temptrigger.test,v 1.3 2009/04/15 13:07:19 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!trigger || !shared_cache} { finish_test ; return }
+
+# Test cases:
+#
+# temptrigger-1.*: Shared cache problem.
+# temptrigger-2.*: A similar shared cache problem.
+# temptrigger-3.*: Attached database problem.
+#
+
+#-------------------------------------------------------------------------
+# Test case temptrigger-1.* demonstrates a problem with temp triggers
+# in shared-cache mode. If process 1 connections to a shared-cache and
+# creates a temp trigger, the temp trigger is linked into the shared-cache
+# schema. If process 2 reloads the shared-cache schema from disk, then
+# it does not recreate the temp trigger belonging to process 1. From the
+# point of view of process 1, the temp trigger just disappeared.
+#
+# temptrigger-1.1: In shared cache mode, create a table in the main
+# database and add a temp trigger to it.
+#
+# temptrigger-1.2: Check that the temp trigger is correctly fired. Check
+# that the temp trigger is not fired by statements
+# executed by a second connection connected to the
+# same shared cache.
+#
+# temptrigger-1.3: Using the second connection to the shared-cache, cause
+# the shared-cache schema to be reloaded.
+#
+# temptrigger-1.4: Check that the temp trigger is still fired correctly.
+#
+# temptrigger-1.5: Check that the temp trigger can be dropped without error.
+#
+db close
+set ::enable_shared_cache [sqlite3_enable_shared_cache]
+sqlite3_enable_shared_cache 1
+
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+do_test temptrigger-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TEMP TABLE tt1(a, b);
+ CREATE TEMP TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO tt1 VALUES(new.a, new.b);
+ END;
+ }
+} {}
+
+do_test temptrigger-1.2.1 {
+ execsql { INSERT INTO t1 VALUES(1, 2) }
+ execsql { SELECT * FROM t1 }
+} {1 2}
+do_test temptrigger-1.2.2 {
+ execsql { SELECT * FROM tt1 }
+} {1 2}
+do_test temptrigger-1.2.3 {
+ execsql { INSERT INTO t1 VALUES(3, 4) } db2
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+do_test temptrigger-1.2.4 {
+ execsql { SELECT * FROM tt1 }
+} {1 2}
+
+# Cause the shared-cache schema to be reloaded.
+#
+do_test temptrigger-1.3 {
+ execsql { BEGIN; CREATE TABLE t3(a, b); ROLLBACK; } db2
+} {}
+
+do_test temptrigger-1.4 {
+ execsql { INSERT INTO t1 VALUES(5, 6) }
+ execsql { SELECT * FROM tt1 }
+} {1 2 5 6}
+
+do_test temptrigger-1.5 {
+ # Before the bug was fixed, the following 'DROP TRIGGER' hit an
+ # assert if executed.
+ #execsql { DROP TRIGGER tr1 }
+} {}
+
+catch {db close}
+catch {db2 close}
+
+#-------------------------------------------------------------------------
+# Tests temptrigger-2.* are similar to temptrigger-1.*, except that
+# temptrigger-2.3 simply opens and closes a connection to the shared-cache.
+# It does not do anything special to cause the schema to be reloaded.
+#
+do_test temptrigger-2.1 {
+ sqlite3 db test.db
+ execsql {
+ DELETE FROM t1;
+ CREATE TEMP TABLE tt1(a, b);
+ CREATE TEMP TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO tt1 VALUES(new.a, new.b);
+ END;
+ }
+} {}
+do_test temptrigger-2.2 {
+ execsql {
+ INSERT INTO t1 VALUES(10, 20);
+ SELECT * FROM tt1;
+ }
+} {10 20}
+do_test temptrigger-2.3 {
+ sqlite3 db2 test.db
+ db2 close
+} {}
+do_test temptrigger-2.4 {
+ execsql {
+ INSERT INTO t1 VALUES(30, 40);
+ SELECT * FROM tt1;
+ }
+} {10 20 30 40}
+do_test temptrigger-2.5 {
+ #execsql { DROP TRIGGER tr1 }
+} {}
+
+catch {db close}
+catch {db2 close}
+sqlite3_enable_shared_cache $::enable_shared_cache
+
+#-------------------------------------------------------------------------
+# Test case temptrigger-3.* demonstrates a problem with temp triggers
+# on tables located in attached databases. At one point when SQLite reloaded
+# the schema of an attached database (because some other connection had
+# changed the schema cookie) it was not re-creating temp triggers attached
+# to tables located within the attached database.
+#
+# temptrigger-3.1: Attach database 'test2.db' to connection [db]. Add a
+# temp trigger to a table in 'test2.db'.
+#
+# temptrigger-3.2: Check that the temp trigger is correctly fired.
+#
+# temptrigger-3.3: Update the schema of 'test2.db' using an external
+# connection. This forces [db] to reload the 'test2.db'
+# schema. Check that the temp trigger is still fired
+# correctly.
+#
+# temptrigger-3.4: Check that the temp trigger can be dropped without error.
+#
+do_test temptrigger-3.1 {
+ catch { forcedelete test2.db test2.db-journal }
+ catch { forcedelete test.db test.db-journal }
+ sqlite3 db test.db
+ sqlite3 db2 test2.db
+ execsql { CREATE TABLE t2(a, b) } db2
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ CREATE TEMP TABLE tt2(a, b);
+ CREATE TEMP TRIGGER tr2 AFTER INSERT ON aux.t2 BEGIN
+ INSERT INTO tt2 VALUES(new.a, new.b);
+ END;
+ }
+} {}
+
+do_test temptrigger-3.2.1 {
+ execsql {
+ INSERT INTO aux.t2 VALUES(1, 2);
+ SELECT * FROM aux.t2;
+ }
+} {1 2}
+do_test temptrigger-3.2.2 {
+ execsql { SELECT * FROM tt2 }
+} {1 2}
+
+do_test temptrigger-3.3.1 {
+ execsql { CREATE TABLE t3(a, b) } db2
+ execsql {
+ INSERT INTO aux.t2 VALUES(3, 4);
+ SELECT * FROM aux.t2;
+ }
+} {1 2 3 4}
+do_test temptrigger-3.3.2 {
+ execsql { SELECT * FROM tt2 }
+} {1 2 3 4}
+
+do_test temptrigger-3.4 {
+ # Before the bug was fixed, the following 'DROP TRIGGER' hit an
+ # assert if executed.
+ #execsql { DROP TRIGGER tr2 }
+} {}
+
+catch { db close }
+catch { db2 close }
+
+finish_test
diff --git a/test/tester.tcl b/test/tester.tcl
new file mode 100644
index 0000000..3c34b45
--- /dev/null
+++ b/test/tester.tcl
@@ -0,0 +1,1561 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements some common TCL routines used for regression
+# testing the SQLite library
+#
+# $Id: tester.tcl,v 1.143 2009/04/09 01:23:49 drh Exp $
+
+#-------------------------------------------------------------------------
+# The commands provided by the code in this file to help with creating
+# test cases are as follows:
+#
+# Commands to manipulate the db and the file-system at a high level:
+#
+# copy_file FROM TO
+# delete_file FILENAME
+# drop_all_tables ?DB?
+# forcecopy FROM TO
+# forcedelete FILENAME
+#
+# Test the capability of the SQLite version built into the interpreter to
+# determine if a specific test can be run:
+#
+# ifcapable EXPR
+#
+# Calulate checksums based on database contents:
+#
+# dbcksum DB DBNAME
+# allcksum ?DB?
+# cksum ?DB?
+#
+# Commands to execute/explain SQL statements:
+#
+# stepsql DB SQL
+# execsql2 SQL
+# explain_no_trace SQL
+# explain SQL ?DB?
+# catchsql SQL ?DB?
+# execsql SQL ?DB?
+#
+# Commands to run test cases:
+#
+# do_ioerr_test TESTNAME ARGS...
+# crashsql ARGS...
+# integrity_check TESTNAME ?DB?
+# do_test TESTNAME SCRIPT EXPECTED
+# do_execsql_test TESTNAME SQL EXPECTED
+# do_catchsql_test TESTNAME SQL EXPECTED
+#
+# Commands providing a lower level interface to the global test counters:
+#
+# set_test_counter COUNTER ?VALUE?
+# omit_test TESTNAME REASON
+# fail_test TESTNAME
+# incr_ntest
+#
+# Command run at the end of each test file:
+#
+# finish_test
+#
+# Commands to help create test files that run with the "WAL" and other
+# permutations (see file permutations.test):
+#
+# wal_is_wal_mode
+# wal_set_journal_mode ?DB?
+# wal_check_journal_mode TESTNAME?DB?
+# permutation
+# presql
+#
+
+# Set the precision of FP arithmatic used by the interpreter. And
+# configure SQLite to take database file locks on the page that begins
+# 64KB into the database file instead of the one 1GB in. This means
+# the code that handles that special case can be tested without creating
+# very large database files.
+#
+set tcl_precision 15
+sqlite3_test_control_pending_byte 0x0010000
+
+
+# If the pager codec is available, create a wrapper for the [sqlite3]
+# command that appends "-key {xyzzy}" to the command line. i.e. this:
+#
+# sqlite3 db test.db
+#
+# becomes
+#
+# sqlite3 db test.db -key {xyzzy}
+#
+if {[info command sqlite_orig]==""} {
+ rename sqlite3 sqlite_orig
+ proc sqlite3 {args} {
+ if {[llength $args]>=2 && [string index [lindex $args 0] 0]!="-"} {
+ # This command is opening a new database connection.
+ #
+ if {[info exists ::G(perm:sqlite3_args)]} {
+ set args [concat $args $::G(perm:sqlite3_args)]
+ }
+ if {[sqlite_orig -has-codec] && ![info exists ::do_not_use_codec]} {
+ lappend args -key {xyzzy}
+ }
+
+ set res [uplevel 1 sqlite_orig $args]
+ if {[info exists ::G(perm:presql)]} {
+ [lindex $args 0] eval $::G(perm:presql)
+ }
+ if {[info exists ::G(perm:dbconfig)]} {
+ set ::dbhandle [lindex $args 0]
+ uplevel #0 $::G(perm:dbconfig)
+ }
+ set res
+ } else {
+ # This command is not opening a new database connection. Pass the
+ # arguments through to the C implemenation as the are.
+ #
+ uplevel 1 sqlite_orig $args
+ }
+ }
+}
+
+proc getFileRetries {} {
+ if {![info exists ::G(file-retries)]} {
+ #
+ # NOTE: Return the default number of retries for [file] operations. A
+ # value of zero or less here means "disabled".
+ #
+ return [expr {$::tcl_platform(platform) eq "windows" ? 10 : 0}]
+ }
+ return $::G(file-retries)
+}
+
+proc getFileRetryDelay {} {
+ if {![info exists ::G(file-retry-delay)]} {
+ #
+ # NOTE: Return the default number of milliseconds to wait when retrying
+ # failed [file] operations. A value of zero or less means "do not
+ # wait".
+ #
+ return 100; # TODO: Good default?
+ }
+ return $::G(file-retry-delay)
+}
+
+# Copy file $from into $to. This is used because some versions of
+# TCL for windows (notably the 8.4.1 binary package shipped with the
+# current mingw release) have a broken "file copy" command.
+#
+proc copy_file {from to} {
+ do_copy_file false $from $to
+}
+
+proc forcecopy {from to} {
+ do_copy_file true $from $to
+}
+
+proc do_copy_file {force from to} {
+ set nRetry [getFileRetries] ;# Maximum number of retries.
+ set nDelay [getFileRetryDelay] ;# Delay in ms before retrying.
+
+ # On windows, sometimes even a [file copy -force] can fail. The cause is
+ # usually "tag-alongs" - programs like anti-virus software, automatic backup
+ # tools and various explorer extensions that keep a file open a little longer
+ # than we expect, causing the delete to fail.
+ #
+ # The solution is to wait a short amount of time before retrying the copy.
+ #
+ if {$nRetry > 0} {
+ for {set i 0} {$i<$nRetry} {incr i} {
+ set rc [catch {
+ if {$force} {
+ file copy -force $from $to
+ } else {
+ file copy $from $to
+ }
+ } msg]
+ if {$rc==0} break
+ if {$nDelay > 0} { after $nDelay }
+ }
+ if {$rc} { error $msg }
+ } else {
+ if {$force} {
+ file copy -force $from $to
+ } else {
+ file copy $from $to
+ }
+ }
+}
+
+# Delete a file or directory
+#
+proc delete_file {args} {
+ do_delete_file false {*}$args
+}
+
+proc forcedelete {args} {
+ do_delete_file true {*}$args
+}
+
+proc do_delete_file {force args} {
+ set nRetry [getFileRetries] ;# Maximum number of retries.
+ set nDelay [getFileRetryDelay] ;# Delay in ms before retrying.
+
+ foreach filename $args {
+ # On windows, sometimes even a [file delete -force] can fail just after
+ # a file is closed. The cause is usually "tag-alongs" - programs like
+ # anti-virus software, automatic backup tools and various explorer
+ # extensions that keep a file open a little longer than we expect, causing
+ # the delete to fail.
+ #
+ # The solution is to wait a short amount of time before retrying the
+ # delete.
+ #
+ if {$nRetry > 0} {
+ for {set i 0} {$i<$nRetry} {incr i} {
+ set rc [catch {
+ if {$force} {
+ file delete -force $filename
+ } else {
+ file delete $filename
+ }
+ } msg]
+ if {$rc==0} break
+ if {$nDelay > 0} { after $nDelay }
+ }
+ if {$rc} { error $msg }
+ } else {
+ if {$force} {
+ file delete -force $filename
+ } else {
+ file delete $filename
+ }
+ }
+ }
+}
+
+proc execpresql {handle args} {
+ trace remove execution $handle enter [list execpresql $handle]
+ if {[info exists ::G(perm:presql)]} {
+ $handle eval $::G(perm:presql)
+ }
+}
+
+# This command should be called after loading tester.tcl from within
+# all test scripts that are incompatible with encryption codecs.
+#
+proc do_not_use_codec {} {
+ set ::do_not_use_codec 1
+ reset_db
+}
+
+# The following block only runs the first time this file is sourced. It
+# does not run in slave interpreters (since the ::cmdlinearg array is
+# populated before the test script is run in slave interpreters).
+#
+if {[info exists cmdlinearg]==0} {
+
+ # Parse any options specified in the $argv array. This script accepts the
+ # following options:
+ #
+ # --pause
+ # --soft-heap-limit=NN
+ # --maxerror=NN
+ # --malloctrace=N
+ # --backtrace=N
+ # --binarylog=N
+ # --soak=N
+ # --file-retries=N
+ # --file-retry-delay=N
+ # --start=[$permutation:]$testfile
+ #
+ set cmdlinearg(soft-heap-limit) 0
+ set cmdlinearg(maxerror) 1000
+ set cmdlinearg(malloctrace) 0
+ set cmdlinearg(backtrace) 10
+ set cmdlinearg(binarylog) 0
+ set cmdlinearg(soak) 0
+ set cmdlinearg(file-retries) 0
+ set cmdlinearg(file-retry-delay) 0
+ set cmdlinearg(start) ""
+
+ set leftover [list]
+ foreach a $argv {
+ switch -regexp -- $a {
+ {^-+pause$} {
+ # Wait for user input before continuing. This is to give the user an
+ # opportunity to connect profiling tools to the process.
+ puts -nonewline "Press RETURN to begin..."
+ flush stdout
+ gets stdin
+ }
+ {^-+soft-heap-limit=.+$} {
+ foreach {dummy cmdlinearg(soft-heap-limit)} [split $a =] break
+ }
+ {^-+maxerror=.+$} {
+ foreach {dummy cmdlinearg(maxerror)} [split $a =] break
+ }
+ {^-+malloctrace=.+$} {
+ foreach {dummy cmdlinearg(malloctrace)} [split $a =] break
+ if {$cmdlinearg(malloctrace)} {
+ sqlite3_memdebug_log start
+ }
+ }
+ {^-+backtrace=.+$} {
+ foreach {dummy cmdlinearg(backtrace)} [split $a =] break
+ sqlite3_memdebug_backtrace $value
+ }
+ {^-+binarylog=.+$} {
+ foreach {dummy cmdlinearg(binarylog)} [split $a =] break
+ }
+ {^-+soak=.+$} {
+ foreach {dummy cmdlinearg(soak)} [split $a =] break
+ set ::G(issoak) $cmdlinearg(soak)
+ }
+ {^-+file-retries=.+$} {
+ foreach {dummy cmdlinearg(file-retries)} [split $a =] break
+ set ::G(file-retries) $cmdlinearg(file-retries)
+ }
+ {^-+file-retry-delay=.+$} {
+ foreach {dummy cmdlinearg(file-retry-delay)} [split $a =] break
+ set ::G(file-retry-delay) $cmdlinearg(file-retry-delay)
+ }
+ {^-+start=.+$} {
+ foreach {dummy cmdlinearg(start)} [split $a =] break
+
+ set ::G(start:file) $cmdlinearg(start)
+ if {[regexp {(.*):(.*)} $cmdlinearg(start) -> s.perm s.file]} {
+ set ::G(start:permutation) ${s.perm}
+ set ::G(start:file) ${s.file}
+ }
+ if {$::G(start:file) == ""} {unset ::G(start:file)}
+ }
+ default {
+ lappend leftover $a
+ }
+ }
+ }
+ set argv $leftover
+
+ # Install the malloc layer used to inject OOM errors. And the 'automatic'
+ # extensions. This only needs to be done once for the process.
+ #
+ sqlite3_shutdown
+ install_malloc_faultsim 1
+ sqlite3_initialize
+ autoinstall_test_functions
+
+ # If the --binarylog option was specified, create the logging VFS. This
+ # call installs the new VFS as the default for all SQLite connections.
+ #
+ if {$cmdlinearg(binarylog)} {
+ vfslog new binarylog {} vfslog.bin
+ }
+
+ # Set the backtrace depth, if malloc tracing is enabled.
+ #
+ if {$cmdlinearg(malloctrace)} {
+ sqlite3_memdebug_backtrace $cmdlinearg(backtrace)
+ }
+}
+
+# Update the soft-heap-limit each time this script is run. In that
+# way if an individual test file changes the soft-heap-limit, it
+# will be reset at the start of the next test file.
+#
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
+
+# Create a test database
+#
+proc reset_db {} {
+ catch {db close}
+ forcedelete test.db
+ forcedelete test.db-journal
+ forcedelete test.db-wal
+ sqlite3 db ./test.db
+ set ::DB [sqlite3_connection_pointer db]
+ if {[info exists ::SETUP_SQL]} {
+ db eval $::SETUP_SQL
+ }
+}
+reset_db
+
+# Abort early if this script has been run before.
+#
+if {[info exists TC(count)]} return
+
+# Make sure memory statistics are enabled.
+#
+sqlite3_config_memstatus 1
+
+# Initialize the test counters and set up commands to access them.
+# Or, if this is a slave interpreter, set up aliases to write the
+# counters in the parent interpreter.
+#
+if {0==[info exists ::SLAVE]} {
+ set TC(errors) 0
+ set TC(count) 0
+ set TC(fail_list) [list]
+ set TC(omit_list) [list]
+
+ proc set_test_counter {counter args} {
+ if {[llength $args]} {
+ set ::TC($counter) [lindex $args 0]
+ }
+ set ::TC($counter)
+ }
+}
+
+# Record the fact that a sequence of tests were omitted.
+#
+proc omit_test {name reason} {
+ set omitList [set_test_counter omit_list]
+ lappend omitList [list $name $reason]
+ set_test_counter omit_list $omitList
+}
+
+# Record the fact that a test failed.
+#
+proc fail_test {name} {
+ set f [set_test_counter fail_list]
+ lappend f $name
+ set_test_counter fail_list $f
+ set_test_counter errors [expr [set_test_counter errors] + 1]
+
+ set nFail [set_test_counter errors]
+ if {$nFail>=$::cmdlinearg(maxerror)} {
+ puts "*** Giving up..."
+ finalize_testing
+ }
+}
+
+# Increment the number of tests run
+#
+proc incr_ntest {} {
+ set_test_counter count [expr [set_test_counter count] + 1]
+}
+
+
+# Invoke the do_test procedure to run a single test
+#
+proc do_test {name cmd expected} {
+
+ global argv cmdlinearg
+
+ fix_testname name
+
+ sqlite3_memdebug_settitle $name
+
+# if {[llength $argv]==0} {
+# set go 1
+# } else {
+# set go 0
+# foreach pattern $argv {
+# if {[string match $pattern $name]} {
+# set go 1
+# break
+# }
+# }
+# }
+
+ if {[info exists ::G(perm:prefix)]} {
+ set name "$::G(perm:prefix)$name"
+ }
+
+ incr_ntest
+ puts -nonewline $name...
+ flush stdout
+ if {[catch {uplevel #0 "$cmd;\n"} result]} {
+ puts "\nError: $result"
+ fail_test $name
+ } elseif {[string compare $result $expected]} {
+ puts "\nExpected: \[$expected\]\n Got: \[$result\]"
+ fail_test $name
+ } else {
+ puts " Ok"
+ }
+ flush stdout
+}
+
+proc filepath_normalize {p} {
+ # test cases should be written to assume "unix"-like file paths
+ if {$::tcl_platform(platform)!="unix"} {
+ # lreverse*2 as a hack to remove any unneeded {} after the string map
+ lreverse [lreverse [string map {\\ /} [regsub -nocase -all {[a-z]:[/\\]+} $p {/}]]]
+ } {
+ set p
+ }
+}
+proc do_filepath_test {name cmd expected} {
+ uplevel [list do_test $name [
+ subst -nocommands { filepath_normalize [ $cmd ] }
+ ] [filepath_normalize $expected]]
+}
+
+proc realnum_normalize {r} {
+ # different TCL versions display floating point values differently.
+ string map {1.#INF inf Inf inf .0e e} [regsub -all {(e[+-])0+} $r {\1}]
+}
+proc do_realnum_test {name cmd expected} {
+ uplevel [list do_test $name [
+ subst -nocommands { realnum_normalize [ $cmd ] }
+ ] [realnum_normalize $expected]]
+}
+
+proc fix_testname {varname} {
+ upvar $varname testname
+ if {[info exists ::testprefix]
+ && [string is digit [string range $testname 0 0]]
+ } {
+ set testname "${::testprefix}-$testname"
+ }
+}
+
+proc do_execsql_test {testname sql {result {}}} {
+ fix_testname testname
+ uplevel do_test [list $testname] [list "execsql {$sql}"] [list [list {*}$result]]
+}
+proc do_catchsql_test {testname sql result} {
+ fix_testname testname
+ uplevel do_test [list $testname] [list "catchsql {$sql}"] [list $result]
+}
+proc do_eqp_test {name sql res} {
+ uplevel do_execsql_test $name [list "EXPLAIN QUERY PLAN $sql"] [list $res]
+}
+
+#-------------------------------------------------------------------------
+# Usage: do_select_tests PREFIX ?SWITCHES? TESTLIST
+#
+# Where switches are:
+#
+# -errorformat FMTSTRING
+# -count
+# -query SQL
+# -tclquery TCL
+# -repair TCL
+#
+proc do_select_tests {prefix args} {
+
+ set testlist [lindex $args end]
+ set switches [lrange $args 0 end-1]
+
+ set errfmt ""
+ set countonly 0
+ set tclquery ""
+ set repair ""
+
+ for {set i 0} {$i < [llength $switches]} {incr i} {
+ set s [lindex $switches $i]
+ set n [string length $s]
+ if {$n>=2 && [string equal -length $n $s "-query"]} {
+ set tclquery [list execsql [lindex $switches [incr i]]]
+ } elseif {$n>=2 && [string equal -length $n $s "-tclquery"]} {
+ set tclquery [lindex $switches [incr i]]
+ } elseif {$n>=2 && [string equal -length $n $s "-errorformat"]} {
+ set errfmt [lindex $switches [incr i]]
+ } elseif {$n>=2 && [string equal -length $n $s "-repair"]} {
+ set repair [lindex $switches [incr i]]
+ } elseif {$n>=2 && [string equal -length $n $s "-count"]} {
+ set countonly 1
+ } else {
+ error "unknown switch: $s"
+ }
+ }
+
+ if {$countonly && $errfmt!=""} {
+ error "Cannot use -count and -errorformat together"
+ }
+ set nTestlist [llength $testlist]
+ if {$nTestlist%3 || $nTestlist==0 } {
+ error "SELECT test list contains [llength $testlist] elements"
+ }
+
+ eval $repair
+ foreach {tn sql res} $testlist {
+ if {$tclquery != ""} {
+ execsql $sql
+ uplevel do_test ${prefix}.$tn [list $tclquery] [list [list {*}$res]]
+ } elseif {$countonly} {
+ set nRow 0
+ db eval $sql {incr nRow}
+ uplevel do_test ${prefix}.$tn [list [list set {} $nRow]] [list $res]
+ } elseif {$errfmt==""} {
+ uplevel do_execsql_test ${prefix}.${tn} [list $sql] [list [list {*}$res]]
+ } else {
+ set res [list 1 [string trim [format $errfmt {*}$res]]]
+ uplevel do_catchsql_test ${prefix}.${tn} [list $sql] [list $res]
+ }
+ eval $repair
+ }
+
+}
+
+proc delete_all_data {} {
+ db eval {SELECT tbl_name AS t FROM sqlite_master WHERE type = 'table'} {
+ db eval "DELETE FROM '[string map {' ''} $t]'"
+ }
+}
+
+# Run an SQL script.
+# Return the number of microseconds per statement.
+#
+proc speed_trial {name numstmt units sql} {
+ puts -nonewline [format {%-21.21s } $name...]
+ flush stdout
+ set speed [time {sqlite3_exec_nr db $sql}]
+ set tm [lindex $speed 0]
+ if {$tm == 0} {
+ set rate [format %20s "many"]
+ } else {
+ set rate [format %20.5f [expr {1000000.0*$numstmt/$tm}]]
+ }
+ set u2 $units/s
+ puts [format {%12d uS %s %s} $tm $rate $u2]
+ global total_time
+ set total_time [expr {$total_time+$tm}]
+ lappend ::speed_trial_times $name $tm
+}
+proc speed_trial_tcl {name numstmt units script} {
+ puts -nonewline [format {%-21.21s } $name...]
+ flush stdout
+ set speed [time {eval $script}]
+ set tm [lindex $speed 0]
+ if {$tm == 0} {
+ set rate [format %20s "many"]
+ } else {
+ set rate [format %20.5f [expr {1000000.0*$numstmt/$tm}]]
+ }
+ set u2 $units/s
+ puts [format {%12d uS %s %s} $tm $rate $u2]
+ global total_time
+ set total_time [expr {$total_time+$tm}]
+ lappend ::speed_trial_times $name $tm
+}
+proc speed_trial_init {name} {
+ global total_time
+ set total_time 0
+ set ::speed_trial_times [list]
+ sqlite3 versdb :memory:
+ set vers [versdb one {SELECT sqlite_source_id()}]
+ versdb close
+ puts "SQLite $vers"
+}
+proc speed_trial_summary {name} {
+ global total_time
+ puts [format {%-21.21s %12d uS TOTAL} $name $total_time]
+
+ if { 0 } {
+ sqlite3 versdb :memory:
+ set vers [lindex [versdb one {SELECT sqlite_source_id()}] 0]
+ versdb close
+ puts "CREATE TABLE IF NOT EXISTS time(version, script, test, us);"
+ foreach {test us} $::speed_trial_times {
+ puts "INSERT INTO time VALUES('$vers', '$name', '$test', $us);"
+ }
+ }
+}
+
+# Run this routine last
+#
+proc finish_test {} {
+ catch {db close}
+ catch {db2 close}
+ catch {db3 close}
+ if {0==[info exists ::SLAVE]} { finalize_testing }
+}
+proc finalize_testing {} {
+ global sqlite_open_file_count
+
+ set omitList [set_test_counter omit_list]
+
+ catch {db close}
+ catch {db2 close}
+ catch {db3 close}
+
+ vfs_unlink_test
+ sqlite3 db {}
+ # sqlite3_clear_tsd_memdebug
+ db close
+ sqlite3_reset_auto_extension
+
+ sqlite3_soft_heap_limit 0
+ set nTest [incr_ntest]
+ set nErr [set_test_counter errors]
+
+ puts "$nErr errors out of $nTest tests"
+ if {$nErr>0} {
+ puts "Failures on these tests: [set_test_counter fail_list]"
+ }
+ run_thread_tests 1
+ if {[llength $omitList]>0} {
+ puts "Omitted test cases:"
+ set prec {}
+ foreach {rec} [lsort $omitList] {
+ if {$rec==$prec} continue
+ set prec $rec
+ puts [format { %-12s %s} [lindex $rec 0] [lindex $rec 1]]
+ }
+ }
+ if {$nErr>0 && ![working_64bit_int]} {
+ puts "******************************************************************"
+ puts "N.B.: The version of TCL that you used to build this test harness"
+ puts "is defective in that it does not support 64-bit integers. Some or"
+ puts "all of the test failures above might be a result from this defect"
+ puts "in your TCL build."
+ puts "******************************************************************"
+ }
+ if {$::cmdlinearg(binarylog)} {
+ vfslog finalize binarylog
+ }
+ if {$sqlite_open_file_count} {
+ puts "$sqlite_open_file_count files were left open"
+ incr nErr
+ }
+ if {[lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1]>0 ||
+ [sqlite3_memory_used]>0} {
+ puts "Unfreed memory: [sqlite3_memory_used] bytes in\
+ [lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1] allocations"
+ incr nErr
+ ifcapable memdebug||mem5||(mem3&&debug) {
+ puts "Writing unfreed memory log to \"./memleak.txt\""
+ sqlite3_memdebug_dump ./memleak.txt
+ }
+ } else {
+ puts "All memory allocations freed - no leaks"
+ ifcapable memdebug||mem5 {
+ sqlite3_memdebug_dump ./memusage.txt
+ }
+ }
+ show_memstats
+ puts "Maximum memory usage: [sqlite3_memory_highwater 1] bytes"
+ puts "Current memory usage: [sqlite3_memory_highwater] bytes"
+ if {[info commands sqlite3_memdebug_malloc_count] ne ""} {
+ puts "Number of malloc() : [sqlite3_memdebug_malloc_count] calls"
+ }
+ if {$::cmdlinearg(malloctrace)} {
+ puts "Writing mallocs.sql..."
+ memdebug_log_sql
+ sqlite3_memdebug_log stop
+ sqlite3_memdebug_log clear
+
+ if {[sqlite3_memory_used]>0} {
+ puts "Writing leaks.sql..."
+ sqlite3_memdebug_log sync
+ memdebug_log_sql leaks.sql
+ }
+ }
+ foreach f [glob -nocomplain test.db-*-journal] {
+ forcedelete $f
+ }
+ foreach f [glob -nocomplain test.db-mj*] {
+ forcedelete $f
+ }
+ exit [expr {$nErr>0}]
+}
+
+# Display memory statistics for analysis and debugging purposes.
+#
+proc show_memstats {} {
+ set x [sqlite3_status SQLITE_STATUS_MEMORY_USED 0]
+ set y [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0]
+ set val [format {now %10d max %10d max-size %10d} \
+ [lindex $x 1] [lindex $x 2] [lindex $y 2]]
+ puts "Memory used: $val"
+ set x [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0]
+ set val [format {now %10d max %10d} [lindex $x 1] [lindex $x 2]]
+ puts "Allocation count: $val"
+ set x [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0]
+ set y [sqlite3_status SQLITE_STATUS_PAGECACHE_SIZE 0]
+ set val [format {now %10d max %10d max-size %10d} \
+ [lindex $x 1] [lindex $x 2] [lindex $y 2]]
+ puts "Page-cache used: $val"
+ set x [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0]
+ set val [format {now %10d max %10d} [lindex $x 1] [lindex $x 2]]
+ puts "Page-cache overflow: $val"
+ set x [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0]
+ set val [format {now %10d max %10d} [lindex $x 1] [lindex $x 2]]
+ puts "Scratch memory used: $val"
+ set x [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0]
+ set y [sqlite3_status SQLITE_STATUS_SCRATCH_SIZE 0]
+ set val [format {now %10d max %10d max-size %10d} \
+ [lindex $x 1] [lindex $x 2] [lindex $y 2]]
+ puts "Scratch overflow: $val"
+ ifcapable yytrackmaxstackdepth {
+ set x [sqlite3_status SQLITE_STATUS_PARSER_STACK 0]
+ set val [format { max %10d} [lindex $x 2]]
+ puts "Parser stack depth: $val"
+ }
+}
+
+# A procedure to execute SQL
+#
+proc execsql {sql {db db}} {
+ # puts "SQL = $sql"
+ uplevel [list $db eval $sql]
+}
+
+# Execute SQL and catch exceptions.
+#
+proc catchsql {sql {db db}} {
+ # puts "SQL = $sql"
+ set r [catch [list uplevel [list $db eval $sql]] msg]
+ lappend r $msg
+ return $r
+}
+
+# Do an VDBE code dump on the SQL given
+#
+proc explain {sql {db db}} {
+ puts ""
+ puts "addr opcode p1 p2 p3 p4 p5 #"
+ puts "---- ------------ ------ ------ ------ --------------- -- -"
+ $db eval "explain $sql" {} {
+ puts [format {%-4d %-12.12s %-6d %-6d %-6d % -17s %s %s} \
+ $addr $opcode $p1 $p2 $p3 $p4 $p5 $comment
+ ]
+ }
+}
+
+# Show the VDBE program for an SQL statement but omit the Trace
+# opcode at the beginning. This procedure can be used to prove
+# that different SQL statements generate exactly the same VDBE code.
+#
+proc explain_no_trace {sql} {
+ set tr [db eval "EXPLAIN $sql"]
+ return [lrange $tr 7 end]
+}
+
+# Another procedure to execute SQL. This one includes the field
+# names in the returned list.
+#
+proc execsql2 {sql} {
+ set result {}
+ db eval $sql data {
+ foreach f $data(*) {
+ lappend result $f $data($f)
+ }
+ }
+ return $result
+}
+
+# Use the non-callback API to execute multiple SQL statements
+#
+proc stepsql {dbptr sql} {
+ set sql [string trim $sql]
+ set r 0
+ while {[string length $sql]>0} {
+ if {[catch {sqlite3_prepare $dbptr $sql -1 sqltail} vm]} {
+ return [list 1 $vm]
+ }
+ set sql [string trim $sqltail]
+# while {[sqlite_step $vm N VAL COL]=="SQLITE_ROW"} {
+# foreach v $VAL {lappend r $v}
+# }
+ while {[sqlite3_step $vm]=="SQLITE_ROW"} {
+ for {set i 0} {$i<[sqlite3_data_count $vm]} {incr i} {
+ lappend r [sqlite3_column_text $vm $i]
+ }
+ }
+ if {[catch {sqlite3_finalize $vm} errmsg]} {
+ return [list 1 $errmsg]
+ }
+ }
+ return $r
+}
+
+# Do an integrity check of the entire database
+#
+proc integrity_check {name {db db}} {
+ ifcapable integrityck {
+ do_test $name [list execsql {PRAGMA integrity_check} $db] {ok}
+ }
+}
+
+
+# Return true if the SQL statement passed as the second argument uses a
+# statement transaction.
+#
+proc sql_uses_stmt {db sql} {
+ set stmt [sqlite3_prepare $db $sql -1 dummy]
+ set uses [uses_stmt_journal $stmt]
+ sqlite3_finalize $stmt
+ return $uses
+}
+
+proc fix_ifcapable_expr {expr} {
+ set ret ""
+ set state 0
+ for {set i 0} {$i < [string length $expr]} {incr i} {
+ set char [string range $expr $i $i]
+ set newstate [expr {[string is alnum $char] || $char eq "_"}]
+ if {$newstate && !$state} {
+ append ret {$::sqlite_options(}
+ }
+ if {!$newstate && $state} {
+ append ret )
+ }
+ append ret $char
+ set state $newstate
+ }
+ if {$state} {append ret )}
+ return $ret
+}
+
+# Evaluate a boolean expression of capabilities. If true, execute the
+# code. Omit the code if false.
+#
+proc ifcapable {expr code {else ""} {elsecode ""}} {
+ #regsub -all {[a-z_0-9]+} $expr {$::sqlite_options(&)} e2
+ set e2 [fix_ifcapable_expr $expr]
+ if ($e2) {
+ set c [catch {uplevel 1 $code} r]
+ } else {
+ set c [catch {uplevel 1 $elsecode} r]
+ }
+ return -code $c $r
+}
+
+# This proc execs a seperate process that crashes midway through executing
+# the SQL script $sql on database test.db.
+#
+# The crash occurs during a sync() of file $crashfile. When the crash
+# occurs a random subset of all unsynced writes made by the process are
+# written into the files on disk. Argument $crashdelay indicates the
+# number of file syncs to wait before crashing.
+#
+# The return value is a list of two elements. The first element is a
+# boolean, indicating whether or not the process actually crashed or
+# reported some other error. The second element in the returned list is the
+# error message. This is "child process exited abnormally" if the crash
+# occured.
+#
+# crashsql -delay CRASHDELAY -file CRASHFILE ?-blocksize BLOCKSIZE? $sql
+#
+proc crashsql {args} {
+
+ set blocksize ""
+ set crashdelay 1
+ set prngseed 0
+ set tclbody {}
+ set crashfile ""
+ set dc ""
+ set sql [lindex $args end]
+
+ for {set ii 0} {$ii < [llength $args]-1} {incr ii 2} {
+ set z [lindex $args $ii]
+ set n [string length $z]
+ set z2 [lindex $args [expr $ii+1]]
+
+ if {$n>1 && [string first $z -delay]==0} {set crashdelay $z2} \
+ elseif {$n>1 && [string first $z -seed]==0} {set prngseed $z2} \
+ elseif {$n>1 && [string first $z -file]==0} {set crashfile $z2} \
+ elseif {$n>1 && [string first $z -tclbody]==0} {set tclbody $z2} \
+ elseif {$n>1 && [string first $z -blocksize]==0} {set blocksize "-s $z2" } \
+ elseif {$n>1 && [string first $z -characteristics]==0} {set dc "-c {$z2}" } \
+ else { error "Unrecognized option: $z" }
+ }
+
+ if {$crashfile eq ""} {
+ error "Compulsory option -file missing"
+ }
+
+ # $crashfile gets compared to the native filename in
+ # cfSync(), which can be different then what TCL uses by
+ # default, so here we force it to the "nativename" format.
+ set cfile [string map {\\ \\\\} [file nativename [file join [pwd] $crashfile]]]
+
+ set f [open crash.tcl w]
+ puts $f "sqlite3_crash_enable 1"
+ puts $f "sqlite3_crashparams $blocksize $dc $crashdelay $cfile"
+ puts $f "sqlite3_test_control_pending_byte $::sqlite_pending_byte"
+ puts $f "sqlite3 db test.db -vfs crash"
+
+ # This block sets the cache size of the main database to 10
+ # pages. This is done in case the build is configured to omit
+ # "PRAGMA cache_size".
+ puts $f {db eval {SELECT * FROM sqlite_master;}}
+ puts $f {set bt [btree_from_db db]}
+ puts $f {btree_set_cache_size $bt 10}
+ if {$prngseed} {
+ set seed [expr {$prngseed%10007+1}]
+ # puts seed=$seed
+ puts $f "db eval {SELECT randomblob($seed)}"
+ }
+
+ if {[string length $tclbody]>0} {
+ puts $f $tclbody
+ }
+ if {[string length $sql]>0} {
+ puts $f "db eval {"
+ puts $f "$sql"
+ puts $f "}"
+ }
+ close $f
+ set r [catch {
+ exec [info nameofexec] crash.tcl >@stdout
+ } msg]
+
+ # Windows/ActiveState TCL returns a slightly different
+ # error message. We map that to the expected message
+ # so that we don't have to change all of the test
+ # cases.
+ if {$::tcl_platform(platform)=="windows"} {
+ if {$msg=="child killed: unknown signal"} {
+ set msg "child process exited abnormally"
+ }
+ }
+
+ lappend r $msg
+}
+
+# Usage: do_ioerr_test <test number> <options...>
+#
+# This proc is used to implement test cases that check that IO errors
+# are correctly handled. The first argument, <test number>, is an integer
+# used to name the tests executed by this proc. Options are as follows:
+#
+# -tclprep TCL script to run to prepare test.
+# -sqlprep SQL script to run to prepare test.
+# -tclbody TCL script to run with IO error simulation.
+# -sqlbody TCL script to run with IO error simulation.
+# -exclude List of 'N' values not to test.
+# -erc Use extended result codes
+# -persist Make simulated I/O errors persistent
+# -start Value of 'N' to begin with (default 1)
+#
+# -cksum Boolean. If true, test that the database does
+# not change during the execution of the test case.
+#
+proc do_ioerr_test {testname args} {
+
+ set ::ioerropts(-start) 1
+ set ::ioerropts(-cksum) 0
+ set ::ioerropts(-erc) 0
+ set ::ioerropts(-count) 100000000
+ set ::ioerropts(-persist) 1
+ set ::ioerropts(-ckrefcount) 0
+ set ::ioerropts(-restoreprng) 1
+ array set ::ioerropts $args
+
+ # TEMPORARY: For 3.5.9, disable testing of extended result codes. There are
+ # a couple of obscure IO errors that do not return them.
+ set ::ioerropts(-erc) 0
+
+ set ::go 1
+ #reset_prng_state
+ save_prng_state
+ for {set n $::ioerropts(-start)} {$::go} {incr n} {
+ set ::TN $n
+ incr ::ioerropts(-count) -1
+ if {$::ioerropts(-count)<0} break
+
+ # Skip this IO error if it was specified with the "-exclude" option.
+ if {[info exists ::ioerropts(-exclude)]} {
+ if {[lsearch $::ioerropts(-exclude) $n]!=-1} continue
+ }
+ if {$::ioerropts(-restoreprng)} {
+ restore_prng_state
+ }
+
+ # Delete the files test.db and test2.db, then execute the TCL and
+ # SQL (in that order) to prepare for the test case.
+ do_test $testname.$n.1 {
+ set ::sqlite_io_error_pending 0
+ catch {db close}
+ catch {db2 close}
+ catch {forcedelete test.db}
+ catch {forcedelete test.db-journal}
+ catch {forcedelete test2.db}
+ catch {forcedelete test2.db-journal}
+ set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
+ sqlite3_extended_result_codes $::DB $::ioerropts(-erc)
+ if {[info exists ::ioerropts(-tclprep)]} {
+ eval $::ioerropts(-tclprep)
+ }
+ if {[info exists ::ioerropts(-sqlprep)]} {
+ execsql $::ioerropts(-sqlprep)
+ }
+ expr 0
+ } {0}
+
+ # Read the 'checksum' of the database.
+ if {$::ioerropts(-cksum)} {
+ set checksum [cksum]
+ }
+
+ # Set the Nth IO error to fail.
+ do_test $testname.$n.2 [subst {
+ set ::sqlite_io_error_persist $::ioerropts(-persist)
+ set ::sqlite_io_error_pending $n
+ }] $n
+
+ # Create a single TCL script from the TCL and SQL specified
+ # as the body of the test.
+ set ::ioerrorbody {}
+ if {[info exists ::ioerropts(-tclbody)]} {
+ append ::ioerrorbody "$::ioerropts(-tclbody)\n"
+ }
+ if {[info exists ::ioerropts(-sqlbody)]} {
+ append ::ioerrorbody "db eval {$::ioerropts(-sqlbody)}"
+ }
+
+ # Execute the TCL Script created in the above block. If
+ # there are at least N IO operations performed by SQLite as
+ # a result of the script, the Nth will fail.
+ do_test $testname.$n.3 {
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_hardhit 0
+ set r [catch $::ioerrorbody msg]
+ set ::errseen $r
+ set rc [sqlite3_errcode $::DB]
+ if {$::ioerropts(-erc)} {
+ # If we are in extended result code mode, make sure all of the
+ # IOERRs we get back really do have their extended code values.
+ # If an extended result code is returned, the sqlite3_errcode
+ # TCLcommand will return a string of the form: SQLITE_IOERR+nnnn
+ # where nnnn is a number
+ if {[regexp {^SQLITE_IOERR} $rc] && ![regexp {IOERR\+\d} $rc]} {
+ return $rc
+ }
+ } else {
+ # If we are not in extended result code mode, make sure no
+ # extended error codes are returned.
+ if {[regexp {\+\d} $rc]} {
+ return $rc
+ }
+ }
+ # The test repeats as long as $::go is non-zero. $::go starts out
+ # as 1. When a test runs to completion without hitting an I/O
+ # error, that means there is no point in continuing with this test
+ # case so set $::go to zero.
+ #
+ if {$::sqlite_io_error_pending>0} {
+ set ::go 0
+ set q 0
+ set ::sqlite_io_error_pending 0
+ } else {
+ set q 1
+ }
+
+ set s [expr $::sqlite_io_error_hit==0]
+ if {$::sqlite_io_error_hit>$::sqlite_io_error_hardhit && $r==0} {
+ set r 1
+ }
+ set ::sqlite_io_error_hit 0
+
+ # One of two things must have happened. either
+ # 1. We never hit the IO error and the SQL returned OK
+ # 2. An IO error was hit and the SQL failed
+ #
+ #puts "s=$s r=$r q=$q"
+ expr { ($s && !$r && !$q) || (!$s && $r && $q) }
+ } {1}
+
+ set ::sqlite_io_error_hit 0
+ set ::sqlite_io_error_pending 0
+
+ # Check that no page references were leaked. There should be
+ # a single reference if there is still an active transaction,
+ # or zero otherwise.
+ #
+ # UPDATE: If the IO error occurs after a 'BEGIN' but before any
+ # locks are established on database files (i.e. if the error
+ # occurs while attempting to detect a hot-journal file), then
+ # there may 0 page references and an active transaction according
+ # to [sqlite3_get_autocommit].
+ #
+ if {$::go && $::sqlite_io_error_hardhit && $::ioerropts(-ckrefcount)} {
+ do_test $testname.$n.4 {
+ set bt [btree_from_db db]
+ db_enter db
+ array set stats [btree_pager_stats $bt]
+ db_leave db
+ set nRef $stats(ref)
+ expr {$nRef == 0 || ([sqlite3_get_autocommit db]==0 && $nRef == 1)}
+ } {1}
+ }
+
+ # If there is an open database handle and no open transaction,
+ # and the pager is not running in exclusive-locking mode,
+ # check that the pager is in "unlocked" state. Theoretically,
+ # if a call to xUnlock() failed due to an IO error the underlying
+ # file may still be locked.
+ #
+ ifcapable pragma {
+ if { [info commands db] ne ""
+ && $::ioerropts(-ckrefcount)
+ && [db one {pragma locking_mode}] eq "normal"
+ && [sqlite3_get_autocommit db]
+ } {
+ do_test $testname.$n.5 {
+ set bt [btree_from_db db]
+ db_enter db
+ array set stats [btree_pager_stats $bt]
+ db_leave db
+ set stats(state)
+ } 0
+ }
+ }
+
+ # If an IO error occured, then the checksum of the database should
+ # be the same as before the script that caused the IO error was run.
+ #
+ if {$::go && $::sqlite_io_error_hardhit && $::ioerropts(-cksum)} {
+ do_test $testname.$n.6 {
+ catch {db close}
+ catch {db2 close}
+ set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
+ cksum
+ } $checksum
+ }
+
+ set ::sqlite_io_error_hardhit 0
+ set ::sqlite_io_error_pending 0
+ if {[info exists ::ioerropts(-cleanup)]} {
+ catch $::ioerropts(-cleanup)
+ }
+ }
+ set ::sqlite_io_error_pending 0
+ set ::sqlite_io_error_persist 0
+ unset ::ioerropts
+}
+
+# Return a checksum based on the contents of the main database associated
+# with connection $db
+#
+proc cksum {{db db}} {
+ set txt [$db eval {
+ SELECT name, type, sql FROM sqlite_master order by name
+ }]\n
+ foreach tbl [$db eval {
+ SELECT name FROM sqlite_master WHERE type='table' order by name
+ }] {
+ append txt [$db eval "SELECT * FROM $tbl"]\n
+ }
+ foreach prag {default_synchronous default_cache_size} {
+ append txt $prag-[$db eval "PRAGMA $prag"]\n
+ }
+ set cksum [string length $txt]-[md5 $txt]
+ # puts $cksum-[file size test.db]
+ return $cksum
+}
+
+# Generate a checksum based on the contents of the main and temp tables
+# database $db. If the checksum of two databases is the same, and the
+# integrity-check passes for both, the two databases are identical.
+#
+proc allcksum {{db db}} {
+ set ret [list]
+ ifcapable tempdb {
+ set sql {
+ SELECT name FROM sqlite_master WHERE type = 'table' UNION
+ SELECT name FROM sqlite_temp_master WHERE type = 'table' UNION
+ SELECT 'sqlite_master' UNION
+ SELECT 'sqlite_temp_master' ORDER BY 1
+ }
+ } else {
+ set sql {
+ SELECT name FROM sqlite_master WHERE type = 'table' UNION
+ SELECT 'sqlite_master' ORDER BY 1
+ }
+ }
+ set tbllist [$db eval $sql]
+ set txt {}
+ foreach tbl $tbllist {
+ append txt [$db eval "SELECT * FROM $tbl"]
+ }
+ foreach prag {default_cache_size} {
+ append txt $prag-[$db eval "PRAGMA $prag"]\n
+ }
+ # puts txt=$txt
+ return [md5 $txt]
+}
+
+# Generate a checksum based on the contents of a single database with
+# a database connection. The name of the database is $dbname.
+# Examples of $dbname are "temp" or "main".
+#
+proc dbcksum {db dbname} {
+ if {$dbname=="temp"} {
+ set master sqlite_temp_master
+ } else {
+ set master $dbname.sqlite_master
+ }
+ set alltab [$db eval "SELECT name FROM $master WHERE type='table'"]
+ set txt [$db eval "SELECT * FROM $master"]\n
+ foreach tab $alltab {
+ append txt [$db eval "SELECT * FROM $dbname.$tab"]\n
+ }
+ return [md5 $txt]
+}
+
+proc memdebug_log_sql {{filename mallocs.sql}} {
+
+ set data [sqlite3_memdebug_log dump]
+ set nFrame [expr [llength [lindex $data 0]]-2]
+ if {$nFrame < 0} { return "" }
+
+ set database temp
+
+ set tbl "CREATE TABLE ${database}.malloc(zTest, nCall, nByte, lStack);"
+
+ set sql ""
+ foreach e $data {
+ set nCall [lindex $e 0]
+ set nByte [lindex $e 1]
+ set lStack [lrange $e 2 end]
+ append sql "INSERT INTO ${database}.malloc VALUES"
+ append sql "('test', $nCall, $nByte, '$lStack');\n"
+ foreach f $lStack {
+ set frames($f) 1
+ }
+ }
+
+ set tbl2 "CREATE TABLE ${database}.frame(frame INTEGER PRIMARY KEY, line);\n"
+ set tbl3 "CREATE TABLE ${database}.file(name PRIMARY KEY, content);\n"
+
+ foreach f [array names frames] {
+ set addr [format %x $f]
+ set cmd "addr2line -e [info nameofexec] $addr"
+ set line [eval exec $cmd]
+ append sql "INSERT INTO ${database}.frame VALUES($f, '$line');\n"
+
+ set file [lindex [split $line :] 0]
+ set files($file) 1
+ }
+
+ foreach f [array names files] {
+ set contents ""
+ catch {
+ set fd [open $f]
+ set contents [read $fd]
+ close $fd
+ }
+ set contents [string map {' ''} $contents]
+ append sql "INSERT INTO ${database}.file VALUES('$f', '$contents');\n"
+ }
+
+ set fd [open $filename w]
+ puts $fd "BEGIN; ${tbl}${tbl2}${tbl3}${sql} ; COMMIT;"
+ close $fd
+}
+
+# Drop all tables in database [db]
+proc drop_all_tables {{db db}} {
+ ifcapable trigger&&foreignkey {
+ set pk [$db one "PRAGMA foreign_keys"]
+ $db eval "PRAGMA foreign_keys = OFF"
+ }
+ foreach {idx name file} [db eval {PRAGMA database_list}] {
+ if {$idx==1} {
+ set master sqlite_temp_master
+ } else {
+ set master $name.sqlite_master
+ }
+ foreach {t type} [$db eval "
+ SELECT name, type FROM $master
+ WHERE type IN('table', 'view') AND name NOT LIKE 'sqliteX_%' ESCAPE 'X'
+ "] {
+ $db eval "DROP $type \"$t\""
+ }
+ }
+ ifcapable trigger&&foreignkey {
+ $db eval "PRAGMA foreign_keys = $pk"
+ }
+}
+
+#-------------------------------------------------------------------------
+# If a test script is executed with global variable $::G(perm:name) set to
+# "wal", then the tests are run in WAL mode. Otherwise, they should be run
+# in rollback mode. The following Tcl procs are used to make this less
+# intrusive:
+#
+# wal_set_journal_mode ?DB?
+#
+# If running a WAL test, execute "PRAGMA journal_mode = wal" using
+# connection handle DB. Otherwise, this command is a no-op.
+#
+# wal_check_journal_mode TESTNAME ?DB?
+#
+# If running a WAL test, execute a tests case that fails if the main
+# database for connection handle DB is not currently a WAL database.
+# Otherwise (if not running a WAL permutation) this is a no-op.
+#
+# wal_is_wal_mode
+#
+# Returns true if this test should be run in WAL mode. False otherwise.
+#
+proc wal_is_wal_mode {} {
+ expr {[permutation] eq "wal"}
+}
+proc wal_set_journal_mode {{db db}} {
+ if { [wal_is_wal_mode] } {
+ $db eval "PRAGMA journal_mode = WAL"
+ }
+}
+proc wal_check_journal_mode {testname {db db}} {
+ if { [wal_is_wal_mode] } {
+ $db eval { SELECT * FROM sqlite_master }
+ do_test $testname [list $db eval "PRAGMA main.journal_mode"] {wal}
+ }
+}
+
+proc permutation {} {
+ set perm ""
+ catch {set perm $::G(perm:name)}
+ set perm
+}
+proc presql {} {
+ set presql ""
+ catch {set presql $::G(perm:presql)}
+ set presql
+}
+
+#-------------------------------------------------------------------------
+#
+proc slave_test_script {script} {
+
+ # Create the interpreter used to run the test script.
+ interp create tinterp
+
+ # Populate some global variables that tester.tcl expects to see.
+ foreach {var value} [list \
+ ::argv0 $::argv0 \
+ ::argv {} \
+ ::SLAVE 1 \
+ ] {
+ interp eval tinterp [list set $var $value]
+ }
+
+ # The alias used to access the global test counters.
+ tinterp alias set_test_counter set_test_counter
+
+ # Set up the ::cmdlinearg array in the slave.
+ interp eval tinterp [list array set ::cmdlinearg [array get ::cmdlinearg]]
+
+ # Set up the ::G array in the slave.
+ interp eval tinterp [list array set ::G [array get ::G]]
+
+ # Load the various test interfaces implemented in C.
+ load_testfixture_extensions tinterp
+
+ # Run the test script.
+ interp eval tinterp $script
+
+ # Check if the interpreter call [run_thread_tests]
+ if { [interp eval tinterp {info exists ::run_thread_tests_called}] } {
+ set ::run_thread_tests_called 1
+ }
+
+ # Delete the interpreter used to run the test script.
+ interp delete tinterp
+}
+
+proc slave_test_file {zFile} {
+ set tail [file tail $zFile]
+
+ if {[info exists ::G(start:permutation)]} {
+ if {[permutation] != $::G(start:permutation)} return
+ unset ::G(start:permutation)
+ }
+ if {[info exists ::G(start:file)]} {
+ if {$tail != $::G(start:file) && $tail!="$::G(start:file).test"} return
+ unset ::G(start:file)
+ }
+
+ # Remember the value of the shared-cache setting. So that it is possible
+ # to check afterwards that it was not modified by the test script.
+ #
+ ifcapable shared_cache { set scs [sqlite3_enable_shared_cache] }
+
+ # Run the test script in a slave interpreter.
+ #
+ unset -nocomplain ::run_thread_tests_called
+ reset_prng_state
+ set ::sqlite_open_file_count 0
+ set time [time { slave_test_script [list source $zFile] }]
+ set ms [expr [lindex $time 0] / 1000]
+
+ # Test that all files opened by the test script were closed. Omit this
+ # if the test script has "thread" in its name. The open file counter
+ # is not thread-safe.
+ #
+ if {[info exists ::run_thread_tests_called]==0} {
+ do_test ${tail}-closeallfiles { expr {$::sqlite_open_file_count>0} } {0}
+ }
+ set ::sqlite_open_file_count 0
+
+ # Test that the global "shared-cache" setting was not altered by
+ # the test script.
+ #
+ ifcapable shared_cache {
+ set res [expr {[sqlite3_enable_shared_cache] == $scs}]
+ do_test ${tail}-sharedcachesetting [list set {} $res] 1
+ }
+
+ # Add some info to the output.
+ #
+ puts "Time: $tail $ms ms"
+ show_memstats
+}
+
+# Open a new connection on database test.db and execute the SQL script
+# supplied as an argument. Before returning, close the new conection and
+# restore the 4 byte fields starting at header offsets 28, 92 and 96
+# to the values they held before the SQL was executed. This simulates
+# a write by a pre-3.7.0 client.
+#
+proc sql36231 {sql} {
+ set B [hexio_read test.db 92 8]
+ set A [hexio_read test.db 28 4]
+ sqlite3 db36231 test.db
+ catch { db36231 func a_string a_string }
+ execsql $sql db36231
+ db36231 close
+ hexio_write test.db 28 $A
+ hexio_write test.db 92 $B
+ return ""
+}
+
+proc db_save {} {
+ foreach f [glob -nocomplain sv_test.db*] { forcedelete $f }
+ foreach f [glob -nocomplain test.db*] {
+ set f2 "sv_$f"
+ forcecopy $f $f2
+ }
+}
+proc db_save_and_close {} {
+ db_save
+ catch { db close }
+ return ""
+}
+proc db_restore {} {
+ foreach f [glob -nocomplain test.db*] { forcedelete $f }
+ foreach f2 [glob -nocomplain sv_test.db*] {
+ set f [string range $f2 3 end]
+ forcecopy $f2 $f
+ }
+}
+proc db_restore_and_reopen {{dbfile test.db}} {
+ catch { db close }
+ db_restore
+ sqlite3 db $dbfile
+}
+proc db_delete_and_reopen {{file test.db}} {
+ catch { db close }
+ foreach f [glob -nocomplain test.db*] { forcedelete $f }
+ sqlite3 db $file
+}
+
+# If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
+# to non-zero, then set the global variable $AUTOVACUUM to 1.
+set AUTOVACUUM $sqlite_options(default_autovacuum)
+
+source $testdir/thread_common.tcl
+source $testdir/malloc_common.tcl
diff --git a/test/thread001.test b/test/thread001.test
new file mode 100644
index 0000000..7e0893f
--- /dev/null
+++ b/test/thread001.test
@@ -0,0 +1,145 @@
+# 2007 September 7
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: thread001.test,v 1.10 2009/03/26 14:48:07 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+
+source $testdir/tester.tcl
+if {[run_thread_tests]==0} { finish_test ; return }
+
+set ::enable_shared_cache [sqlite3_enable_shared_cache]
+
+set ::NTHREAD 10
+
+# Run this test three times:
+#
+# 1) All threads use the same database handle.
+# 2) All threads use their own database handles.
+# 3) All threads use their own database handles, shared-cache is enabled.
+#
+#
+#
+foreach {tn same_db shared_cache} [list \
+ 1 1 0 \
+ 2 0 0 \
+ 3 0 1 \
+] {
+ # Empty the database.
+ #
+ catchsql { DROP TABLE ab; }
+
+ do_test thread001.$tn.0 {
+ db close
+ sqlite3_enable_shared_cache $shared_cache
+ sqlite3_enable_shared_cache $shared_cache
+ } $shared_cache
+ sqlite3 db test.db -fullmutex 1 -key xyzzy
+
+ set dbconfig ""
+ if {$same_db} {
+ set dbconfig [list set ::DB [sqlite3_connection_pointer db]]
+ }
+
+ # Set up a database and a schema. The database contains a single
+ # table with two columns. The first column ("a") is an INTEGER PRIMARY
+ # KEY. The second contains the md5sum of all rows in the table with
+ # a smaller value stored in column "a".
+ #
+ do_test thread001.$tn.1 {
+ execsql {
+ CREATE TABLE ab(a INTEGER PRIMARY KEY, b);
+ CREATE INDEX ab_i ON ab(b);
+ INSERT INTO ab SELECT NULL, md5sum(a, b) FROM ab;
+ SELECT count(*) FROM ab;
+ }
+ } {1}
+ do_test thread001.$tn.2 {
+ execsql {
+ SELECT
+ (SELECT md5sum(a, b) FROM ab WHERE a < (SELECT max(a) FROM ab)) ==
+ (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab))
+ }
+ } {1}
+ do_test thread001.$tn.3 {
+ execsql { PRAGMA integrity_check }
+ } {ok}
+
+ set thread_program {
+ #sqlthread parent {puts STARTING..}
+ set needToClose 0
+ if {![info exists ::DB]} {
+ set ::DB [sqlthread open test.db xyzzy]
+ #sqlthread parent "puts \"OPEN $::DB\""
+ set needToClose 1
+ }
+
+ for {set i 0} {$i < 100} {incr i} {
+ # Test that the invariant is true.
+ do_test t1 {
+ execsql {
+ SELECT
+ (SELECT md5sum(a, b) FROM ab WHERE a < (SELECT max(a) FROM ab)) ==
+ (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab))
+ }
+ } {1}
+
+ # Add another row to the database.
+ execsql { INSERT INTO ab SELECT NULL, md5sum(a, b) FROM ab }
+ }
+
+ if {$needToClose} {
+ #sqlthread parent "puts \"CLOSE $::DB\""
+ sqlite3_close $::DB
+ }
+ #sqlthread parent "puts \"DONE\""
+
+ list OK
+ }
+
+ # Kick off $::NTHREAD threads:
+ #
+ array unset finished
+ for {set i 0} {$i < $::NTHREAD} {incr i} {
+ thread_spawn finished($i) $dbconfig $thread_procs $thread_program
+ }
+
+ # Wait for all threads to finish, then check they all returned "OK".
+ #
+ for {set i 0} {$i < $::NTHREAD} {incr i} {
+ if {![info exists finished($i)]} {
+ vwait finished($i)
+ }
+ do_test thread001.$tn.4.$i {
+ set ::finished($i)
+ } OK
+ }
+
+ # Check the database still looks Ok.
+ #
+ do_test thread001.$tn.5 {
+ execsql { SELECT count(*) FROM ab; }
+ } [expr {1 + $::NTHREAD*100}]
+ do_test thread001.$tn.6 {
+ execsql {
+ SELECT
+ (SELECT md5sum(a, b) FROM ab WHERE a < (SELECT max(a) FROM ab)) ==
+ (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab))
+ }
+ } {1}
+ do_test thread001.$tn.7 {
+ execsql { PRAGMA integrity_check }
+ } {ok}
+}
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+set sqlite_open_file_count 0
+finish_test
diff --git a/test/thread002.test b/test/thread002.test
new file mode 100644
index 0000000..b39c9ae
--- /dev/null
+++ b/test/thread002.test
@@ -0,0 +1,105 @@
+# 2007 September 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test attempts to deadlock SQLite in shared-cache mode.
+#
+#
+# $Id: thread002.test,v 1.9 2009/03/26 14:48:07 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+
+set do_not_use_codec 1
+source $testdir/tester.tcl
+if {[run_thread_tests]==0} { finish_test ; return }
+
+
+db close
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+set ::NTHREAD 10
+
+do_test thread002.1 {
+ # Create 3 databases with identical schemas:
+ for {set ii 0} {$ii < 3} {incr ii} {
+ forcedelete test${ii}.db
+ sqlite3 db test${ii}.db
+ execsql {
+ CREATE TABLE t1(k, v);
+ CREATE INDEX t1_i ON t1(v);
+ INSERT INTO t1(v) VALUES(1.0);
+ }
+ db close
+ }
+} {}
+
+set thread_program {
+ set ::DB [sqlite3_open test.db]
+ for {set ii 1} {$ii <= 3} {incr ii} {
+ set T [lindex $order [expr $ii-1]]
+ execsql "ATTACH 'test${T}.db' AS aux${ii}"
+ }
+
+ for {set ii 0} {$ii < 100} {incr ii} {
+ execsql { SELECT * FROM aux1.t1 }
+ execsql { INSERT INTO aux1.t1(v) SELECT sum(v) FROM aux2.t1 }
+
+ execsql { SELECT * FROM aux2.t1 }
+ execsql { INSERT INTO aux2.t1(v) SELECT sum(v) FROM aux3.t1 }
+
+ execsql { SELECT * FROM aux3.t1 }
+ execsql { INSERT INTO aux3.t1(v) SELECT sum(v) FROM aux1.t1 }
+
+ execsql { CREATE TABLE IF NOT EXISTS aux1.t2(a,b) }
+ execsql { DROP TABLE IF EXISTS aux1.t2 }
+
+ # if {($ii%10)==0} {puts -nonewline . ; flush stdout}
+ puts -nonewline . ; flush stdout
+ }
+
+ sqlite3_close $::DB
+ list OK
+}
+
+set order_list [list {0 1 2} {0 2 1} {1 0 2} {1 2 0} {2 0 1} {2 1 0}]
+
+array unset finished
+for {set ii 0} {$ii < $::NTHREAD} {incr ii} {
+ set order [lindex $order_list [expr $ii%6]]
+ thread_spawn finished($ii) $thread_procs "set order {$order}" $thread_program
+}
+
+# Wait for all threads to finish, then check they all returned "OK".
+#
+for {set i 0} {$i < $::NTHREAD} {incr i} {
+ if {![info exists finished($i)]} {
+ vwait finished($i)
+ }
+ do_test thread002.2.$i {
+ set ::finished($i)
+ } OK
+}
+
+# Check all three databases are Ok.
+for {set ii 0} {$ii < 3} {incr ii} {
+ do_test thread002.3.$ii {
+ sqlite3 db test${ii}.db
+ set res [list \
+ [execsql {SELECT count(*) FROM t1}] \
+ [execsql {PRAGMA integrity_check}] \
+ ]
+ db close
+ set res
+ } [list [expr 1 + $::NTHREAD*100] ok]
+}
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+set sqlite_open_file_count 0
+finish_test
diff --git a/test/thread003.test b/test/thread003.test
new file mode 100644
index 0000000..8c7440c
--- /dev/null
+++ b/test/thread003.test
@@ -0,0 +1,189 @@
+# 2007 September 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests that attempt to break the pcache module
+# by bombarding it with simultaneous requests from multiple threads.
+#
+# $Id: thread003.test,v 1.8 2009/03/26 14:48:07 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+
+source $testdir/tester.tcl
+if {[run_thread_tests]==0} { finish_test ; return }
+
+# Set up a couple of different databases full of pseudo-randomly
+# generated data.
+#
+do_test thread003.1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ }
+ for {set ii 0} {$ii < 5000} {incr ii} {
+ execsql {INSERT INTO t1 VALUES($ii, randomblob(200), randomblob(200))}
+ }
+ execsql {
+ CREATE INDEX i1 ON t1(a, b);
+ COMMIT;
+ }
+} {}
+do_test thread003.1.2 {
+ expr {([file size test.db] / 1024) > 2000}
+} {1}
+do_test thread003.1.3 {
+ db close
+ forcedelete test2.db
+ sqlite3 db test2.db
+} {}
+do_test thread003.1.4 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ }
+ for {set ii 0} {$ii < 5000} {incr ii} {
+ execsql {INSERT INTO t1 VALUES($ii, randomblob(200), randomblob(200))}
+ }
+ execsql {
+ CREATE INDEX i1 ON t1(a, b);
+ COMMIT;
+ }
+} {}
+do_test thread003.1.5 {
+ expr {([file size test.db] / 1024) > 2000}
+} {1}
+do_test thread003.1.6 {
+ db close
+} {}
+
+
+# This test opens a connection on each of the large (>2MB) database files
+# created by the previous block. The connections do not share a cache.
+# Both "cache_size" parameters are set to 15, so there is a maximum of
+# 30 pages available globally.
+#
+# Then, in separate threads, the databases are randomly queried over and
+# over again. This will force the connections to recycle clean pages from
+# each other. If there is a thread-safety problem, a segfault or assertion
+# failure may eventually occur.
+#
+set nSecond 30
+puts "Starting thread003.2 (should run for ~$nSecond seconds)"
+do_test thread003.2 {
+ foreach zFile {test.db test2.db} {
+ set SCRIPT [format {
+ set iEnd [expr {[clock_seconds] + %d}]
+ set ::DB [sqlthread open %s xyzzy]
+
+ # Set the cache size to 15 pages per cache. 30 available globally.
+ execsql { PRAGMA cache_size = 15 }
+
+ while {[clock_seconds] < $iEnd} {
+ set iQuery [expr {int(rand()*5000)}]
+ execsql " SELECT * FROM t1 WHERE a = $iQuery "
+ }
+
+ sqlite3_close $::DB
+ expr 1
+ } $nSecond $zFile]
+
+ unset -nocomplain finished($zFile)
+ thread_spawn finished($zFile) $thread_procs $SCRIPT
+ }
+ foreach zFile {test.db test2.db} {
+ if {![info exists finished($zFile)]} {
+ vwait finished($zFile)
+ }
+ }
+ expr 0
+} {0}
+
+# This test is the same as the test above, except that each thread also
+# writes to the database. This causes pages to be moved back and forth
+# between the caches internal dirty and clean lists, which is another
+# opportunity for a thread-related bug to present itself.
+#
+set nSecond 30
+puts "Starting thread003.3 (should run for ~$nSecond seconds)"
+do_test thread003.3 {
+ foreach zFile {test.db test2.db} {
+ set SCRIPT [format {
+ set iStart [clock_seconds]
+ set iEnd [expr {[clock_seconds] + %d}]
+ set ::DB [sqlthread open %s xyzzy]
+
+ # Set the cache size to 15 pages per cache. 30 available globally.
+ execsql { PRAGMA cache_size = 15 }
+
+ while {[clock_seconds] < $iEnd} {
+ set iQuery [expr {int(rand()*5000)}]
+ execsql "SELECT * FROM t1 WHERE a = $iQuery"
+ execsql "UPDATE t1 SET b = randomblob(200)
+ WHERE a < $iQuery AND a > $iQuery + 20
+ "
+ }
+
+ sqlite3_close $::DB
+ expr 1
+ } $nSecond $zFile]
+
+ unset -nocomplain finished($zFile)
+ thread_spawn finished($zFile) $thread_procs $SCRIPT
+ }
+ foreach zFile {test.db test2.db} {
+ if {![info exists finished($zFile)]} {
+ vwait finished($zFile)
+ }
+ }
+ expr 0
+} {0}
+
+# In this test case, one thread is continually querying the database.
+# The other thread does not have a database connection, but calls
+# sqlite3_release_memory() over and over again.
+#
+set nSecond 30
+puts "Starting thread003.4 (should run for ~$nSecond seconds)"
+unset -nocomplain finished(1)
+unset -nocomplain finished(2)
+do_test thread003.4 {
+ thread_spawn finished(1) $thread_procs [format {
+ set iEnd [expr {[clock_seconds] + %d}]
+ set ::DB [sqlthread open test.db xyzzy]
+
+ # Set the cache size to 15 pages per cache. 30 available globally.
+ execsql { PRAGMA cache_size = 15 }
+
+ while {[clock_seconds] < $iEnd} {
+ set iQuery [expr {int(rand()*5000)}]
+ execsql "SELECT * FROM t1 WHERE a = $iQuery"
+ }
+
+ sqlite3_close $::DB
+ expr 1
+ } $nSecond]
+ thread_spawn finished(2) [format {
+ set iEnd [expr {[clock_seconds] + %d}]
+
+ while {[clock_seconds] < $iEnd} {
+ sqlite3_release_memory 1000
+ }
+ } $nSecond]
+
+ foreach ii {1 2} {
+ if {![info exists finished($ii)]} {
+ vwait finished($ii)
+ }
+ }
+ expr 0
+} {0}
+
+set sqlite_open_file_count 0
+finish_test
diff --git a/test/thread004.test b/test/thread004.test
new file mode 100644
index 0000000..b2adc46
--- /dev/null
+++ b/test/thread004.test
@@ -0,0 +1,79 @@
+# 2009 February 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: thread004.test,v 1.3 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+
+source $testdir/tester.tcl
+if {[run_thread_tests]==0} { finish_test ; return }
+ifcapable !shared_cache {
+ finish_test
+ return
+}
+if { [info commands sqlite3_table_column_metadata] eq "" } {
+ finish_test
+ return
+}
+
+# Use shared-cache mode for this test.
+#
+db close
+set ::enable_shared_cache [sqlite3_enable_shared_cache]
+sqlite3_enable_shared_cache 1
+
+# Create a table in database test.db
+#
+sqlite3 db test.db
+do_test thread004-1.1 {
+ execsql { CREATE TABLE t1(a, b, c) }
+} {}
+
+do_test thread004-1.2 {
+
+ set ThreadOne {
+ set iStart [clock_seconds]
+ while {[clock_seconds]<$iStart+20} {
+ set ::DB [sqlite3_open test.db]
+ sqlite3_close $::DB
+ }
+ }
+ set ThreadTwo {
+ set ::DB [sqlite3_open test.db]
+ set iStart [clock_seconds]
+ set nErr 0
+ while {[clock_seconds] <$iStart+20} {
+ incr nErr [catch {sqlite3_table_column_metadata $::DB main t1 a}]
+ }
+ sqlite3_close $::DB
+ set nErr
+ }
+
+ # Run two threads. The first thread opens and closes database test.db
+ # repeatedly. Each time this happens, the in-memory schema used by
+ # all connections to test.db is discarded.
+ #
+ # The second thread calls sqlite3_table_column_metadata() over and
+ # over again. Each time it is called, the database schema is loaded
+ # if it is not already in memory. At one point this was crashing.
+ #
+ unset -nocomplain finished
+ thread_spawn finished(1) $thread_procs $ThreadOne
+ thread_spawn finished(2) $thread_procs $ThreadTwo
+
+ foreach t {1 2} {
+ if {![info exists finished($t)]} { vwait finished($t) }
+ }
+
+ set finished(2)
+} {0}
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/thread005.test b/test/thread005.test
new file mode 100644
index 0000000..89cbfe7
--- /dev/null
+++ b/test/thread005.test
@@ -0,0 +1,238 @@
+# 2009 March 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test a race-condition that shows up in shared-cache mode.
+#
+# $Id: thread005.test,v 1.5 2009/03/26 14:48:07 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+
+source $testdir/tester.tcl
+if {[run_thread_tests]==0} { finish_test ; return }
+ifcapable !shared_cache {
+ finish_test
+ return
+}
+
+db close
+
+# Use shared-cache mode for these tests.
+#
+set ::enable_shared_cache [sqlite3_enable_shared_cache]
+sqlite3_enable_shared_cache 1
+
+#-------------------------------------------------------------------------
+# This test attempts to hit the race condition fixed by commit [6363].
+#
+proc runsql {zSql {db {}}} {
+ set rc SQLITE_OK
+ while {$rc=="SQLITE_OK" && $zSql ne ""} {
+ set STMT [sqlite3_prepare_v2 $db $zSql -1 zSql]
+ while {[set rc [sqlite3_step $STMT]] eq "SQLITE_ROW"} { }
+ set rc [sqlite3_finalize $STMT]
+ }
+ return $rc
+}
+do_test thread005-1.1 {
+ sqlite3 db test.db
+ db eval { CREATE TABLE t1(a, b) }
+ db close
+} {}
+for {set ii 2} {$ii < 500} {incr ii} {
+ unset -nocomplain finished
+ thread_spawn finished(0) {sqlite3_open test.db}
+ thread_spawn finished(1) {sqlite3_open test.db}
+ if {![info exists finished(0)]} { vwait finished(0) }
+ if {![info exists finished(1)]} { vwait finished(1) }
+
+ do_test thread005-1.$ii {
+ runsql { BEGIN } $finished(0)
+ runsql { INSERT INTO t1 VALUES(1, 2) } $finished(0)
+
+ # If the race-condition was hit, then $finished(0 and $finished(1)
+ # will not use the same pager cache. In this case the next statement
+ # can be executed succesfully. However, if the race-condition is not
+ # hit, then $finished(1) will be blocked by the write-lock held by
+ # $finished(0) on the shared-cache table t1 and the statement will
+ # return SQLITE_LOCKED.
+ #
+ runsql { SELECT * FROM t1 } $finished(1)
+ } {SQLITE_LOCKED}
+
+ sqlite3_close $finished(0)
+ sqlite3_close $finished(1)
+}
+
+
+#-------------------------------------------------------------------------
+# This test tries to exercise a race-condition that existed in shared-cache
+# mode at one point. The test uses two threads; each has a database connection
+# open on the same shared cache. The schema of the database is:
+#
+# CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
+#
+# One thread is a reader and the other thread a reader and a writer. The
+# writer thread repeats the following transaction as fast as possible:
+#
+# BEGIN;
+# DELETE FROM t1 WHERE a = (SELECT max(a) FROM t1);
+# INSERT INTO t1 VALUES(NULL, NULL);
+# UPDATE t1 SET b = a WHERE a = (SELECT max(a) FROM t1);
+# SELECT count(*) FROM t1 WHERE b IS NULL;
+# COMMIT;
+#
+# The reader thread does the following over and over as fast as possible:
+#
+# BEGIN;
+# SELECT count(*) FROM t1 WHERE b IS NULL;
+# COMMIT;
+#
+# The test runs for 20 seconds or until one of the "SELECT count(*)"
+# statements returns a non-zero value. If an SQLITE_LOCKED error occurs,
+# the connection issues a ROLLBACK immediately to abandon the current
+# transaction.
+#
+# If everything is working correctly, the "SELECT count(*)" statements
+# should never return a value other than 0. The "INSERT" statement
+# executed by the writer adds a row with "b IS NULL" to the table, but
+# the subsequent UPDATE statement sets its "b" value to an integer
+# immediately afterwards.
+#
+# However, before the race-condition was fixed, if the reader's SELECT
+# statement hit an error (say an SQLITE_LOCKED) at the same time as the
+# writer was executing the UPDATE statement, then it could incorrectly
+# rollback the statement-transaction belonging to the UPDATE statement.
+# The UPDATE statement would still be reported as successful to the user,
+# but it would have no effect on the database contents.
+#
+# Note that it has so far only proved possible to hit this race-condition
+# when using an ATTACHed database. There doesn't seem to be any reason
+# for this, other than that operating on an ATTACHed database means there
+# are a few more mutex grabs and releases during the window of time open
+# for the race-condition. Maybe this encourages the scheduler to context
+# switch or something...
+#
+
+forcedelete test.db test2.db
+unset -nocomplain finished
+
+do_test thread005-2.1 {
+ sqlite3 db test.db
+ execsql { ATTACH 'test2.db' AS aux }
+ execsql {
+ CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 2);
+ }
+ db close
+} {}
+
+
+set ThreadProgram {
+ proc execsql {zSql {db {}}} {
+ if {$db eq ""} {set db $::DB}
+
+ set lRes [list]
+ set rc SQLITE_OK
+
+ while {$rc=="SQLITE_OK" && $zSql ne ""} {
+ set STMT [sqlite3_prepare_v2 $db $zSql -1 zSql]
+ while {[set rc [sqlite3_step $STMT]] eq "SQLITE_ROW"} {
+ for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {
+ lappend lRes [sqlite3_column_text $STMT 0]
+ }
+ }
+ set rc [sqlite3_finalize $STMT]
+ }
+
+ if {$rc != "SQLITE_OK"} { error "$rc [sqlite3_errmsg $db]" }
+ return $lRes
+ }
+
+ if {$isWriter} {
+ set Sql {
+ BEGIN;
+ DELETE FROM t1 WHERE a = (SELECT max(a) FROM t1);
+ INSERT INTO t1 VALUES(NULL, NULL);
+ UPDATE t1 SET b = a WHERE a = (SELECT max(a) FROM t1);
+ SELECT count(*) FROM t1 WHERE b IS NULL;
+ COMMIT;
+ }
+ } else {
+ set Sql {
+ BEGIN;
+ SELECT count(*) FROM t1 WHERE b IS NULL;
+ COMMIT;
+ }
+ }
+
+ set ::DB [sqlite3_open test.db]
+
+ execsql { ATTACH 'test2.db' AS aux }
+
+ set result "ok"
+ set finish [expr [clock_seconds]+5]
+ while {$result eq "ok" && [clock_seconds] < $finish} {
+ set rc [catch {execsql $Sql} msg]
+ if {$rc} {
+ if {[string match "SQLITE_LOCKED*" $msg]} {
+ catch { execsql ROLLBACK }
+ } else {
+ sqlite3_close $::DB
+ error $msg
+ }
+ } elseif {$msg ne "0"} {
+ set result "failed"
+ }
+ }
+
+ sqlite3_close $::DB
+ set result
+}
+
+# There is a race-condition in btree.c that means that if two threads
+# attempt to open the same database at roughly the same time, and there
+# does not already exist a shared-cache corresponding to that database,
+# then two shared-caches can be created instead of one. Things still more
+# or less work, but the two database connections do not use the same
+# shared-cache.
+#
+# If the threads run by this test hit this race-condition, the tests
+# fail (because SQLITE_BUSY may be unexpectedly returned instead of
+# SQLITE_LOCKED). To prevent this from happening, open a couple of
+# connections to test.db and test2.db now to make sure that there are
+# already shared-caches in memory for all databases opened by the
+# test threads.
+#
+sqlite3 db test.db
+sqlite3 db test2.db
+
+puts "Running thread-tests for ~20 seconds"
+thread_spawn finished(0) {set isWriter 0} $ThreadProgram
+thread_spawn finished(1) {set isWriter 1} $ThreadProgram
+if {![info exists finished(0)]} { vwait finished(0) }
+if {![info exists finished(1)]} { vwait finished(1) }
+
+catch { db close }
+catch { db2 close }
+
+do_test thread005-2.2 {
+ list $finished(0) $finished(1)
+} {ok ok}
+
+do_test thread005-2.3 {
+ sqlite3 db test.db
+ execsql { ATTACH 'test2.db' AS aux }
+ execsql { SELECT count(*) FROM t1 WHERE b IS NULL }
+} {0}
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/thread1.test b/test/thread1.test
new file mode 100644
index 0000000..0618f2c
--- /dev/null
+++ b/test/thread1.test
@@ -0,0 +1,173 @@
+# 2003 December 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is multithreading behavior
+#
+# $Id: thread1.test,v 1.8 2008/10/07 15:25:49 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Skip this whole file if the thread testing code is not enabled
+#
+if {[run_thread_tests]==0} { finish_test ; return }
+if {[llength [info command thread_step]]==0 || [sqlite3 -has-codec]} {
+ finish_test
+ return
+}
+
+# Create some data to work with
+#
+do_test thread1-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,'abcdefgh');
+ INSERT INTO t1 SELECT a+1, b||b FROM t1;
+ INSERT INTO t1 SELECT a+2, b||b FROM t1;
+ INSERT INTO t1 SELECT a+4, b||b FROM t1;
+ SELECT count(*), max(length(b)) FROM t1;
+ }
+} {8 64}
+
+# Interleave two threads on read access. Then make sure a third
+# thread can write the database. In other words:
+#
+# read-lock A
+# read-lock B
+# unlock A
+# unlock B
+# write-lock C
+#
+# At one point, the write-lock of C would fail on Linux.
+#
+do_test thread1-1.2 {
+ thread_create A test.db
+ thread_create B test.db
+ thread_create C test.db
+ thread_compile A {SELECT a FROM t1}
+ thread_step A
+ thread_result A
+} SQLITE_ROW
+do_test thread1-1.3 {
+ thread_argc A
+} 1
+do_test thread1-1.4 {
+ thread_argv A 0
+} 1
+do_test thread1-1.5 {
+ thread_compile B {SELECT b FROM t1}
+ thread_step B
+ thread_result B
+} SQLITE_ROW
+do_test thread1-1.6 {
+ thread_argc B
+} 1
+do_test thread1-1.7 {
+ thread_argv B 0
+} abcdefgh
+do_test thread1-1.8 {
+ thread_finalize A
+ thread_result A
+} SQLITE_OK
+do_test thread1-1.9 {
+ thread_finalize B
+ thread_result B
+} SQLITE_OK
+do_test thread1-1.10 {
+ thread_compile C {CREATE TABLE t2(x,y)}
+ thread_step C
+ thread_result C
+} SQLITE_DONE
+do_test thread1-1.11 {
+ thread_finalize C
+ thread_result C
+} SQLITE_OK
+do_test thread1-1.12 {
+ catchsql {SELECT name FROM sqlite_master}
+ execsql {SELECT name FROM sqlite_master}
+} {t1 t2}
+
+
+#
+# The following tests - thread1-2.* - test the following scenario:
+#
+# 1: Read-lock thread A
+# 2: Read-lock thread B
+# 3: Attempt to write in thread C -> SQLITE_BUSY
+# 4: Check db write failed from main thread.
+# 5: Unlock from thread A.
+# 6: Attempt to write in thread C -> SQLITE_BUSY
+# 7: Check db write failed from main thread.
+# 8: Unlock from thread B.
+# 9: Attempt to write in thread C -> SQLITE_DONE
+# 10: Finalize the write from thread C
+# 11: Check db write succeeded from main thread.
+#
+do_test thread1-2.1 {
+ thread_halt *
+ thread_create A test.db
+ thread_compile A {SELECT a FROM t1}
+ thread_step A
+ thread_result A
+} SQLITE_ROW
+do_test thread1-2.2 {
+ thread_create B test.db
+ thread_compile B {SELECT b FROM t1}
+ thread_step B
+ thread_result B
+} SQLITE_ROW
+do_test thread1-2.3 {
+ thread_create C test.db
+ thread_compile C {INSERT INTO t2 VALUES(98,99)}
+ thread_step C
+ thread_result C
+ thread_finalize C
+ thread_result C
+} SQLITE_BUSY
+
+do_test thread1-2.4 {
+ execsql {SELECT * FROM t2}
+} {}
+
+do_test thread1-2.5 {
+ thread_finalize A
+ thread_result A
+} SQLITE_OK
+do_test thread1-2.6 {
+ thread_compile C {INSERT INTO t2 VALUES(98,99)}
+ thread_step C
+ thread_result C
+ thread_finalize C
+ thread_result C
+} SQLITE_BUSY
+do_test thread1-2.7 {
+ execsql {SELECT * FROM t2}
+} {}
+do_test thread1-2.8 {
+ thread_finalize B
+ thread_result B
+} SQLITE_OK
+do_test thread1-2.9 {
+ thread_compile C {INSERT INTO t2 VALUES(98,99)}
+ thread_step C
+ thread_result C
+} SQLITE_DONE
+do_test thread1-2.10 {
+ thread_finalize C
+ thread_result C
+} SQLITE_OK
+do_test thread1-2.11 {
+ execsql {SELECT * FROM t2}
+} {98 99}
+
+thread_halt *
+finish_test
diff --git a/test/thread2.test b/test/thread2.test
new file mode 100644
index 0000000..dad2bf2
--- /dev/null
+++ b/test/thread2.test
@@ -0,0 +1,120 @@
+# 2006 January 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is multithreading behavior
+#
+# $Id: thread2.test,v 1.3 2008/10/07 15:25:49 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {[run_thread_tests]==0} { finish_test ; return }
+
+# Skip this whole file if the thread testing code is not enabled
+#
+if {[llength [info command thread_step]]==0 || [sqlite3 -has-codec]} {
+ finish_test
+ return
+}
+
+# Create some data to work with
+#
+do_test thread1-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,'abcdefgh');
+ INSERT INTO t1 SELECT a+1, b||b FROM t1;
+ INSERT INTO t1 SELECT a+2, b||b FROM t1;
+ INSERT INTO t1 SELECT a+4, b||b FROM t1;
+ SELECT count(*), max(length(b)) FROM t1;
+ }
+} {8 64}
+
+# Use the thread_swap command to move the database connections between
+# threads, then verify that they still work.
+#
+do_test thread2-1.2 {
+ db close
+ thread_create A test.db
+ thread_create B test.db
+ thread_swap A B
+ thread_compile A {SELECT a FROM t1 LIMIT 1}
+ thread_result A
+} {SQLITE_OK}
+do_test thread2-1.3 {
+ thread_step A
+ thread_result A
+} {SQLITE_ROW}
+do_test thread2-1.4 {
+ thread_argv A 0
+} {1}
+do_test thread2-1.5 {
+ thread_finalize A
+ thread_result A
+} {SQLITE_OK}
+do_test thread2-1.6 {
+ thread_compile B {SELECT a FROM t1 LIMIT 1}
+ thread_result B
+} {SQLITE_OK}
+do_test thread2-1.7 {
+ thread_step B
+ thread_result B
+} {SQLITE_ROW}
+do_test thread2-1.8 {
+ thread_argv B 0
+} {1}
+do_test thread2-1.9 {
+ thread_finalize B
+ thread_result B
+} {SQLITE_OK}
+
+# Swap them again.
+#
+do_test thread2-2.2 {
+ thread_swap A B
+ thread_compile A {SELECT a FROM t1 LIMIT 1}
+ thread_result A
+} {SQLITE_OK}
+do_test thread2-2.3 {
+ thread_step A
+ thread_result A
+} {SQLITE_ROW}
+do_test thread2-2.4 {
+ thread_argv A 0
+} {1}
+do_test thread2-2.5 {
+ thread_finalize A
+ thread_result A
+} {SQLITE_OK}
+do_test thread2-2.6 {
+ thread_compile B {SELECT a FROM t1 LIMIT 1}
+ thread_result B
+} {SQLITE_OK}
+do_test thread2-2.7 {
+ thread_step B
+ thread_result B
+} {SQLITE_ROW}
+do_test thread2-2.8 {
+ thread_argv B 0
+} {1}
+do_test thread2-2.9 {
+ thread_finalize B
+ thread_result B
+} {SQLITE_OK}
+thread_halt A
+thread_halt B
+
+# Also important to halt the worker threads, which are using spin
+# locks and eating away CPU cycles.
+#
+thread_halt *
+finish_test
diff --git a/test/thread_common.tcl b/test/thread_common.tcl
new file mode 100644
index 0000000..6b17082
--- /dev/null
+++ b/test/thread_common.tcl
@@ -0,0 +1,110 @@
+# 2007 September 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: thread_common.tcl,v 1.5 2009/03/26 14:48:07 danielk1977 Exp $
+
+if {[info exists ::thread_procs]} {
+ return 0
+}
+
+# The following script is sourced by every thread spawned using
+# [sqlthread spawn]:
+set thread_procs {
+
+ # Execute the supplied SQL using database handle $::DB.
+ #
+ proc execsql {sql} {
+
+ set rc SQLITE_LOCKED
+ while {$rc eq "SQLITE_LOCKED"
+ || $rc eq "SQLITE_BUSY"
+ || $rc eq "SQLITE_SCHEMA"} {
+ set res [list]
+
+ enter_db_mutex $::DB
+ set err [catch {
+ set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 dummy_tail]
+ } msg]
+
+ if {$err == 0} {
+ while {[set rc [sqlite3_step $::STMT]] eq "SQLITE_ROW"} {
+ for {set i 0} {$i < [sqlite3_column_count $::STMT]} {incr i} {
+ lappend res [sqlite3_column_text $::STMT 0]
+ }
+ }
+ set rc [sqlite3_finalize $::STMT]
+ } else {
+ if {[lindex $msg 0]=="(6)"} {
+ set rc SQLITE_LOCKED
+ } else {
+ set rc SQLITE_ERROR
+ }
+ }
+
+ if {[string first locked [sqlite3_errmsg $::DB]]>=0} {
+ set rc SQLITE_LOCKED
+ }
+ if {$rc ne "SQLITE_OK"} {
+ set errtxt "$rc - [sqlite3_errmsg $::DB] (debug1)"
+ }
+ leave_db_mutex $::DB
+
+ if {$rc eq "SQLITE_LOCKED" || $rc eq "SQLITE_BUSY"} {
+ #sqlthread parent "puts \"thread [sqlthread id] is busy. rc=$rc\""
+ after 200
+ } else {
+ #sqlthread parent "puts \"thread [sqlthread id] ran $sql\""
+ }
+ }
+
+ if {$rc ne "SQLITE_OK"} {
+ error $errtxt
+ }
+ set res
+ }
+
+ proc do_test {name script result} {
+ set res [eval $script]
+ if {$res ne $result} {
+ error "$name failed: expected \"$result\" got \"$res\""
+ }
+ }
+}
+
+proc thread_spawn {varname args} {
+ sqlthread spawn $varname [join $args {;}]
+}
+
+# Return true if this build can run the multi-threaded tests.
+#
+proc run_thread_tests {{print_warning 0}} {
+ ifcapable !mutex {
+ set zProblem "SQLite build is not threadsafe"
+ }
+ ifcapable mutex_noop {
+ set zProblem "SQLite build uses SQLITE_MUTEX_NOOP"
+ }
+ if {[info commands sqlthread] eq ""} {
+ set zProblem "SQLite build is not threadsafe"
+ }
+ if {![info exists ::tcl_platform(threaded)]} {
+ set zProblem "Linked against a non-threadsafe Tcl build"
+ }
+ if {[info exists zProblem]} {
+ puts "WARNING: Multi-threaded tests skipped: $zProblem"
+ return 0
+ }
+ set ::run_thread_tests_called 1
+ return 1;
+}
+
+return 0
+
diff --git a/test/threadtest1.c b/test/threadtest1.c
new file mode 100644
index 0000000..56fcce3
--- /dev/null
+++ b/test/threadtest1.c
@@ -0,0 +1,289 @@
+/*
+** 2002 January 15
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+** This file implements a simple standalone program used to test whether
+** or not the SQLite library is threadsafe.
+**
+** Testing the thread safety of SQLite is difficult because there are very
+** few places in the code that are even potentially unsafe, and those
+** places execute for very short periods of time. So even if the library
+** is compiled with its mutexes disabled, it is likely to work correctly
+** in a multi-threaded program most of the time.
+**
+** This file is NOT part of the standard SQLite library. It is used for
+** testing only.
+*/
+#include "sqlite.h"
+#include <pthread.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/*
+** Enable for tracing
+*/
+static int verbose = 0;
+
+/*
+** Come here to die.
+*/
+static void Exit(int rc){
+ exit(rc);
+}
+
+extern char *sqlite3_mprintf(const char *zFormat, ...);
+extern char *sqlite3_vmprintf(const char *zFormat, va_list);
+
+/*
+** When a lock occurs, yield.
+*/
+static int db_is_locked(void *NotUsed, int iCount){
+ /* sched_yield(); */
+ if( verbose ) printf("BUSY %s #%d\n", (char*)NotUsed, iCount);
+ usleep(100);
+ return iCount<25;
+}
+
+/*
+** Used to accumulate query results by db_query()
+*/
+struct QueryResult {
+ const char *zFile; /* Filename - used for error reporting */
+ int nElem; /* Number of used entries in azElem[] */
+ int nAlloc; /* Number of slots allocated for azElem[] */
+ char **azElem; /* The result of the query */
+};
+
+/*
+** The callback function for db_query
+*/
+static int db_query_callback(
+ void *pUser, /* Pointer to the QueryResult structure */
+ int nArg, /* Number of columns in this result row */
+ char **azArg, /* Text of data in all columns */
+ char **NotUsed /* Names of the columns */
+){
+ struct QueryResult *pResult = (struct QueryResult*)pUser;
+ int i;
+ if( pResult->nElem + nArg >= pResult->nAlloc ){
+ if( pResult->nAlloc==0 ){
+ pResult->nAlloc = nArg+1;
+ }else{
+ pResult->nAlloc = pResult->nAlloc*2 + nArg + 1;
+ }
+ pResult->azElem = realloc( pResult->azElem, pResult->nAlloc*sizeof(char*));
+ if( pResult->azElem==0 ){
+ fprintf(stdout,"%s: malloc failed\n", pResult->zFile);
+ return 1;
+ }
+ }
+ if( azArg==0 ) return 0;
+ for(i=0; i<nArg; i++){
+ pResult->azElem[pResult->nElem++] =
+ sqlite3_mprintf("%s",azArg[i] ? azArg[i] : "");
+ }
+ return 0;
+}
+
+/*
+** Execute a query against the database. NULL values are returned
+** as an empty string. The list is terminated by a single NULL pointer.
+*/
+char **db_query(sqlite *db, const char *zFile, const char *zFormat, ...){
+ char *zSql;
+ int rc;
+ char *zErrMsg = 0;
+ va_list ap;
+ struct QueryResult sResult;
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ memset(&sResult, 0, sizeof(sResult));
+ sResult.zFile = zFile;
+ if( verbose ) printf("QUERY %s: %s\n", zFile, zSql);
+ rc = sqlite3_exec(db, zSql, db_query_callback, &sResult, &zErrMsg);
+ if( rc==SQLITE_SCHEMA ){
+ if( zErrMsg ) free(zErrMsg);
+ rc = sqlite3_exec(db, zSql, db_query_callback, &sResult, &zErrMsg);
+ }
+ if( verbose ) printf("DONE %s %s\n", zFile, zSql);
+ if( zErrMsg ){
+ fprintf(stdout,"%s: query failed: %s - %s\n", zFile, zSql, zErrMsg);
+ free(zErrMsg);
+ free(zSql);
+ Exit(1);
+ }
+ sqlite3_free(zSql);
+ if( sResult.azElem==0 ){
+ db_query_callback(&sResult, 0, 0, 0);
+ }
+ sResult.azElem[sResult.nElem] = 0;
+ return sResult.azElem;
+}
+
+/*
+** Execute an SQL statement.
+*/
+void db_execute(sqlite *db, const char *zFile, const char *zFormat, ...){
+ char *zSql;
+ int rc;
+ char *zErrMsg = 0;
+ va_list ap;
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ if( verbose ) printf("EXEC %s: %s\n", zFile, zSql);
+ do{
+ rc = sqlite3_exec(db, zSql, 0, 0, &zErrMsg);
+ }while( rc==SQLITE_BUSY );
+ if( verbose ) printf("DONE %s: %s\n", zFile, zSql);
+ if( zErrMsg ){
+ fprintf(stdout,"%s: command failed: %s - %s\n", zFile, zSql, zErrMsg);
+ free(zErrMsg);
+ sqlite3_free(zSql);
+ Exit(1);
+ }
+ sqlite3_free(zSql);
+}
+
+/*
+** Free the results of a db_query() call.
+*/
+void db_query_free(char **az){
+ int i;
+ for(i=0; az[i]; i++){
+ sqlite3_free(az[i]);
+ }
+ free(az);
+}
+
+/*
+** Check results
+*/
+void db_check(const char *zFile, const char *zMsg, char **az, ...){
+ va_list ap;
+ int i;
+ char *z;
+ va_start(ap, az);
+ for(i=0; (z = va_arg(ap, char*))!=0; i++){
+ if( az[i]==0 || strcmp(az[i],z)!=0 ){
+ fprintf(stdout,"%s: %s: bad result in column %d: %s\n",
+ zFile, zMsg, i+1, az[i]);
+ db_query_free(az);
+ Exit(1);
+ }
+ }
+ va_end(ap);
+ db_query_free(az);
+}
+
+pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t sig = PTHREAD_COND_INITIALIZER;
+int thread_cnt = 0;
+
+static void *worker_bee(void *pArg){
+ const char *zFilename = (char*)pArg;
+ char *azErr;
+ int i, cnt;
+ int t = atoi(zFilename);
+ char **az;
+ sqlite *db;
+
+ pthread_mutex_lock(&lock);
+ thread_cnt++;
+ pthread_mutex_unlock(&lock);
+ printf("%s: START\n", zFilename);
+ fflush(stdout);
+ for(cnt=0; cnt<10; cnt++){
+ sqlite3_open(&zFilename[2], &db);
+ if( db==0 ){
+ fprintf(stdout,"%s: can't open\n", zFilename);
+ Exit(1);
+ }
+ sqlite3_busy_handler(db, db_is_locked, zFilename);
+ db_execute(db, zFilename, "CREATE TABLE t%d(a,b,c);", t);
+ for(i=1; i<=100; i++){
+ db_execute(db, zFilename, "INSERT INTO t%d VALUES(%d,%d,%d);",
+ t, i, i*2, i*i);
+ }
+ az = db_query(db, zFilename, "SELECT count(*) FROM t%d", t);
+ db_check(zFilename, "tX size", az, "100", 0);
+ az = db_query(db, zFilename, "SELECT avg(b) FROM t%d", t);
+ db_check(zFilename, "tX avg", az, "101", 0);
+ db_execute(db, zFilename, "DELETE FROM t%d WHERE a>50", t);
+ az = db_query(db, zFilename, "SELECT avg(b) FROM t%d", t);
+ db_check(zFilename, "tX avg2", az, "51", 0);
+ for(i=1; i<=50; i++){
+ char z1[30], z2[30];
+ az = db_query(db, zFilename, "SELECT b, c FROM t%d WHERE a=%d", t, i);
+ sprintf(z1, "%d", i*2);
+ sprintf(z2, "%d", i*i);
+ db_check(zFilename, "readback", az, z1, z2, 0);
+ }
+ db_execute(db, zFilename, "DROP TABLE t%d;", t);
+ sqlite3_close(db);
+ }
+ printf("%s: END\n", zFilename);
+ /* unlink(zFilename); */
+ fflush(stdout);
+ pthread_mutex_lock(&lock);
+ thread_cnt--;
+ if( thread_cnt<=0 ){
+ pthread_cond_signal(&sig);
+ }
+ pthread_mutex_unlock(&lock);
+ return 0;
+}
+
+int main(int argc, char **argv){
+ char *zFile;
+ int i, n;
+ pthread_t id;
+ if( argc>2 && strcmp(argv[1], "-v")==0 ){
+ verbose = 1;
+ argc--;
+ argv++;
+ }
+ if( argc<2 || (n=atoi(argv[1]))<1 ) n = 10;
+ for(i=0; i<n; i++){
+ char zBuf[200];
+ sprintf(zBuf, "testdb-%d", (i+1)/2);
+ unlink(zBuf);
+ }
+ for(i=0; i<n; i++){
+ zFile = sqlite3_mprintf("%d.testdb-%d", i%2+1, (i+2)/2);
+ if( (i%2)==0 ){
+ /* Remove both the database file and any old journal for the file
+ ** being used by this thread and the next one. */
+ char *zDb = &zFile[2];
+ char *zJournal = sqlite3_mprintf("%s-journal", zDb);
+ unlink(zDb);
+ unlink(zJournal);
+ free(zJournal);
+ }
+
+ pthread_create(&id, 0, worker_bee, (void*)zFile);
+ pthread_detach(id);
+ }
+ pthread_mutex_lock(&lock);
+ while( thread_cnt>0 ){
+ pthread_cond_wait(&sig, &lock);
+ }
+ pthread_mutex_unlock(&lock);
+ for(i=0; i<n; i++){
+ char zBuf[200];
+ sprintf(zBuf, "testdb-%d", (i+1)/2);
+ unlink(zBuf);
+ }
+ return 0;
+}
diff --git a/test/threadtest2.c b/test/threadtest2.c
new file mode 100644
index 0000000..25b1d90
--- /dev/null
+++ b/test/threadtest2.c
@@ -0,0 +1,133 @@
+/*
+** 2004 January 13
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+** This file implements a simple standalone program used to test whether
+** or not the SQLite library is threadsafe.
+**
+** This file is NOT part of the standard SQLite library. It is used for
+** testing only.
+*/
+#include <stdio.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <stdlib.h>
+#include "sqlite.h"
+
+/*
+** Name of the database
+*/
+#define DB_FILE "test.db"
+
+/*
+** When this variable becomes non-zero, all threads stop
+** what they are doing.
+*/
+volatile int all_stop = 0;
+
+/*
+** Callback from the integrity check. If the result is anything other
+** than "ok" it means the integrity check has failed. Set the "all_stop"
+** global variable to stop all other activity. Print the error message
+** or print OK if the string "ok" is seen.
+*/
+int check_callback(void *pid, int argc, char **argv, char **notUsed2){
+ int id = (int)pid;
+ if( strcmp(argv[0],"ok") ){
+ all_stop = 1;
+ fprintf(stderr,"id: %s\n", id, argv[0]);
+ }else{
+ /* fprintf(stderr,"%d: OK\n", id); */
+ }
+ return 0;
+}
+
+/*
+** Do an integrity check on the database. If the first integrity check
+** fails, try it a second time.
+*/
+int integrity_check(sqlite *db, int id){
+ int rc;
+ if( all_stop ) return 0;
+ /* fprintf(stderr,"%d: CHECK\n", id); */
+ rc = sqlite3_exec(db, "pragma integrity_check", check_callback, 0, 0);
+ if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
+ fprintf(stderr,"%d, Integrity check returns %d\n", id, rc);
+ }
+ if( all_stop ){
+ sqlite3_exec(db, "pragma integrity_check", check_callback, 0, 0);
+ }
+ return 0;
+}
+
+/*
+** This is the worker thread
+*/
+void *worker(void *workerArg){
+ sqlite *db;
+ int id = (int)workerArg;
+ int rc;
+ int cnt = 0;
+ fprintf(stderr, "Starting worker %d\n", id);
+ while( !all_stop && cnt++<10000 ){
+ if( cnt%100==0 ) printf("%d: %d\n", id, cnt);
+ while( (sqlite3_open(DB_FILE, &db))!=SQLITE_OK ) sched_yield();
+ sqlite3_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0);
+ /* integrity_check(db, id); */
+ if( all_stop ){ sqlite3_close(db); break; }
+ /* fprintf(stderr, "%d: BEGIN\n", id); */
+ rc = sqlite3_exec(db, "INSERT INTO t1 VALUES('bogus data')", 0, 0, 0);
+ /* fprintf(stderr, "%d: END rc=%d\n", id, rc); */
+ sqlite3_close(db);
+ }
+ fprintf(stderr, "Worker %d finished\n", id);
+ return 0;
+}
+
+/*
+** Initialize the database and start the threads
+*/
+int main(int argc, char **argv){
+ sqlite *db;
+ int i, rc;
+ pthread_t aThread[5];
+
+ if( strcmp(DB_FILE,":memory:") ){
+ char *zJournal = sqlite3_mprintf("%s-journal", DB_FILE);
+ unlink(DB_FILE);
+ unlink(zJournal);
+ sqlite3_free(zJournal);
+ }
+ sqlite3_open(DB_FILE, &db);
+ if( db==0 ){
+ fprintf(stderr,"unable to initialize database\n");
+ exit(1);
+ }
+ rc = sqlite3_exec(db, "CREATE TABLE t1(x);", 0,0,0);
+ if( rc ){
+ fprintf(stderr,"cannot create table t1: %d\n", rc);
+ exit(1);
+ }
+ sqlite3_close(db);
+ for(i=0; i<sizeof(aThread)/sizeof(aThread[0]); i++){
+ pthread_create(&aThread[i], 0, worker, (void*)i);
+ }
+ for(i=0; i<sizeof(aThread)/sizeof(aThread[i]); i++){
+ pthread_join(aThread[i], 0);
+ }
+ if( !all_stop ){
+ printf("Everything seems ok.\n");
+ return 0;
+ }else{
+ printf("We hit an error.\n");
+ return 1;
+ }
+}
diff --git a/test/threadtest3.c b/test/threadtest3.c
new file mode 100644
index 0000000..cb7e2fa
--- /dev/null
+++ b/test/threadtest3.c
@@ -0,0 +1,1461 @@
+
+/*
+** The code in this file runs a few multi-threaded test cases using the
+** SQLite library. It can be compiled to an executable on unix using the
+** following command:
+**
+** gcc -O2 threadtest3.c sqlite3.c -ldl -lpthread -lm
+**
+** Then run the compiled program. The exit status is non-zero if any tests
+** failed (hopefully there is also some output to stdout to clarify what went
+** wrong).
+**
+** There are three parts to the code in this file, in the following order:
+**
+** 1. Code for the SQL aggregate function md5sum() copied from
+** tclsqlite.c in the SQLite distribution. The names of all the
+** types and functions in this section begin with "MD5" or "md5".
+**
+** 2. A set of utility functions that may be used to implement
+** multi-threaded test cases. These are all called by test code
+** via macros that help with error reporting. The macros are defined
+** immediately below this comment.
+**
+** 3. The test code itself. And a main() routine to drive the test
+** code.
+*/
+
+/*************************************************************************
+** Start of test code/infrastructure interface macros.
+**
+** The following macros constitute the interface between the test
+** programs and the test infrastructure. Test infrastructure code
+** does not itself use any of these macros. Test code should not
+** call any of the macroname_x() functions directly.
+**
+** See the header comments above the corresponding macroname_x()
+** function for a description of each interface.
+*/
+
+/* Database functions */
+#define opendb(w,x,y,z) (SEL(w), opendb_x(w,x,y,z))
+#define closedb(y,z) (SEL(y), closedb_x(y,z))
+
+/* Functions to execute SQL */
+#define sql_script(x,y,z) (SEL(x), sql_script_x(x,y,z))
+#define integrity_check(x,y) (SEL(x), integrity_check_x(x,y))
+#define execsql_i64(x,y,...) (SEL(x), execsql_i64_x(x,y,__VA_ARGS__))
+#define execsql_text(x,y,z,...) (SEL(x), execsql_text_x(x,y,z,__VA_ARGS__))
+#define execsql(x,y,...) (SEL(x), (void)execsql_i64_x(x,y,__VA_ARGS__))
+
+/* Thread functions */
+#define launch_thread(w,x,y,z) (SEL(w), launch_thread_x(w,x,y,z))
+#define join_all_threads(y,z) (SEL(y), join_all_threads_x(y,z))
+
+/* Timer functions */
+#define setstoptime(y,z) (SEL(y), setstoptime_x(y,z))
+#define timetostop(z) (SEL(z), timetostop_x(z))
+
+/* Report/clear errors. */
+#define test_error(z, ...) test_error_x(z, sqlite3_mprintf(__VA_ARGS__))
+#define clear_error(y,z) clear_error_x(y, z)
+
+/* File-system operations */
+#define filesize(y,z) (SEL(y), filesize_x(y,z))
+#define filecopy(x,y,z) (SEL(x), filecopy_x(x,y,z))
+
+/*
+** End of test code/infrastructure interface macros.
+*************************************************************************/
+
+
+
+
+#include <sqlite3.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <pthread.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest. This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ *
+ * To compute the message digest of a chunk of bytes, declare an
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
+ * needed on buffers full of bytes, and then call MD5Final, which
+ * will fill a supplied 16-byte array with the digest.
+ */
+
+/*
+ * If compiled on a machine that doesn't have a 32-bit integer,
+ * you just set "uint32" to the appropriate datatype for an
+ * unsigned 32-bit integer. For example:
+ *
+ * cc -Duint32='unsigned long' md5.c
+ *
+ */
+#ifndef uint32
+# define uint32 unsigned int
+#endif
+
+struct MD5Context {
+ int isInit;
+ uint32 buf[4];
+ uint32 bits[2];
+ unsigned char in[64];
+};
+typedef struct MD5Context MD5Context;
+
+/*
+ * Note: this code is harmless on little-endian machines.
+ */
+static void byteReverse (unsigned char *buf, unsigned longs){
+ uint32 t;
+ do {
+ t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 |
+ ((unsigned)buf[1]<<8 | buf[0]);
+ *(uint32 *)buf = t;
+ buf += 4;
+ } while (--longs);
+}
+/* The four core functions - F1 is optimized somewhat */
+
+/* #define F1(x, y, z) (x & y | ~x & z) */
+#define F1(x, y, z) (z ^ (x & (y ^ z)))
+#define F2(x, y, z) F1(z, x, y)
+#define F3(x, y, z) (x ^ y ^ z)
+#define F4(x, y, z) (y ^ (x | ~z))
+
+/* This is the central step in the MD5 algorithm. */
+#define MD5STEP(f, w, x, y, z, data, s) \
+ ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
+
+/*
+ * The core of the MD5 algorithm, this alters an existing MD5 hash to
+ * reflect the addition of 16 longwords of new data. MD5Update blocks
+ * the data and converts bytes into longwords for this routine.
+ */
+static void MD5Transform(uint32 buf[4], const uint32 in[16]){
+ register uint32 a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
+
+/*
+ * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
+ * initialization constants.
+ */
+static void MD5Init(MD5Context *ctx){
+ ctx->isInit = 1;
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
+}
+
+/*
+ * Update context to reflect the concatenation of another buffer full
+ * of bytes.
+ */
+static
+void MD5Update(MD5Context *ctx, const unsigned char *buf, unsigned int len){
+ uint32 t;
+
+ /* Update bitcount */
+
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = t + ((uint32)len << 3)) < t)
+ ctx->bits[1]++; /* Carry from low to high */
+ ctx->bits[1] += len >> 29;
+
+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
+
+ /* Handle any leading odd-sized chunks */
+
+ if ( t ) {
+ unsigned char *p = (unsigned char *)ctx->in + t;
+
+ t = 64-t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *)ctx->in);
+ buf += t;
+ len -= t;
+ }
+
+ /* Process data in 64-byte chunks */
+
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *)ctx->in);
+ buf += 64;
+ len -= 64;
+ }
+
+ /* Handle any remaining bytes of data. */
+
+ memcpy(ctx->in, buf, len);
+}
+
+/*
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
+ * 1 0* (64-bit count of bits processed, MSB-first)
+ */
+static void MD5Final(unsigned char digest[16], MD5Context *ctx){
+ unsigned count;
+ unsigned char *p;
+
+ /* Compute number of bytes mod 64 */
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ /* Set the first char of padding to 0x80. This is safe since there is
+ always at least one byte free */
+ p = ctx->in + count;
+ *p++ = 0x80;
+
+ /* Bytes of padding needed to make 64 bytes */
+ count = 64 - 1 - count;
+
+ /* Pad out to 56 mod 64 */
+ if (count < 8) {
+ /* Two lots of padding: Pad the first block to 64 bytes */
+ memset(p, 0, count);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *)ctx->in);
+
+ /* Now fill the next block with 56 bytes */
+ memset(ctx->in, 0, 56);
+ } else {
+ /* Pad block to 56 bytes */
+ memset(p, 0, count-8);
+ }
+ byteReverse(ctx->in, 14);
+
+ /* Append length in bits and transform */
+ ((uint32 *)ctx->in)[ 14 ] = ctx->bits[0];
+ ((uint32 *)ctx->in)[ 15 ] = ctx->bits[1];
+
+ MD5Transform(ctx->buf, (uint32 *)ctx->in);
+ byteReverse((unsigned char *)ctx->buf, 4);
+ memcpy(digest, ctx->buf, 16);
+ memset(ctx, 0, sizeof(ctx)); /* In case it is sensitive */
+}
+
+/*
+** Convert a 128-bit MD5 digest into a 32-digit base-16 number.
+*/
+static void MD5DigestToBase16(unsigned char *digest, char *zBuf){
+ static char const zEncode[] = "0123456789abcdef";
+ int i, j;
+
+ for(j=i=0; i<16; i++){
+ int a = digest[i];
+ zBuf[j++] = zEncode[(a>>4)&0xf];
+ zBuf[j++] = zEncode[a & 0xf];
+ }
+ zBuf[j] = 0;
+}
+
+/*
+** During testing, the special md5sum() aggregate function is available.
+** inside SQLite. The following routines implement that function.
+*/
+static void md5step(sqlite3_context *context, int argc, sqlite3_value **argv){
+ MD5Context *p;
+ int i;
+ if( argc<1 ) return;
+ p = sqlite3_aggregate_context(context, sizeof(*p));
+ if( p==0 ) return;
+ if( !p->isInit ){
+ MD5Init(p);
+ }
+ for(i=0; i<argc; i++){
+ const char *zData = (char*)sqlite3_value_text(argv[i]);
+ if( zData ){
+ MD5Update(p, (unsigned char*)zData, strlen(zData));
+ }
+ }
+}
+static void md5finalize(sqlite3_context *context){
+ MD5Context *p;
+ unsigned char digest[16];
+ char zBuf[33];
+ p = sqlite3_aggregate_context(context, sizeof(*p));
+ MD5Final(digest,p);
+ MD5DigestToBase16(digest, zBuf);
+ sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+}
+
+/*************************************************************************
+** End of copied md5sum() code.
+*/
+
+typedef sqlite3_int64 i64;
+
+typedef struct Error Error;
+typedef struct Sqlite Sqlite;
+typedef struct Statement Statement;
+
+typedef struct Threadset Threadset;
+typedef struct Thread Thread;
+
+/* Total number of errors in this process so far. */
+static int nGlobalErr = 0;
+
+/* Set to true to run in "process" instead of "thread" mode. */
+static int bProcessMode = 0;
+
+struct Error {
+ int rc;
+ int iLine;
+ char *zErr;
+};
+
+struct Sqlite {
+ sqlite3 *db; /* Database handle */
+ Statement *pCache; /* Linked list of cached statements */
+ int nText; /* Size of array at aText[] */
+ char **aText; /* Stored text results */
+};
+
+struct Statement {
+ sqlite3_stmt *pStmt; /* Pre-compiled statement handle */
+ Statement *pNext; /* Next statement in linked-list */
+};
+
+struct Thread {
+ int iTid; /* Thread number within test */
+ int iArg; /* Integer argument passed by caller */
+
+ pthread_t tid; /* Thread id */
+ char *(*xProc)(int, int); /* Thread main proc */
+ Thread *pNext; /* Next in this list of threads */
+};
+
+struct Threadset {
+ int iMaxTid; /* Largest iTid value allocated so far */
+ Thread *pThread; /* Linked list of threads */
+};
+
+static void free_err(Error *p){
+ sqlite3_free(p->zErr);
+ p->zErr = 0;
+ p->rc = 0;
+}
+
+static void print_err(Error *p){
+ if( p->rc!=SQLITE_OK ){
+ printf("Error: (%d) \"%s\" at line %d\n", p->rc, p->zErr, p->iLine);
+ nGlobalErr++;
+ }
+}
+
+static void print_and_free_err(Error *p){
+ print_err(p);
+ free_err(p);
+}
+
+static void system_error(Error *pErr, int iSys){
+ pErr->rc = iSys;
+ pErr->zErr = (char *)sqlite3_malloc(512);
+ strerror_r(iSys, pErr->zErr, 512);
+ pErr->zErr[511] = '\0';
+}
+
+static void sqlite_error(
+ Error *pErr,
+ Sqlite *pDb,
+ const char *zFunc
+){
+ pErr->rc = sqlite3_errcode(pDb->db);
+ pErr->zErr = sqlite3_mprintf(
+ "sqlite3_%s() - %s (%d)", zFunc, sqlite3_errmsg(pDb->db),
+ sqlite3_extended_errcode(pDb->db)
+ );
+}
+
+static void test_error_x(
+ Error *pErr,
+ char *zErr
+){
+ if( pErr->rc==SQLITE_OK ){
+ pErr->rc = 1;
+ pErr->zErr = zErr;
+ }else{
+ sqlite3_free(zErr);
+ }
+}
+
+static void clear_error_x(
+ Error *pErr,
+ int rc
+){
+ if( pErr->rc==rc ){
+ pErr->rc = SQLITE_OK;
+ sqlite3_free(pErr->zErr);
+ pErr->zErr = 0;
+ }
+}
+
+static int busyhandler(void *pArg, int n){
+ usleep(10*1000);
+ return 1;
+}
+
+static void opendb_x(
+ Error *pErr, /* IN/OUT: Error code */
+ Sqlite *pDb, /* OUT: Database handle */
+ const char *zFile, /* Database file name */
+ int bDelete /* True to delete db file before opening */
+){
+ if( pErr->rc==SQLITE_OK ){
+ int rc;
+ if( bDelete ) unlink(zFile);
+ rc = sqlite3_open(zFile, &pDb->db);
+ if( rc ){
+ sqlite_error(pErr, pDb, "open");
+ sqlite3_close(pDb->db);
+ pDb->db = 0;
+ }else{
+ sqlite3_create_function(
+ pDb->db, "md5sum", -1, SQLITE_UTF8, 0, 0, md5step, md5finalize
+ );
+ sqlite3_busy_handler(pDb->db, busyhandler, 0);
+ sqlite3_exec(pDb->db, "PRAGMA synchronous=OFF", 0, 0, 0);
+ }
+ }
+}
+
+static void closedb_x(
+ Error *pErr, /* IN/OUT: Error code */
+ Sqlite *pDb /* OUT: Database handle */
+){
+ int rc;
+ int i;
+ Statement *pIter;
+ Statement *pNext;
+ for(pIter=pDb->pCache; pIter; pIter=pNext){
+ pNext = pIter->pNext;
+ sqlite3_finalize(pIter->pStmt);
+ sqlite3_free(pIter);
+ }
+ for(i=0; i<pDb->nText; i++){
+ sqlite3_free(pDb->aText[i]);
+ }
+ sqlite3_free(pDb->aText);
+ rc = sqlite3_close(pDb->db);
+ if( rc && pErr->rc==SQLITE_OK ){
+ pErr->zErr = sqlite3_mprintf("%s", sqlite3_errmsg(pDb->db));
+ }
+ memset(pDb, 0, sizeof(Sqlite));
+}
+
+static void sql_script_x(
+ Error *pErr, /* IN/OUT: Error code */
+ Sqlite *pDb, /* Database handle */
+ const char *zSql /* SQL script to execute */
+){
+ if( pErr->rc==SQLITE_OK ){
+ pErr->rc = sqlite3_exec(pDb->db, zSql, 0, 0, &pErr->zErr);
+ }
+}
+
+static Statement *getSqlStatement(
+ Error *pErr, /* IN/OUT: Error code */
+ Sqlite *pDb, /* Database handle */
+ const char *zSql /* SQL statement */
+){
+ Statement *pRet;
+ int rc;
+
+ for(pRet=pDb->pCache; pRet; pRet=pRet->pNext){
+ if( 0==strcmp(sqlite3_sql(pRet->pStmt), zSql) ){
+ return pRet;
+ }
+ }
+
+ pRet = sqlite3_malloc(sizeof(Statement));
+ rc = sqlite3_prepare_v2(pDb->db, zSql, -1, &pRet->pStmt, 0);
+ if( rc!=SQLITE_OK ){
+ sqlite_error(pErr, pDb, "prepare_v2");
+ return 0;
+ }
+ assert( 0==strcmp(sqlite3_sql(pRet->pStmt), zSql) );
+
+ pRet->pNext = pDb->pCache;
+ pDb->pCache = pRet;
+ return pRet;
+}
+
+static sqlite3_stmt *getAndBindSqlStatement(
+ Error *pErr, /* IN/OUT: Error code */
+ Sqlite *pDb, /* Database handle */
+ va_list ap /* SQL followed by parameters */
+){
+ Statement *pStatement; /* The SQLite statement wrapper */
+ sqlite3_stmt *pStmt; /* The SQLite statement to return */
+ int i; /* Used to iterate through parameters */
+
+ pStatement = getSqlStatement(pErr, pDb, va_arg(ap, const char *));
+ if( !pStatement ) return 0;
+ pStmt = pStatement->pStmt;
+ for(i=1; i<=sqlite3_bind_parameter_count(pStmt); i++){
+ const char *zName = sqlite3_bind_parameter_name(pStmt, i);
+ void * pArg = va_arg(ap, void*);
+
+ switch( zName[1] ){
+ case 'i':
+ sqlite3_bind_int64(pStmt, i, *(i64 *)pArg);
+ break;
+
+ default:
+ pErr->rc = 1;
+ pErr->zErr = sqlite3_mprintf("Cannot discern type: \"%s\"", zName);
+ pStmt = 0;
+ break;
+ }
+ }
+
+ return pStmt;
+}
+
+static i64 execsql_i64_x(
+ Error *pErr, /* IN/OUT: Error code */
+ Sqlite *pDb, /* Database handle */
+ ... /* SQL and pointers to parameter values */
+){
+ i64 iRet = 0;
+ if( pErr->rc==SQLITE_OK ){
+ sqlite3_stmt *pStmt; /* SQL statement to execute */
+ va_list ap; /* ... arguments */
+ int i; /* Used to iterate through parameters */
+ va_start(ap, pDb);
+ pStmt = getAndBindSqlStatement(pErr, pDb, ap);
+ if( pStmt ){
+ int rc;
+ int first = 1;
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){
+ if( first && sqlite3_column_count(pStmt)>0 ){
+ iRet = sqlite3_column_int64(pStmt, 0);
+ }
+ first = 0;
+ }
+ if( SQLITE_OK!=sqlite3_reset(pStmt) ){
+ sqlite_error(pErr, pDb, "reset");
+ }
+ }
+ va_end(ap);
+ }
+ return iRet;
+}
+
+static char * execsql_text_x(
+ Error *pErr, /* IN/OUT: Error code */
+ Sqlite *pDb, /* Database handle */
+ int iSlot, /* Db handle slot to store text in */
+ ... /* SQL and pointers to parameter values */
+){
+ char *zRet = 0;
+
+ if( iSlot>=pDb->nText ){
+ int nByte = sizeof(char *)*(iSlot+1);
+ pDb->aText = (char **)sqlite3_realloc(pDb->aText, nByte);
+ memset(&pDb->aText[pDb->nText], 0, sizeof(char*)*(iSlot+1-pDb->nText));
+ pDb->nText = iSlot+1;
+ }
+
+ if( pErr->rc==SQLITE_OK ){
+ sqlite3_stmt *pStmt; /* SQL statement to execute */
+ va_list ap; /* ... arguments */
+ int i; /* Used to iterate through parameters */
+ va_start(ap, iSlot);
+ pStmt = getAndBindSqlStatement(pErr, pDb, ap);
+ if( pStmt ){
+ int rc;
+ int first = 1;
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){
+ if( first && sqlite3_column_count(pStmt)>0 ){
+ zRet = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
+ sqlite3_free(pDb->aText[iSlot]);
+ pDb->aText[iSlot] = zRet;
+ }
+ first = 0;
+ }
+ if( SQLITE_OK!=sqlite3_reset(pStmt) ){
+ sqlite_error(pErr, pDb, "reset");
+ }
+ }
+ va_end(ap);
+ }
+
+ return zRet;
+}
+
+static void integrity_check_x(
+ Error *pErr, /* IN/OUT: Error code */
+ Sqlite *pDb /* Database handle */
+){
+ if( pErr->rc==SQLITE_OK ){
+ Statement *pStatement; /* Statement to execute */
+ int rc; /* Return code */
+ char *zErr = 0; /* Integrity check error */
+
+ pStatement = getSqlStatement(pErr, pDb, "PRAGMA integrity_check");
+ if( pStatement ){
+ sqlite3_stmt *pStmt = pStatement->pStmt;
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){
+ const char *z = sqlite3_column_text(pStmt, 0);
+ if( strcmp(z, "ok") ){
+ if( zErr==0 ){
+ zErr = sqlite3_mprintf("%s", z);
+ }else{
+ zErr = sqlite3_mprintf("%z\n%s", zErr, z);
+ }
+ }
+ }
+ sqlite3_reset(pStmt);
+
+ if( zErr ){
+ pErr->zErr = zErr;
+ pErr->rc = 1;
+ }
+ }
+ }
+}
+
+static void *launch_thread_main(void *pArg){
+ Thread *p = (Thread *)pArg;
+ return (void *)p->xProc(p->iTid, p->iArg);
+}
+
+static void launch_thread_x(
+ Error *pErr, /* IN/OUT: Error code */
+ Threadset *pThreads, /* Thread set */
+ char *(*xProc)(int, int), /* Proc to run */
+ int iArg /* Argument passed to thread proc */
+){
+ if( pErr->rc==SQLITE_OK ){
+ int iTid = ++pThreads->iMaxTid;
+ Thread *p;
+ int rc;
+
+ p = (Thread *)sqlite3_malloc(sizeof(Thread));
+ memset(p, 0, sizeof(Thread));
+ p->iTid = iTid;
+ p->iArg = iArg;
+ p->xProc = xProc;
+
+ rc = pthread_create(&p->tid, NULL, launch_thread_main, (void *)p);
+ if( rc!=0 ){
+ system_error(pErr, rc);
+ sqlite3_free(p);
+ }else{
+ p->pNext = pThreads->pThread;
+ pThreads->pThread = p;
+ }
+ }
+}
+
+static void join_all_threads_x(
+ Error *pErr, /* IN/OUT: Error code */
+ Threadset *pThreads /* Thread set */
+){
+ Thread *p;
+ Thread *pNext;
+ for(p=pThreads->pThread; p; p=pNext){
+ void *ret;
+ pNext = p->pNext;
+ int rc;
+ rc = pthread_join(p->tid, &ret);
+ if( rc!=0 ){
+ if( pErr->rc==SQLITE_OK ) system_error(pErr, rc);
+ }else{
+ printf("Thread %d says: %s\n", p->iTid, (ret==0 ? "..." : (char *)ret));
+ }
+ sqlite3_free(p);
+ }
+ pThreads->pThread = 0;
+}
+
+static i64 filesize_x(
+ Error *pErr,
+ const char *zFile
+){
+ i64 iRet = 0;
+ if( pErr->rc==SQLITE_OK ){
+ struct stat sStat;
+ if( stat(zFile, &sStat) ){
+ iRet = -1;
+ }else{
+ iRet = sStat.st_size;
+ }
+ }
+ return iRet;
+}
+
+static void filecopy_x(
+ Error *pErr,
+ const char *zFrom,
+ const char *zTo
+){
+ if( pErr->rc==SQLITE_OK ){
+ i64 nByte = filesize_x(pErr, zFrom);
+ if( nByte<0 ){
+ test_error_x(pErr, sqlite3_mprintf("no such file: %s", zFrom));
+ }else{
+ i64 iOff;
+ char aBuf[1024];
+ int fd1;
+ int fd2;
+ unlink(zTo);
+
+ fd1 = open(zFrom, O_RDONLY);
+ if( fd1<0 ){
+ system_error(pErr, errno);
+ return;
+ }
+ fd2 = open(zTo, O_RDWR|O_CREAT|O_EXCL, 0644);
+ if( fd2<0 ){
+ system_error(pErr, errno);
+ close(fd1);
+ return;
+ }
+
+ iOff = 0;
+ while( iOff<nByte ){
+ int nCopy = sizeof(aBuf);
+ if( nCopy+iOff>nByte ){
+ nCopy = nByte - iOff;
+ }
+ if( nCopy!=read(fd1, aBuf, nCopy) ){
+ system_error(pErr, errno);
+ break;
+ }
+ if( nCopy!=write(fd2, aBuf, nCopy) ){
+ system_error(pErr, errno);
+ break;
+ }
+ iOff += nCopy;
+ }
+
+ close(fd1);
+ close(fd2);
+ }
+ }
+}
+
+/*
+** Used by setstoptime() and timetostop().
+*/
+static double timelimit = 0.0;
+static sqlite3_vfs *pTimelimitVfs = 0;
+
+static void setstoptime_x(
+ Error *pErr, /* IN/OUT: Error code */
+ int nMs /* Milliseconds until "stop time" */
+){
+ if( pErr->rc==SQLITE_OK ){
+ double t;
+ int rc;
+ pTimelimitVfs = sqlite3_vfs_find(0);
+ rc = pTimelimitVfs->xCurrentTime(pTimelimitVfs, &t);
+ if( rc!=SQLITE_OK ){
+ pErr->rc = rc;
+ }else{
+ timelimit = t + ((double)nMs)/(1000.0*60.0*60.0*24.0);
+ }
+ }
+}
+
+static int timetostop_x(
+ Error *pErr /* IN/OUT: Error code */
+){
+ int ret = 1;
+ if( pErr->rc==SQLITE_OK ){
+ double t;
+ int rc;
+ rc = pTimelimitVfs->xCurrentTime(pTimelimitVfs, &t);
+ if( rc!=SQLITE_OK ){
+ pErr->rc = rc;
+ }else{
+ ret = (t >= timelimit);
+ }
+ }
+ return ret;
+}
+
+/*
+** The "Set Error Line" macro.
+*/
+#define SEL(e) ((e)->iLine = ((e)->rc ? (e)->iLine : __LINE__))
+
+
+/*************************************************************************
+**************************************************************************
+**************************************************************************
+** End infrastructure. Begin tests.
+*/
+
+#define WALTHREAD1_NTHREAD 10
+#define WALTHREAD3_NTHREAD 6
+
+static char *walthread1_thread(int iTid, int iArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ int nIter = 0; /* Iterations so far */
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ const char *azSql[] = {
+ "SELECT md5sum(x) FROM t1 WHERE rowid != (SELECT max(rowid) FROM t1)",
+ "SELECT x FROM t1 WHERE rowid = (SELECT max(rowid) FROM t1)",
+ };
+ char *z1, *z2, *z3;
+
+ execsql(&err, &db, "BEGIN");
+ integrity_check(&err, &db);
+ z1 = execsql_text(&err, &db, 1, azSql[0]);
+ z2 = execsql_text(&err, &db, 2, azSql[1]);
+ z3 = execsql_text(&err, &db, 3, azSql[0]);
+ execsql(&err, &db, "COMMIT");
+
+ if( strcmp(z1, z2) || strcmp(z1, z3) ){
+ test_error(&err, "Failed read: %s %s %s", z1, z2, z3);
+ }
+
+ sql_script(&err, &db,
+ "BEGIN;"
+ "INSERT INTO t1 VALUES(randomblob(100));"
+ "INSERT INTO t1 VALUES(randomblob(100));"
+ "INSERT INTO t1 SELECT md5sum(x) FROM t1;"
+ "COMMIT;"
+ );
+ nIter++;
+ }
+ closedb(&err, &db);
+
+ print_and_free_err(&err);
+ return sqlite3_mprintf("%d iterations", nIter);
+}
+
+static char *walthread1_ckpt_thread(int iTid, int iArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ int nCkpt = 0; /* Checkpoints so far */
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ usleep(500*1000);
+ execsql(&err, &db, "PRAGMA wal_checkpoint");
+ if( err.rc==SQLITE_OK ) nCkpt++;
+ clear_error(&err, SQLITE_BUSY);
+ }
+ closedb(&err, &db);
+
+ print_and_free_err(&err);
+ return sqlite3_mprintf("%d checkpoints", nCkpt);
+}
+
+static void walthread1(int nMs){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ Threadset threads = {0}; /* Test threads */
+ int i; /* Iterator variable */
+
+ opendb(&err, &db, "test.db", 1);
+ sql_script(&err, &db,
+ "PRAGMA journal_mode = WAL;"
+ "CREATE TABLE t1(x PRIMARY KEY);"
+ "INSERT INTO t1 VALUES(randomblob(100));"
+ "INSERT INTO t1 VALUES(randomblob(100));"
+ "INSERT INTO t1 SELECT md5sum(x) FROM t1;"
+ );
+
+ setstoptime(&err, nMs);
+ for(i=0; i<WALTHREAD1_NTHREAD; i++){
+ launch_thread(&err, &threads, walthread1_thread, 0);
+ }
+ launch_thread(&err, &threads, walthread1_ckpt_thread, 0);
+ join_all_threads(&err, &threads);
+
+ print_and_free_err(&err);
+}
+
+static char *walthread2_thread(int iTid, int iArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ int anTrans[2] = {0, 0}; /* Number of WAL and Rollback transactions */
+
+ const char *zJournal = "PRAGMA journal_mode = WAL";
+ if( iArg ){ zJournal = "PRAGMA journal_mode = DELETE"; }
+
+ while( !timetostop(&err) ){
+ int journal_exists = 0;
+ int wal_exists = 0;
+
+ opendb(&err, &db, "test.db", 0);
+
+ sql_script(&err, &db, zJournal);
+ clear_error(&err, SQLITE_BUSY);
+ sql_script(&err, &db, "BEGIN");
+ sql_script(&err, &db, "INSERT INTO t1 VALUES(NULL, randomblob(100))");
+
+ journal_exists = (filesize(&err, "test.db-journal") >= 0);
+ wal_exists = (filesize(&err, "test.db-wal") >= 0);
+ if( (journal_exists+wal_exists)!=1 ){
+ test_error(&err, "File system looks incorrect (%d, %d)",
+ journal_exists, wal_exists
+ );
+ }
+ anTrans[journal_exists]++;
+
+ sql_script(&err, &db, "COMMIT");
+ integrity_check(&err, &db);
+ closedb(&err, &db);
+ }
+
+ print_and_free_err(&err);
+ return sqlite3_mprintf("W %d R %d", anTrans[0], anTrans[1]);
+}
+
+static void walthread2(int nMs){
+ Error err = {0};
+ Sqlite db = {0};
+ Threadset threads = {0};
+
+ opendb(&err, &db, "test.db", 1);
+ sql_script(&err, &db, "CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE)");
+ closedb(&err, &db);
+
+ setstoptime(&err, nMs);
+ launch_thread(&err, &threads, walthread2_thread, 0);
+ launch_thread(&err, &threads, walthread2_thread, 0);
+ launch_thread(&err, &threads, walthread2_thread, 1);
+ launch_thread(&err, &threads, walthread2_thread, 1);
+ join_all_threads(&err, &threads);
+
+ print_and_free_err(&err);
+}
+
+static char *walthread3_thread(int iTid, int iArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ i64 iNextWrite; /* Next value this thread will write */
+
+ opendb(&err, &db, "test.db", 0);
+ sql_script(&err, &db, "PRAGMA wal_autocheckpoint = 10");
+
+ iNextWrite = iArg+1;
+ while( 1 ){
+ i64 sum1;
+ i64 sum2;
+ int stop = 0; /* True to stop executing (test timed out) */
+
+ while( 0==(stop = timetostop(&err)) ){
+ i64 iMax = execsql_i64(&err, &db, "SELECT max(cnt) FROM t1");
+ if( iMax+1==iNextWrite ) break;
+ }
+ if( stop ) break;
+
+ sum1 = execsql_i64(&err, &db, "SELECT sum(cnt) FROM t1");
+ sum2 = execsql_i64(&err, &db, "SELECT sum(sum1) FROM t1");
+ execsql_i64(&err, &db,
+ "INSERT INTO t1 VALUES(:iNextWrite, :iSum1, :iSum2)",
+ &iNextWrite, &sum1, &sum2
+ );
+ integrity_check(&err, &db);
+
+ iNextWrite += WALTHREAD3_NTHREAD;
+ }
+
+ closedb(&err, &db);
+ print_and_free_err(&err);
+ return 0;
+}
+
+static void walthread3(int nMs){
+ Error err = {0};
+ Sqlite db = {0};
+ Threadset threads = {0};
+ int i;
+
+ opendb(&err, &db, "test.db", 1);
+ sql_script(&err, &db,
+ "PRAGMA journal_mode = WAL;"
+ "CREATE TABLE t1(cnt PRIMARY KEY, sum1, sum2);"
+ "CREATE INDEX i1 ON t1(sum1);"
+ "CREATE INDEX i2 ON t1(sum2);"
+ "INSERT INTO t1 VALUES(0, 0, 0);"
+ );
+ closedb(&err, &db);
+
+ setstoptime(&err, nMs);
+ for(i=0; i<WALTHREAD3_NTHREAD; i++){
+ launch_thread(&err, &threads, walthread3_thread, i);
+ }
+ join_all_threads(&err, &threads);
+
+ print_and_free_err(&err);
+}
+
+static char *walthread4_reader_thread(int iTid, int iArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ integrity_check(&err, &db);
+ }
+ closedb(&err, &db);
+
+ print_and_free_err(&err);
+ return 0;
+}
+
+static char *walthread4_writer_thread(int iTid, int iArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ i64 iRow = 1;
+
+ opendb(&err, &db, "test.db", 0);
+ sql_script(&err, &db, "PRAGMA wal_autocheckpoint = 15;");
+ while( !timetostop(&err) ){
+ execsql_i64(
+ &err, &db, "REPLACE INTO t1 VALUES(:iRow, randomblob(300))", &iRow
+ );
+ iRow++;
+ if( iRow==10 ) iRow = 0;
+ }
+ closedb(&err, &db);
+
+ print_and_free_err(&err);
+ return 0;
+}
+
+static void walthread4(int nMs){
+ Error err = {0};
+ Sqlite db = {0};
+ Threadset threads = {0};
+
+ opendb(&err, &db, "test.db", 1);
+ sql_script(&err, &db,
+ "PRAGMA journal_mode = WAL;"
+ "CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);"
+ );
+ closedb(&err, &db);
+
+ setstoptime(&err, nMs);
+ launch_thread(&err, &threads, walthread4_reader_thread, 0);
+ launch_thread(&err, &threads, walthread4_writer_thread, 0);
+ join_all_threads(&err, &threads);
+
+ print_and_free_err(&err);
+}
+
+static char *walthread5_thread(int iTid, int iArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ i64 nRow;
+
+ opendb(&err, &db, "test.db", 0);
+ nRow = execsql_i64(&err, &db, "SELECT count(*) FROM t1");
+ closedb(&err, &db);
+
+ if( nRow!=65536 ) test_error(&err, "Bad row count: %d", (int)nRow);
+ print_and_free_err(&err);
+ return 0;
+}
+static void walthread5(int nMs){
+ Error err = {0};
+ Sqlite db = {0};
+ Threadset threads = {0};
+
+ opendb(&err, &db, "test.db", 1);
+ sql_script(&err, &db,
+ "PRAGMA wal_autocheckpoint = 0;"
+ "PRAGMA page_size = 1024;"
+ "PRAGMA journal_mode = WAL;"
+ "CREATE TABLE t1(x);"
+ "BEGIN;"
+ "INSERT INTO t1 VALUES(randomblob(900));"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 2 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 8 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 16 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 32 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 128 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 256 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 512 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 1024 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 2048 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4096 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 8192 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 16384 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 32768 */"
+ "INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 65536 */"
+ "COMMIT;"
+ );
+ filecopy(&err, "test.db", "test_sv.db");
+ filecopy(&err, "test.db-wal", "test_sv.db-wal");
+ closedb(&err, &db);
+
+ filecopy(&err, "test_sv.db", "test.db");
+ filecopy(&err, "test_sv.db-wal", "test.db-wal");
+
+ if( err.rc==SQLITE_OK ){
+ printf(" WAL file is %d bytes,", (int)filesize(&err,"test.db-wal"));
+ printf(" DB file is %d.\n", (int)filesize(&err,"test.db"));
+ }
+
+ setstoptime(&err, nMs);
+ launch_thread(&err, &threads, walthread5_thread, 0);
+ launch_thread(&err, &threads, walthread5_thread, 0);
+ launch_thread(&err, &threads, walthread5_thread, 0);
+ launch_thread(&err, &threads, walthread5_thread, 0);
+ launch_thread(&err, &threads, walthread5_thread, 0);
+ join_all_threads(&err, &threads);
+
+ if( err.rc==SQLITE_OK ){
+ printf(" WAL file is %d bytes,", (int)filesize(&err,"test.db-wal"));
+ printf(" DB file is %d.\n", (int)filesize(&err,"test.db"));
+ }
+
+ print_and_free_err(&err);
+}
+
+/*------------------------------------------------------------------------
+** Test case "cgt_pager_1"
+*/
+#define CALLGRINDTEST1_NROW 10000
+static void cgt_pager_1_populate(Error *pErr, Sqlite *pDb){
+ const char *zInsert = "INSERT INTO t1 VALUES(:iRow, zeroblob(:iBlob))";
+ i64 iRow;
+ sql_script(pErr, pDb, "BEGIN");
+ for(iRow=1; iRow<=CALLGRINDTEST1_NROW; iRow++){
+ i64 iBlob = 600 + (iRow%300);
+ execsql(pErr, pDb, zInsert, &iRow, &iBlob);
+ }
+ sql_script(pErr, pDb, "COMMIT");
+}
+static void cgt_pager_1_update(Error *pErr, Sqlite *pDb){
+ const char *zUpdate = "UPDATE t1 SET b = zeroblob(:iBlob) WHERE a = :iRow";
+ i64 iRow;
+ sql_script(pErr, pDb, "BEGIN");
+ for(iRow=1; iRow<=CALLGRINDTEST1_NROW; iRow++){
+ i64 iBlob = 600 + ((iRow+100)%300);
+ execsql(pErr, pDb, zUpdate, &iBlob, &iRow);
+ }
+ sql_script(pErr, pDb, "COMMIT");
+}
+static void cgt_pager_1_read(Error *pErr, Sqlite *pDb){
+ i64 iRow;
+ sql_script(pErr, pDb, "BEGIN");
+ for(iRow=1; iRow<=CALLGRINDTEST1_NROW; iRow++){
+ execsql(pErr, pDb, "SELECT * FROM t1 WHERE a = :iRow", &iRow);
+ }
+ sql_script(pErr, pDb, "COMMIT");
+}
+static void cgt_pager_1(int nMs){
+ void (*xSub)(Error *, Sqlite *);
+ Error err = {0};
+ Sqlite db = {0};
+
+ opendb(&err, &db, "test.db", 1);
+ sql_script(&err, &db,
+ "PRAGMA cache_size = 2000;"
+ "PRAGMA page_size = 1024;"
+ "CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);"
+ );
+
+ xSub = cgt_pager_1_populate; xSub(&err, &db);
+ xSub = cgt_pager_1_update; xSub(&err, &db);
+ xSub = cgt_pager_1_read; xSub(&err, &db);
+
+ closedb(&err, &db);
+ print_and_free_err(&err);
+}
+
+/*------------------------------------------------------------------------
+** Test case "dynamic_triggers"
+**
+** Two threads executing statements that cause deeply nested triggers
+** to fire. And one thread busily creating and deleting triggers. This
+** is an attempt to find a bug reported to us.
+*/
+
+static char *dynamic_triggers_1(int iTid, int iArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ int nDrop = 0;
+ int nCreate = 0;
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ int i;
+
+ for(i=1; i<9; i++){
+ char *zSql = sqlite3_mprintf(
+ "CREATE TRIGGER itr%d BEFORE INSERT ON t%d BEGIN "
+ "INSERT INTO t%d VALUES(new.x, new.y);"
+ "END;", i, i, i+1
+ );
+ execsql(&err, &db, zSql);
+ sqlite3_free(zSql);
+ nCreate++;
+ }
+
+ for(i=1; i<9; i++){
+ char *zSql = sqlite3_mprintf(
+ "CREATE TRIGGER dtr%d BEFORE DELETE ON t%d BEGIN "
+ "DELETE FROM t%d WHERE x = old.x; "
+ "END;", i, i, i+1
+ );
+ execsql(&err, &db, zSql);
+ sqlite3_free(zSql);
+ nCreate++;
+ }
+
+ for(i=1; i<9; i++){
+ char *zSql = sqlite3_mprintf("DROP TRIGGER itr%d", i);
+ execsql(&err, &db, zSql);
+ sqlite3_free(zSql);
+ nDrop++;
+ }
+
+ for(i=1; i<9; i++){
+ char *zSql = sqlite3_mprintf("DROP TRIGGER dtr%d", i);
+ execsql(&err, &db, zSql);
+ sqlite3_free(zSql);
+ nDrop++;
+ }
+ }
+
+ print_and_free_err(&err);
+ return sqlite3_mprintf("%d created, %d dropped", nCreate, nDrop);
+}
+
+static char *dynamic_triggers_2(int iTid, int iArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ i64 iVal = 0;
+ int nInsert = 0;
+ int nDelete = 0;
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ do {
+ iVal = (iVal+1)%100;
+ execsql(&err, &db, "INSERT INTO t1 VALUES(:iX, :iY+1)", &iVal, &iVal);
+ nInsert++;
+ } while( iVal );
+
+ do {
+ iVal = (iVal+1)%100;
+ execsql(&err, &db, "DELETE FROM t1 WHERE x = :iX", &iVal);
+ nDelete++;
+ } while( iVal );
+ }
+
+ print_and_free_err(&err);
+ return sqlite3_mprintf("%d inserts, %d deletes", nInsert, nDelete);
+}
+
+static void dynamic_triggers(int nMs){
+ Error err = {0};
+ Sqlite db = {0};
+ Threadset threads = {0};
+
+ opendb(&err, &db, "test.db", 1);
+ sql_script(&err, &db,
+ "PRAGMA page_size = 1024;"
+ "PRAGMA journal_mode = WAL;"
+ "CREATE TABLE t1(x, y);"
+ "CREATE TABLE t2(x, y);"
+ "CREATE TABLE t3(x, y);"
+ "CREATE TABLE t4(x, y);"
+ "CREATE TABLE t5(x, y);"
+ "CREATE TABLE t6(x, y);"
+ "CREATE TABLE t7(x, y);"
+ "CREATE TABLE t8(x, y);"
+ "CREATE TABLE t9(x, y);"
+ );
+
+ setstoptime(&err, nMs);
+
+ sqlite3_enable_shared_cache(1);
+ launch_thread(&err, &threads, dynamic_triggers_2, 0);
+ launch_thread(&err, &threads, dynamic_triggers_2, 0);
+ sqlite3_enable_shared_cache(0);
+
+ sleep(2);
+
+ launch_thread(&err, &threads, dynamic_triggers_2, 0);
+ launch_thread(&err, &threads, dynamic_triggers_1, 0);
+
+ join_all_threads(&err, &threads);
+
+ print_and_free_err(&err);
+}
+
+#include "tt3_checkpoint.c"
+
+int main(int argc, char **argv){
+ struct ThreadTest {
+ void (*xTest)(int);
+ const char *zTest;
+ int nMs;
+ } aTest[] = {
+ { walthread1, "walthread1", 20000 },
+ { walthread2, "walthread2", 20000 },
+ { walthread3, "walthread3", 20000 },
+ { walthread4, "walthread4", 20000 },
+ { walthread5, "walthread5", 1000 },
+ { walthread5, "walthread5", 1000 },
+
+ { cgt_pager_1, "cgt_pager_1", 0 },
+ { dynamic_triggers, "dynamic_triggers", 20000 },
+
+ { checkpoint_starvation_1, "checkpoint_starvation_1", 10000 },
+ { checkpoint_starvation_2, "checkpoint_starvation_2", 10000 },
+ };
+
+ int i;
+ char *zTest = 0;
+ int nTest = 0;
+ int bTestfound = 0;
+ int bPrefix = 0;
+
+ if( argc>2 ) goto usage;
+ if( argc==2 ){
+ zTest = argv[1];
+ nTest = strlen(zTest);
+ if( zTest[nTest-1]=='*' ){
+ nTest--;
+ bPrefix = 1;
+ }
+ }
+
+ sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
+
+ for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){
+ char const *z = aTest[i].zTest;
+ int n = strlen(z);
+ if( !zTest || ((bPrefix || n==nTest) && 0==strncmp(zTest, z, nTest)) ){
+ printf("Running %s for %d seconds...\n", z, aTest[i].nMs/1000);
+ aTest[i].xTest(aTest[i].nMs);
+ bTestfound++;
+ }
+ }
+ if( bTestfound==0 ) goto usage;
+
+ printf("Total of %d errors across all tests\n", nGlobalErr);
+ return (nGlobalErr>0 ? 255 : 0);
+
+ usage:
+ printf("Usage: %s [testname|testprefix*]\n", argv[0]);
+ printf("Available tests are:\n");
+ for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){
+ printf(" %s\n", aTest[i].zTest);
+ }
+
+ return 254;
+}
+
+
diff --git a/test/tkt-02a8e81d44.test b/test/tkt-02a8e81d44.test
new file mode 100644
index 0000000..4a48fb0
--- /dev/null
+++ b/test/tkt-02a8e81d44.test
@@ -0,0 +1,31 @@
+# 2010 April 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [02a8e81d44] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-02a838-1.1 {
+ execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(4);
+ INSERT INTO t1 VALUES(5);
+ SELECT * FROM (SELECT a FROM t1 LIMIT 1) UNION ALL SELECT 3;
+ }
+} {1 3}
+
+finish_test
diff --git a/test/tkt-26ff0c2d1e.test b/test/tkt-26ff0c2d1e.test
new file mode 100644
index 0000000..83a4f3d
--- /dev/null
+++ b/test/tkt-26ff0c2d1e.test
@@ -0,0 +1,33 @@
+# 2010 May 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script testing a bug found in the OP_Variable optimizer
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test bug-20100512-1 {
+ set DB [sqlite3_connection_pointer db]
+ set SQL {SELECT case when 1 then 99 else ? end + ?}
+ set STMT [sqlite3_prepare_v2 $DB $SQL -1 TAIL]
+ set TAIL
+} {}
+do_test bug-20100512-2 {
+ sqlite3_bind_parameter_count $STMT
+} 2
+do_test bug-20100512-3 {
+ sqlite3_bind_int $STMT 1 123
+ sqlite3_bind_int $STMT 2 456
+ sqlite3_step $STMT
+ sqlite3_column_int $STMT 0
+} {555}
+sqlite3_finalize $STMT
diff --git a/test/tkt-2d1a5c67d.test b/test/tkt-2d1a5c67d.test
new file mode 100644
index 0000000..bf9595f
--- /dev/null
+++ b/test/tkt-2d1a5c67d.test
@@ -0,0 +1,127 @@
+# 2011 May 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has
+# been resolved.
+#
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-2d1a5c67d
+
+ifcapable {!wal || !vtab} {finish_test; return}
+
+for {set ii 1} {$ii<=10} {incr ii} {
+ do_test tkt-2d1a5c67d.1.$ii {
+ db close
+ forcedelete test.db test.db-wal
+ sqlite3 db test.db
+ db eval "PRAGMA cache_size=$::ii"
+ db eval {
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(a,b);
+ CREATE INDEX t1b ON t1(b);
+ CREATE TABLE t2(x,y UNIQUE);
+ INSERT INTO t2 VALUES(3,4);
+ BEGIN;
+ INSERT INTO t1(a,b) VALUES(1,2);
+ SELECT 'A', * FROM t2 WHERE y=4;
+ SELECT 'B', * FROM t1;
+ COMMIT;
+ SELECT 'C', * FROM t1;
+ }
+ } {wal A 3 4 B 1 2 C 1 2}
+}
+
+db close
+forcedelete test.db test.db-wal
+sqlite3 db test.db
+register_wholenumber_module db
+db eval {
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(a,b);
+ CREATE INDEX t1b ON t1(b);
+ CREATE TABLE t2(x,y);
+ CREATE VIRTUAL TABLE nums USING wholenumber;
+ INSERT INTO t2 SELECT value, randomblob(1000) FROM nums
+ WHERE value BETWEEN 1 AND 1000;
+}
+
+for {set ii 1} {$ii<=10} {incr ii} {
+ do_test tkt-2d1a5c67d.2.$ii {
+ db eval "PRAGMA cache_size=$::ii"
+ db eval {
+ DELETE FROM t1;
+ BEGIN;
+ INSERT INTO t1(a,b) VALUES(1,2);
+ SELECT sum(length(y)) FROM t2;
+ COMMIT;
+ SELECT * FROM t1;
+ }
+ } {1000000 1 2}
+}
+
+db close
+sqlite3 db test.db
+
+
+do_execsql_test 3.1 {
+ PRAGMA cache_size = 10;
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t4(a);
+}
+
+do_execsql_test 3.2 {
+ INSERT INTO t3 VALUES(NULL, randomblob(500));
+ INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 2
+ INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 4
+ INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 8
+ INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 16
+ INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 32
+ INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 64
+ INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 128
+}
+
+do_execsql_test 3.3 {
+ BEGIN;
+ INSERT INTO t4 VALUES('xyz');
+}
+
+do_test 3.4 {
+ set blobs [list]
+ for {set i 1} {$i<100} {incr i} {
+ set b [db incrblob -readonly t3 b $i]
+ read $b
+ lappend blobs $b
+ }
+
+ execsql COMMIT
+ execsql { SELECT * FROM t4 WHERE a = 'xyz' }
+} {xyz}
+
+do_test 3.5 {
+ foreach b $blobs { close $b }
+ execsql { SELECT * FROM t4 WHERE a = 'xyz' }
+} {xyz}
+
+# Check that recovery works on the WAL file.
+#
+forcedelete test.db2-wal test.db2
+do_test 3.6 {
+ copy_file test.db-wal test.db2-wal
+ copy_file test.db test.db2
+ sqlite3 db2 test.db2
+ execsql { SELECT * FROM t4 WHERE a = 'xyz' } db2
+} {xyz}
+
+finish_test
diff --git a/test/tkt-2ea2425d34.test b/test/tkt-2ea2425d34.test
new file mode 100644
index 0000000..9793d48
--- /dev/null
+++ b/test/tkt-2ea2425d34.test
@@ -0,0 +1,31 @@
+# 2009 September 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [2ea2425d34be] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-2ea24-1.1 {
+ db eval {
+ PRAGMA encoding=UTF16;
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,'abc');
+ INSERT INTO t1 VALUES(2,'def');
+ INSERT INTO t1 VALUES(3,'ghi');
+ SELECT a FROM t1 WHERE length(b)<10 AND b<>'def' ORDER BY a;
+ }
+} {1 3}
+
+finish_test
diff --git a/test/tkt-31338dca7e.test b/test/tkt-31338dca7e.test
new file mode 100644
index 0000000..9423c68
--- /dev/null
+++ b/test/tkt-31338dca7e.test
@@ -0,0 +1,178 @@
+# 2009 December 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [31338dca7e] has been
+# fixed. Ticket [31338dca7e] demonstrates problems with the OR-clause
+# optimization in joins where the WHERE clause is of the form
+#
+# (x AND y) OR z
+#
+# And the x and y subterms from from different tables of the join.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-31338-1.1 {
+ db eval {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(y);
+ INSERT INTO t1 VALUES(111);
+ INSERT INTO t1 VALUES(222);
+ INSERT INTO t2 VALUES(333);
+ INSERT INTO t2 VALUES(444);
+ SELECT * FROM t1, t2
+ WHERE (x=111 AND y!=444) OR x=222
+ ORDER BY x, y;
+ }
+} {111 333 222 333 222 444}
+
+do_test tkt-31338-1.2 {
+ db eval {
+ CREATE INDEX t1x ON t1(x);
+ SELECT * FROM t1, t2
+ WHERE (x=111 AND y!=444) OR x=222
+ ORDER BY x, y;
+ }
+} {111 333 222 333 222 444}
+
+do_test tkt-31338-2.1 {
+ db eval {
+ CREATE TABLE t3(v,w);
+ CREATE TABLE t4(x,y);
+ CREATE TABLE t5(z);
+ INSERT INTO t3 VALUES(111,222);
+ INSERT INTO t3 VALUES(333,444);
+ INSERT INTO t4 VALUES(222,333);
+ INSERT INTO t4 VALUES(444,555);
+ INSERT INTO t5 VALUES(888);
+ INSERT INTO t5 VALUES(999);
+
+ SELECT * FROM t3, t4, t5
+ WHERE (v=111 AND x=w AND z!=999) OR (v=333 AND x=444)
+ ORDER BY v, w, x, y, z;
+ }
+} {111 222 222 333 888 333 444 444 555 888 333 444 444 555 999}
+
+do_test tkt-31338-2.2 {
+ db eval {
+ CREATE INDEX t3v ON t3(v);
+ CREATE INDEX t4x ON t4(x);
+ SELECT * FROM t3, t4, t5
+ WHERE (v=111 AND x=w AND z!=999) OR (v=333 AND x=444)
+ ORDER BY v, w, x, y, z;
+ }
+} {111 222 222 333 888 333 444 444 555 888 333 444 444 555 999}
+
+
+# Ticket [2c2de252666662f5459904fc33a9f2956cbff23c]
+#
+do_test tkt-31338-3.1 {
+ foreach x [db eval {SELECT name FROM sqlite_master WHERE type='table'}] {
+ db eval "DROP TABLE $x"
+ }
+ db eval {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE TABLE t2(e,f);
+ INSERT INTO t1 VALUES(1,2,3,4);
+ INSERT INTO t2 VALUES(10,-8);
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ CREATE TABLE t3(g);
+ INSERT INTO t3 VALUES(4);
+ CREATE TABLE t4(h);
+ INSERT INTO t4 VALUES(5);
+
+ SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h
+ WHERE (a=1 AND h=4)
+ OR (b IN (
+ SELECT x FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)
+ GROUP BY e
+ ));
+ }
+} {4 1 2 3 4 {}}
+do_test tkt-31338-3.2 {
+ db eval {
+ SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h
+ WHERE (a=1 AND h=4)
+ OR (b=2 AND b NOT IN (
+ SELECT x+1 FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)
+ GROUP BY e
+ ));
+ }
+} {4 1 2 3 4 {}}
+do_test tkt-31338-3.3 {
+ db eval {
+ SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h
+ WHERE (+a=1 AND h=4)
+ OR (b IN (
+ SELECT x FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)
+ GROUP BY e
+ ));
+ }
+} {4 1 2 3 4 {}}
+do_test tkt-31338-3.4 {
+ db eval {
+ SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h
+ WHERE (a=1 AND h=4)
+ OR (+b IN (
+ SELECT x FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)
+ GROUP BY e
+ ));
+ }
+} {4 1 2 3 4 {}}
+
+do_test tkt-31338-3.5 {
+ db eval {
+ CREATE TABLE t5(a,b,c,d,e,f);
+ CREATE TABLE t6(g,h);
+ CREATE TRIGGER t6r AFTER INSERT ON t6 BEGIN
+ INSERT INTO t5
+ SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h
+ WHERE (a=1 AND h=4)
+ OR (b IN (
+ SELECT x FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)
+ GROUP BY e
+ ));
+ END;
+ INSERT INTO t6 VALUES(88,99);
+ SELECT * FROM t5;
+ }
+} {4 1 2 3 4 {}}
+
+do_test tkt-31338-3.6 {
+ db eval {
+ INSERT INTO t1 VALUES(2,4,3,4);
+ INSERT INTO t1 VALUES(99,101,3,4);
+ INSERT INTO t1 VALUES(98,97,3,4);
+ SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h
+ WHERE (a=1 AND h=4)
+ OR (b IN (
+ SELECT x+a FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)
+ GROUP BY e
+ ));
+ }
+} {4 2 4 3 4 {} 4 99 101 3 4 {}}
+
+do_test tkt-31338-3.7 {
+ db eval {
+ SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h
+ WHERE (a=1 AND h=4)
+ OR (b IN (
+ SELECT x FROM (SELECT e+f+a AS x, e FROM t2 ORDER BY 1 LIMIT 2)
+ GROUP BY e
+ ));
+ }
+} {4 2 4 3 4 {} 4 99 101 3 4 {}}
+
+
+finish_test
diff --git a/test/tkt-313723c356.test b/test/tkt-313723c356.test
new file mode 100644
index 0000000..8c08c34
--- /dev/null
+++ b/test/tkt-313723c356.test
@@ -0,0 +1,57 @@
+# 2010 September 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [313723c356] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+ifcapable !wal { finish_test ; return }
+
+do_execsql_test tkt-313723c356.1 {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(randomblob(400), randomblob(400));
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
+} {wal}
+faultsim_save_and_close
+
+do_faultsim_test tkt-313723c356.2 -faults shmerr* -prep {
+ faultsim_restore_and_reopen
+ sqlite3 db2 test.db
+ db eval { SELECT * FROM t1 }
+ db2 eval { UPDATE t1 SET a = randomblob(399) }
+ db2 close
+} -body {
+ # At this point, the cache contains all of table t1 and none of index i1. The
+ # cache is out of date. When the bug existed and the right xShmLock() fails
+ # in the following statement, the internal cache of the WAL header was
+ # being updated, but the contents of the page-cache not flushed. This causes
+ # the integrity-check in the "-test" code to fail, as it is comparing the
+ # cached (out-of-date) version of table t1 with the on disk (up-to-date)
+ # version of index i1.
+ #
+ execsql { SELECT min(rowid) FROM t1 }
+} -test {
+ faultsim_test_result {0 1}
+ faultsim_integrity_check
+}
+
+finish_test
diff --git a/test/tkt-38cb5df375.test b/test/tkt-38cb5df375.test
new file mode 100644
index 0000000..47b0b55
--- /dev/null
+++ b/test/tkt-38cb5df375.test
@@ -0,0 +1,321 @@
+# 2010 October 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that ticket [38cb5df375078d3f9711482d2a1615d09f6b3f33] has
+# been resolved.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-38cb5df375.0 {
+ execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 SELECT a+2 FROM t1;
+ INSERT INTO t1 SELECT a+4 FROM t1;
+ }
+} {}
+
+foreach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {
+ do_test tkt-38cb5df375.1.$ii {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY a)
+ UNION ALL SELECT 9 FROM (SELECT a FROM t1)
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 4 5 6 7 8 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {
+ do_test tkt-38cb5df375.2.$ii {
+ execsql {
+ SELECT 9 FROM (SELECT * FROM t1)
+ UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a)
+ LIMIT $::ii;
+ }
+ } [lrange {9 9 9 9 9 9 9 9 1 2 3 4 5 6 7 8} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {
+ do_test tkt-38cb5df375.3.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a)
+ UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a)
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {
+ do_test tkt-38cb5df375.4.$ii {
+ execsql {
+ SELECT 0 FROM (SELECT * FROM t1)
+ UNION ALL SELECT 9 FROM (SELECT a FROM t1)
+ LIMIT $::ii;
+ }
+ } [lrange {0 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4} {
+ do_test tkt-38cb5df375.5.$ii {
+ execsql {
+ SELECT 0 FROM (SELECT * FROM t1)
+ UNION SELECT 9 FROM (SELECT a FROM t1)
+ LIMIT $::ii;
+ }
+ } [lrange {0 9} 0 [expr {$ii-1}]]
+}
+
+foreach ii {1 2 3 4 5 6 7 8 9 10 11} {
+ do_test tkt-38cb5df375.11.$ii {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY a LIMIT 3)
+ UNION ALL SELECT 9 FROM (SELECT a FROM t1)
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7 8 9 10 11} {
+ do_test tkt-38cb5df375.12.$ii {
+ execsql {
+ SELECT 9 FROM (SELECT * FROM t1)
+ UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 3)
+ LIMIT $::ii;
+ }
+ } [lrange {9 9 9 9 9 9 9 9 1 2 3} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6} {
+ do_test tkt-38cb5df375.13.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 3)
+ UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 3)
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 1 2 3} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6} {
+ do_test tkt-38cb5df375.14.$ii {
+ execsql {
+ SELECT 0 FROM (SELECT * FROM t1 LIMIT 3)
+ UNION ALL SELECT 9 FROM (SELECT a FROM t1 LIMIT 3)
+ LIMIT $::ii;
+ }
+ } [lrange {0 0 0 9 9 9} 0 [expr {$ii-1}]]
+}
+
+foreach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {
+ do_test tkt-38cb5df375.21.$ii {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY a)
+ UNION ALL SELECT 9 FROM (SELECT a FROM t1)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 4 5 6 7 8 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {
+ do_test tkt-38cb5df375.22.$ii {
+ execsql {
+ SELECT 9 FROM (SELECT * FROM t1)
+ UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 4 5 6 7 8 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {
+ do_test tkt-38cb5df375.23.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a)
+ UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a)
+ ORDER BY 1 DESC
+ LIMIT $::ii;
+ }
+ } [lrange {8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {
+ do_test tkt-38cb5df375.24.$ii {
+ execsql {
+ SELECT 0 FROM (SELECT * FROM t1)
+ UNION ALL SELECT 9 FROM (SELECT a FROM t1)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {0 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]
+}
+
+foreach ii {1 2 3 4 5 6 7 8 9 10 11} {
+ do_test tkt-38cb5df375.31.$ii {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY a LIMIT 3)
+ UNION ALL SELECT 9 FROM (SELECT a FROM t1)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7 8 9 10 11} {
+ do_test tkt-38cb5df375.32.$ii {
+ execsql {
+ SELECT 9 FROM (SELECT * FROM t1)
+ UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 3)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7} {
+ do_test tkt-38cb5df375.33.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 4)
+ UNION ALL SELECT 90+a FROM (SELECT a FROM t1 ORDER BY a LIMIT 3)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 4 91 92 93} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7} {
+ do_test tkt-38cb5df375.34.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 2)
+ UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 5)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 1 2 2 3 4 5} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7} {
+ do_test tkt-38cb5df375.35.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 5)
+ UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 1 2 2 3 4 5} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7} {
+ do_test tkt-38cb5df375.35b.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 5)
+ UNION ALL SELECT a+10 FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 4 5 11 12} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7} {
+ do_test tkt-38cb5df375.35c.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 5)
+ UNION SELECT a+10 FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 4 5 11 12} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7} {
+ do_test tkt-38cb5df375.35d.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 5)
+ INTERSECT SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 2} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7} {
+ do_test tkt-38cb5df375.35e.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 5)
+ EXCEPT SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {3 4 5} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7} {
+ do_test tkt-38cb5df375.36.$ii {
+ execsql {
+ SELECT 0 FROM (SELECT * FROM t1 LIMIT 3)
+ UNION ALL SELECT 9 FROM (SELECT a FROM t1 LIMIT 4)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {0 0 0 9 9 9 9} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7} {
+ do_test tkt-38cb5df375.37.$ii {
+ execsql {
+ SELECT 0 FROM (SELECT * FROM t1 LIMIT 3)
+ UNION SELECT 9 FROM (SELECT a FROM t1 LIMIT 4)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {0 9} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7} {
+ do_test tkt-38cb5df375.38.$ii {
+ execsql {
+ SELECT 0 FROM (SELECT * FROM t1 LIMIT 3)
+ EXCEPT SELECT 9 FROM (SELECT a FROM t1 LIMIT 4)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {0} 0 [expr {$ii-1}]]
+}
+
+foreach ii {1 2 3 4 5 6 7 8 9} {
+ do_test tkt-38cb5df375.41.$ii {
+ execsql {
+ SELECT 0 FROM (SELECT * FROM t1 LIMIT 3)
+ UNION ALL SELECT 9 FROM (SELECT a FROM t1 LIMIT 4)
+ UNION ALL SELECT 88 FROM (SELECT a FROM t1 LIMIT 2)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {0 0 0 9 9 9 9 88 88} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7 8 9} {
+ do_test tkt-38cb5df375.42.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 3)
+ UNION ALL SELECT a+10 FROM (SELECT a FROM t1 ORDER BY a LIMIT 4)
+ UNION ALL SELECT a+20 FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 11 12 13 14 21 22} 0 [expr {$ii-1}]]
+}
+foreach ii {1 2 3 4 5 6 7 8 9} {
+ do_test tkt-38cb5df375.43.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 3)
+ UNION SELECT a+10 FROM (SELECT a FROM t1 ORDER BY a LIMIT 4)
+ UNION SELECT a+20 FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)
+ ORDER BY 1
+ LIMIT $::ii;
+ }
+ } [lrange {1 2 3 11 12 13 14 21 22} 0 [expr {$ii-1}]]
+}
+
+foreach ii {1 2 3 4 5 6 7} {
+ set jj [expr {7-$ii}]
+ do_test tkt-38cb5df375.51.$ii {
+ execsql {
+ SELECT a FROM (SELECT * FROM t1 ORDER BY a)
+ EXCEPT SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT $::ii)
+ ORDER BY a DESC
+ LIMIT $::jj;
+ }
+ } [lrange {8 7 6 5 4 3 2 1} 0 [expr {$jj-1}]]
+}
+
+
+finish_test
diff --git a/test/tkt-3998683a16.test b/test/tkt-3998683a16.test
new file mode 100644
index 0000000..919dc23
--- /dev/null
+++ b/test/tkt-3998683a16.test
@@ -0,0 +1,46 @@
+# 2010 September 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that ticket [3998683a16a7076e08f5585c1f4816414c8c653a] where in
+# floating point values with a decimal point at the beginning or end
+# of the mantissa are used.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-3998683a16.1 {
+ db eval {
+ CREATE TABLE t1(x, y REAL);
+ INSERT INTO t1 VALUES(1, '1.0');
+ INSERT INTO t1 VALUES(2, '.125');
+ INSERT INTO t1 VALUES(3, '123.');
+ INSERT INTO t1 VALUES(4, '123.e+2');
+ INSERT INTO t1 VALUES(5, '.125e+3');
+ INSERT INTO t1 VALUES(6, '123e4');
+ INSERT INTO t1 VALUES(11, ' 1.0');
+ INSERT INTO t1 VALUES(12, ' .125');
+ INSERT INTO t1 VALUES(13, ' 123.');
+ INSERT INTO t1 VALUES(14, ' 123.e+2');
+ INSERT INTO t1 VALUES(15, ' .125e+3');
+ INSERT INTO t1 VALUES(16, ' 123e4');
+ INSERT INTO t1 VALUES(21, '1.0 ');
+ INSERT INTO t1 VALUES(22, '.125 ');
+ INSERT INTO t1 VALUES(23, '123. ');
+ INSERT INTO t1 VALUES(24, '123.e+2 ');
+ INSERT INTO t1 VALUES(25, '.125e+3 ');
+ INSERT INTO t1 VALUES(26, '123e4 ');
+ SELECT x FROM t1 WHERE typeof(y)=='real' ORDER BY x;
+ }
+} {1 2 3 4 5 6 11 12 13 14 15 16 21 22 23 24 25 26}
+
+finish_test
diff --git a/test/tkt-3fe897352e.test b/test/tkt-3fe897352e.test
new file mode 100644
index 0000000..deafe48
--- /dev/null
+++ b/test/tkt-3fe897352e.test
@@ -0,0 +1,60 @@
+# 2009 October 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [3fe897352e8d8] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# The following tests use hex_to_utf16be() and hex_to_utf16le() which
+# which are only available if SQLite is built with UTF16 support.
+ifcapable {!utf16} {
+ finish_test
+ return
+}
+
+do_test tkt-3fe89-1.1 {
+ db close
+ sqlite3 db :memory:
+ db eval {
+ PRAGMA encoding=UTF8;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(hex_to_utf16be('D800'));
+ SELECT hex(x) FROM t1;
+ }
+} {EDA080}
+do_test tkt-3fe89-1.2 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(hex_to_utf16le('00D8'));
+ SELECT hex(x) FROM t1;
+ }
+} {EDA080}
+do_test tkt-3fe89-1.3 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(hex_to_utf16be('DFFF'));
+ SELECT hex(x) FROM t1;
+ }
+} {EDBFBF}
+do_test tkt-3fe89-1.4 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(hex_to_utf16le('FFDF'));
+ SELECT hex(x) FROM t1;
+ }
+} {EDBFBF}
+
+
+finish_test
diff --git a/test/tkt-4a03edc4c8.test b/test/tkt-4a03edc4c8.test
new file mode 100644
index 0000000..649f27d
--- /dev/null
+++ b/test/tkt-4a03edc4c8.test
@@ -0,0 +1,46 @@
+# 2009 September 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that
+# ticket [4a03edc4c8c028c93e9269f64fc5e97f632c1166] has been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-4a03ed-1.1 {
+ db eval {
+ CREATE TABLE t1(
+ a INTEGER PRIMARY KEY ON CONFLICT REPLACE,
+ b UNIQUE ON CONFLICT FAIL
+ );
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 2);
+ }
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ COMMIT;
+ }
+} {1 {column b is not unique}}
+do_test tkt-4a03ed-1.2 {
+ db eval {
+ PRAGMA integrity_check;
+ }
+} {ok}
+do_test tkt-4a03ed-1.3 {
+ db eval {
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 1 2 2}
+
+finish_test
diff --git a/test/tkt-54844eea3f.test b/test/tkt-54844eea3f.test
new file mode 100644
index 0000000..7b04f69
--- /dev/null
+++ b/test/tkt-54844eea3f.test
@@ -0,0 +1,67 @@
+# 2011 July 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that bug [54844eea3f] has been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set ::testprefix tkt-54844eea3f
+
+do_test 1.0 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(4);
+
+ CREATE TABLE t2(b INTEGER PRIMARY KEY);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ INSERT INTO t2 SELECT b+2 FROM t2;
+ INSERT INTO t2 SELECT b+4 FROM t2;
+ INSERT INTO t2 SELECT b+8 FROM t2;
+ INSERT INTO t2 SELECT b+16 FROM t2;
+
+ CREATE TABLE t3(c INTEGER PRIMARY KEY);
+ INSERT INTO t3 VALUES(1);
+ INSERT INTO t3 VALUES(2);
+ INSERT INTO t3 VALUES(3);
+ }
+} {}
+
+do_test 1.1 {
+ execsql {
+ SELECT 'test-2', t3.c, (
+ SELECT count(*)
+ FROM t1 JOIN (SELECT DISTINCT t3.c AS p FROM t2) AS x ON t1.a=x.p
+ )
+ FROM t3;
+ }
+} {test-2 1 1 test-2 2 0 test-2 3 0}
+
+do_test 1.2 {
+ execsql {
+ CREATE TABLE t4(a, b, c);
+ INSERT INTO t4 VALUES('a', 1, 'one');
+ INSERT INTO t4 VALUES('a', 2, 'two');
+ INSERT INTO t4 VALUES('b', 1, 'three');
+ INSERT INTO t4 VALUES('b', 2, 'four');
+ SELECT (
+ SELECT c FROM (
+ SELECT * FROM t4 WHERE a=out.a ORDER BY b LIMIT 10 OFFSET 1
+ ) WHERE b=out.b
+ ) FROM t4 AS out;
+ }
+} {{} two {} four}
+
+
+finish_test
diff --git a/test/tkt-5d863f876e.test b/test/tkt-5d863f876e.test
new file mode 100644
index 0000000..0a9017d
--- /dev/null
+++ b/test/tkt-5d863f876e.test
@@ -0,0 +1,53 @@
+# 2011 January 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [5d863f876e] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+
+do_multiclient_test tn {
+ do_test $tn.1 {
+ sql1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ PRAGMA journal_mode = WAL;
+ VACUUM;
+ PRAGMA journal_mode = DELETE;
+ }
+ } {wal delete}
+
+ do_test $tn.2 {
+ sql2 { SELECT * FROM t1 }
+ } {1 2 3 4}
+
+ do_test $tn.3 {
+ sql1 {
+ INSERT INTO t1 VALUES(5, 6);
+ PRAGMA journal_mode = WAL;
+ VACUUM;
+ PRAGMA journal_mode = DELETE;
+ }
+ } {wal delete}
+
+ do_test $tn.2 {
+ sql2 { PRAGMA integrity_check }
+ } {ok}
+}
+
+
+finish_test
diff --git a/test/tkt-5e10420e8d.test b/test/tkt-5e10420e8d.test
new file mode 100644
index 0000000..a2dfefd
--- /dev/null
+++ b/test/tkt-5e10420e8d.test
@@ -0,0 +1,50 @@
+# 2010 August 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test tkt-5e10420e8d.1 {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = incremental;
+
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(x);
+ CREATE TABLE t3(x);
+} {}
+
+do_execsql_test tkt-5e10420e8d.2 {
+ INSERT INTO t3 VALUES(randomblob(500 + 1024*248));
+ INSERT INTO t1 VALUES(randomblob(1500));
+ INSERT INTO t2 VALUES(randomblob(500 + 1024*248));
+
+ DELETE FROM t3;
+ DELETE FROM t2;
+ DELETE FROM t1;
+} {}
+
+do_execsql_test tkt-5e10420e8d.3 {
+ PRAGMA incremental_vacuum(248)
+} {}
+
+do_execsql_test tkt-5e10420e8d.4 {
+ PRAGMA incremental_vacuum(1)
+} {}
+
+db close
+sqlite3 db test.db
+
+do_execsql_test tkt-5e10420e8d.5 {
+ PRAGMA integrity_check;
+} {ok}
+
+finish_test
diff --git a/test/tkt-5ee23731f.test b/test/tkt-5ee23731f.test
new file mode 100644
index 0000000..761382a
--- /dev/null
+++ b/test/tkt-5ee23731f.test
@@ -0,0 +1,42 @@
+# 2009 October 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [5ee23731f15] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-5ee237-1.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(x UNIQUE);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 SELECT x+2 FROM t1;
+ INSERT INTO t1 SELECT x+4 FROM t1;
+ INSERT INTO t1 SELECT x+8 FROM t1;
+ }
+ db close
+ sqlite3 db test.db -readonly 1
+ set rc [catch {
+ db eval {SELECT rowid, x FROM t1 ORDER BY x} {
+ db eval {UPDATE t1 SET x=x+1 WHERE rowid=:rowid}
+ }
+ } msg]
+ lappend rc $msg
+} {1 {attempt to write a readonly database}}
+
+finish_test
diff --git a/test/tkt-752e1646fc.test b/test/tkt-752e1646fc.test
new file mode 100644
index 0000000..3837df8
--- /dev/null
+++ b/test/tkt-752e1646fc.test
@@ -0,0 +1,30 @@
+# 2010 April 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [752e1646fc] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-752e1646fc-1.1 {
+ execsql {
+ CREATE TABLE "test" ("letter" VARCHAR(1) PRIMARY KEY, "number" INTEGER NOT NULL);
+ INSERT INTO "test" ("letter", "number") VALUES('b', 1);
+ INSERT INTO "test" ("letter", "number") VALUES('a', 2);
+ INSERT INTO "test" ("letter", "number") VALUES('c', 2);
+ SELECT DISTINCT "number" FROM (SELECT "letter", "number" FROM "test" ORDER BY "letter", "number" LIMIT 1) AS "test";
+ }
+} {2}
+
+finish_test
diff --git a/test/tkt-78e04e52ea.test b/test/tkt-78e04e52ea.test
new file mode 100644
index 0000000..9524d84
--- /dev/null
+++ b/test/tkt-78e04e52ea.test
@@ -0,0 +1,68 @@
+# 2009 December 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# Verify that we can create zero-length tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-78e04-1.0 {
+ execsql {
+ CREATE TABLE ""("" UNIQUE);
+ CREATE TABLE t2(x);
+ INSERT INTO "" VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ SELECT * FROM "", t2;
+ }
+} {1 2}
+do_test tkt-78e04-1.1 {
+ catchsql {
+ INSERT INTO "" VALUES(1);
+ }
+} {1 {column is not unique}}
+do_test tkt-78e04-1.2 {
+ execsql {
+ PRAGMA table_info("");
+ }
+} {0 {} {} 0 {} 0}
+do_test tkt-78e04-1.3 {
+ execsql {
+ CREATE INDEX i1 ON ""("" COLLATE nocase);
+ }
+} {}
+do_test tkt-78e04-1.4 {
+ execsql {
+ EXPLAIN QUERY PLAN SELECT * FROM "" WHERE "" LIKE 'abc%';
+ }
+} {0 0 0 {SCAN TABLE (~500000 rows)}}
+do_test tkt-78e04-1.5 {
+ execsql {
+ DROP TABLE "";
+ SELECT name FROM sqlite_master;
+ }
+} {t2}
+
+do_test tkt-78e04-2.1 {
+ execsql {
+ CREATE INDEX "" ON t2(x);
+ EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=5;
+ }
+} {0 0 0 {SEARCH TABLE t2 USING COVERING INDEX (x=?) (~10 rows)}}
+do_test tkt-78e04-2.2 {
+ execsql {
+ DROP INDEX "";
+ EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=2;
+ }
+} {0 0 0 {SCAN TABLE t2 (~100000 rows)}}
+
+finish_test
diff --git a/test/tkt-80ba201079.test b/test/tkt-80ba201079.test
new file mode 100644
index 0000000..95e99b5
--- /dev/null
+++ b/test/tkt-80ba201079.test
@@ -0,0 +1,191 @@
+# 2010 December 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that ticket [80ba201079ea608071d22a57856b940ea3ac53ce] is
+# resolved. That ticket is about an incorrect result that appears when
+# an index is added. The root cause is that a constant is being used
+# without initialization when the OR optimization applies in the WHERE clause.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix tkt-80ba2
+
+do_test tkt-80ba2-100 {
+ db eval {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES('A');
+ CREATE TABLE t2(b);
+ INSERT INTO t2 VALUES('B');
+ CREATE TABLE t3(c);
+ INSERT INTO t3 VALUES('C');
+ SELECT * FROM t1, t2
+ WHERE (a='A' AND b='X')
+ OR (a='A' AND EXISTS (SELECT * FROM t3 WHERE c='C'));
+ }
+} {A B}
+do_test tkt-80ba2-101 {
+ db eval {
+ CREATE INDEX i1 ON t1(a);
+ SELECT * FROM t1, t2
+ WHERE (a='A' AND b='X')
+ OR (a='A' AND EXISTS (SELECT * FROM t3 WHERE c='C'));
+ }
+} {A B}
+do_test tkt-80ba2-102 {
+ optimization_control db factor-constants 0
+ db cache flush
+ db eval {
+ SELECT * FROM t1, t2
+ WHERE (a='A' AND b='X')
+ OR (a='A' AND EXISTS (SELECT * FROM t3 WHERE c='C'));
+ }
+} {A B}
+optimization_control db all 1
+
+# Verify that the optimization_control command is actually working
+#
+do_test tkt-80ba2-150 {
+ optimization_control db factor-constants 1
+ db cache flush
+ set x1 [db eval {EXPLAIN
+ SELECT * FROM t1, t2
+ WHERE (a='A' AND b='X')
+ OR (a='A' AND EXISTS (SELECT * FROM t3 WHERE c='C'));}]
+ optimization_control db factor-constants 0
+ db cache flush
+ set x2 [db eval {EXPLAIN
+ SELECT * FROM t1, t2
+ WHERE (a='A' AND b='X')
+ OR (a='A' AND EXISTS (SELECT * FROM t3 WHERE c='C'));}]
+
+ expr {$x1==$x2}
+} {0}
+
+do_test tkt-80ba2-200 {
+ db eval {
+ CREATE TABLE entry_types (
+ id integer primary key,
+ name text
+ );
+ INSERT INTO "entry_types" VALUES(100,'cli_command');
+ INSERT INTO "entry_types" VALUES(300,'object_change');
+ CREATE TABLE object_changes (
+ change_id integer primary key,
+ system_id int,
+ obj_id int,
+ obj_context text,
+ change_type int,
+ command_id int
+ );
+ INSERT INTO "object_changes" VALUES(1551,1,114608,'exported_pools',1,2114);
+ INSERT INTO "object_changes" VALUES(2048,1,114608,'exported_pools',2,2319);
+ CREATE TABLE timeline (
+ rowid integer primary key,
+ timestamp text,
+ system_id int,
+ entry_type int,
+ entry_id int
+ );
+ INSERT INTO "timeline" VALUES(6735,'2010-11-21 17:08:27.000',1,300,2048);
+ INSERT INTO "timeline" VALUES(6825,'2010-11-21 17:09:21.000',1,300,2114);
+ SELECT entry_type,
+ entry_types.name,
+ entry_id
+ FROM timeline JOIN entry_types ON entry_type = entry_types.id
+ WHERE (entry_types.name = 'cli_command' AND entry_id=2114)
+ OR (entry_types.name = 'object_change'
+ AND entry_id IN (SELECT change_id
+ FROM object_changes
+ WHERE obj_context = 'exported_pools'));
+ }
+} {300 object_change 2048}
+do_test tkt-80ba2-201 {
+ db eval {
+ CREATE INDEX timeline_entry_id_idx on timeline(entry_id);
+ SELECT entry_type,
+ entry_types.name,
+ entry_id
+ FROM timeline JOIN entry_types ON entry_type = entry_types.id
+ WHERE (entry_types.name = 'cli_command' AND entry_id=2114)
+ OR (entry_types.name = 'object_change'
+ AND entry_id IN (SELECT change_id
+ FROM object_changes
+ WHERE obj_context = 'exported_pools'));
+ }
+} {300 object_change 2048}
+do_test tkt-80ba2-202 {
+ optimization_control db factor-constants 0
+ db cache flush
+ db eval {
+ SELECT entry_type,
+ entry_types.name,
+ entry_id
+ FROM timeline JOIN entry_types ON entry_type = entry_types.id
+ WHERE (entry_types.name = 'cli_command' AND entry_id=2114)
+ OR (entry_types.name = 'object_change'
+ AND entry_id IN (SELECT change_id
+ FROM object_changes
+ WHERE obj_context = 'exported_pools'));
+ }
+} {300 object_change 2048}
+
+#-------------------------------------------------------------------------
+#
+
+drop_all_tables
+do_execsql_test 301 {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+ CREATE TABLE t2(d, e);
+
+ INSERT INTO t1 VALUES('A', 'B', 'C');
+ INSERT INTO t2 VALUES('D', 'E');
+}
+
+do_execsql_test 302 {
+ SELECT * FROM t1, t2 WHERE
+ (a='A' AND d='E') OR
+ (b='B' AND c IN ('C', 'D', 'E'))
+} {A B C D E}
+
+do_execsql_test 303 {
+ SELECT * FROM t1, t2 WHERE
+ (a='A' AND d='E') OR
+ (b='B' AND c IN (SELECT c FROM t1))
+} {A B C D E}
+
+do_execsql_test 304 {
+ SELECT * FROM t1, t2 WHERE
+ (a='A' AND d='E') OR
+ (b='B' AND c IN (SELECT 'B' UNION SELECT 'C' UNION SELECT 'D'))
+} {A B C D E}
+
+do_execsql_test 305 {
+ SELECT * FROM t1, t2 WHERE
+ (b='B' AND c IN ('C', 'D', 'E')) OR
+ (a='A' AND d='E')
+} {A B C D E}
+
+do_execsql_test 306 {
+ SELECT * FROM t1, t2 WHERE
+ (b='B' AND c IN (SELECT c FROM t1)) OR
+ (a='A' AND d='E')
+} {A B C D E}
+
+do_execsql_test 307 {
+ SELECT * FROM t1, t2 WHERE
+ (b='B' AND c IN (SELECT 'B' UNION SELECT 'C' UNION SELECT 'D')) OR
+ (a='A' AND d='E')
+} {A B C D E}
+
+finish_test
diff --git a/test/tkt-80e031a00f.test b/test/tkt-80e031a00f.test
new file mode 100644
index 0000000..95372ab
--- /dev/null
+++ b/test/tkt-80e031a00f.test
@@ -0,0 +1,206 @@
+# 2010 July 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that ticket [80e031a00f45dca877ed92b225209cfa09280f4f] has been
+# resolved. That ticket is about IN and NOT IN operators with empty-set
+# right-hand sides. Such expressions should always return TRUE or FALSE
+# even if the left-hand side is NULL.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+# EVIDENCE-OF: R-58875-56087 The IN and NOT IN operators take a single
+# scalar operand on the left and a vector operand on the right formed by
+# an explicit list of zero or more scalars or by a single subquery.
+#
+# EVIDENCE-OF: R-52275-55503 When the right operand is an empty set, the
+# result of IN is false and the result of NOT IN is true, regardless of
+# the left operand and even if the left operand is NULL.
+#
+# EVIDENCE-OF: R-13595-45863 Note that SQLite allows the parenthesized
+# list of scalar values on the right-hand side of an IN or NOT IN
+# operator to be an empty list but most other SQL database database
+# engines and the SQL92 standard require the list to contain at least
+# one element.
+#
+do_execsql_test tkt-80e031a00f.1 {SELECT 1 IN ()} 0
+do_execsql_test tkt-80e031a00f.1b {SELECT 1 IN (2)} 0
+do_execsql_test tkt-80e031a00f.1c {SELECT 1 IN (2,3,4,5,6,7,8,9)} 0
+do_execsql_test tkt-80e031a00f.2 {SELECT 1 NOT IN ()} 1
+do_execsql_test tkt-80e031a00f.2b {SELECT 1 NOT IN (2)} 1
+do_execsql_test tkt-80e031a00f.2c {SELECT 1 NOT IN (2,3,4,5,6,7,8,9)} 1
+do_execsql_test tkt-80e031a00f.3 {SELECT null IN ()} 0
+do_execsql_test tkt-80e031a00f.4 {SELECT null NOT IN ()} 1
+do_execsql_test tkt-80e031a00f.5 {
+ CREATE TABLE t1(x);
+ SELECT 1 IN t1;
+} 0
+do_execsql_test tkt-80e031a00f.6 {SELECT 1 NOT IN t1} 1
+do_execsql_test tkt-80e031a00f.7 {SELECT null IN t1} 0
+do_execsql_test tkt-80e031a00f.8 {SELECT null NOT IN t1} 1
+do_execsql_test tkt-80e031a00f.9 {
+ CREATE TABLE t2(y INTEGER PRIMARY KEY);
+ SELECT 1 IN t2;
+} 0
+do_execsql_test tkt-80e031a00f.10 {SELECT 1 NOT IN t2} 1
+do_execsql_test tkt-80e031a00f.11 {SELECT null IN t2} 0
+do_execsql_test tkt-80e031a00f.12 {SELECT null NOT IN t2} 1
+do_execsql_test tkt-80e031a00f.13 {
+ CREATE TABLE t3(z INT UNIQUE);
+ SELECT 1 IN t3;
+} 0
+do_execsql_test tkt-80e031a00f.14 {SELECT 1 NOT IN t3} 1
+do_execsql_test tkt-80e031a00f.15 {SELECT null IN t3} 0
+do_execsql_test tkt-80e031a00f.16 {SELECT null NOT IN t3} 1
+do_execsql_test tkt-80e031a00f.17 {SELECT 1 IN (SELECT x+y FROM t1, t2)} 0
+do_execsql_test tkt-80e031a00f.18 {SELECT 1 NOT IN (SELECT x+y FROM t1,t2)} 1
+do_execsql_test tkt-80e031a00f.19 {SELECT null IN (SELECT x+y FROM t1,t2)} 0
+do_execsql_test tkt-80e031a00f.20 {SELECT null NOT IN (SELECT x+y FROM t1,t2)} 1
+do_execsql_test tkt-80e031a00f.21 {SELECT 1.23 IN ()} 0
+do_execsql_test tkt-80e031a00f.22 {SELECT 1.23 NOT IN ()} 1
+do_execsql_test tkt-80e031a00f.23 {SELECT 1.23 IN t1} 0
+do_execsql_test tkt-80e031a00f.24 {SELECT 1.23 NOT IN t1} 1
+do_execsql_test tkt-80e031a00f.25 {SELECT 'hello' IN ()} 0
+do_execsql_test tkt-80e031a00f.26 {SELECT 'hello' NOT IN ()} 1
+do_execsql_test tkt-80e031a00f.27 {SELECT 'hello' IN t1} 0
+do_execsql_test tkt-80e031a00f.28 {SELECT 'hello' NOT IN t1} 1
+do_execsql_test tkt-80e031a00f.29 {SELECT x'303132' IN ()} 0
+do_execsql_test tkt-80e031a00f.30 {SELECT x'303132' NOT IN ()} 1
+do_execsql_test tkt-80e031a00f.31 {SELECT x'303132' IN t1} 0
+do_execsql_test tkt-80e031a00f.32 {SELECT x'303132' NOT IN t1} 1
+
+# EVIDENCE-OF: R-50221-42915 The result of an IN or NOT IN operator is
+# determined by the following matrix: Left operand is NULL Right operand
+# contains NULL Right operand is an empty set Left operand found within
+# right operand Result of IN operator Result of NOT IN operator no no no
+# no false true does not matter no yes no false true no does not matter
+# no yes true false no yes no no NULL NULL yes does not matter no does
+# not matter NULL NULL
+#
+# Row 1:
+do_execsql_test tkt-80e031a00f.100 {SELECT 1 IN (2,3,4)} 0
+do_execsql_test tkt-80e031a00f.101 {SELECT 1 NOT IN (2,3,4)} 1
+do_execsql_test tkt-80e031a00f.102 {SELECT 'a' IN ('b','c','d')} 0
+do_execsql_test tkt-80e031a00f.103 {SELECT 'a' NOT IN ('b','c','d')} 1
+do_test tkt-80e031a00f.104 {
+ db eval {
+ CREATE TABLE t4(a UNIQUE);
+ CREATE TABLE t5(b INTEGER PRIMARY KEY);
+ CREATE TABLE t6(c);
+ INSERT INTO t4 VALUES(2);
+ INSERT INTO t4 VALUES(3);
+ INSERT INTO t4 VALUES(4);
+ INSERT INTO t5 SELECT * FROM t4;
+ INSERT INTO t6 SELECT * FROM t4;
+ CREATE TABLE t4n(a UNIQUE);
+ CREATE TABLE t6n(c);
+ INSERT INTO t4n SELECT * FROM t4;
+ INSERT INTO t4n VALUES(null);
+ INSERT INTO t6n SELECT * FROM t4n;
+ CREATE TABLE t7(a UNIQUE);
+ CREATE TABLE t8(c);
+ INSERT INTO t7 VALUES('b');
+ INSERT INTO t7 VALUES('c');
+ INSERT INTO t7 VALUES('d');
+ INSERT INTO t8 SELECT * FROM t7;
+ CREATE TABLE t7n(a UNIQUE);
+ CREATE TABLE t8n(c);
+ INSERT INTO t7n SELECT * FROM t7;
+ INSERT INTO t7n VALUES(null);
+ INSERT INTO t8n SELECT * FROM t7n;
+ }
+ execsql {SELECT 1 IN t4}
+} 0
+do_execsql_test tkt-80e031a00f.105 {SELECT 1 NOT IN t4} 1
+do_execsql_test tkt-80e031a00f.106 {SELECT 1 IN t5} 0
+do_execsql_test tkt-80e031a00f.107 {SELECT 1 NOT IN t5} 1
+do_execsql_test tkt-80e031a00f.108 {SELECT 1 IN t6} 0
+do_execsql_test tkt-80e031a00f.109 {SELECT 1 NOT IN t6} 1
+do_execsql_test tkt-80e031a00f.110 {SELECT 'a' IN t7} 0
+do_execsql_test tkt-80e031a00f.111 {SELECT 'a' NOT IN t7} 1
+do_execsql_test tkt-80e031a00f.112 {SELECT 'a' IN t8} 0
+do_execsql_test tkt-80e031a00f.113 {SELECT 'a' NOT IN t8} 1
+#
+# Row 2 is tested by cases 1-32 above.
+# Row 3:
+do_execsql_test tkt-80e031a00f.300 {SELECT 2 IN (2,3,4,null)} 1
+do_execsql_test tkt-80e031a00f.301 {SELECT 3 NOT IN (2,3,4,null)} 0
+do_execsql_test tkt-80e031a00f.302 {SELECT 4 IN (2,3,4)} 1
+do_execsql_test tkt-80e031a00f.303 {SELECT 2 NOT IN (2,3,4)} 0
+do_execsql_test tkt-80e031a00f.304 {SELECT 'b' IN ('b','c','d')} 1
+do_execsql_test tkt-80e031a00f.305 {SELECT 'c' NOT IN ('b','c','d')} 0
+do_execsql_test tkt-80e031a00f.306 {SELECT 'd' IN ('b','c',null,'d')} 1
+do_execsql_test tkt-80e031a00f.307 {SELECT 'b' NOT IN (null,'b','c','d')} 0
+do_execsql_test tkt-80e031a00f.308 {SELECT 2 IN t4} 1
+do_execsql_test tkt-80e031a00f.309 {SELECT 3 NOT IN t4} 0
+do_execsql_test tkt-80e031a00f.310 {SELECT 4 IN t4n} 1
+do_execsql_test tkt-80e031a00f.311 {SELECT 2 NOT IN t4n} 0
+do_execsql_test tkt-80e031a00f.312 {SELECT 2 IN t5} 1
+do_execsql_test tkt-80e031a00f.313 {SELECT 3 NOT IN t5} 0
+do_execsql_test tkt-80e031a00f.314 {SELECT 2 IN t6} 1
+do_execsql_test tkt-80e031a00f.315 {SELECT 3 NOT IN t6} 0
+do_execsql_test tkt-80e031a00f.316 {SELECT 4 IN t6n} 1
+do_execsql_test tkt-80e031a00f.317 {SELECT 2 NOT IN t6n} 0
+do_execsql_test tkt-80e031a00f.318 {SELECT 'b' IN t7} 1
+do_execsql_test tkt-80e031a00f.319 {SELECT 'c' NOT IN t7} 0
+do_execsql_test tkt-80e031a00f.320 {SELECT 'c' IN t7n} 1
+do_execsql_test tkt-80e031a00f.321 {SELECT 'd' NOT IN t7n} 0
+do_execsql_test tkt-80e031a00f.322 {SELECT 'b' IN t8} 1
+do_execsql_test tkt-80e031a00f.323 {SELECT 'c' NOT IN t8} 0
+do_execsql_test tkt-80e031a00f.324 {SELECT 'c' IN t8n} 1
+do_execsql_test tkt-80e031a00f.325 {SELECT 'd' NOT IN t8n} 0
+#
+# Row 4:
+do_execsql_test tkt-80e031a00f.400 {SELECT 1 IN (2,3,4,null)} {{}}
+do_execsql_test tkt-80e031a00f.401 {SELECT 1 NOT IN (2,3,4,null)} {{}}
+do_execsql_test tkt-80e031a00f.402 {SELECT 'a' IN ('b','c',null,'d')} {{}}
+do_execsql_test tkt-80e031a00f.403 {SELECT 'a' NOT IN (null,'b','c','d')} {{}}
+do_execsql_test tkt-80e031a00f.404 {SELECT 1 IN t4n} {{}}
+do_execsql_test tkt-80e031a00f.405 {SELECT 5 NOT IN t4n} {{}}
+do_execsql_test tkt-80e031a00f.406 {SELECT 6 IN t6n} {{}}
+do_execsql_test tkt-80e031a00f.407 {SELECT 7 NOT IN t6n} {{}}
+do_execsql_test tkt-80e031a00f.408 {SELECT 'a' IN t7n} {{}}
+do_execsql_test tkt-80e031a00f.409 {SELECT 'e' NOT IN t7n} {{}}
+do_execsql_test tkt-80e031a00f.410 {SELECT 'f' IN t8n} {{}}
+do_execsql_test tkt-80e031a00f.411 {SELECT 'g' NOT IN t8n} {{}}
+#
+# Row 5:
+do_execsql_test tkt-80e031a00f.500 {SELECT null IN (2,3,4,null)} {{}}
+do_execsql_test tkt-80e031a00f.501 {SELECT null NOT IN (2,3,4,null)} {{}}
+do_execsql_test tkt-80e031a00f.502 {SELECT null IN (2,3,4)} {{}}
+do_execsql_test tkt-80e031a00f.503 {SELECT null NOT IN (2,3,4)} {{}}
+do_execsql_test tkt-80e031a00f.504 {SELECT null IN ('b','c','d')} {{}}
+do_execsql_test tkt-80e031a00f.505 {SELECT null NOT IN ('b','c','d')} {{}}
+do_execsql_test tkt-80e031a00f.506 {SELECT null IN ('b','c',null,'d')} {{}}
+do_execsql_test tkt-80e031a00f.507 {SELECT null NOT IN (null,'b','c','d')} {{}}
+do_execsql_test tkt-80e031a00f.508 {SELECT null IN t4} {{}}
+do_execsql_test tkt-80e031a00f.509 {SELECT null NOT IN t4} {{}}
+do_execsql_test tkt-80e031a00f.510 {SELECT null IN t4n} {{}}
+do_execsql_test tkt-80e031a00f.511 {SELECT null NOT IN t4n} {{}}
+do_execsql_test tkt-80e031a00f.512 {SELECT null IN t5} {{}}
+do_execsql_test tkt-80e031a00f.513 {SELECT null NOT IN t5} {{}}
+do_execsql_test tkt-80e031a00f.514 {SELECT null IN t6} {{}}
+do_execsql_test tkt-80e031a00f.515 {SELECT null NOT IN t6} {{}}
+do_execsql_test tkt-80e031a00f.516 {SELECT null IN t6n} {{}}
+do_execsql_test tkt-80e031a00f.517 {SELECT null NOT IN t6n} {{}}
+do_execsql_test tkt-80e031a00f.518 {SELECT null IN t7} {{}}
+do_execsql_test tkt-80e031a00f.519 {SELECT null NOT IN t7} {{}}
+do_execsql_test tkt-80e031a00f.520 {SELECT null IN t7n} {{}}
+do_execsql_test tkt-80e031a00f.521 {SELECT null NOT IN t7n} {{}}
+do_execsql_test tkt-80e031a00f.522 {SELECT null IN t8} {{}}
+do_execsql_test tkt-80e031a00f.523 {SELECT null NOT IN t8} {{}}
+do_execsql_test tkt-80e031a00f.524 {SELECT null IN t8n} {{}}
+do_execsql_test tkt-80e031a00f.525 {SELECT null NOT IN t8n} {{}}
+
+finish_test
diff --git a/test/tkt-8454a207b9.test b/test/tkt-8454a207b9.test
new file mode 100644
index 0000000..88a8614
--- /dev/null
+++ b/test/tkt-8454a207b9.test
@@ -0,0 +1,67 @@
+# 2010 September 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that ticket [8454a207b9fd2243c4c6b7a73f67ea0315717c1a]. Verify
+# that a negative default value on an added text column actually comes
+# out negative.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-8454a207b9.1 {
+ db eval {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ ALTER TABLE t1 ADD COLUMN b TEXT DEFAULT -123.0;
+ SELECT b, typeof(b) FROM t1;
+ }
+} {-123.0 text}
+do_test tkt-8454a207b9.2 {
+ db eval {
+ ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT -123.5;
+ SELECT c, typeof(c) FROM t1;
+ }
+} {-123.5 text}
+do_test tkt-8454a207b9.3 {
+ db eval {
+ ALTER TABLE t1 ADD COLUMN d TEXT DEFAULT -'hello';
+ SELECT d, typeof(d) FROM t1;
+ }
+} {0 text}
+do_test tkt-8454a207b9.4 {
+ db eval {
+ ALTER TABLE t1 ADD COLUMN e DEFAULT -123.0;
+ SELECT e, typeof(e) FROM t1;
+ }
+} {-123 integer}
+do_test tkt-8454a207b9.5 {
+ db eval {
+ ALTER TABLE t1 ADD COLUMN f DEFAULT -123.5;
+ SELECT f, typeof(f) FROM t1;
+ }
+} {-123.5 real}
+do_test tkt-8454a207b9.6 {
+ db eval {
+ ALTER TABLE t1 ADD COLUMN g DEFAULT -9223372036854775808;
+ SELECT g, typeof(g) FROM t1;
+ }
+} {-9223372036854775808 integer}
+do_test tkt-8454a207b9.7 {
+ db eval {
+ ALTER TABLE t1 ADD COLUMN h DEFAULT 9223372036854775807;
+ SELECT h, typeof(h) FROM t1;
+ }
+} {9223372036854775807 integer}
+
+
+finish_test
diff --git a/test/tkt-91e2e8ba6f.test b/test/tkt-91e2e8ba6f.test
new file mode 100644
index 0000000..57f1374
--- /dev/null
+++ b/test/tkt-91e2e8ba6f.test
@@ -0,0 +1,52 @@
+# 2011 June 23
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests for SQLite. Specifically, it tests that SQLite
+# does not crash and an error is returned if localhost() fails. This
+# is the problem reported by ticket 91e2e8ba6f.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix tkt-91e2e8ba6f
+
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(x INTEGER, y REAL);
+ INSERT INTO t1 VALUES(11, 11);
+} {}
+
+do_execsql_test 1.2 {
+ SELECT x/10, y/10 FROM t1;
+} {1 1.1}
+
+do_execsql_test 1.3 {
+ SELECT x/10, y/10 FROM (SELECT * FROM t1);
+} {1 1.1}
+
+do_execsql_test 1.4 {
+ SELECT x/10, y/10 FROM (SELECT * FROM t1 LIMIT 5 OFFSET 0);
+} {1 1.1}
+
+do_execsql_test 1.5 {
+ SELECT x/10, y/10 FROM (SELECT * FROM t1 LIMIT 5 OFFSET 0) LIMIT 5 OFFSET 0;
+} {1 1.1}
+
+do_execsql_test 1.6 {
+ SELECT a.x/10, a.y/10 FROM
+ (SELECT * FROM t1 LIMIT 5 OFFSET 0) AS a, t1 AS b WHERE a.x = b.x
+ LIMIT 5 OFFSET 0;
+} {1 1.1}
+
+do_execsql_test 1.7 {
+ CREATE VIEW v1 AS SELECT * FROM t1 LIMIT 5;
+ SELECT a.x/10, a.y/10 FROM v1 AS a, t1 AS b WHERE a.x = b.x LIMIT 5 OFFSET 0;
+} {1 1.1}
+
+finish_test
diff --git a/test/tkt-94c04eaadb.test b/test/tkt-94c04eaadb.test
new file mode 100644
index 0000000..cce8a98
--- /dev/null
+++ b/test/tkt-94c04eaadb.test
@@ -0,0 +1,73 @@
+# 2009 October 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {[info commands sqlite3async_initialize] eq ""} {
+ # The async logic is not built into this system
+ finish_test
+ return
+}
+
+# Create a database.
+do_test tkt-94c94-1.1 {
+ execsql { CREATE TABLE t1(a, b) }
+} {}
+
+# Grow the file to larger than 4096MB (2^32 bytes)
+db close
+if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} {
+ puts "**** Unable to create a file larger than 4096 MB. *****"
+ finish_test
+ return
+}
+
+# Switch to async mode.
+sqlite3async_initialize "" 1
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+# Read from and write to the db just past the 4096MB mark.
+#
+do_test tkt-94c94-2.1 {
+ execsql { CREATE TABLE t2(x, y) } db
+} {}
+do_test tkt-94c94-2.2 {
+breakpoint
+ execsql { INSERT INTO t2 VALUES(1, 2) } db2
+} {}
+do_test tkt-94c94-2.3 {
+ execsql { SELECT * FROM t2 } db
+} {1 2}
+do_test tkt-94c94-2.4 {
+ sqlite3async_control halt idle
+ sqlite3async_start
+ sqlite3async_wait
+} {}
+do_test tkt-94c94-2.5 {
+ execsql { SELECT * FROM t2 } db
+} {1 2}
+do_test tkt-94c94-2.6 {
+ sqlite3async_start
+ sqlite3async_wait
+} {}
+
+db close
+db2 close
+sqlite3async_start
+sqlite3async_wait
+sqlite3async_control halt never
+sqlite3async_shutdown
+
+finish_test
diff --git a/test/tkt-9d68c883.test b/test/tkt-9d68c883.test
new file mode 100644
index 0000000..18dc6cc
--- /dev/null
+++ b/test/tkt-9d68c883.test
@@ -0,0 +1,53 @@
+# 2010 April 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file tests that bug 9d68c883132c8e9ffcd5b0c148c990807b5df1b7
+# is fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-9d68c88-1.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 2;
+ CREATE TABLE t3(x);
+ CREATE TABLE t4(x);
+ CREATE TABLE t5(x);
+ INSERT INTO t5 VALUES(randomblob(1500));
+ CREATE TABLE t7(x);
+ CREATE TABLE t8(x);
+ }
+} {}
+
+
+for {set i 0} {$i < 100} {incr i} {
+ db close
+ sqlite3_simulate_device -sectorsize 8192
+ sqlite3 db test.db -vfs devsym
+
+ do_test tkt-9d68c88-2.$i {
+ execsql {
+ BEGIN;
+ DELETE FROM t5;
+ INSERT INTO t8 VALUES('hello world');
+ }
+
+ sqlite3_memdebug_fail $i -repeat 0
+ catchsql { DROP TABLE t7; }
+ sqlite3_memdebug_fail -1
+
+ catchsql { ROLLBACK }
+ execsql { PRAGMA integrity_check }
+ } {ok}
+}
+
+finish_test
diff --git a/test/tkt-b1d3a2e531.test b/test/tkt-b1d3a2e531.test
new file mode 100644
index 0000000..54534b6
--- /dev/null
+++ b/test/tkt-b1d3a2e531.test
@@ -0,0 +1,109 @@
+# 2011 August 22
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for foreign keys. Specifically, it tests
+# that ticket b1d3a2e531 has been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!foreignkey||!trigger} {
+ finish_test
+ return
+}
+set testprefix tkt-b1d3a2e531
+
+do_execsql_test 1.0 { PRAGMA foreign_keys = ON }
+
+do_execsql_test 1.1 {
+ CREATE TABLE pp(x PRIMARY KEY);
+ CREATE TABLE cc(y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);
+ INSERT INTO pp VALUES('abc');
+ INSERT INTO cc VALUES('abc');
+}
+do_execsql_test 1.2 {
+ BEGIN;
+ DROP TABLE pp;
+ DROP TABLE cc;
+ COMMIT;
+}
+do_execsql_test 1.3 {
+ CREATE TABLE pp(x PRIMARY KEY);
+ CREATE TABLE cc(y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);
+ INSERT INTO pp VALUES('abc');
+ INSERT INTO cc VALUES('abc');
+}
+do_execsql_test 1.4 {
+ BEGIN;
+ DROP TABLE cc;
+ DROP TABLE pp;
+ COMMIT;
+}
+
+do_execsql_test 2.1 {
+ CREATE TABLE pp(x PRIMARY KEY);
+ CREATE TABLE cc(
+ y INTEGER PRIMARY KEY REFERENCES pp DEFERRABLE INITIALLY DEFERRED
+ );
+ INSERT INTO pp VALUES(5);
+ INSERT INTO cc VALUES(5);
+}
+do_execsql_test 2.2 {
+ BEGIN;
+ DROP TABLE pp;
+ DROP TABLE cc;
+ COMMIT;
+}
+do_execsql_test 2.3 {
+ CREATE TABLE pp(x PRIMARY KEY);
+ CREATE TABLE cc(
+ y INTEGER PRIMARY KEY REFERENCES pp DEFERRABLE INITIALLY DEFERRED
+ );
+ INSERT INTO pp VALUES(5);
+ INSERT INTO cc VALUES(5);
+}
+do_execsql_test 2.4 {
+ BEGIN;
+ DROP TABLE cc;
+ DROP TABLE pp;
+ COMMIT;
+}
+
+do_execsql_test 3.1 {
+ CREATE TABLE pp1(x PRIMARY KEY);
+ CREATE TABLE cc1(y REFERENCES pp1 DEFERRABLE INITIALLY DEFERRED);
+
+ CREATE TABLE pp2(x PRIMARY KEY);
+ CREATE TABLE cc2(y REFERENCES pp1 DEFERRABLE INITIALLY DEFERRED);
+
+ INSERT INTO pp1 VALUES(2200);
+ INSERT INTO cc1 VALUES(NULL);
+
+ INSERT INTO pp2 VALUES(2200);
+ INSERT INTO cc2 VALUES(2200);
+}
+do_catchsql_test 3.2 {
+ BEGIN;
+ DELETE FROM pp2;
+ DROP TABLE pp1;
+ DROP TABLE cc1;
+ COMMIT;
+} {1 {foreign key constraint failed}}
+do_catchsql_test 3.3 {
+ DROP TABLE cc2;
+ COMMIT;
+} {0 {}}
+
+
+
+finish_test
diff --git a/test/tkt-b351d95f9.test b/test/tkt-b351d95f9.test
new file mode 100644
index 0000000..5bd5ee4
--- /dev/null
+++ b/test/tkt-b351d95f9.test
@@ -0,0 +1,47 @@
+# 2010 September 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that ticket [b351d95f9cd5ef17e9d9dbae18f5ca8611190001] has been
+# resolved.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+do_test tkt-b351d95.1 {
+ execsql {
+ CREATE table t1(a,b);
+ INSERT INTO t1 VALUES('name1','This is a test');
+ INSERT INTO t1 VALUES('name2','xyz');
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 SELECT a, CASE b WHEN 'xyz' THEN null ELSE b END FROM t1;
+ SELECT x, y FROM t2 ORDER BY x;
+ }
+} {name1 {This is a test} name2 {}}
+
+do_test tkt-b351d95.2 {
+ execsql {
+ DELETE FROM t2;
+ INSERT INTO t2 SELECT a, coalesce(b,a) FROM t1;
+ SELECT x, y FROM t2 ORDER BY x;
+ }
+} {name1 {This is a test} name2 xyz}
+do_test tkt-b351d95.3 {
+ execsql {
+ DELETE FROM t2;
+ INSERT INTO t2 SELECT a, coalesce(b,a) FROM t1;
+ SELECT x, y BETWEEN 'xy' AND 'xz' FROM t2 ORDER BY x;
+ }
+} {name1 0 name2 1}
+
+finish_test
diff --git a/test/tkt-b72787b1.test b/test/tkt-b72787b1.test
new file mode 100644
index 0000000..11ea41e
--- /dev/null
+++ b/test/tkt-b72787b1.test
@@ -0,0 +1,77 @@
+# 2011 February 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [b72787b1a7] has been
+# fixed. From the ticket:
+#
+# The sqlite3ExpirePreparedStatements routine marks all statements
+# as expired. This includes statements that are not expired.
+#
+# Steps to reproduce:
+#
+# * Prepare a statement (A)
+# * Alter the schema to invalidate cookie in A
+# * Prepare a statement (B)
+# * Run B and have A run as part of B
+# * A will find a bad cookie and cause *all* statements
+# to be expired including the currently running B by calling
+# sqlite3ExpirePreparedStatements
+# * When control returns to B it will then abort
+#
+# The bug is that sqlite3ExpirePreparedStatements expires all statements.
+# Note that B was prepared after the schema change and hence is perfectly
+# valid and then is marked as expired while running.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+unset -nocomplain ::STMT
+proc runsql {} {
+ db eval {CREATE TABLE IF NOT EXISTS t4(q)}
+ sqlite3_step $::STMT
+ set rc [sqlite3_column_int $::STMT 0]
+ sqlite3_reset $::STMT
+ return $rc
+}
+
+do_test tkt-b72787b1.1 {
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ CREATE TABLE t2(y);
+ INSERT INTO t2 SELECT x+2 FROM t1;
+ INSERT INTO t2 SELECT x+4 FROM t1;
+ }
+ db func runsql ::runsql
+ set DB [sqlite3_connection_pointer db]
+ set sql {SELECT max(x) FROM t1}
+ set ::STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]
+
+ # The runsql() call on the second row of the first query will
+ # cause all $::STMT to hit an expired cookie. Prior to the fix
+ # for [b72787b1a7, the bad cookie would expire all statements, including
+ # the following compound SELECT, which would cause a fault when the
+ # second SELECT was reached. After the fix, the current statement
+ # continues to completion.
+ db eval {
+ SELECT CASE WHEN y=3 THEN y+100 WHEN y==4 THEN runsql()+200
+ ELSE 300+y END FROM t2
+ UNION ALL
+ SELECT * FROM t1;
+ }
+} {103 202 305 306 1 2}
+
+sqlite3_finalize $::STMT
+
+finish_test
diff --git a/test/tkt-bd484a090c.test b/test/tkt-bd484a090c.test
new file mode 100644
index 0000000..3d2b599
--- /dev/null
+++ b/test/tkt-bd484a090c.test
@@ -0,0 +1,38 @@
+# 2011 June 21
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests for SQLite. Specifically, it tests that SQLite
+# does not crash and an error is returned if localhost() fails. This
+# is the problem reported by ticket bd484a090c.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix tkt-bd484a090c
+
+
+do_test 1.1 {
+ lindex [catchsql { SELECT datetime('now', 'localtime') }] 0
+} {0}
+do_test 1.2 {
+ lindex [catchsql { SELECT datetime('now', 'utc') }] 0
+} {0}
+
+sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 1
+
+do_test 2.1 {
+ catchsql { SELECT datetime('now', 'localtime') }
+} {1 {local time unavailable}}
+do_test 2.2 {
+ catchsql { SELECT datetime('now', 'utc') }
+} {1 {local time unavailable}}
+
+sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 0
+
+finish_test
diff --git a/test/tkt-c48d99d690.test b/test/tkt-c48d99d690.test
new file mode 100644
index 0000000..9b40579
--- /dev/null
+++ b/test/tkt-c48d99d690.test
@@ -0,0 +1,26 @@
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set ::testprefix tkt-c48d99d690
+
+do_test 1.0 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t1 VALUES('one' , 1);
+ INSERT INTO t1 VALUES('two' , 5);
+ INSERT INTO t1 VALUES('two' , 2);
+ INSERT INTO t1 VALUES('three', 3);
+ PRAGMA count_changes = 1;
+ }
+} {}
+
+do_test 1.1 {
+ execsql { INSERT INTO t2 SELECT * FROM t1 }
+} {4}
+
+do_test 1.2 { execsql VACUUM } {}
+
+finish_test
+
diff --git a/test/tkt-cbd054fa6b.test b/test/tkt-cbd054fa6b.test
new file mode 100644
index 0000000..180acf5
--- /dev/null
+++ b/test/tkt-cbd054fa6b.test
@@ -0,0 +1,87 @@
+# 2010 March 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests to verify that ticket [cbd054fa6b] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !stat3 {
+ finish_test
+ return
+}
+
+do_test tkt-cbd05-1.1 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT UNIQUE NOT NULL);
+ CREATE INDEX t1_x ON t1(b);
+ INSERT INTO t1 VALUES (NULL, '');
+ INSERT INTO t1 VALUES (NULL, 'A');
+ INSERT INTO t1 VALUES (NULL, 'B');
+ INSERT INTO t1 VALUES (NULL, 'C');
+ INSERT INTO t1 VALUES (NULL, 'D');
+ INSERT INTO t1 VALUES (NULL, 'E');
+ INSERT INTO t1 VALUES (NULL, 'F');
+ INSERT INTO t1 VALUES (NULL, 'G');
+ INSERT INTO t1 VALUES (NULL, 'H');
+ INSERT INTO t1 VALUES (NULL, 'I');
+ SELECT count(*) FROM t1;
+ }
+} {10}
+do_test tkt-cbd05-1.2 {
+ db eval {
+ ANALYZE;
+ }
+} {}
+do_test tkt-cbd05-1.3 {
+ execsql {
+ SELECT tbl,idx,group_concat(sample,' ')
+ FROM sqlite_stat3
+ WHERE idx = 't1_x'
+ GROUP BY tbl,idx
+ }
+} {t1 t1_x { A B C D E F G H I}}
+
+do_test tkt-cbd05-2.1 {
+ db eval {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB UNIQUE NOT NULL);
+ CREATE INDEX t1_x ON t1(b);
+ INSERT INTO t1 VALUES(NULL, X'');
+ INSERT INTO t1 VALUES(NULL, X'41');
+ INSERT INTO t1 VALUES(NULL, X'42');
+ INSERT INTO t1 VALUES(NULL, X'43');
+ INSERT INTO t1 VALUES(NULL, X'44');
+ INSERT INTO t1 VALUES(NULL, X'45');
+ INSERT INTO t1 VALUES(NULL, X'46');
+ INSERT INTO t1 VALUES(NULL, X'47');
+ INSERT INTO t1 VALUES(NULL, X'48');
+ INSERT INTO t1 VALUES(NULL, X'49');
+ SELECT count(*) FROM t1;
+ }
+} {10}
+do_test tkt-cbd05-2.2 {
+ db eval {
+ ANALYZE;
+ }
+} {}
+do_test tkt-cbd05-2.3 {
+ execsql {
+ SELECT tbl,idx,group_concat(sample,' ')
+ FROM sqlite_stat3
+ WHERE idx = 't1_x'
+ GROUP BY tbl,idx
+ }
+} {t1 t1_x { A B C D E F G H I}}
+
+finish_test
diff --git a/test/tkt-d11f09d36e.test b/test/tkt-d11f09d36e.test
new file mode 100644
index 0000000..7065770
--- /dev/null
+++ b/test/tkt-d11f09d36e.test
@@ -0,0 +1,62 @@
+# 2010 June 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test that the bug reported by ticket d11f09d36e7cb0821e01f4 has
+# been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set a_string_counter 1
+proc a_string {n} {
+ global a_string_counter
+ incr a_string_counter
+ string range [string repeat "${a_string_counter}." $n] 1 $n
+}
+db func a_string a_string
+
+do_test tkt-d11f09d36e.1 {
+ execsql {
+ PRAGMA synchronous = NORMAL;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(x, y, UNIQUE(x, y));
+ BEGIN;
+ }
+ for {set i 0} {$i < 10000} {incr i} {
+ execsql { INSERT INTO t1 VALUES($i, $i) }
+ }
+ execsql COMMIT
+} {}
+do_test tkt-d11f09d36e.2 {
+ execsql {
+ BEGIN;
+ UPDATE t1 set x = x+10000;
+ ROLLBACK;
+ }
+} {}
+do_test tkt-d11f09d36e.3 {
+ execsql { PRAGMA integrity_check }
+} {ok}
+do_test tkt-d11f09d36e.4 {
+ execsql {
+ SAVEPOINT tr;
+ UPDATE t1 set x = x+10000;
+ ROLLBACK TO tr;
+ RELEASE tr;
+ }
+} {}
+do_test tkt-d11f09d36e.5 {
+ execsql { PRAGMA integrity_check }
+} {ok}
+
+finish_test
+
diff --git a/test/tkt-d635236375.test b/test/tkt-d635236375.test
new file mode 100644
index 0000000..3fc7822
--- /dev/null
+++ b/test/tkt-d635236375.test
@@ -0,0 +1,38 @@
+# 2011 August 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that bug [d63523637517386191d634e]
+# has been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set ::testprefix tkt-d635236375
+
+do_test 1.0 {
+ execsql {
+ CREATE TABLE t1(id1 INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(9999);
+ CREATE TABLE t2(id2 INTEGER PRIMARY KEY);
+ INSERT INTO t2 VALUES(12345);
+ INSERT INTO t2 VALUES(54321);
+ SELECT DISTINCT id1 AS x, id1 AS y FROM t1, t2;
+ }
+} {9999 9999}
+do_test 1.1 {
+ execsql {
+ SELECT count(*) FROM t1, t2 GROUP BY id1, id1;
+ }
+} {2}
+
+
+finish_test
diff --git a/test/tkt-d82e3f3721.test b/test/tkt-d82e3f3721.test
new file mode 100644
index 0000000..31f7d34
--- /dev/null
+++ b/test/tkt-d82e3f3721.test
@@ -0,0 +1,80 @@
+# 2009 September 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [d82e3f3721] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-d82e3-1.1 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b);
+ INSERT INTO t1 VALUES(null,'abc');
+ INSERT INTO t1 VALUES(null,'def');
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(null,'ghi');
+ SELECT * FROM t1;
+ }
+} {3 ghi}
+do_test tkt-d82e3-1.2 {
+ db eval {
+ CREATE TEMP TABLE t2(a INTEGER PRIMARY KEY AUTOINCREMENT, b);
+ INSERT INTO t2 VALUES(null,'jkl');
+ INSERT INTO t2 VALUES(null,'mno');
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES(null,'pqr');
+ SELECT * FROM t2;
+ }
+} {3 pqr}
+do_test tkt-d82e3-1.3 {
+ db eval {
+ SELECT 'main', * FROM main.sqlite_sequence
+ UNION ALL
+ SELECT 'temp', * FROM temp.sqlite_sequence
+ ORDER BY 2
+ }
+} {main t1 3 temp t2 3}
+do_test tkt-d82e3-1.4 {
+ db eval {
+ VACUUM;
+ SELECT 'main', * FROM main.sqlite_sequence
+ UNION ALL
+ SELECT 'temp', * FROM temp.sqlite_sequence
+ ORDER BY 2
+ }
+} {main t1 3 temp t2 3}
+
+sqlite3 db2 test.db
+do_test tkt-d82e3-2.1 {
+ db eval {
+ CREATE TEMP TABLE t3(x);
+ INSERT INTO t3 VALUES(1);
+ }
+ db2 eval {
+ CREATE TABLE t3(y,z);
+ INSERT INTO t3 VALUES(8,9);
+ }
+ db eval {
+ SELECT * FROM temp.t3 JOIN main.t3;
+ }
+} {1 8 9}
+do_test tkt-d82e3-2.2 {
+ db eval {
+ VACUUM;
+ SELECT * FROM temp.t3 JOIN main.t3;
+ }
+} {1 8 9}
+db2 close
+
+finish_test
diff --git a/test/tkt-f3e5abed55.test b/test/tkt-f3e5abed55.test
new file mode 100644
index 0000000..b3f5d56
--- /dev/null
+++ b/test/tkt-f3e5abed55.test
@@ -0,0 +1,117 @@
+# 2010 July 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+foreach f [glob -nocomplain test.db*mj*] { forcedelete $f }
+forcedelete test.db2
+
+do_test tkt-f3e5abed55-1.1 {
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE main.t1(a, b);
+ CREATE TABLE aux.t2(c, d);
+ }
+} {}
+
+do_test tkt-f3e5abed55-1.2 {
+ glob -nocomplain test.db*mj*
+} {}
+
+do_test tkt-f3e5abed55-1.3 {
+ sqlite3 db2 test.db
+ execsql { BEGIN; SELECT * FROM t1 } db2
+} {}
+
+do_test tkt-f3e5abed55-1.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(1, 2);
+ }
+ catchsql COMMIT
+} {1 {database is locked}}
+
+do_test tkt-f3e5abed55-1.5 {
+ execsql COMMIT db2
+ execsql COMMIT
+} {}
+
+do_test tkt-f3e5abed55-1.6 {
+ glob -nocomplain test.db*mj*
+} {}
+foreach f [glob -nocomplain test.db*mj*] { forcedelete $f }
+db close
+db2 close
+
+
+
+# Set up a testvfs so that the next time SQLite tries to delete the
+# file "test.db-journal", a snapshot of the current file-system contents
+# is taken.
+#
+# This test will not work with an in-memory journal.
+#
+if {[permutation]!="inmemory_journal"} {
+ testvfs tvfs -default 1
+ tvfs script xDelete
+ tvfs filter xDelete
+ proc xDelete {method file args} {
+ if {[file tail $file] == "test.db-journal"} {
+ faultsim_save
+ tvfs filter {}
+ }
+ return "SQLITE_OK"
+ }
+
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ do_test tkt-f3e5abed55-2.1 {
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t2 VALUES(3, 4);
+ }
+ } {}
+ do_test tkt-f3e5abed55-2.2 {
+ execsql { BEGIN; SELECT * FROM t1 } db2
+ } {1 2}
+ do_test tkt-f3e5abed55-2.3 {
+ catchsql COMMIT
+ } {1 {database is locked}}
+
+ do_test tkt-f3e5abed55-2.4 {
+ execsql COMMIT db2
+ execsql {
+ COMMIT;
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+ } {1 2 3 4 1 2 3 4}
+ do_test tkt-f3e5abed55-2.5 {
+ db close
+ db2 close
+ faultsim_restore_and_reopen
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+ } {1 2 3 4 1 2 3 4}
+}
+
+
+finish_test
+
diff --git a/test/tkt-f777251dc7a.test b/test/tkt-f777251dc7a.test
new file mode 100644
index 0000000..6f0b43f
--- /dev/null
+++ b/test/tkt-f777251dc7a.test
@@ -0,0 +1,99 @@
+# 2009 October 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [f777251dc7a] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-f7772-1.1 {
+ execsql {
+ CREATE TEMP TABLE t1(x UNIQUE);
+ INSERT INTO t1 VALUES(1);
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES(1, 2);
+ CREATE TEMP TABLE t3(w, z);
+ }
+} {}
+
+proc force_rollback {} {
+ catch {db eval {INSERT OR ROLLBACK INTO t1 VALUES(1)}}
+}
+db function force_rollback force_rollback
+
+do_test tkt-f7772-1.2 {
+ catchsql {
+ BEGIN IMMEDIATE;
+ SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2;
+ }
+} {1 {callback requested query abort}}
+do_test tkt-f7772-1.3 {
+ sqlite3_get_autocommit db
+} {1}
+
+do_test tkt-f7772-2.1 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ DROP TABLE IF EXISTS t3;
+
+ CREATE TEMP TABLE t1(x UNIQUE);
+ INSERT INTO t1 VALUES(1);
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES(1, 2);
+ }
+} {}
+do_test tkt-f7772-2.2 {
+ execsql {
+ BEGIN IMMEDIATE;
+ CREATE TEMP TABLE t3(w, z);
+ }
+ catchsql {
+ SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2
+ }
+} {1 {callback requested query abort}}
+do_test tkt-f7772-2.3 {
+ sqlite3_get_autocommit db
+} {1}
+
+do_test tkt-f7772-3.1 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ DROP TABLE IF EXISTS t3;
+
+ CREATE TEMP TABLE t1(x);
+ CREATE TABLE t2(x);
+ CREATE TABLE t3(x);
+
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ }
+} {}
+
+proc ins {} { db eval {INSERT INTO t3 VALUES('hello')} }
+db function ins ins
+
+do_test tkt-f7772-3.2 {
+ execsql {
+ SELECT ins() AS x FROM t2 UNION ALL SELECT ins() AS x FROM t1
+ }
+} {{} {} {} {}}
+do_test tkt-f7772-3.3 {
+ execsql { SELECT * FROM t3 }
+} {hello hello hello hello}
+
+finish_test
diff --git a/test/tkt-f7b4edec.test b/test/tkt-f7b4edec.test
new file mode 100644
index 0000000..f6d3d5b
--- /dev/null
+++ b/test/tkt-f7b4edec.test
@@ -0,0 +1,74 @@
+# 2011 March 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket
+# [f7b4edece25c994857dc139207f55a53c8319fae] has been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Open two database connections to the same database file in
+# shared cache mode. Create update hooks that will fire on
+# each connection.
+#
+db close
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+sqlite3 db1 test.db
+sqlite3 db2 test.db
+unset -nocomplain HOOKS
+set HOOKS {}
+proc update_hook {args} { lappend ::HOOKS $args }
+db1 update_hook update_hook
+db2 update_hook update_hook
+
+# Create a prepared statement
+#
+do_test tkt-f7b4edec-1 {
+ execsql { CREATE TABLE t1(x, y); } db1
+ execsql { INSERT INTO t1 VALUES(1, 2) } db1
+ set ::HOOKS
+} {{INSERT main t1 1}}
+
+# In the second database connection cause the schema to be reparsed
+# without changing the schema cookie.
+#
+set HOOKS {}
+do_test tkt-f7b4edec-2 {
+ execsql {
+ BEGIN;
+ DROP TABLE t1;
+ CREATE TABLE t1(x, y);
+ ROLLBACK;
+ } db2
+ set ::HOOKS
+} {}
+
+# Rerun the prepared statement that was created prior to the
+# schema reparse. Verify that the update-hook gives the correct
+# output.
+#
+set HOOKS {}
+do_test tkt-f7b4edec-3 {
+ execsql { INSERT INTO t1 VALUES(1, 2) } db1
+ set ::HOOKS
+} {{INSERT main t1 2}}
+
+# Be sure to restore the original shared-cache mode setting before
+# returning.
+#
+db1 close
+db2 close
+sqlite3_enable_shared_cache $::enable_shared_cache
+
+
+finish_test
diff --git a/test/tkt-f973c7ac31.test b/test/tkt-f973c7ac31.test
new file mode 100644
index 0000000..882e86a
--- /dev/null
+++ b/test/tkt-f973c7ac31.test
@@ -0,0 +1,87 @@
+# 2010 June 09
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-f973c7ac3-1.0 {
+ execsql {
+ CREATE TABLE t(c1 INTEGER, c2 INTEGER);
+ INSERT INTO t VALUES(5, 5);
+ INSERT INTO t VALUES(5, 4);
+ }
+} {}
+
+foreach {tn sql} {
+ 1 ""
+ 2 "CREATE INDEX i1 ON t(c1, c2)"
+} {
+
+ execsql $sql
+
+ do_test tkt-f973c7ac3-1.$tn.1 {
+ execsql {
+ SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='2' ORDER BY c2 DESC
+ }
+ } {}
+ do_test tkt-f973c7ac3-1.$tn.2 {
+ execsql {
+ SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<=5 ORDER BY c2 DESC
+ }
+ } {5 5 5 4}
+ do_test tkt-f973c7ac3-1.$tn.3 {
+ execsql {
+ SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='5' ORDER BY c2 DESC
+ }
+ } {5 5 5 4}
+ do_test tkt-f973c7ac3-1.$tn.4 {
+ execsql {
+ SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<=5 ORDER BY c2 DESC
+ }
+ } {5 5 5 4}
+ do_test tkt-f973c7ac3-1.$tn.5 {
+ execsql {
+ SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<='5' ORDER BY c2 DESC
+ }
+ } {5 5 5 4}
+
+ do_test tkt-f973c7ac3-1.$tn.6 {
+ execsql {
+ SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='2' ORDER BY c2 ASC
+ }
+ } {}
+ do_test tkt-f973c7ac3-1.$tn.7 {
+ execsql {
+ SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<=5 ORDER BY c2 ASC
+ }
+ } {5 4 5 5}
+ do_test tkt-f973c7ac3-1.$tn.8 {
+ execsql {
+ SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='5' ORDER BY c2 ASC
+ }
+ } {5 4 5 5}
+ do_test tkt-f973c7ac3-1.$tn.9 {
+ execsql {
+ SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<=5 ORDER BY c2 ASC
+ }
+ } {5 4 5 5}
+ do_test tkt-f973c7ac3-1.$tn.10 {
+ execsql {
+ SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<='5' ORDER BY c2 ASC
+ }
+ } {5 4 5 5}
+}
+
+
+finish_test
+
diff --git a/test/tkt-fa7bf5ec.test b/test/tkt-fa7bf5ec.test
new file mode 100644
index 0000000..34f12b9
--- /dev/null
+++ b/test/tkt-fa7bf5ec.test
@@ -0,0 +1,39 @@
+# 2011 October 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that ticket [fa7bf5ec94801e7e2030e41eefe5d9dd96eaacfd] has
+# been resolved.
+#
+# The problem described by this ticket was that the sqlite3ExprCompare()
+# function was saying that expressions (x='a') and (x='A') were identical
+# because it was using sqlite3StrICmp() instead of strcmp() to compare string
+# literals. That was causing the query optimizer for aggregate queries to
+# believe that both count() operations were identical, and thus only
+# computing the first count() and making a copy of the result for the
+# second count().
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-fa7bf5ec-1 {
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES ('a');
+ INSERT INTO t1 VALUES ('A');
+ INSERT INTO t1 VALUES ('A');
+ SELECT count(CASE WHEN x='a' THEN 1 END),
+ count(CASE WHEN x='A' THEN 1 END)
+ FROM t1;
+ }
+} {1 2}
+
+finish_test
diff --git a/test/tkt-fc62af4523.test b/test/tkt-fc62af4523.test
new file mode 100644
index 0000000..ed1497b
--- /dev/null
+++ b/test/tkt-fc62af4523.test
@@ -0,0 +1,84 @@
+# 2010 June 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that ticket [fc62af4523] has been resolved.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+do_test tkt-fc62af4523.1 {
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA journal_mode = persist;
+ CREATE TABLE t1(a UNIQUE, b UNIQUE);
+ INSERT INTO t1 SELECT randomblob(200), randomblob(300);
+ INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; -- 2
+ INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; -- 4
+ INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; -- 8
+ INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; -- 16
+ INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; -- 32
+ INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; -- 64
+ }
+ execsql {
+ PRAGMA integrity_check;
+ SELECT count(*) FROM t1;
+ }
+} {ok 64}
+
+# Launch an external process. Have it write (but not commit) a large
+# transaction to the database.
+#
+set ::chan [launch_testfixture]
+proc buddy {code} { testfixture $::chan $code }
+do_test tkt-fc62af4523.2 {
+ testfixture $::chan {
+ sqlite3 db test.db
+ db eval {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ UPDATE t1 SET b = randomblob(400);
+ UPDATE t1 SET a = randomblob(201);
+ }
+ }
+ file exists test.db-journal
+} {1}
+
+# Now do "PRAGMA journal_mode = DELETE" in this process. At one point
+# this was causing SQLite to delete the journal file from the file-system,
+# even though the external process is currently using it.
+#
+do_test tkt-fc62af4523.3 { execsql { PRAGMA journal_mode = DELETE } } {delete}
+do_test tkt-fc62af4523.4 { file exists test.db-journal } {1}
+
+# Cause the external process to crash. Since it has already written
+# uncommitted data into the database file, the next reader will have
+# to do a hot-journal rollback to recover the database.
+#
+# Or, if this test is run in a version with the bug present, the journal
+# file has already been deleted. In this case we are left with a corrupt
+# database file and no hot-journal to fix it with.
+#
+do_test tkt-fc62af4523.5 {
+ testfixture $::chan sqlite_abort
+} {ERROR: Child process hung up}
+after 200
+do_test tkt-fc62af4523.6 {
+ execsql {
+ PRAGMA integrity_check;
+ SELECT count(*) FROM t1;
+ }
+} {ok 64}
+
+catch { close $::chan }
+finish_test
diff --git a/test/tkt1435.test b/test/tkt1435.test
new file mode 100644
index 0000000..1f62147
--- /dev/null
+++ b/test/tkt1435.test
@@ -0,0 +1,111 @@
+# 2005 September 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1435 has been
+# fixed.
+#
+#
+# $Id: tkt1435.test,v 1.2 2006/01/17 09:35:02 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !memorydb {
+ finish_test
+ return
+}
+
+# Construct the sample database.
+#
+do_test tkt1435-1.0 {
+ sqlite3 db :memory:
+ execsql {
+ CREATE TABLE Instances(
+ instanceId INTEGER PRIMARY KEY,
+ troveName STR,
+ versionId INT,
+ flavorId INT,
+ timeStamps STR,
+ isPresent INT,
+ pinned BOOLEAN
+ );
+ INSERT INTO "Instances"
+ VALUES(1, 'libhello:runtime', 1, 1, 1126929880.094, 1, 1);
+ INSERT INTO "Instances"
+ VALUES(2, 'libhello:user', 1, 1, 1126929880.094, 1, 0);
+ INSERT INTO "Instances"
+ VALUES(3, 'libhello:script', 1, 1, 1126929880.094, 1, 0);
+ INSERT INTO "Instances"
+ VALUES(4, 'libhello', 1, 1, 1126929880.094, 1, 0);
+
+ CREATE TABLE Versions(versionId INTEGER PRIMARY KEY,version STR UNIQUE);
+ INSERT INTO "Versions" VALUES(0, NULL);
+ INSERT INTO "Versions" VALUES(1, '/localhost@rpl:linux/0-1-1');
+
+ CREATE TABLE Flavors(flavorId integer primary key, flavor str unique);
+ INSERT INTO "Flavors" VALUES(0, NULL);
+ INSERT INTO "Flavors" VALUES(1, '1#x86');
+
+ CREATE TEMPORARY TABLE tlList (
+ row INTEGER PRIMARY KEY,
+ name STRING,
+ version STRING,
+ flavor STRING
+ );
+
+ INSERT INTO tlList
+ values(NULL, 'libhello:script', '/localhost@rpl:linux/0-1-1', '1#x86');
+ INSERT INTO tlList
+ values(NULL, 'libhello:user', '/localhost@rpl:linux/0-1-1', '1#x86');
+ INSERT INTO tlList
+ values(NULL, 'libhello:runtime', '/localhost@rpl:linux/0-1-1', '1#x86');
+ }
+} {}
+
+# Run the query with an index
+#
+do_test tkt1435-1.1 {
+ execsql {
+ select row, pinned from tlList, Instances, Versions, Flavors
+ where
+ Instances.troveName = tlList.name
+ and Versions.version = tlList.version
+ and Instances.versionId = Versions.versionId
+ and ( Flavors.flavor = tlList.flavor or Flavors.flavor is NULL
+ and tlList.flavor = '')
+ and Instances.flavorId = Flavors.flavorId
+ order by row asc;
+ }
+} {1 0 2 0 3 1}
+
+# Create a indices, analyze and rerun the query.
+# Verify that the results are the same
+#
+do_test tkt1435-1.2 {
+ execsql {
+ CREATE INDEX InstancesNameIdx ON Instances(troveName);
+ CREATE UNIQUE INDEX InstancesIdx
+ ON Instances(troveName, versionId, flavorId);
+ ANALYZE;
+ select row, pinned from tlList, Instances, Versions, Flavors
+ where
+ Instances.troveName = tlList.name
+ and Versions.version = tlList.version
+ and Instances.versionId = Versions.versionId
+ and ( Flavors.flavor = tlList.flavor or Flavors.flavor is NULL
+ and tlList.flavor = '')
+ and Instances.flavorId = Flavors.flavorId
+ order by row asc;
+ }
+} {1 0 2 0 3 1}
+
+finish_test
diff --git a/test/tkt1443.test b/test/tkt1443.test
new file mode 100644
index 0000000..0f55437
--- /dev/null
+++ b/test/tkt1443.test
@@ -0,0 +1,180 @@
+# 2005 September 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1433 has been
+# fixed.
+#
+# The problem in ticket #1433 was that the dependencies on the right-hand
+# side of an IN operator were not being checked correctly. So in an
+# expression of the form:
+#
+# t1.x IN (1,t2.b,3)
+#
+# the optimizer was missing the fact that the right-hand side of the IN
+# depended on table t2. It was checking dependencies based on the
+# Expr.pRight field rather than Expr.pList and Expr.pSelect.
+#
+# Such a bug could be verifed using a less elaborate test case. But
+# this test case (from the original bug poster) exercises so many different
+# parts of the system all at once, that it seemed like a good one to
+# include in the test suite.
+#
+# NOTE: Yes, in spite of the name of this file (tkt1443.test) this
+# test is for ticket #1433 not #1443. I mistyped the name when I was
+# creating the file and I had already checked in the file by the wrong
+# name be the time I noticed the error. With CVS it is a really hassle
+# to change filenames, so I'll just leave it as is. No harm done.
+#
+# $Id: tkt1443.test,v 1.4 2006/01/17 09:35:02 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery||!memorydb {
+ finish_test
+ return
+}
+
+# Construct the sample database.
+#
+do_test tkt1443-1.0 {
+ sqlite3 db :memory:
+ execsql {
+ CREATE TABLE Items(
+ itemId integer primary key,
+ item str unique
+ );
+ INSERT INTO "Items" VALUES(0, 'ALL');
+ INSERT INTO "Items" VALUES(1, 'double:source');
+ INSERT INTO "Items" VALUES(2, 'double');
+ INSERT INTO "Items" VALUES(3, 'double:runtime');
+ INSERT INTO "Items" VALUES(4, '.*:runtime');
+
+ CREATE TABLE Labels(
+ labelId INTEGER PRIMARY KEY,
+ label STR UNIQUE
+ );
+ INSERT INTO "Labels" VALUES(0, 'ALL');
+ INSERT INTO "Labels" VALUES(1, 'localhost@rpl:linux');
+ INSERT INTO "Labels" VALUES(2, 'localhost@rpl:branch');
+
+ CREATE TABLE LabelMap(
+ itemId INTEGER,
+ labelId INTEGER,
+ branchId integer
+ );
+ INSERT INTO "LabelMap" VALUES(1, 1, 1);
+ INSERT INTO "LabelMap" VALUES(2, 1, 1);
+ INSERT INTO "LabelMap" VALUES(3, 1, 1);
+ INSERT INTO "LabelMap" VALUES(1, 2, 2);
+ INSERT INTO "LabelMap" VALUES(2, 2, 3);
+ INSERT INTO "LabelMap" VALUES(3, 2, 3);
+
+ CREATE TABLE Users (
+ userId INTEGER PRIMARY KEY,
+ user STRING UNIQUE,
+ salt BINARY,
+ password STRING
+ );
+ INSERT INTO "Users" VALUES(1, 'test', 'Šæ$d',
+ '43ba0f45014306bd6df529551ffdb3df');
+ INSERT INTO "Users" VALUES(2, 'limited', 'ªš>S',
+ 'cf07c8348fdf675cc1f7696b7d45191b');
+ CREATE TABLE UserGroups (
+ userGroupId INTEGER PRIMARY KEY,
+ userGroup STRING UNIQUE
+ );
+ INSERT INTO "UserGroups" VALUES(1, 'test');
+ INSERT INTO "UserGroups" VALUES(2, 'limited');
+
+ CREATE TABLE UserGroupMembers (
+ userGroupId INTEGER,
+ userId INTEGER
+ );
+ INSERT INTO "UserGroupMembers" VALUES(1, 1);
+ INSERT INTO "UserGroupMembers" VALUES(2, 2);
+
+ CREATE TABLE Permissions (
+ userGroupId INTEGER,
+ labelId INTEGER NOT NULL,
+ itemId INTEGER NOT NULL,
+ write INTEGER,
+ capped INTEGER,
+ admin INTEGER
+ );
+ INSERT INTO "Permissions" VALUES(1, 0, 0, 1, 0, 1);
+ INSERT INTO "Permissions" VALUES(2, 2, 4, 0, 0, 0);
+ }
+} {}
+
+# Run the query with an index
+#
+do_test tkt1443-1.1 {
+ execsql {
+ select distinct
+ Items.Item as trove, UP.pattern as pattern
+ from
+ ( select
+ Permissions.labelId as labelId,
+ PerItems.item as pattern
+ from
+ Users, UserGroupMembers, Permissions
+ left outer join Items as PerItems
+ on Permissions.itemId = PerItems.itemId
+ where
+ Users.user = 'limited'
+ and Users.userId = UserGroupMembers.userId
+ and UserGroupMembers.userGroupId = Permissions.userGroupId
+ ) as UP join LabelMap on ( UP.labelId = 0 or
+ UP.labelId = LabelMap.labelId ),
+ Labels, Items
+ where
+ Labels.label = 'localhost@rpl:branch'
+ and Labels.labelId = LabelMap.labelId
+ and LabelMap.itemId = Items.itemId
+ ORDER BY +trove, +pattern
+ }
+} {double .*:runtime double:runtime .*:runtime double:source .*:runtime}
+
+# Create an index and rerun the query.
+# Verify that the results are the same
+#
+do_test tkt1443-1.2 {
+ execsql {
+ CREATE UNIQUE INDEX PermissionsIdx
+ ON Permissions(userGroupId, labelId, itemId);
+ select distinct
+ Items.Item as trove, UP.pattern as pattern
+ from
+ ( select
+ Permissions.labelId as labelId,
+ PerItems.item as pattern
+ from
+ Users, UserGroupMembers, Permissions
+ left outer join Items as PerItems
+ on Permissions.itemId = PerItems.itemId
+ where
+ Users.user = 'limited'
+ and Users.userId = UserGroupMembers.userId
+ and UserGroupMembers.userGroupId = Permissions.userGroupId
+ ) as UP join LabelMap on ( UP.labelId = 0 or
+ UP.labelId = LabelMap.labelId ),
+ Labels, Items
+ where
+ Labels.label = 'localhost@rpl:branch'
+ and Labels.labelId = LabelMap.labelId
+ and LabelMap.itemId = Items.itemId
+ ORDER BY +trove, +pattern
+ }
+} {double .*:runtime double:runtime .*:runtime double:source .*:runtime}
+
+finish_test
diff --git a/test/tkt1444.test b/test/tkt1444.test
new file mode 100644
index 0000000..13870db
--- /dev/null
+++ b/test/tkt1444.test
@@ -0,0 +1,56 @@
+# 2005 September 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1444 has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !compound||!view {
+ finish_test
+ return
+}
+
+# The use of a VIEW that contained an ORDER BY clause within a UNION ALL
+# was causing problems. See ticket #1444.
+#
+do_test tkt1444-1.1 {
+ execsql {
+ CREATE TABLE DemoTable (x INTEGER, TextKey TEXT, DKey Real);
+ CREATE INDEX DemoTableIdx ON DemoTable (TextKey);
+ INSERT INTO DemoTable VALUES(9,8,7);
+ INSERT INTO DemoTable VALUES(1,2,3);
+ CREATE VIEW DemoView AS SELECT * FROM DemoTable ORDER BY TextKey;
+ SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView ORDER BY 1;
+ }
+} {1 2 3.0 1 2 3.0 9 8 7.0 9 8 7.0}
+do_test tkt1444-1.2 {
+ execsql {
+ SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView;
+ }
+} {9 8 7.0 1 2 3.0 1 2 3.0 9 8 7.0}
+do_test tkt1444-1.3 {
+ execsql {
+ DROP VIEW DemoView;
+ CREATE VIEW DemoView AS SELECT * FROM DemoTable;
+ SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView ORDER BY 1;
+ }
+} {1 2 3.0 1 2 3.0 9 8 7.0 9 8 7.0}
+do_test tkt1444-1.4 {
+ execsql {
+ SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView;
+ }
+} {9 8 7.0 1 2 3.0 9 8 7.0 1 2 3.0}
+
+finish_test
diff --git a/test/tkt1449.test b/test/tkt1449.test
new file mode 100644
index 0000000..5f27ee7
--- /dev/null
+++ b/test/tkt1449.test
@@ -0,0 +1,262 @@
+# 2005 September 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1449 has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Somewhere in tkt1449-1.1 is a VIEW definition that uses a subquery and
+# a compound SELECT. So we cannot run this file if any of these features
+# are not available.
+ifcapable !subquery||!compound||!view {
+ finish_test
+ return
+}
+
+# The following schema generated problems in ticket #1449. We've retained
+# the original schema here because it is some unbelievably complex, it seemed
+# like a good test case for SQLite.
+#
+do_test tkt1449-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE ACLS(ISSUEID text(50) not null, OBJECTID text(50) not null, PARTICIPANTID text(50) not null, PERMISSIONBITS int not null, constraint PK_ACLS primary key (ISSUEID, OBJECTID, PARTICIPANTID));
+ CREATE TABLE ACTIONITEMSTATUSES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, FRIENDLYNAME text(100) not null, REVISION int not null, SHORTNAME text(30) not null, LONGNAME text(200) not null, ATTACHMENTHANDLING int not null, RESULT int not null, NOTIFYCREATOR text(1) null, NOTIFYASSIGNEE text(1) null, NOTIFYFYI text(1) null, NOTIFYCLOSURETEAM text(1) null, NOTIFYCOORDINATORS text(1) null, COMMENTREQUIRED text(1) not null, constraint PK_ACTIONITEMSTATUSES primary key (ISSUEID, OBJECTID));
+ CREATE TABLE ACTIONITEMTYPES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, REVISION int not null, LABEL text(200) not null, INSTRUCTIONS text not null, EMAILINSTRUCTIONS text null, ALLOWEDSTATUSES text not null, INITIALSTATUS text(100) not null, COMMENTREQUIRED text(1) not null, ATTACHMENTHANDLING int not null, constraint PK_ACTIONITEMTYPES primary key (ISSUEID, OBJECTID));
+ CREATE TABLE ATTACHMENTS(TQUNID text(36) not null, OBJECTID text(50) null, ISSUEID text(50) null, DATASTREAM blob not null, CONTENTENCODING text(50) null, CONTENTCHARSET text(50) null, CONTENTTYPE text(100) null, CONTENTID text(100) null, CONTENTLOCATION text(100) null, CONTENTNAME text(100) not null, constraint PK_ATTACHMENTS primary key (TQUNID));
+ CREATE TABLE COMPLIANCEPOLICIES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, BODY text null, constraint PK_COMPLIANCEPOLICIES primary key (ISSUEID, OBJECTID));
+ CREATE TABLE DBHISTORY(DATETIME text(25) not null, OPERATION text(20) not null, KUBIVERSION text(100) not null, FROMVERSION int null, TOVERSION int null);
+ CREATE TABLE DBINFO(FINGERPRINT text(32) not null, VERSION int not null);
+ CREATE TABLE DETACHEDATTACHMENTS (TQUNID text(36) not null, ISSUEID text(50) not null, OBJECTID text(50) not null, PATH text(300) not null, DETACHEDFILELASTMODTIMESTAMP text(25) null, CONTENTID text(100) not null, constraint PK_DETACHEDATTACHMENTS primary key (TQUNID));
+ CREATE TABLE DOCREFERENCES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, REFERENCEDOCUMENTID text(50) null, constraint PK_DOCREFERENCES primary key (ISSUEID, OBJECTID));
+ CREATE TABLE DQ (TQUNID text(36) not null, ISSUEID text(50) not null, DEPENDSID text(50) null, DEPENDSTYPE int null, DEPENDSCOMMANDSTREAM blob null, DEPENDSNODEIDSEQNOKEY text(100) null, DEPENDSACLVERSION int null, constraint PK_DQ primary key (TQUNID));
+ CREATE TABLE EMAILQ(TIMEQUEUED int not null, NODEID text(50) not null, MIME blob not null, TQUNID text(36) not null);
+ CREATE TABLE ENTERPRISEDATA(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, DATE1 text(25) null, DATE2 text(25) null, DATE3 text(25) null, DATE4 text(25) null, DATE5 text(25) null, DATE6 text(25) null, DATE7 text(25) null, DATE8 text(25) null, DATE9 text(25) null, DATE10 text(25) null, VALUE1 int null, VALUE2 int null, VALUE3 int null, VALUE4 int null, VALUE5 int null, VALUE6 int null, VALUE7 int null, VALUE8 int null, VALUE9 int null, VALUE10 int null, VALUE11 int null, VALUE12 int null, VALUE13 int null, VALUE14 int null, VALUE15 int null, VALUE16 int null, VALUE17 int null, VALUE18 int null, VALUE19 int null, VALUE20 int null, STRING1 text(300) null, STRING2 text(300) null, STRING3 text(300) null, STRING4 text(300) null, STRING5 text(300) null, STRING6 text(300) null, STRING7 text(300) null, STRING8 text(300) null, STRING9 text(300) null, STRING10 text(300) null, LONGSTRING1 text null, LONGSTRING2 text null, LONGSTRING3 text null, LONGSTRING4 text null, LONGSTRING5 text null, LONGSTRING6 text null, LONGSTRING7 text null, LONGSTRING8 text null, LONGSTRING9 text null, LONGSTRING10 text null, constraint PK_ENTERPRISEDATA primary key (ISSUEID, OBJECTID));
+ CREATE TABLE FILEMORGUE(TQUNID text(36) not null, PATH text(300) not null, DELETEFOLDERWHENEMPTY text(1) null, constraint PK_FILEMORGUE primary key (TQUNID));
+ CREATE TABLE FILES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARENTENTITYID text(50) null, BODY text null, BODYCONTENTTYPE text(100) null, ISOBSOLETE text(1) null, FILENAME text(300) not null, VISIBLENAME text(300) not null, VERSIONSTRING text(300) not null, DOCUMENTHASH text(40) not null, ISFINAL text(1) null, DOCREFERENCEID text(50) not null, constraint PK_FILES primary key (ISSUEID, OBJECTID));
+ CREATE TABLE FOLDERS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, CONTAINERNAME text(300) null, CONTAINERACLSETTINGS text null, constraint PK_FOLDERS primary key (ISSUEID, OBJECTID));
+ CREATE TABLE GLOBALSETTINGS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, SINGULARPROJECTLABEL text(30) not null, PLURALPROJECTLABEL text(30) not null, PROJECTREQUIRED text(1) not null, CUSTOMPROJECTSALLOWED text(1) not null, ACTIONITEMSPECXML text null, PROJECTLISTXML text null, ENTERPRISEDATALABELS text null, ENTERPRISEDATATABXSL text null, constraint PK_GLOBALSETTINGS primary key (ISSUEID, OBJECTID));
+ CREATE TABLE GLOBALSTRINGPROPERTIES(ID int not null, VALUE text(300) not null, constraint PK_GLOBALSTRINGPROPERTIES primary key (ID));
+ CREATE TABLE IMQ(TQUNID text(36) not null, DATETIMEQUEUED text(25) not null, ISSUEID text(50) not null, KUBIBUILD text(30) not null, FAILCOUNT int not null, LASTRUN text(25) null, ENVELOPESTREAM blob not null, PAYLOADSTREAM blob not null, constraint PK_IMQ primary key (TQUNID));
+ CREATE TABLE INVITATIONNODES(INVITATIONID text(50) not null, RECIPIENTNODEID text(50) not null, DATECREATED text(25) not null, constraint PK_INVITATIONNODES primary key (INVITATIONID, RECIPIENTNODEID));
+ CREATE TABLE INVITATIONS (INVITATIONID text(50) not null, SENDERNODEID text(50) not null, RECIPIENTEMAILADDR text(200) not null, RECIPIENTUSERID text(50) null, RECIPIENTNODES text null, ISSUEID text(50) not null, ENVELOPE text not null, MESSAGEBLOB blob not null, INVITATIONSTATE int not null, TQUNID text(36) not null, DATECREATED text(25) not null);
+ CREATE TABLE ISSUES (CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, CONTAINERNAME text(300) null, CONTAINERACLSETTINGS text null, ISINITIALIZED text(1) null, BLINDINVITES text null, ISSYSTEMISSUE text(1) not null, ISSUETYPE int not null, ACTIVITYTYPEID text(50) null, ISINCOMPLETE text(1) not null, constraint PK_ISSUES primary key (ISSUEID, OBJECTID));
+ CREATE TABLE ISSUESETTINGS (CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, ISSUENAME text(300) not null, ISSUEACLSETTINGS text not null, ISSUEDUEDATE text(25) null, ISSUEPRIORITY int null, ISSUESTATUS int null, DESCRIPTION text null, PROJECTID text(100) null, PROJECTNAME text null, PROJECTNAMEISCUSTOM text(1) null, ISSYSTEMISSUE text(1) not null, ACTIONITEMREVNUM int not null, constraint PK_ISSUESETTINGS primary key (ISSUEID, OBJECTID));
+ CREATE TABLE KMTPMSG (MSGID integer not null, SENDERID text(50) null, RECIPIENTIDLIST text not null, ISSUEID text(50) null, MESSAGETYPE int not null, ENVELOPE text null, MESSAGEBLOB blob not null, RECEIVEDDATE text(25) not null, constraint PK_KMTPMSG primary key (MSGID));
+ CREATE TABLE KMTPNODEQ(NODEID text(50) not null, MSGID int not null, RECEIVEDDATE text(25) not null, SENDCOUNT int not null);
+ CREATE TABLE KMTPQ(MSGID integer not null, SENDERID text(50) null, RECIPIENTIDLIST text not null, ISSUEID text(50) null, MESSAGETYPE int not null, ENVELOPE text null, MESSAGEBLOB blob not null, constraint PK_KMTPQ primary key (MSGID));
+ CREATE TABLE LOGENTRIES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARENTENTITYID text(50) null, BODY text null, BODYCONTENTTYPE text(100) null, ISOBSOLETE text(1) null, ACTIONTYPE int not null, ASSOCIATEDOBJECTIDS text null, OLDENTITIES text null, NEWENTITIES text null, OTHERENTITIES text null, constraint PK_LOGENTRIES primary key (ISSUEID, OBJECTID));
+ CREATE TABLE LSBI(TQUNID text(36) not null, ISSUEID text(50) not null, TABLEITEMID text(50) null, TABLENODEID text(50) null, TABLECMD int null, TABLECONTAINERID text(50) null, TABLESEQNO int null, DIRTYCONTENT text null, STUBBED text(1) null, ENTITYSTUBDATA text null, UPDATENUMBER int not null, constraint PK_LSBI primary key (TQUNID));
+ CREATE TABLE LSBN(TQUNID text(36) not null, ISSUEID text(50) not null, NODEID text(50) not null, STORESEQNO int not null, SYNCSEQNO int not null, LASTMSGDATE text(25) null, constraint PK_LSBN primary key (TQUNID));
+ CREATE TABLE MMQ(TQUNID text(36) not null, ISSUEID text(50) not null, TABLEREQUESTNODE text(50) null, MMQENTRYINDEX text(60) null, DIRECTION int null, NODEID text(50) null, TABLEFIRSTSEQNO int null, TABLELASTSEQNO int null, NEXTRESENDTIMEOUT text(25) null, TABLETIMEOUTMULTIPLIER int null, constraint PK_MMQ primary key (TQUNID));
+ CREATE TABLE NODEREG(NODEID text(50) not null, USERID text(50) null, CREATETIME text(25) not null, TQUNID text(36) not null);
+ CREATE TABLE NODES (NODEID text(50) not null, USERID text(50) null, NODESTATE int not null, NODECERT text null, KUBIVERSION int not null, KUBIBUILD text(30) not null, TQUNID text(36) not null, LASTBINDDATE text(25) null, LASTUNBINDDATE text(25) null, LASTBINDIP text(15) null, NUMBINDS int not null, NUMSENDS int not null, NUMPOLLS int not null, NUMRECVS int not null);
+ CREATE TABLE PARTICIPANTNODES(ISSUEID text(50) not null, OBJECTID text(50) not null, NODEID text(50) not null, USERID text(50) null, NODESTATE int not null, NODECERT text null, KUBIVERSION int not null, KUBIBUILD text(30) not null, TQUNID text(36) not null);
+ CREATE TABLE PARTICIPANTS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARTICIPANTSTATE int not null, PARTICIPANTROLE int not null, PARTICIPANTTEAM int not null, ISREQUIREDMEMBER text(1) null, USERID text(50) null, ISAGENT text(1) null, NAME text(150) not null, EMAILADDRESS text(200) not null, ISEMAILONLY text(1) not null, INVITATION text null, ACCEPTRESENDCOUNT int null, ACCEPTRESENDTIMEOUT text(25) null, ACCEPTLASTSENTTONODEID text(50) null, constraint PK_PARTICIPANTS primary key (ISSUEID, OBJECTID));
+ CREATE TABLE PARTICIPANTSETTINGS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARTICIPANTID text(50) not null, TASKPIMSYNC text(1) null, MOBILESUPPORT text(1) null, NOTIFYBYEMAIL text(1) null, MARKEDCRITICAL text(1) null, constraint PK_PARTICIPANTSETTINGS primary key (ISSUEID, OBJECTID));
+ CREATE TABLE PARTITIONS(PARTITIONID text(50) not null, NAME text(100) not null, LDAPDN text(300) not null, SERVERNODEID text(50) not null, TQUNID text(36) not null);
+ CREATE TABLE PROJECTS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, NAME text(100) not null, ID text(100) null, constraint PK_PROJECTS primary key (ISSUEID, OBJECTID));
+ CREATE TABLE TASKCOMPLETIONS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARENTENTITYID text(50) null, BODY text null, BODYCONTENTTYPE text(100) null, ISOBSOLETE text(1) null, TASKID text(50) not null, DISPOSITION int not null, STATUSID text(50) not null, SHORTNAME text(30) not null, LONGNAME text(200) not null, constraint PK_TASKCOMPLETIONS primary key (ISSUEID, OBJECTID));
+ CREATE TABLE TASKS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARENTENTITYID text(50) null, BODY text null, BODYCONTENTTYPE text(100) null, ISOBSOLETE text(1) null, DUETIME text(25) null, ASSIGNEDTO text(50) not null, TARGETOBJECTIDS text null, RESPONSEID text(50) not null, TYPEID text(50) not null, LABEL text(200) not null, INSTRUCTIONS text not null, ALLOWEDSTATUSES text not null, ISSERIALREVIEW text(1) null, DAYSTOREVIEW int null, REVIEWERIDS text(500) null, REVIEWTYPE int null, REVIEWGROUP text(300) null, constraint PK_TASKS primary key (ISSUEID, OBJECTID));
+ CREATE TABLE USERS (USERID text(50) not null, USERSID text(100) not null, ENTERPRISEUSER text(1) not null, USEREMAILADDRESS text(200) null, EMAILVALIDATED text(1) null, VALIDATIONCOOKIE text(50) null, CREATETIME text(25) not null, TQUNID text(36) not null, PARTITIONID text(50) null);
+ CREATE VIEW CRITICALISSUES as
+
+
+ select
+ USERID, ISSUEID, ISSUENAME, min(DATE1) DATE1
+ from (
+ select p.USERID USERID, p.ISSUEID ISSUEID, iset.ISSUENAME ISSUENAME, t.DUETIME DATE1
+ from PARTICIPANTS p
+ join TASKS t on t.ASSIGNEDTO = p.OBJECTID
+ join TASKCOMPLETIONS tc on tc.TASKID = t.OBJECTID
+ join ISSUESETTINGS iset on iset.ISSUEID = p.ISSUEID
+ where (t.ISOBSOLETE = 'n' or t.ISOBSOLETE is null)
+ and tc.DISPOSITION = 1
+ and iset.ISSUESTATUS = 1
+ union
+ select p.USERID USERID, p.ISSUEID ISSUEID, iset.ISSUENAME ISSUENAME, iset.ISSUEDUEDATE DATE1
+ from PARTICIPANTS p
+ join PARTICIPANTSETTINGS ps on ps.PARTICIPANTID = p.OBJECTID
+ join ISSUESETTINGS iset on iset.ISSUEID = p.ISSUEID
+ where ps.MARKEDCRITICAL = 'y'
+ and iset.ISSUESTATUS = 1
+ ) as CRITICALDATA
+ group by USERID, ISSUEID, ISSUENAME;
+ CREATE VIEW CURRENTFILES as
+
+
+ select
+ d.ISSUEID as ISSUEID,
+ d.REFERENCEDOCUMENTID as OBJECTID,
+ f.VISIBLENAME as VISIBLENAME
+ from
+ DOCREFERENCES d
+ join FILES f on f.OBJECTID = d.REFERENCEDOCUMENTID;
+ CREATE VIEW ISSUEDATA as
+
+
+ select
+ ISSUES.OBJECTID as ISSUEID,
+ ISSUES.CREATIONDATE as CREATIONDATE,
+ ISSUES.AUTHORID as AUTHORID,
+ ISSUES.LASTMODIFIEDDATE as LASTMODIFIEDDATE,
+ ISSUES.LASTMODIFIEDBYID as LASTMODIFIEDBYID,
+ ISSUESETTINGS.ISSUENAME as ISSUENAME,
+ ISSUES.ISINITIALIZED as ISINITIALIZED,
+ ISSUES.ISSYSTEMISSUE as ISSYSTEMISSUE,
+ ISSUES.ISSUETYPE as ISSUETYPE,
+ ISSUES.ISINCOMPLETE as ISINCOMPLETE,
+ ISSUESETTINGS.REVISIONNUM as ISSUESETTINGS_REVISIONNUM,
+ ISSUESETTINGS.LASTMODIFIEDDATE as ISSUESETTINGS_LASTMODIFIEDDATE,
+ ISSUESETTINGS.LASTMODIFIEDBYID as ISSUESETTINGS_LASTMODIFIEDBYID,
+ ISSUESETTINGS.ISSUEDUEDATE as ISSUEDUEDATE,
+ ISSUESETTINGS.ISSUEPRIORITY as ISSUEPRIORITY,
+ ISSUESETTINGS.ISSUESTATUS as ISSUESTATUS,
+ ISSUESETTINGS.DESCRIPTION as DESCRIPTION,
+ ISSUESETTINGS.PROJECTID as PROJECTID,
+ ISSUESETTINGS.PROJECTNAME as PROJECTNAME,
+ ISSUESETTINGS.PROJECTNAMEISCUSTOM as PROJECTNAMEISCUSTOM,
+ ENTERPRISEDATA.REVISIONNUM as ENTERPRISEDATA_REVISIONNUM,
+ ENTERPRISEDATA.CREATIONDATE as ENTERPRISEDATA_CREATIONDATE,
+ ENTERPRISEDATA.AUTHORID as ENTERPRISEDATA_AUTHORID,
+ ENTERPRISEDATA.LASTMODIFIEDDATE as ENTERPRISEDATA_LASTMODIFIEDDATE,
+ ENTERPRISEDATA.LASTMODIFIEDBYID as ENTERPRISEDATA_LASTMODIFIEDBYID,
+ ENTERPRISEDATA.DATE1 as DATE1,
+ ENTERPRISEDATA.DATE2 as DATE2,
+ ENTERPRISEDATA.DATE3 as DATE3,
+ ENTERPRISEDATA.DATE4 as DATE4,
+ ENTERPRISEDATA.DATE5 as DATE5,
+ ENTERPRISEDATA.DATE6 as DATE6,
+ ENTERPRISEDATA.DATE7 as DATE7,
+ ENTERPRISEDATA.DATE8 as DATE8,
+ ENTERPRISEDATA.DATE9 as DATE9,
+ ENTERPRISEDATA.DATE10 as DATE10,
+ ENTERPRISEDATA.VALUE1 as VALUE1,
+ ENTERPRISEDATA.VALUE2 as VALUE2,
+ ENTERPRISEDATA.VALUE3 as VALUE3,
+ ENTERPRISEDATA.VALUE4 as VALUE4,
+ ENTERPRISEDATA.VALUE5 as VALUE5,
+ ENTERPRISEDATA.VALUE6 as VALUE6,
+ ENTERPRISEDATA.VALUE7 as VALUE7,
+ ENTERPRISEDATA.VALUE8 as VALUE8,
+ ENTERPRISEDATA.VALUE9 as VALUE9,
+ ENTERPRISEDATA.VALUE10 as VALUE10,
+ ENTERPRISEDATA.VALUE11 as VALUE11,
+ ENTERPRISEDATA.VALUE12 as VALUE12,
+ ENTERPRISEDATA.VALUE13 as VALUE13,
+ ENTERPRISEDATA.VALUE14 as VALUE14,
+ ENTERPRISEDATA.VALUE15 as VALUE15,
+ ENTERPRISEDATA.VALUE16 as VALUE16,
+ ENTERPRISEDATA.VALUE17 as VALUE17,
+ ENTERPRISEDATA.VALUE18 as VALUE18,
+ ENTERPRISEDATA.VALUE19 as VALUE19,
+ ENTERPRISEDATA.VALUE20 as VALUE20,
+ ENTERPRISEDATA.STRING1 as STRING1,
+ ENTERPRISEDATA.STRING2 as STRING2,
+ ENTERPRISEDATA.STRING3 as STRING3,
+ ENTERPRISEDATA.STRING4 as STRING4,
+ ENTERPRISEDATA.STRING5 as STRING5,
+ ENTERPRISEDATA.STRING6 as STRING6,
+ ENTERPRISEDATA.STRING7 as STRING7,
+ ENTERPRISEDATA.STRING8 as STRING8,
+ ENTERPRISEDATA.STRING9 as STRING9,
+ ENTERPRISEDATA.STRING10 as STRING10,
+ ENTERPRISEDATA.LONGSTRING1 as LONGSTRING1,
+ ENTERPRISEDATA.LONGSTRING2 as LONGSTRING2,
+ ENTERPRISEDATA.LONGSTRING3 as LONGSTRING3,
+ ENTERPRISEDATA.LONGSTRING4 as LONGSTRING4,
+ ENTERPRISEDATA.LONGSTRING5 as LONGSTRING5,
+ ENTERPRISEDATA.LONGSTRING6 as LONGSTRING6,
+ ENTERPRISEDATA.LONGSTRING7 as LONGSTRING7,
+ ENTERPRISEDATA.LONGSTRING8 as LONGSTRING8,
+ ENTERPRISEDATA.LONGSTRING9 as LONGSTRING9,
+ ENTERPRISEDATA.LONGSTRING10 as LONGSTRING10
+ from
+ ISSUES
+ join ISSUESETTINGS on ISSUES.OBJECTID = ISSUESETTINGS.ISSUEID
+ left outer join ENTERPRISEDATA on ISSUES.OBJECTID = ENTERPRISEDATA.ISSUEID;
+ CREATE VIEW ITEMS as
+
+ select 'FILES' as TABLENAME, CLASSID, SEQNO, LASTMODONNODEID, PREVMODONNODEID, ISSUEID, OBJECTID, REVISIONNUM, CONTAINERID, AUTHORID, CREATIONDATE, LASTMODIFIEDDATE, UPDATENUMBER, PREVREVISIONNUM, LASTCMD, LASTCMDACLVERSION, USERDEFINEDFIELD, LASTMODIFIEDBYID, PARENTENTITYID, BODY, BODYCONTENTTYPE, ISOBSOLETE, FILENAME, VISIBLENAME, VERSIONSTRING, DOCUMENTHASH, ISFINAL, DOCREFERENCEID, NULL as ACTIONTYPE, NULL as ASSOCIATEDOBJECTIDS, NULL as OLDENTITIES, NULL as NEWENTITIES, NULL as OTHERENTITIES, NULL as TQUNID, NULL as TABLEITEMID, NULL as TABLENODEID, NULL as TABLECMD, NULL as TABLECONTAINERID, NULL as TABLESEQNO, NULL as DIRTYCONTENT, NULL as STUBBED, NULL as ENTITYSTUBDATA, NULL as PARTICIPANTSTATE, NULL as PARTICIPANTROLE, NULL as PARTICIPANTTEAM, NULL as ISREQUIREDMEMBER, NULL as USERID, NULL as ISAGENT, NULL as NAME, NULL as EMAILADDRESS, NULL as ISEMAILONLY, NULL as INVITATION, NULL as ACCEPTRESENDCOUNT, NULL as ACCEPTRESENDTIMEOUT, NULL as ACCEPTLASTSENTTONODEID, NULL as TASKID, NULL as DISPOSITION, NULL as STATUSID, NULL as SHORTNAME, NULL as LONGNAME, NULL as DUETIME, NULL as ASSIGNEDTO, NULL as TARGETOBJECTIDS, NULL as RESPONSEID, NULL as TYPEID, NULL as LABEL, NULL as INSTRUCTIONS, NULL as ALLOWEDSTATUSES, NULL as ISSERIALREVIEW, NULL as DAYSTOREVIEW, NULL as REVIEWERIDS, NULL as REVIEWTYPE, NULL as REVIEWGROUP from FILES
+ union all
+ select 'LOGENTRIES' as TABLENAME, CLASSID, SEQNO, LASTMODONNODEID, PREVMODONNODEID, ISSUEID, OBJECTID, REVISIONNUM, CONTAINERID, AUTHORID, CREATIONDATE, LASTMODIFIEDDATE, UPDATENUMBER, PREVREVISIONNUM, LASTCMD, LASTCMDACLVERSION, USERDEFINEDFIELD, LASTMODIFIEDBYID, PARENTENTITYID, BODY, BODYCONTENTTYPE, ISOBSOLETE, NULL as FILENAME, NULL as VISIBLENAME, NULL as VERSIONSTRING, NULL as DOCUMENTHASH, NULL as ISFINAL, NULL as DOCREFERENCEID, ACTIONTYPE, ASSOCIATEDOBJECTIDS, OLDENTITIES, NEWENTITIES, OTHERENTITIES, NULL as TQUNID, NULL as TABLEITEMID, NULL as TABLENODEID, NULL as TABLECMD, NULL as TABLECONTAINERID, NULL as TABLESEQNO, NULL as DIRTYCONTENT, NULL as STUBBED, NULL as ENTITYSTUBDATA, NULL as PARTICIPANTSTATE, NULL as PARTICIPANTROLE, NULL as PARTICIPANTTEAM, NULL as ISREQUIREDMEMBER, NULL as USERID, NULL as ISAGENT, NULL as NAME, NULL as EMAILADDRESS, NULL as ISEMAILONLY, NULL as INVITATION, NULL as ACCEPTRESENDCOUNT, NULL as ACCEPTRESENDTIMEOUT, NULL as ACCEPTLASTSENTTONODEID, NULL as TASKID, NULL as DISPOSITION, NULL as STATUSID, NULL as SHORTNAME, NULL as LONGNAME, NULL as DUETIME, NULL as ASSIGNEDTO, NULL as TARGETOBJECTIDS, NULL as RESPONSEID, NULL as TYPEID, NULL as LABEL, NULL as INSTRUCTIONS, NULL as ALLOWEDSTATUSES, NULL as ISSERIALREVIEW, NULL as DAYSTOREVIEW, NULL as REVIEWERIDS, NULL as REVIEWTYPE, NULL as REVIEWGROUP from LOGENTRIES
+ union all
+ select 'LSBI' as TABLENAME, NULL as CLASSID, NULL as SEQNO, NULL as LASTMODONNODEID, NULL as PREVMODONNODEID, ISSUEID, NULL as OBJECTID, NULL as REVISIONNUM, NULL as CONTAINERID, NULL as AUTHORID, NULL as CREATIONDATE, NULL as LASTMODIFIEDDATE, UPDATENUMBER, NULL as PREVREVISIONNUM, NULL as LASTCMD, NULL as LASTCMDACLVERSION, NULL as USERDEFINEDFIELD, NULL as LASTMODIFIEDBYID, NULL as PARENTENTITYID, NULL as BODY, NULL as BODYCONTENTTYPE, NULL as ISOBSOLETE, NULL as FILENAME, NULL as VISIBLENAME, NULL as VERSIONSTRING, NULL as DOCUMENTHASH, NULL as ISFINAL, NULL as DOCREFERENCEID, NULL as ACTIONTYPE, NULL as ASSOCIATEDOBJECTIDS, NULL as OLDENTITIES, NULL as NEWENTITIES, NULL as OTHERENTITIES, TQUNID, TABLEITEMID, TABLENODEID, TABLECMD, TABLECONTAINERID, TABLESEQNO, DIRTYCONTENT, STUBBED, ENTITYSTUBDATA, NULL as PARTICIPANTSTATE, NULL as PARTICIPANTROLE, NULL as PARTICIPANTTEAM, NULL as ISREQUIREDMEMBER, NULL as USERID, NULL as ISAGENT, NULL as NAME, NULL as EMAILADDRESS, NULL as ISEMAILONLY, NULL as INVITATION, NULL as ACCEPTRESENDCOUNT, NULL as ACCEPTRESENDTIMEOUT, NULL as ACCEPTLASTSENTTONODEID, NULL as TASKID, NULL as DISPOSITION, NULL as STATUSID, NULL as SHORTNAME, NULL as LONGNAME, NULL as DUETIME, NULL as ASSIGNEDTO, NULL as TARGETOBJECTIDS, NULL as RESPONSEID, NULL as TYPEID, NULL as LABEL, NULL as INSTRUCTIONS, NULL as ALLOWEDSTATUSES, NULL as ISSERIALREVIEW, NULL as DAYSTOREVIEW, NULL as REVIEWERIDS, NULL as REVIEWTYPE, NULL as REVIEWGROUP from LSBI where TABLECMD=3
+ union all
+ select 'PARTICIPANTS' as TABLENAME, CLASSID, SEQNO, LASTMODONNODEID, PREVMODONNODEID, ISSUEID, OBJECTID, REVISIONNUM, CONTAINERID, AUTHORID, CREATIONDATE, LASTMODIFIEDDATE, UPDATENUMBER, PREVREVISIONNUM, LASTCMD, LASTCMDACLVERSION, USERDEFINEDFIELD, LASTMODIFIEDBYID, NULL as PARENTENTITYID, NULL as BODY, NULL as BODYCONTENTTYPE, NULL as ISOBSOLETE, NULL as FILENAME, NULL as VISIBLENAME, NULL as VERSIONSTRING, NULL as DOCUMENTHASH, NULL as ISFINAL, NULL as DOCREFERENCEID, NULL as ACTIONTYPE, NULL as ASSOCIATEDOBJECTIDS, NULL as OLDENTITIES, NULL as NEWENTITIES, NULL as OTHERENTITIES, NULL as TQUNID, NULL as TABLEITEMID, NULL as TABLENODEID, NULL as TABLECMD, NULL as TABLECONTAINERID, NULL as TABLESEQNO, NULL as DIRTYCONTENT, NULL as STUBBED, NULL as ENTITYSTUBDATA, PARTICIPANTSTATE, PARTICIPANTROLE, PARTICIPANTTEAM, ISREQUIREDMEMBER, USERID, ISAGENT, NAME, EMAILADDRESS, ISEMAILONLY, INVITATION, ACCEPTRESENDCOUNT, ACCEPTRESENDTIMEOUT, ACCEPTLASTSENTTONODEID, NULL as TASKID, NULL as DISPOSITION, NULL as STATUSID, NULL as SHORTNAME, NULL as LONGNAME, NULL as DUETIME, NULL as ASSIGNEDTO, NULL as TARGETOBJECTIDS, NULL as RESPONSEID, NULL as TYPEID, NULL as LABEL, NULL as INSTRUCTIONS, NULL as ALLOWEDSTATUSES, NULL as ISSERIALREVIEW, NULL as DAYSTOREVIEW, NULL as REVIEWERIDS, NULL as REVIEWTYPE, NULL as REVIEWGROUP from PARTICIPANTS
+ union all
+ select 'TASKCOMPLETIONS' as TABLENAME, CLASSID, SEQNO, LASTMODONNODEID, PREVMODONNODEID, ISSUEID, OBJECTID, REVISIONNUM, CONTAINERID, AUTHORID, CREATIONDATE, LASTMODIFIEDDATE, UPDATENUMBER, PREVREVISIONNUM, LASTCMD, LASTCMDACLVERSION, USERDEFINEDFIELD, LASTMODIFIEDBYID, PARENTENTITYID, BODY, BODYCONTENTTYPE, ISOBSOLETE, NULL as FILENAME, NULL as VISIBLENAME, NULL as VERSIONSTRING, NULL as DOCUMENTHASH, NULL as ISFINAL, NULL as DOCREFERENCEID, NULL as ACTIONTYPE, NULL as ASSOCIATEDOBJECTIDS, NULL as OLDENTITIES, NULL as NEWENTITIES, NULL as OTHERENTITIES, NULL as TQUNID, NULL as TABLEITEMID, NULL as TABLENODEID, NULL as TABLECMD, NULL as TABLECONTAINERID, NULL as TABLESEQNO, NULL as DIRTYCONTENT, NULL as STUBBED, NULL as ENTITYSTUBDATA, NULL as PARTICIPANTSTATE, NULL as PARTICIPANTROLE, NULL as PARTICIPANTTEAM, NULL as ISREQUIREDMEMBER, NULL as USERID, NULL as ISAGENT, NULL as NAME, NULL as EMAILADDRESS, NULL as ISEMAILONLY, NULL as INVITATION, NULL as ACCEPTRESENDCOUNT, NULL as ACCEPTRESENDTIMEOUT, NULL as ACCEPTLASTSENTTONODEID, TASKID, DISPOSITION, STATUSID, SHORTNAME, LONGNAME, NULL as DUETIME, NULL as ASSIGNEDTO, NULL as TARGETOBJECTIDS, NULL as RESPONSEID, NULL as TYPEID, NULL as LABEL, NULL as INSTRUCTIONS, NULL as ALLOWEDSTATUSES, NULL as ISSERIALREVIEW, NULL as DAYSTOREVIEW, NULL as REVIEWERIDS, NULL as REVIEWTYPE, NULL as REVIEWGROUP from TASKCOMPLETIONS
+ union all
+ select 'TASKS' as TABLENAME, CLASSID, SEQNO, LASTMODONNODEID, PREVMODONNODEID, ISSUEID, OBJECTID, REVISIONNUM, CONTAINERID, AUTHORID, CREATIONDATE, LASTMODIFIEDDATE, UPDATENUMBER, PREVREVISIONNUM, LASTCMD, LASTCMDACLVERSION, USERDEFINEDFIELD, LASTMODIFIEDBYID, PARENTENTITYID, BODY, BODYCONTENTTYPE, ISOBSOLETE, NULL as FILENAME, NULL as VISIBLENAME, NULL as VERSIONSTRING, NULL as DOCUMENTHASH, NULL as ISFINAL, NULL as DOCREFERENCEID, NULL as ACTIONTYPE, NULL as ASSOCIATEDOBJECTIDS, NULL as OLDENTITIES, NULL as NEWENTITIES, NULL as OTHERENTITIES, NULL as TQUNID, NULL as TABLEITEMID, NULL as TABLENODEID, NULL as TABLECMD, NULL as TABLECONTAINERID, NULL as TABLESEQNO, NULL as DIRTYCONTENT, NULL as STUBBED, NULL as ENTITYSTUBDATA, NULL as PARTICIPANTSTATE, NULL as PARTICIPANTROLE, NULL as PARTICIPANTTEAM, NULL as ISREQUIREDMEMBER, NULL as USERID, NULL as ISAGENT, NULL as NAME, NULL as EMAILADDRESS, NULL as ISEMAILONLY, NULL as INVITATION, NULL as ACCEPTRESENDCOUNT, NULL as ACCEPTRESENDTIMEOUT, NULL as ACCEPTLASTSENTTONODEID, NULL as TASKID, NULL as DISPOSITION, NULL as STATUSID, NULL as SHORTNAME, NULL as LONGNAME, DUETIME, ASSIGNEDTO, TARGETOBJECTIDS, RESPONSEID, TYPEID, LABEL, INSTRUCTIONS, ALLOWEDSTATUSES, ISSERIALREVIEW, DAYSTOREVIEW, REVIEWERIDS, REVIEWTYPE, REVIEWGROUP from TASKS;
+ CREATE VIEW TASKINFO as
+
+
+ select
+ t.ISSUEID as ISSUEID,
+ t.OBJECTID as OBJECTID,
+ t.ASSIGNEDTO as ASSIGNEDTO,
+ t.TARGETOBJECTIDS as TARGETOBJECTIDS,
+ t.DUETIME as DUETIME,
+ t.ISOBSOLETE as ISOBSOLETE,
+ tc.DISPOSITION as DISPOSITION
+ from
+ TASKS t
+ join TASKCOMPLETIONS tc on tc.TASKID = t.OBJECTID;
+ CREATE INDEX DQ_ISSUEID_DEPENDSID on DQ (ISSUEID, DEPENDSID);
+ CREATE INDEX EMAILQ_TIMEQUEUED on EMAILQ (TIMEQUEUED);
+ CREATE INDEX FOLDERS_CONTAINERID_ISSUEID on FOLDERS (CONTAINERID, ISSUEID);
+ CREATE INDEX IMQ_DATETIMEQUEUED on IMQ (DATETIMEQUEUED);
+ CREATE INDEX INVITATIONS_RECIPIENTUSERID_INVITATIONID on INVITATIONS (RECIPIENTUSERID, INVITATIONID);
+ CREATE INDEX INVITATIONS_TQUNID on INVITATIONS (TQUNID);
+ CREATE INDEX ISSUESETTINGS_CONTAINERID on ISSUESETTINGS (CONTAINERID);
+ CREATE INDEX KMTPMSG_RECEIVEDDATE on KMTPMSG (RECEIVEDDATE desc);
+ CREATE INDEX KMTPNODEQ_MSGID on KMTPNODEQ (MSGID);
+ CREATE INDEX KMTPNODEQ_NODEID_MSGID on KMTPNODEQ (NODEID, MSGID);
+ CREATE INDEX KMTPNODEQ_RECEIVEDDATE on KMTPNODEQ (RECEIVEDDATE desc);
+ CREATE INDEX LSBI_ISSUEID_TABLEITEMID on LSBI (ISSUEID, TABLEITEMID);
+ CREATE INDEX LSBN_ISSUEID_NODEID on LSBN (ISSUEID, NODEID);
+ CREATE INDEX MMQ_ISSUEID_MMQENTRYINDEX on MMQ (ISSUEID, MMQENTRYINDEX);
+ CREATE INDEX NODEREG_NODEID_USERID on NODEREG (NODEID, USERID);
+ CREATE INDEX NODEREG_TQUNID on NODEREG (TQUNID);
+ CREATE INDEX NODEREG_USERID_NODEID on NODEREG (USERID, NODEID);
+ CREATE INDEX NODES_NODEID on NODES (NODEID);
+ CREATE INDEX NODES_TQUNID on NODES (TQUNID);
+ CREATE INDEX PARTICIPANTNODES_ISSUEID_OBJECTID_NODEID on PARTICIPANTNODES (ISSUEID, OBJECTID, NODEID);
+ CREATE INDEX PARTICIPANTNODES_TQUNID on PARTICIPANTNODES (TQUNID);
+ CREATE INDEX PARTICIPANTSETTINGS_PARTICIPANTID on PARTICIPANTSETTINGS (PARTICIPANTID);
+ CREATE INDEX PARTITIONS_LDAPDN on PARTITIONS (LDAPDN);
+ CREATE INDEX PARTITIONS_PARTITIONID_SERVERNODEID on PARTITIONS (PARTITIONID, SERVERNODEID);
+ CREATE INDEX PARTITIONS_SERVERNODEID_PARTITIONID on PARTITIONS (SERVERNODEID, PARTITIONID);
+ CREATE INDEX PARTITIONS_TQUNID on PARTITIONS (TQUNID);
+ CREATE INDEX TASKCOMPLETIONS_TASKID on TASKCOMPLETIONS (TASKID);
+ CREATE INDEX TASKS_ASSIGNEDTO on TASKS (ASSIGNEDTO);
+ CREATE INDEX USERS_PARTITIONID_USERID on USERS (PARTITIONID, USERID);
+ CREATE INDEX USERS_TQUNID on USERS (TQUNID);
+ CREATE INDEX USERS_USERID_PARTITIONID on USERS (USERID, PARTITIONID);
+ CREATE INDEX USERS_USERSID_USERID on USERS (USERSID, USERID);
+ COMMIT;
+ }
+} {}
+
+# Given the schema above, the following query was cause an assertion fault
+# do to an uninitialized field in a Select structure.
+#
+do_test tkt1449-1.2 {
+ execsql {
+ select NEWENTITIES from ITEMS where ((ISSUEID = 'x') and (OBJECTID = 'y'))
+ }
+} {}
+
+finish_test
diff --git a/test/tkt1473.test b/test/tkt1473.test
new file mode 100644
index 0000000..3950272
--- /dev/null
+++ b/test/tkt1473.test
@@ -0,0 +1,728 @@
+# 2005 September 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1473 has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+do_test tkt1473-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ SELECT * FROM t1
+ }
+} {1 2 3 4}
+
+do_test tkt1473-1.2 {
+ execsql {
+ SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0
+ }
+} {1}
+do_test tkt1473-1.3 {
+ execsql {
+ SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0
+ }
+} {1}
+do_test tkt1473-1.4 {
+ execsql {
+ SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4
+ }
+} {1 2}
+do_test tkt1473-1.5 {
+ execsql {
+ SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4
+ }
+} {1 2}
+do_test tkt1473-1.6 {
+ execsql {
+ SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4
+ }
+} {2}
+do_test tkt1473-1.7 {
+ execsql {
+ SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4
+ }
+} {2}
+do_test tkt1473-1.8 {
+ execsql {
+ SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0
+ }
+} {}
+do_test tkt1473-1.9 {
+ execsql {
+ SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0
+ }
+} {}
+
+# Everything from this point on depends on sub-queries. So skip it
+# if sub-queries are not available.
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+do_test tkt1473-2.2 {
+ execsql {
+ SELECT (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0)
+ }
+} {1}
+do_test tkt1473-2.3 {
+ execsql {
+ SELECT (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0)
+ }
+} {1}
+do_test tkt1473-2.4 {
+ execsql {
+ SELECT (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4)
+ }
+} {1}
+do_test tkt1473-2.5 {
+ execsql {
+ SELECT (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4)
+ }
+} {1}
+do_test tkt1473-2.6 {
+ execsql {
+ SELECT (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4)
+ }
+} {2}
+do_test tkt1473-2.7 {
+ execsql {
+ SELECT (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4)
+ }
+} {2}
+do_test tkt1473-2.8 {
+ execsql {
+ SELECT (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0)
+ }
+} {{}}
+do_test tkt1473-2.9 {
+ execsql {
+ SELECT (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0)
+ }
+} {{}}
+
+do_test tkt1473-3.2 {
+ execsql {
+ SELECT EXISTS
+ (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0)
+ }
+} {1}
+do_test tkt1473-3.3 {
+ execsql {
+ SELECT EXISTS
+ (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0)
+ }
+} {1}
+do_test tkt1473-3.4 {
+ execsql {
+ SELECT EXISTS
+ (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4)
+ }
+} {1}
+do_test tkt1473-3.5 {
+ execsql {
+ SELECT EXISTS
+ (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4)
+ }
+} {1}
+do_test tkt1473-3.6 {
+ execsql {
+ SELECT EXISTS
+ (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4)
+ }
+} {1}
+do_test tkt1473-3.7 {
+ execsql {
+ SELECT EXISTS
+ (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4)
+ }
+} {1}
+do_test tkt1473-3.8 {
+ execsql {
+ SELECT EXISTS
+ (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0)
+ }
+} {0}
+do_test tkt1473-3.9 {
+ execsql {
+ SELECT EXISTS
+ (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0)
+ }
+} {0}
+
+do_test tkt1473-4.1 {
+ execsql {
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(1,2);
+ INSERT INTO t2 SELECT x+2, y+2 FROM t2;
+ INSERT INTO t2 SELECT x+4, y+4 FROM t2;
+ INSERT INTO t2 SELECT x+8, y+8 FROM t2;
+ INSERT INTO t2 SELECT x+16, y+16 FROM t2;
+ INSERT INTO t2 SELECT x+32, y+32 FROM t2;
+ INSERT INTO t2 SELECT x+64, y+64 FROM t2;
+ SELECT count(*), sum(x), sum(y) FROM t2;
+ }
+} {64 4096 4160}
+do_test tkt1473-4.2 {
+ execsql {
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=3
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=2
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=4
+ }
+} {2 4 8 10}
+do_test tkt1473-4.3 {
+ execsql {
+ SELECT (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=3
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=2
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=4
+ )
+ }
+} {2}
+do_test tkt1473-4.4 {
+ execsql {
+ SELECT (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=3
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=2
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=4
+ )
+ }
+} {4}
+do_test tkt1473-4.5 {
+ execsql {
+ SELECT (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=-1
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=2
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=-4
+ )
+ }
+} {8}
+do_test tkt1473-4.6 {
+ execsql {
+ SELECT (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=-2
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=-3
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=4
+ )
+ }
+} {10}
+do_test tkt1473-4.7 {
+ execsql {
+ SELECT (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=-2
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=-3
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=-4
+ )
+ }
+} {{}}
+
+do_test tkt1473-5.3 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=3
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=2
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=4
+ )
+ }
+} {1}
+do_test tkt1473-5.4 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=3
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=2
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=4
+ )
+ }
+} {1}
+
+do_test tkt1473-5.5 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=-1
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=2
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=-4
+ )
+ }
+} {1}
+do_test tkt1473-5.6 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=-2
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=-3
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=4
+ )
+ }
+} {1}
+do_test tkt1473-5.7 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION ALL
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION ALL
+ SELECT 3 FROM t2 WHERE x=2
+ UNION ALL
+ SELECT 4 FROM t2 WHERE x=-2
+ UNION ALL
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION ALL
+ SELECT 7 FROM t2 WHERE y=1
+ UNION ALL
+ SELECT 8 FROM t2 WHERE y=-3
+ UNION ALL
+ SELECT 9 FROM t2 WHERE y=3
+ UNION ALL
+ SELECT 10 FROM t2 WHERE y=-4
+ )
+ }
+} {0}
+
+do_test tkt1473-6.3 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION
+ SELECT 2 FROM t2 WHERE x=1
+ UNION
+ SELECT 3 FROM t2 WHERE x=2
+ UNION
+ SELECT 4 FROM t2 WHERE x=3
+ UNION
+ SELECT 5 FROM t2 WHERE x=4
+ UNION
+ SELECT 6 FROM t2 WHERE y=0
+ UNION
+ SELECT 7 FROM t2 WHERE y=1
+ UNION
+ SELECT 8 FROM t2 WHERE y=2
+ UNION
+ SELECT 9 FROM t2 WHERE y=3
+ UNION
+ SELECT 10 FROM t2 WHERE y=4
+ )
+ }
+} {1}
+do_test tkt1473-6.4 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION
+ SELECT 3 FROM t2 WHERE x=2
+ UNION
+ SELECT 4 FROM t2 WHERE x=3
+ UNION
+ SELECT 5 FROM t2 WHERE x=4
+ UNION
+ SELECT 6 FROM t2 WHERE y=0
+ UNION
+ SELECT 7 FROM t2 WHERE y=1
+ UNION
+ SELECT 8 FROM t2 WHERE y=2
+ UNION
+ SELECT 9 FROM t2 WHERE y=3
+ UNION
+ SELECT 10 FROM t2 WHERE y=4
+ )
+ }
+} {1}
+
+do_test tkt1473-6.5 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION
+ SELECT 3 FROM t2 WHERE x=2
+ UNION
+ SELECT 4 FROM t2 WHERE x=-1
+ UNION
+ SELECT 5 FROM t2 WHERE x=4
+ UNION
+ SELECT 6 FROM t2 WHERE y=0
+ UNION
+ SELECT 7 FROM t2 WHERE y=1
+ UNION
+ SELECT 8 FROM t2 WHERE y=2
+ UNION
+ SELECT 9 FROM t2 WHERE y=3
+ UNION
+ SELECT 10 FROM t2 WHERE y=-4
+ )
+ }
+} {1}
+do_test tkt1473-6.6 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION
+ SELECT 3 FROM t2 WHERE x=2
+ UNION
+ SELECT 4 FROM t2 WHERE x=-2
+ UNION
+ SELECT 5 FROM t2 WHERE x=4
+ UNION
+ SELECT 6 FROM t2 WHERE y=0
+ UNION
+ SELECT 7 FROM t2 WHERE y=1
+ UNION
+ SELECT 8 FROM t2 WHERE y=-3
+ UNION
+ SELECT 9 FROM t2 WHERE y=3
+ UNION
+ SELECT 10 FROM t2 WHERE y=4
+ )
+ }
+} {1}
+do_test tkt1473-6.7 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION
+ SELECT 3 FROM t2 WHERE x=2
+ UNION
+ SELECT 4 FROM t2 WHERE x=-2
+ UNION
+ SELECT 5 FROM t2 WHERE x=4
+ UNION
+ SELECT 6 FROM t2 WHERE y=0
+ UNION
+ SELECT 7 FROM t2 WHERE y=1
+ UNION
+ SELECT 8 FROM t2 WHERE y=-3
+ UNION
+ SELECT 9 FROM t2 WHERE y=3
+ UNION
+ SELECT 10 FROM t2 WHERE y=-4
+ )
+ }
+} {0}
+do_test tkt1473-6.8 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION
+ SELECT 3 FROM t2 WHERE x=2
+ UNION
+ SELECT 4 FROM t2 WHERE x=-2
+ UNION
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION
+ SELECT 7 FROM t2 WHERE y=1
+ UNION
+ SELECT 8 FROM t2 WHERE y=-3
+ UNION
+ SELECT 9 FROM t2 WHERE y=3
+ UNION
+ SELECT 10 FROM t2 WHERE y=4
+ )
+ }
+} {1}
+do_test tkt1473-6.9 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0
+ UNION
+ SELECT 2 FROM t2 WHERE x=-1
+ UNION
+ SELECT 3 FROM t2 WHERE x=2
+ UNION
+ SELECT 4 FROM t2 WHERE x=-2
+ UNION
+ SELECT 5 FROM t2 WHERE x=4
+ UNION ALL
+ SELECT 6 FROM t2 WHERE y=0
+ UNION
+ SELECT 7 FROM t2 WHERE y=1
+ UNION
+ SELECT 8 FROM t2 WHERE y=-3
+ UNION
+ SELECT 9 FROM t2 WHERE y=3
+ UNION
+ SELECT 10 FROM t2 WHERE y=-4
+ )
+ }
+} {0}
+
+do_test tkt1473-7.1 {
+ execsql {
+ SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2
+ }
+} {1}
+do_test tkt1473-7.2 {
+ execsql {
+ SELECT (
+ SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2
+ )
+ }
+} {1}
+do_test tkt1473-7.3 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2
+ )
+ }
+} {1}
+do_test tkt1473-7.4 {
+ execsql {
+ SELECT (
+ SELECT 1 FROM t2 WHERE x=0 EXCEPT SELECT 2 FROM t2 WHERE y=2
+ )
+ }
+} {{}}
+do_test tkt1473-7.5 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=0 EXCEPT SELECT 2 FROM t2 WHERE y=2
+ )
+ }
+} {0}
+
+do_test tkt1473-8.1 {
+ execsql {
+ SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2
+ }
+} {}
+do_test tkt1473-8.1 {
+ execsql {
+ SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2
+ }
+} {1}
+do_test tkt1473-8.3 {
+ execsql {
+ SELECT (
+ SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2
+ )
+ }
+} {{}}
+do_test tkt1473-8.4 {
+ execsql {
+ SELECT (
+ SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2
+ )
+ }
+} {1}
+do_test tkt1473-8.5 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2
+ )
+ }
+} {0}
+do_test tkt1473-8.6 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2
+ )
+ }
+} {1}
+do_test tkt1473-8.7 {
+ execsql {
+ SELECT (
+ SELECT 1 FROM t2 WHERE x=0 INTERSECT SELECT 1 FROM t2 WHERE y=2
+ )
+ }
+} {{}}
+do_test tkt1473-8.8 {
+ execsql {
+ SELECT EXISTS (
+ SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=0
+ )
+ }
+} {0}
+
+
+
+
+finish_test
diff --git a/test/tkt1501.test b/test/tkt1501.test
new file mode 100644
index 0000000..19ec7f7
--- /dev/null
+++ b/test/tkt1501.test
@@ -0,0 +1,36 @@
+# 2005 November 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1501 is
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+do_test tkt1501-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ SELECT a, b, 'abc' FROM t1
+ UNION
+ SELECT b, a, 'xyz' FROM t1
+ ORDER BY 2, 3;
+ }
+} {2 1 xyz 1 2 abc}
+
+finish_test
diff --git a/test/tkt1512.test b/test/tkt1512.test
new file mode 100644
index 0000000..a2c39db
--- /dev/null
+++ b/test/tkt1512.test
@@ -0,0 +1,54 @@
+# 2005 September 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1512 is
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!vacuum || !autovacuum} {
+ finish_test
+ return
+}
+if {[db one {PRAGMA auto_vacuum}]} {
+ finish_test
+ return
+}
+
+do_test tkt1512-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ SELECT * FROM t1
+ }
+} {1 2 3 4}
+do_test tkt1512-1.2 {
+ file size test.db
+} {2048}
+do_test tkt1512-1.3 {
+ execsql {
+ DROP TABLE t1;
+ }
+ file size test.db
+} {2048}
+do_test tkt1512-1.4 {
+ execsql {
+ VACUUM;
+ }
+ file size test.db
+} {1024}
+
+
+finish_test
diff --git a/test/tkt1514.test b/test/tkt1514.test
new file mode 100644
index 0000000..1dfae1d
--- /dev/null
+++ b/test/tkt1514.test
@@ -0,0 +1,27 @@
+# 2005 November 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1514 is
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt1514-1.1 {
+ catchsql {
+ CREATE TABLE t1(a,b);
+ SELECT a FROM t1 WHERE max(b)<10 GROUP BY a;
+ }
+} {1 {misuse of aggregate: max()}}
+
+finish_test
diff --git a/test/tkt1536.test b/test/tkt1536.test
new file mode 100644
index 0000000..46e4619
--- /dev/null
+++ b/test/tkt1536.test
@@ -0,0 +1,38 @@
+# 2005 November 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1536 is
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt1536-1.1 {
+ execsql {
+ CREATE TABLE t1(
+ a INTEGER PRIMARY KEY,
+ b TEXT
+ );
+ INSERT INTO t1 VALUES(1,'01');
+ SELECT typeof(a), typeof(b) FROM t1;
+ }
+} {integer text}
+do_test tkt1536-1.2 {
+ execsql {
+ INSERT INTO t1(b) SELECT b FROM t1;
+ SELECT b FROM t1 WHERE rowid=2;
+ }
+} {01}
+
+
+finish_test
diff --git a/test/tkt1537.test b/test/tkt1537.test
new file mode 100644
index 0000000..633f91f
--- /dev/null
+++ b/test/tkt1537.test
@@ -0,0 +1,122 @@
+# 2005 November 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1537 is
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt1537-1.1 {
+ execsql {
+ CREATE TABLE t1(id, a1, a2);
+ INSERT INTO t1 VALUES(1, NULL, NULL);
+ INSERT INTO t1 VALUES(2, 1, 3);
+ CREATE TABLE t2(id, b);
+ INSERT INTO t2 VALUES(3, 1);
+ INSERT INTO t2 VALUES(4, NULL);
+ SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=+b;
+ }
+} {1 {} {} {} {} 2 1 3 3 1}
+do_test tkt1537-1.2 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b;
+ }
+} {1 {} {} {} {} 2 1 3 3 1}
+do_test tkt1537-1.3 {
+ execsql {
+ SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b;
+ }
+} {3 1 2 1 3 4 {} {} {} {}}
+ifcapable subquery {
+ do_test tkt1537-1.4 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2);
+ }
+ } {1 {} {} {} {} 2 1 3 3 1}
+ do_test tkt1537-1.5 {
+ execsql {
+ SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1);
+ }
+ } {3 1 2 1 3 4 {} {} {} {}}
+}
+do_test tkt1537-1.6 {
+ execsql {
+ CREATE INDEX t1a1 ON t1(a1);
+ CREATE INDEX t1a2 ON t1(a2);
+ CREATE INDEX t2b ON t2(b);
+ SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b;
+ }
+} {1 {} {} {} {} 2 1 3 3 1}
+do_test tkt1537-1.7 {
+ execsql {
+ SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b;
+ }
+} {3 1 2 1 3 4 {} {} {} {}}
+
+ifcapable subquery {
+ do_test tkt1537-1.8 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2);
+ }
+ } {1 {} {} {} {} 2 1 3 3 1}
+ do_test tkt1537-1.9 {
+ execsql {
+ SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1);
+ }
+ } {3 1 2 1 3 4 {} {} {} {}}
+}
+
+execsql {
+ DROP INDEX t1a1;
+ DROP INDEX t1a2;
+ DROP INDEX t2b;
+}
+
+do_test tkt1537-2.1 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2;
+ }
+} {1 {} {} {} {} 2 1 3 3 1}
+do_test tkt1537-2.2 {
+ execsql {
+ CREATE INDEX t2b ON t2(b);
+ SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2;
+ }
+} {1 {} {} {} {} 2 1 3 3 1}
+do_test tkt1537-2.3 {
+ execsql {
+ SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2;
+ }
+} {3 1 2 1 3 4 {} {} {} {}}
+do_test tkt1537-2.4 {
+ execsql {
+ CREATE INDEX t1a1 ON t1(a1);
+ CREATE INDEX t1a2 ON t1(a2);
+ SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2;
+ }
+} {3 1 2 1 3 4 {} {} {} {}}
+
+do_test tkt1537-3.1 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON b GLOB 'abc*' WHERE t1.id=1;
+ }
+} {1 {} {} {} {}}
+do_test tkt1537-3.2 {
+ execsql {
+ SELECT * FROM t2 LEFT JOIN t1 ON a1 GLOB 'abc*' WHERE t2.id=3;
+ }
+} {3 1 {} {} {}}
+
+
+finish_test
diff --git a/test/tkt1567.test b/test/tkt1567.test
new file mode 100644
index 0000000..6c4548a
--- /dev/null
+++ b/test/tkt1567.test
@@ -0,0 +1,51 @@
+# 2005 December 19 2005
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1567 is
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt1567-1.1 {
+ execsql {
+ CREATE TABLE t1(a TEXT PRIMARY KEY);
+ }
+ set bigstr abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
+ for {set i 0} {$i<100} {incr i} {
+ set x [format %5d [expr $i*2]]
+ set sql "INSERT INTO t1 VALUES('$x-$bigstr')"
+ execsql $sql
+ }
+} {}
+integrity_check tkt1567-1.2
+
+do_test tkt1567-1.3 {
+ execsql {
+ BEGIN;
+ UPDATE t1 SET a = a||'x' WHERE rowid%2==0;
+ }
+} {}
+do_test tkt1567-1.4 {
+ catchsql {
+ UPDATE t1 SET a = CASE WHEN rowid<90 THEN substr(a,1,10) ELSE '9999' END;
+ }
+} {1 {column a is not unique}}
+do_test tkt1567-1.5 {
+ execsql {
+ COMMIT;
+ }
+} {}
+integrity_check tkt1567-1.6
+
+finish_test
diff --git a/test/tkt1644.test b/test/tkt1644.test
new file mode 100644
index 0000000..aa26a88
--- /dev/null
+++ b/test/tkt1644.test
@@ -0,0 +1,111 @@
+# 2006 January 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1644 is
+# fixed. Ticket #1644 complains that precompiled statements
+# are not expired correctly as a result of changes to TEMP
+# views and triggers.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !tempdb||!view {
+ finish_test
+ return
+}
+
+# Create two tables T1 and T2 and make V1 point to T1.
+do_test tkt1644-1.1 {
+ execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ CREATE TABLE t2(b);
+ INSERT INTO t2 VALUES(99);
+ CREATE TEMP VIEW v1 AS SELECT * FROM t1;
+ SELECT * FROM v1;
+ }
+} {1}
+
+# The "SELECT * FROM v1" should be in the TCL interface cache below.
+# It will continue to point to T1 unless the cache is invalidated when
+# the view changes.
+#
+do_test tkt1644-1.2 {
+ execsql {
+ DROP VIEW v1;
+ CREATE TEMP VIEW v1 AS SELECT * FROM t2;
+ SELECT * FROM v1;
+ }
+} {99}
+
+# Cache an access to the T1 table.
+#
+do_test tkt1644-1.3 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {1}
+
+# Create a temp table T1. Make sure the cache is invalidated so that
+# the statement is recompiled and refers to the empty temp table.
+#
+do_test tkt1644-1.4 {
+ execsql {
+ CREATE TEMP TABLE t1(x);
+ }
+ execsql {
+ SELECT * FROM t1;
+ }
+} {}
+
+ifcapable view {
+ do_test tkt1644-2.1 {
+ execsql {
+ CREATE TEMP TABLE temp_t1(a, b);
+ }
+ set ::DB [sqlite3_connection_pointer db]
+ set ::STMT [sqlite3_prepare $::DB "SELECT * FROM temp_t1" -1 DUMMY]
+ execsql {
+ DROP TABLE temp_t1;
+ }
+ list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
+ } {SQLITE_ERROR SQLITE_SCHEMA}
+
+ do_test tkt1644-2.2 {
+ execsql {
+ CREATE TABLE real_t1(a, b);
+ CREATE TEMP VIEW temp_v1 AS SELECT * FROM real_t1;
+ }
+ set ::DB [sqlite3_connection_pointer db]
+ set ::STMT [sqlite3_prepare $::DB "SELECT * FROM temp_v1" -1 DUMMY]
+ execsql {
+ DROP VIEW temp_v1;
+ }
+ list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
+ } {SQLITE_ERROR SQLITE_SCHEMA}
+
+ do_test tkt1644-2.3 {
+ execsql {
+ CREATE TEMP VIEW temp_v1 AS SELECT * FROM real_t1 LIMIT 10 OFFSET 10;
+ }
+ set ::DB [sqlite3_connection_pointer db]
+ set ::STMT [sqlite3_prepare $::DB "SELECT * FROM temp_v1" -1 DUMMY]
+ execsql {
+ DROP VIEW temp_v1;
+ }
+ list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
+ } {SQLITE_ERROR SQLITE_SCHEMA}
+}
+
+
+finish_test
diff --git a/test/tkt1667.test b/test/tkt1667.test
new file mode 100644
index 0000000..6381506
--- /dev/null
+++ b/test/tkt1667.test
@@ -0,0 +1,83 @@
+# 2006 February 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1667 has been
+# fixed.
+#
+#
+# $Id: tkt1667.test,v 1.4 2009/02/05 17:00:54 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !autovacuum||!tclvar {
+ finish_test
+ return
+}
+
+db close
+forcedelete test.db test.db-journal
+
+# Set the pending byte offset such that the page it is on is
+# the first autovacuum pointer map page in the file (assume a page
+# size of 1024).
+
+set first_ptrmap_page [expr 1024/5 + 3]
+sqlite3_test_control_pending_byte [expr 1024 * ($first_ptrmap_page-1)]
+
+sqlite3 db test.db
+
+do_test tkt1667-1 {
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ }
+ for {set i 0} {$i < 500} {incr i} {
+ execsql {
+ INSERT INTO t1 VALUES($i, randstr(1000, 2000))
+ }
+ }
+ execsql {
+ COMMIT;
+ }
+} {}
+for {set i 0} {$i < 500} {incr i} {
+ do_test tkt1667-2.$i.1 {
+ execsql {
+ DELETE FROM t1 WHERE a = $i;
+ }
+ } {}
+ integrity_check tkt1667-2.$i.2
+}
+
+do_test tkt1667-3 {
+ execsql {
+ BEGIN;
+ }
+ for {set i 0} {$i < 500} {incr i} {
+ execsql {
+ INSERT INTO t1 VALUES($i, randstr(1000, 2000))
+ }
+ }
+ execsql {
+ COMMIT;
+ }
+} {}
+do_test tkt1667-4.1 {
+ execsql {
+ DELETE FROM t1;
+ }
+} {}
+integrity_check tkt1667-4.2
+
+finish_test
diff --git a/test/tkt1873.test b/test/tkt1873.test
new file mode 100644
index 0000000..9930790
--- /dev/null
+++ b/test/tkt1873.test
@@ -0,0 +1,72 @@
+# 2006 June 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #1873 has been
+# fixed.
+#
+#
+# $Id: tkt1873.test,v 1.2 2007/10/09 08:29:33 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !attach {
+ finish_test
+ return
+}
+
+forcedelete test2.db test2.db-journal
+
+do_test tkt1873-1.1 {
+ execsql {
+ CREATE TABLE t1(x, y);
+ ATTACH 'test2.db' AS aux;
+ CREATE TABLE aux.t2(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t2 VALUES(5, 6);
+ INSERT INTO t2 VALUES(7, 8);
+ }
+} {}
+
+do_test tkt1873-1.2 {
+ set rc [catch {
+ db eval {SELECT * FROM t2 LIMIT 1} {
+ db eval {DETACH aux}
+ }
+ } msg]
+ list $rc $msg
+} {1 {database aux is locked}}
+
+do_test tkt1873-1.3 {
+ set rc [catch {
+ db eval {SELECT * FROM t1 LIMIT 1} {
+ db eval {DETACH aux}
+ }
+ } msg]
+ list $rc $msg
+} {0 {}}
+
+do_test tkt1873-1.4 {
+ catchsql {
+ select * from t2;
+ }
+} {1 {no such table: t2}}
+
+do_test tkt1873-1.5 {
+ catchsql {
+ ATTACH 'test2.db' AS aux;
+ select * from t2;
+ }
+} {0 {5 6 7 8}}
+
+finish_test
diff --git a/test/tkt2141.test b/test/tkt2141.test
new file mode 100644
index 0000000..a40659f
--- /dev/null
+++ b/test/tkt2141.test
@@ -0,0 +1,61 @@
+# 2007 January 03
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #2141 has been
+# fixed.
+#
+#
+# $Id: tkt2141.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+do_test tkt2141-1.1 {
+ execsql {
+ CREATE TABLE tab1 (t1_id integer PRIMARY KEY, t1_desc);
+ INSERT INTO tab1 VALUES(1,'rec 1 tab 1');
+ CREATE TABLE tab2 (t2_id integer PRIMARY KEY, t2_id_t1, t2_desc);
+ INSERT INTO tab2 VALUES(1,1,'rec 1 tab 2');
+ CREATE TABLE tab3 (t3_id integer PRIMARY KEY, t3_id_t2, t3_desc);
+ INSERT INTO tab3 VALUES(1,1,'aa');
+ SELECT *
+ FROM tab1 t1 LEFT JOIN tab2 t2 ON t1.t1_id = t2.t2_id_t1
+ WHERE t2.t2_id IN
+ (SELECT t2_id FROM tab2, tab3 ON t2_id = t3_id_t2
+ WHERE t3_id IN (1,2) GROUP BY t2_id);
+ }
+} {1 {rec 1 tab 1} 1 1 {rec 1 tab 2}}
+do_test tkt2141-1.2 {
+ execsql {
+ SELECT *
+ FROM tab1 t1 LEFT JOIN tab2 t2 ON t1.t1_id = t2.t2_id_t1
+ WHERE t2.t2_id IN
+ (SELECT t2_id FROM tab2, tab3 ON t2_id = t3_id_t2
+ WHERE t3_id IN (1,2));
+ }
+} {1 {rec 1 tab 1} 1 1 {rec 1 tab 2}}
+do_test tkt2141-1.3 {
+ execsql {
+ SELECT *
+ FROM tab1 t1 LEFT JOIN tab2 t2
+ WHERE t2.t2_id IN
+ (SELECT t2_id FROM tab2, tab3 ON t2_id = t3_id_t2
+ WHERE t3_id IN (1,2));
+ }
+} {1 {rec 1 tab 1} 1 1 {rec 1 tab 2}}
+
+finish_test
diff --git a/test/tkt2192.test b/test/tkt2192.test
new file mode 100644
index 0000000..72ef9a2
--- /dev/null
+++ b/test/tkt2192.test
@@ -0,0 +1,140 @@
+# 2007 January 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #2192 has been
+# fixed.
+#
+#
+# $Id: tkt2192.test,v 1.3 2008/08/04 03:51:24 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !datetime||!compound {
+ finish_test
+ return
+}
+
+do_test tkt2192-1.1 {
+ execsql {
+ -- Raw data (RBS) --------
+
+ create table records (
+ date real,
+ type text,
+ description text,
+ value integer,
+ acc_name text,
+ acc_no text
+ );
+
+ -- Direct Debits ----------------
+ create view direct_debits as
+ select * from records where type = 'D/D';
+
+ create view monthly_direct_debits as
+ select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value
+ from direct_debits
+ group by strftime('%Y-%m', date);
+
+ -- Expense Categories ---------------
+ create view energy as
+ select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value
+ from direct_debits
+ where description like '%NPOWER%'
+ group by strftime('%Y-%m', date);
+
+ create view phone_internet as
+ select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value
+ from direct_debits
+ where description like '%BT DIRECT%'
+ or description like '%SUPANET%'
+ or description like '%ORANGE%'
+ group by strftime('%Y-%m', date);
+
+ create view credit_cards as
+ select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value
+ from direct_debits where description like '%VISA%'
+ group by strftime('%Y-%m', date);
+
+ -- Overview ---------------------
+
+ create view expense_overview as
+ select 'Energy' as expense, date, value from energy
+ union
+ select 'Phone/Internet' as expense, date, value from phone_internet
+ union
+ select 'Credit Card' as expense, date, value from credit_cards;
+
+ create view jan as
+ select 'jan', expense, value from expense_overview
+ where date like '%-01';
+
+ create view nov as
+ select 'nov', expense, value from expense_overview
+ where date like '%-11';
+
+ create view summary as
+ select * from jan join nov on (jan.expense = nov.expense);
+ }
+} {}
+do_test tkt2192-1.2 {
+ # set ::sqlite_addop_trace 1
+ execsql {
+ select * from summary;
+ }
+} {}
+do_test tkt2192-2.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ CREATE VIEW v1 AS
+ SELECT * FROM t1 WHERE b%7=0 UNION SELECT * FROM t1 WHERE b%5=0;
+ INSERT INTO t1 VALUES(1,7);
+ INSERT INTO t1 VALUES(2,10);
+ INSERT INTO t1 VALUES(3,14);
+ INSERT INTO t1 VALUES(4,15);
+ INSERT INTO t1 VALUES(1,16);
+ INSERT INTO t1 VALUES(2,17);
+ INSERT INTO t1 VALUES(3,20);
+ INSERT INTO t1 VALUES(4,21);
+ INSERT INTO t1 VALUES(1,22);
+ INSERT INTO t1 VALUES(2,24);
+ INSERT INTO t1 VALUES(3,25);
+ INSERT INTO t1 VALUES(4,26);
+ INSERT INTO t1 VALUES(1,27);
+
+ SELECT b FROM v1 ORDER BY b;
+ }
+} {7 10 14 15 20 21 25}
+do_test tkt2192-2.2 {
+ execsql {
+ SELECT * FROM v1 ORDER BY a, b;
+ }
+} {1 7 2 10 3 14 3 20 3 25 4 15 4 21}
+do_test tkt2192-2.3 {
+ execsql {
+ SELECT x.a || '/' || x.b || '/' || y.b
+ FROM v1 AS x JOIN v1 AS y ON x.a=y.a AND x.b<y.b
+ ORDER BY x.a, x.b, y.b
+ }
+} {3/14/20 3/14/25 3/20/25 4/15/21}
+do_test tkt2192-2.4 {
+ execsql {
+ CREATE VIEW v2 AS
+ SELECT x.a || '/' || x.b || '/' || y.b AS z
+ FROM v1 AS x JOIN v1 AS y ON x.a=y.a AND x.b<y.b
+ ORDER BY x.a, x.b, y.b;
+ SELECT * FROM v2;
+ }
+} {3/14/20 3/14/25 3/20/25 4/15/21}
+
+finish_test
diff --git a/test/tkt2213.test b/test/tkt2213.test
new file mode 100644
index 0000000..d5a81ab
--- /dev/null
+++ b/test/tkt2213.test
@@ -0,0 +1,29 @@
+# 2007 Febuary 05
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #2213 has been
+# fixed.
+#
+#
+# $Id: tkt2213.test,v 1.2 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt2213-1 {
+ sqlite3_create_function db
+ catchsql {
+ SELECT tkt2213func(tkt2213func('abcd'));
+ }
+} {0 abcd}
+
+finish_test
diff --git a/test/tkt2251.test b/test/tkt2251.test
new file mode 100644
index 0000000..799b7d6
--- /dev/null
+++ b/test/tkt2251.test
@@ -0,0 +1,108 @@
+# 2007 Febuary 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that table column values
+# are pulled out of the database correctly.
+#
+# Long ago, the OP_Column opcode was sufficient to pull out the
+# value of a table column. But then we added the ALTER TABLE ADD COLUMN
+# feature. An added column might not actually exist in every row,
+# and so the OP_Column opcode has to contain a default value. Later
+# still we added a feature whereby a REAL value with no fractional
+# part is stored in the database file as an integer to save space.
+# After extracting the value, we have to call OP_RealAffinity to
+# convert it back to a REAL.
+#
+# The sqlite3ExprCodeGetColumn() routine was added to take care of
+# all of the complications above. The tests in this file attempt
+# to verify that sqlite3ExprCodeGetColumn() is used instead of a
+# raw OP_Column in all places where a table column is extracted from
+# the database.
+#
+# $Id: tkt2251.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+# Create sample data. Verify that the default value and type of an added
+# column is correct for aggregates.
+do_test tkt2251-1.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(9);
+ INSERT INTO t1 VALUES(9);
+ INSERT INTO t1 VALUES(9);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(2);
+ ALTER TABLE t1 ADD COLUMN b REAL DEFAULT 4.0;
+ SELECT avg(b), typeof(avg(b)) FROM t1;
+ }
+} {4.0 real}
+do_test tkt2251-1.2 {
+ execsql {
+ SELECT sum(b), typeof(sum(b)) FROM t1;
+ }
+} {32.0 real}
+do_test tkt2251-1.3 {
+ execsql {
+ SELECT a, sum(b), typeof(sum(b)) FROM t1 GROUP BY a ORDER BY a;
+ }
+} {1 8.0 real 2 8.0 real 3 4.0 real 9 12.0 real}
+
+# Make sure that the REAL value comes out when values are accessed
+# by index.
+#
+do_test tkt2251-2.1 {
+ execsql {
+ SELECT b, typeof(b) FROM t1 WHERE a=3;
+ }
+} {4.0 real}
+do_test tkt2251-2.2 {
+ execsql {
+ CREATE INDEX t1i1 ON t1(a,b);
+ SELECT b, typeof(b) FROM t1 WHERE a=3;
+ }
+} {4.0 real}
+do_test tkt2251-2.3 {
+ execsql {
+ REINDEX;
+ SELECT b, typeof(b) FROM t1 WHERE a=3;
+ }
+} {4.0 real}
+
+# Make sure the correct REAL value is used when copying from one
+# table to another.
+#
+do_test tkt2251-3.1 {
+ execsql {
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 SELECT * FROM t1;
+ SELECT y, typeof(y) FROM t2 WHERE x=3;
+ }
+} {4.0 real}
+do_test tkt2251-3.2 {
+ execsql {
+ CREATE TABLE t3 AS SELECT * FROM t1;
+ SELECT b, typeof(b) FROM t3 WHERE a=3;
+ }
+} {4.0 real}
+
+
+finish_test
diff --git a/test/tkt2285.test b/test/tkt2285.test
new file mode 100644
index 0000000..f177c22
--- /dev/null
+++ b/test/tkt2285.test
@@ -0,0 +1,56 @@
+# 2005 September 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically.
+# it contains tests to verify that ticket #2285 has been fixed.
+#
+# $Id: tkt2285.test,v 1.2 2008/07/12 14:52:20 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !tempdb {
+ finish_test
+ return
+}
+
+do_test tkt2285-1.1 {
+ execsql {
+ PRAGMA locking_mode = EXCLUSIVE;
+ }
+ execsql {
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ ROLLBACK;
+ }
+} {}
+
+do_test tkt2285-1.2 {
+ execsql {
+ SELECT * FROM sqlite_master;
+ }
+} {}
+
+ifcapable tempdb {
+ do_test tkt2285-2.1 {
+ execsql {
+ BEGIN;
+ CREATE TEMP TABLE abc(a, b, c);
+ ROLLBACK;
+ }
+ } {}
+ do_test tkt2285-2.2 {
+ execsql {
+ SELECT * FROM sqlite_temp_master;
+ }
+ } {}
+}
+
+finish_test
diff --git a/test/tkt2332.test b/test/tkt2332.test
new file mode 100644
index 0000000..2d09dda
--- /dev/null
+++ b/test/tkt2332.test
@@ -0,0 +1,67 @@
+# 2007 May 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: tkt2332.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !incrblob||!tclvar {
+ finish_test
+ return
+}
+
+do_test tkt2332.1 {
+ execsql {
+ CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB);
+ PRAGMA cache_size = 100;
+ }
+} {}
+
+set ::iKey 1
+foreach Len [list 10000 100000 1000000] {
+ do_test tkt2332.$Len.1 {
+ set val "[expr rand()][expr rand()][expr rand()][expr rand()][expr rand()]"
+ set ::blobstr [string range \
+ [string repeat $val [expr ($Len/[string length $val])+1]] 0 [expr $Len-1]
+ ]
+
+ db eval { INSERT INTO blobs VALUES($::iKey, zeroblob($Len)) }
+ } {}
+
+ do_test tkt2332.$Len.2 {
+ execsql {
+ SELECT length(v) FROM blobs WHERE k = $::iKey;
+ }
+ } $Len
+
+ do_test tkt2332.$Len.3 {
+ set ::fd [db incrblob blobs v $::iKey]
+ puts -nonewline $::fd $::blobstr
+ close $::fd
+ } {}
+
+ do_test tkt2332.$Len.4 {
+ execsql { SELECT length(v) FROM blobs WHERE k = $::iKey; }
+ } $Len
+
+ do_test tkt2332.$Len.5 {
+ lindex [execsql {SELECT v FROM blobs WHERE k = $::iKey}] 0
+ } $::blobstr
+
+ incr ::iKey
+}
+
+# Free memory:
+unset ::blobstr
+
+finish_test
diff --git a/test/tkt2339.test b/test/tkt2339.test
new file mode 100644
index 0000000..41acd37
--- /dev/null
+++ b/test/tkt2339.test
@@ -0,0 +1,100 @@
+# 2007 May 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: tkt2339.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery||!compound {
+ finish_test
+ return
+}
+
+do_test tkt2339.1 {
+ execsql {
+ create table t1(num int);
+ insert into t1 values (1);
+ insert into t1 values (2);
+ insert into t1 values (3);
+ insert into t1 values (4);
+
+ create table t2(num int);
+ insert into t2 values (11);
+ insert into t2 values (12);
+ insert into t2 values (13);
+ insert into t2 values (14);
+
+ SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
+ UNION
+ SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)
+ }
+} {3 4 13 14}
+do_test tkt2339.2 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
+ UNION ALL
+ SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)
+ }
+} {4 3 14 13}
+do_test tkt2339.3 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC)
+ UNION ALL
+ SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)
+ }
+} {4 3 2 1 14 13}
+do_test tkt2339.4 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
+ UNION ALL
+ SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC)
+ }
+} {4 3 14 13 12 11}
+do_test tkt2339.5 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
+ UNION
+ SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC)
+ }
+} {3 4 11 12 13 14}
+do_test tkt2339.6 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
+ EXCEPT
+ SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC)
+ }
+} {3 4}
+do_test tkt2339.7 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 LIMIT 2)
+ UNION
+ SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)
+ }
+} {1 2 13 14}
+do_test tkt2339.8 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 LIMIT 2)
+ UNION
+ SELECT * FROM (SELECT * FROM t2 LIMIT 2)
+ }
+} {1 2 11 12}
+do_test tkt2339.9 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
+ UNION
+ SELECT * FROM (SELECT * FROM t2 LIMIT 2)
+ }
+} {3 4 11 12}
+
+
+finish_test
diff --git a/test/tkt2391.test b/test/tkt2391.test
new file mode 100644
index 0000000..d192b85
--- /dev/null
+++ b/test/tkt2391.test
@@ -0,0 +1,49 @@
+#
+# 2007 May 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# $Id: tkt2391.test,v 1.1 2007/05/29 12:11:30 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt2391.1 {
+ execsql {
+ CREATE TABLE folders(folderid, parentid, foldername COLLATE binary);
+ INSERT INTO folders VALUES(1, 3, 'FolderA');
+ INSERT INTO folders VALUES(1, 3, 'folderB');
+ INSERT INTO folders VALUES(4, 0, 'FolderC');
+ }
+} {}
+
+do_test tkt2391.2 {
+ execsql {
+ SELECT count(*) FROM folders WHERE foldername < 'FolderC';
+ }
+} {1}
+
+do_test tkt2391.3 {
+ execsql {
+ SELECT count(*) FROM folders WHERE foldername < 'FolderC' COLLATE nocase;
+ }
+} {2}
+
+# This demonstrates the bug. Creating the index causes SQLite to ignore
+# the "COLLATE nocase" clause and use the default collation sequence
+# for column "foldername" instead (happens to be BINARY in this case).
+#
+do_test tkt2391.4 {
+ execsql {
+ CREATE INDEX f_i ON folders(foldername);
+ SELECT count(*) FROM folders WHERE foldername < 'FolderC' COLLATE nocase;
+ }
+} {2}
+
+finish_test
diff --git a/test/tkt2409.test b/test/tkt2409.test
new file mode 100644
index 0000000..9ac6542
--- /dev/null
+++ b/test/tkt2409.test
@@ -0,0 +1,229 @@
+# 2007 June 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #2409 has been
+# fixed. More specifically, they verify that if SQLite cannot
+# obtain an EXCLUSIVE lock while trying to spill the cache during
+# any statement other than a COMMIT, an I/O error is returned instead
+# of SQLITE_BUSY.
+#
+# $Id: tkt2409.test,v 1.6 2008/08/28 17:46:19 drh Exp $
+
+# Test Outline:
+#
+# tkt-2409-1.*: Cause a cache-spill during an INSERT that is within
+# a db transaction but does not start a statement transaction.
+# Verify that the transaction is automatically rolled back
+# and SQLITE_IOERR_BLOCKED is returned
+#
+# UPDATE: As of the pcache modifications, failing to upgrade to
+# an exclusive lock when attempting a cache-spill is no longer an
+# error. The pcache module allocates more space and keeps working
+# in memory if this occurs.
+#
+# tkt-2409-2.*: Cause a cache-spill while updating the change-counter
+# during a database COMMIT. Verify that the transaction is not
+# rolled back and SQLITE_BUSY is returned.
+#
+# tkt-2409-3.*: Similar to 2409-1.*, but using many INSERT statements
+# within a transaction instead of just one.
+#
+# UPDATE: Again, pcache now just keeps working in main memory.
+#
+# tkt-2409-4.*: Similar to 2409-1.*, but rig it so that the
+# INSERT statement starts a statement transaction. Verify that
+# SQLITE_BUSY is returned and the transaction is not rolled back.
+#
+# UPDATE: This time, SQLITE_BUSY is not returned. pcache just uses
+# more malloc()'d memory.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !pager_pragmas {
+ finish_test
+ return
+}
+
+sqlite3_extended_result_codes $::DB 1
+
+# Aquire a read-lock on the database using handle [db2].
+#
+proc read_lock_db {} {
+ if {$::STMT eq ""} {
+ set ::STMT [sqlite3_prepare db2 {SELECT rowid FROM sqlite_master} -1 TAIL]
+ set rc [sqlite3_step $::STMT]
+ if {$rc eq "SQLITE_ERROR"} {
+ unread_lock_db
+ read_lock_db
+ }
+ }
+}
+
+# Release any read-lock obtained using [read_lock_db]
+#
+proc unread_lock_db {} {
+ if {$::STMT ne ""} {
+ sqlite3_finalize $::STMT
+ set ::STMT ""
+ }
+}
+
+# Open the db handle used by [read_lock_db].
+#
+sqlite3 db2 test.db
+set ::STMT ""
+
+do_test tkt2409-1.1 {
+ execsql {
+ PRAGMA cache_size=10;
+ CREATE TABLE t1(x TEXT UNIQUE NOT NULL, y BLOB);
+ }
+ read_lock_db
+ set ::zShort [string repeat 0123456789 1]
+ set ::zLong [string repeat 0123456789 1500]
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 VALUES($::zShort, $::zLong);
+ }
+} {0 {}}
+
+do_test tkt2409-1.2 {
+ sqlite3_errcode $::DB
+} {SQLITE_OK}
+
+# Check the integrity of the cache.
+#
+integrity_check tkt2409-1.3
+
+# Check that the transaction was rolled back. Because the INSERT
+# statement in which the "I/O error" occured did not open a statement
+# transaction, SQLite had no choice but to roll back the transaction.
+#
+do_test tkt2409-1.4 {
+ unread_lock_db
+ catchsql { ROLLBACK }
+} {0 {}}
+
+set ::zShort [string repeat 0123456789 1]
+set ::zLong [string repeat 0123456789 1500]
+set ::rc 1
+for {set iCache 10} {$::rc} {incr iCache} {
+ execsql "PRAGMA cache_size = $iCache"
+ do_test tkt2409-2.1.$iCache {
+ read_lock_db
+ set ::rc [catch {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES($::zShort, $::zLong);
+ }
+ } msg]
+ expr {($::rc == 1 && $msg eq "disk I/O error") || $::rc == 0}
+ } {1}
+}
+
+do_test tkt2409-2.2 {
+ catchsql {
+ ROLLBACK;
+ BEGIN;
+ INSERT INTO t1 VALUES($::zShort, $::zLong);
+ COMMIT;
+ }
+} {1 {database is locked}}
+
+do_test tkt2409-2.3 {
+ unread_lock_db
+ catchsql {
+ COMMIT;
+ }
+} {0 {}}
+
+
+do_test tkt2409-3.1 {
+ db close
+ set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
+ sqlite3_extended_result_codes $::DB 1
+ execsql {
+ PRAGMA cache_size=10;
+ DELETE FROM t1;
+ }
+ read_lock_db
+ set ::zShort [string repeat 0123456789 1]
+ set ::zLong [string repeat 0123456789 1500]
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 SELECT $::zShort, $::zLong;
+ }
+} {0 {}}
+
+do_test tkt2409-3.2 {
+ sqlite3_errcode $::DB
+} {SQLITE_OK}
+
+# Check the integrity of the cache.
+#
+integrity_check tkt2409-3.3
+
+# Check that the transaction was rolled back. Because the INSERT
+# statement in which the "I/O error" occured did not open a statement
+# transaction, SQLite had no choice but to roll back the transaction.
+#
+do_test tkt2409-3.4 {
+ unread_lock_db
+ catchsql { ROLLBACK }
+} {0 {}}
+integrity_check tkt2409-3.5
+
+expr {srand(1)}
+do_test tkt2409-4.1 {
+ execsql {
+ PRAGMA cache_size=20;
+ DROP TABLE t1;
+ CREATE TABLE t1 (x TEXT UNIQUE NOT NULL);
+ }
+
+ unset -nocomplain t1
+ array unset t1
+ set t1(0) 1
+ set sql ""
+ for {set i 0} {$i<5000} {incr i} {
+ set r 0
+ while {[info exists t1($r)]} {
+ set r [expr {int(rand()*1000000000)}]
+ }
+ set t1($r) 1
+ append sql "INSERT INTO t1 VALUES('some-text-$r');"
+ }
+
+ read_lock_db
+ execsql BEGIN
+ catchsql $sql
+} {0 {}}
+
+do_test tkt2409-4.2 {
+ sqlite3_errcode $::DB
+} {SQLITE_OK}
+
+# Check the integrity of the cache.
+#
+integrity_check tkt2409-4.3
+
+do_test tkt2409-4.4 {
+ catchsql { ROLLBACK }
+} {0 {}}
+integrity_check tkt2409-4.5
+
+unread_lock_db
+db2 close
+unset -nocomplain t1
+finish_test
diff --git a/test/tkt2450.test b/test/tkt2450.test
new file mode 100644
index 0000000..50f7189
--- /dev/null
+++ b/test/tkt2450.test
@@ -0,0 +1,48 @@
+# 2007 June 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that ticket #2450 has been fixed.
+#
+# $Id: tkt2450.test,v 1.1 2007/06/24 06:32:18 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt2450-1 {
+ execsql {
+ CREATE TABLE "t a" ("""cb""");
+ INSERT INTO "t a" ("""cb""") VALUES (1);
+ SELECT """cb""" FROM "t a";
+ }
+} {1}
+
+do_test tkt2450-2 {
+ execsql {
+ SELECT * FROM "t a";
+ }
+} {1}
+
+do_test tkt2450-3 {
+ execsql {
+ SELECT "t a".* FROM "t a";
+ }
+} {1}
+
+do_test tkt2450-3 {
+ execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(2);
+ SELECT * FROM "t a", t1;
+ }
+} {1 2}
+
+finish_test
diff --git a/test/tkt2565.test b/test/tkt2565.test
new file mode 100644
index 0000000..8df0419
--- /dev/null
+++ b/test/tkt2565.test
@@ -0,0 +1,92 @@
+# 2009 January 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This script attempts to reproduce the circumstances of ticket #2565.
+#
+# More specifically, this script attempts to generate rollback journals
+# that contain headers with nRec==0 that are followed by additional
+# valid headers.
+#
+# $Id: tkt2565.test,v 1.2 2009/04/09 01:23:49 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Use the alternative pcache and rig it to call pagerStress()
+# very frequently.
+#
+db close
+sqlite3_shutdown
+sqlite3_config_alt_pcache 1 100 0 1
+
+# Open two database connections to database "test.db".
+#
+proc reopen_database {} {
+ catch {db close}
+ sqlite3 db test.db
+ db cache size 0
+ execsql {
+ pragma page_size=512;
+ pragma auto_vacuum=2;
+ pragma cache_size=16;
+ }
+}
+
+# Open two database connections and create a single table in the db.
+#
+do_test tkt2565-1.0 {
+ reopen_database
+ execsql { CREATE TABLE A(Id INTEGER, Name TEXT) }
+} {}
+
+for {set iFail 1} {$iFail<200} {incr iFail} {
+ reopen_database
+ execsql { pragma locking_mode=exclusive }
+ set nRow [db one {SELECT count(*) FROM a}]
+
+ # Dirty (at least) one of the pages in the cache.
+ do_test tkt2565-1.$iFail.1 {
+ execsql {
+ BEGIN EXCLUSIVE;
+ INSERT INTO a VALUES(1, 'ABCDEFGHIJKLMNOP');
+ }
+ } {}
+
+ # Now try to commit the transaction. Cause an IO error to occur
+ # within this operation, which moves the pager into the error state.
+ #
+ set ::sqlite_io_error_persist 1
+ set ::sqlite_io_error_pending $iFail
+ do_test tkt2565-1.$iFail.2 {
+ set rc [catchsql {COMMIT}]
+ list
+ } {}
+ set ::sqlite_io_error_persist 0
+ set ::sqlite_io_error_pending 0
+ if {!$::sqlite_io_error_hit} break
+ set ::sqlite_io_error_hit 0
+}
+
+# Make sure this test script doesn't leave any files open.
+#
+do_test tkt2565-1.X {
+ catch { db close }
+ set sqlite_open_file_count
+} 0
+
+# Restore the pcache configuration for subsequent tests.
+#
+sqlite3_shutdown
+sqlite3_config_alt_pcache 0
+sqlite3_initialize
+autoinstall_test_functions
+
+finish_test
diff --git a/test/tkt2640.test b/test/tkt2640.test
new file mode 100644
index 0000000..13a17e0
--- /dev/null
+++ b/test/tkt2640.test
@@ -0,0 +1,124 @@
+# 2007 Sep 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that ticket #2640 has been fixed.
+#
+# $Id: tkt2640.test,v 1.3 2008/08/04 03:51:24 danielk1977 Exp $
+#
+
+# The problem in ticket #2640 was that the query optimizer was
+# not recognizing all uses of tables within subqueries in the
+# WHERE clause. If the subquery contained a compound SELECT,
+# then tables that were used by terms of the compound other than
+# the last term would not be recognized as dependencies.
+# So if one of the SELECT statements within a compound made
+# use of a table that occurs later in a join, the query
+# optimizer would not recognize this and would try to evaluate
+# the subquery too early, before that tables value had been
+# established.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery||!compound {
+ finish_test
+ return
+}
+
+do_test tkt2640-1.1 {
+ execsql {
+ CREATE TABLE persons(person_id, name);
+ INSERT INTO persons VALUES(1,'fred');
+ INSERT INTO persons VALUES(2,'barney');
+ INSERT INTO persons VALUES(3,'wilma');
+ INSERT INTO persons VALUES(4,'pebbles');
+ INSERT INTO persons VALUES(5,'bambam');
+ CREATE TABLE directors(person_id);
+ INSERT INTO directors VALUES(5);
+ INSERT INTO directors VALUES(3);
+ CREATE TABLE writers(person_id);
+ INSERT INTO writers VALUES(2);
+ INSERT INTO writers VALUES(3);
+ INSERT INTO writers VALUES(4);
+ SELECT DISTINCT p.name
+ FROM persons p, directors d
+ WHERE d.person_id=p.person_id
+ AND NOT EXISTS (
+ SELECT person_id FROM directors d1 WHERE d1.person_id=p.person_id
+ EXCEPT
+ SELECT person_id FROM writers w
+ );
+ }
+} {wilma}
+do_test tkt2640-1.2 {
+ execsql {
+ SELECT DISTINCT p.name
+ FROM persons p CROSS JOIN directors d
+ WHERE d.person_id=p.person_id
+ AND NOT EXISTS (
+ SELECT person_id FROM directors d1 WHERE d1.person_id=p.person_id
+ EXCEPT
+ SELECT person_id FROM writers w
+ );
+ }
+} {wilma}
+do_test tkt2640-1.3 {
+ execsql {
+ SELECT DISTINCT p.name
+ FROM directors d CROSS JOIN persons p
+ WHERE d.person_id=p.person_id
+ AND NOT EXISTS (
+ SELECT person_id FROM directors d1 WHERE d1.person_id=p.person_id
+ EXCEPT
+ SELECT person_id FROM writers w
+ );
+ }
+} {wilma}
+do_test tkt2640-1.4 {
+ execsql {
+ SELECT DISTINCT p.name
+ FROM persons p, directors d
+ WHERE d.person_id=p.person_id
+ AND NOT EXISTS (
+ SELECT person_id FROM directors d1 WHERE d1.person_id=d.person_id
+ EXCEPT
+ SELECT person_id FROM writers w
+ );
+ }
+} {wilma}
+do_test tkt2640-1.5 {
+ execsql {
+ SELECT DISTINCT p.name
+ FROM persons p CROSS JOIN directors d
+ WHERE d.person_id=p.person_id
+ AND NOT EXISTS (
+ SELECT person_id FROM directors d1 WHERE d1.person_id=d.person_id
+ EXCEPT
+ SELECT person_id FROM writers w
+ );
+ }
+} {wilma}
+do_test tkt2640-1.6 {
+ execsql {
+ SELECT DISTINCT p.name
+ FROM directors d CROSS JOIN persons p
+ WHERE d.person_id=p.person_id
+ AND NOT EXISTS (
+ SELECT person_id FROM directors d1 WHERE d1.person_id=d.person_id
+ EXCEPT
+ SELECT person_id FROM writers w
+ );
+ }
+} {wilma}
+
+
+
+finish_test
diff --git a/test/tkt2643.test b/test/tkt2643.test
new file mode 100644
index 0000000..5c58863
--- /dev/null
+++ b/test/tkt2643.test
@@ -0,0 +1,39 @@
+# 2007 Sep 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that ticket #2643 has been fixed.
+#
+# $Id: tkt2643.test,v 1.1 2007/09/13 17:54:41 drh Exp $
+#
+
+# The problem in ticket #2643 has to do with the query optimizer
+# making bad assumptions about index cost when data from ANALYZE
+# is available.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt2643-1.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(2,3,4);
+ ANALYZE;
+ }
+ db close
+ sqlite3 db test.db
+ execsql {
+ CREATE INDEX i1 ON t1(c);
+ SELECT count(*) FROM t1 WHERE c IS NOT NULL
+ }
+} {2}
+
+finish_test
diff --git a/test/tkt2686.test b/test/tkt2686.test
new file mode 100644
index 0000000..20447bb
--- /dev/null
+++ b/test/tkt2686.test
@@ -0,0 +1,81 @@
+# 2007 Oct 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that ticket #2686 has been fixed.
+#
+# $Id: tkt2686.test,v 1.3 2008/02/02 02:48:52 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+db eval {
+ PRAGMA page_size=1024;
+ PRAGMA max_page_count=50;
+ PRAGMA auto_vacuum=0;
+ CREATE TABLE filler (fill);
+}
+for {set i 1} {$i<2000} {incr i} {
+ do_test tkt2686-$i.1 {
+ db eval BEGIN
+ set rc [catch {
+ while 1 {
+ db eval {INSERT INTO filler (fill) VALUES (randstr(1000, 10000)) }
+ }
+ } msg]
+ lappend rc $msg
+ } {1 {database or disk is full}}
+ do_test tkt2686-$i.2 {
+ execsql {
+ DELETE FROM filler
+ WHERE rowid <= (SELECT MAX(rowid) FROM filler LIMIT 20)
+ }
+ } {}
+ integrity_check tkt2686-$i.3
+ catch {db eval COMMIT}
+}
+
+db close
+forcedelete test.db test.db-journal
+sqlite3 db test.db
+
+db eval {
+ PRAGMA page_size=1024;
+ PRAGMA max_page_count=50;
+ PRAGMA auto_vacuum=1;
+ CREATE TABLE filler (fill);
+}
+for {set i 10000} {$i<12000} {incr i} {
+ do_test tkt2686-$i.1 {
+ db eval BEGIN
+ set rc [catch {
+ while 1 {
+ db eval {INSERT INTO filler (fill) VALUES (randstr(1000, 10000)) }
+ }
+ } msg]
+ lappend rc $msg
+ } {1 {database or disk is full}}
+ do_test tkt2686-$i.2 {
+ execsql {
+ DELETE FROM filler
+ WHERE rowid <= (SELECT MAX(rowid) FROM filler LIMIT 20)
+ }
+ } {}
+ integrity_check tkt2686-$i.3
+ catch {db eval COMMIT}
+}
+
+finish_test
diff --git a/test/tkt2767.test b/test/tkt2767.test
new file mode 100644
index 0000000..29b5201
--- /dev/null
+++ b/test/tkt2767.test
@@ -0,0 +1,90 @@
+# 2007 Oct 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that ticket #2767 has been fixed.
+# Ticket #2767 is for a VDBE stack overflow on BEFORE
+# triggers that run RAISE(IGNORE).
+#
+# $Id: tkt2767.test,v 1.3 2009/04/07 14:14:23 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !trigger { finish_test ; return }
+
+do_test tkt2767-1.1 {
+ execsql {
+ -- Construct a table with many rows of data
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 SELECT x+2 FROM t1;
+ INSERT INTO t1 SELECT x+4 FROM t1;
+ INSERT INTO t1 SELECT x+8 FROM t1;
+ INSERT INTO t1 SELECT x+16 FROM t1;
+
+ -- BEFORE triggers that invoke raise(ignore). The effect of
+ -- these triggers should be to make INSERTs, UPDATEs, and DELETEs
+ -- into no-ops.
+ CREATE TRIGGER r1 BEFORE UPDATE ON t1 BEGIN
+ SELECT raise(ignore);
+ END;
+ CREATE TRIGGER r2 BEFORE DELETE ON t1 BEGIN
+ SELECT raise(ignore);
+ END;
+ CREATE TRIGGER r3 BEFORE INSERT ON t1 BEGIN
+ SELECT raise(ignore);
+ END;
+
+ -- Verify the table content
+ SELECT count(*), sum(x) FROM t1;
+ }
+} {32 528}
+
+# Try to delete all elements of the table. This will invoke the
+# DELETE trigger 32 times, which should overflow the VDBE stack if
+# the problem of #2767 is not fixed. If the problem is fixed, all
+# the deletes should be no-ops so the table should remain unchanged.
+#
+do_test tkt2767-1.2 {
+ execsql {
+ DELETE FROM t1 WHERE x>0;
+ SELECT count(*), sum(x) FROM t1;
+ }
+} {32 528}
+
+# Try to update all elements of the table. This will invoke the
+# UPDATE trigger 32 times, which should overflow the VDBE stack if
+# the problem of #2767 is not fixed. If the problem is fixed, all
+# the updates should be no-ops so the table should remain unchanged.
+#
+do_test tkt2767-1.3 {
+ execsql {
+ UPDATE t1 SET x=x+1;
+ SELECT count(*), sum(x) FROM t1;
+ }
+} {32 528}
+
+# Invoke the insert trigger. The insert trigger was working
+# even prior to the fix of #2767. But it seems good to go ahead
+# and verify that it works.
+#
+do_test tkt2767-1.4 {
+ execsql {
+ INSERT INTO t1 SELECT x+32 FROM t1;
+ SELECT count(*), sum(x) FROM t1;
+ }
+} {32 528}
+
+
+
+finish_test
diff --git a/test/tkt2817.test b/test/tkt2817.test
new file mode 100644
index 0000000..579cf2f
--- /dev/null
+++ b/test/tkt2817.test
@@ -0,0 +1,72 @@
+# 2007 December 02
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# Specifically, it tests that bug 2817 is fixed.
+#
+# $Id: tkt2817.test,v 1.2 2008/07/12 14:52:21 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt2817-1.0 {
+ execsql {
+ CREATE TEMP TABLE tbl(a, b, c);
+ -- INSERT INTO tbl VALUES(1, 'abc', 'def');
+ -- INSERT INTO tbl VALUES(2, 'ghi', 'jkl');
+ }
+} {}
+do_test tkt2817-1.1 {
+ execsql {
+ CREATE TABLE main.tbl(a, b, c);
+ CREATE INDEX main.tbli ON tbl(a, b, c);
+ INSERT INTO main.tbl SELECT a, b, c FROM temp.tbl;
+ }
+} {}
+
+# When bug #2817 existed, this test was failing.
+#
+integrity_check tkt2817-1.2
+
+# So was this one.
+#
+db close
+sqlite3 db test.db
+integrity_check tkt2817-1.3
+
+
+# These tests - tkt2817-2.* - are the same as the previous block, except
+# for the fact that the temp-table and the main table do not share the
+# same name. #2817 did not cause a problem with these tests.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_test tkt2817-2.0 {
+ execsql {
+ CREATE TEMP TABLE tmp(a, b, c);
+ INSERT INTO tmp VALUES(1, 'abc', 'def');
+ INSERT INTO tmp VALUES(2, 'ghi', 'jkl');
+ }
+} {}
+do_test tkt2817-2.1 {
+ execsql {
+ CREATE TABLE main.tbl(a, b, c);
+ CREATE INDEX main.tbli ON tbl(a, b, c);
+ INSERT INTO main.tbl SELECT a, b, c FROM temp.tmp;
+ }
+} {}
+integrity_check tkt2817-2.2
+db close
+sqlite3 db test.db
+integrity_check tkt2817-2.3
+
+finish_test
diff --git a/test/tkt2820.test b/test/tkt2820.test
new file mode 100644
index 0000000..11c4cd3
--- /dev/null
+++ b/test/tkt2820.test
@@ -0,0 +1,94 @@
+# 2007 Dec 4
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that ticket #2820 has been fixed.
+# Ticket #2820 observes that a DROP TABLE statement that
+# occurs while a query is in process will fail with a
+# "database is locked" error, but the entry in the sqlite_master
+# table will still be removed. This is incorrect. The
+# entry in the sqlite_master table should persist when
+# the DROP fails due to an error.
+#
+# $Id: tkt2820.test,v 1.1 2007/12/04 16:54:53 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc test_schema_change {testid init ddl res} {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ execsql $init
+ do_test tkt2820-$testid.1 {
+ set STMT [sqlite3_prepare db {SELECT * FROM sqlite_master} -1 DUMMY]
+ sqlite3_step $STMT
+ } {SQLITE_ROW}
+#if {$testid==3} {execsql {PRAGMA vdbe_trace=ON}}
+ do_test tkt2820-$testid.2 "catchsql [list $ddl]" \
+ {1 {database table is locked}}
+ do_test tkt2820-$testid.3 {
+ sqlite3_finalize $STMT
+ execsql {SELECT name FROM sqlite_master ORDER BY 1}
+ } $res
+ integrity_check tkt2820-$testid.4
+ db close
+ sqlite3 db test.db
+ integrity_check tkt2820-$testid.5
+}
+
+test_schema_change 1 {
+ CREATE TABLE t1(a);
+} {
+ DROP TABLE t1
+} {t1}
+test_schema_change 2 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(b);
+} {
+ DROP TABLE t2
+} {t1 t2}
+test_schema_change 3 {
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a);
+} {
+ DROP INDEX i1
+} {i1 t1}
+
+# We further observe that prior to the fix associated with ticket #2820,
+# no statement journal would be created on an SQL statement that was run
+# while a second statement was active, as long as we are in autocommit
+# mode. This is incorrect.
+#
+do_test tkt2820-4.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ }
+
+ # The INSERT statement within the loop should fail on a
+ # constraint violation on the second inserted row. This
+ # should cause the entire INSERT to rollback using a statement
+ # journal.
+ #
+ db eval {SELECT name FROM sqlite_master} {
+ catch {db eval {
+ INSERT INTO t1 SELECT a+1 FROM t1 ORDER BY a DESC
+ }}
+ }
+ db eval {SELECT a FROM t1 ORDER BY a}
+} {1 2}
+
+finish_test
diff --git a/test/tkt2822.test b/test/tkt2822.test
new file mode 100644
index 0000000..281e5dc
--- /dev/null
+++ b/test/tkt2822.test
@@ -0,0 +1,336 @@
+# 2007 Dec 4
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that the issues surrounding expressions in
+# ORDER BY clauses on compound SELECT statements raised by ticket
+# #2822 have been dealt with.
+#
+# $Id: tkt2822.test,v 1.6 2008/08/20 16:35:10 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+# The ORDER BY matching algorithm is three steps:
+#
+# (1) If the ORDER BY term is an integer constant i, then
+# sort by the i-th column of the result set.
+#
+# (2) If the ORDER BY term is an identifier (not x.y or x.y.z
+# but simply x) then look for a column alias with the same
+# name. If found, then sort by that column.
+#
+# (3) Evaluate the term as an expression and sort by the
+# value of the expression.
+#
+# For a compound SELECT the rules are modified slightly.
+# In the third rule, the expression must exactly match one
+# of the result columns. The sequences of three rules is
+# attempted first on the left-most SELECT. If that doesn't
+# work, we move to the right, one by one.
+#
+# Rule (3) is not in standard SQL - it is an SQLite extension,
+# though one copied from PostgreSQL. The rule for compound
+# queries where a search is made of SELECTs to the right
+# if the left-most SELECT does not match is not a part of
+# standard SQL either. This extension is unique to SQLite
+# as far as we know.
+#
+# Rule (2) was added by the changes ticket #2822. Prior to
+# that changes, SQLite did not support rule (2), making it
+# technically in violation of standard SQL semantics.
+# No body noticed because rule (3) has the same effect as
+# rule (2) except in some obscure cases.
+#
+
+
+# Test plan:
+#
+# tkt2822-1.* - Simple identifier as ORDER BY expression.
+# tkt2822-2.* - More complex ORDER BY expressions.
+
+do_test tkt2822-0.1 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+
+ INSERT INTO t1 VALUES(1, 3, 9);
+ INSERT INTO t1 VALUES(3, 9, 27);
+ INSERT INTO t1 VALUES(5, 15, 45);
+
+ INSERT INTO t2 VALUES(2, 6, 18);
+ INSERT INTO t2 VALUES(4, 12, 36);
+ INSERT INTO t2 VALUES(6, 18, 54);
+ }
+} {}
+
+# Test the "ORDER BY <integer>" syntax.
+#
+do_test tkt2822-1.1 {
+ execsql {
+ SELECT a, b, c FROM t1 UNION ALL SELECT a, b, c FROM t2 ORDER BY 1;
+ }
+} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}
+do_test tkt2822-1.2 {
+ execsql {
+ SELECT a, CAST (b AS TEXT), c FROM t1
+ UNION ALL
+ SELECT a, b, c FROM t2
+ ORDER BY 2;
+ }
+} {2 6 18 4 12 36 6 18 54 5 15 45 1 3 9 3 9 27}
+
+# Test the "ORDER BY <identifier>" syntax.
+#
+do_test tkt2822-2.1 {
+ execsql {
+ SELECT a, b, c FROM t1 UNION ALL SELECT a, b, c FROM t2 ORDER BY a;
+ }
+} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}
+
+do_test tkt2822-2.2 {
+ execsql {
+ SELECT a, CAST (b AS TEXT) AS x, c FROM t1
+ UNION ALL
+ SELECT a, b, c FROM t2
+ ORDER BY x;
+ }
+} {2 6 18 4 12 36 6 18 54 5 15 45 1 3 9 3 9 27}
+do_test tkt2822-2.3 {
+ execsql {
+ SELECT t1.a, b, c FROM t1 UNION ALL SELECT t2.a, b, c FROM t2 ORDER BY a;
+ }
+} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}
+
+# Test the "ORDER BY <expression>" syntax.
+#
+do_test tkt2822-3.1 {
+ execsql {
+ SELECT a, CAST (b AS TEXT) AS x, c FROM t1
+ UNION ALL
+ SELECT a, b, c FROM t2
+ ORDER BY CAST (b AS TEXT);
+ }
+} {2 6 18 4 12 36 6 18 54 5 15 45 1 3 9 3 9 27}
+do_test tkt2822-3.2 {
+ execsql {
+ SELECT t1.a, b, c FROM t1 UNION ALL SELECT t2.a, b, c FROM t2 ORDER BY t1.a;
+ }
+} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}
+
+# Test that if a match cannot be found in the leftmost SELECT, an
+# attempt is made to find a match in subsequent SELECT statements.
+#
+do_test tkt2822-3.3 {
+ execsql {
+ SELECT a, b, c FROM t1 UNION ALL SELECT a AS x, b, c FROM t2 ORDER BY x;
+ }
+} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}
+do_test tkt2822-3.4 {
+ # But the leftmost SELECT takes precedence.
+ execsql {
+ SELECT a AS b, CAST (b AS TEXT) AS a, c FROM t1
+ UNION ALL
+ SELECT a, b, c FROM t2
+ ORDER BY a;
+ }
+} {2 6 18 4 12 36 6 18 54 5 15 45 1 3 9 3 9 27}
+do_test tkt2822-3.5 {
+ execsql {
+ SELECT a, b, c FROM t2
+ UNION ALL
+ SELECT a AS b, CAST (b AS TEXT) AS a, c FROM t1
+ ORDER BY a;
+ }
+} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}
+
+# Test some error conditions (ORDER BY clauses that match no column).
+#
+do_test tkt2822-4.1 {
+ catchsql {
+ SELECT a, b, c FROM t1 UNION ALL SELECT a, b, c FROM t2 ORDER BY x
+ }
+} {1 {1st ORDER BY term does not match any column in the result set}}
+do_test tkt2822-4.2 {
+ catchsql {
+ SELECT a, CAST (b AS TEXT) AS x, c FROM t1
+ UNION ALL
+ SELECT a, b, c FROM t2
+ ORDER BY CAST (b AS INTEGER);
+ }
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+# Tests for rule (2).
+#
+# The "ORDER BY b" should match the column alias (rule 2), not the
+# the t3.b value (rule 3).
+#
+do_test tkt2822-5.1 {
+ execsql {
+ CREATE TABLE t3(a,b);
+ INSERT INTO t3 VALUES(1,8);
+ INSERT INTO t3 VALUES(9,2);
+
+ SELECT a AS b FROM t3 ORDER BY b;
+ }
+} {1 9}
+do_test tkt2822-5.2 {
+ # Case does not matter. b should match B
+ execsql {
+ SELECT a AS b FROM t3 ORDER BY B;
+ }
+} {1 9}
+do_test tkt2822-5.3 {
+ # Quoting should not matter
+ execsql {
+ SELECT a AS 'b' FROM t3 ORDER BY "B";
+ }
+} {1 9}
+do_test tkt2822-5.4 {
+ # Quoting should not matter
+ execsql {
+ SELECT a AS "b" FROM t3 ORDER BY [B];
+ }
+} {1 9}
+
+# In "ORDER BY +b" the term is now an expression rather than
+# a label. It therefore matches by rule (3) instead of rule (2).
+#
+do_test tkt2822-5.5 {
+ execsql {
+ SELECT a AS b FROM t3 ORDER BY +b;
+ }
+} {9 1}
+
+# Tests for rule 2 in compound queries
+#
+do_test tkt2822-6.1 {
+ execsql {
+ CREATE TABLE t6a(p,q);
+ INSERT INTO t6a VALUES(1,8);
+ INSERT INTO t6a VALUES(9,2);
+ CREATE TABLE t6b(x,y);
+ INSERT INTO t6b VALUES(1,7);
+ INSERT INTO t6b VALUES(7,2);
+
+ SELECT p, q FROM t6a UNION ALL SELECT x, y FROM t6b ORDER BY 1, 2
+ }
+} {1 7 1 8 7 2 9 2}
+do_test tkt2822-6.2 {
+ execsql {
+ SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b
+ ORDER BY PX, YX
+ }
+} {1 7 1 8 7 2 9 2}
+do_test tkt2822-6.3 {
+ execsql {
+ SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b
+ ORDER BY XX, QX
+ }
+} {1 7 1 8 7 2 9 2}
+do_test tkt2822-6.4 {
+ execsql {
+ SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b
+ ORDER BY QX, XX
+ }
+} {7 2 9 2 1 7 1 8}
+do_test tkt2822-6.5 {
+ execsql {
+ SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b
+ ORDER BY t6b.x, QX
+ }
+} {1 7 1 8 7 2 9 2}
+do_test tkt2822-6.6 {
+ execsql {
+ SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b
+ ORDER BY t6a.q, XX
+ }
+} {7 2 9 2 1 7 1 8}
+
+# More error message tests. This is really more of a test of the
+# %r ordinal value formatting capablity added to sqlite3_snprintf()
+# by ticket #2822.
+#
+do_test tkt2822-7.1 {
+ execsql {
+ CREATE TABLE t7(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,
+ a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25);
+ }
+ catchsql {
+ SELECT * FROM t7 ORDER BY 0;
+ }
+} {1 {1st ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.2 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 0;
+ }
+} {1 {2nd ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.3 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 2, 0;
+ }
+} {1 {3rd ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.4 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 2, 3, 0;
+ }
+} {1 {4th ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.9 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 0;
+ }
+} {1 {9th ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.10 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 0;
+ }
+} {1 {10th ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.11 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0;
+ }
+} {1 {11th ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.12 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 0;
+ }
+} {1 {12th ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.13 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 0;
+ }
+} {1 {13th ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.20 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11,12,13,14,15,16,17,18,19, 0
+ }
+} {1 {20th ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.21 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11,12,13,14,15,16,17,18,19, 20, 0
+ }
+} {1 {21st ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.22 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11,12,13,14,15,16,17,18,19, 20, 21, 0
+ }
+} {1 {22nd ORDER BY term out of range - should be between 1 and 25}}
+
+
+finish_test
diff --git a/test/tkt2832.test b/test/tkt2832.test
new file mode 100644
index 0000000..f998699
--- /dev/null
+++ b/test/tkt2832.test
@@ -0,0 +1,67 @@
+# 2007 Dec 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that ticket #2832 has been fixed.
+#
+# $Id: tkt2832.test,v 1.5 2009/04/07 14:14:23 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !trigger { finish_test ; return }
+
+do_test tkt2832-1.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(3);
+ }
+} {}
+do_test tkt2832-1.2 {
+ execsql {
+ UPDATE OR REPLACE t1 SET a = 1;
+ SELECT * FROM t1;
+ }
+} {1}
+
+do_test tkt2832-2.1 {
+ execsql {
+ CREATE TABLE t2(a, b);
+ CREATE TRIGGER t2_t AFTER UPDATE ON t2 BEGIN
+ DELETE FROM t2 WHERE a = new.a + 1;
+ END;
+ INSERT INTO t2 VALUES(1, 2);
+ INSERT INTO t2 VALUES(2, 3);
+ }
+} {}
+do_test tkt2832-2.2 {
+ execsql {
+ UPDATE t2 SET b = 5
+ }
+} {}
+
+do_test tkt2832-3.1 {
+ execsql {
+ CREATE TABLE t3(a, b);
+ CREATE TRIGGER t3_t AFTER DELETE ON t3 BEGIN
+ DELETE FROM t3 WHERE a = old.a + 1;
+ END;
+ INSERT INTO t3 VALUES(1, 2);
+ INSERT INTO t3 VALUES(2, 3);
+ }
+} {}
+do_test tkt2832-3.2 {
+ execsql { DELETE FROM t3 WHERE 1 }
+} {}
+
+finish_test
diff --git a/test/tkt2854.test b/test/tkt2854.test
new file mode 100644
index 0000000..914ddd1
--- /dev/null
+++ b/test/tkt2854.test
@@ -0,0 +1,149 @@
+# 2007 December 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: tkt2854.test,v 1.4 2009/03/16 13:19:36 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db close
+
+ifcapable !shared_cache {
+ finish_test
+ return
+}
+
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+# Open 3 database connections. Connection "db" and "db2" share a cache.
+# Connection "db3" has its own cache.
+#
+do_test tkt2854-1.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+
+ # This is taken from shared.test. The Windows VFS expands
+ # ./test.db (and test.db) to be the same thing so the path
+ # matches and they share a cache. By changing the case
+ # for Windows platform, we get around this and get a separate
+ # connection.
+ if {$::tcl_platform(platform)=="unix"} {
+ sqlite3 db3 ./test.db
+ } else {
+ sqlite3 db3 TEST.DB
+ }
+
+ db eval {
+ CREATE TABLE abc(a, b, c);
+ }
+} {}
+
+# Check that an exclusive lock cannot be obtained if some other
+# shared-cache connection has a read-lock on a table.
+#
+do_test tkt2854-1.2 {
+ execsql {
+ BEGIN;
+ SELECT * FROM abc;
+ } db2
+} {}
+do_test tkt2854-1.3 {
+ catchsql { BEGIN EXCLUSIVE } db
+} {1 {database table is locked}}
+do_test tkt2854-1.4 {
+ execsql { SELECT * FROM abc } db3
+} {}
+do_test tkt2854-1.5 {
+ catchsql { INSERT INTO abc VALUES(1, 2, 3) } db3
+} {1 {database is locked}}
+do_test tkt2854-1.6 {
+ execsql { COMMIT } db2
+} {}
+
+# Check that an exclusive lock prevents other shared-cache users from
+# starting a transaction.
+#
+do_test tkt2854-1.7 {
+ set ::DB2 [sqlite3_connection_pointer db2]
+ set ::STMT1 [sqlite3_prepare $DB2 "SELECT * FROM abc" -1 TAIL]
+ set ::STMT2 [sqlite3_prepare $DB2 "BEGIN EXCLUSIVE" -1 TAIL]
+ set ::STMT3 [sqlite3_prepare $DB2 "BEGIN IMMEDIATE" -1 TAIL]
+ set ::STMT4 [sqlite3_prepare $DB2 "BEGIN" -1 TAIL]
+ set ::STMT5 [sqlite3_prepare $DB2 "COMMIT" -1 TAIL]
+ execsql { BEGIN EXCLUSIVE } db
+} {}
+do_test tkt2854-1.8 {
+ catchsql { BEGIN EXCLUSIVE } db2
+} {1 {database schema is locked: main}}
+do_test tkt2854-1.9 {
+ catchsql { BEGIN IMMEDIATE } db2
+} {1 {database schema is locked: main}}
+do_test tkt2854-1.10 {
+ # This fails because the schema of main cannot be verified.
+ catchsql { BEGIN } db2
+} {1 {database schema is locked: main}}
+
+# Check that an exclusive lock prevents other shared-cache users from
+# reading the database. Use stored statements so that the error occurs
+# at the b-tree level, not the schema level.
+#
+do_test tkt2854-1.11 {
+ list [sqlite3_step $::STMT1] [sqlite3_finalize $::STMT1]
+} {SQLITE_ERROR SQLITE_LOCKED}
+do_test tkt2854-1.12 {
+ list [sqlite3_step $::STMT2] [sqlite3_finalize $::STMT2]
+} {SQLITE_ERROR SQLITE_LOCKED}
+do_test tkt2854-1.13 {
+ list [sqlite3_step $::STMT3] [sqlite3_finalize $::STMT3]
+} {SQLITE_ERROR SQLITE_LOCKED}
+do_test tkt2854-1.14 {
+ # A regular "BEGIN" doesn't touch any databases. So it succeeds.
+ list [sqlite3_step $::STMT4] [sqlite3_finalize $::STMT4]
+} {SQLITE_DONE SQLITE_OK}
+do_test tkt2854-1.15 {
+ # As does a COMMIT.
+ list [sqlite3_step $::STMT5] [sqlite3_finalize $::STMT5]
+} {SQLITE_DONE SQLITE_OK}
+
+# Try to read the database using connection "db3" (which does not share
+# a cache with "db"). The database should be locked.
+do_test tkt2854-1.16 {
+ catchsql { SELECT * FROM abc } db3
+} {1 {database is locked}}
+do_test tkt2854-1.17 {
+ execsql { COMMIT } db
+} {}
+do_test tkt2854-1.18 {
+ execsql { SELECT * FROM abc } db2
+} {}
+
+# Check that if an attempt to obtain an exclusive lock fails because an
+# attached db cannot be locked, the internal exclusive flag used by
+# shared-cache users is correctly cleared.
+do_test tkt2854-1.19 {
+ forcedelete test2.db test2.db-journal
+ sqlite3 db4 test2.db
+ execsql { CREATE TABLE def(d, e, f) } db4
+ execsql { ATTACH 'test2.db' AS aux } db
+} {}
+do_test tkt2854-1.20 {
+ execsql {BEGIN IMMEDIATE} db4
+ catchsql {BEGIN EXCLUSIVE} db
+} {1 {database table is locked}}
+do_test tkt2854-1.21 {
+ execsql {SELECT * FROM abc} db2
+} {}
+
+db close
+db2 close
+db3 close
+db4 close
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/tkt2920.test b/test/tkt2920.test
new file mode 100644
index 0000000..d76c05b
--- /dev/null
+++ b/test/tkt2920.test
@@ -0,0 +1,78 @@
+# 2008 Feb 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that ticket #2920 is fixed.
+#
+# $Id: tkt2920.test,v 1.1 2008/02/02 02:48:52 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a database file that is full.
+#
+do_test tkt2920-1.1 {
+ db eval {
+ PRAGMA page_size=1024;
+ PRAGMA max_page_count=40;
+ PRAGMA auto_vacuum=0;
+ CREATE TABLE filler (fill);
+ }
+ file size test.db
+} {2048}
+do_test tkt2920-1.2 {
+ db eval BEGIN
+ for {set i 0} {$i<34} {incr i} {
+ db eval {INSERT INTO filler VALUES(randomblob(1024))}
+ }
+ db eval COMMIT
+} {}
+
+# Try to add a single new page to the full database. We get
+# a disk full error. But this does not corrupt the database.
+#
+do_test tkt2920-1.3 {
+ db eval BEGIN
+ catchsql {
+ INSERT INTO filler VALUES(randomblob(1024))
+ }
+} {1 {database or disk is full}}
+integrity_check tkt2920-1.4
+
+# Increase the maximum size of the database file by 1 page,
+# but then try to add a two-page record. This also fails.
+#
+do_test tkt2920-1.5 {
+ db eval {PRAGMA max_page_count=41}
+ catchsql {
+ INSERT INTO filler VALUES(randomblob(2048))
+ }
+} {1 {database or disk is full}}
+integrity_check tkt2920-1.6
+
+# Increase the maximum size of the database by one more page.
+# This time the insert works.
+#
+do_test tkt2920-1.7 {
+ db eval {PRAGMA max_page_count=42}
+ catchsql {
+ INSERT INTO filler VALUES(randomblob(2048))
+ }
+} {0 {}}
+integrity_check tkt2920-1.8
+
+# The previous errors cancelled the transaction.
+#
+do_test tkt2920-1.9 {
+ catchsql {COMMIT}
+} {1 {cannot commit - no transaction is active}}
+
+finish_test
diff --git a/test/tkt2927.test b/test/tkt2927.test
new file mode 100644
index 0000000..fc89a41
--- /dev/null
+++ b/test/tkt2927.test
@@ -0,0 +1,674 @@
+# 2008 Feb 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that ticket #2927 is fixed.
+#
+# $Id: tkt2927.test,v 1.4 2008/08/04 03:51:24 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+# Create a database.
+#
+do_test tkt2927-1.1 {
+ db eval {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1,11);
+ INSERT INTO t1 VALUES(2,22);
+ INSERT INTO t1 VALUES(3,33);
+ INSERT INTO t1 VALUES(4,44);
+ INSERT INTO t1 VALUES(5,55);
+ SELECT * FROM t1;
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+
+
+do_test tkt2927-2.1 {
+ db eval {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT a, b FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.2 {
+#set sqlite_addop_trace 1
+ db eval {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT a, abs(b) FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.3 {
+ db eval {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT abs(a), b FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.4 {
+ db eval {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT abs(a), abs(b) FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.5 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ UNION ALL
+ SELECT a, b FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.6 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ UNION ALL
+ SELECT a, abs(b) FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.7 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ UNION ALL
+ SELECT abs(a), b FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.8 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ UNION ALL
+ SELECT abs(a), abs(b) FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.9 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ UNION ALL
+ SELECT a, b FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.10 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ UNION ALL
+ SELECT a, abs(b) FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.11 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ UNION ALL
+ SELECT abs(a), b FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.12 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ UNION ALL
+ SELECT abs(a), abs(b) FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.13 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ UNION ALL
+ SELECT a, b FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.14 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ UNION ALL
+ SELECT a, abs(b) FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.15 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ UNION ALL
+ SELECT abs(a), b FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-2.16 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ UNION ALL
+ SELECT abs(a), abs(b) FROM t1
+ }
+} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
+
+
+do_test tkt2927-3.1 {
+ db eval {
+ SELECT a, b FROM t1
+ UNION
+ SELECT a, b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.2 {
+ db eval {
+ SELECT a, b FROM t1
+ UNION
+ SELECT a, abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.3 {
+ db eval {
+ SELECT a, b FROM t1
+ UNION
+ SELECT abs(a), b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.4 {
+ db eval {
+ SELECT a, b FROM t1
+ UNION
+ SELECT abs(a), abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.5 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ UNION
+ SELECT a, b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.6 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ UNION
+ SELECT a, abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.7 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ UNION
+ SELECT abs(a), b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.8 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ UNION
+ SELECT abs(a), abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.9 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ UNION
+ SELECT a, b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.10 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ UNION
+ SELECT a, abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.11 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ UNION
+ SELECT abs(a), b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.12 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ UNION
+ SELECT abs(a), abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.13 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ UNION
+ SELECT a, b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.14 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ UNION
+ SELECT a, abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.15 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ UNION
+ SELECT abs(a), b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-3.16 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ UNION
+ SELECT abs(a), abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+
+
+do_test tkt2927-4.1 {
+ db eval {
+ SELECT a+b, a-b, a, b FROM t1
+ UNION ALL
+ SELECT a+b, a-b, a, b FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.2 {
+ db eval {
+ SELECT a+b, a-b, a, b FROM t1
+ UNION ALL
+ SELECT a+b, a-b, a, abs(b) FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.3 {
+ db eval {
+ SELECT a+b, a-b, a, b FROM t1
+ UNION ALL
+ SELECT a+b, a-b, abs(a), b FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.4 {
+ db eval {
+ SELECT a+b, a-b, a, b FROM t1
+ UNION ALL
+ SELECT a+b, a-b, abs(a), abs(b) FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.5 {
+ db eval {
+ SELECT a+b, a-b, a, abs(b) FROM t1
+ UNION ALL
+ SELECT a+b, a-b, a, b FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.6 {
+ db eval {
+ SELECT a+b, a-b, a, abs(b) FROM t1
+ UNION ALL
+ SELECT a+b, a-b, a, abs(b) FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.7 {
+ db eval {
+ SELECT a+b, a-b, a, abs(b) FROM t1
+ UNION ALL
+ SELECT a+b, a-b, abs(a), b FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.8 {
+ db eval {
+ SELECT a+b, a-b, a, abs(b) FROM t1
+ UNION ALL
+ SELECT a+b, a-b, abs(a), abs(b) FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.9 {
+ db eval {
+ SELECT a+b, a-b, abs(a), b FROM t1
+ UNION ALL
+ SELECT a+b, a-b, a, b FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.10 {
+ db eval {
+ SELECT a+b, a-b, abs(a), b FROM t1
+ UNION ALL
+ SELECT a+b, a-b, a, abs(b) FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.11 {
+ db eval {
+ SELECT a+b, a-b, abs(a), b FROM t1
+ UNION ALL
+ SELECT a+b, a-b, abs(a), b FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.12 {
+ db eval {
+ SELECT a+b, a-b, abs(a), b FROM t1
+ UNION ALL
+ SELECT a+b, a-b, abs(a), abs(b) FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.13 {
+ db eval {
+ SELECT a+b, a-b, abs(a), abs(b) FROM t1
+ UNION ALL
+ SELECT a+b, a-b, a, b FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.14 {
+ db eval {
+ SELECT a+b, a-b, abs(a), abs(b) FROM t1
+ UNION ALL
+ SELECT a+b, a-b, a, abs(b) FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.15 {
+ db eval {
+ SELECT a+b, a-b, abs(a), abs(b) FROM t1
+ UNION ALL
+ SELECT a+b, a-b, abs(a), b FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+do_test tkt2927-4.16 {
+ db eval {
+ SELECT a+b, a-b, abs(a), abs(b) FROM t1
+ UNION ALL
+ SELECT a+b, a-b, abs(a), abs(b) FROM t1
+ }
+} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
+
+
+do_test tkt2927-5.1 {
+ db eval {
+ SELECT a, b FROM t1
+ EXCEPT
+ SELECT a, b FROM t1
+ }
+} {}
+do_test tkt2927-5.2 {
+ db eval {
+ SELECT a, b FROM t1
+ EXCEPT
+ SELECT a, abs(b) FROM t1
+ }
+} {}
+do_test tkt2927-5.3 {
+ db eval {
+ SELECT a, b FROM t1
+ EXCEPT
+ SELECT abs(a), b FROM t1
+ }
+} {}
+do_test tkt2927-5.4 {
+ db eval {
+ SELECT a, b FROM t1
+ EXCEPT
+ SELECT abs(a), abs(b) FROM t1
+ }
+} {}
+do_test tkt2927-5.5 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ EXCEPT
+ SELECT a, b FROM t1
+ }
+} {}
+do_test tkt2927-5.6 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ EXCEPT
+ SELECT a, abs(b) FROM t1
+ }
+} {}
+do_test tkt2927-5.7 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ EXCEPT
+ SELECT abs(a), b FROM t1
+ }
+} {}
+do_test tkt2927-5.8 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ EXCEPT
+ SELECT abs(a), abs(b) FROM t1
+ }
+} {}
+do_test tkt2927-5.9 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ EXCEPT
+ SELECT a, b FROM t1
+ }
+} {}
+do_test tkt2927-5.10 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ EXCEPT
+ SELECT a, abs(b) FROM t1
+ }
+} {}
+do_test tkt2927-5.11 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ EXCEPT
+ SELECT abs(a), b FROM t1
+ }
+} {}
+do_test tkt2927-5.12 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ EXCEPT
+ SELECT abs(a), abs(b) FROM t1
+ }
+} {}
+do_test tkt2927-5.13 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ EXCEPT
+ SELECT a, b FROM t1
+ }
+} {}
+do_test tkt2927-5.14 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ EXCEPT
+ SELECT a, abs(b) FROM t1
+ }
+} {}
+do_test tkt2927-5.15 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ EXCEPT
+ SELECT abs(a), b FROM t1
+ }
+} {}
+do_test tkt2927-5.16 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ EXCEPT
+ SELECT abs(a), abs(b) FROM t1
+ }
+} {}
+
+
+do_test tkt2927-6.1 {
+ db eval {
+ SELECT a, b FROM t1
+ INTERSECT
+ SELECT a, b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.2 {
+ db eval {
+ SELECT a, b FROM t1
+ INTERSECT
+ SELECT a, abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.3 {
+ db eval {
+ SELECT a, b FROM t1
+ INTERSECT
+ SELECT abs(a), b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.4 {
+ db eval {
+ SELECT a, b FROM t1
+ INTERSECT
+ SELECT abs(a), abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.5 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ INTERSECT
+ SELECT a, b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.6 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ INTERSECT
+ SELECT a, abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.7 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ INTERSECT
+ SELECT abs(a), b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.8 {
+ db eval {
+ SELECT a, abs(b) FROM t1
+ INTERSECT
+ SELECT abs(a), abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.9 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ INTERSECT
+ SELECT a, b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.10 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ INTERSECT
+ SELECT a, abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.11 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ INTERSECT
+ SELECT abs(a), b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.12 {
+ db eval {
+ SELECT abs(a), b FROM t1
+ INTERSECT
+ SELECT abs(a), abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.13 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ INTERSECT
+ SELECT a, b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.14 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ INTERSECT
+ SELECT a, abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.15 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ INTERSECT
+ SELECT abs(a), b FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+do_test tkt2927-6.16 {
+ db eval {
+ SELECT abs(a), abs(b) FROM t1
+ INTERSECT
+ SELECT abs(a), abs(b) FROM t1
+ ORDER BY 1
+ }
+} {1 11 2 22 3 33 4 44 5 55}
+
+# Ticket #3092 is the same bug. But another test case never hurts.
+#
+do_test tkt2927-7.1 {
+ db eval {
+ CREATE TABLE host (
+ hostname text not null primary key,
+ consoleHost text,
+ consolePort text
+ );
+ INSERT INTO "host" VALUES('aald04','aalp03','4');
+ INSERT INTO "host" VALUES('aald17','aalp01','1');
+ CREATE VIEW consolemap1a as
+ select hostname, consolehost, '/dev/cuaD0.' || (consoleport-1) consoleport
+ from host where consolehost='aalp01';
+ CREATE VIEW consolemap1b as
+ select hostname hostname, consolehost consolehost, '/dev/cuaD' ||
+ substr('01',1+((consoleport-1)/16),1) ||
+ substr('0123456789abcdef',1+((consoleport-1)%16),1) consoleport
+ from host where consolehost='aalp03';
+ CREATE VIEW consolemap1 as
+ select * from consolemap1a
+ union
+ select * from consolemap1b;
+ SELECT * from consolemap1b;
+ }
+} {aald04 aalp03 /dev/cuaD03}
+do_test tkt2927-7.2 {
+ db eval {
+ SELECT * FROM consolemap1
+ }
+} {aald04 aalp03 /dev/cuaD03 aald17 aalp01 /dev/cuaD0.0}
+
+finish_test
diff --git a/test/tkt2942.test b/test/tkt2942.test
new file mode 100644
index 0000000..a7b861c
--- /dev/null
+++ b/test/tkt2942.test
@@ -0,0 +1,62 @@
+# 2008 February 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #2942.
+#
+# Queries of the form:
+#
+# SELECT group_concat(x) FROM (SELECT * FROM table ORDER BY 1);
+#
+# The ORDER BY would be dropped by the query flattener. This used
+# to not matter because aggregate functions sum(), min(), max(), avg(),
+# and so forth give the same result regardless of the order of inputs.
+# But with the addition of the group_concat() function, suddenly the
+# order does matter.
+#
+# $Id: tkt2942.test,v 1.1 2008/02/15 14:33:04 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+do_test tkt2942.1 {
+ execsql {
+ create table t1(num int);
+ insert into t1 values (2);
+ insert into t1 values (1);
+ insert into t1 values (3);
+ insert into t1 values (4);
+ SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY num DESC);
+ }
+} {4,3,2,1}
+do_test tkt2942.2 {
+ execsql {
+ SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY num);
+ }
+} {1,2,3,4}
+do_test tkt2942.3 {
+ execsql {
+ SELECT group_concat(num) FROM (SELECT num FROM t1);
+ }
+} {2,1,3,4}
+do_test tkt2942.4 {
+ execsql {
+ SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY rowid DESC);
+ }
+} {4,3,1,2}
+
+
+finish_test
diff --git a/test/tkt3080.test b/test/tkt3080.test
new file mode 100644
index 0000000..bfccaa9
--- /dev/null
+++ b/test/tkt3080.test
@@ -0,0 +1,77 @@
+# 2008 April 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3080
+#
+# Make sure that application-defined functions are able to recursively
+# invoke SQL statements that create and drop virtual tables.
+#
+# $Id: tkt3080.test,v 1.2 2008/11/05 16:37:35 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3080.1 {
+ db function execsql execsql
+ db eval {
+ SELECT execsql('CREATE TABLE t1(x)');
+ }
+ execsql {SELECT name FROM sqlite_master}
+} {t1}
+do_test tkt3080.2 {
+ db eval {
+ INSERT INTO t1 VALUES('CREATE TABLE t2(y);');
+ SELECT execsql(x) FROM t1;
+ }
+ db eval {
+ SELECT name FROM sqlite_master;
+ }
+} {t1 t2}
+do_test tkt3080.3 {
+ execsql {
+ INSERT INTO t1 VALUES('CREATE TABLE t3(z); DROP TABLE t3;');
+ }
+ catchsql {
+ SELECT execsql(x) FROM t1 WHERE rowid=2;
+ }
+} {1 {database table is locked}}
+do_test tkt3080.4 {
+ db eval {
+ SELECT name FROM sqlite_master;
+ }
+} {t1 t2 t3}
+
+ifcapable vtab {
+ register_echo_module [sqlite3_connection_pointer db]
+ do_test tkt3080.10 {
+ set sql {
+ CREATE VIRTUAL TABLE t4 USING echo(t2);
+ INSERT INTO t4 VALUES(123);
+ DROP TABLE t4;
+ }
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES($sql);
+ }
+ db eval {
+ SELECT execsql(x) FROM t1
+ }
+ execsql {SELECT name FROM sqlite_master}
+ } {t1 t2 t3}
+ do_test tkt3080.11 {
+ execsql {SELECT * FROM t2}
+ } {123}
+}
+
+
+
+finish_test
diff --git a/test/tkt3093.test b/test/tkt3093.test
new file mode 100644
index 0000000..3be46d1
--- /dev/null
+++ b/test/tkt3093.test
@@ -0,0 +1,86 @@
+# 2008 May 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3093
+#
+# Verify that a busy callback waiting on a reserved lock resolves
+# once the lock clears.
+#
+# $Id: tkt3093.test,v 1.2 2008/05/02 14:23:55 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Set up a test database
+#
+do_test tkt3093.1 {
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ SELECT * FROM t1
+ }
+} {1}
+
+# Establish a separate, independent connection to that database.
+#
+do_test tkt3093.2 {
+ catch {sqlite3_enable_shared_cache 0}
+ sqlite3 db2 test.db
+ db2 eval {
+ SELECT * FROM t1
+ }
+} {1}
+
+# Make sure that clearing a lock allows a pending request for
+# a reserved lock to continue.
+#
+do_test tkt3093.3 {
+ # This will be the busy callback for connection db2. On the first
+ # busy callback, commit the transaction in db. This should clear
+ # the lock so that there should not be a second callback. If the
+ # busy handler is called a second time, then fail so that we get
+ # timeout.
+ proc busy_callback {cnt} {
+ if {$cnt==0} {
+ db eval COMMIT
+ return 0
+ } else {
+ return 1
+ }
+ }
+ db2 busy ::busy_callback
+
+ # Start a write transaction on db.
+ db eval {
+ BEGIN;
+ INSERT INTO t1 VALUES(2);
+ }
+
+ # Attempt to modify the database on db2
+ catchsql {
+ UPDATE t1 SET x=x+1;
+ } db2
+} {0 {}}
+
+# Verify that everything worked as expected. The db transaction should
+# have gone first and added entry 2. Then the db2 transaction would have
+# run and added one to each entry.
+#
+do_test tkt3093.4 {
+ db eval {SELECT * FROM t1}
+} {2 3}
+do_test tkt3093.5 {
+ db2 eval {SELECT * FROM t1}
+} {2 3}
+db2 close
+
+finish_test
diff --git a/test/tkt3121.test b/test/tkt3121.test
new file mode 100644
index 0000000..2e8fdbb
--- /dev/null
+++ b/test/tkt3121.test
@@ -0,0 +1,50 @@
+# 2008 May 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: tkt3121.test,v 1.2 2008/07/12 14:52:21 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+# Register the module
+register_echo_module [sqlite3_connection_pointer db]
+
+do_test vtabD-1.1 {
+ execsql {
+ PRAGMA encoding = 'utf16';
+
+ CREATE TABLE r1(field);
+ CREATE TABLE r2(col PRIMARY KEY, descr);
+
+ INSERT INTO r1 VALUES('abcd');
+ INSERT INTO r2 VALUES('abcd', 'A nice description');
+ INSERT INTO r2 VALUES('efgh', 'Another description');
+
+ CREATE VIRTUAL TABLE t1 USING echo(r1);
+ CREATE VIRTUAL TABLE t2 USING echo(r2);
+ }
+} {}
+
+do_test vtabD-1.2 {
+ execsql {
+ select
+ t1.field as Field,
+ t2.descr as Descr
+ from t1 inner join t2 on t1.field = t2.col order by t1.field
+ }
+} {abcd {A nice description}}
+
+finish_test
diff --git a/test/tkt3201.test b/test/tkt3201.test
new file mode 100644
index 0000000..47c5ebb
--- /dev/null
+++ b/test/tkt3201.test
@@ -0,0 +1,105 @@
+# 2008 July 4
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+# Specifically, it tests that bug #3201 has been fixed.
+#
+# $Id: tkt3201.test,v 1.3 2008/07/12 14:52:21 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3201-1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ }
+} {}
+
+do_test tkt3201-2 {
+ execsql {
+ SELECT l.a, r.a FROM t1 AS l, t1 AS r WHERE l.a < r.a;
+ }
+} {1 2}
+
+do_test tkt3201-3 {
+ execsql {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t2 VALUES(2, 'two');
+ }
+ execsql {
+ SELECT l.a, r.a FROM t1 AS l, t2 AS r WHERE l.a < r.a;
+ }
+} {1 2}
+
+do_test tkt3201-4 {
+ execsql {
+ DELETE FROM t1 WHERE a = 2;
+ }
+ execsql {
+ SELECT l.a, r.a FROM t1 AS l, t2 AS r WHERE l.a < r.a;
+ }
+} {1 2}
+
+do_test tkt3201-5 {
+ execsql {
+ DELETE FROM t1 WHERE a = 2;
+ }
+ execsql {
+ SELECT t1.a, t1.b, t2.a, t2.b FROM t1, t2;
+ }
+} {1 one 2 two}
+
+do_test tkt3201-6 {
+ execsql {
+ CREATE TABLE t3(c INTEGER PRIMARY KEY, d TEXT);
+ INSERT INTO t3 VALUES(2, 'two');
+ }
+ execsql { SELECT a, b, c, d FROM t1, t3 }
+} {1 one 2 two}
+
+do_test tkt3201-7 {
+ execsql { SELECT a, b, c, d FROM t1, t3 WHERE a < c }
+} {1 one 2 two}
+
+# Ticket [efc02f977919]
+#
+ifcapable trigger {
+ do_test tkt3201-4.0 {
+ db eval {
+ CREATE TABLE t4(x);
+ CREATE TABLE t4_log(x);
+ CREATE TRIGGER r4_1 AFTER INSERT ON t4 WHEN new.x=1 BEGIN
+ INSERT INTO t4_log(x) VALUES(new.x);
+ END;
+ CREATE TRIGGER r4_2 AFTER INSERT ON t4 WHEN new.x=2 BEGIN
+ INSERT INTO t4_log(x) VALUES(new.x);
+ END;
+ CREATE TRIGGER r4_3 AFTER INSERT ON t4 WHEN new.x=3 BEGIN
+ INSERT INTO t4_log(x) VALUES(new.x);
+ END;
+ CREATE TRIGGER r4_4 AFTER INSERT ON t4 WHEN new.x=4 BEGIN
+ INSERT INTO t4_log(x) VALUES(new.x);
+ END;
+ INSERT INTO t4 VALUES(1);
+ INSERT INTO t4 VALUES(2);
+ INSERT INTO t4 VALUES(3);
+ INSERT INTO t4 VALUES(4);
+ SELECT * FROM t4_log;
+ }
+ } {1 2 3 4}
+}
+
+
+
+
+
+finish_test
diff --git a/test/tkt3292.test b/test/tkt3292.test
new file mode 100644
index 0000000..0f95244
--- /dev/null
+++ b/test/tkt3292.test
@@ -0,0 +1,61 @@
+# 2008 August 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+# Specifically, it tests the behavior of the sqlite3VdbeRecordCompare()
+# routine in cases where the rowid is 0 or 1 in file format 4
+# (meaning that the rowid has type code 8 or 9 with zero bytes of
+# data). Ticket #3292.
+#
+# $Id: tkt3292.test,v 1.1 2008/08/13 14:07:41 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3292-1.1 {
+ execsql {
+ PRAGMA legacy_file_format=OFF;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
+ INSERT INTO t1 VALUES(0, 1);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 1);
+ CREATE INDEX i1 ON t1(b);
+ SELECT * FROM t1 WHERE b>=1;
+ }
+} {0 1 1 1 2 1}
+do_test tkt3292-1.2 {
+ execsql {
+ INSERT INTO t1 VALUES(3, 0);
+ INSERT INTO t1 VALUES(4, 2);
+ SELECT * FROM t1 WHERE b>=1;
+ }
+} {0 1 1 1 2 1 4 2}
+
+
+do_test tkt3292-2.1 {
+ execsql {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c, d);
+ INSERT INTO t2 VALUES(0, 1, 'hello', x'012345');
+ INSERT INTO t2 VALUES(1, 1, 'hello', x'012345');
+ INSERT INTO t2 VALUES(2, 1, 'hello', x'012345');
+ CREATE INDEX i2 ON t2(b,c,d);
+ SELECT a FROM t2 WHERE b=1 AND c='hello' AND d>=x'012345';
+ }
+} {0 1 2}
+do_test tkt3292-2.2 {
+ execsql {
+ INSERT INTO t2 VALUES(3, 1, 'hello', x'012344');
+ INSERT INTO t2 VALUES(4, 1, 'hello', x'012346');
+ SELECT a FROM t2 WHERE b=1 AND c='hello' AND d>=x'012345';
+ }
+} {0 1 2 4}
+
+
+finish_test
diff --git a/test/tkt3298.test b/test/tkt3298.test
new file mode 100644
index 0000000..0e546f7
--- /dev/null
+++ b/test/tkt3298.test
@@ -0,0 +1,80 @@
+# 2008 August 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file tests changes to the name resolution logic that occurred
+# in august of 2008 and where associated with tickets #3298 and #3301
+#
+# $Id: tkt3298.test,v 1.3 2009/04/07 14:14:23 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !trigger { finish_test ; return }
+
+do_test tkt3298-1.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
+ INSERT INTO t1 VALUES(0, 1);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 1);
+ CREATE VIEW v1 AS SELECT a AS x, b+1 AS y FROM t1;
+ CREATE TRIGGER r1 INSTEAD OF UPDATE ON v1
+ BEGIN
+ UPDATE t1 SET b=new.y-1 WHERE a=new.x;
+ END;
+ CREATE TRIGGER r2 INSTEAD OF DELETE ON v1
+ BEGIN
+ DELETE FROM t1 WHERE a=old.x;
+ END;
+ SELECT * FROM v1 ORDER BY x;
+ }
+} {0 2 1 2 2 2}
+do_test tkt3298-1.2 {
+ execsql {
+ UPDATE v1 SET y=3 WHERE x=0;
+ SELECT * FROM v1 ORDER by x;
+ }
+} {0 3 1 2 2 2}
+do_test tkt3298-1.3 {
+ execsql {
+ UPDATE v1 SET y=4 WHERE v1.x=2;
+ SELECT * FROM v1 ORDER by x;
+ }
+} {0 3 1 2 2 4}
+do_test tkt3298-1.4 {
+ execsql {
+ DELETE FROM v1 WHERE x=1;
+ SELECT * FROM v1 ORDER BY x;
+ }
+} {0 3 2 4}
+do_test tkt3298-1.5 {
+ execsql {
+ DELETE FROM v1 WHERE v1.x=2;
+ SELECT * FROM v1 ORDER BY x;
+ }
+} {0 3}
+
+# Ticket #3301
+#
+do_test tkt3298-2.1 {
+ execsql {
+ CREATE TABLE t2(p,q);
+ INSERT INTO t2 VALUES(1,11);
+ INSERT INTO t2 VALUES(2,22);
+ CREATE TABLE t3(x,y);
+ INSERT INTO t3 VALUES(1,'one');
+
+ SELECT *, (SELECT z FROM (SELECT y AS z FROM t3 WHERE x=t1.a+1) ) FROM t1;
+ }
+} {0 2 one}
+
+
+finish_test
diff --git a/test/tkt3334.test b/test/tkt3334.test
new file mode 100644
index 0000000..5473ab4
--- /dev/null
+++ b/test/tkt3334.test
@@ -0,0 +1,84 @@
+# 2008 August 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library.
+# Specifically, it tests that bug #3334 has been fixed by the
+# addition of restriction (19) to the subquery flattener optimization.
+#
+# $Id: tkt3334.test,v 1.1 2008/08/26 12:56:14 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3334-1.0 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,934);
+ INSERT INTO t1 VALUES(2,221);
+ INSERT INTO t1 VALUES(1,372);
+ INSERT INTO t1 VALUES(3,552);
+ INSERT INTO t1 VALUES(1,719);
+ INSERT INTO t1 VALUES(4,102);
+ SELECT * FROM t1 ORDER BY b;
+ }
+} {4 102 2 221 1 372 3 552 1 719 1 934}
+
+do_test tkt3334-1.1 {
+ execsql {
+ SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1;
+ }
+} {}
+do_test tkt3334-1.2 {
+ execsql {
+ SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1;
+ }
+} {0}
+do_test tkt3334-1.3 {
+ execsql {
+ SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1;
+ }
+} {1}
+do_test tkt3334-1.4 {
+ execsql {
+ SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1;
+ }
+} {1}
+do_test tkt3334-1.5 {
+ execsql {
+ SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1;
+ }
+} {1 1 1}
+do_test tkt3334-1.6 {
+ execsql {
+ SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1;
+ }
+} {3}
+do_test tkt3334-1.7 {
+ execsql {
+ SELECT a FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1;
+ }
+} {1 1 1}
+do_test tkt3334-1.8 {
+ execsql {
+ SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1;
+ }
+} {3}
+do_test tkt3334-1.9 {
+ execsql {
+ SELECT a FROM (SELECT a FROM t1) WHERE a=1;
+ }
+} {1 1 1}
+do_test tkt3334-1.10 {
+ execsql {
+ SELECT count(*) FROM (SELECT a FROM t1) WHERE a=1;
+ }
+} {3}
diff --git a/test/tkt3346.test b/test/tkt3346.test
new file mode 100644
index 0000000..806e5e9
--- /dev/null
+++ b/test/tkt3346.test
@@ -0,0 +1,67 @@
+# 2008 September 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the fix for ticket #3346
+#
+# $Id: tkt3346.test,v 1.3 2008/12/09 13:12:57 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3346-1.1 {
+ db eval {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(2,'bob');
+ INSERT INTO t1 VALUES(1,'alice');
+ INSERT INTO t1 VALUES(3,'claire');
+ SELECT *, ( SELECT y FROM (SELECT x.b='alice' AS y) )
+ FROM ( SELECT * FROM t1 ) AS x;
+ }
+} {2 bob 0 1 alice 1 3 claire 0}
+do_test tkt3346-1.2 {
+ db eval {
+ SELECT b FROM (SELECT * FROM t1) AS x
+ WHERE (SELECT y FROM (SELECT x.b='alice' AS y))=0
+ }
+} {bob claire}
+do_test tkt3346-1.3 {
+ db eval {
+ SELECT b FROM (SELECT * FROM t1 ORDER BY a) AS x
+ WHERE (SELECT y FROM (SELECT a||b y FROM t1 WHERE t1.b=x.b))=(x.a||x.b)
+ }
+} {alice bob claire}
+do_test tkt3346-1.4 {
+ db eval {
+ SELECT b FROM (SELECT * FROM t1 ORDER BY a) AS x
+ WHERE (SELECT y FROM (SELECT a||b y FROM t1 WHERE t1.b=x.b))=('2'||x.b)
+ }
+} {bob}
+
+# Ticket #3530
+#
+# As shown by ticket #3346 above (see also ticket #3298) it is important
+# that a subquery in the result-set be able to look up through multiple
+# FROM levels in order to view tables in the FROM clause at the top level.
+#
+# But ticket #3530 shows us that a subquery in the FROM clause should not
+# be able to look up to higher levels:
+#
+do_test tkt3346-2.1 {
+ catchsql {
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(1);
+
+ SELECT * FROM (SELECT * FROM t1 WHERE 1=x.a) AS x;
+ }
+} {1 {no such column: x.a}}
+
+finish_test
diff --git a/test/tkt3357.test b/test/tkt3357.test
new file mode 100644
index 0000000..c3e2a2b
--- /dev/null
+++ b/test/tkt3357.test
@@ -0,0 +1,64 @@
+# 2008 September 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the fix for ticket #3357.
+#
+# $Id: tkt3357.test,v 1.2 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3357-1.1 {
+ execsql {
+ create table a(id integer primary key, b_id integer, myvalue varchar);
+ create table b(id integer primary key, bvalue varchar);
+ insert into a(b_id, myvalue) values(1,'Test');
+ insert into a(b_id, myvalue) values(1,'Test2');
+ insert into a(b_id, myvalue) values(1,'Test3');
+ insert into b(bvalue) values('btest');
+ }
+} {}
+
+do_test tkt3357-1.2 {
+ execsql {
+ SELECT cc.id, cc.b_id, cc.myvalue, dd.bvalue
+ FROM (
+ SELECT DISTINCT a.id, a.b_id, a.myvalue FROM a
+ INNER JOIN b ON a.b_id = b.id WHERE b.bvalue = 'btest'
+ ) cc
+ LEFT OUTER JOIN b dd ON cc.b_id = dd.id
+ }
+} {1 1 Test btest 2 1 Test2 btest 3 1 Test3 btest}
+
+do_test tkt3357-1.3 {
+ execsql {
+ SELECT cc.id, cc.b_id, cc.myvalue
+ FROM (
+ SELECT a.id, a.b_id, a.myvalue
+ FROM a, b WHERE a.b_id = b.id
+ ) cc
+ LEFT OUTER JOIN b dd ON cc.b_id = dd.id
+ }
+} {1 1 Test 2 1 Test2 3 1 Test3}
+
+do_test tkt3357-1.4 {
+ execsql {
+ SELECT cc.id, cc.b_id, cc.myvalue
+ FROM (
+ SELECT DISTINCT a.id, a.b_id, a.myvalue
+ FROM a, b WHERE a.b_id = b.id
+ ) cc
+ LEFT OUTER JOIN b dd ON cc.b_id = dd.id
+ }
+} {1 1 Test 2 1 Test2 3 1 Test3}
+
+finish_test
diff --git a/test/tkt3419.test b/test/tkt3419.test
new file mode 100644
index 0000000..4cfd023
--- /dev/null
+++ b/test/tkt3419.test
@@ -0,0 +1,73 @@
+# 2008 October 06
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the fix for ticket #3419.
+# Ticket #3419 is really a duplication of #3408 and had already
+# been fixed by the time it was reported. But it never hurts to
+# add new test cases.
+#
+# $Id: tkt3419.test,v 1.1 2008/10/06 15:31:13 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3419-1.1 {
+ execsql {
+ create table a(id integer primary key);
+ create table b(id integer primary key, a_id integer);
+ create table c(id integer primary key, b_id integer);
+
+ insert into a values (1);
+ insert into a values (2);
+
+ insert into b values (3, 1);
+ insert into b values (4, 1);
+ insert into b values (5, 1);
+ insert into b values (6, 1);
+ insert into b values (9, 2);
+
+ insert into c values (4, 3);
+ insert into c values (5, 5);
+ insert into c values (6, 4);
+ insert into c values (7, 6);
+ insert into c values (8, 9);
+
+ select * FROM a, b, c WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;
+ }
+} {2 9 2 8 9}
+do_test tkt3419-1.2 {
+ execsql {
+ select * FROM a, c, b WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;
+ }
+} {2 8 9 9 2}
+do_test tkt3419-1.3 {
+ execsql {
+ select * FROM b, a, c WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;
+ }
+} {9 2 2 8 9}
+do_test tkt3419-1.4 {
+ execsql {
+ select * FROM b, c, a WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;
+ }
+} {9 2 8 9 2}
+do_test tkt3419-1.5 {
+ execsql {
+ select * FROM c, a, b WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;
+ }
+} {8 9 2 9 2}
+do_test tkt3419-1.6 {
+ execsql {
+ select * FROM c, b, a WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;
+ }
+} {8 9 9 2 2}
+
+finish_test
diff --git a/test/tkt3424.test b/test/tkt3424.test
new file mode 100644
index 0000000..f38fa5a
--- /dev/null
+++ b/test/tkt3424.test
@@ -0,0 +1,53 @@
+# 2008 October 06
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+#
+# $Id: tkt3424.test,v 1.2 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3424-1.1 {
+ execsql {
+ CREATE TABLE names(id INTEGER, data TEXT, code TEXT);
+ INSERT INTO names VALUES(1,'E1','AAA');
+ INSERT INTO names VALUES(2,NULL,'BBB');
+
+ CREATE TABLE orig(code TEXT, data TEXT);
+ INSERT INTO orig VALUES('AAA','E1');
+ INSERT INTO orig VALUES('AAA','E2');
+ INSERT INTO orig VALUES('AAA','E3');
+ INSERT INTO orig VALUES('AAA','E4');
+ INSERT INTO orig VALUES('AAA','E5');
+ }
+} {}
+
+do_test tkt3424-1.2 {
+ execsql {
+ SELECT * FROM
+ names LEFT OUTER JOIN orig
+ ON names.data = orig.data AND names.code = orig.code;
+ }
+} {1 E1 AAA AAA E1 2 {} BBB {} {}}
+
+do_test tkt3424-1.3 {
+ execsql { CREATE INDEX udx_orig_code_data ON orig(code, data) }
+} {}
+
+do_test tkt3424-1.4 {
+ execsql {
+ SELECT * FROM
+ names LEFT OUTER JOIN orig
+ ON names.data = orig.data AND names.code = orig.code;
+ }
+} {1 E1 AAA AAA E1 2 {} BBB {} {}}
+
+finish_test
diff --git a/test/tkt3442.test b/test/tkt3442.test
new file mode 100644
index 0000000..ae03949
--- /dev/null
+++ b/test/tkt3442.test
@@ -0,0 +1,72 @@
+# 2008 October 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #3442 has been
+# fixed.
+#
+#
+# $Id: tkt3442.test,v 1.2 2009/06/05 17:09:12 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+# Create a schema with some indexes.
+#
+do_test tkt3442-1.1 {
+ execsql {
+ CREATE TABLE listhash(
+ key INTEGER PRIMARY KEY,
+ id TEXT,
+ node INTEGER
+ );
+ CREATE UNIQUE INDEX ididx ON listhash(id);
+ }
+} {}
+
+
+# Explain Query Plan
+#
+proc EQP {sql} {
+ uplevel "execsql {EXPLAIN QUERY PLAN $sql}"
+}
+
+
+# These tests perform an EXPLAIN QUERY PLAN on both versions of the
+# SELECT referenced in ticket #3442 (both '5000' and "5000")
+# and verify that the query plan is the same.
+#
+ifcapable explain {
+ do_test tkt3442-1.2 {
+ EQP { SELECT node FROM listhash WHERE id='5000' LIMIT 1; }
+ } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?) (~1 rows)}}
+ do_test tkt3442-1.3 {
+ EQP { SELECT node FROM listhash WHERE id="5000" LIMIT 1; }
+ } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?) (~1 rows)}}
+}
+
+
+# Some extra tests testing other permutations of 5000.
+#
+ifcapable explain {
+ do_test tkt3442-1.4 {
+ EQP { SELECT node FROM listhash WHERE id=5000 LIMIT 1; }
+ } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?) (~1 rows)}}
+}
+do_test tkt3442-1.5 {
+ catchsql {
+ SELECT node FROM listhash WHERE id=[5000] LIMIT 1;
+ }
+} {1 {no such column: 5000}}
+
+finish_test
diff --git a/test/tkt3457.test b/test/tkt3457.test
new file mode 100644
index 0000000..7b9a1b3
--- /dev/null
+++ b/test/tkt3457.test
@@ -0,0 +1,87 @@
+# 2008 October 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# $Id: tkt3457.test,v 1.3 2009/06/26 07:12:07 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {$tcl_platform(platform) != "unix"} {
+ finish_test
+ return
+}
+
+#-----------------------------------------------------------------------
+# To roll back a hot-journal file, the application needs read and write
+# permission on the journal file in question. The following tests test
+# the outcome of trying to rollback a hot-journal file when this is not
+# the case.
+#
+# tkt3457-1.2: Application has neither read, nor write permission on
+# the hot-journal file. Result: SQLITE_CANTOPEN.
+#
+# tkt3457-1.3: Application has write but not read permission on
+# the hot-journal file. Result: SQLITE_CANTOPEN.
+#
+# tkt3457-1.4: Application has read but not write permission on
+# the hot-journal file. Result: SQLITE_CANTOPEN.
+#
+# tkt3457-1.5: Application has read/write permission on the hot-journal
+# file. Result: SQLITE_OK.
+#
+do_test tkt3457-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ BEGIN;
+ INSERT INTO t1 VALUES(4, 5, 6);
+ }
+
+ forcecopy test.db bak.db
+ forcecopy test.db-journal bak.db-journal
+
+ # Fix the first journal-header in the journal-file. Because the
+ # journal file has not yet been synced, the 8-byte magic string at the
+ # start of the first journal-header has not been written by SQLite.
+ # So write it now.
+ set fd [open bak.db-journal a+]
+ fconfigure $fd -encoding binary -translation binary
+ seek $fd 0
+ puts -nonewline $fd "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7"
+ close $fd
+
+ execsql COMMIT
+} {}
+
+do_test tkt3457-1.2 {
+ forcecopy bak.db-journal test.db-journal
+ file attributes test.db-journal -permissions ---------
+ catchsql { SELECT * FROM t1 }
+} {1 {unable to open database file}}
+do_test tkt3457-1.3 {
+ forcecopy bak.db-journal test.db-journal
+ file attributes test.db-journal -permissions -w--w--w-
+ catchsql { SELECT * FROM t1 }
+} {1 {unable to open database file}}
+do_test tkt3457-1.4 {
+ forcecopy bak.db-journal test.db-journal
+ file attributes test.db-journal -permissions r--r--r--
+ catchsql { SELECT * FROM t1 }
+} {1 {unable to open database file}}
+
+do_test tkt3457-1.5 {
+ forcecopy bak.db-journal test.db-journal
+ file attributes test.db-journal -permissions rw-rw-rw-
+ catchsql { SELECT * FROM t1 }
+} {0 {1 2 3 4 5 6}}
+
+finish_test
diff --git a/test/tkt3461.test b/test/tkt3461.test
new file mode 100644
index 0000000..642980b
--- /dev/null
+++ b/test/tkt3461.test
@@ -0,0 +1,67 @@
+# 2008 October 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #3461 has been
+# fixed.
+#
+# $Id: tkt3461.test,v 1.4 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+####################################
+####################################
+# REMOVE THESE TWO LINES:
+####################################
+####################################
+#finish_test
+#return
+
+do_test tkt3461-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+} {}
+
+do_test tkt3461-1.2 {
+ execsql { SELECT a, b+1 AS b_plus_one FROM t1 WHERE a=1 }
+} {1 3}
+
+do_test tkt3461-1.3 {
+ # explain { SELECT a, b+1 AS b_plus_one FROM t1 WHERE a=1 OR b_plus_one }
+ # execsql { PRAGMA vdbe_trace = 1; PRAGMA vdbe_listing=1 }
+ execsql { SELECT a, b+1 AS b_plus_one FROM t1 WHERE a=1 OR b_plus_one }
+} {1 3}
+
+do_test tkt3461-2.1 {
+ execsql {
+ SELECT a, b+1 AS b_plus_one
+ FROM t1
+ WHERE CASE WHEN a=1 THEN 1 ELSE b_plus_one END
+ }
+} {1 3}
+
+do_test tkt3461-3.1 {
+ execsql {
+ CREATE TABLE t2(c, d);
+ INSERT INTO t2 VALUES(3, 4);
+ }
+ # execsql { PRAGMA vdbe_trace = 1; PRAGMA vdbe_listing=1 }
+ execsql {
+ SELECT a, b+1 AS b_plus_one, c, d
+ FROM t1 LEFT JOIN t2
+ ON (a=c AND d=b_plus_one)
+ }
+} {1 3 {} {}}
+
+finish_test
diff --git a/test/tkt3493.test b/test/tkt3493.test
new file mode 100644
index 0000000..8fe91dd
--- /dev/null
+++ b/test/tkt3493.test
@@ -0,0 +1,153 @@
+# 2008 October 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that affinities and collation sequences are correctly applied
+# in aggregate queries.
+#
+# $Id: tkt3493.test,v 1.2 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3493-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE A (id INTEGER PRIMARY KEY AUTOINCREMENT, val TEXT);
+ INSERT INTO A VALUES(1,'123');
+ INSERT INTO A VALUES(2,'456');
+ CREATE TABLE B (id INTEGER PRIMARY KEY AUTOINCREMENT, val TEXT);
+ INSERT INTO B VALUES(1,1);
+ INSERT INTO B VALUES(2,2);
+ CREATE TABLE A_B (B_id INTEGER NOT NULL, A_id INTEGER);
+ INSERT INTO A_B VALUES(1,1);
+ INSERT INTO A_B VALUES(2,2);
+ COMMIT;
+ }
+} {}
+do_test tkt3493-1.2 {
+ execsql {
+ SELECT
+ CASE
+ WHEN B.val = 1 THEN 'XYZ'
+ ELSE A.val
+ END AS Col1
+ FROM B
+ LEFT OUTER JOIN A_B ON B.id = A_B.B_id
+ LEFT OUTER JOIN A ON A.id = A_B.A_id
+ ORDER BY Col1 ASC;
+ }
+} {456 XYZ}
+do_test tkt3493-1.3 {
+ execsql {
+ SELECT DISTINCT
+ CASE
+ WHEN B.val = 1 THEN 'XYZ'
+ ELSE A.val
+ END AS Col1
+ FROM B
+ LEFT OUTER JOIN A_B ON B.id = A_B.B_id
+ LEFT OUTER JOIN A ON A.id = A_B.A_id
+ ORDER BY Col1 ASC;
+ }
+} {456 XYZ}
+do_test tkt3493-1.4 {
+ execsql {
+ SELECT b.val, CASE WHEN b.val = 1 THEN 'xyz' ELSE b.val END AS col1 FROM b;
+ }
+} {1 xyz 2 2}
+do_test tkt3493-1.5 {
+ execsql {
+ SELECT DISTINCT
+ b.val,
+ CASE WHEN b.val = 1 THEN 'xyz' ELSE b.val END AS col1
+ FROM b;
+ }
+} {1 xyz 2 2}
+do_test tkt3493-1.6 {
+ execsql {
+ SELECT DISTINCT
+ b.val,
+ CASE WHEN b.val = '1' THEN 'xyz' ELSE b.val END AS col1
+ FROM b;
+ }
+} {1 xyz 2 2}
+
+
+do_test tkt3493-2.1 {
+ execsql {
+ CREATE TABLE t1(a TEXT, b INT);
+ INSERT INTO t1 VALUES(123, 456);
+ }
+} {}
+do_test tkt3493-2.2.1 {
+ execsql { SELECT a=123 FROM t1 GROUP BY a }
+} {1}
+do_test tkt3493-2.2.2 {
+ execsql { SELECT a=123 FROM t1 }
+} {1}
+do_test tkt3493-2.2.3 {
+ execsql { SELECT a='123' FROM t1 }
+} {1}
+do_test tkt3493-2.2.4 {
+ execsql { SELECT count(*), a=123 FROM t1 }
+} {1 1}
+do_test tkt3493-2.2.5 {
+ execsql { SELECT count(*), +a=123 FROM t1 }
+} {1 0}
+do_test tkt3493-2.3.3 {
+ execsql { SELECT b='456' FROM t1 GROUP BY a }
+} {1}
+do_test tkt3493-2.3.1 {
+ execsql { SELECT b='456' FROM t1 GROUP BY b }
+} {1}
+do_test tkt3493-2.3.2 {
+ execsql { SELECT b='456' FROM t1 }
+} {1}
+do_test tkt3493-2.4.1 {
+ execsql { SELECT typeof(a), a FROM t1 GROUP BY a HAVING a=123 }
+} {text 123}
+do_test tkt3493-2.4.2 {
+ execsql { SELECT typeof(a), a FROM t1 GROUP BY b HAVING a=123 }
+} {text 123}
+do_test tkt3493-2.5.1 {
+ execsql { SELECT typeof(b), b FROM t1 GROUP BY a HAVING b='456' }
+} {integer 456}
+do_test tkt3493-2.5.2 {
+ execsql { SELECT typeof(b), b FROM t1 GROUP BY b HAVING b='456' }
+} {integer 456}
+
+do_test tkt3493-3.1 {
+ execsql {
+ CREATE TABLE t2(a COLLATE NOCASE, b COLLATE BINARY);
+ INSERT INTO t2 VALUES('aBc', 'DeF');
+ }
+} {}
+do_test tkt3493-3.2.1 {
+ execsql { SELECT a='abc' FROM t2 GROUP BY a }
+} {1}
+do_test tkt3493-3.2.2 {
+ execsql { SELECT a='abc' FROM t2 }
+} {1}
+
+do_test tkt3493-3.3.1 {
+ execsql { SELECT a>b FROM t2 GROUP BY a, b}
+} {0}
+do_test tkt3493-3.3.2 {
+ execsql { SELECT a>b COLLATE BINARY FROM t2 GROUP BY a, b}
+} {1}
+do_test tkt3493-3.3.3 {
+ execsql { SELECT b>a FROM t2 GROUP BY a, b}
+} {0}
+do_test tkt3493-3.3.4 {
+ execsql { SELECT b>a COLLATE NOCASE FROM t2 GROUP BY a, b}
+} {1}
+
+finish_test
diff --git a/test/tkt3508.test b/test/tkt3508.test
new file mode 100644
index 0000000..8275d69
--- /dev/null
+++ b/test/tkt3508.test
@@ -0,0 +1,38 @@
+# 2008 November 22
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# $Id: tkt3508.test,v 1.5 2009/05/28 01:00:56 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3508-1.1 {
+ catchsql {
+ CREATE TABLE modificationsTmp (
+ SUBSTRATE_HPRD_ID VARCHAR(80),
+ SUBSTRATE_GENE_SYMBOL VARCHAR(80),
+ SUBSTRATE_ISOFORM_ID VARCHAR(80),
+ SUBSTRATE_REFSEQ_ID VARCHAR(80),
+ SITE INTEGER,
+ RESIDUE VARCHAR(80),
+ ENZYME_NAME VARCHAR(80),
+ ENZYME_HPRD_ID VARCHAR(80),
+ MODIFICATION_TYPE VARCHAR(80),
+ EXPERIMENT_TYPE VARCHAR(80),
+ REFERENCE_ID VARCHAR(80)
+ );
+ select SUBSTRATE_HPRD_ID, count(substrate_refseq_id) as c
+ from modificationsTmp where c > 1 group by SUBSTRATE_HPRD_ID;
+ }
+} {1 {misuse of aggregate: count()}}
+
+finish_test
diff --git a/test/tkt3522.test b/test/tkt3522.test
new file mode 100644
index 0000000..998d489
--- /dev/null
+++ b/test/tkt3522.test
@@ -0,0 +1,43 @@
+# 2008 December 4
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is a verification that the bugs identified in ticket
+# #3522 have been fixed.
+#
+# $Id: tkt3522.test,v 1.1 2008/12/05 00:00:07 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3522-1.1 {
+ db eval {
+ CREATE TABLE tab4(
+ col0 INTEGER,
+ col1 INTEGER,
+ col2 INTEGER,
+ col3 INTEGER,
+ col4 INTEGER
+ );
+ SELECT cor1.*
+ FROM tab4 AS cor0
+ JOIN tab4 AS cor1 USING ( col4, col3, col2, col1, col0 );
+ }
+} {}
+do_test tkt3522-1.2 {
+ db eval {
+ CREATE TABLE tab1(col0 INTEGER);
+ CREATE TABLE tab2(col0 INTEGER);
+ SELECT cor0.* FROM tab1 NATURAL JOIN tab2 AS cor0;
+ }
+} {}
+
+finish_test
diff --git a/test/tkt3527.test b/test/tkt3527.test
new file mode 100644
index 0000000..34e9e61
--- /dev/null
+++ b/test/tkt3527.test
@@ -0,0 +1,118 @@
+# 2008 December 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is a verification that the bugs identified in ticket
+# #3527 have been fixed.
+#
+# $Id: tkt3527.test,v 1.1 2008/12/08 13:42:36 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3527-1.1 {
+ db eval {
+ CREATE TABLE Element (
+ Code INTEGER PRIMARY KEY,
+ Name VARCHAR(60)
+ );
+
+ CREATE TABLE ElemOr (
+ CodeOr INTEGER NOT NULL,
+ Code INTEGER NOT NULL,
+ PRIMARY KEY(CodeOr,Code)
+ );
+
+ CREATE TABLE ElemAnd (
+ CodeAnd INTEGER,
+ Code INTEGER,
+ Attr1 INTEGER,
+ Attr2 INTEGER,
+ Attr3 INTEGER,
+ PRIMARY KEY(CodeAnd,Code)
+ );
+
+ INSERT INTO Element VALUES(1,'Elem1');
+ INSERT INTO Element VALUES(2,'Elem2');
+ INSERT INTO Element VALUES(3,'Elem3');
+ INSERT INTO Element VALUES(4,'Elem4');
+ INSERT INTO Element VALUES(5,'Elem5');
+ INSERT INTO ElemOr Values(3,4);
+ INSERT INTO ElemOr Values(3,5);
+ INSERT INTO ElemAnd VALUES(1,3,1,1,1);
+ INSERT INTO ElemAnd VALUES(1,2,1,1,1);
+
+ CREATE VIEW ElemView1 AS
+ SELECT
+ CAST(Element.Code AS VARCHAR(50)) AS ElemId,
+ Element.Code AS ElemCode,
+ Element.Name AS ElemName,
+ ElemAnd.Code AS InnerCode,
+ ElemAnd.Attr1 AS Attr1,
+ ElemAnd.Attr2 AS Attr2,
+ ElemAnd.Attr3 AS Attr3,
+ 0 AS Level,
+ 0 AS IsOrElem
+ FROM Element JOIN ElemAnd ON ElemAnd.CodeAnd=Element.Code
+ WHERE ElemAnd.CodeAnd NOT IN (SELECT CodeOr FROM ElemOr)
+ UNION ALL
+ SELECT
+ CAST(ElemOr.CodeOr AS VARCHAR(50)) AS ElemId,
+ Element.Code AS ElemCode,
+ Element.Name AS ElemName,
+ ElemOr.Code AS InnerCode,
+ NULL AS Attr1,
+ NULL AS Attr2,
+ NULL AS Attr3,
+ 0 AS Level,
+ 1 AS IsOrElem
+ FROM ElemOr JOIN Element ON Element.Code=ElemOr.CodeOr
+ ORDER BY ElemId, InnerCode;
+
+ CREATE VIEW ElemView2 AS
+ SELECT
+ ElemId,
+ ElemCode,
+ ElemName,
+ InnerCode,
+ Attr1,
+ Attr2,
+ Attr3,
+ Level,
+ IsOrElem
+ FROM ElemView1
+ UNION ALL
+ SELECT
+ Element.ElemId || '.' || InnerElem.ElemId AS ElemId,
+ InnerElem.ElemCode,
+ InnerElem.ElemName,
+ InnerElem.InnerCode,
+ InnerElem.Attr1,
+ InnerElem.Attr2,
+ InnerElem.Attr3,
+ InnerElem.Level+1,
+ InnerElem.IsOrElem
+ FROM ElemView1 AS Element
+ JOIN ElemView1 AS InnerElem
+ ON Element.Level=0 AND Element.InnerCode=InnerElem.ElemCode
+ ORDER BY ElemId, InnerCode;
+
+ SELECT * FROM ElemView1;
+ }
+} {1 1 Elem1 2 1 1 1 0 0 1 1 Elem1 3 1 1 1 0 0 3 3 Elem3 4 {} {} {} 0 1 3 3 Elem3 5 {} {} {} 0 1}
+
+do_test tkt3527-1.2 {
+ db eval {
+ SELECT * FROM ElemView2;
+ }
+} {1 1 Elem1 2 1 1 1 0 0 1 1 Elem1 3 1 1 1 0 0 1.3 3 Elem3 4 {} {} {} 1 1 1.3 3 Elem3 5 {} {} {} 1 1 3 3 Elem3 4 {} {} {} 0 1 3 3 Elem3 5 {} {} {} 0 1}
+
+finish_test
diff --git a/test/tkt3541.test b/test/tkt3541.test
new file mode 100644
index 0000000..f0597cf
--- /dev/null
+++ b/test/tkt3541.test
@@ -0,0 +1,35 @@
+# 2008 December 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file is a verification that the bugs identified in ticket
+# #3541 have been fixed.
+#
+# $Id: tkt3541.test,v 1.1 2008/12/15 15:27:52 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3541-1.1 {
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(123);
+ SELECT CASE ~max(x) WHEN min(x) THEN 1 ELSE max(x) END FROM t1;
+ }
+} {123}
+do_test tkt3541-1.2 {
+ db eval {
+ SELECT CASE NOT max(x) WHEN min(x) THEN 1 ELSE max(x) END FROM t1;
+ }
+} {123}
+
+
+finish_test
diff --git a/test/tkt3554.test b/test/tkt3554.test
new file mode 100644
index 0000000..a059486
--- /dev/null
+++ b/test/tkt3554.test
@@ -0,0 +1,67 @@
+# 2008 December 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #3554 has been
+# fixed.
+#
+# $Id: tkt3554.test,v 1.2 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !trigger {
+ finish_test
+ return
+}
+
+do_test tkt3544-1.1 {
+ execsql {
+ CREATE TABLE test ( obj, t1, t2, PRIMARY KEY(obj, t1, t2) );
+
+ CREATE TRIGGER test_insert BEFORE INSERT ON test BEGIN
+ UPDATE test SET t1 = new.t1
+ WHERE obj = new.obj AND new.t1 < t1 AND new.t2 >= t1;
+
+ UPDATE test SET t2 = new.t2
+ WHERE obj = new.obj AND new.t2 > t2 AND new.t1 <= t2;
+
+ SELECT RAISE(IGNORE) WHERE EXISTS (
+ SELECT obj FROM test
+ WHERE obj = new.obj AND new.t1 >= t1 AND new.t2 <= t2
+ );
+ END;
+ }
+} {}
+
+do_test tkt3544-1.2 {
+ execsql {
+ INSERT INTO test VALUES('a', 10000, 11000);
+ SELECT * FROM test;
+ }
+} {a 10000 11000}
+
+
+do_test tkt3544-1.3 {
+ execsql {
+ INSERT INTO test VALUES('a', 9000, 10500);
+ }
+ execsql { SELECT * FROM test }
+} {a 9000 11000}
+
+do_test tkt3544-1.4 {
+ execsql {
+ INSERT INTO test VALUES('a', 10000, 12000);
+ }
+ execsql { SELECT * FROM test }
+} {a 9000 12000}
+
+finish_test
diff --git a/test/tkt3581.test b/test/tkt3581.test
new file mode 100644
index 0000000..e9b18fd
--- /dev/null
+++ b/test/tkt3581.test
@@ -0,0 +1,54 @@
+# 2008 January 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #3581 has been
+# fixed.
+#
+# $Id: tkt3581.test,v 1.1 2009/01/14 01:10:40 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3581-1.1 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ INSERT INTO t1 VALUES(0,544,846);
+ INSERT INTO t1 VALUES(1,345,51);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);
+ INSERT INTO t2 SELECT * FROM t1;
+ CREATE INDEX i2 on t2(c);
+ }
+} {}
+
+do_test tkt3581-1.2 {
+ db eval {
+ SELECT a FROM t1
+ WHERE (b > 45 AND c < 356)
+ OR b <= 733
+ OR b >= 557
+ OR (b >= 614 AND c < 251)
+ ORDER BY b;
+ }
+} {1 0}
+
+do_test tkt3581-1.3 {
+ db eval {
+ SELECT a FROM t2
+ WHERE (b > 45 AND c < 356)
+ OR b <= 733
+ OR b >= 557
+ OR (b >= 614 AND c < 251)
+ ORDER BY b;
+ }
+} {1 0}
+
+finish_test
diff --git a/test/tkt35xx.test b/test/tkt35xx.test
new file mode 100644
index 0000000..f9d10c3
--- /dev/null
+++ b/test/tkt35xx.test
@@ -0,0 +1,102 @@
+# 2008 November 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# When a transaction rolls back, make sure that dirty pages in the
+# page cache which are not in the rollback journal are reinitialized
+# in the btree layer.
+#
+# $Id: tkt35xx.test,v 1.4 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt35xx-1.1 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ }
+} {}
+
+# Trigger the problem using explicit rollback.
+#
+do_test tkt35xx-1.1 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX i1 ON t1(c);
+ INSERT INTO t1 VALUES(0, 0, zeroblob(676));
+ INSERT INTO t1 VALUES(1, 1, zeroblob(676));
+ DELETE FROM t1;
+ BEGIN;
+ INSERT INTO t1 VALUES(0, 0, zeroblob(676));
+ INSERT INTO t1 VALUES(1, 1, zeroblob(676));
+ ROLLBACK;
+ INSERT INTO t1 VALUES(0, 0, zeroblob(676));
+ }
+ execsql {
+ INSERT INTO t1 VALUES(1, 1, zeroblob(676));
+ }
+} {}
+
+# Trigger the problem using statement rollback.
+#
+db close
+delete_file test.db
+sqlite3 db test.db
+set big [string repeat abcdefghij 22] ;# 220 byte string
+do_test tkt35xx-1.2.1 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t3 VALUES(1, $big);
+ INSERT INTO t3 VALUES(2, $big);
+ INSERT INTO t3 VALUES(3, $big);
+ INSERT INTO t3 VALUES(4, $big);
+ CREATE TABLE t4(c, d);
+ INSERT INTO t4 VALUES(5, $big);
+ INSERT INTO t4 VALUES(1, $big);
+ }
+} {}
+do_test tkt35xx-1.2.2 {
+ catchsql {
+ BEGIN;
+ CREATE TABLE t5(e PRIMARY KEY, f);
+ DROP TABLE t5;
+ INSERT INTO t3(a, b) SELECT c, d FROM t4;
+ }
+} {1 {PRIMARY KEY must be unique}}
+do_test tkt35xx-1.2.3 {
+ # Show that the transaction has not been rolled back.
+ catchsql BEGIN
+} {1 {cannot start a transaction within a transaction}}
+do_test tkt35xx-1.2.4 {
+ execsql { SELECT count(*) FROM t3 }
+} {4}
+do_test tkt35xx-1.2.5 {
+ # Before the bug was fixed, if SQLITE_DEBUG was defined an assert()
+ # would fail during the following INSERT statement. If SQLITE_DEBUG
+ # was not defined, then the statement would pass and the transaction
+ # would be committed. But, the "SELECT count(*)" in tkt35xx-1.2.6 would
+ # return 1, not 5. Data magically disappeared!
+ #
+ execsql {
+ INSERT INTO t3 VALUES(5, $big);
+ COMMIT;
+ }
+} {}
+do_test tkt35xx-1.2.6 {
+ execsql { SELECT count(*) FROM t3 }
+} {5}
+integrity_check tkt35xx-1.2.7
+
+finish_test
diff --git a/test/tkt3630.test b/test/tkt3630.test
new file mode 100644
index 0000000..b329c48
--- /dev/null
+++ b/test/tkt3630.test
@@ -0,0 +1,47 @@
+# 2009 February 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+#
+# This file checks to make sure the "TEMP" or "TEMPORARY" keyword is
+# omitted from the schema of a table that is created using that
+# keyword. Ticket #3630.
+#
+# $Id: tkt3630.test,v 1.1 2009/02/02 18:03:22 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+
+source $testdir/tester.tcl
+
+do_test tkt3630-1 {
+ db eval {
+ CREATE TEMP TABLE temp1(a,b,c);
+ SELECT * FROM sqlite_temp_master WHERE sql GLOB '*TEMP*';
+ }
+} {}
+do_test tkt3630-2 {
+ db eval {
+ CREATE TABLE main1(a,b,c);
+ CREATE TEMP TABLE temp2 AS SELECT * FROM main1;
+ SELECT * FROM sqlite_temp_master WHERE sql GLOB '*TEMP*';
+ }
+} {}
+
+ifcapable altertable {
+ do_test tkt3630-3 {
+ db eval {
+ ALTER TABLE temp2 ADD COLUMN d;
+ ALTER TABLE temp2 RENAME TO temp2rn;
+ SELECT name FROM sqlite_temp_master WHERE name LIKE 'temp2%';
+ }
+ } {temp2rn}
+}
+
+finish_test
diff --git a/test/tkt3718.test b/test/tkt3718.test
new file mode 100644
index 0000000..e5eb247
--- /dev/null
+++ b/test/tkt3718.test
@@ -0,0 +1,230 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the execution of SQL statements from
+# within callbacks generated by VMs that themselves open statement
+# transactions.
+#
+# $Id: tkt3718.test,v 1.2 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3718-1.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+ INSERT INTO t1 VALUES(4, 'four');
+ INSERT INTO t1 VALUES(5, 'five');
+ CREATE TABLE t2(a PRIMARY KEY, b);
+ }
+} {}
+
+# SQL scalar function:
+#
+# f1(<arg>)
+#
+# Uses database handle [db] to execute "SELECT f2(<arg>)". Returns either
+# the results or error message from the "SELECT f2(<arg>)" query to the
+# caller.
+#
+proc f1 {args} {
+ set a [lindex $args 0]
+ catch { db eval {SELECT f2($a)} } msg
+ set msg
+}
+
+# SQL scalar function:
+#
+# f2(<arg>)
+#
+# Return the value of <arg>. Unless <arg> is "three", in which case throw
+# an exception.
+#
+proc f2 {args} {
+ set a [lindex $args 0]
+ if {$a == "three"} { error "Three!!" }
+ return $a
+}
+
+db func f1 f1
+db func f2 f2
+
+# The second INSERT statement below uses the f1 user function such that
+# half-way through the INSERT operation f1() will run an SQL statement
+# that throws an exception. At one point, before #3718 was fixed, this
+# caused the statement transaction belonging to the INSERT statement to
+# be rolled back. The result was that some (but not all) of the rows that
+# should have been inserted went missing.
+#
+do_test tkt3718-1.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO t2 SELECT a, b FROM t1;
+ INSERT INTO t2 SELECT a+5, f1(b) FROM t1;
+ COMMIT;
+ }
+ execsql {
+ SELECT a FROM t2;
+ }
+} {1 2 3 4 5 6 7 8 9 10}
+
+# This test turns on the count_changes pragma (causing DML statements to
+# return SQLITE_ROW once, with a single integer result value reporting the
+# number of rows affected by the statement). It then executes an INSERT
+# statement that requires a statement journal. After stepping the statement
+# once, so that it returns SQLITE_ROW, a second SQL statement that throws an
+# exception is run. At one point, before #3718 was fixed, this caused the
+# statement transaction belonging to the INSERT statement to be rolled back.
+# The result was that none of the rows were actually inserted.
+#
+#
+do_test tkt3718-1.3 {
+ execsql {
+ DELETE FROM t2 WHERE a > 5;
+ PRAGMA count_changes = 1;
+ BEGIN;
+ }
+ db eval {INSERT INTO t2 SELECT a+5, b||'+5' FROM t1} {
+ catch { db eval {SELECT f2('three')} } msg
+ }
+ execsql {
+ COMMIT;
+ SELECT a FROM t2;
+ }
+} {1 2 3 4 5 6 7 8 9 10}
+
+do_test tkt3718-1.4 {
+ execsql {pragma count_changes=0}
+} {}
+
+# This SQL function executes the SQL specified as an argument against
+# database [db].
+#
+proc sql {doit zSql} {
+ if {$doit} { catchsql $zSql }
+}
+db func sql [list sql]
+
+# The following tests, tkt3718-2.*, test that a nested statement
+# transaction can be successfully committed or reverted without
+# affecting the parent statement transaction.
+#
+do_test tkt3718-2.1 {
+ execsql { SELECT sql(1, 'DELETE FROM t2 WHERE a = '||a ) FROM t2 WHERE a>5 }
+ execsql { SELECT a from t2 }
+} {1 2 3 4 5}
+do_test tkt3718-2.2 {
+ execsql {
+ DELETE FROM t2 WHERE a > 5;
+ BEGIN;
+ INSERT INTO t2 SELECT a+5, sql(a==3,
+ 'INSERT INTO t2 SELECT a+10, f2(b) FROM t1'
+ ) FROM t1;
+ }
+ execsql {
+ COMMIT;
+ SELECT a FROM t2;
+ }
+} {1 2 3 4 5 6 7 8 9 10}
+do_test tkt3718-2.3 {
+ execsql {
+ DELETE FROM t2 WHERE a > 5;
+ BEGIN;
+ INSERT INTO t2 SELECT a+5, sql(a==3,
+ 'INSERT INTO t2 SELECT a+10, b FROM t1'
+ ) FROM t1;
+ COMMIT;
+ }
+ execsql { SELECT a FROM t2 ORDER BY a+0}
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}
+integrity_check tkt3718.2-4
+
+# The next set of tests, tkt3718-3.*, test that a statement transaction
+# that has a committed statement transaction nested inside of it can
+# be committed or reverted.
+#
+foreach {tn io ii results} {
+ 1 0 10 {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
+ 2 1 10 {6 7 8 9 10 16 17 18 19 20}
+ 3 0 11 {1 2 3 4 5 6 7 8 9 10 16 17 18 19 20}
+ 4 1 11 {6 7 8 9 10 16 17 18 19 20}
+} {
+ do_test tkt3718-3.$tn {
+ execsql {
+ DELETE FROM t2;
+ INSERT INTO t2 SELECT a+5, b FROM t1;
+ INSERT INTO t2 SELECT a+15, b FROM t1;
+ }
+
+ catchsql "
+ BEGIN;
+ INSERT INTO t2 SELECT a+$io, sql(a==3,
+ 'INSERT INTO t2 SELECT a+$ii, b FROM t1'
+ ) FROM t1;
+ "
+
+ execsql { COMMIT }
+
+ execsql { SELECT a FROM t2 ORDER BY a+0}
+ } $results
+
+ integrity_check tkt3718-3.$tn.integrity
+}
+
+# This is the same test as tkt3718-3.*, but with 3 levels of nesting.
+#
+foreach {tn i1 i2 i3 results} {
+ 1 0 10 20 {5 10 15 20 25 30}
+ 2 0 10 21 {5 10 15 20 30}
+ 3 0 11 20 {5 10 20 30}
+ 4 0 11 21 {5 10 20 30}
+ 5 1 10 20 {10 20 30}
+ 6 1 10 21 {10 20 30}
+ 7 1 11 20 {10 20 30}
+ 8 1 11 21 {10 20 30}
+} {
+ do_test tkt3718-4.$tn {
+ execsql {
+ DELETE FROM t2;
+ INSERT INTO t2 SELECT a+5, b FROM t1;
+ INSERT INTO t2 SELECT a+15, b FROM t1;
+ INSERT INTO t2 SELECT a+25, b FROM t1;
+ }
+
+ catchsql "
+ BEGIN;
+ INSERT INTO t2 SELECT a+$i1, sql(a==3,
+ 'INSERT INTO t2 SELECT a+$i2, sql(a==3,
+ ''INSERT INTO t2 SELECT a+$i3, b FROM t1''
+ ) FROM t1'
+ ) FROM t1;
+ "
+
+ execsql { COMMIT }
+
+ execsql { SELECT a FROM t2 WHERE (a%5)==0 ORDER BY a+0}
+ } $results
+
+ do_test tkt3718-4.$tn.extra {
+ execsql {
+ SELECT
+ (SELECT sum(a) FROM t2)==(SELECT sum(a*5-10) FROM t2 WHERE (a%5)==0)
+ }
+ } {1}
+
+ integrity_check tkt3718-4.$tn.integrity
+}
+
+
+finish_test
diff --git a/test/tkt3731.test b/test/tkt3731.test
new file mode 100644
index 0000000..11e5efd
--- /dev/null
+++ b/test/tkt3731.test
@@ -0,0 +1,56 @@
+# 2009 March 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: tkt3731.test,v 1.1 2009/03/17 22:33:01 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# The tests in this file were written before SQLite supported recursive
+# trigger invocation, and some tests depend on that to pass. So disable
+# recursive triggers for this file.
+catchsql { pragma recursive_triggers = off }
+
+do_test tkt3731-1.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t1 VALUES(new.a || '+', new.b || '+');
+ END;
+ }
+} {}
+
+do_test tkt3731-1.2 {
+ execsql {
+ INSERT INTO t1 VALUES('a', 'b');
+ INSERT INTO t1 VALUES('c', 'd');
+ SELECT * FROM t1;
+ }
+} {a b a+ b+ c d c+ d+}
+
+do_test tkt3731-1.3 {
+ execsql {
+ DELETE FROM t1;
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES('e', 'f');
+ INSERT INTO t2 VALUES('g', 'h');
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+ }
+} {e f e+ f+ g h g+ h+}
+
+integrity_check tkt3731-1.4
+
+finish_test
diff --git a/test/tkt3757.test b/test/tkt3757.test
new file mode 100644
index 0000000..011beb5
--- /dev/null
+++ b/test/tkt3757.test
@@ -0,0 +1,60 @@
+# 2009 March 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3757: The cost functions on the query optimizer for the
+# IN operator can be improved.
+#
+# $Id: tkt3757.test,v 1.1 2009/03/29 00:13:04 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Evaluate SQL. Return the result set followed by the
+# and the number of full-scan steps.
+#
+proc count_steps {sql} {
+ set r [db eval $sql]
+ lappend r scan [db status step] sort [db status sort]
+}
+
+# Construct tables
+#
+do_test tkt3757-1.1 {
+ db eval {
+ CREATE TABLE t1(x INTEGER, y INTEGER, z TEXT);
+ CREATE INDEX t1i1 ON t1(y,z);
+ INSERT INTO t1 VALUES(1,2,'three');
+ CREATE TABLE t2(a INTEGER, b TEXT);
+ INSERT INTO t2 VALUES(2, 'two');
+ ANALYZE;
+ SELECT * FROM sqlite_stat1 ORDER BY 1, 2;
+ }
+} {t1 t1i1 {1 1 1} t2 {} 1}
+
+# Modify statistics in order to make the optimizer then that:
+#
+# (1) Table T1 has about 250K entries
+# (2) There are only about 5 distinct values of T1.
+#
+# Then run a query with "t1.y IN (SELECT ..)" in the WHERE clause.
+# Make sure the index is used.
+#
+do_test tkt3757-1.2 {
+ db eval {
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1i1','250000 50000 30');
+ }
+ count_steps {
+ SELECT * FROM t1 WHERE y IN (SELECT a FROM t2)
+ }
+} {1 2 three scan 0 sort 0}
+
+finish_test
diff --git a/test/tkt3761.test b/test/tkt3761.test
new file mode 100644
index 0000000..2601b15
--- /dev/null
+++ b/test/tkt3761.test
@@ -0,0 +1,40 @@
+# 2009 March 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3761: Make sure that an incremental vacuum on an in-memory
+# database can be rolled back.
+#
+# $Id: tkt3761.test,v 1.1 2009/03/31 02:54:40 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3761-1.1 {
+ db close
+ sqlite3 db :memory:
+ db eval {
+ PRAGMA auto_vacuum=INCREMENTAL;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(zeroblob(900));
+ INSERT INTO t1 VALUES(zeroblob(900));
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ BEGIN;
+ DELETE FROM t1 WHERE rowid%2;
+ PRAGMA incremental_vacuum(4);
+ ROLLBACK;
+ }
+ db eval {PRAGMA integrity_check}
+} {ok}
+
+finish_test
diff --git a/test/tkt3762.test b/test/tkt3762.test
new file mode 100644
index 0000000..c24041c
--- /dev/null
+++ b/test/tkt3762.test
@@ -0,0 +1,54 @@
+# 2009 March 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3762: Make sure that an incremental vacuum that reduces the
+# size of the database file such that a pointer-map page is elemented
+# can be correctly rolled back.
+#
+# That ticket #3762 has been fixed has already been verified by the
+# savepoint6.test test script. But this script is simplier and a
+# redundant test never hurts.
+#
+# $Id: tkt3762.test,v 1.1 2009/03/31 00:50:36 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3762-1.1 {
+ db eval {
+ PRAGMA auto_vacuum=INCREMENTAL;
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=10;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(zeroblob(900));
+ INSERT INTO t1 VALUES(zeroblob(900));
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ INSERT INTO t1 SELECT x FROM t1;
+ DELETE FROM t1 WHERE rowid>202;
+ VACUUM;
+
+ BEGIN;
+ DELETE FROM t1 WHERE rowid IN (10,11,12) ;
+ PRAGMA incremental_vacuum(10);
+ UPDATE t1 SET x=zeroblob(900) WHERE rowid BETWEEN 100 AND 110;
+ INSERT INTO t1 VALUES(zeroblob(39000));
+ SELECT count(*) FROM t1;
+ ROLLBACK;
+ }
+ db eval {PRAGMA integrity_check}
+} {ok}
+
+finish_test
diff --git a/test/tkt3773.test b/test/tkt3773.test
new file mode 100644
index 0000000..0dc414e
--- /dev/null
+++ b/test/tkt3773.test
@@ -0,0 +1,38 @@
+# 2009 April 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3773: Be careful not to over-optimize when a compound
+# subquery contains an ORDER BY clause.
+#
+#
+# $Id: tkt3773.test,v 1.1 2009/04/02 16:59:47 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3773-1.1 {
+ db eval {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(2,1);
+ INSERT INTO t1 VALUES(33,3);
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(123,2);
+ INSERT INTO t2 VALUES(4,4);
+ SELECT a FROM (
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT x, y FROM t2
+ ORDER BY 2
+ );
+ }
+} {2 123 33 4}
+
+finish_test
diff --git a/test/tkt3791.test b/test/tkt3791.test
new file mode 100644
index 0000000..5d676ca
--- /dev/null
+++ b/test/tkt3791.test
@@ -0,0 +1,28 @@
+# 2009 April 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3791: A segfault when inserting into a table that contains
+# an arbitrary expression as its default value.
+#
+# $Id: tkt3791.test,v 1.1 2009/04/08 12:21:31 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3791-1.1 {
+ db eval {
+ CREATE TABLE t1(x, y DEFAULT(datetime('now')));
+ INSERT INTO t1(x) VALUES(1);
+ SELECT x, length(y) FROM t1;
+ }
+} {1 19}
+
+finish_test
diff --git a/test/tkt3793.test b/test/tkt3793.test
new file mode 100644
index 0000000..074aab2
--- /dev/null
+++ b/test/tkt3793.test
@@ -0,0 +1,121 @@
+# 2009 April 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #3793 has been
+# fixed.
+#
+# $Id: tkt3793.test,v 1.2 2009/06/01 16:42:18 shane Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !shared_cache||!attach {
+ finish_test
+ return
+}
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+do_test tkt3793-1.1 {
+ # This is taken from shared.test. The Windows VFS expands
+ # ./test.db (and test.db) to be the same thing so the path
+ # matches and they share a cache. By changing the case
+ # for Windows platform, we get around this and get a separate
+ # connection.
+ if {$::tcl_platform(platform)=="unix"} {
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+ } else {
+ sqlite3 db1 TEST.DB
+ sqlite3 db2 TEST.DB
+ }
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
+ INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;
+ INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;
+ INSERT INTO t2 SELECT * FROM t1;
+ COMMIT;
+ }
+} {}
+
+proc busyhandler {db args} { set ::busyconnection $db ; return 1 }
+db2 busy {busyhandler db2}
+db1 busy {busyhandler db1}
+
+# Establish a read-lock on the database file using connection [db].
+#
+do_test tkt3793-1.2 {
+ execsql {
+ BEGIN;
+ SELECT count(*) FROM t1;
+ }
+} {1024}
+
+# Set the size of the cache shared by [db1] and [db2] to 10. Then update
+# more than 10 pages of table t1. At this point the shared-cache will
+# hold a RESERVED lock on the database file. Even though there are now
+# more than 10 dirty pages in memory, it cannot upgrade to an EXCLUSIVE
+# lock because of the read-lock held by [db].
+#
+do_test tkt3793-1.3 {
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ UPDATE t1 SET b = randstr(50,50);
+ } db1
+} {}
+
+set x 0
+
+# Run one SELECT query on the shared-cache using [db1], then from within
+# the callback run another via [db2]. Because of the large number of dirty
+# pages within the cache, each time a new page is read from the database
+# SQLite will attempt to upgrade to an EXCLUSIVE lock, and hence invoke
+# the busy-handler. The tests here verify that the correct busy-handler
+# function is invoked (the busy-handler associated with the database
+# connection that called sqlite3_step()). When bug #3793 existed, sometimes
+# the [db2] busy-handler was invoked from within the call to sqlite3_step()
+# associated with [db1].
+#
+# Note: Before the bug was fixed, if [db2] was opened with the "-fullmutex 1"
+# option, then this test case would cause an assert() to fail.
+#
+ifcapable threadsafe {
+ set ::busyconnection db1
+ db1 eval {SELECT * FROM t2 ORDER BY a LIMIT 20} {
+ do_test tkt3793-2.[incr x] { set ::busyconnection } db1
+ set ::busyconnection db2
+
+ db2 eval { SELECT count(*) FROM t2 }
+ do_test tkt3793-2.[incr x] { set ::busyconnection } db2
+ set ::busyconnection db1
+ }
+}
+
+do_test tkt3793-3 {
+ db1 close
+ db2 close
+} {}
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/tkt3810.test b/test/tkt3810.test
new file mode 100644
index 0000000..7e1b2ec
--- /dev/null
+++ b/test/tkt3810.test
@@ -0,0 +1,87 @@
+# 2009 August 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests to make sure #3810 is fixed.
+#
+# $Id: tkt3810.test,v 1.4 2009/08/06 17:43:31 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# Create a table using the first database connection.
+#
+do_test tkt3810-1.1 {
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(123);
+ SELECT * FROM t1;
+ CREATE TABLE t2(y);
+ CREATE TABLE t3(z);
+ }
+} 123
+
+# Create a second connection to the same database. Make sure the
+# schema of the database has been parsed by the second connection.
+#
+do_test tkt3810-2 {
+ sqlite3 db2 test.db
+ execsql {
+ SELECT * FROM t1;
+ } db2
+} 123
+
+# DROP the table using the second connection. The table no longer exists
+# but the first connection does not yet know this. Then try to create a TEMP
+# trigger in the first connection that references the table that was dropped.
+#
+do_test tkt3810-3 {
+ execsql {DROP TABLE t1} db2
+ execsql {
+ CREATE TEMP TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(new.rowid);
+ END;
+ }
+ catchsql {
+ SELECT * FROM t3;
+ }
+} {0 {}}
+
+# Trigger still exists in the sqlite_temp_master table, but now it is
+# an orphan.
+#
+do_test tkt3810-4 {
+ execsql {SELECT name FROM sqlite_temp_master ORDER BY name}
+} {r1}
+
+# Because it is an orphan, it cannot be dropped.
+#
+do_test tkt3810-5 {
+ catchsql {DROP TRIGGER r1}
+} {1 {no such trigger: r1}}
+
+# Create a table t1 then drop the table in order to drop the orphaned
+# trigger.
+#
+do_test tkt3810-6 {
+ execsql {CREATE TABLE t1(x)} db2
+ execsql {DROP TABLE t1}
+ execsql {
+ SELECT name FROM sqlite_temp_master;
+ }
+} {}
+
+db2 close
+
+finish_test
diff --git a/test/tkt3824.test b/test/tkt3824.test
new file mode 100644
index 0000000..3198abb
--- /dev/null
+++ b/test/tkt3824.test
@@ -0,0 +1,99 @@
+# 2009 April 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3824
+#
+# When you use an "IS NULL" constraint on a UNIQUE index, the result
+# is not necessarily UNIQUE. Make sure the optimizer does not assume
+# uniqueness.
+#
+# $Id: tkt3824.test,v 1.2 2009/04/24 20:32:31 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc execsql_status {sql {db db}} {
+ set result [uplevel $db eval [list $sql]]
+ if {[db status sort]} {
+ concat $result sort
+ } else {
+ concat $result nosort
+ }
+}
+
+do_test tkt3824-1.1 {
+ db eval {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,NULL);
+ INSERT INTO t1 VALUES(9,NULL);
+ INSERT INTO t1 VALUES(5,NULL);
+ INSERT INTO t1 VALUES(123,NULL);
+ INSERT INTO t1 VALUES(-10,NULL);
+ CREATE UNIQUE INDEX t1b ON t1(b);
+ }
+ execsql_status {
+ SELECT a FROM t1 WHERE b IS NULL ORDER BY a;
+ }
+} {-10 1 5 9 123 sort}
+do_test tkt3824-1.2 {
+ execsql_status {
+ SELECT a FROM t1 WHERE b IS NULL ORDER BY b, a;
+ }
+} {-10 1 5 9 123 sort}
+
+do_test tkt3824-2.1 {
+ db eval {
+ CREATE TABLE t2(a,b,c);
+ INSERT INTO t2 VALUES(1,1,NULL);
+ INSERT INTO t2 VALUES(9,2,NULL);
+ INSERT INTO t2 VALUES(5,2,NULL);
+ INSERT INTO t2 VALUES(123,3,NULL);
+ INSERT INTO t2 VALUES(-10,3,NULL);
+ CREATE UNIQUE INDEX t2bc ON t2(b,c);
+ }
+ execsql_status {
+ SELECT a FROM t2 WHERE b=2 AND c IS NULL ORDER BY a;
+ }
+} {5 9 sort}
+do_test tkt3824-2.2 {
+ execsql_status {
+ SELECT a FROM t2 WHERE b=2 AND c IS NULL ORDER BY b, a;
+ }
+} {5 9 sort}
+do_test tkt3824-2.3 {
+ lsort [execsql_status {
+ SELECT a FROM t2 WHERE b=2 AND c IS NULL ORDER BY b;
+ }]
+} {5 9 nosort}
+
+do_test tkt3824-3.1 {
+ db eval {
+ CREATE TABLE t3(x,y);
+ INSERT INTO t3 SELECT a, b FROM t1;
+ INSERT INTO t3 VALUES(234,567);
+ CREATE UNIQUE INDEX t3y ON t3(y);
+ DELETE FROM t3 WHERE y IS NULL;
+ SELECT * FROM t3;
+ }
+} {234 567}
+
+do_test tkt3824-4.1 {
+ db eval {
+ CREATE TABLE t4(x,y);
+ INSERT INTO t4 SELECT a, b FROM t1;
+ INSERT INTO t4 VALUES(234,567);
+ CREATE UNIQUE INDEX t4y ON t4(y);
+ UPDATE t4 SET rowid=rowid+100 WHERE y IS NULL;
+ SELECT rowid, x FROM t4 ORDER BY rowid;
+ }
+} {6 234 101 1 102 9 103 5 104 123 105 -10}
+
+finish_test
diff --git a/test/tkt3832.test b/test/tkt3832.test
new file mode 100644
index 0000000..bb73c8c
--- /dev/null
+++ b/test/tkt3832.test
@@ -0,0 +1,41 @@
+# 2009 April 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3832
+#
+# A segfault when using a BEFORE trigger on an INSERT and inserting
+# a NULL into the INTEGER PRIMARY KEY.
+#
+# $Id: tkt3832.test,v 1.1 2009/05/01 02:08:04 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+
+do_test tkt3832-1.1 {
+ db eval {
+ CREATE TABLE t1(a INT, b INTEGER PRIMARY KEY);
+ CREATE TABLE log(x);
+ CREATE TRIGGER t1r1 BEFORE INSERT ON t1 BEGIN
+ INSERT INTO log VALUES(new.b);
+ END;
+ INSERT INTO t1 VALUES(NULL,5);
+ INSERT INTO t1 SELECT b, a FROM t1 ORDER BY b;
+ SELECT rowid, * FROM t1;
+ SELECT rowid, * FROM log;
+ }
+} {5 {} 5 6 5 6 1 5 2 -1}
+
+finish_test
diff --git a/test/tkt3838.test b/test/tkt3838.test
new file mode 100644
index 0000000..5dfc2b8
--- /dev/null
+++ b/test/tkt3838.test
@@ -0,0 +1,41 @@
+# 2009 May 5
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3838
+#
+# The ticket reports that the encoding is UTF8 on the DEFAULT VALUE of
+# a column added using ALTER TABLE even when the database is UTF16.
+# Verify that this has been fixed.
+#
+# $Id: tkt3838.test,v 1.1 2009/05/05 12:54:50 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+do_realnum_test tkt3838-1.1 {
+ db eval {
+ PRAGMA encoding=UTF16;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ ALTER TABLE t1 ADD COLUMN b INTEGER DEFAULT '999';
+ ALTER TABLE t1 ADD COLUMN c REAL DEFAULT '9e99';
+ ALTER TABLE t1 ADD COLUMN d TEXT DEFAULT 'xyzzy';
+ UPDATE t1 SET x=x+1;
+ SELECT * FROM t1;
+ }
+} {2 999 9e+99 xyzzy}
+
+finish_test
diff --git a/test/tkt3841.test b/test/tkt3841.test
new file mode 100644
index 0000000..df6de5c
--- /dev/null
+++ b/test/tkt3841.test
@@ -0,0 +1,48 @@
+# 2009 May 7
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Ticket #3841
+#
+# The sqlite3_aggregate_count() is not being reset when an aggregate
+# functio is used in a correlated subquery.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !subquery {
+ finish_test
+ return
+}
+
+do_test tkt3841.1 {
+ execsql {
+ CREATE TABLE table2 (key TEXT, x TEXT);
+ CREATE TABLE list (key TEXT, value TEXT);
+
+ INSERT INTO table2 VALUES ("a", "alist");
+ INSERT INTO table2 VALUES ("b", "blist");
+ INSERT INTO list VALUES ("a", 1);
+ INSERT INTO list VALUES ("a", 2);
+ INSERT INTO list VALUES ("a", 3);
+ INSERT INTO list VALUES ("b", 4);
+ INSERT INTO list VALUES ("b", 5);
+ INSERT INTO list VALUES ("b", 6);
+
+ SELECT
+ table2.x,
+ (SELECT group_concat(list.value)
+ FROM list
+ WHERE list.key = table2.key)
+ FROM table2;
+ }
+} {alist 1,2,3 blist 4,5,6}
+
+finish_test
diff --git a/test/tkt3871.test b/test/tkt3871.test
new file mode 100644
index 0000000..e7dbfde
--- /dev/null
+++ b/test/tkt3871.test
@@ -0,0 +1,53 @@
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_echo_module [sqlite3_connection_pointer db]
+
+do_test tkt3871-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ }
+ for {set i 0} {$i < 500} {incr i} {
+ execsql { INSERT INTO t1 VALUES($i, $i*$i) }
+ }
+ execsql COMMIT
+ execsql {
+ CREATE VIRTUAL TABLE e USING echo(t1);
+ SELECT count(*) FROM e;
+ }
+} {500}
+
+do_test tkt3871-1.2 {
+ execsql { SELECT * FROM e WHERE a = 1 OR a = 2 }
+} {1 1 2 4}
+do_test tkt3871-1.3 {
+ set echo_module ""
+ execsql { SELECT * FROM e WHERE a = 1 OR a = 2 }
+ set echo_module
+} [list \
+ xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 1 \
+ xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 2 \
+]
+
+do_test tkt3871-1.4 {
+ execsql { SELECT * FROM e WHERE a = 1 OR a = 2 OR b = 9 }
+} {1 1 2 4 3 9}
+do_test tkt3871-1.5 {
+ set echo_module ""
+ execsql { SELECT * FROM e WHERE a = 1 OR a = 2 OR b = 9 }
+ set echo_module
+} [list \
+ xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 1 \
+ xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 2 \
+ xFilter {SELECT rowid, * FROM 't1' WHERE b = ?} 9
+]
+
+
+finish_test
diff --git a/test/tkt3879.test b/test/tkt3879.test
new file mode 100644
index 0000000..ed5577f
--- /dev/null
+++ b/test/tkt3879.test
@@ -0,0 +1,52 @@
+# 2009 May 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests to verify ticket #3879 is fixed.
+#
+# $Id: tkt3879.test,v 1.2 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3879.1.1 {
+ execsql {
+ CREATE TABLE t1 (a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES ('w', 1);
+ INSERT INTO t1 VALUES ('z', -1);
+
+ CREATE TABLE t2 (m INTEGER PRIMARY KEY, n, a, p);
+ INSERT INTO t2 VALUES (25, 13, 'w', 1);
+ INSERT INTO t2 VALUES (26, 25, 'z', 153);
+ INSERT INTO t2 VALUES (27, 25, 'z', 68);
+
+ CREATE TABLE t3 (m);
+ INSERT INTO t3 VALUES (25);
+ }
+} {}
+
+do_test tkt3879.1.2 {
+ execsql {
+ SELECT 111, t1.b*123
+ FROM t3, t2 AS j0, t2 AS j1, t1
+ WHERE j0.m=t3.m AND t1.a=j0.a AND j1.n=j0.m;
+ }
+} {111 123 111 123}
+
+do_test tkt3879.1.3 {
+ execsql {
+ SELECT 222, t1.b*123
+ FROM t3, t2 AS j0, t2 AS j1, t1
+ WHERE j0.m=t3.m AND t1.a=j0.a AND j1.n=j0.m
+ ORDER BY t1.b;
+ }
+} {222 123 222 123}
+
+finish_test
diff --git a/test/tkt3911.test b/test/tkt3911.test
new file mode 100644
index 0000000..2ac56cb
--- /dev/null
+++ b/test/tkt3911.test
@@ -0,0 +1,58 @@
+# 2009 June 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests to verify ticket #3911 is fixed.
+#
+# $Id: tkt3911.test,v 1.1 2009/06/12 03:27:28 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3911.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(11,12);
+
+ CREATE TABLE t2(b,c);
+ INSERT INTO t2 VALUES(2,3);
+ INSERT INTO t2 VALUES(22,23);
+
+ SELECT * FROM t1 JOIN t2 USING(b);
+ }
+} {1 2 3}
+do_test tkt3911.2 {
+ db eval {
+ SELECT * FROM t1 JOIN (t2) AS x USING (b);
+ }
+} {1 2 3}
+do_test tkt3911.3 {
+ db eval {
+ SELECT * FROM t1 JOIN (SELECT * FROM t2) AS x USING (b);
+ }
+} {1 2 3}
+
+do_test tkt3911.4 {
+ db eval {
+ CREATE TABLE t3(m,a);
+ INSERT INTO t3 VALUES('one',1);
+ INSERT INTO t3 VALUES('two',2);
+
+ SELECT * FROM t3 JOIN (SELECT * FROM t1 NATURAL JOIN t2) AS x USING(a);
+ }
+} {one 1 2 3}
+do_test tkt3911.5 {
+ db eval {
+ SELECT * FROM t3 JOIN (SELECT * FROM t1 JOIN t2 USING (b)) AS x USING(a);
+ }
+} {one 1 2 3}
+
+finish_test
diff --git a/test/tkt3918.test b/test/tkt3918.test
new file mode 100644
index 0000000..c46ad8f
--- /dev/null
+++ b/test/tkt3918.test
@@ -0,0 +1,60 @@
+# 2009 June 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: tkt3918.test,v 1.1 2009/06/17 11:13:28 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3918.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = incremental;
+ CREATE TABLE t1(i, x);
+ }
+} {}
+do_test tkt3918.2 {
+ execsql {
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, zeroblob(248*1020 + 100));
+ INSERT INTO t1 VALUES(3, zeroblob(2*1020 + 100));
+ }
+} {}
+
+# This set of statements sets up the free list so that the
+# first free-list trunk page contains only a single leaf.
+# The leaf page is also the last page in the database. The
+# second free-list trunk page contains, amongst other things,
+# page number 4.
+do_test tkt3918.3 {
+ execsql {
+ DELETE FROM t1 WHERE i = 2;
+ DELETE FROM t1 WHERE i = 1;
+ DELETE FROM t1 WHERE i = 3;
+ }
+} {}
+
+# Incrementally vacuum the database to reduce its size by a single
+# page. This will remove the single leaf from the first page in
+# the linked list of free-list trunk pages.
+do_test tkt3918.4 {
+ execsql { PRAGMA incremental_vacuum = 1 }
+} {}
+
+# Create another table. This operation will attempt to extract
+# page 4 from the database free-list. Bug 3918 caused sqlite to
+# incorrectly report corruption here.
+do_test tkt3918.5 {
+ execsql { CREATE TABLE t2(a, b) }
+} {}
+
+finish_test
+
diff --git a/test/tkt3922.test b/test/tkt3922.test
new file mode 100644
index 0000000..86bf5fe
--- /dev/null
+++ b/test/tkt3922.test
@@ -0,0 +1,89 @@
+# 2009 June 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: tkt3922.test,v 1.2 2009/06/26 14:17:47 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {[working_64bit_int]} {
+ do_test tkt3922.1 {
+ execsql {
+ CREATE TABLE t1(a NUMBER);
+ INSERT INTO t1 VALUES('-9223372036854775808');
+ SELECT a, typeof(a) FROM t1;
+ }
+ } {-9223372036854775808 integer}
+} else {
+ # this alternate version of tkt3922.1 doesn't
+ # really test the same thing as the original,
+ # but is needed to create the table and
+ # provided simply as a place holder for
+ # platforms without working 64bit support.
+ do_test tkt3922.1 {
+ execsql {
+ CREATE TABLE t1(a NUMBER);
+ INSERT INTO t1 VALUES('-1');
+ SELECT a, typeof(a) FROM t1;
+ }
+ } {-1 integer}
+}
+do_realnum_test tkt3922.2 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('-9223372036854775809');
+ SELECT a, typeof(a) FROM t1;
+ }
+} {-9.22337203685478e+18 real}
+do_realnum_test tkt3922.3 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('-9223372036854776832');
+ SELECT a, typeof(a) FROM t1;
+ }
+} {-9.22337203685478e+18 real}
+do_realnum_test tkt3922.4 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('-9223372036854776833');
+ SELECT a, typeof(a) FROM t1;
+ }
+} {-9.22337203685478e+18 real}
+if {[working_64bit_int]} {
+ do_test tkt3922.5 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('9223372036854775807');
+ SELECT a, typeof(a) FROM t1;
+ }
+ } {9223372036854775807 integer}
+} else {
+ # this alternate version of tkt3922.5 doesn't
+ # really test the same thing as the original,
+ # but provided simply as a place holder for
+ # platforms without working 64bit support.
+ do_test tkt3922.5 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('1');
+ SELECT a, typeof(a) FROM t1;
+ }
+ } {1 integer}
+}
+do_realnum_test tkt3922.6 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('9223372036854775808');
+ SELECT a, typeof(a) FROM t1;
+ }
+} {9.22337203685478e+18 real}
+
+finish_test
diff --git a/test/tkt3929.test b/test/tkt3929.test
new file mode 100644
index 0000000..3ed4d28
--- /dev/null
+++ b/test/tkt3929.test
@@ -0,0 +1,53 @@
+# 2009 June 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests to verify ticket #3929 is fixed.
+#
+# $Id: tkt3929.test,v 1.1 2009/06/23 11:53:09 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+do_test tkt3929-1.0 {
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ CREATE TRIGGER t1_t1 AFTER INSERT ON t1 BEGIN
+ UPDATE t1 SET b = 'value: ' || a WHERE t1.rowid = new.rowid;
+ END;
+ }
+} {}
+
+do_test tkt3929-1.1 {
+ execsql {
+ INSERT INTO t1(a) VALUES(1);
+ INSERT INTO t1(a) VALUES(2);
+ SELECT * FROM t1;
+ }
+} {1 {value: 1} 2 {value: 2}}
+
+# Before it was fixed, the following provoked the bug, causing either an
+# assertion failure or a "database is malformed" error.
+#
+do_test tkt3930-1.2 {
+ for {set i 3} {$i < 100} {incr i} {
+ execsql { INSERT INTO t1(a) VALUES($i) }
+ }
+} {}
+
+integrity_check tkt3930-1.3
+finish_test
+
diff --git a/test/tkt3935.test b/test/tkt3935.test
new file mode 100644
index 0000000..abbeb3f
--- /dev/null
+++ b/test/tkt3935.test
@@ -0,0 +1,57 @@
+# 2009 July 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #3935 has been fixed.
+#
+# $Id: tkt3935.test,v 1.2 2009/07/01 16:12:08 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3935.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ }
+} {}
+
+do_test tkt3935.2 {
+ execsql { SELECT j1.b FROM ( SELECT * FROM t1 INNER JOIN t2 ON a=c ) AS j1 }
+} {}
+do_test tkt3935.3 {
+ execsql { SELECT j1.b FROM (t1 INNER JOIN t2 ON a=c) AS j1 }
+} {}
+
+
+do_test tkt3935.4 {
+ catchsql { SELECT a FROM (t1) AS t ON b USING(a) }
+} {1 {a JOIN clause is required before ON}}
+do_test tkt3935.5 {
+ catchsql { SELECT a FROM (t1) AS t ON b }
+} {1 {a JOIN clause is required before ON}}
+do_test tkt3935.6 {
+ catchsql { SELECT a FROM (SELECT * FROM t1) AS t ON b USING(a) }
+} {1 {a JOIN clause is required before ON}}
+do_test tkt3935.7 {
+ catchsql { SELECT a FROM (SELECT * FROM t1) AS t ON b }
+} {1 {a JOIN clause is required before ON}}
+do_test tkt3935.8 {
+ catchsql { SELECT a FROM t1 AS t ON b }
+} {1 {a JOIN clause is required before ON}}
+do_test tkt3935.9 {
+ catchsql { SELECT a FROM t1 AS t ON b USING(a) }
+} {1 {a JOIN clause is required before ON}}
+do_test tkt3935.10 {
+ catchsql { SELECT a FROM t1 AS t USING(a) }
+} {1 {a JOIN clause is required before USING}}
+
+finish_test
diff --git a/test/tkt3992.test b/test/tkt3992.test
new file mode 100644
index 0000000..0d8a30f
--- /dev/null
+++ b/test/tkt3992.test
@@ -0,0 +1,81 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: tkt3992.test,v 1.1 2009/07/27 10:05:06 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3992-1.1 {
+ execsql {
+ CREATE TABLE parameters1(
+ mountcnt INT NOT NULL CHECK (typeof(mountcnt) == 'integer'),
+ version REAL NOT NULL
+ );
+ INSERT INTO parameters1(mountcnt, version) VALUES(1, 1.0);
+
+ CREATE TABLE parameters2(
+ mountcnt INT NOT NULL CHECK (typeof(mountcnt) == 'integer'),
+ version REAL CHECK (typeof(version) == 'real')
+ );
+ INSERT INTO parameters2(mountcnt, version) VALUES(1, 1.0);
+ }
+} {}
+
+do_test tkt3992-1.2 {
+ execsql {
+ UPDATE parameters1 SET mountcnt = mountcnt + 1;
+ SELECT * FROM parameters1;
+ }
+} {2 1.0}
+
+do_test tkt3992-1.3 {
+ execsql {
+ UPDATE parameters2 SET mountcnt = mountcnt + 1;
+ SELECT * FROM parameters2;
+ }
+} {2 1.0}
+
+ifcapable altertable {
+ do_test tkt3992-2.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ ALTER TABLE t1 ADD COLUMN c DEFAULT 3;
+ SELECT * FROM t1;
+ }
+ } {1 2 3}
+ do_test tkt3992-2.2 {
+ execsql {
+ UPDATE t1 SET a = 'one';
+ SELECT * FROM t1;
+ }
+ } {one 2 3}
+}
+
+ifcapable trigger {
+ db function tcl eval
+ do_test tkt3992-2.3 {
+ execsql {
+ CREATE TABLE t2(a REAL, b REAL, c REAL);
+ INSERT INTO t2 VALUES(1, 2, 3);
+ CREATE TRIGGER tr2 BEFORE UPDATE ON t2 BEGIN
+ SELECT tcl('set res', typeof(new.c));
+ END;
+
+ UPDATE t2 SET a = 'I';
+ }
+ set res
+ } {real}
+}
+
+
+finish_test
diff --git a/test/tkt3997.test b/test/tkt3997.test
new file mode 100644
index 0000000..85e88db
--- /dev/null
+++ b/test/tkt3997.test
@@ -0,0 +1,73 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests to make sure #3997 is fixed.
+#
+# $Id: tkt3997.test,v 1.1 2009/07/28 13:30:31 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc reverse {lhs rhs} {
+ return [string compare $rhs $lhs]
+}
+proc usual {lhs rhs} {
+ return [string compare $lhs $rhs]
+}
+
+db collate reverse reverse
+db collate usual usual
+
+do_test tkt3997-1.1 {
+ execsql {
+ create table mytext(name BLOB);
+ INSERT INTO mytext VALUES('abc');
+ INSERT INTO mytext VALUES('acd');
+ INSERT INTO mytext VALUES('afe');
+ }
+} {}
+do_test tkt3997-1.2 {
+ execsql {
+ SELECT name
+ FROM mytext
+ ORDER BY name COLLATE reverse
+ }
+} {afe acd abc}
+do_test tkt3997-1.3 {
+ execsql {
+ SELECT name
+ FROM (SELECT name FROM mytext)
+ ORDER BY name COLLATE reverse
+ }
+} {afe acd abc}
+
+do_test tkt3997-2.1 {
+ execsql {
+ CREATE TABLE mytext2(name COLLATE reverse);
+ INSERT INTO mytext2 SELECT name FROM mytext;
+ }
+} {}
+do_test tkt3997-2.2 {
+ execsql {
+ SELECT name
+ FROM (SELECT name FROM mytext2)
+ ORDER BY name
+ }
+} {afe acd abc}
+do_test tkt3997-2.3 {
+ execsql {
+ SELECT name
+ FROM (SELECT name FROM mytext2)
+ ORDER BY name COLLATE usual
+ }
+} {abc acd afe}
+
+finish_test
diff --git a/test/tkt4018.test b/test/tkt4018.test
new file mode 100644
index 0000000..2bc41d4
--- /dev/null
+++ b/test/tkt4018.test
@@ -0,0 +1,89 @@
+# 2009 August 20
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket #4018 has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc testsql {sql} {
+ set fd [open tf_main.tcl w]
+ puts $fd [subst -nocommands {
+ sqlite3_test_control_pending_byte 0x0010000
+ sqlite3 db test.db
+ set rc [catch { db eval {$sql} } msg]
+ puts -nonewline "[set rc] {[set msg]}"
+ flush stdout
+ exit
+ }]
+ close $fd
+ set fd [open "| [info nameofexec] ./tf_main.tcl" r]
+ set res [read $fd]
+ close $fd
+ return $res
+}
+
+do_test tkt4018-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ BEGIN;
+ SELECT * FROM t1;
+ }
+} {}
+
+# The database is locked by connection [db]. Open and close a second
+# connection to test.db 10000 times. If file-descriptors are not being
+# reused, then the process will quickly exceed its maximum number of
+# file descriptors (1024 by default on linux).
+do_test tkt4018-1.2 {
+ for {set i 0} {$i < 10000} {incr i} {
+ sqlite3 db2 test.db
+ db2 close
+ }
+} {}
+
+# Now check that connection [db] is still holding a SHARED lock by
+# having a second process try to write the db.
+do_test tkt4018-1.3 {
+ testsql {INSERT INTO t1 VALUES(3, 4)}
+} {1 {database is locked}}
+
+# Sanity checking. Have [db] release the lock and then retry the
+# INSERT from the previous test case.
+do_test tkt4018-1.4 {
+ db eval COMMIT
+ testsql {INSERT INTO t1 VALUES(3, 4)}
+} {0 {}}
+
+# Check that reusing a file descriptor cannot change a read-only
+# connection into a read-write connection.
+do_test tkt4018-2.1 {
+ sqlite3 db2 test.db
+ execsql {INSERT INTO t1 VALUES(1, 2)} db2
+} {}
+do_test tkt4018-2.2 {
+ execsql {
+ BEGIN;
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 2 3 4}
+do_test tkt4018-2.3 {
+ db2 close
+ sqlite3 db2 test.db -readonly 1
+ execsql COMMIT
+ catchsql {INSERT INTO t1 VALUES(5, 6)} db2
+} {1 {attempt to write a readonly database}}
+db2 close
+
+finish_test
diff --git a/test/tokenize.test b/test/tokenize.test
new file mode 100644
index 0000000..46fd4ee
--- /dev/null
+++ b/test/tokenize.test
@@ -0,0 +1,65 @@
+# 2008 July 7
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script testing the tokenizer
+#
+# $Id: tokenize.test,v 1.1 2008/07/08 00:06:51 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tokenize-1.1 {
+ catchsql {SELECT 1.0e+}
+} {1 {unrecognized token: "1.0e"}}
+do_test tokenize-1.2 {
+ catchsql {SELECT 1.0E+}
+} {1 {unrecognized token: "1.0E"}}
+do_test tokenize-1.3 {
+ catchsql {SELECT 1.0e-}
+} {1 {unrecognized token: "1.0e"}}
+do_test tokenize-1.4 {
+ catchsql {SELECT 1.0E-}
+} {1 {unrecognized token: "1.0E"}}
+do_test tokenize-1.5 {
+ catchsql {SELECT 1.0e+/}
+} {1 {unrecognized token: "1.0e"}}
+do_test tokenize-1.6 {
+ catchsql {SELECT 1.0E+:}
+} {1 {unrecognized token: "1.0E"}}
+do_test tokenize-1.7 {
+ catchsql {SELECT 1.0e-:}
+} {1 {unrecognized token: "1.0e"}}
+do_test tokenize-1.8 {
+ catchsql {SELECT 1.0E-/}
+} {1 {unrecognized token: "1.0E"}}
+do_test tokenize-1.9 {
+ catchsql {SELECT 1.0F+5}
+} {1 {unrecognized token: "1.0F"}}
+do_test tokenize-1.10 {
+ catchsql {SELECT 1.0d-10}
+} {1 {unrecognized token: "1.0d"}}
+do_test tokenize-1.11 {
+ catchsql {SELECT 1.0e,5}
+} {1 {unrecognized token: "1.0e"}}
+do_test tokenize-1.12 {
+ catchsql {SELECT 1.0E.10}
+} {1 {unrecognized token: "1.0E"}}
+
+do_test tokenize-2.1 {
+ catchsql {SELECT 1, 2 /*}
+} {1 {near "*": syntax error}}
+do_test tokenize-2.2 {
+ catchsql {SELECT 1, 2 /* }
+} {0 {1 2}}
+
+
+finish_test
diff --git a/test/trace.test b/test/trace.test
new file mode 100644
index 0000000..ce5a2d7
--- /dev/null
+++ b/test/trace.test
@@ -0,0 +1,245 @@
+# 2004 Jun 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the "sqlite3_trace()" API.
+#
+# $Id: trace.test,v 1.8 2009/04/07 14:14:23 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !trace {
+ finish_test
+ return
+}
+
+set ::stmtlist {}
+do_test trace-1.1 {
+ set rc [catch {db trace 1 2 3} msg]
+ lappend rc $msg
+} {1 {wrong # args: should be "db trace ?CALLBACK?"}}
+proc trace_proc cmd {
+ lappend ::stmtlist [string trim $cmd]
+}
+do_test trace-1.2 {
+ db trace trace_proc
+ db trace
+} {trace_proc}
+do_test trace-1.3 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t1;
+ }
+} {1 2}
+do_test trace-1.4 {
+ set ::stmtlist
+} {{CREATE TABLE t1(a,b);} {INSERT INTO t1 VALUES(1,2);} {SELECT * FROM t1;}}
+do_test trace-1.5 {
+ db trace {}
+ db trace
+} {}
+
+# If we prepare a statement and execute it multiple times, the trace
+# happens on each execution.
+#
+db close
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+do_test trace-2.1 {
+ set STMT [sqlite3_prepare $DB {INSERT INTO t1 VALUES(2,3)} -1 TAIL]
+ db trace trace_proc
+ proc trace_proc sql {
+ global TRACE_OUT
+ lappend TRACE_OUT [string trim $sql]
+ }
+ set TRACE_OUT {}
+ sqlite3_step $STMT
+ set TRACE_OUT
+} {{INSERT INTO t1 VALUES(2,3)}}
+do_test trace-2.2 {
+ set TRACE_OUT {}
+ sqlite3_reset $STMT
+ set TRACE_OUT
+} {}
+do_test trace-2.3 {
+ sqlite3_step $STMT
+ set TRACE_OUT
+} {{INSERT INTO t1 VALUES(2,3)}}
+do_test trace-2.4 {
+ set TRACE_OUT {}
+ execsql {SELECT * FROM t1}
+} {1 2 2 3 2 3}
+do_test trace-2.5 {
+ set TRACE_OUT
+} {{SELECT * FROM t1}}
+catch {sqlite3_finalize $STMT}
+
+do_test trace-2.6 {
+ set TRACE_OUT {}
+ db eval VACUUM
+ set TRACE_OUT
+} {VACUUM}
+
+# Similar tests, but this time for profiling.
+#
+do_test trace-3.1 {
+ set rc [catch {db profile 1 2 3} msg]
+ lappend rc $msg
+} {1 {wrong # args: should be "db profile ?CALLBACK?"}}
+set ::stmtlist {}
+proc profile_proc {cmd tm} {
+ lappend ::stmtlist [string trim $cmd]
+}
+do_test trace-3.2 {
+ db trace {}
+ db profile profile_proc
+ db profile
+} {profile_proc}
+do_test trace-3.3 {
+ execsql {
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+} {1 2}
+do_test trace-3.4 {
+ set ::stmtlist
+} {{CREATE TABLE t2(a,b);} {INSERT INTO t2 VALUES(1,2);} {SELECT * FROM t2;}}
+do_test trace-3.5 {
+ db profile {}
+ db profile
+} {}
+
+# If we prepare a statement and execute it multiple times, the profile
+# happens on each execution.
+#
+db close
+sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+do_test trace-4.1 {
+ set STMT [sqlite3_prepare $DB {INSERT INTO t2 VALUES(2,3)} -1 TAIL]
+ db trace trace_proc
+ proc profile_proc {sql tm} {
+ global TRACE_OUT
+ lappend TRACE_OUT [string trim $sql]
+ }
+ set TRACE_OUT {}
+ sqlite3_step $STMT
+ set TRACE_OUT
+} {{INSERT INTO t2 VALUES(2,3)}}
+do_test trace-4.2 {
+ set TRACE_OUT {}
+ sqlite3_reset $STMT
+ set TRACE_OUT
+} {}
+do_test trace-4.3 {
+ sqlite3_step $STMT
+ set TRACE_OUT
+} {{INSERT INTO t2 VALUES(2,3)}}
+do_test trace-4.4 {
+ set TRACE_OUT {}
+ execsql {SELECT * FROM t1}
+} {1 2 2 3 2 3}
+do_test trace-4.5 {
+ set TRACE_OUT
+} {{SELECT * FROM t1}}
+catch {sqlite3_finalize $STMT}
+
+# Trigger tracing.
+#
+ifcapable trigger {
+ do_test trace-5.1 {
+ db eval {
+ CREATE TRIGGER r1t1 AFTER UPDATE ON t1 BEGIN
+ UPDATE t2 SET a=new.a WHERE rowid=new.rowid;
+ END;
+ CREATE TRIGGER r1t2 AFTER UPDATE ON t2 BEGIN
+ SELECT 'hello';
+ END;
+ }
+ set TRACE_OUT {}
+ proc trace_proc cmd {
+ lappend ::TRACE_OUT [string trim $cmd]
+ }
+ db eval {
+ UPDATE t1 SET a=a+1;
+ }
+ set TRACE_OUT
+ } {{UPDATE t1 SET a=a+1;} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2}}
+}
+
+# With 3.6.21, we add the ability to expand host parameters in the trace
+# output. Test this feature.
+#
+do_test trace-6.1 {
+ set ::t6int [expr {3+3}]
+ set ::t6real [expr {1.5*4.0}]
+ set ::t6str {test-six y'all}
+ db eval {SELECT x'3031323334' AS x} {set ::t6blob $x}
+ unset -nocomplain t6null
+ set TRACE_OUT {}
+ execsql {SELECT $::t6int, $::t6real, $t6str, $t6blob, $t6null}
+} {6 6.0 {test-six y'all} 01234 {}}
+do_test trace-6.2 {
+ set TRACE_OUT
+} {{SELECT 6, 6.0, 'test-six y''all', x'3031323334', NULL}}
+do_test trace-6.3 {
+ set TRACE_OUT {}
+ execsql {SELECT $::t6int, ?1, $::t6int}
+} {6 6 6}
+do_test trace-6.4 {
+ set TRACE_OUT
+} {{SELECT 6, 6, 6}}
+do_test trace-6.5 {
+ execsql {CREATE TABLE t6([$::t6int],"?1"); INSERT INTO t6 VALUES(1,2)}
+ set TRACE_OUT {}
+ execsql {SELECT '$::t6int', [$::t6int], $::t6int, ?1, "?1", $::t6int FROM t6}
+} {{$::t6int} 1 6 6 2 6}
+do_test trace-6.6 {
+ set TRACE_OUT
+} {{SELECT '$::t6int', [$::t6int], 6, 6, "?1", 6 FROM t6}}
+
+# Do these same tests with a UTF16 database.
+#
+do_test trace-6.100 {
+ db close
+ sqlite3 db :memory:
+ db eval {
+ PRAGMA encoding=UTF16be;
+ CREATE TABLE t6([$::t6str],"?1");
+ INSERT INTO t6 VALUES(1,2);
+ }
+ db trace trace_proc
+ set TRACE_OUT {}
+ execsql {SELECT '$::t6str', [$::t6str], $::t6str, ?1, "?1", $::t6str FROM t6}
+} {{$::t6str} 1 {test-six y'all} {test-six y'all} 2 {test-six y'all}}
+do_test trace-6.101 {
+ set TRACE_OUT
+} {{SELECT '$::t6str', [$::t6str], 'test-six y''all', 'test-six y''all', "?1", 'test-six y''all' FROM t6}}
+
+do_test trace-6.200 {
+ db close
+ sqlite3 db :memory:
+ db eval {
+ PRAGMA encoding=UTF16le;
+ CREATE TABLE t6([$::t6str],"?1");
+ INSERT INTO t6 VALUES(1,2);
+ }
+ db trace trace_proc
+ set TRACE_OUT {}
+ execsql {SELECT '$::t6str', [$::t6str], $::t6str, ?1, "?1", $::t6str FROM t6}
+} {{$::t6str} 1 {test-six y'all} {test-six y'all} 2 {test-six y'all}}
+do_test trace-6.201 {
+ set TRACE_OUT
+} {{SELECT '$::t6str', [$::t6str], 'test-six y''all', 'test-six y''all', "?1", 'test-six y''all' FROM t6}}
+
+
+finish_test
diff --git a/test/trace2.test b/test/trace2.test
new file mode 100644
index 0000000..42738db
--- /dev/null
+++ b/test/trace2.test
@@ -0,0 +1,152 @@
+# 2011 Jan 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the "sqlite3_trace()" API. Specifically,
+# it tests the special handling of nested SQL statements (those executed
+# by virtual table or user function callbacks). These statements are treated
+# differently in two respects:
+#
+# 1. Each line of the statement is prefixed with "-- " to turn it into
+# an SQL comment.
+#
+# 2. Parameter expansion is not performed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !trace { finish_test ; return }
+set ::testprefix trace2
+
+proc sql {zSql} { db one $zSql }
+proc trace {zSql} { lappend ::trace $zSql }
+
+db func sql sql
+db trace trace
+
+proc do_trace_test {tn sql expected} {
+ # Test that the list of string passed to the trace callback when $sql
+ # is executed is equivalent to the list of strings in $expected.
+ #
+ set ::trace [list]
+ execsql $sql
+ uplevel do_test $tn [list {set ::trace}] [list [list {*}$expected]]
+}
+
+proc do_trace_select_test {tn sql expected} {
+
+ uplevel [list do_trace_test ${tn}.a $sql $expected]
+
+ # Now execute each SQL statement passed to the trace callback in the
+ # block above. Check that this causes the same set of strings to be
+ # passed to the trace callback again. i.e. that executing the output
+ # of the trace callback is equivalent to the SQL script in $sql.
+ #
+ set sqllist $::trace
+ set ::trace [list]
+ foreach item $sqllist { execsql $item }
+ uplevel do_test $tn.b [list {set ::trace}] [list $sqllist]
+}
+
+do_trace_select_test 1.1 {
+ SELECT 1, 2, 3;
+} {
+ "SELECT 1, 2, 3;"
+}
+
+do_trace_select_test 1.2 {
+ SELECT sql('SELECT 1, 2, 3');
+} {
+ "SELECT sql('SELECT 1, 2, 3');"
+ "-- SELECT 1, 2, 3"
+}
+
+do_trace_select_test 1.3 {
+ SELECT sql('SELECT 1,
+ 2,
+ 3'
+ );
+} {
+ "SELECT sql('SELECT 1,
+ 2,
+ 3'
+ );"
+ "-- SELECT 1,
+-- 2,
+-- 3"
+}
+
+do_trace_select_test 1.4 {
+ SELECT sql('SELECT 1,
+
+
+ 3'
+ );
+} {
+ "SELECT sql('SELECT 1,
+
+
+ 3'
+ );"
+ "-- SELECT 1,
+--
+--
+-- 3"
+}
+
+do_trace_select_test 1.5 {
+ SELECT $var, sql('SELECT 1,
+ $var,
+ 3'
+ );
+} {
+ "SELECT NULL, sql('SELECT 1,
+ $var,
+ 3'
+ );"
+ "-- SELECT 1,
+-- $var,
+-- 3"
+}
+
+ifcapable fts3 {
+ do_execsql_test 2.1 {
+ CREATE VIRTUAL TABLE x1 USING fts4;
+ INSERT INTO x1 VALUES('Cloudy, with a high near 16');
+ INSERT INTO x1 VALUES('Wind chill values as low as -13');
+ }
+
+ do_trace_test 2.2 {
+ INSERT INTO x1 VALUES('North northwest wind between 8 and 14 mph');
+ } {
+ "INSERT INTO x1 VALUES('North northwest wind between 8 and 14 mph');"
+ "-- INSERT INTO 'main'.'x1_content' VALUES(?,(?))"
+ "-- REPLACE INTO 'main'.'x1_docsize' VALUES(?,?)"
+ "-- SELECT value FROM 'main'.'x1_stat' WHERE id=0"
+ "-- REPLACE INTO 'main'.'x1_stat' VALUES(0,?)"
+ "-- SELECT (SELECT max(idx) FROM 'main'.'x1_segdir' WHERE level = ?) + 1"
+ "-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)"
+ "-- INSERT INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)"
+ }
+
+ do_trace_test 2.3 {
+ INSERT INTO x1(x1) VALUES('optimize');
+ } {
+ "INSERT INTO x1(x1) VALUES('optimize');"
+ "-- SELECT idx, start_block, leaves_end_block, end_block, root FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?ORDER BY level DESC, idx ASC"
+ "-- SELECT max(level) FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?"
+ "-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)"
+ "-- DELETE FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?"
+ "-- INSERT INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)"
+ }
+}
+
+finish_test
diff --git a/test/trans.test b/test/trans.test
new file mode 100644
index 0000000..bbaedc5
--- /dev/null
+++ b/test/trans.test
@@ -0,0 +1,956 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is database locks.
+#
+# $Id: trans.test,v 1.41 2009/04/28 16:37:59 danielk1977 Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create several tables to work with.
+#
+wal_set_journal_mode
+do_test trans-1.0 {
+ execsql {
+ CREATE TABLE one(a int PRIMARY KEY, b text);
+ INSERT INTO one VALUES(1,'one');
+ INSERT INTO one VALUES(2,'two');
+ INSERT INTO one VALUES(3,'three');
+ SELECT b FROM one ORDER BY a;
+ }
+} {one two three}
+integrity_check trans-1.0.1
+do_test trans-1.1 {
+ execsql {
+ CREATE TABLE two(a int PRIMARY KEY, b text);
+ INSERT INTO two VALUES(1,'I');
+ INSERT INTO two VALUES(5,'V');
+ INSERT INTO two VALUES(10,'X');
+ SELECT b FROM two ORDER BY a;
+ }
+} {I V X}
+do_test trans-1.9 {
+ sqlite3 altdb test.db
+ execsql {SELECT b FROM one ORDER BY a} altdb
+} {one two three}
+do_test trans-1.10 {
+ execsql {SELECT b FROM two ORDER BY a} altdb
+} {I V X}
+integrity_check trans-1.11
+wal_check_journal_mode trans-1.12
+
+# Basic transactions
+#
+do_test trans-2.1 {
+ set v [catch {execsql {BEGIN}} msg]
+ lappend v $msg
+} {0 {}}
+do_test trans-2.2 {
+ set v [catch {execsql {END}} msg]
+ lappend v $msg
+} {0 {}}
+do_test trans-2.3 {
+ set v [catch {execsql {BEGIN TRANSACTION}} msg]
+ lappend v $msg
+} {0 {}}
+do_test trans-2.4 {
+ set v [catch {execsql {COMMIT TRANSACTION}} msg]
+ lappend v $msg
+} {0 {}}
+do_test trans-2.5 {
+ set v [catch {execsql {BEGIN TRANSACTION 'foo'}} msg]
+ lappend v $msg
+} {0 {}}
+do_test trans-2.6 {
+ set v [catch {execsql {ROLLBACK TRANSACTION 'foo'}} msg]
+ lappend v $msg
+} {0 {}}
+do_test trans-2.10 {
+ execsql {
+ BEGIN;
+ SELECT a FROM one ORDER BY a;
+ SELECT a FROM two ORDER BY a;
+ END;
+ }
+} {1 2 3 1 5 10}
+integrity_check trans-2.11
+wal_check_journal_mode trans-2.12
+
+# Check the locking behavior
+#
+do_test trans-3.1 {
+ execsql {
+ BEGIN;
+ UPDATE one SET a = 0 WHERE 0;
+ SELECT a FROM one ORDER BY a;
+ }
+} {1 2 3}
+do_test trans-3.2 {
+ catchsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb
+} {0 {1 5 10}}
+
+do_test trans-3.3 {
+ catchsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb
+} {0 {1 2 3}}
+do_test trans-3.4 {
+ catchsql {
+ INSERT INTO one VALUES(4,'four');
+ }
+} {0 {}}
+do_test trans-3.5 {
+ catchsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb
+} {0 {1 5 10}}
+do_test trans-3.6 {
+ catchsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb
+} {0 {1 2 3}}
+do_test trans-3.7 {
+ catchsql {
+ INSERT INTO two VALUES(4,'IV');
+ }
+} {0 {}}
+do_test trans-3.8 {
+ catchsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb
+} {0 {1 5 10}}
+do_test trans-3.9 {
+ catchsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb
+} {0 {1 2 3}}
+do_test trans-3.10 {
+ execsql {END TRANSACTION}
+} {}
+
+do_test trans-3.11 {
+ set v [catch {execsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb} msg]
+ lappend v $msg
+} {0 {1 4 5 10}}
+do_test trans-3.12 {
+ set v [catch {execsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb} msg]
+ lappend v $msg
+} {0 {1 2 3 4}}
+do_test trans-3.13 {
+ set v [catch {execsql {
+ SELECT a FROM two ORDER BY a;
+ } db} msg]
+ lappend v $msg
+} {0 {1 4 5 10}}
+do_test trans-3.14 {
+ set v [catch {execsql {
+ SELECT a FROM one ORDER BY a;
+ } db} msg]
+ lappend v $msg
+} {0 {1 2 3 4}}
+integrity_check trans-3.15
+wal_check_journal_mode trans-3.16
+
+do_test trans-4.1 {
+ set v [catch {execsql {
+ COMMIT;
+ } db} msg]
+ lappend v $msg
+} {1 {cannot commit - no transaction is active}}
+do_test trans-4.2 {
+ set v [catch {execsql {
+ ROLLBACK;
+ } db} msg]
+ lappend v $msg
+} {1 {cannot rollback - no transaction is active}}
+do_test trans-4.3 {
+ catchsql {
+ BEGIN TRANSACTION;
+ UPDATE two SET a = 0 WHERE 0;
+ SELECT a FROM two ORDER BY a;
+ } db
+} {0 {1 4 5 10}}
+do_test trans-4.4 {
+ catchsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb
+} {0 {1 4 5 10}}
+do_test trans-4.5 {
+ catchsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb
+} {0 {1 2 3 4}}
+do_test trans-4.6 {
+ catchsql {
+ BEGIN TRANSACTION;
+ SELECT a FROM one ORDER BY a;
+ } db
+} {1 {cannot start a transaction within a transaction}}
+do_test trans-4.7 {
+ catchsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb
+} {0 {1 4 5 10}}
+do_test trans-4.8 {
+ catchsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb
+} {0 {1 2 3 4}}
+do_test trans-4.9 {
+ set v [catch {execsql {
+ END TRANSACTION;
+ SELECT a FROM two ORDER BY a;
+ } db} msg]
+ lappend v $msg
+} {0 {1 4 5 10}}
+do_test trans-4.10 {
+ set v [catch {execsql {
+ SELECT a FROM two ORDER BY a;
+ } altdb} msg]
+ lappend v $msg
+} {0 {1 4 5 10}}
+do_test trans-4.11 {
+ set v [catch {execsql {
+ SELECT a FROM one ORDER BY a;
+ } altdb} msg]
+ lappend v $msg
+} {0 {1 2 3 4}}
+integrity_check trans-4.12
+wal_check_journal_mode trans-4.13
+wal_check_journal_mode trans-4.14 altdb
+do_test trans-4.98 {
+ altdb close
+ execsql {
+ DROP TABLE one;
+ DROP TABLE two;
+ }
+} {}
+integrity_check trans-4.99
+
+# Check out the commit/rollback behavior of the database
+#
+do_test trans-5.1 {
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
+} {}
+do_test trans-5.2 {
+ execsql {BEGIN TRANSACTION}
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
+} {}
+do_test trans-5.3 {
+ execsql {CREATE TABLE one(a text, b int)}
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
+} {one}
+do_test trans-5.4 {
+ execsql {SELECT a,b FROM one ORDER BY b}
+} {}
+do_test trans-5.5 {
+ execsql {INSERT INTO one(a,b) VALUES('hello', 1)}
+ execsql {SELECT a,b FROM one ORDER BY b}
+} {hello 1}
+do_test trans-5.6 {
+ execsql {ROLLBACK}
+ execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
+} {}
+do_test trans-5.7 {
+ set v [catch {
+ execsql {SELECT a,b FROM one ORDER BY b}
+ } msg]
+ lappend v $msg
+} {1 {no such table: one}}
+
+# Test commits and rollbacks of table CREATE TABLEs, CREATE INDEXs
+# DROP TABLEs and DROP INDEXs
+#
+do_test trans-5.8 {
+ execsql {
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name
+ }
+} {}
+do_test trans-5.9 {
+ execsql {
+ BEGIN TRANSACTION;
+ CREATE TABLE t1(a int, b int, c int);
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {t1}
+do_test trans-5.10 {
+ execsql {
+ CREATE INDEX i1 ON t1(a);
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i1 t1}
+do_test trans-5.11 {
+ execsql {
+ COMMIT;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i1 t1}
+do_test trans-5.12 {
+ execsql {
+ BEGIN TRANSACTION;
+ CREATE TABLE t2(a int, b int, c int);
+ CREATE INDEX i2a ON t2(a);
+ CREATE INDEX i2b ON t2(b);
+ DROP TABLE t1;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i2a i2b t2}
+do_test trans-5.13 {
+ execsql {
+ ROLLBACK;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i1 t1}
+do_test trans-5.14 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {t1}
+do_test trans-5.15 {
+ execsql {
+ ROLLBACK;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i1 t1}
+do_test trans-5.16 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ CREATE TABLE t2(x int, y int, z int);
+ CREATE INDEX i2x ON t2(x);
+ CREATE INDEX i2y ON t2(y);
+ INSERT INTO t2 VALUES(1,2,3);
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i2x i2y t1 t2}
+do_test trans-5.17 {
+ execsql {
+ COMMIT;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i2x i2y t1 t2}
+do_test trans-5.18 {
+ execsql {
+ SELECT * FROM t2;
+ }
+} {1 2 3}
+do_test trans-5.19 {
+ execsql {
+ SELECT x FROM t2 WHERE y=2;
+ }
+} {1}
+do_test trans-5.20 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ DROP TABLE t2;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {}
+do_test trans-5.21 {
+ set r [catch {execsql {
+ SELECT * FROM t2
+ }} msg]
+ lappend r $msg
+} {1 {no such table: t2}}
+do_test trans-5.22 {
+ execsql {
+ ROLLBACK;
+ SELECT name fROM sqlite_master
+ WHERE type='table' OR type='index'
+ ORDER BY name;
+ }
+} {i2x i2y t1 t2}
+do_test trans-5.23 {
+ execsql {
+ SELECT * FROM t2;
+ }
+} {1 2 3}
+integrity_check trans-5.23
+
+
+# Try to DROP and CREATE tables and indices with the same name
+# within a transaction. Make sure ROLLBACK works.
+#
+do_test trans-6.1 {
+ execsql2 {
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(p,q,r);
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {a 1 b 2 c 3}
+do_test trans-6.2 {
+ execsql2 {
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(p,q,r);
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {}
+do_test trans-6.3 {
+ execsql2 {
+ INSERT INTO t1 VALUES(1,2,3);
+ SELECT * FROM t1;
+ }
+} {p 1 q 2 r 3}
+do_test trans-6.4 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(4,5,6);
+ SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+} {a 4 b 5 c 6}
+do_test trans-6.5 {
+ execsql2 {
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {p 1 q 2 r 3}
+do_test trans-6.6 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(4,5,6);
+ SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+} {a 4 b 5 c 6}
+do_test trans-6.7 {
+ catchsql {
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {1 {no such table: t1}}
+
+# Repeat on a table with an automatically generated index.
+#
+do_test trans-6.10 {
+ execsql2 {
+ CREATE TABLE t1(a unique,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(p unique,q,r);
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {a 1 b 2 c 3}
+do_test trans-6.11 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(p unique,q,r);
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {}
+do_test trans-6.12 {
+ execsql2 {
+ INSERT INTO t1 VALUES(1,2,3);
+ SELECT * FROM t1;
+ }
+} {p 1 q 2 r 3}
+do_test trans-6.13 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a unique,b,c);
+ INSERT INTO t1 VALUES(4,5,6);
+ SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+} {a 4 b 5 c 6}
+do_test trans-6.14 {
+ execsql2 {
+ ROLLBACK;
+ SELECT * FROM t1;
+ }
+} {p 1 q 2 r 3}
+do_test trans-6.15 {
+ execsql2 {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a unique,b,c);
+ INSERT INTO t1 VALUES(4,5,6);
+ SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+} {a 4 b 5 c 6}
+do_test trans-6.16 {
+ catchsql {
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {1 {no such table: t1}}
+
+do_test trans-6.20 {
+ execsql {
+ CREATE TABLE t1(a integer primary key,b,c);
+ INSERT INTO t1 VALUES(1,-2,-3);
+ INSERT INTO t1 VALUES(4,-5,-6);
+ SELECT * FROM t1;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.21 {
+ execsql {
+ CREATE INDEX i1 ON t1(b);
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.22 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ SELECT * FROM t1 WHERE b<1;
+ ROLLBACK;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.23 {
+ execsql {
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.24 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ ROLLBACK;
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+
+do_test trans-6.25 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ CREATE INDEX i1 ON t1(c);
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.26 {
+ execsql {
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.27 {
+ execsql {
+ ROLLBACK;
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.28 {
+ execsql {
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {1 -2 -3 4 -5 -6}
+
+# The following repeats steps 6.20 through 6.28, but puts a "unique"
+# constraint the first field of the table in order to generate an
+# automatic index.
+#
+do_test trans-6.30 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ CREATE TABLE t1(a int unique,b,c);
+ COMMIT;
+ INSERT INTO t1 VALUES(1,-2,-3);
+ INSERT INTO t1 VALUES(4,-5,-6);
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.31 {
+ execsql {
+ CREATE INDEX i1 ON t1(b);
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.32 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ SELECT * FROM t1 WHERE b<1;
+ ROLLBACK;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.33 {
+ execsql {
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.34 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP TABLE t1;
+ ROLLBACK;
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+
+do_test trans-6.35 {
+ execsql {
+ BEGIN TRANSACTION;
+ DROP INDEX i1;
+ CREATE INDEX i1 ON t1(c);
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.36 {
+ execsql {
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.37 {
+ execsql {
+ DROP INDEX i1;
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {1 -2 -3 4 -5 -6}
+do_test trans-6.38 {
+ execsql {
+ ROLLBACK;
+ SELECT * FROM t1 WHERE b<1;
+ }
+} {4 -5 -6 1 -2 -3}
+do_test trans-6.39 {
+ execsql {
+ SELECT * FROM t1 WHERE c<1;
+ }
+} {1 -2 -3 4 -5 -6}
+integrity_check trans-6.40
+
+# Test to make sure rollback restores the database back to its original
+# state.
+#
+do_test trans-7.1 {
+ execsql {BEGIN}
+ for {set i 0} {$i<1000} {incr i} {
+ set r1 [expr {rand()}]
+ set r2 [expr {rand()}]
+ set r3 [expr {rand()}]
+ execsql "INSERT INTO t2 VALUES($r1,$r2,$r3)"
+ }
+ execsql {COMMIT}
+ set ::checksum [execsql {SELECT md5sum(x,y,z) FROM t2}]
+ set ::checksum2 [
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+ ]
+ execsql {SELECT count(*) FROM t2}
+} {1001}
+do_test trans-7.2 {
+ execsql {SELECT md5sum(x,y,z) FROM t2}
+} $checksum
+do_test trans-7.2.1 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+do_test trans-7.3 {
+ execsql {
+ BEGIN;
+ DELETE FROM t2;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+} $checksum
+do_test trans-7.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO t2 SELECT * FROM t2;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+} $checksum
+do_test trans-7.5 {
+ execsql {
+ BEGIN;
+ DELETE FROM t2;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+} $checksum
+do_test trans-7.6 {
+ execsql {
+ BEGIN;
+ INSERT INTO t2 SELECT * FROM t2;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+} $checksum
+do_test trans-7.7 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t3 AS SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t3;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+} $checksum
+do_test trans-7.8 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+ifcapable tempdb {
+ do_test trans-7.9 {
+ execsql {
+ BEGIN;
+ CREATE TEMP TABLE t3 AS SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t3;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+ } $checksum
+}
+do_test trans-7.10 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+ifcapable tempdb {
+ do_test trans-7.11 {
+ execsql {
+ BEGIN;
+ CREATE TEMP TABLE t3 AS SELECT * FROM t2;
+ INSERT INTO t2 SELECT * FROM t3;
+ DROP INDEX i2x;
+ DROP INDEX i2y;
+ CREATE INDEX i3a ON t3(x);
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+ } $checksum
+}
+do_test trans-7.12 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+ifcapable tempdb {
+ do_test trans-7.13 {
+ execsql {
+ BEGIN;
+ DROP TABLE t2;
+ ROLLBACK;
+ SELECT md5sum(x,y,z) FROM t2;
+ }
+ } $checksum
+}
+do_test trans-7.14 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+integrity_check trans-7.15
+wal_check_journal_mode trans-7.16
+
+# Arrange for another process to begin modifying the database but abort
+# and die in the middle of the modification. Then have this process read
+# the database. This process should detect the journal file and roll it
+# back. Verify that this happens correctly.
+#
+set fd [open test.tcl w]
+puts $fd {
+ sqlite3_test_control_pending_byte 0x0010000
+ sqlite3 db test.db
+ db eval {
+ PRAGMA default_cache_size=20;
+ BEGIN;
+ CREATE TABLE t3 AS SELECT * FROM t2;
+ DELETE FROM t2;
+ }
+ sqlite_abort
+}
+close $fd
+do_test trans-8.1 {
+ catch {exec [info nameofexec] test.tcl}
+ execsql {SELECT md5sum(x,y,z) FROM t2}
+} $checksum
+do_test trans-8.2 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+integrity_check trans-8.3
+set fd [open test.tcl w]
+puts $fd {
+ sqlite3_test_control_pending_byte 0x0010000
+ sqlite3 db test.db
+ db eval {
+ PRAGMA journal_mode=persist;
+ PRAGMA default_cache_size=20;
+ BEGIN;
+ CREATE TABLE t3 AS SELECT * FROM t2;
+ DELETE FROM t2;
+ }
+ sqlite_abort
+}
+close $fd
+do_test trans-8.4 {
+ catch {exec [info nameofexec] test.tcl}
+ execsql {SELECT md5sum(x,y,z) FROM t2}
+} $checksum
+do_test trans-8.5 {
+ execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
+} $checksum2
+integrity_check trans-8.6
+wal_check_journal_mode trans-8.7
+
+# In the following sequence of tests, compute the MD5 sum of the content
+# of a table, make lots of modifications to that table, then do a rollback.
+# Verify that after the rollback, the MD5 checksum is unchanged.
+#
+do_test trans-9.1 {
+ execsql {
+ PRAGMA default_cache_size=10;
+ }
+ db close
+ sqlite3 db test.db
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(x TEXT);
+ INSERT INTO t3 VALUES(randstr(10,400));
+ INSERT INTO t3 VALUES(randstr(10,400));
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3;
+ COMMIT;
+ SELECT count(*) FROM t3;
+ }
+} {1024}
+wal_check_journal_mode trans-9.1.1
+
+# The following procedure computes a "signature" for table "t3". If
+# T3 changes in any way, the signature should change.
+#
+# This is used to test ROLLBACK. We gather a signature for t3, then
+# make lots of changes to t3, then rollback and take another signature.
+# The two signatures should be the same.
+#
+proc signature {} {
+ return [db eval {SELECT count(*), md5sum(x) FROM t3}]
+}
+
+# Repeat the following group of tests 20 times for quick testing and
+# 40 times for full testing. Each iteration of the test makes table
+# t3 a little larger, and thus takes a little longer, so doing 40 tests
+# is more than 2.0 times slower than doing 20 tests. Considerably more.
+#
+# Also, if temporary tables are stored in memory and the test pcache
+# is in use, only 20 iterations. Otherwise the test pcache runs out
+# of page slots and SQLite reports "out of memory".
+#
+if {[info exists G(isquick)] || (
+ $TEMP_STORE==3 && [regexp {^pcache[[:digit:]]*$} [permutation]]
+) } {
+ set limit 20
+} elseif {[info exists G(issoak)]} {
+ set limit 100
+} else {
+ set limit 40
+}
+
+# Do rollbacks. Make sure the signature does not change.
+#
+for {set i 2} {$i<=$limit} {incr i} {
+ set ::sig [signature]
+ set cnt [lindex $::sig 0]
+ if {$i%2==0} {
+ execsql {PRAGMA fullfsync=ON}
+ } else {
+ execsql {PRAGMA fullfsync=OFF}
+ }
+ set sqlite_sync_count 0
+ set sqlite_fullsync_count 0
+ do_test trans-9.$i.1-$cnt {
+ execsql {
+ BEGIN;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ ROLLBACK;
+ }
+ signature
+ } $sig
+ do_test trans-9.$i.2-$cnt {
+ execsql {
+ BEGIN;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ DELETE FROM t3 WHERE random()%10!=0;
+ INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
+ ROLLBACK;
+ }
+ signature
+ } $sig
+ if {$i<$limit} {
+ do_test trans-9.$i.3-$cnt {
+ execsql {
+ INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE random()%10==0;
+ }
+ } {}
+ catch flush_async_queue
+ if {$tcl_platform(platform)=="unix"} {
+ do_test trans-9.$i.4-$cnt {
+ expr {$sqlite_sync_count>0}
+ } 1
+ ifcapable pager_pragmas {
+ do_test trans-9.$i.5-$cnt {
+ expr {$sqlite_fullsync_count>0}
+ } [expr {$i%2==0}]
+ } else {
+ do_test trans-9.$i.5-$cnt {
+ expr {$sqlite_fullsync_count==0}
+ } {1}
+ }
+ }
+ }
+
+ wal_check_journal_mode trans-9.$i.6-$cnt
+ set ::pager_old_format 0
+}
+
+finish_test
diff --git a/test/trans2.test b/test/trans2.test
new file mode 100644
index 0000000..cfd3e67
--- /dev/null
+++ b/test/trans2.test
@@ -0,0 +1,232 @@
+# 2008 August 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. The
+# focus of this script is transactions
+#
+# $Id: trans2.test,v 1.1 2008/08/27 18:56:36 drh Exp $
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# A procedure to scramble the elements of list $inlist into a random order.
+#
+proc scramble {inlist} {
+ set y {}
+ foreach x $inlist {
+ lappend y [list [expr {rand()}] $x]
+ }
+ set y [lsort $y]
+ set outlist {}
+ foreach x $y {
+ lappend outlist [lindex $x 1]
+ }
+ return $outlist
+}
+
+# Generate a UUID using randomness.
+#
+expr srand(1)
+proc random_uuid {} {
+ set u {}
+ for {set i 0} {$i<5} {incr i} {
+ append u [format %06x [expr {int(rand()*16777216)}]]
+ }
+ return $u
+}
+
+# Compute hashes on the u1 and u2 fields of the sample data.
+#
+proc hash1 {} {
+ global data
+ set x ""
+ foreach rec [lsort -integer -index 0 $data] {
+ append x [lindex $rec 1]
+ }
+ return [md5 $x]
+}
+proc hash2 {} {
+ global data
+ set x ""
+ foreach rec [lsort -integer -index 0 $data] {
+ append x [lindex $rec 3]
+ }
+ return [md5 $x]
+}
+
+# Create the initial data set
+#
+unset -nocomplain data i max_rowid todel n rec max1 id origres newres
+unset -nocomplain inssql modsql s j z
+set data {}
+for {set i 0} {$i<400} {incr i} {
+ set rec [list $i [random_uuid] [expr {int(rand()*5000)+1000}] [random_uuid]]
+ lappend data $rec
+}
+set max_rowid [expr {$i-1}]
+
+# Create the T1 table used to hold test data. Populate that table with
+# the initial data set and check hashes to make sure everything is correct.
+#
+do_test trans2-1.1 {
+ execsql {
+ PRAGMA cache_size=100;
+ CREATE TABLE t1(
+ id INTEGER PRIMARY KEY,
+ u1 TEXT UNIQUE,
+ z BLOB NOT NULL,
+ u2 TEXT UNIQUE
+ );
+ }
+ foreach rec [scramble $data] {
+ foreach {id u1 z u2} $rec break
+ db eval {INSERT INTO t1 VALUES($id,$u1,zeroblob($z),$u2)}
+ }
+ db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}
+} [list [hash1] [hash2]]
+
+# Repeat the main test loop multiple times.
+#
+for {set i 2} {$i<=30} {incr i} {
+ # Delete one row out of every 10 in the database. This will add
+ # many pages to the freelist.
+ #
+ set todel {}
+ set n [expr {[llength $data]/10}]
+ set data [scramble $data]
+ foreach rec [lrange $data 0 $n] {
+ lappend todel [lindex $rec 0]
+ }
+ set data [lrange $data [expr {$n+1}] end]
+ set max1 [lindex [lindex $data 0] 0]
+ foreach rec $data {
+ set id [lindex $rec 0]
+ if {$id>$max1} {set max1 $id}
+ }
+ set origres [list [hash1] [hash2]]
+ do_test trans2-$i.1 {
+ db eval "DELETE FROM t1 WHERE id IN ([join $todel ,])"
+ db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}
+ } $origres
+ integrity_check trans2-$i.2
+
+ # Begin a transaction and insert many new records.
+ #
+ set newdata {}
+ foreach id $todel {
+ set rec [list $id [random_uuid] \
+ [expr {int(rand()*5000)+1000}] [random_uuid]]
+ lappend newdata $rec
+ lappend data $rec
+ }
+ for {set j 1} {$j<50} {incr j} {
+ set id [expr {$max_rowid+$j}]
+ lappend todel $id
+ set rec [list $id [random_uuid] \
+ [expr {int(rand()*5000)+1000}] [random_uuid]]
+ lappend newdata $rec
+ lappend data $rec
+ }
+ set max_rowid [expr {$max_rowid+$j-1}]
+ set modsql {}
+ set inssql {}
+ set newres [list [hash1] [hash2]]
+ do_test trans2-$i.3 {
+ db eval BEGIN
+ foreach rec [scramble $newdata] {
+ foreach {id u1 z u2} $rec break
+ set s "INSERT INTO t1 VALUES($id,'$u1',zeroblob($z),'$u2');"
+ append modsql $s\n
+ append inssql $s\n
+ db eval $s
+ }
+ db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}
+ } $newres
+ integrity_check trans2-$i.4
+
+ # Do a large update that aborts do to a constraint failure near
+ # the end. This stresses the statement journal mechanism.
+ #
+ do_test trans2-$i.10 {
+ catchsql {
+ UPDATE t1 SET u1=u1||'x',
+ z = CASE WHEN id<$max_rowid
+ THEN zeroblob((random()&65535)%5000 + 1000) END;
+ }
+ } {1 {t1.z may not be NULL}}
+ do_test trans2-$i.11 {
+ db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}
+ } $newres
+
+ # Delete all of the newly inserted records. Verify that the database
+ # is back to its original state.
+ #
+ do_test trans2-$i.20 {
+ set s "DELETE FROM t1 WHERE id IN ([join $todel ,]);"
+ append modsql $s\n
+ db eval $s
+ db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}
+ } $origres
+
+ # Do another large update that aborts do to a constraint failure near
+ # the end. This stresses the statement journal mechanism.
+ #
+ do_test trans2-$i.30 {
+ catchsql {
+ UPDATE t1 SET u1=u1||'x',
+ z = CASE WHEN id<$max1
+ THEN zeroblob((random()&65535)%5000 + 1000) END;
+ }
+ } {1 {t1.z may not be NULL}}
+ do_test trans2-$i.31 {
+ db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}
+ } $origres
+
+ # Redo the inserts
+ #
+ do_test trans2-$i.40 {
+ db eval $inssql
+ append modsql $inssql
+ db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}
+ } $newres
+
+ # Rollback the transaction. Verify that the content is restored.
+ #
+ do_test trans2-$i.90 {
+ db eval ROLLBACK
+ db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}
+ } $origres
+ integrity_check trans2-$i.91
+
+ # Repeat all the changes, but this time commit.
+ #
+ do_test trans2-$i.92 {
+ db eval BEGIN
+ catchsql {
+ UPDATE t1 SET u1=u1||'x',
+ z = CASE WHEN id<$max1
+ THEN zeroblob((random()&65535)%5000 + 1000) END;
+ }
+ db eval $modsql
+ catchsql {
+ UPDATE t1 SET u1=u1||'x',
+ z = CASE WHEN id<$max1
+ THEN zeroblob((random()&65535)%5000 + 1000) END;
+ }
+ db eval COMMIT
+ db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}
+ } $newres
+ integrity_check trans2-$i.93
+}
+
+unset -nocomplain data i max_rowid todel n rec max1 id origres newres
+unset -nocomplain inssql modsql s j z
+finish_test
diff --git a/test/trans3.test b/test/trans3.test
new file mode 100644
index 0000000..ab7db6a
--- /dev/null
+++ b/test/trans3.test
@@ -0,0 +1,77 @@
+# 2008 November 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements regression tests for SQLite library. The
+# focus of this script is the response of COMMIT and ROLLBACK when
+# statements are still pending.
+#
+# $Id: trans3.test,v 1.2 2008/11/05 16:37:35 drh Exp $
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+unset -nocomplain ecode
+
+do_test trans3-1.1 {
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ SELECT * FROM t1;
+ }
+} {1 2 3}
+do_test trans3-1.2 {
+ db eval BEGIN
+ db eval {INSERT INTO t1 VALUES(4);}
+ set ::ecode {}
+ set x [catch {
+ db eval {SELECT * FROM t1 LIMIT 1} {
+ if {[catch {db eval COMMIT} errmsg]} {
+ set ::ecode [sqlite3_extended_errcode db]
+ error $errmsg
+ }
+ }
+ } errmsg]
+ lappend x $errmsg
+} {0 {}}
+do_test trans3-1.3 {
+ set ::ecode
+} {}
+do_test trans3-1.3.1 {
+ sqlite3_get_autocommit db
+} 1
+do_test trans3-1.4 {
+ db eval {SELECT * FROM t1}
+} {1 2 3 4}
+do_test trans3-1.5 {
+ db eval BEGIN
+ db eval {INSERT INTO t1 VALUES(5);}
+ set ::ecode {}
+ set x [catch {
+ db eval {SELECT * FROM t1} {
+ if {[catch {db eval ROLLBACK} errmsg]} {
+ set ::ecode [sqlite3_extended_errcode db]
+ error $errmsg
+ }
+ }
+ } errmsg]
+ lappend x $errmsg
+} {1 {cannot rollback transaction - SQL statements in progress}}
+do_test trans3-1.6 {
+ set ::ecode
+} {SQLITE_BUSY}
+do_test trans3-1.7 {
+ db eval COMMIT
+ db eval {SELECT * FROM t1}
+} {1 2 3 4 5}
+unset -nocomplain ecode
+
+finish_test
diff --git a/test/trigger1.test b/test/trigger1.test
new file mode 100644
index 0000000..dc344d4
--- /dev/null
+++ b/test/trigger1.test
@@ -0,0 +1,702 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file tests creating and dropping triggers, and interaction thereof
+# with the database COMMIT/ROLLBACK logic.
+#
+# 1. CREATE and DROP TRIGGER tests
+# trig-1.1: Error if table does not exist
+# trig-1.2: Error if trigger already exists
+# trig-1.3: Created triggers are deleted if the transaction is rolled back
+# trig-1.4: DROP TRIGGER removes trigger
+# trig-1.5: Dropped triggers are restored if the transaction is rolled back
+# trig-1.6: Error if dropped trigger doesn't exist
+# trig-1.7: Dropping the table automatically drops all triggers
+# trig-1.8: A trigger created on a TEMP table is not inserted into sqlite_master
+# trig-1.9: Ensure that we cannot create a trigger on sqlite_master
+# trig-1.10:
+# trig-1.11:
+# trig-1.12: Ensure that INSTEAD OF triggers cannot be created on tables
+# trig-1.13: Ensure that AFTER triggers cannot be created on views
+# trig-1.14: Ensure that BEFORE triggers cannot be created on views
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+do_test trigger1-1.1.1 {
+ catchsql {
+ CREATE TRIGGER trig UPDATE ON no_such_table BEGIN
+ SELECT * from sqlite_master;
+ END;
+ }
+} {1 {no such table: main.no_such_table}}
+
+ifcapable tempdb {
+ do_test trigger1-1.1.2 {
+ catchsql {
+ CREATE TEMP TRIGGER trig UPDATE ON no_such_table BEGIN
+ SELECT * from sqlite_master;
+ END;
+ }
+ } {1 {no such table: no_such_table}}
+}
+
+execsql {
+ CREATE TABLE t1(a);
+}
+do_test trigger1-1.1.3 {
+ catchsql {
+ CREATE TRIGGER trig UPDATE ON t1 FOR EACH STATEMENT BEGIN
+ SELECT * FROM sqlite_master;
+ END;
+ }
+} {1 {near "STATEMENT": syntax error}}
+execsql {
+ CREATE TRIGGER tr1 INSERT ON t1 BEGIN
+ INSERT INTO t1 values(1);
+ END;
+}
+do_test trigger1-1.2.0 {
+ catchsql {
+ CREATE TRIGGER IF NOT EXISTS tr1 DELETE ON t1 BEGIN
+ SELECT * FROM sqlite_master;
+ END
+ }
+} {0 {}}
+do_test trigger1-1.2.1 {
+ catchsql {
+ CREATE TRIGGER tr1 DELETE ON t1 BEGIN
+ SELECT * FROM sqlite_master;
+ END
+ }
+} {1 {trigger tr1 already exists}}
+do_test trigger1-1.2.2 {
+ catchsql {
+ CREATE TRIGGER "tr1" DELETE ON t1 BEGIN
+ SELECT * FROM sqlite_master;
+ END
+ }
+} {1 {trigger "tr1" already exists}}
+do_test trigger1-1.2.3 {
+ catchsql {
+ CREATE TRIGGER [tr1] DELETE ON t1 BEGIN
+ SELECT * FROM sqlite_master;
+ END
+ }
+} {1 {trigger [tr1] already exists}}
+
+do_test trigger1-1.3 {
+ catchsql {
+ BEGIN;
+ CREATE TRIGGER tr2 INSERT ON t1 BEGIN
+ SELECT * from sqlite_master; END;
+ ROLLBACK;
+ CREATE TRIGGER tr2 INSERT ON t1 BEGIN
+ SELECT * from sqlite_master; END;
+ }
+} {0 {}}
+
+do_test trigger1-1.4 {
+ catchsql {
+ DROP TRIGGER IF EXISTS tr1;
+ CREATE TRIGGER tr1 DELETE ON t1 BEGIN
+ SELECT * FROM sqlite_master;
+ END
+ }
+} {0 {}}
+
+do_test trigger1-1.5 {
+ execsql {
+ BEGIN;
+ DROP TRIGGER tr2;
+ ROLLBACK;
+ DROP TRIGGER tr2;
+ }
+} {}
+
+do_test trigger1-1.6.1 {
+ catchsql {
+ DROP TRIGGER IF EXISTS biggles;
+ }
+} {0 {}}
+
+do_test trigger1-1.6.2 {
+ catchsql {
+ DROP TRIGGER biggles;
+ }
+} {1 {no such trigger: biggles}}
+
+do_test trigger1-1.7 {
+ catchsql {
+ DROP TABLE t1;
+ DROP TRIGGER tr1;
+ }
+} {1 {no such trigger: tr1}}
+
+ifcapable tempdb {
+ execsql {
+ CREATE TEMP TABLE temp_table(a);
+ }
+ do_test trigger1-1.8 {
+ execsql {
+ CREATE TRIGGER temp_trig UPDATE ON temp_table BEGIN
+ SELECT * from sqlite_master;
+ END;
+ SELECT count(*) FROM sqlite_master WHERE name = 'temp_trig';
+ }
+ } {0}
+}
+
+do_test trigger1-1.9 {
+ catchsql {
+ CREATE TRIGGER tr1 AFTER UPDATE ON sqlite_master BEGIN
+ SELECT * FROM sqlite_master;
+ END;
+ }
+} {1 {cannot create trigger on system table}}
+
+# Check to make sure that a DELETE statement within the body of
+# a trigger does not mess up the DELETE that caused the trigger to
+# run in the first place.
+#
+do_test trigger1-1.10 {
+ execsql {
+ create table t1(a,b);
+ insert into t1 values(1,'a');
+ insert into t1 values(2,'b');
+ insert into t1 values(3,'c');
+ insert into t1 values(4,'d');
+ create trigger r1 after delete on t1 for each row begin
+ delete from t1 WHERE a=old.a+2;
+ end;
+ delete from t1 where a=1 OR a=3;
+ select * from t1;
+ drop table t1;
+ }
+} {2 b 4 d}
+
+do_test trigger1-1.11 {
+ execsql {
+ create table t1(a,b);
+ insert into t1 values(1,'a');
+ insert into t1 values(2,'b');
+ insert into t1 values(3,'c');
+ insert into t1 values(4,'d');
+ create trigger r1 after update on t1 for each row begin
+ delete from t1 WHERE a=old.a+2;
+ end;
+ update t1 set b='x-' || b where a=1 OR a=3;
+ select * from t1;
+ drop table t1;
+ }
+} {1 x-a 2 b 4 d}
+
+# Ensure that we cannot create INSTEAD OF triggers on tables
+do_test trigger1-1.12 {
+ catchsql {
+ create table t1(a,b);
+ create trigger t1t instead of update on t1 for each row begin
+ delete from t1 WHERE a=old.a+2;
+ end;
+ }
+} {1 {cannot create INSTEAD OF trigger on table: main.t1}}
+
+ifcapable view {
+# Ensure that we cannot create BEFORE triggers on views
+do_test trigger1-1.13 {
+ catchsql {
+ create view v1 as select * from t1;
+ create trigger v1t before update on v1 for each row begin
+ delete from t1 WHERE a=old.a+2;
+ end;
+ }
+} {1 {cannot create BEFORE trigger on view: main.v1}}
+# Ensure that we cannot create AFTER triggers on views
+do_test trigger1-1.14 {
+ catchsql {
+ drop view v1;
+ create view v1 as select * from t1;
+ create trigger v1t AFTER update on v1 for each row begin
+ delete from t1 WHERE a=old.a+2;
+ end;
+ }
+} {1 {cannot create AFTER trigger on view: main.v1}}
+} ;# ifcapable view
+
+# Check for memory leaks in the trigger parser
+#
+do_test trigger1-2.1 {
+ catchsql {
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ SELECT * FROM; -- Syntax error
+ END;
+ }
+} {1 {near ";": syntax error}}
+do_test trigger1-2.2 {
+ catchsql {
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ SELECT * FROM t1;
+ SELECT * FROM; -- Syntax error
+ END;
+ }
+} {1 {near ";": syntax error}}
+
+# Create a trigger that refers to a table that might not exist.
+#
+ifcapable tempdb {
+ do_test trigger1-3.1 {
+ execsql {
+ CREATE TEMP TABLE t2(x,y);
+ }
+ catchsql {
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(NEW.a,NEW.b);
+ END;
+ }
+ } {0 {}}
+ do_test trigger-3.2 {
+ catchsql {
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+ } {1 {no such table: main.t2}}
+ do_test trigger-3.3 {
+ db close
+ set rc [catch {sqlite3 db test.db} err]
+ if {$rc} {lappend rc $err}
+ set rc
+ } {0}
+ do_test trigger-3.4 {
+ catchsql {
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+ } {1 {no such table: main.t2}}
+ do_test trigger-3.5 {
+ catchsql {
+ CREATE TEMP TABLE t2(x,y);
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+ } {1 {no such table: main.t2}}
+ do_test trigger-3.6 {
+ catchsql {
+ DROP TRIGGER r1;
+ CREATE TEMP TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(NEW.a,NEW.b);
+ END;
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+ } {0 {1 2}}
+ do_test trigger-3.7 {
+ execsql {
+ DROP TABLE t2;
+ CREATE TABLE t2(x,y);
+ SELECT * FROM t2;
+ }
+ } {}
+
+ # There are two versions of trigger-3.8 and trigger-3.9. One that uses
+ # compound SELECT statements, and another that does not.
+ ifcapable compound {
+ do_test trigger1-3.8 {
+ execsql {
+ INSERT INTO t1 VALUES(3,4);
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2;
+ }
+ } {1 2 3 4 3 4}
+ do_test trigger1-3.9 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ INSERT INTO t1 VALUES(5,6);
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2;
+ }
+ } {1 2 3 4 5 6 3 4}
+ } ;# ifcapable compound
+ ifcapable !compound {
+ do_test trigger1-3.8 {
+ execsql {
+ INSERT INTO t1 VALUES(3,4);
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+ } {1 2 3 4 3 4}
+ do_test trigger1-3.9 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ INSERT INTO t1 VALUES(5,6);
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+ } {1 2 3 4 5 6 3 4}
+ } ;# ifcapable !compound
+
+ do_test trigger1-4.1 {
+ execsql {
+ CREATE TEMP TRIGGER r1 BEFORE INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(NEW.a,NEW.b);
+ END;
+ INSERT INTO t1 VALUES(7,8);
+ SELECT * FROM t2;
+ }
+ } {3 4 7 8}
+ do_test trigger1-4.2 {
+ sqlite3 db2 test.db
+ execsql {
+ INSERT INTO t1 VALUES(9,10);
+ } db2;
+ db2 close
+ execsql {
+ SELECT * FROM t2;
+ }
+ } {3 4 7 8}
+ do_test trigger1-4.3 {
+ execsql {
+ DROP TABLE t1;
+ SELECT * FROM t2;
+ };
+ } {3 4 7 8}
+ do_test trigger1-4.4 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM t2;
+ };
+ } {3 4 7 8}
+} else {
+ execsql {
+ CREATE TABLE t2(x,y);
+ DROP TABLE t1;
+ INSERT INTO t2 VALUES(3, 4);
+ INSERT INTO t2 VALUES(7, 8);
+ }
+}
+
+
+integrity_check trigger1-5.1
+
+# Create a trigger with the same name as a table. Make sure the
+# trigger works. Then drop the trigger. Make sure the table is
+# still there.
+#
+set view_v1 {}
+ifcapable view {
+ set view_v1 {view v1}
+}
+do_test trigger1-6.1 {
+ execsql {SELECT type, name FROM sqlite_master}
+} [concat $view_v1 {table t2}]
+do_test trigger1-6.2 {
+ execsql {
+ CREATE TRIGGER t2 BEFORE DELETE ON t2 BEGIN
+ SELECT RAISE(ABORT,'deletes are not permitted');
+ END;
+ SELECT type, name FROM sqlite_master;
+ }
+} [concat $view_v1 {table t2 trigger t2}]
+do_test trigger1-6.3 {
+ catchsql {DELETE FROM t2}
+} {1 {deletes are not permitted}}
+do_test trigger1-6.4 {
+ execsql {SELECT * FROM t2}
+} {3 4 7 8}
+do_test trigger1-6.5 {
+ db close
+ sqlite3 db test.db
+ execsql {SELECT type, name FROM sqlite_master}
+} [concat $view_v1 {table t2 trigger t2}]
+do_test trigger1-6.6 {
+ execsql {
+ DROP TRIGGER t2;
+ SELECT type, name FROM sqlite_master;
+ }
+} [concat $view_v1 {table t2}]
+do_test trigger1-6.7 {
+ execsql {SELECT * FROM t2}
+} {3 4 7 8}
+do_test trigger1-6.8 {
+ db close
+ sqlite3 db test.db
+ execsql {SELECT * FROM t2}
+} {3 4 7 8}
+
+integrity_check trigger-7.1
+
+# Check to make sure the name of a trigger can be quoted so that keywords
+# can be used as trigger names. Ticket #468
+#
+do_test trigger1-8.1 {
+ execsql {
+ CREATE TRIGGER 'trigger' AFTER INSERT ON t2 BEGIN SELECT 1; END;
+ SELECT name FROM sqlite_master WHERE type='trigger';
+ }
+} {trigger}
+do_test trigger1-8.2 {
+ execsql {
+ DROP TRIGGER 'trigger';
+ SELECT name FROM sqlite_master WHERE type='trigger';
+ }
+} {}
+do_test trigger1-8.3 {
+ execsql {
+ CREATE TRIGGER "trigger" AFTER INSERT ON t2 BEGIN SELECT 1; END;
+ SELECT name FROM sqlite_master WHERE type='trigger';
+ }
+} {trigger}
+do_test trigger1-8.4 {
+ execsql {
+ DROP TRIGGER "trigger";
+ SELECT name FROM sqlite_master WHERE type='trigger';
+ }
+} {}
+do_test trigger1-8.5 {
+ execsql {
+ CREATE TRIGGER [trigger] AFTER INSERT ON t2 BEGIN SELECT 1; END;
+ SELECT name FROM sqlite_master WHERE type='trigger';
+ }
+} {trigger}
+do_test trigger1-8.6 {
+ execsql {
+ DROP TRIGGER [trigger];
+ SELECT name FROM sqlite_master WHERE type='trigger';
+ }
+} {}
+
+ifcapable conflict {
+ # Make sure REPLACE works inside of triggers.
+ #
+ # There are two versions of trigger-9.1 and trigger-9.2. One that uses
+ # compound SELECT statements, and another that does not.
+ ifcapable compound {
+ do_test trigger1-9.1 {
+ execsql {
+ CREATE TABLE t3(a,b);
+ CREATE TABLE t4(x UNIQUE, b);
+ CREATE TRIGGER r34 AFTER INSERT ON t3 BEGIN
+ REPLACE INTO t4 VALUES(new.a,new.b);
+ END;
+ INSERT INTO t3 VALUES(1,2);
+ SELECT * FROM t3 UNION ALL SELECT 99, 99 UNION ALL SELECT * FROM t4;
+ }
+ } {1 2 99 99 1 2}
+ do_test trigger1-9.2 {
+ execsql {
+ INSERT INTO t3 VALUES(1,3);
+ SELECT * FROM t3 UNION ALL SELECT 99, 99 UNION ALL SELECT * FROM t4;
+ }
+ } {1 2 1 3 99 99 1 3}
+ } else {
+ do_test trigger1-9.1 {
+ execsql {
+ CREATE TABLE t3(a,b);
+ CREATE TABLE t4(x UNIQUE, b);
+ CREATE TRIGGER r34 AFTER INSERT ON t3 BEGIN
+ REPLACE INTO t4 VALUES(new.a,new.b);
+ END;
+ INSERT INTO t3 VALUES(1,2);
+ SELECT * FROM t3; SELECT 99, 99; SELECT * FROM t4;
+ }
+ } {1 2 99 99 1 2}
+ do_test trigger1-9.2 {
+ execsql {
+ INSERT INTO t3 VALUES(1,3);
+ SELECT * FROM t3; SELECT 99, 99; SELECT * FROM t4;
+ }
+ } {1 2 1 3 99 99 1 3}
+ }
+ execsql {
+ DROP TABLE t3;
+ DROP TABLE t4;
+ }
+}
+
+
+# Ticket #764. At one stage TEMP triggers would fail to re-install when the
+# schema was reloaded. The following tests ensure that TEMP triggers are
+# correctly re-installed.
+#
+# Also verify that references within trigger programs are resolved at
+# statement compile time, not trigger installation time. This means, for
+# example, that you can drop and re-create tables referenced by triggers.
+ifcapable tempdb&&attach {
+ do_test trigger1-10.0 {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ }
+ } {}
+ do_test trigger1-10.1 {
+ execsql {
+ CREATE TABLE main.t4(a, b, c);
+ CREATE TABLE temp.t4(a, b, c);
+ CREATE TABLE aux.t4(a, b, c);
+ CREATE TABLE insert_log(db, a, b, c);
+ }
+ } {}
+ do_test trigger1-10.2 {
+ execsql {
+ CREATE TEMP TRIGGER trig1 AFTER INSERT ON main.t4 BEGIN
+ INSERT INTO insert_log VALUES('main', new.a, new.b, new.c);
+ END;
+ CREATE TEMP TRIGGER trig2 AFTER INSERT ON temp.t4 BEGIN
+ INSERT INTO insert_log VALUES('temp', new.a, new.b, new.c);
+ END;
+ CREATE TEMP TRIGGER trig3 AFTER INSERT ON aux.t4 BEGIN
+ INSERT INTO insert_log VALUES('aux', new.a, new.b, new.c);
+ END;
+ }
+ } {}
+ do_test trigger1-10.3 {
+ execsql {
+ INSERT INTO main.t4 VALUES(1, 2, 3);
+ INSERT INTO temp.t4 VALUES(4, 5, 6);
+ INSERT INTO aux.t4 VALUES(7, 8, 9);
+ }
+ } {}
+ do_test trigger1-10.4 {
+ execsql {
+ SELECT * FROM insert_log;
+ }
+ } {main 1 2 3 temp 4 5 6 aux 7 8 9}
+ do_test trigger1-10.5 {
+ execsql {
+ BEGIN;
+ INSERT INTO main.t4 VALUES(1, 2, 3);
+ INSERT INTO temp.t4 VALUES(4, 5, 6);
+ INSERT INTO aux.t4 VALUES(7, 8, 9);
+ ROLLBACK;
+ }
+ } {}
+ do_test trigger1-10.6 {
+ execsql {
+ SELECT * FROM insert_log;
+ }
+ } {main 1 2 3 temp 4 5 6 aux 7 8 9}
+ do_test trigger1-10.7 {
+ execsql {
+ DELETE FROM insert_log;
+ INSERT INTO main.t4 VALUES(11, 12, 13);
+ INSERT INTO temp.t4 VALUES(14, 15, 16);
+ INSERT INTO aux.t4 VALUES(17, 18, 19);
+ }
+ } {}
+ do_test trigger1-10.8 {
+ execsql {
+ SELECT * FROM insert_log;
+ }
+ } {main 11 12 13 temp 14 15 16 aux 17 18 19}
+ do_test trigger1-10.8 {
+ # Drop and re-create the insert_log table in a different database. Note
+ # that we can change the column names because the trigger programs don't
+ # use them explicitly.
+ execsql {
+ DROP TABLE insert_log;
+ CREATE TABLE aux.insert_log(db, d, e, f);
+ }
+ } {}
+ do_test trigger1-10.10 {
+ execsql {
+ INSERT INTO main.t4 VALUES(21, 22, 23);
+ INSERT INTO temp.t4 VALUES(24, 25, 26);
+ INSERT INTO aux.t4 VALUES(27, 28, 29);
+ }
+ } {}
+ do_test trigger1-10.11 {
+ execsql {
+ SELECT * FROM insert_log;
+ }
+ } {main 21 22 23 temp 24 25 26 aux 27 28 29}
+}
+
+do_test trigger1-11.1 {
+ catchsql {SELECT raise(abort,'message');}
+} {1 {RAISE() may only be used within a trigger-program}}
+
+do_test trigger1-15.1 {
+ execsql {
+ CREATE TABLE tA(a INTEGER PRIMARY KEY, b, c);
+ CREATE TRIGGER tA_trigger BEFORE UPDATE ON "tA" BEGIN SELECT 1; END;
+ INSERT INTO tA VALUES(1, 2, 3);
+ }
+ catchsql { UPDATE tA SET a = 'abc' }
+} {1 {datatype mismatch}}
+do_test trigger1-15.2 {
+ catchsql { INSERT INTO tA VALUES('abc', 2, 3) }
+} {1 {datatype mismatch}}
+
+# Ticket #3947: Do not allow qualified table names on INSERT, UPDATE, and
+# DELETE statements within triggers. Actually, this has never been allowed
+# by the grammar. But the error message is confusing: one simply gets a
+# "syntax error". That has now been changed to give a full error message.
+#
+do_test trigger1-16.1 {
+ db eval {
+ CREATE TABLE t16(a,b,c);
+ CREATE INDEX t16a ON t16(a);
+ CREATE INDEX t16b ON t16(b);
+ }
+ catchsql {
+ CREATE TRIGGER main.t16err1 AFTER INSERT ON tA BEGIN
+ INSERT INTO main.t16 VALUES(1,2,3);
+ END;
+ }
+} {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}
+do_test trigger1-16.2 {
+ catchsql {
+ CREATE TRIGGER main.t16err2 AFTER INSERT ON tA BEGIN
+ UPDATE main.t16 SET rowid=rowid+1;
+ END;
+ }
+} {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}
+do_test trigger1-16.3 {
+ catchsql {
+ CREATE TRIGGER main.t16err3 AFTER INSERT ON tA BEGIN
+ DELETE FROM main.t16;
+ END;
+ }
+} {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}
+do_test trigger1-16.4 {
+ catchsql {
+ CREATE TRIGGER main.t16err4 AFTER INSERT ON tA BEGIN
+ UPDATE t16 NOT INDEXED SET rowid=rowid+1;
+ END;
+ }
+} {1 {the NOT INDEXED clause is not allowed on UPDATE or DELETE statements within triggers}}
+do_test trigger1-16.5 {
+ catchsql {
+ CREATE TRIGGER main.t16err5 AFTER INSERT ON tA BEGIN
+ UPDATE t16 INDEXED BY t16a SET rowid=rowid+1 WHERE a=1;
+ END;
+ }
+} {1 {the INDEXED BY clause is not allowed on UPDATE or DELETE statements within triggers}}
+do_test trigger1-16.6 {
+ catchsql {
+ CREATE TRIGGER main.t16err6 AFTER INSERT ON tA BEGIN
+ DELETE FROM t16 NOT INDEXED WHERE a=123;
+ END;
+ }
+} {1 {the NOT INDEXED clause is not allowed on UPDATE or DELETE statements within triggers}}
+do_test trigger1-16.7 {
+ catchsql {
+ CREATE TRIGGER main.t16err7 AFTER INSERT ON tA BEGIN
+ DELETE FROM t16 INDEXED BY t16a WHERE a=123;
+ END;
+ }
+} {1 {the INDEXED BY clause is not allowed on UPDATE or DELETE statements within triggers}}
+
+finish_test
diff --git a/test/trigger2.test b/test/trigger2.test
new file mode 100644
index 0000000..b4b922a
--- /dev/null
+++ b/test/trigger2.test
@@ -0,0 +1,759 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Regression testing of FOR EACH ROW table triggers
+#
+# 1. Trigger execution order tests.
+# These tests ensure that BEFORE and AFTER triggers are fired at the correct
+# times relative to each other and the triggering statement.
+#
+# trigger2-1.1.*: ON UPDATE trigger execution model.
+# trigger2-1.2.*: DELETE trigger execution model.
+# trigger2-1.3.*: INSERT trigger execution model.
+#
+# 2. Trigger program execution tests.
+# These tests ensure that trigger programs execute correctly (ie. that a
+# trigger program can correctly execute INSERT, UPDATE, DELETE * SELECT
+# statements, and combinations thereof).
+#
+# 3. Selective trigger execution
+# This tests that conditional triggers (ie. UPDATE OF triggers and triggers
+# with WHEN clauses) are fired only fired when they are supposed to be.
+#
+# trigger2-3.1: UPDATE OF triggers
+# trigger2-3.2: WHEN clause
+#
+# 4. Cascaded trigger execution
+# Tests that trigger-programs may cause other triggers to fire. Also that a
+# trigger-program is never executed recursively.
+#
+# trigger2-4.1: Trivial cascading trigger
+# trigger2-4.2: Trivial recursive trigger handling
+#
+# 5. Count changes behaviour.
+# Verify that rows altered by triggers are not included in the return value
+# of the "count changes" interface.
+#
+# 6. ON CONFLICT clause handling
+# trigger2-6.1[a-f]: INSERT statements
+# trigger2-6.2[a-f]: UPDATE statements
+#
+# 7. & 8. Triggers on views fire correctly.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# The tests in this file were written before SQLite supported recursive
+# trigger invocation, and some tests depend on that to pass. So disable
+# recursive triggers for this file.
+catchsql { pragma recursive_triggers = off }
+
+# 1.
+ifcapable subquery {
+ set ii 0
+ set tbl_definitions [list \
+ {CREATE TABLE tbl (a, b);} \
+ {CREATE TABLE tbl (a INTEGER PRIMARY KEY, b);} \
+ {CREATE TABLE tbl (a, b PRIMARY KEY);} \
+ {CREATE TABLE tbl (a, b); CREATE INDEX tbl_idx ON tbl(b);} \
+ ]
+ ifcapable tempdb {
+ lappend tbl_definitions \
+ {CREATE TEMP TABLE tbl (a, b); CREATE INDEX tbl_idx ON tbl(b);}
+ lappend tbl_definitions {CREATE TEMP TABLE tbl (a, b);}
+ lappend tbl_definitions \
+ {CREATE TEMPORARY TABLE tbl (a INTEGER PRIMARY KEY, b);}
+ }
+ foreach tbl_defn $tbl_definitions {
+ incr ii
+ catchsql { DROP INDEX tbl_idx; }
+ catchsql {
+ DROP TABLE rlog;
+ DROP TABLE clog;
+ DROP TABLE tbl;
+ DROP TABLE other_tbl;
+ }
+
+ execsql $tbl_defn
+
+ execsql {
+ INSERT INTO tbl VALUES(1, 2);
+ INSERT INTO tbl VALUES(3, 4);
+
+ CREATE TABLE rlog (idx, old_a, old_b, db_sum_a, db_sum_b, new_a, new_b);
+ CREATE TABLE clog (idx, old_a, old_b, db_sum_a, db_sum_b, new_a, new_b);
+
+ CREATE TRIGGER before_update_row BEFORE UPDATE ON tbl FOR EACH ROW
+ BEGIN
+ INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog),
+ old.a, old.b,
+ (SELECT coalesce(sum(a),0) FROM tbl),
+ (SELECT coalesce(sum(b),0) FROM tbl),
+ new.a, new.b);
+ END;
+
+ CREATE TRIGGER after_update_row AFTER UPDATE ON tbl FOR EACH ROW
+ BEGIN
+ INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog),
+ old.a, old.b,
+ (SELECT coalesce(sum(a),0) FROM tbl),
+ (SELECT coalesce(sum(b),0) FROM tbl),
+ new.a, new.b);
+ END;
+
+ CREATE TRIGGER conditional_update_row AFTER UPDATE ON tbl FOR EACH ROW
+ WHEN old.a = 1
+ BEGIN
+ INSERT INTO clog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM clog),
+ old.a, old.b,
+ (SELECT coalesce(sum(a),0) FROM tbl),
+ (SELECT coalesce(sum(b),0) FROM tbl),
+ new.a, new.b);
+ END;
+ }
+
+ do_test trigger2-1.$ii.1 {
+ set r {}
+ foreach v [execsql {
+ UPDATE tbl SET a = a * 10, b = b * 10;
+ SELECT * FROM rlog ORDER BY idx;
+ SELECT * FROM clog ORDER BY idx;
+ }] {
+ lappend r [expr {int($v)}]
+ }
+ set r
+ } [list 1 1 2 4 6 10 20 \
+ 2 1 2 13 24 10 20 \
+ 3 3 4 13 24 30 40 \
+ 4 3 4 40 60 30 40 \
+ 1 1 2 13 24 10 20 ]
+
+ execsql {
+ DELETE FROM rlog;
+ DELETE FROM tbl;
+ INSERT INTO tbl VALUES (100, 100);
+ INSERT INTO tbl VALUES (300, 200);
+ CREATE TRIGGER delete_before_row BEFORE DELETE ON tbl FOR EACH ROW
+ BEGIN
+ INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog),
+ old.a, old.b,
+ (SELECT coalesce(sum(a),0) FROM tbl),
+ (SELECT coalesce(sum(b),0) FROM tbl),
+ 0, 0);
+ END;
+
+ CREATE TRIGGER delete_after_row AFTER DELETE ON tbl FOR EACH ROW
+ BEGIN
+ INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog),
+ old.a, old.b,
+ (SELECT coalesce(sum(a),0) FROM tbl),
+ (SELECT coalesce(sum(b),0) FROM tbl),
+ 0, 0);
+ END;
+ }
+ do_test trigger2-1.$ii.2 {
+ set r {}
+ foreach v [execsql {
+ DELETE FROM tbl;
+ SELECT * FROM rlog;
+ }] {
+ lappend r [expr {int($v)}]
+ }
+ set r
+ } [list 1 100 100 400 300 0 0 \
+ 2 100 100 300 200 0 0 \
+ 3 300 200 300 200 0 0 \
+ 4 300 200 0 0 0 0 ]
+
+ execsql {
+ DELETE FROM rlog;
+ CREATE TRIGGER insert_before_row BEFORE INSERT ON tbl FOR EACH ROW
+ BEGIN
+ INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog),
+ 0, 0,
+ (SELECT coalesce(sum(a),0) FROM tbl),
+ (SELECT coalesce(sum(b),0) FROM tbl),
+ new.a, new.b);
+ END;
+
+ CREATE TRIGGER insert_after_row AFTER INSERT ON tbl FOR EACH ROW
+ BEGIN
+ INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog),
+ 0, 0,
+ (SELECT coalesce(sum(a),0) FROM tbl),
+ (SELECT coalesce(sum(b),0) FROM tbl),
+ new.a, new.b);
+ END;
+ }
+ do_test trigger2-1.$ii.3 {
+ execsql {
+
+ CREATE TABLE other_tbl(a, b);
+ INSERT INTO other_tbl VALUES(1, 2);
+ INSERT INTO other_tbl VALUES(3, 4);
+ -- INSERT INTO tbl SELECT * FROM other_tbl;
+ INSERT INTO tbl VALUES(5, 6);
+ DROP TABLE other_tbl;
+
+ SELECT * FROM rlog;
+ }
+ } [list 1 0 0 0 0 5 6 \
+ 2 0 0 5 6 5 6 ]
+
+ integrity_check trigger2-1.$ii.4
+ }
+ catchsql {
+ DROP TABLE rlog;
+ DROP TABLE clog;
+ DROP TABLE tbl;
+ DROP TABLE other_tbl;
+ }
+}
+
+# 2.
+set ii 0
+foreach tr_program {
+ {UPDATE tbl SET b = old.b;}
+ {INSERT INTO log VALUES(new.c, 2, 3);}
+ {DELETE FROM log WHERE a = 1;}
+ {INSERT INTO tbl VALUES(500, new.b * 10, 700);
+ UPDATE tbl SET c = old.c;
+ DELETE FROM log;}
+ {INSERT INTO log select * from tbl;}
+} {
+ foreach test_varset [ list \
+ {
+ set statement {UPDATE tbl SET c = 10 WHERE a = 1;}
+ set prep {INSERT INTO tbl VALUES(1, 2, 3);}
+ set newC 10
+ set newB 2
+ set newA 1
+ set oldA 1
+ set oldB 2
+ set oldC 3
+ } \
+ {
+ set statement {DELETE FROM tbl WHERE a = 1;}
+ set prep {INSERT INTO tbl VALUES(1, 2, 3);}
+ set oldA 1
+ set oldB 2
+ set oldC 3
+ } \
+ {
+ set statement {INSERT INTO tbl VALUES(1, 2, 3);}
+ set newA 1
+ set newB 2
+ set newC 3
+ }
+ ] \
+ {
+ set statement {}
+ set prep {}
+ set newA {''}
+ set newB {''}
+ set newC {''}
+ set oldA {''}
+ set oldB {''}
+ set oldC {''}
+
+ incr ii
+
+ eval $test_varset
+
+ set statement_type [string range $statement 0 5]
+ set tr_program_fixed $tr_program
+ if {$statement_type == "DELETE"} {
+ regsub -all new\.a $tr_program_fixed {''} tr_program_fixed
+ regsub -all new\.b $tr_program_fixed {''} tr_program_fixed
+ regsub -all new\.c $tr_program_fixed {''} tr_program_fixed
+ }
+ if {$statement_type == "INSERT"} {
+ regsub -all old\.a $tr_program_fixed {''} tr_program_fixed
+ regsub -all old\.b $tr_program_fixed {''} tr_program_fixed
+ regsub -all old\.c $tr_program_fixed {''} tr_program_fixed
+ }
+
+
+ set tr_program_cooked $tr_program
+ regsub -all new\.a $tr_program_cooked $newA tr_program_cooked
+ regsub -all new\.b $tr_program_cooked $newB tr_program_cooked
+ regsub -all new\.c $tr_program_cooked $newC tr_program_cooked
+ regsub -all old\.a $tr_program_cooked $oldA tr_program_cooked
+ regsub -all old\.b $tr_program_cooked $oldB tr_program_cooked
+ regsub -all old\.c $tr_program_cooked $oldC tr_program_cooked
+
+ catchsql {
+ DROP TABLE tbl;
+ DROP TABLE log;
+ }
+
+ execsql {
+ CREATE TABLE tbl(a PRIMARY KEY, b, c);
+ CREATE TABLE log(a, b, c);
+ }
+
+ set query {SELECT * FROM tbl; SELECT * FROM log;}
+ set prep "$prep; INSERT INTO log VALUES(1, 2, 3);\
+ INSERT INTO log VALUES(10, 20, 30);"
+
+# Check execution of BEFORE programs:
+
+ set before_data [ execsql "$prep $tr_program_cooked $statement $query" ]
+
+ execsql "DELETE FROM tbl; DELETE FROM log; $prep";
+ execsql "CREATE TRIGGER the_trigger BEFORE [string range $statement 0 6]\
+ ON tbl BEGIN $tr_program_fixed END;"
+
+ do_test trigger2-2.$ii-before "execsql {$statement $query}" $before_data
+
+ execsql "DROP TRIGGER the_trigger;"
+ execsql "DELETE FROM tbl; DELETE FROM log;"
+
+# Check execution of AFTER programs
+ set after_data [ execsql "$prep $statement $tr_program_cooked $query" ]
+
+ execsql "DELETE FROM tbl; DELETE FROM log; $prep";
+ execsql "CREATE TRIGGER the_trigger AFTER [string range $statement 0 6]\
+ ON tbl BEGIN $tr_program_fixed END;"
+
+ do_test trigger2-2.$ii-after "execsql {$statement $query}" $after_data
+ execsql "DROP TRIGGER the_trigger;"
+
+ integrity_check trigger2-2.$ii-integrity
+ }
+}
+catchsql {
+ DROP TABLE tbl;
+ DROP TABLE log;
+}
+
+# 3.
+
+# trigger2-3.1: UPDATE OF triggers
+execsql {
+ CREATE TABLE tbl (a, b, c, d);
+ CREATE TABLE log (a);
+ INSERT INTO log VALUES (0);
+ INSERT INTO tbl VALUES (0, 0, 0, 0);
+ INSERT INTO tbl VALUES (1, 0, 0, 0);
+ CREATE TRIGGER tbl_after_update_cd BEFORE UPDATE OF c, d ON tbl
+ BEGIN
+ UPDATE log SET a = a + 1;
+ END;
+}
+do_test trigger2-3.1 {
+ execsql {
+ UPDATE tbl SET b = 1, c = 10; -- 2
+ UPDATE tbl SET b = 10; -- 0
+ UPDATE tbl SET d = 4 WHERE a = 0; --1
+ UPDATE tbl SET a = 4, b = 10; --0
+ SELECT * FROM log;
+ }
+} {3}
+execsql {
+ DROP TABLE tbl;
+ DROP TABLE log;
+}
+
+# trigger2-3.2: WHEN clause
+set when_triggers [list {t1 BEFORE INSERT ON tbl WHEN new.a > 20}]
+ifcapable subquery {
+ lappend when_triggers \
+ {t2 BEFORE INSERT ON tbl WHEN (SELECT count(*) FROM tbl) = 0}
+}
+
+execsql {
+ CREATE TABLE tbl (a, b, c, d);
+ CREATE TABLE log (a);
+ INSERT INTO log VALUES (0);
+}
+
+foreach trig $when_triggers {
+ execsql "CREATE TRIGGER $trig BEGIN UPDATE log set a = a + 1; END;"
+}
+
+ifcapable subquery {
+ set t232 {1 0 1}
+} else {
+ set t232 {0 0 1}
+}
+do_test trigger2-3.2 {
+ execsql {
+
+ INSERT INTO tbl VALUES(0, 0, 0, 0); -- 1 (ifcapable subquery)
+ SELECT * FROM log;
+ UPDATE log SET a = 0;
+
+ INSERT INTO tbl VALUES(0, 0, 0, 0); -- 0
+ SELECT * FROM log;
+ UPDATE log SET a = 0;
+
+ INSERT INTO tbl VALUES(200, 0, 0, 0); -- 1
+ SELECT * FROM log;
+ UPDATE log SET a = 0;
+ }
+} $t232
+execsql {
+ DROP TABLE tbl;
+ DROP TABLE log;
+}
+integrity_check trigger2-3.3
+
+# Simple cascaded trigger
+execsql {
+ CREATE TABLE tblA(a, b);
+ CREATE TABLE tblB(a, b);
+ CREATE TABLE tblC(a, b);
+
+ CREATE TRIGGER tr1 BEFORE INSERT ON tblA BEGIN
+ INSERT INTO tblB values(new.a, new.b);
+ END;
+
+ CREATE TRIGGER tr2 BEFORE INSERT ON tblB BEGIN
+ INSERT INTO tblC values(new.a, new.b);
+ END;
+}
+do_test trigger2-4.1 {
+ execsql {
+ INSERT INTO tblA values(1, 2);
+ SELECT * FROM tblA;
+ SELECT * FROM tblB;
+ SELECT * FROM tblC;
+ }
+} {1 2 1 2 1 2}
+execsql {
+ DROP TABLE tblA;
+ DROP TABLE tblB;
+ DROP TABLE tblC;
+}
+
+# Simple recursive trigger
+execsql {
+ CREATE TABLE tbl(a, b, c);
+ CREATE TRIGGER tbl_trig BEFORE INSERT ON tbl
+ BEGIN
+ INSERT INTO tbl VALUES (new.a, new.b, new.c);
+ END;
+}
+do_test trigger2-4.2 {
+ execsql {
+ INSERT INTO tbl VALUES (1, 2, 3);
+ select * from tbl;
+ }
+} {1 2 3 1 2 3}
+execsql {
+ DROP TABLE tbl;
+}
+
+# 5.
+execsql {
+ CREATE TABLE tbl(a, b, c);
+ CREATE TRIGGER tbl_trig BEFORE INSERT ON tbl
+ BEGIN
+ INSERT INTO tbl VALUES (1, 2, 3);
+ INSERT INTO tbl VALUES (2, 2, 3);
+ UPDATE tbl set b = 10 WHERE a = 1;
+ DELETE FROM tbl WHERE a = 1;
+ DELETE FROM tbl;
+ END;
+}
+do_test trigger2-5 {
+ execsql {
+ INSERT INTO tbl VALUES(100, 200, 300);
+ }
+ db changes
+} {1}
+execsql {
+ DROP TABLE tbl;
+}
+
+ifcapable conflict {
+ # Handling of ON CONFLICT by INSERT statements inside triggers
+ execsql {
+ CREATE TABLE tbl (a primary key, b, c);
+ CREATE TRIGGER ai_tbl AFTER INSERT ON tbl BEGIN
+ INSERT OR IGNORE INTO tbl values (new.a, 0, 0);
+ END;
+ }
+ do_test trigger2-6.1a {
+ execsql {
+ BEGIN;
+ INSERT INTO tbl values (1, 2, 3);
+ SELECT * from tbl;
+ }
+ } {1 2 3}
+ do_test trigger2-6.1b {
+ catchsql {
+ INSERT OR ABORT INTO tbl values (2, 2, 3);
+ }
+ } {1 {column a is not unique}}
+ do_test trigger2-6.1c {
+ execsql {
+ SELECT * from tbl;
+ }
+ } {1 2 3}
+ do_test trigger2-6.1d {
+ catchsql {
+ INSERT OR FAIL INTO tbl values (2, 2, 3);
+ }
+ } {1 {column a is not unique}}
+ do_test trigger2-6.1e {
+ execsql {
+ SELECT * from tbl;
+ }
+ } {1 2 3 2 2 3}
+ do_test trigger2-6.1f {
+ execsql {
+ INSERT OR REPLACE INTO tbl values (2, 2, 3);
+ SELECT * from tbl;
+ }
+ } {1 2 3 2 0 0}
+ do_test trigger2-6.1g {
+ catchsql {
+ INSERT OR ROLLBACK INTO tbl values (3, 2, 3);
+ }
+ } {1 {column a is not unique}}
+ do_test trigger2-6.1h {
+ execsql {
+ SELECT * from tbl;
+ }
+ } {}
+ execsql {DELETE FROM tbl}
+
+
+ # Handling of ON CONFLICT by UPDATE statements inside triggers
+ execsql {
+ INSERT INTO tbl values (4, 2, 3);
+ INSERT INTO tbl values (6, 3, 4);
+ CREATE TRIGGER au_tbl AFTER UPDATE ON tbl BEGIN
+ UPDATE OR IGNORE tbl SET a = new.a, c = 10;
+ END;
+ }
+ do_test trigger2-6.2a {
+ execsql {
+ BEGIN;
+ UPDATE tbl SET a = 1 WHERE a = 4;
+ SELECT * from tbl;
+ }
+ } {1 2 10 6 3 4}
+ do_test trigger2-6.2b {
+ catchsql {
+ UPDATE OR ABORT tbl SET a = 4 WHERE a = 1;
+ }
+ } {1 {column a is not unique}}
+ do_test trigger2-6.2c {
+ execsql {
+ SELECT * from tbl;
+ }
+ } {1 2 10 6 3 4}
+ do_test trigger2-6.2d {
+ catchsql {
+ UPDATE OR FAIL tbl SET a = 4 WHERE a = 1;
+ }
+ } {1 {column a is not unique}}
+ do_test trigger2-6.2e {
+ execsql {
+ SELECT * from tbl;
+ }
+ } {4 2 10 6 3 4}
+ do_test trigger2-6.2f.1 {
+ execsql {
+ UPDATE OR REPLACE tbl SET a = 1 WHERE a = 4;
+ SELECT * from tbl;
+ }
+ } {1 3 10}
+ do_test trigger2-6.2f.2 {
+ execsql {
+ INSERT INTO tbl VALUES (2, 3, 4);
+ SELECT * FROM tbl;
+ }
+ } {1 3 10 2 3 4}
+ do_test trigger2-6.2g {
+ catchsql {
+ UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1;
+ }
+ } {1 {column a is not unique}}
+ do_test trigger2-6.2h {
+ execsql {
+ SELECT * from tbl;
+ }
+ } {4 2 3 6 3 4}
+ execsql {
+ DROP TABLE tbl;
+ }
+} ; # ifcapable conflict
+
+# 7. Triggers on views
+ifcapable view {
+
+do_test trigger2-7.1 {
+ execsql {
+ CREATE TABLE ab(a, b);
+ CREATE TABLE cd(c, d);
+ INSERT INTO ab VALUES (1, 2);
+ INSERT INTO ab VALUES (0, 0);
+ INSERT INTO cd VALUES (3, 4);
+
+ CREATE TABLE tlog(ii INTEGER PRIMARY KEY,
+ olda, oldb, oldc, oldd, newa, newb, newc, newd);
+
+ CREATE VIEW abcd AS SELECT a, b, c, d FROM ab, cd;
+
+ CREATE TRIGGER before_update INSTEAD OF UPDATE ON abcd BEGIN
+ INSERT INTO tlog VALUES(NULL,
+ old.a, old.b, old.c, old.d, new.a, new.b, new.c, new.d);
+ END;
+ CREATE TRIGGER after_update INSTEAD OF UPDATE ON abcd BEGIN
+ INSERT INTO tlog VALUES(NULL,
+ old.a, old.b, old.c, old.d, new.a, new.b, new.c, new.d);
+ END;
+
+ CREATE TRIGGER before_delete INSTEAD OF DELETE ON abcd BEGIN
+ INSERT INTO tlog VALUES(NULL,
+ old.a, old.b, old.c, old.d, 0, 0, 0, 0);
+ END;
+ CREATE TRIGGER after_delete INSTEAD OF DELETE ON abcd BEGIN
+ INSERT INTO tlog VALUES(NULL,
+ old.a, old.b, old.c, old.d, 0, 0, 0, 0);
+ END;
+
+ CREATE TRIGGER before_insert INSTEAD OF INSERT ON abcd BEGIN
+ INSERT INTO tlog VALUES(NULL,
+ 0, 0, 0, 0, new.a, new.b, new.c, new.d);
+ END;
+ CREATE TRIGGER after_insert INSTEAD OF INSERT ON abcd BEGIN
+ INSERT INTO tlog VALUES(NULL,
+ 0, 0, 0, 0, new.a, new.b, new.c, new.d);
+ END;
+ }
+} {};
+
+do_test trigger2-7.2 {
+ execsql {
+ UPDATE abcd SET a = 100, b = 5*5 WHERE a = 1;
+ DELETE FROM abcd WHERE a = 1;
+ INSERT INTO abcd VALUES(10, 20, 30, 40);
+ SELECT * FROM tlog;
+ }
+} [ list 1 1 2 3 4 100 25 3 4 \
+ 2 1 2 3 4 100 25 3 4 \
+ 3 1 2 3 4 0 0 0 0 \
+ 4 1 2 3 4 0 0 0 0 \
+ 5 0 0 0 0 10 20 30 40 \
+ 6 0 0 0 0 10 20 30 40 ]
+
+do_test trigger2-7.3 {
+ execsql {
+ DELETE FROM tlog;
+ INSERT INTO abcd VALUES(10, 20, 30, 40);
+ UPDATE abcd SET a = 100, b = 5*5 WHERE a = 1;
+ DELETE FROM abcd WHERE a = 1;
+ SELECT * FROM tlog;
+ }
+} [ list \
+ 1 0 0 0 0 10 20 30 40 \
+ 2 0 0 0 0 10 20 30 40 \
+ 3 1 2 3 4 100 25 3 4 \
+ 4 1 2 3 4 100 25 3 4 \
+ 5 1 2 3 4 0 0 0 0 \
+ 6 1 2 3 4 0 0 0 0 \
+]
+do_test trigger2-7.4 {
+ execsql {
+ DELETE FROM tlog;
+ DELETE FROM abcd WHERE a = 1;
+ INSERT INTO abcd VALUES(10, 20, 30, 40);
+ UPDATE abcd SET a = 100, b = 5*5 WHERE a = 1;
+ SELECT * FROM tlog;
+ }
+} [ list \
+ 1 1 2 3 4 0 0 0 0 \
+ 2 1 2 3 4 0 0 0 0 \
+ 3 0 0 0 0 10 20 30 40 \
+ 4 0 0 0 0 10 20 30 40 \
+ 5 1 2 3 4 100 25 3 4 \
+ 6 1 2 3 4 100 25 3 4 \
+]
+
+do_test trigger2-8.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ CREATE VIEW v1 AS
+ SELECT a+b AS x, b+c AS y, a+c AS z FROM t1;
+ SELECT * FROM v1;
+ }
+} {3 5 4}
+do_test trigger2-8.2 {
+ execsql {
+ CREATE TABLE v1log(a,b,c,d,e,f);
+ CREATE TRIGGER r1 INSTEAD OF DELETE ON v1 BEGIN
+ INSERT INTO v1log VALUES(OLD.x,NULL,OLD.y,NULL,OLD.z,NULL);
+ END;
+ DELETE FROM v1 WHERE x=1;
+ SELECT * FROM v1log;
+ }
+} {}
+do_test trigger2-8.3 {
+ execsql {
+ DELETE FROM v1 WHERE x=3;
+ SELECT * FROM v1log;
+ }
+} {3 {} 5 {} 4 {}}
+do_test trigger2-8.4 {
+ execsql {
+ INSERT INTO t1 VALUES(4,5,6);
+ DELETE FROM v1log;
+ DELETE FROM v1 WHERE y=11;
+ SELECT * FROM v1log;
+ }
+} {9 {} 11 {} 10 {}}
+do_test trigger2-8.5 {
+ execsql {
+ CREATE TRIGGER r2 INSTEAD OF INSERT ON v1 BEGIN
+ INSERT INTO v1log VALUES(NULL,NEW.x,NULL,NEW.y,NULL,NEW.z);
+ END;
+ DELETE FROM v1log;
+ INSERT INTO v1 VALUES(1,2,3);
+ SELECT * FROM v1log;
+ }
+} {{} 1 {} 2 {} 3}
+do_test trigger2-8.6 {
+ execsql {
+ CREATE TRIGGER r3 INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO v1log VALUES(OLD.x,NEW.x,OLD.y,NEW.y,OLD.z,NEW.z);
+ END;
+ DELETE FROM v1log;
+ UPDATE v1 SET x=x+100, y=y+200, z=z+300;
+ SELECT * FROM v1log;
+ }
+} {3 103 5 205 4 304 9 109 11 211 10 310}
+
+# At one point the following was causing a segfault.
+do_test trigger2-9.1 {
+ execsql {
+ CREATE TABLE t3(a TEXT, b TEXT);
+ CREATE VIEW v3 AS SELECT t3.a FROM t3;
+ CREATE TRIGGER trig1 INSTEAD OF DELETE ON v3 BEGIN
+ SELECT 1;
+ END;
+ DELETE FROM v3 WHERE a = 1;
+ }
+} {}
+
+} ;# ifcapable view
+
+integrity_check trigger2-9.9
+
+finish_test
diff --git a/test/trigger3.test b/test/trigger3.test
new file mode 100644
index 0000000..34d1970
--- /dev/null
+++ b/test/trigger3.test
@@ -0,0 +1,194 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file tests the RAISE() function.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# The tests in this file were written before SQLite supported recursive }
+# trigger invocation, and some tests depend on that to pass. So disable
+# recursive triggers for this file.
+catchsql { pragma recursive_triggers = off }
+
+# Test that we can cause ROLLBACK, FAIL and ABORT correctly
+#
+catchsql { CREATE TABLE tbl(a, b ,c) }
+execsql {
+ CREATE TRIGGER before_tbl_insert BEFORE INSERT ON tbl BEGIN SELECT CASE
+ WHEN (new.a = 4) THEN RAISE(IGNORE) END;
+ END;
+
+ CREATE TRIGGER after_tbl_insert AFTER INSERT ON tbl BEGIN SELECT CASE
+ WHEN (new.a = 1) THEN RAISE(ABORT, 'Trigger abort')
+ WHEN (new.a = 2) THEN RAISE(FAIL, 'Trigger fail')
+ WHEN (new.a = 3) THEN RAISE(ROLLBACK, 'Trigger rollback') END;
+ END;
+}
+# ABORT
+do_test trigger3-1.1 {
+ catchsql {
+ BEGIN;
+ INSERT INTO tbl VALUES (5, 5, 6);
+ INSERT INTO tbl VALUES (1, 5, 6);
+ }
+} {1 {Trigger abort}}
+do_test trigger3-1.2 {
+ execsql {
+ SELECT * FROM tbl;
+ ROLLBACK;
+ }
+} {5 5 6}
+do_test trigger3-1.3 {
+ execsql {SELECT * FROM tbl}
+} {}
+
+# FAIL
+do_test trigger3-2.1 {
+ catchsql {
+ BEGIN;
+ INSERT INTO tbl VALUES (5, 5, 6);
+ INSERT INTO tbl VALUES (2, 5, 6);
+ }
+} {1 {Trigger fail}}
+do_test trigger3-2.2 {
+ execsql {
+ SELECT * FROM tbl;
+ ROLLBACK;
+ }
+} {5 5 6 2 5 6}
+# ROLLBACK
+do_test trigger3-3.1 {
+ catchsql {
+ BEGIN;
+ INSERT INTO tbl VALUES (5, 5, 6);
+ INSERT INTO tbl VALUES (3, 5, 6);
+ }
+} {1 {Trigger rollback}}
+do_test trigger3-3.2 {
+ execsql {
+ SELECT * FROM tbl;
+ }
+} {}
+
+# Verify that a ROLLBACK trigger works like a FAIL trigger if
+# we are not within a transaction. Ticket #3035.
+#
+do_test trigger3-3.3 {
+ catchsql {COMMIT}
+ catchsql {
+ INSERT INTO tbl VALUES (3, 9, 10);
+ }
+} {1 {Trigger rollback}}
+do_test trigger3-3.4 {
+ execsql {SELECT * FROM tbl}
+} {}
+
+# IGNORE
+do_test trigger3-4.1 {
+ catchsql {
+ BEGIN;
+ INSERT INTO tbl VALUES (5, 5, 6);
+ INSERT INTO tbl VALUES (4, 5, 6);
+ }
+} {0 {}}
+do_test trigger3-4.2 {
+ execsql {
+ SELECT * FROM tbl;
+ ROLLBACK;
+ }
+} {5 5 6}
+
+# Check that we can also do RAISE(IGNORE) for UPDATE and DELETE
+execsql {DROP TABLE tbl;}
+execsql {CREATE TABLE tbl (a, b, c);}
+execsql {INSERT INTO tbl VALUES(1, 2, 3);}
+execsql {INSERT INTO tbl VALUES(4, 5, 6);}
+execsql {
+ CREATE TRIGGER before_tbl_update BEFORE UPDATE ON tbl BEGIN
+ SELECT CASE WHEN (old.a = 1) THEN RAISE(IGNORE) END;
+ END;
+
+ CREATE TRIGGER before_tbl_delete BEFORE DELETE ON tbl BEGIN
+ SELECT CASE WHEN (old.a = 1) THEN RAISE(IGNORE) END;
+ END;
+}
+do_test trigger3-5.1 {
+ execsql {
+ UPDATE tbl SET c = 10;
+ SELECT * FROM tbl;
+ }
+} {1 2 3 4 5 10}
+do_test trigger3-5.2 {
+ execsql {
+ DELETE FROM tbl;
+ SELECT * FROM tbl;
+ }
+} {1 2 3}
+
+# Check that RAISE(IGNORE) works correctly for nested triggers:
+execsql {CREATE TABLE tbl2(a, b, c)}
+execsql {
+ CREATE TRIGGER after_tbl2_insert AFTER INSERT ON tbl2 BEGIN
+ UPDATE tbl SET c = 10;
+ INSERT INTO tbl2 VALUES (new.a, new.b, new.c);
+ END;
+}
+do_test trigger3-6 {
+ execsql {
+ INSERT INTO tbl2 VALUES (1, 2, 3);
+ SELECT * FROM tbl2;
+ SELECT * FROM tbl;
+ }
+} {1 2 3 1 2 3 1 2 3}
+
+# Check that things also work for view-triggers
+
+ifcapable view {
+
+execsql {CREATE VIEW tbl_view AS SELECT * FROM tbl}
+execsql {
+ CREATE TRIGGER tbl_view_insert INSTEAD OF INSERT ON tbl_view BEGIN
+ SELECT CASE WHEN (new.a = 1) THEN RAISE(ROLLBACK, 'View rollback')
+ WHEN (new.a = 2) THEN RAISE(IGNORE)
+ WHEN (new.a = 3) THEN RAISE(ABORT, 'View abort') END;
+ END;
+}
+
+do_test trigger3-7.1 {
+ catchsql {
+ INSERT INTO tbl_view VALUES(1, 2, 3);
+ }
+} {1 {View rollback}}
+do_test trigger3-7.2 {
+ catchsql {
+ INSERT INTO tbl_view VALUES(2, 2, 3);
+ }
+} {0 {}}
+do_test trigger3-7.3 {
+ catchsql {
+ INSERT INTO tbl_view VALUES(3, 2, 3);
+ }
+} {1 {View abort}}
+
+} ;# ifcapable view
+
+integrity_check trigger3-8.1
+
+catchsql { DROP TABLE tbl; }
+catchsql { DROP TABLE tbl2; }
+catchsql { DROP VIEW tbl_view; }
+
+finish_test
diff --git a/test/trigger4.test b/test/trigger4.test
new file mode 100644
index 0000000..a05a5e7
--- /dev/null
+++ b/test/trigger4.test
@@ -0,0 +1,200 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file tests the triggers of views.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If either views or triggers are disabled in this build, omit this file.
+ifcapable {!trigger || !view} {
+ finish_test
+ return
+}
+
+do_test trigger4-1.1 {
+ execsql {
+ create table test1(id integer primary key,a);
+ create table test2(id integer,b);
+ create view test as
+ select test1.id as id,a as a,b as b
+ from test1 join test2 on test2.id = test1.id;
+ create trigger I_test instead of insert on test
+ begin
+ insert into test1 (id,a) values (NEW.id,NEW.a);
+ insert into test2 (id,b) values (NEW.id,NEW.b);
+ end;
+ insert into test values(1,2,3);
+ select * from test1;
+ }
+} {1 2}
+do_test trigger4-1.2 {
+ execsql {
+ select * from test2;
+ }
+} {1 3}
+do_test trigger4-1.3 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ insert into test values(4,5,6);
+ select * from test1;
+ }
+} {1 2 4 5}
+do_test trigger4-1.4 {
+ execsql {
+ select * from test2;
+ }
+} {1 3 4 6}
+
+do_test trigger4-2.1 {
+ execsql {
+ create trigger U_test instead of update on test
+ begin
+ update test1 set a=NEW.a where id=NEW.id;
+ update test2 set b=NEW.b where id=NEW.id;
+ end;
+ update test set a=22 where id=1;
+ select * from test1;
+ }
+} {1 22 4 5}
+do_test trigger4-2.2 {
+ execsql {
+ select * from test2;
+ }
+} {1 3 4 6}
+do_test trigger4-2.3 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ update test set b=66 where id=4;
+ select * from test1;
+ }
+} {1 22 4 5}
+do_test trigger4-2.4 {
+ execsql {
+ select * from test2;
+ }
+} {1 3 4 66}
+
+do_test trigger4-3.1 {
+ catchsql {
+ drop table test2;
+ insert into test values(7,8,9);
+ }
+} {1 {no such table: main.test2}}
+do_test trigger4-3.2 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ insert into test values(7,8,9);
+ }
+} {1 {no such table: main.test2}}
+do_test trigger4-3.3 {
+ catchsql {
+ update test set a=222 where id=1;
+ }
+} {1 {no such table: main.test2}}
+do_test trigger4-3.4 {
+ execsql {
+ select * from test1;
+ }
+} {1 22 4 5}
+do_test trigger4-3.5 {
+ execsql {
+ create table test2(id,b);
+ insert into test values(7,8,9);
+ select * from test1;
+ }
+} {1 22 4 5 7 8}
+do_test trigger4-3.6 {
+ execsql {
+ select * from test2;
+ }
+} {7 9}
+do_test trigger4-3.7 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ update test set b=99 where id=7;
+ select * from test2;
+ }
+} {7 99}
+
+do_test trigger4-4.1 {
+ db close
+ forcedelete trigtest.db
+ forcedelete trigtest.db-journal
+ sqlite3 db trigtest.db
+ catchsql {drop table tbl; drop view vw}
+ execsql {
+ create table tbl(a integer primary key, b integer);
+ create view vw as select * from tbl;
+ create trigger t_del_tbl instead of delete on vw for each row begin
+ delete from tbl where a = old.a;
+ end;
+ create trigger t_upd_tbl instead of update on vw for each row begin
+ update tbl set a=new.a, b=new.b where a = old.a;
+ end;
+ create trigger t_ins_tbl instead of insert on vw for each row begin
+ insert into tbl values (new.a,new.b);
+ end;
+ insert into tbl values(101,1001);
+ insert into tbl values(102,1002);
+ insert into tbl select a+2, b+2 from tbl;
+ insert into tbl select a+4, b+4 from tbl;
+ insert into tbl select a+8, b+8 from tbl;
+ insert into tbl select a+16, b+16 from tbl;
+ insert into tbl select a+32, b+32 from tbl;
+ insert into tbl select a+64, b+64 from tbl;
+ select count(*) from vw;
+ }
+} {128}
+do_test trigger4-4.2 {
+ execsql {select a, b from vw where a<103 or a>226 order by a}
+} {101 1001 102 1002 227 1127 228 1128}
+
+#test delete from view
+do_test trigger4-5.1 {
+ catchsql {delete from vw where a>101 and a<2000}
+} {0 {}}
+do_test trigger4-5.2 {
+ execsql {select * from vw}
+} {101 1001}
+
+#test insert into view
+do_test trigger4-6.1 {
+ catchsql {
+ insert into vw values(102,1002);
+ insert into vw select a+2, b+2 from vw;
+ insert into vw select a+4, b+4 from vw;
+ insert into vw select a+8, b+8 from vw;
+ insert into vw select a+16, b+16 from vw;
+ insert into vw select a+32, b+32 from vw;
+ insert into vw select a+64, b+64 from vw;
+ }
+} {0 {}}
+do_test trigger4-6.2 {
+ execsql {select count(*) from vw}
+} {128}
+
+#test update of view
+do_test trigger4-7.1 {
+ catchsql {update vw set b=b+1000 where a>101 and a<2000}
+} {0 {}}
+do_test trigger4-7.2 {
+ execsql {select a, b from vw where a<=102 or a>=227 order by a}
+} {101 1001 102 2002 227 2127 228 2128}
+
+integrity_check trigger4-99.9
+db close
+forcedelete trigtest.db trigtest.db-journal
+
+finish_test
diff --git a/test/trigger5.test b/test/trigger5.test
new file mode 100644
index 0000000..75c56b1
--- /dev/null
+++ b/test/trigger5.test
@@ -0,0 +1,43 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file tests the triggers of views.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# Ticket #844
+#
+do_test trigger5-1.1 {
+ execsql {
+ CREATE TABLE Item(
+ a integer PRIMARY KEY NOT NULL ,
+ b double NULL ,
+ c int NOT NULL DEFAULT 0
+ );
+ CREATE TABLE Undo(UndoAction TEXT);
+ INSERT INTO Item VALUES (1,38205.60865,340);
+ CREATE TRIGGER trigItem_UNDO_AD AFTER DELETE ON Item FOR EACH ROW
+ BEGIN
+ INSERT INTO Undo SELECT 'INSERT INTO Item (a,b,c) VALUES ('
+ || coalesce(old.a,'NULL') || ',' || quote(old.b) || ',' || old.c || ');';
+ END;
+ DELETE FROM Item WHERE a = 1;
+ SELECT * FROM Undo;
+ }
+} {{INSERT INTO Item (a,b,c) VALUES (1,38205.60865,340);}}
+
+integrity_check trigger5-99.9
+
+finish_test
diff --git a/test/trigger6.test b/test/trigger6.test
new file mode 100644
index 0000000..bb343fa
--- /dev/null
+++ b/test/trigger6.test
@@ -0,0 +1,82 @@
+# 2004 December 07
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure expression of an INSERT
+# and UPDATE statement are only evaluated once. See ticket #980.
+# If an expression uses a function that has side-effects or which
+# is not deterministic (ex: random()) then we want to make sure
+# that the same evaluation occurs for the actual INSERT/UPDATE and
+# for the NEW.* fields of any triggers that fire.
+#
+# $Id: trigger6.test,v 1.2 2005/05/05 11:04:50 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+do_test trigger6-1.1 {
+ execsql {
+ CREATE TABLE t1(x, y);
+ CREATE TABLE log(a, b, c);
+ CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN
+ INSERT INTO log VALUES(1, new.x, new.y);
+ END;
+ CREATE TRIGGER r2 BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES(2, new.x, new.y);
+ END;
+ }
+ set ::trigger6_cnt 0
+ proc trigger6_counter {args} {
+ incr ::trigger6_cnt
+ return $::trigger6_cnt
+ }
+ db function counter trigger6_counter
+ execsql {
+ INSERT INTO t1 VALUES(1,counter());
+ SELECT * FROM t1;
+ }
+} {1 1}
+do_test trigger6-1.2 {
+ execsql {
+ SELECT * FROM log;
+ }
+} {1 1 1}
+do_test trigger6-1.3 {
+ execsql {
+ DELETE FROM t1;
+ DELETE FROM log;
+ INSERT INTO t1 VALUES(2,counter(2,3)+4);
+ SELECT * FROM t1;
+ }
+} {2 6}
+do_test trigger6-1.4 {
+ execsql {
+ SELECT * FROM log;
+ }
+} {1 2 6}
+do_test trigger6-1.5 {
+ execsql {
+ DELETE FROM log;
+ UPDATE t1 SET y=counter(5);
+ SELECT * FROM t1;
+ }
+} {2 3}
+do_test trigger6-1.6 {
+ execsql {
+ SELECT * FROM log;
+ }
+} {2 2 3}
+
+finish_test
diff --git a/test/trigger7.test b/test/trigger7.test
new file mode 100644
index 0000000..8fde200
--- /dev/null
+++ b/test/trigger7.test
@@ -0,0 +1,119 @@
+# 2005 August 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to increase coverage of trigger.c.
+#
+# $Id: trigger7.test,v 1.3 2008/08/11 18:44:58 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+
+# Error messages resulting from qualified trigger names.
+#
+do_test trigger7-1.1 {
+ execsql {
+ CREATE TABLE t1(x, y);
+ }
+ catchsql {
+ CREATE TEMP TRIGGER main.r1 AFTER INSERT ON t1 BEGIN
+ SELECT 'no nothing';
+ END
+ }
+} {1 {temporary trigger may not have qualified name}}
+do_test trigger7-1.2 {
+ catchsql {
+ CREATE TRIGGER not_a_db.r1 AFTER INSERT ON t1 BEGIN
+ SELECT 'no nothing';
+ END
+ }
+} {1 {unknown database not_a_db}}
+
+
+# When the UPDATE OF syntax is used, no code is generated for triggers
+# that do not match the update columns.
+#
+ifcapable explain {
+ do_test trigger7-2.1 {
+ execsql {
+ CREATE TRIGGER r1 AFTER UPDATE OF x ON t1 BEGIN
+ SELECT '___update_t1.x___';
+ END;
+ CREATE TRIGGER r2 AFTER UPDATE OF y ON t1 BEGIN
+ SELECT '___update_t1.y___';
+ END;
+ }
+ set txt [db eval {EXPLAIN UPDATE t1 SET x=5}]
+ string match *___update_t1.x___* $txt
+ } 1
+ do_test trigger7-2.2 {
+ set txt [db eval {EXPLAIN UPDATE t1 SET x=5}]
+ string match *___update_t1.y___* $txt
+ } 0
+ do_test trigger7-2.3 {
+ set txt [db eval {EXPLAIN UPDATE t1 SET y=5}]
+ string match *___update_t1.x___* $txt
+ } 0
+ do_test trigger7-2.4 {
+ set txt [db eval {EXPLAIN UPDATE t1 SET y=5}]
+ string match *___update_t1.y___* $txt
+ } 1
+ do_test trigger7-2.5 {
+ set txt [db eval {EXPLAIN UPDATE t1 SET rowid=5}]
+ string match *___update_t1.x___* $txt
+ } 0
+ do_test trigger7-2.6 {
+ set txt [db eval {EXPLAIN UPDATE t1 SET rowid=5}]
+ string match *___update_t1.x___* $txt
+ } 0
+}
+
+# Test the ability to create many triggers on the same table, then
+# selectively drop those triggers.
+#
+do_test trigger7-3.1 {
+ execsql {
+ CREATE TABLE t2(x,y,z);
+ CREATE TRIGGER t2r1 AFTER INSERT ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r2 BEFORE INSERT ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r3 AFTER UPDATE ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r4 BEFORE UPDATE ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r5 AFTER DELETE ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r6 BEFORE DELETE ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r7 AFTER INSERT ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r8 BEFORE INSERT ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r9 AFTER UPDATE ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r10 BEFORE UPDATE ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r11 AFTER DELETE ON t2 BEGIN SELECT 1; END;
+ CREATE TRIGGER t2r12 BEFORE DELETE ON t2 BEGIN SELECT 1; END;
+ DROP TRIGGER t2r6;
+ }
+} {}
+
+# This test corrupts the database file so it must be the last test
+# in the series.
+#
+do_test trigger7-99.1 {
+ execsql {
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET sql='nonsense';
+ }
+ db close
+ catch { sqlite3 db test.db }
+ catchsql { DROP TRIGGER t2r5 }
+} {1 {malformed database schema (t2r12) - near "nonsense": syntax error}}
+
+finish_test
diff --git a/test/trigger8.test b/test/trigger8.test
new file mode 100644
index 0000000..3064ea6
--- /dev/null
+++ b/test/trigger8.test
@@ -0,0 +1,53 @@
+# 2006 February 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to make sure abusively large triggers
+# (triggers with 100s or 1000s of statements) work.
+#
+# $Id: trigger8.test,v 1.2 2008/09/17 16:14:10 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# Set variable $nStatement to the number of statements to include in the
+# body of the trigger. On a workstation with virtually unlimited memory,
+# use 10000. But on symbian, which allows each application at most a 32MB
+# heap, use 1000.
+#
+set nStatement 10000
+if {$tcl_platform(platform) == "symbian"} {
+ set nStatement 1000
+}
+
+set nStatement 5
+do_test trigger8-1.1 {
+ execsql {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(y);
+ }
+ set sql "CREATE TRIGGER r${nStatement} AFTER INSERT ON t1 BEGIN\n"
+ for {set i 0} {$i<$nStatement} {incr i} {
+ append sql " INSERT INTO t2 VALUES($i);\n"
+ }
+ append sql "END;"
+ execsql $sql
+ execsql {
+ INSERT INTO t1 VALUES(5);
+ SELECT count(*) FROM t2;
+ }
+} $nStatement
+
+finish_test
diff --git a/test/trigger9.test b/test/trigger9.test
new file mode 100644
index 0000000..f56c8ac
--- /dev/null
+++ b/test/trigger9.test
@@ -0,0 +1,223 @@
+# 2008 January 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests some compiler optimizations for SQL statements featuring
+# triggers:
+#
+#
+#
+
+# trigger9-1.* - Test that if there are no references to OLD.* cols, or a
+# reference to only OLD.rowid, the data is not loaded.
+#
+# trigger9-2.* - Test that for NEW.* records populated by UPDATE
+# statements, unused fields are populated with NULL values.
+#
+# trigger9-3.* - Test that the temporary tables used for OLD.* references
+# in "INSTEAD OF" triggers have NULL values in unused
+# fields.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+proc has_rowdata {sql} {
+ expr {[lsearch [execsql "explain $sql"] RowData]>=0}
+}
+
+do_test trigger9-1.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x, y, z);
+ INSERT INTO t1 VALUES('1', randstr(10000,10000), '2');
+ INSERT INTO t1 VALUES('2', randstr(10000,10000), '4');
+ INSERT INTO t1 VALUES('3', randstr(10000,10000), '6');
+ CREATE TABLE t2(x);
+ }
+} {}
+
+do_test trigger9-1.2.1 {
+ execsql {
+ BEGIN;
+ CREATE TRIGGER trig1 BEFORE DELETE ON t1 BEGIN
+ INSERT INTO t2 VALUES(old.rowid);
+ END;
+ DELETE FROM t1;
+ SELECT * FROM t2;
+ }
+} {1 2 3}
+do_test trigger9-1.2.3 {
+ has_rowdata {DELETE FROM t1}
+} 0
+do_test trigger9-1.2.4 { execsql { ROLLBACK } } {}
+
+do_test trigger9-1.3.1 {
+ execsql {
+ BEGIN;
+ CREATE TRIGGER trig1 BEFORE DELETE ON t1 BEGIN
+ INSERT INTO t2 VALUES(old.x);
+ END;
+ DELETE FROM t1;
+ SELECT * FROM t2;
+ }
+} {1 2 3}
+do_test trigger9-1.3.2 {
+ has_rowdata {DELETE FROM t1}
+} 0
+do_test trigger9-1.3.3 { execsql { ROLLBACK } } {}
+
+do_test trigger9-1.4.1 {
+ execsql {
+ BEGIN;
+ CREATE TRIGGER trig1 BEFORE DELETE ON t1 WHEN old.x='1' BEGIN
+ INSERT INTO t2 VALUES(old.rowid);
+ END;
+ DELETE FROM t1;
+ SELECT * FROM t2;
+ }
+} {1}
+do_test trigger9-1.4.2 {
+ has_rowdata {DELETE FROM t1}
+} 0
+do_test trigger9-1.4.3 { execsql { ROLLBACK } } {}
+
+do_test trigger9-1.5.1 {
+ execsql {
+ BEGIN;
+ CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO t2 VALUES(old.rowid);
+ END;
+ UPDATE t1 SET y = '';
+ SELECT * FROM t2;
+ }
+} {1 2 3}
+do_test trigger9-1.5.2 {
+ has_rowdata {UPDATE t1 SET y = ''}
+} 0
+do_test trigger9-1.5.3 { execsql { ROLLBACK } } {}
+
+do_test trigger9-1.6.1 {
+ execsql {
+ BEGIN;
+ CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO t2 VALUES(old.x);
+ END;
+ UPDATE t1 SET y = '';
+ SELECT * FROM t2;
+ }
+} {1 2 3}
+do_test trigger9-1.6.2 {
+ has_rowdata {UPDATE t1 SET y = ''}
+} 0
+do_test trigger9-1.6.3 { execsql { ROLLBACK } } {}
+
+do_test trigger9-1.7.1 {
+ execsql {
+ BEGIN;
+ CREATE TRIGGER trig1 BEFORE UPDATE ON t1 WHEN old.x>='2' BEGIN
+ INSERT INTO t2 VALUES(old.x);
+ END;
+ UPDATE t1 SET y = '';
+ SELECT * FROM t2;
+ }
+} {2 3}
+do_test trigger9-1.7.2 {
+ has_rowdata {UPDATE t1 SET y = ''}
+} 0
+do_test trigger9-1.7.3 { execsql { ROLLBACK } } {}
+
+do_test trigger9-3.1 {
+ execsql {
+ CREATE TABLE t3(a, b);
+ INSERT INTO t3 VALUES(1, 'one');
+ INSERT INTO t3 VALUES(2, 'two');
+ INSERT INTO t3 VALUES(3, 'three');
+ }
+} {}
+do_test trigger9-3.2 {
+ execsql {
+ BEGIN;
+ CREATE VIEW v1 AS SELECT * FROM t3;
+ CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO t2 VALUES(old.a);
+ END;
+ UPDATE v1 SET b = 'hello';
+ SELECT * FROM t2;
+ ROLLBACK;
+ }
+} {1 2 3}
+do_test trigger9-3.3 {
+ # In this test the 'c' column of the view is not required by
+ # the INSTEAD OF trigger, but the expression is reused internally as
+ # part of the view's WHERE clause. Check that this does not cause
+ # a problem.
+ #
+ execsql {
+ BEGIN;
+ CREATE VIEW v1 AS SELECT a, b AS c FROM t3 WHERE c > 'one';
+ CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO t2 VALUES(old.a);
+ END;
+ UPDATE v1 SET c = 'hello';
+ SELECT * FROM t2;
+ ROLLBACK;
+ }
+} {2 3}
+do_test trigger9-3.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO t3 VALUES(3, 'three');
+ INSERT INTO t3 VALUES(3, 'four');
+ CREATE VIEW v1 AS SELECT DISTINCT a, b FROM t3;
+ CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO t2 VALUES(old.a);
+ END;
+ UPDATE v1 SET b = 'hello';
+ SELECT * FROM t2;
+ ROLLBACK;
+ }
+} {1 2 3 3}
+
+ifcapable compound {
+ do_test trigger9-3.5 {
+ execsql {
+ BEGIN;
+ INSERT INTO t3 VALUES(1, 'uno');
+ CREATE VIEW v1 AS SELECT a, b FROM t3 EXCEPT SELECT 1, 'one';
+ CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO t2 VALUES(old.a);
+ END;
+ UPDATE v1 SET b = 'hello';
+ SELECT * FROM t2;
+ ROLLBACK;
+ }
+ } {1 2 3}
+ do_test trigger9-3.6 {
+ execsql {
+ BEGIN;
+ INSERT INTO t3 VALUES(1, 'zero');
+ CREATE VIEW v1 AS
+ SELECT sum(a) AS a, max(b) AS b FROM t3 GROUP BY t3.a HAVING b>'two';
+ CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO t2 VALUES(old.a);
+ END;
+ UPDATE v1 SET b = 'hello';
+ SELECT * FROM t2;
+ ROLLBACK;
+ }
+ } {2}
+}
+
+finish_test
diff --git a/test/triggerA.test b/test/triggerA.test
new file mode 100644
index 0000000..0bc017f
--- /dev/null
+++ b/test/triggerA.test
@@ -0,0 +1,230 @@
+# 2008 February 12
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests issues relating to firing an INSTEAD OF trigger on a VIEW
+# when one tries to UPDATE or DELETE from the view. Does the WHERE
+# clause of the UPDATE or DELETE statement get passed down correctly
+# into the query that manifests the view?
+#
+# Ticket #2938
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !trigger||!compound {
+ finish_test
+ return
+}
+
+# Create two table containing some sample data
+#
+do_test triggerA-1.1 {
+ db eval {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT UNIQUE);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER UNIQUE, c TEXT);
+ }
+ set i 1
+ foreach word {one two three four five six seven eight nine ten} {
+ set j [expr {$i*100 + [string length $word]}]
+ db eval {
+ INSERT INTO t1 VALUES($i,$word);
+ INSERT INTO t2 VALUES(20-$i,$j,$word);
+ }
+ incr i
+ }
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL SELECT count(*) FROM t2;
+ }
+} {10 10}
+
+# Create views of various forms against one or both of the two tables.
+#
+do_test triggerA-1.2 {
+ db eval {
+ CREATE VIEW v1 AS SELECT y, x FROM t1;
+ SELECT * FROM v1 ORDER BY 1;
+ }
+} {eight 8 five 5 four 4 nine 9 one 1 seven 7 six 6 ten 10 three 3 two 2}
+do_test triggerA-1.3 {
+ db eval {
+ CREATE VIEW v2 AS SELECT x, y FROM t1 WHERE y GLOB '*e*';
+ SELECT * FROM v2 ORDER BY 1;
+ }
+} {1 one 3 three 5 five 7 seven 8 eight 9 nine 10 ten}
+do_test triggerA-1.4 {
+ db eval {
+ CREATE VIEW v3 AS
+ SELECT CAST(x AS TEXT) AS c1 FROM t1 UNION SELECT y FROM t1;
+ SELECT * FROM v3 ORDER BY c1;
+ }
+} {1 10 2 3 4 5 6 7 8 9 eight five four nine one seven six ten three two}
+do_test triggerA-1.5 {
+ db eval {
+ CREATE VIEW v4 AS
+ SELECT CAST(x AS TEXT) AS c1 FROM t1
+ UNION SELECT y FROM t1 WHERE x BETWEEN 3 and 5;
+ SELECT * FROM v4 ORDER BY 1;
+ }
+} {1 10 2 3 4 5 6 7 8 9 five four three}
+do_test triggerA-1.6 {
+ db eval {
+ CREATE VIEW v5 AS SELECT x, b FROM t1, t2 WHERE y=c;
+ SELECT * FROM v5 ORDER BY x DESC;
+ }
+} {10 1003 9 904 8 805 7 705 6 603 5 504 4 404 3 305 2 203 1 103}
+
+# Create INSTEAD OF triggers on the views. Run UPDATE and DELETE statements
+# using those triggers. Verify correct operation.
+#
+do_test triggerA-2.1 {
+ db eval {
+ CREATE TABLE result2(a,b);
+ CREATE TRIGGER r1d INSTEAD OF DELETE ON v1 BEGIN
+ INSERT INTO result2(a,b) VALUES(old.y, old.x);
+ END;
+ DELETE FROM v1 WHERE x=5;
+ SELECT * FROM result2;
+ }
+} {five 5}
+do_test triggerA-2.2 {
+ db eval {
+ CREATE TABLE result4(a,b,c,d);
+ CREATE TRIGGER r1u INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO result4(a,b,c,d) VALUES(old.y, old.x, new.y, new.x);
+ END;
+ UPDATE v1 SET y=y||'-extra' WHERE x BETWEEN 3 AND 5;
+ SELECT * FROM result4 ORDER BY a;
+ }
+} {five 5 five-extra 5 four 4 four-extra 4 three 3 three-extra 3}
+
+
+do_test triggerA-2.3 {
+ db eval {
+ DELETE FROM result2;
+ CREATE TRIGGER r2d INSTEAD OF DELETE ON v2 BEGIN
+ INSERT INTO result2(a,b) VALUES(old.y, old.x);
+ END;
+ DELETE FROM v2 WHERE x=5;
+ SELECT * FROM result2;
+ }
+} {five 5}
+do_test triggerA-2.4 {
+ db eval {
+ DELETE FROM result4;
+ CREATE TRIGGER r2u INSTEAD OF UPDATE ON v2 BEGIN
+ INSERT INTO result4(a,b,c,d) VALUES(old.y, old.x, new.y, new.x);
+ END;
+ UPDATE v2 SET y=y||'-extra' WHERE x BETWEEN 3 AND 5;
+ SELECT * FROM result4 ORDER BY a;
+ }
+} {five 5 five-extra 5 three 3 three-extra 3}
+
+
+do_test triggerA-2.5 {
+ db eval {
+ CREATE TABLE result1(a);
+ CREATE TRIGGER r3d INSTEAD OF DELETE ON v3 BEGIN
+ INSERT INTO result1(a) VALUES(old.c1);
+ END;
+ DELETE FROM v3 WHERE c1 BETWEEN '8' AND 'eight';
+ SELECT * FROM result1 ORDER BY a;
+ }
+} {8 9 eight}
+do_test triggerA-2.6 {
+ db eval {
+ DELETE FROM result2;
+ CREATE TRIGGER r3u INSTEAD OF UPDATE ON v3 BEGIN
+ INSERT INTO result2(a,b) VALUES(old.c1, new.c1);
+ END;
+ UPDATE v3 SET c1 = c1 || '-extra' WHERE c1 BETWEEN '8' and 'eight';
+ SELECT * FROM result2 ORDER BY a;
+ }
+} {8 8-extra 9 9-extra eight eight-extra}
+
+
+do_test triggerA-2.7 {
+ db eval {
+ DELETE FROM result1;
+ CREATE TRIGGER r4d INSTEAD OF DELETE ON v4 BEGIN
+ INSERT INTO result1(a) VALUES(old.c1);
+ END;
+ DELETE FROM v4 WHERE c1 BETWEEN '8' AND 'eight';
+ SELECT * FROM result1 ORDER BY a;
+ }
+} {8 9}
+do_test triggerA-2.8 {
+ db eval {
+ DELETE FROM result2;
+ CREATE TRIGGER r4u INSTEAD OF UPDATE ON v4 BEGIN
+ INSERT INTO result2(a,b) VALUES(old.c1, new.c1);
+ END;
+ UPDATE v4 SET c1 = c1 || '-extra' WHERE c1 BETWEEN '8' and 'eight';
+ SELECT * FROM result2 ORDER BY a;
+ }
+} {8 8-extra 9 9-extra}
+
+
+do_test triggerA-2.9 {
+ db eval {
+ DELETE FROM result2;
+ CREATE TRIGGER r5d INSTEAD OF DELETE ON v5 BEGIN
+ INSERT INTO result2(a,b) VALUES(old.x, old.b);
+ END;
+ DELETE FROM v5 WHERE x=5;
+ SELECT * FROM result2;
+ }
+} {5 504}
+do_test triggerA-2.10 {
+ db eval {
+ DELETE FROM result4;
+ CREATE TRIGGER r5u INSTEAD OF UPDATE ON v5 BEGIN
+ INSERT INTO result4(a,b,c,d) VALUES(old.x, old.b, new.x, new.b);
+ END;
+ UPDATE v5 SET b = b+9900000 WHERE x BETWEEN 3 AND 5;
+ SELECT * FROM result4 ORDER BY a;
+ }
+} {3 305 3 9900305 4 404 4 9900404 5 504 5 9900504}
+
+# Only run the reamining tests if memory debugging is turned on.
+#
+ifcapable !memdebug {
+ puts "Skipping triggerA malloc tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+source $testdir/malloc_common.tcl
+
+# Save a copy of the current database configuration.
+#
+db close
+forcedelete test.db-triggerA
+copy_file test.db test.db-triggerA
+sqlite3 db test.db
+
+# Run malloc tests on the INSTEAD OF trigger firing.
+#
+do_malloc_test triggerA-3 -tclprep {
+ db close
+ forcedelete test.db test.db-journal
+ forcecopy test.db-triggerA test.db
+ sqlite3 db test.db
+ sqlite3_extended_result_codes db 1
+ db eval {SELECT * FROM v5; -- warm up the cache}
+} -sqlbody {
+ DELETE FROM v5 WHERE x=5;
+ UPDATE v5 SET b=b+9900000 WHERE x BETWEEN 3 AND 5;
+}
+
+# Clean up the saved database copy.
+#
+forcedelete test.db-triggerA
+
+finish_test
diff --git a/test/triggerB.test b/test/triggerB.test
new file mode 100644
index 0000000..ac4f37b
--- /dev/null
+++ b/test/triggerB.test
@@ -0,0 +1,153 @@
+# 2008 April 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice', here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests updating tables with constraints within a trigger. Ticket #3055.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# Create test tables with constraints.
+#
+do_test triggerB-1.1 {
+ execsql {
+ CREATE TABLE x(x INTEGER PRIMARY KEY, y INT NOT NULL);
+ INSERT INTO x(y) VALUES(1);
+ INSERT INTO x(y) VALUES(1);
+ CREATE TEMP VIEW vx AS SELECT x, y, 0 AS yy FROM x;
+ CREATE TEMP TRIGGER tx INSTEAD OF UPDATE OF y ON vx
+ BEGIN
+ UPDATE x SET y = new.y WHERE x = new.x;
+ END;
+ SELECT * FROM vx;
+ }
+} {1 1 0 2 1 0}
+do_test triggerB-1.2 {
+ execsql {
+ UPDATE vx SET y = yy;
+ SELECT * FROM vx;
+ }
+} {1 0 0 2 0 0}
+
+# Added 2008-08-22:
+#
+# Name resolution within triggers.
+#
+do_test triggerB-2.1 {
+ catchsql {
+ CREATE TRIGGER ty AFTER INSERT ON x BEGIN
+ SELECT wen.x; -- Unrecognized name
+ END;
+ INSERT INTO x VALUES(1,2);
+ }
+} {1 {no such column: wen.x}}
+do_test triggerB-2.2 {
+ catchsql {
+ CREATE TRIGGER tz AFTER UPDATE ON x BEGIN
+ SELECT dlo.x; -- Unrecognized name
+ END;
+ UPDATE x SET y=y+1;
+ }
+} {1 {no such column: dlo.x}}
+
+do_test triggerB-2.3 {
+ execsql {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t2 VALUES(1,2);
+ CREATE TABLE changes(x,y);
+ CREATE TRIGGER r1t2 AFTER UPDATE ON t2 BEGIN
+ INSERT INTO changes VALUES(new.a, new.b);
+ END;
+ }
+ execsql {
+ UPDATE t2 SET a=a+10;
+ SELECT * FROM changes;
+ }
+} {11 2}
+do_test triggerB-2.4 {
+ execsql {
+ CREATE TRIGGER r2t2 AFTER DELETE ON t2 BEGIN
+ INSERT INTO changes VALUES(old.a, old.c);
+ END;
+ }
+ catchsql {
+ DELETE FROM t2;
+ }
+} {1 {no such column: old.c}}
+
+# Triggers maintain a mask of columns from the invoking table that are
+# used in the trigger body as NEW.column or OLD.column. That mask is then
+# used to reduce the amount of information that needs to be loaded into
+# the NEW and OLD pseudo-tables at run-time.
+#
+# These tests cases check the logic for when there are many columns - more
+# than will fit in a bitmask.
+#
+do_test triggerB-3.1 {
+ execsql {
+ CREATE TABLE t3(
+ c0, c1, c2, c3, c4, c5, c6, c7, c8, c9,
+ c10, c11, c12, c13, c14, c15, c16, c17, c18, c19,
+ c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,
+ c30, c31, c32, c33, c34, c35, c36, c37, c38, c39,
+ c40, c41, c42, c43, c44, c45, c46, c47, c48, c49,
+ c50, c51, c52, c53, c54, c55, c56, c57, c58, c59,
+ c60, c61, c62, c63, c64, c65
+ );
+ CREATE TABLE t3_changes(colnum, oldval, newval);
+ INSERT INTO t3 VALUES(
+ 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9',
+ 'a10','a11','a12','a13','a14','a15','a16','a17','a18','a19',
+ 'a20','a21','a22','a23','a24','a25','a26','a27','a28','a29',
+ 'a30','a31','a32','a33','a34','a35','a36','a37','a38','a39',
+ 'a40','a41','a42','a43','a44','a45','a46','a47','a48','a49',
+ 'a50','a51','a52','a53','a54','a55','a56','a57','a58','a59',
+ 'a60','a61','a62','a63','a64','a65'
+ );
+ }
+ for {set i 0} {$i<=65} {incr i} {
+ set sql [subst {
+ CREATE TRIGGER t3c$i AFTER UPDATE ON t3
+ WHEN old.c$i!=new.c$i BEGIN
+ INSERT INTO t3_changes VALUES($i, old.c$i, new.c$i);
+ END
+ }]
+ db eval $sql
+ }
+ execsql {
+ SELECT * FROM t3_changes
+ }
+} {}
+for {set i 0} {$i<=64} {incr i} {
+ do_test triggerB-3.2.$i.1 [subst {
+ execsql {
+ UPDATE t3 SET c$i='b$i';
+ SELECT * FROM t3_changes ORDER BY rowid DESC LIMIT 1;
+ }
+ }] [subst {$i a$i b$i}]
+ do_test triggerB-3.2.$i.2 [subst {
+ execsql {
+ SELECT count(*) FROM t3_changes
+ }
+ }] [expr {$i+1}]
+ do_test triggerB-3.2.$i.2 [subst {
+ execsql {
+ SELECT * FROM t3_changes WHERE colnum=$i
+ }
+ }] [subst {$i a$i b$i}]
+}
+
+
+finish_test
diff --git a/test/triggerC.test b/test/triggerC.test
new file mode 100644
index 0000000..12a5e4a
--- /dev/null
+++ b/test/triggerC.test
@@ -0,0 +1,954 @@
+# 2009 August 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice', here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Test organization:
+#
+# triggerC-1.*: Haphazardly designed trigger related tests that were useful
+# during an upgrade of the triggers sub-system.
+#
+# triggerC-2.*:
+#
+# triggerC-3.*:
+#
+# triggerC-4.*:
+#
+# triggerC-5.*: Test that when recursive triggers are enabled DELETE
+# triggers are fired when rows are deleted as part of OR
+# REPLACE conflict resolution. And that they are not fired
+# if recursive triggers are not enabled.
+#
+# triggerC-6.*: Test that the recursive_triggers pragma returns correct
+# results when invoked without an argument.
+#
+
+# Enable recursive triggers for this file.
+#
+execsql { PRAGMA recursive_triggers = on }
+
+#sqlite3_db_config_lookaside db 0 0 0
+
+#-------------------------------------------------------------------------
+# This block of tests, triggerC-1.*, are not aimed at any specific
+# property of the triggers sub-system. They were created to debug
+# specific problems while modifying SQLite to support recursive
+# triggers. They are left here in case they can help debug the
+# same problems again.
+#
+do_test triggerC-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE log(t, a1, b1, c1, a2, b2, c2);
+ CREATE TRIGGER trig1 BEFORE INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('before', NULL, NULL, NULL, new.a, new.b, new.c);
+ END;
+ CREATE TRIGGER trig2 AFTER INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('after', NULL, NULL, NULL, new.a, new.b, new.c);
+ END;
+ CREATE TRIGGER trig3 BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES('before', old.a,old.b,old.c, new.a,new.b,new.c);
+ END;
+ CREATE TRIGGER trig4 AFTER UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES('after', old.a,old.b,old.c, new.a,new.b,new.c);
+ END;
+
+ CREATE TRIGGER trig5 BEFORE DELETE ON t1 BEGIN
+ INSERT INTO log VALUES('before', old.a,old.b,old.c, NULL,NULL,NULL);
+ END;
+ CREATE TRIGGER trig6 AFTER DELETE ON t1 BEGIN
+ INSERT INTO log VALUES('after', old.a,old.b,old.c, NULL,NULL,NULL);
+ END;
+ }
+} {}
+do_test triggerC-1.2 {
+ execsql {
+ INSERT INTO t1 VALUES('A', 'B', 'C');
+ SELECT * FROM log;
+ }
+} {before {} {} {} A B C after {} {} {} A B C}
+do_test triggerC-1.3 {
+ execsql { SELECT * FROM t1 }
+} {A B C}
+do_test triggerC-1.4 {
+ execsql {
+ DELETE FROM log;
+ UPDATE t1 SET a = 'a';
+ SELECT * FROM log;
+ }
+} {before A B C a B C after A B C a B C}
+do_test triggerC-1.5 {
+ execsql { SELECT * FROM t1 }
+} {a B C}
+do_test triggerC-1.6 {
+ execsql {
+ DELETE FROM log;
+ DELETE FROM t1;
+ SELECT * FROM log;
+ }
+} {before a B C {} {} {} after a B C {} {} {}}
+do_test triggerC-1.7 {
+ execsql { SELECT * FROM t1 }
+} {}
+do_test triggerC-1.8 {
+ execsql {
+ CREATE TABLE t4(a, b);
+ CREATE TRIGGER t4t AFTER DELETE ON t4 BEGIN
+ SELECT RAISE(ABORT, 'delete is not supported');
+ END;
+ }
+} {}
+do_test triggerC-1.9 {
+ execsql { INSERT INTO t4 VALUES(1, 2) }
+ catchsql { DELETE FROM t4 }
+} {1 {delete is not supported}}
+do_test triggerC-1.10 {
+ execsql { SELECT * FROM t4 }
+} {1 2}
+do_test triggerC-1.11 {
+ execsql {
+ CREATE TABLE t5 (a primary key, b, c);
+ INSERT INTO t5 values (1, 2, 3);
+ CREATE TRIGGER au_tbl AFTER UPDATE ON t5 BEGIN
+ UPDATE OR IGNORE t5 SET a = new.a, c = 10;
+ END;
+ }
+} {}
+do_test triggerC-1.12 {
+ catchsql { UPDATE OR REPLACE t5 SET a = 4 WHERE a = 1 }
+} {1 {too many levels of trigger recursion}}
+do_test triggerC-1.13 {
+ execsql {
+ CREATE TABLE t6(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t6 VALUES(1, 2);
+ create trigger r1 after update on t6 for each row begin
+ SELECT 1;
+ end;
+ UPDATE t6 SET a=a;
+ }
+} {}
+do_test triggerC-1.14 {
+ execsql {
+ DROP TABLE t1;
+ CREATE TABLE cnt(n);
+ INSERT INTO cnt VALUES(0);
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c, d, e);
+ CREATE INDEX t1cd ON t1(c,d);
+ CREATE TRIGGER t1r1 AFTER UPDATE ON t1 BEGIN UPDATE cnt SET n=n+1; END;
+ INSERT INTO t1 VALUES(1,2,3,4,5);
+ INSERT INTO t1 VALUES(6,7,8,9,10);
+ INSERT INTO t1 VALUES(11,12,13,14,15);
+ }
+} {}
+do_test triggerC-1.15 {
+ catchsql { UPDATE OR ROLLBACK t1 SET a=100 }
+} {1 {PRIMARY KEY must be unique}}
+
+
+#-------------------------------------------------------------------------
+# This block of tests, triggerC-2.*, tests that recursive trigger
+# programs (triggers that fire themselves) work. More specifically,
+# this block focuses on recursive INSERT triggers.
+#
+do_test triggerC-2.1.0 {
+ execsql {
+ CREATE TABLE t2(a PRIMARY KEY);
+ }
+} {}
+
+foreach {n tdefn rc} {
+ 1 {
+ CREATE TRIGGER t2_trig AFTER INSERT ON t2 WHEN (new.a>0) BEGIN
+ INSERT INTO t2 VALUES(new.a - 1);
+ END;
+ } {0 {10 9 8 7 6 5 4 3 2 1 0}}
+
+ 2 {
+ CREATE TRIGGER t2_trig AFTER INSERT ON t2 BEGIN
+ SELECT CASE WHEN new.a==2 THEN RAISE(IGNORE) ELSE NULL END;
+ INSERT INTO t2 VALUES(new.a - 1);
+ END;
+ } {0 {10 9 8 7 6 5 4 3 2}}
+
+ 3 {
+ CREATE TRIGGER t2_trig BEFORE INSERT ON t2 WHEN (new.a>0) BEGIN
+ INSERT INTO t2 VALUES(new.a - 1);
+ END;
+ } {0 {0 1 2 3 4 5 6 7 8 9 10}}
+
+ 4 {
+ CREATE TRIGGER t2_trig BEFORE INSERT ON t2 BEGIN
+ SELECT CASE WHEN new.a==2 THEN RAISE(IGNORE) ELSE NULL END;
+ INSERT INTO t2 VALUES(new.a - 1);
+ END;
+ } {0 {3 4 5 6 7 8 9 10}}
+
+ 5 {
+ CREATE TRIGGER t2_trig BEFORE INSERT ON t2 BEGIN
+ INSERT INTO t2 VALUES(new.a - 1);
+ END;
+ } {1 {too many levels of trigger recursion}}
+
+ 6 {
+ CREATE TRIGGER t2_trig AFTER INSERT ON t2 WHEN (new.a>0) BEGIN
+ INSERT OR IGNORE INTO t2 VALUES(new.a);
+ END;
+ } {0 10}
+
+ 7 {
+ CREATE TRIGGER t2_trig BEFORE INSERT ON t2 WHEN (new.a>0) BEGIN
+ INSERT OR IGNORE INTO t2 VALUES(new.a);
+ END;
+ } {1 {too many levels of trigger recursion}}
+} {
+ do_test triggerC-2.1.$n {
+ catchsql { DROP TRIGGER t2_trig }
+ execsql { DELETE FROM t2 }
+ execsql $tdefn
+ catchsql {
+ INSERT INTO t2 VALUES(10);
+ SELECT * FROM t2;
+ }
+ } $rc
+}
+
+do_test triggerC-2.2 {
+ execsql "
+ CREATE TABLE t22(x);
+
+ CREATE TRIGGER t22a AFTER INSERT ON t22 BEGIN
+ INSERT INTO t22 SELECT x + (SELECT max(x) FROM t22) FROM t22;
+ END;
+ CREATE TRIGGER t22b BEFORE INSERT ON t22 BEGIN
+ SELECT CASE WHEN (SELECT count(*) FROM t22) >= [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]
+ THEN RAISE(IGNORE)
+ ELSE NULL END;
+ END;
+
+ INSERT INTO t22 VALUES(1);
+ SELECT count(*) FROM t22;
+ "
+} [list [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]]
+
+do_test triggerC-2.3 {
+ execsql "
+ CREATE TABLE t23(x PRIMARY KEY);
+
+ CREATE TRIGGER t23a AFTER INSERT ON t23 BEGIN
+ INSERT INTO t23 VALUES(new.x + 1);
+ END;
+
+ CREATE TRIGGER t23b BEFORE INSERT ON t23 BEGIN
+ SELECT CASE WHEN new.x>[expr $SQLITE_MAX_TRIGGER_DEPTH / 2]
+ THEN RAISE(IGNORE)
+ ELSE NULL END;
+ END;
+
+ INSERT INTO t23 VALUES(1);
+ SELECT count(*) FROM t23;
+ "
+} [list [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]]
+
+
+#-----------------------------------------------------------------------
+# This block of tests, triggerC-3.*, test that SQLite throws an exception
+# when it detects excessive recursion.
+#
+do_test triggerC-3.1.1 {
+ execsql {
+ CREATE TABLE t3(a, b);
+ CREATE TRIGGER t3i AFTER INSERT ON t3 BEGIN
+ DELETE FROM t3 WHERE rowid = new.rowid;
+ END;
+ CREATE TRIGGER t3d AFTER DELETE ON t3 BEGIN
+ INSERT INTO t3 VALUES(old.a, old.b);
+ END;
+ }
+} {}
+do_test triggerC-3.1.2 {
+ catchsql { INSERT INTO t3 VALUES(0,0) }
+} {1 {too many levels of trigger recursion}}
+do_test triggerC-3.1.3 {
+ execsql { SELECT * FROM t3 }
+} {}
+
+do_test triggerC-3.2.1 {
+ execsql "
+ CREATE TABLE t3b(x);
+ CREATE TRIGGER t3bi AFTER INSERT ON t3b WHEN new.x<[expr $SQLITE_MAX_TRIGGER_DEPTH * 2] BEGIN
+ INSERT INTO t3b VALUES(new.x+1);
+ END;
+ "
+ catchsql {
+ INSERT INTO t3b VALUES(1);
+ }
+} {1 {too many levels of trigger recursion}}
+do_test triggerC-3.2.2 {
+ db eval {SELECT * FROM t3b}
+} {}
+
+do_test triggerC-3.3.1 {
+ catchsql "
+ INSERT INTO t3b VALUES([expr $SQLITE_MAX_TRIGGER_DEPTH + 1]);
+ "
+} {0 {}}
+do_test triggerC-3.3.2 {
+ db eval {SELECT count(*), max(x), min(x) FROM t3b}
+} [list $SQLITE_MAX_TRIGGER_DEPTH [expr $SQLITE_MAX_TRIGGER_DEPTH * 2] [expr $SQLITE_MAX_TRIGGER_DEPTH + 1]]
+
+do_test triggerC-3.4.1 {
+ catchsql "
+ DELETE FROM t3b;
+ INSERT INTO t3b VALUES([expr $SQLITE_MAX_TRIGGER_DEPTH - 1]);
+ "
+} {1 {too many levels of trigger recursion}}
+do_test triggerC-3.4.2 {
+ db eval {SELECT count(*), max(x), min(x) FROM t3b}
+} {0 {} {}}
+
+do_test triggerC-3.5.1 {
+ sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH [expr $SQLITE_MAX_TRIGGER_DEPTH / 10]
+ catchsql "
+ INSERT INTO t3b VALUES([expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - ($SQLITE_MAX_TRIGGER_DEPTH / 10) + 1]);
+ "
+} {0 {}}
+do_test triggerC-3.5.2 {
+ db eval {SELECT count(*), max(x), min(x) FROM t3b}
+} [list [expr $SQLITE_MAX_TRIGGER_DEPTH / 10] [expr $SQLITE_MAX_TRIGGER_DEPTH * 2] [expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - ($SQLITE_MAX_TRIGGER_DEPTH / 10) + 1]]
+
+do_test triggerC-3.5.3 {
+ catchsql "
+ DELETE FROM t3b;
+ INSERT INTO t3b VALUES([expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - ($SQLITE_MAX_TRIGGER_DEPTH / 10)]);
+ "
+} {1 {too many levels of trigger recursion}}
+do_test triggerC-3.5.4 {
+ db eval {SELECT count(*), max(x), min(x) FROM t3b}
+} {0 {} {}}
+
+do_test triggerC-3.6.1 {
+ sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1
+ catchsql "
+ INSERT INTO t3b VALUES([expr $SQLITE_MAX_TRIGGER_DEPTH * 2]);
+ "
+} {0 {}}
+do_test triggerC-3.6.2 {
+ db eval {SELECT count(*), max(x), min(x) FROM t3b}
+} [list 1 [expr $SQLITE_MAX_TRIGGER_DEPTH * 2] [expr $SQLITE_MAX_TRIGGER_DEPTH * 2]]
+
+do_test triggerC-3.6.3 {
+ catchsql "
+ DELETE FROM t3b;
+ INSERT INTO t3b VALUES([expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - 1]);
+ "
+} {1 {too many levels of trigger recursion}}
+do_test triggerC-3.6.4 {
+ db eval {SELECT count(*), max(x), min(x) FROM t3b}
+} {0 {} {}}
+sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH $SQLITE_MAX_TRIGGER_DEPTH
+
+
+#-----------------------------------------------------------------------
+# This next block of tests, triggerC-4.*, checks that affinity
+# transformations and constraint processing is performed at the correct
+# times relative to BEFORE and AFTER triggers.
+#
+# For an INSERT statement, for each row to be inserted:
+#
+# 1. Apply affinities to non-rowid values to be inserted.
+# 2. Fire BEFORE triggers.
+# 3. Process constraints.
+# 4. Insert new record.
+# 5. Fire AFTER triggers.
+#
+# If the value of the rowid field is to be automatically assigned, it is
+# set to -1 in the new.* record. Even if it is explicitly set to NULL
+# by the INSERT statement.
+#
+# For an UPDATE statement, for each row to be deleted:
+#
+# 1. Apply affinities to non-rowid values to be inserted.
+# 2. Fire BEFORE triggers.
+# 3. Process constraints.
+# 4. Insert new record.
+# 5. Fire AFTER triggers.
+#
+# For a DELETE statement, for each row to be deleted:
+#
+# 1. Fire BEFORE triggers.
+# 2. Remove database record.
+# 3. Fire AFTER triggers.
+#
+# When a numeric value that as an exact integer representation is stored
+# in a column with REAL affinity, it is actually stored as an integer.
+# These tests check that the typeof() such values is always 'real',
+# not 'integer'.
+#
+# triggerC-4.1.*: Check that affinity transformations are made before
+# triggers are invoked.
+#
+do_test triggerC-4.1.1 {
+ catchsql { DROP TABLE log }
+ catchsql { DROP TABLE t4 }
+ execsql {
+ CREATE TABLE log(t);
+ CREATE TABLE t4(a TEXT,b INTEGER,c REAL);
+ CREATE TRIGGER t4bi BEFORE INSERT ON t4 BEGIN
+ INSERT INTO log VALUES(new.rowid || ' ' || typeof(new.rowid) || ' ' ||
+ new.a || ' ' || typeof(new.a) || ' ' ||
+ new.b || ' ' || typeof(new.b) || ' ' ||
+ new.c || ' ' || typeof(new.c)
+ );
+ END;
+ CREATE TRIGGER t4ai AFTER INSERT ON t4 BEGIN
+ INSERT INTO log VALUES(new.rowid || ' ' || typeof(new.rowid) || ' ' ||
+ new.a || ' ' || typeof(new.a) || ' ' ||
+ new.b || ' ' || typeof(new.b) || ' ' ||
+ new.c || ' ' || typeof(new.c)
+ );
+ END;
+ CREATE TRIGGER t4bd BEFORE DELETE ON t4 BEGIN
+ INSERT INTO log VALUES(old.rowid || ' ' || typeof(old.rowid) || ' ' ||
+ old.a || ' ' || typeof(old.a) || ' ' ||
+ old.b || ' ' || typeof(old.b) || ' ' ||
+ old.c || ' ' || typeof(old.c)
+ );
+ END;
+ CREATE TRIGGER t4ad AFTER DELETE ON t4 BEGIN
+ INSERT INTO log VALUES(old.rowid || ' ' || typeof(old.rowid) || ' ' ||
+ old.a || ' ' || typeof(old.a) || ' ' ||
+ old.b || ' ' || typeof(old.b) || ' ' ||
+ old.c || ' ' || typeof(old.c)
+ );
+ END;
+ CREATE TRIGGER t4bu BEFORE UPDATE ON t4 BEGIN
+ INSERT INTO log VALUES(old.rowid || ' ' || typeof(old.rowid) || ' ' ||
+ old.a || ' ' || typeof(old.a) || ' ' ||
+ old.b || ' ' || typeof(old.b) || ' ' ||
+ old.c || ' ' || typeof(old.c)
+ );
+ INSERT INTO log VALUES(new.rowid || ' ' || typeof(new.rowid) || ' ' ||
+ new.a || ' ' || typeof(new.a) || ' ' ||
+ new.b || ' ' || typeof(new.b) || ' ' ||
+ new.c || ' ' || typeof(new.c)
+ );
+ END;
+ CREATE TRIGGER t4au AFTER UPDATE ON t4 BEGIN
+ INSERT INTO log VALUES(old.rowid || ' ' || typeof(old.rowid) || ' ' ||
+ old.a || ' ' || typeof(old.a) || ' ' ||
+ old.b || ' ' || typeof(old.b) || ' ' ||
+ old.c || ' ' || typeof(old.c)
+ );
+ INSERT INTO log VALUES(new.rowid || ' ' || typeof(new.rowid) || ' ' ||
+ new.a || ' ' || typeof(new.a) || ' ' ||
+ new.b || ' ' || typeof(new.b) || ' ' ||
+ new.c || ' ' || typeof(new.c)
+ );
+ END;
+ }
+} {}
+foreach {n insert log} {
+
+ 2 {
+ INSERT INTO t4 VALUES('1', '1', '1');
+ DELETE FROM t4;
+ } {
+ -1 integer 1 text 1 integer 1.0 real
+ 1 integer 1 text 1 integer 1.0 real
+ 1 integer 1 text 1 integer 1.0 real
+ 1 integer 1 text 1 integer 1.0 real
+ }
+
+ 3 {
+ INSERT INTO t4(rowid,a,b,c) VALUES(45, 45, 45, 45);
+ DELETE FROM t4;
+ } {
+ 45 integer 45 text 45 integer 45.0 real
+ 45 integer 45 text 45 integer 45.0 real
+ 45 integer 45 text 45 integer 45.0 real
+ 45 integer 45 text 45 integer 45.0 real
+ }
+
+ 4 {
+ INSERT INTO t4(rowid,a,b,c) VALUES(-42.0, -42.0, -42.0, -42.0);
+ DELETE FROM t4;
+ } {
+ -42 integer -42.0 text -42 integer -42.0 real
+ -42 integer -42.0 text -42 integer -42.0 real
+ -42 integer -42.0 text -42 integer -42.0 real
+ -42 integer -42.0 text -42 integer -42.0 real
+ }
+
+ 5 {
+ INSERT INTO t4(rowid,a,b,c) VALUES(NULL, -42.4, -42.4, -42.4);
+ DELETE FROM t4;
+ } {
+ -1 integer -42.4 text -42.4 real -42.4 real
+ 1 integer -42.4 text -42.4 real -42.4 real
+ 1 integer -42.4 text -42.4 real -42.4 real
+ 1 integer -42.4 text -42.4 real -42.4 real
+ }
+
+ 6 {
+ INSERT INTO t4 VALUES(7, 7, 7);
+ UPDATE t4 SET a=8, b=8, c=8;
+ } {
+ -1 integer 7 text 7 integer 7.0 real
+ 1 integer 7 text 7 integer 7.0 real
+ 1 integer 7 text 7 integer 7.0 real
+ 1 integer 8 text 8 integer 8.0 real
+ 1 integer 7 text 7 integer 7.0 real
+ 1 integer 8 text 8 integer 8.0 real
+ }
+
+ 7 {
+ UPDATE t4 SET rowid=2;
+ } {
+ 1 integer 8 text 8 integer 8.0 real
+ 2 integer 8 text 8 integer 8.0 real
+ 1 integer 8 text 8 integer 8.0 real
+ 2 integer 8 text 8 integer 8.0 real
+ }
+
+ 8 {
+ UPDATE t4 SET a='9', b='9', c='9';
+ } {
+ 2 integer 8 text 8 integer 8.0 real
+ 2 integer 9 text 9 integer 9.0 real
+ 2 integer 8 text 8 integer 8.0 real
+ 2 integer 9 text 9 integer 9.0 real
+ }
+
+ 9 {
+ UPDATE t4 SET a='9.1', b='9.1', c='9.1';
+ } {
+ 2 integer 9 text 9 integer 9.0 real
+ 2 integer 9.1 text 9.1 real 9.1 real
+ 2 integer 9 text 9 integer 9.0 real
+ 2 integer 9.1 text 9.1 real 9.1 real
+ }
+} {
+ do_test triggerC-4.1.$n {
+ eval concat [execsql "
+ DELETE FROM log;
+ $insert ;
+ SELECT * FROM log;
+ "]
+ } [join $log " "]
+}
+
+#-------------------------------------------------------------------------
+# This block of tests, triggerC-5.*, test that DELETE triggers are fired
+# if a row is deleted as a result of OR REPLACE conflict resolution.
+#
+do_test triggerC-5.1.0 {
+ execsql {
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t5(a INTEGER PRIMARY KEY, b);
+ CREATE UNIQUE INDEX t5i ON t5(b);
+ INSERT INTO t5 VALUES(1, 'a');
+ INSERT INTO t5 VALUES(2, 'b');
+ INSERT INTO t5 VALUES(3, 'c');
+
+ CREATE TABLE t5g(a, b, c);
+ CREATE TRIGGER t5t BEFORE DELETE ON t5 BEGIN
+ INSERT INTO t5g VALUES(old.a, old.b, (SELECT count(*) FROM t5));
+ END;
+ }
+} {}
+foreach {n dml t5g t5} {
+ 1 "DELETE FROM t5 WHERE a=2" {2 b 3} {1 a 3 c}
+ 2 "INSERT OR REPLACE INTO t5 VALUES(2, 'd')" {2 b 3} {1 a 2 d 3 c}
+ 3 "UPDATE OR REPLACE t5 SET a = 2 WHERE a = 3" {2 b 3} {1 a 2 c}
+ 4 "INSERT OR REPLACE INTO t5 VALUES(4, 'b')" {2 b 3} {1 a 3 c 4 b}
+ 5 "UPDATE OR REPLACE t5 SET b = 'b' WHERE b = 'c'" {2 b 3} {1 a 3 b}
+ 6 "INSERT OR REPLACE INTO t5 VALUES(2, 'c')" {2 b 3 3 c 2} {1 a 2 c}
+ 7 "UPDATE OR REPLACE t5 SET a=1, b='b' WHERE a = 3" {1 a 3 2 b 2} {1 b}
+} {
+ do_test triggerC-5.1.$n {
+ execsql "
+ BEGIN;
+ $dml ;
+ SELECT * FROM t5g;
+ SELECT * FROM t5;
+ ROLLBACK;
+ "
+ } [concat $t5g $t5]
+}
+do_test triggerC-5.2.0 {
+ execsql {
+ DROP TRIGGER t5t;
+ CREATE TRIGGER t5t AFTER DELETE ON t5 BEGIN
+ INSERT INTO t5g VALUES(old.a, old.b, (SELECT count(*) FROM t5));
+ END;
+ }
+} {}
+foreach {n dml t5g t5} {
+ 1 "DELETE FROM t5 WHERE a=2" {2 b 2} {1 a 3 c}
+ 2 "INSERT OR REPLACE INTO t5 VALUES(2, 'd')" {2 b 2} {1 a 2 d 3 c}
+ 3 "UPDATE OR REPLACE t5 SET a = 2 WHERE a = 3" {2 b 2} {1 a 2 c}
+ 4 "INSERT OR REPLACE INTO t5 VALUES(4, 'b')" {2 b 2} {1 a 3 c 4 b}
+ 5 "UPDATE OR REPLACE t5 SET b = 'b' WHERE b = 'c'" {2 b 2} {1 a 3 b}
+ 6 "INSERT OR REPLACE INTO t5 VALUES(2, 'c')" {2 b 2 3 c 1} {1 a 2 c}
+ 7 "UPDATE OR REPLACE t5 SET a=1, b='b' WHERE a = 3" {1 a 2 2 b 1} {1 b}
+} {
+ do_test triggerC-5.2.$n {
+ execsql "
+ BEGIN;
+ $dml ;
+ SELECT * FROM t5g;
+ SELECT * FROM t5;
+ ROLLBACK;
+ "
+ } [concat $t5g $t5]
+}
+do_test triggerC-5.3.0 {
+ execsql { PRAGMA recursive_triggers = off }
+} {}
+foreach {n dml t5g t5} {
+ 1 "DELETE FROM t5 WHERE a=2" {2 b 2} {1 a 3 c}
+ 2 "INSERT OR REPLACE INTO t5 VALUES(2, 'd')" {} {1 a 2 d 3 c}
+ 3 "UPDATE OR REPLACE t5 SET a = 2 WHERE a = 3" {} {1 a 2 c}
+ 4 "INSERT OR REPLACE INTO t5 VALUES(4, 'b')" {} {1 a 3 c 4 b}
+ 5 "UPDATE OR REPLACE t5 SET b = 'b' WHERE b = 'c'" {} {1 a 3 b}
+ 6 "INSERT OR REPLACE INTO t5 VALUES(2, 'c')" {} {1 a 2 c}
+ 7 "UPDATE OR REPLACE t5 SET a=1, b='b' WHERE a = 3" {} {1 b}
+} {
+ do_test triggerC-5.3.$n {
+ execsql "
+ BEGIN;
+ $dml ;
+ SELECT * FROM t5g;
+ SELECT * FROM t5;
+ ROLLBACK;
+ "
+ } [concat $t5g $t5]
+}
+do_test triggerC-5.3.8 {
+ execsql { PRAGMA recursive_triggers = on }
+} {}
+
+#-------------------------------------------------------------------------
+# This block of tests, triggerC-6.*, tests that "PRAGMA recursive_triggers"
+# statements return the current value of the recursive triggers flag.
+#
+do_test triggerC-6.1 {
+ execsql { PRAGMA recursive_triggers }
+} {1}
+do_test triggerC-6.2 {
+ execsql {
+ PRAGMA recursive_triggers = off;
+ PRAGMA recursive_triggers;
+ }
+} {0}
+do_test triggerC-6.3 {
+ execsql {
+ PRAGMA recursive_triggers = on;
+ PRAGMA recursive_triggers;
+ }
+} {1}
+
+#-------------------------------------------------------------------------
+# Test some of the "undefined behaviour" associated with triggers. The
+# undefined behaviour occurs when a row being updated or deleted is
+# manipulated by a BEFORE trigger.
+#
+do_test triggerC-7.1 {
+ execsql {
+ CREATE TABLE t8(x);
+ CREATE TABLE t7(a, b);
+ INSERT INTO t7 VALUES(1, 2);
+ INSERT INTO t7 VALUES(3, 4);
+ INSERT INTO t7 VALUES(5, 6);
+ CREATE TRIGGER t7t BEFORE UPDATE ON t7 BEGIN
+ DELETE FROM t7 WHERE a = 1;
+ END;
+ CREATE TRIGGER t7ta AFTER UPDATE ON t7 BEGIN
+ INSERT INTO t8 VALUES('after fired ' || old.rowid || '->' || new.rowid);
+ END;
+ }
+} {}
+do_test triggerC-7.2 {
+ execsql {
+ BEGIN;
+ UPDATE t7 SET b=7 WHERE a = 5;
+ SELECT * FROM t7;
+ SELECT * FROM t8;
+ ROLLBACK;
+ }
+} {3 4 5 7 {after fired 3->3}}
+do_test triggerC-7.3 {
+ execsql {
+ BEGIN;
+ UPDATE t7 SET b=7 WHERE a = 1;
+ SELECT * FROM t7;
+ SELECT * FROM t8;
+ ROLLBACK;
+ }
+} {3 4 5 6}
+
+do_test triggerC-7.4 {
+ execsql {
+ DROP TRIGGER t7t;
+ CREATE TRIGGER t7t BEFORE UPDATE ON t7 WHEN (old.rowid!=1 OR new.rowid!=8)
+ BEGIN
+ UPDATE t7 set rowid = 8 WHERE rowid=1;
+ END;
+ }
+} {}
+do_test triggerC-7.5 {
+ execsql {
+ BEGIN;
+ UPDATE t7 SET b=7 WHERE a = 5;
+ SELECT rowid, * FROM t7;
+ SELECT * FROM t8;
+ ROLLBACK;
+ }
+} {2 3 4 3 5 7 8 1 2 {after fired 1->8} {after fired 3->3}}
+do_test triggerC-7.6 {
+ execsql {
+ BEGIN;
+ UPDATE t7 SET b=7 WHERE a = 1;
+ SELECT rowid, * FROM t7;
+ SELECT * FROM t8;
+ ROLLBACK;
+ }
+} {2 3 4 3 5 6 8 1 2 {after fired 1->8}}
+
+do_test triggerC-7.7 {
+ execsql {
+ DROP TRIGGER t7t;
+ DROP TRIGGER t7ta;
+ CREATE TRIGGER t7t BEFORE DELETE ON t7 BEGIN
+ UPDATE t7 set rowid = 8 WHERE rowid=1;
+ END;
+ CREATE TRIGGER t7ta AFTER DELETE ON t7 BEGIN
+ INSERT INTO t8 VALUES('after fired ' || old.rowid);
+ END;
+ }
+} {}
+do_test triggerC-7.8 {
+ execsql {
+ BEGIN;
+ DELETE FROM t7 WHERE a = 3;
+ SELECT rowid, * FROM t7;
+ SELECT * FROM t8;
+ ROLLBACK;
+ }
+} {3 5 6 8 1 2 {after fired 2}}
+do_test triggerC-7.9 {
+ execsql {
+ BEGIN;
+ DELETE FROM t7 WHERE a = 1;
+ SELECT rowid, * FROM t7;
+ SELECT * FROM t8;
+ ROLLBACK;
+ }
+} {2 3 4 3 5 6 8 1 2}
+
+# Ticket [e25d9ea771febc9c311928c1c01c3163dcb26643]
+#
+do_test triggerC-9.1 {
+ execsql {
+ CREATE TABLE t9(a,b);
+ CREATE INDEX t9b ON t9(b);
+ INSERT INTO t9 VALUES(1,0);
+ INSERT INTO t9 VALUES(2,1);
+ INSERT INTO t9 VALUES(3,2);
+ INSERT INTO t9 SELECT a+3, a+2 FROM t9;
+ INSERT INTO t9 SELECT a+6, a+5 FROM t9;
+ SELECT a FROM t9 ORDER BY a;
+ }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+do_test triggerC-9.2 {
+ execsql {
+ CREATE TRIGGER t9r1 AFTER DELETE ON t9 BEGIN
+ DELETE FROM t9 WHERE b=old.a;
+ END;
+ DELETE FROM t9 WHERE b=4;
+ SELECT a FROM t9 ORDER BY a;
+ }
+} {1 2 3 4}
+
+# At one point (between versions 3.6.18 and 3.6.20 inclusive), an UPDATE
+# that fired a BEFORE trigger that itself updated the same row as the
+# statement causing it to fire was causing a strange side-effect: The
+# values updated by the statement within the trigger were being overwritten
+# by the values in the new.* array, even if those values were not
+# themselves written by the parent UPDATE statement.
+#
+# Technically speaking this was not a bug. The SQLite documentation says
+# that if a BEFORE UPDATE or BEFORE DELETE trigger modifies or deletes the
+# row that the parent statement is operating on the results are undefined.
+# But as of 3.6.21 behaviour is restored to the way it was in versions
+# 3.6.17 and earlier to avoid causing unnecessary difficulties.
+#
+do_test triggerC-10.1 {
+ execsql {
+ CREATE TABLE t10(a, updatecnt DEFAULT 0);
+ CREATE TRIGGER t10_bu BEFORE UPDATE OF a ON t10 BEGIN
+ UPDATE t10 SET updatecnt = updatecnt+1 WHERE rowid = old.rowid;
+ END;
+ INSERT INTO t10(a) VALUES('hello');
+ }
+
+ # Before the problem was fixed, table t10 would contain the tuple
+ # (world, 0) after running the following script (because the value
+ # 1 written to column "updatecnt" was clobbered by the old value 0).
+ #
+ execsql {
+ UPDATE t10 SET a = 'world';
+ SELECT * FROM t10;
+ }
+} {world 1}
+
+do_test triggerC-10.2 {
+ execsql {
+ UPDATE t10 SET a = 'tcl', updatecnt = 5;
+ SELECT * FROM t10;
+ }
+} {tcl 5}
+
+do_test triggerC-10.3 {
+ execsql {
+ CREATE TABLE t11(
+ c1, c2, c3, c4, c5, c6, c7, c8, c9, c10,
+ c11, c12, c13, c14, c15, c16, c17, c18, c19, c20,
+ c21, c22, c23, c24, c25, c26, c27, c28, c29, c30,
+ c31, c32, c33, c34, c35, c36, c37, c38, c39, c40
+ );
+
+ CREATE TRIGGER t11_bu BEFORE UPDATE OF c1 ON t11 BEGIN
+ UPDATE t11 SET c31 = c31+1, c32=c32+1 WHERE rowid = old.rowid;
+ END;
+
+ INSERT INTO t11 VALUES(
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
+ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40
+ );
+ }
+
+ # Before the problem was fixed, table t10 would contain the tuple
+ # (world, 0) after running the following script (because the value
+ # 1 written to column "updatecnt" was clobbered by the old value 0).
+ #
+ execsql {
+ UPDATE t11 SET c4=35, c33=22, c1=5;
+ SELECT * FROM t11;
+ }
+} {5 2 3 35 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 32 33 22 34 35 36 37 38 39 40}
+
+#-------------------------------------------------------------------------
+# Test that bug [371bab5d65] has been fixed. BEFORE INSERT and INSTEAD OF
+# INSERT triggers with the DEFAULT VALUES INSERT syntax.
+#
+do_test triggerC-11.0 {
+ catchsql { DROP TABLE log }
+ execsql { CREATE TABLE log(a, b) }
+} {}
+
+foreach {testno tbl defaults} {
+ 1 "CREATE TABLE t1(a, b)" {{} {}}
+ 2 "CREATE TABLE t1(a DEFAULT 1, b DEFAULT 'abc')" {1 abc}
+ 3 "CREATE TABLE t1(a, b DEFAULT 4.5)" {{} 4.5}
+} {
+ do_test triggerC-11.$testno.1 {
+ catchsql { DROP TABLE t1 }
+ execsql { DELETE FROM log }
+ execsql $tbl
+ execsql {
+ CREATE TRIGGER tt1 BEFORE INSERT ON t1 BEGIN
+ INSERT INTO log VALUES(new.a, new.b);
+ END;
+ INSERT INTO t1 DEFAULT VALUES;
+ SELECT * FROM log;
+ }
+ } $defaults
+
+ do_test triggerC-11.$testno.2 {
+ execsql { DELETE FROM log }
+ execsql {
+ CREATE TRIGGER tt2 AFTER INSERT ON t1 BEGIN
+ INSERT INTO log VALUES(new.a, new.b);
+ END;
+ INSERT INTO t1 DEFAULT VALUES;
+ SELECT * FROM log;
+ }
+ } [concat $defaults $defaults]
+
+ do_test triggerC-11.$testno.3 {
+ execsql { DROP TRIGGER tt1 }
+ execsql { DELETE FROM log }
+ execsql {
+ INSERT INTO t1 DEFAULT VALUES;
+ SELECT * FROM log;
+ }
+ } $defaults
+}
+do_test triggerC-11.4 {
+ catchsql { DROP TABLE t2 }
+ execsql {
+ DELETE FROM log;
+ CREATE TABLE t2(a, b);
+ CREATE VIEW v2 AS SELECT * FROM t2;
+ CREATE TRIGGER tv2 INSTEAD OF INSERT ON v2 BEGIN
+ INSERT INTO log VALUES(new.a, new.b);
+ END;
+ INSERT INTO v2 DEFAULT VALUES;
+ SELECT a, b, a IS NULL, b IS NULL FROM log;
+ }
+} {{} {} 1 1}
+
+do_test triggerC-12.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1 ; END ;
+ SELECT count(*) FROM sqlite_master;
+ }
+} {2}
+do_test triggerC-12.2 {
+ db eval { SELECT * FROM t1 } {
+ if {$a == 3} { execsql { DROP TRIGGER tr1 } }
+ }
+ execsql { SELECT count(*) FROM sqlite_master }
+} {1}
+
+do_execsql_test triggerC-13.1 {
+ PRAGMA recursive_triggers = ON;
+ CREATE TABLE t12(a, b);
+ INSERT INTO t12 VALUES(1, 2);
+ CREATE TRIGGER tr12 AFTER UPDATE ON t12 BEGIN
+ UPDATE t12 SET a=new.a+1, b=new.b+1;
+ END;
+} {}
+do_catchsql_test triggerC-13.2 {
+ UPDATE t12 SET a=a+1, b=b+1;
+} {1 {too many levels of trigger recursion}}
+
+
+
+finish_test
diff --git a/test/triggerD.test b/test/triggerD.test
new file mode 100644
index 0000000..a5dd4bd
--- /dev/null
+++ b/test/triggerD.test
@@ -0,0 +1,219 @@
+# 2009 December 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice', here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Verify that when columns named "rowid", "oid", and "_rowid_" appear
+# in a table as ordinary columns (not as the INTEGER PRIMARY KEY) then
+# the use of these columns in triggers will refer to the column and not
+# to the actual ROWID. Ticket [34d2ae1c6d08b5271ba5e5592936d4a1d913ffe3]
+#
+# Also, verify that triggers created like this:
+#
+# CREATE TRIGGER attached.trig AFTER INSERT ON attached.tab ...
+#
+# can be reparsed as a main database. Ticket [d6ddba6706353915ceedc56b4e3]
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# Triggers on tables where the table has ordinary columns named
+# rowid, oid, and _rowid_.
+#
+do_test triggerD-1.1 {
+ db eval {
+ CREATE TABLE t1(rowid, oid, _rowid_, x);
+ CREATE TABLE log(a,b,c,d,e);
+ CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('r1', new.rowid, new.oid, new._rowid_, new.x);
+ END;
+ CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('r2', new.rowid, new.oid, new._rowid_, new.x);
+ END;
+ CREATE TRIGGER r3 BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES('r3.old', old.rowid, old.oid, old._rowid_, old.x);
+ INSERT INTO log VALUES('r3.new', new.rowid, new.oid, new._rowid_, new.x);
+ END;
+ CREATE TRIGGER r4 AFTER UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES('r4.old', old.rowid, old.oid, old._rowid_, old.x);
+ INSERT INTO log VALUES('r4.new', new.rowid, new.oid, new._rowid_, new.x);
+ END;
+ CREATE TRIGGER r5 BEFORE DELETE ON t1 BEGIN
+ INSERT INTO log VALUES('r5', old.rowid, old.oid, old._rowid_, old.x);
+ END;
+ CREATE TRIGGER r6 AFTER DELETE ON t1 BEGIN
+ INSERT INTO log VALUES('r6', old.rowid, old.oid, old._rowid_, old.x);
+ END;
+ }
+} {}
+do_test triggerD-1.2 {
+ db eval {
+ INSERT INTO t1 VALUES(100,200,300,400);
+ SELECT * FROM log
+ }
+} {r1 100 200 300 400 r2 100 200 300 400}
+do_test triggerD-1.3 {
+ db eval {
+ DELETE FROM log;
+ UPDATE t1 SET rowid=rowid+1;
+ SELECT * FROM log
+ }
+} {r3.old 100 200 300 400 r3.new 101 200 300 400 r4.old 100 200 300 400 r4.new 101 200 300 400}
+do_test triggerD-1.4 {
+ db eval {
+ DELETE FROM log;
+ DELETE FROM t1;
+ SELECT * FROM log
+ }
+} {r5 101 200 300 400 r6 101 200 300 400}
+
+# Triggers on tables where the table does not have ordinary columns named
+# rowid, oid, and _rowid_.
+#
+do_test triggerD-2.1 {
+ db eval {
+ DROP TABLE t1;
+ CREATE TABLE t1(w,x,y,z);
+ CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('r1', new.rowid, new.oid, new._rowid_, new.x);
+ END;
+ CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('r2', new.rowid, new.oid, new._rowid_, new.x);
+ END;
+ CREATE TRIGGER r3 BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES('r3.old', old.rowid, old.oid, old._rowid_, old.x);
+ INSERT INTO log VALUES('r3.new', new.rowid, new.oid, new._rowid_, new.x);
+ END;
+ CREATE TRIGGER r4 AFTER UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES('r4.old', old.rowid, old.oid, old._rowid_, old.x);
+ INSERT INTO log VALUES('r4.new', new.rowid, new.oid, new._rowid_, new.x);
+ END;
+ CREATE TRIGGER r5 BEFORE DELETE ON t1 BEGIN
+ INSERT INTO log VALUES('r5', old.rowid, old.oid, old._rowid_, old.x);
+ END;
+ CREATE TRIGGER r6 AFTER DELETE ON t1 BEGIN
+ INSERT INTO log VALUES('r6', old.rowid, old.oid, old._rowid_, old.x);
+ END;
+ }
+} {}
+do_test triggerD-2.2 {
+ db eval {
+ DELETE FROM log;
+ INSERT INTO t1 VALUES(100,200,300,400);
+ SELECT * FROM log;
+ }
+} {r1 -1 -1 -1 200 r2 1 1 1 200}
+do_test triggerD-2.3 {
+ db eval {
+ DELETE FROM log;
+ UPDATE t1 SET x=x+1;
+ SELECT * FROM log
+ }
+} {r3.old 1 1 1 200 r3.new 1 1 1 201 r4.old 1 1 1 200 r4.new 1 1 1 201}
+do_test triggerD-2.4 {
+ db eval {
+ DELETE FROM log;
+ DELETE FROM t1;
+ SELECT * FROM log
+ }
+} {r5 1 1 1 201 r6 1 1 1 201}
+
+
+###########################################################################
+#
+# Ticket [985771e1161200ae5eac3162686ea6711c035d08]:
+#
+# When both a main database table and a TEMP table have the same name,
+# and a main database trigge is created on the main table, the trigger
+# is incorrectly bound to the TEMP table. For example:
+#
+# CREATE TABLE t1(x);
+# CREATE TEMP TABLE t1(x);
+# CREATE TABLE t2(z);
+# CREATE TRIGGER main.r1 AFTER INSERT ON t1 BEGIN
+# INSERT INTO t2 VALUES(10000 + new.x);
+# END;
+# INSERT INTO main.t1 VALUES(3);
+# INSERT INTO temp.t1 VALUES(4);
+# SELECT * FROM t2;
+#
+# The r1 trigger fires when the value 4 is inserted into the temp.t1
+# table, rather than when value 3 is inserted into main.t1.
+#
+do_test triggerD-3.1 {
+ db eval {
+ CREATE TABLE t300(x);
+ CREATE TEMP TABLE t300(x);
+ CREATE TABLE t301(y);
+ CREATE TRIGGER main.r300 AFTER INSERT ON t300 BEGIN
+ INSERT INTO t301 VALUES(10000 + new.x);
+ END;
+ INSERT INTO main.t300 VALUES(3);
+ INSERT INTO temp.t300 VALUES(4);
+ SELECT * FROM t301;
+ }
+} {10003}
+do_test triggerD-3.2 {
+ db eval {
+ DELETE FROM t301;
+ CREATE TRIGGER temp.r301 AFTER INSERT ON t300 BEGIN
+ INSERT INTO t301 VALUES(20000 + new.x);
+ END;
+ INSERT INTO main.t300 VALUES(3);
+ INSERT INTO temp.t300 VALUES(4);
+ SELECT * FROM t301;
+ }
+} {10003 20004}
+
+
+#############################################################################
+#
+# Ticket [d6ddba6706353915ceedc56b4e3e72ecb4d77ba4]
+#
+# The following syntax really should not be allowed:
+#
+# CREATE TRIGGER xyz.trig BEFORE UPDATE ON xyz.tab BEGIN ...
+#
+# But a long-standing bug does allow it. And the "xyz.tab" slips into
+# the sqlite_master table. We cannot fix the bug simply by disallowing
+# "xyz.tab" since that could break legacy applications. We have to
+# fix the system so that the "xyz." on "xyz.tab" is ignored.
+# Verify that this is the case.
+#
+do_test triggerD-4.1 {
+ db close
+ forcedelete test.db test2.db
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(x);
+ ATTACH 'test2.db' AS db2;
+ CREATE TABLE db2.t2(y);
+ CREATE TABLE db2.log(z);
+ CREATE TRIGGER db2.trig AFTER INSERT ON db2.t2 BEGIN
+ INSERT INTO log(z) VALUES(new.y);
+ END;
+ INSERT INTO t2 VALUES(123);
+ SELECT * FROM log;
+ }
+} {123}
+do_test triggerD-4.2 {
+ sqlite3 db2 test2.db
+ db2 eval {
+ INSERT INTO t2 VALUES(234);
+ SELECT * FROM log;
+ }
+} {123 234}
+db2 close
+
+finish_test
diff --git a/test/tt3_checkpoint.c b/test/tt3_checkpoint.c
new file mode 100644
index 0000000..3c28f0d
--- /dev/null
+++ b/test/tt3_checkpoint.c
@@ -0,0 +1,150 @@
+/*
+** 2001 September 15
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+** This file is part of the test program "threadtest3". Despite being a C
+** file it is not compiled separately, but included by threadtest3.c using
+** the #include directive normally used with header files.
+**
+** This file contains the implementation of test cases:
+**
+** checkpoint_starvation_1
+** checkpoint_starvation_2
+*/
+
+/*
+** Both test cases involve 1 writer/checkpointer thread and N reader threads.
+**
+** Each reader thread performs a series of read transactions, one after
+** another. Each read transaction lasts for 100 ms.
+**
+** The writer writes transactions as fast as possible. It uses a callback
+** registered with sqlite3_wal_hook() to try to keep the WAL-size limited to
+** around 50 pages.
+**
+** In test case checkpoint_starvation_1, the auto-checkpoint uses
+** SQLITE_CHECKPOINT_PASSIVE. In checkpoint_starvation_2, it uses RESTART.
+** The expectation is that in the first case the WAL file will grow very
+** large, and in the second will be limited to the 50 pages or thereabouts.
+** However, the overall transaction throughput will be lower for
+** checkpoint_starvation_2, as every checkpoint will block for up to 200 ms
+** waiting for readers to clear.
+*/
+
+/* Frame limit used by the WAL hook for these tests. */
+#define CHECKPOINT_STARVATION_FRAMELIMIT 50
+
+/* Duration in ms of each read transaction */
+#define CHECKPOINT_STARVATION_READMS 100
+
+struct CheckpointStarvationCtx {
+ int eMode;
+ int nMaxFrame;
+};
+typedef struct CheckpointStarvationCtx CheckpointStarvationCtx;
+
+static int checkpoint_starvation_walhook(
+ void *pCtx,
+ sqlite3 *db,
+ const char *zDb,
+ int nFrame
+){
+ CheckpointStarvationCtx *p = (CheckpointStarvationCtx *)pCtx;
+ if( nFrame>p->nMaxFrame ){
+ p->nMaxFrame = nFrame;
+ }
+ if( nFrame>=CHECKPOINT_STARVATION_FRAMELIMIT ){
+ sqlite3_wal_checkpoint_v2(db, zDb, p->eMode, 0, 0);
+ }
+ return SQLITE_OK;
+}
+
+static char *checkpoint_starvation_reader(int iTid, int iArg){
+ Error err = {0};
+ Sqlite db = {0};
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ i64 iCount1, iCount2;
+ sql_script(&err, &db, "BEGIN");
+ iCount1 = execsql_i64(&err, &db, "SELECT count(x) FROM t1");
+ usleep(CHECKPOINT_STARVATION_READMS*1000);
+ iCount2 = execsql_i64(&err, &db, "SELECT count(x) FROM t1");
+ sql_script(&err, &db, "COMMIT");
+
+ if( iCount1!=iCount2 ){
+ test_error(&err, "Isolation failure - %lld %lld", iCount1, iCount2);
+ }
+ }
+ closedb(&err, &db);
+
+ print_and_free_err(&err);
+ return 0;
+}
+
+static void checkpoint_starvation_main(int nMs, CheckpointStarvationCtx *p){
+ Error err = {0};
+ Sqlite db = {0};
+ Threadset threads = {0};
+ int nInsert = 0;
+ int i;
+
+ opendb(&err, &db, "test.db", 1);
+ sql_script(&err, &db,
+ "PRAGMA page_size = 1024;"
+ "PRAGMA journal_mode = WAL;"
+ "CREATE TABLE t1(x);"
+ );
+
+ setstoptime(&err, nMs);
+
+ for(i=0; i<4; i++){
+ launch_thread(&err, &threads, checkpoint_starvation_reader, 0);
+ usleep(CHECKPOINT_STARVATION_READMS*1000/4);
+ }
+
+ sqlite3_wal_hook(db.db, checkpoint_starvation_walhook, (void *)p);
+ while( !timetostop(&err) ){
+ sql_script(&err, &db, "INSERT INTO t1 VALUES(randomblob(1200))");
+ nInsert++;
+ }
+
+ printf(" Checkpoint mode : %s\n",
+ p->eMode==SQLITE_CHECKPOINT_PASSIVE ? "PASSIVE" : "RESTART"
+ );
+ printf(" Peak WAL : %d frames\n", p->nMaxFrame);
+ printf(" Transaction count: %d transactions\n", nInsert);
+
+ join_all_threads(&err, &threads);
+ closedb(&err, &db);
+ print_and_free_err(&err);
+}
+
+static void checkpoint_starvation_1(int nMs){
+ Error err = {0};
+ CheckpointStarvationCtx ctx = { SQLITE_CHECKPOINT_PASSIVE, 0 };
+ checkpoint_starvation_main(nMs, &ctx);
+ if( ctx.nMaxFrame<(CHECKPOINT_STARVATION_FRAMELIMIT*10) ){
+ test_error(&err, "WAL failed to grow - %d frames", ctx.nMaxFrame);
+ }
+ print_and_free_err(&err);
+}
+
+static void checkpoint_starvation_2(int nMs){
+ Error err = {0};
+ CheckpointStarvationCtx ctx = { SQLITE_CHECKPOINT_RESTART, 0 };
+ checkpoint_starvation_main(nMs, &ctx);
+ if( ctx.nMaxFrame>CHECKPOINT_STARVATION_FRAMELIMIT+10 ){
+ test_error(&err, "WAL grew too large - %d frames", ctx.nMaxFrame);
+ }
+ print_and_free_err(&err);
+}
+
+
diff --git a/test/types.test b/test/types.test
new file mode 100644
index 0000000..62a8efc
--- /dev/null
+++ b/test/types.test
@@ -0,0 +1,325 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specfically
+# it tests that the different storage classes (integer, real, text etc.)
+# all work correctly.
+#
+# $Id: types.test,v 1.20 2009/06/29 06:00:37 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Tests in this file are organized roughly as follows:
+#
+# types-1.*.*: Test that values are stored using the expected storage
+# classes when various forms of literals are inserted into
+# columns with different affinities.
+# types-1.1.*: INSERT INTO <table> VALUES(...)
+# types-1.2.*: INSERT INTO <table> SELECT...
+# types-1.3.*: UPDATE <table> SET...
+#
+# types-2.*.*: Check that values can be stored and retrieving using the
+# various storage classes.
+# types-2.1.*: INTEGER
+# types-2.2.*: REAL
+# types-2.3.*: NULL
+# types-2.4.*: TEXT
+# types-2.5.*: Records with a few different storage classes.
+#
+# types-3.*: Test that the '=' operator respects manifest types.
+#
+
+# Disable encryption on the database for this test.
+db close
+set DB [sqlite3 db test.db; sqlite3_connection_pointer db]
+sqlite3_rekey $DB {}
+
+# Create a table with one column for each type of affinity
+do_test types-1.1.0 {
+ execsql {
+ CREATE TABLE t1(i integer, n numeric, t text, o blob);
+ }
+} {}
+
+# Each element of the following list represents one test case.
+#
+# The first value of each sub-list is an SQL literal. The following
+# four value are the storage classes that would be used if the
+# literal were inserted into a column with affinity INTEGER, NUMERIC, TEXT
+# or NONE, respectively.
+set values {
+ { 5.0 integer integer text real }
+ { 5.1 real real text real }
+ { 5 integer integer text integer }
+ { '5.0' integer integer text text }
+ { '5.1' real real text text }
+ { '-5.0' integer integer text text }
+ { '-5.0' integer integer text text }
+ { '5' integer integer text text }
+ { 'abc' text text text text }
+ { NULL null null null null }
+}
+ifcapable {bloblit} {
+ lappend values { X'00' blob blob blob blob }
+}
+
+# This code tests that the storage classes specified above (in the $values
+# table) are correctly assigned when values are inserted using a statement
+# of the form:
+#
+# INSERT INTO <table> VALUE(<values>);
+#
+set tnum 1
+foreach val $values {
+ set lit [lindex $val 0]
+ execsql "DELETE FROM t1;"
+ execsql "INSERT INTO t1 VALUES($lit, $lit, $lit, $lit);"
+ do_test types-1.1.$tnum {
+ execsql {
+ SELECT typeof(i), typeof(n), typeof(t), typeof(o) FROM t1;
+ }
+ } [lrange $val 1 end]
+ incr tnum
+}
+
+# This code tests that the storage classes specified above (in the $values
+# table) are correctly assigned when values are inserted using a statement
+# of the form:
+#
+# INSERT INTO t1 SELECT ....
+#
+set tnum 1
+foreach val $values {
+ set lit [lindex $val 0]
+ execsql "DELETE FROM t1;"
+ execsql "INSERT INTO t1 SELECT $lit, $lit, $lit, $lit;"
+ do_test types-1.2.$tnum {
+ execsql {
+ SELECT typeof(i), typeof(n), typeof(t), typeof(o) FROM t1;
+ }
+ } [lrange $val 1 end]
+ incr tnum
+}
+
+# This code tests that the storage classes specified above (in the $values
+# table) are correctly assigned when values are inserted using a statement
+# of the form:
+#
+# UPDATE <table> SET <column> = <value>;
+#
+set tnum 1
+foreach val $values {
+ set lit [lindex $val 0]
+ execsql "UPDATE t1 SET i = $lit, n = $lit, t = $lit, o = $lit;"
+ do_test types-1.3.$tnum {
+ execsql {
+ SELECT typeof(i), typeof(n), typeof(t), typeof(o) FROM t1;
+ }
+ } [lrange $val 1 end]
+ incr tnum
+}
+
+execsql {
+ DROP TABLE t1;
+}
+
+# Open the table with root-page $rootpage at the btree
+# level. Return a list that is the length of each record
+# in the table, in the tables default scanning order.
+proc record_sizes {rootpage} {
+ set bt [btree_open test.db 10]
+ btree_begin_transaction $bt
+ set c [btree_cursor $bt $rootpage 0]
+ btree_first $c
+ while 1 {
+ lappend res [btree_payload_size $c]
+ if {[btree_next $c]} break
+ }
+ btree_close_cursor $c
+ btree_close $bt
+ set res
+}
+
+
+# Create a table and insert some 1-byte integers. Make sure they
+# can be read back OK. These should be 3 byte records.
+do_test types-2.1.1 {
+ execsql {
+ CREATE TABLE t1(a integer);
+ INSERT INTO t1 VALUES(0);
+ INSERT INTO t1 VALUES(120);
+ INSERT INTO t1 VALUES(-120);
+ }
+} {}
+do_test types-2.1.2 {
+ execsql {
+ SELECT a FROM t1;
+ }
+} {0 120 -120}
+
+# Try some 2-byte integers (4 byte records)
+do_test types-2.1.3 {
+ execsql {
+ INSERT INTO t1 VALUES(30000);
+ INSERT INTO t1 VALUES(-30000);
+ }
+} {}
+do_test types-2.1.4 {
+ execsql {
+ SELECT a FROM t1;
+ }
+} {0 120 -120 30000 -30000}
+
+# 4-byte integers (6 byte records)
+do_test types-2.1.5 {
+ execsql {
+ INSERT INTO t1 VALUES(2100000000);
+ INSERT INTO t1 VALUES(-2100000000);
+ }
+} {}
+do_test types-2.1.6 {
+ execsql {
+ SELECT a FROM t1;
+ }
+} {0 120 -120 30000 -30000 2100000000 -2100000000}
+
+# 8-byte integers (10 byte records)
+do_test types-2.1.7 {
+ execsql {
+ INSERT INTO t1 VALUES(9000000*1000000*1000000);
+ INSERT INTO t1 VALUES(-9000000*1000000*1000000);
+ }
+} {}
+do_test types-2.1.8 {
+ execsql {
+ SELECT a FROM t1;
+ }
+} [list 0 120 -120 30000 -30000 2100000000 -2100000000 \
+ 9000000000000000000 -9000000000000000000]
+
+# Check that all the record sizes are as we expected.
+ifcapable legacyformat {
+ do_test types-2.1.9 {
+ set root [db eval {select rootpage from sqlite_master where name = 't1'}]
+ record_sizes $root
+ } {3 3 3 4 4 6 6 10 10}
+} else {
+ do_test types-2.1.9 {
+ set root [db eval {select rootpage from sqlite_master where name = 't1'}]
+ record_sizes $root
+ } {2 3 3 4 4 6 6 10 10}
+}
+
+# Insert some reals. These should be 10 byte records.
+do_test types-2.2.1 {
+ execsql {
+ CREATE TABLE t2(a float);
+ INSERT INTO t2 VALUES(0.0);
+ INSERT INTO t2 VALUES(12345.678);
+ INSERT INTO t2 VALUES(-12345.678);
+ }
+} {}
+do_test types-2.2.2 {
+ execsql {
+ SELECT a FROM t2;
+ }
+} {0.0 12345.678 -12345.678}
+
+# Check that all the record sizes are as we expected.
+ifcapable legacyformat {
+ do_test types-2.2.3 {
+ set root [db eval {select rootpage from sqlite_master where name = 't2'}]
+ record_sizes $root
+ } {3 10 10}
+} else {
+ do_test types-2.2.3 {
+ set root [db eval {select rootpage from sqlite_master where name = 't2'}]
+ record_sizes $root
+ } {2 10 10}
+}
+
+# Insert a NULL. This should be a two byte record.
+do_test types-2.3.1 {
+ execsql {
+ CREATE TABLE t3(a nullvalue);
+ INSERT INTO t3 VALUES(NULL);
+ }
+} {}
+do_test types-2.3.2 {
+ execsql {
+ SELECT a ISNULL FROM t3;
+ }
+} {1}
+
+# Check that all the record sizes are as we expected.
+do_test types-2.3.3 {
+ set root [db eval {select rootpage from sqlite_master where name = 't3'}]
+ record_sizes $root
+} {2}
+
+# Insert a couple of strings.
+do_test types-2.4.1 {
+ set string10 abcdefghij
+ set string500 [string repeat $string10 50]
+ set string500000 [string repeat $string10 50000]
+
+ execsql "
+ CREATE TABLE t4(a string);
+ INSERT INTO t4 VALUES('$string10');
+ INSERT INTO t4 VALUES('$string500');
+ INSERT INTO t4 VALUES('$string500000');
+ "
+} {}
+do_test types-2.4.2 {
+ execsql {
+ SELECT a FROM t4;
+ }
+} [list $string10 $string500 $string500000]
+
+# Check that all the record sizes are as we expected. This is dependant on
+# the database encoding.
+if { $sqlite_options(utf16)==0 || [execsql {pragma encoding}] == "UTF-8" } {
+ do_test types-2.4.3 {
+ set root [db eval {select rootpage from sqlite_master where name = 't4'}]
+ record_sizes $root
+ } {12 503 500004}
+} else {
+ do_test types-2.4.3 {
+ set root [db eval {select rootpage from sqlite_master where name = 't4'}]
+ record_sizes $root
+ } {22 1003 1000004}
+}
+
+do_test types-2.5.1 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ DROP TABLE t3;
+ DROP TABLE t4;
+ CREATE TABLE t1(a, b, c);
+ }
+} {}
+do_test types-2.5.2 {
+ set string10 abcdefghij
+ set string500 [string repeat $string10 50]
+ set string500000 [string repeat $string10 50000]
+
+ execsql "INSERT INTO t1 VALUES(NULL, '$string10', 4000);"
+ execsql "INSERT INTO t1 VALUES('$string500', 4000, NULL);"
+ execsql "INSERT INTO t1 VALUES(4000, NULL, '$string500000');"
+} {}
+do_test types-2.5.3 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} [list {} $string10 4000 $string500 4000 {} 4000 {} $string500000]
+
+finish_test
diff --git a/test/types2.test b/test/types2.test
new file mode 100644
index 0000000..4a70aa5
--- /dev/null
+++ b/test/types2.test
@@ -0,0 +1,340 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this file is testing the interaction of manifest types, type affinity
+# and comparison expressions.
+#
+# $Id: types2.test,v 1.7 2007/02/23 03:00:45 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Tests in this file are organized roughly as follows:
+#
+# types2-1.*: The '=' operator in the absence of an index.
+# types2-2.*: The '=' operator implemented using an index.
+# types2-3.*: The '<' operator implemented using an index.
+# types2-4.*: The '>' operator in the absence of an index.
+# types2-5.*: The 'IN(x, y...)' operator in the absence of an index.
+# types2-6.*: The 'IN(x, y...)' operator with an index.
+# types2-7.*: The 'IN(SELECT...)' operator in the absence of an index.
+# types2-8.*: The 'IN(SELECT...)' operator with an index.
+#
+# All tests test the operators using literals and columns, but no
+# other types of expressions. All expressions except columns are
+# handled similarly in the implementation.
+
+execsql {
+ CREATE TABLE t1(
+ i1 INTEGER,
+ i2 INTEGER,
+ n1 NUMERIC,
+ n2 NUMERIC,
+ t1 TEXT,
+ t2 TEXT,
+ o1 BLOB,
+ o2 BLOB
+ );
+ INSERT INTO t1 VALUES(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
+}
+
+proc test_bool {testname vars expr res} {
+ if { $vars != "" } {
+ execsql "UPDATE t1 SET $vars"
+ }
+
+ foreach {t e r} [list $testname $expr $res] {}
+
+ do_test $t.1 "execsql {SELECT $e FROM t1}" $r
+ do_test $t.2 "execsql {SELECT 1 FROM t1 WHERE $expr}" [expr $r?"1":""]
+ do_test $t.3 "execsql {SELECT 1 FROM t1 WHERE NOT ($e)}" [expr $r?"":"1"]
+}
+
+# Compare literals against literals. This should always use a numeric
+# comparison.
+#
+# Changed by ticket #805: Use no affinity for literal comparisons.
+#
+test_bool types2-1.1 "" {500 = 500.0} 1
+test_bool types2-1.2 "" {'500' = 500.0} 0
+test_bool types2-1.3 "" {500 = '500.0'} 0
+test_bool types2-1.4 "" {'500' = '500.0'} 0
+
+# Compare literals against a column with TEXT affinity
+test_bool types2-1.5 {t1=500} {500 = t1} 1
+test_bool types2-1.6 {t1=500} {'500' = t1} 1
+test_bool types2-1.7 {t1=500} {500.0 = t1} 0
+test_bool types2-1.8 {t1=500} {'500.0' = t1} 0
+test_bool types2-1.9 {t1='500'} {500 = t1} 1
+test_bool types2-1.10 {t1='500'} {'500' = t1} 1
+test_bool types2-1.11 {t1='500'} {500.0 = t1} 0
+test_bool types2-1.12 {t1='500'} {'500.0' = t1} 0
+
+# Compare literals against a column with NUMERIC affinity
+test_bool types2-1.13 {n1=500} {500 = n1} 1
+test_bool types2-1.14 {n1=500} {'500' = n1} 1
+test_bool types2-1.15 {n1=500} {500.0 = n1} 1
+test_bool types2-1.16 {n1=500} {'500.0' = n1} 1
+test_bool types2-1.17 {n1='500'} {500 = n1} 1
+test_bool types2-1.18 {n1='500'} {'500' = n1} 1
+test_bool types2-1.19 {n1='500'} {500.0 = n1} 1
+test_bool types2-1.20 {n1='500'} {'500.0' = n1} 1
+
+# Compare literals against a column with affinity NONE
+test_bool types2-1.21 {o1=500} {500 = o1} 1
+test_bool types2-1.22 {o1=500} {'500' = o1} 0
+test_bool types2-1.23 {o1=500} {500.0 = o1} 1
+test_bool types2-1.24 {o1=500} {'500.0' = o1} 0
+test_bool types2-1.25 {o1='500'} {500 = o1} 0
+test_bool types2-1.26 {o1='500'} {'500' = o1} 1
+test_bool types2-1.27 {o1='500'} {500.0 = o1} 0
+test_bool types2-1.28 {o1='500'} {'500.0' = o1} 0
+
+set vals [list 10 10.0 '10' '10.0' 20 20.0 '20' '20.0' 30 30.0 '30' '30.0']
+# 1 2 3 4 5 6 7 8 9 10 11 12
+
+execsql {
+ CREATE TABLE t2(i INTEGER, n NUMERIC, t TEXT, o XBLOBY);
+ CREATE INDEX t2i1 ON t2(i);
+ CREATE INDEX t2i2 ON t2(n);
+ CREATE INDEX t2i3 ON t2(t);
+ CREATE INDEX t2i4 ON t2(o);
+}
+foreach v $vals {
+ execsql "INSERT INTO t2 VALUES($v, $v, $v, $v);"
+}
+
+proc test_boolset {testname where set} {
+ set ::tb_sql "SELECT rowid FROM t2 WHERE $where"
+ do_test $testname {
+ lsort -integer [execsql $::tb_sql]
+ } $set
+}
+
+test_boolset types2-2.1 {i = 10} {1 2 3 4}
+test_boolset types2-2.2 {i = 10.0} {1 2 3 4}
+test_boolset types2-2.3 {i = '10'} {1 2 3 4}
+test_boolset types2-2.4 {i = '10.0'} {1 2 3 4}
+
+test_boolset types2-2.5 {n = 20} {5 6 7 8}
+test_boolset types2-2.6 {n = 20.0} {5 6 7 8}
+test_boolset types2-2.7 {n = '20'} {5 6 7 8}
+test_boolset types2-2.8 {n = '20.0'} {5 6 7 8}
+
+test_boolset types2-2.9 {t = 20} {5 7}
+test_boolset types2-2.10 {t = 20.0} {6 8}
+test_boolset types2-2.11 {t = '20'} {5 7}
+test_boolset types2-2.12 {t = '20.0'} {6 8}
+
+test_boolset types2-2.10 {o = 30} {9 10}
+test_boolset types2-2.11 {o = 30.0} {9 10}
+test_boolset types2-2.12 {o = '30'} 11
+test_boolset types2-2.13 {o = '30.0'} 12
+
+test_boolset types2-3.1 {i < 20} {1 2 3 4}
+test_boolset types2-3.2 {i < 20.0} {1 2 3 4}
+test_boolset types2-3.3 {i < '20'} {1 2 3 4}
+test_boolset types2-3.4 {i < '20.0'} {1 2 3 4}
+
+test_boolset types2-3.1 {n < 20} {1 2 3 4}
+test_boolset types2-3.2 {n < 20.0} {1 2 3 4}
+test_boolset types2-3.3 {n < '20'} {1 2 3 4}
+test_boolset types2-3.4 {n < '20.0'} {1 2 3 4}
+
+test_boolset types2-3.1 {t < 20} {1 2 3 4}
+test_boolset types2-3.2 {t < 20.0} {1 2 3 4 5 7}
+test_boolset types2-3.3 {t < '20'} {1 2 3 4}
+test_boolset types2-3.4 {t < '20.0'} {1 2 3 4 5 7}
+
+test_boolset types2-3.1 {o < 20} {1 2}
+test_boolset types2-3.2 {o < 20.0} {1 2}
+test_boolset types2-3.3 {o < '20'} {1 2 3 4 5 6 9 10}
+test_boolset types2-3.3 {o < '20.0'} {1 2 3 4 5 6 7 9 10}
+
+# Compare literals against literals (always a numeric comparison).
+# Change (by ticket #805): No affinity in comparisons
+test_bool types2-4.1 "" {500 > 60.0} 1
+test_bool types2-4.2 "" {'500' > 60.0} 1
+test_bool types2-4.3 "" {500 > '60.0'} 0
+test_bool types2-4.4 "" {'500' > '60.0'} 0
+
+# Compare literals against a column with TEXT affinity
+test_bool types2-4.5 {t1=500.0} {t1 > 500} 1
+test_bool types2-4.6 {t1=500.0} {t1 > '500' } 1
+test_bool types2-4.7 {t1=500.0} {t1 > 500.0 } 0
+test_bool types2-4.8 {t1=500.0} {t1 > '500.0' } 0
+test_bool types2-4.9 {t1='500.0'} {t1 > 500 } 1
+test_bool types2-4.10 {t1='500.0'} {t1 > '500' } 1
+test_bool types2-4.11 {t1='500.0'} {t1 > 500.0 } 0
+test_bool types2-4.12 {t1='500.0'} {t1 > '500.0' } 0
+
+# Compare literals against a column with NUMERIC affinity
+test_bool types2-4.13 {n1=400} {500 > n1} 1
+test_bool types2-4.14 {n1=400} {'500' > n1} 1
+test_bool types2-4.15 {n1=400} {500.0 > n1} 1
+test_bool types2-4.16 {n1=400} {'500.0' > n1} 1
+test_bool types2-4.17 {n1='400'} {500 > n1} 1
+test_bool types2-4.18 {n1='400'} {'500' > n1} 1
+test_bool types2-4.19 {n1='400'} {500.0 > n1} 1
+test_bool types2-4.20 {n1='400'} {'500.0' > n1} 1
+
+# Compare literals against a column with affinity NONE
+test_bool types2-4.21 {o1=500} {500 > o1} 0
+test_bool types2-4.22 {o1=500} {'500' > o1} 1
+test_bool types2-4.23 {o1=500} {500.0 > o1} 0
+test_bool types2-4.24 {o1=500} {'500.0' > o1} 1
+test_bool types2-4.25 {o1='500'} {500 > o1} 0
+test_bool types2-4.26 {o1='500'} {'500' > o1} 0
+test_bool types2-4.27 {o1='500'} {500.0 > o1} 0
+test_bool types2-4.28 {o1='500'} {'500.0' > o1} 1
+
+ifcapable subquery {
+ # types2-5.* - The 'IN (x, y....)' operator with no index.
+ #
+ # Compare literals against literals (no affinity applied)
+ test_bool types2-5.1 {} {(NULL IN ('10.0', 20)) ISNULL} 1
+ test_bool types2-5.2 {} {10 IN ('10.0', 20)} 0
+ test_bool types2-5.3 {} {'10' IN ('10.0', 20)} 0
+ test_bool types2-5.4 {} {10 IN (10.0, 20)} 1
+ test_bool types2-5.5 {} {'10.0' IN (10, 20)} 0
+
+ # Compare literals against a column with TEXT affinity
+ test_bool types2-5.6 {t1='10.0'} {t1 IN (10.0, 20)} 1
+ test_bool types2-5.7 {t1='10.0'} {t1 IN (10, 20)} 0
+ test_bool types2-5.8 {t1='10'} {t1 IN (10.0, 20)} 0
+ test_bool types2-5.9 {t1='10'} {t1 IN (20, '10.0')} 0
+ test_bool types2-5.10 {t1=10} {t1 IN (20, '10')} 1
+
+ # Compare literals against a column with NUMERIC affinity
+ test_bool types2-5.11 {n1='10.0'} {n1 IN (10.0, 20)} 1
+ test_bool types2-5.12 {n1='10.0'} {n1 IN (10, 20)} 1
+ test_bool types2-5.13 {n1='10'} {n1 IN (10.0, 20)} 1
+ test_bool types2-5.14 {n1='10'} {n1 IN (20, '10.0')} 1
+ test_bool types2-5.15 {n1=10} {n1 IN (20, '10')} 1
+
+ # Compare literals against a column with affinity NONE
+ test_bool types2-5.16 {o1='10.0'} {o1 IN (10.0, 20)} 0
+ test_bool types2-5.17 {o1='10.0'} {o1 IN (10, 20)} 0
+ test_bool types2-5.18 {o1='10'} {o1 IN (10.0, 20)} 0
+ test_bool types2-5.19 {o1='10'} {o1 IN (20, '10.0')} 0
+ test_bool types2-5.20 {o1=10} {o1 IN (20, '10')} 0
+ test_bool types2-5.21 {o1='10.0'} {o1 IN (10, 20, '10.0')} 1
+ test_bool types2-5.22 {o1='10'} {o1 IN (10.0, 20, '10')} 1
+ test_bool types2-5.23 {o1=10} {n1 IN (20, '10', 10)} 1
+
+ # Ticket #2248: Comparisons of strings literals that look like
+ # numbers.
+ test_bool types2-5.24 {} {'1' IN ('1')} 1
+ test_bool types2-5.25 {} {'2' IN (2)} 0
+ test_bool types2-5.26 {} {3 IN ('3')} 0
+ test_bool types2-5.27 {} {4 IN (4)} 1
+
+ # The affinity of columns on the right side of IN(...) is ignored.
+ # All values in the expression list are treated as ordinary expressions,
+ # even if they are columns with affinity.
+ test_bool types2-5.30 {t1='10'} {10 IN (5,t1,'abc')} 0
+ test_bool types2-5.31 {t1='10'} {10 IN ('abc',t1,5)} 0
+ test_bool types2-5.32 {t1='010'} {10 IN (5,t1,'abc')} 0
+ test_bool types2-5.33 {t1='010'} {10 IN ('abc',t1,5)} 0
+ test_bool types2-5.34 {t1='10'} {'10' IN (5,t1,'abc')} 1
+ test_bool types2-5.35 {t1='10'} {'10' IN ('abc',t1,5)} 1
+ test_bool types2-5.36 {t1='010'} {'10' IN (5,t1,'abc')} 0
+ test_bool types2-5.37 {t1='010'} {'10' IN ('abc',t1,5)} 0
+
+ # Columns on both the left and right of IN(...). Only the column
+ # on the left matters. The all values on the right are treated like
+ # expressions.
+ test_bool types2-5.40 {t1='10',n1=10} {t1 IN (5,n1,11)} 1
+ test_bool types2-5.41 {t1='010',n1=10} {t1 IN (5,n1,11)} 0
+ test_bool types2-5.42 {t1='10',n1=10} {n1 IN (5,t1,11)} 1
+ test_bool types2-5.43 {t1='010',n1=10} {n1 IN (5,t1,11)} 1
+}
+
+# Tests named types2-6.* use the same infrastructure as the types2-2.*
+# tests. The contents of the vals array is repeated here for easy
+# reference.
+#
+# set vals [list 10 10.0 '10' '10.0' 20 20.0 '20' '20.0' 30 30.0 '30' '30.0']
+# 1 2 3 4 5 6 7 8 9 10 11 12
+
+ifcapable subquery {
+ test_boolset types2-6.1 {o IN ('10', 30)} {3 9 10}
+ test_boolset types2-6.2 {o IN (20.0, 30.0)} {5 6 9 10}
+ test_boolset types2-6.3 {t IN ('10', 30)} {1 3 9 11}
+ test_boolset types2-6.4 {t IN (20.0, 30.0)} {6 8 10 12}
+ test_boolset types2-6.5 {n IN ('10', 30)} {1 2 3 4 9 10 11 12}
+ test_boolset types2-6.6 {n IN (20.0, 30.0)} {5 6 7 8 9 10 11 12}
+ test_boolset types2-6.7 {i IN ('10', 30)} {1 2 3 4 9 10 11 12}
+ test_boolset types2-6.8 {i IN (20.0, 30.0)} {5 6 7 8 9 10 11 12}
+
+ # Also test than IN(x, y, z) works on a rowid:
+ test_boolset types2-6.9 {rowid IN (1, 6, 10)} {1 6 10}
+}
+
+# Tests types2-7.* concentrate on expressions of the form
+# "x IN (SELECT...)" with no index.
+execsql {
+ CREATE TABLE t3(i INTEGER, n NUMERIC, t TEXT, o BLOB);
+ INSERT INTO t3 VALUES(1, 1, 1, 1);
+ INSERT INTO t3 VALUES(2, 2, 2, 2);
+ INSERT INTO t3 VALUES(3, 3, 3, 3);
+ INSERT INTO t3 VALUES('1', '1', '1', '1');
+ INSERT INTO t3 VALUES('1.0', '1.0', '1.0', '1.0');
+}
+
+ifcapable subquery {
+ test_bool types2-7.1 {i1=1} {i1 IN (SELECT i FROM t3)} 1
+ test_bool types2-7.2 {i1='2.0'} {i1 IN (SELECT i FROM t3)} 1
+ test_bool types2-7.3 {i1='2.0'} {i1 IN (SELECT n FROM t3)} 1
+ test_bool types2-7.4 {i1='2.0'} {i1 IN (SELECT t FROM t3)} 1
+ test_bool types2-7.5 {i1='2.0'} {i1 IN (SELECT o FROM t3)} 1
+
+ test_bool types2-7.6 {n1=1} {n1 IN (SELECT n FROM t3)} 1
+ test_bool types2-7.7 {n1='2.0'} {n1 IN (SELECT i FROM t3)} 1
+ test_bool types2-7.8 {n1='2.0'} {n1 IN (SELECT n FROM t3)} 1
+ test_bool types2-7.9 {n1='2.0'} {n1 IN (SELECT t FROM t3)} 1
+ test_bool types2-7.10 {n1='2.0'} {n1 IN (SELECT o FROM t3)} 1
+
+ test_bool types2-7.6 {t1=1} {t1 IN (SELECT t FROM t3)} 1
+ test_bool types2-7.7 {t1='2.0'} {t1 IN (SELECT t FROM t3)} 0
+ test_bool types2-7.8 {t1='2.0'} {t1 IN (SELECT n FROM t3)} 1
+ test_bool types2-7.9 {t1='2.0'} {t1 IN (SELECT i FROM t3)} 1
+ test_bool types2-7.10 {t1='2.0'} {t1 IN (SELECT o FROM t3)} 0
+ test_bool types2-7.11 {t1='1.0'} {t1 IN (SELECT t FROM t3)} 1
+ test_bool types2-7.12 {t1='1.0'} {t1 IN (SELECT o FROM t3)} 1
+
+ test_bool types2-7.13 {o1=2} {o1 IN (SELECT o FROM t3)} 1
+ test_bool types2-7.14 {o1='2'} {o1 IN (SELECT o FROM t3)} 0
+ test_bool types2-7.15 {o1='2'} {o1 IN (SELECT o||'' FROM t3)} 1
+}
+
+# set vals [list 10 10.0 '10' '10.0' 20 20.0 '20' '20.0' 30 30.0 '30' '30.0']
+# 1 2 3 4 5 6 7 8 9 10 11 12
+execsql {
+ CREATE TABLE t4(i INTEGER, n NUMERIC, t VARCHAR(20), o LARGE BLOB);
+ INSERT INTO t4 VALUES(10, 20, 20, 30);
+}
+ifcapable subquery {
+ test_boolset types2-8.1 {i IN (SELECT i FROM t4)} {1 2 3 4}
+ test_boolset types2-8.2 {n IN (SELECT i FROM t4)} {1 2 3 4}
+ test_boolset types2-8.3 {t IN (SELECT i FROM t4)} {1 2 3 4}
+ test_boolset types2-8.4 {o IN (SELECT i FROM t4)} {1 2 3 4}
+ test_boolset types2-8.5 {i IN (SELECT t FROM t4)} {5 6 7 8}
+ test_boolset types2-8.6 {n IN (SELECT t FROM t4)} {5 6 7 8}
+ test_boolset types2-8.7 {t IN (SELECT t FROM t4)} {5 7}
+ test_boolset types2-8.8 {o IN (SELECT t FROM t4)} {7}
+ test_boolset types2-8.9 {i IN (SELECT o FROM t4)} {9 10 11 12}
+ test_boolset types2-8.6 {n IN (SELECT o FROM t4)} {9 10 11 12}
+ test_boolset types2-8.7 {t IN (SELECT o FROM t4)} {9 11}
+ test_boolset types2-8.8 {o IN (SELECT o FROM t4)} {9 10}
+}
+
+finish_test
diff --git a/test/types3.test b/test/types3.test
new file mode 100644
index 0000000..807ae84
--- /dev/null
+++ b/test/types3.test
@@ -0,0 +1,99 @@
+# 2005 June 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this file is testing the interaction of SQLite manifest types
+# with Tcl dual-representations.
+#
+# $Id: types3.test,v 1.8 2008/04/28 13:02:58 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# A variable with only a string representation comes in as TEXT
+do_test types3-1.1 {
+ set V {}
+ append V x
+ concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
+} {string text}
+
+# A variable with an integer representation comes in as INTEGER
+do_test types3-1.2 {
+ set V [expr {int(1+2)}]
+ concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
+} {int integer}
+set V [expr {1+12345678012345}]
+if {[tcl_variable_type V]=="wideInt"} {
+ do_test types3-1.3 {
+ set V [expr {1+123456789012345}]
+ concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
+ } {wideInt integer}
+} else {
+ do_test types3-1.3 {
+ set V [expr {1+123456789012345}]
+ concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
+ } {int integer}
+}
+
+# A double variable comes in as REAL
+do_test types3-1.4 {
+ set V [expr {1.0+1}]
+ concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
+} {double real}
+
+# A byte-array variable comes in a BLOB if it has no string representation
+# or as TEXT if there is a string representation.
+#
+do_test types3-1.5 {
+ set V [binary format a3 abc]
+ concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
+} {bytearray blob}
+do_test types3-1.6 {
+ set V "abc"
+ binary scan $V a3 x
+ concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
+} {bytearray text}
+
+# Check to make sure return values are of the right types.
+#
+ifcapable bloblit {
+ do_test types3-2.1 {
+ set V [db one {SELECT x'616263'}]
+ tcl_variable_type V
+ } bytearray
+}
+do_test types3-2.2 {
+ set V [db one {SELECT 123}]
+ tcl_variable_type V
+} int
+set Vx [expr {1+wide(123456789123456)}]
+do_test types3-2.3 {
+ set V [db one {SELECT 1234567890123456}]
+ tcl_variable_type V
+} [tcl_variable_type Vx]
+do_test types3-2.4.1 {
+ set V [db one {SELECT 1234567890123456.1}]
+ tcl_variable_type V
+} double
+do_test types3-2.4.2 {
+ set V [db one {SELECT 1234567890123.456}]
+ tcl_variable_type V
+} double
+do_test types3-2.5 {
+ set V [db one {SELECT '1234567890123456.0'}]
+ tcl_variable_type V
+} {}
+do_test types3-2.6 {
+ set V [db one {SELECT NULL}]
+ tcl_variable_type V
+} {}
+
+finish_test
diff --git a/test/unique.test b/test/unique.test
new file mode 100644
index 0000000..56c49ee
--- /dev/null
+++ b/test/unique.test
@@ -0,0 +1,253 @@
+# 2001 September 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the CREATE UNIQUE INDEX statement,
+# and primary keys, and the UNIQUE constraint on table columns
+#
+# $Id: unique.test,v 1.9 2009/05/02 15:46:47 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Try to create a table with two primary keys.
+# (This is allowed in SQLite even that it is not valid SQL)
+#
+do_test unique-1.1 {
+ catchsql {
+ CREATE TABLE t1(
+ a int PRIMARY KEY,
+ b int PRIMARY KEY,
+ c text
+ );
+ }
+} {1 {table "t1" has more than one primary key}}
+do_test unique-1.1b {
+ catchsql {
+ CREATE TABLE t1(
+ a int PRIMARY KEY,
+ b int UNIQUE,
+ c text
+ );
+ }
+} {0 {}}
+do_test unique-1.2 {
+ catchsql {
+ INSERT INTO t1(a,b,c) VALUES(1,2,3)
+ }
+} {0 {}}
+do_test unique-1.3 {
+ catchsql {
+ INSERT INTO t1(a,b,c) VALUES(1,3,4)
+ }
+} {1 {column a is not unique}}
+do_test unique-1.4 {
+ execsql {
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 2 3}
+do_test unique-1.5 {
+ catchsql {
+ INSERT INTO t1(a,b,c) VALUES(3,2,4)
+ }
+} {1 {column b is not unique}}
+do_test unique-1.6 {
+ execsql {
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 2 3}
+do_test unique-1.7 {
+ catchsql {
+ INSERT INTO t1(a,b,c) VALUES(3,4,5)
+ }
+} {0 {}}
+do_test unique-1.8 {
+ execsql {
+ SELECT * FROM t1 ORDER BY a;
+ }
+} {1 2 3 3 4 5}
+integrity_check unique-1.9
+
+do_test unique-2.0 {
+ execsql {
+ DROP TABLE t1;
+ CREATE TABLE t2(a int, b int);
+ INSERT INTO t2(a,b) VALUES(1,2);
+ INSERT INTO t2(a,b) VALUES(3,4);
+ SELECT * FROM t2 ORDER BY a;
+ }
+} {1 2 3 4}
+do_test unique-2.1 {
+ catchsql {
+ CREATE UNIQUE INDEX i2 ON t2(a)
+ }
+} {0 {}}
+do_test unique-2.2 {
+ catchsql {
+ SELECT * FROM t2 ORDER BY a
+ }
+} {0 {1 2 3 4}}
+do_test unique-2.3 {
+ catchsql {
+ INSERT INTO t2 VALUES(1,5);
+ }
+} {1 {column a is not unique}}
+do_test unique-2.4 {
+ catchsql {
+ SELECT * FROM t2 ORDER BY a
+ }
+} {0 {1 2 3 4}}
+do_test unique-2.5 {
+ catchsql {
+ DROP INDEX i2;
+ SELECT * FROM t2 ORDER BY a;
+ }
+} {0 {1 2 3 4}}
+do_test unique-2.6 {
+ catchsql {
+ INSERT INTO t2 VALUES(1,5)
+ }
+} {0 {}}
+do_test unique-2.7 {
+ catchsql {
+ SELECT * FROM t2 ORDER BY a, b;
+ }
+} {0 {1 2 1 5 3 4}}
+do_test unique-2.8 {
+ catchsql {
+ CREATE UNIQUE INDEX i2 ON t2(a);
+ }
+} {1 {indexed columns are not unique}}
+do_test unique-2.9 {
+ catchsql {
+ CREATE INDEX i2 ON t2(a);
+ }
+} {0 {}}
+integrity_check unique-2.10
+
+# Test the UNIQUE keyword as used on two or more fields.
+#
+do_test unique-3.1 {
+ catchsql {
+ CREATE TABLE t3(
+ a int,
+ b int,
+ c int,
+ d int,
+ unique(a,c,d)
+ );
+ }
+} {0 {}}
+do_test unique-3.2 {
+ catchsql {
+ INSERT INTO t3(a,b,c,d) VALUES(1,2,3,4);
+ SELECT * FROM t3 ORDER BY a,b,c,d;
+ }
+} {0 {1 2 3 4}}
+do_test unique-3.3 {
+ catchsql {
+ INSERT INTO t3(a,b,c,d) VALUES(1,2,3,5);
+ SELECT * FROM t3 ORDER BY a,b,c,d;
+ }
+} {0 {1 2 3 4 1 2 3 5}}
+do_test unique-3.4 {
+ catchsql {
+ INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5);
+ SELECT * FROM t3 ORDER BY a,b,c,d;
+ }
+} {1 {columns a, c, d are not unique}}
+integrity_check unique-3.5
+
+# Make sure NULLs are distinct as far as the UNIQUE tests are
+# concerned.
+#
+do_test unique-4.1 {
+ execsql {
+ CREATE TABLE t4(a UNIQUE, b, c, UNIQUE(b,c));
+ INSERT INTO t4 VALUES(1,2,3);
+ INSERT INTO t4 VALUES(NULL, 2, NULL);
+ SELECT * FROM t4;
+ }
+} {1 2 3 {} 2 {}}
+do_test unique-4.2 {
+ catchsql {
+ INSERT INTO t4 VALUES(NULL, 3, 4);
+ }
+} {0 {}}
+do_test unique-4.3 {
+ execsql {
+ SELECT * FROM t4
+ }
+} {1 2 3 {} 2 {} {} 3 4}
+do_test unique-4.4 {
+ catchsql {
+ INSERT INTO t4 VALUES(2, 2, NULL);
+ }
+} {0 {}}
+do_test unique-4.5 {
+ execsql {
+ SELECT * FROM t4
+ }
+} {1 2 3 {} 2 {} {} 3 4 2 2 {}}
+
+# Ticket #1301. Any NULL value in a set of unique columns should
+# cause the rows to be distinct.
+#
+do_test unique-4.6 {
+ catchsql {
+ INSERT INTO t4 VALUES(NULL, 2, NULL);
+ }
+} {0 {}}
+do_test unique-4.7 {
+ execsql {SELECT * FROM t4}
+} {1 2 3 {} 2 {} {} 3 4 2 2 {} {} 2 {}}
+do_test unique-4.8 {
+ catchsql {CREATE UNIQUE INDEX i4a ON t4(a,b)}
+} {0 {}}
+do_test unique-4.9 {
+ catchsql {CREATE UNIQUE INDEX i4b ON t4(a,b,c)}
+} {0 {}}
+do_test unique-4.10 {
+ catchsql {CREATE UNIQUE INDEX i4c ON t4(b)}
+} {1 {indexed columns are not unique}}
+integrity_check unique-4.99
+
+# Test the error message generation logic. In particular, make sure we
+# do not overflow the static buffer used to generate the error message.
+#
+do_test unique-5.1 {
+ execsql {
+ CREATE TABLE t5(
+ first_column_with_long_name,
+ second_column_with_long_name,
+ third_column_with_long_name,
+ fourth_column_with_long_name,
+ fifth_column_with_long_name,
+ sixth_column_with_long_name,
+ UNIQUE(
+ first_column_with_long_name,
+ second_column_with_long_name,
+ third_column_with_long_name,
+ fourth_column_with_long_name,
+ fifth_column_with_long_name,
+ sixth_column_with_long_name
+ )
+ );
+ INSERT INTO t5 VALUES(1,2,3,4,5,6);
+ SELECT * FROM t5;
+ }
+} {1 2 3 4 5 6}
+do_test unique-5.2 {
+ catchsql {
+ INSERT INTO t5 VALUES(1,2,3,4,5,6);
+ }
+} {1 {columns first_column_with_long_name, second_column_with_long_name, third_column_with_long_name, fourth_column_with_long_name, fifth_column_with_long_name, sixth_column_with_long_name are not unique}}
+
+finish_test
diff --git a/test/unixexcl.test b/test/unixexcl.test
new file mode 100644
index 0000000..057ae0a
--- /dev/null
+++ b/test/unixexcl.test
@@ -0,0 +1,83 @@
+# 2011 March 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests for the "unix-excl" VFS module (part of
+# os_unix.c).
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+if {$::tcl_platform(platform)!="unix" || [info commands test_syscall]==""} {
+ finish_test
+ return
+}
+set testprefix unixexcl
+
+
+
+# Test that when using VFS "unix-excl", the first time the database is read
+# a process-wide exclusive lock is taken on it. This means other connections
+# within the process may still access the db normally, but connections from
+# outside the process cannot.
+#
+do_multiclient_test tn {
+ do_test unixexcl-1.$tn.1 {
+ sql1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('hello', 'world');
+ }
+ } {}
+ do_test unixexcl-1.$tn.2 { sql2 { SELECT * FROM t1 } } {hello world}
+ do_test unixexcl-1.$tn.3 {
+ code1 {
+ db close
+ sqlite3 db test.db -vfs unix-excl
+ db eval { SELECT * FROM t1 }
+ }
+ } {hello world}
+ if {$tn==1} {
+ do_test unixexcl-1.$tn.4.multiproc {
+ csql2 { SELECT * FROM t1 }
+ } {1 {database is locked}}
+ } else {
+ do_test unixexcl-1.$tn.4.singleproc {
+ csql2 { SELECT * FROM t1 }
+ } {0 {hello world}}
+ }
+}
+
+# Test that when using VFS "unix-excl", if a file is opened in read-only mode
+# the behaviour is the same as if VFS "unix" were used.
+#
+do_multiclient_test tn {
+ do_test unixexcl-2.$tn.1 {
+ sql1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('hello', 'world');
+ }
+ } {}
+ do_test unixexcl-2.$tn.2 { sql2 { SELECT * FROM t1 } } {hello world}
+ do_test unixexcl-2.$tn.3 {
+ code1 {
+ db close
+ sqlite3 db test.db -readonly yes -vfs unix-excl
+ db eval { SELECT * FROM t1 }
+ }
+ } {hello world}
+ do_test unixexcl-2.$tn.4 {
+ csql2 { SELECT * FROM t1 }
+ } {0 {hello world}}
+}
+
+finish_test
diff --git a/test/unordered.test b/test/unordered.test
new file mode 100644
index 0000000..6c7c2bb
--- /dev/null
+++ b/test/unordered.test
@@ -0,0 +1,70 @@
+# 2011 April 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix unordered
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1 VALUES(1, 'xxx');
+ INSERT INTO t1 SELECT a+1, b FROM t1;
+ INSERT INTO t1 SELECT a+2, b FROM t1;
+ INSERT INTO t1 SELECT a+4, b FROM t1;
+ INSERT INTO t1 SELECT a+8, b FROM t1;
+ INSERT INTO t1 SELECT a+16, b FROM t1;
+ INSERT INTO t1 SELECT a+32, b FROM t1;
+ INSERT INTO t1 SELECT a+64, b FROM t1;
+ ANALYZE;
+} {}
+
+foreach idxmode {ordered unordered} {
+ catchsql { DELETE FROM sqlite_stat2 }
+ catchsql { DELETE FROM sqlite_stat3 }
+ if {$idxmode == "unordered"} {
+ execsql { UPDATE sqlite_stat1 SET stat = stat || ' unordered' }
+ }
+ db close
+ sqlite3 db test.db
+ foreach {tn sql r(ordered) r(unordered)} {
+ 1 "SELECT * FROM t1 ORDER BY a"
+ {0 0 0 {SCAN TABLE t1 USING INDEX i1 (~128 rows)}}
+ {0 0 0 {SCAN TABLE t1 (~128 rows)} 0 0 0 {USE TEMP B-TREE FOR ORDER BY}}
+ 2 "SELECT * FROM t1 WHERE a >?"
+ {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?) (~32 rows)}}
+ {0 0 0 {SCAN TABLE t1 (~42 rows)}}
+ 3 "SELECT * FROM t1 WHERE a = ? ORDER BY rowid"
+ {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}}
+ {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}}
+ 4 "SELECT max(a) FROM t1"
+ {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (~1 rows)}}
+ {0 0 0 {SEARCH TABLE t1 (~1 rows)}}
+ 5 "SELECT group_concat(b) FROM t1 GROUP BY a"
+ {0 0 0 {SCAN TABLE t1 USING INDEX i1 (~128 rows)}}
+ {0 0 0 {SCAN TABLE t1 (~128 rows)} 0 0 0 {USE TEMP B-TREE FOR GROUP BY}}
+
+ 6 "SELECT * FROM t1 WHERE a = ?"
+ {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}}
+ {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}}
+ 7 "SELECT count(*) FROM t1"
+ {0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1(~128 rows)}}
+ {0 0 0 {SCAN TABLE t1 (~128 rows)}}
+ } {
+ do_eqp_test 1.$idxmode.$tn $sql $r($idxmode)
+ }
+}
+
+finish_test
diff --git a/test/update.test b/test/update.test
new file mode 100644
index 0000000..a6fef7d
--- /dev/null
+++ b/test/update.test
@@ -0,0 +1,608 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the UPDATE statement.
+#
+# $Id: update.test,v 1.19 2008/04/10 18:44:36 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Try to update an non-existent table
+#
+do_test update-1.1 {
+ set v [catch {execsql {UPDATE test1 SET f2=5 WHERE f1<1}} msg]
+ lappend v $msg
+} {1 {no such table: test1}}
+
+# Try to update a read-only table
+#
+do_test update-2.1 {
+ set v [catch \
+ {execsql {UPDATE sqlite_master SET name='xyz' WHERE name='123'}} msg]
+ lappend v $msg
+} {1 {table sqlite_master may not be modified}}
+
+# Create a table to work with
+#
+do_test update-3.1 {
+ execsql {CREATE TABLE test1(f1 int,f2 int)}
+ for {set i 1} {$i<=10} {incr i} {
+ set sql "INSERT INTO test1 VALUES($i,[expr {1<<$i}])"
+ execsql $sql
+ }
+ execsql {SELECT * FROM test1 ORDER BY f1}
+} {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024}
+
+# Unknown column name in an expression
+#
+do_test update-3.2 {
+ set v [catch {execsql {UPDATE test1 SET f1=f3*2 WHERE f2==32}} msg]
+ lappend v $msg
+} {1 {no such column: f3}}
+do_test update-3.3 {
+ set v [catch {execsql {UPDATE test1 SET f1=test2.f1*2 WHERE f2==32}} msg]
+ lappend v $msg
+} {1 {no such column: test2.f1}}
+do_test update-3.4 {
+ set v [catch {execsql {UPDATE test1 SET f3=f1*2 WHERE f2==32}} msg]
+ lappend v $msg
+} {1 {no such column: f3}}
+
+# Actually do some updates
+#
+do_test update-3.5 {
+ execsql {UPDATE test1 SET f2=f2*3}
+} {}
+do_test update-3.5.1 {
+ db changes
+} {10}
+
+# verify that SELECT does not reset the change counter
+do_test update-3.5.2 {
+ db eval {SELECT count(*) FROM test1}
+} {10}
+do_test update-3.5.3 {
+ db changes
+} {10}
+
+do_test update-3.6 {
+ execsql {SELECT * FROM test1 ORDER BY f1}
+} {1 6 2 12 3 24 4 48 5 96 6 192 7 384 8 768 9 1536 10 3072}
+do_test update-3.7 {
+ execsql {PRAGMA count_changes=on}
+ execsql {UPDATE test1 SET f2=f2/3 WHERE f1<=5}
+} {5}
+do_test update-3.8 {
+ execsql {SELECT * FROM test1 ORDER BY f1}
+} {1 2 2 4 3 8 4 16 5 32 6 192 7 384 8 768 9 1536 10 3072}
+do_test update-3.9 {
+ execsql {UPDATE test1 SET f2=f2/3 WHERE f1>5}
+} {5}
+do_test update-3.10 {
+ execsql {SELECT * FROM test1 ORDER BY f1}
+} {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024}
+
+# Swap the values of f1 and f2 for all elements
+#
+do_test update-3.11 {
+ execsql {UPDATE test1 SET F2=f1, F1=f2}
+} {10}
+do_test update-3.12 {
+ execsql {SELECT * FROM test1 ORDER BY F1}
+} {2 1 4 2 8 3 16 4 32 5 64 6 128 7 256 8 512 9 1024 10}
+do_test update-3.13 {
+ execsql {PRAGMA count_changes=off}
+ execsql {UPDATE test1 SET F2=f1, F1=f2}
+} {}
+do_test update-3.14 {
+ execsql {SELECT * FROM test1 ORDER BY F1}
+} {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024}
+
+# Create duplicate entries and make sure updating still
+# works.
+#
+do_test update-4.0 {
+ execsql {
+ DELETE FROM test1 WHERE f1<=5;
+ INSERT INTO test1(f1,f2) VALUES(8,88);
+ INSERT INTO test1(f1,f2) VALUES(8,888);
+ INSERT INTO test1(f1,f2) VALUES(77,128);
+ INSERT INTO test1(f1,f2) VALUES(777,128);
+ }
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-4.1 {
+ execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}
+do_test update-4.2 {
+ execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}
+do_test update-4.3 {
+ execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-4.4 {
+ execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}
+do_test update-4.5 {
+ execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}
+do_test update-4.6 {
+ execsql {
+ PRAGMA count_changes=on;
+ UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128;
+ }
+} {2}
+do_test update-4.7 {
+ execsql {
+ PRAGMA count_changes=off;
+ SELECT * FROM test1 ORDER BY f1,f2
+ }
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+
+# Repeat the previous sequence of tests with an index.
+#
+do_test update-5.0 {
+ execsql {CREATE INDEX idx1 ON test1(f1)}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-5.1 {
+ execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}
+do_test update-5.2 {
+ execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}
+do_test update-5.3 {
+ execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-5.4 {
+ execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}
+do_test update-5.4.1 {
+ execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
+} {78 128}
+do_test update-5.4.2 {
+ execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
+} {778 128}
+do_test update-5.4.3 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 128 8 256 8 888}
+do_test update-5.5 {
+ execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}
+} {}
+do_test update-5.5.1 {
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}
+do_test update-5.5.2 {
+ execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
+} {78 128}
+do_test update-5.5.3 {
+ execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
+} {}
+do_test update-5.5.4 {
+ execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
+} {777 128}
+do_test update-5.5.5 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 128 8 256 8 888}
+do_test update-5.6 {
+ execsql {
+ PRAGMA count_changes=on;
+ UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128;
+ }
+} {2}
+do_test update-5.6.1 {
+ execsql {
+ PRAGMA count_changes=off;
+ SELECT * FROM test1 ORDER BY f1,f2
+ }
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-5.6.2 {
+ execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2}
+} {77 128}
+do_test update-5.6.3 {
+ execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
+} {}
+do_test update-5.6.4 {
+ execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
+} {777 128}
+do_test update-5.6.5 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 256 8 888}
+
+# Repeat the previous sequence of tests with a different index.
+#
+execsql {PRAGMA synchronous=FULL}
+do_test update-6.0 {
+ execsql {DROP INDEX idx1}
+ execsql {CREATE INDEX idx1 ON test1(f2)}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-6.1 {
+ execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}
+do_test update-6.1.1 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 89 8 257 8 889}
+do_test update-6.1.2 {
+ execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}
+} {8 89}
+do_test update-6.1.3 {
+ execsql {SELECT * FROM test1 WHERE f1==88 ORDER BY f1,f2}
+} {}
+do_test update-6.2 {
+ execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}
+do_test update-6.3 {
+ execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-6.3.1 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 256 8 888}
+do_test update-6.3.2 {
+ execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}
+} {}
+do_test update-6.3.3 {
+ execsql {SELECT * FROM test1 WHERE f2==88 ORDER BY f1,f2}
+} {8 88}
+do_test update-6.4 {
+ execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}
+do_test update-6.4.1 {
+ execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
+} {78 128}
+do_test update-6.4.2 {
+ execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
+} {778 128}
+do_test update-6.4.3 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 128 8 256 8 888}
+do_test update-6.5 {
+ execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}
+do_test update-6.5.1 {
+ execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
+} {78 128}
+do_test update-6.5.2 {
+ execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
+} {}
+do_test update-6.5.3 {
+ execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
+} {777 128}
+do_test update-6.5.4 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 128 8 256 8 888}
+do_test update-6.6 {
+ execsql {UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-6.6.1 {
+ execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2}
+} {77 128}
+do_test update-6.6.2 {
+ execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
+} {}
+do_test update-6.6.3 {
+ execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
+} {777 128}
+do_test update-6.6.4 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 256 8 888}
+
+# Repeat the previous sequence of tests with multiple
+# indices
+#
+do_test update-7.0 {
+ execsql {CREATE INDEX idx2 ON test1(f2)}
+ execsql {CREATE INDEX idx3 ON test1(f1,f2)}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-7.1 {
+ execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}
+do_test update-7.1.1 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 89 8 257 8 889}
+do_test update-7.1.2 {
+ execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}
+} {8 89}
+do_test update-7.1.3 {
+ execsql {SELECT * FROM test1 WHERE f1==88 ORDER BY f1,f2}
+} {}
+do_test update-7.2 {
+ execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}
+do_test update-7.3 {
+ # explain {UPDATE test1 SET f2=f2-1 WHERE f1==8 and F2<300}
+ execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-7.3.1 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 256 8 888}
+do_test update-7.3.2 {
+ execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}
+} {}
+do_test update-7.3.3 {
+ execsql {SELECT * FROM test1 WHERE f2==88 ORDER BY f1,f2}
+} {8 88}
+do_test update-7.4 {
+ execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}
+do_test update-7.4.1 {
+ execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
+} {78 128}
+do_test update-7.4.2 {
+ execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
+} {778 128}
+do_test update-7.4.3 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 128 8 256 8 888}
+do_test update-7.5 {
+ execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}
+do_test update-7.5.1 {
+ execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
+} {78 128}
+do_test update-7.5.2 {
+ execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
+} {}
+do_test update-7.5.3 {
+ execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
+} {777 128}
+do_test update-7.5.4 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 128 8 256 8 888}
+do_test update-7.6 {
+ execsql {UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128}
+ execsql {SELECT * FROM test1 ORDER BY f1,f2}
+} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
+do_test update-7.6.1 {
+ execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2}
+} {77 128}
+do_test update-7.6.2 {
+ execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
+} {}
+do_test update-7.6.3 {
+ execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
+} {777 128}
+do_test update-7.6.4 {
+ execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
+} {8 88 8 256 8 888}
+
+# Error messages
+#
+do_test update-9.1 {
+ set v [catch {execsql {
+ UPDATE test1 SET x=11 WHERE f1=1025
+ }} msg]
+ lappend v $msg
+} {1 {no such column: x}}
+do_test update-9.2 {
+ set v [catch {execsql {
+ UPDATE test1 SET f1=x(11) WHERE f1=1025
+ }} msg]
+ lappend v $msg
+} {1 {no such function: x}}
+do_test update-9.3 {
+ set v [catch {execsql {
+ UPDATE test1 SET f1=11 WHERE x=1025
+ }} msg]
+ lappend v $msg
+} {1 {no such column: x}}
+do_test update-9.4 {
+ set v [catch {execsql {
+ UPDATE test1 SET f1=11 WHERE x(f1)=1025
+ }} msg]
+ lappend v $msg
+} {1 {no such function: x}}
+
+# Try doing updates on a unique column where the value does not
+# really change.
+#
+do_test update-10.1 {
+ execsql {
+ DROP TABLE test1;
+ CREATE TABLE t1(
+ a integer primary key,
+ b UNIQUE,
+ c, d,
+ e, f,
+ UNIQUE(c,d)
+ );
+ INSERT INTO t1 VALUES(1,2,3,4,5,6);
+ INSERT INTO t1 VALUES(2,3,4,4,6,7);
+ SELECT * FROM t1
+ }
+} {1 2 3 4 5 6 2 3 4 4 6 7}
+do_test update-10.2 {
+ catchsql {
+ UPDATE t1 SET a=1, e=9 WHERE f=6;
+ SELECT * FROM t1;
+ }
+} {0 {1 2 3 4 9 6 2 3 4 4 6 7}}
+do_test update-10.3 {
+ catchsql {
+ UPDATE t1 SET a=1, e=10 WHERE f=7;
+ SELECT * FROM t1;
+ }
+} {1 {PRIMARY KEY must be unique}}
+do_test update-10.4 {
+ catchsql {
+ SELECT * FROM t1;
+ }
+} {0 {1 2 3 4 9 6 2 3 4 4 6 7}}
+do_test update-10.5 {
+ catchsql {
+ UPDATE t1 SET b=2, e=11 WHERE f=6;
+ SELECT * FROM t1;
+ }
+} {0 {1 2 3 4 11 6 2 3 4 4 6 7}}
+do_test update-10.6 {
+ catchsql {
+ UPDATE t1 SET b=2, e=12 WHERE f=7;
+ SELECT * FROM t1;
+ }
+} {1 {column b is not unique}}
+do_test update-10.7 {
+ catchsql {
+ SELECT * FROM t1;
+ }
+} {0 {1 2 3 4 11 6 2 3 4 4 6 7}}
+do_test update-10.8 {
+ catchsql {
+ UPDATE t1 SET c=3, d=4, e=13 WHERE f=6;
+ SELECT * FROM t1;
+ }
+} {0 {1 2 3 4 13 6 2 3 4 4 6 7}}
+do_test update-10.9 {
+ catchsql {
+ UPDATE t1 SET c=3, d=4, e=14 WHERE f=7;
+ SELECT * FROM t1;
+ }
+} {1 {columns c, d are not unique}}
+do_test update-10.10 {
+ catchsql {
+ SELECT * FROM t1;
+ }
+} {0 {1 2 3 4 13 6 2 3 4 4 6 7}}
+
+# Make sure we can handle a subquery in the where clause.
+#
+ifcapable subquery {
+ do_test update-11.1 {
+ execsql {
+ UPDATE t1 SET e=e+1 WHERE b IN (SELECT b FROM t1);
+ SELECT b,e FROM t1;
+ }
+ } {2 14 3 7}
+ do_test update-11.2 {
+ execsql {
+ UPDATE t1 SET e=e+1 WHERE a IN (SELECT a FROM t1);
+ SELECT a,e FROM t1;
+ }
+ } {1 15 2 8}
+}
+
+integrity_check update-12.1
+
+# Ticket 602. Updates should occur in the same order as the records
+# were discovered in the WHERE clause.
+#
+do_test update-13.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ INSERT INTO t2 SELECT a+2 FROM t2;
+ INSERT INTO t2 SELECT a+4 FROM t2;
+ INSERT INTO t2 SELECT a+8 FROM t2;
+ INSERT INTO t2 SELECT a+16 FROM t2;
+ INSERT INTO t2 SELECT a+32 FROM t2;
+ INSERT INTO t2 SELECT a+64 FROM t2;
+ INSERT INTO t2 SELECT a+128 FROM t2;
+ INSERT INTO t2 SELECT a+256 FROM t2;
+ INSERT INTO t2 SELECT a+512 FROM t2;
+ INSERT INTO t2 SELECT a+1024 FROM t2;
+ COMMIT;
+ SELECT count(*) FROM t2;
+ }
+} {2048}
+do_test update-13.2 {
+ execsql {
+ SELECT count(*) FROM t2 WHERE a=rowid;
+ }
+} {2048}
+do_test update-13.3 {
+ execsql {
+ UPDATE t2 SET rowid=rowid-1;
+ SELECT count(*) FROM t2 WHERE a=rowid+1;
+ }
+} {2048}
+do_test update-13.3 {
+ execsql {
+ UPDATE t2 SET rowid=rowid+10000;
+ UPDATE t2 SET rowid=rowid-9999;
+ SELECT count(*) FROM t2 WHERE a=rowid;
+ }
+} {2048}
+do_test update-13.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO t2 SELECT a+2048 FROM t2;
+ INSERT INTO t2 SELECT a+4096 FROM t2;
+ INSERT INTO t2 SELECT a+8192 FROM t2;
+ SELECT count(*) FROM t2 WHERE a=rowid;
+ COMMIT;
+ }
+} 16384
+do_test update-13.5 {
+ execsql {
+ UPDATE t2 SET rowid=rowid-1;
+ SELECT count(*) FROM t2 WHERE a=rowid+1;
+ }
+} 16384
+
+integrity_check update-13.6
+
+ifcapable {trigger} {
+# Test for proper detection of malformed WHEN clauses on UPDATE triggers.
+#
+do_test update-14.1 {
+ execsql {
+ CREATE TABLE t3(a,b,c);
+ CREATE TRIGGER t3r1 BEFORE UPDATE on t3 WHEN nosuchcol BEGIN
+ SELECT 'illegal WHEN clause';
+ END;
+ }
+} {}
+do_test update-14.2 {
+ catchsql {
+ UPDATE t3 SET a=1;
+ }
+} {1 {no such column: nosuchcol}}
+do_test update-14.3 {
+ execsql {
+ CREATE TABLE t4(a,b,c);
+ CREATE TRIGGER t4r1 AFTER UPDATE on t4 WHEN nosuchcol BEGIN
+ SELECT 'illegal WHEN clause';
+ END;
+ }
+} {}
+do_test update-14.4 {
+ catchsql {
+ UPDATE t4 SET a=1;
+ }
+} {1 {no such column: nosuchcol}}
+
+} ;# ifcapable {trigger}
+
+
+finish_test
diff --git a/test/uri.test b/test/uri.test
new file mode 100644
index 0000000..90074d0
--- /dev/null
+++ b/test/uri.test
@@ -0,0 +1,312 @@
+# 2011 April 22
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Test organization:
+#
+# 1.*: That file names are correctly extracted from URIs.
+# 2.*: That URI options (query parameters) are correctly extracted from URIs.
+# 3.*: That specifying an unknown VFS causes an error.
+# 4.*: Tests for specifying other options (other than "vfs").
+# 5.*: Test using a different VFS with an attached database.
+# 6.*: Test that authorities other than "" and localhost cause errors.
+# 7.*: Test that a read-write db can be attached to a read-only connection.
+#
+
+set testprefix uri
+db close
+sqlite3_shutdown
+sqlite3_config_uri 1
+
+#-------------------------------------------------------------------------
+# Test that file names are correctly extracted from URIs.
+#
+foreach {tn uri file} {
+ 1 test.db test.db
+ 2 file:test.db test.db
+ 3 file://PWD/test.db test.db
+ 4 file:PWD/test.db test.db
+ 5 file:test.db?mork=1 test.db
+ 6 file:test.db?mork=1&tonglor=2 test.db
+ 7 file:test.db?mork=1#boris test.db
+ 8 file:test.db#boris test.db
+ 9 test.db#boris test.db#boris
+ 10 file:test%2Edb test.db
+ 11 file file
+ 12 http:test.db http:test.db
+ 13 file:test.db%00extra test.db
+ 14 file:testdb%00.db%00extra testdb
+
+ 15 test.db?mork=1#boris test.db?mork=1#boris
+ 16 file://localhostPWD/test.db%3Fhello test.db?hello
+} {
+
+ if {$tcl_platform(platform)=="windows"} {
+ if {$tn>14} break
+ set uri [string map [list PWD /[pwd]] $uri]
+ } else {
+ set uri [string map [list PWD [pwd]] $uri]
+ }
+
+ if {[file isdir $file]} {error "$file is a directory"}
+ forcedelete $file
+ do_test 1.$tn.1 { file exists $file } 0
+ set DB [sqlite3_open $uri]
+ do_test 1.$tn.2 { file exists $file } 1
+ sqlite3_close $DB
+ forcedelete $file
+
+ do_test 1.$tn.3 { file exists $file } 0
+ sqlite3 db xxx.db
+ catchsql { ATTACH $uri AS aux }
+ do_test 1.$tn.4 { file exists $file } 1
+ db close
+}
+
+#-------------------------------------------------------------------------
+# Test that URI query parameters are passed through to the VFS layer
+# correctly.
+#
+testvfs tvfs2
+testvfs tvfs -default 1
+tvfs filter xOpen
+tvfs script open_method
+proc open_method {method file arglist} {
+ set ::arglist $arglist
+}
+foreach {tn uri kvlist} {
+ 1 file:test.db?hello=world {hello world}
+ 2 file:test.db?hello&world {hello {} world {}}
+ 3 file:test.db?hello=1&world=2&vfs=tvfs {hello 1 world 2 vfs tvfs}
+ 4 file:test.db?hello=1&world=2&vfs=tvfs2 {}
+ 5 file:test.db?%68%65%6C%6C%6F=%77%6F%72%6C%64 {hello world}
+ 6 file:testdb%00.db?hello%00extra=world%00ex {hello world}
+ 7 file:testdb%00.db?hello%00=world%00 {hello world}
+ 8 file:testdb%00.db?=world&xyz=abc {xyz abc}
+ 9 file:test.db?%00hello=world&xyz=abc {xyz abc}
+ 10 file:test.db?hello=%00world&xyz= {hello {} xyz {}}
+ 11 file:test.db?=#ravada {}
+ 12 file:test.db?&&&&&&&&hello=world&&&&&&& {hello world}
+
+ 13 test.db?&&&&&&&&hello=world&&&&&&& {}
+ 14 http:test.db?hello&world {}
+} {
+
+ if {$tcl_platform(platform) == "windows" && $tn>12} {
+ continue
+ }
+
+ set ::arglist ""
+ set DB [sqlite3_open $uri]
+ do_test 2.$tn.1 { set ::arglist } $kvlist
+ sqlite3_close $DB
+
+ sqlite3 db xxx.db
+ set ::arglist ""
+ execsql { ATTACH $uri AS aux }
+ do_test 2.$tn.2 { set ::arglist } $kvlist
+ db close
+}
+tvfs delete
+tvfs2 delete
+
+#-------------------------------------------------------------------------
+# Test that specifying a non-existent VFS raises an error.
+#
+do_test 3.1 {
+ list [catch { sqlite3 db "file:test.db?vfs=nosuchvfs" } msg] $msg
+} {1 {no such vfs: nosuchvfs}}
+
+#-------------------------------------------------------------------------
+# Test some of the other options (other than "vfs").
+#
+foreach {tn mode create_ok write_ok readonly_ok} {
+ 1 ro 0 0 1
+ 2 rw 0 1 0
+ 3 rwc 1 1 0
+} {
+ catch { db close }
+ forcedelete test.db
+
+ set A(1) {0 {}}
+ set A(0) {1 {unable to open database file}}
+ do_test 4.1.$tn.1 {
+ list [catch {sqlite3 db "file:test.db?mode=$mode"} msg] $msg
+ } $A($create_ok)
+
+ catch { db close }
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval { CREATE TABLE t1(a, b) }
+ db close
+
+ set A(1) {0 {}}
+ set A(0) {1 {attempt to write a readonly database}}
+ do_test 4.1.$tn.2 {
+ sqlite3 db "file:test.db?mode=$mode"
+ catchsql { INSERT INTO t1 VALUES(1, 2) }
+ } $A($write_ok)
+
+ set A(1) {0 {}}
+ set A(0) [list 1 "access mode not allowed: $mode"]
+ do_test 4.1.$tn.3 {
+ list [catch {sqlite3 db "file:test.db?mode=$mode" -readonly 1} msg] $msg
+ } $A($readonly_ok)
+}
+
+set orig [sqlite3_enable_shared_cache]
+foreach {tn options sc_default is_shared} {
+ 1 "" 1 1
+ 2 "cache=private" 1 0
+ 3 "cache=shared" 1 1
+ 4 "" 0 0
+ 5 "cache=private" 0 0
+ 6 "cache=shared" 0 1
+} {
+ catch { db close }
+ forcedelete test.db
+
+ sqlite3_enable_shared_cache 1
+ sqlite3 db2 test.db
+ db2 eval {CREATE TABLE t1(a, b)}
+
+ sqlite3_enable_shared_cache $sc_default
+ sqlite3 db "file:test.db?$options"
+ db eval {SELECT * FROM t1}
+
+ set A(1) {1 {database table is locked: t1}}
+ set A(0) {0 {}}
+ do_test 4.2.$tn {
+ db2 eval {BEGIN; INSERT INTO t1 VALUES(1, 2);}
+ catchsql { SELECT * FROM t1 }
+ } $A($is_shared)
+
+ db2 close
+}
+
+do_test 4.3.1 {
+ list [catch {sqlite3 db "file:test.db?mode=rc"} msg] $msg
+} {1 {no such access mode: rc}}
+do_test 4.3.2 {
+ list [catch {sqlite3 db "file:test.db?cache=public"} msg] $msg
+} {1 {no such cache mode: public}}
+
+#-------------------------------------------------------------------------
+# Test that things work if an ATTACHed database uses a different VFS than
+# the main database. The important point is that for all operations
+# involving the ATTACHed database, the correct versions of the following
+# VFS are used for all operations involving the attached database.
+#
+# xOpen
+# xDelete
+# xAccess
+# xFullPathname
+#
+
+# This block of code creates two VFS - "tvfs1" and "tvfs2". Each time one
+# of the above methods is called using "tvfs1", global variable ::T1(X) is
+# set, where X is the file-name the method is called on. Calls to the above
+# methods using "tvfs2" set entries in the global T2 array.
+#
+ifcapable wal {
+ testvfs tvfs1
+ tvfs1 filter {xOpen xDelete xAccess xFullPathname}
+ tvfs1 script tvfs1_callback
+ proc tvfs1_callback {method filename args} {
+ set ::T1([file tail $filename]) 1
+ }
+ testvfs tvfs2
+ tvfs2 filter {xOpen xDelete xAccess xFullPathname}
+ tvfs2 script tvfs2_callback
+ proc tvfs2_callback {method filename args} {
+ set ::T2([file tail $filename]) 1
+ }
+
+ catch {db close}
+ eval forcedelete [glob test.db*]
+ do_test 5.1.1 {
+ sqlite3 db file:test.db1?vfs=tvfs1
+ execsql {
+ ATTACH 'file:test.db2?vfs=tvfs2' AS aux;
+ PRAGMA main.journal_mode = PERSIST;
+ PRAGMA aux.journal_mode = PERSIST;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE aux.t2(a, b);
+ PRAGMA main.journal_mode = WAL;
+ PRAGMA aux.journal_mode = WAL;
+ INSERT INTO t1 VALUES('x', 'y');
+ INSERT INTO t2 VALUES('x', 'y');
+ }
+ lsort [array names ::T1]
+ } {test.db1 test.db1-journal test.db1-wal}
+
+ do_test 5.1.2 {
+ lsort [array names ::T2]
+ } {test.db2 test.db2-journal test.db2-wal}
+ db close
+
+ tvfs1 delete
+ tvfs2 delete
+}
+
+#-------------------------------------------------------------------------
+# Check that only "" and "localhost" are acceptable as authorities.
+#
+catch {db close}
+foreach {tn uri res} {
+ 1 "file://localhost/PWD/test.db" {not an error}
+ 2 "file:///PWD/test.db" {not an error}
+ 3 "file:/PWD/test.db" {not an error}
+ 4 "file://l%6Fcalhost/PWD/test.db" {invalid uri authority: l%6Fcalhost}
+ 5 "file://lbcalhost/PWD/test.db" {invalid uri authority: lbcalhost}
+ 6 "file://x/PWD/test.db" {invalid uri authority: x}
+} {
+
+ if {$tcl_platform(platform)=="windows"} {
+ set uri [string map [list PWD [string range [pwd] 3 end]] $uri]
+ } else {
+ set uri [string map [list PWD [string range [pwd] 1 end]] $uri]
+ }
+
+ do_test 6.$tn {
+ set DB [sqlite3_open $uri]
+ sqlite3_errmsg $DB
+ } $res
+ catch { sqlite3_close $DB }
+}
+
+forcedelete test.db test.db2
+do_test 7.1 {
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t2(a, b);
+ INSERT INTO t1 VALUES('a', 'b');
+ }
+ db close
+} {}
+do_test 7.2 {
+ sqlite3 db file:test.db?mode=ro
+ execsql { ATTACH 'file:test.db2?mode=rw' AS aux }
+} {}
+do_execsql_test 7.3 {
+ INSERT INTO t2 VALUES('c', 'd')
+} {}
+do_catchsql_test 7.4 {
+ INSERT INTO t1 VALUES(3, 4)
+} {1 {attempt to write a readonly database}}
+
+finish_test
diff --git a/test/utf16align.test b/test/utf16align.test
new file mode 100644
index 0000000..f026d95
--- /dev/null
+++ b/test/utf16align.test
@@ -0,0 +1,95 @@
+# 2006 February 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains code to verify that the SQLITE_UTF16_ALIGNED
+# flag passed into the sqlite3_create_collation() function insures
+# that all strings passed to that function are aligned on an even
+# byte boundary.
+#
+# $Id: utf16align.test,v 1.2 2008/11/07 03:29:34 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Skip this entire test if we do not support UTF16
+#
+ifcapable !utf16 {
+ finish_test
+ return
+}
+
+# Create a database with a UTF16 encoding. Put in lots of string
+# data of varying lengths.
+#
+do_test utf16align-1.0 {
+ set unaligned_string_counter 0
+ add_alignment_test_collations [sqlite3_connection_pointer db]
+ execsql {
+ PRAGMA encoding=UTF16;
+ CREATE TABLE t1(
+ id INTEGER PRIMARY KEY,
+ spacer TEXT,
+ a TEXT COLLATE utf16_aligned,
+ b TEXT COLLATE utf16_unaligned
+ );
+ INSERT INTO t1(a) VALUES("abc");
+ INSERT INTO t1(a) VALUES("defghi");
+ INSERT INTO t1(a) VALUES("jklmnopqrstuv");
+ INSERT INTO t1(a) VALUES("wxyz0123456789-");
+ UPDATE t1 SET b=a||'-'||a;
+ INSERT INTO t1(a,b) SELECT a||b, b||a FROM t1;
+ INSERT INTO t1(a,b) SELECT a||b, b||a FROM t1;
+ INSERT INTO t1(a,b) SELECT a||b, b||a FROM t1;
+ INSERT INTO t1(a,b) VALUES('one','two');
+ INSERT INTO t1(a,b) SELECT a, b FROM t1;
+ UPDATE t1 SET spacer = CASE WHEN rowid&1 THEN 'x' ELSE 'xx' END;
+ SELECT count(*) FROM t1;
+ }
+} 66
+do_test utf16align-1.1 {
+ set unaligned_string_counter
+} 0
+
+# Creating an index that uses the unaligned collation. We should see
+# some unaligned strings passed to the collating function.
+#
+do_test utf16align-1.2 {
+ execsql {
+ CREATE INDEX t1i1 ON t1(spacer, b);
+ }
+ # puts $unaligned_string_counter
+ expr {$unaligned_string_counter>0}
+} 1
+
+# Create another index that uses the aligned collation. This time
+# there should be no unaligned accesses
+#
+do_test utf16align-1.3 {
+ set unaligned_string_counter 0
+ execsql {
+ CREATE INDEX t1i2 ON t1(spacer, a);
+ }
+ expr {$unaligned_string_counter>0}
+} 0
+integrity_check utf16align-1.4
+
+# ticket #3482
+#
+db close
+sqlite3 db :memory:
+do_test utf16align-2.1 {
+ db eval {
+ PRAGMA encoding=UTF16be;
+ SELECT hex(ltrim(x'6efcda'));
+ }
+} {6EFC}
+
+finish_test
diff --git a/test/vacuum.test b/test/vacuum.test
new file mode 100644
index 0000000..57429c2
--- /dev/null
+++ b/test/vacuum.test
@@ -0,0 +1,404 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the VACUUM statement.
+#
+# $Id: vacuum.test,v 1.43 2009/01/31 14:54:07 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If the VACUUM statement is disabled in the current build, skip all
+# the tests in this file.
+#
+ifcapable {!vacuum} {
+ omit_test vacuum.test {Compiled with SQLITE_OMIT_VACUUM}
+ finish_test
+ return
+}
+if $AUTOVACUUM {
+ omit_test vacuum.test {Auto-vacuum is enabled}
+ finish_test
+ return
+}
+
+set fcnt 1
+do_test vacuum-1.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ INSERT INTO t1 VALUES(NULL,randstr(10,100),randstr(5,50));
+ INSERT INTO t1 VALUES(123456,randstr(10,100),randstr(5,50));
+ INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
+ CREATE INDEX i1 ON t1(b,c);
+ CREATE UNIQUE INDEX i2 ON t1(c,a);
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ COMMIT;
+ DROP TABLE t2;
+ }
+ set ::size1 [file size test.db]
+ set ::cksum [cksum]
+ expr {$::cksum!=""}
+} {1}
+
+# Create bogus application-defined functions for functions used
+# internally by VACUUM, to ensure that VACUUM falls back
+# to the built-in functions.
+#
+proc failing_app_func {args} {error "bad function"}
+do_test vacuum-1.1b {
+ db func substr failing_app_func
+ db func like failing_app_func
+ db func quote failing_app_func
+ catchsql {SELECT substr(name,1,3) FROM sqlite_master}
+} {1 {bad function}}
+
+do_test vacuum-1.2 {
+ execsql {
+ VACUUM;
+ }
+ cksum
+} $cksum
+ifcapable vacuum {
+ do_test vacuum-1.3 {
+ expr {[file size test.db]<$::size1}
+ } {1}
+}
+do_test vacuum-1.4 {
+ set sql_script {
+ BEGIN;
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ CREATE TABLE t3 AS SELECT * FROM t1;
+ CREATE VIEW v1 AS SELECT b, c FROM t3;
+ CREATE TRIGGER r1 AFTER DELETE ON t2 BEGIN SELECT 1; END;
+ COMMIT;
+ DROP TABLE t2;
+ }
+ # If the library was compiled to omit view support, comment out the
+ # create view in the script $sql_script before executing it. Similarly,
+ # if triggers are not supported, comment out the trigger definition.
+ ifcapable !view {
+ regsub {CREATE VIEW} $sql_script {-- CREATE VIEW} sql_script
+ }
+ ifcapable !trigger {
+ regsub {CREATE TRIGGER} $sql_script {-- CREATE TRIGGER} sql_script
+ }
+ execsql $sql_script
+ set ::size1 [file size test.db]
+ set ::cksum [cksum]
+ expr {$::cksum!=""}
+} {1}
+do_test vacuum-1.5 {
+ execsql {
+ VACUUM;
+ }
+ cksum
+} $cksum
+
+ifcapable vacuum {
+ do_test vacuum-1.6 {
+ expr {[file size test.db]<$::size1}
+ } {1}
+}
+ifcapable vacuum {
+ do_test vacuum-2.1.1 {
+ catchsql {
+ BEGIN;
+ VACUUM;
+ }
+ } {1 {cannot VACUUM from within a transaction}}
+ do_test vacuum-2.1.2 {
+ sqlite3_get_autocommit db
+ } {0}
+ do_test vacuum-2.1.3 {
+ db eval {COMMIT}
+ } {}
+}
+do_test vacuum-2.2 {
+ sqlite3 db2 test.db
+ execsql {
+ BEGIN;
+ CREATE TABLE t4 AS SELECT * FROM t1;
+ CREATE TABLE t5 AS SELECT * FROM t1;
+ COMMIT;
+ DROP TABLE t4;
+ DROP TABLE t5;
+ } db2
+ set ::cksum [cksum db2]
+ catchsql {
+ VACUUM
+ }
+} {0 {}}
+do_test vacuum-2.3 {
+ cksum
+} $cksum
+do_test vacuum-2.4 {
+ catch {db2 eval {SELECT count(*) FROM sqlite_master}}
+ cksum db2
+} $cksum
+
+# Make sure the schema cookie is incremented by vacuum.
+#
+do_test vacuum-2.5 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t6 AS SELECT * FROM t1;
+ CREATE TABLE t7 AS SELECT * FROM t1;
+ COMMIT;
+ }
+ sqlite3 db3 test.db
+ execsql {
+ -- The "SELECT * FROM sqlite_master" statement ensures that this test
+ -- works when shared-cache is enabled. If shared-cache is enabled, then
+ -- db3 shares a cache with db2 (but not db - it was opened as
+ -- "./test.db").
+ SELECT * FROM sqlite_master;
+ SELECT * FROM t7 LIMIT 1
+ } db3
+ execsql {
+ VACUUM;
+ }
+ execsql {
+ INSERT INTO t7 VALUES(1234567890,'hello','world');
+ } db3
+ execsql {
+ SELECT * FROM t7 WHERE a=1234567890
+ }
+} {1234567890 hello world}
+integrity_check vacuum-2.6
+do_test vacuum-2.7 {
+ execsql {
+ SELECT * FROM t7 WHERE a=1234567890
+ } db3
+} {1234567890 hello world}
+do_test vacuum-2.8 {
+ execsql {
+ INSERT INTO t7 SELECT * FROM t6;
+ SELECT count(*) FROM t7;
+ }
+} 513
+integrity_check vacuum-2.9
+do_test vacuum-2.10 {
+ execsql {
+ DELETE FROM t7;
+ SELECT count(*) FROM t7;
+ } db3
+} 0
+integrity_check vacuum-2.11
+db3 close
+
+
+# Ticket #427. Make sure VACUUM works when the EMPTY_RESULT_CALLBACKS
+# pragma is turned on.
+#
+do_test vacuum-3.1 {
+ db close
+ db2 close
+ delete_file test.db
+ sqlite3 db test.db
+ execsql {
+ PRAGMA empty_result_callbacks=on;
+ VACUUM;
+ }
+} {}
+
+# Ticket #464. Make sure VACUUM works with the sqlite3_prepare() API.
+#
+do_test vacuum-4.1 {
+ db close
+ sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
+ set VM [sqlite3_prepare $DB {VACUUM} -1 TAIL]
+ sqlite3_step $VM
+} {SQLITE_DONE}
+do_test vacuum-4.2 {
+ sqlite3_finalize $VM
+} SQLITE_OK
+
+# Ticket #515. VACUUM after deleting and recreating the table that
+# a view refers to. Omit this test if the library is not view-enabled.
+#
+ifcapable view {
+do_test vacuum-5.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ catchsql {
+ CREATE TABLE Test (TestID int primary key);
+ INSERT INTO Test VALUES (NULL);
+ CREATE VIEW viewTest AS SELECT * FROM Test;
+
+ BEGIN;
+ CREATE TABLE tempTest (TestID int primary key, Test2 int NULL);
+ INSERT INTO tempTest SELECT TestID, 1 FROM Test;
+ DROP TABLE Test;
+ CREATE TABLE Test(TestID int primary key, Test2 int NULL);
+ INSERT INTO Test SELECT * FROM tempTest;
+ DROP TABLE tempTest;
+ COMMIT;
+ VACUUM;
+ }
+} {0 {}}
+do_test vacuum-5.2 {
+ catchsql {
+ VACUUM;
+ }
+} {0 {}}
+} ;# ifcapable view
+
+# Ensure vacuum works with complicated tables names.
+do_test vacuum-6.1 {
+ execsql {
+ CREATE TABLE "abc abc"(a, b, c);
+ INSERT INTO "abc abc" VALUES(1, 2, 3);
+ VACUUM;
+ }
+} {}
+do_test vacuum-6.2 {
+ execsql {
+ select * from "abc abc";
+ }
+} {1 2 3}
+
+# Also ensure that blobs survive a vacuum.
+ifcapable {bloblit} {
+ do_test vacuum-6.3 {
+ execsql {
+ DELETE FROM "abc abc";
+ INSERT INTO "abc abc" VALUES(X'00112233', NULL, NULL);
+ VACUUM;
+ }
+ } {}
+ do_test vacuum-6.4 {
+ execsql {
+ select count(*) from "abc abc" WHERE a = X'00112233';
+ }
+ } {1}
+}
+
+# Check what happens when an in-memory database is vacuumed. The
+# [delete_file] command covers us in case the library was compiled
+# without in-memory database support.
+#
+forcedelete :memory:
+do_test vacuum-7.0 {
+ sqlite3 db2 :memory:
+ execsql {
+ CREATE TABLE t1(t);
+ VACUUM;
+ } db2
+} {}
+do_test vacuum-7.1 {
+ execsql {
+ CREATE TABLE t2(t);
+ CREATE TABLE t3(t);
+ DROP TABLE t2;
+ PRAGMA freelist_count;
+ }
+} {1}
+do_test vacuum-7.2 {
+ execsql {
+ VACUUM;
+ pragma integrity_check;
+ } db2
+} {ok}
+do_test vacuum-7.3 {
+ execsql { PRAGMA freelist_count; } db2
+} {0}
+ifcapable autovacuum {
+ do_test vacuum-7.4 {
+ execsql { PRAGMA auto_vacuum } db2
+ } {0}
+ do_test vacuum-7.5 {
+ execsql { PRAGMA auto_vacuum = 1} db2
+ execsql { PRAGMA auto_vacuum } db2
+ } {0}
+ do_test vacuum-7.6 {
+ execsql { PRAGMA auto_vacuum = 1} db2
+ execsql { VACUUM } db2
+ execsql { PRAGMA auto_vacuum } db2
+ } {1}
+}
+db2 close
+
+# Ticket #873. VACUUM a database that has ' in its name.
+#
+do_test vacuum-8.1 {
+ forcedelete a'z.db
+ forcedelete a'z.db-journal
+ sqlite3 db2 a'z.db
+ execsql {
+ CREATE TABLE t1(t);
+ VACUUM;
+ } db2
+} {}
+db2 close
+
+# Ticket #1095: Vacuum a table that uses AUTOINCREMENT
+#
+ifcapable {autoinc} {
+ do_test vacuum-9.1 {
+ execsql {
+ DROP TABLE 'abc abc';
+ CREATE TABLE autoinc(a INTEGER PRIMARY KEY AUTOINCREMENT, b);
+ INSERT INTO autoinc(b) VALUES('hi');
+ INSERT INTO autoinc(b) VALUES('there');
+ DELETE FROM autoinc;
+ }
+ set ::cksum [cksum]
+ expr {$::cksum!=""}
+ } {1}
+ do_test vacuum-9.2 {
+ execsql {
+ VACUUM;
+ }
+ cksum
+ } $::cksum
+ do_test vacuum-9.3 {
+ execsql {
+ INSERT INTO autoinc(b) VALUES('one');
+ INSERT INTO autoinc(b) VALUES('two');
+ }
+ set ::cksum [cksum]
+ expr {$::cksum!=""}
+ } {1}
+ do_test vacuum-9.4 {
+ execsql {
+ VACUUM;
+ }
+ cksum
+ } $::cksum
+}
+
+forcedelete {a'z.db}
+
+# Test that "PRAGMA count_changes" does not interfere with VACUUM or cause
+# it to return any rows to the user.
+#
+do_test vacuum-10.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t8(a, b);
+ INSERT INTO t8 VALUES('a', 'b');
+ INSERT INTO t8 VALUES('c', 'd');
+ PRAGMA count_changes = 1;
+ }
+} {}
+do_test vacuum-10.2 { execsql VACUUM } {}
+
+finish_test
diff --git a/test/vacuum2.test b/test/vacuum2.test
new file mode 100644
index 0000000..b3bfab3
--- /dev/null
+++ b/test/vacuum2.test
@@ -0,0 +1,231 @@
+# 2005 February 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the VACUUM statement.
+#
+# $Id: vacuum2.test,v 1.10 2009/02/18 20:31:18 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# If the VACUUM statement is disabled in the current build, skip all
+# the tests in this file.
+#
+ifcapable {!vacuum||!autoinc} {
+ finish_test
+ return
+}
+if $AUTOVACUUM {
+ finish_test
+ return
+}
+
+# Ticket #1121 - make sure vacuum works if all autoincrement tables
+# have been deleted.
+#
+do_test vacuum2-1.1 {
+ execsql {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
+ DROP TABLE t1;
+ VACUUM;
+ }
+} {}
+
+# Ticket #2518. Make sure vacuum increments the change counter
+# in the database header.
+#
+do_test vacuum2-2.1 {
+ execsql {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(y);
+ INSERT INTO t1 VALUES(1);
+ }
+ hexio_get_int [hexio_read test.db 24 4]
+} [expr {[hexio_get_int [hexio_read test.db 24 4]]+3}]
+do_test vacuum2-2.1 {
+ execsql {
+ VACUUM
+ }
+ hexio_get_int [hexio_read test.db 24 4]
+} [expr {[hexio_get_int [hexio_read test.db 24 4]]+1}]
+
+############################################################################
+# Verify that we can use the auto_vacuum pragma to request a new
+# autovacuum setting, do a VACUUM, and the new setting takes effect.
+# Make sure this happens correctly even if there are multiple open
+# connections to the same database file.
+#
+sqlite3 db2 test.db
+set pageSize [db eval {pragma page_size}]
+
+# We are currently not autovacuuming so the database should be 3 pages
+# in size. 1 page for each of sqlite_master, t1, and t2.
+#
+do_test vacuum2-3.1 {
+ execsql {
+ INSERT INTO t1 VALUES('hello');
+ INSERT INTO t2 VALUES('out there');
+ }
+ expr {[file size test.db]/$pageSize}
+} {3}
+set cksum [cksum]
+do_test vacuum2-3.2 {
+ cksum db2
+} $cksum
+
+# Convert the database to an autovacuumed database.
+ifcapable autovacuum {
+ do_test vacuum2-3.3 {
+ execsql {
+ PRAGMA auto_vacuum=FULL;
+ VACUUM;
+ }
+ expr {[file size test.db]/$pageSize}
+ } {4}
+}
+do_test vacuum2-3.4 {
+ cksum db2
+} $cksum
+do_test vacuum2-3.5 {
+ cksum
+} $cksum
+do_test vacuum2-3.6 {
+ execsql {PRAGMA integrity_check} db2
+} {ok}
+do_test vacuum2-3.7 {
+ execsql {PRAGMA integrity_check} db
+} {ok}
+
+# Convert the database back to a non-autovacuumed database.
+do_test vacuum2-3.13 {
+ execsql {
+ PRAGMA auto_vacuum=NONE;
+ VACUUM;
+ }
+ expr {[file size test.db]/$pageSize}
+} {3}
+do_test vacuum2-3.14 {
+ cksum db2
+} $cksum
+do_test vacuum2-3.15 {
+ cksum
+} $cksum
+do_test vacuum2-3.16 {
+ execsql {PRAGMA integrity_check} db2
+} {ok}
+do_test vacuum2-3.17 {
+ execsql {PRAGMA integrity_check} db
+} {ok}
+
+db2 close
+
+ifcapable autovacuum {
+ do_test vacuum2-4.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql {
+ pragma auto_vacuum=1;
+ create table t(a, b);
+ insert into t values(1, 2);
+ insert into t values(1, 2);
+ pragma auto_vacuum=0;
+ vacuum;
+ pragma auto_vacuum;
+ }
+ } {0}
+ do_test vacuum2-4.2 {
+ execsql {
+ pragma auto_vacuum=1;
+ vacuum;
+ pragma auto_vacuum;
+ }
+ } {1}
+ do_test vacuum2-4.3 {
+ execsql {
+ pragma integrity_check
+ }
+ } {ok}
+ do_test vacuum2-4.4 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ pragma auto_vacuum;
+ }
+ } {1}
+ do_test vacuum2-4.5 { # Ticket #3663
+ execsql {
+ pragma auto_vacuum=2;
+ vacuum;
+ pragma auto_vacuum;
+ }
+ } {2}
+ do_test vacuum2-4.6 {
+ execsql {
+ pragma integrity_check
+ }
+ } {ok}
+ do_test vacuum2-4.7 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ pragma auto_vacuum;
+ }
+ } {2}
+}
+
+
+#-------------------------------------------------------------------------
+# The following block of tests verify the behaviour of the library when
+# a database is VACUUMed when there are one or more unfinalized SQL
+# statements reading the same database using the same db handle.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test vacuum2-5.1 {
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 VALUES(1, randomblob(500));
+ INSERT INTO t1 SELECT a+1, randomblob(500) FROM t1; -- 2
+ INSERT INTO t1 SELECT a+2, randomblob(500) FROM t1; -- 4
+ INSERT INTO t1 SELECT a+4, randomblob(500) FROM t1; -- 8
+ INSERT INTO t1 SELECT a+8, randomblob(500) FROM t1; -- 16
+} {}
+
+do_test vacuum2-5.2 {
+ list [catch {
+ db eval {SELECT a, b FROM t1} { if {$a == 8} { execsql VACUUM } }
+ } msg] $msg
+} {1 {cannot VACUUM - SQL statements in progress}}
+
+do_test vacuum2-5.3 {
+ list [catch {
+ db eval {SELECT 1, 2, 3} { execsql VACUUM }
+ } msg] $msg
+} {1 {cannot VACUUM - SQL statements in progress}}
+
+do_test vacuum2-5.4 {
+ set res ""
+ set res2 ""
+ db eval {SELECT a, b FROM t1 WHERE a<=10} {
+ if {$a==6} { set res [catchsql VACUUM] }
+ lappend res2 $a
+ }
+ lappend res2 $res
+} {1 2 3 4 5 6 7 8 9 10 {1 {cannot VACUUM - SQL statements in progress}}}
+
+
+finish_test
diff --git a/test/vacuum3.test b/test/vacuum3.test
new file mode 100644
index 0000000..484a7d4
--- /dev/null
+++ b/test/vacuum3.test
@@ -0,0 +1,340 @@
+# 2007 March 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is changing the database page size using a
+# VACUUM statement.
+#
+# $Id: vacuum3.test,v 1.9 2008/08/26 21:07:27 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If the VACUUM statement is disabled in the current build, skip all
+# the tests in this file.
+#
+ifcapable !vacuum {
+ finish_test
+ return
+}
+
+
+#-------------------------------------------------------------------
+# Test cases vacuum3-1.* convert a simple 2-page database between a
+# few different page sizes.
+#
+do_test vacuum3-1.1 {
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ }
+} {}
+do_test vacuum3-1.2 {
+ execsql { PRAGMA page_size }
+} {1024}
+do_test vacuum3-1.3 {
+ file size test.db
+} {2048}
+
+set I 4
+foreach {request actual database} [list \
+ 2048 2048 4096 \
+ 1024 1024 2048 \
+ 1170 1024 2048 \
+ 256 1024 2048 \
+ 512 512 1024 \
+ 4096 4096 8192 \
+ 1024 1024 2048 \
+] {
+ do_test vacuum3-1.$I.1 {
+ execsql "
+ PRAGMA page_size = $request;
+ VACUUM;
+ "
+ execsql { PRAGMA page_size }
+ } $actual
+ do_test vacuum3-1.$I.2 {
+ file size test.db
+ } $database
+ do_test vacuum3-1.$I.3 {
+ execsql { SELECT * FROM t1 }
+ } {1 2 3}
+ integrity_check vacuum3-1.$I.4
+
+ incr I
+}
+
+#-------------------------------------------------------------------
+# Test cases vacuum3-2.* convert a simple 3-page database between a
+# few different page sizes.
+#
+do_test vacuum3-2.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ VACUUM;
+ ALTER TABLE t1 ADD COLUMN d;
+ UPDATE t1 SET d = randomblob(1000);
+ }
+ file size test.db
+} {3072}
+do_test vacuum3-2.2 {
+ execsql { PRAGMA page_size }
+} {1024}
+do_test vacuum3-2.3 {
+ set blob [db one {select d from t1}]
+ string length $blob
+} {1000}
+
+set I 4
+foreach {request actual database} [list \
+ 2048 2048 4096 \
+ 1024 1024 3072 \
+ 1170 1024 3072 \
+ 256 1024 3072 \
+ 512 512 2048 \
+ 4096 4096 8192 \
+ 1024 1024 3072 \
+] {
+ do_test vacuum3-2.$I.1 {
+ execsql "
+ PRAGMA page_size = $request;
+ VACUUM;
+ "
+ execsql { PRAGMA page_size }
+ } $actual
+ do_test vacuum3-2.$I.2 {
+ file size test.db
+ } $database
+ do_test vacuum3-2.$I.3 {
+ execsql { SELECT * FROM t1 }
+ } [list 1 2 3 $blob]
+ integrity_check vacuum3-1.$I.4
+
+ incr I
+}
+
+#-------------------------------------------------------------------
+# Test cases vacuum3-3.* converts a database large enough to include
+# the locking page (in a test environment) between few different
+# page sizes.
+#
+proc signature {} {
+ return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
+}
+do_test vacuum3-3.1 {
+ execsql "
+ PRAGMA page_size = 1024;
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY, b, c);
+ INSERT INTO abc VALUES(randomblob(100), randomblob(200), randomblob(1000));
+ INSERT INTO abc
+ SELECT randomblob(1000), randomblob(200), randomblob(100)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(100), randomblob(200), randomblob(1000)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(100), randomblob(200), randomblob(1000)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(100), randomblob(200), randomblob(1000)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(100), randomblob(200), randomblob(1000)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(25), randomblob(45), randomblob(9456)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(100), randomblob(200), randomblob(1000)
+ FROM abc;
+ INSERT INTO abc
+ SELECT randomblob(25), randomblob(45), randomblob(9456)
+ FROM abc;
+ COMMIT;
+ "
+} {}
+do_test vacuum3-3.2 {
+ execsql { PRAGMA page_size }
+} {1024}
+
+set ::sig [signature]
+
+set I 3
+foreach {request actual} [list \
+ 2048 2048 \
+ 1024 1024 \
+ 1170 1024 \
+ 256 1024 \
+ 512 512 \
+ 4096 4096 \
+ 1024 1024 \
+] {
+ do_test vacuum3-3.$I.1 {
+ execsql "
+ PRAGMA page_size = $request;
+ VACUUM;
+ "
+ execsql { PRAGMA page_size }
+ } $actual
+ do_test vacuum3-3.$I.2 {
+ signature
+ } $::sig
+ integrity_check vacuum3-3.$I.3
+
+ incr I
+}
+
+do_test vacuum3-4.1 {
+ db close
+ delete_file test.db
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size=1024;
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ INSERT INTO abc VALUES(4, 5, 6);
+ }
+ execsql { SELECT * FROM abc }
+} {1 2 3 4 5 6}
+do_test vacuum3-4.2 {
+ sqlite3 db2 test.db
+ execsql { SELECT * FROM abc } db2
+} {1 2 3 4 5 6}
+do_test vacuum3-4.3 {
+ execsql {
+ PRAGMA page_size = 2048;
+ VACUUM;
+ }
+ execsql { SELECT * FROM abc }
+} {1 2 3 4 5 6}
+do_test vacuum3-4.4 {
+ execsql { SELECT * FROM abc } db2
+} {1 2 3 4 5 6}
+do_test vacuum3-4.5 {
+ execsql {
+ PRAGMA page_size=16384;
+ VACUUM;
+ } db2
+ execsql { SELECT * FROM abc } db2
+} {1 2 3 4 5 6}
+do_test vacuum3-4.6 {
+ execsql {
+ PRAGMA page_size=1024;
+ VACUUM;
+ }
+ execsql { SELECT * FROM abc } db2
+} {1 2 3 4 5 6}
+
+# Unable to change the page-size of an in-memory using vacuum.
+db2 close
+sqlite3 db2 :memory:
+do_test vacuum3-5.1 {
+ db2 eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1234);
+ PRAGMA page_size=4096;
+ VACUUM;
+ SELECT * FROM t1;
+ }
+} {1234}
+do_test vacuum3-5.2 {
+ db2 eval {
+ PRAGMA page_size
+ }
+} {1024}
+
+set create_database_sql {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, randstr(50,50), randstr(50,50));
+ INSERT INTO t1 SELECT a+2, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+4, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+8, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+16, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+32, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+64, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+128, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 VALUES(1, randstr(600,600), randstr(600,600));
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ CREATE TABLE t3 AS SELECT * FROM t1;
+ COMMIT;
+ DROP TABLE t2;
+}
+
+do_ioerr_test vacuum3-ioerr-1 -cksum true -sqlprep "
+ PRAGMA page_size = 1024;
+ $create_database_sql
+" -sqlbody {
+ PRAGMA page_size = 4096;
+ VACUUM;
+}
+do_ioerr_test vacuum3-ioerr-2 -cksum true -sqlprep "
+ PRAGMA page_size = 2048;
+ $create_database_sql
+" -sqlbody {
+ PRAGMA page_size = 512;
+ VACUUM;
+}
+
+ifcapable autovacuum {
+ do_ioerr_test vacuum3-ioerr-3 -cksum true -sqlprep "
+ PRAGMA auto_vacuum = 0;
+ $create_database_sql
+ " -sqlbody {
+ PRAGMA auto_vacuum = 1;
+ VACUUM;
+ }
+ do_ioerr_test vacuum3-ioerr-4 -cksum true -sqlprep "
+ PRAGMA auto_vacuum = 1;
+ $create_database_sql
+ " -sqlbody {
+ PRAGMA auto_vacuum = 0;
+ VACUUM;
+ }
+}
+
+source $testdir/malloc_common.tcl
+if {$MEMDEBUG} {
+ do_malloc_test vacuum3-malloc-1 -sqlprep {
+ PRAGMA page_size = 2048;
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, randstr(50,50), randstr(50,50));
+ INSERT INTO t1 SELECT a+2, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+4, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+8, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+16, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+32, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+64, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+128, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 VALUES(1, randstr(600,600), randstr(600,600));
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ CREATE TABLE t3 AS SELECT * FROM t1;
+ COMMIT;
+ DROP TABLE t2;
+ } -sqlbody {
+ PRAGMA page_size = 512;
+ VACUUM;
+ }
+ do_malloc_test vacuum3-malloc-2 -sqlprep {
+ PRAGMA encoding=UTF16;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ CREATE TABLE t2(x,y,z);
+ INSERT INTO t2 SELECT * FROM t1;
+ } -sqlbody {
+ VACUUM;
+ }
+}
+
+finish_test
diff --git a/test/vacuum4.test b/test/vacuum4.test
new file mode 100644
index 0000000..326d037
--- /dev/null
+++ b/test/vacuum4.test
@@ -0,0 +1,67 @@
+# 2010 February 21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements a test of ticket [da1151f97df244a1]: An
+# assertion fault while VACUUMing an auto_vacuumed database with
+# large schema.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If the VACUUM statement is disabled in the current build, skip all
+# the tests in this file.
+#
+ifcapable !vacuum {
+ finish_test
+ return
+}
+
+do_test vacuum4-1.1 {
+ db eval {
+ PRAGMA auto_vacuum=FULL;
+ CREATE TABLE t1(
+ c000, c001, c002, c003, c004, c005, c006, c007, c008, c009,
+ c010, c011, c012, c013, c014, c015, c016, c017, c018, c019,
+ c020, c021, c022, c023, c024, c025, c026, c027, c028, c029,
+ c030, c031, c032, c033, c034, c035, c036, c037, c038, c039,
+ c040, c041, c042, c043, c044, c045, c046, c047, c048, c049,
+ c050, c051, c052, c053, c054, c055, c056, c057, c058, c059,
+ c060, c061, c062, c063, c064, c065, c066, c067, c068, c069,
+ c070, c071, c072, c073, c074, c075, c076, c077, c078, c079,
+ c080, c081, c082, c083, c084, c085, c086, c087, c088, c089,
+ c090, c091, c092, c093, c094, c095, c096, c097, c098, c099,
+ c100, c101, c102, c103, c104, c105, c106, c107, c108, c109,
+ c110, c111, c112, c113, c114, c115, c116, c117, c118, c119,
+ c120, c121, c122, c123, c124, c125, c126, c127, c128, c129,
+ c130, c131, c132, c133, c134, c135, c136, c137, c138, c139,
+ c140, c141, c142, c143, c144, c145, c146, c147, c148, c149
+ );
+ CREATE TABLE t2(
+ c000, c001, c002, c003, c004, c005, c006, c007, c008, c009,
+ c010, c011, c012, c013, c014, c015, c016, c017, c018, c019,
+ c020, c021, c022, c023, c024, c025, c026, c027, c028, c029,
+ c030, c031, c032, c033, c034, c035, c036, c037, c038, c039,
+ c040, c041, c042, c043, c044, c045, c046, c047, c048, c049,
+ c050, c051, c052, c053, c054, c055, c056, c057, c058, c059,
+ c060, c061, c062, c063, c064, c065, c066, c067, c068, c069,
+ c070, c071, c072, c073, c074, c075, c076, c077, c078, c079,
+ c080, c081, c082, c083, c084, c085, c086, c087, c088, c089,
+ c090, c091, c092, c093, c094, c095, c096, c097, c098, c099,
+ c100, c101, c102, c103, c104, c105, c106, c107, c108, c109,
+ c110, c111, c112, c113, c114, c115, c116, c117, c118, c119,
+ c120, c121, c122, c123, c124, c125, c126, c127, c128, c129,
+ c130, c131, c132, c133, c134, c135, c136, c137, c138, c139,
+ c140, c141, c142, c143, c144, c145, c146, c147, c148, c149
+ );
+ VACUUM;
+ }
+} {}
diff --git a/test/varint.test b/test/varint.test
new file mode 100644
index 0000000..974e88f
--- /dev/null
+++ b/test/varint.test
@@ -0,0 +1,32 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is variable-length integer encoding scheme.
+#
+# $Id: varint.test,v 1.1 2004/05/18 15:57:42 drh Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Test reading and writing of varints.
+#
+set cnt 0
+foreach start {0 100 10000 1000000 0x10000000} {
+ foreach mult {1 0x10 0x100 0x1000 0x10000 0x100000 0x1000000 0x10000000} {
+ foreach incr {1 500 10000 50000000} {
+ incr cnt
+ do_test varint-1.$cnt {
+ btree_varint_test $start $mult 5000 $incr
+ } {}
+ }
+ }
+}
diff --git a/test/veryquick.test b/test/veryquick.test
new file mode 100644
index 0000000..ca82b22
--- /dev/null
+++ b/test/veryquick.test
@@ -0,0 +1,19 @@
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file runs all the tests run by quick.test except for those related
+# to malloc or IO error simulation. With these tests omitted, the overall
+# run time is reduced by about 75%.
+#
+# $Id: veryquick.test,v 1.9 2008/07/12 14:52:21 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/permutations.test
+
+run_test_suite veryquick
+
+finish_test
+
diff --git a/test/view.test b/test/view.test
new file mode 100644
index 0000000..b444090
--- /dev/null
+++ b/test/view.test
@@ -0,0 +1,579 @@
+# 2002 February 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing VIEW statements.
+#
+# $Id: view.test,v 1.39 2008/12/14 14:45:21 danielk1977 Exp $
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Omit this entire file if the library is not configured with views enabled.
+ifcapable !view {
+ finish_test
+ return
+}
+
+do_test view-1.0 {
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(4,5,6);
+ INSERT INTO t1 VALUES(7,8,9);
+ SELECT * FROM t1;
+ }
+} {1 2 3 4 5 6 7 8 9}
+
+do_test view-1.1 {
+ execsql {
+ BEGIN;
+ CREATE VIEW IF NOT EXISTS v1 AS SELECT a,b FROM t1;
+ SELECT * FROM v1 ORDER BY a;
+ }
+} {1 2 4 5 7 8}
+do_test view-1.2 {
+ catchsql {
+ ROLLBACK;
+ SELECT * FROM v1 ORDER BY a;
+ }
+} {1 {no such table: v1}}
+do_test view-1.3 {
+ execsql {
+ CREATE VIEW v1 AS SELECT a,b FROM t1;
+ SELECT * FROM v1 ORDER BY a;
+ }
+} {1 2 4 5 7 8}
+do_test view-1.3.1 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM v1 ORDER BY a;
+ }
+} {1 2 4 5 7 8}
+do_test view-1.4 {
+ catchsql {
+ DROP VIEW IF EXISTS v1;
+ SELECT * FROM v1 ORDER BY a;
+ }
+} {1 {no such table: v1}}
+do_test view-1.5 {
+ execsql {
+ CREATE VIEW v1 AS SELECT a,b FROM t1;
+ SELECT * FROM v1 ORDER BY a;
+ }
+} {1 2 4 5 7 8}
+do_test view-1.6 {
+ catchsql {
+ DROP TABLE t1;
+ SELECT * FROM v1 ORDER BY a;
+ }
+} {1 {no such table: main.t1}}
+do_test view-1.7 {
+ execsql {
+ CREATE TABLE t1(x,a,b,c);
+ INSERT INTO t1 VALUES(1,2,3,4);
+ INSERT INTO t1 VALUES(4,5,6,7);
+ INSERT INTO t1 VALUES(7,8,9,10);
+ SELECT * FROM v1 ORDER BY a;
+ }
+} {2 3 5 6 8 9}
+do_test view-1.8 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM v1 ORDER BY a;
+ }
+} {2 3 5 6 8 9}
+
+do_test view-2.1 {
+ execsql {
+ CREATE VIEW v2 AS SELECT * FROM t1 WHERE a>5
+ }; # No semicolon
+ execsql2 {
+ SELECT * FROM v2;
+ }
+} {x 7 a 8 b 9 c 10}
+do_test view-2.2 {
+ catchsql {
+ INSERT INTO v2 VALUES(1,2,3,4);
+ }
+} {1 {cannot modify v2 because it is a view}}
+do_test view-2.3 {
+ catchsql {
+ UPDATE v2 SET a=10 WHERE a=5;
+ }
+} {1 {cannot modify v2 because it is a view}}
+do_test view-2.4 {
+ catchsql {
+ DELETE FROM v2;
+ }
+} {1 {cannot modify v2 because it is a view}}
+do_test view-2.5 {
+ execsql {
+ INSERT INTO t1 VALUES(11,12,13,14);
+ SELECT * FROM v2 ORDER BY x;
+ }
+} {7 8 9 10 11 12 13 14}
+do_test view-2.6 {
+ execsql {
+ SELECT x FROM v2 WHERE a>10
+ }
+} {11}
+
+# Test that column name of views are generated correctly.
+#
+do_test view-3.1 {
+ execsql2 {
+ SELECT * FROM v1 LIMIT 1
+ }
+} {a 2 b 3}
+do_test view-3.2 {
+ execsql2 {
+ SELECT * FROM v2 LIMIT 1
+ }
+} {x 7 a 8 b 9 c 10}
+do_test view-3.3.1 {
+ execsql2 {
+ DROP VIEW v1;
+ CREATE VIEW v1 AS SELECT a AS 'xyz', b+c AS 'pqr', c-b FROM t1;
+ SELECT * FROM v1 LIMIT 1
+ }
+} {xyz 2 pqr 7 c-b 1}
+do_test view-3.3.2 {
+ execsql2 {
+ CREATE VIEW v1b AS SELECT t1.a, b+c, t1.c FROM t1;
+ SELECT * FROM v1b LIMIT 1
+ }
+} {a 2 b+c 7 c 4}
+
+ifcapable compound {
+do_test view-3.4 {
+ execsql2 {
+ CREATE VIEW v3 AS SELECT a FROM t1 UNION SELECT b FROM t1 ORDER BY b;
+ SELECT * FROM v3 LIMIT 4;
+ }
+} {a 2 a 3 a 5 a 6}
+do_test view-3.5 {
+ execsql2 {
+ CREATE VIEW v4 AS
+ SELECT a, b FROM t1
+ UNION
+ SELECT b AS 'x', a AS 'y' FROM t1
+ ORDER BY x, y;
+ SELECT b FROM v4 ORDER BY b LIMIT 4;
+ }
+} {b 2 b 3 b 5 b 6}
+} ;# ifcapable compound
+
+
+do_test view-4.1 {
+ catchsql {
+ DROP VIEW t1;
+ }
+} {1 {use DROP TABLE to delete table t1}}
+do_test view-4.2 {
+ execsql {
+ SELECT 1 FROM t1 LIMIT 1;
+ }
+} 1
+do_test view-4.3 {
+ catchsql {
+ DROP TABLE v1;
+ }
+} {1 {use DROP VIEW to delete view v1}}
+do_test view-4.4 {
+ execsql {
+ SELECT 1 FROM v1 LIMIT 1;
+ }
+} {1}
+do_test view-4.5 {
+ catchsql {
+ CREATE INDEX i1v1 ON v1(xyz);
+ }
+} {1 {views may not be indexed}}
+
+do_test view-5.1 {
+ execsql {
+ CREATE TABLE t2(y,a);
+ INSERT INTO t2 VALUES(22,2);
+ INSERT INTO t2 VALUES(33,3);
+ INSERT INTO t2 VALUES(44,4);
+ INSERT INTO t2 VALUES(55,5);
+ SELECT * FROM t2;
+ }
+} {22 2 33 3 44 4 55 5}
+do_test view-5.2 {
+ execsql {
+ CREATE VIEW v5 AS
+ SELECT t1.x AS v, t2.y AS w FROM t1 JOIN t2 USING(a);
+ SELECT * FROM v5;
+ }
+} {1 22 4 55}
+
+# Verify that the view v5 gets flattened. see sqliteFlattenSubquery().
+# This will only work if EXPLAIN is enabled.
+# Ticket #272
+#
+ifcapable {explain} {
+do_test view-5.3 {
+ lsearch [execsql {
+ EXPLAIN SELECT * FROM v5;
+ }] OpenEphemeral
+} {-1}
+do_test view-5.4 {
+ execsql {
+ SELECT * FROM v5 AS a, t2 AS b WHERE a.w=b.y;
+ }
+} {1 22 22 2 4 55 55 5}
+do_test view-5.5 {
+ lsearch [execsql {
+ EXPLAIN SELECT * FROM v5 AS a, t2 AS b WHERE a.w=b.y;
+ }] OpenEphemeral
+} {-1}
+do_test view-5.6 {
+ execsql {
+ SELECT * FROM t2 AS b, v5 AS a WHERE a.w=b.y;
+ }
+} {22 2 1 22 55 5 4 55}
+do_test view-5.7 {
+ lsearch [execsql {
+ EXPLAIN SELECT * FROM t2 AS b, v5 AS a WHERE a.w=b.y;
+ }] OpenEphemeral
+} {-1}
+do_test view-5.8 {
+ execsql {
+ SELECT * FROM t1 AS a, v5 AS b, t2 AS c WHERE a.x=b.v AND b.w=c.y;
+ }
+} {1 2 3 4 1 22 22 2 4 5 6 7 4 55 55 5}
+do_test view-5.9 {
+ lsearch [execsql {
+ EXPLAIN SELECT * FROM t1 AS a, v5 AS b, t2 AS c WHERE a.x=b.v AND b.w=c.y;
+ }] OpenEphemeral
+} {-1}
+} ;# endif explain
+
+do_test view-6.1 {
+ execsql {
+ SELECT min(x), min(a), min(b), min(c), min(a+b+c) FROM v2;
+ }
+} {7 8 9 10 27}
+do_test view-6.2 {
+ execsql {
+ SELECT max(x), max(a), max(b), max(c), max(a+b+c) FROM v2;
+ }
+} {11 12 13 14 39}
+
+do_test view-7.1 {
+ execsql {
+ CREATE TABLE test1(id integer primary key, a);
+ CREATE TABLE test2(id integer, b);
+ INSERT INTO test1 VALUES(1,2);
+ INSERT INTO test2 VALUES(1,3);
+ CREATE VIEW test AS
+ SELECT test1.id, a, b
+ FROM test1 JOIN test2 ON test2.id=test1.id;
+ SELECT * FROM test;
+ }
+} {1 2 3}
+do_test view-7.2 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM test;
+ }
+} {1 2 3}
+do_test view-7.3 {
+ execsql {
+ DROP VIEW test;
+ CREATE VIEW test AS
+ SELECT test1.id, a, b
+ FROM test1 JOIN test2 USING(id);
+ SELECT * FROM test;
+ }
+} {1 2 3}
+do_test view-7.4 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM test;
+ }
+} {1 2 3}
+do_test view-7.5 {
+ execsql {
+ DROP VIEW test;
+ CREATE VIEW test AS
+ SELECT test1.id, a, b
+ FROM test1 NATURAL JOIN test2;
+ SELECT * FROM test;
+ }
+} {1 2 3}
+do_test view-7.6 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM test;
+ }
+} {1 2 3}
+
+do_test view-8.1 {
+ execsql {
+ CREATE VIEW v6 AS SELECT pqr, xyz FROM v1;
+ SELECT * FROM v6 ORDER BY xyz;
+ }
+} {7 2 13 5 19 8 27 12}
+do_test view-8.2 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM v6 ORDER BY xyz;
+ }
+} {7 2 13 5 19 8 27 12}
+do_test view-8.3 {
+ execsql {
+ CREATE VIEW v7 AS SELECT pqr+xyz AS a FROM v6;
+ SELECT * FROM v7 ORDER BY a;
+ }
+} {9 18 27 39}
+
+ifcapable subquery {
+ do_test view-8.4 {
+ execsql {
+ CREATE VIEW v8 AS SELECT max(cnt) AS mx FROM
+ (SELECT a%2 AS eo, count(*) AS cnt FROM t1 GROUP BY eo);
+ SELECT * FROM v8;
+ }
+ } 3
+ do_test view-8.5 {
+ execsql {
+ SELECT mx+10, mx*2 FROM v8;
+ }
+ } {13 6}
+ do_test view-8.6 {
+ execsql {
+ SELECT mx+10, pqr FROM v6, v8 WHERE xyz=2;
+ }
+ } {13 7}
+ do_test view-8.7 {
+ execsql {
+ SELECT mx+10, pqr FROM v6, v8 WHERE xyz>2;
+ }
+ } {13 13 13 19 13 27}
+} ;# ifcapable subquery
+
+# Tests for a bug found by Michiel de Wit involving ORDER BY in a VIEW.
+#
+do_test view-9.1 {
+ execsql {
+ INSERT INTO t2 SELECT * FROM t2 WHERE a<5;
+ INSERT INTO t2 SELECT * FROM t2 WHERE a<4;
+ INSERT INTO t2 SELECT * FROM t2 WHERE a<3;
+ SELECT DISTINCT count(*) FROM t2 GROUP BY a ORDER BY 1;
+ }
+} {1 2 4 8}
+do_test view-9.2 {
+ execsql {
+ SELECT DISTINCT count(*) FROM t2 GROUP BY a ORDER BY 1 LIMIT 3;
+ }
+} {1 2 4}
+do_test view-9.3 {
+ execsql {
+ CREATE VIEW v9 AS
+ SELECT DISTINCT count(*) FROM t2 GROUP BY a ORDER BY 1 LIMIT 3;
+ SELECT * FROM v9;
+ }
+} {1 2 4}
+do_test view-9.4 {
+ execsql {
+ SELECT * FROM v9 ORDER BY 1 DESC;
+ }
+} {4 2 1}
+do_test view-9.5 {
+ execsql {
+ CREATE VIEW v10 AS
+ SELECT DISTINCT a, count(*) FROM t2 GROUP BY a ORDER BY 2 LIMIT 3;
+ SELECT * FROM v10;
+ }
+} {5 1 4 2 3 4}
+do_test view-9.6 {
+ execsql {
+ SELECT * FROM v10 ORDER BY 1;
+ }
+} {3 4 4 2 5 1}
+
+# Tables with columns having peculiar quoted names used in views
+# Ticket #756.
+#
+do_test view-10.1 {
+ execsql {
+ CREATE TABLE t3("9" integer, [4] text);
+ INSERT INTO t3 VALUES(1,2);
+ CREATE VIEW v_t3_a AS SELECT a.[9] FROM t3 AS a;
+ CREATE VIEW v_t3_b AS SELECT "4" FROM t3;
+ SELECT * FROM v_t3_a;
+ }
+} {1}
+do_test view-10.2 {
+ execsql {
+ SELECT * FROM v_t3_b;
+ }
+} {2}
+
+do_test view-11.1 {
+ execsql {
+ CREATE TABLE t4(a COLLATE NOCASE);
+ INSERT INTO t4 VALUES('This');
+ INSERT INTO t4 VALUES('this');
+ INSERT INTO t4 VALUES('THIS');
+ SELECT * FROM t4 WHERE a = 'THIS';
+ }
+} {This this THIS}
+ifcapable subquery {
+ do_test view-11.2 {
+ execsql {
+ SELECT * FROM (SELECT * FROM t4) WHERE a = 'THIS';
+ }
+ } {This this THIS}
+}
+do_test view-11.3 {
+ execsql {
+ CREATE VIEW v11 AS SELECT * FROM t4;
+ SELECT * FROM v11 WHERE a = 'THIS';
+ }
+} {This this THIS}
+
+# Ticket #1270: Do not allow parameters in view definitions.
+#
+do_test view-12.1 {
+ catchsql {
+ CREATE VIEW v12 AS SELECT a FROM t1 WHERE b=?
+ }
+} {1 {parameters are not allowed in views}}
+
+ifcapable attach {
+ do_test view-13.1 {
+ forcedelete test2.db
+ catchsql {
+ ATTACH 'test2.db' AS two;
+ CREATE TABLE two.t2(x,y);
+ CREATE VIEW v13 AS SELECT y FROM two.t2;
+ }
+ } {1 {view v13 cannot reference objects in database two}}
+}
+
+# Ticket #1658
+#
+do_test view-14.1 {
+ catchsql {
+ CREATE TEMP VIEW t1 AS SELECT a,b FROM t1;
+ SELECT * FROM temp.t1;
+ }
+} {1 {view t1 is circularly defined}}
+
+# Tickets #1688, #1709
+#
+do_test view-15.1 {
+ execsql2 {
+ CREATE VIEW v15 AS SELECT a AS x, b AS y FROM t1;
+ SELECT * FROM v15 LIMIT 1;
+ }
+} {x 2 y 3}
+do_test view-15.2 {
+ execsql2 {
+ SELECT x, y FROM v15 LIMIT 1
+ }
+} {x 2 y 3}
+
+do_test view-16.1 {
+ catchsql {
+ CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1;
+ }
+} {0 {}}
+do_test view-16.2 {
+ execsql {
+ SELECT sql FROM sqlite_master WHERE name='v1'
+ }
+} {{CREATE VIEW v1 AS SELECT a AS 'xyz', b+c AS 'pqr', c-b FROM t1}}
+do_test view-16.3 {
+ catchsql {
+ DROP VIEW IF EXISTS nosuchview
+ }
+} {0 {}}
+
+# correct error message when attempting to drop a view that does not
+# exist.
+#
+do_test view-17.1 {
+ catchsql {
+ DROP VIEW nosuchview
+ }
+} {1 {no such view: nosuchview}}
+do_test view-17.2 {
+ catchsql {
+ DROP VIEW main.nosuchview
+ }
+} {1 {no such view: main.nosuchview}}
+
+do_test view-18.1 {
+ execsql {
+ DROP VIEW t1;
+ DROP TABLE t1;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+
+ CREATE VIEW vv1 AS SELECT * FROM t1;
+ CREATE VIEW vv2 AS SELECT * FROM vv1;
+ CREATE VIEW vv3 AS SELECT * FROM vv2;
+ CREATE VIEW vv4 AS SELECT * FROM vv3;
+ CREATE VIEW vv5 AS SELECT * FROM vv4;
+
+ SELECT * FROM vv5;
+ }
+} {1 2 3 4 5 6}
+
+# Ticket #3308
+# Make sure "rowid" columns in a view are named correctly.
+#
+do_test view-19.1 {
+ execsql {
+ CREATE VIEW v3308a AS SELECT rowid, * FROM t1;
+ }
+ execsql2 {
+ SELECT * FROM v3308a
+ }
+} {rowid 1 a 1 b 2 c 3 rowid 2 a 4 b 5 c 6}
+do_test view-19.2 {
+ execsql {
+ CREATE VIEW v3308b AS SELECT t1.rowid, t1.a, t1.b+t1.c FROM t1;
+ }
+ execsql2 {
+ SELECT * FROM v3308b
+ }
+} {rowid 1 a 1 t1.b+t1.c 5 rowid 2 a 4 t1.b+t1.c 11}
+do_test view-19.3 {
+ execsql {
+ CREATE VIEW v3308c AS SELECT t1.oid, A, t1.b+t1.c AS x FROM t1;
+ }
+ execsql2 {
+ SELECT * FROM v3308c
+ }
+} {rowid 1 a 1 x 5 rowid 2 a 4 x 11}
+
+# Ticket #3539 had this crashing (see commit [5940]).
+do_test view-20.1 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP VIEW IF EXISTS v1;
+ CREATE TABLE t1(c1);
+ CREATE VIEW v1 AS SELECT c1 FROM (SELECT t1.c1 FROM t1);
+ }
+} {}
+
+finish_test
diff --git a/test/vtab1.test b/test/vtab1.test
new file mode 100644
index 0000000..16f1b43
--- /dev/null
+++ b/test/vtab1.test
@@ -0,0 +1,1197 @@
+# 2006 June 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is creating and dropping virtual tables.
+#
+# $Id: vtab1.test,v 1.57 2008/08/01 17:51:47 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab||!schema_pragmas {
+ finish_test
+ return
+}
+
+#----------------------------------------------------------------------
+# Organization of tests in this file:
+#
+# vtab1-1.*: Error conditions and other issues surrounding creation/connection
+# of a virtual module.
+# vtab1-2.*: Test sqlite3_declare_vtab() and the xConnect/xDisconnect methods.
+# vtab1-3.*: Table scans and WHERE clauses.
+# vtab1-4.*: Table scans and ORDER BY clauses.
+# vtab1-5.*: Test queries that include joins. This brings the
+# sqlite3_index_info.estimatedCost variable into play.
+# vtab1-6.*: Test UPDATE/INSERT/DELETE on vtables.
+# vtab1-7.*: Test sqlite3_last_insert_rowid().
+#
+# This file uses the "echo" module (see src/test8.c). Refer to comments
+# in that file for the special behaviour of the Tcl $echo_module variable.
+#
+# TODO:
+# * How to test the sqlite3_index_constraint_usage.omit field?
+# * vtab1-5.*
+#
+# vtab1-14.*: Test 'IN' constraints - i.e. "SELECT * FROM t1 WHERE id IN(...)"
+#
+
+
+#----------------------------------------------------------------------
+# Test cases vtab1.1.*
+#
+
+# We cannot create a virtual table if the module has not been registered.
+#
+do_test vtab1-1.1 {
+ explain {
+ CREATE VIRTUAL TABLE t1 USING echo;
+ }
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING echo;
+ }
+} {1 {no such module: echo}}
+do_test vtab1-1.2 {
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY 1
+ }
+} {}
+
+# Register the module
+register_echo_module [sqlite3_connection_pointer db]
+
+# Once a module has been registered, virtual tables using that module
+# may be created. However if a module xCreate() fails to call
+# sqlite3_declare_vtab() an error will be raised and the table not created.
+#
+# The "echo" module does not invoke sqlite3_declare_vtab() if it is
+# passed zero arguments.
+#
+do_test vtab1-1.3 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING echo;
+ }
+} {1 {vtable constructor did not declare schema: t1}}
+do_test vtab1-1.4 {
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY 1
+ }
+} {}
+
+# The "echo" module xCreate method returns an error and does not create
+# the virtual table if it is passed an argument that does not correspond
+# to an existing real table in the same database.
+#
+do_test vtab1-1.5 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING echo(no_such_table);
+ }
+} {1 {vtable constructor failed: t1}}
+do_test vtab1-1.6 {
+ execsql {
+ SELECT name FROM sqlite_master ORDER BY 1
+ }
+} {}
+
+# Ticket #2156. Using the sqlite3_prepare_v2() API, make sure that
+# a CREATE VIRTUAL TABLE statement can be used multiple times.
+#
+do_test vtab1-1.2152.1 {
+ set DB [sqlite3_connection_pointer db]
+ set sql {CREATE VIRTUAL TABLE t2152a USING echo(t2152b)}
+ set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]
+ sqlite3_step $STMT
+} SQLITE_ERROR
+do_test vtab-1.2152.2 {
+ sqlite3_reset $STMT
+ sqlite3_step $STMT
+} SQLITE_ERROR
+do_test vtab-1.2152.3 {
+ sqlite3_reset $STMT
+ db eval {CREATE TABLE t2152b(x,y)}
+ sqlite3_step $STMT
+} SQLITE_DONE
+do_test vtab-1.2152.4 {
+ sqlite3_finalize $STMT
+ db eval {DROP TABLE t2152a; DROP TABLE t2152b}
+} {}
+
+# Test to make sure nothing goes wrong and no memory is leaked if we
+# select an illegal table-name (i.e a reserved name or the name of a
+# table that already exists).
+#
+do_test vtab1-1.7 {
+ catchsql {
+ CREATE VIRTUAL TABLE sqlite_master USING echo;
+ }
+} {1 {object name reserved for internal use: sqlite_master}}
+do_test vtab1-1.8 {
+ catchsql {
+ CREATE TABLE treal(a, b, c);
+ CREATE VIRTUAL TABLE treal USING echo(treal);
+ }
+} {1 {table treal already exists}}
+do_test vtab1-1.9 {
+ execsql {
+ DROP TABLE treal;
+ SELECT name FROM sqlite_master ORDER BY 1
+ }
+} {}
+
+do_test vtab1-1.10 {
+ execsql {
+ CREATE TABLE treal(a, b, c);
+ CREATE VIRTUAL TABLE techo USING echo(treal);
+ }
+ db close
+ sqlite3 db test.db
+ catchsql {
+ SELECT * FROM techo;
+ }
+} {1 {no such module: echo}}
+do_test vtab1-1.11 {
+ catchsql {
+ INSERT INTO techo VALUES(1, 2, 3);
+ }
+} {1 {no such module: echo}}
+do_test vtab1-1.12 {
+ catchsql {
+ UPDATE techo SET a = 10;
+ }
+} {1 {no such module: echo}}
+do_test vtab1-1.13 {
+ catchsql {
+ DELETE FROM techo;
+ }
+} {1 {no such module: echo}}
+do_test vtab1-1.14 {
+ catchsql {
+ PRAGMA table_info(techo)
+ }
+} {1 {no such module: echo}}
+do_test vtab1-1.15 {
+ catchsql {
+ DROP TABLE techo;
+ }
+} {1 {no such module: echo}}
+
+register_echo_module [sqlite3_connection_pointer db]
+register_echo_module [sqlite3_connection_pointer db]
+
+# Test an error message returned from a v-table constructor.
+#
+do_test vtab1-1.16 {
+ execsql {
+ DROP TABLE techo;
+ CREATE TABLE logmsg(log);
+ }
+ catchsql {
+ CREATE VIRTUAL TABLE techo USING echo(treal, logmsg);
+ }
+} {1 {table 'logmsg' already exists}}
+
+do_test vtab1-1.17 {
+ execsql {
+ DROP TABLE treal;
+ DROP TABLE logmsg;
+ SELECT sql FROM sqlite_master;
+ }
+} {}
+
+#----------------------------------------------------------------------
+# Test cases vtab1.2.*
+#
+# At this point, the database is completely empty. The echo module
+# has already been registered.
+
+# If a single argument is passed to the echo module during table
+# creation, it is assumed to be the name of a table in the same
+# database. The echo module attempts to set the schema of the
+# new virtual table to be the same as the existing database table.
+#
+do_test vtab1-2.1 {
+ execsql {
+ CREATE TABLE template(a, b, c);
+ }
+ execsql { PRAGMA table_info(template); }
+} [list \
+ 0 a {} 0 {} 0 \
+ 1 b {} 0 {} 0 \
+ 2 c {} 0 {} 0 \
+]
+do_test vtab1-2.2 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING echo(template);
+ }
+ execsql { PRAGMA table_info(t1); }
+} [list \
+ 0 a {} 0 {} 0 \
+ 1 b {} 0 {} 0 \
+ 2 c {} 0 {} 0 \
+]
+
+# Test that the database can be unloaded. This should invoke the xDisconnect()
+# callback for the successfully create virtual table (t1).
+#
+do_test vtab1-2.3 {
+ set echo_module [list]
+ db close
+ set echo_module
+} [list xDisconnect]
+
+# Re-open the database. This should not cause any virtual methods to
+# be called. The invocation of xConnect() is delayed until the virtual
+# table schema is first required by the compiler.
+#
+do_test vtab1-2.4 {
+ set echo_module [list]
+ sqlite3 db test.db
+ db cache size 0
+ set echo_module
+} {}
+
+# Try to query the virtual table schema. This should fail, as the
+# echo module has not been registered with this database connection.
+#
+do_test vtab1.2.6 {
+ catchsql { PRAGMA table_info(t1); }
+} {1 {no such module: echo}}
+
+# Register the module
+register_echo_module [sqlite3_connection_pointer db]
+
+# Try to query the virtual table schema again. This time it should
+# invoke the xConnect method and succeed.
+#
+do_test vtab1.2.7 {
+ execsql { PRAGMA table_info(t1); }
+} [list \
+ 0 a {} 0 {} 0 \
+ 1 b {} 0 {} 0 \
+ 2 c {} 0 {} 0 \
+]
+do_test vtab1.2.8 {
+ set echo_module
+} {xConnect echo main t1 template}
+
+# Drop table t1. This should cause the xDestroy (but not xDisconnect) method
+# to be invoked.
+do_test vtab1-2.5 {
+ set echo_module ""
+ execsql {
+ DROP TABLE t1;
+ }
+ set echo_module
+} {xDestroy}
+
+do_test vtab1-2.6 {
+ execsql {
+ PRAGMA table_info(t1);
+ }
+} {}
+do_test vtab1-2.7 {
+ execsql {
+ SELECT sql FROM sqlite_master;
+ }
+} [list {CREATE TABLE template(a, b, c)}]
+# Clean up other test artifacts:
+do_test vtab1-2.8 {
+ execsql {
+ DROP TABLE template;
+ SELECT sql FROM sqlite_master;
+ }
+} [list]
+
+#----------------------------------------------------------------------
+# Test case vtab1-3 test table scans and the echo module's
+# xBestIndex/xFilter handling of WHERE conditions.
+
+do_test vtab1-3.1 {
+ set echo_module ""
+ execsql {
+ CREATE TABLE treal(a INTEGER, b INTEGER, c);
+ CREATE INDEX treal_idx ON treal(b);
+ CREATE VIRTUAL TABLE t1 USING echo(treal);
+ }
+ set echo_module
+} [list xCreate echo main t1 treal \
+ xSync echo(treal) \
+ xCommit echo(treal) \
+]
+
+# Test that a SELECT on t1 doesn't crash. No rows are returned
+# because the underlying real table is currently empty.
+#
+do_test vtab1-3.2 {
+ execsql {
+ SELECT a, b, c FROM t1;
+ }
+} {}
+
+# Put some data into the table treal. Then try a few simple SELECT
+# statements on t1.
+#
+do_test vtab1-3.3 {
+ execsql {
+ INSERT INTO treal VALUES(1, 2, 3);
+ INSERT INTO treal VALUES(4, 5, 6);
+ SELECT * FROM t1;
+ }
+} {1 2 3 4 5 6}
+do_test vtab1-3.4 {
+ execsql {
+ SELECT a FROM t1;
+ }
+} {1 4}
+do_test vtab1-3.5 {
+ execsql {
+ SELECT rowid FROM t1;
+ }
+} {1 2}
+do_test vtab1-3.6 {
+ set echo_module ""
+ execsql {
+ SELECT * FROM t1;
+ }
+} {1 2 3 4 5 6}
+do_test vtab1-3.7 {
+ execsql {
+ SELECT rowid, * FROM t1;
+ }
+} {1 1 2 3 2 4 5 6}
+do_test vtab1-3.8 {
+ execsql {
+ SELECT a AS d, b AS e, c AS f FROM t1;
+ }
+} {1 2 3 4 5 6}
+
+# Execute some SELECT statements with WHERE clauses on the t1 table.
+# Then check the echo_module variable (written to by the module methods
+# in test8.c) to make sure the xBestIndex() and xFilter() methods were
+# called correctly.
+#
+do_test vtab1-3.8 {
+ set echo_module ""
+ execsql {
+ SELECT * FROM t1;
+ }
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal'} \
+ xFilter {SELECT rowid, * FROM 'treal'} ]
+do_test vtab1-3.9 {
+ set echo_module ""
+ execsql {
+ SELECT * FROM t1 WHERE b = 5;
+ }
+} {4 5 6}
+do_test vtab1-3.10 {
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal' WHERE b = ?} \
+ xFilter {SELECT rowid, * FROM 'treal' WHERE b = ?} 5 ]
+do_test vtab1-3.10 {
+ set echo_module ""
+ execsql {
+ SELECT * FROM t1 WHERE b >= 5 AND b <= 10;
+ }
+} {4 5 6}
+do_test vtab1-3.11 {
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal' WHERE b >= ? AND b <= ?} \
+ xFilter {SELECT rowid, * FROM 'treal' WHERE b >= ? AND b <= ?} 5 10 ]
+do_test vtab1-3.12 {
+ set echo_module ""
+ execsql {
+ SELECT * FROM t1 WHERE b BETWEEN 2 AND 10;
+ }
+} {1 2 3 4 5 6}
+do_test vtab1-3.13 {
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal' WHERE b >= ? AND b <= ?} \
+ xFilter {SELECT rowid, * FROM 'treal' WHERE b >= ? AND b <= ?} 2 10 ]
+
+# Add a function for the MATCH operator. Everything always matches!
+#proc test_match {lhs rhs} {
+# lappend ::echo_module MATCH $lhs $rhs
+# return 1
+#}
+#db function match test_match
+
+set echo_module ""
+do_test vtab1-3.12 {
+ set echo_module ""
+ catchsql {
+ SELECT * FROM t1 WHERE a MATCH 'string';
+ }
+} {1 {unable to use function MATCH in the requested context}}
+do_test vtab1-3.13 {
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal'} \
+ xFilter {SELECT rowid, * FROM 'treal'}]
+ifcapable subquery {
+# The echo module uses a subquery internally to implement the MATCH operator.
+do_test vtab1-3.14 {
+ set echo_module ""
+ execsql {
+ SELECT * FROM t1 WHERE b MATCH 'string';
+ }
+} {}
+do_test vtab1-3.15 {
+ set echo_module
+} [list xBestIndex \
+ {SELECT rowid, * FROM 'treal' WHERE b LIKE (SELECT '%'||?||'%')} \
+ xFilter \
+ {SELECT rowid, * FROM 'treal' WHERE b LIKE (SELECT '%'||?||'%')} \
+ string ]
+}; #ifcapable subquery
+
+#----------------------------------------------------------------------
+# Test case vtab1-3 test table scans and the echo module's
+# xBestIndex/xFilter handling of ORDER BY clauses.
+
+# This procedure executes the SQL. Then it checks to see if the OP_Sort
+# opcode was executed. If an OP_Sort did occur, then "sort" is appended
+# to the result. If no OP_Sort happened, then "nosort" is appended.
+#
+# This procedure is used to check to make sure sorting is or is not
+# occurring as expected.
+#
+proc cksort {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ if {$::sqlite_sort_count} {set x sort} {set x nosort}
+ lappend data $x
+ return $data
+}
+
+do_test vtab1-4.1 {
+ set echo_module ""
+ cksort {
+ SELECT b FROM t1 ORDER BY b;
+ }
+} {2 5 nosort}
+do_test vtab1-4.2 {
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal' ORDER BY b ASC} \
+ xFilter {SELECT rowid, * FROM 'treal' ORDER BY b ASC} ]
+do_test vtab1-4.3 {
+ set echo_module ""
+ cksort {
+ SELECT b FROM t1 ORDER BY b DESC;
+ }
+} {5 2 nosort}
+do_test vtab1-4.4 {
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal' ORDER BY b DESC} \
+ xFilter {SELECT rowid, * FROM 'treal' ORDER BY b DESC} ]
+do_test vtab1-4.3 {
+ set echo_module ""
+ cksort {
+ SELECT b FROM t1 ORDER BY b||'';
+ }
+} {2 5 sort}
+do_test vtab1-4.4 {
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal'} \
+ xFilter {SELECT rowid, * FROM 'treal'} ]
+
+execsql {
+ DROP TABLE t1;
+ DROP TABLE treal;
+}
+
+#----------------------------------------------------------------------
+# Test cases vtab1-5 test SELECT queries that include joins on virtual
+# tables.
+
+proc filter {log} {
+ set out [list]
+ for {set ii 0} {$ii < [llength $log]} {incr ii} {
+ if {[lindex $log $ii] eq "xFilter"} {
+ lappend out xFilter
+ lappend out [lindex $log [expr $ii+1]]
+ }
+ }
+ return $out
+}
+
+do_test vtab1-5-1 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e, f);
+ INSERT INTO t1 VALUES(1, 'red', 'green');
+ INSERT INTO t1 VALUES(2, 'blue', 'black');
+ INSERT INTO t2 VALUES(1, 'spades', 'clubs');
+ INSERT INTO t2 VALUES(2, 'hearts', 'diamonds');
+ CREATE VIRTUAL TABLE et1 USING echo(t1);
+ CREATE VIRTUAL TABLE et2 USING echo(t2);
+ }
+} {}
+
+do_test vtab1-5-2 {
+ set echo_module ""
+ execsql {
+ SELECT * FROM et1, et2;
+ }
+} [list \
+ 1 red green 1 spades clubs \
+ 1 red green 2 hearts diamonds \
+ 2 blue black 1 spades clubs \
+ 2 blue black 2 hearts diamonds \
+]
+do_test vtab1-5-3 {
+ filter $echo_module
+} [list \
+ xFilter {SELECT rowid, * FROM 't1'} \
+ xFilter {SELECT rowid, * FROM 't2'} \
+ xFilter {SELECT rowid, * FROM 't2'} \
+]
+do_test vtab1-5-4 {
+ set echo_module ""
+ execsql {
+ SELECT * FROM et1, et2 WHERE et2.d = 2;
+ }
+} [list \
+ 1 red green 2 hearts diamonds \
+ 2 blue black 2 hearts diamonds \
+]
+do_test vtab1-5-5 {
+ filter $echo_module
+} [list \
+ xFilter {SELECT rowid, * FROM 't1'} \
+ xFilter {SELECT rowid, * FROM 't2'} \
+ xFilter {SELECT rowid, * FROM 't2'} \
+]
+do_test vtab1-5-6 {
+ execsql {
+ CREATE INDEX i1 ON t2(d);
+ }
+
+ db close
+ sqlite3 db test.db
+ register_echo_module [sqlite3_connection_pointer db]
+
+ set ::echo_module ""
+ execsql {
+ SELECT * FROM et1, et2 WHERE et2.d = 2;
+ }
+} [list \
+ 1 red green 2 hearts diamonds \
+ 2 blue black 2 hearts diamonds \
+]
+do_test vtab1-5-7 {
+ filter $::echo_module
+} [list \
+ xFilter {SELECT rowid, * FROM 't2' WHERE d = ?} \
+ xFilter {SELECT rowid, * FROM 't1'} \
+]
+
+execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ DROP TABLE et1;
+ DROP TABLE et2;
+}
+
+#----------------------------------------------------------------------
+# Test cases vtab1-6 test INSERT, UPDATE and DELETE operations
+# on virtual tables.
+do_test vtab1-6-1 {
+ execsql { SELECT sql FROM sqlite_master }
+} {}
+do_test vtab1-6-2 {
+ execsql {
+ CREATE TABLE treal(a PRIMARY KEY, b, c);
+ CREATE VIRTUAL TABLE techo USING echo(treal);
+ SELECT name FROM sqlite_master WHERE type = 'table';
+ }
+} {treal techo}
+do_test vtab1-6-3.1.1 {
+ execsql {
+ PRAGMA count_changes=ON;
+ INSERT INTO techo VALUES(1, 2, 3);
+ }
+} {1}
+do_test vtab1-6-3.1.2 {
+ db changes
+} {1}
+do_test vtab1-6-3.2 {
+ execsql {
+ SELECT * FROM techo;
+ }
+} {1 2 3}
+do_test vtab1-6-4.1 {
+ execsql {
+ UPDATE techo SET a = 5;
+ }
+ db changes
+} {1}
+do_test vtab1-6-4.2 {
+ execsql {
+ SELECT * FROM techo;
+ }
+} {5 2 3}
+do_test vtab1-6-4.3 {
+ execsql {
+ UPDATE techo SET a=6 WHERE a<0;
+ }
+ db changes
+} {0}
+do_test vtab1-6-4.4 {
+ execsql {
+ SELECT * FROM techo;
+ }
+} {5 2 3}
+
+do_test vtab1-6-5.1 {
+ execsql {
+ UPDATE techo set a = a||b||c;
+ }
+ db changes
+} {1}
+do_test vtab1-6-5.2 {
+ execsql {
+ SELECT * FROM techo;
+ }
+} {523 2 3}
+
+do_test vtab1-6-6.1 {
+ execsql {
+ UPDATE techo set rowid = 10;
+ }
+ db changes
+} {1}
+do_test vtab1-6-6.2 {
+ execsql {
+ SELECT rowid FROM techo;
+ }
+} {10}
+
+do_test vtab1-6-7.1.1 {
+ execsql {
+ INSERT INTO techo VALUES(11,12,13);
+ }
+} {1}
+do_test vtab1-6-7.1.2 {
+ db changes
+} {1}
+do_test vtab1-6-7.2 {
+ execsql {
+ SELECT * FROM techo ORDER BY a;
+ }
+} {11 12 13 523 2 3}
+do_test vtab1-6-7.3 {
+ execsql {
+ UPDATE techo SET b=b+1000
+ }
+ db changes
+} {2}
+do_test vtab1-6-7.4 {
+ execsql {
+ SELECT * FROM techo ORDER BY a;
+ }
+} {11 1012 13 523 1002 3}
+
+
+do_test vtab1-6-8.1 {
+ execsql {
+ DELETE FROM techo WHERE a=5;
+ }
+ db changes
+} {0}
+do_test vtab1-6-8.2 {
+ execsql {
+ SELECT * FROM techo ORDER BY a;
+ }
+} {11 1012 13 523 1002 3}
+do_test vtab1-6-8.3 {
+ execsql {
+ DELETE FROM techo;
+ }
+ db changes
+} {2}
+do_test vtab1-6-8.4 {
+ execsql {
+ SELECT * FROM techo ORDER BY a;
+ }
+} {}
+execsql {PRAGMA count_changes=OFF}
+
+forcedelete test2.db
+forcedelete test2.db-journal
+sqlite3 db2 test2.db
+execsql {
+ CREATE TABLE techo(a PRIMARY KEY, b, c);
+} db2
+proc check_echo_table {tn} {
+ set ::data1 [execsql {SELECT rowid, * FROM techo}]
+ set ::data2 [execsql {SELECT rowid, * FROM techo} db2]
+ do_test $tn {
+ string equal $::data1 $::data2
+ } 1
+}
+set tn 0
+foreach stmt [list \
+ {INSERT INTO techo VALUES('abc', 'def', 'ghi')} \
+ {INSERT INTO techo SELECT a||'.'||rowid, b, c FROM techo} \
+ {INSERT INTO techo SELECT a||'x'||rowid, b, c FROM techo} \
+ {INSERT INTO techo SELECT a||'y'||rowid, b, c FROM techo} \
+ {DELETE FROM techo WHERE (oid % 3) = 0} \
+ {UPDATE techo set rowid = 100 WHERE rowid = 1} \
+ {INSERT INTO techo(a, b) VALUES('hello', 'world')} \
+ {DELETE FROM techo} \
+] {
+ execsql $stmt
+ execsql $stmt db2
+ check_echo_table vtab1-6.8.[incr tn]
+}
+
+db2 close
+
+
+
+#----------------------------------------------------------------------
+# Test cases vtab1-7 tests that the value returned by
+# sqlite3_last_insert_rowid() is set correctly when rows are inserted
+# into virtual tables.
+do_test vtab1.7-1 {
+ execsql {
+ CREATE TABLE real_abc(a PRIMARY KEY, b, c);
+ CREATE VIRTUAL TABLE echo_abc USING echo(real_abc);
+ }
+} {}
+do_test vtab1.7-2 {
+ execsql {
+ INSERT INTO echo_abc VALUES(1, 2, 3);
+ SELECT last_insert_rowid();
+ }
+} {1}
+do_test vtab1.7-3 {
+ execsql {
+ INSERT INTO echo_abc(rowid) VALUES(31427);
+ SELECT last_insert_rowid();
+ }
+} {31427}
+do_test vtab1.7-4 {
+ execsql {
+ INSERT INTO echo_abc SELECT a||'.v2', b, c FROM echo_abc;
+ SELECT last_insert_rowid();
+ }
+} {31429}
+do_test vtab1.7-5 {
+ execsql {
+ SELECT rowid, a, b, c FROM echo_abc
+ }
+} [list 1 1 2 3 \
+ 31427 {} {} {} \
+ 31428 1.v2 2 3 \
+ 31429 {} {} {} \
+]
+
+# Now test that DELETE and UPDATE operations do not modify the value.
+do_test vtab1.7-6 {
+ execsql {
+ UPDATE echo_abc SET c = 5 WHERE b = 2;
+ SELECT last_insert_rowid();
+ }
+} {31429}
+do_test vtab1.7-7 {
+ execsql {
+ UPDATE echo_abc SET rowid = 5 WHERE rowid = 1;
+ SELECT last_insert_rowid();
+ }
+} {31429}
+do_test vtab1.7-8 {
+ execsql {
+ DELETE FROM echo_abc WHERE b = 2;
+ SELECT last_insert_rowid();
+ }
+} {31429}
+do_test vtab1.7-9 {
+ execsql {
+ SELECT rowid, a, b, c FROM echo_abc
+ }
+} [list 31427 {} {} {} \
+ 31429 {} {} {} \
+]
+do_test vtab1.7-10 {
+ execsql {
+ DELETE FROM echo_abc WHERE b = 2;
+ SELECT last_insert_rowid();
+ }
+} {31429}
+do_test vtab1.7-11 {
+ execsql {
+ SELECT rowid, a, b, c FROM real_abc
+ }
+} [list 31427 {} {} {} \
+ 31429 {} {} {} \
+]
+do_test vtab1.7-12 {
+ execsql {
+ DELETE FROM echo_abc;
+ SELECT last_insert_rowid();
+ }
+} {31429}
+do_test vtab1.7-13 {
+ execsql {
+ SELECT rowid, a, b, c FROM real_abc
+ }
+} {}
+
+ifcapable attach {
+ do_test vtab1.8-1 {
+ set echo_module ""
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ CREATE VIRTUAL TABLE aux.e2 USING echo(real_abc);
+ }
+ set echo_module
+ } [list xCreate echo aux e2 real_abc \
+ xSync echo(real_abc) \
+ xCommit echo(real_abc) \
+ ]
+}
+do_test vtab1.8-2 {
+ catchsql {
+ DROP TABLE aux.e2;
+ }
+ execsql {
+ DROP TABLE treal;
+ DROP TABLE techo;
+ DROP TABLE echo_abc;
+ DROP TABLE real_abc;
+ }
+} {}
+
+do_test vtab1.9-1 {
+ set echo_module ""
+ execsql {
+ CREATE TABLE r(a, b, c);
+ CREATE VIRTUAL TABLE e USING echo(r, e_log);
+ SELECT name FROM sqlite_master;
+ }
+} {r e e_log}
+do_test vtab1.9-2 {
+ execsql {
+ DROP TABLE e;
+ SELECT name FROM sqlite_master;
+ }
+} {r}
+
+do_test vtab1.9-3 {
+ set echo_module ""
+ execsql {
+ CREATE VIRTUAL TABLE e USING echo(r, e_log, virtual 1 2 3 varchar(32));
+ }
+ set echo_module
+} [list \
+ xCreate echo main e r e_log {virtual 1 2 3 varchar(32)} \
+ xSync echo(r) \
+ xCommit echo(r) \
+]
+
+do_test vtab1.10-1 {
+ execsql {
+ CREATE TABLE del(d);
+ CREATE VIRTUAL TABLE e2 USING echo(del);
+ }
+ db close
+ sqlite3 db test.db
+ register_echo_module [sqlite3_connection_pointer db]
+ execsql {
+ DROP TABLE del;
+ }
+ catchsql {
+ SELECT * FROM e2;
+ }
+} {1 {vtable constructor failed: e2}}
+do_test vtab1.10-2 {
+ set rc [catch {
+ set ptr [sqlite3_connection_pointer db]
+ sqlite3_declare_vtab $ptr {CREATE TABLE abc(a, b, c)}
+ } msg]
+ list $rc $msg
+} {1 {library routine called out of sequence}}
+do_test vtab1.10-3 {
+ set ::echo_module_begin_fail r
+ catchsql {
+ INSERT INTO e VALUES(1, 2, 3);
+ }
+} {1 {SQL logic error or missing database}}
+do_test vtab1.10-4 {
+ catch {execsql {
+ EXPLAIN SELECT * FROM e WHERE rowid = 2;
+ EXPLAIN QUERY PLAN SELECT * FROM e WHERE rowid = 2 ORDER BY rowid;
+ }}
+} {0}
+
+do_test vtab1.10-5 {
+ set echo_module ""
+ execsql {
+ SELECT * FROM e WHERE rowid||'' MATCH 'pattern';
+ }
+ set echo_module
+} [list \
+ xBestIndex {SELECT rowid, * FROM 'r'} \
+ xFilter {SELECT rowid, * FROM 'r'} \
+]
+proc match_func {args} {return ""}
+do_test vtab1.10-6 {
+ set echo_module ""
+ db function match match_func
+ execsql {
+ SELECT * FROM e WHERE match('pattern', rowid, 'pattern2');
+ }
+ set echo_module
+} [list \
+ xBestIndex {SELECT rowid, * FROM 'r'} \
+ xFilter {SELECT rowid, * FROM 'r'} \
+]
+
+
+# Testing the xFindFunction interface
+#
+catch {rename ::echo_glob_overload {}}
+do_test vtab1.11-1 {
+ execsql {
+ INSERT INTO r(a,b,c) VALUES(1,'?',99);
+ INSERT INTO r(a,b,c) VALUES(2,3,99);
+ SELECT a GLOB b FROM e
+ }
+} {1 0}
+proc ::echo_glob_overload {a b} {
+ return [list $b $a]
+}
+do_test vtab1.11-2 {
+ execsql {
+ SELECT a like 'b' FROM e
+ }
+} {0 0}
+do_test vtab1.11-3 {
+ execsql {
+ SELECT a glob '2' FROM e
+ }
+} {{1 2} {2 2}}
+do_test vtab1.11-4 {
+ execsql {
+ SELECT glob('2',a) FROM e
+ }
+} {0 1}
+do_test vtab1.11-5 {
+ execsql {
+ SELECT glob(a,'2') FROM e
+ }
+} {{2 1} {2 2}}
+
+#----------------------------------------------------------------------
+# Test the outcome if a constraint is encountered half-way through
+# a multi-row INSERT that is inside a transaction
+#
+do_test vtab1.12-1 {
+ execsql {
+ CREATE TABLE b(a, b, c);
+ CREATE TABLE c(a UNIQUE, b, c);
+ INSERT INTO b VALUES(1, 'A', 'B');
+ INSERT INTO b VALUES(2, 'C', 'D');
+ INSERT INTO b VALUES(3, 'E', 'F');
+ INSERT INTO c VALUES(3, 'G', 'H');
+ CREATE VIRTUAL TABLE echo_c USING echo(c);
+ }
+} {}
+
+# First test outside of a transaction.
+do_test vtab1.12-2 {
+ catchsql { INSERT INTO echo_c SELECT * FROM b; }
+} {1 {echo-vtab-error: column a is not unique}}
+do_test vtab1.12-2.1 {
+ sqlite3_errmsg db
+} {echo-vtab-error: column a is not unique}
+do_test vtab1.12-3 {
+ execsql { SELECT * FROM c }
+} {3 G H}
+
+# Now the real test - wrapped in a transaction.
+do_test vtab1.12-4 {
+ execsql {BEGIN}
+ catchsql { INSERT INTO echo_c SELECT * FROM b; }
+} {1 {echo-vtab-error: column a is not unique}}
+do_test vtab1.12-5 {
+ execsql { SELECT * FROM c }
+} {3 G H}
+do_test vtab1.12-6 {
+ execsql { COMMIT }
+ execsql { SELECT * FROM c }
+} {3 G H}
+
+# At one point (ticket #2759), a WHERE clause of the form "<column> IS NULL"
+# on a virtual table was causing an assert() to fail in the compiler.
+#
+# "IS NULL" clauses should not be passed through to the virtual table
+# implementation. They are handled by SQLite after the vtab returns its
+# data.
+#
+do_test vtab1.13-1 {
+ execsql {
+ SELECT * FROM echo_c WHERE a IS NULL
+ }
+} {}
+do_test vtab1.13-2 {
+ execsql {
+ INSERT INTO c VALUES(NULL, 15, 16);
+ SELECT * FROM echo_c WHERE a IS NULL
+ }
+} {{} 15 16}
+do_test vtab1.13-3 {
+ execsql {
+ INSERT INTO c VALUES(15, NULL, 16);
+ SELECT * FROM echo_c WHERE b IS NULL
+ }
+} {15 {} 16}
+do_test vtab1.13-3 {
+ execsql {
+ SELECT * FROM echo_c WHERE b IS NULL AND a = 15;
+ }
+} {15 {} 16}
+
+
+do_test vtab1-14.1 {
+ execsql { DELETE FROM c }
+ set echo_module ""
+ execsql { SELECT * FROM echo_c WHERE rowid IN (1, 2, 3) }
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'c'} xFilter {SELECT rowid, * FROM 'c'}]
+
+do_test vtab1-14.2 {
+ set echo_module ""
+ execsql { SELECT * FROM echo_c WHERE rowid = 1 }
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'c' WHERE rowid = ?} xFilter {SELECT rowid, * FROM 'c' WHERE rowid = ?} 1]
+
+do_test vtab1-14.3 {
+ set echo_module ""
+ execsql { SELECT * FROM echo_c WHERE a = 1 }
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'c' WHERE a = ?} xFilter {SELECT rowid, * FROM 'c' WHERE a = ?} 1]
+
+do_test vtab1-14.4 {
+ set echo_module ""
+ execsql { SELECT * FROM echo_c WHERE a IN (1, 2) }
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'c'} xFilter {SELECT rowid, * FROM 'c'}]
+
+do_test vtab1-15.1 {
+ execsql {
+ CREATE TABLE t1(a, b, c);
+ CREATE VIRTUAL TABLE echo_t1 USING echo(t1);
+ }
+} {}
+do_test vtab1-15.2 {
+ execsql {
+ INSERT INTO echo_t1(rowid) VALUES(45);
+ SELECT rowid, * FROM echo_t1;
+ }
+} {45 {} {} {}}
+do_test vtab1-15.3 {
+ execsql {
+ INSERT INTO echo_t1(rowid) VALUES(NULL);
+ SELECT rowid, * FROM echo_t1;
+ }
+} {45 {} {} {} 46 {} {} {}}
+do_test vtab1-15.4 {
+ catchsql {
+ INSERT INTO echo_t1(rowid) VALUES('new rowid');
+ }
+} {1 {datatype mismatch}}
+
+# The following tests - vtab1-16.* - are designed to test that setting
+# sqlite3_vtab.zErrMsg variable can be used by the vtab interface to
+# return an error message to the user.
+#
+do_test vtab1-16.1 {
+ execsql {
+ CREATE TABLE t2(a PRIMARY KEY, b, c);
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(4, 5, 6);
+ CREATE VIRTUAL TABLE echo_t2 USING echo(t2);
+ }
+} {}
+
+set tn 2
+foreach method [list \
+ xBestIndex \
+ xOpen \
+ xFilter \
+ xNext \
+ xColumn \
+ xRowid \
+] {
+ do_test vtab1-16.$tn {
+ set echo_module_fail($method,t2) "the $method method has failed"
+ catchsql { SELECT rowid, * FROM echo_t2 WHERE a >= 1 }
+ } "1 {echo-vtab-error: the $method method has failed}"
+ unset echo_module_fail($method,t2)
+ incr tn
+}
+
+foreach method [list \
+ xUpdate \
+ xBegin \
+ xSync \
+] {
+ do_test vtab1-16.$tn {
+ set echo_module_fail($method,t2) "the $method method has failed"
+ catchsql { INSERT INTO echo_t2 VALUES(7, 8, 9) }
+ } "1 {echo-vtab-error: the $method method has failed}"
+ unset echo_module_fail($method,t2)
+ incr tn
+}
+
+ifcapable altertable {
+ do_test vtab1-16.$tn {
+ set echo_module_fail(xRename,t2) "the xRename method has failed"
+ catchsql { ALTER TABLE echo_t2 RENAME TO another_name }
+ } "1 {echo-vtab-error: the xRename method has failed}"
+ unset echo_module_fail(xRename,t2)
+ incr tn
+}
+
+# The following test case exposes an instance in sqlite3_declare_vtab()
+# an error message was set using a call similar to sqlite3_mprintf(zErr),
+# where zErr is an arbitrary string. This is no good if the string contains
+# characters that can be mistaken for printf() formatting directives.
+#
+do_test vtab1-17.1 {
+ execsql {
+ PRAGMA writable_schema = 1;
+ INSERT INTO sqlite_master VALUES(
+ 'table', 't3', 't3', 0, 'INSERT INTO "%s%s" VALUES(1)'
+ );
+ }
+ catchsql { CREATE VIRTUAL TABLE t4 USING echo(t3); }
+} {1 {vtable constructor failed: t4}}
+
+# This test verifies that ticket 48f29963 is fixed.
+#
+do_test vtab1-17.1 {
+ execsql {
+ CREATE TABLE t5(a, b);
+ CREATE VIRTUAL TABLE e5 USING echo_v2(t5);
+ BEGIN;
+ INSERT INTO e5 VALUES(1, 2);
+ DROP TABLE e5;
+ SAVEPOINT one;
+ ROLLBACK TO one;
+ COMMIT;
+ }
+} {}
+
+unset -nocomplain echo_module_begin_fail
+finish_test
diff --git a/test/vtab2.test b/test/vtab2.test
new file mode 100644
index 0000000..05a4834
--- /dev/null
+++ b/test/vtab2.test
@@ -0,0 +1,136 @@
+# 2006 June 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# $Id: vtab2.test,v 1.9 2008/10/13 10:37:50 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab||!schema_pragmas {
+ finish_test
+ return
+}
+
+register_schema_module [sqlite3_connection_pointer db]
+do_test vtab2-1.1 {
+ execsql {
+ CREATE VIRTUAL TABLE schema USING schema;
+ SELECT * FROM schema;
+ }
+} [list \
+ main schema 0 database {} 0 {} 0 \
+ main schema 1 tablename {} 0 {} 0 \
+ main schema 2 cid {} 0 {} 0 \
+ main schema 3 name {} 0 {} 0 \
+ main schema 4 type {} 0 {} 0 \
+ main schema 5 not_null {} 0 {} 0 \
+ main schema 6 dflt_value {} 0 {} 0 \
+ main schema 7 pk {} 0 {} 0 \
+]
+
+# See ticket #2230.
+#
+do_test vtab2-1.2 {
+ execsql {
+ SELECT length(tablename) FROM schema GROUP by tablename;
+ }
+} {6}
+do_test vtab2-1.3 {
+ execsql {
+ SELECT tablename FROM schema GROUP by length(tablename);
+ }
+} {schema}
+do_test vtab2-1.4 {
+ execsql {
+ SELECT length(tablename) FROM schema GROUP by length(tablename);
+ }
+} {6}
+
+register_tclvar_module [sqlite3_connection_pointer db]
+do_test vtab2-2.1 {
+ set ::abc 123
+ execsql {
+ CREATE VIRTUAL TABLE vars USING tclvar;
+ SELECT * FROM vars WHERE name='abc';
+ }
+} [list abc "" 123]
+do_test vtab2-2.2 {
+ set A(1) 1
+ set A(2) 4
+ set A(3) 9
+ execsql {
+ SELECT * FROM vars WHERE name='A';
+ }
+} [list A 1 1 A 2 4 A 3 9]
+unset -nocomplain result
+unset -nocomplain var
+set result {}
+foreach var [lsort [info vars tcl_*]] {
+ catch {lappend result $var [set $var]}
+}
+do_test vtab2-2.3 {
+ execsql {
+ SELECT name, value FROM vars
+ WHERE name MATCH 'tcl_*' AND arrayname = ''
+ ORDER BY name;
+ }
+} $result
+unset result
+unset var
+
+# Ticket #2894.
+#
+# Make sure we do call Column(), and Rowid() methods of
+# a virtual table when that table is in a LEFT JOIN.
+#
+do_test vtab2-3.1 {
+ execsql {
+ SELECT * FROM schema WHERE dflt_value IS NULL LIMIT 1
+ }
+} {main schema 0 database {} 0 {} 0}
+do_test vtab2-3.2 {
+ execsql {
+ SELECT *, b.rowid
+ FROM schema a LEFT JOIN schema b ON a.dflt_value=b.dflt_value
+ WHERE a.rowid=1
+ }
+} {main schema 0 database {} 0 {} 0 {} {} {} {} {} {} {} {} {}}
+
+do_test vtab2-4.1 {
+ execsql {
+ BEGIN TRANSACTION;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));
+ CREATE TABLE fkey(
+ to_tbl,
+ to_col
+ );
+ INSERT INTO "fkey" VALUES('t1',NULL);
+ COMMIT;
+ }
+} {}
+do_test vtab2-4.2 {
+ execsql { CREATE VIRTUAL TABLE v_col USING schema }
+} {}
+do_test vtab2-4.3 {
+ execsql { SELECT name FROM v_col WHERE tablename = 't1' AND pk }
+} {a}
+do_test vtab2-4.4 {
+ execsql {
+ UPDATE fkey
+ SET to_col = (SELECT name FROM v_col WHERE tablename = 't1' AND pk);
+ }
+} {}
+do_test vtab2-4.5 {
+ execsql { SELECT * FROM fkey }
+} {t1 a}
+
+finish_test
diff --git a/test/vtab3.test b/test/vtab3.test
new file mode 100644
index 0000000..ebf8369
--- /dev/null
+++ b/test/vtab3.test
@@ -0,0 +1,140 @@
+# 2006 June 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is the authorisation callback and virtual tables.
+#
+# $Id: vtab3.test,v 1.3 2008/07/12 14:52:21 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab||!auth {
+ finish_test
+ return
+}
+
+set ::auth_fail 0
+set ::auth_log [list]
+set ::auth_filter [list SQLITE_READ SQLITE_UPDATE SQLITE_SELECT SQLITE_PRAGMA]
+
+proc auth {code arg1 arg2 arg3 arg4} {
+ if {[lsearch $::auth_filter $code]>-1} {
+ return SQLITE_OK
+ }
+ lappend ::auth_log $code $arg1 $arg2 $arg3 $arg4
+ incr ::auth_fail -1
+ if {$::auth_fail == 0} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+}
+
+do_test vtab3-1.1 {
+ execsql {
+ CREATE TABLE elephant(
+ name VARCHAR(32),
+ color VARCHAR(16),
+ age INTEGER,
+ UNIQUE(name, color)
+ );
+ }
+} {}
+
+
+do_test vtab3-1.2 {
+ register_echo_module [sqlite3_connection_pointer db]
+ db authorizer ::auth
+ execsql {
+ CREATE VIRTUAL TABLE pachyderm USING echo(elephant);
+ }
+ set ::auth_log
+} [list \
+ SQLITE_INSERT sqlite_master {} main {} \
+ SQLITE_CREATE_VTABLE pachyderm echo main {} \
+]
+
+do_test vtab3-1.3 {
+ set ::auth_log [list]
+ execsql {
+ DROP TABLE pachyderm;
+ }
+ set ::auth_log
+} [list \
+ SQLITE_DELETE sqlite_master {} main {} \
+ SQLITE_DROP_VTABLE pachyderm echo main {} \
+ SQLITE_DELETE pachyderm {} main {} \
+ SQLITE_DELETE sqlite_master {} main {} \
+]
+
+do_test vtab3-1.4 {
+ set ::auth_fail 1
+ catchsql {
+ CREATE VIRTUAL TABLE pachyderm USING echo(elephant);
+ }
+} {1 {not authorized}}
+do_test vtab3-1.5 {
+ execsql {
+ SELECT name FROM sqlite_master WHERE type = 'table';
+ }
+} {elephant}
+
+do_test vtab3-1.5 {
+ set ::auth_fail 2
+ catchsql {
+ CREATE VIRTUAL TABLE pachyderm USING echo(elephant);
+ }
+} {1 {not authorized}}
+do_test vtab3-1.6 {
+ execsql {
+ SELECT name FROM sqlite_master WHERE type = 'table';
+ }
+} {elephant}
+
+do_test vtab3-1.5 {
+ set ::auth_fail 3
+ catchsql {
+ CREATE VIRTUAL TABLE pachyderm USING echo(elephant);
+ }
+} {0 {}}
+do_test vtab3-1.6 {
+ execsql {
+ SELECT name FROM sqlite_master WHERE type = 'table';
+ }
+} {elephant pachyderm}
+
+foreach i [list 1 2 3 4] {
+ set ::auth_fail $i
+ do_test vtab3-1.7.$i.1 {
+ set rc [catch {
+ execsql {DROP TABLE pachyderm;}
+ } msg]
+ if {$msg eq "authorization denied"} {set msg "not authorized"}
+ list $rc $msg
+ } {1 {not authorized}}
+ do_test vtab3-1.7.$i.2 {
+ execsql {
+ SELECT name FROM sqlite_master WHERE type = 'table';
+ }
+ } {elephant pachyderm}
+}
+do_test vtab3-1.8.1 {
+ set ::auth_fail 0
+ catchsql {
+ DROP TABLE pachyderm;
+ }
+} {0 {}}
+do_test vtab3-1.8.2 {
+ execsql {
+ SELECT name FROM sqlite_master WHERE type = 'table';
+ }
+} {elephant}
+
+finish_test
diff --git a/test/vtab4.test b/test/vtab4.test
new file mode 100644
index 0000000..07b6e83
--- /dev/null
+++ b/test/vtab4.test
@@ -0,0 +1,193 @@
+# 2006 June 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus is on testing the following virtual table methods:
+#
+# xBegin
+# xSync
+# xCommit
+# xRollback
+#
+# $Id: vtab4.test,v 1.3 2008/07/12 14:52:21 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+unset -nocomplain echo_module
+unset -nocomplain echo_module_sync_fail
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+# Register the echo module
+db cache size 0
+register_echo_module [sqlite3_connection_pointer db]
+
+do_test vtab4-1.1 {
+ execsql {
+ CREATE TABLE treal(a PRIMARY KEY, b, c);
+ CREATE VIRTUAL TABLE techo USING echo(treal);
+ }
+} {}
+
+# Test an INSERT, UPDATE and DELETE statement on the virtual table
+# in an implicit transaction. Each should result in a single call
+# to xBegin, xSync and xCommit.
+#
+do_test vtab4-1.2 {
+ set echo_module [list]
+ execsql {
+ INSERT INTO techo VALUES(1, 2, 3);
+ }
+ set echo_module
+} {xBegin echo(treal) xSync echo(treal) xCommit echo(treal)}
+do_test vtab4-1.3 {
+ set echo_module [list]
+ execsql {
+ UPDATE techo SET a = 2;
+ }
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal'} \
+ xBegin echo(treal) \
+ xFilter {SELECT rowid, * FROM 'treal'} \
+ xSync echo(treal) \
+ xCommit echo(treal) \
+]
+do_test vtab4-1.4 {
+ set echo_module [list]
+ execsql {
+ DELETE FROM techo;
+ }
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal'} \
+ xBegin echo(treal) \
+ xFilter {SELECT rowid, * FROM 'treal'} \
+ xSync echo(treal) \
+ xCommit echo(treal) \
+]
+
+# Ensure xBegin is not called more than once in a single transaction.
+#
+do_test vtab4-2.1 {
+ set echo_module [list]
+ execsql {
+ BEGIN;
+ INSERT INTO techo VALUES(1, 2, 3);
+ INSERT INTO techo VALUES(4, 5, 6);
+ INSERT INTO techo VALUES(7, 8, 9);
+ COMMIT;
+ }
+ set echo_module
+} {xBegin echo(treal) xSync echo(treal) xCommit echo(treal)}
+
+# Try a transaction with two virtual tables.
+#
+do_test vtab4-2.2 {
+ execsql {
+ CREATE TABLE sreal(a, b, c UNIQUE);
+ CREATE VIRTUAL TABLE secho USING echo(sreal);
+ }
+ set echo_module [list]
+ execsql {
+ BEGIN;
+ INSERT INTO secho SELECT * FROM techo;
+ DELETE FROM techo;
+ COMMIT;
+ }
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'treal'} \
+ xBegin echo(sreal) \
+ xFilter {SELECT rowid, * FROM 'treal'} \
+ xBestIndex {SELECT rowid, * FROM 'treal'} \
+ xBegin echo(treal) \
+ xFilter {SELECT rowid, * FROM 'treal'} \
+ xSync echo(sreal) \
+ xSync echo(treal) \
+ xCommit echo(sreal) \
+ xCommit echo(treal) \
+]
+do_test vtab4-2.3 {
+ execsql {
+ SELECT * FROM secho;
+ }
+} {1 2 3 4 5 6 7 8 9}
+do_test vtab4-2.4 {
+ execsql {
+ SELECT * FROM techo;
+ }
+} {}
+
+# Try an explicit ROLLBACK on a transaction with two open virtual tables.
+do_test vtab4-2.5 {
+ set echo_module [list]
+ execsql {
+ BEGIN;
+ INSERT INTO techo SELECT * FROM secho;
+ DELETE FROM secho;
+ ROLLBACK;
+ }
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'sreal'} \
+ xBegin echo(treal) \
+ xFilter {SELECT rowid, * FROM 'sreal'} \
+ xBestIndex {SELECT rowid, * FROM 'sreal'} \
+ xBegin echo(sreal) \
+ xFilter {SELECT rowid, * FROM 'sreal'} \
+ xRollback echo(treal) \
+ xRollback echo(sreal) \
+]
+do_test vtab4-2.6 {
+ execsql {
+ SELECT * FROM secho;
+ }
+} {1 2 3 4 5 6 7 8 9}
+do_test vtab4-2.7 {
+ execsql {
+ SELECT * FROM techo;
+ }
+} {}
+
+do_test vtab4-3.1 {
+ set echo_module [list]
+ set echo_module_sync_fail treal
+ catchsql {
+ INSERT INTO techo VALUES(1, 2, 3);
+ }
+} {1 {unknown error}}
+do_test vtab4-3.2 {
+ set echo_module
+} {xBegin echo(treal) xSync echo(treal) xRollback echo(treal)}
+
+do_test vtab4-3.3 {
+ set echo_module [list]
+ set echo_module_sync_fail sreal
+ catchsql {
+ BEGIN;
+ INSERT INTO techo SELECT * FROM secho;
+ DELETE FROM secho;
+ COMMIT;
+ }
+ set echo_module
+} [list xBestIndex {SELECT rowid, * FROM 'sreal'} \
+ xBegin echo(treal) \
+ xFilter {SELECT rowid, * FROM 'sreal'} \
+ xBestIndex {SELECT rowid, * FROM 'sreal'} \
+ xBegin echo(sreal) \
+ xFilter {SELECT rowid, * FROM 'sreal'} \
+ xSync echo(treal) \
+ xSync echo(sreal) \
+ xRollback echo(treal) \
+ xRollback echo(sreal) \
+]
+
+finish_test
diff --git a/test/vtab5.test b/test/vtab5.test
new file mode 100644
index 0000000..bb84a5c
--- /dev/null
+++ b/test/vtab5.test
@@ -0,0 +1,154 @@
+# 2006 June 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# $Id: vtab5.test,v 1.8 2008/07/12 14:52:21 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+# The following tests - vtab5-1.* - ensure that an INSERT, DELETE or UPDATE
+# statement can be executed immediately after a CREATE or schema reload. The
+# point here is testing that the parser always calls xConnect() before the
+# schema of a virtual table is used.
+#
+register_echo_module [sqlite3_connection_pointer db]
+do_test vtab5-1.1 {
+ execsql {
+ CREATE TABLE treal(a VARCHAR(16), b INTEGER, c FLOAT);
+ INSERT INTO treal VALUES('a', 'b', 'c');
+ CREATE VIRTUAL TABLE techo USING echo(treal);
+ }
+} {}
+do_test vtab5.1.2 {
+ execsql {
+ SELECT * FROM techo;
+ }
+} {a b c}
+do_test vtab5.1.3 {
+ db close
+ sqlite3 db test.db
+ register_echo_module [sqlite3_connection_pointer db]
+ execsql {
+ INSERT INTO techo VALUES('c', 'd', 'e');
+ SELECT * FROM techo;
+ }
+} {a b c c d e}
+do_test vtab5.1.4 {
+ db close
+ sqlite3 db test.db
+ register_echo_module [sqlite3_connection_pointer db]
+ execsql {
+ UPDATE techo SET a = 10;
+ SELECT * FROM techo;
+ }
+} {10 b c 10 d e}
+do_test vtab5.1.5 {
+ db close
+ sqlite3 db test.db
+ register_echo_module [sqlite3_connection_pointer db]
+ execsql {
+ DELETE FROM techo WHERE b > 'c';
+ SELECT * FROM techo;
+ }
+} {10 b c}
+do_test vtab5.1.X {
+ execsql {
+ DROP TABLE techo;
+ DROP TABLE treal;
+ }
+} {}
+
+# The following tests - vtab5-2.* - ensure that collation sequences
+# assigned to virtual table columns via the "CREATE TABLE" statement
+# passed to sqlite3_declare_vtab() are used correctly.
+#
+do_test vtab5.2.1 {
+ execsql {
+ CREATE TABLE strings(str COLLATE NOCASE);
+ INSERT INTO strings VALUES('abc1');
+ INSERT INTO strings VALUES('Abc3');
+ INSERT INTO strings VALUES('ABc2');
+ INSERT INTO strings VALUES('aBc4');
+ SELECT str FROM strings ORDER BY 1;
+ }
+} {abc1 ABc2 Abc3 aBc4}
+do_test vtab5.2.2 {
+ execsql {
+ CREATE VIRTUAL TABLE echo_strings USING echo(strings);
+ SELECT str FROM echo_strings ORDER BY 1;
+ }
+} {abc1 ABc2 Abc3 aBc4}
+do_test vtab5.2.3 {
+ execsql {
+ SELECT str||'' FROM echo_strings ORDER BY 1;
+ }
+} {ABc2 Abc3 aBc4 abc1}
+
+# Test that it is impossible to create a triggger on a virtual table.
+#
+ifcapable trigger {
+ do_test vtab5.3.1 {
+ catchsql {
+ CREATE TRIGGER trig INSTEAD OF INSERT ON echo_strings BEGIN
+ SELECT 1, 2, 3;
+ END;
+ }
+ } {1 {cannot create triggers on virtual tables}}
+ do_test vtab5.3.2 {
+ catchsql {
+ CREATE TRIGGER trig AFTER INSERT ON echo_strings BEGIN
+ SELECT 1, 2, 3;
+ END;
+ }
+ } {1 {cannot create triggers on virtual tables}}
+ do_test vtab5.3.2 {
+ catchsql {
+ CREATE TRIGGER trig BEFORE INSERT ON echo_strings BEGIN
+ SELECT 1, 2, 3;
+ END;
+ }
+ } {1 {cannot create triggers on virtual tables}}
+}
+
+# Test that it is impossible to create an index on a virtual table.
+#
+do_test vtab5.4.1 {
+ catchsql {
+ CREATE INDEX echo_strings_i ON echo_strings(str);
+ }
+} {1 {virtual tables may not be indexed}}
+
+# Test that it is impossible to add a column to a virtual table.
+#
+ifcapable altertable {
+ do_test vtab5.4.2 {
+ catchsql {
+ ALTER TABLE echo_strings ADD COLUMN col2;
+ }
+ } {1 {virtual tables may not be altered}}
+}
+
+# Test that it is impossible to rename a virtual table.
+# UPDATE: It is now possible.
+#
+# do_test vtab5.4.3 {
+# catchsql {
+# ALTER TABLE echo_strings RENAME TO echo_strings2;
+# }
+# } {1 {virtual tables may not be altered}}
+
+finish_test
diff --git a/test/vtab6.test b/test/vtab6.test
new file mode 100644
index 0000000..96e45bf
--- /dev/null
+++ b/test/vtab6.test
@@ -0,0 +1,573 @@
+# 2002 May 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for joins, including outer joins involving
+# virtual tables. The test cases in this file are copied from the file
+# join.test, and some of the comments still reflect that.
+#
+# $Id: vtab6.test,v 1.5 2009/07/01 16:12:08 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_echo_module [sqlite3_connection_pointer db]
+
+execsql {
+ CREATE TABLE real_t1(a,b,c);
+ CREATE TABLE real_t2(b,c,d);
+ CREATE TABLE real_t3(c,d,e);
+ CREATE TABLE real_t4(d,e,f);
+ CREATE TABLE real_t5(a INTEGER PRIMARY KEY);
+ CREATE TABLE real_t6(a INTEGER);
+ CREATE TABLE real_t7 (x, y);
+ CREATE TABLE real_t8 (a integer primary key, b);
+ CREATE TABLE real_t9(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE real_t10(x INTEGER PRIMARY KEY, y);
+ CREATE TABLE real_t11(p INTEGER PRIMARY KEY, q);
+ CREATE TABLE real_t12(a,b);
+ CREATE TABLE real_t13(b,c);
+ CREATE TABLE real_t21(a,b,c);
+ CREATE TABLE real_t22(p,q);
+}
+foreach t [list t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t21 t22] {
+ execsql "CREATE VIRTUAL TABLE $t USING echo(real_$t)"
+}
+
+do_test vtab6-1.1 {
+ execsql {
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(2,3,4);
+ INSERT INTO t1 VALUES(3,4,5);
+ SELECT * FROM t1;
+ }
+} {1 2 3 2 3 4 3 4 5}
+do_test vtab6-1.2 {
+ execsql {
+ INSERT INTO t2 VALUES(1,2,3);
+ INSERT INTO t2 VALUES(2,3,4);
+ INSERT INTO t2 VALUES(3,4,5);
+ SELECT * FROM t2;
+ }
+} {1 2 3 2 3 4 3 4 5}
+
+do_test vtab6-1.3 {
+ execsql2 {
+ SELECT * FROM t1 NATURAL JOIN t2;
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+do_test vtab6-1.3.1 {
+ execsql2 {
+ SELECT * FROM t2 NATURAL JOIN t1;
+ }
+} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}
+do_test vtab6-1.3.2 {
+ execsql2 {
+ SELECT * FROM t2 AS x NATURAL JOIN t1;
+ }
+} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}
+do_test vtab6-1.3.3 {
+ execsql2 {
+ SELECT * FROM t2 NATURAL JOIN t1 AS y;
+ }
+} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}
+do_test vtab6-1.3.4 {
+ execsql {
+ SELECT b FROM t1 NATURAL JOIN t2;
+ }
+} {2 3}
+do_test vtab6-1.4.1 {
+ execsql2 {
+ SELECT * FROM t1 INNER JOIN t2 USING(b,c);
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+do_test vtab6-1.4.2 {
+ execsql2 {
+ SELECT * FROM t1 AS x INNER JOIN t2 USING(b,c);
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+do_test vtab6-1.4.3 {
+ execsql2 {
+ SELECT * FROM t1 INNER JOIN t2 AS y USING(b,c);
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+do_test vtab6-1.4.4 {
+ execsql2 {
+ SELECT * FROM t1 AS x INNER JOIN t2 AS y USING(b,c);
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+do_test vtab6-1.4.5 {
+ execsql {
+ SELECT b FROM t1 JOIN t2 USING(b);
+ }
+} {2 3}
+do_test vtab6-1.5 {
+ execsql2 {
+ SELECT * FROM t1 INNER JOIN t2 USING(b);
+ }
+} {a 1 b 2 c 3 c 3 d 4 a 2 b 3 c 4 c 4 d 5}
+do_test vtab6-1.6 {
+ execsql2 {
+ SELECT * FROM t1 INNER JOIN t2 USING(c);
+ }
+} {a 1 b 2 c 3 b 2 d 4 a 2 b 3 c 4 b 3 d 5}
+do_test vtab6-1.7 {
+ execsql2 {
+ SELECT * FROM t1 INNER JOIN t2 USING(c,b);
+ }
+} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}
+
+do_test vtab6-1.8 {
+ execsql {
+ SELECT * FROM t1 NATURAL CROSS JOIN t2;
+ }
+} {1 2 3 4 2 3 4 5}
+do_test vtab6-1.9 {
+ execsql {
+ SELECT * FROM t1 CROSS JOIN t2 USING(b,c);
+ }
+} {1 2 3 4 2 3 4 5}
+do_test vtab6-1.10 {
+ execsql {
+ SELECT * FROM t1 NATURAL INNER JOIN t2;
+ }
+} {1 2 3 4 2 3 4 5}
+do_test vtab6-1.11 {
+ execsql {
+ SELECT * FROM t1 INNER JOIN t2 USING(b,c);
+ }
+} {1 2 3 4 2 3 4 5}
+do_test vtab6-1.12 {
+ execsql {
+ SELECT * FROM t1 natural inner join t2;
+ }
+} {1 2 3 4 2 3 4 5}
+
+ifcapable subquery {
+ do_test vtab6-1.13 {
+ execsql2 {
+ SELECT * FROM t1 NATURAL JOIN
+ (SELECT b as 'c', c as 'd', d as 'e' FROM t2) as t3
+ }
+ } {a 1 b 2 c 3 d 4 e 5}
+ do_test vtab6-1.14 {
+ execsql2 {
+ SELECT * FROM (SELECT b as 'c', c as 'd', d as 'e' FROM t2) as 'tx'
+ NATURAL JOIN t1
+ }
+ } {c 3 d 4 e 5 a 1 b 2}
+}
+
+do_test vtab6-1.15 {
+ execsql {
+ INSERT INTO t3 VALUES(2,3,4);
+ INSERT INTO t3 VALUES(3,4,5);
+ INSERT INTO t3 VALUES(4,5,6);
+ SELECT * FROM t3;
+ }
+} {2 3 4 3 4 5 4 5 6}
+do_test vtab6-1.16 {
+ execsql {
+ SELECT * FROM t1 natural join t2 natural join t3;
+ }
+} {1 2 3 4 5 2 3 4 5 6}
+do_test vtab6-1.17 {
+ execsql2 {
+ SELECT * FROM t1 natural join t2 natural join t3;
+ }
+} {a 1 b 2 c 3 d 4 e 5 a 2 b 3 c 4 d 5 e 6}
+do_test vtab6-1.18 {
+ execsql {
+ INSERT INTO t4 VALUES(2,3,4);
+ INSERT INTO t4 VALUES(3,4,5);
+ INSERT INTO t4 VALUES(4,5,6);
+ SELECT * FROM t4;
+ }
+} {2 3 4 3 4 5 4 5 6}
+do_test vtab6-1.19.1 {
+ execsql {
+ SELECT * FROM t1 natural join t2 natural join t4;
+ }
+} {1 2 3 4 5 6}
+do_test vtab6-1.19.2 {
+ execsql2 {
+ SELECT * FROM t1 natural join t2 natural join t4;
+ }
+} {a 1 b 2 c 3 d 4 e 5 f 6}
+do_test vtab6-1.20 {
+ execsql {
+ SELECT * FROM t1 natural join t2 natural join t3 WHERE t1.a=1
+ }
+} {1 2 3 4 5}
+
+do_test vtab6-2.1 {
+ execsql {
+ SELECT * FROM t1 NATURAL LEFT JOIN t2;
+ }
+} {1 2 3 4 2 3 4 5 3 4 5 {}}
+do_test vtab6-2.2 {
+ execsql {
+ SELECT * FROM t2 NATURAL LEFT OUTER JOIN t1;
+ }
+} {1 2 3 {} 2 3 4 1 3 4 5 2}
+do_test vtab6-2.3 {
+ catchsql {
+ SELECT * FROM t1 NATURAL RIGHT OUTER JOIN t2;
+ }
+} {1 {RIGHT and FULL OUTER JOINs are not currently supported}}
+do_test vtab6-2.4 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d
+ }
+} {1 2 3 {} {} {} 2 3 4 {} {} {} 3 4 5 1 2 3}
+do_test vtab6-2.5 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d WHERE t1.a>1
+ }
+} {2 3 4 {} {} {} 3 4 5 1 2 3}
+do_test vtab6-2.6 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d WHERE t2.b IS NULL OR t2.b>1
+ }
+} {1 2 3 {} {} {} 2 3 4 {} {} {}}
+
+do_test vtab6-3.1 {
+ catchsql {
+ SELECT * FROM t1 NATURAL JOIN t2 ON t1.a=t2.b;
+ }
+} {1 {a NATURAL join may not have an ON or USING clause}}
+do_test vtab6-3.2 {
+ catchsql {
+ SELECT * FROM t1 NATURAL JOIN t2 USING(b);
+ }
+} {1 {a NATURAL join may not have an ON or USING clause}}
+do_test vtab6-3.3 {
+ catchsql {
+ SELECT * FROM t1 JOIN t2 ON t1.a=t2.b USING(b);
+ }
+} {1 {cannot have both ON and USING clauses in the same join}}
+do_test vtab6-3.4 {
+ catchsql {
+ SELECT * FROM t1 JOIN t2 USING(a);
+ }
+} {1 {cannot join using column a - column not present in both tables}}
+do_test vtab6-3.5 {
+ catchsql { SELECT * FROM t1 USING(a) }
+} {1 {a JOIN clause is required before USING}}
+do_test vtab6-3.6 {
+ catchsql {
+ SELECT * FROM t1 JOIN t2 ON t3.a=t2.b;
+ }
+} {1 {no such column: t3.a}}
+do_test vtab6-3.7 {
+ catchsql {
+ SELECT * FROM t1 INNER OUTER JOIN t2;
+ }
+} {1 {unknown or unsupported join type: INNER OUTER}}
+do_test vtab6-3.7 {
+ catchsql {
+ SELECT * FROM t1 LEFT BOGUS JOIN t2;
+ }
+} {1 {unknown or unsupported join type: LEFT BOGUS}}
+
+do_test vtab6-4.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t6 VALUES(NULL);
+ INSERT INTO t6 VALUES(NULL);
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ INSERT INTO t6 SELECT * FROM t6;
+ COMMIT;
+ }
+ execsql {
+ SELECT * FROM t6 NATURAL JOIN t5;
+ }
+} {}
+do_test vtab6-4.2 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a<t5.a;
+ }
+} {}
+do_test vtab6-4.3 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a>t5.a;
+ }
+} {}
+do_test vtab6-4.4 {
+ execsql {
+ UPDATE t6 SET a='xyz';
+ SELECT * FROM t6 NATURAL JOIN t5;
+ }
+} {}
+do_test vtab6-4.6 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a<t5.a;
+ }
+} {}
+do_test vtab6-4.7 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a>t5.a;
+ }
+} {}
+do_test vtab6-4.8 {
+ execsql {
+ UPDATE t6 SET a=1;
+ SELECT * FROM t6 NATURAL JOIN t5;
+ }
+} {}
+do_test vtab6-4.9 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a<t5.a;
+ }
+} {}
+do_test vtab6-4.10 {
+ execsql {
+ SELECT * FROM t6, t5 WHERE t6.a>t5.a;
+ }
+} {}
+
+# A test for ticket #247.
+#
+do_test vtab6-7.1 {
+ execsql {
+ INSERT INTO t7 VALUES ("pa1", 1);
+ INSERT INTO t7 VALUES ("pa2", NULL);
+ INSERT INTO t7 VALUES ("pa3", NULL);
+ INSERT INTO t7 VALUES ("pa4", 2);
+ INSERT INTO t7 VALUES ("pa30", 131);
+ INSERT INTO t7 VALUES ("pa31", 130);
+ INSERT INTO t7 VALUES ("pa28", NULL);
+
+ INSERT INTO t8 VALUES (1, "pa1");
+ INSERT INTO t8 VALUES (2, "pa4");
+ INSERT INTO t8 VALUES (3, NULL);
+ INSERT INTO t8 VALUES (4, NULL);
+ INSERT INTO t8 VALUES (130, "pa31");
+ INSERT INTO t8 VALUES (131, "pa30");
+
+ SELECT coalesce(t8.a,999) from t7 LEFT JOIN t8 on y=a;
+ }
+} {1 999 999 2 131 130 999}
+
+# Make sure a left join where the right table is really a view that
+# is itself a join works right. Ticket #306.
+#
+ifcapable view {
+do_test vtab6-8.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t9 VALUES(1,11);
+ INSERT INTO t9 VALUES(2,22);
+ INSERT INTO t10 VALUES(1,2);
+ INSERT INTO t10 VALUES(3,3);
+ INSERT INTO t11 VALUES(2,111);
+ INSERT INTO t11 VALUES(3,333);
+ CREATE VIEW v10_11 AS SELECT x, q FROM t10, t11 WHERE t10.y=t11.p;
+ COMMIT;
+ SELECT * FROM t9 LEFT JOIN v10_11 ON( a=x );
+ }
+} {1 11 1 111 2 22 {} {}}
+ifcapable subquery {
+ do_test vtab6-8.2 {
+ execsql {
+ SELECT * FROM t9 LEFT JOIN (SELECT x, q FROM t10, t11 WHERE t10.y=t11.p)
+ ON( a=x);
+ }
+ } {1 11 1 111 2 22 {} {}}
+}
+do_test vtab6-8.3 {
+ execsql {
+ SELECT * FROM v10_11 LEFT JOIN t9 ON( a=x );
+ }
+} {1 111 1 11 3 333 {} {}}
+} ;# ifcapable view
+
+# Ticket #350 describes a scenario where LEFT OUTER JOIN does not
+# function correctly if the right table in the join is really
+# subquery.
+#
+# To test the problem, we generate the same LEFT OUTER JOIN in two
+# separate selects but with on using a subquery and the other calling
+# the table directly. Then connect the two SELECTs using an EXCEPT.
+# Both queries should generate the same results so the answer should
+# be an empty set.
+#
+ifcapable compound {
+do_test vtab6-9.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t12 VALUES(1,11);
+ INSERT INTO t12 VALUES(2,22);
+ INSERT INTO t13 VALUES(22,222);
+ COMMIT;
+ }
+} {}
+
+ifcapable subquery {
+ do_test vtab6-9.1.1 {
+ execsql {
+ SELECT * FROM t12 NATURAL LEFT JOIN t13
+ EXCEPT
+ SELECT * FROM t12 NATURAL LEFT JOIN (SELECT * FROM t13 WHERE b>0);
+ }
+ } {}
+}
+ifcapable view {
+ do_test vtab6-9.2 {
+ execsql {
+ CREATE VIEW v13 AS SELECT * FROM t13 WHERE b>0;
+ SELECT * FROM t12 NATURAL LEFT JOIN t13
+ EXCEPT
+ SELECT * FROM t12 NATURAL LEFT JOIN v13;
+ }
+ } {}
+} ;# ifcapable view
+} ;# ifcapable compound
+
+ifcapable subquery {
+do_test vtab6-10.1 {
+ execsql {
+ CREATE INDEX i22 ON real_t22(q);
+ SELECT a FROM t21 LEFT JOIN t22 ON b=p WHERE q=
+ (SELECT max(m.q) FROM t22 m JOIN t21 n ON n.b=m.p WHERE n.c=1);
+ }
+} {}
+} ;# ifcapable subquery
+
+do_test vtab6-11.1.0 {
+ execsql {
+ CREATE TABLE ab_r(a, b);
+ CREATE TABLE bc_r(b, c);
+
+ CREATE VIRTUAL TABLE ab USING echo(ab_r);
+ CREATE VIRTUAL TABLE bc USING echo(bc_r);
+
+ INSERT INTO ab VALUES(1, 2);
+ INSERT INTO bc VALUES(2, 3);
+ }
+} {}
+
+do_test vtab6-11.1.1 {
+ execsql {
+ SELECT a, b, c FROM ab NATURAL JOIN bc;
+ }
+} {1 2 3}
+do_test vtab6-11.1.2 {
+ execsql {
+ SELECT a, b, c FROM bc NATURAL JOIN ab;
+ }
+} {1 2 3}
+
+set ::echo_module_cost 1.0
+
+do_test vtab6-11.1.3 {
+ execsql {
+ SELECT a, b, c FROM ab NATURAL JOIN bc;
+ }
+} {1 2 3}
+do_test vtab6-11.1.4 {
+ execsql {
+ SELECT a, b, c FROM bc NATURAL JOIN ab;
+ }
+} {1 2 3}
+
+
+do_test vtab6-11.2.0 {
+ execsql {
+ CREATE INDEX ab_i ON ab_r(b);
+ CREATE INDEX bc_i ON bc_r(b);
+ }
+} {}
+
+unset ::echo_module_cost
+
+do_test vtab6-11.2.1 {
+ execsql {
+ SELECT a, b, c FROM ab NATURAL JOIN bc;
+ }
+} {1 2 3}
+do_test vtab6-11.2.2 {
+ execsql {
+ SELECT a, b, c FROM bc NATURAL JOIN ab;
+ }
+} {1 2 3}
+
+set ::echo_module_cost 1.0
+
+do_test vtab6-11.2.3 {
+ execsql {
+ SELECT a, b, c FROM ab NATURAL JOIN bc;
+ }
+} {1 2 3}
+do_test vtab6-11.2.4 {
+ execsql {
+ SELECT a, b, c FROM bc NATURAL JOIN ab;
+ }
+} {1 2 3}
+
+unset ::echo_module_cost
+db close
+sqlite3 db test.db
+register_echo_module [sqlite3_connection_pointer db]
+
+do_test vtab6-11.3.1 {
+ execsql {
+ SELECT a, b, c FROM ab NATURAL JOIN bc;
+ }
+} {1 2 3}
+
+do_test vtab6-11.3.2 {
+ execsql {
+ SELECT a, b, c FROM bc NATURAL JOIN ab;
+ }
+} {1 2 3}
+
+set ::echo_module_cost 1.0
+
+do_test vtab6-11.3.3 {
+ execsql {
+ SELECT a, b, c FROM ab NATURAL JOIN bc;
+ }
+} {1 2 3}
+do_test vtab6-11.3.4 {
+ execsql {
+ SELECT a, b, c FROM bc NATURAL JOIN ab;
+ }
+} {1 2 3}
+
+unset ::echo_module_cost
+
+set ::echo_module_ignore_usable 1
+db cache flush
+
+do_test vtab6-11.4.1 {
+ catchsql {
+ SELECT a, b, c FROM ab NATURAL JOIN bc;
+ }
+} {1 {table bc: xBestIndex returned an invalid plan}}
+do_test vtab6-11.4.2 {
+ catchsql {
+ SELECT a, b, c FROM bc NATURAL JOIN ab;
+ }
+} {1 {table ab: xBestIndex returned an invalid plan}}
+
+unset ::echo_module_ignore_usable
+
+finish_test
diff --git a/test/vtab7.test b/test/vtab7.test
new file mode 100644
index 0000000..162bab5
--- /dev/null
+++ b/test/vtab7.test
@@ -0,0 +1,207 @@
+# 2006 July 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus
+# of this test is reading and writing to the database from within a
+# virtual table xSync() callback.
+#
+# $Id: vtab7.test,v 1.4 2007/12/04 16:54:53 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+# Register the echo module. Code inside the echo module appends elements
+# to the global tcl list variable ::echo_module whenever SQLite invokes
+# certain module callbacks. This includes the xSync(), xCommit() and
+# xRollback() callbacks. For each of these callback, two elements are
+# appended to ::echo_module, as follows:
+#
+# Module method Elements appended to ::echo_module
+# -------------------------------------------------------
+# xSync() xSync echo($tablename)
+# xCommit() xCommit echo($tablename)
+# xRollback() xRollback echo($tablename)
+# -------------------------------------------------------
+#
+# In each case, $tablename is replaced by the name of the real table (not
+# the echo table). By setting up a tcl trace on the ::echo_module variable,
+# code in this file arranges for a Tcl script to be executed from within
+# the echo module xSync() callback.
+#
+register_echo_module [sqlite3_connection_pointer db]
+trace add variable ::echo_module write echo_module_trace
+
+# This Tcl proc is invoked whenever the ::echo_module variable is written.
+#
+proc echo_module_trace {args} {
+ # Filter out writes to ::echo_module that are not xSync, xCommit or
+ # xRollback callbacks.
+ if {[llength $::echo_module] < 2} return
+ set x [lindex $::echo_module end-1]
+ if {$x ne "xSync" && $x ne "xCommit" && $x ne "xRollback"} return
+
+ regexp {^echo.(.*).$} [lindex $::echo_module end] dummy tablename
+ # puts "Ladies and gentlemen, an $x on $tablename!"
+
+ if {[info exists ::callbacks($x,$tablename)]} {
+ eval $::callbacks($x,$tablename)
+ }
+}
+
+# The following tests, vtab7-1.*, test that the trace callback on
+# ::echo_module is providing the expected tcl callbacks.
+do_test vtab7-1.1 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ CREATE VIRTUAL TABLE abc2 USING echo(abc);
+ }
+} {}
+
+do_test vtab7-1.2 {
+ set ::callbacks(xSync,abc) {incr ::counter}
+ set ::counter 0
+ execsql {
+ INSERT INTO abc2 VALUES(1, 2, 3);
+ }
+ set ::counter
+} {1}
+
+# Write to an existing database table from within an xSync callback.
+do_test vtab7-2.1 {
+ set ::callbacks(xSync,abc) {
+ execsql {INSERT INTO log VALUES('xSync');}
+ }
+ execsql {
+ CREATE TABLE log(msg);
+ INSERT INTO abc2 VALUES(4, 5, 6);
+ SELECT * FROM log;
+ }
+} {xSync}
+do_test vtab7-2.3 {
+ execsql {
+ INSERT INTO abc2 VALUES(4, 5, 6);
+ SELECT * FROM log;
+ }
+} {xSync xSync}
+do_test vtab7-2.4 {
+ execsql {
+ INSERT INTO abc2 VALUES(4, 5, 6);
+ SELECT * FROM log;
+ }
+} {xSync xSync xSync}
+
+# Create a database table from within xSync callback.
+do_test vtab7-2.5 {
+ set ::callbacks(xSync,abc) {
+ execsql { CREATE TABLE newtab(d, e, f); }
+ }
+ execsql {
+ INSERT INTO abc2 VALUES(1, 2, 3);
+ SELECT name FROM sqlite_master ORDER BY name;
+ }
+} {abc abc2 log newtab}
+
+# Drop a database table from within xSync callback.
+# This is not allowed. Tables cannot be dropped while
+# any other statement is active.
+#
+do_test vtab7-2.6 {
+ set ::callbacks(xSync,abc) {
+ set ::rc [catchsql { DROP TABLE newtab }]
+ }
+ execsql {
+ INSERT INTO abc2 VALUES(1, 2, 3);
+ SELECT name FROM sqlite_master ORDER BY name;
+ }
+} {abc abc2 log newtab}
+do_test vtab7-2.6.1 {
+ set ::rc
+} {1 {database table is locked}}
+execsql {DROP TABLE newtab}
+
+# Write to an attached database from xSync().
+ifcapable attach {
+ do_test vtab7-3.1 {
+ forcedelete test2.db
+ forcedelete test2.db-journal
+ execsql {
+ ATTACH 'test2.db' AS db2;
+ CREATE TABLE db2.stuff(description, shape, color);
+ }
+ set ::callbacks(xSync,abc) {
+ execsql { INSERT INTO db2.stuff VALUES('abc', 'square', 'green'); }
+ }
+ execsql {
+ INSERT INTO abc2 VALUES(1, 2, 3);
+ SELECT * from stuff;
+ }
+ } {abc square green}
+}
+
+# UPDATE: The next test passes, but leaks memory. So leave it out.
+#
+# The following tests test that writing to the database from within
+# the xCommit callback causes a misuse error.
+# do_test vtab7-4.1 {
+# unset -nocomplain ::callbacks(xSync,abc)
+# set ::callbacks(xCommit,abc) {
+# execsql { INSERT INTO log VALUES('hello') }
+# }
+# catchsql {
+# INSERT INTO abc2 VALUES(1, 2, 3);
+# }
+# } {1 {library routine called out of sequence}}
+
+# These tests, vtab7-4.*, test that an SQLITE_LOCKED error is returned
+# if an attempt to write to a virtual module table or create a new
+# virtual table from within an xSync() callback.
+do_test vtab7-4.1 {
+ execsql {
+ CREATE TABLE def(d, e, f);
+ CREATE VIRTUAL TABLE def2 USING echo(def);
+ }
+ set ::callbacks(xSync,abc) {
+ set ::error [catchsql { INSERT INTO def2 VALUES(1, 2, 3) }]
+ }
+ execsql {
+ INSERT INTO abc2 VALUES(1, 2, 3);
+ }
+ set ::error
+} {1 {database table is locked}}
+do_test vtab7-4.2 {
+ set ::callbacks(xSync,abc) {
+ set ::error [catchsql { CREATE VIRTUAL TABLE def3 USING echo(def) }]
+ }
+ execsql {
+ INSERT INTO abc2 VALUES(1, 2, 3);
+ }
+ set ::error
+} {1 {database table is locked}}
+
+do_test vtab7-4.3 {
+ set ::callbacks(xSync,abc) {
+ set ::error [catchsql { DROP TABLE def2 }]
+ }
+ execsql {
+ INSERT INTO abc2 VALUES(1, 2, 3);
+ SELECT name FROM sqlite_master ORDER BY name;
+ }
+ set ::error
+} {1 {database table is locked}}
+
+trace remove variable ::echo_module write echo_module_trace
+unset -nocomplain ::callbacks
+
+finish_test
diff --git a/test/vtab8.test b/test/vtab8.test
new file mode 100644
index 0000000..8e04a41
--- /dev/null
+++ b/test/vtab8.test
@@ -0,0 +1,78 @@
+# 2006 August 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file inserting into virtual tables from a SELECT
+# statement.
+#
+# $Id: vtab8.test,v 1.2 2007/03/02 08:12:23 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_echo_module [sqlite3_connection_pointer db]
+
+# See ticket #2244
+#
+do_test vtab1.2244-1 {
+ execsql {
+ CREATE TABLE t2244(a, b);
+ CREATE VIRTUAL TABLE t2244e USING echo(t2244);
+ INSERT INTO t2244 VALUES('AA', 'BB');
+ INSERT INTO t2244 VALUES('CC', 'DD');
+ SELECT rowid, * FROM t2244e;
+ }
+} {1 AA BB 2 CC DD}
+do_test vtab1.2244-2 {
+ execsql {
+ SELECT * FROM t2244e WHERE rowid = 10;
+ }
+} {}
+do_test vtab1.2244-3 {
+ execsql {
+ UPDATE t2244e SET a = 'hello world' WHERE 0;
+ SELECT rowid, * FROM t2244e;
+ }
+} {1 AA BB 2 CC DD}
+
+do_test vtab1-2250-2 {
+ execsql {
+ CREATE TABLE t2250(a, b);
+ INSERT INTO t2250 VALUES(10, 20);
+ CREATE VIRTUAL TABLE t2250e USING echo(t2250);
+ select max(rowid) from t2250;
+ select max(rowid) from t2250e;
+ }
+} {1 1}
+
+# See ticket #2260.
+#
+do_test vtab1.2260-1 {
+ execsql {
+ CREATE TABLE t2260a_real(a, b);
+ CREATE TABLE t2260b_real(a, b);
+
+ CREATE INDEX i2260 ON t2260a_real(a);
+ CREATE INDEX i2260x ON t2260b_real(a);
+
+ CREATE VIRTUAL TABLE t2260a USING echo(t2260a_real);
+ CREATE VIRTUAL TABLE t2260b USING echo(t2260b_real);
+
+ SELECT * FROM t2260a, t2260b WHERE t2260a.a = t2260b.a AND t2260a.a > 101;
+ }
+} {}
+
+unset -nocomplain echo_module_begin_fail
+finish_test
diff --git a/test/vtab9.test b/test/vtab9.test
new file mode 100644
index 0000000..b1290eb
--- /dev/null
+++ b/test/vtab9.test
@@ -0,0 +1,70 @@
+# 2006 August 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file inserting into virtual tables from a SELECT
+# statement.
+#
+# $Id: vtab9.test,v 1.2 2007/04/16 15:06:26 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+do_test vtab9-1.1 {
+ register_echo_module [sqlite3_connection_pointer db]
+ execsql {
+ CREATE TABLE t0(a);
+ CREATE VIRTUAL TABLE t1 USING echo(t0);
+ INSERT INTO t1 SELECT 'hello';
+ SELECT rowid, * FROM t1;
+ }
+} {1 hello}
+
+do_test vtab9-1.2 {
+ execsql {
+ CREATE TABLE t2(a,b,c);
+ CREATE VIRTUAL TABLE t3 USING echo(t2);
+ CREATE TABLE d1(a,b,c);
+ INSERT INTO d1 VALUES(1,2,3);
+ INSERT INTO d1 VALUES('a','b','c');
+ INSERT INTO d1 VALUES(NULL,'x',123.456);
+ INSERT INTO d1 VALUES(x'6869',123456789,-12345);
+ INSERT INTO t3(a,b,c) SELECT * FROM d1;
+ SELECT rowid, * FROM t3;
+ }
+} {1 1 2 3 2 a b c 3 {} x 123.456 4 hi 123456789 -12345}
+
+# do_test vtab9-2.1 {
+# execsql {
+# CREATE TABLE t4(a);
+# CREATE VIRTUAL TABLE t5 USING echo(t4);
+# INSERT INTO t4 VALUES('hello');
+# SELECT rowid, a FROM t5;
+# }
+# } {1 hello}
+# do_test vtab9-2.2 {
+# execsql {
+# INSERT INTO t5(rowid, a) VALUES(1, 'goodbye');
+# }
+# } {1 hello}
+# do_test vtab9-2.3 {
+# execsql {
+# REPLACE INTO t5(rowid, a) VALUES(1, 'goodbye');
+# SELECT * FROM t5;
+# }
+# } {1 goodbye}
+
+unset -nocomplain echo_module_begin_fail
+finish_test
diff --git a/test/vtabA.test b/test/vtabA.test
new file mode 100644
index 0000000..928cc2b
--- /dev/null
+++ b/test/vtabA.test
@@ -0,0 +1,153 @@
+# 2007 June 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is 'hidden' virtual table columns.
+#
+# $Id: vtabA.test,v 1.2 2008/07/12 14:52:21 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+proc get_decltype {table col} {
+ set STMT [sqlite3_prepare $::DB "SELECT $col FROM $table" -1 TAIL]
+ set decltype [sqlite3_column_decltype $STMT 0]
+ sqlite3_finalize $STMT
+ set decltype
+}
+
+proc get_collist {table} {
+ set ret [list]
+ db eval "PRAGMA table_info($table)" { lappend ret $name }
+ set ret
+}
+
+# Register the echo module
+register_echo_module [sqlite3_connection_pointer db]
+
+# Create a virtual table with a 'hidden' column (column b).
+#
+do_test vtabA-1.1 {
+ execsql { CREATE TABLE t1(a, b HIDDEN VARCHAR, c INTEGER) }
+} {}
+do_test vtabA-1.2 {
+ execsql { CREATE VIRTUAL TABLE t1e USING echo(t1) }
+} {}
+
+# Test that the hidden column is not listed by [PRAGMA table_info].
+#
+do_test vtabA-1.3 {
+ execsql { PRAGMA table_info(t1e) }
+} [list \
+ 0 a {} 0 {} 0 \
+ 1 c INTEGER 0 {} 0 \
+]
+
+# Test that the hidden column is not require in the default column
+# list for an INSERT statement.
+#
+do_test vtabA-1.4 {
+ catchsql {
+ INSERT INTO t1e VALUES('value a', 'value c');
+ }
+} {0 {}}
+do_test vtabA-1.5 {
+ execsql {
+ SELECT a, b, c FROM t1e;
+ }
+} {{value a} {} {value c}}
+
+do_test vtabA-1.6 {
+ execsql {
+ SELECT * FROM t1e;
+ }
+} {{value a} {value c}}
+
+# Test that the expansion of a '*' expression in the result set of
+# a SELECT does not include the hidden column.
+#
+do_test vtabA-1.7 {
+ execsql {
+ INSERT INTO t1e SELECT * FROM t1e;
+ }
+} {}
+do_test vtabA-1.8 {
+ execsql {
+ SELECT * FROM t1e;
+ }
+} {{value a} {value c} {value a} {value c}}
+
+# Test that the declaration type of the hidden column does not include
+# the token "HIDDEN".
+#
+do_test vtabA-1.9 {
+ get_decltype t1e b
+} {VARCHAR}
+do_test vtabA-1.10 {
+ get_collist t1e
+} {a c}
+
+#----------------------------------------------------------------------
+# These tests vtabA-2.* concentrate on testing that the HIDDEN token
+# is detected and handled correctly in various declarations.
+#
+proc analyse_parse {columns decltype_list} {
+ db eval { DROP TABLE IF EXISTS t1e; }
+ db eval { DROP TABLE IF EXISTS t1; }
+ db eval " CREATE TABLE t1 $columns "
+ db eval { CREATE VIRTUAL TABLE t1e USING echo(t1) }
+ set ret [list [get_collist t1e]]
+ foreach c $decltype_list {
+ lappend ret [get_decltype t1e $c]
+ }
+ set ret
+}
+
+do_test vtabA-2.1 {
+ analyse_parse {(a text, b integer hidden, c hidden)} {a b c}
+} {a text integer {}}
+
+do_test vtabA-2.2 {
+ analyse_parse {(a hidden , b integerhidden, c hidden1)} {a b c}
+} {{b c} {} integerhidden hidden1}
+
+do_test vtabA-2.3 {
+ analyse_parse {(a HiDden, b HIDDEN, c hidden)} {a b c}
+} {{} {} {} {}}
+
+do_test vtabA-2.4 {
+ analyse_parse {(a whatelse can i hidden test, b HIDDEN hidden)} {a b}
+} {{} {whatelse can i test} hidden}
+
+
+# Ticket [d2f02d37f52bfe23e421f2c60fbb8586ac76ff01]:
+# assertion failure on an UPDATE involving two virtual tables.
+#
+do_test vtabA-3.1 {
+ db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(3,4);
+ CREATE VIRTUAL TABLE vt1 USING echo(t1);
+ CREATE VIRTUAL TABLE vt2 USING echo(t2);
+ UPDATE vt2 SET x=(SELECT a FROM vt1 WHERE b=2) WHERE y=4;
+ SELECT * FROM t2;
+ }
+} {1 4}
+
+finish_test
diff --git a/test/vtabB.test b/test/vtabB.test
new file mode 100644
index 0000000..201e978
--- /dev/null
+++ b/test/vtabB.test
@@ -0,0 +1,79 @@
+# 2008 April 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is is verifying that a virtual table in the
+# TEMP database that is created and dropped within a transaction
+# is handled correctly. Ticket #2994.
+#
+# Also make sure a virtual table on the right-hand side of an IN operator
+# is materialized rather than being used directly. Ticket #3082.
+#
+
+#
+# $Id: vtabB.test,v 1.2 2008/04/25 12:10:15 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+do_test vtabB-1.1 {
+ register_echo_module [sqlite3_connection_pointer db]
+ execsql {
+ CREATE TABLE t1(x);
+ BEGIN;
+ CREATE VIRTUAL TABLE temp.echo_test1 USING echo(t1);
+ DROP TABLE echo_test1;
+ ROLLBACK;
+ }
+} {}
+
+do_test vtabB-2.1 {
+ execsql {
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ CREATE TABLE t2(y);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ CREATE VIRTUAL TABLE echo_t2 USING echo(t2);
+ SELECT * FROM t1 WHERE x IN (SELECT rowid FROM t2);
+ }
+} {2}
+do_test vtab8-2.2 {
+ execsql {
+ SELECT rowid FROM echo_t2
+ }
+} {1 2}
+do_test vtabB-2.3 {
+ execsql {
+ SELECT * FROM t1 WHERE x IN (SELECT rowid FROM t2);
+ }
+} {2}
+do_test vtabB-2.4 {
+ execsql {
+ SELECT * FROM t1 WHERE x IN (SELECT rowid FROM echo_t2);
+ }
+} {2}
+do_test vtabB-2.5 {
+ execsql {
+ SELECT * FROM t1 WHERE x IN (SELECT y FROM t2);
+ }
+} {2}
+do_test vtabB-2.6 {
+ execsql {
+ SELECT * FROM t1 WHERE x IN (SELECT y FROM echo_t2);
+ }
+} {2}
+
+finish_test
diff --git a/test/vtabC.test b/test/vtabC.test
new file mode 100644
index 0000000..ca78b70
--- /dev/null
+++ b/test/vtabC.test
@@ -0,0 +1,116 @@
+# 2008 April 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is is verifying that the xUpdate, xSync, xCommit
+# and xRollback methods are only invoked after an xBegin or xCreate.
+# Ticket #3083.
+#
+# $Id: vtabC.test,v 1.2 2009/04/07 14:14:23 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+ifcapable !trigger { finish_test ; return }
+
+
+# N will be the number of virtual tables we have defined.
+#
+unset -nocomplain N
+for {set N 1} {$N<=20} {incr N} {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ register_echo_module [sqlite3_connection_pointer db]
+
+ # Create $N tables and $N virtual tables to echo them.
+ #
+ unset -nocomplain tablist
+ set tablist {}
+ do_test vtabC-1.$N.1 {
+ for {set i 1} {$i<=$::N} {incr i} {
+ execsql "CREATE TABLE t${i}(x)"
+ execsql "CREATE VIRTUAL TABLE vt$i USING echo(t$i)"
+ lappend ::tablist t$i vt$i
+ }
+ execsql {SELECT count(*) FROM sqlite_master}
+ } [expr {$N*2}]
+ do_test vtabC-1.$N.2 {
+ execsql {SELECT name FROM sqlite_master}
+ } $tablist
+
+ # Create a table m and add triggers to make changes on all
+ # of the virtual tables when m is changed.
+ #
+ do_test vtabC-1.$N.3 {
+ execsql {CREATE TABLE m(a)}
+ set sql "CREATE TRIGGER rins AFTER INSERT ON m BEGIN\n"
+ for {set i 1} {$i<=$::N} {incr i} {
+ append sql " INSERT INTO vt$i VALUES(NEW.a+$i);\n"
+ }
+ append sql "END;"
+ execsql $sql
+ execsql {SELECT count(*) FROM sqlite_master}
+ } [expr {$N*2+2}]
+ do_test vtabC-1.$N.4 {
+ execsql {
+ INSERT INTO m VALUES(1000);
+ SELECT * FROM m;
+ }
+ } {1000}
+ for {set j 1} {$j<=$::N} {incr j} {
+ do_test vtabC-1.$N.5.$j {
+ execsql "SELECT * FROM t$::j"
+ } [expr {$j+1000}]
+ do_test vtabC-1.$N.6.$j {
+ execsql "SELECT * FROM vt$::j"
+ } [expr {$j+1000}]
+ }
+ do_test vtabC-1.$N.7 {
+ set sql "CREATE TRIGGER rins2 BEFORE INSERT ON m BEGIN\n"
+ for {set i 1} {$i<=$::N} {incr i} {
+ append sql " INSERT INTO vt$i VALUES(NEW.a+$i*100);\n"
+ }
+ for {set i 1} {$i<=$::N} {incr i} {
+ append sql " INSERT INTO vt$i VALUES(NEW.a+$i*10000);\n"
+ }
+ append sql "END;"
+ execsql $sql
+ execsql {SELECT count(*) FROM sqlite_master}
+ } [expr {$N*2+3}]
+ do_test vtabC-1.$N.8 {
+ execsql {
+ INSERT INTO m VALUES(9000000);
+ SELECT * FROM m;
+ }
+ } {1000 9000000}
+ unset -nocomplain res
+ for {set j 1} {$j<=$::N} {incr j} {
+ set res [expr {$j+1000}]
+ lappend res [expr {$j*100+9000000}]
+ lappend res [expr {$j*10000+9000000}]
+ lappend res [expr {$j+9000000}]
+ do_test vtabC-1.$N.9.$j {
+ execsql "SELECT * FROM t$::j"
+ } $res
+ do_test vtabC-1.$N.10.$j {
+ execsql "SELECT * FROM vt$::j"
+ } $res
+ }
+}
+unset -nocomplain res N i j
+
+
+finish_test
diff --git a/test/vtabD.test b/test/vtabD.test
new file mode 100644
index 0000000..509ba45
--- /dev/null
+++ b/test/vtabD.test
@@ -0,0 +1,71 @@
+# 2009 April 14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is creating and dropping virtual tables.
+#
+# $Id: vtabD.test,v 1.3 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab||!schema_pragmas { finish_test ; return }
+
+# Register the echo module
+register_echo_module [sqlite3_connection_pointer db]
+
+do_test vtabD-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+ CREATE VIRTUAL TABLE tv1 USING echo(t1);
+ }
+} {}
+do_test vtabD-1.2 {
+ execsql BEGIN
+ for {set i 0} {$i < 100000} {incr i} {
+ execsql { INSERT INTO t1 VALUES($i, $i*$i) }
+ }
+ execsql COMMIT
+} {}
+do_test vtabD-1.3 {
+ execsql { SELECT * FROM tv1 WHERE a = 1 OR b = 4 }
+} {1 1 2 4}
+do_test vtabD-1.4 {
+ execsql { SELECT * FROM tv1 WHERE a = 1 OR b = 1 }
+} {1 1}
+do_test vtabD-1.5 {
+ execsql { SELECT * FROM tv1 WHERE (a > 0 AND a < 5) OR (b > 15 AND b < 65) }
+} {1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64}
+
+do_test vtabD-1.6 {
+ execsql { SELECT * FROM tv1 WHERE a < 500 OR b = 810000 }
+} [execsql {
+ SELECT * FROM t1 WHERE a < 500
+ UNION ALL
+ SELECT * FROM t1 WHERE b = 810000 AND NOT (a < 500)
+}]
+
+do_test vtabD-1.7 {
+ execsql { SELECT * FROM tv1 WHERE a < 90000 OR b = 8100000000 }
+} [execsql {
+ SELECT * FROM t1 WHERE a < 90000
+ UNION ALL
+ SELECT * FROM t1 WHERE b = 8100000000 AND NOT (a < 90000)
+}]
+
+if {[working_64bit_int]} {
+do_test vtabD-1.8 {
+ execsql { SELECT * FROM tv1 WHERE a = 90001 OR b = 810000 }
+} {90001 8100180001 900 810000}
+}
+
+finish_test
diff --git a/test/vtabE.test b/test/vtabE.test
new file mode 100644
index 0000000..22ec018
--- /dev/null
+++ b/test/vtabE.test
@@ -0,0 +1,48 @@
+# 2009 November 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# The focus of this file making sure the register cache logic works
+# correctly with virtual tables. Ticket [16fbf14cb2].
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_tclvar_module [sqlite3_connection_pointer db]
+
+unset -nocomplain vtabE
+set vtabE(vtabE1) 11
+set vtabE(vtabE2) 22
+unset -nocomplain vtabE1
+set vtabE1(w) x
+set vtabE1(y) z
+unset -nocomplain vtabE2
+set vtabE2(a) b
+set vtabE2(c) d
+
+do_test vtabE-1 {
+ db eval {
+ CREATE VIRTUAL TABLE t1 USING tclvar;
+ CREATE VIRTUAL TABLE t2 USING tclvar;
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
+ SELECT t1.*, t2.*, abs(t3.b + abs(t2.value + abs(t1.value)))
+ FROM t1 LEFT JOIN t2 ON t2.name = t1.arrayname
+ LEFT JOIN t3 ON t3.a=t2.value
+ WHERE t1.name = 'vtabE'
+ ORDER BY t1.value, t2.value;
+ }
+} {vtabE vtabE1 11 vtabE1 w x {} vtabE vtabE1 11 vtabE1 y z {} vtabE vtabE2 22 vtabE2 a b {} vtabE vtabE2 22 vtabE2 c d {}}
diff --git a/test/vtabF.test b/test/vtabF.test
new file mode 100644
index 0000000..b9341ea
--- /dev/null
+++ b/test/vtabF.test
@@ -0,0 +1,45 @@
+# 2011 Aug 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+# This file checks to make sure IS NOT NULL constraints work on
+# virtual tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab||!schema_pragmas { finish_test ; return }
+
+# Register the echo module
+register_echo_module [sqlite3_connection_pointer db]
+
+do_test vtabE-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+ INSERT INTO t1 VALUES(10,110);
+ INSERT INTO t1 VALUES(11,111);
+ INSERT INTO t1 SELECT a+2, b+2 FROM t1;
+ INSERT INTO t1 SELECT null, b+4 FROM t1;
+ INSERT INTO t1 SELECT null, b+8 FROM t1;
+ INSERT INTO t1 SELECT null, b+16 FROM t1;
+ ANALYZE;
+ CREATE VIRTUAL TABLE tv1 USING echo(t1);
+ SELECT b FROM t1 WHERE a IS NOT NULL;
+ }
+} {110 111 112 113}
+do_test vtabE-1.2 {
+ execsql {SELECT b FROM tv1 WHERE a IS NOT NULL}
+} {110 111 112 113}
+
+
+finish_test
diff --git a/test/vtab_alter.test b/test/vtab_alter.test
new file mode 100644
index 0000000..eb50a28
--- /dev/null
+++ b/test/vtab_alter.test
@@ -0,0 +1,103 @@
+# 2007 June 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the ALTER TABLE ... RENAME TO
+# command on virtual tables.
+#
+# $Id: vtab_alter.test,v 1.3 2007/12/13 21:54:11 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab||!altertable {
+ finish_test
+ return
+}
+
+# Register the echo module.
+#
+# This test uses a special feature of the echo module. If the name
+# of the virtual table is a prefix of the name of the underlying
+# real table (for example if the v-table is "tbl" and the real table
+# is "tbl_base"), then the name of the real table is modified
+# when an "ALTER TABLE ... RENAME TO" is executed on the v-table.
+# For example:
+#
+# sqlite> CREATE TABLE t1_base(a, b, c);
+# sqlite> CREATE VIRTUAL TABLE t1 USING(t1_base);
+# sqlite> ALTER TABLE t1 RENAME TO t2;
+# sqlite> SELECT tbl_name FROM sqlite_master;
+# t2_base
+# t2
+#
+register_echo_module [sqlite3_connection_pointer db]
+
+
+# Try to rename an echo table. Make sure nothing terrible happens.
+#
+do_test vtab_alter-1.1 {
+ execsql { CREATE TABLE t1(a, b VARCHAR, c INTEGER) }
+} {}
+do_test vtab_alter-1.2 {
+ execsql { CREATE VIRTUAL TABLE t1echo USING echo(t1) }
+} {}
+do_test vtab_alter-1.3 {
+ catchsql { SELECT * FROM t1echo }
+} {0 {}}
+do_test vtab_alter-1.4 {
+ execsql { ALTER TABLE t1echo RENAME TO new }
+} {}
+do_test vtab_alter-1.5 {
+ catchsql { SELECT * FROM t1echo }
+} {1 {no such table: t1echo}}
+do_test vtab_alter-1.6 {
+ catchsql { SELECT * FROM new }
+} {0 {}}
+
+# Try to rename an echo table that renames its base table. Make
+# sure nothing terrible happens.
+#
+do_test vtab_alter-2.1 {
+ execsql {
+ DROP TABLE new;
+ DROP TABLE t1;
+ CREATE TABLE t1_base(a, b, c);
+ CREATE VIRTUAL TABLE t1 USING echo('*_base');
+ }
+} {}
+do_test vtab_alter-2.2 {
+ execsql {
+ INSERT INTO t1_base VALUES(1, 2, 3);
+ SELECT * FROM t1;
+ }
+} {1 2 3}
+do_test vtab_alter-2.3 {
+ execsql { ALTER TABLE t1 RENAME TO x }
+} {}
+do_test vtab_alter-2.4 {
+ execsql { SELECT * FROM x; }
+} {1 2 3}
+do_test vtab_alter-2.5 {
+ execsql { SELECT * FROM x_base; }
+} {1 2 3}
+
+# Cause an error to occur when the echo module renames its
+# backing store table.
+#
+do_test vtab_alter-3.1 {
+ execsql { CREATE TABLE y_base(a, b, c) }
+ catchsql { ALTER TABLE x RENAME TO y }
+} {1 {SQL logic error or missing database}}
+do_test vtab_alter-3.2 {
+ execsql { SELECT * FROM x }
+} {1 2 3}
+
+finish_test
diff --git a/test/vtab_err.test b/test/vtab_err.test
new file mode 100644
index 0000000..068386e
--- /dev/null
+++ b/test/vtab_err.test
@@ -0,0 +1,71 @@
+# 2006 June 10
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# $Id: vtab_err.test,v 1.8 2007/09/03 16:12:10 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+
+
+unset -nocomplain echo_module_begin_fail
+do_ioerr_test vtab_err-1 -tclprep {
+ register_echo_module [sqlite3_connection_pointer db]
+} -sqlbody {
+ BEGIN;
+ CREATE TABLE r(a PRIMARY KEY, b, c);
+ CREATE VIRTUAL TABLE e USING echo(r);
+ INSERT INTO e VALUES(1, 2, 3);
+ INSERT INTO e VALUES('a', 'b', 'c');
+ UPDATE e SET c = 10;
+ DELETE FROM e WHERE a = 'a';
+ COMMIT;
+ BEGIN;
+ CREATE TABLE r2(a, b, c);
+ INSERT INTO r2 SELECT * FROM e;
+ INSERT INTO e SELECT a||'x', b, c FROM r2;
+ COMMIT;
+}
+
+ifcapable !memdebug {
+ puts "Skipping vtab_err-2 tests: not compiled with -DSQLITE_MEMDEBUG..."
+ finish_test
+ return
+}
+source $testdir/malloc_common.tcl
+
+
+do_malloc_test vtab_err-2 -tclprep {
+ register_echo_module [sqlite3_connection_pointer db]
+} -sqlbody {
+ BEGIN;
+ CREATE TABLE r(a PRIMARY KEY, b, c);
+ CREATE VIRTUAL TABLE e USING echo(r);
+ INSERT INTO e VALUES(1, 2, 3);
+ INSERT INTO e VALUES('a', 'b', 'c');
+ UPDATE e SET c = 10;
+ DELETE FROM e WHERE a = 'a';
+ COMMIT;
+ BEGIN;
+ CREATE TABLE r2(a, b, c);
+ INSERT INTO r2 SELECT * FROM e;
+ INSERT INTO e SELECT a||'x', b, c FROM r2;
+ COMMIT;
+}
+
+sqlite3_memdebug_fail -1
+
+finish_test
diff --git a/test/vtab_shared.test b/test/vtab_shared.test
new file mode 100644
index 0000000..ce2e432
--- /dev/null
+++ b/test/vtab_shared.test
@@ -0,0 +1,231 @@
+# 2007 April 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file tests interactions between the virtual table and
+# shared-schema functionality.
+#
+# $Id: vtab_shared.test,v 1.3 2009/07/24 17:58:53 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab||!shared_cache {
+ finish_test
+ return
+}
+
+db close
+sqlite3_enable_shared_cache 1
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+do_test vtab_shared-1.1 {
+ register_echo_module [sqlite3_connection_pointer db]
+ execsql {
+ CREATE TABLE t0(a, b, c);
+ INSERT INTO t0 VALUES(1, 2, 3);
+ CREATE VIRTUAL TABLE t1 USING echo(t0);
+ }
+} {}
+
+do_test vtab_shared-1.2 {
+ execsql { SELECT * FROM t1 } db
+} {1 2 3}
+
+# Fails because the 'echo' module has not been registered with connection db2
+do_test vtab_shared-1.3 {
+ catchsql { SELECT * FROM t1 } db2
+} {1 {no such module: echo}}
+
+do_test vtab_shared-1.4 {
+ execsql { SELECT * FROM t0 } db2
+} {1 2 3}
+
+do_test vtab_shared-1.5 {
+ register_echo_module [sqlite3_connection_pointer db2]
+ execsql { SELECT * FROM t1 } db
+} {1 2 3}
+
+# Works after the module is registered with db2
+do_test vtab_shared-1.6 {
+ execsql { SELECT * FROM t1 } db2
+} {1 2 3}
+
+# Set a write-lock on table t0 using connection [db]. Then try to read from
+# virtual table t1 using [db2]. That this returns an SQLITE_LOCKED error
+# shows that the correct sqlite3_vtab is being used.
+#
+do_test vtab_shared-1.8.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(4, 5, 6);
+ SELECT * FROM t1;
+ }
+} {1 2 3 4 5 6}
+do_test vtab_shared-1.8.2 {
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database table is locked}}
+do_test vtab_shared-1.8.3 {
+ catchsql { SELECT * FROM t0 } db2
+} {1 {database table is locked: t0}}
+do_test vtab_shared-1.8.4 {
+ execsql { SELECT * FROM t0 } db
+} {1 2 3 4 5 6}
+do_test vtab_shared-1.8.5 {
+ execsql { COMMIT } db
+ execsql { SELECT * FROM t1 } db2
+} {1 2 3 4 5 6}
+
+# While a SELECT is active on virtual table t1 via connection [db], close
+# [db2]. This causes the schema to be reset internally. Verify that this
+# does not cause a problem.
+#
+foreach {iTest dbSelect dbClose} {
+ 1 db db2
+ 2 db db2
+ 3 db2 db
+} {
+ do_test vtab_shared-1.9.$iTest {
+ set res [list]
+ $dbSelect eval { SELECT * FROM t1 } {
+ if {$a == 1} {$dbClose close}
+ lappend res $a $b $c
+ }
+ sqlite3 $dbClose test.db
+ register_echo_module [sqlite3_connection_pointer $dbClose]
+ set res
+ } {1 2 3 4 5 6}
+}
+
+# Ensure that it is not possible for one connection to DROP a virtual
+# table while a second connection is reading from the database.
+#
+do_test vtab_shared-1.10 {
+ db eval { SELECT * FROM t1 } {
+ set error [catchsql { DROP TABLE t1 } db2]
+ break
+ }
+ set error
+} {1 {database table is locked: sqlite_master}}
+
+do_test vtab_shared-1.11 {
+breakpoint
+ execsql {
+ CREATE VIRTUAL TABLE t2 USING echo(t0);
+ CREATE VIRTUAL TABLE t3 USING echo(t0);
+ }
+ execsql { SELECT * FROM t3 } db2
+} {1 2 3 4 5 6}
+
+do_test vtab_shared-1.12.1 {
+ db close
+ execsql {
+ SELECT * FROM t1 UNION ALL
+ SELECT * FROM t2 UNION ALL
+ SELECT * FROM t3
+ } db2
+} {1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6}
+do_test vtab_shared-1.12.2 {
+ sqlite3 db test.db
+ register_echo_module [sqlite3_connection_pointer db]
+ execsql {
+ SELECT * FROM t1 UNION ALL
+ SELECT * FROM t2 UNION ALL
+ SELECT * FROM t3
+ } db
+} {1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6}
+
+# Try a rename or two.
+#
+ifcapable altertable {
+ do_test vtab_shared-1.13.1 {
+ execsql { ALTER TABLE t1 RENAME TO t4 }
+ execsql { SELECT * FROM t4 } db
+ } {1 2 3 4 5 6}
+ do_test vtab_shared-1.13.2 {
+ execsql { SELECT * FROM t4 } db2
+ } {1 2 3 4 5 6}
+ do_test vtab_shared-1.13.3 {
+ execsql { ALTER TABLE t2 RENAME TO t5 }
+ execsql { SELECT * FROM t4 } db2
+ } {1 2 3 4 5 6}
+}
+
+# Try an UPDATE/INSERT/DELETE on a shared vtab as the first statement after a
+# schema is loaded.
+do_test vtab_shared_1.14.1 {
+ db2 close
+ sqlite3 db2 test.db
+ register_echo_module [sqlite3_connection_pointer db2]
+ execsql { SELECT * FROM t3 }
+} {1 2 3 4 5 6}
+do_test vtab_shared_1.14.2 {
+ execsql {
+ UPDATE t3 SET c = 'six' WHERE c = 6;
+ SELECT * FROM t3;
+ } db2
+} {1 2 3 4 5 six}
+do_test vtab_shared_1.14.3 {
+ db2 close
+ sqlite3 db2 test.db
+ register_echo_module [sqlite3_connection_pointer db2]
+ execsql { SELECT * FROM t3 }
+} {1 2 3 4 5 six}
+do_test vtab_shared_1.14.4 {
+ execsql {
+ DELETE FROM t3 WHERE c = 'six';
+ SELECT * FROM t3;
+ } db2
+} {1 2 3}
+do_test vtab_shared_1.14.5 {
+ db2 close
+ sqlite3 db2 test.db
+ register_echo_module [sqlite3_connection_pointer db2]
+ execsql { SELECT * FROM t3 }
+} {1 2 3}
+do_test vtab_shared_1.14.6 {
+ execsql {
+ INSERT INTO t3 VALUES(4, 5, 6);
+ SELECT * FROM t3;
+ } db2
+} {1 2 3 4 5 6}
+
+do_test vtab_shared_1.15.1 {
+ db2 close
+ sqlite3 db2 test.db
+ register_echo_module [sqlite3_connection_pointer db2]
+ execsql {
+ UPDATE t3 SET c = 'six' WHERE c = 6;
+ SELECT * FROM t3;
+ } db2
+} {1 2 3 4 5 six}
+do_test vtab_shared_1.15.2 {
+ db2 close
+ sqlite3 db2 test.db
+ register_echo_module [sqlite3_connection_pointer db2]
+ execsql {
+ DELETE FROM t3 WHERE c = 'six';
+ SELECT * FROM t3;
+ } db2
+} {1 2 3}
+do_test vtab_shared_1.15.3 {
+ db2 close
+ sqlite3 db2 test.db
+ register_echo_module [sqlite3_connection_pointer db2]
+ execsql {
+ INSERT INTO t3 VALUES(4, 5, 6);
+ SELECT * FROM t3;
+ }
+} {1 2 3 4 5 6}
+
+db close
+db2 close
+sqlite3_enable_shared_cache 0
+finish_test
diff --git a/test/wal.test b/test/wal.test
new file mode 100644
index 0000000..056becf
--- /dev/null
+++ b/test/wal.test
@@ -0,0 +1,1563 @@
+# 2010 April 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+source $testdir/wal_common.tcl
+
+set testprefix wal
+
+ifcapable !wal {finish_test ; return }
+
+proc reopen_db {} {
+ catch { db close }
+ forcedelete test.db test.db-wal test.db-wal-summary
+ sqlite3_wal db test.db
+}
+
+set ::blobcnt 0
+proc blob {nByte} {
+ incr ::blobcnt
+ return [string range [string repeat "${::blobcnt}x" $nByte] 1 $nByte]
+}
+
+proc sqlite3_wal {args} {
+ eval sqlite3 $args
+ [lindex $args 0] eval { PRAGMA auto_vacuum = 0 }
+ [lindex $args 0] eval { PRAGMA page_size = 1024 }
+ [lindex $args 0] eval { PRAGMA journal_mode = wal }
+ [lindex $args 0] eval { PRAGMA synchronous = normal }
+ [lindex $args 0] function blob blob
+}
+
+proc log_deleted {logfile} {
+ return [expr [file exists $logfile]==0]
+}
+
+#
+# These are 'warm-body' tests used while developing the WAL code. They
+# serve to prove that a few really simple cases work:
+#
+# wal-1.*: Read and write the database.
+# wal-2.*: Test MVCC with one reader, one writer.
+# wal-3.*: Test transaction rollback.
+# wal-4.*: Test savepoint/statement rollback.
+# wal-5.*: Test the temp database.
+# wal-6.*: Test creating databases with different page sizes.
+#
+#
+#
+do_test wal-0.1 {
+ execsql { PRAGMA auto_vacuum = 0 }
+ execsql { PRAGMA synchronous = normal }
+ execsql { PRAGMA journal_mode = wal }
+} {wal}
+do_test wal-0.2 {
+ file size test.db
+} {1024}
+
+do_test wal-1.0 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ }
+ list [file exists test.db-journal] \
+ [file exists test.db-wal] \
+ [file size test.db]
+} {0 1 1024}
+do_test wal-1.1 {
+ execsql COMMIT
+ list [file exists test.db-journal] [file exists test.db-wal]
+} {0 1}
+do_test wal-1.2 {
+ # There are now two pages in the log.
+ file size test.db-wal
+} [wal_file_size 2 1024]
+
+do_test wal-1.3 {
+ execsql { SELECT * FROM sqlite_master }
+} {table t1 t1 2 {CREATE TABLE t1(a, b)}}
+
+do_test wal-1.4 {
+ execsql { INSERT INTO t1 VALUES(1, 2) }
+ execsql { INSERT INTO t1 VALUES(3, 4) }
+ execsql { INSERT INTO t1 VALUES(5, 6) }
+ execsql { INSERT INTO t1 VALUES(7, 8) }
+ execsql { INSERT INTO t1 VALUES(9, 10) }
+} {}
+
+do_test wal-1.5 {
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4 5 6 7 8 9 10}
+
+do_test wal-2.1 {
+ sqlite3_wal db2 ./test.db
+ execsql { BEGIN; SELECT * FROM t1 } db2
+} {1 2 3 4 5 6 7 8 9 10}
+
+do_test wal-2.2 {
+ execsql { INSERT INTO t1 VALUES(11, 12) }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+
+do_test wal-2.3 {
+ execsql { SELECT * FROM t1 } db2
+} {1 2 3 4 5 6 7 8 9 10}
+
+do_test wal-2.4 {
+ execsql { INSERT INTO t1 VALUES(13, 14) }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
+
+do_test wal-2.5 {
+ execsql { SELECT * FROM t1 } db2
+} {1 2 3 4 5 6 7 8 9 10}
+
+do_test wal-2.6 {
+ execsql { COMMIT; SELECT * FROM t1 } db2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
+
+do_test wal-3.1 {
+ execsql { BEGIN; DELETE FROM t1 }
+ execsql { SELECT * FROM t1 }
+} {}
+do_test wal-3.2 {
+ execsql { SELECT * FROM t1 } db2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
+do_test wal-3.3 {
+ execsql { ROLLBACK }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
+db2 close
+
+#-------------------------------------------------------------------------
+# The following tests, wal-4.*, test that savepoints work with WAL
+# databases.
+#
+do_test wal-4.1 {
+ execsql {
+ DELETE FROM t1;
+ BEGIN;
+ INSERT INTO t1 VALUES('a', 'b');
+ SAVEPOINT sp;
+ INSERT INTO t1 VALUES('c', 'd');
+ SELECT * FROM t1;
+ }
+} {a b c d}
+do_test wal-4.2 {
+ execsql {
+ ROLLBACK TO sp;
+ SELECT * FROM t1;
+ }
+} {a b}
+do_test wal-4.3 {
+ execsql {
+ COMMIT;
+ SELECT * FROM t1;
+ }
+} {a b}
+
+do_test wal-4.4.1 {
+ db close
+ sqlite3 db test.db
+ db func blob blob
+ list [execsql { SELECT * FROM t1 }] [file size test.db-wal]
+} {{a b} 0}
+do_test wal-4.4.2 {
+ execsql { PRAGMA cache_size = 10 }
+ execsql {
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES(blob(400), blob(400));
+ SAVEPOINT tr;
+ INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 2 */
+ INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 4 */
+ INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 8 */
+ INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 16 */
+ INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 32 */
+ INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 32 */
+ SELECT count(*) FROM t2;
+ }
+} {32}
+do_test wal-4.4.3 {
+ execsql { ROLLBACK TO tr }
+} {}
+do_test wal-4.4.4 {
+ set logsize [file size test.db-wal]
+ execsql {
+ INSERT INTO t1 VALUES('x', 'y');
+ RELEASE tr;
+ }
+ expr { $logsize == [file size test.db-wal] }
+} {1}
+do_test wal-4.4.5 {
+ execsql { SELECT count(*) FROM t2 }
+} {1}
+do_test wal-4.4.6 {
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+ sqlite3 db2 test2.db
+ execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 } db2
+} {1 2}
+do_test wal-4.4.7 {
+ execsql { PRAGMA integrity_check } db2
+} {ok}
+db2 close
+
+do_test wal-4.5.1 {
+ reopen_db
+ db func blob blob
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('a', 'b');
+ }
+ sqlite3 db test.db
+ db func blob blob
+ list [execsql { SELECT * FROM t1 }] [file size test.db-wal]
+} {{a b} 0}
+do_test wal-4.5.2 {
+ execsql { PRAGMA cache_size = 10 }
+ execsql {
+ CREATE TABLE t2(a, b);
+ BEGIN;
+ INSERT INTO t2 VALUES(blob(400), blob(400));
+ SAVEPOINT tr;
+ INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 2 */
+ INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 4 */
+ INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 8 */
+ INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 16 */
+ INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 32 */
+ INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 32 */
+ SELECT count(*) FROM t2;
+ }
+} {32}
+do_test wal-4.5.3 {
+ execsql { ROLLBACK TO tr }
+} {}
+do_test wal-4.5.4 {
+ set logsize [file size test.db-wal]
+ execsql {
+ INSERT INTO t1 VALUES('x', 'y');
+ RELEASE tr;
+ COMMIT;
+ }
+ expr { $logsize == [file size test.db-wal] }
+} {1}
+do_test wal-4.5.5 {
+ execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 }
+} {1 2}
+do_test wal-4.5.6 {
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+ sqlite3 db2 test2.db
+ execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 } db2
+} {1 2}
+do_test wal-4.5.7 {
+ execsql { PRAGMA integrity_check } db2
+} {ok}
+db2 close
+
+do_test wal-4.6.1 {
+ execsql {
+ DELETE FROM t2;
+ PRAGMA wal_checkpoint;
+ BEGIN;
+ INSERT INTO t2 VALUES('w', 'x');
+ SAVEPOINT save;
+ INSERT INTO t2 VALUES('y', 'z');
+ ROLLBACK TO save;
+ COMMIT;
+ }
+ execsql { SELECT * FROM t2 }
+} {w x}
+
+
+reopen_db
+do_test wal-5.1 {
+ execsql {
+ CREATE TEMP TABLE t2(a, b);
+ INSERT INTO t2 VALUES(1, 2);
+ }
+} {}
+do_test wal-5.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO t2 VALUES(3, 4);
+ SELECT * FROM t2;
+ }
+} {1 2 3 4}
+do_test wal-5.3 {
+ execsql {
+ ROLLBACK;
+ SELECT * FROM t2;
+ }
+} {1 2}
+do_test wal-5.4 {
+ execsql {
+ CREATE TEMP TABLE t3(x UNIQUE);
+ BEGIN;
+ INSERT INTO t2 VALUES(3, 4);
+ INSERT INTO t3 VALUES('abc');
+ }
+ catchsql { INSERT INTO t3 VALUES('abc') }
+} {1 {column x is not unique}}
+do_test wal-5.5 {
+ execsql {
+ COMMIT;
+ SELECT * FROM t2;
+ }
+} {1 2 3 4}
+db close
+
+foreach sector {512 4096} {
+ sqlite3_simulate_device -sectorsize $sector
+ foreach pgsz {512 1024 2048 4096} {
+ forcedelete test.db test.db-wal
+ do_test wal-6.$sector.$pgsz.1 {
+ sqlite3 db test.db -vfs devsym
+ execsql "
+ PRAGMA page_size = $pgsz;
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = wal;
+ "
+ execsql "
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ "
+ db close
+ file size test.db
+ } [expr $pgsz*2]
+
+ do_test wal-6.$sector.$pgsz.2 {
+ log_deleted test.db-wal
+ } {1}
+ }
+}
+
+do_test wal-7.1 {
+ forcedelete test.db test.db-wal
+ sqlite3_wal db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ list [file size test.db] [file size test.db-wal]
+} [list 1024 [wal_file_size 3 1024]]
+do_test wal-7.2 {
+ execsql { PRAGMA wal_checkpoint }
+ list [file size test.db] [file size test.db-wal]
+} [list 2048 [wal_file_size 3 1024]]
+
+# Execute some transactions in auto-vacuum mode to test database file
+# truncation.
+#
+do_test wal-8.1 {
+ reopen_db
+ catch { db close }
+ forcedelete test.db test.db-wal
+
+ sqlite3 db test.db
+ db function blob blob
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA journal_mode = wal;
+ PRAGMA auto_vacuum;
+ }
+} {wal 1}
+do_test wal-8.2 {
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(blob(900));
+ INSERT INTO t1 VALUES(blob(900));
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 64 */
+ PRAGMA wal_checkpoint;
+ }
+ file size test.db
+} [expr 68*1024]
+do_test wal-8.3 {
+ execsql {
+ DELETE FROM t1 WHERE rowid<54;
+ PRAGMA wal_checkpoint;
+ }
+ file size test.db
+} [expr 14*1024]
+
+# Run some "warm-body" tests to ensure that log-summary files with more
+# than 256 entries (log summaries that contain index blocks) work Ok.
+#
+do_test wal-9.1 {
+ reopen_db
+ execsql {
+ CREATE TABLE t1(x PRIMARY KEY);
+ INSERT INTO t1 VALUES(blob(900));
+ INSERT INTO t1 VALUES(blob(900));
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 64 */
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 128 */
+ INSERT INTO t1 SELECT blob(900) FROM t1; /* 256 */
+ }
+ file size test.db
+} 1024
+do_test wal-9.2 {
+ sqlite3_wal db2 test.db
+ execsql {PRAGMA integrity_check } db2
+} {ok}
+
+do_test wal-9.3 {
+ forcedelete test2.db test2.db-wal
+ copy_file test.db test2.db
+ copy_file test.db-wal test2.db-wal
+ sqlite3_wal db3 test2.db
+ execsql {PRAGMA integrity_check } db3
+} {ok}
+db3 close
+
+do_test wal-9.4 {
+ execsql { PRAGMA wal_checkpoint }
+ db2 close
+ sqlite3_wal db2 test.db
+ execsql {PRAGMA integrity_check } db2
+} {ok}
+
+foreach handle {db db2 db3} { catch { $handle close } }
+unset handle
+
+#-------------------------------------------------------------------------
+# The following block of tests - wal-10.* - test that the WAL locking
+# scheme works in simple cases. This block of tests is run twice. Once
+# using multiple connections in the address space of the current process,
+# and once with all connections except one running in external processes.
+#
+do_multiclient_test tn {
+
+ # Initialize the database schema and contents.
+ #
+ do_test wal-10.$tn.1 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ SELECT * FROM t1;
+ }
+ } {wal 1 2}
+
+ # Open a transaction and write to the database using [db]. Check that [db2]
+ # is still able to read the snapshot before the transaction was opened.
+ #
+ do_test wal-10.$tn.2 {
+ execsql { BEGIN; INSERT INTO t1 VALUES(3, 4); }
+ sql2 {SELECT * FROM t1}
+ } {1 2}
+
+ # Have [db] commit the transaction. Check that [db2] is now seeing the
+ # new, updated snapshot.
+ #
+ do_test wal-10.$tn.3 {
+ execsql { COMMIT }
+ sql2 {SELECT * FROM t1}
+ } {1 2 3 4}
+
+ # Have [db2] open a read transaction. Then write to the db via [db]. Check
+ # that [db2] is still seeing the original snapshot. Then read with [db3].
+ # [db3] should see the newly committed data.
+ #
+ do_test wal-10.$tn.4 {
+ sql2 { BEGIN ; SELECT * FROM t1}
+ } {1 2 3 4}
+ do_test wal-10.$tn.5 {
+ execsql { INSERT INTO t1 VALUES(5, 6); }
+ sql2 {SELECT * FROM t1}
+ } {1 2 3 4}
+ do_test wal-10.$tn.6 {
+ sql3 {SELECT * FROM t1}
+ } {1 2 3 4 5 6}
+ do_test wal-10.$tn.7 {
+ sql2 COMMIT
+ } {}
+
+ # Have [db2] open a write transaction. Then attempt to write to the
+ # database via [db]. This should fail (writer lock cannot be obtained).
+ #
+ # Then open a read-transaction with [db]. Commit the [db2] transaction
+ # to disk. Verify that [db] still cannot write to the database (because
+ # it is reading an old snapshot).
+ #
+ # Close the current [db] transaction. Open a new one. [db] can now write
+ # to the database (as it is not locked and [db] is reading the latest
+ # snapshot).
+ #
+ do_test wal-10.$tn.7 {
+ sql2 { BEGIN; INSERT INTO t1 VALUES(7, 8) ; }
+ catchsql { INSERT INTO t1 VALUES(9, 10) }
+ } {1 {database is locked}}
+ do_test wal-10.$tn.8 {
+ execsql { BEGIN ; SELECT * FROM t1 }
+ } {1 2 3 4 5 6}
+ do_test wal-10.$tn.9 {
+ sql2 COMMIT
+ catchsql { INSERT INTO t1 VALUES(9, 10) }
+ } {1 {database is locked}}
+ do_test wal-10.$tn.10 {
+ execsql { COMMIT }
+ execsql { BEGIN }
+ execsql { INSERT INTO t1 VALUES(9, 10) }
+ execsql { COMMIT }
+ execsql { SELECT * FROM t1 }
+ } {1 2 3 4 5 6 7 8 9 10}
+
+ # Open a read transaction with [db2]. Check that this prevents [db] from
+ # checkpointing the database. But not from writing to it.
+ #
+ do_test wal-10.$tn.11 {
+ sql2 { BEGIN; SELECT * FROM t1 }
+ } {1 2 3 4 5 6 7 8 9 10}
+ do_test wal-10.$tn.12 {
+ catchsql { PRAGMA wal_checkpoint }
+ } {0 {0 13 13}} ;# Reader no longer block checkpoints
+ do_test wal-10.$tn.13 {
+ execsql { INSERT INTO t1 VALUES(11, 12) }
+ sql2 {SELECT * FROM t1}
+ } {1 2 3 4 5 6 7 8 9 10}
+
+ # Writers do not block checkpoints any more either.
+ #
+ do_test wal-10.$tn.14 {
+ catchsql { PRAGMA wal_checkpoint }
+ } {0 {0 15 13}}
+
+ # The following series of test cases used to verify another blocking
+ # case in WAL - a case which no longer blocks.
+ #
+ do_test wal-10.$tn.15 {
+ sql2 { COMMIT; BEGIN; SELECT * FROM t1; }
+ } {1 2 3 4 5 6 7 8 9 10 11 12}
+ do_test wal-10.$tn.16 {
+ catchsql { PRAGMA wal_checkpoint }
+ } {0 {0 15 15}}
+ do_test wal-10.$tn.17 {
+ execsql { PRAGMA wal_checkpoint }
+ } {0 15 15}
+ do_test wal-10.$tn.18 {
+ sql3 { BEGIN; SELECT * FROM t1 }
+ } {1 2 3 4 5 6 7 8 9 10 11 12}
+ do_test wal-10.$tn.19 {
+ catchsql { INSERT INTO t1 VALUES(13, 14) }
+ } {0 {}}
+ do_test wal-10.$tn.20 {
+ execsql { SELECT * FROM t1 }
+ } {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
+ do_test wal-10.$tn.21 {
+ sql3 COMMIT
+ sql2 COMMIT
+ } {}
+ do_test wal-10.$tn.22 {
+ execsql { SELECT * FROM t1 }
+ } {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
+
+ # Another series of tests that used to demonstrate blocking behavior
+ # but which now work.
+ #
+ do_test wal-10.$tn.23 {
+ execsql { PRAGMA wal_checkpoint }
+ } {0 17 17}
+ do_test wal-10.$tn.24 {
+ sql2 { BEGIN; SELECT * FROM t1; }
+ } {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
+ do_test wal-10.$tn.25 {
+ execsql { PRAGMA wal_checkpoint }
+ } {0 17 17}
+ do_test wal-10.$tn.26 {
+ catchsql { INSERT INTO t1 VALUES(15, 16) }
+ } {0 {}}
+ do_test wal-10.$tn.27 {
+ sql3 { INSERT INTO t1 VALUES(17, 18) }
+ } {}
+ do_test wal-10.$tn.28 {
+ code3 {
+ set ::STMT [sqlite3_prepare db3 "SELECT * FROM t1" -1 TAIL]
+ sqlite3_step $::STMT
+ }
+ execsql { SELECT * FROM t1 }
+ } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18}
+ do_test wal-10.$tn.29 {
+ execsql { INSERT INTO t1 VALUES(19, 20) }
+ catchsql { PRAGMA wal_checkpoint }
+ } {0 {0 6 0}}
+ do_test wal-10.$tn.30 {
+ code3 { sqlite3_finalize $::STMT }
+ execsql { PRAGMA wal_checkpoint }
+ } {0 6 0}
+
+ # At one point, if a reader failed to upgrade to a writer because it
+ # was reading an old snapshot, the write-locks were not being released.
+ # Test that this bug has been fixed.
+ #
+ do_test wal-10.$tn.31 {
+ sql2 COMMIT
+ execsql { BEGIN ; SELECT * FROM t1 }
+ sql2 { INSERT INTO t1 VALUES(21, 22) }
+ catchsql { INSERT INTO t1 VALUES(23, 24) }
+ } {1 {database is locked}}
+ do_test wal-10.$tn.32 {
+ # This statement would fail when the bug was present.
+ sql2 { INSERT INTO t1 VALUES(23, 24) }
+ } {}
+ do_test wal-10.$tn.33 {
+ execsql { SELECT * FROM t1 ; COMMIT }
+ } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
+ do_test wal-10.$tn.34 {
+ execsql { SELECT * FROM t1 }
+ } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24}
+
+ # Test that if a checkpointer cannot obtain the required locks, it
+ # releases all locks before returning a busy error.
+ #
+ do_test wal-10.$tn.35 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('a', 'b');
+ INSERT INTO t1 VALUES('c', 'd');
+ }
+ sql2 {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ } {a b c d}
+ do_test wal-10.$tn.36 {
+ catchsql { PRAGMA wal_checkpoint }
+ } {0 {0 16 16}}
+ do_test wal-10.$tn.36 {
+ sql3 { INSERT INTO t1 VALUES('e', 'f') }
+ sql2 { SELECT * FROM t1 }
+ } {a b c d}
+ do_test wal-10.$tn.37 {
+ sql2 COMMIT
+ execsql { PRAGMA wal_checkpoint }
+ } {0 18 18}
+}
+
+#-------------------------------------------------------------------------
+# This block of tests, wal-11.*, test that nothing goes terribly wrong
+# if frames must be written to the log file before a transaction is
+# committed (in order to free up memory).
+#
+do_test wal-11.1 {
+ reopen_db
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x PRIMARY KEY);
+ }
+ list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]
+} {1 3}
+do_test wal-11.2 {
+ execsql { PRAGMA wal_checkpoint }
+ list [expr [file size test.db]/1024] [file size test.db-wal]
+} [list 3 [wal_file_size 3 1024]]
+do_test wal-11.3 {
+ execsql { INSERT INTO t1 VALUES( blob(900) ) }
+ list [expr [file size test.db]/1024] [file size test.db-wal]
+} [list 3 [wal_file_size 4 1024]]
+
+do_test wal-11.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 SELECT blob(900) FROM t1; -- 2
+ INSERT INTO t1 SELECT blob(900) FROM t1; -- 4
+ INSERT INTO t1 SELECT blob(900) FROM t1; -- 8
+ INSERT INTO t1 SELECT blob(900) FROM t1; -- 16
+ }
+ list [expr [file size test.db]/1024] [file size test.db-wal]
+} [list 3 [wal_file_size 32 1024]]
+do_test wal-11.5 {
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+ }
+} {16 ok}
+do_test wal-11.6 {
+ execsql COMMIT
+ list [expr [file size test.db]/1024] [file size test.db-wal]
+} [list 3 [wal_file_size 41 1024]]
+do_test wal-11.7 {
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+ }
+} {16 ok}
+do_test wal-11.8 {
+ execsql { PRAGMA wal_checkpoint }
+ list [expr [file size test.db]/1024] [file size test.db-wal]
+} [list 37 [wal_file_size 41 1024]]
+do_test wal-11.9 {
+ db close
+ list [expr [file size test.db]/1024] [log_deleted test.db-wal]
+} {37 1}
+sqlite3_wal db test.db
+do_test wal-11.10 {
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ INSERT INTO t1 SELECT blob(900) FROM t1; -- 32
+ SELECT count(*) FROM t1;
+ }
+ list [expr [file size test.db]/1024] [file size test.db-wal]
+} [list 37 [wal_file_size 37 1024]]
+do_test wal-11.11 {
+ execsql {
+ SELECT count(*) FROM t1;
+ ROLLBACK;
+ SELECT count(*) FROM t1;
+ }
+} {32 16}
+do_test wal-11.12 {
+ list [expr [file size test.db]/1024] [file size test.db-wal]
+} [list 37 [wal_file_size 37 1024]]
+do_test wal-11.13 {
+ execsql {
+ INSERT INTO t1 VALUES( blob(900) );
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+ }
+} {17 ok}
+do_test wal-11.14 {
+ list [expr [file size test.db]/1024] [file size test.db-wal]
+} [list 37 [wal_file_size 37 1024]]
+
+
+#-------------------------------------------------------------------------
+# This block of tests, wal-12.*, tests the fix for a problem that
+# could occur if a log that is a prefix of an older log is written
+# into a reused log file.
+#
+reopen_db
+do_test wal-12.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x, y);
+ CREATE TABLE t2(x, y);
+ INSERT INTO t1 VALUES('A', 1);
+ }
+ list [expr [file size test.db]/1024] [file size test.db-wal]
+} [list 1 [wal_file_size 5 1024]]
+do_test wal-12.2 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA synchronous = normal;
+ UPDATE t1 SET y = 0 WHERE x = 'A';
+ }
+ list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]
+} {3 1}
+do_test wal-12.3 {
+ execsql { INSERT INTO t2 VALUES('B', 1) }
+ list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]
+} {3 2}
+do_test wal-12.4 {
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+ sqlite3_wal db2 test2.db
+ execsql { SELECT * FROM t2 } db2
+} {B 1}
+db2 close
+do_test wal-12.5 {
+ execsql {
+ PRAGMA wal_checkpoint;
+ UPDATE t2 SET y = 2 WHERE x = 'B';
+ PRAGMA wal_checkpoint;
+ UPDATE t1 SET y = 1 WHERE x = 'A';
+ PRAGMA wal_checkpoint;
+ UPDATE t1 SET y = 0 WHERE x = 'A';
+ }
+ execsql { SELECT * FROM t2 }
+} {B 2}
+do_test wal-12.6 {
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+ sqlite3_wal db2 test2.db
+ execsql { SELECT * FROM t2 } db2
+} {B 2}
+db2 close
+db close
+
+#-------------------------------------------------------------------------
+# Test large log summaries.
+#
+# In this case "large" usually means a log file that requires a wal-index
+# mapping larger than 64KB (the default initial allocation). A 64KB wal-index
+# is large enough for a log file that contains approximately 13100 frames.
+# So the following tests create logs containing at least this many frames.
+#
+# wal-13.1.*: This test case creates a very large log file within the
+# file-system (around 200MB). The log file does not contain
+# any valid frames. Test that the database file can still be
+# opened and queried, and that the invalid log file causes no
+# problems.
+#
+# wal-13.2.*: Test that a process may create a large log file and query
+# the database (including the log file that it itself created).
+#
+# wal-13.3.*: Test that if a very large log file is created, and then a
+# second connection is opened on the database file, it is possible
+# to query the database (and the very large log) using the
+# second connection.
+#
+# wal-13.4.*: Same test as wal-13.3.*. Except in this case the second
+# connection is opened by an external process.
+#
+do_test wal-13.1.1 {
+ list [file exists test.db] [file exists test.db-wal]
+} {1 0}
+do_test wal-13.1.2 {
+ set fd [open test.db-wal w]
+ seek $fd [expr 200*1024*1024]
+ puts $fd ""
+ close $fd
+ sqlite3 db test.db
+ execsql { SELECT * FROM t2 }
+} {B 2}
+breakpoint
+do_test wal-13.1.3 {
+ db close
+ file exists test.db-wal
+} {0}
+
+do_test wal-13.2.1 {
+ sqlite3 db test.db
+ execsql { SELECT count(*) FROM t2 }
+} {1}
+do_test wal-13.2.2 {
+ db function blob blob
+ for {set i 0} {$i < 16} {incr i} {
+ execsql { INSERT INTO t2 SELECT blob(400), blob(400) FROM t2 }
+ }
+ execsql { SELECT count(*) FROM t2 }
+} [expr int(pow(2, 16))]
+do_test wal-13.2.3 {
+ expr [file size test.db-wal] > [wal_file_size 33000 1024]
+} 1
+
+do_multiclient_test tn {
+ incr tn 2
+
+ do_test wal-13.$tn.0 {
+ sql1 {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 SELECT randomblob(800);
+ }
+ sql1 { SELECT count(*) FROM t1 }
+ } {1}
+
+ for {set ii 1} {$ii<16} {incr ii} {
+ do_test wal-13.$tn.$ii.a {
+ sql2 { INSERT INTO t1 SELECT randomblob(800) FROM t1 }
+ sql2 { SELECT count(*) FROM t1 }
+ } [expr (1<<$ii)]
+ do_test wal-13.$tn.$ii.b {
+ sql1 { SELECT count(*) FROM t1 }
+ } [expr (1<<$ii)]
+ do_test wal-13.$tn.$ii.c {
+ sql1 { SELECT count(*) FROM t1 }
+ } [expr (1<<$ii)]
+ do_test wal-13.$tn.$ii.d {
+ sql1 { PRAGMA integrity_check }
+ } {ok}
+ }
+}
+
+#-------------------------------------------------------------------------
+# Check a fun corruption case has been fixed.
+#
+# The problem was that after performing a checkpoint using a connection
+# that had an out-of-date pager-cache, the next time the connection was
+# used it did not realize the cache was out-of-date and proceeded to
+# operate with an inconsistent cache. Leading to corruption.
+#
+catch { db close }
+catch { db2 close }
+catch { db3 close }
+forcedelete test.db test.db-wal
+sqlite3 db test.db
+sqlite3 db2 test.db
+do_test wal-14 {
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(randomblob(10), randomblob(100));
+ INSERT INTO t1 SELECT randomblob(10), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(10), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(10), randomblob(100) FROM t1;
+ }
+
+ db2 eval {
+ INSERT INTO t1 SELECT randomblob(10), randomblob(100);
+ INSERT INTO t1 SELECT randomblob(10), randomblob(100);
+ INSERT INTO t1 SELECT randomblob(10), randomblob(100);
+ INSERT INTO t1 SELECT randomblob(10), randomblob(100);
+ }
+
+ # After executing the "PRAGMA wal_checkpoint", connection [db] was being
+ # left with an inconsistent cache. Running the CREATE INDEX statement
+ # in this state led to database corruption.
+ catchsql {
+ PRAGMA wal_checkpoint;
+ CREATE INDEX i1 on t1(b);
+ }
+
+ db2 eval { PRAGMA integrity_check }
+} {ok}
+
+catch { db close }
+catch { db2 close }
+
+#-------------------------------------------------------------------------
+# The following block of tests - wal-15.* - focus on testing the
+# implementation of the sqlite3_wal_checkpoint() interface.
+#
+forcedelete test.db test.db-wal
+sqlite3 db test.db
+do_test wal-15.1 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ }
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+} {}
+
+# Test that an error is returned if the database name is not recognized
+#
+do_test wal-15.2.1 {
+ sqlite3_wal_checkpoint db aux
+} {SQLITE_ERROR}
+do_test wal-15.2.2 {
+ sqlite3_errcode db
+} {SQLITE_ERROR}
+do_test wal-15.2.3 {
+ sqlite3_errmsg db
+} {unknown database: aux}
+
+# Test that an error is returned if an attempt is made to checkpoint
+# if a transaction is open on the database.
+#
+do_test wal-15.3.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ sqlite3_wal_checkpoint db main
+} {SQLITE_LOCKED}
+do_test wal-15.3.2 {
+ sqlite3_errcode db
+} {SQLITE_LOCKED}
+do_test wal-15.3.3 {
+ sqlite3_errmsg db
+} {database table is locked}
+
+# Earlier versions returned an error is returned if the db cannot be
+# checkpointed because of locks held by another connection. Check that
+# this is no longer the case.
+#
+sqlite3 db2 test.db
+do_test wal-15.4.1 {
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ } db2
+} {1 2}
+do_test wal-15.4.2 {
+ execsql { COMMIT }
+ sqlite3_wal_checkpoint db
+} {SQLITE_OK}
+do_test wal-15.4.3 {
+ sqlite3_errmsg db
+} {not an error}
+
+# After [db2] drops its lock, [db] may checkpoint the db.
+#
+do_test wal-15.4.4 {
+ execsql { COMMIT } db2
+ sqlite3_wal_checkpoint db
+} {SQLITE_OK}
+do_test wal-15.4.5 {
+ sqlite3_errmsg db
+} {not an error}
+do_test wal-15.4.6 {
+ file size test.db
+} [expr 1024*2]
+
+catch { db2 close }
+catch { db close }
+
+#-------------------------------------------------------------------------
+# The following block of tests - wal-16.* - test that if a NULL pointer or
+# an empty string is passed as the second argument of the wal_checkpoint()
+# API, an attempt is made to checkpoint all attached databases.
+#
+foreach {tn ckpt_cmd ckpt_res ckpt_main ckpt_aux} {
+ 1 {sqlite3_wal_checkpoint db} SQLITE_OK 1 1
+ 2 {sqlite3_wal_checkpoint db ""} SQLITE_OK 1 1
+ 3 {db eval "PRAGMA wal_checkpoint"} {0 10 10} 1 1
+
+ 4 {sqlite3_wal_checkpoint db main} SQLITE_OK 1 0
+ 5 {sqlite3_wal_checkpoint db aux} SQLITE_OK 0 1
+ 6 {sqlite3_wal_checkpoint db temp} SQLITE_OK 0 0
+ 7 {db eval "PRAGMA main.wal_checkpoint"} {0 10 10} 1 0
+ 8 {db eval "PRAGMA aux.wal_checkpoint"} {0 16 16} 0 1
+ 9 {db eval "PRAGMA temp.wal_checkpoint"} {0 -1 -1} 0 0
+} {
+ do_test wal-16.$tn.1 {
+ forcedelete test2.db test2.db-wal test2.db-journal
+ forcedelete test.db test.db-wal test.db-journal
+
+ sqlite3 db test.db
+ execsql {
+ ATTACH 'test2.db' AS aux;
+ PRAGMA main.auto_vacuum = 0;
+ PRAGMA aux.auto_vacuum = 0;
+ PRAGMA main.journal_mode = WAL;
+ PRAGMA aux.journal_mode = WAL;
+ PRAGMA synchronous = NORMAL;
+ }
+ } {wal wal}
+
+ do_test wal-16.$tn.2 {
+ execsql {
+ CREATE TABLE main.t1(a, b, PRIMARY KEY(a, b));
+ CREATE TABLE aux.t2(a, b, PRIMARY KEY(a, b));
+
+ INSERT INTO t2 VALUES(1, randomblob(1000));
+ INSERT INTO t2 VALUES(2, randomblob(1000));
+ INSERT INTO t1 SELECT * FROM t2;
+ }
+
+ list [file size test.db] [file size test.db-wal]
+ } [list [expr 1*1024] [wal_file_size 10 1024]]
+ do_test wal-16.$tn.3 {
+ list [file size test2.db] [file size test2.db-wal]
+ } [list [expr 1*1024] [wal_file_size 16 1024]]
+
+ do_test wal-16.$tn.4 [list eval $ckpt_cmd] $ckpt_res
+
+ do_test wal-16.$tn.5 {
+ list [file size test.db] [file size test.db-wal]
+ } [list [expr ($ckpt_main ? 7 : 1)*1024] [wal_file_size 10 1024]]
+
+ do_test wal-16.$tn.6 {
+ list [file size test2.db] [file size test2.db-wal]
+ } [list [expr ($ckpt_aux ? 7 : 1)*1024] [wal_file_size 16 1024]]
+
+ catch { db close }
+}
+
+#-------------------------------------------------------------------------
+# The following tests - wal-17.* - attempt to verify that the correct
+# number of "padding" frames are appended to the log file when a transaction
+# is committed in synchronous=FULL mode.
+#
+# Do this by creating a database that uses 512 byte pages. Then writing
+# a transaction that modifies 171 pages. In synchronous=NORMAL mode, this
+# produces a log file of:
+#
+# 32 + (24+512)*171 = 90312 bytes.
+#
+# Slightly larger than 11*8192 = 90112 bytes.
+#
+# Run the test using various different sector-sizes. In each case, the
+# WAL code should write the 90300 bytes of log file containing the
+# transaction, then append as may frames as are required to extend the
+# log file so that no part of the next transaction will be written into
+# a disk-sector used by transaction just committed.
+#
+set old_pending_byte [sqlite3_test_control_pending_byte 0x10000000]
+catch { db close }
+foreach {tn sectorsize logsize} "
+ 1 128 [wal_file_size 172 512]
+ 2 256 [wal_file_size 172 512]
+ 3 512 [wal_file_size 172 512]
+ 4 1024 [wal_file_size 172 512]
+ 5 2048 [wal_file_size 172 512]
+ 6 4096 [wal_file_size 176 512]
+ 7 8192 [wal_file_size 184 512]
+" {
+ forcedelete test.db test.db-wal test.db-journal
+ sqlite3_simulate_device -sectorsize $sectorsize
+ sqlite3 db test.db -vfs devsym
+
+ do_test wal-17.$tn.1 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 512;
+ PRAGMA journal_mode = WAL;
+ PRAGMA synchronous = FULL;
+ }
+ execsql {
+ BEGIN;
+ CREATE TABLE t(x);
+ }
+ for {set i 0} {$i<166} {incr i} {
+ execsql { INSERT INTO t VALUES(randomblob(400)) }
+ }
+ execsql COMMIT
+
+ file size test.db-wal
+ } $logsize
+
+ do_test wal-17.$tn.2 {
+ file size test.db
+ } 512
+
+ do_test wal-17.$tn.3 {
+ db close
+ file size test.db
+ } [expr 512*171]
+}
+sqlite3_test_control_pending_byte $old_pending_byte
+
+#-------------------------------------------------------------------------
+# This test - wal-18.* - verifies a couple of specific conditions that
+# may be encountered while recovering a log file are handled correctly:
+#
+# wal-18.1.* When the first 32-bits of a frame checksum is correct but
+# the second 32-bits are false, and
+#
+# wal-18.2.* When the page-size field that occurs at the start of a log
+# file is a power of 2 greater than 16384 or smaller than 512.
+#
+forcedelete test.db test.db-wal test.db-journal
+do_test wal-18.0 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ PRAGMA synchronous = OFF;
+
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ INSERT INTO t1 VALUES(0, 0);
+ PRAGMA wal_checkpoint;
+
+ INSERT INTO t1 VALUES(1, 2); -- frames 1 and 2
+ INSERT INTO t1 VALUES(3, 4); -- frames 3 and 4
+ INSERT INTO t1 VALUES(5, 6); -- frames 5 and 6
+ }
+
+ forcecopy test.db testX.db
+ forcecopy test.db-wal testX.db-wal
+ db close
+ list [file size testX.db] [file size testX.db-wal]
+} [list [expr 3*1024] [wal_file_size 6 1024]]
+
+unset -nocomplain nFrame result
+foreach {nFrame result} {
+ 0 {0 0}
+ 1 {0 0}
+ 2 {0 0 1 2}
+ 3 {0 0 1 2}
+ 4 {0 0 1 2 3 4}
+ 5 {0 0 1 2 3 4}
+ 6 {0 0 1 2 3 4 5 6}
+} {
+ do_test wal-18.1.$nFrame {
+ forcecopy testX.db test.db
+ forcecopy testX.db-wal test.db-wal
+
+ hexio_write test.db-wal [expr 24 + $nFrame*(24+1024) + 20] 00000000
+
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM t1;
+ PRAGMA integrity_check;
+ }
+ } [concat $result ok]
+ db close
+}
+
+proc randomblob {pgsz} {
+ sqlite3 rbdb :memory:
+ set blob [rbdb one {SELECT randomblob($pgsz)}]
+ rbdb close
+ set blob
+}
+
+proc logcksum {ckv1 ckv2 blob} {
+ upvar $ckv1 c1
+ upvar $ckv2 c2
+
+ set scanpattern I*
+ if {$::tcl_platform(byteOrder) eq "littleEndian"} {
+ set scanpattern i*
+ }
+
+ binary scan $blob $scanpattern values
+ foreach {v1 v2} $values {
+ set c1 [expr {($c1 + $v1 + $c2)&0xFFFFFFFF}]
+ set c2 [expr {($c2 + $v2 + $c1)&0xFFFFFFFF}]
+ }
+}
+
+forcecopy test.db testX.db
+foreach {tn pgsz works} {
+ 1 128 0
+ 2 256 0
+ 3 512 1
+ 4 1024 1
+ 5 2048 1
+ 6 4096 1
+ 7 8192 1
+ 8 16384 1
+ 9 32768 1
+ 10 65536 1
+ 11 131072 0
+ 11 1016 0
+} {
+
+ if {$::SQLITE_MAX_PAGE_SIZE < $pgsz} {
+ set works 0
+ }
+
+ for {set pg 1} {$pg <= 3} {incr pg} {
+ forcecopy testX.db test.db
+ forcedelete test.db-wal
+
+ # Check that the database now exists and consists of three pages. And
+ # that there is no associated wal file.
+ #
+ do_test wal-18.2.$tn.$pg.1 { file exists test.db-wal } 0
+ do_test wal-18.2.$tn.$pg.2 { file exists test.db } 1
+ do_test wal-18.2.$tn.$pg.3 { file size test.db } [expr 1024*3]
+
+ do_test wal-18.2.$tn.$pg.4 {
+
+ # Create a wal file that contains a single frame (database page
+ # number $pg) with the commit flag set. The frame checksum is
+ # correct, but the contents of the database page are corrupt.
+ #
+ # The page-size in the log file header is set to $pgsz. If the
+ # WAL code considers $pgsz to be a valid SQLite database file page-size,
+ # the database will be corrupt (because the garbage frame contents
+ # will be treated as valid content). If $pgsz is invalid (too small
+ # or too large), the db will not be corrupt as the log file will
+ # be ignored.
+ #
+ set walhdr [binary format IIIIII 931071618 3007000 $pgsz 1234 22 23]
+ set framebody [randomblob $pgsz]
+ set framehdr [binary format IIII $pg 5 22 23]
+ set c1 0
+ set c2 0
+ logcksum c1 c2 $walhdr
+
+ append walhdr [binary format II $c1 $c2]
+ logcksum c1 c2 [string range $framehdr 0 7]
+ logcksum c1 c2 $framebody
+ set framehdr [binary format IIIIII $pg 5 22 23 $c1 $c2]
+
+ set fd [open test.db-wal w]
+ fconfigure $fd -encoding binary -translation binary
+ puts -nonewline $fd $walhdr
+ puts -nonewline $fd $framehdr
+ puts -nonewline $fd $framebody
+ close $fd
+
+ file size test.db-wal
+ } [wal_file_size 1 $pgsz]
+
+ do_test wal-18.2.$tn.$pg.5 {
+ sqlite3 db test.db
+ set rc [catch { db one {PRAGMA integrity_check} } msg]
+ expr { $rc!=0 || $msg!="ok" }
+ } $works
+
+ db close
+ }
+}
+
+#-------------------------------------------------------------------------
+# The following test - wal-19.* - fixes a bug that was present during
+# development.
+#
+# When a database connection in WAL mode is closed, it attempts an
+# EXCLUSIVE lock on the database file. If the lock is obtained, the
+# connection knows that it is the last connection to disconnect from
+# the database, so it runs a checkpoint operation. The bug was that
+# the connection was not updating its private copy of the wal-index
+# header before doing so, meaning that it could checkpoint an old
+# snapshot.
+#
+do_test wal-19.1 {
+ forcedelete test.db test.db-wal test.db-journal
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ execsql { SELECT * FROM t1 } db2
+} {1 2 3 4}
+do_test wal-19.2 {
+ execsql {
+ INSERT INTO t1 VALUES(5, 6);
+ SELECT * FROM t1;
+ }
+} {1 2 3 4 5 6}
+do_test wal-19.3 {
+ db close
+ db2 close
+ file exists test.db-wal
+} {0}
+do_test wal-19.4 {
+ # When the bug was present, the following was returning {1 2 3 4} only,
+ # as [db2] had an out-of-date copy of the wal-index header when it was
+ # closed.
+ #
+ sqlite3 db test.db
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4 5 6}
+
+#-------------------------------------------------------------------------
+# This test - wal-20.* - uses two connections. One in this process and
+# the other in an external process. The procedure is:
+#
+# 1. Using connection 1, create the database schema.
+#
+# 2. Using connection 2 (in an external process), add so much
+# data to the database without checkpointing that a wal-index
+# larger than 64KB is required.
+#
+# 3. Using connection 1, checkpoint the database. Make sure all
+# the data is present and the database is not corrupt.
+#
+# At one point, SQLite was failing to grow the mapping of the wal-index
+# file in step 3 and the checkpoint was corrupting the database file.
+#
+do_test wal-20.1 {
+ catch {db close}
+ forcedelete test.db test.db-wal test.db-journal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(900));
+ SELECT count(*) FROM t1;
+ }
+} {wal 1}
+do_test wal-20.2 {
+ set ::buddy [launch_testfixture]
+ testfixture $::buddy {
+ sqlite3 db test.db
+ db transaction { db eval {
+ PRAGMA wal_autocheckpoint = 0;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 128 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 256 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 512 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 1024 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 2048 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4096 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 8192 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 16384 */
+ } }
+ }
+} {0}
+do_test wal-20.3 {
+ close $::buddy
+ execsql { PRAGMA wal_checkpoint }
+ execsql { SELECT count(*) FROM t1 }
+} {16384}
+do_test wal-20.4 {
+ db close
+ sqlite3 db test.db
+ execsql { SELECT count(*) FROM t1 }
+} {16384}
+integrity_check wal-20.5
+
+catch { db2 close }
+catch { db close }
+
+do_test wal-21.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ INSERT INTO t1 VALUES(7, 8);
+ INSERT INTO t1 VALUES(9, 10);
+ INSERT INTO t1 VALUES(11, 12);
+ }
+} {wal}
+do_test wal-21.2 {
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA wal_checkpoint;
+ BEGIN;
+ SAVEPOINT s;
+ INSERT INTO t1 SELECT randomblob(900), randomblob(900) FROM t1;
+ ROLLBACK TO s;
+ COMMIT;
+ }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+do_test wal-21.3 {
+ execsql { PRAGMA integrity_check }
+} {ok}
+
+#-------------------------------------------------------------------------
+# Test reading and writing of databases with different page-sizes.
+#
+foreach pgsz {512 1024 2048 4096 8192 16384 32768 65536} {
+ do_multiclient_test tn [string map [list %PGSZ% $pgsz] {
+ do_test wal-22.%PGSZ%.$tn.1 {
+ sql1 {
+ PRAGMA main.page_size = %PGSZ%;
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(x UNIQUE);
+ INSERT INTO t1 SELECT randomblob(800);
+ INSERT INTO t1 SELECT randomblob(800);
+ INSERT INTO t1 SELECT randomblob(800);
+ }
+ } {wal}
+ do_test wal-22.%PGSZ%.$tn.2 { sql2 { PRAGMA integrity_check } } {ok}
+ do_test wal-22.%PGSZ%.$tn.3 {
+ sql1 {PRAGMA wal_checkpoint}
+ expr {[file size test.db] % %PGSZ%}
+ } {0}
+ }]
+}
+
+#-------------------------------------------------------------------------
+# Test that when 1 or more pages are recovered from a WAL file,
+# sqlite3_log() is invoked to report this to the user.
+#
+set walfile [file nativename [file join [pwd] test.db-wal]]
+catch {db close}
+forcedelete test.db
+do_test wal-23.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE t1(a, b);
+ PRAGMA journal_mode = WAL;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ faultsim_save_and_close
+
+ sqlite3_shutdown
+ test_sqlite3_log [list lappend ::log]
+ set ::log [list]
+ sqlite3 db test.db
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+do_test wal-23.2 { set ::log } {}
+
+do_test wal-23.3 {
+ db close
+ set ::log [list]
+ faultsim_restore_and_reopen
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+set nPage [expr 2+$AUTOVACUUM]
+do_test wal-23.4 {
+ set ::log
+} [list SQLITE_OK "Recovered $nPage frames from WAL file $walfile"]
+
+
+ifcapable autovacuum {
+ # This block tests that if the size of a database is reduced by a
+ # transaction (because of an incremental or auto-vacuum), that no
+ # data is written to the WAL file for the truncated pages as part
+ # of the commit. e.g. if a transaction reduces the size of a database
+ # to N pages, data for page N+1 should not be written to the WAL file
+ # when committing the transaction. At one point such data was being
+ # written.
+ #
+ catch {db close}
+ forcedelete test.db
+ sqlite3 db test.db
+ do_execsql_test 24.1 {
+ PRAGMA auto_vacuum = 2;
+ PRAGMA journal_mode = WAL;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(5000));
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ } {wal}
+ do_test 24.2 {
+ execsql {
+ DELETE FROM t1;
+ PRAGMA wal_checkpoint;
+ }
+ db close
+ sqlite3 db test.db
+ file exists test.db-wal
+ } 0
+ do_test 24.3 {
+ file size test.db
+ } [expr 84 * 1024]
+ do_test 24.4 {
+ execsql {
+ PRAGMA cache_size = 200;
+ PRAGMA incremental_vacuum;
+ PRAGMA wal_checkpoint;
+ }
+ file size test.db
+ } [expr 3 * 1024]
+ do_test 24.5 {
+ file size test.db-wal
+ } 2128
+}
+
+db close
+sqlite3_shutdown
+test_sqlite3_log
+sqlite3_initialize
+
+finish_test
diff --git a/test/wal2.test b/test/wal2.test
new file mode 100644
index 0000000..f488706
--- /dev/null
+++ b/test/wal2.test
@@ -0,0 +1,1298 @@
+# 2010 May 5
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+source $testdir/wal_common.tcl
+
+set testprefix wal2
+
+ifcapable !wal {finish_test ; return }
+
+set sqlite_sync_count 0
+proc cond_incr_sync_count {adj} {
+ global sqlite_sync_count
+ if {$::tcl_platform(platform) == "windows"} {
+ incr sqlite_sync_count $adj
+ } {
+ ifcapable !dirsync {
+ incr sqlite_sync_count $adj
+ }
+ }
+}
+
+proc set_tvfs_hdr {file args} {
+
+ # Set $nHdr to the number of bytes in the wal-index header:
+ set nHdr 48
+ set nInt [expr {$nHdr/4}]
+
+ if {[llength $args]>2} {
+ error {wrong # args: should be "set_tvfs_hdr fileName ?val1? ?val2?"}
+ }
+
+ set blob [tvfs shm $file]
+
+ if {[llength $args]} {
+ set ia [lindex $args 0]
+ set ib $ia
+ if {[llength $args]==2} {
+ set ib [lindex $args 1]
+ }
+ binary scan $blob a[expr $nHdr*2]a* dummy tail
+ set blob [binary format i${nInt}i${nInt}a* $ia $ib $tail]
+ tvfs shm $file $blob
+ }
+
+ binary scan $blob i${nInt} ints
+ return $ints
+}
+
+proc incr_tvfs_hdr {file idx incrval} {
+ set ints [set_tvfs_hdr $file]
+ set v [lindex $ints $idx]
+ incr v $incrval
+ lset ints $idx $v
+ set_tvfs_hdr $file $ints
+}
+
+
+#-------------------------------------------------------------------------
+# Test case wal2-1.*:
+#
+# Set up a small database containing a single table. The database is not
+# checkpointed during the test - all content resides in the log file.
+#
+# Two connections are established to the database file - a writer ([db])
+# and a reader ([db2]). For each of the 8 integer fields in the wal-index
+# header (6 fields and 2 checksum values), do the following:
+#
+# 1. Modify the database using the writer.
+#
+# 2. Attempt to read the database using the reader. Before the reader
+# has a chance to snapshot the wal-index header, increment one
+# of the the integer fields (so that the reader ends up with a corrupted
+# header).
+#
+# 3. Check that the reader recovers the wal-index and reads the correct
+# database content.
+#
+do_test wal2-1.0 {
+ proc tvfs_cb {method filename args} {
+ set ::filename $filename
+ return SQLITE_OK
+ }
+
+ testvfs tvfs
+ tvfs script tvfs_cb
+ tvfs filter xShmOpen
+
+ sqlite3 db test.db -vfs tvfs
+ sqlite3 db2 test.db -vfs tvfs
+
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a);
+ } db2
+ execsql {
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ SELECT count(a), sum(a) FROM t1;
+ }
+} {4 10}
+do_test wal2-1.1 {
+ execsql { SELECT count(a), sum(a) FROM t1 } db2
+} {4 10}
+
+set RECOVER [list \
+ {0 1 lock exclusive} {1 7 lock exclusive} \
+ {1 7 unlock exclusive} {0 1 unlock exclusive} \
+]
+set READ [list \
+ {4 1 lock exclusive} {4 1 unlock exclusive} \
+ {4 1 lock shared} {4 1 unlock shared} \
+]
+
+foreach {tn iInsert res wal_index_hdr_mod wal_locks} "
+ 2 5 {5 15} 0 {$RECOVER $READ}
+ 3 6 {6 21} 1 {$RECOVER $READ}
+ 4 7 {7 28} 2 {$RECOVER $READ}
+ 5 8 {8 36} 3 {$RECOVER $READ}
+ 6 9 {9 45} 4 {$RECOVER $READ}
+ 7 10 {10 55} 5 {$RECOVER $READ}
+ 8 11 {11 66} 6 {$RECOVER $READ}
+ 9 12 {12 78} 7 {$RECOVER $READ}
+ 10 13 {13 91} 8 {$RECOVER $READ}
+ 11 14 {14 105} 9 {$RECOVER $READ}
+ 12 15 {15 120} -1 {$READ}
+" {
+
+ do_test wal2-1.$tn.1 {
+ execsql { INSERT INTO t1 VALUES($iInsert) }
+ set ::locks [list]
+ proc tvfs_cb {method args} {
+ lappend ::locks [lindex $args 2]
+ return SQLITE_OK
+ }
+ tvfs filter xShmLock
+ if {$::wal_index_hdr_mod >= 0} {
+ incr_tvfs_hdr $::filename $::wal_index_hdr_mod 1
+ }
+ execsql { SELECT count(a), sum(a) FROM t1 } db2
+ } $res
+
+ do_test wal2-1.$tn.2 {
+ set ::locks
+ } $wal_locks
+}
+db close
+db2 close
+tvfs delete
+forcedelete test.db test.db-wal test.db-journal
+
+#-------------------------------------------------------------------------
+# This test case is very similar to the previous one, except, after
+# the reader reads the corrupt wal-index header, but before it has
+# a chance to re-read it under the cover of the RECOVER lock, the
+# wal-index header is replaced with a valid, but out-of-date, header.
+#
+# Because the header checksum looks Ok, the reader does not run recovery,
+# it simply drops back to a READ lock and proceeds. But because the
+# header is out-of-date, the reader reads the out-of-date snapshot.
+#
+# After this, the header is corrupted again and the reader is allowed
+# to run recovery. This time, it sees an up-to-date snapshot of the
+# database file.
+#
+set WRITER [list 0 1 lock exclusive]
+set LOCKS [list \
+ {0 1 lock exclusive} {0 1 unlock exclusive} \
+ {4 1 lock exclusive} {4 1 unlock exclusive} \
+ {4 1 lock shared} {4 1 unlock shared} \
+]
+do_test wal2-2.0 {
+
+ testvfs tvfs
+ tvfs script tvfs_cb
+ tvfs filter xShmOpen
+ proc tvfs_cb {method args} {
+ set ::filename [lindex $args 0]
+ return SQLITE_OK
+ }
+
+ sqlite3 db test.db -vfs tvfs
+ sqlite3 db2 test.db -vfs tvfs
+
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a);
+ } db2
+ execsql {
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ SELECT count(a), sum(a) FROM t1;
+ }
+} {4 10}
+do_test wal2-2.1 {
+ execsql { SELECT count(a), sum(a) FROM t1 } db2
+} {4 10}
+
+foreach {tn iInsert res0 res1 wal_index_hdr_mod} {
+ 2 5 {4 10} {5 15} 0
+ 3 6 {5 15} {6 21} 1
+ 4 7 {6 21} {7 28} 2
+ 5 8 {7 28} {8 36} 3
+ 6 9 {8 36} {9 45} 4
+ 7 10 {9 45} {10 55} 5
+ 8 11 {10 55} {11 66} 6
+ 9 12 {11 66} {12 78} 7
+} {
+ tvfs filter xShmLock
+
+ do_test wal2-2.$tn.1 {
+ set oldhdr [set_tvfs_hdr $::filename]
+ execsql { INSERT INTO t1 VALUES($iInsert) }
+ execsql { SELECT count(a), sum(a) FROM t1 }
+ } $res1
+
+ do_test wal2-2.$tn.2 {
+ set ::locks [list]
+ proc tvfs_cb {method args} {
+ set lock [lindex $args 2]
+ lappend ::locks $lock
+ if {$lock == $::WRITER} {
+ set_tvfs_hdr $::filename $::oldhdr
+ }
+ return SQLITE_OK
+ }
+
+ if {$::wal_index_hdr_mod >= 0} {
+ incr_tvfs_hdr $::filename $::wal_index_hdr_mod 1
+ }
+ execsql { SELECT count(a), sum(a) FROM t1 } db2
+ } $res0
+
+ do_test wal2-2.$tn.3 {
+ set ::locks
+ } $LOCKS
+
+ do_test wal2-2.$tn.4 {
+ set ::locks [list]
+ proc tvfs_cb {method args} {
+ set lock [lindex $args 2]
+ lappend ::locks $lock
+ return SQLITE_OK
+ }
+
+ if {$::wal_index_hdr_mod >= 0} {
+ incr_tvfs_hdr $::filename $::wal_index_hdr_mod 1
+ }
+ execsql { SELECT count(a), sum(a) FROM t1 } db2
+ } $res1
+}
+db close
+db2 close
+tvfs delete
+forcedelete test.db test.db-wal test.db-journal
+
+
+if 0 {
+#-------------------------------------------------------------------------
+# This test case - wal2-3.* - tests the response of the library to an
+# SQLITE_BUSY when attempting to obtain a READ or RECOVER lock.
+#
+# wal2-3.0 - 2: SQLITE_BUSY when obtaining a READ lock
+# wal2-3.3 - 6: SQLITE_BUSY when obtaining a RECOVER lock
+#
+do_test wal2-3.0 {
+ proc tvfs_cb {method args} {
+ if {$method == "xShmLock"} {
+ if {[info exists ::locked]} { return SQLITE_BUSY }
+ }
+ return SQLITE_OK
+ }
+
+ proc busyhandler x {
+ if {$x>3} { unset -nocomplain ::locked }
+ return 0
+ }
+
+ testvfs tvfs
+ tvfs script tvfs_cb
+ sqlite3 db test.db -vfs tvfs
+ db busy busyhandler
+
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ }
+
+ set ::locked 1
+ info exists ::locked
+} {1}
+do_test wal2-3.1 {
+ execsql { SELECT count(a), sum(a) FROM t1 }
+} {4 10}
+do_test wal2-3.2 {
+ info exists ::locked
+} {0}
+
+do_test wal2-3.3 {
+ proc tvfs_cb {method args} {
+ if {$method == "xShmLock"} {
+ if {[info exists ::sabotage]} {
+ unset -nocomplain ::sabotage
+ incr_tvfs_hdr [lindex $args 0] 1 1
+ }
+ if {[info exists ::locked] && [lindex $args 2] == "RECOVER"} {
+ return SQLITE_BUSY
+ }
+ }
+ return SQLITE_OK
+ }
+ set ::sabotage 1
+ set ::locked 1
+ list [info exists ::sabotage] [info exists ::locked]
+} {1 1}
+do_test wal2-3.4 {
+ execsql { SELECT count(a), sum(a) FROM t1 }
+} {4 10}
+do_test wal2-3.5 {
+ list [info exists ::sabotage] [info exists ::locked]
+} {0 0}
+db close
+tvfs delete
+forcedelete test.db test.db-wal test.db-journal
+
+}
+
+#-------------------------------------------------------------------------
+# Test that a database connection using a VFS that does not support the
+# xShmXXX interfaces cannot open a WAL database.
+#
+do_test wal2-4.1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE data(x);
+ INSERT INTO data VALUES('need xShmOpen to see this');
+ PRAGMA wal_checkpoint;
+ }
+} {wal 0 5 5}
+do_test wal2-4.2 {
+ db close
+ testvfs tvfs -noshm 1
+ sqlite3 db test.db -vfs tvfs
+ catchsql { SELECT * FROM data }
+} {1 {unable to open database file}}
+do_test wal2-4.3 {
+ db close
+ testvfs tvfs
+ sqlite3 db test.db -vfs tvfs
+ catchsql { SELECT * FROM data }
+} {0 {{need xShmOpen to see this}}}
+db close
+tvfs delete
+
+#-------------------------------------------------------------------------
+# Test that if a database connection is forced to run recovery before it
+# can perform a checkpoint, it does not transition into RECOVER state.
+#
+# UPDATE: This has now changed. When running a checkpoint, if recovery is
+# required the client grabs all exclusive locks (just as it would for a
+# recovery performed as a pre-cursor to a normal database transaction).
+#
+set expected_locks [list]
+lappend expected_locks {1 1 lock exclusive} ;# Lock checkpoint
+lappend expected_locks {0 1 lock exclusive} ;# Lock writer
+lappend expected_locks {2 6 lock exclusive} ;# Lock recovery & all aReadMark[]
+lappend expected_locks {2 6 unlock exclusive} ;# Unlock recovery & aReadMark[]
+lappend expected_locks {0 1 unlock exclusive} ;# Unlock writer
+lappend expected_locks {3 1 lock exclusive} ;# Lock aReadMark[0]
+lappend expected_locks {3 1 unlock exclusive} ;# Unlock aReadMark[0]
+lappend expected_locks {1 1 unlock exclusive} ;# Unlock checkpoint
+do_test wal2-5.1 {
+ proc tvfs_cb {method args} {
+ set ::shm_file [lindex $args 0]
+ if {$method == "xShmLock"} { lappend ::locks [lindex $args 2] }
+ return $::tvfs_cb_return
+ }
+ set tvfs_cb_return SQLITE_OK
+
+ testvfs tvfs
+ tvfs script tvfs_cb
+
+ sqlite3 db test.db -vfs tvfs
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE x(y);
+ INSERT INTO x VALUES(1);
+ }
+
+ incr_tvfs_hdr $::shm_file 1 1
+ set ::locks [list]
+ execsql { PRAGMA wal_checkpoint }
+ set ::locks
+} $expected_locks
+db close
+tvfs delete
+
+#-------------------------------------------------------------------------
+# This block, test cases wal2-6.*, tests the operation of WAL with
+# "PRAGMA locking_mode=EXCLUSIVE" set.
+#
+# wal2-6.1.*: Changing to WAL mode before setting locking_mode=exclusive.
+#
+# wal2-6.2.*: Changing to WAL mode after setting locking_mode=exclusive.
+#
+# wal2-6.3.*: Changing back to rollback mode from WAL mode after setting
+# locking_mode=exclusive.
+#
+# wal2-6.4.*: Check that xShmLock calls are omitted in exclusive locking
+# mode.
+#
+# wal2-6.5.*:
+#
+# wal2-6.6.*: Check that if the xShmLock() to reaquire a WAL read-lock when
+# exiting exclusive mode fails (i.e. SQLITE_IOERR), then the
+# connection silently remains in exclusive mode.
+#
+do_test wal2-6.1.1 {
+ forcedelete test.db test.db-wal test.db-journal
+ sqlite3 db test.db
+ execsql {
+ Pragma Journal_Mode = Wal;
+ }
+} {wal}
+do_test wal2-6.1.2 {
+ execsql { PRAGMA lock_status }
+} {main unlocked temp closed}
+do_test wal2-6.1.3 {
+ execsql {
+ SELECT * FROM sqlite_master;
+ Pragma Locking_Mode = Exclusive;
+ }
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ COMMIT;
+ PRAGMA lock_status;
+ }
+} {main exclusive temp closed}
+do_test wal2-6.1.4 {
+ execsql {
+ PRAGMA locking_mode = normal;
+ PRAGMA lock_status;
+ }
+} {normal main exclusive temp closed}
+do_test wal2-6.1.5 {
+ execsql {
+ SELECT * FROM t1;
+ PRAGMA lock_status;
+ }
+} {1 2 main shared temp closed}
+do_test wal2-6.1.6 {
+ execsql {
+ INSERT INTO t1 VALUES(3, 4);
+ PRAGMA lock_status;
+ }
+} {main shared temp closed}
+db close
+
+do_test wal2-6.2.1 {
+ forcedelete test.db test.db-wal test.db-journal
+ sqlite3 db test.db
+ execsql {
+ Pragma Locking_Mode = Exclusive;
+ Pragma Journal_Mode = Wal;
+ Pragma Lock_Status;
+ }
+} {exclusive wal main exclusive temp closed}
+do_test wal2-6.2.2 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ COMMIT;
+ Pragma loCK_STATus;
+ }
+} {main exclusive temp closed}
+do_test wal2-6.2.3 {
+ db close
+ sqlite3 db test.db
+ execsql { SELECT * FROM sqlite_master }
+ execsql { PRAGMA LOCKING_MODE = EXCLUSIVE }
+} {exclusive}
+do_test wal2-6.2.4 {
+ execsql {
+ SELECT * FROM t1;
+ pragma lock_status;
+ }
+} {1 2 main shared temp closed}
+do_test wal2-6.2.5 {
+ execsql {
+ INSERT INTO t1 VALUES(3, 4);
+ pragma lock_status;
+ }
+} {main exclusive temp closed}
+do_test wal2-6.2.6 {
+ execsql {
+ PRAGMA locking_mode = NORMAL;
+ pragma lock_status;
+ }
+} {normal main exclusive temp closed}
+do_test wal2-6.2.7 {
+ execsql {
+ BEGIN IMMEDIATE; COMMIT;
+ pragma lock_status;
+ }
+} {main shared temp closed}
+do_test wal2-6.2.8 {
+ execsql {
+ PRAGMA locking_mode = EXCLUSIVE;
+ BEGIN IMMEDIATE; COMMIT;
+ PRAGMA locking_mode = NORMAL;
+ }
+ execsql {
+ SELECT * FROM t1;
+ pragma lock_status;
+ }
+} {1 2 3 4 main shared temp closed}
+do_test wal2-6.2.9 {
+ execsql {
+ INSERT INTO t1 VALUES(5, 6);
+ SELECT * FROM t1;
+ pragma lock_status;
+ }
+} {1 2 3 4 5 6 main shared temp closed}
+db close
+
+do_test wal2-6.3.1 {
+ forcedelete test.db test.db-wal test.db-journal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA journal_mode = WAL;
+ PRAGMA locking_mode = exclusive;
+ BEGIN;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('Chico');
+ INSERT INTO t1 VALUES('Harpo');
+ COMMIT;
+ }
+ list [file exists test.db-wal] [file exists test.db-journal]
+} {1 0}
+do_test wal2-6.3.2 {
+ execsql { PRAGMA journal_mode = DELETE }
+ file exists test.db-wal
+} {0}
+do_test wal2-6.3.3 {
+ execsql { PRAGMA lock_status }
+} {main exclusive temp closed}
+do_test wal2-6.3.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('Groucho');
+ }
+ list [file exists test.db-wal] [file exists test.db-journal]
+} {0 1}
+do_test wal2-6.3.5 {
+ execsql { PRAGMA lock_status }
+} {main exclusive temp closed}
+do_test wal2-6.3.6 {
+ execsql { COMMIT }
+ list [file exists test.db-wal] [file exists test.db-journal]
+} {0 1}
+do_test wal2-6.3.7 {
+ execsql { PRAGMA lock_status }
+} {main exclusive temp closed}
+db close
+
+
+# This test - wal2-6.4.* - uses a single database connection and the
+# [testvfs] instrumentation to test that xShmLock() is being called
+# as expected when a WAL database is used with locking_mode=exclusive.
+#
+do_test wal2-6.4.1 {
+ forcedelete test.db test.db-wal test.db-journal
+ proc tvfs_cb {method args} {
+ set ::shm_file [lindex $args 0]
+ if {$method == "xShmLock"} { lappend ::locks [lindex $args 2] }
+ return "SQLITE_OK"
+ }
+ testvfs tvfs
+ tvfs script tvfs_cb
+ sqlite3 db test.db -vfs tvfs
+ set {} {}
+} {}
+
+set RECOVERY {
+ {0 1 lock exclusive} {1 7 lock exclusive}
+ {1 7 unlock exclusive} {0 1 unlock exclusive}
+}
+set READMARK0_READ {
+ {3 1 lock shared} {3 1 unlock shared}
+}
+set READMARK0_WRITE {
+ {3 1 lock shared}
+ {0 1 lock exclusive} {3 1 unlock shared}
+ {4 1 lock exclusive} {4 1 unlock exclusive} {4 1 lock shared}
+ {0 1 unlock exclusive} {4 1 unlock shared}
+}
+set READMARK1_SET {
+ {4 1 lock exclusive} {4 1 unlock exclusive}
+}
+set READMARK1_READ {
+ {4 1 lock shared} {4 1 unlock shared}
+}
+set READMARK1_WRITE {
+ {4 1 lock shared}
+ {0 1 lock exclusive} {0 1 unlock exclusive}
+ {4 1 unlock shared}
+}
+
+foreach {tn sql res expected_locks} {
+ 2 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ BEGIN;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('Leonard');
+ INSERT INTO t1 VALUES('Arthur');
+ COMMIT;
+ } {wal} {
+ $RECOVERY
+ $READMARK0_WRITE
+ }
+
+ 3 {
+ # This test should do the READMARK1_SET locking to populate the
+ # aReadMark[1] slot with the current mxFrame value. Followed by
+ # READMARK1_READ to read the database.
+ #
+ SELECT * FROM t1
+ } {Leonard Arthur} {
+ $READMARK1_SET
+ $READMARK1_READ
+ }
+
+ 4 {
+ # aReadMark[1] is already set to mxFrame. So just READMARK1_READ
+ # this time, not READMARK1_SET.
+ #
+ SELECT * FROM t1 ORDER BY x
+ } {Arthur Leonard} {
+ $READMARK1_READ
+ }
+
+ 5 {
+ PRAGMA locking_mode = exclusive
+ } {exclusive} { }
+
+ 6 {
+ INSERT INTO t1 VALUES('Julius Henry');
+ SELECT * FROM t1;
+ } {Leonard Arthur {Julius Henry}} {
+ $READMARK1_READ
+ }
+
+ 7 {
+ INSERT INTO t1 VALUES('Karl');
+ SELECT * FROM t1;
+ } {Leonard Arthur {Julius Henry} Karl} { }
+
+ 8 {
+ PRAGMA locking_mode = normal
+ } {normal} { }
+
+ 9 {
+ SELECT * FROM t1 ORDER BY x
+ } {Arthur {Julius Henry} Karl Leonard} $READMARK1_READ
+
+ 10 { DELETE FROM t1 } {} $READMARK1_WRITE
+
+ 11 {
+ SELECT * FROM t1
+ } {} {
+ $READMARK1_SET
+ $READMARK1_READ
+ }
+} {
+
+ set L [list]
+ foreach el [subst $expected_locks] { lappend L $el }
+
+ set S ""
+ foreach sq [split $sql "\n"] {
+ set sq [string trim $sq]
+ if {[string match {#*} $sq]==0} {append S "$sq\n"}
+ }
+
+ set ::locks [list]
+ do_test wal2-6.4.$tn.1 { execsql $S } $res
+ do_test wal2-6.4.$tn.2 { set ::locks } $L
+}
+
+db close
+tvfs delete
+
+do_test wal2-6.5.1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = wal;
+ PRAGMA locking_mode = exclusive;
+ CREATE TABLE t2(a, b);
+ PRAGMA wal_checkpoint;
+ INSERT INTO t2 VALUES('I', 'II');
+ PRAGMA journal_mode;
+ }
+} {wal exclusive 0 3 3 wal}
+do_test wal2-6.5.2 {
+ execsql {
+ PRAGMA locking_mode = normal;
+ INSERT INTO t2 VALUES('III', 'IV');
+ PRAGMA locking_mode = exclusive;
+ SELECT * FROM t2;
+ }
+} {normal exclusive I II III IV}
+do_test wal2-6.5.3 {
+ execsql { PRAGMA wal_checkpoint }
+} {0 4 4}
+db close
+
+proc lock_control {method filename handle spec} {
+ foreach {start n op type} $spec break
+ if {$op == "lock"} { return SQLITE_IOERR }
+ return SQLITE_OK
+}
+do_test wal2-6.6.1 {
+ testvfs T
+ T script lock_control
+ T filter {}
+ sqlite3 db test.db -vfs T
+ execsql { SELECT * FROM sqlite_master }
+ execsql { PRAGMA locking_mode = exclusive }
+ execsql { INSERT INTO t2 VALUES('V', 'VI') }
+} {}
+do_test wal2-6.6.2 {
+ execsql { PRAGMA locking_mode = normal }
+ T filter xShmLock
+ execsql { INSERT INTO t2 VALUES('VII', 'VIII') }
+} {}
+do_test wal2-6.6.3 {
+ # At this point the connection should still be in exclusive-mode, even
+ # though it tried to exit exclusive-mode when committing the INSERT
+ # statement above. To exit exclusive mode, SQLite has to take a read-lock
+ # on the WAL file using xShmLock(). Since that call failed, it remains
+ # in exclusive mode.
+ #
+ sqlite3 db2 test.db -vfs T
+ catchsql { SELECT * FROM t2 } db2
+} {1 {database is locked}}
+do_test wal2-6.6.2 {
+ db2 close
+ T filter {}
+ execsql { INSERT INTO t2 VALUES('IX', 'X') }
+} {}
+do_test wal2-6.6.4 {
+ # This time, we have successfully exited exclusive mode. So the second
+ # connection can read the database.
+ sqlite3 db2 test.db -vfs T
+ catchsql { SELECT * FROM t2 } db2
+} {0 {I II III IV V VI VII VIII IX X}}
+
+db close
+db2 close
+T delete
+
+#-------------------------------------------------------------------------
+# Test a theory about the checksum algorithm. Theory was false and this
+# test did not provoke a bug.
+#
+forcedelete test.db test.db-wal test.db-journal
+do_test wal2-7.1.1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 4096;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ }
+ file size test.db
+} {4096}
+do_test wal2-7.1.2 {
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+ hexio_write test2.db-wal 48 FF
+} {1}
+do_test wal2-7.1.3 {
+ sqlite3 db2 test2.db
+ execsql { PRAGMA wal_checkpoint } db2
+ execsql { SELECT * FROM sqlite_master } db2
+} {}
+db close
+db2 close
+forcedelete test.db test.db-wal test.db-journal
+do_test wal2-8.1.2 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(zeroblob(8188*1020));
+ CREATE TABLE t2(y);
+ PRAGMA wal_checkpoint;
+ }
+ execsql {
+ SELECT rootpage>=8192 FROM sqlite_master WHERE tbl_name = 't2';
+ }
+} {1}
+do_test wal2-8.1.3 {
+ execsql {
+ PRAGMA cache_size = 10;
+ CREATE TABLE t3(z);
+ BEGIN;
+ INSERT INTO t3 VALUES(randomblob(900));
+ INSERT INTO t3 SELECT randomblob(900) FROM t3;
+ INSERT INTO t2 VALUES('hello');
+ INSERT INTO t3 SELECT randomblob(900) FROM t3;
+ INSERT INTO t3 SELECT randomblob(900) FROM t3;
+ INSERT INTO t3 SELECT randomblob(900) FROM t3;
+ INSERT INTO t3 SELECT randomblob(900) FROM t3;
+ INSERT INTO t3 SELECT randomblob(900) FROM t3;
+ INSERT INTO t3 SELECT randomblob(900) FROM t3;
+ ROLLBACK;
+ }
+ execsql {
+ INSERT INTO t2 VALUES('goodbye');
+ INSERT INTO t3 SELECT randomblob(900) FROM t3;
+ INSERT INTO t3 SELECT randomblob(900) FROM t3;
+ }
+} {}
+do_test wal2-8.1.4 {
+ sqlite3 db2 test.db
+ execsql { SELECT * FROM t2 }
+} {goodbye}
+db2 close
+db close
+
+#-------------------------------------------------------------------------
+# Test that even if the checksums for both are valid, if the two copies
+# of the wal-index header in the wal-index do not match, the client
+# runs (or at least tries to run) database recovery.
+#
+#
+proc get_name {method args} { set ::filename [lindex $args 0] ; tvfs filter {} }
+testvfs tvfs
+tvfs script get_name
+tvfs filter xShmOpen
+
+forcedelete test.db test.db-wal test.db-journal
+do_test wal2-9.1 {
+ sqlite3 db test.db -vfs tvfs
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE x(y);
+ INSERT INTO x VALUES('Barton');
+ INSERT INTO x VALUES('Deakin');
+ }
+
+ # Set $wih(1) to the contents of the wal-index header after
+ # the frames associated with the first two rows in table 'x' have
+ # been inserted. Then insert one more row and set $wih(2)
+ # to the new value of the wal-index header.
+ #
+ # If the $wih(1) is written into the wal-index before running
+ # a read operation, the client will see only the first two rows. If
+ # $wih(2) is written into the wal-index, the client will see
+ # three rows. If an invalid header is written into the wal-index, then
+ # the client will run recovery and see three rows.
+ #
+ set wih(1) [set_tvfs_hdr $::filename]
+ execsql { INSERT INTO x VALUES('Watson') }
+ set wih(2) [set_tvfs_hdr $::filename]
+
+ sqlite3 db2 test.db -vfs tvfs
+ execsql { SELECT * FROM x } db2
+} {Barton Deakin Watson}
+
+foreach {tn hdr1 hdr2 res} [list \
+ 3 $wih(1) $wih(1) {Barton Deakin} \
+ 4 $wih(1) $wih(2) {Barton Deakin Watson} \
+ 5 $wih(2) $wih(1) {Barton Deakin Watson} \
+ 6 $wih(2) $wih(2) {Barton Deakin Watson} \
+ 7 $wih(1) $wih(1) {Barton Deakin} \
+ 8 {0 0 0 0 0 0 0 0 0 0 0 0} {0 0 0 0 0 0 0 0 0 0 0 0} {Barton Deakin Watson}
+] {
+ do_test wal2-9.$tn {
+ set_tvfs_hdr $::filename $hdr1 $hdr2
+ execsql { SELECT * FROM x } db2
+ } $res
+}
+
+db2 close
+db close
+
+#-------------------------------------------------------------------------
+# This block of tests - wal2-10.* - focus on the libraries response to
+# new versions of the wal or wal-index formats.
+#
+# wal2-10.1.*: Test that the library refuses to "recover" a new WAL
+# format.
+#
+# wal2-10.2.*: Test that the library refuses to read or write a database
+# if the wal-index version is newer than it understands.
+#
+# At time of writing, the only versions of the wal and wal-index formats
+# that exist are versions 3007000 (corresponding to SQLite version 3.7.0,
+# the first version of SQLite to feature wal mode).
+#
+do_test wal2-10.1.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ faultsim_save_and_close
+} {}
+do_test wal2-10.1.2 {
+ faultsim_restore_and_reopen
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+do_test wal2-10.1.3 {
+ faultsim_restore_and_reopen
+ set hdr [wal_set_walhdr test.db-wal]
+ lindex $hdr 1
+} {3007000}
+do_test wal2-10.1.4 {
+ lset hdr 1 3007001
+ wal_set_walhdr test.db-wal $hdr
+ catchsql { SELECT * FROM t1 }
+} {1 {unable to open database file}}
+
+testvfs tvfs -default 1
+do_test wal2-10.2.1 {
+ faultsim_restore_and_reopen
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+do_test wal2-10.2.2 {
+ set hdr [set_tvfs_hdr $::filename]
+ lindex $hdr 0
+} {3007000}
+do_test wal2-10.2.3 {
+ lset hdr 0 3007001
+ wal_fix_walindex_cksum hdr
+ set_tvfs_hdr $::filename $hdr
+ catchsql { SELECT * FROM t1 }
+} {1 {unable to open database file}}
+db close
+tvfs delete
+
+#-------------------------------------------------------------------------
+# This block of tests - wal2-11.* - tests that it is not possible to put
+# the library into an infinite loop by presenting it with a corrupt
+# hash table (one that appears to contain a single chain of infinite
+# length).
+#
+# wal2-11.1.*: While reading the hash-table.
+#
+# wal2-11.2.*: While writing the hash-table.
+#
+testvfs tvfs -default 1
+do_test wal2-11.0 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ INSERT INTO t1 VALUES(7, 8, 9);
+ SELECT * FROM t1;
+ }
+} {wal 1 2 3 4 5 6 7 8 9}
+
+do_test wal2-11.1.1 {
+ sqlite3 db2 test.db
+ execsql { SELECT name FROM sqlite_master } db2
+} {t1}
+
+if {$::tcl_version>=8.5} {
+ # Set all zeroed slots in the first hash table to invalid values.
+ #
+ set blob [string range [tvfs shm $::filename] 0 16383]
+ set I [string range [tvfs shm $::filename] 16384 end]
+ binary scan $I t* L
+ set I [list]
+ foreach p $L {
+ lappend I [expr $p ? $p : 400]
+ }
+ append blob [binary format t* $I]
+ tvfs shm $::filename $blob
+ do_test wal2-11.2 {
+ catchsql { INSERT INTO t1 VALUES(10, 11, 12) }
+ } {1 {database disk image is malformed}}
+
+ # Fill up the hash table on the first page of shared memory with 0x55 bytes.
+ #
+ set blob [string range [tvfs shm $::filename] 0 16383]
+ append blob [string repeat [binary format c 55] 16384]
+ tvfs shm $::filename $blob
+ do_test wal2-11.3 {
+ catchsql { SELECT * FROM t1 } db2
+ } {1 {database disk image is malformed}}
+}
+
+db close
+db2 close
+tvfs delete
+
+#-------------------------------------------------------------------------
+# If a connection is required to create a WAL or SHM file, it creates
+# the new files with the same file-system permissions as the database
+# file itself. Test this.
+#
+if {$::tcl_platform(platform) == "unix"} {
+ faultsim_delete_and_reopen
+ set umask [exec /bin/sh -c umask]
+
+ do_test wal2-12.1 {
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE tx(y, z);
+ PRAGMA journal_mode = WAL;
+ }
+ db close
+ list [file exists test.db-wal] [file exists test.db-shm]
+ } {0 0}
+
+ foreach {tn permissions} {
+ 1 00644
+ 2 00666
+ 3 00600
+ 4 00755
+ } {
+ set effective [format %.5o [expr $permissions & ~$umask]]
+ do_test wal2-12.2.$tn.1 {
+ file attributes test.db -permissions $permissions
+ file attributes test.db -permissions
+ } $permissions
+ do_test wal2-12.2.$tn.2 {
+ list [file exists test.db-wal] [file exists test.db-shm]
+ } {0 0}
+ do_test wal2-12.2.$tn.3 {
+ sqlite3 db test.db
+ execsql { INSERT INTO tx DEFAULT VALUES }
+ list [file exists test.db-wal] [file exists test.db-shm]
+ } {1 1}
+ do_test wal2-12.2.$tn.4 {
+ list [file attr test.db-wal -perm] [file attr test.db-shm -perm]
+ } [list $effective $effective]
+ do_test wal2-12.2.$tn.5 {
+ db close
+ list [file exists test.db-wal] [file exists test.db-shm]
+ } {0 0}
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test the libraries response to discovering that one or more of the
+# database, wal or shm files cannot be opened, or can only be opened
+# read-only.
+#
+if {$::tcl_platform(platform) == "unix"} {
+ proc perm {} {
+ set L [list]
+ foreach f {test.db test.db-wal test.db-shm} {
+ if {[file exists $f]} {
+ lappend L [file attr $f -perm]
+ } else {
+ lappend L {}
+ }
+ }
+ set L
+ }
+
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES('3.14', '2.72');
+ }
+ do_test wal2-13.1.1 {
+ list [file exists test.db-shm] [file exists test.db-wal]
+ } {1 1}
+ faultsim_save_and_close
+
+ foreach {tn db_perm wal_perm shm_perm can_open can_read can_write} {
+ 2 00644 00644 00644 1 1 1
+ 3 00644 00400 00644 1 1 0
+ 4 00644 00644 00400 1 0 0
+ 5 00400 00644 00644 1 1 0
+
+ 7 00644 00000 00644 1 0 0
+ 8 00644 00644 00000 1 0 0
+ 9 00000 00644 00644 0 0 0
+ } {
+ faultsim_restore
+ do_test wal2-13.$tn.1 {
+ file attr test.db -perm $db_perm
+ file attr test.db-wal -perm $wal_perm
+ file attr test.db-shm -perm $shm_perm
+
+ set L [file attr test.db -perm]
+ lappend L [file attr test.db-wal -perm]
+ lappend L [file attr test.db-shm -perm]
+ } [list $db_perm $wal_perm $shm_perm]
+
+ # If $can_open is true, then it should be possible to open a database
+ # handle. Otherwise, if $can_open is 0, attempting to open the db
+ # handle throws an "unable to open database file" exception.
+ #
+ set r(1) {0 ok}
+ set r(0) {1 {unable to open database file}}
+ do_test wal2-13.$tn.2 {
+ list [catch {sqlite3 db test.db ; set {} ok} msg] $msg
+ } $r($can_open)
+
+ if {$can_open} {
+
+ # If $can_read is true, then the client should be able to read from
+ # the database file. If $can_read is false, attempting to read should
+ # throw the "unable to open database file" exception.
+ #
+ set a(0) {1 {unable to open database file}}
+ set a(1) {0 {3.14 2.72}}
+ do_test wal2-13.$tn.3 {
+ catchsql { SELECT * FROM t1 }
+ } $a($can_read)
+
+ # Now try to write to the db file. If the client can read but not
+ # write, then it should throw the familiar "unable to open db file"
+ # exception. If it can read but not write, the exception should
+ # be "attempt to write a read only database".
+ #
+ # If the client can read and write, the operation should succeed.
+ #
+ set b(0,0) {1 {unable to open database file}}
+ set b(1,0) {1 {attempt to write a readonly database}}
+ set b(1,1) {0 {}}
+ do_test wal2-13.$tn.4 {
+ catchsql { INSERT INTO t1 DEFAULT VALUES }
+ } $b($can_read,$can_write)
+ }
+ catch { db close }
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test that "PRAGMA checkpoint_fullsync" appears to be working.
+#
+foreach {tn sql reslist} {
+ 1 { } {8 0 3 0 5 0}
+ 2 { PRAGMA checkpoint_fullfsync = 1 } {8 4 3 2 5 2}
+ 3 { PRAGMA checkpoint_fullfsync = 0 } {8 0 3 0 5 0}
+} {
+ faultsim_delete_and_reopen
+
+ execsql {PRAGMA auto_vacuum = 0}
+ execsql $sql
+ do_execsql_test wal2-14.$tn.1 { PRAGMA journal_mode = WAL } {wal}
+
+ set sqlite_sync_count 0
+ set sqlite_fullsync_count 0
+
+ do_execsql_test wal2-14.$tn.2 {
+ PRAGMA wal_autocheckpoint = 10;
+ CREATE TABLE t1(a, b); -- 2 wal syncs
+ INSERT INTO t1 VALUES(1, 2); -- 1 wal sync
+ PRAGMA wal_checkpoint; -- 1 wal sync, 1 db sync
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ COMMIT; -- 1 wal sync
+ PRAGMA wal_checkpoint; -- 1 wal sync, 1 db sync
+ } {10 0 5 5 0 2 2}
+
+ do_test wal2-14.$tn.3 {
+ cond_incr_sync_count 1
+ list $sqlite_sync_count $sqlite_fullsync_count
+ } [lrange $reslist 0 1]
+
+ set sqlite_sync_count 0
+ set sqlite_fullsync_count 0
+
+ do_test wal2-14.$tn.4 {
+ execsql { INSERT INTO t1 VALUES(7, zeroblob(12*4096)) }
+ list $sqlite_sync_count $sqlite_fullsync_count
+ } [lrange $reslist 2 3]
+
+ set sqlite_sync_count 0
+ set sqlite_fullsync_count 0
+
+ do_test wal2-14.$tn.5 {
+ execsql { PRAGMA wal_autocheckpoint = 1000 }
+ execsql { INSERT INTO t1 VALUES(9, 10) }
+ execsql { INSERT INTO t1 VALUES(11, 12) }
+ execsql { INSERT INTO t1 VALUES(13, 14) }
+ db close
+ list $sqlite_sync_count $sqlite_fullsync_count
+ } [lrange $reslist 4 5]
+}
+
+catch { db close }
+
+# PRAGMA checkpoint_fullsync
+# PRAGMA fullfsync
+# PRAGMA synchronous
+#
+foreach {tn settings commit_sync ckpt_sync} {
+ 1 {0 0 off} {0 0} {0 0}
+ 2 {0 0 normal} {0 0} {2 0}
+ 3 {0 0 full} {1 0} {2 0}
+
+ 4 {0 1 off} {0 0} {0 0}
+ 5 {0 1 normal} {0 0} {0 2}
+ 6 {0 1 full} {0 1} {0 2}
+
+ 7 {1 0 off} {0 0} {0 0}
+ 8 {1 0 normal} {0 0} {0 2}
+ 9 {1 0 full} {1 0} {0 2}
+
+ 10 {1 1 off} {0 0} {0 0}
+ 11 {1 1 normal} {0 0} {0 2}
+ 12 {1 1 full} {0 1} {0 2}
+} {
+ forcedelete test.db
+
+ testvfs tvfs -default 1
+ tvfs filter xSync
+ tvfs script xSyncCb
+ proc xSyncCb {method file fileid flags} {
+ incr ::sync($flags)
+ }
+
+ sqlite3 db test.db
+ do_execsql_test 15.$tn.1 "
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = WAL;
+ PRAGMA checkpoint_fullfsync = [lindex $settings 0];
+ PRAGMA fullfsync = [lindex $settings 1];
+ PRAGMA synchronous = [lindex $settings 2];
+ " {wal}
+
+ do_test 15.$tn.2 {
+ set sync(normal) 0
+ set sync(full) 0
+ execsql { INSERT INTO t1 VALUES('abc') }
+ list $::sync(normal) $::sync(full)
+ } $commit_sync
+
+ do_test 15.$tn.3 {
+ set sync(normal) 0
+ set sync(full) 0
+ execsql { INSERT INTO t1 VALUES('def') }
+ list $::sync(normal) $::sync(full)
+ } $commit_sync
+
+ do_test 15.$tn.4 {
+ set sync(normal) 0
+ set sync(full) 0
+ execsql { PRAGMA wal_checkpoint }
+ list $::sync(normal) $::sync(full)
+ } $ckpt_sync
+
+ db close
+ tvfs delete
+}
+
+
+
+finish_test
diff --git a/test/wal3.test b/test/wal3.test
new file mode 100644
index 0000000..ea5e705
--- /dev/null
+++ b/test/wal3.test
@@ -0,0 +1,786 @@
+# 2010 April 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/wal_common.tcl
+source $testdir/malloc_common.tcl
+ifcapable !wal {finish_test ; return }
+
+set a_string_counter 1
+proc a_string {n} {
+ global a_string_counter
+ incr a_string_counter
+ string range [string repeat "${a_string_counter}." $n] 1 $n
+}
+db func a_string a_string
+
+#-------------------------------------------------------------------------
+# When a rollback or savepoint rollback occurs, the client may remove
+# elements from one of the hash tables in the wal-index. This block
+# of test cases tests that nothing appears to go wrong when this is
+# done.
+#
+do_test wal3-1.0 {
+ execsql {
+ PRAGMA cache_size = 2000;
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = off;
+ PRAGMA synchronous = normal;
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 0;
+ BEGIN;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES( a_string(800) ); /* 1 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 64 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 128*/
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 256 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 512 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 1024 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1; /* 2048 */
+ INSERT INTO t1 SELECT a_string(800) FROM t1 LIMIT 1970; /* 4018 */
+ COMMIT;
+ PRAGMA cache_size = 10;
+ }
+ wal_frame_count test.db-wal 1024
+} 4056
+
+for {set i 1} {$i < 50} {incr i} {
+
+ do_test wal3-1.$i.1 {
+ set str [a_string 800]
+ execsql { UPDATE t1 SET x = $str WHERE rowid = $i }
+ lappend L [wal_frame_count test.db-wal 1024]
+ execsql {
+ BEGIN;
+ INSERT INTO t1 SELECT a_string(800) FROM t1 LIMIT 100;
+ ROLLBACK;
+ PRAGMA integrity_check;
+ }
+ } {ok}
+
+ # Check that everything looks OK from the point of view of an
+ # external connection.
+ #
+ sqlite3 db2 test.db
+ do_test wal3-1.$i.2 {
+ execsql { SELECT count(*) FROM t1 } db2
+ } 4018
+ do_test wal3-1.$i.3 {
+ execsql { SELECT x FROM t1 WHERE rowid = $i }
+ } $str
+ do_test wal3-1.$i.4 {
+ execsql { PRAGMA integrity_check } db2
+ } {ok}
+ db2 close
+
+ # Check that the file-system in its current state can be recovered.
+ #
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+ forcedelete test2.db-journal
+ sqlite3 db2 test2.db
+ do_test wal3-1.$i.5 {
+ execsql { SELECT count(*) FROM t1 } db2
+ } 4018
+ do_test wal3-1.$i.6 {
+ execsql { SELECT x FROM t1 WHERE rowid = $i }
+ } $str
+ do_test wal3-1.$i.7 {
+ execsql { PRAGMA integrity_check } db2
+ } {ok}
+ db2 close
+}
+
+proc byte_is_zero {file offset} {
+ if {[file size test.db] <= $offset} { return 1 }
+ expr { [hexio_read $file $offset 1] == "00" }
+}
+
+do_multiclient_test i {
+
+ set testname(1) multiproc
+ set testname(2) singleproc
+ set tn $testname($i)
+
+ do_test wal3-2.$tn.1 {
+ sql1 {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ }
+ sql1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ } {1 one}
+ do_test wal3-2.$tn.2 {
+ sql2 {
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES(2, 'two');
+ BEGIN;
+ SELECT * FROM t2;
+ }
+ } {2 two}
+ do_test wal3-2.$tn.3 {
+ sql3 {
+ CREATE TABLE t3(a, b);
+ INSERT INTO t3 VALUES(3, 'three');
+ BEGIN;
+ SELECT * FROM t3;
+ }
+ } {3 three}
+
+ # Try to checkpoint the database using [db]. It should be possible to
+ # checkpoint everything except the table added by [db3] (checkpointing
+ # these frames would clobber the snapshot currently being used by [db2]).
+ #
+ # After [db2] has committed, a checkpoint can copy the entire log to the
+ # database file. Checkpointing after [db3] has committed is therefore a
+ # no-op, as the entire log has already been backfilled.
+ #
+ do_test wal3-2.$tn.4 {
+ sql1 {
+ COMMIT;
+ PRAGMA wal_checkpoint;
+ }
+ byte_is_zero test.db [expr $AUTOVACUUM ? 4*1024 : 3*1024]
+ } {1}
+ do_test wal3-2.$tn.5 {
+ sql2 {
+ COMMIT;
+ PRAGMA wal_checkpoint;
+ }
+ list [byte_is_zero test.db [expr $AUTOVACUUM ? 4*1024 : 3*1024]] \
+ [byte_is_zero test.db [expr $AUTOVACUUM ? 5*1024 : 4*1024]]
+ } {0 1}
+ do_test wal3-2.$tn.6 {
+ sql3 {
+ COMMIT;
+ PRAGMA wal_checkpoint;
+ }
+ list [byte_is_zero test.db [expr $AUTOVACUUM ? 4*1024 : 3*1024]] \
+ [byte_is_zero test.db [expr $AUTOVACUUM ? 5*1024 : 4*1024]]
+ } {0 1}
+}
+catch {db close}
+
+#-------------------------------------------------------------------------
+# Test that that for the simple test:
+#
+# CREATE TABLE x(y);
+# INSERT INTO x VALUES('z');
+# PRAGMA wal_checkpoint;
+#
+# in WAL mode the xSync method is invoked as expected for each of
+# synchronous=off, synchronous=normal and synchronous=full.
+#
+foreach {tn syncmode synccount} {
+ 1 off
+ {}
+ 2 normal
+ {test.db-wal normal test.db normal}
+ 3 full
+ {test.db-wal normal test.db-wal normal test.db-wal normal test.db normal}
+} {
+
+ proc sync_counter {args} {
+ foreach {method filename id flags} $args break
+ lappend ::syncs [file tail $filename] $flags
+ }
+ do_test wal3-3.$tn {
+ forcedelete test.db test.db-wal test.db-journal
+
+ testvfs T
+ T filter {}
+ T script sync_counter
+ sqlite3 db test.db -vfs T
+
+ execsql "PRAGMA synchronous = $syncmode"
+ execsql { PRAGMA journal_mode = WAL }
+
+ set ::syncs [list]
+ T filter xSync
+ execsql {
+ CREATE TABLE x(y);
+ INSERT INTO x VALUES('z');
+ PRAGMA wal_checkpoint;
+ }
+ T filter {}
+ set ::syncs
+ } $synccount
+
+ db close
+ T delete
+}
+
+#-------------------------------------------------------------------------
+# When recovering the contents of a WAL file, a process obtains the WRITER
+# lock, then locks all other bytes before commencing recovery. If it fails
+# to lock all other bytes (because some other process is holding a read
+# lock) it should retry up to 100 times. Then return SQLITE_PROTOCOL to the
+# caller. Test this (test case wal3-4.3).
+#
+# Also test the effect of hitting an SQLITE_BUSY while attempting to obtain
+# the WRITER lock (should be the same). Test case wal3-4.4.
+#
+proc lock_callback {method filename handle lock} {
+ lappend ::locks $lock
+}
+do_test wal3-4.1 {
+ testvfs T
+ T filter xShmLock
+ T script lock_callback
+ set ::locks [list]
+ sqlite3 db test.db -vfs T
+ execsql { SELECT * FROM x }
+ lrange $::locks 0 3
+} [list {0 1 lock exclusive} {1 7 lock exclusive} \
+ {1 7 unlock exclusive} {0 1 unlock exclusive} \
+]
+do_test wal3-4.2 {
+ db close
+ set ::locks [list]
+ sqlite3 db test.db -vfs T
+ execsql { SELECT * FROM x }
+ lrange $::locks 0 3
+} [list {0 1 lock exclusive} {1 7 lock exclusive} \
+ {1 7 unlock exclusive} {0 1 unlock exclusive} \
+]
+proc lock_callback {method filename handle lock} {
+ if {$lock == "1 7 lock exclusive"} { return SQLITE_BUSY }
+ return SQLITE_OK
+}
+puts " Warning: This next test case causes SQLite to call xSleep(1) 100 times."
+puts " Normally this equates to a 100ms delay, but if SQLite is built on unix"
+puts " without HAVE_USLEEP defined, it may be 100 seconds."
+do_test wal3-4.3 {
+ db close
+ set ::locks [list]
+ sqlite3 db test.db -vfs T
+ catchsql { SELECT * FROM x }
+} {1 {locking protocol}}
+
+puts " Warning: Same again!"
+proc lock_callback {method filename handle lock} {
+ if {$lock == "0 1 lock exclusive"} { return SQLITE_BUSY }
+ return SQLITE_OK
+}
+do_test wal3-4.4 {
+ db close
+ set ::locks [list]
+ sqlite3 db test.db -vfs T
+ catchsql { SELECT * FROM x }
+} {1 {locking protocol}}
+db close
+T delete
+
+
+#-------------------------------------------------------------------------
+# Only one client may run recovery at a time. Test this mechanism.
+#
+# When client-2 tries to open a read transaction while client-1 is
+# running recovery, it fails to obtain a lock on an aReadMark[] slot
+# (because they are all locked by recovery). It then tries to obtain
+# a shared lock on the RECOVER lock to see if there really is a
+# recovery running or not.
+#
+# This block of tests checks the effect of an SQLITE_BUSY or SQLITE_IOERR
+# being returned when client-2 attempts a shared lock on the RECOVER byte.
+#
+# An SQLITE_BUSY should be converted to an SQLITE_BUSY_RECOVERY. An
+# SQLITE_IOERR should be returned to the caller.
+#
+do_test wal3-5.1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ faultsim_save_and_close
+} {}
+
+testvfs T -default 1
+T script method_callback
+
+proc method_callback {method args} {
+ if {$method == "xShmBarrier"} {
+ incr ::barrier_count
+ if {$::barrier_count == 2} {
+ # This code is executed within the xShmBarrier() callback invoked
+ # by the client running recovery as part of writing the recovered
+ # wal-index header. If a second client attempts to access the
+ # database now, it reads a corrupt (partially written) wal-index
+ # header. But it cannot even get that far, as the first client
+ # is still holding all the locks (recovery takes an exclusive lock
+ # on *all* db locks, preventing access by any other client).
+ #
+ # If global variable ::wal3_do_lockfailure is non-zero, then set
+ # things up so that an IO error occurs within an xShmLock() callback
+ # made by the second client (aka [db2]).
+ #
+ sqlite3 db2 test.db
+ if { $::wal3_do_lockfailure } { T filter xShmLock }
+ set ::testrc [ catch { db2 eval "SELECT * FROM t1" } ::testmsg ]
+ T filter {}
+ db2 close
+ }
+ }
+
+ if {$method == "xShmLock"} {
+ foreach {file handle spec} $args break
+ if { $spec == "2 1 lock shared" } {
+ return SQLITE_IOERR
+ }
+ }
+
+ return SQLITE_OK
+}
+
+# Test a normal SQLITE_BUSY return.
+#
+T filter xShmBarrier
+set testrc ""
+set testmsg ""
+set barrier_count 0
+set wal3_do_lockfailure 0
+do_test wal3-5.2 {
+ faultsim_restore_and_reopen
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+do_test wal3-5.3 {
+ list $::testrc $::testmsg
+} {1 {database is locked}}
+db close
+
+# Test an SQLITE_IOERR return.
+#
+T filter xShmBarrier
+set barrier_count 0
+set wal3_do_lockfailure 1
+set testrc ""
+set testmsg ""
+do_test wal3-5.4 {
+ faultsim_restore_and_reopen
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+do_test wal3-5.5 {
+ list $::testrc $::testmsg
+} {1 {disk I/O error}}
+
+db close
+T delete
+
+#-------------------------------------------------------------------------
+# When opening a read-transaction on a database, if the entire log has
+# already been copied to the database file, the reader grabs a special
+# kind of read lock (on aReadMark[0]). This set of test cases tests the
+# outcome of the following:
+#
+# + The reader discovering that between the time when it determined
+# that the log had been completely backfilled and the lock is obtained
+# that a writer has written to the log. In this case the reader should
+# acquire a different read-lock (not aReadMark[0]) and read the new
+# snapshot.
+#
+# + The attempt to obtain the lock on aReadMark[0] fails with SQLITE_BUSY.
+# This can happen if a checkpoint is ongoing. In this case also simply
+# obtain a different read-lock.
+#
+catch {db close}
+testvfs T -default 1
+do_test wal3-6.1.1 {
+ forcedelete test.db test.db-journal test.db wal
+ sqlite3 db test.db
+ execsql { PRAGMA auto_vacuum = off }
+ execsql { PRAGMA journal_mode = WAL }
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('o', 't');
+ INSERT INTO t1 VALUES('t', 'f');
+ }
+} {}
+do_test wal3-6.1.2 {
+ sqlite3 db2 test.db
+ sqlite3 db3 test.db
+ execsql { BEGIN ; SELECT * FROM t1 } db3
+} {o t t f}
+do_test wal3-6.1.3 {
+ execsql { PRAGMA wal_checkpoint } db2
+} {0 7 7}
+
+# At this point the log file has been fully checkpointed. However,
+# connection [db3] holds a lock that prevents the log from being wrapped.
+# Test case 3.6.1.4 has [db] attempt a read-lock on aReadMark[0]. But
+# as it is obtaining the lock, [db2] appends to the log file.
+#
+T filter xShmLock
+T script lock_callback
+proc lock_callback {method file handle spec} {
+ if {$spec == "3 1 lock shared"} {
+ # This is the callback for [db] to obtain the read lock on aReadMark[0].
+ # Disable future callbacks using [T filter {}] and write to the log
+ # file using [db2]. [db3] is preventing [db2] from wrapping the log
+ # here, so this is an append.
+ T filter {}
+ db2 eval { INSERT INTO t1 VALUES('f', 's') }
+ }
+ return SQLITE_OK
+}
+do_test wal3-6.1.4 {
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+} {o t t f f s}
+
+# [db] should be left holding a read-lock on some slot other than
+# aReadMark[0]. Test this by demonstrating that the read-lock is preventing
+# the log from being wrapped.
+#
+do_test wal3-6.1.5 {
+ db3 eval COMMIT
+ db2 eval { PRAGMA wal_checkpoint }
+ set sz1 [file size test.db-wal]
+ db2 eval { INSERT INTO t1 VALUES('s', 'e') }
+ set sz2 [file size test.db-wal]
+ expr {$sz2>$sz1}
+} {1}
+
+# Test that if [db2] had not interfered when [db] was trying to grab
+# aReadMark[0], it would have been possible to wrap the log in 3.6.1.5.
+#
+do_test wal3-6.1.6 {
+ execsql { COMMIT }
+ execsql { PRAGMA wal_checkpoint } db2
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+} {o t t f f s s e}
+do_test wal3-6.1.7 {
+ db2 eval { PRAGMA wal_checkpoint }
+ set sz1 [file size test.db-wal]
+ db2 eval { INSERT INTO t1 VALUES('n', 't') }
+ set sz2 [file size test.db-wal]
+ expr {$sz2==$sz1}
+} {1}
+
+db3 close
+db2 close
+db close
+
+do_test wal3-6.2.1 {
+ forcedelete test.db test.db-journal test.db wal
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql { PRAGMA auto_vacuum = off }
+ execsql { PRAGMA journal_mode = WAL }
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('h', 'h');
+ INSERT INTO t1 VALUES('l', 'b');
+ }
+} {}
+
+T filter xShmLock
+T script lock_callback
+proc lock_callback {method file handle spec} {
+ if {$spec == "3 1 unlock exclusive"} {
+ T filter {}
+ set ::R [db2 eval {
+ BEGIN;
+ SELECT * FROM t1;
+ }]
+ }
+}
+do_test wal3-6.2.2 {
+ execsql { PRAGMA wal_checkpoint }
+} {0 7 7}
+do_test wal3-6.2.3 {
+ set ::R
+} {h h l b}
+do_test wal3-6.2.4 {
+ set sz1 [file size test.db-wal]
+ execsql { INSERT INTO t1 VALUES('b', 'c'); }
+ set sz2 [file size test.db-wal]
+ expr {$sz2 > $sz1}
+} {1}
+do_test wal3-6.2.5 {
+ db2 eval { COMMIT }
+ execsql { PRAGMA wal_checkpoint }
+ set sz1 [file size test.db-wal]
+ execsql { INSERT INTO t1 VALUES('n', 'o'); }
+ set sz2 [file size test.db-wal]
+ expr {$sz2 == $sz1}
+} {1}
+
+db2 close
+db close
+T delete
+
+#-------------------------------------------------------------------------
+# When opening a read-transaction on a database, if the entire log has
+# not yet been copied to the database file, the reader grabs a read
+# lock on aReadMark[x], where x>0. The following test cases experiment
+# with the outcome of the following:
+#
+# + The reader discovering that between the time when it read the
+# wal-index header and the lock was obtained that a writer has
+# written to the log. In this case the reader should re-read the
+# wal-index header and lock a snapshot corresponding to the new
+# header.
+#
+# + The value in the aReadMark[x] slot has been modified since it was
+# read.
+#
+catch {db close}
+testvfs T -default 1
+do_test wal3-7.1.1 {
+ forcedelete test.db test.db-journal test.db wal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE blue(red PRIMARY KEY, green);
+ }
+} {wal}
+
+T script method_callback
+T filter xOpen
+proc method_callback {method args} {
+ if {$method == "xOpen"} { return "reader" }
+}
+do_test wal3-7.1.2 {
+ sqlite3 db2 test.db
+ execsql { SELECT * FROM blue } db2
+} {}
+
+T filter xShmLock
+set ::locks [list]
+proc method_callback {method file handle spec} {
+ if {$handle != "reader" } { return }
+ if {$method == "xShmLock"} {
+ catch { execsql { INSERT INTO blue VALUES(1, 2) } }
+ catch { execsql { INSERT INTO blue VALUES(3, 4) } }
+ }
+ lappend ::locks $spec
+}
+do_test wal3-7.1.3 {
+ execsql { SELECT * FROM blue } db2
+} {1 2 3 4}
+do_test wal3-7.1.4 {
+ set ::locks
+} {{4 1 lock shared} {4 1 unlock shared} {5 1 lock shared} {5 1 unlock shared}}
+
+set ::locks [list]
+proc method_callback {method file handle spec} {
+ if {$handle != "reader" } { return }
+ if {$method == "xShmLock"} {
+ catch { execsql { INSERT INTO blue VALUES(5, 6) } }
+ }
+ lappend ::locks $spec
+}
+do_test wal3-7.2.1 {
+ execsql { SELECT * FROM blue } db2
+} {1 2 3 4 5 6}
+do_test wal3-7.2.2 {
+ set ::locks
+} {{5 1 lock shared} {5 1 unlock shared} {4 1 lock shared} {4 1 unlock shared}}
+
+db close
+db2 close
+T delete
+
+#-------------------------------------------------------------------------
+#
+do_test wal3-8.1 {
+ forcedelete test.db test.db-journal test.db wal
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA auto_vacuum = off;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE b(c);
+ INSERT INTO b VALUES('Tehran');
+ INSERT INTO b VALUES('Qom');
+ INSERT INTO b VALUES('Markazi');
+ PRAGMA wal_checkpoint;
+ }
+} {wal 0 9 9}
+do_test wal3-8.2 {
+ execsql { SELECT * FROM b }
+} {Tehran Qom Markazi}
+do_test wal3-8.3 {
+ db eval { SELECT * FROM b } {
+ db eval { INSERT INTO b VALUES('Qazvin') }
+ set r [db2 eval { SELECT * FROM b }]
+ break
+ }
+ set r
+} {Tehran Qom Markazi Qazvin}
+do_test wal3-8.4 {
+ execsql {
+ INSERT INTO b VALUES('Gilan');
+ INSERT INTO b VALUES('Ardabil');
+ }
+} {}
+db2 close
+
+faultsim_save_and_close
+testvfs T -default 1
+faultsim_restore_and_reopen
+T filter xShmLock
+T script lock_callback
+
+proc lock_callback {method file handle spec} {
+ if {$spec == "4 1 unlock exclusive"} {
+ T filter {}
+ set ::r [catchsql { SELECT * FROM b } db2]
+ }
+}
+sqlite3 db test.db
+sqlite3 db2 test.db
+do_test wal3-8.5 {
+ execsql { SELECT * FROM b }
+} {Tehran Qom Markazi Qazvin Gilan Ardabil}
+do_test wal3-8.6 {
+ set ::r
+} {1 {locking protocol}}
+
+db close
+db2 close
+
+faultsim_restore_and_reopen
+sqlite3 db2 test.db
+T filter xShmLock
+T script lock_callback
+proc lock_callback {method file handle spec} {
+ if {$spec == "1 7 unlock exclusive"} {
+ T filter {}
+ set ::r [catchsql { SELECT * FROM b } db2]
+ }
+}
+unset ::r
+do_test wal3-8.5 {
+ execsql { SELECT * FROM b }
+} {Tehran Qom Markazi Qazvin Gilan Ardabil}
+do_test wal3-8.6 {
+ set ::r
+} {1 {locking protocol}}
+
+db close
+db2 close
+T delete
+
+#-------------------------------------------------------------------------
+# When a connection opens a read-lock on the database, it searches for
+# an aReadMark[] slot that is already set to the mxFrame value for the
+# new transaction. If it cannot find one, it attempts to obtain an
+# exclusive lock on an aReadMark[] slot for the purposes of modifying
+# the value, then drops back to a shared-lock for the duration of the
+# transaction.
+#
+# This test case verifies that if an exclusive lock cannot be obtained
+# on any aReadMark[] slot (because there are already several readers),
+# the client takes a shared-lock on a slot without modifying the value
+# and continues.
+#
+set nConn 50
+if { [string match *BSD $tcl_platform(os)] } { set nConn 25 }
+do_test wal3-9.0 {
+ forcedelete test.db test.db-journal test.db wal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE whoami(x);
+ INSERT INTO whoami VALUES('nobody');
+ }
+} {wal}
+for {set i 0} {$i < $nConn} {incr i} {
+ set c db$i
+ do_test wal3-9.1.$i {
+ sqlite3 $c test.db
+ execsql { UPDATE whoami SET x = $c }
+ execsql {
+ BEGIN;
+ SELECT * FROM whoami
+ } $c
+ } $c
+}
+for {set i 0} {$i < $nConn} {incr i} {
+ set c db$i
+ do_test wal3-9.2.$i {
+ execsql { SELECT * FROM whoami } $c
+ } $c
+}
+
+set sz [expr 1024 * (2+$AUTOVACUUM)]
+do_test wal3-9.3 {
+ for {set i 0} {$i < ($nConn-1)} {incr i} { db$i close }
+ execsql { PRAGMA wal_checkpoint }
+ byte_is_zero test.db [expr $sz-1024]
+} {1}
+do_test wal3-9.4 {
+ db[expr $nConn-1] close
+ execsql { PRAGMA wal_checkpoint }
+ set sz2 [file size test.db]
+ byte_is_zero test.db [expr $sz-1024]
+} {0}
+
+do_multiclient_test tn {
+ do_test wal3-10.$tn.1 {
+ sql1 {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 100000;
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(800));
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 2
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 4
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 8
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 16
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 32
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 64
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 128
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 256
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 512
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 1024
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 2048
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 4096
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; -- 8192
+ COMMIT;
+ CREATE INDEX i1 ON t1(x);
+ }
+
+ expr {[file size test.db-wal] > [expr 1032*9000]}
+ } 1
+
+ do_test wal3-10.$tn.2 {
+ sql2 {PRAGMA integrity_check}
+ } {ok}
+}
+
+finish_test
diff --git a/test/wal4.test b/test/wal4.test
new file mode 100644
index 0000000..c7a4381
--- /dev/null
+++ b/test/wal4.test
@@ -0,0 +1,64 @@
+# 2010 July 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# Verify that an empty database and a non-empty WAL file do not
+# result in database corruption
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+ifcapable !wal {finish_test ; return }
+
+do_test wal4-1.1 {
+ execsql {
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ SELECT x FROM t1 ORDER BY x;
+ }
+} {wal 1 2}
+
+do_test wal4-1.2 {
+ # Save a copy of the file-system containing the wal and wal-index files
+ # only (no database file).
+ faultsim_save_and_close
+ forcedelete sv_test.db
+} {}
+
+do_test wal4-1.3 {
+ faultsim_restore_and_reopen
+ catchsql { SELECT * FROM t1 }
+} {1 {no such table: t1}}
+
+do_faultsim_test wal4-2 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { SELECT name FROM sqlite_master }
+} -test {
+ # Result should be zero rows (empty db file).
+ #
+ faultsim_test_result {0 {}}
+
+ # If the SELECT finished successfully, the WAL file should have been
+ # deleted. In no case should the database file have been written, so
+ # it should still be zero bytes in size regardless of whether or not
+ # a fault was injected. Test these assertions:
+ #
+ if { $testrc==0 && [file exists test.db-wal] } {
+ error "Wal file was not deleted"
+ }
+ if { [file size test.db]!=0 } {
+ error "Db file grew to [file size test.db] bytes"
+ }
+}
+
+finish_test
diff --git a/test/wal5.test b/test/wal5.test
new file mode 100644
index 0000000..ad6bcfc
--- /dev/null
+++ b/test/wal5.test
@@ -0,0 +1,346 @@
+# 2010 April 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of "blocking-checkpoint"
+# operations.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/wal_common.tcl
+ifcapable !wal {finish_test ; return }
+
+set testprefix wal5
+
+proc db_page_count {{file test.db}} { expr [file size $file] / 1024 }
+proc wal_page_count {{file test.db}} { wal_frame_count ${file}-wal 1024 }
+
+
+# A checkpoint may be requested either using the C API or by executing
+# an SQL PRAGMA command. To test both methods, all tests in this file are
+# run twice - once using each method to request checkpoints.
+#
+foreach {testprefix do_wal_checkpoint} {
+
+ wal5-pragma {
+ proc do_wal_checkpoint { dbhandle args } {
+ array set a $args
+ foreach key [array names a] {
+ if {[lsearch {-mode -db} $key]<0} { error "unknown switch: $key" }
+ }
+
+ set sql "PRAGMA "
+ if {[info exists a(-db)]} { append sql "$a(-db)." }
+ append sql "wal_checkpoint"
+ if {[info exists a(-mode)]} { append sql " = $a(-mode)" }
+
+ uplevel [list $dbhandle eval $sql]
+ }
+ }
+
+ wal5-capi {
+ proc do_wal_checkpoint { dbhandle args } {
+ set a(-mode) passive
+ array set a $args
+ foreach key [array names a] {
+ if {[lsearch {-mode -db} $key]<0} { error "unknown switch: $key" }
+ }
+
+ if {$a(-mode)!="restart" && $a(-mode)!="full"} { set a(-mode) passive }
+
+ set cmd [list sqlite3_wal_checkpoint_v2 $dbhandle $a(-mode)]
+ if {[info exists a(-db)]} { lappend sql $a(-db) }
+
+ uplevel $cmd
+ }
+ }
+} {
+
+ eval $do_wal_checkpoint
+
+ do_multiclient_test tn {
+
+ set ::nBusyHandler 0
+ set ::busy_handler_script ""
+ proc busyhandler {n} {
+ incr ::nBusyHandler
+ eval $::busy_handler_script
+ return 0
+ }
+
+ proc reopen_all {} {
+ code1 {db close}
+ code2 {db2 close}
+ code3 {db3 close}
+
+ code1 {sqlite3 db test.db}
+ code2 {sqlite3 db2 test.db}
+ code3 {sqlite3 db3 test.db}
+
+ sql1 { PRAGMA synchronous = NORMAL }
+ code1 { db busy busyhandler }
+ }
+
+ do_test 1.$tn.1 {
+ reopen_all
+ sql1 {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(x, y);
+ PRAGMA journal_mode = WAL;
+ INSERT INTO t1 VALUES(1, zeroblob(1200));
+ INSERT INTO t1 VALUES(2, zeroblob(1200));
+ INSERT INTO t1 VALUES(3, zeroblob(1200));
+ }
+ expr [file size test.db] / 1024
+ } {2}
+
+ # Have connection 2 grab a read-lock on the current snapshot.
+ do_test 1.$tn.2 { sql2 { BEGIN; SELECT x FROM t1 } } {1 2 3}
+
+ # Attempt a checkpoint.
+ do_test 1.$tn.3 {
+ code1 { do_wal_checkpoint db }
+ list [db_page_count] [wal_page_count]
+ } {5 9}
+
+ # Write to the db again. The log cannot wrap because of the lock still
+ # held by connection 2. The busy-handler has not yet been invoked.
+ do_test 1.$tn.4 {
+ sql1 { INSERT INTO t1 VALUES(4, zeroblob(1200)) }
+ list [db_page_count] [wal_page_count] $::nBusyHandler
+ } {5 12 0}
+
+ # Now do a blocking-checkpoint. Set the busy-handler up so that connection
+ # 2 releases its lock on the 6th invocation. The checkpointer should then
+ # proceed to checkpoint the entire log file. Next write should go to the
+ # start of the log file.
+ #
+ set ::busy_handler_script { if {$n==5} { sql2 COMMIT } }
+ do_test 1.$tn.5 {
+ code1 { do_wal_checkpoint db -mode restart }
+ list [db_page_count] [wal_page_count] $::nBusyHandler
+ } {6 12 6}
+ do_test 1.$tn.6 {
+ set ::nBusyHandler 0
+ sql1 { INSERT INTO t1 VALUES(5, zeroblob(1200)) }
+ list [db_page_count] [wal_page_count] $::nBusyHandler
+ } {6 12 0}
+
+ do_test 1.$tn.7 {
+ reopen_all
+ list [db_page_count] [wal_page_count] $::nBusyHandler
+ } {7 0 0}
+
+ do_test 1.$tn.8 { sql2 { BEGIN ; SELECT x FROM t1 } } {1 2 3 4 5}
+ do_test 1.$tn.9 {
+ sql1 { INSERT INTO t1 VALUES(6, zeroblob(1200)) }
+ list [db_page_count] [wal_page_count] $::nBusyHandler
+ } {7 5 0}
+ do_test 1.$tn.10 { sql3 { BEGIN ; SELECT x FROM t1 } } {1 2 3 4 5 6}
+
+ set ::busy_handler_script {
+ if {$n==5} { sql2 COMMIT }
+ if {$n==6} { set ::db_file_size [db_page_count] }
+ if {$n==7} { sql3 COMMIT }
+ }
+ do_test 1.$tn.11 {
+ code1 { do_wal_checkpoint db -mode restart }
+ list [db_page_count] [wal_page_count] $::nBusyHandler
+ } {10 5 8}
+ do_test 1.$tn.12 { set ::db_file_size } 10
+ }
+
+ #-------------------------------------------------------------------------
+ # This block of tests explores checkpoint operations on more than one
+ # database file.
+ #
+ proc setup_and_attach_aux {} {
+ sql1 { ATTACH 'test.db2' AS aux }
+ sql2 { ATTACH 'test.db2' AS aux }
+ sql3 { ATTACH 'test.db2' AS aux }
+ sql1 {
+ PRAGMA aux.auto_vacuum = 0;
+ PRAGMA main.auto_vacuum = 0;
+ PRAGMA main.page_size=1024; PRAGMA main.journal_mode=WAL;
+ PRAGMA aux.page_size=1024; PRAGMA aux.journal_mode=WAL;
+ }
+ }
+
+ proc file_page_counts {} {
+ list [db_page_count test.db ] \
+ [wal_page_count test.db ] \
+ [db_page_count test.db2] \
+ [wal_page_count test.db2]
+ }
+
+ # Test that executing "PRAGMA wal_checkpoint" checkpoints all attached
+ # databases, not just the main db. In capi mode, check that this is
+ # true if a NULL pointer is passed to wal_checkpoint_v2() in place of a
+ # database name.
+ do_multiclient_test tn {
+ setup_and_attach_aux
+ do_test 2.1.$tn.1 {
+ sql1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ CREATE TABLE aux.t2(a, b);
+ INSERT INTO t2 VALUES(1, 2);
+ }
+ } {}
+ do_test 2.2.$tn.2 { file_page_counts } {1 5 1 5}
+ do_test 2.1.$tn.3 { code1 { do_wal_checkpoint db } } {0 5 5}
+ do_test 2.1.$tn.4 { file_page_counts } {2 5 2 5}
+ }
+
+ do_multiclient_test tn {
+ setup_and_attach_aux
+ do_test 2.2.$tn.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ CREATE TABLE aux.t2(a, b);
+ INSERT INTO t2 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ }
+ } {}
+ do_test 2.2.$tn.2 { file_page_counts } {1 5 1 7}
+ do_test 2.2.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2}
+ do_test 2.2.$tn.4 { code1 { do_wal_checkpoint db -mode restart } } {1 5 5}
+ do_test 2.2.$tn.5 { file_page_counts } {2 5 2 7}
+ }
+
+ do_multiclient_test tn {
+ setup_and_attach_aux
+ do_test 2.3.$tn.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ CREATE TABLE aux.t2(a, b);
+ INSERT INTO t2 VALUES(1, 2);
+ }
+ } {}
+ do_test 2.3.$tn.2 { file_page_counts } {1 5 1 5}
+ do_test 2.3.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2}
+ do_test 2.3.$tn.4 { sql1 { INSERT INTO t1 VALUES(3, 4) } } {}
+ do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {}
+ do_test 2.3.$tn.6 { file_page_counts } {1 7 1 7}
+ do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 7 5}
+ do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7}
+ }
+
+ # Check that checkpoints block on the correct locks. And respond correctly
+ # if they cannot obtain those locks. There are three locks that a checkpoint
+ # may block on (in the following order):
+ #
+ # 1. The writer lock: FULL and RESTART checkpoints block until any writer
+ # process releases its lock.
+ #
+ # 2. Readers using part of the log file. FULL and RESTART checkpoints block
+ # until readers using part (but not all) of the log file have finished.
+ #
+ # 3. Readers using any of the log file. After copying data into the
+ # database file, RESTART checkpoints block until readers using any part
+ # of the log file have finished.
+ #
+ # This test case involves running a checkpoint while there exist other
+ # processes holding all three types of locks.
+ #
+ foreach {tn1 checkpoint busy_on ckpt_expected expected} {
+ 1 PASSIVE - {0 5 5} -
+ 2 TYPO - {0 5 5} -
+
+ 3 FULL - {0 7 7} 2
+ 4 FULL 1 {1 5 5} 1
+ 5 FULL 2 {1 7 5} 2
+ 6 FULL 3 {0 7 7} 2
+
+ 7 RESTART - {0 7 7} 3
+ 8 RESTART 1 {1 5 5} 1
+ 9 RESTART 2 {1 7 5} 2
+ 10 RESTART 3 {1 7 7} 3
+
+ } {
+ do_multiclient_test tn {
+ setup_and_attach_aux
+
+ proc busyhandler {x} {
+ set ::max_busyhandler $x
+ if {$::busy_on!="-" && $x==$::busy_on} { return 1 }
+ switch -- $x {
+ 1 { sql2 "COMMIT ; BEGIN ; SELECT * FROM t1" }
+ 2 { sql3 "COMMIT" }
+ 3 { sql2 "COMMIT" }
+ }
+ return 0
+ }
+ set ::max_busyhandler -
+
+ do_test 2.4.$tn1.$tn.1 {
+ sql1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ sql2 { BEGIN; INSERT INTO t1 VALUES(3, 4) }
+ sql3 { BEGIN; SELECT * FROM t1 }
+ } {1 2}
+
+ do_test 2.4.$tn1.$tn.2 {
+ code1 { db busy busyhandler }
+ code1 { do_wal_checkpoint db -mode [string tolower $checkpoint] }
+ } $ckpt_expected
+ do_test 2.4.$tn1.$tn.3 { set ::max_busyhandler } $expected
+ }
+ }
+
+
+ do_multiclient_test tn {
+
+ code1 $do_wal_checkpoint
+ code2 $do_wal_checkpoint
+ code3 $do_wal_checkpoint
+
+ do_test 3.$tn.1 {
+ sql1 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ PRAGMA synchronous = normal;
+ CREATE TABLE t1(x, y);
+ }
+
+ sql2 { PRAGMA journal_mode }
+ sql3 { PRAGMA journal_mode }
+ } {wal}
+
+ do_test 3.$tn.2 { code2 { do_wal_checkpoint db2 } } {0 2 2}
+
+ do_test 3.$tn.3 { code2 { do_wal_checkpoint db2 } } {0 2 2}
+
+ do_test 3.$tn.4 { code3 { do_wal_checkpoint db3 } } {0 2 2}
+
+ code1 {db close}
+ code2 {db2 close}
+ code3 {db3 close}
+
+ code1 {sqlite3 db test.db}
+ code2 {sqlite3 db2 test.db}
+ code3 {sqlite3 db3 test.db}
+
+ do_test 3.$tn.5 { sql3 { PRAGMA journal_mode } } {wal}
+
+ do_test 3.$tn.6 { code3 { do_wal_checkpoint db3 } } {0 0 0}
+ }
+}
+
+
+finish_test
+
diff --git a/test/wal6.test b/test/wal6.test
new file mode 100644
index 0000000..ec31bb8
--- /dev/null
+++ b/test/wal6.test
@@ -0,0 +1,81 @@
+# 2010 December 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/wal_common.tcl
+source $testdir/malloc_common.tcl
+ifcapable !wal {finish_test ; return }
+
+#-------------------------------------------------------------------------
+# Changing to WAL mode in one connection forces the change in others.
+#
+db close
+forcedelete test.db
+
+set all_journal_modes {delete persist truncate memory off}
+foreach jmode $all_journal_modes {
+
+ do_test wal6-1.0.$jmode {
+ sqlite3 db test.db
+ execsql "PRAGMA journal_mode = $jmode;"
+ } $jmode
+
+ do_test wal6-1.1.$jmode {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t1;
+ }
+ } {1 2}
+
+# Under Windows, you'll get an error trying to delete
+# a file this is already opened. Close the first connection
+# so the other tests work.
+if {$tcl_platform(platform)=="windows"} {
+ if {$jmode=="persist" || $jmode=="truncate"} {
+ db close
+ }
+}
+
+ do_test wal6-1.2.$jmode {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA journal_mode=WAL;
+ INSERT INTO t1 VALUES(3,4);
+ SELECT * FROM t1 ORDER BY a;
+ } db2
+ } {wal 1 2 3 4}
+
+if {$tcl_platform(platform)=="windows"} {
+ if {$jmode=="persist" || $jmode=="truncate"} {
+ sqlite3 db test.db
+ }
+}
+
+ do_test wal6-1.3.$jmode {
+ execsql {
+ SELECT * FROM t1 ORDER BY a;
+ }
+ } {1 2 3 4}
+
+ db close
+ db2 close
+ forcedelete test.db
+
+}
+
+finish_test
diff --git a/test/wal7.test b/test/wal7.test
new file mode 100644
index 0000000..cacfaed
--- /dev/null
+++ b/test/wal7.test
@@ -0,0 +1,118 @@
+# 2011 May 16
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the PRAGMA journal_size_limit when
+# in WAL mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !wal {finish_test ; return }
+
+# Case 1: No size limit. Journal can get large.
+#
+do_test wal7-1.0 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA page_size=1024;
+ PRAGMA journal_mode=WAL;
+ PRAGMA wal_autocheckpoint=50; -- 50 pages
+ CREATE TABLE t1(x, y UNIQUE);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(zeroblob(200000),4);
+ CREATE TABLE t2(z);
+ DELETE FROM t1;
+ INSERT INTO t2 SELECT x FROM t1;
+ }
+ expr {[file size test.db-wal]>50*1100}
+} 1
+do_test wal7-1.1 {
+ db eval {PRAGMA wal_checkpoint}
+ expr {[file size test.db-wal]>50*1100}
+} 1
+do_test wal7-1.2 {
+ db eval {INSERT INTO t2 VALUES('hi');}
+ expr {[file size test.db-wal]>50*1100}
+} 1
+
+# Case 2: Size limit at half the autocheckpoint size.
+#
+do_test wal7-2.0 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA page_size=1024;
+ PRAGMA journal_mode=WAL;
+ PRAGMA wal_autocheckpoint=50; -- 50 pages
+ PRAGMA journal_size_limit=25000;
+ CREATE TABLE t1(x, y UNIQUE);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(zeroblob(200000),4);
+ CREATE TABLE t2(z);
+ DELETE FROM t1;
+ INSERT INTO t2 VALUES(1);
+ }
+ file size test.db-wal
+} 25000
+
+
+# Case 3: Size limit of zero.
+#
+do_test wal7-3.0 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA page_size=1024;
+ PRAGMA journal_mode=WAL;
+ PRAGMA wal_autocheckpoint=50; -- 50 pages
+ PRAGMA journal_size_limit=0;
+ CREATE TABLE t1(x, y UNIQUE);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(zeroblob(200000),4);
+ CREATE TABLE t2(z);
+ DELETE FROM t1;
+ INSERT INTO t2 VALUES(1);
+ }
+ set sz [file size test.db-wal]
+ expr {$sz>0 && $sz<13700}
+} 1
+
+
+# Case 4: Size limit set before going WAL
+#
+do_test wal7-4.0 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA page_size=1024;
+ PRAGMA journal_size_limit=25000;
+ PRAGMA journal_mode=WAL;
+ PRAGMA wal_autocheckpoint=50; -- 50 pages
+ CREATE TABLE t1(x, y UNIQUE);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(zeroblob(200000),4);
+ CREATE TABLE t2(z);
+ DELETE FROM t1;
+ INSERT INTO t2 VALUES(1);
+ }
+ set sz [file size test.db-wal]
+} 25000
+
+
+
+
+
+finish_test
diff --git a/test/wal_common.tcl b/test/wal_common.tcl
new file mode 100644
index 0000000..917ad59
--- /dev/null
+++ b/test/wal_common.tcl
@@ -0,0 +1,93 @@
+# 2010 June 03
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains common code used by many different malloc tests
+# within the test suite.
+#
+
+proc wal_file_size {nFrame pgsz} {
+ expr {32 + ($pgsz+24)*$nFrame}
+}
+
+proc wal_frame_count {zFile pgsz} {
+ if {[file exists $zFile]==0} { return 0 }
+ set f [file size $zFile]
+ if {$f < 32} { return 0 }
+ expr {($f - 32) / ($pgsz+24)}
+}
+
+proc wal_cksum_intlist {ckv1 ckv2 intlist} {
+ upvar $ckv1 c1
+ upvar $ckv2 c2
+ foreach {v1 v2} $intlist {
+ set c1 [expr {($c1 + $v1 + $c2)&0xFFFFFFFF}]
+ set c2 [expr {($c2 + $v2 + $c1)&0xFFFFFFFF}]
+ }
+}
+
+
+# This proc calculates checksums in the same way as those used by SQLite
+# in WAL files. If the $endian argument is "big", then checksums are
+# calculated by interpreting data as an array of big-endian integers. If
+# it is "little", data is interpreted as an array of little-endian integers.
+#
+proc wal_cksum {endian ckv1 ckv2 blob} {
+ upvar $ckv1 c1
+ upvar $ckv2 c2
+
+ if {$endian!="big" && $endian!="little"} {
+ return -error "Bad value \"$endian\" - must be \"big\" or \"little\""
+ }
+ set scanpattern I*
+ if {$endian == "little"} { set scanpattern i* }
+
+ binary scan $blob $scanpattern values
+ wal_cksum_intlist c1 c2 $values
+}
+
+proc wal_set_walhdr {filename {intlist {}}} {
+ if {[llength $intlist]==6} {
+ set blob [binary format I6 $intlist]
+ set endian little
+ if {[lindex $intlist 0] & 0x00000001} { set endian big }
+ set c1 0
+ set c2 0
+ wal_cksum $endian c1 c2 $blob
+ append blob [binary format II $c1 $c2]
+
+ set fd [open $filename r+]
+ fconfigure $fd -translation binary
+ fconfigure $fd -encoding binary
+ seek $fd 0
+ puts -nonewline $fd $blob
+ close $fd
+ }
+
+ set fd [open $filename]
+ fconfigure $fd -translation binary
+ fconfigure $fd -encoding binary
+ set blob [read $fd 24]
+ close $fd
+
+ binary scan $blob I6 ints
+ set ints
+}
+
+proc wal_fix_walindex_cksum {hdrvar} {
+ upvar $hdrvar hdr
+ set c1 0
+ set c2 0
+ wal_cksum_intlist c1 c2 [lrange $hdr 0 9]
+ lset hdr 10 $c1
+ lset hdr 11 $c2
+}
+
+
diff --git a/test/walbak.test b/test/walbak.test
new file mode 100644
index 0000000..303a628
--- /dev/null
+++ b/test/walbak.test
@@ -0,0 +1,357 @@
+# 2010 April 22
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/wal_common.tcl
+source $testdir/malloc_common.tcl
+
+do_not_use_codec
+
+ifcapable !wal {finish_test ; return }
+
+
+# Test organization:
+#
+# walback-1.*: Simple tests.
+#
+# walback-2.*: Test backups when the source db is modified mid-backup.
+#
+# walback-3.*: Backup of WAL sources into rollback destinations, and
+# vice-versa.
+#
+
+# Make sure a simple backup from a WAL database works.
+#
+do_test walbak-1.0 {
+ execsql {
+ PRAGMA synchronous = NORMAL;
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = wal;
+ BEGIN;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES('I', 'one');
+ COMMIT;
+ }
+} {wal}
+do_test walbak-1.1 {
+ forcedelete bak.db bak.db-journal bak.db-wal
+ db backup bak.db
+ file size bak.db
+} [expr 3*1024]
+do_test walbak-1.2 {
+ sqlite3 db2 bak.db
+ execsql {
+ SELECT * FROM t1;
+ PRAGMA main.journal_mode;
+ } db2
+} {I one wal}
+do_test walbak-1.3 {
+ execsql { PRAGMA integrity_check } db2
+} {ok}
+db2 close
+
+# Try a VACUUM on a WAL database.
+#
+do_test walbak-1.4 {
+ execsql {
+ VACUUM;
+ PRAGMA main.journal_mode;
+ }
+} {wal}
+do_test walbak-1.5 {
+ list [file size test.db] [file size test.db-wal]
+} [list 1024 [wal_file_size 6 1024]]
+do_test walbak-1.6 {
+ execsql { PRAGMA wal_checkpoint }
+ list [file size test.db] [file size test.db-wal]
+} [list [expr 3*1024] [wal_file_size 6 1024]]
+do_test walbak-1.6.1 {
+ hexio_read test.db 18 2
+} {0202}
+do_test walbak-1.7 {
+ execsql {
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 SELECT * FROM t1;
+ DROP TABLE t1;
+ }
+ list [file size test.db] [file size test.db-wal]
+} [list [expr 3*1024] [wal_file_size 6 1024]]
+do_test walbak-1.8 {
+ execsql { VACUUM }
+ list [file size test.db] [file size test.db-wal]
+} [list [expr 3*1024] [wal_file_size 8 1024]]
+do_test walbak-1.9 {
+ execsql { PRAGMA wal_checkpoint }
+ list [file size test.db] [file size test.db-wal]
+} [list [expr 2*1024] [wal_file_size 8 1024]]
+
+#-------------------------------------------------------------------------
+# Backups when the source db is modified mid-backup.
+#
+proc sig {{db db}} {
+ $db eval {
+ PRAGMA integrity_check;
+ SELECT md5sum(a, b) FROM t1;
+ }
+}
+db close
+delete_file test.db
+sqlite3 db test.db
+do_test walbak-2.1 {
+ execsql { PRAGMA journal_mode = WAL }
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(500), randomblob(500));
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /* 64 */
+ COMMIT;
+ }
+} {}
+do_test walbak-2.2 {
+ db backup abc.db
+ sqlite3 db2 abc.db
+ string compare [sig db] [sig db2]
+} {0}
+
+do_test walbak-2.3 {
+ sqlite3_backup B db2 main db main
+ B step 50
+ execsql { UPDATE t1 SET b = randomblob(500) }
+ list [B step 1000] [B finish]
+} {SQLITE_DONE SQLITE_OK}
+do_test walbak-2.4 {
+ string compare [sig db] [sig db2]
+} {0}
+
+do_test walbak-2.5 {
+ db close
+ sqlite3 db test.db
+ execsql { PRAGMA cache_size = 10 }
+ sqlite3_backup B db2 main db main
+ B step 50
+ execsql {
+ BEGIN;
+ UPDATE t1 SET b = randomblob(500);
+ }
+ expr [file size test.db-wal] > 10*1024
+} {1}
+do_test walbak-2.6 {
+ B step 1000
+} {SQLITE_BUSY}
+do_test walbak-2.7 {
+ execsql COMMIT
+ list [B step 1000] [B finish]
+} {SQLITE_DONE SQLITE_OK}
+do_test walbak-2.8 {
+ string compare [sig db] [sig db2]
+} {0}
+
+do_test walbak-2.9 {
+ db close
+ sqlite3 db test.db
+ execsql { PRAGMA cache_size = 10 }
+ sqlite3_backup B db2 main db main
+ B step 50
+ execsql {
+ BEGIN;
+ UPDATE t1 SET b = randomblob(500);
+ }
+ expr [file size test.db-wal] > 10*1024
+} {1}
+do_test walbak-2.10 {
+ B step 1000
+} {SQLITE_BUSY}
+do_test walbak-2.11 {
+ execsql ROLLBACK
+set sigB [sig db]
+ list [B step 1000] [B finish]
+} {SQLITE_DONE SQLITE_OK}
+do_test walbak-2.12 {
+ string compare [sig db] [sig db2]
+} {0}
+db2 close
+db close
+
+#-------------------------------------------------------------------------
+# Run some backup operations to copy back and forth between WAL and:
+#
+# walbak-3.1.*: an in-memory database
+#
+# walbak-3.2.*: a temporary database
+#
+# walbak-3.3.*: a database in rollback mode.
+#
+# walbak-3.4.*: a database in rollback mode that (initially) uses a
+# different page-size.
+#
+# Check that this does not confuse any connected clients.
+#
+foreach {tn setup} {
+ 1 {
+ sqlite3 db test.db
+ sqlite3 db2 :memory:
+ db eval { PRAGMA page_size = 1024 ; PRAGMA journal_mode = WAL }
+ db2 eval { PRAGMA page_size = 1024 }
+ }
+
+ 2 {
+ sqlite3 db test.db
+ sqlite3 db2 ""
+ db eval { PRAGMA page_size = 1024 ; PRAGMA journal_mode = WAL }
+ db2 eval { PRAGMA page_size = 1024 }
+ }
+
+ 3 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db2
+ db eval { PRAGMA page_size = 1024 ; PRAGMA journal_mode = WAL }
+ db2 eval { PRAGMA page_size = 1024 ; PRAGMA journal_mode = PERSIST }
+ }
+
+ 4 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db2
+ db eval { PRAGMA page_size = 1024 ; PRAGMA journal_mode = WAL }
+ db2 eval {
+ PRAGMA page_size = 2048;
+ PRAGMA journal_mode = PERSIST;
+ CREATE TABLE xx(x);
+ }
+ }
+
+} {
+ foreach f [glob -nocomplain test.db*] { forcedelete $f }
+
+ eval $setup
+
+ do_test walbak-3.$tn.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4}
+
+ do_test walbak-3.$tn.2 {
+ sqlite3_backup B db2 main db main
+ B step 10000
+ B finish
+ execsql { SELECT * FROM t1 } db2
+ } {1 2 3 4}
+
+ do_test walbak-3.$tn.3 {
+ execsql {
+ INSERT INTO t1 VALUES(5, 6);
+ INSERT INTO t1 VALUES(7, 8);
+ SELECT * FROM t1;
+ } db2
+ } {1 2 3 4 5 6 7 8}
+
+ do_test walbak-3.$tn.4 {
+ sqlite3_backup B db main db2 main
+ B step 10000
+ B finish
+ execsql { SELECT * FROM t1 }
+ } {1 2 3 4 5 6 7 8}
+
+ # Check that [db] is still in WAL mode.
+ do_test walbak-3.$tn.5 {
+ execsql { PRAGMA journal_mode }
+ } {wal}
+ do_test walbak-3.$tn.6 {
+ execsql { PRAGMA wal_checkpoint }
+ hexio_read test.db 18 2
+ } {0202}
+
+ # If it was not an in-memory database, check that [db2] is still in
+ # rollback mode.
+ if {[file exists test.db2]} {
+ do_test walbak-3.$tn.7 {
+ execsql { PRAGMA journal_mode } db2
+ } {wal}
+ do_test walbak-3.$tn.8 {
+ execsql { PRAGMA wal_checkpoint }
+ hexio_read test.db 18 2
+ } {0202}
+ }
+
+ db close
+ db2 close
+}
+
+#-------------------------------------------------------------------------
+# Test that the following holds when a backup operation is run:
+#
+# Source | Destination inital | Destination final
+# ---------------------------------------------------
+# Rollback Rollback Rollback
+# Rollback WAL WAL
+# WAL Rollback WAL
+# WAL WAL WAL
+#
+foreach {tn src dest dest_final} {
+ 1 delete delete delete
+ 2 delete wal wal
+ 3 wal delete wal
+ 4 wal wal wal
+} {
+ catch { db close }
+ catch { db2 close }
+ forcedelete test.db test.db2
+
+ do_test walbak-4.$tn.1 {
+ sqlite3 db test.db
+ db eval "PRAGMA journal_mode = $src"
+ db eval {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('I', 'II');
+ INSERT INTO t1 VALUES('III', 'IV');
+ }
+
+ sqlite3 db2 test.db2
+ db2 eval "PRAGMA journal_mode = $dest"
+ db2 eval {
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES('1', '2');
+ INSERT INTO t2 VALUES('3', '4');
+ }
+ } {}
+
+ do_test walbak-4.$tn.2 { execsql { PRAGMA journal_mode } db } $src
+ do_test walbak-4.$tn.3 { execsql { PRAGMA journal_mode } db2 } $dest
+
+ do_test walbak-4.$tn.4 { db backup test.db2 } {}
+ do_test walbak-4.$tn.5 {
+ execsql { SELECT * FROM t1 } db2
+ } {I II III IV}
+ do_test walbak-4.$tn.5 { execsql { PRAGMA journal_mode } db2 } $dest_final
+
+
+ db2 close
+ do_test walbak-4.$tn.6 { file exists test.db2-wal } 0
+ sqlite3 db2 test.db2
+ do_test walbak-4.$tn.7 { execsql { PRAGMA journal_mode } db2 } $dest_final
+}
+
+
+finish_test
diff --git a/test/walbig.test b/test/walbig.test
new file mode 100644
index 0000000..092db23
--- /dev/null
+++ b/test/walbig.test
@@ -0,0 +1,78 @@
+# 2010 July 07
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script testing the ability of SQLite to handle database
+# files larger than 4GB in WAL mode.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !wal {
+ finish_test
+ return
+}
+
+# Do not use a codec for this file, as the database is manipulated using
+# external methods (the [fake_big_file] and [hexio_write] commands).
+#
+do_not_use_codec
+
+# If SQLITE_DISABLE_LFS is defined, omit this file.
+ifcapable !lfs {
+ finish_test
+ return
+}
+
+set a_string_counter 1
+proc a_string {n} {
+ incr ::a_string_counter
+ string range [string repeat "${::a_string_counter}." $n] 1 $n
+}
+db func a_string a_string
+
+do_test walbig-1.0 {
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 VALUES(a_string(300), a_string(500));
+ INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
+ INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
+ INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
+ }
+} {wal}
+
+db close
+if {[catch {fake_big_file 5000 [pwd]/test.db}]} {
+ puts "**** Unable to create a file larger than 5000 MB. *****"
+ finish_test
+ return
+}
+hexio_write test.db 28 00000000
+
+sqlite3 db test.db
+db func a_string a_string
+do_test walbig-1.1 {
+ execsql { INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1 }
+} {}
+db close
+
+sqlite3 db test.db
+do_test walbig-1.2 {
+ execsql { SELECT a FROM t1 ORDER BY a }
+} [lsort [execsql { SELECT a FROM t1 ORDER BY rowid }]]
+
+do_test walbig-1.3 {
+ execsql { SELECT b FROM t1 ORDER BY b }
+} [lsort [execsql { SELECT b FROM t1 ORDER BY rowid }]]
+
+finish_test
diff --git a/test/walcksum.test b/test/walcksum.test
new file mode 100644
index 0000000..08278dd
--- /dev/null
+++ b/test/walcksum.test
@@ -0,0 +1,393 @@
+# 2010 May 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/wal_common.tcl
+
+ifcapable !wal {finish_test ; return }
+
+# Read and return the contents of file $filename. Treat the content as
+# binary data.
+#
+proc readfile {filename} {
+ set fd [open $filename]
+ fconfigure $fd -encoding binary
+ fconfigure $fd -translation binary
+ set data [read $fd]
+ close $fd
+ return $data
+}
+
+#
+# File $filename must be a WAL file on disk. Check that the checksum of frame
+# $iFrame in the file is correct when interpreting data as $endian-endian
+# integers ($endian must be either "big" or "little"). If the checksum looks
+# correct, return 1. Otherwise 0.
+#
+proc log_checksum_verify {filename iFrame endian} {
+ set data [readfile $filename]
+
+ foreach {offset c1 c2} [log_checksum_calc $data $iFrame $endian] {}
+
+ binary scan [string range $data $offset [expr $offset+7]] II expect1 expect2
+ set expect1 [expr $expect1&0xFFFFFFFF]
+ set expect2 [expr $expect2&0xFFFFFFFF]
+
+ expr {$c1==$expect1 && $c2==$expect2}
+}
+
+# File $filename must be a WAL file on disk. Compute the checksum for frame
+# $iFrame in the file by interpreting data as $endian-endian integers
+# ($endian must be either "big" or "little"). Then write the computed
+# checksum into the file.
+#
+proc log_checksum_write {filename iFrame endian} {
+ set data [readfile $filename]
+
+ foreach {offset c1 c2} [log_checksum_calc $data $iFrame $endian] {}
+
+ set bin [binary format II $c1 $c2]
+ set fd [open $filename r+]
+ fconfigure $fd -encoding binary
+ fconfigure $fd -translation binary
+ seek $fd $offset
+ puts -nonewline $fd $bin
+ close $fd
+}
+
+# Calculate and return the checksum for a particular frame in a WAL.
+#
+# Arguments are:
+#
+# $data Blob containing the entire contents of a WAL.
+#
+# $iFrame Frame number within the $data WAL. Frames are numbered
+# starting at 1.
+#
+# $endian One of "big" or "little".
+#
+# Returns a list of three elements, as follows:
+#
+# * The byte offset of the checksum belonging to frame $iFrame in the WAL.
+# * The first integer in the calculated version of the checksum.
+# * The second integer in the calculated version of the checksum.
+#
+proc log_checksum_calc {data iFrame endian} {
+
+ binary scan [string range $data 8 11] I pgsz
+ if {$iFrame > 1} {
+ set n [wal_file_size [expr $iFrame-2] $pgsz]
+ binary scan [string range $data [expr $n+16] [expr $n+23]] II c1 c2
+ } else {
+ set c1 0
+ set c2 0
+ wal_cksum $endian c1 c2 [string range $data 0 23]
+ }
+
+ set n [wal_file_size [expr $iFrame-1] $pgsz]
+ wal_cksum $endian c1 c2 [string range $data $n [expr $n+7]]
+ wal_cksum $endian c1 c2 [string range $data [expr $n+24] [expr $n+24+$pgsz-1]]
+
+ list [expr $n+16] $c1 $c2
+}
+
+#
+# File $filename must be a WAL file on disk. Set the 'magic' field of the
+# WAL header to indicate that checksums are $endian-endian ($endian must be
+# either "big" or "little").
+#
+# Also update the wal header checksum (since the wal header contents may
+# have changed).
+#
+proc log_checksum_writemagic {filename endian} {
+ set val [expr {0x377f0682 | ($endian == "big" ? 1 : 0)}]
+ set bin [binary format I $val]
+ set fd [open $filename r+]
+ fconfigure $fd -encoding binary
+ fconfigure $fd -translation binary
+ puts -nonewline $fd $bin
+
+ seek $fd 0
+ set blob [read $fd 24]
+ set c1 0
+ set c2 0
+ wal_cksum $endian c1 c2 $blob
+ seek $fd 24
+ puts -nonewline $fd [binary format II $c1 $c2]
+
+ close $fd
+}
+
+#-------------------------------------------------------------------------
+# Test cases walcksum-1.* attempt to verify the following:
+#
+# * That both native and non-native order checksum log files can
+# be recovered.
+#
+# * That when appending to native or non-native checksum log files
+# SQLite continues to use the right kind of checksums.
+#
+# * Test point 2 when the appending process is not one that recovered
+# the log file.
+#
+# * Test that both native and non-native checksum log files can be
+# checkpointed. And that after doing so the next write to the log
+# file occurs using native byte-order checksums.
+#
+set native "big"
+if {$::tcl_platform(byteOrder) == "littleEndian"} { set native "little" }
+foreach endian {big little} {
+
+ # Create a database. Leave some data in the log file.
+ #
+ do_test walcksum-1.$endian.1 {
+ catch { db close }
+ forcedelete test.db test.db-wal test.db-journal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ PRAGMA synchronous = NORMAL;
+
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+ INSERT INTO t1 VALUES(5, 'five');
+
+ PRAGMA journal_mode = WAL;
+ INSERT INTO t1 VALUES(8, 'eight');
+ INSERT INTO t1 VALUES(13, 'thirteen');
+ INSERT INTO t1 VALUES(21, 'twentyone');
+ }
+
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+ db close
+
+ list [file size test2.db] [file size test2.db-wal]
+ } [list [expr 1024*3] [wal_file_size 6 1024]]
+
+ # Verify that the checksums are valid for all frames and that they
+ # are calculated by interpreting data in native byte-order.
+ #
+ for {set f 1} {$f <= 6} {incr f} {
+ do_test walcksum-1.$endian.2.$f {
+ log_checksum_verify test2.db-wal $f $native
+ } 1
+ }
+
+ # Replace all checksums in the current WAL file with $endian versions.
+ # Then check that it is still possible to recover and read the database.
+ #
+ log_checksum_writemagic test2.db-wal $endian
+ for {set f 1} {$f <= 6} {incr f} {
+ do_test walcksum-1.$endian.3.$f {
+ log_checksum_write test2.db-wal $f $endian
+ log_checksum_verify test2.db-wal $f $endian
+ } {1}
+ }
+ do_test walcksum-1.$endian.4.1 {
+ forcecopy test2.db test.db
+ forcecopy test2.db-wal test.db-wal
+ sqlite3 db test.db
+ execsql { SELECT a FROM t1 }
+ } {1 2 3 5 8 13 21}
+
+ # Following recovery, any frames written to the log should use the same
+ # endianness as the existing frames. Check that this is the case.
+ #
+ do_test walcksum-1.$endian.5.0 {
+ execsql {
+ PRAGMA synchronous = NORMAL;
+ INSERT INTO t1 VALUES(34, 'thirtyfour');
+ }
+ list [file size test.db] [file size test.db-wal]
+ } [list [expr 1024*3] [wal_file_size 8 1024]]
+ for {set f 1} {$f <= 8} {incr f} {
+ do_test walcksum-1.$endian.5.$f {
+ log_checksum_verify test.db-wal $f $endian
+ } {1}
+ }
+
+ # Now connect a second connection to the database. Check that this one
+ # (not the one that did recovery) also appends frames to the log using
+ # the same endianness for checksums as the existing frames.
+ #
+ do_test walcksum-1.$endian.6 {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA integrity_check;
+ SELECT a FROM t1;
+ } db2
+ } {ok 1 2 3 5 8 13 21 34}
+ do_test walcksum-1.$endian.7.0 {
+ execsql {
+ PRAGMA synchronous = NORMAL;
+ INSERT INTO t1 VALUES(55, 'fiftyfive');
+ } db2
+ list [file size test.db] [file size test.db-wal]
+ } [list [expr 1024*3] [wal_file_size 10 1024]]
+ for {set f 1} {$f <= 10} {incr f} {
+ do_test walcksum-1.$endian.7.$f {
+ log_checksum_verify test.db-wal $f $endian
+ } {1}
+ }
+
+ # Now that both the recoverer and non-recoverer have added frames to the
+ # log file, check that it can still be recovered.
+ #
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+ do_test walcksum-1.$endian.7.11 {
+ sqlite3 db3 test2.db
+ execsql {
+ PRAGMA integrity_check;
+ SELECT a FROM t1;
+ } db3
+ } {ok 1 2 3 5 8 13 21 34 55}
+ db3 close
+
+ # Run a checkpoint on the database file. Then, check that any frames written
+ # to the start of the log use native byte-order checksums.
+ #
+ do_test walcksum-1.$endian.8.1 {
+ execsql {
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES(89, 'eightynine');
+ }
+ log_checksum_verify test.db-wal 1 $native
+ } {1}
+ do_test walcksum-1.$endian.8.2 {
+ log_checksum_verify test.db-wal 2 $native
+ } {1}
+ do_test walcksum-1.$endian.8.3 {
+ log_checksum_verify test.db-wal 3 $native
+ } {0}
+
+ do_test walcksum-1.$endian.9 {
+ execsql {
+ PRAGMA integrity_check;
+ SELECT a FROM t1;
+ } db2
+ } {ok 1 2 3 5 8 13 21 34 55 89}
+
+ catch { db close }
+ catch { db2 close }
+}
+
+#-------------------------------------------------------------------------
+# Test case walcksum-2.* tests that if a statement transaction is rolled
+# back after frames are written to the WAL, and then (after writing some
+# more) the outer transaction is committed, the WAL file is still correctly
+# formatted (and can be recovered by a second process if required).
+#
+do_test walcksum-2.1 {
+ forcedelete test.db test.db-wal test.db-journal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA synchronous = NORMAL;
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(x PRIMARY KEY);
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES(randomblob(800));
+ BEGIN;
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 16 */
+ SAVEPOINT one;
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 64 */
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 128 */
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 256 */
+ ROLLBACK TO one;
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 64 */
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 128 */
+ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 256 */
+ COMMIT;
+ }
+
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+
+ sqlite3 db2 test2.db
+ execsql {
+ PRAGMA integrity_check;
+ SELECT count(*) FROM t1;
+ } db2
+} {ok 256}
+catch { db close }
+catch { db2 close }
+
+#-------------------------------------------------------------------------
+# Test case walcksum-3.* tests that the checksum calculation detects single
+# byte changes to frame or frame-header data and considers the frame
+# invalid as a result.
+#
+do_test walcksum-3.1 {
+ forcedelete test.db test.db-wal test.db-journal
+ sqlite3 db test.db
+
+ execsql {
+ PRAGMA synchronous = NORMAL;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, randomblob(300));
+ INSERT INTO t1 VALUES(2, randomblob(300));
+ PRAGMA journal_mode = WAL;
+ INSERT INTO t1 VALUES(3, randomblob(300));
+ }
+
+ file size test.db-wal
+} [wal_file_size 1 1024]
+do_test walcksum-3.2 {
+ forcecopy test.db-wal test2.db-wal
+ forcecopy test.db test2.db
+ sqlite3 db2 test2.db
+ execsql { SELECT a FROM t1 } db2
+} {1 2 3}
+db2 close
+forcecopy test.db test2.db
+
+
+foreach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} {
+ do_test walcksum-3.3.$incr {
+ set FAIL 0
+ for {set iOff 0} {$iOff < [wal_file_size 1 1024]} {incr iOff} {
+
+ forcecopy test.db-wal test2.db-wal
+ set fd [open test2.db-wal r+]
+ fconfigure $fd -encoding binary
+ fconfigure $fd -translation binary
+
+ seek $fd $iOff
+ binary scan [read $fd 1] c x
+ seek $fd $iOff
+ puts -nonewline $fd [binary format c [expr {($x+$incr)&0xFF}]]
+ close $fd
+
+ sqlite3 db2 test2.db
+ if { [execsql { SELECT a FROM t1 } db2] != "1 2" } {set FAIL 1}
+ db2 close
+ }
+ set FAIL
+ } {0}
+}
+
+finish_test
+
diff --git a/test/walcrash.test b/test/walcrash.test
new file mode 100644
index 0000000..cfce5fe
--- /dev/null
+++ b/test/walcrash.test
@@ -0,0 +1,296 @@
+# 2010 February 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library when
+# recovering a database following a simulated system failure in
+# "PRAGMA journal_mode=WAL" mode.
+#
+
+#
+# These are 'warm-body' tests of database recovery used while developing
+# the WAL code. They serve to prove that a few really simple cases work:
+#
+# walcrash-1.*: Recover a database.
+# walcrash-2.*: Recover a database where the failed transaction spanned more
+# than one page.
+# walcrash-3.*: Recover multiple databases where the failed transaction
+# was a multi-file transaction.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !wal {finish_test ; return }
+
+db close
+
+set seed 0
+set REPEATS 100
+
+# walcrash-1.*
+#
+for {set i 1} {$i < $REPEATS} {incr i} {
+ forcedelete test.db test.db-wal
+ do_test walcrash-1.$i.1 {
+ crashsql -delay 4 -file test.db-wal -seed [incr seed] {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 3);
+ INSERT INTO t1 VALUES(3, 6);
+ }
+ } {1 {child process exited abnormally}}
+ do_test walcrash-1.$i.2 {
+ sqlite3 db test.db
+ execsql { SELECT sum(a)==max(b) FROM t1 }
+ } {1}
+ integrity_check walcrash-1.$i.3
+ db close
+
+ do_test walcrash-1.$i.4 {
+ crashsql -delay 2 -file test.db-wal -seed [incr seed] {
+ INSERT INTO t1 VALUES(4, (SELECT sum(a) FROM t1) + 4);
+ INSERT INTO t1 VALUES(5, (SELECT sum(a) FROM t1) + 5);
+ }
+ } {1 {child process exited abnormally}}
+ do_test walcrash-1.$i.5 {
+ sqlite3 db test.db
+ execsql { SELECT sum(a)==max(b) FROM t1 }
+ } {1}
+ integrity_check walcrash-1.$i.6
+ do_test walcrash-1.$i.7 {
+ execsql { PRAGMA main.journal_mode }
+ } {wal}
+ db close
+}
+
+# walcrash-2.*
+#
+for {set i 1} {$i < $REPEATS} {incr i} {
+ forcedelete test.db test.db-wal
+ do_test walcrash-2.$i.1 {
+ crashsql -delay 4 -file test.db-wal -seed [incr seed] {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 9);
+ }
+ } {1 {child process exited abnormally}}
+ do_test walcrash-2.$i.2 {
+ sqlite3 db test.db
+ execsql { SELECT sum(a)==max(b) FROM t1 }
+ } {1}
+ integrity_check walcrash-2.$i.3
+ db close
+
+ do_test walcrash-2.$i.4 {
+ crashsql -delay 2 -file test.db-wal -seed [incr seed] {
+ INSERT INTO t1 VALUES(6, (SELECT sum(a) FROM t1) + 6);
+ INSERT INTO t1 VALUES(7, (SELECT sum(a) FROM t1) + 7);
+ }
+ } {1 {child process exited abnormally}}
+ do_test walcrash-2.$i.5 {
+ sqlite3 db test.db
+ execsql { SELECT sum(a)==max(b) FROM t1 }
+ } {1}
+ integrity_check walcrash-2.$i.6
+ do_test walcrash-2.$i.6 {
+ execsql { PRAGMA main.journal_mode }
+ } {wal}
+ db close
+}
+
+# walcrash-3.*
+#
+# for {set i 1} {$i < $REPEATS} {incr i} {
+# forcedelete test.db test.db-wal
+# forcedelete test2.db test2.db-wal
+#
+# do_test walcrash-3.$i.1 {
+# crashsql -delay 2 -file test2.db-wal -seed [incr seed] {
+# PRAGMA journal_mode = WAL;
+# ATTACH 'test2.db' AS aux;
+# CREATE TABLE t1(a PRIMARY KEY, b);
+# CREATE TABLE aux.t2(a PRIMARY KEY, b);
+# BEGIN;
+# INSERT INTO t1 VALUES(1, 2);
+# INSERT INTO t2 VALUES(1, 2);
+# COMMIT;
+# }
+# } {1 {child process exited abnormally}}
+#
+# do_test walcrash-3.$i.2 {
+# sqlite3_wal db test.db
+# execsql {
+# ATTACH 'test2.db' AS aux;
+# SELECT * FROM t1 EXCEPT SELECT * FROM t2;
+# }
+# } {}
+# do_test walcrash-3.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}
+# do_test walcrash-3.$i.4 { execsql { PRAGMA aux.integrity_check } } {ok}
+#
+# db close
+# }
+
+# walcrash-4.*
+#
+for {set i 1} {$i < $REPEATS} {incr i} {
+ forcedelete test.db test.db-wal
+ forcedelete test2.db test2.db-wal
+
+ do_test walcrash-4.$i.1 {
+ crashsql -delay 3 -file test.db-wal -seed [incr seed] -blocksize 4096 {
+ PRAGMA journal_mode = WAL;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ } {1 {child process exited abnormally}}
+
+ do_test walcrash-4.$i.2 {
+ sqlite3 db test.db
+ execsql {
+ SELECT * FROM t1 WHERE a = 1;
+ }
+ } {1 2}
+ do_test walcrash-4.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}
+ do_test walcrash-4.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}
+
+ db close
+}
+
+# walcrash-5.*
+#
+for {set i 1} {$i < $REPEATS} {incr i} {
+ forcedelete test.db test.db-wal
+ forcedelete test2.db test2.db-wal
+
+ do_test walcrash-5.$i.1 {
+ crashsql -delay 11 -file test.db-wal -seed [incr seed] -blocksize 4096 {
+ PRAGMA journal_mode = WAL;
+ PRAGMA page_size = 1024;
+ BEGIN;
+ CREATE TABLE t1(x PRIMARY KEY);
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4 */
+ COMMIT;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 8 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 12 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 16 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 20 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 24 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 32 */
+
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 VALUES(randomblob(900));
+ }
+ } {1 {child process exited abnormally}}
+
+ do_test walcrash-5.$i.2 {
+ sqlite3 db test.db
+ execsql { SELECT count(*)==33 OR count(*)==34 FROM t1 WHERE x != 1 }
+ } {1}
+ do_test walcrash-5.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}
+ do_test walcrash-5.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}
+
+ db close
+}
+
+# walcrash-6.*
+#
+for {set i 1} {$i < $REPEATS} {incr i} {
+ forcedelete test.db test.db-wal
+ forcedelete test2.db test2.db-wal
+
+ do_test walcrash-6.$i.1 {
+ crashsql -delay 12 -file test.db-wal -seed [incr seed] -blocksize 512 {
+ PRAGMA journal_mode = WAL;
+ PRAGMA page_size = 1024;
+ BEGIN;
+ CREATE TABLE t1(x PRIMARY KEY);
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4 */
+ COMMIT;
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 8 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 12 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 16 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 20 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 24 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 32 */
+
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 VALUES(randomblob(900));
+ }
+ } {1 {child process exited abnormally}}
+
+ do_test walcrash-6.$i.2 {
+ sqlite3 db test.db
+ execsql { SELECT count(*)==34 OR count(*)==35 FROM t1 WHERE x != 1 }
+ } {1}
+ do_test walcrash-6.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}
+ do_test walcrash-6.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}
+
+ db close
+}
+
+#-------------------------------------------------------------------------
+# This test case simulates a crash while checkpointing the database. Page
+# 1 is one of the pages overwritten by the checkpoint. This is a special
+# case because it means the content of page 1 may be damaged. SQLite will
+# have to determine:
+#
+# (a) that the database is a WAL database, and
+# (b) the database page-size
+#
+# based on the log file.
+#
+for {set i 1} {$i < $REPEATS} {incr i} {
+ forcedelete test.db test.db-wal
+
+ # Select a page-size for this test.
+ #
+ set pgsz [lindex {512 1024 2048 4096 8192 16384} [expr $i%6]]
+
+ do_test walcrash-7.$i.1 {
+ crashsql -delay 3 -file test.db -seed [incr seed] -blocksize 512 "
+ PRAGMA page_size = $pgsz;
+ PRAGMA journal_mode = wal;
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ COMMIT;
+ PRAGMA wal_checkpoint;
+ CREATE INDEX i1 ON t1(a);
+ PRAGMA wal_checkpoint;
+ "
+ } {1 {child process exited abnormally}}
+
+ do_test walcrash-7.$i.2 {
+ sqlite3 db test.db
+ execsql { SELECT b FROM t1 WHERE a = 1 }
+ } {2}
+ do_test walcrash-7.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}
+ do_test walcrash-7.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}
+
+ db close
+}
+
+finish_test
+
diff --git a/test/walcrash2.test b/test/walcrash2.test
new file mode 100644
index 0000000..7116281
--- /dev/null
+++ b/test/walcrash2.test
@@ -0,0 +1,99 @@
+# 2010 May 25
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/wal_common.tcl
+ifcapable !wal {finish_test ; return }
+
+
+#-------------------------------------------------------------------------
+# This test case demonstrates a flaw in the wal-index manipulation that
+# existed at one point: If a process crashes mid-transaction, it may have
+# already added some entries to one of the hash-tables in the wal-index.
+# If the transaction were to be explicitly rolled back at this point, the
+# hash-table entries would be removed as part of the rollback. However,
+# if the process crashes, the transaction is implicitly rolled back and
+# the rogue entries remain in the hash table.
+#
+# Normally, this causes no problem - readers can tell the difference
+# between committed and uncommitted entries in the hash table. However,
+# if it happens often enough that all slots in the hash-table become
+# non-zero, the next process that attempts to read or write the hash
+# table falls into an infinite loop.
+#
+# Even if run with an SQLite version affected by the bug, this test case
+# only goes into an infinite loop if SQLite is compiled without SQLITE_DEBUG
+# defined. If SQLITE_DEBUG is defined, the program is halted by a failing
+# assert() before entering the infinite loop.
+#
+# walcrash2-1.1: Create a database. Commit a transaction that adds 8 frames
+# to the WAL (and 8 entry to the first hash-table in the
+# wal-index).
+#
+# walcrash2-1.2: Have an external process open a transaction, add 8 entries
+# to the wal-index hash-table, then crash. Repeat this 1023
+# times (so that the wal-index contains 8192 entries - all
+# slots are non-zero).
+#
+# walcrash2-1.3: Using a new database connection, attempt to query the
+# database. This should cause the process to go into the
+# infinite loop.
+#
+do_test walcrash2-1.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = off;
+ PRAGMA journal_mode = WAL;
+ PRAGMA synchronous = NORMAL;
+ BEGIN;
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(x);
+ CREATE TABLE t3(x);
+ CREATE TABLE t4(x);
+ CREATE TABLE t5(x);
+ CREATE TABLE t6(x);
+ CREATE TABLE t7(x);
+ COMMIT;
+ }
+ file size test.db-wal
+} [wal_file_size 8 1024]
+for {set nEntry 8} {$nEntry < 8192} {incr nEntry 8} {
+ do_test walcrash2-1.2.[expr $nEntry/8] {
+ set C [launch_testfixture]
+ testfixture $C {
+ sqlite3 db test.db
+ db eval {
+ PRAGMA cache_size = 15;
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(900)); -- 1 row, 1 page
+ INSERT INTO t1 SELECT * FROM t1; -- 2 rows, 3 pages
+ INSERT INTO t1 SELECT * FROM t1; -- 4 rows, 5 pages
+ INSERT INTO t1 SELECT * FROM t1; -- 8 rows, 9 pages
+ INSERT INTO t1 SELECT * FROM t1; -- 16 rows, 17 pages
+ INSERT INTO t1 SELECT * FROM t1 LIMIT 3; -- 20 rows, 20 pages
+ }
+ }
+ close $C
+ file size test.db-wal
+ } [wal_file_size 16 1024]
+}
+do_test walcrash2-1.3 {
+ sqlite3 db2 test.db
+ execsql { SELECT count(*) FROM t1 } db2
+} {0}
+catch { db2 close }
+
+finish_test
+
diff --git a/test/walfault.test b/test/walfault.test
new file mode 100644
index 0000000..1b71d78
--- /dev/null
+++ b/test/walfault.test
@@ -0,0 +1,551 @@
+# 2010 May 03
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+source $testdir/lock_common.tcl
+
+ifcapable !wal {finish_test ; return }
+
+#-------------------------------------------------------------------------
+# This test case, walfault-1-*, simulates faults while executing a
+#
+# PRAGMA journal_mode = WAL;
+#
+# statement immediately after creating a new database.
+#
+do_test walfault-1-pre-1 {
+ faultsim_delete_and_reopen
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ db eval { PRAGMA main.journal_mode = WAL }
+} -test {
+
+ faultsim_test_result {0 wal}
+
+ # Test that the connection that encountered an error as part of
+ # "PRAGMA journal_mode = WAL" and a new connection use the same
+ # journal mode when accessing the database.
+ #
+ # If "PRAGMA journal_mode" is executed immediately, connection [db] (the
+ # one that hit the error in journal_mode="WAL") might return "wal" even
+ # if it failed to switch the database to WAL mode. This is not considered
+ # a problem. When it tries to read the database, connection [db] correctly
+ # recognizes that it is a rollback database and switches back to a
+ # rollback compatible journal mode.
+ #
+ if {[permutation] != "inmemory_journal"} {
+ set jm [db one {SELECT * FROM sqlite_master ; PRAGMA main.journal_mode}]
+ sqlite3 db2 test.db
+ set jm2 [db2 one {SELECT * FROM sqlite_master ; PRAGMA main.journal_mode}]
+ db2 close
+
+ if { $jm!=$jm2 } { error "Journal modes do not match: $jm $jm2" }
+ if { $testrc==0 && $jm!="wal" } { error "Journal mode is not WAL" }
+ }
+}
+
+#--------------------------------------------------------------------------
+# Test case walfault-2-* tests fault injection during recovery of a
+# short WAL file (a dozen frames or thereabouts).
+#
+do_test walfault-2-pre-1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA journal_mode = WAL;
+ BEGIN;
+ CREATE TABLE x(y, z, UNIQUE(y, z));
+ INSERT INTO x VALUES(randomblob(100), randomblob(100));
+ COMMIT;
+ PRAGMA wal_checkpoint;
+
+ INSERT INTO x SELECT randomblob(100), randomblob(100) FROM x;
+ INSERT INTO x SELECT randomblob(100), randomblob(100) FROM x;
+ INSERT INTO x SELECT randomblob(100), randomblob(100) FROM x;
+ }
+ execsql {
+ SELECT count(*) FROM x
+ }
+} {8}
+do_test walfault-2-pre-2 {
+ faultsim_save_and_close
+ faultsim_restore_and_reopen
+ execsql { SELECT count(*) FROM x }
+} {8}
+do_faultsim_test walfault-2 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { SELECT count(*) FROM x }
+} -test {
+ faultsim_test_result {0 8}
+ faultsim_integrity_check
+}
+
+#--------------------------------------------------------------------------
+# Test fault injection while writing and checkpointing a small WAL file.
+#
+do_test walfault-3-pre-1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE abc(a PRIMARY KEY);
+ INSERT INTO abc VALUES(randomblob(1500));
+ }
+ db close
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-3 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ db eval {
+ DELETE FROM abc;
+ PRAGMA wal_checkpoint;
+ }
+ set {} {}
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+
+#--------------------------------------------------------------------------
+#
+if {[permutation] != "inmemory_journal"} {
+ faultsim_delete_and_reopen
+ faultsim_save_and_close
+ do_faultsim_test walfault-4 -prep {
+ faultsim_restore_and_reopen
+ } -body {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES('a', 'b');
+ PRAGMA wal_checkpoint;
+ SELECT * FROM t1;
+ }
+ } -test {
+ faultsim_test_result {0 {wal 0 7 7 a b}}
+ faultsim_integrity_check
+ }
+}
+
+#--------------------------------------------------------------------------
+#
+do_test walfault-5-pre-1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA page_size = 512;
+ PRAGMA journal_mode = WAL;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-5 -faults shmerr* -prep {
+ faultsim_restore_and_reopen
+ execsql { PRAGMA wal_autocheckpoint = 0 }
+ shmfault filter xShmMap
+} -body {
+ execsql {
+ CREATE TABLE t1(x);
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(400)); /* 1 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 64 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 128 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 256 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 512 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 1024 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 2048 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 4096 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 8192 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 16384 */
+ COMMIT;
+ SELECT count(*) FROM t1;
+ }
+} -test {
+ faultsim_test_result {0 16384}
+ faultsim_integrity_check
+}
+
+#--------------------------------------------------------------------------
+#
+do_test walfault-6-pre-1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA page_size = 512;
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 0;
+ CREATE TABLE t1(x);
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(400)); /* 1 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 64 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 128 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 256 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 512 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 1024 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 2048 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 4096 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 8192 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 16384 */
+ COMMIT;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-6 -faults shmerr* -prep {
+ faultsim_restore_and_reopen
+ shmfault filter xShmMap
+} -body {
+ execsql { SELECT count(*) FROM t1 }
+} -test {
+ faultsim_test_result {0 16384}
+ faultsim_integrity_check
+ set n [db one {SELECT count(*) FROM t1}]
+ if {$n != 16384 && $n != 0} { error "Incorrect number of rows: $n" }
+}
+
+#--------------------------------------------------------------------------
+#
+do_test walfault-7-pre-1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA page_size = 512;
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 0;
+ CREATE TABLE t1(x);
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(400)); /* 1 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; /* 4 */
+ COMMIT;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-7 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { SELECT count(*) FROM t1 }
+} -test {
+ faultsim_test_result {0 4}
+ set n [db one {SELECT count(*) FROM t1}]
+ if {$n != 4 && $n != 0} { error "Incorrect number of rows: $n" }
+}
+
+#--------------------------------------------------------------------------
+#
+do_test walfault-8-pre-1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE abc(a PRIMARY KEY);
+ INSERT INTO abc VALUES(randomblob(900));
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-8 -prep {
+ faultsim_restore_and_reopen
+ execsql { PRAGMA cache_size = 10 }
+} -body {
+ execsql {
+ BEGIN;
+ INSERT INTO abc SELECT randomblob(900) FROM abc; /* 1 */
+ --INSERT INTO abc SELECT randomblob(900) FROM abc; /* 2 */
+ --INSERT INTO abc SELECT randomblob(900) FROM abc; /* 4 */
+ --INSERT INTO abc SELECT randomblob(900) FROM abc; /* 8 */
+ ROLLBACK;
+ SELECT count(*) FROM abc;
+ }
+} -test {
+ faultsim_test_result {0 1}
+
+ faultsim_integrity_check
+ catch { db eval ROLLBACK }
+ faultsim_integrity_check
+
+ set n [db one {SELECT count(*) FROM abc}]
+ if {$n != 1} { error "Incorrect number of rows: $n" }
+}
+
+#--------------------------------------------------------------------------
+#
+do_test walfault-9-pre-1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE abc(a PRIMARY KEY);
+ INSERT INTO abc VALUES(randomblob(900));
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-9 -prep {
+ #if {$iFail<73} { set iFail 73 }
+ #if {$iFail>73} { exit }
+
+ faultsim_restore_and_reopen
+ execsql { PRAGMA cache_size = 10 }
+} -body {
+ execsql {
+ BEGIN;
+ INSERT INTO abc SELECT randomblob(900) FROM abc; /* 1 */
+ SAVEPOINT spoint;
+ INSERT INTO abc SELECT randomblob(900) FROM abc; /* 2 */
+ INSERT INTO abc SELECT randomblob(900) FROM abc; /* 4 */
+ INSERT INTO abc SELECT randomblob(900) FROM abc; /* 8 */
+ ROLLBACK TO spoint;
+ COMMIT;
+ SELECT count(*) FROM abc;
+ }
+} -test {
+ faultsim_test_result {0 2}
+ faultsim_integrity_check
+
+ catch { db eval { ROLLBACK TO spoint } }
+ catch { db eval { COMMIT } }
+ set n [db one {SELECT count(*) FROM abc}]
+ if {$n != 1 && $n != 2} { error "Incorrect number of rows: $n" }
+}
+
+do_test walfault-10-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 0;
+ CREATE TABLE z(zz INTEGER PRIMARY KEY, zzz BLOB);
+ CREATE INDEX zzzz ON z(zzz);
+ INSERT INTO z VALUES(NULL, randomblob(800));
+ INSERT INTO z VALUES(NULL, randomblob(800));
+ INSERT INTO z SELECT NULL, randomblob(800) FROM z;
+ INSERT INTO z SELECT NULL, randomblob(800) FROM z;
+ INSERT INTO z SELECT NULL, randomblob(800) FROM z;
+ INSERT INTO z SELECT NULL, randomblob(800) FROM z;
+ INSERT INTO z SELECT NULL, randomblob(800) FROM z;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-10 -prep {
+ faultsim_restore_and_reopen
+ execsql {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ UPDATE z SET zzz = randomblob(799);
+ }
+
+ set ::stmt [sqlite3_prepare db "SELECT zzz FROM z WHERE zz IN (1, 2, 3)" -1]
+ sqlite3_step $::stmt
+} -body {
+ execsql { INSERT INTO z VALUES(NULL, NULL) }
+} -test {
+ sqlite3_finalize $::stmt
+ faultsim_integrity_check
+
+ faultsim_test_result {0 {}}
+ catch { db eval { ROLLBACK } }
+ faultsim_integrity_check
+
+ set n [db eval {SELECT count(*), sum(length(zzz)) FROM z}]
+ if {$n != "64 51200"} { error "Incorrect data: $n" }
+}
+
+#--------------------------------------------------------------------------
+# Test fault injection while checkpointing a large WAL file, if the
+# checkpoint is the first operation run after opening the database.
+# This means that some of the required wal-index pages are mapped as part of
+# the checkpoint process, which means there are a few more opportunities
+# for IO errors.
+#
+# To speed this up, IO errors are only simulated within xShmMap() calls.
+#
+do_test walfault-11-pre-1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 0;
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY);
+ INSERT INTO abc VALUES(randomblob(1500));
+ INSERT INTO abc VALUES(randomblob(1500));
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 4
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 8
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 16
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 32
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 64
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 128
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 256
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 512
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 1024
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 2048
+ INSERT INTO abc SELECT randomblob(1500) FROM abc; -- 4096
+ COMMIT;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-11 -faults shmerr* -prep {
+ catch { db2 close }
+ faultsim_restore_and_reopen
+ shmfault filter xShmMap
+} -body {
+ db eval { SELECT count(*) FROM abc }
+ sqlite3 db2 test.db -vfs shmfault
+ db2 eval { PRAGMA wal_checkpoint }
+ set {} {}
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+# Test the handling of the various IO/OOM/SHM errors that may occur during
+# a log recovery operation undertaken as part of a call to
+# sqlite3_wal_checkpoint().
+#
+do_test walfault-12-pre-1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 0;
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY);
+ INSERT INTO abc VALUES(randomblob(1500));
+ INSERT INTO abc VALUES(randomblob(1500));
+ COMMIT;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-12 -prep {
+ if {[info commands shmfault] == ""} {
+ testvfs shmfault -default true
+ }
+ faultsim_restore_and_reopen
+ db eval { SELECT * FROM sqlite_master }
+ shmfault shm test.db [string repeat "\000" 40]
+} -body {
+ set rc [sqlite3_wal_checkpoint db]
+ if {$rc != "SQLITE_OK"} { error [sqlite3_errmsg db] }
+} -test {
+ db close
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+# Test simple recovery, reading and writing a database file using a
+# heap-memory wal-index.
+#
+do_test walfault-13-pre-1 {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 0;
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY);
+ INSERT INTO abc VALUES(randomblob(1500));
+ INSERT INTO abc VALUES(randomblob(1500));
+ COMMIT;
+ }
+ faultsim_save_and_close
+ delete_file sv_test.db-shm
+} {}
+
+do_faultsim_test walfault-13.1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ db eval { PRAGMA locking_mode = exclusive }
+ db eval { SELECT count(*) FROM abc }
+} -test {
+ faultsim_test_result {0 2}
+ if {[file exists test.db-shm]} { error "Not using heap-memory mode" }
+ faultsim_integrity_check
+}
+
+do_faultsim_test walfault-13.2 -prep {
+ faultsim_restore_and_reopen
+ db eval { PRAGMA locking_mode = exclusive }
+} -body {
+ db eval { PRAGMA journal_mode = delete }
+} -test {
+ faultsim_test_result {0 delete}
+ if {[file exists test.db-shm]} { error "Not using heap-memory mode" }
+ faultsim_integrity_check
+}
+
+do_test walfault-13-pre-2 {
+ faultsim_delete_and_reopen
+ execsql {
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY);
+ INSERT INTO abc VALUES(randomblob(1500));
+ INSERT INTO abc VALUES(randomblob(1500));
+ COMMIT;
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test walfault-13.3 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ db eval {
+ PRAGMA locking_mode = exclusive;
+ PRAGMA journal_mode = WAL;
+ INSERT INTO abc VALUES(randomblob(1500));
+ }
+} -test {
+ faultsim_test_result {0 {exclusive wal}}
+ if {[file exists test.db-shm]} { error "Not using heap-memory mode" }
+ faultsim_integrity_check
+ set nRow [db eval {SELECT count(*) FROM abc}]
+ if {!(($nRow==2 && $testrc) || $nRow==3)} { error "Bad db content" }
+}
+
+#-------------------------------------------------------------------------
+# Test fault-handling when wrapping around to the start of a WAL file.
+#
+do_test walfault-14-pre {
+ faultsim_delete_and_reopen
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY);
+ INSERT INTO abc VALUES(randomblob(1500));
+ INSERT INTO abc VALUES(randomblob(1500));
+ COMMIT;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test walfault-14 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ db eval {
+ PRAGMA wal_checkpoint = full;
+ INSERT INTO abc VALUES(randomblob(1500));
+ }
+} -test {
+ faultsim_test_result {0 {0 10 10}}
+ faultsim_integrity_check
+ set nRow [db eval {SELECT count(*) FROM abc}]
+ if {!(($nRow==2 && $testrc) || $nRow==3)} { error "Bad db content" }
+}
+
+finish_test
diff --git a/test/walhook.test b/test/walhook.test
new file mode 100644
index 0000000..631ec83
--- /dev/null
+++ b/test/walhook.test
@@ -0,0 +1,109 @@
+# 2010 April 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+# More specifically, this file contains regression tests for the
+# sqlite3_wal_hook() mechanism, including the sqlite3_wal_autocheckpoint()
+# and "PRAGMA wal_autocheckpoint" convenience interfaces.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/wal_common.tcl
+
+ifcapable !wal {finish_test ; return }
+
+set ::wal_hook [list]
+proc wal_hook {zDb nEntry} {
+ lappend ::wal_hook $zDb $nEntry
+ return 0
+}
+db wal_hook wal_hook
+
+do_test walhook-1.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = wal;
+ PRAGMA synchronous = normal;
+ CREATE TABLE t1(i PRIMARY KEY, j);
+ }
+ set ::wal_hook
+} {main 3}
+
+do_test walhook-1.2 {
+ set ::wal_hook [list]
+ execsql { INSERT INTO t1 VALUES(1, 'one') }
+ set ::wal_hook
+} {main 5}
+do_test walhook-1.3 {
+ proc wal_hook {args} { db eval {PRAGMA wal_checkpoint}; return 0 }
+ execsql { INSERT INTO t1 VALUES(2, 'two') }
+ file size test.db
+} [expr 3*1024]
+do_test walhook-1.4 {
+ proc wal_hook {zDb nEntry} {
+ execsql { PRAGMA wal_checkpoint }
+ return 0
+ }
+ execsql { CREATE TABLE t2(a, b) }
+ file size test.db
+} [expr 4*1024]
+
+do_test walhook-1.5 {
+ sqlite3 db2 test.db
+ proc wal_hook {zDb nEntry} {
+ execsql { PRAGMA wal_checkpoint } db2
+ return 0
+ }
+ execsql { CREATE TABLE t3(a PRIMARY KEY, b) }
+ file size test.db
+} [expr 6*1024]
+
+db2 close
+db close
+sqlite3 db test.db
+do_test walhook-2.1 {
+ execsql { PRAGMA synchronous = NORMAL }
+ execsql { PRAGMA wal_autocheckpoint }
+} {1000}
+do_test walhook-2.2 {
+ execsql { PRAGMA wal_autocheckpoint = 10}
+} {10}
+do_test walhook-2.3 {
+ execsql { PRAGMA wal_autocheckpoint }
+} {10}
+
+#
+# The database connection is configured with "PRAGMA wal_autocheckpoint = 10".
+# Check that transactions are written to the log file until it contains at
+# least 10 frames, then the database is checkpointed. Subsequent transactions
+# are written into the start of the log file.
+#
+foreach {tn sql dbpages logpages} {
+ 4 "CREATE TABLE t4(x PRIMARY KEY, y)" 6 3
+ 5 "INSERT INTO t4 VALUES(1, 'one')" 6 5
+ 6 "INSERT INTO t4 VALUES(2, 'two')" 6 7
+ 7 "INSERT INTO t4 VALUES(3, 'three')" 6 9
+ 8 "INSERT INTO t4 VALUES(4, 'four')" 8 11
+ 9 "INSERT INTO t4 VALUES(5, 'five')" 8 11
+} {
+ do_test walhook-2.$tn {
+ execsql $sql
+ list [file size test.db] [file size test.db-wal]
+ } [list [expr $dbpages*1024] [wal_file_size $logpages 1024]]
+}
+
+catch { db2 close }
+catch { db close }
+finish_test
diff --git a/test/walmode.test b/test/walmode.test
new file mode 100644
index 0000000..4e14d54
--- /dev/null
+++ b/test/walmode.test
@@ -0,0 +1,387 @@
+# 2010 April 19
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+# If the library was compiled without WAL support, check that the
+# "PRAGMA journal_mode=WAL" treats "WAL" as an unrecognized mode.
+#
+ifcapable !wal {
+
+ do_test walmode-0.1 {
+ execsql { PRAGMA journal_mode = wal }
+ } {delete}
+ do_test walmode-0.2 {
+ execsql { PRAGMA main.journal_mode = wal }
+ } {delete}
+ do_test walmode-0.3 {
+ execsql { PRAGMA main.journal_mode }
+ } {delete}
+
+ finish_test
+ return
+}
+
+do_test walmode-1.1 {
+ set sqlite_sync_count 0
+ execsql { PRAGMA page_size = 1024 }
+ execsql { PRAGMA journal_mode = wal }
+} {wal}
+do_test walmode-1.2 {
+ file size test.db
+} {1024}
+
+set expected_sync_count 3
+if {$::tcl_platform(platform)!="windows"} {
+ ifcapable dirsync {
+ incr expected_sync_count
+ }
+}
+do_test walmode-1.3 {
+ set sqlite_sync_count
+} $expected_sync_count
+
+do_test walmode-1.4 {
+ file exists test.db-wal
+} {0}
+do_test walmode-1.5 {
+ execsql { CREATE TABLE t1(a, b) }
+ file size test.db
+} {1024}
+do_test walmode-1.6 {
+ file exists test.db-wal
+} {1}
+do_test walmode-1.7 {
+ db close
+ file exists test.db-wal
+} {0}
+
+# There is now a database file with the read and write versions set to 2
+# in the file system. This file should default to WAL mode.
+#
+do_test walmode-2.1 {
+ sqlite3 db test.db
+ file exists test.db-wal
+} {0}
+do_test walmode-2.2 {
+ execsql { SELECT * FROM sqlite_master }
+ file exists test.db-wal
+} {1}
+do_test walmode-2.3 {
+ db close
+ file exists test.db-wal
+} {0}
+
+# If the first statement executed is "PRAGMA journal_mode = wal", and
+# the file is already configured for WAL (read and write versions set
+# to 2), then there should be no need to write the database. The
+# statement should cause the client to connect to the log file.
+#
+set sqlite_sync_count 0
+do_test walmode-3.1 {
+ sqlite3 db test.db
+ execsql { PRAGMA journal_mode = wal }
+} {wal}
+do_test walmode-3.2 {
+ list $sqlite_sync_count [file exists test.db-wal] [file size test.db-wal]
+} {0 1 0}
+
+# Test that changing back to journal_mode=persist works.
+#
+do_test walmode-4.1 {
+ execsql { INSERT INTO t1 VALUES(1, 2) }
+ execsql { PRAGMA journal_mode = persist }
+} {persist}
+do_test walmode-4.2 {
+ list [file exists test.db-journal] [file exists test.db-wal]
+} {1 0}
+do_test walmode-4.3 {
+ execsql { SELECT * FROM t1 }
+} {1 2}
+do_test walmode-4.4 {
+ db close
+ sqlite3 db test.db
+ execsql { SELECT * FROM t1 }
+} {1 2}
+do_test walmode-4.5 {
+ list [file exists test.db-journal] [file exists test.db-wal]
+} {1 0}
+
+# Test that nothing goes wrong if a connection is prevented from changing
+# from WAL to rollback mode because a second connection has the database
+# open. Or from rollback to WAL.
+#
+do_test walmode-4.6 {
+ sqlite3 db2 test.db
+ execsql { PRAGMA main.journal_mode } db2
+} {delete}
+do_test walmode-4.7 {
+ execsql { PRAGMA main.journal_mode = wal } db
+} {wal}
+do_test walmode-4.8 {
+ execsql { SELECT * FROM t1 } db2
+} {1 2}
+do_test walmode-4.9 {
+ catchsql { PRAGMA journal_mode = delete } db
+} {1 {database is locked}}
+do_test walmode-4.10 {
+ execsql { PRAGMA main.journal_mode } db
+} {wal}
+
+do_test walmode-4.11 {
+ db2 close
+ execsql { PRAGMA journal_mode = delete } db
+} {delete}
+do_test walmode-4.12 {
+ execsql { PRAGMA main.journal_mode } db
+} {delete}
+do_test walmode-4.13 {
+ list [file exists test.db-journal] [file exists test.db-wal]
+} {0 0}
+do_test walmode-4.14 {
+ sqlite3 db2 test.db
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ } db2
+} {1 2}
+
+do_test walmode-4.16 { execsql { PRAGMA main.journal_mode } db } {delete}
+do_test walmode-4.17 { execsql { PRAGMA main.journal_mode } db2 } {delete}
+
+do_test walmode-4.17 {
+ catchsql { PRAGMA main.journal_mode = wal } db
+} {1 {database is locked}}
+do_test walmode-4.18 {
+ execsql { PRAGMA main.journal_mode } db
+} {delete}
+catch { db close }
+catch { db2 close }
+
+# Test that it is not possible to change a temporary or in-memory database
+# to WAL mode. WAL mode is for persistent file-backed databases only.
+#
+# walmode-5.1.*: Try to set journal_mode=WAL on [sqlite3 db :memory:] database.
+# walmode-5.2.*: Try to set journal_mode=WAL on [sqlite3 db ""] database.
+# walmode-5.3.*: Try to set temp.journal_mode=WAL.
+#
+do_test walmode-5.1.1 {
+ sqlite3 db :memory:
+ execsql { PRAGMA main.journal_mode }
+} {memory}
+do_test walmode-5.1.2 {
+ execsql { PRAGMA main.journal_mode = wal }
+} {memory}
+do_test walmode-5.1.3 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ COMMIT;
+ SELECT * FROM t1;
+ PRAGMA main.journal_mode;
+ }
+} {1 2 memory}
+do_test walmode-5.1.4 {
+ execsql { PRAGMA main.journal_mode = wal }
+} {memory}
+do_test walmode-5.1.5 {
+ execsql {
+ INSERT INTO t1 VALUES(3, 4);
+ SELECT * FROM t1;
+ PRAGMA main.journal_mode;
+ }
+} {1 2 3 4 memory}
+
+if {$TEMP_STORE>=2} {
+ set tempJrnlMode memory
+} else {
+ set tempJrnlMode delete
+}
+do_test walmode-5.2.1 {
+ sqlite3 db ""
+ execsql { PRAGMA main.journal_mode }
+} $tempJrnlMode
+do_test walmode-5.2.2 {
+ execsql { PRAGMA main.journal_mode = wal }
+} $tempJrnlMode
+do_test walmode-5.2.3 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ COMMIT;
+ SELECT * FROM t1;
+ PRAGMA main.journal_mode;
+ }
+} [list 1 2 $tempJrnlMode]
+do_test walmode-5.2.4 {
+ execsql { PRAGMA main.journal_mode = wal }
+} $tempJrnlMode
+do_test walmode-5.2.5 {
+ execsql {
+ INSERT INTO t1 VALUES(3, 4);
+ SELECT * FROM t1;
+ PRAGMA main.journal_mode;
+ }
+} [list 1 2 3 4 $tempJrnlMode]
+
+do_test walmode-5.3.1 {
+ sqlite3 db test.db
+ execsql { PRAGMA temp.journal_mode }
+} $tempJrnlMode
+do_test walmode-5.3.2 {
+ execsql { PRAGMA temp.journal_mode = wal }
+} $tempJrnlMode
+do_test walmode-5.3.3 {
+ execsql {
+ BEGIN;
+ CREATE TEMP TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ COMMIT;
+ SELECT * FROM t1;
+ PRAGMA temp.journal_mode;
+ }
+} [list 1 2 $tempJrnlMode]
+do_test walmode-5.3.4 {
+ execsql { PRAGMA temp.journal_mode = wal }
+} $tempJrnlMode
+do_test walmode-5.3.5 {
+ execsql {
+ INSERT INTO t1 VALUES(3, 4);
+ SELECT * FROM t1;
+ PRAGMA temp.journal_mode;
+ }
+} [list 1 2 3 4 $tempJrnlMode]
+
+
+#-------------------------------------------------------------------------
+# Test changing to WAL mode from journal_mode=off or journal_mode=memory
+#
+foreach {tn mode} {
+ 1 off
+ 2 memory
+ 3 persist
+ 4 delete
+ 5 truncate
+} {
+ do_test walmode-6.$tn {
+ faultsim_delete_and_reopen
+ execsql "
+ PRAGMA journal_mode = $mode;
+ PRAGMA journal_mode = wal;
+ "
+ } [list $mode wal]
+}
+db close
+
+#-------------------------------------------------------------------------
+# Test the effect of a "PRAGMA journal_mode" command being the first
+# thing executed by a new connection. This means that the schema is not
+# loaded when sqlite3_prepare_v2() is called to compile the statement.
+#
+do_test walmode-7.0 {
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ }
+} {wal}
+foreach {tn sql result} {
+ 1 "PRAGMA journal_mode" wal
+ 2 "PRAGMA main.journal_mode" wal
+ 3 "PRAGMA journal_mode = delete" delete
+ 4 "PRAGMA journal_mode" delete
+ 5 "PRAGMA main.journal_mode" delete
+ 6 "PRAGMA journal_mode = wal" wal
+ 7 "PRAGMA journal_mode" wal
+ 8 "PRAGMA main.journal_mode" wal
+
+ 9 "PRAGMA journal_mode" wal
+ 10 "PRAGMA main.journal_mode" wal
+ 11 "PRAGMA main.journal_mode = delete" delete
+ 12 "PRAGMA journal_mode" delete
+ 13 "PRAGMA main.journal_mode" delete
+ 14 "PRAGMA main.journal_mode = wal" wal
+ 15 "PRAGMA journal_mode" wal
+ 16 "PRAGMA main.journal_mode" wal
+} {
+ do_test walmode-7.$tn {
+ db close
+ sqlite3 db test.db
+ execsql $sql
+ } $result
+}
+db close
+
+#-------------------------------------------------------------------------
+# Test the effect of a "PRAGMA journal_mode" command on an attached
+# database.
+#
+faultsim_delete_and_reopen
+do_execsql_test walmode-8.1 {
+ CREATE TABLE t1(a, b);
+ PRAGMA journal_mode = WAL;
+ ATTACH 'test.db2' AS two;
+ CREATE TABLE two.t2(a, b);
+} {wal}
+do_execsql_test walmode-8.2 { PRAGMA main.journal_mode } {wal}
+do_execsql_test walmode-8.3 { PRAGMA two.journal_mode } {delete}
+do_execsql_test walmode-8.4 { PRAGMA two.journal_mode = DELETE } {delete}
+
+db close
+sqlite3 db test.db
+do_execsql_test walmode-8.5 { ATTACH 'test.db2' AS two } {}
+do_execsql_test walmode-8.6 { PRAGMA main.journal_mode } {wal}
+do_execsql_test walmode-8.7 { PRAGMA two.journal_mode } {delete}
+do_execsql_test walmode-8.8 { INSERT INTO two.t2 DEFAULT VALUES } {}
+do_execsql_test walmode-8.9 { PRAGMA two.journal_mode } {delete}
+do_execsql_test walmode-8.10 { INSERT INTO t1 DEFAULT VALUES } {}
+do_execsql_test walmode-8.11 { PRAGMA main.journal_mode } {wal}
+do_execsql_test walmode-8.12 { PRAGMA journal_mode } {wal}
+
+# Change to WAL mode on test2.db and make sure (in the tests that follow)
+# that this mode change persists.
+do_test walmode-8.x1 {
+ execsql {
+ PRAGMA two.journal_mode=WAL;
+ PRAGMA two.journal_mode;
+ }
+} {wal wal}
+
+db close
+sqlite3 db test.db
+do_execsql_test walmode-8.13 { PRAGMA journal_mode = WAL } {wal}
+do_execsql_test walmode-8.14 { ATTACH 'test.db2' AS two } {}
+do_execsql_test walmode-8.15 { PRAGMA main.journal_mode } {wal}
+do_execsql_test walmode-8.16 { PRAGMA two.journal_mode } {wal}
+do_execsql_test walmode-8.17 { INSERT INTO two.t2 DEFAULT VALUES } {}
+do_execsql_test walmode-8.18 { PRAGMA two.journal_mode } {wal}
+
+sqlite3 db2 test.db2
+do_test walmode-8.19 { execsql { PRAGMA main.journal_mode } db2 } {wal}
+db2 close
+
+do_execsql_test walmode-8.20 { PRAGMA journal_mode = DELETE } {delete}
+do_execsql_test walmode-8.21 { PRAGMA main.journal_mode } {delete}
+do_execsql_test walmode-8.22 { PRAGMA two.journal_mode } {delete}
+do_execsql_test walmode-8.21 { PRAGMA journal_mode = WAL } {wal}
+do_execsql_test walmode-8.21 { PRAGMA main.journal_mode } {wal}
+do_execsql_test walmode-8.22 { PRAGMA two.journal_mode } {wal}
+
+finish_test
diff --git a/test/walnoshm.test b/test/walnoshm.test
new file mode 100644
index 0000000..d408217
--- /dev/null
+++ b/test/walnoshm.test
@@ -0,0 +1,184 @@
+# 2010 November 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that WAL databases may be accessed without
+# using the xShm primitives if the connection is in exclusive-mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix walnoshm
+ifcapable !wal {finish_test ; return }
+
+db close
+testvfs tvfsshm
+testvfs tvfs -default 1 -iversion 1
+sqlite3 db test.db
+
+#--------------------------------------------------------------------------
+# Test that when using a version 1 VFS, a database can only be converted
+# to WAL mode after setting locking_mode=EXCLUSIVE. Also, test that if a
+# WAL database is opened using heap-memory for the WAL index, the connection
+# cannot change back to locking_mode=NORMAL while the database is still in
+# WAL mode.
+#
+do_execsql_test 1.1 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+}
+
+do_execsql_test 1.2 {
+ PRAGMA journal_mode = WAL;
+ SELECT * FROM t1;
+} {delete 1 2}
+do_test 1.3 { file exists test.db-wal } {0}
+
+do_execsql_test 1.4 {
+ PRAGMA locking_mode = exclusive;
+ PRAGMA journal_mode = WAL;
+ SELECT * FROM t1;
+} {exclusive wal 1 2}
+do_test 1.5 { file exists test.db-wal } {1}
+
+do_execsql_test 1.6 { INSERT INTO t1 VALUES(3, 4) }
+
+do_execsql_test 1.7 {
+ PRAGMA locking_mode = normal;
+} {exclusive}
+do_execsql_test 1.8 {
+ PRAGMA journal_mode = delete;
+ PRAGMA main.locking_mode;
+} {delete exclusive}
+do_execsql_test 1.9 {
+ PRAGMA locking_mode = normal;
+} {normal}
+do_execsql_test 1.10 {
+ SELECT * FROM t1;
+} {1 2 3 4}
+do_test 1.11 { file exists test.db-wal } {0}
+
+#-------------------------------------------------------------------------
+#
+# 2.1.*: Test that a connection using a version 1 VFS can open a WAL database
+# and convert it to rollback mode if it is set to use
+# locking_mode=exclusive.
+#
+# 2.2.*: Test that if the exclusive lock cannot be obtained while attempting
+# the above, the operation fails and the WAL file is not opened.
+#
+do_execsql_test 2.1.1 {
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES('a', 'b');
+ INSERT INTO t2 VALUES('c', 'd');
+}
+do_execsql_test 2.1.2 {
+ PRAGMA locking_mode = exclusive;
+ PRAGMA journal_mode = WAL;
+ INSERT INTO t2 VALUES('e', 'f');
+ INSERT INTO t2 VALUES('g', 'h');
+} {exclusive wal}
+
+do_test 2.1.3 {
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+ sqlite3 db2 test2.db
+ catchsql { SELECT * FROM t2 } db2
+} {1 {unable to open database file}}
+do_test 2.1.4 {
+ catchsql { PRAGMA journal_mode = delete } db2
+} {1 {unable to open database file}}
+do_test 2.1.5 {
+ execsql {
+ PRAGMA locking_mode = exclusive;
+ PRAGMA journal_mode = delete;
+ SELECT * FROM t2;
+ } db2
+} {exclusive delete a b c d e f g h}
+
+do_test 2.2.1 {
+ forcecopy test.db test2.db
+ forcecopy test.db-wal test2.db-wal
+ sqlite3 db3 test2.db -vfs tvfsshm
+ sqlite3 db2 test2.db
+ execsql { SELECT * FROM t2 } db3
+} {a b c d e f g h}
+
+do_test 2.2.2 {
+ execsql { PRAGMA locking_mode = exclusive } db2
+ catchsql { PRAGMA journal_mode = delete } db2
+} {1 {database is locked}}
+
+do_test 2.2.3 {
+ # This is to test that [db2] is not holding a PENDING lock (which can
+ # happen when an attempt to obtain an EXCLUSIVE lock fails).
+ sqlite3 db4 test2.db -vfs tvfsshm
+ execsql { SELECT * FROM t2 } db4
+} {a b c d e f g h}
+
+do_test 2.2.4 {
+ catchsql { SELECT * FROM t2 } db2
+} {1 {database is locked}}
+
+do_test 2.2.5 {
+ db4 close
+ sqlite3 db4 test2.db -vfs tvfsshm
+ execsql { SELECT * FROM t2 } db4
+} {a b c d e f g h}
+
+do_test 2.2.6 {
+ db3 close
+ db4 close
+ execsql { SELECT * FROM t2 } db2
+} {a b c d e f g h}
+
+db2 close
+db close
+
+#-------------------------------------------------------------------------
+#
+# 3.1: Test that if locking_mode=EXCLUSIVE is set after the wal file is
+# opened, it is possible to drop back to locking_mode=NORMAL.
+#
+# 3.2: Test that if locking_mode=EXCLUSIVE is set before the wal file is
+# opened, it is not.
+#
+do_test 3.1 {
+ sqlite3 db test.db -vfs tvfsshm
+ execsql {
+ SELECT * FROM t1;
+ PRAGMA locking_mode = EXCLUSIVE;
+ INSERT INTO t1 VALUES(5, 6);
+ PRAGMA locking_mode = NORMAL;
+ INSERT INTO t1 VALUES(7, 8);
+ }
+ sqlite3 db2 test.db -vfs tvfsshm
+ execsql { SELECT * FROM t1 } db2
+} {1 2 3 4 5 6 7 8}
+db close
+db2 close
+do_test 3.2 {
+ sqlite3 db test.db -vfs tvfsshm
+ execsql {
+ PRAGMA locking_mode = EXCLUSIVE;
+ INSERT INTO t1 VALUES(9, 10);
+ PRAGMA locking_mode = NORMAL;
+ INSERT INTO t1 VALUES(11, 12);
+ }
+ sqlite3 db2 test.db -vfs tvfsshm
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database is locked}}
+db close
+db2 close
+
+tvfs delete
+tvfsshm delete
+
+finish_test
diff --git a/test/walpersist.test b/test/walpersist.test
new file mode 100644
index 0000000..175dcbf
--- /dev/null
+++ b/test/walpersist.test
@@ -0,0 +1,73 @@
+# 2011 July 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests for using WAL with persistent WAL file mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+set ::testprefix walpersist
+
+ifcapable !wal {
+ finish_test
+ return
+}
+
+do_test walpersist-1.0 {
+ db eval {
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(randomblob(5000));
+ }
+ file exists test.db-wal
+} {1}
+do_test walpersist-1.1 {
+ file exists test.db-shm
+} {1}
+do_test walpersist-1.2 {
+ db close
+ list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
+} {1 0 0}
+do_test walpersist-1.3 {
+ sqlite3 db test.db
+ db eval {SELECT length(a) FROM t1}
+} {5000}
+do_test walpersist-1.4 {
+ list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
+} {1 1 1}
+do_test walpersist-1.5 {
+ file_control_persist_wal db -1
+} {0 0}
+do_test walpersist-1.6 {
+ file_control_persist_wal db 1
+} {0 1}
+do_test walpersist-1.7 {
+ file_control_persist_wal db -1
+} {0 1}
+do_test walpersist-1.8 {
+ file_control_persist_wal db 0
+} {0 0}
+do_test walpersist-1.9 {
+ file_control_persist_wal db -1
+} {0 0}
+do_test walpersist-1.10 {
+ file_control_persist_wal db 1
+} {0 1}
+do_test walpersist-1.11 {
+ db close
+ list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
+} {1 1 1}
+
+
+
+
+finish_test
diff --git a/test/walro.test b/test/walro.test
new file mode 100644
index 0000000..3ae7d53
--- /dev/null
+++ b/test/walro.test
@@ -0,0 +1,168 @@
+# 2011 May 09
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests for using WAL databases in read-only mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+set ::testprefix walro
+
+# These tests are only going to work on unix.
+#
+if {$::tcl_platform(platform) != "unix"} {
+ finish_test
+ return
+}
+
+# And only if the build is WAL-capable.
+#
+ifcapable !wal {
+ finish_test
+ return
+}
+
+do_multiclient_test tn {
+ # Do not run tests with the connections in the same process.
+ #
+ if {$tn==2} continue
+
+ # Close all connections and delete the database.
+ #
+ code1 { db close }
+ code2 { db2 close }
+ code3 { db3 close }
+ forcedelete test.db
+ forcedelete walro
+
+ foreach c {code1 code2 code3} {
+ $c {
+ sqlite3_shutdown
+ sqlite3_config_uri 1
+ }
+ }
+
+ file mkdir walro
+
+ do_test 1.1.1 {
+ code2 { sqlite3 db2 test.db }
+ sql2 {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES('a', 'b');
+ }
+ file exists test.db-shm
+ } {1}
+
+ do_test 1.1.2 {
+ file attributes test.db-shm -permissions r--r--r--
+ code1 { sqlite3 db file:test.db?readonly_shm=1 }
+ } {}
+
+ do_test 1.1.3 { sql1 "SELECT * FROM t1" } {a b}
+ do_test 1.1.4 { sql2 "INSERT INTO t1 VALUES('c', 'd')" } {}
+ do_test 1.1.5 { sql1 "SELECT * FROM t1" } {a b c d}
+
+ # Check that the read-only connection cannot write or checkpoint the db.
+ #
+ do_test 1.1.6 {
+ csql1 "INSERT INTO t1 VALUES('e', 'f')"
+ } {1 {attempt to write a readonly database}}
+ do_test 1.1.7 {
+ csql1 "PRAGMA wal_checkpoint"
+ } {1 {attempt to write a readonly database}}
+
+ do_test 1.1.9 { sql2 "INSERT INTO t1 VALUES('e', 'f')" } {}
+ do_test 1.1.10 { sql1 "SELECT * FROM t1" } {a b c d e f}
+
+ do_test 1.1.11 {
+ sql2 {
+ INSERT INTO t1 VALUES('g', 'h');
+ PRAGMA wal_checkpoint;
+ }
+ set {} {}
+ } {}
+ do_test 1.1.12 { sql1 "SELECT * FROM t1" } {a b c d e f g h}
+ do_test 1.1.13 { sql2 "INSERT INTO t1 VALUES('i', 'j')" } {}
+
+ do_test 1.2.1 {
+ code2 { db2 close }
+ code1 { db close }
+ list [file exists test.db-wal] [file exists test.db-shm]
+ } {1 1}
+ do_test 1.2.2 {
+ code1 { sqlite3 db file:test.db?readonly_shm=1 }
+ sql1 { SELECT * FROM t1 }
+ } {a b c d e f g h i j}
+
+ do_test 1.2.3 {
+ code1 { db close }
+ file attributes test.db-shm -permissions rw-r--r--
+ hexio_write test.db-shm 0 01020304
+ file attributes test.db-shm -permissions r--r--r--
+ code1 { sqlite3 db file:test.db?readonly_shm=1 }
+ csql1 { SELECT * FROM t1 }
+ } {1 {attempt to write a readonly database}}
+ do_test 1.2.4 {
+ code1 { sqlite3_extended_errcode db }
+ } {SQLITE_READONLY_RECOVERY}
+
+ do_test 1.2.5 {
+ file attributes test.db-shm -permissions rw-r--r--
+ code2 { sqlite3 db2 test.db }
+ sql2 "SELECT * FROM t1"
+ } {a b c d e f g h i j}
+ file attributes test.db-shm -permissions r--r--r--
+ do_test 1.2.6 { sql1 "SELECT * FROM t1" } {a b c d e f g h i j}
+
+ do_test 1.2.7 {
+ sql2 {
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES('k', 'l');
+ }
+ set {} {}
+ } {}
+ do_test 1.2.8 { sql1 "SELECT * FROM t1" } {a b c d e f g h i j k l}
+
+ # Now check that if the readonly_shm option is not supplied, or if it
+ # is set to zero, it is not possible to connect to the database without
+ # read-write access to the shm.
+ do_test 1.3.1 {
+ code1 { db close }
+ code1 { sqlite3 db test.db }
+ csql1 { SELECT * FROM t1 }
+ } {1 {unable to open database file}}
+
+ # Also test that if the -shm file can be opened for read/write access,
+ # it is not if readonly_shm=1 is present in the URI.
+ do_test 1.3.2.1 {
+ code1 { db close }
+ code2 { db2 close }
+ file exists test.db-shm
+ } {0}
+ do_test 1.3.2.2 {
+ code1 { sqlite3 db file:test.db?readonly_shm=1 }
+ csql1 { SELECT * FROM sqlite_master }
+ } {1 {unable to open database file}}
+ do_test 1.3.2.3 {
+ code1 { db close }
+ close [open test.db-shm w]
+ file attributes test.db-shm -permissions r--r--r--
+ code1 { sqlite3 db file:test.db?readonly_shm=1 }
+ csql1 { SELECT * FROM t1 }
+ } {1 {attempt to write a readonly database}}
+ do_test 1.3.2.4 {
+ code1 { sqlite3_extended_errcode db }
+ } {SQLITE_READONLY_RECOVERY}
+}
+
+finish_test
diff --git a/test/walshared.test b/test/walshared.test
new file mode 100644
index 0000000..73a3fb8
--- /dev/null
+++ b/test/walshared.test
@@ -0,0 +1,63 @@
+# 2010 August 2
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode with shared-cache turned on.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !wal {finish_test ; return }
+
+db close
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+do_test walshared-1.0 {
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(200));
+ }
+} {wal}
+
+do_test walshared-1.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(200));
+ INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
+ }
+} {}
+
+do_test walshared-1.2 {
+ catchsql { PRAGMA wal_checkpoint }
+} {1 {database table is locked}}
+
+do_test walshared-1.3 {
+ catchsql { PRAGMA wal_checkpoint } db2
+} {1 {database table is locked}}
+
+do_test walshared-1.4 {
+ execsql { COMMIT }
+ execsql { PRAGMA integrity_check } db2
+} {ok}
+
+
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
+
diff --git a/test/walslow.test b/test/walslow.test
new file mode 100644
index 0000000..83f2922
--- /dev/null
+++ b/test/walslow.test
@@ -0,0 +1,73 @@
+# 2010 March 17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode. The tests in this file use
+# brute force methods, so may take a while to run.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !wal {finish_test ; return }
+
+proc reopen_db {} {
+ catch { db close }
+ forcedelete test.db test.db-wal
+ sqlite3 db test.db
+ execsql { PRAGMA journal_mode = wal }
+}
+
+db close
+save_prng_state
+for {set seed 1} {$seed<10} {incr seed} {
+ expr srand($seed)
+ restore_prng_state
+ reopen_db
+ do_test walslow-1.seed=$seed.0 {
+ execsql { CREATE TABLE t1(a, b) }
+ execsql { CREATE INDEX i1 ON t1(a) }
+ execsql { CREATE INDEX i2 ON t1(b) }
+ } {}
+
+ for {set iTest 1} {$iTest < 100} {incr iTest} {
+
+ do_test walslow-1.seed=$seed.$iTest.1 {
+ set w [expr int(rand()*2000)]
+ set x [expr int(rand()*2000)]
+ execsql { INSERT INTO t1 VALUES(randomblob($w), randomblob($x)) }
+ execsql { PRAGMA integrity_check }
+ } {ok}
+
+ do_test walslow-1.seed=$seed.$iTest.2 {
+ execsql "PRAGMA wal_checkpoint;"
+ execsql { PRAGMA integrity_check }
+ } {ok}
+
+ do_test walslow-1.seed=$seed.$iTest.3 {
+ forcedelete testX.db testX.db-wal
+ copy_file test.db testX.db
+ copy_file test.db-wal testX.db-wal
+
+ sqlite3 db2 testX.db
+ execsql { PRAGMA journal_mode = WAL } db2
+ execsql { PRAGMA integrity_check } db2
+ } {ok}
+
+ do_test walslow-1.seed=$seed.$iTest.4 {
+ execsql { SELECT count(*) FROM t1 WHERE a!=b } db2
+ } [execsql { SELECT count(*) FROM t1 WHERE a!=b }]
+ db2 close
+ }
+}
+
+
+finish_test
diff --git a/test/walthread.test b/test/walthread.test
new file mode 100644
index 0000000..cbd6371
--- /dev/null
+++ b/test/walthread.test
@@ -0,0 +1,527 @@
+# 2010 April 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode with multiple threads.
+#
+
+set testdir [file dirname $argv0]
+
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+if {[run_thread_tests]==0} { finish_test ; return }
+ifcapable !wal { finish_test ; return }
+
+set sqlite_walsummary_mmap_incr 64
+
+# How long, in seconds, to run each test for. If a test is set to run for
+# 0 seconds, it is omitted entirely.
+#
+unset -nocomplain seconds
+set seconds(walthread-1) 20
+set seconds(walthread-2) 20
+set seconds(walthread-3) 20
+set seconds(walthread-4) 20
+set seconds(walthread-5) 1
+
+# The parameter is the name of a variable in the callers context. The
+# variable may or may not exist when this command is invoked.
+#
+# If the variable does exist, its value is returned. Otherwise, this
+# command uses [vwait] to wait until it is set, then returns the value.
+# In other words, this is a version of the [set VARNAME] command that
+# blocks until a variable exists.
+#
+proc wait_for_var {varname} {
+ if {0==[uplevel [list info exists $varname]]} {
+ uplevel [list vwait $varname]
+ }
+ uplevel [list set $varname]
+}
+
+# The argument is the name of a list variable in the callers context. The
+# first element of the list is removed and returned. For example:
+#
+# set L {a b c}
+# set x [lshift L]
+# assert { $x == "a" && $L == "b c" }
+#
+proc lshift {lvar} {
+ upvar $lvar L
+ set ret [lindex $L 0]
+ set L [lrange $L 1 end]
+ return $ret
+}
+
+
+#-------------------------------------------------------------------------
+# do_thread_test TESTNAME OPTIONS...
+#
+# where OPTIONS are:
+#
+# -seconds SECONDS How many seconds to run the test for
+# -init SCRIPT Script to run before test.
+# -thread NAME COUNT SCRIPT Scripts to run in threads (or processes).
+# -processes BOOLEAN True to use processes instead of threads.
+# -check SCRIPT Script to run after test.
+#
+proc do_thread_test {args} {
+
+ set A $args
+
+ set P(testname) [lshift A]
+ set P(seconds) 5
+ set P(init) ""
+ set P(threads) [list]
+ set P(processes) 0
+ set P(check) {
+ set ic [db eval "PRAGMA integrity_check"]
+ if {$ic != "ok"} { error $ic }
+ }
+
+ unset -nocomplain ::done
+
+ while {[llength $A]>0} {
+ set a [lshift A]
+ switch -glob -- $a {
+ -seconds {
+ set P(seconds) [lshift A]
+ }
+
+ -init {
+ set P(init) [lshift A]
+ }
+
+ -processes {
+ set P(processes) [lshift A]
+ }
+
+ -check {
+ set P(check) [lshift A]
+ }
+
+ -thread {
+ set name [lshift A]
+ set count [lshift A]
+ set prg [lshift A]
+ lappend P(threads) [list $name $count $prg]
+ }
+
+ default {
+ error "Unknown option: $a"
+ }
+ }
+ }
+
+ if {$P(seconds) == 0} {
+ puts "Skipping $P(testname)"
+ return
+ }
+
+ puts "Running $P(testname) for $P(seconds) seconds..."
+
+ catch { db close }
+ forcedelete test.db test.db-journal test.db-wal
+
+ sqlite3 db test.db
+ eval $P(init)
+ catch { db close }
+
+ foreach T $P(threads) {
+ set name [lindex $T 0]
+ set count [lindex $T 1]
+ set prg [lindex $T 2]
+
+ for {set i 1} {$i <= $count} {incr i} {
+ set vars "
+ set E(pid) $i
+ set E(nthread) $count
+ set E(seconds) $P(seconds)
+ "
+ set program [string map [list %TEST% $prg %VARS% $vars] {
+
+ %VARS%
+
+ proc usleep {ms} {
+ set ::usleep 0
+ after $ms {set ::usleep 1}
+ vwait ::usleep
+ }
+
+ proc integrity_check {{db db}} {
+ set ic [$db eval {PRAGMA integrity_check}]
+ if {$ic != "ok"} {error $ic}
+ }
+
+ proc busyhandler {n} { usleep 10 ; return 0 }
+
+ sqlite3 db test.db
+ db busy busyhandler
+ db eval { SELECT randomblob($E(pid)*5) }
+
+ set ::finished 0
+ after [expr $E(seconds) * 1000] {set ::finished 1}
+ proc tt_continue {} { update ; expr ($::finished==0) }
+
+ set rc [catch { %TEST% } msg]
+
+ catch { db close }
+ list $rc $msg
+ }]
+
+ if {$P(processes)==0} {
+ sqlthread spawn ::done($name,$i) $program
+ } else {
+ testfixture_nb ::done($name,$i) $program
+ }
+ }
+ }
+
+ set report " Results:"
+ foreach T $P(threads) {
+ set name [lindex $T 0]
+ set count [lindex $T 1]
+ set prg [lindex $T 2]
+
+ set reslist [list]
+ for {set i 1} {$i <= $count} {incr i} {
+ set res [wait_for_var ::done($name,$i)]
+ lappend reslist [lindex $res 1]
+ do_test $P(testname).$name.$i [list lindex $res 0] 0
+ }
+
+ append report " $name $reslist"
+ }
+ puts $report
+
+ sqlite3 db test.db
+ set res ""
+ if {[catch $P(check) msg]} { set res $msg }
+ do_test $P(testname).check [list set {} $res] ""
+}
+
+# A wrapper around [do_thread_test] which runs the specified test twice.
+# Once using processes, once using threads. This command takes the same
+# arguments as [do_thread_test], except specifying the -processes switch
+# is illegal.
+#
+proc do_thread_test2 {args} {
+ set name [lindex $args 0]
+ if {[lsearch $args -processes]>=0} { error "bad option: -processes"}
+ uplevel [lreplace $args 0 0 do_thread_test "$name-threads" -processes 0]
+ uplevel [lreplace $args 0 0 do_thread_test "$name-processes" -processes 1]
+}
+
+#--------------------------------------------------------------------------
+# Start 10 threads. Each thread performs both read and write
+# transactions. Each read transaction consists of:
+#
+# 1) Reading the md5sum of all but the last table row,
+# 2) Running integrity check.
+# 3) Reading the value stored in the last table row,
+# 4) Check that the values read in steps 1 and 3 are the same, and that
+# the md5sum of all but the last table row has not changed.
+#
+# Each write transaction consists of:
+#
+# 1) Modifying the contents of t1 (inserting, updating, deleting rows).
+# 2) Appending a new row to the table containing the md5sum() of all
+# rows in the table.
+#
+# Each of the N threads runs N read transactions followed by a single write
+# transaction in a loop as fast as possible.
+#
+# There is also a single checkpointer thread. It runs the following loop:
+#
+# 1) Execute "PRAGMA wal_checkpoint"
+# 2) Sleep for 500 ms.
+#
+do_thread_test2 walthread-1 -seconds $seconds(walthread-1) -init {
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(x PRIMARY KEY);
+ PRAGMA lock_status;
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 SELECT md5sum(x) FROM t1;
+ }
+} -thread main 10 {
+
+ proc read_transaction {} {
+ set results [db eval {
+ BEGIN;
+ PRAGMA integrity_check;
+ SELECT md5sum(x) FROM t1 WHERE rowid != (SELECT max(rowid) FROM t1);
+ SELECT x FROM t1 WHERE rowid = (SELECT max(rowid) FROM t1);
+ SELECT md5sum(x) FROM t1 WHERE rowid != (SELECT max(rowid) FROM t1);
+ COMMIT;
+ }]
+
+ if {[llength $results]!=4
+ || [lindex $results 0] != "ok"
+ || [lindex $results 1] != [lindex $results 2]
+ || [lindex $results 2] != [lindex $results 3]
+ } {
+ error "Failed read transaction: $results"
+ }
+ }
+
+ proc write_transaction {} {
+ db eval {
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 SELECT md5sum(x) FROM t1;
+ COMMIT;
+ }
+ }
+
+ # Turn off auto-checkpoint. Otherwise, an auto-checkpoint run by a
+ # writer may cause the dedicated checkpoint thread to return an
+ # SQLITE_BUSY error.
+ #
+ db eval { PRAGMA wal_autocheckpoint = 0 }
+
+ set nRun 0
+ while {[tt_continue]} {
+ read_transaction
+ write_transaction
+ incr nRun
+ }
+ set nRun
+
+} -thread ckpt 1 {
+ set nRun 0
+ while {[tt_continue]} {
+ db eval "PRAGMA wal_checkpoint"
+ usleep 500
+ incr nRun
+ }
+ set nRun
+}
+
+#--------------------------------------------------------------------------
+# This test has clients run the following procedure as fast as possible
+# in a loop:
+#
+# 1. Open a database handle.
+# 2. Execute a read-only transaction on the db.
+# 3. Do "PRAGMA journal_mode = XXX", where XXX is one of WAL or DELETE.
+# Ignore any SQLITE_BUSY error.
+# 4. Execute a write transaction to insert a row into the db.
+# 5. Run "PRAGMA integrity_check"
+#
+# At present, there are 4 clients in total. 2 do "journal_mode = WAL", and
+# two do "journal_mode = DELETE".
+#
+# Each client returns a string of the form "W w, R r", where W is the
+# number of write-transactions performed using a WAL journal, and D is
+# the number of write-transactions performed using a rollback journal.
+# For example, "192 w, 185 r".
+#
+do_thread_test2 walthread-2 -seconds $seconds(walthread-2) -init {
+ execsql { CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE) }
+} -thread RB 2 {
+
+ db close
+ set nRun 0
+ set nDel 0
+ while {[tt_continue]} {
+ sqlite3 db test.db
+ db busy busyhandler
+ db eval { SELECT * FROM sqlite_master }
+ catch { db eval { PRAGMA journal_mode = DELETE } }
+ db eval {
+ BEGIN;
+ INSERT INTO t1 VALUES(NULL, randomblob(100+$E(pid)));
+ }
+ incr nRun 1
+ incr nDel [file exists test.db-journal]
+ if {[file exists test.db-journal] + [file exists test.db-wal] != 1} {
+ error "File-system looks bad..."
+ }
+ db eval COMMIT
+
+ integrity_check
+ db close
+ }
+ list $nRun $nDel
+ set {} "[expr $nRun-$nDel] w, $nDel r"
+
+} -thread WAL 2 {
+ db close
+ set nRun 0
+ set nDel 0
+ while {[tt_continue]} {
+ sqlite3 db test.db
+ db busy busyhandler
+ db eval { SELECT * FROM sqlite_master }
+ catch { db eval { PRAGMA journal_mode = WAL } }
+ db eval {
+ BEGIN;
+ INSERT INTO t1 VALUES(NULL, randomblob(110+$E(pid)));
+ }
+ incr nRun 1
+ incr nDel [file exists test.db-journal]
+ if {[file exists test.db-journal] + [file exists test.db-wal] != 1} {
+ error "File-system looks bad..."
+ }
+ db eval COMMIT
+
+ integrity_check
+ db close
+ }
+ set {} "[expr $nRun-$nDel] w, $nDel r"
+}
+
+do_thread_test walthread-3 -seconds $seconds(walthread-3) -init {
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(cnt PRIMARY KEY, sum1, sum2);
+ CREATE INDEX i1 ON t1(sum1);
+ CREATE INDEX i2 ON t1(sum2);
+ INSERT INTO t1 VALUES(0, 0, 0);
+ }
+} -thread t 10 {
+
+ set nextwrite $E(pid)
+
+ proc wal_hook {zDb nEntry} {
+ if {$nEntry>10} {
+ set rc [catch { db eval {PRAGMA wal_checkpoint} } msg]
+ if {$rc && $msg != "database is locked"} { error $msg }
+ }
+ return 0
+ }
+ db wal_hook wal_hook
+
+ while {[tt_continue]} {
+ set max 0
+ while { $max != ($nextwrite-1) && [tt_continue] } {
+ set max [db eval { SELECT max(cnt) FROM t1 }]
+ }
+
+ if {[tt_continue]} {
+ set sum1 [db eval { SELECT sum(cnt) FROM t1 }]
+ set sum2 [db eval { SELECT sum(sum1) FROM t1 }]
+ db eval { INSERT INTO t1 VALUES($nextwrite, $sum1, $sum2) }
+ incr nextwrite $E(nthread)
+ integrity_check
+ }
+ }
+
+ set {} ok
+} -check {
+ puts " Final db contains [db eval {SELECT count(*) FROM t1}] rows"
+ puts " Final integrity-check says: [db eval {PRAGMA integrity_check}]"
+
+ # Check that the contents of the database are Ok.
+ set c 0
+ set s1 0
+ set s2 0
+ db eval { SELECT cnt, sum1, sum2 FROM t1 ORDER BY cnt } {
+ if {$c != $cnt || $s1 != $sum1 || $s2 != $sum2} {
+ error "database content is invalid"
+ }
+ incr s2 $s1
+ incr s1 $c
+ incr c 1
+ }
+}
+
+do_thread_test2 walthread-4 -seconds $seconds(walthread-4) -init {
+ execsql {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
+ }
+} -thread r 1 {
+ # This connection only ever reads the database. Therefore the
+ # busy-handler is not required. Disable it to check that this is true.
+ #
+ # UPDATE: That is no longer entirely true - as we don't use a blocking
+ # lock to enter RECOVER state. Which means there is a small chance a
+ # reader can see an SQLITE_BUSY.
+ #
+ while {[tt_continue]} {
+ integrity_check
+ }
+ set {} ok
+} -thread w 1 {
+
+ proc wal_hook {zDb nEntry} {
+ if {$nEntry>15} {db eval {PRAGMA wal_checkpoint}}
+ return 0
+ }
+ db wal_hook wal_hook
+ set row 1
+ while {[tt_continue]} {
+ db eval { REPLACE INTO t1 VALUES($row, randomblob(300)) }
+ incr row
+ if {$row == 10} { set row 1 }
+ }
+
+ set {} ok
+}
+
+
+# This test case attempts to provoke a deadlock condition that existed in
+# the unix VFS at one point. The problem occurred only while recovering a
+# very large wal file (one that requires a wal-index larger than the
+# initial default allocation of 64KB).
+#
+do_thread_test walthread-5 -seconds $seconds(walthread-5) -init {
+
+ proc log_file_size {nFrame pgsz} {
+ expr {12 + ($pgsz+16)*$nFrame}
+ }
+
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(x);
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(900));
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 2 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 8 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 16 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 32 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 128 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 256 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 512 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 1024 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 2048 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4096 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 8192 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 16384 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 32768 */
+ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 65536 */
+ COMMIT;
+ }
+
+ forcecopy test.db-wal bak.db-wal
+ forcecopy test.db bak.db
+ db close
+
+ forcecopy bak.db-wal test.db-wal
+ forcecopy bak.db test.db
+
+ if {[file size test.db-wal] < [log_file_size [expr 64*1024] 1024]} {
+ error "Somehow failed to create a large log file"
+ }
+ puts "Database with large log file recovered. Now running clients..."
+} -thread T 5 {
+ db eval { SELECT count(*) FROM t1 }
+}
+unset -nocomplain seconds
+
+finish_test
diff --git a/test/where.test b/test/where.test
new file mode 100644
index 0000000..9145bcc
--- /dev/null
+++ b/test/where.test
@@ -0,0 +1,1260 @@
+# 2001 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the use of indices in WHERE clases.
+#
+# $Id: where.test,v 1.50 2008/11/03 09:06:06 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+do_test where-1.0 {
+ execsql {
+ CREATE TABLE t1(w int, x int, y int);
+ CREATE TABLE t2(p int, q int, r int, s int);
+ }
+ for {set i 1} {$i<=100} {incr i} {
+ set w $i
+ set x [expr {int(log($i)/log(2))}]
+ set y [expr {$i*$i + 2*$i + 1}]
+ execsql "INSERT INTO t1 VALUES($w,$x,$y)"
+ }
+
+ ifcapable subquery {
+ execsql {
+ INSERT INTO t2 SELECT 101-w, x, (SELECT max(y) FROM t1)+1-y, y FROM t1;
+ }
+ } else {
+ set maxy [execsql {select max(y) from t1}]
+ execsql "
+ INSERT INTO t2 SELECT 101-w, x, $maxy+1-y, y FROM t1;
+ "
+ }
+
+ execsql {
+ CREATE INDEX i1w ON t1(w);
+ CREATE INDEX i1xy ON t1(x,y);
+ CREATE INDEX i2p ON t2(p);
+ CREATE INDEX i2r ON t2(r);
+ CREATE INDEX i2qs ON t2(q, s);
+ }
+} {}
+
+# Do an SQL statement. Append the search count to the end of the result.
+#
+proc count sql {
+ set ::sqlite_search_count 0
+ return [concat [execsql $sql] $::sqlite_search_count]
+}
+
+# Verify that queries use an index. We are using the special variable
+# "sqlite_search_count" which tallys the number of executions of MoveTo
+# and Next operators in the VDBE. By verifing that the search count is
+# small we can be assured that indices are being used properly.
+#
+do_test where-1.1.1 {
+ count {SELECT x, y, w FROM t1 WHERE w=10}
+} {3 121 10 3}
+do_test where-1.1.2 {
+ set sqlite_query_plan
+} {t1 i1w}
+do_test where-1.1.3 {
+ db status step
+} {0}
+do_test where-1.1.4 {
+ db eval {SELECT x, y, w FROM t1 WHERE +w=10}
+} {3 121 10}
+do_test where-1.1.5 {
+ db status step
+} {99}
+do_test where-1.1.6 {
+ set sqlite_query_plan
+} {t1 {}}
+do_test where-1.1.7 {
+ count {SELECT x, y, w AS abc FROM t1 WHERE abc=10}
+} {3 121 10 3}
+do_test where-1.1.8 {
+ set sqlite_query_plan
+} {t1 i1w}
+do_test where-1.1.9 {
+ db status step
+} {0}
+do_test where-1.2.1 {
+ count {SELECT x, y, w FROM t1 WHERE w=11}
+} {3 144 11 3}
+do_test where-1.2.2 {
+ count {SELECT x, y, w AS abc FROM t1 WHERE abc=11}
+} {3 144 11 3}
+do_test where-1.3.1 {
+ count {SELECT x, y, w AS abc FROM t1 WHERE 11=w}
+} {3 144 11 3}
+do_test where-1.3.2 {
+ count {SELECT x, y, w AS abc FROM t1 WHERE 11=abc}
+} {3 144 11 3}
+do_test where-1.4.1 {
+ count {SELECT w, x, y FROM t1 WHERE 11=w AND x>2}
+} {11 3 144 3}
+do_test where-1.4.2 {
+ set sqlite_query_plan
+} {t1 i1w}
+do_test where-1.4.3 {
+ count {SELECT w AS a, x AS b, y FROM t1 WHERE 11=a AND b>2}
+} {11 3 144 3}
+do_test where-1.4.4 {
+ set sqlite_query_plan
+} {t1 i1w}
+do_test where-1.5 {
+ count {SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2}
+} {3 144 3}
+do_test where-1.5.2 {
+ set sqlite_query_plan
+} {t1 i1w}
+do_test where-1.6 {
+ count {SELECT x, y FROM t1 WHERE y<200 AND x>2 AND w=11}
+} {3 144 3}
+do_test where-1.7 {
+ count {SELECT x, y FROM t1 WHERE w=11 AND y<200 AND x>2}
+} {3 144 3}
+do_test where-1.8 {
+ count {SELECT x, y FROM t1 WHERE w>10 AND y=144 AND x=3}
+} {3 144 3}
+do_test where-1.8.2 {
+ set sqlite_query_plan
+} {t1 i1xy}
+do_test where-1.8.3 {
+ count {SELECT x, y FROM t1 WHERE y=144 AND x=3}
+ set sqlite_query_plan
+} {{} i1xy}
+do_test where-1.9 {
+ count {SELECT x, y FROM t1 WHERE y=144 AND w>10 AND x=3}
+} {3 144 3}
+do_test where-1.10 {
+ count {SELECT x, y FROM t1 WHERE x=3 AND w>=10 AND y=121}
+} {3 121 3}
+do_test where-1.11 {
+ count {SELECT x, y FROM t1 WHERE x=3 AND y=100 AND w<10}
+} {3 100 3}
+
+# New for SQLite version 2.1: Verify that that inequality constraints
+# are used correctly.
+#
+do_test where-1.12 {
+ count {SELECT w FROM t1 WHERE x=3 AND y<100}
+} {8 3}
+do_test where-1.13 {
+ count {SELECT w FROM t1 WHERE x=3 AND 100>y}
+} {8 3}
+do_test where-1.14 {
+ count {SELECT w FROM t1 WHERE 3=x AND y<100}
+} {8 3}
+do_test where-1.15 {
+ count {SELECT w FROM t1 WHERE 3=x AND 100>y}
+} {8 3}
+do_test where-1.16 {
+ count {SELECT w FROM t1 WHERE x=3 AND y<=100}
+} {8 9 5}
+do_test where-1.17 {
+ count {SELECT w FROM t1 WHERE x=3 AND 100>=y}
+} {8 9 5}
+do_test where-1.18 {
+ count {SELECT w FROM t1 WHERE x=3 AND y>225}
+} {15 3}
+do_test where-1.19 {
+ count {SELECT w FROM t1 WHERE x=3 AND 225<y}
+} {15 3}
+do_test where-1.20 {
+ count {SELECT w FROM t1 WHERE x=3 AND y>=225}
+} {14 15 5}
+do_test where-1.21 {
+ count {SELECT w FROM t1 WHERE x=3 AND 225<=y}
+} {14 15 5}
+do_test where-1.22 {
+ count {SELECT w FROM t1 WHERE x=3 AND y>121 AND y<196}
+} {11 12 5}
+do_test where-1.23 {
+ count {SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<=196}
+} {10 11 12 13 9}
+do_test where-1.24 {
+ count {SELECT w FROM t1 WHERE x=3 AND 121<y AND 196>y}
+} {11 12 5}
+do_test where-1.25 {
+ count {SELECT w FROM t1 WHERE x=3 AND 121<=y AND 196>=y}
+} {10 11 12 13 9}
+
+# Need to work on optimizing the BETWEEN operator.
+#
+# do_test where-1.26 {
+# count {SELECT w FROM t1 WHERE x=3 AND y BETWEEN 121 AND 196}
+# } {10 11 12 13 9}
+
+do_test where-1.27 {
+ count {SELECT w FROM t1 WHERE x=3 AND y+1==122}
+} {10 10}
+
+do_test where-1.28 {
+ count {SELECT w FROM t1 WHERE x+1=4 AND y+1==122}
+} {10 99}
+do_test where-1.29 {
+ count {SELECT w FROM t1 WHERE y==121}
+} {10 99}
+
+
+do_test where-1.30 {
+ count {SELECT w FROM t1 WHERE w>97}
+} {98 99 100 3}
+do_test where-1.31 {
+ count {SELECT w FROM t1 WHERE w>=97}
+} {97 98 99 100 4}
+do_test where-1.33 {
+ count {SELECT w FROM t1 WHERE w==97}
+} {97 2}
+do_test where-1.33.1 {
+ count {SELECT w FROM t1 WHERE w<=97 AND w==97}
+} {97 2}
+do_test where-1.33.2 {
+ count {SELECT w FROM t1 WHERE w<98 AND w==97}
+} {97 2}
+do_test where-1.33.3 {
+ count {SELECT w FROM t1 WHERE w>=97 AND w==97}
+} {97 2}
+do_test where-1.33.4 {
+ count {SELECT w FROM t1 WHERE w>96 AND w==97}
+} {97 2}
+do_test where-1.33.5 {
+ count {SELECT w FROM t1 WHERE w==97 AND w==97}
+} {97 2}
+do_test where-1.34 {
+ count {SELECT w FROM t1 WHERE w+1==98}
+} {97 99}
+do_test where-1.35 {
+ count {SELECT w FROM t1 WHERE w<3}
+} {1 2 2}
+do_test where-1.36 {
+ count {SELECT w FROM t1 WHERE w<=3}
+} {1 2 3 3}
+do_test where-1.37 {
+ count {SELECT w FROM t1 WHERE w+1<=4 ORDER BY w}
+} {1 2 3 99}
+
+do_test where-1.38 {
+ count {SELECT (w) FROM t1 WHERE (w)>(97)}
+} {98 99 100 3}
+do_test where-1.39 {
+ count {SELECT (w) FROM t1 WHERE (w)>=(97)}
+} {97 98 99 100 4}
+do_test where-1.40 {
+ count {SELECT (w) FROM t1 WHERE (w)==(97)}
+} {97 2}
+do_test where-1.41 {
+ count {SELECT (w) FROM t1 WHERE ((w)+(1))==(98)}
+} {97 99}
+
+
+# Do the same kind of thing except use a join as the data source.
+#
+do_test where-2.1 {
+ count {
+ SELECT w, p FROM t2, t1
+ WHERE x=q AND y=s AND r=8977
+ }
+} {34 67 6}
+do_test where-2.2 {
+ count {
+ SELECT w, p FROM t2, t1
+ WHERE x=q AND s=y AND r=8977
+ }
+} {34 67 6}
+do_test where-2.3 {
+ count {
+ SELECT w, p FROM t2, t1
+ WHERE x=q AND s=y AND r=8977 AND w>10
+ }
+} {34 67 6}
+do_test where-2.4 {
+ count {
+ SELECT w, p FROM t2, t1
+ WHERE p<80 AND x=q AND s=y AND r=8977 AND w>10
+ }
+} {34 67 6}
+do_test where-2.5 {
+ count {
+ SELECT w, p FROM t2, t1
+ WHERE p<80 AND x=q AND 8977=r AND s=y AND w>10
+ }
+} {34 67 6}
+do_test where-2.6 {
+ count {
+ SELECT w, p FROM t2, t1
+ WHERE x=q AND p=77 AND s=y AND w>5
+ }
+} {24 77 6}
+do_test where-2.7 {
+ count {
+ SELECT w, p FROM t1, t2
+ WHERE x=q AND p>77 AND s=y AND w=5
+ }
+} {5 96 6}
+
+# Lets do a 3-way join.
+#
+do_test where-3.1 {
+ count {
+ SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C
+ WHERE C.w=101-B.p AND B.r=10202-A.y AND A.w=11
+ }
+} {11 90 11 8}
+do_test where-3.2 {
+ count {
+ SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C
+ WHERE C.w=101-B.p AND B.r=10202-A.y AND A.w=12
+ }
+} {12 89 12 8}
+do_test where-3.3 {
+ count {
+ SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C
+ WHERE A.w=15 AND B.p=C.w AND B.r=10202-A.y
+ }
+} {15 86 86 8}
+
+# Test to see that the special case of a constant WHERE clause is
+# handled.
+#
+do_test where-4.1 {
+ count {
+ SELECT * FROM t1 WHERE 0
+ }
+} {0}
+do_test where-4.2 {
+ count {
+ SELECT * FROM t1 WHERE 1 LIMIT 1
+ }
+} {1 0 4 0}
+do_test where-4.3 {
+ execsql {
+ SELECT 99 WHERE 0
+ }
+} {}
+do_test where-4.4 {
+ execsql {
+ SELECT 99 WHERE 1
+ }
+} {99}
+do_test where-4.5 {
+ execsql {
+ SELECT 99 WHERE 0.1
+ }
+} {99}
+do_test where-4.6 {
+ execsql {
+ SELECT 99 WHERE 0.0
+ }
+} {}
+do_test where-4.7 {
+ execsql {
+ SELECT count(*) FROM t1 WHERE t1.w
+ }
+} {100}
+
+# Verify that IN operators in a WHERE clause are handled correctly.
+# Omit these tests if the build is not capable of sub-queries.
+#
+ifcapable subquery {
+ do_test where-5.1 {
+ count {
+ SELECT * FROM t1 WHERE rowid IN (1,2,3,1234) order by 1;
+ }
+ } {1 0 4 2 1 9 3 1 16 4}
+ do_test where-5.2 {
+ count {
+ SELECT * FROM t1 WHERE rowid+0 IN (1,2,3,1234) order by 1;
+ }
+ } {1 0 4 2 1 9 3 1 16 102}
+ do_test where-5.3 {
+ count {
+ SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1;
+ }
+ } {1 0 4 2 1 9 3 1 16 14}
+ do_test where-5.4 {
+ count {
+ SELECT * FROM t1 WHERE w+0 IN (-1,1,2,3) order by 1;
+ }
+ } {1 0 4 2 1 9 3 1 16 102}
+ do_test where-5.5 {
+ count {
+ SELECT * FROM t1 WHERE rowid IN
+ (select rowid from t1 where rowid IN (-1,2,4))
+ ORDER BY 1;
+ }
+ } {2 1 9 4 2 25 3}
+ do_test where-5.6 {
+ count {
+ SELECT * FROM t1 WHERE rowid+0 IN
+ (select rowid from t1 where rowid IN (-1,2,4))
+ ORDER BY 1;
+ }
+ } {2 1 9 4 2 25 103}
+ do_test where-5.7 {
+ count {
+ SELECT * FROM t1 WHERE w IN
+ (select rowid from t1 where rowid IN (-1,2,4))
+ ORDER BY 1;
+ }
+ } {2 1 9 4 2 25 9}
+ do_test where-5.8 {
+ count {
+ SELECT * FROM t1 WHERE w+0 IN
+ (select rowid from t1 where rowid IN (-1,2,4))
+ ORDER BY 1;
+ }
+ } {2 1 9 4 2 25 103}
+ do_test where-5.9 {
+ count {
+ SELECT * FROM t1 WHERE x IN (1,7) ORDER BY 1;
+ }
+ } {2 1 9 3 1 16 7}
+ do_test where-5.10 {
+ count {
+ SELECT * FROM t1 WHERE x+0 IN (1,7) ORDER BY 1;
+ }
+ } {2 1 9 3 1 16 199}
+ do_test where-5.11 {
+ count {
+ SELECT * FROM t1 WHERE y IN (6400,8100) ORDER BY 1;
+ }
+ } {79 6 6400 89 6 8100 199}
+ do_test where-5.12 {
+ count {
+ SELECT * FROM t1 WHERE x=6 AND y IN (6400,8100) ORDER BY 1;
+ }
+ } {79 6 6400 89 6 8100 7}
+ do_test where-5.13 {
+ count {
+ SELECT * FROM t1 WHERE x IN (1,7) AND y NOT IN (6400,8100) ORDER BY 1;
+ }
+ } {2 1 9 3 1 16 7}
+ do_test where-5.14 {
+ count {
+ SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,10) ORDER BY 1;
+ }
+ } {2 1 9 8}
+ do_test where-5.15 {
+ count {
+ SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,16) ORDER BY 1;
+ }
+ } {2 1 9 3 1 16 11}
+}
+
+# This procedure executes the SQL. Then it checks to see if the OP_Sort
+# opcode was executed. If an OP_Sort did occur, then "sort" is appended
+# to the result. If no OP_Sort happened, then "nosort" is appended.
+#
+# This procedure is used to check to make sure sorting is or is not
+# occurring as expected.
+#
+proc cksort {sql} {
+ set data [execsql $sql]
+ if {[db status sort]} {set x sort} {set x nosort}
+ lappend data $x
+ return $data
+}
+# Check out the logic that attempts to implement the ORDER BY clause
+# using an index rather than by sorting.
+#
+do_test where-6.1 {
+ execsql {
+ CREATE TABLE t3(a,b,c);
+ CREATE INDEX t3a ON t3(a);
+ CREATE INDEX t3bc ON t3(b,c);
+ CREATE INDEX t3acb ON t3(a,c,b);
+ INSERT INTO t3 SELECT w, 101-w, y FROM t1;
+ SELECT count(*), sum(a), sum(b), sum(c) FROM t3;
+ }
+} {100 5050 5050 348550}
+do_test where-6.2 {
+ cksort {
+ SELECT * FROM t3 ORDER BY a LIMIT 3
+ }
+} {1 100 4 2 99 9 3 98 16 nosort}
+do_test where-6.3 {
+ cksort {
+ SELECT * FROM t3 ORDER BY a+1 LIMIT 3
+ }
+} {1 100 4 2 99 9 3 98 16 sort}
+do_test where-6.4 {
+ cksort {
+ SELECT * FROM t3 WHERE a<10 ORDER BY a LIMIT 3
+ }
+} {1 100 4 2 99 9 3 98 16 nosort}
+do_test where-6.5 {
+ cksort {
+ SELECT * FROM t3 WHERE a>0 AND a<10 ORDER BY a LIMIT 3
+ }
+} {1 100 4 2 99 9 3 98 16 nosort}
+do_test where-6.6 {
+ cksort {
+ SELECT * FROM t3 WHERE a>0 ORDER BY a LIMIT 3
+ }
+} {1 100 4 2 99 9 3 98 16 nosort}
+do_test where-6.7 {
+ cksort {
+ SELECT * FROM t3 WHERE b>0 ORDER BY a LIMIT 3
+ }
+} {1 100 4 2 99 9 3 98 16 nosort}
+ifcapable subquery {
+ do_test where-6.8 {
+ cksort {
+ SELECT * FROM t3 WHERE a IN (3,5,7,1,9,4,2) ORDER BY a LIMIT 3
+ }
+ } {1 100 4 2 99 9 3 98 16 sort}
+}
+do_test where-6.9.1 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.9.1.1 {
+ cksort {
+ SELECT * FROM t3 WHERE a>=1 AND a=1 AND c>0 ORDER BY a LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.9.1.2 {
+ cksort {
+ SELECT * FROM t3 WHERE a<2 AND a=1 AND c>0 ORDER BY a LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.9.2 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a,c LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.9.3 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY c LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.9.4 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a DESC LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.9.5 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a DESC, c DESC LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.9.6 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY c DESC LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.9.7 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY c,a LIMIT 3
+ }
+} {1 100 4 sort}
+do_test where-6.9.8 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a DESC, c ASC LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.9.9 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a ASC, c DESC LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.10 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.11 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a,c LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.12 {
+ cksort {
+ SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a,c,b LIMIT 3
+ }
+} {1 100 4 nosort}
+do_test where-6.13 {
+ cksort {
+ SELECT * FROM t3 WHERE a>0 ORDER BY a DESC LIMIT 3
+ }
+} {100 1 10201 99 2 10000 98 3 9801 nosort}
+do_test where-6.13.1 {
+ cksort {
+ SELECT * FROM t3 WHERE a>0 ORDER BY -a LIMIT 3
+ }
+} {100 1 10201 99 2 10000 98 3 9801 sort}
+do_test where-6.14 {
+ cksort {
+ SELECT * FROM t3 ORDER BY b LIMIT 3
+ }
+} {100 1 10201 99 2 10000 98 3 9801 nosort}
+do_test where-6.15 {
+ cksort {
+ SELECT t3.a, t1.x FROM t3, t1 WHERE t3.a=t1.w ORDER BY t3.a LIMIT 3
+ }
+} {1 0 2 1 3 1 nosort}
+do_test where-6.16 {
+ cksort {
+ SELECT t3.a, t1.x FROM t3, t1 WHERE t3.a=t1.w ORDER BY t1.x, t3.a LIMIT 3
+ }
+} {1 0 2 1 3 1 sort}
+do_test where-6.19 {
+ cksort {
+ SELECT y FROM t1 ORDER BY w LIMIT 3;
+ }
+} {4 9 16 nosort}
+do_test where-6.20 {
+ cksort {
+ SELECT y FROM t1 ORDER BY rowid LIMIT 3;
+ }
+} {4 9 16 nosort}
+do_test where-6.21 {
+ cksort {
+ SELECT y FROM t1 ORDER BY rowid, y LIMIT 3;
+ }
+} {4 9 16 nosort}
+do_test where-6.22 {
+ cksort {
+ SELECT y FROM t1 ORDER BY rowid, y DESC LIMIT 3;
+ }
+} {4 9 16 nosort}
+do_test where-6.23 {
+ cksort {
+ SELECT y FROM t1 WHERE y>4 ORDER BY rowid, w, x LIMIT 3;
+ }
+} {9 16 25 nosort}
+do_test where-6.24 {
+ cksort {
+ SELECT y FROM t1 WHERE y>=9 ORDER BY rowid, x DESC, w LIMIT 3;
+ }
+} {9 16 25 nosort}
+do_test where-6.25 {
+ cksort {
+ SELECT y FROM t1 WHERE y>4 AND y<25 ORDER BY rowid;
+ }
+} {9 16 nosort}
+do_test where-6.26 {
+ cksort {
+ SELECT y FROM t1 WHERE y>=4 AND y<=25 ORDER BY oid;
+ }
+} {4 9 16 25 nosort}
+do_test where-6.27 {
+ cksort {
+ SELECT y FROM t1 WHERE y<=25 ORDER BY _rowid_, w+y;
+ }
+} {4 9 16 25 nosort}
+
+
+# Tests for reverse-order sorting.
+#
+do_test where-7.1 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 ORDER BY y;
+ }
+} {8 9 10 11 12 13 14 15 nosort}
+do_test where-7.2 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 ORDER BY y DESC;
+ }
+} {15 14 13 12 11 10 9 8 nosort}
+do_test where-7.3 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>100 ORDER BY y LIMIT 3;
+ }
+} {10 11 12 nosort}
+do_test where-7.4 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>100 ORDER BY y DESC LIMIT 3;
+ }
+} {15 14 13 nosort}
+do_test where-7.5 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>121 ORDER BY y DESC;
+ }
+} {15 14 13 12 11 nosort}
+do_test where-7.6 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>=121 ORDER BY y DESC;
+ }
+} {15 14 13 12 11 10 nosort}
+do_test where-7.7 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<196 ORDER BY y DESC;
+ }
+} {12 11 10 nosort}
+do_test where-7.8 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<=196 ORDER BY y DESC;
+ }
+} {13 12 11 10 nosort}
+do_test where-7.9 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>121 AND y<=196 ORDER BY y DESC;
+ }
+} {13 12 11 nosort}
+do_test where-7.10 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>100 AND y<196 ORDER BY y DESC;
+ }
+} {12 11 10 nosort}
+do_test where-7.11 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<196 ORDER BY y;
+ }
+} {10 11 12 nosort}
+do_test where-7.12 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<=196 ORDER BY y;
+ }
+} {10 11 12 13 nosort}
+do_test where-7.13 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>121 AND y<=196 ORDER BY y;
+ }
+} {11 12 13 nosort}
+do_test where-7.14 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>100 AND y<196 ORDER BY y;
+ }
+} {10 11 12 nosort}
+do_test where-7.15 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y<81 ORDER BY y;
+ }
+} {nosort}
+do_test where-7.16 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y<=81 ORDER BY y;
+ }
+} {8 nosort}
+do_test where-7.17 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>256 ORDER BY y;
+ }
+} {nosort}
+do_test where-7.18 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>=256 ORDER BY y;
+ }
+} {15 nosort}
+do_test where-7.19 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y<81 ORDER BY y DESC;
+ }
+} {nosort}
+do_test where-7.20 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y<=81 ORDER BY y DESC;
+ }
+} {8 nosort}
+do_test where-7.21 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>256 ORDER BY y DESC;
+ }
+} {nosort}
+do_test where-7.22 {
+ cksort {
+ SELECT w FROM t1 WHERE x=3 AND y>=256 ORDER BY y DESC;
+ }
+} {15 nosort}
+do_test where-7.23 {
+ cksort {
+ SELECT w FROM t1 WHERE x=0 AND y<4 ORDER BY y;
+ }
+} {nosort}
+do_test where-7.24 {
+ cksort {
+ SELECT w FROM t1 WHERE x=0 AND y<=4 ORDER BY y;
+ }
+} {1 nosort}
+do_test where-7.25 {
+ cksort {
+ SELECT w FROM t1 WHERE x=6 AND y>10201 ORDER BY y;
+ }
+} {nosort}
+do_test where-7.26 {
+ cksort {
+ SELECT w FROM t1 WHERE x=6 AND y>=10201 ORDER BY y;
+ }
+} {100 nosort}
+do_test where-7.27 {
+ cksort {
+ SELECT w FROM t1 WHERE x=0 AND y<4 ORDER BY y DESC;
+ }
+} {nosort}
+do_test where-7.28 {
+ cksort {
+ SELECT w FROM t1 WHERE x=0 AND y<=4 ORDER BY y DESC;
+ }
+} {1 nosort}
+do_test where-7.29 {
+ cksort {
+ SELECT w FROM t1 WHERE x=6 AND y>10201 ORDER BY y DESC;
+ }
+} {nosort}
+do_test where-7.30 {
+ cksort {
+ SELECT w FROM t1 WHERE x=6 AND y>=10201 ORDER BY y DESC;
+ }
+} {100 nosort}
+do_test where-7.31 {
+ cksort {
+ SELECT y FROM t1 ORDER BY rowid DESC LIMIT 3
+ }
+} {10201 10000 9801 nosort}
+do_test where-7.32 {
+ cksort {
+ SELECT y FROM t1 WHERE y<25 ORDER BY rowid DESC
+ }
+} {16 9 4 nosort}
+do_test where-7.33 {
+ cksort {
+ SELECT y FROM t1 WHERE y<=25 ORDER BY rowid DESC
+ }
+} {25 16 9 4 nosort}
+do_test where-7.34 {
+ cksort {
+ SELECT y FROM t1 WHERE y<25 AND y>4 ORDER BY rowid DESC, y DESC
+ }
+} {16 9 nosort}
+do_test where-7.35 {
+ cksort {
+ SELECT y FROM t1 WHERE y<25 AND y>=4 ORDER BY rowid DESC
+ }
+} {16 9 4 nosort}
+
+do_test where-8.1 {
+ execsql {
+ CREATE TABLE t4 AS SELECT * FROM t1;
+ CREATE INDEX i4xy ON t4(x,y);
+ }
+ cksort {
+ SELECT w FROM t4 WHERE x=4 and y<1000 ORDER BY y DESC limit 3;
+ }
+} {30 29 28 nosort}
+do_test where-8.2 {
+ execsql {
+ DELETE FROM t4;
+ }
+ cksort {
+ SELECT w FROM t4 WHERE x=4 and y<1000 ORDER BY y DESC limit 3;
+ }
+} {nosort}
+
+# Make sure searches with an index work with an empty table.
+#
+do_test where-9.1 {
+ execsql {
+ CREATE TABLE t5(x PRIMARY KEY);
+ SELECT * FROM t5 WHERE x<10;
+ }
+} {}
+do_test where-9.2 {
+ execsql {
+ SELECT * FROM t5 WHERE x<10 ORDER BY x DESC;
+ }
+} {}
+do_test where-9.3 {
+ execsql {
+ SELECT * FROM t5 WHERE x=10;
+ }
+} {}
+
+do_test where-10.1 {
+ execsql {
+ SELECT 1 WHERE abs(random())<0
+ }
+} {}
+do_test where-10.2 {
+ proc tclvar_func {vname} {return [set ::$vname]}
+ db function tclvar tclvar_func
+ set ::v1 0
+ execsql {
+ SELECT count(*) FROM t1 WHERE tclvar('v1');
+ }
+} {0}
+do_test where-10.3 {
+ set ::v1 1
+ execsql {
+ SELECT count(*) FROM t1 WHERE tclvar('v1');
+ }
+} {100}
+do_test where-10.4 {
+ set ::v1 1
+ proc tclvar_func {vname} {
+ upvar #0 $vname v
+ set v [expr {!$v}]
+ return $v
+ }
+ execsql {
+ SELECT count(*) FROM t1 WHERE tclvar('v1');
+ }
+} {50}
+
+# Ticket #1376. The query below was causing a segfault.
+# The problem was the age-old error of calling realloc() on an
+# array while there are still pointers to individual elements of
+# that array.
+#
+do_test where-11.1 {
+ execsql {
+ CREATE TABLE t99(Dte INT, X INT);
+ DELETE FROM t99 WHERE (Dte = 2451337) OR (Dte = 2451339) OR
+ (Dte BETWEEN 2451345 AND 2451347) OR (Dte = 2451351) OR
+ (Dte BETWEEN 2451355 AND 2451356) OR (Dte = 2451358) OR
+ (Dte = 2451362) OR (Dte = 2451365) OR (Dte = 2451367) OR
+ (Dte BETWEEN 2451372 AND 2451376) OR (Dte BETWEEN 2451382 AND 2451384) OR
+ (Dte = 2451387) OR (Dte BETWEEN 2451389 AND 2451391) OR
+ (Dte BETWEEN 2451393 AND 2451395) OR (Dte = 2451400) OR
+ (Dte = 2451402) OR (Dte = 2451404) OR (Dte BETWEEN 2451416 AND 2451418) OR
+ (Dte = 2451422) OR (Dte = 2451426) OR (Dte BETWEEN 2451445 AND 2451446) OR
+ (Dte = 2451456) OR (Dte = 2451458) OR (Dte BETWEEN 2451465 AND 2451467) OR
+ (Dte BETWEEN 2451469 AND 2451471) OR (Dte = 2451474) OR
+ (Dte BETWEEN 2451477 AND 2451501) OR (Dte BETWEEN 2451503 AND 2451509) OR
+ (Dte BETWEEN 2451511 AND 2451514) OR (Dte BETWEEN 2451518 AND 2451521) OR
+ (Dte BETWEEN 2451523 AND 2451531) OR (Dte BETWEEN 2451533 AND 2451537) OR
+ (Dte BETWEEN 2451539 AND 2451544) OR (Dte BETWEEN 2451546 AND 2451551) OR
+ (Dte BETWEEN 2451553 AND 2451555) OR (Dte = 2451557) OR
+ (Dte BETWEEN 2451559 AND 2451561) OR (Dte = 2451563) OR
+ (Dte BETWEEN 2451565 AND 2451566) OR (Dte BETWEEN 2451569 AND 2451571) OR
+ (Dte = 2451573) OR (Dte = 2451575) OR (Dte = 2451577) OR (Dte = 2451581) OR
+ (Dte BETWEEN 2451583 AND 2451586) OR (Dte BETWEEN 2451588 AND 2451592) OR
+ (Dte BETWEEN 2451596 AND 2451598) OR (Dte = 2451600) OR
+ (Dte BETWEEN 2451602 AND 2451603) OR (Dte = 2451606) OR (Dte = 2451611);
+ }
+} {}
+
+# Ticket #2116: Make sure sorting by index works well with nn INTEGER PRIMARY
+# KEY.
+#
+do_test where-12.1 {
+ execsql {
+ CREATE TABLE t6(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t6 VALUES(1,'one');
+ INSERT INTO t6 VALUES(4,'four');
+ CREATE INDEX t6i1 ON t6(b);
+ }
+ cksort {
+ SELECT * FROM t6 ORDER BY b;
+ }
+} {4 four 1 one nosort}
+do_test where-12.2 {
+ cksort {
+ SELECT * FROM t6 ORDER BY b, a;
+ }
+} {4 four 1 one nosort}
+do_test where-12.3 {
+ cksort {
+ SELECT * FROM t6 ORDER BY a;
+ }
+} {1 one 4 four nosort}
+do_test where-12.4 {
+ cksort {
+ SELECT * FROM t6 ORDER BY a, b;
+ }
+} {1 one 4 four nosort}
+do_test where-12.5 {
+ cksort {
+ SELECT * FROM t6 ORDER BY b DESC;
+ }
+} {1 one 4 four nosort}
+do_test where-12.6 {
+ cksort {
+ SELECT * FROM t6 ORDER BY b DESC, a DESC;
+ }
+} {1 one 4 four nosort}
+do_test where-12.7 {
+ cksort {
+ SELECT * FROM t6 ORDER BY b DESC, a ASC;
+ }
+} {1 one 4 four sort}
+do_test where-12.8 {
+ cksort {
+ SELECT * FROM t6 ORDER BY b ASC, a DESC;
+ }
+} {4 four 1 one sort}
+do_test where-12.9 {
+ cksort {
+ SELECT * FROM t6 ORDER BY a DESC;
+ }
+} {4 four 1 one nosort}
+do_test where-12.10 {
+ cksort {
+ SELECT * FROM t6 ORDER BY a DESC, b DESC;
+ }
+} {4 four 1 one nosort}
+do_test where-12.11 {
+ cksort {
+ SELECT * FROM t6 ORDER BY a DESC, b ASC;
+ }
+} {4 four 1 one nosort}
+do_test where-12.12 {
+ cksort {
+ SELECT * FROM t6 ORDER BY a ASC, b DESC;
+ }
+} {1 one 4 four nosort}
+do_test where-13.1 {
+ execsql {
+ CREATE TABLE t7(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t7 VALUES(1,'one');
+ INSERT INTO t7 VALUES(4,'four');
+ CREATE INDEX t7i1 ON t7(b);
+ }
+ cksort {
+ SELECT * FROM t7 ORDER BY b;
+ }
+} {4 four 1 one nosort}
+do_test where-13.2 {
+ cksort {
+ SELECT * FROM t7 ORDER BY b, a;
+ }
+} {4 four 1 one nosort}
+do_test where-13.3 {
+ cksort {
+ SELECT * FROM t7 ORDER BY a;
+ }
+} {1 one 4 four nosort}
+do_test where-13.4 {
+ cksort {
+ SELECT * FROM t7 ORDER BY a, b;
+ }
+} {1 one 4 four nosort}
+do_test where-13.5 {
+ cksort {
+ SELECT * FROM t7 ORDER BY b DESC;
+ }
+} {1 one 4 four nosort}
+do_test where-13.6 {
+ cksort {
+ SELECT * FROM t7 ORDER BY b DESC, a DESC;
+ }
+} {1 one 4 four nosort}
+do_test where-13.7 {
+ cksort {
+ SELECT * FROM t7 ORDER BY b DESC, a ASC;
+ }
+} {1 one 4 four sort}
+do_test where-13.8 {
+ cksort {
+ SELECT * FROM t7 ORDER BY b ASC, a DESC;
+ }
+} {4 four 1 one sort}
+do_test where-13.9 {
+ cksort {
+ SELECT * FROM t7 ORDER BY a DESC;
+ }
+} {4 four 1 one nosort}
+do_test where-13.10 {
+ cksort {
+ SELECT * FROM t7 ORDER BY a DESC, b DESC;
+ }
+} {4 four 1 one nosort}
+do_test where-13.11 {
+ cksort {
+ SELECT * FROM t7 ORDER BY a DESC, b ASC;
+ }
+} {4 four 1 one nosort}
+do_test where-13.12 {
+ cksort {
+ SELECT * FROM t7 ORDER BY a ASC, b DESC;
+ }
+} {1 one 4 four nosort}
+
+# Ticket #2211.
+#
+# When optimizing out ORDER BY clauses, make sure that trailing terms
+# of the ORDER BY clause do not reference other tables in a join.
+#
+do_test where-14.1 {
+ execsql {
+ CREATE TABLE t8(a INTEGER PRIMARY KEY, b TEXT UNIQUE);
+ INSERT INTO t8 VALUES(1,'one');
+ INSERT INTO t8 VALUES(4,'four');
+ }
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, y.b
+ }
+} {1/4 1/1 4/4 4/1 sort}
+do_test where-14.2 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, y.b DESC
+ }
+} {1/1 1/4 4/1 4/4 sort}
+do_test where-14.3 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, x.b
+ }
+} {1/1 1/4 4/1 4/4 nosort}
+do_test where-14.4 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, x.b DESC
+ }
+} {1/1 1/4 4/1 4/4 nosort}
+do_test where-14.5 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||x.b
+ }
+} {4/1 4/4 1/1 1/4 nosort}
+do_test where-14.6 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||x.b DESC
+ }
+} {4/1 4/4 1/1 1/4 nosort}
+do_test where-14.7 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||y.b
+ }
+} {4/1 4/4 1/1 1/4 sort}
+do_test where-14.7.1 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a, y.a||y.b
+ }
+} {4/1 4/4 1/1 1/4 sort}
+do_test where-14.7.2 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a, x.a||x.b
+ }
+} {4/1 4/4 1/1 1/4 nosort}
+do_test where-14.8 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||y.b DESC
+ }
+} {4/4 4/1 1/4 1/1 sort}
+do_test where-14.9 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||y.b
+ }
+} {4/4 4/1 1/4 1/1 sort}
+do_test where-14.10 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||y.b DESC
+ }
+} {4/1 4/4 1/1 1/4 sort}
+do_test where-14.11 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||x.b
+ }
+} {4/1 4/4 1/1 1/4 sort}
+do_test where-14.12 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||x.b DESC
+ }
+} {4/4 4/1 1/4 1/1 sort}
+
+# Ticket #2445.
+#
+# There was a crash that could occur when a where clause contains an
+# alias for an expression in the result set, and that expression retrieves
+# a column of the second or subsequent table in a join.
+#
+do_test where-15.1 {
+ execsql {
+ CREATE TEMP TABLE t1 (a, b, c, d, e);
+ CREATE TEMP TABLE t2 (f);
+ SELECT t1.e AS alias FROM t2, t1 WHERE alias = 1 ;
+ }
+} {}
+
+# Ticket #3408.
+#
+# The branch of code in where.c that generated rowid lookups was
+# incorrectly deallocating a constant register, meaning that if the
+# vdbe code ran more than once, the second time around the constant
+# value may have been clobbered by some other value.
+#
+do_test where-16.1 {
+ execsql {
+ CREATE TABLE a1(id INTEGER PRIMARY KEY, v);
+ CREATE TABLE a2(id INTEGER PRIMARY KEY, v);
+ INSERT INTO a1 VALUES(1, 'one');
+ INSERT INTO a1 VALUES(2, 'two');
+ INSERT INTO a2 VALUES(1, 'one');
+ INSERT INTO a2 VALUES(2, 'two');
+ }
+} {}
+do_test where-16.2 {
+ execsql {
+ SELECT * FROM a2 CROSS JOIN a1 WHERE a1.id=1 AND a1.v='one';
+ }
+} {1 one 1 one 2 two 1 one}
+
+# The actual problem reported in #3408.
+do_test where-16.3 {
+ execsql {
+ CREATE TEMP TABLE foo(idx INTEGER);
+ INSERT INTO foo VALUES(1);
+ INSERT INTO foo VALUES(1);
+ INSERT INTO foo VALUES(1);
+ INSERT INTO foo VALUES(2);
+ INSERT INTO foo VALUES(2);
+ CREATE TEMP TABLE bar(stuff INTEGER);
+ INSERT INTO bar VALUES(100);
+ INSERT INTO bar VALUES(200);
+ INSERT INTO bar VALUES(300);
+ }
+} {}
+do_test where-16.4 {
+ execsql {
+ SELECT bar.RowID id FROM foo, bar WHERE foo.idx = bar.RowID AND id = 2;
+ }
+} {2 2}
+
+integrity_check {where-99.0}
+
+#---------------------------------------------------------------------
+# These tests test that a bug surrounding the use of ForceInt has been
+# fixed in where.c.
+#
+do_test where-17.1 {
+ execsql {
+ CREATE TABLE tbooking (
+ id INTEGER PRIMARY KEY,
+ eventtype INTEGER NOT NULL
+ );
+ INSERT INTO tbooking VALUES(42, 3);
+ INSERT INTO tbooking VALUES(43, 4);
+ }
+} {}
+do_test where-17.2 {
+ execsql {
+ SELECT a.id
+ FROM tbooking AS a
+ WHERE a.eventtype=3;
+ }
+} {42}
+do_test where-17.3 {
+ execsql {
+ SELECT a.id, (SELECT b.id FROM tbooking AS b WHERE b.id>a.id)
+ FROM tbooking AS a
+ WHERE a.eventtype=3;
+ }
+} {42 43}
+do_test where-17.4 {
+ execsql {
+ SELECT a.id, (SELECT b.id FROM tbooking AS b WHERE b.id>a.id)
+ FROM (SELECT 1.5 AS id) AS a
+ }
+} {1.5 42}
+do_test where-17.5 {
+ execsql {
+ CREATE TABLE tother(a, b);
+ INSERT INTO tother VALUES(1, 3.7);
+ SELECT id, a FROM tbooking, tother WHERE id>a;
+ }
+} {42 1 43 1}
+
+finish_test
diff --git a/test/where2.test b/test/where2.test
new file mode 100644
index 0000000..d61c089
--- /dev/null
+++ b/test/where2.test
@@ -0,0 +1,654 @@
+# 2005 July 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the use of indices in WHERE clauses
+# based on recent changes to the optimizer.
+#
+# $Id: where2.test,v 1.15 2009/02/02 01:50:40 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+do_test where2-1.0 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(w int, x int, y int, z int);
+ }
+ for {set i 1} {$i<=100} {incr i} {
+ set w $i
+ set x [expr {int(log($i)/log(2))}]
+ set y [expr {$i*$i + 2*$i + 1}]
+ set z [expr {$x+$y}]
+ ifcapable tclvar {
+ execsql {INSERT INTO t1 VALUES($::w,$::x,$::y,$::z)}
+ } else {
+ execsql {INSERT INTO t1 VALUES(:w,:x,:y,:z)}
+ }
+ }
+ execsql {
+ CREATE UNIQUE INDEX i1w ON t1(w);
+ CREATE INDEX i1xy ON t1(x,y);
+ CREATE INDEX i1zyx ON t1(z,y,x);
+ COMMIT;
+ }
+} {}
+
+# Do an SQL statement. Append the search count to the end of the result.
+#
+proc count sql {
+ set ::sqlite_search_count 0
+ return [concat [execsql $sql] $::sqlite_search_count]
+}
+
+# This procedure executes the SQL. Then it checks to see if the OP_Sort
+# opcode was executed. If an OP_Sort did occur, then "sort" is appended
+# to the result. If no OP_Sort happened, then "nosort" is appended.
+#
+# This procedure is used to check to make sure sorting is or is not
+# occurring as expected.
+#
+proc cksort {sql} {
+ set data [execsql $sql]
+ if {[db status sort]} {set x sort} {set x nosort}
+ lappend data $x
+ return $data
+}
+
+# This procedure executes the SQL. Then it appends to the result the
+# "sort" or "nosort" keyword (as in the cksort procedure above) then
+# it appends the ::sqlite_query_plan variable.
+#
+proc queryplan {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ if {$::sqlite_sort_count} {set x sort} {set x nosort}
+ lappend data $x
+ return [concat $data $::sqlite_query_plan]
+}
+
+
+# Prefer a UNIQUE index over another index.
+#
+do_test where2-1.1 {
+ queryplan {
+ SELECT * FROM t1 WHERE w=85 AND x=6 AND y=7396
+ }
+} {85 6 7396 7402 nosort t1 i1w}
+
+# Always prefer a rowid== constraint over any other index.
+#
+do_test where2-1.3 {
+ queryplan {
+ SELECT * FROM t1 WHERE w=85 AND x=6 AND y=7396 AND rowid=85
+ }
+} {85 6 7396 7402 nosort t1 *}
+
+# When constrained by a UNIQUE index, the ORDER BY clause is always ignored.
+#
+do_test where2-2.1 {
+ queryplan {
+ SELECT * FROM t1 WHERE w=85 ORDER BY random();
+ }
+} {85 6 7396 7402 nosort t1 i1w}
+do_test where2-2.2 {
+ queryplan {
+ SELECT * FROM t1 WHERE x=6 AND y=7396 ORDER BY random();
+ }
+} {85 6 7396 7402 sort t1 i1xy}
+do_test where2-2.3 {
+ queryplan {
+ SELECT * FROM t1 WHERE rowid=85 AND x=6 AND y=7396 ORDER BY random();
+ }
+} {85 6 7396 7402 nosort t1 *}
+
+
+# Efficient handling of forward and reverse table scans.
+#
+do_test where2-3.1 {
+ queryplan {
+ SELECT * FROM t1 ORDER BY rowid LIMIT 2
+ }
+} {1 0 4 4 2 1 9 10 nosort t1 *}
+do_test where2-3.2 {
+ queryplan {
+ SELECT * FROM t1 ORDER BY rowid DESC LIMIT 2
+ }
+} {100 6 10201 10207 99 6 10000 10006 nosort t1 *}
+
+# The IN operator can be used by indices at multiple layers
+#
+ifcapable subquery {
+ do_test where2-4.1 {
+ queryplan {
+ SELECT * FROM t1 WHERE z IN (10207,10006) AND y IN (10000,10201)
+ AND x>0 AND x<10
+ ORDER BY w
+ }
+ } {99 6 10000 10006 100 6 10201 10207 sort t1 i1zyx}
+ do_test where2-4.2 {
+ queryplan {
+ SELECT * FROM t1 WHERE z IN (10207,10006) AND y=10000
+ AND x>0 AND x<10
+ ORDER BY w
+ }
+ } {99 6 10000 10006 sort t1 i1zyx}
+ do_test where2-4.3 {
+ queryplan {
+ SELECT * FROM t1 WHERE z=10006 AND y IN (10000,10201)
+ AND x>0 AND x<10
+ ORDER BY w
+ }
+ } {99 6 10000 10006 sort t1 i1zyx}
+ ifcapable compound {
+ do_test where2-4.4 {
+ queryplan {
+ SELECT * FROM t1 WHERE z IN (SELECT 10207 UNION SELECT 10006)
+ AND y IN (10000,10201)
+ AND x>0 AND x<10
+ ORDER BY w
+ }
+ } {99 6 10000 10006 100 6 10201 10207 sort t1 i1zyx}
+ do_test where2-4.5 {
+ queryplan {
+ SELECT * FROM t1 WHERE z IN (SELECT 10207 UNION SELECT 10006)
+ AND y IN (SELECT 10000 UNION SELECT 10201)
+ AND x>0 AND x<10
+ ORDER BY w
+ }
+ } {99 6 10000 10006 100 6 10201 10207 sort t1 i1zyx}
+ }
+ do_test where2-4.6 {
+ queryplan {
+ SELECT * FROM t1
+ WHERE x IN (1,2,3,4,5,6,7,8)
+ AND y IN (10000,10001,10002,10003,10004,10005)
+ ORDER BY 2
+ }
+ } {99 6 10000 10006 sort t1 i1xy}
+
+ # Duplicate entires on the RHS of an IN operator do not cause duplicate
+ # output rows.
+ #
+ do_test where2-4.6 {
+ queryplan {
+ SELECT * FROM t1 WHERE z IN (10207,10006,10006,10207)
+ ORDER BY w
+ }
+ } {99 6 10000 10006 100 6 10201 10207 sort t1 i1zyx}
+ ifcapable compound {
+ do_test where2-4.7 {
+ queryplan {
+ SELECT * FROM t1 WHERE z IN (
+ SELECT 10207 UNION ALL SELECT 10006
+ UNION ALL SELECT 10006 UNION ALL SELECT 10207)
+ ORDER BY w
+ }
+ } {99 6 10000 10006 100 6 10201 10207 sort t1 i1zyx}
+ }
+
+} ;# ifcapable subquery
+
+# The use of an IN operator disables the index as a sorter.
+#
+do_test where2-5.1 {
+ queryplan {
+ SELECT * FROM t1 WHERE w=99 ORDER BY w
+ }
+} {99 6 10000 10006 nosort t1 i1w}
+
+ifcapable subquery {
+ do_test where2-5.2 {
+ queryplan {
+ SELECT * FROM t1 WHERE w IN (99) ORDER BY w
+ }
+ } {99 6 10000 10006 sort t1 i1w}
+}
+
+# Verify that OR clauses get translated into IN operators.
+#
+set ::idx {}
+ifcapable subquery {set ::idx i1w}
+do_test where2-6.1.1 {
+ queryplan {
+ SELECT * FROM t1 WHERE w=99 OR w=100 ORDER BY +w
+ }
+} [list 99 6 10000 10006 100 6 10201 10207 sort t1 $::idx]
+do_test where2-6.1.2 {
+ queryplan {
+ SELECT * FROM t1 WHERE 99=w OR 100=w ORDER BY +w
+ }
+} [list 99 6 10000 10006 100 6 10201 10207 sort t1 $::idx]
+do_test where2-6.2 {
+ queryplan {
+ SELECT * FROM t1 WHERE w=99 OR w=100 OR 6=w ORDER BY +w
+ }
+} [list 6 2 49 51 99 6 10000 10006 100 6 10201 10207 sort t1 $::idx]
+
+do_test where2-6.3 {
+ queryplan {
+ SELECT * FROM t1 WHERE w=99 OR w=100 OR 6=+w ORDER BY +w
+ }
+} {6 2 49 51 99 6 10000 10006 100 6 10201 10207 sort t1 {}}
+do_test where2-6.4 {
+ queryplan {
+ SELECT * FROM t1 WHERE w=99 OR +w=100 OR 6=w ORDER BY +w
+ }
+} {6 2 49 51 99 6 10000 10006 100 6 10201 10207 sort t1 {}}
+
+set ::idx {}
+ifcapable subquery {set ::idx i1zyx}
+do_test where2-6.5 {
+ queryplan {
+ SELECT b.* FROM t1 a, t1 b
+ WHERE a.w=1 AND (a.y=b.z OR b.z=10)
+ ORDER BY +b.w
+ }
+} [list 1 0 4 4 2 1 9 10 sort a i1w b $::idx]
+do_test where2-6.6 {
+ queryplan {
+ SELECT b.* FROM t1 a, t1 b
+ WHERE a.w=1 AND (b.z=10 OR a.y=b.z OR b.z=10)
+ ORDER BY +b.w
+ }
+} [list 1 0 4 4 2 1 9 10 sort a i1w b $::idx]
+
+# Ticket #2249. Make sure the OR optimization is not attempted if
+# comparisons between columns of different affinities are needed.
+#
+do_test where2-6.7 {
+ execsql {
+ CREATE TABLE t2249a(a TEXT UNIQUE);
+ CREATE TABLE t2249b(b INTEGER);
+ INSERT INTO t2249a VALUES('0123');
+ INSERT INTO t2249b VALUES(123);
+ }
+ queryplan {
+ -- Because a is type TEXT and b is type INTEGER, both a and b
+ -- will attempt to convert to NUMERIC before the comparison.
+ -- They will thus compare equal.
+ --
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=b;
+ }
+} {123 0123 nosort t2249b {} t2249a {}}
+do_test where2-6.9 {
+ queryplan {
+ -- The + operator removes affinity from the rhs. No conversions
+ -- occur and the comparison is false. The result is an empty set.
+ --
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b;
+ }
+} {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
+do_test where2-6.9.2 {
+ # The same thing but with the expression flipped around.
+ queryplan {
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE +b=a
+ }
+} {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
+do_test where2-6.10 {
+ queryplan {
+ -- Use + on both sides of the comparison to disable indices
+ -- completely. Make sure we get the same result.
+ --
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE +a=+b;
+ }
+} {nosort t2249b {} t2249a {}}
+do_test where2-6.11 {
+ # This will not attempt the OR optimization because of the a=b
+ # comparison.
+ queryplan {
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=b OR a='hello';
+ }
+} {123 0123 nosort t2249b {} t2249a {}}
+do_test where2-6.11.2 {
+ # Permutations of the expression terms.
+ queryplan {
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE b=a OR a='hello';
+ }
+} {123 0123 nosort t2249b {} t2249a {}}
+do_test where2-6.11.3 {
+ # Permutations of the expression terms.
+ queryplan {
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE 'hello'=a OR b=a;
+ }
+} {123 0123 nosort t2249b {} t2249a {}}
+do_test where2-6.11.4 {
+ # Permutations of the expression terms.
+ queryplan {
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR b=a;
+ }
+} {123 0123 nosort t2249b {} t2249a {}}
+ifcapable explain&&subquery {
+ # These tests are not run if subquery support is not included in the
+ # build. This is because these tests test the "a = 1 OR a = 2" to
+ # "a IN (1, 2)" optimisation transformation, which is not enabled if
+ # subqueries and the IN operator is not available.
+ #
+ do_test where2-6.12 {
+ # In this case, the +b disables the affinity conflict and allows
+ # the OR optimization to be used again. The result is now an empty
+ # set, the same as in where2-6.9.
+ queryplan {
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b OR a='hello';
+ }
+ } {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
+ do_test where2-6.12.2 {
+ # In this case, the +b disables the affinity conflict and allows
+ # the OR optimization to be used again. The result is now an empty
+ # set, the same as in where2-6.9.
+ queryplan {
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR +b=a;
+ }
+ } {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
+ do_test where2-6.12.3 {
+ # In this case, the +b disables the affinity conflict and allows
+ # the OR optimization to be used again. The result is now an empty
+ # set, the same as in where2-6.9.
+ queryplan {
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE +b=a OR a='hello';
+ }
+ } {nosort t2249b {} {} sqlite_autoindex_t2249a_1}
+ do_test where2-6.13 {
+ # The addition of +a on the second term disabled the OR optimization.
+ # But we should still get the same empty-set result as in where2-6.9.
+ queryplan {
+ SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b OR +a='hello';
+ }
+ } {nosort t2249b {} t2249a {}}
+}
+
+# Variations on the order of terms in a WHERE clause in order
+# to make sure the OR optimizer can recognize them all.
+do_test where2-6.20 {
+ queryplan {
+ SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a
+ }
+} {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
+ifcapable explain&&subquery {
+ # These tests are not run if subquery support is not included in the
+ # build. This is because these tests test the "a = 1 OR a = 2" to
+ # "a IN (1, 2)" optimisation transformation, which is not enabled if
+ # subqueries and the IN operator is not available.
+ #
+ do_test where2-6.21 {
+ queryplan {
+ SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a OR y.a='hello'
+ }
+ } {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
+ do_test where2-6.22 {
+ queryplan {
+ SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE y.a=x.a OR y.a='hello'
+ }
+ } {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
+ do_test where2-6.23 {
+ queryplan {
+ SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE y.a='hello' OR x.a=y.a
+ }
+ } {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1}
+}
+
+# Unique queries (queries that are guaranteed to return only a single
+# row of result) do not call the sorter. But all tables must give
+# a unique result. If any one table in the join does not give a unique
+# result then sorting is necessary.
+#
+do_test where2-7.1 {
+ cksort {
+ create table t8(a unique, b, c);
+ insert into t8 values(1,2,3);
+ insert into t8 values(2,3,4);
+ create table t9(x,y);
+ insert into t9 values(2,4);
+ insert into t9 values(2,3);
+ select y from t8, t9 where a=1 order by a, y;
+ }
+} {3 4 sort}
+do_test where2-7.2 {
+ cksort {
+ select * from t8 where a=1 order by b, c
+ }
+} {1 2 3 nosort}
+do_test where2-7.3 {
+ cksort {
+ select * from t8, t9 where a=1 and y=3 order by b, x
+ }
+} {1 2 3 2 3 sort}
+do_test where2-7.4 {
+ cksort {
+ create unique index i9y on t9(y);
+ select * from t8, t9 where a=1 and y=3 order by b, x
+ }
+} {1 2 3 2 3 nosort}
+
+# Ticket #1807. Using IN constrains on multiple columns of
+# a multi-column index.
+#
+ifcapable subquery {
+ do_test where2-8.1 {
+ execsql {
+ SELECT * FROM t1 WHERE x IN (20,21) AND y IN (1,2)
+ }
+ } {}
+ do_test where2-8.2 {
+ execsql {
+ SELECT * FROM t1 WHERE x IN (1,2) AND y IN (-5,-6)
+ }
+ } {}
+ execsql {CREATE TABLE tx AS SELECT * FROM t1}
+ do_test where2-8.3 {
+ execsql {
+ SELECT w FROM t1
+ WHERE x IN (SELECT x FROM tx WHERE rowid<0)
+ AND +y IN (SELECT y FROM tx WHERE rowid=1)
+ }
+ } {}
+ do_test where2-8.4 {
+ execsql {
+ SELECT w FROM t1
+ WHERE x IN (SELECT x FROM tx WHERE rowid=1)
+ AND y IN (SELECT y FROM tx WHERE rowid<0)
+ }
+ } {}
+ #set sqlite_where_trace 1
+ do_test where2-8.5 {
+ execsql {
+ CREATE INDEX tx_xyz ON tx(x, y, z, w);
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 12 AND 14)
+ }
+ } {12 13 14}
+ do_test where2-8.6 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 12 AND 14)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)
+ }
+ } {12 13 14}
+ do_test where2-8.7 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 12 AND 14)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)
+ }
+ } {10 11 12 13 14 15}
+ do_test where2-8.8 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)
+ }
+ } {10 11 12 13 14 15 16 17 18 19 20}
+ do_test where2-8.9 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 2 AND 4)
+ }
+ } {}
+ do_test where2-8.10 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 2 AND 4)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)
+ }
+ } {}
+ do_test where2-8.11 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 2 AND 4)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)
+ }
+ } {}
+ do_test where2-8.12 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN -4 AND -2)
+ }
+ } {}
+ do_test where2-8.13 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN -4 AND -2)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)
+ }
+ } {}
+ do_test where2-8.14 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN -4 AND -2)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)
+ }
+ } {}
+ do_test where2-8.15 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 200 AND 300)
+ }
+ } {}
+ do_test where2-8.16 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 200 AND 300)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)
+ }
+ } {}
+ do_test where2-8.17 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 200 AND 300)
+ AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)
+ }
+ } {}
+ do_test where2-8.18 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE +w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE +w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE +w BETWEEN 200 AND 300)
+ }
+ } {}
+ do_test where2-8.19 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE +w BETWEEN 10 AND 20)
+ AND y IN (SELECT y FROM t1 WHERE +w BETWEEN 200 AND 300)
+ AND z IN (SELECT z FROM t1 WHERE +w BETWEEN 10 AND 20)
+ }
+ } {}
+ do_test where2-8.20 {
+ execsql {
+ SELECT w FROM tx
+ WHERE x IN (SELECT x FROM t1 WHERE +w BETWEEN 200 AND 300)
+ AND y IN (SELECT y FROM t1 WHERE +w BETWEEN 10 AND 20)
+ AND z IN (SELECT z FROM t1 WHERE +w BETWEEN 10 AND 20)
+ }
+ } {}
+}
+
+# Make sure WHERE clauses of the form A=1 AND (B=2 OR B=3) are optimized
+# when we have an index on A and B.
+#
+ifcapable or_opt&&tclvar {
+ do_test where2-9.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t10(a,b,c);
+ INSERT INTO t10 VALUES(1,1,1);
+ INSERT INTO t10 VALUES(1,2,2);
+ INSERT INTO t10 VALUES(1,3,3);
+ }
+ for {set i 4} {$i<=1000} {incr i} {
+ execsql {INSERT INTO t10 VALUES(1,$i,$i)}
+ }
+ execsql {
+ CREATE INDEX i10 ON t10(a,b);
+ COMMIT;
+ SELECT count(*) FROM t10;
+ }
+ } 1000
+ ifcapable subquery {
+ do_test where2-9.2 {
+ count {
+ SELECT * FROM t10 WHERE a=1 AND (b=2 OR b=3)
+ }
+ } {1 2 2 1 3 3 7}
+ }
+}
+
+# Indices with redundant columns
+#
+do_test where2-11.1 {
+ execsql {
+ CREATE TABLE t11(a,b,c,d);
+ CREATE INDEX i11aba ON t11(a,b,a,c); -- column A occurs twice.
+ INSERT INTO t11 VALUES(1,2,3,4);
+ INSERT INTO t11 VALUES(5,6,7,8);
+ INSERT INTO t11 VALUES(1,2,9,10);
+ INSERT INTO t11 VALUES(5,11,12,13);
+ SELECT c FROM t11 WHERE a=1 AND b=2 ORDER BY c;
+ }
+} {3 9}
+do_test where2-11.2 {
+ execsql {
+ CREATE INDEX i11cccccccc ON t11(c,c,c,c,c,c,c,c); -- repeated column
+ SELECT d FROM t11 WHERE c=9;
+ }
+} {10}
+do_test where2-11.3 {
+ execsql {
+ SELECT d FROM t11 WHERE c IN (1,2,3,4,5);
+ }
+} {4}
+do_test where2-11.4 {
+ execsql {
+ SELECT d FROM t11 WHERE c=7 OR (a=1 AND b=2) ORDER BY d;
+ }
+} {4 8 10}
+
+
+finish_test
diff --git a/test/where3.test b/test/where3.test
new file mode 100644
index 0000000..e08f905
--- /dev/null
+++ b/test/where3.test
@@ -0,0 +1,428 @@
+# 2006 January 31
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the join reordering optimization
+# in cases that include a LEFT JOIN.
+#
+# $Id: where3.test,v 1.4 2008/04/17 19:14:02 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# The following is from ticket #1652.
+#
+# A comma join then a left outer join: A,B left join C.
+# Arrange indices so that the B table is chosen to go first.
+# Also put an index on C, but make sure that A is chosen before C.
+#
+do_test where3-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(p, q);
+ CREATE TABLE t3(x, y);
+
+ INSERT INTO t1 VALUES(111,'one');
+ INSERT INTO t1 VALUES(222,'two');
+ INSERT INTO t1 VALUES(333,'three');
+
+ INSERT INTO t2 VALUES(1,111);
+ INSERT INTO t2 VALUES(2,222);
+ INSERT INTO t2 VALUES(4,444);
+ CREATE INDEX t2i1 ON t2(p);
+
+ INSERT INTO t3 VALUES(999,'nine');
+ CREATE INDEX t3i1 ON t3(x);
+
+ SELECT * FROM t1, t2 LEFT JOIN t3 ON q=x WHERE p=2 AND a=q;
+ }
+} {222 two 2 222 {} {}}
+
+ifcapable explain {
+ do_test where3-1.1.1 {
+ explain_no_trace {SELECT * FROM t1, t2 LEFT JOIN t3 ON q=x
+ WHERE p=2 AND a=q}
+ } [explain_no_trace {SELECT * FROM t1, t2 LEFT JOIN t3 ON x=q
+ WHERE p=2 AND a=q}]
+}
+
+# Ticket #1830
+#
+# This is similar to the above but with the LEFT JOIN on the
+# other side.
+#
+do_test where3-1.2 {
+ execsql {
+ CREATE TABLE parent1(parent1key, child1key, Child2key, child3key);
+ CREATE TABLE child1 ( child1key NVARCHAR, value NVARCHAR );
+ CREATE UNIQUE INDEX PKIDXChild1 ON child1 ( child1key );
+ CREATE TABLE child2 ( child2key NVARCHAR, value NVARCHAR );
+
+ INSERT INTO parent1(parent1key,child1key,child2key)
+ VALUES ( 1, 'C1.1', 'C2.1' );
+ INSERT INTO child1 ( child1key, value ) VALUES ( 'C1.1', 'Value for C1.1' );
+ INSERT INTO child2 ( child2key, value ) VALUES ( 'C2.1', 'Value for C2.1' );
+
+ INSERT INTO parent1 ( parent1key, child1key, child2key )
+ VALUES ( 2, 'C1.2', 'C2.2' );
+ INSERT INTO child2 ( child2key, value ) VALUES ( 'C2.2', 'Value for C2.2' );
+
+ INSERT INTO parent1 ( parent1key, child1key, child2key )
+ VALUES ( 3, 'C1.3', 'C2.3' );
+ INSERT INTO child1 ( child1key, value ) VALUES ( 'C1.3', 'Value for C1.3' );
+ INSERT INTO child2 ( child2key, value ) VALUES ( 'C2.3', 'Value for C2.3' );
+
+ SELECT parent1.parent1key, child1.value, child2.value
+ FROM parent1
+ LEFT OUTER JOIN child1 ON child1.child1key = parent1.child1key
+ INNER JOIN child2 ON child2.child2key = parent1.child2key;
+ }
+} {1 {Value for C1.1} {Value for C2.1} 2 {} {Value for C2.2} 3 {Value for C1.3} {Value for C2.3}}
+
+ifcapable explain {
+ do_test where3-1.2.1 {
+ explain_no_trace {
+ SELECT parent1.parent1key, child1.value, child2.value
+ FROM parent1
+ LEFT OUTER JOIN child1 ON child1.child1key = parent1.child1key
+ INNER JOIN child2 ON child2.child2key = parent1.child2key;
+ }
+ } [explain_no_trace {
+ SELECT parent1.parent1key, child1.value, child2.value
+ FROM parent1
+ LEFT OUTER JOIN child1 ON parent1.child1key = child1.child1key
+ INNER JOIN child2 ON child2.child2key = parent1.child2key;
+ }]
+}
+
+# This procedure executes the SQL. Then it appends
+# the ::sqlite_query_plan variable.
+#
+proc queryplan {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ return [concat $data $::sqlite_query_plan]
+}
+
+
+# If you have a from clause of the form: A B C left join D
+# then make sure the query optimizer is able to reorder the
+# A B C part anyway it wants.
+#
+# Following the fix to ticket #1652, there was a time when
+# the C table would not reorder. So the following reorderings
+# were possible:
+#
+# A B C left join D
+# B A C left join D
+#
+# But these reorders were not allowed
+#
+# C A B left join D
+# A C B left join D
+# C B A left join D
+# B C A left join D
+#
+# The following tests are here to verify that the latter four
+# reorderings are allowed again.
+#
+do_test where3-2.1 {
+ execsql {
+ CREATE TABLE tA(apk integer primary key, ax);
+ CREATE TABLE tB(bpk integer primary key, bx);
+ CREATE TABLE tC(cpk integer primary key, cx);
+ CREATE TABLE tD(dpk integer primary key, dx);
+ }
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx
+ WHERE cpk=bx AND bpk=ax
+ }
+} {tA {} tB * tC * tD *}
+do_test where3-2.1.1 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON cx=dpk
+ WHERE cpk=bx AND bpk=ax
+ }
+} {tA {} tB * tC * tD *}
+do_test where3-2.1.2 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON cx=dpk
+ WHERE bx=cpk AND bpk=ax
+ }
+} {tA {} tB * tC * tD *}
+do_test where3-2.1.3 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON cx=dpk
+ WHERE bx=cpk AND ax=bpk
+ }
+} {tA {} tB * tC * tD *}
+do_test where3-2.1.4 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx
+ WHERE bx=cpk AND ax=bpk
+ }
+} {tA {} tB * tC * tD *}
+do_test where3-2.1.5 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx
+ WHERE cpk=bx AND ax=bpk
+ }
+} {tA {} tB * tC * tD *}
+do_test where3-2.2 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx
+ WHERE cpk=bx AND apk=bx
+ }
+} {tB {} tA * tC * tD *}
+do_test where3-2.3 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx
+ WHERE cpk=bx AND apk=bx
+ }
+} {tB {} tA * tC * tD *}
+do_test where3-2.4 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx
+ WHERE apk=cx AND bpk=ax
+ }
+} {tC {} tA * tB * tD *}
+do_test where3-2.5 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx
+ WHERE cpk=ax AND bpk=cx
+ }
+} {tA {} tC * tB * tD *}
+do_test where3-2.6 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx
+ WHERE bpk=cx AND apk=bx
+ }
+} {tC {} tB * tA * tD *}
+do_test where3-2.7 {
+ queryplan {
+ SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx
+ WHERE cpk=bx AND apk=cx
+ }
+} {tB {} tC * tA * tD *}
+
+# Ticket [13f033c865f878953]
+# If the outer loop must be a full table scan, do not let ANALYZE trick
+# the planner into use a table for the outer loop that might be indexable
+# if held until an inner loop.
+#
+do_execsql_test where3-3.0 {
+ CREATE TABLE t301(a INTEGER PRIMARY KEY,b,c);
+ CREATE INDEX t301c ON t301(c);
+ INSERT INTO t301 VALUES(1,2,3);
+ CREATE TABLE t302(x, y);
+ INSERT INTO t302 VALUES(4,5);
+ ANALYZE;
+ explain query plan SELECT * FROM t302, t301 WHERE t302.x=5 AND t301.a=t302.y;
+} {
+ 0 0 0 {SCAN TABLE t302 (~1 rows)}
+ 0 1 1 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+}
+do_execsql_test where3-3.1 {
+ explain query plan
+ SELECT * FROM t301, t302 WHERE t302.x=5 AND t301.a=t302.y;
+} {
+ 0 0 1 {SCAN TABLE t302 (~1 rows)}
+ 0 1 0 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+}
+
+# Verify that when there are multiple tables in a join which must be
+# full table scans that the query planner attempts put the table with
+# the fewest number of output rows as the outer loop.
+#
+do_execsql_test where3-4.0 {
+ CREATE TABLE t400(a INTEGER PRIMARY KEY, b, c);
+ CREATE TABLE t401(p INTEGER PRIMARY KEY, q, r);
+ CREATE TABLE t402(x INTEGER PRIMARY KEY, y, z);
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t400, t401, t402 WHERE t402.z GLOB 'abc*';
+} {
+ 0 0 2 {SCAN TABLE t402 (~500000 rows)}
+ 0 1 0 {SCAN TABLE t400 (~1000000 rows)}
+ 0 2 1 {SCAN TABLE t401 (~1000000 rows)}
+}
+do_execsql_test where3-4.1 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t400, t401, t402 WHERE t401.r GLOB 'abc*';
+} {
+ 0 0 1 {SCAN TABLE t401 (~500000 rows)}
+ 0 1 0 {SCAN TABLE t400 (~1000000 rows)}
+ 0 2 2 {SCAN TABLE t402 (~1000000 rows)}
+}
+do_execsql_test where3-4.2 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t400, t401, t402 WHERE t400.c GLOB 'abc*';
+} {
+ 0 0 0 {SCAN TABLE t400 (~500000 rows)}
+ 0 1 1 {SCAN TABLE t401 (~1000000 rows)}
+ 0 2 2 {SCAN TABLE t402 (~1000000 rows)}
+}
+
+# Verify that a performance regression encountered by firefox
+# has been fixed.
+#
+do_execsql_test where3-5.0 {
+ CREATE TABLE aaa (id INTEGER PRIMARY KEY, type INTEGER,
+ fk INTEGER DEFAULT NULL, parent INTEGER,
+ position INTEGER, title LONGVARCHAR,
+ keyword_id INTEGER, folder_type TEXT,
+ dateAdded INTEGER, lastModified INTEGER);
+ CREATE INDEX aaa_111 ON aaa (fk, type);
+ CREATE INDEX aaa_222 ON aaa (parent, position);
+ CREATE INDEX aaa_333 ON aaa (fk, lastModified);
+ CREATE TABLE bbb (id INTEGER PRIMARY KEY, type INTEGER,
+ fk INTEGER DEFAULT NULL, parent INTEGER,
+ position INTEGER, title LONGVARCHAR,
+ keyword_id INTEGER, folder_type TEXT,
+ dateAdded INTEGER, lastModified INTEGER);
+ CREATE INDEX bbb_111 ON bbb (fk, type);
+ CREATE INDEX bbb_222 ON bbb (parent, position);
+ CREATE INDEX bbb_333 ON bbb (fk, lastModified);
+
+ EXPLAIN QUERY PLAN
+ SELECT bbb.title AS tag_title
+ FROM aaa JOIN bbb ON bbb.id = aaa.parent
+ WHERE aaa.fk = 'constant'
+ AND LENGTH(bbb.title) > 0
+ AND bbb.parent = 4
+ ORDER BY bbb.title COLLATE NOCASE ASC;
+} {
+ 0 0 0 {SEARCH TABLE aaa USING INDEX aaa_333 (fk=?) (~10 rows)}
+ 0 1 1 {SEARCH TABLE bbb USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+do_execsql_test where3-5.1 {
+ EXPLAIN QUERY PLAN
+ SELECT bbb.title AS tag_title
+ FROM aaa JOIN aaa AS bbb ON bbb.id = aaa.parent
+ WHERE aaa.fk = 'constant'
+ AND LENGTH(bbb.title) > 0
+ AND bbb.parent = 4
+ ORDER BY bbb.title COLLATE NOCASE ASC;
+} {
+ 0 0 0 {SEARCH TABLE aaa USING INDEX aaa_333 (fk=?) (~10 rows)}
+ 0 1 1 {SEARCH TABLE aaa AS bbb USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+do_execsql_test where3-5.2 {
+ EXPLAIN QUERY PLAN
+ SELECT bbb.title AS tag_title
+ FROM bbb JOIN aaa ON bbb.id = aaa.parent
+ WHERE aaa.fk = 'constant'
+ AND LENGTH(bbb.title) > 0
+ AND bbb.parent = 4
+ ORDER BY bbb.title COLLATE NOCASE ASC;
+} {
+ 0 0 1 {SEARCH TABLE aaa USING INDEX aaa_333 (fk=?) (~10 rows)}
+ 0 1 0 {SEARCH TABLE bbb USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+do_execsql_test where3-5.3 {
+ EXPLAIN QUERY PLAN
+ SELECT bbb.title AS tag_title
+ FROM aaa AS bbb JOIN aaa ON bbb.id = aaa.parent
+ WHERE aaa.fk = 'constant'
+ AND LENGTH(bbb.title) > 0
+ AND bbb.parent = 4
+ ORDER BY bbb.title COLLATE NOCASE ASC;
+} {
+ 0 0 1 {SEARCH TABLE aaa USING INDEX aaa_333 (fk=?) (~10 rows)}
+ 0 1 0 {SEARCH TABLE aaa AS bbb USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+
+# Name resolution with NATURAL JOIN and USING
+#
+do_test where3-6.setup {
+ db eval {
+ CREATE TABLE t6w(a, w);
+ INSERT INTO t6w VALUES(1, 'w-one');
+ INSERT INTO t6w VALUES(2, 'w-two');
+ INSERT INTO t6w VALUES(9, 'w-nine');
+ CREATE TABLE t6x(a, x);
+ INSERT INTO t6x VALUES(1, 'x-one');
+ INSERT INTO t6x VALUES(3, 'x-three');
+ INSERT INTO t6x VALUES(9, 'x-nine');
+ CREATE TABLE t6y(a, y);
+ INSERT INTO t6y VALUES(1, 'y-one');
+ INSERT INTO t6y VALUES(4, 'y-four');
+ INSERT INTO t6y VALUES(9, 'y-nine');
+ CREATE TABLE t6z(a, z);
+ INSERT INTO t6z VALUES(1, 'z-one');
+ INSERT INTO t6z VALUES(5, 'z-five');
+ INSERT INTO t6z VALUES(9, 'z-nine');
+ }
+} {}
+set cnt 0
+foreach predicate {
+ {}
+ {ORDER BY a}
+ {ORDER BY t6w.a}
+ {WHERE a>0}
+ {WHERE t6y.a>0}
+ {WHERE a>0 ORDER BY a}
+} {
+ incr cnt
+ do_test where3-6.$cnt.1 {
+ set sql "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y"
+ append sql " NATURAL JOIN t6z "
+ append sql $::predicate
+ db eval $sql
+ } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}
+ do_test where3-6.$cnt.2 {
+ set sql "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)"
+ append sql " JOIN t6z USING(a) "
+ append sql $::predicate
+ db eval $sql
+ } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}
+ do_test where3-6.$cnt.3 {
+ set sql "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)"
+ append sql " JOIN t6z USING(a) "
+ append sql $::predicate
+ db eval $sql
+ } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}
+ do_test where3-6.$cnt.4 {
+ set sql "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y"
+ append sql " JOIN t6z USING(a) "
+ append sql $::predicate
+ db eval $sql
+ } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}
+ do_test where3-6.$cnt.5 {
+ set sql "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)"
+ append sql " NATURAL JOIN t6z "
+ append sql $::predicate
+ db eval $sql
+ } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}
+ do_test where3-6.$cnt.6 {
+ set sql "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y"
+ append sql " NATURAL JOIN t6z "
+ append sql $::predicate
+ db eval $sql
+ } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}
+ do_test where3-6.$cnt.7 {
+ set sql "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)"
+ append sql " NATURAL JOIN t6z "
+ append sql $::predicate
+ db eval $sql
+ } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}
+ do_test where3-6.$cnt.8 {
+ set sql "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y"
+ append sql " JOIN t6z USING(a) "
+ append sql $::predicate
+ db eval $sql
+ } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}
+}
+
+
+finish_test
diff --git a/test/where4.test b/test/where4.test
new file mode 100644
index 0000000..280eb5f
--- /dev/null
+++ b/test/where4.test
@@ -0,0 +1,273 @@
+# 2006 October 27
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the use of indices in WHERE clauses.
+# This file was created when support for optimizing IS NULL phrases
+# was added. And so the principle purpose of this file is to test
+# that IS NULL phrases are correctly optimized. But you can never
+# have too many tests, so some other tests are thrown in as well.
+#
+# $Id: where4.test,v 1.6 2007/12/10 05:03:48 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !tclvar||!bloblit {
+ finish_test
+ return
+}
+
+# Build some test data
+#
+do_test where4-1.0 {
+ execsql {
+ CREATE TABLE t1(w, x, y);
+ CREATE INDEX i1wxy ON t1(w,x,y);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(1,NULL,3);
+ INSERT INTO t1 VALUES('a','b','c');
+ INSERT INTO t1 VALUES('a',NULL,'c');
+ INSERT INTO t1 VALUES(X'78',x'79',x'7a');
+ INSERT INTO t1 VALUES(X'78',NULL,X'7A');
+ INSERT INTO t1 VALUES(NULL,NULL,NULL);
+ SELECT count(*) FROM t1;
+ }
+} {7}
+
+# Do an SQL statement. Append the search count to the end of the result.
+#
+proc count sql {
+ set ::sqlite_search_count 0
+ return [concat [execsql $sql] $::sqlite_search_count]
+}
+
+# Verify that queries use an index. We are using the special variable
+# "sqlite_search_count" which tallys the number of executions of MoveTo
+# and Next operators in the VDBE. By verifing that the search count is
+# small we can be assured that indices are being used properly.
+#
+do_test where4-1.1 {
+ count {SELECT rowid FROM t1 WHERE w IS NULL}
+} {7 2}
+do_test where4-1.2 {
+ count {SELECT rowid FROM t1 WHERE +w IS NULL}
+} {7 6}
+do_test where4-1.3 {
+ count {SELECT rowid FROM t1 WHERE w=1 AND x IS NULL}
+} {2 2}
+do_test where4-1.4 {
+ count {SELECT rowid FROM t1 WHERE w=1 AND +x IS NULL}
+} {2 3}
+do_test where4-1.5 {
+ count {SELECT rowid FROM t1 WHERE w=1 AND x>0}
+} {1 2}
+do_test where4-1.6 {
+ count {SELECT rowid FROM t1 WHERE w=1 AND x<9}
+} {1 3}
+do_test where4-1.7 {
+ count {SELECT rowid FROM t1 WHERE w=1 AND x IS NULL AND y=3}
+} {2 2}
+do_test where4-1.8 {
+ count {SELECT rowid FROM t1 WHERE w=1 AND x IS NULL AND y>2}
+} {2 2}
+do_test where4-1.9 {
+ count {SELECT rowid FROM t1 WHERE w='a' AND x IS NULL AND y='c'}
+} {4 2}
+do_test where4-1.10 {
+ count {SELECT rowid FROM t1 WHERE w=x'78' AND x IS NULL}
+} {6 2}
+do_test where4-1.11 {
+ count {SELECT rowid FROM t1 WHERE w=x'78' AND x IS NULL AND y=123}
+} {1}
+do_test where4-1.12 {
+ count {SELECT rowid FROM t1 WHERE w=x'78' AND x IS NULL AND y=x'7A'}
+} {6 2}
+do_test where4-1.13 {
+ count {SELECT rowid FROM t1 WHERE w IS NULL AND x IS NULL}
+} {7 2}
+do_test where4-1.14 {
+ count {SELECT rowid FROM t1 WHERE w IS NULL AND x IS NULL AND y IS NULL}
+} {7 2}
+do_test where4-1.15 {
+ count {SELECT rowid FROM t1 WHERE w IS NULL AND x IS NULL AND y<0}
+} {2}
+do_test where4-1.16 {
+ count {SELECT rowid FROM t1 WHERE w IS NULL AND x IS NULL AND y>=0}
+} {1}
+
+do_test where4-2.1 {
+ execsql {SELECT rowid FROM t1 ORDER BY w, x, y}
+} {7 2 1 4 3 6 5}
+do_test where4-2.2 {
+ execsql {SELECT rowid FROM t1 ORDER BY w DESC, x, y}
+} {6 5 4 3 2 1 7}
+do_test where4-2.3 {
+ execsql {SELECT rowid FROM t1 ORDER BY w, x DESC, y}
+} {7 1 2 3 4 5 6}
+
+
+# Ticket #2177
+#
+# Suppose you have a left join where the right table of the left
+# join (the one that can be NULL) has an index on two columns.
+# The first indexed column is used in the ON clause of the join.
+# The second indexed column is used in the WHERE clause with an IS NULL
+# constraint. It is not allowed to use the IS NULL optimization to
+# optimize the query because the second column might be NULL because
+# the right table did not match - something the index does not know
+# about.
+#
+do_test where4-3.1 {
+ execsql {
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ INSERT INTO t2 VALUES(3);
+ CREATE TABLE t3(x,y,UNIQUE(x,y));
+ INSERT INTO t3 VALUES(1,11);
+ INSERT INTO t3 VALUES(2,NULL);
+
+ SELECT * FROM t2 LEFT JOIN t3 ON a=x WHERE +y IS NULL;
+ }
+} {2 2 {} 3 {} {}}
+do_test where4-3.2 {
+ execsql {
+ SELECT * FROM t2 LEFT JOIN t3 ON a=x WHERE y IS NULL;
+ }
+} {2 2 {} 3 {} {}}
+
+# Ticket #2189. Probably the same bug as #2177.
+#
+do_test where4-4.1 {
+ execsql {
+ CREATE TABLE test(col1 TEXT PRIMARY KEY);
+ INSERT INTO test(col1) values('a');
+ INSERT INTO test(col1) values('b');
+ INSERT INTO test(col1) values('c');
+ CREATE TABLE test2(col1 TEXT PRIMARY KEY);
+ INSERT INTO test2(col1) values('a');
+ INSERT INTO test2(col1) values('b');
+ INSERT INTO test2(col1) values('c');
+ SELECT * FROM test t1 LEFT OUTER JOIN test2 t2 ON t1.col1 = t2.col1
+ WHERE +t2.col1 IS NULL;
+ }
+} {}
+do_test where4-4.2 {
+ execsql {
+ SELECT * FROM test t1 LEFT OUTER JOIN test2 t2 ON t1.col1 = t2.col1
+ WHERE t2.col1 IS NULL;
+ }
+} {}
+do_test where4-4.3 {
+ execsql {
+ SELECT * FROM test t1 LEFT OUTER JOIN test2 t2 ON t1.col1 = t2.col1
+ WHERE +t1.col1 IS NULL;
+ }
+} {}
+do_test where4-4.4 {
+ execsql {
+ SELECT * FROM test t1 LEFT OUTER JOIN test2 t2 ON t1.col1 = t2.col1
+ WHERE t1.col1 IS NULL;
+ }
+} {}
+
+# Ticket #2273. Problems with IN operators and NULLs.
+#
+ifcapable subquery {
+do_test where4-5.1 {
+ execsql {
+ CREATE TABLE t4(x,y,z,PRIMARY KEY(x,y));
+ }
+ execsql {
+ SELECT *
+ FROM t2 LEFT JOIN t4 b1
+ LEFT JOIN t4 b2 ON b2.x=b1.x AND b2.y IN (b1.y);
+ }
+} {1 {} {} {} {} {} {} 2 {} {} {} {} {} {} 3 {} {} {} {} {} {}}
+do_test where4-5.2 {
+ execsql {
+ INSERT INTO t4 VALUES(1,1,11);
+ INSERT INTO t4 VALUES(1,2,12);
+ INSERT INTO t4 VALUES(1,3,13);
+ INSERT INTO t4 VALUES(2,2,22);
+ SELECT rowid FROM t4 WHERE x IN (1,9,2,5) AND y IN (1,3,NULL,2) AND z!=13;
+ }
+} {1 2 4}
+do_test where4-5.3 {
+ execsql {
+ SELECT rowid FROM t4 WHERE x IN (1,9,NULL,2) AND y IN (1,3,2) AND z!=13;
+ }
+} {1 2 4}
+do_test where4-6.1 {
+ execsql {
+ CREATE TABLE t5(a,b,c,d,e,f,UNIQUE(a,b,c,d,e,f));
+ INSERT INTO t5 VALUES(1,1,1,1,1,11111);
+ INSERT INTO t5 VALUES(2,2,2,2,2,22222);
+ INSERT INTO t5 VALUES(1,2,3,4,5,12345);
+ INSERT INTO t5 VALUES(2,3,4,5,6,23456);
+ }
+ execsql {
+ SELECT rowid FROM t5
+ WHERE a IN (1,9,2) AND b=2 AND c IN (1,2,3,4) AND d>0
+ }
+} {3 2}
+do_test where4-6.2 {
+ execsql {
+ SELECT rowid FROM t5
+ WHERE a IN (1,NULL,2) AND b=2 AND c IN (1,2,3,4) AND d>0
+ }
+} {3 2}
+do_test where4-7.1 {
+ execsql {
+ CREATE TABLE t6(y,z,PRIMARY KEY(y,z));
+ }
+ execsql {
+ SELECT * FROM t6 WHERE y=NULL AND z IN ('hello');
+ }
+} {}
+
+integrity_check {where4-99.0}
+
+do_test where4-7.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t8(a, b, c, d);
+ CREATE INDEX t8_i ON t8(a, b, c);
+ CREATE TABLE t7(i);
+
+ INSERT INTO t7 VALUES(1);
+ INSERT INTO t7 SELECT i*2 FROM t7;
+ INSERT INTO t7 SELECT i*2 FROM t7;
+ INSERT INTO t7 SELECT i*2 FROM t7;
+ INSERT INTO t7 SELECT i*2 FROM t7;
+ INSERT INTO t7 SELECT i*2 FROM t7;
+ INSERT INTO t7 SELECT i*2 FROM t7;
+
+ COMMIT;
+ }
+} {}
+
+# At one point the sub-select inside the aggregate sum() function in the
+# following query was leaking a couple of stack entries. This query
+# runs the SELECT in a loop enough times that an assert() fails. Or rather,
+# did fail before the bug was fixed.
+#
+do_test where4-7.2 {
+ execsql {
+ SELECT sum((
+ SELECT d FROM t8 WHERE a = i AND b = i AND c < NULL
+ )) FROM t7;
+ }
+} {{}}
+
+}; #ifcapable subquery
+
+finish_test
diff --git a/test/where5.test b/test/where5.test
new file mode 100644
index 0000000..760224c
--- /dev/null
+++ b/test/where5.test
@@ -0,0 +1,288 @@
+# 2007 June 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing NULL comparisons in the WHERE clause.
+# See ticket #2404.
+#
+# $Id: where5.test,v 1.2 2007/06/08 08:43:10 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+do_test where5-1.0 {
+ execsql {
+ CREATE TABLE t1(x TEXT);
+ CREATE TABLE t2(x INTEGER);
+ CREATE TABLE t3(x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(-1);
+ INSERT INTO t1 VALUES(0);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t2 SELECT * FROM t1;
+ INSERT INTO t3 SELECT * FROM t2;
+ }
+ execsql {
+ SELECT * FROM t1 WHERE x<0
+ }
+} {-1}
+do_test where5-1.1 {
+ execsql {
+ SELECT * FROM t1 WHERE x<=0
+ }
+} {-1 0}
+do_test where5-1.2 {
+ execsql {
+ SELECT * FROM t1 WHERE x=0
+ }
+} {0}
+do_test where5-1.3 {
+ execsql {
+ SELECT * FROM t1 WHERE x>=0
+ }
+} {0 1}
+do_test where5-1.4 {
+ execsql {
+ SELECT * FROM t1 WHERE x>0
+ }
+} {1}
+do_test where5-1.5 {
+ execsql {
+ SELECT * FROM t1 WHERE x<>0
+ }
+} {-1 1}
+do_test where5-1.6 {
+ execsql {
+ SELECT * FROM t1 WHERE x<NULL
+ }
+} {}
+do_test where5-1.7 {
+ execsql {
+ SELECT * FROM t1 WHERE x<=NULL
+ }
+} {}
+do_test where5-1.8 {
+ execsql {
+ SELECT * FROM t1 WHERE x=NULL
+ }
+} {}
+do_test where5-1.9 {
+ execsql {
+ SELECT * FROM t1 WHERE x>=NULL
+ }
+} {}
+do_test where5-1.10 {
+ execsql {
+ SELECT * FROM t1 WHERE x>NULL
+ }
+} {}
+do_test where5-1.11 {
+ execsql {
+ SELECT * FROM t1 WHERE x!=NULL
+ }
+} {}
+do_test where5-1.12 {
+ execsql {
+ SELECT * FROM t1 WHERE x IS NULL
+ }
+} {}
+do_test where5-1.13 {
+ execsql {
+ SELECT * FROM t1 WHERE x IS NOT NULL
+ }
+} {-1 0 1}
+
+
+do_test where5-2.0 {
+ execsql {
+ SELECT * FROM t2 WHERE x<0
+ }
+} {-1}
+do_test where5-2.1 {
+ execsql {
+ SELECT * FROM t2 WHERE x<=0
+ }
+} {-1 0}
+do_test where5-2.2 {
+ execsql {
+ SELECT * FROM t2 WHERE x=0
+ }
+} {0}
+do_test where5-2.3 {
+ execsql {
+ SELECT * FROM t2 WHERE x>=0
+ }
+} {0 1}
+do_test where5-2.4 {
+ execsql {
+ SELECT * FROM t2 WHERE x>0
+ }
+} {1}
+do_test where5-2.5 {
+ execsql {
+ SELECT * FROM t2 WHERE x<>0
+ }
+} {-1 1}
+do_test where5-2.6 {
+ execsql {
+ SELECT * FROM t2 WHERE x<NULL
+ }
+} {}
+do_test where5-2.7 {
+ execsql {
+ SELECT * FROM t2 WHERE x<=NULL
+ }
+} {}
+do_test where5-2.8 {
+ execsql {
+ SELECT * FROM t2 WHERE x=NULL
+ }
+} {}
+do_test where5-2.9 {
+ execsql {
+ SELECT * FROM t2 WHERE x>=NULL
+ }
+} {}
+do_test where5-2.10 {
+ execsql {
+ SELECT * FROM t2 WHERE x>NULL
+ }
+} {}
+do_test where5-2.11 {
+ execsql {
+ SELECT * FROM t2 WHERE x!=NULL
+ }
+} {}
+do_test where5-2.12 {
+ execsql {
+ SELECT * FROM t2 WHERE x IS NULL
+ }
+} {}
+do_test where5-2.13 {
+ execsql {
+ SELECT * FROM t2 WHERE x IS NOT NULL
+ }
+} {-1 0 1}
+
+
+do_test where5-3.0 {
+ execsql {
+ SELECT * FROM t3 WHERE x<0
+ }
+} {-1}
+do_test where5-3.1 {
+ execsql {
+ SELECT * FROM t3 WHERE x<=0
+ }
+} {-1 0}
+do_test where5-3.2 {
+ execsql {
+ SELECT * FROM t3 WHERE x=0
+ }
+} {0}
+do_test where5-3.3 {
+ execsql {
+ SELECT * FROM t3 WHERE x>=0
+ }
+} {0 1}
+do_test where5-3.4 {
+ execsql {
+ SELECT * FROM t3 WHERE x>0
+ }
+} {1}
+do_test where5-3.5 {
+ execsql {
+ SELECT * FROM t3 WHERE x<>0
+ }
+} {-1 1}
+do_test where5-3.6 {
+ execsql {
+ SELECT * FROM t3 WHERE x<NULL
+ }
+} {}
+do_test where5-3.7 {
+ execsql {
+ SELECT * FROM t3 WHERE x<=NULL
+ }
+} {}
+do_test where5-3.8 {
+ execsql {
+ SELECT * FROM t3 WHERE x=NULL
+ }
+} {}
+do_test where5-3.9 {
+ execsql {
+ SELECT * FROM t3 WHERE x>=NULL
+ }
+} {}
+do_test where5-3.10 {
+ execsql {
+ SELECT * FROM t3 WHERE x>NULL
+ }
+} {}
+do_test where5-3.11 {
+ execsql {
+ SELECT * FROM t3 WHERE x!=NULL
+ }
+} {}
+do_test where5-3.12 {
+ execsql {
+ SELECT * FROM t3 WHERE x IS NULL
+ }
+} {}
+do_test where5-3.13 {
+ execsql {
+ SELECT * FROM t3 WHERE x IS NOT NULL
+ }
+} {-1 0 1}
+
+do_test where5-4.0 {
+ execsql {
+ SELECT x<NULL FROM t3
+ }
+} {{} {} {}}
+do_test where5-4.1 {
+ execsql {
+ SELECT x<=NULL FROM t3
+ }
+} {{} {} {}}
+do_test where5-4.2 {
+ execsql {
+ SELECT x==NULL FROM t3
+ }
+} {{} {} {}}
+do_test where5-4.3 {
+ execsql {
+ SELECT x>NULL FROM t3
+ }
+} {{} {} {}}
+do_test where5-4.4 {
+ execsql {
+ SELECT x>=NULL FROM t3
+ }
+} {{} {} {}}
+do_test where5-4.5 {
+ execsql {
+ SELECT x!=NULL FROM t3
+ }
+} {{} {} {}}
+do_test where5-4.6 {
+ execsql {
+ SELECT x IS NULL FROM t3
+ }
+} {0 0 0}
+do_test where5-4.7 {
+ execsql {
+ SELECT x IS NOT NULL FROM t3
+ }
+} {1 1 1}
+
+finish_test
diff --git a/test/where6.test b/test/where6.test
new file mode 100644
index 0000000..83e975b
--- /dev/null
+++ b/test/where6.test
@@ -0,0 +1,154 @@
+# 2007 June 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that terms in the ON clause of
+# a LEFT OUTER JOIN are not used with indices. See ticket #3015.
+#
+# $Id: where6.test,v 1.2 2008/04/17 19:14:02 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+do_test where6-1.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c);
+ INSERT INTO t1 VALUES(1,3,1);
+ INSERT INTO t1 VALUES(2,4,2);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY);
+ INSERT INTO t2 VALUES(3);
+
+ SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1;
+ }
+} {1 3 1 3 2 4 2 {}}
+do_test where6-1.2 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON x=b AND c=1;
+ }
+} {1 3 1 3 2 4 2 {}}
+do_test where6-1.3 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c;
+ }
+} {1 3 1 3 2 4 2 {}}
+do_test where6-1.4 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON b=x AND 1=c;
+ }
+} {1 3 1 3 2 4 2 {}}
+
+ifcapable explain {
+ do_test where6-1.5 {
+ explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c}
+ } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1}]
+ do_test where6-1.6 {
+ explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c}
+ } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1}]
+}
+
+do_test where6-1.11 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1;
+ }
+} {1 3 1 3}
+do_test where6-1.12 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE c=1;
+ }
+} {1 3 1 3}
+do_test where6-1.13 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE 1=c;
+ }
+} {1 3 1 3}
+
+
+
+do_test where6-2.1 {
+ execsql {
+ CREATE INDEX i1 ON t1(c);
+
+ SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1;
+ }
+} {1 3 1 3 2 4 2 {}}
+do_test where6-2.2 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON x=b AND c=1;
+ }
+} {1 3 1 3 2 4 2 {}}
+do_test where6-2.3 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c;
+ }
+} {1 3 1 3 2 4 2 {}}
+do_test where6-2.4 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON b=x AND 1=c;
+ }
+} {1 3 1 3 2 4 2 {}}
+
+ifcapable explain {
+ do_test where6-2.5 {
+ explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c}
+ } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1}]
+ do_test where6-2.6 {
+ explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c}
+ } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1}]
+}
+
+
+do_test where6-2.11 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1;
+ }
+} {1 3 1 3}
+do_test where6-2.12 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE c=1;
+ }
+} {1 3 1 3}
+do_test where6-2.13 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c;
+ }
+} {1 3 1 3}
+do_test where6-2.14 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE 1=c;
+ }
+} {1 3 1 3}
+
+# Ticket [ebdbadade5b]:
+# If the ON close on a LEFT JOIN is of the form x=y where both x and y
+# are indexed columns on tables to left of the join, then do not use that
+# term with indices to either table.
+#
+do_test where6-3.1 {
+ db eval {
+ CREATE TABLE t4(x UNIQUE);
+ INSERT INTO t4 VALUES('abc');
+ INSERT INTO t4 VALUES('def');
+ INSERT INTO t4 VALUES('ghi');
+ CREATE TABLE t5(a, b, c, PRIMARY KEY(a,b));
+ INSERT INTO t5 VALUES('abc','def',123);
+ INSERT INTO t5 VALUES('def','ghi',456);
+
+ SELECT t4a.x, t4b.x, t5.c, t6.v
+ FROM t4 AS t4a
+ INNER JOIN t4 AS t4b
+ LEFT JOIN t5 ON t5.a=t4a.x AND t5.b=t4b.x
+ LEFT JOIN (SELECT 1 AS v) AS t6 ON t4a.x=t4b.x
+ ORDER BY 1, 2, 3;
+ }
+} {abc abc {} 1 abc def 123 {} abc ghi {} {} def abc {} {} def def {} 1 def ghi 456 {} ghi abc {} {} ghi def {} {} ghi ghi {} 1}
+
+finish_test
diff --git a/test/where7.test b/test/where7.test
new file mode 100644
index 0000000..ffb7173
--- /dev/null
+++ b/test/where7.test
@@ -0,0 +1,23348 @@
+# 2008 December 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the multi-index OR clause optimizer.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !or_opt {
+ finish_test
+ return
+}
+
+# Evaluate SQL. Return the result set followed by the
+# and the number of full-scan steps.
+#
+proc count_steps {sql} {
+ set r [db eval $sql]
+ lappend r scan [db status step] sort [db status sort]
+}
+
+proc count_steps_sort {sql} {
+ set r [lsort -integer [db eval $sql]]
+ return "$r scan [db status step] sort [db status sort]"
+}
+
+# Build some test data
+#
+do_test where7-1.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d);
+ INSERT INTO t1 VALUES(1,2,3,4);
+ INSERT INTO t1 VALUES(2,3,4,5);
+ INSERT INTO t1 VALUES(3,4,6,8);
+ INSERT INTO t1 VALUES(4,5,10,15);
+ INSERT INTO t1 VALUES(5,10,100,1000);
+ CREATE INDEX t1b ON t1(b);
+ CREATE INDEX t1c ON t1(c);
+ SELECT * FROM t1;
+ }
+} {1 2 3 4 2 3 4 5 3 4 6 8 4 5 10 15 5 10 100 1000}
+do_test where7-1.2 {
+ count_steps {
+ SELECT a FROM t1 WHERE b=3 OR c=6 ORDER BY a
+ }
+} {2 3 scan 0 sort 1}
+do_test where7-1.3 {
+ count_steps {
+ SELECT a FROM t1 WHERE b=3 OR +c=6 ORDER BY a
+ }
+} {2 3 scan 4 sort 0}
+do_test where7-1.4 {
+ count_steps {
+ SELECT a FROM t1 WHERE +b=3 OR c=6 ORDER BY 1
+ }
+} {2 3 scan 4 sort 0}
+do_test where7-1.5 {
+ count_steps {
+ SELECT a FROM t1 WHERE 3=b OR c=6 ORDER BY rowid
+ }
+} {2 3 scan 0 sort 1}
+do_test where7-1.6 {
+ count_steps {
+ SELECT a FROM t1 WHERE (3=b OR c=6) AND +a>0 ORDER BY a
+ }
+} {2 3 scan 0 sort 1}
+do_test where7-1.7 {
+ count_steps {
+ SELECT a FROM t1 WHERE (b=3 OR c>10)
+ }
+} {2 5 scan 0 sort 0}
+do_test where7-1.8 {
+ count_steps {
+ SELECT a FROM t1 WHERE (b=3 OR c>=10)
+ }
+} {2 4 5 scan 0 sort 0}
+do_test where7-1.9 {
+ count_steps {
+ SELECT a FROM t1 WHERE (b=3 OR c>=10 OR c=4)
+ }
+} {2 4 5 scan 0 sort 0}
+do_test where7-1.10 {
+ count_steps {
+ SELECT a FROM t1 WHERE (b=3 OR c>=10 OR c=4 OR b>10)
+ }
+} {2 4 5 scan 0 sort 0}
+do_test where7-1.11 {
+ count_steps {
+ SELECT a FROM t1 WHERE (d=5 AND b=3) OR c==100 ORDER BY a;
+ }
+} {2 5 scan 0 sort 1}
+do_test where7-1.12 {
+ count_steps {
+ SELECT a FROM t1 WHERE (b BETWEEN 2 AND 4) OR c=100 ORDER BY a
+ }
+} {1 2 3 5 scan 0 sort 1}
+do_test where7-1.13 {
+ count_steps {
+ SELECT a FROM t1 WHERE (b BETWEEN 0 AND 2) OR (c BETWEEN 9 AND 999)
+ ORDER BY +a DESC
+ }
+} {5 4 1 scan 0 sort 1}
+
+do_test where7-1.14 {
+ count_steps {
+ SELECT a FROM t1 WHERE (d=8 OR c=6 OR b=4) AND +a>0
+ }
+} {3 scan 4 sort 0}
+do_test where7-1.15 {
+ count_steps {
+ SELECT a FROM t1 WHERE +a>=0 AND (d=8 OR c=6 OR b=4)
+ }
+} {3 scan 4 sort 0}
+
+do_test where7-1.20 {
+ set sql "SELECT a FROM t1 WHERE a=11 OR b=11"
+ for {set i 12} {$i<400} {incr i} {
+ append sql " OR a=$i OR b=$i"
+ }
+ append sql " ORDER BY a"
+ count_steps $sql
+} {scan 0 sort 1}
+do_test where7-1.21 {
+ set sql "SELECT a FROM t1 WHERE b=11 OR c=11"
+ for {set i 12} {$i<400} {incr i} {
+ append sql " OR b=$i OR c=$i"
+ }
+ append sql " ORDER BY a"
+ count_steps $sql
+} {5 scan 0 sort 1}
+do_test where7-1.22 {
+ set sql "SELECT a FROM t1 WHERE (b=11 OR c=11"
+ for {set i 12} {$i<400} {incr i} {
+ append sql " OR b=$i OR c=$i"
+ }
+ append sql ") AND d>=0 AND d<9999 ORDER BY a"
+ count_steps $sql
+} {5 scan 0 sort 1}
+do_test where7-1.23 {
+ set sql "SELECT a FROM t1 WHERE (b=11 OR c=11"
+ for {set i 12} {$i<400} {incr i} {
+ append sql " OR (b=$i AND d!=0) OR (c=$i AND d IS NOT NULL)"
+ }
+ append sql ") AND d>=0 AND d<9999 ORDER BY a"
+ count_steps $sql
+} {5 scan 0 sort 1}
+
+do_test where7-1.31 {
+ set sql "SELECT a FROM t1 WHERE (a=11 AND b=11)"
+ for {set i 12} {$i<400} {incr i} {
+ append sql " OR (a=$i AND b=$i)"
+ }
+ append sql " ORDER BY a"
+ count_steps $sql
+} {scan 0 sort 1}
+do_test where7-1.32 {
+ set sql "SELECT a FROM t1 WHERE (b=11 AND c=11)"
+ for {set i 12} {$i<400} {incr i} {
+ append sql " OR (b=$i AND c=$i)"
+ }
+ append sql " ORDER BY a"
+ count_steps $sql
+} {scan 0 sort 1}
+
+
+do_test where7-2.1 {
+ db eval {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY,b,c,d,e,f TEXT,g);
+ INSERT INTO t2 VALUES(1,11,1001,1.001,100.1,'bcdefghij','yxwvuts');
+ INSERT INTO t2 VALUES(2,22,1001,2.002,100.1,'cdefghijk','yxwvuts');
+ INSERT INTO t2 VALUES(3,33,1001,3.0029999999999997,100.1,'defghijkl','xwvutsr');
+ INSERT INTO t2 VALUES(4,44,2002,4.004,200.2,'efghijklm','xwvutsr');
+ INSERT INTO t2 VALUES(5,55,2002,5.004999999999999,200.2,'fghijklmn','xwvutsr');
+ INSERT INTO t2 VALUES(6,66,2002,6.005999999999999,200.2,'ghijklmno','xwvutsr');
+ INSERT INTO t2 VALUES(7,77,3003,7.007,300.29999999999995,'hijklmnop','xwvutsr');
+ INSERT INTO t2 VALUES(8,88,3003,8.008,300.29999999999995,'ijklmnopq','wvutsrq');
+ INSERT INTO t2 VALUES(9,99,3003,9.008999999999999,300.29999999999995,'jklmnopqr','wvutsrq');
+ INSERT INTO t2 VALUES(10,110,4004,10.009999999999998,400.4,'klmnopqrs','wvutsrq');
+ INSERT INTO t2 VALUES(11,121,4004,11.011,400.4,'lmnopqrst','wvutsrq');
+ INSERT INTO t2 VALUES(12,132,4004,12.011999999999999,400.4,'mnopqrstu','wvutsrq');
+ INSERT INTO t2 VALUES(13,143,5005,13.012999999999998,500.5,'nopqrstuv','vutsrqp');
+ INSERT INTO t2 VALUES(14,154,5005,14.014,500.5,'opqrstuvw','vutsrqp');
+ INSERT INTO t2 VALUES(15,165,5005,15.014999999999999,500.5,'pqrstuvwx','vutsrqp');
+ INSERT INTO t2 VALUES(16,176,6006,16.016,600.5999999999999,'qrstuvwxy','vutsrqp');
+ INSERT INTO t2 VALUES(17,187,6006,17.017,600.5999999999999,'rstuvwxyz','vutsrqp');
+ INSERT INTO t2 VALUES(18,198,6006,18.017999999999997,600.5999999999999,'stuvwxyza','utsrqpo');
+ INSERT INTO t2 VALUES(19,209,7007,19.019,700.6999999999999,'tuvwxyzab','utsrqpo');
+ INSERT INTO t2 VALUES(20,220,7007,20.019999999999996,700.6999999999999,'uvwxyzabc','utsrqpo');
+ INSERT INTO t2 VALUES(21,231,7007,21.020999999999997,700.6999999999999,'vwxyzabcd','utsrqpo');
+ INSERT INTO t2 VALUES(22,242,8008,22.022,800.8,'wxyzabcde','utsrqpo');
+ INSERT INTO t2 VALUES(23,253,8008,23.022999999999996,800.8,'xyzabcdef','tsrqpon');
+ INSERT INTO t2 VALUES(24,264,8008,24.023999999999997,800.8,'yzabcdefg','tsrqpon');
+ INSERT INTO t2 VALUES(25,275,9009,25.025,900.9,'zabcdefgh','tsrqpon');
+ INSERT INTO t2 VALUES(26,286,9009,26.025999999999996,900.9,'abcdefghi','tsrqpon');
+ INSERT INTO t2 VALUES(27,297,9009,27.026999999999997,900.9,'bcdefghij','tsrqpon');
+ INSERT INTO t2 VALUES(28,308,10010,28.028,1001.0,'cdefghijk','srqponm');
+ INSERT INTO t2 VALUES(29,319,10010,29.028999999999996,1001.0,'defghijkl','srqponm');
+ INSERT INTO t2 VALUES(30,330,10010,30.029999999999998,1001.0,'efghijklm','srqponm');
+ INSERT INTO t2 VALUES(31,341,11011,31.030999999999995,1101.1,'fghijklmn','srqponm');
+ INSERT INTO t2 VALUES(32,352,11011,32.032,1101.1,'ghijklmno','srqponm');
+ INSERT INTO t2 VALUES(33,363,11011,33.032999999999994,1101.1,'hijklmnop','rqponml');
+ INSERT INTO t2 VALUES(34,374,12012,34.034,1201.1999999999998,'ijklmnopq','rqponml');
+ INSERT INTO t2 VALUES(35,385,12012,35.035,1201.1999999999998,'jklmnopqr','rqponml');
+ INSERT INTO t2 VALUES(36,396,12012,36.035999999999994,1201.1999999999998,'klmnopqrs','rqponml');
+ INSERT INTO t2 VALUES(37,407,13013,37.037,1301.3,'lmnopqrst','rqponml');
+ INSERT INTO t2 VALUES(38,418,13013,38.038,1301.3,'mnopqrstu','qponmlk');
+ INSERT INTO t2 VALUES(39,429,13013,39.038999999999994,1301.3,'nopqrstuv','qponmlk');
+ INSERT INTO t2 VALUES(40,440,14014,40.03999999999999,1401.3999999999999,'opqrstuvw','qponmlk');
+ INSERT INTO t2 VALUES(41,451,14014,41.041,1401.3999999999999,'pqrstuvwx','qponmlk');
+ INSERT INTO t2 VALUES(42,462,14014,42.041999999999994,1401.3999999999999,'qrstuvwxy','qponmlk');
+ INSERT INTO t2 VALUES(43,473,15015,43.04299999999999,1501.5,'rstuvwxyz','ponmlkj');
+ INSERT INTO t2 VALUES(44,484,15015,44.044,1501.5,'stuvwxyza','ponmlkj');
+ INSERT INTO t2 VALUES(45,495,15015,45.044999999999995,1501.5,'tuvwxyzab','ponmlkj');
+ INSERT INTO t2 VALUES(46,506,16016,46.04599999999999,1601.6,'uvwxyzabc','ponmlkj');
+ INSERT INTO t2 VALUES(47,517,16016,47.047,1601.6,'vwxyzabcd','ponmlkj');
+ INSERT INTO t2 VALUES(48,528,16016,48.047999999999995,1601.6,'wxyzabcde','onmlkji');
+ INSERT INTO t2 VALUES(49,539,17017,49.04899999999999,1701.6999999999998,'xyzabcdef','onmlkji');
+ INSERT INTO t2 VALUES(50,550,17017,50.05,1701.6999999999998,'yzabcdefg','onmlkji');
+ INSERT INTO t2 VALUES(51,561,17017,51.050999999999995,1701.6999999999998,'zabcdefgh','onmlkji');
+ INSERT INTO t2 VALUES(52,572,18018,52.05199999999999,1801.8,'abcdefghi','onmlkji');
+ INSERT INTO t2 VALUES(53,583,18018,53.053,1801.8,'bcdefghij','nmlkjih');
+ INSERT INTO t2 VALUES(54,594,18018,54.053999999999995,1801.8,'cdefghijk','nmlkjih');
+ INSERT INTO t2 VALUES(55,605,19019,55.05499999999999,1901.8999999999999,'defghijkl','nmlkjih');
+ INSERT INTO t2 VALUES(56,616,19019,56.056,1901.8999999999999,'efghijklm','nmlkjih');
+ INSERT INTO t2 VALUES(57,627,19019,57.056999999999995,1901.8999999999999,'fghijklmn','nmlkjih');
+ INSERT INTO t2 VALUES(58,638,20020,58.05799999999999,2002.0,'ghijklmno','mlkjihg');
+ INSERT INTO t2 VALUES(59,649,20020,59.05899999999999,2002.0,'hijklmnop','mlkjihg');
+ INSERT INTO t2 VALUES(60,660,20020,60.059999999999995,2002.0,'ijklmnopq','mlkjihg');
+ INSERT INTO t2 VALUES(61,671,21021,61.06099999999999,2102.1,'jklmnopqr','mlkjihg');
+ INSERT INTO t2 VALUES(62,682,21021,62.06199999999999,2102.1,'klmnopqrs','mlkjihg');
+ INSERT INTO t2 VALUES(63,693,21021,63.062999999999995,2102.1,'lmnopqrst','lkjihgf');
+ INSERT INTO t2 VALUES(64,704,22022,64.064,2202.2,'mnopqrstu','lkjihgf');
+ INSERT INTO t2 VALUES(65,715,22022,65.065,2202.2,'nopqrstuv','lkjihgf');
+ INSERT INTO t2 VALUES(66,726,22022,66.06599999999999,2202.2,'opqrstuvw','lkjihgf');
+ INSERT INTO t2 VALUES(67,737,23023,67.067,2302.2999999999997,'pqrstuvwx','lkjihgf');
+ INSERT INTO t2 VALUES(68,748,23023,68.068,2302.2999999999997,'qrstuvwxy','kjihgfe');
+ INSERT INTO t2 VALUES(69,759,23023,69.06899999999999,2302.2999999999997,'rstuvwxyz','kjihgfe');
+ INSERT INTO t2 VALUES(70,770,24024,70.07,2402.3999999999996,'stuvwxyza','kjihgfe');
+ INSERT INTO t2 VALUES(71,781,24024,71.071,2402.3999999999996,'tuvwxyzab','kjihgfe');
+ INSERT INTO t2 VALUES(72,792,24024,72.07199999999999,2402.3999999999996,'uvwxyzabc','kjihgfe');
+ INSERT INTO t2 VALUES(73,803,25025,73.073,2502.5,'vwxyzabcd','jihgfed');
+ INSERT INTO t2 VALUES(74,814,25025,74.074,2502.5,'wxyzabcde','jihgfed');
+ INSERT INTO t2 VALUES(75,825,25025,75.07499999999999,2502.5,'xyzabcdef','jihgfed');
+ INSERT INTO t2 VALUES(76,836,26026,76.076,2602.6,'yzabcdefg','jihgfed');
+ INSERT INTO t2 VALUES(77,847,26026,77.077,2602.6,'zabcdefgh','jihgfed');
+ INSERT INTO t2 VALUES(78,858,26026,78.07799999999999,2602.6,'abcdefghi','ihgfedc');
+ INSERT INTO t2 VALUES(79,869,27027,79.079,2702.7,'bcdefghij','ihgfedc');
+ INSERT INTO t2 VALUES(80,880,27027,80.07999999999998,2702.7,'cdefghijk','ihgfedc');
+ INSERT INTO t2 VALUES(81,891,27027,81.08099999999999,2702.7,'defghijkl','ihgfedc');
+ INSERT INTO t2 VALUES(82,902,28028,82.082,2802.7999999999997,'efghijklm','ihgfedc');
+ INSERT INTO t2 VALUES(83,913,28028,83.08299999999998,2802.7999999999997,'fghijklmn','hgfedcb');
+ INSERT INTO t2 VALUES(84,924,28028,84.08399999999999,2802.7999999999997,'ghijklmno','hgfedcb');
+ INSERT INTO t2 VALUES(85,935,29029,85.085,2902.8999999999996,'hijklmnop','hgfedcb');
+ INSERT INTO t2 VALUES(86,946,29029,86.08599999999998,2902.8999999999996,'ijklmnopq','hgfedcb');
+ INSERT INTO t2 VALUES(87,957,29029,87.08699999999999,2902.8999999999996,'jklmnopqr','hgfedcb');
+ INSERT INTO t2 VALUES(88,968,30030,88.088,3003.0,'klmnopqrs','gfedcba');
+ INSERT INTO t2 VALUES(89,979,30030,89.08899999999998,3003.0,'lmnopqrst','gfedcba');
+ INSERT INTO t2 VALUES(90,990,30030,90.08999999999999,3003.0,'mnopqrstu','gfedcba');
+ INSERT INTO t2 VALUES(91,1001,31031,91.091,3103.1,'nopqrstuv','gfedcba');
+ INSERT INTO t2 VALUES(92,1012,31031,92.09199999999998,3103.1,'opqrstuvw','gfedcba');
+ INSERT INTO t2 VALUES(93,1023,31031,93.09299999999999,3103.1,'pqrstuvwx','fedcbaz');
+ INSERT INTO t2 VALUES(94,1034,32032,94.094,3203.2,'qrstuvwxy','fedcbaz');
+ INSERT INTO t2 VALUES(95,1045,32032,95.09499999999998,3203.2,'rstuvwxyz','fedcbaz');
+ INSERT INTO t2 VALUES(96,1056,32032,96.09599999999999,3203.2,'stuvwxyza','fedcbaz');
+ INSERT INTO t2 VALUES(97,1067,33033,97.097,3303.2999999999997,'tuvwxyzab','fedcbaz');
+ INSERT INTO t2 VALUES(98,1078,33033,98.09799999999998,3303.2999999999997,'uvwxyzabc','edcbazy');
+ INSERT INTO t2 VALUES(99,1089,33033,99.09899999999999,3303.2999999999997,'vwxyzabcd','edcbazy');
+ INSERT INTO t2 VALUES(100,1100,34034,100.1,3403.3999999999996,'wxyzabcde','edcbazy');
+ CREATE INDEX t2b ON t2(b);
+ CREATE INDEX t2c ON t2(c);
+ CREATE INDEX t2d ON t2(d);
+ CREATE INDEX t2e ON t2(e);
+ CREATE INDEX t2f ON t2(f);
+ CREATE INDEX t2g ON t2(g);
+ CREATE TABLE t3(a INTEGER PRIMARY KEY,b,c,d,e,f TEXT,g);
+ INSERT INTO t3 SELECT * FROM t2;
+ CREATE INDEX t3b ON t3(b,c);
+ CREATE INDEX t3c ON t3(c,e);
+ CREATE INDEX t3d ON t3(d,g);
+ CREATE INDEX t3e ON t3(e,f,g);
+ CREATE INDEX t3f ON t3(f,b,d,c);
+ CREATE INDEX t3g ON t3(g,f);
+ }
+} {}
+
+do_test where7-2.2.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1070
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ }
+} {6 18 20 32 39 58 84 89 96 100 scan 0 sort 0}
+do_test where7-2.2.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1070
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ }
+} {6 18 20 32 39 58 84 89 96 100 scan 0 sort 0}
+do_test where7-2.3.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR b=220
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ }
+} {20 33 35 41 47 67 69 70 98 scan 0 sort 0}
+do_test where7-2.3.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR b=220
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ }
+} {20 33 35 41 47 67 69 70 98 scan 0 sort 0}
+do_test where7-2.4.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=190
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ OR b=407
+ }
+} {33 37 49 51 scan 0 sort 0}
+do_test where7-2.4.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=190
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ OR b=407
+ }
+} {33 37 49 51 scan 0 sort 0}
+do_test where7-2.5.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR b=795
+ OR b=1103
+ OR b=583
+ }
+} {13 39 53 65 91 scan 0 sort 0}
+do_test where7-2.5.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR b=795
+ OR b=1103
+ OR b=583
+ }
+} {13 39 53 65 91 scan 0 sort 0}
+do_test where7-2.6.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=74
+ OR a=50
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ OR c=21021
+ OR ((a BETWEEN 82 AND 84) AND a!=83)
+ }
+} {16 18 50 61 62 63 74 82 84 85 scan 0 sort 0}
+do_test where7-2.6.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=74
+ OR a=50
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ OR c=21021
+ OR ((a BETWEEN 82 AND 84) AND a!=83)
+ }
+} {16 18 50 61 62 63 74 82 84 85 scan 0 sort 0}
+do_test where7-2.7.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 8 AND 10) AND a!=9)
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ OR c=14014
+ OR b=828
+ }
+} {8 10 34 36 40 41 42 94 scan 0 sort 0}
+do_test where7-2.7.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 8 AND 10) AND a!=9)
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ OR c=14014
+ OR b=828
+ }
+} {8 10 34 36 40 41 42 94 scan 0 sort 0}
+do_test where7-2.8.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE 1000000<b
+ OR b=308
+ }
+} {28 scan 0 sort 0}
+do_test where7-2.8.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE 1000000<b
+ OR b=308
+ }
+} {28 scan 0 sort 0}
+do_test where7-2.9.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=949
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR a=63
+ }
+} {22 24 63 scan 0 sort 0}
+do_test where7-2.9.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=949
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR a=63
+ }
+} {22 24 63 scan 0 sort 0}
+do_test where7-2.10.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 49 AND 51) AND a!=50)
+ OR b=396
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ }
+} {36 49 51 68 70 scan 0 sort 0}
+do_test where7-2.10.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 49 AND 51) AND a!=50)
+ OR b=396
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ }
+} {36 49 51 68 70 scan 0 sort 0}
+do_test where7-2.11.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR c=11011
+ OR c=20020
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ }
+} {18 31 32 33 58 59 60 72 74 scan 0 sort 0}
+do_test where7-2.11.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR c=11011
+ OR c=20020
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ }
+} {18 31 32 33 58 59 60 72 74 scan 0 sort 0}
+do_test where7-2.12.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR (d>=83.0 AND d<84.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR b=792
+ OR a=97
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR b=916
+ OR a=69
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR c=6006
+ }
+} {16 17 18 31 50 69 72 81 83 87 97 scan 0 sort 0}
+do_test where7-2.12.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR (d>=83.0 AND d<84.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR b=792
+ OR a=97
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR b=916
+ OR a=69
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR c=6006
+ }
+} {16 17 18 31 50 69 72 81 83 87 97 scan 0 sort 0}
+do_test where7-2.13.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 50 AND 52) AND a!=51)
+ OR c=9009
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR b=539
+ OR b=297
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR b=957
+ OR f='xyzabcdef'
+ OR b=619
+ }
+} {10 15 21 23 25 26 27 49 50 52 75 87 scan 0 sort 0}
+do_test where7-2.13.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 50 AND 52) AND a!=51)
+ OR c=9009
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR b=539
+ OR b=297
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR b=957
+ OR f='xyzabcdef'
+ OR b=619
+ }
+} {10 15 21 23 25 26 27 49 50 52 75 87 scan 0 sort 0}
+do_test where7-2.14.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 47 AND 49) AND a!=48)
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ }
+} {47 48 49 scan 0 sort 0}
+do_test where7-2.14.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 47 AND 49) AND a!=48)
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ }
+} {47 48 49 scan 0 sort 0}
+do_test where7-2.15.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=20
+ OR a=67
+ OR b=58
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ }
+} {19 20 21 67 scan 0 sort 0}
+do_test where7-2.15.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=20
+ OR a=67
+ OR b=58
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ }
+} {19 20 21 67 scan 0 sort 0}
+do_test where7-2.16.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=938
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ }
+} {17 67 scan 0 sort 0}
+do_test where7-2.16.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=938
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ }
+} {17 67 scan 0 sort 0}
+do_test where7-2.17.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=68.0 AND d<69.0 AND d NOT NULL)
+ OR f='zabcdefgh'
+ OR b=308
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ OR b=443
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ OR f='uvwxyzabc'
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ }
+} {12 14 15 16 17 20 24 25 28 29 46 50 51 68 72 76 77 98 scan 0 sort 0}
+do_test where7-2.17.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=68.0 AND d<69.0 AND d NOT NULL)
+ OR f='zabcdefgh'
+ OR b=308
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ OR b=443
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ OR f='uvwxyzabc'
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ }
+} {12 14 15 16 17 20 24 25 28 29 46 50 51 68 72 76 77 98 scan 0 sort 0}
+do_test where7-2.18.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR b=762
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR a=19
+ }
+} {19 46 56 scan 0 sort 0}
+do_test where7-2.18.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR b=762
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR a=19
+ }
+} {19 46 56 scan 0 sort 0}
+do_test where7-2.19.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR a=46
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR a=73
+ OR c=20020
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR b=267
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ }
+} {2 4 20 46 58 59 60 63 68 70 73 scan 0 sort 0}
+do_test where7-2.19.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR a=46
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR a=73
+ OR c=20020
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR b=267
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ }
+} {2 4 20 46 58 59 60 63 68 70 73 scan 0 sort 0}
+do_test where7-2.20.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 27 AND 29) AND a!=28)
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ }
+} {27 29 91 scan 0 sort 0}
+do_test where7-2.20.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 27 AND 29) AND a!=28)
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ }
+} {27 29 91 scan 0 sort 0}
+do_test where7-2.21.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=13013
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR f='bcdefghij'
+ OR b=586
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR (d>=6.0 AND d<7.0 AND d NOT NULL)
+ OR a=9
+ }
+} {1 6 9 27 37 38 39 53 55 58 59 61 75 79 87 89 98 scan 0 sort 0}
+do_test where7-2.21.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=13013
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR f='bcdefghij'
+ OR b=586
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR (d>=6.0 AND d<7.0 AND d NOT NULL)
+ OR a=9
+ }
+} {1 6 9 27 37 38 39 53 55 58 59 61 75 79 87 89 98 scan 0 sort 0}
+do_test where7-2.22.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=399
+ OR c=28028
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ }
+} {42 82 83 84 98 scan 0 sort 0}
+do_test where7-2.22.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=399
+ OR c=28028
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ }
+} {42 82 83 84 98 scan 0 sort 0}
+do_test where7-2.23.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR c=14014
+ OR c=33033
+ OR a=89
+ OR b=770
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR a=35
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR b=253
+ OR c=14014
+ }
+} {4 19 23 30 35 40 41 42 56 70 82 89 95 96 97 98 99 scan 0 sort 0}
+do_test where7-2.23.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR c=14014
+ OR c=33033
+ OR a=89
+ OR b=770
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR a=35
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR b=253
+ OR c=14014
+ }
+} {4 19 23 30 35 40 41 42 56 70 82 89 95 96 97 98 99 scan 0 sort 0}
+do_test where7-2.24.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=330
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR a=16
+ }
+} {6 16 21 30 32 34 scan 0 sort 0}
+do_test where7-2.24.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=330
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR a=16
+ }
+} {6 16 21 30 32 34 scan 0 sort 0}
+do_test where7-2.25.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=5005
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ }
+} {2 13 14 15 36 38 47 scan 0 sort 0}
+do_test where7-2.25.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=5005
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ }
+} {2 13 14 15 36 38 47 scan 0 sort 0}
+do_test where7-2.26.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR a=33
+ }
+} {30 33 58 64 66 68 scan 0 sort 0}
+do_test where7-2.26.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR a=33
+ }
+} {30 33 58 64 66 68 scan 0 sort 0}
+do_test where7-2.27.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1026
+ OR b=410
+ }
+} { scan 0 sort 0}
+do_test where7-2.27.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1026
+ OR b=410
+ }
+} { scan 0 sort 0}
+do_test where7-2.28.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=18018
+ OR a=94
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR b=1012
+ OR a=3
+ OR d>1e10
+ OR b=905
+ OR b=1089
+ }
+} {3 15 26 41 52 53 54 67 92 93 94 99 scan 0 sort 0}
+do_test where7-2.28.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=18018
+ OR a=94
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR b=1012
+ OR a=3
+ OR d>1e10
+ OR b=905
+ OR b=1089
+ }
+} {3 15 26 41 52 53 54 67 92 93 94 99 scan 0 sort 0}
+do_test where7-2.29.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=100
+ OR c=11011
+ OR b=297
+ OR a=63
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR a=76
+ OR b=1026
+ OR a=26
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR c=30030
+ }
+} {24 26 27 31 32 33 50 63 76 84 88 89 90 100 scan 0 sort 0}
+do_test where7-2.29.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=100
+ OR c=11011
+ OR b=297
+ OR a=63
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR a=76
+ OR b=1026
+ OR a=26
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR c=30030
+ }
+} {24 26 27 31 32 33 50 63 76 84 88 89 90 100 scan 0 sort 0}
+do_test where7-2.30.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=561
+ OR b=1070
+ OR a=59
+ OR b=715
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ }
+} {23 49 51 59 65 75 scan 0 sort 0}
+do_test where7-2.30.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=561
+ OR b=1070
+ OR a=59
+ OR b=715
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ }
+} {23 49 51 59 65 75 scan 0 sort 0}
+do_test where7-2.31.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=1056
+ OR b=1012
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ }
+} {19 26 52 57 59 67 69 78 92 95 96 scan 0 sort 0}
+do_test where7-2.31.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=1056
+ OR b=1012
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ }
+} {19 26 52 57 59 67 69 78 92 95 96 scan 0 sort 0}
+do_test where7-2.32.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='rstuvwxyz'
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ }
+} {17 43 69 74 90 92 95 98 scan 0 sort 0}
+do_test where7-2.32.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='rstuvwxyz'
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ }
+} {17 43 69 74 90 92 95 98 scan 0 sort 0}
+do_test where7-2.33.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR c=12012
+ OR a=18
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ }
+} {9 15 17 18 26 34 35 36 41 43 52 61 67 69 76 78 87 93 95 scan 0 sort 0}
+do_test where7-2.33.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR c=12012
+ OR a=18
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ }
+} {9 15 17 18 26 34 35 36 41 43 52 61 67 69 76 78 87 93 95 scan 0 sort 0}
+do_test where7-2.34.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=77
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ }
+} {58 77 scan 0 sort 0}
+do_test where7-2.34.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=77
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ }
+} {58 77 scan 0 sort 0}
+do_test where7-2.35.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=498
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR c=33033
+ OR b=11
+ OR (g='wvutsrq' AND f GLOB 'lmnop*')
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ }
+} {1 7 9 11 27 67 69 88 97 98 99 scan 0 sort 0}
+do_test where7-2.35.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=498
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR c=33033
+ OR b=11
+ OR (g='wvutsrq' AND f GLOB 'lmnop*')
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ }
+} {1 7 9 11 27 67 69 88 97 98 99 scan 0 sort 0}
+do_test where7-2.36.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=6.0 AND d<7.0 AND d NOT NULL)
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ }
+} {6 58 60 scan 0 sort 0}
+do_test where7-2.36.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=6.0 AND d<7.0 AND d NOT NULL)
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ }
+} {6 58 60 scan 0 sort 0}
+do_test where7-2.37.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1059
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR c=4004
+ OR b=806
+ }
+} {10 11 12 43 scan 0 sort 0}
+do_test where7-2.37.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1059
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR c=4004
+ OR b=806
+ }
+} {10 11 12 43 scan 0 sort 0}
+do_test where7-2.38.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=165
+ OR b=201
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR a=32
+ }
+} {15 32 99 scan 0 sort 0}
+do_test where7-2.38.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=165
+ OR b=201
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR a=32
+ }
+} {15 32 99 scan 0 sort 0}
+do_test where7-2.39.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ }
+} {22 48 69 74 100 scan 0 sort 0}
+do_test where7-2.39.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ }
+} {22 48 69 74 100 scan 0 sort 0}
+do_test where7-2.40.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=352
+ OR b=278
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR b=660
+ OR a=18
+ OR a=34
+ OR b=132
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR c=18018
+ }
+} {2 12 18 28 30 32 34 52 53 54 60 80 89 90 92 scan 0 sort 0}
+do_test where7-2.40.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=352
+ OR b=278
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR b=660
+ OR a=18
+ OR a=34
+ OR b=132
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR c=18018
+ }
+} {2 12 18 28 30 32 34 52 53 54 60 80 89 90 92 scan 0 sort 0}
+do_test where7-2.41.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ }
+} {5 7 73 scan 0 sort 0}
+do_test where7-2.41.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ }
+} {5 7 73 scan 0 sort 0}
+do_test where7-2.42.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ OR b=297
+ OR b=113
+ OR b=176
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR a=67
+ OR c=26026
+ }
+} {3 14 16 21 27 29 55 67 75 76 77 78 81 83 scan 0 sort 0}
+do_test where7-2.42.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ OR b=297
+ OR b=113
+ OR b=176
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR a=67
+ OR c=26026
+ }
+} {3 14 16 21 27 29 55 67 75 76 77 78 81 83 scan 0 sort 0}
+do_test where7-2.43.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR a=83
+ OR b=44
+ OR b=1023
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ OR b=1023
+ OR f='ijklmnopq'
+ }
+} {4 6 8 11 13 34 60 78 83 86 93 scan 0 sort 0}
+do_test where7-2.43.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR a=83
+ OR b=44
+ OR b=1023
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ OR b=1023
+ OR f='ijklmnopq'
+ }
+} {4 6 8 11 13 34 60 78 83 86 93 scan 0 sort 0}
+do_test where7-2.44.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR b=935
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=487
+ OR b=619
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ }
+} {17 32 34 39 42 85 scan 0 sort 0}
+do_test where7-2.44.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR b=935
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=487
+ OR b=619
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ }
+} {17 32 34 39 42 85 scan 0 sort 0}
+do_test where7-2.45.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=68.0 AND d<69.0 AND d NOT NULL)
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR b=938
+ OR b=641
+ OR c=17017
+ OR a=82
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ }
+} {37 39 49 50 51 56 58 65 68 82 94 scan 0 sort 0}
+do_test where7-2.45.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=68.0 AND d<69.0 AND d NOT NULL)
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR b=938
+ OR b=641
+ OR c=17017
+ OR a=82
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ }
+} {37 39 49 50 51 56 58 65 68 82 94 scan 0 sort 0}
+do_test where7-2.46.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR c=22022
+ }
+} {64 65 66 79 scan 0 sort 0}
+do_test where7-2.46.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR c=22022
+ }
+} {64 65 66 79 scan 0 sort 0}
+do_test where7-2.47.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=7007
+ OR b=91
+ OR b=212
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR c=28028
+ OR (d>=83.0 AND d<84.0 AND d NOT NULL)
+ }
+} {19 20 21 65 82 83 84 scan 0 sort 0}
+do_test where7-2.47.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=7007
+ OR b=91
+ OR b=212
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR c=28028
+ OR (d>=83.0 AND d<84.0 AND d NOT NULL)
+ }
+} {19 20 21 65 82 83 84 scan 0 sort 0}
+do_test where7-2.48.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR a=51
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ }
+} {12 28 30 51 scan 0 sort 0}
+do_test where7-2.48.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR a=51
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ }
+} {12 28 30 51 scan 0 sort 0}
+do_test where7-2.49.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR (g='wvutsrq' AND f GLOB 'jklmn*')
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR ((a BETWEEN 0 AND 2) AND a!=1)
+ OR c=4004
+ OR b=322
+ OR c=13013
+ OR a=6
+ }
+} {2 6 9 10 11 12 23 37 38 39 scan 0 sort 0}
+do_test where7-2.49.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR (g='wvutsrq' AND f GLOB 'jklmn*')
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR ((a BETWEEN 0 AND 2) AND a!=1)
+ OR c=4004
+ OR b=322
+ OR c=13013
+ OR a=6
+ }
+} {2 6 9 10 11 12 23 37 38 39 scan 0 sort 0}
+do_test where7-2.50.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=297
+ OR b=143
+ OR a=46
+ OR b=660
+ OR (d>=41.0 AND d<42.0 AND d NOT NULL)
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR b=355
+ OR a=93
+ OR b=297
+ }
+} {13 17 23 27 41 46 49 60 75 93 scan 0 sort 0}
+do_test where7-2.50.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=297
+ OR b=143
+ OR a=46
+ OR b=660
+ OR (d>=41.0 AND d<42.0 AND d NOT NULL)
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR b=355
+ OR a=93
+ OR b=297
+ }
+} {13 17 23 27 41 46 49 60 75 93 scan 0 sort 0}
+do_test where7-2.51.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=190
+ OR a=62
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ }
+} {62 99 scan 0 sort 0}
+do_test where7-2.51.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=190
+ OR a=62
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ }
+} {62 99 scan 0 sort 0}
+do_test where7-2.52.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1089
+ OR b=102
+ OR a=6
+ OR b=608
+ }
+} {6 99 scan 0 sort 0}
+do_test where7-2.52.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1089
+ OR b=102
+ OR a=6
+ OR b=608
+ }
+} {6 99 scan 0 sort 0}
+do_test where7-2.53.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=473
+ OR b=1100
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR a=20
+ OR b=1089
+ OR b=330
+ OR b=124
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {15 20 30 43 53 56 58 99 100 scan 0 sort 0}
+do_test where7-2.53.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=473
+ OR b=1100
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR a=20
+ OR b=1089
+ OR b=330
+ OR b=124
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {15 20 30 43 53 56 58 99 100 scan 0 sort 0}
+do_test where7-2.54.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 68 AND 70) AND a!=69)
+ OR b=223
+ OR a=12
+ OR b=1048
+ OR b=256
+ OR a=72
+ OR c>=34035
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR b=674
+ OR a=22
+ }
+} {12 22 35 68 70 72 scan 0 sort 0}
+do_test where7-2.54.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 68 AND 70) AND a!=69)
+ OR b=223
+ OR a=12
+ OR b=1048
+ OR b=256
+ OR a=72
+ OR c>=34035
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR b=674
+ OR a=22
+ }
+} {12 22 35 68 70 72 scan 0 sort 0}
+do_test where7-2.55.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 76 AND 78) AND a!=77)
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR f='yzabcdefg'
+ OR c=14014
+ OR a=1
+ OR a=9
+ OR b=960
+ }
+} {1 9 24 40 41 42 50 76 78 scan 0 sort 0}
+do_test where7-2.55.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 76 AND 78) AND a!=77)
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR f='yzabcdefg'
+ OR c=14014
+ OR a=1
+ OR a=9
+ OR b=960
+ }
+} {1 9 24 40 41 42 50 76 78 scan 0 sort 0}
+do_test where7-2.56.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ }
+} {19 49 96 98 scan 0 sort 0}
+do_test where7-2.56.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ }
+} {19 49 96 98 scan 0 sort 0}
+do_test where7-2.57.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=748
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR b=630
+ }
+} {9 20 67 68 scan 0 sort 0}
+do_test where7-2.57.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=748
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR b=630
+ }
+} {9 20 67 68 scan 0 sort 0}
+do_test where7-2.58.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=223
+ OR b=267
+ OR a=40
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR c<=10
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR b=528
+ }
+} {40 48 55 57 69 71 scan 0 sort 0}
+do_test where7-2.58.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=223
+ OR b=267
+ OR a=40
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR c<=10
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR b=528
+ }
+} {40 48 55 57 69 71 scan 0 sort 0}
+do_test where7-2.59.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='rstuvwxyz'
+ OR a=41
+ OR b=462
+ OR a=68
+ OR a=84
+ OR a=69
+ }
+} {17 41 42 43 68 69 84 95 scan 0 sort 0}
+do_test where7-2.59.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='rstuvwxyz'
+ OR a=41
+ OR b=462
+ OR a=68
+ OR a=84
+ OR a=69
+ }
+} {17 41 42 43 68 69 84 95 scan 0 sort 0}
+do_test where7-2.60.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=979
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ }
+} {3 5 13 89 scan 0 sort 0}
+do_test where7-2.60.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=979
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ }
+} {3 5 13 89 scan 0 sort 0}
+do_test where7-2.61.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR a=8
+ OR a=62
+ OR b=726
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ }
+} {8 9 10 14 50 52 59 61 62 66 scan 0 sort 0}
+do_test where7-2.61.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR a=8
+ OR a=62
+ OR b=726
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ }
+} {8 9 10 14 50 52 59 61 62 66 scan 0 sort 0}
+do_test where7-2.62.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=495
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR b=924
+ OR c=11011
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR b=231
+ OR b=872
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ }
+} {18 20 21 31 32 33 45 47 73 76 84 99 scan 0 sort 0}
+do_test where7-2.62.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=495
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR b=924
+ OR c=11011
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR b=231
+ OR b=872
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ }
+} {18 20 21 31 32 33 45 47 73 76 84 99 scan 0 sort 0}
+do_test where7-2.63.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=24
+ OR b=473
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR b=509
+ OR b=924
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ }
+} {21 24 43 84 86 96 scan 0 sort 0}
+do_test where7-2.63.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=24
+ OR b=473
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR b=509
+ OR b=924
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ }
+} {21 24 43 84 86 96 scan 0 sort 0}
+do_test where7-2.64.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR b=363
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {2 5 8 23 25 28 33 34 54 56 58 60 80 86 93 100 scan 0 sort 0}
+do_test where7-2.64.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR b=363
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {2 5 8 23 25 28 33 34 54 56 58 60 80 86 93 100 scan 0 sort 0}
+do_test where7-2.65.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=42
+ OR e IS NULL
+ OR b=495
+ OR 1000000<b
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ OR a=45
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR a=85
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ }
+} {20 42 45 46 65 69 72 85 98 scan 0 sort 0}
+do_test where7-2.65.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=42
+ OR e IS NULL
+ OR b=495
+ OR 1000000<b
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ OR a=45
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR a=85
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ }
+} {20 42 45 46 65 69 72 85 98 scan 0 sort 0}
+do_test where7-2.66.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=17017
+ OR f='ijklmnopq'
+ OR a=39
+ }
+} {8 34 39 49 50 51 60 86 scan 0 sort 0}
+do_test where7-2.66.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=17017
+ OR f='ijklmnopq'
+ OR a=39
+ }
+} {8 34 39 49 50 51 60 86 scan 0 sort 0}
+do_test where7-2.67.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c>=34035
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR a=91
+ }
+} {11 19 27 37 63 89 91 96 98 100 scan 0 sort 0}
+do_test where7-2.67.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c>=34035
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR a=91
+ }
+} {11 19 27 37 63 89 91 96 98 100 scan 0 sort 0}
+do_test where7-2.68.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='gfedcba' AND f GLOB 'nopqr*')
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR b=649
+ OR b=231
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR b=58
+ }
+} {9 21 28 29 35 48 59 61 87 91 scan 0 sort 0}
+do_test where7-2.68.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='gfedcba' AND f GLOB 'nopqr*')
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR b=649
+ OR b=231
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR b=58
+ }
+} {9 21 28 29 35 48 59 61 87 91 scan 0 sort 0}
+do_test where7-2.69.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=979
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ }
+} {78 89 scan 0 sort 0}
+do_test where7-2.69.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=979
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ }
+} {78 89 scan 0 sort 0}
+do_test where7-2.70.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=825
+ OR b=1004
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {56 58 60 62 75 scan 0 sort 0}
+do_test where7-2.70.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=825
+ OR b=1004
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {56 58 60 62 75 scan 0 sort 0}
+do_test where7-2.71.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=65
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR c=22022
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ OR b=671
+ OR (g='onmlkji' AND f GLOB 'zabcd*')
+ OR a=91
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ OR ((a BETWEEN 47 AND 49) AND a!=48)
+ OR b=1004
+ OR b=960
+ }
+} {5 31 47 49 51 57 61 64 65 66 83 91 98 scan 0 sort 0}
+do_test where7-2.71.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=65
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR c=22022
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ OR b=671
+ OR (g='onmlkji' AND f GLOB 'zabcd*')
+ OR a=91
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ OR ((a BETWEEN 47 AND 49) AND a!=48)
+ OR b=1004
+ OR b=960
+ }
+} {5 31 47 49 51 57 61 64 65 66 83 91 98 scan 0 sort 0}
+do_test where7-2.72.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=762
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {56 58 93 scan 0 sort 0}
+do_test where7-2.72.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=762
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {56 58 93 scan 0 sort 0}
+do_test where7-2.73.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR a=14
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR b=212
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ }
+} {11 14 23 54 78 85 scan 0 sort 0}
+do_test where7-2.73.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR a=14
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR b=212
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ }
+} {11 14 23 54 78 85 scan 0 sort 0}
+do_test where7-2.74.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR b=168
+ OR b=25
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ }
+} {66 79 89 scan 0 sort 0}
+do_test where7-2.74.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR b=168
+ OR b=25
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ }
+} {66 79 89 scan 0 sort 0}
+do_test where7-2.75.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=28028
+ OR f='jklmnopqr'
+ OR b=1015
+ }
+} {9 35 61 82 83 84 87 scan 0 sort 0}
+do_test where7-2.75.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=28028
+ OR f='jklmnopqr'
+ OR b=1015
+ }
+} {9 35 61 82 83 84 87 scan 0 sort 0}
+do_test where7-2.76.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=31031
+ OR (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR a=49
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'klmno*')
+ }
+} {15 41 49 56 62 67 87 89 91 92 93 100 scan 0 sort 0}
+do_test where7-2.76.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=31031
+ OR (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR a=49
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'klmno*')
+ }
+} {15 41 49 56 62 67 87 89 91 92 93 100 scan 0 sort 0}
+do_test where7-2.77.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=80
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR b=971
+ OR a=60
+ }
+} {4 6 25 29 60 80 scan 0 sort 0}
+do_test where7-2.77.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=80
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR b=971
+ OR a=60
+ }
+} {4 6 25 29 60 80 scan 0 sort 0}
+do_test where7-2.78.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR b=1089
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ }
+} {30 32 43 85 89 99 scan 0 sort 0}
+do_test where7-2.78.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR b=1089
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ }
+} {30 32 43 85 89 99 scan 0 sort 0}
+do_test where7-2.79.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=399
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR a=10
+ OR b=1026
+ }
+} {9 10 11 57 90 scan 0 sort 0}
+do_test where7-2.79.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=399
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR a=10
+ OR b=1026
+ }
+} {9 10 11 57 90 scan 0 sort 0}
+do_test where7-2.80.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='jihgfed' AND f GLOB 'yzabc*')
+ OR b=465
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ }
+} {5 43 65 76 scan 0 sort 0}
+do_test where7-2.80.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='jihgfed' AND f GLOB 'yzabc*')
+ OR b=465
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ }
+} {5 43 65 76 scan 0 sort 0}
+do_test where7-2.81.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=25
+ OR b=792
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ }
+} {19 25 45 71 72 97 scan 0 sort 0}
+do_test where7-2.81.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=25
+ OR b=792
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ }
+} {19 25 45 71 72 97 scan 0 sort 0}
+do_test where7-2.82.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=979
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR a=13
+ OR a=15
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR a=27
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR a=32
+ OR a=39
+ }
+} {6 8 13 15 21 27 32 39 67 89 98 100 scan 0 sort 0}
+do_test where7-2.82.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=979
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR a=13
+ OR a=15
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR a=27
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR a=32
+ OR a=39
+ }
+} {6 8 13 15 21 27 32 39 67 89 98 100 scan 0 sort 0}
+do_test where7-2.83.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='hijklmnop'
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR b=528
+ OR c=30030
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ }
+} {1 7 21 31 33 42 48 58 59 77 79 85 88 89 90 scan 0 sort 0}
+do_test where7-2.83.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='hijklmnop'
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR b=528
+ OR c=30030
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ }
+} {1 7 21 31 33 42 48 58 59 77 79 85 88 89 90 scan 0 sort 0}
+do_test where7-2.84.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=69
+ OR e IS NULL
+ OR b=352
+ OR 1000000<b
+ OR b=289
+ }
+} {32 scan 0 sort 0}
+do_test where7-2.84.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=69
+ OR e IS NULL
+ OR b=352
+ OR 1000000<b
+ OR b=289
+ }
+} {32 scan 0 sort 0}
+do_test where7-2.85.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR b=748
+ OR b=696
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ }
+} {4 30 43 56 67 68 82 scan 0 sort 0}
+do_test where7-2.85.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR b=748
+ OR b=696
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ }
+} {4 30 43 56 67 68 82 scan 0 sort 0}
+do_test where7-2.86.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR a=87
+ OR a=80
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR b=784
+ OR a=49
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ }
+} {34 36 40 49 68 71 73 80 87 scan 0 sort 0}
+do_test where7-2.86.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR a=87
+ OR a=80
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR b=784
+ OR a=49
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ }
+} {34 36 40 49 68 71 73 80 87 scan 0 sort 0}
+do_test where7-2.87.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 14 AND 16) AND a!=15)
+ OR (g='wvutsrq' AND f GLOB 'jklmn*')
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR c=1001
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR c=33033
+ }
+} {1 2 3 8 9 14 16 78 85 86 97 98 99 scan 0 sort 0}
+do_test where7-2.87.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 14 AND 16) AND a!=15)
+ OR (g='wvutsrq' AND f GLOB 'jklmn*')
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR c=1001
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR c=33033
+ }
+} {1 2 3 8 9 14 16 78 85 86 97 98 99 scan 0 sort 0}
+do_test where7-2.88.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=311
+ OR b=1103
+ OR b=88
+ }
+} {8 scan 0 sort 0}
+do_test where7-2.88.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=311
+ OR b=1103
+ OR b=88
+ }
+} {8 scan 0 sort 0}
+do_test where7-2.89.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 65 AND 67) AND a!=66)
+ OR ((a BETWEEN 26 AND 28) AND a!=27)
+ OR c=5005
+ OR b=1045
+ OR c=8008
+ OR f='bcdefghij'
+ }
+} {1 13 14 15 22 23 24 26 27 28 53 65 67 79 95 scan 0 sort 0}
+do_test where7-2.89.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 65 AND 67) AND a!=66)
+ OR ((a BETWEEN 26 AND 28) AND a!=27)
+ OR c=5005
+ OR b=1045
+ OR c=8008
+ OR f='bcdefghij'
+ }
+} {1 13 14 15 22 23 24 26 27 28 53 65 67 79 95 scan 0 sort 0}
+do_test where7-2.90.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=66
+ OR b=553
+ OR a=64
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR a=62
+ OR b=1081
+ OR b=770
+ OR b=762
+ OR b=803
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ }
+} {6 17 30 62 64 70 73 93 scan 0 sort 0}
+do_test where7-2.90.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=66
+ OR b=553
+ OR a=64
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR a=62
+ OR b=1081
+ OR b=770
+ OR b=762
+ OR b=803
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ }
+} {6 17 30 62 64 70 73 93 scan 0 sort 0}
+do_test where7-2.91.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='wvutsrq' AND f GLOB 'klmno*')
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR c=17017
+ OR b=168
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ }
+} {10 19 45 49 50 51 71 77 79 97 scan 0 sort 0}
+do_test where7-2.91.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='wvutsrq' AND f GLOB 'klmno*')
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR c=17017
+ OR b=168
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ }
+} {10 19 45 49 50 51 71 77 79 97 scan 0 sort 0}
+do_test where7-2.92.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=34034
+ OR (d>=68.0 AND d<69.0 AND d NOT NULL)
+ OR a=44
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR c=31031
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR b=619
+ OR (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR ((a BETWEEN 29 AND 31) AND a!=30)
+ }
+} {3 12 23 29 31 44 55 68 78 81 91 92 93 100 scan 0 sort 0}
+do_test where7-2.92.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=34034
+ OR (d>=68.0 AND d<69.0 AND d NOT NULL)
+ OR a=44
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR c=31031
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR b=619
+ OR (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR ((a BETWEEN 29 AND 31) AND a!=30)
+ }
+} {3 12 23 29 31 44 55 68 78 81 91 92 93 100 scan 0 sort 0}
+do_test where7-2.93.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=48
+ OR c=15015
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR b=110
+ OR f='klmnopqrs'
+ OR (g='fedcbaz' AND f GLOB 'qrstu*')
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR b=674
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ }
+} {10 36 43 44 45 48 52 62 65 67 88 94 96 97 99 scan 0 sort 0}
+do_test where7-2.93.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=48
+ OR c=15015
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR b=110
+ OR f='klmnopqrs'
+ OR (g='fedcbaz' AND f GLOB 'qrstu*')
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR b=674
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ }
+} {10 36 43 44 45 48 52 62 65 67 88 94 96 97 99 scan 0 sort 0}
+do_test where7-2.94.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=72
+ OR b=913
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR b=121
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ }
+} {2 11 28 72 83 scan 0 sort 0}
+do_test where7-2.94.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=72
+ OR b=913
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR b=121
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ }
+} {2 11 28 72 83 scan 0 sort 0}
+do_test where7-2.95.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=18
+ OR b=286
+ OR b=1015
+ OR a=49
+ OR b=264
+ }
+} {18 24 26 49 scan 0 sort 0}
+do_test where7-2.95.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=18
+ OR b=286
+ OR b=1015
+ OR a=49
+ OR b=264
+ }
+} {18 24 26 49 scan 0 sort 0}
+do_test where7-2.96.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=69
+ OR a=11
+ OR c=1001
+ OR ((a BETWEEN 54 AND 56) AND a!=55)
+ OR a=57
+ OR ((a BETWEEN 48 AND 50) AND a!=49)
+ }
+} {1 2 3 11 48 50 54 56 57 scan 0 sort 0}
+do_test where7-2.96.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=69
+ OR a=11
+ OR c=1001
+ OR ((a BETWEEN 54 AND 56) AND a!=55)
+ OR a=57
+ OR ((a BETWEEN 48 AND 50) AND a!=49)
+ }
+} {1 2 3 11 48 50 54 56 57 scan 0 sort 0}
+do_test where7-2.97.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=231
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ }
+} {21 84 scan 0 sort 0}
+do_test where7-2.97.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=231
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ }
+} {21 84 scan 0 sort 0}
+do_test where7-2.98.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=25
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR ((a BETWEEN 81 AND 83) AND a!=82)
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR b=289
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ }
+} {3 5 17 23 81 83 85 87 scan 0 sort 0}
+do_test where7-2.98.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=25
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR ((a BETWEEN 81 AND 83) AND a!=82)
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR b=289
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ }
+} {3 5 17 23 81 83 85 87 scan 0 sort 0}
+do_test where7-2.99.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='defghijkl'
+ OR b=465
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR c=9009
+ OR b=990
+ OR b=132
+ OR a=35
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR a=81
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ }
+} {3 12 25 26 27 29 35 46 55 71 73 78 81 90 scan 0 sort 0}
+do_test where7-2.99.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='defghijkl'
+ OR b=465
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR c=9009
+ OR b=990
+ OR b=132
+ OR a=35
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR a=81
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ }
+} {3 12 25 26 27 29 35 46 55 71 73 78 81 90 scan 0 sort 0}
+do_test where7-2.100.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=26026
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR f='lmnopqrst'
+ OR a=6
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ }
+} {6 9 11 37 59 61 63 76 77 78 89 scan 0 sort 0}
+do_test where7-2.100.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=26026
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR f='lmnopqrst'
+ OR a=6
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ }
+} {6 9 11 37 59 61 63 76 77 78 89 scan 0 sort 0}
+do_test where7-2.101.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 98 AND 100) AND a!=99)
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ }
+} {7 98 100 scan 0 sort 0}
+do_test where7-2.101.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 98 AND 100) AND a!=99)
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ }
+} {7 98 100 scan 0 sort 0}
+do_test where7-2.102.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=11011
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR b=630
+ OR c=19019
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR a=24
+ OR (d>=95.0 AND d<96.0 AND d NOT NULL)
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ }
+} {24 31 32 33 51 53 55 56 57 89 95 scan 0 sort 0}
+do_test where7-2.102.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=11011
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR b=630
+ OR c=19019
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR a=24
+ OR (d>=95.0 AND d<96.0 AND d NOT NULL)
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ }
+} {24 31 32 33 51 53 55 56 57 89 95 scan 0 sort 0}
+do_test where7-2.103.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=993
+ OR a=81
+ OR b=366
+ OR b=69
+ }
+} {81 91 93 scan 0 sort 0}
+do_test where7-2.103.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=993
+ OR a=81
+ OR b=366
+ OR b=69
+ }
+} {81 91 93 scan 0 sort 0}
+do_test where7-2.104.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='stuvwxyza'
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR ((a BETWEEN 1 AND 3) AND a!=2)
+ OR b=1037
+ OR f='zabcdefgh'
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ }
+} {1 3 18 24 25 44 50 51 70 76 77 90 96 scan 0 sort 0}
+do_test where7-2.104.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='stuvwxyza'
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR ((a BETWEEN 1 AND 3) AND a!=2)
+ OR b=1037
+ OR f='zabcdefgh'
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ }
+} {1 3 18 24 25 44 50 51 70 76 77 90 96 scan 0 sort 0}
+do_test where7-2.105.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ }
+} {4 6 30 32 scan 0 sort 0}
+do_test where7-2.105.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ }
+} {4 6 30 32 scan 0 sort 0}
+do_test where7-2.106.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=847
+ OR b=190
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR ((a BETWEEN 70 AND 72) AND a!=71)
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR b=704
+ }
+} {9 23 35 38 40 61 64 70 72 77 87 scan 0 sort 0}
+do_test where7-2.106.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=847
+ OR b=190
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR ((a BETWEEN 70 AND 72) AND a!=71)
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR b=704
+ }
+} {9 23 35 38 40 61 64 70 72 77 87 scan 0 sort 0}
+do_test where7-2.107.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=88
+ OR f='vwxyzabcd'
+ OR f='fghijklmn'
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ }
+} {5 8 21 31 47 57 73 83 89 99 scan 0 sort 0}
+do_test where7-2.107.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=88
+ OR f='vwxyzabcd'
+ OR f='fghijklmn'
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ }
+} {5 8 21 31 47 57 73 83 89 99 scan 0 sort 0}
+do_test where7-2.108.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=498
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR a=1
+ }
+} {1 69 scan 0 sort 0}
+do_test where7-2.108.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=498
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR a=1
+ }
+} {1 69 scan 0 sort 0}
+do_test where7-2.109.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 47 AND 49) AND a!=48)
+ OR a=5
+ OR b=179
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR a=69
+ }
+} {5 17 43 47 49 69 95 scan 0 sort 0}
+do_test where7-2.109.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 47 AND 49) AND a!=48)
+ OR a=5
+ OR b=179
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR a=69
+ }
+} {5 17 43 47 49 69 95 scan 0 sort 0}
+do_test where7-2.110.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=971
+ OR (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR b=828
+ OR a=81
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR b=627
+ OR b=355
+ OR b=377
+ OR a=44
+ }
+} {1 7 23 25 44 57 81 scan 0 sort 0}
+do_test where7-2.110.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=971
+ OR (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR b=828
+ OR a=81
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR b=627
+ OR b=355
+ OR b=377
+ OR a=44
+ }
+} {1 7 23 25 44 57 81 scan 0 sort 0}
+do_test where7-2.111.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=850
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ }
+} {6 8 scan 0 sort 0}
+do_test where7-2.111.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=850
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ }
+} {6 8 scan 0 sort 0}
+do_test where7-2.112.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='lkjihgf' AND f GLOB 'opqrs*')
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ }
+} {17 43 66 69 95 scan 0 sort 0}
+do_test where7-2.112.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='lkjihgf' AND f GLOB 'opqrs*')
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ }
+} {17 43 66 69 95 scan 0 sort 0}
+do_test where7-2.113.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=726
+ OR b=740
+ OR a=33
+ OR c=8008
+ OR f='rstuvwxyz'
+ OR b=168
+ }
+} {17 22 23 24 33 43 66 69 95 scan 0 sort 0}
+do_test where7-2.113.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=726
+ OR b=740
+ OR a=33
+ OR c=8008
+ OR f='rstuvwxyz'
+ OR b=168
+ }
+} {17 22 23 24 33 43 66 69 95 scan 0 sort 0}
+do_test where7-2.114.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR b=396
+ }
+} {17 19 36 scan 0 sort 0}
+do_test where7-2.114.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR b=396
+ }
+} {17 19 36 scan 0 sort 0}
+do_test where7-2.115.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=77
+ OR ((a BETWEEN 48 AND 50) AND a!=49)
+ OR c<=10
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ }
+} {5 7 48 50 77 scan 0 sort 0}
+do_test where7-2.115.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=77
+ OR ((a BETWEEN 48 AND 50) AND a!=49)
+ OR c<=10
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ }
+} {5 7 48 50 77 scan 0 sort 0}
+do_test where7-2.116.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 12 AND 14) AND a!=13)
+ OR ((a BETWEEN 13 AND 15) AND a!=14)
+ OR b=253
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=396
+ OR b=630
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR c=3003
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ }
+} {1 7 8 9 12 13 14 15 20 22 23 27 36 49 53 79 scan 0 sort 0}
+do_test where7-2.116.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 12 AND 14) AND a!=13)
+ OR ((a BETWEEN 13 AND 15) AND a!=14)
+ OR b=253
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=396
+ OR b=630
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR c=3003
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ }
+} {1 7 8 9 12 13 14 15 20 22 23 27 36 49 53 79 scan 0 sort 0}
+do_test where7-2.117.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=957
+ OR b=242
+ OR b=113
+ OR b=957
+ OR b=311
+ OR b=143
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ }
+} {9 10 13 22 35 48 61 87 scan 0 sort 0}
+do_test where7-2.117.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=957
+ OR b=242
+ OR b=113
+ OR b=957
+ OR b=311
+ OR b=143
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ }
+} {9 10 13 22 35 48 61 87 scan 0 sort 0}
+do_test where7-2.118.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 74 AND 76) AND a!=75)
+ OR ((a BETWEEN 94 AND 96) AND a!=95)
+ OR b=451
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ }
+} {41 66 74 76 94 96 scan 0 sort 0}
+do_test where7-2.118.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 74 AND 76) AND a!=75)
+ OR ((a BETWEEN 94 AND 96) AND a!=95)
+ OR b=451
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ }
+} {41 66 74 76 94 96 scan 0 sort 0}
+do_test where7-2.119.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR b=451
+ OR b=363
+ OR b=330
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR ((a BETWEEN 52 AND 54) AND a!=53)
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 81 AND 83) AND a!=82)
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ }
+} {3 30 33 41 52 54 81 83 89 scan 0 sort 0}
+do_test where7-2.119.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR b=451
+ OR b=363
+ OR b=330
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR ((a BETWEEN 52 AND 54) AND a!=53)
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 81 AND 83) AND a!=82)
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ }
+} {3 30 33 41 52 54 81 83 89 scan 0 sort 0}
+do_test where7-2.120.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR (d>=68.0 AND d<69.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR e IS NULL
+ OR b=759
+ }
+} {15 68 69 95 scan 0 sort 0}
+do_test where7-2.120.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR (d>=68.0 AND d<69.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR e IS NULL
+ OR b=759
+ }
+} {15 68 69 95 scan 0 sort 0}
+do_test where7-2.121.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ }
+} {19 21 45 71 74 97 scan 0 sort 0}
+do_test where7-2.121.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ }
+} {19 21 45 71 74 97 scan 0 sort 0}
+do_test where7-2.122.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1037
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR ((a BETWEEN 75 AND 77) AND a!=76)
+ }
+} {27 43 45 47 75 77 82 scan 0 sort 0}
+do_test where7-2.122.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1037
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR ((a BETWEEN 75 AND 77) AND a!=76)
+ }
+} {27 43 45 47 75 77 82 scan 0 sort 0}
+do_test where7-2.123.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1045
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR c=12012
+ }
+} {34 35 36 37 38 39 95 scan 0 sort 0}
+do_test where7-2.123.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1045
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR c=12012
+ }
+} {34 35 36 37 38 39 95 scan 0 sort 0}
+do_test where7-2.124.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='fedcbaz' AND f GLOB 'tuvwx*')
+ OR b=421
+ OR b=429
+ OR b=498
+ OR b=33
+ OR b=198
+ OR c=14014
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ }
+} {3 18 23 39 40 41 42 49 75 97 scan 0 sort 0}
+do_test where7-2.124.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='fedcbaz' AND f GLOB 'tuvwx*')
+ OR b=421
+ OR b=429
+ OR b=498
+ OR b=33
+ OR b=198
+ OR c=14014
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ }
+} {3 18 23 39 40 41 42 49 75 97 scan 0 sort 0}
+do_test where7-2.125.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=47
+ OR c=31031
+ OR a=38
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR b=242
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR b=352
+ OR a=49
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ }
+} {8 22 31 32 34 38 49 57 60 70 86 91 92 93 scan 0 sort 0}
+do_test where7-2.125.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=47
+ OR c=31031
+ OR a=38
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR b=242
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR b=352
+ OR a=49
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ }
+} {8 22 31 32 34 38 49 57 60 70 86 91 92 93 scan 0 sort 0}
+do_test where7-2.126.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR b=704
+ OR a=7
+ OR a=8
+ OR a=46
+ OR b=740
+ OR b=993
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ }
+} {7 8 38 46 64 87 scan 0 sort 0}
+do_test where7-2.126.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR b=704
+ OR a=7
+ OR a=8
+ OR a=46
+ OR b=740
+ OR b=993
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ }
+} {7 8 38 46 64 87 scan 0 sort 0}
+do_test where7-2.127.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 62 AND 64) AND a!=63)
+ OR c=32032
+ OR a=76
+ }
+} {62 64 76 94 95 96 scan 0 sort 0}
+do_test where7-2.127.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 62 AND 64) AND a!=63)
+ OR c=32032
+ OR a=76
+ }
+} {62 64 76 94 95 96 scan 0 sort 0}
+do_test where7-2.128.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR b=528
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ }
+} {19 48 91 scan 0 sort 0}
+do_test where7-2.128.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR b=528
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ }
+} {19 48 91 scan 0 sort 0}
+do_test where7-2.129.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR a=65
+ }
+} {26 65 97 scan 0 sort 0}
+do_test where7-2.129.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR a=65
+ }
+} {26 65 97 scan 0 sort 0}
+do_test where7-2.130.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR 1000000<b
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR a=24
+ }
+} {2 24 50 71 scan 0 sort 0}
+do_test where7-2.130.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR 1000000<b
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR a=24
+ }
+} {2 24 50 71 scan 0 sort 0}
+do_test where7-2.131.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=60
+ OR a=39
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR b=36
+ OR b=814
+ OR a=14
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR b=440
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ }
+} {5 14 25 39 40 51 60 61 74 77 93 95 scan 0 sort 0}
+do_test where7-2.131.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=60
+ OR a=39
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR b=36
+ OR b=814
+ OR a=14
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR b=440
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ }
+} {5 14 25 39 40 51 60 61 74 77 93 95 scan 0 sort 0}
+do_test where7-2.132.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f IS NULL
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ }
+} {39 41 scan 0 sort 0}
+do_test where7-2.132.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f IS NULL
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ }
+} {39 41 scan 0 sort 0}
+do_test where7-2.133.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=44
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ }
+} {4 17 19 scan 0 sort 0}
+do_test where7-2.133.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=44
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ }
+} {4 17 19 scan 0 sort 0}
+do_test where7-2.134.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=80.0 AND d<81.0 AND d NOT NULL)
+ OR a=82
+ }
+} {80 82 scan 0 sort 0}
+do_test where7-2.134.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=80.0 AND d<81.0 AND d NOT NULL)
+ OR a=82
+ }
+} {80 82 scan 0 sort 0}
+do_test where7-2.135.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 84 AND 86) AND a!=85)
+ OR c=24024
+ OR b=946
+ OR a=19
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ }
+} {19 47 70 71 72 84 86 scan 0 sort 0}
+do_test where7-2.135.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 84 AND 86) AND a!=85)
+ OR c=24024
+ OR b=946
+ OR a=19
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ }
+} {19 47 70 71 72 84 86 scan 0 sort 0}
+do_test where7-2.136.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=27
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR b=1045
+ OR a=84
+ OR f='qrstuvwxy'
+ }
+} {16 19 27 42 45 68 71 82 84 89 91 94 95 97 scan 0 sort 0}
+do_test where7-2.136.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=27
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR b=1045
+ OR a=84
+ OR f='qrstuvwxy'
+ }
+} {16 19 27 42 45 68 71 82 84 89 91 94 95 97 scan 0 sort 0}
+do_test where7-2.137.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=704
+ OR b=949
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR c=24024
+ OR b=553
+ OR a=18
+ OR a=92
+ }
+} {18 22 64 70 71 72 92 scan 0 sort 0}
+do_test where7-2.137.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=704
+ OR b=949
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR c=24024
+ OR b=553
+ OR a=18
+ OR a=92
+ }
+} {18 22 64 70 71 72 92 scan 0 sort 0}
+do_test where7-2.138.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR b=902
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR b=25
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ OR f='zabcdefgh'
+ OR b=385
+ }
+} {1 16 18 25 27 35 51 53 61 77 79 82 scan 0 sort 0}
+do_test where7-2.138.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR b=902
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR b=25
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ OR f='zabcdefgh'
+ OR b=385
+ }
+} {1 16 18 25 27 35 51 53 61 77 79 82 scan 0 sort 0}
+do_test where7-2.139.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=22
+ OR b=36
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR ((a BETWEEN 81 AND 83) AND a!=82)
+ }
+} {22 31 57 59 81 83 scan 0 sort 0}
+do_test where7-2.139.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=22
+ OR b=36
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR ((a BETWEEN 81 AND 83) AND a!=82)
+ }
+} {22 31 57 59 81 83 scan 0 sort 0}
+do_test where7-2.140.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=253
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ }
+} {23 60 scan 0 sort 0}
+do_test where7-2.140.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=253
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ }
+} {23 60 scan 0 sort 0}
+do_test where7-2.141.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR b=641
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ }
+} {1 15 27 36 38 41 53 67 79 93 scan 0 sort 0}
+do_test where7-2.141.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR b=641
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ }
+} {1 15 27 36 38 41 53 67 79 93 scan 0 sort 0}
+do_test where7-2.142.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=30030
+ OR a=18
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR b=11
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR a=52
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR a=13
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ }
+} {1 13 18 22 40 44 46 52 65 88 89 90 scan 0 sort 0}
+do_test where7-2.142.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=30030
+ OR a=18
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR b=11
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR a=52
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR a=13
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ }
+} {1 13 18 22 40 44 46 52 65 88 89 90 scan 0 sort 0}
+do_test where7-2.143.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=23023
+ OR f='efghijklm'
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR b=1045
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR f='uvwxyzabc'
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ }
+} {4 20 24 30 39 41 46 50 56 67 68 69 72 76 82 95 98 scan 0 sort 0}
+do_test where7-2.143.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=23023
+ OR f='efghijklm'
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR b=1045
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR f='uvwxyzabc'
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ }
+} {4 20 24 30 39 41 46 50 56 67 68 69 72 76 82 95 98 scan 0 sort 0}
+do_test where7-2.144.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=476
+ OR a=11
+ OR a=52
+ OR b=858
+ OR b=264
+ OR f='wxyzabcde'
+ OR c=18018
+ OR b=597
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ }
+} {11 22 24 48 52 53 54 69 74 78 100 scan 0 sort 0}
+do_test where7-2.144.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=476
+ OR a=11
+ OR a=52
+ OR b=858
+ OR b=264
+ OR f='wxyzabcde'
+ OR c=18018
+ OR b=597
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ }
+} {11 22 24 48 52 53 54 69 74 78 100 scan 0 sort 0}
+do_test where7-2.145.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=91
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR b=102
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR b=784
+ }
+} {12 21 22 36 59 61 85 89 91 scan 0 sort 0}
+do_test where7-2.145.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=91
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR b=102
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR b=784
+ }
+} {12 21 22 36 59 61 85 89 91 scan 0 sort 0}
+do_test where7-2.146.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR b=990
+ OR a=52
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ }
+} {14 38 52 90 91 scan 0 sort 0}
+do_test where7-2.146.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR b=990
+ OR a=52
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ }
+} {14 38 52 90 91 scan 0 sort 0}
+do_test where7-2.147.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=22022
+ OR b=960
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR a=48
+ OR b=729
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR a=44
+ OR b=773
+ }
+} {41 43 44 45 48 64 65 66 scan 0 sort 0}
+do_test where7-2.147.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=22022
+ OR b=960
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR a=48
+ OR b=729
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR a=44
+ OR b=773
+ }
+} {41 43 44 45 48 64 65 66 scan 0 sort 0}
+do_test where7-2.148.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 68 AND 70) AND a!=69)
+ OR b=421
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR c=22022
+ OR b=825
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ }
+} {2 6 17 19 22 24 29 32 58 64 65 66 68 70 75 84 89 scan 0 sort 0}
+do_test where7-2.148.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 68 AND 70) AND a!=69)
+ OR b=421
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR c=22022
+ OR b=825
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ }
+} {2 6 17 19 22 24 29 32 58 64 65 66 68 70 75 84 89 scan 0 sort 0}
+do_test where7-2.149.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR b=484
+ OR b=1026
+ OR a=90
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR b=608
+ OR a=32
+ }
+} {32 44 74 90 scan 0 sort 0}
+do_test where7-2.149.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR b=484
+ OR b=1026
+ OR a=90
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR b=608
+ OR a=32
+ }
+} {32 44 74 90 scan 0 sort 0}
+do_test where7-2.150.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c<=10
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR b=154
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR b=880
+ OR a=55
+ OR b=773
+ OR b=319
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ }
+} {14 29 55 76 77 80 83 scan 0 sort 0}
+do_test where7-2.150.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c<=10
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR b=154
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR b=880
+ OR a=55
+ OR b=773
+ OR b=319
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ }
+} {14 29 55 76 77 80 83 scan 0 sort 0}
+do_test where7-2.151.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR f='mnopqrstu'
+ OR a=62
+ }
+} {8 12 38 62 64 90 scan 0 sort 0}
+do_test where7-2.151.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR f='mnopqrstu'
+ OR a=62
+ }
+} {8 12 38 62 64 90 scan 0 sort 0}
+do_test where7-2.152.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=33
+ OR b=1045
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR c=13013
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR b=124
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ }
+} {33 37 38 39 40 88 90 95 scan 0 sort 0}
+do_test where7-2.152.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=33
+ OR b=1045
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR c=13013
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR b=124
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ }
+} {33 37 38 39 40 88 90 95 scan 0 sort 0}
+do_test where7-2.153.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=883
+ OR c=32032
+ OR f='fghijklmn'
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR b=421
+ OR b=803
+ OR c=4004
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ }
+} {2 5 10 11 12 28 31 49 51 54 57 73 80 83 94 95 96 scan 0 sort 0}
+do_test where7-2.153.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=883
+ OR c=32032
+ OR f='fghijklmn'
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR b=421
+ OR b=803
+ OR c=4004
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ }
+} {2 5 10 11 12 28 31 49 51 54 57 73 80 83 94 95 96 scan 0 sort 0}
+do_test where7-2.154.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR b=99
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ }
+} {9 16 42 68 72 94 scan 0 sort 0}
+do_test where7-2.154.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR b=99
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ }
+} {9 16 42 68 72 94 scan 0 sort 0}
+do_test where7-2.155.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='defghijkl'
+ OR b=308
+ }
+} {3 28 29 55 81 scan 0 sort 0}
+do_test where7-2.155.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='defghijkl'
+ OR b=308
+ }
+} {3 28 29 55 81 scan 0 sort 0}
+do_test where7-2.156.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=795
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR f='jklmnopqr'
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR b=1056
+ }
+} {2 9 28 35 51 54 61 80 87 96 scan 0 sort 0}
+do_test where7-2.156.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=795
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR f='jklmnopqr'
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR b=1056
+ }
+} {2 9 28 35 51 54 61 80 87 96 scan 0 sort 0}
+do_test where7-2.157.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=47
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR b=410
+ OR b=682
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ OR f='hijklmnop'
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR b=168
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR a=32
+ OR a=72
+ }
+} {7 32 33 40 47 51 59 62 72 85 94 98 100 scan 0 sort 0}
+do_test where7-2.157.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=47
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR b=410
+ OR b=682
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ OR f='hijklmnop'
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR b=168
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR a=32
+ OR a=72
+ }
+} {7 32 33 40 47 51 59 62 72 85 94 98 100 scan 0 sort 0}
+do_test where7-2.158.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=616
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR a=96
+ }
+} {25 27 38 56 96 scan 0 sort 0}
+do_test where7-2.158.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=616
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR a=96
+ }
+} {25 27 38 56 96 scan 0 sort 0}
+do_test where7-2.159.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR b=352
+ }
+} {32 66 scan 0 sort 0}
+do_test where7-2.159.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR b=352
+ }
+} {32 66 scan 0 sort 0}
+do_test where7-2.160.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=795
+ OR c=13013
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR b=597
+ }
+} {28 37 38 39 scan 0 sort 0}
+do_test where7-2.160.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=795
+ OR c=13013
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR b=597
+ }
+} {28 37 38 39 scan 0 sort 0}
+do_test where7-2.161.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=23
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR b=641
+ OR b=352
+ OR b=179
+ OR b=806
+ OR b=839
+ OR b=33
+ }
+} {3 23 32 68 scan 0 sort 0}
+do_test where7-2.161.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=23
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR b=641
+ OR b=352
+ OR b=179
+ OR b=806
+ OR b=839
+ OR b=33
+ }
+} {3 23 32 68 scan 0 sort 0}
+do_test where7-2.162.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1070
+ OR b=1078
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ OR c=12012
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR b=319
+ OR c=5005
+ OR 1000000<b
+ OR b=1037
+ OR b=234
+ }
+} {11 13 14 15 29 34 35 36 84 98 scan 0 sort 0}
+do_test where7-2.162.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1070
+ OR b=1078
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ OR c=12012
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR b=319
+ OR c=5005
+ OR 1000000<b
+ OR b=1037
+ OR b=234
+ }
+} {11 13 14 15 29 34 35 36 84 98 scan 0 sort 0}
+do_test where7-2.163.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='cdefghijk'
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR (d>=59.0 AND d<60.0 AND d NOT NULL)
+ }
+} {2 17 28 43 54 59 69 80 81 95 scan 0 sort 0}
+do_test where7-2.163.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='cdefghijk'
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR (d>=59.0 AND d<60.0 AND d NOT NULL)
+ }
+} {2 17 28 43 54 59 69 80 81 95 scan 0 sort 0}
+do_test where7-2.164.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=65
+ OR c=14014
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR a=47
+ OR b=220
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ }
+} {20 37 40 41 42 47 65 88 scan 0 sort 0}
+do_test where7-2.164.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=65
+ OR c=14014
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR a=47
+ OR b=220
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ }
+} {20 37 40 41 42 47 65 88 scan 0 sort 0}
+do_test where7-2.165.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR b=891
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR b=484
+ OR a=62
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ }
+} {35 44 57 62 81 86 scan 0 sort 0}
+do_test where7-2.165.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR b=891
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR b=484
+ OR a=62
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ }
+} {35 44 57 62 81 86 scan 0 sort 0}
+do_test where7-2.166.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=363
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR a=39
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ }
+} {2 10 25 33 39 46 54 58 60 scan 0 sort 0}
+do_test where7-2.166.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=363
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR a=39
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ }
+} {2 10 25 33 39 46 54 58 60 scan 0 sort 0}
+do_test where7-2.167.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=30030
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR b=850
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ }
+} {20 46 52 72 88 89 90 98 scan 0 sort 0}
+do_test where7-2.167.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=30030
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR b=850
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ }
+} {20 46 52 72 88 89 90 98 scan 0 sort 0}
+do_test where7-2.168.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR b=80
+ }
+} {23 91 scan 0 sort 0}
+do_test where7-2.168.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR b=80
+ }
+} {23 91 scan 0 sort 0}
+do_test where7-2.169.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 59 AND 61) AND a!=60)
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR b=462
+ OR a=51
+ OR b=344
+ OR b=333
+ OR ((a BETWEEN 61 AND 63) AND a!=62)
+ }
+} {42 51 59 61 63 77 scan 0 sort 0}
+do_test where7-2.169.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 59 AND 61) AND a!=60)
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR b=462
+ OR a=51
+ OR b=344
+ OR b=333
+ OR ((a BETWEEN 61 AND 63) AND a!=62)
+ }
+} {42 51 59 61 63 77 scan 0 sort 0}
+do_test where7-2.170.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=586
+ OR a=21
+ OR b=638
+ }
+} {21 58 scan 0 sort 0}
+do_test where7-2.170.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=586
+ OR a=21
+ OR b=638
+ }
+} {21 58 scan 0 sort 0}
+do_test where7-2.171.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=179
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ }
+} {2 4 13 40 42 72 74 scan 0 sort 0}
+do_test where7-2.171.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=179
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ }
+} {2 4 13 40 42 72 74 scan 0 sort 0}
+do_test where7-2.172.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=333
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR b=407
+ OR a=5
+ OR b=817
+ OR b=891
+ }
+} {5 37 53 62 81 scan 0 sort 0}
+do_test where7-2.172.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=333
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR b=407
+ OR a=5
+ OR b=817
+ OR b=891
+ }
+} {5 37 53 62 81 scan 0 sort 0}
+do_test where7-2.173.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b<0
+ OR b=352
+ OR b=517
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ OR b=1012
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ }
+} {11 12 13 14 32 47 92 97 scan 0 sort 0}
+do_test where7-2.173.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b<0
+ OR b=352
+ OR b=517
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ OR b=1012
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ }
+} {11 12 13 14 32 47 92 97 scan 0 sort 0}
+do_test where7-2.174.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='qponmlk' AND f GLOB 'pqrst*')
+ OR c<=10
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR a=32
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR d<0.0
+ }
+} {12 14 32 41 scan 0 sort 0}
+do_test where7-2.174.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='qponmlk' AND f GLOB 'pqrst*')
+ OR c<=10
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR a=32
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR d<0.0
+ }
+} {12 14 32 41 scan 0 sort 0}
+do_test where7-2.175.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=1045
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR a=26
+ OR (g='gfedcba' AND f GLOB 'opqrs*')
+ }
+} {20 22 26 78 92 95 scan 0 sort 0}
+do_test where7-2.175.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=1045
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR a=26
+ OR (g='gfedcba' AND f GLOB 'opqrs*')
+ }
+} {20 22 26 78 92 95 scan 0 sort 0}
+do_test where7-2.176.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=49
+ OR b=58
+ }
+} {49 scan 0 sort 0}
+do_test where7-2.176.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=49
+ OR b=58
+ }
+} {49 scan 0 sort 0}
+do_test where7-2.177.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ OR c=32032
+ OR b=289
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {3 14 16 17 19 75 94 95 96 scan 0 sort 0}
+do_test where7-2.177.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ OR c=32032
+ OR b=289
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {3 14 16 17 19 75 94 95 96 scan 0 sort 0}
+do_test where7-2.178.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 15 AND 17) AND a!=16)
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR b=33
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ }
+} {3 15 17 43 57 59 69 95 scan 0 sort 0}
+do_test where7-2.178.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 15 AND 17) AND a!=16)
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR b=33
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ }
+} {3 15 17 43 57 59 69 95 scan 0 sort 0}
+do_test where7-2.179.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=828
+ OR b=341
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR b=902
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=242
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ }
+} {1 2 16 22 31 42 64 66 68 82 91 94 95 scan 0 sort 0}
+do_test where7-2.179.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=828
+ OR b=341
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR b=902
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=242
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ }
+} {1 2 16 22 31 42 64 66 68 82 91 94 95 scan 0 sort 0}
+do_test where7-2.180.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='nmlkjih' AND f GLOB 'efghi*')
+ OR b=982
+ OR b=781
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR d>1e10
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ }
+} {56 66 68 71 scan 0 sort 0}
+do_test where7-2.180.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='nmlkjih' AND f GLOB 'efghi*')
+ OR b=982
+ OR b=781
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR d>1e10
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ }
+} {56 66 68 71 scan 0 sort 0}
+do_test where7-2.181.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR a=31
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR a=76
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR b=176
+ }
+} {8 16 23 31 34 57 59 60 69 74 76 86 scan 0 sort 0}
+do_test where7-2.181.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR a=31
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR a=76
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR b=176
+ }
+} {8 16 23 31 34 57 59 60 69 74 76 86 scan 0 sort 0}
+do_test where7-2.182.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR b=14
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR f='zabcdefgh'
+ }
+} {12 25 47 51 55 59 60 61 77 88 90 scan 0 sort 0}
+do_test where7-2.182.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR b=14
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR f='zabcdefgh'
+ }
+} {12 25 47 51 55 59 60 61 77 88 90 scan 0 sort 0}
+do_test where7-2.183.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR b=286
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR b=91
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ }
+} {25 26 31 43 45 scan 0 sort 0}
+do_test where7-2.183.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR b=286
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR b=91
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ }
+} {25 26 31 43 45 scan 0 sort 0}
+do_test where7-2.184.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR c=19019
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ OR b=374
+ }
+} {22 34 48 55 56 57 65 74 100 scan 0 sort 0}
+do_test where7-2.184.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR c=19019
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ OR b=374
+ }
+} {22 34 48 55 56 57 65 74 100 scan 0 sort 0}
+do_test where7-2.185.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE g IS NULL
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ }
+} {48 scan 0 sort 0}
+do_test where7-2.185.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE g IS NULL
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ }
+} {48 scan 0 sort 0}
+do_test where7-2.186.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=4
+ OR b=407
+ }
+} {4 37 scan 0 sort 0}
+do_test where7-2.186.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=4
+ OR b=407
+ }
+} {4 37 scan 0 sort 0}
+do_test where7-2.187.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=564
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR b=234
+ OR b=641
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR a=98
+ }
+} {1 5 12 13 27 39 53 65 66 68 79 91 98 scan 0 sort 0}
+do_test where7-2.187.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=564
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR b=234
+ OR b=641
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR a=98
+ }
+} {1 5 12 13 27 39 53 65 66 68 79 91 98 scan 0 sort 0}
+do_test where7-2.188.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=73
+ OR b=44
+ OR b=539
+ OR c=11011
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=69
+ OR b=1001
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ }
+} {4 23 26 31 32 33 34 49 73 81 91 95 scan 0 sort 0}
+do_test where7-2.188.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=73
+ OR b=44
+ OR b=539
+ OR c=11011
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=69
+ OR b=1001
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ }
+} {4 23 26 31 32 33 34 49 73 81 91 95 scan 0 sort 0}
+do_test where7-2.189.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=264
+ OR b=143
+ OR a=48
+ }
+} {13 24 48 scan 0 sort 0}
+do_test where7-2.189.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=264
+ OR b=143
+ OR a=48
+ }
+} {13 24 48 scan 0 sort 0}
+do_test where7-2.190.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1001
+ OR b=1070
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR b=14
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR a=66
+ }
+} {18 56 58 66 72 74 91 scan 0 sort 0}
+do_test where7-2.190.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1001
+ OR b=1070
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR b=14
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR a=66
+ }
+} {18 56 58 66 72 74 91 scan 0 sort 0}
+do_test where7-2.191.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=23023
+ OR (d>=83.0 AND d<84.0 AND d NOT NULL)
+ OR a=66
+ OR (g='onmlkji' AND f GLOB 'zabcd*')
+ OR a=51
+ OR a=23
+ OR c=4004
+ }
+} {10 11 12 23 51 66 67 68 69 83 scan 0 sort 0}
+do_test where7-2.191.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=23023
+ OR (d>=83.0 AND d<84.0 AND d NOT NULL)
+ OR a=66
+ OR (g='onmlkji' AND f GLOB 'zabcd*')
+ OR a=51
+ OR a=23
+ OR c=4004
+ }
+} {10 11 12 23 51 66 67 68 69 83 scan 0 sort 0}
+do_test where7-2.192.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=36
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR a=80
+ }
+} {37 80 scan 0 sort 0}
+do_test where7-2.192.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=36
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR a=80
+ }
+} {37 80 scan 0 sort 0}
+do_test where7-2.193.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR a=55
+ OR f='efghijklm'
+ OR a=8
+ OR a=80
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR b=256
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ }
+} {4 8 30 34 37 39 55 56 60 72 80 82 86 scan 0 sort 0}
+do_test where7-2.193.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR a=55
+ OR f='efghijklm'
+ OR a=8
+ OR a=80
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR b=256
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ }
+} {4 8 30 34 37 39 55 56 60 72 80 82 86 scan 0 sort 0}
+do_test where7-2.194.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR b=836
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR a=91
+ OR b=594
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ }
+} {2 8 28 47 54 76 80 87 91 scan 0 sort 0}
+do_test where7-2.194.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR b=836
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR a=91
+ OR b=594
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ }
+} {2 8 28 47 54 76 80 87 91 scan 0 sort 0}
+do_test where7-2.195.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='tsrqpon' AND f GLOB 'yzabc*')
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 62 AND 64) AND a!=63)
+ OR c=6006
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ }
+} {12 16 17 18 24 43 50 52 62 64 88 90 scan 0 sort 0}
+do_test where7-2.195.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='tsrqpon' AND f GLOB 'yzabc*')
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 62 AND 64) AND a!=63)
+ OR c=6006
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ }
+} {12 16 17 18 24 43 50 52 62 64 88 90 scan 0 sort 0}
+do_test where7-2.196.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 83 AND 85) AND a!=84)
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR a=13
+ OR b=121
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR b=660
+ OR b=792
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ }
+} {6 11 12 13 14 16 18 44 60 72 83 85 scan 0 sort 0}
+do_test where7-2.196.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 83 AND 85) AND a!=84)
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR a=13
+ OR b=121
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR b=660
+ OR b=792
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ }
+} {6 11 12 13 14 16 18 44 60 72 83 85 scan 0 sort 0}
+do_test where7-2.197.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1089
+ OR b=495
+ OR b=157
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ OR (d>=59.0 AND d<60.0 AND d NOT NULL)
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR f='wxyzabcde'
+ }
+} {1 7 20 22 45 46 48 59 72 74 98 99 100 scan 0 sort 0}
+do_test where7-2.197.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1089
+ OR b=495
+ OR b=157
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ OR (d>=59.0 AND d<60.0 AND d NOT NULL)
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR f='wxyzabcde'
+ }
+} {1 7 20 22 45 46 48 59 72 74 98 99 100 scan 0 sort 0}
+do_test where7-2.198.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='bcdefghij'
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR b=157
+ OR b=267
+ OR c=34034
+ }
+} {1 27 32 40 42 53 79 100 scan 0 sort 0}
+do_test where7-2.198.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='bcdefghij'
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR b=157
+ OR b=267
+ OR c=34034
+ }
+} {1 27 32 40 42 53 79 100 scan 0 sort 0}
+do_test where7-2.199.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=19
+ OR a=23
+ OR c<=10
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ }
+} {19 23 66 scan 0 sort 0}
+do_test where7-2.199.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=19
+ OR a=23
+ OR c<=10
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ }
+} {19 23 66 scan 0 sort 0}
+do_test where7-2.200.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 1 AND 3) AND a!=2)
+ OR b=792
+ OR b=803
+ OR b=36
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ }
+} {1 3 27 53 72 73 79 scan 0 sort 0}
+do_test where7-2.200.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 1 AND 3) AND a!=2)
+ OR b=792
+ OR b=803
+ OR b=36
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ }
+} {1 3 27 53 72 73 79 scan 0 sort 0}
+do_test where7-2.201.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR f='jklmnopqr'
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ OR b=891
+ OR a=40
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ }
+} {9 20 35 40 50 61 67 71 73 76 78 81 87 scan 0 sort 0}
+do_test where7-2.201.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR f='jklmnopqr'
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ OR b=891
+ OR a=40
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ }
+} {9 20 35 40 50 61 67 71 73 76 78 81 87 scan 0 sort 0}
+do_test where7-2.202.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR a=32
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR a=95
+ OR d>1e10
+ OR b=429
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR c=10010
+ OR ((a BETWEEN 83 AND 85) AND a!=84)
+ }
+} {15 28 29 30 32 39 54 76 83 85 88 95 scan 0 sort 0}
+do_test where7-2.202.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR a=32
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR a=95
+ OR d>1e10
+ OR b=429
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR c=10010
+ OR ((a BETWEEN 83 AND 85) AND a!=84)
+ }
+} {15 28 29 30 32 39 54 76 83 85 88 95 scan 0 sort 0}
+do_test where7-2.203.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'defgh*')
+ OR a=22
+ OR a=26
+ OR a=81
+ OR a=53
+ OR ((a BETWEEN 92 AND 94) AND a!=93)
+ OR c=30030
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR a=82
+ OR b=594
+ }
+} {3 8 22 26 53 54 81 82 88 89 90 92 94 scan 0 sort 0}
+do_test where7-2.203.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'defgh*')
+ OR a=22
+ OR a=26
+ OR a=81
+ OR a=53
+ OR ((a BETWEEN 92 AND 94) AND a!=93)
+ OR c=30030
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR a=82
+ OR b=594
+ }
+} {3 8 22 26 53 54 81 82 88 89 90 92 94 scan 0 sort 0}
+do_test where7-2.204.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 34 AND 36) AND a!=35)
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR a=83
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=1092
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR b=25
+ }
+} {12 30 34 36 57 68 83 86 99 scan 0 sort 0}
+do_test where7-2.204.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 34 AND 36) AND a!=35)
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR a=83
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=1092
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR b=25
+ }
+} {12 30 34 36 57 68 83 86 99 scan 0 sort 0}
+do_test where7-2.205.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=20
+ OR b=421
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR a=50
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ }
+} {5 20 40 50 53 scan 0 sort 0}
+do_test where7-2.205.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=20
+ OR b=421
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR a=50
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ }
+} {5 20 40 50 53 scan 0 sort 0}
+do_test where7-2.206.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=960
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ }
+} {13 39 65 91 scan 0 sort 0}
+do_test where7-2.206.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=960
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ }
+} {13 39 65 91 scan 0 sort 0}
+do_test where7-2.207.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=891
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR f='nopqrstuv'
+ }
+} {13 31 39 65 81 91 scan 0 sort 0}
+do_test where7-2.207.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=891
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR f='nopqrstuv'
+ }
+} {13 31 39 65 81 91 scan 0 sort 0}
+do_test where7-2.208.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=157
+ OR b=289
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=1001
+ OR b=707
+ }
+} {32 34 91 scan 0 sort 0}
+do_test where7-2.208.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=157
+ OR b=289
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=1001
+ OR b=707
+ }
+} {32 34 91 scan 0 sort 0}
+do_test where7-2.209.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='edcbazy' AND f GLOB 'wxyza*')
+ OR b=957
+ OR ((a BETWEEN 48 AND 50) AND a!=49)
+ }
+} {48 50 87 100 scan 0 sort 0}
+do_test where7-2.209.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='edcbazy' AND f GLOB 'wxyza*')
+ OR b=957
+ OR ((a BETWEEN 48 AND 50) AND a!=49)
+ }
+} {48 50 87 100 scan 0 sort 0}
+do_test where7-2.210.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR a=77
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ }
+} {40 77 85 scan 0 sort 0}
+do_test where7-2.210.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR a=77
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ }
+} {40 77 85 scan 0 sort 0}
+do_test where7-2.211.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR b=11
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR a=99
+ }
+} {1 14 16 38 66 96 99 scan 0 sort 0}
+do_test where7-2.211.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR b=11
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR a=99
+ }
+} {1 14 16 38 66 96 99 scan 0 sort 0}
+do_test where7-2.212.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='fghijklmn'
+ OR a=16
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR b=80
+ }
+} {3 5 9 11 16 31 52 57 60 62 71 83 90 92 scan 0 sort 0}
+do_test where7-2.212.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='fghijklmn'
+ OR a=16
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR b=80
+ }
+} {3 5 9 11 16 31 52 57 60 62 71 83 90 92 scan 0 sort 0}
+do_test where7-2.213.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR a=44
+ OR a=43
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ OR b=25
+ }
+} {12 43 44 66 scan 0 sort 0}
+do_test where7-2.213.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR a=44
+ OR a=43
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ OR b=25
+ }
+} {12 43 44 66 scan 0 sort 0}
+do_test where7-2.214.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='vwxyzabcd'
+ OR a=73
+ OR b=597
+ }
+} {21 47 73 99 scan 0 sort 0}
+do_test where7-2.214.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='vwxyzabcd'
+ OR a=73
+ OR b=597
+ }
+} {21 47 73 99 scan 0 sort 0}
+do_test where7-2.215.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=22
+ OR ((a BETWEEN 61 AND 63) AND a!=62)
+ OR e IS NULL
+ OR a=1
+ }
+} {1 2 61 63 scan 0 sort 0}
+do_test where7-2.215.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=22
+ OR ((a BETWEEN 61 AND 63) AND a!=62)
+ OR e IS NULL
+ OR a=1
+ }
+} {1 2 61 63 scan 0 sort 0}
+do_test where7-2.216.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'opqrs*')
+ OR b=1015
+ OR c=16016
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR f='abcdefghi'
+ OR b=605
+ OR a=63
+ }
+} {3 19 26 45 46 47 48 52 55 63 71 78 92 97 scan 0 sort 0}
+do_test where7-2.216.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'opqrs*')
+ OR b=1015
+ OR c=16016
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR f='abcdefghi'
+ OR b=605
+ OR a=63
+ }
+} {3 19 26 45 46 47 48 52 55 63 71 78 92 97 scan 0 sort 0}
+do_test where7-2.217.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR b=641
+ OR b=795
+ }
+} {1 44 scan 0 sort 0}
+do_test where7-2.217.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR b=641
+ OR b=795
+ }
+} {1 44 scan 0 sort 0}
+do_test where7-2.218.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='fghijklmn'
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ }
+} {5 15 31 44 57 83 scan 0 sort 0}
+do_test where7-2.218.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='fghijklmn'
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ }
+} {5 15 31 44 57 83 scan 0 sort 0}
+do_test where7-2.219.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 99 AND 101) AND a!=100)
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR a=92
+ OR b=1100
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ }
+} {30 32 72 74 85 87 92 98 99 100 scan 0 sort 0}
+do_test where7-2.219.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 99 AND 101) AND a!=100)
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR a=92
+ OR b=1100
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ }
+} {30 32 72 74 85 87 92 98 99 100 scan 0 sort 0}
+do_test where7-2.220.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=880
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR b=1089
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR f IS NULL
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ }
+} {5 12 16 31 57 69 71 80 83 86 97 99 scan 0 sort 0}
+do_test where7-2.220.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=880
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR b=1089
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR f IS NULL
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ }
+} {5 12 16 31 57 69 71 80 83 86 97 99 scan 0 sort 0}
+do_test where7-2.221.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1026
+ OR b=407
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR b=564
+ OR c=23023
+ OR b=891
+ OR c=22022
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ }
+} {9 11 21 22 24 31 34 37 64 65 66 67 68 69 81 scan 0 sort 0}
+do_test where7-2.221.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1026
+ OR b=407
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR b=564
+ OR c=23023
+ OR b=891
+ OR c=22022
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ }
+} {9 11 21 22 24 31 34 37 64 65 66 67 68 69 81 scan 0 sort 0}
+do_test where7-2.222.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR a=72
+ OR a=43
+ }
+} {43 71 72 73 scan 0 sort 0}
+do_test where7-2.222.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR a=72
+ OR a=43
+ }
+} {43 71 72 73 scan 0 sort 0}
+do_test where7-2.223.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 67 AND 69) AND a!=68)
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ OR c=18018
+ OR b=792
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR f='uvwxyzabc'
+ OR (d>=74.0 AND d<75.0 AND d NOT NULL)
+ }
+} {8 20 46 52 53 54 61 67 69 72 74 77 79 81 91 98 scan 0 sort 0}
+do_test where7-2.223.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 67 AND 69) AND a!=68)
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ OR c=18018
+ OR b=792
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR f='uvwxyzabc'
+ OR (d>=74.0 AND d<75.0 AND d NOT NULL)
+ }
+} {8 20 46 52 53 54 61 67 69 72 74 77 79 81 91 98 scan 0 sort 0}
+do_test where7-2.224.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=429
+ OR (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR b=1070
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ }
+} {4 17 30 33 39 40 56 82 scan 0 sort 0}
+do_test where7-2.224.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=429
+ OR (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR b=1070
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ }
+} {4 17 30 33 39 40 56 82 scan 0 sort 0}
+do_test where7-2.225.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=572
+ }
+} {52 61 scan 0 sort 0}
+do_test where7-2.225.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=572
+ }
+} {52 61 scan 0 sort 0}
+do_test where7-2.226.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 62 AND 64) AND a!=63)
+ OR f='abcdefghi'
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ }
+} {8 26 52 62 64 78 scan 0 sort 0}
+do_test where7-2.226.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 62 AND 64) AND a!=63)
+ OR f='abcdefghi'
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ }
+} {8 26 52 62 64 78 scan 0 sort 0}
+do_test where7-2.227.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=40
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ }
+} {40 85 87 scan 0 sort 0}
+do_test where7-2.227.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=40
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ }
+} {40 85 87 scan 0 sort 0}
+do_test where7-2.228.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=43
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR a=1
+ OR ((a BETWEEN 75 AND 77) AND a!=76)
+ OR a=75
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ }
+} {1 43 44 46 59 61 75 77 83 scan 0 sort 0}
+do_test where7-2.228.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=43
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR a=1
+ OR ((a BETWEEN 75 AND 77) AND a!=76)
+ OR a=75
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ }
+} {1 43 44 46 59 61 75 77 83 scan 0 sort 0}
+do_test where7-2.229.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='gfedcba' AND f GLOB 'nopqr*')
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR b=231
+ OR a=87
+ }
+} {8 21 34 60 86 87 91 scan 0 sort 0}
+do_test where7-2.229.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='gfedcba' AND f GLOB 'nopqr*')
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR b=231
+ OR a=87
+ }
+} {8 21 34 60 86 87 91 scan 0 sort 0}
+do_test where7-2.230.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=77
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ OR c=24024
+ OR c=5005
+ }
+} {13 14 15 33 65 70 71 72 77 scan 0 sort 0}
+do_test where7-2.230.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=77
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ OR c=24024
+ OR c=5005
+ }
+} {13 14 15 33 65 70 71 72 77 scan 0 sort 0}
+do_test where7-2.231.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR b=682
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ }
+} {22 29 34 60 62 64 65 66 89 91 scan 0 sort 0}
+do_test where7-2.231.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR b=682
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ }
+} {22 29 34 60 62 64 65 66 89 91 scan 0 sort 0}
+do_test where7-2.232.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=212
+ OR b=121
+ OR c=2002
+ OR ((a BETWEEN 84 AND 86) AND a!=85)
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ }
+} {4 5 6 11 75 84 86 scan 0 sort 0}
+do_test where7-2.232.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=212
+ OR b=121
+ OR c=2002
+ OR ((a BETWEEN 84 AND 86) AND a!=85)
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ }
+} {4 5 6 11 75 84 86 scan 0 sort 0}
+do_test where7-2.233.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR f='abcdefghi'
+ OR b=267
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR a=82
+ OR a=54
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=1078
+ }
+} {16 20 26 52 54 55 78 82 98 scan 0 sort 0}
+do_test where7-2.233.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR f='abcdefghi'
+ OR b=267
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR a=82
+ OR a=54
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=1078
+ }
+} {16 20 26 52 54 55 78 82 98 scan 0 sort 0}
+do_test where7-2.234.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR f='hijklmnop'
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ }
+} {7 33 34 59 85 93 scan 0 sort 0}
+do_test where7-2.234.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR f='hijklmnop'
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ }
+} {7 33 34 59 85 93 scan 0 sort 0}
+do_test where7-2.235.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 98 AND 100) AND a!=99)
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ OR a=18
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR 1000000<b
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ }
+} {7 14 18 31 33 37 40 51 53 59 66 85 92 94 98 100 scan 0 sort 0}
+do_test where7-2.235.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 98 AND 100) AND a!=99)
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ OR a=18
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR 1000000<b
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ }
+} {7 14 18 31 33 37 40 51 53 59 66 85 92 94 98 100 scan 0 sort 0}
+do_test where7-2.236.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1001
+ OR b=168
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ }
+} {7 33 59 85 89 91 scan 0 sort 0}
+do_test where7-2.236.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1001
+ OR b=168
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ }
+} {7 33 59 85 89 91 scan 0 sort 0}
+do_test where7-2.237.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=51
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR b=330
+ }
+} {30 51 96 98 scan 0 sort 0}
+do_test where7-2.237.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=51
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR b=330
+ }
+} {30 51 96 98 scan 0 sort 0}
+do_test where7-2.238.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR b=704
+ OR a=62
+ OR f='pqrstuvwx'
+ OR b=495
+ OR c=26026
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR b<0
+ OR b=597
+ }
+} {15 41 45 62 64 67 68 71 76 77 78 93 scan 0 sort 0}
+do_test where7-2.238.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR b=704
+ OR a=62
+ OR f='pqrstuvwx'
+ OR b=495
+ OR c=26026
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR b<0
+ OR b=597
+ }
+} {15 41 45 62 64 67 68 71 76 77 78 93 scan 0 sort 0}
+do_test where7-2.239.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR b=520
+ OR ((a BETWEEN 47 AND 49) AND a!=48)
+ OR f IS NULL
+ }
+} {2 47 49 87 89 scan 0 sort 0}
+do_test where7-2.239.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR b=520
+ OR ((a BETWEEN 47 AND 49) AND a!=48)
+ OR f IS NULL
+ }
+} {2 47 49 87 89 scan 0 sort 0}
+do_test where7-2.240.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=14014
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=572
+ OR c=15015
+ }
+} {40 41 42 43 44 45 52 95 scan 0 sort 0}
+do_test where7-2.240.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=14014
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=572
+ OR c=15015
+ }
+} {40 41 42 43 44 45 52 95 scan 0 sort 0}
+do_test where7-2.241.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR b=850
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ OR b=88
+ OR f='hijklmnop'
+ OR b=806
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR b=88
+ }
+} {3 7 8 15 17 29 33 46 55 59 65 81 85 scan 0 sort 0}
+do_test where7-2.241.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR b=850
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ OR b=88
+ OR f='hijklmnop'
+ OR b=806
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR b=88
+ }
+} {3 7 8 15 17 29 33 46 55 59 65 81 85 scan 0 sort 0}
+do_test where7-2.242.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=817
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR a=36
+ OR b=960
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR b=374
+ OR b=938
+ OR b=773
+ OR (g='jihgfed' AND f GLOB 'zabcd*')
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ }
+} {34 36 55 58 63 77 scan 0 sort 0}
+do_test where7-2.242.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=817
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR a=36
+ OR b=960
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR b=374
+ OR b=938
+ OR b=773
+ OR (g='jihgfed' AND f GLOB 'zabcd*')
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ }
+} {34 36 55 58 63 77 scan 0 sort 0}
+do_test where7-2.243.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=146
+ }
+} {69 scan 0 sort 0}
+do_test where7-2.243.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=146
+ }
+} {69 scan 0 sort 0}
+do_test where7-2.244.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='pqrstuvwx'
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR b=704
+ OR a=18
+ }
+} {6 8 15 18 41 64 67 76 78 93 scan 0 sort 0}
+do_test where7-2.244.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='pqrstuvwx'
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR b=704
+ OR a=18
+ }
+} {6 8 15 18 41 64 67 76 78 93 scan 0 sort 0}
+do_test where7-2.245.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR b=399
+ OR b=1004
+ OR c=16016
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR b=671
+ OR a=25
+ OR a=30
+ OR a=8
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ }
+} {5 8 19 25 30 31 45 46 47 48 61 71 97 scan 0 sort 0}
+do_test where7-2.245.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR b=399
+ OR b=1004
+ OR c=16016
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR b=671
+ OR a=25
+ OR a=30
+ OR a=8
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ }
+} {5 8 19 25 30 31 45 46 47 48 61 71 97 scan 0 sort 0}
+do_test where7-2.246.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=561
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR b=594
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR b=861
+ OR (d>=90.0 AND d<91.0 AND d NOT NULL)
+ OR b=949
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ }
+} {18 28 30 39 41 51 54 90 scan 0 sort 0}
+do_test where7-2.246.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=561
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR b=594
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR b=861
+ OR (d>=90.0 AND d<91.0 AND d NOT NULL)
+ OR b=949
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ }
+} {18 28 30 39 41 51 54 90 scan 0 sort 0}
+do_test where7-2.247.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR a=83
+ OR c=26026
+ OR a=49
+ OR a=57
+ OR c=23023
+ OR f='uvwxyzabc'
+ }
+} {7 20 46 49 57 67 68 69 72 76 77 78 83 98 scan 0 sort 0}
+do_test where7-2.247.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR a=83
+ OR c=26026
+ OR a=49
+ OR a=57
+ OR c=23023
+ OR f='uvwxyzabc'
+ }
+} {7 20 46 49 57 67 68 69 72 76 77 78 83 98 scan 0 sort 0}
+do_test where7-2.248.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE d>1e10
+ OR b=355
+ OR f='stuvwxyza'
+ OR b=22
+ }
+} {2 18 44 70 96 scan 0 sort 0}
+do_test where7-2.248.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE d>1e10
+ OR b=355
+ OR f='stuvwxyza'
+ OR b=22
+ }
+} {2 18 44 70 96 scan 0 sort 0}
+do_test where7-2.249.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=451
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ }
+} {8 34 41 60 86 scan 0 sort 0}
+do_test where7-2.249.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=451
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ }
+} {8 34 41 60 86 scan 0 sort 0}
+do_test where7-2.250.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=47
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ }
+} {1 27 53 79 scan 0 sort 0}
+do_test where7-2.250.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=47
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ }
+} {1 27 53 79 scan 0 sort 0}
+do_test where7-2.251.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1037
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=344
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ }
+} {12 66 68 86 scan 0 sort 0}
+do_test where7-2.251.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1037
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=344
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ }
+} {12 66 68 86 scan 0 sort 0}
+do_test where7-2.252.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=506
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR b=429
+ OR b=275
+ }
+} {20 22 25 39 46 86 scan 0 sort 0}
+do_test where7-2.252.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=506
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR b=429
+ OR b=275
+ }
+} {20 22 25 39 46 86 scan 0 sort 0}
+do_test where7-2.253.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 60 AND 62) AND a!=61)
+ OR a=28
+ OR b=443
+ OR b=363
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR a=60
+ OR b=80
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR b=616
+ }
+} {28 33 47 56 60 62 scan 0 sort 0}
+do_test where7-2.253.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 60 AND 62) AND a!=61)
+ OR a=28
+ OR b=443
+ OR b=363
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR a=60
+ OR b=80
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR b=616
+ }
+} {28 33 47 56 60 62 scan 0 sort 0}
+do_test where7-2.254.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR b=660
+ }
+} {33 60 scan 0 sort 0}
+do_test where7-2.254.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR b=660
+ }
+} {33 60 scan 0 sort 0}
+do_test where7-2.255.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR a=43
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR b=586
+ OR c=17017
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR a=87
+ OR b=968
+ }
+} {7 21 43 47 49 50 51 64 66 73 87 88 99 scan 0 sort 0}
+do_test where7-2.255.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR a=43
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR b=586
+ OR c=17017
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR a=87
+ OR b=968
+ }
+} {7 21 43 47 49 50 51 64 66 73 87 88 99 scan 0 sort 0}
+do_test where7-2.256.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='klmnopqrs'
+ OR b=982
+ OR b=575
+ OR b=110
+ OR b=99
+ }
+} {9 10 36 62 88 scan 0 sort 0}
+do_test where7-2.256.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='klmnopqrs'
+ OR b=982
+ OR b=575
+ OR b=110
+ OR b=99
+ }
+} {9 10 36 62 88 scan 0 sort 0}
+do_test where7-2.257.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='rqponml' AND f GLOB 'jklmn*')
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR c>=34035
+ OR b=850
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=924
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR b=355
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ }
+} {4 32 34 35 37 56 78 84 86 scan 0 sort 0}
+do_test where7-2.257.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='rqponml' AND f GLOB 'jklmn*')
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR c>=34035
+ OR b=850
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=924
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR b=355
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ }
+} {4 32 34 35 37 56 78 84 86 scan 0 sort 0}
+do_test where7-2.258.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR b=982
+ OR ((a BETWEEN 81 AND 83) AND a!=82)
+ OR b=374
+ }
+} {34 46 81 83 scan 0 sort 0}
+do_test where7-2.258.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR b=982
+ OR ((a BETWEEN 81 AND 83) AND a!=82)
+ OR b=374
+ }
+} {34 46 81 83 scan 0 sort 0}
+do_test where7-2.259.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 87 AND 89) AND a!=88)
+ OR b=814
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ }
+} {19 74 87 89 scan 0 sort 0}
+do_test where7-2.259.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 87 AND 89) AND a!=88)
+ OR b=814
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ }
+} {19 74 87 89 scan 0 sort 0}
+do_test where7-2.260.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='qponmlk' AND f GLOB 'nopqr*')
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=993
+ }
+} {12 39 scan 0 sort 0}
+do_test where7-2.260.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='qponmlk' AND f GLOB 'nopqr*')
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=993
+ }
+} {12 39 scan 0 sort 0}
+do_test where7-2.261.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=234
+ OR a=22
+ OR b=289
+ OR b=795
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR b=242
+ OR a=59
+ OR b=1045
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ }
+} {8 22 59 91 95 scan 0 sort 0}
+do_test where7-2.261.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=234
+ OR a=22
+ OR b=289
+ OR b=795
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR b=242
+ OR a=59
+ OR b=1045
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ }
+} {8 22 59 91 95 scan 0 sort 0}
+do_test where7-2.262.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=245
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR c=3003
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ }
+} {1 7 8 9 10 26 33 52 68 70 71 73 78 scan 0 sort 0}
+do_test where7-2.262.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=245
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR c=3003
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ }
+} {1 7 8 9 10 26 33 52 68 70 71 73 78 scan 0 sort 0}
+do_test where7-2.263.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR b=220
+ OR b=443
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR a=62
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR b=1023
+ OR a=100
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ }
+} {18 20 44 55 62 70 87 93 96 97 100 scan 0 sort 0}
+do_test where7-2.263.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR b=220
+ OR b=443
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR a=62
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR b=1023
+ OR a=100
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ }
+} {18 20 44 55 62 70 87 93 96 97 100 scan 0 sort 0}
+do_test where7-2.264.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=11011
+ OR f='tuvwxyzab'
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ }
+} {19 31 32 33 45 47 71 84 97 scan 0 sort 0}
+do_test where7-2.264.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=11011
+ OR f='tuvwxyzab'
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ }
+} {19 31 32 33 45 47 71 84 97 scan 0 sort 0}
+do_test where7-2.265.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 93 AND 95) AND a!=94)
+ OR a=79
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ OR b=462
+ }
+} {39 42 79 93 95 scan 0 sort 0}
+do_test where7-2.265.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 93 AND 95) AND a!=94)
+ OR a=79
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ OR b=462
+ }
+} {39 42 79 93 95 scan 0 sort 0}
+do_test where7-2.266.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR b=146
+ OR 1000000<b
+ OR b=99
+ OR ((a BETWEEN 75 AND 77) AND a!=76)
+ }
+} {9 33 75 77 scan 0 sort 0}
+do_test where7-2.266.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR b=146
+ OR 1000000<b
+ OR b=99
+ OR ((a BETWEEN 75 AND 77) AND a!=76)
+ }
+} {9 33 75 77 scan 0 sort 0}
+do_test where7-2.267.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=935
+ OR b=473
+ OR a=28
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR ((a BETWEEN 62 AND 64) AND a!=63)
+ OR a=62
+ OR b=619
+ OR a=82
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR c=14014
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ }
+} {20 28 40 41 42 43 62 64 67 82 85 scan 0 sort 0}
+do_test where7-2.267.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=935
+ OR b=473
+ OR a=28
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR ((a BETWEEN 62 AND 64) AND a!=63)
+ OR a=62
+ OR b=619
+ OR a=82
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR c=14014
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ }
+} {20 28 40 41 42 43 62 64 67 82 85 scan 0 sort 0}
+do_test where7-2.268.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR b=443
+ OR b=33
+ OR b=762
+ OR b=575
+ OR c=16016
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR b=1092
+ }
+} {3 40 41 43 46 47 48 72 scan 0 sort 0}
+do_test where7-2.268.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR b=443
+ OR b=33
+ OR b=762
+ OR b=575
+ OR c=16016
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR b=1092
+ }
+} {3 40 41 43 46 47 48 72 scan 0 sort 0}
+do_test where7-2.269.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=806
+ OR b=872
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR f='uvwxyzabc'
+ OR b=748
+ OR b=586
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR b=891
+ }
+} {15 17 20 32 34 46 68 72 80 81 88 98 scan 0 sort 0}
+do_test where7-2.269.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=806
+ OR b=872
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR f='uvwxyzabc'
+ OR b=748
+ OR b=586
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR b=891
+ }
+} {15 17 20 32 34 46 68 72 80 81 88 98 scan 0 sort 0}
+do_test where7-2.270.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=693
+ OR f='fghijklmn'
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ OR a=96
+ }
+} {5 31 33 39 57 63 71 73 83 96 scan 0 sort 0}
+do_test where7-2.270.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=693
+ OR f='fghijklmn'
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ OR a=96
+ }
+} {5 31 33 39 57 63 71 73 83 96 scan 0 sort 0}
+do_test where7-2.271.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR b=451
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR a=84
+ }
+} {41 84 86 96 97 98 99 scan 0 sort 0}
+do_test where7-2.271.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR b=451
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR a=84
+ }
+} {41 84 86 96 97 98 99 scan 0 sort 0}
+do_test where7-2.272.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR a=75
+ OR b=960
+ OR (g='tsrqpon' AND f GLOB 'yzabc*')
+ OR b=616
+ OR b=330
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ OR a=26
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ }
+} {16 18 24 26 30 53 56 63 72 75 scan 0 sort 0}
+do_test where7-2.272.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR a=75
+ OR b=960
+ OR (g='tsrqpon' AND f GLOB 'yzabc*')
+ OR b=616
+ OR b=330
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ OR a=26
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ }
+} {16 18 24 26 30 53 56 63 72 75 scan 0 sort 0}
+do_test where7-2.273.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=762
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ }
+} {53 scan 0 sort 0}
+do_test where7-2.273.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=762
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ }
+} {53 scan 0 sort 0}
+do_test where7-2.274.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=14
+ OR a=23
+ OR b=748
+ OR b=407
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR b=979
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ }
+} {4 15 17 23 37 68 87 89 scan 0 sort 0}
+do_test where7-2.274.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=14
+ OR a=23
+ OR b=748
+ OR b=407
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR b=979
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ }
+} {4 15 17 23 37 68 87 89 scan 0 sort 0}
+do_test where7-2.275.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 36 AND 38) AND a!=37)
+ OR a=92
+ }
+} {36 38 92 scan 0 sort 0}
+do_test where7-2.275.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 36 AND 38) AND a!=37)
+ OR a=92
+ }
+} {36 38 92 scan 0 sort 0}
+do_test where7-2.276.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=14014
+ OR b=927
+ OR b=176
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ OR b=220
+ OR (g='tsrqpon' AND f GLOB 'yzabc*')
+ OR a=4
+ }
+} {4 16 20 24 34 36 40 41 42 scan 0 sort 0}
+do_test where7-2.276.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=14014
+ OR b=927
+ OR b=176
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ OR b=220
+ OR (g='tsrqpon' AND f GLOB 'yzabc*')
+ OR a=4
+ }
+} {4 16 20 24 34 36 40 41 42 scan 0 sort 0}
+do_test where7-2.277.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=29
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR b=979
+ OR b=275
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=41.0 AND d<42.0 AND d NOT NULL)
+ OR b=539
+ OR a=87
+ }
+} {19 25 29 41 49 56 58 87 89 scan 0 sort 0}
+do_test where7-2.277.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=29
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR b=979
+ OR b=275
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=41.0 AND d<42.0 AND d NOT NULL)
+ OR b=539
+ OR a=87
+ }
+} {19 25 29 41 49 56 58 87 89 scan 0 sort 0}
+do_test where7-2.278.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 43 AND 45) AND a!=44)
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR f='fghijklmn'
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR a=74
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ }
+} {4 5 6 7 9 31 36 43 45 57 59 69 74 83 scan 0 sort 0}
+do_test where7-2.278.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 43 AND 45) AND a!=44)
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR f='fghijklmn'
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR a=74
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ }
+} {4 5 6 7 9 31 36 43 45 57 59 69 74 83 scan 0 sort 0}
+do_test where7-2.279.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 80 AND 82) AND a!=81)
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ }
+} {8 34 42 49 51 60 79 80 82 86 scan 0 sort 0}
+do_test where7-2.279.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 80 AND 82) AND a!=81)
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ }
+} {8 34 42 49 51 60 79 80 82 86 scan 0 sort 0}
+do_test where7-2.280.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 58 AND 60) AND a!=59)
+ OR b=696
+ OR f='tuvwxyzab'
+ OR b=374
+ OR b=110
+ OR a=90
+ }
+} {10 19 34 45 58 60 71 90 97 scan 0 sort 0}
+do_test where7-2.280.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 58 AND 60) AND a!=59)
+ OR b=696
+ OR f='tuvwxyzab'
+ OR b=374
+ OR b=110
+ OR a=90
+ }
+} {10 19 34 45 58 60 71 90 97 scan 0 sort 0}
+do_test where7-2.281.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR c=23023
+ OR b=377
+ OR b=858
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ }
+} {6 57 67 68 69 78 scan 0 sort 0}
+do_test where7-2.281.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR c=23023
+ OR b=377
+ OR b=858
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ }
+} {6 57 67 68 69 78 scan 0 sort 0}
+do_test where7-2.282.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR b=322
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR (g='fedcbaz' AND f GLOB 'pqrst*')
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR b=432
+ OR b=55
+ OR a=53
+ OR (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR b=25
+ }
+} {5 7 19 33 38 48 53 59 74 85 93 scan 0 sort 0}
+do_test where7-2.282.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR b=322
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR (g='fedcbaz' AND f GLOB 'pqrst*')
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR b=432
+ OR b=55
+ OR a=53
+ OR (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR b=25
+ }
+} {5 7 19 33 38 48 53 59 74 85 93 scan 0 sort 0}
+do_test where7-2.283.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=484
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR b=616
+ OR c=5005
+ OR ((a BETWEEN 27 AND 29) AND a!=28)
+ }
+} {13 14 15 27 29 44 56 74 scan 0 sort 0}
+do_test where7-2.283.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=484
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR b=616
+ OR c=5005
+ OR ((a BETWEEN 27 AND 29) AND a!=28)
+ }
+} {13 14 15 27 29 44 56 74 scan 0 sort 0}
+do_test where7-2.284.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=916
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR b=1048
+ OR c=6006
+ OR b=762
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR b=751
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ }
+} {13 14 16 17 18 39 40 59 61 65 66 73 91 92 scan 0 sort 0}
+do_test where7-2.284.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=916
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR b=1048
+ OR c=6006
+ OR b=762
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR b=751
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ }
+} {13 14 16 17 18 39 40 59 61 65 66 73 91 92 scan 0 sort 0}
+do_test where7-2.285.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=32.0 AND d<33.0 AND d NOT NULL)
+ OR b=927
+ OR b=275
+ OR b=396
+ OR c=4004
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR b=319
+ OR ((a BETWEEN 83 AND 85) AND a!=84)
+ OR a=3
+ OR ((a BETWEEN 73 AND 75) AND a!=74)
+ }
+} {3 10 11 12 14 25 29 32 36 73 75 83 85 scan 0 sort 0}
+do_test where7-2.285.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=32.0 AND d<33.0 AND d NOT NULL)
+ OR b=927
+ OR b=275
+ OR b=396
+ OR c=4004
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR b=319
+ OR ((a BETWEEN 83 AND 85) AND a!=84)
+ OR a=3
+ OR ((a BETWEEN 73 AND 75) AND a!=74)
+ }
+} {3 10 11 12 14 25 29 32 36 73 75 83 85 scan 0 sort 0}
+do_test where7-2.286.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='wvutsrq' AND f GLOB 'lmnop*')
+ OR b=718
+ OR f='vwxyzabcd'
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ }
+} {9 11 19 21 22 35 45 47 61 66 68 71 73 87 97 98 99 scan 0 sort 0}
+do_test where7-2.286.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='wvutsrq' AND f GLOB 'lmnop*')
+ OR b=718
+ OR f='vwxyzabcd'
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ }
+} {9 11 19 21 22 35 45 47 61 66 68 71 73 87 97 98 99 scan 0 sort 0}
+do_test where7-2.287.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=187
+ OR b=1056
+ OR b=861
+ OR b=1081
+ OR b=572
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR a=11
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ OR a=89
+ OR b=421
+ }
+} {4 11 17 52 89 96 99 scan 0 sort 0}
+do_test where7-2.287.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=187
+ OR b=1056
+ OR b=861
+ OR b=1081
+ OR b=572
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR a=11
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ OR a=89
+ OR b=421
+ }
+} {4 11 17 52 89 96 99 scan 0 sort 0}
+do_test where7-2.288.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=231
+ OR b=388
+ OR d<0.0
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ OR b=1045
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ }
+} {12 21 39 95 scan 0 sort 0}
+do_test where7-2.288.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=231
+ OR b=388
+ OR d<0.0
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ OR b=1045
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ }
+} {12 21 39 95 scan 0 sort 0}
+do_test where7-2.289.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=528
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR b=762
+ }
+} {48 53 scan 0 sort 0}
+do_test where7-2.289.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=528
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR b=762
+ }
+} {48 53 scan 0 sort 0}
+do_test where7-2.290.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='stuvwxyza'
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR b=916
+ }
+} {18 44 70 90 92 96 scan 0 sort 0}
+do_test where7-2.290.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='stuvwxyza'
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR b=916
+ }
+} {18 44 70 90 92 96 scan 0 sort 0}
+do_test where7-2.291.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ }
+} {4 19 52 76 96 98 scan 0 sort 0}
+do_test where7-2.291.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ }
+} {4 19 52 76 96 98 scan 0 sort 0}
+do_test where7-2.292.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=102
+ OR c=6006
+ OR b=231
+ OR b=212
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR c=30030
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ }
+} {16 17 18 21 36 52 88 89 90 scan 0 sort 0}
+do_test where7-2.292.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=102
+ OR c=6006
+ OR b=231
+ OR b=212
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR c=30030
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ }
+} {16 17 18 21 36 52 88 89 90 scan 0 sort 0}
+do_test where7-2.293.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=47
+ OR a=82
+ OR c=25025
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR f='qrstuvwxy'
+ OR a=5
+ }
+} {5 16 40 42 47 68 73 74 75 82 94 scan 0 sort 0}
+do_test where7-2.293.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=47
+ OR a=82
+ OR c=25025
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR f='qrstuvwxy'
+ OR a=5
+ }
+} {5 16 40 42 47 68 73 74 75 82 94 scan 0 sort 0}
+do_test where7-2.294.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=429
+ OR a=30
+ OR f='vwxyzabcd'
+ OR b=762
+ OR a=60
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ }
+} {4 21 30 39 47 60 73 99 scan 0 sort 0}
+do_test where7-2.294.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=429
+ OR a=30
+ OR f='vwxyzabcd'
+ OR b=762
+ OR a=60
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ }
+} {4 21 30 39 47 60 73 99 scan 0 sort 0}
+do_test where7-2.295.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR a=3
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR b=498
+ OR a=100
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR a=69
+ }
+} {3 13 31 39 58 63 65 69 91 100 scan 0 sort 0}
+do_test where7-2.295.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR a=3
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR b=498
+ OR a=100
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR a=69
+ }
+} {3 13 31 39 58 63 65 69 91 100 scan 0 sort 0}
+do_test where7-2.296.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ihgfedc' AND f GLOB 'efghi*')
+ OR b=300
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ OR b=58
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR b=286
+ OR b=234
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR f='ghijklmno'
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ }
+} {6 7 26 32 43 45 55 57 58 82 84 scan 0 sort 0}
+do_test where7-2.296.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ihgfedc' AND f GLOB 'efghi*')
+ OR b=300
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ OR b=58
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR b=286
+ OR b=234
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR f='ghijklmno'
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ }
+} {6 7 26 32 43 45 55 57 58 82 84 scan 0 sort 0}
+do_test where7-2.297.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=95
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR b=594
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ }
+} {5 7 18 20 23 25 31 33 37 39 45 53 54 55 56 57 58 59 72 74 83 85 95 scan 0 sort 0}
+do_test where7-2.297.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=95
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR b=594
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ }
+} {5 7 18 20 23 25 31 33 37 39 45 53 54 55 56 57 58 59 72 74 83 85 95 scan 0 sort 0}
+do_test where7-2.298.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=949
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ }
+} {5 14 scan 0 sort 0}
+do_test where7-2.298.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=949
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ }
+} {5 14 scan 0 sort 0}
+do_test where7-2.299.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=960
+ OR a=44
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR a=39
+ OR b=828
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR d<0.0
+ OR b=770
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR b=594
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ }
+} {3 5 6 18 39 44 54 70 89 91 96 scan 0 sort 0}
+do_test where7-2.299.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=960
+ OR a=44
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR a=39
+ OR b=828
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR d<0.0
+ OR b=770
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR b=594
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ }
+} {3 5 6 18 39 44 54 70 89 91 96 scan 0 sort 0}
+do_test where7-2.300.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 40 AND 42) AND a!=41)
+ OR b=198
+ OR a=51
+ OR b=1056
+ OR b=748
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ }
+} {9 11 18 40 42 51 68 96 scan 0 sort 0}
+do_test where7-2.300.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 40 AND 42) AND a!=41)
+ OR b=198
+ OR a=51
+ OR b=1056
+ OR b=748
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ }
+} {9 11 18 40 42 51 68 96 scan 0 sort 0}
+do_test where7-2.301.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1081
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=1004
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 29 AND 31) AND a!=30)
+ OR b=660
+ OR b=957
+ OR b=869
+ }
+} {29 31 60 66 68 79 87 91 scan 0 sort 0}
+do_test where7-2.301.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1081
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=1004
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 29 AND 31) AND a!=30)
+ OR b=660
+ OR b=957
+ OR b=869
+ }
+} {29 31 60 66 68 79 87 91 scan 0 sort 0}
+do_test where7-2.302.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=927
+ OR c=12012
+ OR f='yzabcdefg'
+ OR b=880
+ OR a=63
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ }
+} {24 34 35 36 44 50 58 63 76 80 86 scan 0 sort 0}
+do_test where7-2.302.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=927
+ OR c=12012
+ OR f='yzabcdefg'
+ OR b=880
+ OR a=63
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ }
+} {24 34 35 36 44 50 58 63 76 80 86 scan 0 sort 0}
+do_test where7-2.303.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=69
+ OR b=1103
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR f='wxyzabcde'
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR f='pqrstuvwx'
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR a=59
+ OR b=946
+ }
+} {15 18 22 26 41 44 48 52 59 67 69 70 73 74 78 86 88 93 96 100 scan 0 sort 0}
+do_test where7-2.303.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=69
+ OR b=1103
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR f='wxyzabcde'
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR f='pqrstuvwx'
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR a=59
+ OR b=946
+ }
+} {15 18 22 26 41 44 48 52 59 67 69 70 73 74 78 86 88 93 96 100 scan 0 sort 0}
+do_test where7-2.304.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ OR a=68
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {14 16 47 68 75 scan 0 sort 0}
+do_test where7-2.304.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ OR a=68
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {14 16 47 68 75 scan 0 sort 0}
+do_test where7-2.305.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'lmnop*')
+ }
+} {10 63 scan 0 sort 0}
+do_test where7-2.305.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'lmnop*')
+ }
+} {10 63 scan 0 sort 0}
+do_test where7-2.306.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=32
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ OR ((a BETWEEN 92 AND 94) AND a!=93)
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR c=7007
+ OR b=968
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ }
+} {15 17 18 19 20 21 32 86 88 92 94 scan 0 sort 0}
+do_test where7-2.306.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=32
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ OR ((a BETWEEN 92 AND 94) AND a!=93)
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR c=7007
+ OR b=968
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ }
+} {15 17 18 19 20 21 32 86 88 92 94 scan 0 sort 0}
+do_test where7-2.307.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='cdefghijk'
+ OR b=1103
+ }
+} {2 28 54 80 scan 0 sort 0}
+do_test where7-2.307.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='cdefghijk'
+ OR b=1103
+ }
+} {2 28 54 80 scan 0 sort 0}
+do_test where7-2.308.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR c=14014
+ OR b=990
+ OR (g='nmlkjih' AND f GLOB 'efghi*')
+ OR c=14014
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ OR b=740
+ OR c=3003
+ }
+} {7 8 9 13 14 21 23 40 41 42 56 90 scan 0 sort 0}
+do_test where7-2.308.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR c=14014
+ OR b=990
+ OR (g='nmlkjih' AND f GLOB 'efghi*')
+ OR c=14014
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ OR b=740
+ OR c=3003
+ }
+} {7 8 9 13 14 21 23 40 41 42 56 90 scan 0 sort 0}
+do_test where7-2.309.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR a=67
+ OR b=135
+ OR f='bcdefghij'
+ OR b=924
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ }
+} {1 22 27 53 60 67 79 84 scan 0 sort 0}
+do_test where7-2.309.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR a=67
+ OR b=135
+ OR f='bcdefghij'
+ OR b=924
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ }
+} {1 22 27 53 60 67 79 84 scan 0 sort 0}
+do_test where7-2.310.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=96
+ OR a=13
+ }
+} {13 96 scan 0 sort 0}
+do_test where7-2.310.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=96
+ OR a=13
+ }
+} {13 96 scan 0 sort 0}
+do_test where7-2.311.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 34 AND 36) AND a!=35)
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR ((a BETWEEN 35 AND 37) AND a!=36)
+ OR a=49
+ OR a=38
+ OR b=157
+ OR a=4
+ OR b=311
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR b=396
+ }
+} {4 27 34 35 36 37 38 49 50 97 99 scan 0 sort 0}
+do_test where7-2.311.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 34 AND 36) AND a!=35)
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR ((a BETWEEN 35 AND 37) AND a!=36)
+ OR a=49
+ OR a=38
+ OR b=157
+ OR a=4
+ OR b=311
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR b=396
+ }
+} {4 27 34 35 36 37 38 49 50 97 99 scan 0 sort 0}
+do_test where7-2.312.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=82
+ OR b=333
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ OR b=99
+ OR a=63
+ OR a=35
+ OR b=176
+ }
+} {9 16 22 35 48 63 74 82 100 scan 0 sort 0}
+do_test where7-2.312.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=82
+ OR b=333
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ OR b=99
+ OR a=63
+ OR a=35
+ OR b=176
+ }
+} {9 16 22 35 48 63 74 82 100 scan 0 sort 0}
+do_test where7-2.313.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=90
+ OR a=81
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ OR f='mnopqrstu'
+ OR b=927
+ OR b=311
+ OR a=34
+ OR b=715
+ OR f='rstuvwxyz'
+ }
+} {12 17 34 38 43 51 53 64 65 69 81 90 95 scan 0 sort 0}
+do_test where7-2.313.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=90
+ OR a=81
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ OR f='mnopqrstu'
+ OR b=927
+ OR b=311
+ OR a=34
+ OR b=715
+ OR f='rstuvwxyz'
+ }
+} {12 17 34 38 43 51 53 64 65 69 81 90 95 scan 0 sort 0}
+do_test where7-2.314.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=484
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR f='lmnopqrst'
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ OR b<0
+ OR b=231
+ OR a=14
+ }
+} {7 10 11 12 14 21 37 39 44 63 64 89 scan 0 sort 0}
+do_test where7-2.314.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=484
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR f='lmnopqrst'
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ OR b<0
+ OR b=231
+ OR a=14
+ }
+} {7 10 11 12 14 21 37 39 44 63 64 89 scan 0 sort 0}
+do_test where7-2.315.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=905
+ OR f='hijklmnop'
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR b=817
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ }
+} {7 11 20 22 26 33 37 45 59 63 80 85 89 scan 0 sort 0}
+do_test where7-2.315.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=905
+ OR f='hijklmnop'
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR b=817
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ }
+} {7 11 20 22 26 33 37 45 59 63 80 85 89 scan 0 sort 0}
+do_test where7-2.316.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR b=311
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR a=48
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR c=32032
+ OR f='opqrstuvw'
+ OR b=300
+ OR b=1001
+ OR ((a BETWEEN 94 AND 96) AND a!=95)
+ }
+} {14 40 43 47 48 61 66 85 91 92 94 95 96 scan 0 sort 0}
+do_test where7-2.316.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR b=311
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR a=48
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR c=32032
+ OR f='opqrstuvw'
+ OR b=300
+ OR b=1001
+ OR ((a BETWEEN 94 AND 96) AND a!=95)
+ }
+} {14 40 43 47 48 61 66 85 91 92 94 95 96 scan 0 sort 0}
+do_test where7-2.317.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=95.0 AND d<96.0 AND d NOT NULL)
+ OR b=1070
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR a=22
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR f='tuvwxyzab'
+ OR a=72
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ }
+} {11 19 22 45 53 55 61 71 72 95 97 99 scan 0 sort 0}
+do_test where7-2.317.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=95.0 AND d<96.0 AND d NOT NULL)
+ OR b=1070
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR a=22
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR f='tuvwxyzab'
+ OR a=72
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ }
+} {11 19 22 45 53 55 61 71 72 95 97 99 scan 0 sort 0}
+do_test where7-2.318.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR a=21
+ OR b=1026
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ OR b=473
+ }
+} {8 16 21 34 36 43 scan 0 sort 0}
+do_test where7-2.318.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR a=21
+ OR b=1026
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ OR b=473
+ }
+} {8 16 21 34 36 43 scan 0 sort 0}
+do_test where7-2.319.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR a=100
+ OR a=29
+ OR c=15015
+ OR a=87
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ }
+} {29 43 44 45 71 73 87 88 100 scan 0 sort 0}
+do_test where7-2.319.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR a=100
+ OR a=29
+ OR c=15015
+ OR a=87
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ }
+} {29 43 44 45 71 73 87 88 100 scan 0 sort 0}
+do_test where7-2.320.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR b=542
+ OR b=638
+ }
+} {1 58 scan 0 sort 0}
+do_test where7-2.320.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR b=542
+ OR b=638
+ }
+} {1 58 scan 0 sort 0}
+do_test where7-2.321.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 5 AND 7) AND a!=6)
+ OR b=1070
+ OR a=91
+ OR b=1015
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ }
+} {5 7 12 80 91 93 scan 0 sort 0}
+do_test where7-2.321.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 5 AND 7) AND a!=6)
+ OR b=1070
+ OR a=91
+ OR b=1015
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ }
+} {5 7 12 80 91 93 scan 0 sort 0}
+do_test where7-2.322.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=7
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR b=1015
+ OR b=839
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR b=410
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR a=71
+ }
+} {1 2 7 28 36 54 71 80 scan 0 sort 0}
+do_test where7-2.322.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=7
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR b=1015
+ OR b=839
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR b=410
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR a=71
+ }
+} {1 2 7 28 36 54 71 80 scan 0 sort 0}
+do_test where7-2.323.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=880
+ OR b=982
+ OR a=52
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR a=24
+ OR ((a BETWEEN 47 AND 49) AND a!=48)
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ }
+} {24 47 49 50 52 60 76 80 scan 0 sort 0}
+do_test where7-2.323.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=880
+ OR b=982
+ OR a=52
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR a=24
+ OR ((a BETWEEN 47 AND 49) AND a!=48)
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ }
+} {24 47 49 50 52 60 76 80 scan 0 sort 0}
+do_test where7-2.324.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 67 AND 69) AND a!=68)
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ }
+} {5 22 31 57 67 69 83 scan 0 sort 0}
+do_test where7-2.324.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 67 AND 69) AND a!=68)
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ }
+} {5 22 31 57 67 69 83 scan 0 sort 0}
+do_test where7-2.325.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='abcdefghi'
+ OR a=5
+ OR b=124
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=432
+ OR 1000000<b
+ OR a=58
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=77
+ OR b=605
+ }
+} {5 7 26 45 52 55 58 69 78 scan 0 sort 0}
+do_test where7-2.325.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='abcdefghi'
+ OR a=5
+ OR b=124
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=432
+ OR 1000000<b
+ OR a=58
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=77
+ OR b=605
+ }
+} {5 7 26 45 52 55 58 69 78 scan 0 sort 0}
+do_test where7-2.326.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR b=583
+ OR a=62
+ }
+} {53 62 89 scan 0 sort 0}
+do_test where7-2.326.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR b=583
+ OR a=62
+ }
+} {53 62 89 scan 0 sort 0}
+do_test where7-2.327.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 84 AND 86) AND a!=85)
+ OR f='pqrstuvwx'
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR b=278
+ OR a=10
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR f='uvwxyzabc'
+ }
+} {5 10 15 20 28 41 46 54 63 65 67 68 72 84 86 93 98 scan 0 sort 0}
+do_test where7-2.327.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 84 AND 86) AND a!=85)
+ OR f='pqrstuvwx'
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR b=278
+ OR a=10
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR f='uvwxyzabc'
+ }
+} {5 10 15 20 28 41 46 54 63 65 67 68 72 84 86 93 98 scan 0 sort 0}
+do_test where7-2.328.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR b=564
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR b=77
+ OR (g='nmlkjih' AND f GLOB 'efghi*')
+ OR b=968
+ OR b=847
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ }
+} {7 14 40 56 57 58 59 66 77 85 88 90 92 scan 0 sort 0}
+do_test where7-2.328.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR b=564
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR b=77
+ OR (g='nmlkjih' AND f GLOB 'efghi*')
+ OR b=968
+ OR b=847
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ }
+} {7 14 40 56 57 58 59 66 77 85 88 90 92 scan 0 sort 0}
+do_test where7-2.329.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=539
+ OR b=594
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR f='abcdefghi'
+ OR a=6
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR b=762
+ }
+} {6 17 26 49 52 54 63 65 78 scan 0 sort 0}
+do_test where7-2.329.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=539
+ OR b=594
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR f='abcdefghi'
+ OR a=6
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR b=762
+ }
+} {6 17 26 49 52 54 63 65 78 scan 0 sort 0}
+do_test where7-2.330.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=869
+ OR b=630
+ }
+} {79 scan 0 sort 0}
+do_test where7-2.330.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=869
+ OR b=630
+ }
+} {79 scan 0 sort 0}
+do_test where7-2.331.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR b=693
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR b=968
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR b=132
+ OR f='nopqrstuv'
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ }
+} {12 13 28 30 39 63 65 72 86 88 91 scan 0 sort 0}
+do_test where7-2.331.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR b=693
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR b=968
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR b=132
+ OR f='nopqrstuv'
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ }
+} {12 13 28 30 39 63 65 72 86 88 91 scan 0 sort 0}
+do_test where7-2.332.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=32032
+ OR b=814
+ OR (d>=90.0 AND d<91.0 AND d NOT NULL)
+ OR b=814
+ OR a=78
+ OR a=37
+ }
+} {37 74 78 90 94 95 96 scan 0 sort 0}
+do_test where7-2.332.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=32032
+ OR b=814
+ OR (d>=90.0 AND d<91.0 AND d NOT NULL)
+ OR b=814
+ OR a=78
+ OR a=37
+ }
+} {37 74 78 90 94 95 96 scan 0 sort 0}
+do_test where7-2.333.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=190
+ OR (g='mlkjihg' AND f GLOB 'hijkl*')
+ OR b=924
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR b=759
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ }
+} {1 40 59 69 84 scan 0 sort 0}
+do_test where7-2.333.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=190
+ OR (g='mlkjihg' AND f GLOB 'hijkl*')
+ OR b=924
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR b=759
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ }
+} {1 40 59 69 84 scan 0 sort 0}
+do_test where7-2.334.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=97
+ OR b=201
+ OR b=597
+ OR a=6
+ OR f='cdefghijk'
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR b=300
+ OR b=693
+ OR b=333
+ OR b=740
+ }
+} {2 6 28 54 63 74 76 80 97 scan 0 sort 0}
+do_test where7-2.334.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=97
+ OR b=201
+ OR b=597
+ OR a=6
+ OR f='cdefghijk'
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR b=300
+ OR b=693
+ OR b=333
+ OR b=740
+ }
+} {2 6 28 54 63 74 76 80 97 scan 0 sort 0}
+do_test where7-2.335.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=26026
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR c=17017
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR (g='jihgfed' AND f GLOB 'zabcd*')
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ }
+} {2 4 32 43 49 50 51 60 72 74 76 77 78 scan 0 sort 0}
+do_test where7-2.335.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=26026
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR c=17017
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR (g='jihgfed' AND f GLOB 'zabcd*')
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ }
+} {2 4 32 43 49 50 51 60 72 74 76 77 78 scan 0 sort 0}
+do_test where7-2.336.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR ((a BETWEEN 13 AND 15) AND a!=14)
+ OR b=638
+ OR b=495
+ OR a=44
+ OR b=374
+ OR a=22
+ OR c=12012
+ }
+} {13 15 22 34 35 36 44 45 58 70 scan 0 sort 0}
+do_test where7-2.336.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR ((a BETWEEN 13 AND 15) AND a!=14)
+ OR b=638
+ OR b=495
+ OR a=44
+ OR b=374
+ OR a=22
+ OR c=12012
+ }
+} {13 15 22 34 35 36 44 45 58 70 scan 0 sort 0}
+do_test where7-2.337.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=8008
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ OR (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR b=300
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR a=41
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ OR b=135
+ OR b=605
+ }
+} {1 2 22 23 24 39 41 49 55 100 scan 0 sort 0}
+do_test where7-2.337.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=8008
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ OR (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR b=300
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR a=41
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ OR b=135
+ OR b=605
+ }
+} {1 2 22 23 24 39 41 49 55 100 scan 0 sort 0}
+do_test where7-2.338.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR b=762
+ OR b=484
+ OR b=190
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=1023
+ }
+} {4 17 30 41 43 44 56 61 69 74 82 93 95 97 scan 0 sort 0}
+do_test where7-2.338.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR b=762
+ OR b=484
+ OR b=190
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=1023
+ }
+} {4 17 30 41 43 44 56 61 69 74 82 93 95 97 scan 0 sort 0}
+do_test where7-2.339.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ihgfedc' AND f GLOB 'efghi*')
+ OR a=34
+ OR f='rstuvwxyz'
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR b=729
+ }
+} {10 17 34 43 69 82 95 scan 0 sort 0}
+do_test where7-2.339.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ihgfedc' AND f GLOB 'efghi*')
+ OR a=34
+ OR f='rstuvwxyz'
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR b=729
+ }
+} {10 17 34 43 69 82 95 scan 0 sort 0}
+do_test where7-2.340.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR b=1004
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR g IS NULL
+ }
+} {37 41 scan 0 sort 0}
+do_test where7-2.340.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR b=1004
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR g IS NULL
+ }
+} {37 41 scan 0 sort 0}
+do_test where7-2.341.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=73
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ OR a=9
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR a=44
+ OR a=23
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ }
+} {1 9 23 36 37 38 44 51 53 55 63 73 78 scan 0 sort 0}
+do_test where7-2.341.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=73
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ OR a=9
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR a=44
+ OR a=23
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ }
+} {1 9 23 36 37 38 44 51 53 55 63 73 78 scan 0 sort 0}
+do_test where7-2.342.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=487
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR a=11
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR a=13
+ OR a=15
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR a=36
+ }
+} {11 12 13 14 15 29 36 69 71 77 78 79 scan 0 sort 0}
+do_test where7-2.342.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=487
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR a=11
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR a=13
+ OR a=15
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR a=36
+ }
+} {11 12 13 14 15 29 36 69 71 77 78 79 scan 0 sort 0}
+do_test where7-2.343.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=938
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (d>=32.0 AND d<33.0 AND d NOT NULL)
+ OR b=245
+ OR (d>=35.0 AND d<36.0 AND d NOT NULL)
+ }
+} {32 35 54 57 59 scan 0 sort 0}
+do_test where7-2.343.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=938
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (d>=32.0 AND d<33.0 AND d NOT NULL)
+ OR b=245
+ OR (d>=35.0 AND d<36.0 AND d NOT NULL)
+ }
+} {32 35 54 57 59 scan 0 sort 0}
+do_test where7-2.344.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1078
+ OR c=19019
+ OR a=38
+ OR a=59
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR c=25025
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ }
+} {30 32 38 51 55 56 57 59 73 74 75 76 79 95 97 98 scan 0 sort 0}
+do_test where7-2.344.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1078
+ OR c=19019
+ OR a=38
+ OR a=59
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR c=25025
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ }
+} {30 32 38 51 55 56 57 59 73 74 75 76 79 95 97 98 scan 0 sort 0}
+do_test where7-2.345.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='cdefghijk'
+ OR b=168
+ OR b=561
+ OR a=81
+ OR a=87
+ }
+} {2 28 51 54 80 81 87 scan 0 sort 0}
+do_test where7-2.345.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='cdefghijk'
+ OR b=168
+ OR b=561
+ OR a=81
+ OR a=87
+ }
+} {2 28 51 54 80 81 87 scan 0 sort 0}
+do_test where7-2.346.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='gfedcba' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ OR a=48
+ OR b=113
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=880
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ }
+} {9 11 20 22 33 48 53 73 80 85 87 88 scan 0 sort 0}
+do_test where7-2.346.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='gfedcba' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ OR a=48
+ OR b=113
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=880
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ }
+} {9 11 20 22 33 48 53 73 80 85 87 88 scan 0 sort 0}
+do_test where7-2.347.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=517
+ OR b=187
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR b=1092
+ OR ((a BETWEEN 84 AND 86) AND a!=85)
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ }
+} {6 17 47 84 86 scan 0 sort 0}
+do_test where7-2.347.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=517
+ OR b=187
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR b=1092
+ OR ((a BETWEEN 84 AND 86) AND a!=85)
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ }
+} {6 17 47 84 86 scan 0 sort 0}
+do_test where7-2.348.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=982
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=234
+ OR c=15015
+ OR a=47
+ OR f='qrstuvwxy'
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ OR b=814
+ OR b=440
+ OR b=454
+ }
+} {16 40 42 43 44 45 47 65 68 74 94 scan 0 sort 0}
+do_test where7-2.348.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=982
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=234
+ OR c=15015
+ OR a=47
+ OR f='qrstuvwxy'
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ OR b=814
+ OR b=440
+ OR b=454
+ }
+} {16 40 42 43 44 45 47 65 68 74 94 scan 0 sort 0}
+do_test where7-2.349.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR c=7007
+ OR b=429
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR b=231
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR c=22022
+ OR f='bcdefghij'
+ }
+} {1 19 20 21 25 26 27 39 47 53 64 65 66 79 scan 0 sort 0}
+do_test where7-2.349.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR c=7007
+ OR b=429
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR b=231
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR c=22022
+ OR f='bcdefghij'
+ }
+} {1 19 20 21 25 26 27 39 47 53 64 65 66 79 scan 0 sort 0}
+do_test where7-2.350.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=17017
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR b=784
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR ((a BETWEEN 54 AND 56) AND a!=55)
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ OR f='zabcdefgh'
+ }
+} {16 18 22 24 25 49 50 51 54 56 62 77 88 90 scan 0 sort 0}
+do_test where7-2.350.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=17017
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR b=784
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR ((a BETWEEN 54 AND 56) AND a!=55)
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ OR f='zabcdefgh'
+ }
+} {16 18 22 24 25 49 50 51 54 56 62 77 88 90 scan 0 sort 0}
+do_test where7-2.351.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=344
+ OR b=275
+ OR c<=10
+ }
+} {25 scan 0 sort 0}
+do_test where7-2.351.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=344
+ OR b=275
+ OR c<=10
+ }
+} {25 scan 0 sort 0}
+do_test where7-2.352.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 44 AND 46) AND a!=45)
+ OR a=76
+ OR b=154
+ OR a=30
+ OR c=3003
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ OR b=564
+ OR b=55
+ OR a=38
+ }
+} {5 7 8 9 14 23 30 38 44 46 49 75 76 88 scan 0 sort 0}
+do_test where7-2.352.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 44 AND 46) AND a!=45)
+ OR a=76
+ OR b=154
+ OR a=30
+ OR c=3003
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ OR b=564
+ OR b=55
+ OR a=38
+ }
+} {5 7 8 9 14 23 30 38 44 46 49 75 76 88 scan 0 sort 0}
+do_test where7-2.353.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=52
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ }
+} {52 54 66 68 scan 0 sort 0}
+do_test where7-2.353.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=52
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ }
+} {52 54 66 68 scan 0 sort 0}
+do_test where7-2.354.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=792
+ OR (g='wvutsrq' AND f GLOB 'jklmn*')
+ }
+} {9 72 scan 0 sort 0}
+do_test where7-2.354.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=792
+ OR (g='wvutsrq' AND f GLOB 'jklmn*')
+ }
+} {9 72 scan 0 sort 0}
+do_test where7-2.355.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR c=21021
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR f='zabcdefgh'
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR b=781
+ OR a=64
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ }
+} {1 11 25 51 61 62 63 64 65 71 73 77 scan 0 sort 0}
+do_test where7-2.355.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR c=21021
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR f='zabcdefgh'
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR b=781
+ OR a=64
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ }
+} {1 11 25 51 61 62 63 64 65 71 73 77 scan 0 sort 0}
+do_test where7-2.356.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR (d>=90.0 AND d<91.0 AND d NOT NULL)
+ OR a=34
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR b=319
+ OR b=330
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ }
+} {28 29 30 34 36 67 90 scan 0 sort 0}
+do_test where7-2.356.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR (d>=90.0 AND d<91.0 AND d NOT NULL)
+ OR a=34
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR b=319
+ OR b=330
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ }
+} {28 29 30 34 36 67 90 scan 0 sort 0}
+do_test where7-2.357.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='qponmlk' AND f GLOB 'pqrst*')
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR a=45
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ }
+} {15 41 45 67 81 93 scan 0 sort 0}
+do_test where7-2.357.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='qponmlk' AND f GLOB 'pqrst*')
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR a=45
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ }
+} {15 41 45 67 81 93 scan 0 sort 0}
+do_test where7-2.358.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR b=165
+ OR b=836
+ }
+} {15 53 54 76 scan 0 sort 0}
+do_test where7-2.358.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR b=165
+ OR b=836
+ }
+} {15 53 54 76 scan 0 sort 0}
+do_test where7-2.359.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1034
+ OR f='vwxyzabcd'
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ }
+} {21 47 57 59 73 91 94 99 scan 0 sort 0}
+do_test where7-2.359.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1034
+ OR f='vwxyzabcd'
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ }
+} {21 47 57 59 73 91 94 99 scan 0 sort 0}
+do_test where7-2.360.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=440
+ OR a=19
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR c=22022
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR a=92
+ OR b=1026
+ OR b=608
+ }
+} {19 40 47 64 65 66 92 scan 0 sort 0}
+do_test where7-2.360.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=440
+ OR a=19
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR c=22022
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR a=92
+ OR b=1026
+ OR b=608
+ }
+} {19 40 47 64 65 66 92 scan 0 sort 0}
+do_test where7-2.361.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=37
+ OR b=88
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR c=23023
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR a=56
+ OR ((a BETWEEN 13 AND 15) AND a!=14)
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR f='ijklmnopq'
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ }
+} {8 13 15 16 22 34 37 42 56 60 67 68 69 85 86 87 94 scan 0 sort 0}
+do_test where7-2.361.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=37
+ OR b=88
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR c=23023
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR a=56
+ OR ((a BETWEEN 13 AND 15) AND a!=14)
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR f='ijklmnopq'
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ }
+} {8 13 15 16 22 34 37 42 56 60 67 68 69 85 86 87 94 scan 0 sort 0}
+do_test where7-2.362.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR a=74
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 42 AND 44) AND a!=43)
+ }
+} {20 22 24 42 44 74 97 scan 0 sort 0}
+do_test where7-2.362.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR a=74
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 42 AND 44) AND a!=43)
+ }
+} {20 22 24 42 44 74 97 scan 0 sort 0}
+do_test where7-2.363.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='uvwxyzabc'
+ OR b=869
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ }
+} {20 46 49 51 72 79 98 scan 0 sort 0}
+do_test where7-2.363.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='uvwxyzabc'
+ OR b=869
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ }
+} {20 46 49 51 72 79 98 scan 0 sort 0}
+do_test where7-2.364.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=682
+ OR b=583
+ OR b=685
+ OR b=817
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ }
+} {34 36 53 62 scan 0 sort 0}
+do_test where7-2.364.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=682
+ OR b=583
+ OR b=685
+ OR b=817
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ }
+} {34 36 53 62 scan 0 sort 0}
+do_test where7-2.365.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=583
+ OR a=39
+ OR b=627
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ }
+} {39 53 57 72 74 scan 0 sort 0}
+do_test where7-2.365.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=583
+ OR a=39
+ OR b=627
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ }
+} {39 53 57 72 74 scan 0 sort 0}
+do_test where7-2.366.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR b=212
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR a=20
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR b=627
+ }
+} {2 4 20 24 26 53 57 68 73 scan 0 sort 0}
+do_test where7-2.366.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR b=212
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR a=20
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR b=627
+ }
+} {2 4 20 24 26 53 57 68 73 scan 0 sort 0}
+do_test where7-2.367.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR b=157
+ OR b=1026
+ }
+} {8 34 60 77 86 scan 0 sort 0}
+do_test where7-2.367.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR b=157
+ OR b=1026
+ }
+} {8 34 60 77 86 scan 0 sort 0}
+do_test where7-2.368.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=553
+ OR a=16
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (g='wvutsrq' AND f GLOB 'lmnop*')
+ OR f='zabcdefgh'
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ }
+} {5 11 16 25 31 33 51 67 77 80 82 scan 0 sort 0}
+do_test where7-2.368.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=553
+ OR a=16
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (g='wvutsrq' AND f GLOB 'lmnop*')
+ OR f='zabcdefgh'
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ }
+} {5 11 16 25 31 33 51 67 77 80 82 scan 0 sort 0}
+do_test where7-2.369.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=858
+ OR c=9009
+ OR b=792
+ OR b=88
+ OR b=154
+ }
+} {8 14 25 26 27 72 78 scan 0 sort 0}
+do_test where7-2.369.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=858
+ OR c=9009
+ OR b=792
+ OR b=88
+ OR b=154
+ }
+} {8 14 25 26 27 72 78 scan 0 sort 0}
+do_test where7-2.370.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f IS NULL
+ OR a=37
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR b=168
+ OR b=22
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR b=506
+ }
+} {2 21 37 46 48 55 57 scan 0 sort 0}
+do_test where7-2.370.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f IS NULL
+ OR a=37
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR b=168
+ OR b=22
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR b=506
+ }
+} {2 21 37 46 48 55 57 scan 0 sort 0}
+do_test where7-2.371.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=29
+ OR ((a BETWEEN 26 AND 28) AND a!=27)
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR b=209
+ OR (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ OR b=146
+ }
+} {19 25 26 28 29 42 45 51 69 71 77 97 scan 0 sort 0}
+do_test where7-2.371.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=29
+ OR ((a BETWEEN 26 AND 28) AND a!=27)
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR b=209
+ OR (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ OR b=146
+ }
+} {19 25 26 28 29 42 45 51 69 71 77 97 scan 0 sort 0}
+do_test where7-2.372.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=63
+ OR a=69
+ OR b=333
+ OR (d>=6.0 AND d<7.0 AND d NOT NULL)
+ OR b=135
+ OR b=25
+ OR b=1037
+ OR b=682
+ OR c=27027
+ OR a=46
+ }
+} {6 46 62 63 69 79 80 81 scan 0 sort 0}
+do_test where7-2.372.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=63
+ OR a=69
+ OR b=333
+ OR (d>=6.0 AND d<7.0 AND d NOT NULL)
+ OR b=135
+ OR b=25
+ OR b=1037
+ OR b=682
+ OR c=27027
+ OR a=46
+ }
+} {6 46 62 63 69 79 80 81 scan 0 sort 0}
+do_test where7-2.373.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='edcbazy' AND f GLOB 'wxyza*')
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR b=113
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ }
+} {40 42 52 53 55 59 61 100 scan 0 sort 0}
+do_test where7-2.373.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='edcbazy' AND f GLOB 'wxyza*')
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR b=113
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ }
+} {40 42 52 53 55 59 61 100 scan 0 sort 0}
+do_test where7-2.374.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1026
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ }
+} {48 scan 0 sort 0}
+do_test where7-2.374.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1026
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ }
+} {48 scan 0 sort 0}
+do_test where7-2.375.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='rqponml' AND f GLOB 'ijklm*')
+ OR a=99
+ OR a=100
+ OR b=429
+ OR b=682
+ OR b=495
+ OR f='efghijklm'
+ OR a=10
+ OR f='mnopqrstu'
+ OR b=946
+ OR (d>=95.0 AND d<96.0 AND d NOT NULL)
+ }
+} {4 10 12 30 34 38 39 45 56 62 64 82 86 90 95 99 100 scan 0 sort 0}
+do_test where7-2.375.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='rqponml' AND f GLOB 'ijklm*')
+ OR a=99
+ OR a=100
+ OR b=429
+ OR b=682
+ OR b=495
+ OR f='efghijklm'
+ OR a=10
+ OR f='mnopqrstu'
+ OR b=946
+ OR (d>=95.0 AND d<96.0 AND d NOT NULL)
+ }
+} {4 10 12 30 34 38 39 45 56 62 64 82 86 90 95 99 100 scan 0 sort 0}
+do_test where7-2.376.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR c=23023
+ OR b=462
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ }
+} {11 17 19 42 67 68 69 scan 0 sort 0}
+do_test where7-2.376.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR c=23023
+ OR b=462
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ }
+} {11 17 19 42 67 68 69 scan 0 sort 0}
+do_test where7-2.377.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=539
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR c=6006
+ OR a=18
+ OR c=24024
+ OR (g='wvutsrq' AND f GLOB 'jklmn*')
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR c=19019
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ }
+} {9 11 16 17 18 38 43 44 46 49 55 56 57 70 71 72 87 scan 0 sort 0}
+do_test where7-2.377.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=539
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR c=6006
+ OR a=18
+ OR c=24024
+ OR (g='wvutsrq' AND f GLOB 'jklmn*')
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR c=19019
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ }
+} {9 11 16 17 18 38 43 44 46 49 55 56 57 70 71 72 87 scan 0 sort 0}
+do_test where7-2.378.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR a=20
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR b=121
+ OR a=10
+ OR b=792
+ }
+} {10 11 15 20 72 94 scan 0 sort 0}
+do_test where7-2.378.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR a=20
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR b=121
+ OR a=10
+ OR b=792
+ }
+} {10 11 15 20 72 94 scan 0 sort 0}
+do_test where7-2.379.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=99
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ }
+} {9 14 40 66 85 87 92 scan 0 sort 0}
+do_test where7-2.379.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=99
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ }
+} {9 14 40 66 85 87 92 scan 0 sort 0}
+do_test where7-2.380.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ OR b=715
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ }
+} {6 23 25 32 58 65 79 81 84 scan 0 sort 0}
+do_test where7-2.380.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ OR b=715
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ }
+} {6 23 25 32 58 65 79 81 84 scan 0 sort 0}
+do_test where7-2.381.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ OR a=46
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ }
+} {28 46 97 scan 0 sort 0}
+do_test where7-2.381.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ OR a=46
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ }
+} {28 46 97 scan 0 sort 0}
+do_test where7-2.382.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ihgfedc' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR b=1056
+ OR b=146
+ }
+} {18 81 96 97 99 scan 0 sort 0}
+do_test where7-2.382.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ihgfedc' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR b=1056
+ OR b=146
+ }
+} {18 81 96 97 99 scan 0 sort 0}
+do_test where7-2.383.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=15
+ OR b=388
+ OR ((a BETWEEN 82 AND 84) AND a!=83)
+ OR a=36
+ OR b=737
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR a=75
+ }
+} {15 21 23 36 67 75 82 84 89 scan 0 sort 0}
+do_test where7-2.383.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=15
+ OR b=388
+ OR ((a BETWEEN 82 AND 84) AND a!=83)
+ OR a=36
+ OR b=737
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR a=75
+ }
+} {15 21 23 36 67 75 82 84 89 scan 0 sort 0}
+do_test where7-2.384.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=9009
+ OR a=34
+ OR (d>=95.0 AND d<96.0 AND d NOT NULL)
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=715
+ OR b=619
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ }
+} {16 25 26 27 34 65 95 98 100 scan 0 sort 0}
+do_test where7-2.384.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=9009
+ OR a=34
+ OR (d>=95.0 AND d<96.0 AND d NOT NULL)
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=715
+ OR b=619
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ }
+} {16 25 26 27 34 65 95 98 100 scan 0 sort 0}
+do_test where7-2.385.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR b=242
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR b=300
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ }
+} {1 11 13 21 22 24 26 27 32 34 39 41 53 61 74 76 79 93 95 scan 0 sort 0}
+do_test where7-2.385.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR b=242
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR b=300
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ }
+} {1 11 13 21 22 24 26 27 32 34 39 41 53 61 74 76 79 93 95 scan 0 sort 0}
+do_test where7-2.386.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=85
+ OR (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR b=212
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR b=36
+ OR b=231
+ OR b=1048
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR c=19019
+ }
+} {21 25 27 33 43 55 56 57 69 71 85 92 scan 0 sort 0}
+do_test where7-2.386.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=85
+ OR (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR b=212
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR b=36
+ OR b=231
+ OR b=1048
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR c=19019
+ }
+} {21 25 27 33 43 55 56 57 69 71 85 92 scan 0 sort 0}
+do_test where7-2.387.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 28 AND 30) AND a!=29)
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR b=1059
+ OR b=630
+ }
+} {8 28 30 scan 0 sort 0}
+do_test where7-2.387.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 28 AND 30) AND a!=29)
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR b=1059
+ OR b=630
+ }
+} {8 28 30 scan 0 sort 0}
+do_test where7-2.388.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='ghijklmno'
+ OR f='nopqrstuv'
+ OR b=297
+ }
+} {6 13 27 32 39 58 65 84 91 scan 0 sort 0}
+do_test where7-2.388.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='ghijklmno'
+ OR f='nopqrstuv'
+ OR b=297
+ }
+} {6 13 27 32 39 58 65 84 91 scan 0 sort 0}
+do_test where7-2.389.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1001
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR a=58
+ OR b=333
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR b=572
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ }
+} {7 15 33 43 49 50 52 58 59 68 70 85 87 89 91 scan 0 sort 0}
+do_test where7-2.389.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1001
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR a=58
+ OR b=333
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR b=572
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ }
+} {7 15 33 43 49 50 52 58 59 68 70 85 87 89 91 scan 0 sort 0}
+do_test where7-2.390.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1034
+ OR f='lmnopqrst'
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ }
+} {11 37 38 63 89 94 scan 0 sort 0}
+do_test where7-2.390.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1034
+ OR f='lmnopqrst'
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ }
+} {11 37 38 63 89 94 scan 0 sort 0}
+do_test where7-2.391.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=15015
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'hijkl*')
+ OR b=58
+ OR b=674
+ OR b=979
+ }
+} {43 44 45 59 87 89 scan 0 sort 0}
+do_test where7-2.391.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=15015
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'hijkl*')
+ OR b=58
+ OR b=674
+ OR b=979
+ }
+} {43 44 45 59 87 89 scan 0 sort 0}
+do_test where7-2.392.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 60 AND 62) AND a!=61)
+ OR b=660
+ OR b=341
+ }
+} {31 60 62 scan 0 sort 0}
+do_test where7-2.392.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 60 AND 62) AND a!=61)
+ OR b=660
+ OR b=341
+ }
+} {31 60 62 scan 0 sort 0}
+do_test where7-2.393.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=528
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR b=630
+ OR a=19
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR f='wxyzabcde'
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR b=377
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR a=77
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ }
+} {8 19 22 43 44 48 64 74 77 100 scan 0 sort 0}
+do_test where7-2.393.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=528
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR b=630
+ OR a=19
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR f='wxyzabcde'
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR b=377
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR a=77
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ }
+} {8 19 22 43 44 48 64 74 77 100 scan 0 sort 0}
+do_test where7-2.394.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=506
+ OR a=70
+ }
+} {46 70 scan 0 sort 0}
+do_test where7-2.394.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=506
+ OR a=70
+ }
+} {46 70 scan 0 sort 0}
+do_test where7-2.395.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=64
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'cdefg*')
+ OR c=14014
+ OR b=586
+ OR c=27027
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ }
+} {26 28 40 41 42 52 57 64 74 78 79 80 81 86 scan 0 sort 0}
+do_test where7-2.395.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=64
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'cdefg*')
+ OR c=14014
+ OR b=586
+ OR c=27027
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ }
+} {26 28 40 41 42 52 57 64 74 78 79 80 81 86 scan 0 sort 0}
+do_test where7-2.396.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=46
+ OR b=297
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR b=275
+ OR b=91
+ OR b=1015
+ OR c=12012
+ OR a=23
+ OR b=278
+ }
+} {23 25 27 34 35 36 46 57 59 75 scan 0 sort 0}
+do_test where7-2.396.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=46
+ OR b=297
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR b=275
+ OR b=91
+ OR b=1015
+ OR c=12012
+ OR a=23
+ OR b=278
+ }
+} {23 25 27 34 35 36 46 57 59 75 scan 0 sort 0}
+do_test where7-2.397.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR a=23
+ OR b=737
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ }
+} {18 20 23 25 27 61 67 68 69 70 71 98 scan 0 sort 0}
+do_test where7-2.397.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR a=23
+ OR b=737
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ }
+} {18 20 23 25 27 61 67 68 69 70 71 98 scan 0 sort 0}
+do_test where7-2.398.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=814
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR b=377
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ }
+} {71 74 79 scan 0 sort 0}
+do_test where7-2.398.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=814
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR b=377
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ }
+} {71 74 79 scan 0 sort 0}
+do_test where7-2.399.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=18
+ OR b=1059
+ OR (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR b=795
+ }
+} {9 18 25 46 51 53 77 scan 0 sort 0}
+do_test where7-2.399.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=18
+ OR b=1059
+ OR (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR b=795
+ }
+} {9 18 25 46 51 53 77 scan 0 sort 0}
+do_test where7-2.400.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR a=93
+ OR a=11
+ OR f='nopqrstuv'
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR a=17
+ OR b=366
+ }
+} {11 13 17 22 24 27 37 39 63 65 89 91 93 scan 0 sort 0}
+do_test where7-2.400.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR a=93
+ OR a=11
+ OR f='nopqrstuv'
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR a=17
+ OR b=366
+ }
+} {11 13 17 22 24 27 37 39 63 65 89 91 93 scan 0 sort 0}
+do_test where7-2.401.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=685
+ OR a=33
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR b=715
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR a=6
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ }
+} {6 16 33 37 39 40 41 42 59 61 65 80 82 93 95 scan 0 sort 0}
+do_test where7-2.401.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=685
+ OR a=33
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR b=715
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR a=6
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ }
+} {6 16 33 37 39 40 41 42 59 61 65 80 82 93 95 scan 0 sort 0}
+do_test where7-2.402.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=89
+ OR b=1037
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ }
+} {60 89 scan 0 sort 0}
+do_test where7-2.402.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=89
+ OR b=1037
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ }
+} {60 89 scan 0 sort 0}
+do_test where7-2.403.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR b=663
+ OR b=531
+ OR b=146
+ OR b=102
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR a=26
+ }
+} {26 28 44 46 87 89 97 scan 0 sort 0}
+do_test where7-2.403.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR b=663
+ OR b=531
+ OR b=146
+ OR b=102
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR a=26
+ }
+} {26 28 44 46 87 89 97 scan 0 sort 0}
+do_test where7-2.404.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR (g='lkjihgf' AND f GLOB 'mnopq*')
+ OR b=726
+ OR ((a BETWEEN 73 AND 75) AND a!=74)
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR c=2002
+ OR c=15015
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR b=201
+ }
+} {4 5 6 12 35 43 44 45 64 66 70 73 75 scan 0 sort 0}
+do_test where7-2.404.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR (g='lkjihgf' AND f GLOB 'mnopq*')
+ OR b=726
+ OR ((a BETWEEN 73 AND 75) AND a!=74)
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR c=2002
+ OR c=15015
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR b=201
+ }
+} {4 5 6 12 35 43 44 45 64 66 70 73 75 scan 0 sort 0}
+do_test where7-2.405.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR b=924
+ OR f='lmnopqrst'
+ OR b=1048
+ }
+} {11 37 63 72 84 89 scan 0 sort 0}
+do_test where7-2.405.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR b=924
+ OR f='lmnopqrst'
+ OR b=1048
+ }
+} {11 37 63 72 84 89 scan 0 sort 0}
+do_test where7-2.406.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR b=198
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=286
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ }
+} {12 14 18 20 22 26 58 63 65 67 scan 0 sort 0}
+do_test where7-2.406.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR b=198
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=286
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ }
+} {12 14 18 20 22 26 58 63 65 67 scan 0 sort 0}
+do_test where7-2.407.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=242
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR f='bcdefghij'
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR a=38
+ OR b=187
+ }
+} {1 17 19 22 27 38 53 57 59 79 88 99 scan 0 sort 0}
+do_test where7-2.407.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=242
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR f='bcdefghij'
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR a=38
+ OR b=187
+ }
+} {1 17 19 22 27 38 53 57 59 79 88 99 scan 0 sort 0}
+do_test where7-2.408.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR b=630
+ OR a=55
+ OR c=26026
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ }
+} {10 23 55 68 76 77 78 scan 0 sort 0}
+do_test where7-2.408.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR b=630
+ OR a=55
+ OR c=26026
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ }
+} {10 23 55 68 76 77 78 scan 0 sort 0}
+do_test where7-2.409.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='uvwxyzabc'
+ OR f='xyzabcdef'
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR b=69
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ }
+} {8 20 23 31 34 46 49 51 53 60 70 72 75 79 86 98 scan 0 sort 0}
+do_test where7-2.409.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='uvwxyzabc'
+ OR f='xyzabcdef'
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR b=69
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ }
+} {8 20 23 31 34 46 49 51 53 60 70 72 75 79 86 98 scan 0 sort 0}
+do_test where7-2.410.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1026
+ OR b=454
+ OR ((a BETWEEN 92 AND 94) AND a!=93)
+ OR b=179
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR f='qrstuvwxy'
+ }
+} {16 26 42 52 68 78 92 94 scan 0 sort 0}
+do_test where7-2.410.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1026
+ OR b=454
+ OR ((a BETWEEN 92 AND 94) AND a!=93)
+ OR b=179
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR f='qrstuvwxy'
+ }
+} {16 26 42 52 68 78 92 94 scan 0 sort 0}
+do_test where7-2.411.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 6 AND 8) AND a!=7)
+ OR b=619
+ OR a=20
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ OR b=946
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR a=64
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR b=1001
+ OR b=858
+ }
+} {6 8 13 17 19 20 61 64 78 86 91 scan 0 sort 0}
+do_test where7-2.411.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 6 AND 8) AND a!=7)
+ OR b=619
+ OR a=20
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ OR b=946
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR a=64
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR b=1001
+ OR b=858
+ }
+} {6 8 13 17 19 20 61 64 78 86 91 scan 0 sort 0}
+do_test where7-2.412.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=902
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR a=86
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ }
+} {27 82 86 97 scan 0 sort 0}
+do_test where7-2.412.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=902
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR a=86
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ }
+} {27 82 86 97 scan 0 sort 0}
+do_test where7-2.413.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR a=32
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR c=32032
+ }
+} {4 32 38 56 94 95 96 scan 0 sort 0}
+do_test where7-2.413.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR a=32
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR c=32032
+ }
+} {4 32 38 56 94 95 96 scan 0 sort 0}
+do_test where7-2.414.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=168
+ OR c=2002
+ OR b=77
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR f='qrstuvwxy'
+ }
+} {4 5 6 7 16 27 42 68 94 scan 0 sort 0}
+do_test where7-2.414.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=168
+ OR c=2002
+ OR b=77
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR f='qrstuvwxy'
+ }
+} {4 5 6 7 16 27 42 68 94 scan 0 sort 0}
+do_test where7-2.415.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='abcdefghi'
+ OR b=506
+ }
+} {26 46 52 78 scan 0 sort 0}
+do_test where7-2.415.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='abcdefghi'
+ OR b=506
+ }
+} {26 46 52 78 scan 0 sort 0}
+do_test where7-2.416.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=264
+ OR c=34034
+ OR a=96
+ }
+} {24 96 100 scan 0 sort 0}
+do_test where7-2.416.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=264
+ OR c=34034
+ OR a=96
+ }
+} {24 96 100 scan 0 sort 0}
+do_test where7-2.417.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=32.0 AND d<33.0 AND d NOT NULL)
+ OR a=27
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ }
+} {19 27 32 55 57 scan 0 sort 0}
+do_test where7-2.417.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=32.0 AND d<33.0 AND d NOT NULL)
+ OR a=27
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ }
+} {19 27 32 55 57 scan 0 sort 0}
+do_test where7-2.418.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR b=77
+ }
+} {7 74 scan 0 sort 0}
+do_test where7-2.418.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR b=77
+ }
+} {7 74 scan 0 sort 0}
+do_test where7-2.419.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=27027
+ OR f='vwxyzabcd'
+ OR b=1048
+ OR a=96
+ OR a=99
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR b=561
+ OR b=352
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR a=95
+ }
+} {18 21 32 37 47 51 56 58 73 79 80 81 95 96 99 scan 0 sort 0}
+do_test where7-2.419.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=27027
+ OR f='vwxyzabcd'
+ OR b=1048
+ OR a=96
+ OR a=99
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR b=561
+ OR b=352
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR a=95
+ }
+} {18 21 32 37 47 51 56 58 73 79 80 81 95 96 99 scan 0 sort 0}
+do_test where7-2.420.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=275
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR f='ghijklmno'
+ OR b=619
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=476
+ OR a=83
+ OR ((a BETWEEN 47 AND 49) AND a!=48)
+ }
+} {6 10 12 25 32 47 49 58 83 84 91 93 99 scan 0 sort 0}
+do_test where7-2.420.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=275
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR f='ghijklmno'
+ OR b=619
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=476
+ OR a=83
+ OR ((a BETWEEN 47 AND 49) AND a!=48)
+ }
+} {6 10 12 25 32 47 49 58 83 84 91 93 99 scan 0 sort 0}
+do_test where7-2.421.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=542
+ OR a=17
+ OR f='jklmnopqr'
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ OR a=23
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ }
+} {5 7 9 17 23 25 35 39 61 87 scan 0 sort 0}
+do_test where7-2.421.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=542
+ OR a=17
+ OR f='jklmnopqr'
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ OR a=23
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ }
+} {5 7 9 17 23 25 35 39 61 87 scan 0 sort 0}
+do_test where7-2.422.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR b=363
+ OR b=454
+ }
+} {33 74 scan 0 sort 0}
+do_test where7-2.422.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR b=363
+ OR b=454
+ }
+} {33 74 scan 0 sort 0}
+do_test where7-2.423.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1059
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR b=47
+ OR b=660
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ OR a=84
+ }
+} {34 35 36 60 76 84 scan 0 sort 0}
+do_test where7-2.423.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1059
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR b=47
+ OR b=660
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ OR a=84
+ }
+} {34 35 36 60 76 84 scan 0 sort 0}
+do_test where7-2.424.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='ghijklmno'
+ OR b=1012
+ }
+} {6 32 58 84 92 scan 0 sort 0}
+do_test where7-2.424.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='ghijklmno'
+ OR b=1012
+ }
+} {6 32 58 84 92 scan 0 sort 0}
+do_test where7-2.425.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=597
+ OR f='lmnopqrst'
+ OR a=24
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR b=1023
+ OR a=53
+ OR a=78
+ OR f='efghijklm'
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ }
+} {4 11 24 30 31 33 37 53 56 63 78 82 85 89 93 96 scan 0 sort 0}
+do_test where7-2.425.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=597
+ OR f='lmnopqrst'
+ OR a=24
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR b=1023
+ OR a=53
+ OR a=78
+ OR f='efghijklm'
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ }
+} {4 11 24 30 31 33 37 53 56 63 78 82 85 89 93 96 scan 0 sort 0}
+do_test where7-2.426.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=198
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR b=388
+ }
+} {18 94 scan 0 sort 0}
+do_test where7-2.426.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=198
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR b=388
+ }
+} {18 94 scan 0 sort 0}
+do_test where7-2.427.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='tuvwxyzab'
+ OR b=388
+ OR ((a BETWEEN 84 AND 86) AND a!=85)
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR b=957
+ OR b=663
+ OR b=847
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ }
+} {19 45 71 73 77 84 86 87 96 97 scan 0 sort 0}
+do_test where7-2.427.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='tuvwxyzab'
+ OR b=388
+ OR ((a BETWEEN 84 AND 86) AND a!=85)
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR b=957
+ OR b=663
+ OR b=847
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ }
+} {19 45 71 73 77 84 86 87 96 97 scan 0 sort 0}
+do_test where7-2.428.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR a=56
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ }
+} {56 81 84 scan 0 sort 0}
+do_test where7-2.428.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR a=56
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ }
+} {56 81 84 scan 0 sort 0}
+do_test where7-2.429.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c>=34035
+ OR b=168
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ }
+} {1 27 53 79 89 scan 0 sort 0}
+do_test where7-2.429.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c>=34035
+ OR b=168
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ }
+} {1 27 53 79 89 scan 0 sort 0}
+do_test where7-2.430.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 79 AND 81) AND a!=80)
+ OR b=564
+ OR c=6006
+ OR b=979
+ }
+} {16 17 18 79 81 89 scan 0 sort 0}
+do_test where7-2.430.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 79 AND 81) AND a!=80)
+ OR b=564
+ OR c=6006
+ OR b=979
+ }
+} {16 17 18 79 81 89 scan 0 sort 0}
+do_test where7-2.431.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR f='rstuvwxyz'
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ }
+} {17 29 39 40 43 69 95 scan 0 sort 0}
+do_test where7-2.431.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR f='rstuvwxyz'
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ }
+} {17 29 39 40 43 69 95 scan 0 sort 0}
+do_test where7-2.432.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=58
+ OR b=484
+ OR (d>=68.0 AND d<69.0 AND d NOT NULL)
+ OR b=671
+ OR a=69
+ }
+} {44 61 68 69 scan 0 sort 0}
+do_test where7-2.432.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=58
+ OR b=484
+ OR (d>=68.0 AND d<69.0 AND d NOT NULL)
+ OR b=671
+ OR a=69
+ }
+} {44 61 68 69 scan 0 sort 0}
+do_test where7-2.433.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='mnopqrstu'
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR b=861
+ OR b=77
+ OR f='qrstuvwxy'
+ }
+} {7 12 16 38 42 64 68 73 90 94 scan 0 sort 0}
+do_test where7-2.433.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='mnopqrstu'
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR b=861
+ OR b=77
+ OR f='qrstuvwxy'
+ }
+} {7 12 16 38 42 64 68 73 90 94 scan 0 sort 0}
+do_test where7-2.434.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=113
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR b=113
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR ((a BETWEEN 62 AND 64) AND a!=63)
+ OR c=6006
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ OR b=946
+ OR a=86
+ }
+} {4 14 16 17 18 51 62 64 86 scan 0 sort 0}
+do_test where7-2.434.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=113
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR b=113
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR ((a BETWEEN 62 AND 64) AND a!=63)
+ OR c=6006
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ OR b=946
+ OR a=86
+ }
+} {4 14 16 17 18 51 62 64 86 scan 0 sort 0}
+do_test where7-2.435.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR c=22022
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR c=25025
+ }
+} {8 10 64 65 66 73 74 75 79 81 85 scan 0 sort 0}
+do_test where7-2.435.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR c=22022
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR c=25025
+ }
+} {8 10 64 65 66 73 74 75 79 81 85 scan 0 sort 0}
+do_test where7-2.436.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 74 AND 76) AND a!=75)
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR b=47
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR a=92
+ OR b=795
+ OR b=25
+ OR c=7007
+ OR a=93
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ }
+} {14 18 19 20 21 40 44 46 66 74 76 92 93 95 scan 0 sort 0}
+do_test where7-2.436.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 74 AND 76) AND a!=75)
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR b=47
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR a=92
+ OR b=795
+ OR b=25
+ OR c=7007
+ OR a=93
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ }
+} {14 18 19 20 21 40 44 46 66 74 76 92 93 95 scan 0 sort 0}
+do_test where7-2.437.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR a=13
+ OR (g='fedcbaz' AND f GLOB 'qrstu*')
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR c=29029
+ OR b=311
+ OR b=366
+ OR a=94
+ OR a=72
+ }
+} {6 13 66 72 85 86 87 94 scan 0 sort 0}
+do_test where7-2.437.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR a=13
+ OR (g='fedcbaz' AND f GLOB 'qrstu*')
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR c=29029
+ OR b=311
+ OR b=366
+ OR a=94
+ OR a=72
+ }
+} {6 13 66 72 85 86 87 94 scan 0 sort 0}
+do_test where7-2.438.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=26026
+ OR a=96
+ OR a=22
+ OR b=341
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR b=872
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ }
+} {2 22 25 27 31 76 77 78 96 scan 0 sort 0}
+do_test where7-2.438.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=26026
+ OR a=96
+ OR a=22
+ OR b=341
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR b=872
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ }
+} {2 22 25 27 31 76 77 78 96 scan 0 sort 0}
+do_test where7-2.439.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=41
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR (g='onmlkji' AND f GLOB 'zabcd*')
+ OR b=913
+ }
+} {6 23 36 41 51 63 65 82 83 scan 0 sort 0}
+do_test where7-2.439.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=41
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR (g='onmlkji' AND f GLOB 'zabcd*')
+ OR b=913
+ }
+} {6 23 36 41 51 63 65 82 83 scan 0 sort 0}
+do_test where7-2.440.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 42 AND 44) AND a!=43)
+ OR a=90
+ }
+} {42 44 90 scan 0 sort 0}
+do_test where7-2.440.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 42 AND 44) AND a!=43)
+ OR a=90
+ }
+} {42 44 90 scan 0 sort 0}
+do_test where7-2.441.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR b=484
+ }
+} {21 44 scan 0 sort 0}
+do_test where7-2.441.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR b=484
+ }
+} {21 44 scan 0 sort 0}
+do_test where7-2.442.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR b=377
+ OR b=363
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR b=737
+ OR (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR b=506
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR a=16
+ }
+} {16 22 25 33 46 55 57 67 100 scan 0 sort 0}
+do_test where7-2.442.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR b=377
+ OR b=363
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR b=737
+ OR (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR b=506
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR a=16
+ }
+} {16 22 25 33 46 55 57 67 100 scan 0 sort 0}
+do_test where7-2.443.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='jihgfed' AND f GLOB 'zabcd*')
+ OR b=102
+ OR b=212
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR b=487
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ }
+} {37 77 82 scan 0 sort 0}
+do_test where7-2.443.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='jihgfed' AND f GLOB 'zabcd*')
+ OR b=102
+ OR b=212
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR b=487
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ }
+} {37 77 82 scan 0 sort 0}
+do_test where7-2.444.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=154
+ OR a=51
+ OR b=520
+ }
+} {14 51 scan 0 sort 0}
+do_test where7-2.444.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=154
+ OR a=51
+ OR b=520
+ }
+} {14 51 scan 0 sort 0}
+do_test where7-2.445.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=872
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR b=957
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR a=67
+ OR a=72
+ }
+} {21 42 47 58 60 67 72 73 87 99 scan 0 sort 0}
+do_test where7-2.445.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=872
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR b=957
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR a=67
+ OR a=72
+ }
+} {21 42 47 58 60 67 72 73 87 99 scan 0 sort 0}
+do_test where7-2.446.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=66
+ OR b=102
+ OR b=396
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ OR b=759
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR f='ghijklmno'
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ }
+} {6 7 9 14 32 36 58 69 84 90 92 97 100 scan 0 sort 0}
+do_test where7-2.446.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=66
+ OR b=102
+ OR b=396
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ OR b=759
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR f='ghijklmno'
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ }
+} {6 7 9 14 32 36 58 69 84 90 92 97 100 scan 0 sort 0}
+do_test where7-2.447.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR a=72
+ OR b=1100
+ OR b=102
+ OR b=135
+ }
+} {24 48 50 69 71 72 76 100 scan 0 sort 0}
+do_test where7-2.447.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR a=72
+ OR b=1100
+ OR b=102
+ OR b=135
+ }
+} {24 48 50 69 71 72 76 100 scan 0 sort 0}
+do_test where7-2.448.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=99
+ OR a=76
+ }
+} {9 76 scan 0 sort 0}
+do_test where7-2.448.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=99
+ OR a=76
+ }
+} {9 76 scan 0 sort 0}
+do_test where7-2.449.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=891
+ OR b=806
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR b=861
+ OR ((a BETWEEN 82 AND 84) AND a!=83)
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ }
+} {19 34 81 82 84 85 87 scan 0 sort 0}
+do_test where7-2.449.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=891
+ OR b=806
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR b=861
+ OR ((a BETWEEN 82 AND 84) AND a!=83)
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ }
+} {19 34 81 82 84 85 87 scan 0 sort 0}
+do_test where7-2.450.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1034
+ OR b=91
+ }
+} {94 scan 0 sort 0}
+do_test where7-2.450.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1034
+ OR b=91
+ }
+} {94 scan 0 sort 0}
+do_test where7-2.451.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=47
+ OR a=91
+ OR d>1e10
+ OR (g='srqponm' AND f GLOB 'cdefg*')
+ }
+} {28 91 scan 0 sort 0}
+do_test where7-2.451.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=47
+ OR a=91
+ OR d>1e10
+ OR (g='srqponm' AND f GLOB 'cdefg*')
+ }
+} {28 91 scan 0 sort 0}
+do_test where7-2.452.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1023
+ OR f='zabcdefgh'
+ OR b=451
+ OR b=443
+ OR c>=34035
+ OR b=58
+ }
+} {25 41 51 77 93 scan 0 sort 0}
+do_test where7-2.452.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1023
+ OR f='zabcdefgh'
+ OR b=451
+ OR b=443
+ OR c>=34035
+ OR b=58
+ }
+} {25 41 51 77 93 scan 0 sort 0}
+do_test where7-2.453.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=971
+ OR b=36
+ OR a=11
+ OR f='hijklmnop'
+ }
+} {7 11 33 59 85 scan 0 sort 0}
+do_test where7-2.453.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=971
+ OR b=36
+ OR a=11
+ OR f='hijklmnop'
+ }
+} {7 11 33 59 85 scan 0 sort 0}
+do_test where7-2.454.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR b=619
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR c=11011
+ OR b=550
+ OR b=1059
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR b=737
+ }
+} {3 18 29 31 32 33 50 55 67 78 81 84 91 92 93 scan 0 sort 0}
+do_test where7-2.454.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR b=619
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR c=11011
+ OR b=550
+ OR b=1059
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR b=737
+ }
+} {3 18 29 31 32 33 50 55 67 78 81 84 91 92 93 scan 0 sort 0}
+do_test where7-2.455.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR a=78
+ OR a=27
+ OR b=792
+ OR b=946
+ OR c=22022
+ OR a=23
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR b=388
+ }
+} {13 23 27 39 59 61 64 65 66 72 78 80 86 91 99 scan 0 sort 0}
+do_test where7-2.455.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR a=78
+ OR a=27
+ OR b=792
+ OR b=946
+ OR c=22022
+ OR a=23
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR b=388
+ }
+} {13 23 27 39 59 61 64 65 66 72 78 80 86 91 99 scan 0 sort 0}
+do_test where7-2.456.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=32032
+ OR f IS NULL
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR b=825
+ }
+} {4 37 39 74 75 94 95 96 scan 0 sort 0}
+do_test where7-2.456.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=32032
+ OR f IS NULL
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR b=825
+ }
+} {4 37 39 74 75 94 95 96 scan 0 sort 0}
+do_test where7-2.457.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=84.0 AND d<85.0 AND d NOT NULL)
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR b=1078
+ OR b=198
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR b=55
+ OR b=517
+ OR b=740
+ }
+} {5 7 18 21 47 54 67 73 84 98 99 scan 0 sort 0}
+do_test where7-2.457.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=84.0 AND d<85.0 AND d NOT NULL)
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR b=1078
+ OR b=198
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR b=55
+ OR b=517
+ OR b=740
+ }
+} {5 7 18 21 47 54 67 73 84 98 99 scan 0 sort 0}
+do_test where7-2.458.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR c=25025
+ OR b=550
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ }
+} {8 22 50 53 73 74 75 scan 0 sort 0}
+do_test where7-2.458.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR c=25025
+ OR b=550
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ }
+} {8 22 50 53 73 74 75 scan 0 sort 0}
+do_test where7-2.459.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=432
+ OR f='opqrstuvw'
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ }
+} {14 40 66 68 92 scan 0 sort 0}
+do_test where7-2.459.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=432
+ OR f='opqrstuvw'
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ }
+} {14 40 66 68 92 scan 0 sort 0}
+do_test where7-2.460.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 14 AND 16) AND a!=15)
+ OR b=847
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR b=583
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR b=938
+ }
+} {11 14 16 26 37 40 42 53 63 65 75 77 89 scan 0 sort 0}
+do_test where7-2.460.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 14 AND 16) AND a!=15)
+ OR b=847
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR b=583
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR b=938
+ }
+} {11 14 16 26 37 40 42 53 63 65 75 77 89 scan 0 sort 0}
+do_test where7-2.461.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=671
+ OR a=56
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR b=157
+ OR a=83
+ OR ((a BETWEEN 73 AND 75) AND a!=74)
+ OR c=21021
+ OR b=319
+ OR b=187
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ OR b=839
+ }
+} {17 29 49 56 61 62 63 65 67 73 75 83 scan 0 sort 0}
+do_test where7-2.461.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=671
+ OR a=56
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR b=157
+ OR a=83
+ OR ((a BETWEEN 73 AND 75) AND a!=74)
+ OR c=21021
+ OR b=319
+ OR b=187
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ OR b=839
+ }
+} {17 29 49 56 61 62 63 65 67 73 75 83 scan 0 sort 0}
+do_test where7-2.462.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR b=586
+ OR d<0.0
+ OR c=9009
+ }
+} {25 26 27 72 scan 0 sort 0}
+do_test where7-2.462.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR b=586
+ OR d<0.0
+ OR c=9009
+ }
+} {25 26 27 72 scan 0 sort 0}
+do_test where7-2.463.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=82
+ OR a=34
+ OR f='jklmnopqr'
+ OR a=82
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=454
+ OR b=355
+ OR c=21021
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=30
+ }
+} {9 16 30 34 35 61 62 63 65 82 87 scan 0 sort 0}
+do_test where7-2.463.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=82
+ OR a=34
+ OR f='jklmnopqr'
+ OR a=82
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=454
+ OR b=355
+ OR c=21021
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=30
+ }
+} {9 16 30 34 35 61 62 63 65 82 87 scan 0 sort 0}
+do_test where7-2.464.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 44 AND 46) AND a!=45)
+ OR a=53
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR b=594
+ OR b=80
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR d>1e10
+ }
+} {18 20 23 44 46 49 53 54 scan 0 sort 0}
+do_test where7-2.464.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 44 AND 46) AND a!=45)
+ OR a=53
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR b=594
+ OR b=80
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR d>1e10
+ }
+} {18 20 23 44 46 49 53 54 scan 0 sort 0}
+do_test where7-2.465.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='opqrstuvw'
+ OR a=7
+ }
+} {7 14 40 66 92 scan 0 sort 0}
+do_test where7-2.465.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='opqrstuvw'
+ OR a=7
+ }
+} {7 14 40 66 92 scan 0 sort 0}
+do_test where7-2.466.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=627
+ OR ((a BETWEEN 75 AND 77) AND a!=76)
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR a=90
+ OR (d>=33.0 AND d<34.0 AND d NOT NULL)
+ }
+} {33 43 45 57 75 77 90 scan 0 sort 0}
+do_test where7-2.466.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=627
+ OR ((a BETWEEN 75 AND 77) AND a!=76)
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR a=90
+ OR (d>=33.0 AND d<34.0 AND d NOT NULL)
+ }
+} {33 43 45 57 75 77 90 scan 0 sort 0}
+do_test where7-2.467.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=59
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR f='wxyzabcde'
+ OR (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ OR a=70
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {5 9 14 16 22 23 25 48 51 59 69 70 71 74 77 100 scan 0 sort 0}
+do_test where7-2.467.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=59
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR f='wxyzabcde'
+ OR (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ OR a=70
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {5 9 14 16 22 23 25 48 51 59 69 70 71 74 77 100 scan 0 sort 0}
+do_test where7-2.468.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=69
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ }
+} {69 81 scan 0 sort 0}
+do_test where7-2.468.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=69
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ }
+} {69 81 scan 0 sort 0}
+do_test where7-2.469.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=41
+ OR a=43
+ OR a=92
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR (g='mlkjihg' AND f GLOB 'klmno*')
+ }
+} {41 43 62 92 95 scan 0 sort 0}
+do_test where7-2.469.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=41
+ OR a=43
+ OR a=92
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR (g='mlkjihg' AND f GLOB 'klmno*')
+ }
+} {41 43 62 92 95 scan 0 sort 0}
+do_test where7-2.470.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=300
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR b=935
+ OR b=190
+ }
+} {52 85 scan 0 sort 0}
+do_test where7-2.470.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=300
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR b=935
+ OR b=190
+ }
+} {52 85 scan 0 sort 0}
+do_test where7-2.471.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='fghijklmn'
+ OR f='fghijklmn'
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR b=465
+ OR b=586
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR b=88
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR b=726
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ }
+} {4 5 8 20 30 31 32 51 53 57 66 83 scan 0 sort 0}
+do_test where7-2.471.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='fghijklmn'
+ OR f='fghijklmn'
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR b=465
+ OR b=586
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR b=88
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR b=726
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ }
+} {4 5 8 20 30 31 32 51 53 57 66 83 scan 0 sort 0}
+do_test where7-2.472.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR b=814
+ OR a=20
+ OR 1000000<b
+ OR b=792
+ }
+} {20 25 34 51 72 74 77 85 97 100 scan 0 sort 0}
+do_test where7-2.472.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR b=814
+ OR a=20
+ OR 1000000<b
+ OR b=792
+ }
+} {20 25 34 51 72 74 77 85 97 100 scan 0 sort 0}
+do_test where7-2.473.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR c=1001
+ OR b=484
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ OR c<=10
+ OR a=92
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR ((a BETWEEN 0 AND 2) AND a!=1)
+ OR b=1026
+ }
+} {1 2 3 25 44 53 55 65 72 92 scan 0 sort 0}
+do_test where7-2.473.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR c=1001
+ OR b=484
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ OR c<=10
+ OR a=92
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR ((a BETWEEN 0 AND 2) AND a!=1)
+ OR b=1026
+ }
+} {1 2 3 25 44 53 55 65 72 92 scan 0 sort 0}
+do_test where7-2.474.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=54
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR b=993
+ OR c=22022
+ OR a=68
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ OR a=62
+ OR (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR b=1015
+ }
+} {3 29 54 55 62 64 65 66 68 81 99 scan 0 sort 0}
+do_test where7-2.474.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=54
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR b=993
+ OR c=22022
+ OR a=68
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ OR a=62
+ OR (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR b=1015
+ }
+} {3 29 54 55 62 64 65 66 68 81 99 scan 0 sort 0}
+do_test where7-2.475.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=319
+ OR a=50
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR a=96
+ }
+} {10 29 50 55 92 96 scan 0 sort 0}
+do_test where7-2.475.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=319
+ OR a=50
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR a=96
+ }
+} {10 29 50 55 92 96 scan 0 sort 0}
+do_test where7-2.476.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=971
+ OR c=18018
+ OR b=564
+ OR b=583
+ OR b=80
+ }
+} {52 53 54 scan 0 sort 0}
+do_test where7-2.476.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=971
+ OR c=18018
+ OR b=564
+ OR b=583
+ OR b=80
+ }
+} {52 53 54 scan 0 sort 0}
+do_test where7-2.477.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=35.0 AND d<36.0 AND d NOT NULL)
+ OR b=1026
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {14 16 35 scan 0 sort 0}
+do_test where7-2.477.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=35.0 AND d<36.0 AND d NOT NULL)
+ OR b=1026
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {14 16 35 scan 0 sort 0}
+do_test where7-2.478.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR b=407
+ OR b=454
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR b=627
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ }
+} {9 13 34 35 37 39 46 57 61 65 87 91 scan 0 sort 0}
+do_test where7-2.478.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR b=407
+ OR b=454
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR b=627
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ }
+} {9 13 34 35 37 39 46 57 61 65 87 91 scan 0 sort 0}
+do_test where7-2.479.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR c=34034
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR a=67
+ }
+} {6 18 20 24 26 32 58 67 79 84 100 scan 0 sort 0}
+do_test where7-2.479.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR c=34034
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR a=67
+ }
+} {6 18 20 24 26 32 58 67 79 84 100 scan 0 sort 0}
+do_test where7-2.480.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=97
+ OR b=575
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ }
+} {1 2 4 16 42 68 81 94 97 scan 0 sort 0}
+do_test where7-2.480.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=97
+ OR b=575
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ }
+} {1 2 4 16 42 68 81 94 97 scan 0 sort 0}
+do_test where7-2.481.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=561
+ OR b=773
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR b=201
+ OR a=99
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR b=946
+ OR b=993
+ OR (g='fedcbaz' AND f GLOB 'qrstu*')
+ }
+} {19 23 36 38 46 51 86 94 99 scan 0 sort 0}
+do_test where7-2.481.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=561
+ OR b=773
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR b=201
+ OR a=99
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR b=946
+ OR b=993
+ OR (g='fedcbaz' AND f GLOB 'qrstu*')
+ }
+} {19 23 36 38 46 51 86 94 99 scan 0 sort 0}
+do_test where7-2.482.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=806
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR b=916
+ OR b<0
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR b=154
+ OR c=10010
+ OR b=451
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ }
+} {14 24 26 28 29 30 41 62 72 scan 0 sort 0}
+do_test where7-2.482.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=806
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR b=916
+ OR b<0
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR b=154
+ OR c=10010
+ OR b=451
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ }
+} {14 24 26 28 29 30 41 62 72 scan 0 sort 0}
+do_test where7-2.483.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=836
+ OR d>1e10
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR f='pqrstuvwx'
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR f='abcdefghi'
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR a=33
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR b=476
+ }
+} {3 5 15 19 20 21 26 33 41 52 57 67 76 78 88 90 93 scan 0 sort 0}
+do_test where7-2.483.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=836
+ OR d>1e10
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR f='pqrstuvwx'
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR f='abcdefghi'
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR a=33
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR b=476
+ }
+} {3 5 15 19 20 21 26 33 41 52 57 67 76 78 88 90 93 scan 0 sort 0}
+do_test where7-2.484.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=48
+ OR a=92
+ OR a=1
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR b=905
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ }
+} {1 4 7 28 30 37 48 51 53 56 82 92 scan 0 sort 0}
+do_test where7-2.484.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=48
+ OR a=92
+ OR a=1
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR b=905
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ }
+} {1 4 7 28 30 37 48 51 53 56 82 92 scan 0 sort 0}
+do_test where7-2.485.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR b=212
+ OR a=42
+ OR a=92
+ }
+} {4 17 42 92 scan 0 sort 0}
+do_test where7-2.485.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR b=212
+ OR a=42
+ OR a=92
+ }
+} {4 17 42 92 scan 0 sort 0}
+do_test where7-2.486.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=740
+ OR b=564
+ OR (g='onmlkji' AND f GLOB 'zabcd*')
+ OR a=11
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR b=322
+ OR (d>=6.0 AND d<7.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR b=902
+ OR c>=34035
+ }
+} {6 11 22 44 46 51 82 scan 0 sort 0}
+do_test where7-2.486.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=740
+ OR b=564
+ OR (g='onmlkji' AND f GLOB 'zabcd*')
+ OR a=11
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR b=322
+ OR (d>=6.0 AND d<7.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR b=902
+ OR c>=34035
+ }
+} {6 11 22 44 46 51 82 scan 0 sort 0}
+do_test where7-2.487.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 52 AND 54) AND a!=53)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR a=27
+ OR a=48
+ OR b=927
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR f='abcdefghi'
+ OR b=91
+ OR b=55
+ }
+} {5 8 26 27 48 52 54 56 58 78 89 91 96 scan 0 sort 0}
+do_test where7-2.487.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 52 AND 54) AND a!=53)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR a=27
+ OR a=48
+ OR b=927
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ OR f='abcdefghi'
+ OR b=91
+ OR b=55
+ }
+} {5 8 26 27 48 52 54 56 58 78 89 91 96 scan 0 sort 0}
+do_test where7-2.488.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='srqponm' AND f GLOB 'efghi*')
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR a=20
+ OR b=11
+ }
+} {1 20 30 88 90 scan 0 sort 0}
+do_test where7-2.488.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='srqponm' AND f GLOB 'efghi*')
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR a=20
+ OR b=11
+ }
+} {1 20 30 88 90 scan 0 sort 0}
+do_test where7-2.489.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR b=55
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR a=50
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ }
+} {5 13 27 50 51 52 64 73 scan 0 sort 0}
+do_test where7-2.489.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR b=55
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR a=50
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ }
+} {5 13 27 50 51 52 64 73 scan 0 sort 0}
+do_test where7-2.490.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='rqponml' AND f GLOB 'ijklm*')
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ }
+} {22 34 48 74 100 scan 0 sort 0}
+do_test where7-2.490.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='rqponml' AND f GLOB 'ijklm*')
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ }
+} {22 34 48 74 100 scan 0 sort 0}
+do_test where7-2.491.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=704
+ OR b=924
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR b=113
+ }
+} {64 84 90 scan 0 sort 0}
+do_test where7-2.491.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=704
+ OR b=924
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR b=113
+ }
+} {64 84 90 scan 0 sort 0}
+do_test where7-2.492.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=289
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {14 16 20 22 scan 0 sort 0}
+do_test where7-2.492.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=289
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {14 16 20 22 scan 0 sort 0}
+do_test where7-2.493.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=935
+ OR b=1001
+ OR ((a BETWEEN 78 AND 80) AND a!=79)
+ OR a=31
+ OR a=56
+ }
+} {31 56 78 80 85 91 scan 0 sort 0}
+do_test where7-2.493.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=935
+ OR b=1001
+ OR ((a BETWEEN 78 AND 80) AND a!=79)
+ OR a=31
+ OR a=56
+ }
+} {31 56 78 80 85 91 scan 0 sort 0}
+do_test where7-2.494.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR b=726
+ OR f='abcdefghi'
+ OR b=179
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR b=539
+ OR b=66
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ }
+} {6 9 19 26 35 49 52 60 61 66 78 86 87 88 scan 0 sort 0}
+do_test where7-2.494.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR b=726
+ OR f='abcdefghi'
+ OR b=179
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR b=539
+ OR b=66
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ }
+} {6 9 19 26 35 49 52 60 61 66 78 86 87 88 scan 0 sort 0}
+do_test where7-2.495.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=179
+ OR b=685
+ }
+} { scan 0 sort 0}
+do_test where7-2.495.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=179
+ OR b=685
+ }
+} { scan 0 sort 0}
+do_test where7-2.496.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=201
+ OR b=682
+ OR b=443
+ OR b=836
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ OR b=110
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ }
+} {2 10 11 13 28 39 51 53 54 62 65 76 80 91 scan 0 sort 0}
+do_test where7-2.496.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=201
+ OR b=682
+ OR b=443
+ OR b=836
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR ((a BETWEEN 51 AND 53) AND a!=52)
+ OR b=110
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ }
+} {2 10 11 13 28 39 51 53 54 62 65 76 80 91 scan 0 sort 0}
+do_test where7-2.497.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR b=462
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR a=22
+ OR b=594
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ }
+} {4 6 18 22 24 42 44 50 54 57 61 70 74 76 96 scan 0 sort 0}
+do_test where7-2.497.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR b=462
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR a=22
+ OR b=594
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ }
+} {4 6 18 22 24 42 44 50 54 57 61 70 74 76 96 scan 0 sort 0}
+do_test where7-2.498.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR f='vwxyzabcd'
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ OR a=37
+ OR a=50
+ }
+} {1 10 13 21 22 37 47 50 73 99 scan 0 sort 0}
+do_test where7-2.498.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR f='vwxyzabcd'
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ OR a=37
+ OR a=50
+ }
+} {1 10 13 21 22 37 47 50 73 99 scan 0 sort 0}
+do_test where7-2.499.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 83 AND 85) AND a!=84)
+ OR b=784
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ OR b=825
+ OR a=80
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR b=531
+ OR a=100
+ }
+} {20 23 46 72 75 80 83 85 97 98 100 scan 0 sort 0}
+do_test where7-2.499.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 83 AND 85) AND a!=84)
+ OR b=784
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ OR b=825
+ OR a=80
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR b=531
+ OR a=100
+ }
+} {20 23 46 72 75 80 83 85 97 98 100 scan 0 sort 0}
+do_test where7-2.500.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR b=220
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ }
+} {19 20 53 scan 0 sort 0}
+do_test where7-2.500.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR b=220
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ }
+} {19 20 53 scan 0 sort 0}
+do_test where7-2.501.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=92
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR b=990
+ }
+} {9 90 92 scan 0 sort 0}
+do_test where7-2.501.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=92
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR b=990
+ }
+} {9 90 92 scan 0 sort 0}
+do_test where7-2.502.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 77 AND 79) AND a!=78)
+ OR b=894
+ OR c=28028
+ OR b=905
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR b=1037
+ }
+} {26 45 52 70 77 78 79 82 83 84 scan 0 sort 0}
+do_test where7-2.502.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 77 AND 79) AND a!=78)
+ OR b=894
+ OR c=28028
+ OR b=905
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR b=1037
+ }
+} {26 45 52 70 77 78 79 82 83 84 scan 0 sort 0}
+do_test where7-2.503.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR b=773
+ OR f='defghijkl'
+ }
+} {3 29 55 72 81 scan 0 sort 0}
+do_test where7-2.503.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR b=773
+ OR f='defghijkl'
+ }
+} {3 29 55 72 81 scan 0 sort 0}
+do_test where7-2.504.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR b=861
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ }
+} {12 37 scan 0 sort 0}
+do_test where7-2.504.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR b=861
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ }
+} {12 37 scan 0 sort 0}
+do_test where7-2.505.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=704
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR b=25
+ OR (g='jihgfed' AND f GLOB 'zabcd*')
+ OR b=487
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (d>=84.0 AND d<85.0 AND d NOT NULL)
+ }
+} {10 23 51 64 77 79 83 84 89 scan 0 sort 0}
+do_test where7-2.505.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=704
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR b=25
+ OR (g='jihgfed' AND f GLOB 'zabcd*')
+ OR b=487
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (d>=84.0 AND d<85.0 AND d NOT NULL)
+ }
+} {10 23 51 64 77 79 83 84 89 scan 0 sort 0}
+do_test where7-2.506.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=19
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ OR b=674
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR b=355
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR c=28028
+ OR b=649
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ }
+} {17 19 31 41 49 59 60 72 74 82 83 84 scan 0 sort 0}
+do_test where7-2.506.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=19
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ OR b=674
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR b=355
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR c=28028
+ OR b=649
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ }
+} {17 19 31 41 49 59 60 72 74 82 83 84 scan 0 sort 0}
+do_test where7-2.507.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 76 AND 78) AND a!=77)
+ OR a=1
+ OR a=22
+ OR b=836
+ OR c=24024
+ }
+} {1 22 70 71 72 76 78 scan 0 sort 0}
+do_test where7-2.507.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 76 AND 78) AND a!=77)
+ OR a=1
+ OR a=22
+ OR b=836
+ OR c=24024
+ }
+} {1 22 70 71 72 76 78 scan 0 sort 0}
+do_test where7-2.508.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=135
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ }
+} {20 39 41 scan 0 sort 0}
+do_test where7-2.508.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=135
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ }
+} {20 39 41 scan 0 sort 0}
+do_test where7-2.509.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ }
+} {9 35 61 86 87 scan 0 sort 0}
+do_test where7-2.509.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ }
+} {9 35 61 86 87 scan 0 sort 0}
+do_test where7-2.510.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='jihgfed' AND f GLOB 'wxyza*')
+ OR f='ghijklmno'
+ }
+} {6 32 58 74 84 scan 0 sort 0}
+do_test where7-2.510.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='jihgfed' AND f GLOB 'wxyza*')
+ OR f='ghijklmno'
+ }
+} {6 32 58 74 84 scan 0 sort 0}
+do_test where7-2.511.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=825
+ OR b=902
+ OR a=40
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR a=30
+ OR a=10
+ OR a=73
+ }
+} {10 28 30 40 73 75 82 scan 0 sort 0}
+do_test where7-2.511.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=825
+ OR b=902
+ OR a=40
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR a=30
+ OR a=10
+ OR a=73
+ }
+} {10 28 30 40 73 75 82 scan 0 sort 0}
+do_test where7-2.512.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 22 AND 24) AND a!=23)
+ OR a=5
+ OR b=432
+ OR b=979
+ OR b=762
+ OR b=352
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR c=27027
+ OR c=20020
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ }
+} {5 22 23 24 32 36 38 58 59 60 79 80 81 89 scan 0 sort 0}
+do_test where7-2.512.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 22 AND 24) AND a!=23)
+ OR a=5
+ OR b=432
+ OR b=979
+ OR b=762
+ OR b=352
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR c=27027
+ OR c=20020
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ }
+} {5 22 23 24 32 36 38 58 59 60 79 80 81 89 scan 0 sort 0}
+do_test where7-2.513.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?lmno*' AND f GLOB 'klmn*')
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ OR b=99
+ OR a=54
+ }
+} {5 7 9 10 36 54 62 88 scan 0 sort 0}
+do_test where7-2.513.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?lmno*' AND f GLOB 'klmn*')
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ OR b=99
+ OR a=54
+ }
+} {5 7 9 10 36 54 62 88 scan 0 sort 0}
+do_test where7-2.514.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=300
+ OR (g='mlkjihg' AND f GLOB 'klmno*')
+ OR b=319
+ OR f='fghijklmn'
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR ((a BETWEEN 42 AND 44) AND a!=43)
+ }
+} {5 29 31 42 44 57 62 73 83 scan 0 sort 0}
+do_test where7-2.514.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=300
+ OR (g='mlkjihg' AND f GLOB 'klmno*')
+ OR b=319
+ OR f='fghijklmn'
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR ((a BETWEEN 42 AND 44) AND a!=43)
+ }
+} {5 29 31 42 44 57 62 73 83 scan 0 sort 0}
+do_test where7-2.515.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=671
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR b=1004
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR b=748
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ }
+} {5 7 18 20 23 27 61 68 82 86 88 scan 0 sort 0}
+do_test where7-2.515.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=671
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR b=1004
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR b=748
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ }
+} {5 7 18 20 23 27 61 68 82 86 88 scan 0 sort 0}
+do_test where7-2.516.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=47
+ OR b=784
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR a=16
+ OR a=25
+ OR b=572
+ }
+} {16 21 23 25 47 52 scan 0 sort 0}
+do_test where7-2.516.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=47
+ OR b=784
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR a=16
+ OR a=25
+ OR b=572
+ }
+} {16 21 23 25 47 52 scan 0 sort 0}
+do_test where7-2.517.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR b=110
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR c=26026
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR b=850
+ OR a=6
+ }
+} {6 10 67 69 74 76 77 78 91 scan 0 sort 0}
+do_test where7-2.517.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR b=110
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR c=26026
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR b=850
+ OR a=6
+ }
+} {6 10 67 69 74 76 77 78 91 scan 0 sort 0}
+do_test where7-2.518.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 74 AND 76) AND a!=75)
+ OR ((a BETWEEN 1 AND 3) AND a!=2)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR (g='mlkjihg' AND f GLOB 'klmno*')
+ OR b=135
+ OR a=28
+ OR ((a BETWEEN 1 AND 3) AND a!=2)
+ OR b=737
+ }
+} {1 3 19 28 62 67 74 76 scan 0 sort 0}
+do_test where7-2.518.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 74 AND 76) AND a!=75)
+ OR ((a BETWEEN 1 AND 3) AND a!=2)
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR (g='mlkjihg' AND f GLOB 'klmno*')
+ OR b=135
+ OR a=28
+ OR ((a BETWEEN 1 AND 3) AND a!=2)
+ OR b=737
+ }
+} {1 3 19 28 62 67 74 76 scan 0 sort 0}
+do_test where7-2.519.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=242
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ }
+} {20 22 scan 0 sort 0}
+do_test where7-2.519.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=242
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ }
+} {20 22 scan 0 sort 0}
+do_test where7-2.520.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=528
+ OR a=41
+ OR f='cdefghijk'
+ OR a=98
+ OR b=759
+ OR a=43
+ OR b=286
+ OR f='hijklmnop'
+ }
+} {2 7 26 28 33 41 43 48 54 59 69 80 85 98 scan 0 sort 0}
+do_test where7-2.520.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=528
+ OR a=41
+ OR f='cdefghijk'
+ OR a=98
+ OR b=759
+ OR a=43
+ OR b=286
+ OR f='hijklmnop'
+ }
+} {2 7 26 28 33 41 43 48 54 59 69 80 85 98 scan 0 sort 0}
+do_test where7-2.521.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR a=52
+ }
+} {6 15 52 61 scan 0 sort 0}
+do_test where7-2.521.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR a=52
+ }
+} {6 15 52 61 scan 0 sort 0}
+do_test where7-2.522.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ihgfedc' AND f GLOB 'abcde*')
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR a=86
+ OR c=33033
+ OR c=2002
+ OR a=92
+ }
+} {2 4 5 6 78 86 92 97 98 99 scan 0 sort 0}
+do_test where7-2.522.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ihgfedc' AND f GLOB 'abcde*')
+ OR ((a BETWEEN 2 AND 4) AND a!=3)
+ OR a=86
+ OR c=33033
+ OR c=2002
+ OR a=92
+ }
+} {2 4 5 6 78 86 92 97 98 99 scan 0 sort 0}
+do_test where7-2.523.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 47 AND 49) AND a!=48)
+ OR b=517
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR f='defghijkl'
+ OR b=707
+ OR c>=34035
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR a=80
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ }
+} {3 23 29 31 33 35 47 49 55 63 67 69 80 81 scan 0 sort 0}
+do_test where7-2.523.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 47 AND 49) AND a!=48)
+ OR b=517
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR f='defghijkl'
+ OR b=707
+ OR c>=34035
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR a=80
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ }
+} {3 23 29 31 33 35 47 49 55 63 67 69 80 81 scan 0 sort 0}
+do_test where7-2.524.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR b=209
+ OR b=399
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ }
+} {19 96 97 scan 0 sort 0}
+do_test where7-2.524.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR b=209
+ OR b=399
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ }
+} {19 96 97 scan 0 sort 0}
+do_test where7-2.525.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR b=597
+ OR a=95
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR b=432
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ }
+} {18 20 24 38 50 55 76 92 95 scan 0 sort 0}
+do_test where7-2.525.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR b=597
+ OR a=95
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR b=432
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ }
+} {18 20 24 38 50 55 76 92 95 scan 0 sort 0}
+do_test where7-2.526.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR b=157
+ OR ((a BETWEEN 78 AND 80) AND a!=79)
+ OR a=3
+ OR b=663
+ OR a=2
+ OR c=21021
+ OR b=330
+ OR b=231
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ }
+} {2 3 21 27 30 61 62 63 78 80 88 scan 0 sort 0}
+do_test where7-2.526.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR b=157
+ OR ((a BETWEEN 78 AND 80) AND a!=79)
+ OR a=3
+ OR b=663
+ OR a=2
+ OR c=21021
+ OR b=330
+ OR b=231
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ }
+} {2 3 21 27 30 61 62 63 78 80 88 scan 0 sort 0}
+do_test where7-2.527.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR f IS NULL
+ }
+} {64 66 83 scan 0 sort 0}
+do_test where7-2.527.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR f IS NULL
+ }
+} {64 66 83 scan 0 sort 0}
+do_test where7-2.528.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 99 AND 101) AND a!=100)
+ OR (g='fedcbaz' AND f GLOB 'pqrst*')
+ OR 1000000<b
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ OR b=990
+ }
+} {75 90 93 99 scan 0 sort 0}
+do_test where7-2.528.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 99 AND 101) AND a!=100)
+ OR (g='fedcbaz' AND f GLOB 'pqrst*')
+ OR 1000000<b
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ OR b=990
+ }
+} {75 90 93 99 scan 0 sort 0}
+do_test where7-2.529.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=165
+ OR a=69
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ }
+} {15 44 69 scan 0 sort 0}
+do_test where7-2.529.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=165
+ OR a=69
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ }
+} {15 44 69 scan 0 sort 0}
+do_test where7-2.530.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='nmlkjih' AND f GLOB 'defgh*')
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR b=784
+ OR b=583
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR b=814
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR b=619
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ }
+} {46 53 54 55 58 74 80 scan 0 sort 0}
+do_test where7-2.530.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='nmlkjih' AND f GLOB 'defgh*')
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR b=784
+ OR b=583
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR b=814
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR b=619
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ }
+} {46 53 54 55 58 74 80 scan 0 sort 0}
+do_test where7-2.531.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=86
+ OR b=484
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR b=418
+ OR b=509
+ OR a=42
+ OR b=825
+ OR a=91
+ OR b=1023
+ OR b=814
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ }
+} {38 42 44 74 75 79 86 91 93 99 scan 0 sort 0}
+do_test where7-2.531.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=86
+ OR b=484
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR b=418
+ OR b=509
+ OR a=42
+ OR b=825
+ OR a=91
+ OR b=1023
+ OR b=814
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ }
+} {38 42 44 74 75 79 86 91 93 99 scan 0 sort 0}
+do_test where7-2.532.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR b=231
+ OR a=81
+ OR a=72
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR b=396
+ }
+} {21 24 26 36 72 81 86 scan 0 sort 0}
+do_test where7-2.532.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR b=231
+ OR a=81
+ OR a=72
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR b=396
+ }
+} {21 24 26 36 72 81 86 scan 0 sort 0}
+do_test where7-2.533.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR a=63
+ OR ((a BETWEEN 70 AND 72) AND a!=71)
+ OR a=71
+ OR b=22
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR a=53
+ }
+} {2 21 53 59 61 63 70 71 72 74 76 78 scan 0 sort 0}
+do_test where7-2.533.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR a=63
+ OR ((a BETWEEN 70 AND 72) AND a!=71)
+ OR a=71
+ OR b=22
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR a=53
+ }
+} {2 21 53 59 61 63 70 71 72 74 76 78 scan 0 sort 0}
+do_test where7-2.534.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=861
+ OR b=649
+ OR b=146
+ OR f='abcdefghi'
+ }
+} {26 52 59 78 scan 0 sort 0}
+do_test where7-2.534.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=861
+ OR b=649
+ OR b=146
+ OR f='abcdefghi'
+ }
+} {26 52 59 78 scan 0 sort 0}
+do_test where7-2.535.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR c=5005
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR a=93
+ OR c=24024
+ OR b=619
+ OR b=234
+ OR b=55
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ }
+} {5 9 13 14 15 21 35 47 50 52 56 61 70 71 72 73 87 93 99 scan 0 sort 0}
+do_test where7-2.535.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR c=5005
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR a=93
+ OR c=24024
+ OR b=619
+ OR b=234
+ OR b=55
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ }
+} {5 9 13 14 15 21 35 47 50 52 56 61 70 71 72 73 87 93 99 scan 0 sort 0}
+do_test where7-2.536.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=355
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=806
+ OR b=462
+ OR b=531
+ OR (g='lkjihgf' AND f GLOB 'lmnop*')
+ OR f='mnopqrstu'
+ }
+} {12 38 42 49 63 64 69 90 scan 0 sort 0}
+do_test where7-2.536.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=355
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=806
+ OR b=462
+ OR b=531
+ OR (g='lkjihgf' AND f GLOB 'lmnop*')
+ OR f='mnopqrstu'
+ }
+} {12 38 42 49 63 64 69 90 scan 0 sort 0}
+do_test where7-2.537.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 60 AND 62) AND a!=61)
+ OR f='pqrstuvwx'
+ OR (g='nmlkjih' AND f GLOB 'efghi*')
+ OR b=495
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR a=75
+ }
+} {15 41 45 56 60 62 67 70 75 93 scan 0 sort 0}
+do_test where7-2.537.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 60 AND 62) AND a!=61)
+ OR f='pqrstuvwx'
+ OR (g='nmlkjih' AND f GLOB 'efghi*')
+ OR b=495
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR a=75
+ }
+} {15 41 45 56 60 62 67 70 75 93 scan 0 sort 0}
+do_test where7-2.538.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'efghi*')
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR b=748
+ OR b=913
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR a=22
+ }
+} {4 5 21 22 68 83 scan 0 sort 0}
+do_test where7-2.538.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'efghi*')
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR b=748
+ OR b=913
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR a=22
+ }
+} {4 5 21 22 68 83 scan 0 sort 0}
+do_test where7-2.539.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=19
+ OR b=902
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR b=168
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR a=50
+ OR f='uvwxyzabc'
+ OR b=836
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR a=50
+ }
+} {19 20 46 50 63 65 67 72 76 77 79 82 98 scan 0 sort 0}
+do_test where7-2.539.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=19
+ OR b=902
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR b=168
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR a=50
+ OR f='uvwxyzabc'
+ OR b=836
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR a=50
+ }
+} {19 20 46 50 63 65 67 72 76 77 79 82 98 scan 0 sort 0}
+do_test where7-2.540.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=12012
+ OR b=993
+ OR b=839
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR a=87
+ }
+} {30 32 34 35 36 87 scan 0 sort 0}
+do_test where7-2.540.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=12012
+ OR b=993
+ OR b=839
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR a=87
+ }
+} {30 32 34 35 36 87 scan 0 sort 0}
+do_test where7-2.541.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=814
+ OR c=30030
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR a=16
+ OR b=1048
+ OR b=113
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR b=729
+ OR a=54
+ }
+} {3 16 34 40 54 61 74 88 89 90 scan 0 sort 0}
+do_test where7-2.541.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=814
+ OR c=30030
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR a=16
+ OR b=1048
+ OR b=113
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR b=729
+ OR a=54
+ }
+} {3 16 34 40 54 61 74 88 89 90 scan 0 sort 0}
+do_test where7-2.542.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=399
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR b=814
+ OR c=22022
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR a=1
+ OR b=311
+ OR b=121
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR b=198
+ }
+} {1 6 8 11 18 32 37 58 63 64 65 66 71 74 84 89 scan 0 sort 0}
+do_test where7-2.542.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=399
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR b=814
+ OR c=22022
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR a=1
+ OR b=311
+ OR b=121
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR b=198
+ }
+} {1 6 8 11 18 32 37 58 63 64 65 66 71 74 84 89 scan 0 sort 0}
+do_test where7-2.543.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=146
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR a=57
+ }
+} {52 57 scan 0 sort 0}
+do_test where7-2.543.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=146
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR a=57
+ }
+} {52 57 scan 0 sort 0}
+do_test where7-2.544.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR f='fghijklmn'
+ OR a=70
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ }
+} {4 5 31 57 70 83 100 scan 0 sort 0}
+do_test where7-2.544.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR f='fghijklmn'
+ OR a=70
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ }
+} {4 5 31 57 70 83 100 scan 0 sort 0}
+do_test where7-2.545.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=42
+ OR b=333
+ OR (d>=35.0 AND d<36.0 AND d NOT NULL)
+ OR b=1089
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR a=22
+ OR b=594
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ }
+} {5 12 15 22 31 35 42 54 57 83 99 scan 0 sort 0}
+do_test where7-2.545.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=42
+ OR b=333
+ OR (d>=35.0 AND d<36.0 AND d NOT NULL)
+ OR b=1089
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR a=22
+ OR b=594
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ }
+} {5 12 15 22 31 35 42 54 57 83 99 scan 0 sort 0}
+do_test where7-2.546.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=113
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR f='mnopqrstu'
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR b=902
+ }
+} {3 5 12 16 17 25 26 38 52 64 67 69 78 82 90 scan 0 sort 0}
+do_test where7-2.546.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=113
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR f='mnopqrstu'
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR b=902
+ }
+} {3 5 12 16 17 25 26 38 52 64 67 69 78 82 90 scan 0 sort 0}
+do_test where7-2.547.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='onmlkji' AND f GLOB 'zabcd*')
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR a=13
+ }
+} {13 15 41 51 67 93 scan 0 sort 0}
+do_test where7-2.547.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='onmlkji' AND f GLOB 'zabcd*')
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR a=13
+ }
+} {13 15 41 51 67 93 scan 0 sort 0}
+do_test where7-2.548.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='edcbazy' AND f GLOB 'wxyza*')
+ OR b=410
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR b=418
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ }
+} {38 65 82 88 100 scan 0 sort 0}
+do_test where7-2.548.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='edcbazy' AND f GLOB 'wxyza*')
+ OR b=410
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR b=418
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ }
+} {38 65 82 88 100 scan 0 sort 0}
+do_test where7-2.549.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=5
+ OR a=95
+ OR a=56
+ OR a=46
+ OR (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR (d>=41.0 AND d<42.0 AND d NOT NULL)
+ }
+} {5 10 41 46 56 61 95 100 scan 0 sort 0}
+do_test where7-2.549.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=5
+ OR a=95
+ OR a=56
+ OR a=46
+ OR (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR (d>=41.0 AND d<42.0 AND d NOT NULL)
+ }
+} {5 10 41 46 56 61 95 100 scan 0 sort 0}
+do_test where7-2.550.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR a=13
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR a=9
+ OR a=27
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR b=484
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR b=594
+ }
+} {9 13 27 37 44 54 75 87 88 90 scan 0 sort 0}
+do_test where7-2.550.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR a=13
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR a=9
+ OR a=27
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR b=484
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR b=594
+ }
+} {9 13 27 37 44 54 75 87 88 90 scan 0 sort 0}
+do_test where7-2.551.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=539
+ OR b=418
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR b=759
+ }
+} {15 38 49 69 scan 0 sort 0}
+do_test where7-2.551.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=539
+ OR b=418
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR b=759
+ }
+} {15 38 49 69 scan 0 sort 0}
+do_test where7-2.552.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1001
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR c=34034
+ OR a=84
+ }
+} {8 54 84 91 100 scan 0 sort 0}
+do_test where7-2.552.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1001
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR c=34034
+ OR a=84
+ }
+} {8 54 84 91 100 scan 0 sort 0}
+do_test where7-2.553.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=795
+ OR b=671
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR b=322
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR c=34034
+ OR b=410
+ }
+} {15 38 41 60 61 63 67 71 73 93 100 scan 0 sort 0}
+do_test where7-2.553.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=795
+ OR b=671
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR b=322
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR c=34034
+ OR b=410
+ }
+} {15 38 41 60 61 63 67 71 73 93 100 scan 0 sort 0}
+do_test where7-2.554.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=13013
+ OR (g='fedcbaz' AND f GLOB 'qrstu*')
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=47
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=828
+ }
+} {37 38 39 42 61 69 79 94 scan 0 sort 0}
+do_test where7-2.554.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=13013
+ OR (g='fedcbaz' AND f GLOB 'qrstu*')
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=47
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=828
+ }
+} {37 38 39 42 61 69 79 94 scan 0 sort 0}
+do_test where7-2.555.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=451
+ OR b=836
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ }
+} {41 48 76 scan 0 sort 0}
+do_test where7-2.555.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=451
+ OR b=836
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ }
+} {41 48 76 scan 0 sort 0}
+do_test where7-2.556.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=575
+ OR b=748
+ OR b=520
+ OR b=154
+ OR a=70
+ OR f='efghijklm'
+ }
+} {4 14 30 56 68 70 82 scan 0 sort 0}
+do_test where7-2.556.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=575
+ OR b=748
+ OR b=520
+ OR b=154
+ OR a=70
+ OR f='efghijklm'
+ }
+} {4 14 30 56 68 70 82 scan 0 sort 0}
+do_test where7-2.557.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='tuvwxyzab'
+ OR (g='nmlkjih' AND f GLOB 'efghi*')
+ }
+} {19 45 56 71 97 scan 0 sort 0}
+do_test where7-2.557.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='tuvwxyzab'
+ OR (g='nmlkjih' AND f GLOB 'efghi*')
+ }
+} {19 45 56 71 97 scan 0 sort 0}
+do_test where7-2.558.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=806
+ OR a=47
+ OR d<0.0
+ OR b=982
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR e IS NULL
+ OR c=32032
+ OR b=795
+ }
+} {2 12 47 87 94 95 96 97 99 scan 0 sort 0}
+do_test where7-2.558.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=806
+ OR a=47
+ OR d<0.0
+ OR b=982
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR e IS NULL
+ OR c=32032
+ OR b=795
+ }
+} {2 12 47 87 94 95 96 97 99 scan 0 sort 0}
+do_test where7-2.559.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=62
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ }
+} {23 49 62 75 89 91 99 scan 0 sort 0}
+do_test where7-2.559.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=62
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ }
+} {23 49 62 75 89 91 99 scan 0 sort 0}
+do_test where7-2.560.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR b=1056
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR b=729
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR b=220
+ OR b=498
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ }
+} {9 20 57 73 96 98 scan 0 sort 0}
+do_test where7-2.560.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR b=1056
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR b=729
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR b=220
+ OR b=498
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ }
+} {9 20 57 73 96 98 scan 0 sort 0}
+do_test where7-2.561.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=44
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ }
+} {4 10 38 scan 0 sort 0}
+do_test where7-2.561.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=44
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ }
+} {4 10 38 scan 0 sort 0}
+do_test where7-2.562.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=883
+ OR b=311
+ OR b=880
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR a=88
+ OR b=154
+ OR a=94
+ OR a=37
+ OR c=31031
+ }
+} {14 37 41 57 59 80 88 91 92 93 94 scan 0 sort 0}
+do_test where7-2.562.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=883
+ OR b=311
+ OR b=880
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR a=88
+ OR b=154
+ OR a=94
+ OR a=37
+ OR c=31031
+ }
+} {14 37 41 57 59 80 88 91 92 93 94 scan 0 sort 0}
+do_test where7-2.563.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='onmlkji' AND f GLOB 'xyzab*')
+ OR a=10
+ OR b=190
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR b=385
+ OR a=82
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR c=22022
+ }
+} {8 10 35 49 55 63 64 65 66 67 69 82 90 scan 0 sort 0}
+do_test where7-2.563.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='onmlkji' AND f GLOB 'xyzab*')
+ OR a=10
+ OR b=190
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR b=385
+ OR a=82
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR c=22022
+ }
+} {8 10 35 49 55 63 64 65 66 67 69 82 90 scan 0 sort 0}
+do_test where7-2.564.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1070
+ OR a=33
+ OR b=363
+ OR a=47
+ }
+} {33 47 scan 0 sort 0}
+do_test where7-2.564.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1070
+ OR a=33
+ OR b=363
+ OR a=47
+ }
+} {33 47 scan 0 sort 0}
+do_test where7-2.565.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=1001
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=49
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR c=33033
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR g IS NULL
+ OR b=220
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ }
+} {1 2 3 18 20 33 35 49 60 62 63 65 70 81 97 98 99 scan 0 sort 0}
+do_test where7-2.565.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=1001
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=49
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR c=33033
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR g IS NULL
+ OR b=220
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ }
+} {1 2 3 18 20 33 35 49 60 62 63 65 70 81 97 98 99 scan 0 sort 0}
+do_test where7-2.566.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR b=212
+ OR b=418
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ }
+} {31 33 38 71 scan 0 sort 0}
+do_test where7-2.566.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR b=212
+ OR b=418
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ }
+} {31 33 38 71 scan 0 sort 0}
+do_test where7-2.567.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=344
+ OR f='nopqrstuv'
+ OR b=704
+ OR a=84
+ }
+} {13 39 64 65 84 91 scan 0 sort 0}
+do_test where7-2.567.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=344
+ OR f='nopqrstuv'
+ OR b=704
+ OR a=84
+ }
+} {13 39 64 65 84 91 scan 0 sort 0}
+do_test where7-2.568.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 30 AND 32) AND a!=31)
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ }
+} {5 30 32 scan 0 sort 0}
+do_test where7-2.568.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 30 AND 32) AND a!=31)
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ }
+} {5 30 32 scan 0 sort 0}
+do_test where7-2.569.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ }
+} {26 52 78 87 scan 0 sort 0}
+do_test where7-2.569.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ }
+} {26 52 78 87 scan 0 sort 0}
+do_test where7-2.570.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 0 AND 2) AND a!=1)
+ OR b=1100
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR b=421
+ OR b=465
+ OR b=894
+ OR c=13013
+ OR b=47
+ OR b=674
+ OR ((a BETWEEN 0 AND 2) AND a!=1)
+ }
+} {2 37 38 39 70 100 scan 0 sort 0}
+do_test where7-2.570.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 0 AND 2) AND a!=1)
+ OR b=1100
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR b=421
+ OR b=465
+ OR b=894
+ OR c=13013
+ OR b=47
+ OR b=674
+ OR ((a BETWEEN 0 AND 2) AND a!=1)
+ }
+} {2 37 38 39 70 100 scan 0 sort 0}
+do_test where7-2.571.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=18018
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR b=410
+ OR b=858
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ }
+} {49 52 53 54 78 scan 0 sort 0}
+do_test where7-2.571.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=18018
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR b=410
+ OR b=858
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ }
+} {49 52 53 54 78 scan 0 sort 0}
+do_test where7-2.572.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR b=781
+ }
+} {47 71 scan 0 sort 0}
+do_test where7-2.572.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR b=781
+ }
+} {47 71 scan 0 sort 0}
+do_test where7-2.573.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1070
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR a=54
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR a=9
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ }
+} {7 9 25 33 47 50 52 54 59 63 85 scan 0 sort 0}
+do_test where7-2.573.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1070
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR a=54
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR a=9
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ }
+} {7 9 25 33 47 50 52 54 59 63 85 scan 0 sort 0}
+do_test where7-2.574.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=55
+ OR a=62
+ OR a=63
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ }
+} {34 50 55 62 63 99 scan 0 sort 0}
+do_test where7-2.574.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=55
+ OR a=62
+ OR a=63
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ }
+} {34 50 55 62 63 99 scan 0 sort 0}
+do_test where7-2.575.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=421
+ OR b=146
+ OR b=22
+ OR f='efghijklm'
+ }
+} {2 4 30 56 82 scan 0 sort 0}
+do_test where7-2.575.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=421
+ OR b=146
+ OR b=22
+ OR f='efghijklm'
+ }
+} {2 4 30 56 82 scan 0 sort 0}
+do_test where7-2.576.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=553
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR (d>=59.0 AND d<60.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=583
+ OR a=56
+ }
+} {21 23 48 53 56 59 61 scan 0 sort 0}
+do_test where7-2.576.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=553
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR (d>=59.0 AND d<60.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=583
+ OR a=56
+ }
+} {21 23 48 53 56 59 61 scan 0 sort 0}
+do_test where7-2.577.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=83
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR a=1
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR b=245
+ }
+} {1 17 19 29 49 51 77 83 scan 0 sort 0}
+do_test where7-2.577.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=83
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR a=1
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR b=245
+ }
+} {1 17 19 29 49 51 77 83 scan 0 sort 0}
+do_test where7-2.578.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=3003
+ OR b=619
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ }
+} {7 8 9 19 21 scan 0 sort 0}
+do_test where7-2.578.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=3003
+ OR b=619
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ }
+} {7 8 9 19 21 scan 0 sort 0}
+do_test where7-2.579.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=924
+ OR a=92
+ OR a=63
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ }
+} {60 63 84 92 97 scan 0 sort 0}
+do_test where7-2.579.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=924
+ OR a=92
+ OR a=63
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ }
+} {60 63 84 92 97 scan 0 sort 0}
+do_test where7-2.580.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=440
+ OR f='vwxyzabcd'
+ OR b=190
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR b=88
+ OR b=58
+ }
+} {8 11 21 37 40 42 47 63 73 89 99 scan 0 sort 0}
+do_test where7-2.580.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=440
+ OR f='vwxyzabcd'
+ OR b=190
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR b=88
+ OR b=58
+ }
+} {8 11 21 37 40 42 47 63 73 89 99 scan 0 sort 0}
+do_test where7-2.581.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=495
+ OR c=24024
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR b=1001
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR d>1e10
+ OR b=531
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR b=1089
+ }
+} {25 45 49 70 71 72 82 91 99 scan 0 sort 0}
+do_test where7-2.581.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=495
+ OR c=24024
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR b=1001
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR d>1e10
+ OR b=531
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR b=1089
+ }
+} {25 45 49 70 71 72 82 91 99 scan 0 sort 0}
+do_test where7-2.582.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR (d>=41.0 AND d<42.0 AND d NOT NULL)
+ }
+} {41 48 scan 0 sort 0}
+do_test where7-2.582.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR (d>=41.0 AND d<42.0 AND d NOT NULL)
+ }
+} {41 48 scan 0 sort 0}
+do_test where7-2.583.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR d>1e10
+ OR b=22
+ OR c=5005
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ }
+} {1 2 13 14 15 22 24 52 71 73 80 82 91 93 scan 0 sort 0}
+do_test where7-2.583.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR d>1e10
+ OR b=22
+ OR c=5005
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ }
+} {1 2 13 14 15 22 24 52 71 73 80 82 91 93 scan 0 sort 0}
+do_test where7-2.584.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 9 AND 11) AND a!=10)
+ OR b=1078
+ OR b=806
+ OR b=605
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ }
+} {9 11 15 23 25 41 55 67 76 93 98 scan 0 sort 0}
+do_test where7-2.584.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 9 AND 11) AND a!=10)
+ OR b=1078
+ OR b=806
+ OR b=605
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ }
+} {9 11 15 23 25 41 55 67 76 93 98 scan 0 sort 0}
+do_test where7-2.585.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 84 AND 86) AND a!=85)
+ OR b=572
+ OR c=10010
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR a=29
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ }
+} {7 28 29 30 33 52 59 68 84 85 86 scan 0 sort 0}
+do_test where7-2.585.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 84 AND 86) AND a!=85)
+ OR b=572
+ OR c=10010
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR a=29
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ }
+} {7 28 29 30 33 52 59 68 84 85 86 scan 0 sort 0}
+do_test where7-2.586.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 94 AND 96) AND a!=95)
+ OR b=858
+ OR b=806
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ }
+} {63 77 78 94 96 scan 0 sort 0}
+do_test where7-2.586.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 94 AND 96) AND a!=95)
+ OR b=858
+ OR b=806
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ }
+} {63 77 78 94 96 scan 0 sort 0}
+do_test where7-2.587.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='vwxyzabcd'
+ OR a=72
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR b=935
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR c=13013
+ }
+} {21 36 37 38 39 40 47 72 73 85 99 scan 0 sort 0}
+do_test where7-2.587.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='vwxyzabcd'
+ OR a=72
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR b=935
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR c=13013
+ }
+} {21 36 37 38 39 40 47 72 73 85 99 scan 0 sort 0}
+do_test where7-2.588.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=5005
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR b=143
+ OR a=68
+ OR a=77
+ OR b=80
+ }
+} {13 14 15 43 44 68 77 88 scan 0 sort 0}
+do_test where7-2.588.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=5005
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR b=143
+ OR a=68
+ OR a=77
+ OR b=80
+ }
+} {13 14 15 43 44 68 77 88 scan 0 sort 0}
+do_test where7-2.589.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR a=99
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ }
+} {5 6 12 14 68 72 76 78 99 scan 0 sort 0}
+do_test where7-2.589.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR a=99
+ OR ((a BETWEEN 12 AND 14) AND a!=13)
+ }
+} {5 6 12 14 68 72 76 78 99 scan 0 sort 0}
+do_test where7-2.590.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='qponmlk' AND f GLOB 'opqrs*')
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR b=971
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ }
+} {5 13 40 88 90 scan 0 sort 0}
+do_test where7-2.590.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='qponmlk' AND f GLOB 'opqrs*')
+ OR ((a BETWEEN 88 AND 90) AND a!=89)
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR b=971
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ }
+} {5 13 40 88 90 scan 0 sort 0}
+do_test where7-2.591.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?lmno*' AND f GLOB 'klmn*')
+ OR b=806
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR b=1015
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ }
+} {10 13 36 39 43 62 65 68 70 88 91 scan 0 sort 0}
+do_test where7-2.591.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?lmno*' AND f GLOB 'klmn*')
+ OR b=806
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR b=1015
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ }
+} {10 13 36 39 43 62 65 68 70 88 91 scan 0 sort 0}
+do_test where7-2.592.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='nopqrstuv'
+ OR b=993
+ OR a=76
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR c=20020
+ OR a=26
+ OR b=1048
+ OR b=561
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR a=56
+ }
+} {13 26 36 39 51 55 56 57 58 59 60 65 76 79 91 scan 0 sort 0}
+do_test where7-2.592.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='nopqrstuv'
+ OR b=993
+ OR a=76
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR c=20020
+ OR a=26
+ OR b=1048
+ OR b=561
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ OR a=56
+ }
+} {13 26 36 39 51 55 56 57 58 59 60 65 76 79 91 scan 0 sort 0}
+do_test where7-2.593.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=781
+ OR b=671
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR b=113
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=385
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ }
+} {15 16 35 39 41 60 61 71 83 scan 0 sort 0}
+do_test where7-2.593.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=781
+ OR b=671
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR b=113
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=385
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ }
+} {15 16 35 39 41 60 61 71 83 scan 0 sort 0}
+do_test where7-2.594.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=410
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR b=674
+ OR b=825
+ OR b=704
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR a=76
+ OR c=32032
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ }
+} {9 43 45 58 60 61 64 75 76 85 87 94 95 96 scan 0 sort 0}
+do_test where7-2.594.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=410
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR b=674
+ OR b=825
+ OR b=704
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR a=76
+ OR c=32032
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ }
+} {9 43 45 58 60 61 64 75 76 85 87 94 95 96 scan 0 sort 0}
+do_test where7-2.595.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=869
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ }
+} {43 79 scan 0 sort 0}
+do_test where7-2.595.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=869
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ }
+} {43 79 scan 0 sort 0}
+do_test where7-2.596.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=869
+ OR a=34
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ }
+} {34 79 87 scan 0 sort 0}
+do_test where7-2.596.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=869
+ OR a=34
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ }
+} {34 79 87 scan 0 sort 0}
+do_test where7-2.597.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='rqponml' AND f GLOB 'hijkl*')
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR a=8
+ OR a=72
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ }
+} {8 33 44 72 90 95 97 scan 0 sort 0}
+do_test where7-2.597.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='rqponml' AND f GLOB 'hijkl*')
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR a=8
+ OR a=72
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ }
+} {8 33 44 72 90 95 97 scan 0 sort 0}
+do_test where7-2.598.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=20
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR b=341
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR b=814
+ OR b=1026
+ OR a=14
+ OR a=13
+ OR b=1037
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {13 14 20 26 31 56 58 74 76 scan 0 sort 0}
+do_test where7-2.598.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=20
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR b=341
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR b=814
+ OR b=1026
+ OR a=14
+ OR a=13
+ OR b=1037
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {13 14 20 26 31 56 58 74 76 scan 0 sort 0}
+do_test where7-2.599.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=443
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR b=839
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ OR c=7007
+ }
+} {10 13 19 20 21 49 51 scan 0 sort 0}
+do_test where7-2.599.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=443
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR b=839
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ OR c=7007
+ }
+} {10 13 19 20 21 49 51 scan 0 sort 0}
+do_test where7-2.600.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR a=21
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR f='zabcdefgh'
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR b=506
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR b=88
+ OR b=190
+ }
+} {3 8 9 14 16 21 25 42 46 51 68 77 94 97 scan 0 sort 0}
+do_test where7-2.600.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR a=21
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR f='zabcdefgh'
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR b=506
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR b=88
+ OR b=190
+ }
+} {3 8 9 14 16 21 25 42 46 51 68 77 94 97 scan 0 sort 0}
+do_test where7-2.601.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=41.0 AND d<42.0 AND d NOT NULL)
+ OR f='bcdefghij'
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=762
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ }
+} {1 27 30 41 53 54 61 63 68 70 76 79 scan 0 sort 0}
+do_test where7-2.601.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=41.0 AND d<42.0 AND d NOT NULL)
+ OR f='bcdefghij'
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=762
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ }
+} {1 27 30 41 53 54 61 63 68 70 76 79 scan 0 sort 0}
+do_test where7-2.602.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR f='qrstuvwxy'
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ }
+} {16 42 56 68 85 94 scan 0 sort 0}
+do_test where7-2.602.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR f='qrstuvwxy'
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ }
+} {16 42 56 68 85 94 scan 0 sort 0}
+do_test where7-2.603.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR a=21
+ OR b<0
+ OR f='bcdefghij'
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {1 14 16 21 27 53 57 79 89 scan 0 sort 0}
+do_test where7-2.603.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR a=21
+ OR b<0
+ OR f='bcdefghij'
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {1 14 16 21 27 53 57 79 89 scan 0 sort 0}
+do_test where7-2.604.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR b=1067
+ OR b=231
+ OR b=113
+ OR b=22
+ OR a=55
+ OR b=663
+ }
+} {2 21 40 55 83 97 scan 0 sort 0}
+do_test where7-2.604.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR b=1067
+ OR b=231
+ OR b=113
+ OR b=22
+ OR a=55
+ OR b=663
+ }
+} {2 21 40 55 83 97 scan 0 sort 0}
+do_test where7-2.605.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=1
+ OR b=454
+ OR b=396
+ OR b=1059
+ OR a=69
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR b=440
+ OR b=825
+ }
+} {1 21 36 40 47 69 73 75 99 scan 0 sort 0}
+do_test where7-2.605.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=1
+ OR b=454
+ OR b=396
+ OR b=1059
+ OR a=69
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR b=440
+ OR b=825
+ }
+} {1 21 36 40 47 69 73 75 99 scan 0 sort 0}
+do_test where7-2.606.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR b=308
+ OR c<=10
+ OR (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR f='ghijklmno'
+ OR b=289
+ OR a=5
+ OR b=267
+ OR b=949
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ }
+} {5 6 7 9 26 28 32 58 84 scan 0 sort 0}
+do_test where7-2.606.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR b=308
+ OR c<=10
+ OR (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR f='ghijklmno'
+ OR b=289
+ OR a=5
+ OR b=267
+ OR b=949
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ }
+} {5 6 7 9 26 28 32 58 84 scan 0 sort 0}
+do_test where7-2.607.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 95 AND 97) AND a!=96)
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR b=993
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR b=663
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR b=869
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR b=121
+ }
+} {11 17 24 43 45 50 76 79 81 95 97 scan 0 sort 0}
+do_test where7-2.607.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 95 AND 97) AND a!=96)
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR b=993
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR b=663
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR b=869
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR b=121
+ }
+} {11 17 24 43 45 50 76 79 81 95 97 scan 0 sort 0}
+do_test where7-2.608.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'efghi*')
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR b=770
+ }
+} {4 27 70 87 scan 0 sort 0}
+do_test where7-2.608.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'efghi*')
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR b=770
+ }
+} {4 27 70 87 scan 0 sort 0}
+do_test where7-2.609.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 80 AND 82) AND a!=81)
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ }
+} {19 45 57 71 80 82 90 97 scan 0 sort 0}
+do_test where7-2.609.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 80 AND 82) AND a!=81)
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ }
+} {19 45 57 71 80 82 90 97 scan 0 sort 0}
+do_test where7-2.610.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=22
+ OR c=31031
+ OR b=894
+ OR a=31
+ OR ((a BETWEEN 84 AND 86) AND a!=85)
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR a=94
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR a=21
+ OR b=1001
+ }
+} {2 21 31 84 86 91 92 93 94 95 scan 0 sort 0}
+do_test where7-2.610.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=22
+ OR c=31031
+ OR b=894
+ OR a=31
+ OR ((a BETWEEN 84 AND 86) AND a!=85)
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR a=94
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR a=21
+ OR b=1001
+ }
+} {2 21 31 84 86 91 92 93 94 95 scan 0 sort 0}
+do_test where7-2.611.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='onmlkji' AND f GLOB 'zabcd*')
+ OR b=1092
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR a=77
+ OR a=63
+ OR b=762
+ OR b=894
+ OR b=685
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ }
+} {13 46 51 63 77 80 scan 0 sort 0}
+do_test where7-2.611.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='onmlkji' AND f GLOB 'zabcd*')
+ OR b=1092
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR a=77
+ OR a=63
+ OR b=762
+ OR b=894
+ OR b=685
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ }
+} {13 46 51 63 77 80 scan 0 sort 0}
+do_test where7-2.612.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='wvutsrq' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR b=231
+ }
+} {10 21 93 95 scan 0 sort 0}
+do_test where7-2.612.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='wvutsrq' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR b=231
+ }
+} {10 21 93 95 scan 0 sort 0}
+do_test where7-2.613.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=828
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ }
+} {8 10 26 52 78 scan 0 sort 0}
+do_test where7-2.613.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=828
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ }
+} {8 10 26 52 78 scan 0 sort 0}
+do_test where7-2.614.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR b=520
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR a=21
+ }
+} {4 6 13 21 31 33 39 47 50 65 91 100 scan 0 sort 0}
+do_test where7-2.614.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR b=520
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR a=21
+ }
+} {4 6 13 21 31 33 39 47 50 65 91 100 scan 0 sort 0}
+do_test where7-2.615.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=553
+ OR (g='lkjihgf' AND f GLOB 'lmnop*')
+ OR b=1034
+ OR b=418
+ OR a=57
+ OR f='mnopqrstu'
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ }
+} {12 38 57 63 64 90 94 99 scan 0 sort 0}
+do_test where7-2.615.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=553
+ OR (g='lkjihgf' AND f GLOB 'lmnop*')
+ OR b=1034
+ OR b=418
+ OR a=57
+ OR f='mnopqrstu'
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ }
+} {12 38 57 63 64 90 94 99 scan 0 sort 0}
+do_test where7-2.616.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=43
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR b=418
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR b=594
+ OR a=21
+ OR a=78
+ OR a=91
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ }
+} {21 38 43 47 54 70 78 80 91 scan 0 sort 0}
+do_test where7-2.616.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=43
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR b=418
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR b=594
+ OR a=21
+ OR a=78
+ OR a=91
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ }
+} {21 38 43 47 54 70 78 80 91 scan 0 sort 0}
+do_test where7-2.617.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=671
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ }
+} {48 61 95 97 scan 0 sort 0}
+do_test where7-2.617.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=671
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ }
+} {48 61 95 97 scan 0 sort 0}
+do_test where7-2.618.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR b=726
+ OR b=663
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR a=25
+ OR f='qrstuvwxy'
+ }
+} {2 13 16 25 42 66 68 94 scan 0 sort 0}
+do_test where7-2.618.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=2.0 AND d<3.0 AND d NOT NULL)
+ OR b=726
+ OR b=663
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR a=25
+ OR f='qrstuvwxy'
+ }
+} {2 13 16 25 42 66 68 94 scan 0 sort 0}
+do_test where7-2.619.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=806
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR b=275
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ }
+} {10 12 25 50 80 82 scan 0 sort 0}
+do_test where7-2.619.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=806
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR b=275
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ }
+} {10 12 25 50 80 82 scan 0 sort 0}
+do_test where7-2.620.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=24024
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR b=429
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR b=110
+ OR a=39
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ }
+} {2 10 23 39 70 71 72 scan 0 sort 0}
+do_test where7-2.620.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=24024
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR b=429
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR b=110
+ OR a=39
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ }
+} {2 10 23 39 70 71 72 scan 0 sort 0}
+do_test where7-2.621.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=66
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR b=198
+ OR b=682
+ OR c=23023
+ }
+} {18 62 66 67 68 69 70 scan 0 sort 0}
+do_test where7-2.621.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=66
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR b=198
+ OR b=682
+ OR c=23023
+ }
+} {18 62 66 67 68 69 70 scan 0 sort 0}
+do_test where7-2.622.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=806
+ OR b=253
+ OR a=36
+ }
+} {23 36 scan 0 sort 0}
+do_test where7-2.622.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=806
+ OR b=253
+ OR a=36
+ }
+} {23 36 scan 0 sort 0}
+do_test where7-2.623.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=509
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ OR b=718
+ OR a=4
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ }
+} {4 13 16 22 24 56 58 69 scan 0 sort 0}
+do_test where7-2.623.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=509
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR (g='vutsrqp' AND f GLOB 'nopqr*')
+ OR b=718
+ OR a=4
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ }
+} {4 13 16 22 24 56 58 69 scan 0 sort 0}
+do_test where7-2.624.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='jihgfed' AND f GLOB 'zabcd*')
+ OR b=1026
+ OR a=93
+ OR c=18018
+ }
+} {52 53 54 77 93 scan 0 sort 0}
+do_test where7-2.624.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='jihgfed' AND f GLOB 'zabcd*')
+ OR b=1026
+ OR a=93
+ OR c=18018
+ }
+} {52 53 54 77 93 scan 0 sort 0}
+do_test where7-2.625.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=388
+ OR a=44
+ }
+} {44 scan 0 sort 0}
+do_test where7-2.625.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=388
+ OR a=44
+ }
+} {44 scan 0 sort 0}
+do_test where7-2.626.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=9009
+ OR b=542
+ OR f='cdefghijk'
+ OR b=319
+ OR b=616
+ }
+} {2 25 26 27 28 29 54 56 80 scan 0 sort 0}
+do_test where7-2.626.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=9009
+ OR b=542
+ OR f='cdefghijk'
+ OR b=319
+ OR b=616
+ }
+} {2 25 26 27 28 29 54 56 80 scan 0 sort 0}
+do_test where7-2.627.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=990
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR b=531
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR f='qrstuvwxy'
+ }
+} {6 16 32 41 42 43 57 58 67 68 84 86 90 94 97 scan 0 sort 0}
+do_test where7-2.627.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=990
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR b=531
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR f='qrstuvwxy'
+ }
+} {6 16 32 41 42 43 57 58 67 68 84 86 90 94 97 scan 0 sort 0}
+do_test where7-2.628.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=60
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR b=627
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR b=883
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR f='yzabcdefg'
+ OR (d>=59.0 AND d<60.0 AND d NOT NULL)
+ }
+} {24 38 50 57 59 60 73 76 78 93 99 scan 0 sort 0}
+do_test where7-2.628.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=60
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR b=627
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR b=883
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR f='yzabcdefg'
+ OR (d>=59.0 AND d<60.0 AND d NOT NULL)
+ }
+} {24 38 50 57 59 60 73 76 78 93 99 scan 0 sort 0}
+do_test where7-2.629.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=696
+ OR b=938
+ OR a=18
+ OR b=957
+ OR c=18018
+ OR c=3003
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ }
+} {7 8 9 18 33 35 52 53 54 87 scan 0 sort 0}
+do_test where7-2.629.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=696
+ OR b=938
+ OR a=18
+ OR b=957
+ OR c=18018
+ OR c=3003
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ }
+} {7 8 9 18 33 35 52 53 54 87 scan 0 sort 0}
+do_test where7-2.630.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=29029
+ OR a=73
+ }
+} {73 85 86 87 scan 0 sort 0}
+do_test where7-2.630.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=29029
+ OR a=73
+ }
+} {73 85 86 87 scan 0 sort 0}
+do_test where7-2.631.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=28
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR b=69
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR b=781
+ OR a=64
+ OR b=91
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR a=16
+ OR b=278
+ OR a=26
+ }
+} {16 26 27 28 64 71 82 85 87 scan 0 sort 0}
+do_test where7-2.631.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=28
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR b=69
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR b=781
+ OR a=64
+ OR b=91
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR a=16
+ OR b=278
+ OR a=26
+ }
+} {16 26 27 28 64 71 82 85 87 scan 0 sort 0}
+do_test where7-2.632.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=70
+ OR c=3003
+ }
+} {7 8 9 70 scan 0 sort 0}
+do_test where7-2.632.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=70
+ OR c=3003
+ }
+} {7 8 9 70 scan 0 sort 0}
+do_test where7-2.633.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=31031
+ OR a=76
+ OR b=1023
+ OR b=33
+ }
+} {3 76 91 92 93 scan 0 sort 0}
+do_test where7-2.633.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=31031
+ OR a=76
+ OR b=1023
+ OR b=33
+ }
+} {3 76 91 92 93 scan 0 sort 0}
+do_test where7-2.634.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR b=1001
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ }
+} {62 86 91 scan 0 sort 0}
+do_test where7-2.634.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR b=1001
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ }
+} {62 86 91 scan 0 sort 0}
+do_test where7-2.635.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='yzabcdefg'
+ OR ((a BETWEEN 48 AND 50) AND a!=49)
+ OR a=100
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ OR a=62
+ OR a=67
+ OR b=605
+ OR c=23023
+ OR a=26
+ OR b=982
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ }
+} {3 5 24 26 34 48 50 55 62 67 68 69 76 100 scan 0 sort 0}
+do_test where7-2.635.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='yzabcdefg'
+ OR ((a BETWEEN 48 AND 50) AND a!=49)
+ OR a=100
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ OR a=62
+ OR a=67
+ OR b=605
+ OR c=23023
+ OR a=26
+ OR b=982
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ }
+} {3 5 24 26 34 48 50 55 62 67 68 69 76 100 scan 0 sort 0}
+do_test where7-2.636.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=220
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR f IS NULL
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR b=784
+ }
+} {20 24 25 26 27 scan 0 sort 0}
+do_test where7-2.636.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=220
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR f IS NULL
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR b=784
+ }
+} {20 24 25 26 27 scan 0 sort 0}
+do_test where7-2.637.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR b=751
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR a=67
+ OR b=102
+ }
+} {10 17 43 67 69 88 95 scan 0 sort 0}
+do_test where7-2.637.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR b=751
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR a=67
+ OR b=102
+ }
+} {10 17 43 67 69 88 95 scan 0 sort 0}
+do_test where7-2.638.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR b=256
+ OR c=7007
+ OR c=26026
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR a=66
+ }
+} {19 20 21 66 69 74 76 77 78 80 82 scan 0 sort 0}
+do_test where7-2.638.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR b=256
+ OR c=7007
+ OR c=26026
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR a=66
+ }
+} {19 20 21 66 69 74 76 77 78 80 82 scan 0 sort 0}
+do_test where7-2.639.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=2002
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR b=33
+ OR b=817
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ }
+} {3 4 5 6 8 10 21 34 41 43 45 60 81 86 scan 0 sort 0}
+do_test where7-2.639.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=2002
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR b=33
+ OR b=817
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ }
+} {3 4 5 6 8 10 21 34 41 43 45 60 81 86 scan 0 sort 0}
+do_test where7-2.640.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='srqponm' AND f GLOB 'cdefg*')
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR a=80
+ OR a=53
+ OR a=62
+ OR a=49
+ OR a=53
+ OR a=56
+ OR (d>=83.0 AND d<84.0 AND d NOT NULL)
+ }
+} {28 49 53 56 62 80 81 83 scan 0 sort 0}
+do_test where7-2.640.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='srqponm' AND f GLOB 'cdefg*')
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR a=80
+ OR a=53
+ OR a=62
+ OR a=49
+ OR a=53
+ OR a=56
+ OR (d>=83.0 AND d<84.0 AND d NOT NULL)
+ }
+} {28 49 53 56 62 80 81 83 scan 0 sort 0}
+do_test where7-2.641.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 7 AND 9) AND a!=8)
+ OR b=652
+ OR a=72
+ OR b=209
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR a=38
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR d>1e10
+ }
+} {7 9 19 23 38 66 68 72 scan 0 sort 0}
+do_test where7-2.641.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 7 AND 9) AND a!=8)
+ OR b=652
+ OR a=72
+ OR b=209
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR a=38
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR d>1e10
+ }
+} {7 9 19 23 38 66 68 72 scan 0 sort 0}
+do_test where7-2.642.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=949
+ OR e IS NULL
+ }
+} { scan 0 sort 0}
+do_test where7-2.642.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=949
+ OR e IS NULL
+ }
+} { scan 0 sort 0}
+do_test where7-2.643.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=179
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR b=509
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR f='bcdefghij'
+ }
+} {1 26 27 29 49 53 58 60 79 scan 0 sort 0}
+do_test where7-2.643.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=179
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR b=509
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR f='bcdefghij'
+ }
+} {1 26 27 29 49 53 58 60 79 scan 0 sort 0}
+do_test where7-2.644.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=23
+ OR a=43
+ OR c=19019
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR c=18018
+ }
+} {23 43 47 52 53 54 55 56 57 scan 0 sort 0}
+do_test where7-2.644.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=23
+ OR a=43
+ OR c=19019
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR c=18018
+ }
+} {23 43 47 52 53 54 55 56 57 scan 0 sort 0}
+do_test where7-2.645.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=36
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR b=231
+ }
+} {21 22 36 scan 0 sort 0}
+do_test where7-2.645.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=36
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR b=231
+ }
+} {21 22 36 scan 0 sort 0}
+do_test where7-2.646.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=21
+ OR b=355
+ OR a=97
+ }
+} {21 97 scan 0 sort 0}
+do_test where7-2.646.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=21
+ OR b=355
+ OR a=97
+ }
+} {21 97 scan 0 sort 0}
+do_test where7-2.647.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR b=421
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR b=704
+ OR a=90
+ OR a=78
+ OR 1000000<b
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ }
+} {28 42 53 55 64 78 80 81 90 scan 0 sort 0}
+do_test where7-2.647.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR b=421
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR b=704
+ OR a=90
+ OR a=78
+ OR 1000000<b
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ }
+} {28 42 53 55 64 78 80 81 90 scan 0 sort 0}
+do_test where7-2.648.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='fedcbaz' AND f GLOB 'pqrst*')
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ }
+} {93 95 scan 0 sort 0}
+do_test where7-2.648.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='fedcbaz' AND f GLOB 'pqrst*')
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ }
+} {93 95 scan 0 sort 0}
+do_test where7-2.649.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE d<0.0
+ OR a=78
+ OR b=539
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR e IS NULL
+ OR a=48
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ }
+} {8 10 25 27 48 49 57 78 scan 0 sort 0}
+do_test where7-2.649.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE d<0.0
+ OR a=78
+ OR b=539
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR e IS NULL
+ OR a=48
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ }
+} {8 10 25 27 48 49 57 78 scan 0 sort 0}
+do_test where7-2.650.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 94 AND 96) AND a!=95)
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR b=22
+ }
+} {2 78 94 96 scan 0 sort 0}
+do_test where7-2.650.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 94 AND 96) AND a!=95)
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR b=22
+ }
+} {2 78 94 96 scan 0 sort 0}
+do_test where7-2.651.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=275
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR f='ijklmnopq'
+ }
+} {8 25 34 37 53 57 59 60 86 92 scan 0 sort 0}
+do_test where7-2.651.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=275
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR f='ijklmnopq'
+ }
+} {8 25 34 37 53 57 59 60 86 92 scan 0 sort 0}
+do_test where7-2.652.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=256
+ OR c=13013
+ OR b=44
+ OR f='jklmnopqr'
+ OR b=883
+ }
+} {4 9 35 37 38 39 61 87 scan 0 sort 0}
+do_test where7-2.652.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=256
+ OR c=13013
+ OR b=44
+ OR f='jklmnopqr'
+ OR b=883
+ }
+} {4 9 35 37 38 39 61 87 scan 0 sort 0}
+do_test where7-2.653.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='zabcdefgh'
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR a=54
+ OR b=770
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR a=81
+ OR b=190
+ OR a=2
+ }
+} {2 3 25 51 54 70 77 81 96 98 scan 0 sort 0}
+do_test where7-2.653.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='zabcdefgh'
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR a=54
+ OR b=770
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR a=81
+ OR b=190
+ OR a=2
+ }
+} {2 3 25 51 54 70 77 81 96 98 scan 0 sort 0}
+do_test where7-2.654.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR c=12012
+ OR a=16
+ OR a=15
+ OR ((a BETWEEN 70 AND 72) AND a!=71)
+ OR a=69
+ OR b=748
+ OR a=61
+ OR b=473
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ }
+} {12 15 16 34 35 36 43 61 68 69 70 71 72 scan 0 sort 0}
+do_test where7-2.654.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR c=12012
+ OR a=16
+ OR a=15
+ OR ((a BETWEEN 70 AND 72) AND a!=71)
+ OR a=69
+ OR b=748
+ OR a=61
+ OR b=473
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ }
+} {12 15 16 34 35 36 43 61 68 69 70 71 72 scan 0 sort 0}
+do_test where7-2.655.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=223
+ OR a=14
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR b=539
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR a=21
+ }
+} {14 21 33 35 41 48 49 61 74 76 scan 0 sort 0}
+do_test where7-2.655.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=223
+ OR a=14
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR b=539
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR a=21
+ }
+} {14 21 33 35 41 48 49 61 74 76 scan 0 sort 0}
+do_test where7-2.656.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=99
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ OR a=73
+ OR a=56
+ OR b=253
+ OR b=880
+ }
+} {5 23 31 56 57 73 80 83 99 scan 0 sort 0}
+do_test where7-2.656.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=99
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ OR a=73
+ OR a=56
+ OR b=253
+ OR b=880
+ }
+} {5 23 31 56 57 73 80 83 99 scan 0 sort 0}
+do_test where7-2.657.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=927
+ OR b=300
+ OR b=223
+ OR (g='wvutsrq' AND f GLOB 'jklmn*')
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=154
+ OR b=759
+ }
+} {9 14 69 95 scan 0 sort 0}
+do_test where7-2.657.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=927
+ OR b=300
+ OR b=223
+ OR (g='wvutsrq' AND f GLOB 'jklmn*')
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=154
+ OR b=759
+ }
+} {9 14 69 95 scan 0 sort 0}
+do_test where7-2.658.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=242
+ OR b=905
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR a=24
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR b=1100
+ OR b=850
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ }
+} {22 24 55 57 66 67 69 86 96 100 scan 0 sort 0}
+do_test where7-2.658.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=242
+ OR b=905
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'ijklm*')
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR a=24
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ OR b=1100
+ OR b=850
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ }
+} {22 24 55 57 66 67 69 86 96 100 scan 0 sort 0}
+do_test where7-2.659.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=190
+ OR a=72
+ OR b=377
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR b=476
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ }
+} {2 26 52 72 78 93 scan 0 sort 0}
+do_test where7-2.659.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=190
+ OR a=72
+ OR b=377
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR b=476
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ }
+} {2 26 52 72 78 93 scan 0 sort 0}
+do_test where7-2.660.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=245
+ OR b=638
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR f='opqrstuvw'
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR b=817
+ OR a=85
+ OR (g='lkjihgf' AND f GLOB 'mnopq*')
+ }
+} {14 40 58 62 64 66 67 85 86 92 scan 0 sort 0}
+do_test where7-2.660.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=245
+ OR b=638
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR f='opqrstuvw'
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR b=817
+ OR a=85
+ OR (g='lkjihgf' AND f GLOB 'mnopq*')
+ }
+} {14 40 58 62 64 66 67 85 86 92 scan 0 sort 0}
+do_test where7-2.661.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 22 AND 24) AND a!=23)
+ OR b=968
+ }
+} {22 24 88 scan 0 sort 0}
+do_test where7-2.661.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 22 AND 24) AND a!=23)
+ OR b=968
+ }
+} {22 24 88 scan 0 sort 0}
+do_test where7-2.662.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 60 AND 62) AND a!=61)
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR b=22
+ OR b=993
+ OR f='tuvwxyzab'
+ }
+} {2 19 45 60 62 71 74 76 97 scan 0 sort 0}
+do_test where7-2.662.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 60 AND 62) AND a!=61)
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR b=22
+ OR b=993
+ OR f='tuvwxyzab'
+ }
+} {2 19 45 60 62 71 74 76 97 scan 0 sort 0}
+do_test where7-2.663.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 55 AND 57) AND a!=56)
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR c<=10
+ OR ((a BETWEEN 75 AND 77) AND a!=76)
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR b=553
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR b=1045
+ }
+} {55 57 72 73 75 77 85 95 scan 0 sort 0}
+do_test where7-2.663.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 55 AND 57) AND a!=56)
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR c<=10
+ OR ((a BETWEEN 75 AND 77) AND a!=76)
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR b=553
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR b=1045
+ }
+} {55 57 72 73 75 77 85 95 scan 0 sort 0}
+do_test where7-2.664.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=440
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ OR a=89
+ OR c=18018
+ OR b=154
+ OR b=506
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR a=78
+ OR b=751
+ }
+} {1 3 5 14 27 31 40 44 46 52 53 54 57 78 79 83 89 scan 0 sort 0}
+do_test where7-2.664.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=440
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR ((a BETWEEN 44 AND 46) AND a!=45)
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ OR a=89
+ OR c=18018
+ OR b=154
+ OR b=506
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR a=78
+ OR b=751
+ }
+} {1 3 5 14 27 31 40 44 46 52 53 54 57 78 79 83 89 scan 0 sort 0}
+do_test where7-2.665.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=407
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR b=209
+ OR b=814
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR a=44
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR b=1092
+ }
+} {10 19 36 37 38 44 65 74 99 scan 0 sort 0}
+do_test where7-2.665.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=407
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR b=209
+ OR b=814
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR a=44
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR b=1092
+ }
+} {10 19 36 37 38 44 65 74 99 scan 0 sort 0}
+do_test where7-2.666.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 24 AND 26) AND a!=25)
+ OR b=1103
+ OR b=190
+ OR b=737
+ OR a=97
+ OR b=451
+ OR b=583
+ OR a=63
+ OR c=8008
+ OR ((a BETWEEN 45 AND 47) AND a!=46)
+ }
+} {22 23 24 26 41 45 47 53 63 67 97 scan 0 sort 0}
+do_test where7-2.666.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 24 AND 26) AND a!=25)
+ OR b=1103
+ OR b=190
+ OR b=737
+ OR a=97
+ OR b=451
+ OR b=583
+ OR a=63
+ OR c=8008
+ OR ((a BETWEEN 45 AND 47) AND a!=46)
+ }
+} {22 23 24 26 41 45 47 53 63 67 97 scan 0 sort 0}
+do_test where7-2.667.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=12
+ OR b=935
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR b=1070
+ OR a=24
+ OR a=95
+ OR ((a BETWEEN 27 AND 29) AND a!=28)
+ OR a=40
+ OR b=935
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ }
+} {12 24 27 29 40 53 85 87 95 scan 0 sort 0}
+do_test where7-2.667.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=12
+ OR b=935
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR b=1070
+ OR a=24
+ OR a=95
+ OR ((a BETWEEN 27 AND 29) AND a!=28)
+ OR a=40
+ OR b=935
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ }
+} {12 24 27 29 40 53 85 87 95 scan 0 sort 0}
+do_test where7-2.668.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=858
+ OR a=82
+ OR b=209
+ OR b=374
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR c=22022
+ }
+} {19 34 40 64 65 66 76 78 82 scan 0 sort 0}
+do_test where7-2.668.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=858
+ OR a=82
+ OR b=209
+ OR b=374
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR c=22022
+ }
+} {19 34 40 64 65 66 76 78 82 scan 0 sort 0}
+do_test where7-2.669.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=27
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR b=121
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR a=67
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR c=1001
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ }
+} {1 2 3 7 8 9 11 19 21 27 30 32 37 50 52 67 scan 0 sort 0}
+do_test where7-2.669.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=27
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR b=121
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR a=67
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR c=1001
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ }
+} {1 2 3 7 8 9 11 19 21 27 30 32 37 50 52 67 scan 0 sort 0}
+do_test where7-2.670.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=99
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ }
+} {1 9 46 57 98 scan 0 sort 0}
+do_test where7-2.670.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=99
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR (d>=98.0 AND d<99.0 AND d NOT NULL)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ }
+} {1 9 46 57 98 scan 0 sort 0}
+do_test where7-2.671.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=3
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR b=355
+ OR b=814
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR a=81
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR b=542
+ OR b=795
+ }
+} {3 42 62 74 79 81 scan 0 sort 0}
+do_test where7-2.671.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=3
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR b=355
+ OR b=814
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR a=81
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR b=542
+ OR b=795
+ }
+} {3 42 62 74 79 81 scan 0 sort 0}
+do_test where7-2.672.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR b=363
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR b=619
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR a=73
+ }
+} {1 14 31 33 56 64 66 73 scan 0 sort 0}
+do_test where7-2.672.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR b=363
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 64 AND 66) AND a!=65)
+ OR b=619
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ OR a=73
+ }
+} {1 14 31 33 56 64 66 73 scan 0 sort 0}
+do_test where7-2.673.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=935
+ OR a=42
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR b=330
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ }
+} {9 30 35 42 55 61 85 87 scan 0 sort 0}
+do_test where7-2.673.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=935
+ OR a=42
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR b=330
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ }
+} {9 30 35 42 55 61 85 87 scan 0 sort 0}
+do_test where7-2.674.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=79
+ OR b=201
+ OR b=99
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR a=64
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR a=89
+ }
+} {9 16 19 21 42 64 68 79 89 94 scan 0 sort 0}
+do_test where7-2.674.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=79
+ OR b=201
+ OR b=99
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR a=64
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR a=89
+ }
+} {9 16 19 21 42 64 68 79 89 94 scan 0 sort 0}
+do_test where7-2.675.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=784
+ OR a=85
+ OR b=663
+ OR c=17017
+ OR b=561
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR b=495
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR b=352
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ }
+} {32 39 41 45 49 50 51 65 68 85 scan 0 sort 0}
+do_test where7-2.675.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=784
+ OR a=85
+ OR b=663
+ OR c=17017
+ OR b=561
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR b=495
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR b=352
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ }
+} {32 39 41 45 49 50 51 65 68 85 scan 0 sort 0}
+do_test where7-2.676.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR f='klmnopqrs'
+ OR f='lmnopqrst'
+ }
+} {10 11 19 36 37 62 63 88 89 100 scan 0 sort 0}
+do_test where7-2.676.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR f='klmnopqrs'
+ OR f='lmnopqrst'
+ }
+} {10 11 19 36 37 62 63 88 89 100 scan 0 sort 0}
+do_test where7-2.677.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 90 AND 92) AND a!=91)
+ OR a=46
+ OR a=44
+ }
+} {44 46 90 92 scan 0 sort 0}
+do_test where7-2.677.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 90 AND 92) AND a!=91)
+ OR a=46
+ OR a=44
+ }
+} {44 46 90 92 scan 0 sort 0}
+do_test where7-2.678.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=36
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR b=682
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR b=91
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR c=12012
+ OR b=267
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ }
+} {18 20 34 35 36 39 43 53 55 62 76 95 97 scan 0 sort 0}
+do_test where7-2.678.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=36
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR b=682
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR b=91
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR c=12012
+ OR b=267
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ }
+} {18 20 34 35 36 39 43 53 55 62 76 95 97 scan 0 sort 0}
+do_test where7-2.679.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=594
+ OR f='hijklmnop'
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR b=707
+ OR b=363
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=157
+ OR (g='tsrqpon' AND f GLOB 'yzabc*')
+ }
+} {7 12 24 33 54 58 59 65 67 85 scan 0 sort 0}
+do_test where7-2.679.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=594
+ OR f='hijklmnop'
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR b=707
+ OR b=363
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=157
+ OR (g='tsrqpon' AND f GLOB 'yzabc*')
+ }
+} {7 12 24 33 54 58 59 65 67 85 scan 0 sort 0}
+do_test where7-2.680.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR a=2
+ OR a=84
+ OR b=399
+ OR b=828
+ OR a=21
+ OR b=748
+ OR c=13013
+ OR a=57
+ OR f='mnopqrstu'
+ }
+} {2 12 21 27 37 38 39 57 64 68 84 90 scan 0 sort 0}
+do_test where7-2.680.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR a=2
+ OR a=84
+ OR b=399
+ OR b=828
+ OR a=21
+ OR b=748
+ OR c=13013
+ OR a=57
+ OR f='mnopqrstu'
+ }
+} {2 12 21 27 37 38 39 57 64 68 84 90 scan 0 sort 0}
+do_test where7-2.681.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='nmlkjih' AND f GLOB 'defgh*')
+ OR b=674
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR c=3003
+ OR a=19
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ }
+} {7 8 9 19 20 22 38 40 46 55 scan 0 sort 0}
+do_test where7-2.681.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='nmlkjih' AND f GLOB 'defgh*')
+ OR b=674
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR c=3003
+ OR a=19
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ }
+} {7 8 9 19 20 22 38 40 46 55 scan 0 sort 0}
+do_test where7-2.682.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=652
+ OR a=83
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR b=102
+ OR b=300
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ }
+} {49 83 97 scan 0 sort 0}
+do_test where7-2.682.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=652
+ OR a=83
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR b=102
+ OR b=300
+ OR (d>=49.0 AND d<50.0 AND d NOT NULL)
+ }
+} {49 83 97 scan 0 sort 0}
+do_test where7-2.683.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 53 AND 55) AND a!=54)
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR c=4004
+ OR a=95
+ OR b=707
+ OR f='vwxyzabcd'
+ OR b=286
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR b=693
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ }
+} {6 8 10 11 12 21 26 43 45 47 53 55 63 73 95 99 scan 0 sort 0}
+do_test where7-2.683.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 53 AND 55) AND a!=54)
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR c=4004
+ OR a=95
+ OR b=707
+ OR f='vwxyzabcd'
+ OR b=286
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR b=693
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ }
+} {6 8 10 11 12 21 26 43 45 47 53 55 63 73 95 99 scan 0 sort 0}
+do_test where7-2.684.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=209
+ OR b=198
+ OR a=52
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR d<0.0
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR b=168
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR f='uvwxyzabc'
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ }
+} {7 18 19 20 24 33 35 42 46 52 59 64 72 85 98 scan 0 sort 0}
+do_test where7-2.684.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=209
+ OR b=198
+ OR a=52
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR d<0.0
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR b=168
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR f='uvwxyzabc'
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ }
+} {7 18 19 20 24 33 35 42 46 52 59 64 72 85 98 scan 0 sort 0}
+do_test where7-2.685.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 4 AND 6) AND a!=5)
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR f='rstuvwxyz'
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR a=14
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ }
+} {4 6 8 12 14 17 21 26 43 47 69 73 84 89 91 95 99 scan 0 sort 0}
+do_test where7-2.685.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 4 AND 6) AND a!=5)
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR f='rstuvwxyz'
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR a=14
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ }
+} {4 6 8 12 14 17 21 26 43 47 69 73 84 89 91 95 99 scan 0 sort 0}
+do_test where7-2.686.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 13 AND 15) AND a!=14)
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR f='mnopqrstu'
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR a=38
+ OR c=26026
+ }
+} {2 12 13 15 33 35 38 64 76 77 78 90 93 95 97 scan 0 sort 0}
+do_test where7-2.686.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 13 AND 15) AND a!=14)
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR f='mnopqrstu'
+ OR (g='fedcbaz' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR a=38
+ OR c=26026
+ }
+} {2 12 13 15 33 35 38 64 76 77 78 90 93 95 97 scan 0 sort 0}
+do_test where7-2.687.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ OR a=7
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ }
+} {7 32 33 35 39 44 71 73 scan 0 sort 0}
+do_test where7-2.687.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR ((a BETWEEN 71 AND 73) AND a!=72)
+ OR a=7
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ }
+} {7 32 33 35 39 44 71 73 scan 0 sort 0}
+do_test where7-2.688.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=6006
+ OR b=938
+ OR b=484
+ OR b=652
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR f='opqrstuvw'
+ }
+} {14 15 16 17 18 40 41 44 58 66 67 92 93 scan 0 sort 0}
+do_test where7-2.688.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=6006
+ OR b=938
+ OR b=484
+ OR b=652
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR f='opqrstuvw'
+ }
+} {14 15 16 17 18 40 41 44 58 66 67 92 93 scan 0 sort 0}
+do_test where7-2.689.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=27027
+ OR b=968
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR b=487
+ OR b=924
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR c=14014
+ OR b=1001
+ }
+} {40 41 42 51 70 79 80 81 84 88 91 scan 0 sort 0}
+do_test where7-2.689.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=27027
+ OR b=968
+ OR (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR b=487
+ OR b=924
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ OR c=14014
+ OR b=1001
+ }
+} {40 41 42 51 70 79 80 81 84 88 91 scan 0 sort 0}
+do_test where7-2.690.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=25
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR b=443
+ OR b=564
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=531
+ OR b=1081
+ OR a=96
+ }
+} {10 19 25 43 45 69 71 90 96 97 scan 0 sort 0}
+do_test where7-2.690.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=25
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR b=443
+ OR b=564
+ OR (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=531
+ OR b=1081
+ OR a=96
+ }
+} {10 19 25 43 45 69 71 90 96 97 scan 0 sort 0}
+do_test where7-2.691.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=36
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ }
+} {29 scan 0 sort 0}
+do_test where7-2.691.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=36
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ }
+} {29 scan 0 sort 0}
+do_test where7-2.692.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR b=531
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR (d>=3.0 AND d<4.0 AND d NOT NULL)
+ }
+} {3 70 93 95 scan 0 sort 0}
+do_test where7-2.692.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR b=531
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR (d>=3.0 AND d<4.0 AND d NOT NULL)
+ }
+} {3 70 93 95 scan 0 sort 0}
+do_test where7-2.693.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=256
+ OR b=1034
+ }
+} {94 scan 0 sort 0}
+do_test where7-2.693.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=256
+ OR b=1034
+ }
+} {94 scan 0 sort 0}
+do_test where7-2.694.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR (d>=83.0 AND d<84.0 AND d NOT NULL)
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR b=784
+ OR b=718
+ OR a=18
+ OR a=3
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR c=28028
+ }
+} {3 18 19 21 24 26 47 58 60 73 82 83 84 99 scan 0 sort 0}
+do_test where7-2.694.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR (d>=83.0 AND d<84.0 AND d NOT NULL)
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR b=784
+ OR b=718
+ OR a=18
+ OR a=3
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR c=28028
+ }
+} {3 18 19 21 24 26 47 58 60 73 82 83 84 99 scan 0 sort 0}
+do_test where7-2.695.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=473
+ OR b=649
+ OR ((a BETWEEN 46 AND 48) AND a!=47)
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR b=1100
+ OR b=1012
+ OR a=72
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR b=176
+ OR b=355
+ }
+} {16 18 43 46 48 59 72 91 92 100 scan 0 sort 0}
+do_test where7-2.695.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=473
+ OR b=649
+ OR ((a BETWEEN 46 AND 48) AND a!=47)
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR b=1100
+ OR b=1012
+ OR a=72
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR b=176
+ OR b=355
+ }
+} {16 18 43 46 48 59 72 91 92 100 scan 0 sort 0}
+do_test where7-2.696.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR f='cdefghijk'
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ }
+} {2 15 19 28 29 30 32 54 80 91 scan 0 sort 0}
+do_test where7-2.696.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR f='cdefghijk'
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ }
+} {2 15 19 28 29 30 32 54 80 91 scan 0 sort 0}
+do_test where7-2.697.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR b=883
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR b=938
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR f='defghijkl'
+ OR c=2002
+ OR b=990
+ }
+} {3 4 5 6 17 19 22 29 55 60 81 90 scan 0 sort 0}
+do_test where7-2.697.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR b=883
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR b=938
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR f='defghijkl'
+ OR c=2002
+ OR b=990
+ }
+} {3 4 5 6 17 19 22 29 55 60 81 90 scan 0 sort 0}
+do_test where7-2.698.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 7 AND 9) AND a!=8)
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR b=902
+ OR b=25
+ }
+} {7 9 76 82 scan 0 sort 0}
+do_test where7-2.698.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 7 AND 9) AND a!=8)
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR b=902
+ OR b=25
+ }
+} {7 9 76 82 scan 0 sort 0}
+do_test where7-2.699.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='tsrqpon' AND f GLOB 'abcde*')
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR b=1092
+ OR b=495
+ }
+} {26 45 55 68 70 74 76 scan 0 sort 0}
+do_test where7-2.699.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='tsrqpon' AND f GLOB 'abcde*')
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ OR b=1092
+ OR b=495
+ }
+} {26 45 55 68 70 74 76 scan 0 sort 0}
+do_test where7-2.700.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 90 AND 92) AND a!=91)
+ OR a=46
+ OR a=74
+ }
+} {46 74 90 92 scan 0 sort 0}
+do_test where7-2.700.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 90 AND 92) AND a!=91)
+ OR a=46
+ OR a=74
+ }
+} {46 74 90 92 scan 0 sort 0}
+do_test where7-2.701.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=18
+ OR b=66
+ OR b=498
+ OR b=143
+ OR b=1034
+ OR b=289
+ OR b=319
+ }
+} {6 13 18 29 94 scan 0 sort 0}
+do_test where7-2.701.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=18
+ OR b=66
+ OR b=498
+ OR b=143
+ OR b=1034
+ OR b=289
+ OR b=319
+ }
+} {6 13 18 29 94 scan 0 sort 0}
+do_test where7-2.702.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR (g='srqponm' AND f GLOB 'cdefg*')
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR f='lmnopqrst'
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ OR b=872
+ OR a=44
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ }
+} {11 13 25 28 30 37 38 40 44 45 51 54 63 77 79 89 scan 0 sort 0}
+do_test where7-2.702.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?abcd*' AND f GLOB 'zabc*')
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR (g='srqponm' AND f GLOB 'cdefg*')
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR f='lmnopqrst'
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ OR b=872
+ OR a=44
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ }
+} {11 13 25 28 30 37 38 40 44 45 51 54 63 77 79 89 scan 0 sort 0}
+do_test where7-2.703.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR a=20
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ OR b=1004
+ OR b=77
+ OR b=927
+ OR a=99
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ }
+} {7 17 20 46 66 71 72 73 75 98 99 scan 0 sort 0}
+do_test where7-2.703.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR a=20
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ OR b=1004
+ OR b=77
+ OR b=927
+ OR a=99
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ }
+} {7 17 20 46 66 71 72 73 75 98 99 scan 0 sort 0}
+do_test where7-2.704.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=11
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ }
+} {1 21 23 45 76 scan 0 sort 0}
+do_test where7-2.704.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=11
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ }
+} {1 21 23 45 76 scan 0 sort 0}
+do_test where7-2.705.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=572
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ }
+} {52 57 scan 0 sort 0}
+do_test where7-2.705.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=572
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ }
+} {52 57 scan 0 sort 0}
+do_test where7-2.706.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR ((a BETWEEN 54 AND 56) AND a!=55)
+ OR f='lmnopqrst'
+ OR (f GLOB '?lmno*' AND f GLOB 'klmn*')
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR a=23
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ }
+} {10 11 23 36 37 44 54 56 62 63 69 81 88 89 scan 0 sort 0}
+do_test where7-2.706.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR ((a BETWEEN 54 AND 56) AND a!=55)
+ OR f='lmnopqrst'
+ OR (f GLOB '?lmno*' AND f GLOB 'klmn*')
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR a=23
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ }
+} {10 11 23 36 37 44 54 56 62 63 69 81 88 89 scan 0 sort 0}
+do_test where7-2.707.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=836
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR b=605
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR b=759
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR a=40
+ OR f='ghijklmno'
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ }
+} {6 24 32 38 40 46 50 55 58 69 70 76 84 85 89 91 scan 0 sort 0}
+do_test where7-2.707.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=836
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR b=605
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR b=759
+ OR (f GLOB '?zabc*' AND f GLOB 'yzab*')
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR a=40
+ OR f='ghijklmno'
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ }
+} {6 24 32 38 40 46 50 55 58 69 70 76 84 85 89 91 scan 0 sort 0}
+do_test where7-2.708.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ }
+} {42 51 scan 0 sort 0}
+do_test where7-2.708.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ }
+} {42 51 scan 0 sort 0}
+do_test where7-2.709.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=27027
+ OR b=872
+ OR a=56
+ }
+} {56 79 80 81 scan 0 sort 0}
+do_test where7-2.709.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=27027
+ OR b=872
+ OR a=56
+ }
+} {56 79 80 81 scan 0 sort 0}
+do_test where7-2.710.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=685
+ OR b=256
+ OR ((a BETWEEN 78 AND 80) AND a!=79)
+ OR a=44
+ OR a=63
+ OR a=15
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ }
+} {15 22 24 44 63 78 80 scan 0 sort 0}
+do_test where7-2.710.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=685
+ OR b=256
+ OR ((a BETWEEN 78 AND 80) AND a!=79)
+ OR a=44
+ OR a=63
+ OR a=15
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ }
+} {15 22 24 44 63 78 80 scan 0 sort 0}
+do_test where7-2.711.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='nmlkjih' AND f GLOB 'efghi*')
+ OR a=34
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR a=67
+ OR a=28
+ }
+} {6 8 28 34 56 67 75 scan 0 sort 0}
+do_test where7-2.711.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='nmlkjih' AND f GLOB 'efghi*')
+ OR a=34
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR a=67
+ OR a=28
+ }
+} {6 8 28 34 56 67 75 scan 0 sort 0}
+do_test where7-2.712.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='qponmlk' AND f GLOB 'pqrst*')
+ OR a=52
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR f='ghijklmno'
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR b=319
+ OR a=34
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR f='hijklmnop'
+ }
+} {6 7 12 18 24 29 32 33 34 41 52 58 59 68 70 84 85 scan 0 sort 0}
+do_test where7-2.712.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='qponmlk' AND f GLOB 'pqrst*')
+ OR a=52
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR f='ghijklmno'
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR b=319
+ OR a=34
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR f='hijklmnop'
+ }
+} {6 7 12 18 24 29 32 33 34 41 52 58 59 68 70 84 85 scan 0 sort 0}
+do_test where7-2.713.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='qponmlk' AND f GLOB 'pqrst*')
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR a=47
+ }
+} {41 47 69 71 scan 0 sort 0}
+do_test where7-2.713.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='qponmlk' AND f GLOB 'pqrst*')
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR a=47
+ }
+} {41 47 69 71 scan 0 sort 0}
+do_test where7-2.714.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 33 AND 35) AND a!=34)
+ OR c=7007
+ }
+} {19 20 21 33 35 scan 0 sort 0}
+do_test where7-2.714.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 33 AND 35) AND a!=34)
+ OR c=7007
+ }
+} {19 20 21 33 35 scan 0 sort 0}
+do_test where7-2.715.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=531
+ OR a=12
+ OR b=583
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR a=61
+ OR b=187
+ }
+} {12 17 53 61 93 95 scan 0 sort 0}
+do_test where7-2.715.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=531
+ OR a=12
+ OR b=583
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR a=61
+ OR b=187
+ }
+} {12 17 53 61 93 95 scan 0 sort 0}
+do_test where7-2.716.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=31031
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=256
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR b=715
+ OR b=212
+ OR b=99
+ OR c=29029
+ }
+} {9 12 38 45 65 66 68 77 79 85 86 87 91 92 93 scan 0 sort 0}
+do_test where7-2.716.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=31031
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=256
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR b=715
+ OR b=212
+ OR b=99
+ OR c=29029
+ }
+} {9 12 38 45 65 66 68 77 79 85 86 87 91 92 93 scan 0 sort 0}
+do_test where7-2.717.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 40 AND 42) AND a!=41)
+ OR b=33
+ OR a=62
+ OR b=916
+ OR b=1012
+ OR a=2
+ OR a=51
+ OR b=286
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR b=80
+ }
+} {2 3 26 40 42 51 62 92 96 scan 0 sort 0}
+do_test where7-2.717.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 40 AND 42) AND a!=41)
+ OR b=33
+ OR a=62
+ OR b=916
+ OR b=1012
+ OR a=2
+ OR a=51
+ OR b=286
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR b=80
+ }
+} {2 3 26 40 42 51 62 92 96 scan 0 sort 0}
+do_test where7-2.718.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=847
+ OR f='efghijklm'
+ OR (d>=6.0 AND d<7.0 AND d NOT NULL)
+ }
+} {4 6 30 56 77 82 scan 0 sort 0}
+do_test where7-2.718.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=847
+ OR f='efghijklm'
+ OR (d>=6.0 AND d<7.0 AND d NOT NULL)
+ }
+} {4 6 30 56 77 82 scan 0 sort 0}
+do_test where7-2.719.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR ((a BETWEEN 62 AND 64) AND a!=63)
+ }
+} {25 62 64 scan 0 sort 0}
+do_test where7-2.719.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR ((a BETWEEN 62 AND 64) AND a!=63)
+ }
+} {25 62 64 scan 0 sort 0}
+do_test where7-2.720.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 43 AND 45) AND a!=44)
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR a=43
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ OR b=729
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ }
+} {14 31 33 43 45 53 scan 0 sort 0}
+do_test where7-2.720.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 43 AND 45) AND a!=44)
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR a=43
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ OR b=729
+ OR (g='vutsrqp' AND f GLOB 'opqrs*')
+ }
+} {14 31 33 43 45 53 scan 0 sort 0}
+do_test where7-2.721.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='efghijklm'
+ OR a=70
+ OR b=278
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR c=8008
+ OR f='opqrstuvw'
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ }
+} {4 5 14 22 23 24 25 30 33 35 40 56 66 70 82 92 scan 0 sort 0}
+do_test where7-2.721.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='efghijklm'
+ OR a=70
+ OR b=278
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR c=8008
+ OR f='opqrstuvw'
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ }
+} {4 5 14 22 23 24 25 30 33 35 40 56 66 70 82 92 scan 0 sort 0}
+do_test where7-2.722.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR c<=10
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR a=35
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR b=1089
+ OR a=73
+ OR b=737
+ OR c=18018
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ }
+} {6 23 31 32 35 40 42 52 53 54 58 62 67 73 84 99 scan 0 sort 0}
+do_test where7-2.722.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR c<=10
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR a=35
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR b=1089
+ OR a=73
+ OR b=737
+ OR c=18018
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ }
+} {6 23 31 32 35 40 42 52 53 54 58 62 67 73 84 99 scan 0 sort 0}
+do_test where7-2.723.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 0 AND 2) AND a!=1)
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=762
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR a=80
+ }
+} {2 39 41 79 80 95 scan 0 sort 0}
+do_test where7-2.723.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 0 AND 2) AND a!=1)
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=762
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ OR a=80
+ }
+} {2 39 41 79 80 95 scan 0 sort 0}
+do_test where7-2.724.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 28 AND 30) AND a!=29)
+ OR b=737
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR b=979
+ OR a=36
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR a=55
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ }
+} {20 28 30 36 46 50 55 67 72 80 82 89 95 98 scan 0 sort 0}
+do_test where7-2.724.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 28 AND 30) AND a!=29)
+ OR b=737
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR b=979
+ OR a=36
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ OR a=55
+ OR (g='fedcbaz' AND f GLOB 'rstuv*')
+ }
+} {20 28 30 36 46 50 55 67 72 80 82 89 95 98 scan 0 sort 0}
+do_test where7-2.725.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=75
+ OR a=61
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ }
+} {52 61 75 91 scan 0 sort 0}
+do_test where7-2.725.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=75
+ OR a=61
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ }
+} {52 61 75 91 scan 0 sort 0}
+do_test where7-2.726.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1004
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ OR a=56
+ }
+} {7 56 61 scan 0 sort 0}
+do_test where7-2.726.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1004
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ OR a=56
+ }
+} {7 56 61 scan 0 sort 0}
+do_test where7-2.727.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=93
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR a=83
+ OR b=828
+ OR b=454
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR b=924
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ OR a=50
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ }
+} {38 50 58 66 83 84 89 91 93 scan 0 sort 0}
+do_test where7-2.727.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=93
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR a=83
+ OR b=828
+ OR b=454
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR b=924
+ OR (g='lkjihgf' AND f GLOB 'opqrs*')
+ OR a=50
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ }
+} {38 50 58 66 83 84 89 91 93 scan 0 sort 0}
+do_test where7-2.728.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='stuvwxyza'
+ OR a=44
+ OR c=2002
+ }
+} {4 5 6 18 44 70 96 scan 0 sort 0}
+do_test where7-2.728.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='stuvwxyza'
+ OR a=44
+ OR c=2002
+ }
+} {4 5 6 18 44 70 96 scan 0 sort 0}
+do_test where7-2.729.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=55
+ OR a=65
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ }
+} {14 40 55 65 66 92 scan 0 sort 0}
+do_test where7-2.729.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=55
+ OR a=65
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ }
+} {14 40 55 65 66 92 scan 0 sort 0}
+do_test where7-2.730.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 72 AND 74) AND a!=73)
+ OR b=605
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR f='ijklmnopq'
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR c=9009
+ OR b=374
+ }
+} {8 12 13 25 26 27 34 43 55 60 72 74 86 88 scan 0 sort 0}
+do_test where7-2.730.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 72 AND 74) AND a!=73)
+ OR b=605
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR f='ijklmnopq'
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR c=9009
+ OR b=374
+ }
+} {8 12 13 25 26 27 34 43 55 60 72 74 86 88 scan 0 sort 0}
+do_test where7-2.731.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=476
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR b=982
+ OR a=43
+ OR b=355
+ }
+} {8 43 scan 0 sort 0}
+do_test where7-2.731.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=476
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR b=982
+ OR a=43
+ OR b=355
+ }
+} {8 43 scan 0 sort 0}
+do_test where7-2.732.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=85
+ OR b=718
+ OR (g='fedcbaz' AND f GLOB 'pqrst*')
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ }
+} {1 25 27 53 79 85 93 scan 0 sort 0}
+do_test where7-2.732.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=85
+ OR b=718
+ OR (g='fedcbaz' AND f GLOB 'pqrst*')
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ }
+} {1 25 27 53 79 85 93 scan 0 sort 0}
+do_test where7-2.733.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ }
+} {73 96 98 scan 0 sort 0}
+do_test where7-2.733.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ }
+} {73 96 98 scan 0 sort 0}
+do_test where7-2.734.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=176
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR ((a BETWEEN 27 AND 29) AND a!=28)
+ OR b=619
+ OR b=597
+ OR b=198
+ OR a=27
+ OR b=91
+ OR a=77
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ }
+} {16 18 25 27 29 77 80 scan 0 sort 0}
+do_test where7-2.734.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=176
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR ((a BETWEEN 27 AND 29) AND a!=28)
+ OR b=619
+ OR b=597
+ OR b=198
+ OR a=27
+ OR b=91
+ OR a=77
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ }
+} {16 18 25 27 29 77 80 scan 0 sort 0}
+do_test where7-2.735.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=41
+ OR b=528
+ OR c=3003
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=22
+ }
+} {2 7 8 9 20 22 41 48 scan 0 sort 0}
+do_test where7-2.735.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=41
+ OR b=528
+ OR c=3003
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR b=22
+ }
+} {2 7 8 9 20 22 41 48 scan 0 sort 0}
+do_test where7-2.736.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR b=465
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=37
+ OR b=1056
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR b=1023
+ }
+} {4 16 29 37 42 63 65 68 93 94 96 scan 0 sort 0}
+do_test where7-2.736.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR b=465
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=37
+ OR b=1056
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR b=1023
+ }
+} {4 16 29 37 42 63 65 68 93 94 96 scan 0 sort 0}
+do_test where7-2.737.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=76
+ OR a=8
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR b=495
+ OR b=663
+ OR a=98
+ OR b=748
+ }
+} {8 27 45 68 76 98 scan 0 sort 0}
+do_test where7-2.737.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=76
+ OR a=8
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR b=495
+ OR b=663
+ OR a=98
+ OR b=748
+ }
+} {8 27 45 68 76 98 scan 0 sort 0}
+do_test where7-2.738.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1081
+ OR b=542
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR b=828
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR a=18
+ }
+} {18 47 61 64 67 scan 0 sort 0}
+do_test where7-2.738.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1081
+ OR b=542
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR b=828
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR a=18
+ }
+} {18 47 61 64 67 scan 0 sort 0}
+do_test where7-2.739.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='abcdefghi'
+ OR a=14
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR c=27027
+ OR a=47
+ }
+} {13 14 26 47 52 78 79 80 81 scan 0 sort 0}
+do_test where7-2.739.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='abcdefghi'
+ OR a=14
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR c=27027
+ OR a=47
+ }
+} {13 14 26 47 52 78 79 80 81 scan 0 sort 0}
+do_test where7-2.740.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=31031
+ OR b=737
+ OR a=37
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ OR a=91
+ OR b=77
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ }
+} {7 37 65 67 91 92 93 94 98 100 scan 0 sort 0}
+do_test where7-2.740.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=31031
+ OR b=737
+ OR a=37
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ OR a=91
+ OR b=77
+ OR (d>=94.0 AND d<95.0 AND d NOT NULL)
+ }
+} {7 37 65 67 91 92 93 94 98 100 scan 0 sort 0}
+do_test where7-2.741.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=17
+ OR b=484
+ OR c=3003
+ OR b=121
+ OR a=53
+ }
+} {7 8 9 11 17 44 53 scan 0 sort 0}
+do_test where7-2.741.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=17
+ OR b=484
+ OR c=3003
+ OR b=121
+ OR a=53
+ }
+} {7 8 9 11 17 44 53 scan 0 sort 0}
+do_test where7-2.742.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=880
+ OR b=696
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR b=308
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ }
+} {5 28 65 80 96 98 scan 0 sort 0}
+do_test where7-2.742.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=880
+ OR b=696
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR b=308
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ }
+} {5 28 65 80 96 98 scan 0 sort 0}
+do_test where7-2.743.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR a=24
+ OR f IS NULL
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR c=12012
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ }
+} {24 25 34 35 36 57 77 88 scan 0 sort 0}
+do_test where7-2.743.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR a=24
+ OR f IS NULL
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR c=12012
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ }
+} {24 25 34 35 36 57 77 88 scan 0 sort 0}
+do_test where7-2.744.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=94
+ OR (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR b=792
+ OR a=77
+ OR a=26
+ OR b=641
+ OR a=38
+ }
+} {26 38 72 74 77 85 94 scan 0 sort 0}
+do_test where7-2.744.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=94
+ OR (d>=74.0 AND d<75.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR b=792
+ OR a=77
+ OR a=26
+ OR b=641
+ OR a=38
+ }
+} {26 38 72 74 77 85 94 scan 0 sort 0}
+do_test where7-2.745.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 51 AND 53) AND a!=52)
+ OR (d>=30.0 AND d<31.0 AND d NOT NULL)
+ OR b=14
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR b=121
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ }
+} {11 15 17 27 30 51 53 63 86 89 91 scan 0 sort 0}
+do_test where7-2.745.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 51 AND 53) AND a!=52)
+ OR (d>=30.0 AND d<31.0 AND d NOT NULL)
+ OR b=14
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR ((a BETWEEN 15 AND 17) AND a!=16)
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR b=121
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ }
+} {11 15 17 27 30 51 53 63 86 89 91 scan 0 sort 0}
+do_test where7-2.746.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=517
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR f='opqrstuvw'
+ }
+} {14 40 47 66 69 71 92 scan 0 sort 0}
+do_test where7-2.746.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=517
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR f='opqrstuvw'
+ }
+} {14 40 47 66 69 71 92 scan 0 sort 0}
+do_test where7-2.747.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=84.0 AND d<85.0 AND d NOT NULL)
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=267
+ OR c=19019
+ OR a=42
+ OR b=938
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ }
+} {1 9 17 21 22 24 32 34 35 42 43 55 56 57 61 69 84 87 95 scan 0 sort 0}
+do_test where7-2.747.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=84.0 AND d<85.0 AND d NOT NULL)
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=267
+ OR c=19019
+ OR a=42
+ OR b=938
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ }
+} {1 9 17 21 22 24 32 34 35 42 43 55 56 57 61 69 84 87 95 scan 0 sort 0}
+do_test where7-2.748.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=179
+ OR a=50
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ }
+} {29 50 scan 0 sort 0}
+do_test where7-2.748.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=179
+ OR a=50
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ }
+} {29 50 scan 0 sort 0}
+do_test where7-2.749.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR f='xyzabcdef'
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR b=575
+ OR b=385
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=46
+ OR b=220
+ OR a=63
+ }
+} {17 18 20 23 35 46 49 51 63 65 75 scan 0 sort 0}
+do_test where7-2.749.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR f='xyzabcdef'
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR b=575
+ OR b=385
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=46
+ OR b=220
+ OR a=63
+ }
+} {17 18 20 23 35 46 49 51 63 65 75 scan 0 sort 0}
+do_test where7-2.750.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1056
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=1078
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ OR c=31031
+ OR b=869
+ OR (g='jihgfed' AND f GLOB 'zabcd*')
+ OR b=245
+ OR a=92
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR b=880
+ }
+} {66 77 79 80 91 92 93 96 98 scan 0 sort 0}
+do_test where7-2.750.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1056
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=1078
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ OR c=31031
+ OR b=869
+ OR (g='jihgfed' AND f GLOB 'zabcd*')
+ OR b=245
+ OR a=92
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR b=880
+ }
+} {66 77 79 80 91 92 93 96 98 scan 0 sort 0}
+do_test where7-2.751.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1078
+ OR c=28028
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR c=9009
+ OR a=17
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ }
+} {16 17 19 25 26 27 38 39 40 42 61 68 82 83 84 94 98 scan 0 sort 0}
+do_test where7-2.751.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1078
+ OR c=28028
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR c=9009
+ OR a=17
+ OR (d>=39.0 AND d<40.0 AND d NOT NULL)
+ }
+} {16 17 19 25 26 27 38 39 40 42 61 68 82 83 84 94 98 scan 0 sort 0}
+do_test where7-2.752.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR b=762
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR f='tuvwxyzab'
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR b=1034
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ }
+} {14 19 31 33 44 45 57 58 71 94 97 scan 0 sort 0}
+do_test where7-2.752.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR b=762
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR f='tuvwxyzab'
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR b=1034
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ }
+} {14 19 31 33 44 45 57 58 71 94 97 scan 0 sort 0}
+do_test where7-2.753.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=47
+ OR b=187
+ OR a=56
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ }
+} {17 30 32 56 68 70 89 91 scan 0 sort 0}
+do_test where7-2.753.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=47
+ OR b=187
+ OR a=56
+ OR ((a BETWEEN 30 AND 32) AND a!=31)
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ }
+} {17 30 32 56 68 70 89 91 scan 0 sort 0}
+do_test where7-2.754.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=11011
+ OR a=14
+ OR c=16016
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR f='jklmnopqr'
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR b=916
+ }
+} {9 14 21 25 30 31 32 33 35 46 47 48 61 87 96 scan 0 sort 0}
+do_test where7-2.754.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=11011
+ OR a=14
+ OR c=16016
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR f='jklmnopqr'
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR b=916
+ }
+} {9 14 21 25 30 31 32 33 35 46 47 48 61 87 96 scan 0 sort 0}
+do_test where7-2.755.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=949
+ OR (g='srqponm' AND f GLOB 'cdefg*')
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR c<=10
+ OR a=14
+ OR b=608
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR b=121
+ OR b=333
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ }
+} {11 14 17 28 66 93 95 98 scan 0 sort 0}
+do_test where7-2.755.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=949
+ OR (g='srqponm' AND f GLOB 'cdefg*')
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ OR c<=10
+ OR a=14
+ OR b=608
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR b=121
+ OR b=333
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ }
+} {11 14 17 28 66 93 95 98 scan 0 sort 0}
+do_test where7-2.756.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=355
+ OR b=627
+ OR b=1001
+ OR b=1026
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ }
+} {57 58 60 69 91 scan 0 sort 0}
+do_test where7-2.756.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'rstuv*')
+ OR b=355
+ OR b=627
+ OR b=1001
+ OR b=1026
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ }
+} {57 58 60 69 91 scan 0 sort 0}
+do_test where7-2.757.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'efghi*')
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ }
+} {4 79 scan 0 sort 0}
+do_test where7-2.757.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'efghi*')
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ }
+} {4 79 scan 0 sort 0}
+do_test where7-2.758.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=685
+ OR a=14
+ OR b=990
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR f='efghijklm'
+ OR c=1001
+ OR b=784
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ }
+} {1 2 3 4 14 26 30 32 56 69 82 90 scan 0 sort 0}
+do_test where7-2.758.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=685
+ OR a=14
+ OR b=990
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR f='efghijklm'
+ OR c=1001
+ OR b=784
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ }
+} {1 2 3 4 14 26 30 32 56 69 82 90 scan 0 sort 0}
+do_test where7-2.759.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=54
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR c=26026
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ }
+} {39 54 76 77 78 97 99 scan 0 sort 0}
+do_test where7-2.759.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=54
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR c=26026
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ }
+} {39 54 76 77 78 97 99 scan 0 sort 0}
+do_test where7-2.760.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR c=24024
+ OR a=98
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR a=5
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR f='pqrstuvwx'
+ OR f='bcdefghij'
+ OR b=1001
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ }
+} {1 5 15 21 27 31 33 36 41 53 67 70 71 72 77 79 84 91 93 98 scan 0 sort 0}
+do_test where7-2.760.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR c=24024
+ OR a=98
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR a=5
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR f='pqrstuvwx'
+ OR f='bcdefghij'
+ OR b=1001
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ }
+} {1 5 15 21 27 31 33 36 41 53 67 70 71 72 77 79 84 91 93 98 scan 0 sort 0}
+do_test where7-2.761.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=781
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR f='lmnopqrst'
+ OR a=39
+ OR a=100
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {1 11 14 37 39 40 54 56 58 63 66 71 89 92 99 100 scan 0 sort 0}
+do_test where7-2.761.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=781
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR f='lmnopqrst'
+ OR a=39
+ OR a=100
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ }
+} {1 11 14 37 39 40 54 56 58 63 66 71 89 92 99 100 scan 0 sort 0}
+do_test where7-2.762.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=4004
+ OR b=718
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR a=50
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR b=363
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ OR b=1023
+ }
+} {10 11 12 33 34 40 50 93 scan 0 sort 0}
+do_test where7-2.762.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=4004
+ OR b=718
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR a=50
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR b=363
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ OR b=1023
+ }
+} {10 11 12 33 34 40 50 93 scan 0 sort 0}
+do_test where7-2.763.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1081
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR b=473
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR b=586
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ }
+} {20 26 43 45 46 55 72 98 scan 0 sort 0}
+do_test where7-2.763.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1081
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR b=473
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ OR b=586
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')
+ }
+} {20 26 43 45 46 55 72 98 scan 0 sort 0}
+do_test where7-2.764.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ }
+} {7 13 33 58 59 85 scan 0 sort 0}
+do_test where7-2.764.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ }
+} {7 13 33 58 59 85 scan 0 sort 0}
+do_test where7-2.765.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR a=47
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR (g='lkjihgf' AND f GLOB 'lmnop*')
+ OR (d>=84.0 AND d<85.0 AND d NOT NULL)
+ OR f='lmnopqrst'
+ }
+} {11 37 47 63 68 76 78 84 85 89 scan 0 sort 0}
+do_test where7-2.765.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR ((a BETWEEN 76 AND 78) AND a!=77)
+ OR a=47
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR (g='lkjihgf' AND f GLOB 'lmnop*')
+ OR (d>=84.0 AND d<85.0 AND d NOT NULL)
+ OR f='lmnopqrst'
+ }
+} {11 37 47 63 68 76 78 84 85 89 scan 0 sort 0}
+do_test where7-2.766.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c>=34035
+ OR a=29
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR f='abcdefghi'
+ OR b=993
+ OR ((a BETWEEN 52 AND 54) AND a!=53)
+ OR ((a BETWEEN 45 AND 47) AND a!=46)
+ }
+} {19 21 26 29 45 47 52 54 73 78 99 scan 0 sort 0}
+do_test where7-2.766.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c>=34035
+ OR a=29
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')
+ OR f='abcdefghi'
+ OR b=993
+ OR ((a BETWEEN 52 AND 54) AND a!=53)
+ OR ((a BETWEEN 45 AND 47) AND a!=46)
+ }
+} {19 21 26 29 45 47 52 54 73 78 99 scan 0 sort 0}
+do_test where7-2.767.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=696
+ OR b=154
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR a=22
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR a=52
+ OR a=21
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ }
+} {14 16 21 22 24 47 52 63 70 scan 0 sort 0}
+do_test where7-2.767.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=696
+ OR b=154
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR a=22
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR a=52
+ OR a=21
+ OR (d>=70.0 AND d<71.0 AND d NOT NULL)
+ }
+} {14 16 21 22 24 47 52 63 70 scan 0 sort 0}
+do_test where7-2.768.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=693
+ OR b=201
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR b=520
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR b=407
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR c>=34035
+ OR b=135
+ }
+} {23 25 36 37 38 63 scan 0 sort 0}
+do_test where7-2.768.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=693
+ OR b=201
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ OR b=520
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR b=407
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR c>=34035
+ OR b=135
+ }
+} {23 25 36 37 38 63 scan 0 sort 0}
+do_test where7-2.769.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR b=707
+ OR b=14
+ OR b=1089
+ OR b=352
+ }
+} {32 43 99 scan 0 sort 0}
+do_test where7-2.769.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR b=707
+ OR b=14
+ OR b=1089
+ OR b=352
+ }
+} {32 43 99 scan 0 sort 0}
+do_test where7-2.770.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=278
+ OR b=278
+ OR b=825
+ OR f='rstuvwxyz'
+ OR b=938
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ }
+} {17 19 43 45 69 75 95 scan 0 sort 0}
+do_test where7-2.770.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=278
+ OR b=278
+ OR b=825
+ OR f='rstuvwxyz'
+ OR b=938
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR ((a BETWEEN 43 AND 45) AND a!=44)
+ }
+} {17 19 43 45 69 75 95 scan 0 sort 0}
+do_test where7-2.771.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=1045
+ OR c=27027
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ }
+} {11 32 34 37 63 79 80 81 89 95 scan 0 sort 0}
+do_test where7-2.771.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=1045
+ OR c=27027
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ }
+} {11 32 34 37 63 79 80 81 89 95 scan 0 sort 0}
+do_test where7-2.772.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=87
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR b=487
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ }
+} {47 87 90 scan 0 sort 0}
+do_test where7-2.772.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=87
+ OR (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR b=487
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ }
+} {47 87 90 scan 0 sort 0}
+do_test where7-2.773.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 30 AND 32) AND a!=31)
+ OR b=69
+ OR b=608
+ OR b=814
+ OR a=67
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR b=1059
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ OR a=18
+ OR b=407
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ }
+} {10 12 18 30 32 37 58 61 67 74 scan 0 sort 0}
+do_test where7-2.773.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 30 AND 32) AND a!=31)
+ OR b=69
+ OR b=608
+ OR b=814
+ OR a=67
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR b=1059
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ OR a=18
+ OR b=407
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ }
+} {10 12 18 30 32 37 58 61 67 74 scan 0 sort 0}
+do_test where7-2.774.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=223
+ OR b=80
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ }
+} {74 76 97 99 scan 0 sort 0}
+do_test where7-2.774.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=223
+ OR b=80
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR ((a BETWEEN 74 AND 76) AND a!=75)
+ }
+} {74 76 97 99 scan 0 sort 0}
+do_test where7-2.775.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=220
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR b=363
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ }
+} {10 12 20 33 52 54 55 66 scan 0 sort 0}
+do_test where7-2.775.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=220
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR b=363
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'defgh*')
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ }
+} {10 12 20 33 52 54 55 66 scan 0 sort 0}
+do_test where7-2.776.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=498
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR b=880
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR b=828
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR b=113
+ }
+} {5 15 60 62 80 scan 0 sort 0}
+do_test where7-2.776.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=498
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR b=880
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR b=828
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR b=113
+ }
+} {5 15 60 62 80 scan 0 sort 0}
+do_test where7-2.777.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1059
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR b=960
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR b=894
+ OR c=2002
+ }
+} {4 5 6 12 16 20 42 68 94 scan 0 sort 0}
+do_test where7-2.777.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1059
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR b=960
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR b=894
+ OR c=2002
+ }
+} {4 5 6 12 16 20 42 68 94 scan 0 sort 0}
+do_test where7-2.778.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=14
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ }
+} {85 scan 0 sort 0}
+do_test where7-2.778.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=14
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ }
+} {85 scan 0 sort 0}
+do_test where7-2.779.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=806
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ OR b=795
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR c=23023
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ }
+} {21 23 33 67 68 69 86 88 99 scan 0 sort 0}
+do_test where7-2.779.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=806
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ OR b=795
+ OR ((a BETWEEN 99 AND 101) AND a!=100)
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR c=23023
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ }
+} {21 23 33 67 68 69 86 88 99 scan 0 sort 0}
+do_test where7-2.780.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=726
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR f='abcdefghi'
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR b=869
+ }
+} {8 10 15 26 41 52 66 67 78 79 92 93 scan 0 sort 0}
+do_test where7-2.780.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=726
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR f='abcdefghi'
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR b=869
+ }
+} {8 10 15 26 41 52 66 67 78 79 92 93 scan 0 sort 0}
+do_test where7-2.781.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=59
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ OR b=1081
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ }
+} {5 7 59 96 scan 0 sort 0}
+do_test where7-2.781.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=59
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ OR b=1081
+ OR (g='fedcbaz' AND f GLOB 'stuvw*')
+ }
+} {5 7 59 96 scan 0 sort 0}
+do_test where7-2.782.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='qponmlk' AND f GLOB 'nopqr*')
+ OR b=1037
+ OR b=132
+ OR c=1001
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR a=32
+ }
+} {1 2 3 12 18 20 32 39 58 68 91 scan 0 sort 0}
+do_test where7-2.782.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='qponmlk' AND f GLOB 'nopqr*')
+ OR b=1037
+ OR b=132
+ OR c=1001
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR a=32
+ }
+} {1 2 3 12 18 20 32 39 58 68 91 scan 0 sort 0}
+do_test where7-2.783.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=24
+ OR b=927
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR a=7
+ OR b=462
+ OR b=608
+ OR b=781
+ OR b=253
+ OR c=25025
+ OR b=132
+ }
+} {7 12 23 24 42 52 71 73 74 75 scan 0 sort 0}
+do_test where7-2.783.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=24
+ OR b=927
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR a=7
+ OR b=462
+ OR b=608
+ OR b=781
+ OR b=253
+ OR c=25025
+ OR b=132
+ }
+} {7 12 23 24 42 52 71 73 74 75 scan 0 sort 0}
+do_test where7-2.784.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=1001
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR a=83
+ }
+} {23 25 61 83 91 scan 0 sort 0}
+do_test where7-2.784.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=1001
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR a=83
+ }
+} {23 25 61 83 91 scan 0 sort 0}
+do_test where7-2.785.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR b=36
+ OR (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR ((a BETWEEN 46 AND 48) AND a!=47)
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR ((a BETWEEN 26 AND 28) AND a!=27)
+ }
+} {3 26 28 29 31 33 46 48 55 60 73 77 80 81 82 91 scan 0 sort 0}
+do_test where7-2.785.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR b=36
+ OR (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR ((a BETWEEN 46 AND 48) AND a!=47)
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR (d>=91.0 AND d<92.0 AND d NOT NULL)
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR ((a BETWEEN 26 AND 28) AND a!=27)
+ }
+} {3 26 28 29 31 33 46 48 55 60 73 77 80 81 82 91 scan 0 sort 0}
+do_test where7-2.786.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=69
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR a=98
+ OR b=300
+ OR a=41
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR a=33
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ }
+} {1 2 10 12 28 33 37 39 41 54 58 60 69 80 98 scan 0 sort 0}
+do_test where7-2.786.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=69
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR a=98
+ OR b=300
+ OR a=41
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR a=33
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ }
+} {1 2 10 12 28 33 37 39 41 54 58 60 69 80 98 scan 0 sort 0}
+do_test where7-2.787.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR ((a BETWEEN 94 AND 96) AND a!=95)
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR b=619
+ OR c=6006
+ OR b=91
+ OR b=297
+ OR b=165
+ }
+} {1 15 16 17 18 22 24 27 53 68 70 71 79 90 94 96 scan 0 sort 0}
+do_test where7-2.787.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 68 AND 70) AND a!=69)
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR ((a BETWEEN 94 AND 96) AND a!=95)
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR b=619
+ OR c=6006
+ OR b=91
+ OR b=297
+ OR b=165
+ }
+} {1 15 16 17 18 22 24 27 53 68 70 71 79 90 94 96 scan 0 sort 0}
+do_test where7-2.788.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 9 AND 11) AND a!=10)
+ OR a=55
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ }
+} {9 11 55 75 scan 0 sort 0}
+do_test where7-2.788.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 9 AND 11) AND a!=10)
+ OR a=55
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ }
+} {9 11 55 75 scan 0 sort 0}
+do_test where7-2.789.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 84 AND 86) AND a!=85)
+ OR b=737
+ OR b=201
+ OR a=7
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR b=957
+ }
+} {2 7 26 67 84 86 87 scan 0 sort 0}
+do_test where7-2.789.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 84 AND 86) AND a!=85)
+ OR b=737
+ OR b=201
+ OR a=7
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR (g='yxwvuts' AND f GLOB 'cdefg*')
+ OR b=957
+ }
+} {2 7 26 67 84 86 87 scan 0 sort 0}
+do_test where7-2.790.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 90 AND 92) AND a!=91)
+ OR a=74
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR a=89
+ }
+} {18 44 67 70 74 79 89 90 92 95 96 97 scan 0 sort 0}
+do_test where7-2.790.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 90 AND 92) AND a!=91)
+ OR a=74
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')
+ OR a=89
+ }
+} {18 44 67 70 74 79 89 90 92 95 96 97 scan 0 sort 0}
+do_test where7-2.791.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=179
+ OR b=1081
+ OR b=377
+ OR b=495
+ OR b=564
+ OR b=289
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ }
+} {39 45 scan 0 sort 0}
+do_test where7-2.791.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=179
+ OR b=1081
+ OR b=377
+ OR b=495
+ OR b=564
+ OR b=289
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ }
+} {39 45 scan 0 sort 0}
+do_test where7-2.792.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR a=69
+ OR a=12
+ OR b=718
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ }
+} {12 20 22 69 scan 0 sort 0}
+do_test where7-2.792.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR a=69
+ OR a=12
+ OR b=718
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ }
+} {12 20 22 69 scan 0 sort 0}
+do_test where7-2.793.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR f='klmnopqrs'
+ OR b=674
+ OR a=96
+ OR a=99
+ OR b=608
+ OR b=707
+ OR f='cdefghijk'
+ OR a=91
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ }
+} {2 10 23 25 28 36 54 62 80 88 91 96 99 scan 0 sort 0}
+do_test where7-2.793.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR f='klmnopqrs'
+ OR b=674
+ OR a=96
+ OR a=99
+ OR b=608
+ OR b=707
+ OR f='cdefghijk'
+ OR a=91
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ }
+} {2 10 23 25 28 36 54 62 80 88 91 96 99 scan 0 sort 0}
+do_test where7-2.794.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR b=564
+ OR b=784
+ OR b=418
+ OR b=275
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR a=58
+ OR c=11011
+ OR b=660
+ }
+} {9 25 31 32 33 35 38 58 60 61 87 88 scan 0 sort 0}
+do_test where7-2.794.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR b=564
+ OR b=784
+ OR b=418
+ OR b=275
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ OR a=58
+ OR c=11011
+ OR b=660
+ }
+} {9 25 31 32 33 35 38 58 60 61 87 88 scan 0 sort 0}
+do_test where7-2.795.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR b=509
+ OR b=1004
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (g='mlkjihg' AND f GLOB 'hijkl*')
+ OR f='pqrstuvwx'
+ }
+} {15 25 28 30 41 57 59 67 93 scan 0 sort 0}
+do_test where7-2.795.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR b=509
+ OR b=1004
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR ((a BETWEEN 57 AND 59) AND a!=58)
+ OR (g='mlkjihg' AND f GLOB 'hijkl*')
+ OR f='pqrstuvwx'
+ }
+} {15 25 28 30 41 57 59 67 93 scan 0 sort 0}
+do_test where7-2.796.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=440
+ OR ((a BETWEEN 52 AND 54) AND a!=53)
+ }
+} {40 52 54 scan 0 sort 0}
+do_test where7-2.796.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=440
+ OR ((a BETWEEN 52 AND 54) AND a!=53)
+ }
+} {40 52 54 scan 0 sort 0}
+do_test where7-2.797.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=95.0 AND d<96.0 AND d NOT NULL)
+ OR f='abcdefghi'
+ }
+} {26 52 78 95 scan 0 sort 0}
+do_test where7-2.797.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=95.0 AND d<96.0 AND d NOT NULL)
+ OR f='abcdefghi'
+ }
+} {26 52 78 95 scan 0 sort 0}
+do_test where7-2.798.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=19
+ OR a=29
+ OR b=476
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR b=91
+ }
+} {19 29 41 scan 0 sort 0}
+do_test where7-2.798.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=19
+ OR a=29
+ OR b=476
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR b=91
+ }
+} {19 29 41 scan 0 sort 0}
+do_test where7-2.799.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='lmnopqrst'
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR a=47
+ OR a=71
+ }
+} {8 11 37 47 63 71 89 scan 0 sort 0}
+do_test where7-2.799.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='lmnopqrst'
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR a=47
+ OR a=71
+ }
+} {8 11 37 47 63 71 89 scan 0 sort 0}
+do_test where7-2.800.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=531
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=44
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ OR b=707
+ OR b=322
+ }
+} {4 12 32 34 49 84 95 97 scan 0 sort 0}
+do_test where7-2.800.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=531
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=44
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ OR b=707
+ OR b=322
+ }
+} {4 12 32 34 49 84 95 97 scan 0 sort 0}
+do_test where7-2.801.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR f='jklmnopqr'
+ }
+} {3 9 29 35 55 61 81 82 87 89 scan 0 sort 0}
+do_test where7-2.801.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR f='jklmnopqr'
+ }
+} {3 9 29 35 55 61 81 82 87 89 scan 0 sort 0}
+do_test where7-2.802.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=946
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR a=47
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR b=80
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ }
+} {8 23 42 47 60 62 78 86 93 scan 0 sort 0}
+do_test where7-2.802.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=946
+ OR (g='ihgfedc' AND f GLOB 'abcde*')
+ OR a=47
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR b=80
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ }
+} {8 23 42 47 60 62 78 86 93 scan 0 sort 0}
+do_test where7-2.803.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=48
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR b=1015
+ OR a=57
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR ((a BETWEEN 47 AND 49) AND a!=48)
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR b=165
+ }
+} {4 9 15 35 47 48 49 50 55 57 61 87 98 100 scan 0 sort 0}
+do_test where7-2.803.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=48
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR b=1015
+ OR a=57
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR ((a BETWEEN 47 AND 49) AND a!=48)
+ OR ((a BETWEEN 98 AND 100) AND a!=99)
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ OR (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR b=165
+ }
+} {4 9 15 35 47 48 49 50 55 57 61 87 98 100 scan 0 sort 0}
+do_test where7-2.804.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 97 AND 99) AND a!=98)
+ OR a=73
+ OR b=1048
+ OR c>=34035
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR a=72
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=638
+ }
+} {58 72 73 80 91 93 97 99 scan 0 sort 0}
+do_test where7-2.804.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 97 AND 99) AND a!=98)
+ OR a=73
+ OR b=1048
+ OR c>=34035
+ OR (g='ihgfedc' AND f GLOB 'cdefg*')
+ OR a=72
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=638
+ }
+} {58 72 73 80 91 93 97 99 scan 0 sort 0}
+do_test where7-2.805.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 28 AND 30) AND a!=29)
+ OR a=39
+ OR b=165
+ }
+} {15 28 30 39 scan 0 sort 0}
+do_test where7-2.805.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 28 AND 30) AND a!=29)
+ OR a=39
+ OR b=165
+ }
+} {15 28 30 39 scan 0 sort 0}
+do_test where7-2.806.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=50
+ OR ((a BETWEEN 61 AND 63) AND a!=62)
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR a=32
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR a=14
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR b=946
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR b=124
+ }
+} {14 17 32 43 45 50 53 55 61 63 69 86 93 95 97 scan 0 sort 0}
+do_test where7-2.806.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=50
+ OR ((a BETWEEN 61 AND 63) AND a!=62)
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR a=32
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR a=14
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR b=946
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR b=124
+ }
+} {14 17 32 43 45 50 53 55 61 63 69 86 93 95 97 scan 0 sort 0}
+do_test where7-2.807.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 88 AND 90) AND a!=89)
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ }
+} {52 66 88 90 scan 0 sort 0}
+do_test where7-2.807.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 88 AND 90) AND a!=89)
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ }
+} {52 66 88 90 scan 0 sort 0}
+do_test where7-2.808.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=6
+ OR f='tuvwxyzab'
+ OR (g='mlkjihg' AND f GLOB 'hijkl*')
+ OR b=286
+ OR b=781
+ }
+} {6 19 26 45 59 71 97 scan 0 sort 0}
+do_test where7-2.808.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=6
+ OR f='tuvwxyzab'
+ OR (g='mlkjihg' AND f GLOB 'hijkl*')
+ OR b=286
+ OR b=781
+ }
+} {6 19 26 45 59 71 97 scan 0 sort 0}
+do_test where7-2.809.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='jihgfed' AND f GLOB 'zabcd*')
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR f='vwxyzabcd'
+ OR b=275
+ }
+} {9 11 21 25 35 37 43 47 61 63 73 77 79 81 87 89 99 100 scan 0 sort 0}
+do_test where7-2.809.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='jihgfed' AND f GLOB 'zabcd*')
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR f='vwxyzabcd'
+ OR b=275
+ }
+} {9 11 21 25 35 37 43 47 61 63 73 77 79 81 87 89 99 100 scan 0 sort 0}
+do_test where7-2.810.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR a=59
+ }
+} {4 30 59 64 89 91 scan 0 sort 0}
+do_test where7-2.810.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)
+ OR (g='xwvutsr' AND f GLOB 'efghi*')
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'nopqr*')
+ OR a=59
+ }
+} {4 30 59 64 89 91 scan 0 sort 0}
+do_test where7-2.811.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR b=663
+ OR f='ghijklmno'
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR f='ghijklmno'
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR b=1081
+ }
+} {6 8 10 14 16 19 22 32 48 58 64 71 74 84 99 100 scan 0 sort 0}
+do_test where7-2.811.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR b=663
+ OR f='ghijklmno'
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR f='ghijklmno'
+ OR (d>=64.0 AND d<65.0 AND d NOT NULL)
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ OR b=1081
+ }
+} {6 8 10 14 16 19 22 32 48 58 64 71 74 84 99 100 scan 0 sort 0}
+do_test where7-2.812.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 30 AND 32) AND a!=31)
+ OR a=96
+ OR b=355
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR b=597
+ OR ((a BETWEEN 92 AND 94) AND a!=93)
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR (f GLOB '?lmno*' AND f GLOB 'klmn*')
+ OR b=168
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ }
+} {10 15 30 32 36 62 81 88 92 94 96 scan 0 sort 0}
+do_test where7-2.812.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 30 AND 32) AND a!=31)
+ OR a=96
+ OR b=355
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR b=597
+ OR ((a BETWEEN 92 AND 94) AND a!=93)
+ OR (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR (f GLOB '?lmno*' AND f GLOB 'klmn*')
+ OR b=168
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ }
+} {10 15 30 32 36 62 81 88 92 94 96 scan 0 sort 0}
+do_test where7-2.813.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR b=957
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR a=40
+ }
+} {9 40 47 58 60 87 89 scan 0 sort 0}
+do_test where7-2.813.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)
+ OR b=957
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR a=40
+ }
+} {9 40 47 58 60 87 89 scan 0 sort 0}
+do_test where7-2.814.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 12 AND 14) AND a!=13)
+ OR a=36
+ OR a=75
+ OR b=179
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ OR b=850
+ OR a=62
+ }
+} {12 14 18 36 43 62 65 75 scan 0 sort 0}
+do_test where7-2.814.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 12 AND 14) AND a!=13)
+ OR a=36
+ OR a=75
+ OR b=179
+ OR (d>=43.0 AND d<44.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'stuvw*')
+ OR (d>=65.0 AND d<66.0 AND d NOT NULL)
+ OR b=850
+ OR a=62
+ }
+} {12 14 18 36 43 62 65 75 scan 0 sort 0}
+do_test where7-2.815.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 21 AND 23) AND a!=22)
+ OR a=79
+ OR a=66
+ OR b=487
+ OR a=1
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR c=5005
+ OR a=47
+ OR c=5005
+ OR b=319
+ OR b=1037
+ }
+} {1 13 14 15 21 23 29 47 54 66 79 scan 0 sort 0}
+do_test where7-2.815.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 21 AND 23) AND a!=22)
+ OR a=79
+ OR a=66
+ OR b=487
+ OR a=1
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR c=5005
+ OR a=47
+ OR c=5005
+ OR b=319
+ OR b=1037
+ }
+} {1 13 14 15 21 23 29 47 54 66 79 scan 0 sort 0}
+do_test where7-2.816.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=176
+ OR b=297
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR f='ijklmnopq'
+ }
+} {8 16 25 27 34 60 86 scan 0 sort 0}
+do_test where7-2.816.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=176
+ OR b=297
+ OR (g='tsrqpon' AND f GLOB 'zabcd*')
+ OR f='ijklmnopq'
+ }
+} {8 16 25 27 34 60 86 scan 0 sort 0}
+do_test where7-2.817.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR b=319
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR a=21
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ }
+} {9 10 11 21 29 31 33 72 90 92 scan 0 sort 0}
+do_test where7-2.817.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ OR b=319
+ OR ((a BETWEEN 31 AND 33) AND a!=32)
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR a=21
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ }
+} {9 10 11 21 29 31 33 72 90 92 scan 0 sort 0}
+do_test where7-2.818.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR b=396
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR b=1012
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR b=784
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR b=979
+ OR c<=10
+ OR b=913
+ OR b=66
+ }
+} {6 9 22 35 36 60 61 72 83 87 89 92 scan 0 sort 0}
+do_test where7-2.818.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR b=396
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR b=1012
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR b=784
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR b=979
+ OR c<=10
+ OR b=913
+ OR b=66
+ }
+} {6 9 22 35 36 60 61 72 83 87 89 92 scan 0 sort 0}
+do_test where7-2.819.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=3
+ OR b=803
+ }
+} {3 73 scan 0 sort 0}
+do_test where7-2.819.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=3
+ OR b=803
+ }
+} {3 73 scan 0 sort 0}
+do_test where7-2.820.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 79 AND 81) AND a!=80)
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ }
+} {16 19 23 25 42 45 68 71 79 81 94 97 scan 0 sort 0}
+do_test where7-2.820.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 79 AND 81) AND a!=80)
+ OR (f GLOB '?rstu*' AND f GLOB 'qrst*')
+ OR ((a BETWEEN 23 AND 25) AND a!=24)
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ }
+} {16 19 23 25 42 45 68 71 79 81 94 97 scan 0 sort 0}
+do_test where7-2.821.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=1001
+ OR a=16
+ OR b=132
+ OR b=1012
+ OR f='xyzabcdef'
+ OR b=682
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ }
+} {1 2 3 12 16 23 49 52 62 75 92 scan 0 sort 0}
+do_test where7-2.821.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=1001
+ OR a=16
+ OR b=132
+ OR b=1012
+ OR f='xyzabcdef'
+ OR b=682
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ }
+} {1 2 3 12 16 23 49 52 62 75 92 scan 0 sort 0}
+do_test where7-2.822.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=96
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ }
+} {19 96 scan 0 sort 0}
+do_test where7-2.822.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=96
+ OR (d>=19.0 AND d<20.0 AND d NOT NULL)
+ }
+} {19 96 scan 0 sort 0}
+do_test where7-2.823.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=2
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR a=23
+ OR b=1092
+ OR c=19019
+ OR b=245
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR (f GLOB '?nopq*' AND f GLOB 'mnop*')
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR b=572
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ }
+} {2 11 12 22 23 24 38 52 55 56 57 64 68 70 90 97 99 scan 0 sort 0}
+do_test where7-2.823.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=2
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ OR a=23
+ OR b=1092
+ OR c=19019
+ OR b=245
+ OR ((a BETWEEN 97 AND 99) AND a!=98)
+ OR (f GLOB '?nopq*' AND f GLOB 'mnop*')
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR b=572
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ }
+} {2 11 12 22 23 24 38 52 55 56 57 64 68 70 90 97 99 scan 0 sort 0}
+do_test where7-2.824.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=993
+ OR c=17017
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR b=333
+ }
+} {16 29 37 49 50 51 53 85 scan 0 sort 0}
+do_test where7-2.824.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR b=993
+ OR c=17017
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR b=333
+ }
+} {16 29 37 49 50 51 53 85 scan 0 sort 0}
+do_test where7-2.825.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=330
+ OR a=73
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR b=828
+ OR b=363
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ }
+} {30 33 37 40 61 73 scan 0 sort 0}
+do_test where7-2.825.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=330
+ OR a=73
+ OR (d>=61.0 AND d<62.0 AND d NOT NULL)
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR b=828
+ OR b=363
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ }
+} {30 33 37 40 61 73 scan 0 sort 0}
+do_test where7-2.826.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='gfedcba' AND f GLOB 'lmnop*')
+ OR a=41
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR b=825
+ }
+} {29 41 75 89 scan 0 sort 0}
+do_test where7-2.826.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='gfedcba' AND f GLOB 'lmnop*')
+ OR a=41
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR b=825
+ }
+} {29 41 75 89 scan 0 sort 0}
+do_test where7-2.827.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 46 AND 48) AND a!=47)
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR b=905
+ OR b=176
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR b=561
+ OR c=8008
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR b=935
+ OR c=1001
+ }
+} {1 2 3 10 16 22 23 24 46 48 51 84 85 89 91 scan 0 sort 0}
+do_test where7-2.827.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 46 AND 48) AND a!=47)
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ OR b=905
+ OR b=176
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR b=561
+ OR c=8008
+ OR (g='hgfedcb' AND f GLOB 'ghijk*')
+ OR b=935
+ OR c=1001
+ }
+} {1 2 3 10 16 22 23 24 46 48 51 84 85 89 91 scan 0 sort 0}
+do_test where7-2.828.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 75 AND 77) AND a!=76)
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ }
+} {72 75 77 scan 0 sort 0}
+do_test where7-2.828.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 75 AND 77) AND a!=76)
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ }
+} {72 75 77 scan 0 sort 0}
+do_test where7-2.829.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 5 AND 7) AND a!=6)
+ OR a=28
+ }
+} {5 7 28 scan 0 sort 0}
+do_test where7-2.829.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 5 AND 7) AND a!=6)
+ OR a=28
+ }
+} {5 7 28 scan 0 sort 0}
+do_test where7-2.830.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=781
+ OR b=410
+ }
+} {71 scan 0 sort 0}
+do_test where7-2.830.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=781
+ OR b=410
+ }
+} {71 scan 0 sort 0}
+do_test where7-2.831.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 18 AND 20) AND a!=19)
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR f='zabcdefgh'
+ OR b=861
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR a=28
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR b=311
+ }
+} {6 15 18 20 25 28 32 40 42 51 56 58 63 72 77 84 scan 0 sort 0}
+do_test where7-2.831.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 18 AND 20) AND a!=19)
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR f='zabcdefgh'
+ OR b=861
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ OR a=28
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR b=311
+ }
+} {6 15 18 20 25 28 32 40 42 51 56 58 63 72 77 84 scan 0 sort 0}
+do_test where7-2.832.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=575
+ OR (f GLOB '?nopq*' AND f GLOB 'mnop*')
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR b=418
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR b=792
+ OR b=861
+ OR b=220
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ }
+} {12 15 20 38 41 64 67 72 73 89 90 91 93 scan 0 sort 0}
+do_test where7-2.832.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=575
+ OR (f GLOB '?nopq*' AND f GLOB 'mnop*')
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR b=418
+ OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')
+ OR b=792
+ OR b=861
+ OR b=220
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ }
+} {12 15 20 38 41 64 67 72 73 89 90 91 93 scan 0 sort 0}
+do_test where7-2.833.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=517
+ OR b=913
+ OR b=253
+ OR b=198
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR a=17
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ }
+} {17 18 23 27 47 83 85 scan 0 sort 0}
+do_test where7-2.833.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=517
+ OR b=913
+ OR b=253
+ OR b=198
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR a=17
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ }
+} {17 18 23 27 47 83 85 scan 0 sort 0}
+do_test where7-2.834.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='qponmlk' AND f GLOB 'qrstu*')
+ OR b=693
+ OR a=73
+ OR b=627
+ OR c=5005
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR b=267
+ OR b=872
+ OR a=27
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ }
+} {13 14 15 27 28 42 57 62 63 73 88 scan 0 sort 0}
+do_test where7-2.834.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='qponmlk' AND f GLOB 'qrstu*')
+ OR b=693
+ OR a=73
+ OR b=627
+ OR c=5005
+ OR (d>=62.0 AND d<63.0 AND d NOT NULL)
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR b=267
+ OR b=872
+ OR a=27
+ OR (g='gfedcba' AND f GLOB 'klmno*')
+ }
+} {13 14 15 27 28 42 57 62 63 73 88 scan 0 sort 0}
+do_test where7-2.835.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=10
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR ((a BETWEEN 13 AND 15) AND a!=14)
+ OR b=1059
+ OR a=70
+ OR a=93
+ }
+} {10 13 15 70 93 95 97 scan 0 sort 0}
+do_test where7-2.835.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=10
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR ((a BETWEEN 13 AND 15) AND a!=14)
+ OR b=1059
+ OR a=70
+ OR a=93
+ }
+} {10 13 15 70 93 95 97 scan 0 sort 0}
+do_test where7-2.836.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=30
+ OR a=32
+ OR b=1037
+ OR b=198
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR a=25
+ }
+} {13 18 25 30 32 scan 0 sort 0}
+do_test where7-2.836.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=30
+ OR a=32
+ OR b=1037
+ OR b=198
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR a=25
+ }
+} {13 18 25 30 32 scan 0 sort 0}
+do_test where7-2.837.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR b=66
+ OR b=322
+ OR b=465
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR (g='lkjihgf' AND f GLOB 'mnopq*')
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR b=454
+ }
+} {6 7 38 46 64 77 79 89 scan 0 sort 0}
+do_test where7-2.837.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR b=66
+ OR b=322
+ OR b=465
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR (d>=7.0 AND d<8.0 AND d NOT NULL)
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ OR (g='lkjihgf' AND f GLOB 'mnopq*')
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR b=454
+ }
+} {6 7 38 46 64 77 79 89 scan 0 sort 0}
+do_test where7-2.838.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=924
+ OR ((a BETWEEN 35 AND 37) AND a!=36)
+ OR c=15015
+ OR (d>=84.0 AND d<85.0 AND d NOT NULL)
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR b=803
+ }
+} {3 5 35 37 43 44 45 52 73 84 scan 0 sort 0}
+do_test where7-2.838.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=924
+ OR ((a BETWEEN 35 AND 37) AND a!=36)
+ OR c=15015
+ OR (d>=84.0 AND d<85.0 AND d NOT NULL)
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR b=803
+ }
+} {3 5 35 37 43 44 45 52 73 84 scan 0 sort 0}
+do_test where7-2.839.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1100
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR a=75
+ OR a=45
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR a=27
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR b=850
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ }
+} {12 27 45 55 57 68 70 72 74 75 77 90 100 scan 0 sort 0}
+do_test where7-2.839.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1100
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 72 AND 74) AND a!=73)
+ OR ((a BETWEEN 68 AND 70) AND a!=69)
+ OR a=75
+ OR a=45
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR a=27
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR b=850
+ OR ((a BETWEEN 55 AND 57) AND a!=56)
+ }
+} {12 27 45 55 57 68 70 72 74 75 77 90 100 scan 0 sort 0}
+do_test where7-2.840.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=751
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR a=89
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ }
+} {36 38 56 71 89 96 98 scan 0 sort 0}
+do_test where7-2.840.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=751
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR (d>=71.0 AND d<72.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR a=89
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ }
+} {36 38 56 71 89 96 98 scan 0 sort 0}
+do_test where7-2.841.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='wvutsrq' AND f GLOB 'jklmn*')
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR a=1
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ }
+} {1 9 19 scan 0 sort 0}
+do_test where7-2.841.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='wvutsrq' AND f GLOB 'jklmn*')
+ OR (g='yxwvuts' AND f GLOB 'bcdef*')
+ OR a=1
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ }
+} {1 9 19 scan 0 sort 0}
+do_test where7-2.842.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=927
+ OR c=15015
+ OR f='klmnopqrs'
+ OR c=8008
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR b=960
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR b=443
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ }
+} {10 22 23 24 34 36 41 43 44 45 62 76 88 scan 0 sort 0}
+do_test where7-2.842.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=927
+ OR c=15015
+ OR f='klmnopqrs'
+ OR c=8008
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR b=960
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR b=443
+ OR (g='rqponml' AND f GLOB 'ijklm*')
+ }
+} {10 22 23 24 34 36 41 43 44 45 62 76 88 scan 0 sort 0}
+do_test where7-2.843.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR b=212
+ OR f='cdefghijk'
+ }
+} {2 28 37 54 80 scan 0 sort 0}
+do_test where7-2.843.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR b=212
+ OR f='cdefghijk'
+ }
+} {2 28 37 54 80 scan 0 sort 0}
+do_test where7-2.844.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=685
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR b=520
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR a=53
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=938
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR c=25025
+ }
+} {43 53 63 73 74 75 76 91 93 scan 0 sort 0}
+do_test where7-2.844.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=685
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR b=520
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR a=53
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=938
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR c=25025
+ }
+} {43 53 63 73 74 75 76 91 93 scan 0 sort 0}
+do_test where7-2.845.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=583
+ OR b=894
+ OR c=26026
+ OR (d>=84.0 AND d<85.0 AND d NOT NULL)
+ }
+} {53 76 77 78 84 scan 0 sort 0}
+do_test where7-2.845.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=583
+ OR b=894
+ OR c=26026
+ OR (d>=84.0 AND d<85.0 AND d NOT NULL)
+ }
+} {53 76 77 78 84 scan 0 sort 0}
+do_test where7-2.846.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='abcdefghi'
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ }
+} {26 52 78 100 scan 0 sort 0}
+do_test where7-2.846.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='abcdefghi'
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ }
+} {26 52 78 100 scan 0 sort 0}
+do_test where7-2.847.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1103
+ OR b=638
+ OR b=792
+ OR b=1034
+ OR b=308
+ OR f='nopqrstuv'
+ OR b=264
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ }
+} {13 24 28 33 35 39 58 65 72 91 94 scan 0 sort 0}
+do_test where7-2.847.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1103
+ OR b=638
+ OR b=792
+ OR b=1034
+ OR b=308
+ OR f='nopqrstuv'
+ OR b=264
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR (d>=58.0 AND d<59.0 AND d NOT NULL)
+ }
+} {13 24 28 33 35 39 58 65 72 91 94 scan 0 sort 0}
+do_test where7-2.848.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='defghijkl'
+ OR b=814
+ OR f='yzabcdefg'
+ }
+} {3 24 29 50 55 74 76 81 scan 0 sort 0}
+do_test where7-2.848.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='defghijkl'
+ OR b=814
+ OR f='yzabcdefg'
+ }
+} {3 24 29 50 55 74 76 81 scan 0 sort 0}
+do_test where7-2.849.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=209
+ OR b=806
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ }
+} {8 17 19 scan 0 sort 0}
+do_test where7-2.849.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=209
+ OR b=806
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'rstuv*')
+ }
+} {8 17 19 scan 0 sort 0}
+do_test where7-2.850.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='opqrstuvw'
+ OR b=69
+ OR b=366
+ }
+} {14 40 66 92 scan 0 sort 0}
+do_test where7-2.850.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='opqrstuvw'
+ OR b=69
+ OR b=366
+ }
+} {14 40 66 92 scan 0 sort 0}
+do_test where7-2.851.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR a=45
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR a=69
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ }
+} {4 45 69 71 72 scan 0 sort 0}
+do_test where7-2.851.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR a=45
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR a=69
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ }
+} {4 45 69 71 72 scan 0 sort 0}
+do_test where7-2.852.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=9009
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ }
+} {9 10 25 26 27 67 85 scan 0 sort 0}
+do_test where7-2.852.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=9009
+ OR (d>=85.0 AND d<86.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR (d>=9.0 AND d<10.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'pqrst*')
+ }
+} {9 10 25 26 27 67 85 scan 0 sort 0}
+do_test where7-2.853.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=98
+ OR (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR a=47
+ OR c=24024
+ OR a=27
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ }
+} {20 27 45 47 63 70 71 72 98 100 scan 0 sort 0}
+do_test where7-2.853.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=98
+ OR (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR a=47
+ OR c=24024
+ OR a=27
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ }
+} {20 27 45 47 63 70 71 72 98 100 scan 0 sort 0}
+do_test where7-2.854.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR a=19
+ }
+} {19 22 44 scan 0 sort 0}
+do_test where7-2.854.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR a=19
+ }
+} {19 22 44 scan 0 sort 0}
+do_test where7-2.855.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=12012
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ }
+} {16 18 34 35 36 80 98 scan 0 sort 0}
+do_test where7-2.855.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=12012
+ OR (d>=80.0 AND d<81.0 AND d NOT NULL)
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ }
+} {16 18 34 35 36 80 98 scan 0 sort 0}
+do_test where7-2.856.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 38 AND 40) AND a!=39)
+ OR (f GLOB '?nopq*' AND f GLOB 'mnop*')
+ OR b=429
+ OR f='jklmnopqr'
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ }
+} {9 12 35 38 39 40 48 61 64 77 79 87 90 scan 0 sort 0}
+do_test where7-2.856.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 38 AND 40) AND a!=39)
+ OR (f GLOB '?nopq*' AND f GLOB 'mnop*')
+ OR b=429
+ OR f='jklmnopqr'
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR ((a BETWEEN 77 AND 79) AND a!=78)
+ }
+} {9 12 35 38 39 40 48 61 64 77 79 87 90 scan 0 sort 0}
+do_test where7-2.857.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='lkjihgf' AND f GLOB 'mnopq*')
+ OR b=190
+ }
+} {64 scan 0 sort 0}
+do_test where7-2.857.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='lkjihgf' AND f GLOB 'mnopq*')
+ OR b=190
+ }
+} {64 scan 0 sort 0}
+do_test where7-2.858.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='jihgfed' AND f GLOB 'yzabc*')
+ OR b=674
+ OR b=289
+ }
+} {76 scan 0 sort 0}
+do_test where7-2.858.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='jihgfed' AND f GLOB 'yzabc*')
+ OR b=674
+ OR b=289
+ }
+} {76 scan 0 sort 0}
+do_test where7-2.859.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=17
+ OR b=539
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ }
+} {17 21 47 49 scan 0 sort 0}
+do_test where7-2.859.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=17
+ OR b=539
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR (g='utsrqpo' AND f GLOB 'vwxyz*')
+ }
+} {17 21 47 49 scan 0 sort 0}
+do_test where7-2.860.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=924
+ OR c=27027
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ }
+} {65 67 79 80 81 84 scan 0 sort 0}
+do_test where7-2.860.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=924
+ OR c=27027
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ }
+} {65 67 79 80 81 84 scan 0 sort 0}
+do_test where7-2.861.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=564
+ OR f='mnopqrstu'
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR b=1103
+ }
+} {12 28 30 38 64 90 scan 0 sort 0}
+do_test where7-2.861.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=564
+ OR f='mnopqrstu'
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR b=1103
+ }
+} {12 28 30 38 64 90 scan 0 sort 0}
+do_test where7-2.862.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=231
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR a=38
+ OR a=4
+ OR b=784
+ }
+} {4 21 24 38 scan 0 sort 0}
+do_test where7-2.862.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=231
+ OR (d>=24.0 AND d<25.0 AND d NOT NULL)
+ OR a=38
+ OR a=4
+ OR b=784
+ }
+} {4 21 24 38 scan 0 sort 0}
+do_test where7-2.863.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='ghijklmno'
+ OR a=26
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR a=81
+ OR (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR b=275
+ OR (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR b=311
+ OR b=894
+ OR b=872
+ }
+} {3 6 25 26 28 30 32 58 68 81 84 87 scan 0 sort 0}
+do_test where7-2.863.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='ghijklmno'
+ OR a=26
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR a=81
+ OR (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR ((a BETWEEN 28 AND 30) AND a!=29)
+ OR b=275
+ OR (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR b=311
+ OR b=894
+ OR b=872
+ }
+} {3 6 25 26 28 30 32 58 68 81 84 87 scan 0 sort 0}
+do_test where7-2.864.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=91
+ OR b=619
+ }
+} {91 scan 0 sort 0}
+do_test where7-2.864.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=91
+ OR b=619
+ }
+} {91 scan 0 sort 0}
+do_test where7-2.865.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR a=85
+ OR f IS NULL
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=154
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ }
+} {4 14 25 40 42 49 51 66 68 85 87 89 scan 0 sort 0}
+do_test where7-2.865.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=4.0 AND d<5.0 AND d NOT NULL)
+ OR a=85
+ OR f IS NULL
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=154
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ }
+} {4 14 25 40 42 49 51 66 68 85 87 89 scan 0 sort 0}
+do_test where7-2.866.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=44
+ OR b=55
+ OR a=30
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR 1000000<b
+ OR a=24
+ OR b=1089
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ }
+} {5 19 24 30 33 44 45 71 75 97 99 scan 0 sort 0}
+do_test where7-2.866.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=44
+ OR b=55
+ OR a=30
+ OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR 1000000<b
+ OR a=24
+ OR b=1089
+ OR (d>=75.0 AND d<76.0 AND d NOT NULL)
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ }
+} {5 19 24 30 33 44 45 71 75 97 99 scan 0 sort 0}
+do_test where7-2.867.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR b=36
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ }
+} {16 33 35 80 82 scan 0 sort 0}
+do_test where7-2.867.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=16.0 AND d<17.0 AND d NOT NULL)
+ OR ((a BETWEEN 80 AND 82) AND a!=81)
+ OR b=36
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ }
+} {16 33 35 80 82 scan 0 sort 0}
+do_test where7-2.868.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR (d>=35.0 AND d<36.0 AND d NOT NULL)
+ OR c=26026
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR a=56
+ OR b=506
+ OR b=781
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ }
+} {28 35 37 39 46 56 71 76 77 78 97 scan 0 sort 0}
+do_test where7-2.868.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR (d>=35.0 AND d<36.0 AND d NOT NULL)
+ OR c=26026
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR a=56
+ OR b=506
+ OR b=781
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ }
+} {28 35 37 39 46 56 71 76 77 78 97 scan 0 sort 0}
+do_test where7-2.869.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR f='xyzabcdef'
+ OR b=517
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ }
+} {23 25 27 39 47 49 68 75 76 89 91 98 scan 0 sort 0}
+do_test where7-2.869.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 25 AND 27) AND a!=26)
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR ((a BETWEEN 89 AND 91) AND a!=90)
+ OR f='xyzabcdef'
+ OR b=517
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ }
+} {23 25 27 39 47 49 68 75 76 89 91 98 scan 0 sort 0}
+do_test where7-2.870.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=54
+ OR a=59
+ }
+} {54 59 scan 0 sort 0}
+do_test where7-2.870.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=54
+ OR a=59
+ }
+} {54 59 scan 0 sort 0}
+do_test where7-2.871.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='tsrqpon' AND f GLOB 'yzabc*')
+ OR b=762
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR a=25
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ }
+} {24 25 48 65 67 scan 0 sort 0}
+do_test where7-2.871.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='tsrqpon' AND f GLOB 'yzabc*')
+ OR b=762
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR a=25
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ }
+} {24 25 48 65 67 scan 0 sort 0}
+do_test where7-2.872.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=59.0 AND d<60.0 AND d NOT NULL)
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR b=839
+ OR f='defghijkl'
+ OR (d>=95.0 AND d<96.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR b=498
+ }
+} {3 14 16 29 52 55 59 60 81 85 95 scan 0 sort 0}
+do_test where7-2.872.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=59.0 AND d<60.0 AND d NOT NULL)
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR b=839
+ OR f='defghijkl'
+ OR (d>=95.0 AND d<96.0 AND d NOT NULL)
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR b=498
+ }
+} {3 14 16 29 52 55 59 60 81 85 95 scan 0 sort 0}
+do_test where7-2.873.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=256
+ OR c=19019
+ OR a=54
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR b=498
+ OR b=77
+ }
+} {7 46 54 55 56 57 scan 0 sort 0}
+do_test where7-2.873.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=256
+ OR c=19019
+ OR a=54
+ OR (d>=46.0 AND d<47.0 AND d NOT NULL)
+ OR b=498
+ OR b=77
+ }
+} {7 46 54 55 56 57 scan 0 sort 0}
+do_test where7-2.874.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=256
+ OR b=586
+ OR a=74
+ OR b=113
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR b=495
+ }
+} {45 61 74 99 scan 0 sort 0}
+do_test where7-2.874.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='mlkjihg' AND f GLOB 'jklmn*')
+ OR b=256
+ OR b=586
+ OR a=74
+ OR b=113
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR b=495
+ }
+} {45 61 74 99 scan 0 sort 0}
+do_test where7-2.875.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=12
+ OR a=50
+ OR (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ }
+} {12 33 50 66 68 scan 0 sort 0}
+do_test where7-2.875.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=12
+ OR a=50
+ OR (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ }
+} {12 33 50 66 68 scan 0 sort 0}
+do_test where7-2.876.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=308
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR a=83
+ OR c=23023
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR a=58
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR c=4004
+ }
+} {10 11 12 17 19 28 30 53 57 58 65 67 68 69 73 83 scan 0 sort 0}
+do_test where7-2.876.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=308
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR a=83
+ OR c=23023
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR (g='lkjihgf' AND f GLOB 'nopqr*')
+ OR a=58
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR c=4004
+ }
+} {10 11 12 17 19 28 30 53 57 58 65 67 68 69 73 83 scan 0 sort 0}
+do_test where7-2.877.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=476
+ OR a=26
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR b=762
+ OR b=157
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ }
+} {17 26 54 87 scan 0 sort 0}
+do_test where7-2.877.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=476
+ OR a=26
+ OR (d>=87.0 AND d<88.0 AND d NOT NULL)
+ OR b=762
+ OR b=157
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ }
+} {17 26 54 87 scan 0 sort 0}
+do_test where7-2.878.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR a=1
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR b=278
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR f='qrstuvwxy'
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR ((a BETWEEN 82 AND 84) AND a!=83)
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ }
+} {1 3 16 42 52 68 72 74 77 82 84 93 94 95 98 scan 0 sort 0}
+do_test where7-2.878.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR a=1
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR b=278
+ OR (g='xwvutsr' AND f GLOB 'defgh*')
+ OR f='qrstuvwxy'
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR ((a BETWEEN 82 AND 84) AND a!=83)
+ OR (g='edcbazy' AND f GLOB 'uvwxy*')
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ }
+} {1 3 16 42 52 68 72 74 77 82 84 93 94 95 98 scan 0 sort 0}
+do_test where7-2.879.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=124
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR b=759
+ OR (f GLOB '?nopq*' AND f GLOB 'mnop*')
+ OR ((a BETWEEN 45 AND 47) AND a!=46)
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ }
+} {12 38 41 43 45 47 64 69 72 90 92 96 scan 0 sort 0}
+do_test where7-2.879.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=124
+ OR (d>=92.0 AND d<93.0 AND d NOT NULL)
+ OR ((a BETWEEN 41 AND 43) AND a!=42)
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR b=759
+ OR (f GLOB '?nopq*' AND f GLOB 'mnop*')
+ OR ((a BETWEEN 45 AND 47) AND a!=46)
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ }
+} {12 38 41 43 45 47 64 69 72 90 92 96 scan 0 sort 0}
+do_test where7-2.880.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=872
+ OR b=267
+ OR b=814
+ OR b=99
+ OR c<=10
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR b=44
+ OR f='zabcdefgh'
+ OR b=979
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ }
+} {4 8 9 10 25 33 51 74 77 89 scan 0 sort 0}
+do_test where7-2.880.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=872
+ OR b=267
+ OR b=814
+ OR b=99
+ OR c<=10
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR b=44
+ OR f='zabcdefgh'
+ OR b=979
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ }
+} {4 8 9 10 25 33 51 74 77 89 scan 0 sort 0}
+do_test where7-2.881.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR f='xyzabcdef'
+ }
+} {23 26 49 75 scan 0 sort 0}
+do_test where7-2.881.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR f='xyzabcdef'
+ }
+} {23 26 49 75 scan 0 sort 0}
+do_test where7-2.882.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=487
+ OR b=355
+ OR c=9009
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=113
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR a=90
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR f='nopqrstuv'
+ }
+} {8 13 24 25 26 27 32 34 39 65 66 87 90 91 scan 0 sort 0}
+do_test where7-2.882.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=487
+ OR b=355
+ OR c=9009
+ OR (d>=8.0 AND d<9.0 AND d NOT NULL)
+ OR ((a BETWEEN 32 AND 34) AND a!=33)
+ OR b=113
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR a=90
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR (g='hgfedcb' AND f GLOB 'jklmn*')
+ OR f='nopqrstuv'
+ }
+} {8 13 24 25 26 27 32 34 39 65 66 87 90 91 scan 0 sort 0}
+do_test where7-2.883.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR b=275
+ }
+} {25 34 scan 0 sort 0}
+do_test where7-2.883.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR b=275
+ }
+} {25 34 scan 0 sort 0}
+do_test where7-2.884.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=355
+ OR a=44
+ OR b=374
+ OR c=25025
+ OR b=198
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR d<0.0
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR c=9009
+ }
+} {4 6 18 25 26 27 34 41 44 69 71 73 74 75 scan 0 sort 0}
+do_test where7-2.884.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=355
+ OR a=44
+ OR b=374
+ OR c=25025
+ OR b=198
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR d<0.0
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR c=9009
+ }
+} {4 6 18 25 26 27 34 41 44 69 71 73 74 75 scan 0 sort 0}
+do_test where7-2.885.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR b=814
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ }
+} {19 45 54 71 74 97 scan 0 sort 0}
+do_test where7-2.885.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')
+ OR b=814
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ }
+} {19 45 54 71 74 97 scan 0 sort 0}
+do_test where7-2.886.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='lkjihgf' AND f GLOB 'mnopq*')
+ OR b=333
+ OR b=275
+ }
+} {25 64 scan 0 sort 0}
+do_test where7-2.886.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='lkjihgf' AND f GLOB 'mnopq*')
+ OR b=333
+ OR b=275
+ }
+} {25 64 scan 0 sort 0}
+do_test where7-2.887.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='ihgfedc' AND f GLOB 'efghi*')
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ }
+} {33 35 82 scan 0 sort 0}
+do_test where7-2.887.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='ihgfedc' AND f GLOB 'efghi*')
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ }
+} {33 35 82 scan 0 sort 0}
+do_test where7-2.888.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 11 AND 13) AND a!=12)
+ OR b=253
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR b=286
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ }
+} {10 11 13 14 23 26 40 66 92 scan 0 sort 0}
+do_test where7-2.888.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 11 AND 13) AND a!=12)
+ OR b=253
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR b=286
+ OR (d>=10.0 AND d<11.0 AND d NOT NULL)
+ }
+} {10 11 13 14 23 26 40 66 92 scan 0 sort 0}
+do_test where7-2.889.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 26 AND 28) AND a!=27)
+ OR b=421
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR f='ijklmnopq'
+ OR b=891
+ OR b=1056
+ }
+} {5 8 15 26 28 34 60 81 86 90 96 scan 0 sort 0}
+do_test where7-2.889.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 26 AND 28) AND a!=27)
+ OR b=421
+ OR (g='xwvutsr' AND f GLOB 'fghij*')
+ OR f='ijklmnopq'
+ OR b=891
+ OR b=1056
+ }
+} {5 8 15 26 28 34 60 81 86 90 96 scan 0 sort 0}
+do_test where7-2.890.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='fghijklmn'
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR b=671
+ OR (g='xwvutsr' AND f GLOB 'hijkl*')
+ }
+} {5 7 31 39 57 61 83 99 scan 0 sort 0}
+do_test where7-2.890.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='fghijklmn'
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR (g='edcbazy' AND f GLOB 'vwxyz*')
+ OR b=671
+ OR (g='xwvutsr' AND f GLOB 'hijkl*')
+ }
+} {5 7 31 39 57 61 83 99 scan 0 sort 0}
+do_test where7-2.891.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='lkjihgf' AND f GLOB 'lmnop*')
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ }
+} {4 6 11 31 63 68 scan 0 sort 0}
+do_test where7-2.891.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='lkjihgf' AND f GLOB 'lmnop*')
+ OR (g='srqponm' AND f GLOB 'fghij*')
+ OR ((a BETWEEN 4 AND 6) AND a!=5)
+ OR (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR (d>=11.0 AND d<12.0 AND d NOT NULL)
+ }
+} {4 6 11 31 63 68 scan 0 sort 0}
+do_test where7-2.892.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=11011
+ OR a=20
+ OR b=432
+ OR b=410
+ OR a=86
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR b=638
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR b=190
+ }
+} {20 31 32 33 58 60 86 89 scan 0 sort 0}
+do_test where7-2.892.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=11011
+ OR a=20
+ OR b=432
+ OR b=410
+ OR a=86
+ OR (d>=89.0 AND d<90.0 AND d NOT NULL)
+ OR b=638
+ OR ((a BETWEEN 58 AND 60) AND a!=59)
+ OR b=190
+ }
+} {20 31 32 33 58 60 86 89 scan 0 sort 0}
+do_test where7-2.893.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=88
+ OR ((a BETWEEN 42 AND 44) AND a!=43)
+ OR a=76
+ OR b=69
+ OR b=847
+ OR b=275
+ }
+} {8 25 42 44 76 77 scan 0 sort 0}
+do_test where7-2.893.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=88
+ OR ((a BETWEEN 42 AND 44) AND a!=43)
+ OR a=76
+ OR b=69
+ OR b=847
+ OR b=275
+ }
+} {8 25 42 44 76 77 scan 0 sort 0}
+do_test where7-2.894.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=781
+ OR b=77
+ OR b=58
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ }
+} {7 67 69 71 scan 0 sort 0}
+do_test where7-2.894.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=781
+ OR b=77
+ OR b=58
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ }
+} {7 67 69 71 scan 0 sort 0}
+do_test where7-2.895.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 67 AND 69) AND a!=68)
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR a=46
+ OR b=187
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ }
+} {17 20 46 50 67 69 71 scan 0 sort 0}
+do_test where7-2.895.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 67 AND 69) AND a!=68)
+ OR (d>=69.0 AND d<70.0 AND d NOT NULL)
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR a=46
+ OR b=187
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ }
+} {17 20 46 50 67 69 71 scan 0 sort 0}
+do_test where7-2.896.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR a=99
+ OR c=3003
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR b=300
+ OR b=718
+ OR c>=34035
+ OR b=264
+ }
+} {7 8 9 24 57 97 99 scan 0 sort 0}
+do_test where7-2.896.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR a=99
+ OR c=3003
+ OR (d>=57.0 AND d<58.0 AND d NOT NULL)
+ OR b=300
+ OR b=718
+ OR c>=34035
+ OR b=264
+ }
+} {7 8 9 24 57 97 99 scan 0 sort 0}
+do_test where7-2.897.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=872
+ OR b=209
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ OR b=355
+ OR b=729
+ OR ((a BETWEEN 81 AND 83) AND a!=82)
+ OR a=58
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR b=608
+ }
+} {14 19 40 58 65 66 67 81 83 92 scan 0 sort 0}
+do_test where7-2.897.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=872
+ OR b=209
+ OR ((a BETWEEN 65 AND 67) AND a!=66)
+ OR b=355
+ OR b=729
+ OR ((a BETWEEN 81 AND 83) AND a!=82)
+ OR a=58
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR b=608
+ }
+} {14 19 40 58 65 66 67 81 83 92 scan 0 sort 0}
+do_test where7-2.898.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=29029
+ OR f='efghijklm'
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR a=26
+ OR (f GLOB '?efgh*' AND f GLOB 'defg*')
+ }
+} {3 4 26 29 30 48 55 56 81 82 85 86 87 scan 0 sort 0}
+do_test where7-2.898.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=29029
+ OR f='efghijklm'
+ OR (d>=48.0 AND d<49.0 AND d NOT NULL)
+ OR a=26
+ OR (f GLOB '?efgh*' AND f GLOB 'defg*')
+ }
+} {3 4 26 29 30 48 55 56 81 82 85 86 87 scan 0 sort 0}
+do_test where7-2.899.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=59
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR a=7
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR b=762
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ }
+} {7 12 14 26 40 59 66 92 scan 0 sort 0}
+do_test where7-2.899.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=59
+ OR (g='wvutsrq' AND f GLOB 'mnopq*')
+ OR a=7
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR b=762
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ }
+} {7 12 14 26 40 59 66 92 scan 0 sort 0}
+do_test where7-2.900.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='gfedcba' AND f GLOB 'nopqr*')
+ OR b=539
+ OR b=399
+ }
+} {49 91 scan 0 sort 0}
+do_test where7-2.900.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='gfedcba' AND f GLOB 'nopqr*')
+ OR b=539
+ OR b=399
+ }
+} {49 91 scan 0 sort 0}
+do_test where7-2.901.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR a=92
+ }
+} {71 73 92 96 98 scan 0 sort 0}
+do_test where7-2.901.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 71 AND 73) AND a!=72)
+ OR ((a BETWEEN 96 AND 98) AND a!=97)
+ OR a=92
+ }
+} {71 73 92 96 98 scan 0 sort 0}
+do_test where7-2.902.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR f='lmnopqrst'
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ }
+} {9 11 35 36 37 57 61 63 87 89 scan 0 sort 0}
+do_test where7-2.902.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR (g='rqponml' AND f GLOB 'klmno*')
+ OR f='lmnopqrst'
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ }
+} {9 11 35 36 37 57 61 63 87 89 scan 0 sort 0}
+do_test where7-2.903.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 69 AND 71) AND a!=70)
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=652
+ }
+} {69 71 91 93 scan 0 sort 0}
+do_test where7-2.903.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 69 AND 71) AND a!=70)
+ OR ((a BETWEEN 91 AND 93) AND a!=92)
+ OR b=652
+ }
+} {69 71 91 93 scan 0 sort 0}
+do_test where7-2.904.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1067
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR b=520
+ OR b=399
+ OR b=209
+ OR a=68
+ OR (g='fedcbaz' AND f GLOB 'qrstu*')
+ }
+} {18 19 53 54 55 68 73 94 97 scan 0 sort 0}
+do_test where7-2.904.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1067
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR b=520
+ OR b=399
+ OR b=209
+ OR a=68
+ OR (g='fedcbaz' AND f GLOB 'qrstu*')
+ }
+} {18 19 53 54 55 68 73 94 97 scan 0 sort 0}
+do_test where7-2.905.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR a=57
+ OR b=55
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR ((a BETWEEN 0 AND 2) AND a!=1)
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ }
+} {2 5 20 21 22 23 34 37 57 79 scan 0 sort 0}
+do_test where7-2.905.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR a=57
+ OR b=55
+ OR (d>=34.0 AND d<35.0 AND d NOT NULL)
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR ((a BETWEEN 0 AND 2) AND a!=1)
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ }
+} {2 5 20 21 22 23 34 37 57 79 scan 0 sort 0}
+do_test where7-2.906.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 21 AND 23) AND a!=22)
+ OR a=2
+ OR b=784
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR b=850
+ }
+} {2 21 23 81 scan 0 sort 0}
+do_test where7-2.906.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 21 AND 23) AND a!=22)
+ OR a=2
+ OR b=784
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (g='ihgfedc' AND f GLOB 'defgh*')
+ OR b=850
+ }
+} {2 21 23 81 scan 0 sort 0}
+do_test where7-2.907.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=748
+ OR b=209
+ OR a=100
+ }
+} {19 45 51 68 100 scan 0 sort 0}
+do_test where7-2.907.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=51.0 AND d<52.0 AND d NOT NULL)
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=748
+ OR b=209
+ OR a=100
+ }
+} {19 45 51 68 100 scan 0 sort 0}
+do_test where7-2.908.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='jihgfed' AND f GLOB 'zabcd*')
+ OR a=18
+ OR a=30
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR ((a BETWEEN 84 AND 86) AND a!=85)
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR b=792
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR c=26026
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ }
+} {8 9 10 11 18 19 21 30 33 37 63 72 76 77 78 84 86 89 scan 0 sort 0}
+do_test where7-2.908.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='jihgfed' AND f GLOB 'zabcd*')
+ OR a=18
+ OR a=30
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ OR ((a BETWEEN 84 AND 86) AND a!=85)
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR b=792
+ OR (f GLOB '?mnop*' AND f GLOB 'lmno*')
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR c=26026
+ OR (g='rqponml' AND f GLOB 'hijkl*')
+ }
+} {8 9 10 11 18 19 21 30 33 37 63 72 76 77 78 84 86 89 scan 0 sort 0}
+do_test where7-2.909.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR b=968
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR a=78
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ }
+} {16 22 48 63 65 72 74 78 88 90 92 100 scan 0 sort 0}
+do_test where7-2.909.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR b=968
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR (d>=72.0 AND d<73.0 AND d NOT NULL)
+ OR a=78
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ }
+} {16 22 48 63 65 72 74 78 88 90 92 100 scan 0 sort 0}
+do_test where7-2.910.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=10010
+ OR f='pqrstuvwx'
+ }
+} {15 28 29 30 41 67 93 scan 0 sort 0}
+do_test where7-2.910.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=10010
+ OR f='pqrstuvwx'
+ }
+} {15 28 29 30 41 67 93 scan 0 sort 0}
+do_test where7-2.911.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=86
+ OR a=10
+ OR b=528
+ OR b=253
+ OR a=80
+ OR a=87
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ }
+} {10 23 37 48 80 86 87 scan 0 sort 0}
+do_test where7-2.911.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=86
+ OR a=10
+ OR b=528
+ OR b=253
+ OR a=80
+ OR a=87
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ }
+} {10 23 37 48 80 86 87 scan 0 sort 0}
+do_test where7-2.912.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR b=825
+ OR a=100
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR a=60
+ }
+} {42 60 75 77 100 scan 0 sort 0}
+do_test where7-2.912.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR b=825
+ OR a=100
+ OR (d>=77.0 AND d<78.0 AND d NOT NULL)
+ OR a=60
+ }
+} {42 60 75 77 100 scan 0 sort 0}
+do_test where7-2.913.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR b=883
+ OR (d>=35.0 AND d<36.0 AND d NOT NULL)
+ OR (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR a=81
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR f='mnopqrstu'
+ }
+} {3 4 12 30 35 38 45 56 64 78 81 82 90 94 scan 0 sort 0}
+do_test where7-2.913.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=94.0 AND d<95.0 AND d NOT NULL)
+ OR b=883
+ OR (d>=35.0 AND d<36.0 AND d NOT NULL)
+ OR (d>=3.0 AND d<4.0 AND d NOT NULL)
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR a=81
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR f='mnopqrstu'
+ }
+} {3 4 12 30 35 38 45 56 64 78 81 82 90 94 scan 0 sort 0}
+do_test where7-2.914.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=443
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR b=663
+ OR b=905
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR b=883
+ OR c=22022
+ OR b=638
+ }
+} {14 16 58 64 65 66 96 scan 0 sort 0}
+do_test where7-2.914.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=443
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ OR b=663
+ OR b=905
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR b=883
+ OR c=22022
+ OR b=638
+ }
+} {14 16 58 64 65 66 96 scan 0 sort 0}
+do_test where7-2.915.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 84 AND 86) AND a!=85)
+ OR b=234
+ OR a=53
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR ((a BETWEEN 27 AND 29) AND a!=28)
+ OR b=319
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {14 16 20 22 27 29 40 53 84 86 scan 0 sort 0}
+do_test where7-2.915.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 84 AND 86) AND a!=85)
+ OR b=234
+ OR a=53
+ OR ((a BETWEEN 20 AND 22) AND a!=21)
+ OR ((a BETWEEN 27 AND 29) AND a!=28)
+ OR b=319
+ OR (g='qponmlk' AND f GLOB 'opqrs*')
+ OR ((a BETWEEN 14 AND 16) AND a!=15)
+ }
+} {14 16 20 22 27 29 40 53 84 86 scan 0 sort 0}
+do_test where7-2.916.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=179
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR a=46
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR a=25
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR f='opqrstuvw'
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR b=938
+ }
+} {5 13 14 25 40 46 53 55 66 72 92 95 97 scan 0 sort 0}
+do_test where7-2.916.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=179
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR a=46
+ OR (g='kjihgfe' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 53 AND 55) AND a!=54)
+ OR a=25
+ OR (d>=5.0 AND d<6.0 AND d NOT NULL)
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR f='opqrstuvw'
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR b=938
+ }
+} {5 13 14 25 40 46 53 55 66 72 92 95 97 scan 0 sort 0}
+do_test where7-2.917.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='nmlkjih' AND f GLOB 'fghij*')
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ }
+} {15 57 scan 0 sort 0}
+do_test where7-2.917.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='nmlkjih' AND f GLOB 'fghij*')
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ }
+} {15 57 scan 0 sort 0}
+do_test where7-2.918.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=748
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR a=32
+ OR b=110
+ OR b=297
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR f='ghijklmno'
+ OR b=473
+ OR b=135
+ }
+} {6 10 13 22 27 32 43 58 60 62 68 84 scan 0 sort 0}
+do_test where7-2.918.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=748
+ OR (g='utsrqpo' AND f GLOB 'wxyza*')
+ OR a=32
+ OR b=110
+ OR b=297
+ OR (d>=13.0 AND d<14.0 AND d NOT NULL)
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR f='ghijklmno'
+ OR b=473
+ OR b=135
+ }
+} {6 10 13 22 27 32 43 58 60 62 68 84 scan 0 sort 0}
+do_test where7-2.919.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR b=905
+ OR a=97
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR c=27027
+ OR f='bcdefghij'
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ }
+} {1 4 25 27 30 33 38 40 53 54 56 79 80 81 82 85 97 scan 0 sort 0}
+do_test where7-2.919.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)
+ OR b=905
+ OR a=97
+ OR (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR c=27027
+ OR f='bcdefghij'
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR (d>=25.0 AND d<26.0 AND d NOT NULL)
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ }
+} {1 4 25 27 30 33 38 40 53 54 56 79 80 81 82 85 97 scan 0 sort 0}
+do_test where7-2.920.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 64 AND 66) AND a!=65)
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ }
+} {64 66 90 92 scan 0 sort 0}
+do_test where7-2.920.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 64 AND 66) AND a!=65)
+ OR ((a BETWEEN 90 AND 92) AND a!=91)
+ }
+} {64 66 90 92 scan 0 sort 0}
+do_test where7-2.921.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=594
+ OR b=80
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR b=421
+ OR b=418
+ OR b=828
+ OR a=88
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ }
+} {23 27 38 54 60 88 scan 0 sort 0}
+do_test where7-2.921.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=594
+ OR b=80
+ OR (g='tsrqpon' AND f GLOB 'bcdef*')
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR b=421
+ OR b=418
+ OR b=828
+ OR a=88
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ }
+} {23 27 38 54 60 88 scan 0 sort 0}
+do_test where7-2.922.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ OR b=366
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR c=16016
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR c=9009
+ }
+} {17 25 26 27 28 46 47 48 75 100 scan 0 sort 0}
+do_test where7-2.922.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'xyzab*')
+ OR b=366
+ OR (d>=28.0 AND d<29.0 AND d NOT NULL)
+ OR c=16016
+ OR (g='edcbazy' AND f GLOB 'wxyza*')
+ OR c=9009
+ }
+} {17 25 26 27 28 46 47 48 75 100 scan 0 sort 0}
+do_test where7-2.923.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=33
+ OR f='qrstuvwxy'
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR b=858
+ }
+} {3 16 20 42 68 78 94 scan 0 sort 0}
+do_test where7-2.923.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=33
+ OR f='qrstuvwxy'
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR b=858
+ }
+} {3 16 20 42 68 78 94 scan 0 sort 0}
+do_test where7-2.924.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=861
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR b=682
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR b=286
+ }
+} {22 26 29 48 62 74 93 95 100 scan 0 sort 0}
+do_test where7-2.924.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=861
+ OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')
+ OR (d>=29.0 AND d<30.0 AND d NOT NULL)
+ OR b=682
+ OR ((a BETWEEN 93 AND 95) AND a!=94)
+ OR b=286
+ }
+} {22 26 29 48 62 74 93 95 100 scan 0 sort 0}
+do_test where7-2.925.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=740
+ OR ((a BETWEEN 27 AND 29) AND a!=28)
+ OR a=88
+ }
+} {27 29 88 scan 0 sort 0}
+do_test where7-2.925.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=740
+ OR ((a BETWEEN 27 AND 29) AND a!=28)
+ OR a=88
+ }
+} {27 29 88 scan 0 sort 0}
+do_test where7-2.926.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='abcdefghi'
+ OR c=9009
+ OR b=663
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR b=91
+ }
+} {10 25 26 27 52 78 scan 0 sort 0}
+do_test where7-2.926.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='abcdefghi'
+ OR c=9009
+ OR b=663
+ OR (g='wvutsrq' AND f GLOB 'klmno*')
+ OR b=91
+ }
+} {10 25 26 27 52 78 scan 0 sort 0}
+do_test where7-2.927.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR ((a BETWEEN 29 AND 31) AND a!=30)
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR b=1015
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR b=916
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR b=69
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ }
+} {13 29 31 39 42 65 68 83 91 scan 0 sort 0}
+do_test where7-2.927.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='kjihgfe' AND f GLOB 'qrstu*')
+ OR ((a BETWEEN 29 AND 31) AND a!=30)
+ OR (f GLOB '?opqr*' AND f GLOB 'nopq*')
+ OR b=1015
+ OR (g='qponmlk' AND f GLOB 'qrstu*')
+ OR b=916
+ OR (d>=31.0 AND d<32.0 AND d NOT NULL)
+ OR b=69
+ OR (g='hgfedcb' AND f GLOB 'fghij*')
+ }
+} {13 29 31 39 42 65 68 83 91 scan 0 sort 0}
+do_test where7-2.928.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=88
+ OR a=1
+ OR f='uvwxyzabc'
+ OR b=498
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR a=63
+ OR f='mnopqrstu'
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR b=495
+ OR a=35
+ OR a=22
+ }
+} {1 12 20 22 35 38 45 46 60 63 64 72 88 90 98 scan 0 sort 0}
+do_test where7-2.928.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=88
+ OR a=1
+ OR f='uvwxyzabc'
+ OR b=498
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR a=63
+ OR f='mnopqrstu'
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR b=495
+ OR a=35
+ OR a=22
+ }
+} {1 12 20 22 35 38 45 46 60 63 64 72 88 90 98 scan 0 sort 0}
+do_test where7-2.929.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=869
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR b=289
+ OR a=62
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ }
+} {9 11 35 62 79 scan 0 sort 0}
+do_test where7-2.929.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=869
+ OR (g='rqponml' AND f GLOB 'jklmn*')
+ OR b=289
+ OR a=62
+ OR ((a BETWEEN 9 AND 11) AND a!=10)
+ }
+} {9 11 35 62 79 scan 0 sort 0}
+do_test where7-2.930.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 22 AND 24) AND a!=23)
+ OR b=542
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR a=7
+ OR f='klmnopqrs'
+ }
+} {7 10 19 21 22 24 36 62 88 scan 0 sort 0}
+do_test where7-2.930.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 22 AND 24) AND a!=23)
+ OR b=542
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR a=7
+ OR f='klmnopqrs'
+ }
+} {7 10 19 21 22 24 36 62 88 scan 0 sort 0}
+do_test where7-2.931.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 57 AND 59) AND a!=58)
+ OR b=1078
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR b=429
+ }
+} {20 21 23 39 57 59 60 98 scan 0 sort 0}
+do_test where7-2.931.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 57 AND 59) AND a!=58)
+ OR b=1078
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (g='mlkjihg' AND f GLOB 'ijklm*')
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR b=429
+ }
+} {20 21 23 39 57 59 60 98 scan 0 sort 0}
+do_test where7-2.932.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR b=264
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR b=1048
+ OR a=15
+ }
+} {15 24 82 85 87 scan 0 sort 0}
+do_test where7-2.932.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR b=264
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR b=1048
+ OR a=15
+ }
+} {15 24 82 85 87 scan 0 sort 0}
+do_test where7-2.933.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=93
+ OR f='ijklmnopq'
+ OR f='mnopqrstu'
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ }
+} {8 12 34 38 60 64 67 69 86 90 93 scan 0 sort 0}
+do_test where7-2.933.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=93
+ OR f='ijklmnopq'
+ OR f='mnopqrstu'
+ OR ((a BETWEEN 67 AND 69) AND a!=68)
+ }
+} {8 12 34 38 60 64 67 69 86 90 93 scan 0 sort 0}
+do_test where7-2.934.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR b=858
+ OR a=58
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ OR c=21021
+ OR ((a BETWEEN 45 AND 47) AND a!=46)
+ OR b=616
+ OR b=784
+ OR b=55
+ }
+} {5 45 47 49 56 58 61 62 63 78 scan 0 sort 0}
+do_test where7-2.934.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR b=858
+ OR a=58
+ OR (g='onmlkji' AND f GLOB 'xyzab*')
+ OR c=21021
+ OR ((a BETWEEN 45 AND 47) AND a!=46)
+ OR b=616
+ OR b=784
+ OR b=55
+ }
+} {5 45 47 49 56 58 61 62 63 78 scan 0 sort 0}
+do_test where7-2.935.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=682
+ OR b=99
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR b=531
+ }
+} {2 9 28 54 62 80 scan 0 sort 0}
+do_test where7-2.935.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=682
+ OR b=99
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR b=531
+ }
+} {2 9 28 54 62 80 scan 0 sort 0}
+do_test where7-2.936.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR b=726
+ OR a=79
+ OR a=47
+ OR b=212
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR c=8008
+ }
+} {8 22 23 24 26 34 47 52 56 58 60 66 70 78 79 86 scan 0 sort 0}
+do_test where7-2.936.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')
+ OR b=726
+ OR a=79
+ OR a=47
+ OR b=212
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ OR c=8008
+ }
+} {8 22 23 24 26 34 47 52 56 58 60 66 70 78 79 86 scan 0 sort 0}
+do_test where7-2.937.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='uvwxyzabc'
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR a=5
+ OR b=33
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ OR a=59
+ OR b=44
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ OR (d>=59.0 AND d<60.0 AND d NOT NULL)
+ }
+} {3 4 5 14 20 23 46 49 59 60 62 72 75 98 scan 0 sort 0}
+do_test where7-2.937.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='uvwxyzabc'
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR a=5
+ OR b=33
+ OR (f GLOB '?yzab*' AND f GLOB 'xyza*')
+ OR a=59
+ OR b=44
+ OR (d>=14.0 AND d<15.0 AND d NOT NULL)
+ OR (d>=59.0 AND d<60.0 AND d NOT NULL)
+ }
+} {3 4 5 14 20 23 46 49 59 60 62 72 75 98 scan 0 sort 0}
+do_test where7-2.938.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=564
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR b=451
+ OR b=330
+ OR a=47
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ }
+} {17 19 30 41 47 93 scan 0 sort 0}
+do_test where7-2.938.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=564
+ OR (d>=93.0 AND d<94.0 AND d NOT NULL)
+ OR b=451
+ OR b=330
+ OR a=47
+ OR ((a BETWEEN 17 AND 19) AND a!=18)
+ }
+} {17 19 30 41 47 93 scan 0 sort 0}
+do_test where7-2.939.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=40
+ OR b=333
+ }
+} {40 scan 0 sort 0}
+do_test where7-2.939.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=40
+ OR b=333
+ }
+} {40 scan 0 sort 0}
+do_test where7-2.940.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=924
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR a=100
+ OR c=15015
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ }
+} {2 6 8 36 40 43 44 45 82 84 100 scan 0 sort 0}
+do_test where7-2.940.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=924
+ OR ((a BETWEEN 6 AND 8) AND a!=7)
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR a=100
+ OR c=15015
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ OR (d>=2.0 AND d<3.0 AND d NOT NULL)
+ }
+} {2 6 8 36 40 43 44 45 82 84 100 scan 0 sort 0}
+do_test where7-2.941.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ }
+} {36 44 63 scan 0 sort 0}
+do_test where7-2.941.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ }
+} {36 44 63 scan 0 sort 0}
+do_test where7-2.942.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=58
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=31
+ OR f='tuvwxyzab'
+ OR b=341
+ OR b=47
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR a=49
+ OR b=223
+ OR f='qrstuvwxy'
+ }
+} {7 9 16 19 31 42 45 49 63 65 68 71 94 95 97 scan 0 sort 0}
+do_test where7-2.942.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=58
+ OR ((a BETWEEN 7 AND 9) AND a!=8)
+ OR ((a BETWEEN 63 AND 65) AND a!=64)
+ OR a=31
+ OR f='tuvwxyzab'
+ OR b=341
+ OR b=47
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ OR a=49
+ OR b=223
+ OR f='qrstuvwxy'
+ }
+} {7 9 16 19 31 42 45 49 63 65 68 71 94 95 97 scan 0 sort 0}
+do_test where7-2.943.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=96
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR a=85
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR c=11011
+ OR b=641
+ OR f='vwxyzabcd'
+ OR b=286
+ }
+} {4 10 12 21 23 26 30 31 32 33 37 39 47 56 73 82 85 96 99 scan 0 sort 0}
+do_test where7-2.943.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=96
+ OR (d>=23.0 AND d<24.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'vwxyz*')
+ OR (f GLOB '?fghi*' AND f GLOB 'efgh*')
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ OR a=85
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR c=11011
+ OR b=641
+ OR f='vwxyzabcd'
+ OR b=286
+ }
+} {4 10 12 21 23 26 30 31 32 33 37 39 47 56 73 82 85 96 99 scan 0 sort 0}
+do_test where7-2.944.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 3 AND 5) AND a!=4)
+ OR b=1012
+ OR a=7
+ OR b=773
+ OR a=1
+ OR b=726
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR b=110
+ }
+} {1 3 5 7 10 66 87 89 92 99 scan 0 sort 0}
+do_test where7-2.944.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 3 AND 5) AND a!=4)
+ OR b=1012
+ OR a=7
+ OR b=773
+ OR a=1
+ OR b=726
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR ((a BETWEEN 87 AND 89) AND a!=88)
+ OR b=110
+ }
+} {1 3 5 7 10 66 87 89 92 99 scan 0 sort 0}
+do_test where7-2.945.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR a=60
+ OR a=4
+ OR b=520
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR a=44
+ OR a=36
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR b=715
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ }
+} {4 7 16 36 44 60 65 76 79 scan 0 sort 0}
+do_test where7-2.945.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'hijkl*')
+ OR a=60
+ OR a=4
+ OR b=520
+ OR (g='ihgfedc' AND f GLOB 'bcdef*')
+ OR a=44
+ OR a=36
+ OR (d>=76.0 AND d<77.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR b=715
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ }
+} {4 7 16 36 44 60 65 76 79 scan 0 sort 0}
+do_test where7-2.946.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 3 AND 5) AND a!=4)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR a=24
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ }
+} {3 5 15 24 26 52 55 56 58 76 78 99 scan 0 sort 0}
+do_test where7-2.946.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 3 AND 5) AND a!=4)
+ OR ((a BETWEEN 56 AND 58) AND a!=57)
+ OR (d>=15.0 AND d<16.0 AND d NOT NULL)
+ OR (d>=55.0 AND d<56.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'yzabc*')
+ OR a=24
+ OR (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR (f GLOB '?bcde*' AND f GLOB 'abcd*')
+ }
+} {3 5 15 24 26 52 55 56 58 76 78 99 scan 0 sort 0}
+do_test where7-2.947.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR b=132
+ OR f='ghijklmno'
+ OR b=740
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR b=1059
+ }
+} {6 12 21 26 32 38 58 84 scan 0 sort 0}
+do_test where7-2.947.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='utsrqpo' AND f GLOB 'vwxyz*')
+ OR b=132
+ OR f='ghijklmno'
+ OR b=740
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR b=1059
+ }
+} {6 12 21 26 32 38 58 84 scan 0 sort 0}
+do_test where7-2.948.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=28
+ OR b=927
+ OR b=520
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR b=638
+ OR f='vwxyzabcd'
+ }
+} {21 28 47 53 58 73 99 scan 0 sort 0}
+do_test where7-2.948.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=28
+ OR b=927
+ OR b=520
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ OR b=638
+ OR f='vwxyzabcd'
+ }
+} {21 28 47 53 58 73 99 scan 0 sort 0}
+do_test where7-2.949.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR b=1026
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'lmnop*')
+ OR b=355
+ OR b=641
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ }
+} {1 11 53 54 scan 0 sort 0}
+do_test where7-2.949.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR b=1026
+ OR (d>=1.0 AND d<2.0 AND d NOT NULL)
+ OR (g='wvutsrq' AND f GLOB 'lmnop*')
+ OR b=355
+ OR b=641
+ OR (d>=53.0 AND d<54.0 AND d NOT NULL)
+ }
+} {1 11 53 54 scan 0 sort 0}
+do_test where7-2.950.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 46 AND 48) AND a!=47)
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR b=641
+ OR a=3
+ OR a=35
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR f='opqrstuvw'
+ OR a=41
+ OR a=83
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR b=751
+ }
+} {3 14 35 40 41 46 48 54 60 62 66 81 83 92 scan 0 sort 0}
+do_test where7-2.950.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 46 AND 48) AND a!=47)
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR b=641
+ OR a=3
+ OR a=35
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR f='opqrstuvw'
+ OR a=41
+ OR a=83
+ OR (g='nmlkjih' AND f GLOB 'cdefg*')
+ OR b=751
+ }
+} {3 14 35 40 41 46 48 54 60 62 66 81 83 92 scan 0 sort 0}
+do_test where7-2.951.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 3 AND 5) AND a!=4)
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR c=15015
+ OR b=146
+ OR b=1092
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ }
+} {3 5 43 44 45 60 62 scan 0 sort 0}
+do_test where7-2.951.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 3 AND 5) AND a!=4)
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR c=15015
+ OR b=146
+ OR b=1092
+ OR (d>=60.0 AND d<61.0 AND d NOT NULL)
+ }
+} {3 5 43 44 45 60 62 scan 0 sort 0}
+do_test where7-2.952.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='qponmlk' AND f GLOB 'qrstu*')
+ OR f='bcdefghij'
+ OR f='hijklmnop'
+ OR a=65
+ OR f='ijklmnopq'
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR g IS NULL
+ OR a=26
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR a=9
+ OR (d>=32.0 AND d<33.0 AND d NOT NULL)
+ }
+} {1 7 8 9 26 27 32 33 34 38 40 42 53 59 60 65 79 85 86 scan 0 sort 0}
+do_test where7-2.952.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='qponmlk' AND f GLOB 'qrstu*')
+ OR f='bcdefghij'
+ OR f='hijklmnop'
+ OR a=65
+ OR f='ijklmnopq'
+ OR (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR g IS NULL
+ OR a=26
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR a=9
+ OR (d>=32.0 AND d<33.0 AND d NOT NULL)
+ }
+} {1 7 8 9 26 27 32 33 34 38 40 42 53 59 60 65 79 85 86 scan 0 sort 0}
+do_test where7-2.953.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR b=1100
+ OR c=6006
+ OR c=4004
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR c=33033
+ }
+} {10 11 12 16 17 18 24 26 41 70 73 79 81 97 98 99 100 scan 0 sort 0}
+do_test where7-2.953.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='jihgfed' AND f GLOB 'vwxyz*')
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ OR (g='kjihgfe' AND f GLOB 'stuvw*')
+ OR (g='qponmlk' AND f GLOB 'pqrst*')
+ OR b=1100
+ OR c=6006
+ OR c=4004
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR c=33033
+ }
+} {10 11 12 16 17 18 24 26 41 70 73 79 81 97 98 99 100 scan 0 sort 0}
+do_test where7-2.954.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=17
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ }
+} {17 95 97 scan 0 sort 0}
+do_test where7-2.954.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=17
+ OR ((a BETWEEN 95 AND 97) AND a!=96)
+ }
+} {17 95 97 scan 0 sort 0}
+do_test where7-2.955.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=3003
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR a=93
+ }
+} {7 8 9 67 93 scan 0 sort 0}
+do_test where7-2.955.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=3003
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR a=93
+ }
+} {7 8 9 67 93 scan 0 sort 0}
+do_test where7-2.956.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=737
+ }
+} {12 21 23 42 44 67 scan 0 sort 0}
+do_test where7-2.956.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR ((a BETWEEN 21 AND 23) AND a!=22)
+ OR (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR b=737
+ }
+} {12 21 23 42 44 67 scan 0 sort 0}
+do_test where7-2.957.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='rqponml' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ }
+} {5 7 36 scan 0 sort 0}
+do_test where7-2.957.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='rqponml' AND f GLOB 'klmno*')
+ OR ((a BETWEEN 5 AND 7) AND a!=6)
+ }
+} {5 7 36 scan 0 sort 0}
+do_test where7-2.958.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR c=32032
+ OR f='opqrstuvw'
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR b=993
+ }
+} {14 40 49 51 66 68 85 92 94 95 96 scan 0 sort 0}
+do_test where7-2.958.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='hgfedcb' AND f GLOB 'hijkl*')
+ OR c=32032
+ OR f='opqrstuvw'
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR ((a BETWEEN 49 AND 51) AND a!=50)
+ OR b=993
+ }
+} {14 40 49 51 66 68 85 92 94 95 96 scan 0 sort 0}
+do_test where7-2.959.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR b=245
+ OR b=528
+ OR b=366
+ OR a=73
+ OR a=49
+ OR b=421
+ OR a=58
+ }
+} {12 38 48 49 58 59 61 73 86 88 scan 0 sort 0}
+do_test where7-2.959.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)
+ OR ((a BETWEEN 59 AND 61) AND a!=60)
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR b=245
+ OR b=528
+ OR b=366
+ OR a=73
+ OR a=49
+ OR b=421
+ OR a=58
+ }
+} {12 38 48 49 58 59 61 73 86 88 scan 0 sort 0}
+do_test where7-2.960.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR b=146
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR ((a BETWEEN 73 AND 75) AND a!=74)
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR b=704
+ }
+} {8 10 20 43 60 62 64 73 75 82 86 88 100 scan 0 sort 0}
+do_test where7-2.960.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR ((a BETWEEN 86 AND 88) AND a!=87)
+ OR b=146
+ OR (g='ponmlkj' AND f GLOB 'rstuv*')
+ OR ((a BETWEEN 73 AND 75) AND a!=74)
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR ((a BETWEEN 60 AND 62) AND a!=61)
+ OR (g='ihgfedc' AND f GLOB 'efghi*')
+ OR b=704
+ }
+} {8 10 20 43 60 62 64 73 75 82 86 88 100 scan 0 sort 0}
+do_test where7-2.961.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 65 AND 67) AND a!=66)
+ OR b=14
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR a=49
+ OR b=333
+ }
+} {3 5 49 65 67 scan 0 sort 0}
+do_test where7-2.961.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 65 AND 67) AND a!=66)
+ OR b=14
+ OR ((a BETWEEN 3 AND 5) AND a!=4)
+ OR a=49
+ OR b=333
+ }
+} {3 5 49 65 67 scan 0 sort 0}
+do_test where7-2.962.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=17017
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR b=971
+ OR a=37
+ OR a=7
+ OR b=641
+ OR a=13
+ OR b=597
+ }
+} {7 13 37 38 49 50 51 scan 0 sort 0}
+do_test where7-2.962.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=17017
+ OR (g='qponmlk' AND f GLOB 'mnopq*')
+ OR b=971
+ OR a=37
+ OR a=7
+ OR b=641
+ OR a=13
+ OR b=597
+ }
+} {7 13 37 38 49 50 51 scan 0 sort 0}
+do_test where7-2.963.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='tuvwxyzab'
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ }
+} {17 19 43 45 69 71 95 97 scan 0 sort 0}
+do_test where7-2.963.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='tuvwxyzab'
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ }
+} {17 19 43 45 69 71 95 97 scan 0 sort 0}
+do_test where7-2.964.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=638
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR b=165
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR f='stuvwxyza'
+ OR b=652
+ OR b=66
+ OR b=770
+ OR b=91
+ }
+} {6 10 12 15 18 44 58 70 89 96 scan 0 sort 0}
+do_test where7-2.964.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=638
+ OR (d>=44.0 AND d<45.0 AND d NOT NULL)
+ OR (g='gfedcba' AND f GLOB 'lmnop*')
+ OR b=165
+ OR ((a BETWEEN 10 AND 12) AND a!=11)
+ OR f='stuvwxyza'
+ OR b=652
+ OR b=66
+ OR b=770
+ OR b=91
+ }
+} {6 10 12 15 18 44 58 70 89 96 scan 0 sort 0}
+do_test where7-2.965.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR f='opqrstuvw'
+ OR a=83
+ OR a=93
+ OR b=858
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ }
+} {14 18 40 52 66 73 78 83 92 93 scan 0 sort 0}
+do_test where7-2.965.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=52.0 AND d<53.0 AND d NOT NULL)
+ OR f='opqrstuvw'
+ OR a=83
+ OR a=93
+ OR b=858
+ OR (d>=18.0 AND d<19.0 AND d NOT NULL)
+ OR (g='jihgfed' AND f GLOB 'vwxyz*')
+ }
+} {14 18 40 52 66 73 78 83 92 93 scan 0 sort 0}
+do_test where7-2.966.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE c=3003
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR a=38
+ }
+} {7 8 9 38 40 42 scan 0 sort 0}
+do_test where7-2.966.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE c=3003
+ OR ((a BETWEEN 40 AND 42) AND a!=41)
+ OR a=38
+ }
+} {7 8 9 38 40 42 scan 0 sort 0}
+do_test where7-2.967.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ }
+} {50 52 60 scan 0 sort 0}
+do_test where7-2.967.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)
+ OR ((a BETWEEN 50 AND 52) AND a!=51)
+ }
+} {50 52 60 scan 0 sort 0}
+do_test where7-2.968.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='qponmlk' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR a=5
+ OR b=396
+ OR a=13
+ }
+} {5 13 24 26 36 38 scan 0 sort 0}
+do_test where7-2.968.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='qponmlk' AND f GLOB 'mnopq*')
+ OR ((a BETWEEN 24 AND 26) AND a!=25)
+ OR a=5
+ OR b=396
+ OR a=13
+ }
+} {5 13 24 26 36 38 scan 0 sort 0}
+do_test where7-2.969.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=748
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR b=531
+ OR b=1092
+ OR b=418
+ }
+} {38 68 69 71 95 97 scan 0 sort 0}
+do_test where7-2.969.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR b=748
+ OR (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR ((a BETWEEN 69 AND 71) AND a!=70)
+ OR b=531
+ OR b=1092
+ OR b=418
+ }
+} {38 68 69 71 95 97 scan 0 sort 0}
+do_test where7-2.970.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR a=50
+ OR a=46
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ }
+} {8 10 14 30 38 40 46 50 66 92 scan 0 sort 0}
+do_test where7-2.970.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)
+ OR ((a BETWEEN 8 AND 10) AND a!=9)
+ OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')
+ OR a=50
+ OR a=46
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ }
+} {8 10 14 30 38 40 46 50 66 92 scan 0 sort 0}
+do_test where7-2.971.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=24
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR b=487
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR ((a BETWEEN 13 AND 15) AND a!=14)
+ OR b=132
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR b=795
+ OR b=737
+ }
+} {12 13 15 22 24 54 67 96 scan 0 sort 0}
+do_test where7-2.971.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=24
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR b=487
+ OR (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR ((a BETWEEN 13 AND 15) AND a!=14)
+ OR b=132
+ OR (d>=54.0 AND d<55.0 AND d NOT NULL)
+ OR b=795
+ OR b=737
+ }
+} {12 13 15 22 24 54 67 96 scan 0 sort 0}
+do_test where7-2.972.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR a=34
+ OR c=16016
+ OR b=1078
+ OR b=960
+ OR (g='hgfedcb' AND f GLOB 'jklmn*')
+ }
+} {34 46 47 48 87 88 98 scan 0 sort 0}
+do_test where7-2.972.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=88.0 AND d<89.0 AND d NOT NULL)
+ OR a=34
+ OR c=16016
+ OR b=1078
+ OR b=960
+ OR (g='hgfedcb' AND f GLOB 'jklmn*')
+ }
+} {34 46 47 48 87 88 98 scan 0 sort 0}
+do_test where7-2.973.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1081
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 73 AND 75) AND a!=74)
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR a=6
+ }
+} {6 19 21 38 45 73 75 scan 0 sort 0}
+do_test where7-2.973.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1081
+ OR ((a BETWEEN 19 AND 21) AND a!=20)
+ OR (g='ponmlkj' AND f GLOB 'tuvwx*')
+ OR ((a BETWEEN 73 AND 75) AND a!=74)
+ OR (d>=38.0 AND d<39.0 AND d NOT NULL)
+ OR a=6
+ }
+} {6 19 21 38 45 73 75 scan 0 sort 0}
+do_test where7-2.974.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR a=92
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR f='fghijklmn'
+ OR a=100
+ OR b=209
+ OR c=9009
+ OR ((a BETWEEN 52 AND 54) AND a!=53)
+ OR a=73
+ OR b=902
+ }
+} {5 9 19 25 26 27 31 35 37 52 54 57 61 73 82 83 87 92 95 100 scan 0 sort 0}
+do_test where7-2.974.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='fedcbaz' AND f GLOB 'rstuv*')
+ OR (g='rqponml' AND f GLOB 'lmnop*')
+ OR a=92
+ OR (f GLOB '?klmn*' AND f GLOB 'jklm*')
+ OR f='fghijklmn'
+ OR a=100
+ OR b=209
+ OR c=9009
+ OR ((a BETWEEN 52 AND 54) AND a!=53)
+ OR a=73
+ OR b=902
+ }
+} {5 9 19 25 26 27 31 35 37 52 54 57 61 73 82 83 87 92 95 100 scan 0 sort 0}
+do_test where7-2.975.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR b=110
+ OR f='ghijklmno'
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ }
+} {6 10 21 32 40 58 84 scan 0 sort 0}
+do_test where7-2.975.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=40.0 AND d<41.0 AND d NOT NULL)
+ OR b=110
+ OR f='ghijklmno'
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ }
+} {6 10 21 32 40 58 84 scan 0 sort 0}
+do_test where7-2.976.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 51 AND 53) AND a!=52)
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR b=91
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=77
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ }
+} {1 7 15 20 27 45 46 51 53 79 scan 0 sort 0}
+do_test where7-2.976.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 51 AND 53) AND a!=52)
+ OR (g='utsrqpo' AND f GLOB 'uvwxy*')
+ OR (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR b=91
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR b=77
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR (g='vutsrqp' AND f GLOB 'pqrst*')
+ }
+} {1 7 15 20 27 45 46 51 53 79 scan 0 sort 0}
+do_test where7-2.977.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR b=693
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR a=52
+ OR b=377
+ }
+} {21 26 42 52 56 63 78 scan 0 sort 0}
+do_test where7-2.977.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR b=693
+ OR (d>=21.0 AND d<22.0 AND d NOT NULL)
+ OR (d>=26.0 AND d<27.0 AND d NOT NULL)
+ OR (d>=42.0 AND d<43.0 AND d NOT NULL)
+ OR a=52
+ OR b=377
+ }
+} {21 26 42 52 56 63 78 scan 0 sort 0}
+do_test where7-2.978.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=99
+ OR a=36
+ OR b=297
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=1004
+ OR b=872
+ OR a=95
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR b=176
+ OR b=300
+ }
+} {16 27 36 66 68 95 99 scan 0 sort 0}
+do_test where7-2.978.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=99
+ OR a=36
+ OR b=297
+ OR ((a BETWEEN 66 AND 68) AND a!=67)
+ OR b=1004
+ OR b=872
+ OR a=95
+ OR (d>=27.0 AND d<28.0 AND d NOT NULL)
+ OR b=176
+ OR b=300
+ }
+} {16 27 36 66 68 95 99 scan 0 sort 0}
+do_test where7-2.979.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=737
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ OR a=40
+ OR f='uvwxyzabc'
+ OR b=311
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR b=927
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ }
+} {5 6 8 20 31 32 40 46 50 53 57 58 67 72 83 84 98 scan 0 sort 0}
+do_test where7-2.979.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=737
+ OR (g='wvutsrq' AND f GLOB 'ijklm*')
+ OR (f GLOB '?ghij*' AND f GLOB 'fghi*')
+ OR a=40
+ OR f='uvwxyzabc'
+ OR b=311
+ OR (g='nmlkjih' AND f GLOB 'bcdef*')
+ OR (f GLOB '?hijk*' AND f GLOB 'ghij*')
+ OR b=927
+ OR (d>=50.0 AND d<51.0 AND d NOT NULL)
+ }
+} {5 6 8 20 31 32 40 46 50 53 57 58 67 72 83 84 98 scan 0 sort 0}
+do_test where7-2.980.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE f='fghijklmn'
+ OR b=1078
+ OR (d>=35.0 AND d<36.0 AND d NOT NULL)
+ OR f='fghijklmn'
+ }
+} {5 31 35 57 83 98 scan 0 sort 0}
+do_test where7-2.980.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE f='fghijklmn'
+ OR b=1078
+ OR (d>=35.0 AND d<36.0 AND d NOT NULL)
+ OR f='fghijklmn'
+ }
+} {5 31 35 57 83 98 scan 0 sort 0}
+do_test where7-2.981.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR b=487
+ OR f='tuvwxyzab'
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR b=971
+ OR c=19019
+ OR a=39
+ OR (f GLOB '?nopq*' AND f GLOB 'mnop*')
+ OR b=550
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR b=660
+ }
+} {6 12 19 38 39 45 48 50 55 56 57 60 64 71 90 97 scan 0 sort 0}
+do_test where7-2.981.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='xwvutsr' AND f GLOB 'ghijk*')
+ OR b=487
+ OR f='tuvwxyzab'
+ OR (g='onmlkji' AND f GLOB 'wxyza*')
+ OR b=971
+ OR c=19019
+ OR a=39
+ OR (f GLOB '?nopq*' AND f GLOB 'mnop*')
+ OR b=550
+ OR (g='kjihgfe' AND f GLOB 'tuvwx*')
+ OR b=660
+ }
+} {6 12 19 38 39 45 48 50 55 56 57 60 64 71 90 97 scan 0 sort 0}
+do_test where7-2.982.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=80
+ OR b=839
+ }
+} { scan 0 sort 0}
+do_test where7-2.982.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=80
+ OR b=839
+ }
+} { scan 0 sort 0}
+do_test where7-2.983.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=363
+ OR b=630
+ OR b=935
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR f='yzabcdefg'
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ }
+} {20 24 29 33 37 39 50 76 85 scan 0 sort 0}
+do_test where7-2.983.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=363
+ OR b=630
+ OR b=935
+ OR (d>=20.0 AND d<21.0 AND d NOT NULL)
+ OR (g='srqponm' AND f GLOB 'defgh*')
+ OR f='yzabcdefg'
+ OR ((a BETWEEN 37 AND 39) AND a!=38)
+ }
+} {20 24 29 33 37 39 50 76 85 scan 0 sort 0}
+do_test where7-2.984.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR a=40
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR f='abcdefghi'
+ OR b=696
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR b=682
+ OR a=32
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ OR b=671
+ OR a=15
+ }
+} {15 16 26 32 34 36 40 52 61 62 78 86 97 scan 0 sort 0}
+do_test where7-2.984.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)
+ OR a=40
+ OR (d>=86.0 AND d<87.0 AND d NOT NULL)
+ OR f='abcdefghi'
+ OR b=696
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR b=682
+ OR a=32
+ OR ((a BETWEEN 34 AND 36) AND a!=35)
+ OR b=671
+ OR a=15
+ }
+} {15 16 26 32 34 36 40 52 61 62 78 86 97 scan 0 sort 0}
+do_test where7-2.985.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (g='gfedcba' AND f GLOB 'lmnop*')
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR b=311
+ }
+} {7 33 59 85 89 scan 0 sort 0}
+do_test where7-2.985.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (g='gfedcba' AND f GLOB 'lmnop*')
+ OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')
+ OR b=311
+ }
+} {7 33 59 85 89 scan 0 sort 0}
+do_test where7-2.986.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR a=73
+ OR b=729
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR a=32
+ }
+} {32 67 73 81 96 scan 0 sort 0}
+do_test where7-2.986.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=96.0 AND d<97.0 AND d NOT NULL)
+ OR a=73
+ OR b=729
+ OR (d>=81.0 AND d<82.0 AND d NOT NULL)
+ OR (d>=67.0 AND d<68.0 AND d NOT NULL)
+ OR a=32
+ }
+} {32 67 73 81 96 scan 0 sort 0}
+do_test where7-2.987.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 98 AND 100) AND a!=99)
+ OR b=110
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR b=484
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ }
+} {10 23 38 40 44 82 98 100 scan 0 sort 0}
+do_test where7-2.987.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 98 AND 100) AND a!=99)
+ OR b=110
+ OR ((a BETWEEN 38 AND 40) AND a!=39)
+ OR (g='tsrqpon' AND f GLOB 'xyzab*')
+ OR b=484
+ OR (d>=82.0 AND d<83.0 AND d NOT NULL)
+ }
+} {10 23 38 40 44 82 98 100 scan 0 sort 0}
+do_test where7-2.988.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR b=135
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR b=209
+ OR b=363
+ OR c=27027
+ OR b=1026
+ OR c=6006
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ }
+} {16 17 18 19 33 46 66 73 79 80 81 99 scan 0 sort 0}
+do_test where7-2.988.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=99.0 AND d<100.0 AND d NOT NULL)
+ OR b=135
+ OR (d>=66.0 AND d<67.0 AND d NOT NULL)
+ OR b=209
+ OR b=363
+ OR c=27027
+ OR b=1026
+ OR c=6006
+ OR (g='ponmlkj' AND f GLOB 'uvwxy*')
+ OR (d>=73.0 AND d<74.0 AND d NOT NULL)
+ }
+} {16 17 18 19 33 46 66 73 79 80 81 99 scan 0 sort 0}
+do_test where7-2.989.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR a=97
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR b=674
+ OR c=14014
+ OR b=69
+ }
+} {18 20 22 24 39 40 41 42 45 58 79 97 scan 0 sort 0}
+do_test where7-2.989.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)
+ OR ((a BETWEEN 18 AND 20) AND a!=19)
+ OR (g='qponmlk' AND f GLOB 'nopqr*')
+ OR a=97
+ OR (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR ((a BETWEEN 22 AND 24) AND a!=23)
+ OR (g='mlkjihg' AND f GLOB 'ghijk*')
+ OR b=674
+ OR c=14014
+ OR b=69
+ }
+} {18 20 22 24 39 40 41 42 45 58 79 97 scan 0 sort 0}
+do_test where7-2.990.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=297
+ OR a=83
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ }
+} {16 18 27 78 83 scan 0 sort 0}
+do_test where7-2.990.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=297
+ OR a=83
+ OR (d>=78.0 AND d<79.0 AND d NOT NULL)
+ OR ((a BETWEEN 16 AND 18) AND a!=17)
+ }
+} {16 18 27 78 83 scan 0 sort 0}
+do_test where7-2.991.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=451
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR b=539
+ OR a=26
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR b=465
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ }
+} {11 13 26 30 41 49 74 scan 0 sort 0}
+do_test where7-2.991.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=451
+ OR ((a BETWEEN 11 AND 13) AND a!=12)
+ OR (g='tsrqpon' AND f GLOB 'abcde*')
+ OR b=539
+ OR a=26
+ OR (g='srqponm' AND f GLOB 'efghi*')
+ OR b=465
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ }
+} {11 13 26 30 41 49 74 scan 0 sort 0}
+do_test where7-2.992.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ }
+} {45 63 scan 0 sort 0}
+do_test where7-2.992.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (d>=45.0 AND d<46.0 AND d NOT NULL)
+ OR (d>=63.0 AND d<64.0 AND d NOT NULL)
+ }
+} {45 63 scan 0 sort 0}
+do_test where7-2.993.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 16 AND 18) AND a!=17)
+ OR b=872
+ OR c=31031
+ }
+} {16 18 91 92 93 scan 0 sort 0}
+do_test where7-2.993.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 16 AND 18) AND a!=17)
+ OR b=872
+ OR c=31031
+ }
+} {16 18 91 92 93 scan 0 sort 0}
+do_test where7-2.994.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR a=13
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR b=322
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR b=377
+ OR f='cdefghijk'
+ OR b=286
+ OR ((a BETWEEN 61 AND 63) AND a!=62)
+ }
+} {1 2 13 17 26 27 28 33 35 43 53 54 61 63 69 79 80 95 scan 0 sort 0}
+do_test where7-2.994.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE (f GLOB '?cdef*' AND f GLOB 'bcde*')
+ OR a=13
+ OR (f GLOB '?stuv*' AND f GLOB 'rstu*')
+ OR b=322
+ OR ((a BETWEEN 33 AND 35) AND a!=34)
+ OR b=377
+ OR f='cdefghijk'
+ OR b=286
+ OR ((a BETWEEN 61 AND 63) AND a!=62)
+ }
+} {1 2 13 17 26 27 28 33 35 43 53 54 61 63 69 79 80 95 scan 0 sort 0}
+do_test where7-2.995.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=41
+ OR b=990
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR b=605
+ OR (g='srqponm' AND f GLOB 'cdefg*')
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR b=968
+ OR a=66
+ }
+} {16 28 36 41 55 66 88 90 scan 0 sort 0}
+do_test where7-2.995.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=41
+ OR b=990
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR b=605
+ OR (g='srqponm' AND f GLOB 'cdefg*')
+ OR (d>=36.0 AND d<37.0 AND d NOT NULL)
+ OR (g='vutsrqp' AND f GLOB 'qrstu*')
+ OR b=968
+ OR a=66
+ }
+} {16 28 36 41 55 66 88 90 scan 0 sort 0}
+do_test where7-2.996.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1059
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ }
+} {17 19 32 37 39 41 52 57 scan 0 sort 0}
+do_test where7-2.996.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1059
+ OR (g='srqponm' AND f GLOB 'ghijk*')
+ OR (g='utsrqpo' AND f GLOB 'tuvwx*')
+ OR (g='nmlkjih' AND f GLOB 'fghij*')
+ OR (d>=17.0 AND d<18.0 AND d NOT NULL)
+ OR (d>=37.0 AND d<38.0 AND d NOT NULL)
+ OR (g='onmlkji' AND f GLOB 'abcde*')
+ OR ((a BETWEEN 39 AND 41) AND a!=40)
+ }
+} {17 19 32 37 39 41 52 57 scan 0 sort 0}
+do_test where7-2.997.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE ((a BETWEEN 41 AND 43) AND a!=42)
+ OR f='nopqrstuv'
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR a=42
+ OR b=729
+ OR b=297
+ OR a=77
+ OR b=781
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ }
+} {13 27 36 38 39 41 42 43 44 65 71 77 91 scan 0 sort 0}
+do_test where7-2.997.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE ((a BETWEEN 41 AND 43) AND a!=42)
+ OR f='nopqrstuv'
+ OR (g='ponmlkj' AND f GLOB 'stuvw*')
+ OR a=42
+ OR b=729
+ OR b=297
+ OR a=77
+ OR b=781
+ OR ((a BETWEEN 36 AND 38) AND a!=37)
+ }
+} {13 27 36 38 39 41 42 43 44 65 71 77 91 scan 0 sort 0}
+do_test where7-2.998.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE a=12
+ OR f='qrstuvwxy'
+ OR a=47
+ OR b=135
+ OR a=25
+ }
+} {12 16 25 42 47 68 94 scan 0 sort 0}
+do_test where7-2.998.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE a=12
+ OR f='qrstuvwxy'
+ OR a=47
+ OR b=135
+ OR a=25
+ }
+} {12 16 25 42 47 68 94 scan 0 sort 0}
+do_test where7-2.999.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=451
+ OR b=660
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ OR b=781
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR b=198
+ OR b=1023
+ OR a=98
+ OR d<0.0
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ }
+} {18 41 50 60 71 74 79 81 93 98 scan 0 sort 0}
+do_test where7-2.999.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=451
+ OR b=660
+ OR (g='onmlkji' AND f GLOB 'yzabc*')
+ OR b=781
+ OR (g='jihgfed' AND f GLOB 'wxyza*')
+ OR b=198
+ OR b=1023
+ OR a=98
+ OR d<0.0
+ OR ((a BETWEEN 79 AND 81) AND a!=80)
+ }
+} {18 41 50 60 71 74 79 81 93 98 scan 0 sort 0}
+do_test where7-2.1000.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=685
+ OR a=86
+ OR c=17017
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR a=80
+ OR b=773
+ }
+} {49 50 51 80 85 86 87 90 scan 0 sort 0}
+do_test where7-2.1000.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=685
+ OR a=86
+ OR c=17017
+ OR ((a BETWEEN 85 AND 87) AND a!=86)
+ OR (g='gfedcba' AND f GLOB 'mnopq*')
+ OR a=80
+ OR b=773
+ }
+} {49 50 51 80 85 86 87 90 scan 0 sort 0}
+do_test where7-2.1001.1 {
+ count_steps_sort {
+ SELECT a FROM t2
+ WHERE b=1092
+ OR a=23
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR d<0.0
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR a=91
+ }
+} {2 22 23 28 54 80 91 scan 0 sort 0}
+do_test where7-2.1001.2 {
+ count_steps_sort {
+ SELECT a FROM t3
+ WHERE b=1092
+ OR a=23
+ OR (f GLOB '?defg*' AND f GLOB 'cdef*')
+ OR d<0.0
+ OR (d>=22.0 AND d<23.0 AND d NOT NULL)
+ OR a=91
+ }
+} {2 22 23 28 54 80 91 scan 0 sort 0}
+
+# test case for the performance regression fixed by
+# check-in 28ba6255282b on 2010-10-21 02:05:06
+#
+# The test case that follows is code from an actual
+# application with identifiers change and unused columns
+# remove.
+#
+do_execsql_test where7-3.1 {
+ CREATE TABLE t301 (
+ c8 INTEGER PRIMARY KEY,
+ c6 INTEGER,
+ c4 INTEGER,
+ c7 INTEGER,
+ FOREIGN KEY (c4) REFERENCES series(c4)
+ );
+ CREATE INDEX t301_c6 on t301(c6);
+ CREATE INDEX t301_c4 on t301(c4);
+ CREATE INDEX t301_c7 on t301(c7);
+
+ CREATE TABLE t302 (
+ c1 INTEGER PRIMARY KEY,
+ c8 INTEGER,
+ c5 INTEGER,
+ c3 INTEGER,
+ c2 INTEGER,
+ c4 INTEGER,
+ FOREIGN KEY (c8) REFERENCES t301(c8)
+ );
+ CREATE INDEX t302_c3 on t302(c3);
+ CREATE INDEX t302_c8_c3 on t302(c8, c3);
+ CREATE INDEX t302_c5 on t302(c5);
+
+ EXPLAIN QUERY PLAN
+ SELECT t302.c1
+ FROM t302 JOIN t301 ON t302.c8 = t301.c8
+ WHERE t302.c2 = 19571
+ AND t302.c3 > 1287603136
+ AND (t301.c4 = 1407449685622784
+ OR t301.c8 = 1407424651264000)
+ ORDER BY t302.c5 LIMIT 200;
+} {
+ 0 0 1 {SEARCH TABLE t301 USING COVERING INDEX t301_c4 (c4=?) (~5 rows)}
+ 0 0 1 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+ 0 1 0 {SEARCH TABLE t302 USING INDEX t302_c8_c3 (c8=? AND c3>?) (~2 rows)}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+
+finish_test
diff --git a/test/where8.test b/test/where8.test
new file mode 100644
index 0000000..a7d5edb
--- /dev/null
+++ b/test/where8.test
@@ -0,0 +1,719 @@
+# 2008 December 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus
+# is testing of where.c. More specifically, the focus is the optimization
+# of WHERE clauses that feature the OR operator.
+#
+# $Id: where8.test,v 1.9 2009/07/31 06:14:52 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Test organization:
+#
+# where8-1.*: Tests to demonstrate simple cases work with a single table
+# in the FROM clause.
+#
+# where8-2.*: Tests surrounding virtual tables and the OR optimization.
+#
+# where8-3.*: Tests with more than one table in the FROM clause.
+#
+
+proc execsql_status {sql {db db}} {
+ set result [uplevel $db eval [list $sql]]
+ concat $result [db status step] [db status sort]
+}
+
+proc execsql_status2 {sql {db db}} {
+ set ::sqlite_search_count 0
+ set result [uplevel [list execsql_status $sql $db]]
+ concat $result $::sqlite_search_count
+}
+
+do_test where8-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b TEXT, c);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+
+ INSERT INTO t1 VALUES(1, 'one', 'I');
+ INSERT INTO t1 VALUES(2, 'two', 'II');
+ INSERT INTO t1 VALUES(3, 'three', 'III');
+ INSERT INTO t1 VALUES(4, 'four', 'IV');
+ INSERT INTO t1 VALUES(5, 'five', 'V');
+ INSERT INTO t1 VALUES(6, 'six', 'VI');
+ INSERT INTO t1 VALUES(7, 'seven', 'VII');
+ INSERT INTO t1 VALUES(8, 'eight', 'VIII');
+ INSERT INTO t1 VALUES(9, 'nine', 'IX');
+ INSERT INTO t1 VALUES(10, 'ten', 'X');
+ }
+} {}
+
+do_test where8-1.2 {
+ execsql_status2 { SELECT c FROM t1 WHERE a = 1 OR b = 'nine' }
+} {I IX 0 0 6}
+
+do_test where8-1.3 {
+ execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b = 'two' }
+} {IX X II 0 0 6}
+
+do_test where8-1.4 {
+ execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 't*' }
+} {IX X III II 0 0 9}
+
+do_test where8-1.5 {
+ execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 'f*' }
+} {IX X V IV 0 0 9}
+
+do_test where8-1.6 {
+ execsql_status { SELECT c FROM t1 WHERE a = 1 OR b = 'three' ORDER BY rowid }
+} {I III 0 1}
+
+do_test where8-1.7 {
+ execsql_status { SELECT c FROM t1 WHERE a = 1 OR b = 'three' ORDER BY a }
+} {I III 0 1}
+
+do_test where8-1.8 {
+ # 18 searches. 9 on the index cursor and 9 on the table cursor.
+ execsql_status2 { SELECT c FROM t1 WHERE a > 1 AND c LIKE 'I%' }
+} {II III IV IX 0 0 18}
+
+do_test where8-1.9 {
+ execsql_status2 { SELECT c FROM t1 WHERE a >= 9 OR b <= 'eight' }
+} {IX X VIII 0 0 6}
+
+do_test where8-1.10 {
+ execsql_status2 {
+ SELECT c FROM t1 WHERE (a >= 9 AND c != 'X') OR b <= 'eight'
+ }
+} {IX VIII 0 0 6}
+
+do_test where8-1.11 {
+ execsql_status2 {
+ SELECT c FROM t1 WHERE (a >= 4 AND a <= 6) OR b = 'nine'
+ }
+} {IV V VI IX 0 0 10}
+
+do_test where8-1.12.1 {
+ execsql_status2 {
+ SELECT c FROM t1 WHERE a IN(1, 2, 3) OR a = 5
+ }
+} {I II III V 0 0 14}
+
+do_test where8-1.12.2 {
+ execsql_status2 {
+ SELECT c FROM t1 WHERE +a IN(1, 2, 3) OR +a = 5
+ }
+} {I II III V 9 0 9}
+
+do_test where8-1.13 {
+ execsql_status2 {
+ SELECT c FROM t1
+ WHERE a = 2 OR b = 'three' OR a = 4 OR b = 'five' OR a = 6
+ ORDER BY rowid
+ }
+} {II III IV V VI 0 1 18}
+do_test where8-1.14 {
+ execsql_status2 {
+ SELECT c FROM t1
+ WHERE
+ a = 2 OR b = 'three' OR a = 4 OR b = 'five' OR a = 6 OR
+ b = 'seven' OR a = 8 OR b = 'nine' OR a = 10
+ ORDER BY rowid
+ }
+} {II III IV V VI VII VIII IX X 0 1 33}
+
+do_test where8-1.15 {
+ execsql_status2 {
+ SELECT c FROM t1 WHERE
+ a BETWEEN 2 AND 4 OR b = 'nine'
+ ORDER BY rowid
+ }
+} {II III IV IX 0 1 12}
+
+
+#--------------------------------------------------------------------------
+# Tests where8-2.*: Virtual tables
+#
+
+if 0 {
+ifcapable vtab {
+ # Register the 'echo' module used for testing virtual tables.
+ #
+ register_echo_module [sqlite3_connection_pointer db]
+
+ do_test where8-2.1 {
+ execsql {
+ CREATE VIRTUAL TABLE e1 USING echo(t1);
+ SELECT b FROM e1;
+ }
+ } {one two three four five six seven eight nine ten}
+
+ do_test where8-2.2.1 {
+ set echo_module ""
+ execsql {
+ SELECT c FROM e1 WHERE a=1 OR b='three';
+ }
+ } {I III}
+ do_test where8-2.2.2 {
+ set echo_module
+ } {TODO: What should this be?}
+}
+}
+
+#--------------------------------------------------------------------------
+# Tests where8-3.*: Cases with multiple tables in the FROM clause.
+#
+do_test where8-3.1 {
+ execsql {
+ CREATE TABLE t2(d, e, f);
+ CREATE INDEX i3 ON t2(d);
+ CREATE INDEX i4 ON t2(e);
+
+ INSERT INTO t2 VALUES(1, NULL, 'I');
+ INSERT INTO t2 VALUES(2, 'four', 'IV');
+ INSERT INTO t2 VALUES(3, NULL, 'IX');
+ INSERT INTO t2 VALUES(4, 'sixteen', 'XVI');
+ INSERT INTO t2 VALUES(5, NULL, 'XXV');
+ INSERT INTO t2 VALUES(6, 'thirtysix', 'XXXVI');
+ INSERT INTO t2 VALUES(7, 'fortynine', 'XLIX');
+ INSERT INTO t2 VALUES(8, 'sixtyeight', 'LXIV');
+ INSERT INTO t2 VALUES(9, 'eightyone', 'LXXXIX');
+ INSERT INTO t2 VALUES(10, NULL, 'C');
+ }
+} {}
+
+do_test where8-3.2 {
+ execsql_status {
+ SELECT a, d FROM t1, t2 WHERE b=e
+ }
+} {4 2 9 0}
+
+do_test where8-3.3 {
+ execsql_status {
+ SELECT a, d FROM t1, t2 WHERE (a = 2 OR a = 3) AND d = 6
+ }
+} {2 6 3 6 0 0}
+
+do_test where8-3.4 {
+ execsql_status {
+ SELECT a, d FROM t1, t2 WHERE (a = 2 OR a = 3) AND d = a
+ }
+} {2 2 3 3 0 0}
+
+do_test where8-3.5 {
+ execsql_status {
+ SELECT a, d FROM t1, t2 WHERE (a = 2 OR a = 3) AND (d = a OR e = 'sixteen')
+ }
+} {2 2 2 4 3 3 3 4 0 0}
+
+do_test where8-3.6 {
+ # The first part of the WHERE clause in this query, (a=2 OR a=3) is
+ # transformed into "a IN (2, 3)". This is why the sort is required.
+ #
+ execsql_status {
+ SELECT a, d
+ FROM t1, t2
+ WHERE (a = 2 OR a = 3) AND (d = a OR e = 'sixteen')
+ ORDER BY t1.rowid
+ }
+} {2 2 2 4 3 3 3 4 0 1}
+do_test where8-3.7 {
+ execsql_status {
+ SELECT a, d
+ FROM t1, t2
+ WHERE a = 2 AND (d = a OR e = 'sixteen')
+ ORDER BY t1.rowid
+ }
+} {2 2 2 4 0 0}
+do_test where8-3.8 {
+ execsql_status {
+ SELECT a, d
+ FROM t1, t2
+ WHERE (a = 2 OR b = 'three') AND (d = a OR e = 'sixteen')
+ ORDER BY t1.rowid
+ }
+} {2 2 2 4 3 3 3 4 0 1}
+
+do_test where8-3.9 {
+ # The "OR c = 'IX'" term forces a linear scan.
+ execsql_status {
+ SELECT a, d
+ FROM t1, t2
+ WHERE (a = 2 OR b = 'three' OR c = 'IX') AND (d = a OR e = 'sixteen')
+ ORDER BY t1.rowid
+ }
+} {2 2 2 4 3 3 3 4 9 9 9 4 9 0}
+
+do_test where8-3.10 {
+ execsql_status {
+ SELECT d FROM t2 WHERE e IS NULL OR e = 'four'
+ }
+} {1 3 5 10 2 0 0}
+
+do_test where8-3.11 {
+ execsql_status {
+ SELECT a, d FROM t1, t2 WHERE (a=d OR b=e) AND a<5 ORDER BY a
+ }
+} {1 1 2 2 3 3 4 2 4 4 0 0}
+do_test where8-3.12 {
+ execsql_status {
+ SELECT a, d FROM t1, t2 WHERE (a=d OR b=e) AND +a<5 ORDER BY a
+ }
+} {1 1 2 2 3 3 4 2 4 4 0 0}
+do_test where8-3.13 {
+ execsql_status {
+ SELECT a, d FROM t1, t2 WHERE (a=d OR b=e) AND +a<5
+ }
+} {1 1 2 2 3 3 4 2 4 4 9 0}
+
+do_test where8-3.14 {
+ execsql_status {
+ SELECT c FROM t1 WHERE a > (SELECT d FROM t2 WHERE e = b) OR a = 5
+ }
+} {IV V 9 0}
+
+do_test where8-3.15 {
+ execsql_status {
+ SELECT c FROM t1, t2 WHERE a BETWEEN 1 AND 2 OR a = (
+ SELECT sum(e IS NULL) FROM t2 AS inner WHERE t2.d>inner.d
+ )
+ ORDER BY c
+ }
+} {I I I I I I I I I I II II II II II II II II II II III III III III III 9 1}
+
+#-----------------------------------------------------------------------
+# The following tests - where8-4.* - verify that adding or removing
+# indexes does not change the results returned by various queries.
+#
+do_test where8-4.1 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t3(a INTEGER, b REAL, c TEXT);
+ CREATE TABLE t4(f INTEGER, g REAL, h TEXT);
+ INSERT INTO t3 VALUES('hills', NULL, 1415926535);
+ INSERT INTO t3 VALUES('and', 'of', NULL);
+ INSERT INTO t3 VALUES('have', 'towering', 53594.08128);
+ INSERT INTO t3 VALUES(NULL, 45.64856692, 'Not');
+ INSERT INTO t3 VALUES('same', 5028841971, NULL);
+ INSERT INTO t3 VALUES('onlookers', 'in', 8214808651);
+ INSERT INTO t3 VALUES(346.0348610, 2643383279, NULL);
+ INSERT INTO t3 VALUES(1415926535, 'of', 'are');
+ INSERT INTO t3 VALUES(NULL, 0.4811174502, 'snapshots');
+ INSERT INTO t3 VALUES('over', 'the', 8628034825);
+ INSERT INTO t3 VALUES(8628034825, 66.59334461, 2847564.823);
+ INSERT INTO t3 VALUES('onlookers', 'same', 'and');
+ INSERT INTO t3 VALUES(NULL, 'light', 6939937510);
+ INSERT INTO t3 VALUES('from', 'their', 'viewed');
+ INSERT INTO t3 VALUES('from', 'Alpine', 'snapshots');
+ INSERT INTO t3 VALUES('from', 'sometimes', 'unalike');
+ INSERT INTO t3 VALUES(1339.360726, 'light', 'have');
+ INSERT INTO t3 VALUES(6939937510, 3282306647, 'other');
+ INSERT INTO t3 VALUES('paintings', 8628034825, 'all');
+ INSERT INTO t3 VALUES('paintings', NULL, 'same');
+ INSERT INTO t3 VALUES('Alpine', 378678316.5, 'unalike');
+ INSERT INTO t3 VALUES('Alpine', NULL, 'same');
+ INSERT INTO t3 VALUES(1339.360726, 2847564.823, 'over');
+ INSERT INTO t3 VALUES('villages', 'their', 'have');
+ INSERT INTO t3 VALUES('unalike', 'remarkably', 'in');
+ INSERT INTO t3 VALUES('and', 8979323846, 'and');
+ INSERT INTO t3 VALUES(NULL, 1415926535, 'an');
+ INSERT INTO t3 VALUES(271.2019091, 8628034825, 0.4811174502);
+ INSERT INTO t3 VALUES('all', 3421170679, 'the');
+ INSERT INTO t3 VALUES('Not', 'and', 1415926535);
+ INSERT INTO t3 VALUES('of', 'other', 'light');
+ INSERT INTO t3 VALUES(NULL, 'towering', 'Not');
+ INSERT INTO t3 VALUES(346.0348610, NULL, 'other');
+ INSERT INTO t3 VALUES('Not', 378678316.5, NULL);
+ INSERT INTO t3 VALUES('snapshots', 8628034825, 'of');
+ INSERT INTO t3 VALUES(3282306647, 271.2019091, 'and');
+ INSERT INTO t3 VALUES(50.58223172, 378678316.5, 5028841971);
+ INSERT INTO t3 VALUES(50.58223172, 2643383279, 'snapshots');
+ INSERT INTO t3 VALUES('writings', 8979323846, 8979323846);
+ INSERT INTO t3 VALUES('onlookers', 'his', 'in');
+ INSERT INTO t3 VALUES('unalike', 8628034825, 1339.360726);
+ INSERT INTO t3 VALUES('of', 'Alpine', 'and');
+ INSERT INTO t3 VALUES('onlookers', NULL, 'from');
+ INSERT INTO t3 VALUES('writings', 'it', 1339.360726);
+ INSERT INTO t3 VALUES('it', 'and', 'villages');
+ INSERT INTO t3 VALUES('an', 'the', 'villages');
+ INSERT INTO t3 VALUES(8214808651, 8214808651, 'same');
+ INSERT INTO t3 VALUES(346.0348610, 'light', 1415926535);
+ INSERT INTO t3 VALUES(NULL, 8979323846, 'and');
+ INSERT INTO t3 VALUES(NULL, 'same', 1339.360726);
+ INSERT INTO t4 VALUES('his', 'from', 'an');
+ INSERT INTO t4 VALUES('snapshots', 'or', NULL);
+ INSERT INTO t4 VALUES('Alpine', 'have', 'it');
+ INSERT INTO t4 VALUES('have', 'peak', 'remarkably');
+ INSERT INTO t4 VALUES('hills', NULL, 'Not');
+ INSERT INTO t4 VALUES('same', 'from', 2643383279);
+ INSERT INTO t4 VALUES('have', 'angle', 8628034825);
+ INSERT INTO t4 VALUES('sometimes', 'it', 2847564.823);
+ INSERT INTO t4 VALUES(0938446095, 'peak', 'of');
+ INSERT INTO t4 VALUES(8628034825, 'and', 'same');
+ INSERT INTO t4 VALUES('and', 271.2019091, 'their');
+ INSERT INTO t4 VALUES('the', 'of', 'remarkably');
+ INSERT INTO t4 VALUES('and', 3421170679, 1415926535);
+ INSERT INTO t4 VALUES('and', 'in', 'all');
+ INSERT INTO t4 VALUES(378678316.5, 0.4811174502, 'snapshots');
+ INSERT INTO t4 VALUES('it', 'are', 'have');
+ INSERT INTO t4 VALUES('angle', 'snapshots', 378678316.5);
+ INSERT INTO t4 VALUES('from', 1415926535, 8628034825);
+ INSERT INTO t4 VALUES('snapshots', 'angle', 'have');
+ INSERT INTO t4 VALUES(3421170679, 0938446095, 'Not');
+ INSERT INTO t4 VALUES('peak', NULL, 0.4811174502);
+ INSERT INTO t4 VALUES('same', 'have', 'Alpine');
+ INSERT INTO t4 VALUES(271.2019091, 66.59334461, 0938446095);
+ INSERT INTO t4 VALUES(8979323846, 'his', 'an');
+ INSERT INTO t4 VALUES(NULL, 'and', 3282306647);
+ INSERT INTO t4 VALUES('remarkably', NULL, 'Not');
+ INSERT INTO t4 VALUES('villages', 4543.266482, 'his');
+ INSERT INTO t4 VALUES(2643383279, 'paintings', 'onlookers');
+ INSERT INTO t4 VALUES(1339.360726, 'of', 'the');
+ INSERT INTO t4 VALUES('peak', 'other', 'peak');
+ INSERT INTO t4 VALUES('it', 'or', 8979323846);
+ INSERT INTO t4 VALUES('onlookers', 'Not', 'towering');
+ INSERT INTO t4 VALUES(NULL, 'peak', 'Not');
+ INSERT INTO t4 VALUES('of', 'have', 6939937510);
+ INSERT INTO t4 VALUES('light', 'hills', 0.4811174502);
+ INSERT INTO t4 VALUES(5028841971, 'Not', 'it');
+ INSERT INTO t4 VALUES('and', 'Not', NULL);
+ INSERT INTO t4 VALUES(346.0348610, 'villages', NULL);
+ INSERT INTO t4 VALUES(8979323846, NULL, 6939937510);
+ INSERT INTO t4 VALUES('an', 'light', 'peak');
+ INSERT INTO t4 VALUES(5028841971, 6939937510, 'light');
+ INSERT INTO t4 VALUES('sometimes', 'peak', 'peak');
+ INSERT INTO t4 VALUES(378678316.5, 5028841971, 'an');
+ INSERT INTO t4 VALUES(378678316.5, 'his', 'Alpine');
+ INSERT INTO t4 VALUES('from', 'of', 'all');
+ INSERT INTO t4 VALUES(0938446095, 'same', NULL);
+ INSERT INTO t4 VALUES(0938446095, 'Alpine', NULL);
+ INSERT INTO t4 VALUES('his', 'of', 378678316.5);
+ INSERT INTO t4 VALUES(271.2019091, 'viewed', 3282306647);
+ INSERT INTO t4 VALUES('hills', 'all', 'peak');
+ CREATE TABLE t5(s);
+ INSERT INTO t5 VALUES('tab-t5');
+ CREATE TABLE t6(t);
+ INSERT INTO t6 VALUES(123456);
+ COMMIT;
+ }
+} {}
+
+catch {unset results}
+catch {unset A}
+catch {unset B}
+
+set A 2
+foreach idxsql {
+ {
+ /* No indexes */
+ } {
+ CREATE INDEX i5 ON t3(a);
+ } {
+ CREATE INDEX i5 ON t3(a, b);
+ CREATE INDEX i6 ON t4(f);
+ } {
+ CREATE UNIQUE INDEX i5 ON t3(a, b);
+ CREATE INDEX i7 ON t3(c);
+ CREATE INDEX i6 ON t4(f);
+ CREATE INDEX i8 ON t4(h);
+ } {
+ CREATE INDEX i5 ON t3(a, b, c);
+ CREATE INDEX i6 ON t4(f, g, h);
+ CREATE INDEX i7 ON t3(c, b, a);
+ CREATE INDEX i8 ON t4(h, g, f);
+ }
+} {
+
+ execsql {
+ DROP INDEX IF EXISTS i5;
+ DROP INDEX IF EXISTS i6;
+ DROP INDEX IF EXISTS i7;
+ DROP INDEX IF EXISTS i8;
+ }
+ execsql $idxsql
+
+ foreach {B sql} {
+ 1 { SELECT * FROM t3 WHERE c LIKE b }
+ 2 { SELECT * FROM t3 WHERE c||'' LIKE 'the%' }
+ 3 { SELECT * FROM t3 WHERE rowid LIKE '12%' }
+ 4 { SELECT * FROM t3 WHERE +c LIKE 'the%' }
+ 5 { SELECT * FROM t3 WHERE c LIKE 'the%' }
+ 6 { SELECT * FROM t3 WHERE c GLOB '*llo' }
+
+ 7 { SELECT * FROM t3 WHERE a = 'angle' }
+ 8 { SELECT * FROM t3 WHERE a = 'it' OR b = 6939937510 }
+ 9 { SELECT * FROM t3, t4 WHERE a = 'painting' OR a = 'are' OR a = f }
+10 { SELECT * FROM t3, t4 WHERE a = 'all' OR a = 'and' OR a = h }
+11 { SELECT * FROM t3, t4 WHERE a < 'of' OR b > 346 AND c IS NULL }
+12 { SELECT * FROM t3, t4 WHERE 'the' > a OR b > 'have' AND c = 1415926535 }
+
+13 { SELECT * FROM t3 WHERE a BETWEEN 'one' AND 'two' OR a = 3421170679 }
+14 { SELECT * FROM t3 WHERE a BETWEEN 'one' AND 'two' OR a IS NULL }
+15 { SELECT * FROM t3 WHERE c > 'one' OR c >= 'one' OR c LIKE 'one%' }
+16 { SELECT * FROM t3 WHERE c > 'one' OR c = c OR c = a }
+17 { SELECT * FROM t3 WHERE c IS NULL OR a >= 'peak' }
+18 { SELECT * FROM t3 WHERE c IN ('other', 'all', 'snapshots') OR a>1 }
+19 { SELECT * FROM t3 WHERE c IN ('other', 'all', 'snapshots') AND a>1 }
+20 { SELECT * FROM t3 WHERE c IS NULL AND a>'one' }
+21 { SELECT * FROM t3 WHERE c IS NULL OR a>'one' }
+22 { SELECT * FROM t3 WHERE b = b AND a > 'are' }
+23 { SELECT * FROM t3 WHERE c <= b OR b < 'snapshots' }
+24 { SELECT * FROM t3 WHERE 'onlookers' >= c AND a <= b OR b = 'angle' }
+25 { SELECT * FROM t3 WHERE b = 'from' }
+26 { SELECT * FROM t3 WHERE b = 4543.266482 }
+27 { SELECT * FROM t3 WHERE c < 3282306647 }
+28 { SELECT * FROM t3 WHERE c IS NULL AND b >= c }
+29 { SELECT * FROM t3 WHERE b > 0.4811174502 AND c = 'other' AND 'viewed' > a }
+30 { SELECT * FROM t3 WHERE c = 'peak' }
+31 { SELECT * FROM t3 WHERE c < 53594.08128 OR c <= b }
+32 { SELECT * FROM t3 WHERE 'writings' <= b }
+33 { SELECT * FROM t3 WHERE 2643383279 = b OR c < b AND b <= 3282306647 }
+34 { SELECT * FROM t3 WHERE a IS NULL }
+35 { SELECT * FROM t3 WHERE 'writings' = a OR b = 378678316.5 }
+36 { SELECT * FROM t3 WHERE 'and' >= c }
+37 { SELECT * FROM t3 WHERE c < 'from' }
+38 { SELECT * FROM t3 WHERE 'his' < c OR b < b }
+39 { SELECT * FROM t3 WHERE 53594.08128 = b AND c >= b }
+40 { SELECT * FROM t3 WHERE 'unalike' < c AND 'are' >= c AND a <= b }
+41 { SELECT * FROM t3 WHERE b >= 4543.266482 OR 'Alpine' > a OR 271.2019091 <= a }
+42 { SELECT * FROM t3 WHERE b = c }
+43 { SELECT * FROM t3 WHERE c > a AND b < 'all' }
+44 { SELECT * FROM t3 WHERE c BETWEEN 'hills' AND 'snapshots' AND c <= 'the' OR c = a }
+45 { SELECT * FROM t3 WHERE b > c AND c >= 'hills' }
+46 { SELECT * FROM t3 WHERE b > 'or' OR a <= 'hills' OR c IS NULL }
+47 { SELECT * FROM t3 WHERE c > b OR b BETWEEN 1339.360726 AND 'onlookers' OR 1415926535 >= b }
+48 { SELECT * FROM t3 WHERE a IS NULL }
+49 { SELECT * FROM t3 WHERE a > 'other' }
+50 { SELECT * FROM t3 WHERE 'the' <= c AND a <= c }
+51 { SELECT * FROM t3 WHERE 346.0348610 = a AND c = b }
+52 { SELECT * FROM t3 WHERE c BETWEEN 50.58223172 AND 'same' AND a < b }
+53 { SELECT * FROM t3 WHERE 'Alpine' <= b AND c >= 'angle' OR b <= 271.2019091 }
+54 { SELECT * FROM t3 WHERE a < a AND 1415926535 > b }
+55 { SELECT * FROM t3 WHERE c > a AND 'have' >= c }
+56 { SELECT * FROM t3 WHERE b <= b AND c > b }
+57 { SELECT * FROM t3 WHERE a IS NULL AND c <= c }
+58 { SELECT * FROM t3 WHERE b < c OR b = c }
+59 { SELECT * FROM t3 WHERE c < b AND b >= 'it' }
+60 { SELECT * FROM t3 WHERE a = b AND a <= b OR b >= a }
+61 { SELECT * FROM t3 WHERE b = c }
+62 { SELECT * FROM t3 WHERE c BETWEEN 'the' AND 271.2019091 OR c <= 3282306647 AND c >= b }
+63 { SELECT * FROM t3 WHERE c >= c AND c < 'writings' }
+64 { SELECT * FROM t3 WHERE c <= 3282306647 AND b > a OR 'unalike' <= a }
+65 { SELECT * FROM t3 WHERE a > c }
+66 { SELECT * FROM t3 WHERE c = 'it' OR b >= b }
+67 { SELECT * FROM t3 WHERE c = a OR b < c }
+68 { SELECT * FROM t3 WHERE b > a }
+69 { SELECT * FROM t3 WHERE a < b OR a > 4543.266482 OR 'same' = b }
+70 { SELECT * FROM t3 WHERE c < c OR b <= c OR a <= b }
+71 { SELECT * FROM t3 WHERE c > a }
+72 { SELECT * FROM t3 WHERE c > b }
+73 { SELECT * FROM t3 WHERE b <= a }
+74 { SELECT * FROM t3 WHERE 3282306647 < b AND a >= 'or' OR a >= 378678316.5 }
+75 { SELECT * FROM t3 WHERE 50.58223172 <= c OR c = c AND b < b }
+76 { SELECT * FROM t3 WHERE 'and' < b OR b < c OR c > 1339.360726 }
+77 { SELECT * FROM t3 WHERE b <= c }
+78 { SELECT * FROM t3 WHERE 'in' <= c }
+79 { SELECT * FROM t3 WHERE c <= b AND a > a AND c < b }
+80 { SELECT * FROM t3 WHERE 'over' < b }
+81 { SELECT * FROM t3 WHERE b >= b OR b < c OR a < b }
+82 { SELECT * FROM t3 WHERE 'towering' <= b OR 'towering' = a AND c > b }
+83 { SELECT * FROM t3 WHERE 'peak' = a OR b BETWEEN 2643383279 AND 'the' }
+84 { SELECT * FROM t3 WHERE 'an' < c AND c > 'the' AND c IS NULL }
+85 { SELECT * FROM t3 WHERE a <= 'sometimes' AND a BETWEEN 'unalike' AND 1339.360726 }
+86 { SELECT * FROM t3 WHERE 1339.360726 < c AND c IS NULL }
+87 { SELECT * FROM t3 WHERE b > 'the' }
+88 { SELECT * FROM t3 WHERE 'and' = a }
+89 { SELECT * FROM t3 WHERE b >= b }
+90 { SELECT * FROM t3 WHERE b >= 8979323846 }
+91 { SELECT * FROM t3 WHERE c <= a }
+92 { SELECT * FROM t3 WHERE a BETWEEN 'have' AND 'light' OR a > b OR a >= 378678316.5 }
+93 { SELECT * FROM t3 WHERE c > 3282306647 }
+94 { SELECT * FROM t3 WHERE b > c }
+95 { SELECT * FROM t3 WHERE b >= a AND 'villages' > a AND b >= c }
+96 { SELECT * FROM t3 WHERE 'angle' > a }
+97 { SELECT * FROM t3 WHERE 'paintings' >= a }
+98 { SELECT * FROM t3 WHERE 'or' >= c }
+99 { SELECT * FROM t3 WHERE c < b }
+
+
+101 { SELECT * FROM t3, t4 WHERE f < 'sometimes' OR 'over' <= g AND h < 1415926535 }
+102 { SELECT * FROM t3, t4 WHERE h >= 'from' AND h < 6939937510 OR g > h }
+103 { SELECT * FROM t3, t4 WHERE c <= h AND g = h AND c >= 'all' }
+104 { SELECT * FROM t3, t4 WHERE c = a }
+105 { SELECT * FROM t3, t4 WHERE 'of' >= h }
+106 { SELECT * FROM t3, t4 WHERE f >= b AND a < g AND h < 'and' }
+107 { SELECT * FROM t3, t4 WHERE f <= 8628034825 AND 0938446095 >= b }
+108 { SELECT * FROM t3, t4 WHERE a < 'the' }
+109 { SELECT * FROM t3, t4 WHERE f = 'sometimes' OR b < 'of' }
+110 { SELECT * FROM t3, t4 WHERE c IS NULL }
+111 { SELECT * FROM t3, t4 WHERE 'have' = b OR g <= 346.0348610 }
+112 { SELECT * FROM t3, t4 WHERE f > b AND b <= h }
+113 { SELECT * FROM t3, t4 WHERE f > c OR 'the' = a OR 50.58223172 = a }
+114 { SELECT * FROM t3, t4 WHERE 2643383279 <= a AND c = a }
+115 { SELECT * FROM t3, t4 WHERE h >= b AND 'it' <= b }
+116 { SELECT * FROM t3, t4 WHERE g BETWEEN 'from' AND 'peak' }
+117 { SELECT * FROM t3, t4 WHERE 'their' > a AND g > b AND f <= c }
+118 { SELECT * FROM t3, t4 WHERE h = 5028841971 AND 'unalike' <= f }
+119 { SELECT * FROM t3, t4 WHERE c IS NULL AND a = 3282306647 OR a <= 'Alpine' }
+120 { SELECT * FROM t3, t4 WHERE 'sometimes' <= f OR 8214808651 >= a AND b <= 53594.08128 }
+121 { SELECT * FROM t3, t4 WHERE 6939937510 <= f OR c < f OR 'sometimes' = c }
+122 { SELECT * FROM t3, t4 WHERE b < 'onlookers' AND 'paintings' = g AND c <= h }
+123 { SELECT * FROM t3, t4 WHERE a BETWEEN 'all' AND 'from' OR c > 346.0348610 }
+124 { SELECT * FROM t3, t4 WHERE 'from' <= b OR a BETWEEN 53594.08128 AND 'their' AND c > a }
+125 { SELECT * FROM t3, t4 WHERE h = 2643383279 }
+126 { SELECT * FROM t3, t4 WHERE a <= 'the' }
+127 { SELECT * FROM t3, t4 WHERE h <= c }
+128 { SELECT * FROM t3, t4 WHERE g <= 346.0348610 AND 66.59334461 >= f AND f <= f }
+129 { SELECT * FROM t3, t4 WHERE g >= c OR 'in' < b OR b > g }
+130 { SELECT * FROM t3, t4 WHERE 'over' > g AND b BETWEEN 'unalike' AND 'remarkably' }
+131 { SELECT * FROM t3, t4 WHERE h <= 2847564.823 }
+132 { SELECT * FROM t3, t4 WHERE h <= 'remarkably' AND 4543.266482 > h }
+133 { SELECT * FROM t3, t4 WHERE a >= c AND 'it' > g AND c < c }
+134 { SELECT * FROM t3, t4 WHERE h <= 66.59334461 AND b > 3421170679 }
+135 { SELECT * FROM t3, t4 WHERE h < 'are' OR f BETWEEN 0938446095 AND 'are' OR b = b }
+136 { SELECT * FROM t3, t4 WHERE h = a OR 66.59334461 <= f }
+137 { SELECT * FROM t3, t4 WHERE f > 'of' OR h <= h OR a = f }
+138 { SELECT * FROM t3, t4 WHERE 'other' >= g }
+139 { SELECT * FROM t3, t4 WHERE b <= 3421170679 }
+140 { SELECT * FROM t3, t4 WHERE 'all' = f AND 4543.266482 = b OR f BETWEEN 'and' AND 'angle' }
+141 { SELECT * FROM t3, t4 WHERE 'light' = f OR h BETWEEN 'remarkably' AND 1415926535 }
+142 { SELECT * FROM t3, t4 WHERE 'hills' = f OR 'the' >= f }
+143 { SELECT * FROM t3, t4 WHERE a > 346.0348610 }
+144 { SELECT * FROM t3, t4 WHERE 5028841971 = h }
+145 { SELECT * FROM t3, t4 WHERE b >= c AND 'the' >= g OR 45.64856692 <= g }
+146 { SELECT * FROM t3, t4 WHERE c < 5028841971 }
+147 { SELECT * FROM t3, t4 WHERE a > a }
+148 { SELECT * FROM t3, t4 WHERE c = 'snapshots' }
+149 { SELECT * FROM t3, t4 WHERE h > 1339.360726 AND 'and' > c }
+150 { SELECT * FROM t3, t4 WHERE 'and' > g OR 'sometimes' = c }
+151 { SELECT * FROM t3, t4 WHERE g >= 'the' AND b >= 'onlookers' }
+152 { SELECT * FROM t3, t4 WHERE h BETWEEN 'other' AND 2643383279 }
+153 { SELECT * FROM t3, t4 WHERE 'it' = b }
+154 { SELECT * FROM t3, t4 WHERE f = c OR c BETWEEN 'and' AND 0.4811174502 }
+155 { SELECT * FROM t3, t4 WHERE b <= 'sometimes' OR c <= 0938446095 }
+156 { SELECT * FROM t3, t4 WHERE 'and' <= b }
+157 { SELECT * FROM t3, t4 WHERE g > a AND f = 'the' AND b < a }
+158 { SELECT * FROM t3, t4 WHERE a < 'an' }
+159 { SELECT * FROM t3, t4 WHERE a BETWEEN 'his' AND 'same' OR 8628034825 > f }
+160 { SELECT * FROM t3, t4 WHERE b = 'peak' }
+161 { SELECT * FROM t3, t4 WHERE f IS NULL AND a >= h }
+162 { SELECT * FROM t3, t4 WHERE a IS NULL OR 2643383279 = c }
+163 { SELECT * FROM t3, t4 WHERE b >= 5028841971 AND f < c AND a IS NULL }
+164 { SELECT * FROM t3, t4 WHERE a >= g }
+165 { SELECT * FROM t3, t4 WHERE c IS NULL }
+166 { SELECT * FROM t3, t4 WHERE h >= h }
+167 { SELECT * FROM t3, t4 WHERE 'over' <= h }
+168 { SELECT * FROM t3, t4 WHERE b < 4543.266482 OR b = 2643383279 OR 8628034825 < b }
+169 { SELECT * FROM t3, t4 WHERE g >= 6939937510 }
+170 { SELECT * FROM t3, t4 WHERE 'or' < a OR b < g }
+171 { SELECT * FROM t3, t4 WHERE h < 'hills' OR 'and' > g }
+172 { SELECT * FROM t3, t4 WHERE 'from' > f OR f <= f }
+173 { SELECT * FROM t3, t4 WHERE 'viewed' > b AND f < c }
+174 { SELECT * FROM t3, t4 WHERE 'of' <= a }
+175 { SELECT * FROM t3, t4 WHERE f > 0938446095 }
+176 { SELECT * FROM t3, t4 WHERE a = g }
+177 { SELECT * FROM t3, t4 WHERE g >= b AND f BETWEEN 'peak' AND 'and' }
+178 { SELECT * FROM t3, t4 WHERE g = a AND 'it' > f }
+179 { SELECT * FROM t3, t4 WHERE a <= b OR 'from' > f }
+180 { SELECT * FROM t3, t4 WHERE f < 'and' }
+181 { SELECT * FROM t3, t4 WHERE 6939937510 < b OR 'sometimes' < h }
+182 { SELECT * FROM t3, t4 WHERE f > g AND f < 'peak' }
+183 { SELECT * FROM t3, t4 WHERE a <= 53594.08128 AND c <= f AND f >= c }
+184 { SELECT * FROM t3, t4 WHERE f = c OR 'it' > b OR g BETWEEN 'the' AND 'all' }
+185 { SELECT * FROM t3, t4 WHERE c <= g OR a = h }
+186 { SELECT * FROM t3, t4 WHERE 'same' = b OR c >= 2643383279 }
+187 { SELECT * FROM t3, t4 WHERE h <= g OR c > 66.59334461 OR a <= f }
+188 { SELECT * FROM t3, t4 WHERE b < c AND f = 'writings' }
+189 { SELECT * FROM t3, t4 WHERE b < a }
+190 { SELECT * FROM t3, t4 WHERE c >= f OR c = 'and' }
+191 { SELECT * FROM t3, t4 WHERE f >= 'peak' AND g > f AND h > g }
+192 { SELECT * FROM t3, t4 WHERE a >= 8979323846 AND 'same' > b OR c = 'and' }
+193 { SELECT * FROM t3, t4 WHERE c >= g OR 'writings' >= c AND b = 'all' }
+194 { SELECT * FROM t3, t4 WHERE 'remarkably' < g }
+195 { SELECT * FROM t3, t4 WHERE a BETWEEN 'or' AND 'paintings' AND g <= f }
+196 { SELECT * FROM t3, t4 WHERE 0938446095 > b OR g <= a OR h > b }
+197 { SELECT * FROM t3, t4 WHERE g = 2643383279 AND f = g }
+198 { SELECT * FROM t3, t4 WHERE g < 8979323846 }
+199 { SELECT * FROM t3, t4 WHERE 'are' <= b }
+200 { SELECT * FROM t3, t4 WHERE (a=1415926535 AND f=8628034825)
+ OR (a=6939937510 AND f=2643383279) }
+201 { SELECT * FROM t3, t4, t5, t6
+ WHERE (a=1415926535 AND f=8628034825 AND s!='hello' AND t!=5)
+ OR (a=6939937510 AND f=2643383279 AND s='tab-t5' AND t=123456) }
+202 { SELECT * FROM t3, t4, t5, t6
+ WHERE (a=1415926535 AND f=8628034825 AND s!='hello' AND t==5)
+ OR (a=6939937510 AND f=2643383279 AND s='tab-t5' AND t!=123456) }
+
+ } {
+ do_test where8-4.$A.$B.1 {
+ unset -nocomplain R
+ set R [execsql $sql]
+ if {![info exists results($B)]} {
+ set results($B) $R
+ }
+ list
+ } {}
+
+ do_test where8-4.$A.$B.2 { lsort $R } [lsort $results($B)]
+ }
+ incr A
+}
+catch {unset results}
+catch {unset A}
+catch {unset B}
+
+# At one point the following tests provoked an invalid write error (writing
+# to memory that had already been freed). It was not possible to demonstrate
+# that this bug could cause a query to return bad data.
+#
+do_test where8-5.1 {
+ db close
+ sqlite3 db test.db
+ sqlite3_db_config_lookaside db 0 0 0
+ execsql {
+ CREATE TABLE tA(
+ a, b, c, d, e, f, g, h,
+ i, j, k, l, m, n, o, p
+ );
+ }
+ execsql {
+ SELECT * FROM tA WHERE
+ a=1 AND b=2 AND c=3 AND d=4 AND e=5 AND f=6 AND g=7 AND h=8 AND
+ i=1 AND j=2 AND k=3 AND l=4 AND m=5 AND n=6 AND o=7 AND
+ (p = 1 OR p = 2 OR p = 3)
+ }
+} {}
+do_test where8-5.2 {
+ execsql {
+ SELECT * FROM tA WHERE
+ a=1 AND b=2 AND c=3 AND d=4 AND e=5 AND f=6 AND g=7 AND h=8 AND
+ i=1 AND j=2 AND k=3 AND l=4 AND m=5 AND
+ (p = 1 OR p = 2 OR p = 3) AND n=6 AND o=7
+ }
+} {}
+do_test where8-5.3 {
+ execsql {
+ INSERT INTO tA VALUES(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8);
+ CREATE UNIQUE INDEX tAI ON tA(p);
+ CREATE TABLE tB(x);
+ INSERT INTO tB VALUES('x');
+ }
+ execsql {
+ SELECT a, x FROM tA LEFT JOIN tB ON (
+ a=1 AND b=2 AND c=3 AND d=4 AND e=5 AND f=6 AND g=7 AND h=8 AND
+ i=1 AND j=2 AND k=3 AND l=4 AND m=5 AND n=6 AND o=7 AND
+ (p = 1 OR p = 2 OR p = 3)
+ )
+ }
+} {1 {}}
+
+finish_test
diff --git a/test/where8m.test b/test/where8m.test
new file mode 100644
index 0000000..4fce3db
--- /dev/null
+++ b/test/where8m.test
@@ -0,0 +1,57 @@
+# 2008 December 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus
+# is testing of where.c. More specifically, the focus is the optimization
+# of WHERE clauses that feature the OR operator.
+#
+# $Id: where8m.test,v 1.3 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+source $testdir/malloc_common.tcl
+
+do_malloc_test where8m-1 -sqlprep {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+} -sqlbody {
+ SELECT c FROM t1
+ WHERE
+ a = 2 OR b = 'three' OR a = 4 OR b = 'five' OR a = 6 OR
+ b = 'seven' OR a = 8 OR b = 'nine' OR a = 10
+ ORDER BY rowid;
+
+ SELECT c FROM t1 WHERE
+ a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6;
+
+ SELECT c FROM t1 WHERE
+ a BETWEEN 1 AND 3 AND b < 5 AND b > 2 AND c = 4;
+}
+
+do_malloc_test where8m-2 -tclprep {
+ db eval {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+ }
+ for {set i 0} {$i < 1000} {incr i} {
+ set ii [expr $i*$i]
+ set iii [expr $i*$i]
+ db eval { INSERT INTO t1 VALUES($i, $ii, $iii) }
+ }
+ db eval COMMIT
+} -sqlbody {
+ SELECT count(*) FROM t1 WHERE a BETWEEN 5 AND 995 OR b BETWEEN 5 AND 900000;
+}
+
+finish_test
diff --git a/test/where9.test b/test/where9.test
new file mode 100644
index 0000000..b4a2d8d
--- /dev/null
+++ b/test/where9.test
@@ -0,0 +1,860 @@
+# 2008 December 30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the multi-index OR clause optimizer.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !or_opt {
+ finish_test
+ return
+}
+
+# Evaluate SQL. Return the result set followed by the
+# and the number of full-scan steps.
+#
+proc count_steps {sql} {
+ set r [db eval $sql]
+ lappend r scan [db status step] sort [db status sort]
+}
+
+
+# Construct test data.
+#
+do_test where9-1.1 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d,e,f,g);
+ INSERT INTO t1 VALUES(1,11,1001,1.001,100.1,'bcdefghij','yxwvuts');
+ INSERT INTO t1 VALUES(2,22,1001,2.002,100.1,'cdefghijk','yxwvuts');
+ INSERT INTO t1 VALUES(3,33,1001,3.003,100.1,'defghijkl','xwvutsr');
+ INSERT INTO t1 VALUES(4,44,2002,4.004,200.2,'efghijklm','xwvutsr');
+ INSERT INTO t1 VALUES(5,55,2002,5.005,200.2,'fghijklmn','xwvutsr');
+ INSERT INTO t1 VALUES(6,66,2002,6.006,200.2,'ghijklmno','xwvutsr');
+ INSERT INTO t1 VALUES(7,77,3003,7.007,300.3,'hijklmnop','xwvutsr');
+ INSERT INTO t1 VALUES(8,88,3003,8.008,300.3,'ijklmnopq','wvutsrq');
+ INSERT INTO t1 VALUES(9,99,3003,9.009,300.3,'jklmnopqr','wvutsrq');
+ INSERT INTO t1 VALUES(10,110,4004,10.01,400.4,'klmnopqrs','wvutsrq');
+ INSERT INTO t1 VALUES(11,121,4004,11.011,400.4,'lmnopqrst','wvutsrq');
+ INSERT INTO t1 VALUES(12,132,4004,12.012,400.4,'mnopqrstu','wvutsrq');
+ INSERT INTO t1 VALUES(13,143,5005,13.013,500.5,'nopqrstuv','vutsrqp');
+ INSERT INTO t1 VALUES(14,154,5005,14.014,500.5,'opqrstuvw','vutsrqp');
+ INSERT INTO t1 VALUES(15,165,5005,15.015,500.5,'pqrstuvwx','vutsrqp');
+ INSERT INTO t1 VALUES(16,176,6006,16.016,600.6,'qrstuvwxy','vutsrqp');
+ INSERT INTO t1 VALUES(17,187,6006,17.017,600.6,'rstuvwxyz','vutsrqp');
+ INSERT INTO t1 VALUES(18,198,6006,18.018,600.6,'stuvwxyza','utsrqpo');
+ INSERT INTO t1 VALUES(19,209,7007,19.019,700.7,'tuvwxyzab','utsrqpo');
+ INSERT INTO t1 VALUES(20,220,7007,20.02,700.7,'uvwxyzabc','utsrqpo');
+ INSERT INTO t1 VALUES(21,231,7007,21.021,700.7,'vwxyzabcd','utsrqpo');
+ INSERT INTO t1 VALUES(22,242,8008,22.022,800.8,'wxyzabcde','utsrqpo');
+ INSERT INTO t1 VALUES(23,253,8008,23.023,800.8,'xyzabcdef','tsrqpon');
+ INSERT INTO t1 VALUES(24,264,8008,24.024,800.8,'yzabcdefg','tsrqpon');
+ INSERT INTO t1 VALUES(25,275,9009,25.025,900.9,'zabcdefgh','tsrqpon');
+ INSERT INTO t1 VALUES(26,286,9009,26.026,900.9,'abcdefghi','tsrqpon');
+ INSERT INTO t1 VALUES(27,297,9009,27.027,900.9,'bcdefghij','tsrqpon');
+ INSERT INTO t1 VALUES(28,308,10010,28.028,1001.0,'cdefghijk','srqponm');
+ INSERT INTO t1 VALUES(29,319,10010,29.029,1001.0,'defghijkl','srqponm');
+ INSERT INTO t1 VALUES(30,330,10010,30.03,1001.0,'efghijklm','srqponm');
+ INSERT INTO t1 VALUES(31,341,11011,31.031,1101.1,'fghijklmn','srqponm');
+ INSERT INTO t1 VALUES(32,352,11011,32.032,1101.1,'ghijklmno','srqponm');
+ INSERT INTO t1 VALUES(33,363,11011,33.033,1101.1,'hijklmnop','rqponml');
+ INSERT INTO t1 VALUES(34,374,12012,34.034,1201.2,'ijklmnopq','rqponml');
+ INSERT INTO t1 VALUES(35,385,12012,35.035,1201.2,'jklmnopqr','rqponml');
+ INSERT INTO t1 VALUES(36,396,12012,36.036,1201.2,'klmnopqrs','rqponml');
+ INSERT INTO t1 VALUES(37,407,13013,37.037,1301.3,'lmnopqrst','rqponml');
+ INSERT INTO t1 VALUES(38,418,13013,38.038,1301.3,'mnopqrstu','qponmlk');
+ INSERT INTO t1 VALUES(39,429,13013,39.039,1301.3,'nopqrstuv','qponmlk');
+ INSERT INTO t1 VALUES(40,440,14014,40.04,1401.4,'opqrstuvw','qponmlk');
+ INSERT INTO t1 VALUES(41,451,14014,41.041,1401.4,'pqrstuvwx','qponmlk');
+ INSERT INTO t1 VALUES(42,462,14014,42.042,1401.4,'qrstuvwxy','qponmlk');
+ INSERT INTO t1 VALUES(43,473,15015,43.043,1501.5,'rstuvwxyz','ponmlkj');
+ INSERT INTO t1 VALUES(44,484,15015,44.044,1501.5,'stuvwxyza','ponmlkj');
+ INSERT INTO t1 VALUES(45,495,15015,45.045,1501.5,'tuvwxyzab','ponmlkj');
+ INSERT INTO t1 VALUES(46,506,16016,46.046,1601.6,'uvwxyzabc','ponmlkj');
+ INSERT INTO t1 VALUES(47,517,16016,47.047,1601.6,'vwxyzabcd','ponmlkj');
+ INSERT INTO t1 VALUES(48,528,16016,48.048,1601.6,'wxyzabcde','onmlkji');
+ INSERT INTO t1 VALUES(49,539,17017,49.049,1701.7,'xyzabcdef','onmlkji');
+ INSERT INTO t1 VALUES(50,550,17017,50.05,1701.7,'yzabcdefg','onmlkji');
+ INSERT INTO t1 VALUES(51,561,17017,51.051,1701.7,'zabcdefgh','onmlkji');
+ INSERT INTO t1 VALUES(52,572,18018,52.052,1801.8,'abcdefghi','onmlkji');
+ INSERT INTO t1 VALUES(53,583,18018,53.053,1801.8,'bcdefghij','nmlkjih');
+ INSERT INTO t1 VALUES(54,594,18018,54.054,1801.8,'cdefghijk','nmlkjih');
+ INSERT INTO t1 VALUES(55,605,19019,55.055,1901.9,'defghijkl','nmlkjih');
+ INSERT INTO t1 VALUES(56,616,19019,56.056,1901.9,'efghijklm','nmlkjih');
+ INSERT INTO t1 VALUES(57,627,19019,57.057,1901.9,'fghijklmn','nmlkjih');
+ INSERT INTO t1 VALUES(58,638,20020,58.058,2002.0,'ghijklmno','mlkjihg');
+ INSERT INTO t1 VALUES(59,649,20020,59.059,2002.0,'hijklmnop','mlkjihg');
+ INSERT INTO t1 VALUES(60,660,20020,60.06,2002.0,'ijklmnopq','mlkjihg');
+ INSERT INTO t1 VALUES(61,671,21021,61.061,2102.1,'jklmnopqr','mlkjihg');
+ INSERT INTO t1 VALUES(62,682,21021,62.062,2102.1,'klmnopqrs','mlkjihg');
+ INSERT INTO t1 VALUES(63,693,21021,63.063,2102.1,'lmnopqrst','lkjihgf');
+ INSERT INTO t1 VALUES(64,704,22022,64.064,2202.2,'mnopqrstu','lkjihgf');
+ INSERT INTO t1 VALUES(65,715,22022,65.065,2202.2,'nopqrstuv','lkjihgf');
+ INSERT INTO t1 VALUES(66,726,22022,66.066,2202.2,'opqrstuvw','lkjihgf');
+ INSERT INTO t1 VALUES(67,737,23023,67.067,2302.3,'pqrstuvwx','lkjihgf');
+ INSERT INTO t1 VALUES(68,748,23023,68.068,2302.3,'qrstuvwxy','kjihgfe');
+ INSERT INTO t1 VALUES(69,759,23023,69.069,2302.3,'rstuvwxyz','kjihgfe');
+ INSERT INTO t1 VALUES(70,770,24024,70.07,2402.4,'stuvwxyza','kjihgfe');
+ INSERT INTO t1 VALUES(71,781,24024,71.071,2402.4,'tuvwxyzab','kjihgfe');
+ INSERT INTO t1 VALUES(72,792,24024,72.072,2402.4,'uvwxyzabc','kjihgfe');
+ INSERT INTO t1 VALUES(73,803,25025,73.073,2502.5,'vwxyzabcd','jihgfed');
+ INSERT INTO t1 VALUES(74,814,25025,74.074,2502.5,'wxyzabcde','jihgfed');
+ INSERT INTO t1 VALUES(75,825,25025,75.075,2502.5,'xyzabcdef','jihgfed');
+ INSERT INTO t1 VALUES(76,836,26026,76.076,2602.6,'yzabcdefg','jihgfed');
+ INSERT INTO t1 VALUES(77,847,26026,77.077,2602.6,'zabcdefgh','jihgfed');
+ INSERT INTO t1 VALUES(78,858,26026,78.078,2602.6,'abcdefghi','ihgfedc');
+ INSERT INTO t1 VALUES(79,869,27027,79.079,2702.7,'bcdefghij','ihgfedc');
+ INSERT INTO t1 VALUES(80,880,27027,80.08,2702.7,'cdefghijk','ihgfedc');
+ INSERT INTO t1 VALUES(81,891,27027,81.081,2702.7,'defghijkl','ihgfedc');
+ INSERT INTO t1 VALUES(82,902,28028,82.082,2802.8,'efghijklm','ihgfedc');
+ INSERT INTO t1 VALUES(83,913,28028,83.083,2802.8,'fghijklmn','hgfedcb');
+ INSERT INTO t1 VALUES(84,924,28028,84.084,2802.8,'ghijklmno','hgfedcb');
+ INSERT INTO t1 VALUES(85,935,29029,85.085,2902.9,'hijklmnop','hgfedcb');
+ INSERT INTO t1 VALUES(86,946,29029,86.086,2902.9,'ijklmnopq','hgfedcb');
+ INSERT INTO t1 VALUES(87,957,29029,87.087,2902.9,'jklmnopqr','hgfedcb');
+ INSERT INTO t1 VALUES(88,968,30030,88.088,3003.0,'klmnopqrs','gfedcba');
+ INSERT INTO t1 VALUES(89,979,30030,89.089,3003.0,'lmnopqrst','gfedcba');
+ INSERT INTO t1 VALUES(90,NULL,30030,90.09,3003.0,'mnopqrstu','gfedcba');
+ INSERT INTO t1 VALUES(91,1001,NULL,91.091,3103.1,'nopqrstuv','gfedcba');
+ INSERT INTO t1 VALUES(92,1012,31031,NULL,3103.1,'opqrstuvw','gfedcba');
+ INSERT INTO t1 VALUES(93,1023,31031,93.093,NULL,'pqrstuvwx','fedcbaz');
+ INSERT INTO t1 VALUES(94,1034,32032,94.094,3203.2,NULL,'fedcbaz');
+ INSERT INTO t1 VALUES(95,1045,32032,95.095,3203.2,'rstuvwxyz',NULL);
+ INSERT INTO t1 VALUES(96,NULL,NULL,96.096,3203.2,'stuvwxyza','fedcbaz');
+ INSERT INTO t1 VALUES(97,1067,33033,NULL,NULL,'tuvwxyzab','fedcbaz');
+ INSERT INTO t1 VALUES(98,1078,33033,98.098,3303.3,NULL,NULL);
+ INSERT INTO t1 VALUES(99,NULL,NULL,NULL,NULL,NULL,NULL);
+ CREATE INDEX t1b ON t1(b);
+ CREATE INDEX t1c ON t1(c);
+ CREATE INDEX t1d ON t1(d);
+ CREATE INDEX t1e ON t1(e);
+ CREATE INDEX t1f ON t1(f);
+ CREATE INDEX t1g ON t1(g);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY,b,c,d,e,f,g);
+ INSERT INTO t2 SELECT * FROM t1;
+ CREATE INDEX t2b ON t2(b,c);
+ CREATE INDEX t2c ON t2(c,e);
+ CREATE INDEX t2d ON t2(d,g);
+ CREATE INDEX t2e ON t2(e,f,g);
+ CREATE INDEX t2f ON t2(f,b,d,c);
+ CREATE INDEX t2g ON t2(g,f);
+ CREATE TABLE t3(x,y);
+ INSERT INTO t3 VALUES(1,80);
+ INSERT INTO t3 VALUES(2,80);
+ CREATE TABLE t4(a INTEGER PRIMARY KEY,b,c,d,e,f,g);
+ INSERT INTO t4 SELECT * FROM t1;
+ CREATE INDEX t4b ON t4(b);
+ CREATE INDEX t4c ON t4(c);
+ }
+} {}
+
+do_test where9-1.2.1 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE b IS NULL
+ OR c IS NULL
+ OR d IS NULL
+ ORDER BY a
+ }
+} {90 91 92 96 97 99 scan 0 sort 1}
+do_test where9-1.2.2 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE +b IS NULL
+ OR c IS NULL
+ OR d IS NULL
+ ORDER BY a
+ }
+} {90 91 92 96 97 99 scan 98 sort 0}
+do_test where9-1.2.3 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE b IS NULL
+ OR +c IS NULL
+ OR d IS NULL
+ ORDER BY a
+ }
+} {90 91 92 96 97 99 scan 98 sort 0}
+do_test where9-1.2.4 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE b IS NULL
+ OR c IS NULL
+ OR +d IS NULL
+ ORDER BY a
+ }
+} {90 91 92 96 97 99 scan 98 sort 0}
+do_test where9-1.2.5 {
+ count_steps {
+ SELECT a FROM t4
+ WHERE b IS NULL
+ OR c IS NULL
+ OR d IS NULL
+ ORDER BY a
+ }
+} {90 91 92 96 97 99 scan 98 sort 0}
+
+do_test where9-1.3.1 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ ORDER BY a
+ }
+} {90 91 92 97 scan 0 sort 1}
+do_test where9-1.3.2 {
+ count_steps {
+ SELECT a FROM t4
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ ORDER BY a
+ }
+} {90 91 92 97 scan 98 sort 0}
+do_test where9-1.3.3 {
+ count_steps {
+ SELECT a FROM t4
+ WHERE (b NOT NULL AND c NOT NULL AND d IS NULL)
+ OR (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ ORDER BY a
+ }
+} {90 91 92 97 scan 98 sort 0}
+do_test where9-1.3.4 {
+ count_steps {
+ SELECT a FROM t4
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ ORDER BY a
+ }
+} {90 91 92 97 scan 98 sort 0}
+
+do_test where9-1.4 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE (b>=950 AND b<=1010) OR (b IS NULL AND c NOT NULL)
+ ORDER BY a
+ }
+} {87 88 89 90 91 scan 0 sort 1}
+do_test where9-1.5 {
+ # When this test was originally written, SQLite used a rowset object
+ # to optimize the "ORDER BY a" clause. Now that it is using a rowhash,
+ # this is not possible. So we have to comment out one term of the OR
+ # expression in order to prevent SQLite from deeming a full-table
+ # scan to be a better strategy than using multiple indexes, which would
+ # defeat the point of the test.
+ count_steps {
+ SELECT a FROM t1
+ WHERE a=83
+ OR b=913
+ OR c=28028
+ OR (d>=82 AND d<83)
+/* OR (e>2802 AND e<2803) */
+ OR f='fghijklmn'
+ OR g='hgfedcb'
+ ORDER BY a
+ }
+} {5 31 57 82 83 84 85 86 87 scan 0 sort 1}
+do_test where9-1.6 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE b=1012
+ OR (d IS NULL AND e IS NOT NULL)
+ }
+} {92 scan 0 sort 0}
+do_test where9-1.7 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE (b=1012 OR (d IS NULL AND e IS NOT NULL))
+ AND f!=g
+ }
+} {92 scan 0 sort 0}
+do_test where9-1.8 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE (b=1012 OR (d IS NULL AND e IS NOT NULL))
+ AND f==g
+ }
+} {scan 0 sort 0}
+
+do_test where9-2.1 {
+ count_steps {
+ SELECT t2.a FROM t1, t2
+ WHERE t1.a=80
+ AND (t1.c=t2.c OR t1.d=t2.d)
+ ORDER BY 1
+ }
+} {79 80 81 scan 0 sort 1}
+do_test where9-2.2 {
+ count_steps {
+ SELECT t2.a FROM t1, t2
+ WHERE t1.a=80
+ AND ((t1.c=t2.c AND t1.d=t2.d) OR t1.f=t2.f)
+ ORDER BY 1
+ }
+} {2 28 54 80 scan 0 sort 1}
+do_test where9-2.3 {
+ count_steps {
+ SELECT coalesce(t2.a,9999)
+ FROM t1 LEFT JOIN t2 ON (t1.c=t2.c AND t1.d=t2.d) OR t1.f=t2.f
+ WHERE t1.a=80
+ ORDER BY 1
+ }
+} {2 28 54 80 scan 0 sort 1}
+do_test where9-2.4 {
+ count_steps {
+ SELECT coalesce(t2.a,9999)
+ FROM t1 LEFT JOIN t2 ON (t1.c+1=t2.c AND t1.d=t2.d) OR (t1.f||'x')=t2.f
+ WHERE t1.a=80
+ ORDER BY 1
+ }
+} {9999 scan 0 sort 1}
+do_test where9-2.5 {
+ count_steps {
+ SELECT t1.a, coalesce(t2.a,9999)
+ FROM t1 LEFT JOIN t2 ON (t1.c=t2.c AND t1.d=t2.d) OR (t1.f)=t2.f
+ WHERE t1.a=80 OR t1.b=880 OR (t1.c=27027 AND round(t1.d)==80)
+ ORDER BY 1
+ }
+} {80 80 80 2 80 28 80 54 scan 0 sort 1}
+do_test where9-2.6 {
+ count_steps {
+ SELECT t1.a, coalesce(t2.a,9999)
+ FROM t1 LEFT JOIN t2 ON (t1.c+1=t2.c AND t1.d=t2.d) OR (t1.f||'x')=t2.f
+ WHERE t1.a=80 OR t1.b=880 OR (t1.c=27027 AND round(t1.d)==80)
+ ORDER BY 1
+ }
+} {80 9999 scan 0 sort 1}
+do_test where9-2.7 {
+ count_steps {
+ SELECT t3.x, t1.a, coalesce(t2.a,9999)
+ FROM t3 JOIN
+ t1 LEFT JOIN t2 ON (t1.c+1=t2.c AND t1.d=t2.d) OR (t1.f||'x')=t2.f
+ WHERE t1.a=t3.y OR t1.b=t3.y*11 OR (t1.c=27027 AND round(t1.d)==80)
+ ORDER BY 1, 2
+ }
+} {1 80 9999 2 80 9999 scan 1 sort 1}
+do_test where9-2.8 {
+ count_steps {
+ SELECT t3.x, t1.a, coalesce(t2.a,9999)
+ FROM t3 JOIN
+ t1 LEFT JOIN t2 ON (t1.c=t2.c AND t1.d=t2.d) OR (t1.f)=t2.f
+ WHERE t1.a=t3.y OR t1.b=t3.y*11 OR (t1.c=27027 AND round(t1.d)==80)
+ ORDER BY 1, 2, 3
+ }
+} {1 80 2 1 80 28 1 80 54 1 80 80 2 80 2 2 80 28 2 80 54 2 80 80 scan 1 sort 1}
+
+
+ifcapable explain {
+ do_execsql_test where9-3.1 {
+ EXPLAIN QUERY PLAN
+ SELECT t2.a FROM t1, t2
+ WHERE t1.a=80 AND ((t1.c=t2.c AND t1.d=t2.d) OR t1.f=t2.f)
+ } {
+ 0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+ 0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?) (~2 rows)}
+ 0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~5 rows)}
+ }
+ do_execsql_test where9-3.2 {
+ EXPLAIN QUERY PLAN
+ SELECT coalesce(t2.a,9999)
+ FROM t1 LEFT JOIN t2 ON (t1.c+1=t2.c AND t1.d=t2.d) OR (t1.f||'x')=t2.f
+ WHERE t1.a=80
+ } {
+ 0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
+ 0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?) (~2 rows)}
+ 0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~5 rows)}
+ }
+}
+
+# Make sure that INDEXED BY and multi-index OR clauses play well with
+# one another.
+#
+do_test where9-4.1 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE b>1000
+ AND (c=31031 OR d IS NULL)
+ ORDER BY +a
+ }
+} {92 93 97 scan 0 sort 1}
+do_test where9-4.2 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE b>1000
+ AND (c=31031 OR +d IS NULL)
+ ORDER BY +a
+ }
+} {92 93 97 scan 0 sort 1}
+do_test where9-4.3 {
+ count_steps {
+ SELECT a FROM t1
+ WHERE +b>1000
+ AND (c=31031 OR d IS NULL)
+ ORDER BY +a
+ }
+} {92 93 97 scan 0 sort 1}
+do_test where9-4.4 {
+ count_steps {
+ SELECT a FROM t1 INDEXED BY t1b
+ WHERE b>1000
+ AND (c=31031 OR d IS NULL)
+ ORDER BY +a
+ }
+} {92 93 97 scan 0 sort 1}
+do_test where9-4.5 {
+ catchsql {
+ SELECT a FROM t1 INDEXED BY t1b
+ WHERE +b>1000
+ AND (c=31031 OR d IS NULL)
+ ORDER BY +a
+ }
+} {1 {cannot use index: t1b}}
+do_test where9-4.6 {
+ count_steps {
+ SELECT a FROM t1 NOT INDEXED
+ WHERE b>1000
+ AND (c=31031 OR d IS NULL)
+ ORDER BY +a
+ }
+} {92 93 97 scan 98 sort 1}
+do_test where9-4.7 {
+ catchsql {
+ SELECT a FROM t1 INDEXED BY t1c
+ WHERE b>1000
+ AND (c=31031 OR d IS NULL)
+ ORDER BY +a
+ }
+} {1 {cannot use index: t1c}}
+do_test where9-4.8 {
+ catchsql {
+ SELECT a FROM t1 INDEXED BY t1d
+ WHERE b>1000
+ AND (c=31031 OR d IS NULL)
+ ORDER BY +a
+ }
+} {1 {cannot use index: t1d}}
+
+ifcapable explain {
+ # The (c=31031 OR d IS NULL) clause is preferred over b>1000 because
+ # the former is an equality test which is expected to return fewer rows.
+ #
+ do_execsql_test where9-5.1 {
+ EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c=31031 OR d IS NULL)
+ } {
+ 0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?) (~2 rows)}
+ 0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?) (~2 rows)}
+ }
+
+ # In contrast, b=1000 is preferred over any OR-clause.
+ #
+ do_execsql_test where9-5.2 {
+ EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b=1000 AND (c=31031 OR d IS NULL)
+ } {
+ 0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~5 rows)}
+ }
+
+ # Likewise, inequalities in an AND are preferred over inequalities in
+ # an OR.
+ #
+ do_execsql_test where9-5.3 {
+ EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c>=31031 OR d IS NULL)
+ } {
+ 0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>?) (~125000 rows)}
+ }
+}
+
+############################################################################
+# Make sure OR-clauses work correctly on UPDATE and DELETE statements.
+
+do_test where9-6.2.1 {
+ db eval {SELECT count(*) FROM t1 UNION ALL SELECT a FROM t1 WHERE a>=85}
+} {99 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99}
+
+do_test where9-6.2.2 { ;# Deletes entries 90 91 92 96 97 99
+ count_steps {
+ BEGIN;
+ DELETE FROM t1
+ WHERE b IS NULL
+ OR c IS NULL
+ OR d IS NULL
+ }
+} {scan 0 sort 0}
+
+do_test where9-6.2.3 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a>=85;
+ ROLLBACK;
+ }
+} {93 85 86 87 88 89 93 94 95 98}
+
+do_test where9-6.2.4 { ;# Deletes entries 90 91 92 96 97 99
+ count_steps {
+ BEGIN;
+ DELETE FROM t1
+ WHERE +b IS NULL
+ OR c IS NULL
+ OR d IS NULL
+ }
+} {scan 98 sort 0}
+
+do_test where9-6.2.5 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a>=85;
+ ROLLBACK;
+ }
+} {93 85 86 87 88 89 93 94 95 98}
+
+do_test where9-6.2.6 {
+ count_steps {
+ BEGIN;
+ UPDATE t1 SET a=a+100
+ WHERE (b IS NULL
+ OR c IS NULL
+ OR d IS NULL)
+ AND a!=92
+ AND a!=97
+ }
+} {scan 0 sort 0} ;# Add 100 to entries 90 91 96 99
+
+do_test where9-6.2.7 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a>=85;
+ ROLLBACK
+ }
+} {99 85 86 87 88 89 92 93 94 95 97 98 190 191 196 199}
+
+do_test where9-6.2.8 { ;# Deletes entries 90 91 92 97 99
+ count_steps {
+ BEGIN;
+ DELETE FROM t1
+ WHERE (b IS NULL
+ OR c IS NULL
+ OR d IS NULL)
+ AND a!=96
+ }
+} {scan 0 sort 0}
+
+do_test where9-6.2.9 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL SELECT a FROM t1 WHERE a>=85;
+ ROLLBACK;
+ }
+} {94 85 86 87 88 89 93 94 95 96 98}
+
+do_test where9-6.3.1 {
+ count_steps {
+ BEGIN;
+ DELETE FROM t1
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ }
+} {scan 0 sort 0} ;# DELETEs rows 90 91 92 97
+do_test where9-6.3.2 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;
+ ROLLBACK;
+ }
+} {95 85 86 87 88 89 93 94 95 96 98 99}
+
+do_test where9-6.3.3 {
+ count_steps {
+ BEGIN;
+ UPDATE t1 SET a=a+100
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ }
+} {scan 0 sort 0} ;# Add 100 to rowids 90 91 92 97
+do_test where9-6.3.4 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a BETWEEN 85 AND 200;
+ ROLLBACK;
+ }
+} {99 85 86 87 88 89 93 94 95 96 98 99 190 191 192 197}
+
+do_test where9-6.3.5 {
+ count_steps {
+ BEGIN;
+ DELETE FROM t1
+ WHERE (+b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ }
+} {scan 98 sort 0} ;# DELETEs rows 90 91 92 97
+do_test where9-6.3.6 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;
+ ROLLBACK;
+ }
+} {95 85 86 87 88 89 93 94 95 96 98 99}
+
+do_test where9-6.3.7 {
+ count_steps {
+ BEGIN;
+ UPDATE t1 SET a=a+100
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND +c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ }
+} {scan 98 sort 0} ;# Add 100 to rowids 90 91 92 97
+do_test where9-6.3.8 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;
+ ROLLBACK;
+ }
+} {99 85 86 87 88 89 93 94 95 96 98 99}
+
+
+do_test where9-6.4.1 {
+ count_steps {
+ BEGIN;
+ DELETE FROM t1
+ WHERE (b>=950 AND b<=1010) OR (b IS NULL AND c NOT NULL)
+ }
+} {scan 0 sort 0} ;# DELETE rows 87 88 89 90 91
+do_test where9-6.4.2 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;
+ ROLLBACK;
+ }
+} {94 85 86 92 93 94 95 96 97 98 99}
+do_test where9-6.4.3 {
+ count_steps {
+ BEGIN;
+ UPDATE t1 SET a=a+100
+ WHERE (b>=950 AND b<=1010) OR (b IS NULL AND c NOT NULL)
+ }
+} {scan 0 sort 0} ;# Add 100 to rowids 87 88 89 90 91
+do_test where9-6.4.4 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;
+ ROLLBACK;
+ }
+} {99 85 86 92 93 94 95 96 97 98 99}
+
+
+do_test where9-6.5.1 {
+ count_steps {
+ BEGIN;
+ DELETE FROM t1
+ WHERE a=83
+ OR b=913
+ OR c=28028
+ OR (d>=82 AND d<83)
+ OR (e>2802 AND e<2803)
+ OR f='fghijklmn'
+ OR g='hgfedcb'
+ }
+} {scan 0 sort 0} ;# DELETE rows 5 31 57 82 83 84 85 86 87
+do_test where9-6.5.2 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a IN (5,31,57,82,83,84,85,86,87);
+ ROLLBACK;
+ }
+} {90}
+
+do_test where9-6.5.3 {
+ count_steps {
+ BEGIN;
+ UPDATE t1 SET a=a+100
+ WHERE a=83
+ OR b=913
+ OR c=28028
+ OR (d>=82 AND d<83)
+ OR (e>2802 AND e<2803)
+ OR f='fghijklmn'
+ OR g='hgfedcb'
+ }
+} {scan 0 sort 0} ;# Add 100 to rowids 5 31 57 82 83 84 85 86 87
+do_test where9-6.5.4 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a%100 IN (5,31,57,82,83,84,85,86,87);
+ ROLLBACK;
+ }
+} {99 105 131 157 182 183 184 185 186 187}
+
+do_test where9-6.6.1 {
+ count_steps {
+ BEGIN;
+ DELETE FROM t1
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND +c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ }
+} {scan 98 sort 0} ;# DELETEs rows 90 91 92 97
+do_test where9-6.6.2 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;
+ ROLLBACK;
+ }
+} {95 85 86 87 88 89 93 94 95 96 98 99}
+
+do_test where9-6.6.3 {
+ count_steps {
+ BEGIN;
+ UPDATE t1 SET a=a+100
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND +c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ }
+} {scan 98 sort 0} ;# Add 100 to rowids 90 91 92 97
+do_test where9-6.6.4 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a BETWEEN 85 AND 200;
+ ROLLBACK;
+ }
+} {99 85 86 87 88 89 93 94 95 96 98 99 190 191 192 197}
+
+do_test where9-6.7.1 {
+ count_steps {
+ BEGIN;
+ DELETE FROM t1 NOT INDEXED
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ }
+} {scan 98 sort 0} ;# DELETEs rows 90 91 92 97
+do_test where9-6.7.2 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;
+ ROLLBACK;
+ }
+} {95 85 86 87 88 89 93 94 95 96 98 99}
+
+do_test where9-6.7.3 {
+ count_steps {
+ BEGIN;
+ UPDATE t1 NOT INDEXED SET a=a+100
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ }
+} {scan 98 sort 0} ;# Add 100 to rowids 90 91 92 97
+do_test where9-6.7.4 {
+ db eval {
+ SELECT count(*) FROM t1 UNION ALL
+ SELECT a FROM t1 WHERE a BETWEEN 85 AND 200;
+ ROLLBACK;
+ }
+} {99 85 86 87 88 89 93 94 95 96 98 99 190 191 192 197}
+
+do_test where9-6.8.1 {
+ catchsql {
+ DELETE FROM t1 INDEXED BY t1b
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ }
+} {1 {cannot use index: t1b}}
+do_test where9-6.8.2 {
+ catchsql {
+ UPDATE t1 INDEXED BY t1b SET a=a+100
+ WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
+ OR (b NOT NULL AND c IS NULL AND d NOT NULL)
+ OR (b NOT NULL AND c NOT NULL AND d IS NULL)
+ }
+} {1 {cannot use index: t1b}}
+
+############################################################################
+# Test cases where terms inside an OR series are combined with AND terms
+# external to the OR clause. In other words, cases where
+#
+# x AND (y OR z)
+#
+# is able to use indices on x,y and x,z, or indices y,x and z,x.
+#
+do_test where9-7.0 {
+ execsql {
+ CREATE TABLE t5(a, b, c, d, e, f, g, x, y);
+ INSERT INTO t5
+ SELECT a, b, c, e, d, f, g,
+ CASE WHEN (a&1)!=0 THEN 'y' ELSE 'n' END,
+ CASE WHEN (a&2)!=0 THEN 'y' ELSE 'n' END
+ FROM t1;
+ CREATE INDEX t5xb ON t5(x, b);
+ CREATE INDEX t5xc ON t5(x, c);
+ CREATE INDEX t5xd ON t5(x, d);
+ CREATE INDEX t5xe ON t5(x, e);
+ CREATE INDEX t5xf ON t5(x, f);
+ CREATE INDEX t5xg ON t5(x, g);
+ CREATE INDEX t5yb ON t5(y, b);
+ CREATE INDEX t5yc ON t5(y, c);
+ CREATE INDEX t5yd ON t5(y, d);
+ CREATE INDEX t5ye ON t5(y, e);
+ CREATE INDEX t5yf ON t5(y, f);
+ CREATE INDEX t5yg ON t5(y, g);
+ CREATE TABLE t6(a, b, c, e, d, f, g, x, y);
+ INSERT INTO t6 SELECT * FROM t5;
+ ANALYZE t5;
+ }
+} {}
+do_test where9-7.1.1 {
+ count_steps {
+ SELECT a FROM t5 WHERE x='y' AND (b=913 OR c=27027) ORDER BY a;
+ }
+} {79 81 83 scan 0 sort 1}
+do_test where9-7.1.2 {
+ execsql {
+ SELECT a FROM t6 WHERE x='y' AND (b=913 OR c=27027) ORDER BY a;
+ }
+} {79 81 83}
+do_test where9-7.1.3 {
+ count_steps {
+ SELECT a FROM t5 WHERE x='n' AND (b=913 OR c=27027) ORDER BY a;
+ }
+} {80 scan 0 sort 1}
+do_test where9-7.1.4 {
+ execsql {
+ SELECT a FROM t6 WHERE x='n' AND (b=913 OR c=27027) ORDER BY a;
+ }
+} {80}
+do_test where9-7.2.1 {
+ count_steps {
+ SELECT a FROM t5 WHERE (x='y' OR y='y') AND b=913 ORDER BY a;
+ }
+} {83 scan 0 sort 1}
+do_test where9-7.2.2 {
+ execsql {
+ SELECT a FROM t6 WHERE (x='y' OR y='y') AND b=913 ORDER BY a;
+ }
+} {83}
+do_test where9-7.3.1 {
+ count_steps {
+ SELECT a FROM t5 WHERE (x='y' OR y='y') AND c=27027 ORDER BY a;
+ }
+} {79 81 scan 0 sort 1}
+do_test where9-7.3.2 {
+ execsql {
+ SELECT a FROM t6 WHERE (x='y' OR y='y') AND c=27027 ORDER BY a;
+ }
+} {79 81}
+
+
+finish_test
diff --git a/test/whereA.test b/test/whereA.test
new file mode 100644
index 0000000..5d0aca5
--- /dev/null
+++ b/test/whereA.test
@@ -0,0 +1,156 @@
+# 2009 February 23
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the reverse_select_order pragma.
+#
+# $Id: whereA.test,v 1.3 2009/06/10 19:33:29 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test whereA-1.1 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 values(2,'hello','world');
+ INSERT INTO t1 VALUES(3,4.53,NULL);
+ SELECT * FROM t1
+ }
+} {1 2 3 2 hello world 3 4.53 {}}
+do_test whereA-1.2 {
+ db eval {
+ PRAGMA reverse_unordered_selects=1;
+ SELECT * FROM t1;
+ }
+} {3 4.53 {} 2 hello world 1 2 3}
+
+do_test whereA-1.3 {
+ db close
+ sqlite3 db test.db
+ db eval {
+ PRAGMA reverse_unordered_selects=1;
+ SELECT * FROM t1;
+ }
+} {3 4.53 {} 2 hello world 1 2 3}
+do_test whereA-1.4 {
+ db close
+ sqlite3 db test.db
+ db eval {
+ PRAGMA reverse_unordered_selects=1;
+ SELECT * FROM t1 ORDER BY rowid;
+ }
+} {1 2 3 2 hello world 3 4.53 {}}
+do_test whereA-1.5 {
+ db eval {
+ VACUUM;
+ SELECT * FROM t1 ORDER BY rowid;
+ }
+} {1 2 3 2 hello world 3 4.53 {}}
+do_test whereA-1.6 {
+ db eval {
+ PRAGMA reverse_unordered_selects;
+ }
+} {1}
+do_test whereA-1.7 {
+ db close
+ sqlite3 db test.db
+ db eval {
+ PRAGMA reverse_unordered_selects=1;
+ VACUUM;
+ SELECT * FROM t1;
+ }
+} {3 4.53 {} 2 hello world 1 2 3}
+
+do_test whereA-2.1 {
+ db eval {
+ PRAGMA reverse_unordered_selects=0;
+ SELECT * FROM t1 WHERE a>0;
+ }
+} {1 2 3 2 hello world 3 4.53 {}}
+do_test whereA-2.2 {
+ db eval {
+ PRAGMA reverse_unordered_selects=1;
+ SELECT * FROM t1 WHERE a>0;
+ }
+} {3 4.53 {} 2 hello world 1 2 3}
+
+do_test whereA-2.3 {
+ db eval {
+ PRAGMA reverse_unordered_selects=1;
+ SELECT * FROM t1 WHERE a>0 ORDER BY rowid;
+ }
+} {1 2 3 2 hello world 3 4.53 {}}
+
+do_test whereA-3.1 {
+ db eval {
+ PRAGMA reverse_unordered_selects=0;
+ SELECT * FROM t1 WHERE b>0;
+ }
+} {1 2 3 3 4.53 {} 2 hello world}
+do_test whereA-3.2 {
+ db eval {
+ PRAGMA reverse_unordered_selects=1;
+ SELECT * FROM t1 WHERE b>0;
+ }
+} {2 hello world 3 4.53 {} 1 2 3}
+do_test whereA-3.3 {
+ db eval {
+ PRAGMA reverse_unordered_selects=1;
+ SELECT * FROM t1 WHERE b>0 ORDER BY b;
+ }
+} {1 2 3 3 4.53 {} 2 hello world}
+
+do_test whereA-4.1 {
+ db eval {
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ SELECT x FROM t2;
+ }
+} {2 1}
+# Do an SQL statement. Append the search count to the end of the result.
+#
+proc count sql {
+ set ::sqlite_sort_count 0
+ return [concat [execsql $sql] $::sqlite_sort_count]
+}
+do_test whereA-4.2 { ;# Ticket #3904
+ db eval {
+ CREATE INDEX t2x ON t2(x);
+ }
+ count {
+ SELECT x FROM t2;
+ }
+} {2 1 0}
+do_test whereA-4.3 {
+ count {
+ SELECT x FROM t2 ORDER BY x;
+ }
+} {1 2 0}
+do_test whereA-4.4 {
+ count {
+ SELECT x FROM t2 ORDER BY x DESC;
+ }
+} {2 1 0}
+do_test whereA-4.5 {
+ db eval {DROP INDEX t2x;}
+ count {
+ SELECT x FROM t2 ORDER BY x;
+ }
+} {1 2 1}
+do_test whereA-4.6 {
+ count {
+ SELECT x FROM t2 ORDER BY x DESC;
+ }
+} {2 1 1}
+
+
+finish_test
diff --git a/test/whereB.test b/test/whereB.test
new file mode 100644
index 0000000..e443854
--- /dev/null
+++ b/test/whereB.test
@@ -0,0 +1,543 @@
+# 2009 August 13
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing WHERE clause conditions with
+# subtle affinity issues.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# For this set of tests:
+#
+# * t1.y holds an integer value with affinity NONE
+# * t2.b holds a text value with affinity TEXT
+#
+# These values are not equal and because neither affinity is NUMERIC
+# no type conversion occurs.
+#
+do_test whereB-1.1 {
+ db eval {
+ CREATE TABLE t1(x,y); -- affinity of t1.y is NONE
+ INSERT INTO t1 VALUES(1,99);
+
+ CREATE TABLE t2(a, b TEXT); -- affinity of t2.b is TEXT
+ CREATE INDEX t2b ON t2(b);
+ INSERT INTO t2 VALUES(2,99);
+
+ SELECT x, a, y=b FROM t1, t2 ORDER BY +x, +a;
+ }
+} {1 2 0}
+do_test whereB-1.2 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {}
+do_test whereB-1.3 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {}
+do_test whereB-1.4 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+do_test whereB-1.100 {
+ db eval {
+ DROP INDEX t2b;
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {}
+do_test whereB-1.101 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {}
+do_test whereB-1.102 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+
+# For this set of tests:
+#
+# * t1.y holds a text value with affinity TEXT
+# * t2.b holds an integer value with affinity NONE
+#
+# These values are not equal and because neither affinity is NUMERIC
+# no type conversion occurs.
+#
+do_test whereB-2.1 {
+ db eval {
+ DROP TABLE t1;
+ DROP TABLE t2;
+
+ CREATE TABLE t1(x, y TEXT); -- affinity of t1.y is TEXT
+ INSERT INTO t1 VALUES(1,99);
+
+ CREATE TABLE t2(a, b BLOB); -- affinity of t2.b is NONE
+ CREATE INDEX t2b ON t2(b);
+ INSERT INTO t2 VALUES(2,99);
+
+ SELECT x, a, y=b FROM t1, t2 ORDER BY +x, +a;
+ }
+} {1 2 0}
+do_test whereB-2.2 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {}
+do_test whereB-2.3 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {}
+do_test whereB-2.4 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+do_test whereB-2.100 {
+ db eval {
+ DROP INDEX t2b;
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {}
+do_test whereB-2.101 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {}
+do_test whereB-2.102 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+
+# For this set of tests:
+#
+# * t1.y holds a text value with affinity NONE
+# * t2.b holds an integer value with affinity NONE
+#
+# These values are not equal and because neither affinity is NUMERIC
+# no type conversion occurs.
+#
+do_test whereB-3.1 {
+ db eval {
+ DROP TABLE t1;
+ DROP TABLE t2;
+
+ CREATE TABLE t1(x, y BLOB); -- affinity of t1.y is NONE
+ INSERT INTO t1 VALUES(1,99);
+
+ CREATE TABLE t2(a, b BLOB); -- affinity of t2.b is NONE
+ CREATE INDEX t2b ON t2(b);
+ INSERT INTO t2 VALUES(2,'99');
+
+ SELECT x, a, y=b FROM t1, t2;
+ }
+} {1 2 0}
+do_test whereB-3.2 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {}
+do_test whereB-3.3 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {}
+do_test whereB-3.4 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+do_test whereB-3.100 {
+ db eval {
+ DROP INDEX t2b;
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {}
+do_test whereB-3.101 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {}
+do_test whereB-3.102 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+
+
+# For this set of tests:
+#
+# * t1.y holds a text value with affinity NONE
+# * t2.b holds an integer value with affinity NUMERIC
+#
+# Because t2.b has a numeric affinity, type conversion should occur
+# and the two fields should be equal.
+#
+do_test whereB-4.1 {
+ db eval {
+ DROP TABLE t1;
+ DROP TABLE t2;
+
+ CREATE TABLE t1(x, y BLOB); -- affinity of t1.y is NONE
+ INSERT INTO t1 VALUES(1,'99');
+
+ CREATE TABLE t2(a, b NUMERIC); -- affinity of t2.b is NUMERIC
+ CREATE INDEX t2b ON t2(b);
+ INSERT INTO t2 VALUES(2,99);
+
+ SELECT x, a, y=b FROM t1, t2;
+ }
+} {1 2 1}
+do_test whereB-4.2 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-4.3 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-4.4 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+do_test whereB-4.100 {
+ db eval {
+ DROP INDEX t2b;
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-4.101 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-4.102 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+
+
+
+# For this set of tests:
+#
+# * t1.y holds a text value with affinity NONE
+# * t2.b holds an integer value with affinity INTEGER
+#
+# Because t2.b has a numeric affinity, type conversion should occur
+# and the two fields should be equal.
+#
+do_test whereB-5.1 {
+ db eval {
+ DROP TABLE t1;
+ DROP TABLE t2;
+
+ CREATE TABLE t1(x, y BLOB); -- affinity of t1.y is NONE
+ INSERT INTO t1 VALUES(1,'99');
+
+ CREATE TABLE t2(a, b INT); -- affinity of t2.b is INTEGER
+ CREATE INDEX t2b ON t2(b);
+ INSERT INTO t2 VALUES(2,99);
+
+ SELECT x, a, y=b FROM t1, t2;
+ }
+} {1 2 1}
+do_test whereB-5.2 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-5.3 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-5.4 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+do_test whereB-5.100 {
+ db eval {
+ DROP INDEX t2b;
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-5.101 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-5.102 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+
+
+# For this set of tests:
+#
+# * t1.y holds a text value with affinity NONE
+# * t2.b holds an integer value with affinity REAL
+#
+# Because t2.b has a numeric affinity, type conversion should occur
+# and the two fields should be equal.
+#
+do_test whereB-6.1 {
+ db eval {
+ DROP TABLE t1;
+ DROP TABLE t2;
+
+ CREATE TABLE t1(x, y BLOB); -- affinity of t1.y is NONE
+ INSERT INTO t1 VALUES(1,'99');
+
+ CREATE TABLE t2(a, b REAL); -- affinity of t2.b is REAL
+ CREATE INDEX t2b ON t2(b);
+ INSERT INTO t2 VALUES(2,99.0);
+
+ SELECT x, a, y=b FROM t1, t2;
+ }
+} {1 2 1}
+do_test whereB-6.2 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-6.3 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-6.4 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+do_test whereB-6.100 {
+ db eval {
+ DROP INDEX t2b;
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-6.101 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-6.102 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+
+
+# For this set of tests:
+#
+# * t1.y holds an integer value with affinity NUMERIC
+# * t2.b holds a text value with affinity NONE
+#
+# Because t1.y has a numeric affinity, type conversion should occur
+# and the two fields should be equal.
+#
+do_test whereB-7.1 {
+ db eval {
+ DROP TABLE t1;
+ DROP TABLE t2;
+
+ CREATE TABLE t1(x, y NUMERIC); -- affinity of t1.y is NUMERIC
+ INSERT INTO t1 VALUES(1,99);
+
+ CREATE TABLE t2(a, b BLOB); -- affinity of t2.b is NONE
+ CREATE INDEX t2b ON t2(b);
+ INSERT INTO t2 VALUES(2,'99');
+
+ SELECT x, a, y=b FROM t1, t2;
+ }
+} {1 2 1}
+do_test whereB-7.2 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-7.3 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-7.4 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+do_test whereB-7.100 {
+ db eval {
+ DROP INDEX t2b;
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-7.101 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-7.102 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+
+# For this set of tests:
+#
+# * t1.y holds an integer value with affinity INTEGER
+# * t2.b holds a text value with affinity NONE
+#
+# Because t1.y has a numeric affinity, type conversion should occur
+# and the two fields should be equal.
+#
+do_test whereB-8.1 {
+ db eval {
+ DROP TABLE t1;
+ DROP TABLE t2;
+
+ CREATE TABLE t1(x, y INT); -- affinity of t1.y is INTEGER
+ INSERT INTO t1 VALUES(1,99);
+
+ CREATE TABLE t2(a, b BLOB); -- affinity of t2.b is NONE
+ CREATE INDEX t2b ON t2(b);
+ INSERT INTO t2 VALUES(2,'99');
+
+ SELECT x, a, y=b FROM t1, t2;
+ }
+} {1 2 1}
+do_test whereB-8.2 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-8.3 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-8.4 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+do_test whereB-8.100 {
+ db eval {
+ DROP INDEX t2b;
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-8.101 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-8.102 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+
+# For this set of tests:
+#
+# * t1.y holds an integer value with affinity REAL
+# * t2.b holds a text value with affinity NONE
+#
+# Because t1.y has a numeric affinity, type conversion should occur
+# and the two fields should be equal.
+#
+do_test whereB-9.1 {
+ db eval {
+ DROP TABLE t1;
+ DROP TABLE t2;
+
+ CREATE TABLE t1(x, y REAL); -- affinity of t1.y is REAL
+ INSERT INTO t1 VALUES(1,99.0);
+
+ CREATE TABLE t2(a, b BLOB); -- affinity of t2.b is NONE
+ CREATE INDEX t2b ON t2(b);
+ INSERT INTO t2 VALUES(2,'99');
+
+ SELECT x, a, y=b FROM t1, t2;
+ }
+} {1 2 1}
+do_test whereB-9.2 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-9.3 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-9.4 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+do_test whereB-9.100 {
+ db eval {
+ DROP INDEX t2b;
+ SELECT x, a, y=b FROM t1, t2 WHERE y=b;
+ }
+} {1 2 1}
+do_test whereB-9.101 {
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE b=y;
+ }
+} {1 2 1}
+do_test whereB-9.102 {
+ # In this case the unary "+" operator removes the column affinity so
+ # the columns compare false
+ db eval {
+ SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;
+ }
+} {}
+
+
+
+
+finish_test
diff --git a/test/wherelimit.test b/test/wherelimit.test
new file mode 100644
index 0000000..f0cfbb6
--- /dev/null
+++ b/test/wherelimit.test
@@ -0,0 +1,284 @@
+# 2008 October 6
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the LIMIT ... OFFSET ... clause
+# of UPDATE and DELETE statements.
+#
+# $Id: wherelimit.test,v 1.2 2008/10/10 18:25:46 shane Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc create_test_data {size} {
+ # Build some test data
+ #
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x int, y int);
+ BEGIN;
+ }
+ for {set i 1} {$i<=$size} {incr i} {
+ for {set j 1} {$j<=$size} {incr j} {
+ execsql "INSERT INTO t1 VALUES([expr {$i}],[expr {$j}])"
+ }
+ }
+ execsql {
+ COMMIT;
+ }
+ return {}
+}
+
+ifcapable {update_delete_limit} {
+
+ # check syntax error support
+ do_test wherelimit-0.1 {
+ catchsql {DELETE FROM t1 ORDER BY x}
+ } {1 {ORDER BY without LIMIT on DELETE}}
+ do_test wherelimit-0.2 {
+ catchsql {DELETE FROM t1 WHERE x=1 ORDER BY x}
+ } {1 {ORDER BY without LIMIT on DELETE}}
+ do_test wherelimit-0.3 {
+ catchsql {UPDATE t1 SET y=1 WHERE x=1 ORDER BY x}
+ } {1 {ORDER BY without LIMIT on UPDATE}}
+
+ # no AS on table sources
+ do_test wherelimit-0.4 {
+ catchsql {DELETE FROM t1 AS a WHERE x=1}
+ } {1 {near "AS": syntax error}}
+ do_test wherelimit-0.5 {
+ catchsql {UPDATE t1 AS a SET y=1 WHERE x=1}
+ } {1 {near "AS": syntax error}}
+
+ # OFFSET w/o LIMIT
+ do_test wherelimit-0.6 {
+ catchsql {DELETE FROM t1 WHERE x=1 OFFSET 2}
+ } {1 {near "OFFSET": syntax error}}
+ do_test wherelimit-0.7 {
+ catchsql {UPDATE t1 SET y=1 WHERE x=1 OFFSET 2}
+ } {1 {near "OFFSET": syntax error}}
+
+
+ # check deletes w/o where clauses but with limit/offsets
+ create_test_data 5
+ do_test wherelimit-1.0 {
+ execsql {SELECT count(*) FROM t1}
+ } {25}
+ do_test wherelimit-1.1 {
+ execsql {DELETE FROM t1}
+ execsql {SELECT count(*) FROM t1}
+ } {0}
+ create_test_data 5
+ do_test wherelimit-1.2 {
+ execsql {DELETE FROM t1 LIMIT 5}
+ execsql {SELECT count(*) FROM t1}
+ } {20}
+ do_test wherelimit-1.3 {
+ # limit 5
+ execsql {DELETE FROM t1 ORDER BY x LIMIT 5}
+ execsql {SELECT count(*) FROM t1}
+ } {15}
+ do_test wherelimit-1.4 {
+ # limit 5, offset 2
+ execsql {DELETE FROM t1 ORDER BY x LIMIT 5 OFFSET 2}
+ execsql {SELECT count(*) FROM t1}
+ } {10}
+ do_test wherelimit-1.5 {
+ # limit 5, offset -2
+ execsql {DELETE FROM t1 ORDER BY x LIMIT 5 OFFSET -2}
+ execsql {SELECT count(*) FROM t1}
+ } {5}
+ do_test wherelimit-1.6 {
+ # limit -5 (no limit), offset 2
+ execsql {DELETE FROM t1 ORDER BY x LIMIT 2, -5}
+ execsql {SELECT count(*) FROM t1}
+ } {2}
+ do_test wherelimit-1.7 {
+ # limit 5, offset -2 (no offset)
+ execsql {DELETE FROM t1 ORDER BY x LIMIT -2, 5}
+ execsql {SELECT count(*) FROM t1}
+ } {0}
+ create_test_data 5
+ do_test wherelimit-1.8 {
+ # limit -5 (no limit), offset -2 (no offset)
+ execsql {DELETE FROM t1 ORDER BY x LIMIT -2, -5}
+ execsql {SELECT count(*) FROM t1}
+ } {0}
+ create_test_data 3
+ do_test wherelimit-1.9 {
+ # limit 5, offset 2
+ execsql {DELETE FROM t1 ORDER BY x LIMIT 2, 5}
+ execsql {SELECT count(*) FROM t1}
+ } {4}
+ do_test wherelimit-1.10 {
+ # limit 5, offset 5
+ execsql {DELETE FROM t1 ORDER BY x LIMIT 5 OFFSET 5}
+ execsql {SELECT count(*) FROM t1}
+ } {4}
+ do_test wherelimit-1.11 {
+ # limit 50, offset 30
+ execsql {DELETE FROM t1 ORDER BY x LIMIT 50 OFFSET 30}
+ execsql {SELECT count(*) FROM t1}
+ } {4}
+ do_test wherelimit-1.12 {
+ # limit 50, offset 30
+ execsql {DELETE FROM t1 ORDER BY x LIMIT 30, 50}
+ execsql {SELECT count(*) FROM t1}
+ } {4}
+ do_test wherelimit-1.13 {
+ execsql {DELETE FROM t1 ORDER BY x LIMIT 50 OFFSET 50}
+ execsql {SELECT count(*) FROM t1}
+ } {4}
+
+
+ create_test_data 6
+ do_test wherelimit-2.0 {
+ execsql {SELECT count(*) FROM t1}
+ } {36}
+ do_test wherelimit-2.1 {
+ execsql {DELETE FROM t1 WHERE x=1}
+ execsql {SELECT count(*) FROM t1}
+ } {30}
+ create_test_data 6
+ do_test wherelimit-2.2 {
+ execsql {DELETE FROM t1 WHERE x=1 LIMIT 5}
+ execsql {SELECT count(*) FROM t1}
+ } {31}
+ do_test wherelimit-2.3 {
+ # limit 5
+ execsql {DELETE FROM t1 WHERE x=1 ORDER BY x LIMIT 5}
+ execsql {SELECT count(*) FROM t1}
+ } {30}
+ do_test wherelimit-2.4 {
+ # limit 5, offset 2
+ execsql {DELETE FROM t1 WHERE x=2 ORDER BY x LIMIT 5 OFFSET 2}
+ execsql {SELECT count(*) FROM t1}
+ } {26}
+ do_test wherelimit-2.5 {
+ # limit 5, offset -2
+ execsql {DELETE FROM t1 WHERE x=2 ORDER BY x LIMIT 5 OFFSET -2}
+ execsql {SELECT count(*) FROM t1}
+ } {24}
+ do_test wherelimit-2.6 {
+ # limit -5 (no limit), offset 2
+ execsql {DELETE FROM t1 WHERE x=3 ORDER BY x LIMIT 2, -5}
+ execsql {SELECT count(*) FROM t1}
+ } {20}
+ do_test wherelimit-2.7 {
+ # limit 5, offset -2 (no offset)
+ execsql {DELETE FROM t1 WHERE x=3 ORDER BY x LIMIT -2, 5}
+ execsql {SELECT count(*) FROM t1}
+ } {18}
+ do_test wherelimit-2.8 {
+ # limit -5 (no limit), offset -2 (no offset)
+ execsql {DELETE FROM t1 WHERE x=4 ORDER BY x LIMIT -2, -5}
+ execsql {SELECT count(*) FROM t1}
+ } {12}
+ create_test_data 6
+ do_test wherelimit-2.9 {
+ # limit 5, offset 2
+ execsql {DELETE FROM t1 WHERE x=5 ORDER BY x LIMIT 2, 5}
+ execsql {SELECT count(*) FROM t1}
+ } {32}
+ do_test wherelimit-2.10 {
+ # limit 5, offset 5
+ execsql {DELETE FROM t1 WHERE x=6 ORDER BY x LIMIT 5 OFFSET 5}
+ execsql {SELECT count(*) FROM t1}
+ } {31}
+ do_test wherelimit-2.11 {
+ # limit 50, offset 30
+ execsql {DELETE FROM t1 WHERE x=1 ORDER BY x LIMIT 50 OFFSET 30}
+ execsql {SELECT count(*) FROM t1}
+ } {31}
+ do_test wherelimit-2.12 {
+ # limit 50, offset 30
+ execsql {DELETE FROM t1 WHERE x=2 ORDER BY x LIMIT 30, 50}
+ execsql {SELECT count(*) FROM t1}
+ } {31}
+ do_test wherelimit-2.13 {
+ execsql {DELETE FROM t1 WHERE x=3 ORDER BY x LIMIT 50 OFFSET 50}
+ execsql {SELECT count(*) FROM t1}
+ } {31}
+
+
+ create_test_data 6
+ do_test wherelimit-3.0 {
+ execsql {SELECT count(*) FROM t1}
+ } {36}
+ do_test wherelimit-3.1 {
+ execsql {UPDATE t1 SET y=1 WHERE x=1}
+ execsql {SELECT count(*) FROM t1 WHERE y=1}
+ } {11}
+ create_test_data 6
+ do_test wherelimit-3.2 {
+ execsql {UPDATE t1 SET y=1 WHERE x=1 LIMIT 5}
+ execsql {SELECT count(*) FROM t1 WHERE y=1}
+ } {10}
+ do_test wherelimit-3.3 {
+ # limit 5
+ execsql {UPDATE t1 SET y=2 WHERE x=2 ORDER BY x LIMIT 5}
+ execsql {SELECT count(*) FROM t1 WHERE y=2}
+ } {9}
+ create_test_data 6
+ do_test wherelimit-3.4 {
+ # limit 5, offset 2
+ execsql {UPDATE t1 SET y=2 WHERE x=2 ORDER BY x LIMIT 5 OFFSET 2}
+ execsql {SELECT count(*) FROM t1 WHERE y=1}
+ } {6}
+ do_test wherelimit-3.5 {
+ # limit 5, offset -2
+ execsql {UPDATE t1 SET y=2 WHERE x=2 ORDER BY x LIMIT 5 OFFSET -2}
+ execsql {SELECT count(*) FROM t1 WHERE y=1}
+ } {5}
+ do_test wherelimit-3.6 {
+ # limit -5 (no limit), offset 2
+ execsql {UPDATE t1 SET y=3 WHERE x=3 ORDER BY x LIMIT 2, -5}
+ execsql {SELECT count(*) FROM t1 WHERE y=3}
+ } {8}
+ do_test wherelimit-3.7 {
+ # limit 5, offset -2 (no offset)
+ execsql {UPDATE t1 SET y=3 WHERE x=3 ORDER BY x LIMIT -2, 5}
+ execsql {SELECT count(*) FROM t1 WHERE y=3}
+ } {10}
+
+ do_test wherelimit-3.8 {
+ # limit -5 (no limit), offset -2 (no offset)
+ execsql {UPDATE t1 SET y=4 WHERE x=4 ORDER BY x LIMIT -2, -5}
+ execsql {SELECT count(*) FROM t1 WHERE y=4}
+ } {9}
+ create_test_data 6
+ do_test wherelimit-3.9 {
+ # limit 5, offset 2
+ execsql {UPDATE t1 SET y=4 WHERE x=5 ORDER BY x LIMIT 2, 5}
+ execsql {SELECT count(*) FROM t1 WHERE y=4}
+ } {9}
+ do_test wherelimit-3.10 {
+ # limit 5, offset 5
+ execsql {UPDATE t1 SET y=4 WHERE x=6 ORDER BY x LIMIT 5 OFFSET 5}
+ execsql {SELECT count(*) FROM t1 WHERE y=1}
+ } {6}
+ do_test wherelimit-3.11 {
+ # limit 50, offset 30
+ execsql {UPDATE t1 SET y=1 WHERE x=1 ORDER BY x LIMIT 50 OFFSET 30}
+ execsql {SELECT count(*) FROM t1 WHERE y=1}
+ } {6}
+ do_test wherelimit-3.12 {
+ # limit 50, offset 30
+ execsql {UPDATE t1 SET y=1 WHERE x=2 ORDER BY x LIMIT 30, 50}
+ execsql {SELECT count(*) FROM t1 WHERE y=1}
+ } {6}
+ do_test wherelimit-3.13 {
+ execsql {UPDATE t1 SET y=1 WHERE x=3 ORDER BY x LIMIT 50 OFFSET 50}
+ execsql {SELECT count(*) FROM t1 WHERE y=1}
+ } {6}
+
+}
+
+finish_test
diff --git a/test/win32lock.test b/test/win32lock.test
new file mode 100644
index 0000000..d014be4
--- /dev/null
+++ b/test/win32lock.test
@@ -0,0 +1,133 @@
+# 2011 July 11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is recovery from transient manditory locks
+# that sometimes appear on database files due to anti-virus software.
+#
+
+if {$tcl_platform(platform)!="windows"} return
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix win32lock
+
+db close
+sqlite3_shutdown
+test_sqlite3_log xLog
+proc xLog {error_code msg} {
+ lappend ::log $msg
+}
+sqlite3 db test.db
+
+do_test win32lock-1.1 {
+ db eval {
+ PRAGMA cache_size=10;
+ CREATE TABLE t1(x,y);
+ INSERT INTO t1 VALUES(1,randomblob(100000));
+ INSERT INTO t1 VALUES(2,randomblob(50000));
+ INSERT INTO t1 VALUES(3,randomblob(25000));
+ INSERT INTO t1 VALUES(4,randomblob(12500));
+ SELECT x, length(y) FROM t1 ORDER BY rowid;
+ }
+} {1 100000 2 50000 3 25000 4 12500}
+
+unset -nocomplain delay1 rc msg
+set old_pending_byte [sqlite3_test_control_pending_byte 0x40000000]
+
+set win32_lock_ok [list]
+set win32_lock_error [list]
+set delay1 25
+while {1} {
+ lock_win32_file test.db 0 $::delay1
+ set ::log {}
+ set rc [catch {db eval {SELECT x, length(y) FROM t1 ORDER BY rowid}} msg]
+ if {$rc} {
+ lappend win32_lock_error $::delay1
+ do_test win32lock-1.2-$delay1-error {
+ set ::msg
+ } {disk I/O error}
+ } else {
+ lappend win32_lock_ok $::delay1
+ do_test win32lock-1.2-$delay1-ok {
+ set ::msg
+ } {1 100000 2 50000 3 25000 4 12500}
+ if {[info exists ::log] && $::log!=""} {
+ do_test win32lock-1.2-$delay1-log1 {
+ regsub {\d+} $::log # x
+ set x
+ } {{delayed #ms for lock/sharing conflict}}
+ }
+ }
+ if {[llength $win32_lock_ok] && [llength $win32_lock_error]} break
+ incr delay1 25
+ if {$delay1 > 12500} {
+ puts "Timed out waiting for \"ok\" and \"error\" results."
+ break
+ }
+ sqlite3_sleep 10
+}
+
+do_test win32lock-2.0 {
+ file_control_win32_av_retry db -1 -1
+} {0 10 25}
+do_test win32lock-2.1 {
+ file_control_win32_av_retry db 1 1
+} {0 1 1}
+
+#
+# NOTE: It is known that the win32lock-2.2-* tests may fail if the system is
+# experiencing heavy load (i.e. they are very timing sensitive). This is
+# primarily due to the AV retry delay being set to 1 millisecond in the
+# win32lock-2.1 test (above). While it is important to test this corner
+# case for the AV retry logic, a failure of this test should probably not
+# be interpreted as a bug in SQLite or these test cases.
+#
+set win32_lock_ok [list]
+set win32_lock_error [list]
+set delay1 1
+while {1} {
+ lock_win32_file test.db 0 $::delay1
+ set ::log {}
+ set rc [catch {db eval {SELECT x, length(y) FROM t1 ORDER BY rowid}} msg]
+ if {$rc} {
+ lappend win32_lock_error $::delay1
+ do_test win32lock-2.2-$delay1-error {
+ set ::msg
+ } {disk I/O error}
+ } else {
+ lappend win32_lock_ok $::delay1
+ do_test win32lock-2.2-$delay1-ok {
+ set ::msg
+ } {1 100000 2 50000 3 25000 4 12500}
+ if {[info exists ::log] && $::log!=""} {
+ do_test win32lock-2.2-$delay1-log1 {
+ regsub {\d+} $::log # x
+ set x
+ } {{delayed #ms for lock/sharing conflict}}
+ }
+ }
+ if {[llength $win32_lock_ok] && [llength $win32_lock_error]} break
+ incr delay1 1
+ if {$delay1 > 500} {
+ puts "Timed out waiting for \"ok\" and \"error\" results."
+ break
+ }
+ sqlite3_sleep 10
+}
+
+file_control_win32_av_retry db 10 25
+sqlite3_test_control_pending_byte $old_pending_byte
+db close
+sqlite3_shutdown
+test_sqlite3_log
+sqlite3_initialize
+finish_test
diff --git a/test/zeroblob.test b/test/zeroblob.test
new file mode 100644
index 0000000..f4a1950
--- /dev/null
+++ b/test/zeroblob.test
@@ -0,0 +1,259 @@
+# 2007 May 02
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing of the zero-filled blob functionality
+# including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),
+# and the built-in zeroblob() SQL function.
+#
+# $Id: zeroblob.test,v 1.14 2009/07/14 02:33:02 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !incrblob {
+ finish_test
+ return
+}
+
+# When zeroblob() is used for the last field of a column, then the
+# content of the zeroblob is never instantiated on the VDBE stack.
+# But it does get inserted into the database correctly.
+#
+db eval {PRAGMA cache_size=10}
+sqlite3_memory_highwater 1
+unset -nocomplain memused
+set memused [sqlite3_memory_used]
+do_test zeroblob-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c,d);
+ }
+ set ::sqlite3_max_blobsize 0
+ execsql {
+ INSERT INTO t1 VALUES(2,3,4,zeroblob(1000000));
+ }
+ set ::sqlite3_max_blobsize
+} {10}
+do_test zeroblob-1.1.1 {
+ expr {[sqlite3_memory_highwater]<$::memused+25000}
+} {1}
+do_test zeroblob-1.2 {
+ execsql {
+ SELECT length(d) FROM t1
+ }
+} {1000000}
+
+# If a non-NULL column follows the zeroblob, then the content of
+# the zeroblob must be instantiated.
+#
+do_test zeroblob-1.3 {
+ set ::sqlite3_max_blobsize 0
+ execsql {
+ INSERT INTO t1 VALUES(3,4,zeroblob(10000),5);
+ }
+ set ::sqlite3_max_blobsize
+} {10010}
+do_test zeroblob-1.4 {
+ execsql {
+ SELECT length(c), length(d) FROM t1
+ }
+} {1 1000000 10000 1}
+
+# Multiple zeroblobs can appear at the end of record. No instantiation
+# of the blob content occurs on the stack.
+#
+do_test zeroblob-1.5 {
+ set ::sqlite3_max_blobsize 0
+ execsql {
+ INSERT INTO t1 VALUES(4,5,zeroblob(10000),zeroblob(10000));
+ }
+ set ::sqlite3_max_blobsize
+} {11}
+do_test zeroblob-1.6 {
+ execsql {
+ SELECT length(c), length(d) FROM t1
+ }
+} {1 1000000 10000 1 10000 10000}
+
+# NULLs can follow the zeroblob() or be intermixed with zeroblobs and
+# no instantiation of the zeroblobs occurs on the stack.
+#
+do_test zeroblob-1.7 {
+ set ::sqlite3_max_blobsize 0
+ execsql {
+ INSERT INTO t1 VALUES(5,zeroblob(10000),NULL,zeroblob(10000));
+ }
+ set ::sqlite3_max_blobsize
+} {10}
+do_test zeroblob-1.8 {
+ execsql {
+ SELECT length(b), length(d) FROM t1 WHERE a=5
+ }
+} {10000 10000}
+
+# Comparisons against zeroblobs work.
+#
+do_test zeroblob-2.1 {
+ execsql {
+ SELECT a FROM t1 WHERE b=zeroblob(10000)
+ }
+} {5}
+
+# Comparisons against zeroblobs work even when indexed.
+#
+do_test zeroblob-2.2 {
+ execsql {
+ CREATE INDEX i1_1 ON t1(b);
+ SELECT a FROM t1 WHERE b=zeroblob(10000);
+ }
+} {5}
+
+# DISTINCT works for zeroblobs
+#
+ifcapable bloblit&&subquery&&compound {
+ do_test zeroblob-3.1 {
+ execsql {
+ SELECT count(DISTINCT a) FROM (
+ SELECT x'00000000000000000000' AS a
+ UNION ALL
+ SELECT zeroblob(10) AS a
+ )
+ }
+ } {1}
+}
+
+# Concatentation works with zeroblob
+#
+ifcapable bloblit {
+ do_test zeroblob-4.1 {
+ execsql {
+ SELECT hex(zeroblob(2) || x'61')
+ }
+ } {000061}
+}
+
+# Check various CAST(...) operations on zeroblob.
+#
+do_test zeroblob-5.1 {
+ execsql {
+ SELECT CAST (zeroblob(100) AS REAL);
+ }
+} {0.0}
+do_test zeroblob-5.2 {
+ execsql {
+ SELECT CAST (zeroblob(100) AS INTEGER);
+ }
+} {0}
+do_test zeroblob-5.3 {
+ execsql {
+ SELECT CAST (zeroblob(100) AS TEXT);
+ }
+} {{}}
+do_test zeroblob-5.4 {
+ execsql {
+ SELECT CAST(zeroblob(100) AS BLOB);
+ }
+} [execsql {SELECT zeroblob(100)}]
+
+
+# Check for malicious use of zeroblob. Make sure nothing crashes.
+#
+do_test zeroblob-6.1.1 {
+ execsql {select zeroblob(-1)}
+} {{}}
+do_test zeroblob-6.1.2 {
+ execsql {select zeroblob(-10)}
+} {{}}
+do_test zeroblob-6.1.3 {
+ execsql {select zeroblob(-100)}
+} {{}}
+do_test zeroblob-6.2 {
+ execsql {select length(zeroblob(-1))}
+} {0}
+do_test zeroblob-6.3 {
+ execsql {select zeroblob(-1)|1}
+} {1}
+do_test zeroblob-6.4 {
+ catchsql {select length(zeroblob(2147483648))}
+} {1 {string or blob too big}}
+do_test zeroblob-6.5 {
+ catchsql {select zeroblob(2147483648)}
+} {1 {string or blob too big}}
+do_test zeroblob-6.6 {
+ execsql {select hex(zeroblob(-1))}
+} {{}}
+do_test zeroblob-6.7 {
+ execsql {select typeof(zeroblob(-1))}
+} {blob}
+
+# Test bind_zeroblob()
+#
+sqlite3_memory_highwater 1
+unset -nocomplain memused
+set memused [sqlite3_memory_used]
+do_test zeroblob-7.1 {
+ set ::STMT [sqlite3_prepare $::DB "SELECT length(?)" -1 DUMMY]
+ set ::sqlite3_max_blobsize 0
+ sqlite3_bind_zeroblob $::STMT 1 450000
+ sqlite3_step $::STMT
+} {SQLITE_ROW}
+do_test zeroblob-7.2 {
+ sqlite3_column_int $::STMT 0
+} {450000}
+do_test zeroblob-7.3 {
+ sqlite3_finalize $::STMT
+} {SQLITE_OK}
+do_test zeroblob-7.4 {
+ set ::sqlite3_max_blobsize
+} {0}
+do_test zeroblob-7.5 {
+ expr {[sqlite3_memory_highwater]<$::memused+10000}
+} {1}
+
+# Test that MakeRecord can handle a value with some real content
+# and a zero-blob tail.
+#
+do_test zeroblob-8.1 {
+ llength [execsql {
+ SELECT 'hello' AS a, zeroblob(10) as b from t1 ORDER BY a, b;
+ }]
+} {8}
+
+
+# Ticket #3965
+# zeroblobs on either size of an IN operator
+#
+do_test zeroblob-9.1 {
+ db eval {SELECT x'0000' IN (x'000000')}
+} {0}
+do_test zeroblob-9.2 {
+ db eval {SELECT x'0000' IN (x'0000')}
+} {1}
+do_test zeroblob-9.3 {
+ db eval {SELECT zeroblob(2) IN (x'000000')}
+} {0}
+do_test zeroblob-9.4 {
+ db eval {SELECT zeroblob(2) IN (x'0000')}
+} {1}
+do_test zeroblob-9.5 {
+ db eval {SELECT x'0000' IN (zeroblob(3))}
+} {0}
+do_test zeroblob-9.6 {
+ db eval {SELECT x'0000' IN (zeroblob(2))}
+} {1}
+do_test zeroblob-9.7 {
+ db eval {SELECT zeroblob(2) IN (zeroblob(3))}
+} {0}
+do_test zeroblob-9.8 {
+ db eval {SELECT zeroblob(2) IN (zeroblob(2))}
+} {1}
+
+
+finish_test